@sitecore-jss/sitecore-jss-nextjs 21.1.0-canary.9 → 21.1.0-canary.91
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/ComponentPropsContext.js +7 -3
- package/dist/cjs/components/EditingComponentPlaceholder.js +12 -0
- package/dist/cjs/components/Link.js +8 -4
- package/dist/cjs/components/NextImage.js +1 -1
- package/dist/cjs/components/Placeholder.js +6 -2
- package/dist/cjs/components/RichText.js +8 -4
- package/dist/cjs/editing/editing-data-cache.js +15 -10
- package/dist/cjs/editing/editing-data-middleware.js +4 -4
- package/dist/cjs/editing/editing-data-service.js +3 -3
- package/dist/cjs/editing/editing-render-middleware.js +13 -4
- package/dist/cjs/index.js +17 -6
- package/dist/cjs/middleware/index.js +5 -1
- package/dist/cjs/middleware/multisite-middleware.js +104 -0
- package/dist/cjs/middleware/personalize-middleware.js +17 -3
- package/dist/cjs/middleware/redirects-middleware.js +75 -42
- package/dist/cjs/monitoring/healthcheck-middleware.js +30 -0
- package/dist/cjs/monitoring/index.js +5 -0
- package/dist/cjs/services/graphql-sitemap-service.js +48 -25
- package/dist/cjs/utils.js +3 -3
- package/dist/esm/components/EditingComponentPlaceholder.js +5 -0
- package/dist/esm/components/Link.js +2 -2
- package/dist/esm/editing/editing-data-cache.js +15 -10
- package/dist/esm/editing/editing-data-middleware.js +2 -2
- package/dist/esm/editing/editing-data-service.js +2 -2
- package/dist/esm/editing/editing-render-middleware.js +11 -2
- package/dist/esm/index.js +4 -4
- package/dist/esm/middleware/index.js +2 -0
- package/dist/esm/middleware/multisite-middleware.js +100 -0
- package/dist/esm/middleware/personalize-middleware.js +16 -2
- package/dist/esm/middleware/redirects-middleware.js +75 -42
- package/dist/esm/monitoring/healthcheck-middleware.js +26 -0
- package/dist/esm/monitoring/index.js +1 -0
- package/dist/esm/services/graphql-sitemap-service.js +47 -24
- package/monitoring.d.ts +1 -0
- package/monitoring.js +1 -0
- package/package.json +34 -33
- package/types/components/ComponentPropsContext.d.ts +1 -1
- package/types/components/EditingComponentPlaceholder.d.ts +4 -0
- package/types/components/Link.d.ts +1 -1
- package/types/components/NextImage.d.ts +1 -1
- package/types/components/RichText.d.ts +1 -1
- package/types/editing/editing-data-cache.d.ts +4 -4
- package/types/editing/editing-data.d.ts +1 -1
- package/types/index.d.ts +5 -5
- package/types/middleware/index.d.ts +2 -0
- package/types/middleware/multisite-middleware.d.ts +46 -0
- package/types/middleware/personalize-middleware.d.ts +12 -1
- package/types/middleware/redirects-middleware.d.ts +33 -4
- package/types/monitoring/healthcheck-middleware.d.ts +12 -0
- package/types/monitoring/index.d.ts +1 -0
- package/types/services/component-props-service.d.ts +3 -3
- package/types/services/graphql-sitemap-service.d.ts +10 -5
- package/types/sharedTypes/component-module.d.ts +2 -2
- package/types/sharedTypes/component-props.d.ts +4 -4
|
@@ -20,13 +20,20 @@ export class PersonalizeMiddleware {
|
|
|
20
20
|
constructor(config) {
|
|
21
21
|
this.config = config;
|
|
22
22
|
this.handler = (req, res) => __awaiter(this, void 0, void 0, function* () {
|
|
23
|
+
var _a;
|
|
24
|
+
const hostHeader = (_a = req.headers.get('host')) === null || _a === void 0 ? void 0 : _a.split(':')[0];
|
|
25
|
+
const hostname = hostHeader || this.defaultHostname;
|
|
23
26
|
const pathname = req.nextUrl.pathname;
|
|
24
27
|
const language = req.nextUrl.locale || req.nextUrl.defaultLocale || 'en';
|
|
28
|
+
const siteName = (res === null || res === void 0 ? void 0 : res.cookies.get('sc_site')) || this.config.getSite(hostname).name;
|
|
25
29
|
let browserId = this.getBrowserId(req);
|
|
26
30
|
debug.personalize('personalize middleware start: %o', {
|
|
27
31
|
pathname,
|
|
28
32
|
language,
|
|
29
33
|
});
|
|
34
|
+
if (!hostHeader) {
|
|
35
|
+
debug.personalize(`host header is missing, default ${hostname} is used`);
|
|
36
|
+
}
|
|
30
37
|
// Response will be provided if other middleware is run before us (e.g. redirects)
|
|
31
38
|
let response = res || NextResponse.next();
|
|
32
39
|
if (this.config.disabled && this.config.disabled(req, response)) {
|
|
@@ -41,7 +48,7 @@ export class PersonalizeMiddleware {
|
|
|
41
48
|
return response;
|
|
42
49
|
}
|
|
43
50
|
// Get personalization info from Experience Edge
|
|
44
|
-
const personalizeInfo = yield this.personalizeService.getPersonalizeInfo(pathname, language);
|
|
51
|
+
const personalizeInfo = yield this.personalizeService.getPersonalizeInfo(pathname, language, siteName);
|
|
45
52
|
if (!personalizeInfo) {
|
|
46
53
|
// Likely an invalid route / language
|
|
47
54
|
debug.personalize('skipped (personalize info not found)');
|
|
@@ -71,8 +78,10 @@ export class PersonalizeMiddleware {
|
|
|
71
78
|
debug.personalize('skipped (invalid variant)');
|
|
72
79
|
return response;
|
|
73
80
|
}
|
|
81
|
+
// Path can be rewritten by previously executed middleware
|
|
82
|
+
const basePath = (res === null || res === void 0 ? void 0 : res.headers.get('x-sc-rewrite')) || pathname;
|
|
74
83
|
// Rewrite to persononalized path
|
|
75
|
-
const rewritePath = getPersonalizedRewrite(
|
|
84
|
+
const rewritePath = getPersonalizedRewrite(basePath, { variantId });
|
|
76
85
|
// Note an absolute URL is required: https://nextjs.org/docs/messages/middleware-relative-urls
|
|
77
86
|
const rewriteUrl = req.nextUrl.clone();
|
|
78
87
|
rewriteUrl.pathname = rewritePath;
|
|
@@ -80,8 +89,12 @@ export class PersonalizeMiddleware {
|
|
|
80
89
|
// Disable preflight caching to force revalidation on client-side navigation (personalization may be influenced)
|
|
81
90
|
// See https://github.com/vercel/next.js/issues/32727
|
|
82
91
|
response.headers.set('x-middleware-cache', 'no-cache');
|
|
92
|
+
// Share rewrite path with following executed middlewares
|
|
93
|
+
response.headers.set('x-sc-rewrite', rewritePath);
|
|
83
94
|
// Set browserId cookie on the response
|
|
84
95
|
this.setBrowserId(response, browserId);
|
|
96
|
+
// Share site name with the following executed middlewares
|
|
97
|
+
response.cookies.set('sc_site', siteName);
|
|
85
98
|
debug.personalize('personalize middleware end: %o', {
|
|
86
99
|
rewritePath,
|
|
87
100
|
browserId,
|
|
@@ -101,6 +114,7 @@ export class PersonalizeMiddleware {
|
|
|
101
114
|
});
|
|
102
115
|
return (url, data) => fetcher.fetch(url, data);
|
|
103
116
|
} }));
|
|
117
|
+
this.defaultHostname = config.defaultHostname || 'localhost';
|
|
104
118
|
}
|
|
105
119
|
/**
|
|
106
120
|
* Gets the Next.js middleware handler with error handling
|
|
@@ -19,46 +19,61 @@ export class RedirectsMiddleware {
|
|
|
19
19
|
* @param {RedirectsMiddlewareConfig} [config] redirects middleware config
|
|
20
20
|
*/
|
|
21
21
|
constructor(config) {
|
|
22
|
-
this.
|
|
23
|
-
|
|
24
|
-
const
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
22
|
+
this.config = config;
|
|
23
|
+
this.handler = (req, res) => __awaiter(this, void 0, void 0, function* () {
|
|
24
|
+
const hostname = this.getHostname(req);
|
|
25
|
+
const siteName = (res === null || res === void 0 ? void 0 : res.cookies.get('sc_site')) || this.config.getSite(hostname).name;
|
|
26
|
+
const createResponse = () => __awaiter(this, void 0, void 0, function* () {
|
|
27
|
+
if ((this.config.disabled && this.config.disabled(req, NextResponse.next())) ||
|
|
28
|
+
this.excludeRoute(req.nextUrl.pathname) ||
|
|
29
|
+
(this.config.excludeRoute && this.config.excludeRoute(req.nextUrl.pathname))) {
|
|
30
|
+
return res || NextResponse.next();
|
|
31
|
+
}
|
|
32
|
+
// Find the redirect from result of RedirectService
|
|
33
|
+
const existsRedirect = yield this.getExistsRedirect(req, siteName);
|
|
34
|
+
if (!existsRedirect) {
|
|
35
|
+
return res || NextResponse.next();
|
|
36
|
+
}
|
|
37
|
+
const url = req.nextUrl.clone();
|
|
38
|
+
const absoluteUrlRegex = new RegExp('^(?:[a-z]+:)?//', 'i');
|
|
39
|
+
if (absoluteUrlRegex.test(existsRedirect.target)) {
|
|
40
|
+
url.href = existsRedirect.target;
|
|
41
|
+
url.locale = req.nextUrl.locale;
|
|
40
42
|
}
|
|
41
43
|
else {
|
|
42
|
-
url.
|
|
44
|
+
url.search = existsRedirect.isQueryStringPreserved ? url.search : '';
|
|
45
|
+
const urlFirstPart = existsRedirect.target.split('/')[1];
|
|
46
|
+
if (this.locales.includes(urlFirstPart)) {
|
|
47
|
+
url.locale = urlFirstPart;
|
|
48
|
+
url.pathname = existsRedirect.target.replace(`/${urlFirstPart}`, '');
|
|
49
|
+
}
|
|
50
|
+
else {
|
|
51
|
+
url.pathname = existsRedirect.target;
|
|
52
|
+
}
|
|
43
53
|
}
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
}
|
|
54
|
+
const redirectUrl = decodeURIComponent(url.href);
|
|
55
|
+
/** return Response redirect with http code of redirect type **/
|
|
56
|
+
switch (existsRedirect.redirectType) {
|
|
57
|
+
case REDIRECT_TYPE_301:
|
|
58
|
+
return NextResponse.redirect(redirectUrl, 301);
|
|
59
|
+
case REDIRECT_TYPE_302:
|
|
60
|
+
return NextResponse.redirect(redirectUrl, 302);
|
|
61
|
+
case REDIRECT_TYPE_SERVER_TRANSFER:
|
|
62
|
+
return NextResponse.rewrite(redirectUrl);
|
|
63
|
+
default:
|
|
64
|
+
return NextResponse.next();
|
|
65
|
+
}
|
|
66
|
+
});
|
|
67
|
+
const response = yield createResponse();
|
|
68
|
+
// Share site name with the following executed middlewares
|
|
69
|
+
response.cookies.set('sc_site', siteName);
|
|
70
|
+
return response;
|
|
57
71
|
});
|
|
58
72
|
// NOTE: we provide native fetch for compatibility on Next.js Edge Runtime
|
|
59
73
|
// (underlying default 'cross-fetch' is not currently compatible: https://github.com/lquixada/cross-fetch/issues/78)
|
|
60
74
|
this.redirectsService = new GraphQLRedirectsService(Object.assign(Object.assign({}, config), { fetch: fetch }));
|
|
61
75
|
this.locales = config.locales;
|
|
76
|
+
this.defaultHostname = config.defaultHostname || 'localhost';
|
|
62
77
|
}
|
|
63
78
|
/**
|
|
64
79
|
* Gets the Next.js API route handler
|
|
@@ -67,22 +82,40 @@ export class RedirectsMiddleware {
|
|
|
67
82
|
getHandler() {
|
|
68
83
|
return this.handler;
|
|
69
84
|
}
|
|
85
|
+
excludeRoute(pathname) {
|
|
86
|
+
if (pathname.includes('.') || // Ignore files
|
|
87
|
+
pathname.startsWith('/api/') || // Ignore Next.js API calls
|
|
88
|
+
pathname.startsWith('/sitecore/') || // Ignore Sitecore API calls
|
|
89
|
+
pathname.startsWith('/_next') // Ignore next service calls
|
|
90
|
+
) {
|
|
91
|
+
return true;
|
|
92
|
+
}
|
|
93
|
+
return false;
|
|
94
|
+
}
|
|
95
|
+
getHostname(req) {
|
|
96
|
+
var _a;
|
|
97
|
+
const hostHeader = (_a = req.headers.get('host')) === null || _a === void 0 ? void 0 : _a.split(':')[0];
|
|
98
|
+
return hostHeader || this.defaultHostname;
|
|
99
|
+
}
|
|
70
100
|
/**
|
|
71
101
|
* Method returns RedirectInfo when matches
|
|
72
|
-
* @param {NextRequest} req
|
|
102
|
+
* @param {NextRequest} req request
|
|
103
|
+
* @param {string} siteName site name
|
|
73
104
|
* @returns Promise<RedirectInfo | undefined>
|
|
74
105
|
* @private
|
|
75
106
|
*/
|
|
76
|
-
getExistsRedirect(req) {
|
|
107
|
+
getExistsRedirect(req, siteName) {
|
|
77
108
|
return __awaiter(this, void 0, void 0, function* () {
|
|
78
|
-
const redirects = yield this.redirectsService.fetchRedirects();
|
|
79
|
-
return redirects.
|
|
80
|
-
|
|
81
|
-
regexParser(redirect.pattern.toLowerCase()).test(
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
109
|
+
const redirects = yield this.redirectsService.fetchRedirects(siteName);
|
|
110
|
+
return redirects.length
|
|
111
|
+
? redirects.find((redirect) => {
|
|
112
|
+
return ((regexParser(redirect.pattern.toLowerCase()).test(req.nextUrl.pathname.toLowerCase()) ||
|
|
113
|
+
regexParser(redirect.pattern.toLowerCase()).test(`/${req.nextUrl.locale}${req.nextUrl.pathname}`.toLowerCase())) &&
|
|
114
|
+
(redirect.locale
|
|
115
|
+
? redirect.locale.toLowerCase() === req.nextUrl.locale.toLowerCase()
|
|
116
|
+
: true));
|
|
117
|
+
})
|
|
118
|
+
: undefined;
|
|
86
119
|
});
|
|
87
120
|
}
|
|
88
121
|
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
/**
|
|
11
|
+
* Middleware / handler for use in healthcheck Next.js API route (e.g. '/api/healthz').
|
|
12
|
+
*/
|
|
13
|
+
export class HealthcheckMiddleware {
|
|
14
|
+
constructor() {
|
|
15
|
+
this.handler = (_req, res) => __awaiter(this, void 0, void 0, function* () {
|
|
16
|
+
res.status(200).send('Healthy');
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Gets the Next.js API route handler
|
|
21
|
+
* @returns route handler
|
|
22
|
+
*/
|
|
23
|
+
getHandler() {
|
|
24
|
+
return this.handler;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { HealthcheckMiddleware } from './healthcheck-middleware';
|
|
@@ -10,8 +10,10 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
10
10
|
import { GraphQLRequestClient } from '@sitecore-jss/sitecore-jss/graphql';
|
|
11
11
|
import { debug } from '@sitecore-jss/sitecore-jss';
|
|
12
12
|
import { getPersonalizedRewrite } from '@sitecore-jss/sitecore-jss/personalize';
|
|
13
|
+
import { getSiteRewrite } from '@sitecore-jss/sitecore-jss/site';
|
|
13
14
|
/** @private */
|
|
14
15
|
export const languageError = 'The list of languages cannot be empty';
|
|
16
|
+
export const sitesError = 'The list of sites cannot be empty';
|
|
15
17
|
/**
|
|
16
18
|
* @param {string} siteName to inject into error text
|
|
17
19
|
* @private
|
|
@@ -49,7 +51,7 @@ query ${usesPersonalize ? 'PersonalizeSitemapQuery' : 'DefaultSitemapQuery'}(
|
|
|
49
51
|
hasNext
|
|
50
52
|
}
|
|
51
53
|
results {
|
|
52
|
-
path: routePath
|
|
54
|
+
path: routePath
|
|
53
55
|
${usesPersonalize
|
|
54
56
|
? `
|
|
55
57
|
route {
|
|
@@ -62,7 +64,7 @@ query ${usesPersonalize ? 'PersonalizeSitemapQuery' : 'DefaultSitemapQuery'}(
|
|
|
62
64
|
}
|
|
63
65
|
}
|
|
64
66
|
}
|
|
65
|
-
}
|
|
67
|
+
}
|
|
66
68
|
`;
|
|
67
69
|
/**
|
|
68
70
|
* Service that fetches the list of site pages using Sitecore's GraphQL API.
|
|
@@ -70,6 +72,12 @@ query ${usesPersonalize ? 'PersonalizeSitemapQuery' : 'DefaultSitemapQuery'}(
|
|
|
70
72
|
* @mixes SearchQueryService<PageListQueryResult>
|
|
71
73
|
*/
|
|
72
74
|
export class GraphQLSitemapService {
|
|
75
|
+
/**
|
|
76
|
+
* Gets the default query used for fetching the list of site pages
|
|
77
|
+
*/
|
|
78
|
+
get query() {
|
|
79
|
+
return defaultQuery(this.options.includePersonalizedRoutes);
|
|
80
|
+
}
|
|
73
81
|
/**
|
|
74
82
|
* Creates an instance of graphQL sitemap service with the provided options
|
|
75
83
|
* @param {GraphQLSitemapServiceConfig} options instance
|
|
@@ -78,12 +86,6 @@ export class GraphQLSitemapService {
|
|
|
78
86
|
this.options = options;
|
|
79
87
|
this.graphQLClient = this.getGraphQLClient();
|
|
80
88
|
}
|
|
81
|
-
/**
|
|
82
|
-
* Gets the default query used for fetching the list of site pages
|
|
83
|
-
*/
|
|
84
|
-
get query() {
|
|
85
|
-
return defaultQuery(this.options.includePersonalizedRoutes);
|
|
86
|
-
}
|
|
87
89
|
/**
|
|
88
90
|
* Fetch sitemap which could be used for generation of static pages during `next export`.
|
|
89
91
|
* The `locale` parameter will be used in the item query, but since i18n is not supported,
|
|
@@ -128,43 +130,64 @@ export class GraphQLSitemapService {
|
|
|
128
130
|
*/
|
|
129
131
|
fetchSitemap(languages, formatStaticPath) {
|
|
130
132
|
return __awaiter(this, void 0, void 0, function* () {
|
|
133
|
+
const paths = new Array();
|
|
131
134
|
if (!languages.length) {
|
|
132
135
|
throw new RangeError(languageError);
|
|
133
136
|
}
|
|
134
|
-
//
|
|
135
|
-
const
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
137
|
+
// Get all sites
|
|
138
|
+
const sites = this.options.sites;
|
|
139
|
+
if (!sites || !sites.length) {
|
|
140
|
+
throw new RangeError(sitesError);
|
|
141
|
+
}
|
|
142
|
+
// Fetch paths for each site
|
|
143
|
+
for (let i = 0; i < sites.length; i++) {
|
|
144
|
+
const siteName = sites[i];
|
|
145
|
+
const multiSiteName = sites.length > 1 ? siteName : undefined;
|
|
146
|
+
// Fetch paths using all locales
|
|
147
|
+
yield Promise.all(languages.map((language) => __awaiter(this, void 0, void 0, function* () {
|
|
148
|
+
if (language === '') {
|
|
149
|
+
throw new RangeError(languageEmptyError);
|
|
150
|
+
}
|
|
151
|
+
debug.sitemap('fetching sitemap data for %s %s', language, siteName);
|
|
152
|
+
const results = yield this.fetchLanguageSitePaths(language, siteName);
|
|
153
|
+
const transformedPaths = yield this.transformLanguageSitePaths(results, formatStaticPath, language, multiSiteName);
|
|
154
|
+
paths.push(...transformedPaths);
|
|
155
|
+
})));
|
|
156
|
+
}
|
|
143
157
|
return [].concat(...paths);
|
|
144
158
|
});
|
|
145
159
|
}
|
|
146
|
-
transformLanguageSitePaths(sitePaths, formatStaticPath, language) {
|
|
160
|
+
transformLanguageSitePaths(sitePaths, formatStaticPath, language, multiSiteName) {
|
|
147
161
|
return __awaiter(this, void 0, void 0, function* () {
|
|
148
162
|
const formatPath = (path) => formatStaticPath(path.replace(/^\/|\/$/g, '').split('/'), language);
|
|
149
163
|
const aggregatedPaths = [];
|
|
150
164
|
sitePaths.forEach((item) => {
|
|
151
|
-
var _a, _b, _c, _d;
|
|
165
|
+
var _a, _b, _c, _d, _e, _f;
|
|
152
166
|
if (!item)
|
|
153
167
|
return;
|
|
154
|
-
|
|
168
|
+
if (!multiSiteName) {
|
|
169
|
+
aggregatedPaths.push(formatPath(item.path));
|
|
170
|
+
}
|
|
171
|
+
else {
|
|
172
|
+
aggregatedPaths.push(formatPath(getSiteRewrite(item.path, { siteName: multiSiteName })));
|
|
173
|
+
}
|
|
155
174
|
// check for type safety's sake - personalize may be empty depending on query type
|
|
156
175
|
if ((_b = (_a = item.route) === null || _a === void 0 ? void 0 : _a.personalization) === null || _b === void 0 ? void 0 : _b.variantIds.length) {
|
|
157
|
-
|
|
176
|
+
multiSiteName
|
|
177
|
+
? aggregatedPaths.push(...(((_d = (_c = item.route) === null || _c === void 0 ? void 0 : _c.personalization) === null || _d === void 0 ? void 0 : _d.variantIds.map((varId) => formatPath(getPersonalizedRewrite(getSiteRewrite(item.path, { siteName: multiSiteName }), {
|
|
178
|
+
variantId: varId,
|
|
179
|
+
})))) || {}))
|
|
180
|
+
: aggregatedPaths.push(...(((_f = (_e = item.route) === null || _e === void 0 ? void 0 : _e.personalization) === null || _f === void 0 ? void 0 : _f.variantIds.map((varId) => formatPath(getPersonalizedRewrite(item.path, { variantId: varId })))) || {}));
|
|
158
181
|
}
|
|
159
182
|
});
|
|
160
183
|
return aggregatedPaths;
|
|
161
184
|
});
|
|
162
185
|
}
|
|
163
|
-
fetchLanguageSitePaths(language) {
|
|
186
|
+
fetchLanguageSitePaths(language, siteName) {
|
|
164
187
|
var _a, _b, _c, _d;
|
|
165
188
|
return __awaiter(this, void 0, void 0, function* () {
|
|
166
189
|
const args = {
|
|
167
|
-
siteName:
|
|
190
|
+
siteName: siteName,
|
|
168
191
|
language: language,
|
|
169
192
|
pageSize: this.options.pageSize,
|
|
170
193
|
includedPaths: this.options.includedPaths,
|
|
@@ -176,7 +199,7 @@ export class GraphQLSitemapService {
|
|
|
176
199
|
while (hasNext) {
|
|
177
200
|
const fetchResponse = yield this.graphQLClient.request(this.query, Object.assign(Object.assign({}, args), { after }));
|
|
178
201
|
if (!((_a = fetchResponse === null || fetchResponse === void 0 ? void 0 : fetchResponse.site) === null || _a === void 0 ? void 0 : _a.siteInfo)) {
|
|
179
|
-
throw new RangeError(getSiteEmptyError(
|
|
202
|
+
throw new RangeError(getSiteEmptyError(siteName));
|
|
180
203
|
}
|
|
181
204
|
else {
|
|
182
205
|
results = results.concat((_b = fetchResponse.site.siteInfo.routes) === null || _b === void 0 ? void 0 : _b.results);
|
package/monitoring.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './types/monitoring/index';
|
package/monitoring.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
module.exports = require('./dist/cjs/monitoring/index');
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sitecore-jss/sitecore-jss-nextjs",
|
|
3
|
-
"version": "21.1.0-canary.
|
|
3
|
+
"version": "21.1.0-canary.91",
|
|
4
4
|
"main": "dist/cjs/index.js",
|
|
5
5
|
"module": "dist/esm/index.js",
|
|
6
6
|
"sideEffects": false,
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
"test": "mocha --require ./test/setup.js \"./src/**/*.test.ts\" \"./src/**/*.test.tsx\" --exit",
|
|
12
12
|
"prepublishOnly": "npm run build",
|
|
13
13
|
"coverage": "nyc npm test",
|
|
14
|
-
"generate-docs": "npx typedoc --plugin typedoc-plugin-markdown --readme none --out ../../ref-docs/sitecore-jss-nextjs --entryPoints src/index.ts --entryPoints src/editing/index.ts --entryPoints src/middleware/index.ts --githubPages false"
|
|
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 --githubPages false"
|
|
15
15
|
},
|
|
16
16
|
"engines": {
|
|
17
17
|
"node": ">=12",
|
|
@@ -30,56 +30,57 @@
|
|
|
30
30
|
"url": "https://github.com/sitecore/jss/issues"
|
|
31
31
|
},
|
|
32
32
|
"devDependencies": {
|
|
33
|
-
"@types/chai": "^4.
|
|
34
|
-
"@types/chai-as-promised": "^7.1.
|
|
33
|
+
"@types/chai": "^4.3.4",
|
|
34
|
+
"@types/chai-as-promised": "^7.1.5",
|
|
35
35
|
"@types/chai-string": "^1.4.2",
|
|
36
36
|
"@types/enzyme": "^3.10.12",
|
|
37
|
-
"@types/mocha": "^
|
|
38
|
-
"@types/node": "
|
|
39
|
-
"@types/prop-types": "^15.7.
|
|
40
|
-
"@types/react": "^18.0.
|
|
41
|
-
"@types/react-dom": "^18.0.
|
|
42
|
-
"@types/sinon": "^
|
|
43
|
-
"@types/sinon-chai": "^3.2.
|
|
44
|
-
"@wojtekmaj/enzyme-adapter-react-17": "^0.
|
|
45
|
-
"chai": "^4.
|
|
37
|
+
"@types/mocha": "^10.0.1",
|
|
38
|
+
"@types/node": "~18.11.18",
|
|
39
|
+
"@types/prop-types": "^15.7.5",
|
|
40
|
+
"@types/react": "^18.0.27",
|
|
41
|
+
"@types/react-dom": "^18.0.10",
|
|
42
|
+
"@types/sinon": "^10.0.13",
|
|
43
|
+
"@types/sinon-chai": "^3.2.9",
|
|
44
|
+
"@wojtekmaj/enzyme-adapter-react-17": "^0.8.0",
|
|
45
|
+
"chai": "^4.3.7",
|
|
46
46
|
"chai-as-promised": "^7.1.1",
|
|
47
47
|
"chai-string": "^1.5.0",
|
|
48
48
|
"chalk": "^4.1.2",
|
|
49
|
-
"cheerio": "1.0.0-rc.
|
|
49
|
+
"cheerio": "1.0.0-rc.12",
|
|
50
50
|
"cross-fetch": "^3.1.5",
|
|
51
51
|
"del-cli": "^5.0.0",
|
|
52
52
|
"enzyme": "^3.11.0",
|
|
53
|
-
"eslint": "^
|
|
54
|
-
"eslint-plugin-react": "^7.
|
|
55
|
-
"jsdom": "^
|
|
56
|
-
"mocha": "^
|
|
57
|
-
"next": "^12.
|
|
58
|
-
"nock": "^13.0
|
|
53
|
+
"eslint": "^8.32.0",
|
|
54
|
+
"eslint-plugin-react": "^7.32.1",
|
|
55
|
+
"jsdom": "^21.1.0",
|
|
56
|
+
"mocha": "^10.2.0",
|
|
57
|
+
"next": "^12.3.4",
|
|
58
|
+
"nock": "^13.3.0",
|
|
59
59
|
"nyc": "^15.1.0",
|
|
60
|
-
"react": "^18.
|
|
61
|
-
"react-dom": "^18.
|
|
62
|
-
"sinon": "^
|
|
60
|
+
"react": "^18.2.0",
|
|
61
|
+
"react-dom": "^18.2.0",
|
|
62
|
+
"sinon": "^15.0.1",
|
|
63
63
|
"sinon-chai": "^3.7.0",
|
|
64
|
-
"ts-node": "^9.
|
|
65
|
-
"typescript": "~4.
|
|
64
|
+
"ts-node": "^10.9.1",
|
|
65
|
+
"typescript": "~4.9.4"
|
|
66
66
|
},
|
|
67
67
|
"peerDependencies": {
|
|
68
|
-
"next": "^12.
|
|
69
|
-
"react": "^18.
|
|
70
|
-
"react-dom": "^18.
|
|
68
|
+
"next": "^12.3.4",
|
|
69
|
+
"react": "^18.2.0",
|
|
70
|
+
"react-dom": "^18.2.0"
|
|
71
71
|
},
|
|
72
72
|
"dependencies": {
|
|
73
|
-
"@sitecore-jss/sitecore-jss": "^21.1.0-canary.
|
|
74
|
-
"@sitecore-jss/sitecore-jss-dev-tools": "^21.1.0-canary.
|
|
75
|
-
"@sitecore-jss/sitecore-jss-react": "^21.1.0-canary.
|
|
76
|
-
"
|
|
73
|
+
"@sitecore-jss/sitecore-jss": "^21.1.0-canary.91",
|
|
74
|
+
"@sitecore-jss/sitecore-jss-dev-tools": "^21.1.0-canary.91",
|
|
75
|
+
"@sitecore-jss/sitecore-jss-react": "^21.1.0-canary.91",
|
|
76
|
+
"node-html-parser": "^6.1.4",
|
|
77
|
+
"prop-types": "^15.8.1",
|
|
77
78
|
"regex-parser": "^2.2.11",
|
|
78
79
|
"sync-disk-cache": "^2.1.0"
|
|
79
80
|
},
|
|
80
81
|
"description": "",
|
|
81
82
|
"types": "types/index.d.ts",
|
|
82
|
-
"gitHead": "
|
|
83
|
+
"gitHead": "2fd48403f90b6ebeb6cd75750807f05f3d27f069",
|
|
83
84
|
"files": [
|
|
84
85
|
"dist",
|
|
85
86
|
"types",
|
|
@@ -11,7 +11,7 @@ export declare const ComponentPropsReactContext: React.Context<ComponentPropsCol
|
|
|
11
11
|
* @returns {ComponentData | undefined} component props
|
|
12
12
|
*/
|
|
13
13
|
export declare function useComponentProps<ComponentData>(componentUid: string | undefined): ComponentData | undefined;
|
|
14
|
-
export
|
|
14
|
+
export type ComponentPropsContextProps = {
|
|
15
15
|
children: ReactNode;
|
|
16
16
|
value: ComponentPropsCollection;
|
|
17
17
|
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { LinkProps as ReactLinkProps } from '@sitecore-jss/sitecore-jss-react';
|
|
3
|
-
export
|
|
3
|
+
export type LinkProps = ReactLinkProps & {
|
|
4
4
|
/**
|
|
5
5
|
* If `href` match with `internalLinkMatcher` regexp, then it's internal link and NextLink will be rendered
|
|
6
6
|
* @default /^\//g
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { ImageProps } from '@sitecore-jss/sitecore-jss-react';
|
|
3
3
|
import { ImageLoader, ImageProps as NextImageProperties } from 'next/image';
|
|
4
|
-
|
|
4
|
+
type NextImageProps = Omit<ImageProps, 'media'> & Partial<NextImageProperties>;
|
|
5
5
|
export declare const sitecoreLoader: ImageLoader;
|
|
6
6
|
export declare const NextImage: React.FC<NextImageProps>;
|
|
7
7
|
export {};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import PropTypes from 'prop-types';
|
|
2
2
|
import { RichTextProps as ReactRichTextProps } from '@sitecore-jss/sitecore-jss-react';
|
|
3
|
-
export
|
|
3
|
+
export type RichTextProps = ReactRichTextProps & {
|
|
4
4
|
/**
|
|
5
5
|
* Selector which should be used in order to prefetch it and attach event listeners
|
|
6
6
|
* @default 'a[href^="/"]'
|
|
@@ -3,8 +3,8 @@ import { EditingData } from './editing-data';
|
|
|
3
3
|
* Defines an editing data cache implementation
|
|
4
4
|
*/
|
|
5
5
|
export interface EditingDataCache {
|
|
6
|
-
set(key: string, editingData: EditingData): void
|
|
7
|
-
get(key: string): EditingData | undefined
|
|
6
|
+
set(key: string, editingData: EditingData): Promise<void>;
|
|
7
|
+
get(key: string): Promise<EditingData | undefined>;
|
|
8
8
|
}
|
|
9
9
|
/**
|
|
10
10
|
* A disk-based editing data cache implementation (required for hosting on Vercel via Serverless Functions)
|
|
@@ -16,8 +16,8 @@ export declare class EditingDataDiskCache implements EditingDataCache {
|
|
|
16
16
|
* @param {string} [tmpDir] Temp directory to use. Default is the OS temp directory (os.tmpdir()).
|
|
17
17
|
*/
|
|
18
18
|
constructor(tmpDir?: string);
|
|
19
|
-
set(key: string, editingData: EditingData): void
|
|
20
|
-
get(key: string): EditingData | undefined
|
|
19
|
+
set(key: string, editingData: EditingData): Promise<void>;
|
|
20
|
+
get(key: string): Promise<EditingData | undefined>;
|
|
21
21
|
}
|
|
22
22
|
/** EditingDataDiskCache singleton */
|
|
23
23
|
export declare const editingDataDiskCache: EditingDataDiskCache;
|
package/types/index.d.ts
CHANGED
|
@@ -1,23 +1,23 @@
|
|
|
1
|
-
export { constants, HttpDataFetcher, HttpResponse, AxiosDataFetcher, AxiosDataFetcherConfig, NativeDataFetcher, NativeDataFetcherConfig, enableDebug, } from '@sitecore-jss/sitecore-jss';
|
|
1
|
+
export { constants, HttpDataFetcher, HttpResponse, AxiosResponse, AxiosDataFetcher, AxiosDataFetcherConfig, NativeDataFetcher, NativeDataFetcherConfig, enableDebug, } from '@sitecore-jss/sitecore-jss';
|
|
2
2
|
export { isEditorActive, resetEditorChromes, resolveUrl } from '@sitecore-jss/sitecore-jss/utils';
|
|
3
|
-
export { LayoutService, LayoutServiceData, LayoutServicePageState, LayoutServiceContext, LayoutServiceContextData, GraphQLLayoutService, GraphQLLayoutServiceConfig, RestLayoutService, RestLayoutServiceConfig, PlaceholderData, PlaceholdersData, RouteData, Field, Item, HtmlElementRendering, getChildPlaceholder, getFieldValue, ComponentRendering, ComponentFields, ComponentParams, } from '@sitecore-jss/sitecore-jss/layout';
|
|
3
|
+
export { LayoutService, LayoutServiceData, LayoutServicePageState, LayoutServiceContext, LayoutServiceContextData, GraphQLLayoutService, GraphQLLayoutServiceConfig, RestLayoutService, RestLayoutServiceConfig, PlaceholderData, PlaceholdersData, RouteData, Field, Item, HtmlElementRendering, getChildPlaceholder, getFieldValue, ComponentRendering, ComponentFields, ComponentParams, RenderingType, EDITING_COMPONENT_PLACEHOLDER, EDITING_COMPONENT_ID, } from '@sitecore-jss/sitecore-jss/layout';
|
|
4
4
|
export { mediaApi } from '@sitecore-jss/sitecore-jss/media';
|
|
5
5
|
export { trackingApi, TrackingRequestOptions, CampaignInstance, GoalInstance, OutcomeInstance, EventInstance, PageViewInstance, } from '@sitecore-jss/sitecore-jss/tracking';
|
|
6
6
|
export { DictionaryPhrases, DictionaryService, GraphQLDictionaryService, GraphQLDictionaryServiceConfig, RestDictionaryService, RestDictionaryServiceConfig, } from '@sitecore-jss/sitecore-jss/i18n';
|
|
7
7
|
export { personalizeLayout, getPersonalizedRewrite, getPersonalizedRewriteData, normalizePersonalizedRewrite, CdpHelper, } from '@sitecore-jss/sitecore-jss/personalize';
|
|
8
|
-
export { RobotsQueryResult, GraphQLRobotsService, GraphQLRobotsServiceConfig, } from '@sitecore-jss/sitecore-jss/site';
|
|
9
8
|
export { GraphQLRequestClient } from '@sitecore-jss/sitecore-jss';
|
|
10
9
|
export { ComponentPropsCollection, GetStaticComponentProps, GetServerSideComponentProps, } from './sharedTypes/component-props';
|
|
11
10
|
export { ComponentModule } from './sharedTypes/component-module';
|
|
12
11
|
export { ComponentPropsService } from './services/component-props-service';
|
|
13
12
|
export { DisconnectedSitemapService } from './services/disconnected-sitemap-service';
|
|
14
13
|
export { GraphQLSitemapService, GraphQLSitemapServiceConfig, } from './services/graphql-sitemap-service';
|
|
15
|
-
export { GraphQLSitemapXmlService, GraphQLSitemapXmlServiceConfig, GraphQLErrorPagesService, GraphQLErrorPagesServiceConfig, ErrorPages, } from '@sitecore-jss/sitecore-jss/site';
|
|
14
|
+
export { GraphQLSitemapXmlService, GraphQLSitemapXmlServiceConfig, GraphQLErrorPagesService, GraphQLErrorPagesServiceConfig, RobotsQueryResult, GraphQLRobotsService, GraphQLRobotsServiceConfig, ErrorPages, SiteInfo, SiteResolver, GraphQLSiteInfoService, GraphQLSiteInfoServiceConfig, getSiteRewrite, getSiteRewriteData, normalizeSiteRewrite, } from '@sitecore-jss/sitecore-jss/site';
|
|
16
15
|
export { StaticPath } from './services/graphql-sitemap-service';
|
|
17
16
|
export { ComponentPropsReactContext, ComponentPropsContextProps, ComponentPropsContext, useComponentProps, } from './components/ComponentPropsContext';
|
|
18
17
|
export { handleEditorFastRefresh, getPublicUrl } from './utils';
|
|
19
18
|
export { Link, LinkProps } from './components/Link';
|
|
20
19
|
export { RichText, RichTextProps } from './components/RichText';
|
|
21
20
|
export { Placeholder } from './components/Placeholder';
|
|
21
|
+
export { EditingComponentPlaceholder } from './components/EditingComponentPlaceholder';
|
|
22
22
|
export { NextImage } from './components/NextImage';
|
|
23
|
-
export { ComponentFactory, Image, ImageField, ImageFieldValue, ImageProps, LinkField, LinkFieldValue, Text, TextField, DateField, File, FileField, RichTextField, VisitorIdentification, PlaceholderComponentProps, SitecoreContext, SitecoreContextState, SitecoreContextValue, SitecoreContextReactContext, withSitecoreContext, useSitecoreContext, withEditorChromes, withPlaceholder, withDatasourceCheck, ImageSizeParameters, ComponentConsumerProps, WithSitecoreContextOptions, WithSitecoreContextProps, } from '@sitecore-jss/sitecore-jss-react';
|
|
23
|
+
export { ComponentFactory, Image, ImageField, ImageFieldValue, ImageProps, LinkField, LinkFieldValue, Text, TextField, DateField, FEaaSComponent, FEaaSComponentProps, File, FileField, RichTextField, VisitorIdentification, PlaceholderComponentProps, SitecoreContext, SitecoreContextState, SitecoreContextValue, SitecoreContextReactContext, withSitecoreContext, useSitecoreContext, withEditorChromes, withPlaceholder, withDatasourceCheck, ImageSizeParameters, ComponentConsumerProps, WithSitecoreContextOptions, WithSitecoreContextProps, } from '@sitecore-jss/sitecore-jss-react';
|
|
@@ -1,2 +1,4 @@
|
|
|
1
1
|
export { RedirectsMiddleware, RedirectsMiddlewareConfig } from './redirects-middleware';
|
|
2
2
|
export { PersonalizeMiddleware, PersonalizeMiddlewareConfig } from './personalize-middleware';
|
|
3
|
+
export { MultisiteMiddleware, MultisiteMiddlewareConfig } from './multisite-middleware';
|
|
4
|
+
export { SiteResolver, SiteInfo } from '@sitecore-jss/sitecore-jss/site';
|