@algolia/client-search 5.52.1 → 5.53.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 +88 -14
- package/dist/builds/browser.js +31 -14
- package/dist/builds/browser.js.map +1 -1
- package/dist/builds/browser.min.js +1 -1
- package/dist/builds/browser.min.js.map +1 -1
- package/dist/builds/browser.umd.js +3 -3
- package/dist/builds/fetch.js +35 -16
- package/dist/builds/fetch.js.map +1 -1
- package/dist/builds/node.cjs +35 -16
- package/dist/builds/node.cjs.map +1 -1
- package/dist/builds/node.js +35 -16
- package/dist/builds/node.js.map +1 -1
- package/dist/builds/worker.js +31 -14
- package/dist/builds/worker.js.map +1 -1
- package/dist/fetch.d.ts +88 -14
- package/dist/node.d.cts +88 -14
- package/dist/node.d.ts +88 -14
- package/dist/src/searchClient.cjs +31 -14
- package/dist/src/searchClient.cjs.map +1 -1
- package/dist/src/searchClient.js +33 -19
- package/dist/src/searchClient.js.map +1 -1
- package/dist/worker.d.ts +88 -14
- package/package.json +9 -9
package/dist/builds/node.cjs
CHANGED
|
@@ -31,7 +31,7 @@ var import_requester_node_http = require("@algolia/requester-node-http");
|
|
|
31
31
|
|
|
32
32
|
// src/searchClient.ts
|
|
33
33
|
var import_client_common = require("@algolia/client-common");
|
|
34
|
-
var apiClientVersion = "5.
|
|
34
|
+
var apiClientVersion = "5.53.0";
|
|
35
35
|
function getDefaultHosts(appId) {
|
|
36
36
|
return [
|
|
37
37
|
{
|
|
@@ -365,9 +365,17 @@ function createSearchClient({
|
|
|
365
365
|
* @param chunkedBatch.action - The `batch` `action` to perform on the given array of `objects`, defaults to `addObject`.
|
|
366
366
|
* @param chunkedBatch.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.
|
|
367
367
|
* @param chunkedBatch.batchSize - The size of the chunk of `objects`. The number of `batch` calls will be equal to `length(objects) / batchSize`. Defaults to 1000.
|
|
368
|
+
* @param chunkedBatch.maxRetries - The maximum number of retries when polling for task completion. 100 by default.
|
|
368
369
|
* @param requestOptions - The requestOptions to send along with the query, they will be forwarded to the `getTask` method and merged with the transporter requestOptions.
|
|
369
370
|
*/
|
|
370
|
-
async chunkedBatch({
|
|
371
|
+
async chunkedBatch({
|
|
372
|
+
indexName,
|
|
373
|
+
objects,
|
|
374
|
+
action = "addObject",
|
|
375
|
+
waitForTasks,
|
|
376
|
+
batchSize = 1e3,
|
|
377
|
+
maxRetries = 100
|
|
378
|
+
}, requestOptions) {
|
|
371
379
|
let requests = [];
|
|
372
380
|
const responses = [];
|
|
373
381
|
const objectEntries = objects.entries();
|
|
@@ -380,7 +388,7 @@ function createSearchClient({
|
|
|
380
388
|
}
|
|
381
389
|
if (waitForTasks) {
|
|
382
390
|
for (const resp of responses) {
|
|
383
|
-
await this.waitForTask({ indexName, taskID: resp.taskID });
|
|
391
|
+
await this.waitForTask({ indexName, taskID: resp.taskID, maxRetries });
|
|
384
392
|
}
|
|
385
393
|
}
|
|
386
394
|
return responses;
|
|
@@ -394,11 +402,12 @@ function createSearchClient({
|
|
|
394
402
|
* @param saveObjects.objects - The array of `objects` to store in the given Algolia `indexName`.
|
|
395
403
|
* @param saveObjects.batchSize - The size of the chunk of `objects`. The number of `batch` calls will be equal to `length(objects) / batchSize`. Defaults to 1000.
|
|
396
404
|
* @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.
|
|
405
|
+
* @param saveObjects.maxRetries - The maximum number of retries when polling for task completion. 100 by default.
|
|
397
406
|
* @param requestOptions - The requestOptions to send along with the query, they will be forwarded to the `batch` method and merged with the transporter requestOptions.
|
|
398
407
|
*/
|
|
399
|
-
async saveObjects({ indexName, objects, waitForTasks, batchSize }, requestOptions) {
|
|
408
|
+
async saveObjects({ indexName, objects, waitForTasks, batchSize, maxRetries }, requestOptions) {
|
|
400
409
|
return await this.chunkedBatch(
|
|
401
|
-
{ indexName, objects, action: "addObject", waitForTasks, batchSize },
|
|
410
|
+
{ indexName, objects, action: "addObject", waitForTasks, batchSize, maxRetries },
|
|
402
411
|
requestOptions
|
|
403
412
|
);
|
|
404
413
|
},
|
|
@@ -411,16 +420,18 @@ function createSearchClient({
|
|
|
411
420
|
* @param deleteObjects.objectIDs - The objectIDs to delete.
|
|
412
421
|
* @param deleteObjects.batchSize - The size of the chunk of `objects`. The number of `batch` calls will be equal to `length(objects) / batchSize`. Defaults to 1000.
|
|
413
422
|
* @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.
|
|
423
|
+
* @param deleteObjects.maxRetries - The maximum number of retries when polling for task completion. 100 by default.
|
|
414
424
|
* @param requestOptions - The requestOptions to send along with the query, they will be forwarded to the `batch` method and merged with the transporter requestOptions.
|
|
415
425
|
*/
|
|
416
|
-
async deleteObjects({ indexName, objectIDs, waitForTasks, batchSize }, requestOptions) {
|
|
426
|
+
async deleteObjects({ indexName, objectIDs, waitForTasks, batchSize, maxRetries }, requestOptions) {
|
|
417
427
|
return await this.chunkedBatch(
|
|
418
428
|
{
|
|
419
429
|
indexName,
|
|
420
430
|
objects: objectIDs.map((objectID) => ({ objectID })),
|
|
421
431
|
action: "deleteObject",
|
|
422
432
|
waitForTasks,
|
|
423
|
-
batchSize
|
|
433
|
+
batchSize,
|
|
434
|
+
maxRetries
|
|
424
435
|
},
|
|
425
436
|
requestOptions
|
|
426
437
|
);
|
|
@@ -435,16 +446,18 @@ function createSearchClient({
|
|
|
435
446
|
* @param partialUpdateObjects.createIfNotExists - To be provided if non-existing objects are passed, otherwise, the call will fail.
|
|
436
447
|
* @param partialUpdateObjects.batchSize - The size of the chunk of `objects`. The number of `batch` calls will be equal to `length(objects) / batchSize`. Defaults to 1000.
|
|
437
448
|
* @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.
|
|
449
|
+
* @param partialUpdateObjects.maxRetries - The maximum number of retries when polling for task completion. 100 by default.
|
|
438
450
|
* @param requestOptions - The requestOptions to send along with the query, they will be forwarded to the `getTask` method and merged with the transporter requestOptions.
|
|
439
451
|
*/
|
|
440
|
-
async partialUpdateObjects({ indexName, objects, createIfNotExists, waitForTasks, batchSize }, requestOptions) {
|
|
452
|
+
async partialUpdateObjects({ indexName, objects, createIfNotExists, waitForTasks, batchSize, maxRetries }, requestOptions) {
|
|
441
453
|
return await this.chunkedBatch(
|
|
442
454
|
{
|
|
443
455
|
indexName,
|
|
444
456
|
objects,
|
|
445
457
|
action: createIfNotExists ? "partialUpdateObject" : "partialUpdateObjectNoCreate",
|
|
446
458
|
batchSize,
|
|
447
|
-
waitForTasks
|
|
459
|
+
waitForTasks,
|
|
460
|
+
maxRetries
|
|
448
461
|
},
|
|
449
462
|
requestOptions
|
|
450
463
|
);
|
|
@@ -459,9 +472,10 @@ function createSearchClient({
|
|
|
459
472
|
* @param replaceAllObjects.objects - The array of `objects` to store in the given Algolia `indexName`.
|
|
460
473
|
* @param replaceAllObjects.batchSize - The size of the chunk of `objects`. The number of `batch` calls will be equal to `objects.length / batchSize`. Defaults to 1000.
|
|
461
474
|
* @param replaceAllObjects.scopes - The `scopes` to keep from the index. Defaults to ['settings', 'rules', 'synonyms'].
|
|
475
|
+
* @param replaceAllObjects.maxRetries - The maximum number of retries when polling for task completion. 100 by default.
|
|
462
476
|
* @param requestOptions - The requestOptions to send along with the query, they will be forwarded to the `batch`, `operationIndex` and `getTask` method and merged with the transporter requestOptions.
|
|
463
477
|
*/
|
|
464
|
-
async replaceAllObjects({ indexName, objects, batchSize, scopes }, requestOptions) {
|
|
478
|
+
async replaceAllObjects({ indexName, objects, batchSize, scopes, maxRetries = 100 }, requestOptions) {
|
|
465
479
|
const randomSuffix = Math.floor(Math.random() * 1e6) + 1e5;
|
|
466
480
|
const tmpIndexName = `${indexName}_tmp_${randomSuffix}`;
|
|
467
481
|
if (scopes === void 0) {
|
|
@@ -480,12 +494,13 @@ function createSearchClient({
|
|
|
480
494
|
requestOptions
|
|
481
495
|
);
|
|
482
496
|
const batchResponses = await this.chunkedBatch(
|
|
483
|
-
{ indexName: tmpIndexName, objects, waitForTasks: true, batchSize },
|
|
497
|
+
{ indexName: tmpIndexName, objects, waitForTasks: true, batchSize, maxRetries },
|
|
484
498
|
requestOptions
|
|
485
499
|
);
|
|
486
500
|
await this.waitForTask({
|
|
487
501
|
indexName: tmpIndexName,
|
|
488
|
-
taskID: copyOperationResponse.taskID
|
|
502
|
+
taskID: copyOperationResponse.taskID,
|
|
503
|
+
maxRetries
|
|
489
504
|
});
|
|
490
505
|
copyOperationResponse = await this.operationIndex(
|
|
491
506
|
{
|
|
@@ -500,7 +515,8 @@ function createSearchClient({
|
|
|
500
515
|
);
|
|
501
516
|
await this.waitForTask({
|
|
502
517
|
indexName: tmpIndexName,
|
|
503
|
-
taskID: copyOperationResponse.taskID
|
|
518
|
+
taskID: copyOperationResponse.taskID,
|
|
519
|
+
maxRetries
|
|
504
520
|
});
|
|
505
521
|
const moveOperationResponse = await this.operationIndex(
|
|
506
522
|
{
|
|
@@ -511,7 +527,8 @@ function createSearchClient({
|
|
|
511
527
|
);
|
|
512
528
|
await this.waitForTask({
|
|
513
529
|
indexName: tmpIndexName,
|
|
514
|
-
taskID: moveOperationResponse.taskID
|
|
530
|
+
taskID: moveOperationResponse.taskID,
|
|
531
|
+
maxRetries
|
|
515
532
|
});
|
|
516
533
|
return { copyOperationResponse, batchResponses, moveOperationResponse };
|
|
517
534
|
} catch (error) {
|
|
@@ -2429,6 +2446,7 @@ function searchClient(appId, apiKey, options) {
|
|
|
2429
2446
|
* @param accountCopyIndex.destinationApiKey - The API Key of the `destinationAppID` to write the index to, must have write ACLs.
|
|
2430
2447
|
* @param accountCopyIndex.destinationIndexName - The name of the index to write the copied index to.
|
|
2431
2448
|
* @param accountCopyIndex.batchSize - The size of the chunk of `objects`. Defaults to 1000.
|
|
2449
|
+
* @param accountCopyIndex.maxRetries - The maximum number of retries when polling for task completion. 100 by default.
|
|
2432
2450
|
* @param requestOptions - The requestOptions to send along with the query, they will be forwarded to the `setSettings`, `saveRules`, `saveSynonyms` and `saveObjects` method and merged with the transporter requestOptions.
|
|
2433
2451
|
*/
|
|
2434
2452
|
async accountCopyIndex({
|
|
@@ -2436,7 +2454,8 @@ function searchClient(appId, apiKey, options) {
|
|
|
2436
2454
|
destinationAppID,
|
|
2437
2455
|
destinationApiKey,
|
|
2438
2456
|
destinationIndexName,
|
|
2439
|
-
batchSize
|
|
2457
|
+
batchSize,
|
|
2458
|
+
maxRetries = 100
|
|
2440
2459
|
}, requestOptions) {
|
|
2441
2460
|
const responses = [];
|
|
2442
2461
|
if (this.appId === destinationAppID) {
|
|
@@ -2508,7 +2527,7 @@ function searchClient(appId, apiKey, options) {
|
|
|
2508
2527
|
}
|
|
2509
2528
|
});
|
|
2510
2529
|
for (const response of responses) {
|
|
2511
|
-
await destinationClient.waitForTask({ indexName: destinationIndexName, taskID: response.taskID });
|
|
2530
|
+
await destinationClient.waitForTask({ indexName: destinationIndexName, taskID: response.taskID, maxRetries });
|
|
2512
2531
|
}
|
|
2513
2532
|
},
|
|
2514
2533
|
/**
|