@sitecore-content-sdk/core 1.5.0 → 2.0.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 -202
- package/dist/cjs/constants.js +7 -21
- package/dist/cjs/debug.js +14 -18
- package/dist/cjs/graphql-request-client.js +10 -5
- package/dist/cjs/index.js +3 -7
- package/dist/cjs/native-fetcher.js +1 -1
- package/dist/cjs/{utils → tools}/ensurePath.js +1 -0
- package/dist/cjs/{media/index.js → tools/index-node.js} +27 -3
- package/dist/cjs/tools/index.js +28 -72
- package/dist/cjs/tools/{generateMetadata.js → metadata/generateMetadata.js} +2 -2
- package/dist/cjs/tools/metadata/index.js +5 -0
- package/dist/cjs/{editing → tools/metadata}/metadata.js +1 -6
- package/dist/cjs/tools/normalize-env-value.js +22 -0
- package/dist/cjs/{utils → tools}/normalize-url.js +6 -0
- package/dist/cjs/tools/resolve-edge-url.js +95 -0
- package/dist/cjs/{utils → tools}/utils.js +6 -64
- package/dist/esm/constants.js +6 -20
- package/dist/esm/debug.js +13 -17
- package/dist/esm/graphql-request-client.js +10 -5
- package/dist/esm/index.js +1 -6
- package/dist/esm/native-fetcher.js +1 -1
- package/dist/esm/{utils → tools}/ensurePath.js +1 -0
- package/dist/esm/tools/index-node.js +22 -0
- package/dist/esm/tools/index.js +6 -28
- package/dist/esm/tools/{generateMetadata.js → metadata/generateMetadata.js} +2 -2
- package/dist/esm/tools/metadata/index.js +1 -0
- package/dist/esm/{editing → tools/metadata}/metadata.js +1 -6
- package/dist/esm/tools/normalize-env-value.js +19 -0
- package/dist/esm/tools/normalize-url.js +7 -0
- package/dist/esm/tools/resolve-edge-url.js +89 -0
- package/dist/esm/{utils → tools}/utils.js +5 -61
- package/node-tools.d.ts +1 -0
- package/package.json +98 -163
- package/types/constants.d.ts +6 -17
- package/types/constants.d.ts.map +1 -1
- package/types/debug.d.ts +13 -13
- package/types/debug.d.ts.map +1 -1
- package/types/graphql-request-client.d.ts +8 -2
- package/types/graphql-request-client.d.ts.map +1 -1
- package/types/index.d.ts +3 -6
- package/types/index.d.ts.map +1 -1
- package/types/models.d.ts +0 -31
- package/types/models.d.ts.map +1 -1
- package/types/{utils → tools}/ensurePath.d.ts +1 -0
- package/types/tools/ensurePath.d.ts.map +1 -0
- package/types/{utils → tools}/globalCache.d.ts.map +1 -1
- package/types/tools/index-node.d.ts +14 -0
- package/types/tools/index-node.d.ts.map +1 -0
- package/types/tools/index.d.ts +5 -21
- package/types/tools/index.d.ts.map +1 -1
- package/types/tools/is-server.d.ts.map +1 -0
- package/types/tools/metadata/generateMetadata.d.ts.map +1 -0
- package/types/tools/metadata/index.d.ts +3 -0
- package/types/tools/metadata/index.d.ts.map +1 -0
- package/types/{editing → tools/metadata}/metadata.d.ts +9 -1
- package/types/tools/metadata/metadata.d.ts.map +1 -0
- package/types/tools/normalize-env-value.d.ts +10 -0
- package/types/tools/normalize-env-value.d.ts.map +1 -0
- package/types/tools/normalize-url.d.ts +8 -0
- package/types/tools/normalize-url.d.ts.map +1 -0
- package/types/tools/resolve-edge-url.d.ts +52 -0
- package/types/tools/resolve-edge-url.d.ts.map +1 -0
- package/types/{utils → tools}/timeout-promise.d.ts.map +1 -1
- package/types/{utils → tools}/utils.d.ts +6 -26
- package/types/tools/utils.d.ts.map +1 -0
- package/client.d.ts +0 -1
- package/codegen.d.ts +0 -1
- package/config-cli.d.ts +0 -1
- package/config.d.ts +0 -1
- package/dist/cjs/client/constants.js +0 -7
- package/dist/cjs/client/edge-proxy.js +0 -24
- package/dist/cjs/client/index.js +0 -15
- package/dist/cjs/client/models.js +0 -2
- package/dist/cjs/client/sitecore-client.js +0 -424
- package/dist/cjs/client/utils.js +0 -51
- package/dist/cjs/config/define-config.js +0 -195
- package/dist/cjs/config/index.js +0 -7
- package/dist/cjs/config/models.js +0 -12
- package/dist/cjs/config-cli/define-cli-config.js +0 -23
- package/dist/cjs/config-cli/index.js +0 -7
- package/dist/cjs/config-cli/models.js +0 -8
- package/dist/cjs/editing/codegen/index.js +0 -15
- package/dist/cjs/editing/codegen/preview.js +0 -306
- package/dist/cjs/editing/component-layout-service.js +0 -63
- package/dist/cjs/editing/design-library.js +0 -190
- package/dist/cjs/editing/editing-service.js +0 -81
- package/dist/cjs/editing/index.js +0 -34
- package/dist/cjs/editing/models.js +0 -44
- package/dist/cjs/editing/utils.js +0 -108
- package/dist/cjs/form/form.js +0 -81
- package/dist/cjs/form/index.js +0 -7
- package/dist/cjs/i18n/dictionary-service.js +0 -144
- package/dist/cjs/i18n/index.js +0 -7
- package/dist/cjs/i18n/utils.js +0 -16
- package/dist/cjs/layout/content-styles.js +0 -72
- package/dist/cjs/layout/index.js +0 -24
- package/dist/cjs/layout/layout-service.js +0 -68
- package/dist/cjs/layout/models.js +0 -39
- package/dist/cjs/layout/themes.js +0 -76
- package/dist/cjs/layout/utils.js +0 -117
- package/dist/cjs/media/media-api.js +0 -100
- package/dist/cjs/personalize/index.js +0 -15
- package/dist/cjs/personalize/layout-personalizer.js +0 -98
- package/dist/cjs/personalize/personalize-service.js +0 -109
- package/dist/cjs/personalize/utils.js +0 -143
- package/dist/cjs/site/error-pages-service.js +0 -82
- package/dist/cjs/site/index.js +0 -26
- package/dist/cjs/site/models.js +0 -2
- package/dist/cjs/site/redirects-service.js +0 -108
- package/dist/cjs/site/robots-service.js +0 -74
- package/dist/cjs/site/site-resolver.js +0 -73
- package/dist/cjs/site/siteinfo-service.js +0 -94
- package/dist/cjs/site/sitemap-xml-service.js +0 -92
- package/dist/cjs/site/sitepath-service.js +0 -201
- package/dist/cjs/site/utils.js +0 -55
- package/dist/cjs/sitecore-service-base.js +0 -36
- package/dist/cjs/tools/codegen/component-generation.js +0 -52
- package/dist/cjs/tools/codegen/extract-files.js +0 -105
- package/dist/cjs/tools/codegen/import-map.js +0 -411
- package/dist/cjs/tools/codegen/utils.js +0 -418
- package/dist/cjs/tools/generate-map.js +0 -2
- package/dist/cjs/tools/generateSites.js +0 -59
- package/dist/cjs/tools/scaffold.js +0 -62
- package/dist/cjs/tools/templating/components.js +0 -96
- package/dist/cjs/tools/templating/index.js +0 -11
- package/dist/cjs/tools/templating/plugins.js +0 -80
- package/dist/cjs/tools/templating/utils.js +0 -67
- package/dist/cjs/utils/env.js +0 -28
- package/dist/cjs/utils/index.js +0 -26
- package/dist/esm/client/constants.js +0 -4
- package/dist/esm/client/edge-proxy.js +0 -19
- package/dist/esm/client/index.js +0 -5
- package/dist/esm/client/models.js +0 -1
- package/dist/esm/client/sitecore-client.js +0 -417
- package/dist/esm/client/utils.js +0 -47
- package/dist/esm/config/define-config.js +0 -189
- package/dist/esm/config/index.js +0 -2
- package/dist/esm/config/models.js +0 -9
- package/dist/esm/config-cli/define-cli-config.js +0 -19
- package/dist/esm/config-cli/index.js +0 -2
- package/dist/esm/config-cli/models.js +0 -5
- package/dist/esm/editing/codegen/index.js +0 -1
- package/dist/esm/editing/codegen/preview.js +0 -288
- package/dist/esm/editing/component-layout-service.js +0 -56
- package/dist/esm/editing/design-library.js +0 -178
- package/dist/esm/editing/editing-service.js +0 -74
- package/dist/esm/editing/index.js +0 -6
- package/dist/esm/editing/models.js +0 -41
- package/dist/esm/editing/utils.js +0 -98
- package/dist/esm/form/form.js +0 -72
- package/dist/esm/form/index.js +0 -1
- package/dist/esm/i18n/dictionary-service.js +0 -137
- package/dist/esm/i18n/index.js +0 -2
- package/dist/esm/i18n/utils.js +0 -13
- package/dist/esm/layout/content-styles.js +0 -64
- package/dist/esm/layout/index.js +0 -6
- package/dist/esm/layout/layout-service.js +0 -61
- package/dist/esm/layout/models.js +0 -36
- package/dist/esm/layout/themes.js +0 -71
- package/dist/esm/layout/utils.js +0 -109
- package/dist/esm/media/index.js +0 -2
- package/dist/esm/media/media-api.js +0 -90
- package/dist/esm/personalize/index.js +0 -3
- package/dist/esm/personalize/layout-personalizer.js +0 -93
- package/dist/esm/personalize/personalize-service.js +0 -102
- package/dist/esm/personalize/utils.js +0 -135
- package/dist/esm/site/error-pages-service.js +0 -75
- package/dist/esm/site/index.js +0 -8
- package/dist/esm/site/models.js +0 -1
- package/dist/esm/site/redirects-service.js +0 -101
- package/dist/esm/site/robots-service.js +0 -67
- package/dist/esm/site/site-resolver.js +0 -69
- package/dist/esm/site/siteinfo-service.js +0 -87
- package/dist/esm/site/sitemap-xml-service.js +0 -85
- package/dist/esm/site/sitepath-service.js +0 -193
- package/dist/esm/site/utils.js +0 -49
- package/dist/esm/sitecore-service-base.js +0 -29
- package/dist/esm/tools/codegen/component-generation.js +0 -44
- package/dist/esm/tools/codegen/extract-files.js +0 -99
- package/dist/esm/tools/codegen/import-map.js +0 -368
- package/dist/esm/tools/codegen/utils.js +0 -373
- package/dist/esm/tools/generate-map.js +0 -1
- package/dist/esm/tools/generateSites.js +0 -52
- package/dist/esm/tools/scaffold.js +0 -54
- package/dist/esm/tools/templating/components.js +0 -59
- package/dist/esm/tools/templating/index.js +0 -3
- package/dist/esm/tools/templating/plugins.js +0 -72
- package/dist/esm/tools/templating/utils.js +0 -59
- package/dist/esm/utils/env.js +0 -24
- package/dist/esm/utils/index.js +0 -4
- package/dist/esm/utils/normalize-url.js +0 -1
- package/editing.d.ts +0 -1
- package/i18n.d.ts +0 -1
- package/layout.d.ts +0 -1
- package/media.d.ts +0 -1
- package/personalize.d.ts +0 -1
- package/site.d.ts +0 -1
- package/types/client/constants.d.ts +0 -5
- package/types/client/constants.d.ts.map +0 -1
- package/types/client/edge-proxy.d.ts +0 -18
- package/types/client/edge-proxy.d.ts.map +0 -1
- package/types/client/index.d.ts +0 -8
- package/types/client/index.d.ts.map +0 -1
- package/types/client/models.d.ts +0 -21
- package/types/client/models.d.ts.map +0 -1
- package/types/client/sitecore-client.d.ts +0 -338
- package/types/client/sitecore-client.d.ts.map +0 -1
- package/types/client/utils.d.ts +0 -15
- package/types/client/utils.d.ts.map +0 -1
- package/types/config/define-config.d.ts +0 -20
- package/types/config/define-config.d.ts.map +0 -1
- package/types/config/index.d.ts +0 -3
- package/types/config/index.d.ts.map +0 -1
- package/types/config/models.d.ts +0 -287
- package/types/config/models.d.ts.map +0 -1
- package/types/config-cli/define-cli-config.d.ts +0 -9
- package/types/config-cli/define-cli-config.d.ts.map +0 -1
- package/types/config-cli/index.d.ts +0 -3
- package/types/config-cli/index.d.ts.map +0 -1
- package/types/config-cli/models.d.ts +0 -6
- package/types/config-cli/models.d.ts.map +0 -1
- package/types/editing/codegen/index.d.ts +0 -2
- package/types/editing/codegen/index.d.ts.map +0 -1
- package/types/editing/codegen/preview.d.ts +0 -289
- package/types/editing/codegen/preview.d.ts.map +0 -1
- package/types/editing/component-layout-service.d.ts +0 -84
- package/types/editing/component-layout-service.d.ts.map +0 -1
- package/types/editing/design-library.d.ts +0 -118
- package/types/editing/design-library.d.ts.map +0 -1
- package/types/editing/editing-service.d.ts +0 -72
- package/types/editing/editing-service.d.ts.map +0 -1
- package/types/editing/index.d.ts +0 -7
- package/types/editing/index.d.ts.map +0 -1
- package/types/editing/metadata.d.ts.map +0 -1
- package/types/editing/models.d.ts +0 -103
- package/types/editing/models.d.ts.map +0 -1
- package/types/editing/utils.d.ts +0 -91
- package/types/editing/utils.d.ts.map +0 -1
- package/types/form/form.d.ts +0 -25
- package/types/form/form.d.ts.map +0 -1
- package/types/form/index.d.ts +0 -2
- package/types/form/index.d.ts.map +0 -1
- package/types/i18n/dictionary-service.d.ts +0 -135
- package/types/i18n/dictionary-service.d.ts.map +0 -1
- package/types/i18n/index.d.ts +0 -3
- package/types/i18n/index.d.ts.map +0 -1
- package/types/i18n/utils.d.ts +0 -9
- package/types/i18n/utils.d.ts.map +0 -1
- package/types/layout/content-styles.d.ts +0 -20
- package/types/layout/content-styles.d.ts.map +0 -1
- package/types/layout/index.d.ts +0 -6
- package/types/layout/index.d.ts.map +0 -1
- package/types/layout/layout-service.d.ts +0 -45
- package/types/layout/layout-service.d.ts.map +0 -1
- package/types/layout/models.d.ts +0 -174
- package/types/layout/models.d.ts.map +0 -1
- package/types/layout/themes.d.ts +0 -13
- package/types/layout/themes.d.ts.map +0 -1
- package/types/layout/utils.d.ts +0 -56
- package/types/layout/utils.d.ts.map +0 -1
- package/types/media/index.d.ts +0 -3
- package/types/media/index.d.ts.map +0 -1
- package/types/media/media-api.d.ts +0 -60
- package/types/media/media-api.d.ts.map +0 -1
- package/types/personalize/index.d.ts +0 -4
- package/types/personalize/index.d.ts.map +0 -1
- package/types/personalize/layout-personalizer.d.ts +0 -29
- package/types/personalize/layout-personalizer.d.ts.map +0 -1
- package/types/personalize/personalize-service.d.ts +0 -90
- package/types/personalize/personalize-service.d.ts.map +0 -1
- package/types/personalize/utils.d.ts +0 -78
- package/types/personalize/utils.d.ts.map +0 -1
- package/types/site/error-pages-service.d.ts +0 -64
- package/types/site/error-pages-service.d.ts.map +0 -1
- package/types/site/index.d.ts +0 -10
- package/types/site/index.d.ts.map +0 -1
- package/types/site/models.d.ts +0 -23
- package/types/site/models.d.ts.map +0 -1
- package/types/site/redirects-service.d.ts +0 -92
- package/types/site/redirects-service.d.ts.map +0 -1
- package/types/site/robots-service.d.ts +0 -57
- package/types/site/robots-service.d.ts.map +0 -1
- package/types/site/site-resolver.d.ts +0 -28
- package/types/site/site-resolver.d.ts.map +0 -1
- package/types/site/siteinfo-service.d.ts +0 -65
- package/types/site/siteinfo-service.d.ts.map +0 -1
- package/types/site/sitemap-xml-service.d.ts +0 -63
- package/types/site/sitemap-xml-service.d.ts.map +0 -1
- package/types/site/sitepath-service.d.ts +0 -137
- package/types/site/sitepath-service.d.ts.map +0 -1
- package/types/site/utils.d.ts +0 -41
- package/types/site/utils.d.ts.map +0 -1
- package/types/sitecore-service-base.d.ts +0 -31
- package/types/sitecore-service-base.d.ts.map +0 -1
- package/types/tools/codegen/component-generation.d.ts +0 -50
- package/types/tools/codegen/component-generation.d.ts.map +0 -1
- package/types/tools/codegen/extract-files.d.ts +0 -24
- package/types/tools/codegen/extract-files.d.ts.map +0 -1
- package/types/tools/codegen/import-map.d.ts +0 -102
- package/types/tools/codegen/import-map.d.ts.map +0 -1
- package/types/tools/codegen/utils.d.ts +0 -76
- package/types/tools/codegen/utils.d.ts.map +0 -1
- package/types/tools/generate-map.d.ts +0 -36
- package/types/tools/generate-map.d.ts.map +0 -1
- package/types/tools/generateMetadata.d.ts.map +0 -1
- package/types/tools/generateSites.d.ts +0 -25
- package/types/tools/generateSites.d.ts.map +0 -1
- package/types/tools/scaffold.d.ts +0 -27
- package/types/tools/scaffold.d.ts.map +0 -1
- package/types/tools/templating/components.d.ts +0 -104
- package/types/tools/templating/components.d.ts.map +0 -1
- package/types/tools/templating/index.d.ts +0 -4
- package/types/tools/templating/index.d.ts.map +0 -1
- package/types/tools/templating/plugins.d.ts +0 -71
- package/types/tools/templating/plugins.d.ts.map +0 -1
- package/types/tools/templating/utils.d.ts +0 -42
- package/types/tools/templating/utils.d.ts.map +0 -1
- package/types/utils/ensurePath.d.ts.map +0 -1
- package/types/utils/env.d.ts +0 -9
- package/types/utils/env.d.ts.map +0 -1
- package/types/utils/index.d.ts +0 -5
- package/types/utils/index.d.ts.map +0 -1
- package/types/utils/is-server.d.ts.map +0 -1
- package/types/utils/normalize-url.d.ts +0 -2
- package/types/utils/normalize-url.d.ts.map +0 -1
- package/types/utils/utils.d.ts.map +0 -1
- package/utils.d.ts +0 -1
- /package/dist/cjs/{utils → tools}/globalCache.js +0 -0
- /package/dist/cjs/{utils → tools}/is-server.js +0 -0
- /package/dist/cjs/{utils → tools}/timeout-promise.js +0 -0
- /package/dist/esm/{utils → tools}/globalCache.js +0 -0
- /package/dist/esm/{utils → tools}/is-server.js +0 -0
- /package/dist/esm/{utils → tools}/timeout-promise.js +0 -0
- /package/types/{utils → tools}/globalCache.d.ts +0 -0
- /package/types/{utils → tools}/is-server.d.ts +0 -0
- /package/types/tools/{generateMetadata.d.ts → metadata/generateMetadata.d.ts} +0 -0
- /package/types/{utils → tools}/timeout-promise.d.ts +0 -0
package/dist/cjs/tools/index.js
CHANGED
|
@@ -1,75 +1,31 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var
|
|
3
|
-
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
19
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
20
4
|
};
|
|
21
|
-
var __importStar = (this && this.__importStar) || (function () {
|
|
22
|
-
var ownKeys = function(o) {
|
|
23
|
-
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
24
|
-
var ar = [];
|
|
25
|
-
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
26
|
-
return ar;
|
|
27
|
-
};
|
|
28
|
-
return ownKeys(o);
|
|
29
|
-
};
|
|
30
|
-
return function (mod) {
|
|
31
|
-
if (mod && mod.__esModule) return mod;
|
|
32
|
-
var result = {};
|
|
33
|
-
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
34
|
-
__setModuleDefault(result, mod);
|
|
35
|
-
return result;
|
|
36
|
-
};
|
|
37
|
-
})();
|
|
38
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
-
exports.
|
|
40
|
-
var
|
|
41
|
-
Object.defineProperty(exports, "
|
|
42
|
-
|
|
43
|
-
Object.defineProperty(exports, "
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
var
|
|
47
|
-
Object.defineProperty(exports, "
|
|
48
|
-
var
|
|
49
|
-
Object.defineProperty(exports, "
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
Object.defineProperty(exports, "
|
|
53
|
-
Object.defineProperty(exports, "
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
exports.auth = {};
|
|
66
|
-
/*
|
|
67
|
-
* Define an accessor so reads are dynamic
|
|
68
|
-
* - Production: returns the real `authModule.clientCredentialsFlow`.
|
|
69
|
-
* - Tests: can be replaced with a stub via `sinon.replaceGetter` or `sandbox.replaceGetter`
|
|
70
|
-
*/
|
|
71
|
-
Object.defineProperty(exports.auth, 'clientCredentialsFlow', {
|
|
72
|
-
get: () => authModule.clientCredentialsFlow,
|
|
73
|
-
configurable: true,
|
|
74
|
-
enumerable: true,
|
|
75
|
-
});
|
|
6
|
+
exports.mergeURLSearchParams = exports.escapeNonSpecialQuestionMarks = exports.areURLSearchParamsEqual = exports.isRegexOrUrl = exports.getAllowedOriginsFromEnv = exports.getEnforcedCorsHeaders = exports.isTimeoutError = exports.resolveUrl = exports.SITECORE_EXPERIENCE_EDGE_HOSTNAME_ENV = exports.SITECORE_EDGE_PLATFORM_HOSTNAME_ENV = exports.resolveExperienceEdgeUrl = exports.resolveEdgeUrlForStaticFiles = exports.resolveEdgeUrl = exports.isServer = exports.normalizeUrl = exports.setCache = exports.getCacheAndClean = exports.getCache = exports.hasCache = void 0;
|
|
7
|
+
var globalCache_1 = require("./globalCache");
|
|
8
|
+
Object.defineProperty(exports, "hasCache", { enumerable: true, get: function () { return globalCache_1.hasCache; } });
|
|
9
|
+
Object.defineProperty(exports, "getCache", { enumerable: true, get: function () { return globalCache_1.getCache; } });
|
|
10
|
+
Object.defineProperty(exports, "getCacheAndClean", { enumerable: true, get: function () { return globalCache_1.getCacheAndClean; } });
|
|
11
|
+
Object.defineProperty(exports, "setCache", { enumerable: true, get: function () { return globalCache_1.setCache; } });
|
|
12
|
+
// decoupling client-safe logic from /tools submodule which is not client-side safe
|
|
13
|
+
var normalize_url_1 = require("./normalize-url");
|
|
14
|
+
Object.defineProperty(exports, "normalizeUrl", { enumerable: true, get: function () { return normalize_url_1.normalizeUrl; } });
|
|
15
|
+
var is_server_1 = require("./is-server");
|
|
16
|
+
Object.defineProperty(exports, "isServer", { enumerable: true, get: function () { return __importDefault(is_server_1).default; } });
|
|
17
|
+
var resolve_edge_url_1 = require("./resolve-edge-url");
|
|
18
|
+
Object.defineProperty(exports, "resolveEdgeUrl", { enumerable: true, get: function () { return resolve_edge_url_1.resolveEdgeUrl; } });
|
|
19
|
+
Object.defineProperty(exports, "resolveEdgeUrlForStaticFiles", { enumerable: true, get: function () { return resolve_edge_url_1.resolveEdgeUrlForStaticFiles; } });
|
|
20
|
+
Object.defineProperty(exports, "resolveExperienceEdgeUrl", { enumerable: true, get: function () { return resolve_edge_url_1.resolveExperienceEdgeUrl; } });
|
|
21
|
+
Object.defineProperty(exports, "SITECORE_EDGE_PLATFORM_HOSTNAME_ENV", { enumerable: true, get: function () { return resolve_edge_url_1.SITECORE_EDGE_PLATFORM_HOSTNAME_ENV; } });
|
|
22
|
+
Object.defineProperty(exports, "SITECORE_EXPERIENCE_EDGE_HOSTNAME_ENV", { enumerable: true, get: function () { return resolve_edge_url_1.SITECORE_EXPERIENCE_EDGE_HOSTNAME_ENV; } });
|
|
23
|
+
var utils_1 = require("./utils");
|
|
24
|
+
Object.defineProperty(exports, "resolveUrl", { enumerable: true, get: function () { return utils_1.resolveUrl; } });
|
|
25
|
+
Object.defineProperty(exports, "isTimeoutError", { enumerable: true, get: function () { return utils_1.isTimeoutError; } });
|
|
26
|
+
Object.defineProperty(exports, "getEnforcedCorsHeaders", { enumerable: true, get: function () { return utils_1.getEnforcedCorsHeaders; } });
|
|
27
|
+
Object.defineProperty(exports, "getAllowedOriginsFromEnv", { enumerable: true, get: function () { return utils_1.getAllowedOriginsFromEnv; } });
|
|
28
|
+
Object.defineProperty(exports, "isRegexOrUrl", { enumerable: true, get: function () { return utils_1.isRegexOrUrl; } });
|
|
29
|
+
Object.defineProperty(exports, "areURLSearchParamsEqual", { enumerable: true, get: function () { return utils_1.areURLSearchParamsEqual; } });
|
|
30
|
+
Object.defineProperty(exports, "escapeNonSpecialQuestionMarks", { enumerable: true, get: function () { return utils_1.escapeNonSpecialQuestionMarks; } });
|
|
31
|
+
Object.defineProperty(exports, "mergeURLSearchParams", { enumerable: true, get: function () { return utils_1.mergeURLSearchParams; } });
|
|
@@ -6,8 +6,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
exports.generateMetadata = void 0;
|
|
7
7
|
const fs_1 = __importDefault(require("fs"));
|
|
8
8
|
const path_1 = __importDefault(require("path"));
|
|
9
|
-
const metadata_1 = require("
|
|
10
|
-
const ensurePath_1 = require("../
|
|
9
|
+
const metadata_1 = require("./metadata");
|
|
10
|
+
const ensurePath_1 = require("../ensurePath");
|
|
11
11
|
/**
|
|
12
12
|
* Generate application metadata
|
|
13
13
|
* @param {GenerateMetadataConfig} config - Optional configuration for generating metadata.
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.generateMetadata = void 0;
|
|
4
|
+
var generateMetadata_1 = require("./generateMetadata");
|
|
5
|
+
Object.defineProperty(exports, "generateMetadata", { enumerable: true, get: function () { return generateMetadata_1.generateMetadata; } });
|
|
@@ -2,12 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.getMetadata = getMetadata;
|
|
4
4
|
const child_process_1 = require("child_process");
|
|
5
|
-
const trackedScopes = [
|
|
6
|
-
'@sitecore',
|
|
7
|
-
'@sitecore-cloudsdk',
|
|
8
|
-
'@sitecore-feaas',
|
|
9
|
-
'@sitecore-content-sdk',
|
|
10
|
-
];
|
|
5
|
+
const trackedScopes = ['@sitecore', '@sitecore-feaas', '@sitecore-content-sdk'];
|
|
11
6
|
/**
|
|
12
7
|
* Get application metadata
|
|
13
8
|
* @param {boolean} allowWorkspaces - Whether to allow workspaces in the metadata generation.
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.normalizeEnvValue = normalizeEnvValue;
|
|
4
|
+
/**
|
|
5
|
+
* Normalizes values that may come from environment variables.
|
|
6
|
+
* In Node, setting `process.env.FOO = undefined` results in the string 'undefined',
|
|
7
|
+
* which should be treated as if the variable is not set.
|
|
8
|
+
* @param {string | undefined} value - Possibly undefined env-like value
|
|
9
|
+
* @returns {string | undefined} A usable string value, or undefined if not meaningful
|
|
10
|
+
* @internal
|
|
11
|
+
*/
|
|
12
|
+
function normalizeEnvValue(value) {
|
|
13
|
+
if (!value)
|
|
14
|
+
return undefined;
|
|
15
|
+
const trimmed = value.trim();
|
|
16
|
+
if (!trimmed)
|
|
17
|
+
return undefined;
|
|
18
|
+
const lowered = trimmed.toLowerCase();
|
|
19
|
+
if (lowered === 'undefined' || lowered === 'null')
|
|
20
|
+
return undefined;
|
|
21
|
+
return trimmed;
|
|
22
|
+
}
|
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.normalizeUrl = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Normalize a URL by removing the trailing slash
|
|
6
|
+
* @param {string} url - The URL to normalize
|
|
7
|
+
* @returns {string} The normalized URL
|
|
8
|
+
* @public
|
|
9
|
+
*/
|
|
4
10
|
const normalizeUrl = (url) => (url.endsWith('/') ? url.slice(0, -1) : url);
|
|
5
11
|
exports.normalizeUrl = normalizeUrl;
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SITECORE_EXPERIENCE_EDGE_HOSTNAME_ENV = exports.SITECORE_EDGE_PLATFORM_HOSTNAME_ENV = void 0;
|
|
4
|
+
exports.resolveEdgeUrl = resolveEdgeUrl;
|
|
5
|
+
exports.resolveExperienceEdgeUrl = resolveExperienceEdgeUrl;
|
|
6
|
+
exports.resolveEdgeUrlForStaticFiles = resolveEdgeUrlForStaticFiles;
|
|
7
|
+
const constants_1 = require("../constants");
|
|
8
|
+
const normalize_env_value_1 = require("./normalize-env-value");
|
|
9
|
+
const normalize_url_1 = require("./normalize-url");
|
|
10
|
+
/**
|
|
11
|
+
* Environment variable name for the custom Edge Platform hostname (framework-agnostic).
|
|
12
|
+
* Used for service endpoints (GraphQL, APIs, forms). Server-side only.
|
|
13
|
+
* @public
|
|
14
|
+
*/
|
|
15
|
+
exports.SITECORE_EDGE_PLATFORM_HOSTNAME_ENV = 'SITECORE_EDGE_PLATFORM_HOSTNAME';
|
|
16
|
+
/**
|
|
17
|
+
* Environment variable name for the custom Experience Edge hostname.
|
|
18
|
+
* Used only when rewriting media URLs in layout/editing (rewrite-edge-host). Server-side only.
|
|
19
|
+
* @public
|
|
20
|
+
*/
|
|
21
|
+
exports.SITECORE_EXPERIENCE_EDGE_HOSTNAME_ENV = 'SITECORE_EXPERIENCE_EDGE_HOSTNAME';
|
|
22
|
+
/**
|
|
23
|
+
* Resolves the Sitecore Edge URL based on configuration and environment.
|
|
24
|
+
*
|
|
25
|
+
* Priority order:
|
|
26
|
+
* 1. Explicit `edgeUrl` parameter (if provided and not empty)
|
|
27
|
+
* 2. `SITECORE_EDGE_PLATFORM_HOSTNAME` environment variable
|
|
28
|
+
* 3. Default Edge Platform URL (`https://edge-platform.sitecorecloud.io`)
|
|
29
|
+
*
|
|
30
|
+
* The hostname env var can be provided as:
|
|
31
|
+
* - Full URL: `https://my-custom-edge.example.com`
|
|
32
|
+
* - Hostname only: `my-custom-edge.example.com` (will be prefixed with `https://`)
|
|
33
|
+
* @param {string} [edgeUrl] - Optional explicit Edge URL to use (takes precedence if provided)
|
|
34
|
+
* @returns {string} The resolved Edge Platform base URL (normalized, no trailing slash)
|
|
35
|
+
* @public
|
|
36
|
+
* @example
|
|
37
|
+
* resolveEdgeUrl() // => 'https://my-tenant.edge.example.com'
|
|
38
|
+
* @example
|
|
39
|
+
* resolveEdgeUrl('https://custom.edge.com') // => 'https://custom.edge.com'
|
|
40
|
+
* @example
|
|
41
|
+
* resolveEdgeUrl() // => 'https://edge-platform.sitecorecloud.io'
|
|
42
|
+
*/
|
|
43
|
+
function resolveEdgeUrl(edgeUrl) {
|
|
44
|
+
// Use explicit edgeUrl if provided and not empty
|
|
45
|
+
const explicit = (0, normalize_env_value_1.normalizeEnvValue)(edgeUrl);
|
|
46
|
+
if (explicit) {
|
|
47
|
+
return (0, normalize_url_1.normalizeUrl)(explicit);
|
|
48
|
+
}
|
|
49
|
+
// Check for custom hostname env var
|
|
50
|
+
const hostnameEnvVar = (0, normalize_env_value_1.normalizeEnvValue)(process.env[exports.SITECORE_EDGE_PLATFORM_HOSTNAME_ENV]);
|
|
51
|
+
if (hostnameEnvVar) {
|
|
52
|
+
return normalizeHostnameToUrl(hostnameEnvVar);
|
|
53
|
+
}
|
|
54
|
+
return constants_1.SITECORE_EDGE_PLATFORM_URL_DEFAULT;
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Resolves the Experience Edge URL for media URL rewriting.
|
|
58
|
+
* Use only when rewriting media URLs in layout/editing (e.g. rewriteEdgeHostInResponse).
|
|
59
|
+
* Priority: SITECORE_EXPERIENCE_EDGE_HOSTNAME env, then default (edge.sitecorecloud.io).
|
|
60
|
+
* Server-side only.
|
|
61
|
+
* @returns {string} The Experience Edge base URL (no trailing slash)
|
|
62
|
+
* @public
|
|
63
|
+
*/
|
|
64
|
+
function resolveExperienceEdgeUrl() {
|
|
65
|
+
const hostnameEnvVar = (0, normalize_env_value_1.normalizeEnvValue)(process.env[exports.SITECORE_EXPERIENCE_EDGE_HOSTNAME_ENV]);
|
|
66
|
+
if (hostnameEnvVar) {
|
|
67
|
+
return normalizeHostnameToUrl(hostnameEnvVar);
|
|
68
|
+
}
|
|
69
|
+
return constants_1.SITECORE_EXPERIENCE_EDGE_URL_DEFAULT;
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Resolves the Edge URL for static files (e.g. stylesheets) by ignoring the custom hostname.
|
|
73
|
+
* Use this when the custom host does not serve static file paths (e.g. /v1/files/...).
|
|
74
|
+
* Returns the default Edge Platform URL.
|
|
75
|
+
* @returns {string} The Edge Platform base URL for static files (no trailing slash)
|
|
76
|
+
* @public
|
|
77
|
+
*/
|
|
78
|
+
function resolveEdgeUrlForStaticFiles() {
|
|
79
|
+
return constants_1.SITECORE_EDGE_PLATFORM_URL_DEFAULT;
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* Normalizes a hostname or URL to a full HTTPS URL without trailing slash.
|
|
83
|
+
* @param {string} hostnameOrUrl - A hostname (e.g., 'my.domain.com') or full URL (e.g., 'https://my.domain.com')
|
|
84
|
+
* @returns {string} A normalized HTTPS URL
|
|
85
|
+
* @internal
|
|
86
|
+
*/
|
|
87
|
+
function normalizeHostnameToUrl(hostnameOrUrl) {
|
|
88
|
+
const trimmed = hostnameOrUrl.trim();
|
|
89
|
+
// If it already has a protocol, normalize and return
|
|
90
|
+
if (trimmed.startsWith('https://') || trimmed.startsWith('http://')) {
|
|
91
|
+
return (0, normalize_url_1.normalizeUrl)(trimmed);
|
|
92
|
+
}
|
|
93
|
+
// Otherwise, treat as hostname and add https://
|
|
94
|
+
return (0, normalize_url_1.normalizeUrl)(`https://${trimmed}`);
|
|
95
|
+
}
|
|
@@ -3,7 +3,7 @@ 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.mergeURLSearchParams = exports.escapeNonSpecialQuestionMarks = exports.areURLSearchParamsEqual = exports.isRegexOrUrl = exports.getEnforcedCorsHeaders = exports.
|
|
6
|
+
exports.mergeURLSearchParams = exports.escapeNonSpecialQuestionMarks = exports.areURLSearchParamsEqual = exports.isRegexOrUrl = exports.getEnforcedCorsHeaders = exports.getAllowedOriginsFromEnv = exports.isTimeoutError = void 0;
|
|
7
7
|
exports.resolveUrl = resolveUrl;
|
|
8
8
|
const is_server_1 = __importDefault(require("./is-server"));
|
|
9
9
|
/**
|
|
@@ -34,7 +34,6 @@ function resolveUrl(urlBase, params = {}) {
|
|
|
34
34
|
// This is a better way to work with URLs since it handles different user input
|
|
35
35
|
// edge cases. This works in Node and all browser except IE11.
|
|
36
36
|
// https://developer.mozilla.org/en-US/docs/Web/API/URL
|
|
37
|
-
// TODO: Verify our browser support requirements.
|
|
38
37
|
if ((0, is_server_1.default)()) {
|
|
39
38
|
const url = new URL(urlBase);
|
|
40
39
|
for (const key in params) {
|
|
@@ -49,22 +48,6 @@ function resolveUrl(urlBase, params = {}) {
|
|
|
49
48
|
const result = urlBase.indexOf('?') !== -1 ? `${urlBase}&${qs}` : `${urlBase}?${qs}`;
|
|
50
49
|
return result;
|
|
51
50
|
}
|
|
52
|
-
/**
|
|
53
|
-
* Checks if the given URL is an absolute URL
|
|
54
|
-
* @param {string} url - The URL to check.
|
|
55
|
-
* @returns {boolean} - Returns true if the URL is an absolute URL, otherwise false.
|
|
56
|
-
* @public
|
|
57
|
-
*/
|
|
58
|
-
const isAbsoluteUrl = (url) => {
|
|
59
|
-
if (!url) {
|
|
60
|
-
return false;
|
|
61
|
-
}
|
|
62
|
-
if (typeof url !== 'string') {
|
|
63
|
-
throw new TypeError('Expected a string');
|
|
64
|
-
}
|
|
65
|
-
return /^[a-z][a-z0-9+.-]*:/.test(url);
|
|
66
|
-
};
|
|
67
|
-
exports.isAbsoluteUrl = isAbsoluteUrl;
|
|
68
51
|
/**
|
|
69
52
|
* Indicates whether the error is a timeout error
|
|
70
53
|
* @param {unknown} error error
|
|
@@ -93,54 +76,13 @@ const getAllowedOriginsFromEnv = () => process.env.JSS_ALLOWED_ORIGINS
|
|
|
93
76
|
? process.env.JSS_ALLOWED_ORIGINS.replace(' ', '').split(',')
|
|
94
77
|
: [];
|
|
95
78
|
exports.getAllowedOriginsFromEnv = getAllowedOriginsFromEnv;
|
|
96
|
-
/**
|
|
97
|
-
* Tests origin from incoming request against allowed origins list that can be
|
|
98
|
-
* set in JSS's JSS_ALLOWED_ORIGINS env variable, passed via allowedOrigins param and/or
|
|
99
|
-
* be already set in Access-Control-Allow-Origin by other logic.
|
|
100
|
-
* Applies Access-Control-Allow-Origin and Access-Control-Allow-Methods on match
|
|
101
|
-
* Also applies Access-Control-Allow-Headers for preflight requests
|
|
102
|
-
* @param {IncomingMessage} req incoming request
|
|
103
|
-
* @param {OutgoingMessage} res response to set CORS headers for
|
|
104
|
-
* @param {string[]} [allowedOrigins] additional list of origins to test against
|
|
105
|
-
* @returns true if incoming origin matches the allowed lists, false when it does not
|
|
106
|
-
* @deprecated use getEnforcedCorsHeaders instead
|
|
107
|
-
* @public
|
|
108
|
-
*/
|
|
109
|
-
const enforceCors = (req, res, allowedOrigins) => {
|
|
110
|
-
// origin in not present for non-CORS requests (e.g. server-side) - so we skip the checks
|
|
111
|
-
if (!req.headers.origin) {
|
|
112
|
-
return true;
|
|
113
|
-
}
|
|
114
|
-
// 3 sources of allowed origins are considered:
|
|
115
|
-
// the env value
|
|
116
|
-
const defaultAllowedOrigins = (0, exports.getAllowedOriginsFromEnv)();
|
|
117
|
-
// the allowedOrigins prop
|
|
118
|
-
allowedOrigins = defaultAllowedOrigins.concat(allowedOrigins || []);
|
|
119
|
-
// and the existing CORS header, if present (i.e. set by nextjs config)
|
|
120
|
-
const presetCors = res.getHeader('Access-Control-Allow-Origin');
|
|
121
|
-
if (presetCors) {
|
|
122
|
-
allowedOrigins.push(presetCors);
|
|
123
|
-
}
|
|
124
|
-
const origin = req.headers.origin;
|
|
125
|
-
if (origin &&
|
|
126
|
-
allowedOrigins.some((allowedOrigin) => origin === allowedOrigin || new RegExp(convertToWildcardRegex(allowedOrigin)).test(origin))) {
|
|
127
|
-
res.setHeader('Access-Control-Allow-Origin', origin);
|
|
128
|
-
res.setHeader('Access-Control-Allow-Methods', 'GET, POST, OPTIONS, DELETE, PUT, PATCH');
|
|
129
|
-
// set the allowed headers for preflight requests
|
|
130
|
-
if (req.method === 'OPTIONS') {
|
|
131
|
-
res.setHeader('Access-Control-Allow-Headers', 'Content-Type, Authorization');
|
|
132
|
-
}
|
|
133
|
-
return true;
|
|
134
|
-
}
|
|
135
|
-
return false;
|
|
136
|
-
};
|
|
137
|
-
exports.enforceCors = enforceCors;
|
|
138
79
|
/**
|
|
139
80
|
* Gets enforced CORS headers
|
|
140
|
-
* @param {
|
|
141
|
-
* @param {
|
|
142
|
-
* @param {
|
|
143
|
-
* @param {string[]}
|
|
81
|
+
* @param {object} options - The options
|
|
82
|
+
* @param {string} options.requestMethod - The HTTP method of the request.
|
|
83
|
+
* @param {IncomingHttpHeaders | Headers} options.headers - The headers of the request.
|
|
84
|
+
* @param {string | string[]} options.presetCorsHeader - The preset CORS header.
|
|
85
|
+
* @param {string[]} [options.allowedOrigins] - The allowed origins.
|
|
144
86
|
* @returns {Record<string, string>} - The enforced CORS headers.
|
|
145
87
|
* @public
|
|
146
88
|
*/
|
package/dist/esm/constants.js
CHANGED
|
@@ -1,29 +1,15 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
3
|
-
*
|
|
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
|
|
2
|
+
* Default Edge Platform URL (edge-platform.sitecorecloud.io). Used for service endpoints
|
|
3
|
+
* (GraphQL, content API, forms, layout, static files) when no custom hostname is configured.
|
|
19
4
|
* @internal
|
|
20
5
|
*/
|
|
21
|
-
export const
|
|
6
|
+
export const SITECORE_EDGE_PLATFORM_URL_DEFAULT = 'https://edge-platform.sitecorecloud.io';
|
|
22
7
|
/**
|
|
23
|
-
*
|
|
8
|
+
* Default Experience Edge URL (edge.sitecorecloud.io). Used only when replacing media URLs
|
|
9
|
+
* in layout/editing responses (rewrite-edge-host). Do not use for service endpoints.
|
|
24
10
|
* @internal
|
|
25
11
|
*/
|
|
26
|
-
export const
|
|
12
|
+
export const SITECORE_EXPERIENCE_EDGE_URL_DEFAULT = 'https://edge.sitecorecloud.io';
|
|
27
13
|
/**
|
|
28
14
|
* Claims URL
|
|
29
15
|
* @internal
|
package/dist/esm/debug.js
CHANGED
|
@@ -1,8 +1,17 @@
|
|
|
1
1
|
var _a;
|
|
2
2
|
/* eslint-disable import/no-anonymous-default-export */
|
|
3
3
|
import debug from 'debug';
|
|
4
|
-
import isServer from './
|
|
5
|
-
|
|
4
|
+
import isServer from './tools/is-server';
|
|
5
|
+
/**
|
|
6
|
+
* Debug module
|
|
7
|
+
* @public
|
|
8
|
+
*/
|
|
9
|
+
export const debugModule = debug;
|
|
10
|
+
/**
|
|
11
|
+
* Debug namespace
|
|
12
|
+
* @public
|
|
13
|
+
*/
|
|
14
|
+
export const debugNamespace = 'content-sdk';
|
|
6
15
|
// On server/node side, allow switching from the built-in
|
|
7
16
|
// `%o` (pretty-print single line) and `%O` (pretty-print multiple line)
|
|
8
17
|
// with a `DEBUG_MULTILINE` environment variable.
|
|
@@ -23,19 +32,6 @@ export const enableDebug = (namespaces) => debug.enable(namespaces);
|
|
|
23
32
|
* See {@link https://www.npmjs.com/package/debug} for details.
|
|
24
33
|
*/
|
|
25
34
|
export default {
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
form: debug(`${rootNamespace}:form`),
|
|
29
|
-
http: debug(`${rootNamespace}:http`),
|
|
30
|
-
layout: debug(`${rootNamespace}:layout`),
|
|
31
|
-
dictionary: debug(`${rootNamespace}:dictionary`),
|
|
32
|
-
editing: debug(`${rootNamespace}:editing`),
|
|
33
|
-
sitemap: debug(`${rootNamespace}:sitemap`),
|
|
34
|
-
multisite: debug(`${rootNamespace}:multisite`),
|
|
35
|
-
robots: debug(`${rootNamespace}:robots`),
|
|
36
|
-
redirects: debug(`${rootNamespace}:redirects`),
|
|
37
|
-
personalize: debug(`${rootNamespace}:personalize`),
|
|
38
|
-
locale: debug(`${rootNamespace}:locale`),
|
|
39
|
-
errorpages: debug(`${rootNamespace}:errorpages`),
|
|
40
|
-
proxy: debug(`${rootNamespace}:proxy`),
|
|
35
|
+
common: debug(`${debugNamespace}:common`),
|
|
36
|
+
http: debug(`${debugNamespace}:http`),
|
|
41
37
|
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { GraphQLClient as Client } from 'graphql-request';
|
|
2
2
|
import parse from 'url-parse';
|
|
3
3
|
import debuggers from './debug';
|
|
4
|
-
import TimeoutPromise from './
|
|
4
|
+
import TimeoutPromise from './tools/timeout-promise';
|
|
5
5
|
import { DefaultRetryStrategy } from './retries';
|
|
6
6
|
/**
|
|
7
7
|
* A GraphQL client for Sitecore APIs that uses the 'graphql-request' library.
|
|
@@ -24,6 +24,9 @@ export class GraphQLRequestClient {
|
|
|
24
24
|
if (clientConfig.headers) {
|
|
25
25
|
this.headers = Object.assign(Object.assign({}, this.headers), clientConfig.headers);
|
|
26
26
|
}
|
|
27
|
+
if (clientConfig.contextId) {
|
|
28
|
+
this.headers['x-sitecore-contextid'] = clientConfig.contextId;
|
|
29
|
+
}
|
|
27
30
|
if (!endpoint || !parse(endpoint).hostname) {
|
|
28
31
|
throw new Error(`Invalid GraphQL endpoint '${endpoint}'. Verify that appropriate environment variable is set`);
|
|
29
32
|
}
|
|
@@ -43,9 +46,10 @@ export class GraphQLRequestClient {
|
|
|
43
46
|
* @param {object} config - client configuration options.
|
|
44
47
|
* @param {string} config.endpoint - endpoint
|
|
45
48
|
* @param {string} [config.apiKey] - apikey
|
|
49
|
+
* @param {string} [config.contextId] - contextId
|
|
46
50
|
*/
|
|
47
|
-
static createClientFactory({ endpoint, apiKey, }) {
|
|
48
|
-
return (config = {}) => new GraphQLRequestClient(endpoint, Object.assign(Object.assign({}, config), { apiKey }));
|
|
51
|
+
static createClientFactory({ endpoint, apiKey, contextId, }) {
|
|
52
|
+
return (config = {}) => new GraphQLRequestClient(endpoint, Object.assign(Object.assign({}, config), { apiKey, contextId }));
|
|
49
53
|
}
|
|
50
54
|
/**
|
|
51
55
|
* Execute graphql request
|
|
@@ -67,8 +71,9 @@ export class GraphQLRequestClient {
|
|
|
67
71
|
variables,
|
|
68
72
|
timeout: this.timeout,
|
|
69
73
|
});
|
|
70
|
-
|
|
74
|
+
// Use performance.now() for Next.js 16 compatibility (safe to use before request data access)
|
|
71
75
|
const headers = Object.assign(Object.assign({}, this.headers), options === null || options === void 0 ? void 0 : options.headers);
|
|
76
|
+
const startTimestamp = performance.now();
|
|
72
77
|
const fetchWithOptionalTimeout = [this.client.request(query, variables, headers)];
|
|
73
78
|
if (this.timeout) {
|
|
74
79
|
this.abortTimeout = new TimeoutPromise(this.timeout);
|
|
@@ -77,7 +82,7 @@ export class GraphQLRequestClient {
|
|
|
77
82
|
return Promise.race(fetchWithOptionalTimeout).then((data) => {
|
|
78
83
|
var _a;
|
|
79
84
|
(_a = this.abortTimeout) === null || _a === void 0 ? void 0 : _a.clear();
|
|
80
|
-
this.debug('response in %dms: %o',
|
|
85
|
+
this.debug('response in %dms: %o', performance.now() - startTimestamp, data);
|
|
81
86
|
return Promise.resolve(data);
|
|
82
87
|
}, async (error) => {
|
|
83
88
|
var _a, _b;
|
package/dist/esm/index.js
CHANGED
|
@@ -1,13 +1,8 @@
|
|
|
1
|
-
// NOTE: all imports are now named as to not make breaking changes
|
|
2
|
-
// and to keep react-native working with cjs modules.
|
|
3
1
|
import * as constants from './constants';
|
|
4
|
-
|
|
5
|
-
export { default as debug, enableDebug } from './debug';
|
|
2
|
+
export { default as debug, enableDebug, debugNamespace, debugModule } from './debug';
|
|
6
3
|
export { GraphQLRequestClient, } from './graphql-request-client';
|
|
7
4
|
export { DefaultRetryStrategy } from './retries';
|
|
8
5
|
export { MemoryCacheClient } from './cache-client';
|
|
9
6
|
export { ClientError } from 'graphql-request';
|
|
10
7
|
export { NativeDataFetcher, } from './native-fetcher';
|
|
11
8
|
export { constants };
|
|
12
|
-
export { form };
|
|
13
|
-
export { defineConfig } from './config';
|
|
@@ -10,7 +10,7 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
10
10
|
return t;
|
|
11
11
|
};
|
|
12
12
|
import debuggers from './debug';
|
|
13
|
-
import TimeoutPromise from './
|
|
13
|
+
import TimeoutPromise from './tools/timeout-promise';
|
|
14
14
|
/**
|
|
15
15
|
* Native data fetcher class
|
|
16
16
|
* @public
|
|
@@ -4,6 +4,7 @@ import path from 'path';
|
|
|
4
4
|
* Ensures that the directory path for the given file path exists.
|
|
5
5
|
* If the directory does not exist, it will be created recursively.
|
|
6
6
|
* @param {string} filePath - The file path for which to ensure the directory exists.
|
|
7
|
+
* @internal
|
|
7
8
|
*/
|
|
8
9
|
export const ensurePathExists = (filePath) => {
|
|
9
10
|
const outputDir = path.dirname(filePath);
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
// export point for /node-tools submodule, which is not client-side safe and should not be imported in browser bundles
|
|
2
|
+
export * from './auth/models';
|
|
3
|
+
import * as authModule from './auth';
|
|
4
|
+
export * from './metadata';
|
|
5
|
+
export { ensurePathExists } from './ensurePath';
|
|
6
|
+
/**
|
|
7
|
+
* Preserve "live binding" semantics similar to ES module imports: production
|
|
8
|
+
* code always sees the current implementation; tests can swap it safely and
|
|
9
|
+
* restore via `sandbox.restore()` with no hidden global state.
|
|
10
|
+
* @public
|
|
11
|
+
*/
|
|
12
|
+
export const auth = {};
|
|
13
|
+
/*
|
|
14
|
+
* Define an accessor so reads are dynamic
|
|
15
|
+
* - Production: returns the real `authModule.clientCredentialsFlow`.
|
|
16
|
+
* - Tests: can be replaced with a stub via `sinon.replaceGetter` or `sandbox.replaceGetter`
|
|
17
|
+
*/
|
|
18
|
+
Object.defineProperty(auth, 'clientCredentialsFlow', {
|
|
19
|
+
get: () => authModule.clientCredentialsFlow,
|
|
20
|
+
configurable: true,
|
|
21
|
+
enumerable: true,
|
|
22
|
+
});
|
package/dist/esm/tools/index.js
CHANGED
|
@@ -1,28 +1,6 @@
|
|
|
1
|
-
export {
|
|
2
|
-
|
|
3
|
-
export {
|
|
4
|
-
export {
|
|
5
|
-
export {
|
|
6
|
-
export {
|
|
7
|
-
export * from './templating';
|
|
8
|
-
export * from './auth/models';
|
|
9
|
-
import * as authModule from './auth';
|
|
10
|
-
/**
|
|
11
|
-
* Preserve "live binding" semantics similar to ES module imports: production
|
|
12
|
-
* code always sees the current implementation; tests can swap it safely and
|
|
13
|
-
* restore via `sandbox.restore()` with no hidden global state.
|
|
14
|
-
*
|
|
15
|
-
* Public surface consumed by the rest of the codebase.
|
|
16
|
-
* @public
|
|
17
|
-
*/
|
|
18
|
-
export const auth = {};
|
|
19
|
-
/*
|
|
20
|
-
* Define an accessor so reads are dynamic
|
|
21
|
-
* - Production: returns the real `authModule.clientCredentialsFlow`.
|
|
22
|
-
* - Tests: can be replaced with a stub via `sinon.replaceGetter` or `sandbox.replaceGetter`
|
|
23
|
-
*/
|
|
24
|
-
Object.defineProperty(auth, 'clientCredentialsFlow', {
|
|
25
|
-
get: () => authModule.clientCredentialsFlow,
|
|
26
|
-
configurable: true,
|
|
27
|
-
enumerable: true,
|
|
28
|
-
});
|
|
1
|
+
export { hasCache, getCache, getCacheAndClean, setCache } from './globalCache';
|
|
2
|
+
// decoupling client-safe logic from /tools submodule which is not client-side safe
|
|
3
|
+
export { normalizeUrl } from './normalize-url';
|
|
4
|
+
export { default as isServer } from './is-server';
|
|
5
|
+
export { resolveEdgeUrl, resolveEdgeUrlForStaticFiles, resolveExperienceEdgeUrl, SITECORE_EDGE_PLATFORM_HOSTNAME_ENV, SITECORE_EXPERIENCE_EDGE_HOSTNAME_ENV, } from './resolve-edge-url';
|
|
6
|
+
export { resolveUrl, isTimeoutError, getEnforcedCorsHeaders, getAllowedOriginsFromEnv, isRegexOrUrl, areURLSearchParamsEqual, escapeNonSpecialQuestionMarks, mergeURLSearchParams, } from './utils';
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import fs from 'fs';
|
|
2
2
|
import path from 'path';
|
|
3
|
-
import { getMetadata } from '
|
|
4
|
-
import { ensurePathExists } from '../
|
|
3
|
+
import { getMetadata } from './metadata';
|
|
4
|
+
import { ensurePathExists } from '../ensurePath';
|
|
5
5
|
/**
|
|
6
6
|
* Generate application metadata
|
|
7
7
|
* @param {GenerateMetadataConfig} config - Optional configuration for generating metadata.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { generateMetadata } from './generateMetadata';
|
|
@@ -1,10 +1,5 @@
|
|
|
1
1
|
import { execSync } from 'child_process';
|
|
2
|
-
const trackedScopes = [
|
|
3
|
-
'@sitecore',
|
|
4
|
-
'@sitecore-cloudsdk',
|
|
5
|
-
'@sitecore-feaas',
|
|
6
|
-
'@sitecore-content-sdk',
|
|
7
|
-
];
|
|
2
|
+
const trackedScopes = ['@sitecore', '@sitecore-feaas', '@sitecore-content-sdk'];
|
|
8
3
|
/**
|
|
9
4
|
* Get application metadata
|
|
10
5
|
* @param {boolean} allowWorkspaces - Whether to allow workspaces in the metadata generation.
|