@commercetools-frontend/application-config 20.9.4 → 20.10.6

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.
@@ -59,9 +59,9 @@ var uniq__default = /*#__PURE__*/_interopDefault(uniq);
59
59
  var _trimInstanceProperty__default = /*#__PURE__*/_interopDefault(_trimInstanceProperty);
60
60
  var _JSON$stringify__default = /*#__PURE__*/_interopDefault(_JSON$stringify);
61
61
 
62
- 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); }; }
62
+ 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); }; }
63
63
 
64
- function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !_Reflect$construct__default['default']) return false; if (_Reflect$construct__default['default'].sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(_Reflect$construct__default['default'](Boolean, [], function () {})); return true; } catch (e) { return false; } }
64
+ function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !_Reflect$construct__default["default"]) return false; if (_Reflect$construct__default["default"].sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(_Reflect$construct__default["default"](Boolean, [], function () {})); return true; } catch (e) { return false; } }
65
65
 
66
66
  var MissingOrInvalidConfigError = /*#__PURE__*/function (_Error) {
67
67
  _inherits(MissingOrInvalidConfigError, _Error);
@@ -75,7 +75,7 @@ var MissingOrInvalidConfigError = /*#__PURE__*/function (_Error) {
75
75
 
76
76
  _this = _super.call(this, message);
77
77
 
78
- _Object$defineProperty__default['default'](_assertThisInitialized(_this), 'name', {
78
+ _Object$defineProperty__default["default"](_assertThisInitialized(_this), 'name', {
79
79
  value: 'MissingOrInvalidConfigError'
80
80
  });
81
81
 
@@ -88,26 +88,26 @@ var MissingOrInvalidConfigError = /*#__PURE__*/function (_Error) {
88
88
  // for instance in respect to both source files and dist files.
89
89
 
90
90
  var findPackageRootPath = function findPackageRootPath(dir) {
91
- var packageJsonPath = path__default['default'].join(dir, 'package.json');
91
+ var packageJsonPath = path__default["default"].join(dir, 'package.json');
92
92
 
93
- if (fs__default['default'].existsSync(packageJsonPath)) {
93
+ if (fs__default["default"].existsSync(packageJsonPath)) {
94
94
  return dir;
95
95
  }
96
96
 
97
- var parentDir = path__default['default'].join(dir, '..');
97
+ var parentDir = path__default["default"].join(dir, '..');
98
98
  return findPackageRootPath(parentDir);
99
99
  };
100
100
 
101
101
  var loadJsModule = function loadJsModule(filePath) {
102
102
  var packageRootPath = findPackageRootPath( // Start from the parent folder
103
- path__default['default'].join(__dirname, '..')); // Load the JS module using a child process. This is primarly to avoid
103
+ path__default["default"].join(__dirname, '..')); // Load the JS module using a child process. This is primarly to avoid
104
104
  // unwanted behaviors using `@babel/register` in the main process.
105
105
  // The loader script does the actual `require` of the given `filePath`
106
106
  // and uses `@babel/register` to correctly parse and execute the file.
107
107
  // The "required module output" is then written into `stdout` and parsed
108
108
  // as JSON.
109
109
 
110
- var output = child_process.execFileSync(path__default['default'].join(packageRootPath, 'scripts/load-js-module.js'), [filePath], {
110
+ var output = child_process.execFileSync(path__default["default"].join(packageRootPath, 'scripts/load-js-module.js'), [filePath], {
111
111
  encoding: 'utf8'
112
112
  });
113
113
  return JSON.parse(output);
@@ -457,7 +457,7 @@ var schemaJson = {
457
457
  ]
458
458
  };
459
459
 
460
- var ajv = new Ajv__default['default']({
460
+ var ajv = new Ajv__default["default"]({
461
461
  strict: true,
462
462
  useDefaults: true
463
463
  });
@@ -468,17 +468,17 @@ var printErrors = function printErrors(errors) {
468
468
  return 'No errors';
469
469
  }
470
470
 
471
- return _mapInstanceProperty__default['default'](errors).call(errors, function (error) {
471
+ return _mapInstanceProperty__default["default"](errors).call(errors, function (error) {
472
472
  var _context, _context2, _context3;
473
473
 
474
- var baseMessage = _concatInstanceProperty__default['default'](_context = "".concat(error.instancePath, " ")).call(_context, error.message);
474
+ var baseMessage = _concatInstanceProperty__default["default"](_context = "".concat(error.instancePath, " ")).call(_context, error.message);
475
475
 
476
476
  switch (error.keyword) {
477
477
  case 'additionalProperties':
478
- return _concatInstanceProperty__default['default'](_context2 = "".concat(baseMessage, ": ")).call(_context2, error.params.additionalProperty);
478
+ return _concatInstanceProperty__default["default"](_context2 = "".concat(baseMessage, ": ")).call(_context2, error.params.additionalProperty);
479
479
 
480
480
  case 'enum':
481
- return _concatInstanceProperty__default['default'](_context3 = "".concat(baseMessage, ": ")).call(_context3, error.params.allowedValues.toString());
481
+ return _concatInstanceProperty__default["default"](_context3 = "".concat(baseMessage, ": ")).call(_context3, error.params.allowedValues.toString());
482
482
 
483
483
  default:
484
484
  return baseMessage;
@@ -531,7 +531,7 @@ var mapCloudIdentifierToApiUrl = function mapCloudIdentifierToApiUrl(key) {
531
531
  default:
532
532
  // We would probably never get to this point, as the JSON schema validation
533
533
  // kicks in before.
534
- throw new Error(_concatInstanceProperty__default['default'](_context = "Unknown cloud identifier \"".concat(key, "\". Supported values: ")).call(_context, _Object$values__default['default'](CLOUD_IDENTIFIERS).toString()));
534
+ throw new Error(_concatInstanceProperty__default["default"](_context = "Unknown cloud identifier \"".concat(key, "\". Supported values: ")).call(_context, _Object$values__default["default"](CLOUD_IDENTIFIERS).toString()));
535
535
  }
536
536
  };
537
537
 
@@ -540,7 +540,7 @@ var getUniqueValues = function getUniqueValues() {
540
540
 
541
541
  var initialValues = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
542
542
  var additionalValues = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
543
- return uniq__default['default'](_concatInstanceProperty__default['default'](_context2 = []).call(_context2, _toConsumableArray(initialValues), _toConsumableArray(additionalValues)));
543
+ return uniq__default["default"](_concatInstanceProperty__default["default"](_context2 = []).call(_context2, _toConsumableArray(initialValues), _toConsumableArray(additionalValues)));
544
544
  };
545
545
 
546
546
  var nonProductionEnvironment = ['development', 'test'];
@@ -550,7 +550,7 @@ var getIsProd = function getIsProd(env) {
550
550
  // a production environment unless it's one of `development` or `test`.
551
551
  // This allows to use for example the `staging` value, which from the
552
552
  // application perspective is still considered a production environment.
553
- env.MC_APP_ENV ? !_includesInstanceProperty__default['default'](nonProductionEnvironment).call(nonProductionEnvironment, env.MC_APP_ENV) : env.NODE_ENV === 'production'
553
+ env.MC_APP_ENV ? !_includesInstanceProperty__default["default"](nonProductionEnvironment).call(nonProductionEnvironment, env.MC_APP_ENV) : env.NODE_ENV === 'production'
554
554
  );
555
555
  };
556
556
 
@@ -605,7 +605,7 @@ var substituteEnvVariablePlaceholder = function substituteEnvVariablePlaceholder
605
605
  if (!hasEnvField) {
606
606
  var _context;
607
607
 
608
- throw new Error(_concatInstanceProperty__default['default'](_context = "Missing environment variable '".concat(requestedEnvVar, "' specified in config as 'env:")).call(_context, requestedEnvVar, "'."));
608
+ throw new Error(_concatInstanceProperty__default["default"](_context = "Missing environment variable '".concat(requestedEnvVar, "' specified in config as 'env:")).call(_context, requestedEnvVar, "'."));
609
609
  }
610
610
 
611
611
  var escapedMatchedString = matchedString.replace(/[${}:]/g, '\\$&');
@@ -629,7 +629,7 @@ var substituteIntlVariablePlaceholder = function substituteIntlVariablePlacehold
629
629
  if (!hasIntlMessage) {
630
630
  var _context2, _context3;
631
631
 
632
- throw new Error(_concatInstanceProperty__default['default'](_context2 = _concatInstanceProperty__default['default'](_context3 = "Missing message key '".concat(requestedIntlMessageId, "' specified in config as 'intl:")).call(_context3, locale, ":")).call(_context2, requestedIntlMessageId, "'."));
632
+ throw new Error(_concatInstanceProperty__default["default"](_context2 = _concatInstanceProperty__default["default"](_context3 = "Missing message key '".concat(requestedIntlMessageId, "' specified in config as 'intl:")).call(_context3, locale, ":")).call(_context2, requestedIntlMessageId, "'."));
633
633
  }
634
634
 
635
635
  var escapedMatchedString = matchedString.replace(/[${}:]/g, '\\$&');
@@ -641,7 +641,7 @@ var substituteFilePathVariablePlaceholder = function substituteFilePathVariableP
641
641
  _valueOfPlaceholder$s6 = _slicedToArray(_valueOfPlaceholder$s5, 2),
642
642
  filePathOrModule = _valueOfPlaceholder$s6[1];
643
643
 
644
- var content = fs__default['default'].readFileSync(require.resolve(filePathOrModule, {
644
+ var content = fs__default["default"].readFileSync(require.resolve(filePathOrModule, {
645
645
  // Relative paths should be resolved from the application folder.
646
646
  paths: [meta.applicationPath]
647
647
  }), {
@@ -653,12 +653,12 @@ var substituteFilePathVariablePlaceholder = function substituteFilePathVariableP
653
653
 
654
654
  var getValueOfPlaceholder = function getValueOfPlaceholder(valueWithPlaceholder) {
655
655
  return valueWithPlaceholder.replace(variableSyntax, function (_match, varName) {
656
- return _trimInstanceProperty__default['default'](varName).call(varName);
656
+ return _trimInstanceProperty__default["default"](varName).call(varName);
657
657
  }).replace(/\s/g, '');
658
658
  };
659
659
 
660
660
  var substituteVariablePlaceholders = function substituteVariablePlaceholders(config, meta) {
661
- return JSON.parse(_JSON$stringify__default['default'](config), function (_key, value) {
661
+ return JSON.parse(_JSON$stringify__default["default"](config), function (_key, value) {
662
662
  // Only strings are allowed
663
663
  var substitutedValue = value;
664
664
 
@@ -666,7 +666,7 @@ var substituteVariablePlaceholders = function substituteVariablePlaceholders(con
666
666
  var matchResult = substitutedValue.match(variableSyntax);
667
667
 
668
668
  if (matchResult) {
669
- _forEachInstanceProperty__default['default'](matchResult).call(matchResult, function (matchedString) {
669
+ _forEachInstanceProperty__default["default"](matchResult).call(matchResult, function (matchedString) {
670
670
  var valueOfPlaceholder = getValueOfPlaceholder(matchedString);
671
671
 
672
672
  if (isEnvVariablePlaceholder(valueOfPlaceholder)) {
@@ -684,10 +684,12 @@ var substituteVariablePlaceholders = function substituteVariablePlaceholders(con
684
684
  });
685
685
  };
686
686
 
687
- function ownKeys(object, enumerableOnly) { var keys = _Object$keys__default['default'](object); if (_Object$getOwnPropertySymbols__default['default']) { var symbols = _Object$getOwnPropertySymbols__default['default'](object); if (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; }
687
+ function ownKeys(object, enumerableOnly) { var keys = _Object$keys__default["default"](object); if (_Object$getOwnPropertySymbols__default["default"]) { var symbols = _Object$getOwnPropertySymbols__default["default"](object); if (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; }
688
688
 
689
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { var _context3; _forEachInstanceProperty__default['default'](_context3 = ownKeys(Object(source), true)).call(_context3, function (key) { _defineProperty(target, key, source[key]); }); } else if (_Object$getOwnPropertyDescriptors__default['default']) { _Object$defineProperties__default['default'](target, _Object$getOwnPropertyDescriptors__default['default'](source)); } else { var _context4; _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; }
690
- var developmentAppUrl = 'http://localhost:3001';
689
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { var _context3; _forEachInstanceProperty__default["default"](_context3 = ownKeys(Object(source), true)).call(_context3, function (key) { _defineProperty(target, key, source[key]); }); } else if (_Object$getOwnPropertyDescriptors__default["default"]) { _Object$defineProperties__default["default"](target, _Object$getOwnPropertyDescriptors__default["default"](source)); } else { var _context4; _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; }
690
+ // TODO: make it configurable.
691
+ var developmentPort = 3001;
692
+ var developmentAppUrl = "http://localhost:".concat(developmentPort);
691
693
 
692
694
  var omitDevConfigIfEmpty = function omitDevConfigIfEmpty(devConfig) {
693
695
  if ( // @ts-expect-error: the `accountLinks` is not explicitly typed as it's only used by the account app.
@@ -708,7 +710,7 @@ var processConfig = function processConfig() {
708
710
  _ref$processEnv = _ref.processEnv,
709
711
  processEnv = _ref$processEnv === void 0 ? process.env : _ref$processEnv,
710
712
  _ref$applicationPath = _ref.applicationPath,
711
- applicationPath = _ref$applicationPath === void 0 ? fs__default['default'].realpathSync(process.cwd()) : _ref$applicationPath;
713
+ applicationPath = _ref$applicationPath === void 0 ? fs__default["default"].realpathSync(process.cwd()) : _ref$applicationPath;
712
714
 
713
715
  if (cachedConfig && !disableCache) return cachedConfig;
714
716
  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';
@@ -727,15 +729,15 @@ var processConfig = function processConfig() {
727
729
 
728
730
  var envAppUrl = isProd ? appConfig.env.production.url : developmentAppUrl;
729
731
  var appUrl = getOrThrow(function () {
730
- return new _URL__default['default'](envAppUrl);
732
+ return new _URL__default["default"](envAppUrl);
731
733
  }, "Invalid application URL: \"".concat(envAppUrl, "\"")); // Use `||` instead of `??` to include empty string values.
732
734
 
733
735
  var envCdnUrl = isProd ? appConfig.env.production.cdnUrl || appUrl.href : developmentAppUrl;
734
736
  var cdnUrl = getOrThrow(function () {
735
- return new _URL__default['default'](envCdnUrl);
737
+ return new _URL__default["default"](envCdnUrl);
736
738
  }, "Invalid application CDN URL: \"".concat(envCdnUrl, "\""));
737
739
  var mcApiUrl = getOrThrow(function () {
738
- return new _URL__default['default']( // Use `||` instead of `??` to include empty string values.
740
+ return new _URL__default["default"]( // Use `||` instead of `??` to include empty string values.
739
741
  appConfig.mcApiUrl || mapCloudIdentifierToApiUrl(appConfig.cloudIdentifier));
740
742
  }, "Invalid MC API URL: \"".concat(appConfig.mcApiUrl, "\"")); // The real application ID is only used in production.
741
743
  // In development, we prefix the entry point with the "__local" prefix.
@@ -749,7 +751,7 @@ var processConfig = function processConfig() {
749
751
  if (appConfig.env.production.applicationId) {
750
752
  var _context;
751
753
 
752
- applicationId = _concatInstanceProperty__default['default'](_context = "".concat(appConfig.env.production.applicationId, ":")).call(_context, appConfig.entryPointUriPath);
754
+ applicationId = _concatInstanceProperty__default["default"](_context = "".concat(appConfig.env.production.applicationId, ":")).call(_context, appConfig.entryPointUriPath);
753
755
  } else {
754
756
  // As long as we don't require the application ID in production, we should
755
757
  // fall back to unset the value.
@@ -758,8 +760,10 @@ var processConfig = function processConfig() {
758
760
  }
759
761
 
760
762
  var developmentConfig = isProd ? undefined : omitDevConfigIfEmpty({
761
- oidc: isOidcForDevelopmentEnabled ? omitEmpty__default['default']({
762
- authorizeUrl: [mcApiUrl.protocol, '//', mcApiUrl.host.replace('mc-api', 'mc')].join(''),
763
+ oidc: isOidcForDevelopmentEnabled ? omitEmpty__default["default"]({
764
+ authorizeUrl: [// In case the MC API url points to localhost, we need to point
765
+ // to a local running dev login page to handle the workflow properly.
766
+ mcApiUrl.hostname === 'localhost' ? mcApiUrl.origin.replace(mcApiUrl.port, String(developmentPort)) : mcApiUrl.origin.replace('mc-api', 'mc'), '/login/authorize'].join(''),
763
767
  initialProjectKey: (_appConfig$env$develo = appConfig.env.development) === null || _appConfig$env$develo === void 0 ? void 0 : _appConfig$env$develo.initialProjectKey,
764
768
  teamId: (_appConfig$env$develo2 = appConfig.env.development) === null || _appConfig$env$develo2 === void 0 ? void 0 : _appConfig$env$develo2.teamId,
765
769
  oAuthScopes: appConfig.oAuthScopes
@@ -769,7 +773,7 @@ var processConfig = function processConfig() {
769
773
  accountLinks: appConfig.accountLinks
770
774
  });
771
775
  cachedConfig = {
772
- env: _objectSpread(_objectSpread(_objectSpread({}, omitEmpty__default['default'](additionalAppEnv)), {}, {
776
+ env: _objectSpread(_objectSpread(_objectSpread({}, omitEmpty__default["default"](additionalAppEnv)), {}, {
773
777
  // TODO: how else should we provide the app identifier?
774
778
  applicationId: applicationId,
775
779
  applicationName: appConfig.name,
@@ -787,7 +791,7 @@ var processConfig = function processConfig() {
787
791
  }),
788
792
  headers: _objectSpread(_objectSpread({}, appConfig.headers), {}, {
789
793
  csp: _objectSpread(_objectSpread({}, (_appConfig$headers = appConfig.headers) === null || _appConfig$headers === void 0 ? void 0 : _appConfig$headers.csp), {}, {
790
- 'connect-src': getUniqueValues((_appConfig$headers2 = appConfig.headers) === null || _appConfig$headers2 === void 0 ? void 0 : _appConfig$headers2.csp['connect-src'], _concatInstanceProperty__default['default'](_context2 = [mcApiUrl.origin]).call(_context2, isProd ? [appUrl.href] : [])),
794
+ 'connect-src': getUniqueValues((_appConfig$headers2 = appConfig.headers) === null || _appConfig$headers2 === void 0 ? void 0 : _appConfig$headers2.csp['connect-src'], _concatInstanceProperty__default["default"](_context2 = [mcApiUrl.origin]).call(_context2, isProd ? [appUrl.href] : [])),
791
795
  'script-src': getUniqueValues((_appConfig$headers3 = appConfig.headers) === null || _appConfig$headers3 === void 0 ? void 0 : _appConfig$headers3.csp['script-src'], isProd ? [appUrl.href, cdnUrl.href] : []),
792
796
  'style-src': getUniqueValues((_appConfig$headers4 = appConfig.headers) === null || _appConfig$headers4 === void 0 ? void 0 : _appConfig$headers4.csp['style-src'], isProd ? [appUrl.href, cdnUrl.href] : [])
793
797
  })
@@ -59,9 +59,9 @@ var uniq__default = /*#__PURE__*/_interopDefault(uniq);
59
59
  var _trimInstanceProperty__default = /*#__PURE__*/_interopDefault(_trimInstanceProperty);
60
60
  var _JSON$stringify__default = /*#__PURE__*/_interopDefault(_JSON$stringify);
61
61
 
62
- 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); }; }
62
+ 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); }; }
63
63
 
64
- function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !_Reflect$construct__default['default']) return false; if (_Reflect$construct__default['default'].sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(_Reflect$construct__default['default'](Boolean, [], function () {})); return true; } catch (e) { return false; } }
64
+ function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !_Reflect$construct__default["default"]) return false; if (_Reflect$construct__default["default"].sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(_Reflect$construct__default["default"](Boolean, [], function () {})); return true; } catch (e) { return false; } }
65
65
 
66
66
  var MissingOrInvalidConfigError = /*#__PURE__*/function (_Error) {
67
67
  _inherits(MissingOrInvalidConfigError, _Error);
@@ -75,7 +75,7 @@ var MissingOrInvalidConfigError = /*#__PURE__*/function (_Error) {
75
75
 
76
76
  _this = _super.call(this, message);
77
77
 
78
- _Object$defineProperty__default['default'](_assertThisInitialized(_this), 'name', {
78
+ _Object$defineProperty__default["default"](_assertThisInitialized(_this), 'name', {
79
79
  value: 'MissingOrInvalidConfigError'
80
80
  });
81
81
 
@@ -88,26 +88,26 @@ var MissingOrInvalidConfigError = /*#__PURE__*/function (_Error) {
88
88
  // for instance in respect to both source files and dist files.
89
89
 
90
90
  var findPackageRootPath = function findPackageRootPath(dir) {
91
- var packageJsonPath = path__default['default'].join(dir, 'package.json');
91
+ var packageJsonPath = path__default["default"].join(dir, 'package.json');
92
92
 
93
- if (fs__default['default'].existsSync(packageJsonPath)) {
93
+ if (fs__default["default"].existsSync(packageJsonPath)) {
94
94
  return dir;
95
95
  }
96
96
 
97
- var parentDir = path__default['default'].join(dir, '..');
97
+ var parentDir = path__default["default"].join(dir, '..');
98
98
  return findPackageRootPath(parentDir);
99
99
  };
100
100
 
101
101
  var loadJsModule = function loadJsModule(filePath) {
102
102
  var packageRootPath = findPackageRootPath( // Start from the parent folder
103
- path__default['default'].join(__dirname, '..')); // Load the JS module using a child process. This is primarly to avoid
103
+ path__default["default"].join(__dirname, '..')); // Load the JS module using a child process. This is primarly to avoid
104
104
  // unwanted behaviors using `@babel/register` in the main process.
105
105
  // The loader script does the actual `require` of the given `filePath`
106
106
  // and uses `@babel/register` to correctly parse and execute the file.
107
107
  // The "required module output" is then written into `stdout` and parsed
108
108
  // as JSON.
109
109
 
110
- var output = child_process.execFileSync(path__default['default'].join(packageRootPath, 'scripts/load-js-module.js'), [filePath], {
110
+ var output = child_process.execFileSync(path__default["default"].join(packageRootPath, 'scripts/load-js-module.js'), [filePath], {
111
111
  encoding: 'utf8'
112
112
  });
113
113
  return JSON.parse(output);
@@ -457,7 +457,7 @@ var schemaJson = {
457
457
  ]
458
458
  };
459
459
 
460
- var ajv = new Ajv__default['default']({
460
+ var ajv = new Ajv__default["default"]({
461
461
  strict: true,
462
462
  useDefaults: true
463
463
  });
@@ -468,17 +468,17 @@ var printErrors = function printErrors(errors) {
468
468
  return 'No errors';
469
469
  }
470
470
 
471
- return _mapInstanceProperty__default['default'](errors).call(errors, function (error) {
471
+ return _mapInstanceProperty__default["default"](errors).call(errors, function (error) {
472
472
  var _context, _context2, _context3;
473
473
 
474
- var baseMessage = _concatInstanceProperty__default['default'](_context = "".concat(error.instancePath, " ")).call(_context, error.message);
474
+ var baseMessage = _concatInstanceProperty__default["default"](_context = "".concat(error.instancePath, " ")).call(_context, error.message);
475
475
 
476
476
  switch (error.keyword) {
477
477
  case 'additionalProperties':
478
- return _concatInstanceProperty__default['default'](_context2 = "".concat(baseMessage, ": ")).call(_context2, error.params.additionalProperty);
478
+ return _concatInstanceProperty__default["default"](_context2 = "".concat(baseMessage, ": ")).call(_context2, error.params.additionalProperty);
479
479
 
480
480
  case 'enum':
481
- return _concatInstanceProperty__default['default'](_context3 = "".concat(baseMessage, ": ")).call(_context3, error.params.allowedValues.toString());
481
+ return _concatInstanceProperty__default["default"](_context3 = "".concat(baseMessage, ": ")).call(_context3, error.params.allowedValues.toString());
482
482
 
483
483
  default:
484
484
  return baseMessage;
@@ -531,7 +531,7 @@ var mapCloudIdentifierToApiUrl = function mapCloudIdentifierToApiUrl(key) {
531
531
  default:
532
532
  // We would probably never get to this point, as the JSON schema validation
533
533
  // kicks in before.
534
- throw new Error(_concatInstanceProperty__default['default'](_context = "Unknown cloud identifier \"".concat(key, "\". Supported values: ")).call(_context, _Object$values__default['default'](CLOUD_IDENTIFIERS).toString()));
534
+ throw new Error(_concatInstanceProperty__default["default"](_context = "Unknown cloud identifier \"".concat(key, "\". Supported values: ")).call(_context, _Object$values__default["default"](CLOUD_IDENTIFIERS).toString()));
535
535
  }
536
536
  };
537
537
 
@@ -540,7 +540,7 @@ var getUniqueValues = function getUniqueValues() {
540
540
 
541
541
  var initialValues = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
542
542
  var additionalValues = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
543
- return uniq__default['default'](_concatInstanceProperty__default['default'](_context2 = []).call(_context2, _toConsumableArray(initialValues), _toConsumableArray(additionalValues)));
543
+ return uniq__default["default"](_concatInstanceProperty__default["default"](_context2 = []).call(_context2, _toConsumableArray(initialValues), _toConsumableArray(additionalValues)));
544
544
  };
545
545
 
546
546
  var nonProductionEnvironment = ['development', 'test'];
@@ -550,7 +550,7 @@ var getIsProd = function getIsProd(env) {
550
550
  // a production environment unless it's one of `development` or `test`.
551
551
  // This allows to use for example the `staging` value, which from the
552
552
  // application perspective is still considered a production environment.
553
- env.MC_APP_ENV ? !_includesInstanceProperty__default['default'](nonProductionEnvironment).call(nonProductionEnvironment, env.MC_APP_ENV) : env.NODE_ENV === 'production'
553
+ env.MC_APP_ENV ? !_includesInstanceProperty__default["default"](nonProductionEnvironment).call(nonProductionEnvironment, env.MC_APP_ENV) : env.NODE_ENV === 'production'
554
554
  );
555
555
  };
556
556
 
@@ -605,7 +605,7 @@ var substituteEnvVariablePlaceholder = function substituteEnvVariablePlaceholder
605
605
  if (!hasEnvField) {
606
606
  var _context;
607
607
 
608
- throw new Error(_concatInstanceProperty__default['default'](_context = "Missing environment variable '".concat(requestedEnvVar, "' specified in config as 'env:")).call(_context, requestedEnvVar, "'."));
608
+ throw new Error(_concatInstanceProperty__default["default"](_context = "Missing environment variable '".concat(requestedEnvVar, "' specified in config as 'env:")).call(_context, requestedEnvVar, "'."));
609
609
  }
610
610
 
611
611
  var escapedMatchedString = matchedString.replace(/[${}:]/g, '\\$&');
@@ -629,7 +629,7 @@ var substituteIntlVariablePlaceholder = function substituteIntlVariablePlacehold
629
629
  if (!hasIntlMessage) {
630
630
  var _context2, _context3;
631
631
 
632
- throw new Error(_concatInstanceProperty__default['default'](_context2 = _concatInstanceProperty__default['default'](_context3 = "Missing message key '".concat(requestedIntlMessageId, "' specified in config as 'intl:")).call(_context3, locale, ":")).call(_context2, requestedIntlMessageId, "'."));
632
+ throw new Error(_concatInstanceProperty__default["default"](_context2 = _concatInstanceProperty__default["default"](_context3 = "Missing message key '".concat(requestedIntlMessageId, "' specified in config as 'intl:")).call(_context3, locale, ":")).call(_context2, requestedIntlMessageId, "'."));
633
633
  }
634
634
 
635
635
  var escapedMatchedString = matchedString.replace(/[${}:]/g, '\\$&');
@@ -641,7 +641,7 @@ var substituteFilePathVariablePlaceholder = function substituteFilePathVariableP
641
641
  _valueOfPlaceholder$s6 = _slicedToArray(_valueOfPlaceholder$s5, 2),
642
642
  filePathOrModule = _valueOfPlaceholder$s6[1];
643
643
 
644
- var content = fs__default['default'].readFileSync(require.resolve(filePathOrModule, {
644
+ var content = fs__default["default"].readFileSync(require.resolve(filePathOrModule, {
645
645
  // Relative paths should be resolved from the application folder.
646
646
  paths: [meta.applicationPath]
647
647
  }), {
@@ -653,12 +653,12 @@ var substituteFilePathVariablePlaceholder = function substituteFilePathVariableP
653
653
 
654
654
  var getValueOfPlaceholder = function getValueOfPlaceholder(valueWithPlaceholder) {
655
655
  return valueWithPlaceholder.replace(variableSyntax, function (_match, varName) {
656
- return _trimInstanceProperty__default['default'](varName).call(varName);
656
+ return _trimInstanceProperty__default["default"](varName).call(varName);
657
657
  }).replace(/\s/g, '');
658
658
  };
659
659
 
660
660
  var substituteVariablePlaceholders = function substituteVariablePlaceholders(config, meta) {
661
- return JSON.parse(_JSON$stringify__default['default'](config), function (_key, value) {
661
+ return JSON.parse(_JSON$stringify__default["default"](config), function (_key, value) {
662
662
  // Only strings are allowed
663
663
  var substitutedValue = value;
664
664
 
@@ -666,7 +666,7 @@ var substituteVariablePlaceholders = function substituteVariablePlaceholders(con
666
666
  var matchResult = substitutedValue.match(variableSyntax);
667
667
 
668
668
  if (matchResult) {
669
- _forEachInstanceProperty__default['default'](matchResult).call(matchResult, function (matchedString) {
669
+ _forEachInstanceProperty__default["default"](matchResult).call(matchResult, function (matchedString) {
670
670
  var valueOfPlaceholder = getValueOfPlaceholder(matchedString);
671
671
 
672
672
  if (isEnvVariablePlaceholder(valueOfPlaceholder)) {
@@ -684,10 +684,12 @@ var substituteVariablePlaceholders = function substituteVariablePlaceholders(con
684
684
  });
685
685
  };
686
686
 
687
- function ownKeys(object, enumerableOnly) { var keys = _Object$keys__default['default'](object); if (_Object$getOwnPropertySymbols__default['default']) { var symbols = _Object$getOwnPropertySymbols__default['default'](object); if (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; }
687
+ function ownKeys(object, enumerableOnly) { var keys = _Object$keys__default["default"](object); if (_Object$getOwnPropertySymbols__default["default"]) { var symbols = _Object$getOwnPropertySymbols__default["default"](object); if (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; }
688
688
 
689
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { var _context3; _forEachInstanceProperty__default['default'](_context3 = ownKeys(Object(source), true)).call(_context3, function (key) { _defineProperty(target, key, source[key]); }); } else if (_Object$getOwnPropertyDescriptors__default['default']) { _Object$defineProperties__default['default'](target, _Object$getOwnPropertyDescriptors__default['default'](source)); } else { var _context4; _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; }
690
- var developmentAppUrl = 'http://localhost:3001';
689
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { var _context3; _forEachInstanceProperty__default["default"](_context3 = ownKeys(Object(source), true)).call(_context3, function (key) { _defineProperty(target, key, source[key]); }); } else if (_Object$getOwnPropertyDescriptors__default["default"]) { _Object$defineProperties__default["default"](target, _Object$getOwnPropertyDescriptors__default["default"](source)); } else { var _context4; _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; }
690
+ // TODO: make it configurable.
691
+ var developmentPort = 3001;
692
+ var developmentAppUrl = "http://localhost:".concat(developmentPort);
691
693
 
692
694
  var omitDevConfigIfEmpty = function omitDevConfigIfEmpty(devConfig) {
693
695
  if ( // @ts-expect-error: the `accountLinks` is not explicitly typed as it's only used by the account app.
@@ -708,7 +710,7 @@ var processConfig = function processConfig() {
708
710
  _ref$processEnv = _ref.processEnv,
709
711
  processEnv = _ref$processEnv === void 0 ? process.env : _ref$processEnv,
710
712
  _ref$applicationPath = _ref.applicationPath,
711
- applicationPath = _ref$applicationPath === void 0 ? fs__default['default'].realpathSync(process.cwd()) : _ref$applicationPath;
713
+ applicationPath = _ref$applicationPath === void 0 ? fs__default["default"].realpathSync(process.cwd()) : _ref$applicationPath;
712
714
 
713
715
  if (cachedConfig && !disableCache) return cachedConfig;
714
716
  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';
@@ -727,15 +729,15 @@ var processConfig = function processConfig() {
727
729
 
728
730
  var envAppUrl = isProd ? appConfig.env.production.url : developmentAppUrl;
729
731
  var appUrl = getOrThrow(function () {
730
- return new _URL__default['default'](envAppUrl);
732
+ return new _URL__default["default"](envAppUrl);
731
733
  }, "Invalid application URL: \"".concat(envAppUrl, "\"")); // Use `||` instead of `??` to include empty string values.
732
734
 
733
735
  var envCdnUrl = isProd ? appConfig.env.production.cdnUrl || appUrl.href : developmentAppUrl;
734
736
  var cdnUrl = getOrThrow(function () {
735
- return new _URL__default['default'](envCdnUrl);
737
+ return new _URL__default["default"](envCdnUrl);
736
738
  }, "Invalid application CDN URL: \"".concat(envCdnUrl, "\""));
737
739
  var mcApiUrl = getOrThrow(function () {
738
- return new _URL__default['default']( // Use `||` instead of `??` to include empty string values.
740
+ return new _URL__default["default"]( // Use `||` instead of `??` to include empty string values.
739
741
  appConfig.mcApiUrl || mapCloudIdentifierToApiUrl(appConfig.cloudIdentifier));
740
742
  }, "Invalid MC API URL: \"".concat(appConfig.mcApiUrl, "\"")); // The real application ID is only used in production.
741
743
  // In development, we prefix the entry point with the "__local" prefix.
@@ -749,7 +751,7 @@ var processConfig = function processConfig() {
749
751
  if (appConfig.env.production.applicationId) {
750
752
  var _context;
751
753
 
752
- applicationId = _concatInstanceProperty__default['default'](_context = "".concat(appConfig.env.production.applicationId, ":")).call(_context, appConfig.entryPointUriPath);
754
+ applicationId = _concatInstanceProperty__default["default"](_context = "".concat(appConfig.env.production.applicationId, ":")).call(_context, appConfig.entryPointUriPath);
753
755
  } else {
754
756
  // As long as we don't require the application ID in production, we should
755
757
  // fall back to unset the value.
@@ -758,8 +760,10 @@ var processConfig = function processConfig() {
758
760
  }
759
761
 
760
762
  var developmentConfig = isProd ? undefined : omitDevConfigIfEmpty({
761
- oidc: isOidcForDevelopmentEnabled ? omitEmpty__default['default']({
762
- authorizeUrl: [mcApiUrl.protocol, '//', mcApiUrl.host.replace('mc-api', 'mc')].join(''),
763
+ oidc: isOidcForDevelopmentEnabled ? omitEmpty__default["default"]({
764
+ authorizeUrl: [// In case the MC API url points to localhost, we need to point
765
+ // to a local running dev login page to handle the workflow properly.
766
+ mcApiUrl.hostname === 'localhost' ? mcApiUrl.origin.replace(mcApiUrl.port, String(developmentPort)) : mcApiUrl.origin.replace('mc-api', 'mc'), '/login/authorize'].join(''),
763
767
  initialProjectKey: (_appConfig$env$develo = appConfig.env.development) === null || _appConfig$env$develo === void 0 ? void 0 : _appConfig$env$develo.initialProjectKey,
764
768
  teamId: (_appConfig$env$develo2 = appConfig.env.development) === null || _appConfig$env$develo2 === void 0 ? void 0 : _appConfig$env$develo2.teamId,
765
769
  oAuthScopes: appConfig.oAuthScopes
@@ -769,7 +773,7 @@ var processConfig = function processConfig() {
769
773
  accountLinks: appConfig.accountLinks
770
774
  });
771
775
  cachedConfig = {
772
- env: _objectSpread(_objectSpread(_objectSpread({}, omitEmpty__default['default'](additionalAppEnv)), {}, {
776
+ env: _objectSpread(_objectSpread(_objectSpread({}, omitEmpty__default["default"](additionalAppEnv)), {}, {
773
777
  // TODO: how else should we provide the app identifier?
774
778
  applicationId: applicationId,
775
779
  applicationName: appConfig.name,
@@ -787,7 +791,7 @@ var processConfig = function processConfig() {
787
791
  }),
788
792
  headers: _objectSpread(_objectSpread({}, appConfig.headers), {}, {
789
793
  csp: _objectSpread(_objectSpread({}, (_appConfig$headers = appConfig.headers) === null || _appConfig$headers === void 0 ? void 0 : _appConfig$headers.csp), {}, {
790
- 'connect-src': getUniqueValues((_appConfig$headers2 = appConfig.headers) === null || _appConfig$headers2 === void 0 ? void 0 : _appConfig$headers2.csp['connect-src'], _concatInstanceProperty__default['default'](_context2 = [mcApiUrl.origin]).call(_context2, isProd ? [appUrl.href] : [])),
794
+ 'connect-src': getUniqueValues((_appConfig$headers2 = appConfig.headers) === null || _appConfig$headers2 === void 0 ? void 0 : _appConfig$headers2.csp['connect-src'], _concatInstanceProperty__default["default"](_context2 = [mcApiUrl.origin]).call(_context2, isProd ? [appUrl.href] : [])),
791
795
  'script-src': getUniqueValues((_appConfig$headers3 = appConfig.headers) === null || _appConfig$headers3 === void 0 ? void 0 : _appConfig$headers3.csp['script-src'], isProd ? [appUrl.href, cdnUrl.href] : []),
792
796
  'style-src': getUniqueValues((_appConfig$headers4 = appConfig.headers) === null || _appConfig$headers4 === void 0 ? void 0 : _appConfig$headers4.csp['style-src'], isProd ? [appUrl.href, cdnUrl.href] : [])
793
797
  })
@@ -659,7 +659,9 @@ var substituteVariablePlaceholders = function substituteVariablePlaceholders(con
659
659
  function ownKeys(object, enumerableOnly) { var keys = _Object$keys(object); if (_Object$getOwnPropertySymbols) { var symbols = _Object$getOwnPropertySymbols(object); if (enumerableOnly) { symbols = _filterInstanceProperty(symbols).call(symbols, function (sym) { return _Object$getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
660
660
 
661
661
  function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { var _context3; _forEachInstanceProperty(_context3 = ownKeys(Object(source), true)).call(_context3, function (key) { _defineProperty(target, key, source[key]); }); } else if (_Object$getOwnPropertyDescriptors) { _Object$defineProperties(target, _Object$getOwnPropertyDescriptors(source)); } else { var _context4; _forEachInstanceProperty(_context4 = ownKeys(Object(source))).call(_context4, function (key) { _Object$defineProperty(target, key, _Object$getOwnPropertyDescriptor(source, key)); }); } } return target; }
662
- var developmentAppUrl = 'http://localhost:3001';
662
+ // TODO: make it configurable.
663
+ var developmentPort = 3001;
664
+ var developmentAppUrl = "http://localhost:".concat(developmentPort);
663
665
 
664
666
  var omitDevConfigIfEmpty = function omitDevConfigIfEmpty(devConfig) {
665
667
  if ( // @ts-expect-error: the `accountLinks` is not explicitly typed as it's only used by the account app.
@@ -731,7 +733,9 @@ var processConfig = function processConfig() {
731
733
 
732
734
  var developmentConfig = isProd ? undefined : omitDevConfigIfEmpty({
733
735
  oidc: isOidcForDevelopmentEnabled ? omitEmpty({
734
- authorizeUrl: [mcApiUrl.protocol, '//', mcApiUrl.host.replace('mc-api', 'mc')].join(''),
736
+ authorizeUrl: [// In case the MC API url points to localhost, we need to point
737
+ // to a local running dev login page to handle the workflow properly.
738
+ mcApiUrl.hostname === 'localhost' ? mcApiUrl.origin.replace(mcApiUrl.port, String(developmentPort)) : mcApiUrl.origin.replace('mc-api', 'mc'), '/login/authorize'].join(''),
735
739
  initialProjectKey: (_appConfig$env$develo = appConfig.env.development) === null || _appConfig$env$develo === void 0 ? void 0 : _appConfig$env$develo.initialProjectKey,
736
740
  teamId: (_appConfig$env$develo2 = appConfig.env.development) === null || _appConfig$env$develo2 === void 0 ? void 0 : _appConfig$env$develo2.teamId,
737
741
  oAuthScopes: appConfig.oAuthScopes
@@ -1,14 +1,14 @@
1
- export declare const CLOUD_IDENTIFIERS: {
2
- readonly GCP_AU: "gcp-au";
3
- readonly GCP_EU: "gcp-eu";
4
- readonly GCP_US: "gcp-us";
5
- readonly AWS_FRA: "aws-fra";
6
- readonly AWS_OHIO: "aws-ohio";
7
- };
8
- export declare const MC_API_URLS: {
9
- readonly GCP_AU: "https://mc-api.australia-southeast1.gcp.commercetools.com";
10
- readonly GCP_EU: "https://mc-api.europe-west1.gcp.commercetools.com";
11
- readonly GCP_US: "https://mc-api.us-central1.gcp.commercetools.com";
12
- readonly AWS_FRA: "https://mc-api.eu-central-1.aws.commercetools.com";
13
- readonly AWS_OHIO: "https://mc-api.us-east-2.aws.commercetools.com";
14
- };
1
+ export declare const CLOUD_IDENTIFIERS: {
2
+ readonly GCP_AU: "gcp-au";
3
+ readonly GCP_EU: "gcp-eu";
4
+ readonly GCP_US: "gcp-us";
5
+ readonly AWS_FRA: "aws-fra";
6
+ readonly AWS_OHIO: "aws-ohio";
7
+ };
8
+ export declare const MC_API_URLS: {
9
+ readonly GCP_AU: "https://mc-api.australia-southeast1.gcp.commercetools.com";
10
+ readonly GCP_EU: "https://mc-api.europe-west1.gcp.commercetools.com";
11
+ readonly GCP_US: "https://mc-api.us-central1.gcp.commercetools.com";
12
+ readonly AWS_FRA: "https://mc-api.eu-central-1.aws.commercetools.com";
13
+ readonly AWS_OHIO: "https://mc-api.us-east-2.aws.commercetools.com";
14
+ };
@@ -1,4 +1,4 @@
1
- declare class MissingOrInvalidConfigError extends Error {
2
- constructor(message: string);
3
- }
4
- export { MissingOrInvalidConfigError };
1
+ declare class MissingOrInvalidConfigError extends Error {
2
+ constructor(message: string);
3
+ }
4
+ export { MissingOrInvalidConfigError };
@@ -1,3 +1,3 @@
1
- export { default as processConfig } from './process-config';
2
- export * from './errors';
3
- export * from './types';
1
+ export { default as processConfig } from './process-config';
2
+ export * from './errors';
3
+ export * from './types';
@@ -1,3 +1,3 @@
1
- import type { JSONSchemaForCustomApplicationConfigurationFiles } from './schema';
2
- declare const loadConfig: (applicationPath: string) => JSONSchemaForCustomApplicationConfigurationFiles;
3
- export default loadConfig;
1
+ import type { JSONSchemaForCustomApplicationConfigurationFiles } from './schema';
2
+ declare const loadConfig: (applicationPath: string) => JSONSchemaForCustomApplicationConfigurationFiles;
3
+ export default loadConfig;
@@ -1,11 +1,11 @@
1
- /// <reference types="node" />
2
- import type { JSONSchemaForCustomApplicationConfigurationFiles } from './schema';
3
- import type { ApplicationRuntimeConfig } from './types';
4
- declare type ProcessConfigOptions = {
5
- disableCache?: boolean;
6
- processEnv?: NodeJS.ProcessEnv;
7
- applicationPath?: string;
8
- configJson?: JSONSchemaForCustomApplicationConfigurationFiles | undefined;
9
- };
10
- declare const processConfig: ({ disableCache, processEnv, applicationPath, }?: ProcessConfigOptions) => ApplicationRuntimeConfig;
11
- export default processConfig;
1
+ /// <reference types="node" />
2
+ import type { JSONSchemaForCustomApplicationConfigurationFiles } from './schema';
3
+ import type { ApplicationRuntimeConfig } from './types';
4
+ declare type ProcessConfigOptions = {
5
+ disableCache?: boolean;
6
+ processEnv?: NodeJS.ProcessEnv;
7
+ applicationPath?: string;
8
+ configJson?: JSONSchemaForCustomApplicationConfigurationFiles | undefined;
9
+ };
10
+ declare const processConfig: ({ disableCache, processEnv, applicationPath, }?: ProcessConfigOptions) => ApplicationRuntimeConfig;
11
+ export default processConfig;
@@ -1,63 +1,63 @@
1
- export declare type EnvVariablePlaceholder = string;
2
- export declare type CspDirective = string[];
3
- export interface JSONSchemaForCustomApplicationConfigurationFiles {
4
- name: string;
5
- entryPointUriPath: string;
6
- cloudIdentifier: (('gcp-au' | 'gcp-eu' | 'gcp-us' | 'aws-fra' | 'aws-ohio') | EnvVariablePlaceholder) & string;
7
- mcApiUrl?: string;
8
- oAuthScopes?: {
9
- view: string[];
10
- manage: string[];
11
- };
12
- env: {
13
- development?: {
14
- initialProjectKey?: string;
15
- teamId?: string;
16
- };
17
- production: {
18
- applicationId?: string;
19
- url: string;
20
- cdnUrl?: string;
21
- };
22
- };
23
- additionalEnv?: {
24
- [k: string]: unknown;
25
- };
26
- headers?: {
27
- csp: {
28
- 'connect-src': CspDirective;
29
- 'font-src'?: CspDirective;
30
- 'img-src'?: CspDirective;
31
- 'script-src'?: CspDirective;
32
- 'style-src'?: CspDirective;
33
- };
34
- featurePolicies?: {
35
- [k: string]: unknown;
36
- };
37
- permissionsPolicies?: {
38
- [k: string]: unknown;
39
- };
40
- strictTransportSecurity?: ('includeSubDomains' | 'preload')[];
41
- };
42
- menuLinks?: {
43
- icon: string;
44
- defaultLabel: string;
45
- labelAllLocales: {
46
- locale: 'en' | 'de' | 'es' | 'fr-FR' | 'zh-CN' | 'ja';
47
- value: string;
48
- }[];
49
- permissions: string[];
50
- submenuLinks: {
51
- uriPath: string;
52
- defaultLabel: string;
53
- labelAllLocales: {
54
- locale: 'en' | 'de' | 'es' | 'fr-FR' | 'zh-CN' | 'ja';
55
- value: string;
56
- }[];
57
- permissions: string[];
58
- [k: string]: unknown;
59
- }[];
60
- [k: string]: unknown;
61
- };
62
- [k: string]: unknown;
63
- }
1
+ export declare type EnvVariablePlaceholder = string;
2
+ export declare type CspDirective = string[];
3
+ export interface JSONSchemaForCustomApplicationConfigurationFiles {
4
+ name: string;
5
+ entryPointUriPath: string;
6
+ cloudIdentifier: (('gcp-au' | 'gcp-eu' | 'gcp-us' | 'aws-fra' | 'aws-ohio') | EnvVariablePlaceholder) & string;
7
+ mcApiUrl?: string;
8
+ oAuthScopes?: {
9
+ view: string[];
10
+ manage: string[];
11
+ };
12
+ env: {
13
+ development?: {
14
+ initialProjectKey?: string;
15
+ teamId?: string;
16
+ };
17
+ production: {
18
+ applicationId?: string;
19
+ url: string;
20
+ cdnUrl?: string;
21
+ };
22
+ };
23
+ additionalEnv?: {
24
+ [k: string]: unknown;
25
+ };
26
+ headers?: {
27
+ csp: {
28
+ 'connect-src': CspDirective;
29
+ 'font-src'?: CspDirective;
30
+ 'img-src'?: CspDirective;
31
+ 'script-src'?: CspDirective;
32
+ 'style-src'?: CspDirective;
33
+ };
34
+ featurePolicies?: {
35
+ [k: string]: unknown;
36
+ };
37
+ permissionsPolicies?: {
38
+ [k: string]: unknown;
39
+ };
40
+ strictTransportSecurity?: ('includeSubDomains' | 'preload')[];
41
+ };
42
+ menuLinks?: {
43
+ icon: string;
44
+ defaultLabel: string;
45
+ labelAllLocales: {
46
+ locale: 'en' | 'de' | 'es' | 'fr-FR' | 'zh-CN' | 'ja';
47
+ value: string;
48
+ }[];
49
+ permissions: string[];
50
+ submenuLinks: {
51
+ uriPath: string;
52
+ defaultLabel: string;
53
+ labelAllLocales: {
54
+ locale: 'en' | 'de' | 'es' | 'fr-FR' | 'zh-CN' | 'ja';
55
+ value: string;
56
+ }[];
57
+ permissions: string[];
58
+ [k: string]: unknown;
59
+ }[];
60
+ [k: string]: unknown;
61
+ };
62
+ [k: string]: unknown;
63
+ }
@@ -1,7 +1,7 @@
1
- /// <reference types="node" />
2
- declare type Meta = {
3
- processEnv: NodeJS.ProcessEnv;
4
- applicationPath: string;
5
- };
6
- declare const substituteVariablePlaceholders: <T>(config: T, meta: Meta) => T;
7
- export default substituteVariablePlaceholders;
1
+ /// <reference types="node" />
2
+ declare type Meta = {
3
+ processEnv: NodeJS.ProcessEnv;
4
+ applicationPath: string;
5
+ };
6
+ declare const substituteVariablePlaceholders: <T>(config: T, meta: Meta) => T;
7
+ export default substituteVariablePlaceholders;
@@ -1,9 +1,9 @@
1
- import type { ApplicationWindow } from '@commercetools-frontend/constants';
2
- import type { JSONSchemaForCustomApplicationConfigurationFiles } from './schema';
3
- import { CLOUD_IDENTIFIERS } from './constants';
4
- export declare type ConfigOptions = JSONSchemaForCustomApplicationConfigurationFiles;
5
- export declare type CloudIdentifier = typeof CLOUD_IDENTIFIERS[keyof typeof CLOUD_IDENTIFIERS];
6
- export declare type ApplicationRuntimeConfig = {
7
- env: ApplicationWindow['app'];
8
- headers: JSONSchemaForCustomApplicationConfigurationFiles['headers'];
9
- };
1
+ import type { ApplicationWindow } from '@commercetools-frontend/constants';
2
+ import type { JSONSchemaForCustomApplicationConfigurationFiles } from './schema';
3
+ import { CLOUD_IDENTIFIERS } from './constants';
4
+ export declare type ConfigOptions = JSONSchemaForCustomApplicationConfigurationFiles;
5
+ export declare type CloudIdentifier = typeof CLOUD_IDENTIFIERS[keyof typeof CLOUD_IDENTIFIERS];
6
+ export declare type ApplicationRuntimeConfig = {
7
+ env: ApplicationWindow['app'];
8
+ headers: JSONSchemaForCustomApplicationConfigurationFiles['headers'];
9
+ };
@@ -1,9 +1,9 @@
1
- /// <reference types="node" />
2
- /// <reference types="webpack-env" />
3
- import { CLOUD_IDENTIFIERS } from './constants';
4
- declare const mapCloudIdentifierToApiUrl: (key: typeof CLOUD_IDENTIFIERS[keyof typeof CLOUD_IDENTIFIERS]) => string;
5
- declare const getUniqueValues: (initialValues?: string[], additionalValues?: string[]) => string[];
6
- declare const getIsProd: (env: NodeJS.ProcessEnv) => boolean;
7
- declare const getOrThrow: <T>(fn: () => T, errorMessage: string) => T;
8
- declare const parseJsonFile: <T>(filePath: string) => T;
9
- export { mapCloudIdentifierToApiUrl, getUniqueValues, getIsProd, getOrThrow, parseJsonFile, };
1
+ /// <reference types="node" />
2
+ /// <reference types="webpack-env" />
3
+ import { CLOUD_IDENTIFIERS } from './constants';
4
+ declare const mapCloudIdentifierToApiUrl: (key: typeof CLOUD_IDENTIFIERS[keyof typeof CLOUD_IDENTIFIERS]) => string;
5
+ declare const getUniqueValues: (initialValues?: string[], additionalValues?: string[]) => string[];
6
+ declare const getIsProd: (env: NodeJS.ProcessEnv) => boolean;
7
+ declare const getOrThrow: <T>(fn: () => T, errorMessage: string) => T;
8
+ declare const parseJsonFile: <T>(filePath: string) => T;
9
+ export { mapCloudIdentifierToApiUrl, getUniqueValues, getIsProd, getOrThrow, parseJsonFile, };
@@ -1,3 +1,3 @@
1
- import type { JSONSchemaForCustomApplicationConfigurationFiles } from './schema';
2
- declare const validateConfig: (config: JSONSchemaForCustomApplicationConfigurationFiles) => void;
3
- export default validateConfig;
1
+ import type { JSONSchemaForCustomApplicationConfigurationFiles } from './schema';
2
+ declare const validateConfig: (config: JSONSchemaForCustomApplicationConfigurationFiles) => void;
3
+ export default validateConfig;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@commercetools-frontend/application-config",
3
- "version": "20.9.4",
3
+ "version": "20.10.6",
4
4
  "description": "Configuration utilities for building Custom Applications",
5
5
  "bugs": "https://github.com/commercetools/merchant-center-application-kit/issues",
6
6
  "repository": {
@@ -11,7 +11,6 @@
11
11
  "homepage": "https://docs.commercetools.com/custom-applications",
12
12
  "keywords": ["javascript", "frontend", "react", "toolkit", "config"],
13
13
  "license": "MIT",
14
- "private": false,
15
14
  "publishConfig": {
16
15
  "access": "public"
17
16
  },
@@ -26,23 +25,21 @@
26
25
  "README.md"
27
26
  ],
28
27
  "scripts": {
29
- "prepare": "./../../scripts/version.js replace",
30
- "prebuild": "yarn build:schema",
31
28
  "build:schema": "json2ts schema.json src/schema.ts --style.singleQuote --bannerComment '/* eslint-disable prettier/prettier */\n// This file was automatically generated by json-schema-to-typescript.\n// DO NOT MODIFY IT BY HAND. Instead, modify the source schema.json file.'"
32
29
  },
33
30
  "dependencies": {
34
- "@babel/register": "7.14.5",
35
- "@babel/runtime": "7.14.8",
36
- "@babel/runtime-corejs3": "7.14.9",
37
- "@commercetools-frontend/babel-preset-mc-app": "20.9.4",
38
- "ajv": "8.6.2",
39
- "core-js": "3.16.1",
40
- "cosmiconfig": "7.0.0",
31
+ "@babel/register": "7.15.3",
32
+ "@babel/runtime": "7.15.4",
33
+ "@babel/runtime-corejs3": "7.15.4",
34
+ "@commercetools-frontend/babel-preset-mc-app": "20.10.6",
35
+ "ajv": "8.6.3",
36
+ "core-js": "3.19.0",
37
+ "cosmiconfig": "7.0.1",
41
38
  "lodash": "4.17.21",
42
39
  "omit-empty-es": "1.1.3"
43
40
  },
44
41
  "devDependencies": {
45
- "json-schema-to-typescript": "10.1.4",
42
+ "json-schema-to-typescript": "10.1.5",
46
43
  "shelljs": "0.8.4"
47
44
  },
48
45
  "engines": {
@@ -1,387 +0,0 @@
1
- export declare const $schema: string;
2
- export declare const $id: string;
3
- export declare const title: string;
4
- export declare const type: string;
5
- export declare namespace definitions {
6
- namespace envVariablePlaceholder {
7
- const type_1: string;
8
- export { type_1 as type };
9
- export const pattern: string;
10
- }
11
- namespace cspDirective {
12
- const type_2: string;
13
- export { type_2 as type };
14
- export namespace items {
15
- const type_3: string;
16
- export { type_3 as type };
17
- }
18
- export const uniqueItems: boolean;
19
- }
20
- }
21
- export declare namespace properties {
22
- namespace name {
23
- export const description: string;
24
- const type_4: string;
25
- export { type_4 as type };
26
- }
27
- namespace entryPointUriPath {
28
- const description_1: string;
29
- export { description_1 as description };
30
- const type_5: string;
31
- export { type_5 as type };
32
- }
33
- namespace cloudIdentifier {
34
- const description_2: string;
35
- export { description_2 as description };
36
- const type_6: string;
37
- export { type_6 as type };
38
- export const oneOf: ({
39
- enum: string[];
40
- $ref?: undefined;
41
- } | {
42
- $ref: string;
43
- enum?: undefined;
44
- })[];
45
- }
46
- namespace mcApiUrl {
47
- const description_3: string;
48
- export { description_3 as description };
49
- const type_7: string;
50
- export { type_7 as type };
51
- }
52
- namespace oAuthScopes {
53
- const description_4: string;
54
- export { description_4 as description };
55
- const type_8: string;
56
- export { type_8 as type };
57
- export namespace properties_1 {
58
- namespace view {
59
- const description_5: string;
60
- export { description_5 as description };
61
- const type_9: string;
62
- export { type_9 as type };
63
- export namespace items_1 {
64
- const type_10: string;
65
- export { type_10 as type };
66
- const pattern_1: string;
67
- export { pattern_1 as pattern };
68
- }
69
- export { items_1 as items };
70
- const uniqueItems_1: boolean;
71
- export { uniqueItems_1 as uniqueItems };
72
- }
73
- namespace manage {
74
- const description_6: string;
75
- export { description_6 as description };
76
- const type_11: string;
77
- export { type_11 as type };
78
- export namespace items_2 {
79
- const type_12: string;
80
- export { type_12 as type };
81
- const pattern_2: string;
82
- export { pattern_2 as pattern };
83
- }
84
- export { items_2 as items };
85
- const uniqueItems_2: boolean;
86
- export { uniqueItems_2 as uniqueItems };
87
- }
88
- }
89
- export { properties_1 as properties };
90
- export const additionalProperties: boolean;
91
- export const required: string[];
92
- }
93
- namespace env {
94
- const description_7: string;
95
- export { description_7 as description };
96
- const type_13: string;
97
- export { type_13 as type };
98
- export namespace properties_2 {
99
- namespace development {
100
- const description_8: string;
101
- export { description_8 as description };
102
- const type_14: string;
103
- export { type_14 as type };
104
- export namespace properties_3 {
105
- namespace initialProjectKey {
106
- const description_9: string;
107
- export { description_9 as description };
108
- const type_15: string;
109
- export { type_15 as type };
110
- }
111
- namespace teamId {
112
- const description_10: string;
113
- export { description_10 as description };
114
- const type_16: string;
115
- export { type_16 as type };
116
- }
117
- }
118
- export { properties_3 as properties };
119
- const additionalProperties_1: boolean;
120
- export { additionalProperties_1 as additionalProperties };
121
- }
122
- namespace production {
123
- const description_11: string;
124
- export { description_11 as description };
125
- const type_17: string;
126
- export { type_17 as type };
127
- export namespace properties_4 {
128
- namespace applicationId {
129
- const description_12: string;
130
- export { description_12 as description };
131
- const type_18: string;
132
- export { type_18 as type };
133
- }
134
- namespace url {
135
- const description_13: string;
136
- export { description_13 as description };
137
- const type_19: string;
138
- export { type_19 as type };
139
- }
140
- namespace cdnUrl {
141
- const description_14: string;
142
- export { description_14 as description };
143
- const type_20: string;
144
- export { type_20 as type };
145
- }
146
- }
147
- export { properties_4 as properties };
148
- const additionalProperties_2: boolean;
149
- export { additionalProperties_2 as additionalProperties };
150
- const required_1: string[];
151
- export { required_1 as required };
152
- }
153
- }
154
- export { properties_2 as properties };
155
- const additionalProperties_3: boolean;
156
- export { additionalProperties_3 as additionalProperties };
157
- const required_2: string[];
158
- export { required_2 as required };
159
- }
160
- namespace additionalEnv {
161
- const description_15: string;
162
- export { description_15 as description };
163
- const type_21: string;
164
- export { type_21 as type };
165
- }
166
- namespace headers {
167
- const description_16: string;
168
- export { description_16 as description };
169
- const type_22: string;
170
- export { type_22 as type };
171
- export namespace properties_5 {
172
- namespace csp {
173
- const description_17: string;
174
- export { description_17 as description };
175
- const type_23: string;
176
- export { type_23 as type };
177
- const properties_6: {
178
- "connect-src": {
179
- $ref: string;
180
- };
181
- "font-src": {
182
- $ref: string;
183
- };
184
- "img-src": {
185
- $ref: string;
186
- };
187
- "script-src": {
188
- $ref: string;
189
- };
190
- "style-src": {
191
- $ref: string;
192
- };
193
- };
194
- export { properties_6 as properties };
195
- const additionalProperties_4: boolean;
196
- export { additionalProperties_4 as additionalProperties };
197
- const required_3: string[];
198
- export { required_3 as required };
199
- }
200
- namespace featurePolicies {
201
- const description_18: string;
202
- export { description_18 as description };
203
- const type_24: string;
204
- export { type_24 as type };
205
- }
206
- namespace permissionsPolicies {
207
- const description_19: string;
208
- export { description_19 as description };
209
- const type_25: string;
210
- export { type_25 as type };
211
- }
212
- namespace strictTransportSecurity {
213
- const description_20: string;
214
- export { description_20 as description };
215
- const type_26: string;
216
- export { type_26 as type };
217
- export namespace items_3 {
218
- const _enum: string[];
219
- export { _enum as enum };
220
- }
221
- export { items_3 as items };
222
- const uniqueItems_3: boolean;
223
- export { uniqueItems_3 as uniqueItems };
224
- }
225
- }
226
- export { properties_5 as properties };
227
- const additionalProperties_5: boolean;
228
- export { additionalProperties_5 as additionalProperties };
229
- const required_4: string[];
230
- export { required_4 as required };
231
- }
232
- namespace menuLinks {
233
- const description_21: string;
234
- export { description_21 as description };
235
- const type_27: string;
236
- export { type_27 as type };
237
- export namespace properties_7 {
238
- namespace icon {
239
- const description_22: string;
240
- export { description_22 as description };
241
- const type_28: string;
242
- export { type_28 as type };
243
- }
244
- namespace defaultLabel {
245
- const description_23: string;
246
- export { description_23 as description };
247
- const type_29: string;
248
- export { type_29 as type };
249
- }
250
- namespace labelAllLocales {
251
- const description_24: string;
252
- export { description_24 as description };
253
- const type_30: string;
254
- export { type_30 as type };
255
- const _default: never[];
256
- export { _default as default };
257
- export namespace items_4 {
258
- const type_31: string;
259
- export { type_31 as type };
260
- export namespace properties_8 {
261
- namespace locale {
262
- const type_32: string;
263
- export { type_32 as type };
264
- const _enum_1: string[];
265
- export { _enum_1 as enum };
266
- }
267
- namespace value {
268
- const description_25: string;
269
- export { description_25 as description };
270
- const type_33: string;
271
- export { type_33 as type };
272
- }
273
- }
274
- export { properties_8 as properties };
275
- const additionalProperties_6: boolean;
276
- export { additionalProperties_6 as additionalProperties };
277
- const required_5: string[];
278
- export { required_5 as required };
279
- }
280
- export { items_4 as items };
281
- }
282
- namespace permissions {
283
- const description_26: string;
284
- export { description_26 as description };
285
- const type_34: string;
286
- export { type_34 as type };
287
- const _default_1: never[];
288
- export { _default_1 as default };
289
- export namespace items_5 {
290
- const type_35: string;
291
- export { type_35 as type };
292
- }
293
- export { items_5 as items };
294
- }
295
- namespace submenuLinks {
296
- const description_27: string;
297
- export { description_27 as description };
298
- const _default_2: never[];
299
- export { _default_2 as default };
300
- const type_36: string;
301
- export { type_36 as type };
302
- export namespace items_6 {
303
- const type_37: string;
304
- export { type_37 as type };
305
- export namespace properties_9 {
306
- export namespace uriPath {
307
- const description_28: string;
308
- export { description_28 as description };
309
- const type_38: string;
310
- export { type_38 as type };
311
- }
312
- export namespace defaultLabel_1 {
313
- const description_29: string;
314
- export { description_29 as description };
315
- const type_39: string;
316
- export { type_39 as type };
317
- }
318
- export { defaultLabel_1 as defaultLabel };
319
- export namespace labelAllLocales_1 {
320
- const description_30: string;
321
- export { description_30 as description };
322
- const type_40: string;
323
- export { type_40 as type };
324
- const _default_3: never[];
325
- export { _default_3 as default };
326
- export namespace items_7 {
327
- const type_41: string;
328
- export { type_41 as type };
329
- export namespace properties_10 {
330
- export namespace locale_1 {
331
- const type_42: string;
332
- export { type_42 as type };
333
- const _enum_2: string[];
334
- export { _enum_2 as enum };
335
- }
336
- export { locale_1 as locale };
337
- export namespace value_1 {
338
- const description_31: string;
339
- export { description_31 as description };
340
- const type_43: string;
341
- export { type_43 as type };
342
- }
343
- export { value_1 as value };
344
- }
345
- export { properties_10 as properties };
346
- const additionalProperties_7: boolean;
347
- export { additionalProperties_7 as additionalProperties };
348
- const required_6: string[];
349
- export { required_6 as required };
350
- }
351
- export { items_7 as items };
352
- }
353
- export { labelAllLocales_1 as labelAllLocales };
354
- export namespace permissions_1 {
355
- const description_32: string;
356
- export { description_32 as description };
357
- const type_44: string;
358
- export { type_44 as type };
359
- const _default_4: never[];
360
- export { _default_4 as default };
361
- export namespace items_8 {
362
- const type_45: string;
363
- export { type_45 as type };
364
- }
365
- export { items_8 as items };
366
- }
367
- export { permissions_1 as permissions };
368
- }
369
- export { properties_9 as properties };
370
- const additionalProperties_8: boolean;
371
- export { additionalProperties_8 as additionalProperties };
372
- const required_7: string[];
373
- export { required_7 as required };
374
- }
375
- export { items_6 as items };
376
- }
377
- }
378
- export { properties_7 as properties };
379
- const additionalProperties_9: boolean;
380
- export { additionalProperties_9 as additionalProperties };
381
- const required_8: string[];
382
- export { required_8 as required };
383
- }
384
- }
385
- declare const additionalProperties_10: boolean;
386
- declare const required_9: string[];
387
- export { additionalProperties_10 as additionalProperties, required_9 as required };