New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@sitecore-cloudsdk/personalize

Package Overview
Dependencies
Maintainers
3
Versions
29
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@sitecore-cloudsdk/personalize - npm Package Compare versions

Comparing version 0.1.4 to 0.1.5

dist/cjs/src/lib/personalization/callflow-edge-proxy-client.d.ts

12

dist/cjs/package.json
{
"name": "@sitecore-cloudsdk/personalize",
"version": "0.1.4",
"version": "0.1.5",
"license": "Apache-2.0",

@@ -18,4 +18,4 @@ "exports": {

"dependencies": {
"@sitecore-cloudsdk/core": "^0.2.0",
"@sitecore-cloudsdk/utils": "^0.2.0"
"@sitecore-cloudsdk/core": "^0.1.3",
"@sitecore-cloudsdk/utils": "^0.1.3"
},

@@ -36,7 +36,3 @@ "scripts": {

"server.d.ts"
],
"engines": {
"node": ">=18",
"npm": ">=9"
}
]
}

@@ -5,7 +5,1 @@ /**

export declare const LIBRARY_VERSION: string;
export declare enum ErrorMessages {
IE_0001 = "[IE-0001] The \"window\" object is not available on the server side. Use the \"window\" object only on the client side, and in the correct execution context.",
IE_0006 = "[IE-0006] You must first initialize the \"personalize/browser\" module. Run the \"init\" function.",
IE_0007 = "[IE-0007] You must first initialize the \"personalize/server\" module. Run the \"init\" function.",
MV_0004 = "[MV-0004] \"friendlyId\" is required."
}

@@ -7,3 +7,3 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
exports.ErrorMessages = exports.LIBRARY_VERSION = void 0;
exports.LIBRARY_VERSION = void 0;
/* eslint-disable @typescript-eslint/naming-convention */

@@ -15,8 +15,1 @@ const package_json_1 = __importDefault(require("../../package.json"));

exports.LIBRARY_VERSION = package_json_1.default.version;
var ErrorMessages;
(function (ErrorMessages) {
ErrorMessages["IE_0001"] = "[IE-0001] The \"window\" object is not available on the server side. Use the \"window\" object only on the client side, and in the correct execution context.";
ErrorMessages["IE_0006"] = "[IE-0006] You must first initialize the \"personalize/browser\" module. Run the \"init\" function.";
ErrorMessages["IE_0007"] = "[IE-0007] You must first initialize the \"personalize/server\" module. Run the \"init\" function.";
ErrorMessages["MV_0004"] = "[MV-0004] \"friendlyId\" is required.";
})(ErrorMessages || (exports.ErrorMessages = ErrorMessages = {}));

@@ -1,4 +0,19 @@

import { SettingsParamsBrowser } from '@sitecore-cloudsdk/core';
export declare let initPromise: Promise<void> | null;
import { Settings, SettingsParamsBrowser } from '@sitecore-cloudsdk/core';
import { CallFlowEdgeProxyClient } from '../../personalization/callflow-edge-proxy-client';
/**
* Sets the personalize settings to be used by the application.
*
* @param settings - The personalize settings to be set, or `null` to clear the settings.
*/
export declare function setDependencies(settings: BrowserPersonalizeSettings | null): void;
/**
* Retrieves the browser personalize settings object.
*
* This function ensures that the browser personalize settings have been initialized and contain essential properties like `settings` and `callFlowEPClient`.
*
* @returns The browser personalize settings object.
* @throws Error if the personalize settings haven't been initialized with the required properties.
*/
export declare function getDependencies(): BrowserPersonalizeSettings;
/**
* Initiates the Engage library using the global settings added by the developer

@@ -9,5 +24,6 @@ * @param settingsInput - Global settings added by the developer

export declare function init(settingsInput: SettingsParamsBrowser): Promise<void>;
/**
* A function that handles the async browser init logic. Throws an error or awaits the promise.
*/
export declare function awaitInit(): Promise<void>;
export interface BrowserPersonalizeSettings {
id: string;
settings: Settings;
callFlowEdgeProxyClient: CallFlowEdgeProxyClient;
}
"use strict";
// © Sitecore Corporation A/S. All rights reserved. Sitecore® is a registered trademark of Sitecore Corporation A/S.
Object.defineProperty(exports, "__esModule", { value: true });
exports.awaitInit = exports.init = exports.initPromise = void 0;
// © Sitecore Corporation A/S. All rights reserved. Sitecore® is a registered trademark of Sitecore Corporation A/S.
exports.init = exports.getDependencies = exports.setDependencies = void 0;
const core_1 = require("@sitecore-cloudsdk/core");
const consts_1 = require("../../consts");
exports.initPromise = null;
const callflow_edge_proxy_client_1 = require("../../personalization/callflow-edge-proxy-client");
let dependencies = null;
/**
* Sets the personalize settings to be used by the application.
*
* @param settings - The personalize settings to be set, or `null` to clear the settings.
*/
function setDependencies(settings) {
dependencies = settings;
}
exports.setDependencies = setDependencies;
/**
* Retrieves the browser personalize settings object.
*
* This function ensures that the browser personalize settings have been initialized and contain essential properties like `settings` and `callFlowEPClient`.
*
* @returns The browser personalize settings object.
* @throws Error if the personalize settings haven't been initialized with the required properties.
*/
function getDependencies() {
if (!dependencies) {
throw Error(`[IE-0006] You must first initialize the "personalize/browser" module. Run the "init" function.`);
}
return dependencies;
}
exports.getDependencies = getDependencies;
/**
* Initiates the Engage library using the global settings added by the developer

@@ -14,13 +39,17 @@ * @param settingsInput - Global settings added by the developer

async function init(settingsInput) {
if (typeof window === 'undefined')
throw new Error(consts_1.ErrorMessages.IE_0001);
try {
exports.initPromise = (0, core_1.initCore)(settingsInput);
await exports.initPromise;
if (typeof window === 'undefined') {
throw new Error(
// eslint-disable-next-line max-len
`[IE-0001] The "window" object is not available on the server side. Use the "window" object only on the client side, and in the correct execution context.`);
}
catch (error) {
exports.initPromise = null;
throw new Error(error);
}
await (0, core_1.initCore)(settingsInput);
const settings = (0, core_1.getSettings)();
const id = (0, core_1.getBrowserId)();
const callFlowEdgeProxyClient = new callflow_edge_proxy_client_1.CallFlowEdgeProxyClient(settings);
window.Engage ?? (window.Engage = {});
setDependencies({
callFlowEdgeProxyClient,
id,
settings,
});
window.Engage = {

@@ -36,10 +65,1 @@ ...window.Engage,

exports.init = init;
/**
* A function that handles the async browser init logic. Throws an error or awaits the promise.
*/
async function awaitInit() {
if (exports.initPromise === null)
throw new Error(consts_1.ErrorMessages.IE_0006);
await exports.initPromise;
}
exports.awaitInit = awaitInit;
import { SettingsParamsServer } from '@sitecore-cloudsdk/core';
import { BrowserPersonalizeSettings } from '../client/initializer';
import { HttpResponse, MiddlewareNextResponse, Request } from '@sitecore-cloudsdk/utils';
/**
* Sets the personalize settings to be used by the application.
*
* @param settings - The personalize settings to be set, or `null` to clear the settings.
*/
export declare function setDependencies(settings: ServerPersonalize | null): void;
/**
* Retrieves the personalize server settings used by the application.
*
* @returns The personalize server settings.
* @throws Error if the personalize server settings haven't been initialized.
*/
export declare function getServerDependencies(): ServerPersonalize;
/**
* Initiates the server Engage library using the global settings added by the developer

@@ -9,1 +23,2 @@ * @param settings - Global settings added by the developer

export declare function initServer<Response extends MiddlewareNextResponse | HttpResponse>(settingsInput: SettingsParamsServer, request: Request, response: Response): Promise<void>;
export type ServerPersonalize = Omit<BrowserPersonalizeSettings, 'id'>;
"use strict";
// © Sitecore Corporation A/S. All rights reserved. Sitecore® is a registered trademark of Sitecore Corporation A/S.
Object.defineProperty(exports, "__esModule", { value: true });
exports.initServer = void 0;
exports.initServer = exports.getServerDependencies = exports.setDependencies = void 0;
const core_1 = require("@sitecore-cloudsdk/core");
const callflow_edge_proxy_client_1 = require("../../personalization/callflow-edge-proxy-client");
let serverDependencies = null;
/**
* Sets the personalize settings to be used by the application.
*
* @param settings - The personalize settings to be set, or `null` to clear the settings.
*/
function setDependencies(settings) {
serverDependencies = settings;
}
exports.setDependencies = setDependencies;
/**
* Retrieves the personalize server settings used by the application.
*
* @returns The personalize server settings.
* @throws Error if the personalize server settings haven't been initialized.
*/
function getServerDependencies() {
if (!serverDependencies) {
throw Error(`[IE-0007] You must first initialize the "personalize/server" module. Run the "init" function.`);
}
return serverDependencies;
}
exports.getServerDependencies = getServerDependencies;
/**
* Initiates the server Engage library using the global settings added by the developer

@@ -13,3 +37,9 @@ * @param settings - Global settings added by the developer

await (0, core_1.initCoreServer)(settingsInput, request, response);
const settings = (0, core_1.getSettingsServer)();
const callFlowEdgeProxyClient = new callflow_edge_proxy_client_1.CallFlowEdgeProxyClient(settings);
setDependencies({
callFlowEdgeProxyClient,
settings: settings,
});
}
exports.initServer = initServer;

@@ -1,2 +0,2 @@

import { FailedCalledFlowsResponse } from './send-call-flows-request';
import { FailedCalledFlowsResponse } from './callflow-edge-proxy-client';
import { PersonalizerInput } from './personalizer';

@@ -3,0 +3,0 @@ /**

"use strict";
// © Sitecore Corporation A/S. All rights reserved. Sitecore® is a registered trademark of Sitecore Corporation A/S.
Object.defineProperty(exports, "__esModule", { value: true });
exports.personalize = void 0;
const core_1 = require("@sitecore-cloudsdk/core");
const initializer_1 = require("../initializer/client/initializer");
const personalizer_1 = require("./personalizer");
const initializer_1 = require("../initializer/client/initializer");
/**

@@ -14,8 +14,6 @@ * A function that executes an interactive experiment or web experiment over any web-based or mobile application.

*/
async function personalize(personalizeData, timeout) {
await (0, initializer_1.awaitInit)();
const id = (0, core_1.getBrowserId)();
const settings = (0, core_1.getSettings)();
return new personalizer_1.Personalizer(id).getInteractiveExperienceData(personalizeData, settings, timeout);
function personalize(personalizeData, timeout) {
const { callFlowEdgeProxyClient, id } = (0, initializer_1.getDependencies)();
return new personalizer_1.Personalizer(callFlowEdgeProxyClient, id).getInteractiveExperienceData(personalizeData, timeout);
}
exports.personalize = personalize;

@@ -1,5 +0,5 @@

import { Settings } from '@sitecore-cloudsdk/core';
import { FailedCalledFlowsResponse } from './send-call-flows-request';
import { FailedCalledFlowsResponse, PersonalizeClient } from './callflow-edge-proxy-client';
import { NestedObject } from '@sitecore-cloudsdk/utils';
export declare class Personalizer {
private personalizeClient;
private id;

@@ -11,3 +11,3 @@ /**

*/
constructor(id: string);
constructor(personalizeClient: PersonalizeClient, id: string);
/**

@@ -18,3 +18,3 @@ * A function to make a request to the Sitecore EP /callFlows API endpoint

*/
getInteractiveExperienceData(personalizeInput: PersonalizerInput, settings: Settings, timeout?: number): Promise<unknown | null | FailedCalledFlowsResponse>;
getInteractiveExperienceData(personalizeInput: PersonalizerInput, timeout?: number): Promise<unknown | null | FailedCalledFlowsResponse>;
/**

@@ -21,0 +21,0 @@ * A function that sanitizes the personalize input data

"use strict";
// © Sitecore Corporation A/S. All rights reserved. Sitecore® is a registered trademark of Sitecore Corporation A/S.
Object.defineProperty(exports, "__esModule", { value: true });
exports.Personalizer = void 0;
// © Sitecore Corporation A/S. All rights reserved. Sitecore® is a registered trademark of Sitecore Corporation A/S.
const core_1 = require("@sitecore-cloudsdk/core");
const send_call_flows_request_1 = require("./send-call-flows-request");
const utils_1 = require("@sitecore-cloudsdk/utils");
const consts_1 = require("../consts");
class Personalizer {

@@ -15,3 +13,4 @@ /**

*/
constructor(id) {
constructor(personalizeClient, id) {
this.personalizeClient = personalizeClient;
this.id = id;

@@ -24,3 +23,3 @@ }

*/
async getInteractiveExperienceData(personalizeInput, settings, timeout) {
async getInteractiveExperienceData(personalizeInput, timeout) {
this.validate(personalizeInput);

@@ -31,7 +30,4 @@ const sanitizedInput = this.sanitizeInput(personalizeInput);

mappedData.browserId = this.id;
return (0, send_call_flows_request_1.sendCallFlowsRequest)(mappedData, settings, timeout)
.then((payload) => payload)
.catch((err) => {
throw err;
});
const response = await this.personalizeClient.sendCallFlowsRequest(mappedData, timeout);
return response;
}

@@ -82,5 +78,5 @@ /**

if (!friendlyId || friendlyId.trim().length === 0)
throw new Error(consts_1.ErrorMessages.MV_0004);
throw new Error(`[MV-0004] "friendlyId" is required.`);
}
}
exports.Personalizer = Personalizer;

@@ -1,2 +0,2 @@

import { FailedCalledFlowsResponse } from './send-call-flows-request';
import { FailedCalledFlowsResponse } from './callflow-edge-proxy-client';
import { Request } from '@sitecore-cloudsdk/utils';

@@ -3,0 +3,0 @@ import { PersonalizerInput } from './personalizer';

@@ -6,2 +6,3 @@ "use strict";

const core_1 = require("@sitecore-cloudsdk/core");
const initializer_1 = require("../initializer/server/initializer");
const personalizer_1 = require("./personalizer");

@@ -17,6 +18,6 @@ /**

function personalizeServer(personalizeData, request, timeout) {
const settings = (0, core_1.getSettingsServer)();
const { callFlowEdgeProxyClient, settings } = (0, initializer_1.getServerDependencies)();
const id = (0, core_1.getBrowserIdFromRequest)(request, settings.cookieSettings.cookieName);
return new personalizer_1.Personalizer(id).getInteractiveExperienceData(personalizeData, settings, timeout);
return new personalizer_1.Personalizer(callFlowEdgeProxyClient, id).getInteractiveExperienceData(personalizeData, timeout);
}
exports.personalizeServer = personalizeServer;
{
"name": "@sitecore-cloudsdk/personalize",
"version": "0.1.4",
"version": "0.1.5",
"license": "Apache-2.0",

@@ -18,4 +18,4 @@ "exports": {

"dependencies": {
"@sitecore-cloudsdk/core": "^0.2.0",
"@sitecore-cloudsdk/utils": "^0.2.0"
"@sitecore-cloudsdk/core": "^0.1.3",
"@sitecore-cloudsdk/utils": "^0.1.3"
},

@@ -36,7 +36,3 @@ "scripts": {

"server.d.ts"
],
"engines": {
"node": ">=18",
"npm": ">=9"
}
]
}

@@ -5,7 +5,1 @@ /**

export declare const LIBRARY_VERSION: string;
export declare enum ErrorMessages {
IE_0001 = "[IE-0001] The \"window\" object is not available on the server side. Use the \"window\" object only on the client side, and in the correct execution context.",
IE_0006 = "[IE-0006] You must first initialize the \"personalize/browser\" module. Run the \"init\" function.",
IE_0007 = "[IE-0007] You must first initialize the \"personalize/server\" module. Run the \"init\" function.",
MV_0004 = "[MV-0004] \"friendlyId\" is required."
}

@@ -8,8 +8,1 @@ // © Sitecore Corporation A/S. All rights reserved. Sitecore® is a registered trademark of Sitecore Corporation A/S.

export const LIBRARY_VERSION = packageJson.version;
export var ErrorMessages;
(function (ErrorMessages) {
ErrorMessages["IE_0001"] = "[IE-0001] The \"window\" object is not available on the server side. Use the \"window\" object only on the client side, and in the correct execution context.";
ErrorMessages["IE_0006"] = "[IE-0006] You must first initialize the \"personalize/browser\" module. Run the \"init\" function.";
ErrorMessages["IE_0007"] = "[IE-0007] You must first initialize the \"personalize/server\" module. Run the \"init\" function.";
ErrorMessages["MV_0004"] = "[MV-0004] \"friendlyId\" is required.";
})(ErrorMessages || (ErrorMessages = {}));

@@ -1,4 +0,19 @@

import { SettingsParamsBrowser } from '@sitecore-cloudsdk/core';
export declare let initPromise: Promise<void> | null;
import { Settings, SettingsParamsBrowser } from '@sitecore-cloudsdk/core';
import { CallFlowEdgeProxyClient } from '../../personalization/callflow-edge-proxy-client';
/**
* Sets the personalize settings to be used by the application.
*
* @param settings - The personalize settings to be set, or `null` to clear the settings.
*/
export declare function setDependencies(settings: BrowserPersonalizeSettings | null): void;
/**
* Retrieves the browser personalize settings object.
*
* This function ensures that the browser personalize settings have been initialized and contain essential properties like `settings` and `callFlowEPClient`.
*
* @returns The browser personalize settings object.
* @throws Error if the personalize settings haven't been initialized with the required properties.
*/
export declare function getDependencies(): BrowserPersonalizeSettings;
/**
* Initiates the Engage library using the global settings added by the developer

@@ -9,5 +24,6 @@ * @param settingsInput - Global settings added by the developer

export declare function init(settingsInput: SettingsParamsBrowser): Promise<void>;
/**
* A function that handles the async browser init logic. Throws an error or awaits the promise.
*/
export declare function awaitInit(): Promise<void>;
export interface BrowserPersonalizeSettings {
id: string;
settings: Settings;
callFlowEdgeProxyClient: CallFlowEdgeProxyClient;
}
// © Sitecore Corporation A/S. All rights reserved. Sitecore® is a registered trademark of Sitecore Corporation A/S.
import { getBrowserId, initCore } from '@sitecore-cloudsdk/core';
import { ErrorMessages, LIBRARY_VERSION } from '../../consts';
export let initPromise = null;
import { getBrowserId, getSettings, initCore } from '@sitecore-cloudsdk/core';
import { LIBRARY_VERSION } from '../../consts';
import { CallFlowEdgeProxyClient } from '../../personalization/callflow-edge-proxy-client';
let dependencies = null;
/**
* Sets the personalize settings to be used by the application.
*
* @param settings - The personalize settings to be set, or `null` to clear the settings.
*/
export function setDependencies(settings) {
dependencies = settings;
}
/**
* Retrieves the browser personalize settings object.
*
* This function ensures that the browser personalize settings have been initialized and contain essential properties like `settings` and `callFlowEPClient`.
*
* @returns The browser personalize settings object.
* @throws Error if the personalize settings haven't been initialized with the required properties.
*/
export function getDependencies() {
if (!dependencies) {
throw Error(`[IE-0006] You must first initialize the "personalize/browser" module. Run the "init" function.`);
}
return dependencies;
}
/**
* Initiates the Engage library using the global settings added by the developer

@@ -11,13 +34,17 @@ * @param settingsInput - Global settings added by the developer

export async function init(settingsInput) {
if (typeof window === 'undefined')
throw new Error(ErrorMessages.IE_0001);
try {
initPromise = initCore(settingsInput);
await initPromise;
if (typeof window === 'undefined') {
throw new Error(
// eslint-disable-next-line max-len
`[IE-0001] The "window" object is not available on the server side. Use the "window" object only on the client side, and in the correct execution context.`);
}
catch (error) {
initPromise = null;
throw new Error(error);
}
await initCore(settingsInput);
const settings = getSettings();
const id = getBrowserId();
const callFlowEdgeProxyClient = new CallFlowEdgeProxyClient(settings);
window.Engage ?? (window.Engage = {});
setDependencies({
callFlowEdgeProxyClient,
id,
settings,
});
window.Engage = {

@@ -32,9 +59,1 @@ ...window.Engage,

}
/**
* A function that handles the async browser init logic. Throws an error or awaits the promise.
*/
export async function awaitInit() {
if (initPromise === null)
throw new Error(ErrorMessages.IE_0006);
await initPromise;
}
import { SettingsParamsServer } from '@sitecore-cloudsdk/core';
import { BrowserPersonalizeSettings } from '../client/initializer';
import { HttpResponse, MiddlewareNextResponse, Request } from '@sitecore-cloudsdk/utils';
/**
* Sets the personalize settings to be used by the application.
*
* @param settings - The personalize settings to be set, or `null` to clear the settings.
*/
export declare function setDependencies(settings: ServerPersonalize | null): void;
/**
* Retrieves the personalize server settings used by the application.
*
* @returns The personalize server settings.
* @throws Error if the personalize server settings haven't been initialized.
*/
export declare function getServerDependencies(): ServerPersonalize;
/**
* Initiates the server Engage library using the global settings added by the developer

@@ -9,1 +23,2 @@ * @param settings - Global settings added by the developer

export declare function initServer<Response extends MiddlewareNextResponse | HttpResponse>(settingsInput: SettingsParamsServer, request: Request, response: Response): Promise<void>;
export type ServerPersonalize = Omit<BrowserPersonalizeSettings, 'id'>;
// © Sitecore Corporation A/S. All rights reserved. Sitecore® is a registered trademark of Sitecore Corporation A/S.
import { initCoreServer } from '@sitecore-cloudsdk/core';
import { getSettingsServer, initCoreServer } from '@sitecore-cloudsdk/core';
import { CallFlowEdgeProxyClient } from '../../personalization/callflow-edge-proxy-client';
let serverDependencies = null;
/**
* Sets the personalize settings to be used by the application.
*
* @param settings - The personalize settings to be set, or `null` to clear the settings.
*/
export function setDependencies(settings) {
serverDependencies = settings;
}
/**
* Retrieves the personalize server settings used by the application.
*
* @returns The personalize server settings.
* @throws Error if the personalize server settings haven't been initialized.
*/
export function getServerDependencies() {
if (!serverDependencies) {
throw Error(`[IE-0007] You must first initialize the "personalize/server" module. Run the "init" function.`);
}
return serverDependencies;
}
/**
* Initiates the server Engage library using the global settings added by the developer

@@ -10,2 +32,8 @@ * @param settings - Global settings added by the developer

await initCoreServer(settingsInput, request, response);
const settings = getSettingsServer();
const callFlowEdgeProxyClient = new CallFlowEdgeProxyClient(settings);
setDependencies({
callFlowEdgeProxyClient,
settings: settings,
});
}

@@ -1,2 +0,2 @@

import { FailedCalledFlowsResponse } from './send-call-flows-request';
import { FailedCalledFlowsResponse } from './callflow-edge-proxy-client';
import { PersonalizerInput } from './personalizer';

@@ -3,0 +3,0 @@ /**

@@ -1,4 +0,4 @@

import { getBrowserId, getSettings } from '@sitecore-cloudsdk/core';
// © Sitecore Corporation A/S. All rights reserved. Sitecore® is a registered trademark of Sitecore Corporation A/S.
import { getDependencies } from '../initializer/client/initializer';
import { Personalizer } from './personalizer';
import { awaitInit } from '../initializer/client/initializer';
/**

@@ -11,7 +11,5 @@ * A function that executes an interactive experiment or web experiment over any web-based or mobile application.

*/
export async function personalize(personalizeData, timeout) {
await awaitInit();
const id = getBrowserId();
const settings = getSettings();
return new Personalizer(id).getInteractiveExperienceData(personalizeData, settings, timeout);
export function personalize(personalizeData, timeout) {
const { callFlowEdgeProxyClient, id } = getDependencies();
return new Personalizer(callFlowEdgeProxyClient, id).getInteractiveExperienceData(personalizeData, timeout);
}

@@ -1,5 +0,5 @@

import { Settings } from '@sitecore-cloudsdk/core';
import { FailedCalledFlowsResponse } from './send-call-flows-request';
import { FailedCalledFlowsResponse, PersonalizeClient } from './callflow-edge-proxy-client';
import { NestedObject } from '@sitecore-cloudsdk/utils';
export declare class Personalizer {
private personalizeClient;
private id;

@@ -11,3 +11,3 @@ /**

*/
constructor(id: string);
constructor(personalizeClient: PersonalizeClient, id: string);
/**

@@ -18,3 +18,3 @@ * A function to make a request to the Sitecore EP /callFlows API endpoint

*/
getInteractiveExperienceData(personalizeInput: PersonalizerInput, settings: Settings, timeout?: number): Promise<unknown | null | FailedCalledFlowsResponse>;
getInteractiveExperienceData(personalizeInput: PersonalizerInput, timeout?: number): Promise<unknown | null | FailedCalledFlowsResponse>;
/**

@@ -21,0 +21,0 @@ * A function that sanitizes the personalize input data

// © Sitecore Corporation A/S. All rights reserved. Sitecore® is a registered trademark of Sitecore Corporation A/S.
import { language } from '@sitecore-cloudsdk/core';
import { sendCallFlowsRequest } from './send-call-flows-request';
import { flattenObject } from '@sitecore-cloudsdk/utils';
import { ErrorMessages } from '../consts';
export class Personalizer {

@@ -12,3 +10,4 @@ /**

*/
constructor(id) {
constructor(personalizeClient, id) {
this.personalizeClient = personalizeClient;
this.id = id;

@@ -21,3 +20,3 @@ }

*/
async getInteractiveExperienceData(personalizeInput, settings, timeout) {
async getInteractiveExperienceData(personalizeInput, timeout) {
this.validate(personalizeInput);

@@ -28,7 +27,4 @@ const sanitizedInput = this.sanitizeInput(personalizeInput);

mappedData.browserId = this.id;
return sendCallFlowsRequest(mappedData, settings, timeout)
.then((payload) => payload)
.catch((err) => {
throw err;
});
const response = await this.personalizeClient.sendCallFlowsRequest(mappedData, timeout);
return response;
}

@@ -79,4 +75,4 @@ /**

if (!friendlyId || friendlyId.trim().length === 0)
throw new Error(ErrorMessages.MV_0004);
throw new Error(`[MV-0004] "friendlyId" is required.`);
}
}

@@ -1,2 +0,2 @@

import { FailedCalledFlowsResponse } from './send-call-flows-request';
import { FailedCalledFlowsResponse } from './callflow-edge-proxy-client';
import { Request } from '@sitecore-cloudsdk/utils';

@@ -3,0 +3,0 @@ import { PersonalizerInput } from './personalizer';

// © Sitecore Corporation A/S. All rights reserved. Sitecore® is a registered trademark of Sitecore Corporation A/S.
import { getBrowserIdFromRequest, getSettingsServer } from '@sitecore-cloudsdk/core';
import { getBrowserIdFromRequest } from '@sitecore-cloudsdk/core';
import { getServerDependencies } from '../initializer/server/initializer';
import { Personalizer } from './personalizer';

@@ -13,5 +14,5 @@ /**

export function personalizeServer(personalizeData, request, timeout) {
const settings = getSettingsServer();
const { callFlowEdgeProxyClient, settings } = getServerDependencies();
const id = getBrowserIdFromRequest(request, settings.cookieSettings.cookieName);
return new Personalizer(id).getInteractiveExperienceData(personalizeData, settings, timeout);
return new Personalizer(callFlowEdgeProxyClient, id).getInteractiveExperienceData(personalizeData, timeout);
}
{
"name": "@sitecore-cloudsdk/personalize",
"version": "0.1.4",
"version": "0.1.5",
"license": "Apache-2.0",

@@ -18,4 +18,4 @@ "exports": {

"dependencies": {
"@sitecore-cloudsdk/core": "^0.2.0",
"@sitecore-cloudsdk/utils": "^0.2.0"
"@sitecore-cloudsdk/core": "^0.1.3",
"@sitecore-cloudsdk/utils": "^0.1.3"
},

@@ -36,7 +36,3 @@ "scripts": {

"server.d.ts"
],
"engines": {
"node": ">=18",
"npm": ">=9"
}
]
}

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc