@commercetools-frontend/application-config 24.10.0 → 24.12.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.
@@ -8,8 +8,8 @@ import _Object$defineProperties from '@babel/runtime-corejs3/core-js-stable/obje
8
8
  import _Object$defineProperty from '@babel/runtime-corejs3/core-js-stable/object/define-property';
9
9
  import _defineProperty from '@babel/runtime-corejs3/helpers/esm/defineProperty';
10
10
  import _includesInstanceProperty from '@babel/runtime-corejs3/core-js-stable/instance/includes';
11
- import _URL from '@babel/runtime-corejs3/core-js-stable/url';
12
11
  import _concatInstanceProperty from '@babel/runtime-corejs3/core-js-stable/instance/concat';
12
+ import _URL from '@babel/runtime-corejs3/core-js-stable/url';
13
13
  import fs$1 from 'node:fs';
14
14
  import path, { parse } from 'node:path';
15
15
  import omitEmpty from 'omit-empty-es';
@@ -32,7 +32,7 @@ import _trimInstanceProperty from '@babel/runtime-corejs3/core-js-stable/instanc
32
32
  import _JSON$stringify from '@babel/runtime-corejs3/core-js-stable/json/stringify';
33
33
  import _startsWithInstanceProperty from '@babel/runtime-corejs3/core-js-stable/instance/starts-with';
34
34
  import _reduceInstanceProperty from '@babel/runtime-corejs3/core-js-stable/instance/reduce';
35
- import { f as formatEntryPointUriPathToResourceAccessKey, e as entryPointUriPathToResourceAccesses } from './formatters-882eafa8.esm.js';
35
+ import { f as formatEntryPointUriPathToResourceAccessKey, e as entryPointUriPathToResourceAccesses } from './formatters-80a6c235.esm.js';
36
36
  import _Set from '@babel/runtime-corejs3/core-js-stable/set';
37
37
  import _Array$isArray from '@babel/runtime-corejs3/core-js-stable/array/is-array';
38
38
  import Ajv from 'ajv';
@@ -112,10 +112,11 @@ const isDynamicAwaitSupported = () => {
112
112
  const isEsmModule = async cwd => {
113
113
  const packagePath = path.join(cwd, 'package.json');
114
114
  try {
115
+ var _JSON$parse;
115
116
  const packageJSON = await fs.readFile(packagePath, {
116
117
  encoding: 'utf-8'
117
118
  });
118
- return JSON.parse(packageJSON)?.type === 'module';
119
+ return ((_JSON$parse = JSON.parse(packageJSON)) === null || _JSON$parse === void 0 ? void 0 : _JSON$parse.type) === 'module';
119
120
  } catch (error) {
120
121
  return false;
121
122
  }
@@ -135,7 +136,7 @@ const createExplorerFor = async configFileName => {
135
136
  const loaders = isDynamicAwaitSupported() || (await isEsmModule(process.cwd())) ? defaultLoaders : defaultLoadersSync;
136
137
  return cosmiconfig(configFileName, {
137
138
  searchStrategy: 'project',
138
- searchPlaces: [`${configFileName}.js`, `${configFileName}.cjs`, `${configFileName}.mjs`, `${configFileName}.ts`],
139
+ searchPlaces: ["".concat(configFileName, ".js"), "".concat(configFileName, ".cjs"), "".concat(configFileName, ".mjs"), "".concat(configFileName, ".ts")],
139
140
  loaders: {
140
141
  '.js': loaders['.js'],
141
142
  '.cjs': loaders['.cjs'],
@@ -150,9 +151,9 @@ const getConfigPath = async () => {
150
151
  const customApplicationConfigFile = await customApplicationExplorer.search();
151
152
  const customViewConfigFile = await customViewExplorer.search();
152
153
  if (!customApplicationConfigFile && !customViewConfigFile) {
153
- throw new Error(`Missing or invalid configuration file.`);
154
+ throw new Error("Missing or invalid configuration file.");
154
155
  }
155
- return customApplicationConfigFile?.filepath || customViewConfigFile?.filepath;
156
+ return (customApplicationConfigFile === null || customApplicationConfigFile === void 0 ? void 0 : customApplicationConfigFile.filepath) || (customViewConfigFile === null || customViewConfigFile === void 0 ? void 0 : customViewConfigFile.filepath);
156
157
  };
157
158
  const loadConfig = async applicationPath => {
158
159
  const customApplicationExplorer = await createExplorerFor('custom-application-config');
@@ -160,10 +161,10 @@ const loadConfig = async applicationPath => {
160
161
  const customApplicationConfigFile = await customApplicationExplorer.search(applicationPath);
161
162
  const customViewConfigFile = await customViewExplorer.search(applicationPath);
162
163
  if ((!customApplicationConfigFile || !customApplicationConfigFile.config) && (!customViewConfigFile || !customViewConfigFile.config)) {
163
- throw new MissingOrInvalidConfigError(`Missing or invalid configuration file.`);
164
+ throw new MissingOrInvalidConfigError("Missing or invalid configuration file.");
164
165
  }
165
166
  if (customApplicationConfigFile && customViewConfigFile) {
166
- throw new MissingOrInvalidConfigError(`Found configuration files for both Custom Application and Custom View. Please remove one of them.`);
167
+ throw new MissingOrInvalidConfigError("Found configuration files for both Custom Application and Custom View. Please remove one of them.");
167
168
  }
168
169
  return customViewConfigFile || customApplicationConfigFile;
169
170
  };
@@ -192,35 +193,37 @@ Boolean(valueOfEnvConfig.match(variableSyntax));
192
193
  const isEnvVariablePlaceholder = valueOfPlaceholder => Boolean(valueOfPlaceholder.match(envRefSyntax));
193
194
  const isIntlVariablePlaceholder = valueOfPlaceholder => Boolean(valueOfPlaceholder.match(intlRefSyntax));
194
195
  const isFilePathVariablePlaceholder = valueOfPlaceholder => Boolean(valueOfPlaceholder.match(filePathRefSyntax));
195
- const isStructuredJson = message => message?.string !== undefined;
196
+ const isStructuredJson = message => (message === null || message === void 0 ? void 0 : message.string) !== undefined;
196
197
  const substituteEnvVariablePlaceholder = (valueOfPlaceholder, matchedString, valueOfEnvConfig, loadingOptions) => {
197
198
  const _valueOfPlaceholder$s = valueOfPlaceholder.split(':'),
198
199
  _valueOfPlaceholder$s2 = _slicedToArray(_valueOfPlaceholder$s, 2),
199
200
  requestedEnvVar = _valueOfPlaceholder$s2[1];
200
201
  const hasEnvField = loadingOptions.processEnv.hasOwnProperty(requestedEnvVar);
201
202
  if (!hasEnvField) {
202
- throw new Error(`Missing environment variable '${requestedEnvVar}' specified in config as 'env:${requestedEnvVar}'.`);
203
+ var _context;
204
+ throw new Error(_concatInstanceProperty(_context = "Missing environment variable '".concat(requestedEnvVar, "' specified in config as 'env:")).call(_context, requestedEnvVar, "'."));
203
205
  }
204
206
  const escapedMatchedString = matchedString.replace(/[${}:]/g, '\\$&');
205
- return valueOfEnvConfig.replace(new RegExp(`(${escapedMatchedString})+`, 'g'), loadingOptions.processEnv[requestedEnvVar]);
207
+ return valueOfEnvConfig.replace(new RegExp("(".concat(escapedMatchedString, ")+"), 'g'), loadingOptions.processEnv[requestedEnvVar]);
206
208
  };
207
209
  const substituteIntlVariablePlaceholder = (valueOfPlaceholder, matchedString, valueOfEnvConfig, loadingOptions) => {
208
210
  const _valueOfPlaceholder$s3 = valueOfPlaceholder.split(':'),
209
211
  _valueOfPlaceholder$s4 = _slicedToArray(_valueOfPlaceholder$s3, 3),
210
212
  locale = _valueOfPlaceholder$s4[1],
211
213
  requestedIntlMessageId = _valueOfPlaceholder$s4[2];
212
- const translationsFilePath = require.resolve(`./i18n/data/${locale}.json`, {
213
- paths: [`${loadingOptions.applicationPath}/src`, loadingOptions.applicationPath]
214
+ const translationsFilePath = require.resolve("./i18n/data/".concat(locale, ".json"), {
215
+ paths: ["".concat(loadingOptions.applicationPath, "/src"), loadingOptions.applicationPath]
214
216
  });
215
217
  const translations = require(translationsFilePath);
216
218
  const hasIntlMessage = translations.hasOwnProperty(requestedIntlMessageId);
217
219
  if (!hasIntlMessage) {
218
- throw new Error(`Missing message key '${requestedIntlMessageId}' specified in config as 'intl:${locale}:${requestedIntlMessageId}'.`);
220
+ var _context2, _context3;
221
+ throw new Error(_concatInstanceProperty(_context2 = _concatInstanceProperty(_context3 = "Missing message key '".concat(requestedIntlMessageId, "' specified in config as 'intl:")).call(_context3, locale, ":")).call(_context2, requestedIntlMessageId, "'."));
219
222
  }
220
223
  const translation = translations[requestedIntlMessageId];
221
224
  const translationValue = isStructuredJson(translation) ? translation.string : translation;
222
225
  const escapedMatchedString = matchedString.replace(/[${}:]/g, '\\$&');
223
- return valueOfEnvConfig.replace(new RegExp(`(${escapedMatchedString})+`, 'g'), translationValue);
226
+ return valueOfEnvConfig.replace(new RegExp("(".concat(escapedMatchedString, ")+"), 'g'), translationValue);
224
227
  };
225
228
  const substituteFilePathVariablePlaceholder = (valueOfPlaceholder, matchedString, valueOfEnvConfig, loadingOptions) => {
226
229
  const _valueOfPlaceholder$s5 = valueOfPlaceholder.split(':'),
@@ -233,7 +236,7 @@ const substituteFilePathVariablePlaceholder = (valueOfPlaceholder, matchedString
233
236
  encoding: 'utf-8'
234
237
  });
235
238
  const escapedMatchedString = matchedString.replace(/[${}:]/g, '\\$&');
236
- return valueOfEnvConfig.replace(new RegExp(`(${escapedMatchedString})+`, 'g'), content);
239
+ return valueOfEnvConfig.replace(new RegExp("(".concat(escapedMatchedString, ")+"), 'g'), content);
237
240
  };
238
241
  const getValueOfPlaceholder = valueWithPlaceholder => valueWithPlaceholder.replace(variableSyntax, (_match, varName) => _trimInstanceProperty(varName).call(varName)).replace(/\s/g, '');
239
242
  const substituteVariablePlaceholders = (config, loadingOptions) => JSON.parse(_JSON$stringify(config), (_key, value) => {
@@ -926,12 +929,13 @@ const printErrors = errors => {
926
929
  return 'No errors';
927
930
  }
928
931
  return _mapInstanceProperty(errors).call(errors, error => {
929
- const baseMessage = `${error.instancePath} ${error.message}`;
932
+ var _context, _context2, _context3;
933
+ const baseMessage = _concatInstanceProperty(_context = "".concat(error.instancePath, " ")).call(_context, error.message);
930
934
  switch (error.keyword) {
931
935
  case 'additionalProperties':
932
- return `${baseMessage}: ${error.params.additionalProperty}`;
936
+ return _concatInstanceProperty(_context2 = "".concat(baseMessage, ": ")).call(_context2, error.params.additionalProperty);
933
937
  case 'enum':
934
- return `${baseMessage}: ${error.params.allowedValues.toString()}`;
938
+ return _concatInstanceProperty(_context3 = "".concat(baseMessage, ": ")).call(_context3, error.params.allowedValues.toString());
935
939
  default:
936
940
  return baseMessage;
937
941
  }
@@ -944,7 +948,8 @@ const validateConfig = (configType, config) => {
944
948
  } else if (configType === LOADED_CONFIG_TYPES.CUSTOM_VIEW) {
945
949
  validation = validateCustomViewConfig;
946
950
  } else {
947
- throw new Error(`Invalid config type "${configType}", expected ${_Object$keys(LOADED_CONFIG_TYPES).toString()}`);
951
+ var _context4;
952
+ throw new Error(_concatInstanceProperty(_context4 = "Invalid config type \"".concat(configType, "\", expected ")).call(_context4, _Object$keys(LOADED_CONFIG_TYPES).toString()));
948
953
  }
949
954
  const isValid = validation(config);
950
955
  if (!isValid) {
@@ -957,9 +962,9 @@ const validateEntryPointUriPath = config => {
957
962
  }
958
963
  };
959
964
  const validateSubmenuLinks = config => {
960
- var _context;
965
+ var _context5;
961
966
  const uriPathSet = new _Set();
962
- _forEachInstanceProperty(_context = config.submenuLinks).call(_context, _ref => {
967
+ _forEachInstanceProperty(_context5 = config.submenuLinks).call(_context5, _ref => {
963
968
  let uriPath = _ref.uriPath;
964
969
  if (uriPathSet.has(uriPath)) {
965
970
  throw new Error('Duplicate URI path. Every submenu link must have a unique URI path value');
@@ -968,62 +973,64 @@ const validateSubmenuLinks = config => {
968
973
  });
969
974
  };
970
975
  const validateAdditionalOAuthScopes = config => {
976
+ var _config$additionalOAu;
971
977
  const additionalPermissionNames = new _Set();
972
- config.additionalOAuthScopes?.forEach(_ref2 => {
978
+ (_config$additionalOAu = config.additionalOAuthScopes) === null || _config$additionalOAu === void 0 || _forEachInstanceProperty(_config$additionalOAu).call(_config$additionalOAu, _ref2 => {
973
979
  let name = _ref2.name,
974
980
  view = _ref2.view,
975
981
  manage = _ref2.manage;
976
982
  if ((_Array$isArray(view) && view.length === 0 || !view) && (_Array$isArray(manage) && manage.length === 0 || !manage)) {
977
- throw new Error(`At least one OAuth Scope for permission group name "${name}" is required`);
983
+ throw new Error("At least one OAuth Scope for permission group name \"".concat(name, "\" is required"));
978
984
  } else if (additionalPermissionNames.has(name)) {
979
- throw new Error(`Duplicate additional permission group name "${name}". Every additional permission must have a unique name`);
985
+ throw new Error("Duplicate additional permission group name \"".concat(name, "\". Every additional permission must have a unique name"));
980
986
  }
981
987
  if (!name.match(PERMISSION_GROUP_NAME_REGEX)) {
982
- 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`);
988
+ 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"));
983
989
  }
984
990
  additionalPermissionNames.add(name);
985
991
  });
986
992
  };
987
993
 
988
994
  function ownKeys$1(e, r) { var t = _Object$keys(e); if (_Object$getOwnPropertySymbols) { var o = _Object$getOwnPropertySymbols(e); r && (o = _filterInstanceProperty(o).call(o, function (r) { return _Object$getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
989
- 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(_context4 = ownKeys$1(Object(t), !0)).call(_context4, function (r) { _defineProperty(e, r, t[r]); }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(e, _Object$getOwnPropertyDescriptors(t)) : _forEachInstanceProperty(_context5 = ownKeys$1(Object(t))).call(_context5, function (r) { _Object$defineProperty(e, r, _Object$getOwnPropertyDescriptor(t, r)); }); } return e; }
995
+ 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(_context5 = ownKeys$1(Object(t), !0)).call(_context5, function (r) { _defineProperty(e, r, t[r]); }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(e, _Object$getOwnPropertyDescriptors(t)) : _forEachInstanceProperty(_context6 = ownKeys$1(Object(t))).call(_context6, function (r) { _Object$defineProperty(e, r, _Object$getOwnPropertyDescriptor(t, r)); }); } return e; }
990
996
 
991
997
  // The `uriPath` of each submenu link is supposed to be defined relative
992
998
  // to the `entryPointUriPath`. Computing the full path is done internally to keep
993
999
  // the configuration simple.
994
1000
  const computeUriPath = (uriPath, entryPointUriPath) => {
1001
+ var _context;
995
1002
  // In case the `uriPath` is only `/`, it means that the link is supposed to be
996
1003
  // treated the same as the main application path. In this case, the return value
997
1004
  // should not contain any unnecessary trailing slash and therefore we use the `entryPointUriPath`.
998
1005
  if (uriPath === '/') return entryPointUriPath;
999
1006
  // In case the `uriPath` is already configured including the `entryPointUriPath`,
1000
1007
  // we return the `uriPath` as-is.
1001
- if (_startsWithInstanceProperty(uriPath).call(uriPath, `${entryPointUriPath}/`)) return uriPath;
1008
+ if (_startsWithInstanceProperty(uriPath).call(uriPath, "".concat(entryPointUriPath, "/"))) return uriPath;
1002
1009
  // Return the full path including the `entryPointUriPath` as a prefix.
1003
- return `${entryPointUriPath}/${uriPath}`;
1010
+ return _concatInstanceProperty(_context = "".concat(entryPointUriPath, "/")).call(_context, uriPath);
1004
1011
  };
1005
1012
  const getPermissions = appConfig => {
1006
- var _context, _context2;
1007
- const additionalResourceAccessKeyToOauthScopeMap = _reduceInstanceProperty(_context = appConfig.additionalOAuthScopes || []).call(_context, (previousOauthScope, _ref) => {
1013
+ var _context2, _appConfig$additional, _context3;
1014
+ const additionalResourceAccessKeyToOauthScopeMap = _reduceInstanceProperty(_context2 = appConfig.additionalOAuthScopes || []).call(_context2, (previousOauthScope, _ref) => {
1008
1015
  let name = _ref.name,
1009
1016
  view = _ref.view,
1010
1017
  manage = _ref.manage;
1011
1018
  const formattedResourceKey = formatEntryPointUriPathToResourceAccessKey(name);
1012
1019
  return _objectSpread$1(_objectSpread$1({}, previousOauthScope), {}, {
1013
- [`view${formattedResourceKey}`]: view,
1014
- [`manage${formattedResourceKey}`]: manage
1020
+ ["view".concat(formattedResourceKey)]: view,
1021
+ ["manage".concat(formattedResourceKey)]: manage
1015
1022
  });
1016
1023
  }, {});
1017
- const additionalPermissionNames = appConfig.additionalOAuthScopes?.map(_ref2 => {
1024
+ const additionalPermissionNames = ((_appConfig$additional = appConfig.additionalOAuthScopes) === null || _appConfig$additional === void 0 ? void 0 : _mapInstanceProperty(_appConfig$additional).call(_appConfig$additional, _ref2 => {
1018
1025
  let name = _ref2.name;
1019
1026
  return name;
1020
- }) || [];
1027
+ })) || [];
1021
1028
  const permissionKeys = entryPointUriPathToResourceAccesses(appConfig.entryPointUriPath ||
1022
1029
  // In case the `entryPointUriPath` is not defined it is because the
1023
1030
  // configuration is for a custom view. In this case we use the
1024
1031
  // default entry point uri path.
1025
1032
  CUSTOM_VIEW_HOST_ENTRY_POINT_URI_PATH, additionalPermissionNames);
1026
- const additionalPermissions = _mapInstanceProperty(_context2 = _Object$keys(additionalResourceAccessKeyToOauthScopeMap)).call(_context2, additionalResourceAccessKey => ({
1033
+ const additionalPermissions = _mapInstanceProperty(_context3 = _Object$keys(additionalResourceAccessKeyToOauthScopeMap)).call(_context3, additionalResourceAccessKey => ({
1027
1034
  name: permissionKeys[additionalResourceAccessKey],
1028
1035
  oAuthScopes: additionalResourceAccessKeyToOauthScopeMap[additionalResourceAccessKey]
1029
1036
  }));
@@ -1036,7 +1043,7 @@ const getPermissions = appConfig => {
1036
1043
  }, ...additionalPermissions];
1037
1044
  };
1038
1045
  function transformCustomApplicationConfigToData(appConfig) {
1039
- var _context3;
1046
+ var _context4;
1040
1047
  validateEntryPointUriPath(appConfig);
1041
1048
  validateSubmenuLinks(appConfig);
1042
1049
  validateAdditionalOAuthScopes(appConfig);
@@ -1049,7 +1056,7 @@ function transformCustomApplicationConfigToData(appConfig) {
1049
1056
  permissions: getPermissions(appConfig),
1050
1057
  icon: appConfig.icon,
1051
1058
  mainMenuLink: appConfig.mainMenuLink,
1052
- submenuLinks: _mapInstanceProperty(_context3 = appConfig.submenuLinks).call(_context3, submenuLink => _objectSpread$1(_objectSpread$1({}, submenuLink), {}, {
1059
+ submenuLinks: _mapInstanceProperty(_context4 = appConfig.submenuLinks).call(_context4, submenuLink => _objectSpread$1(_objectSpread$1({}, submenuLink), {}, {
1053
1060
  uriPath: computeUriPath(submenuLink.uriPath, appConfig.entryPointUriPath)
1054
1061
  }))
1055
1062
  };
@@ -1074,11 +1081,12 @@ function transformConfigurationToData(configType, configuration) {
1074
1081
  } else if (configType === LOADED_CONFIG_TYPES.CUSTOM_VIEW) {
1075
1082
  return transformCustomViewConfigToData(configuration);
1076
1083
  } else {
1077
- throw new Error(`Invalid config type: ${configType}`);
1084
+ throw new Error("Invalid config type: ".concat(configType));
1078
1085
  }
1079
1086
  }
1080
1087
 
1081
1088
  const mapCloudIdentifierToApiUrl = key => {
1089
+ var _context;
1082
1090
  switch (key) {
1083
1091
  case CLOUD_IDENTIFIERS.GCP_AU:
1084
1092
  return MC_API_URLS[CLOUD_IDENTIFIERS.GCP_AU];
@@ -1095,7 +1103,7 @@ const mapCloudIdentifierToApiUrl = key => {
1095
1103
  default:
1096
1104
  // We would probably never get to this point, as the JSON schema validation
1097
1105
  // kicks in before.
1098
- throw new Error(`Unknown cloud identifier "${key}". Supported values: ${_Object$values(CLOUD_IDENTIFIERS).toString()}`);
1106
+ throw new Error(_concatInstanceProperty(_context = "Unknown cloud identifier \"".concat(key, "\". Supported values: ")).call(_context, _Object$values(CLOUD_IDENTIFIERS).toString()));
1099
1107
  }
1100
1108
  };
1101
1109
  const getUniqueValues = function () {
@@ -1119,10 +1127,10 @@ const getOrThrow = (fn, errorMessage) => {
1119
1127
  };
1120
1128
 
1121
1129
  function ownKeys(e, r) { var t = _Object$keys(e); if (_Object$getOwnPropertySymbols) { var o = _Object$getOwnPropertySymbols(e); r && (o = _filterInstanceProperty(o).call(o, function (r) { return _Object$getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
1122
- function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var _context2, _context3; var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? _forEachInstanceProperty(_context2 = ownKeys(Object(t), !0)).call(_context2, function (r) { _defineProperty(e, r, t[r]); }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(e, _Object$getOwnPropertyDescriptors(t)) : _forEachInstanceProperty(_context3 = ownKeys(Object(t))).call(_context3, function (r) { _Object$defineProperty(e, r, _Object$getOwnPropertyDescriptor(t, r)); }); } return e; }
1130
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var _context4, _context5; var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? _forEachInstanceProperty(_context4 = ownKeys(Object(t), !0)).call(_context4, function (r) { _defineProperty(e, r, t[r]); }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(e, _Object$getOwnPropertyDescriptors(t)) : _forEachInstanceProperty(_context5 = ownKeys(Object(t))).call(_context5, function (r) { _Object$defineProperty(e, r, _Object$getOwnPropertyDescriptor(t, r)); }); } return e; }
1123
1131
  // TODO: make it configurable.
1124
1132
  const developmentPort = 3001;
1125
- const developmentAppUrl = `http://localhost:${developmentPort}`;
1133
+ const developmentAppUrl = "http://localhost:".concat(developmentPort);
1126
1134
  const getLoadedConfigurationType = configFileName => {
1127
1135
  if (_includesInstanceProperty(configFileName).call(configFileName, 'custom-view-config')) {
1128
1136
  return LOADED_CONFIG_TYPES.CUSTOM_VIEW;
@@ -1138,6 +1146,7 @@ const omitDevConfigIfEmpty = devConfig => {
1138
1146
  };
1139
1147
  const isCustomViewData = data => data.entryPointUriPath === undefined;
1140
1148
  const getRuntimeEnvironmentConfigForDevelopment = _ref => {
1149
+ var _appConfig$env$develo;
1141
1150
  let isProd = _ref.isProd,
1142
1151
  configurationData = _ref.configurationData,
1143
1152
  mcApiUrl = _ref.mcApiUrl,
@@ -1154,7 +1163,7 @@ const getRuntimeEnvironmentConfigForDevelopment = _ref => {
1154
1163
  initialProjectKey:
1155
1164
  // For the `account` application, we should unset the projectKey.
1156
1165
  entryPointUriPath === 'account' ? undefined : appConfig.env.development.initialProjectKey
1157
- }, appConfig.env.development?.teamId && _objectSpread({
1166
+ }, ((_appConfig$env$develo = appConfig.env.development) === null || _appConfig$env$develo === void 0 ? void 0 : _appConfig$env$develo.teamId) && _objectSpread({
1158
1167
  teamId: appConfig.env.development.teamId
1159
1168
  }, isCustomViewData(configurationData) ? {
1160
1169
  customViewId: configurationData.id
@@ -1162,11 +1171,12 @@ const getRuntimeEnvironmentConfigForDevelopment = _ref => {
1162
1171
  applicationId: configurationData.id
1163
1172
  })), {}, {
1164
1173
  oAuthScopes: appConfig.oAuthScopes,
1165
- additionalOAuthScopes: appConfig?.additionalOAuthScopes
1174
+ additionalOAuthScopes: appConfig === null || appConfig === void 0 ? void 0 : appConfig.additionalOAuthScopes
1166
1175
  }));
1167
1176
  if (isCustomViewData(configurationData)) {
1177
+ var _context;
1168
1178
  const hostUriPath = appConfig.env.development.hostUriPath;
1169
- const defaultHostUriPath = oidcConfig.initialProjectKey ? `/${oidcConfig.initialProjectKey}/${entryPointUriPath}` : `/${entryPointUriPath}`;
1179
+ const defaultHostUriPath = oidcConfig.initialProjectKey ? _concatInstanceProperty(_context = "/".concat(oidcConfig.initialProjectKey, "/")).call(_context, entryPointUriPath) : "/".concat(entryPointUriPath);
1170
1180
  const hostUrl = new _URL(hostUriPath || defaultHostUriPath, developmentAppUrl);
1171
1181
  return omitDevConfigIfEmpty({
1172
1182
  oidc: oidcConfig,
@@ -1188,6 +1198,7 @@ const getRuntimeEnvironmentConfigForDevelopment = _ref => {
1188
1198
  });
1189
1199
  };
1190
1200
  const getRuntimeEnvironmentConfig = _ref2 => {
1201
+ var _context2;
1191
1202
  let isProd = _ref2.isProd,
1192
1203
  configurationData = _ref2.configurationData,
1193
1204
  additionalAppEnv = _ref2.additionalAppEnv,
@@ -1206,7 +1217,7 @@ const getRuntimeEnvironmentConfig = _ref2 => {
1206
1217
  // In development, we prefix the entry point with the "__local" prefix.
1207
1218
  // This is important to determine to which URL the MC should redirect to
1208
1219
  // after successful login.
1209
- const applicationIdentifier = isProd ? `${configurationData.id}:${entryPointUriPath}` : `__local:${entryPointUriPath}`;
1220
+ const applicationIdentifier = isProd ? _concatInstanceProperty(_context2 = "".concat(configurationData.id, ":")).call(_context2, entryPointUriPath) : "__local:".concat(entryPointUriPath);
1210
1221
  const developmentConfig = getRuntimeEnvironmentConfigForDevelopment({
1211
1222
  isProd,
1212
1223
  configurationData,
@@ -1238,7 +1249,7 @@ const getRuntimeEnvironmentConfig = _ref2 => {
1238
1249
  // again will result in returning the cached value.
1239
1250
  let cachedConfig;
1240
1251
  const processConfig = async function () {
1241
- var _context;
1252
+ var _ref4, _processEnv$MC_APP_EN, _appConfig$additional, _ref5, _appConfig$headers, _appConfig$headers2, _context3, _appConfig$headers3, _appConfig$headers4;
1242
1253
  let _ref3 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
1243
1254
  _ref3$disableCache = _ref3.disableCache,
1244
1255
  disableCache = _ref3$disableCache === void 0 ? false : _ref3$disableCache,
@@ -1257,22 +1268,22 @@ const processConfig = async function () {
1257
1268
  processEnv
1258
1269
  });
1259
1270
  const configurationData = transformConfigurationToData(configType, appConfig);
1260
- const appEnvKey = processEnv.MC_APP_ENV ?? processEnv.NODE_ENV ?? 'development';
1271
+ 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';
1261
1272
  const isProd = getIsProd(processEnv);
1262
- const additionalAppEnv = appConfig.additionalEnv ?? {};
1263
- const revision = additionalAppEnv.revision ?? '';
1273
+ const additionalAppEnv = (_appConfig$additional = appConfig.additionalEnv) !== null && _appConfig$additional !== void 0 ? _appConfig$additional : {};
1274
+ const revision = (_ref5 = additionalAppEnv.revision) !== null && _ref5 !== void 0 ? _ref5 : '';
1264
1275
 
1265
1276
  // Parse all the supported URLs, which gets implicitly validated
1266
1277
 
1267
1278
  const envAppUrl = isProd ? configurationData.url : developmentAppUrl;
1268
- const appUrl = getOrThrow(() => new _URL(envAppUrl), `Invalid application URL: "${envAppUrl}"`);
1279
+ const appUrl = getOrThrow(() => new _URL(envAppUrl), "Invalid application URL: \"".concat(envAppUrl, "\""));
1269
1280
 
1270
1281
  // Use `||` instead of `??` to include empty string values.
1271
1282
  const envCdnUrl = isProd ? appConfig.env.production.cdnUrl || appUrl.href : developmentAppUrl;
1272
- const cdnUrl = getOrThrow(() => new _URL(envCdnUrl), `Invalid application CDN URL: "${envCdnUrl}"`);
1283
+ const cdnUrl = getOrThrow(() => new _URL(envCdnUrl), "Invalid application CDN URL: \"".concat(envCdnUrl, "\""));
1273
1284
  const mcApiUrl = getOrThrow(() => new _URL(
1274
1285
  // Use `||` instead of `??` to include empty string values.
1275
- appConfig.mcApiUrl || mapCloudIdentifierToApiUrl(appConfig.cloudIdentifier)), `Invalid MC API URL: "${appConfig.mcApiUrl}"`);
1286
+ appConfig.mcApiUrl || mapCloudIdentifierToApiUrl(appConfig.cloudIdentifier)), "Invalid MC API URL: \"".concat(appConfig.mcApiUrl, "\""));
1276
1287
  cachedConfig = {
1277
1288
  data: configurationData,
1278
1289
  env: getRuntimeEnvironmentConfig({
@@ -1287,16 +1298,16 @@ const processConfig = async function () {
1287
1298
  revision
1288
1299
  }),
1289
1300
  headers: _objectSpread(_objectSpread({}, appConfig.headers), {}, {
1290
- csp: _objectSpread(_objectSpread({}, appConfig.headers?.csp), {}, {
1301
+ csp: _objectSpread(_objectSpread({}, (_appConfig$headers = appConfig.headers) === null || _appConfig$headers === void 0 ? void 0 : _appConfig$headers.csp), {}, {
1291
1302
  // We need to make sure the URL we use in these CSP headers have a slash in the end,
1292
1303
  // otherwise it might create an invalid value when application/CDN URL points to a
1293
1304
  // non-root directory (ex: https://www.my-domain.com/app). This is a valid URL but from
1294
1305
  // the CSP point of view, it will say only the file `app` can be used as a source, so
1295
1306
  // any other file from that domain will be forbidden. Using the slash (ex: https://www.my-domain.com/app/)
1296
1307
  // at the end it's like using a wildcard so anything 'below' `app` will be allowed.
1297
- 'connect-src': getUniqueValues(appConfig.headers?.csp?.['connect-src'], _concatInstanceProperty(_context = [mcApiUrl.origin]).call(_context, isProd ? [`${trimTrailingSlash(appUrl.href)}/`, `${trimTrailingSlash(cdnUrl.href)}/`] : [])),
1298
- 'script-src': getUniqueValues(appConfig.headers?.csp?.['script-src'], isProd ? [`${trimTrailingSlash(appUrl.href)}/`, `${trimTrailingSlash(cdnUrl.href)}/`] : []),
1299
- 'style-src': getUniqueValues(appConfig.headers?.csp?.['style-src'], isProd ? [`${trimTrailingSlash(appUrl.href)}/`, `${trimTrailingSlash(cdnUrl.href)}/`] : [])
1308
+ '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(_context3 = [mcApiUrl.origin]).call(_context3, isProd ? ["".concat(trimTrailingSlash(appUrl.href), "/"), "".concat(trimTrailingSlash(cdnUrl.href), "/")] : [])),
1309
+ '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), "/")] : []),
1310
+ '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), "/")] : [])
1300
1311
  })
1301
1312
  })
1302
1313
  };
@@ -12,6 +12,7 @@ var _slicedToArray = require('@babel/runtime-corejs3/helpers/slicedToArray');
12
12
  var _defineProperty = require('@babel/runtime-corejs3/helpers/defineProperty');
13
13
  var _mapInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/map');
14
14
  var _reduceInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/reduce');
15
+ var _concatInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/concat');
15
16
  var _Object$entries = require('@babel/runtime-corejs3/core-js-stable/object/entries');
16
17
  var upperFirst = require('lodash/upperFirst');
17
18
  var constants = require('@commercetools-frontend/constants');
@@ -28,11 +29,12 @@ var _Object$defineProperties__default = /*#__PURE__*/_interopDefault(_Object$def
28
29
  var _Object$defineProperty__default = /*#__PURE__*/_interopDefault(_Object$defineProperty);
29
30
  var _mapInstanceProperty__default = /*#__PURE__*/_interopDefault(_mapInstanceProperty);
30
31
  var _reduceInstanceProperty__default = /*#__PURE__*/_interopDefault(_reduceInstanceProperty);
32
+ var _concatInstanceProperty__default = /*#__PURE__*/_interopDefault(_concatInstanceProperty);
31
33
  var _Object$entries__default = /*#__PURE__*/_interopDefault(_Object$entries);
32
34
  var upperFirst__default = /*#__PURE__*/_interopDefault(upperFirst);
33
35
 
34
36
  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; }
35
- function _objectSpread(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(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(Object(t))).call(_context7, function (r) { _Object$defineProperty__default["default"](e, r, _Object$getOwnPropertyDescriptor__default["default"](t, r)); }); } return e; }
37
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var _context8, _context9; var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? _forEachInstanceProperty__default["default"](_context8 = ownKeys(Object(t), !0)).call(_context8, function (r) { _defineProperty(e, r, t[r]); }) : _Object$getOwnPropertyDescriptors__default["default"] ? _Object$defineProperties__default["default"](e, _Object$getOwnPropertyDescriptors__default["default"](t)) : _forEachInstanceProperty__default["default"](_context9 = ownKeys(Object(t))).call(_context9, function (r) { _Object$defineProperty__default["default"](e, r, _Object$getOwnPropertyDescriptor__default["default"](t, r)); }); } return e; }
36
38
  /**
37
39
  * The function formats the `entryPointUriPath` to a resource access key.
38
40
  * It makes the first character of the string and the next character after a special character an uppercase.
@@ -60,7 +62,7 @@ const formatEntryPointUriPathToResourceAccessKey = entryPointUriPath => {
60
62
  // If the word after the hyphen is numeric, replace the hyphen with a forward slash.
61
63
  // If not, omit the hyphen and uppercase the first character
62
64
  if (i > 0 && /^-?\d+$/.test(word[0])) {
63
- return `/${word}`;
65
+ return "/".concat(word);
64
66
  }
65
67
  return upperFirst__default["default"](word);
66
68
  }).join('');
@@ -84,14 +86,15 @@ function entryPointUriPathToResourceAccesses(entryPointUriPath, permissionGroupN
84
86
  var _context4;
85
87
  const resourceAccessKey = constants.CUSTOM_VIEW_HOST_ENTRY_POINT_URI_PATH === entryPointUriPath ? '' : formatEntryPointUriPathToResourceAccessKey(entryPointUriPath);
86
88
  const defaultResourceAccesses = {
87
- view: `view${resourceAccessKey}`,
88
- manage: `manage${resourceAccessKey}`
89
+ view: "view".concat(resourceAccessKey),
90
+ manage: "manage".concat(resourceAccessKey)
89
91
  };
90
- const additionalResourceAccesses = _reduceInstanceProperty__default["default"](_context4 = permissionGroupNames ?? []).call(_context4, (resourceAccesses, permissionGroupName) => {
92
+ const additionalResourceAccesses = _reduceInstanceProperty__default["default"](_context4 = permissionGroupNames !== null && permissionGroupNames !== void 0 ? permissionGroupNames : []).call(_context4, (resourceAccesses, permissionGroupName) => {
93
+ var _context5, _context6;
91
94
  const additionalResourceAccessKey = formatPermissionGroupNameToResourceAccessKey(permissionGroupName);
92
95
  return _objectSpread(_objectSpread({}, resourceAccesses), {}, {
93
- [`view${additionalResourceAccessKey}`]: `${defaultResourceAccesses.view}${additionalResourceAccessKey}`,
94
- [`manage${additionalResourceAccessKey}`]: `${defaultResourceAccesses.manage}${additionalResourceAccessKey}`
96
+ ["view".concat(additionalResourceAccessKey)]: _concatInstanceProperty__default["default"](_context5 = "".concat(defaultResourceAccesses.view)).call(_context5, additionalResourceAccessKey),
97
+ ["manage".concat(additionalResourceAccessKey)]: _concatInstanceProperty__default["default"](_context6 = "".concat(defaultResourceAccesses.manage)).call(_context6, additionalResourceAccessKey)
95
98
  });
96
99
  }, {});
97
100
  return _objectSpread(_objectSpread({}, defaultResourceAccesses), additionalResourceAccesses);
@@ -103,9 +106,9 @@ function computeCustomViewPermissionsKeys(permissionGroupNames) {
103
106
  return entryPointUriPathToPermissionKeys(constants.CUSTOM_VIEW_HOST_ENTRY_POINT_URI_PATH, permissionGroupNames || []);
104
107
  }
105
108
  function entryPointUriPathToPermissionKeys(entryPointUriPath, permissionGroupNames) {
106
- var _context5;
107
- const resourceAccesses = entryPointUriPathToResourceAccesses(entryPointUriPath, permissionGroupNames ?? []);
108
- return _reduceInstanceProperty__default["default"](_context5 = _Object$entries__default["default"](resourceAccesses)).call(_context5, (permissionKeys, _ref) => {
109
+ var _context7;
110
+ const resourceAccesses = entryPointUriPathToResourceAccesses(entryPointUriPath, permissionGroupNames !== null && permissionGroupNames !== void 0 ? permissionGroupNames : []);
111
+ return _reduceInstanceProperty__default["default"](_context7 = _Object$entries__default["default"](resourceAccesses)).call(_context7, (permissionKeys, _ref) => {
109
112
  let _ref2 = _slicedToArray(_ref, 2),
110
113
  resourceAccessKey = _ref2[0],
111
114
  resourceAccessValue = _ref2[1];
@@ -10,12 +10,13 @@ import _slicedToArray from '@babel/runtime-corejs3/helpers/esm/slicedToArray';
10
10
  import _defineProperty from '@babel/runtime-corejs3/helpers/esm/defineProperty';
11
11
  import _mapInstanceProperty from '@babel/runtime-corejs3/core-js-stable/instance/map';
12
12
  import _reduceInstanceProperty from '@babel/runtime-corejs3/core-js-stable/instance/reduce';
13
+ import _concatInstanceProperty from '@babel/runtime-corejs3/core-js-stable/instance/concat';
13
14
  import _Object$entries from '@babel/runtime-corejs3/core-js-stable/object/entries';
14
15
  import upperFirst from 'lodash/upperFirst';
15
16
  import { CUSTOM_VIEW_HOST_ENTRY_POINT_URI_PATH } from '@commercetools-frontend/constants';
16
17
 
17
18
  function ownKeys(e, r) { var t = _Object$keys(e); if (_Object$getOwnPropertySymbols) { var o = _Object$getOwnPropertySymbols(e); r && (o = _filterInstanceProperty(o).call(o, function (r) { return _Object$getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
18
- function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var _context6, _context7; var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? _forEachInstanceProperty(_context6 = ownKeys(Object(t), !0)).call(_context6, function (r) { _defineProperty(e, r, t[r]); }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(e, _Object$getOwnPropertyDescriptors(t)) : _forEachInstanceProperty(_context7 = ownKeys(Object(t))).call(_context7, function (r) { _Object$defineProperty(e, r, _Object$getOwnPropertyDescriptor(t, r)); }); } return e; }
19
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var _context8, _context9; var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? _forEachInstanceProperty(_context8 = ownKeys(Object(t), !0)).call(_context8, function (r) { _defineProperty(e, r, t[r]); }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(e, _Object$getOwnPropertyDescriptors(t)) : _forEachInstanceProperty(_context9 = ownKeys(Object(t))).call(_context9, function (r) { _Object$defineProperty(e, r, _Object$getOwnPropertyDescriptor(t, r)); }); } return e; }
19
20
  /**
20
21
  * The function formats the `entryPointUriPath` to a resource access key.
21
22
  * It makes the first character of the string and the next character after a special character an uppercase.
@@ -43,7 +44,7 @@ const formatEntryPointUriPathToResourceAccessKey = entryPointUriPath => {
43
44
  // If the word after the hyphen is numeric, replace the hyphen with a forward slash.
44
45
  // If not, omit the hyphen and uppercase the first character
45
46
  if (i > 0 && /^-?\d+$/.test(word[0])) {
46
- return `/${word}`;
47
+ return "/".concat(word);
47
48
  }
48
49
  return upperFirst(word);
49
50
  }).join('');
@@ -67,14 +68,15 @@ function entryPointUriPathToResourceAccesses(entryPointUriPath, permissionGroupN
67
68
  var _context4;
68
69
  const resourceAccessKey = CUSTOM_VIEW_HOST_ENTRY_POINT_URI_PATH === entryPointUriPath ? '' : formatEntryPointUriPathToResourceAccessKey(entryPointUriPath);
69
70
  const defaultResourceAccesses = {
70
- view: `view${resourceAccessKey}`,
71
- manage: `manage${resourceAccessKey}`
71
+ view: "view".concat(resourceAccessKey),
72
+ manage: "manage".concat(resourceAccessKey)
72
73
  };
73
- const additionalResourceAccesses = _reduceInstanceProperty(_context4 = permissionGroupNames ?? []).call(_context4, (resourceAccesses, permissionGroupName) => {
74
+ const additionalResourceAccesses = _reduceInstanceProperty(_context4 = permissionGroupNames !== null && permissionGroupNames !== void 0 ? permissionGroupNames : []).call(_context4, (resourceAccesses, permissionGroupName) => {
75
+ var _context5, _context6;
74
76
  const additionalResourceAccessKey = formatPermissionGroupNameToResourceAccessKey(permissionGroupName);
75
77
  return _objectSpread(_objectSpread({}, resourceAccesses), {}, {
76
- [`view${additionalResourceAccessKey}`]: `${defaultResourceAccesses.view}${additionalResourceAccessKey}`,
77
- [`manage${additionalResourceAccessKey}`]: `${defaultResourceAccesses.manage}${additionalResourceAccessKey}`
78
+ ["view".concat(additionalResourceAccessKey)]: _concatInstanceProperty(_context5 = "".concat(defaultResourceAccesses.view)).call(_context5, additionalResourceAccessKey),
79
+ ["manage".concat(additionalResourceAccessKey)]: _concatInstanceProperty(_context6 = "".concat(defaultResourceAccesses.manage)).call(_context6, additionalResourceAccessKey)
78
80
  });
79
81
  }, {});
80
82
  return _objectSpread(_objectSpread({}, defaultResourceAccesses), additionalResourceAccesses);
@@ -86,9 +88,9 @@ function computeCustomViewPermissionsKeys(permissionGroupNames) {
86
88
  return entryPointUriPathToPermissionKeys(CUSTOM_VIEW_HOST_ENTRY_POINT_URI_PATH, permissionGroupNames || []);
87
89
  }
88
90
  function entryPointUriPathToPermissionKeys(entryPointUriPath, permissionGroupNames) {
89
- var _context5;
90
- const resourceAccesses = entryPointUriPathToResourceAccesses(entryPointUriPath, permissionGroupNames ?? []);
91
- return _reduceInstanceProperty(_context5 = _Object$entries(resourceAccesses)).call(_context5, (permissionKeys, _ref) => {
91
+ var _context7;
92
+ const resourceAccesses = entryPointUriPathToResourceAccesses(entryPointUriPath, permissionGroupNames !== null && permissionGroupNames !== void 0 ? permissionGroupNames : []);
93
+ return _reduceInstanceProperty(_context7 = _Object$entries(resourceAccesses)).call(_context7, (permissionKeys, _ref) => {
92
94
  let _ref2 = _slicedToArray(_ref, 2),
93
95
  resourceAccessKey = _ref2[0],
94
96
  resourceAccessValue = _ref2[1];
@@ -12,6 +12,7 @@ var _slicedToArray = require('@babel/runtime-corejs3/helpers/slicedToArray');
12
12
  var _defineProperty = require('@babel/runtime-corejs3/helpers/defineProperty');
13
13
  var _mapInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/map');
14
14
  var _reduceInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/reduce');
15
+ var _concatInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/concat');
15
16
  var _Object$entries = require('@babel/runtime-corejs3/core-js-stable/object/entries');
16
17
  var upperFirst = require('lodash/upperFirst');
17
18
  var constants = require('@commercetools-frontend/constants');
@@ -28,11 +29,12 @@ var _Object$defineProperties__default = /*#__PURE__*/_interopDefault(_Object$def
28
29
  var _Object$defineProperty__default = /*#__PURE__*/_interopDefault(_Object$defineProperty);
29
30
  var _mapInstanceProperty__default = /*#__PURE__*/_interopDefault(_mapInstanceProperty);
30
31
  var _reduceInstanceProperty__default = /*#__PURE__*/_interopDefault(_reduceInstanceProperty);
32
+ var _concatInstanceProperty__default = /*#__PURE__*/_interopDefault(_concatInstanceProperty);
31
33
  var _Object$entries__default = /*#__PURE__*/_interopDefault(_Object$entries);
32
34
  var upperFirst__default = /*#__PURE__*/_interopDefault(upperFirst);
33
35
 
34
36
  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; }
35
- function _objectSpread(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(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(Object(t))).call(_context7, function (r) { _Object$defineProperty__default["default"](e, r, _Object$getOwnPropertyDescriptor__default["default"](t, r)); }); } return e; }
37
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var _context8, _context9; var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? _forEachInstanceProperty__default["default"](_context8 = ownKeys(Object(t), !0)).call(_context8, function (r) { _defineProperty(e, r, t[r]); }) : _Object$getOwnPropertyDescriptors__default["default"] ? _Object$defineProperties__default["default"](e, _Object$getOwnPropertyDescriptors__default["default"](t)) : _forEachInstanceProperty__default["default"](_context9 = ownKeys(Object(t))).call(_context9, function (r) { _Object$defineProperty__default["default"](e, r, _Object$getOwnPropertyDescriptor__default["default"](t, r)); }); } return e; }
36
38
  /**
37
39
  * The function formats the `entryPointUriPath` to a resource access key.
38
40
  * It makes the first character of the string and the next character after a special character an uppercase.
@@ -60,7 +62,7 @@ const formatEntryPointUriPathToResourceAccessKey = entryPointUriPath => {
60
62
  // If the word after the hyphen is numeric, replace the hyphen with a forward slash.
61
63
  // If not, omit the hyphen and uppercase the first character
62
64
  if (i > 0 && /^-?\d+$/.test(word[0])) {
63
- return `/${word}`;
65
+ return "/".concat(word);
64
66
  }
65
67
  return upperFirst__default["default"](word);
66
68
  }).join('');
@@ -84,14 +86,15 @@ function entryPointUriPathToResourceAccesses(entryPointUriPath, permissionGroupN
84
86
  var _context4;
85
87
  const resourceAccessKey = constants.CUSTOM_VIEW_HOST_ENTRY_POINT_URI_PATH === entryPointUriPath ? '' : formatEntryPointUriPathToResourceAccessKey(entryPointUriPath);
86
88
  const defaultResourceAccesses = {
87
- view: `view${resourceAccessKey}`,
88
- manage: `manage${resourceAccessKey}`
89
+ view: "view".concat(resourceAccessKey),
90
+ manage: "manage".concat(resourceAccessKey)
89
91
  };
90
- const additionalResourceAccesses = _reduceInstanceProperty__default["default"](_context4 = permissionGroupNames ?? []).call(_context4, (resourceAccesses, permissionGroupName) => {
92
+ const additionalResourceAccesses = _reduceInstanceProperty__default["default"](_context4 = permissionGroupNames !== null && permissionGroupNames !== void 0 ? permissionGroupNames : []).call(_context4, (resourceAccesses, permissionGroupName) => {
93
+ var _context5, _context6;
91
94
  const additionalResourceAccessKey = formatPermissionGroupNameToResourceAccessKey(permissionGroupName);
92
95
  return _objectSpread(_objectSpread({}, resourceAccesses), {}, {
93
- [`view${additionalResourceAccessKey}`]: `${defaultResourceAccesses.view}${additionalResourceAccessKey}`,
94
- [`manage${additionalResourceAccessKey}`]: `${defaultResourceAccesses.manage}${additionalResourceAccessKey}`
96
+ ["view".concat(additionalResourceAccessKey)]: _concatInstanceProperty__default["default"](_context5 = "".concat(defaultResourceAccesses.view)).call(_context5, additionalResourceAccessKey),
97
+ ["manage".concat(additionalResourceAccessKey)]: _concatInstanceProperty__default["default"](_context6 = "".concat(defaultResourceAccesses.manage)).call(_context6, additionalResourceAccessKey)
95
98
  });
96
99
  }, {});
97
100
  return _objectSpread(_objectSpread({}, defaultResourceAccesses), additionalResourceAccesses);
@@ -103,9 +106,9 @@ function computeCustomViewPermissionsKeys(permissionGroupNames) {
103
106
  return entryPointUriPathToPermissionKeys(constants.CUSTOM_VIEW_HOST_ENTRY_POINT_URI_PATH, permissionGroupNames || []);
104
107
  }
105
108
  function entryPointUriPathToPermissionKeys(entryPointUriPath, permissionGroupNames) {
106
- var _context5;
107
- const resourceAccesses = entryPointUriPathToResourceAccesses(entryPointUriPath, permissionGroupNames ?? []);
108
- return _reduceInstanceProperty__default["default"](_context5 = _Object$entries__default["default"](resourceAccesses)).call(_context5, (permissionKeys, _ref) => {
109
+ var _context7;
110
+ const resourceAccesses = entryPointUriPathToResourceAccesses(entryPointUriPath, permissionGroupNames !== null && permissionGroupNames !== void 0 ? permissionGroupNames : []);
111
+ return _reduceInstanceProperty__default["default"](_context7 = _Object$entries__default["default"](resourceAccesses)).call(_context7, (permissionKeys, _ref) => {
109
112
  let _ref2 = _slicedToArray(_ref, 2),
110
113
  resourceAccessKey = _ref2[0],
111
114
  resourceAccessValue = _ref2[1];