Skip to content

Commit c993b36

Browse files
algolia-boteunjae-leeshortcuts
committed
chore: generated code for commit 4f8d355. [skip ci]
Co-authored-by: Eunjae Lee <[email protected]> Co-authored-by: Clément Vannicatte <[email protected]>
1 parent 4f8d355 commit c993b36

File tree

1 file changed

+31
-0
lines changed
  • clients/algoliasearch-client-javascript/packages/client-search/src

1 file changed

+31
-0
lines changed

clients/algoliasearch-client-javascript/packages/client-search/src/searchClient.ts

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import {
33
createTransporter,
44
getAlgoliaAgent,
55
shuffle,
6+
createRetryablePromise,
67
} from '@experimental-api-clients-automation/client-common';
78
import type {
89
CreateClientOptions,
@@ -11,6 +12,7 @@ import type {
1112
Request,
1213
RequestOptions,
1314
QueryParameters,
15+
CreateRetryablePromiseOptions,
1416
} from '@experimental-api-clients-automation/client-common';
1517

1618
import type { AddApiKeyResponse } from '../model/addApiKeyResponse';
@@ -138,6 +140,35 @@ export function createSearchClient(options: CreateClientOptions) {
138140

139141
return {
140142
addAlgoliaAgent,
143+
/**
144+
* Wait for a task to complete with `indexName` and `taskID`.
145+
*
146+
* @summary Wait for a task to complete.
147+
* @param waitForTaskProps - The waitForTaskProps object.
148+
* @param waitForTaskProps.indexName - The index in which to perform the request.
149+
* @param waitForTaskProps.taskID - The unique identifier of the task to wait for.
150+
*/
151+
waitForTask({
152+
indexName,
153+
taskID,
154+
...createRetryablePromiseOptions
155+
}: Omit<
156+
CreateRetryablePromiseOptions<GetTaskResponse>,
157+
'func' | 'validate'
158+
> & {
159+
indexName: string;
160+
taskID: number;
161+
}): Promise<void> {
162+
return new Promise<void>((resolve, reject) => {
163+
createRetryablePromise<GetTaskResponse>({
164+
...createRetryablePromiseOptions,
165+
func: () => this.getTask({ indexName, taskID }),
166+
validate: (response) => response.status === 'published',
167+
})
168+
.then(() => resolve())
169+
.catch(reject);
170+
});
171+
},
141172
/**
142173
* Add a new API Key with specific permissions/restrictions.
143174
*

0 commit comments

Comments
 (0)