@sitecore-jss/sitecore-jss-nextjs 22.2.0-canary.80 → 22.2.0-canary.81
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/index.js +2 -4
- package/dist/cjs/middleware/personalize-middleware.js +7 -4
- package/dist/esm/index.js +0 -1
- package/dist/esm/middleware/personalize-middleware.js +6 -3
- package/package.json +9 -8
- package/types/index.d.ts +0 -1
- package/context.d.ts +0 -1
- package/context.js +0 -1
- package/dist/cjs/context/context.js +0 -83
- package/dist/cjs/context/index.js +0 -5
- package/dist/esm/context/context.js +0 -79
- package/dist/esm/context/index.js +0 -1
- package/types/context/context.d.ts +0 -116
- package/types/context/index.d.ts +0 -1
package/dist/cjs/index.js
CHANGED
|
@@ -23,8 +23,8 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
23
23
|
return result;
|
|
24
24
|
};
|
|
25
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
-
exports.
|
|
27
|
-
exports.EditingScripts = exports.withEmptyFieldEditingComponent = exports.withFieldMetadata = exports.withDatasourceCheck = exports.withPlaceholder = exports.withEditorChromes = exports.useSitecoreContext = exports.withSitecoreContext = exports.SitecoreContextReactContext = exports.SitecoreContext = exports.VisitorIdentification = exports.DefaultEmptyFieldEditingComponentText = exports.DefaultEmptyFieldEditingComponentImage = exports.File = exports.getComponentLibraryStylesheetLinks = exports.BYOCComponent = exports.fetchFEaaSComponentServerProps =
|
|
26
|
+
exports.FEaaSComponent = exports.EditFrame = exports.DateField = exports.Text = exports.Image = exports.ComponentBuilder = exports.BYOCWrapper = exports.FEaaSWrapper = exports.NextImage = exports.Placeholder = exports.RichText = exports.Link = exports.useComponentProps = exports.ComponentPropsContext = exports.ComponentPropsReactContext = exports.normalizeSiteRewrite = exports.getSiteRewriteData = exports.getSiteRewrite = exports.GraphQLSiteInfoService = exports.SiteResolver = exports.GraphQLRobotsService = exports.GraphQLErrorPagesService = exports.GraphQLSitemapXmlService = exports.MultisiteGraphQLSitemapService = exports.GraphQLSitemapService = exports.DisconnectedSitemapService = exports.ComponentPropsService = exports.CdpHelper = exports.normalizePersonalizedRewrite = exports.getGroomedVariantIds = exports.getPersonalizedRewriteData = exports.getPersonalizedRewrite = exports.personalizeLayout = exports.RestDictionaryService = exports.GraphQLDictionaryService = exports.trackingApi = exports.mediaApi = exports.EditMode = exports.getContentStylesheetLink = exports.getFieldValue = exports.getChildPlaceholder = exports.RestLayoutService = exports.GraphQLLayoutService = exports.LayoutServicePageState = exports.MemoryCacheClient = exports.debug = exports.enableDebug = exports.NativeDataFetcher = exports.AxiosDataFetcher = exports.constants = void 0;
|
|
27
|
+
exports.EditingScripts = exports.withEmptyFieldEditingComponent = exports.withFieldMetadata = exports.withDatasourceCheck = exports.withPlaceholder = exports.withEditorChromes = exports.useSitecoreContext = exports.withSitecoreContext = exports.SitecoreContextReactContext = exports.SitecoreContext = exports.VisitorIdentification = exports.DefaultEmptyFieldEditingComponentText = exports.DefaultEmptyFieldEditingComponentImage = exports.File = exports.getComponentLibraryStylesheetLinks = exports.BYOCComponent = exports.fetchFEaaSComponentServerProps = void 0;
|
|
28
28
|
var sitecore_jss_1 = require("@sitecore-jss/sitecore-jss");
|
|
29
29
|
Object.defineProperty(exports, "constants", { enumerable: true, get: function () { return sitecore_jss_1.constants; } });
|
|
30
30
|
Object.defineProperty(exports, "AxiosDataFetcher", { enumerable: true, get: function () { return sitecore_jss_1.AxiosDataFetcher; } });
|
|
@@ -89,8 +89,6 @@ const BYOCWrapper = __importStar(require("./components/BYOCWrapper"));
|
|
|
89
89
|
exports.BYOCWrapper = BYOCWrapper;
|
|
90
90
|
var ComponentBuilder_1 = require("./ComponentBuilder");
|
|
91
91
|
Object.defineProperty(exports, "ComponentBuilder", { enumerable: true, get: function () { return ComponentBuilder_1.ComponentBuilder; } });
|
|
92
|
-
var context_1 = require("./context");
|
|
93
|
-
Object.defineProperty(exports, "Context", { enumerable: true, get: function () { return context_1.Context; } });
|
|
94
92
|
var sitecore_jss_react_1 = require("@sitecore-jss/sitecore-jss-react");
|
|
95
93
|
Object.defineProperty(exports, "Image", { enumerable: true, get: function () { return sitecore_jss_react_1.Image; } });
|
|
96
94
|
Object.defineProperty(exports, "Text", { enumerable: true, get: function () { return sitecore_jss_react_1.Text; } });
|
|
@@ -14,7 +14,8 @@ const server_1 = require("next/server");
|
|
|
14
14
|
const personalize_1 = require("@sitecore-jss/sitecore-jss/personalize");
|
|
15
15
|
const sitecore_jss_1 = require("@sitecore-jss/sitecore-jss");
|
|
16
16
|
const middleware_1 = require("./middleware");
|
|
17
|
-
const server_2 = require("@sitecore-cloudsdk/
|
|
17
|
+
const server_2 = require("@sitecore-cloudsdk/core/server");
|
|
18
|
+
const server_3 = require("@sitecore-cloudsdk/personalize/server");
|
|
18
19
|
/**
|
|
19
20
|
* Middleware / handler to support Sitecore Personalize
|
|
20
21
|
*/
|
|
@@ -136,20 +137,22 @@ class PersonalizeMiddleware extends middleware_1.MiddlewareBase {
|
|
|
136
137
|
}
|
|
137
138
|
initPersonalizeServer({ hostname, siteName, request, response, }) {
|
|
138
139
|
return __awaiter(this, void 0, void 0, function* () {
|
|
139
|
-
yield (0, server_2.
|
|
140
|
+
yield (0, server_2.CloudSDK)(request, response, {
|
|
140
141
|
sitecoreEdgeUrl: this.config.cdpConfig.sitecoreEdgeUrl,
|
|
141
142
|
sitecoreEdgeContextId: this.config.cdpConfig.sitecoreEdgeContextId,
|
|
142
143
|
siteName,
|
|
143
144
|
cookieDomain: hostname,
|
|
144
145
|
enableServerCookie: true,
|
|
145
|
-
})
|
|
146
|
+
})
|
|
147
|
+
.addPersonalize()
|
|
148
|
+
.initialize();
|
|
146
149
|
});
|
|
147
150
|
}
|
|
148
151
|
personalize({ params, friendlyId, language, timeout, variantIds, }, request) {
|
|
149
152
|
var _a;
|
|
150
153
|
return __awaiter(this, void 0, void 0, function* () {
|
|
151
154
|
sitecore_jss_1.debug.personalize('executing experience for %s %o', friendlyId, params);
|
|
152
|
-
return (yield (0,
|
|
155
|
+
return (yield (0, server_3.personalize)(request, {
|
|
153
156
|
channel: this.config.cdpConfig.channel || 'WEB',
|
|
154
157
|
currency: (_a = this.config.cdpConfig.currency) !== null && _a !== void 0 ? _a : 'USD',
|
|
155
158
|
friendlyId,
|
package/dist/esm/index.js
CHANGED
|
@@ -19,5 +19,4 @@ import * as BYOCWrapper from './components/BYOCWrapper';
|
|
|
19
19
|
export { FEaaSWrapper };
|
|
20
20
|
export { BYOCWrapper };
|
|
21
21
|
export { ComponentBuilder } from './ComponentBuilder';
|
|
22
|
-
export { Context } from './context';
|
|
23
22
|
export { Image, Text, DateField, EditFrame, FEaaSComponent, fetchFEaaSComponentServerProps, BYOCComponent, getComponentLibraryStylesheetLinks, File, DefaultEmptyFieldEditingComponentImage, DefaultEmptyFieldEditingComponentText, VisitorIdentification, SitecoreContext, SitecoreContextReactContext, withSitecoreContext, useSitecoreContext, withEditorChromes, withPlaceholder, withDatasourceCheck, withFieldMetadata, withEmptyFieldEditingComponent, EditingScripts, } from '@sitecore-jss/sitecore-jss-react';
|
|
@@ -11,7 +11,8 @@ import { NextResponse } from 'next/server';
|
|
|
11
11
|
import { GraphQLPersonalizeService, getPersonalizedRewrite, CdpHelper, DEFAULT_VARIANT, } 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 { CloudSDK } from '@sitecore-cloudsdk/core/server';
|
|
15
|
+
import { personalize } from '@sitecore-cloudsdk/personalize/server';
|
|
15
16
|
/**
|
|
16
17
|
* Middleware / handler to support Sitecore Personalize
|
|
17
18
|
*/
|
|
@@ -133,13 +134,15 @@ export class PersonalizeMiddleware extends MiddlewareBase {
|
|
|
133
134
|
}
|
|
134
135
|
initPersonalizeServer({ hostname, siteName, request, response, }) {
|
|
135
136
|
return __awaiter(this, void 0, void 0, function* () {
|
|
136
|
-
yield
|
|
137
|
+
yield CloudSDK(request, response, {
|
|
137
138
|
sitecoreEdgeUrl: this.config.cdpConfig.sitecoreEdgeUrl,
|
|
138
139
|
sitecoreEdgeContextId: this.config.cdpConfig.sitecoreEdgeContextId,
|
|
139
140
|
siteName,
|
|
140
141
|
cookieDomain: hostname,
|
|
141
142
|
enableServerCookie: true,
|
|
142
|
-
})
|
|
143
|
+
})
|
|
144
|
+
.addPersonalize()
|
|
145
|
+
.initialize();
|
|
143
146
|
});
|
|
144
147
|
}
|
|
145
148
|
personalize({ params, friendlyId, language, timeout, variantIds, }, request) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sitecore-jss/sitecore-jss-nextjs",
|
|
3
|
-
"version": "22.2.0-canary.
|
|
3
|
+
"version": "22.2.0-canary.81",
|
|
4
4
|
"main": "dist/cjs/index.js",
|
|
5
5
|
"module": "dist/esm/index.js",
|
|
6
6
|
"sideEffects": false,
|
|
@@ -29,7 +29,8 @@
|
|
|
29
29
|
"url": "https://github.com/sitecore/jss/issues"
|
|
30
30
|
},
|
|
31
31
|
"devDependencies": {
|
|
32
|
-
"@sitecore-cloudsdk/
|
|
32
|
+
"@sitecore-cloudsdk/core": "^0.4.0",
|
|
33
|
+
"@sitecore-cloudsdk/personalize": "^0.4.0",
|
|
33
34
|
"@types/chai": "^4.3.4",
|
|
34
35
|
"@types/chai-as-promised": "^7.1.5",
|
|
35
36
|
"@types/chai-string": "^1.4.2",
|
|
@@ -65,16 +66,16 @@
|
|
|
65
66
|
"typescript": "~4.9.4"
|
|
66
67
|
},
|
|
67
68
|
"peerDependencies": {
|
|
68
|
-
"@sitecore-cloudsdk/
|
|
69
|
-
"@sitecore-cloudsdk/personalize": "^0.
|
|
69
|
+
"@sitecore-cloudsdk/core": "^0.4.0",
|
|
70
|
+
"@sitecore-cloudsdk/personalize": "^0.4.0",
|
|
70
71
|
"next": "^14.2.7",
|
|
71
72
|
"react": "^18.2.0",
|
|
72
73
|
"react-dom": "^18.2.0"
|
|
73
74
|
},
|
|
74
75
|
"dependencies": {
|
|
75
|
-
"@sitecore-jss/sitecore-jss": "^22.2.0-canary.
|
|
76
|
-
"@sitecore-jss/sitecore-jss-dev-tools": "^22.2.0-canary.
|
|
77
|
-
"@sitecore-jss/sitecore-jss-react": "^22.2.0-canary.
|
|
76
|
+
"@sitecore-jss/sitecore-jss": "^22.2.0-canary.81",
|
|
77
|
+
"@sitecore-jss/sitecore-jss-dev-tools": "^22.2.0-canary.81",
|
|
78
|
+
"@sitecore-jss/sitecore-jss-react": "^22.2.0-canary.81",
|
|
78
79
|
"@vercel/kv": "^0.2.1",
|
|
79
80
|
"prop-types": "^15.8.1",
|
|
80
81
|
"regex-parser": "^2.2.11",
|
|
@@ -82,7 +83,7 @@
|
|
|
82
83
|
},
|
|
83
84
|
"description": "",
|
|
84
85
|
"types": "types/index.d.ts",
|
|
85
|
-
"gitHead": "
|
|
86
|
+
"gitHead": "8b710877973ac2dedbf09cb4dffc62bb85bbc6dd",
|
|
86
87
|
"files": [
|
|
87
88
|
"dist",
|
|
88
89
|
"types",
|
package/types/index.d.ts
CHANGED
|
@@ -22,5 +22,4 @@ import * as BYOCWrapper from './components/BYOCWrapper';
|
|
|
22
22
|
export { FEaaSWrapper };
|
|
23
23
|
export { BYOCWrapper };
|
|
24
24
|
export { ComponentBuilder, ComponentBuilderConfig } from './ComponentBuilder';
|
|
25
|
-
export { Context, ContextConfig, SDK } from './context';
|
|
26
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';
|
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,83 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Context = void 0;
|
|
4
|
-
const sitecore_jss_react_1 = require("@sitecore-jss/sitecore-jss-react");
|
|
5
|
-
/**
|
|
6
|
-
* Context instance that is used to initialize the application Context and associated Software Development Kits (SDKs).
|
|
7
|
-
*/
|
|
8
|
-
class Context {
|
|
9
|
-
constructor(props) {
|
|
10
|
-
this.props = props;
|
|
11
|
-
/**
|
|
12
|
-
* Indicates whether the Context and SDK(s) have been initialized
|
|
13
|
-
*/
|
|
14
|
-
this.isInitialized = false;
|
|
15
|
-
/**
|
|
16
|
-
* Software Development Kits (SDKs) to be initialized
|
|
17
|
-
*/
|
|
18
|
-
this.sdks = {};
|
|
19
|
-
/**
|
|
20
|
-
* Promises for the SDKs
|
|
21
|
-
*/
|
|
22
|
-
this.sdkPromises = {};
|
|
23
|
-
this.sdkErrors = {};
|
|
24
|
-
/**
|
|
25
|
-
* Retrieves the Software Development Kit (SDK) instance, ensuring it is initialized before returning
|
|
26
|
-
*
|
|
27
|
-
* @param {string} name SDK name
|
|
28
|
-
* @returns initialized SDK
|
|
29
|
-
*/
|
|
30
|
-
this.getSDK = (name) => {
|
|
31
|
-
if (!this.sdkPromises[name]) {
|
|
32
|
-
return Promise.reject(`Unknown SDK '${String(name)}'`);
|
|
33
|
-
}
|
|
34
|
-
else {
|
|
35
|
-
return this.sdkPromises[name].then((result) => {
|
|
36
|
-
return ((this.sdkErrors[name] && Promise.reject(this.sdkErrors[name])) || Promise.resolve(result));
|
|
37
|
-
});
|
|
38
|
-
}
|
|
39
|
-
};
|
|
40
|
-
this.sitecoreEdgeUrl = props.sitecoreEdgeUrl;
|
|
41
|
-
this.sitecoreEdgeContextId = props.sitecoreEdgeContextId;
|
|
42
|
-
this.siteName = props.siteName;
|
|
43
|
-
this.pageState = sitecore_jss_react_1.LayoutServicePageState.Normal;
|
|
44
|
-
}
|
|
45
|
-
init(props = {}) {
|
|
46
|
-
// Context and SDKs are initialized only once
|
|
47
|
-
if (this.isInitialized)
|
|
48
|
-
return;
|
|
49
|
-
this.isInitialized = true;
|
|
50
|
-
if (props.siteName) {
|
|
51
|
-
this.siteName = props.siteName;
|
|
52
|
-
}
|
|
53
|
-
if (props.pageState) {
|
|
54
|
-
this.pageState = props.pageState;
|
|
55
|
-
}
|
|
56
|
-
// iterate over the SDKs and initialize them
|
|
57
|
-
for (const sdkName of Object.keys(this.props.sdks)) {
|
|
58
|
-
this.initSDK(sdkName);
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
/**
|
|
62
|
-
* Initializes the Software Development Kit (SDK)
|
|
63
|
-
*
|
|
64
|
-
* @param {T} name SDK name
|
|
65
|
-
* @returns {void}
|
|
66
|
-
*/
|
|
67
|
-
initSDK(name) {
|
|
68
|
-
this.sdkPromises[name] = new Promise((resolve) => {
|
|
69
|
-
this.props.sdks[name]
|
|
70
|
-
.init(this)
|
|
71
|
-
.then(() => {
|
|
72
|
-
this.sdks[name] = this.props.sdks[name].sdk;
|
|
73
|
-
resolve(this.sdks[name]);
|
|
74
|
-
})
|
|
75
|
-
.catch((e) => {
|
|
76
|
-
// if init rejects, we mark SDK as failed - so getSDK call would reject with a reason
|
|
77
|
-
this.sdkErrors[name] = e;
|
|
78
|
-
resolve(undefined);
|
|
79
|
-
});
|
|
80
|
-
});
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
exports.Context = Context;
|
|
@@ -1,79 +0,0 @@
|
|
|
1
|
-
import { LayoutServicePageState } from '@sitecore-jss/sitecore-jss-react';
|
|
2
|
-
/**
|
|
3
|
-
* Context instance that is used to initialize the application Context and associated Software Development Kits (SDKs).
|
|
4
|
-
*/
|
|
5
|
-
export class Context {
|
|
6
|
-
constructor(props) {
|
|
7
|
-
this.props = props;
|
|
8
|
-
/**
|
|
9
|
-
* Indicates whether the Context and SDK(s) have been initialized
|
|
10
|
-
*/
|
|
11
|
-
this.isInitialized = false;
|
|
12
|
-
/**
|
|
13
|
-
* Software Development Kits (SDKs) to be initialized
|
|
14
|
-
*/
|
|
15
|
-
this.sdks = {};
|
|
16
|
-
/**
|
|
17
|
-
* Promises for the SDKs
|
|
18
|
-
*/
|
|
19
|
-
this.sdkPromises = {};
|
|
20
|
-
this.sdkErrors = {};
|
|
21
|
-
/**
|
|
22
|
-
* Retrieves the Software Development Kit (SDK) instance, ensuring it is initialized before returning
|
|
23
|
-
*
|
|
24
|
-
* @param {string} name SDK name
|
|
25
|
-
* @returns initialized SDK
|
|
26
|
-
*/
|
|
27
|
-
this.getSDK = (name) => {
|
|
28
|
-
if (!this.sdkPromises[name]) {
|
|
29
|
-
return Promise.reject(`Unknown SDK '${String(name)}'`);
|
|
30
|
-
}
|
|
31
|
-
else {
|
|
32
|
-
return this.sdkPromises[name].then((result) => {
|
|
33
|
-
return ((this.sdkErrors[name] && Promise.reject(this.sdkErrors[name])) || Promise.resolve(result));
|
|
34
|
-
});
|
|
35
|
-
}
|
|
36
|
-
};
|
|
37
|
-
this.sitecoreEdgeUrl = props.sitecoreEdgeUrl;
|
|
38
|
-
this.sitecoreEdgeContextId = props.sitecoreEdgeContextId;
|
|
39
|
-
this.siteName = props.siteName;
|
|
40
|
-
this.pageState = LayoutServicePageState.Normal;
|
|
41
|
-
}
|
|
42
|
-
init(props = {}) {
|
|
43
|
-
// Context and SDKs are initialized only once
|
|
44
|
-
if (this.isInitialized)
|
|
45
|
-
return;
|
|
46
|
-
this.isInitialized = true;
|
|
47
|
-
if (props.siteName) {
|
|
48
|
-
this.siteName = props.siteName;
|
|
49
|
-
}
|
|
50
|
-
if (props.pageState) {
|
|
51
|
-
this.pageState = props.pageState;
|
|
52
|
-
}
|
|
53
|
-
// iterate over the SDKs and initialize them
|
|
54
|
-
for (const sdkName of Object.keys(this.props.sdks)) {
|
|
55
|
-
this.initSDK(sdkName);
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
/**
|
|
59
|
-
* Initializes the Software Development Kit (SDK)
|
|
60
|
-
*
|
|
61
|
-
* @param {T} name SDK name
|
|
62
|
-
* @returns {void}
|
|
63
|
-
*/
|
|
64
|
-
initSDK(name) {
|
|
65
|
-
this.sdkPromises[name] = new Promise((resolve) => {
|
|
66
|
-
this.props.sdks[name]
|
|
67
|
-
.init(this)
|
|
68
|
-
.then(() => {
|
|
69
|
-
this.sdks[name] = this.props.sdks[name].sdk;
|
|
70
|
-
resolve(this.sdks[name]);
|
|
71
|
-
})
|
|
72
|
-
.catch((e) => {
|
|
73
|
-
// if init rejects, we mark SDK as failed - so getSDK call would reject with a reason
|
|
74
|
-
this.sdkErrors[name] = e;
|
|
75
|
-
resolve(undefined);
|
|
76
|
-
});
|
|
77
|
-
});
|
|
78
|
-
}
|
|
79
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { Context } from './context';
|
|
@@ -1,116 +0,0 @@
|
|
|
1
|
-
import { LayoutServicePageState } from '@sitecore-jss/sitecore-jss-react';
|
|
2
|
-
/**
|
|
3
|
-
* Software Development Kit (SDK) instance
|
|
4
|
-
*/
|
|
5
|
-
export type SDK<SDKType = unknown> = {
|
|
6
|
-
/**
|
|
7
|
-
* The Software Development Kit (SDK) library instance
|
|
8
|
-
*/
|
|
9
|
-
sdk: SDKType;
|
|
10
|
-
/**
|
|
11
|
-
* Initializes the Software Development Kit (SDK)
|
|
12
|
-
*/
|
|
13
|
-
init: (props: InitSDKProps) => Promise<void>;
|
|
14
|
-
};
|
|
15
|
-
/**
|
|
16
|
-
* Software Development Kits (SDKs) to be initialized
|
|
17
|
-
*/
|
|
18
|
-
type SDKModulesType = Record<string, SDK>;
|
|
19
|
-
/**
|
|
20
|
-
* Properties that are passed to the Context.
|
|
21
|
-
*/
|
|
22
|
-
export interface ContextInitProps {
|
|
23
|
-
/**
|
|
24
|
-
* Your Sitecore site name
|
|
25
|
-
*/
|
|
26
|
-
siteName?: string;
|
|
27
|
-
/**
|
|
28
|
-
* Sitecore page state (normal, preview, edit)
|
|
29
|
-
*/
|
|
30
|
-
pageState?: LayoutServicePageState;
|
|
31
|
-
}
|
|
32
|
-
/**
|
|
33
|
-
* Configuration that is passed to the Context.
|
|
34
|
-
*/
|
|
35
|
-
export interface ContextConfig<SDKModules extends SDKModulesType> {
|
|
36
|
-
/**
|
|
37
|
-
* Your Sitecore Edge URL
|
|
38
|
-
*/
|
|
39
|
-
sitecoreEdgeUrl: string;
|
|
40
|
-
/**
|
|
41
|
-
* Your Sitecore Edge Context ID
|
|
42
|
-
*/
|
|
43
|
-
sitecoreEdgeContextId: string;
|
|
44
|
-
/**
|
|
45
|
-
* Your Sitecore site name
|
|
46
|
-
*/
|
|
47
|
-
siteName: string;
|
|
48
|
-
/**
|
|
49
|
-
* Software Development Kits (SDKs) to be initialized
|
|
50
|
-
*/
|
|
51
|
-
sdks: {
|
|
52
|
-
[module in keyof SDKModules]: SDKModules[module];
|
|
53
|
-
};
|
|
54
|
-
}
|
|
55
|
-
/**
|
|
56
|
-
* Properties that are passed to the Software Development Kit (SDK) initialization function.
|
|
57
|
-
*/
|
|
58
|
-
type InitSDKProps = Omit<ContextConfig<SDKModulesType>, 'sdks'>;
|
|
59
|
-
/**
|
|
60
|
-
* Context instance that is used to initialize the application Context and associated Software Development Kits (SDKs).
|
|
61
|
-
*/
|
|
62
|
-
export declare class Context<SDKModules extends SDKModulesType> {
|
|
63
|
-
protected props: ContextConfig<SDKModules>;
|
|
64
|
-
/**
|
|
65
|
-
* Indicates whether the Context and SDK(s) have been initialized
|
|
66
|
-
*/
|
|
67
|
-
isInitialized: boolean;
|
|
68
|
-
/**
|
|
69
|
-
* The Sitecore Edge URL
|
|
70
|
-
*/
|
|
71
|
-
readonly sitecoreEdgeUrl: string;
|
|
72
|
-
/**
|
|
73
|
-
* The Sitecore Edge Context ID
|
|
74
|
-
*/
|
|
75
|
-
readonly sitecoreEdgeContextId: string;
|
|
76
|
-
/**
|
|
77
|
-
* The Sitecore site name
|
|
78
|
-
*/
|
|
79
|
-
siteName: string;
|
|
80
|
-
/**
|
|
81
|
-
* Sitecore page state (normal, preview, edit)
|
|
82
|
-
*/
|
|
83
|
-
pageState: LayoutServicePageState;
|
|
84
|
-
/**
|
|
85
|
-
* Software Development Kits (SDKs) to be initialized
|
|
86
|
-
*/
|
|
87
|
-
readonly sdks: {
|
|
88
|
-
[module in keyof SDKModules]?: SDKModules[module]['sdk'];
|
|
89
|
-
};
|
|
90
|
-
/**
|
|
91
|
-
* Promises for the SDKs
|
|
92
|
-
*/
|
|
93
|
-
protected sdkPromises: {
|
|
94
|
-
[module in keyof SDKModules]?: Promise<SDKModules[module]['sdk']>;
|
|
95
|
-
};
|
|
96
|
-
protected sdkErrors: {
|
|
97
|
-
[module in keyof SDKModules]?: string;
|
|
98
|
-
};
|
|
99
|
-
constructor(props: ContextConfig<SDKModules>);
|
|
100
|
-
init(props?: ContextInitProps): void;
|
|
101
|
-
/**
|
|
102
|
-
* Retrieves the Software Development Kit (SDK) instance, ensuring it is initialized before returning
|
|
103
|
-
*
|
|
104
|
-
* @param {string} name SDK name
|
|
105
|
-
* @returns initialized SDK
|
|
106
|
-
*/
|
|
107
|
-
getSDK: <T extends keyof SDKModules>(name: T) => Promise<SDKModules[T]["sdk"]>;
|
|
108
|
-
/**
|
|
109
|
-
* Initializes the Software Development Kit (SDK)
|
|
110
|
-
*
|
|
111
|
-
* @param {T} name SDK name
|
|
112
|
-
* @returns {void}
|
|
113
|
-
*/
|
|
114
|
-
protected initSDK<T extends keyof SDKModules>(name: T): void;
|
|
115
|
-
}
|
|
116
|
-
export {};
|
package/types/context/index.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { Context, ContextConfig, SDK } from './context';
|