@veloceapps/sdk 2.0.6 → 2.0.7

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.
@@ -577,6 +577,64 @@
577
577
  type: i0.Injectable
578
578
  }] });
579
579
 
580
+ var IOPlugin = /** @class */ (function () {
581
+ function IOPlugin(host) {
582
+ var _this = this;
583
+ var _a, _b;
584
+ this.host = host;
585
+ var elementMetadata = this.host.injector.get(ELEMENT_METADATA);
586
+ var inputProvider = this.host.injector.get(IOProviderService);
587
+ var inputs = Object.entries((_a = elementMetadata.inputs) !== null && _a !== void 0 ? _a : {});
588
+ var outputs = Object.entries((_b = elementMetadata.outputs) !== null && _b !== void 0 ? _b : {});
589
+ inputs.forEach(function (_c) {
590
+ var _d = __read(_c, 2), key = _d[0], path = _d[1];
591
+ var _a;
592
+ if (path && typeof path !== 'string') {
593
+ console.error("The value of '" + key + "' input should be a string");
594
+ }
595
+ if (((_a = elementMetadata.outputs) === null || _a === void 0 ? void 0 : _a[key]) !== undefined) {
596
+ console.warn("'" + key + "' appears both in inputs and outputs. To prevent inconsistent behavior please keep them unique ");
597
+ }
598
+ _this.host[key] = inputProvider.connect(elementMetadata, key, path);
599
+ });
600
+ outputs.forEach(function (_c) {
601
+ var _d = __read(_c, 2), key = _d[0], path = _d[1];
602
+ if (path && typeof path !== 'string') {
603
+ console.error("The value of '" + key + "' output should be a string");
604
+ }
605
+ _this.host[key] = inputProvider.provide(elementMetadata, key, path);
606
+ });
607
+ }
608
+ return IOPlugin;
609
+ }());
610
+ IOPlugin.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0__namespace, type: IOPlugin, deps: [{ token: exports.ElementComponent }], target: i0__namespace.ɵɵFactoryTarget.Directive });
611
+ IOPlugin.ɵdir = i0__namespace.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "12.2.16", type: IOPlugin, ngImport: i0__namespace });
612
+ i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0__namespace, type: IOPlugin, decorators: [{
613
+ type: i0.Directive
614
+ }], ctorParameters: function () { return [{ type: exports.ElementComponent }]; } });
615
+
616
+ var CONFIG = {
617
+ CUSTOM: {
618
+ component: exports.ElementComponent,
619
+ plugins: [IOPlugin],
620
+ },
621
+ CONTAINER: {
622
+ component: exports.ElementComponent,
623
+ defaultTemplate: '<element-children></element-children>',
624
+ plugins: [],
625
+ },
626
+ SERVICE: {
627
+ component: exports.ElementComponent,
628
+ plugins: [IOPlugin],
629
+ suppressTemplate: true,
630
+ suppressStyles: true,
631
+ },
632
+ REFERENCE: {
633
+ component: exports.ElementComponent,
634
+ plugins: [IOPlugin],
635
+ },
636
+ };
637
+
580
638
  var EXPORTED_CLASS_REGEX = /export class (\S+)/;
581
639
  var METADATA_DECORATOR_REGEX = /@ElementDefinition\(([\s\S]+)\)(\n|.)*export class/g;
582
640
  var elementToMetadata = function (el, parentPath) {
@@ -601,8 +659,8 @@
601
659
  reference: metadata.reference,
602
660
  inputs: metadata.inputs,
603
661
  outputs: metadata.outputs,
604
- children: metadata.children.map(function (_b) {
605
- var name = _b.name;
662
+ children: metadata.children.map(function (_c) {
663
+ var name = _c.name;
606
664
  return name;
607
665
  }),
608
666
  };
@@ -635,6 +693,13 @@
635
693
  var updated = Object.assign(Object.assign({}, eval("(" + metadataString + ")")), extend);
636
694
  return script.replace(metadataString, JSON.stringify(updated));
637
695
  };
696
+ var getElementConfig = function (type) {
697
+ return CONFIG[type];
698
+ };
699
+ var doesElementSupportIO = function (type) {
700
+ var _a, _b;
701
+ return (_b = (_a = getElementConfig(type).plugins) === null || _a === void 0 ? void 0 : _a.includes(IOPlugin)) !== null && _b !== void 0 ? _b : false;
702
+ };
638
703
 
639
704
  var ElementContextService = /** @class */ (function () {
640
705
  function ElementContextService() {
@@ -854,11 +919,14 @@
854
919
  this.apiService = apiService;
855
920
  this.contextService = contextService;
856
921
  this.runtimeContextService = runtimeContextService;
857
- this._isInitialized = new rxjs.BehaviorSubject(false);
922
+ this._isInitialized = false;
858
923
  this.uiDefinitionProperties = {};
859
924
  }
860
925
  ConfigurationRuntimeService.prototype.reset = function () {
861
- this._isInitialized.next(false);
926
+ this._isInitialized = false;
927
+ this._runtimeContext = undefined;
928
+ this._assets = undefined;
929
+ this.uiDefinitionProperties = {};
862
930
  };
863
931
  ConfigurationRuntimeService.prototype.initTestMode = function (modelId, uiDefinitionProperties) {
864
932
  var _this = this;
@@ -875,7 +943,7 @@
875
943
  runtimeMode: i2.RuntimeMode.TEST,
876
944
  };
877
945
  _this._runtimeContext = runtimeContext;
878
- _this._isInitialized.next(true);
946
+ _this._isInitialized = true;
879
947
  }));
880
948
  };
881
949
  ConfigurationRuntimeService.prototype.init = function (props) {
@@ -896,7 +964,7 @@
896
964
  });
897
965
  }
898
966
  _this._runtimeContext = mergeContext;
899
- _this._isInitialized.next(true);
967
+ _this._isInitialized = true;
900
968
  }));
901
969
  };
902
970
  ConfigurationRuntimeService.prototype.patchContext = function (context, patch) {
@@ -905,16 +973,9 @@
905
973
  ConfigurationRuntimeService.prototype.getAsset = function (lineItem) {
906
974
  return this._assets && this._assets.find(function (a) { return a.id === lineItem.openOrderLineItemId || a.id === lineItem.assetId; });
907
975
  };
908
- Object.defineProperty(ConfigurationRuntimeService.prototype, "isInitialized$", {
909
- get: function () {
910
- return this._isInitialized.asObservable();
911
- },
912
- enumerable: false,
913
- configurable: true
914
- });
915
976
  Object.defineProperty(ConfigurationRuntimeService.prototype, "isInitialized", {
916
977
  get: function () {
917
- return this._isInitialized.getValue();
978
+ return this._isInitialized;
918
979
  },
919
980
  enumerable: false,
920
981
  configurable: true
@@ -953,6 +1014,12 @@
953
1014
  this.lineItem = new rxjs.BehaviorSubject(undefined);
954
1015
  this.charges = new rxjs.BehaviorSubject({});
955
1016
  }
1017
+ ConfigurationService.prototype.reset = function () {
1018
+ this.runtimeService.reset();
1019
+ this.states = {};
1020
+ this.lineItem.next(undefined);
1021
+ this.charges.next({});
1022
+ };
956
1023
  ConfigurationService.prototype.patch = function (lineItem) {
957
1024
  var _this = this;
958
1025
  if (!this.lineItem.value) {
@@ -1376,6 +1443,8 @@
1376
1443
  metadataToElement: metadataToElement,
1377
1444
  extractElementMetadata: extractElementMetadata,
1378
1445
  extendElementMetadata: extendElementMetadata,
1446
+ getElementConfig: getElementConfig,
1447
+ doesElementSupportIO: doesElementSupportIO,
1379
1448
  parseBoundPath: parseBoundPath,
1380
1449
  findLineItem: findLineItem,
1381
1450
  insertLineItem: insertLineItem,
@@ -1453,65 +1522,9 @@
1453
1522
  DEFAULT: [ScriptPlugin],
1454
1523
  };
1455
1524
 
1456
- var IOPlugin = /** @class */ (function () {
1457
- function IOPlugin(host) {
1458
- var _this = this;
1459
- var _a, _b;
1460
- this.host = host;
1461
- var elementMetadata = this.host.injector.get(ELEMENT_METADATA);
1462
- var inputProvider = this.host.injector.get(IOProviderService);
1463
- var inputs = Object.entries((_a = elementMetadata.inputs) !== null && _a !== void 0 ? _a : {});
1464
- var outputs = Object.entries((_b = elementMetadata.outputs) !== null && _b !== void 0 ? _b : {});
1465
- inputs.forEach(function (_c) {
1466
- var _d = __read(_c, 2), key = _d[0], path = _d[1];
1467
- var _a;
1468
- if (path && typeof path !== 'string') {
1469
- console.error("The value of '" + key + "' input should be a string");
1470
- }
1471
- if (((_a = elementMetadata.outputs) === null || _a === void 0 ? void 0 : _a[key]) !== undefined) {
1472
- console.warn("'" + key + "' appears both in inputs and outputs. To prevent inconsistent behavior please keep them unique ");
1473
- }
1474
- _this.host[key] = inputProvider.connect(elementMetadata, key, path);
1475
- });
1476
- outputs.forEach(function (_c) {
1477
- var _d = __read(_c, 2), key = _d[0], path = _d[1];
1478
- if (path && typeof path !== 'string') {
1479
- console.error("The value of '" + key + "' output should be a string");
1480
- }
1481
- _this.host[key] = inputProvider.provide(elementMetadata, key, path);
1482
- });
1483
- }
1484
- return IOPlugin;
1485
- }());
1486
- IOPlugin.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0__namespace, type: IOPlugin, deps: [{ token: exports.ElementComponent }], target: i0__namespace.ɵɵFactoryTarget.Directive });
1487
- IOPlugin.ɵdir = i0__namespace.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "12.2.16", type: IOPlugin, ngImport: i0__namespace });
1488
- i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0__namespace, type: IOPlugin, decorators: [{
1489
- type: i0.Directive
1490
- }], ctorParameters: function () { return [{ type: exports.ElementComponent }]; } });
1491
-
1492
- var CONFIG = {
1493
- CUSTOM: {
1494
- component: exports.ElementComponent,
1495
- plugins: [IOPlugin],
1496
- },
1497
- CONTAINER: {
1498
- component: exports.ElementComponent,
1499
- template: '<element-children></element-children>',
1500
- plugins: [IOPlugin],
1501
- },
1502
- SERVICE: {
1503
- component: exports.ElementComponent,
1504
- plugins: [IOPlugin],
1505
- },
1506
- REFERENCE: {
1507
- component: exports.ElementComponent,
1508
- plugins: [IOPlugin],
1509
- },
1510
- };
1511
-
1512
1525
  var ElementsResolver = /** @class */ (function () {
1513
1526
  function ElementsResolver(uiDef, elements) {
1514
- var e_1, _b;
1527
+ var e_1, _c;
1515
1528
  this.uiDef = uiDef;
1516
1529
  this.renderableElements = [];
1517
1530
  this.sharedElements = [];
@@ -1531,7 +1544,7 @@
1531
1544
  catch (e_1_1) { e_1 = { error: e_1_1 }; }
1532
1545
  finally {
1533
1546
  try {
1534
- if (flatElements_1_1 && !flatElements_1_1.done && (_b = flatElements_1.return)) _b.call(flatElements_1);
1547
+ if (flatElements_1_1 && !flatElements_1_1.done && (_c = flatElements_1.return)) _c.call(flatElements_1);
1535
1548
  }
1536
1549
  finally { if (e_1) throw e_1.error; }
1537
1550
  }
@@ -1563,21 +1576,38 @@
1563
1576
  if (element.type !== 'REFERENCE') {
1564
1577
  return;
1565
1578
  }
1566
- return this.sharedElements.find(function (el) { return element.reference === el.name; });
1579
+ return this.sharedElements.find(function (el) { return element.reference === el.reference; });
1580
+ };
1581
+ ElementsResolver.prototype.resolveElementTemplate = function (element) {
1582
+ var config = CONFIG[element.type];
1583
+ var template = !config.suppressTemplate ? element.template : '';
1584
+ return template || config.defaultTemplate || '';
1585
+ };
1586
+ ElementsResolver.prototype.resolveElementStyles = function (element) {
1587
+ var _a;
1588
+ var config = CONFIG[element.type];
1589
+ return !config.suppressStyles ? (_a = element.styles) !== null && _a !== void 0 ? _a : '' : '';
1567
1590
  };
1568
- ElementsResolver.prototype.processElementMetadata = function (element, sharedElement) {
1569
- if (element.type === 'REFERENCE') {
1591
+ ElementsResolver.prototype.processElementMetadata = function (sourceElement) {
1592
+ var _a, _b;
1593
+ var sharedElement = this.getSharedElement(sourceElement);
1594
+ var finalElement;
1595
+ if (sourceElement.type === 'REFERENCE') {
1570
1596
  if (!sharedElement) {
1571
- console.warn("Shared element \"" + element.reference + "\" not found");
1597
+ console.warn("Shared element \"" + sourceElement.reference + "\" not found");
1572
1598
  return;
1573
1599
  }
1574
- return Object.assign(Object.assign({}, element), { type: sharedElement.type, template: sharedElement.template, styles: sharedElement.styles, inputs: Object.assign(Object.assign({}, sharedElement.inputs), element.inputs), outputs: Object.assign(Object.assign({}, sharedElement.outputs), element.outputs) });
1600
+ 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) });
1575
1601
  }
1576
- return element;
1602
+ else {
1603
+ finalElement = sourceElement;
1604
+ }
1605
+ finalElement.template = this.resolveElementTemplate(finalElement);
1606
+ finalElement.styles = this.resolveElementStyles(finalElement);
1607
+ return finalElement;
1577
1608
  };
1578
1609
  ElementsResolver.prototype.resolveElement = function (sourceElement) {
1579
- var sharedElement = this.getSharedElement(sourceElement);
1580
- var element = this.processElementMetadata(sourceElement, sharedElement);
1610
+ var element = this.processElementMetadata(sourceElement);
1581
1611
  if (!element) {
1582
1612
  return;
1583
1613
  }
@@ -1587,11 +1617,11 @@
1587
1617
  console.warn("Unknown element type \"" + element.type + "\"");
1588
1618
  return;
1589
1619
  }
1590
- var component = Object.assign(Object.assign({ selector: 'vl-element', template: element.template || config.template || '' }, (element.styles ? { styles: [element.styles] } : {})), { providers: [
1620
+ var component = Object.assign(Object.assign({ selector: 'vl-element', template: element.template }, (element.styles ? { styles: [element.styles] } : {})), { providers: [
1591
1621
  { provide: DEFAULT_PLUGINS_TOKEN, useValue: defaultPlugins },
1592
1622
  { provide: UI_DEFINITION_METADATA, useValue: this.uiDef },
1593
1623
  { provide: ELEMENT_METADATA, useValue: element },
1594
- { provide: SHARED_ELEMENT_METADATA, useValue: sharedElement },
1624
+ { provide: SHARED_ELEMENT_METADATA, useValue: this.getSharedElement(sourceElement) },
1595
1625
  { provide: ELEMENT_CONFIG, useValue: config },
1596
1626
  ] });
1597
1627
  var cmp = i0.Component(component)(/** @class */ (function (_super) {
@@ -1829,7 +1859,7 @@
1829
1859
  PreviewComponent.prototype.ngOnDestroy = function () {
1830
1860
  this.destroy$.next();
1831
1861
  this.destroy$.complete();
1832
- this.runtimeService.reset();
1862
+ this.configurationService.reset();
1833
1863
  };
1834
1864
  PreviewComponent.prototype.initializeConfiguration$ = function () {
1835
1865
  var _this = this;
@@ -2007,6 +2037,7 @@
2007
2037
  exports.SHARED_ELEMENT_METADATA = SHARED_ELEMENT_METADATA;
2008
2038
  exports.TemplatesService = TemplatesService;
2009
2039
  exports.UI_DEFINITION_METADATA = UI_DEFINITION_METADATA;
2040
+ exports.doesElementSupportIO = doesElementSupportIO;
2010
2041
  exports.elementToMetadata = elementToMetadata;
2011
2042
  exports.extendElementMetadata = extendElementMetadata;
2012
2043
  exports.extractElementMetadata = extractElementMetadata;
@@ -2015,6 +2046,7 @@
2015
2046
  exports.getAttributeValue = getAttributeValue;
2016
2047
  exports.getAttributes = getAttributes;
2017
2048
  exports.getDefaultLineItem = getDefaultLineItem;
2049
+ exports.getElementConfig = getElementConfig;
2018
2050
  exports.getRecommendedPrices = getRecommendedPrices;
2019
2051
  exports.insertLineItem = insertLineItem;
2020
2052
  exports.mapAttributes = mapAttributes;