@sitecore-jss/sitecore-jss-nextjs 22.1.0-canary.5 → 22.1.0-canary.51
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/components/Link.js +7 -3
- package/dist/cjs/components/NextImage.js +10 -5
- package/dist/cjs/components/RichText.js +2 -2
- package/dist/cjs/editing/constants.js +12 -3
- package/dist/cjs/editing/editing-config-middleware.js +8 -0
- package/dist/cjs/editing/editing-data-middleware.js +6 -0
- package/dist/cjs/editing/editing-render-middleware.js +207 -103
- package/dist/cjs/editing/feaas-render-middleware.js +8 -0
- package/dist/cjs/editing/index.js +4 -1
- package/dist/cjs/editing/render-middleware.js +18 -4
- package/dist/cjs/index.js +8 -7
- package/dist/cjs/utils/index.js +4 -3
- package/dist/cjs/utils/utils.js +3 -3
- package/dist/esm/components/Link.js +7 -3
- package/dist/esm/components/NextImage.js +11 -5
- package/dist/esm/components/RichText.js +2 -2
- package/dist/esm/editing/constants.js +11 -2
- package/dist/esm/editing/editing-config-middleware.js +9 -1
- package/dist/esm/editing/editing-data-middleware.js +7 -1
- package/dist/esm/editing/editing-render-middleware.js +205 -103
- package/dist/esm/editing/feaas-render-middleware.js +9 -1
- package/dist/esm/editing/index.js +2 -1
- package/dist/esm/editing/render-middleware.js +19 -5
- package/dist/esm/index.js +2 -3
- package/dist/esm/utils/index.js +2 -1
- package/dist/esm/utils/utils.js +1 -1
- package/package.json +7 -8
- package/types/ComponentBuilder.d.ts +3 -5
- package/types/components/Placeholder.d.ts +7 -2
- package/types/components/RichText.d.ts +6 -0
- package/types/editing/constants.d.ts +11 -2
- package/types/editing/editing-config-middleware.d.ts +7 -0
- package/types/editing/editing-data-service.d.ts +1 -0
- package/types/editing/editing-render-middleware.d.ts +111 -23
- package/types/editing/index.d.ts +2 -1
- package/types/editing/render-middleware.d.ts +9 -0
- package/types/index.d.ts +2 -3
- package/types/utils/index.d.ts +2 -1
- package/dist/cjs/components/EditingComponentPlaceholder.js +0 -12
- package/dist/esm/components/EditingComponentPlaceholder.js +0 -5
- package/types/components/EditingComponentPlaceholder.d.ts +0 -4
|
@@ -8,9 +8,10 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
8
8
|
});
|
|
9
9
|
};
|
|
10
10
|
import { debug } from '@sitecore-jss/sitecore-jss';
|
|
11
|
-
import { QUERY_PARAM_EDITING_SECRET } from './constants';
|
|
11
|
+
import { EDITING_ALLOWED_ORIGINS, QUERY_PARAM_EDITING_SECRET } from './constants';
|
|
12
12
|
import { getJssEditingSecret } from '../utils/utils';
|
|
13
13
|
import { RenderMiddlewareBase } from './render-middleware';
|
|
14
|
+
import { enforceCors } from '@sitecore-jss/sitecore-jss/utils';
|
|
14
15
|
/**
|
|
15
16
|
* Middleware / handler for use in the feaas render Next.js API route (e.g. '/api/editing/feaas/render')
|
|
16
17
|
* which is required for Sitecore editing support.
|
|
@@ -25,6 +26,7 @@ export class FEAASRenderMiddleware extends RenderMiddlewareBase {
|
|
|
25
26
|
this.config = config;
|
|
26
27
|
this.defaultPageUrl = '/feaas/render';
|
|
27
28
|
this.handler = (req, res) => __awaiter(this, void 0, void 0, function* () {
|
|
29
|
+
var _b;
|
|
28
30
|
const { method, query, headers } = req;
|
|
29
31
|
const startTimestamp = Date.now();
|
|
30
32
|
debug.editing('feaas render middleware start: %o', {
|
|
@@ -32,6 +34,12 @@ export class FEAASRenderMiddleware extends RenderMiddlewareBase {
|
|
|
32
34
|
query,
|
|
33
35
|
headers,
|
|
34
36
|
});
|
|
37
|
+
if (!enforceCors(req, res, EDITING_ALLOWED_ORIGINS)) {
|
|
38
|
+
debug.editing('invalid origin host - set allowed origins in JSS_ALLOWED_ORIGINS environment variable');
|
|
39
|
+
return res
|
|
40
|
+
.status(401)
|
|
41
|
+
.send(`<html><body>Requests from origin ${(_b = req.headers) === null || _b === void 0 ? void 0 : _b.origin} are not allowed</body></html>`);
|
|
42
|
+
}
|
|
35
43
|
if (method !== 'GET') {
|
|
36
44
|
debug.editing('invalid method - sent %s expected GET', method);
|
|
37
45
|
res.setHeader('Allow', 'GET');
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
+
export { GraphQLEditingService } from '@sitecore-jss/sitecore-jss/editing';
|
|
1
2
|
export { EditingDataDiskCache } from './editing-data-cache';
|
|
2
3
|
export { EditingDataMiddleware } from './editing-data-middleware';
|
|
3
|
-
export { EditingRenderMiddleware, } from './editing-render-middleware';
|
|
4
|
+
export { EditingRenderMiddleware, isEditingMetadataPreviewData, } from './editing-render-middleware';
|
|
4
5
|
export { BasicEditingDataService, ServerlessEditingDataService, editingDataService, } from './editing-data-service';
|
|
5
6
|
export { VercelEditingDataCache } from './vercel-editing-data-cache';
|
|
6
7
|
export { FEAASRenderMiddleware } from './feaas-render-middleware';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { QUERY_PARAM_VERCEL_PROTECTION_BYPASS, QUERY_PARAM_VERCEL_SET_BYPASS_COOKIE, EDITING_PASS_THROUGH_HEADERS, } from './constants';
|
|
2
2
|
/**
|
|
3
3
|
* Base class for middleware that handles pages and components rendering in Sitecore Editors.
|
|
4
4
|
*/
|
|
@@ -11,13 +11,27 @@ export class RenderMiddlewareBase {
|
|
|
11
11
|
*/
|
|
12
12
|
this.getQueryParamsForPropagation = (query) => {
|
|
13
13
|
const params = {};
|
|
14
|
-
if (query[
|
|
15
|
-
params[
|
|
14
|
+
if (query[QUERY_PARAM_VERCEL_PROTECTION_BYPASS]) {
|
|
15
|
+
params[QUERY_PARAM_VERCEL_PROTECTION_BYPASS] = query[QUERY_PARAM_VERCEL_PROTECTION_BYPASS];
|
|
16
16
|
}
|
|
17
|
-
if (query[
|
|
18
|
-
params[
|
|
17
|
+
if (query[QUERY_PARAM_VERCEL_SET_BYPASS_COOKIE]) {
|
|
18
|
+
params[QUERY_PARAM_VERCEL_SET_BYPASS_COOKIE] = query[QUERY_PARAM_VERCEL_SET_BYPASS_COOKIE];
|
|
19
19
|
}
|
|
20
20
|
return params;
|
|
21
21
|
};
|
|
22
|
+
/**
|
|
23
|
+
* Get headers that should be passed along to subsequent requests
|
|
24
|
+
* @param {IncomingHttpHeaders} headers Incoming HTTP Headers
|
|
25
|
+
* @returns Object of approved headers
|
|
26
|
+
*/
|
|
27
|
+
this.getHeadersForPropagation = (headers) => {
|
|
28
|
+
const result = {};
|
|
29
|
+
EDITING_PASS_THROUGH_HEADERS.forEach((header) => {
|
|
30
|
+
if (headers[header]) {
|
|
31
|
+
result[header] = headers[header];
|
|
32
|
+
}
|
|
33
|
+
});
|
|
34
|
+
return result;
|
|
35
|
+
};
|
|
22
36
|
}
|
|
23
37
|
}
|
package/dist/esm/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export { constants, AxiosDataFetcher, NativeDataFetcher, enableDebug, debug, } from '@sitecore-jss/sitecore-jss';
|
|
2
|
-
export { LayoutServicePageState, GraphQLLayoutService, RestLayoutService, getChildPlaceholder, getFieldValue,
|
|
2
|
+
export { LayoutServicePageState, GraphQLLayoutService, RestLayoutService, getChildPlaceholder, getFieldValue, getContentStylesheetLink, EditMode, } from '@sitecore-jss/sitecore-jss/layout';
|
|
3
3
|
export { mediaApi } from '@sitecore-jss/sitecore-jss/media';
|
|
4
4
|
export { trackingApi, } from '@sitecore-jss/sitecore-jss/tracking';
|
|
5
5
|
export { GraphQLDictionaryService, RestDictionaryService, } from '@sitecore-jss/sitecore-jss/i18n';
|
|
@@ -13,7 +13,6 @@ export { ComponentPropsReactContext, ComponentPropsContext, useComponentProps, }
|
|
|
13
13
|
export { Link } from './components/Link';
|
|
14
14
|
export { RichText } from './components/RichText';
|
|
15
15
|
export { Placeholder } from './components/Placeholder';
|
|
16
|
-
export { EditingComponentPlaceholder } from './components/EditingComponentPlaceholder';
|
|
17
16
|
export { NextImage } from './components/NextImage';
|
|
18
17
|
import * as FEaaSWrapper from './components/FEaaSWrapper';
|
|
19
18
|
import * as BYOCWrapper from './components/BYOCWrapper';
|
|
@@ -21,4 +20,4 @@ export { FEaaSWrapper };
|
|
|
21
20
|
export { BYOCWrapper };
|
|
22
21
|
export { ComponentBuilder } from './ComponentBuilder';
|
|
23
22
|
export { Context } from './context';
|
|
24
|
-
export { Image, Text, DateField, EditFrame, FEaaSComponent, fetchFEaaSComponentServerProps, BYOCComponent, getComponentLibraryStylesheetLinks, File, VisitorIdentification, SitecoreContext, SitecoreContextReactContext, withSitecoreContext, useSitecoreContext, withEditorChromes, withPlaceholder, withDatasourceCheck, } from '@sitecore-jss/sitecore-jss-react';
|
|
23
|
+
export { Image, Text, DateField, EditFrame, FEaaSComponent, fetchFEaaSComponentServerProps, BYOCComponent, getComponentLibraryStylesheetLinks, File, DefaultEmptyFieldEditingComponentImage, DefaultEmptyFieldEditingComponentText, VisitorIdentification, SitecoreContext, SitecoreContextReactContext, withSitecoreContext, useSitecoreContext, withEditorChromes, withPlaceholder, withDatasourceCheck, withFieldMetadata, withEmptyFieldEditingComponent, EditingScripts, } from '@sitecore-jss/sitecore-jss-react';
|
package/dist/esm/utils/index.js
CHANGED
|
@@ -1,2 +1,3 @@
|
|
|
1
1
|
export { getPublicUrl, handleEditorFastRefresh } from './utils';
|
|
2
|
-
export { tryParseEnvValue,
|
|
2
|
+
export { tryParseEnvValue, resolveUrl } from '@sitecore-jss/sitecore-jss/utils';
|
|
3
|
+
export { isEditorActive, resetEditorChromes } from '@sitecore-jss/sitecore-jss/editing';
|
package/dist/esm/utils/utils.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { isEditorActive, resetEditorChromes } from '@sitecore-jss/sitecore-jss/
|
|
1
|
+
import { isEditorActive, resetEditorChromes } from '@sitecore-jss/sitecore-jss/editing';
|
|
2
2
|
/**
|
|
3
3
|
* Get the publicUrl.
|
|
4
4
|
* This is used primarily to enable compatibility with Sitecore editors.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sitecore-jss/sitecore-jss-nextjs",
|
|
3
|
-
"version": "22.1.0-canary.
|
|
3
|
+
"version": "22.1.0-canary.51",
|
|
4
4
|
"main": "dist/cjs/index.js",
|
|
5
5
|
"module": "dist/esm/index.js",
|
|
6
6
|
"sideEffects": false,
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
"generate-docs": "npx typedoc --plugin typedoc-plugin-markdown --readme none --out ../../ref-docs/sitecore-jss-nextjs --entryPoints src/index.ts --entryPoints src/monitoring/index.ts --entryPoints src/editing/index.ts --entryPoints src/middleware/index.ts --entryPoints src/context/index.ts --entryPoints src/utils/index.ts --entryPoints src/site/index.ts --entryPoints src/graphql/index.ts --githubPages false"
|
|
15
15
|
},
|
|
16
16
|
"engines": {
|
|
17
|
-
"node": ">=
|
|
17
|
+
"node": ">=20"
|
|
18
18
|
},
|
|
19
19
|
"author": {
|
|
20
20
|
"name": "Sitecore Corporation",
|
|
@@ -35,7 +35,7 @@
|
|
|
35
35
|
"@types/chai-string": "^1.4.2",
|
|
36
36
|
"@types/enzyme": "^3.10.12",
|
|
37
37
|
"@types/mocha": "^10.0.1",
|
|
38
|
-
"@types/node": "~
|
|
38
|
+
"@types/node": "~20.14.2",
|
|
39
39
|
"@types/prop-types": "^15.7.5",
|
|
40
40
|
"@types/react": "^18.2.22",
|
|
41
41
|
"@types/react-dom": "^18.0.10",
|
|
@@ -72,18 +72,17 @@
|
|
|
72
72
|
"react-dom": "^18.2.0"
|
|
73
73
|
},
|
|
74
74
|
"dependencies": {
|
|
75
|
-
"@sitecore-jss/sitecore-jss": "^22.1.0-canary.
|
|
76
|
-
"@sitecore-jss/sitecore-jss-dev-tools": "^22.1.0-canary.
|
|
77
|
-
"@sitecore-jss/sitecore-jss-react": "^22.1.0-canary.
|
|
75
|
+
"@sitecore-jss/sitecore-jss": "^22.1.0-canary.51",
|
|
76
|
+
"@sitecore-jss/sitecore-jss-dev-tools": "^22.1.0-canary.51",
|
|
77
|
+
"@sitecore-jss/sitecore-jss-react": "^22.1.0-canary.51",
|
|
78
78
|
"@vercel/kv": "^0.2.1",
|
|
79
|
-
"node-html-parser": "^6.1.4",
|
|
80
79
|
"prop-types": "^15.8.1",
|
|
81
80
|
"regex-parser": "^2.2.11",
|
|
82
81
|
"sync-disk-cache": "^2.1.0"
|
|
83
82
|
},
|
|
84
83
|
"description": "",
|
|
85
84
|
"types": "types/index.d.ts",
|
|
86
|
-
"gitHead": "
|
|
85
|
+
"gitHead": "be8b346940440043e2826363699d5a496e2c2c00",
|
|
87
86
|
"files": [
|
|
88
87
|
"dist",
|
|
89
88
|
"types",
|
|
@@ -1,18 +1,16 @@
|
|
|
1
|
-
|
|
2
|
-
import { ComponentFactory } from '@sitecore-jss/sitecore-jss-react';
|
|
1
|
+
import { ComponentFactory, JssComponentType } from '@sitecore-jss/sitecore-jss-react';
|
|
3
2
|
import { Module, ModuleFactory } from './sharedTypes/module-factory';
|
|
4
|
-
import { ComponentType } from 'react';
|
|
5
3
|
/**
|
|
6
4
|
* Represents a component that can be imported dynamically
|
|
7
5
|
*/
|
|
8
6
|
export type LazyModule = {
|
|
9
7
|
module: () => Promise<Module>;
|
|
10
|
-
element: (isEditing?: boolean) =>
|
|
8
|
+
element: (isEditing?: boolean) => JssComponentType;
|
|
11
9
|
};
|
|
12
10
|
/**
|
|
13
11
|
* Component is a module or a lazy module
|
|
14
12
|
*/
|
|
15
|
-
type Component = Module | LazyModule |
|
|
13
|
+
type Component = Module | LazyModule | JssComponentType;
|
|
16
14
|
/**
|
|
17
15
|
* Configuration for ComponentBuilder
|
|
18
16
|
*/
|
|
@@ -1,4 +1,9 @@
|
|
|
1
1
|
/// <reference types="@types/react" />
|
|
2
2
|
import React from 'react';
|
|
3
|
-
import { PlaceholderComponentProps } from '@sitecore-jss/sitecore-jss-react';
|
|
4
|
-
|
|
3
|
+
import { PlaceholderComponentProps, WithSitecoreContextProps, EnhancedOmit } from '@sitecore-jss/sitecore-jss-react';
|
|
4
|
+
/**
|
|
5
|
+
* React Placeholder component wrapped by withSitecoreContext, so these properties shouldn't be passed to the Next.js Placeholder.
|
|
6
|
+
*/
|
|
7
|
+
type PlaceholderProps = EnhancedOmit<PlaceholderComponentProps, keyof WithSitecoreContextProps>;
|
|
8
|
+
export declare const Placeholder: (props: PlaceholderProps) => React.JSX.Element;
|
|
9
|
+
export {};
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
/// <reference types="@types/react" />
|
|
2
|
+
import React from 'react';
|
|
1
3
|
import PropTypes from 'prop-types';
|
|
2
4
|
import { RichTextProps as ReactRichTextProps } from '@sitecore-jss/sitecore-jss-react';
|
|
3
5
|
export type RichTextProps = ReactRichTextProps & {
|
|
@@ -19,9 +21,13 @@ export declare const RichText: {
|
|
|
19
21
|
field: PropTypes.Requireable<PropTypes.InferProps<{
|
|
20
22
|
value: PropTypes.Requireable<string>;
|
|
21
23
|
editable: PropTypes.Requireable<string>;
|
|
24
|
+
metadata: PropTypes.Requireable<{
|
|
25
|
+
[x: string]: any;
|
|
26
|
+
}>;
|
|
22
27
|
}>>;
|
|
23
28
|
tag: PropTypes.Requireable<string>;
|
|
24
29
|
editable: PropTypes.Requireable<boolean>;
|
|
30
|
+
emptyFieldEditingComponent: PropTypes.Requireable<NonNullable<React.ComponentClass<unknown, any> | React.FC<unknown>>>;
|
|
25
31
|
internalLinksSelector: PropTypes.Requireable<string>;
|
|
26
32
|
};
|
|
27
33
|
displayName: string;
|
|
@@ -1,3 +1,12 @@
|
|
|
1
1
|
export declare const QUERY_PARAM_EDITING_SECRET = "secret";
|
|
2
|
-
export declare const
|
|
3
|
-
export declare const
|
|
2
|
+
export declare const QUERY_PARAM_VERCEL_PROTECTION_BYPASS = "x-vercel-protection-bypass";
|
|
3
|
+
export declare const QUERY_PARAM_VERCEL_SET_BYPASS_COOKIE = "x-vercel-set-bypass-cookie";
|
|
4
|
+
/**
|
|
5
|
+
* Headers that should be passed along to (Editing Chromes handler) SSR request.
|
|
6
|
+
* Note these are in lowercase format to match expected `IncomingHttpHeaders`.
|
|
7
|
+
*/
|
|
8
|
+
export declare const EDITING_PASS_THROUGH_HEADERS: string[];
|
|
9
|
+
/**
|
|
10
|
+
* Default allowed origins for editing requests. This is used to enforce CORS, CSP headers.
|
|
11
|
+
*/
|
|
12
|
+
export declare const EDITING_ALLOWED_ORIGINS: string[];
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { NextApiRequest, NextApiResponse } from 'next';
|
|
2
|
+
import { EditMode } from '@sitecore-jss/sitecore-jss/layout';
|
|
2
3
|
import { Metadata } from '@sitecore-jss/sitecore-jss-dev-tools';
|
|
3
4
|
export type EditingConfigMiddlewareConfig = {
|
|
4
5
|
/**
|
|
@@ -9,6 +10,12 @@ export type EditingConfigMiddlewareConfig = {
|
|
|
9
10
|
* Application metadata
|
|
10
11
|
*/
|
|
11
12
|
metadata: Metadata;
|
|
13
|
+
/**
|
|
14
|
+
* Determines which editing mode should be used by Pages.
|
|
15
|
+
* Can be either 'chromes' or 'metadata'.
|
|
16
|
+
* By default its 'metadata'
|
|
17
|
+
*/
|
|
18
|
+
pagesEditMode?: EditMode;
|
|
12
19
|
};
|
|
13
20
|
/**
|
|
14
21
|
* Middleware / handler used in the editing config API route in xmcloud add on (e.g. '/api/editing/config')
|
|
@@ -1,16 +1,23 @@
|
|
|
1
1
|
import { NextApiRequest, NextApiResponse } from 'next';
|
|
2
2
|
import { AxiosDataFetcher } from '@sitecore-jss/sitecore-jss';
|
|
3
|
-
import {
|
|
3
|
+
import { EditMode, LayoutServicePageState } from '@sitecore-jss/sitecore-jss/layout';
|
|
4
4
|
import { EditingDataService } from './editing-data-service';
|
|
5
5
|
import { RenderMiddlewareBase } from './render-middleware';
|
|
6
|
-
|
|
6
|
+
/**
|
|
7
|
+
* Configuration for the Editing Render Middleware.
|
|
8
|
+
*/
|
|
9
|
+
export type EditingRenderMiddlewareConfig = {
|
|
7
10
|
/**
|
|
11
|
+
* -- Edit Mode Chromes --
|
|
12
|
+
*
|
|
8
13
|
* The `AxiosDataFetcher` instance to use for API requests.
|
|
9
14
|
* @default new AxiosDataFetcher()
|
|
10
15
|
* @see AxiosDataFetcher
|
|
11
16
|
*/
|
|
12
17
|
dataFetcher?: AxiosDataFetcher;
|
|
13
18
|
/**
|
|
19
|
+
* -- Edit Mode Chromes --
|
|
20
|
+
*
|
|
14
21
|
* The `EditingDataService` instance to use.
|
|
15
22
|
* This would typically only be necessary if you've got a custom `EditingDataService` instance (e.g. using a custom API route).
|
|
16
23
|
* By default, this is `editingDataService` (the `EditingDataService` default instance).
|
|
@@ -20,16 +27,25 @@ export interface EditingRenderMiddlewareConfig {
|
|
|
20
27
|
*/
|
|
21
28
|
editingDataService?: EditingDataService;
|
|
22
29
|
/**
|
|
30
|
+
* -- Edit Mode Chromes / Metadata --
|
|
31
|
+
*
|
|
23
32
|
* Function used to determine route/page URL to render.
|
|
24
33
|
* This may be necessary for certain custom Next.js routing configurations.
|
|
25
|
-
* @param {
|
|
34
|
+
* @param {Object} args Arguments for resolving the page URL
|
|
35
|
+
* @param {string} args.serverUrl The root server URL e.g. 'http://localhost:3000'. Available in Chromes Edit Mode only.
|
|
26
36
|
* @param {string} itemPath The Sitecore relative item path e.g. '/styleguide'
|
|
27
37
|
* @returns {string} The URL to render
|
|
28
|
-
* @default `${serverUrl}${itemPath}`
|
|
38
|
+
* @default `${serverUrl}${itemPath}` In Edit Mode Chromes
|
|
39
|
+
* @default `${itemPath}` In XMCloud Pages for Edit Mode Metadata
|
|
29
40
|
* @see resolveServerUrl
|
|
30
41
|
*/
|
|
31
|
-
resolvePageUrl?: (
|
|
42
|
+
resolvePageUrl?: (args: {
|
|
43
|
+
serverUrl?: string;
|
|
44
|
+
itemPath: string;
|
|
45
|
+
}) => string;
|
|
32
46
|
/**
|
|
47
|
+
* -- Edit Mode Chromes --
|
|
48
|
+
*
|
|
33
49
|
* Function used to determine the root server URL. This is used for the route/page and subsequent data API requests.
|
|
34
50
|
* By default, the host header is used, with https protocol on Vercel (due to serverless function architecture) and http protocol elsewhere.
|
|
35
51
|
* @param {NextApiRequest} req The current request.
|
|
@@ -37,30 +53,29 @@ export interface EditingRenderMiddlewareConfig {
|
|
|
37
53
|
* @see resolvePageUrl
|
|
38
54
|
*/
|
|
39
55
|
resolveServerUrl?: (req: NextApiRequest) => string;
|
|
40
|
-
}
|
|
56
|
+
};
|
|
41
57
|
/**
|
|
42
|
-
*
|
|
43
|
-
* which is required for Sitecore editing support.
|
|
58
|
+
* Configuration for the Editing Chromes Handler.
|
|
44
59
|
*/
|
|
45
|
-
export
|
|
60
|
+
export type EditingRenderMiddlewareChromesConfig = EditingRenderMiddlewareConfig;
|
|
61
|
+
/**
|
|
62
|
+
* Handler for the Editing Chromes POST requests.
|
|
63
|
+
* This handler is responsible for rendering the page and returning the HTML content that is provided via request.
|
|
64
|
+
*/
|
|
65
|
+
export declare class ChromesHandler extends RenderMiddlewareBase {
|
|
66
|
+
config?: EditingRenderMiddlewareConfig | undefined;
|
|
46
67
|
private editingDataService;
|
|
47
68
|
private dataFetcher;
|
|
48
69
|
private resolvePageUrl;
|
|
49
70
|
private resolveServerUrl;
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
*/
|
|
53
|
-
constructor(config?: EditingRenderMiddlewareConfig);
|
|
54
|
-
/**
|
|
55
|
-
* Gets the Next.js API route handler
|
|
56
|
-
* @returns route handler
|
|
57
|
-
*/
|
|
58
|
-
getHandler(): (req: NextApiRequest, res: NextApiResponse) => Promise<void>;
|
|
59
|
-
private handler;
|
|
71
|
+
constructor(config?: EditingRenderMiddlewareConfig | undefined);
|
|
72
|
+
render(req: NextApiRequest, res: NextApiResponse): Promise<void>;
|
|
60
73
|
/**
|
|
61
74
|
* Default page URL resolution.
|
|
62
|
-
* @param {
|
|
63
|
-
* @param {string}
|
|
75
|
+
* @param {Object} args Arguments for resolving the page URL
|
|
76
|
+
* @param {string} args.serverUrl The root server URL e.g. 'http://localhost:3000'
|
|
77
|
+
* @param {string} args.itemPath The Sitecore relative item path e.g. '/styleguide'
|
|
78
|
+
* @returns {string} The URL to render
|
|
64
79
|
*/
|
|
65
80
|
private defaultResolvePageUrl;
|
|
66
81
|
/**
|
|
@@ -74,8 +89,81 @@ export declare class EditingRenderMiddleware extends RenderMiddlewareBase {
|
|
|
74
89
|
* @param {NextApiRequest} req
|
|
75
90
|
*/
|
|
76
91
|
private defaultResolveServerUrl;
|
|
92
|
+
private extractEditingData;
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* Configuration for the Editing Metadata Handler.
|
|
96
|
+
*/
|
|
97
|
+
export type EditingRenderMiddlewareMetadataConfig = Pick<EditingRenderMiddlewareConfig, 'resolvePageUrl'>;
|
|
98
|
+
/**
|
|
99
|
+
* Query parameters appended to the page route URL
|
|
100
|
+
* Appended when XMCloud Pages preview (editing) Metadata Edit Mode is used
|
|
101
|
+
*/
|
|
102
|
+
export type MetadataQueryParams = {
|
|
103
|
+
secret: string;
|
|
104
|
+
sc_lang: string;
|
|
105
|
+
sc_itemid: string;
|
|
106
|
+
sc_site: string;
|
|
107
|
+
route: string;
|
|
108
|
+
mode: Exclude<LayoutServicePageState, 'normal'>;
|
|
109
|
+
sc_variant?: string;
|
|
110
|
+
sc_version?: string;
|
|
111
|
+
};
|
|
112
|
+
/**
|
|
113
|
+
* Next.js API request with Metadata query parameters.
|
|
114
|
+
*/
|
|
115
|
+
type MetadataNextApiRequest = NextApiRequest & {
|
|
116
|
+
query: MetadataQueryParams;
|
|
117
|
+
};
|
|
118
|
+
/**
|
|
119
|
+
* Data for Next.js Preview (Editing) Metadata Edit Mode.
|
|
120
|
+
*/
|
|
121
|
+
export type EditingMetadataPreviewData = {
|
|
122
|
+
site: string;
|
|
123
|
+
itemId: string;
|
|
124
|
+
language: string;
|
|
125
|
+
editMode: EditMode.Metadata;
|
|
126
|
+
pageState: Exclude<LayoutServicePageState, 'Normal'>;
|
|
127
|
+
variantId: string;
|
|
128
|
+
version?: string;
|
|
129
|
+
};
|
|
130
|
+
/**
|
|
131
|
+
* Type guard for EditingMetadataPreviewData
|
|
132
|
+
* @param {Object} data preview data to check
|
|
133
|
+
* @returns true if the data is EditingMetadataPreviewData
|
|
134
|
+
* @see EditingMetadataPreviewData
|
|
135
|
+
*/
|
|
136
|
+
export declare const isEditingMetadataPreviewData: (data: unknown) => data is EditingMetadataPreviewData;
|
|
137
|
+
/**
|
|
138
|
+
* Handler for the Editing Metadata GET requests.
|
|
139
|
+
* This handler is responsible for redirecting the request to the page route.
|
|
140
|
+
* The page fetches the layout, dictionary and renders the page.
|
|
141
|
+
*/
|
|
142
|
+
export declare class MetadataHandler {
|
|
143
|
+
config: EditingRenderMiddlewareMetadataConfig;
|
|
144
|
+
constructor(config: EditingRenderMiddlewareMetadataConfig);
|
|
145
|
+
render(req: MetadataNextApiRequest, res: NextApiResponse): void;
|
|
146
|
+
/**
|
|
147
|
+
* Gets the Content-Security-Policy header value
|
|
148
|
+
* @returns Content-Security-Policy header value
|
|
149
|
+
*/
|
|
150
|
+
getSCPHeader(): string;
|
|
77
151
|
}
|
|
78
152
|
/**
|
|
79
|
-
*
|
|
153
|
+
* Middleware / handler for use in the editing render Next.js API route (e.g. '/api/editing/render')
|
|
154
|
+
* which is required for Sitecore editing support.
|
|
80
155
|
*/
|
|
81
|
-
export declare
|
|
156
|
+
export declare class EditingRenderMiddleware extends RenderMiddlewareBase {
|
|
157
|
+
config?: EditingRenderMiddlewareConfig | undefined;
|
|
158
|
+
/**
|
|
159
|
+
* @param {EditingRenderMiddlewareConfig} [config] Editing render middleware config
|
|
160
|
+
*/
|
|
161
|
+
constructor(config?: EditingRenderMiddlewareConfig | undefined);
|
|
162
|
+
/**
|
|
163
|
+
* Gets the Next.js API route handler
|
|
164
|
+
* @returns route handler
|
|
165
|
+
*/
|
|
166
|
+
getHandler(): (req: NextApiRequest, res: NextApiResponse) => Promise<void>;
|
|
167
|
+
private handler;
|
|
168
|
+
}
|
|
169
|
+
export {};
|
package/types/editing/index.d.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
|
+
export { GraphQLEditingService } from '@sitecore-jss/sitecore-jss/editing';
|
|
1
2
|
export { EditingData } from './editing-data';
|
|
2
3
|
export { EditingDataCache, EditingDataDiskCache } from './editing-data-cache';
|
|
3
4
|
export { EditingDataMiddleware, EditingDataMiddlewareConfig } from './editing-data-middleware';
|
|
4
|
-
export { EditingRenderMiddleware, EditingRenderMiddlewareConfig, } from './editing-render-middleware';
|
|
5
|
+
export { EditingRenderMiddleware, EditingRenderMiddlewareConfig, EditingMetadataPreviewData, isEditingMetadataPreviewData, } from './editing-render-middleware';
|
|
5
6
|
export { EditingPreviewData, EditingDataService, BasicEditingDataService, BasicEditingDataServiceConfig, ServerlessEditingDataService, ServerlessEditingDataServiceConfig, editingDataService, } from './editing-data-service';
|
|
6
7
|
export { VercelEditingDataCache } from './vercel-editing-data-cache';
|
|
7
8
|
export { FEAASRenderMiddleware, FEAASRenderMiddlewareConfig } from './feaas-render-middleware';
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { IncomingHttpHeaders } from 'http';
|
|
1
2
|
/**
|
|
2
3
|
* Base class for middleware that handles pages and components rendering in Sitecore Editors.
|
|
3
4
|
*/
|
|
@@ -12,4 +13,12 @@ export declare abstract class RenderMiddlewareBase {
|
|
|
12
13
|
}>) => {
|
|
13
14
|
[key: string]: string;
|
|
14
15
|
};
|
|
16
|
+
/**
|
|
17
|
+
* Get headers that should be passed along to subsequent requests
|
|
18
|
+
* @param {IncomingHttpHeaders} headers Incoming HTTP Headers
|
|
19
|
+
* @returns Object of approved headers
|
|
20
|
+
*/
|
|
21
|
+
protected getHeadersForPropagation: (headers: IncomingHttpHeaders) => {
|
|
22
|
+
[key: string]: string | string[];
|
|
23
|
+
};
|
|
15
24
|
}
|
package/types/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
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,
|
|
2
|
+
export { LayoutService, LayoutServiceData, LayoutServicePageState, LayoutServiceContext, LayoutServiceContextData, GraphQLLayoutService, GraphQLLayoutServiceConfig, RestLayoutService, RestLayoutServiceConfig, PlaceholderData, PlaceholdersData, RouteData, Field, Item, HtmlElementRendering, getChildPlaceholder, getFieldValue, ComponentRendering, ComponentFields, ComponentParams, getContentStylesheetLink, EditMode, } from '@sitecore-jss/sitecore-jss/layout';
|
|
3
3
|
export { mediaApi } from '@sitecore-jss/sitecore-jss/media';
|
|
4
4
|
export { trackingApi, TrackingRequestOptions, CampaignInstance, GoalInstance, OutcomeInstance, EventInstance, PageViewInstance, } from '@sitecore-jss/sitecore-jss/tracking';
|
|
5
5
|
export { DictionaryPhrases, DictionaryService, GraphQLDictionaryService, GraphQLDictionaryServiceConfig, RestDictionaryService, RestDictionaryServiceConfig, } from '@sitecore-jss/sitecore-jss/i18n';
|
|
@@ -16,7 +16,6 @@ export { ComponentPropsReactContext, ComponentPropsContextProps, ComponentPropsC
|
|
|
16
16
|
export { Link, LinkProps } from './components/Link';
|
|
17
17
|
export { RichText, RichTextProps } from './components/RichText';
|
|
18
18
|
export { Placeholder } from './components/Placeholder';
|
|
19
|
-
export { EditingComponentPlaceholder } from './components/EditingComponentPlaceholder';
|
|
20
19
|
export { NextImage } from './components/NextImage';
|
|
21
20
|
import * as FEaaSWrapper from './components/FEaaSWrapper';
|
|
22
21
|
import * as BYOCWrapper from './components/BYOCWrapper';
|
|
@@ -24,4 +23,4 @@ export { FEaaSWrapper };
|
|
|
24
23
|
export { BYOCWrapper };
|
|
25
24
|
export { ComponentBuilder, ComponentBuilderConfig } from './ComponentBuilder';
|
|
26
25
|
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,
|
|
26
|
+
export { ComponentFactory, Image, ImageField, ImageFieldValue, ImageProps, LinkField, LinkFieldValue, Text, TextField, DateField, EditFrame, FEaaSComponent, FEaaSComponentProps, FEaaSComponentParams, fetchFEaaSComponentServerProps, BYOCComponentParams, BYOCComponent, BYOCComponentProps, getComponentLibraryStylesheetLinks, File, FileField, RichTextField, DefaultEmptyFieldEditingComponentImage, DefaultEmptyFieldEditingComponentText, VisitorIdentification, PlaceholderComponentProps, SitecoreContext, SitecoreContextState, SitecoreContextValue, SitecoreContextReactContext, withSitecoreContext, useSitecoreContext, withEditorChromes, withPlaceholder, withDatasourceCheck, ImageSizeParameters, WithSitecoreContextOptions, WithSitecoreContextProps, WithSitecoreContextHocProps, withFieldMetadata, withEmptyFieldEditingComponent, EditingScripts, } from '@sitecore-jss/sitecore-jss-react';
|
package/types/utils/index.d.ts
CHANGED
|
@@ -1,2 +1,3 @@
|
|
|
1
1
|
export { getPublicUrl, handleEditorFastRefresh } from './utils';
|
|
2
|
-
export { tryParseEnvValue,
|
|
2
|
+
export { tryParseEnvValue, resolveUrl } from '@sitecore-jss/sitecore-jss/utils';
|
|
3
|
+
export { isEditorActive, resetEditorChromes } from '@sitecore-jss/sitecore-jss/editing';
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.EditingComponentPlaceholder = void 0;
|
|
7
|
-
const react_1 = __importDefault(require("react"));
|
|
8
|
-
const layout_1 = require("@sitecore-jss/sitecore-jss/layout");
|
|
9
|
-
const Placeholder_1 = require("./Placeholder");
|
|
10
|
-
const EditingComponentPlaceholder = ({ rendering, }) => (react_1.default.createElement("div", { id: layout_1.EDITING_COMPONENT_ID },
|
|
11
|
-
react_1.default.createElement(Placeholder_1.Placeholder, { name: layout_1.EDITING_COMPONENT_PLACEHOLDER, rendering: rendering })));
|
|
12
|
-
exports.EditingComponentPlaceholder = EditingComponentPlaceholder;
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { EDITING_COMPONENT_ID, EDITING_COMPONENT_PLACEHOLDER, } from '@sitecore-jss/sitecore-jss/layout';
|
|
3
|
-
import { Placeholder } from './Placeholder';
|
|
4
|
-
export const EditingComponentPlaceholder = ({ rendering, }) => (React.createElement("div", { id: EDITING_COMPONENT_ID },
|
|
5
|
-
React.createElement(Placeholder, { name: EDITING_COMPONENT_PLACEHOLDER, rendering: rendering })));
|