@veloceapps/sdk 3.0.5 → 3.0.6

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 (40) hide show
  1. package/bundles/veloce-sdk-cms.umd.js +157 -18
  2. package/bundles/veloce-sdk-cms.umd.js.map +1 -1
  3. package/bundles/veloce-sdk-runtime.umd.js +3 -0
  4. package/bundles/veloce-sdk-runtime.umd.js.map +1 -1
  5. package/bundles/veloce-sdk.umd.js +202 -122
  6. package/bundles/veloce-sdk.umd.js.map +1 -1
  7. package/cms/modules/flow-configuration/index.d.ts +2 -0
  8. package/cms/modules/flow-configuration/services/flow-configuration.service.d.ts +10 -1
  9. package/cms/modules/flow-configuration/services/flow-update.service.d.ts +13 -0
  10. package/cms/modules/flow-configuration/types/update.types.d.ts +12 -0
  11. package/cms/utils/line-item.utils.d.ts +1 -0
  12. package/esm2015/cms/modules/flow-configuration/flow-configuration.module.js +4 -3
  13. package/esm2015/cms/modules/flow-configuration/index.js +3 -1
  14. package/esm2015/cms/modules/flow-configuration/services/flow-configuration.service.js +31 -12
  15. package/esm2015/cms/modules/flow-configuration/services/flow-update.service.js +97 -0
  16. package/esm2015/cms/modules/flow-configuration/types/update.types.js +2 -0
  17. package/esm2015/cms/utils/line-item.utils.js +14 -4
  18. package/esm2015/runtime/execution/directives/vl-ramp.directive.js +1 -1
  19. package/esm2015/runtime/services/quote.service.js +4 -1
  20. package/esm2015/src/components/header/cart-overlay/cart-overlay.component.js +60 -0
  21. package/esm2015/src/components/header/cart-overlay/cart-overlay.module.js +21 -0
  22. package/esm2015/src/components/header/header.component.js +16 -10
  23. package/esm2015/src/components/header/header.module.js +6 -4
  24. package/esm2015/src/components/header/header.types.js +1 -1
  25. package/esm2015/src/pages/debug/debug.component.js +16 -11
  26. package/fesm2015/veloce-sdk-cms.js +142 -18
  27. package/fesm2015/veloce-sdk-cms.js.map +1 -1
  28. package/fesm2015/veloce-sdk-runtime.js +3 -0
  29. package/fesm2015/veloce-sdk-runtime.js.map +1 -1
  30. package/fesm2015/veloce-sdk.js +133 -62
  31. package/fesm2015/veloce-sdk.js.map +1 -1
  32. package/package.json +1 -1
  33. package/runtime/execution/directives/vl-ramp.directive.d.ts +1 -1
  34. package/runtime/services/quote.service.d.ts +1 -0
  35. package/src/components/header/cart-overlay/cart-overlay.component.d.ts +21 -0
  36. package/src/components/header/cart-overlay/cart-overlay.module.d.ts +11 -0
  37. package/src/components/header/header.component.d.ts +5 -2
  38. package/src/components/header/header.module.d.ts +3 -1
  39. package/src/components/header/header.types.d.ts +1 -0
  40. package/src/pages/debug/debug.component.d.ts +5 -2
@@ -1,8 +1,10 @@
1
1
  (function (global, factory) {
2
- typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@angular/core'), require('rxjs'), require('@angular/common'), require('@veloce/core'), require('@angular/cdk/drag-drop'), require('@angular/forms'), require('lodash'), require('@veloce/components'), require('@veloce/sdk/runtime'), require('rxjs/operators'), require('@veloce/api'), require('primeng/api'), require('primeng/dynamicdialog'), require('@babel/standalone')) :
3
- typeof define === 'function' && define.amd ? define('@veloce/sdk/cms', ['exports', '@angular/core', 'rxjs', '@angular/common', '@veloce/core', '@angular/cdk/drag-drop', '@angular/forms', 'lodash', '@veloce/components', '@veloce/sdk/runtime', 'rxjs/operators', '@veloce/api', 'primeng/api', 'primeng/dynamicdialog', '@babel/standalone'], factory) :
4
- (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory((global.veloce = global.veloce || {}, global.veloce.sdk = global.veloce.sdk || {}, global.veloce.sdk.cms = {}), global.ng.core, global.rxjs, global.ng.common, global["@veloce/core"], global.ng.cdk.dragDrop, global.ng.forms, global.lodash, global["@veloce/components"], global.veloce.sdk.runtime, global.rxjs.operators, global["@veloce/api"], global["primeng/api"], global["primeng/dynamicdialog"], global["@babel/standalone"]));
5
- })(this, (function (exports, i0, rxjs, i8, core, dragDrop, angularForms, lodash, i6, i2, rxjsOperators, i1, i3, i5, standalone) { 'use strict';
2
+ typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@angular/core'), require('rxjs'), require('@angular/common'), require('@veloce/core'), require('@angular/cdk/drag-drop'), require('@angular/forms'), require('lodash'), require('@veloce/components'), require('@veloce/sdk/runtime'), require('rxjs/operators'), require('@veloce/api'), require('primeng/api'), require('primeng/dynamicdialog'), require('@babel/standalone'), require('moment')) :
3
+ typeof define === 'function' && define.amd ? define('@veloce/sdk/cms', ['exports', '@angular/core', 'rxjs', '@angular/common', '@veloce/core', '@angular/cdk/drag-drop', '@angular/forms', 'lodash', '@veloce/components', '@veloce/sdk/runtime', 'rxjs/operators', '@veloce/api', 'primeng/api', 'primeng/dynamicdialog', '@babel/standalone', 'moment'], factory) :
4
+ (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory((global.veloce = global.veloce || {}, global.veloce.sdk = global.veloce.sdk || {}, global.veloce.sdk.cms = {}), global.ng.core, global.rxjs, global.ng.common, global["@veloce/core"], global.ng.cdk.dragDrop, global.ng.forms, global.lodash, global["@veloce/components"], global.veloce.sdk.runtime, global.rxjs.operators, global["@veloce/api"], global["primeng/api"], global["primeng/dynamicdialog"], global["@babel/standalone"], global.moment));
5
+ })(this, (function (exports, i0, rxjs, i8, core, dragDrop, angularForms, lodash, i6, i2, rxjsOperators, i1, i3, i5, standalone, moment) { 'use strict';
6
+
7
+ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
6
8
 
7
9
  function _interopNamespace(e) {
8
10
  if (e && e.__esModule) return e;
@@ -33,6 +35,7 @@
33
35
  var i1__namespace = /*#__PURE__*/_interopNamespace(i1);
34
36
  var i3__namespace = /*#__PURE__*/_interopNamespace(i3);
35
37
  var i5__namespace = /*#__PURE__*/_interopNamespace(i5);
38
+ var moment__default = /*#__PURE__*/_interopDefaultLegacy(moment);
36
39
 
37
40
  /*! *****************************************************************************
38
41
  Copyright (c) Microsoft Corporation.
@@ -878,7 +881,18 @@
878
881
  return blocks;
879
882
  };
880
883
  var findLineItem = function (id, lineItems) {
881
- return core.EntityUtil.findByFieldHierarchically('id', id, lineItems, 'lineItems');
884
+ return findLineItemWithComparator(lineItems, function (li) { return li.id === id; });
885
+ };
886
+ var findLineItemWithComparator = function (lineItems, comparator) {
887
+ var currentLevel = lineItems;
888
+ while (currentLevel.length) {
889
+ var found = currentLevel.find(comparator);
890
+ if (found) {
891
+ return found;
892
+ }
893
+ currentLevel = lodash.flatten(currentLevel.map(function (parent) { return parent.lineItems; }));
894
+ }
895
+ return;
882
896
  };
883
897
  var insertLineItem = function (lineItem, parentId, toInsert) {
884
898
  var insertData = lineItem.id === parentId ? [toInsert] : [];
@@ -1764,14 +1778,120 @@
1764
1778
  DEFAULT: [],
1765
1779
  };
1766
1780
 
1781
+ var FlowUpdateService = /** @class */ (function () {
1782
+ function FlowUpdateService() {
1783
+ }
1784
+ FlowUpdateService.prototype.update = function (rootLineItem, params) {
1785
+ switch (params.attributeType) {
1786
+ case 'QTY':
1787
+ return this.updateQty(rootLineItem, params);
1788
+ case 'START_DATE':
1789
+ return this.updateStartDate(rootLineItem, params);
1790
+ case 'END_DATE':
1791
+ return this.updateEndDate(rootLineItem, params);
1792
+ case 'PRICE_ADJUSTMENT':
1793
+ return this.updatePriceAdjustment(rootLineItem, params);
1794
+ default:
1795
+ return rootLineItem;
1796
+ }
1797
+ };
1798
+ FlowUpdateService.prototype.delete = function (lineItems, id) {
1799
+ var filtered = lineItems.filter(function (lineItem) { return lineItem.id !== id; });
1800
+ return filtered.map(function (lineItem) { return new LineItemWorker(lineItem).remove(id).li; });
1801
+ };
1802
+ FlowUpdateService.prototype.updateQty = function (rootLineItem, params) {
1803
+ // change quantity allowed only for lineItem
1804
+ if (params.dataType !== 'LINEITEM') {
1805
+ return rootLineItem;
1806
+ }
1807
+ var lineItem = findLineItem(params.id, [rootLineItem]);
1808
+ if (!lineItem) {
1809
+ return rootLineItem;
1810
+ }
1811
+ if (lineItem.id !== rootLineItem.id) {
1812
+ throw new Error('Quantity can be changed only for root product');
1813
+ }
1814
+ var updated = new LineItemWorker(rootLineItem).replace(Object.assign(Object.assign({}, lineItem), { qty: params.newValue }));
1815
+ return updated.li;
1816
+ };
1817
+ FlowUpdateService.prototype.updateStartDate = function (rootLineItem, params) {
1818
+ var lineItem = findLineItem(params.id, [rootLineItem]);
1819
+ if (!lineItem) {
1820
+ return rootLineItem;
1821
+ }
1822
+ var updated = new LineItemWorker(rootLineItem).replace(Object.assign(Object.assign({}, lineItem), { effectiveDate: moment__default["default"](params.newValue).format('YYYY-MM-DD') }));
1823
+ return updated.li;
1824
+ };
1825
+ FlowUpdateService.prototype.updateEndDate = function (rootLineItem, params) {
1826
+ var lineItem = findLineItem(params.id, [rootLineItem]);
1827
+ if (!lineItem) {
1828
+ return rootLineItem;
1829
+ }
1830
+ var updated = new LineItemWorker(rootLineItem).replace(Object.assign(Object.assign({}, lineItem), { endDate: moment__default["default"](params.newValue).format('YYYY-MM-DD') }));
1831
+ return updated.li;
1832
+ };
1833
+ FlowUpdateService.prototype.updatePriceAdjustment = function (rootLineItem, params) {
1834
+ var comparator = params.dataType === 'LINEITEM'
1835
+ ? function (li) { return li.id === params.id; }
1836
+ : params.dataType === 'CHARGE'
1837
+ ? function (li) { return li.chargeItems.some(function (_a) {
1838
+ var id = _a.id;
1839
+ return id === params.id;
1840
+ }); }
1841
+ : params.dataType === 'GROUP_CHARGE'
1842
+ ? function (li) { return li.chargeGroupItems.some(function (_a) {
1843
+ var id = _a.id;
1844
+ return id === params.id;
1845
+ }); }
1846
+ : undefined;
1847
+ if (!comparator) {
1848
+ return rootLineItem;
1849
+ }
1850
+ var lineItem = findLineItemWithComparator([rootLineItem], comparator);
1851
+ if (!lineItem) {
1852
+ return rootLineItem;
1853
+ }
1854
+ var updated;
1855
+ if (params.dataType === 'LINEITEM') {
1856
+ updated = Object.assign(Object.assign({}, lineItem), { chargeItems: lineItem.chargeItems.map(function (chargeItem, index) {
1857
+ return index === 0 ? Object.assign(Object.assign({}, chargeItem), { priceAdjustment: params.newValue }) : chargeItem;
1858
+ }) });
1859
+ }
1860
+ else if (params.dataType === 'CHARGE') {
1861
+ updated = Object.assign(Object.assign({}, lineItem), { chargeItems: lineItem.chargeItems.map(function (chargeItem) {
1862
+ return chargeItem.id === params.id ? Object.assign(Object.assign({}, chargeItem), { priceAdjustment: params.newValue }) : chargeItem;
1863
+ }) });
1864
+ }
1865
+ else if (params.dataType === 'GROUP_CHARGE') {
1866
+ updated = Object.assign(Object.assign({}, lineItem), { chargeGroupItems: lineItem.chargeGroupItems.map(function (chargeGroupItem) {
1867
+ return chargeGroupItem.id === params.id
1868
+ ? Object.assign(Object.assign({}, chargeGroupItem), { priceAdjustment: params.newValue }) : chargeGroupItem;
1869
+ }) });
1870
+ }
1871
+ var updatedRootLineItem = updated ? new LineItemWorker(rootLineItem).replace(updated).li : rootLineItem;
1872
+ return updatedRootLineItem;
1873
+ };
1874
+ return FlowUpdateService;
1875
+ }());
1876
+ FlowUpdateService.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: FlowUpdateService, deps: [], target: i0__namespace.ɵɵFactoryTarget.Injectable });
1877
+ FlowUpdateService.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: FlowUpdateService });
1878
+ i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: FlowUpdateService, decorators: [{
1879
+ type: i0.Injectable
1880
+ }] });
1881
+
1767
1882
  var FlowConfigurationService = /** @class */ (function () {
1768
- function FlowConfigurationService(priceApiService, contextService, messageService) {
1883
+ function FlowConfigurationService(priceApiService, contextService, messageService, updateService) {
1769
1884
  this.priceApiService = priceApiService;
1770
1885
  this.contextService = contextService;
1771
1886
  this.messageService = messageService;
1887
+ this.updateService = updateService;
1772
1888
  this.lineItems = new rxjs.BehaviorSubject([]);
1773
1889
  this.charges = new rxjs.BehaviorSubject({});
1774
1890
  }
1891
+ FlowConfigurationService.prototype.reset = function () {
1892
+ this.lineItems.next([]);
1893
+ this.charges.next({});
1894
+ };
1775
1895
  FlowConfigurationService.prototype.calculate$ = function (currentState) {
1776
1896
  var _this = this;
1777
1897
  var context = this.contextService.resolve();
@@ -1781,17 +1901,25 @@
1781
1901
  if (context) {
1782
1902
  _this.contextService.update({ properties: context.properties });
1783
1903
  }
1784
- }), rxjs.catchError(function (error) {
1785
- console.error(error);
1786
- _this.messageService.add({ severity: 'error', summary: error });
1787
- // bounce back if configuration call has failed
1788
- _this.lineItems.next(_this.lineItems.value.slice());
1789
- return rxjs.throwError(function () { return error; });
1790
- }));
1904
+ }), rxjs.catchError(function (error) { return _this.handleError(error); }));
1791
1905
  };
1792
1906
  FlowConfigurationService.prototype.calculate = function (currentState) {
1793
1907
  this.calculate$(currentState).subscribe();
1794
1908
  };
1909
+ FlowConfigurationService.prototype.update$ = function (params) {
1910
+ var _this = this;
1911
+ return rxjs.of([]).pipe(rxjs.map(function () { return _this.lineItems.value.map(function (li) { return _this.updateService.update(li, params); }); }), rxjs.catchError(function (error) { return _this.handleError(error); }), rxjs.switchMap(function (currentState) { return _this.calculate$(currentState); }));
1912
+ };
1913
+ FlowConfigurationService.prototype.update = function (params) {
1914
+ this.update$(params).subscribe();
1915
+ };
1916
+ FlowConfigurationService.prototype.delete$ = function (id) {
1917
+ var _this = this;
1918
+ return rxjs.of([]).pipe(rxjs.map(function () { return _this.updateService.delete(_this.lineItems.value, id); }), rxjs.catchError(function (error) { return _this.handleError(error); }), rxjs.switchMap(function (currentState) { return _this.calculate$(currentState); }));
1919
+ };
1920
+ FlowConfigurationService.prototype.delete = function (id) {
1921
+ this.delete$(id).subscribe();
1922
+ };
1795
1923
  FlowConfigurationService.prototype.get = function () {
1796
1924
  return this.lineItems.asObservable().pipe(rxjs.shareReplay());
1797
1925
  };
@@ -1826,13 +1954,20 @@
1826
1954
  enumerable: false,
1827
1955
  configurable: true
1828
1956
  });
1957
+ FlowConfigurationService.prototype.handleError = function (error) {
1958
+ console.error(error);
1959
+ this.messageService.add({ severity: 'error', summary: error });
1960
+ // bounce back if configuration call has failed
1961
+ this.lineItems.next(this.lineItems.value.slice());
1962
+ return rxjs.throwError(function () { return error; });
1963
+ };
1829
1964
  return FlowConfigurationService;
1830
1965
  }());
1831
- FlowConfigurationService.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: FlowConfigurationService, deps: [{ token: i1__namespace.PriceApiService }, { token: i2__namespace.ContextService }, { token: i3__namespace.MessageService }], target: i0__namespace.ɵɵFactoryTarget.Injectable });
1966
+ FlowConfigurationService.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: FlowConfigurationService, deps: [{ token: i1__namespace.PriceApiService }, { token: i2__namespace.ContextService }, { token: i3__namespace.MessageService }, { token: FlowUpdateService }], target: i0__namespace.ɵɵFactoryTarget.Injectable });
1832
1967
  FlowConfigurationService.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: FlowConfigurationService });
1833
1968
  i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: FlowConfigurationService, decorators: [{
1834
1969
  type: i0.Injectable
1835
- }], ctorParameters: function () { return [{ type: i1__namespace.PriceApiService }, { type: i2__namespace.ContextService }, { type: i3__namespace.MessageService }]; } });
1970
+ }], ctorParameters: function () { return [{ type: i1__namespace.PriceApiService }, { type: i2__namespace.ContextService }, { type: i3__namespace.MessageService }, { type: FlowUpdateService }]; } });
1836
1971
 
1837
1972
  var FlowConfigurationModule = /** @class */ (function () {
1838
1973
  function FlowConfigurationModule() {
@@ -1841,11 +1976,11 @@
1841
1976
  }());
1842
1977
  FlowConfigurationModule.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: FlowConfigurationModule, deps: [], target: i0__namespace.ɵɵFactoryTarget.NgModule });
1843
1978
  FlowConfigurationModule.ɵmod = i0__namespace.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: FlowConfigurationModule });
1844
- FlowConfigurationModule.ɵinj = i0__namespace.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: FlowConfigurationModule, providers: [FlowConfigurationService, i2.ContextService, i1.PriceApiService] });
1979
+ FlowConfigurationModule.ɵinj = i0__namespace.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: FlowConfigurationModule, providers: [FlowConfigurationService, FlowUpdateService, i2.ContextService, i1.PriceApiService] });
1845
1980
  i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: FlowConfigurationModule, decorators: [{
1846
1981
  type: i0.NgModule,
1847
1982
  args: [{
1848
- providers: [FlowConfigurationService, i2.ContextService, i1.PriceApiService],
1983
+ providers: [FlowConfigurationService, FlowUpdateService, i2.ContextService, i1.PriceApiService],
1849
1984
  }]
1850
1985
  }] });
1851
1986
 
@@ -1855,7 +1990,8 @@
1855
1990
  ConfigurationRuntimeService: ConfigurationRuntimeService,
1856
1991
  ConfigurationService: ConfigurationService,
1857
1992
  FlowConfigurationModule: FlowConfigurationModule,
1858
- FlowConfigurationService: FlowConfigurationService
1993
+ FlowConfigurationService: FlowConfigurationService,
1994
+ FlowUpdateService: FlowUpdateService
1859
1995
  });
1860
1996
 
1861
1997
  var InitAction = { type: 'INIT' };
@@ -1918,6 +2054,7 @@
1918
2054
  isValidScript: isValidScript,
1919
2055
  parseBoundPath: parseBoundPath,
1920
2056
  findLineItem: findLineItem,
2057
+ findLineItemWithComparator: findLineItemWithComparator,
1921
2058
  insertLineItem: insertLineItem,
1922
2059
  removeLineItem: removeLineItem,
1923
2060
  replaceLineItem: replaceLineItem,
@@ -2326,6 +2463,7 @@
2326
2463
  exports.ElementDefinition = ElementDefinition;
2327
2464
  exports.FlowConfigurationModule = FlowConfigurationModule;
2328
2465
  exports.FlowConfigurationService = FlowConfigurationService;
2466
+ exports.FlowUpdateService = FlowUpdateService;
2329
2467
  exports.IntegrationState = IntegrationState;
2330
2468
  exports.LauncherModule = LauncherModule;
2331
2469
  exports.LauncherService = LauncherService;
@@ -2342,6 +2480,7 @@
2342
2480
  exports.extendElementMetadata = extendElementMetadata;
2343
2481
  exports.extractElementMetadata = extractElementMetadata;
2344
2482
  exports.findLineItem = findLineItem;
2483
+ exports.findLineItemWithComparator = findLineItemWithComparator;
2345
2484
  exports.generateLineItem = generateLineItem;
2346
2485
  exports.getAttributeValue = getAttributeValue;
2347
2486
  exports.getAttributes = getAttributes;