From c319f599e6ed085bcbd40fbe3eb3a780a0713b7e Mon Sep 17 00:00:00 2001 From: Charlotte Vermandel Date: Mon, 27 Jun 2022 15:52:19 +0200 Subject: [PATCH 1/3] Add types on settings and fix tests --- src/types/types.ts | 9 +++++++++ tests/settings.test.ts | 12 ++++++++++++ 2 files changed, 21 insertions(+) diff --git a/src/types/types.ts b/src/types/types.ts index 769c3fa28..f0615be51 100644 --- a/src/types/types.ts +++ b/src/types/types.ts @@ -162,6 +162,13 @@ export type TypoTolerance = { } } | null +export type Faceting = { + maxValuesPerFacet?: number | null +} +export type PaginationSettings = { + maxTotalHits?: number | null +} + export type Settings = { filterableAttributes?: FilterableAttributes distinctAttribute?: DistinctAttribute @@ -172,6 +179,8 @@ export type Settings = { stopWords?: StopWords synonyms?: Synonyms typoTolerance?: TypoTolerance + faceting?: Faceting + pagination?: PaginationSettings } /* diff --git a/tests/settings.test.ts b/tests/settings.test.ts index cf0ed0623..0eb327548 100644 --- a/tests/settings.test.ts +++ b/tests/settings.test.ts @@ -50,6 +50,12 @@ const defaultSettings = { disableOnWords: [], disableOnAttributes: [], }, + pagination: { + maxTotalHits: 1000, + }, + faceting: { + maxValuesPerFacet: 100, + }, } jest.setTimeout(100 * 1000) @@ -125,6 +131,12 @@ describe.each([{ permission: 'Master' }, { permission: 'Private' }])( disableOnWords: ['prince'], disableOnAttributes: ['comment'], }, + pagination: { + maxTotalHits: 1000, + }, + faceting: { + maxValuesPerFacet: 100, + }, } // Add the settings const task = await client.index(index.uid).updateSettings(newSettings) From ba04c47f0324eda4566762cf68c8c24d184ef2f1 Mon Sep 17 00:00:00 2001 From: Charlotte Vermandel Date: Mon, 27 Jun 2022 17:32:33 +0200 Subject: [PATCH 2/3] Fix esm env test --- tests/env/esm/src/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/env/esm/src/index.js b/tests/env/esm/src/index.js index 6a79377f9..96f6b2fb7 100644 --- a/tests/env/esm/src/index.js +++ b/tests/env/esm/src/index.js @@ -3,5 +3,5 @@ import * as DefaultMeiliSearch from '../../../../' const client = new MeiliSearch({ host:'http://localhost:7700', apiKey: 'masterKey'}) const defaultClient = new DefaultMeiliSearch.MeiliSearch({ host:'http://localhost:7700', apiKey: 'masterKey'}) -const token = client.generateTenantToken([]) +const token = client.generateTenantToken('e489fe16-3381-431b-bee3-00430192915d', []) console.log({ client, token, defaultClient }) From cb4e04f6495b9a1f825930234678f85f43ca6af9 Mon Sep 17 00:00:00 2001 From: Charlotte Vermandel Date: Mon, 27 Jun 2022 17:32:33 +0200 Subject: [PATCH 3/3] Fix esm env test --- tests/env/esm/src/index.js | 2 +- tests/env/typescript-browser/src/index.ts | 5 +++-- tests/env/typescript-node/src/index.ts | 2 +- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/tests/env/esm/src/index.js b/tests/env/esm/src/index.js index 6a79377f9..96f6b2fb7 100644 --- a/tests/env/esm/src/index.js +++ b/tests/env/esm/src/index.js @@ -3,5 +3,5 @@ import * as DefaultMeiliSearch from '../../../../' const client = new MeiliSearch({ host:'http://localhost:7700', apiKey: 'masterKey'}) const defaultClient = new DefaultMeiliSearch.MeiliSearch({ host:'http://localhost:7700', apiKey: 'masterKey'}) -const token = client.generateTenantToken([]) +const token = client.generateTenantToken('e489fe16-3381-431b-bee3-00430192915d', []) console.log({ client, token, defaultClient }) diff --git a/tests/env/typescript-browser/src/index.ts b/tests/env/typescript-browser/src/index.ts index a78d8dda3..5c1472bf7 100644 --- a/tests/env/typescript-browser/src/index.ts +++ b/tests/env/typescript-browser/src/index.ts @@ -1,4 +1,5 @@ -import { IndexObject, MeiliSearch } from '../../../../' +import { MeiliSearch } from '../../../../' +import { IndexObject } from '../../../../src' const config = { host: 'http://127.0.0.1:7700', @@ -20,5 +21,5 @@ function greeter(person: string) { user )} this is the list of all your indexes: \n ${uids.join(', ')}` - console.log(await client.generateTenantToken([])) // Resolved using the `browser` field + console.log(await client.generateTenantToken('e489fe16-3381-431b-bee3-00430192915d', [])) // Resolved using the `browser` field })() diff --git a/tests/env/typescript-node/src/index.ts b/tests/env/typescript-node/src/index.ts index 7218f9006..206cfd703 100644 --- a/tests/env/typescript-node/src/index.ts +++ b/tests/env/typescript-node/src/index.ts @@ -59,7 +59,7 @@ const indexUid = "movies" console.log(hit?._formatted?.title) }) - console.log(await client.generateTenantToken([])) + console.log(await client.generateTenantToken('e489fe16-3381-431b-bee3-00430192915d', [])) await index.delete() })()