@commercetools-frontend/application-config 22.30.3 → 22.32.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 = require('node:fs');
18
18
  var path = require('node:path');
19
19
  var omitEmpty = require('omit-empty-es');
@@ -34,7 +34,7 @@ var _JSON$stringify = require('@babel/runtime-corejs3/core-js-stable/json/string
34
34
  var _startsWithInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/starts-with');
35
35
  var _reduceInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/reduce');
36
36
  var _mapInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/map');
37
- var formatters = require('./formatters-a09672cf.cjs.dev.js');
37
+ var formatters = require('./formatters-a76b45b9.cjs.dev.js');
38
38
  var _Set = require('@babel/runtime-corejs3/core-js-stable/set');
39
39
  var _Array$isArray = require('@babel/runtime-corejs3/core-js-stable/array/is-array');
40
40
  var Ajv = require('ajv');
@@ -56,8 +56,8 @@ var _Object$getOwnPropertyDescriptors__default = /*#__PURE__*/_interopDefault(_O
56
56
  var _Object$defineProperties__default = /*#__PURE__*/_interopDefault(_Object$defineProperties);
57
57
  var _Object$defineProperty__default = /*#__PURE__*/_interopDefault(_Object$defineProperty);
58
58
  var _includesInstanceProperty__default = /*#__PURE__*/_interopDefault(_includesInstanceProperty);
59
- var _concatInstanceProperty__default = /*#__PURE__*/_interopDefault(_concatInstanceProperty);
60
59
  var _URL__default = /*#__PURE__*/_interopDefault(_URL);
60
+ var _concatInstanceProperty__default = /*#__PURE__*/_interopDefault(_concatInstanceProperty);
61
61
  var fs__default = /*#__PURE__*/_interopDefault(fs);
62
62
  var path__default = /*#__PURE__*/_interopDefault(path);
63
63
  var omitEmpty__default = /*#__PURE__*/_interopDefault(omitEmpty);
@@ -150,7 +150,7 @@ const loadJsModule = filePath => {
150
150
  const createExplorerFor = configFileName => {
151
151
  return cosmiconfig.cosmiconfigSync(configFileName, {
152
152
  // Restrict the supported file formats / names
153
- searchPlaces: [".".concat(configFileName, "rc"), ".".concat(configFileName, ".json"), ".".concat(configFileName, ".js"), ".".concat(configFileName, ".cjs"), ".".concat(configFileName, ".mjs"), ".".concat(configFileName, ".ts"), "".concat(configFileName, ".json"), "".concat(configFileName, ".js"), "".concat(configFileName, ".cjs"), "".concat(configFileName, ".mjs"), "".concat(configFileName, ".ts")],
153
+ searchPlaces: [`.${configFileName}rc`, `.${configFileName}.json`, `.${configFileName}.js`, `.${configFileName}.cjs`, `.${configFileName}.mjs`, `.${configFileName}.ts`, `${configFileName}.json`, `${configFileName}.js`, `${configFileName}.cjs`, `${configFileName}.mjs`, `${configFileName}.ts`],
154
154
  loaders: {
155
155
  noExt: cosmiconfig.defaultLoaders['.json'],
156
156
  '.js': loadJsModule,
@@ -166,18 +166,18 @@ const getConfigPath = () => {
166
166
  const customApplicationConfigFile = customApplicationExplorer.search();
167
167
  const customViewConfigFile = customViewExplorer.search();
168
168
  if (!customApplicationConfigFile && !customViewConfigFile) {
169
- throw new Error("Missing or invalid configuration file.");
169
+ throw new Error(`Missing or invalid configuration file.`);
170
170
  }
171
- return (customApplicationConfigFile === null || customApplicationConfigFile === void 0 ? void 0 : customApplicationConfigFile.filepath) || (customViewConfigFile === null || customViewConfigFile === void 0 ? void 0 : customViewConfigFile.filepath);
171
+ return customApplicationConfigFile?.filepath || customViewConfigFile?.filepath;
172
172
  };
173
173
  const loadConfig = applicationPath => {
174
174
  const customApplicationConfigFile = customApplicationExplorer.search(applicationPath);
175
175
  const customViewConfigFile = customViewExplorer.search(applicationPath);
176
176
  if ((!customApplicationConfigFile || !customApplicationConfigFile.config) && (!customViewConfigFile || !customViewConfigFile.config)) {
177
- throw new MissingOrInvalidConfigError("Missing or invalid configuration file.");
177
+ throw new MissingOrInvalidConfigError(`Missing or invalid configuration file.`);
178
178
  }
179
179
  if (customApplicationConfigFile && customViewConfigFile) {
180
- throw new MissingOrInvalidConfigError("Found configuration files for both Custom Application and Custom View. Please remove one of them.");
180
+ throw new MissingOrInvalidConfigError(`Found configuration files for both Custom Application and Custom View. Please remove one of them.`);
181
181
  }
182
182
  return customViewConfigFile || customApplicationConfigFile;
183
183
  };
@@ -206,37 +206,35 @@ Boolean(valueOfEnvConfig.match(variableSyntax));
206
206
  const isEnvVariablePlaceholder = valueOfPlaceholder => Boolean(valueOfPlaceholder.match(envRefSyntax));
207
207
  const isIntlVariablePlaceholder = valueOfPlaceholder => Boolean(valueOfPlaceholder.match(intlRefSyntax));
208
208
  const isFilePathVariablePlaceholder = valueOfPlaceholder => Boolean(valueOfPlaceholder.match(filePathRefSyntax));
209
- const isStructuredJson = message => (message === null || message === void 0 ? void 0 : message.string) !== undefined;
209
+ const isStructuredJson = message => message?.string !== undefined;
210
210
  const substituteEnvVariablePlaceholder = (valueOfPlaceholder, matchedString, valueOfEnvConfig, loadingOptions) => {
211
211
  const _valueOfPlaceholder$s = valueOfPlaceholder.split(':'),
212
212
  _valueOfPlaceholder$s2 = _slicedToArray(_valueOfPlaceholder$s, 2),
213
213
  requestedEnvVar = _valueOfPlaceholder$s2[1];
214
214
  const hasEnvField = loadingOptions.processEnv.hasOwnProperty(requestedEnvVar);
215
215
  if (!hasEnvField) {
216
- var _context;
217
- throw new Error(_concatInstanceProperty__default["default"](_context = "Missing environment variable '".concat(requestedEnvVar, "' specified in config as 'env:")).call(_context, requestedEnvVar, "'."));
216
+ throw new Error(`Missing environment variable '${requestedEnvVar}' specified in config as 'env:${requestedEnvVar}'.`);
218
217
  }
219
218
  const escapedMatchedString = matchedString.replace(/[${}:]/g, '\\$&');
220
- return valueOfEnvConfig.replace(new RegExp("(".concat(escapedMatchedString, ")+"), 'g'), loadingOptions.processEnv[requestedEnvVar]);
219
+ return valueOfEnvConfig.replace(new RegExp(`(${escapedMatchedString})+`, 'g'), loadingOptions.processEnv[requestedEnvVar]);
221
220
  };
222
221
  const substituteIntlVariablePlaceholder = (valueOfPlaceholder, matchedString, valueOfEnvConfig, loadingOptions) => {
223
222
  const _valueOfPlaceholder$s3 = valueOfPlaceholder.split(':'),
224
223
  _valueOfPlaceholder$s4 = _slicedToArray(_valueOfPlaceholder$s3, 3),
225
224
  locale = _valueOfPlaceholder$s4[1],
226
225
  requestedIntlMessageId = _valueOfPlaceholder$s4[2];
227
- const translationsFilePath = require.resolve("./i18n/data/".concat(locale, ".json"), {
228
- paths: ["".concat(loadingOptions.applicationPath, "/src"), loadingOptions.applicationPath]
226
+ const translationsFilePath = require.resolve(`./i18n/data/${locale}.json`, {
227
+ paths: [`${loadingOptions.applicationPath}/src`, loadingOptions.applicationPath]
229
228
  });
230
229
  const translations = require(translationsFilePath);
231
230
  const hasIntlMessage = translations.hasOwnProperty(requestedIntlMessageId);
232
231
  if (!hasIntlMessage) {
233
- var _context2, _context3;
234
- 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, "'."));
232
+ throw new Error(`Missing message key '${requestedIntlMessageId}' specified in config as 'intl:${locale}:${requestedIntlMessageId}'.`);
235
233
  }
236
234
  const translation = translations[requestedIntlMessageId];
237
235
  const translationValue = isStructuredJson(translation) ? translation.string : translation;
238
236
  const escapedMatchedString = matchedString.replace(/[${}:]/g, '\\$&');
239
- return valueOfEnvConfig.replace(new RegExp("(".concat(escapedMatchedString, ")+"), 'g'), translationValue);
237
+ return valueOfEnvConfig.replace(new RegExp(`(${escapedMatchedString})+`, 'g'), translationValue);
240
238
  };
241
239
  const substituteFilePathVariablePlaceholder = (valueOfPlaceholder, matchedString, valueOfEnvConfig, loadingOptions) => {
242
240
  const _valueOfPlaceholder$s5 = valueOfPlaceholder.split(':'),
@@ -249,7 +247,7 @@ const substituteFilePathVariablePlaceholder = (valueOfPlaceholder, matchedString
249
247
  encoding: 'utf-8'
250
248
  });
251
249
  const escapedMatchedString = matchedString.replace(/[${}:]/g, '\\$&');
252
- return valueOfEnvConfig.replace(new RegExp("(".concat(escapedMatchedString, ")+"), 'g'), content);
250
+ return valueOfEnvConfig.replace(new RegExp(`(${escapedMatchedString})+`, 'g'), content);
253
251
  };
254
252
  const getValueOfPlaceholder = valueWithPlaceholder => valueWithPlaceholder.replace(variableSyntax, (_match, varName) => _trimInstanceProperty__default["default"](varName).call(varName)).replace(/\s/g, '');
255
253
  const substituteVariablePlaceholders = (config, loadingOptions) => JSON.parse(_JSON$stringify__default["default"](config), (_key, value) => {
@@ -925,13 +923,12 @@ const printErrors = errors => {
925
923
  return 'No errors';
926
924
  }
927
925
  return _mapInstanceProperty__default["default"](errors).call(errors, error => {
928
- var _context, _context2, _context3;
929
- const baseMessage = _concatInstanceProperty__default["default"](_context = "".concat(error.instancePath, " ")).call(_context, error.message);
926
+ const baseMessage = `${error.instancePath} ${error.message}`;
930
927
  switch (error.keyword) {
931
928
  case 'additionalProperties':
932
- return _concatInstanceProperty__default["default"](_context2 = "".concat(baseMessage, ": ")).call(_context2, error.params.additionalProperty);
929
+ return `${baseMessage}: ${error.params.additionalProperty}`;
933
930
  case 'enum':
934
- return _concatInstanceProperty__default["default"](_context3 = "".concat(baseMessage, ": ")).call(_context3, error.params.allowedValues.toString());
931
+ return `${baseMessage}: ${error.params.allowedValues.toString()}`;
935
932
  default:
936
933
  return baseMessage;
937
934
  }
@@ -944,8 +941,7 @@ const validateConfig = (configType, config) => {
944
941
  } else if (configType === LOADED_CONFIG_TYPES.CUSTOM_VIEW) {
945
942
  validation = validateCustomViewConfig;
946
943
  } else {
947
- var _context4;
948
- throw new Error(_concatInstanceProperty__default["default"](_context4 = "Invalid config type \"".concat(configType, "\", expected ")).call(_context4, _Object$keys__default["default"](LOADED_CONFIG_TYPES).toString()));
944
+ throw new Error(`Invalid config type "${configType}", expected ${_Object$keys__default["default"](LOADED_CONFIG_TYPES).toString()}`);
949
945
  }
950
946
  const isValid = validation(config);
951
947
  if (!isValid) {
@@ -958,9 +954,9 @@ const validateEntryPointUriPath = config => {
958
954
  }
959
955
  };
960
956
  const validateSubmenuLinks = config => {
961
- var _context5;
957
+ var _context;
962
958
  const uriPathSet = new _Set__default["default"]();
963
- _forEachInstanceProperty__default["default"](_context5 = config.submenuLinks).call(_context5, _ref => {
959
+ _forEachInstanceProperty__default["default"](_context = config.submenuLinks).call(_context, _ref => {
964
960
  let uriPath = _ref.uriPath;
965
961
  if (uriPathSet.has(uriPath)) {
966
962
  throw new Error('Duplicate URI path. Every submenu link must have a unique URI path value');
@@ -969,64 +965,62 @@ const validateSubmenuLinks = config => {
969
965
  });
970
966
  };
971
967
  const validateAdditionalOAuthScopes = config => {
972
- var _config$additionalOAu;
973
968
  const additionalPermissionNames = new _Set__default["default"]();
974
- (_config$additionalOAu = config.additionalOAuthScopes) === null || _config$additionalOAu === void 0 || _forEachInstanceProperty__default["default"](_config$additionalOAu).call(_config$additionalOAu, _ref2 => {
969
+ config.additionalOAuthScopes?.forEach(_ref2 => {
975
970
  let name = _ref2.name,
976
971
  view = _ref2.view,
977
972
  manage = _ref2.manage;
978
973
  if ((_Array$isArray__default["default"](view) && view.length === 0 || !view) && (_Array$isArray__default["default"](manage) && manage.length === 0 || !manage)) {
979
- throw new Error("At least one OAuth Scope for permission group name \"".concat(name, "\" is required"));
974
+ throw new Error(`At least one OAuth Scope for permission group name "${name}" is required`);
980
975
  } else if (additionalPermissionNames.has(name)) {
981
- throw new Error("Duplicate additional permission group name \"".concat(name, "\". Every additional permission must have a unique name"));
976
+ throw new Error(`Duplicate additional permission group name "${name}". Every additional permission must have a unique name`);
982
977
  }
983
978
  if (!name.match(constants.PERMISSION_GROUP_NAME_REGEX)) {
984
- 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"));
979
+ 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`);
985
980
  }
986
981
  additionalPermissionNames.add(name);
987
982
  });
988
983
  };
989
984
 
990
985
  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; }
991
- 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; }
986
+ function _objectSpread$1(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$1(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$1(Object(t))).call(_context5, function (r) { _Object$defineProperty__default["default"](e, r, _Object$getOwnPropertyDescriptor__default["default"](t, r)); }); } return e; }
992
987
 
993
988
  // The `uriPath` of each submenu link is supposed to be defined relative
994
989
  // to the `entryPointUriPath`. Computing the full path is done internally to keep
995
990
  // the configuration simple.
996
991
  const computeUriPath = (uriPath, entryPointUriPath) => {
997
- var _context;
998
992
  // In case the `uriPath` is only `/`, it means that the link is supposed to be
999
993
  // treated the same as the main application path. In this case, the return value
1000
994
  // should not contain any unnecessary trailing slash and therefore we use the `entryPointUriPath`.
1001
995
  if (uriPath === '/') return entryPointUriPath;
1002
996
  // In case the `uriPath` is already configured including the `entryPointUriPath`,
1003
997
  // we return the `uriPath` as-is.
1004
- if (_startsWithInstanceProperty__default["default"](uriPath).call(uriPath, "".concat(entryPointUriPath, "/"))) return uriPath;
998
+ if (_startsWithInstanceProperty__default["default"](uriPath).call(uriPath, `${entryPointUriPath}/`)) return uriPath;
1005
999
  // Return the full path including the `entryPointUriPath` as a prefix.
1006
- return _concatInstanceProperty__default["default"](_context = "".concat(entryPointUriPath, "/")).call(_context, uriPath);
1000
+ return `${entryPointUriPath}/${uriPath}`;
1007
1001
  };
1008
1002
  const getPermissions = appConfig => {
1009
- var _context2, _appConfig$additional, _context3;
1010
- const additionalResourceAccessKeyToOauthScopeMap = _reduceInstanceProperty__default["default"](_context2 = appConfig.additionalOAuthScopes || []).call(_context2, (previousOauthScope, _ref) => {
1003
+ var _context, _context2;
1004
+ const additionalResourceAccessKeyToOauthScopeMap = _reduceInstanceProperty__default["default"](_context = appConfig.additionalOAuthScopes || []).call(_context, (previousOauthScope, _ref) => {
1011
1005
  let name = _ref.name,
1012
1006
  view = _ref.view,
1013
1007
  manage = _ref.manage;
1014
1008
  const formattedResourceKey = formatters.formatEntryPointUriPathToResourceAccessKey(name);
1015
1009
  return _objectSpread$1(_objectSpread$1({}, previousOauthScope), {}, {
1016
- ["view".concat(formattedResourceKey)]: view,
1017
- ["manage".concat(formattedResourceKey)]: manage
1010
+ [`view${formattedResourceKey}`]: view,
1011
+ [`manage${formattedResourceKey}`]: manage
1018
1012
  });
1019
1013
  }, {});
1020
- const additionalPermissionNames = ((_appConfig$additional = appConfig.additionalOAuthScopes) === null || _appConfig$additional === void 0 ? void 0 : _mapInstanceProperty__default["default"](_appConfig$additional).call(_appConfig$additional, _ref2 => {
1014
+ const additionalPermissionNames = appConfig.additionalOAuthScopes?.map(_ref2 => {
1021
1015
  let name = _ref2.name;
1022
1016
  return name;
1023
- })) || [];
1017
+ }) || [];
1024
1018
  const permissionKeys = formatters.entryPointUriPathToResourceAccesses(appConfig.entryPointUriPath ||
1025
1019
  // In case the `entryPointUriPath` is not defined it is because the
1026
1020
  // configuration is for a custom view. In this case we use the
1027
1021
  // default entry point uri path.
1028
1022
  constants.CUSTOM_VIEW_HOST_ENTRY_POINT_URI_PATH, additionalPermissionNames);
1029
- const additionalPermissions = _mapInstanceProperty__default["default"](_context3 = _Object$keys__default["default"](additionalResourceAccessKeyToOauthScopeMap)).call(_context3, additionalResourceAccessKey => ({
1023
+ const additionalPermissions = _mapInstanceProperty__default["default"](_context2 = _Object$keys__default["default"](additionalResourceAccessKeyToOauthScopeMap)).call(_context2, additionalResourceAccessKey => ({
1030
1024
  name: permissionKeys[additionalResourceAccessKey],
1031
1025
  oAuthScopes: additionalResourceAccessKeyToOauthScopeMap[additionalResourceAccessKey]
1032
1026
  }));
@@ -1039,7 +1033,7 @@ const getPermissions = appConfig => {
1039
1033
  }, ...additionalPermissions];
1040
1034
  };
1041
1035
  function transformCustomApplicationConfigToData(appConfig) {
1042
- var _context4;
1036
+ var _context3;
1043
1037
  validateEntryPointUriPath(appConfig);
1044
1038
  validateSubmenuLinks(appConfig);
1045
1039
  validateAdditionalOAuthScopes(appConfig);
@@ -1052,7 +1046,7 @@ function transformCustomApplicationConfigToData(appConfig) {
1052
1046
  permissions: getPermissions(appConfig),
1053
1047
  icon: appConfig.icon,
1054
1048
  mainMenuLink: appConfig.mainMenuLink,
1055
- submenuLinks: _mapInstanceProperty__default["default"](_context4 = appConfig.submenuLinks).call(_context4, submenuLink => _objectSpread$1(_objectSpread$1({}, submenuLink), {}, {
1049
+ submenuLinks: _mapInstanceProperty__default["default"](_context3 = appConfig.submenuLinks).call(_context3, submenuLink => _objectSpread$1(_objectSpread$1({}, submenuLink), {}, {
1056
1050
  uriPath: computeUriPath(submenuLink.uriPath, appConfig.entryPointUriPath)
1057
1051
  }))
1058
1052
  };
@@ -1077,12 +1071,11 @@ function transformConfigurationToData(configType, configuration) {
1077
1071
  } else if (configType === LOADED_CONFIG_TYPES.CUSTOM_VIEW) {
1078
1072
  return transformCustomViewConfigToData(configuration);
1079
1073
  } else {
1080
- throw new Error("Invalid config type: ".concat(configType));
1074
+ throw new Error(`Invalid config type: ${configType}`);
1081
1075
  }
1082
1076
  }
1083
1077
 
1084
1078
  const mapCloudIdentifierToApiUrl = key => {
1085
- var _context;
1086
1079
  switch (key) {
1087
1080
  case CLOUD_IDENTIFIERS.GCP_AU:
1088
1081
  return MC_API_URLS.GCP_AU;
@@ -1101,7 +1094,7 @@ const mapCloudIdentifierToApiUrl = key => {
1101
1094
  default:
1102
1095
  // We would probably never get to this point, as the JSON schema validation
1103
1096
  // kicks in before.
1104
- throw new Error(_concatInstanceProperty__default["default"](_context = "Unknown cloud identifier \"".concat(key, "\". Supported values: ")).call(_context, _Object$values__default["default"](CLOUD_IDENTIFIERS).toString()));
1097
+ throw new Error(`Unknown cloud identifier "${key}". Supported values: ${_Object$values__default["default"](CLOUD_IDENTIFIERS).toString()}`);
1105
1098
  }
1106
1099
  };
1107
1100
  const getUniqueValues = function () {
@@ -1125,10 +1118,10 @@ const getOrThrow = (fn, errorMessage) => {
1125
1118
  };
1126
1119
 
1127
1120
  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; }
1128
- 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; }
1121
+ 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; }
1129
1122
  // TODO: make it configurable.
1130
1123
  const developmentPort = 3001;
1131
- const developmentAppUrl = "http://localhost:".concat(developmentPort);
1124
+ const developmentAppUrl = `http://localhost:${developmentPort}`;
1132
1125
  const getLoadedConfigurationType = configFileName => {
1133
1126
  if (_includesInstanceProperty__default["default"](configFileName).call(configFileName, 'custom-view-config')) {
1134
1127
  return LOADED_CONFIG_TYPES.CUSTOM_VIEW;
@@ -1144,7 +1137,6 @@ const omitDevConfigIfEmpty = devConfig => {
1144
1137
  };
1145
1138
  const isCustomViewData = data => data.entryPointUriPath === undefined;
1146
1139
  const getRuntimeEnvironmentConfigForDevelopment = _ref => {
1147
- var _appConfig$env$develo;
1148
1140
  let isProd = _ref.isProd,
1149
1141
  configurationData = _ref.configurationData,
1150
1142
  mcApiUrl = _ref.mcApiUrl,
@@ -1161,7 +1153,7 @@ const getRuntimeEnvironmentConfigForDevelopment = _ref => {
1161
1153
  initialProjectKey:
1162
1154
  // For the `account` application, we should unset the projectKey.
1163
1155
  entryPointUriPath === 'account' ? undefined : appConfig.env.development.initialProjectKey
1164
- }, ((_appConfig$env$develo = appConfig.env.development) === null || _appConfig$env$develo === void 0 ? void 0 : _appConfig$env$develo.teamId) && _objectSpread({
1156
+ }, appConfig.env.development?.teamId && _objectSpread({
1165
1157
  teamId: appConfig.env.development.teamId
1166
1158
  }, isCustomViewData(configurationData) ? {
1167
1159
  customViewId: configurationData.id
@@ -1169,12 +1161,11 @@ const getRuntimeEnvironmentConfigForDevelopment = _ref => {
1169
1161
  applicationId: configurationData.id
1170
1162
  })), {}, {
1171
1163
  oAuthScopes: appConfig.oAuthScopes,
1172
- additionalOAuthScopes: appConfig === null || appConfig === void 0 ? void 0 : appConfig.additionalOAuthScopes
1164
+ additionalOAuthScopes: appConfig?.additionalOAuthScopes
1173
1165
  }));
1174
1166
  if (isCustomViewData(configurationData)) {
1175
- var _context;
1176
1167
  const hostUriPath = appConfig.env.development.hostUriPath;
1177
- const defaultHostUriPath = oidcConfig.initialProjectKey ? _concatInstanceProperty__default["default"](_context = "/".concat(oidcConfig.initialProjectKey, "/")).call(_context, entryPointUriPath) : "/".concat(entryPointUriPath);
1168
+ const defaultHostUriPath = oidcConfig.initialProjectKey ? `/${oidcConfig.initialProjectKey}/${entryPointUriPath}` : `/${entryPointUriPath}`;
1178
1169
  const hostUrl = new _URL__default["default"](hostUriPath || defaultHostUriPath, developmentAppUrl);
1179
1170
  return omitDevConfigIfEmpty({
1180
1171
  oidc: oidcConfig,
@@ -1194,7 +1185,6 @@ const getRuntimeEnvironmentConfigForDevelopment = _ref => {
1194
1185
  });
1195
1186
  };
1196
1187
  const getRuntimeEnvironmentConfig = _ref2 => {
1197
- var _context2;
1198
1188
  let isProd = _ref2.isProd,
1199
1189
  configurationData = _ref2.configurationData,
1200
1190
  additionalAppEnv = _ref2.additionalAppEnv,
@@ -1213,7 +1203,7 @@ const getRuntimeEnvironmentConfig = _ref2 => {
1213
1203
  // In development, we prefix the entry point with the "__local" prefix.
1214
1204
  // This is important to determine to which URL the MC should redirect to
1215
1205
  // after successful login.
1216
- const applicationIdentifier = isProd ? _concatInstanceProperty__default["default"](_context2 = "".concat(configurationData.id, ":")).call(_context2, entryPointUriPath) : "__local:".concat(entryPointUriPath);
1206
+ const applicationIdentifier = isProd ? `${configurationData.id}:${entryPointUriPath}` : `__local:${entryPointUriPath}`;
1217
1207
  const developmentConfig = getRuntimeEnvironmentConfigForDevelopment({
1218
1208
  isProd,
1219
1209
  configurationData,
@@ -1245,7 +1235,7 @@ const getRuntimeEnvironmentConfig = _ref2 => {
1245
1235
  // again will result in returning the cached value.
1246
1236
  let cachedConfig;
1247
1237
  const processConfig = function () {
1248
- var _ref4, _processEnv$MC_APP_EN, _appConfig$additional, _ref5, _appConfig$headers, _appConfig$headers2, _context3, _appConfig$headers3, _appConfig$headers4;
1238
+ var _context;
1249
1239
  let _ref3 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
1250
1240
  _ref3$disableCache = _ref3.disableCache,
1251
1241
  disableCache = _ref3$disableCache === void 0 ? false : _ref3$disableCache,
@@ -1264,22 +1254,22 @@ const processConfig = function () {
1264
1254
  processEnv
1265
1255
  });
1266
1256
  const configurationData = transformConfigurationToData(configType, appConfig);
1267
- 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';
1257
+ const appEnvKey = processEnv.MC_APP_ENV ?? processEnv.NODE_ENV ?? 'development';
1268
1258
  const isProd = getIsProd(processEnv);
1269
- const additionalAppEnv = (_appConfig$additional = appConfig.additionalEnv) !== null && _appConfig$additional !== void 0 ? _appConfig$additional : {};
1270
- const revision = (_ref5 = additionalAppEnv.revision) !== null && _ref5 !== void 0 ? _ref5 : '';
1259
+ const additionalAppEnv = appConfig.additionalEnv ?? {};
1260
+ const revision = additionalAppEnv.revision ?? '';
1271
1261
 
1272
1262
  // Parse all the supported URLs, which gets implicitly validated
1273
1263
 
1274
1264
  const envAppUrl = isProd ? configurationData.url : developmentAppUrl;
1275
- const appUrl = getOrThrow(() => new _URL__default["default"](envAppUrl), "Invalid application URL: \"".concat(envAppUrl, "\""));
1265
+ const appUrl = getOrThrow(() => new _URL__default["default"](envAppUrl), `Invalid application URL: "${envAppUrl}"`);
1276
1266
 
1277
1267
  // Use `||` instead of `??` to include empty string values.
1278
1268
  const envCdnUrl = isProd ? appConfig.env.production.cdnUrl || appUrl.href : developmentAppUrl;
1279
- const cdnUrl = getOrThrow(() => new _URL__default["default"](envCdnUrl), "Invalid application CDN URL: \"".concat(envCdnUrl, "\""));
1269
+ const cdnUrl = getOrThrow(() => new _URL__default["default"](envCdnUrl), `Invalid application CDN URL: "${envCdnUrl}"`);
1280
1270
  const mcApiUrl = getOrThrow(() => new _URL__default["default"](
1281
1271
  // Use `||` instead of `??` to include empty string values.
1282
- appConfig.mcApiUrl || mapCloudIdentifierToApiUrl(appConfig.cloudIdentifier)), "Invalid MC API URL: \"".concat(appConfig.mcApiUrl, "\""));
1272
+ appConfig.mcApiUrl || mapCloudIdentifierToApiUrl(appConfig.cloudIdentifier)), `Invalid MC API URL: "${appConfig.mcApiUrl}"`);
1283
1273
  cachedConfig = {
1284
1274
  data: configurationData,
1285
1275
  env: getRuntimeEnvironmentConfig({
@@ -1294,16 +1284,16 @@ const processConfig = function () {
1294
1284
  revision
1295
1285
  }),
1296
1286
  headers: _objectSpread(_objectSpread({}, appConfig.headers), {}, {
1297
- csp: _objectSpread(_objectSpread({}, (_appConfig$headers = appConfig.headers) === null || _appConfig$headers === void 0 ? void 0 : _appConfig$headers.csp), {}, {
1287
+ csp: _objectSpread(_objectSpread({}, appConfig.headers?.csp), {}, {
1298
1288
  // We need to make sure the URL we use in these CSP headers have a slash in the end,
1299
1289
  // otherwise it might create an invalid value when application/CDN URL points to a
1300
1290
  // non-root directory (ex: https://www.my-domain.com/app). This is a valid URL but from
1301
1291
  // the CSP point of view, it will say only the file `app` can be used as a source, so
1302
1292
  // any other file from that domain will be forbidden. Using the slash (ex: https://www.my-domain.com/app/)
1303
1293
  // at the end it's like using a wildcard so anything 'below' `app` will be allowed.
1304
- '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), "/")] : [])),
1305
- '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), "/")] : []),
1306
- '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), "/")] : [])
1294
+ 'connect-src': getUniqueValues(appConfig.headers?.csp?.['connect-src'], _concatInstanceProperty__default["default"](_context = [mcApiUrl.origin]).call(_context, isProd ? [`${trimTrailingSlash(appUrl.href)}/`] : [])),
1295
+ 'script-src': getUniqueValues(appConfig.headers?.csp?.['script-src'], isProd ? [`${trimTrailingSlash(appUrl.href)}/`, `${trimTrailingSlash(cdnUrl.href)}/`] : []),
1296
+ 'style-src': getUniqueValues(appConfig.headers?.csp?.['style-src'], isProd ? [`${trimTrailingSlash(appUrl.href)}/`, `${trimTrailingSlash(cdnUrl.href)}/`] : [])
1307
1297
  })
1308
1298
  })
1309
1299
  };