@commercetools-frontend/application-config 21.3.4 → 21.5.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.
@@ -27,6 +27,7 @@ var _possibleConstructorReturn = require('@babel/runtime-corejs3/helpers/possibl
27
27
  var _getPrototypeOf = require('@babel/runtime-corejs3/helpers/getPrototypeOf');
28
28
  var _wrapNativeSuper = require('@babel/runtime-corejs3/helpers/wrapNativeSuper');
29
29
  var _mapInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/map');
30
+ var _Set = require('@babel/runtime-corejs3/core-js-stable/set');
30
31
  var Ajv = require('ajv');
31
32
  var _slicedToArray = require('@babel/runtime-corejs3/helpers/slicedToArray');
32
33
  var _trimInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/trim');
@@ -56,6 +57,7 @@ var omitEmpty__default = /*#__PURE__*/_interopDefault(omitEmpty);
56
57
  var path__default = /*#__PURE__*/_interopDefault(path);
57
58
  var _Reflect$construct__default = /*#__PURE__*/_interopDefault(_Reflect$construct);
58
59
  var _mapInstanceProperty__default = /*#__PURE__*/_interopDefault(_mapInstanceProperty);
60
+ var _Set__default = /*#__PURE__*/_interopDefault(_Set);
59
61
  var Ajv__default = /*#__PURE__*/_interopDefault(Ajv);
60
62
  var _trimInstanceProperty__default = /*#__PURE__*/_interopDefault(_trimInstanceProperty);
61
63
  var _JSON$stringify__default = /*#__PURE__*/_interopDefault(_JSON$stringify);
@@ -524,6 +526,21 @@ var validateConfig = function validateConfig(config) {
524
526
  throw new Error(printErrors(validate.errors));
525
527
  }
526
528
  };
529
+ var validateSubmenuLinks = function validateSubmenuLinks(config) {
530
+ var _context4;
531
+
532
+ var uriPathSet = new _Set__default["default"]();
533
+
534
+ _forEachInstanceProperty__default["default"](_context4 = config.submenuLinks).call(_context4, function (_ref) {
535
+ var uriPath = _ref.uriPath;
536
+
537
+ if (uriPathSet.has(uriPath)) {
538
+ throw new Error('Duplicate URI path. Every submenu link must have a unique URI path value');
539
+ }
540
+
541
+ uriPathSet.add(uriPath);
542
+ });
543
+ };
527
544
 
528
545
  /**
529
546
  * NOTE:
@@ -739,6 +756,7 @@ function transformCustomApplicationConfigToData(appConfig) {
739
756
  var _context2;
740
757
 
741
758
  var permissionKeys = formatters.entryPointUriPathToResourceAccesses(appConfig.entryPointUriPath);
759
+ validateSubmenuLinks(appConfig);
742
760
  return {
743
761
  id: appConfig.env.production.applicationId,
744
762
  name: appConfig.name,
@@ -27,6 +27,7 @@ var _possibleConstructorReturn = require('@babel/runtime-corejs3/helpers/possibl
27
27
  var _getPrototypeOf = require('@babel/runtime-corejs3/helpers/getPrototypeOf');
28
28
  var _wrapNativeSuper = require('@babel/runtime-corejs3/helpers/wrapNativeSuper');
29
29
  var _mapInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/map');
30
+ var _Set = require('@babel/runtime-corejs3/core-js-stable/set');
30
31
  var Ajv = require('ajv');
31
32
  var _slicedToArray = require('@babel/runtime-corejs3/helpers/slicedToArray');
32
33
  var _trimInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/trim');
@@ -56,6 +57,7 @@ var omitEmpty__default = /*#__PURE__*/_interopDefault(omitEmpty);
56
57
  var path__default = /*#__PURE__*/_interopDefault(path);
57
58
  var _Reflect$construct__default = /*#__PURE__*/_interopDefault(_Reflect$construct);
58
59
  var _mapInstanceProperty__default = /*#__PURE__*/_interopDefault(_mapInstanceProperty);
60
+ var _Set__default = /*#__PURE__*/_interopDefault(_Set);
59
61
  var Ajv__default = /*#__PURE__*/_interopDefault(Ajv);
60
62
  var _trimInstanceProperty__default = /*#__PURE__*/_interopDefault(_trimInstanceProperty);
61
63
  var _JSON$stringify__default = /*#__PURE__*/_interopDefault(_JSON$stringify);
@@ -524,6 +526,21 @@ var validateConfig = function validateConfig(config) {
524
526
  throw new Error(printErrors(validate.errors));
525
527
  }
526
528
  };
529
+ var validateSubmenuLinks = function validateSubmenuLinks(config) {
530
+ var _context4;
531
+
532
+ var uriPathSet = new _Set__default["default"]();
533
+
534
+ _forEachInstanceProperty__default["default"](_context4 = config.submenuLinks).call(_context4, function (_ref) {
535
+ var uriPath = _ref.uriPath;
536
+
537
+ if (uriPathSet.has(uriPath)) {
538
+ throw new Error('Duplicate URI path. Every submenu link must have a unique URI path value');
539
+ }
540
+
541
+ uriPathSet.add(uriPath);
542
+ });
543
+ };
527
544
 
528
545
  /**
529
546
  * NOTE:
@@ -739,6 +756,7 @@ function transformCustomApplicationConfigToData(appConfig) {
739
756
  var _context2;
740
757
 
741
758
  var permissionKeys = formatters.entryPointUriPathToResourceAccesses(appConfig.entryPointUriPath);
759
+ validateSubmenuLinks(appConfig);
742
760
  return {
743
761
  id: appConfig.env.production.applicationId,
744
762
  name: appConfig.name,
@@ -23,6 +23,7 @@ import _possibleConstructorReturn from '@babel/runtime-corejs3/helpers/esm/possi
23
23
  import _getPrototypeOf from '@babel/runtime-corejs3/helpers/esm/getPrototypeOf';
24
24
  import _wrapNativeSuper from '@babel/runtime-corejs3/helpers/esm/wrapNativeSuper';
25
25
  import _mapInstanceProperty from '@babel/runtime-corejs3/core-js-stable/instance/map';
26
+ import _Set from '@babel/runtime-corejs3/core-js-stable/set';
26
27
  import Ajv from 'ajv';
27
28
  import _slicedToArray from '@babel/runtime-corejs3/helpers/esm/slicedToArray';
28
29
  import _trimInstanceProperty from '@babel/runtime-corejs3/core-js-stable/instance/trim';
@@ -495,6 +496,21 @@ var validateConfig = function validateConfig(config) {
495
496
  throw new Error(printErrors(validate.errors));
496
497
  }
497
498
  };
499
+ var validateSubmenuLinks = function validateSubmenuLinks(config) {
500
+ var _context4;
501
+
502
+ var uriPathSet = new _Set();
503
+
504
+ _forEachInstanceProperty(_context4 = config.submenuLinks).call(_context4, function (_ref) {
505
+ var uriPath = _ref.uriPath;
506
+
507
+ if (uriPathSet.has(uriPath)) {
508
+ throw new Error('Duplicate URI path. Every submenu link must have a unique URI path value');
509
+ }
510
+
511
+ uriPathSet.add(uriPath);
512
+ });
513
+ };
498
514
 
499
515
  /**
500
516
  * NOTE:
@@ -710,6 +726,7 @@ function transformCustomApplicationConfigToData(appConfig) {
710
726
  var _context2;
711
727
 
712
728
  var permissionKeys = entryPointUriPathToResourceAccesses(appConfig.entryPointUriPath);
729
+ validateSubmenuLinks(appConfig);
713
730
  return {
714
731
  id: appConfig.env.production.applicationId,
715
732
  name: appConfig.name,
@@ -34,9 +34,9 @@ export declare type CustomApplicationData = {
34
34
  mainMenuLink: CustomApplicationMenuLinkData;
35
35
  submenuLinks: CustomApplicationSubmenuLinkData[];
36
36
  };
37
- export declare type ApplicationRuntimeConfig = {
37
+ export declare type ApplicationRuntimeConfig<AdditionalEnvironmentProperties extends {} = {}> = {
38
38
  data: CustomApplicationData;
39
- env: ApplicationWindow['app'];
39
+ env: AdditionalEnvironmentProperties & ApplicationWindow['app'];
40
40
  headers: JSONSchemaForCustomApplicationConfigurationFiles['headers'];
41
41
  };
42
42
  export declare type LoadingConfigOptions = {
@@ -0,0 +1,3 @@
1
+ import type { JSONSchemaForCustomApplicationConfigurationFiles } from './schema';
2
+ export declare const validateConfig: (config: JSONSchemaForCustomApplicationConfigurationFiles) => void;
3
+ export declare const validateSubmenuLinks: (config: JSONSchemaForCustomApplicationConfigurationFiles) => void;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@commercetools-frontend/application-config",
3
- "version": "21.3.4",
3
+ "version": "21.5.0",
4
4
  "description": "Configuration utilities for building Custom Applications",
5
5
  "bugs": "https://github.com/commercetools/merchant-center-application-kit/issues",
6
6
  "repository": {
@@ -1,3 +0,0 @@
1
- import type { JSONSchemaForCustomApplicationConfigurationFiles } from './schema';
2
- declare const validateConfig: (config: JSONSchemaForCustomApplicationConfigurationFiles) => void;
3
- export default validateConfig;