@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.
@@ -1,14 +1,6 @@
1
1
  // builds/node.ts
2
2
  import { createHttpRequester } from "@algolia/requester-node-http";
3
- import {
4
- createMemoryCache,
5
- createNullCache,
6
- createNullLogger,
7
- DEFAULT_CONNECT_TIMEOUT_NODE,
8
- DEFAULT_READ_TIMEOUT_NODE,
9
- DEFAULT_WRITE_TIMEOUT_NODE,
10
- serializeQueryParameters
11
- } from "@algolia/client-common";
3
+ import { createMemoryCache, createNullCache, createNullLogger, serializeQueryParameters } from "@algolia/client-common";
12
4
 
13
5
  // src/searchClient.ts
14
6
  import {
@@ -19,7 +11,7 @@ import {
19
11
  getAlgoliaAgent,
20
12
  shuffle
21
13
  } from "@algolia/client-common";
22
- var apiClientVersion = "5.14.2";
14
+ var apiClientVersion = "5.16.0";
23
15
  function getDefaultHosts(appId) {
24
16
  return [
25
17
  {
@@ -376,11 +368,15 @@ function createSearchClient({
376
368
  * @param saveObjects - The `saveObjects` object.
377
369
  * @param saveObjects.indexName - The `indexName` to save `objects` in.
378
370
  * @param saveObjects.objects - The array of `objects` to store in the given Algolia `indexName`.
371
+ * @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.
379
372
  * @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.
380
373
  * @param requestOptions - The requestOptions to send along with the query, they will be forwarded to the `batch` method and merged with the transporter requestOptions.
381
374
  */
382
- async saveObjects({ indexName, objects, waitForTasks }, requestOptions) {
383
- return await this.chunkedBatch({ indexName, objects, action: "addObject", waitForTasks }, requestOptions);
375
+ async saveObjects({ indexName, objects, waitForTasks, batchSize }, requestOptions) {
376
+ return await this.chunkedBatch(
377
+ { indexName, objects, action: "addObject", waitForTasks, batchSize },
378
+ requestOptions
379
+ );
384
380
  },
385
381
  /**
386
382
  * 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.
@@ -389,16 +385,18 @@ function createSearchClient({
389
385
  * @param deleteObjects - The `deleteObjects` object.
390
386
  * @param deleteObjects.indexName - The `indexName` to delete `objectIDs` from.
391
387
  * @param deleteObjects.objectIDs - The objectIDs to delete.
388
+ * @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.
392
389
  * @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.
393
390
  * @param requestOptions - The requestOptions to send along with the query, they will be forwarded to the `batch` method and merged with the transporter requestOptions.
394
391
  */
395
- async deleteObjects({ indexName, objectIDs, waitForTasks }, requestOptions) {
392
+ async deleteObjects({ indexName, objectIDs, waitForTasks, batchSize }, requestOptions) {
396
393
  return await this.chunkedBatch(
397
394
  {
398
395
  indexName,
399
396
  objects: objectIDs.map((objectID) => ({ objectID })),
400
397
  action: "deleteObject",
401
- waitForTasks
398
+ waitForTasks,
399
+ batchSize
402
400
  },
403
401
  requestOptions
404
402
  );
@@ -411,15 +409,17 @@ function createSearchClient({
411
409
  * @param partialUpdateObjects.indexName - The `indexName` to update `objects` in.
412
410
  * @param partialUpdateObjects.objects - The array of `objects` to update in the given Algolia `indexName`.
413
411
  * @param partialUpdateObjects.createIfNotExists - To be provided if non-existing objects are passed, otherwise, the call will fail..
412
+ * @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.
414
413
  * @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.
415
414
  * @param requestOptions - The requestOptions to send along with the query, they will be forwarded to the `getTask` method and merged with the transporter requestOptions.
416
415
  */
417
- async partialUpdateObjects({ indexName, objects, createIfNotExists, waitForTasks }, requestOptions) {
416
+ async partialUpdateObjects({ indexName, objects, createIfNotExists, waitForTasks, batchSize }, requestOptions) {
418
417
  return await this.chunkedBatch(
419
418
  {
420
419
  indexName,
421
420
  objects,
422
421
  action: createIfNotExists ? "partialUpdateObject" : "partialUpdateObjectNoCreate",
422
+ batchSize,
423
423
  waitForTasks
424
424
  },
425
425
  requestOptions
@@ -642,7 +642,7 @@ function createSearchClient({
642
642
  return transporter.request(request, requestOptions);
643
643
  },
644
644
  /**
645
- * 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.
645
+ * 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).
646
646
  * @param batch - The batch object.
647
647
  * @param batch.indexName - Name of the index on which to perform the operation.
648
648
  * @param batch.batchWriteParams - The batchWriteParams object.
@@ -773,7 +773,7 @@ function createSearchClient({
773
773
  return transporter.request(request, requestOptions);
774
774
  },
775
775
  /**
776
- * Deletes only the records from an index while keeping settings, synonyms, and rules.
776
+ * 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).
777
777
  *
778
778
  * Required API Key ACLs:
779
779
  * - deleteIndex
@@ -969,7 +969,7 @@ function createSearchClient({
969
969
  return transporter.request(request, requestOptions);
970
970
  },
971
971
  /**
972
- * 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).
972
+ * 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).
973
973
  *
974
974
  * Required API Key ACLs:
975
975
  * - deleteIndex
@@ -1606,7 +1606,7 @@ function createSearchClient({
1606
1606
  return transporter.request(request, requestOptions);
1607
1607
  },
1608
1608
  /**
1609
- * 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.
1609
+ * 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).
1610
1610
  * @param batchParams - The batchParams object.
1611
1611
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
1612
1612
  */
@@ -1630,7 +1630,7 @@ function createSearchClient({
1630
1630
  return transporter.request(request, requestOptions);
1631
1631
  },
1632
1632
  /**
1633
- * 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/).
1633
+ * 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).
1634
1634
  *
1635
1635
  * Required API Key ACLs:
1636
1636
  * - addObject
@@ -1665,7 +1665,7 @@ function createSearchClient({
1665
1665
  return transporter.request(request, requestOptions);
1666
1666
  },
1667
1667
  /**
1668
- * 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.
1668
+ * 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).
1669
1669
  *
1670
1670
  * Required API Key ACLs:
1671
1671
  * - addObject
@@ -1775,7 +1775,7 @@ function createSearchClient({
1775
1775
  return transporter.request(request, requestOptions);
1776
1776
  },
1777
1777
  /**
1778
- * 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).
1778
+ * 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).
1779
1779
  *
1780
1780
  * Required API Key ACLs:
1781
1781
  * - addObject
@@ -1828,6 +1828,9 @@ function createSearchClient({
1828
1828
  if (!rule.objectID) {
1829
1829
  throw new Error("Parameter `rule.objectID` is required when calling `saveRule`.");
1830
1830
  }
1831
+ if (!rule.consequence) {
1832
+ throw new Error("Parameter `rule.consequence` is required when calling `saveRule`.");
1833
+ }
1831
1834
  const requestPath = "/1/indexes/{indexName}/rules/{objectID}".replace("{indexName}", encodeURIComponent(indexName)).replace("{objectID}", encodeURIComponent(objectID));
1832
1835
  const headers = {};
1833
1836
  const queryParameters = {};
@@ -1844,7 +1847,7 @@ function createSearchClient({
1844
1847
  return transporter.request(request, requestOptions);
1845
1848
  },
1846
1849
  /**
1847
- * 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.
1850
+ * 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).
1848
1851
  *
1849
1852
  * Required API Key ACLs:
1850
1853
  * - editSettings
@@ -1924,7 +1927,7 @@ function createSearchClient({
1924
1927
  return transporter.request(request, requestOptions);
1925
1928
  },
1926
1929
  /**
1927
- * If a synonym with the `objectID` doesn\'t exist, Algolia adds a new one. Otherwise, existing synonyms are replaced.
1930
+ * 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).
1928
1931
  *
1929
1932
  * Required API Key ACLs:
1930
1933
  * - editSettings
@@ -2310,9 +2313,9 @@ function searchClient(appId, apiKey, options) {
2310
2313
  appId,
2311
2314
  apiKey,
2312
2315
  timeouts: {
2313
- connect: DEFAULT_CONNECT_TIMEOUT_NODE,
2314
- read: DEFAULT_READ_TIMEOUT_NODE,
2315
- write: DEFAULT_WRITE_TIMEOUT_NODE
2316
+ connect: 2e3,
2317
+ read: 5e3,
2318
+ write: 3e4
2316
2319
  },
2317
2320
  logger: createNullLogger(),
2318
2321
  requester: createHttpRequester(),