@sitecore-content-sdk/core 1.3.0-canary.9 → 1.4.0-canary.2
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/README.md +7 -7
- package/dist/cjs/cache-client.js +55 -54
- package/dist/cjs/client/constants.js +7 -7
- package/dist/cjs/client/edge-proxy.js +24 -22
- package/dist/cjs/client/index.js +15 -15
- package/dist/cjs/client/models.js +2 -2
- package/dist/cjs/client/sitecore-client.js +421 -419
- package/dist/cjs/client/utils.js +47 -46
- package/dist/cjs/config/define-config.js +194 -193
- package/dist/cjs/config/index.js +7 -7
- package/dist/cjs/config/models.js +12 -11
- package/dist/cjs/config-cli/define-cli-config.js +23 -22
- package/dist/cjs/config-cli/index.js +7 -7
- package/dist/cjs/config-cli/models.js +8 -7
- package/dist/cjs/constants.js +49 -17
- package/dist/cjs/debug.js +48 -46
- package/dist/cjs/editing/codegen/index.js +14 -9
- package/dist/cjs/editing/codegen/preview.js +277 -193
- package/dist/cjs/editing/component-layout-service.js +62 -61
- package/dist/cjs/editing/design-library.js +183 -126
- package/dist/cjs/editing/editing-service.js +75 -74
- package/dist/cjs/editing/index.js +33 -27
- package/dist/cjs/editing/metadata.js +42 -42
- package/dist/cjs/editing/models.js +44 -38
- package/dist/cjs/editing/utils.js +108 -90
- package/dist/cjs/form/form.js +81 -78
- package/dist/cjs/form/index.js +7 -7
- package/dist/cjs/graphql-request-client.js +108 -107
- package/dist/cjs/i18n/dictionary-service.js +122 -121
- package/dist/cjs/i18n/index.js +7 -7
- package/dist/cjs/i18n/utils.js +16 -15
- package/dist/cjs/index.js +60 -60
- package/dist/cjs/layout/content-styles.js +72 -71
- package/dist/cjs/layout/index.js +24 -24
- package/dist/cjs/layout/layout-service.js +62 -57
- package/dist/cjs/layout/models.js +39 -34
- package/dist/cjs/layout/themes.js +76 -75
- package/dist/cjs/layout/utils.js +117 -110
- package/dist/cjs/media/index.js +38 -38
- package/dist/cjs/media/media-api.js +100 -96
- package/dist/cjs/models.js +2 -2
- package/dist/cjs/native-fetcher.js +194 -179
- package/dist/cjs/personalize/index.js +15 -15
- package/dist/cjs/personalize/layout-personalizer.js +98 -97
- package/dist/cjs/personalize/personalize-service.js +98 -94
- package/dist/cjs/personalize/utils.js +143 -136
- package/dist/cjs/retries.js +43 -42
- package/dist/cjs/site/error-pages-service.js +65 -64
- package/dist/cjs/site/index.js +26 -26
- package/dist/cjs/site/models.js +2 -2
- package/dist/cjs/site/redirects-service.js +94 -81
- package/dist/cjs/site/robots-service.js +66 -65
- package/dist/cjs/site/site-resolver.js +73 -72
- package/dist/cjs/site/siteinfo-service.js +84 -80
- package/dist/cjs/site/sitemap-xml-service.js +84 -83
- package/dist/cjs/site/sitepath-service.js +165 -164
- package/dist/cjs/site/utils.js +55 -47
- package/dist/cjs/sitecore-service-base.js +36 -36
- package/dist/cjs/tools/auth/flow.js +65 -64
- package/dist/cjs/tools/auth/index.js +5 -5
- package/dist/cjs/tools/auth/models.js +2 -2
- package/dist/cjs/tools/auth/tenant-store.js +38 -38
- package/dist/cjs/tools/codegen/component-generation.js +52 -50
- package/dist/cjs/tools/codegen/extract-files.js +105 -107
- package/dist/cjs/tools/codegen/import-map.js +401 -349
- package/dist/cjs/tools/codegen/utils.js +418 -418
- package/dist/cjs/tools/generate-map.js +2 -2
- package/dist/cjs/tools/generateMetadata.js +36 -35
- package/dist/cjs/tools/generateSites.js +59 -58
- package/dist/cjs/tools/index.js +75 -73
- package/dist/cjs/tools/scaffold.js +60 -59
- package/dist/cjs/tools/templating/components.js +96 -266
- package/dist/cjs/tools/templating/index.js +11 -14
- package/dist/cjs/tools/templating/plugins.js +80 -78
- package/dist/cjs/tools/templating/utils.js +67 -66
- package/dist/cjs/utils/ensurePath.js +20 -20
- package/dist/cjs/utils/env.js +28 -27
- package/dist/cjs/utils/globalCache.js +55 -0
- package/dist/cjs/utils/index.js +26 -21
- package/dist/cjs/utils/is-server.js +11 -10
- package/dist/cjs/utils/normalize-url.js +5 -5
- package/dist/cjs/utils/timeout-promise.js +31 -31
- package/dist/cjs/utils/utils.js +254 -229
- package/dist/esm/cache-client.js +51 -50
- package/dist/esm/client/constants.js +4 -4
- package/dist/esm/client/edge-proxy.js +19 -17
- package/dist/esm/client/index.js +5 -5
- package/dist/esm/client/models.js +1 -1
- package/dist/esm/client/sitecore-client.js +414 -412
- package/dist/esm/client/utils.js +43 -42
- package/dist/esm/config/define-config.js +188 -187
- package/dist/esm/config/index.js +2 -2
- package/dist/esm/config/models.js +9 -8
- package/dist/esm/config-cli/define-cli-config.js +19 -18
- package/dist/esm/config-cli/index.js +2 -2
- package/dist/esm/config-cli/models.js +5 -4
- package/dist/esm/constants.js +46 -14
- package/dist/esm/debug.js +41 -39
- package/dist/esm/editing/codegen/index.js +1 -1
- package/dist/esm/editing/codegen/preview.js +263 -185
- package/dist/esm/editing/component-layout-service.js +55 -54
- package/dist/esm/editing/design-library.js +171 -117
- package/dist/esm/editing/editing-service.js +68 -67
- package/dist/esm/editing/index.js +6 -5
- package/dist/esm/editing/metadata.js +39 -39
- package/dist/esm/editing/models.js +41 -35
- package/dist/esm/editing/utils.js +98 -80
- package/dist/esm/form/form.js +72 -69
- package/dist/esm/form/index.js +1 -1
- package/dist/esm/graphql-request-client.js +101 -100
- package/dist/esm/i18n/dictionary-service.js +115 -114
- package/dist/esm/i18n/index.js +2 -2
- package/dist/esm/i18n/utils.js +13 -12
- package/dist/esm/index.js +13 -13
- package/dist/esm/layout/content-styles.js +64 -63
- package/dist/esm/layout/index.js +6 -6
- package/dist/esm/layout/layout-service.js +55 -50
- package/dist/esm/layout/models.js +36 -31
- package/dist/esm/layout/themes.js +71 -70
- package/dist/esm/layout/utils.js +109 -102
- package/dist/esm/media/index.js +2 -2
- package/dist/esm/media/media-api.js +90 -86
- package/dist/esm/models.js +1 -1
- package/dist/esm/native-fetcher.js +187 -172
- package/dist/esm/personalize/index.js +3 -3
- package/dist/esm/personalize/layout-personalizer.js +93 -92
- package/dist/esm/personalize/personalize-service.js +91 -87
- package/dist/esm/personalize/utils.js +135 -128
- package/dist/esm/retries.js +39 -38
- package/dist/esm/site/error-pages-service.js +58 -57
- package/dist/esm/site/index.js +8 -8
- package/dist/esm/site/models.js +1 -1
- package/dist/esm/site/redirects-service.js +87 -74
- package/dist/esm/site/robots-service.js +59 -58
- package/dist/esm/site/site-resolver.js +69 -68
- package/dist/esm/site/siteinfo-service.js +77 -73
- package/dist/esm/site/sitemap-xml-service.js +77 -76
- package/dist/esm/site/sitepath-service.js +157 -156
- package/dist/esm/site/utils.js +49 -41
- package/dist/esm/sitecore-service-base.js +29 -29
- package/dist/esm/tools/auth/flow.js +62 -61
- package/dist/esm/tools/auth/index.js +1 -1
- package/dist/esm/tools/auth/models.js +1 -1
- package/dist/esm/tools/auth/tenant-store.js +35 -35
- package/dist/esm/tools/codegen/component-generation.js +44 -42
- package/dist/esm/tools/codegen/extract-files.js +99 -101
- package/dist/esm/tools/codegen/import-map.js +358 -306
- package/dist/esm/tools/codegen/utils.js +373 -373
- package/dist/esm/tools/generate-map.js +1 -1
- package/dist/esm/tools/generateMetadata.js +29 -28
- package/dist/esm/tools/generateSites.js +52 -51
- package/dist/esm/tools/index.js +28 -27
- package/dist/esm/tools/scaffold.js +52 -51
- package/dist/esm/tools/templating/components.js +59 -223
- package/dist/esm/tools/templating/index.js +3 -3
- package/dist/esm/tools/templating/plugins.js +72 -70
- package/dist/esm/tools/templating/utils.js +59 -58
- package/dist/esm/utils/ensurePath.js +13 -13
- package/dist/esm/utils/env.js +24 -23
- package/dist/esm/utils/globalCache.js +49 -0
- package/dist/esm/utils/index.js +4 -3
- package/dist/esm/utils/is-server.js +9 -8
- package/dist/esm/utils/normalize-url.js +1 -1
- package/dist/esm/utils/timeout-promise.js +28 -28
- package/dist/esm/utils/utils.js +238 -213
- package/package.json +73 -5
- package/types/cache-client.d.ts +68 -64
- package/types/cache-client.d.ts.map +1 -0
- package/types/client/constants.d.ts +5 -4
- package/types/client/constants.d.ts.map +1 -0
- package/types/client/edge-proxy.d.ts +18 -15
- package/types/client/edge-proxy.d.ts.map +1 -0
- package/types/client/index.d.ts +8 -7
- package/types/client/index.d.ts.map +1 -0
- package/types/client/models.d.ts +21 -19
- package/types/client/models.d.ts.map +1 -0
- package/types/client/sitecore-client.d.ts +338 -327
- package/types/client/sitecore-client.d.ts.map +1 -0
- package/types/client/utils.d.ts +15 -9
- package/types/client/utils.d.ts.map +1 -0
- package/types/config/define-config.d.ts +20 -18
- package/types/config/define-config.d.ts.map +1 -0
- package/types/config/index.d.ts +3 -2
- package/types/config/index.d.ts.map +1 -0
- package/types/config/models.d.ts +287 -268
- package/types/config/models.d.ts.map +1 -0
- package/types/config-cli/define-cli-config.d.ts +9 -7
- package/types/config-cli/define-cli-config.d.ts.map +1 -0
- package/types/config-cli/index.d.ts +3 -2
- package/types/config-cli/index.d.ts.map +1 -0
- package/types/config-cli/models.d.ts +6 -4
- package/types/config-cli/models.d.ts.map +1 -0
- package/types/constants.d.ts +44 -11
- package/types/constants.d.ts.map +1 -0
- package/types/debug.d.ts +35 -28
- package/types/debug.d.ts.map +1 -0
- package/types/editing/codegen/index.d.ts +2 -1
- package/types/editing/codegen/index.d.ts.map +1 -0
- package/types/editing/codegen/preview.d.ts +256 -195
- package/types/editing/codegen/preview.d.ts.map +1 -0
- package/types/editing/component-layout-service.d.ts +84 -80
- package/types/editing/component-layout-service.d.ts.map +1 -0
- package/types/editing/design-library.d.ts +111 -63
- package/types/editing/design-library.d.ts.map +1 -0
- package/types/editing/editing-service.d.ts +72 -62
- package/types/editing/editing-service.d.ts.map +1 -0
- package/types/editing/index.d.ts +7 -6
- package/types/editing/index.d.ts.map +1 -0
- package/types/editing/metadata.d.ts +8 -7
- package/types/editing/metadata.d.ts.map +1 -0
- package/types/editing/models.d.ts +103 -92
- package/types/editing/models.d.ts.map +1 -0
- package/types/editing/utils.d.ts +91 -74
- package/types/editing/utils.d.ts.map +1 -0
- package/types/form/form.d.ts +25 -21
- package/types/form/form.d.ts.map +1 -0
- package/types/form/index.d.ts +2 -1
- package/types/form/index.d.ts.map +1 -0
- package/types/graphql-request-client.d.ts +112 -105
- package/types/graphql-request-client.d.ts.map +1 -0
- package/types/i18n/dictionary-service.d.ts +135 -131
- package/types/i18n/dictionary-service.d.ts.map +1 -0
- package/types/i18n/index.d.ts +3 -2
- package/types/i18n/index.d.ts.map +1 -0
- package/types/i18n/utils.d.ts +9 -7
- package/types/i18n/utils.d.ts.map +1 -0
- package/types/index.d.ts +13 -12
- package/types/index.d.ts.map +1 -0
- package/types/layout/content-styles.d.ts +20 -18
- package/types/layout/content-styles.d.ts.map +1 -0
- package/types/layout/index.d.ts +6 -5
- package/types/layout/index.d.ts.map +1 -0
- package/types/layout/layout-service.d.ts +45 -35
- package/types/layout/layout-service.d.ts.map +1 -0
- package/types/layout/models.d.ts +174 -151
- package/types/layout/models.d.ts.map +1 -0
- package/types/layout/themes.d.ts +13 -11
- package/types/layout/themes.d.ts.map +1 -0
- package/types/layout/utils.d.ts +56 -41
- package/types/layout/utils.d.ts.map +1 -0
- package/types/media/index.d.ts +3 -2
- package/types/media/index.d.ts.map +1 -0
- package/types/media/media-api.d.ts +60 -55
- package/types/media/media-api.d.ts.map +1 -0
- package/types/models.d.ts +94 -84
- package/types/models.d.ts.map +1 -0
- package/types/native-fetcher.d.ts +124 -114
- package/types/native-fetcher.d.ts.map +1 -0
- package/types/personalize/index.d.ts +4 -3
- package/types/personalize/index.d.ts.map +1 -0
- package/types/personalize/layout-personalizer.d.ts +29 -27
- package/types/personalize/layout-personalizer.d.ts.map +1 -0
- package/types/personalize/personalize-service.d.ts +90 -80
- package/types/personalize/personalize-service.d.ts.map +1 -0
- package/types/personalize/utils.d.ts +78 -69
- package/types/personalize/utils.d.ts.map +1 -0
- package/types/retries.d.ts +26 -24
- package/types/retries.d.ts.map +1 -0
- package/types/site/error-pages-service.d.ts +64 -57
- package/types/site/error-pages-service.d.ts.map +1 -0
- package/types/site/index.d.ts +10 -9
- package/types/site/index.d.ts.map +1 -0
- package/types/site/models.d.ts +23 -18
- package/types/site/models.d.ts.map +1 -0
- package/types/site/redirects-service.d.ts +92 -69
- package/types/site/redirects-service.d.ts.map +1 -0
- package/types/site/robots-service.d.ts +57 -50
- package/types/site/robots-service.d.ts.map +1 -0
- package/types/site/site-resolver.d.ts +28 -26
- package/types/site/site-resolver.d.ts.map +1 -0
- package/types/site/siteinfo-service.d.ts +65 -52
- package/types/site/siteinfo-service.d.ts.map +1 -0
- package/types/site/sitemap-xml-service.d.ts +63 -56
- package/types/site/sitemap-xml-service.d.ts.map +1 -0
- package/types/site/sitepath-service.d.ts +137 -134
- package/types/site/sitepath-service.d.ts.map +1 -0
- package/types/site/utils.d.ts +41 -28
- package/types/site/utils.d.ts.map +1 -0
- package/types/sitecore-service-base.d.ts +31 -30
- package/types/sitecore-service-base.d.ts.map +1 -0
- package/types/tools/auth/flow.d.ts +29 -27
- package/types/tools/auth/flow.d.ts.map +1 -0
- package/types/tools/auth/index.d.ts +2 -1
- package/types/tools/auth/index.d.ts.map +1 -0
- package/types/tools/auth/models.d.ts +35 -33
- package/types/tools/auth/models.d.ts.map +1 -0
- package/types/tools/auth/tenant-store.d.ts +12 -11
- package/types/tools/auth/tenant-store.d.ts.map +1 -0
- package/types/tools/codegen/component-generation.d.ts +50 -47
- package/types/tools/codegen/component-generation.d.ts.map +1 -0
- package/types/tools/codegen/extract-files.d.ts +24 -22
- package/types/tools/codegen/extract-files.d.ts.map +1 -0
- package/types/tools/codegen/import-map.d.ts +103 -70
- package/types/tools/codegen/import-map.d.ts.map +1 -0
- package/types/tools/codegen/utils.d.ts +76 -75
- package/types/tools/codegen/utils.d.ts.map +1 -0
- package/types/tools/generate-map.d.ts +36 -26
- package/types/tools/generate-map.d.ts.map +1 -0
- package/types/tools/generateMetadata.d.ts +24 -22
- package/types/tools/generateMetadata.d.ts.map +1 -0
- package/types/tools/generateSites.d.ts +25 -22
- package/types/tools/generateSites.d.ts.map +1 -0
- package/types/tools/index.d.ts +22 -20
- package/types/tools/index.d.ts.map +1 -0
- package/types/tools/scaffold.d.ts +27 -25
- package/types/tools/scaffold.d.ts.map +1 -0
- package/types/tools/templating/components.d.ts +104 -103
- package/types/tools/templating/components.d.ts.map +1 -0
- package/types/tools/templating/index.d.ts +4 -3
- package/types/tools/templating/index.d.ts.map +1 -0
- package/types/tools/templating/plugins.d.ts +71 -67
- package/types/tools/templating/plugins.d.ts.map +1 -0
- package/types/tools/templating/utils.d.ts +42 -40
- package/types/tools/templating/utils.d.ts.map +1 -0
- package/types/utils/ensurePath.d.ts +7 -6
- package/types/utils/ensurePath.d.ts.map +1 -0
- package/types/utils/env.d.ts +9 -7
- package/types/utils/env.d.ts.map +1 -0
- package/types/utils/globalCache.d.ts +37 -0
- package/types/utils/globalCache.d.ts.map +1 -0
- package/types/utils/index.d.ts +5 -3
- package/types/utils/index.d.ts.map +1 -0
- package/types/utils/is-server.d.ts +8 -6
- package/types/utils/is-server.d.ts.map +1 -0
- package/types/utils/normalize-url.d.ts +2 -1
- package/types/utils/normalize-url.d.ts.map +1 -0
- package/types/utils/timeout-promise.d.ts +18 -17
- package/types/utils/timeout-promise.d.ts.map +1 -0
- package/types/utils/utils.d.ts +104 -79
- package/types/utils/utils.d.ts.map +1 -0
- package/client.js +0 -1
- package/codegen.js +0 -1
- package/config-cli.js +0 -1
- package/config.js +0 -1
- package/editing.js +0 -1
- package/i18n.js +0 -1
- package/layout.js +0 -1
- package/media.js +0 -1
- package/personalize.js +0 -1
- package/site.js +0 -1
- package/tools.js +0 -1
- package/utils.js +0 -1
package/dist/esm/client/utils.js
CHANGED
|
@@ -1,46 +1,47 @@
|
|
|
1
|
-
import { GraphQLRequestClient } from '../graphql-request-client';
|
|
2
|
-
import { getEdgeProxyContentUrl } from './edge-proxy';
|
|
3
|
-
/**
|
|
4
|
-
* Creates a new GraphQLRequestClientFactory instance
|
|
5
|
-
* @param {GraphQLClientOptions} options content sdk config
|
|
6
|
-
* @returns GraphQLRequestClientFactory instance
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
const {
|
|
12
|
-
const
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
1
|
+
import { GraphQLRequestClient } from '../graphql-request-client';
|
|
2
|
+
import { getEdgeProxyContentUrl } from './edge-proxy';
|
|
3
|
+
/**
|
|
4
|
+
* Creates a new GraphQLRequestClientFactory instance
|
|
5
|
+
* @param {GraphQLClientOptions} options content sdk config
|
|
6
|
+
* @returns GraphQLRequestClientFactory instance
|
|
7
|
+
* @public
|
|
8
|
+
*/
|
|
9
|
+
export const createGraphQLClientFactory = (options) => {
|
|
10
|
+
let clientConfig;
|
|
11
|
+
const { api } = options;
|
|
12
|
+
const { edge, local } = api !== null && api !== void 0 ? api : {};
|
|
13
|
+
const isBrowser = typeof window !== 'undefined';
|
|
14
|
+
if (edge === null || edge === void 0 ? void 0 : edge.contextId) {
|
|
15
|
+
// Real client for server-side rendering / API routes
|
|
16
|
+
clientConfig = {
|
|
17
|
+
endpoint: getEdgeProxyContentUrl(edge.contextId, edge.edgeUrl),
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
else if (isBrowser && (edge === null || edge === void 0 ? void 0 : edge.clientContextId)) {
|
|
21
|
+
// Real client for client-side requests
|
|
22
|
+
clientConfig = {
|
|
23
|
+
endpoint: getEdgeProxyContentUrl(edge.clientContextId, edge.edgeUrl),
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
else if ((local === null || local === void 0 ? void 0 : local.apiKey) && (local === null || local === void 0 ? void 0 : local.apiHost)) {
|
|
27
|
+
// Fallback to local API settings
|
|
28
|
+
clientConfig = {
|
|
29
|
+
endpoint: `${local.apiHost}${local.path}`,
|
|
30
|
+
apiKey: local.apiKey,
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
else if (isBrowser) {
|
|
34
|
+
// Browser bundle has no IDs – initialise a dummy client and warn
|
|
35
|
+
/* eslint-disable no-console */
|
|
36
|
+
console.warn('GraphQL client initialised in the browser without Edge or local API configuration; client-side requests may fail.');
|
|
37
|
+
clientConfig = { endpoint: '/api/graphql' };
|
|
38
|
+
}
|
|
39
|
+
else {
|
|
39
40
|
throw new Error(`GraphQL client misconfigured.
|
|
40
41
|
Configure one of the following in sitecore.config or your .env file:
|
|
41
42
|
Edge mode: set both sitecore.edge.contextId (server-side) and sitecore.edge.clientContextId (browser).
|
|
42
43
|
Local API mode: set api.local.apiHost and api.local.apiKey.
|
|
43
|
-
Supplying only api.edge.clientContextId will cause the application to fail at runtime.`);
|
|
44
|
-
}
|
|
45
|
-
return GraphQLRequestClient.createClientFactory(Object.assign(Object.assign({}, clientConfig), options));
|
|
46
|
-
};
|
|
44
|
+
Supplying only api.edge.clientContextId will cause the application to fail at runtime.`);
|
|
45
|
+
}
|
|
46
|
+
return GraphQLRequestClient.createClientFactory(Object.assign(Object.assign({}, clientConfig), options));
|
|
47
|
+
};
|
|
@@ -1,188 +1,189 @@
|
|
|
1
|
-
import { SITECORE_EDGE_URL_DEFAULT } from '../constants';
|
|
2
|
-
import { DefaultRetryStrategy } from '../retries';
|
|
3
|
-
import { SITECORE_CLI_MODE_ENV_VAR } from '../config-cli';
|
|
4
|
-
/**
|
|
5
|
-
* Provides default initial values for SitecoreConfig
|
|
6
|
-
* @returns default config
|
|
7
|
-
*/
|
|
8
|
-
export const getFallbackConfig = () => ({
|
|
9
|
-
api: {
|
|
10
|
-
edge: {
|
|
11
|
-
contextId: process.env.SITECORE_EDGE_CONTEXT_ID || '',
|
|
12
|
-
clientContextId: '',
|
|
13
|
-
edgeUrl: process.env.SITECORE_EDGE_URL || SITECORE_EDGE_URL_DEFAULT,
|
|
14
|
-
},
|
|
15
|
-
local: {
|
|
16
|
-
apiKey: process.env.SITECORE_API_KEY || process.env.NEXT_PUBLIC_SITECORE_API_KEY || '',
|
|
17
|
-
apiHost: process.env.SITECORE_API_HOST || process.env.NEXT_PUBLIC_SITECORE_API_HOST || '',
|
|
18
|
-
path: '/sitecore/api/graph/edge',
|
|
19
|
-
},
|
|
20
|
-
},
|
|
21
|
-
editingSecret: process.env.SITECORE_EDITING_SECRET || 'editing-secret-missing',
|
|
22
|
-
retries: {
|
|
23
|
-
count: 3,
|
|
24
|
-
retryStrategy: new DefaultRetryStrategy({
|
|
25
|
-
statusCodes: [429, 502, 503, 504, 520, 521, 522, 523, 524],
|
|
26
|
-
}),
|
|
27
|
-
},
|
|
28
|
-
redirects: {
|
|
29
|
-
enabled: process.env.NODE_ENV !== 'development',
|
|
30
|
-
locales: ['en'],
|
|
31
|
-
},
|
|
32
|
-
multisite: {
|
|
33
|
-
enabled: true,
|
|
34
|
-
useCookieResolution: () => false,
|
|
35
|
-
},
|
|
36
|
-
personalize: {
|
|
37
|
-
enabled: process.env.NODE_ENV !== 'development',
|
|
38
|
-
edgeTimeout: parseInt(process.env.PERSONALIZE_MIDDLEWARE_EDGE_TIMEOUT, 10) || 400,
|
|
39
|
-
cdpTimeout: parseInt(process.env.PERSONALIZE_MIDDLEWARE_CDP_TIMEOUT, 10) || 400,
|
|
40
|
-
scope: '',
|
|
41
|
-
channel: 'WEB',
|
|
42
|
-
currency: 'USD',
|
|
43
|
-
},
|
|
44
|
-
defaultSite: '',
|
|
45
|
-
defaultLanguage: 'en',
|
|
46
|
-
layout: {
|
|
47
|
-
formatLayoutQuery: null,
|
|
48
|
-
},
|
|
49
|
-
dictionary: {
|
|
50
|
-
caching: {
|
|
51
|
-
enabled: true,
|
|
52
|
-
timeout: 60,
|
|
53
|
-
},
|
|
54
|
-
},
|
|
55
|
-
disableCodeGeneration: false,
|
|
56
|
-
});
|
|
57
|
-
/**
|
|
58
|
-
* Deep merge utility that skips undefined or empty string values in the override.
|
|
59
|
-
* @param {T} base base value
|
|
60
|
-
* @param {DeepPartial<T>} [override] override value
|
|
61
|
-
*/
|
|
62
|
-
export function deepMerge(base, override) {
|
|
63
|
-
if (!override)
|
|
64
|
-
return base;
|
|
65
|
-
const result = Object.assign({}, base);
|
|
66
|
-
for (const key in override) {
|
|
67
|
-
if (!Object.prototype.hasOwnProperty.call(override, key))
|
|
68
|
-
continue;
|
|
69
|
-
const typedKey = key;
|
|
70
|
-
const baseValue = base[typedKey];
|
|
71
|
-
const overrideValue = override[typedKey];
|
|
72
|
-
// Skip undefined and empty string overrides
|
|
73
|
-
if (overrideValue === undefined || overrideValue === '') {
|
|
74
|
-
continue;
|
|
75
|
-
}
|
|
76
|
-
if (typeof overrideValue === 'object' &&
|
|
77
|
-
overrideValue !== null &&
|
|
78
|
-
!Array.isArray(overrideValue) &&
|
|
79
|
-
Object.getPrototypeOf(overrideValue) === Object.prototype) {
|
|
80
|
-
result[typedKey] = deepMerge(baseValue, overrideValue);
|
|
81
|
-
}
|
|
82
|
-
else {
|
|
83
|
-
result[typedKey] = overrideValue;
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
return result;
|
|
87
|
-
}
|
|
88
|
-
/**
|
|
89
|
-
* Resolves sitecore config based on base config and overrides
|
|
90
|
-
* @param {SitecoreConfig} base base sitecore config object
|
|
91
|
-
* @param {SitecoreConfig} override override sitecore config object
|
|
92
|
-
* @returns resolved SitecoreConfig object
|
|
93
|
-
*/
|
|
94
|
-
const resolveConfig = (base, override) => {
|
|
95
|
-
const result = deepMerge(base, override);
|
|
96
|
-
if (Number.isNaN(result.personalize.cdpTimeout) || !result.personalize.cdpTimeout) {
|
|
97
|
-
result.personalize.cdpTimeout = base.personalize.cdpTimeout;
|
|
98
|
-
}
|
|
99
|
-
if (Number.isNaN(result.personalize.edgeTimeout) || !result.personalize.edgeTimeout) {
|
|
100
|
-
result.personalize.edgeTimeout = base.personalize.edgeTimeout;
|
|
101
|
-
}
|
|
102
|
-
return result;
|
|
103
|
-
};
|
|
104
|
-
const validateApiConfiguration = (config) => {
|
|
105
|
-
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
106
|
-
const isBrowser = typeof window !== 'undefined';
|
|
107
|
-
const hasEdgeContextId = !!((_b = (_a = config.api) === null || _a === void 0 ? void 0 : _a.edge) === null || _b === void 0 ? void 0 : _b.contextId);
|
|
108
|
-
const hasClientContextId = !!((_d = (_c = config.api) === null || _c === void 0 ? void 0 : _c.edge) === null || _d === void 0 ? void 0 : _d.clientContextId);
|
|
109
|
-
const hasLocalCreds = !!((_f = (_e = config.api) === null || _e === void 0 ? void 0 : _e.local) === null || _f === void 0 ? void 0 : _f.apiHost) && !!((_h = (_g = config.api) === null || _g === void 0 ? void 0 : _g.local) === null || _h === void 0 ? void 0 : _h.apiKey);
|
|
110
|
-
// Server-side: allow Edge OR Local; clientContextId alone is NOT sufficient
|
|
111
|
-
if (!isBrowser) {
|
|
112
|
-
if (!hasEdgeContextId && !hasLocalCreds) {
|
|
113
|
-
throw new Error('Configuration error: provide either Edge contextId (api.edge.contextId) or local credentials (api.local.apiHost + api.local.apiKey).');
|
|
114
|
-
}
|
|
115
|
-
if (hasEdgeContextId && !hasClientContextId) {
|
|
116
|
-
// eslint-disable-next-line no-console
|
|
117
|
-
if (process.env.NODE_ENV === 'development') {
|
|
118
|
-
console.warn('Warning: only a server-side edge contextId is provided. Client-side requests will require api.edge.clientContextId or a proxy.');
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
|
-
return; // validation complete on the server
|
|
122
|
-
}
|
|
123
|
-
// Browser-side warning (runs only if contextId exists but clientContextId is missing)
|
|
124
|
-
if (isBrowser && !hasClientContextId) {
|
|
125
|
-
// eslint-disable-next-line no-console
|
|
126
|
-
if (process.env.NODE_ENV === 'development') {
|
|
1
|
+
import { SITECORE_EDGE_URL_DEFAULT } from '../constants';
|
|
2
|
+
import { DefaultRetryStrategy } from '../retries';
|
|
3
|
+
import { SITECORE_CLI_MODE_ENV_VAR } from '../config-cli';
|
|
4
|
+
/**
|
|
5
|
+
* Provides default initial values for SitecoreConfig
|
|
6
|
+
* @returns default config
|
|
7
|
+
*/
|
|
8
|
+
export const getFallbackConfig = () => ({
|
|
9
|
+
api: {
|
|
10
|
+
edge: {
|
|
11
|
+
contextId: process.env.SITECORE_EDGE_CONTEXT_ID || '',
|
|
12
|
+
clientContextId: '',
|
|
13
|
+
edgeUrl: process.env.SITECORE_EDGE_URL || SITECORE_EDGE_URL_DEFAULT,
|
|
14
|
+
},
|
|
15
|
+
local: {
|
|
16
|
+
apiKey: process.env.SITECORE_API_KEY || process.env.NEXT_PUBLIC_SITECORE_API_KEY || '',
|
|
17
|
+
apiHost: process.env.SITECORE_API_HOST || process.env.NEXT_PUBLIC_SITECORE_API_HOST || '',
|
|
18
|
+
path: '/sitecore/api/graph/edge',
|
|
19
|
+
},
|
|
20
|
+
},
|
|
21
|
+
editingSecret: process.env.SITECORE_EDITING_SECRET || 'editing-secret-missing',
|
|
22
|
+
retries: {
|
|
23
|
+
count: 3,
|
|
24
|
+
retryStrategy: new DefaultRetryStrategy({
|
|
25
|
+
statusCodes: [429, 502, 503, 504, 520, 521, 522, 523, 524],
|
|
26
|
+
}),
|
|
27
|
+
},
|
|
28
|
+
redirects: {
|
|
29
|
+
enabled: process.env.NODE_ENV !== 'development',
|
|
30
|
+
locales: ['en'],
|
|
31
|
+
},
|
|
32
|
+
multisite: {
|
|
33
|
+
enabled: true,
|
|
34
|
+
useCookieResolution: () => false,
|
|
35
|
+
},
|
|
36
|
+
personalize: {
|
|
37
|
+
enabled: process.env.NODE_ENV !== 'development',
|
|
38
|
+
edgeTimeout: parseInt(process.env.PERSONALIZE_MIDDLEWARE_EDGE_TIMEOUT, 10) || 400,
|
|
39
|
+
cdpTimeout: parseInt(process.env.PERSONALIZE_MIDDLEWARE_CDP_TIMEOUT, 10) || 400,
|
|
40
|
+
scope: '',
|
|
41
|
+
channel: 'WEB',
|
|
42
|
+
currency: 'USD',
|
|
43
|
+
},
|
|
44
|
+
defaultSite: '',
|
|
45
|
+
defaultLanguage: 'en',
|
|
46
|
+
layout: {
|
|
47
|
+
formatLayoutQuery: null,
|
|
48
|
+
},
|
|
49
|
+
dictionary: {
|
|
50
|
+
caching: {
|
|
51
|
+
enabled: true,
|
|
52
|
+
timeout: 60,
|
|
53
|
+
},
|
|
54
|
+
},
|
|
55
|
+
disableCodeGeneration: false,
|
|
56
|
+
});
|
|
57
|
+
/**
|
|
58
|
+
* Deep merge utility that skips undefined or empty string values in the override.
|
|
59
|
+
* @param {T} base base value
|
|
60
|
+
* @param {DeepPartial<T>} [override] override value
|
|
61
|
+
*/
|
|
62
|
+
export function deepMerge(base, override) {
|
|
63
|
+
if (!override)
|
|
64
|
+
return base;
|
|
65
|
+
const result = Object.assign({}, base);
|
|
66
|
+
for (const key in override) {
|
|
67
|
+
if (!Object.prototype.hasOwnProperty.call(override, key))
|
|
68
|
+
continue;
|
|
69
|
+
const typedKey = key;
|
|
70
|
+
const baseValue = base[typedKey];
|
|
71
|
+
const overrideValue = override[typedKey];
|
|
72
|
+
// Skip undefined and empty string overrides
|
|
73
|
+
if (overrideValue === undefined || overrideValue === '') {
|
|
74
|
+
continue;
|
|
75
|
+
}
|
|
76
|
+
if (typeof overrideValue === 'object' &&
|
|
77
|
+
overrideValue !== null &&
|
|
78
|
+
!Array.isArray(overrideValue) &&
|
|
79
|
+
Object.getPrototypeOf(overrideValue) === Object.prototype) {
|
|
80
|
+
result[typedKey] = deepMerge(baseValue, overrideValue);
|
|
81
|
+
}
|
|
82
|
+
else {
|
|
83
|
+
result[typedKey] = overrideValue;
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
return result;
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* Resolves sitecore config based on base config and overrides
|
|
90
|
+
* @param {SitecoreConfig} base base sitecore config object
|
|
91
|
+
* @param {SitecoreConfig} override override sitecore config object
|
|
92
|
+
* @returns resolved SitecoreConfig object
|
|
93
|
+
*/
|
|
94
|
+
const resolveConfig = (base, override) => {
|
|
95
|
+
const result = deepMerge(base, override);
|
|
96
|
+
if (Number.isNaN(result.personalize.cdpTimeout) || !result.personalize.cdpTimeout) {
|
|
97
|
+
result.personalize.cdpTimeout = base.personalize.cdpTimeout;
|
|
98
|
+
}
|
|
99
|
+
if (Number.isNaN(result.personalize.edgeTimeout) || !result.personalize.edgeTimeout) {
|
|
100
|
+
result.personalize.edgeTimeout = base.personalize.edgeTimeout;
|
|
101
|
+
}
|
|
102
|
+
return result;
|
|
103
|
+
};
|
|
104
|
+
const validateApiConfiguration = (config) => {
|
|
105
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
106
|
+
const isBrowser = typeof window !== 'undefined';
|
|
107
|
+
const hasEdgeContextId = !!((_b = (_a = config.api) === null || _a === void 0 ? void 0 : _a.edge) === null || _b === void 0 ? void 0 : _b.contextId);
|
|
108
|
+
const hasClientContextId = !!((_d = (_c = config.api) === null || _c === void 0 ? void 0 : _c.edge) === null || _d === void 0 ? void 0 : _d.clientContextId);
|
|
109
|
+
const hasLocalCreds = !!((_f = (_e = config.api) === null || _e === void 0 ? void 0 : _e.local) === null || _f === void 0 ? void 0 : _f.apiHost) && !!((_h = (_g = config.api) === null || _g === void 0 ? void 0 : _g.local) === null || _h === void 0 ? void 0 : _h.apiKey);
|
|
110
|
+
// Server-side: allow Edge OR Local; clientContextId alone is NOT sufficient
|
|
111
|
+
if (!isBrowser) {
|
|
112
|
+
if (!hasEdgeContextId && !hasLocalCreds) {
|
|
113
|
+
throw new Error('Configuration error: provide either Edge contextId (api.edge.contextId) or local credentials (api.local.apiHost + api.local.apiKey).');
|
|
114
|
+
}
|
|
115
|
+
if (hasEdgeContextId && !hasClientContextId) {
|
|
116
|
+
// eslint-disable-next-line no-console
|
|
117
|
+
if (process.env.NODE_ENV === 'development') {
|
|
118
|
+
console.warn('Warning: only a server-side edge contextId is provided. Client-side requests will require api.edge.clientContextId or a proxy.');
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
return; // validation complete on the server
|
|
122
|
+
}
|
|
123
|
+
// Browser-side warning (runs only if contextId exists but clientContextId is missing)
|
|
124
|
+
if (isBrowser && !hasClientContextId) {
|
|
125
|
+
// eslint-disable-next-line no-console
|
|
126
|
+
if (process.env.NODE_ENV === 'development') {
|
|
127
127
|
console.warn(`Warning: clientContextId is missing. The browser will use contextId instead.
|
|
128
|
-
Client Side functionalities (like Tracking and Personalization) may be limited.`);
|
|
129
|
-
}
|
|
130
|
-
}
|
|
131
|
-
};
|
|
132
|
-
/**
|
|
133
|
-
* The validators for the config object during build time.
|
|
134
|
-
* Validators are called when the literal path of the config object is accessed.
|
|
135
|
-
*/
|
|
136
|
-
const PROPERTY_VALIDATORS = {
|
|
137
|
-
'api.edge.contextId': validateApiConfiguration,
|
|
138
|
-
'api.local.apiKey': validateApiConfiguration,
|
|
139
|
-
};
|
|
140
|
-
/**
|
|
141
|
-
* Creates a proxy for the config object to validate the config object during build time.
|
|
142
|
-
* @param {SitecoreConfig} config - The config object to create a proxy for.
|
|
143
|
-
* @returns {SitecoreConfig} The proxy for the config object.
|
|
144
|
-
*/
|
|
145
|
-
const createConfigProxy = (config) => {
|
|
146
|
-
const validated = new Set();
|
|
147
|
-
const createProxy = (target, propPath = '') => {
|
|
148
|
-
return new Proxy(target, {
|
|
149
|
-
get(obj, prop, receiver) {
|
|
150
|
-
// Skip symbol properties, do not attempt to stringify them
|
|
151
|
-
// Type safety check
|
|
152
|
-
if (typeof prop === 'symbol') {
|
|
153
|
-
return Reflect.get(obj, prop, receiver);
|
|
154
|
-
}
|
|
155
|
-
const fullPath = propPath ? `${propPath}.${prop}` : prop;
|
|
156
|
-
const value = Reflect.get(obj, prop, receiver);
|
|
157
|
-
if (fullPath in PROPERTY_VALIDATORS &&
|
|
158
|
-
!validated.has(fullPath)) {
|
|
159
|
-
const validator = PROPERTY_VALIDATORS[fullPath];
|
|
160
|
-
validator(config);
|
|
161
|
-
validated.add(fullPath);
|
|
162
|
-
}
|
|
163
|
-
if (typeof value === 'object' && value !== null && !Array.isArray(value)) {
|
|
164
|
-
return createProxy(value, fullPath);
|
|
165
|
-
}
|
|
166
|
-
return value;
|
|
167
|
-
},
|
|
168
|
-
});
|
|
169
|
-
};
|
|
170
|
-
return createProxy(config);
|
|
171
|
-
};
|
|
172
|
-
/**
|
|
173
|
-
* Accepts a SitecoreConfigInput object and returns full sitecore configuration
|
|
174
|
-
* @param {SitecoreConfigInput} config override values to be written over default config settings
|
|
175
|
-
* @returns {SitecoreConfig} full sitecore configuration to use in application
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
const
|
|
180
|
-
|
|
181
|
-
//
|
|
182
|
-
//
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
128
|
+
Client Side functionalities (like Tracking and Personalization) may be limited.`);
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
};
|
|
132
|
+
/**
|
|
133
|
+
* The validators for the config object during build time.
|
|
134
|
+
* Validators are called when the literal path of the config object is accessed.
|
|
135
|
+
*/
|
|
136
|
+
const PROPERTY_VALIDATORS = {
|
|
137
|
+
'api.edge.contextId': validateApiConfiguration,
|
|
138
|
+
'api.local.apiKey': validateApiConfiguration,
|
|
139
|
+
};
|
|
140
|
+
/**
|
|
141
|
+
* Creates a proxy for the config object to validate the config object during build time.
|
|
142
|
+
* @param {SitecoreConfig} config - The config object to create a proxy for.
|
|
143
|
+
* @returns {SitecoreConfig} The proxy for the config object.
|
|
144
|
+
*/
|
|
145
|
+
const createConfigProxy = (config) => {
|
|
146
|
+
const validated = new Set();
|
|
147
|
+
const createProxy = (target, propPath = '') => {
|
|
148
|
+
return new Proxy(target, {
|
|
149
|
+
get(obj, prop, receiver) {
|
|
150
|
+
// Skip symbol properties, do not attempt to stringify them
|
|
151
|
+
// Type safety check
|
|
152
|
+
if (typeof prop === 'symbol') {
|
|
153
|
+
return Reflect.get(obj, prop, receiver);
|
|
154
|
+
}
|
|
155
|
+
const fullPath = propPath ? `${propPath}.${prop}` : prop;
|
|
156
|
+
const value = Reflect.get(obj, prop, receiver);
|
|
157
|
+
if (fullPath in PROPERTY_VALIDATORS &&
|
|
158
|
+
!validated.has(fullPath)) {
|
|
159
|
+
const validator = PROPERTY_VALIDATORS[fullPath];
|
|
160
|
+
validator(config);
|
|
161
|
+
validated.add(fullPath);
|
|
162
|
+
}
|
|
163
|
+
if (typeof value === 'object' && value !== null && !Array.isArray(value)) {
|
|
164
|
+
return createProxy(value, fullPath);
|
|
165
|
+
}
|
|
166
|
+
return value;
|
|
167
|
+
},
|
|
168
|
+
});
|
|
169
|
+
};
|
|
170
|
+
return createProxy(config);
|
|
171
|
+
};
|
|
172
|
+
/**
|
|
173
|
+
* Accepts a SitecoreConfigInput object and returns full sitecore configuration
|
|
174
|
+
* @param {SitecoreConfigInput} config override values to be written over default config settings
|
|
175
|
+
* @returns {SitecoreConfig} full sitecore configuration to use in application
|
|
176
|
+
* @public
|
|
177
|
+
*/
|
|
178
|
+
export const defineConfig = (config) => {
|
|
179
|
+
const resolvedConfig = resolveConfig(getFallbackConfig(), config);
|
|
180
|
+
const isCLI = process.env[SITECORE_CLI_MODE_ENV_VAR] === 'true';
|
|
181
|
+
// At `build time`, we create a proxy for the config object to validate the config by
|
|
182
|
+
// accessing the literal paths instead of validating the whole object at once.
|
|
183
|
+
// At `runtime` all the config should be validated to fail fast in case of invalid configuration.
|
|
184
|
+
if (isCLI) {
|
|
185
|
+
return createConfigProxy(resolvedConfig);
|
|
186
|
+
}
|
|
187
|
+
validateApiConfiguration(resolvedConfig);
|
|
188
|
+
return resolvedConfig;
|
|
189
|
+
};
|
package/dist/esm/config/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { ComponentTemplateType, } from './models';
|
|
2
|
-
export { defineConfig } from './define-config';
|
|
1
|
+
export { ComponentTemplateType, } from './models';
|
|
2
|
+
export { defineConfig } from './define-config';
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Enumeration of default component templates
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
ComponentTemplateType["
|
|
8
|
-
|
|
1
|
+
/**
|
|
2
|
+
* Enumeration of default component templates
|
|
3
|
+
* @internal
|
|
4
|
+
*/
|
|
5
|
+
export var ComponentTemplateType;
|
|
6
|
+
(function (ComponentTemplateType) {
|
|
7
|
+
ComponentTemplateType["BYOC"] = "byoc";
|
|
8
|
+
ComponentTemplateType["DEFAULT"] = "default";
|
|
9
|
+
})(ComponentTemplateType || (ComponentTemplateType = {}));
|
|
@@ -1,18 +1,19 @@
|
|
|
1
|
-
const validateConfig = (cliConfig) => {
|
|
2
|
-
var _a, _b, _c, _d;
|
|
3
|
-
if (!((_b = (_a = cliConfig.build) === null || _a === void 0 ? void 0 : _a.commands) === null || _b === void 0 ? void 0 : _b.length)) {
|
|
4
|
-
throw new Error('Configuration error: build commands should be defined in sitecore.cli.config');
|
|
5
|
-
}
|
|
6
|
-
if (!((_d = (_c = cliConfig.scaffold) === null || _c === void 0 ? void 0 : _c.templates) === null || _d === void 0 ? void 0 : _d.length)) {
|
|
7
|
-
throw new Error('Configuration error: scaffold templates should be defined in sitecore.cli.config');
|
|
8
|
-
}
|
|
9
|
-
};
|
|
10
|
-
/**
|
|
11
|
-
* Accepts a `SitecoreCliConfigInput` object and returns Sitecore Content SDK CLI configuration, updated with required default values
|
|
12
|
-
* @param {SitecoreCliConfigInput} cliConfig the cli configuration provided by the application
|
|
13
|
-
* @returns {SitecoreCliConfig} full sitecore cli configuration to use with cli
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
1
|
+
const validateConfig = (cliConfig) => {
|
|
2
|
+
var _a, _b, _c, _d;
|
|
3
|
+
if (!((_b = (_a = cliConfig.build) === null || _a === void 0 ? void 0 : _a.commands) === null || _b === void 0 ? void 0 : _b.length)) {
|
|
4
|
+
throw new Error('Configuration error: build commands should be defined in sitecore.cli.config');
|
|
5
|
+
}
|
|
6
|
+
if (!((_d = (_c = cliConfig.scaffold) === null || _c === void 0 ? void 0 : _c.templates) === null || _d === void 0 ? void 0 : _d.length)) {
|
|
7
|
+
throw new Error('Configuration error: scaffold templates should be defined in sitecore.cli.config');
|
|
8
|
+
}
|
|
9
|
+
};
|
|
10
|
+
/**
|
|
11
|
+
* Accepts a `SitecoreCliConfigInput` object and returns Sitecore Content SDK CLI configuration, updated with required default values
|
|
12
|
+
* @param {SitecoreCliConfigInput} cliConfig the cli configuration provided by the application
|
|
13
|
+
* @returns {SitecoreCliConfig} full sitecore cli configuration to use with cli
|
|
14
|
+
* @public
|
|
15
|
+
*/
|
|
16
|
+
export const defineCliConfig = (cliConfig) => {
|
|
17
|
+
validateConfig(cliConfig);
|
|
18
|
+
return cliConfig;
|
|
19
|
+
};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { defineCliConfig } from './define-cli-config';
|
|
2
|
-
export { SITECORE_CLI_MODE_ENV_VAR } from './models';
|
|
1
|
+
export { defineCliConfig } from './define-cli-config';
|
|
2
|
+
export { SITECORE_CLI_MODE_ENV_VAR } from './models';
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Environment variable to indicate that the application is running in CLI mode
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
/**
|
|
2
|
+
* Environment variable to indicate that the application is running in CLI mode
|
|
3
|
+
* @internal
|
|
4
|
+
*/
|
|
5
|
+
export const SITECORE_CLI_MODE_ENV_VAR = 'SITECORE_CLI_MODE';
|
package/dist/esm/constants.js
CHANGED
|
@@ -1,14 +1,46 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
1
|
+
/**
|
|
2
|
+
* Sitecore template IDs
|
|
3
|
+
* @public
|
|
4
|
+
*/
|
|
5
|
+
export var SitecoreTemplateId;
|
|
6
|
+
(function (SitecoreTemplateId) {
|
|
7
|
+
// /sitecore/templates/Foundation/JavaScript Services/App
|
|
8
|
+
SitecoreTemplateId["ContentSdkApp"] = "061cba1554744b918a0617903b102b82";
|
|
9
|
+
// /sitecore/templates/System/Dictionary/Dictionary entry
|
|
10
|
+
SitecoreTemplateId["DictionaryEntry"] = "6d1cd89719364a3aa511289a94c2a7b1";
|
|
11
|
+
})(SitecoreTemplateId || (SitecoreTemplateId = {}));
|
|
12
|
+
/**
|
|
13
|
+
* Site name error
|
|
14
|
+
* @internal
|
|
15
|
+
*/
|
|
16
|
+
export const siteNameError = 'The siteName cannot be empty';
|
|
17
|
+
/**
|
|
18
|
+
* Default Sitecore edge URL
|
|
19
|
+
* @internal
|
|
20
|
+
*/
|
|
21
|
+
export const SITECORE_EDGE_URL_DEFAULT = 'https://edge-platform.sitecorecloud.io';
|
|
22
|
+
/**
|
|
23
|
+
* Hidden rendering name
|
|
24
|
+
* @internal
|
|
25
|
+
*/
|
|
26
|
+
export const HIDDEN_RENDERING_NAME = 'Hidden Rendering';
|
|
27
|
+
/**
|
|
28
|
+
* Claims URL
|
|
29
|
+
* @internal
|
|
30
|
+
*/
|
|
31
|
+
export const CLAIMS = 'https://auth.sitecorecloud.io/claims';
|
|
32
|
+
/**
|
|
33
|
+
* Default Sitecore auth domain
|
|
34
|
+
* @internal
|
|
35
|
+
*/
|
|
36
|
+
export const DEFAULT_SITECORE_AUTH_DOMAIN = 'https://auth.sitecorecloud.io';
|
|
37
|
+
/**
|
|
38
|
+
* Default Sitecore auth audience
|
|
39
|
+
* @internal
|
|
40
|
+
*/
|
|
41
|
+
export const DEFAULT_SITECORE_AUTH_AUDIENCE = 'https://api.sitecorecloud.io';
|
|
42
|
+
/**
|
|
43
|
+
* Default Sitecore auth base URL
|
|
44
|
+
* @internal
|
|
45
|
+
*/
|
|
46
|
+
export const DEFAULT_SITECORE_AUTH_BASE_URL = 'https://edge-platform.sitecorecloud.io/cs/api';
|