@veloceapps/sdk 2.0.5 → 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.
- package/bundles/veloce-sdk-cms.umd.js +117 -81
- package/bundles/veloce-sdk-cms.umd.js.map +1 -1
- package/cms/modules/configuration/services/configuration-runtime.service.d.ts +1 -1
- package/cms/modules/configuration/services/configuration.service.d.ts +1 -0
- package/cms/types/common.types.d.ts +3 -4
- package/cms/utils/element.utils.d.ts +3 -1
- package/cms/utils/elements-resolver.d.ts +2 -0
- package/esm2015/cms/cms.elements.js +5 -3
- package/esm2015/cms/components/preview/preview.component.js +2 -1
- package/esm2015/cms/modules/configuration/services/configuration-runtime.service.js +12 -9
- package/esm2015/cms/modules/configuration/services/configuration.service.js +7 -1
- package/esm2015/cms/types/common.types.js +1 -1
- package/esm2015/cms/utils/element.utils.js +10 -1
- package/esm2015/cms/utils/elements-resolver.js +28 -11
- package/fesm2015/veloce-sdk-cms.js +109 -71
- package/fesm2015/veloce-sdk-cms.js.map +1 -1
- package/package.json +1 -1
|
@@ -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 (
|
|
605
|
-
var 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,9 +919,15 @@
|
|
|
854
919
|
this.apiService = apiService;
|
|
855
920
|
this.contextService = contextService;
|
|
856
921
|
this.runtimeContextService = runtimeContextService;
|
|
857
|
-
this._isInitialized =
|
|
922
|
+
this._isInitialized = false;
|
|
858
923
|
this.uiDefinitionProperties = {};
|
|
859
924
|
}
|
|
925
|
+
ConfigurationRuntimeService.prototype.reset = function () {
|
|
926
|
+
this._isInitialized = false;
|
|
927
|
+
this._runtimeContext = undefined;
|
|
928
|
+
this._assets = undefined;
|
|
929
|
+
this.uiDefinitionProperties = {};
|
|
930
|
+
};
|
|
860
931
|
ConfigurationRuntimeService.prototype.initTestMode = function (modelId, uiDefinitionProperties) {
|
|
861
932
|
var _this = this;
|
|
862
933
|
this.uiDefinitionProperties = uiDefinitionProperties;
|
|
@@ -872,7 +943,7 @@
|
|
|
872
943
|
runtimeMode: i2.RuntimeMode.TEST,
|
|
873
944
|
};
|
|
874
945
|
_this._runtimeContext = runtimeContext;
|
|
875
|
-
_this._isInitialized
|
|
946
|
+
_this._isInitialized = true;
|
|
876
947
|
}));
|
|
877
948
|
};
|
|
878
949
|
ConfigurationRuntimeService.prototype.init = function (props) {
|
|
@@ -893,7 +964,7 @@
|
|
|
893
964
|
});
|
|
894
965
|
}
|
|
895
966
|
_this._runtimeContext = mergeContext;
|
|
896
|
-
_this._isInitialized
|
|
967
|
+
_this._isInitialized = true;
|
|
897
968
|
}));
|
|
898
969
|
};
|
|
899
970
|
ConfigurationRuntimeService.prototype.patchContext = function (context, patch) {
|
|
@@ -902,16 +973,9 @@
|
|
|
902
973
|
ConfigurationRuntimeService.prototype.getAsset = function (lineItem) {
|
|
903
974
|
return this._assets && this._assets.find(function (a) { return a.id === lineItem.openOrderLineItemId || a.id === lineItem.assetId; });
|
|
904
975
|
};
|
|
905
|
-
Object.defineProperty(ConfigurationRuntimeService.prototype, "isInitialized$", {
|
|
906
|
-
get: function () {
|
|
907
|
-
return this._isInitialized.asObservable();
|
|
908
|
-
},
|
|
909
|
-
enumerable: false,
|
|
910
|
-
configurable: true
|
|
911
|
-
});
|
|
912
976
|
Object.defineProperty(ConfigurationRuntimeService.prototype, "isInitialized", {
|
|
913
977
|
get: function () {
|
|
914
|
-
return this._isInitialized
|
|
978
|
+
return this._isInitialized;
|
|
915
979
|
},
|
|
916
980
|
enumerable: false,
|
|
917
981
|
configurable: true
|
|
@@ -950,6 +1014,12 @@
|
|
|
950
1014
|
this.lineItem = new rxjs.BehaviorSubject(undefined);
|
|
951
1015
|
this.charges = new rxjs.BehaviorSubject({});
|
|
952
1016
|
}
|
|
1017
|
+
ConfigurationService.prototype.reset = function () {
|
|
1018
|
+
this.runtimeService.reset();
|
|
1019
|
+
this.states = {};
|
|
1020
|
+
this.lineItem.next(undefined);
|
|
1021
|
+
this.charges.next({});
|
|
1022
|
+
};
|
|
953
1023
|
ConfigurationService.prototype.patch = function (lineItem) {
|
|
954
1024
|
var _this = this;
|
|
955
1025
|
if (!this.lineItem.value) {
|
|
@@ -1373,6 +1443,8 @@
|
|
|
1373
1443
|
metadataToElement: metadataToElement,
|
|
1374
1444
|
extractElementMetadata: extractElementMetadata,
|
|
1375
1445
|
extendElementMetadata: extendElementMetadata,
|
|
1446
|
+
getElementConfig: getElementConfig,
|
|
1447
|
+
doesElementSupportIO: doesElementSupportIO,
|
|
1376
1448
|
parseBoundPath: parseBoundPath,
|
|
1377
1449
|
findLineItem: findLineItem,
|
|
1378
1450
|
insertLineItem: insertLineItem,
|
|
@@ -1450,65 +1522,9 @@
|
|
|
1450
1522
|
DEFAULT: [ScriptPlugin],
|
|
1451
1523
|
};
|
|
1452
1524
|
|
|
1453
|
-
var IOPlugin = /** @class */ (function () {
|
|
1454
|
-
function IOPlugin(host) {
|
|
1455
|
-
var _this = this;
|
|
1456
|
-
var _a, _b;
|
|
1457
|
-
this.host = host;
|
|
1458
|
-
var elementMetadata = this.host.injector.get(ELEMENT_METADATA);
|
|
1459
|
-
var inputProvider = this.host.injector.get(IOProviderService);
|
|
1460
|
-
var inputs = Object.entries((_a = elementMetadata.inputs) !== null && _a !== void 0 ? _a : {});
|
|
1461
|
-
var outputs = Object.entries((_b = elementMetadata.outputs) !== null && _b !== void 0 ? _b : {});
|
|
1462
|
-
inputs.forEach(function (_c) {
|
|
1463
|
-
var _d = __read(_c, 2), key = _d[0], path = _d[1];
|
|
1464
|
-
var _a;
|
|
1465
|
-
if (path && typeof path !== 'string') {
|
|
1466
|
-
console.error("The value of '" + key + "' input should be a string");
|
|
1467
|
-
}
|
|
1468
|
-
if (((_a = elementMetadata.outputs) === null || _a === void 0 ? void 0 : _a[key]) !== undefined) {
|
|
1469
|
-
console.warn("'" + key + "' appears both in inputs and outputs. To prevent inconsistent behavior please keep them unique ");
|
|
1470
|
-
}
|
|
1471
|
-
_this.host[key] = inputProvider.connect(elementMetadata, key, path);
|
|
1472
|
-
});
|
|
1473
|
-
outputs.forEach(function (_c) {
|
|
1474
|
-
var _d = __read(_c, 2), key = _d[0], path = _d[1];
|
|
1475
|
-
if (path && typeof path !== 'string') {
|
|
1476
|
-
console.error("The value of '" + key + "' output should be a string");
|
|
1477
|
-
}
|
|
1478
|
-
_this.host[key] = inputProvider.provide(elementMetadata, key, path);
|
|
1479
|
-
});
|
|
1480
|
-
}
|
|
1481
|
-
return IOPlugin;
|
|
1482
|
-
}());
|
|
1483
|
-
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 });
|
|
1484
|
-
IOPlugin.ɵdir = i0__namespace.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "12.2.16", type: IOPlugin, ngImport: i0__namespace });
|
|
1485
|
-
i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0__namespace, type: IOPlugin, decorators: [{
|
|
1486
|
-
type: i0.Directive
|
|
1487
|
-
}], ctorParameters: function () { return [{ type: exports.ElementComponent }]; } });
|
|
1488
|
-
|
|
1489
|
-
var CONFIG = {
|
|
1490
|
-
CUSTOM: {
|
|
1491
|
-
component: exports.ElementComponent,
|
|
1492
|
-
plugins: [IOPlugin],
|
|
1493
|
-
},
|
|
1494
|
-
CONTAINER: {
|
|
1495
|
-
component: exports.ElementComponent,
|
|
1496
|
-
template: '<element-children></element-children>',
|
|
1497
|
-
plugins: [IOPlugin],
|
|
1498
|
-
},
|
|
1499
|
-
SERVICE: {
|
|
1500
|
-
component: exports.ElementComponent,
|
|
1501
|
-
plugins: [IOPlugin],
|
|
1502
|
-
},
|
|
1503
|
-
REFERENCE: {
|
|
1504
|
-
component: exports.ElementComponent,
|
|
1505
|
-
plugins: [IOPlugin],
|
|
1506
|
-
},
|
|
1507
|
-
};
|
|
1508
|
-
|
|
1509
1525
|
var ElementsResolver = /** @class */ (function () {
|
|
1510
1526
|
function ElementsResolver(uiDef, elements) {
|
|
1511
|
-
var e_1,
|
|
1527
|
+
var e_1, _c;
|
|
1512
1528
|
this.uiDef = uiDef;
|
|
1513
1529
|
this.renderableElements = [];
|
|
1514
1530
|
this.sharedElements = [];
|
|
@@ -1528,7 +1544,7 @@
|
|
|
1528
1544
|
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
1529
1545
|
finally {
|
|
1530
1546
|
try {
|
|
1531
|
-
if (flatElements_1_1 && !flatElements_1_1.done && (
|
|
1547
|
+
if (flatElements_1_1 && !flatElements_1_1.done && (_c = flatElements_1.return)) _c.call(flatElements_1);
|
|
1532
1548
|
}
|
|
1533
1549
|
finally { if (e_1) throw e_1.error; }
|
|
1534
1550
|
}
|
|
@@ -1560,21 +1576,38 @@
|
|
|
1560
1576
|
if (element.type !== 'REFERENCE') {
|
|
1561
1577
|
return;
|
|
1562
1578
|
}
|
|
1563
|
-
return this.sharedElements.find(function (el) { return element.reference === el.
|
|
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 || '';
|
|
1564
1585
|
};
|
|
1565
|
-
ElementsResolver.prototype.
|
|
1566
|
-
|
|
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 : '' : '';
|
|
1590
|
+
};
|
|
1591
|
+
ElementsResolver.prototype.processElementMetadata = function (sourceElement) {
|
|
1592
|
+
var _a, _b;
|
|
1593
|
+
var sharedElement = this.getSharedElement(sourceElement);
|
|
1594
|
+
var finalElement;
|
|
1595
|
+
if (sourceElement.type === 'REFERENCE') {
|
|
1567
1596
|
if (!sharedElement) {
|
|
1568
|
-
console.warn("Shared element \"" +
|
|
1597
|
+
console.warn("Shared element \"" + sourceElement.reference + "\" not found");
|
|
1569
1598
|
return;
|
|
1570
1599
|
}
|
|
1571
|
-
|
|
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) });
|
|
1601
|
+
}
|
|
1602
|
+
else {
|
|
1603
|
+
finalElement = sourceElement;
|
|
1572
1604
|
}
|
|
1573
|
-
|
|
1605
|
+
finalElement.template = this.resolveElementTemplate(finalElement);
|
|
1606
|
+
finalElement.styles = this.resolveElementStyles(finalElement);
|
|
1607
|
+
return finalElement;
|
|
1574
1608
|
};
|
|
1575
1609
|
ElementsResolver.prototype.resolveElement = function (sourceElement) {
|
|
1576
|
-
var
|
|
1577
|
-
var element = this.processElementMetadata(sourceElement, sharedElement);
|
|
1610
|
+
var element = this.processElementMetadata(sourceElement);
|
|
1578
1611
|
if (!element) {
|
|
1579
1612
|
return;
|
|
1580
1613
|
}
|
|
@@ -1584,11 +1617,11 @@
|
|
|
1584
1617
|
console.warn("Unknown element type \"" + element.type + "\"");
|
|
1585
1618
|
return;
|
|
1586
1619
|
}
|
|
1587
|
-
var component = Object.assign(Object.assign({ selector: 'vl-element', template: element.template
|
|
1620
|
+
var component = Object.assign(Object.assign({ selector: 'vl-element', template: element.template }, (element.styles ? { styles: [element.styles] } : {})), { providers: [
|
|
1588
1621
|
{ provide: DEFAULT_PLUGINS_TOKEN, useValue: defaultPlugins },
|
|
1589
1622
|
{ provide: UI_DEFINITION_METADATA, useValue: this.uiDef },
|
|
1590
1623
|
{ provide: ELEMENT_METADATA, useValue: element },
|
|
1591
|
-
{ provide: SHARED_ELEMENT_METADATA, useValue:
|
|
1624
|
+
{ provide: SHARED_ELEMENT_METADATA, useValue: this.getSharedElement(sourceElement) },
|
|
1592
1625
|
{ provide: ELEMENT_CONFIG, useValue: config },
|
|
1593
1626
|
] });
|
|
1594
1627
|
var cmp = i0.Component(component)(/** @class */ (function (_super) {
|
|
@@ -1826,6 +1859,7 @@
|
|
|
1826
1859
|
PreviewComponent.prototype.ngOnDestroy = function () {
|
|
1827
1860
|
this.destroy$.next();
|
|
1828
1861
|
this.destroy$.complete();
|
|
1862
|
+
this.configurationService.reset();
|
|
1829
1863
|
};
|
|
1830
1864
|
PreviewComponent.prototype.initializeConfiguration$ = function () {
|
|
1831
1865
|
var _this = this;
|
|
@@ -2003,6 +2037,7 @@
|
|
|
2003
2037
|
exports.SHARED_ELEMENT_METADATA = SHARED_ELEMENT_METADATA;
|
|
2004
2038
|
exports.TemplatesService = TemplatesService;
|
|
2005
2039
|
exports.UI_DEFINITION_METADATA = UI_DEFINITION_METADATA;
|
|
2040
|
+
exports.doesElementSupportIO = doesElementSupportIO;
|
|
2006
2041
|
exports.elementToMetadata = elementToMetadata;
|
|
2007
2042
|
exports.extendElementMetadata = extendElementMetadata;
|
|
2008
2043
|
exports.extractElementMetadata = extractElementMetadata;
|
|
@@ -2011,6 +2046,7 @@
|
|
|
2011
2046
|
exports.getAttributeValue = getAttributeValue;
|
|
2012
2047
|
exports.getAttributes = getAttributes;
|
|
2013
2048
|
exports.getDefaultLineItem = getDefaultLineItem;
|
|
2049
|
+
exports.getElementConfig = getElementConfig;
|
|
2014
2050
|
exports.getRecommendedPrices = getRecommendedPrices;
|
|
2015
2051
|
exports.insertLineItem = insertLineItem;
|
|
2016
2052
|
exports.mapAttributes = mapAttributes;
|