@commercetools-frontend/application-config 20.12.3 → 21.0.0-rc.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.
@@ -160,8 +160,9 @@ var schemaJson = {
160
160
  type: "string"
161
161
  },
162
162
  entryPointUriPath: {
163
- description: "The unique route path of the Custom Application. This is the identifier that the Merchant Center Proxy uses to match the HTTP request and to forward it to the Custom Application URL. This value also needs to be used in the application client side routes. The value must be the same as the `navbarMenu.uriPath` in the `menu.json` and the application route path when registering the Custom Application. For example, if the Custom Application should be served at the route `/:projectKey/avengers`, the `entryPointUriPath` must be set to `avengers` and the same for the application routes.",
164
- type: "string"
163
+ description: "The unique route path of the Custom Application. This is the identifier that the Merchant Center Proxy uses to match the HTTP request and to forward it to the Custom Application URL (https://docs.commercetools.com/custom-applications/api-reference/application-config).",
164
+ type: "string",
165
+ pattern: "^[^\\-_]([0-9a-z]|[\\-_](?![\\-_])){2,64}[^\\-_]$"
165
166
  },
166
167
  cloudIdentifier: {
167
168
  description: "The cloud identifier where the Custom Application is running. This value is used to derive the Merchant Center API URL. Alternatively you can use the `mcApiUrl` property.",
@@ -192,6 +193,8 @@ var schemaJson = {
192
193
  view: {
193
194
  description: "The list of view-only OAuth Scopes (https://docs.commercetools.com/api/scopes).",
194
195
  type: "array",
196
+ "default": [
197
+ ],
195
198
  items: {
196
199
  type: "string",
197
200
  pattern: "view_(.*)"
@@ -201,6 +204,8 @@ var schemaJson = {
201
204
  manage: {
202
205
  description: "The list of manage-only OAuth Scopes (https://docs.commercetools.com/api/scopes).",
203
206
  type: "array",
207
+ "default": [
208
+ ],
204
209
  items: {
205
210
  type: "string",
206
211
  pattern: "manage_(.*)"
@@ -231,7 +236,10 @@ var schemaJson = {
231
236
  type: "string"
232
237
  }
233
238
  },
234
- additionalProperties: false
239
+ additionalProperties: false,
240
+ required: [
241
+ "initialProjectKey"
242
+ ]
235
243
  },
236
244
  production: {
237
245
  description: "Configuration for production only",
@@ -252,12 +260,14 @@ var schemaJson = {
252
260
  },
253
261
  additionalProperties: false,
254
262
  required: [
263
+ "applicationId",
255
264
  "url"
256
265
  ]
257
266
  }
258
267
  },
259
268
  additionalProperties: false,
260
269
  required: [
270
+ "development",
261
271
  "production"
262
272
  ]
263
273
  },
@@ -317,19 +327,16 @@ var schemaJson = {
317
327
  uniqueItems: true
318
328
  }
319
329
  },
320
- additionalProperties: false,
321
- required: [
322
- "csp"
323
- ]
330
+ additionalProperties: false
324
331
  },
325
- menuLinks: {
326
- description: "Configuration for the menu links on the left-side navbar.",
332
+ icon: {
333
+ description: "The SVG icon that represents this application. Pass the raw SVG string or a path to an SVG file, for example a relative path `${path:./app.svg}`, or a path from a module `${path:@commercetools-frontend/assets/application-icons/rocket.svg}`.",
334
+ type: "string"
335
+ },
336
+ mainMenuLink: {
337
+ description: "Configuration for the main menu link on the left-side navbar.",
327
338
  type: "object",
328
339
  properties: {
329
- icon: {
330
- description: "The SVG icon that represents this application. Pass the raw SVG string or a path to an SVG file, for example a relative path `${path:./app.svg}`, or a path from a module `${path:@commercetools-frontend/assets/application-icons/rocket.svg}`.",
331
- type: "string"
332
- },
333
340
  defaultLabel: {
334
341
  description: "A default label to be rendered if there is no matching localized label for the user locale.",
335
342
  type: "string"
@@ -366,89 +373,87 @@ var schemaJson = {
366
373
  }
367
374
  },
368
375
  permissions: {
369
- description: "Set the visibility of the menu link. Users must have at least one permission to see the Custom Application in the Merchant Center menu.",
376
+ description: "Set the visibility of the menu link. Permission values are derived from the `entryPointUriPath`. Users must have at least one permission to see the Custom Application in the Merchant Center menu.",
370
377
  type: "array",
371
378
  "default": [
372
379
  ],
373
380
  items: {
374
381
  type: "string"
375
382
  }
376
- },
377
- submenuLinks: {
378
- description: "Configuration for the submenu links on the left-side navbar.",
379
- "default": [
380
- ],
381
- type: "array",
382
- items: {
383
- type: "object",
384
- properties: {
385
- uriPath: {
386
- description: "Route path relative to the entry point URI path of the Custom Application.",
387
- type: "string"
388
- },
389
- defaultLabel: {
390
- description: "A default label to be rendered if there is no matching localized label for the user locale.",
391
- type: "string"
392
- },
393
- labelAllLocales: {
394
- description: "Localized label based on the application locales available from the user profile.",
395
- type: "array",
396
- "default": [
397
- ],
398
- items: {
399
- type: "object",
400
- properties: {
401
- locale: {
402
- type: "string",
403
- "enum": [
404
- "en",
405
- "de",
406
- "es",
407
- "fr-FR",
408
- "zh-CN",
409
- "ja"
410
- ]
411
- },
412
- value: {
413
- description: "A label for the specific locale or a reference to a translated message. For example `${intl:en:Menu.Avengers}` which looks for the message key `Menu.Avengers` in the `src/i18n/data/en.json`",
414
- type: "string"
415
- }
416
- },
417
- additionalProperties: false,
418
- required: [
419
- "locale",
420
- "value"
421
- ]
422
- }
423
- },
424
- permissions: {
425
- description: "Set the visibility of the menu link. Users must have at least one permission to see the Custom Application in the Merchant Center menu.",
426
- type: "array",
427
- "default": [
428
- ],
429
- items: {
430
- type: "string"
431
- }
432
- }
433
- },
434
- additionalProperties: true,
435
- required: [
436
- "uriPath",
437
- "defaultLabel",
438
- "labelAllLocales",
439
- "permissions"
440
- ]
441
- }
442
383
  }
443
384
  },
444
385
  additionalProperties: true,
445
386
  required: [
446
- "icon",
447
387
  "defaultLabel",
448
388
  "labelAllLocales",
449
- "permissions",
450
- "submenuLinks"
389
+ "permissions"
451
390
  ]
391
+ },
392
+ submenuLinks: {
393
+ description: "Configuration for the submenu links on the left-side navbar.",
394
+ "default": [
395
+ ],
396
+ type: "array",
397
+ items: {
398
+ type: "object",
399
+ properties: {
400
+ uriPath: {
401
+ description: "Route path relative to the entry point URI path of the Custom Application.",
402
+ type: "string"
403
+ },
404
+ defaultLabel: {
405
+ description: "A default label to be rendered if there is no matching localized label for the user locale.",
406
+ type: "string"
407
+ },
408
+ labelAllLocales: {
409
+ description: "Localized label based on the application locales available from the user profile.",
410
+ type: "array",
411
+ "default": [
412
+ ],
413
+ items: {
414
+ type: "object",
415
+ properties: {
416
+ locale: {
417
+ type: "string",
418
+ "enum": [
419
+ "en",
420
+ "de",
421
+ "es",
422
+ "fr-FR",
423
+ "zh-CN",
424
+ "ja"
425
+ ]
426
+ },
427
+ value: {
428
+ description: "A label for the specific locale or a reference to a translated message. For example `${intl:en:Menu.Avengers}` which looks for the message key `Menu.Avengers` in the `src/i18n/data/en.json`",
429
+ type: "string"
430
+ }
431
+ },
432
+ additionalProperties: false,
433
+ required: [
434
+ "locale",
435
+ "value"
436
+ ]
437
+ }
438
+ },
439
+ permissions: {
440
+ description: "Set the visibility of the menu link. Permission values are derived from the `entryPointUriPath`. Users must have at least one permission to see the Custom Application in the Merchant Center menu.",
441
+ type: "array",
442
+ "default": [
443
+ ],
444
+ items: {
445
+ type: "string"
446
+ }
447
+ }
448
+ },
449
+ additionalProperties: true,
450
+ required: [
451
+ "uriPath",
452
+ "defaultLabel",
453
+ "labelAllLocales",
454
+ "permissions"
455
+ ]
456
+ }
452
457
  }
453
458
  },
454
459
  additionalProperties: true,
@@ -456,7 +461,11 @@ var schemaJson = {
456
461
  "name",
457
462
  "entryPointUriPath",
458
463
  "cloudIdentifier",
459
- "env"
464
+ "env",
465
+ "oAuthScopes",
466
+ "icon",
467
+ "mainMenuLink",
468
+ "submenuLinks"
460
469
  ]
461
470
  };
462
471
 
@@ -687,9 +696,9 @@ var substituteVariablePlaceholders = function substituteVariablePlaceholders(con
687
696
  });
688
697
  };
689
698
 
690
- function ownKeys(object, enumerableOnly) { var keys = _Object$keys__default["default"](object); if (_Object$getOwnPropertySymbols__default["default"]) { var symbols = _Object$getOwnPropertySymbols__default["default"](object); if (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; }
699
+ function ownKeys(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; }
691
700
 
692
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { var _context3; _forEachInstanceProperty__default["default"](_context3 = ownKeys(Object(source), true)).call(_context3, function (key) { _defineProperty(target, key, source[key]); }); } else if (_Object$getOwnPropertyDescriptors__default["default"]) { _Object$defineProperties__default["default"](target, _Object$getOwnPropertyDescriptors__default["default"](source)); } else { var _context4; _forEachInstanceProperty__default["default"](_context4 = ownKeys(Object(source))).call(_context4, function (key) { _Object$defineProperty__default["default"](target, key, _Object$getOwnPropertyDescriptor__default["default"](source, key)); }); } } return target; }
701
+ function _objectSpread(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(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(Object(source))).call(_context4, function (key) { _Object$defineProperty__default["default"](target, key, _Object$getOwnPropertyDescriptor__default["default"](source, key)); }); } return target; }
693
702
  // TODO: make it configurable.
694
703
  var developmentPort = 3001;
695
704
  var developmentAppUrl = "http://localhost:".concat(developmentPort);
@@ -705,7 +714,7 @@ var omitDevConfigIfEmpty = function omitDevConfigIfEmpty(devConfig) {
705
714
  var cachedConfig;
706
715
 
707
716
  var processConfig = function processConfig() {
708
- var _ref2, _processEnv$MC_APP_EN, _appConfig$additional, _ref3, _appConfig$env$develo, _appConfig$env$develo2, _appConfig$headers, _appConfig$headers2, _context2, _appConfig$headers3, _appConfig$headers4;
717
+ var _ref2, _processEnv$MC_APP_EN, _appConfig$additional, _ref3, _context, _appConfig$env$develo, _appConfig$headers, _appConfig$headers2, _appConfig$headers2$c, _context2, _appConfig$headers3, _appConfig$headers3$c, _appConfig$headers4, _appConfig$headers4$c;
709
718
 
710
719
  var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
711
720
  _ref$disableCache = _ref.disableCache,
@@ -726,9 +735,7 @@ var processConfig = function processConfig() {
726
735
  applicationPath: applicationPath
727
736
  });
728
737
  var additionalAppEnv = (_appConfig$additional = appConfig.additionalEnv) !== null && _appConfig$additional !== void 0 ? _appConfig$additional : {};
729
- var revision = (_ref3 = additionalAppEnv.revision) !== null && _ref3 !== void 0 ? _ref3 : ''; // Feature flags
730
-
731
- var isOidcForDevelopmentEnabled = Boolean(JSON.parse(processEnv.ENABLE_OIDC_FOR_DEVELOPMENT || 'false')); // Parse all the supported URLs, which gets implicitly validated
738
+ var revision = (_ref3 = additionalAppEnv.revision) !== null && _ref3 !== void 0 ? _ref3 : ''; // Parse all the supported URLs, which gets implicitly validated
732
739
 
733
740
  var envAppUrl = isProd ? appConfig.env.production.url : developmentAppUrl;
734
741
  var appUrl = getOrThrow(function () {
@@ -747,37 +754,26 @@ var processConfig = function processConfig() {
747
754
  // This is important to determine to which URL the MC should redirect to
748
755
  // after successful login.
749
756
 
750
- var applicationId = isOidcForDevelopmentEnabled ? "__local:".concat(appConfig.entryPointUriPath) : undefined;
751
-
752
- if (isProd) {
753
- // TODO: decide if we do require the application ID or not.
754
- if (appConfig.env.production.applicationId) {
755
- var _context;
756
-
757
- applicationId = _concatInstanceProperty__default["default"](_context = "".concat(appConfig.env.production.applicationId, ":")).call(_context, appConfig.entryPointUriPath);
758
- } else {
759
- // As long as we don't require the application ID in production, we should
760
- // fall back to unset the value.
761
- applicationId = undefined;
762
- }
763
- }
764
-
757
+ var applicationId = isProd ? _concatInstanceProperty__default["default"](_context = "".concat(appConfig.env.production.applicationId, ":")).call(_context, appConfig.entryPointUriPath) : "__local:".concat(appConfig.entryPointUriPath);
765
758
  var developmentConfig = isProd ? undefined : omitDevConfigIfEmpty({
766
- oidc: isOidcForDevelopmentEnabled ? omitEmpty__default["default"]({
759
+ oidc: omitEmpty__default["default"]({
767
760
  authorizeUrl: [// In case the MC API url points to localhost, we need to point
768
761
  // to a local running dev login page to handle the workflow properly.
769
762
  mcApiUrl.hostname === 'localhost' ? mcApiUrl.origin.replace(mcApiUrl.port, String(developmentPort)) : mcApiUrl.origin.replace('mc-api', 'mc'), '/login/authorize'].join(''),
770
- initialProjectKey: (_appConfig$env$develo = appConfig.env.development) === null || _appConfig$env$develo === void 0 ? void 0 : _appConfig$env$develo.initialProjectKey,
771
- teamId: (_appConfig$env$develo2 = appConfig.env.development) === null || _appConfig$env$develo2 === void 0 ? void 0 : _appConfig$env$develo2.teamId,
763
+ initialProjectKey: appConfig.env.development.initialProjectKey,
764
+ teamId: (_appConfig$env$develo = appConfig.env.development) === null || _appConfig$env$develo === void 0 ? void 0 : _appConfig$env$develo.teamId,
772
765
  oAuthScopes: appConfig.oAuthScopes
773
- }) : undefined,
774
- menuLinks: appConfig.menuLinks,
766
+ }),
767
+ menuLinks: _objectSpread(_objectSpread({
768
+ icon: appConfig.icon
769
+ }, appConfig.mainMenuLink), {}, {
770
+ submenuLinks: appConfig.submenuLinks
771
+ }),
775
772
  // @ts-expect-error: the `accountLinks` is not explicitly typed as it's only used by the account app.
776
773
  accountLinks: appConfig.accountLinks
777
774
  });
778
775
  cachedConfig = {
779
776
  env: _objectSpread(_objectSpread(_objectSpread({}, omitEmpty__default["default"](additionalAppEnv)), {}, {
780
- // TODO: how else should we provide the app identifier?
781
777
  applicationId: applicationId,
782
778
  applicationName: appConfig.name,
783
779
  entryPointUriPath: appConfig.entryPointUriPath
@@ -794,9 +790,9 @@ var processConfig = function processConfig() {
794
790
  }),
795
791
  headers: _objectSpread(_objectSpread({}, appConfig.headers), {}, {
796
792
  csp: _objectSpread(_objectSpread({}, (_appConfig$headers = appConfig.headers) === null || _appConfig$headers === void 0 ? void 0 : _appConfig$headers.csp), {}, {
797
- 'connect-src': getUniqueValues((_appConfig$headers2 = appConfig.headers) === null || _appConfig$headers2 === void 0 ? void 0 : _appConfig$headers2.csp['connect-src'], _concatInstanceProperty__default["default"](_context2 = [mcApiUrl.origin]).call(_context2, isProd ? [appUrl.href] : [])),
798
- 'script-src': getUniqueValues((_appConfig$headers3 = appConfig.headers) === null || _appConfig$headers3 === void 0 ? void 0 : _appConfig$headers3.csp['script-src'], isProd ? [appUrl.href, cdnUrl.href] : []),
799
- 'style-src': getUniqueValues((_appConfig$headers4 = appConfig.headers) === null || _appConfig$headers4 === void 0 ? void 0 : _appConfig$headers4.csp['style-src'], isProd ? [appUrl.href, cdnUrl.href] : [])
793
+ 'connect-src': getUniqueValues((_appConfig$headers2 = appConfig.headers) === null || _appConfig$headers2 === void 0 ? void 0 : (_appConfig$headers2$c = _appConfig$headers2.csp) === null || _appConfig$headers2$c === void 0 ? void 0 : _appConfig$headers2$c['connect-src'], _concatInstanceProperty__default["default"](_context2 = [mcApiUrl.origin]).call(_context2, isProd ? [appUrl.href] : [])),
794
+ 'script-src': getUniqueValues((_appConfig$headers3 = appConfig.headers) === null || _appConfig$headers3 === void 0 ? void 0 : (_appConfig$headers3$c = _appConfig$headers3.csp) === null || _appConfig$headers3$c === void 0 ? void 0 : _appConfig$headers3$c['script-src'], isProd ? [appUrl.href, cdnUrl.href] : []),
795
+ 'style-src': getUniqueValues((_appConfig$headers4 = appConfig.headers) === null || _appConfig$headers4 === void 0 ? void 0 : (_appConfig$headers4$c = _appConfig$headers4.csp) === null || _appConfig$headers4$c === void 0 ? void 0 : _appConfig$headers4$c['style-src'], isProd ? [appUrl.href, cdnUrl.href] : [])
800
796
  })
801
797
  })
802
798
  };