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