@algolia/client-search 5.0.0-alpha.2 → 5.0.0-alpha.5

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.
Files changed (214) hide show
  1. package/dist/builds/browser.d.ts +2 -2
  2. package/dist/builds/browser.d.ts.map +1 -1
  3. package/dist/builds/node.d.ts +2 -2
  4. package/dist/builds/node.d.ts.map +1 -1
  5. package/dist/client-search.cjs.js +148 -26
  6. package/dist/client-search.esm.browser.js +176 -54
  7. package/dist/client-search.esm.node.js +149 -27
  8. package/dist/client-search.umd.js +2 -2
  9. package/dist/model/acl.d.ts +3 -0
  10. package/dist/model/acl.d.ts.map +1 -1
  11. package/dist/model/addApiKeyResponse.d.ts +1 -1
  12. package/dist/model/addApiKeyResponse.d.ts.map +1 -1
  13. package/dist/model/apiKey.d.ts.map +1 -1
  14. package/dist/model/attributeToUpdate.d.ts +3 -0
  15. package/dist/model/attributeToUpdate.d.ts.map +1 -0
  16. package/dist/model/automaticFacetFilter.d.ts.map +1 -1
  17. package/dist/model/baseGetApiKeyResponse.d.ts +11 -0
  18. package/dist/model/baseGetApiKeyResponse.d.ts.map +1 -0
  19. package/dist/model/baseIndexSettings.d.ts.map +1 -1
  20. package/dist/model/baseSearchParamsWithoutQuery.d.ts.map +1 -1
  21. package/dist/model/baseSearchResponse.d.ts.map +1 -1
  22. package/dist/model/batchAssignUserIdsParams.d.ts.map +1 -1
  23. package/dist/model/batchDictionaryEntriesParams.d.ts.map +1 -1
  24. package/dist/model/batchDictionaryEntriesRequest.d.ts.map +1 -1
  25. package/dist/model/batchParams.d.ts +2 -2
  26. package/dist/model/batchParams.d.ts.map +1 -1
  27. package/dist/model/{batchOperation.d.ts → batchRequest.d.ts} +2 -2
  28. package/dist/model/batchRequest.d.ts.map +1 -0
  29. package/dist/model/batchResponse.d.ts.map +1 -1
  30. package/dist/model/batchWriteParams.d.ts +2 -2
  31. package/dist/model/batchWriteParams.d.ts.map +1 -1
  32. package/dist/model/browseRequest.d.ts.map +1 -1
  33. package/dist/model/browseResponse.d.ts +1 -1
  34. package/dist/model/browseResponse.d.ts.map +1 -1
  35. package/dist/model/builtInOperation.d.ts.map +1 -1
  36. package/dist/model/clientMethodProps.d.ts +22 -11
  37. package/dist/model/clientMethodProps.d.ts.map +1 -1
  38. package/dist/model/condition.d.ts.map +1 -1
  39. package/dist/model/consequence.d.ts.map +1 -1
  40. package/dist/model/consequenceQueryObject.d.ts.map +1 -1
  41. package/dist/model/deletedAtResponse.d.ts.map +1 -1
  42. package/dist/model/dictionaryEntry.d.ts.map +1 -1
  43. package/dist/model/distinct.d.ts +5 -0
  44. package/dist/model/distinct.d.ts.map +1 -0
  45. package/dist/model/edit.d.ts.map +1 -1
  46. package/dist/model/facetHits.d.ts.map +1 -1
  47. package/dist/model/facetOrdering.d.ts.map +1 -1
  48. package/dist/model/facetsStats.d.ts.map +1 -1
  49. package/dist/model/fetchedIndex.d.ts.map +1 -1
  50. package/dist/model/getApiKeyResponse.d.ts +4 -0
  51. package/dist/model/getApiKeyResponse.d.ts.map +1 -0
  52. package/dist/model/getObjectsParams.d.ts +2 -2
  53. package/dist/model/getObjectsParams.d.ts.map +1 -1
  54. package/dist/model/{multipleGetObjectsParams.d.ts → getObjectsRequest.d.ts} +2 -2
  55. package/dist/model/getObjectsRequest.d.ts.map +1 -0
  56. package/dist/model/getObjectsResponse.d.ts +2 -2
  57. package/dist/model/getObjectsResponse.d.ts.map +1 -1
  58. package/dist/model/hasPendingMappingsResponse.d.ts.map +1 -1
  59. package/dist/model/highlightResultOption.d.ts.map +1 -1
  60. package/dist/model/hit.d.ts +1 -1
  61. package/dist/model/hit.d.ts.map +1 -1
  62. package/dist/model/index.d.ts +7 -6
  63. package/dist/model/index.d.ts.map +1 -1
  64. package/dist/model/indexSettingsAsSearchParams.d.ts +2 -4
  65. package/dist/model/indexSettingsAsSearchParams.d.ts.map +1 -1
  66. package/dist/model/languages.d.ts.map +1 -1
  67. package/dist/model/listApiKeysResponse.d.ts +2 -2
  68. package/dist/model/listApiKeysResponse.d.ts.map +1 -1
  69. package/dist/model/listIndicesResponse.d.ts +1 -1
  70. package/dist/model/listIndicesResponse.d.ts.map +1 -1
  71. package/dist/model/log.d.ts.map +1 -1
  72. package/dist/model/logQuery.d.ts.map +1 -1
  73. package/dist/model/matchedGeoLocation.d.ts.map +1 -1
  74. package/dist/model/{multipleBatchOperation.d.ts → multipleBatchRequest.d.ts} +5 -5
  75. package/dist/model/multipleBatchRequest.d.ts.map +1 -0
  76. package/dist/model/multipleBatchResponse.d.ts +2 -2
  77. package/dist/model/multipleBatchResponse.d.ts.map +1 -1
  78. package/dist/model/operationIndexParams.d.ts.map +1 -1
  79. package/dist/model/params.d.ts.map +1 -1
  80. package/dist/model/personalization.d.ts.map +1 -1
  81. package/dist/model/promoteObjectID.d.ts.map +1 -1
  82. package/dist/model/promoteObjectIDs.d.ts.map +1 -1
  83. package/dist/model/rankingInfo.d.ts.map +1 -1
  84. package/dist/model/rule.d.ts.map +1 -1
  85. package/dist/model/saveObjectResponse.d.ts +2 -2
  86. package/dist/model/saveObjectResponse.d.ts.map +1 -1
  87. package/dist/model/saveSynonymResponse.d.ts.map +1 -1
  88. package/dist/model/searchDictionaryEntriesParams.d.ts.map +1 -1
  89. package/dist/model/searchForFacetValuesRequest.d.ts.map +1 -1
  90. package/dist/model/searchForFacetsOptions.d.ts.map +1 -1
  91. package/dist/model/searchForHitsOptions.d.ts.map +1 -1
  92. package/dist/model/searchHits.d.ts +1 -1
  93. package/dist/model/searchHits.d.ts.map +1 -1
  94. package/dist/model/searchMethodParams.d.ts.map +1 -1
  95. package/dist/model/searchResponse.d.ts +1 -1
  96. package/dist/model/searchResponse.d.ts.map +1 -1
  97. package/dist/model/searchResponses.d.ts +1 -1
  98. package/dist/model/searchResponses.d.ts.map +1 -1
  99. package/dist/model/searchRulesParams.d.ts.map +1 -1
  100. package/dist/model/searchRulesResponse.d.ts.map +1 -1
  101. package/dist/model/searchSynonymsResponse.d.ts.map +1 -1
  102. package/dist/model/searchUserIdsParams.d.ts.map +1 -1
  103. package/dist/model/searchUserIdsResponse.d.ts.map +1 -1
  104. package/dist/model/snippetResultOption.d.ts.map +1 -1
  105. package/dist/model/source.d.ts.map +1 -1
  106. package/dist/model/standardEntries.d.ts.map +1 -1
  107. package/dist/model/synonymHit.d.ts.map +1 -1
  108. package/dist/model/synonymHitHighlightResult.d.ts.map +1 -1
  109. package/dist/model/timeRange.d.ts.map +1 -1
  110. package/dist/model/updateApiKeyResponse.d.ts +1 -1
  111. package/dist/model/updateApiKeyResponse.d.ts.map +1 -1
  112. package/dist/model/updatedAtResponse.d.ts.map +1 -1
  113. package/dist/model/updatedAtWithObjectIdResponse.d.ts.map +1 -1
  114. package/dist/model/updatedRuleResponse.d.ts.map +1 -1
  115. package/dist/model/userHighlightResult.d.ts.map +1 -1
  116. package/dist/model/userHit.d.ts.map +1 -1
  117. package/dist/model/userId.d.ts.map +1 -1
  118. package/dist/model/value.d.ts.map +1 -1
  119. package/dist/src/searchClient.d.ts +64 -17
  120. package/dist/src/searchClient.d.ts.map +1 -1
  121. package/model/acl.ts +3 -0
  122. package/model/addApiKeyResponse.ts +2 -1
  123. package/model/apiKey.ts +7 -0
  124. package/model/{attributeOrBuiltInOperation.ts → attributeToUpdate.ts} +1 -1
  125. package/model/automaticFacetFilter.ts +2 -0
  126. package/model/baseGetApiKeyResponse.ts +13 -0
  127. package/model/baseIndexSettings.ts +13 -0
  128. package/model/baseSearchParamsWithoutQuery.ts +32 -0
  129. package/model/baseSearchResponse.ts +24 -0
  130. package/model/batchAssignUserIdsParams.ts +1 -0
  131. package/model/batchDictionaryEntriesParams.ts +1 -0
  132. package/model/batchDictionaryEntriesRequest.ts +1 -0
  133. package/model/batchParams.ts +2 -2
  134. package/model/{batchOperation.ts → batchRequest.ts} +2 -1
  135. package/model/batchResponse.ts +1 -0
  136. package/model/batchWriteParams.ts +2 -2
  137. package/model/browseRequest.ts +1 -0
  138. package/model/browseResponse.ts +1 -1
  139. package/model/builtInOperation.ts +1 -0
  140. package/model/clientMethodProps.ts +27 -16
  141. package/model/condition.ts +3 -0
  142. package/model/consequence.ts +4 -0
  143. package/model/consequenceQueryObject.ts +1 -0
  144. package/model/deletedAtResponse.ts +1 -0
  145. package/model/dictionaryEntry.ts +5 -0
  146. package/model/{createdAtObject.ts → distinct.ts} +4 -6
  147. package/model/edit.ts +2 -0
  148. package/model/facetHits.ts +2 -0
  149. package/model/facetOrdering.ts +1 -0
  150. package/model/facetsStats.ts +3 -0
  151. package/model/fetchedIndex.ts +10 -0
  152. package/model/{key.ts → getApiKeyResponse.ts} +2 -2
  153. package/model/getObjectsParams.ts +2 -2
  154. package/model/{multipleGetObjectsParams.ts → getObjectsRequest.ts} +3 -1
  155. package/model/getObjectsResponse.ts +2 -2
  156. package/model/hasPendingMappingsResponse.ts +1 -0
  157. package/model/highlightResultOption.ts +3 -0
  158. package/model/hit.ts +5 -1
  159. package/model/index.ts +7 -6
  160. package/model/indexSettingsAsSearchParams.ts +43 -4
  161. package/model/languages.ts +2 -0
  162. package/model/listApiKeysResponse.ts +2 -2
  163. package/model/listIndicesResponse.ts +2 -1
  164. package/model/log.ts +14 -0
  165. package/model/logQuery.ts +2 -0
  166. package/model/matchedGeoLocation.ts +2 -0
  167. package/model/{multipleBatchOperation.ts → multipleBatchRequest.ts} +6 -4
  168. package/model/multipleBatchResponse.ts +3 -2
  169. package/model/operationIndexParams.ts +2 -0
  170. package/model/params.ts +3 -0
  171. package/model/personalization.ts +2 -0
  172. package/model/promoteObjectID.ts +1 -0
  173. package/model/promoteObjectIDs.ts +1 -0
  174. package/model/rankingInfo.ts +12 -0
  175. package/model/rule.ts +5 -0
  176. package/model/saveObjectResponse.ts +4 -2
  177. package/model/saveSynonymResponse.ts +2 -0
  178. package/model/searchDictionaryEntriesParams.ts +3 -0
  179. package/model/searchForFacetValuesRequest.ts +2 -0
  180. package/model/searchForFacetsOptions.ts +4 -0
  181. package/model/searchForHitsOptions.ts +1 -0
  182. package/model/searchHits.ts +1 -1
  183. package/model/searchMethodParams.ts +1 -0
  184. package/model/searchResponse.ts +2 -1
  185. package/model/searchResponses.ts +1 -1
  186. package/model/searchRulesParams.ts +6 -0
  187. package/model/searchRulesResponse.ts +3 -0
  188. package/model/searchSynonymsResponse.ts +1 -0
  189. package/model/searchUserIdsParams.ts +3 -0
  190. package/model/searchUserIdsResponse.ts +4 -0
  191. package/model/snippetResultOption.ts +1 -0
  192. package/model/source.ts +1 -0
  193. package/model/standardEntries.ts +2 -0
  194. package/model/synonymHit.ts +8 -0
  195. package/model/synonymHitHighlightResult.ts +1 -0
  196. package/model/timeRange.ts +1 -0
  197. package/model/updateApiKeyResponse.ts +2 -1
  198. package/model/updatedAtResponse.ts +1 -0
  199. package/model/updatedAtWithObjectIdResponse.ts +2 -0
  200. package/model/updatedRuleResponse.ts +2 -0
  201. package/model/userHighlightResult.ts +1 -0
  202. package/model/userHit.ts +5 -0
  203. package/model/userId.ts +3 -0
  204. package/model/value.ts +1 -0
  205. package/package.json +5 -5
  206. package/dist/model/attributeOrBuiltInOperation.d.ts +0 -3
  207. package/dist/model/attributeOrBuiltInOperation.d.ts.map +0 -1
  208. package/dist/model/batchOperation.d.ts.map +0 -1
  209. package/dist/model/createdAtObject.d.ts +0 -7
  210. package/dist/model/createdAtObject.d.ts.map +0 -1
  211. package/dist/model/key.d.ts +0 -4
  212. package/dist/model/key.d.ts.map +0 -1
  213. package/dist/model/multipleBatchOperation.d.ts.map +0 -1
  214. package/dist/model/multipleGetObjectsParams.d.ts.map +0 -1
@@ -1,6 +1,6 @@
1
- import type { InitClientOptions } from '@algolia/client-common';
1
+ import type { ClientOptions } from '@algolia/client-common';
2
2
  import type { SearchClient } from '../src/searchClient';
3
3
  export { apiClientVersion, SearchClient } from '../src/searchClient';
4
4
  export * from '../model';
5
- export declare function searchClient(appId: string, apiKey: string, options?: InitClientOptions): SearchClient;
5
+ export declare function searchClient(appId: string, apiKey: string, options?: ClientOptions): SearchClient;
6
6
  //# sourceMappingURL=browser.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"browser.d.ts","sourceRoot":"","sources":["../../../../packages/client-search/builds/browser.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAYhE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAExD,OAAO,EAAE,gBAAgB,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACrE,cAAc,UAAU,CAAC;AAEzB,wBAAgB,YAAY,CAC1B,KAAK,EAAE,MAAM,EACb,MAAM,EAAE,MAAM,EACd,OAAO,CAAC,EAAE,iBAAiB,GAC1B,YAAY,CA8Bd"}
1
+ {"version":3,"file":"browser.d.ts","sourceRoot":"","sources":["../../../../packages/client-search/builds/browser.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AAY5D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAExD,OAAO,EAAE,gBAAgB,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACrE,cAAc,UAAU,CAAC;AAEzB,wBAAgB,YAAY,CAC1B,KAAK,EAAE,MAAM,EACb,MAAM,EAAE,MAAM,EACd,OAAO,CAAC,EAAE,aAAa,GACtB,YAAY,CA8Bd"}
@@ -1,6 +1,6 @@
1
- import type { InitClientOptions } from '@algolia/client-common';
1
+ import type { ClientOptions } from '@algolia/client-common';
2
2
  import type { SearchClient } from '../src/searchClient';
3
3
  export { apiClientVersion, SearchClient } from '../src/searchClient';
4
4
  export * from '../model';
5
- export declare function searchClient(appId: string, apiKey: string, options?: InitClientOptions): SearchClient;
5
+ export declare function searchClient(appId: string, apiKey: string, options?: ClientOptions): SearchClient;
6
6
  //# sourceMappingURL=node.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"node.d.ts","sourceRoot":"","sources":["../../../../packages/client-search/builds/node.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAWhE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAExD,OAAO,EAAE,gBAAgB,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACrE,cAAc,UAAU,CAAC;AAEzB,wBAAgB,YAAY,CAC1B,KAAK,EAAE,MAAM,EACb,MAAM,EAAE,MAAM,EACd,OAAO,CAAC,EAAE,iBAAiB,GAC1B,YAAY,CAwBd"}
1
+ {"version":3,"file":"node.d.ts","sourceRoot":"","sources":["../../../../packages/client-search/builds/node.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AAW5D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAExD,OAAO,EAAE,gBAAgB,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACrE,cAAc,UAAU,CAAC;AAEzB,wBAAgB,YAAY,CAC1B,KAAK,EAAE,MAAM,EACb,MAAM,EAAE,MAAM,EACd,OAAO,CAAC,EAAE,aAAa,GACtB,YAAY,CAwBd"}
@@ -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.2';
9
+ const apiClientVersion = '5.0.0-alpha.5';
10
10
  function getDefaultHosts(appId) {
11
11
  return [
12
12
  {
@@ -60,6 +60,19 @@ function createSearchClient({ appId: appIdOption, apiKey: apiKeyOption, authMode
60
60
  });
61
61
  return {
62
62
  transporter,
63
+ /**
64
+ * The `appId` currently in use.
65
+ */
66
+ appId: appIdOption,
67
+ /**
68
+ * Clears the cache of the transporter for the `requestsCache` and `responsesCache` properties.
69
+ */
70
+ clearCache() {
71
+ return Promise.all([
72
+ transporter.requestsCache.clear(),
73
+ transporter.responsesCache.clear(),
74
+ ]).then(() => undefined);
75
+ },
63
76
  /**
64
77
  * Get the value of the `algoliaAgent`, used by our libraries internally and telemetry system.
65
78
  */
@@ -76,38 +89,57 @@ function createSearchClient({ appId: appIdOption, apiKey: apiKeyOption, authMode
76
89
  transporter.algoliaAgent.add({ segment, version });
77
90
  },
78
91
  /**
79
- * Helper: Wait for a task to complete with `indexName` and `taskID`.
92
+ * Helper: Wait for a task to be published (completed) for a given `indexName` and `taskID`.
80
93
  *
81
- * @summary Wait for a task to complete.
94
+ * @summary Helper method that waits for a task to be published (completed).
82
95
  * @param waitForTaskOptions - The waitForTaskOptions object.
83
96
  * @param waitForTaskOptions.indexName - The `indexName` where the operation was performed.
84
97
  * @param waitForTaskOptions.taskID - The `taskID` returned in the method response.
98
+ * @param waitForTaskOptions.maxRetries - The maximum number of retries. 50 by default.
99
+ * @param waitForTaskOptions.timeout - The function to decide how long to wait between retries.
85
100
  * @param requestOptions - The requestOptions to send along with the query, they will be forwarded to the `getTask` method and merged with the transporter requestOptions.
86
101
  */
87
- waitForTask({ indexName, taskID, ...createRetryablePromiseOptions }, requestOptions) {
88
- return clientCommon.createRetryablePromise({
89
- ...createRetryablePromiseOptions,
102
+ waitForTask({ indexName, taskID, maxRetries = 50, timeout = (retryCount) => Math.min(retryCount * 200, 5000), }, requestOptions) {
103
+ let retryCount = 0;
104
+ return clientCommon.createIterablePromise({
90
105
  func: () => this.getTask({ indexName, taskID }, requestOptions),
91
106
  validate: (response) => response.status === 'published',
107
+ aggregator: () => (retryCount += 1),
108
+ error: {
109
+ validate: () => retryCount >= maxRetries,
110
+ message: () => `The maximum number of retries exceeded. (${retryCount}/${maxRetries})`,
111
+ },
112
+ timeout: () => timeout(retryCount),
92
113
  });
93
114
  },
94
115
  /**
95
116
  * Helper: Wait for an API key to be added, updated or deleted based on a given `operation`.
96
117
  *
97
- * @summary Wait for an API key task to be processed.
118
+ * @summary Helper method that waits for an API key task to be processed.
98
119
  * @param waitForApiKeyOptions - The waitForApiKeyOptions object.
99
120
  * @param waitForApiKeyOptions.operation - The `operation` that was done on a `key`.
100
121
  * @param waitForApiKeyOptions.key - The `key` that has been added, deleted or updated.
101
122
  * @param waitForApiKeyOptions.apiKey - Necessary to know if an `update` operation has been processed, compare fields of the response with it.
123
+ * @param waitForApiKeyOptions.maxRetries - The maximum number of retries. 50 by default.
124
+ * @param waitForApiKeyOptions.timeout - The function to decide how long to wait between retries.
102
125
  * @param requestOptions - The requestOptions to send along with the query, they will be forwarded to the `getApikey` method and merged with the transporter requestOptions.
103
126
  */
104
- waitForApiKey({ operation, key, apiKey, ...createRetryablePromiseOptions }, requestOptions) {
127
+ waitForApiKey({ operation, key, apiKey, maxRetries = 50, timeout = (retryCount) => Math.min(retryCount * 200, 5000), }, requestOptions) {
128
+ let retryCount = 0;
129
+ const baseIteratorOptions = {
130
+ aggregator: () => (retryCount += 1),
131
+ error: {
132
+ validate: () => retryCount >= maxRetries,
133
+ message: () => `The maximum number of retries exceeded. (${retryCount}/${maxRetries})`,
134
+ },
135
+ timeout: () => timeout(retryCount),
136
+ };
105
137
  if (operation === 'update') {
106
138
  if (!apiKey) {
107
139
  throw new Error('`apiKey` is required when waiting for an `update` operation.');
108
140
  }
109
- return clientCommon.createRetryablePromise({
110
- ...createRetryablePromiseOptions,
141
+ return clientCommon.createIterablePromise({
142
+ ...baseIteratorOptions,
111
143
  func: () => this.getApiKey({ key }, requestOptions),
112
144
  validate: (response) => {
113
145
  for (const field of Object.keys(apiKey)) {
@@ -125,12 +157,99 @@ function createSearchClient({ appId: appIdOption, apiKey: apiKeyOption, authMode
125
157
  },
126
158
  });
127
159
  }
128
- return clientCommon.createRetryablePromise({
129
- ...createRetryablePromiseOptions,
160
+ return clientCommon.createIterablePromise({
161
+ ...baseIteratorOptions,
130
162
  func: () => this.getApiKey({ key }, requestOptions).catch((error) => error),
131
163
  validate: (error) => operation === 'add' ? error.status !== 404 : error.status === 404,
132
164
  });
133
165
  },
166
+ /**
167
+ * Helper: Iterate on the `browse` method of the client to allow aggregating objects of an index.
168
+ *
169
+ * @summary Helper method that iterates on the `browse` method.
170
+ * @param browseObjects - The browseObjects object.
171
+ * @param browseObjects.indexName - The index in which to perform the request.
172
+ * @param browseObjects.browseRequest - The `browse` method 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
+ * @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
+ * @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
+ */
177
+ browseObjects({ indexName, browseRequest, ...browseObjectsOptions }, requestOptions) {
178
+ return clientCommon.createIterablePromise({
179
+ func: (previousResponse) => {
180
+ return this.browse({
181
+ indexName,
182
+ browseRequest: {
183
+ cursor: previousResponse ? previousResponse.cursor : undefined,
184
+ ...browseRequest,
185
+ },
186
+ }, requestOptions);
187
+ },
188
+ validate: (response) => response.cursor === undefined,
189
+ ...browseObjectsOptions,
190
+ });
191
+ },
192
+ /**
193
+ * Helper: Iterate on the `searchRules` method of the client to allow aggregating rules of an index.
194
+ *
195
+ * @summary Helper method that iterates on the `searchRules` method.
196
+ * @param browseObjects - The browseObjects object.
197
+ * @param browseObjects.indexName - The index in which to perform the request.
198
+ * @param browseObjects.searchRulesParams - The `searchRules` method parameters.
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
+ * @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
+ * @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
+ */
203
+ browseRules({ indexName, searchRulesParams, ...browseRulesOptions }, requestOptions) {
204
+ const params = {
205
+ hitsPerPage: 1000,
206
+ ...searchRulesParams,
207
+ };
208
+ return clientCommon.createIterablePromise({
209
+ func: (previousResponse) => {
210
+ return this.searchRules({
211
+ indexName,
212
+ searchRulesParams: {
213
+ ...params,
214
+ page: previousResponse
215
+ ? previousResponse.page + 1
216
+ : params.page || 0,
217
+ },
218
+ }, requestOptions);
219
+ },
220
+ validate: (response) => response.nbHits < params.hitsPerPage,
221
+ ...browseRulesOptions,
222
+ });
223
+ },
224
+ /**
225
+ * Helper: Iterate on the `searchSynonyms` method of the client to allow aggregating rules of an index.
226
+ *
227
+ * @summary Helper method that iterates on the `searchSynonyms` method.
228
+ * @param browseObjects - The browseObjects object.
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. By default, stops when there is less hits returned than the number of maximum hits (1000).
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
+ * @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
+ */
234
+ browseSynonyms({ indexName, validate, aggregator, ...browseSynonymsOptions }, requestOptions) {
235
+ const params = {
236
+ hitsPerPage: 1000,
237
+ ...browseSynonymsOptions,
238
+ };
239
+ return clientCommon.createIterablePromise({
240
+ func: (previousResponse) => {
241
+ return this.searchSynonyms({
242
+ ...params,
243
+ indexName,
244
+ page: previousResponse
245
+ ? previousResponse.page + 1
246
+ : browseSynonymsOptions.page || 0,
247
+ }, requestOptions);
248
+ },
249
+ validate: (response) => response.nbHits < params.hitsPerPage,
250
+ ...browseSynonymsOptions,
251
+ });
252
+ },
134
253
  /**
135
254
  * Add a new API Key with specific permissions/restrictions.
136
255
  *
@@ -824,6 +943,9 @@ function createSearchClient({ appId: appIdOption, apiKey: apiKeyOption, authMode
824
943
  if (!getObjectsParams) {
825
944
  throw new Error('Parameter `getObjectsParams` is required when calling `getObjects`.');
826
945
  }
946
+ if (!getObjectsParams.requests) {
947
+ throw new Error('Parameter `getObjectsParams.requests` is required when calling `getObjects`.');
948
+ }
827
949
  const requestPath = '/1/indexes/*/objects';
828
950
  const headers = {};
829
951
  const queryParameters = {};
@@ -1127,6 +1249,9 @@ function createSearchClient({ appId: appIdOption, apiKey: apiKeyOption, authMode
1127
1249
  if (!batchParams) {
1128
1250
  throw new Error('Parameter `batchParams` is required when calling `multipleBatch`.');
1129
1251
  }
1252
+ if (!batchParams.requests) {
1253
+ throw new Error('Parameter `batchParams.requests` is required when calling `multipleBatch`.');
1254
+ }
1130
1255
  const requestPath = '/1/indexes/*/batch';
1131
1256
  const headers = {};
1132
1257
  const queryParameters = {};
@@ -1180,19 +1305,19 @@ function createSearchClient({ appId: appIdOption, apiKey: apiKeyOption, authMode
1180
1305
  * @param partialUpdateObject - The partialUpdateObject object.
1181
1306
  * @param partialUpdateObject.indexName - The index in which to perform the request.
1182
1307
  * @param partialUpdateObject.objectID - Unique identifier of an object.
1183
- * @param partialUpdateObject.attributeOrBuiltInOperation - List of attributes to update.
1308
+ * @param partialUpdateObject.attributesToUpdate - Map of attribute(s) to update.
1184
1309
  * @param partialUpdateObject.createIfNotExists - Creates the record if it does not exist yet.
1185
1310
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
1186
1311
  */
1187
- partialUpdateObject({ indexName, objectID, attributeOrBuiltInOperation, createIfNotExists, }, requestOptions) {
1312
+ partialUpdateObject({ indexName, objectID, attributesToUpdate, createIfNotExists, }, requestOptions) {
1188
1313
  if (!indexName) {
1189
1314
  throw new Error('Parameter `indexName` is required when calling `partialUpdateObject`.');
1190
1315
  }
1191
1316
  if (!objectID) {
1192
1317
  throw new Error('Parameter `objectID` is required when calling `partialUpdateObject`.');
1193
1318
  }
1194
- if (!attributeOrBuiltInOperation) {
1195
- throw new Error('Parameter `attributeOrBuiltInOperation` is required when calling `partialUpdateObject`.');
1319
+ if (!attributesToUpdate) {
1320
+ throw new Error('Parameter `attributesToUpdate` is required when calling `partialUpdateObject`.');
1196
1321
  }
1197
1322
  const requestPath = '/1/indexes/{indexName}/{objectID}/partial'
1198
1323
  .replace('{indexName}', encodeURIComponent(indexName))
@@ -1207,7 +1332,7 @@ function createSearchClient({ appId: appIdOption, apiKey: apiKeyOption, authMode
1207
1332
  path: requestPath,
1208
1333
  queryParameters,
1209
1334
  headers,
1210
- data: attributeOrBuiltInOperation,
1335
+ data: attributesToUpdate,
1211
1336
  };
1212
1337
  return transporter.request(request, requestOptions);
1213
1338
  },
@@ -1408,17 +1533,17 @@ function createSearchClient({ appId: appIdOption, apiKey: apiKeyOption, authMode
1408
1533
  * @summary Save a batch of rules.
1409
1534
  * @param saveRules - The saveRules object.
1410
1535
  * @param saveRules.indexName - The index in which to perform the request.
1411
- * @param saveRules.rule - The rule object.
1536
+ * @param saveRules.rules - The rules object.
1412
1537
  * @param saveRules.forwardToReplicas - When true, changes are also propagated to replicas of the given indexName.
1413
1538
  * @param saveRules.clearExistingRules - When true, existing Rules are cleared before adding this batch. When false, existing Rules are kept.
1414
1539
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
1415
1540
  */
1416
- saveRules({ indexName, rule, forwardToReplicas, clearExistingRules, }, requestOptions) {
1541
+ saveRules({ indexName, rules, forwardToReplicas, clearExistingRules, }, requestOptions) {
1417
1542
  if (!indexName) {
1418
1543
  throw new Error('Parameter `indexName` is required when calling `saveRules`.');
1419
1544
  }
1420
- if (!rule) {
1421
- throw new Error('Parameter `rule` is required when calling `saveRules`.');
1545
+ if (!rules) {
1546
+ throw new Error('Parameter `rules` is required when calling `saveRules`.');
1422
1547
  }
1423
1548
  const requestPath = '/1/indexes/{indexName}/rules/batch'.replace('{indexName}', encodeURIComponent(indexName));
1424
1549
  const headers = {};
@@ -1434,7 +1559,7 @@ function createSearchClient({ appId: appIdOption, apiKey: apiKeyOption, authMode
1434
1559
  path: requestPath,
1435
1560
  queryParameters,
1436
1561
  headers,
1437
- data: rule,
1562
+ data: rules,
1438
1563
  };
1439
1564
  return transporter.request(request, requestOptions);
1440
1565
  },
@@ -1645,9 +1770,6 @@ function createSearchClient({ appId: appIdOption, apiKey: apiKeyOption, authMode
1645
1770
  if (!indexName) {
1646
1771
  throw new Error('Parameter `indexName` is required when calling `searchRules`.');
1647
1772
  }
1648
- if (!searchRulesParams) {
1649
- throw new Error('Parameter `searchRulesParams` is required when calling `searchRules`.');
1650
- }
1651
1773
  const requestPath = '/1/indexes/{indexName}/rules/search'.replace('{indexName}', encodeURIComponent(indexName));
1652
1774
  const headers = {};
1653
1775
  const queryParameters = {};
@@ -1656,7 +1778,7 @@ function createSearchClient({ appId: appIdOption, apiKey: apiKeyOption, authMode
1656
1778
  path: requestPath,
1657
1779
  queryParameters,
1658
1780
  headers,
1659
- data: searchRulesParams,
1781
+ data: searchRulesParams ? searchRulesParams : {},
1660
1782
  useReadTransporter: true,
1661
1783
  cacheable: true,
1662
1784
  };