@sitecore-content-sdk/content 2.0.0-canary.10 → 2.0.0-canary.13
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/client/sitecore-client.js +3 -5
- package/dist/cjs/config/define-config.js +4 -4
- package/dist/cjs/constants.js +1 -5
- package/dist/cjs/editing/codegen/preview.js +2 -2
- package/dist/cjs/editing/component-layout-service.js +2 -2
- package/dist/cjs/editing/design-library.js +2 -1
- package/dist/cjs/form/form.js +7 -5
- package/dist/cjs/i18n/dictionary-service.js +4 -6
- package/dist/cjs/site/error-pages-service.js +3 -2
- package/dist/cjs/site/redirects-service.js +2 -2
- package/dist/cjs/site/robots-service.js +3 -2
- package/dist/cjs/site/site-resolver.js +3 -1
- package/dist/cjs/site/sitemap-xml-service.js +3 -2
- package/dist/cjs/site/sitepath-service.js +5 -4
- package/dist/cjs/tools/codegen/component-generation.js +3 -3
- package/dist/cjs/tools/codegen/extract-files.js +4 -3
- package/dist/cjs/tools/codegen/import-map.js +3 -1
- package/dist/cjs/tools/codegen/utils.js +2 -1
- package/dist/cjs/tools/generateSites.js +4 -2
- package/dist/esm/client/sitecore-client.js +4 -6
- package/dist/esm/config/define-config.js +5 -5
- package/dist/esm/constants.js +0 -4
- package/dist/esm/editing/codegen/preview.js +2 -2
- package/dist/esm/editing/component-layout-service.js +2 -2
- package/dist/esm/editing/design-library.js +2 -1
- package/dist/esm/form/form.js +6 -4
- package/dist/esm/i18n/dictionary-service.js +4 -6
- package/dist/esm/site/error-pages-service.js +3 -2
- package/dist/esm/site/redirects-service.js +3 -3
- package/dist/esm/site/robots-service.js +3 -2
- package/dist/esm/site/site-resolver.js +3 -1
- package/dist/esm/site/sitemap-xml-service.js +3 -2
- package/dist/esm/site/sitepath-service.js +4 -3
- package/dist/esm/tools/codegen/component-generation.js +3 -3
- package/dist/esm/tools/codegen/extract-files.js +5 -4
- package/dist/esm/tools/codegen/import-map.js +3 -1
- package/dist/esm/tools/codegen/utils.js +3 -2
- package/dist/esm/tools/generateSites.js +4 -2
- package/package.json +5 -5
- package/types/client/sitecore-client.d.ts.map +1 -1
- package/types/config/define-config.d.ts.map +1 -1
- package/types/constants.d.ts +0 -4
- package/types/constants.d.ts.map +1 -1
- package/types/editing/codegen/preview.d.ts.map +1 -1
- package/types/editing/component-layout-service.d.ts.map +1 -1
- package/types/editing/design-library.d.ts.map +1 -1
- package/types/form/form.d.ts.map +1 -1
- package/types/i18n/dictionary-service.d.ts +0 -2
- package/types/i18n/dictionary-service.d.ts.map +1 -1
- package/types/site/error-pages-service.d.ts.map +1 -1
- package/types/site/redirects-service.d.ts.map +1 -1
- package/types/site/robots-service.d.ts.map +1 -1
- package/types/site/site-resolver.d.ts.map +1 -1
- package/types/site/sitemap-xml-service.d.ts.map +1 -1
- package/types/site/sitepath-service.d.ts +0 -1
- package/types/site/sitepath-service.d.ts.map +1 -1
- package/types/tools/codegen/component-generation.d.ts.map +1 -1
- package/types/tools/codegen/extract-files.d.ts.map +1 -1
- package/types/tools/codegen/import-map.d.ts.map +1 -1
- package/types/tools/codegen/utils.d.ts.map +1 -1
- package/types/tools/generateSites.d.ts.map +1 -1
|
@@ -12,6 +12,7 @@ const utils_2 = require("./utils");
|
|
|
12
12
|
const robots_service_1 = require("../site/robots-service");
|
|
13
13
|
const models_1 = require("../editing/models");
|
|
14
14
|
const editing_1 = require("../editing");
|
|
15
|
+
const { ERROR_MESSAGES } = core_1.constants;
|
|
15
16
|
/**
|
|
16
17
|
* Error page codes
|
|
17
18
|
* @public
|
|
@@ -179,7 +180,7 @@ class SitecoreClient {
|
|
|
179
180
|
mode,
|
|
180
181
|
}, fetchOptions);
|
|
181
182
|
if (!data) {
|
|
182
|
-
throw new Error(`Unable to fetch editing data for preview ${JSON.stringify(previewData)}`);
|
|
183
|
+
throw new Error(`Unable to fetch editing data for preview ${JSON.stringify(previewData)}. ${ERROR_MESSAGES.CONTACT_SUPPORT}`);
|
|
183
184
|
}
|
|
184
185
|
let layout = data.layoutData;
|
|
185
186
|
const personalizeData = (0, utils_1.getGroomedVariantIds)(variantIds);
|
|
@@ -201,9 +202,6 @@ class SitecoreClient {
|
|
|
201
202
|
*/
|
|
202
203
|
async getDesignLibraryData(designLibData, fetchOptions) {
|
|
203
204
|
var _a;
|
|
204
|
-
if (!this.initOptions.api.local) {
|
|
205
|
-
throw new Error('Component Library requires Sitecore apiHost and apiKey to be provided');
|
|
206
|
-
}
|
|
207
205
|
const { itemId, componentUid, site, language, renderingId, dataSourceId, version, mode, generation, } = designLibData;
|
|
208
206
|
const componentData = await this.componentService.fetchComponentData(Object.assign({ siteName: site, itemId,
|
|
209
207
|
language,
|
|
@@ -213,7 +211,7 @@ class SitecoreClient {
|
|
|
213
211
|
version,
|
|
214
212
|
mode }, (generation ? { generation } : {})), fetchOptions);
|
|
215
213
|
if (!componentData) {
|
|
216
|
-
throw new Error(`Unable to fetch editing data for preview ${JSON.stringify(designLibData)}`);
|
|
214
|
+
throw new Error(`Unable to fetch editing data for preview ${JSON.stringify(designLibData)}. ${ERROR_MESSAGES.CONTACT_SUPPORT}`);
|
|
217
215
|
}
|
|
218
216
|
const layout = this.applyContentRewrite(componentData);
|
|
219
217
|
const page = {
|
|
@@ -5,6 +5,7 @@ exports.deepMerge = deepMerge;
|
|
|
5
5
|
const core_1 = require("@sitecore-content-sdk/core");
|
|
6
6
|
const tools_1 = require("@sitecore-content-sdk/core/tools");
|
|
7
7
|
const config_cli_1 = require("../config-cli");
|
|
8
|
+
const { ERROR_MESSAGES } = core_1.constants;
|
|
8
9
|
/**
|
|
9
10
|
* Provides default initial values for SitecoreConfig
|
|
10
11
|
* @returns default config
|
|
@@ -120,12 +121,12 @@ const validateApiConfiguration = (config) => {
|
|
|
120
121
|
// Server-side: allow Edge OR Local; clientContextId alone is NOT sufficient
|
|
121
122
|
if (!isBrowser) {
|
|
122
123
|
if (!hasEdgeContextId && !hasLocalCreds) {
|
|
123
|
-
throw new Error(
|
|
124
|
+
throw new Error(ERROR_MESSAGES.MV_007);
|
|
124
125
|
}
|
|
125
126
|
if (hasEdgeContextId && !hasClientContextId) {
|
|
126
127
|
// eslint-disable-next-line no-console
|
|
127
128
|
if (process.env.NODE_ENV === 'development') {
|
|
128
|
-
console.warn(
|
|
129
|
+
console.warn(ERROR_MESSAGES.MV_006);
|
|
129
130
|
}
|
|
130
131
|
}
|
|
131
132
|
return; // validation complete on the server
|
|
@@ -134,8 +135,7 @@ const validateApiConfiguration = (config) => {
|
|
|
134
135
|
if (isBrowser && !hasClientContextId) {
|
|
135
136
|
// eslint-disable-next-line no-console
|
|
136
137
|
if (process.env.NODE_ENV === 'development') {
|
|
137
|
-
console.warn(
|
|
138
|
-
Client Side functionalities (like Tracking and Personalization) may be limited.`);
|
|
138
|
+
console.warn(ERROR_MESSAGES.MV_006);
|
|
139
139
|
}
|
|
140
140
|
}
|
|
141
141
|
};
|
package/dist/cjs/constants.js
CHANGED
|
@@ -1,10 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.HIDDEN_RENDERING_NAME =
|
|
4
|
-
/** @private */
|
|
5
|
-
exports.siteNameError = 'The site name must be a non-empty string';
|
|
6
|
-
/** @private */
|
|
7
|
-
exports.languageError = 'The language must be a non-empty string';
|
|
3
|
+
exports.HIDDEN_RENDERING_NAME = void 0;
|
|
8
4
|
/**
|
|
9
5
|
* Hidden rendering name
|
|
10
6
|
* @internal
|
|
@@ -15,7 +15,7 @@ exports.fetchGeneratedComponentFromCache = fetchGeneratedComponentFromCache;
|
|
|
15
15
|
const core_1 = require("@sitecore-content-sdk/core");
|
|
16
16
|
const design_library_1 = require("../design-library");
|
|
17
17
|
const debug_1 = __importDefault(require("../../debug"));
|
|
18
|
-
const { SITECORE_EDGE_PLATFORM_URL_DEFAULT } = core_1.constants;
|
|
18
|
+
const { SITECORE_EDGE_PLATFORM_URL_DEFAULT, ERROR_MESSAGES } = core_1.constants;
|
|
19
19
|
/**
|
|
20
20
|
* Event to send import map to design library
|
|
21
21
|
*/
|
|
@@ -299,7 +299,7 @@ function isImportEntryInfoArray(data) {
|
|
|
299
299
|
*/
|
|
300
300
|
const sendErrorEvent = (uid, error, type) => {
|
|
301
301
|
const errorEvent = getDesignLibraryErrorEvent(uid, error, type);
|
|
302
|
-
console.error(
|
|
302
|
+
console.error(`Component Library: sending error event. ${ERROR_MESSAGES.CONTACT_SUPPORT}`, errorEvent);
|
|
303
303
|
if (typeof window !== 'undefined') {
|
|
304
304
|
const target = window.parent && window.parent !== window ? window.parent : window;
|
|
305
305
|
target.postMessage(errorEvent, '*');
|
|
@@ -8,6 +8,7 @@ const core_1 = require("@sitecore-content-sdk/core");
|
|
|
8
8
|
const tools_1 = require("@sitecore-content-sdk/core/tools");
|
|
9
9
|
const debug_1 = __importDefault(require("../debug"));
|
|
10
10
|
const models_1 = require("./models");
|
|
11
|
+
const { ERROR_MESSAGES } = core_1.constants;
|
|
11
12
|
/**
|
|
12
13
|
* REST service that enables Design Library functionality.
|
|
13
14
|
* Returns layout data for a single rendered component.
|
|
@@ -21,8 +22,7 @@ class ComponentLayoutService {
|
|
|
21
22
|
// Choose the correct Edge ID per environment
|
|
22
23
|
const sitecoreContextId = this.config.contextId || this.config.clientContextId;
|
|
23
24
|
if (!sitecoreContextId) {
|
|
24
|
-
throw new Error(
|
|
25
|
-
Provide contextId on the server, and clientContextId in the browser if you need to full client-side functionality.`);
|
|
25
|
+
throw new Error(ERROR_MESSAGES.MV_001);
|
|
26
26
|
}
|
|
27
27
|
const fetcher = new core_1.NativeDataFetcher({ debugger: debug_1.default.layout });
|
|
28
28
|
debug_1.default.layout('fetching component with uid %s for %s %s %s %s', params.componentUid, params.itemId, params.language, params.siteName, params.dataSourceId);
|
|
@@ -7,6 +7,7 @@ exports.isDesignLibraryMode = isDesignLibraryMode;
|
|
|
7
7
|
const core_1 = require("@sitecore-content-sdk/core");
|
|
8
8
|
const tools_1 = require("@sitecore-content-sdk/core/tools");
|
|
9
9
|
const models_1 = require("./models");
|
|
10
|
+
const { ERROR_MESSAGES } = core_1.constants;
|
|
10
11
|
/**
|
|
11
12
|
* Event to be sent when report status to design library
|
|
12
13
|
*/
|
|
@@ -185,7 +186,7 @@ const postToDesignLibrary = (evt) => {
|
|
|
185
186
|
target.postMessage(evt, '*');
|
|
186
187
|
}
|
|
187
188
|
catch (err) {
|
|
188
|
-
console.error(
|
|
189
|
+
console.error(`Component Library: postMessage failed. ${ERROR_MESSAGES.CONTACT_SUPPORT}`, err, evt);
|
|
189
190
|
}
|
|
190
191
|
};
|
|
191
192
|
exports.postToDesignLibrary = postToDesignLibrary;
|
package/dist/cjs/form/form.js
CHANGED
|
@@ -4,9 +4,11 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.subscribeToFormSubmitEvent = exports.executeScriptElements = exports.loadForm = void 0;
|
|
7
|
-
const
|
|
7
|
+
const events_1 = require("@sitecore-content-sdk/events");
|
|
8
|
+
const core_1 = require("@sitecore-content-sdk/core");
|
|
8
9
|
const client_1 = require("../client");
|
|
9
10
|
const debug_1 = __importDefault(require("../debug"));
|
|
11
|
+
const { ERROR_MESSAGES } = core_1.constants;
|
|
10
12
|
/**
|
|
11
13
|
* Fetches the form markup from the Sitecore Edge service and renders it in the component's template.
|
|
12
14
|
* @param {string} contextId - The unique identifier of the current context
|
|
@@ -16,7 +18,7 @@ const debug_1 = __importDefault(require("../debug"));
|
|
|
16
18
|
*/
|
|
17
19
|
const loadForm = async (contextId, formId, edgeUrl) => {
|
|
18
20
|
if (!contextId) {
|
|
19
|
-
debug_1.default.form(
|
|
21
|
+
debug_1.default.form(`${ERROR_MESSAGES.MV_001}. Form was not able to render.`);
|
|
20
22
|
return '';
|
|
21
23
|
}
|
|
22
24
|
const url = (0, client_1.getEdgeProxyFormsUrl)(contextId, formId, edgeUrl);
|
|
@@ -27,14 +29,14 @@ const loadForm = async (contextId, formId, edgeUrl) => {
|
|
|
27
29
|
cache: 'no-cache',
|
|
28
30
|
});
|
|
29
31
|
if (rsp.status !== 200) {
|
|
30
|
-
throw new Error(
|
|
32
|
+
throw new Error(`Failed to fetch form data. ${ERROR_MESSAGES.CONTACT_SUPPORT}`);
|
|
31
33
|
}
|
|
32
34
|
const content = await rsp.text();
|
|
33
35
|
debug_1.default.form(`Form data fetch response: ${content}`);
|
|
34
36
|
return content;
|
|
35
37
|
}
|
|
36
38
|
catch (error) {
|
|
37
|
-
debug_1.default.form(`Form '${formId}' was not able to render`, error);
|
|
39
|
+
debug_1.default.form(`Form '${formId}' was not able to render. ${ERROR_MESSAGES.CONTACT_SUPPORT}`, error);
|
|
38
40
|
throw error;
|
|
39
41
|
}
|
|
40
42
|
};
|
|
@@ -74,7 +76,7 @@ const subscribeToFormSubmitEvent = (formElement, componentId) => {
|
|
|
74
76
|
const { formId, name } = e.detail;
|
|
75
77
|
if (formId && name) {
|
|
76
78
|
debug_1.default.form('Sending form event', formId, name);
|
|
77
|
-
(0,
|
|
79
|
+
(0, events_1.form)(formId, name, (componentId === null || componentId === void 0 ? void 0 : componentId.replace(/-/g, '')) || '');
|
|
78
80
|
}
|
|
79
81
|
}));
|
|
80
82
|
};
|
|
@@ -3,12 +3,10 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.DictionaryService =
|
|
6
|
+
exports.DictionaryService = void 0;
|
|
7
7
|
const core_1 = require("@sitecore-content-sdk/core");
|
|
8
|
-
const constants_1 = require("../constants");
|
|
9
8
|
const debug_1 = __importDefault(require("../debug"));
|
|
10
|
-
|
|
11
|
-
exports.queryError = 'Valid value for rootItemId not provided and failed to auto-resolve app root item.';
|
|
9
|
+
const { ERROR_MESSAGES } = core_1.constants;
|
|
12
10
|
/** @default */
|
|
13
11
|
const siteQuery = /* GraphQL */ `
|
|
14
12
|
query DictionarySiteQuery(
|
|
@@ -71,10 +69,10 @@ class DictionaryService {
|
|
|
71
69
|
let hasNext = true;
|
|
72
70
|
let after = '';
|
|
73
71
|
if (!site) {
|
|
74
|
-
throw new RangeError(
|
|
72
|
+
throw new RangeError(ERROR_MESSAGES.MV_002);
|
|
75
73
|
}
|
|
76
74
|
if (!language) {
|
|
77
|
-
throw new RangeError(
|
|
75
|
+
throw new RangeError(ERROR_MESSAGES.MV_009);
|
|
78
76
|
}
|
|
79
77
|
while (hasNext) {
|
|
80
78
|
const fetchResponse = await this.graphQLClient.request(siteQuery, {
|
|
@@ -4,8 +4,9 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.ErrorPagesService = void 0;
|
|
7
|
+
const core_1 = require("@sitecore-content-sdk/core");
|
|
7
8
|
const debug_1 = __importDefault(require("../debug"));
|
|
8
|
-
const
|
|
9
|
+
const { ERROR_MESSAGES } = core_1.constants;
|
|
9
10
|
// The default query for request error handling
|
|
10
11
|
const defaultQuery = /* GraphQL */ `
|
|
11
12
|
query ErrorPagesQuery($siteName: String!, $language: String!) {
|
|
@@ -52,7 +53,7 @@ class ErrorPagesService {
|
|
|
52
53
|
async fetchErrorPages(siteName, locale, fetchOptions) {
|
|
53
54
|
const language = locale || this.options.language;
|
|
54
55
|
if (!siteName) {
|
|
55
|
-
throw new Error(
|
|
56
|
+
throw new Error(ERROR_MESSAGES.MV_002);
|
|
56
57
|
}
|
|
57
58
|
return this.graphQLClient.request(this.query, {
|
|
58
59
|
siteName,
|
|
@@ -5,8 +5,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.RedirectsService = exports.REDIRECT_TYPE_SERVER_TRANSFER = exports.REDIRECT_TYPE_302 = exports.REDIRECT_TYPE_301 = void 0;
|
|
7
7
|
const core_1 = require("@sitecore-content-sdk/core");
|
|
8
|
-
const constants_1 = require("../constants");
|
|
9
8
|
const debug_1 = __importDefault(require("../debug"));
|
|
9
|
+
const { ERROR_MESSAGES } = core_1.constants;
|
|
10
10
|
/**
|
|
11
11
|
* Redirect type for 301 redirects
|
|
12
12
|
* @public
|
|
@@ -66,7 +66,7 @@ class RedirectsService {
|
|
|
66
66
|
async fetchRedirects(siteName, fetchOptions) {
|
|
67
67
|
var _a, _b;
|
|
68
68
|
if (!siteName) {
|
|
69
|
-
throw new Error(
|
|
69
|
+
throw new Error(ERROR_MESSAGES.MV_002);
|
|
70
70
|
}
|
|
71
71
|
const cacheKey = `redirects-${siteName}`;
|
|
72
72
|
let data = this.cache.getCacheValue(cacheKey);
|
|
@@ -4,8 +4,9 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.RobotsService = void 0;
|
|
7
|
+
const core_1 = require("@sitecore-content-sdk/core");
|
|
7
8
|
const debug_1 = __importDefault(require("../debug"));
|
|
8
|
-
const
|
|
9
|
+
const { ERROR_MESSAGES } = core_1.constants;
|
|
9
10
|
// The default query for request robots.txt
|
|
10
11
|
const defaultQuery = /* GraphQL */ `
|
|
11
12
|
query RobotsQuery($siteName: String!) {
|
|
@@ -41,7 +42,7 @@ class RobotsService {
|
|
|
41
42
|
async fetchRobots(fetchOptions) {
|
|
42
43
|
const siteName = this.options.siteName;
|
|
43
44
|
if (!siteName) {
|
|
44
|
-
throw new Error(
|
|
45
|
+
throw new Error(ERROR_MESSAGES.MV_002);
|
|
45
46
|
}
|
|
46
47
|
const robotsResult = this.graphQLClient.request(this.query, {
|
|
47
48
|
siteName,
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.SiteResolver = void 0;
|
|
4
|
+
const core_1 = require("@sitecore-content-sdk/core");
|
|
5
|
+
const { ERROR_MESSAGES } = core_1.constants;
|
|
4
6
|
// Delimiters for multi-value hostnames
|
|
5
7
|
const DELIMITERS = /\||,|;/g;
|
|
6
8
|
/**
|
|
@@ -25,7 +27,7 @@ class SiteResolver {
|
|
|
25
27
|
return site;
|
|
26
28
|
}
|
|
27
29
|
}
|
|
28
|
-
throw new Error(
|
|
30
|
+
throw new Error(ERROR_MESSAGES.IE_007(hostName));
|
|
29
31
|
};
|
|
30
32
|
/**
|
|
31
33
|
* Resolve site by site name
|
|
@@ -4,8 +4,9 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.SitemapXmlService = void 0;
|
|
7
|
+
const core_1 = require("@sitecore-content-sdk/core");
|
|
7
8
|
const debug_1 = __importDefault(require("../debug"));
|
|
8
|
-
const
|
|
9
|
+
const { ERROR_MESSAGES } = core_1.constants;
|
|
9
10
|
const PREFIX_NAME_SITEMAP = 'sitemap';
|
|
10
11
|
// The default query for request sitemaps
|
|
11
12
|
const defaultQuery = /* GraphQL */ `
|
|
@@ -42,7 +43,7 @@ class SitemapXmlService {
|
|
|
42
43
|
async fetchSitemaps(fetchOptions) {
|
|
43
44
|
const siteName = this.options.siteName;
|
|
44
45
|
if (!siteName) {
|
|
45
|
-
throw new Error(
|
|
46
|
+
throw new Error(ERROR_MESSAGES.MV_002);
|
|
46
47
|
}
|
|
47
48
|
const sitemapResult = this.graphQLClient.request(this.query, {
|
|
48
49
|
siteName,
|
|
@@ -3,21 +3,22 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.SitePathService = exports.sitesError = exports.
|
|
6
|
+
exports.SitePathService = exports.sitesError = exports.languageError = void 0;
|
|
7
7
|
exports.getSiteEmptyError = getSiteEmptyError;
|
|
8
|
+
const core_1 = require("@sitecore-content-sdk/core");
|
|
8
9
|
const personalize_1 = require("../personalize");
|
|
9
10
|
const site_1 = require("../site");
|
|
10
11
|
const debug_1 = __importDefault(require("../debug"));
|
|
12
|
+
const { ERROR_MESSAGES } = core_1.constants;
|
|
11
13
|
/** @private */
|
|
12
14
|
exports.languageError = 'The list of languages cannot be empty';
|
|
13
|
-
exports.siteError = 'The service needs a site name';
|
|
14
15
|
exports.sitesError = 'The list of sites cannot be empty';
|
|
15
16
|
/**
|
|
16
17
|
* @param {string} siteName to inject into error text
|
|
17
18
|
* @private
|
|
18
19
|
*/
|
|
19
20
|
function getSiteEmptyError(siteName) {
|
|
20
|
-
return
|
|
21
|
+
return ERROR_MESSAGES.IV_007(siteName);
|
|
21
22
|
}
|
|
22
23
|
/**
|
|
23
24
|
* GQL query made dynamic based whether personalization is enabled or not
|
|
@@ -110,7 +111,7 @@ class SitePathService {
|
|
|
110
111
|
});
|
|
111
112
|
const paths = new Array();
|
|
112
113
|
if (!languages.length) {
|
|
113
|
-
throw new RangeError(
|
|
114
|
+
throw new RangeError(ERROR_MESSAGES.MV_009);
|
|
114
115
|
}
|
|
115
116
|
// Get all sites
|
|
116
117
|
if (!sites || !sites.length) {
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.getComponentSpec = exports.getComponentSpecUrl = void 0;
|
|
4
4
|
const core_1 = require("@sitecore-content-sdk/core");
|
|
5
|
-
const { SITECORE_EDGE_PLATFORM_URL_DEFAULT } = core_1.constants;
|
|
5
|
+
const { SITECORE_EDGE_PLATFORM_URL_DEFAULT, ERROR_MESSAGES } = core_1.constants;
|
|
6
6
|
/**
|
|
7
7
|
* Gets the component spec url.
|
|
8
8
|
* @param {GetComponentSpecParams} params - The parameters for getting the component spec url.
|
|
@@ -35,14 +35,14 @@ const getComponentSpec = async ({ componentId, edgeUrl = SITECORE_EDGE_PLATFORM_
|
|
|
35
35
|
throw new Error('The token is incorrect or expired or the component ID is incorrect.');
|
|
36
36
|
}
|
|
37
37
|
if (!response.ok) {
|
|
38
|
-
throw new Error(`Failed to fetch component ${componentId}`);
|
|
38
|
+
throw new Error(`Failed to fetch component ${componentId}. ${ERROR_MESSAGES.CONTACT_SUPPORT}`);
|
|
39
39
|
}
|
|
40
40
|
const spec = await response.json();
|
|
41
41
|
core_1.debug.common('Component spec fetched successfully for %s: %o', componentId, spec);
|
|
42
42
|
return spec;
|
|
43
43
|
}
|
|
44
44
|
catch (error) {
|
|
45
|
-
core_1.debug.common(
|
|
45
|
+
core_1.debug.common(`Failed to fetch component spec: ${String(error)}. ${ERROR_MESSAGES.CONTACT_SUPPORT}`);
|
|
46
46
|
throw error;
|
|
47
47
|
}
|
|
48
48
|
};
|
|
@@ -11,6 +11,7 @@ const node_tools_1 = require("@sitecore-content-sdk/core/node-tools");
|
|
|
11
11
|
const core_1 = require("@sitecore-content-sdk/core");
|
|
12
12
|
const path_1 = __importDefault(require("path"));
|
|
13
13
|
const fs_1 = __importDefault(require("fs"));
|
|
14
|
+
const { ERROR_MESSAGES } = core_1.constants;
|
|
14
15
|
/**
|
|
15
16
|
* Extracts components from the app folder and sends them to XMCloud.
|
|
16
17
|
* @param {ExtractFilesConfig} args - Config for components extraction
|
|
@@ -38,7 +39,7 @@ function _extractFiles(args = {}) {
|
|
|
38
39
|
const renderingHost = process.env.SITECORE_RENDERINGHOST_NAME;
|
|
39
40
|
return async ({ scConfig }) => {
|
|
40
41
|
if (!scConfig) {
|
|
41
|
-
throw new Error(
|
|
42
|
+
throw new Error(ERROR_MESSAGES.MV_008);
|
|
42
43
|
}
|
|
43
44
|
if ((args.customValidateDeployContext && !args.customValidateDeployContext()) ||
|
|
44
45
|
!(0, utils_1.validateDeployContext)()) {
|
|
@@ -56,7 +57,7 @@ function _extractFiles(args = {}) {
|
|
|
56
57
|
const targetUrl = scConfig.api.edge.edgeUrl;
|
|
57
58
|
const { accessToken } = await node_tools_1.auth.clientCredentialsFlow(authParams);
|
|
58
59
|
if (!accessToken) {
|
|
59
|
-
console.error(chalk_1.default.red(
|
|
60
|
+
console.error(chalk_1.default.red(`Failed to get access token, aborting code extraction. ${ERROR_MESSAGES.CONTACT_SUPPORT}`));
|
|
60
61
|
return;
|
|
61
62
|
}
|
|
62
63
|
// Resolve files from component-map
|
|
@@ -97,7 +98,7 @@ function _extractFiles(args = {}) {
|
|
|
97
98
|
.join('\r\n')}`));
|
|
98
99
|
}
|
|
99
100
|
catch (error) {
|
|
100
|
-
console.warn(chalk_1.default.yellow(
|
|
101
|
+
console.warn(chalk_1.default.yellow(`Error during code extraction:`, error, error.stack, ERROR_MESSAGES.CONTACT_SUPPORT));
|
|
101
102
|
}
|
|
102
103
|
};
|
|
103
104
|
}
|
|
@@ -44,6 +44,8 @@ const core_1 = require("@sitecore-content-sdk/core");
|
|
|
44
44
|
const templating_1 = require("./../templating");
|
|
45
45
|
const crypto_1 = __importDefault(require("crypto"));
|
|
46
46
|
const utils_1 = require("./utils");
|
|
47
|
+
const core_2 = require("@sitecore-content-sdk/core");
|
|
48
|
+
const { ERROR_MESSAGES } = core_2.constants;
|
|
47
49
|
let _getComponentList = templating_1.getComponentList;
|
|
48
50
|
const aliasImport = /^([a-zA-Z0-9]+) as .+$/;
|
|
49
51
|
const unitMocks = ({ getComponentListStub, }) => {
|
|
@@ -278,7 +280,7 @@ const writeImportMap = (args) => {
|
|
|
278
280
|
const defaultTemplate = args.defaultTemplate || exports.defaultMapTemplate;
|
|
279
281
|
const clientTemplate = args.clientTemplate || exports.defaultMapTemplate;
|
|
280
282
|
if (!scConfig) {
|
|
281
|
-
throw new Error(
|
|
283
|
+
throw new Error(ERROR_MESSAGES.MV_008);
|
|
282
284
|
}
|
|
283
285
|
if (scConfig.disableCodeGeneration) {
|
|
284
286
|
core_1.debug.common('Skipping import map generation. Code generation functionality is disabled.');
|
|
@@ -46,6 +46,7 @@ const fs_1 = __importDefault(require("fs"));
|
|
|
46
46
|
const ts = __importStar(require("typescript"));
|
|
47
47
|
const core_1 = require("@sitecore-content-sdk/core");
|
|
48
48
|
const module_1 = require("module");
|
|
49
|
+
const { ERROR_MESSAGES } = core_1.constants;
|
|
49
50
|
/**
|
|
50
51
|
* Parse the generated component-map file and return all referenced modules
|
|
51
52
|
* per map entry (handles both single identifiers and spread objects).
|
|
@@ -384,7 +385,7 @@ async function _sendCode({ file, token, targetUrl, }) {
|
|
|
384
385
|
}
|
|
385
386
|
}
|
|
386
387
|
catch (error) {
|
|
387
|
-
console.error(chalk_1.default.red(`Fetch request to send extracted code from ${file.path} failed: ${JSON.stringify(error)}`));
|
|
388
|
+
console.error(chalk_1.default.red(`Fetch request to send extracted code from ${file.path} failed: ${JSON.stringify(error)}. ${ERROR_MESSAGES.CONTACT_SUPPORT}`));
|
|
388
389
|
return null;
|
|
389
390
|
}
|
|
390
391
|
return file.path;
|
|
@@ -8,9 +8,11 @@ const path_1 = __importDefault(require("path"));
|
|
|
8
8
|
const chalk_1 = __importDefault(require("chalk"));
|
|
9
9
|
const fs_1 = __importDefault(require("fs"));
|
|
10
10
|
const node_tools_1 = require("@sitecore-content-sdk/core/node-tools");
|
|
11
|
+
const core_1 = require("@sitecore-content-sdk/core");
|
|
11
12
|
const site_1 = require("../site");
|
|
12
13
|
const client_1 = require("../client");
|
|
13
14
|
const debug_1 = __importDefault(require("../debug"));
|
|
15
|
+
const { ERROR_MESSAGES } = core_1.constants;
|
|
14
16
|
const DEFAULT_SITES_DIST_PATH = '.sitecore/sites.json';
|
|
15
17
|
/**
|
|
16
18
|
* Generates site information and writes it to a specified destination path.
|
|
@@ -21,7 +23,7 @@ const DEFAULT_SITES_DIST_PATH = '.sitecore/sites.json';
|
|
|
21
23
|
const generateSites = ({ destinationPath } = {}) => {
|
|
22
24
|
return async ({ scConfig }) => {
|
|
23
25
|
if (!scConfig) {
|
|
24
|
-
throw new Error(
|
|
26
|
+
throw new Error(ERROR_MESSAGES.MV_008);
|
|
25
27
|
}
|
|
26
28
|
let sites = [];
|
|
27
29
|
const sitesFilePath = path_1.default.resolve(destinationPath !== null && destinationPath !== void 0 ? destinationPath : DEFAULT_SITES_DIST_PATH);
|
|
@@ -40,7 +42,7 @@ const generateSites = ({ destinationPath } = {}) => {
|
|
|
40
42
|
sites = await siteInfoService.fetchSiteInfo();
|
|
41
43
|
}
|
|
42
44
|
catch (error) {
|
|
43
|
-
console.error(chalk_1.default.red(
|
|
45
|
+
console.error(chalk_1.default.red(`Failed to fetch site information. ${ERROR_MESSAGES.CONTACT_SUPPORT}`));
|
|
44
46
|
throw error;
|
|
45
47
|
}
|
|
46
48
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { NativeDataFetcher, debug, } from '@sitecore-content-sdk/core';
|
|
1
|
+
import { NativeDataFetcher, debug, constants, } from '@sitecore-content-sdk/core';
|
|
2
2
|
import { resolveEdgeUrlForStaticFiles, resolveExperienceEdgeUrl, } from '@sitecore-content-sdk/core/tools';
|
|
3
3
|
import { DictionaryService } from '../i18n';
|
|
4
4
|
import { getDesignLibraryStylesheetLinks, getContentStylesheetLink, LayoutService, LayoutServicePageState, rewriteEdgeHostInResponse, getDefaultMediaUrlTransformer, applyMediaUrlRewrite, } from '../layout';
|
|
@@ -9,6 +9,7 @@ import { createGraphQLClientFactory } from './utils';
|
|
|
9
9
|
import { RobotsService } from '../site/robots-service';
|
|
10
10
|
import { DesignLibraryVariantGeneration } from '../editing/models';
|
|
11
11
|
import { EditingService, ComponentLayoutService, DesignLibraryMode, } from '../editing';
|
|
12
|
+
const { ERROR_MESSAGES } = constants;
|
|
12
13
|
/**
|
|
13
14
|
* Error page codes
|
|
14
15
|
* @public
|
|
@@ -176,7 +177,7 @@ export class SitecoreClient {
|
|
|
176
177
|
mode,
|
|
177
178
|
}, fetchOptions);
|
|
178
179
|
if (!data) {
|
|
179
|
-
throw new Error(`Unable to fetch editing data for preview ${JSON.stringify(previewData)}`);
|
|
180
|
+
throw new Error(`Unable to fetch editing data for preview ${JSON.stringify(previewData)}. ${ERROR_MESSAGES.CONTACT_SUPPORT}`);
|
|
180
181
|
}
|
|
181
182
|
let layout = data.layoutData;
|
|
182
183
|
const personalizeData = getGroomedVariantIds(variantIds);
|
|
@@ -198,9 +199,6 @@ export class SitecoreClient {
|
|
|
198
199
|
*/
|
|
199
200
|
async getDesignLibraryData(designLibData, fetchOptions) {
|
|
200
201
|
var _a;
|
|
201
|
-
if (!this.initOptions.api.local) {
|
|
202
|
-
throw new Error('Component Library requires Sitecore apiHost and apiKey to be provided');
|
|
203
|
-
}
|
|
204
202
|
const { itemId, componentUid, site, language, renderingId, dataSourceId, version, mode, generation, } = designLibData;
|
|
205
203
|
const componentData = await this.componentService.fetchComponentData(Object.assign({ siteName: site, itemId,
|
|
206
204
|
language,
|
|
@@ -210,7 +208,7 @@ export class SitecoreClient {
|
|
|
210
208
|
version,
|
|
211
209
|
mode }, (generation ? { generation } : {})), fetchOptions);
|
|
212
210
|
if (!componentData) {
|
|
213
|
-
throw new Error(`Unable to fetch editing data for preview ${JSON.stringify(designLibData)}`);
|
|
211
|
+
throw new Error(`Unable to fetch editing data for preview ${JSON.stringify(designLibData)}. ${ERROR_MESSAGES.CONTACT_SUPPORT}`);
|
|
214
212
|
}
|
|
215
213
|
const layout = this.applyContentRewrite(componentData);
|
|
216
214
|
const page = {
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import { DefaultRetryStrategy } from '@sitecore-content-sdk/core';
|
|
1
|
+
import { constants, DefaultRetryStrategy } from '@sitecore-content-sdk/core';
|
|
2
2
|
import { resolveEdgeUrl } from '@sitecore-content-sdk/core/tools';
|
|
3
3
|
import { SITECORE_CLI_MODE_ENV_VAR } from '../config-cli';
|
|
4
|
+
const { ERROR_MESSAGES } = constants;
|
|
4
5
|
/**
|
|
5
6
|
* Provides default initial values for SitecoreConfig
|
|
6
7
|
* @returns default config
|
|
@@ -115,12 +116,12 @@ const validateApiConfiguration = (config) => {
|
|
|
115
116
|
// Server-side: allow Edge OR Local; clientContextId alone is NOT sufficient
|
|
116
117
|
if (!isBrowser) {
|
|
117
118
|
if (!hasEdgeContextId && !hasLocalCreds) {
|
|
118
|
-
throw new Error(
|
|
119
|
+
throw new Error(ERROR_MESSAGES.MV_007);
|
|
119
120
|
}
|
|
120
121
|
if (hasEdgeContextId && !hasClientContextId) {
|
|
121
122
|
// eslint-disable-next-line no-console
|
|
122
123
|
if (process.env.NODE_ENV === 'development') {
|
|
123
|
-
console.warn(
|
|
124
|
+
console.warn(ERROR_MESSAGES.MV_006);
|
|
124
125
|
}
|
|
125
126
|
}
|
|
126
127
|
return; // validation complete on the server
|
|
@@ -129,8 +130,7 @@ const validateApiConfiguration = (config) => {
|
|
|
129
130
|
if (isBrowser && !hasClientContextId) {
|
|
130
131
|
// eslint-disable-next-line no-console
|
|
131
132
|
if (process.env.NODE_ENV === 'development') {
|
|
132
|
-
console.warn(
|
|
133
|
-
Client Side functionalities (like Tracking and Personalization) may be limited.`);
|
|
133
|
+
console.warn(ERROR_MESSAGES.MV_006);
|
|
134
134
|
}
|
|
135
135
|
}
|
|
136
136
|
};
|
package/dist/esm/constants.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { NativeDataFetcher, constants } from '@sitecore-content-sdk/core';
|
|
2
2
|
import { validateEvent } from '../design-library';
|
|
3
3
|
import debug from '../../debug';
|
|
4
|
-
const { SITECORE_EDGE_PLATFORM_URL_DEFAULT } = constants;
|
|
4
|
+
const { SITECORE_EDGE_PLATFORM_URL_DEFAULT, ERROR_MESSAGES } = constants;
|
|
5
5
|
/**
|
|
6
6
|
* Event to send import map to design library
|
|
7
7
|
*/
|
|
@@ -282,7 +282,7 @@ export function isImportEntryInfoArray(data) {
|
|
|
282
282
|
*/
|
|
283
283
|
export const sendErrorEvent = (uid, error, type) => {
|
|
284
284
|
const errorEvent = getDesignLibraryErrorEvent(uid, error, type);
|
|
285
|
-
console.error(
|
|
285
|
+
console.error(`Component Library: sending error event. ${ERROR_MESSAGES.CONTACT_SUPPORT}`, errorEvent);
|
|
286
286
|
if (typeof window !== 'undefined') {
|
|
287
287
|
const target = window.parent && window.parent !== window ? window.parent : window;
|
|
288
288
|
target.postMessage(errorEvent, '*');
|
|
@@ -2,6 +2,7 @@ import { constants, NativeDataFetcher } from '@sitecore-content-sdk/core';
|
|
|
2
2
|
import { normalizeUrl, resolveUrl } from '@sitecore-content-sdk/core/tools';
|
|
3
3
|
import debug from '../debug';
|
|
4
4
|
import { DesignLibraryMode } from './models';
|
|
5
|
+
const { ERROR_MESSAGES } = constants;
|
|
5
6
|
/**
|
|
6
7
|
* REST service that enables Design Library functionality.
|
|
7
8
|
* Returns layout data for a single rendered component.
|
|
@@ -15,8 +16,7 @@ export class ComponentLayoutService {
|
|
|
15
16
|
// Choose the correct Edge ID per environment
|
|
16
17
|
const sitecoreContextId = this.config.contextId || this.config.clientContextId;
|
|
17
18
|
if (!sitecoreContextId) {
|
|
18
|
-
throw new Error(
|
|
19
|
-
Provide contextId on the server, and clientContextId in the browser if you need to full client-side functionality.`);
|
|
19
|
+
throw new Error(ERROR_MESSAGES.MV_001);
|
|
20
20
|
}
|
|
21
21
|
const fetcher = new NativeDataFetcher({ debugger: debug.layout });
|
|
22
22
|
debug.layout('fetching component with uid %s for %s %s %s %s', params.componentUid, params.itemId, params.language, params.siteName, params.dataSourceId);
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { constants } from '@sitecore-content-sdk/core';
|
|
2
2
|
import { normalizeUrl } from '@sitecore-content-sdk/core/tools';
|
|
3
3
|
import { DesignLibraryMode } from './models';
|
|
4
|
+
const { ERROR_MESSAGES } = constants;
|
|
4
5
|
/**
|
|
5
6
|
* Event to be sent when report status to design library
|
|
6
7
|
*/
|
|
@@ -174,6 +175,6 @@ export const postToDesignLibrary = (evt) => {
|
|
|
174
175
|
target.postMessage(evt, '*');
|
|
175
176
|
}
|
|
176
177
|
catch (err) {
|
|
177
|
-
console.error(
|
|
178
|
+
console.error(`Component Library: postMessage failed. ${ERROR_MESSAGES.CONTACT_SUPPORT}`, err, evt);
|
|
178
179
|
}
|
|
179
180
|
};
|