From 86eb1244584487f70e6c6fc7835a810936065629 Mon Sep 17 00:00:00 2001 From: algolia-bot Date: Mon, 28 Oct 2024 16:19:11 +0000 Subject: [PATCH] feat(clients): expose waitForTasks to batch helpers [skip-bc] (generated) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit https://github.com/algolia/api-clients-automation/pull/4030 Co-authored-by: algolia-bot Co-authored-by: Clément Vannicatte --- packages/client-search/model/clientMethodProps.ts | 6 +++--- packages/client-search/src/searchClient.ts | 13 +++++++++---- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/packages/client-search/model/clientMethodProps.ts b/packages/client-search/model/clientMethodProps.ts index 7f9c838a5..210a71601 100644 --- a/packages/client-search/model/clientMethodProps.ts +++ b/packages/client-search/model/clientMethodProps.ts @@ -824,21 +824,21 @@ export type SearchClientNodeHelpers = { getSecuredApiKeyRemainingValidity: (opts: GetSecuredApiKeyRemainingValidityOptions) => number; }; -export type DeleteObjectsOptions = Pick & { +export type DeleteObjectsOptions = Pick & { /** * The objectIDs to delete. */ objectIDs: string[]; }; -export type PartialUpdateObjectsOptions = Pick & { +export type PartialUpdateObjectsOptions = Pick & { /** *To be provided if non-existing objects are passed, otherwise, the call will fail. */ createIfNotExists?: boolean; }; -export type SaveObjectsOptions = Pick; +export type SaveObjectsOptions = Pick; export type ChunkedBatchOptions = ReplaceAllObjectsOptions & { /** diff --git a/packages/client-search/src/searchClient.ts b/packages/client-search/src/searchClient.ts index f5fd864fb..a3908b717 100644 --- a/packages/client-search/src/searchClient.ts +++ b/packages/client-search/src/searchClient.ts @@ -550,13 +550,14 @@ export function createSearchClient({ * @param saveObjects - The `saveObjects` object. * @param saveObjects.indexName - The `indexName` to save `objects` in. * @param saveObjects.objects - The array of `objects` to store in the given Algolia `indexName`. + * @param saveObjects.waitForTasks - Whether or not we should wait until every `batch` tasks has been processed, this operation may slow the total execution time of this method but is more reliable. * @param requestOptions - The requestOptions to send along with the query, they will be forwarded to the `batch` method and merged with the transporter requestOptions. */ async saveObjects( - { indexName, objects }: SaveObjectsOptions, + { indexName, objects, waitForTasks }: SaveObjectsOptions, requestOptions?: RequestOptions, ): Promise { - return await this.chunkedBatch({ indexName, objects, action: 'addObject' }, requestOptions); + return await this.chunkedBatch({ indexName, objects, action: 'addObject', waitForTasks }, requestOptions); }, /** @@ -566,10 +567,11 @@ export function createSearchClient({ * @param deleteObjects - The `deleteObjects` object. * @param deleteObjects.indexName - The `indexName` to delete `objectIDs` from. * @param deleteObjects.objectIDs - The objectIDs to delete. + * @param deleteObjects.waitForTasks - Whether or not we should wait until every `batch` tasks has been processed, this operation may slow the total execution time of this method but is more reliable. * @param requestOptions - The requestOptions to send along with the query, they will be forwarded to the `batch` method and merged with the transporter requestOptions. */ async deleteObjects( - { indexName, objectIDs }: DeleteObjectsOptions, + { indexName, objectIDs, waitForTasks }: DeleteObjectsOptions, requestOptions?: RequestOptions, ): Promise { return await this.chunkedBatch( @@ -577,6 +579,7 @@ export function createSearchClient({ indexName, objects: objectIDs.map((objectID) => ({ objectID })), action: 'deleteObject', + waitForTasks, }, requestOptions, ); @@ -590,10 +593,11 @@ export function createSearchClient({ * @param partialUpdateObjects.indexName - The `indexName` to update `objects` in. * @param partialUpdateObjects.objects - The array of `objects` to update in the given Algolia `indexName`. * @param partialUpdateObjects.createIfNotExists - To be provided if non-existing objects are passed, otherwise, the call will fail.. + * @param partialUpdateObjects.waitForTasks - Whether or not we should wait until every `batch` tasks has been processed, this operation may slow the total execution time of this method but is more reliable. * @param requestOptions - The requestOptions to send along with the query, they will be forwarded to the `getTask` method and merged with the transporter requestOptions. */ async partialUpdateObjects( - { indexName, objects, createIfNotExists }: PartialUpdateObjectsOptions, + { indexName, objects, createIfNotExists, waitForTasks }: PartialUpdateObjectsOptions, requestOptions?: RequestOptions, ): Promise { return await this.chunkedBatch( @@ -601,6 +605,7 @@ export function createSearchClient({ indexName, objects, action: createIfNotExists ? 'partialUpdateObject' : 'partialUpdateObjectNoCreate', + waitForTasks, }, requestOptions, );