@algolia/client-search 5.52.0 → 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 +31 -14
- package/dist/src/searchClient.js.map +1 -1
- package/dist/worker.d.ts +88 -14
- package/package.json +9 -9
package/dist/builds/worker.js
CHANGED
|
@@ -11,7 +11,7 @@ import {
|
|
|
11
11
|
getAlgoliaAgent,
|
|
12
12
|
shuffle
|
|
13
13
|
} from "@algolia/client-common";
|
|
14
|
-
var apiClientVersion = "5.
|
|
14
|
+
var apiClientVersion = "5.53.0";
|
|
15
15
|
function getDefaultHosts(appId) {
|
|
16
16
|
return [
|
|
17
17
|
{
|
|
@@ -345,9 +345,17 @@ function createSearchClient({
|
|
|
345
345
|
* @param chunkedBatch.action - The `batch` `action` to perform on the given array of `objects`, defaults to `addObject`.
|
|
346
346
|
* @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.
|
|
347
347
|
* @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.
|
|
348
|
+
* @param chunkedBatch.maxRetries - The maximum number of retries when polling for task completion. 100 by default.
|
|
348
349
|
* @param requestOptions - The requestOptions to send along with the query, they will be forwarded to the `getTask` method and merged with the transporter requestOptions.
|
|
349
350
|
*/
|
|
350
|
-
async chunkedBatch({
|
|
351
|
+
async chunkedBatch({
|
|
352
|
+
indexName,
|
|
353
|
+
objects,
|
|
354
|
+
action = "addObject",
|
|
355
|
+
waitForTasks,
|
|
356
|
+
batchSize = 1e3,
|
|
357
|
+
maxRetries = 100
|
|
358
|
+
}, requestOptions) {
|
|
351
359
|
let requests = [];
|
|
352
360
|
const responses = [];
|
|
353
361
|
const objectEntries = objects.entries();
|
|
@@ -360,7 +368,7 @@ function createSearchClient({
|
|
|
360
368
|
}
|
|
361
369
|
if (waitForTasks) {
|
|
362
370
|
for (const resp of responses) {
|
|
363
|
-
await this.waitForTask({ indexName, taskID: resp.taskID });
|
|
371
|
+
await this.waitForTask({ indexName, taskID: resp.taskID, maxRetries });
|
|
364
372
|
}
|
|
365
373
|
}
|
|
366
374
|
return responses;
|
|
@@ -374,11 +382,12 @@ function createSearchClient({
|
|
|
374
382
|
* @param saveObjects.objects - The array of `objects` to store in the given Algolia `indexName`.
|
|
375
383
|
* @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.
|
|
376
384
|
* @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.
|
|
385
|
+
* @param saveObjects.maxRetries - The maximum number of retries when polling for task completion. 100 by default.
|
|
377
386
|
* @param requestOptions - The requestOptions to send along with the query, they will be forwarded to the `batch` method and merged with the transporter requestOptions.
|
|
378
387
|
*/
|
|
379
|
-
async saveObjects({ indexName, objects, waitForTasks, batchSize }, requestOptions) {
|
|
388
|
+
async saveObjects({ indexName, objects, waitForTasks, batchSize, maxRetries }, requestOptions) {
|
|
380
389
|
return await this.chunkedBatch(
|
|
381
|
-
{ indexName, objects, action: "addObject", waitForTasks, batchSize },
|
|
390
|
+
{ indexName, objects, action: "addObject", waitForTasks, batchSize, maxRetries },
|
|
382
391
|
requestOptions
|
|
383
392
|
);
|
|
384
393
|
},
|
|
@@ -391,16 +400,18 @@ function createSearchClient({
|
|
|
391
400
|
* @param deleteObjects.objectIDs - The objectIDs to delete.
|
|
392
401
|
* @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.
|
|
393
402
|
* @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.
|
|
403
|
+
* @param deleteObjects.maxRetries - The maximum number of retries when polling for task completion. 100 by default.
|
|
394
404
|
* @param requestOptions - The requestOptions to send along with the query, they will be forwarded to the `batch` method and merged with the transporter requestOptions.
|
|
395
405
|
*/
|
|
396
|
-
async deleteObjects({ indexName, objectIDs, waitForTasks, batchSize }, requestOptions) {
|
|
406
|
+
async deleteObjects({ indexName, objectIDs, waitForTasks, batchSize, maxRetries }, requestOptions) {
|
|
397
407
|
return await this.chunkedBatch(
|
|
398
408
|
{
|
|
399
409
|
indexName,
|
|
400
410
|
objects: objectIDs.map((objectID) => ({ objectID })),
|
|
401
411
|
action: "deleteObject",
|
|
402
412
|
waitForTasks,
|
|
403
|
-
batchSize
|
|
413
|
+
batchSize,
|
|
414
|
+
maxRetries
|
|
404
415
|
},
|
|
405
416
|
requestOptions
|
|
406
417
|
);
|
|
@@ -415,16 +426,18 @@ function createSearchClient({
|
|
|
415
426
|
* @param partialUpdateObjects.createIfNotExists - To be provided if non-existing objects are passed, otherwise, the call will fail.
|
|
416
427
|
* @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.
|
|
417
428
|
* @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.
|
|
429
|
+
* @param partialUpdateObjects.maxRetries - The maximum number of retries when polling for task completion. 100 by default.
|
|
418
430
|
* @param requestOptions - The requestOptions to send along with the query, they will be forwarded to the `getTask` method and merged with the transporter requestOptions.
|
|
419
431
|
*/
|
|
420
|
-
async partialUpdateObjects({ indexName, objects, createIfNotExists, waitForTasks, batchSize }, requestOptions) {
|
|
432
|
+
async partialUpdateObjects({ indexName, objects, createIfNotExists, waitForTasks, batchSize, maxRetries }, requestOptions) {
|
|
421
433
|
return await this.chunkedBatch(
|
|
422
434
|
{
|
|
423
435
|
indexName,
|
|
424
436
|
objects,
|
|
425
437
|
action: createIfNotExists ? "partialUpdateObject" : "partialUpdateObjectNoCreate",
|
|
426
438
|
batchSize,
|
|
427
|
-
waitForTasks
|
|
439
|
+
waitForTasks,
|
|
440
|
+
maxRetries
|
|
428
441
|
},
|
|
429
442
|
requestOptions
|
|
430
443
|
);
|
|
@@ -439,9 +452,10 @@ function createSearchClient({
|
|
|
439
452
|
* @param replaceAllObjects.objects - The array of `objects` to store in the given Algolia `indexName`.
|
|
440
453
|
* @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.
|
|
441
454
|
* @param replaceAllObjects.scopes - The `scopes` to keep from the index. Defaults to ['settings', 'rules', 'synonyms'].
|
|
455
|
+
* @param replaceAllObjects.maxRetries - The maximum number of retries when polling for task completion. 100 by default.
|
|
442
456
|
* @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.
|
|
443
457
|
*/
|
|
444
|
-
async replaceAllObjects({ indexName, objects, batchSize, scopes }, requestOptions) {
|
|
458
|
+
async replaceAllObjects({ indexName, objects, batchSize, scopes, maxRetries = 100 }, requestOptions) {
|
|
445
459
|
const randomSuffix = Math.floor(Math.random() * 1e6) + 1e5;
|
|
446
460
|
const tmpIndexName = `${indexName}_tmp_${randomSuffix}`;
|
|
447
461
|
if (scopes === void 0) {
|
|
@@ -460,12 +474,13 @@ function createSearchClient({
|
|
|
460
474
|
requestOptions
|
|
461
475
|
);
|
|
462
476
|
const batchResponses = await this.chunkedBatch(
|
|
463
|
-
{ indexName: tmpIndexName, objects, waitForTasks: true, batchSize },
|
|
477
|
+
{ indexName: tmpIndexName, objects, waitForTasks: true, batchSize, maxRetries },
|
|
464
478
|
requestOptions
|
|
465
479
|
);
|
|
466
480
|
await this.waitForTask({
|
|
467
481
|
indexName: tmpIndexName,
|
|
468
|
-
taskID: copyOperationResponse.taskID
|
|
482
|
+
taskID: copyOperationResponse.taskID,
|
|
483
|
+
maxRetries
|
|
469
484
|
});
|
|
470
485
|
copyOperationResponse = await this.operationIndex(
|
|
471
486
|
{
|
|
@@ -480,7 +495,8 @@ function createSearchClient({
|
|
|
480
495
|
);
|
|
481
496
|
await this.waitForTask({
|
|
482
497
|
indexName: tmpIndexName,
|
|
483
|
-
taskID: copyOperationResponse.taskID
|
|
498
|
+
taskID: copyOperationResponse.taskID,
|
|
499
|
+
maxRetries
|
|
484
500
|
});
|
|
485
501
|
const moveOperationResponse = await this.operationIndex(
|
|
486
502
|
{
|
|
@@ -491,7 +507,8 @@ function createSearchClient({
|
|
|
491
507
|
);
|
|
492
508
|
await this.waitForTask({
|
|
493
509
|
indexName: tmpIndexName,
|
|
494
|
-
taskID: moveOperationResponse.taskID
|
|
510
|
+
taskID: moveOperationResponse.taskID,
|
|
511
|
+
maxRetries
|
|
495
512
|
});
|
|
496
513
|
return { copyOperationResponse, batchResponses, moveOperationResponse };
|
|
497
514
|
} catch (error) {
|