@algolia/client-personalization 5.0.0-alpha.9 → 5.0.0-alpha.91
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 → client-personalization.cjs} +283 -285
- package/dist/client-personalization.esm.browser.js +465 -515
- package/dist/client-personalization.esm.node.js +283 -283
- 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/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/index.js +1 -1
- package/model/clientMethodProps.ts +11 -11
- 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 +30 -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,53 +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
|
-
const queryParameters = {
|
|
399
|
+
const queryParameters = {
|
|
400
|
+
...baseQueryParameters,
|
|
419
401
|
...request.queryParameters,
|
|
420
402
|
...dataQueryParameters
|
|
421
403
|
};
|
|
422
|
-
|
|
423
404
|
if (algoliaAgent.value) {
|
|
424
405
|
queryParameters['x-algolia-agent'] = algoliaAgent.value;
|
|
425
406
|
}
|
|
426
|
-
|
|
427
407
|
if (requestOptions && requestOptions.queryParameters) {
|
|
428
408
|
for (const key of Object.keys(requestOptions.queryParameters)) {
|
|
429
409
|
// We want to keep `undefined` and `null` values,
|
|
@@ -436,25 +416,19 @@ function createTransporter({
|
|
|
436
416
|
}
|
|
437
417
|
}
|
|
438
418
|
}
|
|
439
|
-
|
|
440
419
|
let timeoutsCount = 0;
|
|
441
|
-
|
|
442
420
|
const retry = async (retryableHosts, getTimeout) => {
|
|
443
|
-
/**
|
|
444
|
-
* We iterate on each host, until there is no host left.
|
|
421
|
+
/**
|
|
422
|
+
* We iterate on each host, until there is no host left.
|
|
445
423
|
*/
|
|
446
424
|
const host = retryableHosts.pop();
|
|
447
|
-
|
|
448
425
|
if (host === undefined) {
|
|
449
426
|
throw new RetryError(stackTraceWithoutCredentials(stackTrace));
|
|
450
427
|
}
|
|
451
|
-
|
|
452
428
|
let responseTimeout = requestOptions.timeout;
|
|
453
|
-
|
|
454
429
|
if (responseTimeout === undefined) {
|
|
455
430
|
responseTimeout = isRead ? timeouts.read : timeouts.write;
|
|
456
431
|
}
|
|
457
|
-
|
|
458
432
|
const payload = {
|
|
459
433
|
data,
|
|
460
434
|
headers,
|
|
@@ -463,12 +437,11 @@ function createTransporter({
|
|
|
463
437
|
connectTimeout: getTimeout(timeoutsCount, timeouts.connect),
|
|
464
438
|
responseTimeout: getTimeout(timeoutsCount, responseTimeout)
|
|
465
439
|
};
|
|
466
|
-
/**
|
|
467
|
-
* The stackFrame is pushed to the stackTrace so we
|
|
468
|
-
* can have information about onRetry and onFailure
|
|
469
|
-
* decisions.
|
|
440
|
+
/**
|
|
441
|
+
* The stackFrame is pushed to the stackTrace so we
|
|
442
|
+
* can have information about onRetry and onFailure
|
|
443
|
+
* decisions.
|
|
470
444
|
*/
|
|
471
|
-
|
|
472
445
|
const pushToStackTrace = response => {
|
|
473
446
|
const stackFrame = {
|
|
474
447
|
request: payload,
|
|
@@ -479,102 +452,85 @@ function createTransporter({
|
|
|
479
452
|
stackTrace.push(stackFrame);
|
|
480
453
|
return stackFrame;
|
|
481
454
|
};
|
|
482
|
-
|
|
483
455
|
const response = await requester.send(payload);
|
|
484
|
-
|
|
485
456
|
if (isRetryable(response)) {
|
|
486
|
-
const stackFrame = pushToStackTrace(response);
|
|
487
|
-
|
|
457
|
+
const stackFrame = pushToStackTrace(response);
|
|
458
|
+
// If response is a timeout, we increase the number of timeouts so we can increase the timeout later.
|
|
488
459
|
if (response.isTimedOut) {
|
|
489
460
|
timeoutsCount++;
|
|
490
461
|
}
|
|
491
|
-
/**
|
|
492
|
-
* Failures are individually sent to the logger, allowing
|
|
493
|
-
* the end user to debug / store stack frames even
|
|
494
|
-
* 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.
|
|
495
466
|
*/
|
|
496
467
|
// eslint-disable-next-line no-console -- this will be fixed by exposing a `logger` to the transporter
|
|
497
|
-
|
|
498
|
-
|
|
499
468
|
console.log('Retryable failure', stackFrameWithoutCredentials(stackFrame));
|
|
500
|
-
/**
|
|
501
|
-
* We also store the state of the host in failure cases. If the host, is
|
|
502
|
-
* down it will remain down for the next 2 minutes. In a timeout situation,
|
|
503
|
-
* 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.
|
|
504
473
|
*/
|
|
505
|
-
|
|
506
474
|
await hostsCache.set(host, createStatefulHost(host, response.isTimedOut ? 'timed out' : 'down'));
|
|
507
475
|
return retry(retryableHosts, getTimeout);
|
|
508
476
|
}
|
|
509
|
-
|
|
510
477
|
if (isSuccess(response)) {
|
|
511
478
|
return deserializeSuccess(response);
|
|
512
479
|
}
|
|
513
|
-
|
|
514
480
|
pushToStackTrace(response);
|
|
515
481
|
throw deserializeFailure(response, stackTrace);
|
|
516
482
|
};
|
|
517
|
-
/**
|
|
518
|
-
* Finally, for each retryable host perform request until we got a non
|
|
519
|
-
* retryable response. Some notes here:
|
|
520
|
-
*
|
|
521
|
-
* 1. The reverse here is applied so we can apply a `pop` later on => more performant.
|
|
522
|
-
* 2. We also get from the retryable options a timeout multiplier that is tailored
|
|
523
|
-
* 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.
|
|
524
490
|
*/
|
|
525
|
-
|
|
526
|
-
|
|
527
491
|
const compatibleHosts = hosts.filter(host => host.accept === 'readWrite' || (isRead ? host.accept === 'read' : host.accept === 'write'));
|
|
528
492
|
const options = await createRetryableOptions(compatibleHosts);
|
|
529
493
|
return retry([...options.hosts].reverse(), options.getTimeout);
|
|
530
494
|
}
|
|
531
|
-
|
|
532
495
|
function createRequest(request, requestOptions = {}) {
|
|
533
|
-
/**
|
|
534
|
-
* A read request is either a `GET` request, or a request that we make
|
|
535
|
-
* 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`).
|
|
536
499
|
*/
|
|
537
500
|
const isRead = request.useReadTransporter || request.method === 'GET';
|
|
538
|
-
|
|
539
501
|
if (!isRead) {
|
|
540
|
-
/**
|
|
541
|
-
* On write requests, no cache mechanisms are applied, and we
|
|
542
|
-
* 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.
|
|
543
505
|
*/
|
|
544
506
|
return retryableRequest(request, requestOptions, isRead);
|
|
545
507
|
}
|
|
546
|
-
|
|
547
508
|
const createRetryableRequest = () => {
|
|
548
|
-
/**
|
|
549
|
-
* Then, we prepare a function factory that contains the construction of
|
|
550
|
-
* the retryable request. At this point, we may *not* perform the actual
|
|
551
|
-
* 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.
|
|
552
513
|
*/
|
|
553
514
|
return retryableRequest(request, requestOptions);
|
|
554
515
|
};
|
|
555
|
-
/**
|
|
556
|
-
* Once we have the function factory ready, we need to determine of the
|
|
557
|
-
* request is "cacheable" - should be cached. Note that, once again,
|
|
558
|
-
* 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.
|
|
559
520
|
*/
|
|
560
|
-
|
|
561
|
-
|
|
562
521
|
const cacheable = requestOptions.cacheable || request.cacheable;
|
|
563
|
-
/**
|
|
564
|
-
* If is not "cacheable", we immediately trigger the retryable request, no
|
|
565
|
-
* need to check cache implementations.
|
|
522
|
+
/**
|
|
523
|
+
* If is not "cacheable", we immediately trigger the retryable request, no
|
|
524
|
+
* need to check cache implementations.
|
|
566
525
|
*/
|
|
567
|
-
|
|
568
526
|
if (cacheable !== true) {
|
|
569
527
|
return createRetryableRequest();
|
|
570
528
|
}
|
|
571
|
-
/**
|
|
572
|
-
* If the request is "cacheable", we need to first compute the key to ask
|
|
573
|
-
* the cache implementations if this request is on progress or if the
|
|
574
|
-
* 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.
|
|
575
533
|
*/
|
|
576
|
-
|
|
577
|
-
|
|
578
534
|
const key = {
|
|
579
535
|
request,
|
|
580
536
|
requestOptions,
|
|
@@ -583,33 +539,31 @@ function createTransporter({
|
|
|
583
539
|
headers: baseHeaders
|
|
584
540
|
}
|
|
585
541
|
};
|
|
586
|
-
/**
|
|
587
|
-
* With the computed key, we first ask the responses cache
|
|
588
|
-
* 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.
|
|
589
545
|
*/
|
|
590
|
-
|
|
591
546
|
return responsesCache.get(key, () => {
|
|
592
|
-
/**
|
|
593
|
-
* If the request has never resolved before, we actually ask if there
|
|
594
|
-
* 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.
|
|
595
550
|
*/
|
|
596
551
|
return requestsCache.get(key, () =>
|
|
597
|
-
/**
|
|
598
|
-
* Finally, if there is no request in progress with the same key,
|
|
599
|
-
* this `createRetryableRequest()` will actually trigger the
|
|
600
|
-
* 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.
|
|
601
556
|
*/
|
|
602
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));
|
|
603
558
|
}, {
|
|
604
|
-
/**
|
|
605
|
-
* Of course, once we get this response back from the server, we
|
|
606
|
-
* tell response cache to actually store the received response
|
|
607
|
-
* 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.
|
|
608
563
|
*/
|
|
609
564
|
miss: response => responsesCache.set(key, response)
|
|
610
565
|
});
|
|
611
566
|
}
|
|
612
|
-
|
|
613
567
|
return {
|
|
614
568
|
hostsCache,
|
|
615
569
|
requester,
|
|
@@ -627,17 +581,13 @@ function createTransporter({
|
|
|
627
581
|
function createAlgoliaAgent(version) {
|
|
628
582
|
const algoliaAgent = {
|
|
629
583
|
value: `Algolia for JavaScript (${version})`,
|
|
630
|
-
|
|
631
584
|
add(options) {
|
|
632
585
|
const addedAlgoliaAgent = `; ${options.segment}${options.version !== undefined ? ` (${options.version})` : ''}`;
|
|
633
|
-
|
|
634
586
|
if (algoliaAgent.value.indexOf(addedAlgoliaAgent) === -1) {
|
|
635
587
|
algoliaAgent.value = `${algoliaAgent.value}${addedAlgoliaAgent}`;
|
|
636
588
|
}
|
|
637
|
-
|
|
638
589
|
return algoliaAgent;
|
|
639
590
|
}
|
|
640
|
-
|
|
641
591
|
};
|
|
642
592
|
return algoliaAgent;
|
|
643
593
|
}
|
|
@@ -659,349 +609,349 @@ const DEFAULT_CONNECT_TIMEOUT_BROWSER = 1000;
|
|
|
659
609
|
const DEFAULT_READ_TIMEOUT_BROWSER = 2000;
|
|
660
610
|
const DEFAULT_WRITE_TIMEOUT_BROWSER = 30000;
|
|
661
611
|
|
|
662
|
-
function createXhrRequester() {
|
|
663
|
-
function send(request) {
|
|
664
|
-
return new Promise((resolve) => {
|
|
665
|
-
const baseRequester = new XMLHttpRequest();
|
|
666
|
-
baseRequester.open(request.method, request.url, true);
|
|
667
|
-
Object.keys(request.headers).forEach((key) => baseRequester.setRequestHeader(key, request.headers[key]));
|
|
668
|
-
const createTimeout = (timeout, content) => {
|
|
669
|
-
return setTimeout(() => {
|
|
670
|
-
baseRequester.abort();
|
|
671
|
-
resolve({
|
|
672
|
-
status: 0,
|
|
673
|
-
content,
|
|
674
|
-
isTimedOut: true,
|
|
675
|
-
});
|
|
676
|
-
}, timeout);
|
|
677
|
-
};
|
|
678
|
-
const connectTimeout = createTimeout(request.connectTimeout, 'Connection timeout');
|
|
679
|
-
let responseTimeout;
|
|
680
|
-
baseRequester.onreadystatechange = () => {
|
|
681
|
-
if (baseRequester.readyState > baseRequester.OPENED &&
|
|
682
|
-
responseTimeout === undefined) {
|
|
683
|
-
clearTimeout(connectTimeout);
|
|
684
|
-
responseTimeout = createTimeout(request.responseTimeout, 'Socket timeout');
|
|
685
|
-
}
|
|
686
|
-
};
|
|
687
|
-
baseRequester.onerror = () => {
|
|
688
|
-
// istanbul ignore next
|
|
689
|
-
if (baseRequester.status === 0) {
|
|
690
|
-
clearTimeout(connectTimeout);
|
|
691
|
-
clearTimeout(responseTimeout);
|
|
692
|
-
resolve({
|
|
693
|
-
content: baseRequester.responseText || 'Network request failed',
|
|
694
|
-
status: baseRequester.status,
|
|
695
|
-
isTimedOut: false,
|
|
696
|
-
});
|
|
697
|
-
}
|
|
698
|
-
};
|
|
699
|
-
baseRequester.onload = () => {
|
|
700
|
-
clearTimeout(connectTimeout);
|
|
701
|
-
clearTimeout(responseTimeout);
|
|
702
|
-
resolve({
|
|
703
|
-
content: baseRequester.responseText,
|
|
704
|
-
status: baseRequester.status,
|
|
705
|
-
isTimedOut: false,
|
|
706
|
-
});
|
|
707
|
-
};
|
|
708
|
-
baseRequester.send(request.data);
|
|
709
|
-
});
|
|
710
|
-
}
|
|
711
|
-
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 };
|
|
712
662
|
}
|
|
713
663
|
|
|
714
|
-
//
|
|
715
|
-
const apiClientVersion = '5.0.0-alpha.
|
|
716
|
-
const REGIONS = ['eu', 'us'];
|
|
717
|
-
function getDefaultHosts(region) {
|
|
718
|
-
const url = 'personalization.{region}.algolia.com'.replace('{region}', region);
|
|
719
|
-
return [{ url, accept: 'readWrite', protocol: 'https' }];
|
|
720
|
-
}
|
|
721
|
-
// eslint-disable-next-line @typescript-eslint/explicit-function-return-type
|
|
722
|
-
function createPersonalizationClient({ appId: appIdOption, apiKey: apiKeyOption, authMode, algoliaAgents, region: regionOption, ...options }) {
|
|
723
|
-
const auth = createAuth(appIdOption, apiKeyOption, authMode);
|
|
724
|
-
const transporter = createTransporter({
|
|
725
|
-
hosts: getDefaultHosts(regionOption),
|
|
726
|
-
...options,
|
|
727
|
-
algoliaAgent: getAlgoliaAgent({
|
|
728
|
-
algoliaAgents,
|
|
729
|
-
client: 'Personalization',
|
|
730
|
-
version: apiClientVersion,
|
|
731
|
-
}),
|
|
732
|
-
baseHeaders: {
|
|
733
|
-
'content-type': 'text/plain',
|
|
734
|
-
...auth.headers(),
|
|
735
|
-
...options.baseHeaders,
|
|
736
|
-
},
|
|
737
|
-
baseQueryParameters: {
|
|
738
|
-
...auth.queryParameters(),
|
|
739
|
-
...options.baseQueryParameters,
|
|
740
|
-
},
|
|
741
|
-
});
|
|
742
|
-
return {
|
|
743
|
-
transporter,
|
|
744
|
-
/**
|
|
745
|
-
* The `appId` currently in use.
|
|
746
|
-
*/
|
|
747
|
-
appId: appIdOption,
|
|
748
|
-
/**
|
|
749
|
-
* Clears the cache of the transporter for the `requestsCache` and `responsesCache` properties.
|
|
750
|
-
*/
|
|
751
|
-
clearCache() {
|
|
752
|
-
return Promise.all([
|
|
753
|
-
transporter.requestsCache.clear(),
|
|
754
|
-
transporter.responsesCache.clear(),
|
|
755
|
-
]).then(() => undefined);
|
|
756
|
-
},
|
|
757
|
-
/**
|
|
758
|
-
* Get the value of the `algoliaAgent`, used by our libraries internally and telemetry system.
|
|
759
|
-
*/
|
|
760
|
-
get _ua() {
|
|
761
|
-
return transporter.algoliaAgent.value;
|
|
762
|
-
},
|
|
763
|
-
/**
|
|
764
|
-
* Adds a `segment` to the `x-algolia-agent` sent with every requests.
|
|
765
|
-
*
|
|
766
|
-
* @param segment - The algolia agent (user-agent) segment to add.
|
|
767
|
-
* @param version - The version of the agent.
|
|
768
|
-
*/
|
|
769
|
-
addAlgoliaAgent(segment, version) {
|
|
770
|
-
transporter.algoliaAgent.add({ segment, version });
|
|
771
|
-
},
|
|
772
|
-
/**
|
|
773
|
-
* This method allow you to send requests to the Algolia REST API.
|
|
774
|
-
*
|
|
775
|
-
* @summary Send requests to the Algolia REST API.
|
|
776
|
-
* @param del - The del object.
|
|
777
|
-
* @param del.path -
|
|
778
|
-
* @param del.parameters - Query parameters to
|
|
779
|
-
* @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
|
|
780
|
-
*/
|
|
781
|
-
del({ path, parameters }, requestOptions) {
|
|
782
|
-
if (!path) {
|
|
783
|
-
throw new Error('Parameter `path` is required when calling `del`.');
|
|
784
|
-
}
|
|
785
|
-
const requestPath = '/1{path}'.replace('{path}', path);
|
|
786
|
-
const headers = {};
|
|
787
|
-
const queryParameters = parameters ? parameters : {};
|
|
788
|
-
const request = {
|
|
789
|
-
method: 'DELETE',
|
|
790
|
-
path: requestPath,
|
|
791
|
-
queryParameters,
|
|
792
|
-
headers,
|
|
793
|
-
};
|
|
794
|
-
return transporter.request(request, requestOptions);
|
|
795
|
-
},
|
|
796
|
-
/**
|
|
797
|
-
* 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.
|
|
798
|
-
*
|
|
799
|
-
* @summary Delete a user profile.
|
|
800
|
-
* @param deleteUserProfile - The deleteUserProfile object.
|
|
801
|
-
* @param deleteUserProfile.userToken - UserToken representing the user for which to fetch the Personalization profile.
|
|
802
|
-
* @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
|
|
803
|
-
*/
|
|
804
|
-
deleteUserProfile({ userToken }, requestOptions) {
|
|
805
|
-
if (!userToken) {
|
|
806
|
-
throw new Error('Parameter `userToken` is required when calling `deleteUserProfile`.');
|
|
807
|
-
}
|
|
808
|
-
const requestPath = '/1/profiles/{userToken}'.replace('{userToken}', encodeURIComponent(userToken));
|
|
809
|
-
const headers = {};
|
|
810
|
-
const queryParameters = {};
|
|
811
|
-
const request = {
|
|
812
|
-
method: 'DELETE',
|
|
813
|
-
path: requestPath,
|
|
814
|
-
queryParameters,
|
|
815
|
-
headers,
|
|
816
|
-
};
|
|
817
|
-
return transporter.request(request, requestOptions);
|
|
818
|
-
},
|
|
819
|
-
/**
|
|
820
|
-
* This method allow you to send requests to the Algolia REST API.
|
|
821
|
-
*
|
|
822
|
-
* @summary Send requests to the Algolia REST API.
|
|
823
|
-
* @param get - The get object.
|
|
824
|
-
* @param get.path -
|
|
825
|
-
* @param get.parameters - Query parameters to
|
|
826
|
-
* @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
|
|
827
|
-
*/
|
|
828
|
-
get({ path, parameters }, requestOptions) {
|
|
829
|
-
if (!path) {
|
|
830
|
-
throw new Error('Parameter `path` is required when calling `get`.');
|
|
831
|
-
}
|
|
832
|
-
const requestPath = '/1{path}'.replace('{path}', path);
|
|
833
|
-
const headers = {};
|
|
834
|
-
const queryParameters = parameters ? parameters : {};
|
|
835
|
-
const request = {
|
|
836
|
-
method: 'GET',
|
|
837
|
-
path: requestPath,
|
|
838
|
-
queryParameters,
|
|
839
|
-
headers,
|
|
840
|
-
};
|
|
841
|
-
return transporter.request(request, requestOptions);
|
|
842
|
-
},
|
|
843
|
-
/**
|
|
844
|
-
* The strategy contains information on the events and facets that impact user profiles and personalized search results.
|
|
845
|
-
*
|
|
846
|
-
* @summary Get the current strategy.
|
|
847
|
-
* @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
|
|
848
|
-
*/
|
|
849
|
-
getPersonalizationStrategy(requestOptions) {
|
|
850
|
-
const requestPath = '/1/strategies/personalization';
|
|
851
|
-
const headers = {};
|
|
852
|
-
const queryParameters = {};
|
|
853
|
-
const request = {
|
|
854
|
-
method: 'GET',
|
|
855
|
-
path: requestPath,
|
|
856
|
-
queryParameters,
|
|
857
|
-
headers,
|
|
858
|
-
};
|
|
859
|
-
return transporter.request(request, requestOptions);
|
|
860
|
-
},
|
|
861
|
-
/**
|
|
862
|
-
* 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.
|
|
863
|
-
*
|
|
864
|
-
* @summary Get a user profile.
|
|
865
|
-
* @param getUserTokenProfile - The getUserTokenProfile object.
|
|
866
|
-
* @param getUserTokenProfile.userToken - UserToken representing the user for which to fetch the Personalization profile.
|
|
867
|
-
* @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
|
|
868
|
-
*/
|
|
869
|
-
getUserTokenProfile({ userToken }, requestOptions) {
|
|
870
|
-
if (!userToken) {
|
|
871
|
-
throw new Error('Parameter `userToken` is required when calling `getUserTokenProfile`.');
|
|
872
|
-
}
|
|
873
|
-
const requestPath = '/1/profiles/personalization/{userToken}'.replace('{userToken}', encodeURIComponent(userToken));
|
|
874
|
-
const headers = {};
|
|
875
|
-
const queryParameters = {};
|
|
876
|
-
const request = {
|
|
877
|
-
method: 'GET',
|
|
878
|
-
path: requestPath,
|
|
879
|
-
queryParameters,
|
|
880
|
-
headers,
|
|
881
|
-
};
|
|
882
|
-
return transporter.request(request, requestOptions);
|
|
883
|
-
},
|
|
884
|
-
/**
|
|
885
|
-
* This method allow you to send requests to the Algolia REST API.
|
|
886
|
-
*
|
|
887
|
-
* @summary Send requests to the Algolia REST API.
|
|
888
|
-
* @param post - The post object.
|
|
889
|
-
* @param post.path -
|
|
890
|
-
* @param post.parameters - Query parameters to
|
|
891
|
-
* @param post.body -
|
|
892
|
-
* @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
|
|
893
|
-
*/
|
|
894
|
-
post({ path, parameters, body }, requestOptions) {
|
|
895
|
-
if (!path) {
|
|
896
|
-
throw new Error('Parameter `path` is required when calling `post`.');
|
|
897
|
-
}
|
|
898
|
-
const requestPath = '/1{path}'.replace('{path}', path);
|
|
899
|
-
const headers = {};
|
|
900
|
-
const queryParameters = parameters ? parameters : {};
|
|
901
|
-
const request = {
|
|
902
|
-
method: 'POST',
|
|
903
|
-
path: requestPath,
|
|
904
|
-
queryParameters,
|
|
905
|
-
headers,
|
|
906
|
-
data: body ? body : {},
|
|
907
|
-
};
|
|
908
|
-
return transporter.request(request, requestOptions);
|
|
909
|
-
},
|
|
910
|
-
/**
|
|
911
|
-
* This method allow you to send requests to the Algolia REST API.
|
|
912
|
-
*
|
|
913
|
-
* @summary Send requests to the Algolia REST API.
|
|
914
|
-
* @param put - The put object.
|
|
915
|
-
* @param put.path -
|
|
916
|
-
* @param put.parameters - Query parameters to
|
|
917
|
-
* @param put.body -
|
|
918
|
-
* @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
|
|
919
|
-
*/
|
|
920
|
-
put({ path, parameters, body }, requestOptions) {
|
|
921
|
-
if (!path) {
|
|
922
|
-
throw new Error('Parameter `path` is required when calling `put`.');
|
|
923
|
-
}
|
|
924
|
-
const requestPath = '/1{path}'.replace('{path}', path);
|
|
925
|
-
const headers = {};
|
|
926
|
-
const queryParameters = parameters ? parameters : {};
|
|
927
|
-
const request = {
|
|
928
|
-
method: 'PUT',
|
|
929
|
-
path: requestPath,
|
|
930
|
-
queryParameters,
|
|
931
|
-
headers,
|
|
932
|
-
data: body ? body : {},
|
|
933
|
-
};
|
|
934
|
-
return transporter.request(request, requestOptions);
|
|
935
|
-
},
|
|
936
|
-
/**
|
|
937
|
-
* A strategy defines the events and facets that impact user profiles and personalized search results.
|
|
938
|
-
*
|
|
939
|
-
* @summary Set a new strategy.
|
|
940
|
-
* @param personalizationStrategyParams - The personalizationStrategyParams object.
|
|
941
|
-
* @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
|
|
942
|
-
*/
|
|
943
|
-
setPersonalizationStrategy(personalizationStrategyParams, requestOptions) {
|
|
944
|
-
if (!personalizationStrategyParams) {
|
|
945
|
-
throw new Error('Parameter `personalizationStrategyParams` is required when calling `setPersonalizationStrategy`.');
|
|
946
|
-
}
|
|
947
|
-
if (!personalizationStrategyParams.eventScoring) {
|
|
948
|
-
throw new Error('Parameter `personalizationStrategyParams.eventScoring` is required when calling `setPersonalizationStrategy`.');
|
|
949
|
-
}
|
|
950
|
-
if (!personalizationStrategyParams.facetScoring) {
|
|
951
|
-
throw new Error('Parameter `personalizationStrategyParams.facetScoring` is required when calling `setPersonalizationStrategy`.');
|
|
952
|
-
}
|
|
953
|
-
if (!personalizationStrategyParams.personalizationImpact) {
|
|
954
|
-
throw new Error('Parameter `personalizationStrategyParams.personalizationImpact` is required when calling `setPersonalizationStrategy`.');
|
|
955
|
-
}
|
|
956
|
-
const requestPath = '/1/strategies/personalization';
|
|
957
|
-
const headers = {};
|
|
958
|
-
const queryParameters = {};
|
|
959
|
-
const request = {
|
|
960
|
-
method: 'POST',
|
|
961
|
-
path: requestPath,
|
|
962
|
-
queryParameters,
|
|
963
|
-
headers,
|
|
964
|
-
data: personalizationStrategyParams,
|
|
965
|
-
};
|
|
966
|
-
return transporter.request(request, requestOptions);
|
|
967
|
-
},
|
|
968
|
-
};
|
|
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.91';
|
|
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 - Path of the endpoint, anything after \"/1\" must be specified.
|
|
728
|
+
* @param del.parameters - Query parameters to apply 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 - Path of the endpoint, anything after \"/1\" must be specified.
|
|
775
|
+
* @param get.parameters - Query parameters to apply 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 - Path of the endpoint, anything after \"/1\" must be specified.
|
|
840
|
+
* @param post.parameters - Query parameters to apply to the current query.
|
|
841
|
+
* @param post.body - 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 - Path of the endpoint, anything after \"/1\" must be specified.
|
|
866
|
+
* @param put.parameters - Query parameters to apply to the current query.
|
|
867
|
+
* @param put.body - 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
|
+
};
|
|
969
919
|
}
|
|
970
920
|
|
|
971
|
-
//
|
|
972
|
-
function personalizationClient(appId, apiKey, region, options) {
|
|
973
|
-
if (!appId || typeof appId !== 'string') {
|
|
974
|
-
throw new Error('`appId` is missing.');
|
|
975
|
-
}
|
|
976
|
-
if (!apiKey || typeof apiKey !== 'string') {
|
|
977
|
-
throw new Error('`apiKey` is missing.');
|
|
978
|
-
}
|
|
979
|
-
if (!region ||
|
|
980
|
-
(region && (typeof region !== 'string' || !REGIONS.includes(region)))) {
|
|
981
|
-
throw new Error(`\`region\` is required and must be one of the following: ${REGIONS.join(', ')}`);
|
|
982
|
-
}
|
|
983
|
-
return createPersonalizationClient({
|
|
984
|
-
appId,
|
|
985
|
-
apiKey,
|
|
986
|
-
region,
|
|
987
|
-
timeouts: {
|
|
988
|
-
connect: DEFAULT_CONNECT_TIMEOUT_BROWSER,
|
|
989
|
-
read: DEFAULT_READ_TIMEOUT_BROWSER,
|
|
990
|
-
write: DEFAULT_WRITE_TIMEOUT_BROWSER,
|
|
991
|
-
},
|
|
992
|
-
requester: createXhrRequester(),
|
|
993
|
-
algoliaAgents: [{ segment: 'Browser' }],
|
|
994
|
-
authMode: 'WithinQueryParameters',
|
|
995
|
-
responsesCache: createMemoryCache(),
|
|
996
|
-
requestsCache: createMemoryCache({ serializable: false }),
|
|
997
|
-
hostsCache: createFallbackableCache({
|
|
998
|
-
caches: [
|
|
999
|
-
createBrowserLocalStorageCache({ key: `${apiClientVersion}-${appId}` }),
|
|
1000
|
-
createMemoryCache(),
|
|
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 };
|