@commercetools-frontend/application-config 21.3.2 → 21.3.3

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.
@@ -35,6 +35,7 @@ var _toConsumableArray = require('@babel/runtime-corejs3/helpers/toConsumableArr
35
35
  var _Object$values = require('@babel/runtime-corejs3/core-js-stable/object/values');
36
36
  var _includesInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/includes');
37
37
  var uniq = require('lodash/uniq');
38
+ var _startsWithInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/starts-with');
38
39
  var formatters = require('./formatters-41584280.cjs.dev.js');
39
40
  require('lodash/upperFirst');
40
41
 
@@ -61,6 +62,7 @@ var _JSON$stringify__default = /*#__PURE__*/_interopDefault(_JSON$stringify);
61
62
  var _Object$values__default = /*#__PURE__*/_interopDefault(_Object$values);
62
63
  var _includesInstanceProperty__default = /*#__PURE__*/_interopDefault(_includesInstanceProperty);
63
64
  var uniq__default = /*#__PURE__*/_interopDefault(uniq);
65
+ var _startsWithInstanceProperty__default = /*#__PURE__*/_interopDefault(_startsWithInstanceProperty);
64
66
 
65
67
  function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = _Reflect$construct__default["default"](Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
66
68
 
@@ -713,7 +715,29 @@ var getOrThrow = function getOrThrow(fn, errorMessage) {
713
715
  }
714
716
  };
715
717
 
718
+ function ownKeys$1(object, enumerableOnly) { var keys = _Object$keys__default["default"](object); if (_Object$getOwnPropertySymbols__default["default"]) { var symbols = _Object$getOwnPropertySymbols__default["default"](object); enumerableOnly && (symbols = _filterInstanceProperty__default["default"](symbols).call(symbols, function (sym) { return _Object$getOwnPropertyDescriptor__default["default"](object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
719
+
720
+ function _objectSpread$1(target) { for (var i = 1; i < arguments.length; i++) { var _context3, _context4; var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? _forEachInstanceProperty__default["default"](_context3 = ownKeys$1(Object(source), !0)).call(_context3, function (key) { _defineProperty(target, key, source[key]); }) : _Object$getOwnPropertyDescriptors__default["default"] ? _Object$defineProperties__default["default"](target, _Object$getOwnPropertyDescriptors__default["default"](source)) : _forEachInstanceProperty__default["default"](_context4 = ownKeys$1(Object(source))).call(_context4, function (key) { _Object$defineProperty__default["default"](target, key, _Object$getOwnPropertyDescriptor__default["default"](source, key)); }); } return target; }
721
+ // to the `entryPointUriPath`. Computing the full path is done internally to keep
722
+ // the configuration simple.
723
+
724
+ var computeUriPath = function computeUriPath(uriPath, entryPointUriPath) {
725
+ var _context;
726
+
727
+ // In case the `uriPath` is only `/`, it means that the link is supposed to be
728
+ // treated the same as the main application path. In this case, the return value
729
+ // should not contain any unnecessary trailing slash and therefore we use the `entryPointUriPath`.
730
+ if (uriPath === '/') return entryPointUriPath; // In case the `uriPath` is already configured including the `entryPointUriPath`,
731
+ // we return the `uriPath` as-is.
732
+
733
+ if (_startsWithInstanceProperty__default["default"](uriPath).call(uriPath, "".concat(entryPointUriPath, "/"))) return uriPath; // Return the full path including the `entryPointUriPath` as a prefix.
734
+
735
+ return _concatInstanceProperty__default["default"](_context = "".concat(entryPointUriPath, "/")).call(_context, uriPath);
736
+ };
737
+
716
738
  function transformCustomApplicationConfigToData(appConfig) {
739
+ var _context2;
740
+
717
741
  var permissionKeys = formatters.entryPointUriPathToResourceAccesses(appConfig.entryPointUriPath);
718
742
  return {
719
743
  id: appConfig.env.production.applicationId,
@@ -730,7 +754,11 @@ function transformCustomApplicationConfigToData(appConfig) {
730
754
  }],
731
755
  icon: appConfig.icon,
732
756
  mainMenuLink: appConfig.mainMenuLink,
733
- submenuLinks: appConfig.submenuLinks
757
+ submenuLinks: _mapInstanceProperty__default["default"](_context2 = appConfig.submenuLinks).call(_context2, function (submenuLink) {
758
+ return _objectSpread$1(_objectSpread$1({}, submenuLink), {}, {
759
+ uriPath: computeUriPath(submenuLink.uriPath, appConfig.entryPointUriPath)
760
+ });
761
+ })
734
762
  };
735
763
  }
736
764
 
@@ -35,6 +35,7 @@ var _toConsumableArray = require('@babel/runtime-corejs3/helpers/toConsumableArr
35
35
  var _Object$values = require('@babel/runtime-corejs3/core-js-stable/object/values');
36
36
  var _includesInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/includes');
37
37
  var uniq = require('lodash/uniq');
38
+ var _startsWithInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/starts-with');
38
39
  var formatters = require('./formatters-40251cfd.cjs.prod.js');
39
40
  require('lodash/upperFirst');
40
41
 
@@ -61,6 +62,7 @@ var _JSON$stringify__default = /*#__PURE__*/_interopDefault(_JSON$stringify);
61
62
  var _Object$values__default = /*#__PURE__*/_interopDefault(_Object$values);
62
63
  var _includesInstanceProperty__default = /*#__PURE__*/_interopDefault(_includesInstanceProperty);
63
64
  var uniq__default = /*#__PURE__*/_interopDefault(uniq);
65
+ var _startsWithInstanceProperty__default = /*#__PURE__*/_interopDefault(_startsWithInstanceProperty);
64
66
 
65
67
  function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = _Reflect$construct__default["default"](Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
66
68
 
@@ -713,7 +715,29 @@ var getOrThrow = function getOrThrow(fn, errorMessage) {
713
715
  }
714
716
  };
715
717
 
718
+ function ownKeys$1(object, enumerableOnly) { var keys = _Object$keys__default["default"](object); if (_Object$getOwnPropertySymbols__default["default"]) { var symbols = _Object$getOwnPropertySymbols__default["default"](object); enumerableOnly && (symbols = _filterInstanceProperty__default["default"](symbols).call(symbols, function (sym) { return _Object$getOwnPropertyDescriptor__default["default"](object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
719
+
720
+ function _objectSpread$1(target) { for (var i = 1; i < arguments.length; i++) { var _context3, _context4; var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? _forEachInstanceProperty__default["default"](_context3 = ownKeys$1(Object(source), !0)).call(_context3, function (key) { _defineProperty(target, key, source[key]); }) : _Object$getOwnPropertyDescriptors__default["default"] ? _Object$defineProperties__default["default"](target, _Object$getOwnPropertyDescriptors__default["default"](source)) : _forEachInstanceProperty__default["default"](_context4 = ownKeys$1(Object(source))).call(_context4, function (key) { _Object$defineProperty__default["default"](target, key, _Object$getOwnPropertyDescriptor__default["default"](source, key)); }); } return target; }
721
+ // to the `entryPointUriPath`. Computing the full path is done internally to keep
722
+ // the configuration simple.
723
+
724
+ var computeUriPath = function computeUriPath(uriPath, entryPointUriPath) {
725
+ var _context;
726
+
727
+ // In case the `uriPath` is only `/`, it means that the link is supposed to be
728
+ // treated the same as the main application path. In this case, the return value
729
+ // should not contain any unnecessary trailing slash and therefore we use the `entryPointUriPath`.
730
+ if (uriPath === '/') return entryPointUriPath; // In case the `uriPath` is already configured including the `entryPointUriPath`,
731
+ // we return the `uriPath` as-is.
732
+
733
+ if (_startsWithInstanceProperty__default["default"](uriPath).call(uriPath, "".concat(entryPointUriPath, "/"))) return uriPath; // Return the full path including the `entryPointUriPath` as a prefix.
734
+
735
+ return _concatInstanceProperty__default["default"](_context = "".concat(entryPointUriPath, "/")).call(_context, uriPath);
736
+ };
737
+
716
738
  function transformCustomApplicationConfigToData(appConfig) {
739
+ var _context2;
740
+
717
741
  var permissionKeys = formatters.entryPointUriPathToResourceAccesses(appConfig.entryPointUriPath);
718
742
  return {
719
743
  id: appConfig.env.production.applicationId,
@@ -730,7 +754,11 @@ function transformCustomApplicationConfigToData(appConfig) {
730
754
  }],
731
755
  icon: appConfig.icon,
732
756
  mainMenuLink: appConfig.mainMenuLink,
733
- submenuLinks: appConfig.submenuLinks
757
+ submenuLinks: _mapInstanceProperty__default["default"](_context2 = appConfig.submenuLinks).call(_context2, function (submenuLink) {
758
+ return _objectSpread$1(_objectSpread$1({}, submenuLink), {}, {
759
+ uriPath: computeUriPath(submenuLink.uriPath, appConfig.entryPointUriPath)
760
+ });
761
+ })
734
762
  };
735
763
  }
736
764
 
@@ -31,6 +31,7 @@ import _toConsumableArray from '@babel/runtime-corejs3/helpers/esm/toConsumableA
31
31
  import _Object$values from '@babel/runtime-corejs3/core-js-stable/object/values';
32
32
  import _includesInstanceProperty from '@babel/runtime-corejs3/core-js-stable/instance/includes';
33
33
  import uniq from 'lodash/uniq';
34
+ import _startsWithInstanceProperty from '@babel/runtime-corejs3/core-js-stable/instance/starts-with';
34
35
  import { e as entryPointUriPathToResourceAccesses } from './formatters-62af6993.esm.js';
35
36
  import 'lodash/upperFirst';
36
37
 
@@ -685,7 +686,29 @@ var getOrThrow = function getOrThrow(fn, errorMessage) {
685
686
  }
686
687
  };
687
688
 
689
+ function ownKeys$1(object, enumerableOnly) { var keys = _Object$keys(object); if (_Object$getOwnPropertySymbols) { var symbols = _Object$getOwnPropertySymbols(object); enumerableOnly && (symbols = _filterInstanceProperty(symbols).call(symbols, function (sym) { return _Object$getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
690
+
691
+ function _objectSpread$1(target) { for (var i = 1; i < arguments.length; i++) { var _context3, _context4; var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? _forEachInstanceProperty(_context3 = ownKeys$1(Object(source), !0)).call(_context3, function (key) { _defineProperty(target, key, source[key]); }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(target, _Object$getOwnPropertyDescriptors(source)) : _forEachInstanceProperty(_context4 = ownKeys$1(Object(source))).call(_context4, function (key) { _Object$defineProperty(target, key, _Object$getOwnPropertyDescriptor(source, key)); }); } return target; }
692
+ // to the `entryPointUriPath`. Computing the full path is done internally to keep
693
+ // the configuration simple.
694
+
695
+ var computeUriPath = function computeUriPath(uriPath, entryPointUriPath) {
696
+ var _context;
697
+
698
+ // In case the `uriPath` is only `/`, it means that the link is supposed to be
699
+ // treated the same as the main application path. In this case, the return value
700
+ // should not contain any unnecessary trailing slash and therefore we use the `entryPointUriPath`.
701
+ if (uriPath === '/') return entryPointUriPath; // In case the `uriPath` is already configured including the `entryPointUriPath`,
702
+ // we return the `uriPath` as-is.
703
+
704
+ if (_startsWithInstanceProperty(uriPath).call(uriPath, "".concat(entryPointUriPath, "/"))) return uriPath; // Return the full path including the `entryPointUriPath` as a prefix.
705
+
706
+ return _concatInstanceProperty(_context = "".concat(entryPointUriPath, "/")).call(_context, uriPath);
707
+ };
708
+
688
709
  function transformCustomApplicationConfigToData(appConfig) {
710
+ var _context2;
711
+
689
712
  var permissionKeys = entryPointUriPathToResourceAccesses(appConfig.entryPointUriPath);
690
713
  return {
691
714
  id: appConfig.env.production.applicationId,
@@ -702,7 +725,11 @@ function transformCustomApplicationConfigToData(appConfig) {
702
725
  }],
703
726
  icon: appConfig.icon,
704
727
  mainMenuLink: appConfig.mainMenuLink,
705
- submenuLinks: appConfig.submenuLinks
728
+ submenuLinks: _mapInstanceProperty(_context2 = appConfig.submenuLinks).call(_context2, function (submenuLink) {
729
+ return _objectSpread$1(_objectSpread$1({}, submenuLink), {}, {
730
+ uriPath: computeUriPath(submenuLink.uriPath, appConfig.entryPointUriPath)
731
+ });
732
+ })
706
733
  };
707
734
  }
708
735
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@commercetools-frontend/application-config",
3
- "version": "21.3.2",
3
+ "version": "21.3.3",
4
4
  "description": "Configuration utilities for building Custom Applications",
5
5
  "bugs": "https://github.com/commercetools/merchant-center-application-kit/issues",
6
6
  "repository": {