@sitecore-content-sdk/content 2.0.0-canary.1 → 2.0.0-canary.12
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/index.js +2 -2
- package/dist/cjs/editing/codegen/preview.js +40 -14
- 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 +6 -5
- package/dist/cjs/tools/codegen/import-map.js +7 -13
- package/dist/cjs/tools/codegen/utils.js +2 -1
- package/dist/cjs/tools/generateSites.js +6 -4
- package/dist/cjs/tools/index-node.js +14 -0
- package/dist/cjs/tools/index.js +3 -25
- 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/index.js +1 -1
- package/dist/esm/editing/codegen/preview.js +39 -13
- 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 +6 -5
- package/dist/esm/tools/codegen/import-map.js +7 -13
- package/dist/esm/tools/codegen/utils.js +3 -2
- package/dist/esm/tools/generateSites.js +5 -3
- package/dist/esm/tools/index-node.js +5 -0
- package/dist/esm/tools/index.js +1 -5
- package/node-tools.d.ts +1 -0
- package/package.json +11 -6
- 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/index.d.ts +1 -1
- package/types/editing/codegen/index.d.ts.map +1 -1
- package/types/editing/codegen/preview.d.ts +39 -7
- 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
- package/types/tools/index-node.d.ts +6 -0
- package/types/tools/index-node.d.ts.map +1 -0
- package/types/tools/index.d.ts +1 -5
- package/types/tools/index.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
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.fetchGeneratedComponentFromCache = exports.DesignLibraryPreviewError = exports.sendErrorEvent = exports.createComponentInstance = exports.addStyleElement = exports.getImportMapInfo = exports.getDesignLibraryImportMapEvent = exports.getDesignLibraryComponentPropsEvent = exports.
|
|
3
|
+
exports.fetchGeneratedComponentFromCache = exports.DesignLibraryPreviewError = exports.sendErrorEvent = exports.createComponentInstance = exports.addStyleElement = exports.getImportMapInfo = exports.getDesignLibraryImportMapEvent = exports.getDesignLibraryComponentPropsEvent = exports.getDesignLibraryErrorEvent = exports.addServerComponentPreviewHandler = exports.addComponentPreviewHandler = void 0;
|
|
4
4
|
var preview_1 = require("./preview");
|
|
5
5
|
Object.defineProperty(exports, "addComponentPreviewHandler", { enumerable: true, get: function () { return preview_1.addComponentPreviewHandler; } });
|
|
6
6
|
Object.defineProperty(exports, "addServerComponentPreviewHandler", { enumerable: true, get: function () { return preview_1.addServerComponentPreviewHandler; } });
|
|
7
|
-
Object.defineProperty(exports, "
|
|
7
|
+
Object.defineProperty(exports, "getDesignLibraryErrorEvent", { enumerable: true, get: function () { return preview_1.getDesignLibraryErrorEvent; } });
|
|
8
8
|
Object.defineProperty(exports, "getDesignLibraryComponentPropsEvent", { enumerable: true, get: function () { return preview_1.getDesignLibraryComponentPropsEvent; } });
|
|
9
9
|
Object.defineProperty(exports, "getDesignLibraryImportMapEvent", { enumerable: true, get: function () { return preview_1.getDesignLibraryImportMapEvent; } });
|
|
10
10
|
Object.defineProperty(exports, "getImportMapInfo", { enumerable: true, get: function () { return preview_1.getImportMapInfo; } });
|
|
@@ -6,7 +6,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
exports.sendErrorEvent = exports.createComponentInstance = exports.addServerComponentPreviewHandler = exports.addComponentPreviewHandler = exports.DesignLibraryPreviewError = void 0;
|
|
7
7
|
exports.buildComponentDependencies = buildComponentDependencies;
|
|
8
8
|
exports.addStyleElement = addStyleElement;
|
|
9
|
-
exports.
|
|
9
|
+
exports.getDesignLibraryErrorEvent = getDesignLibraryErrorEvent;
|
|
10
10
|
exports.getDesignLibraryComponentPropsEvent = getDesignLibraryComponentPropsEvent;
|
|
11
11
|
exports.getDesignLibraryImportMapEvent = getDesignLibraryImportMapEvent;
|
|
12
12
|
exports.getImportMapInfo = getImportMapInfo;
|
|
@@ -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
|
*/
|
|
@@ -29,9 +29,13 @@ const DESIGN_LIBRARY_COMPONENT_PROPS_EVENT_NAME = 'component:generation:componen
|
|
|
29
29
|
*/
|
|
30
30
|
const DESIGN_LIBRARY_COMPONENT_PREVIEW_EVENT_NAME = 'component:generation:component-preview';
|
|
31
31
|
/**
|
|
32
|
-
* Event to send component error to design library
|
|
32
|
+
* Event to send component preview error to design library
|
|
33
33
|
*/
|
|
34
34
|
const DESIGN_LIBRARY_COMPONENT_PREVIEW_ERROR_EVENT_NAME = 'component:generation:component-preview-error';
|
|
35
|
+
/**
|
|
36
|
+
* Event to send general component preview error to design library
|
|
37
|
+
*/
|
|
38
|
+
const DESIGN_LIBRARY_ERROR_EVENT_NAME = 'component:generation:error';
|
|
35
39
|
/**
|
|
36
40
|
* Enumeration of error types for the design library preview.
|
|
37
41
|
* @internal
|
|
@@ -46,6 +50,18 @@ var DesignLibraryPreviewError;
|
|
|
46
50
|
* Error occurred during component and event handlers initialization.
|
|
47
51
|
*/
|
|
48
52
|
DesignLibraryPreviewError["RenderInit"] = "render-init";
|
|
53
|
+
/**
|
|
54
|
+
* The import map is missing
|
|
55
|
+
*/
|
|
56
|
+
DesignLibraryPreviewError["ImportMapMissing"] = "import-map-missing";
|
|
57
|
+
/**
|
|
58
|
+
* Error during loading of the import map
|
|
59
|
+
*/
|
|
60
|
+
DesignLibraryPreviewError["ImportMapLoad"] = "import-map-load-error";
|
|
61
|
+
/**
|
|
62
|
+
* Error during fetching the generated component data from secured endpoint
|
|
63
|
+
*/
|
|
64
|
+
DesignLibraryPreviewError["GeneratedComponentFetch"] = "generated-component-fetch-error";
|
|
49
65
|
})(DesignLibraryPreviewError || (exports.DesignLibraryPreviewError = DesignLibraryPreviewError = {}));
|
|
50
66
|
/**
|
|
51
67
|
* Builds the component dependencies from the component imports and the import map.
|
|
@@ -192,18 +208,27 @@ const createComponentInstance = (importMap, generatedComponentData) => {
|
|
|
192
208
|
};
|
|
193
209
|
exports.createComponentInstance = createComponentInstance;
|
|
194
210
|
/**
|
|
195
|
-
* Generates a
|
|
211
|
+
* Generates a DesignLibraryErrorEvent depending on the type of error with the given uid and error.
|
|
196
212
|
* @param {string} uid - The unique identifier for the event.
|
|
197
213
|
* @param {unknown} error - The error to be sent.
|
|
198
214
|
* @param {DesignLibraryPreviewError} type - The type of error.
|
|
199
|
-
* @returns An object representing the
|
|
215
|
+
* @returns An object representing the DesignLibraryErrorEvent.
|
|
200
216
|
* @internal
|
|
201
217
|
*/
|
|
202
|
-
function
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
218
|
+
function getDesignLibraryErrorEvent(uid, error, type) {
|
|
219
|
+
switch (type) {
|
|
220
|
+
case DesignLibraryPreviewError.Render:
|
|
221
|
+
case DesignLibraryPreviewError.RenderInit:
|
|
222
|
+
return {
|
|
223
|
+
name: DESIGN_LIBRARY_COMPONENT_PREVIEW_ERROR_EVENT_NAME,
|
|
224
|
+
message: { uid, error, type },
|
|
225
|
+
};
|
|
226
|
+
default:
|
|
227
|
+
return {
|
|
228
|
+
name: DESIGN_LIBRARY_ERROR_EVENT_NAME,
|
|
229
|
+
message: { uid, error, type },
|
|
230
|
+
};
|
|
231
|
+
}
|
|
207
232
|
}
|
|
208
233
|
/**
|
|
209
234
|
* Generates a DesignLibraryComponentPropsEvent with the given uid, fields and parameters.
|
|
@@ -266,15 +291,15 @@ function isImportEntryInfoArray(data) {
|
|
|
266
291
|
typeof data[0].exports[0] === 'string');
|
|
267
292
|
}
|
|
268
293
|
/**
|
|
269
|
-
* Sends a
|
|
294
|
+
* Sends a design library error event to the design library
|
|
270
295
|
* @param {string} uid - The unique identifier of the component that's being edited.
|
|
271
296
|
* @param {unknown} error - The error object or message to be sent.
|
|
272
297
|
* @param {DesignLibraryPreviewError} type - The type of error, as defined in DesignLibraryPreviewError.
|
|
273
298
|
* @internal
|
|
274
299
|
*/
|
|
275
300
|
const sendErrorEvent = (uid, error, type) => {
|
|
276
|
-
const errorEvent =
|
|
277
|
-
console.error(
|
|
301
|
+
const errorEvent = getDesignLibraryErrorEvent(uid, error, type);
|
|
302
|
+
console.error(`Component Library: sending error event. ${ERROR_MESSAGES.CONTACT_SUPPORT}`, errorEvent);
|
|
278
303
|
if (typeof window !== 'undefined') {
|
|
279
304
|
const target = window.parent && window.parent !== window ? window.parent : window;
|
|
280
305
|
target.postMessage(errorEvent, '*');
|
|
@@ -301,5 +326,6 @@ async function fetchGeneratedComponentFromCache(id, token, edgeUrl = SITECORE_ED
|
|
|
301
326
|
if (componentDataResponse.status !== 200) {
|
|
302
327
|
throw new Error(`Failed to fetch generated component data from cache for id: ${id}. Response Status: ${componentDataResponse.status}, Response Status Text: ${componentDataResponse.statusText}`);
|
|
303
328
|
}
|
|
304
|
-
|
|
329
|
+
const generatedComponentData = JSON.parse(componentDataResponse.data.content);
|
|
330
|
+
return generatedComponentData;
|
|
305
331
|
}
|
|
@@ -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
|
};
|
|
@@ -7,10 +7,11 @@ exports.unitMocks = exports.extractFiles = void 0;
|
|
|
7
7
|
/* eslint-disable jsdoc/require-jsdoc */
|
|
8
8
|
const chalk_1 = __importDefault(require("chalk"));
|
|
9
9
|
const utils_1 = require("./utils");
|
|
10
|
-
const
|
|
10
|
+
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)()) {
|
|
@@ -54,9 +55,9 @@ function _extractFiles(args = {}) {
|
|
|
54
55
|
try {
|
|
55
56
|
// Use Edge Platform mesh endpoint - staging is ready, prod QA in progress
|
|
56
57
|
const targetUrl = scConfig.api.edge.edgeUrl;
|
|
57
|
-
const { accessToken } = await
|
|
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, }) => {
|
|
@@ -252,19 +254,11 @@ const prepImportMaps = async (paths, separateMaps) => {
|
|
|
252
254
|
? componentPath
|
|
253
255
|
: path_1.default.resolve(appPath, componentPath);
|
|
254
256
|
// read the start of the file that may be 'use client'
|
|
255
|
-
const
|
|
256
|
-
|
|
257
|
-
const stream = fs_1.default.createReadStream(fullPath, { end: 12 });
|
|
258
|
-
stream
|
|
259
|
-
.on('data', async (chunk) => {
|
|
260
|
-
readBuffer += chunk.toString();
|
|
261
|
-
})
|
|
262
|
-
.on('close', () => resolve(readBuffer))
|
|
263
|
-
.on('error', () => resolve(''));
|
|
264
|
-
});
|
|
265
|
-
if (!firstLine)
|
|
257
|
+
const fileContent = await fs_1.default.promises.readFile(fullPath, 'utf8');
|
|
258
|
+
if (!fileContent)
|
|
266
259
|
continue;
|
|
267
|
-
if
|
|
260
|
+
// check if 'use client' directive is present, ignoring any comments or whitespace before it
|
|
261
|
+
if (fileContent.match(/^(?:\s|\/\/[^\n]*\n|\/\*[^*]*\*+(?:[^\/*][^*]*\*+)*\/)*['"]use client['"]/)) {
|
|
268
262
|
clientPaths.push(fullPath);
|
|
269
263
|
}
|
|
270
264
|
else {
|
|
@@ -286,7 +280,7 @@ const writeImportMap = (args) => {
|
|
|
286
280
|
const defaultTemplate = args.defaultTemplate || exports.defaultMapTemplate;
|
|
287
281
|
const clientTemplate = args.clientTemplate || exports.defaultMapTemplate;
|
|
288
282
|
if (!scConfig) {
|
|
289
|
-
throw new Error(
|
|
283
|
+
throw new Error(ERROR_MESSAGES.MV_008);
|
|
290
284
|
}
|
|
291
285
|
if (scConfig.disableCodeGeneration) {
|
|
292
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;
|
|
@@ -7,10 +7,12 @@ exports.generateSites = void 0;
|
|
|
7
7
|
const path_1 = __importDefault(require("path"));
|
|
8
8
|
const chalk_1 = __importDefault(require("chalk"));
|
|
9
9
|
const fs_1 = __importDefault(require("fs"));
|
|
10
|
-
const
|
|
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
|
}
|
|
@@ -51,7 +53,7 @@ const generateSites = ({ destinationPath } = {}) => {
|
|
|
51
53
|
language: scConfig.defaultLanguage,
|
|
52
54
|
};
|
|
53
55
|
sites.unshift(defaultSite);
|
|
54
|
-
(0,
|
|
56
|
+
(0, node_tools_1.ensurePathExists)(sitesFilePath);
|
|
55
57
|
fs_1.default.writeFileSync(sitesFilePath, JSON.stringify(sites, null, 2), { encoding: 'utf8' });
|
|
56
58
|
};
|
|
57
59
|
};
|