@commercetools-frontend/application-config 21.1.2 → 21.3.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/dist/commercetools-frontend-application-config.cjs.dev.js +133 -99
- package/dist/commercetools-frontend-application-config.cjs.prod.js +133 -99
- package/dist/commercetools-frontend-application-config.esm.js +131 -98
- package/dist/declarations/src/formatters.d.ts +8 -0
- package/dist/declarations/src/index.d.ts +1 -0
- package/dist/declarations/src/load-config.d.ts +1 -0
- package/dist/declarations/src/process-config.d.ts +2 -7
- package/dist/declarations/src/ssr.d.ts +1 -0
- package/dist/declarations/src/substitute-variable-placeholders.d.ts +2 -6
- package/dist/declarations/src/transformers.d.ts +4 -0
- package/dist/declarations/src/types.d.ts +37 -0
- package/dist/formatters-40251cfd.cjs.prod.js +56 -0
- package/dist/formatters-41584280.cjs.dev.js +56 -0
- package/dist/formatters-62af6993.esm.js +48 -0
- package/package.json +11 -7
- package/ssr/dist/commercetools-frontend-application-config-ssr.cjs.d.ts +1 -0
- package/ssr/dist/commercetools-frontend-application-config-ssr.cjs.dev.js +12 -0
- package/ssr/dist/commercetools-frontend-application-config-ssr.cjs.js +7 -0
- package/ssr/dist/commercetools-frontend-application-config-ssr.cjs.prod.js +12 -0
- package/ssr/dist/commercetools-frontend-application-config-ssr.esm.js +3 -0
- package/ssr/package.json +4 -0
|
@@ -28,13 +28,15 @@ var _getPrototypeOf = require('@babel/runtime-corejs3/helpers/getPrototypeOf');
|
|
|
28
28
|
var _wrapNativeSuper = require('@babel/runtime-corejs3/helpers/wrapNativeSuper');
|
|
29
29
|
var _mapInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/map');
|
|
30
30
|
var Ajv = require('ajv');
|
|
31
|
+
var _slicedToArray = require('@babel/runtime-corejs3/helpers/slicedToArray');
|
|
32
|
+
var _trimInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/trim');
|
|
33
|
+
var _JSON$stringify = require('@babel/runtime-corejs3/core-js-stable/json/stringify');
|
|
31
34
|
var _toConsumableArray = require('@babel/runtime-corejs3/helpers/toConsumableArray');
|
|
32
35
|
var _Object$values = require('@babel/runtime-corejs3/core-js-stable/object/values');
|
|
33
36
|
var _includesInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/includes');
|
|
34
37
|
var uniq = require('lodash/uniq');
|
|
35
|
-
var
|
|
36
|
-
|
|
37
|
-
var _JSON$stringify = require('@babel/runtime-corejs3/core-js-stable/json/stringify');
|
|
38
|
+
var formatters = require('./formatters-41584280.cjs.dev.js');
|
|
39
|
+
require('lodash/upperFirst');
|
|
38
40
|
|
|
39
41
|
function _interopDefault (e) { return e && e.__esModule ? e : { 'default': e }; }
|
|
40
42
|
|
|
@@ -54,11 +56,11 @@ var path__default = /*#__PURE__*/_interopDefault(path);
|
|
|
54
56
|
var _Reflect$construct__default = /*#__PURE__*/_interopDefault(_Reflect$construct);
|
|
55
57
|
var _mapInstanceProperty__default = /*#__PURE__*/_interopDefault(_mapInstanceProperty);
|
|
56
58
|
var Ajv__default = /*#__PURE__*/_interopDefault(Ajv);
|
|
59
|
+
var _trimInstanceProperty__default = /*#__PURE__*/_interopDefault(_trimInstanceProperty);
|
|
60
|
+
var _JSON$stringify__default = /*#__PURE__*/_interopDefault(_JSON$stringify);
|
|
57
61
|
var _Object$values__default = /*#__PURE__*/_interopDefault(_Object$values);
|
|
58
62
|
var _includesInstanceProperty__default = /*#__PURE__*/_interopDefault(_includesInstanceProperty);
|
|
59
63
|
var uniq__default = /*#__PURE__*/_interopDefault(uniq);
|
|
60
|
-
var _trimInstanceProperty__default = /*#__PURE__*/_interopDefault(_trimInstanceProperty);
|
|
61
|
-
var _JSON$stringify__default = /*#__PURE__*/_interopDefault(_JSON$stringify);
|
|
62
64
|
|
|
63
65
|
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = _Reflect$construct__default["default"](Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
64
66
|
|
|
@@ -126,6 +128,15 @@ var explorer = cosmiconfig.cosmiconfigSync(moduleName, {
|
|
|
126
128
|
'.ts': loadJsModule
|
|
127
129
|
}
|
|
128
130
|
});
|
|
131
|
+
var getConfigPath = function getConfigPath() {
|
|
132
|
+
var configFile = explorer.search();
|
|
133
|
+
|
|
134
|
+
if (!configFile) {
|
|
135
|
+
throw new Error("Missing or invalid Custom Application configuration file.");
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
return configFile.filepath;
|
|
139
|
+
};
|
|
129
140
|
|
|
130
141
|
var loadConfig = function loadConfig(applicationPath) {
|
|
131
142
|
var configFile = explorer.search(applicationPath);
|
|
@@ -512,74 +523,6 @@ var validateConfig = function validateConfig(config) {
|
|
|
512
523
|
}
|
|
513
524
|
};
|
|
514
525
|
|
|
515
|
-
var CLOUD_IDENTIFIERS = {
|
|
516
|
-
GCP_AU: 'gcp-au',
|
|
517
|
-
GCP_EU: 'gcp-eu',
|
|
518
|
-
GCP_US: 'gcp-us',
|
|
519
|
-
AWS_FRA: 'aws-fra',
|
|
520
|
-
AWS_OHIO: 'aws-ohio'
|
|
521
|
-
};
|
|
522
|
-
var MC_API_URLS = {
|
|
523
|
-
GCP_AU: 'https://mc-api.australia-southeast1.gcp.commercetools.com',
|
|
524
|
-
GCP_EU: 'https://mc-api.europe-west1.gcp.commercetools.com',
|
|
525
|
-
GCP_US: 'https://mc-api.us-central1.gcp.commercetools.com',
|
|
526
|
-
AWS_FRA: 'https://mc-api.eu-central-1.aws.commercetools.com',
|
|
527
|
-
AWS_OHIO: 'https://mc-api.us-east-2.aws.commercetools.com'
|
|
528
|
-
};
|
|
529
|
-
|
|
530
|
-
var mapCloudIdentifierToApiUrl = function mapCloudIdentifierToApiUrl(key) {
|
|
531
|
-
var _context;
|
|
532
|
-
|
|
533
|
-
switch (key) {
|
|
534
|
-
case CLOUD_IDENTIFIERS.GCP_AU:
|
|
535
|
-
return MC_API_URLS.GCP_AU;
|
|
536
|
-
|
|
537
|
-
case CLOUD_IDENTIFIERS.GCP_EU:
|
|
538
|
-
return MC_API_URLS.GCP_EU;
|
|
539
|
-
|
|
540
|
-
case CLOUD_IDENTIFIERS.GCP_US:
|
|
541
|
-
return MC_API_URLS.GCP_US;
|
|
542
|
-
|
|
543
|
-
case CLOUD_IDENTIFIERS.AWS_FRA:
|
|
544
|
-
return MC_API_URLS.AWS_FRA;
|
|
545
|
-
|
|
546
|
-
case CLOUD_IDENTIFIERS.AWS_OHIO:
|
|
547
|
-
return MC_API_URLS.AWS_OHIO;
|
|
548
|
-
|
|
549
|
-
default:
|
|
550
|
-
// We would probably never get to this point, as the JSON schema validation
|
|
551
|
-
// kicks in before.
|
|
552
|
-
throw new Error(_concatInstanceProperty__default["default"](_context = "Unknown cloud identifier \"".concat(key, "\". Supported values: ")).call(_context, _Object$values__default["default"](CLOUD_IDENTIFIERS).toString()));
|
|
553
|
-
}
|
|
554
|
-
};
|
|
555
|
-
|
|
556
|
-
var getUniqueValues = function getUniqueValues() {
|
|
557
|
-
var _context2;
|
|
558
|
-
|
|
559
|
-
var initialValues = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
|
|
560
|
-
var additionalValues = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
|
|
561
|
-
return uniq__default["default"](_concatInstanceProperty__default["default"](_context2 = []).call(_context2, _toConsumableArray(initialValues), _toConsumableArray(additionalValues)));
|
|
562
|
-
};
|
|
563
|
-
|
|
564
|
-
var nonProductionEnvironment = ['development', 'test'];
|
|
565
|
-
|
|
566
|
-
var getIsProd = function getIsProd(env) {
|
|
567
|
-
return (// TL;DR: in case the `MC_APP_ENV` is defined, we consider that it's
|
|
568
|
-
// a production environment unless it's one of `development` or `test`.
|
|
569
|
-
// This allows to use for example the `staging` value, which from the
|
|
570
|
-
// application perspective is still considered a production environment.
|
|
571
|
-
env.MC_APP_ENV ? !_includesInstanceProperty__default["default"](nonProductionEnvironment).call(nonProductionEnvironment, env.MC_APP_ENV) : env.NODE_ENV === 'production'
|
|
572
|
-
);
|
|
573
|
-
};
|
|
574
|
-
|
|
575
|
-
var getOrThrow = function getOrThrow(fn, errorMessage) {
|
|
576
|
-
try {
|
|
577
|
-
return fn();
|
|
578
|
-
} catch (error) {
|
|
579
|
-
throw new Error(errorMessage);
|
|
580
|
-
}
|
|
581
|
-
};
|
|
582
|
-
|
|
583
526
|
/**
|
|
584
527
|
* NOTE:
|
|
585
528
|
* Allows variable placeholders. Supported types are:
|
|
@@ -613,12 +556,12 @@ var isFilePathVariablePlaceholder = function isFilePathVariablePlaceholder(value
|
|
|
613
556
|
return Boolean(valueOfPlaceholder.match(filePathRefSyntax));
|
|
614
557
|
};
|
|
615
558
|
|
|
616
|
-
var substituteEnvVariablePlaceholder = function substituteEnvVariablePlaceholder(valueOfPlaceholder, matchedString, valueOfEnvConfig,
|
|
559
|
+
var substituteEnvVariablePlaceholder = function substituteEnvVariablePlaceholder(valueOfPlaceholder, matchedString, valueOfEnvConfig, loadingOptions) {
|
|
617
560
|
var _valueOfPlaceholder$s = valueOfPlaceholder.split(':'),
|
|
618
561
|
_valueOfPlaceholder$s2 = _slicedToArray(_valueOfPlaceholder$s, 2),
|
|
619
562
|
requestedEnvVar = _valueOfPlaceholder$s2[1];
|
|
620
563
|
|
|
621
|
-
var hasEnvField =
|
|
564
|
+
var hasEnvField = loadingOptions.processEnv.hasOwnProperty(requestedEnvVar);
|
|
622
565
|
|
|
623
566
|
if (!hasEnvField) {
|
|
624
567
|
var _context;
|
|
@@ -627,17 +570,17 @@ var substituteEnvVariablePlaceholder = function substituteEnvVariablePlaceholder
|
|
|
627
570
|
}
|
|
628
571
|
|
|
629
572
|
var escapedMatchedString = matchedString.replace(/[${}:]/g, '\\$&');
|
|
630
|
-
return valueOfEnvConfig.replace(new RegExp("(".concat(escapedMatchedString, ")+"), 'g'),
|
|
573
|
+
return valueOfEnvConfig.replace(new RegExp("(".concat(escapedMatchedString, ")+"), 'g'), loadingOptions.processEnv[requestedEnvVar]);
|
|
631
574
|
};
|
|
632
575
|
|
|
633
|
-
var substituteIntlVariablePlaceholder = function substituteIntlVariablePlaceholder(valueOfPlaceholder, matchedString, valueOfEnvConfig,
|
|
576
|
+
var substituteIntlVariablePlaceholder = function substituteIntlVariablePlaceholder(valueOfPlaceholder, matchedString, valueOfEnvConfig, loadingOptions) {
|
|
634
577
|
var _valueOfPlaceholder$s3 = valueOfPlaceholder.split(':'),
|
|
635
578
|
_valueOfPlaceholder$s4 = _slicedToArray(_valueOfPlaceholder$s3, 3),
|
|
636
579
|
locale = _valueOfPlaceholder$s4[1],
|
|
637
580
|
requestedIntlMessageId = _valueOfPlaceholder$s4[2];
|
|
638
581
|
|
|
639
582
|
var translationsFilePath = require.resolve("./i18n/data/".concat(locale, ".json"), {
|
|
640
|
-
paths: ["".concat(
|
|
583
|
+
paths: ["".concat(loadingOptions.applicationPath, "/src"), loadingOptions.applicationPath]
|
|
641
584
|
});
|
|
642
585
|
|
|
643
586
|
var translations = require(translationsFilePath);
|
|
@@ -654,14 +597,14 @@ var substituteIntlVariablePlaceholder = function substituteIntlVariablePlacehold
|
|
|
654
597
|
return valueOfEnvConfig.replace(new RegExp("(".concat(escapedMatchedString, ")+"), 'g'), translations[requestedIntlMessageId]);
|
|
655
598
|
};
|
|
656
599
|
|
|
657
|
-
var substituteFilePathVariablePlaceholder = function substituteFilePathVariablePlaceholder(valueOfPlaceholder, matchedString, valueOfEnvConfig,
|
|
600
|
+
var substituteFilePathVariablePlaceholder = function substituteFilePathVariablePlaceholder(valueOfPlaceholder, matchedString, valueOfEnvConfig, loadingOptions) {
|
|
658
601
|
var _valueOfPlaceholder$s5 = valueOfPlaceholder.split(':'),
|
|
659
602
|
_valueOfPlaceholder$s6 = _slicedToArray(_valueOfPlaceholder$s5, 2),
|
|
660
603
|
filePathOrModule = _valueOfPlaceholder$s6[1];
|
|
661
604
|
|
|
662
605
|
var content = fs__default["default"].readFileSync(require.resolve(filePathOrModule, {
|
|
663
606
|
// Relative paths should be resolved from the application folder.
|
|
664
|
-
paths: [
|
|
607
|
+
paths: [loadingOptions.applicationPath]
|
|
665
608
|
}), {
|
|
666
609
|
encoding: 'utf-8'
|
|
667
610
|
});
|
|
@@ -675,7 +618,7 @@ var getValueOfPlaceholder = function getValueOfPlaceholder(valueWithPlaceholder)
|
|
|
675
618
|
}).replace(/\s/g, '');
|
|
676
619
|
};
|
|
677
620
|
|
|
678
|
-
var substituteVariablePlaceholders = function substituteVariablePlaceholders(config,
|
|
621
|
+
var substituteVariablePlaceholders = function substituteVariablePlaceholders(config, loadingOptions) {
|
|
679
622
|
return JSON.parse(_JSON$stringify__default["default"](config), function (_key, value) {
|
|
680
623
|
// Only strings are allowed
|
|
681
624
|
var substitutedValue = value;
|
|
@@ -688,11 +631,11 @@ var substituteVariablePlaceholders = function substituteVariablePlaceholders(con
|
|
|
688
631
|
var valueOfPlaceholder = getValueOfPlaceholder(matchedString);
|
|
689
632
|
|
|
690
633
|
if (isEnvVariablePlaceholder(valueOfPlaceholder)) {
|
|
691
|
-
substitutedValue = substituteEnvVariablePlaceholder(valueOfPlaceholder, matchedString, substitutedValue,
|
|
634
|
+
substitutedValue = substituteEnvVariablePlaceholder(valueOfPlaceholder, matchedString, substitutedValue, loadingOptions);
|
|
692
635
|
} else if (isIntlVariablePlaceholder(valueOfPlaceholder)) {
|
|
693
|
-
substitutedValue = substituteIntlVariablePlaceholder(valueOfPlaceholder, matchedString, substitutedValue,
|
|
636
|
+
substitutedValue = substituteIntlVariablePlaceholder(valueOfPlaceholder, matchedString, substitutedValue, loadingOptions);
|
|
694
637
|
} else if (isFilePathVariablePlaceholder(valueOfPlaceholder)) {
|
|
695
|
-
substitutedValue = substituteFilePathVariablePlaceholder(valueOfPlaceholder, matchedString, substitutedValue,
|
|
638
|
+
substitutedValue = substituteFilePathVariablePlaceholder(valueOfPlaceholder, matchedString, substitutedValue, loadingOptions);
|
|
696
639
|
}
|
|
697
640
|
});
|
|
698
641
|
}
|
|
@@ -702,6 +645,95 @@ var substituteVariablePlaceholders = function substituteVariablePlaceholders(con
|
|
|
702
645
|
});
|
|
703
646
|
};
|
|
704
647
|
|
|
648
|
+
var CLOUD_IDENTIFIERS = {
|
|
649
|
+
GCP_AU: 'gcp-au',
|
|
650
|
+
GCP_EU: 'gcp-eu',
|
|
651
|
+
GCP_US: 'gcp-us',
|
|
652
|
+
AWS_FRA: 'aws-fra',
|
|
653
|
+
AWS_OHIO: 'aws-ohio'
|
|
654
|
+
};
|
|
655
|
+
var MC_API_URLS = {
|
|
656
|
+
GCP_AU: 'https://mc-api.australia-southeast1.gcp.commercetools.com',
|
|
657
|
+
GCP_EU: 'https://mc-api.europe-west1.gcp.commercetools.com',
|
|
658
|
+
GCP_US: 'https://mc-api.us-central1.gcp.commercetools.com',
|
|
659
|
+
AWS_FRA: 'https://mc-api.eu-central-1.aws.commercetools.com',
|
|
660
|
+
AWS_OHIO: 'https://mc-api.us-east-2.aws.commercetools.com'
|
|
661
|
+
};
|
|
662
|
+
|
|
663
|
+
var mapCloudIdentifierToApiUrl = function mapCloudIdentifierToApiUrl(key) {
|
|
664
|
+
var _context;
|
|
665
|
+
|
|
666
|
+
switch (key) {
|
|
667
|
+
case CLOUD_IDENTIFIERS.GCP_AU:
|
|
668
|
+
return MC_API_URLS.GCP_AU;
|
|
669
|
+
|
|
670
|
+
case CLOUD_IDENTIFIERS.GCP_EU:
|
|
671
|
+
return MC_API_URLS.GCP_EU;
|
|
672
|
+
|
|
673
|
+
case CLOUD_IDENTIFIERS.GCP_US:
|
|
674
|
+
return MC_API_URLS.GCP_US;
|
|
675
|
+
|
|
676
|
+
case CLOUD_IDENTIFIERS.AWS_FRA:
|
|
677
|
+
return MC_API_URLS.AWS_FRA;
|
|
678
|
+
|
|
679
|
+
case CLOUD_IDENTIFIERS.AWS_OHIO:
|
|
680
|
+
return MC_API_URLS.AWS_OHIO;
|
|
681
|
+
|
|
682
|
+
default:
|
|
683
|
+
// We would probably never get to this point, as the JSON schema validation
|
|
684
|
+
// kicks in before.
|
|
685
|
+
throw new Error(_concatInstanceProperty__default["default"](_context = "Unknown cloud identifier \"".concat(key, "\". Supported values: ")).call(_context, _Object$values__default["default"](CLOUD_IDENTIFIERS).toString()));
|
|
686
|
+
}
|
|
687
|
+
};
|
|
688
|
+
|
|
689
|
+
var getUniqueValues = function getUniqueValues() {
|
|
690
|
+
var _context2;
|
|
691
|
+
|
|
692
|
+
var initialValues = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
|
|
693
|
+
var additionalValues = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
|
|
694
|
+
return uniq__default["default"](_concatInstanceProperty__default["default"](_context2 = []).call(_context2, _toConsumableArray(initialValues), _toConsumableArray(additionalValues)));
|
|
695
|
+
};
|
|
696
|
+
|
|
697
|
+
var nonProductionEnvironment = ['development', 'test'];
|
|
698
|
+
|
|
699
|
+
var getIsProd = function getIsProd(env) {
|
|
700
|
+
return (// TL;DR: in case the `MC_APP_ENV` is defined, we consider that it's
|
|
701
|
+
// a production environment unless it's one of `development` or `test`.
|
|
702
|
+
// This allows to use for example the `staging` value, which from the
|
|
703
|
+
// application perspective is still considered a production environment.
|
|
704
|
+
env.MC_APP_ENV ? !_includesInstanceProperty__default["default"](nonProductionEnvironment).call(nonProductionEnvironment, env.MC_APP_ENV) : env.NODE_ENV === 'production'
|
|
705
|
+
);
|
|
706
|
+
};
|
|
707
|
+
|
|
708
|
+
var getOrThrow = function getOrThrow(fn, errorMessage) {
|
|
709
|
+
try {
|
|
710
|
+
return fn();
|
|
711
|
+
} catch (error) {
|
|
712
|
+
throw new Error(errorMessage);
|
|
713
|
+
}
|
|
714
|
+
};
|
|
715
|
+
|
|
716
|
+
function transformCustomApplicationConfigToData(appConfig) {
|
|
717
|
+
var permissionKeys = formatters.entryPointUriPathToResourceAccesses(appConfig.entryPointUriPath);
|
|
718
|
+
return {
|
|
719
|
+
id: appConfig.env.production.applicationId,
|
|
720
|
+
name: appConfig.name,
|
|
721
|
+
description: appConfig.description,
|
|
722
|
+
entryPointUriPath: appConfig.entryPointUriPath,
|
|
723
|
+
url: appConfig.env.production.url,
|
|
724
|
+
permissions: [{
|
|
725
|
+
name: permissionKeys.view,
|
|
726
|
+
oAuthScopes: appConfig.oAuthScopes.view
|
|
727
|
+
}, {
|
|
728
|
+
name: permissionKeys.manage,
|
|
729
|
+
oAuthScopes: appConfig.oAuthScopes.manage
|
|
730
|
+
}],
|
|
731
|
+
icon: appConfig.icon,
|
|
732
|
+
mainMenuLink: appConfig.mainMenuLink,
|
|
733
|
+
submenuLinks: appConfig.submenuLinks
|
|
734
|
+
};
|
|
735
|
+
}
|
|
736
|
+
|
|
705
737
|
function ownKeys(object, enumerableOnly) { var keys = _Object$keys__default["default"](object); if (_Object$getOwnPropertySymbols__default["default"]) { var symbols = _Object$getOwnPropertySymbols__default["default"](object); enumerableOnly && (symbols = _filterInstanceProperty__default["default"](symbols).call(symbols, function (sym) { return _Object$getOwnPropertyDescriptor__default["default"](object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
706
738
|
|
|
707
739
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var _context3, _context4; var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? _forEachInstanceProperty__default["default"](_context3 = ownKeys(Object(source), !0)).call(_context3, function (key) { _defineProperty(target, key, source[key]); }) : _Object$getOwnPropertyDescriptors__default["default"] ? _Object$defineProperties__default["default"](target, _Object$getOwnPropertyDescriptors__default["default"](source)) : _forEachInstanceProperty__default["default"](_context4 = ownKeys(Object(source))).call(_context4, function (key) { _Object$defineProperty__default["default"](target, key, _Object$getOwnPropertyDescriptor__default["default"](source, key)); }); } return target; }
|
|
@@ -731,19 +763,19 @@ var processConfig = function processConfig() {
|
|
|
731
763
|
applicationPath = _ref$applicationPath === void 0 ? fs__default["default"].realpathSync(process.cwd()) : _ref$applicationPath;
|
|
732
764
|
|
|
733
765
|
if (cachedConfig && !disableCache) return cachedConfig;
|
|
766
|
+
var rawConfig = loadConfig(applicationPath);
|
|
767
|
+
validateConfig(rawConfig);
|
|
768
|
+
var appConfig = substituteVariablePlaceholders(rawConfig, {
|
|
769
|
+
applicationPath: applicationPath,
|
|
770
|
+
processEnv: processEnv
|
|
771
|
+
});
|
|
772
|
+
var customApplicationData = transformCustomApplicationConfigToData(appConfig);
|
|
734
773
|
var appEnvKey = (_ref2 = (_processEnv$MC_APP_EN = processEnv.MC_APP_ENV) !== null && _processEnv$MC_APP_EN !== void 0 ? _processEnv$MC_APP_EN : processEnv.NODE_ENV) !== null && _ref2 !== void 0 ? _ref2 : 'development';
|
|
735
774
|
var isProd = getIsProd(processEnv);
|
|
736
|
-
var loadedAppConfig = loadConfig(applicationPath);
|
|
737
|
-
validateConfig(loadedAppConfig);
|
|
738
|
-
var validatedLoadedAppConfig = loadedAppConfig;
|
|
739
|
-
var appConfig = substituteVariablePlaceholders(validatedLoadedAppConfig, {
|
|
740
|
-
processEnv: processEnv,
|
|
741
|
-
applicationPath: applicationPath
|
|
742
|
-
});
|
|
743
775
|
var additionalAppEnv = (_appConfig$additional = appConfig.additionalEnv) !== null && _appConfig$additional !== void 0 ? _appConfig$additional : {};
|
|
744
776
|
var revision = (_ref3 = additionalAppEnv.revision) !== null && _ref3 !== void 0 ? _ref3 : ''; // Parse all the supported URLs, which gets implicitly validated
|
|
745
777
|
|
|
746
|
-
var envAppUrl = isProd ?
|
|
778
|
+
var envAppUrl = isProd ? customApplicationData.url : developmentAppUrl;
|
|
747
779
|
var appUrl = getOrThrow(function () {
|
|
748
780
|
return new _URL__default["default"](envAppUrl);
|
|
749
781
|
}, "Invalid application URL: \"".concat(envAppUrl, "\"")); // Use `||` instead of `??` to include empty string values.
|
|
@@ -760,30 +792,31 @@ var processConfig = function processConfig() {
|
|
|
760
792
|
// This is important to determine to which URL the MC should redirect to
|
|
761
793
|
// after successful login.
|
|
762
794
|
|
|
763
|
-
var applicationId = isProd ? _concatInstanceProperty__default["default"](_context = "".concat(
|
|
795
|
+
var applicationId = isProd ? _concatInstanceProperty__default["default"](_context = "".concat(customApplicationData.id, ":")).call(_context, customApplicationData.entryPointUriPath) : "__local:".concat(customApplicationData.entryPointUriPath);
|
|
764
796
|
var developmentConfig = isProd ? undefined : omitDevConfigIfEmpty({
|
|
765
797
|
oidc: omitEmpty__default["default"]({
|
|
766
798
|
authorizeUrl: [// In case the MC API url points to localhost, we need to point
|
|
767
799
|
// to a local running dev login page to handle the workflow properly.
|
|
768
800
|
mcApiUrl.hostname === 'localhost' ? mcApiUrl.origin.replace(mcApiUrl.port, String(developmentPort)) : mcApiUrl.origin.replace('mc-api', 'mc'), '/login/authorize'].join(''),
|
|
769
801
|
initialProjectKey: // For the `account` application, we should unset the projectKey.
|
|
770
|
-
|
|
802
|
+
customApplicationData.entryPointUriPath === 'account' ? undefined : appConfig.env.development.initialProjectKey,
|
|
771
803
|
teamId: (_appConfig$env$develo = appConfig.env.development) === null || _appConfig$env$develo === void 0 ? void 0 : _appConfig$env$develo.teamId,
|
|
772
804
|
oAuthScopes: appConfig.oAuthScopes
|
|
773
805
|
}),
|
|
774
806
|
menuLinks: _objectSpread(_objectSpread({
|
|
775
|
-
icon:
|
|
776
|
-
},
|
|
777
|
-
submenuLinks:
|
|
807
|
+
icon: customApplicationData.icon
|
|
808
|
+
}, customApplicationData.mainMenuLink), {}, {
|
|
809
|
+
submenuLinks: customApplicationData.submenuLinks
|
|
778
810
|
}),
|
|
779
811
|
// @ts-expect-error: the `accountLinks` is not explicitly typed as it's only used by the account app.
|
|
780
812
|
accountLinks: appConfig.accountLinks
|
|
781
813
|
});
|
|
782
814
|
cachedConfig = {
|
|
815
|
+
data: customApplicationData,
|
|
783
816
|
env: _objectSpread(_objectSpread(_objectSpread({}, omitEmpty__default["default"](additionalAppEnv)), {}, {
|
|
784
817
|
applicationId: applicationId,
|
|
785
|
-
applicationName:
|
|
786
|
-
entryPointUriPath:
|
|
818
|
+
applicationName: customApplicationData.name,
|
|
819
|
+
entryPointUriPath: customApplicationData.entryPointUriPath
|
|
787
820
|
}, isProd || !developmentConfig ? {} : {
|
|
788
821
|
__DEVELOPMENT__: developmentConfig
|
|
789
822
|
}), {}, {
|
|
@@ -807,4 +840,5 @@ var processConfig = function processConfig() {
|
|
|
807
840
|
};
|
|
808
841
|
|
|
809
842
|
exports.MissingOrInvalidConfigError = MissingOrInvalidConfigError;
|
|
843
|
+
exports.getConfigPath = getConfigPath;
|
|
810
844
|
exports.processConfig = processConfig;
|