Skip to content

Commit c6614d5

Browse files
chore: generated code for commit b9c4145. [skip ci]
Co-authored-by: Clément Vannicatte <[email protected]>
1 parent b9c4145 commit c6614d5

File tree

1 file changed

+13
-6
lines changed
  • clients/algoliasearch-client-javascript/packages/client-search/src

1 file changed

+13
-6
lines changed

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

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -220,23 +220,30 @@ export function createSearchClient({
220220
...createRetryablePromiseOptions
221221
}: WaitForApiKeyOptions): Promise<ApiError | Key> {
222222
if (operation === 'update') {
223+
if (!apiKey) {
224+
throw new Error(
225+
'`apiKey` is required when waiting for an `update` operation.'
226+
);
227+
}
228+
223229
return createRetryablePromise({
224230
...createRetryablePromiseOptions,
225231
func: () => this.getApiKey({ key }),
226232
validate: (response) => {
227-
for (const [entry, values] of Object.entries(apiKey)) {
228-
if (Array.isArray(values)) {
233+
for (const field of Object.keys(apiKey)) {
234+
if (Array.isArray(apiKey[field])) {
229235
if (
230-
values.length !== response[entry].length ||
231-
values.some((val, index) => val !== response[entry][index])
236+
apiKey[field].length !== response[field].length ||
237+
(apiKey[field] as string[]).some(
238+
(value, index) => value !== response[field][index]
239+
)
232240
) {
233241
return false;
234242
}
235-
} else if (values !== response[entry]) {
243+
} else if (response[field] !== apiKey[field]) {
236244
return false;
237245
}
238246
}
239-
240247
return true;
241248
},
242249
});

0 commit comments

Comments
 (0)