@algolia/recommend 5.0.0-alpha.73 → 5.0.0-alpha.75
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.
- package/dist/model/anchoring.d.ts +5 -0
- package/dist/model/anchoring.d.ts.map +1 -0
- package/dist/model/aroundRadius.d.ts +1 -1
- package/dist/model/automaticFacetFilter.d.ts +18 -0
- package/dist/model/automaticFacetFilter.d.ts.map +1 -0
- package/dist/model/automaticFacetFilters.d.ts +6 -0
- package/dist/model/automaticFacetFilters.d.ts.map +1 -0
- package/dist/model/baseRecommendRequest.d.ts +3 -3
- package/dist/model/baseRecommendationRequest.d.ts +1 -1
- package/dist/model/baseSearchParamsWithoutQuery.d.ts +25 -25
- package/dist/model/baseSearchResponse.d.ts +20 -20
- package/dist/model/baseSearchResponseRedirect.d.ts +1 -1
- package/dist/model/baseTrendingRequest.d.ts +2 -2
- package/dist/model/clientMethodProps.d.ts +77 -10
- package/dist/model/clientMethodProps.d.ts.map +1 -1
- package/dist/model/condition.d.ts +17 -0
- package/dist/model/condition.d.ts.map +1 -0
- package/dist/model/consequence.d.ts +26 -0
- package/dist/model/consequence.d.ts.map +1 -0
- package/dist/model/consequenceHide.d.ts +10 -0
- package/dist/model/consequenceHide.d.ts.map +1 -0
- package/dist/model/consequenceParams.d.ts +5 -0
- package/dist/model/consequenceParams.d.ts.map +1 -0
- package/dist/model/consequenceQuery.d.ts +6 -0
- package/dist/model/consequenceQuery.d.ts.map +1 -0
- package/dist/model/consequenceQueryObject.d.ts +12 -0
- package/dist/model/consequenceQueryObject.d.ts.map +1 -0
- package/dist/model/deletedAtResponse.d.ts +14 -0
- package/dist/model/deletedAtResponse.d.ts.map +1 -0
- package/dist/model/distinct.d.ts +1 -1
- package/dist/model/edit.d.ts +13 -0
- package/dist/model/edit.d.ts.map +1 -0
- package/dist/model/editType.d.ts +5 -0
- package/dist/model/editType.d.ts.map +1 -0
- package/dist/model/exactOnSingleWordQuery.d.ts +1 -1
- package/dist/model/facetFilters.d.ts +1 -1
- package/dist/model/facetOrdering.d.ts +2 -2
- package/dist/model/facets.d.ts +1 -1
- package/dist/model/facetsStats.d.ts +4 -4
- package/dist/model/getRecommendTaskResponse.d.ts +5 -0
- package/dist/model/getRecommendTaskResponse.d.ts.map +1 -0
- package/dist/model/getRecommendationsParams.d.ts +2 -2
- package/dist/model/highlightResultOption.d.ts +1 -1
- package/dist/model/ignorePlurals.d.ts +1 -1
- package/dist/model/index.d.ts +23 -0
- package/dist/model/index.d.ts.map +1 -1
- package/dist/model/indexSettingsAsSearchParams.d.ts +30 -30
- package/dist/model/indexSettingsAsSearchParamsSemanticSearch.d.ts +2 -2
- package/dist/model/mode.d.ts +1 -1
- package/dist/model/numericFilters.d.ts +1 -1
- package/dist/model/optionalFilters.d.ts +1 -1
- package/dist/model/params.d.ts +13 -0
- package/dist/model/params.d.ts.map +1 -0
- package/dist/model/promote.d.ts +4 -0
- package/dist/model/promote.d.ts.map +1 -0
- package/dist/model/promoteObjectID.d.ts +14 -0
- package/dist/model/promoteObjectID.d.ts.map +1 -0
- package/dist/model/promoteObjectIDs.d.ts +14 -0
- package/dist/model/promoteObjectIDs.d.ts.map +1 -0
- package/dist/model/queryType.d.ts +1 -1
- package/dist/model/reRankingApplyFilter.d.ts +1 -1
- package/dist/model/recommendHit.d.ts +3 -3
- package/dist/model/recommendModels.d.ts +2 -0
- package/dist/model/recommendModels.d.ts.map +1 -0
- package/dist/model/recommendationModels.d.ts +1 -1
- package/dist/model/redirectRuleIndexMetadata.d.ts +1 -1
- package/dist/model/redirectRuleIndexMetadataData.d.ts +1 -1
- package/dist/model/removeStopWords.d.ts +1 -1
- package/dist/model/removeWordsIfNoResults.d.ts +1 -1
- package/dist/model/renderingContent.d.ts +1 -1
- package/dist/model/ruleResponse.d.ts +27 -0
- package/dist/model/ruleResponse.d.ts.map +1 -0
- package/dist/model/ruleResponseMetadata.d.ts +7 -0
- package/dist/model/ruleResponseMetadata.d.ts.map +1 -0
- package/dist/model/searchParamsQuery.d.ts +1 -1
- package/dist/model/searchRecommendRulesParams.d.ts +30 -0
- package/dist/model/searchRecommendRulesParams.d.ts.map +1 -0
- package/dist/model/searchRecommendRulesResponse.d.ts +20 -0
- package/dist/model/searchRecommendRulesResponse.d.ts.map +1 -0
- package/dist/model/snippetResultOption.d.ts +1 -1
- package/dist/model/sortRemainingBy.d.ts +1 -1
- package/dist/model/tagFilters.d.ts +1 -1
- package/dist/model/taskStatus.d.ts +5 -0
- package/dist/model/taskStatus.d.ts.map +1 -0
- package/dist/model/trendingModels.d.ts +1 -1
- package/dist/model/typoTolerance.d.ts +1 -1
- package/dist/recommend.cjs.js +148 -15
- package/dist/recommend.esm.browser.js +148 -13
- package/dist/recommend.esm.node.js +148 -13
- package/dist/recommend.umd.js +2 -2
- package/dist/src/recommendClient.d.ts +62 -14
- package/dist/src/recommendClient.d.ts.map +1 -1
- package/model/anchoring.ts +6 -0
- package/model/aroundRadius.ts +1 -1
- package/model/automaticFacetFilter.ts +21 -0
- package/model/automaticFacetFilters.ts +8 -0
- package/model/baseRecommendRequest.ts +3 -3
- package/model/baseRecommendationRequest.ts +1 -1
- package/model/baseSearchParamsWithoutQuery.ts +25 -25
- package/model/baseSearchResponse.ts +20 -20
- package/model/baseSearchResponseRedirect.ts +1 -1
- package/model/baseTrendingRequest.ts +2 -2
- package/model/clientMethodProps.ts +82 -10
- package/model/condition.ts +22 -0
- package/model/consequence.ts +32 -0
- package/model/consequenceHide.ts +11 -0
- package/model/consequenceParams.ts +9 -0
- package/model/consequenceQuery.ts +8 -0
- package/model/consequenceQueryObject.ts +15 -0
- package/model/deletedAtResponse.ts +16 -0
- package/model/distinct.ts +1 -1
- package/model/edit.ts +17 -0
- package/model/editType.ts +6 -0
- package/model/exactOnSingleWordQuery.ts +1 -1
- package/model/facetFilters.ts +1 -1
- package/model/facetOrdering.ts +2 -2
- package/model/facets.ts +1 -1
- package/model/facetsStats.ts +4 -4
- package/model/getRecommendTaskResponse.ts +7 -0
- package/model/getRecommendationsParams.ts +2 -2
- package/model/highlightResultOption.ts +1 -1
- package/model/ignorePlurals.ts +1 -1
- package/model/index.ts +23 -0
- package/model/indexSettingsAsSearchParams.ts +30 -30
- package/model/indexSettingsAsSearchParamsSemanticSearch.ts +2 -2
- package/model/mode.ts +1 -1
- package/model/numericFilters.ts +1 -1
- package/model/optionalFilters.ts +1 -1
- package/model/params.ts +18 -0
- package/model/promote.ts +6 -0
- package/model/promoteObjectID.ts +16 -0
- package/model/promoteObjectIDs.ts +16 -0
- package/model/queryType.ts +1 -1
- package/model/reRankingApplyFilter.ts +1 -1
- package/model/recommendHit.ts +3 -3
- package/model/recommendModels.ts +7 -0
- package/model/recommendationModels.ts +1 -1
- package/model/redirectRuleIndexMetadata.ts +1 -1
- package/model/redirectRuleIndexMetadataData.ts +1 -1
- package/model/removeStopWords.ts +1 -1
- package/model/removeWordsIfNoResults.ts +1 -1
- package/model/renderingContent.ts +1 -1
- package/model/ruleResponse.ts +34 -0
- package/model/ruleResponseMetadata.ts +8 -0
- package/model/searchParamsQuery.ts +1 -1
- package/model/searchRecommendRulesParams.ts +36 -0
- package/model/searchRecommendRulesResponse.ts +25 -0
- package/model/snippetResultOption.ts +1 -1
- package/model/sortRemainingBy.ts +1 -1
- package/model/tagFilters.ts +1 -1
- package/model/taskStatus.ts +6 -0
- package/model/trendingModels.ts +1 -1
- package/model/typoTolerance.ts +1 -1
- package/package.json +8 -7
|
@@ -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.
|
|
5
|
+
const apiClientVersion = '5.0.0-alpha.75';
|
|
6
6
|
function getDefaultHosts(appId) {
|
|
7
7
|
return [
|
|
8
8
|
{
|
|
@@ -89,8 +89,8 @@ function createRecommendClient({ appId: appIdOption, apiKey: apiKeyOption, authM
|
|
|
89
89
|
*
|
|
90
90
|
* @summary Send requests to the Algolia REST API.
|
|
91
91
|
* @param del - The del object.
|
|
92
|
-
* @param del.path -
|
|
93
|
-
* @param del.parameters - Query parameters to
|
|
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.
|
|
94
94
|
* @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
|
|
95
95
|
*/
|
|
96
96
|
del({ path, parameters }, requestOptions) {
|
|
@@ -108,13 +108,47 @@ function createRecommendClient({ appId: appIdOption, apiKey: apiKeyOption, authM
|
|
|
108
108
|
};
|
|
109
109
|
return transporter.request(request, requestOptions);
|
|
110
110
|
},
|
|
111
|
+
/**
|
|
112
|
+
* Delete a [Recommend rule](https://www.algolia.com/doc/guides/algolia-recommend/how-to/rules/).
|
|
113
|
+
*
|
|
114
|
+
* @summary Delete a Recommend rule.
|
|
115
|
+
* @param deleteRecommendRule - The deleteRecommendRule object.
|
|
116
|
+
* @param deleteRecommendRule.indexName - Index on which to perform the request.
|
|
117
|
+
* @param deleteRecommendRule.model - [Recommend models](https://www.algolia.com/doc/guides/algolia-recommend/overview/#recommend-models).
|
|
118
|
+
* @param deleteRecommendRule.objectID - Unique record (object) identifier.
|
|
119
|
+
* @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
|
|
120
|
+
*/
|
|
121
|
+
deleteRecommendRule({ indexName, model, objectID }, requestOptions) {
|
|
122
|
+
if (!indexName) {
|
|
123
|
+
throw new Error('Parameter `indexName` is required when calling `deleteRecommendRule`.');
|
|
124
|
+
}
|
|
125
|
+
if (!model) {
|
|
126
|
+
throw new Error('Parameter `model` is required when calling `deleteRecommendRule`.');
|
|
127
|
+
}
|
|
128
|
+
if (!objectID) {
|
|
129
|
+
throw new Error('Parameter `objectID` is required when calling `deleteRecommendRule`.');
|
|
130
|
+
}
|
|
131
|
+
const requestPath = '/1/indexes/{indexName}/{model}/recommend/rules/{objectID}'
|
|
132
|
+
.replace('{indexName}', encodeURIComponent(indexName))
|
|
133
|
+
.replace('{model}', encodeURIComponent(model))
|
|
134
|
+
.replace('{objectID}', encodeURIComponent(objectID));
|
|
135
|
+
const headers = {};
|
|
136
|
+
const queryParameters = {};
|
|
137
|
+
const request = {
|
|
138
|
+
method: 'DELETE',
|
|
139
|
+
path: requestPath,
|
|
140
|
+
queryParameters,
|
|
141
|
+
headers,
|
|
142
|
+
};
|
|
143
|
+
return transporter.request(request, requestOptions);
|
|
144
|
+
},
|
|
111
145
|
/**
|
|
112
146
|
* This method allow you to send requests to the Algolia REST API.
|
|
113
147
|
*
|
|
114
148
|
* @summary Send requests to the Algolia REST API.
|
|
115
149
|
* @param get - The get object.
|
|
116
|
-
* @param get.path -
|
|
117
|
-
* @param get.parameters - Query parameters to
|
|
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.
|
|
118
152
|
* @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
|
|
119
153
|
*/
|
|
120
154
|
get({ path, parameters }, requestOptions) {
|
|
@@ -133,9 +167,77 @@ function createRecommendClient({ appId: appIdOption, apiKey: apiKeyOption, authM
|
|
|
133
167
|
return transporter.request(request, requestOptions);
|
|
134
168
|
},
|
|
135
169
|
/**
|
|
136
|
-
*
|
|
170
|
+
* Return a [Recommend rule](https://www.algolia.com/doc/guides/algolia-recommend/how-to/rules/).
|
|
137
171
|
*
|
|
138
|
-
* @summary Get
|
|
172
|
+
* @summary Get a Recommend rule.
|
|
173
|
+
* @param getRecommendRule - The getRecommendRule object.
|
|
174
|
+
* @param getRecommendRule.indexName - Index on which to perform the request.
|
|
175
|
+
* @param getRecommendRule.model - [Recommend models](https://www.algolia.com/doc/guides/algolia-recommend/overview/#recommend-models).
|
|
176
|
+
* @param getRecommendRule.objectID - Unique record (object) identifier.
|
|
177
|
+
* @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
|
|
178
|
+
*/
|
|
179
|
+
getRecommendRule({ indexName, model, objectID }, requestOptions) {
|
|
180
|
+
if (!indexName) {
|
|
181
|
+
throw new Error('Parameter `indexName` is required when calling `getRecommendRule`.');
|
|
182
|
+
}
|
|
183
|
+
if (!model) {
|
|
184
|
+
throw new Error('Parameter `model` is required when calling `getRecommendRule`.');
|
|
185
|
+
}
|
|
186
|
+
if (!objectID) {
|
|
187
|
+
throw new Error('Parameter `objectID` is required when calling `getRecommendRule`.');
|
|
188
|
+
}
|
|
189
|
+
const requestPath = '/1/indexes/{indexName}/{model}/recommend/rules/{objectID}'
|
|
190
|
+
.replace('{indexName}', encodeURIComponent(indexName))
|
|
191
|
+
.replace('{model}', encodeURIComponent(model))
|
|
192
|
+
.replace('{objectID}', encodeURIComponent(objectID));
|
|
193
|
+
const headers = {};
|
|
194
|
+
const queryParameters = {};
|
|
195
|
+
const request = {
|
|
196
|
+
method: 'GET',
|
|
197
|
+
path: requestPath,
|
|
198
|
+
queryParameters,
|
|
199
|
+
headers,
|
|
200
|
+
};
|
|
201
|
+
return transporter.request(request, requestOptions);
|
|
202
|
+
},
|
|
203
|
+
/**
|
|
204
|
+
* Some operations, such as deleting a Recommend rule, will respond with a `taskID` value. Use this value here to check the status of that task.
|
|
205
|
+
*
|
|
206
|
+
* @summary Get a Recommend task\'s status.
|
|
207
|
+
* @param getRecommendStatus - The getRecommendStatus object.
|
|
208
|
+
* @param getRecommendStatus.indexName - Index on which to perform the request.
|
|
209
|
+
* @param getRecommendStatus.model - [Recommend models](https://www.algolia.com/doc/guides/algolia-recommend/overview/#recommend-models).
|
|
210
|
+
* @param getRecommendStatus.taskID - Unique identifier of a task. Numeric value (up to 64bits).
|
|
211
|
+
* @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
|
|
212
|
+
*/
|
|
213
|
+
getRecommendStatus({ indexName, model, taskID }, requestOptions) {
|
|
214
|
+
if (!indexName) {
|
|
215
|
+
throw new Error('Parameter `indexName` is required when calling `getRecommendStatus`.');
|
|
216
|
+
}
|
|
217
|
+
if (!model) {
|
|
218
|
+
throw new Error('Parameter `model` is required when calling `getRecommendStatus`.');
|
|
219
|
+
}
|
|
220
|
+
if (!taskID) {
|
|
221
|
+
throw new Error('Parameter `taskID` is required when calling `getRecommendStatus`.');
|
|
222
|
+
}
|
|
223
|
+
const requestPath = '/1/indexes/{indexName}/{model}/task/{taskID}'
|
|
224
|
+
.replace('{indexName}', encodeURIComponent(indexName))
|
|
225
|
+
.replace('{model}', encodeURIComponent(model))
|
|
226
|
+
.replace('{taskID}', encodeURIComponent(taskID));
|
|
227
|
+
const headers = {};
|
|
228
|
+
const queryParameters = {};
|
|
229
|
+
const request = {
|
|
230
|
+
method: 'GET',
|
|
231
|
+
path: requestPath,
|
|
232
|
+
queryParameters,
|
|
233
|
+
headers,
|
|
234
|
+
};
|
|
235
|
+
return transporter.request(request, requestOptions);
|
|
236
|
+
},
|
|
237
|
+
/**
|
|
238
|
+
* Returns results from either recommendation or trending models: - **Recommendations** are provided by the [Related Products](https://www.algolia.com/doc/guides/algolia-recommend/overview/#related-products-and-related-content) and [Frequently Bought Together](https://www.algolia.com/doc/guides/algolia-recommend/overview/#frequently-bought-together) models - **Trending** models are [Trending Items and Trending Facet Values](https://www.algolia.com/doc/guides/algolia-recommend/overview/#trending-items-and-trending-facet-values).
|
|
239
|
+
*
|
|
240
|
+
* @summary Get recommendations and trending items.
|
|
139
241
|
* @param getRecommendationsParams - The getRecommendationsParams object.
|
|
140
242
|
* @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
|
|
141
243
|
*/
|
|
@@ -165,9 +267,9 @@ function createRecommendClient({ appId: appIdOption, apiKey: apiKeyOption, authM
|
|
|
165
267
|
*
|
|
166
268
|
* @summary Send requests to the Algolia REST API.
|
|
167
269
|
* @param post - The post object.
|
|
168
|
-
* @param post.path -
|
|
169
|
-
* @param post.parameters - Query parameters to
|
|
170
|
-
* @param post.body -
|
|
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.
|
|
171
273
|
* @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
|
|
172
274
|
*/
|
|
173
275
|
post({ path, parameters, body }, requestOptions) {
|
|
@@ -191,9 +293,9 @@ function createRecommendClient({ appId: appIdOption, apiKey: apiKeyOption, authM
|
|
|
191
293
|
*
|
|
192
294
|
* @summary Send requests to the Algolia REST API.
|
|
193
295
|
* @param put - The put object.
|
|
194
|
-
* @param put.path -
|
|
195
|
-
* @param put.parameters - Query parameters to
|
|
196
|
-
* @param put.body -
|
|
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.
|
|
197
299
|
* @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
|
|
198
300
|
*/
|
|
199
301
|
put({ path, parameters, body }, requestOptions) {
|
|
@@ -212,6 +314,39 @@ function createRecommendClient({ appId: appIdOption, apiKey: apiKeyOption, authM
|
|
|
212
314
|
};
|
|
213
315
|
return transporter.request(request, requestOptions);
|
|
214
316
|
},
|
|
317
|
+
/**
|
|
318
|
+
* List [Recommend rules](https://www.algolia.com/doc/guides/algolia-recommend/how-to/rules/).
|
|
319
|
+
*
|
|
320
|
+
* @summary List Recommend rules.
|
|
321
|
+
* @param searchRecommendRules - The searchRecommendRules object.
|
|
322
|
+
* @param searchRecommendRules.indexName - Index on which to perform the request.
|
|
323
|
+
* @param searchRecommendRules.model - [Recommend models](https://www.algolia.com/doc/guides/algolia-recommend/overview/#recommend-models).
|
|
324
|
+
* @param searchRecommendRules.searchRecommendRulesParams - The searchRecommendRulesParams object.
|
|
325
|
+
* @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
|
|
326
|
+
*/
|
|
327
|
+
searchRecommendRules({ indexName, model, searchRecommendRulesParams, }, requestOptions) {
|
|
328
|
+
if (!indexName) {
|
|
329
|
+
throw new Error('Parameter `indexName` is required when calling `searchRecommendRules`.');
|
|
330
|
+
}
|
|
331
|
+
if (!model) {
|
|
332
|
+
throw new Error('Parameter `model` is required when calling `searchRecommendRules`.');
|
|
333
|
+
}
|
|
334
|
+
const requestPath = '/1/indexes/{indexName}/{model}/recommend/rules/search'
|
|
335
|
+
.replace('{indexName}', encodeURIComponent(indexName))
|
|
336
|
+
.replace('{model}', encodeURIComponent(model));
|
|
337
|
+
const headers = {};
|
|
338
|
+
const queryParameters = {};
|
|
339
|
+
const request = {
|
|
340
|
+
method: 'POST',
|
|
341
|
+
path: requestPath,
|
|
342
|
+
queryParameters,
|
|
343
|
+
headers,
|
|
344
|
+
data: searchRecommendRulesParams ? searchRecommendRulesParams : {},
|
|
345
|
+
useReadTransporter: true,
|
|
346
|
+
cacheable: true,
|
|
347
|
+
};
|
|
348
|
+
return transporter.request(request, requestOptions);
|
|
349
|
+
},
|
|
215
350
|
};
|
|
216
351
|
}
|
|
217
352
|
|
package/dist/recommend.umd.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
/*! recommend.umd.js | 5.0.0-alpha.
|
|
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 s(){return void 0===t&&(t=e.localStorage||window.localStorage),t}function a(){return JSON.parse(s().getItem(r)||"{}")}return{get:(e,t,r={miss:()=>Promise.resolve()})=>Promise.resolve().then((()=>{const r=JSON.stringify(e),s=a()[r];return Promise.all([s||t(),void 0!==s])})).then((([e,t])=>Promise.all([e,t||r.miss(e)]))).then((([e])=>e)),set:(e,t)=>Promise.resolve().then((()=>{const o=a();return o[JSON.stringify(e)]=t,s().setItem(r,JSON.stringify(o)),t})),delete:e=>Promise.resolve().then((()=>{const t=a();delete t[JSON.stringify(e)],s().setItem(r,JSON.stringify(t))})),clear:()=>Promise.resolve().then((()=>{s().removeItem(r)}))}}function r(e){const t=[...e.caches],s=t.shift();return void 0===s?{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,a,o={miss:()=>Promise.resolve()})=>s.get(e,a,o).catch((()=>r({caches:t}).get(e,a,o))),set:(e,a)=>s.set(e,a).catch((()=>r({caches:t}).set(e,a))),delete:e=>s.delete(e).catch((()=>r({caches:t}).delete(e))),clear:()=>s.clear().catch((()=>r({caches:t}).clear()))}}function s(e={serializable:!0}){let t={};return{get(r,s,a={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=s();return n.then((e=>a.miss(e))).then((()=>n))},set:(r,s)=>(t[JSON.stringify(r)]=e.serializable?JSON.stringify(s):s,Promise.resolve(s)),delete:e=>(delete t[JSON.stringify(e)],Promise.resolve()),clear:()=>(t={},Promise.resolve())}}const a=12e4;function o(e,t="up"){const r=Date.now();return{...e,status:t,lastUpdate:r,isUp:function(){return"up"===t||Date.now()-r>a},isTimedOut:function(){return"timed out"===t&&Date.now()-r<=a}}}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 s=r.call(e,t||"default");if("object"!=typeof s)return s;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 u extends c{constructor(e){super("Unreachable hosts - your application id may be incorrect. If the error persists, contact support@algolia.com.",e,"RetryError")}}class l extends c{constructor(e,t,r,s="ApiError"){super(e,r,s),n(this,"status",void 0),this.status=t}}class d extends i{constructor(e,t){super(e,"DeserializationError"),n(this,"response",void 0),this.response=t}}class m extends l{constructor(e,t,r,s){super(e,t,s,"DetailedApiError"),n(this,"error",void 0),this.error=r}}function h(e,t,r){const s=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 a=`${e.protocol}://${e.url}/${"/"===t.charAt(0)?t.substr(1):t}`;return s.length&&(a+=`?${s}`),a}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:s,algoliaAgent:a,timeouts:n,requester:i,requestsCache:c,responsesCache:g}){async function f(c,g,f=!0){const y=[],P=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),v=function(e,t,r){const s={Accept:"application/json",...e,...t,...r},a={};return Object.keys(s).forEach((e=>{const t=s[e];a[e.toLowerCase()]=t})),a}(r,c.headers,g.headers),w="GET"===c.method?{...c.data,...g.data}:{},b={...s,...c.queryParameters,...w};if(a.value&&(b["x-algolia-agent"]=a.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 q=0;const O=async(e,r)=>{const s=e.pop();if(void 0===s)throw new u(function(e){return e.map((e=>p(e)))}(y));let a=g.timeout;void 0===a&&(a=f?n.read:n.write);const w={data:P,headers:v,method:c.method,url:h(s,c.path,b),connectTimeout:r(q,n.connect),responseTimeout:r(q,a)},T=t=>{const r={request:w,response:t,host:s,triesLeft:e.length};return y.push(r),r},S=await i.send(w);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)}(S)){const a=T(S);return S.isTimedOut&&q++,console.log("Retryable failure",p(a)),await t.set(s,o(s,S.isTimedOut?"timed out":"down")),O(e,r)}if(function({status:e}){return 2==~~(e/100)}(S))return function(e){try{return JSON.parse(e.content)}catch(t){throw new d(t.message,e)}}(S);throw T(S),function({content:e,status:t},r){try{const s=JSON.parse(e);return"error"in s?new m(s.message,t,s.error,r):new l(s.message,t,r)}catch(e){}return new l(e,t,r)}(S,y)},T=e.filter((e=>"readWrite"===e.accept||(f?"read"===e.accept:"write"===e.accept))),S=await async function(e){const r=await Promise.all(e.map((e=>t.get(e,(()=>Promise.resolve(o(e))))))),s=r.filter((e=>e.isUp())),a=r.filter((e=>e.isTimedOut())),n=[...s,...a];return{hosts:n.length>0?n:e,getTimeout:(e,t)=>(0===a.length&&0===e?1:a.length+3+e)*t}}(T);return O([...S.hosts].reverse(),S.getTimeout)}return{hostsCache:t,requester:i,timeouts:n,algoliaAgent:a,baseHeaders:r,baseQueryParameters:s,hosts:e,request:function(e,t={}){const a=e.useReadTransporter||"GET"===e.method;if(!a)return f(e,t,a);const o=()=>f(e,t);if(!0!==(t.cacheable||e.cacheable))return o();const n={request:e,requestOptions:t,transporter:{queryParameters:s,headers:r}};return g.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=>g.set(n,e)})},requestsCache:c,responsesCache:g}}function f({algoliaAgents:e,client:t,version:r}){const s=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=>s.add(e))),s}const y="5.0.0-alpha.73";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 s=Math.floor(Math.random()*(r+1)),a=e[r];t[r]=e[s],t[s]=a}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,a,o){if(!e||"string"!=typeof e)throw new Error("`appId` is missing.");if(!a||"string"!=typeof a)throw new Error("`apiKey` is missing.");return function({appId:e,apiKey:t,authMode:r,algoliaAgents:s,...a}){const o=function(e,t,r="WithinHeaders"){const s={"x-algolia-api-key":t,"x-algolia-application-id":e};return{headers:()=>"WithinHeaders"===r?s:{},queryParameters:()=>"WithinQueryParameters"===r?s:{}}}(e,t,r),n=g({hosts:P(e),...a,algoliaAgent:f({algoliaAgents:s,client:"Recommend",version:y}),baseHeaders:{"content-type":"text/plain",...o.headers(),...a.baseHeaders},baseQueryParameters:{...o.queryParameters(),...a.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 s={method:"DELETE",path:"/1{path}".replace("{path}",e),queryParameters:t||{},headers:{}};return n.request(s,r)},get({path:e,parameters:t},r){if(!e)throw new Error("Parameter `path` is required when calling `get`.");const s={method:"GET",path:"/1{path}".replace("{path}",e),queryParameters:t||{},headers:{}};return n.request(s,r)},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},s){if(!e)throw new Error("Parameter `path` is required when calling `post`.");const a={method:"POST",path:"/1{path}".replace("{path}",e),queryParameters:t||{},headers:{},data:r||{}};return n.request(a,s)},put({path:e,parameters:t,body:r},s){if(!e)throw new Error("Parameter `path` is required when calling `put`.");const a={method:"PUT",path:"/1{path}".replace("{path}",e),queryParameters:t||{},headers:{},data:r||{}};return n.request(a,s)}}}({appId:e,apiKey:a,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 s=(e,s)=>setTimeout((()=>{r.abort(),t({status:0,content:s,isTimedOut:!0})}),e),a=s(e.connectTimeout,"Connection timeout");let o;r.onreadystatechange=()=>{r.readyState>r.OPENED&&void 0===o&&(clearTimeout(a),o=s(e.responseTimeout,"Socket timeout"))},r.onerror=()=>{0===r.status&&(clearTimeout(a),clearTimeout(o),t({content:r.responseText||"Network request failed",status:r.status,isTimedOut:!1}))},r.onload=()=>{clearTimeout(a),clearTimeout(o),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:r({caches:[t({key:`${y}-${e}`}),s()]}),...o})}}));
|
|
1
|
+
/*! recommend.umd.js | 5.0.0-alpha.75 | © 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.75";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,8 +1,12 @@
|
|
|
1
1
|
import type { CreateClientOptions, RequestOptions } from '@algolia/client-common';
|
|
2
|
-
import type { DelProps, GetProps, PostProps, PutProps } from '../model/clientMethodProps';
|
|
2
|
+
import type { DelProps, DeleteRecommendRuleProps, GetProps, GetRecommendRuleProps, GetRecommendStatusProps, PostProps, PutProps, SearchRecommendRulesProps } from '../model/clientMethodProps';
|
|
3
|
+
import type { DeletedAtResponse } from '../model/deletedAtResponse';
|
|
4
|
+
import type { GetRecommendTaskResponse } from '../model/getRecommendTaskResponse';
|
|
3
5
|
import type { GetRecommendationsParams } from '../model/getRecommendationsParams';
|
|
4
6
|
import type { GetRecommendationsResponse } from '../model/getRecommendationsResponse';
|
|
5
|
-
|
|
7
|
+
import type { RuleResponse } from '../model/ruleResponse';
|
|
8
|
+
import type { SearchRecommendRulesResponse } from '../model/searchRecommendRulesResponse';
|
|
9
|
+
export declare const apiClientVersion = "5.0.0-alpha.75";
|
|
6
10
|
export declare function createRecommendClient({ appId: appIdOption, apiKey: apiKeyOption, authMode, algoliaAgents, ...options }: CreateClientOptions): {
|
|
7
11
|
transporter: import("@algolia/client-common").Transporter;
|
|
8
12
|
/**
|
|
@@ -29,25 +33,58 @@ export declare function createRecommendClient({ appId: appIdOption, apiKey: apiK
|
|
|
29
33
|
*
|
|
30
34
|
* @summary Send requests to the Algolia REST API.
|
|
31
35
|
* @param del - The del object.
|
|
32
|
-
* @param del.path -
|
|
33
|
-
* @param del.parameters - Query parameters to
|
|
36
|
+
* @param del.path - Path of the endpoint, anything after \"/1\" must be specified.
|
|
37
|
+
* @param del.parameters - Query parameters to apply to the current query.
|
|
34
38
|
* @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
|
|
35
39
|
*/
|
|
36
40
|
del({ path, parameters }: DelProps, requestOptions?: RequestOptions): Promise<Record<string, any>>;
|
|
41
|
+
/**
|
|
42
|
+
* Delete a [Recommend rule](https://www.algolia.com/doc/guides/algolia-recommend/how-to/rules/).
|
|
43
|
+
*
|
|
44
|
+
* @summary Delete a Recommend rule.
|
|
45
|
+
* @param deleteRecommendRule - The deleteRecommendRule object.
|
|
46
|
+
* @param deleteRecommendRule.indexName - Index on which to perform the request.
|
|
47
|
+
* @param deleteRecommendRule.model - [Recommend models](https://www.algolia.com/doc/guides/algolia-recommend/overview/#recommend-models).
|
|
48
|
+
* @param deleteRecommendRule.objectID - Unique record (object) identifier.
|
|
49
|
+
* @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
|
|
50
|
+
*/
|
|
51
|
+
deleteRecommendRule({ indexName, model, objectID }: DeleteRecommendRuleProps, requestOptions?: RequestOptions): Promise<DeletedAtResponse>;
|
|
37
52
|
/**
|
|
38
53
|
* This method allow you to send requests to the Algolia REST API.
|
|
39
54
|
*
|
|
40
55
|
* @summary Send requests to the Algolia REST API.
|
|
41
56
|
* @param get - The get object.
|
|
42
|
-
* @param get.path -
|
|
43
|
-
* @param get.parameters - Query parameters to
|
|
57
|
+
* @param get.path - Path of the endpoint, anything after \"/1\" must be specified.
|
|
58
|
+
* @param get.parameters - Query parameters to apply to the current query.
|
|
44
59
|
* @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
|
|
45
60
|
*/
|
|
46
61
|
get({ path, parameters }: GetProps, requestOptions?: RequestOptions): Promise<Record<string, any>>;
|
|
47
62
|
/**
|
|
48
|
-
*
|
|
63
|
+
* Return a [Recommend rule](https://www.algolia.com/doc/guides/algolia-recommend/how-to/rules/).
|
|
64
|
+
*
|
|
65
|
+
* @summary Get a Recommend rule.
|
|
66
|
+
* @param getRecommendRule - The getRecommendRule object.
|
|
67
|
+
* @param getRecommendRule.indexName - Index on which to perform the request.
|
|
68
|
+
* @param getRecommendRule.model - [Recommend models](https://www.algolia.com/doc/guides/algolia-recommend/overview/#recommend-models).
|
|
69
|
+
* @param getRecommendRule.objectID - Unique record (object) identifier.
|
|
70
|
+
* @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
|
|
71
|
+
*/
|
|
72
|
+
getRecommendRule({ indexName, model, objectID }: GetRecommendRuleProps, requestOptions?: RequestOptions): Promise<RuleResponse>;
|
|
73
|
+
/**
|
|
74
|
+
* Some operations, such as deleting a Recommend rule, will respond with a `taskID` value. Use this value here to check the status of that task.
|
|
49
75
|
*
|
|
50
|
-
* @summary Get
|
|
76
|
+
* @summary Get a Recommend task\'s status.
|
|
77
|
+
* @param getRecommendStatus - The getRecommendStatus object.
|
|
78
|
+
* @param getRecommendStatus.indexName - Index on which to perform the request.
|
|
79
|
+
* @param getRecommendStatus.model - [Recommend models](https://www.algolia.com/doc/guides/algolia-recommend/overview/#recommend-models).
|
|
80
|
+
* @param getRecommendStatus.taskID - Unique identifier of a task. Numeric value (up to 64bits).
|
|
81
|
+
* @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
|
|
82
|
+
*/
|
|
83
|
+
getRecommendStatus({ indexName, model, taskID }: GetRecommendStatusProps, requestOptions?: RequestOptions): Promise<GetRecommendTaskResponse>;
|
|
84
|
+
/**
|
|
85
|
+
* Returns results from either recommendation or trending models: - **Recommendations** are provided by the [Related Products](https://www.algolia.com/doc/guides/algolia-recommend/overview/#related-products-and-related-content) and [Frequently Bought Together](https://www.algolia.com/doc/guides/algolia-recommend/overview/#frequently-bought-together) models - **Trending** models are [Trending Items and Trending Facet Values](https://www.algolia.com/doc/guides/algolia-recommend/overview/#trending-items-and-trending-facet-values).
|
|
86
|
+
*
|
|
87
|
+
* @summary Get recommendations and trending items.
|
|
51
88
|
* @param getRecommendationsParams - The getRecommendationsParams object.
|
|
52
89
|
* @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
|
|
53
90
|
*/
|
|
@@ -57,9 +94,9 @@ export declare function createRecommendClient({ appId: appIdOption, apiKey: apiK
|
|
|
57
94
|
*
|
|
58
95
|
* @summary Send requests to the Algolia REST API.
|
|
59
96
|
* @param post - The post object.
|
|
60
|
-
* @param post.path -
|
|
61
|
-
* @param post.parameters - Query parameters to
|
|
62
|
-
* @param post.body -
|
|
97
|
+
* @param post.path - Path of the endpoint, anything after \"/1\" must be specified.
|
|
98
|
+
* @param post.parameters - Query parameters to apply to the current query.
|
|
99
|
+
* @param post.body - Parameters to send with the custom request.
|
|
63
100
|
* @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
|
|
64
101
|
*/
|
|
65
102
|
post({ path, parameters, body }: PostProps, requestOptions?: RequestOptions): Promise<Record<string, any>>;
|
|
@@ -68,12 +105,23 @@ export declare function createRecommendClient({ appId: appIdOption, apiKey: apiK
|
|
|
68
105
|
*
|
|
69
106
|
* @summary Send requests to the Algolia REST API.
|
|
70
107
|
* @param put - The put object.
|
|
71
|
-
* @param put.path -
|
|
72
|
-
* @param put.parameters - Query parameters to
|
|
73
|
-
* @param put.body -
|
|
108
|
+
* @param put.path - Path of the endpoint, anything after \"/1\" must be specified.
|
|
109
|
+
* @param put.parameters - Query parameters to apply to the current query.
|
|
110
|
+
* @param put.body - Parameters to send with the custom request.
|
|
74
111
|
* @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
|
|
75
112
|
*/
|
|
76
113
|
put({ path, parameters, body }: PutProps, requestOptions?: RequestOptions): Promise<Record<string, any>>;
|
|
114
|
+
/**
|
|
115
|
+
* List [Recommend rules](https://www.algolia.com/doc/guides/algolia-recommend/how-to/rules/).
|
|
116
|
+
*
|
|
117
|
+
* @summary List Recommend rules.
|
|
118
|
+
* @param searchRecommendRules - The searchRecommendRules object.
|
|
119
|
+
* @param searchRecommendRules.indexName - Index on which to perform the request.
|
|
120
|
+
* @param searchRecommendRules.model - [Recommend models](https://www.algolia.com/doc/guides/algolia-recommend/overview/#recommend-models).
|
|
121
|
+
* @param searchRecommendRules.searchRecommendRulesParams - The searchRecommendRulesParams object.
|
|
122
|
+
* @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
|
|
123
|
+
*/
|
|
124
|
+
searchRecommendRules({ indexName, model, searchRecommendRulesParams, }: SearchRecommendRulesProps, requestOptions?: RequestOptions): Promise<SearchRecommendRulesResponse>;
|
|
77
125
|
};
|
|
78
126
|
/**
|
|
79
127
|
* The client type.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"recommendClient.d.ts","sourceRoot":"","sources":["../../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,
|
|
1
|
+
{"version":3,"file":"recommendClient.d.ts","sourceRoot":"","sources":["../../src/recommendClient.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EACV,mBAAmB,EAInB,cAAc,EAEf,MAAM,wBAAwB,CAAC;AAEhC,OAAO,KAAK,EACV,QAAQ,EACR,wBAAwB,EACxB,QAAQ,EACR,qBAAqB,EACrB,uBAAuB,EACvB,SAAS,EACT,QAAQ,EACR,yBAAyB,EAC1B,MAAM,4BAA4B,CAAC;AACpC,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,4BAA4B,CAAC;AACpE,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,mCAAmC,CAAC;AAClF,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,mCAAmC,CAAC;AAClF,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,qCAAqC,CAAC;AACtF,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAC1D,OAAO,KAAK,EAAE,4BAA4B,EAAE,MAAM,uCAAuC,CAAC;AAE1F,eAAO,MAAM,gBAAgB,mBAAmB,CAAC;AAsCjD,wBAAgB,qBAAqB,CAAC,EACpC,KAAK,EAAE,WAAW,EAClB,MAAM,EAAE,YAAY,EACpB,QAAQ,EACR,aAAa,EACb,GAAG,OAAO,EACX,EAAE,mBAAmB;;IAwBlB;;OAEG;;IAGH;;OAEG;kBACW,QAAQ,IAAI,CAAC;IAO3B;;OAEG;;IAKH;;;;;OAKG;6BACsB,MAAM,YAAY,MAAM,GAAG,IAAI;IAIxD;;;;;;;;OAQG;8BAEqB,QAAQ,mBACb,cAAc,GAC9B,QAAQ,OAAO,MAAM,EAAE,GAAG,CAAC,CAAC;IAmB/B;;;;;;;;;OASG;wDAE+B,wBAAwB,mBACvC,cAAc,GAC9B,QAAQ,iBAAiB,CAAC;IAqC7B;;;;;;;;OAQG;8BAEqB,QAAQ,mBACb,cAAc,GAC9B,QAAQ,OAAO,MAAM,EAAE,GAAG,CAAC,CAAC;IAmB/B;;;;;;;;;OASG;qDAE+B,qBAAqB,mBACpC,cAAc,GAC9B,QAAQ,YAAY,CAAC;IAqCxB;;;;;;;;;OASG;qDAE6B,uBAAuB,mBACpC,cAAc,GAC9B,QAAQ,wBAAwB,CAAC;IAoCpC;;;;;;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;IAoB/B;;;;;;;;;OASG;4EAME,yBAAyB,mBACX,cAAc,GAC9B,QAAQ,4BAA4B,CAAC;EAiC3C;AAED;;GAEG;AACH,MAAM,MAAM,eAAe,GAAG,UAAU,CAAC,OAAO,qBAAqB,CAAC,CAAC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
// 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.
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Whether the pattern parameter matches the beginning (`startsWith`) or end (`endsWith`) of the query string, is an exact match (`is`), or a partial match (`contains`).
|
|
5
|
+
*/
|
|
6
|
+
export type Anchoring = 'contains' | 'endsWith' | 'is' | 'startsWith';
|
package/model/aroundRadius.ts
CHANGED
|
@@ -3,6 +3,6 @@
|
|
|
3
3
|
import type { AroundRadiusAll } from './aroundRadiusAll';
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
|
-
*
|
|
6
|
+
* [Maximum radius](https://www.algolia.com/doc/guides/managing-results/refine-results/geolocation/#increase-the-search-radius) for a geographical search (in meters).
|
|
7
7
|
*/
|
|
8
8
|
export type AroundRadius = AroundRadiusAll | number;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
// 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.
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Automatic facet Filter.
|
|
5
|
+
*/
|
|
6
|
+
export type AutomaticFacetFilter = {
|
|
7
|
+
/**
|
|
8
|
+
* Attribute to filter on. This must match a facet placeholder in the Rule\'s pattern.
|
|
9
|
+
*/
|
|
10
|
+
facet: string;
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Score for the filter. Typically used for optional or disjunctive filters.
|
|
14
|
+
*/
|
|
15
|
+
score?: number;
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Whether the filter is disjunctive (true) or conjunctive (false).
|
|
19
|
+
*/
|
|
20
|
+
disjunctive?: boolean;
|
|
21
|
+
};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
// 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.
|
|
2
|
+
|
|
3
|
+
import type { AutomaticFacetFilter } from './automaticFacetFilter';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Names of facets to which automatic filtering must be applied; they must match the facet name of a facet value placeholder in the query pattern.
|
|
7
|
+
*/
|
|
8
|
+
export type AutomaticFacetFilters = AutomaticFacetFilter[] | string[];
|
|
@@ -4,17 +4,17 @@ import type { SearchParamsObject } from './searchParamsObject';
|
|
|
4
4
|
|
|
5
5
|
export type BaseRecommendRequest = {
|
|
6
6
|
/**
|
|
7
|
-
*
|
|
7
|
+
* Algolia index name.
|
|
8
8
|
*/
|
|
9
9
|
indexName: string;
|
|
10
10
|
|
|
11
11
|
/**
|
|
12
|
-
*
|
|
12
|
+
* Recommendations with a confidence score lower than `threshold` won\'t appear in results. > **Note**: Each recommendation has a confidence score of 0 to 100. The closer the score is to 100, the more relevant the recommendations are.
|
|
13
13
|
*/
|
|
14
14
|
threshold: number;
|
|
15
15
|
|
|
16
16
|
/**
|
|
17
|
-
*
|
|
17
|
+
* Maximum number of recommendations to retrieve. If 0, all recommendations will be returned.
|
|
18
18
|
*/
|
|
19
19
|
maxRecommendations?: number;
|
|
20
20
|
|