@algolia/client-search 5.15.0 → 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.
- package/README.md +4 -4
- package/dist/browser.d.ts +23 -35
- package/dist/builds/browser.js +30 -22
- package/dist/builds/browser.js.map +1 -1
- package/dist/builds/browser.min.js +1 -1
- package/dist/builds/browser.min.js.map +1 -1
- package/dist/builds/browser.umd.js +2 -2
- package/dist/builds/fetch.js +30 -27
- package/dist/builds/fetch.js.map +1 -1
- package/dist/builds/node.cjs +29 -18
- package/dist/builds/node.cjs.map +1 -1
- package/dist/builds/node.js +30 -27
- package/dist/builds/node.js.map +1 -1
- package/dist/fetch.d.ts +23 -35
- package/dist/node.d.cts +23 -35
- package/dist/node.d.ts +23 -35
- package/dist/src/searchClient.cjs +26 -15
- package/dist/src/searchClient.cjs.map +1 -1
- package/dist/src/searchClient.js +26 -15
- package/dist/src/searchClient.js.map +1 -1
- package/package.json +10 -9
package/dist/src/searchClient.js
CHANGED
|
@@ -7,7 +7,7 @@ import {
|
|
|
7
7
|
getAlgoliaAgent,
|
|
8
8
|
shuffle
|
|
9
9
|
} from "@algolia/client-common";
|
|
10
|
-
var apiClientVersion = "5.
|
|
10
|
+
var apiClientVersion = "5.16.0";
|
|
11
11
|
function getDefaultHosts(appId) {
|
|
12
12
|
return [
|
|
13
13
|
{
|
|
@@ -364,11 +364,15 @@ function createSearchClient({
|
|
|
364
364
|
* @param saveObjects - The `saveObjects` object.
|
|
365
365
|
* @param saveObjects.indexName - The `indexName` to save `objects` in.
|
|
366
366
|
* @param saveObjects.objects - The array of `objects` to store in the given Algolia `indexName`.
|
|
367
|
+
* @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.
|
|
367
368
|
* @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.
|
|
368
369
|
* @param requestOptions - The requestOptions to send along with the query, they will be forwarded to the `batch` method and merged with the transporter requestOptions.
|
|
369
370
|
*/
|
|
370
|
-
async saveObjects({ indexName, objects, waitForTasks }, requestOptions) {
|
|
371
|
-
return await this.chunkedBatch(
|
|
371
|
+
async saveObjects({ indexName, objects, waitForTasks, batchSize }, requestOptions) {
|
|
372
|
+
return await this.chunkedBatch(
|
|
373
|
+
{ indexName, objects, action: "addObject", waitForTasks, batchSize },
|
|
374
|
+
requestOptions
|
|
375
|
+
);
|
|
372
376
|
},
|
|
373
377
|
/**
|
|
374
378
|
* 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.
|
|
@@ -377,16 +381,18 @@ function createSearchClient({
|
|
|
377
381
|
* @param deleteObjects - The `deleteObjects` object.
|
|
378
382
|
* @param deleteObjects.indexName - The `indexName` to delete `objectIDs` from.
|
|
379
383
|
* @param deleteObjects.objectIDs - The objectIDs to delete.
|
|
384
|
+
* @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.
|
|
380
385
|
* @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.
|
|
381
386
|
* @param requestOptions - The requestOptions to send along with the query, they will be forwarded to the `batch` method and merged with the transporter requestOptions.
|
|
382
387
|
*/
|
|
383
|
-
async deleteObjects({ indexName, objectIDs, waitForTasks }, requestOptions) {
|
|
388
|
+
async deleteObjects({ indexName, objectIDs, waitForTasks, batchSize }, requestOptions) {
|
|
384
389
|
return await this.chunkedBatch(
|
|
385
390
|
{
|
|
386
391
|
indexName,
|
|
387
392
|
objects: objectIDs.map((objectID) => ({ objectID })),
|
|
388
393
|
action: "deleteObject",
|
|
389
|
-
waitForTasks
|
|
394
|
+
waitForTasks,
|
|
395
|
+
batchSize
|
|
390
396
|
},
|
|
391
397
|
requestOptions
|
|
392
398
|
);
|
|
@@ -399,15 +405,17 @@ function createSearchClient({
|
|
|
399
405
|
* @param partialUpdateObjects.indexName - The `indexName` to update `objects` in.
|
|
400
406
|
* @param partialUpdateObjects.objects - The array of `objects` to update in the given Algolia `indexName`.
|
|
401
407
|
* @param partialUpdateObjects.createIfNotExists - To be provided if non-existing objects are passed, otherwise, the call will fail..
|
|
408
|
+
* @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
409
|
* @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.
|
|
403
410
|
* @param requestOptions - The requestOptions to send along with the query, they will be forwarded to the `getTask` method and merged with the transporter requestOptions.
|
|
404
411
|
*/
|
|
405
|
-
async partialUpdateObjects({ indexName, objects, createIfNotExists, waitForTasks }, requestOptions) {
|
|
412
|
+
async partialUpdateObjects({ indexName, objects, createIfNotExists, waitForTasks, batchSize }, requestOptions) {
|
|
406
413
|
return await this.chunkedBatch(
|
|
407
414
|
{
|
|
408
415
|
indexName,
|
|
409
416
|
objects,
|
|
410
417
|
action: createIfNotExists ? "partialUpdateObject" : "partialUpdateObjectNoCreate",
|
|
418
|
+
batchSize,
|
|
411
419
|
waitForTasks
|
|
412
420
|
},
|
|
413
421
|
requestOptions
|
|
@@ -630,7 +638,7 @@ function createSearchClient({
|
|
|
630
638
|
return transporter.request(request, requestOptions);
|
|
631
639
|
},
|
|
632
640
|
/**
|
|
633
|
-
* 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.
|
|
641
|
+
* 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).
|
|
634
642
|
* @param batch - The batch object.
|
|
635
643
|
* @param batch.indexName - Name of the index on which to perform the operation.
|
|
636
644
|
* @param batch.batchWriteParams - The batchWriteParams object.
|
|
@@ -761,7 +769,7 @@ function createSearchClient({
|
|
|
761
769
|
return transporter.request(request, requestOptions);
|
|
762
770
|
},
|
|
763
771
|
/**
|
|
764
|
-
* Deletes only the records from an index while keeping settings, synonyms, and rules.
|
|
772
|
+
* 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).
|
|
765
773
|
*
|
|
766
774
|
* Required API Key ACLs:
|
|
767
775
|
* - deleteIndex
|
|
@@ -957,7 +965,7 @@ function createSearchClient({
|
|
|
957
965
|
return transporter.request(request, requestOptions);
|
|
958
966
|
},
|
|
959
967
|
/**
|
|
960
|
-
* This operation doesn\'t accept empty
|
|
968
|
+
* 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).
|
|
961
969
|
*
|
|
962
970
|
* Required API Key ACLs:
|
|
963
971
|
* - deleteIndex
|
|
@@ -1594,7 +1602,7 @@ function createSearchClient({
|
|
|
1594
1602
|
return transporter.request(request, requestOptions);
|
|
1595
1603
|
},
|
|
1596
1604
|
/**
|
|
1597
|
-
* 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.
|
|
1605
|
+
* 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).
|
|
1598
1606
|
* @param batchParams - The batchParams object.
|
|
1599
1607
|
* @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
|
|
1600
1608
|
*/
|
|
@@ -1618,7 +1626,7 @@ function createSearchClient({
|
|
|
1618
1626
|
return transporter.request(request, requestOptions);
|
|
1619
1627
|
},
|
|
1620
1628
|
/**
|
|
1621
|
-
* 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/).
|
|
1629
|
+
* 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).
|
|
1622
1630
|
*
|
|
1623
1631
|
* Required API Key ACLs:
|
|
1624
1632
|
* - addObject
|
|
@@ -1653,7 +1661,7 @@ function createSearchClient({
|
|
|
1653
1661
|
return transporter.request(request, requestOptions);
|
|
1654
1662
|
},
|
|
1655
1663
|
/**
|
|
1656
|
-
* 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,
|
|
1664
|
+
* 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).
|
|
1657
1665
|
*
|
|
1658
1666
|
* Required API Key ACLs:
|
|
1659
1667
|
* - addObject
|
|
@@ -1763,7 +1771,7 @@ function createSearchClient({
|
|
|
1763
1771
|
return transporter.request(request, requestOptions);
|
|
1764
1772
|
},
|
|
1765
1773
|
/**
|
|
1766
|
-
* 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).
|
|
1774
|
+
* 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).
|
|
1767
1775
|
*
|
|
1768
1776
|
* Required API Key ACLs:
|
|
1769
1777
|
* - addObject
|
|
@@ -1816,6 +1824,9 @@ function createSearchClient({
|
|
|
1816
1824
|
if (!rule.objectID) {
|
|
1817
1825
|
throw new Error("Parameter `rule.objectID` is required when calling `saveRule`.");
|
|
1818
1826
|
}
|
|
1827
|
+
if (!rule.consequence) {
|
|
1828
|
+
throw new Error("Parameter `rule.consequence` is required when calling `saveRule`.");
|
|
1829
|
+
}
|
|
1819
1830
|
const requestPath = "/1/indexes/{indexName}/rules/{objectID}".replace("{indexName}", encodeURIComponent(indexName)).replace("{objectID}", encodeURIComponent(objectID));
|
|
1820
1831
|
const headers = {};
|
|
1821
1832
|
const queryParameters = {};
|
|
@@ -1832,7 +1843,7 @@ function createSearchClient({
|
|
|
1832
1843
|
return transporter.request(request, requestOptions);
|
|
1833
1844
|
},
|
|
1834
1845
|
/**
|
|
1835
|
-
* 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.
|
|
1846
|
+
* 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).
|
|
1836
1847
|
*
|
|
1837
1848
|
* Required API Key ACLs:
|
|
1838
1849
|
* - editSettings
|
|
@@ -1912,7 +1923,7 @@ function createSearchClient({
|
|
|
1912
1923
|
return transporter.request(request, requestOptions);
|
|
1913
1924
|
},
|
|
1914
1925
|
/**
|
|
1915
|
-
* If a synonym with the `objectID` doesn\'t exist, Algolia adds a new one. Otherwise, existing synonyms are replaced.
|
|
1926
|
+
* 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).
|
|
1916
1927
|
*
|
|
1917
1928
|
* Required API Key ACLs:
|
|
1918
1929
|
* - editSettings
|