Skip to content

Commit 30b147e

Browse files
authored
Merge branch 'main' into remove-nodejs-18
2 parents b19b464 + 77505c0 commit 30b147e

13 files changed

+414
-356
lines changed

.code-samples.meilisearch.yaml

Lines changed: 9 additions & 27 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',

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ name: Meilisearch prototype tests
33

44
env:
55
HUSKY: 0
6+
NODE_OPTIONS: '--trace-warnings'
67

78
# Will only run for PRs and pushes to *-beta
89
on:

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ name: Pre-Release Tests
33

44
env:
55
HUSKY: 0
6+
NODE_OPTIONS: '--trace-warnings'
67

78
# Will only run for PRs and pushes to bump-meilisearch-v*
89
on:

.github/workflows/tests.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ name: Tests
22

33
env:
44
HUSKY: 0
5+
NODE_OPTIONS: '--trace-warnings'
56

67
on:
78
pull_request:

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.13.15",
74+
"@types/node": "^22.15.3",
7575
"@typescript-eslint/utils": "^8.29.0",
7676
"@vitest/eslint-plugin": "^1.1.38",
77-
"eslint": "^9.23.0",
78-
"eslint-config-prettier": "^10.1.1",
77+
"eslint": "^9.25.1",
78+
"eslint-config-prettier": "^10.1.2",
7979
"eslint-plugin-tsdoc": "^0.4.0",
80-
"typescript": "^5.8.2",
81-
"vite": "^6.2.6",
80+
"typescript": "^5.8.3",
81+
"vite": "^6.3.4",
8282
"globals": "^16.0.0",
8383
"husky": "^9.1.7",
84-
"lint-staged": "15.5.0",
84+
"lint-staged": "15.5.1",
8585
"prettier": "^3.5.3",
8686
"prettier-plugin-jsdoc": "^1.3.2",
87-
"typedoc": "^0.28.1",
88-
"typescript-eslint": "^8.29.0",
87+
"typedoc": "^0.28.3",
88+
"typescript-eslint": "^8.31.1",
8989
"vitest": "^3.1.1"
9090
},
9191
"packageManager": "[email protected]"

src/meilisearch.ts

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ import type {
2828
ExtraRequestInit,
2929
Network,
3030
RecordAny,
31+
RuntimeTogglableFeatures,
3132
} from "./types/index.js";
3233
import { ErrorStatusCode } from "./types/index.js";
3334
import { HttpRequests } from "./http-requests.js";
@@ -454,4 +455,25 @@ export class MeiliSearch {
454455
path: "snapshots",
455456
});
456457
}
458+
459+
///
460+
/// EXPERIMENTAL-FEATURES
461+
///
462+
463+
/** {@link https://www.meilisearch.com/docs/reference/api/experimental_features#get-all-experimental-features} */
464+
async getExperimentalFeatures(): Promise<RuntimeTogglableFeatures> {
465+
return await this.httpRequest.get({
466+
path: "experimental-features",
467+
});
468+
}
469+
470+
/** {@link https://www.meilisearch.com/docs/reference/api/experimental_features#configure-experimental-features} */
471+
async updateExperimentalFeatures(
472+
runtimeTogglableFeatures: RuntimeTogglableFeatures,
473+
): Promise<RuntimeTogglableFeatures> {
474+
return await this.httpRequest.patch({
475+
path: "experimental-features",
476+
body: runtimeTogglableFeatures,
477+
});
478+
}
457479
}

src/types/experimental-features.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
/**
2+
* {@link https://www.meilisearch.com/docs/reference/api/experimental_features#experimental-features-object}
3+
*
4+
* @see `meilisearch::routes::features::RuntimeTogglableFeatures`
5+
*/
6+
export type RuntimeTogglableFeatures = {
7+
metrics?: boolean | null;
8+
logsRoute?: boolean | null;
9+
editDocumentsByFunction?: boolean | null;
10+
containsFilter?: boolean | null;
11+
network?: boolean | null;
12+
getTaskDocumentsRoute?: boolean | null;
13+
compositeEmbedders?: boolean | null;
14+
};

src/types/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
export * from "./experimental-features.js";
12
export * from "./task_and_batch.js";
23
export * from "./token.js";
34
export * from "./types.js";

tests/documents.test.ts

Lines changed: 17 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -680,17 +680,13 @@ describe("Documents tests", () => {
680680
test(`${permission} key: test updateDocumentsByFunction`, async () => {
681681
const client = await getClient(permission);
682682
const index = client.index<(typeof dataset)[number]>(indexPk.uid);
683-
const adminKey = await getKey("Admin");
684683

685684
await index.updateFilterableAttributes(["id"]).waitTask();
686685

687-
await fetch(`${HOST}/experimental-features`, {
688-
body: JSON.stringify({ editDocumentsByFunction: true }),
689-
headers: {
690-
Authorization: `Bearer ${adminKey}`,
691-
"Content-Type": "application/json",
692-
},
693-
method: "PATCH",
686+
await (
687+
await getClient("Master")
688+
).updateExperimentalFeatures({
689+
editDocumentsByFunction: true,
694690
});
695691

696692
await index.addDocuments(dataset).waitTask();
@@ -761,15 +757,11 @@ describe("Documents tests", () => {
761757

762758
test(`${permission} key: Try updateDocumentsByFunction and be denied`, async () => {
763759
const client = await getClient(permission);
764-
const adminKey = await getKey("Admin");
765760

766-
await fetch(`${HOST}/experimental-features`, {
767-
body: JSON.stringify({ editDocumentsByFunction: true }),
768-
headers: {
769-
Authorization: `Bearer ${adminKey}`,
770-
"Content-Type": "application/json",
771-
},
772-
method: "PATCH",
761+
await (
762+
await getClient("Master")
763+
).updateExperimentalFeatures({
764+
editDocumentsByFunction: true,
773765
});
774766

775767
await expect(
@@ -848,15 +840,11 @@ describe("Documents tests", () => {
848840

849841
test(`${permission} key: Try updateDocumentsByFunction and be denied`, async () => {
850842
const client = await getClient(permission);
851-
const adminKey = await getKey("Admin");
852843

853-
await fetch(`${HOST}/experimental-features`, {
854-
body: JSON.stringify({ editDocumentsByFunction: true }),
855-
headers: {
856-
Authorization: `Bearer ${adminKey}`,
857-
"Content-Type": "application/json",
858-
},
859-
method: "PATCH",
844+
await (
845+
await getClient("Master")
846+
).updateExperimentalFeatures({
847+
editDocumentsByFunction: true,
860848
});
861849

862850
await expect(
@@ -962,15 +950,11 @@ describe("Documents tests", () => {
962950
const route = `indexes/${indexPk.uid}/documents/edit`;
963951
const client = new MeiliSearch({ host });
964952
const strippedHost = trailing ? host.slice(0, -1) : host;
965-
const adminKey = await getKey("Admin");
966-
967-
await fetch(`${HOST}/experimental-features`, {
968-
body: JSON.stringify({ editDocumentsByFunction: true }),
969-
headers: {
970-
Authorization: `Bearer ${adminKey}`,
971-
"Content-Type": "application/json",
972-
},
973-
method: "PATCH",
953+
954+
await (
955+
await getClient("Master")
956+
).updateExperimentalFeatures({
957+
editDocumentsByFunction: true,
974958
});
975959

976960
await expect(

tests/embedders.test.ts

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,7 @@ import {
66
BAD_HOST,
77
MeiliSearch,
88
getClient,
9-
getKey,
10-
HOST,
9+
masterClient,
1110
} from "./utils/meilisearch-test-utils.js";
1211

1312
const index = {
@@ -239,16 +238,9 @@ describe.each([{ permission: "Master" }, { permission: "Admin" }])(
239238
});
240239

241240
test(`${permission} key: Update embedders with composite embedder`, async () => {
242-
const adminKey = await getKey("Admin");
243-
244241
// first enable the network endpoint.
245-
await fetch(`${HOST}/experimental-features`, {
246-
body: JSON.stringify({ compositeEmbedders: true }),
247-
headers: {
248-
Authorization: `Bearer ${adminKey}`,
249-
"Content-Type": "application/json",
250-
},
251-
method: "PATCH",
242+
await masterClient.updateExperimentalFeatures({
243+
compositeEmbedders: true,
252244
});
253245

254246
const client = await getClient(permission);

0 commit comments

Comments
 (0)