Skip to content

Commit 63a815d

Browse files
committed
Merge with main
2 parents db16378 + d8d2abe commit 63a815d

20 files changed

+869
-372
lines changed

.code-samples.meilisearch.yaml

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -99,35 +99,35 @@ multi_search_1: |-
9999
},
100100
]})
101101
get_all_tasks_1: |-
102-
client.getTasks()
102+
client.tasks.getTasks()
103103
get_task_1: |-
104-
client.getTask(1)
104+
client.tasks.getTask(1)
105105
async_guide_filter_by_date_1: |-
106-
client.getTasks({ afterEnqueuedAt: '2020-10-11T11:49:53.000Z' })
106+
client.tasks.getTasks({ afterEnqueuedAt: '2020-10-11T11:49:53.000Z' })
107107
async_guide_multiple_filters_1: |-
108-
client.getTasks({
108+
client.tasks.getTasks({
109109
indexUids: ['movies'],
110110
types: ['documentAdditionOrUpdate','documentDeletion'],
111111
statuses: ['processing']
112112
})
113113
async_guide_filter_by_ids_1: |-
114-
client.getTasks({ uids: [5, 10, 13] })
114+
client.tasks.getTasks({ uids: [5, 10, 13] })
115115
async_guide_filter_by_statuses_1: |-
116-
client.getTasks({ statuses: ['failed', 'canceled'] })
116+
client.tasks.getTasks({ statuses: ['failed', 'canceled'] })
117117
async_guide_filter_by_types_1: |-
118-
client.getTasks({ types: ['dumpCreation', 'indexSwap'] })
118+
client.tasks.getTasks({ types: ['dumpCreation', 'indexSwap'] })
119119
async_guide_filter_by_index_uids_1: |-
120-
client.getTasks({ indexUids: ['movies'] })
120+
client.tasks.getTasks({ indexUids: ['movies'] })
121121
get_all_tasks_paginating_1: |-
122-
client.getTasks({ limit: 2, from: 10 })
122+
client.tasks.getTasks({ limit: 2, from: 10 })
123123
get_all_tasks_paginating_2: |-
124-
client.getTasks({ limit: 2, from: 8 })
124+
client.tasks.getTasks({ limit: 2, from: 8 })
125125
async_guide_canceled_by_1: |-
126-
client.getTasks({ canceledBy: [9, 15] })
126+
client.tasks.getTasks({ canceledBy: [9, 15] })
127127
delete_tasks_1: |-
128-
client.deleteTasks({ uids: [1, 2] })
128+
client.tasks.deleteTasks({ uids: [1, 2] })
129129
cancel_tasks_1: |-
130-
client.cancelTasks({ uids: [1, 2] })
130+
client.tasks.cancelTasks({ uids: [1, 2] })
131131
get_one_key_1: |-
132132
client.getKey('6062abda-a5aa-4414-ac91-ecd7944c0f8d')
133133
get_all_keys_1: |-
@@ -458,7 +458,7 @@ getting_started_update_searchable_attributes: |-
458458
getting_started_update_stop_words: |-
459459
client.index('movies').updateStopWords(['the'])
460460
getting_started_check_task_status: |-
461-
client.getTask(0)
461+
client.tasks.getTask(0)
462462
getting_started_synonyms: |-
463463
client.index('movies').updateSynonyms({
464464
winnie: ['piglet'],
@@ -806,9 +806,9 @@ update_prefix_search_settings_1: |-
806806
reset_prefix_search_settings_1: |-
807807
client.index('INDEX_NAME').resetPrefixSearch();
808808
get_all_batches_1: |-
809-
client.getBatches();
809+
client.batches.getBatches();
810810
get_batch_1: |-
811-
client.getBatch(BATCH_UID);
811+
client.batches.getBatch(BATCH_UID);
812812
# Vector search
813813
update_embedders_1: |-
814814
client.index('INDEX_NAME').updateEmbedders({

.github/workflows/meilisearch-prototype-tests.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ jobs:
4646
- '7700:7700'
4747
strategy:
4848
matrix:
49-
node: ['18', '20', '22']
49+
node: ['20', '22']
5050
name: integration-tests (Node.js ${{ matrix.node }})
5151
steps:
5252
- uses: actions/checkout@v4

.github/workflows/pre-release-tests.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ jobs:
4343
- '7700:7700'
4444
strategy:
4545
matrix:
46-
node: ['18', '20', '22']
46+
node: ['20', '22']
4747
name: integration-tests (Node.js ${{ matrix.node }})
4848
steps:
4949
- uses: actions/checkout@v4

.github/workflows/tests.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ jobs:
3636
strategy:
3737
fail-fast: false
3838
matrix:
39-
node: ['18', '20', '22']
39+
node: ['20', '22']
4040
name: integration-tests (Node.js ${{ matrix.node }})
4141
steps:
4242
- uses: actions/checkout@v4

CONTRIBUTING.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ First of all, thank you for contributing to Meilisearch! The goal of this docume
3434

3535
To run this project, you will need:
3636

37-
- Node >= v18 and Node <= 22
37+
- Node >= v20 and Node <= 22
3838
- Yarn v1.x
3939

4040
### Setup

docker-compose.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
services:
22
package:
3-
image: node:18
3+
image: node:22
44
tty: true
55
stdin_open: true
66
working_dir: /home/package

package.json

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -71,21 +71,21 @@
7171
"devDependencies": {
7272
"@eslint/js": "^9.23.0",
7373
"@vitest/coverage-v8": "^3.1.1",
74-
"@types/node": "^22.15.3",
74+
"@types/node": "^22.15.29",
7575
"@typescript-eslint/utils": "^8.29.0",
76-
"@vitest/eslint-plugin": "^1.1.38",
77-
"eslint": "^9.25.1",
76+
"@vitest/eslint-plugin": "^1.2.1",
77+
"eslint": "^9.28.0",
7878
"eslint-config-prettier": "^10.1.2",
7979
"eslint-plugin-tsdoc": "^0.4.0",
8080
"typescript": "^5.8.3",
81-
"vite": "^6.3.4",
82-
"globals": "^16.0.0",
81+
"vite": "^6.3.5",
82+
"globals": "^16.2.0",
8383
"husky": "^9.1.7",
84-
"lint-staged": "15.5.1",
84+
"lint-staged": "16.1.0",
8585
"prettier": "^3.5.3",
8686
"prettier-plugin-jsdoc": "^1.3.2",
87-
"typedoc": "^0.28.3",
88-
"typescript-eslint": "^8.31.1",
87+
"typedoc": "^0.28.5",
88+
"typescript-eslint": "^8.33.0",
8989
"vitest": "^3.1.1"
9090
},
9191
"packageManager": "[email protected]"

src/batch.ts

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -19,20 +19,11 @@ export class BatchClient {
1919

2020
/** {@link https://www.meilisearch.com/docs/reference/api/batches#get-one-batch} */
2121
async getBatch(uid: number): Promise<Batch> {
22-
const batch = await this.#httpRequest.get<Batch>({
23-
path: `batches/${uid}`,
24-
});
25-
return batch;
22+
return await this.#httpRequest.get({ path: `batches/${uid}` });
2623
}
2724

2825
/** {@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>({
33-
path: "batches",
34-
params: batchesQuery,
35-
});
36-
return batches;
26+
async getBatches(params?: TasksOrBatchesQuery): Promise<BatchesResults> {
27+
return await this.#httpRequest.get({ path: "batches", params });
3728
}
3829
}

src/http-requests.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,9 +69,8 @@ function getHeaders(config: Config, headersInit?: HeadersInit): Headers {
6969
return headers;
7070
}
7171

72-
// TODO: Convert to Symbol("timeout id") when Node.js 18 is dropped
7372
/** Used to identify whether an error is a timeout error after fetch request. */
74-
const TIMEOUT_ID = {};
73+
const TIMEOUT_ID = Symbol("<timeout>");
7574

7675
/**
7776
* Attach a timeout signal to a {@link RequestInit}, while preserving original

src/task.ts

Lines changed: 7 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,11 @@ import type {
1212
} from "./types/index.js";
1313
import type { HttpRequests } from "./http-requests.js";
1414

15-
// TODO: Convert to Symbol("timeout id") when Node.js 18 is dropped
1615
/**
1716
* Used to identify whether an error is a timeout error in
1817
* {@link TaskClient.waitForTask}.
1918
*/
20-
const TIMEOUT_ID = {};
19+
const TIMEOUT_ID = Symbol("<task timeout>");
2120

2221
/**
2322
* @returns A function which defines an extra function property on a
@@ -74,24 +73,20 @@ export class TaskClient {
7473
// TODO: Need to do this for all other methods: https://github.com/meilisearch/meilisearch-js/issues/1476
7574
extraRequestInit?: ExtraRequestInit,
7675
): Promise<Task> {
77-
const task = await this.#httpRequest.get<Task>({
76+
return await this.#httpRequest.get({
7877
path: `tasks/${uid}`,
7978
extraRequestInit,
8079
});
81-
return task;
8280
}
8381

8482
/** {@link https://www.meilisearch.com/docs/reference/api/tasks#get-tasks} */
8583
async getTasks(params?: TasksOrBatchesQuery): Promise<TasksResults> {
86-
const tasks = await this.#httpRequest.get<TasksResults>({
87-
path: "tasks",
88-
params,
89-
});
90-
return tasks;
84+
return await this.#httpRequest.get({ path: "tasks", params });
9185
}
9286

9387
/**
94-
* Wait for an enqueued task to be processed.
88+
* Wait for an enqueued task to be processed. This is done through polling
89+
* with {@link TaskClient.getTask}.
9590
*
9691
* @remarks
9792
* If an {@link EnqueuedTask} needs to be awaited instantly, it is recommended
@@ -167,20 +162,14 @@ export class TaskClient {
167162
/** {@link https://www.meilisearch.com/docs/reference/api/tasks#cancel-tasks} */
168163
cancelTasks(params: DeleteOrCancelTasksQuery): EnqueuedTaskPromise {
169164
return this.#applyWaitTask(
170-
this.#httpRequest.post({
171-
path: "tasks/cancel",
172-
params,
173-
}),
165+
this.#httpRequest.post({ path: "tasks/cancel", params }),
174166
);
175167
}
176168

177169
/** {@link https://www.meilisearch.com/docs/reference/api/tasks#delete-tasks} */
178170
deleteTasks(params: DeleteOrCancelTasksQuery): EnqueuedTaskPromise {
179171
return this.#applyWaitTask(
180-
this.#httpRequest.delete({
181-
path: "tasks",
182-
params,
183-
}),
172+
this.#httpRequest.delete({ path: "tasks", params }),
184173
);
185174
}
186175
}

0 commit comments

Comments
 (0)