@algolia/recommend 5.0.0-alpha.91 → 5.0.0-alpha.97

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 (61) hide show
  1. package/dist/model/baseRecommendedForYouQuery.d.ts +8 -0
  2. package/dist/model/baseRecommendedForYouQuery.d.ts.map +1 -0
  3. package/dist/model/baseRecommendedForYouQueryParameters.d.ts +7 -0
  4. package/dist/model/baseRecommendedForYouQueryParameters.d.ts.map +1 -0
  5. package/dist/model/clientMethodProps.d.ts +42 -42
  6. package/dist/model/clientMethodProps.d.ts.map +1 -1
  7. package/dist/model/getRecommendationsResponse.d.ts +2 -2
  8. package/dist/model/getRecommendationsResponse.d.ts.map +1 -1
  9. package/dist/model/highlightResult.d.ts +1 -1
  10. package/dist/model/highlightResult.d.ts.map +1 -1
  11. package/dist/model/index.d.ts +9 -2
  12. package/dist/model/index.d.ts.map +1 -1
  13. package/dist/model/recommendationsHit.d.ts +4 -0
  14. package/dist/model/recommendationsHit.d.ts.map +1 -0
  15. package/dist/model/recommendationsHits.d.ts +13 -0
  16. package/dist/model/recommendationsHits.d.ts.map +1 -0
  17. package/dist/model/recommendationsRequest.d.ts +2 -1
  18. package/dist/model/recommendationsRequest.d.ts.map +1 -1
  19. package/dist/model/recommendationsResults.d.ts +4 -0
  20. package/dist/model/recommendationsResults.d.ts.map +1 -0
  21. package/dist/model/recommendedForYouModel.d.ts +5 -0
  22. package/dist/model/recommendedForYouModel.d.ts.map +1 -0
  23. package/dist/model/recommendedForYouQuery.d.ts +4 -0
  24. package/dist/model/recommendedForYouQuery.d.ts.map +1 -0
  25. package/dist/model/recommendedForYouQueryParameters.d.ts +4 -0
  26. package/dist/model/recommendedForYouQueryParameters.d.ts.map +1 -0
  27. package/dist/model/searchRecommendRulesParams.d.ts +0 -4
  28. package/dist/model/searchRecommendRulesParams.d.ts.map +1 -1
  29. package/dist/model/searchRecommendRulesResponse.d.ts +3 -3
  30. package/dist/model/snippetResult.d.ts +1 -1
  31. package/dist/model/snippetResult.d.ts.map +1 -1
  32. package/dist/model/trendingFacetHit.d.ts +18 -0
  33. package/dist/model/trendingFacetHit.d.ts.map +1 -0
  34. package/dist/recommend.cjs +82 -82
  35. package/dist/recommend.esm.browser.js +125 -101
  36. package/dist/recommend.esm.node.js +82 -82
  37. package/dist/recommend.umd.js +2 -2
  38. package/dist/src/recommendClient.d.ts +38 -38
  39. package/dist/src/recommendClient.d.ts.map +1 -1
  40. package/model/baseRecommendedForYouQuery.ts +12 -0
  41. package/model/baseRecommendedForYouQueryParameters.ts +8 -0
  42. package/model/clientMethodProps.ts +42 -42
  43. package/model/getRecommendationsResponse.ts +2 -2
  44. package/model/highlightResult.ts +3 -1
  45. package/model/index.ts +9 -2
  46. package/model/recommendationsHit.ts +6 -0
  47. package/model/{recommendHits.ts → recommendationsHits.ts} +3 -3
  48. package/model/recommendationsRequest.ts +2 -0
  49. package/model/{recommendationsResponse.ts → recommendationsResults.ts} +2 -2
  50. package/model/recommendedForYouModel.ts +6 -0
  51. package/model/recommendedForYouQuery.ts +7 -0
  52. package/model/recommendedForYouQueryParameters.ts +7 -0
  53. package/model/searchRecommendRulesParams.ts +0 -5
  54. package/model/searchRecommendRulesResponse.ts +3 -3
  55. package/model/snippetResult.ts +3 -1
  56. package/model/trendingFacetHit.ts +21 -0
  57. package/package.json +7 -7
  58. package/dist/model/recommendHits.d.ts +0 -13
  59. package/dist/model/recommendHits.d.ts.map +0 -1
  60. package/dist/model/recommendationsResponse.d.ts +0 -4
  61. package/dist/model/recommendationsResponse.d.ts.map +0 -1
@@ -26,14 +26,35 @@ function createBrowserLocalStorageCache(options) {
26
26
  function getNamespace() {
27
27
  return JSON.parse(getStorage().getItem(namespaceKey) || '{}');
28
28
  }
29
+ function setNamespace(namespace) {
30
+ getStorage().setItem(namespaceKey, JSON.stringify(namespace));
31
+ }
32
+ function removeOutdatedCacheItems() {
33
+ const timeToLive = options.timeToLive ? options.timeToLive * 1000 : null;
34
+ const namespace = getNamespace();
35
+ const filteredNamespaceWithoutOldFormattedCacheItems = Object.fromEntries(Object.entries(namespace).filter(([, cacheItem]) => {
36
+ return cacheItem.timestamp !== undefined;
37
+ }));
38
+ setNamespace(filteredNamespaceWithoutOldFormattedCacheItems);
39
+ if (!timeToLive) {
40
+ return;
41
+ }
42
+ const filteredNamespaceWithoutExpiredItems = Object.fromEntries(Object.entries(filteredNamespaceWithoutOldFormattedCacheItems).filter(([, cacheItem]) => {
43
+ const currentTimestamp = new Date().getTime();
44
+ const isExpired = cacheItem.timestamp + timeToLive < currentTimestamp;
45
+ return !isExpired;
46
+ }));
47
+ setNamespace(filteredNamespaceWithoutExpiredItems);
48
+ }
29
49
  return {
30
50
  get(key, defaultValue, events = {
31
51
  miss: () => Promise.resolve()
32
52
  }) {
33
53
  return Promise.resolve().then(() => {
34
- const keyAsString = JSON.stringify(key);
35
- const value = getNamespace()[keyAsString];
36
- return Promise.all([value || defaultValue(), value !== undefined]);
54
+ removeOutdatedCacheItems();
55
+ return getNamespace()[JSON.stringify(key)];
56
+ }).then(value => {
57
+ return Promise.all([value ? value.value : defaultValue(), value !== undefined]);
37
58
  }).then(([value, exists]) => {
38
59
  return Promise.all([value, exists || events.miss(value)]);
39
60
  }).then(([value]) => value);
@@ -41,7 +62,10 @@ function createBrowserLocalStorageCache(options) {
41
62
  set(key, value) {
42
63
  return Promise.resolve().then(() => {
43
64
  const namespace = getNamespace();
44
- namespace[JSON.stringify(key)] = value;
65
+ namespace[JSON.stringify(key)] = {
66
+ timestamp: new Date().getTime(),
67
+ value
68
+ };
45
69
  getStorage().setItem(namespaceKey, JSON.stringify(namespace));
46
70
  return value;
47
71
  });
@@ -171,6 +195,20 @@ function createStatefulHost(host, status = 'up') {
171
195
  };
172
196
  }
173
197
 
198
+ function _toPrimitive(t, r) {
199
+ if ("object" != typeof t || !t) return t;
200
+ var e = t[Symbol.toPrimitive];
201
+ if (void 0 !== e) {
202
+ var i = e.call(t, r || "default");
203
+ if ("object" != typeof i) return i;
204
+ throw new TypeError("@@toPrimitive must return a primitive value.");
205
+ }
206
+ return ("string" === r ? String : Number)(t);
207
+ }
208
+ function _toPropertyKey(t) {
209
+ var i = _toPrimitive(t, "string");
210
+ return "symbol" == typeof i ? i : String(i);
211
+ }
174
212
  function _defineProperty(obj, key, value) {
175
213
  key = _toPropertyKey(key);
176
214
  if (key in obj) {
@@ -185,20 +223,6 @@ function _defineProperty(obj, key, value) {
185
223
  }
186
224
  return obj;
187
225
  }
188
- function _toPrimitive(input, hint) {
189
- if (typeof input !== "object" || input === null) return input;
190
- var prim = input[Symbol.toPrimitive];
191
- if (prim !== undefined) {
192
- var res = prim.call(input, hint || "default");
193
- if (typeof res !== "object") return res;
194
- throw new TypeError("@@toPrimitive must return a primitive value.");
195
- }
196
- return (hint === "string" ? String : Number)(input);
197
- }
198
- function _toPropertyKey(arg) {
199
- var key = _toPrimitive(arg, "string");
200
- return typeof key === "symbol" ? key : String(key);
201
- }
202
226
 
203
227
  class AlgoliaError extends Error {
204
228
  constructor(message, name) {
@@ -219,7 +243,7 @@ class ErrorWithStackTrace extends AlgoliaError {
219
243
  }
220
244
  class RetryError extends ErrorWithStackTrace {
221
245
  constructor(stackTrace) {
222
- super('Unreachable hosts - your application id may be incorrect. If the error persists, contact support@algolia.com.', stackTrace, 'RetryError');
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');
223
247
  }
224
248
  }
225
249
  class ApiError extends ErrorWithStackTrace {
@@ -673,7 +697,7 @@ function createXhrRequester() {
673
697
  }
674
698
 
675
699
  // 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.
676
- const apiClientVersion = '5.0.0-alpha.91';
700
+ const apiClientVersion = '5.0.0-alpha.97';
677
701
  function getDefaultHosts(appId) {
678
702
  return [
679
703
  {
@@ -759,14 +783,14 @@ function createRecommendClient({ appId: appIdOption, apiKey: apiKeyOption, authM
759
783
  * This method allow you to send requests to the Algolia REST API.
760
784
  *
761
785
  * @summary Send requests to the Algolia REST API.
762
- * @param del - The del object.
763
- * @param del.path - Path of the endpoint, anything after \"/1\" must be specified.
764
- * @param del.parameters - Query parameters to apply to the current query.
786
+ * @param customDelete - The customDelete object.
787
+ * @param customDelete.path - Path of the endpoint, anything after \"/1\" must be specified.
788
+ * @param customDelete.parameters - Query parameters to apply to the current query.
765
789
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
766
790
  */
767
- del({ path, parameters }, requestOptions) {
791
+ customDelete({ path, parameters }, requestOptions) {
768
792
  if (!path) {
769
- throw new Error('Parameter `path` is required when calling `del`.');
793
+ throw new Error('Parameter `path` is required when calling `customDelete`.');
770
794
  }
771
795
  const requestPath = '/1{path}'.replace('{path}', path);
772
796
  const headers = {};
@@ -779,6 +803,82 @@ function createRecommendClient({ appId: appIdOption, apiKey: apiKeyOption, authM
779
803
  };
780
804
  return transporter.request(request, requestOptions);
781
805
  },
806
+ /**
807
+ * This method allow you to send requests to the Algolia REST API.
808
+ *
809
+ * @summary Send requests to the Algolia REST API.
810
+ * @param customGet - The customGet object.
811
+ * @param customGet.path - Path of the endpoint, anything after \"/1\" must be specified.
812
+ * @param customGet.parameters - Query parameters to apply to the current query.
813
+ * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
814
+ */
815
+ customGet({ path, parameters }, requestOptions) {
816
+ if (!path) {
817
+ throw new Error('Parameter `path` is required when calling `customGet`.');
818
+ }
819
+ const requestPath = '/1{path}'.replace('{path}', path);
820
+ const headers = {};
821
+ const queryParameters = parameters ? parameters : {};
822
+ const request = {
823
+ method: 'GET',
824
+ path: requestPath,
825
+ queryParameters,
826
+ headers,
827
+ };
828
+ return transporter.request(request, requestOptions);
829
+ },
830
+ /**
831
+ * This method allow you to send requests to the Algolia REST API.
832
+ *
833
+ * @summary Send requests to the Algolia REST API.
834
+ * @param customPost - The customPost object.
835
+ * @param customPost.path - Path of the endpoint, anything after \"/1\" must be specified.
836
+ * @param customPost.parameters - Query parameters to apply to the current query.
837
+ * @param customPost.body - Parameters to send with the custom request.
838
+ * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
839
+ */
840
+ customPost({ path, parameters, body }, requestOptions) {
841
+ if (!path) {
842
+ throw new Error('Parameter `path` is required when calling `customPost`.');
843
+ }
844
+ const requestPath = '/1{path}'.replace('{path}', path);
845
+ const headers = {};
846
+ const queryParameters = parameters ? parameters : {};
847
+ const request = {
848
+ method: 'POST',
849
+ path: requestPath,
850
+ queryParameters,
851
+ headers,
852
+ data: body ? body : {},
853
+ };
854
+ return transporter.request(request, requestOptions);
855
+ },
856
+ /**
857
+ * This method allow you to send requests to the Algolia REST API.
858
+ *
859
+ * @summary Send requests to the Algolia REST API.
860
+ * @param customPut - The customPut object.
861
+ * @param customPut.path - Path of the endpoint, anything after \"/1\" must be specified.
862
+ * @param customPut.parameters - Query parameters to apply to the current query.
863
+ * @param customPut.body - Parameters to send with the custom request.
864
+ * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
865
+ */
866
+ customPut({ path, parameters, body }, requestOptions) {
867
+ if (!path) {
868
+ throw new Error('Parameter `path` is required when calling `customPut`.');
869
+ }
870
+ const requestPath = '/1{path}'.replace('{path}', path);
871
+ const headers = {};
872
+ const queryParameters = parameters ? parameters : {};
873
+ const request = {
874
+ method: 'PUT',
875
+ path: requestPath,
876
+ queryParameters,
877
+ headers,
878
+ data: body ? body : {},
879
+ };
880
+ return transporter.request(request, requestOptions);
881
+ },
782
882
  /**
783
883
  * Delete a [Recommend rule](https://www.algolia.com/doc/guides/algolia-recommend/how-to/rules/).
784
884
  *
@@ -813,30 +913,6 @@ function createRecommendClient({ appId: appIdOption, apiKey: apiKeyOption, authM
813
913
  };
814
914
  return transporter.request(request, requestOptions);
815
915
  },
816
- /**
817
- * This method allow you to send requests to the Algolia REST API.
818
- *
819
- * @summary Send requests to the Algolia REST API.
820
- * @param get - The get object.
821
- * @param get.path - Path of the endpoint, anything after \"/1\" must be specified.
822
- * @param get.parameters - Query parameters to apply to the current query.
823
- * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
824
- */
825
- get({ path, parameters }, requestOptions) {
826
- if (!path) {
827
- throw new Error('Parameter `path` is required when calling `get`.');
828
- }
829
- const requestPath = '/1{path}'.replace('{path}', path);
830
- const headers = {};
831
- const queryParameters = parameters ? parameters : {};
832
- const request = {
833
- method: 'GET',
834
- path: requestPath,
835
- queryParameters,
836
- headers,
837
- };
838
- return transporter.request(request, requestOptions);
839
- },
840
916
  /**
841
917
  * Return a [Recommend rule](https://www.algolia.com/doc/guides/algolia-recommend/how-to/rules/).
842
918
  *
@@ -933,58 +1009,6 @@ function createRecommendClient({ appId: appIdOption, apiKey: apiKeyOption, authM
933
1009
  };
934
1010
  return transporter.request(request, requestOptions);
935
1011
  },
936
- /**
937
- * This method allow you to send requests to the Algolia REST API.
938
- *
939
- * @summary Send requests to the Algolia REST API.
940
- * @param post - The post object.
941
- * @param post.path - Path of the endpoint, anything after \"/1\" must be specified.
942
- * @param post.parameters - Query parameters to apply to the current query.
943
- * @param post.body - Parameters to send with the custom request.
944
- * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
945
- */
946
- post({ path, parameters, body }, requestOptions) {
947
- if (!path) {
948
- throw new Error('Parameter `path` is required when calling `post`.');
949
- }
950
- const requestPath = '/1{path}'.replace('{path}', path);
951
- const headers = {};
952
- const queryParameters = parameters ? parameters : {};
953
- const request = {
954
- method: 'POST',
955
- path: requestPath,
956
- queryParameters,
957
- headers,
958
- data: body ? body : {},
959
- };
960
- return transporter.request(request, requestOptions);
961
- },
962
- /**
963
- * This method allow you to send requests to the Algolia REST API.
964
- *
965
- * @summary Send requests to the Algolia REST API.
966
- * @param put - The put object.
967
- * @param put.path - Path of the endpoint, anything after \"/1\" must be specified.
968
- * @param put.parameters - Query parameters to apply to the current query.
969
- * @param put.body - Parameters to send with the custom request.
970
- * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
971
- */
972
- put({ path, parameters, body }, requestOptions) {
973
- if (!path) {
974
- throw new Error('Parameter `path` is required when calling `put`.');
975
- }
976
- const requestPath = '/1{path}'.replace('{path}', path);
977
- const headers = {};
978
- const queryParameters = parameters ? parameters : {};
979
- const request = {
980
- method: 'PUT',
981
- path: requestPath,
982
- queryParameters,
983
- headers,
984
- data: body ? body : {},
985
- };
986
- return transporter.request(request, requestOptions);
987
- },
988
1012
  /**
989
1013
  * List [Recommend rules](https://www.algolia.com/doc/guides/algolia-recommend/how-to/rules/).
990
1014
  *
@@ -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.91';
5
+ const apiClientVersion = '5.0.0-alpha.97';
6
6
  function getDefaultHosts(appId) {
7
7
  return [
8
8
  {
@@ -88,14 +88,14 @@ function createRecommendClient({ appId: appIdOption, apiKey: apiKeyOption, authM
88
88
  * This method allow you to send requests to the Algolia REST API.
89
89
  *
90
90
  * @summary Send requests to the Algolia REST API.
91
- * @param del - The del object.
92
- * @param del.path - Path of the endpoint, anything after \"/1\" must be specified.
93
- * @param del.parameters - Query parameters to apply to the current query.
91
+ * @param customDelete - The customDelete object.
92
+ * @param customDelete.path - Path of the endpoint, anything after \"/1\" must be specified.
93
+ * @param customDelete.parameters - Query parameters to apply to the current query.
94
94
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
95
95
  */
96
- del({ path, parameters }, requestOptions) {
96
+ customDelete({ path, parameters }, requestOptions) {
97
97
  if (!path) {
98
- throw new Error('Parameter `path` is required when calling `del`.');
98
+ throw new Error('Parameter `path` is required when calling `customDelete`.');
99
99
  }
100
100
  const requestPath = '/1{path}'.replace('{path}', path);
101
101
  const headers = {};
@@ -108,6 +108,82 @@ function createRecommendClient({ appId: appIdOption, apiKey: apiKeyOption, authM
108
108
  };
109
109
  return transporter.request(request, requestOptions);
110
110
  },
111
+ /**
112
+ * This method allow you to send requests to the Algolia REST API.
113
+ *
114
+ * @summary Send requests to the Algolia REST API.
115
+ * @param customGet - The customGet object.
116
+ * @param customGet.path - Path of the endpoint, anything after \"/1\" must be specified.
117
+ * @param customGet.parameters - Query parameters to apply to the current query.
118
+ * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
119
+ */
120
+ customGet({ path, parameters }, requestOptions) {
121
+ if (!path) {
122
+ throw new Error('Parameter `path` is required when calling `customGet`.');
123
+ }
124
+ const requestPath = '/1{path}'.replace('{path}', path);
125
+ const headers = {};
126
+ const queryParameters = parameters ? parameters : {};
127
+ const request = {
128
+ method: 'GET',
129
+ path: requestPath,
130
+ queryParameters,
131
+ headers,
132
+ };
133
+ return transporter.request(request, requestOptions);
134
+ },
135
+ /**
136
+ * This method allow you to send requests to the Algolia REST API.
137
+ *
138
+ * @summary Send requests to the Algolia REST API.
139
+ * @param customPost - The customPost object.
140
+ * @param customPost.path - Path of the endpoint, anything after \"/1\" must be specified.
141
+ * @param customPost.parameters - Query parameters to apply to the current query.
142
+ * @param customPost.body - Parameters to send with the custom request.
143
+ * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
144
+ */
145
+ customPost({ path, parameters, body }, requestOptions) {
146
+ if (!path) {
147
+ throw new Error('Parameter `path` is required when calling `customPost`.');
148
+ }
149
+ const requestPath = '/1{path}'.replace('{path}', path);
150
+ const headers = {};
151
+ const queryParameters = parameters ? parameters : {};
152
+ const request = {
153
+ method: 'POST',
154
+ path: requestPath,
155
+ queryParameters,
156
+ headers,
157
+ data: body ? body : {},
158
+ };
159
+ return transporter.request(request, requestOptions);
160
+ },
161
+ /**
162
+ * This method allow you to send requests to the Algolia REST API.
163
+ *
164
+ * @summary Send requests to the Algolia REST API.
165
+ * @param customPut - The customPut object.
166
+ * @param customPut.path - Path of the endpoint, anything after \"/1\" must be specified.
167
+ * @param customPut.parameters - Query parameters to apply to the current query.
168
+ * @param customPut.body - Parameters to send with the custom request.
169
+ * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
170
+ */
171
+ customPut({ path, parameters, body }, requestOptions) {
172
+ if (!path) {
173
+ throw new Error('Parameter `path` is required when calling `customPut`.');
174
+ }
175
+ const requestPath = '/1{path}'.replace('{path}', path);
176
+ const headers = {};
177
+ const queryParameters = parameters ? parameters : {};
178
+ const request = {
179
+ method: 'PUT',
180
+ path: requestPath,
181
+ queryParameters,
182
+ headers,
183
+ data: body ? body : {},
184
+ };
185
+ return transporter.request(request, requestOptions);
186
+ },
111
187
  /**
112
188
  * Delete a [Recommend rule](https://www.algolia.com/doc/guides/algolia-recommend/how-to/rules/).
113
189
  *
@@ -142,30 +218,6 @@ function createRecommendClient({ appId: appIdOption, apiKey: apiKeyOption, authM
142
218
  };
143
219
  return transporter.request(request, requestOptions);
144
220
  },
145
- /**
146
- * This method allow you to send requests to the Algolia REST API.
147
- *
148
- * @summary Send requests to the Algolia REST API.
149
- * @param get - The get object.
150
- * @param get.path - Path of the endpoint, anything after \"/1\" must be specified.
151
- * @param get.parameters - Query parameters to apply to the current query.
152
- * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
153
- */
154
- get({ path, parameters }, requestOptions) {
155
- if (!path) {
156
- throw new Error('Parameter `path` is required when calling `get`.');
157
- }
158
- const requestPath = '/1{path}'.replace('{path}', path);
159
- const headers = {};
160
- const queryParameters = parameters ? parameters : {};
161
- const request = {
162
- method: 'GET',
163
- path: requestPath,
164
- queryParameters,
165
- headers,
166
- };
167
- return transporter.request(request, requestOptions);
168
- },
169
221
  /**
170
222
  * Return a [Recommend rule](https://www.algolia.com/doc/guides/algolia-recommend/how-to/rules/).
171
223
  *
@@ -262,58 +314,6 @@ function createRecommendClient({ appId: appIdOption, apiKey: apiKeyOption, authM
262
314
  };
263
315
  return transporter.request(request, requestOptions);
264
316
  },
265
- /**
266
- * This method allow you to send requests to the Algolia REST API.
267
- *
268
- * @summary Send requests to the Algolia REST API.
269
- * @param post - The post object.
270
- * @param post.path - Path of the endpoint, anything after \"/1\" must be specified.
271
- * @param post.parameters - Query parameters to apply to the current query.
272
- * @param post.body - Parameters to send with the custom request.
273
- * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
274
- */
275
- post({ path, parameters, body }, requestOptions) {
276
- if (!path) {
277
- throw new Error('Parameter `path` is required when calling `post`.');
278
- }
279
- const requestPath = '/1{path}'.replace('{path}', path);
280
- const headers = {};
281
- const queryParameters = parameters ? parameters : {};
282
- const request = {
283
- method: 'POST',
284
- path: requestPath,
285
- queryParameters,
286
- headers,
287
- data: body ? body : {},
288
- };
289
- return transporter.request(request, requestOptions);
290
- },
291
- /**
292
- * This method allow you to send requests to the Algolia REST API.
293
- *
294
- * @summary Send requests to the Algolia REST API.
295
- * @param put - The put object.
296
- * @param put.path - Path of the endpoint, anything after \"/1\" must be specified.
297
- * @param put.parameters - Query parameters to apply to the current query.
298
- * @param put.body - Parameters to send with the custom request.
299
- * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
300
- */
301
- put({ path, parameters, body }, requestOptions) {
302
- if (!path) {
303
- throw new Error('Parameter `path` is required when calling `put`.');
304
- }
305
- const requestPath = '/1{path}'.replace('{path}', path);
306
- const headers = {};
307
- const queryParameters = parameters ? parameters : {};
308
- const request = {
309
- method: 'PUT',
310
- path: requestPath,
311
- queryParameters,
312
- headers,
313
- data: body ? body : {},
314
- };
315
- return transporter.request(request, requestOptions);
316
- },
317
317
  /**
318
318
  * List [Recommend rules](https://www.algolia.com/doc/guides/algolia-recommend/how-to/rules/).
319
319
  *
@@ -1,2 +1,2 @@
1
- /*! recommend.umd.js | 5.0.0-alpha.91 | © 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)||"{}")}return{get:(e,t,r={miss:()=>Promise.resolve()})=>Promise.resolve().then((()=>{const r=JSON.stringify(e),a=o()[r];return Promise.all([a||t(),void 0!==a])})).then((([e,t])=>Promise.all([e,t||r.miss(e)]))).then((([e])=>e)),set:(e,t)=>Promise.resolve().then((()=>{const s=o();return s[JSON.stringify(e)]=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||null===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)}(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, contact support@algolia.com.",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=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 o=`${e.protocol}://${e.url}/${"/"===t.charAt(0)?t.substr(1):t}`;return a.length&&(o+=`?${a}`),o}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}:{},b={...a,...c.queryParameters,...q};if(o.value&&(b["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])?b[e]=g.queryParameters[e].toString():b[e]=g.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=>p(e)))}(w));let o=g.timeout;void 0===o&&(o=f?n.read:n.write);const q={data:y,headers:P,method:c.method,url:h(a,c.path,b),connectTimeout:r(v,n.connect),responseTimeout:r(v,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&&0==~~t}({isTimedOut:e,status:t})||2!=~~(t/100)&&4!=~~(t/100)}(E)){const o=T(E);return E.isTimedOut&&v++,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-alpha.91";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})},del({path:e,parameters:t},r){if(!e)throw new Error("Parameter `path` is required when calling `del`.");const a={method:"DELETE",path:"/1{path}".replace("{path}",e),queryParameters:t||{},headers:{}};return n.request(a,r)},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)},get({path:e,parameters:t},r){if(!e)throw new Error("Parameter `path` is required when calling `get`.");const a={method:"GET",path:"/1{path}".replace("{path}",e),queryParameters:t||{},headers:{}};return n.request(a,r)},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)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)},post({path:e,parameters:t,body:r},a){if(!e)throw new Error("Parameter `path` is required when calling `post`.");const o={method:"POST",path:"/1{path}".replace("{path}",e),queryParameters:t||{},headers:{},data:r||{}};return n.request(o,a)},put({path:e,parameters:t,body:r},a){if(!e)throw new Error("Parameter `path` is required when calling `put`.");const o={method:"PUT",path:"/1{path}".replace("{path}",e),queryParameters:t||{},headers:{},data:r||{}};return n.request(o,a)},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})}}));
1
+ /*! recommend.umd.js | 5.0.0-alpha.97 | © 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.97";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})}}));