@sitecore-jss/sitecore-jss-proxy 22.3.0 → 22.3.1-canary.2

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 (49) hide show
  1. package/README.md +1 -1
  2. package/dist/cjs/index.js +19 -447
  3. package/dist/cjs/middleware/editing/config.js +27 -0
  4. package/dist/cjs/middleware/editing/index.js +89 -0
  5. package/dist/cjs/middleware/editing/render.js +103 -0
  6. package/dist/cjs/middleware/headless-ssr-proxy/index.js +450 -0
  7. package/dist/cjs/middleware/healthcheck/index.js +16 -0
  8. package/dist/cjs/middleware/index.js +32 -0
  9. package/dist/cjs/personalize/PersonalizeHelper.js +243 -0
  10. package/dist/cjs/personalize/index.js +5 -0
  11. package/dist/cjs/personalize/test-data/personalizeData.js +86 -0
  12. package/dist/cjs/types/personalize.js +2 -0
  13. package/dist/esm/index.js +4 -441
  14. package/dist/esm/middleware/editing/config.js +23 -0
  15. package/dist/esm/middleware/editing/index.js +84 -0
  16. package/dist/esm/middleware/editing/render.js +98 -0
  17. package/dist/esm/middleware/headless-ssr-proxy/index.js +441 -0
  18. package/dist/esm/middleware/healthcheck/index.js +12 -0
  19. package/dist/esm/middleware/index.js +4 -0
  20. package/dist/esm/personalize/PersonalizeHelper.js +236 -0
  21. package/dist/esm/personalize/index.js +1 -0
  22. package/dist/esm/personalize/test-data/personalizeData.js +82 -0
  23. package/dist/esm/types/personalize.js +1 -0
  24. package/package.json +22 -9
  25. package/types/index.d.ts +4 -21
  26. package/types/middleware/editing/config.d.ts +27 -0
  27. package/types/middleware/editing/index.d.ts +32 -0
  28. package/types/middleware/editing/render.d.ts +42 -0
  29. package/types/{ProxyConfig.d.ts → middleware/headless-ssr-proxy/ProxyConfig.d.ts} +2 -5
  30. package/types/middleware/headless-ssr-proxy/index.d.ts +20 -0
  31. package/types/middleware/healthcheck/index.d.ts +6 -0
  32. package/types/middleware/index.d.ts +3 -0
  33. package/types/personalize/PersonalizeHelper.d.ts +43 -0
  34. package/types/personalize/index.d.ts +2 -0
  35. package/types/personalize/test-data/personalizeData.d.ts +59 -0
  36. package/types/types/AppRenderer.d.ts +35 -0
  37. package/types/types/index.d.ts +3 -0
  38. package/types/types/personalize.d.ts +85 -0
  39. package/types/AppRenderer.d.ts +0 -10
  40. package/types/RenderResponse.d.ts +0 -15
  41. /package/dist/cjs/{ProxyConfig.js → middleware/headless-ssr-proxy/ProxyConfig.js} +0 -0
  42. /package/dist/cjs/{AppRenderer.js → types/AppRenderer.js} +0 -0
  43. /package/dist/cjs/{RouteUrlParser.js → types/RouteUrlParser.js} +0 -0
  44. /package/dist/cjs/{RenderResponse.js → types/index.js} +0 -0
  45. /package/dist/esm/{ProxyConfig.js → middleware/headless-ssr-proxy/ProxyConfig.js} +0 -0
  46. /package/dist/esm/{AppRenderer.js → types/AppRenderer.js} +0 -0
  47. /package/dist/esm/{RouteUrlParser.js → types/RouteUrlParser.js} +0 -0
  48. /package/dist/esm/{RenderResponse.js → types/index.js} +0 -0
  49. /package/types/{RouteUrlParser.d.ts → types/RouteUrlParser.d.ts} +0 -0
@@ -0,0 +1,59 @@
1
+ export declare const mountainBikeVariant: {
2
+ uid: string;
3
+ componentName: string;
4
+ dataSource: string;
5
+ fields: {
6
+ content: {
7
+ value: string;
8
+ };
9
+ heading: {
10
+ value: string;
11
+ };
12
+ };
13
+ };
14
+ export declare const cityBikeVariant: {
15
+ uid: string;
16
+ componentName: string;
17
+ dataSource: string;
18
+ fields: {
19
+ content: {
20
+ value: string;
21
+ };
22
+ heading: {
23
+ value: string;
24
+ };
25
+ };
26
+ };
27
+ export declare const component_variant: {
28
+ uid: string;
29
+ componentName: string;
30
+ dataSource: string;
31
+ fields: {
32
+ content: {
33
+ value: string;
34
+ };
35
+ heading: {
36
+ value: string;
37
+ };
38
+ };
39
+ };
40
+ export declare const getPersonalizeLayoutData: (variant: string, language?: string, path?: string) => {
41
+ sitecore: {
42
+ context: {
43
+ pageEditing: boolean;
44
+ site: {
45
+ name: string;
46
+ };
47
+ visitorIdentificationTimestamp: number;
48
+ language: string;
49
+ variantId: string;
50
+ itemPath: string;
51
+ };
52
+ route: {
53
+ name: string;
54
+ placeholders: {
55
+ main: {};
56
+ };
57
+ };
58
+ };
59
+ };
@@ -0,0 +1,35 @@
1
+ import { LayoutServiceData } from '@sitecore-jss/sitecore-jss/layout';
2
+ import { DictionaryPhrases } from '@sitecore-jss/sitecore-jss/types/i18n';
3
+ /**
4
+ * Response object produced by the AppRenderer callback function.
5
+ */
6
+ export interface RenderResponse {
7
+ /**
8
+ * The rendered HTML to return to the client
9
+ */
10
+ html: string;
11
+ /**
12
+ * Set the HTTP status code. If not set, the status code returned from Layout Service is returned.
13
+ */
14
+ status?: number;
15
+ /**
16
+ * Sets a redirect URL, causing the reply to send a HTTP redirect instead of the HTML content.
17
+ * Note: when using this you must set the status code to 301 or 302.
18
+ */
19
+ redirect?: string;
20
+ }
21
+ /**
22
+ * AppRenderer is a function that renders a JSS app's markup for a given route and data.
23
+ */
24
+ export type AppRenderer = (callback: (error: Error | null, result: RenderResponse | null) => void, path: string,
25
+ /**
26
+ * Data returned by Layout Service. If the route does not exist, null.
27
+ */
28
+ data: LayoutServiceData,
29
+ /**
30
+ * Additional data to pass to the view
31
+ */
32
+ viewBag: {
33
+ [key: string]: unknown;
34
+ dictionary: DictionaryPhrases;
35
+ }) => void;
@@ -0,0 +1,3 @@
1
+ export { AppRenderer, RenderResponse } from './AppRenderer';
2
+ export { RouteUrlParser } from './RouteUrlParser';
3
+ export { PersonalizeConfig } from './personalize';
@@ -0,0 +1,85 @@
1
+ import { GraphQLPersonalizeServiceConfig } from '@sitecore-jss/sitecore-jss/personalize';
2
+ import { IncomingMessage, OutgoingMessage } from 'http';
3
+ export type CdpServiceConfig = {
4
+ /**
5
+ * Your Sitecore Edge Platform endpoint
6
+ * Default is https://edge-platform.sitecorecloud.io
7
+ */
8
+ sitecoreEdgeUrl?: string;
9
+ /**
10
+ * Your unified Sitecore Edge Context Id
11
+ */
12
+ sitecoreEdgeContextId: string;
13
+ /**
14
+ * The Sitecore CDP channel to use for events. Uses 'WEB' by default.
15
+ */
16
+ channel?: string;
17
+ /**
18
+ * Currency for CDP request. Uses 'USA' as default.
19
+ */
20
+ currency?: string;
21
+ /**
22
+ * Timeout (ms) for CDP request. Default is 400.
23
+ */
24
+ timeout?: number;
25
+ };
26
+ export type PersonalizeConfig = {
27
+ /**
28
+ * function, determines if personalization should be turned off, based on cookie, header, or other considerations
29
+ * @param {IncomingMessage} [req] request object
30
+ * @param {OutgoingMessage} [res] response object
31
+ */
32
+ disabled?: (req?: IncomingMessage, res?: OutgoingMessage) => boolean;
33
+ /**
34
+ * Function used to determine if route should be excluded.
35
+ * @param {string} pathname The pathname
36
+ * @returns {boolean} Whether to exclude the route
37
+ */
38
+ excludeRoute?: (pathname: string) => boolean;
39
+ /**
40
+ * Fallback hostname in case `host` header is not present
41
+ * @default localhost
42
+ */
43
+ defaultHostname?: string;
44
+ /**
45
+ * Fallback language in case language can't be read from layout data
46
+ * @default 'en'
47
+ */
48
+ defaultLanguage?: string;
49
+ /**
50
+ * Site name for current site
51
+ */
52
+ sitecoreSiteName: string;
53
+ /**
54
+ * Configuration for your Sitecore Experience Edge endpoint
55
+ */
56
+ edgeConfig: Omit<GraphQLPersonalizeServiceConfig, 'fetch'>;
57
+ /**
58
+ * Configuration for your Sitecore CDP endpoint
59
+ */
60
+ cdpConfig: CdpServiceConfig;
61
+ /**
62
+ * Optional Sitecore Personalize scope identifier allowing you to isolate your personalization data between XM Cloud environments
63
+ */
64
+ scope?: string;
65
+ };
66
+ /**
67
+ * Object model of Experience Context data
68
+ */
69
+ export type ExperienceParams = {
70
+ referrer: string;
71
+ utm: {
72
+ [key: string]: string | undefined;
73
+ campaign: string | undefined;
74
+ source: string | undefined;
75
+ medium: string | undefined;
76
+ content: string | undefined;
77
+ };
78
+ };
79
+ /**
80
+ * Object model of personalize execution data
81
+ */
82
+ export type PersonalizeExecution = {
83
+ friendlyId: string;
84
+ variantIds: string[];
85
+ };
@@ -1,10 +0,0 @@
1
- import { RenderResponse } from './RenderResponse';
2
- export type AppRenderer = (callback: (error: Error | null, result: RenderResponse | null) => void, path: string,
3
- /**
4
- * Data returned by Layout Service. If the route does not exist, null.
5
- */
6
- data: {
7
- [key: string]: unknown;
8
- }, viewBag: {
9
- [key: string]: unknown;
10
- }) => void;
@@ -1,15 +0,0 @@
1
- export interface RenderResponse {
2
- /**
3
- * The rendered HTML to return to the client
4
- */
5
- html: string;
6
- /**
7
- * Set the HTTP status code. If not set, the status code returned from Layout Service is returned.
8
- */
9
- status?: number;
10
- /**
11
- * Sets a redirect URL, causing the reply to send a HTTP redirect instead of the HTML content.
12
- * Note: when using this you must set the status code to 301 or 302.
13
- */
14
- redirect?: string;
15
- }
File without changes
File without changes