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