Skip to content

Commit 86eb124

Browse files
feat(clients): expose waitForTasks to batch helpers [skip-bc] (generated)
algolia/api-clients-automation#4030 Co-authored-by: algolia-bot <[email protected]> Co-authored-by: Clément Vannicatte <[email protected]>
1 parent 4866f7f commit 86eb124

File tree

2 files changed

+12
-7
lines changed

2 files changed

+12
-7
lines changed

packages/client-search/model/clientMethodProps.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -824,21 +824,21 @@ export type SearchClientNodeHelpers = {
824824
getSecuredApiKeyRemainingValidity: (opts: GetSecuredApiKeyRemainingValidityOptions) => number;
825825
};
826826

827-
export type DeleteObjectsOptions = Pick<ChunkedBatchOptions, 'indexName'> & {
827+
export type DeleteObjectsOptions = Pick<ChunkedBatchOptions, 'indexName' | 'waitForTasks'> & {
828828
/**
829829
* The objectIDs to delete.
830830
*/
831831
objectIDs: string[];
832832
};
833833

834-
export type PartialUpdateObjectsOptions = Pick<ChunkedBatchOptions, 'indexName' | 'objects'> & {
834+
export type PartialUpdateObjectsOptions = Pick<ChunkedBatchOptions, 'indexName' | 'objects' | 'waitForTasks'> & {
835835
/**
836836
*To be provided if non-existing objects are passed, otherwise, the call will fail.
837837
*/
838838
createIfNotExists?: boolean;
839839
};
840840

841-
export type SaveObjectsOptions = Pick<ChunkedBatchOptions, 'indexName' | 'objects'>;
841+
export type SaveObjectsOptions = Pick<ChunkedBatchOptions, 'indexName' | 'objects' | 'waitForTasks'>;
842842

843843
export type ChunkedBatchOptions = ReplaceAllObjectsOptions & {
844844
/**

packages/client-search/src/searchClient.ts

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -550,13 +550,14 @@ export function createSearchClient({
550550
* @param saveObjects - The `saveObjects` object.
551551
* @param saveObjects.indexName - The `indexName` to save `objects` in.
552552
* @param saveObjects.objects - The array of `objects` to store in the given Algolia `indexName`.
553+
* @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.
553554
* @param requestOptions - The requestOptions to send along with the query, they will be forwarded to the `batch` method and merged with the transporter requestOptions.
554555
*/
555556
async saveObjects(
556-
{ indexName, objects }: SaveObjectsOptions,
557+
{ indexName, objects, waitForTasks }: SaveObjectsOptions,
557558
requestOptions?: RequestOptions,
558559
): Promise<BatchResponse[]> {
559-
return await this.chunkedBatch({ indexName, objects, action: 'addObject' }, requestOptions);
560+
return await this.chunkedBatch({ indexName, objects, action: 'addObject', waitForTasks }, requestOptions);
560561
},
561562

562563
/**
@@ -566,17 +567,19 @@ export function createSearchClient({
566567
* @param deleteObjects - The `deleteObjects` object.
567568
* @param deleteObjects.indexName - The `indexName` to delete `objectIDs` from.
568569
* @param deleteObjects.objectIDs - The objectIDs to delete.
570+
* @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.
569571
* @param requestOptions - The requestOptions to send along with the query, they will be forwarded to the `batch` method and merged with the transporter requestOptions.
570572
*/
571573
async deleteObjects(
572-
{ indexName, objectIDs }: DeleteObjectsOptions,
574+
{ indexName, objectIDs, waitForTasks }: DeleteObjectsOptions,
573575
requestOptions?: RequestOptions,
574576
): Promise<BatchResponse[]> {
575577
return await this.chunkedBatch(
576578
{
577579
indexName,
578580
objects: objectIDs.map((objectID) => ({ objectID })),
579581
action: 'deleteObject',
582+
waitForTasks,
580583
},
581584
requestOptions,
582585
);
@@ -590,17 +593,19 @@ export function createSearchClient({
590593
* @param partialUpdateObjects.indexName - The `indexName` to update `objects` in.
591594
* @param partialUpdateObjects.objects - The array of `objects` to update in the given Algolia `indexName`.
592595
* @param partialUpdateObjects.createIfNotExists - To be provided if non-existing objects are passed, otherwise, the call will fail..
596+
* @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.
593597
* @param requestOptions - The requestOptions to send along with the query, they will be forwarded to the `getTask` method and merged with the transporter requestOptions.
594598
*/
595599
async partialUpdateObjects(
596-
{ indexName, objects, createIfNotExists }: PartialUpdateObjectsOptions,
600+
{ indexName, objects, createIfNotExists, waitForTasks }: PartialUpdateObjectsOptions,
597601
requestOptions?: RequestOptions,
598602
): Promise<BatchResponse[]> {
599603
return await this.chunkedBatch(
600604
{
601605
indexName,
602606
objects,
603607
action: createIfNotExists ? 'partialUpdateObject' : 'partialUpdateObjectNoCreate',
608+
waitForTasks,
604609
},
605610
requestOptions,
606611
);

0 commit comments

Comments
 (0)