@sitecore-jss/sitecore-jss-nextjs 21.6.0-canary.35 → 21.6.0-canary.38
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/editing/editing-data-middleware.js +2 -2
- package/dist/cjs/editing/editing-data-service.js +7 -15
- package/dist/cjs/editing/editing-render-middleware.js +8 -31
- package/dist/cjs/index.js +6 -10
- package/dist/cjs/middleware/personalize-middleware.js +32 -33
- package/dist/cjs/middleware/redirects-middleware.js +6 -3
- package/dist/cjs/services/base-graphql-sitemap-service.js +0 -8
- package/dist/esm/editing/editing-data-middleware.js +1 -1
- package/dist/esm/editing/editing-data-service.js +5 -13
- package/dist/esm/editing/editing-render-middleware.js +8 -31
- package/dist/esm/index.js +3 -9
- package/dist/esm/middleware/personalize-middleware.js +33 -34
- package/dist/esm/middleware/redirects-middleware.js +6 -3
- package/dist/esm/services/base-graphql-sitemap-service.js +1 -9
- package/package.json +8 -9
- package/types/editing/editing-data-service.d.ts +4 -12
- package/types/editing/editing-render-middleware.d.ts +0 -10
- package/types/index.d.ts +3 -7
- package/types/middleware/personalize-middleware.d.ts +15 -20
- package/types/services/base-graphql-sitemap-service.d.ts +3 -10
- package/context.d.ts +0 -1
- package/context.js +0 -1
- package/dist/cjs/context/context.js +0 -63
- package/dist/cjs/context/index.js +0 -5
- package/dist/cjs/editing/constants.js +0 -6
- package/dist/cjs/graphql/index.js +0 -6
- package/dist/esm/context/context.js +0 -59
- package/dist/esm/context/index.js +0 -1
- package/dist/esm/editing/constants.js +0 -3
- package/dist/esm/graphql/index.js +0 -1
- package/graphql.d.ts +0 -1
- package/graphql.js +0 -1
- package/types/context/context.d.ts +0 -104
- package/types/context/index.d.ts +0 -1
- package/types/editing/constants.d.ts +0 -3
- package/types/graphql/index.d.ts +0 -1
|
@@ -8,10 +8,10 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
8
8
|
});
|
|
9
9
|
};
|
|
10
10
|
import { NextResponse } from 'next/server';
|
|
11
|
-
import { GraphQLPersonalizeService, getPersonalizedRewrite, } from '@sitecore-jss/sitecore-jss/personalize';
|
|
11
|
+
import { GraphQLPersonalizeService, getPersonalizedRewrite, PosResolver, } from '@sitecore-jss/sitecore-jss/personalize';
|
|
12
12
|
import { debug } from '@sitecore-jss/sitecore-jss';
|
|
13
13
|
import { MiddlewareBase } from './middleware';
|
|
14
|
-
import {
|
|
14
|
+
import { initServer } from '@sitecore/engage';
|
|
15
15
|
/**
|
|
16
16
|
* Middleware / handler to support Sitecore Personalize
|
|
17
17
|
*/
|
|
@@ -23,6 +23,7 @@ export class PersonalizeMiddleware extends MiddlewareBase {
|
|
|
23
23
|
super(config);
|
|
24
24
|
this.config = config;
|
|
25
25
|
this.handler = (req, res) => __awaiter(this, void 0, void 0, function* () {
|
|
26
|
+
var _a;
|
|
26
27
|
const pathname = req.nextUrl.pathname;
|
|
27
28
|
const language = this.getLanguage(req);
|
|
28
29
|
const hostname = this.getHostHeader(req) || this.defaultHostname;
|
|
@@ -58,20 +59,30 @@ export class PersonalizeMiddleware extends MiddlewareBase {
|
|
|
58
59
|
debug.personalize('skipped (no personalization configured)');
|
|
59
60
|
return response;
|
|
60
61
|
}
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
response,
|
|
66
|
-
}
|
|
62
|
+
const engageServer = this.initializeEngageServer(hostname, site, language);
|
|
63
|
+
// creates the browser ID cookie on the server side
|
|
64
|
+
// and includes the cookie in the response header
|
|
65
|
+
try {
|
|
66
|
+
yield engageServer.handleCookie(req, response, timeout);
|
|
67
|
+
}
|
|
68
|
+
catch (error) {
|
|
69
|
+
debug.personalize('skipped (browser id generation failed)');
|
|
70
|
+
throw error;
|
|
71
|
+
}
|
|
67
72
|
const params = this.getExperienceParams(req);
|
|
68
|
-
debug.personalize('executing experience for %s %o', personalizeInfo.contentId, params);
|
|
73
|
+
debug.personalize('executing experience for %s %s %o', personalizeInfo.contentId, params);
|
|
74
|
+
const personalizationData = {
|
|
75
|
+
channel: this.config.cdpConfig.channel || 'WEB',
|
|
76
|
+
currency: (_a = this.config.cdpConfig.currency) !== null && _a !== void 0 ? _a : 'USA',
|
|
77
|
+
friendlyId: personalizeInfo.contentId,
|
|
78
|
+
params,
|
|
79
|
+
language,
|
|
80
|
+
};
|
|
69
81
|
let variantId;
|
|
70
|
-
// Execute targeted experience in
|
|
82
|
+
// Execute targeted experience in CDP
|
|
71
83
|
// eslint-disable-next-line no-useless-catch
|
|
72
84
|
try {
|
|
73
|
-
|
|
74
|
-
variantId = personalization.variantId;
|
|
85
|
+
variantId = (yield engageServer.personalize(personalizationData, req, timeout)).variantId;
|
|
75
86
|
}
|
|
76
87
|
catch (error) {
|
|
77
88
|
throw error;
|
|
@@ -132,29 +143,17 @@ export class PersonalizeMiddleware extends MiddlewareBase {
|
|
|
132
143
|
}
|
|
133
144
|
});
|
|
134
145
|
}
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
});
|
|
145
|
-
}
|
|
146
|
-
personalize({ params, personalizeInfo, language, timeout, }, request) {
|
|
147
|
-
var _a;
|
|
148
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
149
|
-
const personalizationData = {
|
|
150
|
-
channel: this.config.cdpConfig.channel || 'WEB',
|
|
151
|
-
currency: (_a = this.config.cdpConfig.currency) !== null && _a !== void 0 ? _a : 'USD',
|
|
152
|
-
friendlyId: personalizeInfo.contentId,
|
|
153
|
-
params,
|
|
154
|
-
language,
|
|
155
|
-
};
|
|
156
|
-
return (yield personalize(personalizationData, request, timeout));
|
|
146
|
+
initializeEngageServer(hostName, site, language) {
|
|
147
|
+
const engageServer = initServer({
|
|
148
|
+
clientKey: this.config.cdpConfig.clientKey,
|
|
149
|
+
targetURL: this.config.cdpConfig.endpoint,
|
|
150
|
+
pointOfSale: this.config.getPointOfSale
|
|
151
|
+
? this.config.getPointOfSale(site, language)
|
|
152
|
+
: PosResolver.resolve(site, language),
|
|
153
|
+
cookieDomain: hostName,
|
|
154
|
+
forceServerCookieMode: true,
|
|
157
155
|
});
|
|
156
|
+
return engageServer;
|
|
158
157
|
}
|
|
159
158
|
getExperienceParams(req) {
|
|
160
159
|
const utm = {
|
|
@@ -130,13 +130,16 @@ export class RedirectsMiddleware extends MiddlewareBase {
|
|
|
130
130
|
const redirects = yield this.redirectsService.fetchRedirects(siteName);
|
|
131
131
|
const tragetURL = req.nextUrl.pathname;
|
|
132
132
|
const targetQS = req.nextUrl.search || '';
|
|
133
|
-
|
|
134
|
-
|
|
133
|
+
const language = this.getLanguage(req);
|
|
134
|
+
const modifyRedirects = JSON.parse(JSON.stringify(redirects));
|
|
135
|
+
return modifyRedirects.length
|
|
136
|
+
? modifyRedirects.find((redirect) => {
|
|
137
|
+
redirect.pattern = redirect.pattern.replace(RegExp(`^[^]?/${language}/`, 'gi'), '');
|
|
135
138
|
redirect.pattern = `/^\/${redirect.pattern
|
|
136
139
|
.replace(/^\/|\/$/g, '')
|
|
137
140
|
.replace(/^\^\/|\/\$$/g, '')
|
|
138
141
|
.replace(/^\^|\$$/g, '')
|
|
139
|
-
.replace(/\$\/gi$/g, '')}
|
|
142
|
+
.replace(/\$\/gi$/g, '')}[\/]?$/gi`;
|
|
140
143
|
return ((regexParser(redirect.pattern).test(tragetURL) ||
|
|
141
144
|
regexParser(redirect.pattern).test(`${tragetURL}${targetQS}`) ||
|
|
142
145
|
regexParser(redirect.pattern).test(`/${req.nextUrl.locale}${tragetURL}`) ||
|
|
@@ -7,7 +7,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
7
7
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
8
|
});
|
|
9
9
|
};
|
|
10
|
-
import { GraphQLRequestClient
|
|
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
13
|
/** @private */
|
|
@@ -191,14 +191,6 @@ export class BaseGraphQLSitemapService {
|
|
|
191
191
|
* @returns {GraphQLClient} implementation
|
|
192
192
|
*/
|
|
193
193
|
getGraphQLClient() {
|
|
194
|
-
if (!this.options.endpoint) {
|
|
195
|
-
if (!this.options.clientFactory) {
|
|
196
|
-
throw new Error('You should provide either an endpoint and apiKey, or a clientFactory.');
|
|
197
|
-
}
|
|
198
|
-
return this.options.clientFactory({
|
|
199
|
-
debugger: debug.sitemap,
|
|
200
|
-
});
|
|
201
|
-
}
|
|
202
194
|
return new GraphQLRequestClient(this.options.endpoint, {
|
|
203
195
|
apiKey: this.options.apiKey,
|
|
204
196
|
debugger: debug.sitemap,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sitecore-jss/sitecore-jss-nextjs",
|
|
3
|
-
"version": "21.6.0-canary.
|
|
3
|
+
"version": "21.6.0-canary.38",
|
|
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/monitoring/index.ts --entryPoints src/editing/index.ts --entryPoints src/middleware/index.ts --
|
|
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,7 +30,7 @@
|
|
|
30
30
|
"url": "https://github.com/sitecore/jss/issues"
|
|
31
31
|
},
|
|
32
32
|
"devDependencies": {
|
|
33
|
-
"@sitecore
|
|
33
|
+
"@sitecore/engage": "^1.4.1",
|
|
34
34
|
"@types/chai": "^4.3.4",
|
|
35
35
|
"@types/chai-as-promised": "^7.1.5",
|
|
36
36
|
"@types/chai-string": "^1.4.2",
|
|
@@ -66,16 +66,15 @@
|
|
|
66
66
|
"typescript": "~4.9.4"
|
|
67
67
|
},
|
|
68
68
|
"peerDependencies": {
|
|
69
|
-
"@sitecore
|
|
70
|
-
"@sitecore-cloudsdk/personalize": "^0.1.1",
|
|
69
|
+
"@sitecore/engage": "^1.4.1",
|
|
71
70
|
"next": "^13.4.16",
|
|
72
71
|
"react": "^18.2.0",
|
|
73
72
|
"react-dom": "^18.2.0"
|
|
74
73
|
},
|
|
75
74
|
"dependencies": {
|
|
76
|
-
"@sitecore-jss/sitecore-jss": "^21.6.0-canary.
|
|
77
|
-
"@sitecore-jss/sitecore-jss-dev-tools": "^21.6.0-canary.
|
|
78
|
-
"@sitecore-jss/sitecore-jss-react": "^21.6.0-canary.
|
|
75
|
+
"@sitecore-jss/sitecore-jss": "^21.6.0-canary.38",
|
|
76
|
+
"@sitecore-jss/sitecore-jss-dev-tools": "^21.6.0-canary.38",
|
|
77
|
+
"@sitecore-jss/sitecore-jss-react": "^21.6.0-canary.38",
|
|
79
78
|
"@vercel/kv": "^0.2.1",
|
|
80
79
|
"node-html-parser": "^6.1.4",
|
|
81
80
|
"prop-types": "^15.8.1",
|
|
@@ -84,7 +83,7 @@
|
|
|
84
83
|
},
|
|
85
84
|
"description": "",
|
|
86
85
|
"types": "types/index.d.ts",
|
|
87
|
-
"gitHead": "
|
|
86
|
+
"gitHead": "51a9556fdfd9c3db0dc5988b46a4c61cef3cde20",
|
|
88
87
|
"files": [
|
|
89
88
|
"dist",
|
|
90
89
|
"types",
|
|
@@ -2,15 +2,13 @@ import { AxiosDataFetcher } from '@sitecore-jss/sitecore-jss';
|
|
|
2
2
|
import { EditingData } from './editing-data';
|
|
3
3
|
import { EditingDataCache } from './editing-data-cache';
|
|
4
4
|
import { PreviewData } from 'next';
|
|
5
|
+
export declare const QUERY_PARAM_EDITING_SECRET = "secret";
|
|
5
6
|
/**
|
|
6
7
|
* Data for Next.js Preview (Editing) mode
|
|
7
8
|
*/
|
|
8
9
|
export interface EditingPreviewData {
|
|
9
10
|
key: string;
|
|
10
11
|
serverUrl?: string;
|
|
11
|
-
params?: {
|
|
12
|
-
[key: string]: string;
|
|
13
|
-
};
|
|
14
12
|
}
|
|
15
13
|
/**
|
|
16
14
|
* Defines an editing data service implementation
|
|
@@ -22,9 +20,7 @@ export interface EditingDataService {
|
|
|
22
20
|
* @param {string} serverUrl The server url e.g. which can be used for further API requests
|
|
23
21
|
* @returns The {@link EditingPreviewData} containing the information to use for retrieval
|
|
24
22
|
*/
|
|
25
|
-
setEditingData(data: EditingData, serverUrl: string
|
|
26
|
-
[key: string]: string;
|
|
27
|
-
}): Promise<EditingPreviewData>;
|
|
23
|
+
setEditingData(data: EditingData, serverUrl: string): Promise<EditingPreviewData>;
|
|
28
24
|
/**
|
|
29
25
|
* Retrieves Sitecore editor payload data
|
|
30
26
|
* @param {PreviewData} previewData Editing preview data containing the information to use for retrieval
|
|
@@ -111,18 +107,14 @@ export declare class ServerlessEditingDataService implements EditingDataService
|
|
|
111
107
|
* @param {string} serverUrl The server url to use for subsequent data API requests
|
|
112
108
|
* @returns {Promise} The {@link EditingPreviewData} containing the generated key and serverUrl to use for retrieval
|
|
113
109
|
*/
|
|
114
|
-
setEditingData(data: EditingData, serverUrl: string
|
|
115
|
-
[key: string]: string;
|
|
116
|
-
}): Promise<EditingPreviewData>;
|
|
110
|
+
setEditingData(data: EditingData, serverUrl: string): Promise<EditingPreviewData>;
|
|
117
111
|
/**
|
|
118
112
|
* Retrieves Sitecore editor payload data by key
|
|
119
113
|
* @param {PreviewData} previewData Editing preview data containing the key and serverUrl to use for retrieval
|
|
120
114
|
* @returns {Promise} The {@link EditingData}
|
|
121
115
|
*/
|
|
122
116
|
getEditingData(previewData: PreviewData): Promise<EditingData | undefined>;
|
|
123
|
-
protected getUrl(serverUrl: string, key: string
|
|
124
|
-
[key: string]: string;
|
|
125
|
-
}): string;
|
|
117
|
+
protected getUrl(serverUrl: string, key: string): string;
|
|
126
118
|
}
|
|
127
119
|
/**
|
|
128
120
|
* The `EditingDataService` default instance.
|
|
@@ -55,16 +55,6 @@ export declare class EditingRenderMiddleware {
|
|
|
55
55
|
* @returns route handler
|
|
56
56
|
*/
|
|
57
57
|
getHandler(): (req: NextApiRequest, res: NextApiResponse) => Promise<void>;
|
|
58
|
-
/**
|
|
59
|
-
* Gets query parameters that should be passed along to subsequent requests
|
|
60
|
-
* @param query Object of query parameters from incoming URL
|
|
61
|
-
* @returns Object of approved query parameters
|
|
62
|
-
*/
|
|
63
|
-
protected getQueryParamsForPropagation: (query: Partial<{
|
|
64
|
-
[key: string]: string | string[];
|
|
65
|
-
}>) => {
|
|
66
|
-
[key: string]: string;
|
|
67
|
-
};
|
|
68
58
|
private handler;
|
|
69
59
|
/**
|
|
70
60
|
* Default page URL resolution.
|
package/types/index.d.ts
CHANGED
|
@@ -1,18 +1,15 @@
|
|
|
1
1
|
export { constants, HttpDataFetcher, HttpResponse, AxiosResponse, AxiosDataFetcher, AxiosDataFetcherConfig, NativeDataFetcher, NativeDataFetcherConfig, HTMLLink, enableDebug, debug, } from '@sitecore-jss/sitecore-jss';
|
|
2
|
-
import { GraphQLRequestClient as GraphQLRequestClientDep } from './graphql';
|
|
3
2
|
import { resolveUrl as resolveUrlDep } from '@sitecore-jss/sitecore-jss/utils';
|
|
4
3
|
/** @deprecated use import from '@sitecore-jss/sitecore-jss-nextjs/utils' instead */
|
|
5
4
|
declare const isEditorActive: () => boolean, resetEditorChromes: () => void, resolveUrl: typeof resolveUrlDep, tryParseEnvValue: <T>(envValue: string | undefined, defaultValue: T) => T, handleEditorFastRefresh: (forceReload?: boolean) => void, getPublicUrl: () => string;
|
|
6
|
-
/** @deprecated use import from '@sitecore-jss/sitecore-jss-nextjs/graphql' instead */
|
|
7
|
-
declare const GraphQLRequestClient: typeof GraphQLRequestClientDep;
|
|
8
|
-
export { GraphQLRequestClient };
|
|
9
5
|
export { handleEditorFastRefresh, getPublicUrl };
|
|
10
6
|
export { isEditorActive, resetEditorChromes, resolveUrl, tryParseEnvValue };
|
|
11
|
-
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';
|
|
7
|
+
export { LayoutService, LayoutServiceData, LayoutServicePageState, LayoutServiceContext, LayoutServiceContextData, GraphQLLayoutService, GraphQLLayoutServiceConfig, RestLayoutService, RestLayoutServiceConfig, PlaceholderData, PlaceholdersData, RouteData, Field, Item, HtmlElementRendering, getChildPlaceholder, getFieldValue, ComponentRendering, ComponentFields, ComponentParams, RenderingType, EDITING_COMPONENT_PLACEHOLDER, EDITING_COMPONENT_ID, getContentStylesheetLink, } from '@sitecore-jss/sitecore-jss/layout';
|
|
12
8
|
export { mediaApi } from '@sitecore-jss/sitecore-jss/media';
|
|
13
9
|
export { trackingApi, TrackingRequestOptions, CampaignInstance, GoalInstance, OutcomeInstance, EventInstance, PageViewInstance, } from '@sitecore-jss/sitecore-jss/tracking';
|
|
14
10
|
export { DictionaryPhrases, DictionaryService, GraphQLDictionaryService, GraphQLDictionaryServiceConfig, RestDictionaryService, RestDictionaryServiceConfig, } from '@sitecore-jss/sitecore-jss/i18n';
|
|
15
|
-
export { personalizeLayout, getPersonalizedRewrite, getPersonalizedRewriteData, normalizePersonalizedRewrite, CdpHelper, } from '@sitecore-jss/sitecore-jss/personalize';
|
|
11
|
+
export { personalizeLayout, getPersonalizedRewrite, getPersonalizedRewriteData, normalizePersonalizedRewrite, CdpHelper, PosResolver, } from '@sitecore-jss/sitecore-jss/personalize';
|
|
12
|
+
export { GraphQLRequestClient } from '@sitecore-jss/sitecore-jss';
|
|
16
13
|
export { ComponentPropsCollection, ComponentPropsError, GetStaticComponentProps, GetServerSideComponentProps, } from './sharedTypes/component-props';
|
|
17
14
|
export { ModuleFactory, Module } from './sharedTypes/module-factory';
|
|
18
15
|
export { ComponentPropsService } from './services/component-props-service';
|
|
@@ -32,5 +29,4 @@ import * as BYOCWrapper from './components/BYOCWrapper';
|
|
|
32
29
|
export { FEaaSWrapper };
|
|
33
30
|
export { BYOCWrapper };
|
|
34
31
|
export { ComponentBuilder, ComponentBuilderConfig } from './ComponentBuilder';
|
|
35
|
-
export { Context, ContextConfig, SDK } from './context';
|
|
36
32
|
export { ComponentFactory, Image, ImageField, ImageFieldValue, ImageProps, LinkField, LinkFieldValue, Text, TextField, DateField, EditFrame, FEaaSComponent, FEaaSComponentProps, FEaaSComponentParams, fetchFEaaSComponentServerProps, BYOCComponentParams, BYOCComponent, BYOCComponentProps, getFEAASLibraryStylesheetLinks, 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,16 +1,17 @@
|
|
|
1
1
|
import { NextResponse, NextRequest } from 'next/server';
|
|
2
|
-
import { GraphQLPersonalizeServiceConfig
|
|
2
|
+
import { GraphQLPersonalizeServiceConfig } from '@sitecore-jss/sitecore-jss/personalize';
|
|
3
|
+
import { SiteInfo } from '@sitecore-jss/sitecore-jss/site';
|
|
3
4
|
import { MiddlewareBase, MiddlewareBaseConfig } from './middleware';
|
|
5
|
+
import { EngageServer } from '@sitecore/engage';
|
|
4
6
|
export type CdpServiceConfig = {
|
|
5
7
|
/**
|
|
6
|
-
* Your Sitecore
|
|
7
|
-
* Default is https://edge-platform.sitecorecloud.io
|
|
8
|
+
* Your Sitecore CDP API endpoint
|
|
8
9
|
*/
|
|
9
|
-
|
|
10
|
+
endpoint: string;
|
|
10
11
|
/**
|
|
11
|
-
*
|
|
12
|
+
* The client key to use for authentication
|
|
12
13
|
*/
|
|
13
|
-
|
|
14
|
+
clientKey: string;
|
|
14
15
|
/**
|
|
15
16
|
* The Sitecore CDP channel to use for events. Uses 'WEB' by default.
|
|
16
17
|
*/
|
|
@@ -33,6 +34,13 @@ export type PersonalizeMiddlewareConfig = MiddlewareBaseConfig & {
|
|
|
33
34
|
* Configuration for your Sitecore CDP endpoint
|
|
34
35
|
*/
|
|
35
36
|
cdpConfig: CdpServiceConfig;
|
|
37
|
+
/**
|
|
38
|
+
* function to resolve point of sale for a site
|
|
39
|
+
* @param {Siteinfo} site to get info from
|
|
40
|
+
* @param {string} language to get info for
|
|
41
|
+
* @returns point of sale value for site/language combination
|
|
42
|
+
*/
|
|
43
|
+
getPointOfSale?: (site: SiteInfo, language: string) => string;
|
|
36
44
|
};
|
|
37
45
|
/**
|
|
38
46
|
* Object model of Experience Context data
|
|
@@ -62,20 +70,7 @@ export declare class PersonalizeMiddleware extends MiddlewareBase {
|
|
|
62
70
|
* @returns middleware handler
|
|
63
71
|
*/
|
|
64
72
|
getHandler(): (req: NextRequest, res?: NextResponse) => Promise<NextResponse>;
|
|
65
|
-
protected
|
|
66
|
-
hostname: string;
|
|
67
|
-
siteName: string;
|
|
68
|
-
request: NextRequest;
|
|
69
|
-
response: NextResponse;
|
|
70
|
-
}): Promise<void>;
|
|
71
|
-
protected personalize({ params, personalizeInfo, language, timeout, }: {
|
|
72
|
-
personalizeInfo: PersonalizeInfo;
|
|
73
|
-
params: ExperienceParams;
|
|
74
|
-
language: string;
|
|
75
|
-
timeout?: number;
|
|
76
|
-
}, request: NextRequest): Promise<{
|
|
77
|
-
variantId: string;
|
|
78
|
-
}>;
|
|
73
|
+
protected initializeEngageServer(hostName: string, site: SiteInfo, language: string): EngageServer;
|
|
79
74
|
protected getExperienceParams(req: NextRequest): ExperienceParams;
|
|
80
75
|
protected excludeRoute(pathname: string): boolean | undefined;
|
|
81
76
|
private handler;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { GraphQLClient,
|
|
1
|
+
import { GraphQLClient, PageInfo } from '@sitecore-jss/sitecore-jss/graphql';
|
|
2
2
|
/** @private */
|
|
3
3
|
export declare const languageError = "The list of languages cannot be empty";
|
|
4
4
|
export declare const siteError = "The service needs a site name";
|
|
@@ -68,24 +68,17 @@ export type RouteListQueryResult = {
|
|
|
68
68
|
export interface BaseGraphQLSitemapServiceConfig extends Omit<SiteRouteQueryVariables, 'language' | 'siteName'> {
|
|
69
69
|
/**
|
|
70
70
|
* Your Graphql endpoint
|
|
71
|
-
* @deprecated use @param clientFactory property instead
|
|
72
71
|
*/
|
|
73
|
-
endpoint
|
|
72
|
+
endpoint: string;
|
|
74
73
|
/**
|
|
75
74
|
* The API key to use for authentication.
|
|
76
|
-
* @deprecated use @param clientFactory property instead
|
|
77
75
|
*/
|
|
78
|
-
apiKey
|
|
76
|
+
apiKey: string;
|
|
79
77
|
/**
|
|
80
78
|
* A flag for whether to include personalized routes in service output - only works on XM Cloud
|
|
81
79
|
* turned off by default
|
|
82
80
|
*/
|
|
83
81
|
includePersonalizedRoutes?: boolean;
|
|
84
|
-
/**
|
|
85
|
-
* A GraphQL Request Client Factory is a function that accepts configuration and returns an instance of a GraphQLRequestClient.
|
|
86
|
-
* This factory function is used to create and configure GraphQL clients for making GraphQL API requests.
|
|
87
|
-
*/
|
|
88
|
-
clientFactory?: GraphQLRequestClientFactory;
|
|
89
82
|
}
|
|
90
83
|
/**
|
|
91
84
|
* Object model of a site page item.
|
package/context.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './types/context/index';
|
package/context.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
module.exports = require('./dist/cjs/context/index');
|
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Context = void 0;
|
|
4
|
-
/**
|
|
5
|
-
* Context instance that is used to initialize the application Context and associated Software Development Kits (SDKs).
|
|
6
|
-
*/
|
|
7
|
-
class Context {
|
|
8
|
-
constructor(props) {
|
|
9
|
-
this.props = props;
|
|
10
|
-
/**
|
|
11
|
-
* Indicates whether the Context and SDK(s) have been initialized
|
|
12
|
-
*/
|
|
13
|
-
this.isInitialized = false;
|
|
14
|
-
/**
|
|
15
|
-
* Software Development Kits (SDKs) to be initialized
|
|
16
|
-
*/
|
|
17
|
-
this.sdks = {};
|
|
18
|
-
/**
|
|
19
|
-
* Promises for the SDKs
|
|
20
|
-
*/
|
|
21
|
-
this.sdkPromises = {};
|
|
22
|
-
/**
|
|
23
|
-
* Retrieves the Software Development Kit (SDK) instance, ensuring it is initialized before returning
|
|
24
|
-
*
|
|
25
|
-
* @param {string} name SDK name
|
|
26
|
-
* @returns initialized SDK
|
|
27
|
-
*/
|
|
28
|
-
this.getSDK = (name) => {
|
|
29
|
-
return this.sdkPromises[name] || Promise.reject(`Unknown SDK '${String(name)}'`);
|
|
30
|
-
};
|
|
31
|
-
this.sitecoreEdgeUrl = props.sitecoreEdgeUrl;
|
|
32
|
-
this.sitecoreEdgeContextId = props.sitecoreEdgeContextId;
|
|
33
|
-
this.siteName = props.siteName;
|
|
34
|
-
}
|
|
35
|
-
init(props = {}) {
|
|
36
|
-
// Context and SDKs are initialized only once
|
|
37
|
-
if (this.isInitialized)
|
|
38
|
-
return;
|
|
39
|
-
this.isInitialized = true;
|
|
40
|
-
if (props.siteName) {
|
|
41
|
-
this.siteName = props.siteName;
|
|
42
|
-
}
|
|
43
|
-
// iterate over the SDKs and initialize them
|
|
44
|
-
for (const sdkName of Object.keys(this.props.sdks)) {
|
|
45
|
-
this.initSDK(sdkName);
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
/**
|
|
49
|
-
* Initializes the Software Development Kit (SDK)
|
|
50
|
-
*
|
|
51
|
-
* @param {T} name SDK name
|
|
52
|
-
* @returns {void}
|
|
53
|
-
*/
|
|
54
|
-
initSDK(name) {
|
|
55
|
-
this.sdkPromises[name] = new Promise((resolve) => {
|
|
56
|
-
this.props.sdks[name].init(this).then(() => {
|
|
57
|
-
this.sdks[name] = this.props.sdks[name].sdk;
|
|
58
|
-
resolve(this.sdks[name]);
|
|
59
|
-
});
|
|
60
|
-
});
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
exports.Context = Context;
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.QUERY_PARAM_PROTECTION_BYPASS_VERCEL = exports.QUERY_PARAM_PROTECTION_BYPASS_SITECORE = exports.QUERY_PARAM_EDITING_SECRET = void 0;
|
|
4
|
-
exports.QUERY_PARAM_EDITING_SECRET = 'secret';
|
|
5
|
-
exports.QUERY_PARAM_PROTECTION_BYPASS_SITECORE = 'x-sitecore-protection-bypass';
|
|
6
|
-
exports.QUERY_PARAM_PROTECTION_BYPASS_VERCEL = 'x-vercel-protection-bypass';
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getEdgeProxyContentUrl = exports.GraphQLRequestClient = void 0;
|
|
4
|
-
var graphql_1 = require("@sitecore-jss/sitecore-jss/graphql");
|
|
5
|
-
Object.defineProperty(exports, "GraphQLRequestClient", { enumerable: true, get: function () { return graphql_1.GraphQLRequestClient; } });
|
|
6
|
-
Object.defineProperty(exports, "getEdgeProxyContentUrl", { enumerable: true, get: function () { return graphql_1.getEdgeProxyContentUrl; } });
|
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Context instance that is used to initialize the application Context and associated Software Development Kits (SDKs).
|
|
3
|
-
*/
|
|
4
|
-
export class Context {
|
|
5
|
-
constructor(props) {
|
|
6
|
-
this.props = props;
|
|
7
|
-
/**
|
|
8
|
-
* Indicates whether the Context and SDK(s) have been initialized
|
|
9
|
-
*/
|
|
10
|
-
this.isInitialized = false;
|
|
11
|
-
/**
|
|
12
|
-
* Software Development Kits (SDKs) to be initialized
|
|
13
|
-
*/
|
|
14
|
-
this.sdks = {};
|
|
15
|
-
/**
|
|
16
|
-
* Promises for the SDKs
|
|
17
|
-
*/
|
|
18
|
-
this.sdkPromises = {};
|
|
19
|
-
/**
|
|
20
|
-
* Retrieves the Software Development Kit (SDK) instance, ensuring it is initialized before returning
|
|
21
|
-
*
|
|
22
|
-
* @param {string} name SDK name
|
|
23
|
-
* @returns initialized SDK
|
|
24
|
-
*/
|
|
25
|
-
this.getSDK = (name) => {
|
|
26
|
-
return this.sdkPromises[name] || Promise.reject(`Unknown SDK '${String(name)}'`);
|
|
27
|
-
};
|
|
28
|
-
this.sitecoreEdgeUrl = props.sitecoreEdgeUrl;
|
|
29
|
-
this.sitecoreEdgeContextId = props.sitecoreEdgeContextId;
|
|
30
|
-
this.siteName = props.siteName;
|
|
31
|
-
}
|
|
32
|
-
init(props = {}) {
|
|
33
|
-
// Context and SDKs are initialized only once
|
|
34
|
-
if (this.isInitialized)
|
|
35
|
-
return;
|
|
36
|
-
this.isInitialized = true;
|
|
37
|
-
if (props.siteName) {
|
|
38
|
-
this.siteName = props.siteName;
|
|
39
|
-
}
|
|
40
|
-
// iterate over the SDKs and initialize them
|
|
41
|
-
for (const sdkName of Object.keys(this.props.sdks)) {
|
|
42
|
-
this.initSDK(sdkName);
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
/**
|
|
46
|
-
* Initializes the Software Development Kit (SDK)
|
|
47
|
-
*
|
|
48
|
-
* @param {T} name SDK name
|
|
49
|
-
* @returns {void}
|
|
50
|
-
*/
|
|
51
|
-
initSDK(name) {
|
|
52
|
-
this.sdkPromises[name] = new Promise((resolve) => {
|
|
53
|
-
this.props.sdks[name].init(this).then(() => {
|
|
54
|
-
this.sdks[name] = this.props.sdks[name].sdk;
|
|
55
|
-
resolve(this.sdks[name]);
|
|
56
|
-
});
|
|
57
|
-
});
|
|
58
|
-
}
|
|
59
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { Context } from './context';
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { GraphQLRequestClient, getEdgeProxyContentUrl, } from '@sitecore-jss/sitecore-jss/graphql';
|
package/graphql.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './types/graphql/index';
|
package/graphql.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
module.exports = require('./dist/cjs/graphql/index');
|