@algolia/client-search 5.0.0-alpha.4 → 5.0.0-alpha.7
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/client-search.cjs.js +21 -21
- package/dist/client-search.esm.browser.js +21 -21
- package/dist/client-search.esm.node.js +21 -21
- package/dist/client-search.umd.js +2 -2
- package/dist/model/baseSearchResponse.d.ts +1 -1
- package/dist/model/baseSearchResponse.d.ts.map +1 -1
- package/dist/model/browseParams.d.ts +4 -0
- package/dist/model/browseParams.d.ts.map +1 -0
- package/dist/model/browseParamsObject.d.ts +4 -0
- package/dist/model/browseParamsObject.d.ts.map +1 -0
- package/dist/model/browseResponse.d.ts +2 -2
- package/dist/model/browseResponse.d.ts.map +1 -1
- package/dist/model/clientMethodProps.d.ts +9 -11
- package/dist/model/clientMethodProps.d.ts.map +1 -1
- package/dist/model/{baseBrowseResponse.d.ts → cursor.d.ts} +3 -3
- package/dist/model/cursor.d.ts.map +1 -0
- package/dist/model/index.d.ts +3 -2
- package/dist/model/index.d.ts.map +1 -1
- package/dist/model/indexSettingsAsSearchParams.d.ts +4 -0
- package/dist/model/indexSettingsAsSearchParams.d.ts.map +1 -1
- package/dist/src/searchClient.d.ts +12 -12
- package/dist/src/searchClient.d.ts.map +1 -1
- package/model/baseSearchResponse.ts +1 -1
- package/model/browseParams.ts +6 -0
- package/model/browseParamsObject.ts +6 -0
- package/model/browseResponse.ts +3 -3
- package/model/clientMethodProps.ts +9 -14
- package/model/{baseBrowseResponse.ts → cursor.ts} +2 -2
- package/model/index.ts +3 -2
- package/model/indexSettingsAsSearchParams.ts +5 -0
- package/package.json +4 -4
- package/dist/model/baseBrowseResponse.d.ts.map +0 -1
- package/dist/model/browseRequest.d.ts +0 -11
- package/dist/model/browseRequest.d.ts.map +0 -1
- package/model/browseRequest.ts +0 -13
|
@@ -6,7 +6,7 @@ var clientCommon = require('@algolia/client-common');
|
|
|
6
6
|
var requesterNodeHttp = require('@algolia/requester-node-http');
|
|
7
7
|
|
|
8
8
|
// This file is generated, manual changes will be lost - read more on https://github.com/algolia/api-clients-automation.
|
|
9
|
-
const apiClientVersion = '5.0.0-alpha.
|
|
9
|
+
const apiClientVersion = '5.0.0-alpha.7';
|
|
10
10
|
function getDefaultHosts(appId) {
|
|
11
11
|
return [
|
|
12
12
|
{
|
|
@@ -169,19 +169,19 @@ function createSearchClient({ appId: appIdOption, apiKey: apiKeyOption, authMode
|
|
|
169
169
|
* @summary Helper method that iterates on the `browse` method.
|
|
170
170
|
* @param browseObjects - The browseObjects object.
|
|
171
171
|
* @param browseObjects.indexName - The index in which to perform the request.
|
|
172
|
-
* @param browseObjects.
|
|
173
|
-
* @param browseObjects.validate - The validator function. It receive the resolved return of the API call.
|
|
172
|
+
* @param browseObjects.browseParams - The `browse` parameters.
|
|
173
|
+
* @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.
|
|
174
174
|
* @param browseObjects.aggregator - The function that runs right after the API call has been resolved, allows you to do anything with the response before `validate`.
|
|
175
175
|
* @param requestOptions - The requestOptions to send along with the query, they will be forwarded to the `browse` method and merged with the transporter requestOptions.
|
|
176
176
|
*/
|
|
177
|
-
browseObjects({ indexName,
|
|
177
|
+
browseObjects({ indexName, browseParams, ...browseObjectsOptions }, requestOptions) {
|
|
178
178
|
return clientCommon.createIterablePromise({
|
|
179
179
|
func: (previousResponse) => {
|
|
180
180
|
return this.browse({
|
|
181
181
|
indexName,
|
|
182
|
-
|
|
182
|
+
browseParams: {
|
|
183
183
|
cursor: previousResponse ? previousResponse.cursor : undefined,
|
|
184
|
-
...
|
|
184
|
+
...browseParams,
|
|
185
185
|
},
|
|
186
186
|
}, requestOptions);
|
|
187
187
|
},
|
|
@@ -196,7 +196,7 @@ function createSearchClient({ appId: appIdOption, apiKey: apiKeyOption, authMode
|
|
|
196
196
|
* @param browseObjects - The browseObjects object.
|
|
197
197
|
* @param browseObjects.indexName - The index in which to perform the request.
|
|
198
198
|
* @param browseObjects.searchRulesParams - The `searchRules` method parameters.
|
|
199
|
-
* @param browseObjects.validate - The validator function. It receive the resolved return of the API call.
|
|
199
|
+
* @param browseObjects.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).
|
|
200
200
|
* @param browseObjects.aggregator - The function that runs right after the API call has been resolved, allows you to do anything with the response before `validate`.
|
|
201
201
|
* @param requestOptions - The requestOptions to send along with the query, they will be forwarded to the `searchRules` method and merged with the transporter requestOptions.
|
|
202
202
|
*/
|
|
@@ -227,7 +227,7 @@ function createSearchClient({ appId: appIdOption, apiKey: apiKeyOption, authMode
|
|
|
227
227
|
* @summary Helper method that iterates on the `searchSynonyms` method.
|
|
228
228
|
* @param browseObjects - The browseObjects object.
|
|
229
229
|
* @param browseObjects.indexName - The index in which to perform the request.
|
|
230
|
-
* @param browseObjects.validate - The validator function. It receive the resolved return of the API call.
|
|
230
|
+
* @param browseObjects.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).
|
|
231
231
|
* @param browseObjects.aggregator - The function that runs right after the API call has been resolved, allows you to do anything with the response before `validate`.
|
|
232
232
|
* @param requestOptions - The requestOptions to send along with the query, they will be forwarded to the `searchSynonyms` method and merged with the transporter requestOptions.
|
|
233
233
|
*/
|
|
@@ -469,10 +469,10 @@ function createSearchClient({ appId: appIdOption, apiKey: apiKeyOption, authMode
|
|
|
469
469
|
* @summary Retrieve all index content.
|
|
470
470
|
* @param browse - The browse object.
|
|
471
471
|
* @param browse.indexName - The index in which to perform the request.
|
|
472
|
-
* @param browse.
|
|
472
|
+
* @param browse.browseParams - The browseParams object.
|
|
473
473
|
* @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
|
|
474
474
|
*/
|
|
475
|
-
browse({ indexName,
|
|
475
|
+
browse({ indexName, browseParams }, requestOptions) {
|
|
476
476
|
if (!indexName) {
|
|
477
477
|
throw new Error('Parameter `indexName` is required when calling `browse`.');
|
|
478
478
|
}
|
|
@@ -484,7 +484,7 @@ function createSearchClient({ appId: appIdOption, apiKey: apiKeyOption, authMode
|
|
|
484
484
|
path: requestPath,
|
|
485
485
|
queryParameters,
|
|
486
486
|
headers,
|
|
487
|
-
data:
|
|
487
|
+
data: browseParams ? browseParams : {},
|
|
488
488
|
};
|
|
489
489
|
return transporter.request(request, requestOptions);
|
|
490
490
|
},
|
|
@@ -1305,19 +1305,19 @@ function createSearchClient({ appId: appIdOption, apiKey: apiKeyOption, authMode
|
|
|
1305
1305
|
* @param partialUpdateObject - The partialUpdateObject object.
|
|
1306
1306
|
* @param partialUpdateObject.indexName - The index in which to perform the request.
|
|
1307
1307
|
* @param partialUpdateObject.objectID - Unique identifier of an object.
|
|
1308
|
-
* @param partialUpdateObject.
|
|
1308
|
+
* @param partialUpdateObject.attributesToUpdate - Map of attribute(s) to update.
|
|
1309
1309
|
* @param partialUpdateObject.createIfNotExists - Creates the record if it does not exist yet.
|
|
1310
1310
|
* @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
|
|
1311
1311
|
*/
|
|
1312
|
-
partialUpdateObject({ indexName, objectID,
|
|
1312
|
+
partialUpdateObject({ indexName, objectID, attributesToUpdate, createIfNotExists, }, requestOptions) {
|
|
1313
1313
|
if (!indexName) {
|
|
1314
1314
|
throw new Error('Parameter `indexName` is required when calling `partialUpdateObject`.');
|
|
1315
1315
|
}
|
|
1316
1316
|
if (!objectID) {
|
|
1317
1317
|
throw new Error('Parameter `objectID` is required when calling `partialUpdateObject`.');
|
|
1318
1318
|
}
|
|
1319
|
-
if (!
|
|
1320
|
-
throw new Error('Parameter `
|
|
1319
|
+
if (!attributesToUpdate) {
|
|
1320
|
+
throw new Error('Parameter `attributesToUpdate` is required when calling `partialUpdateObject`.');
|
|
1321
1321
|
}
|
|
1322
1322
|
const requestPath = '/1/indexes/{indexName}/{objectID}/partial'
|
|
1323
1323
|
.replace('{indexName}', encodeURIComponent(indexName))
|
|
@@ -1332,7 +1332,7 @@ function createSearchClient({ appId: appIdOption, apiKey: apiKeyOption, authMode
|
|
|
1332
1332
|
path: requestPath,
|
|
1333
1333
|
queryParameters,
|
|
1334
1334
|
headers,
|
|
1335
|
-
data:
|
|
1335
|
+
data: attributesToUpdate,
|
|
1336
1336
|
};
|
|
1337
1337
|
return transporter.request(request, requestOptions);
|
|
1338
1338
|
},
|
|
@@ -1533,17 +1533,17 @@ function createSearchClient({ appId: appIdOption, apiKey: apiKeyOption, authMode
|
|
|
1533
1533
|
* @summary Save a batch of rules.
|
|
1534
1534
|
* @param saveRules - The saveRules object.
|
|
1535
1535
|
* @param saveRules.indexName - The index in which to perform the request.
|
|
1536
|
-
* @param saveRules.
|
|
1536
|
+
* @param saveRules.rules - The rules object.
|
|
1537
1537
|
* @param saveRules.forwardToReplicas - When true, changes are also propagated to replicas of the given indexName.
|
|
1538
1538
|
* @param saveRules.clearExistingRules - When true, existing Rules are cleared before adding this batch. When false, existing Rules are kept.
|
|
1539
1539
|
* @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
|
|
1540
1540
|
*/
|
|
1541
|
-
saveRules({ indexName,
|
|
1541
|
+
saveRules({ indexName, rules, forwardToReplicas, clearExistingRules, }, requestOptions) {
|
|
1542
1542
|
if (!indexName) {
|
|
1543
1543
|
throw new Error('Parameter `indexName` is required when calling `saveRules`.');
|
|
1544
1544
|
}
|
|
1545
|
-
if (!
|
|
1546
|
-
throw new Error('Parameter `
|
|
1545
|
+
if (!rules) {
|
|
1546
|
+
throw new Error('Parameter `rules` is required when calling `saveRules`.');
|
|
1547
1547
|
}
|
|
1548
1548
|
const requestPath = '/1/indexes/{indexName}/rules/batch'.replace('{indexName}', encodeURIComponent(indexName));
|
|
1549
1549
|
const headers = {};
|
|
@@ -1559,7 +1559,7 @@ function createSearchClient({ appId: appIdOption, apiKey: apiKeyOption, authMode
|
|
|
1559
1559
|
path: requestPath,
|
|
1560
1560
|
queryParameters,
|
|
1561
1561
|
headers,
|
|
1562
|
-
data:
|
|
1562
|
+
data: rules,
|
|
1563
1563
|
};
|
|
1564
1564
|
return transporter.request(request, requestOptions);
|
|
1565
1565
|
},
|
|
@@ -767,7 +767,7 @@ function createXhrRequester() {
|
|
|
767
767
|
}
|
|
768
768
|
|
|
769
769
|
// This file is generated, manual changes will be lost - read more on https://github.com/algolia/api-clients-automation.
|
|
770
|
-
const apiClientVersion = '5.0.0-alpha.
|
|
770
|
+
const apiClientVersion = '5.0.0-alpha.7';
|
|
771
771
|
function getDefaultHosts(appId) {
|
|
772
772
|
return [
|
|
773
773
|
{
|
|
@@ -930,19 +930,19 @@ function createSearchClient({ appId: appIdOption, apiKey: apiKeyOption, authMode
|
|
|
930
930
|
* @summary Helper method that iterates on the `browse` method.
|
|
931
931
|
* @param browseObjects - The browseObjects object.
|
|
932
932
|
* @param browseObjects.indexName - The index in which to perform the request.
|
|
933
|
-
* @param browseObjects.
|
|
934
|
-
* @param browseObjects.validate - The validator function. It receive the resolved return of the API call.
|
|
933
|
+
* @param browseObjects.browseParams - The `browse` parameters.
|
|
934
|
+
* @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.
|
|
935
935
|
* @param browseObjects.aggregator - The function that runs right after the API call has been resolved, allows you to do anything with the response before `validate`.
|
|
936
936
|
* @param requestOptions - The requestOptions to send along with the query, they will be forwarded to the `browse` method and merged with the transporter requestOptions.
|
|
937
937
|
*/
|
|
938
|
-
browseObjects({ indexName,
|
|
938
|
+
browseObjects({ indexName, browseParams, ...browseObjectsOptions }, requestOptions) {
|
|
939
939
|
return createIterablePromise({
|
|
940
940
|
func: (previousResponse) => {
|
|
941
941
|
return this.browse({
|
|
942
942
|
indexName,
|
|
943
|
-
|
|
943
|
+
browseParams: {
|
|
944
944
|
cursor: previousResponse ? previousResponse.cursor : undefined,
|
|
945
|
-
...
|
|
945
|
+
...browseParams,
|
|
946
946
|
},
|
|
947
947
|
}, requestOptions);
|
|
948
948
|
},
|
|
@@ -957,7 +957,7 @@ function createSearchClient({ appId: appIdOption, apiKey: apiKeyOption, authMode
|
|
|
957
957
|
* @param browseObjects - The browseObjects object.
|
|
958
958
|
* @param browseObjects.indexName - The index in which to perform the request.
|
|
959
959
|
* @param browseObjects.searchRulesParams - The `searchRules` method parameters.
|
|
960
|
-
* @param browseObjects.validate - The validator function. It receive the resolved return of the API call.
|
|
960
|
+
* @param browseObjects.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).
|
|
961
961
|
* @param browseObjects.aggregator - The function that runs right after the API call has been resolved, allows you to do anything with the response before `validate`.
|
|
962
962
|
* @param requestOptions - The requestOptions to send along with the query, they will be forwarded to the `searchRules` method and merged with the transporter requestOptions.
|
|
963
963
|
*/
|
|
@@ -988,7 +988,7 @@ function createSearchClient({ appId: appIdOption, apiKey: apiKeyOption, authMode
|
|
|
988
988
|
* @summary Helper method that iterates on the `searchSynonyms` method.
|
|
989
989
|
* @param browseObjects - The browseObjects object.
|
|
990
990
|
* @param browseObjects.indexName - The index in which to perform the request.
|
|
991
|
-
* @param browseObjects.validate - The validator function. It receive the resolved return of the API call.
|
|
991
|
+
* @param browseObjects.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).
|
|
992
992
|
* @param browseObjects.aggregator - The function that runs right after the API call has been resolved, allows you to do anything with the response before `validate`.
|
|
993
993
|
* @param requestOptions - The requestOptions to send along with the query, they will be forwarded to the `searchSynonyms` method and merged with the transporter requestOptions.
|
|
994
994
|
*/
|
|
@@ -1230,10 +1230,10 @@ function createSearchClient({ appId: appIdOption, apiKey: apiKeyOption, authMode
|
|
|
1230
1230
|
* @summary Retrieve all index content.
|
|
1231
1231
|
* @param browse - The browse object.
|
|
1232
1232
|
* @param browse.indexName - The index in which to perform the request.
|
|
1233
|
-
* @param browse.
|
|
1233
|
+
* @param browse.browseParams - The browseParams object.
|
|
1234
1234
|
* @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
|
|
1235
1235
|
*/
|
|
1236
|
-
browse({ indexName,
|
|
1236
|
+
browse({ indexName, browseParams }, requestOptions) {
|
|
1237
1237
|
if (!indexName) {
|
|
1238
1238
|
throw new Error('Parameter `indexName` is required when calling `browse`.');
|
|
1239
1239
|
}
|
|
@@ -1245,7 +1245,7 @@ function createSearchClient({ appId: appIdOption, apiKey: apiKeyOption, authMode
|
|
|
1245
1245
|
path: requestPath,
|
|
1246
1246
|
queryParameters,
|
|
1247
1247
|
headers,
|
|
1248
|
-
data:
|
|
1248
|
+
data: browseParams ? browseParams : {},
|
|
1249
1249
|
};
|
|
1250
1250
|
return transporter.request(request, requestOptions);
|
|
1251
1251
|
},
|
|
@@ -2066,19 +2066,19 @@ function createSearchClient({ appId: appIdOption, apiKey: apiKeyOption, authMode
|
|
|
2066
2066
|
* @param partialUpdateObject - The partialUpdateObject object.
|
|
2067
2067
|
* @param partialUpdateObject.indexName - The index in which to perform the request.
|
|
2068
2068
|
* @param partialUpdateObject.objectID - Unique identifier of an object.
|
|
2069
|
-
* @param partialUpdateObject.
|
|
2069
|
+
* @param partialUpdateObject.attributesToUpdate - Map of attribute(s) to update.
|
|
2070
2070
|
* @param partialUpdateObject.createIfNotExists - Creates the record if it does not exist yet.
|
|
2071
2071
|
* @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
|
|
2072
2072
|
*/
|
|
2073
|
-
partialUpdateObject({ indexName, objectID,
|
|
2073
|
+
partialUpdateObject({ indexName, objectID, attributesToUpdate, createIfNotExists, }, requestOptions) {
|
|
2074
2074
|
if (!indexName) {
|
|
2075
2075
|
throw new Error('Parameter `indexName` is required when calling `partialUpdateObject`.');
|
|
2076
2076
|
}
|
|
2077
2077
|
if (!objectID) {
|
|
2078
2078
|
throw new Error('Parameter `objectID` is required when calling `partialUpdateObject`.');
|
|
2079
2079
|
}
|
|
2080
|
-
if (!
|
|
2081
|
-
throw new Error('Parameter `
|
|
2080
|
+
if (!attributesToUpdate) {
|
|
2081
|
+
throw new Error('Parameter `attributesToUpdate` is required when calling `partialUpdateObject`.');
|
|
2082
2082
|
}
|
|
2083
2083
|
const requestPath = '/1/indexes/{indexName}/{objectID}/partial'
|
|
2084
2084
|
.replace('{indexName}', encodeURIComponent(indexName))
|
|
@@ -2093,7 +2093,7 @@ function createSearchClient({ appId: appIdOption, apiKey: apiKeyOption, authMode
|
|
|
2093
2093
|
path: requestPath,
|
|
2094
2094
|
queryParameters,
|
|
2095
2095
|
headers,
|
|
2096
|
-
data:
|
|
2096
|
+
data: attributesToUpdate,
|
|
2097
2097
|
};
|
|
2098
2098
|
return transporter.request(request, requestOptions);
|
|
2099
2099
|
},
|
|
@@ -2294,17 +2294,17 @@ function createSearchClient({ appId: appIdOption, apiKey: apiKeyOption, authMode
|
|
|
2294
2294
|
* @summary Save a batch of rules.
|
|
2295
2295
|
* @param saveRules - The saveRules object.
|
|
2296
2296
|
* @param saveRules.indexName - The index in which to perform the request.
|
|
2297
|
-
* @param saveRules.
|
|
2297
|
+
* @param saveRules.rules - The rules object.
|
|
2298
2298
|
* @param saveRules.forwardToReplicas - When true, changes are also propagated to replicas of the given indexName.
|
|
2299
2299
|
* @param saveRules.clearExistingRules - When true, existing Rules are cleared before adding this batch. When false, existing Rules are kept.
|
|
2300
2300
|
* @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
|
|
2301
2301
|
*/
|
|
2302
|
-
saveRules({ indexName,
|
|
2302
|
+
saveRules({ indexName, rules, forwardToReplicas, clearExistingRules, }, requestOptions) {
|
|
2303
2303
|
if (!indexName) {
|
|
2304
2304
|
throw new Error('Parameter `indexName` is required when calling `saveRules`.');
|
|
2305
2305
|
}
|
|
2306
|
-
if (!
|
|
2307
|
-
throw new Error('Parameter `
|
|
2306
|
+
if (!rules) {
|
|
2307
|
+
throw new Error('Parameter `rules` is required when calling `saveRules`.');
|
|
2308
2308
|
}
|
|
2309
2309
|
const requestPath = '/1/indexes/{indexName}/rules/batch'.replace('{indexName}', encodeURIComponent(indexName));
|
|
2310
2310
|
const headers = {};
|
|
@@ -2320,7 +2320,7 @@ function createSearchClient({ appId: appIdOption, apiKey: apiKeyOption, authMode
|
|
|
2320
2320
|
path: requestPath,
|
|
2321
2321
|
queryParameters,
|
|
2322
2322
|
headers,
|
|
2323
|
-
data:
|
|
2323
|
+
data: rules,
|
|
2324
2324
|
};
|
|
2325
2325
|
return transporter.request(request, requestOptions);
|
|
2326
2326
|
},
|
|
@@ -2,7 +2,7 @@ import { createAuth, createTransporter, getAlgoliaAgent, createIterablePromise,
|
|
|
2
2
|
import { createHttpRequester } from '@algolia/requester-node-http';
|
|
3
3
|
|
|
4
4
|
// This file is generated, manual changes will be lost - read more on https://github.com/algolia/api-clients-automation.
|
|
5
|
-
const apiClientVersion = '5.0.0-alpha.
|
|
5
|
+
const apiClientVersion = '5.0.0-alpha.7';
|
|
6
6
|
function getDefaultHosts(appId) {
|
|
7
7
|
return [
|
|
8
8
|
{
|
|
@@ -165,19 +165,19 @@ function createSearchClient({ appId: appIdOption, apiKey: apiKeyOption, authMode
|
|
|
165
165
|
* @summary Helper method that iterates on the `browse` method.
|
|
166
166
|
* @param browseObjects - The browseObjects object.
|
|
167
167
|
* @param browseObjects.indexName - The index in which to perform the request.
|
|
168
|
-
* @param browseObjects.
|
|
169
|
-
* @param browseObjects.validate - The validator function. It receive the resolved return of the API call.
|
|
168
|
+
* @param browseObjects.browseParams - The `browse` parameters.
|
|
169
|
+
* @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.
|
|
170
170
|
* @param browseObjects.aggregator - The function that runs right after the API call has been resolved, allows you to do anything with the response before `validate`.
|
|
171
171
|
* @param requestOptions - The requestOptions to send along with the query, they will be forwarded to the `browse` method and merged with the transporter requestOptions.
|
|
172
172
|
*/
|
|
173
|
-
browseObjects({ indexName,
|
|
173
|
+
browseObjects({ indexName, browseParams, ...browseObjectsOptions }, requestOptions) {
|
|
174
174
|
return createIterablePromise({
|
|
175
175
|
func: (previousResponse) => {
|
|
176
176
|
return this.browse({
|
|
177
177
|
indexName,
|
|
178
|
-
|
|
178
|
+
browseParams: {
|
|
179
179
|
cursor: previousResponse ? previousResponse.cursor : undefined,
|
|
180
|
-
...
|
|
180
|
+
...browseParams,
|
|
181
181
|
},
|
|
182
182
|
}, requestOptions);
|
|
183
183
|
},
|
|
@@ -192,7 +192,7 @@ function createSearchClient({ appId: appIdOption, apiKey: apiKeyOption, authMode
|
|
|
192
192
|
* @param browseObjects - The browseObjects object.
|
|
193
193
|
* @param browseObjects.indexName - The index in which to perform the request.
|
|
194
194
|
* @param browseObjects.searchRulesParams - The `searchRules` method parameters.
|
|
195
|
-
* @param browseObjects.validate - The validator function. It receive the resolved return of the API call.
|
|
195
|
+
* @param browseObjects.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).
|
|
196
196
|
* @param browseObjects.aggregator - The function that runs right after the API call has been resolved, allows you to do anything with the response before `validate`.
|
|
197
197
|
* @param requestOptions - The requestOptions to send along with the query, they will be forwarded to the `searchRules` method and merged with the transporter requestOptions.
|
|
198
198
|
*/
|
|
@@ -223,7 +223,7 @@ function createSearchClient({ appId: appIdOption, apiKey: apiKeyOption, authMode
|
|
|
223
223
|
* @summary Helper method that iterates on the `searchSynonyms` method.
|
|
224
224
|
* @param browseObjects - The browseObjects object.
|
|
225
225
|
* @param browseObjects.indexName - The index in which to perform the request.
|
|
226
|
-
* @param browseObjects.validate - The validator function. It receive the resolved return of the API call.
|
|
226
|
+
* @param browseObjects.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).
|
|
227
227
|
* @param browseObjects.aggregator - The function that runs right after the API call has been resolved, allows you to do anything with the response before `validate`.
|
|
228
228
|
* @param requestOptions - The requestOptions to send along with the query, they will be forwarded to the `searchSynonyms` method and merged with the transporter requestOptions.
|
|
229
229
|
*/
|
|
@@ -465,10 +465,10 @@ function createSearchClient({ appId: appIdOption, apiKey: apiKeyOption, authMode
|
|
|
465
465
|
* @summary Retrieve all index content.
|
|
466
466
|
* @param browse - The browse object.
|
|
467
467
|
* @param browse.indexName - The index in which to perform the request.
|
|
468
|
-
* @param browse.
|
|
468
|
+
* @param browse.browseParams - The browseParams object.
|
|
469
469
|
* @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
|
|
470
470
|
*/
|
|
471
|
-
browse({ indexName,
|
|
471
|
+
browse({ indexName, browseParams }, requestOptions) {
|
|
472
472
|
if (!indexName) {
|
|
473
473
|
throw new Error('Parameter `indexName` is required when calling `browse`.');
|
|
474
474
|
}
|
|
@@ -480,7 +480,7 @@ function createSearchClient({ appId: appIdOption, apiKey: apiKeyOption, authMode
|
|
|
480
480
|
path: requestPath,
|
|
481
481
|
queryParameters,
|
|
482
482
|
headers,
|
|
483
|
-
data:
|
|
483
|
+
data: browseParams ? browseParams : {},
|
|
484
484
|
};
|
|
485
485
|
return transporter.request(request, requestOptions);
|
|
486
486
|
},
|
|
@@ -1301,19 +1301,19 @@ function createSearchClient({ appId: appIdOption, apiKey: apiKeyOption, authMode
|
|
|
1301
1301
|
* @param partialUpdateObject - The partialUpdateObject object.
|
|
1302
1302
|
* @param partialUpdateObject.indexName - The index in which to perform the request.
|
|
1303
1303
|
* @param partialUpdateObject.objectID - Unique identifier of an object.
|
|
1304
|
-
* @param partialUpdateObject.
|
|
1304
|
+
* @param partialUpdateObject.attributesToUpdate - Map of attribute(s) to update.
|
|
1305
1305
|
* @param partialUpdateObject.createIfNotExists - Creates the record if it does not exist yet.
|
|
1306
1306
|
* @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
|
|
1307
1307
|
*/
|
|
1308
|
-
partialUpdateObject({ indexName, objectID,
|
|
1308
|
+
partialUpdateObject({ indexName, objectID, attributesToUpdate, createIfNotExists, }, requestOptions) {
|
|
1309
1309
|
if (!indexName) {
|
|
1310
1310
|
throw new Error('Parameter `indexName` is required when calling `partialUpdateObject`.');
|
|
1311
1311
|
}
|
|
1312
1312
|
if (!objectID) {
|
|
1313
1313
|
throw new Error('Parameter `objectID` is required when calling `partialUpdateObject`.');
|
|
1314
1314
|
}
|
|
1315
|
-
if (!
|
|
1316
|
-
throw new Error('Parameter `
|
|
1315
|
+
if (!attributesToUpdate) {
|
|
1316
|
+
throw new Error('Parameter `attributesToUpdate` is required when calling `partialUpdateObject`.');
|
|
1317
1317
|
}
|
|
1318
1318
|
const requestPath = '/1/indexes/{indexName}/{objectID}/partial'
|
|
1319
1319
|
.replace('{indexName}', encodeURIComponent(indexName))
|
|
@@ -1328,7 +1328,7 @@ function createSearchClient({ appId: appIdOption, apiKey: apiKeyOption, authMode
|
|
|
1328
1328
|
path: requestPath,
|
|
1329
1329
|
queryParameters,
|
|
1330
1330
|
headers,
|
|
1331
|
-
data:
|
|
1331
|
+
data: attributesToUpdate,
|
|
1332
1332
|
};
|
|
1333
1333
|
return transporter.request(request, requestOptions);
|
|
1334
1334
|
},
|
|
@@ -1529,17 +1529,17 @@ function createSearchClient({ appId: appIdOption, apiKey: apiKeyOption, authMode
|
|
|
1529
1529
|
* @summary Save a batch of rules.
|
|
1530
1530
|
* @param saveRules - The saveRules object.
|
|
1531
1531
|
* @param saveRules.indexName - The index in which to perform the request.
|
|
1532
|
-
* @param saveRules.
|
|
1532
|
+
* @param saveRules.rules - The rules object.
|
|
1533
1533
|
* @param saveRules.forwardToReplicas - When true, changes are also propagated to replicas of the given indexName.
|
|
1534
1534
|
* @param saveRules.clearExistingRules - When true, existing Rules are cleared before adding this batch. When false, existing Rules are kept.
|
|
1535
1535
|
* @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
|
|
1536
1536
|
*/
|
|
1537
|
-
saveRules({ indexName,
|
|
1537
|
+
saveRules({ indexName, rules, forwardToReplicas, clearExistingRules, }, requestOptions) {
|
|
1538
1538
|
if (!indexName) {
|
|
1539
1539
|
throw new Error('Parameter `indexName` is required when calling `saveRules`.');
|
|
1540
1540
|
}
|
|
1541
|
-
if (!
|
|
1542
|
-
throw new Error('Parameter `
|
|
1541
|
+
if (!rules) {
|
|
1542
|
+
throw new Error('Parameter `rules` is required when calling `saveRules`.');
|
|
1543
1543
|
}
|
|
1544
1544
|
const requestPath = '/1/indexes/{indexName}/rules/batch'.replace('{indexName}', encodeURIComponent(indexName));
|
|
1545
1545
|
const headers = {};
|
|
@@ -1555,7 +1555,7 @@ function createSearchClient({ appId: appIdOption, apiKey: apiKeyOption, authMode
|
|
|
1555
1555
|
path: requestPath,
|
|
1556
1556
|
queryParameters,
|
|
1557
1557
|
headers,
|
|
1558
|
-
data:
|
|
1558
|
+
data: rules,
|
|
1559
1559
|
};
|
|
1560
1560
|
return transporter.request(request, requestOptions);
|
|
1561
1561
|
},
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
/*! client-search.umd.js | 5.0.0-alpha.
|
|
2
|
-
!function(e,r){"object"==typeof exports&&"undefined"!=typeof module?r(exports):"function"==typeof define&&define.amd?define(["exports"],r):r((e="undefined"!=typeof globalThis?globalThis:e||self)["@algolia/client-search"]={})}(this,(function(e){"use strict";function r(e,r,t){return r in e?Object.defineProperty(e,r,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[r]=t,e}function t({func:e,validate:r,aggregator:t,error:a,timeout:n=(()=>0)}){const i=o=>new Promise(((s,c)=>{e(o).then((e=>(t&&t(e),r(e)?s(e):a&&a.validate(e)?c(new Error(a.message(e))):setTimeout((()=>{i(e).then(s).catch(c)}),n())))).catch((e=>{c(e)}))}));return i()}function a(e){let r;const t=`algolia-client-js-${e.key}`;function a(){return void 0===r&&(r=e.localStorage||window.localStorage),r}function n(){return JSON.parse(a().getItem(t)||"{}")}return{get:(e,r,t={miss:()=>Promise.resolve()})=>Promise.resolve().then((()=>{const t=JSON.stringify(e),a=n()[t];return Promise.all([a||r(),void 0!==a])})).then((([e,r])=>Promise.all([e,r||t.miss(e)]))).then((([e])=>e)),set:(e,r)=>Promise.resolve().then((()=>{const i=n();return i[JSON.stringify(e)]=r,a().setItem(t,JSON.stringify(i)),r})),delete:e=>Promise.resolve().then((()=>{const r=n();delete r[JSON.stringify(e)],a().setItem(t,JSON.stringify(r))})),clear:()=>Promise.resolve().then((()=>{a().removeItem(t)}))}}function n(e){const r=[...e.caches],t=r.shift();return void 0===t?{get:(e,r,t={miss:()=>Promise.resolve()})=>r().then((e=>Promise.all([e,t.miss(e)]))).then((([e])=>e)),set:(e,r)=>Promise.resolve(r),delete:e=>Promise.resolve(),clear:()=>Promise.resolve()}:{get:(e,a,i={miss:()=>Promise.resolve()})=>t.get(e,a,i).catch((()=>n({caches:r}).get(e,a,i))),set:(e,a)=>t.set(e,a).catch((()=>n({caches:r}).set(e,a))),delete:e=>t.delete(e).catch((()=>n({caches:r}).delete(e))),clear:()=>t.clear().catch((()=>n({caches:r}).clear()))}}function i(e={serializable:!0}){let r={};return{get(t,a,n={miss:()=>Promise.resolve()}){const i=JSON.stringify(t);if(i in r)return Promise.resolve(e.serializable?JSON.parse(r[i]):r[i]);const o=a();return o.then((e=>n.miss(e))).then((()=>o))},set:(t,a)=>(r[JSON.stringify(t)]=e.serializable?JSON.stringify(a):a,Promise.resolve(a)),delete:e=>(delete r[JSON.stringify(e)],Promise.resolve()),clear:()=>(r={},Promise.resolve())}}const o=12e4;function s(e,r="up"){const t=Date.now();return{...e,status:r,lastUpdate:t,isUp:function(){return"up"===r||Date.now()-t>o},isTimedOut:function(){return"timed out"===r&&Date.now()-t<=o}}}function c(e,r,t){return r in e?Object.defineProperty(e,r,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[r]=t,e}class u extends Error{constructor(e,r){super(e),c(this,"name","AlgoliaError"),r&&(this.name=r)}}class d extends u{constructor(e,r,t){super(e,t),c(this,"stackTrace",void 0),this.stackTrace=r}}class l extends d{constructor(e){super("Unreachable hosts - your application id may be incorrect. If the error persists, contact support@algolia.com.",e,"RetryError")}}class m extends d{constructor(e,r,t){super(e,t,"ApiError"),c(this,"status",void 0),this.status=r}}class h extends u{constructor(e,r){super(e,"DeserializationError"),c(this,"response",void 0),this.response=r}}function p(e,r,t){const a=function(e){const r=e=>"[object Object]"===Object.prototype.toString.call(e)||"[object Array]"===Object.prototype.toString.call(e);return Object.keys(e).map((t=>`${t}=${r(e[t])?JSON.stringify(e[t]):e[t]}`)).join("&")}(t);let n=`${e.protocol}://${e.url}/${"/"===r.charAt(0)?r.substr(1):r}`;return a.length&&(n+=`?${a}`),n}function f(e){const r=e.request.headers["x-algolia-api-key"]?{"x-algolia-api-key":"*****"}:{};return{...e,request:{...e.request,headers:{...e.request.headers,...r}}}}function g({hosts:e,hostsCache:r,baseHeaders:t,baseQueryParameters:a,algoliaAgent:n,timeouts:i,requester:o,requestsCache:c,responsesCache:u}){async function d(c,u,d=!0){const g=[],w=function(e,r){if("GET"===e.method||void 0===e.data&&void 0===r.data)return;const t=Array.isArray(e.data)?e.data:{...e.data,...r.data};return JSON.stringify(t)}(c,u),y=function(e,r,t){const a={Accept:"application/json",...e,...r,...t},n={};return Object.keys(a).forEach((e=>{const r=a[e];n[e.toLowerCase()]=r})),n}(t,c.headers,u.headers),P="GET"===c.method?{...c.data,...u.data}:{},q={"x-algolia-agent":n.value,...a,...c.queryParameters,...P};if(u&&u.queryParameters)for(const e of Object.keys(u.queryParameters))u.queryParameters[e]&&"[object Object]"!==Object.prototype.toString.call(u.queryParameters[e])?q[e]=u.queryParameters[e].toString():q[e]=u.queryParameters[e];let v=0;const b=async(e,t)=>{const a=e.pop();if(void 0===a)throw new l(function(e){return e.map((e=>f(e)))}(g));let n=u.timeout;void 0===n&&(n=d?i.read:i.write);const P={data:w,headers:y,method:c.method,url:p(a,c.path,q),connectTimeout:t(v,i.connect),responseTimeout:t(v,n)},x=r=>{const t={request:P,response:r,host:a,triesLeft:e.length};return g.push(t),t},E=await o.send(P);if(function({isTimedOut:e,status:r}){return e||function({isTimedOut:e,status:r}){return!e&&0==~~r}({isTimedOut:e,status:r})||2!=~~(r/100)&&4!=~~(r/100)}(E)){const n=x(E);return E.isTimedOut&&v++,console.log("Retryable failure",f(n)),await r.set(a,s(a,E.isTimedOut?"timed out":"down")),b(e,t)}if(function({status:e}){return 2==~~(e/100)}(E))return function(e){try{return JSON.parse(e.content)}catch(r){throw new h(r.message,e)}}(E);throw x(E),function({content:e,status:r},t){let a=e;try{a=JSON.parse(e).message}catch(e){}return new m(a,r,t)}(E,g)},x=e.filter((e=>"readWrite"===e.accept||(d?"read"===e.accept:"write"===e.accept))),E=await async function(e){const t=await Promise.all(e.map((e=>r.get(e,(()=>Promise.resolve(s(e))))))),a=t.filter((e=>e.isUp())),n=t.filter((e=>e.isTimedOut())),i=[...a,...n];return{hosts:i.length>0?i:e,getTimeout:(e,r)=>(0===n.length&&0===e?1:n.length+3+e)*r}}(x);return b([...E.hosts].reverse(),E.getTimeout)}return{hostsCache:r,requester:o,timeouts:i,algoliaAgent:n,baseHeaders:t,baseQueryParameters:a,hosts:e,request:function(e,r={}){const n=e.useReadTransporter||"GET"===e.method;if(!n)return d(e,r,n);const i=()=>d(e,r);if(!0!==(r.cacheable||e.cacheable))return i();const o={request:e,requestOptions:r,transporter:{queryParameters:a,headers:t}};return u.get(o,(()=>c.get(o,(()=>c.set(o,i()).then((e=>Promise.all([c.delete(o),e])),(e=>Promise.all([c.delete(o),Promise.reject(e)]))).then((([e,r])=>r))))),{miss:e=>u.set(o,e)})},requestsCache:c,responsesCache:u}}function w({algoliaAgents:e,client:r,version:t}){const a=function(e){const r={value:`Algolia for JavaScript (${e})`,add(e){const t=`; ${e.segment}${void 0!==e.version?` (${e.version})`:""}`;return-1===r.value.indexOf(t)&&(r.value=`${r.value}${t}`),r}};return r}(t).add({segment:r,version:t});return e.forEach((e=>a.add(e))),a}function y(e){return y="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},y(e)}function P(e,r){if(null==e)return{};var t,a,n=function(e,r){if(null==e)return{};var t,a,n={},i=Object.keys(e);for(a=0;a<i.length;a++)t=i[a],r.indexOf(t)>=0||(n[t]=e[t]);return n}(e,r);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(a=0;a<i.length;a++)t=i[a],r.indexOf(t)>=0||Object.prototype.propertyIsEnumerable.call(e,t)&&(n[t]=e[t])}return n}var q=["appId","apiKey","authMode","algoliaAgents"],v=["indexName","browseRequest"],b=["indexName","searchRulesParams"],x=["indexName","validate","aggregator"],E=["params"];function I(e,r){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);r&&(a=a.filter((function(r){return Object.getOwnPropertyDescriptor(e,r).enumerable}))),t.push.apply(t,a)}return t}function N(e){for(var t=1;t<arguments.length;t++){var a=null!=arguments[t]?arguments[t]:{};t%2?I(Object(a),!0).forEach((function(t){r(e,t,a[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(a)):I(Object(a)).forEach((function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(a,r))}))}return e}var O="5.0.0-alpha.4";function S(e){return[{url:"".concat(e,"-dsn.algolia.net"),accept:"read",protocol:"https"},{url:"".concat(e,".algolia.net"),accept:"write",protocol:"https"}].concat(function(e){const r=e;for(let t=e.length-1;t>0;t--){const a=Math.floor(Math.random()*(t+1)),n=e[t];r[t]=e[a],r[a]=n}return r}([{url:"".concat(e,"-1.algolianet.com"),accept:"readWrite",protocol:"https"},{url:"".concat(e,"-2.algolianet.com"),accept:"readWrite",protocol:"https"},{url:"".concat(e,"-3.algolianet.com"),accept:"readWrite",protocol:"https"}]))}function T(e,r){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);r&&(a=a.filter((function(r){return Object.getOwnPropertyDescriptor(e,r).enumerable}))),t.push.apply(t,a)}return t}e.apiClientVersion=O,e.searchClient=function(e,o,s){if(!e||"string"!=typeof e)throw new Error("`appId` is missing.");if(!o||"string"!=typeof o)throw new Error("`apiKey` is missing.");return function(e){var r=e.appId,a=e.apiKey,n=e.authMode,i=e.algoliaAgents,o=P(e,q),s=function(e,r,t="WithinHeaders"){const a={"x-algolia-api-key":r,"x-algolia-application-id":e};return{headers:()=>"WithinHeaders"===t?a:{},queryParameters:()=>"WithinQueryParameters"===t?a:{}}}(r,a,n),c=g(N(N({hosts:S(r)},o),{},{algoliaAgent:w({algoliaAgents:i,client:"Search",version:O}),baseHeaders:N(N({"content-type":"text/plain"},s.headers()),o.baseHeaders),baseQueryParameters:N(N({},s.queryParameters()),o.baseQueryParameters)}));return{transporter:c,appId:r,clearCache:function(){return Promise.all([c.requestsCache.clear(),c.responsesCache.clear()]).then((function(){}))},get _ua(){return c.algoliaAgent.value},addAlgoliaAgent:function(e,r){c.algoliaAgent.add({segment:e,version:r})},waitForTask:function(e,r){var a=this,n=e.indexName,i=e.taskID,o=e.maxRetries,s=void 0===o?50:o,c=e.timeout,u=void 0===c?function(e){return Math.min(200*e,5e3)}:c,d=0;return t({func:function(){return a.getTask({indexName:n,taskID:i},r)},validate:function(e){return"published"===e.status},aggregator:function(){return d+=1},error:{validate:function(){return d>=s},message:function(){return"The maximum number of retries exceeded. (".concat(d,"/").concat(s,")")}},timeout:function(){return u(d)}})},waitForApiKey:function(e,r){var a=this,n=e.operation,i=e.key,o=e.apiKey,s=e.maxRetries,c=void 0===s?50:s,u=e.timeout,d=void 0===u?function(e){return Math.min(200*e,5e3)}:u,l=0,m={aggregator:function(){return l+=1},error:{validate:function(){return l>=c},message:function(){return"The maximum number of retries exceeded. (".concat(l,"/").concat(c,")")}},timeout:function(){return d(l)}};if("update"===n){if(!o)throw new Error("`apiKey` is required when waiting for an `update` operation.");return t(N(N({},m),{},{func:function(){return a.getApiKey({key:i},r)},validate:function(e){for(var r=function(){var r=a[t];if(Array.isArray(o[r])){if(o[r].length!==e[r].length||o[r].some((function(t,a){return t!==e[r][a]})))return{v:!1}}else if(e[r]!==o[r])return{v:!1}},t=0,a=Object.keys(o);t<a.length;t++){var n=r();if("object"===y(n))return n.v}return!0}}))}return t(N(N({},m),{},{func:function(){return a.getApiKey({key:i},r).catch((function(e){return e}))},validate:function(e){return"add"===n?404!==e.status:404===e.status}}))},browseObjects:function(e,r){var a=this,n=e.indexName,i=e.browseRequest;return t(N({func:function(e){return a.browse({indexName:n,browseRequest:N({cursor:e?e.cursor:void 0},i)},r)},validate:function(e){return void 0===e.cursor}},P(e,v)))},browseRules:function(e,r){var a=this,n=e.indexName,i=e.searchRulesParams,o=P(e,b),s=N({hitsPerPage:1e3},i);return t(N({func:function(e){return a.searchRules({indexName:n,searchRulesParams:N(N({},s),{},{page:e?e.page+1:s.page||0})},r)},validate:function(e){return e.nbHits<s.hitsPerPage}},o))},browseSynonyms:function(e,r){var a=this,n=e.indexName;e.validate,e.aggregator;var i=P(e,x),o=N({hitsPerPage:1e3},i);return t(N({func:function(e){return a.searchSynonyms(N(N({},o),{},{indexName:n,page:e?e.page+1:i.page||0}),r)},validate:function(e){return e.nbHits<o.hitsPerPage}},i))},addApiKey:function(e,r){if(!e)throw new Error("Parameter `apiKey` is required when calling `addApiKey`.");if(!e.acl)throw new Error("Parameter `apiKey.acl` is required when calling `addApiKey`.");var t={method:"POST",path:"/1/keys",queryParameters:{},headers:{},data:e};return c.request(t,r)},addOrUpdateObject:function(e,r){var t=e.indexName,a=e.objectID,n=e.body;if(!t)throw new Error("Parameter `indexName` is required when calling `addOrUpdateObject`.");if(!a)throw new Error("Parameter `objectID` is required when calling `addOrUpdateObject`.");if(!n)throw new Error("Parameter `body` is required when calling `addOrUpdateObject`.");var i={method:"PUT",path:"/1/indexes/{indexName}/{objectID}".replace("{indexName}",encodeURIComponent(t)).replace("{objectID}",encodeURIComponent(a)),queryParameters:{},headers:{},data:n};return c.request(i,r)},appendSource:function(e,r){if(!e)throw new Error("Parameter `source` is required when calling `appendSource`.");var t={method:"POST",path:"/1/security/sources/append",queryParameters:{},headers:{},data:e};return c.request(t,r)},assignUserId:function(e,r){var t=e.xAlgoliaUserID,a=e.assignUserIdParams;if(!t)throw new Error("Parameter `xAlgoliaUserID` is required when calling `assignUserId`.");if(!a)throw new Error("Parameter `assignUserIdParams` is required when calling `assignUserId`.");if(!a.cluster)throw new Error("Parameter `assignUserIdParams.cluster` is required when calling `assignUserId`.");var n={};void 0!==t&&(n["X-Algolia-User-ID"]=t.toString());var i={method:"POST",path:"/1/clusters/mapping",queryParameters:{},headers:n,data:a};return c.request(i,r)},batch:function(e,r){var t=e.indexName,a=e.batchWriteParams;if(!t)throw new Error("Parameter `indexName` is required when calling `batch`.");if(!a)throw new Error("Parameter `batchWriteParams` is required when calling `batch`.");var n={method:"POST",path:"/1/indexes/{indexName}/batch".replace("{indexName}",encodeURIComponent(t)),queryParameters:{},headers:{},data:a};return c.request(n,r)},batchAssignUserIds:function(e,r){var t=e.xAlgoliaUserID,a=e.batchAssignUserIdsParams;if(!t)throw new Error("Parameter `xAlgoliaUserID` is required when calling `batchAssignUserIds`.");if(!a)throw new Error("Parameter `batchAssignUserIdsParams` is required when calling `batchAssignUserIds`.");if(!a.cluster)throw new Error("Parameter `batchAssignUserIdsParams.cluster` is required when calling `batchAssignUserIds`.");if(!a.users)throw new Error("Parameter `batchAssignUserIdsParams.users` is required when calling `batchAssignUserIds`.");var n={};void 0!==t&&(n["X-Algolia-User-ID"]=t.toString());var i={method:"POST",path:"/1/clusters/mapping/batch",queryParameters:{},headers:n,data:a};return c.request(i,r)},batchDictionaryEntries:function(e,r){var t=e.dictionaryName,a=e.batchDictionaryEntriesParams;if(!t)throw new Error("Parameter `dictionaryName` is required when calling `batchDictionaryEntries`.");if(!a)throw new Error("Parameter `batchDictionaryEntriesParams` is required when calling `batchDictionaryEntries`.");if(!a.requests)throw new Error("Parameter `batchDictionaryEntriesParams.requests` is required when calling `batchDictionaryEntries`.");var n={method:"POST",path:"/1/dictionaries/{dictionaryName}/batch".replace("{dictionaryName}",encodeURIComponent(t)),queryParameters:{},headers:{},data:a};return c.request(n,r)},browse:function(e,r){var t=e.indexName,a=e.browseRequest;if(!t)throw new Error("Parameter `indexName` is required when calling `browse`.");var n={method:"POST",path:"/1/indexes/{indexName}/browse".replace("{indexName}",encodeURIComponent(t)),queryParameters:{},headers:{},data:a||{}};return c.request(n,r)},clearAllSynonyms:function(e,r){var t=e.indexName,a=e.forwardToReplicas;if(!t)throw new Error("Parameter `indexName` is required when calling `clearAllSynonyms`.");var n="/1/indexes/{indexName}/synonyms/clear".replace("{indexName}",encodeURIComponent(t)),i={};void 0!==a&&(i.forwardToReplicas=a.toString());var o={method:"POST",path:n,queryParameters:i,headers:{}};return c.request(o,r)},clearObjects:function(e,r){var t=e.indexName;if(!t)throw new Error("Parameter `indexName` is required when calling `clearObjects`.");var a={method:"POST",path:"/1/indexes/{indexName}/clear".replace("{indexName}",encodeURIComponent(t)),queryParameters:{},headers:{}};return c.request(a,r)},clearRules:function(e,r){var t=e.indexName,a=e.forwardToReplicas;if(!t)throw new Error("Parameter `indexName` is required when calling `clearRules`.");var n="/1/indexes/{indexName}/rules/clear".replace("{indexName}",encodeURIComponent(t)),i={};void 0!==a&&(i.forwardToReplicas=a.toString());var o={method:"POST",path:n,queryParameters:i,headers:{}};return c.request(o,r)},del:function(e,r){var t=e.path,a=e.parameters;if(!t)throw new Error("Parameter `path` is required when calling `del`.");var n={method:"DELETE",path:"/1{path}".replace("{path}",t),queryParameters:a||{},headers:{}};return c.request(n,r)},deleteApiKey:function(e,r){var t=e.key;if(!t)throw new Error("Parameter `key` is required when calling `deleteApiKey`.");var a={method:"DELETE",path:"/1/keys/{key}".replace("{key}",encodeURIComponent(t)),queryParameters:{},headers:{}};return c.request(a,r)},deleteBy:function(e,r){var t=e.indexName,a=e.searchParams;if(!t)throw new Error("Parameter `indexName` is required when calling `deleteBy`.");if(!a)throw new Error("Parameter `searchParams` is required when calling `deleteBy`.");var n={method:"POST",path:"/1/indexes/{indexName}/deleteByQuery".replace("{indexName}",encodeURIComponent(t)),queryParameters:{},headers:{},data:a};return c.request(n,r)},deleteIndex:function(e,r){var t=e.indexName;if(!t)throw new Error("Parameter `indexName` is required when calling `deleteIndex`.");var a={method:"DELETE",path:"/1/indexes/{indexName}".replace("{indexName}",encodeURIComponent(t)),queryParameters:{},headers:{}};return c.request(a,r)},deleteObject:function(e,r){var t=e.indexName,a=e.objectID;if(!t)throw new Error("Parameter `indexName` is required when calling `deleteObject`.");if(!a)throw new Error("Parameter `objectID` is required when calling `deleteObject`.");var n={method:"DELETE",path:"/1/indexes/{indexName}/{objectID}".replace("{indexName}",encodeURIComponent(t)).replace("{objectID}",encodeURIComponent(a)),queryParameters:{},headers:{}};return c.request(n,r)},deleteRule:function(e,r){var t=e.indexName,a=e.objectID,n=e.forwardToReplicas;if(!t)throw new Error("Parameter `indexName` is required when calling `deleteRule`.");if(!a)throw new Error("Parameter `objectID` is required when calling `deleteRule`.");var i="/1/indexes/{indexName}/rules/{objectID}".replace("{indexName}",encodeURIComponent(t)).replace("{objectID}",encodeURIComponent(a)),o={};void 0!==n&&(o.forwardToReplicas=n.toString());var s={method:"DELETE",path:i,queryParameters:o,headers:{}};return c.request(s,r)},deleteSource:function(e,r){var t=e.source;if(!t)throw new Error("Parameter `source` is required when calling `deleteSource`.");var a={method:"DELETE",path:"/1/security/sources/{source}".replace("{source}",encodeURIComponent(t)),queryParameters:{},headers:{}};return c.request(a,r)},deleteSynonym:function(e,r){var t=e.indexName,a=e.objectID,n=e.forwardToReplicas;if(!t)throw new Error("Parameter `indexName` is required when calling `deleteSynonym`.");if(!a)throw new Error("Parameter `objectID` is required when calling `deleteSynonym`.");var i="/1/indexes/{indexName}/synonyms/{objectID}".replace("{indexName}",encodeURIComponent(t)).replace("{objectID}",encodeURIComponent(a)),o={};void 0!==n&&(o.forwardToReplicas=n.toString());var s={method:"DELETE",path:i,queryParameters:o,headers:{}};return c.request(s,r)},get:function(e,r){var t=e.path,a=e.parameters;if(!t)throw new Error("Parameter `path` is required when calling `get`.");var n={method:"GET",path:"/1{path}".replace("{path}",t),queryParameters:a||{},headers:{}};return c.request(n,r)},getApiKey:function(e,r){var t=e.key;if(!t)throw new Error("Parameter `key` is required when calling `getApiKey`.");var a={method:"GET",path:"/1/keys/{key}".replace("{key}",encodeURIComponent(t)),queryParameters:{},headers:{}};return c.request(a,r)},getDictionaryLanguages:function(e){var r={method:"GET",path:"/1/dictionaries/*/languages",queryParameters:{},headers:{}};return c.request(r,e)},getDictionarySettings:function(e){var r={method:"GET",path:"/1/dictionaries/*/settings",queryParameters:{},headers:{}};return c.request(r,e)},getLogs:function(e,r){var t=e.offset,a=e.length,n=e.indexName,i=e.type,o={};void 0!==t&&(o.offset=t.toString()),void 0!==a&&(o.length=a.toString()),void 0!==n&&(o.indexName=n.toString()),void 0!==i&&(o.type=i.toString());var s={method:"GET",path:"/1/logs",queryParameters:o,headers:{}};return c.request(s,r)},getObject:function(e,r){var t=e.indexName,a=e.objectID,n=e.attributesToRetrieve;if(!t)throw new Error("Parameter `indexName` is required when calling `getObject`.");if(!a)throw new Error("Parameter `objectID` is required when calling `getObject`.");var i="/1/indexes/{indexName}/{objectID}".replace("{indexName}",encodeURIComponent(t)).replace("{objectID}",encodeURIComponent(a)),o={};void 0!==n&&(o.attributesToRetrieve=n.toString());var s={method:"GET",path:i,queryParameters:o,headers:{}};return c.request(s,r)},getObjects:function(e,r){if(!e)throw new Error("Parameter `getObjectsParams` is required when calling `getObjects`.");if(!e.requests)throw new Error("Parameter `getObjectsParams.requests` is required when calling `getObjects`.");var t={method:"POST",path:"/1/indexes/*/objects",queryParameters:{},headers:{},data:e,useReadTransporter:!0,cacheable:!0};return c.request(t,r)},getRule:function(e,r){var t=e.indexName,a=e.objectID;if(!t)throw new Error("Parameter `indexName` is required when calling `getRule`.");if(!a)throw new Error("Parameter `objectID` is required when calling `getRule`.");var n={method:"GET",path:"/1/indexes/{indexName}/rules/{objectID}".replace("{indexName}",encodeURIComponent(t)).replace("{objectID}",encodeURIComponent(a)),queryParameters:{},headers:{}};return c.request(n,r)},getSettings:function(e,r){var t=e.indexName;if(!t)throw new Error("Parameter `indexName` is required when calling `getSettings`.");var a={method:"GET",path:"/1/indexes/{indexName}/settings".replace("{indexName}",encodeURIComponent(t)),queryParameters:{},headers:{}};return c.request(a,r)},getSources:function(e){var r={method:"GET",path:"/1/security/sources",queryParameters:{},headers:{}};return c.request(r,e)},getSynonym:function(e,r){var t=e.indexName,a=e.objectID;if(!t)throw new Error("Parameter `indexName` is required when calling `getSynonym`.");if(!a)throw new Error("Parameter `objectID` is required when calling `getSynonym`.");var n={method:"GET",path:"/1/indexes/{indexName}/synonyms/{objectID}".replace("{indexName}",encodeURIComponent(t)).replace("{objectID}",encodeURIComponent(a)),queryParameters:{},headers:{}};return c.request(n,r)},getTask:function(e,r){var t=e.indexName,a=e.taskID;if(!t)throw new Error("Parameter `indexName` is required when calling `getTask`.");if(!a)throw new Error("Parameter `taskID` is required when calling `getTask`.");var n={method:"GET",path:"/1/indexes/{indexName}/task/{taskID}".replace("{indexName}",encodeURIComponent(t)).replace("{taskID}",encodeURIComponent(a)),queryParameters:{},headers:{}};return c.request(n,r)},getTopUserIds:function(e){var r={method:"GET",path:"/1/clusters/mapping/top",queryParameters:{},headers:{}};return c.request(r,e)},getUserId:function(e,r){var t=e.userID;if(!t)throw new Error("Parameter `userID` is required when calling `getUserId`.");var a={method:"GET",path:"/1/clusters/mapping/{userID}".replace("{userID}",encodeURIComponent(t)),queryParameters:{},headers:{}};return c.request(a,r)},hasPendingMappings:function(e,r){var t=e.getClusters,a={};void 0!==t&&(a.getClusters=t.toString());var n={method:"GET",path:"/1/clusters/mapping/pending",queryParameters:a,headers:{}};return c.request(n,r)},listApiKeys:function(e){var r={method:"GET",path:"/1/keys",queryParameters:{},headers:{}};return c.request(r,e)},listClusters:function(e){var r={method:"GET",path:"/1/clusters",queryParameters:{},headers:{}};return c.request(r,e)},listIndices:function(e,r){var t=e.page,a={};void 0!==t&&(a.page=t.toString());var n={method:"GET",path:"/1/indexes",queryParameters:a,headers:{}};return c.request(n,r)},listUserIds:function(e,r){var t=e.page,a=e.hitsPerPage,n={};void 0!==t&&(n.page=t.toString()),void 0!==a&&(n.hitsPerPage=a.toString());var i={method:"GET",path:"/1/clusters/mapping",queryParameters:n,headers:{}};return c.request(i,r)},multipleBatch:function(e,r){if(!e)throw new Error("Parameter `batchParams` is required when calling `multipleBatch`.");if(!e.requests)throw new Error("Parameter `batchParams.requests` is required when calling `multipleBatch`.");var t={method:"POST",path:"/1/indexes/*/batch",queryParameters:{},headers:{},data:e};return c.request(t,r)},operationIndex:function(e,r){var t=e.indexName,a=e.operationIndexParams;if(!t)throw new Error("Parameter `indexName` is required when calling `operationIndex`.");if(!a)throw new Error("Parameter `operationIndexParams` is required when calling `operationIndex`.");if(!a.operation)throw new Error("Parameter `operationIndexParams.operation` is required when calling `operationIndex`.");if(!a.destination)throw new Error("Parameter `operationIndexParams.destination` is required when calling `operationIndex`.");var n={method:"POST",path:"/1/indexes/{indexName}/operation".replace("{indexName}",encodeURIComponent(t)),queryParameters:{},headers:{},data:a};return c.request(n,r)},partialUpdateObject:function(e,r){var t=e.indexName,a=e.objectID,n=e.attributeToUpdate,i=e.createIfNotExists;if(!t)throw new Error("Parameter `indexName` is required when calling `partialUpdateObject`.");if(!a)throw new Error("Parameter `objectID` is required when calling `partialUpdateObject`.");if(!n)throw new Error("Parameter `attributeToUpdate` is required when calling `partialUpdateObject`.");var o="/1/indexes/{indexName}/{objectID}/partial".replace("{indexName}",encodeURIComponent(t)).replace("{objectID}",encodeURIComponent(a)),s={};void 0!==i&&(s.createIfNotExists=i.toString());var u={method:"POST",path:o,queryParameters:s,headers:{},data:n};return c.request(u,r)},post:function(e,r){var t=e.path,a=e.parameters,n=e.body;if(!t)throw new Error("Parameter `path` is required when calling `post`.");var i={method:"POST",path:"/1{path}".replace("{path}",t),queryParameters:a||{},headers:{},data:n||{}};return c.request(i,r)},put:function(e,r){var t=e.path,a=e.parameters,n=e.body;if(!t)throw new Error("Parameter `path` is required when calling `put`.");var i={method:"PUT",path:"/1{path}".replace("{path}",t),queryParameters:a||{},headers:{},data:n||{}};return c.request(i,r)},removeUserId:function(e,r){var t=e.userID;if(!t)throw new Error("Parameter `userID` is required when calling `removeUserId`.");var a={method:"DELETE",path:"/1/clusters/mapping/{userID}".replace("{userID}",encodeURIComponent(t)),queryParameters:{},headers:{}};return c.request(a,r)},replaceSources:function(e,r){var t=e.source;if(!t)throw new Error("Parameter `source` is required when calling `replaceSources`.");var a={method:"PUT",path:"/1/security/sources",queryParameters:{},headers:{},data:t};return c.request(a,r)},restoreApiKey:function(e,r){var t=e.key;if(!t)throw new Error("Parameter `key` is required when calling `restoreApiKey`.");var a={method:"POST",path:"/1/keys/{key}/restore".replace("{key}",encodeURIComponent(t)),queryParameters:{},headers:{}};return c.request(a,r)},saveObject:function(e,r){var t=e.indexName,a=e.body;if(!t)throw new Error("Parameter `indexName` is required when calling `saveObject`.");if(!a)throw new Error("Parameter `body` is required when calling `saveObject`.");var n={method:"POST",path:"/1/indexes/{indexName}".replace("{indexName}",encodeURIComponent(t)),queryParameters:{},headers:{},data:a};return c.request(n,r)},saveRule:function(e,r){var t=e.indexName,a=e.objectID,n=e.rule,i=e.forwardToReplicas;if(!t)throw new Error("Parameter `indexName` is required when calling `saveRule`.");if(!a)throw new Error("Parameter `objectID` is required when calling `saveRule`.");if(!n)throw new Error("Parameter `rule` is required when calling `saveRule`.");if(!n.objectID)throw new Error("Parameter `rule.objectID` is required when calling `saveRule`.");var o="/1/indexes/{indexName}/rules/{objectID}".replace("{indexName}",encodeURIComponent(t)).replace("{objectID}",encodeURIComponent(a)),s={};void 0!==i&&(s.forwardToReplicas=i.toString());var u={method:"PUT",path:o,queryParameters:s,headers:{},data:n};return c.request(u,r)},saveRules:function(e,r){var t=e.indexName,a=e.rule,n=e.forwardToReplicas,i=e.clearExistingRules;if(!t)throw new Error("Parameter `indexName` is required when calling `saveRules`.");if(!a)throw new Error("Parameter `rule` is required when calling `saveRules`.");var o="/1/indexes/{indexName}/rules/batch".replace("{indexName}",encodeURIComponent(t)),s={};void 0!==n&&(s.forwardToReplicas=n.toString()),void 0!==i&&(s.clearExistingRules=i.toString());var u={method:"POST",path:o,queryParameters:s,headers:{},data:a};return c.request(u,r)},saveSynonym:function(e,r){var t=e.indexName,a=e.objectID,n=e.synonymHit,i=e.forwardToReplicas;if(!t)throw new Error("Parameter `indexName` is required when calling `saveSynonym`.");if(!a)throw new Error("Parameter `objectID` is required when calling `saveSynonym`.");if(!n)throw new Error("Parameter `synonymHit` is required when calling `saveSynonym`.");if(!n.objectID)throw new Error("Parameter `synonymHit.objectID` is required when calling `saveSynonym`.");var o="/1/indexes/{indexName}/synonyms/{objectID}".replace("{indexName}",encodeURIComponent(t)).replace("{objectID}",encodeURIComponent(a)),s={};void 0!==i&&(s.forwardToReplicas=i.toString());var u={method:"PUT",path:o,queryParameters:s,headers:{},data:n};return c.request(u,r)},saveSynonyms:function(e,r){var t=e.indexName,a=e.synonymHit,n=e.forwardToReplicas,i=e.replaceExistingSynonyms;if(!t)throw new Error("Parameter `indexName` is required when calling `saveSynonyms`.");if(!a)throw new Error("Parameter `synonymHit` is required when calling `saveSynonyms`.");var o="/1/indexes/{indexName}/synonyms/batch".replace("{indexName}",encodeURIComponent(t)),s={};void 0!==n&&(s.forwardToReplicas=n.toString()),void 0!==i&&(s.replaceExistingSynonyms=i.toString());var u={method:"POST",path:o,queryParameters:s,headers:{},data:a};return c.request(u,r)},search:function(e,r){if(e&&Array.isArray(e)){var t={requests:e.map((function(e){var r=e.params,t=P(e,E);return"facet"===t.type?N(N(N({},t),r),{},{type:"facet"}):N(N(N({},t),r),{},{facet:void 0,maxFacetHits:void 0,facetQuery:void 0})}))};e=t}if(!e)throw new Error("Parameter `searchMethodParams` is required when calling `search`.");if(!e.requests)throw new Error("Parameter `searchMethodParams.requests` is required when calling `search`.");var a={method:"POST",path:"/1/indexes/*/queries",queryParameters:{},headers:{},data:e,useReadTransporter:!0,cacheable:!0};return c.request(a,r)},searchDictionaryEntries:function(e,r){var t=e.dictionaryName,a=e.searchDictionaryEntriesParams;if(!t)throw new Error("Parameter `dictionaryName` is required when calling `searchDictionaryEntries`.");if(!a)throw new Error("Parameter `searchDictionaryEntriesParams` is required when calling `searchDictionaryEntries`.");if(!a.query)throw new Error("Parameter `searchDictionaryEntriesParams.query` is required when calling `searchDictionaryEntries`.");var n={method:"POST",path:"/1/dictionaries/{dictionaryName}/search".replace("{dictionaryName}",encodeURIComponent(t)),queryParameters:{},headers:{},data:a,useReadTransporter:!0,cacheable:!0};return c.request(n,r)},searchForFacetValues:function(e,r){var t=e.indexName,a=e.facetName,n=e.searchForFacetValuesRequest;if(!t)throw new Error("Parameter `indexName` is required when calling `searchForFacetValues`.");if(!a)throw new Error("Parameter `facetName` is required when calling `searchForFacetValues`.");var i={method:"POST",path:"/1/indexes/{indexName}/facets/{facetName}/query".replace("{indexName}",encodeURIComponent(t)).replace("{facetName}",encodeURIComponent(a)),queryParameters:{},headers:{},data:n||{},useReadTransporter:!0,cacheable:!0};return c.request(i,r)},searchRules:function(e,r){var t=e.indexName,a=e.searchRulesParams;if(!t)throw new Error("Parameter `indexName` is required when calling `searchRules`.");var n={method:"POST",path:"/1/indexes/{indexName}/rules/search".replace("{indexName}",encodeURIComponent(t)),queryParameters:{},headers:{},data:a||{},useReadTransporter:!0,cacheable:!0};return c.request(n,r)},searchSingleIndex:function(e,r){var t=e.indexName,a=e.searchParams;if(!t)throw new Error("Parameter `indexName` is required when calling `searchSingleIndex`.");var n={method:"POST",path:"/1/indexes/{indexName}/query".replace("{indexName}",encodeURIComponent(t)),queryParameters:{},headers:{},data:a||{},useReadTransporter:!0,cacheable:!0};return c.request(n,r)},searchSynonyms:function(e,r){var t=e.indexName,a=e.type,n=e.page,i=e.hitsPerPage,o=e.searchSynonymsParams;if(!t)throw new Error("Parameter `indexName` is required when calling `searchSynonyms`.");var s="/1/indexes/{indexName}/synonyms/search".replace("{indexName}",encodeURIComponent(t)),u={};void 0!==a&&(u.type=a.toString()),void 0!==n&&(u.page=n.toString()),void 0!==i&&(u.hitsPerPage=i.toString());var d={method:"POST",path:s,queryParameters:u,headers:{},data:o||{},useReadTransporter:!0,cacheable:!0};return c.request(d,r)},searchUserIds:function(e,r){if(!e)throw new Error("Parameter `searchUserIdsParams` is required when calling `searchUserIds`.");if(!e.query)throw new Error("Parameter `searchUserIdsParams.query` is required when calling `searchUserIds`.");var t={method:"POST",path:"/1/clusters/mapping/search",queryParameters:{},headers:{},data:e,useReadTransporter:!0,cacheable:!0};return c.request(t,r)},setDictionarySettings:function(e,r){if(!e)throw new Error("Parameter `dictionarySettingsParams` is required when calling `setDictionarySettings`.");if(!e.disableStandardEntries)throw new Error("Parameter `dictionarySettingsParams.disableStandardEntries` is required when calling `setDictionarySettings`.");var t={method:"PUT",path:"/1/dictionaries/*/settings",queryParameters:{},headers:{},data:e};return c.request(t,r)},setSettings:function(e,r){var t=e.indexName,a=e.indexSettings,n=e.forwardToReplicas;if(!t)throw new Error("Parameter `indexName` is required when calling `setSettings`.");if(!a)throw new Error("Parameter `indexSettings` is required when calling `setSettings`.");var i="/1/indexes/{indexName}/settings".replace("{indexName}",encodeURIComponent(t)),o={};void 0!==n&&(o.forwardToReplicas=n.toString());var s={method:"PUT",path:i,queryParameters:o,headers:{},data:a};return c.request(s,r)},updateApiKey:function(e,r){var t=e.key,a=e.apiKey;if(!t)throw new Error("Parameter `key` is required when calling `updateApiKey`.");if(!a)throw new Error("Parameter `apiKey` is required when calling `updateApiKey`.");if(!a.acl)throw new Error("Parameter `apiKey.acl` is required when calling `updateApiKey`.");var n={method:"PUT",path:"/1/keys/{key}".replace("{key}",encodeURIComponent(t)),queryParameters:{},headers:{},data:a};return c.request(n,r)}}}(function(e){for(var t=1;t<arguments.length;t++){var a=null!=arguments[t]?arguments[t]:{};t%2?T(Object(a),!0).forEach((function(t){r(e,t,a[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(a)):T(Object(a)).forEach((function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(a,r))}))}return e}({appId:e,apiKey:o,timeouts:{connect:1e3,read:2e3,write:3e4},requester:{send:function(e){return new Promise((r=>{const t=new XMLHttpRequest;t.open(e.method,e.url,!0),Object.keys(e.headers).forEach((r=>t.setRequestHeader(r,e.headers[r])));const a=(e,a)=>setTimeout((()=>{t.abort(),r({status:0,content:a,isTimedOut:!0})}),e),n=a(e.connectTimeout,"Connection timeout");let i;t.onreadystatechange=()=>{t.readyState>t.OPENED&&void 0===i&&(clearTimeout(n),i=a(e.responseTimeout,"Socket timeout"))},t.onerror=()=>{0===t.status&&(clearTimeout(n),clearTimeout(i),r({content:t.responseText||"Network request failed",status:t.status,isTimedOut:!1}))},t.onload=()=>{clearTimeout(n),clearTimeout(i),r({content:t.responseText,status:t.status,isTimedOut:!1})},t.send(e.data)}))}},algoliaAgents:[{segment:"Browser"}],authMode:"WithinQueryParameters",responsesCache:i(),requestsCache:i({serializable:!1}),hostsCache:n({caches:[a({key:"".concat(O,"-").concat(e)}),i()]})},s))}}));
|
|
1
|
+
/*! client-search.umd.js | 5.0.0-alpha.7 | © Algolia, inc. | https://github.com/algolia/algoliasearch-client-javascript */
|
|
2
|
+
!function(e,r){"object"==typeof exports&&"undefined"!=typeof module?r(exports):"function"==typeof define&&define.amd?define(["exports"],r):r((e="undefined"!=typeof globalThis?globalThis:e||self)["@algolia/client-search"]={})}(this,(function(e){"use strict";function r(e,r,t){return r in e?Object.defineProperty(e,r,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[r]=t,e}function t({func:e,validate:r,aggregator:t,error:a,timeout:n=(()=>0)}){const i=o=>new Promise(((s,c)=>{e(o).then((e=>(t&&t(e),r(e)?s(e):a&&a.validate(e)?c(new Error(a.message(e))):setTimeout((()=>{i(e).then(s).catch(c)}),n())))).catch((e=>{c(e)}))}));return i()}function a(e){let r;const t=`algolia-client-js-${e.key}`;function a(){return void 0===r&&(r=e.localStorage||window.localStorage),r}function n(){return JSON.parse(a().getItem(t)||"{}")}return{get:(e,r,t={miss:()=>Promise.resolve()})=>Promise.resolve().then((()=>{const t=JSON.stringify(e),a=n()[t];return Promise.all([a||r(),void 0!==a])})).then((([e,r])=>Promise.all([e,r||t.miss(e)]))).then((([e])=>e)),set:(e,r)=>Promise.resolve().then((()=>{const i=n();return i[JSON.stringify(e)]=r,a().setItem(t,JSON.stringify(i)),r})),delete:e=>Promise.resolve().then((()=>{const r=n();delete r[JSON.stringify(e)],a().setItem(t,JSON.stringify(r))})),clear:()=>Promise.resolve().then((()=>{a().removeItem(t)}))}}function n(e){const r=[...e.caches],t=r.shift();return void 0===t?{get:(e,r,t={miss:()=>Promise.resolve()})=>r().then((e=>Promise.all([e,t.miss(e)]))).then((([e])=>e)),set:(e,r)=>Promise.resolve(r),delete:e=>Promise.resolve(),clear:()=>Promise.resolve()}:{get:(e,a,i={miss:()=>Promise.resolve()})=>t.get(e,a,i).catch((()=>n({caches:r}).get(e,a,i))),set:(e,a)=>t.set(e,a).catch((()=>n({caches:r}).set(e,a))),delete:e=>t.delete(e).catch((()=>n({caches:r}).delete(e))),clear:()=>t.clear().catch((()=>n({caches:r}).clear()))}}function i(e={serializable:!0}){let r={};return{get(t,a,n={miss:()=>Promise.resolve()}){const i=JSON.stringify(t);if(i in r)return Promise.resolve(e.serializable?JSON.parse(r[i]):r[i]);const o=a();return o.then((e=>n.miss(e))).then((()=>o))},set:(t,a)=>(r[JSON.stringify(t)]=e.serializable?JSON.stringify(a):a,Promise.resolve(a)),delete:e=>(delete r[JSON.stringify(e)],Promise.resolve()),clear:()=>(r={},Promise.resolve())}}const o=12e4;function s(e,r="up"){const t=Date.now();return{...e,status:r,lastUpdate:t,isUp:function(){return"up"===r||Date.now()-t>o},isTimedOut:function(){return"timed out"===r&&Date.now()-t<=o}}}function c(e,r,t){return r in e?Object.defineProperty(e,r,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[r]=t,e}class u extends Error{constructor(e,r){super(e),c(this,"name","AlgoliaError"),r&&(this.name=r)}}class d extends u{constructor(e,r,t){super(e,t),c(this,"stackTrace",void 0),this.stackTrace=r}}class l extends d{constructor(e){super("Unreachable hosts - your application id may be incorrect. If the error persists, contact support@algolia.com.",e,"RetryError")}}class m extends d{constructor(e,r,t){super(e,t,"ApiError"),c(this,"status",void 0),this.status=r}}class h extends u{constructor(e,r){super(e,"DeserializationError"),c(this,"response",void 0),this.response=r}}function p(e,r,t){const a=function(e){const r=e=>"[object Object]"===Object.prototype.toString.call(e)||"[object Array]"===Object.prototype.toString.call(e);return Object.keys(e).map((t=>`${t}=${r(e[t])?JSON.stringify(e[t]):e[t]}`)).join("&")}(t);let n=`${e.protocol}://${e.url}/${"/"===r.charAt(0)?r.substr(1):r}`;return a.length&&(n+=`?${a}`),n}function f(e){const r=e.request.headers["x-algolia-api-key"]?{"x-algolia-api-key":"*****"}:{};return{...e,request:{...e.request,headers:{...e.request.headers,...r}}}}function g({hosts:e,hostsCache:r,baseHeaders:t,baseQueryParameters:a,algoliaAgent:n,timeouts:i,requester:o,requestsCache:c,responsesCache:u}){async function d(c,u,d=!0){const g=[],w=function(e,r){if("GET"===e.method||void 0===e.data&&void 0===r.data)return;const t=Array.isArray(e.data)?e.data:{...e.data,...r.data};return JSON.stringify(t)}(c,u),y=function(e,r,t){const a={Accept:"application/json",...e,...r,...t},n={};return Object.keys(a).forEach((e=>{const r=a[e];n[e.toLowerCase()]=r})),n}(t,c.headers,u.headers),P="GET"===c.method?{...c.data,...u.data}:{},v={"x-algolia-agent":n.value,...a,...c.queryParameters,...P};if(u&&u.queryParameters)for(const e of Object.keys(u.queryParameters))u.queryParameters[e]&&"[object Object]"!==Object.prototype.toString.call(u.queryParameters[e])?v[e]=u.queryParameters[e].toString():v[e]=u.queryParameters[e];let q=0;const b=async(e,t)=>{const a=e.pop();if(void 0===a)throw new l(function(e){return e.map((e=>f(e)))}(g));let n=u.timeout;void 0===n&&(n=d?i.read:i.write);const P={data:w,headers:y,method:c.method,url:p(a,c.path,v),connectTimeout:t(q,i.connect),responseTimeout:t(q,n)},x=r=>{const t={request:P,response:r,host:a,triesLeft:e.length};return g.push(t),t},E=await o.send(P);if(function({isTimedOut:e,status:r}){return e||function({isTimedOut:e,status:r}){return!e&&0==~~r}({isTimedOut:e,status:r})||2!=~~(r/100)&&4!=~~(r/100)}(E)){const n=x(E);return E.isTimedOut&&q++,console.log("Retryable failure",f(n)),await r.set(a,s(a,E.isTimedOut?"timed out":"down")),b(e,t)}if(function({status:e}){return 2==~~(e/100)}(E))return function(e){try{return JSON.parse(e.content)}catch(r){throw new h(r.message,e)}}(E);throw x(E),function({content:e,status:r},t){let a=e;try{a=JSON.parse(e).message}catch(e){}return new m(a,r,t)}(E,g)},x=e.filter((e=>"readWrite"===e.accept||(d?"read"===e.accept:"write"===e.accept))),E=await async function(e){const t=await Promise.all(e.map((e=>r.get(e,(()=>Promise.resolve(s(e))))))),a=t.filter((e=>e.isUp())),n=t.filter((e=>e.isTimedOut())),i=[...a,...n];return{hosts:i.length>0?i:e,getTimeout:(e,r)=>(0===n.length&&0===e?1:n.length+3+e)*r}}(x);return b([...E.hosts].reverse(),E.getTimeout)}return{hostsCache:r,requester:o,timeouts:i,algoliaAgent:n,baseHeaders:t,baseQueryParameters:a,hosts:e,request:function(e,r={}){const n=e.useReadTransporter||"GET"===e.method;if(!n)return d(e,r,n);const i=()=>d(e,r);if(!0!==(r.cacheable||e.cacheable))return i();const o={request:e,requestOptions:r,transporter:{queryParameters:a,headers:t}};return u.get(o,(()=>c.get(o,(()=>c.set(o,i()).then((e=>Promise.all([c.delete(o),e])),(e=>Promise.all([c.delete(o),Promise.reject(e)]))).then((([e,r])=>r))))),{miss:e=>u.set(o,e)})},requestsCache:c,responsesCache:u}}function w({algoliaAgents:e,client:r,version:t}){const a=function(e){const r={value:`Algolia for JavaScript (${e})`,add(e){const t=`; ${e.segment}${void 0!==e.version?` (${e.version})`:""}`;return-1===r.value.indexOf(t)&&(r.value=`${r.value}${t}`),r}};return r}(t).add({segment:r,version:t});return e.forEach((e=>a.add(e))),a}function y(e){return y="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},y(e)}function P(e,r){if(null==e)return{};var t,a,n=function(e,r){if(null==e)return{};var t,a,n={},i=Object.keys(e);for(a=0;a<i.length;a++)t=i[a],r.indexOf(t)>=0||(n[t]=e[t]);return n}(e,r);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(a=0;a<i.length;a++)t=i[a],r.indexOf(t)>=0||Object.prototype.propertyIsEnumerable.call(e,t)&&(n[t]=e[t])}return n}var v=["appId","apiKey","authMode","algoliaAgents"],q=["indexName","browseParams"],b=["indexName","searchRulesParams"],x=["indexName","validate","aggregator"],E=["params"];function I(e,r){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);r&&(a=a.filter((function(r){return Object.getOwnPropertyDescriptor(e,r).enumerable}))),t.push.apply(t,a)}return t}function N(e){for(var t=1;t<arguments.length;t++){var a=null!=arguments[t]?arguments[t]:{};t%2?I(Object(a),!0).forEach((function(t){r(e,t,a[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(a)):I(Object(a)).forEach((function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(a,r))}))}return e}var O="5.0.0-alpha.7";function S(e){return[{url:"".concat(e,"-dsn.algolia.net"),accept:"read",protocol:"https"},{url:"".concat(e,".algolia.net"),accept:"write",protocol:"https"}].concat(function(e){const r=e;for(let t=e.length-1;t>0;t--){const a=Math.floor(Math.random()*(t+1)),n=e[t];r[t]=e[a],r[a]=n}return r}([{url:"".concat(e,"-1.algolianet.com"),accept:"readWrite",protocol:"https"},{url:"".concat(e,"-2.algolianet.com"),accept:"readWrite",protocol:"https"},{url:"".concat(e,"-3.algolianet.com"),accept:"readWrite",protocol:"https"}]))}function T(e,r){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);r&&(a=a.filter((function(r){return Object.getOwnPropertyDescriptor(e,r).enumerable}))),t.push.apply(t,a)}return t}e.apiClientVersion=O,e.searchClient=function(e,o,s){if(!e||"string"!=typeof e)throw new Error("`appId` is missing.");if(!o||"string"!=typeof o)throw new Error("`apiKey` is missing.");return function(e){var r=e.appId,a=e.apiKey,n=e.authMode,i=e.algoliaAgents,o=P(e,v),s=function(e,r,t="WithinHeaders"){const a={"x-algolia-api-key":r,"x-algolia-application-id":e};return{headers:()=>"WithinHeaders"===t?a:{},queryParameters:()=>"WithinQueryParameters"===t?a:{}}}(r,a,n),c=g(N(N({hosts:S(r)},o),{},{algoliaAgent:w({algoliaAgents:i,client:"Search",version:O}),baseHeaders:N(N({"content-type":"text/plain"},s.headers()),o.baseHeaders),baseQueryParameters:N(N({},s.queryParameters()),o.baseQueryParameters)}));return{transporter:c,appId:r,clearCache:function(){return Promise.all([c.requestsCache.clear(),c.responsesCache.clear()]).then((function(){}))},get _ua(){return c.algoliaAgent.value},addAlgoliaAgent:function(e,r){c.algoliaAgent.add({segment:e,version:r})},waitForTask:function(e,r){var a=this,n=e.indexName,i=e.taskID,o=e.maxRetries,s=void 0===o?50:o,c=e.timeout,u=void 0===c?function(e){return Math.min(200*e,5e3)}:c,d=0;return t({func:function(){return a.getTask({indexName:n,taskID:i},r)},validate:function(e){return"published"===e.status},aggregator:function(){return d+=1},error:{validate:function(){return d>=s},message:function(){return"The maximum number of retries exceeded. (".concat(d,"/").concat(s,")")}},timeout:function(){return u(d)}})},waitForApiKey:function(e,r){var a=this,n=e.operation,i=e.key,o=e.apiKey,s=e.maxRetries,c=void 0===s?50:s,u=e.timeout,d=void 0===u?function(e){return Math.min(200*e,5e3)}:u,l=0,m={aggregator:function(){return l+=1},error:{validate:function(){return l>=c},message:function(){return"The maximum number of retries exceeded. (".concat(l,"/").concat(c,")")}},timeout:function(){return d(l)}};if("update"===n){if(!o)throw new Error("`apiKey` is required when waiting for an `update` operation.");return t(N(N({},m),{},{func:function(){return a.getApiKey({key:i},r)},validate:function(e){for(var r=function(){var r=a[t];if(Array.isArray(o[r])){if(o[r].length!==e[r].length||o[r].some((function(t,a){return t!==e[r][a]})))return{v:!1}}else if(e[r]!==o[r])return{v:!1}},t=0,a=Object.keys(o);t<a.length;t++){var n=r();if("object"===y(n))return n.v}return!0}}))}return t(N(N({},m),{},{func:function(){return a.getApiKey({key:i},r).catch((function(e){return e}))},validate:function(e){return"add"===n?404!==e.status:404===e.status}}))},browseObjects:function(e,r){var a=this,n=e.indexName,i=e.browseParams;return t(N({func:function(e){return a.browse({indexName:n,browseParams:N({cursor:e?e.cursor:void 0},i)},r)},validate:function(e){return void 0===e.cursor}},P(e,q)))},browseRules:function(e,r){var a=this,n=e.indexName,i=e.searchRulesParams,o=P(e,b),s=N({hitsPerPage:1e3},i);return t(N({func:function(e){return a.searchRules({indexName:n,searchRulesParams:N(N({},s),{},{page:e?e.page+1:s.page||0})},r)},validate:function(e){return e.nbHits<s.hitsPerPage}},o))},browseSynonyms:function(e,r){var a=this,n=e.indexName;e.validate,e.aggregator;var i=P(e,x),o=N({hitsPerPage:1e3},i);return t(N({func:function(e){return a.searchSynonyms(N(N({},o),{},{indexName:n,page:e?e.page+1:i.page||0}),r)},validate:function(e){return e.nbHits<o.hitsPerPage}},i))},addApiKey:function(e,r){if(!e)throw new Error("Parameter `apiKey` is required when calling `addApiKey`.");if(!e.acl)throw new Error("Parameter `apiKey.acl` is required when calling `addApiKey`.");var t={method:"POST",path:"/1/keys",queryParameters:{},headers:{},data:e};return c.request(t,r)},addOrUpdateObject:function(e,r){var t=e.indexName,a=e.objectID,n=e.body;if(!t)throw new Error("Parameter `indexName` is required when calling `addOrUpdateObject`.");if(!a)throw new Error("Parameter `objectID` is required when calling `addOrUpdateObject`.");if(!n)throw new Error("Parameter `body` is required when calling `addOrUpdateObject`.");var i={method:"PUT",path:"/1/indexes/{indexName}/{objectID}".replace("{indexName}",encodeURIComponent(t)).replace("{objectID}",encodeURIComponent(a)),queryParameters:{},headers:{},data:n};return c.request(i,r)},appendSource:function(e,r){if(!e)throw new Error("Parameter `source` is required when calling `appendSource`.");var t={method:"POST",path:"/1/security/sources/append",queryParameters:{},headers:{},data:e};return c.request(t,r)},assignUserId:function(e,r){var t=e.xAlgoliaUserID,a=e.assignUserIdParams;if(!t)throw new Error("Parameter `xAlgoliaUserID` is required when calling `assignUserId`.");if(!a)throw new Error("Parameter `assignUserIdParams` is required when calling `assignUserId`.");if(!a.cluster)throw new Error("Parameter `assignUserIdParams.cluster` is required when calling `assignUserId`.");var n={};void 0!==t&&(n["X-Algolia-User-ID"]=t.toString());var i={method:"POST",path:"/1/clusters/mapping",queryParameters:{},headers:n,data:a};return c.request(i,r)},batch:function(e,r){var t=e.indexName,a=e.batchWriteParams;if(!t)throw new Error("Parameter `indexName` is required when calling `batch`.");if(!a)throw new Error("Parameter `batchWriteParams` is required when calling `batch`.");var n={method:"POST",path:"/1/indexes/{indexName}/batch".replace("{indexName}",encodeURIComponent(t)),queryParameters:{},headers:{},data:a};return c.request(n,r)},batchAssignUserIds:function(e,r){var t=e.xAlgoliaUserID,a=e.batchAssignUserIdsParams;if(!t)throw new Error("Parameter `xAlgoliaUserID` is required when calling `batchAssignUserIds`.");if(!a)throw new Error("Parameter `batchAssignUserIdsParams` is required when calling `batchAssignUserIds`.");if(!a.cluster)throw new Error("Parameter `batchAssignUserIdsParams.cluster` is required when calling `batchAssignUserIds`.");if(!a.users)throw new Error("Parameter `batchAssignUserIdsParams.users` is required when calling `batchAssignUserIds`.");var n={};void 0!==t&&(n["X-Algolia-User-ID"]=t.toString());var i={method:"POST",path:"/1/clusters/mapping/batch",queryParameters:{},headers:n,data:a};return c.request(i,r)},batchDictionaryEntries:function(e,r){var t=e.dictionaryName,a=e.batchDictionaryEntriesParams;if(!t)throw new Error("Parameter `dictionaryName` is required when calling `batchDictionaryEntries`.");if(!a)throw new Error("Parameter `batchDictionaryEntriesParams` is required when calling `batchDictionaryEntries`.");if(!a.requests)throw new Error("Parameter `batchDictionaryEntriesParams.requests` is required when calling `batchDictionaryEntries`.");var n={method:"POST",path:"/1/dictionaries/{dictionaryName}/batch".replace("{dictionaryName}",encodeURIComponent(t)),queryParameters:{},headers:{},data:a};return c.request(n,r)},browse:function(e,r){var t=e.indexName,a=e.browseParams;if(!t)throw new Error("Parameter `indexName` is required when calling `browse`.");var n={method:"POST",path:"/1/indexes/{indexName}/browse".replace("{indexName}",encodeURIComponent(t)),queryParameters:{},headers:{},data:a||{}};return c.request(n,r)},clearAllSynonyms:function(e,r){var t=e.indexName,a=e.forwardToReplicas;if(!t)throw new Error("Parameter `indexName` is required when calling `clearAllSynonyms`.");var n="/1/indexes/{indexName}/synonyms/clear".replace("{indexName}",encodeURIComponent(t)),i={};void 0!==a&&(i.forwardToReplicas=a.toString());var o={method:"POST",path:n,queryParameters:i,headers:{}};return c.request(o,r)},clearObjects:function(e,r){var t=e.indexName;if(!t)throw new Error("Parameter `indexName` is required when calling `clearObjects`.");var a={method:"POST",path:"/1/indexes/{indexName}/clear".replace("{indexName}",encodeURIComponent(t)),queryParameters:{},headers:{}};return c.request(a,r)},clearRules:function(e,r){var t=e.indexName,a=e.forwardToReplicas;if(!t)throw new Error("Parameter `indexName` is required when calling `clearRules`.");var n="/1/indexes/{indexName}/rules/clear".replace("{indexName}",encodeURIComponent(t)),i={};void 0!==a&&(i.forwardToReplicas=a.toString());var o={method:"POST",path:n,queryParameters:i,headers:{}};return c.request(o,r)},del:function(e,r){var t=e.path,a=e.parameters;if(!t)throw new Error("Parameter `path` is required when calling `del`.");var n={method:"DELETE",path:"/1{path}".replace("{path}",t),queryParameters:a||{},headers:{}};return c.request(n,r)},deleteApiKey:function(e,r){var t=e.key;if(!t)throw new Error("Parameter `key` is required when calling `deleteApiKey`.");var a={method:"DELETE",path:"/1/keys/{key}".replace("{key}",encodeURIComponent(t)),queryParameters:{},headers:{}};return c.request(a,r)},deleteBy:function(e,r){var t=e.indexName,a=e.searchParams;if(!t)throw new Error("Parameter `indexName` is required when calling `deleteBy`.");if(!a)throw new Error("Parameter `searchParams` is required when calling `deleteBy`.");var n={method:"POST",path:"/1/indexes/{indexName}/deleteByQuery".replace("{indexName}",encodeURIComponent(t)),queryParameters:{},headers:{},data:a};return c.request(n,r)},deleteIndex:function(e,r){var t=e.indexName;if(!t)throw new Error("Parameter `indexName` is required when calling `deleteIndex`.");var a={method:"DELETE",path:"/1/indexes/{indexName}".replace("{indexName}",encodeURIComponent(t)),queryParameters:{},headers:{}};return c.request(a,r)},deleteObject:function(e,r){var t=e.indexName,a=e.objectID;if(!t)throw new Error("Parameter `indexName` is required when calling `deleteObject`.");if(!a)throw new Error("Parameter `objectID` is required when calling `deleteObject`.");var n={method:"DELETE",path:"/1/indexes/{indexName}/{objectID}".replace("{indexName}",encodeURIComponent(t)).replace("{objectID}",encodeURIComponent(a)),queryParameters:{},headers:{}};return c.request(n,r)},deleteRule:function(e,r){var t=e.indexName,a=e.objectID,n=e.forwardToReplicas;if(!t)throw new Error("Parameter `indexName` is required when calling `deleteRule`.");if(!a)throw new Error("Parameter `objectID` is required when calling `deleteRule`.");var i="/1/indexes/{indexName}/rules/{objectID}".replace("{indexName}",encodeURIComponent(t)).replace("{objectID}",encodeURIComponent(a)),o={};void 0!==n&&(o.forwardToReplicas=n.toString());var s={method:"DELETE",path:i,queryParameters:o,headers:{}};return c.request(s,r)},deleteSource:function(e,r){var t=e.source;if(!t)throw new Error("Parameter `source` is required when calling `deleteSource`.");var a={method:"DELETE",path:"/1/security/sources/{source}".replace("{source}",encodeURIComponent(t)),queryParameters:{},headers:{}};return c.request(a,r)},deleteSynonym:function(e,r){var t=e.indexName,a=e.objectID,n=e.forwardToReplicas;if(!t)throw new Error("Parameter `indexName` is required when calling `deleteSynonym`.");if(!a)throw new Error("Parameter `objectID` is required when calling `deleteSynonym`.");var i="/1/indexes/{indexName}/synonyms/{objectID}".replace("{indexName}",encodeURIComponent(t)).replace("{objectID}",encodeURIComponent(a)),o={};void 0!==n&&(o.forwardToReplicas=n.toString());var s={method:"DELETE",path:i,queryParameters:o,headers:{}};return c.request(s,r)},get:function(e,r){var t=e.path,a=e.parameters;if(!t)throw new Error("Parameter `path` is required when calling `get`.");var n={method:"GET",path:"/1{path}".replace("{path}",t),queryParameters:a||{},headers:{}};return c.request(n,r)},getApiKey:function(e,r){var t=e.key;if(!t)throw new Error("Parameter `key` is required when calling `getApiKey`.");var a={method:"GET",path:"/1/keys/{key}".replace("{key}",encodeURIComponent(t)),queryParameters:{},headers:{}};return c.request(a,r)},getDictionaryLanguages:function(e){var r={method:"GET",path:"/1/dictionaries/*/languages",queryParameters:{},headers:{}};return c.request(r,e)},getDictionarySettings:function(e){var r={method:"GET",path:"/1/dictionaries/*/settings",queryParameters:{},headers:{}};return c.request(r,e)},getLogs:function(e,r){var t=e.offset,a=e.length,n=e.indexName,i=e.type,o={};void 0!==t&&(o.offset=t.toString()),void 0!==a&&(o.length=a.toString()),void 0!==n&&(o.indexName=n.toString()),void 0!==i&&(o.type=i.toString());var s={method:"GET",path:"/1/logs",queryParameters:o,headers:{}};return c.request(s,r)},getObject:function(e,r){var t=e.indexName,a=e.objectID,n=e.attributesToRetrieve;if(!t)throw new Error("Parameter `indexName` is required when calling `getObject`.");if(!a)throw new Error("Parameter `objectID` is required when calling `getObject`.");var i="/1/indexes/{indexName}/{objectID}".replace("{indexName}",encodeURIComponent(t)).replace("{objectID}",encodeURIComponent(a)),o={};void 0!==n&&(o.attributesToRetrieve=n.toString());var s={method:"GET",path:i,queryParameters:o,headers:{}};return c.request(s,r)},getObjects:function(e,r){if(!e)throw new Error("Parameter `getObjectsParams` is required when calling `getObjects`.");if(!e.requests)throw new Error("Parameter `getObjectsParams.requests` is required when calling `getObjects`.");var t={method:"POST",path:"/1/indexes/*/objects",queryParameters:{},headers:{},data:e,useReadTransporter:!0,cacheable:!0};return c.request(t,r)},getRule:function(e,r){var t=e.indexName,a=e.objectID;if(!t)throw new Error("Parameter `indexName` is required when calling `getRule`.");if(!a)throw new Error("Parameter `objectID` is required when calling `getRule`.");var n={method:"GET",path:"/1/indexes/{indexName}/rules/{objectID}".replace("{indexName}",encodeURIComponent(t)).replace("{objectID}",encodeURIComponent(a)),queryParameters:{},headers:{}};return c.request(n,r)},getSettings:function(e,r){var t=e.indexName;if(!t)throw new Error("Parameter `indexName` is required when calling `getSettings`.");var a={method:"GET",path:"/1/indexes/{indexName}/settings".replace("{indexName}",encodeURIComponent(t)),queryParameters:{},headers:{}};return c.request(a,r)},getSources:function(e){var r={method:"GET",path:"/1/security/sources",queryParameters:{},headers:{}};return c.request(r,e)},getSynonym:function(e,r){var t=e.indexName,a=e.objectID;if(!t)throw new Error("Parameter `indexName` is required when calling `getSynonym`.");if(!a)throw new Error("Parameter `objectID` is required when calling `getSynonym`.");var n={method:"GET",path:"/1/indexes/{indexName}/synonyms/{objectID}".replace("{indexName}",encodeURIComponent(t)).replace("{objectID}",encodeURIComponent(a)),queryParameters:{},headers:{}};return c.request(n,r)},getTask:function(e,r){var t=e.indexName,a=e.taskID;if(!t)throw new Error("Parameter `indexName` is required when calling `getTask`.");if(!a)throw new Error("Parameter `taskID` is required when calling `getTask`.");var n={method:"GET",path:"/1/indexes/{indexName}/task/{taskID}".replace("{indexName}",encodeURIComponent(t)).replace("{taskID}",encodeURIComponent(a)),queryParameters:{},headers:{}};return c.request(n,r)},getTopUserIds:function(e){var r={method:"GET",path:"/1/clusters/mapping/top",queryParameters:{},headers:{}};return c.request(r,e)},getUserId:function(e,r){var t=e.userID;if(!t)throw new Error("Parameter `userID` is required when calling `getUserId`.");var a={method:"GET",path:"/1/clusters/mapping/{userID}".replace("{userID}",encodeURIComponent(t)),queryParameters:{},headers:{}};return c.request(a,r)},hasPendingMappings:function(e,r){var t=e.getClusters,a={};void 0!==t&&(a.getClusters=t.toString());var n={method:"GET",path:"/1/clusters/mapping/pending",queryParameters:a,headers:{}};return c.request(n,r)},listApiKeys:function(e){var r={method:"GET",path:"/1/keys",queryParameters:{},headers:{}};return c.request(r,e)},listClusters:function(e){var r={method:"GET",path:"/1/clusters",queryParameters:{},headers:{}};return c.request(r,e)},listIndices:function(e,r){var t=e.page,a={};void 0!==t&&(a.page=t.toString());var n={method:"GET",path:"/1/indexes",queryParameters:a,headers:{}};return c.request(n,r)},listUserIds:function(e,r){var t=e.page,a=e.hitsPerPage,n={};void 0!==t&&(n.page=t.toString()),void 0!==a&&(n.hitsPerPage=a.toString());var i={method:"GET",path:"/1/clusters/mapping",queryParameters:n,headers:{}};return c.request(i,r)},multipleBatch:function(e,r){if(!e)throw new Error("Parameter `batchParams` is required when calling `multipleBatch`.");if(!e.requests)throw new Error("Parameter `batchParams.requests` is required when calling `multipleBatch`.");var t={method:"POST",path:"/1/indexes/*/batch",queryParameters:{},headers:{},data:e};return c.request(t,r)},operationIndex:function(e,r){var t=e.indexName,a=e.operationIndexParams;if(!t)throw new Error("Parameter `indexName` is required when calling `operationIndex`.");if(!a)throw new Error("Parameter `operationIndexParams` is required when calling `operationIndex`.");if(!a.operation)throw new Error("Parameter `operationIndexParams.operation` is required when calling `operationIndex`.");if(!a.destination)throw new Error("Parameter `operationIndexParams.destination` is required when calling `operationIndex`.");var n={method:"POST",path:"/1/indexes/{indexName}/operation".replace("{indexName}",encodeURIComponent(t)),queryParameters:{},headers:{},data:a};return c.request(n,r)},partialUpdateObject:function(e,r){var t=e.indexName,a=e.objectID,n=e.attributesToUpdate,i=e.createIfNotExists;if(!t)throw new Error("Parameter `indexName` is required when calling `partialUpdateObject`.");if(!a)throw new Error("Parameter `objectID` is required when calling `partialUpdateObject`.");if(!n)throw new Error("Parameter `attributesToUpdate` is required when calling `partialUpdateObject`.");var o="/1/indexes/{indexName}/{objectID}/partial".replace("{indexName}",encodeURIComponent(t)).replace("{objectID}",encodeURIComponent(a)),s={};void 0!==i&&(s.createIfNotExists=i.toString());var u={method:"POST",path:o,queryParameters:s,headers:{},data:n};return c.request(u,r)},post:function(e,r){var t=e.path,a=e.parameters,n=e.body;if(!t)throw new Error("Parameter `path` is required when calling `post`.");var i={method:"POST",path:"/1{path}".replace("{path}",t),queryParameters:a||{},headers:{},data:n||{}};return c.request(i,r)},put:function(e,r){var t=e.path,a=e.parameters,n=e.body;if(!t)throw new Error("Parameter `path` is required when calling `put`.");var i={method:"PUT",path:"/1{path}".replace("{path}",t),queryParameters:a||{},headers:{},data:n||{}};return c.request(i,r)},removeUserId:function(e,r){var t=e.userID;if(!t)throw new Error("Parameter `userID` is required when calling `removeUserId`.");var a={method:"DELETE",path:"/1/clusters/mapping/{userID}".replace("{userID}",encodeURIComponent(t)),queryParameters:{},headers:{}};return c.request(a,r)},replaceSources:function(e,r){var t=e.source;if(!t)throw new Error("Parameter `source` is required when calling `replaceSources`.");var a={method:"PUT",path:"/1/security/sources",queryParameters:{},headers:{},data:t};return c.request(a,r)},restoreApiKey:function(e,r){var t=e.key;if(!t)throw new Error("Parameter `key` is required when calling `restoreApiKey`.");var a={method:"POST",path:"/1/keys/{key}/restore".replace("{key}",encodeURIComponent(t)),queryParameters:{},headers:{}};return c.request(a,r)},saveObject:function(e,r){var t=e.indexName,a=e.body;if(!t)throw new Error("Parameter `indexName` is required when calling `saveObject`.");if(!a)throw new Error("Parameter `body` is required when calling `saveObject`.");var n={method:"POST",path:"/1/indexes/{indexName}".replace("{indexName}",encodeURIComponent(t)),queryParameters:{},headers:{},data:a};return c.request(n,r)},saveRule:function(e,r){var t=e.indexName,a=e.objectID,n=e.rule,i=e.forwardToReplicas;if(!t)throw new Error("Parameter `indexName` is required when calling `saveRule`.");if(!a)throw new Error("Parameter `objectID` is required when calling `saveRule`.");if(!n)throw new Error("Parameter `rule` is required when calling `saveRule`.");if(!n.objectID)throw new Error("Parameter `rule.objectID` is required when calling `saveRule`.");var o="/1/indexes/{indexName}/rules/{objectID}".replace("{indexName}",encodeURIComponent(t)).replace("{objectID}",encodeURIComponent(a)),s={};void 0!==i&&(s.forwardToReplicas=i.toString());var u={method:"PUT",path:o,queryParameters:s,headers:{},data:n};return c.request(u,r)},saveRules:function(e,r){var t=e.indexName,a=e.rules,n=e.forwardToReplicas,i=e.clearExistingRules;if(!t)throw new Error("Parameter `indexName` is required when calling `saveRules`.");if(!a)throw new Error("Parameter `rules` is required when calling `saveRules`.");var o="/1/indexes/{indexName}/rules/batch".replace("{indexName}",encodeURIComponent(t)),s={};void 0!==n&&(s.forwardToReplicas=n.toString()),void 0!==i&&(s.clearExistingRules=i.toString());var u={method:"POST",path:o,queryParameters:s,headers:{},data:a};return c.request(u,r)},saveSynonym:function(e,r){var t=e.indexName,a=e.objectID,n=e.synonymHit,i=e.forwardToReplicas;if(!t)throw new Error("Parameter `indexName` is required when calling `saveSynonym`.");if(!a)throw new Error("Parameter `objectID` is required when calling `saveSynonym`.");if(!n)throw new Error("Parameter `synonymHit` is required when calling `saveSynonym`.");if(!n.objectID)throw new Error("Parameter `synonymHit.objectID` is required when calling `saveSynonym`.");var o="/1/indexes/{indexName}/synonyms/{objectID}".replace("{indexName}",encodeURIComponent(t)).replace("{objectID}",encodeURIComponent(a)),s={};void 0!==i&&(s.forwardToReplicas=i.toString());var u={method:"PUT",path:o,queryParameters:s,headers:{},data:n};return c.request(u,r)},saveSynonyms:function(e,r){var t=e.indexName,a=e.synonymHit,n=e.forwardToReplicas,i=e.replaceExistingSynonyms;if(!t)throw new Error("Parameter `indexName` is required when calling `saveSynonyms`.");if(!a)throw new Error("Parameter `synonymHit` is required when calling `saveSynonyms`.");var o="/1/indexes/{indexName}/synonyms/batch".replace("{indexName}",encodeURIComponent(t)),s={};void 0!==n&&(s.forwardToReplicas=n.toString()),void 0!==i&&(s.replaceExistingSynonyms=i.toString());var u={method:"POST",path:o,queryParameters:s,headers:{},data:a};return c.request(u,r)},search:function(e,r){if(e&&Array.isArray(e)){var t={requests:e.map((function(e){var r=e.params,t=P(e,E);return"facet"===t.type?N(N(N({},t),r),{},{type:"facet"}):N(N(N({},t),r),{},{facet:void 0,maxFacetHits:void 0,facetQuery:void 0})}))};e=t}if(!e)throw new Error("Parameter `searchMethodParams` is required when calling `search`.");if(!e.requests)throw new Error("Parameter `searchMethodParams.requests` is required when calling `search`.");var a={method:"POST",path:"/1/indexes/*/queries",queryParameters:{},headers:{},data:e,useReadTransporter:!0,cacheable:!0};return c.request(a,r)},searchDictionaryEntries:function(e,r){var t=e.dictionaryName,a=e.searchDictionaryEntriesParams;if(!t)throw new Error("Parameter `dictionaryName` is required when calling `searchDictionaryEntries`.");if(!a)throw new Error("Parameter `searchDictionaryEntriesParams` is required when calling `searchDictionaryEntries`.");if(!a.query)throw new Error("Parameter `searchDictionaryEntriesParams.query` is required when calling `searchDictionaryEntries`.");var n={method:"POST",path:"/1/dictionaries/{dictionaryName}/search".replace("{dictionaryName}",encodeURIComponent(t)),queryParameters:{},headers:{},data:a,useReadTransporter:!0,cacheable:!0};return c.request(n,r)},searchForFacetValues:function(e,r){var t=e.indexName,a=e.facetName,n=e.searchForFacetValuesRequest;if(!t)throw new Error("Parameter `indexName` is required when calling `searchForFacetValues`.");if(!a)throw new Error("Parameter `facetName` is required when calling `searchForFacetValues`.");var i={method:"POST",path:"/1/indexes/{indexName}/facets/{facetName}/query".replace("{indexName}",encodeURIComponent(t)).replace("{facetName}",encodeURIComponent(a)),queryParameters:{},headers:{},data:n||{},useReadTransporter:!0,cacheable:!0};return c.request(i,r)},searchRules:function(e,r){var t=e.indexName,a=e.searchRulesParams;if(!t)throw new Error("Parameter `indexName` is required when calling `searchRules`.");var n={method:"POST",path:"/1/indexes/{indexName}/rules/search".replace("{indexName}",encodeURIComponent(t)),queryParameters:{},headers:{},data:a||{},useReadTransporter:!0,cacheable:!0};return c.request(n,r)},searchSingleIndex:function(e,r){var t=e.indexName,a=e.searchParams;if(!t)throw new Error("Parameter `indexName` is required when calling `searchSingleIndex`.");var n={method:"POST",path:"/1/indexes/{indexName}/query".replace("{indexName}",encodeURIComponent(t)),queryParameters:{},headers:{},data:a||{},useReadTransporter:!0,cacheable:!0};return c.request(n,r)},searchSynonyms:function(e,r){var t=e.indexName,a=e.type,n=e.page,i=e.hitsPerPage,o=e.searchSynonymsParams;if(!t)throw new Error("Parameter `indexName` is required when calling `searchSynonyms`.");var s="/1/indexes/{indexName}/synonyms/search".replace("{indexName}",encodeURIComponent(t)),u={};void 0!==a&&(u.type=a.toString()),void 0!==n&&(u.page=n.toString()),void 0!==i&&(u.hitsPerPage=i.toString());var d={method:"POST",path:s,queryParameters:u,headers:{},data:o||{},useReadTransporter:!0,cacheable:!0};return c.request(d,r)},searchUserIds:function(e,r){if(!e)throw new Error("Parameter `searchUserIdsParams` is required when calling `searchUserIds`.");if(!e.query)throw new Error("Parameter `searchUserIdsParams.query` is required when calling `searchUserIds`.");var t={method:"POST",path:"/1/clusters/mapping/search",queryParameters:{},headers:{},data:e,useReadTransporter:!0,cacheable:!0};return c.request(t,r)},setDictionarySettings:function(e,r){if(!e)throw new Error("Parameter `dictionarySettingsParams` is required when calling `setDictionarySettings`.");if(!e.disableStandardEntries)throw new Error("Parameter `dictionarySettingsParams.disableStandardEntries` is required when calling `setDictionarySettings`.");var t={method:"PUT",path:"/1/dictionaries/*/settings",queryParameters:{},headers:{},data:e};return c.request(t,r)},setSettings:function(e,r){var t=e.indexName,a=e.indexSettings,n=e.forwardToReplicas;if(!t)throw new Error("Parameter `indexName` is required when calling `setSettings`.");if(!a)throw new Error("Parameter `indexSettings` is required when calling `setSettings`.");var i="/1/indexes/{indexName}/settings".replace("{indexName}",encodeURIComponent(t)),o={};void 0!==n&&(o.forwardToReplicas=n.toString());var s={method:"PUT",path:i,queryParameters:o,headers:{},data:a};return c.request(s,r)},updateApiKey:function(e,r){var t=e.key,a=e.apiKey;if(!t)throw new Error("Parameter `key` is required when calling `updateApiKey`.");if(!a)throw new Error("Parameter `apiKey` is required when calling `updateApiKey`.");if(!a.acl)throw new Error("Parameter `apiKey.acl` is required when calling `updateApiKey`.");var n={method:"PUT",path:"/1/keys/{key}".replace("{key}",encodeURIComponent(t)),queryParameters:{},headers:{},data:a};return c.request(n,r)}}}(function(e){for(var t=1;t<arguments.length;t++){var a=null!=arguments[t]?arguments[t]:{};t%2?T(Object(a),!0).forEach((function(t){r(e,t,a[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(a)):T(Object(a)).forEach((function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(a,r))}))}return e}({appId:e,apiKey:o,timeouts:{connect:1e3,read:2e3,write:3e4},requester:{send:function(e){return new Promise((r=>{const t=new XMLHttpRequest;t.open(e.method,e.url,!0),Object.keys(e.headers).forEach((r=>t.setRequestHeader(r,e.headers[r])));const a=(e,a)=>setTimeout((()=>{t.abort(),r({status:0,content:a,isTimedOut:!0})}),e),n=a(e.connectTimeout,"Connection timeout");let i;t.onreadystatechange=()=>{t.readyState>t.OPENED&&void 0===i&&(clearTimeout(n),i=a(e.responseTimeout,"Socket timeout"))},t.onerror=()=>{0===t.status&&(clearTimeout(n),clearTimeout(i),r({content:t.responseText||"Network request failed",status:t.status,isTimedOut:!1}))},t.onload=()=>{clearTimeout(n),clearTimeout(i),r({content:t.responseText,status:t.status,isTimedOut:!1})},t.send(e.data)}))}},algoliaAgents:[{segment:"Browser"}],authMode:"WithinQueryParameters",responsesCache:i(),requestsCache:i({serializable:!1}),hostsCache:n({caches:[a({key:"".concat(O,"-").concat(e)}),i()]})},s))}}));
|
|
@@ -28,7 +28,7 @@ export declare type BaseSearchResponse = {
|
|
|
28
28
|
/**
|
|
29
29
|
* Indicate if the typo-tolerance search was exhaustive or approximate (only included when typo-tolerance is enabled).
|
|
30
30
|
*/
|
|
31
|
-
exhaustiveTypo
|
|
31
|
+
exhaustiveTypo?: boolean;
|
|
32
32
|
/**
|
|
33
33
|
* A mapping of each facet name to the corresponding facet counts.
|
|
34
34
|
*/
|