@sitecore-content-sdk/content 1.5.0-canary.10
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/LICENSE.txt +202 -0
- package/README.md +7 -0
- package/client.d.ts +1 -0
- package/codegen.d.ts +1 -0
- package/config-cli.d.ts +1 -0
- package/config.d.ts +1 -0
- package/dist/cjs/client/edge-proxy.js +29 -0
- package/dist/cjs/client/index.js +14 -0
- package/dist/cjs/client/models.js +2 -0
- package/dist/cjs/client/sitecore-client.js +443 -0
- package/dist/cjs/client/utils.js +53 -0
- package/dist/cjs/config/define-config.js +200 -0
- package/dist/cjs/config/index.js +7 -0
- package/dist/cjs/config/models.js +12 -0
- package/dist/cjs/config-cli/define-cli-config.js +23 -0
- package/dist/cjs/config-cli/index.js +7 -0
- package/dist/cjs/config-cli/models.js +8 -0
- package/dist/cjs/constants.js +12 -0
- package/dist/cjs/debug.js +21 -0
- package/dist/cjs/editing/codegen/index.js +15 -0
- package/dist/cjs/editing/codegen/preview.js +305 -0
- package/dist/cjs/editing/component-layout-service.js +63 -0
- package/dist/cjs/editing/design-library.js +191 -0
- package/dist/cjs/editing/editing-service.js +82 -0
- package/dist/cjs/editing/index.js +34 -0
- package/dist/cjs/editing/models.js +44 -0
- package/dist/cjs/editing/utils.js +105 -0
- package/dist/cjs/form/form.js +81 -0
- package/dist/cjs/form/index.js +7 -0
- package/dist/cjs/i18n/dictionary-service.js +144 -0
- package/dist/cjs/i18n/index.js +7 -0
- package/dist/cjs/i18n/utils.js +16 -0
- package/dist/cjs/index.js +47 -0
- package/dist/cjs/layout/content-styles.js +72 -0
- package/dist/cjs/layout/index.js +29 -0
- package/dist/cjs/layout/layout-service.js +69 -0
- package/dist/cjs/layout/models.js +39 -0
- package/dist/cjs/layout/rewrite-edge-host.js +161 -0
- package/dist/cjs/layout/themes.js +74 -0
- package/dist/cjs/layout/utils.js +117 -0
- package/dist/cjs/media/index.js +38 -0
- package/dist/cjs/media/media-api.js +100 -0
- package/dist/cjs/models.js +2 -0
- package/dist/cjs/personalize/index.js +15 -0
- package/dist/cjs/personalize/layout-personalizer.js +98 -0
- package/dist/cjs/personalize/personalize-service.js +109 -0
- package/dist/cjs/personalize/utils.js +143 -0
- package/dist/cjs/site/error-pages-service.js +95 -0
- package/dist/cjs/site/index.js +26 -0
- package/dist/cjs/site/models.js +2 -0
- package/dist/cjs/site/redirects-service.js +109 -0
- package/dist/cjs/site/robots-service.js +74 -0
- package/dist/cjs/site/site-resolver.js +73 -0
- package/dist/cjs/site/siteinfo-service.js +94 -0
- package/dist/cjs/site/sitemap-xml-service.js +92 -0
- package/dist/cjs/site/sitepath-service.js +201 -0
- package/dist/cjs/site/utils.js +55 -0
- package/dist/cjs/sitecore-service-base.js +33 -0
- package/dist/cjs/tools/codegen/component-generation.js +49 -0
- package/dist/cjs/tools/codegen/extract-files.js +103 -0
- package/dist/cjs/tools/codegen/import-map.js +398 -0
- package/dist/cjs/tools/codegen/utils.js +418 -0
- package/dist/cjs/tools/generate-map.js +2 -0
- package/dist/cjs/tools/generateSites.js +58 -0
- package/dist/cjs/tools/index.js +30 -0
- package/dist/cjs/tools/scaffold.js +62 -0
- package/dist/cjs/tools/templating/components.js +96 -0
- package/dist/cjs/tools/templating/index.js +6 -0
- package/dist/esm/client/edge-proxy.js +24 -0
- package/dist/esm/client/index.js +4 -0
- package/dist/esm/client/models.js +1 -0
- package/dist/esm/client/sitecore-client.js +439 -0
- package/dist/esm/client/utils.js +49 -0
- package/dist/esm/config/define-config.js +194 -0
- package/dist/esm/config/index.js +2 -0
- package/dist/esm/config/models.js +9 -0
- package/dist/esm/config-cli/define-cli-config.js +19 -0
- package/dist/esm/config-cli/index.js +2 -0
- package/dist/esm/config-cli/models.js +5 -0
- package/dist/esm/constants.js +9 -0
- package/dist/esm/debug.js +19 -0
- package/dist/esm/editing/codegen/index.js +1 -0
- package/dist/esm/editing/codegen/preview.js +287 -0
- package/dist/esm/editing/component-layout-service.js +56 -0
- package/dist/esm/editing/design-library.js +179 -0
- package/dist/esm/editing/editing-service.js +75 -0
- package/dist/esm/editing/index.js +6 -0
- package/dist/esm/editing/models.js +41 -0
- package/dist/esm/editing/utils.js +98 -0
- package/dist/esm/form/form.js +72 -0
- package/dist/esm/form/index.js +1 -0
- package/dist/esm/i18n/dictionary-service.js +137 -0
- package/dist/esm/i18n/index.js +2 -0
- package/dist/esm/i18n/utils.js +13 -0
- package/dist/esm/index.js +5 -0
- package/dist/esm/layout/content-styles.js +64 -0
- package/dist/esm/layout/index.js +7 -0
- package/dist/esm/layout/layout-service.js +62 -0
- package/dist/esm/layout/models.js +36 -0
- package/dist/esm/layout/rewrite-edge-host.js +155 -0
- package/dist/esm/layout/themes.js +69 -0
- package/dist/esm/layout/utils.js +109 -0
- package/dist/esm/media/index.js +2 -0
- package/dist/esm/media/media-api.js +90 -0
- package/dist/esm/models.js +1 -0
- package/dist/esm/personalize/index.js +3 -0
- package/dist/esm/personalize/layout-personalizer.js +93 -0
- package/dist/esm/personalize/personalize-service.js +102 -0
- package/dist/esm/personalize/utils.js +135 -0
- package/dist/esm/site/error-pages-service.js +88 -0
- package/dist/esm/site/index.js +8 -0
- package/dist/esm/site/models.js +1 -0
- package/dist/esm/site/redirects-service.js +102 -0
- package/dist/esm/site/robots-service.js +67 -0
- package/dist/esm/site/site-resolver.js +69 -0
- package/dist/esm/site/siteinfo-service.js +87 -0
- package/dist/esm/site/sitemap-xml-service.js +85 -0
- package/dist/esm/site/sitepath-service.js +193 -0
- package/dist/esm/site/utils.js +49 -0
- package/dist/esm/sitecore-service-base.js +29 -0
- package/dist/esm/tools/codegen/component-generation.js +44 -0
- package/dist/esm/tools/codegen/extract-files.js +97 -0
- package/dist/esm/tools/codegen/import-map.js +355 -0
- package/dist/esm/tools/codegen/utils.js +373 -0
- package/dist/esm/tools/generate-map.js +1 -0
- package/dist/esm/tools/generateSites.js +51 -0
- package/dist/esm/tools/index.js +6 -0
- package/dist/esm/tools/scaffold.js +54 -0
- package/dist/esm/tools/templating/components.js +59 -0
- package/dist/esm/tools/templating/index.js +1 -0
- package/editing.d.ts +1 -0
- package/i18n.d.ts +1 -0
- package/layout.d.ts +1 -0
- package/media.d.ts +1 -0
- package/package.json +157 -0
- package/personalize.d.ts +1 -0
- package/site.d.ts +1 -0
- package/tools.d.ts +1 -0
- package/types/client/edge-proxy.d.ts +17 -0
- package/types/client/edge-proxy.d.ts.map +1 -0
- package/types/client/index.d.ts +7 -0
- package/types/client/index.d.ts.map +1 -0
- package/types/client/models.d.ts +21 -0
- package/types/client/models.d.ts.map +1 -0
- package/types/client/sitecore-client.d.ts +346 -0
- package/types/client/sitecore-client.d.ts.map +1 -0
- package/types/client/utils.d.ts +15 -0
- package/types/client/utils.d.ts.map +1 -0
- package/types/config/define-config.d.ts +20 -0
- package/types/config/define-config.d.ts.map +1 -0
- package/types/config/index.d.ts +3 -0
- package/types/config/index.d.ts.map +1 -0
- package/types/config/models.d.ts +294 -0
- package/types/config/models.d.ts.map +1 -0
- package/types/config-cli/define-cli-config.d.ts +9 -0
- package/types/config-cli/define-cli-config.d.ts.map +1 -0
- package/types/config-cli/index.d.ts +3 -0
- package/types/config-cli/index.d.ts.map +1 -0
- package/types/config-cli/models.d.ts +6 -0
- package/types/config-cli/models.d.ts.map +1 -0
- package/types/constants.d.ts +10 -0
- package/types/constants.d.ts.map +1 -0
- package/types/debug.d.ts +19 -0
- package/types/debug.d.ts.map +1 -0
- package/types/editing/codegen/index.d.ts +2 -0
- package/types/editing/codegen/index.d.ts.map +1 -0
- package/types/editing/codegen/preview.d.ts +289 -0
- package/types/editing/codegen/preview.d.ts.map +1 -0
- package/types/editing/component-layout-service.d.ts +84 -0
- package/types/editing/component-layout-service.d.ts.map +1 -0
- package/types/editing/design-library.d.ts +119 -0
- package/types/editing/design-library.d.ts.map +1 -0
- package/types/editing/editing-service.d.ts +71 -0
- package/types/editing/editing-service.d.ts.map +1 -0
- package/types/editing/index.d.ts +7 -0
- package/types/editing/index.d.ts.map +1 -0
- package/types/editing/models.d.ts +103 -0
- package/types/editing/models.d.ts.map +1 -0
- package/types/editing/utils.d.ts +82 -0
- package/types/editing/utils.d.ts.map +1 -0
- package/types/form/form.d.ts +25 -0
- package/types/form/form.d.ts.map +1 -0
- package/types/form/index.d.ts +2 -0
- package/types/form/index.d.ts.map +1 -0
- package/types/i18n/dictionary-service.d.ts +133 -0
- package/types/i18n/dictionary-service.d.ts.map +1 -0
- package/types/i18n/index.d.ts +3 -0
- package/types/i18n/index.d.ts.map +1 -0
- package/types/i18n/utils.d.ts +9 -0
- package/types/i18n/utils.d.ts.map +1 -0
- package/types/index.d.ts +7 -0
- package/types/index.d.ts.map +1 -0
- package/types/layout/content-styles.d.ts +20 -0
- package/types/layout/content-styles.d.ts.map +1 -0
- package/types/layout/index.d.ts +7 -0
- package/types/layout/index.d.ts.map +1 -0
- package/types/layout/layout-service.d.ts +45 -0
- package/types/layout/layout-service.d.ts.map +1 -0
- package/types/layout/models.d.ts +174 -0
- package/types/layout/models.d.ts.map +1 -0
- package/types/layout/rewrite-edge-host.d.ts +43 -0
- package/types/layout/rewrite-edge-host.d.ts.map +1 -0
- package/types/layout/themes.d.ts +13 -0
- package/types/layout/themes.d.ts.map +1 -0
- package/types/layout/utils.d.ts +56 -0
- package/types/layout/utils.d.ts.map +1 -0
- package/types/media/index.d.ts +3 -0
- package/types/media/index.d.ts.map +1 -0
- package/types/media/media-api.d.ts +60 -0
- package/types/media/media-api.d.ts.map +1 -0
- package/types/models.d.ts +32 -0
- package/types/models.d.ts.map +1 -0
- package/types/personalize/index.d.ts +4 -0
- package/types/personalize/index.d.ts.map +1 -0
- package/types/personalize/layout-personalizer.d.ts +29 -0
- package/types/personalize/layout-personalizer.d.ts.map +1 -0
- package/types/personalize/personalize-service.d.ts +88 -0
- package/types/personalize/personalize-service.d.ts.map +1 -0
- package/types/personalize/utils.d.ts +78 -0
- package/types/personalize/utils.d.ts.map +1 -0
- package/types/site/error-pages-service.d.ts +72 -0
- package/types/site/error-pages-service.d.ts.map +1 -0
- package/types/site/index.d.ts +10 -0
- package/types/site/index.d.ts.map +1 -0
- package/types/site/models.d.ts +23 -0
- package/types/site/models.d.ts.map +1 -0
- package/types/site/redirects-service.d.ts +91 -0
- package/types/site/redirects-service.d.ts.map +1 -0
- package/types/site/robots-service.d.ts +57 -0
- package/types/site/robots-service.d.ts.map +1 -0
- package/types/site/site-resolver.d.ts +28 -0
- package/types/site/site-resolver.d.ts.map +1 -0
- package/types/site/siteinfo-service.d.ts +64 -0
- package/types/site/siteinfo-service.d.ts.map +1 -0
- package/types/site/sitemap-xml-service.d.ts +63 -0
- package/types/site/sitemap-xml-service.d.ts.map +1 -0
- package/types/site/sitepath-service.d.ts +137 -0
- package/types/site/sitepath-service.d.ts.map +1 -0
- package/types/site/utils.d.ts +41 -0
- package/types/site/utils.d.ts.map +1 -0
- package/types/sitecore-service-base.d.ts +31 -0
- package/types/sitecore-service-base.d.ts.map +1 -0
- package/types/tools/codegen/component-generation.d.ts +50 -0
- package/types/tools/codegen/component-generation.d.ts.map +1 -0
- package/types/tools/codegen/extract-files.d.ts +20 -0
- package/types/tools/codegen/extract-files.d.ts.map +1 -0
- package/types/tools/codegen/import-map.d.ts +98 -0
- package/types/tools/codegen/import-map.d.ts.map +1 -0
- package/types/tools/codegen/utils.d.ts +76 -0
- package/types/tools/codegen/utils.d.ts.map +1 -0
- package/types/tools/generate-map.d.ts +36 -0
- package/types/tools/generate-map.d.ts.map +1 -0
- package/types/tools/generateSites.d.ts +22 -0
- package/types/tools/generateSites.d.ts.map +1 -0
- package/types/tools/index.d.ts +8 -0
- package/types/tools/index.d.ts.map +1 -0
- package/types/tools/scaffold.d.ts +27 -0
- package/types/tools/scaffold.d.ts.map +1 -0
- package/types/tools/templating/components.d.ts +104 -0
- package/types/tools/templating/components.d.ts.map +1 -0
- package/types/tools/templating/index.d.ts +2 -0
- package/types/tools/templating/index.d.ts.map +1 -0
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { constants } from '@sitecore-content-sdk/core';
|
|
2
|
+
import { normalizeUrl } from '@sitecore-content-sdk/core/tools';
|
|
3
|
+
/**
|
|
4
|
+
* Resolves the base Edge URL from config. Caller should pass the resolved Edge URL from config.
|
|
5
|
+
* @param {string} [sitecoreEdgeUrl] - The base Edge URL from config. Defaults to platform URL.
|
|
6
|
+
* @internal
|
|
7
|
+
*/
|
|
8
|
+
const getBaseEdgeUrl = (sitecoreEdgeUrl = constants.SITECORE_EDGE_PLATFORM_URL_DEFAULT) => normalizeUrl(sitecoreEdgeUrl);
|
|
9
|
+
/**
|
|
10
|
+
* Generates a URL for accessing Sitecore Edge Platform Content using the provided endpoint and context ID.
|
|
11
|
+
* @param {string} [sitecoreEdgeUrl] - The base endpoint URL for the Edge Platform (resolved at config level). Defaults to platform URL.
|
|
12
|
+
* @returns {string} The complete URL for accessing content through the Edge Platform.
|
|
13
|
+
* @public
|
|
14
|
+
*/
|
|
15
|
+
export const getEdgeProxyContentUrl = (sitecoreEdgeUrl = constants.SITECORE_EDGE_PLATFORM_URL_DEFAULT) => `${getBaseEdgeUrl(sitecoreEdgeUrl)}/v1/content/api/graphql/v1`;
|
|
16
|
+
/**
|
|
17
|
+
* Generates a URL for accessing Sitecore Edge Platform Forms using the provided form ID and context ID.
|
|
18
|
+
* @param {string} sitecoreEdgeContextId - The unique context id.
|
|
19
|
+
* @param {string} formId - The unique form id.
|
|
20
|
+
* @param {string} [sitecoreEdgeUrl] - The base endpoint URL for the Edge Platform (resolved at config level). Defaults to platform URL.
|
|
21
|
+
* @returns {string} The complete URL for accessing forms through the Edge Platform.
|
|
22
|
+
* @internal
|
|
23
|
+
*/
|
|
24
|
+
export const getEdgeProxyFormsUrl = (sitecoreEdgeContextId, formId, sitecoreEdgeUrl = constants.SITECORE_EDGE_PLATFORM_URL_DEFAULT) => `${getBaseEdgeUrl(sitecoreEdgeUrl)}/v1/forms/publisher/${formId}?sitecoreContextId=${sitecoreEdgeContextId}`;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export { GraphQLRequestClient, DefaultRetryStrategy } from '@sitecore-content-sdk/core';
|
|
2
|
+
export { getEdgeProxyContentUrl, getEdgeProxyFormsUrl } from './edge-proxy';
|
|
3
|
+
export { SitecoreClient, ErrorPage, } from './sitecore-client';
|
|
4
|
+
export { createGraphQLClientFactory } from './utils';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,439 @@
|
|
|
1
|
+
import { NativeDataFetcher, debug, } from '@sitecore-content-sdk/core';
|
|
2
|
+
import { resolveEdgeUrlForStaticFiles, resolveExperienceEdgeUrl, } from '@sitecore-content-sdk/core/tools';
|
|
3
|
+
import { DictionaryService } from '../i18n';
|
|
4
|
+
import { getDesignLibraryStylesheetLinks, getContentStylesheetLink, LayoutService, LayoutServicePageState, rewriteEdgeHostInResponse, getDefaultMediaUrlTransformer, applyMediaUrlRewrite, } from '../layout';
|
|
5
|
+
import { getGroomedVariantIds } from '../personalize/utils';
|
|
6
|
+
import { personalizeLayout } from '../personalize/layout-personalizer';
|
|
7
|
+
import { ErrorPagesService, SitePathService, SitemapXmlService } from '../site';
|
|
8
|
+
import { createGraphQLClientFactory } from './utils';
|
|
9
|
+
import { RobotsService } from '../site/robots-service';
|
|
10
|
+
import { DesignLibraryVariantGeneration } from '../editing/models';
|
|
11
|
+
import { EditingService, ComponentLayoutService, DesignLibraryMode, } from '../editing';
|
|
12
|
+
/**
|
|
13
|
+
* Error page codes
|
|
14
|
+
* @public
|
|
15
|
+
*/
|
|
16
|
+
export var ErrorPage;
|
|
17
|
+
(function (ErrorPage) {
|
|
18
|
+
ErrorPage["NotFound"] = "404";
|
|
19
|
+
ErrorPage["InternalServerError"] = "500";
|
|
20
|
+
})(ErrorPage || (ErrorPage = {}));
|
|
21
|
+
/**
|
|
22
|
+
* This is a generic content client that can be used by any framework.
|
|
23
|
+
* Use it to retrieve pages, preview data, dictionary and other data
|
|
24
|
+
* @public
|
|
25
|
+
*/
|
|
26
|
+
export class SitecoreClient {
|
|
27
|
+
/**
|
|
28
|
+
* Init SitecoreClient
|
|
29
|
+
* @param {SitecoreClientInit} initOptions initOptions for the client, containing site and Sitecore connection details
|
|
30
|
+
*/
|
|
31
|
+
constructor(initOptions) {
|
|
32
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
|
|
33
|
+
this.initOptions = initOptions;
|
|
34
|
+
this.clientFactory = this.getClientFactory();
|
|
35
|
+
this.graphQLClient = this.clientFactory({
|
|
36
|
+
debugger: debug.http,
|
|
37
|
+
});
|
|
38
|
+
const baseServiceOptions = this.getBaseServiceOptions();
|
|
39
|
+
this.layoutService =
|
|
40
|
+
(_b = (_a = initOptions.custom) === null || _a === void 0 ? void 0 : _a.layoutService) !== null && _b !== void 0 ? _b : this.getLayoutService(baseServiceOptions);
|
|
41
|
+
this.dictionaryService =
|
|
42
|
+
(_d = (_c = initOptions.custom) === null || _c === void 0 ? void 0 : _c.dictionaryService) !== null && _d !== void 0 ? _d : this.getDictionaryService(baseServiceOptions);
|
|
43
|
+
this.editingService = (_f = (_e = initOptions.custom) === null || _e === void 0 ? void 0 : _e.editingService) !== null && _f !== void 0 ? _f : this.getEditingService();
|
|
44
|
+
this.errorPagesService = (_h = (_g = initOptions.custom) === null || _g === void 0 ? void 0 : _g.errorPagesService) !== null && _h !== void 0 ? _h : this.getErrorPagesService();
|
|
45
|
+
this.sitePathService = (_k = (_j = initOptions.custom) === null || _j === void 0 ? void 0 : _j.sitePathService) !== null && _k !== void 0 ? _k : this.getSitePathService();
|
|
46
|
+
this.componentService = this.getComponentService();
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Normalize path regardless of type
|
|
50
|
+
* @param {string | string[]} path string or string array path
|
|
51
|
+
* @returns {string} string path
|
|
52
|
+
*/
|
|
53
|
+
parsePath(path) {
|
|
54
|
+
// join array path, while clearing extra slashes and ensure first slash
|
|
55
|
+
return typeof path === 'string'
|
|
56
|
+
? path.startsWith('/')
|
|
57
|
+
? path
|
|
58
|
+
: `/${path}`
|
|
59
|
+
: `/${path
|
|
60
|
+
.filter((part) => part !== '/')
|
|
61
|
+
.map((part) => part.replace(/^\/+/, '').replace(/\/+$/, ''))
|
|
62
|
+
.join('/')}`;
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Execute a raw GraphQL request using the client's configured GraphQL Edge endpoint.
|
|
66
|
+
* This is a thin pass-through to the underlying `GraphQLClient.request` method,
|
|
67
|
+
* @param {string | DocumentNode} query GraphQL query
|
|
68
|
+
* @param {Record<string, unknown>} [variables] Optional variables bag
|
|
69
|
+
* @param {FetchOptions} [fetchOptions] Optional fetch overrides (e.g. fetch, headers)
|
|
70
|
+
*/
|
|
71
|
+
getData(query, variables, fetchOptions) {
|
|
72
|
+
return this.graphQLClient.request(query, variables, fetchOptions);
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Get page details for a route, with layout and other details
|
|
76
|
+
* @param {string} path route path
|
|
77
|
+
* @param {PageOptions} [pageOptions] site, language and personalization variant details for route
|
|
78
|
+
* @param {FetchOptions} [fetchOptions] Additional fetch fetch options to override GraphQL requests
|
|
79
|
+
* @returns {Page | null} page details
|
|
80
|
+
*/
|
|
81
|
+
async getPage(path, pageOptions, fetchOptions) {
|
|
82
|
+
var _a, _b, _c, _d;
|
|
83
|
+
const computedPath = this.parsePath(path);
|
|
84
|
+
const locale = (_a = pageOptions === null || pageOptions === void 0 ? void 0 : pageOptions.locale) !== null && _a !== void 0 ? _a : this.initOptions.defaultLanguage;
|
|
85
|
+
const site = (_b = pageOptions === null || pageOptions === void 0 ? void 0 : pageOptions.site) !== null && _b !== void 0 ? _b : this.initOptions.defaultSite;
|
|
86
|
+
// Fetch layout data, passing on req/res for SSR
|
|
87
|
+
let layout = await this.layoutService.fetchLayoutData(computedPath, {
|
|
88
|
+
locale,
|
|
89
|
+
site,
|
|
90
|
+
}, fetchOptions);
|
|
91
|
+
if (!layout.sitecore.route) {
|
|
92
|
+
return null;
|
|
93
|
+
}
|
|
94
|
+
// Apply personalization first to select the variant(s) that will be used,
|
|
95
|
+
// then rewrite content URLs so we only process the selected variant(s)
|
|
96
|
+
if ((_c = pageOptions === null || pageOptions === void 0 ? void 0 : pageOptions.personalize) === null || _c === void 0 ? void 0 : _c.variantId) {
|
|
97
|
+
personalizeLayout(layout, pageOptions.personalize.variantId, pageOptions.personalize.componentVariantIds);
|
|
98
|
+
}
|
|
99
|
+
layout = this.applyContentRewrite(layout);
|
|
100
|
+
return {
|
|
101
|
+
layout,
|
|
102
|
+
siteName: ((_d = layout.sitecore.context.site) === null || _d === void 0 ? void 0 : _d.name) || site,
|
|
103
|
+
locale,
|
|
104
|
+
mode: this.getPageMode(LayoutServicePageState.Normal),
|
|
105
|
+
};
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* Retrieves the head `<link>` elements for Sitecore styles and themes.
|
|
109
|
+
* @param {LayoutServiceData} layoutData - The layout data containing styles and themes.
|
|
110
|
+
* @param {object} [options] - Optional configuration for enabling styles and themes.
|
|
111
|
+
* @param {boolean} [options.enableStyles] - Whether to include content styles.
|
|
112
|
+
* @param {boolean} [options.enableThemes] - Whether to include theme styles.
|
|
113
|
+
* @returns {HTMLLink[]} An array of `<link>` elements for stylesheets.
|
|
114
|
+
*/
|
|
115
|
+
getHeadLinks(layoutData, options = {}) {
|
|
116
|
+
const { enableStyles = true, enableThemes = true } = options;
|
|
117
|
+
const { contextId: serverContextId, clientContextId } = this.initOptions.api.edge;
|
|
118
|
+
const headLinks = [];
|
|
119
|
+
const contextId = serverContextId || clientContextId;
|
|
120
|
+
// Use default Edge URL for styles (ignore custom hostname) so stylesheets load from platform
|
|
121
|
+
const edgeUrlForStyles = resolveEdgeUrlForStaticFiles();
|
|
122
|
+
if (enableStyles) {
|
|
123
|
+
const contentStyles = getContentStylesheetLink(layoutData, contextId, edgeUrlForStyles);
|
|
124
|
+
if (contentStyles)
|
|
125
|
+
headLinks.push(contentStyles);
|
|
126
|
+
}
|
|
127
|
+
if (enableThemes) {
|
|
128
|
+
headLinks.push(...getDesignLibraryStylesheetLinks(layoutData, contextId, edgeUrlForStyles));
|
|
129
|
+
}
|
|
130
|
+
return headLinks;
|
|
131
|
+
}
|
|
132
|
+
/**
|
|
133
|
+
* Retrieves dictionary phrases for a given site and locale.
|
|
134
|
+
* @param {RouteOptions} routeOptions - Route options containing language and site name to load dictionary for
|
|
135
|
+
* @param {FetchOptions} [fetchOptions] Additional fetch fetch options to override GraphQL requests
|
|
136
|
+
* @returns {DictionaryPhrases} A promise that resolves to the dictionary phrases.
|
|
137
|
+
*/
|
|
138
|
+
async getDictionary(routeOptions, fetchOptions) {
|
|
139
|
+
const locale = (routeOptions === null || routeOptions === void 0 ? void 0 : routeOptions.locale) || this.initOptions.defaultLanguage;
|
|
140
|
+
const site = (routeOptions === null || routeOptions === void 0 ? void 0 : routeOptions.site) || this.initOptions.defaultSite;
|
|
141
|
+
return await this.dictionaryService.fetchDictionaryData(locale, site, fetchOptions);
|
|
142
|
+
}
|
|
143
|
+
/**
|
|
144
|
+
* Retrieves error pages for a given site and locale.
|
|
145
|
+
* @param {RouteOptions} routeOptions - Route options containing language and site name to load error pages
|
|
146
|
+
* @param {FetchOptions} [fetchOptions] Additional fetch fetch options to override GraphQL requests
|
|
147
|
+
* @returns {ErrorPages | null} A promise that resolves to the error pages or null if not found.
|
|
148
|
+
*/
|
|
149
|
+
async getErrorPages(routeOptions, fetchOptions) {
|
|
150
|
+
const locale = (routeOptions === null || routeOptions === void 0 ? void 0 : routeOptions.locale) || this.initOptions.defaultLanguage;
|
|
151
|
+
const site = (routeOptions === null || routeOptions === void 0 ? void 0 : routeOptions.site) || this.initOptions.defaultSite;
|
|
152
|
+
return await this.errorPagesService.fetchErrorPages(site, locale, fetchOptions);
|
|
153
|
+
}
|
|
154
|
+
/**
|
|
155
|
+
* Retrieves preview page and layout details
|
|
156
|
+
* @param {EditingPreviewData | undefined} previewData - The editing preview data for metadata mode.
|
|
157
|
+
* @param {FetchOptions} [fetchOptions] Additional fetch fetch options to override GraphQL requests
|
|
158
|
+
* @returns {Page} preview page details
|
|
159
|
+
*/
|
|
160
|
+
async getPreview(previewData, fetchOptions) {
|
|
161
|
+
var _a;
|
|
162
|
+
if (!previewData) {
|
|
163
|
+
console.error('Preview data missing');
|
|
164
|
+
return null;
|
|
165
|
+
}
|
|
166
|
+
// If we're in Pages preview (editing) mode, prefetch the editing data
|
|
167
|
+
const { site, itemId, language, version, layoutKind, mode } = previewData;
|
|
168
|
+
const variantIds = Array.isArray(previewData.variantIds)
|
|
169
|
+
? previewData.variantIds
|
|
170
|
+
: previewData.variantIds.split(',');
|
|
171
|
+
const data = await this.editingService.fetchEditingData({
|
|
172
|
+
itemId,
|
|
173
|
+
language,
|
|
174
|
+
version,
|
|
175
|
+
layoutKind,
|
|
176
|
+
mode,
|
|
177
|
+
}, fetchOptions);
|
|
178
|
+
if (!data) {
|
|
179
|
+
throw new Error(`Unable to fetch editing data for preview ${JSON.stringify(previewData)}`);
|
|
180
|
+
}
|
|
181
|
+
let layout = data.layoutData;
|
|
182
|
+
const personalizeData = getGroomedVariantIds(variantIds);
|
|
183
|
+
personalizeLayout(layout, personalizeData.variantId, personalizeData.componentVariantIds);
|
|
184
|
+
layout = this.applyContentRewrite(layout);
|
|
185
|
+
const page = {
|
|
186
|
+
locale: language,
|
|
187
|
+
layout,
|
|
188
|
+
siteName: ((_a = layout.sitecore.context.site) === null || _a === void 0 ? void 0 : _a.name) || site,
|
|
189
|
+
mode: this.getPageMode(mode),
|
|
190
|
+
};
|
|
191
|
+
return page;
|
|
192
|
+
}
|
|
193
|
+
/**
|
|
194
|
+
* Get design library page details for Design Library mode of your app
|
|
195
|
+
* @param {DesignLibraryRenderPreviewData} designLibData preview data set in 'library' mode of the app
|
|
196
|
+
* @param {FetchOptions} [fetchOptions] Additional fetch fetch options to override GraphQL requests
|
|
197
|
+
* @returns {Page} preview page for Design Library
|
|
198
|
+
*/
|
|
199
|
+
async getDesignLibraryData(designLibData, fetchOptions) {
|
|
200
|
+
var _a;
|
|
201
|
+
if (!this.initOptions.api.local) {
|
|
202
|
+
throw new Error('Component Library requires Sitecore apiHost and apiKey to be provided');
|
|
203
|
+
}
|
|
204
|
+
const { itemId, componentUid, site, language, renderingId, dataSourceId, version, mode, generation, } = designLibData;
|
|
205
|
+
const componentData = await this.componentService.fetchComponentData(Object.assign({ siteName: site, itemId,
|
|
206
|
+
language,
|
|
207
|
+
componentUid,
|
|
208
|
+
renderingId,
|
|
209
|
+
dataSourceId,
|
|
210
|
+
version,
|
|
211
|
+
mode }, (generation ? { generation } : {})), fetchOptions);
|
|
212
|
+
if (!componentData) {
|
|
213
|
+
throw new Error(`Unable to fetch editing data for preview ${JSON.stringify(designLibData)}`);
|
|
214
|
+
}
|
|
215
|
+
const layout = this.applyContentRewrite(componentData);
|
|
216
|
+
const page = {
|
|
217
|
+
locale: designLibData.language,
|
|
218
|
+
layout,
|
|
219
|
+
siteName: ((_a = layout.sitecore.context.site) === null || _a === void 0 ? void 0 : _a.name) || site,
|
|
220
|
+
mode: this.getPageMode(mode, generation),
|
|
221
|
+
};
|
|
222
|
+
return page;
|
|
223
|
+
}
|
|
224
|
+
/**
|
|
225
|
+
* Get error page details for a given error code
|
|
226
|
+
* @param {ErrorPage} code - The error code to get the error page for
|
|
227
|
+
* @param {Partial<RouteOptions>} pageOptions - The page options to get the error page for
|
|
228
|
+
* @param {FetchOptions} [fetchOptions] - Additional fetch fetch options to override GraphQL requests
|
|
229
|
+
* @returns {Promise<Page | null>} A promise that resolves to the error page details or null if not found
|
|
230
|
+
*/
|
|
231
|
+
async getErrorPage(code, pageOptions, fetchOptions) {
|
|
232
|
+
var _a, _b;
|
|
233
|
+
const locale = (pageOptions === null || pageOptions === void 0 ? void 0 : pageOptions.locale) || this.initOptions.defaultLanguage;
|
|
234
|
+
const site = (pageOptions === null || pageOptions === void 0 ? void 0 : pageOptions.site) || this.initOptions.defaultSite;
|
|
235
|
+
const result = await this.getErrorPages({
|
|
236
|
+
site,
|
|
237
|
+
locale,
|
|
238
|
+
}, fetchOptions);
|
|
239
|
+
let layout = null;
|
|
240
|
+
switch (code) {
|
|
241
|
+
case ErrorPage.NotFound:
|
|
242
|
+
layout = ((_a = result === null || result === void 0 ? void 0 : result.notFoundPage) === null || _a === void 0 ? void 0 : _a.rendered) || null;
|
|
243
|
+
break;
|
|
244
|
+
case ErrorPage.InternalServerError:
|
|
245
|
+
layout = ((_b = result === null || result === void 0 ? void 0 : result.serverErrorPage) === null || _b === void 0 ? void 0 : _b.rendered) || null;
|
|
246
|
+
break;
|
|
247
|
+
default:
|
|
248
|
+
return null;
|
|
249
|
+
}
|
|
250
|
+
if (!layout) {
|
|
251
|
+
return null;
|
|
252
|
+
}
|
|
253
|
+
layout = this.applyContentRewrite(layout);
|
|
254
|
+
return {
|
|
255
|
+
layout,
|
|
256
|
+
locale,
|
|
257
|
+
mode: this.getPageMode(LayoutServicePageState.Normal),
|
|
258
|
+
siteName: site,
|
|
259
|
+
};
|
|
260
|
+
}
|
|
261
|
+
/**
|
|
262
|
+
* Retrieves the static paths for pages based on the given languages.
|
|
263
|
+
* @param {string[]} sites - An array of site names to fetch routes for.
|
|
264
|
+
* @param {string[]} [languages] - An optional array of language codes to generate paths for.
|
|
265
|
+
* @param {FetchOptions} [fetchOptions] - Additional fetch options.
|
|
266
|
+
* @returns {Promise<StaticPath[]>} A promise that resolves to an array of static paths.
|
|
267
|
+
*/
|
|
268
|
+
async getPagePaths(sites, languages, fetchOptions) {
|
|
269
|
+
return this.sitePathService.fetchSiteRoutes(sites, languages || [], fetchOptions);
|
|
270
|
+
}
|
|
271
|
+
/**
|
|
272
|
+
* Retrieves sitemap XML content - either a specific sitemap or the index of all sitemaps.
|
|
273
|
+
* @param {SitemapXmlOptions} reqOptions - Options for sitemap retrieval
|
|
274
|
+
* @param {FetchOptions} [fetchOptions] - Additional fetch options.
|
|
275
|
+
* @returns {Promise<string>} Promise resolving to the sitemap XML content as string
|
|
276
|
+
* @throws {Error} Throws 'REDIRECT_404' if requested sitemap is not found
|
|
277
|
+
*/
|
|
278
|
+
async getSiteMap(reqOptions, fetchOptions) {
|
|
279
|
+
const { reqHost, reqProtocol, id, siteName } = reqOptions;
|
|
280
|
+
// create sitemap graphql service
|
|
281
|
+
const sitemapXmlService = this.getGraphqlSitemapXMLService(siteName || this.initOptions.defaultSite);
|
|
282
|
+
// The id is present if url has sitemap-{n}.xml type.
|
|
283
|
+
// The id can be null if it's index sitemap.xml request
|
|
284
|
+
const sitemapPath = await sitemapXmlService.getSitemap(id);
|
|
285
|
+
// regular sitemap
|
|
286
|
+
if (sitemapPath) {
|
|
287
|
+
try {
|
|
288
|
+
const experienceEdgeUrl = resolveExperienceEdgeUrl();
|
|
289
|
+
const rewrittenSitemapPath = rewriteEdgeHostInResponse(sitemapPath, experienceEdgeUrl);
|
|
290
|
+
const fetcher = new NativeDataFetcher();
|
|
291
|
+
const xmlResponse = await fetcher.fetch(rewrittenSitemapPath);
|
|
292
|
+
if (!xmlResponse.data) {
|
|
293
|
+
throw new Error('REDIRECT_404');
|
|
294
|
+
}
|
|
295
|
+
return rewriteEdgeHostInResponse(xmlResponse.data, experienceEdgeUrl);
|
|
296
|
+
// eslint-disable-next-line no-unused-vars
|
|
297
|
+
}
|
|
298
|
+
catch (error) {
|
|
299
|
+
throw new Error('REDIRECT_404');
|
|
300
|
+
}
|
|
301
|
+
}
|
|
302
|
+
// index /sitemap.xml that includes links to all sitemaps
|
|
303
|
+
const sitemaps = await sitemapXmlService.fetchSitemaps(fetchOptions);
|
|
304
|
+
if (!sitemaps.length) {
|
|
305
|
+
throw new Error('REDIRECT_404');
|
|
306
|
+
}
|
|
307
|
+
return `<?xml version="1.0" encoding="UTF-8"?>
|
|
308
|
+
<sitemapindex xmlns="http://sitemaps.org/schemas/sitemap/0.9">
|
|
309
|
+
${sitemaps
|
|
310
|
+
.map((item) => {
|
|
311
|
+
const parseUrl = item.split('/');
|
|
312
|
+
const lastSegment = parseUrl[parseUrl.length - 1];
|
|
313
|
+
const escapedUrl = `${reqProtocol}://${reqHost}/${lastSegment}`.replace(/&/g, '&');
|
|
314
|
+
return `<sitemap><loc>${escapedUrl}</loc></sitemap>`;
|
|
315
|
+
})
|
|
316
|
+
.join('')}
|
|
317
|
+
</sitemapindex>`;
|
|
318
|
+
}
|
|
319
|
+
/**
|
|
320
|
+
* Retrieves the robots.txt content for a given site name.
|
|
321
|
+
* @param {string} siteName - The name of the site to retrieve the robots.txt for.
|
|
322
|
+
* @param {FetchOptions} [fetchOptions] - Optional fetch options.
|
|
323
|
+
* @returns {Promise<string | null>} A promise that resolves to the robots.txt content,
|
|
324
|
+
* or null if no content is found.
|
|
325
|
+
*/
|
|
326
|
+
async getRobots(siteName, fetchOptions) {
|
|
327
|
+
const robotsService = this.getRobotsService(siteName || this.initOptions.defaultSite);
|
|
328
|
+
const content = await robotsService.fetchRobots(fetchOptions);
|
|
329
|
+
return content || null;
|
|
330
|
+
}
|
|
331
|
+
/**
|
|
332
|
+
* Factory methods for creating dependencies
|
|
333
|
+
* Subclasses can override these to provide custom implementations.
|
|
334
|
+
*/
|
|
335
|
+
getGraphqlSitemapXMLService(siteName) {
|
|
336
|
+
return new SitemapXmlService({
|
|
337
|
+
clientFactory: this.clientFactory,
|
|
338
|
+
siteName,
|
|
339
|
+
});
|
|
340
|
+
}
|
|
341
|
+
getRobotsService(siteName) {
|
|
342
|
+
return new RobotsService({
|
|
343
|
+
clientFactory: this.clientFactory,
|
|
344
|
+
siteName,
|
|
345
|
+
});
|
|
346
|
+
}
|
|
347
|
+
getBaseServiceOptions() {
|
|
348
|
+
return {
|
|
349
|
+
defaultSite: this.initOptions.defaultSite,
|
|
350
|
+
clientFactory: this.clientFactory,
|
|
351
|
+
retries: this.initOptions.retries,
|
|
352
|
+
};
|
|
353
|
+
}
|
|
354
|
+
/**
|
|
355
|
+
* Get page mode based on mode name
|
|
356
|
+
* @param {PageModeName} mode - The mode name to get the page mode for
|
|
357
|
+
* @param { DesignLibraryVariantGeneration} generation - The variant generation mode, if applicable
|
|
358
|
+
* @returns {PageMode} The page mode
|
|
359
|
+
*/
|
|
360
|
+
/**
|
|
361
|
+
* Applies media URL rewrite when rewriteMediaUrls is enabled.
|
|
362
|
+
* When true, uses default Edge host rewriter; when a function, transforms each string.
|
|
363
|
+
* @param {LayoutServiceData} layout - Layout data from layout/editing/component/error service
|
|
364
|
+
* @returns {LayoutServiceData} Rewritten layout (or same reference if rewrite disabled)
|
|
365
|
+
* @internal
|
|
366
|
+
*/
|
|
367
|
+
applyContentRewrite(layout) {
|
|
368
|
+
const opt = this.initOptions.rewriteMediaUrls;
|
|
369
|
+
if (!opt) {
|
|
370
|
+
return layout;
|
|
371
|
+
}
|
|
372
|
+
const experienceEdgeUrl = resolveExperienceEdgeUrl();
|
|
373
|
+
const transformer = opt === true ? getDefaultMediaUrlTransformer(experienceEdgeUrl) : opt;
|
|
374
|
+
return applyMediaUrlRewrite(layout, transformer);
|
|
375
|
+
}
|
|
376
|
+
getPageMode(mode, generation) {
|
|
377
|
+
const pageMode = {
|
|
378
|
+
name: mode,
|
|
379
|
+
isNormal: false,
|
|
380
|
+
isPreview: false,
|
|
381
|
+
isEditing: false,
|
|
382
|
+
isDesignLibrary: false,
|
|
383
|
+
designLibrary: { isVariantGeneration: false },
|
|
384
|
+
};
|
|
385
|
+
switch (mode) {
|
|
386
|
+
case LayoutServicePageState.Normal:
|
|
387
|
+
pageMode.isNormal = true;
|
|
388
|
+
break;
|
|
389
|
+
case LayoutServicePageState.Preview:
|
|
390
|
+
pageMode.isPreview = true;
|
|
391
|
+
break;
|
|
392
|
+
case LayoutServicePageState.Edit:
|
|
393
|
+
pageMode.isEditing = true;
|
|
394
|
+
break;
|
|
395
|
+
case DesignLibraryMode.Normal:
|
|
396
|
+
pageMode.isDesignLibrary = true;
|
|
397
|
+
break;
|
|
398
|
+
case DesignLibraryMode.Metadata:
|
|
399
|
+
pageMode.isDesignLibrary = true;
|
|
400
|
+
pageMode.isEditing = true;
|
|
401
|
+
break;
|
|
402
|
+
default:
|
|
403
|
+
break;
|
|
404
|
+
}
|
|
405
|
+
if (pageMode.isDesignLibrary && generation === DesignLibraryVariantGeneration.Variant) {
|
|
406
|
+
pageMode.designLibrary.isVariantGeneration = true;
|
|
407
|
+
pageMode.isEditing = true;
|
|
408
|
+
}
|
|
409
|
+
return pageMode;
|
|
410
|
+
}
|
|
411
|
+
getClientFactory() {
|
|
412
|
+
const graphQLOptions = {
|
|
413
|
+
api: this.initOptions.api,
|
|
414
|
+
retries: this.initOptions.retries.count,
|
|
415
|
+
retryStrategy: this.initOptions.retries.retryStrategy,
|
|
416
|
+
};
|
|
417
|
+
return createGraphQLClientFactory(graphQLOptions);
|
|
418
|
+
}
|
|
419
|
+
getLayoutService(baseOptions) {
|
|
420
|
+
return new LayoutService(Object.assign(Object.assign({}, baseOptions), { formatLayoutQuery: this.initOptions.layout.formatLayoutQuery }));
|
|
421
|
+
}
|
|
422
|
+
getDictionaryService(baseOptions) {
|
|
423
|
+
return new DictionaryService(Object.assign(Object.assign({}, baseOptions), { cacheEnabled: this.initOptions.dictionary.caching.enabled, cacheTimeout: this.initOptions.dictionary.caching.timeout }));
|
|
424
|
+
}
|
|
425
|
+
getEditingService() {
|
|
426
|
+
return new EditingService({ clientFactory: this.clientFactory });
|
|
427
|
+
}
|
|
428
|
+
getErrorPagesService() {
|
|
429
|
+
return new ErrorPagesService(Object.assign(Object.assign({}, this.initOptions), { language: this.initOptions.defaultLanguage, clientFactory: this.clientFactory }));
|
|
430
|
+
}
|
|
431
|
+
getComponentService() {
|
|
432
|
+
return new ComponentLayoutService(this.initOptions.api.edge);
|
|
433
|
+
}
|
|
434
|
+
getSitePathService() {
|
|
435
|
+
return new SitePathService({
|
|
436
|
+
clientFactory: this.clientFactory,
|
|
437
|
+
});
|
|
438
|
+
}
|
|
439
|
+
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { GraphQLRequestClient, } from '@sitecore-content-sdk/core';
|
|
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.edgeUrl),
|
|
18
|
+
contextId: edge.contextId,
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
else if (isBrowser && (edge === null || edge === void 0 ? void 0 : edge.clientContextId)) {
|
|
22
|
+
// Real client for client-side requests
|
|
23
|
+
clientConfig = {
|
|
24
|
+
endpoint: getEdgeProxyContentUrl(edge.edgeUrl),
|
|
25
|
+
contextId: edge.clientContextId,
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
else if ((local === null || local === void 0 ? void 0 : local.apiKey) && (local === null || local === void 0 ? void 0 : local.apiHost)) {
|
|
29
|
+
// Fallback to local API settings
|
|
30
|
+
clientConfig = {
|
|
31
|
+
endpoint: `${local.apiHost}${local.path}`,
|
|
32
|
+
apiKey: local.apiKey,
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
else if (isBrowser) {
|
|
36
|
+
// Browser bundle has no IDs – initialise a dummy client and warn
|
|
37
|
+
/* eslint-disable no-console */
|
|
38
|
+
console.warn('GraphQL client initialised in the browser without Edge or local API configuration; client-side requests may fail.');
|
|
39
|
+
clientConfig = { endpoint: '/api/graphql' };
|
|
40
|
+
}
|
|
41
|
+
else {
|
|
42
|
+
throw new Error(`GraphQL client misconfigured.
|
|
43
|
+
Configure one of the following in sitecore.config or your .env file:
|
|
44
|
+
Edge mode: set both sitecore.edge.contextId (server-side) and sitecore.edge.clientContextId (browser).
|
|
45
|
+
Local API mode: set api.local.apiHost and api.local.apiKey.
|
|
46
|
+
Supplying only api.edge.clientContextId will cause the application to fail at runtime.`);
|
|
47
|
+
}
|
|
48
|
+
return GraphQLRequestClient.createClientFactory(Object.assign(Object.assign({}, clientConfig), options));
|
|
49
|
+
};
|