Skip to content

Commit d01a22c

Browse files
committed
Merge branch 'main' into jsr
2 parents be2c2c0 + 69e056c commit d01a22c

File tree

77 files changed

+2435
-3400
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

77 files changed

+2435
-3400
lines changed

.code-samples.meilisearch.yaml

Lines changed: 17 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -417,47 +417,29 @@ primary_field_guide_add_document_primary_key: |-
417417
price: 5.00
418418
}
419419
], { primaryKey: 'reference_number' })
420-
getting_started_add_documents_md: |-
421-
```bash
422-
npm install meilisearch
423-
```
420+
getting_started_add_documents: |-
421+
// With npm:
422+
// npm install meilisearch
424423
425-
Or, if you are using `yarn`
426-
```bash
427-
yarn add meilisearch
428-
```
424+
// Or with yarn:
425+
// yarn add meilisearch
429426
430-
**Import**
431-
432-
`require` syntax:
433-
```js
427+
// In your .js file:
428+
// With the `require` syntax:
434429
const { MeiliSearch } = require('meilisearch')
435430
const movies = require('./movies.json')
436-
```
437-
438-
`import` syntax:
439-
```js
431+
// With the `import` syntax:
440432
import { MeiliSearch } from 'meilisearch'
441433
import movies from './movies.json'
442-
```
443434
444-
**Use**
445-
```js
446435
const client = new MeiliSearch({
447436
host: 'http://localhost:7700',
448437
apiKey: 'aSampleMasterKey'
449438
})
450439
client.index('movies').addDocuments(movies)
451440
.then((res) => console.log(res))
452-
```
453-
454-
[About this SDK](https://github.com/meilisearch/meilisearch-js/)
455-
getting_started_search_md: |-
456-
```js
441+
getting_started_search: |-
457442
client.index('movies').search('botman').then((res) => console.log(res))
458-
```
459-
460-
[About this SDK](https://github.com/meilisearch/meilisearch-js/)
461443
getting_started_update_ranking_rules: |-
462444
client.index('movies').updateRankingRules([
463445
'exactness',
@@ -528,8 +510,14 @@ get_filterable_attributes_1: |-
528510
update_filterable_attributes_1: |-
529511
client.index('movies')
530512
.updateFilterableAttributes([
531-
'genres',
532-
'director'
513+
"genres",
514+
{
515+
attributePatterns: ["genre"],
516+
features: {
517+
facetSearch: true,
518+
filter: { equality: true, comparison: false },
519+
},
520+
}
533521
])
534522
reset_filterable_attributes_1: |-
535523
client.index('movies').resetFilterableAttributes()

.github/release-draft-template.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,5 @@ replacers:
3131
replace: ''
3232
- search: '/(?:and )?@dependabot(?:\[bot\])?,?/g'
3333
replace: ''
34-
- search: '/(?:and )?@bors(?:\[bot\])?,?/g'
35-
replace: ''
3634
- search: '/(?:and )?@meili-bot,?/g'
3735
replace: ''

.github/workflows/tests.yml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,9 @@ env:
55

66
on:
77
pull_request:
8+
merge_group:
89
push:
9-
# trying and staging branches are for BORS config
1010
branches:
11-
- trying
12-
- staging
1311
- main
1412

1513
jobs:

CONTRIBUTING.md

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ Some notes on GitHub PRs:
9494

9595
- [Convert your PR as a draft](https://help.github.com/en/github/collaborating-with-issues-and-pull-requests/changing-the-stage-of-a-pull-request) if your changes are a work in progress: no one will review it until you pass your PR as ready for review.<br>
9696
The draft PR can be very useful if you want to show that you are working on something and make your work visible.
97-
- The branch related to the PR must be **up-to-date with `main`** before merging. Fortunately, this project [integrates a bot](https://github.com/meilisearch/integration-guides/blob/main/resources/bors.md) to automatically enforce this requirement without the PR author having to do it manually.
97+
- The branch related to the PR must be **up-to-date with `main`** before merging. Fortunately, this project uses [GitHub Merge Queues](https://github.blog/news-insights/product-news/github-merge-queue-is-generally-available/) to automatically enforce this requirement without the PR author having to rebase manually.
9898
- All PRs must be reviewed and approved by at least one maintainer.
9999
- The PR title should be accurate and descriptive of the changes. The title of the PR will be indeed automatically added to the next [release changelogs](https://github.com/meilisearch/meilisearch-js/releases/).
100100

@@ -104,8 +104,7 @@ Meilisearch tools follow the [Semantic Versioning Convention](https://semver.org
104104

105105
### Automation to Rebase and Merge the PRs
106106

107-
This project integrates a bot that helps us manage pull requests merging.<br>
108-
_[Read more about this](https://github.com/meilisearch/integration-guides/blob/main/resources/bors.md)._
107+
This project uses GitHub Merge Queues that helps us manage pull requests merging.
109108

110109
### Automated Changelogs
111110

README.md

Lines changed: 3 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
<a href="https://codecov.io/gh/meilisearch/meilisearch-js"><img src="https://codecov.io/github/meilisearch/meilisearch-js/coverage.svg?branch=main" alt="Codecov"></a>
2121
<a href="https://github.com/prettier/prettier"><img src="https://img.shields.io/badge/styled_with-prettier-ff69b4.svg" alt="Prettier"></a>
2222
<a href="https://github.com/meilisearch/meilisearch-js/blob/main/LICENSE"><img src="https://img.shields.io/badge/license-MIT-informational" alt="License"></a>
23-
<a href="https://ms-bors.herokuapp.com/repositories/10"><img src="https://bors.tech/images/badge_small.svg" alt="Bors enabled"></a>
23+
<a href="https://github.com/meilisearch/meilisearch-js/queue"><img alt="Merge Queues enabled" src="https://img.shields.io/badge/Merge_Queues-enabled-%2357cf60?logo=github"></a>
2424
</p>
2525

2626
<p align="center">⚡ The Meilisearch API client written for JavaScript</p>
@@ -564,34 +564,16 @@ client.index('myIndex').getTasks(parameters: TasksQuery): Promise<TasksResults>
564564
client.index('myIndex').getTask(uid: number): Promise<Task>
565565
```
566566

567-
568567
#### Wait for one task
569568

570-
571-
##### Using the client
572-
573-
```ts
574-
client.waitForTask(uid: number, { timeOutMs?: number, intervalMs?: number }): Promise<Task>
575-
```
576-
577-
##### Using the index
578-
579569
```ts
580-
client.index('myIndex').waitForTask(uid: number, { timeOutMs?: number, intervalMs?: number }): Promise<Task>
570+
client.tasks.waitForTask(uid: number, { timeout?: number, interval?: number }): Promise<Task>
581571
```
582572

583573
#### Wait for multiple tasks
584574

585-
##### Using the client
586-
587-
```ts
588-
client.waitForTasks(uids: number[], { timeOutMs?: number, intervalMs?: number }): Promise<Task[]>
589-
```
590-
591-
##### Using the index
592-
593575
```ts
594-
client.index('myIndex').waitForTasks(uids: number[], { timeOutMs?: number, intervalMs?: number }): Promise<Task[]>
576+
client.tasks.waitForTasks(uids: number[], { timeout?: number, interval?: number }): Promise<Task[]>
595577
```
596578

597579
### Batches <!-- omit in toc -->

bors.toml

Lines changed: 0 additions & 9 deletions
This file was deleted.

eslint.config.js

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -29,30 +29,12 @@ export default tseslint.config([
2929
},
3030
},
3131
rules: {
32-
// TODO: Remove the ones between "~~", adapt code
33-
// ~~
34-
"@typescript-eslint/prefer-as-const": "off",
35-
"@typescript-eslint/ban-ts-comment": "off",
36-
"@typescript-eslint/no-unsafe-call": "off",
37-
"@typescript-eslint/no-unsafe-member-access": "off",
38-
"@typescript-eslint/no-unsafe-return": "off",
39-
"@typescript-eslint/no-unsafe-assignment": "off",
40-
"@typescript-eslint/no-unsafe-argument": "off",
41-
"@typescript-eslint/no-floating-promises": "off",
42-
// ~~
43-
"@typescript-eslint/array-type": ["warn", { default: "array-simple" }],
44-
// TODO: Should be careful with this rule, should leave it be and disable
45-
// it within files where necessary with explanations
46-
"@typescript-eslint/no-explicit-any": "off",
4732
"@typescript-eslint/no-unused-vars": [
4833
"error",
4934
// argsIgnorePattern: https://eslint.org/docs/latest/rules/no-unused-vars#argsignorepattern
5035
// varsIgnorePattern: https://eslint.org/docs/latest/rules/no-unused-vars#varsignorepattern
5136
{ args: "all", argsIgnorePattern: "^_", varsIgnorePattern: "^_" },
5237
],
53-
// TODO: Not recommended to disable rule, should instead disable locally
54-
// with explanation
55-
"@typescript-eslint/ban-ts-ignore": "off",
5638
},
5739
},
5840
// Vitest

package.json

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "meilisearch",
3-
"version": "0.49.0",
3+
"version": "0.50.0",
44
"description": "The Meilisearch JS client for Node.js and the browser.",
55
"keywords": [
66
"meilisearch",
@@ -36,7 +36,7 @@
3636
"sideEffects": false,
3737
"repository": {
3838
"type": "git",
39-
"url": "https://github.com/meilisearch/meilisearch-js"
39+
"url": "https://github.com/meilisearch/meilisearch-js.git"
4040
},
4141
"scripts": {
4242
"playground:javascript": "vite serve playgrounds/javascript --open",
@@ -70,25 +70,24 @@
7070
"CONTRIBUTING.md"
7171
],
7272
"devDependencies": {
73-
"@eslint/js": "^9.19.0",
74-
"@types/eslint__js": "^8.42.3",
75-
"@vitest/coverage-v8": "^3.0.7",
76-
"@types/node": "^22.13.8",
77-
"@typescript-eslint/utils": "^8.22.0",
78-
"@vitest/eslint-plugin": "^1.1.25",
79-
"eslint": "^9.21.0",
80-
"eslint-config-prettier": "^10.0.2",
73+
"@eslint/js": "^9.23.0",
74+
"@vitest/coverage-v8": "^3.1.1",
75+
"@types/node": "^22.13.15",
76+
"@typescript-eslint/utils": "^8.29.0",
77+
"@vitest/eslint-plugin": "^1.1.38",
78+
"eslint": "^9.23.0",
79+
"eslint-config-prettier": "^10.1.1",
8180
"eslint-plugin-tsdoc": "^0.4.0",
8281
"typescript": "^5.8.2",
83-
"vite": "^6.2.0",
82+
"vite": "^6.2.6",
8483
"globals": "^16.0.0",
8584
"husky": "^9.1.7",
86-
"lint-staged": "15.4.3",
87-
"prettier": "^3.5.2",
85+
"lint-staged": "15.5.0",
86+
"prettier": "^3.5.3",
8887
"prettier-plugin-jsdoc": "^1.3.2",
89-
"typedoc": "^0.27.9",
90-
"typescript-eslint": "^8.25.0",
91-
"vitest": "^3.0.7"
88+
"typedoc": "^0.28.1",
89+
"typescript-eslint": "^8.29.0",
90+
"vitest": "^3.1.1"
9291
},
9392
"packageManager": "[email protected]"
9493
}

playgrounds/javascript/src/meilisearch.ts

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -12,23 +12,22 @@ const index = client.index<{ id: number; title: string; genres: string[] }>(
1212
export async function addDocuments(): Promise<void> {
1313
await client.deleteIndexIfExists(indexUid);
1414

15-
const task1 = await client.createIndex(indexUid);
16-
await client.waitForTask(task1.taskUid);
17-
18-
const task2 = await index.addDocuments([
19-
{ id: 1, title: "Carol", genres: ["Romance", "Drama"] },
20-
{ id: 2, title: "Wonder Woman", genres: ["Action", "Adventure"] },
21-
{ id: 3, title: "Life of Pi", genres: ["Adventure", "Drama"] },
22-
{
23-
id: 4,
24-
title: "Mad Max: Fury Road",
25-
genres: ["Adventure", "Science Fiction"],
26-
},
27-
{ id: 5, title: "Moana", genres: ["Fantasy", "Action"] },
28-
{ id: 6, title: "Philadelphia", genres: ["Drama"] },
29-
]);
30-
31-
await client.index(indexUid).waitForTask(task2.taskUid);
15+
await client.createIndex(indexUid).waitTask();
16+
17+
await index
18+
.addDocuments([
19+
{ id: 1, title: "Carol", genres: ["Romance", "Drama"] },
20+
{ id: 2, title: "Wonder Woman", genres: ["Action", "Adventure"] },
21+
{ id: 3, title: "Life of Pi", genres: ["Adventure", "Drama"] },
22+
{
23+
id: 4,
24+
title: "Mad Max: Fury Road",
25+
genres: ["Adventure", "Science Fiction"],
26+
},
27+
{ id: 5, title: "Moana", genres: ["Fantasy", "Action"] },
28+
{ id: 6, title: "Philadelphia", genres: ["Drama"] },
29+
])
30+
.waitTask();
3231
}
3332

3433
export async function getAllHits(element: HTMLDivElement): Promise<void> {

src/batch.ts

Lines changed: 24 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -1,69 +1,38 @@
11
import type {
2-
Config,
3-
BatchObject,
4-
BatchesQuery,
2+
Batch,
53
BatchesResults,
6-
BatchesResultsObject,
7-
} from "./types.js";
8-
import { HttpRequests } from "./http-requests.js";
9-
10-
class Batch {
11-
uid: BatchObject["uid"];
12-
details: BatchObject["details"];
13-
stats: BatchObject["stats"];
14-
startedAt: BatchObject["startedAt"];
15-
finishedAt: BatchObject["finishedAt"];
16-
duration: BatchObject["duration"];
17-
progress: BatchObject["progress"];
18-
19-
constructor(batch: BatchObject) {
20-
this.uid = batch.uid;
21-
this.details = batch.details;
22-
this.stats = batch.stats;
23-
this.startedAt = batch.startedAt;
24-
this.finishedAt = batch.finishedAt;
25-
this.duration = batch.duration;
26-
this.progress = batch.progress;
27-
}
28-
}
29-
30-
class BatchClient {
31-
httpRequest: HttpRequests;
32-
33-
constructor(config: Config) {
34-
this.httpRequest = new HttpRequests(config);
4+
TasksOrBatchesQuery,
5+
} from "./types/index.js";
6+
import type { HttpRequests } from "./http-requests.js";
7+
8+
/**
9+
* Class for handling batches.
10+
*
11+
* @see {@link https://www.meilisearch.com/docs/reference/api/batches}
12+
*/
13+
export class BatchClient {
14+
readonly #httpRequest: HttpRequests;
15+
16+
constructor(httpRequests: HttpRequests) {
17+
this.#httpRequest = httpRequests;
3518
}
3619

37-
/**
38-
* Get one batch
39-
*
40-
* @param uid - Unique identifier of the batch
41-
* @returns
42-
*/
20+
/** {@link https://www.meilisearch.com/docs/reference/api/batches#get-one-batch} */
4321
async getBatch(uid: number): Promise<Batch> {
44-
const batch = await this.httpRequest.get<BatchObject>({
22+
const batch = await this.#httpRequest.get<Batch>({
4523
path: `batches/${uid}`,
4624
});
47-
return new Batch(batch);
25+
return batch;
4826
}
4927

50-
/**
51-
* Get batches
52-
*
53-
* @param parameters - Parameters to browse the batches
54-
* @returns Promise containing all batches
55-
*/
56-
async getBatches(batchesQuery?: BatchesQuery): Promise<BatchesResults> {
57-
const batches = await this.httpRequest.get<BatchesResultsObject>({
28+
/** {@link https://www.meilisearch.com/docs/reference/api/batches#get-batches} */
29+
async getBatches(
30+
batchesQuery?: TasksOrBatchesQuery,
31+
): Promise<BatchesResults> {
32+
const batches = await this.#httpRequest.get<BatchesResults>({
5833
path: "batches",
5934
params: batchesQuery,
6035
});
61-
62-
return {
63-
...batches,
64-
results: batches.results.map((batch) => new Batch(batch)),
65-
};
36+
return batches;
6637
}
6738
}
68-
69-
export { BatchClient, Batch };

0 commit comments

Comments
 (0)