@commercetools-frontend/application-config 25.0.0 → 25.1.0

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.
@@ -12,8 +12,8 @@ var _Object$defineProperties = require('@babel/runtime-corejs3/core-js-stable/ob
12
12
  var _Object$defineProperty = require('@babel/runtime-corejs3/core-js-stable/object/define-property');
13
13
  var _defineProperty = require('@babel/runtime-corejs3/helpers/defineProperty');
14
14
  var _includesInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/includes');
15
- var _concatInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/concat');
16
15
  var _URL = require('@babel/runtime-corejs3/core-js-stable/url');
16
+ var _concatInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/concat');
17
17
  var fs$1 = require('node:fs');
18
18
  var path = require('node:path');
19
19
  var omitEmpty = require('omit-empty-es');
@@ -35,7 +35,8 @@ var _trimInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/insta
35
35
  var _JSON$stringify = require('@babel/runtime-corejs3/core-js-stable/json/stringify');
36
36
  var _startsWithInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/starts-with');
37
37
  var _reduceInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/reduce');
38
- var formatters = require('./formatters-a09672cf.cjs.dev.js');
38
+ var _bindInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/bind');
39
+ var formatters = require('./formatters-a76b45b9.cjs.dev.js');
39
40
  var _Set = require('@babel/runtime-corejs3/core-js-stable/set');
40
41
  var _Array$isArray = require('@babel/runtime-corejs3/core-js-stable/array/is-array');
41
42
  var Ajv = require('ajv');
@@ -57,8 +58,8 @@ var _Object$getOwnPropertyDescriptors__default = /*#__PURE__*/_interopDefault(_O
57
58
  var _Object$defineProperties__default = /*#__PURE__*/_interopDefault(_Object$defineProperties);
58
59
  var _Object$defineProperty__default = /*#__PURE__*/_interopDefault(_Object$defineProperty);
59
60
  var _includesInstanceProperty__default = /*#__PURE__*/_interopDefault(_includesInstanceProperty);
60
- var _concatInstanceProperty__default = /*#__PURE__*/_interopDefault(_concatInstanceProperty);
61
61
  var _URL__default = /*#__PURE__*/_interopDefault(_URL);
62
+ var _concatInstanceProperty__default = /*#__PURE__*/_interopDefault(_concatInstanceProperty);
62
63
  var fs__default$1 = /*#__PURE__*/_interopDefault(fs$1);
63
64
  var path__default = /*#__PURE__*/_interopDefault(path);
64
65
  var omitEmpty__default = /*#__PURE__*/_interopDefault(omitEmpty);
@@ -70,6 +71,7 @@ var _trimInstanceProperty__default = /*#__PURE__*/_interopDefault(_trimInstanceP
70
71
  var _JSON$stringify__default = /*#__PURE__*/_interopDefault(_JSON$stringify);
71
72
  var _startsWithInstanceProperty__default = /*#__PURE__*/_interopDefault(_startsWithInstanceProperty);
72
73
  var _reduceInstanceProperty__default = /*#__PURE__*/_interopDefault(_reduceInstanceProperty);
74
+ var _bindInstanceProperty__default = /*#__PURE__*/_interopDefault(_bindInstanceProperty);
73
75
  var _Set__default = /*#__PURE__*/_interopDefault(_Set);
74
76
  var _Array$isArray__default = /*#__PURE__*/_interopDefault(_Array$isArray);
75
77
  var Ajv__default = /*#__PURE__*/_interopDefault(Ajv);
@@ -146,11 +148,10 @@ const isDynamicAwaitSupported = () => {
146
148
  const isEsmModule = async cwd => {
147
149
  const packagePath = path__default["default"].join(cwd, 'package.json');
148
150
  try {
149
- var _JSON$parse;
150
151
  const packageJSON = await fs__default["default"].readFile(packagePath, {
151
152
  encoding: 'utf-8'
152
153
  });
153
- return ((_JSON$parse = JSON.parse(packageJSON)) === null || _JSON$parse === void 0 ? void 0 : _JSON$parse.type) === 'module';
154
+ return JSON.parse(packageJSON)?.type === 'module';
154
155
  } catch (error) {
155
156
  return false;
156
157
  }
@@ -170,7 +171,7 @@ const createExplorerFor = async configFileName => {
170
171
  const loaders = isDynamicAwaitSupported() || (await isEsmModule(process.cwd())) ? cosmiconfig.defaultLoaders : cosmiconfig.defaultLoadersSync;
171
172
  return cosmiconfig.cosmiconfig(configFileName, {
172
173
  searchStrategy: 'project',
173
- searchPlaces: ["".concat(configFileName, ".js"), "".concat(configFileName, ".cjs"), "".concat(configFileName, ".mjs"), "".concat(configFileName, ".ts")],
174
+ searchPlaces: [`${configFileName}.js`, `${configFileName}.cjs`, `${configFileName}.mjs`, `${configFileName}.ts`],
174
175
  loaders: {
175
176
  '.js': loaders['.js'],
176
177
  '.cjs': loaders['.cjs'],
@@ -185,9 +186,9 @@ const getConfigPath = async () => {
185
186
  const customApplicationConfigFile = await customApplicationExplorer.search();
186
187
  const customViewConfigFile = await customViewExplorer.search();
187
188
  if (!customApplicationConfigFile && !customViewConfigFile) {
188
- throw new Error("Missing or invalid configuration file.");
189
+ throw new Error(`Missing or invalid configuration file.`);
189
190
  }
190
- return (customApplicationConfigFile === null || customApplicationConfigFile === void 0 ? void 0 : customApplicationConfigFile.filepath) || (customViewConfigFile === null || customViewConfigFile === void 0 ? void 0 : customViewConfigFile.filepath);
191
+ return customApplicationConfigFile?.filepath || customViewConfigFile?.filepath;
191
192
  };
192
193
  const loadConfig = async applicationPath => {
193
194
  const customApplicationExplorer = await createExplorerFor('custom-application-config');
@@ -195,10 +196,10 @@ const loadConfig = async applicationPath => {
195
196
  const customApplicationConfigFile = await customApplicationExplorer.search(applicationPath);
196
197
  const customViewConfigFile = await customViewExplorer.search(applicationPath);
197
198
  if ((!customApplicationConfigFile || !customApplicationConfigFile.config) && (!customViewConfigFile || !customViewConfigFile.config)) {
198
- throw new MissingOrInvalidConfigError("Missing or invalid configuration file.");
199
+ throw new MissingOrInvalidConfigError(`Missing or invalid configuration file.`);
199
200
  }
200
201
  if (customApplicationConfigFile && customViewConfigFile) {
201
- throw new MissingOrInvalidConfigError("Found configuration files for both Custom Application and Custom View. Please remove one of them.");
202
+ throw new MissingOrInvalidConfigError(`Found configuration files for both Custom Application and Custom View. Please remove one of them.`);
202
203
  }
203
204
  return customViewConfigFile || customApplicationConfigFile;
204
205
  };
@@ -227,37 +228,35 @@ Boolean(valueOfEnvConfig.match(variableSyntax));
227
228
  const isEnvVariablePlaceholder = valueOfPlaceholder => Boolean(valueOfPlaceholder.match(envRefSyntax));
228
229
  const isIntlVariablePlaceholder = valueOfPlaceholder => Boolean(valueOfPlaceholder.match(intlRefSyntax));
229
230
  const isFilePathVariablePlaceholder = valueOfPlaceholder => Boolean(valueOfPlaceholder.match(filePathRefSyntax));
230
- const isStructuredJson = message => (message === null || message === void 0 ? void 0 : message.string) !== undefined;
231
+ const isStructuredJson = message => message?.string !== undefined;
231
232
  const substituteEnvVariablePlaceholder = (valueOfPlaceholder, matchedString, valueOfEnvConfig, loadingOptions) => {
232
233
  const _valueOfPlaceholder$s = valueOfPlaceholder.split(':'),
233
234
  _valueOfPlaceholder$s2 = _slicedToArray(_valueOfPlaceholder$s, 2),
234
235
  requestedEnvVar = _valueOfPlaceholder$s2[1];
235
236
  const hasEnvField = loadingOptions.processEnv.hasOwnProperty(requestedEnvVar);
236
237
  if (!hasEnvField) {
237
- var _context;
238
- throw new Error(_concatInstanceProperty__default["default"](_context = "Missing environment variable '".concat(requestedEnvVar, "' specified in config as 'env:")).call(_context, requestedEnvVar, "'."));
238
+ throw new Error(`Missing environment variable '${requestedEnvVar}' specified in config as 'env:${requestedEnvVar}'.`);
239
239
  }
240
240
  const escapedMatchedString = matchedString.replace(/[${}:]/g, '\\$&');
241
- return valueOfEnvConfig.replace(new RegExp("(".concat(escapedMatchedString, ")+"), 'g'), loadingOptions.processEnv[requestedEnvVar]);
241
+ return valueOfEnvConfig.replace(new RegExp(`(${escapedMatchedString})+`, 'g'), loadingOptions.processEnv[requestedEnvVar]);
242
242
  };
243
243
  const substituteIntlVariablePlaceholder = (valueOfPlaceholder, matchedString, valueOfEnvConfig, loadingOptions) => {
244
244
  const _valueOfPlaceholder$s3 = valueOfPlaceholder.split(':'),
245
245
  _valueOfPlaceholder$s4 = _slicedToArray(_valueOfPlaceholder$s3, 3),
246
246
  locale = _valueOfPlaceholder$s4[1],
247
247
  requestedIntlMessageId = _valueOfPlaceholder$s4[2];
248
- const translationsFilePath = require.resolve("./i18n/data/".concat(locale, ".json"), {
249
- paths: ["".concat(loadingOptions.applicationPath, "/src"), loadingOptions.applicationPath]
248
+ const translationsFilePath = require.resolve(`./i18n/data/${locale}.json`, {
249
+ paths: [`${loadingOptions.applicationPath}/src`, loadingOptions.applicationPath]
250
250
  });
251
251
  const translations = require(translationsFilePath);
252
252
  const hasIntlMessage = translations.hasOwnProperty(requestedIntlMessageId);
253
253
  if (!hasIntlMessage) {
254
- var _context2, _context3;
255
- 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, "'."));
254
+ throw new Error(`Missing message key '${requestedIntlMessageId}' specified in config as 'intl:${locale}:${requestedIntlMessageId}'.`);
256
255
  }
257
256
  const translation = translations[requestedIntlMessageId];
258
257
  const translationValue = isStructuredJson(translation) ? translation.string : translation;
259
258
  const escapedMatchedString = matchedString.replace(/[${}:]/g, '\\$&');
260
- return valueOfEnvConfig.replace(new RegExp("(".concat(escapedMatchedString, ")+"), 'g'), translationValue);
259
+ return valueOfEnvConfig.replace(new RegExp(`(${escapedMatchedString})+`, 'g'), translationValue);
261
260
  };
262
261
  const substituteFilePathVariablePlaceholder = (valueOfPlaceholder, matchedString, valueOfEnvConfig, loadingOptions) => {
263
262
  const _valueOfPlaceholder$s5 = valueOfPlaceholder.split(':'),
@@ -270,7 +269,7 @@ const substituteFilePathVariablePlaceholder = (valueOfPlaceholder, matchedString
270
269
  encoding: 'utf-8'
271
270
  });
272
271
  const escapedMatchedString = matchedString.replace(/[${}:]/g, '\\$&');
273
- return valueOfEnvConfig.replace(new RegExp("(".concat(escapedMatchedString, ")+"), 'g'), content);
272
+ return valueOfEnvConfig.replace(new RegExp(`(${escapedMatchedString})+`, 'g'), content);
274
273
  };
275
274
  const getValueOfPlaceholder = valueWithPlaceholder => valueWithPlaceholder.replace(variableSyntax, (_match, varName) => _trimInstanceProperty__default["default"](varName).call(varName)).replace(/\s/g, '');
276
275
  const substituteVariablePlaceholders = (config, loadingOptions) => JSON.parse(_JSON$stringify__default["default"](config), (_key, value) => {
@@ -963,13 +962,12 @@ const printErrors = errors => {
963
962
  return 'No errors';
964
963
  }
965
964
  return _mapInstanceProperty__default["default"](errors).call(errors, error => {
966
- var _context, _context2, _context3;
967
- const baseMessage = _concatInstanceProperty__default["default"](_context = "".concat(error.instancePath, " ")).call(_context, error.message);
965
+ const baseMessage = `${error.instancePath} ${error.message}`;
968
966
  switch (error.keyword) {
969
967
  case 'additionalProperties':
970
- return _concatInstanceProperty__default["default"](_context2 = "".concat(baseMessage, ": ")).call(_context2, error.params.additionalProperty);
968
+ return `${baseMessage}: ${error.params.additionalProperty}`;
971
969
  case 'enum':
972
- return _concatInstanceProperty__default["default"](_context3 = "".concat(baseMessage, ": ")).call(_context3, error.params.allowedValues.toString());
970
+ return `${baseMessage}: ${error.params.allowedValues.toString()}`;
973
971
  default:
974
972
  return baseMessage;
975
973
  }
@@ -982,8 +980,7 @@ const validateConfig = (configType, config) => {
982
980
  } else if (configType === LOADED_CONFIG_TYPES.CUSTOM_VIEW) {
983
981
  validation = validateCustomViewConfig;
984
982
  } else {
985
- var _context4;
986
- throw new Error(_concatInstanceProperty__default["default"](_context4 = "Invalid config type \"".concat(configType, "\", expected ")).call(_context4, _Object$keys__default["default"](LOADED_CONFIG_TYPES).toString()));
983
+ throw new Error(`Invalid config type "${configType}", expected ${_Object$keys__default["default"](LOADED_CONFIG_TYPES).toString()}`);
987
984
  }
988
985
  const isValid = validation(config);
989
986
  if (!isValid) {
@@ -996,9 +993,9 @@ const validateEntryPointUriPath = config => {
996
993
  }
997
994
  };
998
995
  const validateSubmenuLinks = config => {
999
- var _context5;
996
+ var _context;
1000
997
  const uriPathSet = new _Set__default["default"]();
1001
- _forEachInstanceProperty__default["default"](_context5 = config.submenuLinks).call(_context5, _ref => {
998
+ _forEachInstanceProperty__default["default"](_context = config.submenuLinks).call(_context, _ref => {
1002
999
  let uriPath = _ref.uriPath;
1003
1000
  if (uriPathSet.has(uriPath)) {
1004
1001
  throw new Error('Duplicate URI path. Every submenu link must have a unique URI path value');
@@ -1007,64 +1004,63 @@ const validateSubmenuLinks = config => {
1007
1004
  });
1008
1005
  };
1009
1006
  const validateAdditionalOAuthScopes = config => {
1010
- var _config$additionalOAu;
1007
+ var _context2, _context3;
1011
1008
  const additionalPermissionNames = new _Set__default["default"]();
1012
- (_config$additionalOAu = config.additionalOAuthScopes) === null || _config$additionalOAu === void 0 || _forEachInstanceProperty__default["default"](_config$additionalOAu).call(_config$additionalOAu, _ref2 => {
1009
+ ((_context2 = config.additionalOAuthScopes) == null ? void 0 : _bindInstanceProperty__default["default"](_context3 = Function.call).call(_context3, _forEachInstanceProperty__default["default"](_context2), _context2))?.(_ref2 => {
1013
1010
  let name = _ref2.name,
1014
1011
  view = _ref2.view,
1015
1012
  manage = _ref2.manage;
1016
1013
  if ((_Array$isArray__default["default"](view) && view.length === 0 || !view) && (_Array$isArray__default["default"](manage) && manage.length === 0 || !manage)) {
1017
- throw new Error("At least one OAuth Scope for permission group name \"".concat(name, "\" is required"));
1014
+ throw new Error(`At least one OAuth Scope for permission group name "${name}" is required`);
1018
1015
  } else if (additionalPermissionNames.has(name)) {
1019
- throw new Error("Duplicate additional permission group name \"".concat(name, "\". Every additional permission must have a unique name"));
1016
+ throw new Error(`Duplicate additional permission group name "${name}". Every additional permission must have a unique name`);
1020
1017
  }
1021
1018
  if (!name.match(constants.PERMISSION_GROUP_NAME_REGEX)) {
1022
- throw new Error("Additional permission group name \"".concat(name, "\" is invalid. The value may be between 2 and 64 characters and only contain alphabetic lowercase characters and non-consecutive hyphens. Leading and trailing hyphens are also not allowed"));
1019
+ throw new Error(`Additional permission group name "${name}" is invalid. The value may be between 2 and 64 characters and only contain alphabetic lowercase characters and non-consecutive hyphens. Leading and trailing hyphens are also not allowed`);
1023
1020
  }
1024
1021
  additionalPermissionNames.add(name);
1025
1022
  });
1026
1023
  };
1027
1024
 
1028
1025
  function ownKeys$1(e, r) { var t = _Object$keys__default["default"](e); if (_Object$getOwnPropertySymbols__default["default"]) { var o = _Object$getOwnPropertySymbols__default["default"](e); r && (o = _filterInstanceProperty__default["default"](o).call(o, function (r) { return _Object$getOwnPropertyDescriptor__default["default"](e, r).enumerable; })), t.push.apply(t, o); } return t; }
1029
- function _objectSpread$1(e) { for (var r = 1; r < arguments.length; r++) { var _context5, _context6; var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? _forEachInstanceProperty__default["default"](_context5 = ownKeys$1(Object(t), !0)).call(_context5, function (r) { _defineProperty(e, r, t[r]); }) : _Object$getOwnPropertyDescriptors__default["default"] ? _Object$defineProperties__default["default"](e, _Object$getOwnPropertyDescriptors__default["default"](t)) : _forEachInstanceProperty__default["default"](_context6 = ownKeys$1(Object(t))).call(_context6, function (r) { _Object$defineProperty__default["default"](e, r, _Object$getOwnPropertyDescriptor__default["default"](t, r)); }); } return e; }
1026
+ function _objectSpread$1(e) { for (var r = 1; r < arguments.length; r++) { var _context6, _context7; var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? _forEachInstanceProperty__default["default"](_context6 = ownKeys$1(Object(t), !0)).call(_context6, function (r) { _defineProperty(e, r, t[r]); }) : _Object$getOwnPropertyDescriptors__default["default"] ? _Object$defineProperties__default["default"](e, _Object$getOwnPropertyDescriptors__default["default"](t)) : _forEachInstanceProperty__default["default"](_context7 = ownKeys$1(Object(t))).call(_context7, function (r) { _Object$defineProperty__default["default"](e, r, _Object$getOwnPropertyDescriptor__default["default"](t, r)); }); } return e; }
1030
1027
 
1031
1028
  // The `uriPath` of each submenu link is supposed to be defined relative
1032
1029
  // to the `entryPointUriPath`. Computing the full path is done internally to keep
1033
1030
  // the configuration simple.
1034
1031
  const computeUriPath = (uriPath, entryPointUriPath) => {
1035
- var _context;
1036
1032
  // In case the `uriPath` is only `/`, it means that the link is supposed to be
1037
1033
  // treated the same as the main application path. In this case, the return value
1038
1034
  // should not contain any unnecessary trailing slash and therefore we use the `entryPointUriPath`.
1039
1035
  if (uriPath === '/') return entryPointUriPath;
1040
1036
  // In case the `uriPath` is already configured including the `entryPointUriPath`,
1041
1037
  // we return the `uriPath` as-is.
1042
- if (_startsWithInstanceProperty__default["default"](uriPath).call(uriPath, "".concat(entryPointUriPath, "/"))) return uriPath;
1038
+ if (_startsWithInstanceProperty__default["default"](uriPath).call(uriPath, `${entryPointUriPath}/`)) return uriPath;
1043
1039
  // Return the full path including the `entryPointUriPath` as a prefix.
1044
- return _concatInstanceProperty__default["default"](_context = "".concat(entryPointUriPath, "/")).call(_context, uriPath);
1040
+ return `${entryPointUriPath}/${uriPath}`;
1045
1041
  };
1046
1042
  const getPermissions = appConfig => {
1047
- var _context2, _appConfig$additional, _context3;
1048
- const additionalResourceAccessKeyToOauthScopeMap = _reduceInstanceProperty__default["default"](_context2 = appConfig.additionalOAuthScopes || []).call(_context2, (previousOauthScope, _ref) => {
1043
+ var _context, _context2, _context3, _context4;
1044
+ const additionalResourceAccessKeyToOauthScopeMap = _reduceInstanceProperty__default["default"](_context = appConfig.additionalOAuthScopes || []).call(_context, (previousOauthScope, _ref) => {
1049
1045
  let name = _ref.name,
1050
1046
  view = _ref.view,
1051
1047
  manage = _ref.manage;
1052
1048
  const formattedResourceKey = formatters.formatEntryPointUriPathToResourceAccessKey(name);
1053
1049
  return _objectSpread$1(_objectSpread$1({}, previousOauthScope), {}, {
1054
- ["view".concat(formattedResourceKey)]: view,
1055
- ["manage".concat(formattedResourceKey)]: manage
1050
+ [`view${formattedResourceKey}`]: view,
1051
+ [`manage${formattedResourceKey}`]: manage
1056
1052
  });
1057
1053
  }, {});
1058
- const additionalPermissionNames = ((_appConfig$additional = appConfig.additionalOAuthScopes) === null || _appConfig$additional === void 0 ? void 0 : _mapInstanceProperty__default["default"](_appConfig$additional).call(_appConfig$additional, _ref2 => {
1054
+ const additionalPermissionNames = ((_context2 = appConfig.additionalOAuthScopes) == null ? void 0 : _bindInstanceProperty__default["default"](_context3 = Function.call).call(_context3, _mapInstanceProperty__default["default"](_context2), _context2))?.(_ref2 => {
1059
1055
  let name = _ref2.name;
1060
1056
  return name;
1061
- })) || [];
1057
+ }) || [];
1062
1058
  const permissionKeys = formatters.entryPointUriPathToResourceAccesses(appConfig.entryPointUriPath ||
1063
1059
  // In case the `entryPointUriPath` is not defined it is because the
1064
1060
  // configuration is for a custom view. In this case we use the
1065
1061
  // default entry point uri path.
1066
1062
  constants.CUSTOM_VIEW_HOST_ENTRY_POINT_URI_PATH, additionalPermissionNames);
1067
- const additionalPermissions = _mapInstanceProperty__default["default"](_context3 = _Object$keys__default["default"](additionalResourceAccessKeyToOauthScopeMap)).call(_context3, additionalResourceAccessKey => ({
1063
+ const additionalPermissions = _mapInstanceProperty__default["default"](_context4 = _Object$keys__default["default"](additionalResourceAccessKeyToOauthScopeMap)).call(_context4, additionalResourceAccessKey => ({
1068
1064
  name: permissionKeys[additionalResourceAccessKey],
1069
1065
  oAuthScopes: additionalResourceAccessKeyToOauthScopeMap[additionalResourceAccessKey]
1070
1066
  }));
@@ -1077,7 +1073,7 @@ const getPermissions = appConfig => {
1077
1073
  }, ...additionalPermissions];
1078
1074
  };
1079
1075
  function transformCustomApplicationConfigToData(appConfig) {
1080
- var _context4;
1076
+ var _context5;
1081
1077
  validateEntryPointUriPath(appConfig);
1082
1078
  validateSubmenuLinks(appConfig);
1083
1079
  validateAdditionalOAuthScopes(appConfig);
@@ -1090,7 +1086,7 @@ function transformCustomApplicationConfigToData(appConfig) {
1090
1086
  permissions: getPermissions(appConfig),
1091
1087
  icon: appConfig.icon,
1092
1088
  mainMenuLink: appConfig.mainMenuLink,
1093
- submenuLinks: _mapInstanceProperty__default["default"](_context4 = appConfig.submenuLinks).call(_context4, submenuLink => _objectSpread$1(_objectSpread$1({}, submenuLink), {}, {
1089
+ submenuLinks: _mapInstanceProperty__default["default"](_context5 = appConfig.submenuLinks).call(_context5, submenuLink => _objectSpread$1(_objectSpread$1({}, submenuLink), {}, {
1094
1090
  uriPath: computeUriPath(submenuLink.uriPath, appConfig.entryPointUriPath)
1095
1091
  }))
1096
1092
  };
@@ -1115,12 +1111,11 @@ function transformConfigurationToData(configType, configuration) {
1115
1111
  } else if (configType === LOADED_CONFIG_TYPES.CUSTOM_VIEW) {
1116
1112
  return transformCustomViewConfigToData(configuration);
1117
1113
  } else {
1118
- throw new Error("Invalid config type: ".concat(configType));
1114
+ throw new Error(`Invalid config type: ${configType}`);
1119
1115
  }
1120
1116
  }
1121
1117
 
1122
1118
  const mapCloudIdentifierToApiUrl = key => {
1123
- var _context;
1124
1119
  switch (key) {
1125
1120
  case CLOUD_IDENTIFIERS.GCP_AU:
1126
1121
  return MC_API_URLS[CLOUD_IDENTIFIERS.GCP_AU];
@@ -1137,7 +1132,7 @@ const mapCloudIdentifierToApiUrl = key => {
1137
1132
  default:
1138
1133
  // We would probably never get to this point, as the JSON schema validation
1139
1134
  // kicks in before.
1140
- throw new Error(_concatInstanceProperty__default["default"](_context = "Unknown cloud identifier \"".concat(key, "\". Supported values: ")).call(_context, _Object$values__default["default"](CLOUD_IDENTIFIERS).toString()));
1135
+ throw new Error(`Unknown cloud identifier "${key}". Supported values: ${_Object$values__default["default"](CLOUD_IDENTIFIERS).toString()}`);
1141
1136
  }
1142
1137
  };
1143
1138
  const getUniqueValues = function () {
@@ -1161,10 +1156,10 @@ const getOrThrow = (fn, errorMessage) => {
1161
1156
  };
1162
1157
 
1163
1158
  function ownKeys(e, r) { var t = _Object$keys__default["default"](e); if (_Object$getOwnPropertySymbols__default["default"]) { var o = _Object$getOwnPropertySymbols__default["default"](e); r && (o = _filterInstanceProperty__default["default"](o).call(o, function (r) { return _Object$getOwnPropertyDescriptor__default["default"](e, r).enumerable; })), t.push.apply(t, o); } return t; }
1164
- function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var _context4, _context5; var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? _forEachInstanceProperty__default["default"](_context4 = ownKeys(Object(t), !0)).call(_context4, function (r) { _defineProperty(e, r, t[r]); }) : _Object$getOwnPropertyDescriptors__default["default"] ? _Object$defineProperties__default["default"](e, _Object$getOwnPropertyDescriptors__default["default"](t)) : _forEachInstanceProperty__default["default"](_context5 = ownKeys(Object(t))).call(_context5, function (r) { _Object$defineProperty__default["default"](e, r, _Object$getOwnPropertyDescriptor__default["default"](t, r)); }); } return e; }
1159
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var _context2, _context3; var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? _forEachInstanceProperty__default["default"](_context2 = ownKeys(Object(t), !0)).call(_context2, function (r) { _defineProperty(e, r, t[r]); }) : _Object$getOwnPropertyDescriptors__default["default"] ? _Object$defineProperties__default["default"](e, _Object$getOwnPropertyDescriptors__default["default"](t)) : _forEachInstanceProperty__default["default"](_context3 = ownKeys(Object(t))).call(_context3, function (r) { _Object$defineProperty__default["default"](e, r, _Object$getOwnPropertyDescriptor__default["default"](t, r)); }); } return e; }
1165
1160
  // TODO: make it configurable.
1166
1161
  const developmentPort = 3001;
1167
- const developmentAppUrl = "http://localhost:".concat(developmentPort);
1162
+ const developmentAppUrl = `http://localhost:${developmentPort}`;
1168
1163
  const getLoadedConfigurationType = configFileName => {
1169
1164
  if (_includesInstanceProperty__default["default"](configFileName).call(configFileName, 'custom-view-config')) {
1170
1165
  return LOADED_CONFIG_TYPES.CUSTOM_VIEW;
@@ -1180,7 +1175,6 @@ const omitDevConfigIfEmpty = devConfig => {
1180
1175
  };
1181
1176
  const isCustomViewData = data => data.entryPointUriPath === undefined;
1182
1177
  const getRuntimeEnvironmentConfigForDevelopment = _ref => {
1183
- var _appConfig$env$develo;
1184
1178
  let isProd = _ref.isProd,
1185
1179
  configurationData = _ref.configurationData,
1186
1180
  mcApiUrl = _ref.mcApiUrl,
@@ -1197,7 +1191,7 @@ const getRuntimeEnvironmentConfigForDevelopment = _ref => {
1197
1191
  initialProjectKey:
1198
1192
  // For the `account` application, we should unset the projectKey.
1199
1193
  entryPointUriPath === 'account' ? undefined : appConfig.env.development.initialProjectKey
1200
- }, ((_appConfig$env$develo = appConfig.env.development) === null || _appConfig$env$develo === void 0 ? void 0 : _appConfig$env$develo.teamId) && _objectSpread({
1194
+ }, appConfig.env.development?.teamId && _objectSpread({
1201
1195
  teamId: appConfig.env.development.teamId
1202
1196
  }, isCustomViewData(configurationData) ? {
1203
1197
  customViewId: configurationData.id
@@ -1205,12 +1199,11 @@ const getRuntimeEnvironmentConfigForDevelopment = _ref => {
1205
1199
  applicationId: configurationData.id
1206
1200
  })), {}, {
1207
1201
  oAuthScopes: appConfig.oAuthScopes,
1208
- additionalOAuthScopes: appConfig === null || appConfig === void 0 ? void 0 : appConfig.additionalOAuthScopes
1202
+ additionalOAuthScopes: appConfig?.additionalOAuthScopes
1209
1203
  }));
1210
1204
  if (isCustomViewData(configurationData)) {
1211
- var _context;
1212
1205
  const hostUriPath = appConfig.env.development.hostUriPath;
1213
- const defaultHostUriPath = oidcConfig.initialProjectKey ? _concatInstanceProperty__default["default"](_context = "/".concat(oidcConfig.initialProjectKey, "/")).call(_context, entryPointUriPath) : "/".concat(entryPointUriPath);
1206
+ const defaultHostUriPath = oidcConfig.initialProjectKey ? `/${oidcConfig.initialProjectKey}/${entryPointUriPath}` : `/${entryPointUriPath}`;
1214
1207
  const hostUrl = new _URL__default["default"](hostUriPath || defaultHostUriPath, developmentAppUrl);
1215
1208
  return omitDevConfigIfEmpty({
1216
1209
  oidc: oidcConfig,
@@ -1232,7 +1225,6 @@ const getRuntimeEnvironmentConfigForDevelopment = _ref => {
1232
1225
  });
1233
1226
  };
1234
1227
  const getRuntimeEnvironmentConfig = _ref2 => {
1235
- var _context2;
1236
1228
  let isProd = _ref2.isProd,
1237
1229
  configurationData = _ref2.configurationData,
1238
1230
  additionalAppEnv = _ref2.additionalAppEnv,
@@ -1251,7 +1243,7 @@ const getRuntimeEnvironmentConfig = _ref2 => {
1251
1243
  // In development, we prefix the entry point with the "__local" prefix.
1252
1244
  // This is important to determine to which URL the MC should redirect to
1253
1245
  // after successful login.
1254
- const applicationIdentifier = isProd ? _concatInstanceProperty__default["default"](_context2 = "".concat(configurationData.id, ":")).call(_context2, entryPointUriPath) : "__local:".concat(entryPointUriPath);
1246
+ const applicationIdentifier = isProd ? `${configurationData.id}:${entryPointUriPath}` : `__local:${entryPointUriPath}`;
1255
1247
  const developmentConfig = getRuntimeEnvironmentConfigForDevelopment({
1256
1248
  isProd,
1257
1249
  configurationData,
@@ -1283,7 +1275,7 @@ const getRuntimeEnvironmentConfig = _ref2 => {
1283
1275
  // again will result in returning the cached value.
1284
1276
  let cachedConfig;
1285
1277
  const processConfig = async function () {
1286
- var _ref4, _processEnv$MC_APP_EN, _appConfig$additional, _ref5, _appConfig$headers, _appConfig$headers2, _context3, _appConfig$headers3, _appConfig$headers4;
1278
+ var _context;
1287
1279
  let _ref3 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
1288
1280
  _ref3$disableCache = _ref3.disableCache,
1289
1281
  disableCache = _ref3$disableCache === void 0 ? false : _ref3$disableCache,
@@ -1302,22 +1294,22 @@ const processConfig = async function () {
1302
1294
  processEnv
1303
1295
  });
1304
1296
  const configurationData = transformConfigurationToData(configType, appConfig);
1305
- const appEnvKey = (_ref4 = (_processEnv$MC_APP_EN = processEnv.MC_APP_ENV) !== null && _processEnv$MC_APP_EN !== void 0 ? _processEnv$MC_APP_EN : processEnv.NODE_ENV) !== null && _ref4 !== void 0 ? _ref4 : 'development';
1297
+ const appEnvKey = processEnv.MC_APP_ENV ?? processEnv.NODE_ENV ?? 'development';
1306
1298
  const isProd = getIsProd(processEnv);
1307
- const additionalAppEnv = (_appConfig$additional = appConfig.additionalEnv) !== null && _appConfig$additional !== void 0 ? _appConfig$additional : {};
1308
- const revision = (_ref5 = additionalAppEnv.revision) !== null && _ref5 !== void 0 ? _ref5 : '';
1299
+ const additionalAppEnv = appConfig.additionalEnv ?? {};
1300
+ const revision = additionalAppEnv.revision ?? '';
1309
1301
 
1310
1302
  // Parse all the supported URLs, which gets implicitly validated
1311
1303
 
1312
1304
  const envAppUrl = isProd ? configurationData.url : developmentAppUrl;
1313
- const appUrl = getOrThrow(() => new _URL__default["default"](envAppUrl), "Invalid application URL: \"".concat(envAppUrl, "\""));
1305
+ const appUrl = getOrThrow(() => new _URL__default["default"](envAppUrl), `Invalid application URL: "${envAppUrl}"`);
1314
1306
 
1315
1307
  // Use `||` instead of `??` to include empty string values.
1316
1308
  const envCdnUrl = isProd ? appConfig.env.production.cdnUrl || appUrl.href : developmentAppUrl;
1317
- const cdnUrl = getOrThrow(() => new _URL__default["default"](envCdnUrl), "Invalid application CDN URL: \"".concat(envCdnUrl, "\""));
1309
+ const cdnUrl = getOrThrow(() => new _URL__default["default"](envCdnUrl), `Invalid application CDN URL: "${envCdnUrl}"`);
1318
1310
  const mcApiUrl = getOrThrow(() => new _URL__default["default"](
1319
1311
  // Use `||` instead of `??` to include empty string values.
1320
- appConfig.mcApiUrl || mapCloudIdentifierToApiUrl(appConfig.cloudIdentifier)), "Invalid MC API URL: \"".concat(appConfig.mcApiUrl, "\""));
1312
+ appConfig.mcApiUrl || mapCloudIdentifierToApiUrl(appConfig.cloudIdentifier)), `Invalid MC API URL: "${appConfig.mcApiUrl}"`);
1321
1313
  cachedConfig = {
1322
1314
  data: configurationData,
1323
1315
  env: getRuntimeEnvironmentConfig({
@@ -1332,16 +1324,16 @@ const processConfig = async function () {
1332
1324
  revision
1333
1325
  }),
1334
1326
  headers: _objectSpread(_objectSpread({}, appConfig.headers), {}, {
1335
- csp: _objectSpread(_objectSpread({}, (_appConfig$headers = appConfig.headers) === null || _appConfig$headers === void 0 ? void 0 : _appConfig$headers.csp), {}, {
1327
+ csp: _objectSpread(_objectSpread({}, appConfig.headers?.csp), {}, {
1336
1328
  // We need to make sure the URL we use in these CSP headers have a slash in the end,
1337
1329
  // otherwise it might create an invalid value when application/CDN URL points to a
1338
1330
  // non-root directory (ex: https://www.my-domain.com/app). This is a valid URL but from
1339
1331
  // the CSP point of view, it will say only the file `app` can be used as a source, so
1340
1332
  // any other file from that domain will be forbidden. Using the slash (ex: https://www.my-domain.com/app/)
1341
1333
  // at the end it's like using a wildcard so anything 'below' `app` will be allowed.
1342
- 'connect-src': getUniqueValues((_appConfig$headers2 = appConfig.headers) === null || _appConfig$headers2 === void 0 || (_appConfig$headers2 = _appConfig$headers2.csp) === null || _appConfig$headers2 === void 0 ? void 0 : _appConfig$headers2['connect-src'], _concatInstanceProperty__default["default"](_context3 = [mcApiUrl.origin]).call(_context3, isProd ? ["".concat(trimTrailingSlash(appUrl.href), "/"), "".concat(trimTrailingSlash(cdnUrl.href), "/")] : [])),
1343
- 'script-src': getUniqueValues((_appConfig$headers3 = appConfig.headers) === null || _appConfig$headers3 === void 0 || (_appConfig$headers3 = _appConfig$headers3.csp) === null || _appConfig$headers3 === void 0 ? void 0 : _appConfig$headers3['script-src'], isProd ? ["".concat(trimTrailingSlash(appUrl.href), "/"), "".concat(trimTrailingSlash(cdnUrl.href), "/")] : []),
1344
- 'style-src': getUniqueValues((_appConfig$headers4 = appConfig.headers) === null || _appConfig$headers4 === void 0 || (_appConfig$headers4 = _appConfig$headers4.csp) === null || _appConfig$headers4 === void 0 ? void 0 : _appConfig$headers4['style-src'], isProd ? ["".concat(trimTrailingSlash(appUrl.href), "/"), "".concat(trimTrailingSlash(cdnUrl.href), "/")] : [])
1334
+ 'connect-src': getUniqueValues(appConfig.headers?.csp?.['connect-src'], _concatInstanceProperty__default["default"](_context = [mcApiUrl.origin]).call(_context, isProd ? [`${trimTrailingSlash(appUrl.href)}/`, `${trimTrailingSlash(cdnUrl.href)}/`] : [])),
1335
+ 'script-src': getUniqueValues(appConfig.headers?.csp?.['script-src'], isProd ? [`${trimTrailingSlash(appUrl.href)}/`, `${trimTrailingSlash(cdnUrl.href)}/`] : []),
1336
+ 'style-src': getUniqueValues(appConfig.headers?.csp?.['style-src'], isProd ? [`${trimTrailingSlash(appUrl.href)}/`, `${trimTrailingSlash(cdnUrl.href)}/`] : [])
1345
1337
  })
1346
1338
  })
1347
1339
  };