11import type { Index } from "meilisearch" ;
22import { Mutex } from "async-mutex" ;
3- import { MeiliSearch } from "meilisearch" ;
3+ import { Meilisearch } from "meilisearch" ;
44
55import type {
66 BookmarkSearchDocument ,
@@ -196,9 +196,9 @@ class BatchingDocumentQueue {
196196 }
197197
198198 private async ensureTaskSuccess ( taskUid : number ) : Promise < void > {
199- const task = await this . index . waitForTask ( taskUid , {
200- intervalMs : 200 ,
201- timeOutMs : this . jobTimeoutSec * 1000 * 0.9 ,
199+ const task = await this . index . tasks . waitForTask ( taskUid , {
200+ interval : 200 ,
201+ timeout : this . jobTimeoutSec * 1000 * 0.9 ,
202202 } ) ;
203203 if ( task . error ) {
204204 throw new Error ( `Search task failed: ${ task . error . message } ` ) ;
@@ -286,9 +286,9 @@ class MeiliSearchIndexClient implements SearchIndexClient {
286286 }
287287
288288 private async ensureTaskSuccess ( taskUid : number ) : Promise < void > {
289- const task = await this . index . waitForTask ( taskUid , {
290- intervalMs : 200 ,
291- timeOutMs : this . jobTimeoutSec * 1000 * 0.9 ,
289+ const task = await this . index . tasks . waitForTask ( taskUid , {
290+ interval : 200 ,
291+ timeout : this . jobTimeoutSec * 1000 * 0.9 ,
292292 } ) ;
293293 if ( task . error ) {
294294 throw new Error ( `Search task failed: ${ task . error . message } ` ) ;
@@ -297,14 +297,14 @@ class MeiliSearchIndexClient implements SearchIndexClient {
297297}
298298
299299export class MeiliSearchProvider implements PluginProvider < SearchIndexClient > {
300- private client : MeiliSearch | undefined ;
300+ private client : Meilisearch | undefined ;
301301 private indexClient : SearchIndexClient | undefined ;
302302 private initPromise : Promise < SearchIndexClient | null > | undefined ;
303303 private readonly indexName = "bookmarks" ;
304304
305305 constructor ( ) {
306306 if ( MeiliSearchProvider . isConfigured ( ) ) {
307- this . client = new MeiliSearch ( {
307+ this . client = new Meilisearch ( {
308308 host : envConfig . MEILI_ADDR ! ,
309309 apiKey : envConfig . MEILI_MASTER_KEY ,
310310 } ) ;
@@ -339,10 +339,11 @@ export class MeiliSearchProvider implements PluginProvider<SearchIndexClient> {
339339 let indexFound = indices . results . find ( ( i ) => i . uid === this . indexName ) ;
340340
341341 if ( ! indexFound ) {
342- const idx = await this . client . createIndex ( this . indexName , {
343- primaryKey : "id" ,
344- } ) ;
345- await this . client . waitForTask ( idx . taskUid ) ;
342+ await this . client
343+ . createIndex ( this . indexName , {
344+ primaryKey : "id" ,
345+ } )
346+ . waitTask ( ) ;
346347 indexFound = await this . client . getIndex < BookmarkSearchDocument > (
347348 this . indexName ,
348349 ) ;
@@ -373,10 +374,9 @@ export class MeiliSearchProvider implements PluginProvider<SearchIndexClient> {
373374 console . log (
374375 `[meilisearch] Updating desired filterable attributes to ${ desiredFilterableAttributes } from ${ settings . filterableAttributes } ` ,
375376 ) ;
376- const taskId = await index . updateFilterableAttributes (
377- desiredFilterableAttributes ,
378- ) ;
379- await this . client ! . waitForTask ( taskId . taskUid ) ;
377+ await index
378+ . updateFilterableAttributes ( desiredFilterableAttributes )
379+ . waitTask ( ) ;
380380 }
381381
382382 if (
@@ -386,10 +386,9 @@ export class MeiliSearchProvider implements PluginProvider<SearchIndexClient> {
386386 console . log (
387387 `[meilisearch] Updating desired sortable attributes to ${ desiredSortableAttributes } from ${ settings . sortableAttributes } ` ,
388388 ) ;
389- const taskId = await index . updateSortableAttributes (
390- desiredSortableAttributes ,
391- ) ;
392- await this . client ! . waitForTask ( taskId . taskUid ) ;
389+ await index
390+ . updateSortableAttributes ( desiredSortableAttributes )
391+ . waitTask ( ) ;
393392 }
394393 }
395394}
0 commit comments