@sitecore-jss/sitecore-jss-nextjs 22.4.0-canary.8 → 22.4.0
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/LICENSE.txt +202 -202
- package/README.md +11 -11
- package/dist/cjs/editing/editing-data-service.js +1 -1
- package/dist/cjs/editing/editing-render-middleware.js +21 -58
- package/dist/cjs/editing/index.js +1 -6
- package/dist/cjs/editing/render-middleware.js +8 -6
- package/dist/cjs/index.js +2 -6
- package/dist/cjs/middleware/redirects-middleware.js +52 -120
- package/dist/esm/editing/editing-data-service.js +2 -2
- package/dist/esm/editing/editing-render-middleware.js +22 -58
- package/dist/esm/editing/index.js +1 -2
- package/dist/esm/editing/render-middleware.js +8 -6
- package/dist/esm/index.js +2 -3
- package/dist/esm/middleware/redirects-middleware.js +53 -121
- package/package.json +5 -5
- package/types/editing/editing-data-service.d.ts +5 -5
- package/types/editing/editing-render-middleware.d.ts +7 -28
- package/types/editing/index.d.ts +1 -2
- package/types/editing/render-middleware.d.ts +1 -1
- package/types/index.d.ts +2 -3
- package/types/middleware/redirects-middleware.d.ts +0 -21
|
@@ -9,7 +9,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
9
9
|
};
|
|
10
10
|
import { debug } from '@sitecore-jss/sitecore-jss';
|
|
11
11
|
import { GraphQLRedirectsService, REDIRECT_TYPE_301, REDIRECT_TYPE_302, REDIRECT_TYPE_SERVER_TRANSFER, } from '@sitecore-jss/sitecore-jss/site';
|
|
12
|
-
import {
|
|
12
|
+
import { areURLSearchParamsEqual, escapeNonSpecialQuestionMarks, isRegexOrUrl, mergeURLSearchParams, } from '@sitecore-jss/sitecore-jss/utils';
|
|
13
13
|
import { NextResponse } from 'next/server';
|
|
14
14
|
import regexParser from 'regex-parser';
|
|
15
15
|
import { MiddlewareBase } from './middleware';
|
|
@@ -39,20 +39,28 @@ export class RedirectsMiddleware extends MiddlewareBase {
|
|
|
39
39
|
});
|
|
40
40
|
const createResponse = () => __awaiter(this, void 0, void 0, function* () {
|
|
41
41
|
var _a;
|
|
42
|
+
const response = res || NextResponse.next();
|
|
42
43
|
if (this.config.disabled && this.config.disabled(req, res || NextResponse.next())) {
|
|
43
44
|
debug.redirects('skipped (redirects middleware is disabled)');
|
|
44
|
-
return
|
|
45
|
+
return response;
|
|
45
46
|
}
|
|
46
47
|
if (this.isPreview(req) || this.excludeRoute(pathname)) {
|
|
47
48
|
debug.redirects('skipped (%s)', this.isPreview(req) ? 'preview' : 'route excluded');
|
|
48
|
-
return
|
|
49
|
+
return response;
|
|
50
|
+
}
|
|
51
|
+
// Skip prefetch requests from Next.js, which are not original client requests
|
|
52
|
+
// as they load unnecessary requests that burden the redirects middleware with meaningless traffic
|
|
53
|
+
if (this.isPrefetch(req)) {
|
|
54
|
+
debug.redirects('skipped (prefetch)');
|
|
55
|
+
response.headers.set('x-middleware-cache', 'no-cache');
|
|
56
|
+
return response;
|
|
49
57
|
}
|
|
50
58
|
site = this.getSite(req, res);
|
|
51
59
|
// Find the redirect from result of RedirectService
|
|
52
60
|
const existsRedirect = yield this.getExistsRedirect(req, site.name);
|
|
53
61
|
if (!existsRedirect) {
|
|
54
62
|
debug.redirects('skipped (redirect does not exist)');
|
|
55
|
-
return
|
|
63
|
+
return response;
|
|
56
64
|
}
|
|
57
65
|
// Find context site language and replace token
|
|
58
66
|
if (REGEXP_CONTEXT_SITE_LANG.test(existsRedirect.target) &&
|
|
@@ -66,27 +74,26 @@ export class RedirectsMiddleware extends MiddlewareBase {
|
|
|
66
74
|
url.href = existsRedirect.target;
|
|
67
75
|
}
|
|
68
76
|
else {
|
|
69
|
-
const
|
|
70
|
-
const
|
|
77
|
+
const isUrl = isRegexOrUrl(existsRedirect.pattern) === 'url';
|
|
78
|
+
const targetParts = existsRedirect.target.split('/');
|
|
79
|
+
const urlFirstPart = targetParts[1];
|
|
71
80
|
if (this.locales.includes(urlFirstPart)) {
|
|
72
81
|
req.nextUrl.locale = urlFirstPart;
|
|
73
82
|
existsRedirect.target = existsRedirect.target.replace(`/${urlFirstPart}`, '');
|
|
74
83
|
}
|
|
75
|
-
const
|
|
76
|
-
|
|
77
|
-
.replace(
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
}
|
|
89
|
-
const prepareNewURL = new URL(`${target[0]}${url.search}`, url.origin);
|
|
84
|
+
const targetSegments = isUrl
|
|
85
|
+
? existsRedirect.target.split('?')
|
|
86
|
+
: url.pathname.replace(/\/*$/gi, '') + existsRedirect.matchedQueryString;
|
|
87
|
+
const [targetPath, targetQueryString] = isUrl
|
|
88
|
+
? targetSegments
|
|
89
|
+
: targetSegments
|
|
90
|
+
.replace(regexParser(existsRedirect.pattern), existsRedirect.target)
|
|
91
|
+
.replace(/^\/\//, '/')
|
|
92
|
+
.split('?');
|
|
93
|
+
const mergedQueryString = existsRedirect.isQueryStringPreserved
|
|
94
|
+
? mergeURLSearchParams(new URLSearchParams((_a = url.search) !== null && _a !== void 0 ? _a : ''), new URLSearchParams(targetQueryString || ''))
|
|
95
|
+
: targetQueryString || '';
|
|
96
|
+
const prepareNewURL = new URL(`${targetPath}${mergedQueryString ? '?' + mergedQueryString : ''}`, url.origin);
|
|
90
97
|
url.href = prepareNewURL.href;
|
|
91
98
|
url.pathname = prepareNewURL.pathname;
|
|
92
99
|
url.search = prepareNewURL.search;
|
|
@@ -95,16 +102,16 @@ export class RedirectsMiddleware extends MiddlewareBase {
|
|
|
95
102
|
/** return Response redirect with http code of redirect type */
|
|
96
103
|
switch (existsRedirect.redirectType) {
|
|
97
104
|
case REDIRECT_TYPE_301: {
|
|
98
|
-
return this.createRedirectResponse(url,
|
|
105
|
+
return this.createRedirectResponse(url, response, 301, 'Moved Permanently');
|
|
99
106
|
}
|
|
100
107
|
case REDIRECT_TYPE_302: {
|
|
101
|
-
return this.createRedirectResponse(url,
|
|
108
|
+
return this.createRedirectResponse(url, response, 302, 'Found');
|
|
102
109
|
}
|
|
103
110
|
case REDIRECT_TYPE_SERVER_TRANSFER: {
|
|
104
|
-
return this.rewrite(url.href, req,
|
|
111
|
+
return this.rewrite(url.href, req, response);
|
|
105
112
|
}
|
|
106
113
|
default:
|
|
107
|
-
return
|
|
114
|
+
return response;
|
|
108
115
|
}
|
|
109
116
|
});
|
|
110
117
|
const response = yield createResponse();
|
|
@@ -146,59 +153,43 @@ export class RedirectsMiddleware extends MiddlewareBase {
|
|
|
146
153
|
*/
|
|
147
154
|
getExistsRedirect(req, siteName) {
|
|
148
155
|
return __awaiter(this, void 0, void 0, function* () {
|
|
149
|
-
const redirects = yield this.redirectsService.fetchRedirects(siteName);
|
|
150
156
|
const { pathname: targetURL, search: targetQS = '', locale } = this.normalizeUrl(req.nextUrl.clone());
|
|
157
|
+
const normalizedPath = targetURL.replace(/\/*$/gi, '');
|
|
158
|
+
const redirects = yield this.redirectsService.fetchRedirects(siteName);
|
|
151
159
|
const language = this.getLanguage(req);
|
|
152
160
|
const modifyRedirects = structuredClone(redirects);
|
|
161
|
+
let matchedQueryString;
|
|
153
162
|
return modifyRedirects.length
|
|
154
163
|
? modifyRedirects.find((redirect) => {
|
|
164
|
+
var _a;
|
|
165
|
+
if (isRegexOrUrl(redirect.pattern) === 'url') {
|
|
166
|
+
const parseUrlPattern = redirect.pattern.endsWith('/')
|
|
167
|
+
? redirect.pattern.slice(0, -1).split('?')
|
|
168
|
+
: redirect.pattern.split('?');
|
|
169
|
+
return ((parseUrlPattern[0] === normalizedPath ||
|
|
170
|
+
parseUrlPattern[0] === `/${locale}${normalizedPath}`) &&
|
|
171
|
+
areURLSearchParamsEqual(new URLSearchParams((_a = parseUrlPattern[1]) !== null && _a !== void 0 ? _a : ''), new URLSearchParams(targetQS)));
|
|
172
|
+
}
|
|
155
173
|
// Modify the redirect pattern to ignore the language prefix in the path
|
|
156
174
|
// And escapes non-special "?" characters in a string or regex.
|
|
157
|
-
redirect.pattern =
|
|
175
|
+
redirect.pattern = escapeNonSpecialQuestionMarks(redirect.pattern.replace(new RegExp(`^[^]?/${language}/`, 'gi'), ''));
|
|
158
176
|
// Prepare the redirect pattern as a regular expression, making it more flexible for matching URLs
|
|
159
177
|
redirect.pattern = `/^\/${redirect.pattern
|
|
160
178
|
.replace(/^\/|\/$/g, '') // Removes leading and trailing slashes
|
|
161
179
|
.replace(/^\^\/|\/\$$/g, '') // Removes unnecessary start (^) and end ($) anchors
|
|
162
180
|
.replace(/^\^|\$$/g, '') // Further cleans up anchors
|
|
163
181
|
.replace(/\$\/gi$/g, '')}[\/]?$/i`; // Ensures the pattern allows an optional trailing slash
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
* To account for this, the method `isPermutedQueryMatch` generates all possible permutations
|
|
171
|
-
* of the query parameters and checks if any of those permutations match the regex pattern for the redirect.
|
|
172
|
-
*
|
|
173
|
-
* NOTE: This fix is specifically implemented for Netlify, where query parameters are sometimes
|
|
174
|
-
* automatically sorted, which can cause issues with matching redirects if the order of query
|
|
175
|
-
* parameters is important. By checking every possible permutation, we ensure that redirects
|
|
176
|
-
* work correctly on Netlify despite this behavior.
|
|
177
|
-
*
|
|
178
|
-
* It passes several pieces of information to the function:
|
|
179
|
-
* 1. `pathname`: The normalized URL path without query parameters (e.g., '/about').
|
|
180
|
-
* 2. `queryString`: The current query string from the URL, which will be permuted and matched (e.g., '?key1=value1&key2=value2').
|
|
181
|
-
* 3. `pattern`: The regex pattern for the redirect that we are trying to match against the URL (e.g., '/about?key1=value1').
|
|
182
|
-
* 4. `locale`: The locale part of the URL (if any), which helps support multilingual URLs.
|
|
183
|
-
*
|
|
184
|
-
* If one of the permutations of the query string matches the redirect pattern, the function
|
|
185
|
-
* returns the matched query string, which is stored in `matchedQueryString`. If no match is found,
|
|
186
|
-
* it returns `undefined`. The `matchedQueryString` is later used to indicate whether the query
|
|
187
|
-
* string contributed to a successful redirect match.
|
|
188
|
-
*/
|
|
189
|
-
const matchedQueryString = this.isPermutedQueryMatch({
|
|
190
|
-
pathname: targetURL,
|
|
191
|
-
queryString: targetQS,
|
|
192
|
-
pattern: redirect.pattern,
|
|
193
|
-
locale,
|
|
194
|
-
});
|
|
182
|
+
matchedQueryString = [
|
|
183
|
+
regexParser(redirect.pattern).test(`${normalizedPath}${targetQS}`),
|
|
184
|
+
regexParser(redirect.pattern).test(`/${locale}${normalizedPath}${targetQS}`),
|
|
185
|
+
].some(Boolean)
|
|
186
|
+
? targetQS
|
|
187
|
+
: undefined;
|
|
195
188
|
// Save the matched query string (if found) into the redirect object
|
|
196
189
|
redirect.matchedQueryString = matchedQueryString || '';
|
|
197
|
-
|
|
198
|
-
return ((regexParser(redirect.pattern).test(targetURL) ||
|
|
190
|
+
return (!!(regexParser(redirect.pattern).test(targetURL) ||
|
|
199
191
|
regexParser(redirect.pattern).test(`/${req.nextUrl.locale}${targetURL}`) ||
|
|
200
|
-
matchedQueryString) &&
|
|
201
|
-
(redirect.locale ? redirect.locale.toLowerCase() === locale.toLowerCase() : true));
|
|
192
|
+
matchedQueryString) && (redirect.locale ? redirect.locale.toLowerCase() === locale.toLowerCase() : true));
|
|
202
193
|
})
|
|
203
194
|
: undefined;
|
|
204
195
|
});
|
|
@@ -263,63 +254,4 @@ export class RedirectsMiddleware extends MiddlewareBase {
|
|
|
263
254
|
}
|
|
264
255
|
return redirect;
|
|
265
256
|
}
|
|
266
|
-
/**
|
|
267
|
-
* Checks if the current URL query matches the provided pattern, considering all permutations of query parameters.
|
|
268
|
-
* It constructs all possible query parameter permutations and tests them against the pattern.
|
|
269
|
-
* @param {object} params - The parameters for the URL match.
|
|
270
|
-
* @param {string} params.pathname - The current URL pathname.
|
|
271
|
-
* @param {string} params.queryString - The current URL query string.
|
|
272
|
-
* @param {string} params.pattern - The regex pattern to test the constructed URLs against.
|
|
273
|
-
* @param {string} [params.locale] - The locale prefix to include in the URL if present.
|
|
274
|
-
* @returns {string | undefined} - return query string if any of the query permutations match the provided pattern, undefined otherwise.
|
|
275
|
-
*/
|
|
276
|
-
isPermutedQueryMatch({ pathname, queryString, pattern, locale, }) {
|
|
277
|
-
const paramsArray = Array.from(new URLSearchParams(queryString).entries());
|
|
278
|
-
const listOfPermuted = getPermutations(paramsArray).map((permutation) => '?' + permutation.map(([key, value]) => `${key}=${value}`).join('&'));
|
|
279
|
-
const normalizedPath = pathname.replace(/\/*$/gi, '');
|
|
280
|
-
return listOfPermuted.find((query) => [
|
|
281
|
-
regexParser(pattern).test(`${normalizedPath}${query}`),
|
|
282
|
-
regexParser(pattern).test(`/${locale}${normalizedPath}${query}`),
|
|
283
|
-
].some(Boolean));
|
|
284
|
-
}
|
|
285
|
-
/**
|
|
286
|
-
* Escapes non-special "?" characters in a string or regex.
|
|
287
|
-
*
|
|
288
|
-
* - For regular strings, it escapes all unescaped "?" characters by adding a backslash (`\`).
|
|
289
|
-
* - For regex patterns (strings enclosed in `/.../`), it analyzes each "?" to determine if it has special meaning
|
|
290
|
-
* (e.g., `?` in `(abc)?`, `.*?`) or is just a literal character. Only literal "?" characters are escaped.
|
|
291
|
-
* @param {string} input - The input string or regex pattern.
|
|
292
|
-
* @returns {string} - The modified string or regex with non-special "?" characters escaped.
|
|
293
|
-
**/
|
|
294
|
-
escapeNonSpecialQuestionMarks(input) {
|
|
295
|
-
const regexPattern = /(?<!\\)\?/g; // Find unescaped "?" characters
|
|
296
|
-
const isRegex = input.startsWith('/') && input.endsWith('/'); // Check if the string is a regex
|
|
297
|
-
if (!isRegex) {
|
|
298
|
-
// If not a regex, escape all unescaped "?" characters
|
|
299
|
-
return input.replace(regexPattern, '\\?');
|
|
300
|
-
}
|
|
301
|
-
// If it's a regex, analyze each "?" character
|
|
302
|
-
let result = '';
|
|
303
|
-
let lastIndex = 0;
|
|
304
|
-
let match;
|
|
305
|
-
while ((match = regexPattern.exec(input)) !== null) {
|
|
306
|
-
const index = match.index; // Position of "?" in the string
|
|
307
|
-
const before = input.slice(0, index).replace(/\s+$/, ''); // Context before "?"
|
|
308
|
-
const lastChar = before.slice(-1); // Last character before "?"
|
|
309
|
-
// Determine if the "?" is a special regex symbol
|
|
310
|
-
const isSpecialRegexSymbol = /[\.\*\+\)\[\]]$/.test(lastChar);
|
|
311
|
-
if (isSpecialRegexSymbol) {
|
|
312
|
-
// If it's special, keep it as is
|
|
313
|
-
result += input.slice(lastIndex, index + 1);
|
|
314
|
-
}
|
|
315
|
-
else {
|
|
316
|
-
// If it's not special, escape it
|
|
317
|
-
result += input.slice(lastIndex, index) + '\\?';
|
|
318
|
-
}
|
|
319
|
-
lastIndex = index + 1;
|
|
320
|
-
}
|
|
321
|
-
// Append the remaining part of the string
|
|
322
|
-
result += input.slice(lastIndex);
|
|
323
|
-
return result;
|
|
324
|
-
}
|
|
325
257
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sitecore-jss/sitecore-jss-nextjs",
|
|
3
|
-
"version": "22.4.0
|
|
3
|
+
"version": "22.4.0",
|
|
4
4
|
"main": "dist/cjs/index.js",
|
|
5
5
|
"module": "dist/esm/index.js",
|
|
6
6
|
"sideEffects": false,
|
|
@@ -73,9 +73,9 @@
|
|
|
73
73
|
"react-dom": "^18.2.0"
|
|
74
74
|
},
|
|
75
75
|
"dependencies": {
|
|
76
|
-
"@sitecore-jss/sitecore-jss": "
|
|
77
|
-
"@sitecore-jss/sitecore-jss-dev-tools": "
|
|
78
|
-
"@sitecore-jss/sitecore-jss-react": "
|
|
76
|
+
"@sitecore-jss/sitecore-jss": "22.4.0",
|
|
77
|
+
"@sitecore-jss/sitecore-jss-dev-tools": "22.4.0",
|
|
78
|
+
"@sitecore-jss/sitecore-jss-react": "22.4.0",
|
|
79
79
|
"@vercel/kv": "^0.2.1",
|
|
80
80
|
"prop-types": "^15.8.1",
|
|
81
81
|
"regex-parser": "^2.2.11",
|
|
@@ -83,7 +83,7 @@
|
|
|
83
83
|
},
|
|
84
84
|
"description": "",
|
|
85
85
|
"types": "types/index.d.ts",
|
|
86
|
-
"gitHead": "
|
|
86
|
+
"gitHead": "775a85600b541df7bcffd0e4056154ee6d068992",
|
|
87
87
|
"files": [
|
|
88
88
|
"dist",
|
|
89
89
|
"types",
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { NativeDataFetcher } from '@sitecore-jss/sitecore-jss';
|
|
2
2
|
import { EditingData } from './editing-data';
|
|
3
3
|
import { EditingDataCache } from './editing-data-cache';
|
|
4
4
|
import { PreviewData } from 'next';
|
|
@@ -87,11 +87,11 @@ export interface ServerlessEditingDataServiceConfig {
|
|
|
87
87
|
*/
|
|
88
88
|
apiRoute?: string;
|
|
89
89
|
/**
|
|
90
|
-
* The `
|
|
91
|
-
* @default new
|
|
92
|
-
* @see
|
|
90
|
+
* The `NativeDataFetcher` instance to use for API requests.
|
|
91
|
+
* @default new NativeDataFetcher()
|
|
92
|
+
* @see NativeDataFetcher
|
|
93
93
|
*/
|
|
94
|
-
dataFetcher?:
|
|
94
|
+
dataFetcher?: NativeDataFetcher;
|
|
95
95
|
}
|
|
96
96
|
/**
|
|
97
97
|
* Service responsible for maintaining Sitecore editor data between requests
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { NextApiRequest, NextApiResponse } from 'next';
|
|
2
|
-
import {
|
|
2
|
+
import { NativeDataFetcher } from '@sitecore-jss/sitecore-jss';
|
|
3
3
|
import { EditMode, LayoutServicePageState } from '@sitecore-jss/sitecore-jss/layout';
|
|
4
4
|
import { RenderMetadataQueryParams, LayoutKind } from '@sitecore-jss/sitecore-jss/editing';
|
|
5
5
|
import { EditingDataService } from './editing-data-service';
|
|
@@ -11,11 +11,11 @@ export type EditingRenderMiddlewareConfig = {
|
|
|
11
11
|
/**
|
|
12
12
|
* -- Edit Mode Chromes --
|
|
13
13
|
*
|
|
14
|
-
* The `
|
|
15
|
-
* @default new
|
|
16
|
-
* @see
|
|
14
|
+
* The `NativeDataFetcher` instance to use for API requests.
|
|
15
|
+
* @default new NativeDataFetcher()
|
|
16
|
+
* @see NativeDataFetcher
|
|
17
17
|
*/
|
|
18
|
-
dataFetcher?:
|
|
18
|
+
dataFetcher?: NativeDataFetcher;
|
|
19
19
|
/**
|
|
20
20
|
* -- Edit Mode Chromes --
|
|
21
21
|
*
|
|
@@ -99,7 +99,7 @@ export type EditingRenderMiddlewareMetadataConfig = Pick<EditingRenderMiddleware
|
|
|
99
99
|
/**
|
|
100
100
|
* Next.js API request with Metadata query parameters.
|
|
101
101
|
*/
|
|
102
|
-
|
|
102
|
+
type MetadataNextApiRequest = NextApiRequest & {
|
|
103
103
|
query: RenderMetadataQueryParams;
|
|
104
104
|
};
|
|
105
105
|
/**
|
|
@@ -115,21 +115,6 @@ export type EditingMetadataPreviewData = {
|
|
|
115
115
|
version?: string;
|
|
116
116
|
layoutKind?: LayoutKind;
|
|
117
117
|
};
|
|
118
|
-
/**
|
|
119
|
-
* Data for Component Library rendering mode
|
|
120
|
-
*/
|
|
121
|
-
export interface ComponentLibraryRenderPreviewData {
|
|
122
|
-
site: string;
|
|
123
|
-
itemId: string;
|
|
124
|
-
renderingId: string;
|
|
125
|
-
componentUid: string;
|
|
126
|
-
language: string;
|
|
127
|
-
pageState: LayoutServicePageState;
|
|
128
|
-
mode?: 'library';
|
|
129
|
-
variant?: string;
|
|
130
|
-
version?: string;
|
|
131
|
-
dataSourceId?: string;
|
|
132
|
-
}
|
|
133
118
|
/**
|
|
134
119
|
* Type guard for EditingMetadataPreviewData
|
|
135
120
|
* @param {object} data preview data to check
|
|
@@ -137,13 +122,6 @@ export interface ComponentLibraryRenderPreviewData {
|
|
|
137
122
|
* @see EditingMetadataPreviewData
|
|
138
123
|
*/
|
|
139
124
|
export declare const isEditingMetadataPreviewData: (data: unknown) => data is EditingMetadataPreviewData;
|
|
140
|
-
/**
|
|
141
|
-
* Type guard for Component Library mode
|
|
142
|
-
* @param {object} data preview data to check
|
|
143
|
-
* @returns true if the data is EditingMetadataPreviewData
|
|
144
|
-
* @see EditingMetadataPreviewData
|
|
145
|
-
*/
|
|
146
|
-
export declare const isComponentLibraryPreviewData: (data: unknown) => data is ComponentLibraryRenderPreviewData;
|
|
147
125
|
/**
|
|
148
126
|
* Handler for the Editing Metadata GET requests.
|
|
149
127
|
* This handler is responsible for redirecting the request to the page route.
|
|
@@ -176,3 +154,4 @@ export declare class EditingRenderMiddleware extends RenderMiddlewareBase {
|
|
|
176
154
|
getHandler(): (req: NextApiRequest, res: NextApiResponse) => Promise<void>;
|
|
177
155
|
private handler;
|
|
178
156
|
}
|
|
157
|
+
export {};
|
package/types/editing/index.d.ts
CHANGED
|
@@ -2,9 +2,8 @@ export { GraphQLEditingService } from '@sitecore-jss/sitecore-jss/editing';
|
|
|
2
2
|
export { EditingData } from './editing-data';
|
|
3
3
|
export { EditingDataCache, EditingDataDiskCache } from './editing-data-cache';
|
|
4
4
|
export { EditingDataMiddleware, EditingDataMiddlewareConfig } from './editing-data-middleware';
|
|
5
|
-
export { EditingRenderMiddleware, EditingRenderMiddlewareConfig, EditingMetadataPreviewData, isEditingMetadataPreviewData,
|
|
5
|
+
export { EditingRenderMiddleware, EditingRenderMiddlewareConfig, EditingMetadataPreviewData, isEditingMetadataPreviewData, } from './editing-render-middleware';
|
|
6
6
|
export { EditingPreviewData, EditingDataService, BasicEditingDataService, BasicEditingDataServiceConfig, ServerlessEditingDataService, ServerlessEditingDataServiceConfig, editingDataService, } from './editing-data-service';
|
|
7
7
|
export { VercelEditingDataCache } from './vercel-editing-data-cache';
|
|
8
8
|
export { FEAASRenderMiddleware, FEAASRenderMiddlewareConfig } from './feaas-render-middleware';
|
|
9
9
|
export { EditingConfigMiddleware, EditingConfigMiddlewareConfig, } from './editing-config-middleware';
|
|
10
|
-
export { RenderingType, EDITING_COMPONENT_PLACEHOLDER, EDITING_COMPONENT_ID, } from '@sitecore-jss/sitecore-jss/layout';
|
package/types/index.d.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
export { constants, HttpDataFetcher,
|
|
1
|
+
export { constants, HttpDataFetcher, NativeDataFetcher, NativeDataFetcherConfig, NativeDataFetcherResponse, NativeDataFetcherError, HTMLLink, enableDebug, debug, CacheClient, CacheOptions, MemoryCacheClient, } from '@sitecore-jss/sitecore-jss';
|
|
2
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
|
-
export { RestComponentLayoutService } from '@sitecore-jss/sitecore-jss/editing';
|
|
4
3
|
export { mediaApi } from '@sitecore-jss/sitecore-jss/media';
|
|
5
4
|
export { trackingApi, TrackingRequestOptions, CampaignInstance, GoalInstance, OutcomeInstance, EventInstance, PageViewInstance, } from '@sitecore-jss/sitecore-jss/tracking';
|
|
6
5
|
export { DictionaryPhrases, DictionaryService, GraphQLDictionaryService, GraphQLDictionaryServiceConfig, RestDictionaryService, RestDictionaryServiceConfig, } from '@sitecore-jss/sitecore-jss/i18n';
|
|
@@ -23,4 +22,4 @@ import * as BYOCWrapper from './components/BYOCWrapper';
|
|
|
23
22
|
export { FEaaSWrapper };
|
|
24
23
|
export { BYOCWrapper };
|
|
25
24
|
export { ComponentBuilder, ComponentBuilderConfig } from './ComponentBuilder';
|
|
26
|
-
export { ComponentFactory, Image, ImageField, ImageFieldValue, ImageProps, LinkField, LinkFieldValue, Text, TextField, DateField, EditFrame, FEaaSComponent, FEaaSComponentProps, FEaaSComponentParams, fetchFEaaSComponentServerProps, BYOCComponentParams, BYOCComponent, BYOCComponentProps, getComponentLibraryStylesheetLinks, File, FileField, RichTextField,
|
|
25
|
+
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';
|
|
@@ -54,25 +54,4 @@ export declare class RedirectsMiddleware extends MiddlewareBase {
|
|
|
54
54
|
* @returns {NextResponse<unknown>} The redirect response.
|
|
55
55
|
*/
|
|
56
56
|
private createRedirectResponse;
|
|
57
|
-
/**
|
|
58
|
-
* Checks if the current URL query matches the provided pattern, considering all permutations of query parameters.
|
|
59
|
-
* It constructs all possible query parameter permutations and tests them against the pattern.
|
|
60
|
-
* @param {object} params - The parameters for the URL match.
|
|
61
|
-
* @param {string} params.pathname - The current URL pathname.
|
|
62
|
-
* @param {string} params.queryString - The current URL query string.
|
|
63
|
-
* @param {string} params.pattern - The regex pattern to test the constructed URLs against.
|
|
64
|
-
* @param {string} [params.locale] - The locale prefix to include in the URL if present.
|
|
65
|
-
* @returns {string | undefined} - return query string if any of the query permutations match the provided pattern, undefined otherwise.
|
|
66
|
-
*/
|
|
67
|
-
private isPermutedQueryMatch;
|
|
68
|
-
/**
|
|
69
|
-
* Escapes non-special "?" characters in a string or regex.
|
|
70
|
-
*
|
|
71
|
-
* - For regular strings, it escapes all unescaped "?" characters by adding a backslash (`\`).
|
|
72
|
-
* - For regex patterns (strings enclosed in `/.../`), it analyzes each "?" to determine if it has special meaning
|
|
73
|
-
* (e.g., `?` in `(abc)?`, `.*?`) or is just a literal character. Only literal "?" characters are escaped.
|
|
74
|
-
* @param {string} input - The input string or regex pattern.
|
|
75
|
-
* @returns {string} - The modified string or regex with non-special "?" characters escaped.
|
|
76
|
-
**/
|
|
77
|
-
private escapeNonSpecialQuestionMarks;
|
|
78
57
|
}
|