algoliasearch 5.0.0-alpha.3 → 5.0.0-alpha.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/algoliasearch/builds/browser.d.ts +15 -10
- package/dist/algoliasearch/builds/browser.d.ts.map +1 -1
- package/dist/algoliasearch/builds/node.d.ts +15 -10
- package/dist/algoliasearch/builds/node.d.ts.map +1 -1
- package/dist/algoliasearch/lite/model/acl.d.ts +3 -0
- package/dist/algoliasearch/lite/model/acl.d.ts.map +1 -1
- package/dist/algoliasearch/lite/model/addApiKeyResponse.d.ts +1 -1
- package/dist/algoliasearch/lite/model/attributeToUpdate.d.ts +3 -0
- package/dist/algoliasearch/lite/model/attributeToUpdate.d.ts.map +1 -0
- package/dist/algoliasearch/lite/model/baseBrowseResponse.d.ts +1 -1
- package/dist/algoliasearch/lite/model/baseBrowseResponse.d.ts.map +1 -1
- package/dist/algoliasearch/lite/model/baseGetApiKeyResponse.d.ts +11 -0
- package/dist/algoliasearch/lite/model/baseGetApiKeyResponse.d.ts.map +1 -0
- package/dist/algoliasearch/lite/model/baseSearchResponse.d.ts +1 -1
- package/dist/algoliasearch/lite/model/baseSearchResponse.d.ts.map +1 -1
- package/dist/algoliasearch/lite/model/getApiKeyResponse.d.ts +4 -0
- package/dist/algoliasearch/lite/model/getApiKeyResponse.d.ts.map +1 -0
- package/dist/algoliasearch/lite/model/index.d.ts +3 -3
- package/dist/algoliasearch/lite/model/index.d.ts.map +1 -1
- package/dist/algoliasearch/lite/model/indexSettingsAsSearchParams.d.ts +4 -0
- package/dist/algoliasearch/lite/model/indexSettingsAsSearchParams.d.ts.map +1 -1
- package/dist/algoliasearch/lite/src/liteClient.d.ts +9 -1
- package/dist/algoliasearch/lite/src/liteClient.d.ts.map +1 -1
- package/dist/algoliasearch.cjs.js +190 -29
- package/dist/algoliasearch.esm.browser.js +218 -57
- package/dist/algoliasearch.esm.node.js +191 -30
- package/dist/algoliasearch.umd.js +2 -2
- package/dist/builds/browser.d.ts +15 -10
- package/dist/builds/browser.d.ts.map +1 -1
- package/dist/builds/node.d.ts +15 -10
- package/dist/builds/node.d.ts.map +1 -1
- package/dist/client-abtesting/src/abtestingClient.d.ts +9 -1
- package/dist/client-abtesting/src/abtestingClient.d.ts.map +1 -1
- package/dist/client-analytics/src/analyticsClient.d.ts +9 -1
- package/dist/client-analytics/src/analyticsClient.d.ts.map +1 -1
- package/dist/client-personalization/src/personalizationClient.d.ts +9 -1
- package/dist/client-personalization/src/personalizationClient.d.ts.map +1 -1
- package/dist/client-search/model/acl.d.ts +3 -0
- package/dist/client-search/model/acl.d.ts.map +1 -1
- package/dist/client-search/model/addApiKeyResponse.d.ts +1 -1
- package/dist/client-search/model/attributeToUpdate.d.ts +3 -0
- package/dist/client-search/model/attributeToUpdate.d.ts.map +1 -0
- package/dist/client-search/model/baseBrowseResponse.d.ts +1 -1
- package/dist/client-search/model/baseBrowseResponse.d.ts.map +1 -1
- package/dist/client-search/model/baseGetApiKeyResponse.d.ts +11 -0
- package/dist/client-search/model/baseGetApiKeyResponse.d.ts.map +1 -0
- package/dist/client-search/model/baseSearchResponse.d.ts +1 -1
- package/dist/client-search/model/baseSearchResponse.d.ts.map +1 -1
- package/dist/client-search/model/batchParams.d.ts +1 -1
- package/dist/client-search/model/batchParams.d.ts.map +1 -1
- package/dist/client-search/model/clientMethodProps.d.ts +22 -11
- package/dist/client-search/model/clientMethodProps.d.ts.map +1 -1
- package/dist/client-search/model/getApiKeyResponse.d.ts +4 -0
- package/dist/client-search/model/getApiKeyResponse.d.ts.map +1 -0
- package/dist/client-search/model/getObjectsParams.d.ts +1 -1
- package/dist/client-search/model/getObjectsParams.d.ts.map +1 -1
- package/dist/client-search/model/index.d.ts +3 -3
- package/dist/client-search/model/index.d.ts.map +1 -1
- package/dist/client-search/model/indexSettingsAsSearchParams.d.ts +4 -0
- package/dist/client-search/model/indexSettingsAsSearchParams.d.ts.map +1 -1
- package/dist/client-search/model/listApiKeysResponse.d.ts +2 -2
- package/dist/client-search/model/listApiKeysResponse.d.ts.map +1 -1
- package/dist/client-search/model/multipleBatchRequest.d.ts +3 -3
- package/dist/client-search/model/multipleBatchRequest.d.ts.map +1 -1
- package/dist/client-search/model/multipleBatchResponse.d.ts +2 -2
- package/dist/client-search/model/multipleBatchResponse.d.ts.map +1 -1
- package/dist/client-search/model/updateApiKeyResponse.d.ts +1 -1
- package/dist/client-search/src/searchClient.d.ts +64 -17
- package/dist/client-search/src/searchClient.d.ts.map +1 -1
- package/dist/lite/builds/browser.d.ts +15 -10
- package/dist/lite/builds/browser.d.ts.map +1 -1
- package/dist/lite/builds/node.d.ts +15 -10
- package/dist/lite/builds/node.d.ts.map +1 -1
- package/dist/lite/lite/model/acl.d.ts +3 -0
- package/dist/lite/lite/model/acl.d.ts.map +1 -1
- package/dist/lite/lite/model/addApiKeyResponse.d.ts +1 -1
- package/dist/lite/lite/model/attributeToUpdate.d.ts +3 -0
- package/dist/lite/lite/model/attributeToUpdate.d.ts.map +1 -0
- package/dist/lite/lite/model/baseBrowseResponse.d.ts +1 -1
- package/dist/lite/lite/model/baseBrowseResponse.d.ts.map +1 -1
- package/dist/lite/lite/model/baseGetApiKeyResponse.d.ts +11 -0
- package/dist/lite/lite/model/baseGetApiKeyResponse.d.ts.map +1 -0
- package/dist/lite/lite/model/baseSearchResponse.d.ts +1 -1
- package/dist/lite/lite/model/baseSearchResponse.d.ts.map +1 -1
- package/dist/lite/lite/model/getApiKeyResponse.d.ts +4 -0
- package/dist/lite/lite/model/getApiKeyResponse.d.ts.map +1 -0
- package/dist/lite/lite/model/index.d.ts +3 -3
- package/dist/lite/lite/model/index.d.ts.map +1 -1
- package/dist/lite/lite/model/indexSettingsAsSearchParams.d.ts +4 -0
- package/dist/lite/lite/model/indexSettingsAsSearchParams.d.ts.map +1 -1
- package/dist/lite/lite/src/liteClient.d.ts +9 -1
- package/dist/lite/lite/src/liteClient.d.ts.map +1 -1
- package/dist/lite/lite.cjs.js +14 -1
- package/dist/lite/lite.esm.browser.js +14 -1
- package/dist/lite/lite.esm.node.js +14 -1
- package/dist/lite/lite.umd.js +2 -2
- package/lite/model/acl.ts +3 -0
- package/lite/model/addApiKeyResponse.ts +1 -1
- package/lite/model/{attributeOrBuiltInOperation.ts → attributeToUpdate.ts} +1 -1
- package/lite/model/baseBrowseResponse.ts +1 -1
- package/lite/model/baseGetApiKeyResponse.ts +13 -0
- package/lite/model/baseSearchResponse.ts +1 -1
- package/lite/model/{key.ts → getApiKeyResponse.ts} +2 -2
- package/lite/model/index.ts +3 -3
- package/lite/model/indexSettingsAsSearchParams.ts +5 -0
- package/lite/src/liteClient.ts +19 -1
- package/package.json +9 -9
- package/dist/algoliasearch/lite/model/attributeOrBuiltInOperation.d.ts +0 -3
- package/dist/algoliasearch/lite/model/attributeOrBuiltInOperation.d.ts.map +0 -1
- package/dist/algoliasearch/lite/model/createdAtObject.d.ts +0 -7
- package/dist/algoliasearch/lite/model/createdAtObject.d.ts.map +0 -1
- package/dist/algoliasearch/lite/model/key.d.ts +0 -4
- package/dist/algoliasearch/lite/model/key.d.ts.map +0 -1
- package/dist/client-search/model/attributeOrBuiltInOperation.d.ts +0 -3
- package/dist/client-search/model/attributeOrBuiltInOperation.d.ts.map +0 -1
- package/dist/client-search/model/createdAtObject.d.ts +0 -7
- package/dist/client-search/model/createdAtObject.d.ts.map +0 -1
- package/dist/client-search/model/key.d.ts +0 -4
- package/dist/client-search/model/key.d.ts.map +0 -1
- package/dist/lite/lite/model/attributeOrBuiltInOperation.d.ts +0 -3
- package/dist/lite/lite/model/attributeOrBuiltInOperation.d.ts.map +0 -1
- package/dist/lite/lite/model/createdAtObject.d.ts +0 -7
- package/dist/lite/lite/model/createdAtObject.d.ts.map +0 -1
- package/dist/lite/lite/model/key.d.ts +0 -4
- package/dist/lite/lite/model/key.d.ts.map +0 -1
- package/lite/model/createdAtObject.ts +0 -8
|
@@ -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$4 = '5.0.0-alpha.
|
|
9
|
+
const apiClientVersion$4 = '5.0.0-alpha.6';
|
|
10
10
|
const REGIONS$2 = ['de', 'us'];
|
|
11
11
|
function getDefaultHosts$3(region) {
|
|
12
12
|
const url = !region
|
|
@@ -37,6 +37,19 @@ function createAbtestingClient({ appId: appIdOption, apiKey: apiKeyOption, authM
|
|
|
37
37
|
});
|
|
38
38
|
return {
|
|
39
39
|
transporter,
|
|
40
|
+
/**
|
|
41
|
+
* The `appId` currently in use.
|
|
42
|
+
*/
|
|
43
|
+
appId: appIdOption,
|
|
44
|
+
/**
|
|
45
|
+
* Clears the cache of the transporter for the `requestsCache` and `responsesCache` properties.
|
|
46
|
+
*/
|
|
47
|
+
clearCache() {
|
|
48
|
+
return Promise.all([
|
|
49
|
+
transporter.requestsCache.clear(),
|
|
50
|
+
transporter.responsesCache.clear(),
|
|
51
|
+
]).then(() => undefined);
|
|
52
|
+
},
|
|
40
53
|
/**
|
|
41
54
|
* Get the value of the `algoliaAgent`, used by our libraries internally and telemetry system.
|
|
42
55
|
*/
|
|
@@ -284,7 +297,7 @@ function createAbtestingClient({ appId: appIdOption, apiKey: apiKeyOption, authM
|
|
|
284
297
|
}
|
|
285
298
|
|
|
286
299
|
// This file is generated, manual changes will be lost - read more on https://github.com/algolia/api-clients-automation.
|
|
287
|
-
const apiClientVersion$3 = '5.0.0-alpha.
|
|
300
|
+
const apiClientVersion$3 = '5.0.0-alpha.6';
|
|
288
301
|
const REGIONS$1 = ['de', 'us'];
|
|
289
302
|
function getDefaultHosts$2(region) {
|
|
290
303
|
const url = !region
|
|
@@ -315,6 +328,19 @@ function createAnalyticsClient({ appId: appIdOption, apiKey: apiKeyOption, authM
|
|
|
315
328
|
});
|
|
316
329
|
return {
|
|
317
330
|
transporter,
|
|
331
|
+
/**
|
|
332
|
+
* The `appId` currently in use.
|
|
333
|
+
*/
|
|
334
|
+
appId: appIdOption,
|
|
335
|
+
/**
|
|
336
|
+
* Clears the cache of the transporter for the `requestsCache` and `responsesCache` properties.
|
|
337
|
+
*/
|
|
338
|
+
clearCache() {
|
|
339
|
+
return Promise.all([
|
|
340
|
+
transporter.requestsCache.clear(),
|
|
341
|
+
transporter.responsesCache.clear(),
|
|
342
|
+
]).then(() => undefined);
|
|
343
|
+
},
|
|
318
344
|
/**
|
|
319
345
|
* Get the value of the `algoliaAgent`, used by our libraries internally and telemetry system.
|
|
320
346
|
*/
|
|
@@ -1168,7 +1194,7 @@ function createAnalyticsClient({ appId: appIdOption, apiKey: apiKeyOption, authM
|
|
|
1168
1194
|
}
|
|
1169
1195
|
|
|
1170
1196
|
// This file is generated, manual changes will be lost - read more on https://github.com/algolia/api-clients-automation.
|
|
1171
|
-
const apiClientVersion$2 = '5.0.0-alpha.
|
|
1197
|
+
const apiClientVersion$2 = '5.0.0-alpha.6';
|
|
1172
1198
|
const REGIONS = ['eu', 'us'];
|
|
1173
1199
|
function getDefaultHosts$1(region) {
|
|
1174
1200
|
const url = 'personalization.{region}.algolia.com'.replace('{region}', region);
|
|
@@ -1197,6 +1223,19 @@ function createPersonalizationClient({ appId: appIdOption, apiKey: apiKeyOption,
|
|
|
1197
1223
|
});
|
|
1198
1224
|
return {
|
|
1199
1225
|
transporter,
|
|
1226
|
+
/**
|
|
1227
|
+
* The `appId` currently in use.
|
|
1228
|
+
*/
|
|
1229
|
+
appId: appIdOption,
|
|
1230
|
+
/**
|
|
1231
|
+
* Clears the cache of the transporter for the `requestsCache` and `responsesCache` properties.
|
|
1232
|
+
*/
|
|
1233
|
+
clearCache() {
|
|
1234
|
+
return Promise.all([
|
|
1235
|
+
transporter.requestsCache.clear(),
|
|
1236
|
+
transporter.responsesCache.clear(),
|
|
1237
|
+
]).then(() => undefined);
|
|
1238
|
+
},
|
|
1200
1239
|
/**
|
|
1201
1240
|
* Get the value of the `algoliaAgent`, used by our libraries internally and telemetry system.
|
|
1202
1241
|
*/
|
|
@@ -1412,7 +1451,7 @@ function createPersonalizationClient({ appId: appIdOption, apiKey: apiKeyOption,
|
|
|
1412
1451
|
}
|
|
1413
1452
|
|
|
1414
1453
|
// This file is generated, manual changes will be lost - read more on https://github.com/algolia/api-clients-automation.
|
|
1415
|
-
const apiClientVersion$1 = '5.0.0-alpha.
|
|
1454
|
+
const apiClientVersion$1 = '5.0.0-alpha.6';
|
|
1416
1455
|
function getDefaultHosts(appId) {
|
|
1417
1456
|
return [
|
|
1418
1457
|
{
|
|
@@ -1466,6 +1505,19 @@ function createSearchClient({ appId: appIdOption, apiKey: apiKeyOption, authMode
|
|
|
1466
1505
|
});
|
|
1467
1506
|
return {
|
|
1468
1507
|
transporter,
|
|
1508
|
+
/**
|
|
1509
|
+
* The `appId` currently in use.
|
|
1510
|
+
*/
|
|
1511
|
+
appId: appIdOption,
|
|
1512
|
+
/**
|
|
1513
|
+
* Clears the cache of the transporter for the `requestsCache` and `responsesCache` properties.
|
|
1514
|
+
*/
|
|
1515
|
+
clearCache() {
|
|
1516
|
+
return Promise.all([
|
|
1517
|
+
transporter.requestsCache.clear(),
|
|
1518
|
+
transporter.responsesCache.clear(),
|
|
1519
|
+
]).then(() => undefined);
|
|
1520
|
+
},
|
|
1469
1521
|
/**
|
|
1470
1522
|
* Get the value of the `algoliaAgent`, used by our libraries internally and telemetry system.
|
|
1471
1523
|
*/
|
|
@@ -1482,38 +1534,57 @@ function createSearchClient({ appId: appIdOption, apiKey: apiKeyOption, authMode
|
|
|
1482
1534
|
transporter.algoliaAgent.add({ segment, version });
|
|
1483
1535
|
},
|
|
1484
1536
|
/**
|
|
1485
|
-
* Helper: Wait for a task to
|
|
1537
|
+
* Helper: Wait for a task to be published (completed) for a given `indexName` and `taskID`.
|
|
1486
1538
|
*
|
|
1487
|
-
* @summary
|
|
1539
|
+
* @summary Helper method that waits for a task to be published (completed).
|
|
1488
1540
|
* @param waitForTaskOptions - The waitForTaskOptions object.
|
|
1489
1541
|
* @param waitForTaskOptions.indexName - The `indexName` where the operation was performed.
|
|
1490
1542
|
* @param waitForTaskOptions.taskID - The `taskID` returned in the method response.
|
|
1543
|
+
* @param waitForTaskOptions.maxRetries - The maximum number of retries. 50 by default.
|
|
1544
|
+
* @param waitForTaskOptions.timeout - The function to decide how long to wait between retries.
|
|
1491
1545
|
* @param requestOptions - The requestOptions to send along with the query, they will be forwarded to the `getTask` method and merged with the transporter requestOptions.
|
|
1492
1546
|
*/
|
|
1493
|
-
waitForTask({ indexName, taskID,
|
|
1494
|
-
|
|
1495
|
-
|
|
1547
|
+
waitForTask({ indexName, taskID, maxRetries = 50, timeout = (retryCount) => Math.min(retryCount * 200, 5000), }, requestOptions) {
|
|
1548
|
+
let retryCount = 0;
|
|
1549
|
+
return clientCommon.createIterablePromise({
|
|
1496
1550
|
func: () => this.getTask({ indexName, taskID }, requestOptions),
|
|
1497
1551
|
validate: (response) => response.status === 'published',
|
|
1552
|
+
aggregator: () => (retryCount += 1),
|
|
1553
|
+
error: {
|
|
1554
|
+
validate: () => retryCount >= maxRetries,
|
|
1555
|
+
message: () => `The maximum number of retries exceeded. (${retryCount}/${maxRetries})`,
|
|
1556
|
+
},
|
|
1557
|
+
timeout: () => timeout(retryCount),
|
|
1498
1558
|
});
|
|
1499
1559
|
},
|
|
1500
1560
|
/**
|
|
1501
1561
|
* Helper: Wait for an API key to be added, updated or deleted based on a given `operation`.
|
|
1502
1562
|
*
|
|
1503
|
-
* @summary
|
|
1563
|
+
* @summary Helper method that waits for an API key task to be processed.
|
|
1504
1564
|
* @param waitForApiKeyOptions - The waitForApiKeyOptions object.
|
|
1505
1565
|
* @param waitForApiKeyOptions.operation - The `operation` that was done on a `key`.
|
|
1506
1566
|
* @param waitForApiKeyOptions.key - The `key` that has been added, deleted or updated.
|
|
1507
1567
|
* @param waitForApiKeyOptions.apiKey - Necessary to know if an `update` operation has been processed, compare fields of the response with it.
|
|
1568
|
+
* @param waitForApiKeyOptions.maxRetries - The maximum number of retries. 50 by default.
|
|
1569
|
+
* @param waitForApiKeyOptions.timeout - The function to decide how long to wait between retries.
|
|
1508
1570
|
* @param requestOptions - The requestOptions to send along with the query, they will be forwarded to the `getApikey` method and merged with the transporter requestOptions.
|
|
1509
1571
|
*/
|
|
1510
|
-
waitForApiKey({ operation, key, apiKey,
|
|
1572
|
+
waitForApiKey({ operation, key, apiKey, maxRetries = 50, timeout = (retryCount) => Math.min(retryCount * 200, 5000), }, requestOptions) {
|
|
1573
|
+
let retryCount = 0;
|
|
1574
|
+
const baseIteratorOptions = {
|
|
1575
|
+
aggregator: () => (retryCount += 1),
|
|
1576
|
+
error: {
|
|
1577
|
+
validate: () => retryCount >= maxRetries,
|
|
1578
|
+
message: () => `The maximum number of retries exceeded. (${retryCount}/${maxRetries})`,
|
|
1579
|
+
},
|
|
1580
|
+
timeout: () => timeout(retryCount),
|
|
1581
|
+
};
|
|
1511
1582
|
if (operation === 'update') {
|
|
1512
1583
|
if (!apiKey) {
|
|
1513
1584
|
throw new Error('`apiKey` is required when waiting for an `update` operation.');
|
|
1514
1585
|
}
|
|
1515
|
-
return clientCommon.
|
|
1516
|
-
...
|
|
1586
|
+
return clientCommon.createIterablePromise({
|
|
1587
|
+
...baseIteratorOptions,
|
|
1517
1588
|
func: () => this.getApiKey({ key }, requestOptions),
|
|
1518
1589
|
validate: (response) => {
|
|
1519
1590
|
for (const field of Object.keys(apiKey)) {
|
|
@@ -1531,12 +1602,99 @@ function createSearchClient({ appId: appIdOption, apiKey: apiKeyOption, authMode
|
|
|
1531
1602
|
},
|
|
1532
1603
|
});
|
|
1533
1604
|
}
|
|
1534
|
-
return clientCommon.
|
|
1535
|
-
...
|
|
1605
|
+
return clientCommon.createIterablePromise({
|
|
1606
|
+
...baseIteratorOptions,
|
|
1536
1607
|
func: () => this.getApiKey({ key }, requestOptions).catch((error) => error),
|
|
1537
1608
|
validate: (error) => operation === 'add' ? error.status !== 404 : error.status === 404,
|
|
1538
1609
|
});
|
|
1539
1610
|
},
|
|
1611
|
+
/**
|
|
1612
|
+
* Helper: Iterate on the `browse` method of the client to allow aggregating objects of an index.
|
|
1613
|
+
*
|
|
1614
|
+
* @summary Helper method that iterates on the `browse` method.
|
|
1615
|
+
* @param browseObjects - The browseObjects object.
|
|
1616
|
+
* @param browseObjects.indexName - The index in which to perform the request.
|
|
1617
|
+
* @param browseObjects.browseRequest - The `browse` method parameters.
|
|
1618
|
+
* @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.
|
|
1619
|
+
* @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`.
|
|
1620
|
+
* @param requestOptions - The requestOptions to send along with the query, they will be forwarded to the `browse` method and merged with the transporter requestOptions.
|
|
1621
|
+
*/
|
|
1622
|
+
browseObjects({ indexName, browseRequest, ...browseObjectsOptions }, requestOptions) {
|
|
1623
|
+
return clientCommon.createIterablePromise({
|
|
1624
|
+
func: (previousResponse) => {
|
|
1625
|
+
return this.browse({
|
|
1626
|
+
indexName,
|
|
1627
|
+
browseRequest: {
|
|
1628
|
+
cursor: previousResponse ? previousResponse.cursor : undefined,
|
|
1629
|
+
...browseRequest,
|
|
1630
|
+
},
|
|
1631
|
+
}, requestOptions);
|
|
1632
|
+
},
|
|
1633
|
+
validate: (response) => response.cursor === undefined,
|
|
1634
|
+
...browseObjectsOptions,
|
|
1635
|
+
});
|
|
1636
|
+
},
|
|
1637
|
+
/**
|
|
1638
|
+
* Helper: Iterate on the `searchRules` method of the client to allow aggregating rules of an index.
|
|
1639
|
+
*
|
|
1640
|
+
* @summary Helper method that iterates on the `searchRules` method.
|
|
1641
|
+
* @param browseObjects - The browseObjects object.
|
|
1642
|
+
* @param browseObjects.indexName - The index in which to perform the request.
|
|
1643
|
+
* @param browseObjects.searchRulesParams - The `searchRules` method parameters.
|
|
1644
|
+
* @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).
|
|
1645
|
+
* @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`.
|
|
1646
|
+
* @param requestOptions - The requestOptions to send along with the query, they will be forwarded to the `searchRules` method and merged with the transporter requestOptions.
|
|
1647
|
+
*/
|
|
1648
|
+
browseRules({ indexName, searchRulesParams, ...browseRulesOptions }, requestOptions) {
|
|
1649
|
+
const params = {
|
|
1650
|
+
hitsPerPage: 1000,
|
|
1651
|
+
...searchRulesParams,
|
|
1652
|
+
};
|
|
1653
|
+
return clientCommon.createIterablePromise({
|
|
1654
|
+
func: (previousResponse) => {
|
|
1655
|
+
return this.searchRules({
|
|
1656
|
+
indexName,
|
|
1657
|
+
searchRulesParams: {
|
|
1658
|
+
...params,
|
|
1659
|
+
page: previousResponse
|
|
1660
|
+
? previousResponse.page + 1
|
|
1661
|
+
: params.page || 0,
|
|
1662
|
+
},
|
|
1663
|
+
}, requestOptions);
|
|
1664
|
+
},
|
|
1665
|
+
validate: (response) => response.nbHits < params.hitsPerPage,
|
|
1666
|
+
...browseRulesOptions,
|
|
1667
|
+
});
|
|
1668
|
+
},
|
|
1669
|
+
/**
|
|
1670
|
+
* Helper: Iterate on the `searchSynonyms` method of the client to allow aggregating rules of an index.
|
|
1671
|
+
*
|
|
1672
|
+
* @summary Helper method that iterates on the `searchSynonyms` method.
|
|
1673
|
+
* @param browseObjects - The browseObjects object.
|
|
1674
|
+
* @param browseObjects.indexName - The index in which to perform the request.
|
|
1675
|
+
* @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).
|
|
1676
|
+
* @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`.
|
|
1677
|
+
* @param requestOptions - The requestOptions to send along with the query, they will be forwarded to the `searchSynonyms` method and merged with the transporter requestOptions.
|
|
1678
|
+
*/
|
|
1679
|
+
browseSynonyms({ indexName, validate, aggregator, ...browseSynonymsOptions }, requestOptions) {
|
|
1680
|
+
const params = {
|
|
1681
|
+
hitsPerPage: 1000,
|
|
1682
|
+
...browseSynonymsOptions,
|
|
1683
|
+
};
|
|
1684
|
+
return clientCommon.createIterablePromise({
|
|
1685
|
+
func: (previousResponse) => {
|
|
1686
|
+
return this.searchSynonyms({
|
|
1687
|
+
...params,
|
|
1688
|
+
indexName,
|
|
1689
|
+
page: previousResponse
|
|
1690
|
+
? previousResponse.page + 1
|
|
1691
|
+
: browseSynonymsOptions.page || 0,
|
|
1692
|
+
}, requestOptions);
|
|
1693
|
+
},
|
|
1694
|
+
validate: (response) => response.nbHits < params.hitsPerPage,
|
|
1695
|
+
...browseSynonymsOptions,
|
|
1696
|
+
});
|
|
1697
|
+
},
|
|
1540
1698
|
/**
|
|
1541
1699
|
* Add a new API Key with specific permissions/restrictions.
|
|
1542
1700
|
*
|
|
@@ -2230,6 +2388,9 @@ function createSearchClient({ appId: appIdOption, apiKey: apiKeyOption, authMode
|
|
|
2230
2388
|
if (!getObjectsParams) {
|
|
2231
2389
|
throw new Error('Parameter `getObjectsParams` is required when calling `getObjects`.');
|
|
2232
2390
|
}
|
|
2391
|
+
if (!getObjectsParams.requests) {
|
|
2392
|
+
throw new Error('Parameter `getObjectsParams.requests` is required when calling `getObjects`.');
|
|
2393
|
+
}
|
|
2233
2394
|
const requestPath = '/1/indexes/*/objects';
|
|
2234
2395
|
const headers = {};
|
|
2235
2396
|
const queryParameters = {};
|
|
@@ -2533,6 +2694,9 @@ function createSearchClient({ appId: appIdOption, apiKey: apiKeyOption, authMode
|
|
|
2533
2694
|
if (!batchParams) {
|
|
2534
2695
|
throw new Error('Parameter `batchParams` is required when calling `multipleBatch`.');
|
|
2535
2696
|
}
|
|
2697
|
+
if (!batchParams.requests) {
|
|
2698
|
+
throw new Error('Parameter `batchParams.requests` is required when calling `multipleBatch`.');
|
|
2699
|
+
}
|
|
2536
2700
|
const requestPath = '/1/indexes/*/batch';
|
|
2537
2701
|
const headers = {};
|
|
2538
2702
|
const queryParameters = {};
|
|
@@ -2586,19 +2750,19 @@ function createSearchClient({ appId: appIdOption, apiKey: apiKeyOption, authMode
|
|
|
2586
2750
|
* @param partialUpdateObject - The partialUpdateObject object.
|
|
2587
2751
|
* @param partialUpdateObject.indexName - The index in which to perform the request.
|
|
2588
2752
|
* @param partialUpdateObject.objectID - Unique identifier of an object.
|
|
2589
|
-
* @param partialUpdateObject.
|
|
2753
|
+
* @param partialUpdateObject.attributesToUpdate - Map of attribute(s) to update.
|
|
2590
2754
|
* @param partialUpdateObject.createIfNotExists - Creates the record if it does not exist yet.
|
|
2591
2755
|
* @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
|
|
2592
2756
|
*/
|
|
2593
|
-
partialUpdateObject({ indexName, objectID,
|
|
2757
|
+
partialUpdateObject({ indexName, objectID, attributesToUpdate, createIfNotExists, }, requestOptions) {
|
|
2594
2758
|
if (!indexName) {
|
|
2595
2759
|
throw new Error('Parameter `indexName` is required when calling `partialUpdateObject`.');
|
|
2596
2760
|
}
|
|
2597
2761
|
if (!objectID) {
|
|
2598
2762
|
throw new Error('Parameter `objectID` is required when calling `partialUpdateObject`.');
|
|
2599
2763
|
}
|
|
2600
|
-
if (!
|
|
2601
|
-
throw new Error('Parameter `
|
|
2764
|
+
if (!attributesToUpdate) {
|
|
2765
|
+
throw new Error('Parameter `attributesToUpdate` is required when calling `partialUpdateObject`.');
|
|
2602
2766
|
}
|
|
2603
2767
|
const requestPath = '/1/indexes/{indexName}/{objectID}/partial'
|
|
2604
2768
|
.replace('{indexName}', encodeURIComponent(indexName))
|
|
@@ -2613,7 +2777,7 @@ function createSearchClient({ appId: appIdOption, apiKey: apiKeyOption, authMode
|
|
|
2613
2777
|
path: requestPath,
|
|
2614
2778
|
queryParameters,
|
|
2615
2779
|
headers,
|
|
2616
|
-
data:
|
|
2780
|
+
data: attributesToUpdate,
|
|
2617
2781
|
};
|
|
2618
2782
|
return transporter.request(request, requestOptions);
|
|
2619
2783
|
},
|
|
@@ -2814,17 +2978,17 @@ function createSearchClient({ appId: appIdOption, apiKey: apiKeyOption, authMode
|
|
|
2814
2978
|
* @summary Save a batch of rules.
|
|
2815
2979
|
* @param saveRules - The saveRules object.
|
|
2816
2980
|
* @param saveRules.indexName - The index in which to perform the request.
|
|
2817
|
-
* @param saveRules.
|
|
2981
|
+
* @param saveRules.rules - The rules object.
|
|
2818
2982
|
* @param saveRules.forwardToReplicas - When true, changes are also propagated to replicas of the given indexName.
|
|
2819
2983
|
* @param saveRules.clearExistingRules - When true, existing Rules are cleared before adding this batch. When false, existing Rules are kept.
|
|
2820
2984
|
* @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
|
|
2821
2985
|
*/
|
|
2822
|
-
saveRules({ indexName,
|
|
2986
|
+
saveRules({ indexName, rules, forwardToReplicas, clearExistingRules, }, requestOptions) {
|
|
2823
2987
|
if (!indexName) {
|
|
2824
2988
|
throw new Error('Parameter `indexName` is required when calling `saveRules`.');
|
|
2825
2989
|
}
|
|
2826
|
-
if (!
|
|
2827
|
-
throw new Error('Parameter `
|
|
2990
|
+
if (!rules) {
|
|
2991
|
+
throw new Error('Parameter `rules` is required when calling `saveRules`.');
|
|
2828
2992
|
}
|
|
2829
2993
|
const requestPath = '/1/indexes/{indexName}/rules/batch'.replace('{indexName}', encodeURIComponent(indexName));
|
|
2830
2994
|
const headers = {};
|
|
@@ -2840,7 +3004,7 @@ function createSearchClient({ appId: appIdOption, apiKey: apiKeyOption, authMode
|
|
|
2840
3004
|
path: requestPath,
|
|
2841
3005
|
queryParameters,
|
|
2842
3006
|
headers,
|
|
2843
|
-
data:
|
|
3007
|
+
data: rules,
|
|
2844
3008
|
};
|
|
2845
3009
|
return transporter.request(request, requestOptions);
|
|
2846
3010
|
},
|
|
@@ -3051,9 +3215,6 @@ function createSearchClient({ appId: appIdOption, apiKey: apiKeyOption, authMode
|
|
|
3051
3215
|
if (!indexName) {
|
|
3052
3216
|
throw new Error('Parameter `indexName` is required when calling `searchRules`.');
|
|
3053
3217
|
}
|
|
3054
|
-
if (!searchRulesParams) {
|
|
3055
|
-
throw new Error('Parameter `searchRulesParams` is required when calling `searchRules`.');
|
|
3056
|
-
}
|
|
3057
3218
|
const requestPath = '/1/indexes/{indexName}/rules/search'.replace('{indexName}', encodeURIComponent(indexName));
|
|
3058
3219
|
const headers = {};
|
|
3059
3220
|
const queryParameters = {};
|
|
@@ -3062,7 +3223,7 @@ function createSearchClient({ appId: appIdOption, apiKey: apiKeyOption, authMode
|
|
|
3062
3223
|
path: requestPath,
|
|
3063
3224
|
queryParameters,
|
|
3064
3225
|
headers,
|
|
3065
|
-
data: searchRulesParams,
|
|
3226
|
+
data: searchRulesParams ? searchRulesParams : {},
|
|
3066
3227
|
useReadTransporter: true,
|
|
3067
3228
|
cacheable: true,
|
|
3068
3229
|
};
|