@algolia/client-search 5.0.0-alpha.3 → 5.0.0-alpha.31

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 (228) hide show
  1. package/dist/builds/browser.d.ts.map +1 -1
  2. package/dist/builds/node.d.ts.map +1 -1
  3. package/dist/client-search.cjs.js +163 -38
  4. package/dist/client-search.esm.browser.js +217 -172
  5. package/dist/client-search.esm.node.js +164 -39
  6. package/dist/client-search.umd.js +2 -2
  7. package/dist/model/acl.d.ts +3 -0
  8. package/dist/model/acl.d.ts.map +1 -1
  9. package/dist/model/action.d.ts.map +1 -1
  10. package/dist/model/addApiKeyResponse.d.ts +1 -1
  11. package/dist/model/addApiKeyResponse.d.ts.map +1 -1
  12. package/dist/model/advancedSyntaxFeatures.d.ts.map +1 -1
  13. package/dist/model/alternativesAsExact.d.ts.map +1 -1
  14. package/dist/model/anchoring.d.ts.map +1 -1
  15. package/dist/model/apiKey.d.ts.map +1 -1
  16. package/dist/model/aroundRadius.d.ts.map +1 -1
  17. package/dist/model/aroundRadiusAll.d.ts.map +1 -1
  18. package/dist/model/assignUserIdParams.d.ts.map +1 -1
  19. package/dist/model/attributeToUpdate.d.ts +3 -0
  20. package/dist/model/attributeToUpdate.d.ts.map +1 -0
  21. package/dist/model/automaticFacetFilter.d.ts.map +1 -1
  22. package/dist/model/automaticFacetFilters.d.ts.map +1 -1
  23. package/dist/model/baseGetApiKeyResponse.d.ts +11 -0
  24. package/dist/model/baseGetApiKeyResponse.d.ts.map +1 -0
  25. package/dist/model/baseIndexSettings.d.ts +4 -0
  26. package/dist/model/baseIndexSettings.d.ts.map +1 -1
  27. package/dist/model/baseSearchParams.d.ts.map +1 -1
  28. package/dist/model/baseSearchParamsWithoutQuery.d.ts.map +1 -1
  29. package/dist/model/baseSearchResponse.d.ts +1 -1
  30. package/dist/model/baseSearchResponse.d.ts.map +1 -1
  31. package/dist/model/batchAssignUserIdsParams.d.ts.map +1 -1
  32. package/dist/model/batchDictionaryEntriesParams.d.ts.map +1 -1
  33. package/dist/model/batchDictionaryEntriesRequest.d.ts.map +1 -1
  34. package/dist/model/batchParams.d.ts +1 -1
  35. package/dist/model/batchParams.d.ts.map +1 -1
  36. package/dist/model/batchRequest.d.ts +2 -2
  37. package/dist/model/batchRequest.d.ts.map +1 -1
  38. package/dist/model/batchResponse.d.ts.map +1 -1
  39. package/dist/model/batchWriteParams.d.ts +1 -1
  40. package/dist/model/batchWriteParams.d.ts.map +1 -1
  41. package/dist/model/browseParams.d.ts +4 -0
  42. package/dist/model/browseParams.d.ts.map +1 -0
  43. package/dist/model/browseParamsObject.d.ts +4 -0
  44. package/dist/model/browseParamsObject.d.ts.map +1 -0
  45. package/dist/model/browseResponse.d.ts +2 -2
  46. package/dist/model/browseResponse.d.ts.map +1 -1
  47. package/dist/model/builtInOperation.d.ts.map +1 -1
  48. package/dist/model/builtInOperationType.d.ts.map +1 -1
  49. package/dist/model/clientMethodProps.d.ts +26 -14
  50. package/dist/model/clientMethodProps.d.ts.map +1 -1
  51. package/dist/model/condition.d.ts.map +1 -1
  52. package/dist/model/consequence.d.ts.map +1 -1
  53. package/dist/model/consequenceHide.d.ts.map +1 -1
  54. package/dist/model/consequenceParams.d.ts.map +1 -1
  55. package/dist/model/consequenceQuery.d.ts.map +1 -1
  56. package/dist/model/consequenceQueryObject.d.ts.map +1 -1
  57. package/dist/model/createdAtResponse.d.ts.map +1 -1
  58. package/dist/model/{baseBrowseResponse.d.ts → cursor.d.ts} +3 -3
  59. package/dist/model/cursor.d.ts.map +1 -0
  60. package/dist/model/deleteApiKeyResponse.d.ts.map +1 -1
  61. package/dist/model/deleteByParams.d.ts +27 -0
  62. package/dist/model/deleteByParams.d.ts.map +1 -0
  63. package/dist/model/deleteSourceResponse.d.ts.map +1 -1
  64. package/dist/model/deletedAtResponse.d.ts.map +1 -1
  65. package/dist/model/dictionaryAction.d.ts.map +1 -1
  66. package/dist/model/dictionaryEntry.d.ts.map +1 -1
  67. package/dist/model/dictionaryEntryState.d.ts.map +1 -1
  68. package/dist/model/dictionaryLanguage.d.ts.map +1 -1
  69. package/dist/model/dictionarySettingsParams.d.ts.map +1 -1
  70. package/dist/model/dictionaryType.d.ts.map +1 -1
  71. package/dist/model/distinct.d.ts.map +1 -1
  72. package/dist/model/edit.d.ts.map +1 -1
  73. package/dist/model/editType.d.ts.map +1 -1
  74. package/dist/model/errorBase.d.ts.map +1 -1
  75. package/dist/model/exactOnSingleWordQuery.d.ts.map +1 -1
  76. package/dist/model/facetFilters.d.ts.map +1 -1
  77. package/dist/model/facetHits.d.ts.map +1 -1
  78. package/dist/model/facetOrdering.d.ts.map +1 -1
  79. package/dist/model/facets.d.ts.map +1 -1
  80. package/dist/model/facetsStats.d.ts.map +1 -1
  81. package/dist/model/fetchedIndex.d.ts +1 -1
  82. package/dist/model/fetchedIndex.d.ts.map +1 -1
  83. package/dist/model/getApiKeyResponse.d.ts +4 -0
  84. package/dist/model/getApiKeyResponse.d.ts.map +1 -0
  85. package/dist/model/getDictionarySettingsResponse.d.ts.map +1 -1
  86. package/dist/model/getLogsResponse.d.ts.map +1 -1
  87. package/dist/model/getObjectsParams.d.ts +1 -1
  88. package/dist/model/getObjectsParams.d.ts.map +1 -1
  89. package/dist/model/getObjectsRequest.d.ts.map +1 -1
  90. package/dist/model/getObjectsResponse.d.ts.map +1 -1
  91. package/dist/model/getTaskResponse.d.ts.map +1 -1
  92. package/dist/model/getTopUserIdsResponse.d.ts.map +1 -1
  93. package/dist/model/hasPendingMappingsResponse.d.ts.map +1 -1
  94. package/dist/model/highlightResult.d.ts.map +1 -1
  95. package/dist/model/highlightResultOption.d.ts.map +1 -1
  96. package/dist/model/hit.d.ts.map +1 -1
  97. package/dist/model/ignorePlurals.d.ts.map +1 -1
  98. package/dist/model/index.d.ts +7 -6
  99. package/dist/model/index.d.ts.map +1 -1
  100. package/dist/model/indexSettings.d.ts.map +1 -1
  101. package/dist/model/indexSettingsAsSearchParams.d.ts +4 -4
  102. package/dist/model/indexSettingsAsSearchParams.d.ts.map +1 -1
  103. package/dist/model/languages.d.ts.map +1 -1
  104. package/dist/model/listApiKeysResponse.d.ts +2 -2
  105. package/dist/model/listApiKeysResponse.d.ts.map +1 -1
  106. package/dist/model/listClustersResponse.d.ts.map +1 -1
  107. package/dist/model/listIndicesResponse.d.ts.map +1 -1
  108. package/dist/model/listUserIdsResponse.d.ts.map +1 -1
  109. package/dist/model/log.d.ts.map +1 -1
  110. package/dist/model/logQuery.d.ts.map +1 -1
  111. package/dist/model/logType.d.ts.map +1 -1
  112. package/dist/model/matchLevel.d.ts.map +1 -1
  113. package/dist/model/matchedGeoLocation.d.ts.map +1 -1
  114. package/dist/model/mixedSearchFilters.d.ts.map +1 -1
  115. package/dist/model/multipleBatchRequest.d.ts +3 -3
  116. package/dist/model/multipleBatchRequest.d.ts.map +1 -1
  117. package/dist/model/multipleBatchResponse.d.ts +2 -2
  118. package/dist/model/multipleBatchResponse.d.ts.map +1 -1
  119. package/dist/model/numericFilters.d.ts.map +1 -1
  120. package/dist/model/operationIndexParams.d.ts.map +1 -1
  121. package/dist/model/operationType.d.ts.map +1 -1
  122. package/dist/model/optionalFilters.d.ts.map +1 -1
  123. package/dist/model/params.d.ts.map +1 -1
  124. package/dist/model/personalization.d.ts.map +1 -1
  125. package/dist/model/promote.d.ts.map +1 -1
  126. package/dist/model/promoteObjectID.d.ts.map +1 -1
  127. package/dist/model/promoteObjectIDs.d.ts.map +1 -1
  128. package/dist/model/queryType.d.ts.map +1 -1
  129. package/dist/model/rankingInfo.d.ts.map +1 -1
  130. package/dist/model/reRankingApplyFilter.d.ts.map +1 -1
  131. package/dist/model/removeStopWords.d.ts.map +1 -1
  132. package/dist/model/removeUserIdResponse.d.ts.map +1 -1
  133. package/dist/model/removeWordsIfNoResults.d.ts.map +1 -1
  134. package/dist/model/renderingContent.d.ts.map +1 -1
  135. package/dist/model/replaceSourceResponse.d.ts.map +1 -1
  136. package/dist/model/rule.d.ts.map +1 -1
  137. package/dist/model/saveObjectResponse.d.ts.map +1 -1
  138. package/dist/model/saveSynonymResponse.d.ts.map +1 -1
  139. package/dist/model/scopeType.d.ts.map +1 -1
  140. package/dist/model/searchDictionaryEntriesParams.d.ts.map +1 -1
  141. package/dist/model/searchForFacetValuesRequest.d.ts.map +1 -1
  142. package/dist/model/searchForFacetValuesResponse.d.ts.map +1 -1
  143. package/dist/model/searchForFacets.d.ts.map +1 -1
  144. package/dist/model/searchForFacetsOptions.d.ts.map +1 -1
  145. package/dist/model/searchForHits.d.ts.map +1 -1
  146. package/dist/model/searchForHitsOptions.d.ts.map +1 -1
  147. package/dist/model/searchHits.d.ts.map +1 -1
  148. package/dist/model/searchMethodParams.d.ts.map +1 -1
  149. package/dist/model/searchParams.d.ts.map +1 -1
  150. package/dist/model/searchParamsObject.d.ts.map +1 -1
  151. package/dist/model/searchParamsQuery.d.ts.map +1 -1
  152. package/dist/model/searchParamsString.d.ts.map +1 -1
  153. package/dist/model/searchQuery.d.ts.map +1 -1
  154. package/dist/model/searchResponse.d.ts.map +1 -1
  155. package/dist/model/searchResponses.d.ts.map +1 -1
  156. package/dist/model/searchRulesParams.d.ts.map +1 -1
  157. package/dist/model/searchRulesResponse.d.ts.map +1 -1
  158. package/dist/model/searchStrategy.d.ts.map +1 -1
  159. package/dist/model/searchSynonymsParams.d.ts.map +1 -1
  160. package/dist/model/searchSynonymsResponse.d.ts.map +1 -1
  161. package/dist/model/searchTypeDefault.d.ts.map +1 -1
  162. package/dist/model/searchTypeFacet.d.ts.map +1 -1
  163. package/dist/model/searchUserIdsParams.d.ts.map +1 -1
  164. package/dist/model/searchUserIdsResponse.d.ts.map +1 -1
  165. package/dist/model/snippetResult.d.ts.map +1 -1
  166. package/dist/model/snippetResultOption.d.ts.map +1 -1
  167. package/dist/model/sortRemainingBy.d.ts.map +1 -1
  168. package/dist/model/source.d.ts.map +1 -1
  169. package/dist/model/standardEntries.d.ts.map +1 -1
  170. package/dist/model/synonymHit.d.ts +0 -2
  171. package/dist/model/synonymHit.d.ts.map +1 -1
  172. package/dist/model/synonymType.d.ts.map +1 -1
  173. package/dist/model/tagFilters.d.ts.map +1 -1
  174. package/dist/model/taskStatus.d.ts.map +1 -1
  175. package/dist/model/timeRange.d.ts.map +1 -1
  176. package/dist/model/typoTolerance.d.ts.map +1 -1
  177. package/dist/model/typoToleranceEnum.d.ts.map +1 -1
  178. package/dist/model/updateApiKeyResponse.d.ts +1 -1
  179. package/dist/model/updateApiKeyResponse.d.ts.map +1 -1
  180. package/dist/model/updatedAtResponse.d.ts.map +1 -1
  181. package/dist/model/updatedAtWithObjectIdResponse.d.ts.map +1 -1
  182. package/dist/model/updatedRuleResponse.d.ts.map +1 -1
  183. package/dist/model/userHighlightResult.d.ts.map +1 -1
  184. package/dist/model/userHit.d.ts.map +1 -1
  185. package/dist/model/userId.d.ts.map +1 -1
  186. package/dist/model/value.d.ts.map +1 -1
  187. package/dist/src/searchClient.d.ts +71 -24
  188. package/dist/src/searchClient.d.ts.map +1 -1
  189. package/model/acl.ts +3 -0
  190. package/model/addApiKeyResponse.ts +1 -1
  191. package/model/{attributeOrBuiltInOperation.ts → attributeToUpdate.ts} +1 -1
  192. package/model/baseGetApiKeyResponse.ts +13 -0
  193. package/model/baseIndexSettings.ts +5 -0
  194. package/model/baseSearchResponse.ts +1 -1
  195. package/model/batchParams.ts +1 -1
  196. package/model/batchRequest.ts +2 -2
  197. package/model/batchWriteParams.ts +1 -1
  198. package/model/browseParams.ts +6 -0
  199. package/model/browseParamsObject.ts +6 -0
  200. package/model/browseResponse.ts +3 -3
  201. package/model/clientMethodProps.ts +31 -19
  202. package/model/{baseBrowseResponse.ts → cursor.ts} +2 -2
  203. package/model/deleteByParams.ts +36 -0
  204. package/model/fetchedIndex.ts +1 -1
  205. package/model/{key.ts → getApiKeyResponse.ts} +2 -2
  206. package/model/getObjectsParams.ts +1 -1
  207. package/model/index.ts +7 -6
  208. package/model/indexSettingsAsSearchParams.ts +5 -5
  209. package/model/listApiKeysResponse.ts +2 -2
  210. package/model/multipleBatchRequest.ts +3 -3
  211. package/model/multipleBatchResponse.ts +2 -2
  212. package/model/synonymHit.ts +0 -3
  213. package/model/updateApiKeyResponse.ts +1 -1
  214. package/package.json +31 -13
  215. package/dist/model/attributeOrBuiltInOperation.d.ts +0 -3
  216. package/dist/model/attributeOrBuiltInOperation.d.ts.map +0 -1
  217. package/dist/model/baseBrowseResponse.d.ts.map +0 -1
  218. package/dist/model/browseRequest.d.ts +0 -11
  219. package/dist/model/browseRequest.d.ts.map +0 -1
  220. package/dist/model/createdAtObject.d.ts +0 -7
  221. package/dist/model/createdAtObject.d.ts.map +0 -1
  222. package/dist/model/key.d.ts +0 -4
  223. package/dist/model/key.d.ts.map +0 -1
  224. package/dist/model/synonymHitHighlightResult.d.ts +0 -12
  225. package/dist/model/synonymHitHighlightResult.d.ts.map +0 -1
  226. package/model/browseRequest.ts +0 -13
  227. package/model/createdAtObject.ts +0 -8
  228. package/model/synonymHitHighlightResult.ts +0 -15
@@ -7,75 +7,65 @@ function createAuth(appId, apiKey, authMode = 'WithinHeaders') {
7
7
  headers() {
8
8
  return authMode === 'WithinHeaders' ? credentials : {};
9
9
  },
10
-
11
10
  queryParameters() {
12
11
  return authMode === 'WithinQueryParameters' ? credentials : {};
13
12
  }
14
-
15
13
  };
16
14
  }
17
15
 
18
- const DEFAULT_MAX_RETRIES = 50;
19
- const DEFAULT_TIMEOUT = retryCount => Math.min(retryCount * 200, 5000);
20
16
  /**
21
- * Return a promise that retry a task until it meets the condition.
17
+ * Helper: Returns the promise of a given `func` to iterate on, based on a given `validate` condition.
22
18
  *
23
- * @param createRetryablePromiseOptions - The createRetryablePromise options.
24
- * @param createRetryablePromiseOptions.func - The function to run, which returns a promise.
25
- * @param createRetryablePromiseOptions.validate - The validator function. It receives the resolved return of `func`.
26
- * @param createRetryablePromiseOptions.maxRetries - The maximum number of retries. 50 by default.
27
- * @param createRetryablePromiseOptions.timeout - The function to decide how long to wait between retries.
19
+ * @param createIterator - The createIterator options.
20
+ * @param createIterator.func - The function to run, which returns a promise.
21
+ * @param createIterator.validate - The validator function. It receives the resolved return of `func`.
22
+ * @param createIterator.aggregator - The function that runs right after the `func` method has been executed, allows you to do anything with the response before `validate`.
23
+ * @param createIterator.error - The `validate` condition to throw an error, and its message.
24
+ * @param createIterator.timeout - The function to decide how long to wait between iterations.
28
25
  */
29
-
30
- function createRetryablePromise({
26
+ function createIterablePromise({
31
27
  func,
32
28
  validate,
33
- maxRetries = DEFAULT_MAX_RETRIES,
34
- timeout = DEFAULT_TIMEOUT
29
+ aggregator,
30
+ error,
31
+ timeout = () => 0
35
32
  }) {
36
- let retryCount = 0;
37
-
38
- const retry = () => {
33
+ const retry = previousResponse => {
39
34
  return new Promise((resolve, reject) => {
40
- func().then(response => {
41
- const isValid = validate(response);
42
-
43
- if (isValid) {
44
- resolve(response);
45
- } else if (retryCount + 1 >= maxRetries) {
46
- reject(new Error(`The maximum number of retries exceeded. (${retryCount + 1}/${maxRetries})`));
47
- } else {
48
- retryCount += 1;
49
- setTimeout(() => {
50
- retry().then(resolve).catch(reject);
51
- }, timeout(retryCount));
35
+ func(previousResponse).then(response => {
36
+ if (aggregator) {
37
+ aggregator(response);
38
+ }
39
+ if (validate(response)) {
40
+ return resolve(response);
41
+ }
42
+ if (error && error.validate(response)) {
43
+ return reject(new Error(error.message(response)));
52
44
  }
53
- }).catch(error => {
54
- reject(error);
45
+ return setTimeout(() => {
46
+ retry(response).then(resolve).catch(reject);
47
+ }, timeout());
48
+ }).catch(err => {
49
+ reject(err);
55
50
  });
56
51
  });
57
52
  };
58
-
59
53
  return retry();
60
54
  }
61
55
 
62
56
  function createBrowserLocalStorageCache(options) {
63
- let storage; // We've changed the namespace to avoid conflicts with v4, as this version is a huge breaking change
64
-
57
+ let storage;
58
+ // We've changed the namespace to avoid conflicts with v4, as this version is a huge breaking change
65
59
  const namespaceKey = `algolia-client-js-${options.key}`;
66
-
67
60
  function getStorage() {
68
61
  if (storage === undefined) {
69
62
  storage = options.localStorage || window.localStorage;
70
63
  }
71
-
72
64
  return storage;
73
65
  }
74
-
75
66
  function getNamespace() {
76
67
  return JSON.parse(getStorage().getItem(namespaceKey) || '{}');
77
68
  }
78
-
79
69
  return {
80
70
  get(key, defaultValue, events = {
81
71
  miss: () => Promise.resolve()
@@ -88,7 +78,6 @@ function createBrowserLocalStorageCache(options) {
88
78
  return Promise.all([value, exists || events.miss(value)]);
89
79
  }).then(([value]) => value);
90
80
  },
91
-
92
81
  set(key, value) {
93
82
  return Promise.resolve().then(() => {
94
83
  const namespace = getNamespace();
@@ -97,7 +86,6 @@ function createBrowserLocalStorageCache(options) {
97
86
  return value;
98
87
  });
99
88
  },
100
-
101
89
  delete(key) {
102
90
  return Promise.resolve().then(() => {
103
91
  const namespace = getNamespace();
@@ -105,13 +93,11 @@ function createBrowserLocalStorageCache(options) {
105
93
  getStorage().setItem(namespaceKey, JSON.stringify(namespace));
106
94
  });
107
95
  },
108
-
109
96
  clear() {
110
97
  return Promise.resolve().then(() => {
111
98
  getStorage().removeItem(namespaceKey);
112
99
  });
113
100
  }
114
-
115
101
  };
116
102
  }
117
103
 
@@ -123,30 +109,24 @@ function createNullCache() {
123
109
  const value = defaultValue();
124
110
  return value.then(result => Promise.all([result, events.miss(result)])).then(([result]) => result);
125
111
  },
126
-
127
112
  set(_key, value) {
128
113
  return Promise.resolve(value);
129
114
  },
130
-
131
115
  delete(_key) {
132
116
  return Promise.resolve();
133
117
  },
134
-
135
118
  clear() {
136
119
  return Promise.resolve();
137
120
  }
138
-
139
121
  };
140
122
  }
141
123
 
142
124
  function createFallbackableCache(options) {
143
125
  const caches = [...options.caches];
144
126
  const current = caches.shift();
145
-
146
127
  if (current === undefined) {
147
128
  return createNullCache();
148
129
  }
149
-
150
130
  return {
151
131
  get(key, defaultValue, events = {
152
132
  miss: () => Promise.resolve()
@@ -157,7 +137,6 @@ function createFallbackableCache(options) {
157
137
  }).get(key, defaultValue, events);
158
138
  });
159
139
  },
160
-
161
140
  set(key, value) {
162
141
  return current.set(key, value).catch(() => {
163
142
  return createFallbackableCache({
@@ -165,7 +144,6 @@ function createFallbackableCache(options) {
165
144
  }).set(key, value);
166
145
  });
167
146
  },
168
-
169
147
  delete(key) {
170
148
  return current.delete(key).catch(() => {
171
149
  return createFallbackableCache({
@@ -173,7 +151,6 @@ function createFallbackableCache(options) {
173
151
  }).delete(key);
174
152
  });
175
153
  },
176
-
177
154
  clear() {
178
155
  return current.clear().catch(() => {
179
156
  return createFallbackableCache({
@@ -181,7 +158,6 @@ function createFallbackableCache(options) {
181
158
  }).clear();
182
159
  });
183
160
  }
184
-
185
161
  };
186
162
  }
187
163
 
@@ -194,30 +170,24 @@ function createMemoryCache(options = {
194
170
  miss: () => Promise.resolve()
195
171
  }) {
196
172
  const keyAsString = JSON.stringify(key);
197
-
198
173
  if (keyAsString in cache) {
199
174
  return Promise.resolve(options.serializable ? JSON.parse(cache[keyAsString]) : cache[keyAsString]);
200
175
  }
201
-
202
176
  const promise = defaultValue();
203
177
  return promise.then(value => events.miss(value)).then(() => promise);
204
178
  },
205
-
206
179
  set(key, value) {
207
180
  cache[JSON.stringify(key)] = options.serializable ? JSON.stringify(value) : value;
208
181
  return Promise.resolve(value);
209
182
  },
210
-
211
183
  delete(key) {
212
184
  delete cache[JSON.stringify(key)];
213
185
  return Promise.resolve();
214
186
  },
215
-
216
187
  clear() {
217
188
  cache = {};
218
189
  return Promise.resolve();
219
190
  }
220
-
221
191
  };
222
192
  }
223
193
 
@@ -226,16 +196,14 @@ function createMemoryCache(options = {
226
196
  const EXPIRATION_DELAY = 2 * 60 * 1000;
227
197
  function createStatefulHost(host, status = 'up') {
228
198
  const lastUpdate = Date.now();
229
-
230
199
  function isUp() {
231
200
  return status === 'up' || Date.now() - lastUpdate > EXPIRATION_DELAY;
232
201
  }
233
-
234
202
  function isTimedOut() {
235
203
  return status === 'timed out' && Date.now() - lastUpdate <= EXPIRATION_DELAY;
236
204
  }
237
-
238
- return { ...host,
205
+ return {
206
+ ...host,
239
207
  status,
240
208
  lastUpdate,
241
209
  isUp,
@@ -254,92 +222,74 @@ function _defineProperty(obj, key, value) {
254
222
  } else {
255
223
  obj[key] = value;
256
224
  }
257
-
258
225
  return obj;
259
226
  }
260
227
 
261
228
  class AlgoliaError extends Error {
262
229
  constructor(message, name) {
263
230
  super(message);
264
-
265
231
  _defineProperty(this, "name", 'AlgoliaError');
266
-
267
232
  if (name) {
268
233
  this.name = name;
269
234
  }
270
235
  }
271
-
272
236
  }
273
237
  class ErrorWithStackTrace extends AlgoliaError {
274
238
  constructor(message, stackTrace, name) {
275
- super(message, name); // the array and object should be frozen to reflect the stackTrace at the time of the error
276
-
239
+ super(message, name);
240
+ // the array and object should be frozen to reflect the stackTrace at the time of the error
277
241
  _defineProperty(this, "stackTrace", void 0);
278
-
279
242
  this.stackTrace = stackTrace;
280
243
  }
281
-
282
244
  }
283
245
  class RetryError extends ErrorWithStackTrace {
284
246
  constructor(stackTrace) {
285
247
  super('Unreachable hosts - your application id may be incorrect. If the error persists, contact support@algolia.com.', stackTrace, 'RetryError');
286
248
  }
287
-
288
249
  }
289
250
  class ApiError extends ErrorWithStackTrace {
290
251
  constructor(message, status, stackTrace) {
291
252
  super(message, stackTrace, 'ApiError');
292
-
293
253
  _defineProperty(this, "status", void 0);
294
-
295
254
  this.status = status;
296
255
  }
297
-
298
256
  }
299
257
  class DeserializationError extends AlgoliaError {
300
258
  constructor(message, response) {
301
259
  super(message, 'DeserializationError');
302
-
303
260
  _defineProperty(this, "response", void 0);
304
-
305
261
  this.response = response;
306
262
  }
307
-
308
263
  }
309
264
 
310
265
  function shuffle(array) {
311
266
  const shuffledArray = array;
312
-
313
267
  for (let c = array.length - 1; c > 0; c--) {
314
268
  const b = Math.floor(Math.random() * (c + 1));
315
269
  const a = array[c];
316
270
  shuffledArray[c] = array[b];
317
271
  shuffledArray[b] = a;
318
272
  }
319
-
320
273
  return shuffledArray;
321
274
  }
322
275
  function serializeUrl(host, path, queryParameters) {
323
276
  const queryParametersAsString = serializeQueryParameters(queryParameters);
324
277
  let url = `${host.protocol}://${host.url}/${path.charAt(0) === '/' ? path.substr(1) : path}`;
325
-
326
278
  if (queryParametersAsString.length) {
327
279
  url += `?${queryParametersAsString}`;
328
280
  }
329
-
330
281
  return url;
331
282
  }
332
283
  function serializeQueryParameters(parameters) {
333
284
  const isObjectOrArray = value => Object.prototype.toString.call(value) === '[object Object]' || Object.prototype.toString.call(value) === '[object Array]';
334
-
335
- return Object.keys(parameters).map(key => `${key}=${isObjectOrArray(parameters[key]) ? JSON.stringify(parameters[key]) : parameters[key]}`).join('&');
285
+ return Object.keys(parameters).map(key => `${key}=${encodeURIComponent(isObjectOrArray(parameters[key]) ? JSON.stringify(parameters[key]) : parameters[key])}`).join('&');
336
286
  }
337
287
  function serializeData(request, requestOptions) {
338
288
  if (request.method === 'GET' || request.data === undefined && requestOptions.data === undefined) {
339
289
  return undefined;
340
290
  }
341
-
342
- const data = Array.isArray(request.data) ? request.data : { ...request.data,
291
+ const data = Array.isArray(request.data) ? request.data : {
292
+ ...request.data,
343
293
  ...requestOptions.data
344
294
  };
345
295
  return JSON.stringify(data);
@@ -370,12 +320,11 @@ function deserializeFailure({
370
320
  status
371
321
  }, stackFrame) {
372
322
  let message = content;
373
-
374
323
  try {
375
324
  message = JSON.parse(content).message;
376
- } catch (e) {// ..
325
+ } catch (e) {
326
+ // ..
377
327
  }
378
-
379
328
  return new ApiError(message, status, stackFrame);
380
329
  }
381
330
 
@@ -407,9 +356,12 @@ function stackFrameWithoutCredentials(stackFrame) {
407
356
  const modifiedHeaders = stackFrame.request.headers['x-algolia-api-key'] ? {
408
357
  'x-algolia-api-key': '*****'
409
358
  } : {};
410
- return { ...stackFrame,
411
- request: { ...stackFrame.request,
412
- headers: { ...stackFrame.request.headers,
359
+ return {
360
+ ...stackFrame,
361
+ request: {
362
+ ...stackFrame.request,
363
+ headers: {
364
+ ...stackFrame.request.headers,
413
365
  ...modifiedHeaders
414
366
  }
415
367
  }
@@ -434,13 +386,12 @@ function createTransporter({
434
386
  });
435
387
  }));
436
388
  const hostsUp = statefulHosts.filter(host => host.isUp());
437
- const hostsTimedOut = statefulHosts.filter(host => host.isTimedOut()); // Note, we put the hosts that previously timed out on the end of the list.
438
-
389
+ const hostsTimedOut = statefulHosts.filter(host => host.isTimedOut());
390
+ // Note, we put the hosts that previously timed out on the end of the list.
439
391
  const hostsAvailable = [...hostsUp, ...hostsTimedOut];
440
392
  const compatibleHostsAvailable = hostsAvailable.length > 0 ? hostsAvailable : compatibleHosts;
441
393
  return {
442
394
  hosts: compatibleHostsAvailable,
443
-
444
395
  getTimeout(timeoutsCount, baseTimeout) {
445
396
  /**
446
397
  * Imagine that you have 4 hosts, if timeouts will increase
@@ -456,29 +407,28 @@ function createTransporter({
456
407
  const timeoutMultiplier = hostsTimedOut.length === 0 && timeoutsCount === 0 ? 1 : hostsTimedOut.length + 3 + timeoutsCount;
457
408
  return timeoutMultiplier * baseTimeout;
458
409
  }
459
-
460
410
  };
461
411
  }
462
-
463
412
  async function retryableRequest(request, requestOptions, isRead = true) {
464
413
  const stackTrace = [];
465
414
  /**
466
415
  * First we prepare the payload that do not depend from hosts.
467
416
  */
468
-
469
417
  const data = serializeData(request, requestOptions);
470
- const headers = serializeHeaders(baseHeaders, request.headers, requestOptions.headers); // On `GET`, the data is proxied to query parameters.
471
-
472
- const dataQueryParameters = request.method === 'GET' ? { ...request.data,
418
+ const headers = serializeHeaders(baseHeaders, request.headers, requestOptions.headers);
419
+ // On `GET`, the data is proxied to query parameters.
420
+ const dataQueryParameters = request.method === 'GET' ? {
421
+ ...request.data,
473
422
  ...requestOptions.data
474
423
  } : {};
475
424
  const queryParameters = {
476
- 'x-algolia-agent': algoliaAgent.value,
477
425
  ...baseQueryParameters,
478
426
  ...request.queryParameters,
479
427
  ...dataQueryParameters
480
428
  };
481
-
429
+ if (algoliaAgent.value) {
430
+ queryParameters['x-algolia-agent'] = algoliaAgent.value;
431
+ }
482
432
  if (requestOptions && requestOptions.queryParameters) {
483
433
  for (const key of Object.keys(requestOptions.queryParameters)) {
484
434
  // We want to keep `undefined` and `null` values,
@@ -491,25 +441,19 @@ function createTransporter({
491
441
  }
492
442
  }
493
443
  }
494
-
495
444
  let timeoutsCount = 0;
496
-
497
445
  const retry = async (retryableHosts, getTimeout) => {
498
446
  /**
499
447
  * We iterate on each host, until there is no host left.
500
448
  */
501
449
  const host = retryableHosts.pop();
502
-
503
450
  if (host === undefined) {
504
451
  throw new RetryError(stackTraceWithoutCredentials(stackTrace));
505
452
  }
506
-
507
453
  let responseTimeout = requestOptions.timeout;
508
-
509
454
  if (responseTimeout === undefined) {
510
455
  responseTimeout = isRead ? timeouts.read : timeouts.write;
511
456
  }
512
-
513
457
  const payload = {
514
458
  data,
515
459
  headers,
@@ -523,7 +467,6 @@ function createTransporter({
523
467
  * can have information about onRetry and onFailure
524
468
  * decisions.
525
469
  */
526
-
527
470
  const pushToStackTrace = response => {
528
471
  const stackFrame = {
529
472
  request: payload,
@@ -534,12 +477,10 @@ function createTransporter({
534
477
  stackTrace.push(stackFrame);
535
478
  return stackFrame;
536
479
  };
537
-
538
480
  const response = await requester.send(payload);
539
-
540
481
  if (isRetryable(response)) {
541
- const stackFrame = pushToStackTrace(response); // If response is a timeout, we increase the number of timeouts so we can increase the timeout later.
542
-
482
+ const stackFrame = pushToStackTrace(response);
483
+ // If response is a timeout, we increase the number of timeouts so we can increase the timeout later.
543
484
  if (response.isTimedOut) {
544
485
  timeoutsCount++;
545
486
  }
@@ -549,23 +490,18 @@ function createTransporter({
549
490
  * when a retry error does not happen.
550
491
  */
551
492
  // eslint-disable-next-line no-console -- this will be fixed by exposing a `logger` to the transporter
552
-
553
-
554
493
  console.log('Retryable failure', stackFrameWithoutCredentials(stackFrame));
555
494
  /**
556
495
  * We also store the state of the host in failure cases. If the host, is
557
496
  * down it will remain down for the next 2 minutes. In a timeout situation,
558
497
  * this host will be added end of the list of hosts on the next request.
559
498
  */
560
-
561
499
  await hostsCache.set(host, createStatefulHost(host, response.isTimedOut ? 'timed out' : 'down'));
562
500
  return retry(retryableHosts, getTimeout);
563
501
  }
564
-
565
502
  if (isSuccess(response)) {
566
503
  return deserializeSuccess(response);
567
504
  }
568
-
569
505
  pushToStackTrace(response);
570
506
  throw deserializeFailure(response, stackTrace);
571
507
  };
@@ -577,20 +513,16 @@ function createTransporter({
577
513
  * 2. We also get from the retryable options a timeout multiplier that is tailored
578
514
  * for the current context.
579
515
  */
580
-
581
-
582
516
  const compatibleHosts = hosts.filter(host => host.accept === 'readWrite' || (isRead ? host.accept === 'read' : host.accept === 'write'));
583
517
  const options = await createRetryableOptions(compatibleHosts);
584
518
  return retry([...options.hosts].reverse(), options.getTimeout);
585
519
  }
586
-
587
520
  function createRequest(request, requestOptions = {}) {
588
521
  /**
589
522
  * A read request is either a `GET` request, or a request that we make
590
523
  * via the `read` transporter (e.g. `search`).
591
524
  */
592
525
  const isRead = request.useReadTransporter || request.method === 'GET';
593
-
594
526
  if (!isRead) {
595
527
  /**
596
528
  * On write requests, no cache mechanisms are applied, and we
@@ -598,7 +530,6 @@ function createTransporter({
598
530
  */
599
531
  return retryableRequest(request, requestOptions, isRead);
600
532
  }
601
-
602
533
  const createRetryableRequest = () => {
603
534
  /**
604
535
  * Then, we prepare a function factory that contains the construction of
@@ -612,14 +543,11 @@ function createTransporter({
612
543
  * request is "cacheable" - should be cached. Note that, once again,
613
544
  * the user can force this option.
614
545
  */
615
-
616
-
617
546
  const cacheable = requestOptions.cacheable || request.cacheable;
618
547
  /**
619
548
  * If is not "cacheable", we immediately trigger the retryable request, no
620
549
  * need to check cache implementations.
621
550
  */
622
-
623
551
  if (cacheable !== true) {
624
552
  return createRetryableRequest();
625
553
  }
@@ -628,8 +556,6 @@ function createTransporter({
628
556
  * the cache implementations if this request is on progress or if the
629
557
  * response already exists on the cache.
630
558
  */
631
-
632
-
633
559
  const key = {
634
560
  request,
635
561
  requestOptions,
@@ -642,7 +568,6 @@ function createTransporter({
642
568
  * With the computed key, we first ask the responses cache
643
569
  * implementation if this request was been resolved before.
644
570
  */
645
-
646
571
  return responsesCache.get(key, () => {
647
572
  /**
648
573
  * If the request has never resolved before, we actually ask if there
@@ -664,7 +589,6 @@ function createTransporter({
664
589
  miss: response => responsesCache.set(key, response)
665
590
  });
666
591
  }
667
-
668
592
  return {
669
593
  hostsCache,
670
594
  requester,
@@ -682,17 +606,13 @@ function createTransporter({
682
606
  function createAlgoliaAgent(version) {
683
607
  const algoliaAgent = {
684
608
  value: `Algolia for JavaScript (${version})`,
685
-
686
609
  add(options) {
687
610
  const addedAlgoliaAgent = `; ${options.segment}${options.version !== undefined ? ` (${options.version})` : ''}`;
688
-
689
611
  if (algoliaAgent.value.indexOf(addedAlgoliaAgent) === -1) {
690
612
  algoliaAgent.value = `${algoliaAgent.value}${addedAlgoliaAgent}`;
691
613
  }
692
-
693
614
  return algoliaAgent;
694
615
  }
695
-
696
616
  };
697
617
  return algoliaAgent;
698
618
  }
@@ -767,7 +687,7 @@ function createXhrRequester() {
767
687
  }
768
688
 
769
689
  // This file is generated, manual changes will be lost - read more on https://github.com/algolia/api-clients-automation.
770
- const apiClientVersion = '5.0.0-alpha.3';
690
+ const apiClientVersion = '5.0.0-alpha.31';
771
691
  function getDefaultHosts(appId) {
772
692
  return [
773
693
  {
@@ -821,6 +741,19 @@ function createSearchClient({ appId: appIdOption, apiKey: apiKeyOption, authMode
821
741
  });
822
742
  return {
823
743
  transporter,
744
+ /**
745
+ * The `appId` currently in use.
746
+ */
747
+ appId: appIdOption,
748
+ /**
749
+ * Clears the cache of the transporter for the `requestsCache` and `responsesCache` properties.
750
+ */
751
+ clearCache() {
752
+ return Promise.all([
753
+ transporter.requestsCache.clear(),
754
+ transporter.responsesCache.clear(),
755
+ ]).then(() => undefined);
756
+ },
824
757
  /**
825
758
  * Get the value of the `algoliaAgent`, used by our libraries internally and telemetry system.
826
759
  */
@@ -837,38 +770,57 @@ function createSearchClient({ appId: appIdOption, apiKey: apiKeyOption, authMode
837
770
  transporter.algoliaAgent.add({ segment, version });
838
771
  },
839
772
  /**
840
- * Helper: Wait for a task to complete with `indexName` and `taskID`.
773
+ * Helper: Wait for a task to be published (completed) for a given `indexName` and `taskID`.
841
774
  *
842
- * @summary Wait for a task to complete.
775
+ * @summary Helper method that waits for a task to be published (completed).
843
776
  * @param waitForTaskOptions - The waitForTaskOptions object.
844
777
  * @param waitForTaskOptions.indexName - The `indexName` where the operation was performed.
845
778
  * @param waitForTaskOptions.taskID - The `taskID` returned in the method response.
779
+ * @param waitForTaskOptions.maxRetries - The maximum number of retries. 50 by default.
780
+ * @param waitForTaskOptions.timeout - The function to decide how long to wait between retries.
846
781
  * @param requestOptions - The requestOptions to send along with the query, they will be forwarded to the `getTask` method and merged with the transporter requestOptions.
847
782
  */
848
- waitForTask({ indexName, taskID, ...createRetryablePromiseOptions }, requestOptions) {
849
- return createRetryablePromise({
850
- ...createRetryablePromiseOptions,
783
+ waitForTask({ indexName, taskID, maxRetries = 50, timeout = (retryCount) => Math.min(retryCount * 200, 5000), }, requestOptions) {
784
+ let retryCount = 0;
785
+ return createIterablePromise({
851
786
  func: () => this.getTask({ indexName, taskID }, requestOptions),
852
787
  validate: (response) => response.status === 'published',
788
+ aggregator: () => (retryCount += 1),
789
+ error: {
790
+ validate: () => retryCount >= maxRetries,
791
+ message: () => `The maximum number of retries exceeded. (${retryCount}/${maxRetries})`,
792
+ },
793
+ timeout: () => timeout(retryCount),
853
794
  });
854
795
  },
855
796
  /**
856
797
  * Helper: Wait for an API key to be added, updated or deleted based on a given `operation`.
857
798
  *
858
- * @summary Wait for an API key task to be processed.
799
+ * @summary Helper method that waits for an API key task to be processed.
859
800
  * @param waitForApiKeyOptions - The waitForApiKeyOptions object.
860
801
  * @param waitForApiKeyOptions.operation - The `operation` that was done on a `key`.
861
802
  * @param waitForApiKeyOptions.key - The `key` that has been added, deleted or updated.
862
803
  * @param waitForApiKeyOptions.apiKey - Necessary to know if an `update` operation has been processed, compare fields of the response with it.
804
+ * @param waitForApiKeyOptions.maxRetries - The maximum number of retries. 50 by default.
805
+ * @param waitForApiKeyOptions.timeout - The function to decide how long to wait between retries.
863
806
  * @param requestOptions - The requestOptions to send along with the query, they will be forwarded to the `getApikey` method and merged with the transporter requestOptions.
864
807
  */
865
- waitForApiKey({ operation, key, apiKey, ...createRetryablePromiseOptions }, requestOptions) {
808
+ waitForApiKey({ operation, key, apiKey, maxRetries = 50, timeout = (retryCount) => Math.min(retryCount * 200, 5000), }, requestOptions) {
809
+ let retryCount = 0;
810
+ const baseIteratorOptions = {
811
+ aggregator: () => (retryCount += 1),
812
+ error: {
813
+ validate: () => retryCount >= maxRetries,
814
+ message: () => `The maximum number of retries exceeded. (${retryCount}/${maxRetries})`,
815
+ },
816
+ timeout: () => timeout(retryCount),
817
+ };
866
818
  if (operation === 'update') {
867
819
  if (!apiKey) {
868
820
  throw new Error('`apiKey` is required when waiting for an `update` operation.');
869
821
  }
870
- return createRetryablePromise({
871
- ...createRetryablePromiseOptions,
822
+ return createIterablePromise({
823
+ ...baseIteratorOptions,
872
824
  func: () => this.getApiKey({ key }, requestOptions),
873
825
  validate: (response) => {
874
826
  for (const field of Object.keys(apiKey)) {
@@ -886,12 +838,99 @@ function createSearchClient({ appId: appIdOption, apiKey: apiKeyOption, authMode
886
838
  },
887
839
  });
888
840
  }
889
- return createRetryablePromise({
890
- ...createRetryablePromiseOptions,
841
+ return createIterablePromise({
842
+ ...baseIteratorOptions,
891
843
  func: () => this.getApiKey({ key }, requestOptions).catch((error) => error),
892
844
  validate: (error) => operation === 'add' ? error.status !== 404 : error.status === 404,
893
845
  });
894
846
  },
847
+ /**
848
+ * Helper: Iterate on the `browse` method of the client to allow aggregating objects of an index.
849
+ *
850
+ * @summary Helper method that iterates on the `browse` method.
851
+ * @param browseObjects - The browseObjects object.
852
+ * @param browseObjects.indexName - The index in which to perform the request.
853
+ * @param browseObjects.browseParams - The `browse` parameters.
854
+ * @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.
855
+ * @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`.
856
+ * @param requestOptions - The requestOptions to send along with the query, they will be forwarded to the `browse` method and merged with the transporter requestOptions.
857
+ */
858
+ browseObjects({ indexName, browseParams, ...browseObjectsOptions }, requestOptions) {
859
+ return createIterablePromise({
860
+ func: (previousResponse) => {
861
+ return this.browse({
862
+ indexName,
863
+ browseParams: {
864
+ cursor: previousResponse ? previousResponse.cursor : undefined,
865
+ ...browseParams,
866
+ },
867
+ }, requestOptions);
868
+ },
869
+ validate: (response) => response.cursor === undefined,
870
+ ...browseObjectsOptions,
871
+ });
872
+ },
873
+ /**
874
+ * Helper: Iterate on the `searchRules` method of the client to allow aggregating rules of an index.
875
+ *
876
+ * @summary Helper method that iterates on the `searchRules` method.
877
+ * @param browseObjects - The browseObjects object.
878
+ * @param browseObjects.indexName - The index in which to perform the request.
879
+ * @param browseObjects.searchRulesParams - The `searchRules` method parameters.
880
+ * @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).
881
+ * @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`.
882
+ * @param requestOptions - The requestOptions to send along with the query, they will be forwarded to the `searchRules` method and merged with the transporter requestOptions.
883
+ */
884
+ browseRules({ indexName, searchRulesParams, ...browseRulesOptions }, requestOptions) {
885
+ const params = {
886
+ hitsPerPage: 1000,
887
+ ...searchRulesParams,
888
+ };
889
+ return createIterablePromise({
890
+ func: (previousResponse) => {
891
+ return this.searchRules({
892
+ indexName,
893
+ searchRulesParams: {
894
+ ...params,
895
+ page: previousResponse
896
+ ? previousResponse.page + 1
897
+ : params.page || 0,
898
+ },
899
+ }, requestOptions);
900
+ },
901
+ validate: (response) => response.nbHits < params.hitsPerPage,
902
+ ...browseRulesOptions,
903
+ });
904
+ },
905
+ /**
906
+ * Helper: Iterate on the `searchSynonyms` method of the client to allow aggregating rules of an index.
907
+ *
908
+ * @summary Helper method that iterates on the `searchSynonyms` method.
909
+ * @param browseObjects - The browseObjects object.
910
+ * @param browseObjects.indexName - The index in which to perform the request.
911
+ * @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).
912
+ * @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`.
913
+ * @param requestOptions - The requestOptions to send along with the query, they will be forwarded to the `searchSynonyms` method and merged with the transporter requestOptions.
914
+ */
915
+ browseSynonyms({ indexName, validate, aggregator, ...browseSynonymsOptions }, requestOptions) {
916
+ const params = {
917
+ hitsPerPage: 1000,
918
+ ...browseSynonymsOptions,
919
+ };
920
+ return createIterablePromise({
921
+ func: (previousResponse) => {
922
+ return this.searchSynonyms({
923
+ ...params,
924
+ indexName,
925
+ page: previousResponse
926
+ ? previousResponse.page + 1
927
+ : browseSynonymsOptions.page || 0,
928
+ }, requestOptions);
929
+ },
930
+ validate: (response) => response.nbHits < params.hitsPerPage,
931
+ ...browseSynonymsOptions,
932
+ });
933
+ },
895
934
  /**
896
935
  * Add a new API Key with specific permissions/restrictions.
897
936
  *
@@ -1025,6 +1064,9 @@ function createSearchClient({ appId: appIdOption, apiKey: apiKeyOption, authMode
1025
1064
  if (!batchWriteParams) {
1026
1065
  throw new Error('Parameter `batchWriteParams` is required when calling `batch`.');
1027
1066
  }
1067
+ if (!batchWriteParams.requests) {
1068
+ throw new Error('Parameter `batchWriteParams.requests` is required when calling `batch`.');
1069
+ }
1028
1070
  const requestPath = '/1/indexes/{indexName}/batch'.replace('{indexName}', encodeURIComponent(indexName));
1029
1071
  const headers = {};
1030
1072
  const queryParameters = {};
@@ -1111,10 +1153,10 @@ function createSearchClient({ appId: appIdOption, apiKey: apiKeyOption, authMode
1111
1153
  * @summary Retrieve all index content.
1112
1154
  * @param browse - The browse object.
1113
1155
  * @param browse.indexName - The index in which to perform the request.
1114
- * @param browse.browseRequest - The browseRequest object.
1156
+ * @param browse.browseParams - The browseParams object.
1115
1157
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
1116
1158
  */
1117
- browse({ indexName, browseRequest }, requestOptions) {
1159
+ browse({ indexName, browseParams }, requestOptions) {
1118
1160
  if (!indexName) {
1119
1161
  throw new Error('Parameter `indexName` is required when calling `browse`.');
1120
1162
  }
@@ -1126,7 +1168,7 @@ function createSearchClient({ appId: appIdOption, apiKey: apiKeyOption, authMode
1126
1168
  path: requestPath,
1127
1169
  queryParameters,
1128
1170
  headers,
1129
- data: browseRequest ? browseRequest : {},
1171
+ data: browseParams ? browseParams : {},
1130
1172
  };
1131
1173
  return transporter.request(request, requestOptions);
1132
1174
  },
@@ -1260,15 +1302,15 @@ function createSearchClient({ appId: appIdOption, apiKey: apiKeyOption, authMode
1260
1302
  * @summary Delete all records matching the query.
1261
1303
  * @param deleteBy - The deleteBy object.
1262
1304
  * @param deleteBy.indexName - The index in which to perform the request.
1263
- * @param deleteBy.searchParams - The searchParams object.
1305
+ * @param deleteBy.deleteByParams - The deleteByParams object.
1264
1306
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
1265
1307
  */
1266
- deleteBy({ indexName, searchParams }, requestOptions) {
1308
+ deleteBy({ indexName, deleteByParams }, requestOptions) {
1267
1309
  if (!indexName) {
1268
1310
  throw new Error('Parameter `indexName` is required when calling `deleteBy`.');
1269
1311
  }
1270
- if (!searchParams) {
1271
- throw new Error('Parameter `searchParams` is required when calling `deleteBy`.');
1312
+ if (!deleteByParams) {
1313
+ throw new Error('Parameter `deleteByParams` is required when calling `deleteBy`.');
1272
1314
  }
1273
1315
  const requestPath = '/1/indexes/{indexName}/deleteByQuery'.replace('{indexName}', encodeURIComponent(indexName));
1274
1316
  const headers = {};
@@ -1278,7 +1320,7 @@ function createSearchClient({ appId: appIdOption, apiKey: apiKeyOption, authMode
1278
1320
  path: requestPath,
1279
1321
  queryParameters,
1280
1322
  headers,
1281
- data: searchParams,
1323
+ data: deleteByParams,
1282
1324
  };
1283
1325
  return transporter.request(request, requestOptions);
1284
1326
  },
@@ -1517,7 +1559,7 @@ function createSearchClient({ appId: appIdOption, apiKey: apiKeyOption, authMode
1517
1559
  * @param getLogs.type - Type of log entries to retrieve. When omitted, all log entries are retrieved.
1518
1560
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
1519
1561
  */
1520
- getLogs({ offset, length, indexName, type }, requestOptions) {
1562
+ getLogs({ offset, length, indexName, type } = {}, requestOptions = undefined) {
1521
1563
  const requestPath = '/1/logs';
1522
1564
  const headers = {};
1523
1565
  const queryParameters = {};
@@ -1585,6 +1627,9 @@ function createSearchClient({ appId: appIdOption, apiKey: apiKeyOption, authMode
1585
1627
  if (!getObjectsParams) {
1586
1628
  throw new Error('Parameter `getObjectsParams` is required when calling `getObjects`.');
1587
1629
  }
1630
+ if (!getObjectsParams.requests) {
1631
+ throw new Error('Parameter `getObjectsParams.requests` is required when calling `getObjects`.');
1632
+ }
1588
1633
  const requestPath = '/1/indexes/*/objects';
1589
1634
  const headers = {};
1590
1635
  const queryParameters = {};
@@ -1776,7 +1821,7 @@ function createSearchClient({ appId: appIdOption, apiKey: apiKeyOption, authMode
1776
1821
  * @param hasPendingMappings.getClusters - If the clusters pending mapping state should be on the response.
1777
1822
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
1778
1823
  */
1779
- hasPendingMappings({ getClusters }, requestOptions) {
1824
+ hasPendingMappings({ getClusters } = {}, requestOptions = undefined) {
1780
1825
  const requestPath = '/1/clusters/mapping/pending';
1781
1826
  const headers = {};
1782
1827
  const queryParameters = {};
@@ -1835,7 +1880,7 @@ function createSearchClient({ appId: appIdOption, apiKey: apiKeyOption, authMode
1835
1880
  * @param listIndices.page - Requested page (zero-based). When specified, will retrieve a specific page; the page size is implicitly set to 100. When null, will retrieve all indices (no pagination).
1836
1881
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
1837
1882
  */
1838
- listIndices({ page }, requestOptions) {
1883
+ listIndices({ page } = {}, requestOptions = undefined) {
1839
1884
  const requestPath = '/1/indexes';
1840
1885
  const headers = {};
1841
1886
  const queryParameters = {};
@@ -1859,7 +1904,7 @@ function createSearchClient({ appId: appIdOption, apiKey: apiKeyOption, authMode
1859
1904
  * @param listUserIds.hitsPerPage - Maximum number of objects to retrieve.
1860
1905
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
1861
1906
  */
1862
- listUserIds({ page, hitsPerPage }, requestOptions) {
1907
+ listUserIds({ page, hitsPerPage } = {}, requestOptions = undefined) {
1863
1908
  const requestPath = '/1/clusters/mapping';
1864
1909
  const headers = {};
1865
1910
  const queryParameters = {};
@@ -1888,6 +1933,9 @@ function createSearchClient({ appId: appIdOption, apiKey: apiKeyOption, authMode
1888
1933
  if (!batchParams) {
1889
1934
  throw new Error('Parameter `batchParams` is required when calling `multipleBatch`.');
1890
1935
  }
1936
+ if (!batchParams.requests) {
1937
+ throw new Error('Parameter `batchParams.requests` is required when calling `multipleBatch`.');
1938
+ }
1891
1939
  const requestPath = '/1/indexes/*/batch';
1892
1940
  const headers = {};
1893
1941
  const queryParameters = {};
@@ -1941,19 +1989,19 @@ function createSearchClient({ appId: appIdOption, apiKey: apiKeyOption, authMode
1941
1989
  * @param partialUpdateObject - The partialUpdateObject object.
1942
1990
  * @param partialUpdateObject.indexName - The index in which to perform the request.
1943
1991
  * @param partialUpdateObject.objectID - Unique identifier of an object.
1944
- * @param partialUpdateObject.attributeOrBuiltInOperation - List of attributes to update.
1992
+ * @param partialUpdateObject.attributesToUpdate - Map of attribute(s) to update.
1945
1993
  * @param partialUpdateObject.createIfNotExists - Creates the record if it does not exist yet.
1946
1994
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
1947
1995
  */
1948
- partialUpdateObject({ indexName, objectID, attributeOrBuiltInOperation, createIfNotExists, }, requestOptions) {
1996
+ partialUpdateObject({ indexName, objectID, attributesToUpdate, createIfNotExists, }, requestOptions) {
1949
1997
  if (!indexName) {
1950
1998
  throw new Error('Parameter `indexName` is required when calling `partialUpdateObject`.');
1951
1999
  }
1952
2000
  if (!objectID) {
1953
2001
  throw new Error('Parameter `objectID` is required when calling `partialUpdateObject`.');
1954
2002
  }
1955
- if (!attributeOrBuiltInOperation) {
1956
- throw new Error('Parameter `attributeOrBuiltInOperation` is required when calling `partialUpdateObject`.');
2003
+ if (!attributesToUpdate) {
2004
+ throw new Error('Parameter `attributesToUpdate` is required when calling `partialUpdateObject`.');
1957
2005
  }
1958
2006
  const requestPath = '/1/indexes/{indexName}/{objectID}/partial'
1959
2007
  .replace('{indexName}', encodeURIComponent(indexName))
@@ -1968,7 +2016,7 @@ function createSearchClient({ appId: appIdOption, apiKey: apiKeyOption, authMode
1968
2016
  path: requestPath,
1969
2017
  queryParameters,
1970
2018
  headers,
1971
- data: attributeOrBuiltInOperation,
2019
+ data: attributesToUpdate,
1972
2020
  };
1973
2021
  return transporter.request(request, requestOptions);
1974
2022
  },
@@ -2169,17 +2217,17 @@ function createSearchClient({ appId: appIdOption, apiKey: apiKeyOption, authMode
2169
2217
  * @summary Save a batch of rules.
2170
2218
  * @param saveRules - The saveRules object.
2171
2219
  * @param saveRules.indexName - The index in which to perform the request.
2172
- * @param saveRules.rule - The rule object.
2220
+ * @param saveRules.rules - The rules object.
2173
2221
  * @param saveRules.forwardToReplicas - When true, changes are also propagated to replicas of the given indexName.
2174
2222
  * @param saveRules.clearExistingRules - When true, existing Rules are cleared before adding this batch. When false, existing Rules are kept.
2175
2223
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
2176
2224
  */
2177
- saveRules({ indexName, rule, forwardToReplicas, clearExistingRules, }, requestOptions) {
2225
+ saveRules({ indexName, rules, forwardToReplicas, clearExistingRules, }, requestOptions) {
2178
2226
  if (!indexName) {
2179
2227
  throw new Error('Parameter `indexName` is required when calling `saveRules`.');
2180
2228
  }
2181
- if (!rule) {
2182
- throw new Error('Parameter `rule` is required when calling `saveRules`.');
2229
+ if (!rules) {
2230
+ throw new Error('Parameter `rules` is required when calling `saveRules`.');
2183
2231
  }
2184
2232
  const requestPath = '/1/indexes/{indexName}/rules/batch'.replace('{indexName}', encodeURIComponent(indexName));
2185
2233
  const headers = {};
@@ -2195,7 +2243,7 @@ function createSearchClient({ appId: appIdOption, apiKey: apiKeyOption, authMode
2195
2243
  path: requestPath,
2196
2244
  queryParameters,
2197
2245
  headers,
2198
- data: rule,
2246
+ data: rules,
2199
2247
  };
2200
2248
  return transporter.request(request, requestOptions);
2201
2249
  },
@@ -2406,9 +2454,6 @@ function createSearchClient({ appId: appIdOption, apiKey: apiKeyOption, authMode
2406
2454
  if (!indexName) {
2407
2455
  throw new Error('Parameter `indexName` is required when calling `searchRules`.');
2408
2456
  }
2409
- if (!searchRulesParams) {
2410
- throw new Error('Parameter `searchRulesParams` is required when calling `searchRules`.');
2411
- }
2412
2457
  const requestPath = '/1/indexes/{indexName}/rules/search'.replace('{indexName}', encodeURIComponent(indexName));
2413
2458
  const headers = {};
2414
2459
  const queryParameters = {};
@@ -2417,7 +2462,7 @@ function createSearchClient({ appId: appIdOption, apiKey: apiKeyOption, authMode
2417
2462
  path: requestPath,
2418
2463
  queryParameters,
2419
2464
  headers,
2420
- data: searchRulesParams,
2465
+ data: searchRulesParams ? searchRulesParams : {},
2421
2466
  useReadTransporter: true,
2422
2467
  cacheable: true,
2423
2468
  };