@sitecore-content-sdk/nextjs 2.0.0-canary.1 → 2.0.0-canary.10

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 (42) hide show
  1. package/dist/cjs/editing/editing-render-middleware.js +15 -7
  2. package/dist/cjs/editing/types.js +2 -0
  3. package/dist/cjs/editing/utils.js +30 -1
  4. package/dist/cjs/index.js +2 -1
  5. package/dist/cjs/route-handler/editing-render-route-handler.js +12 -5
  6. package/dist/cjs/tools/codegen/import-map.js +2 -2
  7. package/dist/cjs/tools/index.js +6 -6
  8. package/dist/cjs/tools/templating/utils.js +5 -6
  9. package/dist/esm/editing/editing-render-middleware.js +16 -8
  10. package/dist/esm/editing/types.js +1 -0
  11. package/dist/esm/editing/utils.js +28 -0
  12. package/dist/esm/index.js +1 -1
  13. package/dist/esm/route-handler/editing-render-route-handler.js +13 -6
  14. package/dist/esm/tools/codegen/import-map.js +1 -1
  15. package/dist/esm/tools/index.js +2 -2
  16. package/dist/esm/tools/templating/utils.js +1 -2
  17. package/package.json +5 -5
  18. package/types/components/Placeholder.d.ts +2 -2
  19. package/types/components/Placeholder.d.ts.map +1 -1
  20. package/types/config/define-config.d.ts.map +1 -1
  21. package/types/editing/editing-config-middleware.d.ts +1 -1
  22. package/types/editing/editing-config-middleware.d.ts.map +1 -1
  23. package/types/editing/editing-render-middleware.d.ts +7 -0
  24. package/types/editing/editing-render-middleware.d.ts.map +1 -1
  25. package/types/editing/index.d.ts +1 -0
  26. package/types/editing/index.d.ts.map +1 -1
  27. package/types/editing/types.d.ts +37 -0
  28. package/types/editing/types.d.ts.map +1 -0
  29. package/types/editing/utils.d.ts +11 -0
  30. package/types/editing/utils.d.ts.map +1 -1
  31. package/types/index.d.ts +1 -1
  32. package/types/index.d.ts.map +1 -1
  33. package/types/route-handler/editing-config-route-handler.d.ts +1 -1
  34. package/types/route-handler/editing-config-route-handler.d.ts.map +1 -1
  35. package/types/route-handler/editing-render-route-handler.d.ts +7 -0
  36. package/types/route-handler/editing-render-route-handler.d.ts.map +1 -1
  37. package/types/tools/codegen/import-map.d.ts +1 -1
  38. package/types/tools/codegen/import-map.d.ts.map +1 -1
  39. package/types/tools/index.d.ts +3 -2
  40. package/types/tools/index.d.ts.map +1 -1
  41. package/types/tools/templating/utils.d.ts +1 -1
  42. package/types/tools/templating/utils.d.ts.map +1 -1
@@ -34,7 +34,7 @@ class EditingRenderMiddleware extends render_middleware_1.RenderMiddlewareBase {
34
34
  super();
35
35
  this.config = config;
36
36
  this.handler = (req, res) => __awaiter(this, void 0, void 0, function* () {
37
- var _a, _b, _c, _d, _e;
37
+ var _a, _b, _c, _d, _e, _f;
38
38
  const { body, method, headers, query } = req;
39
39
  debug_1.default.editing('editing render middleware start: %o', {
40
40
  method,
@@ -81,15 +81,22 @@ class EditingRenderMiddleware extends render_middleware_1.RenderMiddlewareBase {
81
81
  const mode = query.mode;
82
82
  const requiredQueryParams = (0, utils_2.getRequiredEditingParamsList)(mode);
83
83
  const missingQueryParams = requiredQueryParams.filter((param) => !query[param]);
84
+ const { allowedQueryParams, missingAllowedParams } = (0, utils_2.getAllowedQueryParams)(query, (_b = this.config) === null || _b === void 0 ? void 0 : _b.allowedQueryParams);
84
85
  // Validate query parameters
85
- if (missingQueryParams.length) {
86
- debug_1.default.editing('missing required query parameters: %o', missingQueryParams);
86
+ if (missingQueryParams.length || missingAllowedParams.length) {
87
+ debug_1.default.editing('missing required query parameters: %o', [
88
+ ...missingQueryParams,
89
+ ...missingAllowedParams,
90
+ ]);
87
91
  return res.status(400).json({
88
- html: `<html><body>Missing required query parameters: ${missingQueryParams.join(', ')}</body></html>`,
92
+ html: `<html><body>Missing required query parameters: ${[
93
+ ...missingQueryParams,
94
+ ...missingAllowedParams,
95
+ ].join(', ')}</body></html>`,
89
96
  });
90
97
  }
91
98
  const previewDataParams = (0, utils_2.mapEditingParams)(query);
92
- res.setPreviewData(Object.assign(Object.assign({}, previewDataParams), { variantIds: (_b = previewDataParams.variantIds) === null || _b === void 0 ? void 0 : _b.split(',') }), {
99
+ res.setPreviewData(Object.assign(Object.assign(Object.assign({}, previewDataParams), allowedQueryParams), { variantIds: (_c = previewDataParams.variantIds) === null || _c === void 0 ? void 0 : _c.split(',') }), {
93
100
  maxAge: 3,
94
101
  });
95
102
  // Set Preview mode identifier cookie, if the page is rendered in Sitecore Preview mode
@@ -101,8 +108,8 @@ class EditingRenderMiddleware extends render_middleware_1.RenderMiddlewareBase {
101
108
  // Restrict the page to be rendered only within the allowed origins
102
109
  res.setHeader('Content-Security-Policy', (0, utils_2.getCSPHeader)());
103
110
  const encodedRoute = encodeURI(query.route);
104
- const route = ((_d = (_c = this.config) === null || _c === void 0 ? void 0 : _c.resolvePageUrl) === null || _d === void 0 ? void 0 : _d.call(_c, encodedRoute)) || encodedRoute;
105
- const base = ((_e = this.config) === null || _e === void 0 ? void 0 : _e.sitecoreInternalEditingHostUrl) || (0, utils_2.resolveServerUrl)(req);
111
+ const route = ((_e = (_d = this.config) === null || _d === void 0 ? void 0 : _d.resolvePageUrl) === null || _e === void 0 ? void 0 : _e.call(_d, encodedRoute)) || encodedRoute;
112
+ const base = ((_f = this.config) === null || _f === void 0 ? void 0 : _f.sitecoreInternalEditingHostUrl) || (0, utils_2.resolveServerUrl)(req);
106
113
  const requestUrl = new URL(route, base);
107
114
  const cookies = res.getHeader('Set-Cookie');
108
115
  // Make actual render request for page route, passing on preview cookies as well as any approved query string parameters.
@@ -123,6 +130,7 @@ class EditingRenderMiddleware extends render_middleware_1.RenderMiddlewareBase {
123
130
  status: 200,
124
131
  route,
125
132
  });
133
+ res.setHeader('Content-Type', 'text/html; charset=utf-8');
126
134
  res.status(200).send(html);
127
135
  }
128
136
  catch (err) {
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -9,7 +9,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
9
9
  });
10
10
  };
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.getCSPHeader = exports.resolveServerUrl = exports.isDesignLibraryPreviewData = exports.getEditingRequestHtml = exports.getHeadersForPropagation = exports.getQueryParamsForPropagation = exports.getRequiredEditingParamsList = exports.getPreviewCookies = exports.cleanupNextPreviewCookies = exports.mapEditingParams = exports.getEditingSecretFromRequest = void 0;
12
+ exports.getCSPHeader = exports.resolveServerUrl = exports.isDesignLibraryPreviewData = exports.getEditingRequestHtml = exports.getHeadersForPropagation = exports.getQueryParamsForPropagation = exports.getRequiredEditingParamsList = exports.getPreviewCookies = exports.cleanupNextPreviewCookies = exports.getAllowedQueryParams = exports.mapEditingParams = exports.getEditingSecretFromRequest = void 0;
13
13
  const editing_1 = require("@sitecore-content-sdk/content/editing");
14
14
  const personalize_1 = require("@sitecore-content-sdk/content/personalize");
15
15
  const site_1 = require("@sitecore-content-sdk/content/site");
@@ -69,6 +69,35 @@ const mapEditingParams = (query) => {
69
69
  return params;
70
70
  };
71
71
  exports.mapEditingParams = mapEditingParams;
72
+ /**
73
+ * Parses the query parameters based on the provided allowed parameters or a resolver function, to extract additional parameters that should be allowed.
74
+ * @param {{ [key: string]: string | undefined }} queryParams Object of query parameters from incoming URL.
75
+ * @param {AllowedQueryParams} allowedParams Allowed parameters to map.
76
+ * @returns Object containing the list of missing required parameters and the allowed query parameters that were extracted.
77
+ * @internal
78
+ */
79
+ const getAllowedQueryParams = (queryParams, allowedParams) => {
80
+ const allowedQueryParamsList = typeof allowedParams === 'function'
81
+ ? allowedParams(Object.keys(queryParams))
82
+ : Array.isArray(allowedParams)
83
+ ? allowedParams
84
+ : [];
85
+ if (!allowedQueryParamsList.length)
86
+ return { missingAllowedParams: [], allowedQueryParams: {} };
87
+ return allowedQueryParamsList.reduce((acc, param) => {
88
+ const name = typeof param === 'string' ? param : param.name;
89
+ const required = typeof param === 'string' ? false : param.required;
90
+ const value = queryParams[name];
91
+ if (value !== undefined) {
92
+ acc.allowedQueryParams[name] = value;
93
+ return acc;
94
+ }
95
+ if (required)
96
+ acc.missingAllowedParams.push(name);
97
+ return acc;
98
+ }, { missingAllowedParams: [], allowedQueryParams: {} });
99
+ };
100
+ exports.getAllowedQueryParams = getAllowedQueryParams;
72
101
  /**
73
102
  * Filters out Next.js preview cookies from a cookie string or array
74
103
  * @param {string | string[] | null} cookies cookie header value
package/dist/cjs/index.js CHANGED
@@ -37,7 +37,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
37
37
  };
38
38
  Object.defineProperty(exports, "__esModule", { value: true });
39
39
  exports.BYOCWrapper = exports.FEaaSWrapper = exports.BYOCServerWrapper = exports.BYOCClientWrapper = exports.FEaaSServerWrapper = exports.FEaaSClientWrapper = exports.NextImage = exports.Placeholder = exports.RichText = exports.Link = exports.useComponentProps = exports.ComponentPropsContext = exports.ComponentPropsReactContext = exports.ComponentPropsService = exports.normalizeSiteRewrite = exports.getSiteRewriteData = exports.getSiteRewrite = exports.SiteInfoService = exports.SiteResolver = exports.RobotsService = exports.ErrorPagesService = exports.SitemapXmlService = exports.REDIRECT_TYPE_SERVER_TRANSFER = exports.REDIRECT_TYPE_302 = exports.REDIRECT_TYPE_301 = exports.RedirectsService = exports.SitePathService = exports.PersonalizeService = exports.CdpHelper = exports.normalizePersonalizedRewrite = exports.getGroomedVariantIds = exports.getPersonalizedRewriteData = exports.getPersonalizedRewrite = exports.personalizeLayout = exports.DictionaryService = exports.mediaApi = exports.ComponentLayoutService = exports.ErrorPage = exports.RenderingType = exports.EditMode = exports.getContentStylesheetLink = exports.getFieldValue = exports.getChildPlaceholder = exports.LayoutService = exports.LayoutServicePageState = exports.MemoryCacheClient = exports.enableDebug = exports.NativeDataFetcher = exports.constants = exports.debug = void 0;
40
- exports.renderEmptyPlaceholder = exports.AppPlaceholder = exports.ClientEditingChromesUpdate = exports.Form = exports.EditingScripts = exports.withEmptyFieldEditingComponent = exports.withFieldMetadata = exports.withDatasourceCheck = exports.withPlaceholder = exports.withEditorChromes = exports.useSitecore = exports.withSitecore = exports.SitecoreProviderReactContext = exports.SitecoreProvider = exports.DefaultEmptyFieldEditingComponentText = exports.DefaultEmptyFieldEditingComponentImage = exports.DesignLibraryApp = exports.DesignLibrary = exports.File = exports.getDesignLibraryStylesheetLinks = exports.BYOCComponent = exports.fetchFEaaSComponentServerProps = exports.FEaaSComponent = exports.DateField = exports.Text = exports.Image = void 0;
40
+ exports.renderEmptyPlaceholder = exports.AppPlaceholder = exports.ClientEditingChromesUpdate = exports.Form = exports.EditingScripts = exports.withEmptyFieldEditingComponent = exports.withFieldMetadata = exports.withDatasourceCheck = exports.withPlaceholder = exports.withAppPlaceholder = exports.withEditorChromes = exports.useSitecore = exports.withSitecore = exports.SitecoreProviderReactContext = exports.SitecoreProvider = exports.DefaultEmptyFieldEditingComponentText = exports.DefaultEmptyFieldEditingComponentImage = exports.DesignLibraryApp = exports.DesignLibrary = exports.File = exports.getDesignLibraryStylesheetLinks = exports.BYOCComponent = exports.fetchFEaaSComponentServerProps = exports.FEaaSComponent = exports.DateField = exports.Text = exports.Image = void 0;
41
41
  var debug_1 = require("./debug");
42
42
  Object.defineProperty(exports, "debug", { enumerable: true, get: function () { return __importDefault(debug_1).default; } });
43
43
  var core_1 = require("@sitecore-content-sdk/core");
@@ -126,6 +126,7 @@ Object.defineProperty(exports, "SitecoreProviderReactContext", { enumerable: tru
126
126
  Object.defineProperty(exports, "withSitecore", { enumerable: true, get: function () { return react_2.withSitecore; } });
127
127
  Object.defineProperty(exports, "useSitecore", { enumerable: true, get: function () { return react_2.useSitecore; } });
128
128
  Object.defineProperty(exports, "withEditorChromes", { enumerable: true, get: function () { return react_2.withEditorChromes; } });
129
+ Object.defineProperty(exports, "withAppPlaceholder", { enumerable: true, get: function () { return react_2.withAppPlaceholder; } });
129
130
  Object.defineProperty(exports, "withPlaceholder", { enumerable: true, get: function () { return react_2.withPlaceholder; } });
130
131
  Object.defineProperty(exports, "withDatasourceCheck", { enumerable: true, get: function () { return react_2.withDatasourceCheck; } });
131
132
  Object.defineProperty(exports, "withFieldMetadata", { enumerable: true, get: function () { return react_2.withFieldMetadata; } });
@@ -116,11 +116,18 @@ const createEditingRenderRouteHandlers = (options) => {
116
116
  const mode = query.mode;
117
117
  const requiredQueryParams = (0, utils_2.getRequiredEditingParamsList)(mode);
118
118
  const missingQueryParams = requiredQueryParams.filter((param) => !query[param]);
119
+ const { allowedQueryParams, missingAllowedParams } = (0, utils_2.getAllowedQueryParams)(query, options.allowedQueryParams);
119
120
  // Validate query parameters
120
- if (missingQueryParams.length) {
121
- debug_1.default.editing('missing required query parameters: %o', missingQueryParams);
121
+ if (missingQueryParams.length || missingAllowedParams.length) {
122
+ debug_1.default.editing('missing required query parameters: %o', [
123
+ ...missingQueryParams,
124
+ ...missingAllowedParams,
125
+ ]);
122
126
  return Response.json({
123
- html: `<html><body>Missing required query parameters: ${missingQueryParams.join(', ')}</body></html>`,
127
+ html: `<html><body>Missing required query parameters: ${[
128
+ ...missingQueryParams,
129
+ ...missingAllowedParams,
130
+ ].join(', ')}</body></html>`,
124
131
  }, { status: 400, headers: responseHeaders });
125
132
  }
126
133
  const encodedRoute = encodeURI(query.route);
@@ -156,7 +163,7 @@ const createEditingRenderRouteHandlers = (options) => {
156
163
  debug_1.default.editing('fetching page route for %s', query.route);
157
164
  // Get query string parameters to propagate on subsequent requests (e.g. for deployment protection bypass)
158
165
  // Additionally ,in app router preview data is passed through query string instead of preview data cookie
159
- const propagatedQsParams = Object.assign(Object.assign({}, (0, utils_2.getQueryParamsForPropagation)(query)), (0, utils_2.mapEditingParams)(query));
166
+ const propagatedQsParams = Object.assign(Object.assign(Object.assign({}, (0, utils_2.getQueryParamsForPropagation)(query)), (0, utils_2.mapEditingParams)(query)), allowedQueryParams);
160
167
  // Get headers to propagate on subsequent requests
161
168
  const propagatedHeaders = (0, utils_2.getHeadersForPropagation)(headers);
162
169
  const html = yield (0, utils_2.getEditingRequestHtml)(requestUrl, propagatedQsParams, propagatedHeaders, convertedCookies, dataFetcher);
@@ -215,7 +222,7 @@ const createEditingRenderRouteHandlers = (options) => {
215
222
  req.nextUrl.searchParams.forEach((value, key) => {
216
223
  query[key] = value;
217
224
  });
218
- const propagatedQsParams = Object.assign(Object.assign({}, (0, utils_2.getQueryParamsForPropagation)(query)), (0, utils_2.mapEditingParams)(query));
225
+ const propagatedQsParams = Object.assign(Object.assign(Object.assign({}, (0, utils_2.getQueryParamsForPropagation)(query)), (0, utils_2.mapEditingParams)(query)), (0, utils_2.getAllowedQueryParams)(query, options.allowedQueryParams).allowedQueryParams);
219
226
  const base = (0, utils_2.resolveServerUrl)(req);
220
227
  const targetUrl = new URL('/', base);
221
228
  for (const key in propagatedQsParams) {
@@ -1,9 +1,9 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.writeImportMap = exports.__mockDependencies = void 0;
4
- const tools_1 = require("@sitecore-content-sdk/content/tools");
4
+ const node_tools_1 = require("@sitecore-content-sdk/content/node-tools");
5
5
  const utils_1 = require("../templating/utils");
6
- let writeImportMapCore = tools_1.writeImportMap;
6
+ let writeImportMapCore = node_tools_1.writeImportMap;
7
7
  const __mockDependencies = (mocks) => {
8
8
  if (mocks.writeImportMapCore) {
9
9
  writeImportMapCore = mocks.writeImportMapCore;
@@ -1,12 +1,12 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.writeImportMap = exports.generateMap = exports.generateMetadata = exports.extractFiles = exports.getComponentList = exports.generateSites = void 0;
4
- var tools_1 = require("@sitecore-content-sdk/content/tools");
5
- Object.defineProperty(exports, "generateSites", { enumerable: true, get: function () { return tools_1.generateSites; } });
6
- Object.defineProperty(exports, "getComponentList", { enumerable: true, get: function () { return tools_1.getComponentList; } });
7
- Object.defineProperty(exports, "extractFiles", { enumerable: true, get: function () { return tools_1.extractFiles; } });
8
- var tools_2 = require("@sitecore-content-sdk/core/tools");
9
- Object.defineProperty(exports, "generateMetadata", { enumerable: true, get: function () { return tools_2.generateMetadata; } });
4
+ var node_tools_1 = require("@sitecore-content-sdk/content/node-tools");
5
+ Object.defineProperty(exports, "generateSites", { enumerable: true, get: function () { return node_tools_1.generateSites; } });
6
+ Object.defineProperty(exports, "getComponentList", { enumerable: true, get: function () { return node_tools_1.getComponentList; } });
7
+ Object.defineProperty(exports, "extractFiles", { enumerable: true, get: function () { return node_tools_1.extractFiles; } });
8
+ var node_tools_2 = require("@sitecore-content-sdk/core/node-tools");
9
+ Object.defineProperty(exports, "generateMetadata", { enumerable: true, get: function () { return node_tools_2.generateMetadata; } });
10
10
  var generate_map_1 = require("./generate-map");
11
11
  Object.defineProperty(exports, "generateMap", { enumerable: true, get: function () { return generate_map_1.generateMap; } });
12
12
  var import_map_1 = require("./codegen/import-map");
@@ -9,10 +9,9 @@ exports.getComponentListWithTypes = getComponentListWithTypes;
9
9
  exports.nextjsClientMapTemplate = nextjsClientMapTemplate;
10
10
  exports.nextjsServertMapTemplate = nextjsServertMapTemplate;
11
11
  exports.nextjsDefaultMapTemplate = nextjsDefaultMapTemplate;
12
- const tools_1 = require("@sitecore-content-sdk/content/tools");
12
+ const node_tools_1 = require("@sitecore-content-sdk/content/node-tools");
13
13
  const typescript_1 = __importDefault(require("typescript"));
14
14
  const fs_1 = __importDefault(require("fs"));
15
- const tools_2 = require("@sitecore-content-sdk/content/tools");
16
15
  /**
17
16
  * Detects the Next.js router type (App Router or Pages Router) based on directory structure.
18
17
  * @param {string} projectRoot - The project root directory. Defaults to current working directory.
@@ -178,7 +177,7 @@ function detectComponentType(filePath, routerType) {
178
177
  * @internal
179
178
  */
180
179
  function getComponentListWithTypes(paths, exclude, includeVariants, routerType) {
181
- const components = (0, tools_1.getComponentList)(paths, exclude, includeVariants);
180
+ const components = (0, node_tools_1.getComponentList)(paths, exclude, includeVariants);
182
181
  const detectedRouterType = routerType || detectRouterType();
183
182
  return components.map((component) => (Object.assign(Object.assign({}, component), { componentType: detectComponentType(component.filePath, detectedRouterType) })));
184
183
  }
@@ -189,7 +188,7 @@ function getComponentListWithTypes(paths, exclude, includeVariants, routerType)
189
188
  */
190
189
  function nextjsClientMapTemplate(indexedImportMap) {
191
190
  return `'use client';
192
- ${(0, tools_2.defaultImportMapTemplate)(indexedImportMap, 'nextjs')}`;
191
+ ${(0, node_tools_1.defaultImportMapTemplate)(indexedImportMap, 'nextjs')}`;
193
192
  }
194
193
  /**
195
194
  * React-specific import map template for server side imports only. Used in App Router.
@@ -197,7 +196,7 @@ function nextjsClientMapTemplate(indexedImportMap) {
197
196
  * @returns {string} contents for resulting import map file
198
197
  */
199
198
  function nextjsServertMapTemplate(indexedImportMap) {
200
- return (0, tools_2.defaultImportMapTemplate)(indexedImportMap, 'nextjs', 'defaultServerImportEntries');
199
+ return (0, node_tools_1.defaultImportMapTemplate)(indexedImportMap, 'nextjs', 'defaultServerImportEntries');
201
200
  }
202
201
  /**
203
202
  * React-specific import map template. Used in Pages Router.
@@ -205,5 +204,5 @@ function nextjsServertMapTemplate(indexedImportMap) {
205
204
  * @returns {string} contents for resulting import map file
206
205
  */
207
206
  function nextjsDefaultMapTemplate(indexedImportMap) {
208
- return (0, tools_2.defaultImportMapTemplate)(indexedImportMap, 'nextjs');
207
+ return (0, node_tools_1.defaultImportMapTemplate)(indexedImportMap, 'nextjs');
209
208
  }
@@ -14,7 +14,7 @@ import { getEditingSecret } from '../utils/utils';
14
14
  import { RenderMiddlewareBase } from './render-middleware';
15
15
  import { getEnforcedCorsHeaders } from '@sitecore-content-sdk/core/tools';
16
16
  import debug from '../debug';
17
- import { getPreviewCookies, getRequiredEditingParamsList, mapEditingParams, cleanupNextPreviewCookies, getQueryParamsForPropagation, getHeadersForPropagation, getEditingRequestHtml, getCSPHeader, resolveServerUrl, } from './utils';
17
+ import { getPreviewCookies, getRequiredEditingParamsList, mapEditingParams, cleanupNextPreviewCookies, getQueryParamsForPropagation, getHeadersForPropagation, getEditingRequestHtml, getCSPHeader, resolveServerUrl, getAllowedQueryParams, } from './utils';
18
18
  /**
19
19
  * Middleware / handler for use in the editing render Next.js API route (e.g. '/api/editing/render')
20
20
  * which is required for Sitecore editing support.
@@ -28,7 +28,7 @@ export class EditingRenderMiddleware extends RenderMiddlewareBase {
28
28
  super();
29
29
  this.config = config;
30
30
  this.handler = (req, res) => __awaiter(this, void 0, void 0, function* () {
31
- var _a, _b, _c, _d, _e;
31
+ var _a, _b, _c, _d, _e, _f;
32
32
  const { body, method, headers, query } = req;
33
33
  debug.editing('editing render middleware start: %o', {
34
34
  method,
@@ -75,15 +75,22 @@ export class EditingRenderMiddleware extends RenderMiddlewareBase {
75
75
  const mode = query.mode;
76
76
  const requiredQueryParams = getRequiredEditingParamsList(mode);
77
77
  const missingQueryParams = requiredQueryParams.filter((param) => !query[param]);
78
+ const { allowedQueryParams, missingAllowedParams } = getAllowedQueryParams(query, (_b = this.config) === null || _b === void 0 ? void 0 : _b.allowedQueryParams);
78
79
  // Validate query parameters
79
- if (missingQueryParams.length) {
80
- debug.editing('missing required query parameters: %o', missingQueryParams);
80
+ if (missingQueryParams.length || missingAllowedParams.length) {
81
+ debug.editing('missing required query parameters: %o', [
82
+ ...missingQueryParams,
83
+ ...missingAllowedParams,
84
+ ]);
81
85
  return res.status(400).json({
82
- html: `<html><body>Missing required query parameters: ${missingQueryParams.join(', ')}</body></html>`,
86
+ html: `<html><body>Missing required query parameters: ${[
87
+ ...missingQueryParams,
88
+ ...missingAllowedParams,
89
+ ].join(', ')}</body></html>`,
83
90
  });
84
91
  }
85
92
  const previewDataParams = mapEditingParams(query);
86
- res.setPreviewData(Object.assign(Object.assign({}, previewDataParams), { variantIds: (_b = previewDataParams.variantIds) === null || _b === void 0 ? void 0 : _b.split(',') }), {
93
+ res.setPreviewData(Object.assign(Object.assign(Object.assign({}, previewDataParams), allowedQueryParams), { variantIds: (_c = previewDataParams.variantIds) === null || _c === void 0 ? void 0 : _c.split(',') }), {
87
94
  maxAge: 3,
88
95
  });
89
96
  // Set Preview mode identifier cookie, if the page is rendered in Sitecore Preview mode
@@ -95,8 +102,8 @@ export class EditingRenderMiddleware extends RenderMiddlewareBase {
95
102
  // Restrict the page to be rendered only within the allowed origins
96
103
  res.setHeader('Content-Security-Policy', getCSPHeader());
97
104
  const encodedRoute = encodeURI(query.route);
98
- const route = ((_d = (_c = this.config) === null || _c === void 0 ? void 0 : _c.resolvePageUrl) === null || _d === void 0 ? void 0 : _d.call(_c, encodedRoute)) || encodedRoute;
99
- const base = ((_e = this.config) === null || _e === void 0 ? void 0 : _e.sitecoreInternalEditingHostUrl) || resolveServerUrl(req);
105
+ const route = ((_e = (_d = this.config) === null || _d === void 0 ? void 0 : _d.resolvePageUrl) === null || _e === void 0 ? void 0 : _e.call(_d, encodedRoute)) || encodedRoute;
106
+ const base = ((_f = this.config) === null || _f === void 0 ? void 0 : _f.sitecoreInternalEditingHostUrl) || resolveServerUrl(req);
100
107
  const requestUrl = new URL(route, base);
101
108
  const cookies = res.getHeader('Set-Cookie');
102
109
  // Make actual render request for page route, passing on preview cookies as well as any approved query string parameters.
@@ -117,6 +124,7 @@ export class EditingRenderMiddleware extends RenderMiddlewareBase {
117
124
  status: 200,
118
125
  route,
119
126
  });
127
+ res.setHeader('Content-Type', 'text/html; charset=utf-8');
120
128
  res.status(200).send(html);
121
129
  }
122
130
  catch (err) {
@@ -0,0 +1 @@
1
+ export {};
@@ -64,6 +64,34 @@ export const mapEditingParams = (query) => {
64
64
  };
65
65
  return params;
66
66
  };
67
+ /**
68
+ * Parses the query parameters based on the provided allowed parameters or a resolver function, to extract additional parameters that should be allowed.
69
+ * @param {{ [key: string]: string | undefined }} queryParams Object of query parameters from incoming URL.
70
+ * @param {AllowedQueryParams} allowedParams Allowed parameters to map.
71
+ * @returns Object containing the list of missing required parameters and the allowed query parameters that were extracted.
72
+ * @internal
73
+ */
74
+ export const getAllowedQueryParams = (queryParams, allowedParams) => {
75
+ const allowedQueryParamsList = typeof allowedParams === 'function'
76
+ ? allowedParams(Object.keys(queryParams))
77
+ : Array.isArray(allowedParams)
78
+ ? allowedParams
79
+ : [];
80
+ if (!allowedQueryParamsList.length)
81
+ return { missingAllowedParams: [], allowedQueryParams: {} };
82
+ return allowedQueryParamsList.reduce((acc, param) => {
83
+ const name = typeof param === 'string' ? param : param.name;
84
+ const required = typeof param === 'string' ? false : param.required;
85
+ const value = queryParams[name];
86
+ if (value !== undefined) {
87
+ acc.allowedQueryParams[name] = value;
88
+ return acc;
89
+ }
90
+ if (required)
91
+ acc.missingAllowedParams.push(name);
92
+ return acc;
93
+ }, { missingAllowedParams: [], allowedQueryParams: {} });
94
+ };
67
95
  /**
68
96
  * Filters out Next.js preview cookies from a cookie string or array
69
97
  * @param {string | string[] | null} cookies cookie header value
package/dist/esm/index.js CHANGED
@@ -21,4 +21,4 @@ import * as BYOCWrapper from './components/BYOCWrapper';
21
21
  export { FEaaSClientWrapper, FEaaSServerWrapper, BYOCClientWrapper, BYOCServerWrapper, } from '@sitecore-content-sdk/react';
22
22
  export { FEaaSWrapper };
23
23
  export { BYOCWrapper };
24
- export { Image, Text, DateField, FEaaSComponent, fetchFEaaSComponentServerProps, BYOCComponent, getDesignLibraryStylesheetLinks, File, DesignLibrary, DesignLibraryApp, DefaultEmptyFieldEditingComponentImage, DefaultEmptyFieldEditingComponentText, SitecoreProvider, SitecoreProviderReactContext, withSitecore, useSitecore, withEditorChromes, withPlaceholder, withDatasourceCheck, withFieldMetadata, withEmptyFieldEditingComponent, EditingScripts, Form, ClientEditingChromesUpdate, AppPlaceholder, renderEmptyPlaceholder, } from '@sitecore-content-sdk/react';
24
+ export { Image, Text, DateField, FEaaSComponent, fetchFEaaSComponentServerProps, BYOCComponent, getDesignLibraryStylesheetLinks, File, DesignLibrary, DesignLibraryApp, DefaultEmptyFieldEditingComponentImage, DefaultEmptyFieldEditingComponentText, SitecoreProvider, SitecoreProviderReactContext, withSitecore, useSitecore, withEditorChromes, withAppPlaceholder, withPlaceholder, withDatasourceCheck, withFieldMetadata, withEmptyFieldEditingComponent, EditingScripts, Form, ClientEditingChromesUpdate, AppPlaceholder, renderEmptyPlaceholder, } from '@sitecore-content-sdk/react';
@@ -13,7 +13,7 @@ import { getEnforcedCorsHeaders } from '@sitecore-content-sdk/core/tools';
13
13
  import { LayoutServicePageState } from '@sitecore-content-sdk/content/layout';
14
14
  import { getEditingSecret } from '../utils/utils';
15
15
  import { draftMode, cookies as nextCokies } from 'next/headers';
16
- import { mapEditingParams, getEditingRequestHtml, cleanupNextPreviewCookies, getHeadersForPropagation, getQueryParamsForPropagation, getRequiredEditingParamsList, getCSPHeader, resolveServerUrl, } from '../editing/utils';
16
+ import { mapEditingParams, getEditingRequestHtml, cleanupNextPreviewCookies, getHeadersForPropagation, getQueryParamsForPropagation, getRequiredEditingParamsList, getCSPHeader, resolveServerUrl, getAllowedQueryParams, } from '../editing/utils';
17
17
  import { SITE_KEY } from '@sitecore-content-sdk/content/site';
18
18
  import debug from '../debug';
19
19
  /**
@@ -109,11 +109,18 @@ export const createEditingRenderRouteHandlers = (options) => {
109
109
  const mode = query.mode;
110
110
  const requiredQueryParams = getRequiredEditingParamsList(mode);
111
111
  const missingQueryParams = requiredQueryParams.filter((param) => !query[param]);
112
+ const { allowedQueryParams, missingAllowedParams } = getAllowedQueryParams(query, options.allowedQueryParams);
112
113
  // Validate query parameters
113
- if (missingQueryParams.length) {
114
- debug.editing('missing required query parameters: %o', missingQueryParams);
114
+ if (missingQueryParams.length || missingAllowedParams.length) {
115
+ debug.editing('missing required query parameters: %o', [
116
+ ...missingQueryParams,
117
+ ...missingAllowedParams,
118
+ ]);
115
119
  return Response.json({
116
- html: `<html><body>Missing required query parameters: ${missingQueryParams.join(', ')}</body></html>`,
120
+ html: `<html><body>Missing required query parameters: ${[
121
+ ...missingQueryParams,
122
+ ...missingAllowedParams,
123
+ ].join(', ')}</body></html>`,
117
124
  }, { status: 400, headers: responseHeaders });
118
125
  }
119
126
  const encodedRoute = encodeURI(query.route);
@@ -149,7 +156,7 @@ export const createEditingRenderRouteHandlers = (options) => {
149
156
  debug.editing('fetching page route for %s', query.route);
150
157
  // Get query string parameters to propagate on subsequent requests (e.g. for deployment protection bypass)
151
158
  // Additionally ,in app router preview data is passed through query string instead of preview data cookie
152
- const propagatedQsParams = Object.assign(Object.assign({}, getQueryParamsForPropagation(query)), mapEditingParams(query));
159
+ const propagatedQsParams = Object.assign(Object.assign(Object.assign({}, getQueryParamsForPropagation(query)), mapEditingParams(query)), allowedQueryParams);
153
160
  // Get headers to propagate on subsequent requests
154
161
  const propagatedHeaders = getHeadersForPropagation(headers);
155
162
  const html = yield getEditingRequestHtml(requestUrl, propagatedQsParams, propagatedHeaders, convertedCookies, dataFetcher);
@@ -208,7 +215,7 @@ export const createEditingRenderRouteHandlers = (options) => {
208
215
  req.nextUrl.searchParams.forEach((value, key) => {
209
216
  query[key] = value;
210
217
  });
211
- const propagatedQsParams = Object.assign(Object.assign({}, getQueryParamsForPropagation(query)), mapEditingParams(query));
218
+ const propagatedQsParams = Object.assign(Object.assign(Object.assign({}, getQueryParamsForPropagation(query)), mapEditingParams(query)), getAllowedQueryParams(query, options.allowedQueryParams).allowedQueryParams);
212
219
  const base = resolveServerUrl(req);
213
220
  const targetUrl = new URL('/', base);
214
221
  for (const key in propagatedQsParams) {
@@ -1,4 +1,4 @@
1
- import { writeImportMap as writeImportMapCoreImpl, } from '@sitecore-content-sdk/content/tools';
1
+ import { writeImportMap as writeImportMapCoreImpl, } from '@sitecore-content-sdk/content/node-tools';
2
2
  import { detectRouterType, nextjsClientMapTemplate, nextjsServertMapTemplate, nextjsDefaultMapTemplate, } from '../templating/utils';
3
3
  let writeImportMapCore = writeImportMapCoreImpl;
4
4
  export const __mockDependencies = (mocks) => {
@@ -1,4 +1,4 @@
1
- export { generateSites, getComponentList, extractFiles, } from '@sitecore-content-sdk/content/tools';
2
- export { generateMetadata } from '@sitecore-content-sdk/core/tools';
1
+ export { generateSites, getComponentList, extractFiles, } from '@sitecore-content-sdk/content/node-tools';
2
+ export { generateMetadata } from '@sitecore-content-sdk/core/node-tools';
3
3
  export { generateMap } from './generate-map';
4
4
  export { writeImportMap } from './codegen/import-map';
@@ -1,7 +1,6 @@
1
- import { getComponentList, } from '@sitecore-content-sdk/content/tools';
1
+ import { getComponentList, defaultImportMapTemplate, } from '@sitecore-content-sdk/content/node-tools';
2
2
  import ts from 'typescript';
3
3
  import fs from 'fs';
4
- import { defaultImportMapTemplate } from '@sitecore-content-sdk/content/tools';
5
4
  /**
6
5
  * Detects the Next.js router type (App Router or Pages Router) based on directory structure.
7
6
  * @param {string} projectRoot - The project root directory. Defaults to current working directory.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sitecore-content-sdk/nextjs",
3
- "version": "2.0.0-canary.1",
3
+ "version": "2.0.0-canary.10",
4
4
  "main": "dist/cjs/index.js",
5
5
  "module": "dist/esm/index.js",
6
6
  "sideEffects": false,
@@ -91,9 +91,9 @@
91
91
  },
92
92
  "dependencies": {
93
93
  "@babel/parser": "^7.27.2",
94
- "@sitecore-content-sdk/content": "2.0.0-canary.1",
95
- "@sitecore-content-sdk/core": "2.0.0-canary.1",
96
- "@sitecore-content-sdk/react": "2.0.0-canary.1",
94
+ "@sitecore-content-sdk/content": "2.0.0-canary.10",
95
+ "@sitecore-content-sdk/core": "2.0.0-canary.10",
96
+ "@sitecore-content-sdk/react": "2.0.0-canary.10",
97
97
  "recast": "^0.23.11",
98
98
  "regex-parser": "^2.3.1",
99
99
  "sync-disk-cache": "^2.1.0"
@@ -177,7 +177,7 @@
177
177
  },
178
178
  "description": "",
179
179
  "types": "types/index.d.ts",
180
- "gitHead": "b457ff6e0b17787c66803a15b50da0d3ad6e4200",
180
+ "gitHead": "6246e4787e22778e64c90bcd9292a9988b3552a8",
181
181
  "files": [
182
182
  "dist",
183
183
  "types",
@@ -1,9 +1,9 @@
1
1
  import React from 'react';
2
- import { PlaceholderComponentProps, WithSitecoreProps, EnhancedOmit } from '@sitecore-content-sdk/react';
2
+ import { PlaceholderComponentProps, EnhancedOmit, SitecoreProviderState } from '@sitecore-content-sdk/react';
3
3
  /**
4
4
  * React Placeholder component wrapped by withSitecore, so these properties shouldn't be passed to the Next.js Placeholder.
5
5
  */
6
- type PlaceholderProps = EnhancedOmit<PlaceholderComponentProps, keyof WithSitecoreProps>;
6
+ type PlaceholderProps = EnhancedOmit<PlaceholderComponentProps, keyof SitecoreProviderState>;
7
7
  /**
8
8
  * The Placeholder component.
9
9
  * @param {PlaceholderProps} props component props
@@ -1 +1 @@
1
- {"version":3,"file":"Placeholder.d.ts","sourceRoot":"","sources":["../../src/components/Placeholder.tsx"],"names":[],"mappings":"AACA,OAAO,KAAqB,MAAM,OAAO,CAAC;AAC1C,OAAO,EAEL,yBAAyB,EACzB,iBAAiB,EACjB,YAAY,EACb,MAAM,6BAA6B,CAAC;AAGrC;;GAEG;AACH,KAAK,gBAAgB,GAAG,YAAY,CAAC,yBAAyB,EAAE,MAAM,iBAAiB,CAAC,CAAC;AAEzF;;;;GAIG;AACH,eAAO,MAAM,WAAW,GAAI,OAAO,gBAAgB,sBAiBlD,CAAC"}
1
+ {"version":3,"file":"Placeholder.d.ts","sourceRoot":"","sources":["../../src/components/Placeholder.tsx"],"names":[],"mappings":"AACA,OAAO,KAAqB,MAAM,OAAO,CAAC;AAC1C,OAAO,EAEL,yBAAyB,EACzB,YAAY,EACZ,qBAAqB,EACtB,MAAM,6BAA6B,CAAC;AAGrC;;GAEG;AACH,KAAK,gBAAgB,GAAG,YAAY,CAAC,yBAAyB,EAAE,MAAM,qBAAqB,CAAC,CAAC;AAE7F;;;;GAIG;AACH,eAAO,MAAM,WAAW,GAAI,OAAO,gBAAgB,sBAiBlD,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"define-config.d.ts","sourceRoot":"","sources":["../../src/config/define-config.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,YAAY,EAEZ,mBAAmB,IAAI,uBAAuB,EAC/C,MAAM,sCAAsC,CAAC;AAM9C;;;;GAIG;AACH,eAAO,MAAM,qBAAqB,GAAI,SAAS,mBAAmB,KAAG,mBAuCpE,CAAC;AAEF;;;GAGG;AACH,MAAM,MAAM,mBAAmB,GAAG,uBAAuB,GAAG;IAC1D;;;;;;;;;OASG;IACH,mBAAmB,CAAC,EAAE,OAAO,CAAC;IAE9B;;;OAGG;IACH,8BAA8B,CAAC,EAAE,MAAM,CAAC;CACzC,CAAC;AAEF;;;GAGG;AACH,MAAM,MAAM,cAAc,GAAG,YAAY,CAAC,mBAAmB,CAAC,CAAC;AAE/D;;;;;GAKG;AACH,eAAO,MAAM,YAAY,GAAI,SAAS,mBAAmB,KAAG,cAE3D,CAAC"}
1
+ {"version":3,"file":"define-config.d.ts","sourceRoot":"","sources":["../../src/config/define-config.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,YAAY,EAEZ,mBAAmB,IAAI,uBAAuB,EAC/C,MAAM,sCAAsC,CAAC;AAO9C;;;;GAIG;AACH,eAAO,MAAM,qBAAqB,GAAI,SAAS,mBAAmB,KAAG,mBAsCpE,CAAC;AAEF;;;GAGG;AACH,MAAM,MAAM,mBAAmB,GAAG,uBAAuB,GAAG;IAC1D;;;;;;;;;OASG;IACH,mBAAmB,CAAC,EAAE,OAAO,CAAC;IAE9B;;;OAGG;IACH,8BAA8B,CAAC,EAAE,MAAM,CAAC;CACzC,CAAC;AAEF;;;GAGG;AACH,MAAM,MAAM,cAAc,GAAG,YAAY,CAAC,mBAAmB,CAAC,CAAC;AAE/D;;;;;GAKG;AACH,eAAO,MAAM,YAAY,GAAI,SAAS,mBAAmB,KAAG,cAE3D,CAAC"}
@@ -1,5 +1,5 @@
1
1
  import { NextApiRequest, NextApiResponse } from 'next';
2
- import { Metadata } from '@sitecore-content-sdk/core/tools';
2
+ import { Metadata } from '@sitecore-content-sdk/core/node-tools';
3
3
  import { ComponentMap } from '@sitecore-content-sdk/react';
4
4
  import { NextjsContentSdkComponent } from '../sharedTypes/component-props';
5
5
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"editing-config-middleware.d.ts","sourceRoot":"","sources":["../../src/editing/editing-config-middleware.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,MAAM,CAAC;AAMvD,OAAO,EAAE,QAAQ,EAAE,MAAM,kCAAkC,CAAC;AAI5D,OAAO,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAC3D,OAAO,EAAE,yBAAyB,EAAE,MAAM,gCAAgC,CAAC;AAE3E;;;GAGG;AACH,MAAM,MAAM,6BAA6B,GAAG;IAC1C;;OAEG;IACH,UAAU,EAAE,YAAY,CAAC,yBAAyB,CAAC,CAAC;IACpD;;OAEG;IACH,QAAQ,EAAE,QAAQ,CAAC;CACpB,CAAC;AAEF;;;;GAIG;AACH,qBAAa,uBAAuB;IAItB,SAAS,CAAC,MAAM,EAAE,6BAA6B;IAH3D;;OAEG;gBACmB,MAAM,EAAE,6BAA6B;IAE3D;;;OAGG;IACI,UAAU,IAAI,CAAC,GAAG,EAAE,cAAc,EAAE,GAAG,EAAE,eAAe,KAAK,OAAO,CAAC,IAAI,CAAC;IAIjF,OAAO,CAAC,OAAO,CAqCb;CACH"}
1
+ {"version":3,"file":"editing-config-middleware.d.ts","sourceRoot":"","sources":["../../src/editing/editing-config-middleware.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,MAAM,CAAC;AAMvD,OAAO,EAAE,QAAQ,EAAE,MAAM,uCAAuC,CAAC;AAIjE,OAAO,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAC3D,OAAO,EAAE,yBAAyB,EAAE,MAAM,gCAAgC,CAAC;AAE3E;;;GAGG;AACH,MAAM,MAAM,6BAA6B,GAAG;IAC1C;;OAEG;IACH,UAAU,EAAE,YAAY,CAAC,yBAAyB,CAAC,CAAC;IACpD;;OAEG;IACH,QAAQ,EAAE,QAAQ,CAAC;CACpB,CAAC;AAEF;;;;GAIG;AACH,qBAAa,uBAAuB;IAItB,SAAS,CAAC,MAAM,EAAE,6BAA6B;IAH3D;;OAEG;gBACmB,MAAM,EAAE,6BAA6B;IAE3D;;;OAGG;IACI,UAAU,IAAI,CAAC,GAAG,EAAE,cAAc,EAAE,GAAG,EAAE,eAAe,KAAK,OAAO,CAAC,IAAI,CAAC;IAIjF,OAAO,CAAC,OAAO,CAqCb;CACH"}
@@ -1,6 +1,7 @@
1
1
  import { NextApiRequest, NextApiResponse } from 'next';
2
2
  import { EditingRenderQueryParams } from '@sitecore-content-sdk/content/editing';
3
3
  import { RenderMiddlewareBase } from './render-middleware';
4
+ import type { AllowedQueryParams } from './types';
4
5
  /**
5
6
  * Configuration for the Editing Render Middleware.
6
7
  * @public
@@ -18,6 +19,12 @@ export type EditingRenderMiddlewareConfig = {
18
19
  * The internal host URL for the Next.js application, used for server-side requests for page rendering during editing.
19
20
  */
20
21
  sitecoreInternalEditingHostUrl?: string;
22
+ /**
23
+ * Query string parameters to allow and include in the preview data.
24
+ * - Array: each item is a parameter name (string) or an object `{ name, required? }`.
25
+ * - Function: receives the request's query parameter names and returns the list of allowed parameters.
26
+ */
27
+ allowedQueryParams?: AllowedQueryParams;
21
28
  };
22
29
  /**
23
30
  * Next.js API request with editing request query parameters.
@@ -1 +1 @@
1
- {"version":3,"file":"editing-render-middleware.d.ts","sourceRoot":"","sources":["../../src/editing/editing-render-middleware.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,MAAM,CAAC;AAEvD,OAAO,EAIL,wBAAwB,EACzB,MAAM,uCAAuC,CAAC;AAG/C,OAAO,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAe3D;;;GAGG;AACH,MAAM,MAAM,6BAA6B,GAAG;IAC1C;;;;;;OAMG;IACH,cAAc,CAAC,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,MAAM,CAAC;IAC9C;;OAEG;IACH,8BAA8B,CAAC,EAAE,MAAM,CAAC;CACzC,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,qBAAqB,GAAG,cAAc,GAAG;IACnD,KAAK,EAAE,wBAAwB,CAAC;CACjC,CAAC;AAEF;;;;GAIG;AACH,qBAAa,uBAAwB,SAAQ,oBAAoB;IAK5C,MAAM,CAAC,EAAE,6BAA6B;IAJzD,OAAO,CAAC,WAAW,CAAoB;IACvC;;OAEG;gBACgB,MAAM,CAAC,EAAE,6BAA6B,YAAA;IAKzD;;;OAGG;IACI,UAAU,IAAI,CAAC,GAAG,EAAE,qBAAqB,EAAE,GAAG,EAAE,eAAe,KAAK,OAAO,CAAC,IAAI,CAAC;IAIxF,OAAO,CAAC,OAAO,CAoJb;CACH"}
1
+ {"version":3,"file":"editing-render-middleware.d.ts","sourceRoot":"","sources":["../../src/editing/editing-render-middleware.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,MAAM,CAAC;AAEvD,OAAO,EAIL,wBAAwB,EACzB,MAAM,uCAAuC,CAAC;AAG/C,OAAO,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAe3D,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAC;AAElD;;;GAGG;AACH,MAAM,MAAM,6BAA6B,GAAG;IAC1C;;;;;;OAMG;IACH,cAAc,CAAC,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,MAAM,CAAC;IAC9C;;OAEG;IACH,8BAA8B,CAAC,EAAE,MAAM,CAAC;IACxC;;;;OAIG;IACH,kBAAkB,CAAC,EAAE,kBAAkB,CAAC;CACzC,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,qBAAqB,GAAG,cAAc,GAAG;IACnD,KAAK,EAAE,wBAAwB,CAAC;CACjC,CAAC;AAEF;;;;GAIG;AACH,qBAAa,uBAAwB,SAAQ,oBAAoB;IAK5C,MAAM,CAAC,EAAE,6BAA6B;IAJzD,OAAO,CAAC,WAAW,CAAoB;IACvC;;OAEG;gBACgB,MAAM,CAAC,EAAE,6BAA6B,YAAA;IAKzD;;;OAGG;IACI,UAAU,IAAI,CAAC,GAAG,EAAE,qBAAqB,EAAE,GAAG,EAAE,eAAe,KAAK,OAAO,CAAC,IAAI,CAAC;IAIxF,OAAO,CAAC,OAAO,CA8Jb;CACH"}
@@ -4,4 +4,5 @@ export { isDesignLibraryPreviewData, getQueryParamsForPropagation, getHeadersFor
4
4
  export { FEAASRenderMiddleware, FEAASRenderMiddlewareConfig } from './feaas-render-middleware';
5
5
  export { EditingConfigMiddleware, EditingConfigMiddlewareConfig, } from './editing-config-middleware';
6
6
  export { RenderingType, EDITING_COMPONENT_PLACEHOLDER, EDITING_COMPONENT_ID, } from '@sitecore-content-sdk/content/layout';
7
+ export type { AllowedQueryParam, AllowedQueryParamsResolver, AllowedQueryParams } from './types';
7
8
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/editing/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,uCAAuC,CAAC;AACvE,OAAO,EACL,uBAAuB,EACvB,6BAA6B,GAC9B,MAAM,6BAA6B,CAAC;AACrC,OAAO,EACL,0BAA0B,EAC1B,4BAA4B,EAC5B,wBAAwB,GACzB,MAAM,SAAS,CAAC;AACjB,OAAO,EAAE,qBAAqB,EAAE,2BAA2B,EAAE,MAAM,2BAA2B,CAAC;AAC/F,OAAO,EACL,uBAAuB,EACvB,6BAA6B,GAC9B,MAAM,6BAA6B,CAAC;AACrC,OAAO,EACL,aAAa,EACb,6BAA6B,EAC7B,oBAAoB,GACrB,MAAM,sCAAsC,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/editing/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,uCAAuC,CAAC;AACvE,OAAO,EACL,uBAAuB,EACvB,6BAA6B,GAC9B,MAAM,6BAA6B,CAAC;AACrC,OAAO,EACL,0BAA0B,EAC1B,4BAA4B,EAC5B,wBAAwB,GACzB,MAAM,SAAS,CAAC;AACjB,OAAO,EAAE,qBAAqB,EAAE,2BAA2B,EAAE,MAAM,2BAA2B,CAAC;AAC/F,OAAO,EACL,uBAAuB,EACvB,6BAA6B,GAC9B,MAAM,6BAA6B,CAAC;AACrC,OAAO,EACL,aAAa,EACb,6BAA6B,EAC7B,oBAAoB,GACrB,MAAM,sCAAsC,CAAC;AAC9C,YAAY,EAAE,iBAAiB,EAAE,0BAA0B,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAC"}
@@ -0,0 +1,37 @@
1
+ /**
2
+ * Represents an allowed query parameter.
3
+ * @public
4
+ */
5
+ export interface AllowedQueryParam {
6
+ /**
7
+ * The name of the query parameter to allow.
8
+ */
9
+ name: string;
10
+ /**
11
+ * Whether the query parameter is required.
12
+ */
13
+ required?: boolean;
14
+ }
15
+ /**
16
+ * Resolver function for allowed query parameters, which can be used to extract additional parameters from the query string beyond the required editing parameters.
17
+ * @param {string[]} queryParams Array of query parameters from incoming URL.
18
+ * @returns {Array<AllowedQueryParam | string>} Allowed query editing parameters.
19
+ * @public
20
+ */
21
+ export type AllowedQueryParamsResolver = (queryParams: string[]) => Array<AllowedQueryParam | string>;
22
+ /**
23
+ * Allowed query parameters which can be defined as an array of parameter names or objects, or a resolver function which can be used to extract additional parameters from the query string beyond the required editing parameters.
24
+ * @public
25
+ */
26
+ export type AllowedQueryParams = Array<AllowedQueryParam | string> | AllowedQueryParamsResolver;
27
+ /**
28
+ * Result of processing allowed query parameters, including any missing required parameters and the set of allowed parameters that were extracted from the query string.
29
+ * @internal
30
+ */
31
+ export interface GetAllowedQueryParamsResult {
32
+ missingAllowedParams: string[];
33
+ allowedQueryParams: {
34
+ [key: string]: unknown;
35
+ };
36
+ }
37
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/editing/types.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,MAAM,WAAW,iBAAiB;IAChC;;OAEG;IACH,IAAI,EAAE,MAAM,CAAC;IACb;;OAEG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AAED;;;;;GAKG;AACH,MAAM,MAAM,0BAA0B,GAAG,CACvC,WAAW,EAAE,MAAM,EAAE,KAClB,KAAK,CAAC,iBAAiB,GAAG,MAAM,CAAC,CAAC;AAEvC;;;GAGG;AACH,MAAM,MAAM,kBAAkB,GAAG,KAAK,CAAC,iBAAiB,GAAG,MAAM,CAAC,GAAG,0BAA0B,CAAC;AAEhG;;;GAGG;AACH,MAAM,WAAW,2BAA2B;IAC1C,oBAAoB,EAAE,MAAM,EAAE,CAAC;IAC/B,kBAAkB,EAAE;QAAE,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAA;KAAE,CAAC;CAChD"}
@@ -3,6 +3,7 @@ import { NextApiRequest } from 'next';
3
3
  import { NextRequest } from 'next/server';
4
4
  import { IncomingHttpHeaders } from 'http';
5
5
  import { NativeDataFetcher } from '@sitecore-content-sdk/core';
6
+ import { AllowedQueryParams, GetAllowedQueryParamsResult } from './types';
6
7
  /**
7
8
  * Gets editing secret value from request
8
9
  * @param {NextApiRequest | NextRequest} req incoming request
@@ -19,6 +20,16 @@ export declare const mapEditingParams: (query: {
19
20
  }) => {
20
21
  [key: string]: string | undefined;
21
22
  };
23
+ /**
24
+ * Parses the query parameters based on the provided allowed parameters or a resolver function, to extract additional parameters that should be allowed.
25
+ * @param {{ [key: string]: string | undefined }} queryParams Object of query parameters from incoming URL.
26
+ * @param {AllowedQueryParams} allowedParams Allowed parameters to map.
27
+ * @returns Object containing the list of missing required parameters and the allowed query parameters that were extracted.
28
+ * @internal
29
+ */
30
+ export declare const getAllowedQueryParams: (queryParams: {
31
+ [key: string]: unknown;
32
+ }, allowedParams?: AllowedQueryParams) => GetAllowedQueryParamsResult;
22
33
  /**
23
34
  * Next.js preview cookies enum
24
35
  */
@@ -1 +1 @@
1
- {"version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AM,CAgDhB,CAAC;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,0BAA0B,GACrC,MAAM,OAAO,KACZ,IAAI,IAAI,8BAOV,CAAC;AAEF;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,gBAAgB,GAAI,KAAK,cAAc,GAAG,WAAW,WAmBjE,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,YAAY,cAIxB,CAAC"}
package/types/index.d.ts CHANGED
@@ -23,5 +23,5 @@ import * as BYOCWrapper from './components/BYOCWrapper';
23
23
  export { FEaaSClientWrapper, FEaaSServerWrapper, BYOCClientWrapper, BYOCServerWrapper, } from '@sitecore-content-sdk/react';
24
24
  export { FEaaSWrapper };
25
25
  export { BYOCWrapper };
26
- export { ComponentMap, Image, ImageField, ImageFieldValue, ImageProps, LinkField, LinkFieldValue, Text, TextField, DateField, FEaaSComponent, FEaaSComponentProps, FEaaSComponentParams, fetchFEaaSComponentServerProps, BYOCComponentParams, BYOCComponent, BYOCComponentProps, getDesignLibraryStylesheetLinks, File, FileField, RichTextField, DesignLibrary, DesignLibraryApp, DefaultEmptyFieldEditingComponentImage, DefaultEmptyFieldEditingComponentText, PlaceholderComponentProps, SitecoreProvider, SitecoreProviderState, SitecoreProviderReactContext, withSitecore, useSitecore, withEditorChromes, withPlaceholder, withDatasourceCheck, ImageSizeParameters, WithSitecoreOptions, WithSitecoreProps, WithSitecoreHocProps, withFieldMetadata, withEmptyFieldEditingComponent, EditingScripts, Form, ClientEditingChromesUpdate, AppPlaceholder, AppPlaceholderProps, renderEmptyPlaceholder, } from '@sitecore-content-sdk/react';
26
+ export { ComponentMap, Image, ImageField, ImageFieldValue, ImageProps, LinkField, LinkFieldValue, Text, TextField, DateField, FEaaSComponent, FEaaSComponentProps, FEaaSComponentParams, fetchFEaaSComponentServerProps, BYOCComponentParams, BYOCComponent, BYOCComponentProps, getDesignLibraryStylesheetLinks, File, FileField, RichTextField, DesignLibrary, DesignLibraryApp, DefaultEmptyFieldEditingComponentImage, DefaultEmptyFieldEditingComponentText, PlaceholderComponentProps, SitecoreProvider, SitecoreProviderState, SitecoreProviderReactContext, withSitecore, useSitecore, withEditorChromes, withAppPlaceholder, withPlaceholder, withDatasourceCheck, ImageSizeParameters, withFieldMetadata, withEmptyFieldEditingComponent, EditingScripts, Form, ClientEditingChromesUpdate, AppPlaceholder, AppPlaceholderProps, renderEmptyPlaceholder, } from '@sitecore-content-sdk/react';
27
27
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,KAAK,EAAE,MAAM,SAAS,CAAC;AAE3C,OAAO,EACL,SAAS,EAET,iBAAiB,EACjB,uBAAuB,EACvB,yBAAyB,EACzB,sBAAsB,EACtB,WAAW,EACX,WAAW,EACX,YAAY,EACZ,iBAAiB,GAClB,MAAM,4BAA4B,CAAC;AAEpC,OAAO,EAAE,QAAQ,EAAE,MAAM,+BAA+B,CAAC;AAEzD,OAAO,EACL,iBAAiB,EACjB,sBAAsB,EACtB,oBAAoB,EACpB,wBAAwB,EACxB,aAAa,EACb,mBAAmB,EACnB,eAAe,EACf,gBAAgB,EAChB,SAAS,EACT,KAAK,EACL,IAAI,EACJ,mBAAmB,EACnB,aAAa,EACb,kBAAkB,EAClB,eAAe,EACf,eAAe,EACf,wBAAwB,EACxB,QAAQ,EACR,aAAa,GACd,MAAM,sCAAsC,CAAC;AAC9C,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,IAAI,EAAE,MAAM,sCAAsC,CAAC;AACjF,OAAO,EAAE,sBAAsB,EAAE,MAAM,uCAAuC,CAAC;AAC/E,OAAO,EAAE,QAAQ,EAAE,MAAM,qCAAqC,CAAC;AAC/D,OAAO,EACL,iBAAiB,EACjB,iBAAiB,EACjB,uBAAuB,GACxB,MAAM,oCAAoC,CAAC;AAE5C,OAAO,EACL,iBAAiB,EACjB,sBAAsB,E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M,6BAA6B,CAAC;AACrC,OAAO,EAAE,YAAY,EAAE,CAAC;AACxB,OAAO,EAAE,WAAW,EAAE,CAAC;AAEvB,OAAO,EACL,YAAY,EACZ,KAAK,EACL,UAAU,EACV,eAAe,EACf,UAAU,EACV,SAAS,EACT,cAAc,EACd,IAAI,EACJ,SAAS,EACT,SAAS,EACT,cAAc,EACd,mBAAmB,EACnB,oBAAoB,EACpB,8BAA8B,EAC9B,mBAAmB,EACnB,aAAa,EACb,kBAAkB,EAClB,+BAA+B,EAC/B,IAAI,EACJ,SAAS,EACT,aAAa,EACb,aAAa,EACb,gBAAgB,EAChB,sCAAsC,EACtC,qCAAqC,EACrC,yBAAyB,EACzB,gBAAgB,EAChB,qBAAqB,EACrB,4BAA4B,EAC5B,YAAY,EACZ,WAAW,EACX,iBAAiB,EACjB,eAAe,EACf,mBAAmB,EACnB,mBAAmB,EACnB,mBAAmB,EACnB,iBAAiB,EACjB,oBAAoB,EACpB,iBAAiB,EACjB,8BAA8B,EAC9B,cAAc,EACd,IAAI,EACJ,0BAA0B,EAC1B,cAAc,EACd,mBAAmB,EACnB,sBAAsB,GACvB,MAAM,6BAA6B,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,KAAK,EAAE,MAAM,SAAS,CAAC;AAE3C,OAAO,EACL,SAAS,EAET,iBAAiB,EACjB,uBAAuB,EACvB,yBAAyB,EACzB,sBAAsB,EACtB,WAAW,EACX,WAAW,EACX,YAAY,EACZ,iBAAiB,GAClB,MAAM,4BAA4B,CAAC;AAEpC,OAAO,EAAE,QAAQ,EAAE,MAAM,+BAA+B,CAAC;AAEzD,OAAO,EACL,iBAAiB,EACjB,sBAAsB,EACtB,oBAAoB,EACpB,wBAAwB,EACxB,aAAa,EACb,mBAAmB,EACnB,eAAe,EACf,gBAAgB,EAChB,SAAS,EACT,KAAK,EACL,IAAI,EACJ,mBAAmB,EACn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M,oCAAoC,CAAC;AAE5C,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EAAE,QAAQ,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AAChE,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AACvD,OAAO,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AACnD,OAAO,KAAK,YAAY,MAAM,2BAA2B,CAAC;AAC1D,OAAO,KAAK,WAAW,MAAM,0BAA0B,CAAC;AACxD,OAAO,EACL,kBAAkB,EAClB,kBAAkB,EAClB,iBAAiB,EACjB,iBAAiB,GAClB,MAAM,6BAA6B,CAAC;AACrC,OAAO,EAAE,YAAY,EAAE,CAAC;AACxB,OAAO,EAAE,WAAW,EAAE,CAAC;AAEvB,OAAO,EACL,YAAY,EACZ,KAAK,EACL,UAAU,EACV,eAAe,EACf,UAAU,EACV,SAAS,EACT,cAAc,EACd,IAAI,EACJ,SAAS,EACT,SAAS,EACT,cAAc,EACd,mBAAmB,EACnB,oBAAoB,EACpB,8BAA8B,EAC9B,mBAAmB,EACnB,aAAa,EACb,kBAAkB,EAClB,+BAA+B,EAC/B,IAAI,EACJ,SAAS,EACT,aAAa,EACb,aAAa,EACb,gBAAgB,EAChB,sCAAsC,EACtC,qCAAqC,EACrC,yBAAyB,EACzB,gBAAgB,EAChB,qBAAqB,EACrB,4BAA4B,EAC5B,YAAY,EACZ,WAAW,EACX,iBAAiB,EACjB,kBAAkB,EAClB,eAAe,EACf,mBAAmB,EACnB,mBAAmB,EACnB,iBAAiB,EACjB,8BAA8B,EAC9B,cAAc,EACd,IAAI,EACJ,0BAA0B,EAC1B,cAAc,EACd,mBAAmB,EACnB,sBAAsB,GACvB,MAAM,6BAA6B,CAAC"}
@@ -1,5 +1,5 @@
1
1
  import { NextRequest } from 'next/server';
2
- import { Metadata } from '@sitecore-content-sdk/core/tools';
2
+ import { Metadata } from '@sitecore-content-sdk/core/node-tools';
3
3
  import { ComponentMap } from '@sitecore-content-sdk/react';
4
4
  import { NextjsContentSdkComponent } from '../sharedTypes/component-props';
5
5
  export type EditingConfigRouteHandlerOptions = {
@@ -1 +1 @@
1
- {"version":3,"file":"editing-config-route-handler.d.ts","sourceRoot":"","sources":["../../src/route-handler/editing-config-route-handler.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAK1C,OAAO,EAAE,QAAQ,EAAE,MAAM,kCAAkC,CAAC;AAI5D,OAAO,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAC3D,OAAO,EAAE,yBAAyB,EAAE,MAAM,gCAAgC,CAAC;AAG3E,MAAM,MAAM,gCAAgC,GAAG;IAC7C;;OAEG;IACH,UAAU,EAAE,YAAY,CAAC,yBAAyB,CAAC,CAAC;IACpD;;OAEG;IACH,QAAQ,EAAE,QAAQ,CAAC;IACnB;;OAEG;IACH,gBAAgB,CAAC,EAAE,YAAY,CAAC,yBAAyB,CAAC,CAAC;CAC5D,CAAC;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,+BAA+B,GAAI,SAAS,gCAAgC;eAe/D,WAAW;mBAkEP,WAAW;CAkCxC,CAAC"}
1
+ {"version":3,"file":"editing-config-route-handler.d.ts","sourceRoot":"","sources":["../../src/route-handler/editing-config-route-handler.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAK1C,OAAO,EAAE,QAAQ,EAAE,MAAM,uCAAuC,CAAC;AAIjE,OAAO,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAC3D,OAAO,EAAE,yBAAyB,EAAE,MAAM,gCAAgC,CAAC;AAG3E,MAAM,MAAM,gCAAgC,GAAG;IAC7C;;OAEG;IACH,UAAU,EAAE,YAAY,CAAC,yBAAyB,CAAC,CAAC;IACpD;;OAEG;IACH,QAAQ,EAAE,QAAQ,CAAC;IACnB;;OAEG;IACH,gBAAgB,CAAC,EAAE,YAAY,CAAC,yBAAyB,CAAC,CAAC;CAC5D,CAAC;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,+BAA+B,GAAI,SAAS,gCAAgC;eAe/D,WAAW;mBAkEP,WAAW;CAkCxC,CAAC"}
@@ -1,4 +1,5 @@
1
1
  import { NextRequest } from 'next/server';
2
+ import type { AllowedQueryParams } from '../editing/types';
2
3
  /**
3
4
  * Helper function to handle cookie operations - can be mocked for testing
4
5
  * @returns {Promise<NextCookies>} Next cookies
@@ -17,6 +18,12 @@ type EditingHandlerOptions = {
17
18
  * The internal host URL for the Next.js application, used for server-side requests for page rendering during editing.
18
19
  */
19
20
  sitecoreInternalEditingHostUrl?: string;
21
+ /**
22
+ * Query string parameters to allow and include in the search params.
23
+ * - Array: each item is a parameter name (string) or an object `{ name, required? }`.
24
+ * - Function: receives the request's query parameter names and returns the list of allowed parameters.
25
+ */
26
+ allowedQueryParams?: AllowedQueryParams;
20
27
  };
21
28
  /**
22
29
  * Creates a route handler for the editing render API route (e.g. '/api/editing/render')
@@ -1 +1 @@
1
- {"version":3,"file":"editing-render-route-handler.d.ts","sourceRoot":"","sources":["../../src/route-handler/editing-render-route-handler.ts"],"names":[],"mappings":"AAUA,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAiB1C;;;GAGG;AACH,wBAAsB,cAAc,iBAMnC;AAED,KAAK,qBAAqB,GAAG;IAC3B;;;;;;OAMG;IACH,cAAc,CAAC,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,MAAM,CAAC;IAC9C;;OAEG;IACH,8BAA8B,CAAC,EAAE,MAAM,CAAC;CACzC,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,gCAAgC,GAAI,SAAS,qBAAqB;eAwDrD,WAAW;gBAyJV,WAAW;mBA3Kd,WAAW;CAqRlC,CAAC"}
1
+ {"version":3,"file":"editing-render-route-handler.d.ts","sourceRoot":"","sources":["../../src/route-handler/editing-render-route-handler.ts"],"names":[],"mappings":"AAUA,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAiB1C,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AAE3D;;;GAGG;AACH,wBAAsB,cAAc,iBAMnC;AAED,KAAK,qBAAqB,GAAG;IAC3B;;;;;;OAMG;IACH,cAAc,CAAC,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,MAAM,CAAC;IAC9C;;OAEG;IACH,8BAA8B,CAAC,EAAE,MAAM,CAAC;IACxC;;;;OAIG;IACH,kBAAkB,CAAC,EAAE,kBAAkB,CAAC;CACzC,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,gCAAgC,GAAI,SAAS,qBAAqB;eAwDrD,WAAW;gBAiKV,WAAW;mBAnLd,WAAW;CAgSlC,CAAC"}
@@ -1,4 +1,4 @@
1
- import { WriteImportMapArgs } from '@sitecore-content-sdk/content/tools';
1
+ import { WriteImportMapArgs } from '@sitecore-content-sdk/content/node-tools';
2
2
  export declare const __mockDependencies: (mocks: any) => void;
3
3
  /**
4
4
  * Entry point function for generating import-map. Parses provided paths and outputs the modules and imports from those files into .sitecore/import-map.ts
@@ -1 +1 @@
1
- {"version":3,"file":"import-map.d.ts","sourceRoot":"","sources":["../../../src/tools/codegen/import-map.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,kBAAkB,EACnB,MAAM,qCAAqC,CAAC;AAU7C,eAAO,MAAM,kBAAkB,GAAI,OAAO,GAAG,SAI5C,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,cAAc,GAAI,MAAM,kBAAkB;;mBAQtD,CAAC"}
1
+ {"version":3,"file":"import-map.d.ts","sourceRoot":"","sources":["../../../src/tools/codegen/import-map.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,kBAAkB,EACnB,MAAM,0CAA0C,CAAC;AAUlD,eAAO,MAAM,kBAAkB,GAAI,OAAO,GAAG,SAI5C,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,cAAc,GAAI,MAAM,kBAAkB;;mBAQtD,CAAC"}
@@ -1,5 +1,6 @@
1
- export { generateSites, GenerateSitesConfig, ComponentFile, ComponentImport, getComponentList, GenerateMapArgs, extractFiles, } from '@sitecore-content-sdk/content/tools';
2
- export { generateMetadata } from '@sitecore-content-sdk/core/tools';
1
+ export { ComponentFile, ComponentImport, GenerateMapArgs, } from '@sitecore-content-sdk/content/tools';
2
+ export { generateSites, GenerateSitesConfig, getComponentList, extractFiles, } from '@sitecore-content-sdk/content/node-tools';
3
+ export { generateMetadata } from '@sitecore-content-sdk/core/node-tools';
3
4
  export { generateMap } from './generate-map';
4
5
  export { writeImportMap } from './codegen/import-map';
5
6
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/tools/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,aAAa,EACb,mBAAmB,EACnB,aAAa,EACb,eAAe,EACf,gBAAgB,EAChB,eAAe,EACf,YAAY,GACb,MAAM,qCAAqC,CAAC;AAE7C,OAAO,EAAE,gBAAgB,EAAE,MAAM,kCAAkC,CAAC;AAEpE,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAC7C,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/tools/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,aAAa,EACb,eAAe,EACf,eAAe,GAChB,MAAM,qCAAqC,CAAC;AAC7C,OAAO,EACL,aAAa,EACb,mBAAmB,EACnB,gBAAgB,EAChB,YAAY,GACb,MAAM,0CAA0C,CAAC;AAElD,OAAO,EAAE,gBAAgB,EAAE,MAAM,uCAAuC,CAAC;AAEzE,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAC7C,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC"}
@@ -1,5 +1,5 @@
1
1
  import { ComponentFileWithType, ComponentType, RouterType } from '@sitecore-content-sdk/content/tools';
2
- import { ModuleExports } from '@sitecore-content-sdk/content/tools';
2
+ import { ModuleExports } from '@sitecore-content-sdk/content/node-tools';
3
3
  /**
4
4
  * Detects the Next.js router type (App Router or Pages Router) based on directory structure.
5
5
  * @param {string} projectRoot - The project root directory. Defaults to current working directory.
@@ -1 +1 @@
1
- {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/tools/templating/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,qBAAqB,EACrB,aAAa,EAEb,UAAU,EACX,MAAM,qCAAqC,CAAC;AAG7C,OAAO,EAA4B,aAAa,EAAE,MAAM,qCAAqC,CAAC;AAE9F;;;;;GAKG;AACH,wBAAgB,gBAAgB,CAAC,WAAW,GAAE,MAAsB,GAAG,UAAU,CAehF;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,mBAAmB,CAAC,QAAQ,EAAE,MAAM,EAAE,UAAU,CAAC,EAAE,UAAU,GAAG,aAAa,CA0J5F;AAED;;;;;;;;GAQG;AACH,wBAAgB,yBAAyB,CACvC,KAAK,EAAE,MAAM,EAAE,EACf,OAAO,CAAC,EAAE,MAAM,EAAE,EAClB,eAAe,CAAC,EAAE,OAAO,EACzB,UAAU,CAAC,EAAE,UAAU,GACtB,qBAAqB,EAAE,CAQzB;AAED;;;;GAIG;AACH,wBAAgB,uBAAuB,CAAC,gBAAgB,EAAE,GAAG,CAAC,MAAM,EAAE,aAAa,CAAC,UAGnF;AAED;;;;GAIG;AACH,wBAAgB,wBAAwB,CAAC,gBAAgB,EAAE,GAAG,CAAC,MAAM,EAAE,aAAa,CAAC,UAEpF;AAED;;;;GAIG;AACH,wBAAgB,wBAAwB,CAAC,gBAAgB,EAAE,GAAG,CAAC,MAAM,EAAE,aAAa,CAAC,UAEpF"}
1
+ {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/tools/templating/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,qBAAq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