@algolia/recommend 5.0.0-alpha.99 → 5.0.0-beta.10

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 (290) hide show
  1. package/LICENSE +21 -0
  2. package/dist/builds/browser.d.ts +21 -3
  3. package/dist/builds/browser.d.ts.map +1 -1
  4. package/dist/builds/node.d.ts +21 -3
  5. package/dist/builds/node.d.ts.map +1 -1
  6. package/dist/model/aroundPrecision.d.ts +1 -1
  7. package/dist/model/aroundPrecisionFromValueInner.d.ts +9 -0
  8. package/dist/model/aroundPrecisionFromValueInner.d.ts.map +1 -1
  9. package/dist/model/aroundRadius.d.ts +1 -1
  10. package/dist/model/aroundRadiusAll.d.ts +3 -0
  11. package/dist/model/aroundRadiusAll.d.ts.map +1 -1
  12. package/dist/model/autoFacetFilter.d.ts +14 -0
  13. package/dist/model/autoFacetFilter.d.ts.map +1 -0
  14. package/dist/model/baseRecommendRequest.d.ts +6 -4
  15. package/dist/model/baseRecommendRequest.d.ts.map +1 -1
  16. package/dist/model/baseSearchParamsWithoutQuery.d.ts +26 -29
  17. package/dist/model/baseSearchParamsWithoutQuery.d.ts.map +1 -1
  18. package/dist/model/baseSearchResponse.d.ts +8 -20
  19. package/dist/model/baseSearchResponse.d.ts.map +1 -1
  20. package/dist/model/boughtTogetherQuery.d.ts +4 -0
  21. package/dist/model/boughtTogetherQuery.d.ts.map +1 -0
  22. package/dist/model/clientMethodProps.d.ts +18 -11
  23. package/dist/model/clientMethodProps.d.ts.map +1 -1
  24. package/dist/model/condition.d.ts +6 -9
  25. package/dist/model/condition.d.ts.map +1 -1
  26. package/dist/model/consequence.d.ts +9 -17
  27. package/dist/model/consequence.d.ts.map +1 -1
  28. package/dist/model/deletedAtResponse.d.ts +2 -2
  29. package/dist/model/distinct.d.ts +1 -1
  30. package/dist/model/exactOnSingleWordQuery.d.ts +1 -1
  31. package/dist/model/facetFilters.d.ts +2 -3
  32. package/dist/model/facetFilters.d.ts.map +1 -1
  33. package/dist/model/facetOrdering.d.ts +2 -2
  34. package/dist/model/facets.d.ts +2 -2
  35. package/dist/model/fallbackParams.d.ts +3 -0
  36. package/dist/model/fallbackParams.d.ts.map +1 -0
  37. package/dist/model/fbtModel.d.ts +5 -0
  38. package/dist/model/fbtModel.d.ts.map +1 -0
  39. package/dist/model/frequentlyBoughtTogether.d.ts +9 -0
  40. package/dist/model/frequentlyBoughtTogether.d.ts.map +1 -0
  41. package/dist/model/getRecommendationsParams.d.ts +2 -2
  42. package/dist/model/hideConsequenceObject.d.ts +10 -0
  43. package/dist/model/hideConsequenceObject.d.ts.map +1 -0
  44. package/dist/model/highlightResult.d.ts +1 -1
  45. package/dist/model/highlightResult.d.ts.map +1 -1
  46. package/dist/model/highlightResultOption.d.ts +3 -3
  47. package/dist/model/ignorePlurals.d.ts +3 -2
  48. package/dist/model/ignorePlurals.d.ts.map +1 -1
  49. package/dist/model/index.d.ts +23 -24
  50. package/dist/model/index.d.ts.map +1 -1
  51. package/dist/model/indexSettingsAsSearchParams.d.ts +32 -35
  52. package/dist/model/indexSettingsAsSearchParams.d.ts.map +1 -1
  53. package/dist/model/lookingSimilar.d.ts +11 -0
  54. package/dist/model/lookingSimilar.d.ts.map +1 -0
  55. package/dist/model/lookingSimilarModel.d.ts +5 -0
  56. package/dist/model/lookingSimilarModel.d.ts.map +1 -0
  57. package/dist/model/lookingSimilarQuery.d.ts +4 -0
  58. package/dist/model/lookingSimilarQuery.d.ts.map +1 -0
  59. package/dist/model/matchLevel.d.ts +1 -1
  60. package/dist/model/mode.d.ts +1 -1
  61. package/dist/model/numericFilters.d.ts +2 -3
  62. package/dist/model/numericFilters.d.ts.map +1 -1
  63. package/dist/model/optionalFilters.d.ts +2 -3
  64. package/dist/model/optionalFilters.d.ts.map +1 -1
  65. package/dist/model/paramsConsequence.d.ts +19 -0
  66. package/dist/model/paramsConsequence.d.ts.map +1 -0
  67. package/dist/model/promoteConsequenceObject.d.ts +14 -0
  68. package/dist/model/promoteConsequenceObject.d.ts.map +1 -0
  69. package/dist/model/queryType.d.ts +1 -1
  70. package/dist/model/rankingInfo.d.ts +13 -10
  71. package/dist/model/rankingInfo.d.ts.map +1 -1
  72. package/dist/model/reRankingApplyFilter.d.ts +2 -3
  73. package/dist/model/reRankingApplyFilter.d.ts.map +1 -1
  74. package/dist/model/recommendHit.d.ts +3 -3
  75. package/dist/model/recommendRule.d.ts +24 -0
  76. package/dist/model/recommendRule.d.ts.map +1 -0
  77. package/dist/model/recommendRuleMetadata.d.ts +10 -0
  78. package/dist/model/recommendRuleMetadata.d.ts.map +1 -0
  79. package/dist/model/recommendationsHits.d.ts +0 -8
  80. package/dist/model/recommendationsHits.d.ts.map +1 -1
  81. package/dist/model/recommendationsRequest.d.ts +4 -2
  82. package/dist/model/recommendationsRequest.d.ts.map +1 -1
  83. package/dist/model/recommendationsResults.d.ts +2 -1
  84. package/dist/model/recommendationsResults.d.ts.map +1 -1
  85. package/dist/model/recommendedForYou.d.ts +7 -0
  86. package/dist/model/recommendedForYou.d.ts.map +1 -0
  87. package/dist/model/recommendedForYouModel.d.ts +1 -1
  88. package/dist/model/recommendedForYouQuery.d.ts +2 -2
  89. package/dist/model/recommendedForYouQuery.d.ts.map +1 -1
  90. package/dist/model/redirect.d.ts +1 -1
  91. package/dist/model/redirectURL.d.ts +7 -0
  92. package/dist/model/redirectURL.d.ts.map +1 -0
  93. package/dist/model/relatedModel.d.ts +5 -0
  94. package/dist/model/relatedModel.d.ts.map +1 -0
  95. package/dist/model/relatedProducts.d.ts +11 -0
  96. package/dist/model/relatedProducts.d.ts.map +1 -0
  97. package/dist/model/relatedQuery.d.ts +4 -0
  98. package/dist/model/relatedQuery.d.ts.map +1 -0
  99. package/dist/model/removeStopWords.d.ts +3 -2
  100. package/dist/model/removeStopWords.d.ts.map +1 -1
  101. package/dist/model/removeWordsIfNoResults.d.ts +1 -1
  102. package/dist/model/renderingContent.d.ts +3 -1
  103. package/dist/model/renderingContent.d.ts.map +1 -1
  104. package/dist/model/searchPagination.d.ts +19 -0
  105. package/dist/model/searchPagination.d.ts.map +1 -0
  106. package/dist/model/searchParams.d.ts +3 -0
  107. package/dist/model/searchParams.d.ts.map +1 -0
  108. package/dist/model/searchParamsObject.d.ts +3 -0
  109. package/dist/model/searchParamsObject.d.ts.map +1 -1
  110. package/dist/model/searchParamsQuery.d.ts +1 -1
  111. package/dist/model/searchRecommendRulesParams.d.ts +18 -6
  112. package/dist/model/searchRecommendRulesParams.d.ts.map +1 -1
  113. package/dist/model/searchRecommendRulesResponse.d.ts +6 -6
  114. package/dist/model/searchRecommendRulesResponse.d.ts.map +1 -1
  115. package/dist/model/semanticSearch.d.ts +2 -2
  116. package/dist/model/snippetResult.d.ts +1 -1
  117. package/dist/model/snippetResult.d.ts.map +1 -1
  118. package/dist/model/snippetResultOption.d.ts +2 -2
  119. package/dist/model/sortRemainingBy.d.ts +1 -1
  120. package/dist/model/supportedLanguage.d.ts +5 -0
  121. package/dist/model/supportedLanguage.d.ts.map +1 -0
  122. package/dist/model/tagFilters.d.ts +2 -3
  123. package/dist/model/tagFilters.d.ts.map +1 -1
  124. package/dist/model/taskStatus.d.ts +1 -1
  125. package/dist/model/trendingFacetHit.d.ts +2 -2
  126. package/dist/model/trendingFacets.d.ts +11 -0
  127. package/dist/model/trendingFacets.d.ts.map +1 -0
  128. package/dist/model/trendingFacetsModel.d.ts +1 -1
  129. package/dist/model/trendingFacetsQuery.d.ts +2 -2
  130. package/dist/model/trendingFacetsQuery.d.ts.map +1 -1
  131. package/dist/model/trendingItems.d.ts +15 -0
  132. package/dist/model/trendingItems.d.ts.map +1 -0
  133. package/dist/model/trendingItemsModel.d.ts +1 -1
  134. package/dist/model/trendingItemsQuery.d.ts +2 -2
  135. package/dist/model/trendingItemsQuery.d.ts.map +1 -1
  136. package/dist/model/typoTolerance.d.ts +1 -1
  137. package/dist/model/typoToleranceEnum.d.ts +3 -0
  138. package/dist/model/typoToleranceEnum.d.ts.map +1 -1
  139. package/dist/model/value.d.ts +5 -1
  140. package/dist/model/value.d.ts.map +1 -1
  141. package/dist/recommend.cjs +61 -45
  142. package/dist/recommend.esm.browser.js +58 -54
  143. package/dist/recommend.esm.node.js +61 -45
  144. package/dist/recommend.umd.js +2 -2
  145. package/dist/src/recommendClient.d.ts +36 -34
  146. package/dist/src/recommendClient.d.ts.map +1 -1
  147. package/model/aroundPrecision.ts +1 -1
  148. package/model/aroundPrecisionFromValueInner.ts +9 -0
  149. package/model/aroundRadius.ts +1 -1
  150. package/model/aroundRadiusAll.ts +3 -0
  151. package/model/autoFacetFilter.ts +16 -0
  152. package/model/baseRecommendRequest.ts +8 -4
  153. package/model/baseSearchParamsWithoutQuery.ts +26 -30
  154. package/model/baseSearchResponse.ts +9 -24
  155. package/model/{recommendationsQuery.ts → boughtTogetherQuery.ts} +3 -3
  156. package/model/clientMethodProps.ts +19 -11
  157. package/model/condition.ts +6 -12
  158. package/model/consequence.ts +9 -19
  159. package/model/deletedAtResponse.ts +2 -2
  160. package/model/distinct.ts +1 -1
  161. package/model/exactOnSingleWordQuery.ts +1 -1
  162. package/model/facetFilters.ts +2 -4
  163. package/model/facetOrdering.ts +2 -2
  164. package/model/facets.ts +2 -2
  165. package/model/{recommendationModels.ts → fallbackParams.ts} +3 -4
  166. package/model/fbtModel.ts +6 -0
  167. package/model/{consequenceHide.ts → frequentlyBoughtTogether.ts} +6 -5
  168. package/model/getRecommendationsParams.ts +2 -2
  169. package/model/hideConsequenceObject.ts +11 -0
  170. package/model/highlightResult.ts +1 -0
  171. package/model/highlightResultOption.ts +3 -3
  172. package/model/ignorePlurals.ts +4 -2
  173. package/model/index.ts +23 -24
  174. package/model/indexSettingsAsSearchParams.ts +32 -36
  175. package/model/lookingSimilar.ts +15 -0
  176. package/model/lookingSimilarModel.ts +6 -0
  177. package/model/lookingSimilarQuery.ts +6 -0
  178. package/model/matchLevel.ts +1 -1
  179. package/model/mode.ts +1 -1
  180. package/model/numericFilters.ts +2 -4
  181. package/model/optionalFilters.ts +2 -4
  182. package/model/paramsConsequence.ts +23 -0
  183. package/model/promoteConsequenceObject.ts +16 -0
  184. package/model/queryType.ts +1 -1
  185. package/model/rankingInfo.ts +13 -10
  186. package/model/reRankingApplyFilter.ts +2 -4
  187. package/model/recommendHit.ts +3 -3
  188. package/model/{ruleResponse.ts → recommendRule.ts} +7 -10
  189. package/model/{ruleResponseMetadata.ts → recommendRuleMetadata.ts} +5 -2
  190. package/model/recommendationsHits.ts +0 -10
  191. package/model/recommendationsRequest.ts +6 -2
  192. package/model/recommendationsResults.ts +4 -1
  193. package/model/{baseRecommendedForYouQuery.ts → recommendedForYou.ts} +3 -5
  194. package/model/recommendedForYouModel.ts +1 -1
  195. package/model/recommendedForYouQuery.ts +2 -3
  196. package/model/redirect.ts +1 -1
  197. package/model/{editType.ts → redirectURL.ts} +4 -2
  198. package/model/relatedModel.ts +6 -0
  199. package/model/relatedProducts.ts +15 -0
  200. package/model/relatedQuery.ts +6 -0
  201. package/model/removeStopWords.ts +4 -2
  202. package/model/removeWordsIfNoResults.ts +1 -1
  203. package/model/renderingContent.ts +4 -1
  204. package/model/searchPagination.ts +23 -0
  205. package/model/{mixedSearchFilters.ts → searchParams.ts} +3 -1
  206. package/model/searchParamsObject.ts +3 -0
  207. package/model/searchParamsQuery.ts +1 -1
  208. package/model/searchRecommendRulesParams.ts +21 -6
  209. package/model/searchRecommendRulesResponse.ts +6 -6
  210. package/model/semanticSearch.ts +2 -2
  211. package/model/snippetResult.ts +2 -1
  212. package/model/snippetResultOption.ts +2 -2
  213. package/model/sortRemainingBy.ts +1 -1
  214. package/model/supportedLanguage.ts +74 -0
  215. package/model/tagFilters.ts +2 -4
  216. package/model/taskStatus.ts +1 -1
  217. package/model/trendingFacetHit.ts +2 -2
  218. package/model/{baseTrendingFacetsQuery.ts → trendingFacets.ts} +7 -4
  219. package/model/trendingFacetsModel.ts +1 -1
  220. package/model/trendingFacetsQuery.ts +2 -3
  221. package/model/trendingItems.ts +20 -0
  222. package/model/trendingItemsModel.ts +1 -1
  223. package/model/trendingItemsQuery.ts +2 -2
  224. package/model/typoTolerance.ts +1 -1
  225. package/model/typoToleranceEnum.ts +3 -0
  226. package/model/value.ts +6 -1
  227. package/package.json +11 -8
  228. package/dist/model/anchoring.d.ts +0 -5
  229. package/dist/model/anchoring.d.ts.map +0 -1
  230. package/dist/model/automaticFacetFilter.d.ts +0 -18
  231. package/dist/model/automaticFacetFilter.d.ts.map +0 -1
  232. package/dist/model/automaticFacetFilters.d.ts +0 -6
  233. package/dist/model/automaticFacetFilters.d.ts.map +0 -1
  234. package/dist/model/baseRecommendationsQuery.d.ts +0 -12
  235. package/dist/model/baseRecommendationsQuery.d.ts.map +0 -1
  236. package/dist/model/baseRecommendedForYouQuery.d.ts +0 -8
  237. package/dist/model/baseRecommendedForYouQuery.d.ts.map +0 -1
  238. package/dist/model/baseRecommendedForYouQueryParameters.d.ts +0 -7
  239. package/dist/model/baseRecommendedForYouQueryParameters.d.ts.map +0 -1
  240. package/dist/model/baseTrendingFacetsQuery.d.ts +0 -9
  241. package/dist/model/baseTrendingFacetsQuery.d.ts.map +0 -1
  242. package/dist/model/baseTrendingItemsQuery.d.ts +0 -16
  243. package/dist/model/baseTrendingItemsQuery.d.ts.map +0 -1
  244. package/dist/model/consequenceHide.d.ts +0 -10
  245. package/dist/model/consequenceHide.d.ts.map +0 -1
  246. package/dist/model/consequenceParams.d.ts +0 -5
  247. package/dist/model/consequenceParams.d.ts.map +0 -1
  248. package/dist/model/consequenceQuery.d.ts +0 -6
  249. package/dist/model/consequenceQuery.d.ts.map +0 -1
  250. package/dist/model/consequenceQueryObject.d.ts +0 -12
  251. package/dist/model/consequenceQueryObject.d.ts.map +0 -1
  252. package/dist/model/edit.d.ts +0 -13
  253. package/dist/model/edit.d.ts.map +0 -1
  254. package/dist/model/editType.d.ts +0 -5
  255. package/dist/model/editType.d.ts.map +0 -1
  256. package/dist/model/mixedSearchFilters.d.ts +0 -2
  257. package/dist/model/mixedSearchFilters.d.ts.map +0 -1
  258. package/dist/model/params.d.ts +0 -13
  259. package/dist/model/params.d.ts.map +0 -1
  260. package/dist/model/promote.d.ts +0 -4
  261. package/dist/model/promote.d.ts.map +0 -1
  262. package/dist/model/promoteObjectID.d.ts +0 -14
  263. package/dist/model/promoteObjectID.d.ts.map +0 -1
  264. package/dist/model/promoteObjectIDs.d.ts +0 -14
  265. package/dist/model/promoteObjectIDs.d.ts.map +0 -1
  266. package/dist/model/recommendationModels.d.ts +0 -5
  267. package/dist/model/recommendationModels.d.ts.map +0 -1
  268. package/dist/model/recommendationsQuery.d.ts +0 -4
  269. package/dist/model/recommendationsQuery.d.ts.map +0 -1
  270. package/dist/model/recommendedForYouQueryParameters.d.ts +0 -4
  271. package/dist/model/recommendedForYouQueryParameters.d.ts.map +0 -1
  272. package/dist/model/ruleResponse.d.ts +0 -27
  273. package/dist/model/ruleResponse.d.ts.map +0 -1
  274. package/dist/model/ruleResponseMetadata.d.ts +0 -7
  275. package/dist/model/ruleResponseMetadata.d.ts.map +0 -1
  276. package/model/anchoring.ts +0 -6
  277. package/model/automaticFacetFilter.ts +0 -21
  278. package/model/automaticFacetFilters.ts +0 -8
  279. package/model/baseRecommendationsQuery.ts +0 -17
  280. package/model/baseRecommendedForYouQueryParameters.ts +0 -8
  281. package/model/baseTrendingItemsQuery.ts +0 -22
  282. package/model/consequenceParams.ts +0 -9
  283. package/model/consequenceQuery.ts +0 -8
  284. package/model/consequenceQueryObject.ts +0 -15
  285. package/model/edit.ts +0 -17
  286. package/model/params.ts +0 -18
  287. package/model/promote.ts +0 -6
  288. package/model/promoteObjectID.ts +0 -16
  289. package/model/promoteObjectIDs.ts +0 -16
  290. package/model/recommendedForYouQueryParameters.ts +0 -7
@@ -195,6 +195,14 @@ function createStatefulHost(host, status = 'up') {
195
195
  };
196
196
  }
197
197
 
198
+ function _defineProperty(e, r, t) {
199
+ return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
200
+ value: t,
201
+ enumerable: !0,
202
+ configurable: !0,
203
+ writable: !0
204
+ }) : e[r] = t, e;
205
+ }
198
206
  function _toPrimitive(t, r) {
199
207
  if ("object" != typeof t || !t) return t;
200
208
  var e = t[Symbol.toPrimitive];
@@ -207,21 +215,7 @@ function _toPrimitive(t, r) {
207
215
  }
208
216
  function _toPropertyKey(t) {
209
217
  var i = _toPrimitive(t, "string");
210
- return "symbol" == typeof i ? i : String(i);
211
- }
212
- function _defineProperty(obj, key, value) {
213
- key = _toPropertyKey(key);
214
- if (key in obj) {
215
- Object.defineProperty(obj, key, {
216
- value: value,
217
- enumerable: true,
218
- configurable: true,
219
- writable: true
220
- });
221
- } else {
222
- obj[key] = value;
223
- }
224
- return obj;
218
+ return "symbol" == typeof i ? i : i + "";
225
219
  }
226
220
 
227
221
  class AlgoliaError extends Error {
@@ -243,7 +237,7 @@ class ErrorWithStackTrace extends AlgoliaError {
243
237
  }
244
238
  class RetryError extends ErrorWithStackTrace {
245
239
  constructor(stackTrace) {
246
- super('Unreachable hosts - your application id may be incorrect. If the error persists, please create a ticket at https://support.algolia.com/ sharing steps we can use to reproduce the issue.', stackTrace, 'RetryError');
240
+ super('Unreachable hosts - your application id may be incorrect. If the error persists, please reach out to the Algolia Support team: https://alg.li/support.', stackTrace, 'RetryError');
247
241
  }
248
242
  }
249
243
  class ApiError extends ErrorWithStackTrace {
@@ -281,15 +275,14 @@ function shuffle(array) {
281
275
  }
282
276
  function serializeUrl(host, path, queryParameters) {
283
277
  const queryParametersAsString = serializeQueryParameters(queryParameters);
284
- let url = `${host.protocol}://${host.url}/${path.charAt(0) === '/' ? path.substr(1) : path}`;
278
+ let url = `${host.protocol}://${host.url}${host.port ? `:${host.port}` : ''}/${path.charAt(0) === '/' ? path.substring(1) : path}`;
285
279
  if (queryParametersAsString.length) {
286
280
  url += `?${queryParametersAsString}`;
287
281
  }
288
282
  return url;
289
283
  }
290
284
  function serializeQueryParameters(parameters) {
291
- const isObjectOrArray = value => Object.prototype.toString.call(value) === '[object Object]' || Object.prototype.toString.call(value) === '[object Array]';
292
- return Object.keys(parameters).map(key => `${key}=${encodeURIComponent(isObjectOrArray(parameters[key]) ? JSON.stringify(parameters[key]) : parameters[key])}`).join('&');
285
+ return Object.keys(parameters).filter(key => parameters[key] !== undefined).sort().map(key => `${key}=${encodeURIComponent(Object.prototype.toString.call(parameters[key]) === '[object Array]' ? parameters[key].join(',') : parameters[key]).replaceAll('+', '%20')}`).join('&');
293
286
  }
294
287
  function serializeData(request, requestOptions) {
295
288
  if (request.method === 'GET' || request.data === undefined && requestOptions.data === undefined) {
@@ -460,16 +453,13 @@ function createTransporter({
460
453
  if (host === undefined) {
461
454
  throw new RetryError(stackTraceWithoutCredentials(stackTrace));
462
455
  }
463
- let responseTimeout = requestOptions.timeout;
464
- if (responseTimeout === undefined) {
465
- responseTimeout = isRead ? timeouts.read : timeouts.write;
466
- }
456
+ let responseTimeout = isRead ? requestOptions.timeouts?.read || timeouts.read : requestOptions.timeouts?.write || timeouts.write;
467
457
  const payload = {
468
458
  data,
469
459
  headers,
470
460
  method: request.method,
471
461
  url: serializeUrl(host, request.path, queryParameters),
472
- connectTimeout: getTimeout(timeoutsCount, timeouts.connect),
462
+ connectTimeout: getTimeout(timeoutsCount, requestOptions.timeouts?.connect || timeouts.connect),
473
463
  responseTimeout: getTimeout(timeoutsCount, responseTimeout)
474
464
  };
475
465
  /**
@@ -697,7 +687,7 @@ function createXhrRequester() {
697
687
  }
698
688
 
699
689
  // Code generated by OpenAPI Generator (https://openapi-generator.tech), manual changes will be lost - read more on https://github.com/algolia/api-clients-automation. DO NOT EDIT.
700
- const apiClientVersion = '5.0.0-alpha.99';
690
+ const apiClientVersion = '5.0.0-beta.10';
701
691
  function getDefaultHosts(appId) {
702
692
  return [
703
693
  {
@@ -782,7 +772,6 @@ function createRecommendClient({ appId: appIdOption, apiKey: apiKeyOption, authM
782
772
  /**
783
773
  * This method allow you to send requests to the Algolia REST API.
784
774
  *
785
- * @summary Send requests to the Algolia REST API.
786
775
  * @param customDelete - The customDelete object.
787
776
  * @param customDelete.path - Path of the endpoint, anything after \"/1\" must be specified.
788
777
  * @param customDelete.parameters - Query parameters to apply to the current query.
@@ -792,7 +781,7 @@ function createRecommendClient({ appId: appIdOption, apiKey: apiKeyOption, authM
792
781
  if (!path) {
793
782
  throw new Error('Parameter `path` is required when calling `customDelete`.');
794
783
  }
795
- const requestPath = '/1{path}'.replace('{path}', path);
784
+ const requestPath = '/{path}'.replace('{path}', path);
796
785
  const headers = {};
797
786
  const queryParameters = parameters ? parameters : {};
798
787
  const request = {
@@ -806,7 +795,6 @@ function createRecommendClient({ appId: appIdOption, apiKey: apiKeyOption, authM
806
795
  /**
807
796
  * This method allow you to send requests to the Algolia REST API.
808
797
  *
809
- * @summary Send requests to the Algolia REST API.
810
798
  * @param customGet - The customGet object.
811
799
  * @param customGet.path - Path of the endpoint, anything after \"/1\" must be specified.
812
800
  * @param customGet.parameters - Query parameters to apply to the current query.
@@ -816,7 +804,7 @@ function createRecommendClient({ appId: appIdOption, apiKey: apiKeyOption, authM
816
804
  if (!path) {
817
805
  throw new Error('Parameter `path` is required when calling `customGet`.');
818
806
  }
819
- const requestPath = '/1{path}'.replace('{path}', path);
807
+ const requestPath = '/{path}'.replace('{path}', path);
820
808
  const headers = {};
821
809
  const queryParameters = parameters ? parameters : {};
822
810
  const request = {
@@ -830,7 +818,6 @@ function createRecommendClient({ appId: appIdOption, apiKey: apiKeyOption, authM
830
818
  /**
831
819
  * This method allow you to send requests to the Algolia REST API.
832
820
  *
833
- * @summary Send requests to the Algolia REST API.
834
821
  * @param customPost - The customPost object.
835
822
  * @param customPost.path - Path of the endpoint, anything after \"/1\" must be specified.
836
823
  * @param customPost.parameters - Query parameters to apply to the current query.
@@ -841,7 +828,7 @@ function createRecommendClient({ appId: appIdOption, apiKey: apiKeyOption, authM
841
828
  if (!path) {
842
829
  throw new Error('Parameter `path` is required when calling `customPost`.');
843
830
  }
844
- const requestPath = '/1{path}'.replace('{path}', path);
831
+ const requestPath = '/{path}'.replace('{path}', path);
845
832
  const headers = {};
846
833
  const queryParameters = parameters ? parameters : {};
847
834
  const request = {
@@ -856,7 +843,6 @@ function createRecommendClient({ appId: appIdOption, apiKey: apiKeyOption, authM
856
843
  /**
857
844
  * This method allow you to send requests to the Algolia REST API.
858
845
  *
859
- * @summary Send requests to the Algolia REST API.
860
846
  * @param customPut - The customPut object.
861
847
  * @param customPut.path - Path of the endpoint, anything after \"/1\" must be specified.
862
848
  * @param customPut.parameters - Query parameters to apply to the current query.
@@ -867,7 +853,7 @@ function createRecommendClient({ appId: appIdOption, apiKey: apiKeyOption, authM
867
853
  if (!path) {
868
854
  throw new Error('Parameter `path` is required when calling `customPut`.');
869
855
  }
870
- const requestPath = '/1{path}'.replace('{path}', path);
856
+ const requestPath = '/{path}'.replace('{path}', path);
871
857
  const headers = {};
872
858
  const queryParameters = parameters ? parameters : {};
873
859
  const request = {
@@ -880,13 +866,15 @@ function createRecommendClient({ appId: appIdOption, apiKey: apiKeyOption, authM
880
866
  return transporter.request(request, requestOptions);
881
867
  },
882
868
  /**
883
- * Delete a [Recommend rule](https://www.algolia.com/doc/guides/algolia-recommend/how-to/rules/).
869
+ * Deletes a Recommend rule from a recommendation scenario.
870
+ *
871
+ * Required API Key ACLs:
872
+ * - editSettings.
884
873
  *
885
- * @summary Delete a Recommend rule.
886
874
  * @param deleteRecommendRule - The deleteRecommendRule object.
887
- * @param deleteRecommendRule.indexName - Index on which to perform the request.
888
- * @param deleteRecommendRule.model - [Recommend models](https://www.algolia.com/doc/guides/algolia-recommend/overview/#recommend-models).
889
- * @param deleteRecommendRule.objectID - Unique record (object) identifier.
875
+ * @param deleteRecommendRule.indexName - Name of the index on which to perform the operation.
876
+ * @param deleteRecommendRule.model - [Recommend model](https://www.algolia.com/doc/guides/algolia-recommend/overview/#recommend-models).
877
+ * @param deleteRecommendRule.objectID - Unique record identifier.
890
878
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
891
879
  */
892
880
  deleteRecommendRule({ indexName, model, objectID }, requestOptions) {
@@ -914,13 +902,15 @@ function createRecommendClient({ appId: appIdOption, apiKey: apiKeyOption, authM
914
902
  return transporter.request(request, requestOptions);
915
903
  },
916
904
  /**
917
- * Return a [Recommend rule](https://www.algolia.com/doc/guides/algolia-recommend/how-to/rules/).
905
+ * Retrieves a Recommend rule that you previously created in the Algolia dashboard.
906
+ *
907
+ * Required API Key ACLs:
908
+ * - settings.
918
909
  *
919
- * @summary Get a Recommend rule.
920
910
  * @param getRecommendRule - The getRecommendRule object.
921
- * @param getRecommendRule.indexName - Index on which to perform the request.
922
- * @param getRecommendRule.model - [Recommend models](https://www.algolia.com/doc/guides/algolia-recommend/overview/#recommend-models).
923
- * @param getRecommendRule.objectID - Unique record (object) identifier.
911
+ * @param getRecommendRule.indexName - Name of the index on which to perform the operation.
912
+ * @param getRecommendRule.model - [Recommend model](https://www.algolia.com/doc/guides/algolia-recommend/overview/#recommend-models).
913
+ * @param getRecommendRule.objectID - Unique record identifier.
924
914
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
925
915
  */
926
916
  getRecommendRule({ indexName, model, objectID }, requestOptions) {
@@ -948,13 +938,15 @@ function createRecommendClient({ appId: appIdOption, apiKey: apiKeyOption, authM
948
938
  return transporter.request(request, requestOptions);
949
939
  },
950
940
  /**
951
- * Some operations, such as deleting a Recommend rule, will respond with a `taskID` value. Use this value here to check the status of that task.
941
+ * Checks the status of a given task. Deleting a Recommend rule is asynchronous. When you delete a rule, a task is created on a queue and completed depending on the load on the server. The API response includes a task ID that you can use to check the status.
942
+ *
943
+ * Required API Key ACLs:
944
+ * - editSettings.
952
945
  *
953
- * @summary Get a Recommend task\'s status.
954
946
  * @param getRecommendStatus - The getRecommendStatus object.
955
- * @param getRecommendStatus.indexName - Index on which to perform the request.
956
- * @param getRecommendStatus.model - [Recommend models](https://www.algolia.com/doc/guides/algolia-recommend/overview/#recommend-models).
957
- * @param getRecommendStatus.taskID - Unique identifier of a task. Numeric value (up to 64bits).
947
+ * @param getRecommendStatus.indexName - Name of the index on which to perform the operation.
948
+ * @param getRecommendStatus.model - [Recommend model](https://www.algolia.com/doc/guides/algolia-recommend/overview/#recommend-models).
949
+ * @param getRecommendStatus.taskID - Unique task identifier.
958
950
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
959
951
  */
960
952
  getRecommendStatus({ indexName, model, taskID }, requestOptions) {
@@ -982,13 +974,22 @@ function createRecommendClient({ appId: appIdOption, apiKey: apiKeyOption, authM
982
974
  return transporter.request(request, requestOptions);
983
975
  },
984
976
  /**
985
- * Returns results from either recommendation or trending models: - **Recommendations** are provided by the [Related Products](https://www.algolia.com/doc/guides/algolia-recommend/overview/#related-products-and-related-content) and [Frequently Bought Together](https://www.algolia.com/doc/guides/algolia-recommend/overview/#frequently-bought-together) models - **Trending** models are [Trending Items and Trending Facet Values](https://www.algolia.com/doc/guides/algolia-recommend/overview/#trending-items-and-trending-facet-values).
977
+ * Retrieves recommendations from selected AI models.
978
+ *
979
+ * Required API Key ACLs:
980
+ * - search.
986
981
  *
987
- * @summary Get recommendations and trending items.
988
982
  * @param getRecommendationsParams - The getRecommendationsParams object.
989
983
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
990
984
  */
991
985
  getRecommendations(getRecommendationsParams, requestOptions) {
986
+ if (getRecommendationsParams && Array.isArray(getRecommendationsParams)) {
987
+ const newSignatureRequest = {
988
+ requests: getRecommendationsParams,
989
+ };
990
+ // eslint-disable-next-line no-param-reassign
991
+ getRecommendationsParams = newSignatureRequest;
992
+ }
992
993
  if (!getRecommendationsParams) {
993
994
  throw new Error('Parameter `getRecommendationsParams` is required when calling `getRecommendations`.');
994
995
  }
@@ -1010,12 +1011,14 @@ function createRecommendClient({ appId: appIdOption, apiKey: apiKeyOption, authM
1010
1011
  return transporter.request(request, requestOptions);
1011
1012
  },
1012
1013
  /**
1013
- * List [Recommend rules](https://www.algolia.com/doc/guides/algolia-recommend/how-to/rules/).
1014
+ * Searches for Recommend rules. Use an empty query to list all rules for this recommendation scenario.
1015
+ *
1016
+ * Required API Key ACLs:
1017
+ * - settings.
1014
1018
  *
1015
- * @summary List Recommend rules.
1016
1019
  * @param searchRecommendRules - The searchRecommendRules object.
1017
- * @param searchRecommendRules.indexName - Index on which to perform the request.
1018
- * @param searchRecommendRules.model - [Recommend models](https://www.algolia.com/doc/guides/algolia-recommend/overview/#recommend-models).
1020
+ * @param searchRecommendRules.indexName - Name of the index on which to perform the operation.
1021
+ * @param searchRecommendRules.model - [Recommend model](https://www.algolia.com/doc/guides/algolia-recommend/overview/#recommend-models).
1019
1022
  * @param searchRecommendRules.searchRecommendRulesParams - The searchRecommendRulesParams object.
1020
1023
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
1021
1024
  */
@@ -1046,6 +1049,7 @@ function createRecommendClient({ appId: appIdOption, apiKey: apiKeyOption, authM
1046
1049
  }
1047
1050
 
1048
1051
  // Code generated by OpenAPI Generator (https://openapi-generator.tech), manual changes will be lost - read more on https://github.com/algolia/api-clients-automation. DO NOT EDIT.
1052
+ // eslint-disable-next-line @typescript-eslint/explicit-function-return-type
1049
1053
  function recommendClient(appId, apiKey, options) {
1050
1054
  if (!appId || typeof appId !== 'string') {
1051
1055
  throw new Error('`appId` is missing.');
@@ -2,7 +2,7 @@ import { createAuth, createTransporter, getAlgoliaAgent, shuffle, DEFAULT_CONNEC
2
2
  import { createHttpRequester } from '@algolia/requester-node-http';
3
3
 
4
4
  // Code generated by OpenAPI Generator (https://openapi-generator.tech), manual changes will be lost - read more on https://github.com/algolia/api-clients-automation. DO NOT EDIT.
5
- const apiClientVersion = '5.0.0-alpha.99';
5
+ const apiClientVersion = '5.0.0-beta.10';
6
6
  function getDefaultHosts(appId) {
7
7
  return [
8
8
  {
@@ -87,7 +87,6 @@ function createRecommendClient({ appId: appIdOption, apiKey: apiKeyOption, authM
87
87
  /**
88
88
  * This method allow you to send requests to the Algolia REST API.
89
89
  *
90
- * @summary Send requests to the Algolia REST API.
91
90
  * @param customDelete - The customDelete object.
92
91
  * @param customDelete.path - Path of the endpoint, anything after \"/1\" must be specified.
93
92
  * @param customDelete.parameters - Query parameters to apply to the current query.
@@ -97,7 +96,7 @@ function createRecommendClient({ appId: appIdOption, apiKey: apiKeyOption, authM
97
96
  if (!path) {
98
97
  throw new Error('Parameter `path` is required when calling `customDelete`.');
99
98
  }
100
- const requestPath = '/1{path}'.replace('{path}', path);
99
+ const requestPath = '/{path}'.replace('{path}', path);
101
100
  const headers = {};
102
101
  const queryParameters = parameters ? parameters : {};
103
102
  const request = {
@@ -111,7 +110,6 @@ function createRecommendClient({ appId: appIdOption, apiKey: apiKeyOption, authM
111
110
  /**
112
111
  * This method allow you to send requests to the Algolia REST API.
113
112
  *
114
- * @summary Send requests to the Algolia REST API.
115
113
  * @param customGet - The customGet object.
116
114
  * @param customGet.path - Path of the endpoint, anything after \"/1\" must be specified.
117
115
  * @param customGet.parameters - Query parameters to apply to the current query.
@@ -121,7 +119,7 @@ function createRecommendClient({ appId: appIdOption, apiKey: apiKeyOption, authM
121
119
  if (!path) {
122
120
  throw new Error('Parameter `path` is required when calling `customGet`.');
123
121
  }
124
- const requestPath = '/1{path}'.replace('{path}', path);
122
+ const requestPath = '/{path}'.replace('{path}', path);
125
123
  const headers = {};
126
124
  const queryParameters = parameters ? parameters : {};
127
125
  const request = {
@@ -135,7 +133,6 @@ function createRecommendClient({ appId: appIdOption, apiKey: apiKeyOption, authM
135
133
  /**
136
134
  * This method allow you to send requests to the Algolia REST API.
137
135
  *
138
- * @summary Send requests to the Algolia REST API.
139
136
  * @param customPost - The customPost object.
140
137
  * @param customPost.path - Path of the endpoint, anything after \"/1\" must be specified.
141
138
  * @param customPost.parameters - Query parameters to apply to the current query.
@@ -146,7 +143,7 @@ function createRecommendClient({ appId: appIdOption, apiKey: apiKeyOption, authM
146
143
  if (!path) {
147
144
  throw new Error('Parameter `path` is required when calling `customPost`.');
148
145
  }
149
- const requestPath = '/1{path}'.replace('{path}', path);
146
+ const requestPath = '/{path}'.replace('{path}', path);
150
147
  const headers = {};
151
148
  const queryParameters = parameters ? parameters : {};
152
149
  const request = {
@@ -161,7 +158,6 @@ function createRecommendClient({ appId: appIdOption, apiKey: apiKeyOption, authM
161
158
  /**
162
159
  * This method allow you to send requests to the Algolia REST API.
163
160
  *
164
- * @summary Send requests to the Algolia REST API.
165
161
  * @param customPut - The customPut object.
166
162
  * @param customPut.path - Path of the endpoint, anything after \"/1\" must be specified.
167
163
  * @param customPut.parameters - Query parameters to apply to the current query.
@@ -172,7 +168,7 @@ function createRecommendClient({ appId: appIdOption, apiKey: apiKeyOption, authM
172
168
  if (!path) {
173
169
  throw new Error('Parameter `path` is required when calling `customPut`.');
174
170
  }
175
- const requestPath = '/1{path}'.replace('{path}', path);
171
+ const requestPath = '/{path}'.replace('{path}', path);
176
172
  const headers = {};
177
173
  const queryParameters = parameters ? parameters : {};
178
174
  const request = {
@@ -185,13 +181,15 @@ function createRecommendClient({ appId: appIdOption, apiKey: apiKeyOption, authM
185
181
  return transporter.request(request, requestOptions);
186
182
  },
187
183
  /**
188
- * Delete a [Recommend rule](https://www.algolia.com/doc/guides/algolia-recommend/how-to/rules/).
184
+ * Deletes a Recommend rule from a recommendation scenario.
185
+ *
186
+ * Required API Key ACLs:
187
+ * - editSettings.
189
188
  *
190
- * @summary Delete a Recommend rule.
191
189
  * @param deleteRecommendRule - The deleteRecommendRule object.
192
- * @param deleteRecommendRule.indexName - Index on which to perform the request.
193
- * @param deleteRecommendRule.model - [Recommend models](https://www.algolia.com/doc/guides/algolia-recommend/overview/#recommend-models).
194
- * @param deleteRecommendRule.objectID - Unique record (object) identifier.
190
+ * @param deleteRecommendRule.indexName - Name of the index on which to perform the operation.
191
+ * @param deleteRecommendRule.model - [Recommend model](https://www.algolia.com/doc/guides/algolia-recommend/overview/#recommend-models).
192
+ * @param deleteRecommendRule.objectID - Unique record identifier.
195
193
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
196
194
  */
197
195
  deleteRecommendRule({ indexName, model, objectID }, requestOptions) {
@@ -219,13 +217,15 @@ function createRecommendClient({ appId: appIdOption, apiKey: apiKeyOption, authM
219
217
  return transporter.request(request, requestOptions);
220
218
  },
221
219
  /**
222
- * Return a [Recommend rule](https://www.algolia.com/doc/guides/algolia-recommend/how-to/rules/).
220
+ * Retrieves a Recommend rule that you previously created in the Algolia dashboard.
221
+ *
222
+ * Required API Key ACLs:
223
+ * - settings.
223
224
  *
224
- * @summary Get a Recommend rule.
225
225
  * @param getRecommendRule - The getRecommendRule object.
226
- * @param getRecommendRule.indexName - Index on which to perform the request.
227
- * @param getRecommendRule.model - [Recommend models](https://www.algolia.com/doc/guides/algolia-recommend/overview/#recommend-models).
228
- * @param getRecommendRule.objectID - Unique record (object) identifier.
226
+ * @param getRecommendRule.indexName - Name of the index on which to perform the operation.
227
+ * @param getRecommendRule.model - [Recommend model](https://www.algolia.com/doc/guides/algolia-recommend/overview/#recommend-models).
228
+ * @param getRecommendRule.objectID - Unique record identifier.
229
229
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
230
230
  */
231
231
  getRecommendRule({ indexName, model, objectID }, requestOptions) {
@@ -253,13 +253,15 @@ function createRecommendClient({ appId: appIdOption, apiKey: apiKeyOption, authM
253
253
  return transporter.request(request, requestOptions);
254
254
  },
255
255
  /**
256
- * Some operations, such as deleting a Recommend rule, will respond with a `taskID` value. Use this value here to check the status of that task.
256
+ * Checks the status of a given task. Deleting a Recommend rule is asynchronous. When you delete a rule, a task is created on a queue and completed depending on the load on the server. The API response includes a task ID that you can use to check the status.
257
+ *
258
+ * Required API Key ACLs:
259
+ * - editSettings.
257
260
  *
258
- * @summary Get a Recommend task\'s status.
259
261
  * @param getRecommendStatus - The getRecommendStatus object.
260
- * @param getRecommendStatus.indexName - Index on which to perform the request.
261
- * @param getRecommendStatus.model - [Recommend models](https://www.algolia.com/doc/guides/algolia-recommend/overview/#recommend-models).
262
- * @param getRecommendStatus.taskID - Unique identifier of a task. Numeric value (up to 64bits).
262
+ * @param getRecommendStatus.indexName - Name of the index on which to perform the operation.
263
+ * @param getRecommendStatus.model - [Recommend model](https://www.algolia.com/doc/guides/algolia-recommend/overview/#recommend-models).
264
+ * @param getRecommendStatus.taskID - Unique task identifier.
263
265
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
264
266
  */
265
267
  getRecommendStatus({ indexName, model, taskID }, requestOptions) {
@@ -287,13 +289,22 @@ function createRecommendClient({ appId: appIdOption, apiKey: apiKeyOption, authM
287
289
  return transporter.request(request, requestOptions);
288
290
  },
289
291
  /**
290
- * Returns results from either recommendation or trending models: - **Recommendations** are provided by the [Related Products](https://www.algolia.com/doc/guides/algolia-recommend/overview/#related-products-and-related-content) and [Frequently Bought Together](https://www.algolia.com/doc/guides/algolia-recommend/overview/#frequently-bought-together) models - **Trending** models are [Trending Items and Trending Facet Values](https://www.algolia.com/doc/guides/algolia-recommend/overview/#trending-items-and-trending-facet-values).
292
+ * Retrieves recommendations from selected AI models.
293
+ *
294
+ * Required API Key ACLs:
295
+ * - search.
291
296
  *
292
- * @summary Get recommendations and trending items.
293
297
  * @param getRecommendationsParams - The getRecommendationsParams object.
294
298
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
295
299
  */
296
300
  getRecommendations(getRecommendationsParams, requestOptions) {
301
+ if (getRecommendationsParams && Array.isArray(getRecommendationsParams)) {
302
+ const newSignatureRequest = {
303
+ requests: getRecommendationsParams,
304
+ };
305
+ // eslint-disable-next-line no-param-reassign
306
+ getRecommendationsParams = newSignatureRequest;
307
+ }
297
308
  if (!getRecommendationsParams) {
298
309
  throw new Error('Parameter `getRecommendationsParams` is required when calling `getRecommendations`.');
299
310
  }
@@ -315,12 +326,14 @@ function createRecommendClient({ appId: appIdOption, apiKey: apiKeyOption, authM
315
326
  return transporter.request(request, requestOptions);
316
327
  },
317
328
  /**
318
- * List [Recommend rules](https://www.algolia.com/doc/guides/algolia-recommend/how-to/rules/).
329
+ * Searches for Recommend rules. Use an empty query to list all rules for this recommendation scenario.
330
+ *
331
+ * Required API Key ACLs:
332
+ * - settings.
319
333
  *
320
- * @summary List Recommend rules.
321
334
  * @param searchRecommendRules - The searchRecommendRules object.
322
- * @param searchRecommendRules.indexName - Index on which to perform the request.
323
- * @param searchRecommendRules.model - [Recommend models](https://www.algolia.com/doc/guides/algolia-recommend/overview/#recommend-models).
335
+ * @param searchRecommendRules.indexName - Name of the index on which to perform the operation.
336
+ * @param searchRecommendRules.model - [Recommend model](https://www.algolia.com/doc/guides/algolia-recommend/overview/#recommend-models).
324
337
  * @param searchRecommendRules.searchRecommendRulesParams - The searchRecommendRulesParams object.
325
338
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
326
339
  */
@@ -351,6 +364,7 @@ function createRecommendClient({ appId: appIdOption, apiKey: apiKeyOption, authM
351
364
  }
352
365
 
353
366
  // Code generated by OpenAPI Generator (https://openapi-generator.tech), manual changes will be lost - read more on https://github.com/algolia/api-clients-automation. DO NOT EDIT.
367
+ // eslint-disable-next-line @typescript-eslint/explicit-function-return-type
354
368
  function recommendClient(appId, apiKey, options) {
355
369
  if (!appId || typeof appId !== 'string') {
356
370
  throw new Error('`appId` is missing.');
@@ -358,21 +372,23 @@ function recommendClient(appId, apiKey, options) {
358
372
  if (!apiKey || typeof apiKey !== 'string') {
359
373
  throw new Error('`apiKey` is missing.');
360
374
  }
361
- return createRecommendClient({
362
- appId,
363
- apiKey,
364
- timeouts: {
365
- connect: DEFAULT_CONNECT_TIMEOUT_NODE,
366
- read: DEFAULT_READ_TIMEOUT_NODE,
367
- write: DEFAULT_WRITE_TIMEOUT_NODE,
368
- },
369
- requester: createHttpRequester(),
370
- algoliaAgents: [{ segment: 'Node.js', version: process.versions.node }],
371
- responsesCache: createNullCache(),
372
- requestsCache: createNullCache(),
373
- hostsCache: createMemoryCache(),
374
- ...options,
375
- });
375
+ return {
376
+ ...createRecommendClient({
377
+ appId,
378
+ apiKey,
379
+ timeouts: {
380
+ connect: DEFAULT_CONNECT_TIMEOUT_NODE,
381
+ read: DEFAULT_READ_TIMEOUT_NODE,
382
+ write: DEFAULT_WRITE_TIMEOUT_NODE,
383
+ },
384
+ requester: createHttpRequester(),
385
+ algoliaAgents: [{ segment: 'Node.js', version: process.versions.node }],
386
+ responsesCache: createNullCache(),
387
+ requestsCache: createNullCache(),
388
+ hostsCache: createMemoryCache(),
389
+ ...options,
390
+ }),
391
+ };
376
392
  }
377
393
 
378
394
  export { apiClientVersion, recommendClient };
@@ -1,2 +1,2 @@
1
- /*! recommend.umd.js | 5.0.0-alpha.99 | © Algolia, inc. | https://github.com/algolia/algoliasearch-client-javascript */
2
- !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self)["@algolia/recommend"]={})}(this,(function(e){"use strict";function t(e){let t;const r=`algolia-client-js-${e.key}`;function a(){return void 0===t&&(t=e.localStorage||window.localStorage),t}function s(){return JSON.parse(a().getItem(r)||"{}")}function o(e){a().setItem(r,JSON.stringify(e))}return{get:(t,r,a={miss:()=>Promise.resolve()})=>Promise.resolve().then((()=>(function(){const t=e.timeToLive?1e3*e.timeToLive:null,r=s(),a=Object.fromEntries(Object.entries(r).filter((([,e])=>void 0!==e.timestamp)));if(o(a),!t)return;o(Object.fromEntries(Object.entries(a).filter((([,e])=>{const r=(new Date).getTime();return!(e.timestamp+t<r)}))))}(),s()[JSON.stringify(t)]))).then((e=>Promise.all([e?e.value:r(),void 0!==e]))).then((([e,t])=>Promise.all([e,t||a.miss(e)]))).then((([e])=>e)),set:(e,t)=>Promise.resolve().then((()=>{const o=s();return o[JSON.stringify(e)]={timestamp:(new Date).getTime(),value:t},a().setItem(r,JSON.stringify(o)),t})),delete:e=>Promise.resolve().then((()=>{const t=s();delete t[JSON.stringify(e)],a().setItem(r,JSON.stringify(t))})),clear:()=>Promise.resolve().then((()=>{a().removeItem(r)}))}}function r(e){const t=[...e.caches],a=t.shift();return void 0===a?{get:(e,t,r={miss:()=>Promise.resolve()})=>t().then((e=>Promise.all([e,r.miss(e)]))).then((([e])=>e)),set:(e,t)=>Promise.resolve(t),delete:e=>Promise.resolve(),clear:()=>Promise.resolve()}:{get:(e,s,o={miss:()=>Promise.resolve()})=>a.get(e,s,o).catch((()=>r({caches:t}).get(e,s,o))),set:(e,s)=>a.set(e,s).catch((()=>r({caches:t}).set(e,s))),delete:e=>a.delete(e).catch((()=>r({caches:t}).delete(e))),clear:()=>a.clear().catch((()=>r({caches:t}).clear()))}}function a(e={serializable:!0}){let t={};return{get(r,a,s={miss:()=>Promise.resolve()}){const o=JSON.stringify(r);if(o in t)return Promise.resolve(e.serializable?JSON.parse(t[o]):t[o]);const n=a();return n.then((e=>s.miss(e))).then((()=>n))},set:(r,a)=>(t[JSON.stringify(r)]=e.serializable?JSON.stringify(a):a,Promise.resolve(a)),delete:e=>(delete t[JSON.stringify(e)],Promise.resolve()),clear:()=>(t={},Promise.resolve())}}const s=12e4;function o(e,t="up"){const r=Date.now();return{...e,status:t,lastUpdate:r,isUp:function(){return"up"===t||Date.now()-r>s},isTimedOut:function(){return"timed out"===t&&Date.now()-r<=s}}}function n(e){var t=function(e,t){if("object"!=typeof e||!e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var a=r.call(e,t||"default");if("object"!=typeof a)return a;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:String(t)}function i(e,t,r){return(t=n(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}class c extends Error{constructor(e,t){super(e),i(this,"name","AlgoliaError"),t&&(this.name=t)}}class u extends c{constructor(e,t,r){super(e,r),i(this,"stackTrace",void 0),this.stackTrace=t}}class l extends u{constructor(e){super("Unreachable hosts - your application id may be incorrect. If the error persists, please create a ticket at https://support.algolia.com/ sharing steps we can use to reproduce the issue.",e,"RetryError")}}class m extends u{constructor(e,t,r,a="ApiError"){super(e,r,a),i(this,"status",void 0),this.status=t}}class d extends c{constructor(e,t){super(e,"DeserializationError"),i(this,"response",void 0),this.response=t}}class h extends m{constructor(e,t,r,a){super(e,t,a,"DetailedApiError"),i(this,"error",void 0),this.error=r}}function p(e,t,r){const a=function(e){const t=e=>"[object Object]"===Object.prototype.toString.call(e)||"[object Array]"===Object.prototype.toString.call(e);return Object.keys(e).map((r=>`${r}=${encodeURIComponent(t(e[r])?JSON.stringify(e[r]):e[r])}`)).join("&")}(r);let s=`${e.protocol}://${e.url}/${"/"===t.charAt(0)?t.substr(1):t}`;return a.length&&(s+=`?${a}`),s}function g(e){const t=e.request.headers["x-algolia-api-key"]?{"x-algolia-api-key":"*****"}:{};return{...e,request:{...e.request,headers:{...e.request.headers,...t}}}}function f({hosts:e,hostsCache:t,baseHeaders:r,baseQueryParameters:a,algoliaAgent:s,timeouts:n,requester:i,requestsCache:c,responsesCache:u}){async function f(c,u,f=!0){const w=[],y=function(e,t){if("GET"===e.method||void 0===e.data&&void 0===t.data)return;const r=Array.isArray(e.data)?e.data:{...e.data,...t.data};return JSON.stringify(r)}(c,u),P=function(e,t,r){const a={Accept:"application/json",...e,...t,...r},s={};return Object.keys(a).forEach((e=>{const t=a[e];s[e.toLowerCase()]=t})),s}(r,c.headers,u.headers),q="GET"===c.method?{...c.data,...u.data}:{},b={...a,...c.queryParameters,...q};if(s.value&&(b["x-algolia-agent"]=s.value),u&&u.queryParameters)for(const e of Object.keys(u.queryParameters))u.queryParameters[e]&&"[object Object]"!==Object.prototype.toString.call(u.queryParameters[e])?b[e]=u.queryParameters[e].toString():b[e]=u.queryParameters[e];let v=0;const R=async(e,r)=>{const a=e.pop();if(void 0===a)throw new l(function(e){return e.map((e=>g(e)))}(w));let s=u.timeout;void 0===s&&(s=f?n.read:n.write);const q={data:y,headers:P,method:c.method,url:p(a,c.path,b),connectTimeout:r(v,n.connect),responseTimeout:r(v,s)},T=t=>{const r={request:q,response:t,host:a,triesLeft:e.length};return w.push(r),r},O=await i.send(q);if(function({isTimedOut:e,status:t}){return e||function({isTimedOut:e,status:t}){return!e&&0==~~t}({isTimedOut:e,status:t})||2!=~~(t/100)&&4!=~~(t/100)}(O)){const s=T(O);return O.isTimedOut&&v++,console.log("Retryable failure",g(s)),await t.set(a,o(a,O.isTimedOut?"timed out":"down")),R(e,r)}if(function({status:e}){return 2==~~(e/100)}(O))return function(e){try{return JSON.parse(e.content)}catch(t){throw new d(t.message,e)}}(O);throw T(O),function({content:e,status:t},r){try{const a=JSON.parse(e);return"error"in a?new h(a.message,t,a.error,r):new m(a.message,t,r)}catch(e){}return new m(e,t,r)}(O,w)},T=e.filter((e=>"readWrite"===e.accept||(f?"read"===e.accept:"write"===e.accept))),O=await async function(e){const r=await Promise.all(e.map((e=>t.get(e,(()=>Promise.resolve(o(e))))))),a=r.filter((e=>e.isUp())),s=r.filter((e=>e.isTimedOut())),n=[...a,...s];return{hosts:n.length>0?n:e,getTimeout:(e,t)=>(0===s.length&&0===e?1:s.length+3+e)*t}}(T);return R([...O.hosts].reverse(),O.getTimeout)}return{hostsCache:t,requester:i,timeouts:n,algoliaAgent:s,baseHeaders:r,baseQueryParameters:a,hosts:e,request:function(e,t={}){const s=e.useReadTransporter||"GET"===e.method;if(!s)return f(e,t,s);const o=()=>f(e,t);if(!0!==(t.cacheable||e.cacheable))return o();const n={request:e,requestOptions:t,transporter:{queryParameters:a,headers:r}};return u.get(n,(()=>c.get(n,(()=>c.set(n,o()).then((e=>Promise.all([c.delete(n),e])),(e=>Promise.all([c.delete(n),Promise.reject(e)]))).then((([e,t])=>t))))),{miss:e=>u.set(n,e)})},requestsCache:c,responsesCache:u}}function w({algoliaAgents:e,client:t,version:r}){const a=function(e){const t={value:`Algolia for JavaScript (${e})`,add(e){const r=`; ${e.segment}${void 0!==e.version?` (${e.version})`:""}`;return-1===t.value.indexOf(r)&&(t.value=`${t.value}${r}`),t}};return t}(r).add({segment:t,version:r});return e.forEach((e=>a.add(e))),a}const y="5.0.0-alpha.99";function P(e){return[{url:`${e}-dsn.algolia.net`,accept:"read",protocol:"https"},{url:`${e}.algolia.net`,accept:"write",protocol:"https"}].concat(function(e){const t=e;for(let r=e.length-1;r>0;r--){const a=Math.floor(Math.random()*(r+1)),s=e[r];t[r]=e[a],t[a]=s}return t}([{url:`${e}-1.algolianet.com`,accept:"readWrite",protocol:"https"},{url:`${e}-2.algolianet.com`,accept:"readWrite",protocol:"https"},{url:`${e}-3.algolianet.com`,accept:"readWrite",protocol:"https"}]))}e.apiClientVersion=y,e.recommendClient=function(e,s,o){if(!e||"string"!=typeof e)throw new Error("`appId` is missing.");if(!s||"string"!=typeof s)throw new Error("`apiKey` is missing.");return function({appId:e,apiKey:t,authMode:r,algoliaAgents:a,...s}){const o=function(e,t,r="WithinHeaders"){const a={"x-algolia-api-key":t,"x-algolia-application-id":e};return{headers:()=>"WithinHeaders"===r?a:{},queryParameters:()=>"WithinQueryParameters"===r?a:{}}}(e,t,r),n=f({hosts:P(e),...s,algoliaAgent:w({algoliaAgents:a,client:"Recommend",version:y}),baseHeaders:{"content-type":"text/plain",...o.headers(),...s.baseHeaders},baseQueryParameters:{...o.queryParameters(),...s.baseQueryParameters}});return{transporter:n,appId:e,clearCache:()=>Promise.all([n.requestsCache.clear(),n.responsesCache.clear()]).then((()=>{})),get _ua(){return n.algoliaAgent.value},addAlgoliaAgent(e,t){n.algoliaAgent.add({segment:e,version:t})},customDelete({path:e,parameters:t},r){if(!e)throw new Error("Parameter `path` is required when calling `customDelete`.");const a={method:"DELETE",path:"/1{path}".replace("{path}",e),queryParameters:t||{},headers:{}};return n.request(a,r)},customGet({path:e,parameters:t},r){if(!e)throw new Error("Parameter `path` is required when calling `customGet`.");const a={method:"GET",path:"/1{path}".replace("{path}",e),queryParameters:t||{},headers:{}};return n.request(a,r)},customPost({path:e,parameters:t,body:r},a){if(!e)throw new Error("Parameter `path` is required when calling `customPost`.");const s={method:"POST",path:"/1{path}".replace("{path}",e),queryParameters:t||{},headers:{},data:r||{}};return n.request(s,a)},customPut({path:e,parameters:t,body:r},a){if(!e)throw new Error("Parameter `path` is required when calling `customPut`.");const s={method:"PUT",path:"/1{path}".replace("{path}",e),queryParameters:t||{},headers:{},data:r||{}};return n.request(s,a)},deleteRecommendRule({indexName:e,model:t,objectID:r},a){if(!e)throw new Error("Parameter `indexName` is required when calling `deleteRecommendRule`.");if(!t)throw new Error("Parameter `model` is required when calling `deleteRecommendRule`.");if(!r)throw new Error("Parameter `objectID` is required when calling `deleteRecommendRule`.");const s={method:"DELETE",path:"/1/indexes/{indexName}/{model}/recommend/rules/{objectID}".replace("{indexName}",encodeURIComponent(e)).replace("{model}",encodeURIComponent(t)).replace("{objectID}",encodeURIComponent(r)),queryParameters:{},headers:{}};return n.request(s,a)},getRecommendRule({indexName:e,model:t,objectID:r},a){if(!e)throw new Error("Parameter `indexName` is required when calling `getRecommendRule`.");if(!t)throw new Error("Parameter `model` is required when calling `getRecommendRule`.");if(!r)throw new Error("Parameter `objectID` is required when calling `getRecommendRule`.");const s={method:"GET",path:"/1/indexes/{indexName}/{model}/recommend/rules/{objectID}".replace("{indexName}",encodeURIComponent(e)).replace("{model}",encodeURIComponent(t)).replace("{objectID}",encodeURIComponent(r)),queryParameters:{},headers:{}};return n.request(s,a)},getRecommendStatus({indexName:e,model:t,taskID:r},a){if(!e)throw new Error("Parameter `indexName` is required when calling `getRecommendStatus`.");if(!t)throw new Error("Parameter `model` is required when calling `getRecommendStatus`.");if(!r)throw new Error("Parameter `taskID` is required when calling `getRecommendStatus`.");const s={method:"GET",path:"/1/indexes/{indexName}/{model}/task/{taskID}".replace("{indexName}",encodeURIComponent(e)).replace("{model}",encodeURIComponent(t)).replace("{taskID}",encodeURIComponent(r)),queryParameters:{},headers:{}};return n.request(s,a)},getRecommendations(e,t){if(!e)throw new Error("Parameter `getRecommendationsParams` is required when calling `getRecommendations`.");if(!e.requests)throw new Error("Parameter `getRecommendationsParams.requests` is required when calling `getRecommendations`.");const r={method:"POST",path:"/1/indexes/*/recommendations",queryParameters:{},headers:{},data:e,useReadTransporter:!0,cacheable:!0};return n.request(r,t)},searchRecommendRules({indexName:e,model:t,searchRecommendRulesParams:r},a){if(!e)throw new Error("Parameter `indexName` is required when calling `searchRecommendRules`.");if(!t)throw new Error("Parameter `model` is required when calling `searchRecommendRules`.");const s={method:"POST",path:"/1/indexes/{indexName}/{model}/recommend/rules/search".replace("{indexName}",encodeURIComponent(e)).replace("{model}",encodeURIComponent(t)),queryParameters:{},headers:{},data:r||{},useReadTransporter:!0,cacheable:!0};return n.request(s,a)}}}({appId:e,apiKey:s,timeouts:{connect:1e3,read:2e3,write:3e4},requester:{send:function(e){return new Promise((t=>{const r=new XMLHttpRequest;r.open(e.method,e.url,!0),Object.keys(e.headers).forEach((t=>r.setRequestHeader(t,e.headers[t])));const a=(e,a)=>setTimeout((()=>{r.abort(),t({status:0,content:a,isTimedOut:!0})}),e),s=a(e.connectTimeout,"Connection timeout");let o;r.onreadystatechange=()=>{r.readyState>r.OPENED&&void 0===o&&(clearTimeout(s),o=a(e.responseTimeout,"Socket timeout"))},r.onerror=()=>{0===r.status&&(clearTimeout(s),clearTimeout(o),t({content:r.responseText||"Network request failed",status:r.status,isTimedOut:!1}))},r.onload=()=>{clearTimeout(s),clearTimeout(o),t({content:r.responseText,status:r.status,isTimedOut:!1})},r.send(e.data)}))}},algoliaAgents:[{segment:"Browser"}],authMode:"WithinQueryParameters",responsesCache:a(),requestsCache:a({serializable:!1}),hostsCache:r({caches:[t({key:`${y}-${e}`}),a()]}),...o})}}));
1
+ /*! recommend.umd.js | 5.0.0-beta.10 | © Algolia, inc. | https://github.com/algolia/algoliasearch-client-javascript */
2
+ !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self)["@algolia/recommend"]={})}(this,(function(e){"use strict";function t(e){let t;const r=`algolia-client-js-${e.key}`;function a(){return void 0===t&&(t=e.localStorage||window.localStorage),t}function o(){return JSON.parse(a().getItem(r)||"{}")}function s(e){a().setItem(r,JSON.stringify(e))}return{get:(t,r,a={miss:()=>Promise.resolve()})=>Promise.resolve().then((()=>(function(){const t=e.timeToLive?1e3*e.timeToLive:null,r=o(),a=Object.fromEntries(Object.entries(r).filter((([,e])=>void 0!==e.timestamp)));if(s(a),!t)return;s(Object.fromEntries(Object.entries(a).filter((([,e])=>{const r=(new Date).getTime();return!(e.timestamp+t<r)}))))}(),o()[JSON.stringify(t)]))).then((e=>Promise.all([e?e.value:r(),void 0!==e]))).then((([e,t])=>Promise.all([e,t||a.miss(e)]))).then((([e])=>e)),set:(e,t)=>Promise.resolve().then((()=>{const s=o();return s[JSON.stringify(e)]={timestamp:(new Date).getTime(),value:t},a().setItem(r,JSON.stringify(s)),t})),delete:e=>Promise.resolve().then((()=>{const t=o();delete t[JSON.stringify(e)],a().setItem(r,JSON.stringify(t))})),clear:()=>Promise.resolve().then((()=>{a().removeItem(r)}))}}function r(e){const t=[...e.caches],a=t.shift();return void 0===a?{get:(e,t,r={miss:()=>Promise.resolve()})=>t().then((e=>Promise.all([e,r.miss(e)]))).then((([e])=>e)),set:(e,t)=>Promise.resolve(t),delete:e=>Promise.resolve(),clear:()=>Promise.resolve()}:{get:(e,o,s={miss:()=>Promise.resolve()})=>a.get(e,o,s).catch((()=>r({caches:t}).get(e,o,s))),set:(e,o)=>a.set(e,o).catch((()=>r({caches:t}).set(e,o))),delete:e=>a.delete(e).catch((()=>r({caches:t}).delete(e))),clear:()=>a.clear().catch((()=>r({caches:t}).clear()))}}function a(e={serializable:!0}){let t={};return{get(r,a,o={miss:()=>Promise.resolve()}){const s=JSON.stringify(r);if(s in t)return Promise.resolve(e.serializable?JSON.parse(t[s]):t[s]);const n=a();return n.then((e=>o.miss(e))).then((()=>n))},set:(r,a)=>(t[JSON.stringify(r)]=e.serializable?JSON.stringify(a):a,Promise.resolve(a)),delete:e=>(delete t[JSON.stringify(e)],Promise.resolve()),clear:()=>(t={},Promise.resolve())}}const o=12e4;function s(e,t="up"){const r=Date.now();return{...e,status:t,lastUpdate:r,isUp:function(){return"up"===t||Date.now()-r>o},isTimedOut:function(){return"timed out"===t&&Date.now()-r<=o}}}function n(e,t,r){return(t=function(e){var t=function(e,t){if("object"!=typeof e||!e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var a=r.call(e,t||"default");if("object"!=typeof a)return a;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:t+""}(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}class i extends Error{constructor(e,t){super(e),n(this,"name","AlgoliaError"),t&&(this.name=t)}}class c extends i{constructor(e,t,r){super(e,r),n(this,"stackTrace",void 0),this.stackTrace=t}}class l extends c{constructor(e){super("Unreachable hosts - your application id may be incorrect. If the error persists, please reach out to the Algolia Support team: https://alg.li/support.",e,"RetryError")}}class u extends c{constructor(e,t,r,a="ApiError"){super(e,r,a),n(this,"status",void 0),this.status=t}}class m extends i{constructor(e,t){super(e,"DeserializationError"),n(this,"response",void 0),this.response=t}}class d extends u{constructor(e,t,r,a){super(e,t,a,"DetailedApiError"),n(this,"error",void 0),this.error=r}}function h(e,t,r){const a=(o=r,Object.keys(o).filter((e=>void 0!==o[e])).sort().map((e=>`${e}=${encodeURIComponent("[object Array]"===Object.prototype.toString.call(o[e])?o[e].join(","):o[e]).replaceAll("+","%20")}`)).join("&"));var o;let s=`${e.protocol}://${e.url}${e.port?`:${e.port}`:""}/${"/"===t.charAt(0)?t.substring(1):t}`;return a.length&&(s+=`?${a}`),s}function p(e){const t=e.request.headers["x-algolia-api-key"]?{"x-algolia-api-key":"*****"}:{};return{...e,request:{...e.request,headers:{...e.request.headers,...t}}}}function g({hosts:e,hostsCache:t,baseHeaders:r,baseQueryParameters:a,algoliaAgent:o,timeouts:n,requester:i,requestsCache:c,responsesCache:g}){async function f(c,g,f=!0){const w=[],y=function(e,t){if("GET"===e.method||void 0===e.data&&void 0===t.data)return;const r=Array.isArray(e.data)?e.data:{...e.data,...t.data};return JSON.stringify(r)}(c,g),P=function(e,t,r){const a={Accept:"application/json",...e,...t,...r},o={};return Object.keys(a).forEach((e=>{const t=a[e];o[e.toLowerCase()]=t})),o}(r,c.headers,g.headers),q="GET"===c.method?{...c.data,...g.data}:{},v={...a,...c.queryParameters,...q};if(o.value&&(v["x-algolia-agent"]=o.value),g&&g.queryParameters)for(const e of Object.keys(g.queryParameters))g.queryParameters[e]&&"[object Object]"!==Object.prototype.toString.call(g.queryParameters[e])?v[e]=g.queryParameters[e].toString():v[e]=g.queryParameters[e];let b=0;const R=async(e,r)=>{const a=e.pop();if(void 0===a)throw new l(function(e){return e.map((e=>p(e)))}(w));let o=f?g.timeouts?.read||n.read:g.timeouts?.write||n.write;const q={data:y,headers:P,method:c.method,url:h(a,c.path,v),connectTimeout:r(b,g.timeouts?.connect||n.connect),responseTimeout:r(b,o)},T=t=>{const r={request:q,response:t,host:a,triesLeft:e.length};return w.push(r),r},E=await i.send(q);if(function({isTimedOut:e,status:t}){return e||function({isTimedOut:e,status:t}){return!e&&!~~t}({isTimedOut:e,status:t})||2!=~~(t/100)&&4!=~~(t/100)}(E)){const o=T(E);return E.isTimedOut&&b++,console.log("Retryable failure",p(o)),await t.set(a,s(a,E.isTimedOut?"timed out":"down")),R(e,r)}if(function({status:e}){return 2==~~(e/100)}(E))return function(e){try{return JSON.parse(e.content)}catch(t){throw new m(t.message,e)}}(E);throw T(E),function({content:e,status:t},r){try{const a=JSON.parse(e);return"error"in a?new d(a.message,t,a.error,r):new u(a.message,t,r)}catch(e){}return new u(e,t,r)}(E,w)},T=e.filter((e=>"readWrite"===e.accept||(f?"read"===e.accept:"write"===e.accept))),E=await async function(e){const r=await Promise.all(e.map((e=>t.get(e,(()=>Promise.resolve(s(e))))))),a=r.filter((e=>e.isUp())),o=r.filter((e=>e.isTimedOut())),n=[...a,...o];return{hosts:n.length>0?n:e,getTimeout:(e,t)=>(0===o.length&&0===e?1:o.length+3+e)*t}}(T);return R([...E.hosts].reverse(),E.getTimeout)}return{hostsCache:t,requester:i,timeouts:n,algoliaAgent:o,baseHeaders:r,baseQueryParameters:a,hosts:e,request:function(e,t={}){const o=e.useReadTransporter||"GET"===e.method;if(!o)return f(e,t,o);const s=()=>f(e,t);if(!0!==(t.cacheable||e.cacheable))return s();const n={request:e,requestOptions:t,transporter:{queryParameters:a,headers:r}};return g.get(n,(()=>c.get(n,(()=>c.set(n,s()).then((e=>Promise.all([c.delete(n),e])),(e=>Promise.all([c.delete(n),Promise.reject(e)]))).then((([e,t])=>t))))),{miss:e=>g.set(n,e)})},requestsCache:c,responsesCache:g}}function f({algoliaAgents:e,client:t,version:r}){const a=function(e){const t={value:`Algolia for JavaScript (${e})`,add(e){const r=`; ${e.segment}${void 0!==e.version?` (${e.version})`:""}`;return-1===t.value.indexOf(r)&&(t.value=`${t.value}${r}`),t}};return t}(r).add({segment:t,version:r});return e.forEach((e=>a.add(e))),a}const w="5.0.0-beta.10";function y(e){return[{url:`${e}-dsn.algolia.net`,accept:"read",protocol:"https"},{url:`${e}.algolia.net`,accept:"write",protocol:"https"}].concat(function(e){const t=e;for(let r=e.length-1;r>0;r--){const a=Math.floor(Math.random()*(r+1)),o=e[r];t[r]=e[a],t[a]=o}return t}([{url:`${e}-1.algolianet.com`,accept:"readWrite",protocol:"https"},{url:`${e}-2.algolianet.com`,accept:"readWrite",protocol:"https"},{url:`${e}-3.algolianet.com`,accept:"readWrite",protocol:"https"}]))}e.apiClientVersion=w,e.recommendClient=function(e,o,s){if(!e||"string"!=typeof e)throw new Error("`appId` is missing.");if(!o||"string"!=typeof o)throw new Error("`apiKey` is missing.");return function({appId:e,apiKey:t,authMode:r,algoliaAgents:a,...o}){const s=function(e,t,r="WithinHeaders"){const a={"x-algolia-api-key":t,"x-algolia-application-id":e};return{headers:()=>"WithinHeaders"===r?a:{},queryParameters:()=>"WithinQueryParameters"===r?a:{}}}(e,t,r),n=g({hosts:y(e),...o,algoliaAgent:f({algoliaAgents:a,client:"Recommend",version:w}),baseHeaders:{"content-type":"text/plain",...s.headers(),...o.baseHeaders},baseQueryParameters:{...s.queryParameters(),...o.baseQueryParameters}});return{transporter:n,appId:e,clearCache:()=>Promise.all([n.requestsCache.clear(),n.responsesCache.clear()]).then((()=>{})),get _ua(){return n.algoliaAgent.value},addAlgoliaAgent(e,t){n.algoliaAgent.add({segment:e,version:t})},customDelete({path:e,parameters:t},r){if(!e)throw new Error("Parameter `path` is required when calling `customDelete`.");const a={method:"DELETE",path:"/{path}".replace("{path}",e),queryParameters:t||{},headers:{}};return n.request(a,r)},customGet({path:e,parameters:t},r){if(!e)throw new Error("Parameter `path` is required when calling `customGet`.");const a={method:"GET",path:"/{path}".replace("{path}",e),queryParameters:t||{},headers:{}};return n.request(a,r)},customPost({path:e,parameters:t,body:r},a){if(!e)throw new Error("Parameter `path` is required when calling `customPost`.");const o={method:"POST",path:"/{path}".replace("{path}",e),queryParameters:t||{},headers:{},data:r||{}};return n.request(o,a)},customPut({path:e,parameters:t,body:r},a){if(!e)throw new Error("Parameter `path` is required when calling `customPut`.");const o={method:"PUT",path:"/{path}".replace("{path}",e),queryParameters:t||{},headers:{},data:r||{}};return n.request(o,a)},deleteRecommendRule({indexName:e,model:t,objectID:r},a){if(!e)throw new Error("Parameter `indexName` is required when calling `deleteRecommendRule`.");if(!t)throw new Error("Parameter `model` is required when calling `deleteRecommendRule`.");if(!r)throw new Error("Parameter `objectID` is required when calling `deleteRecommendRule`.");const o={method:"DELETE",path:"/1/indexes/{indexName}/{model}/recommend/rules/{objectID}".replace("{indexName}",encodeURIComponent(e)).replace("{model}",encodeURIComponent(t)).replace("{objectID}",encodeURIComponent(r)),queryParameters:{},headers:{}};return n.request(o,a)},getRecommendRule({indexName:e,model:t,objectID:r},a){if(!e)throw new Error("Parameter `indexName` is required when calling `getRecommendRule`.");if(!t)throw new Error("Parameter `model` is required when calling `getRecommendRule`.");if(!r)throw new Error("Parameter `objectID` is required when calling `getRecommendRule`.");const o={method:"GET",path:"/1/indexes/{indexName}/{model}/recommend/rules/{objectID}".replace("{indexName}",encodeURIComponent(e)).replace("{model}",encodeURIComponent(t)).replace("{objectID}",encodeURIComponent(r)),queryParameters:{},headers:{}};return n.request(o,a)},getRecommendStatus({indexName:e,model:t,taskID:r},a){if(!e)throw new Error("Parameter `indexName` is required when calling `getRecommendStatus`.");if(!t)throw new Error("Parameter `model` is required when calling `getRecommendStatus`.");if(!r)throw new Error("Parameter `taskID` is required when calling `getRecommendStatus`.");const o={method:"GET",path:"/1/indexes/{indexName}/{model}/task/{taskID}".replace("{indexName}",encodeURIComponent(e)).replace("{model}",encodeURIComponent(t)).replace("{taskID}",encodeURIComponent(r)),queryParameters:{},headers:{}};return n.request(o,a)},getRecommendations(e,t){if(e&&Array.isArray(e)&&(e={requests:e}),!e)throw new Error("Parameter `getRecommendationsParams` is required when calling `getRecommendations`.");if(!e.requests)throw new Error("Parameter `getRecommendationsParams.requests` is required when calling `getRecommendations`.");const r={method:"POST",path:"/1/indexes/*/recommendations",queryParameters:{},headers:{},data:e,useReadTransporter:!0,cacheable:!0};return n.request(r,t)},searchRecommendRules({indexName:e,model:t,searchRecommendRulesParams:r},a){if(!e)throw new Error("Parameter `indexName` is required when calling `searchRecommendRules`.");if(!t)throw new Error("Parameter `model` is required when calling `searchRecommendRules`.");const o={method:"POST",path:"/1/indexes/{indexName}/{model}/recommend/rules/search".replace("{indexName}",encodeURIComponent(e)).replace("{model}",encodeURIComponent(t)),queryParameters:{},headers:{},data:r||{},useReadTransporter:!0,cacheable:!0};return n.request(o,a)}}}({appId:e,apiKey:o,timeouts:{connect:1e3,read:2e3,write:3e4},requester:{send:function(e){return new Promise((t=>{const r=new XMLHttpRequest;r.open(e.method,e.url,!0),Object.keys(e.headers).forEach((t=>r.setRequestHeader(t,e.headers[t])));const a=(e,a)=>setTimeout((()=>{r.abort(),t({status:0,content:a,isTimedOut:!0})}),e),o=a(e.connectTimeout,"Connection timeout");let s;r.onreadystatechange=()=>{r.readyState>r.OPENED&&void 0===s&&(clearTimeout(o),s=a(e.responseTimeout,"Socket timeout"))},r.onerror=()=>{0===r.status&&(clearTimeout(o),clearTimeout(s),t({content:r.responseText||"Network request failed",status:r.status,isTimedOut:!1}))},r.onload=()=>{clearTimeout(o),clearTimeout(s),t({content:r.responseText,status:r.status,isTimedOut:!1})},r.send(e.data)}))}},algoliaAgents:[{segment:"Browser"}],authMode:"WithinQueryParameters",responsesCache:a(),requestsCache:a({serializable:!1}),hostsCache:r({caches:[t({key:`${w}-${e}`}),a()]}),...s})}}));