@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/src/searchClient.js
CHANGED
|
@@ -7,7 +7,7 @@ import {
|
|
|
7
7
|
getAlgoliaAgent,
|
|
8
8
|
shuffle
|
|
9
9
|
} from "@algolia/client-common";
|
|
10
|
-
var apiClientVersion = "5.
|
|
10
|
+
var apiClientVersion = "5.53.0";
|
|
11
11
|
function getDefaultHosts(appId) {
|
|
12
12
|
return [
|
|
13
13
|
{
|
|
@@ -272,7 +272,7 @@ function createSearchClient({
|
|
|
272
272
|
browseRules({ indexName, searchRulesParams, ...browseRulesOptions }, requestOptions) {
|
|
273
273
|
const params = {
|
|
274
274
|
...searchRulesParams,
|
|
275
|
-
hitsPerPage: searchRulesParams
|
|
275
|
+
hitsPerPage: (searchRulesParams == null ? void 0 : searchRulesParams.hitsPerPage) || 1e3
|
|
276
276
|
};
|
|
277
277
|
return createIterablePromise({
|
|
278
278
|
func: (previousResponse) => {
|
|
@@ -309,7 +309,7 @@ function createSearchClient({
|
|
|
309
309
|
}, requestOptions) {
|
|
310
310
|
const params = {
|
|
311
311
|
...searchSynonymsParams,
|
|
312
|
-
page: searchSynonymsParams
|
|
312
|
+
page: (searchSynonymsParams == null ? void 0 : searchSynonymsParams.page) || 0,
|
|
313
313
|
hitsPerPage: 1e3
|
|
314
314
|
};
|
|
315
315
|
return createIterablePromise({
|
|
@@ -341,9 +341,17 @@ function createSearchClient({
|
|
|
341
341
|
* @param chunkedBatch.action - The `batch` `action` to perform on the given array of `objects`, defaults to `addObject`.
|
|
342
342
|
* @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.
|
|
343
343
|
* @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.
|
|
344
|
+
* @param chunkedBatch.maxRetries - The maximum number of retries when polling for task completion. 100 by default.
|
|
344
345
|
* @param requestOptions - The requestOptions to send along with the query, they will be forwarded to the `getTask` method and merged with the transporter requestOptions.
|
|
345
346
|
*/
|
|
346
|
-
async chunkedBatch({
|
|
347
|
+
async chunkedBatch({
|
|
348
|
+
indexName,
|
|
349
|
+
objects,
|
|
350
|
+
action = "addObject",
|
|
351
|
+
waitForTasks,
|
|
352
|
+
batchSize = 1e3,
|
|
353
|
+
maxRetries = 100
|
|
354
|
+
}, requestOptions) {
|
|
347
355
|
let requests = [];
|
|
348
356
|
const responses = [];
|
|
349
357
|
const objectEntries = objects.entries();
|
|
@@ -356,7 +364,7 @@ function createSearchClient({
|
|
|
356
364
|
}
|
|
357
365
|
if (waitForTasks) {
|
|
358
366
|
for (const resp of responses) {
|
|
359
|
-
await this.waitForTask({ indexName, taskID: resp.taskID });
|
|
367
|
+
await this.waitForTask({ indexName, taskID: resp.taskID, maxRetries });
|
|
360
368
|
}
|
|
361
369
|
}
|
|
362
370
|
return responses;
|
|
@@ -370,11 +378,12 @@ function createSearchClient({
|
|
|
370
378
|
* @param saveObjects.objects - The array of `objects` to store in the given Algolia `indexName`.
|
|
371
379
|
* @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.
|
|
372
380
|
* @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.
|
|
381
|
+
* @param saveObjects.maxRetries - The maximum number of retries when polling for task completion. 100 by default.
|
|
373
382
|
* @param requestOptions - The requestOptions to send along with the query, they will be forwarded to the `batch` method and merged with the transporter requestOptions.
|
|
374
383
|
*/
|
|
375
|
-
async saveObjects({ indexName, objects, waitForTasks, batchSize }, requestOptions) {
|
|
384
|
+
async saveObjects({ indexName, objects, waitForTasks, batchSize, maxRetries }, requestOptions) {
|
|
376
385
|
return await this.chunkedBatch(
|
|
377
|
-
{ indexName, objects, action: "addObject", waitForTasks, batchSize },
|
|
386
|
+
{ indexName, objects, action: "addObject", waitForTasks, batchSize, maxRetries },
|
|
378
387
|
requestOptions
|
|
379
388
|
);
|
|
380
389
|
},
|
|
@@ -387,16 +396,18 @@ function createSearchClient({
|
|
|
387
396
|
* @param deleteObjects.objectIDs - The objectIDs to delete.
|
|
388
397
|
* @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.
|
|
389
398
|
* @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.
|
|
399
|
+
* @param deleteObjects.maxRetries - The maximum number of retries when polling for task completion. 100 by default.
|
|
390
400
|
* @param requestOptions - The requestOptions to send along with the query, they will be forwarded to the `batch` method and merged with the transporter requestOptions.
|
|
391
401
|
*/
|
|
392
|
-
async deleteObjects({ indexName, objectIDs, waitForTasks, batchSize }, requestOptions) {
|
|
402
|
+
async deleteObjects({ indexName, objectIDs, waitForTasks, batchSize, maxRetries }, requestOptions) {
|
|
393
403
|
return await this.chunkedBatch(
|
|
394
404
|
{
|
|
395
405
|
indexName,
|
|
396
406
|
objects: objectIDs.map((objectID) => ({ objectID })),
|
|
397
407
|
action: "deleteObject",
|
|
398
408
|
waitForTasks,
|
|
399
|
-
batchSize
|
|
409
|
+
batchSize,
|
|
410
|
+
maxRetries
|
|
400
411
|
},
|
|
401
412
|
requestOptions
|
|
402
413
|
);
|
|
@@ -411,16 +422,18 @@ function createSearchClient({
|
|
|
411
422
|
* @param partialUpdateObjects.createIfNotExists - To be provided if non-existing objects are passed, otherwise, the call will fail.
|
|
412
423
|
* @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.
|
|
413
424
|
* @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.
|
|
425
|
+
* @param partialUpdateObjects.maxRetries - The maximum number of retries when polling for task completion. 100 by default.
|
|
414
426
|
* @param requestOptions - The requestOptions to send along with the query, they will be forwarded to the `getTask` method and merged with the transporter requestOptions.
|
|
415
427
|
*/
|
|
416
|
-
async partialUpdateObjects({ indexName, objects, createIfNotExists, waitForTasks, batchSize }, requestOptions) {
|
|
428
|
+
async partialUpdateObjects({ indexName, objects, createIfNotExists, waitForTasks, batchSize, maxRetries }, requestOptions) {
|
|
417
429
|
return await this.chunkedBatch(
|
|
418
430
|
{
|
|
419
431
|
indexName,
|
|
420
432
|
objects,
|
|
421
433
|
action: createIfNotExists ? "partialUpdateObject" : "partialUpdateObjectNoCreate",
|
|
422
434
|
batchSize,
|
|
423
|
-
waitForTasks
|
|
435
|
+
waitForTasks,
|
|
436
|
+
maxRetries
|
|
424
437
|
},
|
|
425
438
|
requestOptions
|
|
426
439
|
);
|
|
@@ -435,9 +448,10 @@ function createSearchClient({
|
|
|
435
448
|
* @param replaceAllObjects.objects - The array of `objects` to store in the given Algolia `indexName`.
|
|
436
449
|
* @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.
|
|
437
450
|
* @param replaceAllObjects.scopes - The `scopes` to keep from the index. Defaults to ['settings', 'rules', 'synonyms'].
|
|
451
|
+
* @param replaceAllObjects.maxRetries - The maximum number of retries when polling for task completion. 100 by default.
|
|
438
452
|
* @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.
|
|
439
453
|
*/
|
|
440
|
-
async replaceAllObjects({ indexName, objects, batchSize, scopes }, requestOptions) {
|
|
454
|
+
async replaceAllObjects({ indexName, objects, batchSize, scopes, maxRetries = 100 }, requestOptions) {
|
|
441
455
|
const randomSuffix = Math.floor(Math.random() * 1e6) + 1e5;
|
|
442
456
|
const tmpIndexName = `${indexName}_tmp_${randomSuffix}`;
|
|
443
457
|
if (scopes === void 0) {
|
|
@@ -456,12 +470,13 @@ function createSearchClient({
|
|
|
456
470
|
requestOptions
|
|
457
471
|
);
|
|
458
472
|
const batchResponses = await this.chunkedBatch(
|
|
459
|
-
{ indexName: tmpIndexName, objects, waitForTasks: true, batchSize },
|
|
473
|
+
{ indexName: tmpIndexName, objects, waitForTasks: true, batchSize, maxRetries },
|
|
460
474
|
requestOptions
|
|
461
475
|
);
|
|
462
476
|
await this.waitForTask({
|
|
463
477
|
indexName: tmpIndexName,
|
|
464
|
-
taskID: copyOperationResponse.taskID
|
|
478
|
+
taskID: copyOperationResponse.taskID,
|
|
479
|
+
maxRetries
|
|
465
480
|
});
|
|
466
481
|
copyOperationResponse = await this.operationIndex(
|
|
467
482
|
{
|
|
@@ -476,7 +491,8 @@ function createSearchClient({
|
|
|
476
491
|
);
|
|
477
492
|
await this.waitForTask({
|
|
478
493
|
indexName: tmpIndexName,
|
|
479
|
-
taskID: copyOperationResponse.taskID
|
|
494
|
+
taskID: copyOperationResponse.taskID,
|
|
495
|
+
maxRetries
|
|
480
496
|
});
|
|
481
497
|
const moveOperationResponse = await this.operationIndex(
|
|
482
498
|
{
|
|
@@ -487,7 +503,8 @@ function createSearchClient({
|
|
|
487
503
|
);
|
|
488
504
|
await this.waitForTask({
|
|
489
505
|
indexName: tmpIndexName,
|
|
490
|
-
taskID: moveOperationResponse.taskID
|
|
506
|
+
taskID: moveOperationResponse.taskID,
|
|
507
|
+
maxRetries
|
|
491
508
|
});
|
|
492
509
|
return { copyOperationResponse, batchResponses, moveOperationResponse };
|
|
493
510
|
} catch (error) {
|
|
@@ -2342,7 +2359,4 @@ export {
|
|
|
2342
2359
|
apiClientVersion,
|
|
2343
2360
|
createSearchClient
|
|
2344
2361
|
};
|
|
2345
|
-
//# sourceMappingURL=searchClient.js.mapClientVersion,
|
|
2346
|
-
createSearchClient
|
|
2347
|
-
};
|
|
2348
2362
|
//# sourceMappingURL=searchClient.js.map
|