@algolia/client-search 5.14.2 → 5.16.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -29,7 +29,7 @@ var import_client_common2 = require("@algolia/client-common");
29
29
 
30
30
  // src/searchClient.ts
31
31
  var import_client_common = require("@algolia/client-common");
32
- var apiClientVersion = "5.14.2";
32
+ var apiClientVersion = "5.16.0";
33
33
  function getDefaultHosts(appId) {
34
34
  return [
35
35
  {
@@ -386,11 +386,15 @@ function createSearchClient({
386
386
  * @param saveObjects - The `saveObjects` object.
387
387
  * @param saveObjects.indexName - The `indexName` to save `objects` in.
388
388
  * @param saveObjects.objects - The array of `objects` to store in the given Algolia `indexName`.
389
+ * @param chunkedBatch.batchSize - The size of the chunk of `objects`. The number of `batch` calls will be equal to `length(objects) / batchSize`. Defaults to 1000.
389
390
  * @param saveObjects.waitForTasks - Whether or not we should wait until every `batch` tasks has been processed, this operation may slow the total execution time of this method but is more reliable.
390
391
  * @param requestOptions - The requestOptions to send along with the query, they will be forwarded to the `batch` method and merged with the transporter requestOptions.
391
392
  */
392
- async saveObjects({ indexName, objects, waitForTasks }, requestOptions) {
393
- return await this.chunkedBatch({ indexName, objects, action: "addObject", waitForTasks }, requestOptions);
393
+ async saveObjects({ indexName, objects, waitForTasks, batchSize }, requestOptions) {
394
+ return await this.chunkedBatch(
395
+ { indexName, objects, action: "addObject", waitForTasks, batchSize },
396
+ requestOptions
397
+ );
394
398
  },
395
399
  /**
396
400
  * Helper: Deletes every records for the given objectIDs. The `chunkedBatch` helper is used under the hood, which creates a `batch` requests with at most 1000 objectIDs in it.
@@ -399,16 +403,18 @@ function createSearchClient({
399
403
  * @param deleteObjects - The `deleteObjects` object.
400
404
  * @param deleteObjects.indexName - The `indexName` to delete `objectIDs` from.
401
405
  * @param deleteObjects.objectIDs - The objectIDs to delete.
406
+ * @param chunkedBatch.batchSize - The size of the chunk of `objects`. The number of `batch` calls will be equal to `length(objects) / batchSize`. Defaults to 1000.
402
407
  * @param deleteObjects.waitForTasks - Whether or not we should wait until every `batch` tasks has been processed, this operation may slow the total execution time of this method but is more reliable.
403
408
  * @param requestOptions - The requestOptions to send along with the query, they will be forwarded to the `batch` method and merged with the transporter requestOptions.
404
409
  */
405
- async deleteObjects({ indexName, objectIDs, waitForTasks }, requestOptions) {
410
+ async deleteObjects({ indexName, objectIDs, waitForTasks, batchSize }, requestOptions) {
406
411
  return await this.chunkedBatch(
407
412
  {
408
413
  indexName,
409
414
  objects: objectIDs.map((objectID) => ({ objectID })),
410
415
  action: "deleteObject",
411
- waitForTasks
416
+ waitForTasks,
417
+ batchSize
412
418
  },
413
419
  requestOptions
414
420
  );
@@ -421,15 +427,17 @@ function createSearchClient({
421
427
  * @param partialUpdateObjects.indexName - The `indexName` to update `objects` in.
422
428
  * @param partialUpdateObjects.objects - The array of `objects` to update in the given Algolia `indexName`.
423
429
  * @param partialUpdateObjects.createIfNotExists - To be provided if non-existing objects are passed, otherwise, the call will fail..
430
+ * @param chunkedBatch.batchSize - The size of the chunk of `objects`. The number of `batch` calls will be equal to `length(objects) / batchSize`. Defaults to 1000.
424
431
  * @param partialUpdateObjects.waitForTasks - Whether or not we should wait until every `batch` tasks has been processed, this operation may slow the total execution time of this method but is more reliable.
425
432
  * @param requestOptions - The requestOptions to send along with the query, they will be forwarded to the `getTask` method and merged with the transporter requestOptions.
426
433
  */
427
- async partialUpdateObjects({ indexName, objects, createIfNotExists, waitForTasks }, requestOptions) {
434
+ async partialUpdateObjects({ indexName, objects, createIfNotExists, waitForTasks, batchSize }, requestOptions) {
428
435
  return await this.chunkedBatch(
429
436
  {
430
437
  indexName,
431
438
  objects,
432
439
  action: createIfNotExists ? "partialUpdateObject" : "partialUpdateObjectNoCreate",
440
+ batchSize,
433
441
  waitForTasks
434
442
  },
435
443
  requestOptions
@@ -652,7 +660,7 @@ function createSearchClient({
652
660
  return transporter.request(request, requestOptions);
653
661
  },
654
662
  /**
655
- * Adds, updates, or deletes records in one index with a single API request. Batching index updates reduces latency and increases data integrity. - Actions are applied in the order they\'re specified. - Actions are equivalent to the individual API requests of the same name.
663
+ * Adds, updates, or deletes records in one index with a single API request. Batching index updates reduces latency and increases data integrity. - Actions are applied in the order they\'re specified. - Actions are equivalent to the individual API requests of the same name. This operation is subject to [indexing rate limits](https://support.algolia.com/hc/en-us/articles/4406975251089-Is-there-a-rate-limit-for-indexing-on-Algolia).
656
664
  * @param batch - The batch object.
657
665
  * @param batch.indexName - Name of the index on which to perform the operation.
658
666
  * @param batch.batchWriteParams - The batchWriteParams object.
@@ -783,7 +791,7 @@ function createSearchClient({
783
791
  return transporter.request(request, requestOptions);
784
792
  },
785
793
  /**
786
- * Deletes only the records from an index while keeping settings, synonyms, and rules.
794
+ * Deletes only the records from an index while keeping settings, synonyms, and rules. This operation is resource-intensive and subject to [indexing rate limits](https://support.algolia.com/hc/en-us/articles/4406975251089-Is-there-a-rate-limit-for-indexing-on-Algolia).
787
795
  *
788
796
  * Required API Key ACLs:
789
797
  * - deleteIndex
@@ -979,7 +987,7 @@ function createSearchClient({
979
987
  return transporter.request(request, requestOptions);
980
988
  },
981
989
  /**
982
- * This operation doesn\'t accept empty queries or filters. It\'s more efficient to get a list of object IDs with the [`browse` operation](#tag/Search/operation/browse), and then delete the records using the [`batch` operation](#tag/Records/operation/batch).
990
+ * This operation doesn\'t accept empty filters. This operation is resource-intensive. You should only use it if you can\'t get the object IDs of the records you want to delete. It\'s more efficient to get a list of object IDs with the [`browse` operation](#tag/Search/operation/browse), and then delete the records using the [`batch` operation](#tag/Records/operation/batch). This operation is subject to [indexing rate limits](https://support.algolia.com/hc/en-us/articles/4406975251089-Is-there-a-rate-limit-for-indexing-on-Algolia).
983
991
  *
984
992
  * Required API Key ACLs:
985
993
  * - deleteIndex
@@ -1616,7 +1624,7 @@ function createSearchClient({
1616
1624
  return transporter.request(request, requestOptions);
1617
1625
  },
1618
1626
  /**
1619
- * Adds, updates, or deletes records in multiple indices with a single API request. - Actions are applied in the order they are specified. - Actions are equivalent to the individual API requests of the same name.
1627
+ * Adds, updates, or deletes records in multiple indices with a single API request. - Actions are applied in the order they are specified. - Actions are equivalent to the individual API requests of the same name. This operation is subject to [indexing rate limits](https://support.algolia.com/hc/en-us/articles/4406975251089-Is-there-a-rate-limit-for-indexing-on-Algolia).
1620
1628
  * @param batchParams - The batchParams object.
1621
1629
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
1622
1630
  */
@@ -1640,7 +1648,7 @@ function createSearchClient({
1640
1648
  return transporter.request(request, requestOptions);
1641
1649
  },
1642
1650
  /**
1643
- * Copies or moves (renames) an index within the same Algolia application. - Existing destination indices are overwritten, except for their analytics data. - If the destination index doesn\'t exist yet, it\'ll be created. **Copy** - Copying a source index that doesn\'t exist creates a new index with 0 records and default settings. - The API keys of the source index are merged with the existing keys in the destination index. - You can\'t copy the `enableReRanking`, `mode`, and `replicas` settings. - You can\'t copy to a destination index that already has replicas. - Be aware of the [size limits](https://www.algolia.com/doc/guides/scaling/algolia-service-limits/#application-record-and-index-limits). - Related guide: [Copy indices](https://www.algolia.com/doc/guides/sending-and-managing-data/manage-indices-and-apps/manage-indices/how-to/copy-indices/) **Move** - Moving a source index that doesn\'t exist is ignored without returning an error. - When moving an index, the analytics data keeps its original name, and a new set of analytics data is started for the new name. To access the original analytics in the dashboard, create an index with the original name. - If the destination index has replicas, moving will overwrite the existing index and copy the data to the replica indices. - Related guide: [Move indices](https://www.algolia.com/doc/guides/sending-and-managing-data/manage-indices-and-apps/manage-indices/how-to/move-indices/).
1651
+ * Copies or moves (renames) an index within the same Algolia application. - Existing destination indices are overwritten, except for their analytics data. - If the destination index doesn\'t exist yet, it\'ll be created. - This operation is resource-intensive. **Copy** - Copying a source index that doesn\'t exist creates a new index with 0 records and default settings. - The API keys of the source index are merged with the existing keys in the destination index. - You can\'t copy the `enableReRanking`, `mode`, and `replicas` settings. - You can\'t copy to a destination index that already has replicas. - Be aware of the [size limits](https://www.algolia.com/doc/guides/scaling/algolia-service-limits/#application-record-and-index-limits). - Related guide: [Copy indices](https://www.algolia.com/doc/guides/sending-and-managing-data/manage-indices-and-apps/manage-indices/how-to/copy-indices/) **Move** - Moving a source index that doesn\'t exist is ignored without returning an error. - When moving an index, the analytics data keeps its original name, and a new set of analytics data is started for the new name. To access the original analytics in the dashboard, create an index with the original name. - If the destination index has replicas, moving will overwrite the existing index and copy the data to the replica indices. - Related guide: [Move indices](https://www.algolia.com/doc/guides/sending-and-managing-data/manage-indices-and-apps/manage-indices/how-to/move-indices/). This operation is subject to [indexing rate limits](https://support.algolia.com/hc/en-us/articles/4406975251089-Is-there-a-rate-limit-for-indexing-on-Algolia).
1644
1652
  *
1645
1653
  * Required API Key ACLs:
1646
1654
  * - addObject
@@ -1675,7 +1683,7 @@ function createSearchClient({
1675
1683
  return transporter.request(request, requestOptions);
1676
1684
  },
1677
1685
  /**
1678
- * Adds new attributes to a record, or updates existing ones. - If a record with the specified object ID doesn\'t exist, a new record is added to the index **if** `createIfNotExists` is true. - If the index doesn\'t exist yet, this method creates a new index. - You can use any first-level attribute but not nested attributes. If you specify a nested attribute, the engine treats it as a replacement for its first-level ancestor. To update an attribute without pushing the entire record, you can use these built-in operations. These operations can be helpful if you don\'t have access to your initial data. - Increment: increment a numeric attribute - Decrement: decrement a numeric attribute - Add: append a number or string element to an array attribute - Remove: remove all matching number or string elements from an array attribute made of numbers or strings - AddUnique: add a number or string element to an array attribute made of numbers or strings only if it\'s not already present - IncrementFrom: increment a numeric integer attribute only if the provided value matches the current value, and otherwise ignore the whole object update. For example, if you pass an IncrementFrom value of 2 for the version attribute, but the current value of the attribute is 1, the engine ignores the update. If the object doesn\'t exist, the engine only creates it if you pass an IncrementFrom value of 0. - IncrementSet: increment a numeric integer attribute only if the provided value is greater than the current value, and otherwise ignore the whole object update. For example, if you pass an IncrementSet value of 2 for the version attribute, and the current value of the attribute is 1, the engine updates the object. If the object doesn\'t exist yet, the engine only creates it if you pass an IncrementSet value greater than 0. You can specify an operation by providing an object with the attribute to update as the key and its value being an object with the following properties: - _operation: the operation to apply on the attribute - value: the right-hand side argument to the operation, for example, increment or decrement step, value to add or remove.
1686
+ * Adds new attributes to a record, or updates existing ones. - If a record with the specified object ID doesn\'t exist, a new record is added to the index **if** `createIfNotExists` is true. - If the index doesn\'t exist yet, this method creates a new index. - You can use any first-level attribute but not nested attributes. If you specify a nested attribute, this operation replaces its first-level ancestor. To update an attribute without pushing the entire record, you can use these built-in operations. These operations can be helpful if you don\'t have access to your initial data. - Increment: increment a numeric attribute - Decrement: decrement a numeric attribute - Add: append a number or string element to an array attribute - Remove: remove all matching number or string elements from an array attribute made of numbers or strings - AddUnique: add a number or string element to an array attribute made of numbers or strings only if it\'s not already present - IncrementFrom: increment a numeric integer attribute only if the provided value matches the current value, and otherwise ignore the whole object update. For example, if you pass an IncrementFrom value of 2 for the version attribute, but the current value of the attribute is 1, the engine ignores the update. If the object doesn\'t exist, the engine only creates it if you pass an IncrementFrom value of 0. - IncrementSet: increment a numeric integer attribute only if the provided value is greater than the current value, and otherwise ignore the whole object update. For example, if you pass an IncrementSet value of 2 for the version attribute, and the current value of the attribute is 1, the engine updates the object. If the object doesn\'t exist yet, the engine only creates it if you pass an IncrementSet value greater than 0. You can specify an operation by providing an object with the attribute to update as the key and its value being an object with the following properties: - _operation: the operation to apply on the attribute - value: the right-hand side argument to the operation, for example, increment or decrement step, value to add or remove. This operation is subject to [indexing rate limits](https://support.algolia.com/hc/en-us/articles/4406975251089-Is-there-a-rate-limit-for-indexing-on-Algolia).
1679
1687
  *
1680
1688
  * Required API Key ACLs:
1681
1689
  * - addObject
@@ -1785,7 +1793,7 @@ function createSearchClient({
1785
1793
  return transporter.request(request, requestOptions);
1786
1794
  },
1787
1795
  /**
1788
- * Adds a record to an index or replace it. - If the record doesn\'t have an object ID, a new record with an auto-generated object ID is added to your index. - If a record with the specified object ID exists, the existing record is replaced. - If a record with the specified object ID doesn\'t exist, a new record is added to your index. - If you add a record to an index that doesn\'t exist yet, a new index is created. To update _some_ attributes of a record, use the [`partial` operation](#tag/Records/operation/partialUpdateObject). To add, update, or replace multiple records, use the [`batch` operation](#tag/Records/operation/batch).
1796
+ * Adds a record to an index or replace it. - If the record doesn\'t have an object ID, a new record with an auto-generated object ID is added to your index. - If a record with the specified object ID exists, the existing record is replaced. - If a record with the specified object ID doesn\'t exist, a new record is added to your index. - If you add a record to an index that doesn\'t exist yet, a new index is created. To update _some_ attributes of a record, use the [`partial` operation](#tag/Records/operation/partialUpdateObject). To add, update, or replace multiple records, use the [`batch` operation](#tag/Records/operation/batch). This operation is subject to [indexing rate limits](https://support.algolia.com/hc/en-us/articles/4406975251089-Is-there-a-rate-limit-for-indexing-on-Algolia).
1789
1797
  *
1790
1798
  * Required API Key ACLs:
1791
1799
  * - addObject
@@ -1838,6 +1846,9 @@ function createSearchClient({
1838
1846
  if (!rule.objectID) {
1839
1847
  throw new Error("Parameter `rule.objectID` is required when calling `saveRule`.");
1840
1848
  }
1849
+ if (!rule.consequence) {
1850
+ throw new Error("Parameter `rule.consequence` is required when calling `saveRule`.");
1851
+ }
1841
1852
  const requestPath = "/1/indexes/{indexName}/rules/{objectID}".replace("{indexName}", encodeURIComponent(indexName)).replace("{objectID}", encodeURIComponent(objectID));
1842
1853
  const headers = {};
1843
1854
  const queryParameters = {};
@@ -1854,7 +1865,7 @@ function createSearchClient({
1854
1865
  return transporter.request(request, requestOptions);
1855
1866
  },
1856
1867
  /**
1857
- * Create or update multiple rules. If a rule with the specified object ID doesn\'t exist, Algolia creates a new one. Otherwise, existing rules are replaced.
1868
+ * Create or update multiple rules. If a rule with the specified object ID doesn\'t exist, Algolia creates a new one. Otherwise, existing rules are replaced. This operation is subject to [indexing rate limits](https://support.algolia.com/hc/en-us/articles/4406975251089-Is-there-a-rate-limit-for-indexing-on-Algolia).
1858
1869
  *
1859
1870
  * Required API Key ACLs:
1860
1871
  * - editSettings
@@ -1934,7 +1945,7 @@ function createSearchClient({
1934
1945
  return transporter.request(request, requestOptions);
1935
1946
  },
1936
1947
  /**
1937
- * If a synonym with the `objectID` doesn\'t exist, Algolia adds a new one. Otherwise, existing synonyms are replaced.
1948
+ * If a synonym with the `objectID` doesn\'t exist, Algolia adds a new one. Otherwise, existing synonyms are replaced. This operation is subject to [indexing rate limits](https://support.algolia.com/hc/en-us/articles/4406975251089-Is-there-a-rate-limit-for-indexing-on-Algolia).
1938
1949
  *
1939
1950
  * Required API Key ACLs:
1940
1951
  * - editSettings
@@ -2320,9 +2331,9 @@ function searchClient(appId, apiKey, options) {
2320
2331
  appId,
2321
2332
  apiKey,
2322
2333
  timeouts: {
2323
- connect: import_client_common2.DEFAULT_CONNECT_TIMEOUT_NODE,
2324
- read: import_client_common2.DEFAULT_READ_TIMEOUT_NODE,
2325
- write: import_client_common2.DEFAULT_WRITE_TIMEOUT_NODE
2334
+ connect: 2e3,
2335
+ read: 5e3,
2336
+ write: 3e4
2326
2337
  },
2327
2338
  logger: (0, import_client_common2.createNullLogger)(),
2328
2339
  requester: (0, import_requester_node_http.createHttpRequester)(),