@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
package/dist/builds/node.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
// builds/node.ts
|
|
2
|
+
import { createHmac } from "node:crypto";
|
|
2
3
|
import { createHttpRequester } from "@algolia/requester-node-http";
|
|
3
4
|
import { createMemoryCache, createNullCache, createNullLogger, serializeQueryParameters } from "@algolia/client-common";
|
|
4
5
|
|
|
@@ -11,7 +12,7 @@ import {
|
|
|
11
12
|
getAlgoliaAgent,
|
|
12
13
|
shuffle
|
|
13
14
|
} from "@algolia/client-common";
|
|
14
|
-
var apiClientVersion = "5.
|
|
15
|
+
var apiClientVersion = "5.19.0";
|
|
15
16
|
function getDefaultHosts(appId) {
|
|
16
17
|
return [
|
|
17
18
|
{
|
|
@@ -76,6 +77,10 @@ function createSearchClient({
|
|
|
76
77
|
* The `appId` currently in use.
|
|
77
78
|
*/
|
|
78
79
|
appId: appIdOption,
|
|
80
|
+
/**
|
|
81
|
+
* The `apiKey` currently in use.
|
|
82
|
+
*/
|
|
83
|
+
apiKey: apiKeyOption,
|
|
79
84
|
/**
|
|
80
85
|
* Clears the cache of the transporter for the `requestsCache` and `responsesCache` properties.
|
|
81
86
|
*/
|
|
@@ -434,57 +439,66 @@ function createSearchClient({
|
|
|
434
439
|
* @param replaceAllObjects.indexName - The `indexName` to replace `objects` in.
|
|
435
440
|
* @param replaceAllObjects.objects - The array of `objects` to store in the given Algolia `indexName`.
|
|
436
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'].
|
|
437
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.
|
|
438
444
|
*/
|
|
439
|
-
async replaceAllObjects({ indexName, objects, batchSize }, requestOptions) {
|
|
445
|
+
async replaceAllObjects({ indexName, objects, batchSize, scopes }, requestOptions) {
|
|
440
446
|
const randomSuffix = Math.floor(Math.random() * 1e6) + 1e5;
|
|
441
447
|
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
|
-
{
|
|
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({
|
|
478
468
|
indexName: tmpIndexName,
|
|
479
|
-
|
|
480
|
-
}
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
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
|
+
}
|
|
488
502
|
},
|
|
489
503
|
async indexExists({ indexName }) {
|
|
490
504
|
try {
|
|
@@ -2300,7 +2314,6 @@ function createSearchClient({
|
|
|
2300
2314
|
}
|
|
2301
2315
|
|
|
2302
2316
|
// builds/node.ts
|
|
2303
|
-
import { createHmac } from "node:crypto";
|
|
2304
2317
|
function searchClient(appId, apiKey, options) {
|
|
2305
2318
|
if (!appId || typeof appId !== "string") {
|
|
2306
2319
|
throw new Error("`appId` is missing.");
|
|
@@ -2362,7 +2375,7 @@ function searchClient(appId, apiKey, options) {
|
|
|
2362
2375
|
* @param getSecuredApiKeyRemainingValidity.securedApiKey - The secured API key generated with the `generateSecuredApiKey` method.
|
|
2363
2376
|
*/
|
|
2364
2377
|
getSecuredApiKeyRemainingValidity: ({ securedApiKey }) => {
|
|
2365
|
-
const decodedString =
|
|
2378
|
+
const decodedString = atob(securedApiKey);
|
|
2366
2379
|
const regex = /validUntil=(\d+)/;
|
|
2367
2380
|
const match = decodedString.match(regex);
|
|
2368
2381
|
if (match === null) {
|