@algolia/client-search 5.18.0 → 5.19.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 +11 -2
- 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 +11 -2
- package/dist/node.d.cts +11 -2
- package/dist/node.d.ts +11 -2
- 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 +11 -2
- package/package.json +8 -8
package/dist/builds/node.cjs
CHANGED
|
@@ -30,7 +30,7 @@ var import_client_common2 = require("@algolia/client-common");
|
|
|
30
30
|
|
|
31
31
|
// src/searchClient.ts
|
|
32
32
|
var import_client_common = require("@algolia/client-common");
|
|
33
|
-
var apiClientVersion = "5.
|
|
33
|
+
var apiClientVersion = "5.19.0";
|
|
34
34
|
function getDefaultHosts(appId) {
|
|
35
35
|
return [
|
|
36
36
|
{
|
|
@@ -95,6 +95,10 @@ function createSearchClient({
|
|
|
95
95
|
* The `appId` currently in use.
|
|
96
96
|
*/
|
|
97
97
|
appId: appIdOption,
|
|
98
|
+
/**
|
|
99
|
+
* The `apiKey` currently in use.
|
|
100
|
+
*/
|
|
101
|
+
apiKey: apiKeyOption,
|
|
98
102
|
/**
|
|
99
103
|
* Clears the cache of the transporter for the `requestsCache` and `responsesCache` properties.
|
|
100
104
|
*/
|
|
@@ -453,57 +457,66 @@ function createSearchClient({
|
|
|
453
457
|
* @param replaceAllObjects.indexName - The `indexName` to replace `objects` in.
|
|
454
458
|
* @param replaceAllObjects.objects - The array of `objects` to store in the given Algolia `indexName`.
|
|
455
459
|
* @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.
|
|
460
|
+
* @param replaceAllObjects.scopes - The `scopes` to keep from the index. Defaults to ['settings', 'rules', 'synonyms'].
|
|
456
461
|
* @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.
|
|
457
462
|
*/
|
|
458
|
-
async replaceAllObjects({ indexName, objects, batchSize }, requestOptions) {
|
|
463
|
+
async replaceAllObjects({ indexName, objects, batchSize, scopes }, requestOptions) {
|
|
459
464
|
const randomSuffix = Math.floor(Math.random() * 1e6) + 1e5;
|
|
460
465
|
const tmpIndexName = `${indexName}_tmp_${randomSuffix}`;
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
{
|
|
482
|
-
indexName,
|
|
483
|
-
operationIndexParams: {
|
|
484
|
-
operation: "copy",
|
|
485
|
-
destination: tmpIndexName,
|
|
486
|
-
scope: ["settings", "rules", "synonyms"]
|
|
487
|
-
}
|
|
488
|
-
},
|
|
489
|
-
requestOptions
|
|
490
|
-
);
|
|
491
|
-
await this.waitForTask({
|
|
492
|
-
indexName: tmpIndexName,
|
|
493
|
-
taskID: copyOperationResponse.taskID
|
|
494
|
-
});
|
|
495
|
-
const moveOperationResponse = await this.operationIndex(
|
|
496
|
-
{
|
|
466
|
+
if (scopes === void 0) {
|
|
467
|
+
scopes = ["settings", "rules", "synonyms"];
|
|
468
|
+
}
|
|
469
|
+
try {
|
|
470
|
+
let copyOperationResponse = await this.operationIndex(
|
|
471
|
+
{
|
|
472
|
+
indexName,
|
|
473
|
+
operationIndexParams: {
|
|
474
|
+
operation: "copy",
|
|
475
|
+
destination: tmpIndexName,
|
|
476
|
+
scope: scopes
|
|
477
|
+
}
|
|
478
|
+
},
|
|
479
|
+
requestOptions
|
|
480
|
+
);
|
|
481
|
+
const batchResponses = await this.chunkedBatch(
|
|
482
|
+
{ indexName: tmpIndexName, objects, waitForTasks: true, batchSize },
|
|
483
|
+
requestOptions
|
|
484
|
+
);
|
|
485
|
+
await this.waitForTask({
|
|
497
486
|
indexName: tmpIndexName,
|
|
498
|
-
|
|
499
|
-
}
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
487
|
+
taskID: copyOperationResponse.taskID
|
|
488
|
+
});
|
|
489
|
+
copyOperationResponse = await this.operationIndex(
|
|
490
|
+
{
|
|
491
|
+
indexName,
|
|
492
|
+
operationIndexParams: {
|
|
493
|
+
operation: "copy",
|
|
494
|
+
destination: tmpIndexName,
|
|
495
|
+
scope: scopes
|
|
496
|
+
}
|
|
497
|
+
},
|
|
498
|
+
requestOptions
|
|
499
|
+
);
|
|
500
|
+
await this.waitForTask({
|
|
501
|
+
indexName: tmpIndexName,
|
|
502
|
+
taskID: copyOperationResponse.taskID
|
|
503
|
+
});
|
|
504
|
+
const moveOperationResponse = await this.operationIndex(
|
|
505
|
+
{
|
|
506
|
+
indexName: tmpIndexName,
|
|
507
|
+
operationIndexParams: { operation: "move", destination: indexName }
|
|
508
|
+
},
|
|
509
|
+
requestOptions
|
|
510
|
+
);
|
|
511
|
+
await this.waitForTask({
|
|
512
|
+
indexName: tmpIndexName,
|
|
513
|
+
taskID: moveOperationResponse.taskID
|
|
514
|
+
});
|
|
515
|
+
return { copyOperationResponse, batchResponses, moveOperationResponse };
|
|
516
|
+
} catch (error) {
|
|
517
|
+
await this.deleteIndex({ indexName: tmpIndexName });
|
|
518
|
+
throw error;
|
|
519
|
+
}
|
|
507
520
|
},
|
|
508
521
|
async indexExists({ indexName }) {
|
|
509
522
|
try {
|