From 7646593c5414050f4254b67e4a45412c3f649394 Mon Sep 17 00:00:00 2001 From: meili-bot <74670311+meili-bot@users.noreply.github.com> Date: Fri, 21 Mar 2025 10:07:25 +0100 Subject: [PATCH 1/9] Update README.md From 27d014651b0e3a8a3c547f1230d094d4ebf8767a Mon Sep 17 00:00:00 2001 From: Strift Date: Tue, 15 Apr 2025 11:02:48 +0900 Subject: [PATCH 2/9] Bump meilisearch-js to v0.50 --- packages/instant-meilisearch/package.json | 2 +- yarn.lock | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/packages/instant-meilisearch/package.json b/packages/instant-meilisearch/package.json index ee92442b..1bbeea51 100644 --- a/packages/instant-meilisearch/package.json +++ b/packages/instant-meilisearch/package.json @@ -44,7 +44,7 @@ "templates" ], "dependencies": { - "meilisearch": "^0.49.0" + "meilisearch": "0.50" }, "devDependencies": { "cssnano": "^4.1.10", diff --git a/yarn.lock b/yarn.lock index 86b9ca3c..d256d0bf 100644 --- a/yarn.lock +++ b/yarn.lock @@ -4683,10 +4683,10 @@ mdn-data@2.0.4: resolved "https://registry.npmjs.org/mdn-data/-/mdn-data-2.0.4.tgz" integrity sha512-iV3XNKw06j5Q7mi6h+9vbx23Tv7JkjEVgKHW4pimwyDGWm0OIQntJJ+u1C6mg6mK1EaTv42XQ7w76yuzH7M2cA== -meilisearch@^0.49.0: - version "0.49.0" - resolved "https://registry.yarnpkg.com/meilisearch/-/meilisearch-0.49.0.tgz#21584739588cd33cc970e1abbcb4d6240e6928d6" - integrity sha512-oMJ/e6Or6cz2+owcEKeB11p2OWiWW9NmssqOZC/KIwQB0sBGKLJ7RCpYzf+GhUIZIZ9FRYZ419ox3RGebVQX5g== +meilisearch@0.50: + version "0.50.0" + resolved "https://registry.yarnpkg.com/meilisearch/-/meilisearch-0.50.0.tgz#b2eb92984100f33fe2c5dc19600bdc643776170e" + integrity sha512-9IzIkobvnuS18Eg4dq/eJB9W+eXqeLZjNRgq/kKMswSmVYYSQsXqGgSuCA0JkF+o5RwJlwIsieQee6rh313VhA== meow@^6.0.0: version "6.1.1" From 7ee3be530870494d6f19f6661568eb0417b5f0a5 Mon Sep 17 00:00:00 2001 From: Strift Date: Tue, 15 Apr 2025 11:20:25 +0900 Subject: [PATCH 3/9] Replace requestConfig by requestInit --- packages/instant-meilisearch/src/client/config/index.ts | 8 ++++---- .../src/client/instant-meilisearch-client.ts | 4 ++-- packages/instant-meilisearch/src/types/types.ts | 2 +- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/packages/instant-meilisearch/src/client/config/index.ts b/packages/instant-meilisearch/src/client/config/index.ts index c9922d63..b5fcb259 100644 --- a/packages/instant-meilisearch/src/client/config/index.ts +++ b/packages/instant-meilisearch/src/client/config/index.ts @@ -61,7 +61,7 @@ export function validateInstantMeiliSearchParams( apiKey: string | (() => string), instantMeiliSearchOptions: InstantMeiliSearchOptions ) { - const { requestConfig, httpClient } = instantMeiliSearchOptions + const { requestInit, httpClient } = instantMeiliSearchOptions // Validate host url if (typeof hostUrl !== 'string') { throw new TypeError( @@ -76,9 +76,9 @@ export function validateInstantMeiliSearchParams( ) } - // Validate requestConfig - if (requestConfig !== undefined && !isPureObject(requestConfig)) { - throw new TypeError('Provided requestConfig should be an object') + // Validate requestInit + if (requestInit !== undefined && !isPureObject(requestInit)) { + throw new TypeError('Provided requestInit should be an object') } // Validate custom HTTP client diff --git a/packages/instant-meilisearch/src/client/instant-meilisearch-client.ts b/packages/instant-meilisearch/src/client/instant-meilisearch-client.ts index c90740f3..fc1a9997 100644 --- a/packages/instant-meilisearch/src/client/instant-meilisearch-client.ts +++ b/packages/instant-meilisearch/src/client/instant-meilisearch-client.ts @@ -68,8 +68,8 @@ export function instantMeiliSearch( meilisearchConfig.httpClient = instantMeiliSearchOptions.httpClient } - if (instantMeiliSearchOptions.requestConfig !== undefined) { - meilisearchConfig.requestConfig = instantMeiliSearchOptions.requestConfig + if (instantMeiliSearchOptions.requestInit !== undefined) { + meilisearchConfig.requestInit = instantMeiliSearchOptions.requestInit } const meilisearchClient = new MeiliSearch(meilisearchConfig) diff --git a/packages/instant-meilisearch/src/types/types.ts b/packages/instant-meilisearch/src/types/types.ts index 3b0e26de..ebfa9849 100644 --- a/packages/instant-meilisearch/src/types/types.ts +++ b/packages/instant-meilisearch/src/types/types.ts @@ -71,7 +71,7 @@ type BaseInstantMeiliSearchOptions = { export type InstantMeiliSearchOptions = Pick< MeilisearchConfig, - 'requestConfig' | 'httpClient' + 'requestInit' | 'httpClient' > & BaseInstantMeiliSearchOptions From 774b53fe68f614e333f4546780859e96d3b035cb Mon Sep 17 00:00:00 2001 From: Strift Date: Tue, 15 Apr 2025 13:33:58 +0900 Subject: [PATCH 4/9] Use new waitTask() function --- .../search/__tests__/fetchMeilisearchResults.test.ts | 3 +-- .../__tests__/configure.attributes-to-retrieve.test.ts | 7 +++---- .../__tests__/custom-http-client.test.ts | 9 ++++----- .../__tests__/disjunctive-facet-search.test.ts | 4 +--- .../instant-meilisearch/__tests__/facet-stats.test.ts | 8 ++++---- .../__tests__/facets-distribution.test.ts | 8 ++++---- packages/instant-meilisearch/__tests__/filter.test.ts | 8 ++++---- .../__tests__/first-facets-distribution.test.ts | 9 ++++----- .../instant-meilisearch/__tests__/geosearch.test.ts | 10 +++++----- .../instant-meilisearch/__tests__/highlight.test.ts | 8 ++++---- .../__tests__/multi-index-search.test.ts | 10 ++++------ .../overridden-meilisearch-parameters.test.ts | 7 +++---- .../instant-meilisearch/__tests__/pagination.test.ts | 8 ++++---- .../__tests__/placeholder-search.test.ts | 8 ++++---- .../instant-meilisearch/__tests__/snippets.test.ts | 8 ++++---- packages/instant-meilisearch/__tests__/sort.test.ts | 9 ++++----- 16 files changed, 57 insertions(+), 67 deletions(-) diff --git a/packages/autocomplete-client/src/search/__tests__/fetchMeilisearchResults.test.ts b/packages/autocomplete-client/src/search/__tests__/fetchMeilisearchResults.test.ts index 1a409711..70c1a860 100644 --- a/packages/autocomplete-client/src/search/__tests__/fetchMeilisearchResults.test.ts +++ b/packages/autocomplete-client/src/search/__tests__/fetchMeilisearchResults.test.ts @@ -14,8 +14,7 @@ const SECOND_ITEM_ID = MOVIES[1].id beforeAll(async () => { await meilisearchClient.deleteIndex(INDEX_NAME) - const task = await meilisearchClient.index(INDEX_NAME).addDocuments(MOVIES) - await meilisearchClient.waitForTask(task.taskUid) + await meilisearchClient.index(INDEX_NAME).addDocuments(MOVIES).waitTask() }) afterAll(async () => { diff --git a/packages/instant-meilisearch/__tests__/configure.attributes-to-retrieve.test.ts b/packages/instant-meilisearch/__tests__/configure.attributes-to-retrieve.test.ts index c6fb5adc..3fa97531 100644 --- a/packages/instant-meilisearch/__tests__/configure.attributes-to-retrieve.test.ts +++ b/packages/instant-meilisearch/__tests__/configure.attributes-to-retrieve.test.ts @@ -8,13 +8,12 @@ import { describe('Instant Meilisearch Browser test', () => { beforeAll(async () => { - const deleteTask = await meilisearchClient.deleteIndex('movies') - await meilisearchClient.waitForTask(deleteTask.taskUid) + await meilisearchClient.deleteIndex('movies').waitTask() - const documentsTask = await meilisearchClient + await meilisearchClient .index('movies') .addDocuments(dataset) - await meilisearchClient.index('movies').waitForTask(documentsTask.taskUid) + .waitTask() }) test('attributesToRetrieve on no attributes', async () => { diff --git a/packages/instant-meilisearch/__tests__/custom-http-client.test.ts b/packages/instant-meilisearch/__tests__/custom-http-client.test.ts index abc386ba..4729294c 100644 --- a/packages/instant-meilisearch/__tests__/custom-http-client.test.ts +++ b/packages/instant-meilisearch/__tests__/custom-http-client.test.ts @@ -4,17 +4,16 @@ import { meilisearchClient, dataset } from './assets/utils.js' describe('Custom HTTP client tests', () => { beforeAll(async () => { - const deleteTask = await meilisearchClient.deleteIndex('movies') - await meilisearchClient.waitForTask(deleteTask.taskUid) + await meilisearchClient.deleteIndex('movies').waitTask() - const documentsTask = await meilisearchClient + await meilisearchClient .index('movies') .addDocuments(dataset) - await meilisearchClient.index('movies').waitForTask(documentsTask.taskUid) + .waitTask() }) test('a custom HTTP client', async () => { - const httpClient = vi.fn(async (url: string, init?: RequestInit) => { + const httpClient = vi.fn(async (url: RequestInfo | URL, init?: RequestInit) => { const result = await fetch(url, init) return await result.json() }) diff --git a/packages/instant-meilisearch/__tests__/disjunctive-facet-search.test.ts b/packages/instant-meilisearch/__tests__/disjunctive-facet-search.test.ts index 3080627d..a4858605 100644 --- a/packages/instant-meilisearch/__tests__/disjunctive-facet-search.test.ts +++ b/packages/instant-meilisearch/__tests__/disjunctive-facet-search.test.ts @@ -22,9 +22,7 @@ describe('Keep zero facets tests', () => { }) await moviesIndex.addDocuments(movies) - const response = await gamesIndex.addDocuments(games) - - await meilisearchClient.waitForTask(response.taskUid) + await gamesIndex.addDocuments(games).waitTask() }) test('searching on one index with facet filtering', async () => { diff --git a/packages/instant-meilisearch/__tests__/facet-stats.test.ts b/packages/instant-meilisearch/__tests__/facet-stats.test.ts index 7429d65a..6a97b30b 100644 --- a/packages/instant-meilisearch/__tests__/facet-stats.test.ts +++ b/packages/instant-meilisearch/__tests__/facet-stats.test.ts @@ -3,15 +3,15 @@ import { searchClient, dataset, meilisearchClient } from './assets/utils.js' describe('Facet stats tests', () => { beforeAll(async () => { - const deleteTask = await meilisearchClient.deleteIndex('movies') - await meilisearchClient.waitForTask(deleteTask.taskUid) + await meilisearchClient.deleteIndex('movies').waitTask() await meilisearchClient .index('movies') .updateFilterableAttributes(['genres', 'release_date', 'id']) - const documentsTask = await meilisearchClient + .waitTask() + await meilisearchClient .index('movies') .addDocuments(dataset) - await meilisearchClient.index('movies').waitForTask(documentsTask.taskUid) + .waitTask() }) test('Facet stats on an empty facets array', async () => { diff --git a/packages/instant-meilisearch/__tests__/facets-distribution.test.ts b/packages/instant-meilisearch/__tests__/facets-distribution.test.ts index 67417e17..252757b2 100644 --- a/packages/instant-meilisearch/__tests__/facets-distribution.test.ts +++ b/packages/instant-meilisearch/__tests__/facets-distribution.test.ts @@ -3,15 +3,15 @@ import { searchClient, dataset, meilisearchClient } from './assets/utils.js' describe('Instant Meilisearch Browser test', () => { beforeAll(async () => { - const deleteTask = await meilisearchClient.deleteIndex('movies') - await meilisearchClient.waitForTask(deleteTask.taskUid) + await meilisearchClient.deleteIndex('movies').waitTask() await meilisearchClient .index('movies') .updateFilterableAttributes(['genres']) - const documentsTask = await meilisearchClient + .waitTask() + await meilisearchClient .index('movies') .addDocuments(dataset) - await meilisearchClient.index('movies').waitForTask(documentsTask.taskUid) + .waitTask() }) test('empty array on facetDistribution', async () => { diff --git a/packages/instant-meilisearch/__tests__/filter.test.ts b/packages/instant-meilisearch/__tests__/filter.test.ts index eb5ef740..573d5592 100644 --- a/packages/instant-meilisearch/__tests__/filter.test.ts +++ b/packages/instant-meilisearch/__tests__/filter.test.ts @@ -8,8 +8,7 @@ import { describe('Instant Meilisearch Browser test', () => { beforeAll(async () => { - const deleteTask = await meilisearchClient.deleteIndex('movies') - await meilisearchClient.waitForTask(deleteTask.taskUid) + await meilisearchClient.deleteIndex('movies').waitTask() await meilisearchClient .index('movies') .updateFilterableAttributes([ @@ -18,10 +17,11 @@ describe('Instant Meilisearch Browser test', () => { 'numberField', 'crazy_\\_"field"', ]) - const documentsTask = await meilisearchClient + .waitTask() + await meilisearchClient .index('movies') .addDocuments(dataset) - await meilisearchClient.index('movies').waitForTask(documentsTask.taskUid) + .waitTask() }) test('one string facet on filter without a query', async () => { diff --git a/packages/instant-meilisearch/__tests__/first-facets-distribution.test.ts b/packages/instant-meilisearch/__tests__/first-facets-distribution.test.ts index 45b46327..1d4fd2d7 100644 --- a/packages/instant-meilisearch/__tests__/first-facets-distribution.test.ts +++ b/packages/instant-meilisearch/__tests__/first-facets-distribution.test.ts @@ -4,16 +4,15 @@ import { instantMeiliSearch } from '../src/index.js' describe('Default facet distribution', () => { beforeAll(async () => { - const deleteTask = await meilisearchClient.deleteIndex('movies') - await meilisearchClient.waitForTask(deleteTask.taskUid) + await meilisearchClient.deleteIndex('movies').waitTask() await meilisearchClient.index('movies').updateSettings({ filterableAttributes: ['genres', 'release_date'], sortableAttributes: ['release_date'], - }) - const documentsTask = await meilisearchClient + }).waitTask() + await meilisearchClient .index('movies') .addDocuments(dataset) - await meilisearchClient.index('movies').waitForTask(documentsTask.taskUid) + .waitTask() }) // Without facets diff --git a/packages/instant-meilisearch/__tests__/geosearch.test.ts b/packages/instant-meilisearch/__tests__/geosearch.test.ts index 1f2f9c81..e8086936 100644 --- a/packages/instant-meilisearch/__tests__/geosearch.test.ts +++ b/packages/instant-meilisearch/__tests__/geosearch.test.ts @@ -8,16 +8,16 @@ import { describe('Instant Meilisearch Browser test', () => { beforeAll(async () => { - const deleteTask = await meilisearchClient.deleteIndex('geotest') - await meilisearchClient.waitForTask(deleteTask.taskUid) + await meilisearchClient.deleteIndex('geotest').waitTask() await meilisearchClient .index('geotest') .updateFilterableAttributes(['_geo']) - await meilisearchClient.index('geotest').updateSortableAttributes(['_geo']) - const documentsTask = await meilisearchClient + .waitTask() + await meilisearchClient.index('geotest').updateSortableAttributes(['_geo']).waitTask() + await meilisearchClient .index('geotest') .addDocuments(geoDataset) - await meilisearchClient.index('movies').waitForTask(documentsTask.taskUid) + .waitTask() }) test('aroundRadius and aroundLatLng in geo search', async () => { diff --git a/packages/instant-meilisearch/__tests__/highlight.test.ts b/packages/instant-meilisearch/__tests__/highlight.test.ts index 7bc32824..5dadd6f3 100644 --- a/packages/instant-meilisearch/__tests__/highlight.test.ts +++ b/packages/instant-meilisearch/__tests__/highlight.test.ts @@ -8,15 +8,15 @@ import { describe('Highlight Browser test', () => { beforeAll(async () => { - const deleteTask = await meilisearchClient.deleteIndex('movies') - await meilisearchClient.waitForTask(deleteTask.taskUid) + await meilisearchClient.deleteIndex('movies').waitTask() await meilisearchClient .index('movies') .updateFilterableAttributes(['genres']) - const documentsTask = await meilisearchClient + .waitTask() + await meilisearchClient .index('movies') .addDocuments(dataset) - await meilisearchClient.index('movies').waitForTask(documentsTask.taskUid) + .waitTask() }) test('one attributesToHighlight on wrong attribute placeholder', async () => { diff --git a/packages/instant-meilisearch/__tests__/multi-index-search.test.ts b/packages/instant-meilisearch/__tests__/multi-index-search.test.ts index d3ffdfb4..43177b40 100644 --- a/packages/instant-meilisearch/__tests__/multi-index-search.test.ts +++ b/packages/instant-meilisearch/__tests__/multi-index-search.test.ts @@ -14,15 +14,13 @@ describe('Multi-index search test', () => { await moviesIndex.updateSettings({ filterableAttributes: ['genres', 'color', 'platforms'], - }) + }).waitTask() await gamesIndex.updateSettings({ filterableAttributes: ['genres', 'color', 'platforms'], - }) - - await moviesIndex.addDocuments(movies) - const response = await gamesIndex.addDocuments(games) + }).waitTask() - await meilisearchClient.waitForTask(response.taskUid) + await moviesIndex.addDocuments(movies).waitTask() + await gamesIndex.addDocuments(games).waitTask() }) test('searching on two indexes', async () => { diff --git a/packages/instant-meilisearch/__tests__/overridden-meilisearch-parameters.test.ts b/packages/instant-meilisearch/__tests__/overridden-meilisearch-parameters.test.ts index af9fc73f..37d820e8 100644 --- a/packages/instant-meilisearch/__tests__/overridden-meilisearch-parameters.test.ts +++ b/packages/instant-meilisearch/__tests__/overridden-meilisearch-parameters.test.ts @@ -4,12 +4,11 @@ import { dataset, meilisearchClient, type Movies } from './assets/utils.js' describe('InstantMeiliSearch overridden parameters', () => { beforeAll(async () => { - const deleteTask = await meilisearchClient.deleteIndex('movies') - await meilisearchClient.waitForTask(deleteTask.taskUid) - const documentsTask = await meilisearchClient + await meilisearchClient.deleteIndex('movies').waitTask() + await meilisearchClient .index('movies') .addDocuments(dataset) - await meilisearchClient.index('movies').waitForTask(documentsTask.taskUid) + .waitTask() }) test('instantiating with, and changing overridden Meilisearch parameters', async () => { diff --git a/packages/instant-meilisearch/__tests__/pagination.test.ts b/packages/instant-meilisearch/__tests__/pagination.test.ts index a696a0c3..185bbed6 100644 --- a/packages/instant-meilisearch/__tests__/pagination.test.ts +++ b/packages/instant-meilisearch/__tests__/pagination.test.ts @@ -8,15 +8,15 @@ import { describe('Pagination browser test', () => { beforeAll(async () => { - const deleteTask = await meilisearchClient.deleteIndex('movies') - await meilisearchClient.waitForTask(deleteTask.taskUid) + await meilisearchClient.deleteIndex('movies').waitTask() await meilisearchClient .index('movies') .updateFilterableAttributes(['genres']) - const documentsTask = await meilisearchClient + .waitTask() + await meilisearchClient .index('movies') .addDocuments(dataset) - await meilisearchClient.index('movies').waitForTask(documentsTask.taskUid) + .waitTask() }) test('1 hitsPerPage', async () => { diff --git a/packages/instant-meilisearch/__tests__/placeholder-search.test.ts b/packages/instant-meilisearch/__tests__/placeholder-search.test.ts index ce17a14c..00528b7e 100644 --- a/packages/instant-meilisearch/__tests__/placeholder-search.test.ts +++ b/packages/instant-meilisearch/__tests__/placeholder-search.test.ts @@ -4,15 +4,15 @@ import { dataset, type Movies, meilisearchClient } from './assets/utils.js' describe('Pagination browser test', () => { beforeAll(async () => { - const deleteTask = await meilisearchClient.deleteIndex('movies') - await meilisearchClient.waitForTask(deleteTask.taskUid) + await meilisearchClient.deleteIndex('movies').waitTask() await meilisearchClient .index('movies') .updateFilterableAttributes(['genres']) - const documentsTask = await meilisearchClient + .waitTask() + await meilisearchClient .index('movies') .addDocuments(dataset) - await meilisearchClient.index('movies').waitForTask(documentsTask.taskUid) + .waitTask() }) test('placeholdersearch set to true', async () => { diff --git a/packages/instant-meilisearch/__tests__/snippets.test.ts b/packages/instant-meilisearch/__tests__/snippets.test.ts index c285781c..2eed7636 100644 --- a/packages/instant-meilisearch/__tests__/snippets.test.ts +++ b/packages/instant-meilisearch/__tests__/snippets.test.ts @@ -8,15 +8,15 @@ import { describe('Snippet Browser test', () => { beforeAll(async () => { - const deleteTask = await meilisearchClient.deleteIndex('movies') - await meilisearchClient.waitForTask(deleteTask.taskUid) + await meilisearchClient.deleteIndex('movies').waitTask() await meilisearchClient .index('movies') .updateFilterableAttributes(['genres']) - const documentsTask = await meilisearchClient + .waitTask() + await meilisearchClient .index('movies') .addDocuments(dataset) - await meilisearchClient.index('movies').waitForTask(documentsTask.taskUid) + .waitTask() }) test('Test one attributesToSnippet on placeholder without a snippetEllipsisText', async () => { diff --git a/packages/instant-meilisearch/__tests__/sort.test.ts b/packages/instant-meilisearch/__tests__/sort.test.ts index b2065720..18f7a66a 100644 --- a/packages/instant-meilisearch/__tests__/sort.test.ts +++ b/packages/instant-meilisearch/__tests__/sort.test.ts @@ -10,16 +10,15 @@ import { splitSortString } from '../src/contexts/sort-context.js' describe('Sort browser test', () => { beforeAll(async () => { - const deleteTask = await meilisearchClient.deleteIndex('movies') - await meilisearchClient.waitForTask(deleteTask.taskUid) + await meilisearchClient.deleteIndex('movies').waitTask() await meilisearchClient.index('movies').updateSettings({ sortableAttributes: ['release_date', 'title'], - }) + }).waitTask() - const documentsTask = await meilisearchClient + await meilisearchClient .index('movies') .addDocuments(dataset) - await meilisearchClient.index('movies').waitForTask(documentsTask.taskUid) + .waitTask() }) test('sort-by one field', async () => { From d3a042834996efafecae1a9bd9fb0482e591c352 Mon Sep 17 00:00:00 2001 From: Strift Date: Tue, 15 Apr 2025 13:34:48 +0900 Subject: [PATCH 5/9] Replace requestConfig by requestInit --- .../instant-meilisearch/__tests__/instantiation.test.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/instant-meilisearch/__tests__/instantiation.test.ts b/packages/instant-meilisearch/__tests__/instantiation.test.ts index 05277173..ebddac5d 100644 --- a/packages/instant-meilisearch/__tests__/instantiation.test.ts +++ b/packages/instant-meilisearch/__tests__/instantiation.test.ts @@ -44,7 +44,7 @@ describe('InstantMeiliSearch instantiation', () => { test('instantiation with custom request config with correct type', () => { const searchClient = instantMeiliSearch('http://localhost:7700', '', { - requestConfig: {}, + requestInit: {}, }) expect(searchClient).toBeTruthy() @@ -52,7 +52,7 @@ describe('InstantMeiliSearch instantiation', () => { test('instantiation with custom request config set to undefined', () => { const searchClient = instantMeiliSearch('http://localhost:7700', '', { - requestConfig: undefined, + requestInit: undefined, }) expect(searchClient).toBeTruthy() @@ -62,9 +62,9 @@ describe('InstantMeiliSearch instantiation', () => { expect(() => { instantMeiliSearch('http://localhost:7700', '', { // @ts-expect-error - requestConfig: '', + requestInit: '', }) - }).toThrow('Provided requestConfig should be an object') + }).toThrow('Provided requestInit should be an object') }) test('instantiation with custom HTTP client with correct type', () => { From 82f4fc7ef97754a812ac659f18fdfe41e37e76ff Mon Sep 17 00:00:00 2001 From: Strift Date: Tue, 15 Apr 2025 13:50:39 +0900 Subject: [PATCH 6/9] Run linter --- .../configure.attributes-to-retrieve.test.ts | 5 +---- .../__tests__/custom-http-client.test.ts | 15 +++++++-------- .../__tests__/facet-stats.test.ts | 5 +---- .../__tests__/facets-distribution.test.ts | 5 +---- .../instant-meilisearch/__tests__/filter.test.ts | 5 +---- .../__tests__/first-facets-distribution.test.ts | 10 +++++----- .../__tests__/geosearch.test.ts | 4 ++-- .../__tests__/highlight.test.ts | 5 +---- .../__tests__/multi-index-search.test.ts | 16 ++++++++++------ .../overridden-meilisearch-parameters.test.ts | 5 +---- .../__tests__/pagination.test.ts | 5 +---- .../__tests__/placeholder-search.test.ts | 5 +---- .../__tests__/snippets.test.ts | 5 +---- .../instant-meilisearch/__tests__/sort.test.ts | 10 +++++----- 14 files changed, 38 insertions(+), 62 deletions(-) diff --git a/packages/instant-meilisearch/__tests__/configure.attributes-to-retrieve.test.ts b/packages/instant-meilisearch/__tests__/configure.attributes-to-retrieve.test.ts index 3fa97531..8056abc5 100644 --- a/packages/instant-meilisearch/__tests__/configure.attributes-to-retrieve.test.ts +++ b/packages/instant-meilisearch/__tests__/configure.attributes-to-retrieve.test.ts @@ -10,10 +10,7 @@ describe('Instant Meilisearch Browser test', () => { beforeAll(async () => { await meilisearchClient.deleteIndex('movies').waitTask() - await meilisearchClient - .index('movies') - .addDocuments(dataset) - .waitTask() + await meilisearchClient.index('movies').addDocuments(dataset).waitTask() }) test('attributesToRetrieve on no attributes', async () => { diff --git a/packages/instant-meilisearch/__tests__/custom-http-client.test.ts b/packages/instant-meilisearch/__tests__/custom-http-client.test.ts index 4729294c..926ca6de 100644 --- a/packages/instant-meilisearch/__tests__/custom-http-client.test.ts +++ b/packages/instant-meilisearch/__tests__/custom-http-client.test.ts @@ -6,17 +6,16 @@ describe('Custom HTTP client tests', () => { beforeAll(async () => { await meilisearchClient.deleteIndex('movies').waitTask() - await meilisearchClient - .index('movies') - .addDocuments(dataset) - .waitTask() + await meilisearchClient.index('movies').addDocuments(dataset).waitTask() }) test('a custom HTTP client', async () => { - const httpClient = vi.fn(async (url: RequestInfo | URL, init?: RequestInit) => { - const result = await fetch(url, init) - return await result.json() - }) + const httpClient = vi.fn( + async (url: RequestInfo | URL, init?: RequestInit) => { + const result = await fetch(url, init) + return await result.json() + } + ) const { searchClient } = instantMeiliSearch( 'http://localhost:7700', diff --git a/packages/instant-meilisearch/__tests__/facet-stats.test.ts b/packages/instant-meilisearch/__tests__/facet-stats.test.ts index 6a97b30b..4d9e1682 100644 --- a/packages/instant-meilisearch/__tests__/facet-stats.test.ts +++ b/packages/instant-meilisearch/__tests__/facet-stats.test.ts @@ -8,10 +8,7 @@ describe('Facet stats tests', () => { .index('movies') .updateFilterableAttributes(['genres', 'release_date', 'id']) .waitTask() - await meilisearchClient - .index('movies') - .addDocuments(dataset) - .waitTask() + await meilisearchClient.index('movies').addDocuments(dataset).waitTask() }) test('Facet stats on an empty facets array', async () => { diff --git a/packages/instant-meilisearch/__tests__/facets-distribution.test.ts b/packages/instant-meilisearch/__tests__/facets-distribution.test.ts index 252757b2..0735fe6e 100644 --- a/packages/instant-meilisearch/__tests__/facets-distribution.test.ts +++ b/packages/instant-meilisearch/__tests__/facets-distribution.test.ts @@ -8,10 +8,7 @@ describe('Instant Meilisearch Browser test', () => { .index('movies') .updateFilterableAttributes(['genres']) .waitTask() - await meilisearchClient - .index('movies') - .addDocuments(dataset) - .waitTask() + await meilisearchClient.index('movies').addDocuments(dataset).waitTask() }) test('empty array on facetDistribution', async () => { diff --git a/packages/instant-meilisearch/__tests__/filter.test.ts b/packages/instant-meilisearch/__tests__/filter.test.ts index 573d5592..c90012a9 100644 --- a/packages/instant-meilisearch/__tests__/filter.test.ts +++ b/packages/instant-meilisearch/__tests__/filter.test.ts @@ -18,10 +18,7 @@ describe('Instant Meilisearch Browser test', () => { 'crazy_\\_"field"', ]) .waitTask() - await meilisearchClient - .index('movies') - .addDocuments(dataset) - .waitTask() + await meilisearchClient.index('movies').addDocuments(dataset).waitTask() }) test('one string facet on filter without a query', async () => { diff --git a/packages/instant-meilisearch/__tests__/first-facets-distribution.test.ts b/packages/instant-meilisearch/__tests__/first-facets-distribution.test.ts index 1d4fd2d7..80be4ccb 100644 --- a/packages/instant-meilisearch/__tests__/first-facets-distribution.test.ts +++ b/packages/instant-meilisearch/__tests__/first-facets-distribution.test.ts @@ -5,14 +5,14 @@ import { instantMeiliSearch } from '../src/index.js' describe('Default facet distribution', () => { beforeAll(async () => { await meilisearchClient.deleteIndex('movies').waitTask() - await meilisearchClient.index('movies').updateSettings({ - filterableAttributes: ['genres', 'release_date'], - sortableAttributes: ['release_date'], - }).waitTask() await meilisearchClient .index('movies') - .addDocuments(dataset) + .updateSettings({ + filterableAttributes: ['genres', 'release_date'], + sortableAttributes: ['release_date'], + }) .waitTask() + await meilisearchClient.index('movies').addDocuments(dataset).waitTask() }) // Without facets diff --git a/packages/instant-meilisearch/__tests__/geosearch.test.ts b/packages/instant-meilisearch/__tests__/geosearch.test.ts index e8086936..c8e8216c 100644 --- a/packages/instant-meilisearch/__tests__/geosearch.test.ts +++ b/packages/instant-meilisearch/__tests__/geosearch.test.ts @@ -13,11 +13,11 @@ describe('Instant Meilisearch Browser test', () => { .index('geotest') .updateFilterableAttributes(['_geo']) .waitTask() - await meilisearchClient.index('geotest').updateSortableAttributes(['_geo']).waitTask() await meilisearchClient .index('geotest') - .addDocuments(geoDataset) + .updateSortableAttributes(['_geo']) .waitTask() + await meilisearchClient.index('geotest').addDocuments(geoDataset).waitTask() }) test('aroundRadius and aroundLatLng in geo search', async () => { diff --git a/packages/instant-meilisearch/__tests__/highlight.test.ts b/packages/instant-meilisearch/__tests__/highlight.test.ts index 5dadd6f3..f714e1d0 100644 --- a/packages/instant-meilisearch/__tests__/highlight.test.ts +++ b/packages/instant-meilisearch/__tests__/highlight.test.ts @@ -13,10 +13,7 @@ describe('Highlight Browser test', () => { .index('movies') .updateFilterableAttributes(['genres']) .waitTask() - await meilisearchClient - .index('movies') - .addDocuments(dataset) - .waitTask() + await meilisearchClient.index('movies').addDocuments(dataset).waitTask() }) test('one attributesToHighlight on wrong attribute placeholder', async () => { diff --git a/packages/instant-meilisearch/__tests__/multi-index-search.test.ts b/packages/instant-meilisearch/__tests__/multi-index-search.test.ts index 43177b40..55dcef9e 100644 --- a/packages/instant-meilisearch/__tests__/multi-index-search.test.ts +++ b/packages/instant-meilisearch/__tests__/multi-index-search.test.ts @@ -12,12 +12,16 @@ describe('Multi-index search test', () => { await moviesIndex.delete() await gamesIndex.delete() - await moviesIndex.updateSettings({ - filterableAttributes: ['genres', 'color', 'platforms'], - }).waitTask() - await gamesIndex.updateSettings({ - filterableAttributes: ['genres', 'color', 'platforms'], - }).waitTask() + await moviesIndex + .updateSettings({ + filterableAttributes: ['genres', 'color', 'platforms'], + }) + .waitTask() + await gamesIndex + .updateSettings({ + filterableAttributes: ['genres', 'color', 'platforms'], + }) + .waitTask() await moviesIndex.addDocuments(movies).waitTask() await gamesIndex.addDocuments(games).waitTask() diff --git a/packages/instant-meilisearch/__tests__/overridden-meilisearch-parameters.test.ts b/packages/instant-meilisearch/__tests__/overridden-meilisearch-parameters.test.ts index 37d820e8..6b6fccd7 100644 --- a/packages/instant-meilisearch/__tests__/overridden-meilisearch-parameters.test.ts +++ b/packages/instant-meilisearch/__tests__/overridden-meilisearch-parameters.test.ts @@ -5,10 +5,7 @@ import { dataset, meilisearchClient, type Movies } from './assets/utils.js' describe('InstantMeiliSearch overridden parameters', () => { beforeAll(async () => { await meilisearchClient.deleteIndex('movies').waitTask() - await meilisearchClient - .index('movies') - .addDocuments(dataset) - .waitTask() + await meilisearchClient.index('movies').addDocuments(dataset).waitTask() }) test('instantiating with, and changing overridden Meilisearch parameters', async () => { diff --git a/packages/instant-meilisearch/__tests__/pagination.test.ts b/packages/instant-meilisearch/__tests__/pagination.test.ts index 185bbed6..9e7b4d70 100644 --- a/packages/instant-meilisearch/__tests__/pagination.test.ts +++ b/packages/instant-meilisearch/__tests__/pagination.test.ts @@ -13,10 +13,7 @@ describe('Pagination browser test', () => { .index('movies') .updateFilterableAttributes(['genres']) .waitTask() - await meilisearchClient - .index('movies') - .addDocuments(dataset) - .waitTask() + await meilisearchClient.index('movies').addDocuments(dataset).waitTask() }) test('1 hitsPerPage', async () => { diff --git a/packages/instant-meilisearch/__tests__/placeholder-search.test.ts b/packages/instant-meilisearch/__tests__/placeholder-search.test.ts index 00528b7e..18740888 100644 --- a/packages/instant-meilisearch/__tests__/placeholder-search.test.ts +++ b/packages/instant-meilisearch/__tests__/placeholder-search.test.ts @@ -9,10 +9,7 @@ describe('Pagination browser test', () => { .index('movies') .updateFilterableAttributes(['genres']) .waitTask() - await meilisearchClient - .index('movies') - .addDocuments(dataset) - .waitTask() + await meilisearchClient.index('movies').addDocuments(dataset).waitTask() }) test('placeholdersearch set to true', async () => { diff --git a/packages/instant-meilisearch/__tests__/snippets.test.ts b/packages/instant-meilisearch/__tests__/snippets.test.ts index 2eed7636..389f7b33 100644 --- a/packages/instant-meilisearch/__tests__/snippets.test.ts +++ b/packages/instant-meilisearch/__tests__/snippets.test.ts @@ -13,10 +13,7 @@ describe('Snippet Browser test', () => { .index('movies') .updateFilterableAttributes(['genres']) .waitTask() - await meilisearchClient - .index('movies') - .addDocuments(dataset) - .waitTask() + await meilisearchClient.index('movies').addDocuments(dataset).waitTask() }) test('Test one attributesToSnippet on placeholder without a snippetEllipsisText', async () => { diff --git a/packages/instant-meilisearch/__tests__/sort.test.ts b/packages/instant-meilisearch/__tests__/sort.test.ts index 18f7a66a..353c28a9 100644 --- a/packages/instant-meilisearch/__tests__/sort.test.ts +++ b/packages/instant-meilisearch/__tests__/sort.test.ts @@ -11,14 +11,14 @@ import { splitSortString } from '../src/contexts/sort-context.js' describe('Sort browser test', () => { beforeAll(async () => { await meilisearchClient.deleteIndex('movies').waitTask() - await meilisearchClient.index('movies').updateSettings({ - sortableAttributes: ['release_date', 'title'], - }).waitTask() - await meilisearchClient .index('movies') - .addDocuments(dataset) + .updateSettings({ + sortableAttributes: ['release_date', 'title'], + }) .waitTask() + + await meilisearchClient.index('movies').addDocuments(dataset).waitTask() }) test('sort-by one field', async () => { From bfb5ebffd7f673a918558d631a64c0118055856b Mon Sep 17 00:00:00 2001 From: Strift Date: Tue, 15 Apr 2025 14:30:30 +0900 Subject: [PATCH 7/9] Update waitTask calls in playgrounds --- playgrounds/autocomplete/setup.mjs | 3 +-- playgrounds/local-react/setup.mjs | 9 +++++---- playgrounds/node-env/index.js | 6 ++---- 3 files changed, 8 insertions(+), 10 deletions(-) diff --git a/playgrounds/autocomplete/setup.mjs b/playgrounds/autocomplete/setup.mjs index d27aa5fe..203446d8 100644 --- a/playgrounds/autocomplete/setup.mjs +++ b/playgrounds/autocomplete/setup.mjs @@ -6,5 +6,4 @@ const client = new MeiliSearch({ apiKey: 'masterKey', }) await client.index('steam-video-games').delete() -const task = await client.index('steam-video-games').addDocuments(games) -await client.waitForTask(task.taskUid) +client.index('steam-video-games').addDocuments(games).waitTask() diff --git a/playgrounds/local-react/setup.mjs b/playgrounds/local-react/setup.mjs index 20cf588b..a4039fe7 100644 --- a/playgrounds/local-react/setup.mjs +++ b/playgrounds/local-react/setup.mjs @@ -22,10 +22,11 @@ await gamesIndex.updateSettings({ sortableAttributes: ['recommendationCount'], }) -const moviesRes = await moviesIndex.addDocuments(movies) -const gamesRes = await gamesIndex.addDocuments(games) +const moviesTask = await moviesIndex.addDocuments(movies) +const gamesTask = await gamesIndex.addDocuments(games) + +await moviesTask.waitTask() +await gamesTask.waitTask() -const moviesTask = await client.waitForTask(moviesRes.taskUid) -const gamesTask = await client.waitForTask(gamesRes.taskUid) console.log(moviesTask) console.log(gamesTask) diff --git a/playgrounds/node-env/index.js b/playgrounds/node-env/index.js index 09438ad4..a71ca3a7 100644 --- a/playgrounds/node-env/index.js +++ b/playgrounds/node-env/index.js @@ -12,8 +12,7 @@ const msClient = new MeiliSearch({ }) try { - const task1 = await msClient.index('node_test').addDocuments([]) - await msClient.waitForTask(task1.taskUid) + await msClient.index('node_test').addDocuments([]).waitTask() await searchClient.search([ { indexName: 'node_test', @@ -23,8 +22,7 @@ try { }, ]) - const task2 = await msClient.index('node_test').delete() - await msClient.waitForTask(task2.taskUid) + await msClient.index('node_test').delete().waitTask() process.exit(0) } catch (e) { console.log(e) From 8284f94a5e1190859b841c37ac139cabc713c73a Mon Sep 17 00:00:00 2001 From: Strift Date: Tue, 15 Apr 2025 14:35:55 +0900 Subject: [PATCH 8/9] Fix syntax --- playgrounds/local-react/setup.mjs | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/playgrounds/local-react/setup.mjs b/playgrounds/local-react/setup.mjs index a4039fe7..411c3ce2 100644 --- a/playgrounds/local-react/setup.mjs +++ b/playgrounds/local-react/setup.mjs @@ -22,11 +22,8 @@ await gamesIndex.updateSettings({ sortableAttributes: ['recommendationCount'], }) -const moviesTask = await moviesIndex.addDocuments(movies) -const gamesTask = await gamesIndex.addDocuments(games) - -await moviesTask.waitTask() -await gamesTask.waitTask() +const moviesTask = await moviesIndex.addDocuments(movies).waitTask() +const gamesTask = await gamesIndex.addDocuments(games).waitTask() console.log(moviesTask) console.log(gamesTask) From 3085de3a00783a96b34d3c362765aac7db8c56a6 Mon Sep 17 00:00:00 2001 From: Strift Date: Tue, 15 Apr 2025 14:57:42 +0900 Subject: [PATCH 9/9] Add changeset --- .changeset/rude-walls-deny.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changeset/rude-walls-deny.md diff --git a/.changeset/rude-walls-deny.md b/.changeset/rude-walls-deny.md new file mode 100644 index 00000000..311da1f1 --- /dev/null +++ b/.changeset/rude-walls-deny.md @@ -0,0 +1,5 @@ +--- +"@meilisearch/instant-meilisearch": minor +--- + +Bump meilisearch to v0.50.0