@algolia/client-search 5.56.0 → 5.57.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +4 -4
- package/dist/browser.d.ts +4 -2
- package/dist/builds/browser.js +49 -21
- package/dist/builds/browser.js.map +1 -1
- package/dist/builds/browser.min.js +5 -5
- package/dist/builds/browser.min.js.map +1 -1
- package/dist/builds/browser.umd.js +7 -7
- package/dist/builds/fetch.js +102 -60
- package/dist/builds/fetch.js.map +1 -1
- package/dist/builds/node.cjs +97 -58
- package/dist/builds/node.cjs.map +1 -1
- package/dist/builds/node.js +102 -60
- package/dist/builds/node.js.map +1 -1
- package/dist/builds/worker.js +49 -21
- package/dist/builds/worker.js.map +1 -1
- package/dist/fetch.d.ts +4 -2
- package/dist/node.d.cts +4 -2
- package/dist/node.d.ts +4 -2
- package/dist/src/searchClient.cjs +45 -20
- package/dist/src/searchClient.cjs.map +1 -1
- package/dist/src/searchClient.js +53 -23
- package/dist/src/searchClient.js.map +1 -1
- package/dist/worker.d.ts +4 -2
- package/package.json +9 -9
package/dist/src/searchClient.js
CHANGED
|
@@ -6,10 +6,12 @@ import {
|
|
|
6
6
|
createIterablePromise,
|
|
7
7
|
createTransporter,
|
|
8
8
|
getAlgoliaAgent,
|
|
9
|
+
logWarning,
|
|
9
10
|
shuffle,
|
|
10
|
-
validateRequired
|
|
11
|
+
validateRequired,
|
|
12
|
+
withRequestId
|
|
11
13
|
} from "@algolia/client-common";
|
|
12
|
-
var apiClientVersion = "5.
|
|
14
|
+
var apiClientVersion = "5.57.0";
|
|
13
15
|
function getDefaultHosts(appId) {
|
|
14
16
|
return [
|
|
15
17
|
{
|
|
@@ -129,6 +131,7 @@ function createSearchClient({
|
|
|
129
131
|
maxRetries = 100,
|
|
130
132
|
timeout = (retryCount) => Math.min(retryCount * 200, 5e3)
|
|
131
133
|
}, requestOptions) {
|
|
134
|
+
requestOptions = withRequestId(transporter, requestOptions);
|
|
132
135
|
let retryCount = 0;
|
|
133
136
|
return createIterablePromise({
|
|
134
137
|
func: () => this.getTask({ indexName, taskID }, requestOptions),
|
|
@@ -156,6 +159,7 @@ function createSearchClient({
|
|
|
156
159
|
maxRetries = 100,
|
|
157
160
|
timeout = (retryCount) => Math.min(retryCount * 200, 5e3)
|
|
158
161
|
}, requestOptions) {
|
|
162
|
+
requestOptions = withRequestId(transporter, requestOptions);
|
|
159
163
|
let retryCount = 0;
|
|
160
164
|
return createIterablePromise({
|
|
161
165
|
func: () => this.getAppTask({ taskID }, requestOptions),
|
|
@@ -187,6 +191,7 @@ function createSearchClient({
|
|
|
187
191
|
maxRetries = 100,
|
|
188
192
|
timeout = (retryCount) => Math.min(retryCount * 200, 5e3)
|
|
189
193
|
}, requestOptions) {
|
|
194
|
+
requestOptions = withRequestId(transporter, requestOptions);
|
|
190
195
|
let retryCount = 0;
|
|
191
196
|
const baseIteratorOptions = {
|
|
192
197
|
aggregator: () => retryCount += 1,
|
|
@@ -242,6 +247,7 @@ function createSearchClient({
|
|
|
242
247
|
* @param requestOptions - The requestOptions to send along with the query, they will be forwarded to the `browse` method and merged with the transporter requestOptions.
|
|
243
248
|
*/
|
|
244
249
|
browseObjects({ indexName, browseParams, ...browseObjectsOptions }, requestOptions) {
|
|
250
|
+
requestOptions = withRequestId(transporter, requestOptions);
|
|
245
251
|
return createIterablePromise({
|
|
246
252
|
func: (previousResponse) => {
|
|
247
253
|
return this.browse(
|
|
@@ -272,9 +278,10 @@ function createSearchClient({
|
|
|
272
278
|
* @param requestOptions - The requestOptions to send along with the query, they will be forwarded to the `searchRules` method and merged with the transporter requestOptions.
|
|
273
279
|
*/
|
|
274
280
|
browseRules({ indexName, searchRulesParams, ...browseRulesOptions }, requestOptions) {
|
|
281
|
+
requestOptions = withRequestId(transporter, requestOptions);
|
|
275
282
|
const params = {
|
|
276
283
|
...searchRulesParams,
|
|
277
|
-
hitsPerPage:
|
|
284
|
+
hitsPerPage: searchRulesParams?.hitsPerPage || 1e3
|
|
278
285
|
};
|
|
279
286
|
return createIterablePromise({
|
|
280
287
|
func: (previousResponse) => {
|
|
@@ -309,9 +316,10 @@ function createSearchClient({
|
|
|
309
316
|
searchSynonymsParams,
|
|
310
317
|
...browseSynonymsOptions
|
|
311
318
|
}, requestOptions) {
|
|
319
|
+
requestOptions = withRequestId(transporter, requestOptions);
|
|
312
320
|
const params = {
|
|
313
321
|
...searchSynonymsParams,
|
|
314
|
-
page:
|
|
322
|
+
page: searchSynonymsParams?.page || 0,
|
|
315
323
|
hitsPerPage: 1e3
|
|
316
324
|
};
|
|
317
325
|
return createIterablePromise({
|
|
@@ -354,6 +362,7 @@ function createSearchClient({
|
|
|
354
362
|
batchSize = 1e3,
|
|
355
363
|
maxRetries = 100
|
|
356
364
|
}, requestOptions) {
|
|
365
|
+
requestOptions = withRequestId(transporter, requestOptions);
|
|
357
366
|
let requests = [];
|
|
358
367
|
const responses = [];
|
|
359
368
|
const objectEntries = objects.entries();
|
|
@@ -366,7 +375,7 @@ function createSearchClient({
|
|
|
366
375
|
}
|
|
367
376
|
if (waitForTasks) {
|
|
368
377
|
for (const resp of responses) {
|
|
369
|
-
await this.waitForTask({ indexName, taskID: resp.taskID, maxRetries });
|
|
378
|
+
await this.waitForTask({ indexName, taskID: resp.taskID, maxRetries }, requestOptions);
|
|
370
379
|
}
|
|
371
380
|
}
|
|
372
381
|
return responses;
|
|
@@ -444,6 +453,8 @@ function createSearchClient({
|
|
|
444
453
|
* Helper: Replaces all objects (records) in the given `index_name` with the given `objects`. A temporary index is created during this process in order to backup your data.
|
|
445
454
|
* See https://api-clients-automation.netlify.app/docs/custom-helpers/#replaceallobjects for implementation details.
|
|
446
455
|
*
|
|
456
|
+
* Warning: calling this method with an empty `objects` list replaces the index with an empty one, deleting all existing records.
|
|
457
|
+
*
|
|
447
458
|
* @summary Helper: Replaces all objects (records) in the given `index_name` with the given `objects`. A temporary index is created during this process in order to backup your data.
|
|
448
459
|
* @param replaceAllObjects - The `replaceAllObjects` object.
|
|
449
460
|
* @param replaceAllObjects.indexName - The `indexName` to replace `objects` in.
|
|
@@ -460,6 +471,13 @@ function createSearchClient({
|
|
|
460
471
|
scopes,
|
|
461
472
|
maxRetries = DEFAULT_REPLACE_ALL_OBJECTS_MAX_RETRIES
|
|
462
473
|
}, requestOptions) {
|
|
474
|
+
requestOptions = withRequestId(transporter, requestOptions);
|
|
475
|
+
if (objects.length === 0) {
|
|
476
|
+
logWarning(
|
|
477
|
+
transporter.logger,
|
|
478
|
+
`replaceAllObjects was called with an empty list of objects, which will delete all records currently in the "${indexName}" index.`
|
|
479
|
+
);
|
|
480
|
+
}
|
|
463
481
|
const randomSuffix = Math.floor(Math.random() * 1e6) + 1e5;
|
|
464
482
|
const tmpIndexName = `${indexName}_tmp_${randomSuffix}`;
|
|
465
483
|
if (scopes === void 0) {
|
|
@@ -481,11 +499,14 @@ function createSearchClient({
|
|
|
481
499
|
{ indexName: tmpIndexName, objects, waitForTasks: true, batchSize, maxRetries },
|
|
482
500
|
requestOptions
|
|
483
501
|
);
|
|
484
|
-
await this.waitForTask(
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
502
|
+
await this.waitForTask(
|
|
503
|
+
{
|
|
504
|
+
indexName: tmpIndexName,
|
|
505
|
+
taskID: copyOperationResponse.taskID,
|
|
506
|
+
maxRetries
|
|
507
|
+
},
|
|
508
|
+
requestOptions
|
|
509
|
+
);
|
|
489
510
|
copyOperationResponse = await this.operationIndex(
|
|
490
511
|
{
|
|
491
512
|
indexName,
|
|
@@ -497,11 +518,14 @@ function createSearchClient({
|
|
|
497
518
|
},
|
|
498
519
|
requestOptions
|
|
499
520
|
);
|
|
500
|
-
await this.waitForTask(
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
521
|
+
await this.waitForTask(
|
|
522
|
+
{
|
|
523
|
+
indexName: tmpIndexName,
|
|
524
|
+
taskID: copyOperationResponse.taskID,
|
|
525
|
+
maxRetries
|
|
526
|
+
},
|
|
527
|
+
requestOptions
|
|
528
|
+
);
|
|
505
529
|
const moveOperationResponse = await this.operationIndex(
|
|
506
530
|
{
|
|
507
531
|
indexName: tmpIndexName,
|
|
@@ -509,20 +533,23 @@ function createSearchClient({
|
|
|
509
533
|
},
|
|
510
534
|
requestOptions
|
|
511
535
|
);
|
|
512
|
-
await this.waitForTask(
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
536
|
+
await this.waitForTask(
|
|
537
|
+
{
|
|
538
|
+
indexName: tmpIndexName,
|
|
539
|
+
taskID: moveOperationResponse.taskID,
|
|
540
|
+
maxRetries
|
|
541
|
+
},
|
|
542
|
+
requestOptions
|
|
543
|
+
);
|
|
517
544
|
return { copyOperationResponse, batchResponses, moveOperationResponse };
|
|
518
545
|
} catch (error) {
|
|
519
|
-
await this.deleteIndex({ indexName: tmpIndexName });
|
|
546
|
+
await this.deleteIndex({ indexName: tmpIndexName }, requestOptions);
|
|
520
547
|
throw error;
|
|
521
548
|
}
|
|
522
549
|
},
|
|
523
|
-
async indexExists({ indexName }) {
|
|
550
|
+
async indexExists({ indexName }, requestOptions) {
|
|
524
551
|
try {
|
|
525
|
-
await this.getSettings({ indexName });
|
|
552
|
+
await this.getSettings({ indexName }, requestOptions);
|
|
526
553
|
} catch (error) {
|
|
527
554
|
if (error instanceof ApiError && error.status === 404) {
|
|
528
555
|
return false;
|
|
@@ -3989,4 +4016,7 @@ export {
|
|
|
3989
4016
|
apiClientVersion,
|
|
3990
4017
|
createSearchClient
|
|
3991
4018
|
};
|
|
4019
|
+
//# sourceMappingURL=searchClient.js.mapClientVersion,
|
|
4020
|
+
createSearchClient
|
|
4021
|
+
};
|
|
3992
4022
|
//# sourceMappingURL=searchClient.js.map
|