@algolia/recommend 4.14.1 → 5.0.0-alpha.2

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 (174) hide show
  1. package/dist/builds/browser.d.ts +6 -0
  2. package/dist/builds/browser.d.ts.map +1 -0
  3. package/dist/builds/node.d.ts +6 -0
  4. package/dist/builds/node.d.ts.map +1 -0
  5. package/dist/model/advancedSyntaxFeatures.d.ts +2 -0
  6. package/dist/model/advancedSyntaxFeatures.d.ts.map +1 -0
  7. package/dist/model/alternativesAsExact.d.ts +2 -0
  8. package/dist/model/alternativesAsExact.d.ts.map +1 -0
  9. package/dist/model/aroundRadius.d.ts +6 -0
  10. package/dist/model/aroundRadius.d.ts.map +1 -0
  11. package/dist/model/aroundRadiusAll.d.ts +2 -0
  12. package/dist/model/aroundRadiusAll.d.ts.map +1 -0
  13. package/dist/model/baseRecommendRequest.d.ts +18 -0
  14. package/dist/model/baseRecommendRequest.d.ts.map +1 -0
  15. package/dist/model/baseRecommendationRequest.d.ts +9 -0
  16. package/dist/model/baseRecommendationRequest.d.ts.map +1 -0
  17. package/dist/model/baseSearchParams.d.ts +4 -0
  18. package/dist/model/baseSearchParams.d.ts.map +1 -0
  19. package/dist/model/baseSearchParamsWithoutQuery.d.ts +123 -0
  20. package/dist/model/baseSearchParamsWithoutQuery.d.ts.map +1 -0
  21. package/dist/model/baseSearchResponse.d.ts +102 -0
  22. package/dist/model/baseSearchResponse.d.ts.map +1 -0
  23. package/dist/model/baseTrendingRequest.d.ts +13 -0
  24. package/dist/model/baseTrendingRequest.d.ts.map +1 -0
  25. package/dist/model/clientMethodProps.d.ts +61 -0
  26. package/dist/model/clientMethodProps.d.ts.map +1 -0
  27. package/dist/model/errorBase.d.ts +7 -0
  28. package/dist/model/errorBase.d.ts.map +1 -0
  29. package/dist/model/exactOnSingleWordQuery.d.ts +5 -0
  30. package/dist/model/exactOnSingleWordQuery.d.ts.map +1 -0
  31. package/dist/model/facetFilters.d.ts +6 -0
  32. package/dist/model/facetFilters.d.ts.map +1 -0
  33. package/dist/model/facetOrdering.d.ts +13 -0
  34. package/dist/model/facetOrdering.d.ts.map +1 -0
  35. package/dist/model/facets.d.ts +10 -0
  36. package/dist/model/facets.d.ts.map +1 -0
  37. package/dist/model/facetsStats.d.ts +19 -0
  38. package/dist/model/facetsStats.d.ts.map +1 -0
  39. package/dist/model/getRecommendationsParams.d.ts +11 -0
  40. package/dist/model/getRecommendationsParams.d.ts.map +1 -0
  41. package/dist/model/getRecommendationsResponse.d.ts +5 -0
  42. package/dist/model/getRecommendationsResponse.d.ts.map +1 -0
  43. package/dist/model/highlightResult.d.ts +3 -0
  44. package/dist/model/highlightResult.d.ts.map +1 -0
  45. package/dist/model/highlightResultOption.d.ts +20 -0
  46. package/dist/model/highlightResultOption.d.ts.map +1 -0
  47. package/dist/model/ignorePlurals.d.ts +5 -0
  48. package/dist/model/ignorePlurals.d.ts.map +1 -0
  49. package/dist/model/index.d.ts +53 -0
  50. package/dist/model/index.d.ts.map +1 -0
  51. package/dist/model/indexSettingsAsSearchParams.d.ts +159 -0
  52. package/dist/model/indexSettingsAsSearchParams.d.ts.map +1 -0
  53. package/dist/model/matchLevel.d.ts +5 -0
  54. package/dist/model/matchLevel.d.ts.map +1 -0
  55. package/dist/model/matchedGeoLocation.d.ts +15 -0
  56. package/dist/model/matchedGeoLocation.d.ts.map +1 -0
  57. package/dist/model/mixedSearchFilters.d.ts +2 -0
  58. package/dist/model/mixedSearchFilters.d.ts.map +1 -0
  59. package/dist/model/numericFilters.d.ts +6 -0
  60. package/dist/model/numericFilters.d.ts.map +1 -0
  61. package/dist/model/optionalFilters.d.ts +6 -0
  62. package/dist/model/optionalFilters.d.ts.map +1 -0
  63. package/dist/model/personalization.d.ts +15 -0
  64. package/dist/model/personalization.d.ts.map +1 -0
  65. package/dist/model/queryType.d.ts +5 -0
  66. package/dist/model/queryType.d.ts.map +1 -0
  67. package/dist/model/rankingInfo.d.ts +51 -0
  68. package/dist/model/rankingInfo.d.ts.map +1 -0
  69. package/dist/model/reRankingApplyFilter.d.ts +6 -0
  70. package/dist/model/reRankingApplyFilter.d.ts.map +1 -0
  71. package/dist/model/recommendHit.d.ts +27 -0
  72. package/dist/model/recommendHit.d.ts.map +1 -0
  73. package/dist/model/recommendHits.d.ts +5 -0
  74. package/dist/model/recommendHits.d.ts.map +1 -0
  75. package/dist/model/recommendationModels.d.ts +5 -0
  76. package/dist/model/recommendationModels.d.ts.map +1 -0
  77. package/dist/model/recommendationRequest.d.ts +4 -0
  78. package/dist/model/recommendationRequest.d.ts.map +1 -0
  79. package/dist/model/recommendationsRequest.d.ts +4 -0
  80. package/dist/model/recommendationsRequest.d.ts.map +1 -0
  81. package/dist/model/recommendationsResponse.d.ts +4 -0
  82. package/dist/model/recommendationsResponse.d.ts.map +1 -0
  83. package/dist/model/removeStopWords.d.ts +5 -0
  84. package/dist/model/removeStopWords.d.ts.map +1 -0
  85. package/dist/model/removeWordsIfNoResults.d.ts +5 -0
  86. package/dist/model/removeWordsIfNoResults.d.ts.map +1 -0
  87. package/dist/model/renderingContent.d.ts +8 -0
  88. package/dist/model/renderingContent.d.ts.map +1 -0
  89. package/dist/model/searchParamsObject.d.ts +4 -0
  90. package/dist/model/searchParamsObject.d.ts.map +1 -0
  91. package/dist/model/searchParamsQuery.d.ts +7 -0
  92. package/dist/model/searchParamsQuery.d.ts.map +1 -0
  93. package/dist/model/snippetResult.d.ts +3 -0
  94. package/dist/model/snippetResult.d.ts.map +1 -0
  95. package/dist/model/snippetResultOption.d.ts +12 -0
  96. package/dist/model/snippetResultOption.d.ts.map +1 -0
  97. package/dist/model/sortRemainingBy.d.ts +5 -0
  98. package/dist/model/sortRemainingBy.d.ts.map +1 -0
  99. package/dist/model/tagFilters.d.ts +6 -0
  100. package/dist/model/tagFilters.d.ts.map +1 -0
  101. package/dist/model/trendingModels.d.ts +5 -0
  102. package/dist/model/trendingModels.d.ts.map +1 -0
  103. package/dist/model/trendingRequest.d.ts +4 -0
  104. package/dist/model/trendingRequest.d.ts.map +1 -0
  105. package/dist/model/typoTolerance.d.ts +6 -0
  106. package/dist/model/typoTolerance.d.ts.map +1 -0
  107. package/dist/model/typoToleranceEnum.d.ts +2 -0
  108. package/dist/model/typoToleranceEnum.d.ts.map +1 -0
  109. package/dist/model/value.d.ts +9 -0
  110. package/dist/model/value.d.ts.map +1 -0
  111. package/dist/recommend.cjs.js +212 -142
  112. package/dist/recommend.esm.browser.js +884 -824
  113. package/dist/recommend.esm.node.js +230 -0
  114. package/dist/recommend.umd.js +2 -2
  115. package/dist/src/recommendClient.d.ts +74 -0
  116. package/dist/src/recommendClient.d.ts.map +1 -0
  117. package/index.d.ts +2 -3
  118. package/index.js +2 -15
  119. package/model/advancedSyntaxFeatures.ts +3 -0
  120. package/model/alternativesAsExact.ts +6 -0
  121. package/model/aroundRadius.ts +8 -0
  122. package/model/aroundRadiusAll.ts +3 -0
  123. package/model/baseRecommendRequest.ts +20 -0
  124. package/model/baseRecommendationRequest.ts +11 -0
  125. package/model/baseSearchParams.ts +6 -0
  126. package/model/baseSearchParamsWithoutQuery.ts +125 -0
  127. package/model/baseSearchResponse.ts +104 -0
  128. package/model/baseTrendingRequest.ts +15 -0
  129. package/model/clientMethodProps.ts +65 -0
  130. package/model/errorBase.ts +8 -0
  131. package/model/exactOnSingleWordQuery.ts +6 -0
  132. package/model/facetFilters.ts +8 -0
  133. package/model/facetOrdering.ts +15 -0
  134. package/model/facets.ts +11 -0
  135. package/model/facetsStats.ts +20 -0
  136. package/model/getRecommendationsParams.ts +13 -0
  137. package/model/getRecommendationsResponse.ts +7 -0
  138. package/model/highlightResult.ts +5 -0
  139. package/model/highlightResultOption.ts +22 -0
  140. package/model/ignorePlurals.ts +6 -0
  141. package/model/index.ts +54 -0
  142. package/model/indexSettingsAsSearchParams.ts +161 -0
  143. package/model/matchLevel.ts +6 -0
  144. package/model/matchedGeoLocation.ts +16 -0
  145. package/model/mixedSearchFilters.ts +3 -0
  146. package/model/numericFilters.ts +8 -0
  147. package/model/optionalFilters.ts +8 -0
  148. package/model/personalization.ts +16 -0
  149. package/model/queryType.ts +6 -0
  150. package/model/rankingInfo.ts +53 -0
  151. package/model/reRankingApplyFilter.ts +8 -0
  152. package/model/recommendHit.ts +29 -0
  153. package/model/recommendHits.ts +7 -0
  154. package/model/recommendationModels.ts +6 -0
  155. package/model/recommendationRequest.ts +7 -0
  156. package/model/recommendationsRequest.ts +6 -0
  157. package/model/recommendationsResponse.ts +6 -0
  158. package/model/removeStopWords.ts +6 -0
  159. package/model/removeWordsIfNoResults.ts +10 -0
  160. package/model/renderingContent.ts +10 -0
  161. package/model/searchParamsObject.ts +6 -0
  162. package/model/searchParamsQuery.ts +8 -0
  163. package/model/snippetResult.ts +5 -0
  164. package/model/snippetResultOption.ts +14 -0
  165. package/model/sortRemainingBy.ts +6 -0
  166. package/model/tagFilters.ts +8 -0
  167. package/model/trendingModels.ts +6 -0
  168. package/model/trendingRequest.ts +6 -0
  169. package/model/typoTolerance.ts +8 -0
  170. package/model/typoToleranceEnum.ts +3 -0
  171. package/model/value.ts +11 -0
  172. package/package.json +22 -24
  173. package/README.md +0 -76
  174. package/dist/recommend.d.ts +0 -162
@@ -0,0 +1,230 @@
1
+ import { createAuth, createTransporter, getAlgoliaAgent, shuffle, DEFAULT_CONNECT_TIMEOUT_NODE, DEFAULT_READ_TIMEOUT_NODE, DEFAULT_WRITE_TIMEOUT_NODE, createNullCache, createMemoryCache } from '@algolia/client-common';
2
+ import { createHttpRequester } from '@algolia/requester-node-http';
3
+
4
+ // This file is generated, manual changes will be lost - read more on https://github.com/algolia/api-clients-automation.
5
+ const apiClientVersion = '5.0.0-alpha.2';
6
+ function getDefaultHosts(appId) {
7
+ return [
8
+ {
9
+ url: `${appId}-dsn.algolia.net`,
10
+ accept: 'read',
11
+ protocol: 'https',
12
+ },
13
+ {
14
+ url: `${appId}.algolia.net`,
15
+ accept: 'write',
16
+ protocol: 'https',
17
+ },
18
+ ].concat(shuffle([
19
+ {
20
+ url: `${appId}-1.algolianet.com`,
21
+ accept: 'readWrite',
22
+ protocol: 'https',
23
+ },
24
+ {
25
+ url: `${appId}-2.algolianet.com`,
26
+ accept: 'readWrite',
27
+ protocol: 'https',
28
+ },
29
+ {
30
+ url: `${appId}-3.algolianet.com`,
31
+ accept: 'readWrite',
32
+ protocol: 'https',
33
+ },
34
+ ]));
35
+ }
36
+ // eslint-disable-next-line @typescript-eslint/explicit-function-return-type
37
+ function createRecommendClient({ appId: appIdOption, apiKey: apiKeyOption, authMode, algoliaAgents, ...options }) {
38
+ const auth = createAuth(appIdOption, apiKeyOption, authMode);
39
+ const transporter = createTransporter({
40
+ hosts: getDefaultHosts(appIdOption),
41
+ ...options,
42
+ algoliaAgent: getAlgoliaAgent({
43
+ algoliaAgents,
44
+ client: 'Recommend',
45
+ version: apiClientVersion,
46
+ }),
47
+ baseHeaders: {
48
+ 'content-type': 'text/plain',
49
+ ...auth.headers(),
50
+ ...options.baseHeaders,
51
+ },
52
+ baseQueryParameters: {
53
+ ...auth.queryParameters(),
54
+ ...options.baseQueryParameters,
55
+ },
56
+ });
57
+ return {
58
+ transporter,
59
+ /**
60
+ * Get the value of the `algoliaAgent`, used by our libraries internally and telemetry system.
61
+ */
62
+ get _ua() {
63
+ return transporter.algoliaAgent.value;
64
+ },
65
+ /**
66
+ * Adds a `segment` to the `x-algolia-agent` sent with every requests.
67
+ *
68
+ * @param segment - The algolia agent (user-agent) segment to add.
69
+ * @param version - The version of the agent.
70
+ */
71
+ addAlgoliaAgent(segment, version) {
72
+ transporter.algoliaAgent.add({ segment, version });
73
+ },
74
+ /**
75
+ * This method allow you to send requests to the Algolia REST API.
76
+ *
77
+ * @summary Send requests to the Algolia REST API.
78
+ * @param del - The del object.
79
+ * @param del.path - The path of the API endpoint to target, anything after the /1 needs to be specified.
80
+ * @param del.parameters - Query parameters to be applied to the current query.
81
+ * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
82
+ */
83
+ del({ path, parameters }, requestOptions) {
84
+ if (!path) {
85
+ throw new Error('Parameter `path` is required when calling `del`.');
86
+ }
87
+ const requestPath = '/1{path}'.replace('{path}', path);
88
+ const headers = {};
89
+ const queryParameters = parameters ? parameters : {};
90
+ const request = {
91
+ method: 'DELETE',
92
+ path: requestPath,
93
+ queryParameters,
94
+ headers,
95
+ };
96
+ return transporter.request(request, requestOptions);
97
+ },
98
+ /**
99
+ * This method allow you to send requests to the Algolia REST API.
100
+ *
101
+ * @summary Send requests to the Algolia REST API.
102
+ * @param get - The get object.
103
+ * @param get.path - The path of the API endpoint to target, anything after the /1 needs to be specified.
104
+ * @param get.parameters - Query parameters to be applied to the current query.
105
+ * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
106
+ */
107
+ get({ path, parameters }, requestOptions) {
108
+ if (!path) {
109
+ throw new Error('Parameter `path` is required when calling `get`.');
110
+ }
111
+ const requestPath = '/1{path}'.replace('{path}', path);
112
+ const headers = {};
113
+ const queryParameters = parameters ? parameters : {};
114
+ const request = {
115
+ method: 'GET',
116
+ path: requestPath,
117
+ queryParameters,
118
+ headers,
119
+ };
120
+ return transporter.request(request, requestOptions);
121
+ },
122
+ /**
123
+ * Returns recommendations or trending results, for a specific model and `objectID`.
124
+ *
125
+ * @summary Get results.
126
+ * @param getRecommendationsParams - The getRecommendationsParams object.
127
+ * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
128
+ */
129
+ getRecommendations(getRecommendationsParams, requestOptions) {
130
+ if (!getRecommendationsParams) {
131
+ throw new Error('Parameter `getRecommendationsParams` is required when calling `getRecommendations`.');
132
+ }
133
+ if (!getRecommendationsParams.requests) {
134
+ throw new Error('Parameter `getRecommendationsParams.requests` is required when calling `getRecommendations`.');
135
+ }
136
+ const requestPath = '/1/indexes/*/recommendations';
137
+ const headers = {};
138
+ const queryParameters = {};
139
+ const request = {
140
+ method: 'POST',
141
+ path: requestPath,
142
+ queryParameters,
143
+ headers,
144
+ data: getRecommendationsParams,
145
+ useReadTransporter: true,
146
+ cacheable: true,
147
+ };
148
+ return transporter.request(request, requestOptions);
149
+ },
150
+ /**
151
+ * This method allow you to send requests to the Algolia REST API.
152
+ *
153
+ * @summary Send requests to the Algolia REST API.
154
+ * @param post - The post object.
155
+ * @param post.path - The path of the API endpoint to target, anything after the /1 needs to be specified.
156
+ * @param post.parameters - Query parameters to be applied to the current query.
157
+ * @param post.body - The parameters to send with the custom request.
158
+ * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
159
+ */
160
+ post({ path, parameters, body }, requestOptions) {
161
+ if (!path) {
162
+ throw new Error('Parameter `path` is required when calling `post`.');
163
+ }
164
+ const requestPath = '/1{path}'.replace('{path}', path);
165
+ const headers = {};
166
+ const queryParameters = parameters ? parameters : {};
167
+ const request = {
168
+ method: 'POST',
169
+ path: requestPath,
170
+ queryParameters,
171
+ headers,
172
+ data: body ? body : {},
173
+ };
174
+ return transporter.request(request, requestOptions);
175
+ },
176
+ /**
177
+ * This method allow you to send requests to the Algolia REST API.
178
+ *
179
+ * @summary Send requests to the Algolia REST API.
180
+ * @param put - The put object.
181
+ * @param put.path - The path of the API endpoint to target, anything after the /1 needs to be specified.
182
+ * @param put.parameters - Query parameters to be applied to the current query.
183
+ * @param put.body - The parameters to send with the custom request.
184
+ * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
185
+ */
186
+ put({ path, parameters, body }, requestOptions) {
187
+ if (!path) {
188
+ throw new Error('Parameter `path` is required when calling `put`.');
189
+ }
190
+ const requestPath = '/1{path}'.replace('{path}', path);
191
+ const headers = {};
192
+ const queryParameters = parameters ? parameters : {};
193
+ const request = {
194
+ method: 'PUT',
195
+ path: requestPath,
196
+ queryParameters,
197
+ headers,
198
+ data: body ? body : {},
199
+ };
200
+ return transporter.request(request, requestOptions);
201
+ },
202
+ };
203
+ }
204
+
205
+ // This file is generated, manual changes will be lost - read more on https://github.com/algolia/api-clients-automation.
206
+ function recommendClient(appId, apiKey, options) {
207
+ if (!appId || typeof appId !== 'string') {
208
+ throw new Error('`appId` is missing.');
209
+ }
210
+ if (!apiKey || typeof apiKey !== 'string') {
211
+ throw new Error('`apiKey` is missing.');
212
+ }
213
+ return createRecommendClient({
214
+ appId,
215
+ apiKey,
216
+ timeouts: {
217
+ connect: DEFAULT_CONNECT_TIMEOUT_NODE,
218
+ read: DEFAULT_READ_TIMEOUT_NODE,
219
+ write: DEFAULT_WRITE_TIMEOUT_NODE,
220
+ },
221
+ requester: createHttpRequester(),
222
+ algoliaAgents: [{ segment: 'Node.js', version: process.versions.node }],
223
+ responsesCache: createNullCache(),
224
+ requestsCache: createNullCache(),
225
+ hostsCache: createMemoryCache(),
226
+ ...options,
227
+ });
228
+ }
229
+
230
+ export { apiClientVersion, recommendClient };
@@ -1,2 +1,2 @@
1
- /*! recommend.umd.js | 4.14.1 | © Algolia, inc. | https://github.com/algolia/algoliasearch-client-javascript */
2
- !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e=e||self)["@algolia/recommend"]=t()}(this,(function(){"use strict";function e(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function t(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function r(r){for(var n=1;n<arguments.length;n++){var o=null!=arguments[n]?arguments[n]:{};n%2?t(Object(o),!0).forEach((function(t){e(r,t,o[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(r,Object.getOwnPropertyDescriptors(o)):t(Object(o)).forEach((function(e){Object.defineProperty(r,e,Object.getOwnPropertyDescriptor(o,e))}))}return r}function n(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){if(!(Symbol.iterator in Object(e)||"[object Arguments]"===Object.prototype.toString.call(e)))return;var r=[],n=!0,o=!1,a=void 0;try{for(var u,i=e[Symbol.iterator]();!(n=(u=i.next()).done)&&(r.push(u.value),!t||r.length!==t);n=!0);}catch(e){o=!0,a=e}finally{try{n||null==i.return||i.return()}finally{if(o)throw a}}return r}(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance")}()}function o(e){return function(e){if(Array.isArray(e)){for(var t=0,r=new Array(e.length);t<e.length;t++)r[t]=e[t];return r}}(e)||function(e){if(Symbol.iterator in Object(e)||"[object Arguments]"===Object.prototype.toString.call(e))return Array.from(e)}(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance")}()}function a(e){var t,r="algoliasearch-client-js-".concat(e.key),o=function(){return void 0===t&&(t=e.localStorage||window.localStorage),t},a=function(){return JSON.parse(o().getItem(r)||"{}")};return{get:function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{miss:function(){return Promise.resolve()}};return Promise.resolve().then((function(){var r=JSON.stringify(e),n=a()[r];return Promise.all([n||t(),void 0!==n])})).then((function(e){var t=n(e,2),o=t[0],a=t[1];return Promise.all([o,a||r.miss(o)])})).then((function(e){return n(e,1)[0]}))},set:function(e,t){return Promise.resolve().then((function(){var n=a();return n[JSON.stringify(e)]=t,o().setItem(r,JSON.stringify(n)),t}))},delete:function(e){return Promise.resolve().then((function(){var t=a();delete t[JSON.stringify(e)],o().setItem(r,JSON.stringify(t))}))},clear:function(){return Promise.resolve().then((function(){o().removeItem(r)}))}}}function u(e){var t=o(e.caches),r=t.shift();return void 0===r?{get:function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{miss:function(){return Promise.resolve()}},o=t();return o.then((function(e){return Promise.all([e,r.miss(e)])})).then((function(e){return n(e,1)[0]}))},set:function(e,t){return Promise.resolve(t)},delete:function(e){return Promise.resolve()},clear:function(){return Promise.resolve()}}:{get:function(e,n){var o=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{miss:function(){return Promise.resolve()}};return r.get(e,n,o).catch((function(){return u({caches:t}).get(e,n,o)}))},set:function(e,n){return r.set(e,n).catch((function(){return u({caches:t}).set(e,n)}))},delete:function(e){return r.delete(e).catch((function(){return u({caches:t}).delete(e)}))},clear:function(){return r.clear().catch((function(){return u({caches:t}).clear()}))}}}function i(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{serializable:!0},t={};return{get:function(r,n){var o=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{miss:function(){return Promise.resolve()}},a=JSON.stringify(r);if(a in t)return Promise.resolve(e.serializable?JSON.parse(t[a]):t[a]);var u=n(),i=o&&o.miss||function(){return Promise.resolve()};return u.then((function(e){return i(e)})).then((function(){return u}))},set:function(r,n){return t[JSON.stringify(r)]=e.serializable?JSON.stringify(n):n,Promise.resolve(n)},delete:function(e){return delete t[JSON.stringify(e)],Promise.resolve()},clear:function(){return t={},Promise.resolve()}}}function s(e){for(var t=e.length-1;t>0;t--){var r=Math.floor(Math.random()*(t+1)),n=e[t];e[t]=e[r],e[r]=n}return e}var c={WithinQueryParameters:0,WithinHeaders:1},l=1,f=2,d=3;function h(e,t){var r=e||{},n=r.data||{};return Object.keys(r).forEach((function(e){-1===["timeout","headers","queryParameters","data","cacheable"].indexOf(e)&&(n[e]=r[e])})),{data:Object.entries(n).length>0?n:void 0,timeout:r.timeout||t,headers:r.headers||{},queryParameters:r.queryParameters||{},cacheable:r.cacheable}}var m={Read:1,Write:2,Any:3},p=1,g=2,v=3;function y(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:p;return r(r({},e),{},{status:t,lastUpdate:Date.now()})}function b(e){return"string"==typeof e?{protocol:"https",url:e,accept:m.Any}:{protocol:e.protocol||"https",url:e.url,accept:e.accept||m.Any}}var P="GET",O="POST";function q(e,t){return Promise.all(t.map((function(t){return e.get(t,(function(){return Promise.resolve(y(t))}))}))).then((function(e){var r=e.filter((function(e){return function(e){return e.status===p||Date.now()-e.lastUpdate>12e4}(e)})),n=e.filter((function(e){return function(e){return e.status===v&&Date.now()-e.lastUpdate<=12e4}(e)})),a=[].concat(o(r),o(n));return{getTimeout:function(e,t){return(0===n.length&&0===e?1:n.length+3+e)*t},statelessHosts:a.length>0?a.map((function(e){return b(e)})):t}}))}function S(e,t,n,a){var u=[],i=function(e,t){if(e.method===P||void 0===e.data&&void 0===t.data)return;var n=Array.isArray(e.data)?e.data:r(r({},e.data),t.data);return JSON.stringify(n)}(n,a),s=function(e,t){var n=r(r({},e.headers),t.headers),o={};return Object.keys(n).forEach((function(e){var t=n[e];o[e.toLowerCase()]=t})),o}(e,a),c=n.method,l=n.method!==P?{}:r(r({},n.data),a.data),f=r(r(r({"x-algolia-agent":e.userAgent.value},e.queryParameters),l),a.queryParameters),d=0,h=function t(r,o){var l=r.pop();if(void 0===l)throw{name:"RetryError",message:"Unreachable hosts - your application id may be incorrect. If the error persists, contact support@algolia.com.",transporterStackTrace:T(u)};var h={data:i,headers:s,method:c,url:w(l,n.path,f),connectTimeout:o(d,e.timeouts.connect),responseTimeout:o(d,a.timeout)},m=function(e){var t={request:h,response:e,host:l,triesLeft:r.length};return u.push(t),t},p={onSuccess:function(e){return function(e){try{return JSON.parse(e.content)}catch(t){throw function(e,t){return{name:"DeserializationError",message:e,response:t}}(t.message,e)}}(e)},onRetry:function(n){var a=m(n);return n.isTimedOut&&d++,Promise.all([e.logger.info("Retryable failure",A(a)),e.hostsCache.set(l,y(l,n.isTimedOut?v:g))]).then((function(){return t(r,o)}))},onFail:function(e){throw m(e),function(e,t){var r=e.content,n=e.status,o=r;try{o=JSON.parse(r).message}catch(e){}return function(e,t,r){return{name:"ApiError",message:e,status:t,transporterStackTrace:r}}(o,n,t)}(e,T(u))}};return e.requester.send(h).then((function(e){return function(e,t){return function(e){var t=e.status;return e.isTimedOut||function(e){var t=e.isTimedOut,r=e.status;return!t&&0==~~r}(e)||2!=~~(t/100)&&4!=~~(t/100)}(e)?t.onRetry(e):2==~~(e.status/100)?t.onSuccess(e):t.onFail(e)}(e,p)}))};return q(e.hostsCache,t).then((function(e){return h(o(e.statelessHosts).reverse(),e.getTimeout)}))}function j(e){var t={value:"Algolia for JavaScript (".concat(e,")"),add:function(e){var r="; ".concat(e.segment).concat(void 0!==e.version?" (".concat(e.version,")"):"");return-1===t.value.indexOf(r)&&(t.value="".concat(t.value).concat(r)),t}};return t}function w(e,t,r){var n,o=(n=r,Object.keys(n).map((function(e){return function(e){for(var t=arguments.length,r=new Array(t>1?t-1:0),n=1;n<t;n++)r[n-1]=arguments[n];var o=0;return e.replace(/%s/g,(function(){return encodeURIComponent(r[o++])}))}("%s=%s",e,(t=n[e],"[object Object]"===Object.prototype.toString.call(t)||"[object Array]"===Object.prototype.toString.call(t)?JSON.stringify(n[e]):n[e]));var t})).join("&")),a="".concat(e.protocol,"://").concat(e.url,"/").concat("/"===t.charAt(0)?t.substr(1):t);return o.length&&(a+="?".concat(o)),a}function T(e){return e.map((function(e){return A(e)}))}function A(e){var t=e.request.headers["x-algolia-api-key"]?{"x-algolia-api-key":"*****"}:{};return r(r({},e),{},{request:r(r({},e.request),{},{headers:r(r({},e.request.headers),t)})})}var C=function(e){var t=e.appId,o=function(e,t,r){var n={"x-algolia-api-key":r,"x-algolia-application-id":t};return{headers:function(){return e===c.WithinHeaders?n:{}},queryParameters:function(){return e===c.WithinQueryParameters?n:{}}}}(void 0!==e.authMode?e.authMode:c.WithinHeaders,t,e.apiKey),a=function(e){var t=e.hostsCache,r=e.logger,o=e.requester,a=e.requestsCache,u=e.responsesCache,i=e.timeouts,s=e.userAgent,c=e.hosts,l=e.queryParameters,f={hostsCache:t,logger:r,requester:o,requestsCache:a,responsesCache:u,timeouts:i,userAgent:s,headers:e.headers,queryParameters:l,hosts:c.map((function(e){return b(e)})),read:function(e,t){var r=h(t,f.timeouts.read),o=function(){return S(f,f.hosts.filter((function(e){return 0!=(e.accept&m.Read)})),e,r)};if(!0!==(void 0!==r.cacheable?r.cacheable:e.cacheable))return o();var a={request:e,mappedRequestOptions:r,transporter:{queryParameters:f.queryParameters,headers:f.headers}};return f.responsesCache.get(a,(function(){return f.requestsCache.get(a,(function(){return f.requestsCache.set(a,o()).then((function(e){return Promise.all([f.requestsCache.delete(a),e])}),(function(e){return Promise.all([f.requestsCache.delete(a),Promise.reject(e)])})).then((function(e){var t=n(e,2);t[0];return t[1]}))}))}),{miss:function(e){return f.responsesCache.set(a,e)}})},write:function(e,t){return S(f,f.hosts.filter((function(e){return 0!=(e.accept&m.Write)})),e,h(t,f.timeouts.write))}};return f}(r(r({hosts:[{url:"".concat(t,"-dsn.algolia.net"),accept:m.Read},{url:"".concat(t,".algolia.net"),accept:m.Write}].concat(s([{url:"".concat(t,"-1.algolianet.com")},{url:"".concat(t,"-2.algolianet.com")},{url:"".concat(t,"-3.algolianet.com")}]))},e),{},{headers:r(r(r({},o.headers()),{"content-type":"application/x-www-form-urlencoded"}),e.headers),queryParameters:r(r({},o.queryParameters()),e.queryParameters)}));return function(e,t){return t?(Object.keys(t).forEach((function(r){e[r]=t[r](e)})),e):e}({transporter:a,appId:t,addAlgoliaAgent:function(e,t){a.userAgent.add({segment:e,version:t})},clearCache:function(){return Promise.all([a.requestsCache.clear(),a.responsesCache.clear()]).then((function(){}))}},e.methods)},N=function(e){return function(t,n){var o=t.map((function(e){return r(r({},e),{},{threshold:e.threshold||0})}));return e.transporter.read({method:O,path:"1/indexes/*/recommendations",data:{requests:o},cacheable:!0},n)}},k=function(e){return function(t,n){return N(e)(t.map((function(e){return r(r({},e),{},{fallbackParameters:{},model:"bought-together"})})),n)}},x=function(e){return function(t,n){return N(e)(t.map((function(e){return r(r({},e),{},{model:"related-products"})})),n)}},J=function(e){return function(t,n){var o=t.map((function(e){return r(r({},e),{},{model:"trending-facets",threshold:e.threshold||0})}));return e.transporter.read({method:O,path:"1/indexes/*/recommendations",data:{requests:o},cacheable:!0},n)}},E=function(e){return function(t,n){var o=t.map((function(e){return r(r({},e),{},{model:"trending-items",threshold:e.threshold||0})}));return e.transporter.read({method:O,path:"1/indexes/*/recommendations",data:{requests:o},cacheable:!0},n)}};function R(e,t,n){var o,s={appId:e,apiKey:t,timeouts:{connect:1,read:2,write:30},requester:{send:function(e){return new Promise((function(t){var r=new XMLHttpRequest;r.open(e.method,e.url,!0),Object.keys(e.headers).forEach((function(t){return r.setRequestHeader(t,e.headers[t])}));var n,o=function(e,n){return setTimeout((function(){r.abort(),t({status:0,content:n,isTimedOut:!0})}),1e3*e)},a=o(e.connectTimeout,"Connection timeout");r.onreadystatechange=function(){r.readyState>r.OPENED&&void 0===n&&(clearTimeout(a),n=o(e.responseTimeout,"Socket timeout"))},r.onerror=function(){0===r.status&&(clearTimeout(a),clearTimeout(n),t({content:r.responseText||"Network request failed",status:r.status,isTimedOut:!1}))},r.onload=function(){clearTimeout(a),clearTimeout(n),t({content:r.responseText,status:r.status,isTimedOut:!1})},r.send(e.data)}))}},logger:(o=d,{debug:function(e,t){return l>=o&&console.debug(e,t),Promise.resolve()},info:function(e,t){return f>=o&&console.info(e,t),Promise.resolve()},error:function(e,t){return console.error(e,t),Promise.resolve()}}),responsesCache:i(),requestsCache:i({serializable:!1}),hostsCache:u({caches:[a({key:"".concat("4.14.1","-").concat(e)}),i()]}),userAgent:j("4.14.1").add({segment:"Recommend",version:"4.14.1"}).add({segment:"Browser"}),authMode:c.WithinQueryParameters};return C(r(r(r({},s),n),{},{methods:{getFrequentlyBoughtTogether:k,getRecommendations:N,getRelatedProducts:x,getTrendingFacets:J,getTrendingItems:E}}))}return R.version="4.14.1",R}));
1
+ /*! recommend.umd.js | 5.0.0-alpha.2 | © 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,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function r(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)||"{}")}return{get:(e,t,r={miss:()=>Promise.resolve()})=>Promise.resolve().then((()=>{const r=JSON.stringify(e),a=s()[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 n=s();return n[JSON.stringify(e)]=t,a().setItem(r,JSON.stringify(n)),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 a(e){const t=[...e.caches],r=t.shift();return void 0===r?{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,n={miss:()=>Promise.resolve()})=>r.get(e,s,n).catch((()=>a({caches:t}).get(e,s,n))),set:(e,s)=>r.set(e,s).catch((()=>a({caches:t}).set(e,s))),delete:e=>r.delete(e).catch((()=>a({caches:t}).delete(e))),clear:()=>r.clear().catch((()=>a({caches:t}).clear()))}}function s(e={serializable:!0}){let t={};return{get(r,a,s={miss:()=>Promise.resolve()}){const n=JSON.stringify(r);if(n in t)return Promise.resolve(e.serializable?JSON.parse(t[n]):t[n]);const o=a();return o.then((e=>s.miss(e))).then((()=>o))},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 n=12e4;function o(e,t="up"){const r=Date.now();return{...e,status:t,lastUpdate:r,isUp:function(){return"up"===t||Date.now()-r>n},isTimedOut:function(){return"timed out"===t&&Date.now()-r<=n}}}function i(e,t,r){return 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, contact support@algolia.com.",e,"RetryError")}}class p extends u{constructor(e,t,r){super(e,r,"ApiError"),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}}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}=${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 m(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 g=[],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),O=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),b="GET"===c.method?{...c.data,...u.data}:{},P={"x-algolia-agent":s.value,...a,...c.queryParameters,...b};if(u&&u.queryParameters)for(const e of Object.keys(u.queryParameters))u.queryParameters[e]&&"[object Object]"!==Object.prototype.toString.call(u.queryParameters[e])?P[e]=u.queryParameters[e].toString():P[e]=u.queryParameters[e];let v=0;const w=async(e,r)=>{const a=e.pop();if(void 0===a)throw new l(function(e){return e.map((e=>m(e)))}(g));let s=u.timeout;void 0===s&&(s=f?n.read:n.write);const b={data:y,headers:O,method:c.method,url:h(a,c.path,P),connectTimeout:r(v,n.connect),responseTimeout:r(v,s)},j=t=>{const r={request:b,response:t,host:a,triesLeft:e.length};return g.push(r),r},q=await i.send(b);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)}(q)){const s=j(q);return q.isTimedOut&&v++,console.log("Retryable failure",m(s)),await t.set(a,o(a,q.isTimedOut?"timed out":"down")),w(e,r)}if(function({status:e}){return 2==~~(e/100)}(q))return function(e){try{return JSON.parse(e.content)}catch(t){throw new d(t.message,e)}}(q);throw j(q),function({content:e,status:t},r){let a=e;try{a=JSON.parse(e).message}catch(e){}return new p(a,t,r)}(q,g)},j=e.filter((e=>"readWrite"===e.accept||(f?"read"===e.accept:"write"===e.accept))),q=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}}(j);return w([...q.hosts].reverse(),q.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 n=()=>f(e,t);if(!0!==(t.cacheable||e.cacheable))return n();const o={request:e,requestOptions:t,transporter:{queryParameters:a,headers:r}};return u.get(o,(()=>c.get(o,(()=>c.set(o,n()).then((e=>Promise.all([c.delete(o),e])),(e=>Promise.all([c.delete(o),Promise.reject(e)]))).then((([e,t])=>t))))),{miss:e=>u.set(o,e)})},requestsCache:c,responsesCache:u}}function g({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}function y(e,t){if(null==e)return{};var r,a,s=function(e,t){if(null==e)return{};var r,a,s={},n=Object.keys(e);for(a=0;a<n.length;a++)r=n[a],t.indexOf(r)>=0||(s[r]=e[r]);return s}(e,t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);for(a=0;a<n.length;a++)r=n[a],t.indexOf(r)>=0||Object.prototype.propertyIsEnumerable.call(e,r)&&(s[r]=e[r])}return s}var O=["appId","apiKey","authMode","algoliaAgents"];function b(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);t&&(a=a.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,a)}return r}function P(e){for(var r=1;r<arguments.length;r++){var a=null!=arguments[r]?arguments[r]:{};r%2?b(Object(a),!0).forEach((function(r){t(e,r,a[r])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(a)):b(Object(a)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(a,t))}))}return e}var v="5.0.0-alpha.2";function w(e){return[{url:"".concat(e,"-dsn.algolia.net"),accept:"read",protocol:"https"},{url:"".concat(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:"".concat(e,"-1.algolianet.com"),accept:"readWrite",protocol:"https"},{url:"".concat(e,"-2.algolianet.com"),accept:"readWrite",protocol:"https"},{url:"".concat(e,"-3.algolianet.com"),accept:"readWrite",protocol:"https"}]))}function j(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);t&&(a=a.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,a)}return r}e.apiClientVersion=v,e.recommendClient=function(e,n,o){if(!e||"string"!=typeof e)throw new Error("`appId` is missing.");if(!n||"string"!=typeof n)throw new Error("`apiKey` is missing.");return function(e){var t=e.appId,r=e.apiKey,a=e.authMode,s=e.algoliaAgents,n=y(e,O),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:{}}}(t,r,a),i=f(P(P({hosts:w(t)},n),{},{algoliaAgent:g({algoliaAgents:s,client:"Recommend",version:v}),baseHeaders:P(P({"content-type":"text/plain"},o.headers()),n.baseHeaders),baseQueryParameters:P(P({},o.queryParameters()),n.baseQueryParameters)}));return{transporter:i,get _ua(){return i.algoliaAgent.value},addAlgoliaAgent:function(e,t){i.algoliaAgent.add({segment:e,version:t})},del:function(e,t){var r=e.path,a=e.parameters;if(!r)throw new Error("Parameter `path` is required when calling `del`.");var s={method:"DELETE",path:"/1{path}".replace("{path}",r),queryParameters:a||{},headers:{}};return i.request(s,t)},get:function(e,t){var r=e.path,a=e.parameters;if(!r)throw new Error("Parameter `path` is required when calling `get`.");var s={method:"GET",path:"/1{path}".replace("{path}",r),queryParameters:a||{},headers:{}};return i.request(s,t)},getRecommendations:function(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`.");var r={method:"POST",path:"/1/indexes/*/recommendations",queryParameters:{},headers:{},data:e,useReadTransporter:!0,cacheable:!0};return i.request(r,t)},post:function(e,t){var r=e.path,a=e.parameters,s=e.body;if(!r)throw new Error("Parameter `path` is required when calling `post`.");var n={method:"POST",path:"/1{path}".replace("{path}",r),queryParameters:a||{},headers:{},data:s||{}};return i.request(n,t)},put:function(e,t){var r=e.path,a=e.parameters,s=e.body;if(!r)throw new Error("Parameter `path` is required when calling `put`.");var n={method:"PUT",path:"/1{path}".replace("{path}",r),queryParameters:a||{},headers:{},data:s||{}};return i.request(n,t)}}}(function(e){for(var r=1;r<arguments.length;r++){var a=null!=arguments[r]?arguments[r]:{};r%2?j(Object(a),!0).forEach((function(r){t(e,r,a[r])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(a)):j(Object(a)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(a,t))}))}return e}({appId:e,apiKey:n,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 n;r.onreadystatechange=()=>{r.readyState>r.OPENED&&void 0===n&&(clearTimeout(s),n=a(e.responseTimeout,"Socket timeout"))},r.onerror=()=>{0===r.status&&(clearTimeout(s),clearTimeout(n),t({content:r.responseText||"Network request failed",status:r.status,isTimedOut:!1}))},r.onload=()=>{clearTimeout(s),clearTimeout(n),t({content:r.responseText,status:r.status,isTimedOut:!1})},r.send(e.data)}))}},algoliaAgents:[{segment:"Browser"}],authMode:"WithinQueryParameters",responsesCache:s(),requestsCache:s({serializable:!1}),hostsCache:a({caches:[r({key:"".concat(v,"-").concat(e)}),s()]})},o))}}));
@@ -0,0 +1,74 @@
1
+ import type { CreateClientOptions, RequestOptions } from '@algolia/client-common';
2
+ import type { DelProps, GetProps, PostProps, PutProps } from '../model/clientMethodProps';
3
+ import type { GetRecommendationsParams } from '../model/getRecommendationsParams';
4
+ import type { GetRecommendationsResponse } from '../model/getRecommendationsResponse';
5
+ export declare const apiClientVersion = "5.0.0-alpha.2";
6
+ export declare function createRecommendClient({ appId: appIdOption, apiKey: apiKeyOption, authMode, algoliaAgents, ...options }: CreateClientOptions): {
7
+ transporter: import("@algolia/client-common").Transporter;
8
+ /**
9
+ * Get the value of the `algoliaAgent`, used by our libraries internally and telemetry system.
10
+ */
11
+ readonly _ua: string;
12
+ /**
13
+ * Adds a `segment` to the `x-algolia-agent` sent with every requests.
14
+ *
15
+ * @param segment - The algolia agent (user-agent) segment to add.
16
+ * @param version - The version of the agent.
17
+ */
18
+ addAlgoliaAgent(segment: string, version?: string): void;
19
+ /**
20
+ * This method allow you to send requests to the Algolia REST API.
21
+ *
22
+ * @summary Send requests to the Algolia REST API.
23
+ * @param del - The del object.
24
+ * @param del.path - The path of the API endpoint to target, anything after the /1 needs to be specified.
25
+ * @param del.parameters - Query parameters to be applied to the current query.
26
+ * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
27
+ */
28
+ del({ path, parameters }: DelProps, requestOptions?: RequestOptions): Promise<Record<string, any>>;
29
+ /**
30
+ * This method allow you to send requests to the Algolia REST API.
31
+ *
32
+ * @summary Send requests to the Algolia REST API.
33
+ * @param get - The get object.
34
+ * @param get.path - The path of the API endpoint to target, anything after the /1 needs to be specified.
35
+ * @param get.parameters - Query parameters to be applied to the current query.
36
+ * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
37
+ */
38
+ get({ path, parameters }: GetProps, requestOptions?: RequestOptions): Promise<Record<string, any>>;
39
+ /**
40
+ * Returns recommendations or trending results, for a specific model and `objectID`.
41
+ *
42
+ * @summary Get results.
43
+ * @param getRecommendationsParams - The getRecommendationsParams object.
44
+ * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
45
+ */
46
+ getRecommendations(getRecommendationsParams: GetRecommendationsParams, requestOptions?: RequestOptions): Promise<GetRecommendationsResponse>;
47
+ /**
48
+ * This method allow you to send requests to the Algolia REST API.
49
+ *
50
+ * @summary Send requests to the Algolia REST API.
51
+ * @param post - The post object.
52
+ * @param post.path - The path of the API endpoint to target, anything after the /1 needs to be specified.
53
+ * @param post.parameters - Query parameters to be applied to the current query.
54
+ * @param post.body - The parameters to send with the custom request.
55
+ * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
56
+ */
57
+ post({ path, parameters, body }: PostProps, requestOptions?: RequestOptions): Promise<Record<string, any>>;
58
+ /**
59
+ * This method allow you to send requests to the Algolia REST API.
60
+ *
61
+ * @summary Send requests to the Algolia REST API.
62
+ * @param put - The put object.
63
+ * @param put.path - The path of the API endpoint to target, anything after the /1 needs to be specified.
64
+ * @param put.parameters - Query parameters to be applied to the current query.
65
+ * @param put.body - The parameters to send with the custom request.
66
+ * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
67
+ */
68
+ put({ path, parameters, body }: PutProps, requestOptions?: RequestOptions): Promise<Record<string, any>>;
69
+ };
70
+ /**
71
+ * The client type.
72
+ */
73
+ export declare type RecommendClient = ReturnType<typeof createRecommendClient>;
74
+ //# sourceMappingURL=recommendClient.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"recommendClient.d.ts","sourceRoot":"","sources":["../../../../packages/recommend/src/recommendClient.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EACV,mBAAmB,EAInB,cAAc,EAEf,MAAM,wBAAwB,CAAC;AAEhC,OAAO,KAAK,EACV,QAAQ,EACR,QAAQ,EACR,SAAS,EACT,QAAQ,EACT,MAAM,4BAA4B,CAAC;AACpC,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,mCAAmC,CAAC;AAClF,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,qCAAqC,CAAC;AAEtF,eAAO,MAAM,gBAAgB,kBAAkB,CAAC;AAsChD,wBAAgB,qBAAqB,CAAC,EACpC,KAAK,EAAE,WAAW,EAClB,MAAM,EAAE,YAAY,EACpB,QAAQ,EACR,aAAa,EACb,GAAG,OAAO,EACX,EAAE,mBAAmB;;IAuBlB;;OAEG;;IAIH;;;;;OAKG;6BACsB,MAAM,YAAY,MAAM,GAAG,IAAI;IAGxD;;;;;;;;OAQG;8BAEqB,QAAQ,mBACb,cAAc,GAC9B,QAAQ,OAAO,MAAM,EAAE,GAAG,CAAC,CAAC;IAmB/B;;;;;;;;OAQG;8BAEqB,QAAQ,mBACb,cAAc,GAC9B,QAAQ,OAAO,MAAM,EAAE,GAAG,CAAC,CAAC;IAmB/B;;;;;;OAMG;iDAEyB,wBAAwB,mBACjC,cAAc,GAC9B,QAAQ,0BAA0B,CAAC;IA8BtC;;;;;;;;;OASG;qCAE2B,SAAS,mBACpB,cAAc,GAC9B,QAAQ,OAAO,MAAM,EAAE,GAAG,CAAC,CAAC;IAoB/B;;;;;;;;;OASG;oCAE2B,QAAQ,mBACnB,cAAc,GAC9B,QAAQ,OAAO,MAAM,EAAE,GAAG,CAAC,CAAC;EAoBlC;AAED;;GAEG;AACH,oBAAY,eAAe,GAAG,UAAU,CAAC,OAAO,qBAAqB,CAAC,CAAC"}
package/index.d.ts CHANGED
@@ -1,3 +1,2 @@
1
- /* eslint-disable import/no-unresolved*/
2
- export * from './dist/recommend';
3
- export { default } from './dist/recommend';
1
+ // eslint-disable-next-line import/no-unresolved
2
+ export * from './dist/builds/node';
package/index.js CHANGED
@@ -1,15 +1,2 @@
1
- /* eslint-disable functional/immutable-data, import/no-commonjs */
2
- const recommend = require('./dist/recommend.cjs.js');
3
-
4
- /**
5
- * The Common JS build is the default entry point for the Node environment. Keep in
6
- * in mind, that for the browser environment, we hint the bundler to use the UMD
7
- * build instead as specified on the key `browser` of our `package.json` file.
8
- */
9
- module.exports = recommend;
10
-
11
- /**
12
- * In addition, we also set explicitly the default export below making
13
- * this Common JS module in compliance with es6 modules specification.
14
- */
15
- module.exports.default = recommend;
1
+ // eslint-disable-next-line import/no-commonjs,import/extensions
2
+ module.exports = require('./dist/recommend.cjs.js');
@@ -0,0 +1,3 @@
1
+ // This file is generated, manual changes will be lost - read more on https://github.com/algolia/api-clients-automation.
2
+
3
+ export type AdvancedSyntaxFeatures = 'exactPhrase' | 'excludeWords';
@@ -0,0 +1,6 @@
1
+ // This file is generated, manual changes will be lost - read more on https://github.com/algolia/api-clients-automation.
2
+
3
+ export type AlternativesAsExact =
4
+ | 'ignorePlurals'
5
+ | 'multiWordsSynonym'
6
+ | 'singleWordSynonym';
@@ -0,0 +1,8 @@
1
+ // This file is generated, manual changes will be lost - read more on https://github.com/algolia/api-clients-automation.
2
+
3
+ import type { AroundRadiusAll } from './aroundRadiusAll';
4
+
5
+ /**
6
+ * Define the maximum radius for a geo search (in meters).
7
+ */
8
+ export type AroundRadius = AroundRadiusAll | number;
@@ -0,0 +1,3 @@
1
+ // This file is generated, manual changes will be lost - read more on https://github.com/algolia/api-clients-automation.
2
+
3
+ export type AroundRadiusAll = 'all';
@@ -0,0 +1,20 @@
1
+ // This file is generated, manual changes will be lost - read more on https://github.com/algolia/api-clients-automation.
2
+
3
+ import type { SearchParamsObject } from './searchParamsObject';
4
+
5
+ export type BaseRecommendRequest = {
6
+ /**
7
+ * The Algolia index name.
8
+ */
9
+ indexName: string;
10
+ /**
11
+ * The threshold to use when filtering recommendations by their score.
12
+ */
13
+ threshold: number;
14
+ /**
15
+ * The max number of recommendations to retrieve. If it\'s set to 0, all the recommendations of the objectID may be returned.
16
+ */
17
+ maxRecommendations?: number;
18
+ queryParameters?: SearchParamsObject;
19
+ fallbackParameters?: SearchParamsObject;
20
+ };
@@ -0,0 +1,11 @@
1
+ // This file is generated, manual changes will be lost - read more on https://github.com/algolia/api-clients-automation.
2
+
3
+ import type { RecommendationModels } from './recommendationModels';
4
+
5
+ export type BaseRecommendationRequest = {
6
+ model: RecommendationModels;
7
+ /**
8
+ * Unique identifier of the object.
9
+ */
10
+ objectID: string;
11
+ };
@@ -0,0 +1,6 @@
1
+ // This file is generated, manual changes will be lost - read more on https://github.com/algolia/api-clients-automation.
2
+
3
+ import type { BaseSearchParamsWithoutQuery } from './baseSearchParamsWithoutQuery';
4
+ import type { SearchParamsQuery } from './searchParamsQuery';
5
+
6
+ export type BaseSearchParams = BaseSearchParamsWithoutQuery & SearchParamsQuery;
@@ -0,0 +1,125 @@
1
+ // This file is generated, manual changes will be lost - read more on https://github.com/algolia/api-clients-automation.
2
+
3
+ import type { AroundRadius } from './aroundRadius';
4
+ import type { FacetFilters } from './facetFilters';
5
+ import type { NumericFilters } from './numericFilters';
6
+ import type { OptionalFilters } from './optionalFilters';
7
+ import type { ReRankingApplyFilter } from './reRankingApplyFilter';
8
+ import type { TagFilters } from './tagFilters';
9
+
10
+ export type BaseSearchParamsWithoutQuery = {
11
+ /**
12
+ * Overrides the query parameter and performs a more generic search that can be used to find \"similar\" results.
13
+ */
14
+ similarQuery?: string;
15
+ /**
16
+ * Filter the query with numeric, facet and/or tag filters.
17
+ */
18
+ filters?: string;
19
+ facetFilters?: FacetFilters;
20
+ optionalFilters?: OptionalFilters;
21
+ numericFilters?: NumericFilters;
22
+ tagFilters?: TagFilters;
23
+ /**
24
+ * Determines how to calculate the total score for filtering.
25
+ */
26
+ sumOrFiltersScores?: boolean;
27
+ /**
28
+ * Retrieve facets and their facet values.
29
+ */
30
+ facets?: string[];
31
+ /**
32
+ * Maximum number of facet values to return for each facet during a regular search.
33
+ */
34
+ maxValuesPerFacet?: number;
35
+ /**
36
+ * Force faceting to be applied after de-duplication (via the Distinct setting).
37
+ */
38
+ facetingAfterDistinct?: boolean;
39
+ /**
40
+ * Controls how facet values are fetched.
41
+ */
42
+ sortFacetValuesBy?: string;
43
+ /**
44
+ * Specify the page to retrieve.
45
+ */
46
+ page?: number;
47
+ /**
48
+ * Specify the offset of the first hit to return.
49
+ */
50
+ offset?: number;
51
+ /**
52
+ * Set the number of hits to retrieve (used only with offset).
53
+ */
54
+ length?: number;
55
+ /**
56
+ * Search for entries around a central geolocation, enabling a geo search within a circular area.
57
+ */
58
+ aroundLatLng?: string;
59
+ /**
60
+ * Search for entries around a given location automatically computed from the requester\'s IP address.
61
+ */
62
+ aroundLatLngViaIP?: boolean;
63
+ aroundRadius?: AroundRadius;
64
+ /**
65
+ * Precision of geo search (in meters), to add grouping by geo location to the ranking formula.
66
+ */
67
+ aroundPrecision?: number;
68
+ /**
69
+ * Minimum radius (in meters) used for a geo search when aroundRadius is not set.
70
+ */
71
+ minimumAroundRadius?: number;
72
+ /**
73
+ * Search inside a rectangular area (in geo coordinates).
74
+ */
75
+ insideBoundingBox?: number[];
76
+ /**
77
+ * Search inside a polygon (in geo coordinates).
78
+ */
79
+ insidePolygon?: number[];
80
+ /**
81
+ * This parameter changes the default values of certain parameters and settings that work best for a natural language query, such as ignorePlurals, removeStopWords, removeWordsIfNoResults, analyticsTags and ruleContexts. These parameters and settings work well together when the query is formatted in natural language instead of keywords, for example when your user performs a voice search.
82
+ */
83
+ naturalLanguages?: string[];
84
+ /**
85
+ * Enables contextual rules.
86
+ */
87
+ ruleContexts?: string[];
88
+ /**
89
+ * Define the impact of the Personalization feature.
90
+ */
91
+ personalizationImpact?: number;
92
+ /**
93
+ * Associates a certain user token with the current search.
94
+ */
95
+ userToken?: string;
96
+ /**
97
+ * Retrieve detailed ranking information.
98
+ */
99
+ getRankingInfo?: boolean;
100
+ /**
101
+ * Enable the Click Analytics feature.
102
+ */
103
+ clickAnalytics?: boolean;
104
+ /**
105
+ * Whether the current query will be taken into account in the Analytics.
106
+ */
107
+ analytics?: boolean;
108
+ /**
109
+ * List of tags to apply to the query for analytics purposes.
110
+ */
111
+ analyticsTags?: string[];
112
+ /**
113
+ * Whether to include or exclude a query from the processing-time percentile computation.
114
+ */
115
+ percentileComputation?: boolean;
116
+ /**
117
+ * Whether this search should participate in running AB tests.
118
+ */
119
+ enableABTest?: boolean;
120
+ /**
121
+ * Whether this search should use AI Re-Ranking.
122
+ */
123
+ enableReRanking?: boolean;
124
+ reRankingApplyFilter?: ReRankingApplyFilter | null;
125
+ };