@sitecore-jss/sitecore-jss-nextjs 22.0.0-canary.4 → 22.0.0-canary.43
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/README.md +5 -3
- package/context.d.ts +1 -0
- package/context.js +1 -0
- package/dist/cjs/ComponentBuilder.js +63 -0
- package/dist/cjs/components/BYOCWrapper.js +47 -0
- package/dist/cjs/components/FEaaSWrapper.js +49 -0
- package/dist/cjs/components/Link.js +4 -0
- package/dist/cjs/components/NextImage.js +2 -10
- package/dist/cjs/components/RichText.js +10 -10
- package/dist/cjs/context/context.js +83 -0
- package/dist/cjs/context/index.js +5 -0
- package/dist/cjs/editing/constants.js +6 -0
- package/dist/cjs/editing/editing-config-middleware.js +49 -0
- package/dist/cjs/editing/editing-data-middleware.js +3 -3
- package/dist/cjs/editing/editing-data-service.js +16 -8
- package/dist/cjs/editing/editing-render-middleware.js +25 -11
- package/dist/cjs/editing/feaas-render-middleware.js +87 -0
- package/dist/cjs/editing/index.js +7 -1
- package/dist/cjs/editing/render-middleware.js +27 -0
- package/dist/cjs/editing/vercel-editing-data-cache.js +48 -0
- package/dist/cjs/graphql/index.js +7 -0
- package/dist/cjs/index.js +38 -13
- package/dist/cjs/middleware/index.js +3 -5
- package/dist/cjs/middleware/middleware.js +18 -2
- package/dist/cjs/middleware/multisite-middleware.js +14 -8
- package/dist/cjs/middleware/personalize-middleware.js +62 -56
- package/dist/cjs/middleware/redirects-middleware.js +64 -21
- package/dist/cjs/services/base-graphql-sitemap-service.js +7 -6
- package/dist/cjs/services/component-props-service.js +6 -6
- package/dist/cjs/site/index.js +5 -0
- package/dist/cjs/utils/index.js +11 -0
- package/dist/cjs/{utils.js → utils/utils.js} +7 -16
- package/dist/esm/ComponentBuilder.js +59 -0
- package/dist/esm/components/BYOCWrapper.js +42 -0
- package/dist/esm/components/FEaaSWrapper.js +44 -0
- package/dist/esm/components/Link.js +4 -0
- package/dist/esm/components/NextImage.js +1 -8
- package/dist/esm/components/RichText.js +10 -10
- package/dist/esm/context/context.js +79 -0
- package/dist/esm/context/index.js +1 -0
- package/dist/esm/editing/constants.js +3 -0
- package/dist/esm/editing/editing-config-middleware.js +45 -0
- package/dist/esm/editing/editing-data-middleware.js +2 -2
- package/dist/esm/editing/editing-data-service.js +14 -6
- package/dist/esm/editing/editing-render-middleware.js +25 -11
- package/dist/esm/editing/feaas-render-middleware.js +83 -0
- package/dist/esm/editing/index.js +3 -0
- package/dist/esm/editing/render-middleware.js +23 -0
- package/dist/esm/editing/vercel-editing-data-cache.js +44 -0
- package/dist/esm/graphql/index.js +1 -0
- package/dist/esm/index.js +10 -7
- package/dist/esm/middleware/index.js +1 -2
- package/dist/esm/middleware/middleware.js +18 -2
- package/dist/esm/middleware/multisite-middleware.js +14 -8
- package/dist/esm/middleware/personalize-middleware.js +65 -59
- package/dist/esm/middleware/redirects-middleware.js +64 -21
- package/dist/esm/services/base-graphql-sitemap-service.js +7 -6
- package/dist/esm/services/component-props-service.js +6 -6
- package/dist/esm/site/index.js +1 -0
- package/dist/esm/utils/index.js +2 -0
- package/dist/esm/{utils.js → utils/utils.js} +7 -13
- package/graphql.d.ts +1 -0
- package/graphql.js +1 -0
- package/package.json +15 -12
- package/site.d.ts +1 -0
- package/site.js +1 -0
- package/types/ComponentBuilder.d.ts +61 -0
- package/types/components/BYOCWrapper.d.ts +19 -0
- package/types/components/ComponentPropsContext.d.ts +1 -0
- package/types/components/FEaaSWrapper.d.ts +21 -0
- package/types/components/Link.d.ts +2 -1
- package/types/components/NextImage.d.ts +3 -3
- package/types/components/Placeholder.d.ts +3 -1
- package/types/components/RichText.d.ts +6 -0
- package/types/context/context.d.ts +116 -0
- package/types/context/index.d.ts +1 -0
- package/types/editing/constants.d.ts +3 -0
- package/types/editing/editing-config-middleware.d.ts +29 -0
- package/types/editing/editing-data-service.d.ts +12 -4
- package/types/editing/editing-render-middleware.d.ts +2 -1
- package/types/editing/feaas-render-middleware.d.ts +32 -0
- package/types/editing/index.d.ts +3 -0
- package/types/editing/render-middleware.d.ts +15 -0
- package/types/editing/vercel-editing-data-cache.d.ts +19 -0
- package/types/graphql/index.d.ts +1 -0
- package/types/index.d.ts +12 -9
- package/types/middleware/index.d.ts +1 -2
- package/types/middleware/middleware.d.ts +8 -0
- package/types/middleware/multisite-middleware.d.ts +15 -0
- package/types/middleware/personalize-middleware.d.ts +53 -14
- package/types/middleware/redirects-middleware.d.ts +1 -1
- package/types/services/base-graphql-sitemap-service.d.ts +7 -10
- package/types/services/component-props-service.d.ts +2 -2
- package/types/sharedTypes/component-props.d.ts +5 -1
- package/types/sharedTypes/module-factory.d.ts +33 -0
- package/types/site/index.d.ts +1 -0
- package/types/utils/index.d.ts +2 -0
- package/types/{utils.d.ts → utils/utils.d.ts} +2 -0
- package/utils.d.ts +1 -0
- package/utils.js +1 -0
- package/types/sharedTypes/component-module.d.ts +0 -13
- /package/dist/cjs/sharedTypes/{component-module.js → module-factory.js} +0 -0
- /package/dist/esm/sharedTypes/{component-module.js → module-factory.js} +0 -0
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { FEaaSWrapper } from '@sitecore-jss/sitecore-jss-react';
|
|
2
|
+
import { GetStaticComponentProps, GetServerSideComponentProps } from '../sharedTypes/component-props';
|
|
3
|
+
/**
|
|
4
|
+
* This is a repackaged version of the React FEaaSWrapper component with support for
|
|
5
|
+
* server rendering in Next.js (using component-level data-fetching feature of JSS).
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* Will be called during SSG
|
|
9
|
+
* @param {ComponentRendering} rendering
|
|
10
|
+
* @param {LayoutServiceData} layoutData
|
|
11
|
+
* @returns {GetStaticPropsContext} context
|
|
12
|
+
*/
|
|
13
|
+
export declare const getStaticProps: GetStaticComponentProps;
|
|
14
|
+
/**
|
|
15
|
+
* Will be called during SSR
|
|
16
|
+
* @param {ComponentRendering} rendering
|
|
17
|
+
* @param {LayoutServiceData} layoutData
|
|
18
|
+
* @returns {GetStaticPropsContext} context
|
|
19
|
+
*/
|
|
20
|
+
export declare const getServerSideProps: GetServerSideComponentProps;
|
|
21
|
+
export default FEaaSWrapper;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
/// <reference types="@types/react" />
|
|
1
2
|
import React from 'react';
|
|
2
3
|
import { LinkProps as ReactLinkProps } from '@sitecore-jss/sitecore-jss-react';
|
|
3
4
|
export type LinkProps = ReactLinkProps & {
|
|
@@ -7,4 +8,4 @@ export type LinkProps = ReactLinkProps & {
|
|
|
7
8
|
*/
|
|
8
9
|
internalLinkMatcher?: RegExp;
|
|
9
10
|
};
|
|
10
|
-
export declare const Link: React.ForwardRefExoticComponent<
|
|
11
|
+
export declare const Link: React.ForwardRefExoticComponent<Omit<LinkProps, "ref"> & React.RefAttributes<HTMLAnchorElement>>;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
+
/// <reference types="@types/react" />
|
|
1
2
|
import React from 'react';
|
|
2
3
|
import { ImageProps } from '@sitecore-jss/sitecore-jss-react';
|
|
3
|
-
import {
|
|
4
|
-
type NextImageProps =
|
|
5
|
-
export declare const sitecoreLoader: ImageLoader;
|
|
4
|
+
import { ImageProps as NextImageProperties } from 'next/image';
|
|
5
|
+
type NextImageProps = ImageProps & Partial<NextImageProperties>;
|
|
6
6
|
export declare const NextImage: React.FC<NextImageProps>;
|
|
7
7
|
export {};
|
|
@@ -1,2 +1,4 @@
|
|
|
1
|
+
/// <reference types="@types/react" />
|
|
2
|
+
import React from 'react';
|
|
1
3
|
import { PlaceholderComponentProps } from '@sitecore-jss/sitecore-jss-react';
|
|
2
|
-
export declare const Placeholder: (props: PlaceholderComponentProps) => JSX.Element;
|
|
4
|
+
export declare const Placeholder: (props: PlaceholderComponentProps) => React.JSX.Element;
|
|
@@ -6,6 +6,12 @@ export type RichTextProps = ReactRichTextProps & {
|
|
|
6
6
|
* @default 'a[href^="/"]'
|
|
7
7
|
*/
|
|
8
8
|
internalLinksSelector?: string;
|
|
9
|
+
/**
|
|
10
|
+
* Controls the prefetch of internal links. This can be beneficial if you have RichText fields
|
|
11
|
+
* with large numbers of internal links in them.
|
|
12
|
+
* @default true
|
|
13
|
+
*/
|
|
14
|
+
prefetchLinks?: boolean;
|
|
9
15
|
};
|
|
10
16
|
export declare const RichText: {
|
|
11
17
|
(props: RichTextProps): JSX.Element;
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
import { LayoutServicePageState } from '@sitecore-jss/sitecore-jss-react';
|
|
2
|
+
/**
|
|
3
|
+
* Software Development Kit (SDK) instance
|
|
4
|
+
*/
|
|
5
|
+
export type SDK<SDKType = unknown> = {
|
|
6
|
+
/**
|
|
7
|
+
* The Software Development Kit (SDK) library instance
|
|
8
|
+
*/
|
|
9
|
+
sdk: SDKType;
|
|
10
|
+
/**
|
|
11
|
+
* Initializes the Software Development Kit (SDK)
|
|
12
|
+
*/
|
|
13
|
+
init: (props: InitSDKProps) => Promise<void>;
|
|
14
|
+
};
|
|
15
|
+
/**
|
|
16
|
+
* Software Development Kits (SDKs) to be initialized
|
|
17
|
+
*/
|
|
18
|
+
type SDKModulesType = Record<string, SDK>;
|
|
19
|
+
/**
|
|
20
|
+
* Properties that are passed to the Context.
|
|
21
|
+
*/
|
|
22
|
+
export interface ContextInitProps {
|
|
23
|
+
/**
|
|
24
|
+
* Your Sitecore site name
|
|
25
|
+
*/
|
|
26
|
+
siteName?: string;
|
|
27
|
+
/**
|
|
28
|
+
* Sitecore page state (normal, preview, edit)
|
|
29
|
+
*/
|
|
30
|
+
pageState?: LayoutServicePageState;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Configuration that is passed to the Context.
|
|
34
|
+
*/
|
|
35
|
+
export interface ContextConfig<SDKModules extends SDKModulesType> {
|
|
36
|
+
/**
|
|
37
|
+
* Your Sitecore Edge URL
|
|
38
|
+
*/
|
|
39
|
+
sitecoreEdgeUrl: string;
|
|
40
|
+
/**
|
|
41
|
+
* Your Sitecore Edge Context ID
|
|
42
|
+
*/
|
|
43
|
+
sitecoreEdgeContextId: string;
|
|
44
|
+
/**
|
|
45
|
+
* Your Sitecore site name
|
|
46
|
+
*/
|
|
47
|
+
siteName: string;
|
|
48
|
+
/**
|
|
49
|
+
* Software Development Kits (SDKs) to be initialized
|
|
50
|
+
*/
|
|
51
|
+
sdks: {
|
|
52
|
+
[module in keyof SDKModules]: SDKModules[module];
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Properties that are passed to the Software Development Kit (SDK) initialization function.
|
|
57
|
+
*/
|
|
58
|
+
type InitSDKProps = Omit<ContextConfig<SDKModulesType>, 'sdks'>;
|
|
59
|
+
/**
|
|
60
|
+
* Context instance that is used to initialize the application Context and associated Software Development Kits (SDKs).
|
|
61
|
+
*/
|
|
62
|
+
export declare class Context<SDKModules extends SDKModulesType> {
|
|
63
|
+
protected props: ContextConfig<SDKModules>;
|
|
64
|
+
/**
|
|
65
|
+
* Indicates whether the Context and SDK(s) have been initialized
|
|
66
|
+
*/
|
|
67
|
+
isInitialized: boolean;
|
|
68
|
+
/**
|
|
69
|
+
* The Sitecore Edge URL
|
|
70
|
+
*/
|
|
71
|
+
readonly sitecoreEdgeUrl: string;
|
|
72
|
+
/**
|
|
73
|
+
* The Sitecore Edge Context ID
|
|
74
|
+
*/
|
|
75
|
+
readonly sitecoreEdgeContextId: string;
|
|
76
|
+
/**
|
|
77
|
+
* The Sitecore site name
|
|
78
|
+
*/
|
|
79
|
+
siteName: string;
|
|
80
|
+
/**
|
|
81
|
+
* Sitecore page state (normal, preview, edit)
|
|
82
|
+
*/
|
|
83
|
+
pageState: LayoutServicePageState;
|
|
84
|
+
/**
|
|
85
|
+
* Software Development Kits (SDKs) to be initialized
|
|
86
|
+
*/
|
|
87
|
+
readonly sdks: {
|
|
88
|
+
[module in keyof SDKModules]?: SDKModules[module]['sdk'];
|
|
89
|
+
};
|
|
90
|
+
/**
|
|
91
|
+
* Promises for the SDKs
|
|
92
|
+
*/
|
|
93
|
+
protected sdkPromises: {
|
|
94
|
+
[module in keyof SDKModules]?: Promise<SDKModules[module]['sdk']>;
|
|
95
|
+
};
|
|
96
|
+
protected sdkErrors: {
|
|
97
|
+
[module in keyof SDKModules]?: string;
|
|
98
|
+
};
|
|
99
|
+
constructor(props: ContextConfig<SDKModules>);
|
|
100
|
+
init(props?: ContextInitProps): void;
|
|
101
|
+
/**
|
|
102
|
+
* Retrieves the Software Development Kit (SDK) instance, ensuring it is initialized before returning
|
|
103
|
+
*
|
|
104
|
+
* @param {string} name SDK name
|
|
105
|
+
* @returns initialized SDK
|
|
106
|
+
*/
|
|
107
|
+
getSDK: <T extends keyof SDKModules>(name: T) => Promise<SDKModules[T]["sdk"]>;
|
|
108
|
+
/**
|
|
109
|
+
* Initializes the Software Development Kit (SDK)
|
|
110
|
+
*
|
|
111
|
+
* @param {T} name SDK name
|
|
112
|
+
* @returns {void}
|
|
113
|
+
*/
|
|
114
|
+
protected initSDK<T extends keyof SDKModules>(name: T): void;
|
|
115
|
+
}
|
|
116
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { Context, ContextConfig, SDK } from './context';
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { NextApiRequest, NextApiResponse } from 'next';
|
|
2
|
+
import { Metadata } from '@sitecore-jss/sitecore-jss-dev-tools';
|
|
3
|
+
export type EditingConfigMiddlewareConfig = {
|
|
4
|
+
/**
|
|
5
|
+
* Components available in the application
|
|
6
|
+
*/
|
|
7
|
+
components: string[] | Map<string, unknown>;
|
|
8
|
+
/**
|
|
9
|
+
* Application metadata
|
|
10
|
+
*/
|
|
11
|
+
metadata: Metadata;
|
|
12
|
+
};
|
|
13
|
+
/**
|
|
14
|
+
* Middleware / handler used in the editing config API route in xmcloud add on (e.g. '/api/editing/config')
|
|
15
|
+
* provides configuration information to determine feature compatibility on Pages side.
|
|
16
|
+
*/
|
|
17
|
+
export declare class EditingConfigMiddleware {
|
|
18
|
+
protected config: EditingConfigMiddlewareConfig;
|
|
19
|
+
/**
|
|
20
|
+
* @param {EditingConfigMiddlewareConfig} [config] Editing configuration middleware config
|
|
21
|
+
*/
|
|
22
|
+
constructor(config: EditingConfigMiddlewareConfig);
|
|
23
|
+
/**
|
|
24
|
+
* Gets the Next.js API route handler
|
|
25
|
+
* @returns middleware handler
|
|
26
|
+
*/
|
|
27
|
+
getHandler(): (req: NextApiRequest, res: NextApiResponse) => Promise<void>;
|
|
28
|
+
private handler;
|
|
29
|
+
}
|
|
@@ -2,13 +2,15 @@ import { AxiosDataFetcher } from '@sitecore-jss/sitecore-jss';
|
|
|
2
2
|
import { EditingData } from './editing-data';
|
|
3
3
|
import { EditingDataCache } from './editing-data-cache';
|
|
4
4
|
import { PreviewData } from 'next';
|
|
5
|
-
export declare const QUERY_PARAM_EDITING_SECRET = "secret";
|
|
6
5
|
/**
|
|
7
6
|
* Data for Next.js Preview (Editing) mode
|
|
8
7
|
*/
|
|
9
8
|
export interface EditingPreviewData {
|
|
10
9
|
key: string;
|
|
11
10
|
serverUrl?: string;
|
|
11
|
+
params?: {
|
|
12
|
+
[key: string]: string;
|
|
13
|
+
};
|
|
12
14
|
}
|
|
13
15
|
/**
|
|
14
16
|
* Defines an editing data service implementation
|
|
@@ -20,7 +22,9 @@ export interface EditingDataService {
|
|
|
20
22
|
* @param {string} serverUrl The server url e.g. which can be used for further API requests
|
|
21
23
|
* @returns The {@link EditingPreviewData} containing the information to use for retrieval
|
|
22
24
|
*/
|
|
23
|
-
setEditingData(data: EditingData, serverUrl: string
|
|
25
|
+
setEditingData(data: EditingData, serverUrl: string, params?: {
|
|
26
|
+
[key: string]: string;
|
|
27
|
+
}): Promise<EditingPreviewData>;
|
|
24
28
|
/**
|
|
25
29
|
* Retrieves Sitecore editor payload data
|
|
26
30
|
* @param {PreviewData} previewData Editing preview data containing the information to use for retrieval
|
|
@@ -107,14 +111,18 @@ export declare class ServerlessEditingDataService implements EditingDataService
|
|
|
107
111
|
* @param {string} serverUrl The server url to use for subsequent data API requests
|
|
108
112
|
* @returns {Promise} The {@link EditingPreviewData} containing the generated key and serverUrl to use for retrieval
|
|
109
113
|
*/
|
|
110
|
-
setEditingData(data: EditingData, serverUrl: string
|
|
114
|
+
setEditingData(data: EditingData, serverUrl: string, params?: {
|
|
115
|
+
[key: string]: string;
|
|
116
|
+
}): Promise<EditingPreviewData>;
|
|
111
117
|
/**
|
|
112
118
|
* Retrieves Sitecore editor payload data by key
|
|
113
119
|
* @param {PreviewData} previewData Editing preview data containing the key and serverUrl to use for retrieval
|
|
114
120
|
* @returns {Promise} The {@link EditingData}
|
|
115
121
|
*/
|
|
116
122
|
getEditingData(previewData: PreviewData): Promise<EditingData | undefined>;
|
|
117
|
-
protected getUrl(serverUrl: string, key: string
|
|
123
|
+
protected getUrl(serverUrl: string, key: string, params?: {
|
|
124
|
+
[key: string]: string;
|
|
125
|
+
}): string;
|
|
118
126
|
}
|
|
119
127
|
/**
|
|
120
128
|
* The `EditingDataService` default instance.
|
|
@@ -2,6 +2,7 @@ import { NextApiRequest, NextApiResponse } from 'next';
|
|
|
2
2
|
import { AxiosDataFetcher } from '@sitecore-jss/sitecore-jss';
|
|
3
3
|
import { EditingData } from './editing-data';
|
|
4
4
|
import { EditingDataService } from './editing-data-service';
|
|
5
|
+
import { RenderMiddlewareBase } from './render-middleware';
|
|
5
6
|
export interface EditingRenderMiddlewareConfig {
|
|
6
7
|
/**
|
|
7
8
|
* The `AxiosDataFetcher` instance to use for API requests.
|
|
@@ -41,7 +42,7 @@ export interface EditingRenderMiddlewareConfig {
|
|
|
41
42
|
* Middleware / handler for use in the editing render Next.js API route (e.g. '/api/editing/render')
|
|
42
43
|
* which is required for Sitecore editing support.
|
|
43
44
|
*/
|
|
44
|
-
export declare class EditingRenderMiddleware {
|
|
45
|
+
export declare class EditingRenderMiddleware extends RenderMiddlewareBase {
|
|
45
46
|
private editingDataService;
|
|
46
47
|
private dataFetcher;
|
|
47
48
|
private resolvePageUrl;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { NextApiRequest, NextApiResponse } from 'next';
|
|
2
|
+
import { RenderMiddlewareBase } from './render-middleware';
|
|
3
|
+
/**
|
|
4
|
+
* Configuration for `FEAASRenderMiddleware`.
|
|
5
|
+
*/
|
|
6
|
+
export interface FEAASRenderMiddlewareConfig {
|
|
7
|
+
/**
|
|
8
|
+
* Defines FEAAS page route to render.
|
|
9
|
+
* This may be necessary for certain custom Next.js routing configurations.
|
|
10
|
+
* @default /feaas/render
|
|
11
|
+
*/
|
|
12
|
+
pageUrl?: string;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Middleware / handler for use in the feaas render Next.js API route (e.g. '/api/editing/feaas/render')
|
|
16
|
+
* which is required for Sitecore editing support.
|
|
17
|
+
*/
|
|
18
|
+
export declare class FEAASRenderMiddleware extends RenderMiddlewareBase {
|
|
19
|
+
protected config?: FEAASRenderMiddlewareConfig | undefined;
|
|
20
|
+
private pageUrl;
|
|
21
|
+
private defaultPageUrl;
|
|
22
|
+
/**
|
|
23
|
+
* @param {EditingRenderMiddlewareConfig} [config] Editing render middleware config
|
|
24
|
+
*/
|
|
25
|
+
constructor(config?: FEAASRenderMiddlewareConfig | undefined);
|
|
26
|
+
/**
|
|
27
|
+
* Gets the Next.js API route handler
|
|
28
|
+
* @returns route handler
|
|
29
|
+
*/
|
|
30
|
+
getHandler(): (req: NextApiRequest, res: NextApiResponse) => Promise<void>;
|
|
31
|
+
private handler;
|
|
32
|
+
}
|
package/types/editing/index.d.ts
CHANGED
|
@@ -3,3 +3,6 @@ export { EditingDataCache, EditingDataDiskCache } from './editing-data-cache';
|
|
|
3
3
|
export { EditingDataMiddleware, EditingDataMiddlewareConfig } from './editing-data-middleware';
|
|
4
4
|
export { EditingRenderMiddleware, EditingRenderMiddlewareConfig, } from './editing-render-middleware';
|
|
5
5
|
export { EditingPreviewData, EditingDataService, BasicEditingDataService, BasicEditingDataServiceConfig, ServerlessEditingDataService, ServerlessEditingDataServiceConfig, editingDataService, } from './editing-data-service';
|
|
6
|
+
export { VercelEditingDataCache } from './vercel-editing-data-cache';
|
|
7
|
+
export { FEAASRenderMiddleware, FEAASRenderMiddlewareConfig } from './feaas-render-middleware';
|
|
8
|
+
export { EditingConfigMiddleware, EditingConfigMiddlewareConfig, } from './editing-config-middleware';
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Base class for middleware that handles pages and components rendering in Sitecore Editors.
|
|
3
|
+
*/
|
|
4
|
+
export declare abstract class RenderMiddlewareBase {
|
|
5
|
+
/**
|
|
6
|
+
* Gets query parameters that should be passed along to subsequent requests (e.g. for deployment protection bypass)
|
|
7
|
+
* @param {Object} query Object of query parameters from incoming URL
|
|
8
|
+
* @returns Object of approved query parameters
|
|
9
|
+
*/
|
|
10
|
+
protected getQueryParamsForPropagation: (query: Partial<{
|
|
11
|
+
[key: string]: string | string[];
|
|
12
|
+
}>) => {
|
|
13
|
+
[key: string]: string;
|
|
14
|
+
};
|
|
15
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { VercelKV } from '@vercel/kv';
|
|
2
|
+
import { EditingDataCache } from './editing-data-cache';
|
|
3
|
+
import { EditingData } from './editing-data';
|
|
4
|
+
/**
|
|
5
|
+
* Implementation of editing cache for Vercel deployments
|
|
6
|
+
* Uses Vercel KV database and client to store data
|
|
7
|
+
* Set TTL for cache data in constructor (default: 60 seconds)
|
|
8
|
+
*/
|
|
9
|
+
export declare class VercelEditingDataCache implements EditingDataCache {
|
|
10
|
+
protected redisCache: VercelKV;
|
|
11
|
+
private defaultTtl;
|
|
12
|
+
/**
|
|
13
|
+
* @param {string} redisUrl KV endpoint URL. Usually stored in process.env.KV_REST_API_URL
|
|
14
|
+
* @param {string} redisToken KV endpoint tokem. Usually stored in process.env.KV_REST_API_TOKEN
|
|
15
|
+
*/
|
|
16
|
+
constructor(redisUrl: string | undefined, redisToken: string | undefined);
|
|
17
|
+
set(key: string, editingData: EditingData): Promise<void>;
|
|
18
|
+
get(key: string): Promise<EditingData | undefined>;
|
|
19
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { GraphQLClientError, RetryStrategy, DefaultRetryStrategy, GraphQLRequestClient, GraphQLRequestClientFactory, GraphQLRequestClientFactoryConfig, getEdgeProxyContentUrl, } from '@sitecore-jss/sitecore-jss/graphql';
|
package/types/index.d.ts
CHANGED
|
@@ -1,13 +1,11 @@
|
|
|
1
|
-
export { constants, HttpDataFetcher, HttpResponse, AxiosResponse, AxiosDataFetcher, AxiosDataFetcherConfig, NativeDataFetcher, NativeDataFetcherConfig, enableDebug, } from '@sitecore-jss/sitecore-jss';
|
|
2
|
-
export {
|
|
3
|
-
export { LayoutService, LayoutServiceData, LayoutServicePageState, LayoutServiceContext, LayoutServiceContextData, GraphQLLayoutService, GraphQLLayoutServiceConfig, RestLayoutService, RestLayoutServiceConfig, PlaceholderData, PlaceholdersData, RouteData, Field, Item, HtmlElementRendering, getChildPlaceholder, getFieldValue, ComponentRendering, ComponentFields, ComponentParams, RenderingType, EDITING_COMPONENT_PLACEHOLDER, EDITING_COMPONENT_ID, } from '@sitecore-jss/sitecore-jss/layout';
|
|
1
|
+
export { constants, HttpDataFetcher, HttpResponse, AxiosResponse, AxiosDataFetcher, AxiosDataFetcherConfig, NativeDataFetcher, NativeDataFetcherConfig, HTMLLink, enableDebug, debug, } from '@sitecore-jss/sitecore-jss';
|
|
2
|
+
export { LayoutService, LayoutServiceData, LayoutServicePageState, LayoutServiceContext, LayoutServiceContextData, GraphQLLayoutService, GraphQLLayoutServiceConfig, RestLayoutService, RestLayoutServiceConfig, PlaceholderData, PlaceholdersData, RouteData, Field, Item, HtmlElementRendering, getChildPlaceholder, getFieldValue, ComponentRendering, ComponentFields, ComponentParams, RenderingType, EDITING_COMPONENT_PLACEHOLDER, EDITING_COMPONENT_ID, getContentStylesheetLink, } from '@sitecore-jss/sitecore-jss/layout';
|
|
4
3
|
export { mediaApi } from '@sitecore-jss/sitecore-jss/media';
|
|
5
4
|
export { trackingApi, TrackingRequestOptions, CampaignInstance, GoalInstance, OutcomeInstance, EventInstance, PageViewInstance, } from '@sitecore-jss/sitecore-jss/tracking';
|
|
6
5
|
export { DictionaryPhrases, DictionaryService, GraphQLDictionaryService, GraphQLDictionaryServiceConfig, RestDictionaryService, RestDictionaryServiceConfig, } from '@sitecore-jss/sitecore-jss/i18n';
|
|
7
|
-
export { personalizeLayout, getPersonalizedRewrite, getPersonalizedRewriteData, normalizePersonalizedRewrite, CdpHelper,
|
|
8
|
-
export {
|
|
9
|
-
export {
|
|
10
|
-
export { ComponentModule } from './sharedTypes/component-module';
|
|
6
|
+
export { personalizeLayout, getPersonalizedRewrite, getPersonalizedRewriteData, normalizePersonalizedRewrite, CdpHelper, } from '@sitecore-jss/sitecore-jss/personalize';
|
|
7
|
+
export { ComponentPropsCollection, ComponentPropsError, GetStaticComponentProps, GetServerSideComponentProps, } from './sharedTypes/component-props';
|
|
8
|
+
export { ModuleFactory, Module } from './sharedTypes/module-factory';
|
|
11
9
|
export { ComponentPropsService } from './services/component-props-service';
|
|
12
10
|
export { DisconnectedSitemapService } from './services/disconnected-sitemap-service';
|
|
13
11
|
export { GraphQLSitemapService, GraphQLSitemapServiceConfig, } from './services/graphql-sitemap-service';
|
|
@@ -15,10 +13,15 @@ export { MultisiteGraphQLSitemapService, MultisiteGraphQLSitemapServiceConfig, }
|
|
|
15
13
|
export { GraphQLSitemapXmlService, GraphQLSitemapXmlServiceConfig, GraphQLErrorPagesService, GraphQLErrorPagesServiceConfig, RobotsQueryResult, GraphQLRobotsService, GraphQLRobotsServiceConfig, ErrorPages, SiteInfo, SiteResolver, GraphQLSiteInfoService, GraphQLSiteInfoServiceConfig, getSiteRewrite, getSiteRewriteData, normalizeSiteRewrite, } from '@sitecore-jss/sitecore-jss/site';
|
|
16
14
|
export { StaticPath } from './services/graphql-sitemap-service';
|
|
17
15
|
export { ComponentPropsReactContext, ComponentPropsContextProps, ComponentPropsContext, useComponentProps, } from './components/ComponentPropsContext';
|
|
18
|
-
export { handleEditorFastRefresh, getPublicUrl } from './utils';
|
|
19
16
|
export { Link, LinkProps } from './components/Link';
|
|
20
17
|
export { RichText, RichTextProps } from './components/RichText';
|
|
21
18
|
export { Placeholder } from './components/Placeholder';
|
|
22
19
|
export { EditingComponentPlaceholder } from './components/EditingComponentPlaceholder';
|
|
23
20
|
export { NextImage } from './components/NextImage';
|
|
24
|
-
|
|
21
|
+
import * as FEaaSWrapper from './components/FEaaSWrapper';
|
|
22
|
+
import * as BYOCWrapper from './components/BYOCWrapper';
|
|
23
|
+
export { FEaaSWrapper };
|
|
24
|
+
export { BYOCWrapper };
|
|
25
|
+
export { ComponentBuilder, ComponentBuilderConfig } from './ComponentBuilder';
|
|
26
|
+
export { Context, ContextConfig, SDK } from './context';
|
|
27
|
+
export { ComponentFactory, Image, ImageField, ImageFieldValue, ImageProps, LinkField, LinkFieldValue, Text, TextField, DateField, EditFrame, FEaaSComponent, FEaaSComponentProps, FEaaSComponentParams, fetchFEaaSComponentServerProps, BYOCComponentParams, BYOCComponent, BYOCComponentProps, getComponentLibraryStylesheetLinks, File, FileField, RichTextField, VisitorIdentification, PlaceholderComponentProps, SitecoreContext, SitecoreContextState, SitecoreContextValue, SitecoreContextReactContext, withSitecoreContext, useSitecoreContext, withEditorChromes, withPlaceholder, withDatasourceCheck, ImageSizeParameters, ComponentConsumerProps, WithSitecoreContextOptions, WithSitecoreContextProps, } from '@sitecore-jss/sitecore-jss-react';
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
+
export { debug } from '@sitecore-jss/sitecore-jss';
|
|
1
2
|
export { RedirectsMiddleware, RedirectsMiddlewareConfig } from './redirects-middleware';
|
|
2
3
|
export { PersonalizeMiddleware, PersonalizeMiddlewareConfig } from './personalize-middleware';
|
|
3
4
|
export { MultisiteMiddleware, MultisiteMiddlewareConfig } from './multisite-middleware';
|
|
4
|
-
export { SiteResolver, SiteInfo } from '@sitecore-jss/sitecore-jss/site';
|
|
5
|
-
export { tryParseEnvValue } from '@sitecore-jss/sitecore-jss/utils';
|
|
@@ -28,6 +28,7 @@ export type MiddlewareBaseConfig = {
|
|
|
28
28
|
export declare abstract class MiddlewareBase {
|
|
29
29
|
protected config: MiddlewareBaseConfig;
|
|
30
30
|
protected SITE_SYMBOL: string;
|
|
31
|
+
protected REWRITE_HEADER_NAME: string;
|
|
31
32
|
protected defaultHostname: string;
|
|
32
33
|
constructor(config: MiddlewareBaseConfig);
|
|
33
34
|
/**
|
|
@@ -65,4 +66,11 @@ export declare abstract class MiddlewareBase {
|
|
|
65
66
|
* @returns {SiteInfo} site information
|
|
66
67
|
*/
|
|
67
68
|
protected getSite(req: NextRequest, res?: NextResponse): SiteInfo;
|
|
69
|
+
/**
|
|
70
|
+
* Create a rewrite response
|
|
71
|
+
* @param {string} rewritePath the destionation path
|
|
72
|
+
* @param {NextRequest} req the current request
|
|
73
|
+
* @param {NextResponse} res the current response
|
|
74
|
+
*/
|
|
75
|
+
protected rewrite(rewritePath: string, req: NextRequest, res: NextResponse): NextResponse;
|
|
68
76
|
}
|
|
@@ -1,5 +1,19 @@
|
|
|
1
1
|
import { NextResponse, NextRequest } from 'next/server';
|
|
2
2
|
import { MiddlewareBase, MiddlewareBaseConfig } from './middleware';
|
|
3
|
+
export type CookieAttributes = {
|
|
4
|
+
/**
|
|
5
|
+
* the Secure attribute of the site cookie
|
|
6
|
+
*/
|
|
7
|
+
secure: boolean;
|
|
8
|
+
/**
|
|
9
|
+
* the HttpOnly attribute of the site cookie
|
|
10
|
+
*/
|
|
11
|
+
httpOnly: boolean;
|
|
12
|
+
/**
|
|
13
|
+
* the SameSite attribute of the site cookie
|
|
14
|
+
*/
|
|
15
|
+
sameSite?: true | false | 'lax' | 'strict' | 'none' | undefined;
|
|
16
|
+
};
|
|
3
17
|
export type MultisiteMiddlewareConfig = Omit<MiddlewareBaseConfig, 'disabled'> & {
|
|
4
18
|
/**
|
|
5
19
|
* Function used to determine if site should be resolved from sc_site cookie when present
|
|
@@ -20,5 +34,6 @@ export declare class MultisiteMiddleware extends MiddlewareBase {
|
|
|
20
34
|
* @returns middleware handler
|
|
21
35
|
*/
|
|
22
36
|
getHandler(): (req: NextRequest, res?: NextResponse) => Promise<NextResponse>;
|
|
37
|
+
protected excludeRoute(pathname: string): boolean | undefined;
|
|
23
38
|
private handler;
|
|
24
39
|
}
|
|
@@ -1,7 +1,29 @@
|
|
|
1
1
|
import { NextResponse, NextRequest } from 'next/server';
|
|
2
|
-
import { GraphQLPersonalizeServiceConfig,
|
|
2
|
+
import { GraphQLPersonalizeServiceConfig, PersonalizeInfo } from '@sitecore-jss/sitecore-jss/personalize';
|
|
3
3
|
import { MiddlewareBase, MiddlewareBaseConfig } from './middleware';
|
|
4
|
-
|
|
4
|
+
export type CdpServiceConfig = {
|
|
5
|
+
/**
|
|
6
|
+
* Your Sitecore Edge Platform endpoint
|
|
7
|
+
* Default is https://edge-platform.sitecorecloud.io
|
|
8
|
+
*/
|
|
9
|
+
sitecoreEdgeUrl?: string;
|
|
10
|
+
/**
|
|
11
|
+
* Your unified Sitecore Edge Context Id
|
|
12
|
+
*/
|
|
13
|
+
sitecoreEdgeContextId: string;
|
|
14
|
+
/**
|
|
15
|
+
* The Sitecore CDP channel to use for events. Uses 'WEB' by default.
|
|
16
|
+
*/
|
|
17
|
+
channel?: string;
|
|
18
|
+
/**
|
|
19
|
+
* Currency for CDP request. Uses 'USA' as default.
|
|
20
|
+
*/
|
|
21
|
+
currency?: string;
|
|
22
|
+
/**
|
|
23
|
+
* Timeout (ms) for CDP request. Default is 400.
|
|
24
|
+
*/
|
|
25
|
+
timeout?: number;
|
|
26
|
+
};
|
|
5
27
|
export type PersonalizeMiddlewareConfig = MiddlewareBaseConfig & {
|
|
6
28
|
/**
|
|
7
29
|
* Configuration for your Sitecore Experience Edge endpoint
|
|
@@ -10,14 +32,20 @@ export type PersonalizeMiddlewareConfig = MiddlewareBaseConfig & {
|
|
|
10
32
|
/**
|
|
11
33
|
* Configuration for your Sitecore CDP endpoint
|
|
12
34
|
*/
|
|
13
|
-
cdpConfig:
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
35
|
+
cdpConfig: CdpServiceConfig;
|
|
36
|
+
};
|
|
37
|
+
/**
|
|
38
|
+
* Object model of Experience Context data
|
|
39
|
+
*/
|
|
40
|
+
export type ExperienceParams = {
|
|
41
|
+
referrer: string;
|
|
42
|
+
utm: {
|
|
43
|
+
[key: string]: string | undefined;
|
|
44
|
+
campaign: string | undefined;
|
|
45
|
+
source: string | undefined;
|
|
46
|
+
medium: string | undefined;
|
|
47
|
+
content: string | undefined;
|
|
48
|
+
};
|
|
21
49
|
};
|
|
22
50
|
/**
|
|
23
51
|
* Middleware / handler to support Sitecore Personalize
|
|
@@ -25,7 +53,6 @@ export type PersonalizeMiddlewareConfig = MiddlewareBaseConfig & {
|
|
|
25
53
|
export declare class PersonalizeMiddleware extends MiddlewareBase {
|
|
26
54
|
protected config: PersonalizeMiddlewareConfig;
|
|
27
55
|
private personalizeService;
|
|
28
|
-
private cdpService;
|
|
29
56
|
/**
|
|
30
57
|
* @param {PersonalizeMiddlewareConfig} [config] Personalize middleware config
|
|
31
58
|
*/
|
|
@@ -35,9 +62,21 @@ export declare class PersonalizeMiddleware extends MiddlewareBase {
|
|
|
35
62
|
* @returns middleware handler
|
|
36
63
|
*/
|
|
37
64
|
getHandler(): (req: NextRequest, res?: NextResponse) => Promise<NextResponse>;
|
|
38
|
-
protected
|
|
39
|
-
|
|
40
|
-
|
|
65
|
+
protected initPersonalizeServer({ hostname, siteName, request, response, }: {
|
|
66
|
+
hostname: string;
|
|
67
|
+
siteName: string;
|
|
68
|
+
request: NextRequest;
|
|
69
|
+
response: NextResponse;
|
|
70
|
+
}): Promise<void>;
|
|
71
|
+
protected personalize({ params, personalizeInfo, language, timeout, }: {
|
|
72
|
+
personalizeInfo: PersonalizeInfo;
|
|
73
|
+
params: ExperienceParams;
|
|
74
|
+
language: string;
|
|
75
|
+
timeout?: number;
|
|
76
|
+
}, request: NextRequest): Promise<{
|
|
77
|
+
variantId: string;
|
|
78
|
+
}>;
|
|
41
79
|
protected getExperienceParams(req: NextRequest): ExperienceParams;
|
|
80
|
+
protected excludeRoute(pathname: string): boolean | undefined;
|
|
42
81
|
private handler;
|
|
43
82
|
}
|
|
@@ -24,7 +24,7 @@ export declare class RedirectsMiddleware extends MiddlewareBase {
|
|
|
24
24
|
*/
|
|
25
25
|
constructor(config: RedirectsMiddlewareConfig);
|
|
26
26
|
/**
|
|
27
|
-
* Gets the Next.js
|
|
27
|
+
* Gets the Next.js middleware handler with error handling
|
|
28
28
|
* @returns route handler
|
|
29
29
|
*/
|
|
30
30
|
getHandler(): (req: NextRequest, res?: NextResponse) => Promise<NextResponse>;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { GraphQLClient, PageInfo } from '@sitecore-jss/sitecore-jss/graphql';
|
|
1
|
+
import { GraphQLClient, GraphQLRequestClientFactory, PageInfo } from '@sitecore-jss/sitecore-jss/graphql';
|
|
2
2
|
/** @private */
|
|
3
3
|
export declare const languageError = "The list of languages cannot be empty";
|
|
4
4
|
export declare const siteError = "The service needs a site name";
|
|
@@ -30,7 +30,7 @@ interface SiteRouteQueryVariables {
|
|
|
30
30
|
/** common variable for all GraphQL queries
|
|
31
31
|
* it will be used for every type of query to regulate result batch size
|
|
32
32
|
* Optional. How many result items to fetch in each GraphQL call. This is needed for pagination.
|
|
33
|
-
* @default
|
|
33
|
+
* @default 100
|
|
34
34
|
*/
|
|
35
35
|
pageSize?: number;
|
|
36
36
|
}
|
|
@@ -66,19 +66,16 @@ export type RouteListQueryResult = {
|
|
|
66
66
|
* Configuration options for @see GraphQLSitemapService instances
|
|
67
67
|
*/
|
|
68
68
|
export interface BaseGraphQLSitemapServiceConfig extends Omit<SiteRouteQueryVariables, 'language' | 'siteName'> {
|
|
69
|
-
/**
|
|
70
|
-
* Your Graphql endpoint
|
|
71
|
-
*/
|
|
72
|
-
endpoint: string;
|
|
73
|
-
/**
|
|
74
|
-
* The API key to use for authentication.
|
|
75
|
-
*/
|
|
76
|
-
apiKey: string;
|
|
77
69
|
/**
|
|
78
70
|
* A flag for whether to include personalized routes in service output - only works on XM Cloud
|
|
79
71
|
* turned off by default
|
|
80
72
|
*/
|
|
81
73
|
includePersonalizedRoutes?: boolean;
|
|
74
|
+
/**
|
|
75
|
+
* A GraphQL Request Client Factory is a function that accepts configuration and returns an instance of a GraphQLRequestClient.
|
|
76
|
+
* This factory function is used to create and configure GraphQL clients for making GraphQL API requests.
|
|
77
|
+
*/
|
|
78
|
+
clientFactory: GraphQLRequestClientFactory;
|
|
82
79
|
}
|
|
83
80
|
/**
|
|
84
81
|
* Object model of a site page item.
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { GetServerSidePropsContext, GetStaticPropsContext } from 'next';
|
|
2
2
|
import { LayoutServiceData, ComponentRendering, PlaceholdersData } from '@sitecore-jss/sitecore-jss/layout';
|
|
3
3
|
import { ComponentPropsCollection, ComponentPropsFetchFunction } from '../sharedTypes/component-props';
|
|
4
|
-
import {
|
|
4
|
+
import { ModuleFactory } from '../sharedTypes/module-factory';
|
|
5
5
|
export type FetchComponentPropsArguments<NextContext> = {
|
|
6
6
|
layoutData: LayoutServiceData;
|
|
7
7
|
context: NextContext;
|
|
8
|
-
|
|
8
|
+
moduleFactory: ModuleFactory;
|
|
9
9
|
};
|
|
10
10
|
export type ComponentPropsRequest<NextContext> = {
|
|
11
11
|
fetch: ComponentPropsFetchFunction<NextContext>;
|
|
@@ -1,10 +1,14 @@
|
|
|
1
1
|
import { GetServerSidePropsContext, GetStaticPropsContext } from 'next';
|
|
2
2
|
import { ComponentRendering, LayoutServiceData } from '@sitecore-jss/sitecore-jss/layout';
|
|
3
|
+
export type ComponentPropsError = {
|
|
4
|
+
error: string;
|
|
5
|
+
componentName: string;
|
|
6
|
+
};
|
|
3
7
|
/**
|
|
4
8
|
* Shape of component props storage
|
|
5
9
|
*/
|
|
6
10
|
export type ComponentPropsCollection = {
|
|
7
|
-
[componentUid: string]: unknown;
|
|
11
|
+
[componentUid: string]: unknown | ComponentPropsError;
|
|
8
12
|
};
|
|
9
13
|
/**
|
|
10
14
|
* Type of side effect function which could be invoked on component level (getStaticProps/getServerSideProps)
|