algoliasearch 5.0.0-alpha.101 → 5.0.0-alpha.103
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/dist/algoliasearch/builds/browser.d.ts +5 -1
- package/dist/algoliasearch/builds/browser.d.ts.map +1 -1
- package/dist/algoliasearch/builds/node.d.ts +5 -1
- package/dist/algoliasearch/builds/node.d.ts.map +1 -1
- package/dist/algoliasearch.cjs +118 -22
- package/dist/algoliasearch.esm.browser.js +120 -23
- package/dist/algoliasearch.esm.node.js +119 -23
- package/dist/algoliasearch.umd.js +2 -2
- package/dist/client-abtesting/src/abtestingClient.d.ts +1 -1
- package/dist/client-abtesting/src/abtestingClient.d.ts.map +1 -1
- package/dist/client-analytics/src/analyticsClient.d.ts +1 -1
- package/dist/client-analytics/src/analyticsClient.d.ts.map +1 -1
- package/dist/client-personalization/src/personalizationClient.d.ts +1 -1
- package/dist/client-personalization/src/personalizationClient.d.ts.map +1 -1
- package/dist/client-search/model/clientMethodProps.d.ts +76 -0
- package/dist/client-search/model/clientMethodProps.d.ts.map +1 -1
- package/dist/client-search/src/searchClient.d.ts +56 -15
- package/dist/client-search/src/searchClient.d.ts.map +1 -1
- package/dist/lite/lite.cjs +1 -1
- package/dist/lite/lite.esm.browser.js +2 -2
- package/dist/lite/lite.esm.node.js +1 -1
- package/dist/lite/lite.umd.js +2 -2
- package/dist/lite/src/liteClient.d.ts +1 -1
- package/dist/lite/src/liteClient.d.ts.map +1 -1
- package/lite/src/liteClient.ts +2 -2
- package/package.json +9 -9
|
@@ -4,7 +4,7 @@ import type { ClientOptions } from '@algolia/client-common';
|
|
|
4
4
|
import type { Region as PersonalizationRegion, PersonalizationClient } from '@algolia/client-personalization/src/personalizationClient';
|
|
5
5
|
import type { InitClientOptions, InitClientRegion } from './models';
|
|
6
6
|
export * from './models';
|
|
7
|
-
export declare const apiClientVersion = "5.0.0-alpha.
|
|
7
|
+
export declare const apiClientVersion = "5.0.0-alpha.103";
|
|
8
8
|
/**
|
|
9
9
|
* The client type.
|
|
10
10
|
*/
|
|
@@ -29,6 +29,10 @@ export declare function algoliasearch(appId: string, apiKey: string, options?: C
|
|
|
29
29
|
searchForFacets(searchMethodParams: import("@algolia/client-search/model/clientMethodProps").LegacySearchMethodProps | import("@algolia/client-search/model/searchMethodParams").SearchMethodParams, requestOptions?: import("@algolia/client-common").RequestOptions | undefined): Promise<{
|
|
30
30
|
results: import("@algolia/client-search/model/searchForFacetValuesResponse").SearchForFacetValuesResponse[];
|
|
31
31
|
}>;
|
|
32
|
+
generateSecuredApiKey({ parentApiKey, restrictions, }: import("@algolia/client-search/model/clientMethodProps").GenerateSecuredApiKeyOptions): string;
|
|
33
|
+
getSecuredApiKeyRemainingValidity({ securedApiKey, }: import("@algolia/client-search/model/clientMethodProps").GetSecuredApiKeyRemainingValidityOptions): number;
|
|
34
|
+
chunkedBatch({ indexName, objects, action, waitForTasks, batchSize, }: import("@algolia/client-search/model/clientMethodProps").ChunkedBatchOptions, requestOptions?: import("@algolia/client-common").RequestOptions | undefined): Promise<import("@algolia/client-search/model/batchResponse").BatchResponse[]>;
|
|
35
|
+
replaceAllObjects({ indexName, objects, batchSize }: import("@algolia/client-search/model/clientMethodProps").ReplaceAllObjectsOptions, requestOptions?: import("@algolia/client-common").RequestOptions | undefined): Promise<import("@algolia/client-search/model/clientMethodProps").ReplaceAllObjectsResponse>;
|
|
32
36
|
addApiKey(apiKey: import("@algolia/client-search/model/apiKey").ApiKey, requestOptions?: import("@algolia/client-common").RequestOptions | undefined): Promise<import("@algolia/client-search/model/addApiKeyResponse").AddApiKeyResponse>;
|
|
33
37
|
addOrUpdateObject({ indexName, objectID, body }: import("@algolia/client-search/model/clientMethodProps").AddOrUpdateObjectProps, requestOptions?: import("@algolia/client-common").RequestOptions | undefined): Promise<import("@algolia/client-search/model/updatedAtWithObjectIdResponse").UpdatedAtWithObjectIdResponse>;
|
|
34
38
|
appendSource(source: import("@algolia/client-search/model/source").Source, requestOptions?: import("@algolia/client-common").RequestOptions | undefined): Promise<import("@algolia/client-search/model/createdAtResponse").CreatedAtResponse>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"browser.d.ts","sourceRoot":"","sources":["../../../builds/browser.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACV,MAAM,IAAI,eAAe,EACzB,eAAe,EAChB,MAAM,+CAA+C,CAAC;AAKvD,OAAO,KAAK,EACV,MAAM,IAAI,eAAe,EACzB,eAAe,EAChB,MAAM,+CAA+C,CAAC;AAavD,OAAO,KAAK,EAEV,aAAa,EACd,MAAM,wBAAwB,CAAC;AAKhC,OAAO,KAAK,EACV,MAAM,IAAI,qBAAqB,EAC/B,qBAAqB,EACtB,MAAM,2DAA2D,CAAC;AAOnE,OAAO,KAAK,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AAEpE,cAAc,UAAU,CAAC;AAEzB,eAAO,MAAM,gBAAgB,oBAAsB,CAAC;AAEpD;;GAEG;AACH,MAAM,MAAM,aAAa,GAAG,UAAU,CAAC,OAAO,aAAa,CAAC,CAAC;AAG7D,wBAAgB,aAAa,CAC3B,KAAK,EAAE,MAAM,EACb,MAAM,EAAE,MAAM,EACd,OAAO,CAAC,EAAE,aAAa;;kCAiCR,iBAAiB,GAAG,iBAAiB,eAAe,CAAC,KACjE,eAAe;uCAuCH,iBAAiB,GAC5B,SAAS,iBAAiB,qBAAqB,CAAC,CAAC,KAClD,qBAAqB;kCAtBT,iBAAiB,GAAG,iBAAiB,eAAe,CAAC,KACjE,eAAe
|
|
1
|
+
{"version":3,"file":"browser.d.ts","sourceRoot":"","sources":["../../../builds/browser.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACV,MAAM,IAAI,eAAe,EACzB,eAAe,EAChB,MAAM,+CAA+C,CAAC;AAKvD,OAAO,KAAK,EACV,MAAM,IAAI,eAAe,EACzB,eAAe,EAChB,MAAM,+CAA+C,CAAC;AAavD,OAAO,KAAK,EAEV,aAAa,EACd,MAAM,wBAAwB,CAAC;AAKhC,OAAO,KAAK,EACV,MAAM,IAAI,qBAAqB,EAC/B,qBAAqB,EACtB,MAAM,2DAA2D,CAAC;AAOnE,OAAO,KAAK,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AAEpE,cAAc,UAAU,CAAC;AAEzB,eAAO,MAAM,gBAAgB,oBAAsB,CAAC;AAEpD;;GAEG;AACH,MAAM,MAAM,aAAa,GAAG,UAAU,CAAC,OAAO,aAAa,CAAC,CAAC;AAG7D,wBAAgB,aAAa,CAC3B,KAAK,EAAE,MAAM,EACb,MAAM,EAAE,MAAM,EACd,OAAO,CAAC,EAAE,aAAa;;kCAiCR,iBAAiB,GAAG,iBAAiB,eAAe,CAAC,KACjE,eAAe;uCAuCH,iBAAiB,GAC5B,SAAS,iBAAiB,qBAAqB,CAAC,CAAC,KAClD,qBAAqB;kCAtBT,iBAAiB,GAAG,iBAAiB,eAAe,CAAC,KACjE,eAAe;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAoDnB"}
|
|
@@ -4,7 +4,7 @@ import type { ClientOptions } from '@algolia/client-common';
|
|
|
4
4
|
import type { Region as PersonalizationRegion, PersonalizationClient } from '@algolia/client-personalization/src/personalizationClient';
|
|
5
5
|
import type { InitClientOptions, InitClientRegion } from './models';
|
|
6
6
|
export * from './models';
|
|
7
|
-
export declare const apiClientVersion = "5.0.0-alpha.
|
|
7
|
+
export declare const apiClientVersion = "5.0.0-alpha.103";
|
|
8
8
|
/**
|
|
9
9
|
* The client type.
|
|
10
10
|
*/
|
|
@@ -29,6 +29,10 @@ export declare function algoliasearch(appId: string, apiKey: string, options?: C
|
|
|
29
29
|
searchForFacets(searchMethodParams: import("@algolia/client-search/model/clientMethodProps").LegacySearchMethodProps | import("@algolia/client-search/model/searchMethodParams").SearchMethodParams, requestOptions?: import("@algolia/client-common").RequestOptions | undefined): Promise<{
|
|
30
30
|
results: import("@algolia/client-search/model/searchForFacetValuesResponse").SearchForFacetValuesResponse[];
|
|
31
31
|
}>;
|
|
32
|
+
generateSecuredApiKey({ parentApiKey, restrictions, }: import("@algolia/client-search/model/clientMethodProps").GenerateSecuredApiKeyOptions): string;
|
|
33
|
+
getSecuredApiKeyRemainingValidity({ securedApiKey, }: import("@algolia/client-search/model/clientMethodProps").GetSecuredApiKeyRemainingValidityOptions): number;
|
|
34
|
+
chunkedBatch({ indexName, objects, action, waitForTasks, batchSize, }: import("@algolia/client-search/model/clientMethodProps").ChunkedBatchOptions, requestOptions?: import("@algolia/client-common").RequestOptions | undefined): Promise<import("@algolia/client-search/model/batchResponse").BatchResponse[]>;
|
|
35
|
+
replaceAllObjects({ indexName, objects, batchSize }: import("@algolia/client-search/model/clientMethodProps").ReplaceAllObjectsOptions, requestOptions?: import("@algolia/client-common").RequestOptions | undefined): Promise<import("@algolia/client-search/model/clientMethodProps").ReplaceAllObjectsResponse>;
|
|
32
36
|
addApiKey(apiKey: import("@algolia/client-search/model/apiKey").ApiKey, requestOptions?: import("@algolia/client-common").RequestOptions | undefined): Promise<import("@algolia/client-search/model/addApiKeyResponse").AddApiKeyResponse>;
|
|
33
37
|
addOrUpdateObject({ indexName, objectID, body }: import("@algolia/client-search/model/clientMethodProps").AddOrUpdateObjectProps, requestOptions?: import("@algolia/client-common").RequestOptions | undefined): Promise<import("@algolia/client-search/model/updatedAtWithObjectIdResponse").UpdatedAtWithObjectIdResponse>;
|
|
34
38
|
appendSource(source: import("@algolia/client-search/model/source").Source, requestOptions?: import("@algolia/client-common").RequestOptions | undefined): Promise<import("@algolia/client-search/model/createdAtResponse").CreatedAtResponse>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"node.d.ts","sourceRoot":"","sources":["../../../builds/node.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACV,MAAM,IAAI,eAAe,EACzB,eAAe,EAChB,MAAM,+CAA+C,CAAC;AAKvD,OAAO,KAAK,EACV,MAAM,IAAI,eAAe,EACzB,eAAe,EAChB,MAAM,+CAA+C,CAAC;AAYvD,OAAO,KAAK,EAEV,aAAa,EACd,MAAM,wBAAwB,CAAC;AAKhC,OAAO,KAAK,EACV,MAAM,IAAI,qBAAqB,EAC/B,qBAAqB,EACtB,MAAM,2DAA2D,CAAC;AAOnE,OAAO,KAAK,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AAEpE,cAAc,UAAU,CAAC;AAEzB,eAAO,MAAM,gBAAgB,oBAAsB,CAAC;AAEpD;;GAEG;AACH,MAAM,MAAM,aAAa,GAAG,UAAU,CAAC,OAAO,aAAa,CAAC,CAAC;AAG7D,wBAAgB,aAAa,CAC3B,KAAK,EAAE,MAAM,EACb,MAAM,EAAE,MAAM,EACd,OAAO,CAAC,EAAE,aAAa;;kCA2BR,iBAAiB,GAAG,iBAAiB,eAAe,CAAC,KACjE,eAAe;uCAuCH,iBAAiB,GAC5B,SAAS,iBAAiB,qBAAqB,CAAC,CAAC,KAClD,qBAAqB;kCAtBT,iBAAiB,GAAG,iBAAiB,eAAe,CAAC,KACjE,eAAe
|
|
1
|
+
{"version":3,"file":"node.d.ts","sourceRoot":"","sources":["../../../builds/node.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACV,MAAM,IAAI,eAAe,EACzB,eAAe,EAChB,MAAM,+CAA+C,CAAC;AAKvD,OAAO,KAAK,EACV,MAAM,IAAI,eAAe,EACzB,eAAe,EAChB,MAAM,+CAA+C,CAAC;AAYvD,OAAO,KAAK,EAEV,aAAa,EACd,MAAM,wBAAwB,CAAC;AAKhC,OAAO,KAAK,EACV,MAAM,IAAI,qBAAqB,EAC/B,qBAAqB,EACtB,MAAM,2DAA2D,CAAC;AAOnE,OAAO,KAAK,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AAEpE,cAAc,UAAU,CAAC;AAEzB,eAAO,MAAM,gBAAgB,oBAAsB,CAAC;AAEpD;;GAEG;AACH,MAAM,MAAM,aAAa,GAAG,UAAU,CAAC,OAAO,aAAa,CAAC,CAAC;AAG7D,wBAAgB,aAAa,CAC3B,KAAK,EAAE,MAAM,EACb,MAAM,EAAE,MAAM,EACd,OAAO,CAAC,EAAE,aAAa;;kCA2BR,iBAAiB,GAAG,iBAAiB,eAAe,CAAC,KACjE,eAAe;uCAuCH,iBAAiB,GAC5B,SAAS,iBAAiB,qBAAqB,CAAC,CAAC,KAClD,qBAAqB;kCAtBT,iBAAiB,GAAG,iBAAiB,eAAe,CAAC,KACjE,eAAe;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAoDnB"}
|
package/dist/algoliasearch.cjs
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
var clientCommon = require('@algolia/client-common');
|
|
4
|
+
var crypto = require('crypto');
|
|
4
5
|
var requesterNodeHttp = require('@algolia/requester-node-http');
|
|
5
6
|
|
|
6
7
|
// Code generated by OpenAPI Generator (https://openapi-generator.tech), manual changes will be lost - read more on https://github.com/algolia/api-clients-automation. DO NOT EDIT.
|
|
7
|
-
const apiClientVersion$4 = '5.0.0-alpha.
|
|
8
|
+
const apiClientVersion$4 = '5.0.0-alpha.103';
|
|
8
9
|
const REGIONS$2 = ['de', 'us'];
|
|
9
10
|
function getDefaultHosts$3(region) {
|
|
10
11
|
const url = !region
|
|
@@ -309,7 +310,7 @@ function createAbtestingClient({ appId: appIdOption, apiKey: apiKeyOption, authM
|
|
|
309
310
|
}
|
|
310
311
|
|
|
311
312
|
// Code generated by OpenAPI Generator (https://openapi-generator.tech), manual changes will be lost - read more on https://github.com/algolia/api-clients-automation. DO NOT EDIT.
|
|
312
|
-
const apiClientVersion$3 = '5.0.0-alpha.
|
|
313
|
+
const apiClientVersion$3 = '5.0.0-alpha.103';
|
|
313
314
|
const REGIONS$1 = ['de', 'us'];
|
|
314
315
|
function getDefaultHosts$2(region) {
|
|
315
316
|
const url = !region
|
|
@@ -1236,7 +1237,7 @@ function createAnalyticsClient({ appId: appIdOption, apiKey: apiKeyOption, authM
|
|
|
1236
1237
|
}
|
|
1237
1238
|
|
|
1238
1239
|
// Code generated by OpenAPI Generator (https://openapi-generator.tech), manual changes will be lost - read more on https://github.com/algolia/api-clients-automation. DO NOT EDIT.
|
|
1239
|
-
const apiClientVersion$2 = '5.0.0-alpha.
|
|
1240
|
+
const apiClientVersion$2 = '5.0.0-alpha.103';
|
|
1240
1241
|
const REGIONS = ['eu', 'us'];
|
|
1241
1242
|
function getDefaultHosts$1(region) {
|
|
1242
1243
|
const url = 'personalization.{region}.algolia.com'.replace('{region}', region);
|
|
@@ -1497,7 +1498,7 @@ function createPersonalizationClient({ appId: appIdOption, apiKey: apiKeyOption,
|
|
|
1497
1498
|
}
|
|
1498
1499
|
|
|
1499
1500
|
// Code generated by OpenAPI Generator (https://openapi-generator.tech), manual changes will be lost - read more on https://github.com/algolia/api-clients-automation. DO NOT EDIT.
|
|
1500
|
-
const apiClientVersion$1 = '5.0.0-alpha.
|
|
1501
|
+
const apiClientVersion$1 = '5.0.0-alpha.103';
|
|
1501
1502
|
function getDefaultHosts(appId) {
|
|
1502
1503
|
return [
|
|
1503
1504
|
{
|
|
@@ -1583,7 +1584,7 @@ function createSearchClient({ appId: appIdOption, apiKey: apiKeyOption, authMode
|
|
|
1583
1584
|
* Helper: Wait for a task to be published (completed) for a given `indexName` and `taskID`.
|
|
1584
1585
|
*
|
|
1585
1586
|
* @summary Helper method that waits for a task to be published (completed).
|
|
1586
|
-
* @param waitForTaskOptions - The waitForTaskOptions object.
|
|
1587
|
+
* @param waitForTaskOptions - The `waitForTaskOptions` object.
|
|
1587
1588
|
* @param waitForTaskOptions.indexName - The `indexName` where the operation was performed.
|
|
1588
1589
|
* @param waitForTaskOptions.taskID - The `taskID` returned in the method response.
|
|
1589
1590
|
* @param waitForTaskOptions.maxRetries - The maximum number of retries. 50 by default.
|
|
@@ -1607,7 +1608,7 @@ function createSearchClient({ appId: appIdOption, apiKey: apiKeyOption, authMode
|
|
|
1607
1608
|
* Helper: Wait for an API key to be added, updated or deleted based on a given `operation`.
|
|
1608
1609
|
*
|
|
1609
1610
|
* @summary Helper method that waits for an API key task to be processed.
|
|
1610
|
-
* @param waitForApiKeyOptions - The waitForApiKeyOptions object.
|
|
1611
|
+
* @param waitForApiKeyOptions - The `waitForApiKeyOptions` object.
|
|
1611
1612
|
* @param waitForApiKeyOptions.operation - The `operation` that was done on a `key`.
|
|
1612
1613
|
* @param waitForApiKeyOptions.key - The `key` that has been added, deleted or updated.
|
|
1613
1614
|
* @param waitForApiKeyOptions.apiKey - Necessary to know if an `update` operation has been processed, compare fields of the response with it.
|
|
@@ -1660,7 +1661,7 @@ function createSearchClient({ appId: appIdOption, apiKey: apiKeyOption, authMode
|
|
|
1660
1661
|
* Helper: Iterate on the `browse` method of the client to allow aggregating objects of an index.
|
|
1661
1662
|
*
|
|
1662
1663
|
* @summary Helper method that iterates on the `browse` method.
|
|
1663
|
-
* @param browseObjects - The browseObjects object.
|
|
1664
|
+
* @param browseObjects - The `browseObjects` object.
|
|
1664
1665
|
* @param browseObjects.indexName - The index in which to perform the request.
|
|
1665
1666
|
* @param browseObjects.browseParams - The `browse` parameters.
|
|
1666
1667
|
* @param browseObjects.validate - The validator function. It receive the resolved return of the API call. By default, stops when there is no `cursor` in the response.
|
|
@@ -1686,11 +1687,11 @@ function createSearchClient({ appId: appIdOption, apiKey: apiKeyOption, authMode
|
|
|
1686
1687
|
* Helper: Iterate on the `searchRules` method of the client to allow aggregating rules of an index.
|
|
1687
1688
|
*
|
|
1688
1689
|
* @summary Helper method that iterates on the `searchRules` method.
|
|
1689
|
-
* @param
|
|
1690
|
-
* @param
|
|
1691
|
-
* @param
|
|
1692
|
-
* @param
|
|
1693
|
-
* @param
|
|
1690
|
+
* @param browseRules - The `browseRules` object.
|
|
1691
|
+
* @param browseRules.indexName - The index in which to perform the request.
|
|
1692
|
+
* @param browseRules.searchRulesParams - The `searchRules` method parameters.
|
|
1693
|
+
* @param browseRules.validate - The validator function. It receive the resolved return of the API call. By default, stops when there is less hits returned than the number of maximum hits (1000).
|
|
1694
|
+
* @param browseRules.aggregator - The function that runs right after the API call has been resolved, allows you to do anything with the response before `validate`.
|
|
1694
1695
|
* @param requestOptions - The requestOptions to send along with the query, they will be forwarded to the `searchRules` method and merged with the transporter requestOptions.
|
|
1695
1696
|
*/
|
|
1696
1697
|
browseRules({ indexName, searchRulesParams, ...browseRulesOptions }, requestOptions) {
|
|
@@ -1718,11 +1719,11 @@ function createSearchClient({ appId: appIdOption, apiKey: apiKeyOption, authMode
|
|
|
1718
1719
|
* Helper: Iterate on the `searchSynonyms` method of the client to allow aggregating rules of an index.
|
|
1719
1720
|
*
|
|
1720
1721
|
* @summary Helper method that iterates on the `searchSynonyms` method.
|
|
1721
|
-
* @param
|
|
1722
|
-
* @param
|
|
1723
|
-
* @param
|
|
1724
|
-
* @param
|
|
1725
|
-
* @param
|
|
1722
|
+
* @param browseSynonyms - The `browseSynonyms` object.
|
|
1723
|
+
* @param browseSynonyms.indexName - The index in which to perform the request.
|
|
1724
|
+
* @param browseSynonyms.validate - The validator function. It receive the resolved return of the API call. By default, stops when there is less hits returned than the number of maximum hits (1000).
|
|
1725
|
+
* @param browseSynonyms.aggregator - The function that runs right after the API call has been resolved, allows you to do anything with the response before `validate`.
|
|
1726
|
+
* @param browseSynonyms.searchSynonymsParams - The `searchSynonyms` method parameters.
|
|
1726
1727
|
* @param requestOptions - The requestOptions to send along with the query, they will be forwarded to the `searchSynonyms` method and merged with the transporter requestOptions.
|
|
1727
1728
|
*/
|
|
1728
1729
|
browseSynonyms({ indexName, searchSynonymsParams, ...browseSynonymsOptions }, requestOptions) {
|
|
@@ -1732,16 +1733,16 @@ function createSearchClient({ appId: appIdOption, apiKey: apiKeyOption, authMode
|
|
|
1732
1733
|
hitsPerPage: 1000,
|
|
1733
1734
|
};
|
|
1734
1735
|
return clientCommon.createIterablePromise({
|
|
1735
|
-
func: (
|
|
1736
|
-
|
|
1736
|
+
func: (_) => {
|
|
1737
|
+
const resp = this.searchSynonyms({
|
|
1737
1738
|
indexName,
|
|
1738
1739
|
searchSynonymsParams: {
|
|
1739
1740
|
...params,
|
|
1740
|
-
page:
|
|
1741
|
-
? previousResponse.page + 1
|
|
1742
|
-
: params.page,
|
|
1741
|
+
page: params.page,
|
|
1743
1742
|
},
|
|
1744
1743
|
}, requestOptions);
|
|
1744
|
+
params.page += 1;
|
|
1745
|
+
return resp;
|
|
1745
1746
|
},
|
|
1746
1747
|
validate: (response) => response.nbHits < params.hitsPerPage,
|
|
1747
1748
|
...browseSynonymsOptions,
|
|
@@ -1769,6 +1770,101 @@ function createSearchClient({ appId: appIdOption, apiKey: apiKeyOption, authMode
|
|
|
1769
1770
|
searchForFacets(searchMethodParams, requestOptions) {
|
|
1770
1771
|
return this.search(searchMethodParams, requestOptions);
|
|
1771
1772
|
},
|
|
1773
|
+
/**
|
|
1774
|
+
* Helper: Generates a secured API key based on the given `parentApiKey` and given `restrictions`.
|
|
1775
|
+
*
|
|
1776
|
+
* @summary Helper: Generates a secured API key based on the given `parentApiKey` and given `restrictions`.
|
|
1777
|
+
* @param generateSecuredApiKey - The `generateSecuredApiKey` object.
|
|
1778
|
+
* @param generateSecuredApiKey.parentApiKey - The base API key from which to generate the new secured one.
|
|
1779
|
+
* @param generateSecuredApiKey.restrictions - A set of properties defining the restrictions of the secured API key.
|
|
1780
|
+
*/
|
|
1781
|
+
generateSecuredApiKey({ parentApiKey, restrictions = {}, }) {
|
|
1782
|
+
const queryParameters = clientCommon.serializeQueryParameters(restrictions);
|
|
1783
|
+
return Buffer.from(crypto.createHmac('sha256', parentApiKey)
|
|
1784
|
+
.update(queryParameters)
|
|
1785
|
+
.digest('hex') + queryParameters).toString('base64');
|
|
1786
|
+
},
|
|
1787
|
+
/**
|
|
1788
|
+
* Helper: Retrieves the remaining validity of the previous generated `secured_api_key`, the `ValidUntil` parameter must have been provided.
|
|
1789
|
+
*
|
|
1790
|
+
* @summary Helper: Retrieves the remaining validity of the previous generated `secured_api_key`, the `ValidUntil` parameter must have been provided.
|
|
1791
|
+
* @param getSecuredApiKeyRemainingValidity - The `getSecuredApiKeyRemainingValidity` object.
|
|
1792
|
+
* @param getSecuredApiKeyRemainingValidity.securedApiKey - The secured API key generated with the `generateSecuredApiKey` method.
|
|
1793
|
+
*/
|
|
1794
|
+
getSecuredApiKeyRemainingValidity({ securedApiKey, }) {
|
|
1795
|
+
const decodedString = Buffer.from(securedApiKey, 'base64').toString('ascii');
|
|
1796
|
+
const regex = /validUntil=(\d+)/;
|
|
1797
|
+
const match = decodedString.match(regex);
|
|
1798
|
+
if (match === null) {
|
|
1799
|
+
throw new Error('ValidUntil not found in given secured api key.');
|
|
1800
|
+
}
|
|
1801
|
+
return parseInt(match[1], 10) - Math.round(new Date().getTime() / 1000);
|
|
1802
|
+
},
|
|
1803
|
+
/**
|
|
1804
|
+
* Helper: Chunks the given `objects` list in subset of 1000 elements max in order to make it fit in `batch` requests.
|
|
1805
|
+
*
|
|
1806
|
+
* @summary Helper: Chunks the given `objects` list in subset of 1000 elements max in order to make it fit in `batch` requests. * @param getSecuredApiKeyRemainingValidity - The `getSecuredApiKeyRemainingValidity` object.
|
|
1807
|
+
* @param chunkedBatch - The `chunkedBatch` object.
|
|
1808
|
+
* @param chunkedBatch.indexName - The `indexName` to replace `objects` in.
|
|
1809
|
+
* @param chunkedBatch.objects - The array of `objects` to store in the given Algolia `indexName`.
|
|
1810
|
+
* @param chunkedBatch.action - The `batch` `action` to perform on the given array of `objects`, defaults to `addObject`.
|
|
1811
|
+
* @param chunkedBatch.waitForTasks - Whether or not we should wait until every `batch` tasks has been processed, this operation may slow the total execution time of this method but is more reliable.
|
|
1812
|
+
* @param chunkedBatch.batchSize - The size of the chunk of `objects`. The number of `batch` calls will be equal to `length(objects) / batchSize`. Defaults to 1000.
|
|
1813
|
+
* @param requestOptions - The requestOptions to send along with the query, they will be forwarded to the `getTask` method and merged with the transporter requestOptions.
|
|
1814
|
+
*/
|
|
1815
|
+
async chunkedBatch({ indexName, objects, action = 'addObject', waitForTasks, batchSize = 1000, }, requestOptions) {
|
|
1816
|
+
let requests = [];
|
|
1817
|
+
const responses = [];
|
|
1818
|
+
for (const [i, obj] of objects.entries()) {
|
|
1819
|
+
requests.push({ action, body: obj });
|
|
1820
|
+
if (i % batchSize === 0) {
|
|
1821
|
+
responses.push(await this.batch({ indexName, batchWriteParams: { requests } }, requestOptions));
|
|
1822
|
+
requests = [];
|
|
1823
|
+
}
|
|
1824
|
+
}
|
|
1825
|
+
if (waitForTasks) {
|
|
1826
|
+
for (const resp of responses) {
|
|
1827
|
+
await this.waitForTask({ indexName, taskID: resp.taskID });
|
|
1828
|
+
}
|
|
1829
|
+
}
|
|
1830
|
+
return responses;
|
|
1831
|
+
},
|
|
1832
|
+
/**
|
|
1833
|
+
* Helper: Replaces all objects (records) in the given `index_name` with the given `objects`. A temporary index is created during this process in order to backup your data.
|
|
1834
|
+
*
|
|
1835
|
+
* @summary Helper: Replaces all objects (records) in the given `index_name` with the given `objects`. A temporary index is created during this process in order to backup your data.
|
|
1836
|
+
* @param replaceAllObjects - The `replaceAllObjects` object.
|
|
1837
|
+
* @param replaceAllObjects.indexName - The `indexName` to replace `objects` in.
|
|
1838
|
+
* @param replaceAllObjects.objects - The array of `objects` to store in the given Algolia `indexName`.
|
|
1839
|
+
* @param replaceAllObjects.batchSize - The size of the chunk of `objects`. The number of `batch` calls will be equal to `length(objects) / batchSize`. Defaults to 1000.
|
|
1840
|
+
* @param requestOptions - The requestOptions to send along with the query, they will be forwarded to the `getTask` method and merged with the transporter requestOptions.
|
|
1841
|
+
*/
|
|
1842
|
+
async replaceAllObjects({ indexName, objects, batchSize }, requestOptions) {
|
|
1843
|
+
const randomSuffix = Math.random().toString(36).substring(7);
|
|
1844
|
+
const tmpIndexName = `${indexName}_tmp_${randomSuffix}`;
|
|
1845
|
+
const copyOperationResponse = await this.operationIndex({
|
|
1846
|
+
indexName,
|
|
1847
|
+
operationIndexParams: {
|
|
1848
|
+
operation: 'copy',
|
|
1849
|
+
destination: tmpIndexName,
|
|
1850
|
+
scope: ['settings', 'rules', 'synonyms'],
|
|
1851
|
+
},
|
|
1852
|
+
}, requestOptions);
|
|
1853
|
+
await this.waitForTask({
|
|
1854
|
+
indexName,
|
|
1855
|
+
taskID: copyOperationResponse.taskID,
|
|
1856
|
+
});
|
|
1857
|
+
const batchResponses = await this.chunkedBatch({ indexName: tmpIndexName, objects, waitForTasks: true, batchSize }, requestOptions);
|
|
1858
|
+
const moveOperationResponse = await this.operationIndex({
|
|
1859
|
+
indexName: tmpIndexName,
|
|
1860
|
+
operationIndexParams: { operation: 'move', destination: indexName },
|
|
1861
|
+
}, requestOptions);
|
|
1862
|
+
await this.waitForTask({
|
|
1863
|
+
indexName,
|
|
1864
|
+
taskID: moveOperationResponse.taskID,
|
|
1865
|
+
});
|
|
1866
|
+
return { copyOperationResponse, batchResponses, moveOperationResponse };
|
|
1867
|
+
},
|
|
1772
1868
|
/**
|
|
1773
1869
|
* Add a new API key with specific permissions and restrictions. The request must be authenticated with the admin API key. The response returns an API key string.
|
|
1774
1870
|
*
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { createHmac } from 'crypto';
|
|
2
|
+
|
|
1
3
|
function createAuth(appId, apiKey, authMode = 'WithinHeaders') {
|
|
2
4
|
const credentials = {
|
|
3
5
|
'x-algolia-api-key': apiKey,
|
|
@@ -321,7 +323,7 @@ function shuffle(array) {
|
|
|
321
323
|
}
|
|
322
324
|
function serializeUrl(host, path, queryParameters) {
|
|
323
325
|
const queryParametersAsString = serializeQueryParameters(queryParameters);
|
|
324
|
-
let url = `${host.protocol}://${host.url}${host.port ? `:${host.port}` : ''}/${path.charAt(0) === '/' ? path.
|
|
326
|
+
let url = `${host.protocol}://${host.url}${host.port ? `:${host.port}` : ''}/${path.charAt(0) === '/' ? path.substring(1) : path}`;
|
|
325
327
|
if (queryParametersAsString.length) {
|
|
326
328
|
url += `?${queryParametersAsString}`;
|
|
327
329
|
}
|
|
@@ -685,7 +687,7 @@ const DEFAULT_READ_TIMEOUT_BROWSER = 2000;
|
|
|
685
687
|
const DEFAULT_WRITE_TIMEOUT_BROWSER = 30000;
|
|
686
688
|
|
|
687
689
|
// Code generated by OpenAPI Generator (https://openapi-generator.tech), manual changes will be lost - read more on https://github.com/algolia/api-clients-automation. DO NOT EDIT.
|
|
688
|
-
const apiClientVersion$4 = '5.0.0-alpha.
|
|
690
|
+
const apiClientVersion$4 = '5.0.0-alpha.103';
|
|
689
691
|
const REGIONS$2 = ['de', 'us'];
|
|
690
692
|
function getDefaultHosts$3(region) {
|
|
691
693
|
const url = !region
|
|
@@ -990,7 +992,7 @@ function createAbtestingClient({ appId: appIdOption, apiKey: apiKeyOption, authM
|
|
|
990
992
|
}
|
|
991
993
|
|
|
992
994
|
// Code generated by OpenAPI Generator (https://openapi-generator.tech), manual changes will be lost - read more on https://github.com/algolia/api-clients-automation. DO NOT EDIT.
|
|
993
|
-
const apiClientVersion$3 = '5.0.0-alpha.
|
|
995
|
+
const apiClientVersion$3 = '5.0.0-alpha.103';
|
|
994
996
|
const REGIONS$1 = ['de', 'us'];
|
|
995
997
|
function getDefaultHosts$2(region) {
|
|
996
998
|
const url = !region
|
|
@@ -1917,7 +1919,7 @@ function createAnalyticsClient({ appId: appIdOption, apiKey: apiKeyOption, authM
|
|
|
1917
1919
|
}
|
|
1918
1920
|
|
|
1919
1921
|
// Code generated by OpenAPI Generator (https://openapi-generator.tech), manual changes will be lost - read more on https://github.com/algolia/api-clients-automation. DO NOT EDIT.
|
|
1920
|
-
const apiClientVersion$2 = '5.0.0-alpha.
|
|
1922
|
+
const apiClientVersion$2 = '5.0.0-alpha.103';
|
|
1921
1923
|
const REGIONS = ['eu', 'us'];
|
|
1922
1924
|
function getDefaultHosts$1(region) {
|
|
1923
1925
|
const url = 'personalization.{region}.algolia.com'.replace('{region}', region);
|
|
@@ -2178,7 +2180,7 @@ function createPersonalizationClient({ appId: appIdOption, apiKey: apiKeyOption,
|
|
|
2178
2180
|
}
|
|
2179
2181
|
|
|
2180
2182
|
// Code generated by OpenAPI Generator (https://openapi-generator.tech), manual changes will be lost - read more on https://github.com/algolia/api-clients-automation. DO NOT EDIT.
|
|
2181
|
-
const apiClientVersion$1 = '5.0.0-alpha.
|
|
2183
|
+
const apiClientVersion$1 = '5.0.0-alpha.103';
|
|
2182
2184
|
function getDefaultHosts(appId) {
|
|
2183
2185
|
return [
|
|
2184
2186
|
{
|
|
@@ -2264,7 +2266,7 @@ function createSearchClient({ appId: appIdOption, apiKey: apiKeyOption, authMode
|
|
|
2264
2266
|
* Helper: Wait for a task to be published (completed) for a given `indexName` and `taskID`.
|
|
2265
2267
|
*
|
|
2266
2268
|
* @summary Helper method that waits for a task to be published (completed).
|
|
2267
|
-
* @param waitForTaskOptions - The waitForTaskOptions object.
|
|
2269
|
+
* @param waitForTaskOptions - The `waitForTaskOptions` object.
|
|
2268
2270
|
* @param waitForTaskOptions.indexName - The `indexName` where the operation was performed.
|
|
2269
2271
|
* @param waitForTaskOptions.taskID - The `taskID` returned in the method response.
|
|
2270
2272
|
* @param waitForTaskOptions.maxRetries - The maximum number of retries. 50 by default.
|
|
@@ -2288,7 +2290,7 @@ function createSearchClient({ appId: appIdOption, apiKey: apiKeyOption, authMode
|
|
|
2288
2290
|
* Helper: Wait for an API key to be added, updated or deleted based on a given `operation`.
|
|
2289
2291
|
*
|
|
2290
2292
|
* @summary Helper method that waits for an API key task to be processed.
|
|
2291
|
-
* @param waitForApiKeyOptions - The waitForApiKeyOptions object.
|
|
2293
|
+
* @param waitForApiKeyOptions - The `waitForApiKeyOptions` object.
|
|
2292
2294
|
* @param waitForApiKeyOptions.operation - The `operation` that was done on a `key`.
|
|
2293
2295
|
* @param waitForApiKeyOptions.key - The `key` that has been added, deleted or updated.
|
|
2294
2296
|
* @param waitForApiKeyOptions.apiKey - Necessary to know if an `update` operation has been processed, compare fields of the response with it.
|
|
@@ -2341,7 +2343,7 @@ function createSearchClient({ appId: appIdOption, apiKey: apiKeyOption, authMode
|
|
|
2341
2343
|
* Helper: Iterate on the `browse` method of the client to allow aggregating objects of an index.
|
|
2342
2344
|
*
|
|
2343
2345
|
* @summary Helper method that iterates on the `browse` method.
|
|
2344
|
-
* @param browseObjects - The browseObjects object.
|
|
2346
|
+
* @param browseObjects - The `browseObjects` object.
|
|
2345
2347
|
* @param browseObjects.indexName - The index in which to perform the request.
|
|
2346
2348
|
* @param browseObjects.browseParams - The `browse` parameters.
|
|
2347
2349
|
* @param browseObjects.validate - The validator function. It receive the resolved return of the API call. By default, stops when there is no `cursor` in the response.
|
|
@@ -2367,11 +2369,11 @@ function createSearchClient({ appId: appIdOption, apiKey: apiKeyOption, authMode
|
|
|
2367
2369
|
* Helper: Iterate on the `searchRules` method of the client to allow aggregating rules of an index.
|
|
2368
2370
|
*
|
|
2369
2371
|
* @summary Helper method that iterates on the `searchRules` method.
|
|
2370
|
-
* @param
|
|
2371
|
-
* @param
|
|
2372
|
-
* @param
|
|
2373
|
-
* @param
|
|
2374
|
-
* @param
|
|
2372
|
+
* @param browseRules - The `browseRules` object.
|
|
2373
|
+
* @param browseRules.indexName - The index in which to perform the request.
|
|
2374
|
+
* @param browseRules.searchRulesParams - The `searchRules` method parameters.
|
|
2375
|
+
* @param browseRules.validate - The validator function. It receive the resolved return of the API call. By default, stops when there is less hits returned than the number of maximum hits (1000).
|
|
2376
|
+
* @param browseRules.aggregator - The function that runs right after the API call has been resolved, allows you to do anything with the response before `validate`.
|
|
2375
2377
|
* @param requestOptions - The requestOptions to send along with the query, they will be forwarded to the `searchRules` method and merged with the transporter requestOptions.
|
|
2376
2378
|
*/
|
|
2377
2379
|
browseRules({ indexName, searchRulesParams, ...browseRulesOptions }, requestOptions) {
|
|
@@ -2399,11 +2401,11 @@ function createSearchClient({ appId: appIdOption, apiKey: apiKeyOption, authMode
|
|
|
2399
2401
|
* Helper: Iterate on the `searchSynonyms` method of the client to allow aggregating rules of an index.
|
|
2400
2402
|
*
|
|
2401
2403
|
* @summary Helper method that iterates on the `searchSynonyms` method.
|
|
2402
|
-
* @param
|
|
2403
|
-
* @param
|
|
2404
|
-
* @param
|
|
2405
|
-
* @param
|
|
2406
|
-
* @param
|
|
2404
|
+
* @param browseSynonyms - The `browseSynonyms` object.
|
|
2405
|
+
* @param browseSynonyms.indexName - The index in which to perform the request.
|
|
2406
|
+
* @param browseSynonyms.validate - The validator function. It receive the resolved return of the API call. By default, stops when there is less hits returned than the number of maximum hits (1000).
|
|
2407
|
+
* @param browseSynonyms.aggregator - The function that runs right after the API call has been resolved, allows you to do anything with the response before `validate`.
|
|
2408
|
+
* @param browseSynonyms.searchSynonymsParams - The `searchSynonyms` method parameters.
|
|
2407
2409
|
* @param requestOptions - The requestOptions to send along with the query, they will be forwarded to the `searchSynonyms` method and merged with the transporter requestOptions.
|
|
2408
2410
|
*/
|
|
2409
2411
|
browseSynonyms({ indexName, searchSynonymsParams, ...browseSynonymsOptions }, requestOptions) {
|
|
@@ -2413,16 +2415,16 @@ function createSearchClient({ appId: appIdOption, apiKey: apiKeyOption, authMode
|
|
|
2413
2415
|
hitsPerPage: 1000,
|
|
2414
2416
|
};
|
|
2415
2417
|
return createIterablePromise({
|
|
2416
|
-
func: (
|
|
2417
|
-
|
|
2418
|
+
func: (_) => {
|
|
2419
|
+
const resp = this.searchSynonyms({
|
|
2418
2420
|
indexName,
|
|
2419
2421
|
searchSynonymsParams: {
|
|
2420
2422
|
...params,
|
|
2421
|
-
page:
|
|
2422
|
-
? previousResponse.page + 1
|
|
2423
|
-
: params.page,
|
|
2423
|
+
page: params.page,
|
|
2424
2424
|
},
|
|
2425
2425
|
}, requestOptions);
|
|
2426
|
+
params.page += 1;
|
|
2427
|
+
return resp;
|
|
2426
2428
|
},
|
|
2427
2429
|
validate: (response) => response.nbHits < params.hitsPerPage,
|
|
2428
2430
|
...browseSynonymsOptions,
|
|
@@ -2450,6 +2452,101 @@ function createSearchClient({ appId: appIdOption, apiKey: apiKeyOption, authMode
|
|
|
2450
2452
|
searchForFacets(searchMethodParams, requestOptions) {
|
|
2451
2453
|
return this.search(searchMethodParams, requestOptions);
|
|
2452
2454
|
},
|
|
2455
|
+
/**
|
|
2456
|
+
* Helper: Generates a secured API key based on the given `parentApiKey` and given `restrictions`.
|
|
2457
|
+
*
|
|
2458
|
+
* @summary Helper: Generates a secured API key based on the given `parentApiKey` and given `restrictions`.
|
|
2459
|
+
* @param generateSecuredApiKey - The `generateSecuredApiKey` object.
|
|
2460
|
+
* @param generateSecuredApiKey.parentApiKey - The base API key from which to generate the new secured one.
|
|
2461
|
+
* @param generateSecuredApiKey.restrictions - A set of properties defining the restrictions of the secured API key.
|
|
2462
|
+
*/
|
|
2463
|
+
generateSecuredApiKey({ parentApiKey, restrictions = {}, }) {
|
|
2464
|
+
const queryParameters = serializeQueryParameters(restrictions);
|
|
2465
|
+
return Buffer.from(createHmac('sha256', parentApiKey)
|
|
2466
|
+
.update(queryParameters)
|
|
2467
|
+
.digest('hex') + queryParameters).toString('base64');
|
|
2468
|
+
},
|
|
2469
|
+
/**
|
|
2470
|
+
* Helper: Retrieves the remaining validity of the previous generated `secured_api_key`, the `ValidUntil` parameter must have been provided.
|
|
2471
|
+
*
|
|
2472
|
+
* @summary Helper: Retrieves the remaining validity of the previous generated `secured_api_key`, the `ValidUntil` parameter must have been provided.
|
|
2473
|
+
* @param getSecuredApiKeyRemainingValidity - The `getSecuredApiKeyRemainingValidity` object.
|
|
2474
|
+
* @param getSecuredApiKeyRemainingValidity.securedApiKey - The secured API key generated with the `generateSecuredApiKey` method.
|
|
2475
|
+
*/
|
|
2476
|
+
getSecuredApiKeyRemainingValidity({ securedApiKey, }) {
|
|
2477
|
+
const decodedString = Buffer.from(securedApiKey, 'base64').toString('ascii');
|
|
2478
|
+
const regex = /validUntil=(\d+)/;
|
|
2479
|
+
const match = decodedString.match(regex);
|
|
2480
|
+
if (match === null) {
|
|
2481
|
+
throw new Error('ValidUntil not found in given secured api key.');
|
|
2482
|
+
}
|
|
2483
|
+
return parseInt(match[1], 10) - Math.round(new Date().getTime() / 1000);
|
|
2484
|
+
},
|
|
2485
|
+
/**
|
|
2486
|
+
* Helper: Chunks the given `objects` list in subset of 1000 elements max in order to make it fit in `batch` requests.
|
|
2487
|
+
*
|
|
2488
|
+
* @summary Helper: Chunks the given `objects` list in subset of 1000 elements max in order to make it fit in `batch` requests. * @param getSecuredApiKeyRemainingValidity - The `getSecuredApiKeyRemainingValidity` object.
|
|
2489
|
+
* @param chunkedBatch - The `chunkedBatch` object.
|
|
2490
|
+
* @param chunkedBatch.indexName - The `indexName` to replace `objects` in.
|
|
2491
|
+
* @param chunkedBatch.objects - The array of `objects` to store in the given Algolia `indexName`.
|
|
2492
|
+
* @param chunkedBatch.action - The `batch` `action` to perform on the given array of `objects`, defaults to `addObject`.
|
|
2493
|
+
* @param chunkedBatch.waitForTasks - Whether or not we should wait until every `batch` tasks has been processed, this operation may slow the total execution time of this method but is more reliable.
|
|
2494
|
+
* @param chunkedBatch.batchSize - The size of the chunk of `objects`. The number of `batch` calls will be equal to `length(objects) / batchSize`. Defaults to 1000.
|
|
2495
|
+
* @param requestOptions - The requestOptions to send along with the query, they will be forwarded to the `getTask` method and merged with the transporter requestOptions.
|
|
2496
|
+
*/
|
|
2497
|
+
async chunkedBatch({ indexName, objects, action = 'addObject', waitForTasks, batchSize = 1000, }, requestOptions) {
|
|
2498
|
+
let requests = [];
|
|
2499
|
+
const responses = [];
|
|
2500
|
+
for (const [i, obj] of objects.entries()) {
|
|
2501
|
+
requests.push({ action, body: obj });
|
|
2502
|
+
if (i % batchSize === 0) {
|
|
2503
|
+
responses.push(await this.batch({ indexName, batchWriteParams: { requests } }, requestOptions));
|
|
2504
|
+
requests = [];
|
|
2505
|
+
}
|
|
2506
|
+
}
|
|
2507
|
+
if (waitForTasks) {
|
|
2508
|
+
for (const resp of responses) {
|
|
2509
|
+
await this.waitForTask({ indexName, taskID: resp.taskID });
|
|
2510
|
+
}
|
|
2511
|
+
}
|
|
2512
|
+
return responses;
|
|
2513
|
+
},
|
|
2514
|
+
/**
|
|
2515
|
+
* Helper: Replaces all objects (records) in the given `index_name` with the given `objects`. A temporary index is created during this process in order to backup your data.
|
|
2516
|
+
*
|
|
2517
|
+
* @summary Helper: Replaces all objects (records) in the given `index_name` with the given `objects`. A temporary index is created during this process in order to backup your data.
|
|
2518
|
+
* @param replaceAllObjects - The `replaceAllObjects` object.
|
|
2519
|
+
* @param replaceAllObjects.indexName - The `indexName` to replace `objects` in.
|
|
2520
|
+
* @param replaceAllObjects.objects - The array of `objects` to store in the given Algolia `indexName`.
|
|
2521
|
+
* @param replaceAllObjects.batchSize - The size of the chunk of `objects`. The number of `batch` calls will be equal to `length(objects) / batchSize`. Defaults to 1000.
|
|
2522
|
+
* @param requestOptions - The requestOptions to send along with the query, they will be forwarded to the `getTask` method and merged with the transporter requestOptions.
|
|
2523
|
+
*/
|
|
2524
|
+
async replaceAllObjects({ indexName, objects, batchSize }, requestOptions) {
|
|
2525
|
+
const randomSuffix = Math.random().toString(36).substring(7);
|
|
2526
|
+
const tmpIndexName = `${indexName}_tmp_${randomSuffix}`;
|
|
2527
|
+
const copyOperationResponse = await this.operationIndex({
|
|
2528
|
+
indexName,
|
|
2529
|
+
operationIndexParams: {
|
|
2530
|
+
operation: 'copy',
|
|
2531
|
+
destination: tmpIndexName,
|
|
2532
|
+
scope: ['settings', 'rules', 'synonyms'],
|
|
2533
|
+
},
|
|
2534
|
+
}, requestOptions);
|
|
2535
|
+
await this.waitForTask({
|
|
2536
|
+
indexName,
|
|
2537
|
+
taskID: copyOperationResponse.taskID,
|
|
2538
|
+
});
|
|
2539
|
+
const batchResponses = await this.chunkedBatch({ indexName: tmpIndexName, objects, waitForTasks: true, batchSize }, requestOptions);
|
|
2540
|
+
const moveOperationResponse = await this.operationIndex({
|
|
2541
|
+
indexName: tmpIndexName,
|
|
2542
|
+
operationIndexParams: { operation: 'move', destination: indexName },
|
|
2543
|
+
}, requestOptions);
|
|
2544
|
+
await this.waitForTask({
|
|
2545
|
+
indexName,
|
|
2546
|
+
taskID: moveOperationResponse.taskID,
|
|
2547
|
+
});
|
|
2548
|
+
return { copyOperationResponse, batchResponses, moveOperationResponse };
|
|
2549
|
+
},
|
|
2453
2550
|
/**
|
|
2454
2551
|
* Add a new API key with specific permissions and restrictions. The request must be authenticated with the admin API key. The response returns an API key string.
|
|
2455
2552
|
*
|