@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/README.md
CHANGED
|
@@ -41,11 +41,11 @@ All of our clients comes with type definition, and are available for both browse
|
|
|
41
41
|
### With a package manager
|
|
42
42
|
|
|
43
43
|
```bash
|
|
44
|
-
yarn add @algolia/client-search@5.
|
|
44
|
+
yarn add @algolia/client-search@5.19.0
|
|
45
45
|
# or
|
|
46
|
-
npm install @algolia/client-search@5.
|
|
46
|
+
npm install @algolia/client-search@5.19.0
|
|
47
47
|
# or
|
|
48
|
-
pnpm add @algolia/client-search@5.
|
|
48
|
+
pnpm add @algolia/client-search@5.19.0
|
|
49
49
|
```
|
|
50
50
|
|
|
51
51
|
### Without a package manager
|
|
@@ -53,7 +53,7 @@ pnpm add @algolia/client-search@5.17.1
|
|
|
53
53
|
Add the following JavaScript snippet to the <head> of your website:
|
|
54
54
|
|
|
55
55
|
```html
|
|
56
|
-
<script src="https://cdn.jsdelivr.net/npm/@algolia/client-search@5.
|
|
56
|
+
<script src="https://cdn.jsdelivr.net/npm/@algolia/client-search@5.19.0/dist/builds/browser.umd.js"></script>
|
|
57
57
|
```
|
|
58
58
|
|
|
59
59
|
### Usage
|
package/dist/browser.d.ts
CHANGED
|
@@ -3019,15 +3019,23 @@ type ReplaceAllObjectsOptions = {
|
|
|
3019
3019
|
* The size of the chunk of `objects`. The number of `batch` calls will be equal to `length(objects) / batchSize`. Defaults to 1000.
|
|
3020
3020
|
*/
|
|
3021
3021
|
batchSize?: number;
|
|
3022
|
+
/**
|
|
3023
|
+
* The `scopes` to keep from the index. Defaults to ['settings', 'rules', 'synonyms'].
|
|
3024
|
+
*/
|
|
3025
|
+
scopes?: Array<ScopeType>;
|
|
3022
3026
|
};
|
|
3023
3027
|
|
|
3024
|
-
declare const apiClientVersion = "5.
|
|
3028
|
+
declare const apiClientVersion = "5.19.0";
|
|
3025
3029
|
declare function createSearchClient({ appId: appIdOption, apiKey: apiKeyOption, authMode, algoliaAgents, ...options }: CreateClientOptions): {
|
|
3026
3030
|
transporter: _algolia_client_common.Transporter;
|
|
3027
3031
|
/**
|
|
3028
3032
|
* The `appId` currently in use.
|
|
3029
3033
|
*/
|
|
3030
3034
|
appId: string;
|
|
3035
|
+
/**
|
|
3036
|
+
* The `apiKey` currently in use.
|
|
3037
|
+
*/
|
|
3038
|
+
apiKey: string;
|
|
3031
3039
|
/**
|
|
3032
3040
|
* Clears the cache of the transporter for the `requestsCache` and `responsesCache` properties.
|
|
3033
3041
|
*/
|
|
@@ -3183,9 +3191,10 @@ declare function createSearchClient({ appId: appIdOption, apiKey: apiKeyOption,
|
|
|
3183
3191
|
* @param replaceAllObjects.indexName - The `indexName` to replace `objects` in.
|
|
3184
3192
|
* @param replaceAllObjects.objects - The array of `objects` to store in the given Algolia `indexName`.
|
|
3185
3193
|
* @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.
|
|
3194
|
+
* @param replaceAllObjects.scopes - The `scopes` to keep from the index. Defaults to ['settings', 'rules', 'synonyms'].
|
|
3186
3195
|
* @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.
|
|
3187
3196
|
*/
|
|
3188
|
-
replaceAllObjects({ indexName, objects, batchSize }: ReplaceAllObjectsOptions, requestOptions?: RequestOptions): Promise<ReplaceAllObjectsResponse>;
|
|
3197
|
+
replaceAllObjects({ indexName, objects, batchSize, scopes }: ReplaceAllObjectsOptions, requestOptions?: RequestOptions): Promise<ReplaceAllObjectsResponse>;
|
|
3189
3198
|
indexExists({ indexName }: GetSettingsProps): Promise<boolean>;
|
|
3190
3199
|
/**
|
|
3191
3200
|
* Helper: calls the `search` method but with certainty that we will only request Algolia records (hits) and not facets.
|
package/dist/builds/browser.js
CHANGED
|
@@ -16,7 +16,7 @@ import {
|
|
|
16
16
|
getAlgoliaAgent,
|
|
17
17
|
shuffle
|
|
18
18
|
} from "@algolia/client-common";
|
|
19
|
-
var apiClientVersion = "5.
|
|
19
|
+
var apiClientVersion = "5.19.0";
|
|
20
20
|
function getDefaultHosts(appId) {
|
|
21
21
|
return [
|
|
22
22
|
{
|
|
@@ -81,6 +81,10 @@ function createSearchClient({
|
|
|
81
81
|
* The `appId` currently in use.
|
|
82
82
|
*/
|
|
83
83
|
appId: appIdOption,
|
|
84
|
+
/**
|
|
85
|
+
* The `apiKey` currently in use.
|
|
86
|
+
*/
|
|
87
|
+
apiKey: apiKeyOption,
|
|
84
88
|
/**
|
|
85
89
|
* Clears the cache of the transporter for the `requestsCache` and `responsesCache` properties.
|
|
86
90
|
*/
|
|
@@ -439,57 +443,66 @@ function createSearchClient({
|
|
|
439
443
|
* @param replaceAllObjects.indexName - The `indexName` to replace `objects` in.
|
|
440
444
|
* @param replaceAllObjects.objects - The array of `objects` to store in the given Algolia `indexName`.
|
|
441
445
|
* @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.
|
|
446
|
+
* @param replaceAllObjects.scopes - The `scopes` to keep from the index. Defaults to ['settings', 'rules', 'synonyms'].
|
|
442
447
|
* @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.
|
|
443
448
|
*/
|
|
444
|
-
async replaceAllObjects({ indexName, objects, batchSize }, requestOptions) {
|
|
449
|
+
async replaceAllObjects({ indexName, objects, batchSize, scopes }, requestOptions) {
|
|
445
450
|
const randomSuffix = Math.floor(Math.random() * 1e6) + 1e5;
|
|
446
451
|
const tmpIndexName = `${indexName}_tmp_${randomSuffix}`;
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
{
|
|
468
|
-
indexName,
|
|
469
|
-
operationIndexParams: {
|
|
470
|
-
operation: "copy",
|
|
471
|
-
destination: tmpIndexName,
|
|
472
|
-
scope: ["settings", "rules", "synonyms"]
|
|
473
|
-
}
|
|
474
|
-
},
|
|
475
|
-
requestOptions
|
|
476
|
-
);
|
|
477
|
-
await this.waitForTask({
|
|
478
|
-
indexName: tmpIndexName,
|
|
479
|
-
taskID: copyOperationResponse.taskID
|
|
480
|
-
});
|
|
481
|
-
const moveOperationResponse = await this.operationIndex(
|
|
482
|
-
{
|
|
452
|
+
if (scopes === void 0) {
|
|
453
|
+
scopes = ["settings", "rules", "synonyms"];
|
|
454
|
+
}
|
|
455
|
+
try {
|
|
456
|
+
let copyOperationResponse = await this.operationIndex(
|
|
457
|
+
{
|
|
458
|
+
indexName,
|
|
459
|
+
operationIndexParams: {
|
|
460
|
+
operation: "copy",
|
|
461
|
+
destination: tmpIndexName,
|
|
462
|
+
scope: scopes
|
|
463
|
+
}
|
|
464
|
+
},
|
|
465
|
+
requestOptions
|
|
466
|
+
);
|
|
467
|
+
const batchResponses = await this.chunkedBatch(
|
|
468
|
+
{ indexName: tmpIndexName, objects, waitForTasks: true, batchSize },
|
|
469
|
+
requestOptions
|
|
470
|
+
);
|
|
471
|
+
await this.waitForTask({
|
|
483
472
|
indexName: tmpIndexName,
|
|
484
|
-
|
|
485
|
-
}
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
473
|
+
taskID: copyOperationResponse.taskID
|
|
474
|
+
});
|
|
475
|
+
copyOperationResponse = await this.operationIndex(
|
|
476
|
+
{
|
|
477
|
+
indexName,
|
|
478
|
+
operationIndexParams: {
|
|
479
|
+
operation: "copy",
|
|
480
|
+
destination: tmpIndexName,
|
|
481
|
+
scope: scopes
|
|
482
|
+
}
|
|
483
|
+
},
|
|
484
|
+
requestOptions
|
|
485
|
+
);
|
|
486
|
+
await this.waitForTask({
|
|
487
|
+
indexName: tmpIndexName,
|
|
488
|
+
taskID: copyOperationResponse.taskID
|
|
489
|
+
});
|
|
490
|
+
const moveOperationResponse = await this.operationIndex(
|
|
491
|
+
{
|
|
492
|
+
indexName: tmpIndexName,
|
|
493
|
+
operationIndexParams: { operation: "move", destination: indexName }
|
|
494
|
+
},
|
|
495
|
+
requestOptions
|
|
496
|
+
);
|
|
497
|
+
await this.waitForTask({
|
|
498
|
+
indexName: tmpIndexName,
|
|
499
|
+
taskID: moveOperationResponse.taskID
|
|
500
|
+
});
|
|
501
|
+
return { copyOperationResponse, batchResponses, moveOperationResponse };
|
|
502
|
+
} catch (error) {
|
|
503
|
+
await this.deleteIndex({ indexName: tmpIndexName });
|
|
504
|
+
throw error;
|
|
505
|
+
}
|
|
493
506
|
},
|
|
494
507
|
async indexExists({ indexName }) {
|
|
495
508
|
try {
|