@sitecore-cloudsdk/personalize 0.1.3 → 0.2.0
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/cjs/package.json +6 -2
- package/dist/cjs/src/lib/consts.d.ts +6 -0
- package/dist/cjs/src/lib/consts.js +8 -1
- package/dist/cjs/src/lib/initializer/client/initializer.d.ts +6 -22
- package/dist/cjs/src/lib/initializer/client/initializer.js +21 -41
- package/dist/cjs/src/lib/initializer/server/initializer.d.ts +0 -15
- package/dist/cjs/src/lib/initializer/server/initializer.js +1 -31
- package/dist/cjs/src/lib/personalization/personalize.d.ts +1 -1
- package/dist/cjs/src/lib/personalization/personalize.js +7 -5
- package/dist/cjs/src/lib/personalization/personalizeServer.d.ts +1 -1
- package/dist/cjs/src/lib/personalization/personalizeServer.js +2 -3
- package/dist/cjs/src/lib/personalization/personalizer.d.ts +4 -4
- package/dist/cjs/src/lib/personalization/personalizer.js +11 -7
- package/dist/cjs/src/lib/personalization/{callflow-edge-proxy-client.d.ts → send-call-flows-request.d.ts} +8 -16
- package/dist/cjs/src/lib/personalization/send-call-flows-request.js +42 -0
- package/dist/cjs/tsconfig.cjs.tsbuildinfo +1 -1
- package/dist/esm/package.json +6 -2
- package/dist/esm/src/lib/consts.d.ts +6 -0
- package/dist/esm/src/lib/consts.js +7 -0
- package/dist/esm/src/lib/initializer/client/initializer.d.ts +6 -22
- package/dist/esm/src/lib/initializer/client/initializer.js +20 -39
- package/dist/esm/src/lib/initializer/server/initializer.d.ts +0 -15
- package/dist/esm/src/lib/initializer/server/initializer.js +1 -29
- package/dist/esm/src/lib/personalization/personalize.d.ts +1 -1
- package/dist/esm/src/lib/personalization/personalize.js +7 -5
- package/dist/esm/src/lib/personalization/personalizeServer.d.ts +1 -1
- package/dist/esm/src/lib/personalization/personalizeServer.js +3 -4
- package/dist/esm/src/lib/personalization/personalizer.d.ts +4 -4
- package/dist/esm/src/lib/personalization/personalizer.js +10 -6
- package/dist/esm/src/lib/personalization/{callflow-edge-proxy-client.d.ts → send-call-flows-request.d.ts} +8 -16
- package/dist/esm/src/lib/personalization/send-call-flows-request.js +38 -0
- package/dist/esm/tsconfig.tsbuildinfo +1 -1
- package/package.json +6 -2
- package/dist/cjs/src/lib/personalization/callflow-edge-proxy-client.js +0 -44
- package/dist/esm/src/lib/personalization/callflow-edge-proxy-client.js +0 -40
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
// © Sitecore Corporation A/S. All rights reserved. Sitecore® is a registered trademark of Sitecore Corporation A/S.
|
|
3
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
-
exports.CallFlowEdgeProxyClient = void 0;
|
|
5
|
-
const utils_1 = require("@sitecore-cloudsdk/utils");
|
|
6
|
-
const consts_1 = require("../consts");
|
|
7
|
-
class CallFlowEdgeProxyClient {
|
|
8
|
-
/**
|
|
9
|
-
* A helper class which handles the functionality for sending CALLFLOW requests
|
|
10
|
-
* @param personalizeData - The mandatory payload to be send to Sitecore EP
|
|
11
|
-
* @param settings - The global settings
|
|
12
|
-
*/
|
|
13
|
-
constructor(settings) {
|
|
14
|
-
this.settings = settings;
|
|
15
|
-
}
|
|
16
|
-
/**
|
|
17
|
-
* A function that sends a CallFlow request to Sitecore EP
|
|
18
|
-
* @param personalizeData - Properties to be send to Sitecore EP
|
|
19
|
-
* @param timeout - Optional timeout in milliseconds to cancel the request
|
|
20
|
-
* @returns - A promise that resolves with either the Sitecore EP response object or unknown
|
|
21
|
-
*/
|
|
22
|
-
async sendCallFlowsRequest(epCallFlowsBody, timeout) {
|
|
23
|
-
const requestUrl = `${this.settings.sitecoreEdgeUrl}/personalize/v2/callFlows?sitecoreContextId=${this.settings.sitecoreEdgeContextId}&siteId=${this.settings.siteName}`;
|
|
24
|
-
const fetchOptions = {
|
|
25
|
-
body: JSON.stringify(epCallFlowsBody),
|
|
26
|
-
headers: {
|
|
27
|
-
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
28
|
-
'Content-Type': 'application/json',
|
|
29
|
-
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
30
|
-
'X-Library-Version': consts_1.LIBRARY_VERSION,
|
|
31
|
-
},
|
|
32
|
-
method: 'POST',
|
|
33
|
-
};
|
|
34
|
-
if (timeout === undefined)
|
|
35
|
-
return fetch(requestUrl, fetchOptions)
|
|
36
|
-
.then((response) => response.json())
|
|
37
|
-
.then((data) => data)
|
|
38
|
-
.catch(() => {
|
|
39
|
-
return null;
|
|
40
|
-
});
|
|
41
|
-
return (0, utils_1.fetchWithTimeout)(requestUrl, timeout, fetchOptions);
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
exports.CallFlowEdgeProxyClient = CallFlowEdgeProxyClient;
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
// © Sitecore Corporation A/S. All rights reserved. Sitecore® is a registered trademark of Sitecore Corporation A/S.
|
|
2
|
-
import { fetchWithTimeout } from '@sitecore-cloudsdk/utils';
|
|
3
|
-
import { LIBRARY_VERSION } from '../consts';
|
|
4
|
-
export class CallFlowEdgeProxyClient {
|
|
5
|
-
/**
|
|
6
|
-
* A helper class which handles the functionality for sending CALLFLOW requests
|
|
7
|
-
* @param personalizeData - The mandatory payload to be send to Sitecore EP
|
|
8
|
-
* @param settings - The global settings
|
|
9
|
-
*/
|
|
10
|
-
constructor(settings) {
|
|
11
|
-
this.settings = settings;
|
|
12
|
-
}
|
|
13
|
-
/**
|
|
14
|
-
* A function that sends a CallFlow request to Sitecore EP
|
|
15
|
-
* @param personalizeData - Properties to be send to Sitecore EP
|
|
16
|
-
* @param timeout - Optional timeout in milliseconds to cancel the request
|
|
17
|
-
* @returns - A promise that resolves with either the Sitecore EP response object or unknown
|
|
18
|
-
*/
|
|
19
|
-
async sendCallFlowsRequest(epCallFlowsBody, timeout) {
|
|
20
|
-
const requestUrl = `${this.settings.sitecoreEdgeUrl}/personalize/v2/callFlows?sitecoreContextId=${this.settings.sitecoreEdgeContextId}&siteId=${this.settings.siteName}`;
|
|
21
|
-
const fetchOptions = {
|
|
22
|
-
body: JSON.stringify(epCallFlowsBody),
|
|
23
|
-
headers: {
|
|
24
|
-
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
25
|
-
'Content-Type': 'application/json',
|
|
26
|
-
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
27
|
-
'X-Library-Version': LIBRARY_VERSION,
|
|
28
|
-
},
|
|
29
|
-
method: 'POST',
|
|
30
|
-
};
|
|
31
|
-
if (timeout === undefined)
|
|
32
|
-
return fetch(requestUrl, fetchOptions)
|
|
33
|
-
.then((response) => response.json())
|
|
34
|
-
.then((data) => data)
|
|
35
|
-
.catch(() => {
|
|
36
|
-
return null;
|
|
37
|
-
});
|
|
38
|
-
return fetchWithTimeout(requestUrl, timeout, fetchOptions);
|
|
39
|
-
}
|
|
40
|
-
}
|