@algolia/client-personalization 5.0.0-alpha.7 → 5.0.0-alpha.71
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/builds/browser.d.ts +5 -5
- package/dist/builds/browser.d.ts.map +1 -1
- package/dist/builds/node.d.ts +5 -5
- package/dist/builds/node.d.ts.map +1 -1
- package/dist/client-personalization.cjs.js +283 -285
- package/dist/client-personalization.esm.browser.js +466 -516
- package/dist/client-personalization.esm.node.js +283 -285
- package/dist/client-personalization.umd.js +2 -2
- package/dist/model/clientMethodProps.d.ts +78 -78
- package/dist/model/clientMethodProps.d.ts.map +1 -1
- package/dist/model/deleteUserProfileResponse.d.ts +10 -10
- package/dist/model/deleteUserProfileResponse.d.ts.map +1 -1
- package/dist/model/errorBase.d.ts +6 -6
- package/dist/model/errorBase.d.ts.map +1 -1
- package/dist/model/eventScoring.d.ts +14 -14
- package/dist/model/eventScoring.d.ts.map +1 -1
- package/dist/model/facetScoring.d.ts +10 -10
- package/dist/model/facetScoring.d.ts.map +1 -1
- package/dist/model/getUserTokenResponse.d.ts +14 -14
- package/dist/model/getUserTokenResponse.d.ts.map +1 -1
- package/dist/model/index.d.ts +8 -8
- package/dist/model/index.d.ts.map +1 -1
- package/dist/model/personalizationStrategyParams.d.ts +16 -16
- package/dist/model/personalizationStrategyParams.d.ts.map +1 -1
- package/dist/model/setPersonalizationStrategyResponse.d.ts +6 -6
- package/dist/model/setPersonalizationStrategyResponse.d.ts.map +1 -1
- package/dist/src/personalizationClient.d.ts +112 -112
- package/dist/src/personalizationClient.d.ts.map +1 -1
- package/model/clientMethodProps.ts +1 -1
- package/model/deleteUserProfileResponse.ts +1 -1
- package/model/errorBase.ts +1 -1
- package/model/eventScoring.ts +1 -1
- package/model/facetScoring.ts +1 -1
- package/model/getUserTokenResponse.ts +1 -1
- package/model/index.ts +1 -1
- package/model/personalizationStrategyParams.ts +1 -1
- package/model/setPersonalizationStrategyResponse.ts +1 -1
- package/package.json +31 -13
|
@@ -7,31 +7,25 @@ function createAuth(appId, apiKey, authMode = 'WithinHeaders') {
|
|
|
7
7
|
headers() {
|
|
8
8
|
return authMode === 'WithinHeaders' ? credentials : {};
|
|
9
9
|
},
|
|
10
|
-
|
|
11
10
|
queryParameters() {
|
|
12
11
|
return authMode === 'WithinQueryParameters' ? credentials : {};
|
|
13
12
|
}
|
|
14
|
-
|
|
15
13
|
};
|
|
16
14
|
}
|
|
17
15
|
|
|
18
16
|
function createBrowserLocalStorageCache(options) {
|
|
19
|
-
let storage;
|
|
20
|
-
|
|
17
|
+
let storage;
|
|
18
|
+
// We've changed the namespace to avoid conflicts with v4, as this version is a huge breaking change
|
|
21
19
|
const namespaceKey = `algolia-client-js-${options.key}`;
|
|
22
|
-
|
|
23
20
|
function getStorage() {
|
|
24
21
|
if (storage === undefined) {
|
|
25
22
|
storage = options.localStorage || window.localStorage;
|
|
26
23
|
}
|
|
27
|
-
|
|
28
24
|
return storage;
|
|
29
25
|
}
|
|
30
|
-
|
|
31
26
|
function getNamespace() {
|
|
32
27
|
return JSON.parse(getStorage().getItem(namespaceKey) || '{}');
|
|
33
28
|
}
|
|
34
|
-
|
|
35
29
|
return {
|
|
36
30
|
get(key, defaultValue, events = {
|
|
37
31
|
miss: () => Promise.resolve()
|
|
@@ -44,7 +38,6 @@ function createBrowserLocalStorageCache(options) {
|
|
|
44
38
|
return Promise.all([value, exists || events.miss(value)]);
|
|
45
39
|
}).then(([value]) => value);
|
|
46
40
|
},
|
|
47
|
-
|
|
48
41
|
set(key, value) {
|
|
49
42
|
return Promise.resolve().then(() => {
|
|
50
43
|
const namespace = getNamespace();
|
|
@@ -53,7 +46,6 @@ function createBrowserLocalStorageCache(options) {
|
|
|
53
46
|
return value;
|
|
54
47
|
});
|
|
55
48
|
},
|
|
56
|
-
|
|
57
49
|
delete(key) {
|
|
58
50
|
return Promise.resolve().then(() => {
|
|
59
51
|
const namespace = getNamespace();
|
|
@@ -61,13 +53,11 @@ function createBrowserLocalStorageCache(options) {
|
|
|
61
53
|
getStorage().setItem(namespaceKey, JSON.stringify(namespace));
|
|
62
54
|
});
|
|
63
55
|
},
|
|
64
|
-
|
|
65
56
|
clear() {
|
|
66
57
|
return Promise.resolve().then(() => {
|
|
67
58
|
getStorage().removeItem(namespaceKey);
|
|
68
59
|
});
|
|
69
60
|
}
|
|
70
|
-
|
|
71
61
|
};
|
|
72
62
|
}
|
|
73
63
|
|
|
@@ -79,30 +69,24 @@ function createNullCache() {
|
|
|
79
69
|
const value = defaultValue();
|
|
80
70
|
return value.then(result => Promise.all([result, events.miss(result)])).then(([result]) => result);
|
|
81
71
|
},
|
|
82
|
-
|
|
83
72
|
set(_key, value) {
|
|
84
73
|
return Promise.resolve(value);
|
|
85
74
|
},
|
|
86
|
-
|
|
87
75
|
delete(_key) {
|
|
88
76
|
return Promise.resolve();
|
|
89
77
|
},
|
|
90
|
-
|
|
91
78
|
clear() {
|
|
92
79
|
return Promise.resolve();
|
|
93
80
|
}
|
|
94
|
-
|
|
95
81
|
};
|
|
96
82
|
}
|
|
97
83
|
|
|
98
84
|
function createFallbackableCache(options) {
|
|
99
85
|
const caches = [...options.caches];
|
|
100
86
|
const current = caches.shift();
|
|
101
|
-
|
|
102
87
|
if (current === undefined) {
|
|
103
88
|
return createNullCache();
|
|
104
89
|
}
|
|
105
|
-
|
|
106
90
|
return {
|
|
107
91
|
get(key, defaultValue, events = {
|
|
108
92
|
miss: () => Promise.resolve()
|
|
@@ -113,7 +97,6 @@ function createFallbackableCache(options) {
|
|
|
113
97
|
}).get(key, defaultValue, events);
|
|
114
98
|
});
|
|
115
99
|
},
|
|
116
|
-
|
|
117
100
|
set(key, value) {
|
|
118
101
|
return current.set(key, value).catch(() => {
|
|
119
102
|
return createFallbackableCache({
|
|
@@ -121,7 +104,6 @@ function createFallbackableCache(options) {
|
|
|
121
104
|
}).set(key, value);
|
|
122
105
|
});
|
|
123
106
|
},
|
|
124
|
-
|
|
125
107
|
delete(key) {
|
|
126
108
|
return current.delete(key).catch(() => {
|
|
127
109
|
return createFallbackableCache({
|
|
@@ -129,7 +111,6 @@ function createFallbackableCache(options) {
|
|
|
129
111
|
}).delete(key);
|
|
130
112
|
});
|
|
131
113
|
},
|
|
132
|
-
|
|
133
114
|
clear() {
|
|
134
115
|
return current.clear().catch(() => {
|
|
135
116
|
return createFallbackableCache({
|
|
@@ -137,7 +118,6 @@ function createFallbackableCache(options) {
|
|
|
137
118
|
}).clear();
|
|
138
119
|
});
|
|
139
120
|
}
|
|
140
|
-
|
|
141
121
|
};
|
|
142
122
|
}
|
|
143
123
|
|
|
@@ -150,30 +130,24 @@ function createMemoryCache(options = {
|
|
|
150
130
|
miss: () => Promise.resolve()
|
|
151
131
|
}) {
|
|
152
132
|
const keyAsString = JSON.stringify(key);
|
|
153
|
-
|
|
154
133
|
if (keyAsString in cache) {
|
|
155
134
|
return Promise.resolve(options.serializable ? JSON.parse(cache[keyAsString]) : cache[keyAsString]);
|
|
156
135
|
}
|
|
157
|
-
|
|
158
136
|
const promise = defaultValue();
|
|
159
137
|
return promise.then(value => events.miss(value)).then(() => promise);
|
|
160
138
|
},
|
|
161
|
-
|
|
162
139
|
set(key, value) {
|
|
163
140
|
cache[JSON.stringify(key)] = options.serializable ? JSON.stringify(value) : value;
|
|
164
141
|
return Promise.resolve(value);
|
|
165
142
|
},
|
|
166
|
-
|
|
167
143
|
delete(key) {
|
|
168
144
|
delete cache[JSON.stringify(key)];
|
|
169
145
|
return Promise.resolve();
|
|
170
146
|
},
|
|
171
|
-
|
|
172
147
|
clear() {
|
|
173
148
|
cache = {};
|
|
174
149
|
return Promise.resolve();
|
|
175
150
|
}
|
|
176
|
-
|
|
177
151
|
};
|
|
178
152
|
}
|
|
179
153
|
|
|
@@ -182,16 +156,14 @@ function createMemoryCache(options = {
|
|
|
182
156
|
const EXPIRATION_DELAY = 2 * 60 * 1000;
|
|
183
157
|
function createStatefulHost(host, status = 'up') {
|
|
184
158
|
const lastUpdate = Date.now();
|
|
185
|
-
|
|
186
159
|
function isUp() {
|
|
187
160
|
return status === 'up' || Date.now() - lastUpdate > EXPIRATION_DELAY;
|
|
188
161
|
}
|
|
189
|
-
|
|
190
162
|
function isTimedOut() {
|
|
191
163
|
return status === 'timed out' && Date.now() - lastUpdate <= EXPIRATION_DELAY;
|
|
192
164
|
}
|
|
193
|
-
|
|
194
|
-
|
|
165
|
+
return {
|
|
166
|
+
...host,
|
|
195
167
|
status,
|
|
196
168
|
lastUpdate,
|
|
197
169
|
isUp,
|
|
@@ -200,6 +172,7 @@ function createStatefulHost(host, status = 'up') {
|
|
|
200
172
|
}
|
|
201
173
|
|
|
202
174
|
function _defineProperty(obj, key, value) {
|
|
175
|
+
key = _toPropertyKey(key);
|
|
203
176
|
if (key in obj) {
|
|
204
177
|
Object.defineProperty(obj, key, {
|
|
205
178
|
value: value,
|
|
@@ -210,79 +183,85 @@ function _defineProperty(obj, key, value) {
|
|
|
210
183
|
} else {
|
|
211
184
|
obj[key] = value;
|
|
212
185
|
}
|
|
213
|
-
|
|
214
186
|
return obj;
|
|
215
187
|
}
|
|
188
|
+
function _toPrimitive(input, hint) {
|
|
189
|
+
if (typeof input !== "object" || input === null) return input;
|
|
190
|
+
var prim = input[Symbol.toPrimitive];
|
|
191
|
+
if (prim !== undefined) {
|
|
192
|
+
var res = prim.call(input, hint || "default");
|
|
193
|
+
if (typeof res !== "object") return res;
|
|
194
|
+
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
195
|
+
}
|
|
196
|
+
return (hint === "string" ? String : Number)(input);
|
|
197
|
+
}
|
|
198
|
+
function _toPropertyKey(arg) {
|
|
199
|
+
var key = _toPrimitive(arg, "string");
|
|
200
|
+
return typeof key === "symbol" ? key : String(key);
|
|
201
|
+
}
|
|
216
202
|
|
|
217
203
|
class AlgoliaError extends Error {
|
|
218
204
|
constructor(message, name) {
|
|
219
205
|
super(message);
|
|
220
|
-
|
|
221
206
|
_defineProperty(this, "name", 'AlgoliaError');
|
|
222
|
-
|
|
223
207
|
if (name) {
|
|
224
208
|
this.name = name;
|
|
225
209
|
}
|
|
226
210
|
}
|
|
227
|
-
|
|
228
211
|
}
|
|
229
212
|
class ErrorWithStackTrace extends AlgoliaError {
|
|
230
213
|
constructor(message, stackTrace, name) {
|
|
231
|
-
super(message, name);
|
|
232
|
-
|
|
214
|
+
super(message, name);
|
|
215
|
+
// the array and object should be frozen to reflect the stackTrace at the time of the error
|
|
233
216
|
_defineProperty(this, "stackTrace", void 0);
|
|
234
|
-
|
|
235
217
|
this.stackTrace = stackTrace;
|
|
236
218
|
}
|
|
237
|
-
|
|
238
219
|
}
|
|
239
220
|
class RetryError extends ErrorWithStackTrace {
|
|
240
221
|
constructor(stackTrace) {
|
|
241
222
|
super('Unreachable hosts - your application id may be incorrect. If the error persists, contact support@algolia.com.', stackTrace, 'RetryError');
|
|
242
223
|
}
|
|
243
|
-
|
|
244
224
|
}
|
|
245
225
|
class ApiError extends ErrorWithStackTrace {
|
|
246
|
-
constructor(message, status, stackTrace) {
|
|
247
|
-
super(message, stackTrace,
|
|
248
|
-
|
|
226
|
+
constructor(message, status, stackTrace, name = 'ApiError') {
|
|
227
|
+
super(message, stackTrace, name);
|
|
249
228
|
_defineProperty(this, "status", void 0);
|
|
250
|
-
|
|
251
229
|
this.status = status;
|
|
252
230
|
}
|
|
253
|
-
|
|
254
231
|
}
|
|
255
232
|
class DeserializationError extends AlgoliaError {
|
|
256
233
|
constructor(message, response) {
|
|
257
234
|
super(message, 'DeserializationError');
|
|
258
|
-
|
|
259
235
|
_defineProperty(this, "response", void 0);
|
|
260
|
-
|
|
261
236
|
this.response = response;
|
|
262
237
|
}
|
|
263
|
-
|
|
238
|
+
}
|
|
239
|
+
// DetailedApiError is only used by the ingestion client to return more informative error, other clients will use ApiClient.
|
|
240
|
+
class DetailedApiError extends ApiError {
|
|
241
|
+
constructor(message, status, error, stackTrace) {
|
|
242
|
+
super(message, status, stackTrace, 'DetailedApiError');
|
|
243
|
+
_defineProperty(this, "error", void 0);
|
|
244
|
+
this.error = error;
|
|
245
|
+
}
|
|
264
246
|
}
|
|
265
247
|
function serializeUrl(host, path, queryParameters) {
|
|
266
248
|
const queryParametersAsString = serializeQueryParameters(queryParameters);
|
|
267
249
|
let url = `${host.protocol}://${host.url}/${path.charAt(0) === '/' ? path.substr(1) : path}`;
|
|
268
|
-
|
|
269
250
|
if (queryParametersAsString.length) {
|
|
270
251
|
url += `?${queryParametersAsString}`;
|
|
271
252
|
}
|
|
272
|
-
|
|
273
253
|
return url;
|
|
274
254
|
}
|
|
275
255
|
function serializeQueryParameters(parameters) {
|
|
276
256
|
const isObjectOrArray = value => Object.prototype.toString.call(value) === '[object Object]' || Object.prototype.toString.call(value) === '[object Array]';
|
|
277
|
-
|
|
278
|
-
return Object.keys(parameters).map(key => `${key}=${isObjectOrArray(parameters[key]) ? JSON.stringify(parameters[key]) : parameters[key]}`).join('&');
|
|
257
|
+
return Object.keys(parameters).map(key => `${key}=${encodeURIComponent(isObjectOrArray(parameters[key]) ? JSON.stringify(parameters[key]) : parameters[key])}`).join('&');
|
|
279
258
|
}
|
|
280
259
|
function serializeData(request, requestOptions) {
|
|
281
260
|
if (request.method === 'GET' || request.data === undefined && requestOptions.data === undefined) {
|
|
282
261
|
return undefined;
|
|
283
262
|
}
|
|
284
|
-
|
|
285
|
-
|
|
263
|
+
const data = Array.isArray(request.data) ? request.data : {
|
|
264
|
+
...request.data,
|
|
286
265
|
...requestOptions.data
|
|
287
266
|
};
|
|
288
267
|
return JSON.stringify(data);
|
|
@@ -312,14 +291,16 @@ function deserializeFailure({
|
|
|
312
291
|
content,
|
|
313
292
|
status
|
|
314
293
|
}, stackFrame) {
|
|
315
|
-
let message = content;
|
|
316
|
-
|
|
317
294
|
try {
|
|
318
|
-
|
|
319
|
-
|
|
295
|
+
const parsed = JSON.parse(content);
|
|
296
|
+
if ('error' in parsed) {
|
|
297
|
+
return new DetailedApiError(parsed.message, status, parsed.error, stackFrame);
|
|
298
|
+
}
|
|
299
|
+
return new ApiError(parsed.message, status, stackFrame);
|
|
300
|
+
} catch (e) {
|
|
301
|
+
// ..
|
|
320
302
|
}
|
|
321
|
-
|
|
322
|
-
return new ApiError(message, status, stackFrame);
|
|
303
|
+
return new ApiError(content, status, stackFrame);
|
|
323
304
|
}
|
|
324
305
|
|
|
325
306
|
function isNetworkError({
|
|
@@ -350,9 +331,12 @@ function stackFrameWithoutCredentials(stackFrame) {
|
|
|
350
331
|
const modifiedHeaders = stackFrame.request.headers['x-algolia-api-key'] ? {
|
|
351
332
|
'x-algolia-api-key': '*****'
|
|
352
333
|
} : {};
|
|
353
|
-
return {
|
|
354
|
-
|
|
355
|
-
|
|
334
|
+
return {
|
|
335
|
+
...stackFrame,
|
|
336
|
+
request: {
|
|
337
|
+
...stackFrame.request,
|
|
338
|
+
headers: {
|
|
339
|
+
...stackFrame.request.headers,
|
|
356
340
|
...modifiedHeaders
|
|
357
341
|
}
|
|
358
342
|
}
|
|
@@ -377,51 +361,49 @@ function createTransporter({
|
|
|
377
361
|
});
|
|
378
362
|
}));
|
|
379
363
|
const hostsUp = statefulHosts.filter(host => host.isUp());
|
|
380
|
-
const hostsTimedOut = statefulHosts.filter(host => host.isTimedOut());
|
|
381
|
-
|
|
364
|
+
const hostsTimedOut = statefulHosts.filter(host => host.isTimedOut());
|
|
365
|
+
// Note, we put the hosts that previously timed out on the end of the list.
|
|
382
366
|
const hostsAvailable = [...hostsUp, ...hostsTimedOut];
|
|
383
367
|
const compatibleHostsAvailable = hostsAvailable.length > 0 ? hostsAvailable : compatibleHosts;
|
|
384
368
|
return {
|
|
385
369
|
hosts: compatibleHostsAvailable,
|
|
386
|
-
|
|
387
370
|
getTimeout(timeoutsCount, baseTimeout) {
|
|
388
|
-
/**
|
|
389
|
-
* Imagine that you have 4 hosts, if timeouts will increase
|
|
390
|
-
* on the following way: 1 (timed out) > 4 (timed out) > 5 (200).
|
|
391
|
-
*
|
|
392
|
-
* Note that, the very next request, we start from the previous timeout.
|
|
393
|
-
*
|
|
394
|
-
* 5 (timed out) > 6 (timed out) > 7 ...
|
|
395
|
-
*
|
|
396
|
-
* This strategy may need to be reviewed, but is the strategy on the our
|
|
397
|
-
* current v3 version.
|
|
371
|
+
/**
|
|
372
|
+
* Imagine that you have 4 hosts, if timeouts will increase
|
|
373
|
+
* on the following way: 1 (timed out) > 4 (timed out) > 5 (200).
|
|
374
|
+
*
|
|
375
|
+
* Note that, the very next request, we start from the previous timeout.
|
|
376
|
+
*
|
|
377
|
+
* 5 (timed out) > 6 (timed out) > 7 ...
|
|
378
|
+
*
|
|
379
|
+
* This strategy may need to be reviewed, but is the strategy on the our
|
|
380
|
+
* current v3 version.
|
|
398
381
|
*/
|
|
399
382
|
const timeoutMultiplier = hostsTimedOut.length === 0 && timeoutsCount === 0 ? 1 : hostsTimedOut.length + 3 + timeoutsCount;
|
|
400
383
|
return timeoutMultiplier * baseTimeout;
|
|
401
384
|
}
|
|
402
|
-
|
|
403
385
|
};
|
|
404
386
|
}
|
|
405
|
-
|
|
406
387
|
async function retryableRequest(request, requestOptions, isRead = true) {
|
|
407
388
|
const stackTrace = [];
|
|
408
|
-
/**
|
|
409
|
-
* First we prepare the payload that do not depend from hosts.
|
|
389
|
+
/**
|
|
390
|
+
* First we prepare the payload that do not depend from hosts.
|
|
410
391
|
*/
|
|
411
|
-
|
|
412
392
|
const data = serializeData(request, requestOptions);
|
|
413
|
-
const headers = serializeHeaders(baseHeaders, request.headers, requestOptions.headers);
|
|
414
|
-
|
|
415
|
-
const dataQueryParameters = request.method === 'GET' ? {
|
|
393
|
+
const headers = serializeHeaders(baseHeaders, request.headers, requestOptions.headers);
|
|
394
|
+
// On `GET`, the data is proxied to query parameters.
|
|
395
|
+
const dataQueryParameters = request.method === 'GET' ? {
|
|
396
|
+
...request.data,
|
|
416
397
|
...requestOptions.data
|
|
417
398
|
} : {};
|
|
418
399
|
const queryParameters = {
|
|
419
|
-
'x-algolia-agent': algoliaAgent.value,
|
|
420
400
|
...baseQueryParameters,
|
|
421
401
|
...request.queryParameters,
|
|
422
402
|
...dataQueryParameters
|
|
423
403
|
};
|
|
424
|
-
|
|
404
|
+
if (algoliaAgent.value) {
|
|
405
|
+
queryParameters['x-algolia-agent'] = algoliaAgent.value;
|
|
406
|
+
}
|
|
425
407
|
if (requestOptions && requestOptions.queryParameters) {
|
|
426
408
|
for (const key of Object.keys(requestOptions.queryParameters)) {
|
|
427
409
|
// We want to keep `undefined` and `null` values,
|
|
@@ -434,25 +416,19 @@ function createTransporter({
|
|
|
434
416
|
}
|
|
435
417
|
}
|
|
436
418
|
}
|
|
437
|
-
|
|
438
419
|
let timeoutsCount = 0;
|
|
439
|
-
|
|
440
420
|
const retry = async (retryableHosts, getTimeout) => {
|
|
441
|
-
/**
|
|
442
|
-
* We iterate on each host, until there is no host left.
|
|
421
|
+
/**
|
|
422
|
+
* We iterate on each host, until there is no host left.
|
|
443
423
|
*/
|
|
444
424
|
const host = retryableHosts.pop();
|
|
445
|
-
|
|
446
425
|
if (host === undefined) {
|
|
447
426
|
throw new RetryError(stackTraceWithoutCredentials(stackTrace));
|
|
448
427
|
}
|
|
449
|
-
|
|
450
428
|
let responseTimeout = requestOptions.timeout;
|
|
451
|
-
|
|
452
429
|
if (responseTimeout === undefined) {
|
|
453
430
|
responseTimeout = isRead ? timeouts.read : timeouts.write;
|
|
454
431
|
}
|
|
455
|
-
|
|
456
432
|
const payload = {
|
|
457
433
|
data,
|
|
458
434
|
headers,
|
|
@@ -461,12 +437,11 @@ function createTransporter({
|
|
|
461
437
|
connectTimeout: getTimeout(timeoutsCount, timeouts.connect),
|
|
462
438
|
responseTimeout: getTimeout(timeoutsCount, responseTimeout)
|
|
463
439
|
};
|
|
464
|
-
/**
|
|
465
|
-
* The stackFrame is pushed to the stackTrace so we
|
|
466
|
-
* can have information about onRetry and onFailure
|
|
467
|
-
* decisions.
|
|
440
|
+
/**
|
|
441
|
+
* The stackFrame is pushed to the stackTrace so we
|
|
442
|
+
* can have information about onRetry and onFailure
|
|
443
|
+
* decisions.
|
|
468
444
|
*/
|
|
469
|
-
|
|
470
445
|
const pushToStackTrace = response => {
|
|
471
446
|
const stackFrame = {
|
|
472
447
|
request: payload,
|
|
@@ -477,102 +452,85 @@ function createTransporter({
|
|
|
477
452
|
stackTrace.push(stackFrame);
|
|
478
453
|
return stackFrame;
|
|
479
454
|
};
|
|
480
|
-
|
|
481
455
|
const response = await requester.send(payload);
|
|
482
|
-
|
|
483
456
|
if (isRetryable(response)) {
|
|
484
|
-
const stackFrame = pushToStackTrace(response);
|
|
485
|
-
|
|
457
|
+
const stackFrame = pushToStackTrace(response);
|
|
458
|
+
// If response is a timeout, we increase the number of timeouts so we can increase the timeout later.
|
|
486
459
|
if (response.isTimedOut) {
|
|
487
460
|
timeoutsCount++;
|
|
488
461
|
}
|
|
489
|
-
/**
|
|
490
|
-
* Failures are individually sent to the logger, allowing
|
|
491
|
-
* the end user to debug / store stack frames even
|
|
492
|
-
* when a retry error does not happen.
|
|
462
|
+
/**
|
|
463
|
+
* Failures are individually sent to the logger, allowing
|
|
464
|
+
* the end user to debug / store stack frames even
|
|
465
|
+
* when a retry error does not happen.
|
|
493
466
|
*/
|
|
494
467
|
// eslint-disable-next-line no-console -- this will be fixed by exposing a `logger` to the transporter
|
|
495
|
-
|
|
496
|
-
|
|
497
468
|
console.log('Retryable failure', stackFrameWithoutCredentials(stackFrame));
|
|
498
|
-
/**
|
|
499
|
-
* We also store the state of the host in failure cases. If the host, is
|
|
500
|
-
* down it will remain down for the next 2 minutes. In a timeout situation,
|
|
501
|
-
* this host will be added end of the list of hosts on the next request.
|
|
469
|
+
/**
|
|
470
|
+
* We also store the state of the host in failure cases. If the host, is
|
|
471
|
+
* down it will remain down for the next 2 minutes. In a timeout situation,
|
|
472
|
+
* this host will be added end of the list of hosts on the next request.
|
|
502
473
|
*/
|
|
503
|
-
|
|
504
474
|
await hostsCache.set(host, createStatefulHost(host, response.isTimedOut ? 'timed out' : 'down'));
|
|
505
475
|
return retry(retryableHosts, getTimeout);
|
|
506
476
|
}
|
|
507
|
-
|
|
508
477
|
if (isSuccess(response)) {
|
|
509
478
|
return deserializeSuccess(response);
|
|
510
479
|
}
|
|
511
|
-
|
|
512
480
|
pushToStackTrace(response);
|
|
513
481
|
throw deserializeFailure(response, stackTrace);
|
|
514
482
|
};
|
|
515
|
-
/**
|
|
516
|
-
* Finally, for each retryable host perform request until we got a non
|
|
517
|
-
* retryable response. Some notes here:
|
|
518
|
-
*
|
|
519
|
-
* 1. The reverse here is applied so we can apply a `pop` later on => more performant.
|
|
520
|
-
* 2. We also get from the retryable options a timeout multiplier that is tailored
|
|
521
|
-
* for the current context.
|
|
483
|
+
/**
|
|
484
|
+
* Finally, for each retryable host perform request until we got a non
|
|
485
|
+
* retryable response. Some notes here:
|
|
486
|
+
*
|
|
487
|
+
* 1. The reverse here is applied so we can apply a `pop` later on => more performant.
|
|
488
|
+
* 2. We also get from the retryable options a timeout multiplier that is tailored
|
|
489
|
+
* for the current context.
|
|
522
490
|
*/
|
|
523
|
-
|
|
524
|
-
|
|
525
491
|
const compatibleHosts = hosts.filter(host => host.accept === 'readWrite' || (isRead ? host.accept === 'read' : host.accept === 'write'));
|
|
526
492
|
const options = await createRetryableOptions(compatibleHosts);
|
|
527
493
|
return retry([...options.hosts].reverse(), options.getTimeout);
|
|
528
494
|
}
|
|
529
|
-
|
|
530
495
|
function createRequest(request, requestOptions = {}) {
|
|
531
|
-
/**
|
|
532
|
-
* A read request is either a `GET` request, or a request that we make
|
|
533
|
-
* via the `read` transporter (e.g. `search`).
|
|
496
|
+
/**
|
|
497
|
+
* A read request is either a `GET` request, or a request that we make
|
|
498
|
+
* via the `read` transporter (e.g. `search`).
|
|
534
499
|
*/
|
|
535
500
|
const isRead = request.useReadTransporter || request.method === 'GET';
|
|
536
|
-
|
|
537
501
|
if (!isRead) {
|
|
538
|
-
/**
|
|
539
|
-
* On write requests, no cache mechanisms are applied, and we
|
|
540
|
-
* proxy the request immediately to the requester.
|
|
502
|
+
/**
|
|
503
|
+
* On write requests, no cache mechanisms are applied, and we
|
|
504
|
+
* proxy the request immediately to the requester.
|
|
541
505
|
*/
|
|
542
506
|
return retryableRequest(request, requestOptions, isRead);
|
|
543
507
|
}
|
|
544
|
-
|
|
545
508
|
const createRetryableRequest = () => {
|
|
546
|
-
/**
|
|
547
|
-
* Then, we prepare a function factory that contains the construction of
|
|
548
|
-
* the retryable request. At this point, we may *not* perform the actual
|
|
549
|
-
* request. But we want to have the function factory ready.
|
|
509
|
+
/**
|
|
510
|
+
* Then, we prepare a function factory that contains the construction of
|
|
511
|
+
* the retryable request. At this point, we may *not* perform the actual
|
|
512
|
+
* request. But we want to have the function factory ready.
|
|
550
513
|
*/
|
|
551
514
|
return retryableRequest(request, requestOptions);
|
|
552
515
|
};
|
|
553
|
-
/**
|
|
554
|
-
* Once we have the function factory ready, we need to determine of the
|
|
555
|
-
* request is "cacheable" - should be cached. Note that, once again,
|
|
556
|
-
* the user can force this option.
|
|
516
|
+
/**
|
|
517
|
+
* Once we have the function factory ready, we need to determine of the
|
|
518
|
+
* request is "cacheable" - should be cached. Note that, once again,
|
|
519
|
+
* the user can force this option.
|
|
557
520
|
*/
|
|
558
|
-
|
|
559
|
-
|
|
560
521
|
const cacheable = requestOptions.cacheable || request.cacheable;
|
|
561
|
-
/**
|
|
562
|
-
* If is not "cacheable", we immediately trigger the retryable request, no
|
|
563
|
-
* need to check cache implementations.
|
|
522
|
+
/**
|
|
523
|
+
* If is not "cacheable", we immediately trigger the retryable request, no
|
|
524
|
+
* need to check cache implementations.
|
|
564
525
|
*/
|
|
565
|
-
|
|
566
526
|
if (cacheable !== true) {
|
|
567
527
|
return createRetryableRequest();
|
|
568
528
|
}
|
|
569
|
-
/**
|
|
570
|
-
* If the request is "cacheable", we need to first compute the key to ask
|
|
571
|
-
* the cache implementations if this request is on progress or if the
|
|
572
|
-
* response already exists on the cache.
|
|
529
|
+
/**
|
|
530
|
+
* If the request is "cacheable", we need to first compute the key to ask
|
|
531
|
+
* the cache implementations if this request is on progress or if the
|
|
532
|
+
* response already exists on the cache.
|
|
573
533
|
*/
|
|
574
|
-
|
|
575
|
-
|
|
576
534
|
const key = {
|
|
577
535
|
request,
|
|
578
536
|
requestOptions,
|
|
@@ -581,33 +539,31 @@ function createTransporter({
|
|
|
581
539
|
headers: baseHeaders
|
|
582
540
|
}
|
|
583
541
|
};
|
|
584
|
-
/**
|
|
585
|
-
* With the computed key, we first ask the responses cache
|
|
586
|
-
* implementation if this request was been resolved before.
|
|
542
|
+
/**
|
|
543
|
+
* With the computed key, we first ask the responses cache
|
|
544
|
+
* implementation if this request was been resolved before.
|
|
587
545
|
*/
|
|
588
|
-
|
|
589
546
|
return responsesCache.get(key, () => {
|
|
590
|
-
/**
|
|
591
|
-
* If the request has never resolved before, we actually ask if there
|
|
592
|
-
* is a current request with the same key on progress.
|
|
547
|
+
/**
|
|
548
|
+
* If the request has never resolved before, we actually ask if there
|
|
549
|
+
* is a current request with the same key on progress.
|
|
593
550
|
*/
|
|
594
551
|
return requestsCache.get(key, () =>
|
|
595
|
-
/**
|
|
596
|
-
* Finally, if there is no request in progress with the same key,
|
|
597
|
-
* this `createRetryableRequest()` will actually trigger the
|
|
598
|
-
* retryable request.
|
|
552
|
+
/**
|
|
553
|
+
* Finally, if there is no request in progress with the same key,
|
|
554
|
+
* this `createRetryableRequest()` will actually trigger the
|
|
555
|
+
* retryable request.
|
|
599
556
|
*/
|
|
600
557
|
requestsCache.set(key, createRetryableRequest()).then(response => Promise.all([requestsCache.delete(key), response]), err => Promise.all([requestsCache.delete(key), Promise.reject(err)])).then(([_, response]) => response));
|
|
601
558
|
}, {
|
|
602
|
-
/**
|
|
603
|
-
* Of course, once we get this response back from the server, we
|
|
604
|
-
* tell response cache to actually store the received response
|
|
605
|
-
* to be used later.
|
|
559
|
+
/**
|
|
560
|
+
* Of course, once we get this response back from the server, we
|
|
561
|
+
* tell response cache to actually store the received response
|
|
562
|
+
* to be used later.
|
|
606
563
|
*/
|
|
607
564
|
miss: response => responsesCache.set(key, response)
|
|
608
565
|
});
|
|
609
566
|
}
|
|
610
|
-
|
|
611
567
|
return {
|
|
612
568
|
hostsCache,
|
|
613
569
|
requester,
|
|
@@ -625,17 +581,13 @@ function createTransporter({
|
|
|
625
581
|
function createAlgoliaAgent(version) {
|
|
626
582
|
const algoliaAgent = {
|
|
627
583
|
value: `Algolia for JavaScript (${version})`,
|
|
628
|
-
|
|
629
584
|
add(options) {
|
|
630
585
|
const addedAlgoliaAgent = `; ${options.segment}${options.version !== undefined ? ` (${options.version})` : ''}`;
|
|
631
|
-
|
|
632
586
|
if (algoliaAgent.value.indexOf(addedAlgoliaAgent) === -1) {
|
|
633
587
|
algoliaAgent.value = `${algoliaAgent.value}${addedAlgoliaAgent}`;
|
|
634
588
|
}
|
|
635
|
-
|
|
636
589
|
return algoliaAgent;
|
|
637
590
|
}
|
|
638
|
-
|
|
639
591
|
};
|
|
640
592
|
return algoliaAgent;
|
|
641
593
|
}
|
|
@@ -657,351 +609,349 @@ const DEFAULT_CONNECT_TIMEOUT_BROWSER = 1000;
|
|
|
657
609
|
const DEFAULT_READ_TIMEOUT_BROWSER = 2000;
|
|
658
610
|
const DEFAULT_WRITE_TIMEOUT_BROWSER = 30000;
|
|
659
611
|
|
|
660
|
-
function createXhrRequester() {
|
|
661
|
-
function send(request) {
|
|
662
|
-
return new Promise((resolve) => {
|
|
663
|
-
const baseRequester = new XMLHttpRequest();
|
|
664
|
-
baseRequester.open(request.method, request.url, true);
|
|
665
|
-
Object.keys(request.headers).forEach((key) => baseRequester.setRequestHeader(key, request.headers[key]));
|
|
666
|
-
const createTimeout = (timeout, content) => {
|
|
667
|
-
return setTimeout(() => {
|
|
668
|
-
baseRequester.abort();
|
|
669
|
-
resolve({
|
|
670
|
-
status: 0,
|
|
671
|
-
content,
|
|
672
|
-
isTimedOut: true,
|
|
673
|
-
});
|
|
674
|
-
}, timeout);
|
|
675
|
-
};
|
|
676
|
-
const connectTimeout = createTimeout(request.connectTimeout, 'Connection timeout');
|
|
677
|
-
let responseTimeout;
|
|
678
|
-
baseRequester.onreadystatechange = () => {
|
|
679
|
-
if (baseRequester.readyState > baseRequester.OPENED &&
|
|
680
|
-
responseTimeout === undefined) {
|
|
681
|
-
clearTimeout(connectTimeout);
|
|
682
|
-
responseTimeout = createTimeout(request.responseTimeout, 'Socket timeout');
|
|
683
|
-
}
|
|
684
|
-
};
|
|
685
|
-
baseRequester.onerror = () => {
|
|
686
|
-
// istanbul ignore next
|
|
687
|
-
if (baseRequester.status === 0) {
|
|
688
|
-
clearTimeout(connectTimeout);
|
|
689
|
-
clearTimeout(responseTimeout);
|
|
690
|
-
resolve({
|
|
691
|
-
content: baseRequester.responseText || 'Network request failed',
|
|
692
|
-
status: baseRequester.status,
|
|
693
|
-
isTimedOut: false,
|
|
694
|
-
});
|
|
695
|
-
}
|
|
696
|
-
};
|
|
697
|
-
baseRequester.onload = () => {
|
|
698
|
-
clearTimeout(connectTimeout);
|
|
699
|
-
clearTimeout(responseTimeout);
|
|
700
|
-
resolve({
|
|
701
|
-
content: baseRequester.responseText,
|
|
702
|
-
status: baseRequester.status,
|
|
703
|
-
isTimedOut: false,
|
|
704
|
-
});
|
|
705
|
-
};
|
|
706
|
-
baseRequester.send(request.data);
|
|
707
|
-
});
|
|
708
|
-
}
|
|
709
|
-
return { send };
|
|
612
|
+
function createXhrRequester() {
|
|
613
|
+
function send(request) {
|
|
614
|
+
return new Promise((resolve) => {
|
|
615
|
+
const baseRequester = new XMLHttpRequest();
|
|
616
|
+
baseRequester.open(request.method, request.url, true);
|
|
617
|
+
Object.keys(request.headers).forEach((key) => baseRequester.setRequestHeader(key, request.headers[key]));
|
|
618
|
+
const createTimeout = (timeout, content) => {
|
|
619
|
+
return setTimeout(() => {
|
|
620
|
+
baseRequester.abort();
|
|
621
|
+
resolve({
|
|
622
|
+
status: 0,
|
|
623
|
+
content,
|
|
624
|
+
isTimedOut: true,
|
|
625
|
+
});
|
|
626
|
+
}, timeout);
|
|
627
|
+
};
|
|
628
|
+
const connectTimeout = createTimeout(request.connectTimeout, 'Connection timeout');
|
|
629
|
+
let responseTimeout;
|
|
630
|
+
baseRequester.onreadystatechange = () => {
|
|
631
|
+
if (baseRequester.readyState > baseRequester.OPENED &&
|
|
632
|
+
responseTimeout === undefined) {
|
|
633
|
+
clearTimeout(connectTimeout);
|
|
634
|
+
responseTimeout = createTimeout(request.responseTimeout, 'Socket timeout');
|
|
635
|
+
}
|
|
636
|
+
};
|
|
637
|
+
baseRequester.onerror = () => {
|
|
638
|
+
// istanbul ignore next
|
|
639
|
+
if (baseRequester.status === 0) {
|
|
640
|
+
clearTimeout(connectTimeout);
|
|
641
|
+
clearTimeout(responseTimeout);
|
|
642
|
+
resolve({
|
|
643
|
+
content: baseRequester.responseText || 'Network request failed',
|
|
644
|
+
status: baseRequester.status,
|
|
645
|
+
isTimedOut: false,
|
|
646
|
+
});
|
|
647
|
+
}
|
|
648
|
+
};
|
|
649
|
+
baseRequester.onload = () => {
|
|
650
|
+
clearTimeout(connectTimeout);
|
|
651
|
+
clearTimeout(responseTimeout);
|
|
652
|
+
resolve({
|
|
653
|
+
content: baseRequester.responseText,
|
|
654
|
+
status: baseRequester.status,
|
|
655
|
+
isTimedOut: false,
|
|
656
|
+
});
|
|
657
|
+
};
|
|
658
|
+
baseRequester.send(request.data);
|
|
659
|
+
});
|
|
660
|
+
}
|
|
661
|
+
return { send };
|
|
710
662
|
}
|
|
711
663
|
|
|
712
|
-
//
|
|
713
|
-
const apiClientVersion = '5.0.0-alpha.
|
|
714
|
-
const REGIONS = ['eu', 'us'];
|
|
715
|
-
function getDefaultHosts(region) {
|
|
716
|
-
const url = 'personalization.{region}.algolia.com'.replace('{region}', region);
|
|
717
|
-
return [{ url, accept: 'readWrite', protocol: 'https' }];
|
|
718
|
-
}
|
|
719
|
-
// eslint-disable-next-line @typescript-eslint/explicit-function-return-type
|
|
720
|
-
function createPersonalizationClient({ appId: appIdOption, apiKey: apiKeyOption, authMode, algoliaAgents, region: regionOption, ...options }) {
|
|
721
|
-
const auth = createAuth(appIdOption, apiKeyOption, authMode);
|
|
722
|
-
const transporter = createTransporter({
|
|
723
|
-
hosts: getDefaultHosts(regionOption),
|
|
724
|
-
...options,
|
|
725
|
-
algoliaAgent: getAlgoliaAgent({
|
|
726
|
-
algoliaAgents,
|
|
727
|
-
client: 'Personalization',
|
|
728
|
-
version: apiClientVersion,
|
|
729
|
-
}),
|
|
730
|
-
baseHeaders: {
|
|
731
|
-
'content-type': 'text/plain',
|
|
732
|
-
...auth.headers(),
|
|
733
|
-
...options.baseHeaders,
|
|
734
|
-
},
|
|
735
|
-
baseQueryParameters: {
|
|
736
|
-
...auth.queryParameters(),
|
|
737
|
-
...options.baseQueryParameters,
|
|
738
|
-
},
|
|
739
|
-
});
|
|
740
|
-
return {
|
|
741
|
-
transporter,
|
|
742
|
-
/**
|
|
743
|
-
* The `appId` currently in use.
|
|
744
|
-
*/
|
|
745
|
-
appId: appIdOption,
|
|
746
|
-
/**
|
|
747
|
-
* Clears the cache of the transporter for the `requestsCache` and `responsesCache` properties.
|
|
748
|
-
*/
|
|
749
|
-
clearCache() {
|
|
750
|
-
return Promise.all([
|
|
751
|
-
transporter.requestsCache.clear(),
|
|
752
|
-
transporter.responsesCache.clear(),
|
|
753
|
-
]).then(() => undefined);
|
|
754
|
-
},
|
|
755
|
-
/**
|
|
756
|
-
* Get the value of the `algoliaAgent`, used by our libraries internally and telemetry system.
|
|
757
|
-
*/
|
|
758
|
-
get _ua() {
|
|
759
|
-
return transporter.algoliaAgent.value;
|
|
760
|
-
},
|
|
761
|
-
/**
|
|
762
|
-
* Adds a `segment` to the `x-algolia-agent` sent with every requests.
|
|
763
|
-
*
|
|
764
|
-
* @param segment - The algolia agent (user-agent) segment to add.
|
|
765
|
-
* @param version - The version of the agent.
|
|
766
|
-
*/
|
|
767
|
-
addAlgoliaAgent(segment, version) {
|
|
768
|
-
transporter.algoliaAgent.add({ segment, version });
|
|
769
|
-
},
|
|
770
|
-
/**
|
|
771
|
-
* This method allow you to send requests to the Algolia REST API.
|
|
772
|
-
*
|
|
773
|
-
* @summary Send requests to the Algolia REST API.
|
|
774
|
-
* @param del - The del object.
|
|
775
|
-
* @param del.path - The path of the API endpoint to target, anything after the /1 needs to be specified.
|
|
776
|
-
* @param del.parameters - Query parameters to be applied to the current query.
|
|
777
|
-
* @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
|
|
778
|
-
*/
|
|
779
|
-
del({ path, parameters }, requestOptions) {
|
|
780
|
-
if (!path) {
|
|
781
|
-
throw new Error('Parameter `path` is required when calling `del`.');
|
|
782
|
-
}
|
|
783
|
-
const requestPath = '/1{path}'.replace('{path}', path);
|
|
784
|
-
const headers = {};
|
|
785
|
-
const queryParameters = parameters ? parameters : {};
|
|
786
|
-
const request = {
|
|
787
|
-
method: 'DELETE',
|
|
788
|
-
path: requestPath,
|
|
789
|
-
queryParameters,
|
|
790
|
-
headers,
|
|
791
|
-
};
|
|
792
|
-
return transporter.request(request, requestOptions);
|
|
793
|
-
},
|
|
794
|
-
/**
|
|
795
|
-
* Delete the user profile and all its associated data. Returns, as part of the response, a date until which the data can safely be considered as deleted for the given user. This means if you send events for the given user before this date, they will be ignored. Any data received after the deletedUntil date will start building a new user profile. It might take a couple hours for the deletion request to be fully processed.
|
|
796
|
-
*
|
|
797
|
-
* @summary Delete a user profile.
|
|
798
|
-
* @param deleteUserProfile - The deleteUserProfile object.
|
|
799
|
-
* @param deleteUserProfile.userToken - UserToken representing the user for which to fetch the Personalization profile.
|
|
800
|
-
* @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
|
|
801
|
-
*/
|
|
802
|
-
deleteUserProfile({ userToken }, requestOptions) {
|
|
803
|
-
if (!userToken) {
|
|
804
|
-
throw new Error('Parameter `userToken` is required when calling `deleteUserProfile`.');
|
|
805
|
-
}
|
|
806
|
-
const requestPath = '/1/profiles/{userToken}'.replace('{userToken}', encodeURIComponent(userToken));
|
|
807
|
-
const headers = {};
|
|
808
|
-
const queryParameters = {};
|
|
809
|
-
const request = {
|
|
810
|
-
method: 'DELETE',
|
|
811
|
-
path: requestPath,
|
|
812
|
-
queryParameters,
|
|
813
|
-
headers,
|
|
814
|
-
};
|
|
815
|
-
return transporter.request(request, requestOptions);
|
|
816
|
-
},
|
|
817
|
-
/**
|
|
818
|
-
* This method allow you to send requests to the Algolia REST API.
|
|
819
|
-
*
|
|
820
|
-
* @summary Send requests to the Algolia REST API.
|
|
821
|
-
* @param get - The get object.
|
|
822
|
-
* @param get.path - The path of the API endpoint to target, anything after the /1 needs to be specified.
|
|
823
|
-
* @param get.parameters - Query parameters to be applied to the current query.
|
|
824
|
-
* @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
|
|
825
|
-
*/
|
|
826
|
-
get({ path, parameters }, requestOptions) {
|
|
827
|
-
if (!path) {
|
|
828
|
-
throw new Error('Parameter `path` is required when calling `get`.');
|
|
829
|
-
}
|
|
830
|
-
const requestPath = '/1{path}'.replace('{path}', path);
|
|
831
|
-
const headers = {};
|
|
832
|
-
const queryParameters = parameters ? parameters : {};
|
|
833
|
-
const request = {
|
|
834
|
-
method: 'GET',
|
|
835
|
-
path: requestPath,
|
|
836
|
-
queryParameters,
|
|
837
|
-
headers,
|
|
838
|
-
};
|
|
839
|
-
return transporter.request(request, requestOptions);
|
|
840
|
-
},
|
|
841
|
-
/**
|
|
842
|
-
* The strategy contains information on the events and facets that impact user profiles and personalized search results.
|
|
843
|
-
*
|
|
844
|
-
* @summary Get the current strategy.
|
|
845
|
-
* @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
|
|
846
|
-
*/
|
|
847
|
-
getPersonalizationStrategy(requestOptions) {
|
|
848
|
-
const requestPath = '/1/strategies/personalization';
|
|
849
|
-
const headers = {};
|
|
850
|
-
const queryParameters = {};
|
|
851
|
-
const request = {
|
|
852
|
-
method: 'GET',
|
|
853
|
-
path: requestPath,
|
|
854
|
-
queryParameters,
|
|
855
|
-
headers,
|
|
856
|
-
};
|
|
857
|
-
return transporter.request(request, requestOptions);
|
|
858
|
-
},
|
|
859
|
-
/**
|
|
860
|
-
* Get the user profile built from Personalization strategy. The profile is structured by facet name used in the strategy. Each facet value is mapped to its score. Each score represents the user affinity for a specific facet value given the userToken past events and the Personalization strategy defined. Scores are bounded to 20. The last processed event timestamp is provided using the ISO 8601 format for debugging purposes.
|
|
861
|
-
*
|
|
862
|
-
* @summary Get a user profile.
|
|
863
|
-
* @param getUserTokenProfile - The getUserTokenProfile object.
|
|
864
|
-
* @param getUserTokenProfile.userToken - UserToken representing the user for which to fetch the Personalization profile.
|
|
865
|
-
* @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
|
|
866
|
-
*/
|
|
867
|
-
getUserTokenProfile({ userToken }, requestOptions) {
|
|
868
|
-
if (!userToken) {
|
|
869
|
-
throw new Error('Parameter `userToken` is required when calling `getUserTokenProfile`.');
|
|
870
|
-
}
|
|
871
|
-
const requestPath = '/1/profiles/personalization/{userToken}'.replace('{userToken}', encodeURIComponent(userToken));
|
|
872
|
-
const headers = {};
|
|
873
|
-
const queryParameters = {};
|
|
874
|
-
const request = {
|
|
875
|
-
method: 'GET',
|
|
876
|
-
path: requestPath,
|
|
877
|
-
queryParameters,
|
|
878
|
-
headers,
|
|
879
|
-
};
|
|
880
|
-
return transporter.request(request, requestOptions);
|
|
881
|
-
},
|
|
882
|
-
/**
|
|
883
|
-
* This method allow you to send requests to the Algolia REST API.
|
|
884
|
-
*
|
|
885
|
-
* @summary Send requests to the Algolia REST API.
|
|
886
|
-
* @param post - The post object.
|
|
887
|
-
* @param post.path - The path of the API endpoint to target, anything after the /1 needs to be specified.
|
|
888
|
-
* @param post.parameters - Query parameters to be applied to the current query.
|
|
889
|
-
* @param post.body - The parameters to send with the custom request.
|
|
890
|
-
* @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
|
|
891
|
-
*/
|
|
892
|
-
post({ path, parameters, body }, requestOptions) {
|
|
893
|
-
if (!path) {
|
|
894
|
-
throw new Error('Parameter `path` is required when calling `post`.');
|
|
895
|
-
}
|
|
896
|
-
const requestPath = '/1{path}'.replace('{path}', path);
|
|
897
|
-
const headers = {};
|
|
898
|
-
const queryParameters = parameters ? parameters : {};
|
|
899
|
-
const request = {
|
|
900
|
-
method: 'POST',
|
|
901
|
-
path: requestPath,
|
|
902
|
-
queryParameters,
|
|
903
|
-
headers,
|
|
904
|
-
data: body ? body : {},
|
|
905
|
-
};
|
|
906
|
-
return transporter.request(request, requestOptions);
|
|
907
|
-
},
|
|
908
|
-
/**
|
|
909
|
-
* This method allow you to send requests to the Algolia REST API.
|
|
910
|
-
*
|
|
911
|
-
* @summary Send requests to the Algolia REST API.
|
|
912
|
-
* @param put - The put object.
|
|
913
|
-
* @param put.path - The path of the API endpoint to target, anything after the /1 needs to be specified.
|
|
914
|
-
* @param put.parameters - Query parameters to be applied to the current query.
|
|
915
|
-
* @param put.body - The parameters to send with the custom request.
|
|
916
|
-
* @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
|
|
917
|
-
*/
|
|
918
|
-
put({ path, parameters, body }, requestOptions) {
|
|
919
|
-
if (!path) {
|
|
920
|
-
throw new Error('Parameter `path` is required when calling `put`.');
|
|
921
|
-
}
|
|
922
|
-
const requestPath = '/1{path}'.replace('{path}', path);
|
|
923
|
-
const headers = {};
|
|
924
|
-
const queryParameters = parameters ? parameters : {};
|
|
925
|
-
const request = {
|
|
926
|
-
method: 'PUT',
|
|
927
|
-
path: requestPath,
|
|
928
|
-
queryParameters,
|
|
929
|
-
headers,
|
|
930
|
-
data: body ? body : {},
|
|
931
|
-
};
|
|
932
|
-
return transporter.request(request, requestOptions);
|
|
933
|
-
},
|
|
934
|
-
/**
|
|
935
|
-
* A strategy defines the events and facets that impact user profiles and personalized search results.
|
|
936
|
-
*
|
|
937
|
-
* @summary Set a new strategy.
|
|
938
|
-
* @param personalizationStrategyParams - The personalizationStrategyParams object.
|
|
939
|
-
* @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
|
|
940
|
-
*/
|
|
941
|
-
setPersonalizationStrategy(personalizationStrategyParams, requestOptions) {
|
|
942
|
-
if (!personalizationStrategyParams) {
|
|
943
|
-
throw new Error('Parameter `personalizationStrategyParams` is required when calling `setPersonalizationStrategy`.');
|
|
944
|
-
}
|
|
945
|
-
if (!personalizationStrategyParams.eventScoring) {
|
|
946
|
-
throw new Error('Parameter `personalizationStrategyParams.eventScoring` is required when calling `setPersonalizationStrategy`.');
|
|
947
|
-
}
|
|
948
|
-
if (!personalizationStrategyParams.facetScoring) {
|
|
949
|
-
throw new Error('Parameter `personalizationStrategyParams.facetScoring` is required when calling `setPersonalizationStrategy`.');
|
|
950
|
-
}
|
|
951
|
-
if (!personalizationStrategyParams.personalizationImpact) {
|
|
952
|
-
throw new Error('Parameter `personalizationStrategyParams.personalizationImpact` is required when calling `setPersonalizationStrategy`.');
|
|
953
|
-
}
|
|
954
|
-
const requestPath = '/1/strategies/personalization';
|
|
955
|
-
const headers = {};
|
|
956
|
-
const queryParameters = {};
|
|
957
|
-
const request = {
|
|
958
|
-
method: 'POST',
|
|
959
|
-
path: requestPath,
|
|
960
|
-
queryParameters,
|
|
961
|
-
headers,
|
|
962
|
-
data: personalizationStrategyParams,
|
|
963
|
-
};
|
|
964
|
-
return transporter.request(request, requestOptions);
|
|
965
|
-
},
|
|
966
|
-
};
|
|
664
|
+
// 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.
|
|
665
|
+
const apiClientVersion = '5.0.0-alpha.71';
|
|
666
|
+
const REGIONS = ['eu', 'us'];
|
|
667
|
+
function getDefaultHosts(region) {
|
|
668
|
+
const url = 'personalization.{region}.algolia.com'.replace('{region}', region);
|
|
669
|
+
return [{ url, accept: 'readWrite', protocol: 'https' }];
|
|
670
|
+
}
|
|
671
|
+
// eslint-disable-next-line @typescript-eslint/explicit-function-return-type
|
|
672
|
+
function createPersonalizationClient({ appId: appIdOption, apiKey: apiKeyOption, authMode, algoliaAgents, region: regionOption, ...options }) {
|
|
673
|
+
const auth = createAuth(appIdOption, apiKeyOption, authMode);
|
|
674
|
+
const transporter = createTransporter({
|
|
675
|
+
hosts: getDefaultHosts(regionOption),
|
|
676
|
+
...options,
|
|
677
|
+
algoliaAgent: getAlgoliaAgent({
|
|
678
|
+
algoliaAgents,
|
|
679
|
+
client: 'Personalization',
|
|
680
|
+
version: apiClientVersion,
|
|
681
|
+
}),
|
|
682
|
+
baseHeaders: {
|
|
683
|
+
'content-type': 'text/plain',
|
|
684
|
+
...auth.headers(),
|
|
685
|
+
...options.baseHeaders,
|
|
686
|
+
},
|
|
687
|
+
baseQueryParameters: {
|
|
688
|
+
...auth.queryParameters(),
|
|
689
|
+
...options.baseQueryParameters,
|
|
690
|
+
},
|
|
691
|
+
});
|
|
692
|
+
return {
|
|
693
|
+
transporter,
|
|
694
|
+
/**
|
|
695
|
+
* The `appId` currently in use.
|
|
696
|
+
*/
|
|
697
|
+
appId: appIdOption,
|
|
698
|
+
/**
|
|
699
|
+
* Clears the cache of the transporter for the `requestsCache` and `responsesCache` properties.
|
|
700
|
+
*/
|
|
701
|
+
clearCache() {
|
|
702
|
+
return Promise.all([
|
|
703
|
+
transporter.requestsCache.clear(),
|
|
704
|
+
transporter.responsesCache.clear(),
|
|
705
|
+
]).then(() => undefined);
|
|
706
|
+
},
|
|
707
|
+
/**
|
|
708
|
+
* Get the value of the `algoliaAgent`, used by our libraries internally and telemetry system.
|
|
709
|
+
*/
|
|
710
|
+
get _ua() {
|
|
711
|
+
return transporter.algoliaAgent.value;
|
|
712
|
+
},
|
|
713
|
+
/**
|
|
714
|
+
* Adds a `segment` to the `x-algolia-agent` sent with every requests.
|
|
715
|
+
*
|
|
716
|
+
* @param segment - The algolia agent (user-agent) segment to add.
|
|
717
|
+
* @param version - The version of the agent.
|
|
718
|
+
*/
|
|
719
|
+
addAlgoliaAgent(segment, version) {
|
|
720
|
+
transporter.algoliaAgent.add({ segment, version });
|
|
721
|
+
},
|
|
722
|
+
/**
|
|
723
|
+
* This method allow you to send requests to the Algolia REST API.
|
|
724
|
+
*
|
|
725
|
+
* @summary Send requests to the Algolia REST API.
|
|
726
|
+
* @param del - The del object.
|
|
727
|
+
* @param del.path - The path of the API endpoint to target, anything after the /1 needs to be specified.
|
|
728
|
+
* @param del.parameters - Query parameters to be applied to the current query.
|
|
729
|
+
* @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
|
|
730
|
+
*/
|
|
731
|
+
del({ path, parameters }, requestOptions) {
|
|
732
|
+
if (!path) {
|
|
733
|
+
throw new Error('Parameter `path` is required when calling `del`.');
|
|
734
|
+
}
|
|
735
|
+
const requestPath = '/1{path}'.replace('{path}', path);
|
|
736
|
+
const headers = {};
|
|
737
|
+
const queryParameters = parameters ? parameters : {};
|
|
738
|
+
const request = {
|
|
739
|
+
method: 'DELETE',
|
|
740
|
+
path: requestPath,
|
|
741
|
+
queryParameters,
|
|
742
|
+
headers,
|
|
743
|
+
};
|
|
744
|
+
return transporter.request(request, requestOptions);
|
|
745
|
+
},
|
|
746
|
+
/**
|
|
747
|
+
* Delete the user profile and all its associated data. Returns, as part of the response, a date until which the data can safely be considered as deleted for the given user. This means if you send events for the given user before this date, they will be ignored. Any data received after the deletedUntil date will start building a new user profile. It might take a couple hours for the deletion request to be fully processed.
|
|
748
|
+
*
|
|
749
|
+
* @summary Delete a user profile.
|
|
750
|
+
* @param deleteUserProfile - The deleteUserProfile object.
|
|
751
|
+
* @param deleteUserProfile.userToken - UserToken representing the user for which to fetch the Personalization profile.
|
|
752
|
+
* @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
|
|
753
|
+
*/
|
|
754
|
+
deleteUserProfile({ userToken }, requestOptions) {
|
|
755
|
+
if (!userToken) {
|
|
756
|
+
throw new Error('Parameter `userToken` is required when calling `deleteUserProfile`.');
|
|
757
|
+
}
|
|
758
|
+
const requestPath = '/1/profiles/{userToken}'.replace('{userToken}', encodeURIComponent(userToken));
|
|
759
|
+
const headers = {};
|
|
760
|
+
const queryParameters = {};
|
|
761
|
+
const request = {
|
|
762
|
+
method: 'DELETE',
|
|
763
|
+
path: requestPath,
|
|
764
|
+
queryParameters,
|
|
765
|
+
headers,
|
|
766
|
+
};
|
|
767
|
+
return transporter.request(request, requestOptions);
|
|
768
|
+
},
|
|
769
|
+
/**
|
|
770
|
+
* This method allow you to send requests to the Algolia REST API.
|
|
771
|
+
*
|
|
772
|
+
* @summary Send requests to the Algolia REST API.
|
|
773
|
+
* @param get - The get object.
|
|
774
|
+
* @param get.path - The path of the API endpoint to target, anything after the /1 needs to be specified.
|
|
775
|
+
* @param get.parameters - Query parameters to be applied to the current query.
|
|
776
|
+
* @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
|
|
777
|
+
*/
|
|
778
|
+
get({ path, parameters }, requestOptions) {
|
|
779
|
+
if (!path) {
|
|
780
|
+
throw new Error('Parameter `path` is required when calling `get`.');
|
|
781
|
+
}
|
|
782
|
+
const requestPath = '/1{path}'.replace('{path}', path);
|
|
783
|
+
const headers = {};
|
|
784
|
+
const queryParameters = parameters ? parameters : {};
|
|
785
|
+
const request = {
|
|
786
|
+
method: 'GET',
|
|
787
|
+
path: requestPath,
|
|
788
|
+
queryParameters,
|
|
789
|
+
headers,
|
|
790
|
+
};
|
|
791
|
+
return transporter.request(request, requestOptions);
|
|
792
|
+
},
|
|
793
|
+
/**
|
|
794
|
+
* The strategy contains information on the events and facets that impact user profiles and personalized search results.
|
|
795
|
+
*
|
|
796
|
+
* @summary Get the current strategy.
|
|
797
|
+
* @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
|
|
798
|
+
*/
|
|
799
|
+
getPersonalizationStrategy(requestOptions) {
|
|
800
|
+
const requestPath = '/1/strategies/personalization';
|
|
801
|
+
const headers = {};
|
|
802
|
+
const queryParameters = {};
|
|
803
|
+
const request = {
|
|
804
|
+
method: 'GET',
|
|
805
|
+
path: requestPath,
|
|
806
|
+
queryParameters,
|
|
807
|
+
headers,
|
|
808
|
+
};
|
|
809
|
+
return transporter.request(request, requestOptions);
|
|
810
|
+
},
|
|
811
|
+
/**
|
|
812
|
+
* Get the user profile built from Personalization strategy. The profile is structured by facet name used in the strategy. Each facet value is mapped to its score. Each score represents the user affinity for a specific facet value given the userToken past events and the Personalization strategy defined. Scores are bounded to 20. The last processed event timestamp is provided using the ISO 8601 format for debugging purposes.
|
|
813
|
+
*
|
|
814
|
+
* @summary Get a user profile.
|
|
815
|
+
* @param getUserTokenProfile - The getUserTokenProfile object.
|
|
816
|
+
* @param getUserTokenProfile.userToken - UserToken representing the user for which to fetch the Personalization profile.
|
|
817
|
+
* @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
|
|
818
|
+
*/
|
|
819
|
+
getUserTokenProfile({ userToken }, requestOptions) {
|
|
820
|
+
if (!userToken) {
|
|
821
|
+
throw new Error('Parameter `userToken` is required when calling `getUserTokenProfile`.');
|
|
822
|
+
}
|
|
823
|
+
const requestPath = '/1/profiles/personalization/{userToken}'.replace('{userToken}', encodeURIComponent(userToken));
|
|
824
|
+
const headers = {};
|
|
825
|
+
const queryParameters = {};
|
|
826
|
+
const request = {
|
|
827
|
+
method: 'GET',
|
|
828
|
+
path: requestPath,
|
|
829
|
+
queryParameters,
|
|
830
|
+
headers,
|
|
831
|
+
};
|
|
832
|
+
return transporter.request(request, requestOptions);
|
|
833
|
+
},
|
|
834
|
+
/**
|
|
835
|
+
* This method allow you to send requests to the Algolia REST API.
|
|
836
|
+
*
|
|
837
|
+
* @summary Send requests to the Algolia REST API.
|
|
838
|
+
* @param post - The post object.
|
|
839
|
+
* @param post.path - The path of the API endpoint to target, anything after the /1 needs to be specified.
|
|
840
|
+
* @param post.parameters - Query parameters to be applied to the current query.
|
|
841
|
+
* @param post.body - The parameters to send with the custom request.
|
|
842
|
+
* @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
|
|
843
|
+
*/
|
|
844
|
+
post({ path, parameters, body }, requestOptions) {
|
|
845
|
+
if (!path) {
|
|
846
|
+
throw new Error('Parameter `path` is required when calling `post`.');
|
|
847
|
+
}
|
|
848
|
+
const requestPath = '/1{path}'.replace('{path}', path);
|
|
849
|
+
const headers = {};
|
|
850
|
+
const queryParameters = parameters ? parameters : {};
|
|
851
|
+
const request = {
|
|
852
|
+
method: 'POST',
|
|
853
|
+
path: requestPath,
|
|
854
|
+
queryParameters,
|
|
855
|
+
headers,
|
|
856
|
+
data: body ? body : {},
|
|
857
|
+
};
|
|
858
|
+
return transporter.request(request, requestOptions);
|
|
859
|
+
},
|
|
860
|
+
/**
|
|
861
|
+
* This method allow you to send requests to the Algolia REST API.
|
|
862
|
+
*
|
|
863
|
+
* @summary Send requests to the Algolia REST API.
|
|
864
|
+
* @param put - The put object.
|
|
865
|
+
* @param put.path - The path of the API endpoint to target, anything after the /1 needs to be specified.
|
|
866
|
+
* @param put.parameters - Query parameters to be applied to the current query.
|
|
867
|
+
* @param put.body - The parameters to send with the custom request.
|
|
868
|
+
* @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
|
|
869
|
+
*/
|
|
870
|
+
put({ path, parameters, body }, requestOptions) {
|
|
871
|
+
if (!path) {
|
|
872
|
+
throw new Error('Parameter `path` is required when calling `put`.');
|
|
873
|
+
}
|
|
874
|
+
const requestPath = '/1{path}'.replace('{path}', path);
|
|
875
|
+
const headers = {};
|
|
876
|
+
const queryParameters = parameters ? parameters : {};
|
|
877
|
+
const request = {
|
|
878
|
+
method: 'PUT',
|
|
879
|
+
path: requestPath,
|
|
880
|
+
queryParameters,
|
|
881
|
+
headers,
|
|
882
|
+
data: body ? body : {},
|
|
883
|
+
};
|
|
884
|
+
return transporter.request(request, requestOptions);
|
|
885
|
+
},
|
|
886
|
+
/**
|
|
887
|
+
* A strategy defines the events and facets that impact user profiles and personalized search results.
|
|
888
|
+
*
|
|
889
|
+
* @summary Set a new strategy.
|
|
890
|
+
* @param personalizationStrategyParams - The personalizationStrategyParams object.
|
|
891
|
+
* @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
|
|
892
|
+
*/
|
|
893
|
+
setPersonalizationStrategy(personalizationStrategyParams, requestOptions) {
|
|
894
|
+
if (!personalizationStrategyParams) {
|
|
895
|
+
throw new Error('Parameter `personalizationStrategyParams` is required when calling `setPersonalizationStrategy`.');
|
|
896
|
+
}
|
|
897
|
+
if (!personalizationStrategyParams.eventScoring) {
|
|
898
|
+
throw new Error('Parameter `personalizationStrategyParams.eventScoring` is required when calling `setPersonalizationStrategy`.');
|
|
899
|
+
}
|
|
900
|
+
if (!personalizationStrategyParams.facetScoring) {
|
|
901
|
+
throw new Error('Parameter `personalizationStrategyParams.facetScoring` is required when calling `setPersonalizationStrategy`.');
|
|
902
|
+
}
|
|
903
|
+
if (!personalizationStrategyParams.personalizationImpact) {
|
|
904
|
+
throw new Error('Parameter `personalizationStrategyParams.personalizationImpact` is required when calling `setPersonalizationStrategy`.');
|
|
905
|
+
}
|
|
906
|
+
const requestPath = '/1/strategies/personalization';
|
|
907
|
+
const headers = {};
|
|
908
|
+
const queryParameters = {};
|
|
909
|
+
const request = {
|
|
910
|
+
method: 'POST',
|
|
911
|
+
path: requestPath,
|
|
912
|
+
queryParameters,
|
|
913
|
+
headers,
|
|
914
|
+
data: personalizationStrategyParams,
|
|
915
|
+
};
|
|
916
|
+
return transporter.request(request, requestOptions);
|
|
917
|
+
},
|
|
918
|
+
};
|
|
967
919
|
}
|
|
968
920
|
|
|
969
|
-
//
|
|
970
|
-
function personalizationClient(appId, apiKey, region, options) {
|
|
971
|
-
if (!appId || typeof appId !== 'string') {
|
|
972
|
-
throw new Error('`appId` is missing.');
|
|
973
|
-
}
|
|
974
|
-
if (!apiKey || typeof apiKey !== 'string') {
|
|
975
|
-
throw new Error('`apiKey` is missing.');
|
|
976
|
-
}
|
|
977
|
-
if (!region
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
},
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
...options,
|
|
1004
|
-
});
|
|
921
|
+
// 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.
|
|
922
|
+
function personalizationClient(appId, apiKey, region, options) {
|
|
923
|
+
if (!appId || typeof appId !== 'string') {
|
|
924
|
+
throw new Error('`appId` is missing.');
|
|
925
|
+
}
|
|
926
|
+
if (!apiKey || typeof apiKey !== 'string') {
|
|
927
|
+
throw new Error('`apiKey` is missing.');
|
|
928
|
+
}
|
|
929
|
+
if (!region ||
|
|
930
|
+
(region && (typeof region !== 'string' || !REGIONS.includes(region)))) {
|
|
931
|
+
throw new Error(`\`region\` is required and must be one of the following: ${REGIONS.join(', ')}`);
|
|
932
|
+
}
|
|
933
|
+
return createPersonalizationClient({
|
|
934
|
+
appId,
|
|
935
|
+
apiKey,
|
|
936
|
+
region,
|
|
937
|
+
timeouts: {
|
|
938
|
+
connect: DEFAULT_CONNECT_TIMEOUT_BROWSER,
|
|
939
|
+
read: DEFAULT_READ_TIMEOUT_BROWSER,
|
|
940
|
+
write: DEFAULT_WRITE_TIMEOUT_BROWSER,
|
|
941
|
+
},
|
|
942
|
+
requester: createXhrRequester(),
|
|
943
|
+
algoliaAgents: [{ segment: 'Browser' }],
|
|
944
|
+
authMode: 'WithinQueryParameters',
|
|
945
|
+
responsesCache: createMemoryCache(),
|
|
946
|
+
requestsCache: createMemoryCache({ serializable: false }),
|
|
947
|
+
hostsCache: createFallbackableCache({
|
|
948
|
+
caches: [
|
|
949
|
+
createBrowserLocalStorageCache({ key: `${apiClientVersion}-${appId}` }),
|
|
950
|
+
createMemoryCache(),
|
|
951
|
+
],
|
|
952
|
+
}),
|
|
953
|
+
...options,
|
|
954
|
+
});
|
|
1005
955
|
}
|
|
1006
956
|
|
|
1007
957
|
export { apiClientVersion, personalizationClient };
|