@algolia/client-personalization 5.0.0-alpha.53 → 5.0.0-alpha.55
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/node.d.ts +5 -5
- package/dist/client-personalization.cjs.js +283 -283
- package/dist/client-personalization.esm.browser.js +407 -407
- 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/deleteUserProfileResponse.d.ts +10 -10
- package/dist/model/errorBase.d.ts +6 -6
- package/dist/model/eventScoring.d.ts +14 -14
- package/dist/model/facetScoring.d.ts +10 -10
- package/dist/model/getUserTokenResponse.d.ts +14 -14
- package/dist/model/index.d.ts +8 -8
- package/dist/model/personalizationStrategyParams.d.ts +16 -16
- package/dist/model/setPersonalizationStrategyResponse.d.ts +6 -6
- package/dist/src/personalizationClient.d.ts +112 -112
- 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 +6 -6
|
@@ -368,16 +368,16 @@ function createTransporter({
|
|
|
368
368
|
return {
|
|
369
369
|
hosts: compatibleHostsAvailable,
|
|
370
370
|
getTimeout(timeoutsCount, baseTimeout) {
|
|
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.
|
|
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.
|
|
381
381
|
*/
|
|
382
382
|
const timeoutMultiplier = hostsTimedOut.length === 0 && timeoutsCount === 0 ? 1 : hostsTimedOut.length + 3 + timeoutsCount;
|
|
383
383
|
return timeoutMultiplier * baseTimeout;
|
|
@@ -386,8 +386,8 @@ function createTransporter({
|
|
|
386
386
|
}
|
|
387
387
|
async function retryableRequest(request, requestOptions, isRead = true) {
|
|
388
388
|
const stackTrace = [];
|
|
389
|
-
/**
|
|
390
|
-
* First we prepare the payload that do not depend from hosts.
|
|
389
|
+
/**
|
|
390
|
+
* First we prepare the payload that do not depend from hosts.
|
|
391
391
|
*/
|
|
392
392
|
const data = serializeData(request, requestOptions);
|
|
393
393
|
const headers = serializeHeaders(baseHeaders, request.headers, requestOptions.headers);
|
|
@@ -418,8 +418,8 @@ function createTransporter({
|
|
|
418
418
|
}
|
|
419
419
|
let timeoutsCount = 0;
|
|
420
420
|
const retry = async (retryableHosts, getTimeout) => {
|
|
421
|
-
/**
|
|
422
|
-
* We iterate on each host, until there is no host left.
|
|
421
|
+
/**
|
|
422
|
+
* We iterate on each host, until there is no host left.
|
|
423
423
|
*/
|
|
424
424
|
const host = retryableHosts.pop();
|
|
425
425
|
if (host === undefined) {
|
|
@@ -437,10 +437,10 @@ function createTransporter({
|
|
|
437
437
|
connectTimeout: getTimeout(timeoutsCount, timeouts.connect),
|
|
438
438
|
responseTimeout: getTimeout(timeoutsCount, responseTimeout)
|
|
439
439
|
};
|
|
440
|
-
/**
|
|
441
|
-
* The stackFrame is pushed to the stackTrace so we
|
|
442
|
-
* can have information about onRetry and onFailure
|
|
443
|
-
* decisions.
|
|
440
|
+
/**
|
|
441
|
+
* The stackFrame is pushed to the stackTrace so we
|
|
442
|
+
* can have information about onRetry and onFailure
|
|
443
|
+
* decisions.
|
|
444
444
|
*/
|
|
445
445
|
const pushToStackTrace = response => {
|
|
446
446
|
const stackFrame = {
|
|
@@ -459,17 +459,17 @@ function createTransporter({
|
|
|
459
459
|
if (response.isTimedOut) {
|
|
460
460
|
timeoutsCount++;
|
|
461
461
|
}
|
|
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.
|
|
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.
|
|
466
466
|
*/
|
|
467
467
|
// eslint-disable-next-line no-console -- this will be fixed by exposing a `logger` to the transporter
|
|
468
468
|
console.log('Retryable failure', stackFrameWithoutCredentials(stackFrame));
|
|
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.
|
|
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.
|
|
473
473
|
*/
|
|
474
474
|
await hostsCache.set(host, createStatefulHost(host, response.isTimedOut ? 'timed out' : 'down'));
|
|
475
475
|
return retry(retryableHosts, getTimeout);
|
|
@@ -480,56 +480,56 @@ function createTransporter({
|
|
|
480
480
|
pushToStackTrace(response);
|
|
481
481
|
throw deserializeFailure(response, stackTrace);
|
|
482
482
|
};
|
|
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.
|
|
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.
|
|
490
490
|
*/
|
|
491
491
|
const compatibleHosts = hosts.filter(host => host.accept === 'readWrite' || (isRead ? host.accept === 'read' : host.accept === 'write'));
|
|
492
492
|
const options = await createRetryableOptions(compatibleHosts);
|
|
493
493
|
return retry([...options.hosts].reverse(), options.getTimeout);
|
|
494
494
|
}
|
|
495
495
|
function createRequest(request, requestOptions = {}) {
|
|
496
|
-
/**
|
|
497
|
-
* A read request is either a `GET` request, or a request that we make
|
|
498
|
-
* 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`).
|
|
499
499
|
*/
|
|
500
500
|
const isRead = request.useReadTransporter || request.method === 'GET';
|
|
501
501
|
if (!isRead) {
|
|
502
|
-
/**
|
|
503
|
-
* On write requests, no cache mechanisms are applied, and we
|
|
504
|
-
* 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.
|
|
505
505
|
*/
|
|
506
506
|
return retryableRequest(request, requestOptions, isRead);
|
|
507
507
|
}
|
|
508
508
|
const createRetryableRequest = () => {
|
|
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.
|
|
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.
|
|
513
513
|
*/
|
|
514
514
|
return retryableRequest(request, requestOptions);
|
|
515
515
|
};
|
|
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.
|
|
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.
|
|
520
520
|
*/
|
|
521
521
|
const cacheable = requestOptions.cacheable || request.cacheable;
|
|
522
|
-
/**
|
|
523
|
-
* If is not "cacheable", we immediately trigger the retryable request, no
|
|
524
|
-
* need to check cache implementations.
|
|
522
|
+
/**
|
|
523
|
+
* If is not "cacheable", we immediately trigger the retryable request, no
|
|
524
|
+
* need to check cache implementations.
|
|
525
525
|
*/
|
|
526
526
|
if (cacheable !== true) {
|
|
527
527
|
return createRetryableRequest();
|
|
528
528
|
}
|
|
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.
|
|
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.
|
|
533
533
|
*/
|
|
534
534
|
const key = {
|
|
535
535
|
request,
|
|
@@ -539,27 +539,27 @@ function createTransporter({
|
|
|
539
539
|
headers: baseHeaders
|
|
540
540
|
}
|
|
541
541
|
};
|
|
542
|
-
/**
|
|
543
|
-
* With the computed key, we first ask the responses cache
|
|
544
|
-
* 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.
|
|
545
545
|
*/
|
|
546
546
|
return responsesCache.get(key, () => {
|
|
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.
|
|
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.
|
|
550
550
|
*/
|
|
551
551
|
return requestsCache.get(key, () =>
|
|
552
|
-
/**
|
|
553
|
-
* Finally, if there is no request in progress with the same key,
|
|
554
|
-
* this `createRetryableRequest()` will actually trigger the
|
|
555
|
-
* 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.
|
|
556
556
|
*/
|
|
557
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));
|
|
558
558
|
}, {
|
|
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.
|
|
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.
|
|
563
563
|
*/
|
|
564
564
|
miss: response => responsesCache.set(key, response)
|
|
565
565
|
});
|
|
@@ -609,349 +609,349 @@ const DEFAULT_CONNECT_TIMEOUT_BROWSER = 1000;
|
|
|
609
609
|
const DEFAULT_READ_TIMEOUT_BROWSER = 2000;
|
|
610
610
|
const DEFAULT_WRITE_TIMEOUT_BROWSER = 30000;
|
|
611
611
|
|
|
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 };
|
|
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 };
|
|
662
662
|
}
|
|
663
663
|
|
|
664
|
-
//
|
|
665
|
-
const apiClientVersion = '5.0.0-alpha.
|
|
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
|
-
};
|
|
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.55';
|
|
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
|
+
};
|
|
919
919
|
}
|
|
920
920
|
|
|
921
|
-
//
|
|
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
|
-
});
|
|
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
|
+
});
|
|
955
955
|
}
|
|
956
956
|
|
|
957
957
|
export { apiClientVersion, personalizationClient };
|