@algolia/client-search 5.18.0 → 5.20.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 +26 -17
- package/dist/builds/browser.js +60 -47
- 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 +1 -1
- package/dist/builds/fetch.js +60 -47
- package/dist/builds/fetch.js.map +1 -1
- package/dist/builds/node.cjs +60 -47
- package/dist/builds/node.cjs.map +1 -1
- package/dist/builds/node.js +60 -47
- package/dist/builds/node.js.map +1 -1
- package/dist/builds/worker.js +60 -47
- package/dist/builds/worker.js.map +1 -1
- package/dist/fetch.d.ts +26 -17
- package/dist/node.d.cts +26 -17
- package/dist/node.d.ts +26 -17
- package/dist/src/searchClient.cjs +60 -47
- package/dist/src/searchClient.cjs.map +1 -1
- package/dist/src/searchClient.js +60 -47
- package/dist/src/searchClient.js.map +1 -1
- package/dist/worker.d.ts +26 -17
- package/package.json +10 -10
package/dist/builds/node.js
CHANGED
|
@@ -12,7 +12,7 @@ import {
|
|
|
12
12
|
getAlgoliaAgent,
|
|
13
13
|
shuffle
|
|
14
14
|
} from "@algolia/client-common";
|
|
15
|
-
var apiClientVersion = "5.
|
|
15
|
+
var apiClientVersion = "5.20.0";
|
|
16
16
|
function getDefaultHosts(appId) {
|
|
17
17
|
return [
|
|
18
18
|
{
|
|
@@ -77,6 +77,10 @@ function createSearchClient({
|
|
|
77
77
|
* The `appId` currently in use.
|
|
78
78
|
*/
|
|
79
79
|
appId: appIdOption,
|
|
80
|
+
/**
|
|
81
|
+
* The `apiKey` currently in use.
|
|
82
|
+
*/
|
|
83
|
+
apiKey: apiKeyOption,
|
|
80
84
|
/**
|
|
81
85
|
* Clears the cache of the transporter for the `requestsCache` and `responsesCache` properties.
|
|
82
86
|
*/
|
|
@@ -435,57 +439,66 @@ function createSearchClient({
|
|
|
435
439
|
* @param replaceAllObjects.indexName - The `indexName` to replace `objects` in.
|
|
436
440
|
* @param replaceAllObjects.objects - The array of `objects` to store in the given Algolia `indexName`.
|
|
437
441
|
* @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.
|
|
442
|
+
* @param replaceAllObjects.scopes - The `scopes` to keep from the index. Defaults to ['settings', 'rules', 'synonyms'].
|
|
438
443
|
* @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
444
|
*/
|
|
440
|
-
async replaceAllObjects({ indexName, objects, batchSize }, requestOptions) {
|
|
445
|
+
async replaceAllObjects({ indexName, objects, batchSize, scopes }, requestOptions) {
|
|
441
446
|
const randomSuffix = Math.floor(Math.random() * 1e6) + 1e5;
|
|
442
447
|
const tmpIndexName = `${indexName}_tmp_${randomSuffix}`;
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
{
|
|
464
|
-
indexName,
|
|
465
|
-
operationIndexParams: {
|
|
466
|
-
operation: "copy",
|
|
467
|
-
destination: tmpIndexName,
|
|
468
|
-
scope: ["settings", "rules", "synonyms"]
|
|
469
|
-
}
|
|
470
|
-
},
|
|
471
|
-
requestOptions
|
|
472
|
-
);
|
|
473
|
-
await this.waitForTask({
|
|
474
|
-
indexName: tmpIndexName,
|
|
475
|
-
taskID: copyOperationResponse.taskID
|
|
476
|
-
});
|
|
477
|
-
const moveOperationResponse = await this.operationIndex(
|
|
478
|
-
{
|
|
448
|
+
if (scopes === void 0) {
|
|
449
|
+
scopes = ["settings", "rules", "synonyms"];
|
|
450
|
+
}
|
|
451
|
+
try {
|
|
452
|
+
let copyOperationResponse = await this.operationIndex(
|
|
453
|
+
{
|
|
454
|
+
indexName,
|
|
455
|
+
operationIndexParams: {
|
|
456
|
+
operation: "copy",
|
|
457
|
+
destination: tmpIndexName,
|
|
458
|
+
scope: scopes
|
|
459
|
+
}
|
|
460
|
+
},
|
|
461
|
+
requestOptions
|
|
462
|
+
);
|
|
463
|
+
const batchResponses = await this.chunkedBatch(
|
|
464
|
+
{ indexName: tmpIndexName, objects, waitForTasks: true, batchSize },
|
|
465
|
+
requestOptions
|
|
466
|
+
);
|
|
467
|
+
await this.waitForTask({
|
|
479
468
|
indexName: tmpIndexName,
|
|
480
|
-
|
|
481
|
-
}
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
469
|
+
taskID: copyOperationResponse.taskID
|
|
470
|
+
});
|
|
471
|
+
copyOperationResponse = await this.operationIndex(
|
|
472
|
+
{
|
|
473
|
+
indexName,
|
|
474
|
+
operationIndexParams: {
|
|
475
|
+
operation: "copy",
|
|
476
|
+
destination: tmpIndexName,
|
|
477
|
+
scope: scopes
|
|
478
|
+
}
|
|
479
|
+
},
|
|
480
|
+
requestOptions
|
|
481
|
+
);
|
|
482
|
+
await this.waitForTask({
|
|
483
|
+
indexName: tmpIndexName,
|
|
484
|
+
taskID: copyOperationResponse.taskID
|
|
485
|
+
});
|
|
486
|
+
const moveOperationResponse = await this.operationIndex(
|
|
487
|
+
{
|
|
488
|
+
indexName: tmpIndexName,
|
|
489
|
+
operationIndexParams: { operation: "move", destination: indexName }
|
|
490
|
+
},
|
|
491
|
+
requestOptions
|
|
492
|
+
);
|
|
493
|
+
await this.waitForTask({
|
|
494
|
+
indexName: tmpIndexName,
|
|
495
|
+
taskID: moveOperationResponse.taskID
|
|
496
|
+
});
|
|
497
|
+
return { copyOperationResponse, batchResponses, moveOperationResponse };
|
|
498
|
+
} catch (error) {
|
|
499
|
+
await this.deleteIndex({ indexName: tmpIndexName });
|
|
500
|
+
throw error;
|
|
501
|
+
}
|
|
489
502
|
},
|
|
490
503
|
async indexExists({ indexName }) {
|
|
491
504
|
try {
|