@algolia/client-search 5.17.1 → 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 +63 -50
- package/dist/builds/fetch.js.map +1 -1
- package/dist/builds/node.cjs +62 -49
- package/dist/builds/node.cjs.map +1 -1
- package/dist/builds/node.js +62 -49
- package/dist/builds/node.js.map +1 -1
- package/dist/builds/worker.js +2408 -0
- package/dist/builds/worker.js.map +1 -0
- 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 +3894 -0
- package/package.json +10 -10
|
@@ -25,7 +25,7 @@ __export(searchClient_exports, {
|
|
|
25
25
|
});
|
|
26
26
|
module.exports = __toCommonJS(searchClient_exports);
|
|
27
27
|
var import_client_common = require("@algolia/client-common");
|
|
28
|
-
var apiClientVersion = "5.
|
|
28
|
+
var apiClientVersion = "5.19.0";
|
|
29
29
|
function getDefaultHosts(appId) {
|
|
30
30
|
return [
|
|
31
31
|
{
|
|
@@ -90,6 +90,10 @@ function createSearchClient({
|
|
|
90
90
|
* The `appId` currently in use.
|
|
91
91
|
*/
|
|
92
92
|
appId: appIdOption,
|
|
93
|
+
/**
|
|
94
|
+
* The `apiKey` currently in use.
|
|
95
|
+
*/
|
|
96
|
+
apiKey: apiKeyOption,
|
|
93
97
|
/**
|
|
94
98
|
* Clears the cache of the transporter for the `requestsCache` and `responsesCache` properties.
|
|
95
99
|
*/
|
|
@@ -448,57 +452,66 @@ function createSearchClient({
|
|
|
448
452
|
* @param replaceAllObjects.indexName - The `indexName` to replace `objects` in.
|
|
449
453
|
* @param replaceAllObjects.objects - The array of `objects` to store in the given Algolia `indexName`.
|
|
450
454
|
* @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.
|
|
455
|
+
* @param replaceAllObjects.scopes - The `scopes` to keep from the index. Defaults to ['settings', 'rules', 'synonyms'].
|
|
451
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.
|
|
452
457
|
*/
|
|
453
|
-
async replaceAllObjects({ indexName, objects, batchSize }, requestOptions) {
|
|
458
|
+
async replaceAllObjects({ indexName, objects, batchSize, scopes }, requestOptions) {
|
|
454
459
|
const randomSuffix = Math.floor(Math.random() * 1e6) + 1e5;
|
|
455
460
|
const tmpIndexName = `${indexName}_tmp_${randomSuffix}`;
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
{
|
|
477
|
-
indexName,
|
|
478
|
-
operationIndexParams: {
|
|
479
|
-
operation: "copy",
|
|
480
|
-
destination: tmpIndexName,
|
|
481
|
-
scope: ["settings", "rules", "synonyms"]
|
|
482
|
-
}
|
|
483
|
-
},
|
|
484
|
-
requestOptions
|
|
485
|
-
);
|
|
486
|
-
await this.waitForTask({
|
|
487
|
-
indexName: tmpIndexName,
|
|
488
|
-
taskID: copyOperationResponse.taskID
|
|
489
|
-
});
|
|
490
|
-
const moveOperationResponse = await this.operationIndex(
|
|
491
|
-
{
|
|
461
|
+
if (scopes === void 0) {
|
|
462
|
+
scopes = ["settings", "rules", "synonyms"];
|
|
463
|
+
}
|
|
464
|
+
try {
|
|
465
|
+
let copyOperationResponse = await this.operationIndex(
|
|
466
|
+
{
|
|
467
|
+
indexName,
|
|
468
|
+
operationIndexParams: {
|
|
469
|
+
operation: "copy",
|
|
470
|
+
destination: tmpIndexName,
|
|
471
|
+
scope: scopes
|
|
472
|
+
}
|
|
473
|
+
},
|
|
474
|
+
requestOptions
|
|
475
|
+
);
|
|
476
|
+
const batchResponses = await this.chunkedBatch(
|
|
477
|
+
{ indexName: tmpIndexName, objects, waitForTasks: true, batchSize },
|
|
478
|
+
requestOptions
|
|
479
|
+
);
|
|
480
|
+
await this.waitForTask({
|
|
492
481
|
indexName: tmpIndexName,
|
|
493
|
-
|
|
494
|
-
}
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
482
|
+
taskID: copyOperationResponse.taskID
|
|
483
|
+
});
|
|
484
|
+
copyOperationResponse = await this.operationIndex(
|
|
485
|
+
{
|
|
486
|
+
indexName,
|
|
487
|
+
operationIndexParams: {
|
|
488
|
+
operation: "copy",
|
|
489
|
+
destination: tmpIndexName,
|
|
490
|
+
scope: scopes
|
|
491
|
+
}
|
|
492
|
+
},
|
|
493
|
+
requestOptions
|
|
494
|
+
);
|
|
495
|
+
await this.waitForTask({
|
|
496
|
+
indexName: tmpIndexName,
|
|
497
|
+
taskID: copyOperationResponse.taskID
|
|
498
|
+
});
|
|
499
|
+
const moveOperationResponse = await this.operationIndex(
|
|
500
|
+
{
|
|
501
|
+
indexName: tmpIndexName,
|
|
502
|
+
operationIndexParams: { operation: "move", destination: indexName }
|
|
503
|
+
},
|
|
504
|
+
requestOptions
|
|
505
|
+
);
|
|
506
|
+
await this.waitForTask({
|
|
507
|
+
indexName: tmpIndexName,
|
|
508
|
+
taskID: moveOperationResponse.taskID
|
|
509
|
+
});
|
|
510
|
+
return { copyOperationResponse, batchResponses, moveOperationResponse };
|
|
511
|
+
} catch (error) {
|
|
512
|
+
await this.deleteIndex({ indexName: tmpIndexName });
|
|
513
|
+
throw error;
|
|
514
|
+
}
|
|
502
515
|
},
|
|
503
516
|
async indexExists({ indexName }) {
|
|
504
517
|
try {
|