@veloceapps/sdk 5.0.9 → 5.0.11

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.
Files changed (109) hide show
  1. package/bundles/veloce-sdk-cms.umd.js +102 -51
  2. package/bundles/veloce-sdk-cms.umd.js.map +1 -1
  3. package/bundles/veloce-sdk-core.umd.js.map +1 -1
  4. package/bundles/veloce-sdk-runtime.umd.js.map +1 -1
  5. package/bundles/veloce-sdk.umd.js +4 -2
  6. package/bundles/veloce-sdk.umd.js.map +1 -1
  7. package/cms/components/element-renderer/element-renderer.component.d.ts +1 -0
  8. package/cms/services/launcher.service.d.ts +3 -3
  9. package/cms/types/compilation.types.d.ts +6 -0
  10. package/cms/types/index.d.ts +1 -0
  11. package/cms/utils/elements-resolver.d.ts +3 -0
  12. package/cms/vendor-map.d.ts +124 -116
  13. package/core/modules/configuration/services/configuration-runtime.service.d.ts +1 -1
  14. package/esm2015/cms/components/element-renderer/element-renderer.component.js +23 -2
  15. package/esm2015/cms/components/element.component.js +1 -1
  16. package/esm2015/cms/components/preview/preview.component.js +7 -4
  17. package/esm2015/cms/decorators/element.decorator.js +1 -1
  18. package/esm2015/cms/directives/custom-template.directive.js +1 -1
  19. package/esm2015/cms/engine/models/entity.js +1 -1
  20. package/esm2015/cms/modules/federated/federated.component.js +1 -1
  21. package/esm2015/cms/modules/federated/federated.utils.js +1 -1
  22. package/esm2015/cms/plugins/configuration.plugin.js +1 -1
  23. package/esm2015/cms/plugins/script.plugin.js +1 -1
  24. package/esm2015/cms/services/dynamic-module.service.js +1 -1
  25. package/esm2015/cms/services/element-context.service.js +1 -1
  26. package/esm2015/cms/services/integration.state.js +1 -1
  27. package/esm2015/cms/services/launcher.service.js +10 -10
  28. package/esm2015/cms/services/templates.service.js +1 -1
  29. package/esm2015/cms/types/compilation.types.js +2 -0
  30. package/esm2015/cms/types/index.js +2 -1
  31. package/esm2015/cms/utils/element.utils.js +1 -1
  32. package/esm2015/cms/utils/elements-resolver.js +52 -30
  33. package/esm2015/core/modules/configuration/services/configuration-runtime.service.js +1 -1
  34. package/esm2015/core/modules/configuration/services/configuration.service.js +1 -1
  35. package/esm2015/core/modules/configuration/services/runtime-context.service.js +1 -1
  36. package/esm2015/core/modules/flow-configuration/services/flow-update.service.js +1 -1
  37. package/esm2015/core/services/context.service.js +1 -1
  38. package/esm2015/core/services/quote-draft.service.js +1 -1
  39. package/esm2015/core/utils/line-item.utils.js +1 -1
  40. package/esm2015/runtime/components/component-preview/component-preview.component.js +1 -1
  41. package/esm2015/runtime/components/section-renderer/section-renderer.component.js +1 -1
  42. package/esm2015/runtime/components/ui-runtime/runtime.component.js +1 -1
  43. package/esm2015/runtime/components/ui-runtime-preview/runtime-preview.component.js +1 -1
  44. package/esm2015/runtime/execution/components/children-placeholder/children-placeholder.component.js +1 -1
  45. package/esm2015/runtime/execution/components/context-provider/context-provider.component.js +1 -1
  46. package/esm2015/runtime/execution/components/execution-section-renderer/execution-section-renderer.component.js +1 -1
  47. package/esm2015/runtime/execution/components/federated/federated.component.js +1 -1
  48. package/esm2015/runtime/execution/components/velo-attribute/velo-attribute.component.js +1 -1
  49. package/esm2015/runtime/execution/components/velo-multiselect/velo-multiselect.component.js +1 -1
  50. package/esm2015/runtime/execution/components/velo-port-checkbox/velo-port-checkbox.component.js +1 -1
  51. package/esm2015/runtime/execution/components/velo-port-dropdown/velo-port-dropdown.component.js +1 -1
  52. package/esm2015/runtime/execution/components/velo-port-radio/velo-port-radio.component.js +1 -1
  53. package/esm2015/runtime/execution/components/velo-type/velo-type.component.js +1 -1
  54. package/esm2015/runtime/execution/directives/section-script.directive.js +1 -1
  55. package/esm2015/runtime/execution/directives/sf-query.directive.js +1 -1
  56. package/esm2015/runtime/execution/directives/velo-attribute.directive.js +1 -1
  57. package/esm2015/runtime/execution/directives/velo-port.directive.js +1 -1
  58. package/esm2015/runtime/execution/directives/vl-approval.directive.js +1 -1
  59. package/esm2015/runtime/execution/directives/vl-document-attachments.directive.js +1 -1
  60. package/esm2015/runtime/execution/directives/vl-document-templates.directive.js +1 -1
  61. package/esm2015/runtime/execution/directives/vl-quote.directive.js +1 -1
  62. package/esm2015/runtime/execution/directives/vl-ramp.directive.js +1 -1
  63. package/esm2015/runtime/execution/utils/federated.util.js +1 -1
  64. package/esm2015/runtime/services/cart.service.js +1 -1
  65. package/esm2015/runtime/services/collapsible-state.service.js +1 -1
  66. package/esm2015/runtime/services/configuration.service.js +1 -1
  67. package/esm2015/runtime/services/current-state.service.js +1 -1
  68. package/esm2015/runtime/services/form-scope.service.js +1 -1
  69. package/esm2015/runtime/services/product-model-cache.service.js +1 -1
  70. package/esm2015/runtime/services/runtime-context.service.js +1 -1
  71. package/esm2015/runtime/services/runtime-form.service.js +2 -2
  72. package/esm2015/runtime/services/runtime.service.js +1 -1
  73. package/esm2015/runtime/services/section-helper.service.js +1 -1
  74. package/esm2015/runtime/services/section-scope.service.js +1 -1
  75. package/esm2015/runtime/services/section-store.service.js +1 -1
  76. package/esm2015/runtime/services/section.service.js +1 -1
  77. package/esm2015/runtime/types/script-registry.types.js +1 -1
  78. package/esm2015/runtime/utils/line-item.util.js +1 -1
  79. package/esm2015/runtime/utils/sections-binder.helper.js +1 -1
  80. package/esm2015/src/components/dialog/dialog.component.js +1 -1
  81. package/esm2015/src/components/doc-gen/doc-gen.component.js +2 -2
  82. package/esm2015/src/components/header/cart-overlay/cart-preview.component.js +2 -2
  83. package/esm2015/src/components/header/header.component.js +4 -2
  84. package/esm2015/src/components/header/metrics/metrics.component.js +1 -1
  85. package/esm2015/src/flow-routing.module.js +1 -1
  86. package/esm2015/src/flow.component.js +1 -1
  87. package/esm2015/src/guards/product-unload.guard.js +1 -1
  88. package/esm2015/src/guards/root.guard.js +1 -1
  89. package/esm2015/src/pages/catalog/catalog.component.js +1 -1
  90. package/esm2015/src/pages/debug/debug.component.js +1 -1
  91. package/esm2015/src/pages/legacy-product/legacy-product.component.js +1 -1
  92. package/esm2015/src/pages/product/product.component.js +1 -1
  93. package/esm2015/src/pages/record-not-found/record-not-found.component.js +1 -1
  94. package/esm2015/src/pages/shopping-cart/shopping-cart.component.js +1 -1
  95. package/esm2015/src/resolvers/flow.resolver.js +1 -1
  96. package/esm2015/src/resolvers/quote.resolver.js +1 -1
  97. package/esm2015/src/services/flow-router.service.js +1 -1
  98. package/fesm2015/veloce-sdk-cms.js +86 -40
  99. package/fesm2015/veloce-sdk-cms.js.map +1 -1
  100. package/fesm2015/veloce-sdk-core.js.map +1 -1
  101. package/fesm2015/veloce-sdk-runtime.js +1 -1
  102. package/fesm2015/veloce-sdk-runtime.js.map +1 -1
  103. package/fesm2015/veloce-sdk.js +4 -2
  104. package/fesm2015/veloce-sdk.js.map +1 -1
  105. package/package.json +1 -1
  106. package/runtime/services/runtime-form.service.d.ts +3 -3
  107. package/runtime/utils/line-item.util.d.ts +1 -1
  108. package/src/guards/product-unload.guard.d.ts +2 -1
  109. package/src/resolvers/flow.resolver.d.ts +1 -1
@@ -1033,16 +1033,37 @@
1033
1033
  _this.processChildren(children);
1034
1034
  });
1035
1035
  };
1036
+ ElementRendererComponent.prototype.getModelComponent = function () {
1037
+ var component = null;
1038
+ var injector = this.parentInjector;
1039
+ while (!component) {
1040
+ var parentComp = injector.get(ElementRendererComponent, null);
1041
+ if (parentComp === null || parentComp === void 0 ? void 0 : parentComp.meta.model) {
1042
+ component = parentComp;
1043
+ break;
1044
+ }
1045
+ if (parentComp) {
1046
+ injector = parentComp.parentInjector;
1047
+ }
1048
+ else {
1049
+ break;
1050
+ }
1051
+ }
1052
+ return component;
1053
+ };
1036
1054
  ElementRendererComponent.prototype.createFromLineItem = function (path) {
1037
1055
  var _this = this;
1038
1056
  var _a, _b;
1039
- var parentComp = this.parentInjector.get(ElementRendererComponent, null);
1057
+ var parentComp = this.getModelComponent();
1040
1058
  var parentPath = (_a = parentComp === null || parentComp === void 0 ? void 0 : parentComp.meta.model) === null || _a === void 0 ? void 0 : _a.lineItem;
1041
1059
  var pathBlocks = parseBoundPath(path).reverse();
1042
1060
  var _c = (_b = pathBlocks[1]) !== null && _b !== void 0 ? _b : {}, property = _c.property, name = _c.name;
1043
1061
  var finalPath = pathBlocks[0];
1044
1062
  var children$ = this.getParentLineItem$(parentComp).pipe(rxjs.map(function (model) {
1045
1063
  var _a;
1064
+ if (!model) {
1065
+ return [];
1066
+ }
1046
1067
  if (property === 'ports' && !finalPath.property && parentPath !== path) {
1047
1068
  return (_a = model.lineItems.filter(function (_c) {
1048
1069
  var port = _c.port;
@@ -1519,30 +1540,14 @@
1519
1540
 
1520
1541
  var ElementsResolver = /** @class */ (function () {
1521
1542
  function ElementsResolver(uiDef, elements) {
1522
- var e_1, _c;
1543
+ var _this = this;
1523
1544
  this.uiDef = uiDef;
1524
1545
  this.renderableElements = [];
1525
1546
  this.sharedElements = [];
1526
- this.elements = this.transpileScripts(elements);
1527
- var flatElements = this.flattenElements(this.elements);
1528
- try {
1529
- for (var flatElements_1 = __values(flatElements), flatElements_1_1 = flatElements_1.next(); !flatElements_1_1.done; flatElements_1_1 = flatElements_1.next()) {
1530
- var el = flatElements_1_1.value;
1531
- if (this.isSharedElement(el)) {
1532
- this.sharedElements.push(el);
1533
- }
1534
- else {
1535
- this.renderableElements.push(el);
1536
- }
1537
- }
1538
- }
1539
- catch (e_1_1) { e_1 = { error: e_1_1 }; }
1540
- finally {
1541
- try {
1542
- if (flatElements_1_1 && !flatElements_1_1.done && (_c = flatElements_1.return)) _c.call(flatElements_1);
1543
- }
1544
- finally { if (e_1) throw e_1.error; }
1545
- }
1547
+ var transpiledElements = this.transpileScripts(elements);
1548
+ this.sharedElements = this.flattenElements(transpiledElements).filter(function (el) { return _this.isSharedElement(el); });
1549
+ this.elements = transpiledElements.map(function (el) { return _this.processElementMetadata(el); }).filter(Boolean);
1550
+ this.renderableElements = this.getRenderableElements(this.elements);
1546
1551
  }
1547
1552
  ElementsResolver.prototype.getNgComponents = function () {
1548
1553
  var _this = this;
@@ -1571,8 +1576,31 @@
1571
1576
  ElementsResolver.prototype.isSharedElement = function (el) {
1572
1577
  return Boolean(el.isShared) && el.type !== 'REFERENCE';
1573
1578
  };
1579
+ ElementsResolver.prototype.getRenderableElements = function (elements) {
1580
+ var e_1, _c;
1581
+ var _this = this;
1582
+ var renderable = [];
1583
+ try {
1584
+ for (var elements_1 = __values(elements), elements_1_1 = elements_1.next(); !elements_1_1.done; elements_1_1 = elements_1.next()) {
1585
+ var el = elements_1_1.value;
1586
+ if (!this.isSharedElement(el)) {
1587
+ var children = el.children.filter(function (child) { return !_this.isSharedElement(child); });
1588
+ var renderableChildren = this.getRenderableElements(children);
1589
+ renderable.push.apply(renderable, __spreadArray([Object.assign(Object.assign({}, el), { children: children })], __read(renderableChildren)));
1590
+ }
1591
+ }
1592
+ }
1593
+ catch (e_1_1) { e_1 = { error: e_1_1 }; }
1594
+ finally {
1595
+ try {
1596
+ if (elements_1_1 && !elements_1_1.done && (_c = elements_1.return)) _c.call(elements_1);
1597
+ }
1598
+ finally { if (e_1) throw e_1.error; }
1599
+ }
1600
+ return renderable;
1601
+ };
1574
1602
  ElementsResolver.prototype.getSharedElement = function (element) {
1575
- if (element.type !== 'REFERENCE') {
1603
+ if (!element.reference) {
1576
1604
  return;
1577
1605
  }
1578
1606
  return this.sharedElements.find(function (el) { return element.reference === el.name; });
@@ -1588,45 +1616,52 @@
1588
1616
  return !config.suppressStyles ? (_a = element.styles) !== null && _a !== void 0 ? _a : '' : '';
1589
1617
  };
1590
1618
  ElementsResolver.prototype.processElementMetadata = function (sourceElement) {
1619
+ var _this = this;
1591
1620
  var _a, _b;
1592
- var sharedElement = this.getSharedElement(sourceElement);
1593
1621
  var finalElement;
1594
1622
  if (sourceElement.type === 'REFERENCE') {
1623
+ var sharedElement = this.getSharedElement(sourceElement);
1595
1624
  if (!sharedElement) {
1596
1625
  console.warn("Shared element \"" + sourceElement.reference + "\" not found");
1597
1626
  return;
1598
1627
  }
1599
- finalElement = Object.assign(Object.assign({}, sourceElement), { type: sharedElement.type, template: sharedElement.template, styles: ((_a = sharedElement.styles) !== null && _a !== void 0 ? _a : '') + '\n' + ((_b = sourceElement.styles) !== null && _b !== void 0 ? _b : ''), inputs: Object.assign(Object.assign({}, sharedElement.inputs), sourceElement.inputs), outputs: Object.assign(Object.assign({}, sharedElement.outputs), sourceElement.outputs) });
1628
+ finalElement = Object.assign(Object.assign({}, sourceElement), { children: this.getSharedChildren(sharedElement.children, sourceElement.path), type: sharedElement.type, template: sharedElement.template, styles: ((_a = sharedElement.styles) !== null && _a !== void 0 ? _a : '') + '\n' + ((_b = sourceElement.styles) !== null && _b !== void 0 ? _b : ''), inputs: Object.assign(Object.assign({}, sharedElement.inputs), sourceElement.inputs), outputs: Object.assign(Object.assign({}, sharedElement.outputs), sourceElement.outputs) });
1600
1629
  }
1601
1630
  else {
1602
1631
  finalElement = sourceElement;
1632
+ delete sourceElement.reference;
1603
1633
  }
1604
1634
  finalElement.template = this.resolveElementTemplate(finalElement);
1605
1635
  finalElement.styles = this.resolveElementStyles(finalElement);
1606
- return finalElement;
1636
+ return Object.assign(Object.assign({}, finalElement), { children: finalElement.children
1637
+ .map(function (child) { return _this.processElementMetadata(child); })
1638
+ .filter(Boolean) });
1639
+ };
1640
+ ElementsResolver.prototype.getSharedChildren = function (children, parentPath) {
1641
+ var _this = this;
1642
+ return children.map(function (c) {
1643
+ if (!c.path) {
1644
+ return c;
1645
+ }
1646
+ var _c = __read(c.path.split('/').reverse(), 1), elName = _c[0];
1647
+ var path = parentPath + '/' + elName;
1648
+ return Object.assign(Object.assign({}, c), { path: path, children: _this.getSharedChildren(c.children, path) });
1649
+ });
1607
1650
  };
1608
- ElementsResolver.prototype.resolveElement = function (sourceElement) {
1651
+ ElementsResolver.prototype.resolveElement = function (element) {
1609
1652
  var _a;
1610
- var element = this.processElementMetadata(sourceElement);
1611
- if (!element) {
1612
- return;
1613
- }
1614
1653
  var config = CONFIG[element.type];
1615
1654
  var defaultPlugins = (_a = DEFAULT_PLUGINS[this.uiDef.type]) !== null && _a !== void 0 ? _a : [];
1616
1655
  if (!config) {
1617
1656
  console.warn("Unknown element type \"" + element.type + "\"");
1618
1657
  return;
1619
1658
  }
1620
- var configuredStyles = this.convertInlineStylesToCSS(element.configuredStyles);
1621
- if (configuredStyles) {
1622
- // order is important: styles written by user in CSS code should has higher priority
1623
- element.styles = configuredStyles + element.styles;
1624
- }
1625
- var component = Object.assign(Object.assign({ selector: 'vl-element', template: element.template }, (element.styles ? { styles: [element.styles] } : {})), { providers: [
1659
+ var styles = this.getElementStyles(element);
1660
+ var component = Object.assign(Object.assign({ selector: 'vl-element', template: element.template }, (styles ? { styles: [styles] } : {})), { providers: [
1626
1661
  { provide: DEFAULT_PLUGINS_TOKEN, useValue: defaultPlugins },
1627
1662
  { provide: UI_DEFINITION_METADATA, useValue: this.uiDef },
1628
1663
  { provide: ELEMENT_METADATA, useValue: element },
1629
- { provide: SHARED_ELEMENT_METADATA, useValue: this.getSharedElement(sourceElement) },
1664
+ { provide: SHARED_ELEMENT_METADATA, useValue: this.getSharedElement(element) },
1630
1665
  { provide: ELEMENT_CONFIG, useValue: config },
1631
1666
  { provide: VENDOR_MAP, useValue: vendorMap },
1632
1667
  ] });
@@ -1640,17 +1675,29 @@
1640
1675
  lodash.set(cmp, 'path', element.path);
1641
1676
  return cmp;
1642
1677
  };
1678
+ ElementsResolver.prototype.getElementStyles = function (element) {
1679
+ var result = '';
1680
+ var configuredStyles = this.convertInlineStylesToCSS(element.configuredStyles);
1681
+ if (configuredStyles) {
1682
+ // order is important: styles written by user in CSS code should has higher priority
1683
+ result += configuredStyles;
1684
+ }
1685
+ if (element.styles) {
1686
+ result += element.styles;
1687
+ }
1688
+ return result || undefined;
1689
+ };
1643
1690
  ElementsResolver.prototype.convertInlineStylesToCSS = function (styles) {
1644
1691
  if (!styles) {
1645
1692
  return '';
1646
1693
  }
1647
1694
  var entries = Object.entries(styles);
1648
- var result = ':host {';
1695
+ var result = ':host {\n';
1649
1696
  entries.forEach(function (_c) {
1650
1697
  var _d = __read(_c, 2), style = _d[0], value = _d[1];
1651
- result += lodash.kebabCase(style) + ":" + value + ";";
1698
+ result += " " + lodash.kebabCase(style) + ":" + value + ";\n";
1652
1699
  });
1653
- result += '}';
1700
+ result += '}\n';
1654
1701
  return result;
1655
1702
  };
1656
1703
  return ElementsResolver;
@@ -1661,13 +1708,15 @@
1661
1708
  this.compiler = compiler;
1662
1709
  this.dynamicModuleService = dynamicModuleService;
1663
1710
  }
1664
- LauncherService.prototype.compileModule = function (elements, uiDefs) {
1711
+ LauncherService.prototype.compileModule = function (uiDef, elements) {
1665
1712
  var _this = this;
1666
- this.module = this.getModule(elements, uiDefs);
1713
+ var elementsResolver = new ElementsResolver(uiDef, elements);
1714
+ this.dynamicModuleService.elementsTree = elementsResolver.elements;
1715
+ this.module = this.getModule(elementsResolver.getNgComponents());
1667
1716
  return rxjs.from(this.compiler.compileModuleAndAllComponentsAsync(this.module)).pipe(rxjs.tap(function (m) {
1668
1717
  _this.dynamicModuleService.componentFactories = m.componentFactories;
1669
1718
  _this.moduleInstance = m;
1670
- }));
1719
+ }), rxjs.map(function (m) { return ({ module: m, elements: elementsResolver.elements }); }));
1671
1720
  };
1672
1721
  LauncherService.prototype.destroy = function () {
1673
1722
  if (this.moduleInstance) {
@@ -1679,10 +1728,8 @@
1679
1728
  this.module = undefined;
1680
1729
  }
1681
1730
  };
1682
- LauncherService.prototype.getModule = function (elements, uiDef) {
1731
+ LauncherService.prototype.getModule = function (components) {
1683
1732
  var staticComponents = [ElementChildrenComponent, ElementRendererComponent, CustomTemplateDirective];
1684
- var elementsResolver = new ElementsResolver(uiDef, elements);
1685
- this.dynamicModuleService.elementsTree = elementsResolver.elements;
1686
1733
  var DynamicModule = /** @class */ (function () {
1687
1734
  function DynamicModule() {
1688
1735
  }
@@ -1691,7 +1738,7 @@
1691
1738
  DynamicModule = __decorate([
1692
1739
  i0.NgModule({
1693
1740
  imports: [i7.CommonModule, angularForms.FormsModule, angularForms.ReactiveFormsModule, FederatedModule, dragDrop.DragDropModule],
1694
- declarations: __spreadArray(__spreadArray([], __read(staticComponents)), __read(elementsResolver.getNgComponents())),
1741
+ declarations: __spreadArray(__spreadArray([], __read(staticComponents)), __read(components)),
1695
1742
  jit: true,
1696
1743
  })
1697
1744
  ], DynamicModule);
@@ -1762,10 +1809,14 @@
1762
1809
  return;
1763
1810
  }
1764
1811
  var _a = this.uiDefinition, children = _a.children, uiDefinitionMeta = __rest(_a, ["children"]);
1765
- this.elements = this.elementToMetadataSafe(children);
1766
- var compilation$ = this.launcherService.compileModule(this.elements, uiDefinitionMeta);
1812
+ var elements = this.elementToMetadataSafe(children);
1813
+ var compilation$ = this.launcherService.compileModule(uiDefinitionMeta, elements);
1767
1814
  rxjs.forkJoin([compilation$, this.initializeConfiguration$()])
1768
- .pipe(rxjs.tap(function () { return _this.state$.next({ loading: false, failure: false }); }), rxjs.catchError(function (error) {
1815
+ .pipe(rxjs.tap(function (_c) {
1816
+ var _d = __read(_c, 1), result = _d[0];
1817
+ _this.elements = result.elements;
1818
+ _this.state$.next({ loading: false, failure: false });
1819
+ }), rxjs.catchError(function (error) {
1769
1820
  var _a, _b;
1770
1821
  console.error(error);
1771
1822
  if (!((_b = (_a = _this.uiDefinition) === null || _a === void 0 ? void 0 : _a.properties) === null || _b === void 0 ? void 0 : _b.suppressToastMessages)) {