@sitecore-content-sdk/personalize 2.0.0-canary.12

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.
Files changed (74) hide show
  1. package/LICENSE.MD +202 -0
  2. package/README.md +114 -0
  3. package/dist/cjs/package.json +75 -0
  4. package/dist/cjs/src/consts.js +14 -0
  5. package/dist/cjs/src/debug.js +12 -0
  6. package/dist/cjs/src/index.js +13 -0
  7. package/dist/cjs/src/initialization/browser-adapter.js +48 -0
  8. package/dist/cjs/src/initialization/const.js +8 -0
  9. package/dist/cjs/src/initialization/get-profile-id.js +17 -0
  10. package/dist/cjs/src/initialization/plugin-browser.js +82 -0
  11. package/dist/cjs/src/initialization/plugin-server.js +43 -0
  12. package/dist/cjs/src/initialization/server-adapter.js +89 -0
  13. package/dist/cjs/src/initialization/shared.js +17 -0
  14. package/dist/cjs/src/initialization/types.js +2 -0
  15. package/dist/cjs/src/internal.js +11 -0
  16. package/dist/cjs/src/personalization/personalize.js +29 -0
  17. package/dist/cjs/src/personalization/personalizer.js +120 -0
  18. package/dist/cjs/src/personalization/send-call-flows-request.js +47 -0
  19. package/dist/cjs/src/profile-id/fetch-profile-id-from-edge-proxy.js +35 -0
  20. package/dist/cjs/src/web-personalization/get-cdn-url.js +27 -0
  21. package/dist/esm/package.json +75 -0
  22. package/dist/esm/src/consts.js +8 -0
  23. package/dist/esm/src/debug.js +9 -0
  24. package/dist/esm/src/index.js +5 -0
  25. package/dist/esm/src/initialization/browser-adapter.js +45 -0
  26. package/dist/esm/src/initialization/const.js +5 -0
  27. package/dist/esm/src/initialization/get-profile-id.js +14 -0
  28. package/dist/esm/src/initialization/plugin-browser.js +79 -0
  29. package/dist/esm/src/initialization/plugin-server.js +40 -0
  30. package/dist/esm/src/initialization/server-adapter.js +86 -0
  31. package/dist/esm/src/initialization/shared.js +14 -0
  32. package/dist/esm/src/initialization/types.js +1 -0
  33. package/dist/esm/src/internal.js +4 -0
  34. package/dist/esm/src/personalization/personalize.js +26 -0
  35. package/dist/esm/src/personalization/personalizer.js +116 -0
  36. package/dist/esm/src/personalization/send-call-flows-request.js +44 -0
  37. package/dist/esm/src/profile-id/fetch-profile-id-from-edge-proxy.js +32 -0
  38. package/dist/esm/src/web-personalization/get-cdn-url.js +24 -0
  39. package/internal.d.ts +1 -0
  40. package/package.json +75 -0
  41. package/types/src/consts.d.ts +8 -0
  42. package/types/src/consts.d.ts.map +1 -0
  43. package/types/src/debug.d.ts +9 -0
  44. package/types/src/debug.d.ts.map +1 -0
  45. package/types/src/index.d.ts +15 -0
  46. package/types/src/index.d.ts.map +1 -0
  47. package/types/src/initialization/browser-adapter.d.ts +19 -0
  48. package/types/src/initialization/browser-adapter.d.ts.map +1 -0
  49. package/types/src/initialization/const.d.ts +6 -0
  50. package/types/src/initialization/const.d.ts.map +1 -0
  51. package/types/src/initialization/get-profile-id.d.ts +8 -0
  52. package/types/src/initialization/get-profile-id.d.ts.map +1 -0
  53. package/types/src/initialization/plugin-browser.d.ts +37 -0
  54. package/types/src/initialization/plugin-browser.d.ts.map +1 -0
  55. package/types/src/initialization/plugin-server.d.ts +23 -0
  56. package/types/src/initialization/plugin-server.d.ts.map +1 -0
  57. package/types/src/initialization/server-adapter.d.ts +29 -0
  58. package/types/src/initialization/server-adapter.d.ts.map +1 -0
  59. package/types/src/initialization/shared.d.ts +8 -0
  60. package/types/src/initialization/shared.d.ts.map +1 -0
  61. package/types/src/initialization/types.d.ts +168 -0
  62. package/types/src/initialization/types.d.ts.map +1 -0
  63. package/types/src/internal.d.ts +8 -0
  64. package/types/src/internal.d.ts.map +1 -0
  65. package/types/src/personalization/personalize.d.ts +21 -0
  66. package/types/src/personalization/personalize.d.ts.map +1 -0
  67. package/types/src/personalization/personalizer.d.ts +177 -0
  68. package/types/src/personalization/personalizer.d.ts.map +1 -0
  69. package/types/src/personalization/send-call-flows-request.d.ts +78 -0
  70. package/types/src/personalization/send-call-flows-request.d.ts.map +1 -0
  71. package/types/src/profile-id/fetch-profile-id-from-edge-proxy.d.ts +39 -0
  72. package/types/src/profile-id/fetch-profile-id-from-edge-proxy.d.ts.map +1 -0
  73. package/types/src/web-personalization/get-cdn-url.d.ts +9 -0
  74. package/types/src/web-personalization/get-cdn-url.d.ts.map +1 -0
@@ -0,0 +1,29 @@
1
+ import { PersonalizeAdapter } from './types';
2
+ import type { IncomingMessage, OutgoingMessage } from 'http';
3
+ /**
4
+ * Defines the PersonalizeServerAdapter.
5
+ * @public
6
+ */
7
+ export interface PersonalizeServerAdapter extends PersonalizeAdapter {
8
+ /**
9
+ * The type of the adapter.
10
+ */
11
+ type: 'server';
12
+ /**
13
+ * Gets the user agent from the request headers.
14
+ */
15
+ getUserAgent: PersonalizeAdapter['getUserAgent'];
16
+ }
17
+ /**
18
+ * Creates a server-based personalize adapter that reads and writes the profile ID
19
+ * using cookies and can resolve a new profile ID from the Edge proxy when needed.
20
+ * The adapter also provides access user agent from the request headers.
21
+ * @template Request - The HTTP request type extending `IncomingMessage`.
22
+ * @template Response - The HTTP response type extending `OutgoingMessage`.
23
+ * @param {Request} request - The HTTP request object.
24
+ * @param {Response} response - The HTTP response object.
25
+ * @returns {PersonalizeServerAdapter} An PersonalizeServerAdapter instance.
26
+ * @public
27
+ */
28
+ export declare function personalizeServerAdapter<Request extends IncomingMessage, Response extends OutgoingMessage>(request: Request, response: Response): PersonalizeServerAdapter;
29
+ //# sourceMappingURL=server-adapter.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"server-adapter.d.ts","sourceRoot":"","sources":["../../../src/initialization/server-adapter.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAC;AAS7C,OAAO,KAAK,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,MAAM,CAAC;AAE7D;;;GAGG;AACH,MAAM,WAAW,wBAAyB,SAAQ,kBAAkB;IAClE;;OAEG;IACH,IAAI,EAAE,QAAQ,CAAC;IACf;;OAEG;IACH,YAAY,EAAE,kBAAkB,CAAC,cAAc,CAAC,CAAC;CAClD;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,wBAAwB,CACtC,OAAO,SAAS,eAAe,EAC/B,QAAQ,SAAS,eAAe,EAChC,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,QAAQ,GAAG,wBAAwB,CA0FhE"}
@@ -0,0 +1,8 @@
1
+ import { PersonalizePlugin } from './types';
2
+ /**
3
+ * Retrieves the personalize plugin instance from the core context.
4
+ * @returns {PersonalizePlugin} The personalize plugin instance.
5
+ * @internal
6
+ */
7
+ export declare function getPersonalizePlugin(): PersonalizePlugin;
8
+ //# sourceMappingURL=shared.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"shared.d.ts","sourceRoot":"","sources":["../../../src/initialization/shared.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAC;AAI5C;;;;GAIG;AACH,wBAAgB,oBAAoB,IAAI,iBAAiB,CAQxD"}
@@ -0,0 +1,168 @@
1
+ import { PluginAdapter } from '@sitecore-content-sdk/core';
2
+ import { PERSONALIZE_PLUGIN_NAME } from './const';
3
+ /**
4
+ * Represents the web personalization options.
5
+ * @public
6
+ */
7
+ export interface WebPersonalizationOptions {
8
+ /**
9
+ * Whether to load the web personalization script with the async attribute.
10
+ */
11
+ async: boolean;
12
+ /**
13
+ * Whether to load the web personalization script with the defer attribute.
14
+ */
15
+ defer: boolean;
16
+ /**
17
+ * The language to be used for web personalization.
18
+ */
19
+ language?: string;
20
+ }
21
+ /**
22
+ * Parameters for creating a personalize plugin.
23
+ * @public
24
+ */
25
+ export interface PersonalizePluginOptions {
26
+ /**
27
+ * Whether to set the sc_cid_personalize cookie.
28
+ *
29
+ * If using only the browser plugin of the personalize package, set to true.
30
+ *
31
+ * If using both the browser and the server plugins of the personalize package, set enablePersonalizeCookie to true either on the browser or the server, and set to false on the other.
32
+ *
33
+ * If enableCookie of analytics plugin is false, enablePersonalizeCookie will not be set.
34
+ *
35
+ * Default: `false`.
36
+ */
37
+ enablePersonalizeCookie?: boolean;
38
+ /**
39
+ * Whether to enable web personalization.
40
+ *
41
+ * If true, a web personalization script will load in your app with async but without defer.
42
+ *
43
+ * To customize the loading of the script, set the value to an object, and in the object, use the async, defer, and language attributes.
44
+ *
45
+ * Default: `false`.
46
+ */
47
+ webPersonalization?: boolean | Partial<WebPersonalizationOptions>;
48
+ }
49
+ /**
50
+ * Parameters for creating a personalize server plugin.
51
+ * @public
52
+ */
53
+ export type PersonalizeServerPluginOptions = Omit<PersonalizePluginOptions, 'webPersonalization'>;
54
+ /**
55
+ * Represents the personalize plugin options.
56
+ * @public
57
+ */
58
+ export interface PersonalizeOptions {
59
+ /**
60
+ * The web personalization options.
61
+ */
62
+ webPersonalization: false | WebPersonalizationOptions;
63
+ /**
64
+ * The cookie settings for the personalize plugin, including whether the cookie is enabled and the name of the cookie.
65
+ */
66
+ cookies: {
67
+ /**
68
+ * Whether the sc_cid_personalize cookie is enabled.
69
+ */
70
+ enabled: boolean;
71
+ /**
72
+ * The name of the sc_cid_personalize cookie.
73
+ */
74
+ name: string;
75
+ };
76
+ }
77
+ /**
78
+ * Represents the personalize plugin interface.
79
+ * @public
80
+ */
81
+ export type PersonalizeServerOptions = Omit<PersonalizeOptions, 'webPersonalization'>;
82
+ /**
83
+ * Represents the personalize plugin interface.
84
+ * @internal
85
+ */
86
+ export interface PersonalizePlugin {
87
+ options: PersonalizeOptions | PersonalizeServerOptions;
88
+ init: () => Promise<void>;
89
+ name: typeof PERSONALIZE_PLUGIN_NAME;
90
+ dependencies: string[];
91
+ adapter: PersonalizeAdapter;
92
+ }
93
+ /**
94
+ * Represents the personalize browser plugin interface.
95
+ * @public
96
+ */
97
+ export interface PersonalizeBrowserPlugin {
98
+ /**
99
+ * The options for the personalize browser plugin, including web personalization and cookie settings.
100
+ */
101
+ options: PersonalizeOptions;
102
+ /**
103
+ * Initializes the personalize browser plugin, which may involve setting up necessary configurations, loading scripts, or performing any asynchronous operations required for the plugin to function properly.
104
+ * @returns A promise that resolves when the initialization is complete.
105
+ */
106
+ init: () => Promise<void>;
107
+ /**
108
+ * The name of the personalize plugin.
109
+ */
110
+ name: typeof PERSONALIZE_PLUGIN_NAME;
111
+ /**
112
+ * An array of plugin names that the personalize browser plugin depends on. This ensures that the required plugins are initialized before the personalize plugin is initialized.
113
+ */
114
+ dependencies: string[];
115
+ /**
116
+ * The adapter for the personalize browser plugin, which provides methods to get and set the profile id, and optionally get the user agent. The adapter allows the personalize plugin to interact with the underlying platform or environment in a consistent way.
117
+ */
118
+ adapter: PersonalizeAdapter;
119
+ }
120
+ /**
121
+ * Represents the personalize server plugin interface.
122
+ * @public
123
+ */
124
+ export interface PersonalizeServerPlugin {
125
+ /**
126
+ * The options for the personalize server plugin, including cookie settings.
127
+ */
128
+ options: PersonalizeServerOptions;
129
+ /**
130
+ * Initializes the personalize server plugin, which may involve setting up necessary configurations or performing any asynchronous operations required for the plugin to function properly.
131
+ * @returns A promise that resolves when the initialization is complete.
132
+ */
133
+ init: () => Promise<void>;
134
+ /**
135
+ * The name of the personalize plugin.
136
+ */
137
+ name: typeof PERSONALIZE_PLUGIN_NAME;
138
+ /**
139
+ * An array of plugin names that the personalize server plugin depends on. This ensures that the required plugins are initialized before the personalize plugin is initialized.
140
+ */
141
+ dependencies: string[];
142
+ /**
143
+ * The adapter for the personalize server plugin, which provides methods to get and set the profile id, and optionally get the user agent. The adapter allows the personalize plugin to interact with the underlying platform or environment in a consistent way.
144
+ */
145
+ adapter: PersonalizeAdapter;
146
+ }
147
+ /**
148
+ * Represents the personalize adapter interface that defines the methods to get and set the profile id, and optionally get the user agent.
149
+ * @public
150
+ */
151
+ export interface PersonalizeAdapter extends PluginAdapter {
152
+ /**
153
+ * Gets the profile ID. The method returns a string representing the profile ID if it exists, or null if it does not exist.
154
+ * @returns {string | null} The profile ID or null if not found.
155
+ */
156
+ getProfileId: () => string | null;
157
+ /**
158
+ * Sets the profile ID. The method may involve asynchronous operations, such as setting cookies or making API calls, and returns a promise that resolves when the profile ID has been set.
159
+ * @returns {Promise<void>} A promise that resolves when the profile ID has been set.
160
+ */
161
+ setProfileId: () => Promise<void>;
162
+ /**
163
+ * Optionally gets the user agent string. The method returns a string representing the user agent if it is available, or undefined if it is not available. This method can be used to provide additional context for personalization based on the user's device or browser.
164
+ * @returns {string | undefined} The user agent string or undefined.
165
+ */
166
+ getUserAgent?: () => string | undefined;
167
+ }
168
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/initialization/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAC3D,OAAO,EAAE,uBAAuB,EAAE,MAAM,SAAS,CAAC;AAElD;;;GAGG;AACH,MAAM,WAAW,yBAAyB;IACxC;;OAEG;IACH,KAAK,EAAE,OAAO,CAAC;IACf;;OAEG;IACH,KAAK,EAAE,OAAO,CAAC;IACf;;OAEG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED;;;GAGG;AACH,MAAM,WAAW,wBAAwB;IACvC;;;;;;;;;;OAUG;IACH,uBAAuB,CAAC,EAAE,OAAO,CAAC;IAClC;;;;;;;;OAQG;IACH,kBAAkB,CAAC,EAAE,OAAO,GAAG,OAAO,CAAC,yBAAyB,CAAC,CAAC;CACnE;AAED;;;GAGG;AACH,MAAM,MAAM,8BAA8B,GAAG,IAAI,CAAC,wBAAwB,EAAE,oBAAoB,CAAC,CAAC;AAElG;;;GAGG;AACH,MAAM,WAAW,kBAAkB;IACjC;;OAEG;IACH,kBAAkB,EAAE,KAAK,GAAG,yBAAyB,CAAC;IACtD;;OAEG;IACH,OAAO,EAAE;QACP;;WAEG;QACH,OAAO,EAAE,OAAO,CAAC;QACjB;;WAEG;QACH,IAAI,EAAE,MAAM,CAAC;KACd,CAAC;CACH;AAED;;;GAGG;AACH,MAAM,MAAM,wBAAwB,GAAG,IAAI,CAAC,kBAAkB,EAAE,oBAAoB,CAAC,CAAC;AAEtF;;;GAGG;AACH,MAAM,WAAW,iBAAiB;IAChC,OAAO,EAAE,kBAAkB,GAAG,wBAAwB,CAAC;IACvD,IAAI,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;IAC1B,IAAI,EAAE,OAAO,uBAAuB,CAAC;IACrC,YAAY,EAAE,MAAM,EAAE,CAAC;IACvB,OAAO,EAAE,kBAAkB,CAAC;CAC7B;AAED;;;GAGG;AACH,MAAM,WAAW,wBAAwB;IACvC;;OAEG;IACH,OAAO,EAAE,kBAAkB,CAAC;IAC5B;;;OAGG;IACH,IAAI,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;IAC1B;;OAEG;IACH,IAAI,EAAE,OAAO,uBAAuB,CAAC;IACrC;;OAEG;IACH,YAAY,EAAE,MAAM,EAAE,CAAC;IACvB;;OAEG;IACH,OAAO,EAAE,kBAAkB,CAAC;CAC7B;AAED;;;GAGG;AACH,MAAM,WAAW,uBAAuB;IACtC;;OAEG;IACH,OAAO,EAAE,wBAAwB,CAAC;IAClC;;;OAGG;IACH,IAAI,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;IAC1B;;OAEG;IACH,IAAI,EAAE,OAAO,uBAAuB,CAAC;IACrC;;OAEG;IACH,YAAY,EAAE,MAAM,EAAE,CAAC;IACvB;;OAEG;IACH,OAAO,EAAE,kBAAkB,CAAC;CAC7B;AAED;;;GAGG;AACH,MAAM,WAAW,kBAAmB,SAAQ,aAAa;IACvD;;;OAGG;IACH,YAAY,EAAE,MAAM,MAAM,GAAG,IAAI,CAAC;IAClC;;;OAGG;IACH,YAAY,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;IAClC;;;OAGG;IACH,YAAY,CAAC,EAAE,MAAM,MAAM,GAAG,SAAS,CAAC;CACzC"}
@@ -0,0 +1,8 @@
1
+ export type { PersonalizePlugin } from './initialization/types';
2
+ export { getPersonalizePlugin } from './initialization/shared';
3
+ export { PERSONALIZE_PLUGIN_NAME } from './initialization/const';
4
+ export { fetchProfileIdFromEdgeProxy } from './profile-id/fetch-profile-id-from-edge-proxy';
5
+ export { PACKAGE_VERSION } from './consts';
6
+ export { PersonalizeAdapter } from './initialization/types';
7
+ export type { PersonalizeBrowserPlugin, PersonalizeServerPlugin, PersonalizeOptions, PersonalizeServerOptions, } from './initialization/types';
8
+ //# sourceMappingURL=internal.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"internal.d.ts","sourceRoot":"","sources":["../../src/internal.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAChE,OAAO,EAAE,oBAAoB,EAAE,MAAM,yBAAyB,CAAC;AAC/D,OAAO,EAAE,uBAAuB,EAAE,MAAM,wBAAwB,CAAC;AACjE,OAAO,EAAE,2BAA2B,EAAE,MAAM,+CAA+C,CAAC;AAC5F,OAAO,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AAC3C,OAAO,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AAC5D,YAAY,EACV,wBAAwB,EACxB,uBAAuB,EACvB,kBAAkB,EAClB,wBAAwB,GACzB,MAAM,wBAAwB,CAAC"}
@@ -0,0 +1,21 @@
1
+ import type { PersonalizeData } from './personalizer';
2
+ import type { FailedCalledFlowsResponse } from './send-call-flows-request';
3
+ /**
4
+ * A function that executes an interactive/web experiment over any web-based/mobile application.
5
+ * @param {PersonalizeData} personalizeData - The required/optional attributes for a flow execution.
6
+ * @param {PersonalizeOpts} opts - An object containing additional options.
7
+ * @returns {Promise<unknown | null | FailedCalledFlowsResponse>} A flow execution response.
8
+ * @public
9
+ */
10
+ export declare function personalize(personalizeData: PersonalizeData, opts?: PersonalizeOpts): Promise<unknown | null | FailedCalledFlowsResponse>;
11
+ /**
12
+ * Options for the personalize function.
13
+ * @public
14
+ */
15
+ export interface PersonalizeOpts {
16
+ /**
17
+ * Timeout in milliseconds for the personalize request
18
+ */
19
+ timeout?: number;
20
+ }
21
+ //# sourceMappingURL=personalize.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"personalize.d.ts","sourceRoot":"","sources":["../../../src/personalization/personalize.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AAEtD,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,2BAA2B,CAAC;AAI3E;;;;;;GAMG;AACH,wBAAsB,WAAW,CAC/B,eAAe,EAAE,eAAe,EAChC,IAAI,CAAC,EAAE,eAAe,GACrB,OAAO,CAAC,OAAO,GAAG,IAAI,GAAG,yBAAyB,CAAC,CAqBrD;AAED;;;GAGG;AACH,MAAM,WAAW,eAAe;IAC9B;;OAEG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB"}
@@ -0,0 +1,177 @@
1
+ import type { NestedObject } from '@sitecore-content-sdk/analytics-core/utils';
2
+ import type { FailedCalledFlowsResponse } from './send-call-flows-request';
3
+ import { CoreContext } from '@sitecore-content-sdk/core';
4
+ /**
5
+ * The Personalizer Class runs a flow of interactive experiments.
6
+ * @internal
7
+ */
8
+ export declare class Personalizer {
9
+ private clientId;
10
+ private profileId?;
11
+ /**
12
+ * The Personalizer Class runs a flow of interactive experiments.
13
+ * @param {string} clientId - The client id of the user
14
+ * @param {string} [profileId] - The profile id of the user
15
+ */
16
+ constructor(clientId: string, profileId?: string | undefined);
17
+ /**
18
+ * A function to make a request to the Sitecore Edge Proxy `/callFlows` API endpoint
19
+ * @param {PersonalizeData} personalizeData - The personalize input from the developer
20
+ * @param {CoreContext['config']} config - The configuration that was set during initialization
21
+ * @param {string} searchParams - The URL search parameters
22
+ * @param {GetInteractiveExperienceDataOpts} opts - Optional object that contains options for timeout and User Agent
23
+ * @returns {Promise<unknown | null | FailedCalledFlowsResponse>} A promise that resolves with either the Sitecore Edge Proxy response object or null
24
+ */
25
+ getInteractiveExperienceData(personalizeData: PersonalizeData, config: CoreContext['config'], searchParams: string, opts?: GetInteractiveExperienceDataOpts): Promise<unknown | null | FailedCalledFlowsResponse>;
26
+ /**
27
+ * A function that sanitizes the personalize input data
28
+ * @param {PersonalizeData} personalizeData - The personalize input data to sanitize
29
+ * @returns {PersonalizeData} The sanitized object
30
+ */
31
+ private sanitizeInput;
32
+ /**
33
+ * A function that maps the personalize input data with the Edge Proxy
34
+ * @param {PersonalizeData} input - The personalize input data to map
35
+ * @returns {EPCallFlowsBody} The Edge Proxy object
36
+ */
37
+ private mapPersonalizeInputToEPData;
38
+ /**
39
+ * A validation method to throw error for the mandatory property for runtime users
40
+ * @param {PersonalizeData} params - The personalize data object
41
+ */
42
+ private validate;
43
+ /**
44
+ * Retrieves UTM parameters from the url query string e.g. `utm_test1=123&utm_test2=456`
45
+ * @param {string} urlParams - The url params passed
46
+ * @param {string} prefix - The prefix we want to extract from the params
47
+ * @returns {{ [key: string]: string }} An object containing the UTM parameters (if they exist) in the form: `utm: {test1: 123, test2: 456}`
48
+ */
49
+ private extractUrlParamsWithPrefix;
50
+ }
51
+ /**
52
+ * An interface that describes the geolocation attributes.
53
+ * @public
54
+ */
55
+ export interface PersonalizeGeolocation {
56
+ /**
57
+ * The site visitor's city.
58
+ *
59
+ * Format: title case recommended.
60
+ */
61
+ city?: string;
62
+ /**
63
+ * The site visitor's country.
64
+ *
65
+ * Format: uppercase ISO 3166-1 alpha-2.
66
+ */
67
+ country?: string;
68
+ /**
69
+ * The site visitor's region.
70
+ * Depends on the regional structure of the country.
71
+ *
72
+ * Format: for example, for Australia, use state and territory abbreviations. For the United States, use ANSI standard INCITS 38:2009.
73
+ */
74
+ region?: string;
75
+ }
76
+ /**
77
+ * An interface that describes the flow execution model attributes input for the library
78
+ * @public
79
+ */
80
+ export interface PersonalizeData {
81
+ /**
82
+ * The touchpoint where the user interacts with your brand.
83
+ * For example, for webpages, the channel is "WEB". For mobile app screens, the channel is "MOBILE_APP".
84
+ *
85
+ * Format: uppercase.
86
+ */
87
+ channel: string;
88
+ /**
89
+ * The alphabetic currency code of the currency the site visitor uses in your app.
90
+ * For example, if the site visitor selects Australian dollars as the currency, the currency is "AUD".
91
+ *
92
+ * Format: uppercase ISO 4217.
93
+ */
94
+ currency?: string;
95
+ /**
96
+ * The site visitor's email address.
97
+ *
98
+ * Format: lowercase recommended.
99
+ */
100
+ email?: string;
101
+ /**
102
+ * The unique identifier of the live interactive experience or experiment to run.
103
+ * To find the friendly ID in Sitecore Personalize, click the live experience or experiment to run, then click Build summary. The friendly ID is in the Details pane.
104
+ */
105
+ friendlyId: string;
106
+ /**
107
+ * The site visitor's geolocation data.
108
+ */
109
+ geo?: PersonalizeGeolocation;
110
+ /**
111
+ * The identifiers used for identifying site visitors.
112
+ *
113
+ * If set, the experience or experiment runs only for the identified site visitor.
114
+ */
115
+ identifier?: PersonalizeIdentifierInput;
116
+ /**
117
+ * The language the site visitor interacts with your brand in.
118
+ * For example, if the site visitor selects the Japanese language in your app, the language is "JA".
119
+ *
120
+ * Format: uppercase ISO 639.
121
+ *
122
+ * Default for browser-side events: inferred from the HTML lang attribute. If lang is not specified, the default is an empty string.
123
+ *
124
+ * Default for server-side events: empty string.
125
+ */
126
+ language?: string;
127
+ /**
128
+ * An object of your choice.
129
+ *
130
+ * If the URL of the webpage where this function runs contains UTM parameters, those parameters are automatically captured in params.utm.
131
+ *
132
+ * To override the automatically captured UTM parameters, specify values manually in params.utm.
133
+ */
134
+ params?: PersonalizeInputParams;
135
+ /**
136
+ * A list of IDs of personalized page variants.
137
+ *
138
+ * Ensures that the correct variants are rendered for personalization.
139
+ *
140
+ * If unset or an empty array, this property will not be part of the payload.
141
+ */
142
+ pageVariantIds?: string[];
143
+ }
144
+ /**
145
+ * An interface that describes the identifier model attributes for the library
146
+ * @public
147
+ */
148
+ export interface PersonalizeIdentifierInput {
149
+ /**
150
+ * The unique guest (site visitor) identifier provided by your organization's identity system, such as a Customer Relationship Management (CRM) system.
151
+ */
152
+ id: string;
153
+ /**
154
+ * The name of your organization's identity system, external to SitecoreAI, that provided the unique guest (site visitor) identifier.
155
+ */
156
+ provider: string;
157
+ }
158
+ /**
159
+ * A type that describes the params field
160
+ * @public
161
+ */
162
+ export type PersonalizeInputParams = NestedObject;
163
+ /**
164
+ * Options for the getInteractiveExperienceData method
165
+ * @internal
166
+ */
167
+ export interface GetInteractiveExperienceDataOpts {
168
+ /**
169
+ * Timeout in milliseconds for the personalize request
170
+ */
171
+ timeout?: number;
172
+ /**
173
+ * Optional user agent string
174
+ */
175
+ userAgent?: string | null;
176
+ }
177
+ //# sourceMappingURL=personalizer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"personalizer.d.ts","sourceRoot":"","sources":["../../../src/personalization/personalizer.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,4CAA4C,CAAC;AAE/E,OAAO,KAAK,EAAmB,yBAAyB,EAAE,MAAM,2BAA2B,CAAC;AAE5F,OAAO,EAAE,WAAW,EAAa,MAAM,4BAA4B,CAAC;AAIpE;;;GAGG;AACH,qBAAa,YAAY;IAMX,OAAO,CAAC,QAAQ;IAAU,OAAO,CAAC,SAAS,CAAC;IALxD;;;;OAIG;gBACiB,QAAQ,EAAE,MAAM,EAAU,SAAS,CAAC,EAAE,MAAM,YAAA;IAEhE;;;;;;;OAOG;IACG,4BAA4B,CAChC,eAAe,EAAE,eAAe,EAChC,MAAM,EAAE,WAAW,CAAC,QAAQ,CAAC,EAC7B,YAAY,EAAE,MAAM,EACpB,IAAI,CAAC,EAAE,gCAAgC,GACtC,OAAO,CAAC,OAAO,GAAG,IAAI,GAAG,yBAAyB,CAAC;IAgBtD;;;;OAIG;IACH,OAAO,CAAC,aAAa;IA6BrB;;;;OAIG;IACH,OAAO,CAAC,2BAA2B;IAkBnC;;;OAGG;IACH,OAAO,CAAC,QAAQ;IAKhB;;;;;OAKG;IACH,OAAO,CAAC,0BAA0B;CAenC;AAED;;;GAGG;AACH,MAAM,WAAW,sBAAsB;IACrC;;;;OAIG;IACH,IAAI,CAAC,EAAE,MAAM,CAAC;IACd;;;;OAIG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB;;;;;OAKG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED;;;GAGG;AACH,MAAM,WAAW,eAAe;IAC9B;;;;;OAKG;IACH,OAAO,EAAE,MAAM,CAAC;IAChB;;;;;OAKG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB;;;;OAIG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;IACf;;;OAGG;IACH,UAAU,EAAE,MAAM,CAAC;IACnB;;OAEG;IACH,GAAG,CAAC,EAAE,sBAAsB,CAAC;IAC7B;;;;OAIG;IACH,UAAU,CAAC,EAAE,0BAA0B,CAAC;IACxC;;;;;;;;;OASG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB;;;;;;OAMG;IACH,MAAM,CAAC,EAAE,sBAAsB,CAAC;IAChC;;;;;;OAMG;IACH,cAAc,CAAC,EAAE,MAAM,EAAE,CAAC;CAC3B;AAED;;;GAGG;AACH,MAAM,WAAW,0BAA0B;IACzC;;OAEG;IACH,EAAE,EAAE,MAAM,CAAC;IACX;;OAEG;IACH,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED;;;GAGG;AACH,MAAM,MAAM,sBAAsB,GAAG,YAAY,CAAC;AAElD;;;GAGG;AACH,MAAM,WAAW,gCAAgC;IAC/C;;OAEG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB;;OAEG;IACH,SAAS,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CAC3B"}
@@ -0,0 +1,78 @@
1
+ import type { NestedObject } from '@sitecore-content-sdk/analytics-core/utils';
2
+ import { GetInteractiveExperienceDataOpts } from './personalizer';
3
+ import { CoreContext } from '@sitecore-content-sdk/core';
4
+ /**
5
+ * A function that sends a CallFlow request to Sitecore Edge Proxy
6
+ * @param {EPCallFlowsBody} epCallFlowsBody - Properties to be sent to Sitecore Edge Proxy
7
+ * @param {CoreContext['config']} config - Configuration for the url params
8
+ * @param {GetInteractiveExperienceDataOpts} opts - Optional configuration object
9
+ * @returns {Promise<unknown | null | FailedCalledFlowsResponse>} A promise that resolves with either the Sitecore Edge Proxy response object or unknown
10
+ * @internal
11
+ */
12
+ export declare function sendCallFlowsRequest(epCallFlowsBody: EPCallFlowsBody, config: CoreContext['config'], opts?: GetInteractiveExperienceDataOpts): Promise<unknown>;
13
+ /**
14
+ * An interface with the basic functionality that the derived classes needs to implement
15
+ * @internal
16
+ */
17
+ export interface PersonalizeClient {
18
+ config: CoreContext['config'];
19
+ sendCallFlowsRequest: (epCallFlowAttributes: EPCallFlowsBody, timeout?: number) => Promise<unknown | null | FailedCalledFlowsResponse>;
20
+ }
21
+ /**
22
+ * An interface that describes the failed response model from Sitecore Edge Proxy
23
+ * @public
24
+ */
25
+ export interface FailedCalledFlowsResponse {
26
+ /**
27
+ * The status of the response.
28
+ */
29
+ status: string;
30
+ /**
31
+ * The error code.
32
+ */
33
+ code: string;
34
+ /**
35
+ * A message describing the error.
36
+ */
37
+ message: string;
38
+ /**
39
+ * A more detailed message intended for developers.
40
+ */
41
+ developerMessage: string;
42
+ /**
43
+ * A URL with more information about the error.
44
+ */
45
+ moreInfoUrl: string;
46
+ }
47
+ /**
48
+ * An interface that describes the identifier model attributes for the library
49
+ * @internal
50
+ */
51
+ export interface EPIdentifier {
52
+ id: string;
53
+ provider: string;
54
+ }
55
+ /**
56
+ * An interface that describes the payload sent to Sitecore Edge Proxy library
57
+ * @internal
58
+ */
59
+ export interface EPCallFlowsBody {
60
+ browserId?: string;
61
+ email?: string;
62
+ friendlyId: string;
63
+ identifiers?: EPIdentifier;
64
+ channel: string;
65
+ clientKey: string;
66
+ currencyCode?: string;
67
+ language: string | undefined;
68
+ params?: EPCallFlowsParams;
69
+ pointOfSale: string;
70
+ guestRef?: string;
71
+ variants?: string[];
72
+ }
73
+ /**
74
+ * A type that describes the params property of the EPCallFlowsBody
75
+ * @internal
76
+ */
77
+ export type EPCallFlowsParams = NestedObject;
78
+ //# sourceMappingURL=send-call-flows-request.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"send-call-flows-request.d.ts","sourceRoot":"","sources":["../../../src/personalization/send-call-flows-request.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,4CAA4C,CAAC;AAE/E,OAAO,EAAE,gCAAgC,EAAE,MAAM,gBAAgB,CAAC;AAClE,OAAO,EAAE,WAAW,EAAgC,MAAM,4BAA4B,CAAC;AAKvF;;;;;;;GAOG;AACH,wBAAsB,oBAAoB,CACxC,eAAe,EAAE,eAAe,EAChC,MAAM,EAAE,WAAW,CAAC,QAAQ,CAAC,EAC7B,IAAI,CAAC,EAAE,gCAAgC,oBAmCxC;AAED;;;GAGG;AACH,MAAM,WAAW,iBAAiB;IAChC,MAAM,EAAE,WAAW,CAAC,QAAQ,CAAC,CAAC;IAC9B,oBAAoB,EAAE,CACpB,oBAAoB,EAAE,eAAe,EACrC,OAAO,CAAC,EAAE,MAAM,KACb,OAAO,CAAC,OAAO,GAAG,IAAI,GAAG,yBAAyB,CAAC,CAAC;CAC1D;AAED;;;GAGG;AACH,MAAM,WAAW,yBAAyB;IACxC;;OAEG;IACH,MAAM,EAAE,MAAM,CAAC;IACf;;OAEG;IACH,IAAI,EAAE,MAAM,CAAC;IACb;;OAEG;IACH,OAAO,EAAE,MAAM,CAAC;IAChB;;OAEG;IACH,gBAAgB,EAAE,MAAM,CAAC;IACzB;;OAEG;IACH,WAAW,EAAE,MAAM,CAAC;CACrB;AAED;;;GAGG;AACH,MAAM,WAAW,YAAY;IAC3B,EAAE,EAAE,MAAM,CAAC;IACX,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED;;;GAGG;AACH,MAAM,WAAW,eAAe;IAC9B,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,UAAU,EAAE,MAAM,CAAC;IACnB,WAAW,CAAC,EAAE,YAAY,CAAC;IAC3B,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,MAAM,CAAC;IAClB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,QAAQ,EAAE,MAAM,GAAG,SAAS,CAAC;IAC7B,MAAM,CAAC,EAAE,iBAAiB,CAAC;IAC3B,WAAW,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAC;CACrB;AAED;;;GAGG;AACH,MAAM,MAAM,iBAAiB,GAAG,YAAY,CAAC"}
@@ -0,0 +1,39 @@
1
+ /**
2
+ * Gets the profile id from Edge Proxy.
3
+ * @param {string} clientId - The client ID of the client.
4
+ * @param {string} contextId - The Sitecore Edge context ID.
5
+ * @param {string} edgeUrl - The Sitecore Edge base URL.
6
+ * @returns {Promise<string>} A promise that resolves with the profile id.
7
+ * @throws Will throw an error if the client key or client ID is invalid.
8
+ * @internal
9
+ */
10
+ export declare function fetchProfileIdFromEdgeProxy(clientId: string, contextId: string, edgeUrl: string): Promise<string>;
11
+ /**
12
+ * Represents the common properties of the response from the Edge Proxy when fetching the profile id.
13
+ * @internal
14
+ */
15
+ interface GetProfileIdCommon {
16
+ status: string;
17
+ version: string;
18
+ clientKey: string;
19
+ }
20
+ /**
21
+ * Represents the successful response from the Edge Proxy when fetching the profile id.
22
+ * @internal
23
+ */
24
+ export interface GetProfileIdResponse extends GetProfileIdCommon {
25
+ ref: string;
26
+ customer: {
27
+ ref: string;
28
+ };
29
+ }
30
+ /**
31
+ * Represents the error response from the Edge Proxy when fetching the profile id.
32
+ * @internal
33
+ */
34
+ export interface GetProfileIdResponseError extends GetProfileIdCommon {
35
+ error_msg: string;
36
+ moreInfo: string;
37
+ }
38
+ export {};
39
+ //# sourceMappingURL=fetch-profile-id-from-edge-proxy.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fetch-profile-id-from-edge-proxy.d.ts","sourceRoot":"","sources":["../../../src/profile-id/fetch-profile-id-from-edge-proxy.ts"],"names":[],"mappings":"AAMA;;;;;;;;GAQG;AACH,wBAAsB,2BAA2B,CAC/C,QAAQ,EAAE,MAAM,EAChB,SAAS,EAAE,MAAM,EACjB,OAAO,EAAE,MAAM,GACd,OAAO,CAAC,MAAM,CAAC,CAqBjB;AAED;;;GAGG;AACH,UAAU,kBAAkB;IAC1B,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,MAAM,CAAC;CACnB;AAED;;;GAGG;AACH,MAAM,WAAW,oBAAqB,SAAQ,kBAAkB;IAC9D,GAAG,EAAE,MAAM,CAAC;IACZ,QAAQ,EAAE;QAAE,GAAG,EAAE,MAAM,CAAA;KAAE,CAAC;CAC3B;AAED;;;GAGG;AACH,MAAM,WAAW,yBAA0B,SAAQ,kBAAkB;IAEnE,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,MAAM,CAAC;CAClB"}
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Retrieves the CDN URL for web personalization
3
+ * @param {string} contextId - The Sitecore Edge context ID
4
+ * @param {string} edgeUrl - The Sitecore Edge URL
5
+ * @returns {Promise<string | null>} The CDN URL or null if unavailable
6
+ * @internal
7
+ */
8
+ export declare function getCdnUrl(contextId: string, edgeUrl: string): Promise<string | null>;
9
+ //# sourceMappingURL=get-cdn-url.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"get-cdn-url.d.ts","sourceRoot":"","sources":["../../../src/web-personalization/get-cdn-url.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,wBAAsB,SAAS,CAAC,SAAS,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAgB1F"}