@veloceapps/sdk 3.0.13 → 3.0.15
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 +94 -90
- package/bundles/veloce-sdk-cms.umd.js.map +1 -1
- package/bundles/veloce-sdk.umd.js +8 -6
- package/bundles/veloce-sdk.umd.js.map +1 -1
- package/cms/modules/flow-configuration/services/flow-configuration.service.d.ts +2 -2
- package/cms/modules/flow-configuration/services/flow-update.service.d.ts +4 -5
- package/esm2015/cms/modules/configuration/services/configuration.service.js +2 -4
- package/esm2015/cms/modules/flow-configuration/services/flow-configuration.service.js +7 -5
- package/esm2015/cms/modules/flow-configuration/services/flow-update.service.js +74 -70
- package/esm2015/src/components/header/cart-overlay/cart-overlay.component.js +9 -7
- package/fesm2015/veloce-sdk-cms.js +79 -76
- package/fesm2015/veloce-sdk-cms.js.map +1 -1
- package/fesm2015/veloce-sdk.js +8 -6
- package/fesm2015/veloce-sdk.js.map +1 -1
- package/package.json +1 -1
|
@@ -1287,9 +1287,7 @@
|
|
|
1287
1287
|
.configureLineItem({ configurationRequest: configurationRequest, runtimeModel: runtimeModel, pricingEnabled: pricingEnabled })
|
|
1288
1288
|
.pipe(rxjsOperators.map(function (_f) {
|
|
1289
1289
|
var lineItem = _f.lineItem, context = _f.context, charges = _f.charges, deletedLineItems = _f.deletedLineItems;
|
|
1290
|
-
|
|
1291
|
-
_this.contextService.update({ properties: context.properties });
|
|
1292
|
-
}
|
|
1290
|
+
_this.contextService.update(context !== null && context !== void 0 ? context : {});
|
|
1293
1291
|
_this.charges.next(charges !== null && charges !== void 0 ? charges : {});
|
|
1294
1292
|
if (deletedLineItems === null || deletedLineItems === void 0 ? void 0 : deletedLineItems.length) {
|
|
1295
1293
|
_this.showInactiveProductsConfirmation();
|
|
@@ -1794,18 +1792,36 @@
|
|
|
1794
1792
|
var FlowUpdateService = /** @class */ (function () {
|
|
1795
1793
|
function FlowUpdateService() {
|
|
1796
1794
|
}
|
|
1797
|
-
FlowUpdateService.prototype.update = function (
|
|
1798
|
-
|
|
1799
|
-
|
|
1800
|
-
|
|
1801
|
-
|
|
1802
|
-
|
|
1803
|
-
|
|
1804
|
-
|
|
1805
|
-
|
|
1806
|
-
|
|
1807
|
-
|
|
1808
|
-
|
|
1795
|
+
FlowUpdateService.prototype.update = function (rootLineItems, updates) {
|
|
1796
|
+
var _this = this;
|
|
1797
|
+
var remainingUpdates = __spreadArray([], __read(updates));
|
|
1798
|
+
var currentLevel = rootLineItems;
|
|
1799
|
+
while (currentLevel.length && remainingUpdates.length) {
|
|
1800
|
+
currentLevel.forEach(function (li) {
|
|
1801
|
+
var unhandledUpdates = [];
|
|
1802
|
+
remainingUpdates.forEach(function (update) {
|
|
1803
|
+
var updated = false;
|
|
1804
|
+
switch (update.dataType) {
|
|
1805
|
+
case 'LINEITEM':
|
|
1806
|
+
updated = _this.applyLineItemUpdate(li, update);
|
|
1807
|
+
break;
|
|
1808
|
+
case 'CHARGE':
|
|
1809
|
+
updated = _this.applyChargeUpdate(li, update);
|
|
1810
|
+
break;
|
|
1811
|
+
case 'GROUP_CHARGE':
|
|
1812
|
+
updated = _this.applyChargeGroupUpdate(li, update);
|
|
1813
|
+
break;
|
|
1814
|
+
default:
|
|
1815
|
+
// Unknown dataType. Do not try to handle it anymore
|
|
1816
|
+
updated = true;
|
|
1817
|
+
}
|
|
1818
|
+
if (!updated) {
|
|
1819
|
+
unhandledUpdates.push(update);
|
|
1820
|
+
}
|
|
1821
|
+
});
|
|
1822
|
+
remainingUpdates = unhandledUpdates;
|
|
1823
|
+
});
|
|
1824
|
+
currentLevel = lodash.flatten(currentLevel.map(function (parent) { return parent.lineItems; }));
|
|
1809
1825
|
}
|
|
1810
1826
|
};
|
|
1811
1827
|
FlowUpdateService.prototype.delete = function (lineItems, id) {
|
|
@@ -1825,77 +1841,64 @@
|
|
|
1825
1841
|
var filtered = lineItems.filter(function (lineItem) { return !idsToRemove.includes(lineItem.id); });
|
|
1826
1842
|
return filtered.map(function (lineItem) { return new LineItemWorker(lineItem).remove(id).li; });
|
|
1827
1843
|
};
|
|
1828
|
-
FlowUpdateService.prototype.
|
|
1829
|
-
|
|
1830
|
-
|
|
1831
|
-
|
|
1832
|
-
|
|
1833
|
-
|
|
1834
|
-
|
|
1835
|
-
|
|
1836
|
-
|
|
1837
|
-
|
|
1838
|
-
|
|
1839
|
-
|
|
1840
|
-
|
|
1841
|
-
|
|
1842
|
-
|
|
1843
|
-
|
|
1844
|
-
|
|
1845
|
-
|
|
1846
|
-
|
|
1847
|
-
|
|
1848
|
-
|
|
1849
|
-
|
|
1850
|
-
|
|
1851
|
-
|
|
1852
|
-
|
|
1853
|
-
|
|
1854
|
-
|
|
1855
|
-
|
|
1856
|
-
var
|
|
1857
|
-
|
|
1858
|
-
|
|
1859
|
-
|
|
1860
|
-
|
|
1861
|
-
|
|
1862
|
-
|
|
1863
|
-
|
|
1864
|
-
|
|
1865
|
-
|
|
1866
|
-
|
|
1867
|
-
|
|
1868
|
-
|
|
1869
|
-
|
|
1870
|
-
|
|
1871
|
-
|
|
1872
|
-
|
|
1873
|
-
|
|
1874
|
-
return
|
|
1875
|
-
}
|
|
1876
|
-
|
|
1877
|
-
|
|
1878
|
-
|
|
1879
|
-
|
|
1880
|
-
|
|
1881
|
-
|
|
1882
|
-
|
|
1883
|
-
|
|
1884
|
-
|
|
1885
|
-
|
|
1886
|
-
else if (params.dataType === 'CHARGE') {
|
|
1887
|
-
updated = Object.assign(Object.assign({}, lineItem), { chargeItems: lineItem.chargeItems.map(function (chargeItem) {
|
|
1888
|
-
return chargeItem.id === params.id ? Object.assign(Object.assign({}, chargeItem), { priceAdjustment: params.newValue }) : chargeItem;
|
|
1889
|
-
}) });
|
|
1890
|
-
}
|
|
1891
|
-
else if (params.dataType === 'GROUP_CHARGE') {
|
|
1892
|
-
updated = Object.assign(Object.assign({}, lineItem), { chargeGroupItems: lineItem.chargeGroupItems.map(function (chargeGroupItem) {
|
|
1893
|
-
return chargeGroupItem.id === params.id
|
|
1894
|
-
? Object.assign(Object.assign({}, chargeGroupItem), { priceAdjustment: params.newValue }) : chargeGroupItem;
|
|
1895
|
-
}) });
|
|
1896
|
-
}
|
|
1897
|
-
var updatedRootLineItem = updated ? new LineItemWorker(rootLineItem).replace(updated).li : rootLineItem;
|
|
1898
|
-
return updatedRootLineItem;
|
|
1844
|
+
FlowUpdateService.prototype.applyLineItemUpdate = function (lineItem, update) {
|
|
1845
|
+
if (lineItem.id !== update.id) {
|
|
1846
|
+
return false;
|
|
1847
|
+
}
|
|
1848
|
+
switch (update.attributeType) {
|
|
1849
|
+
case 'QTY':
|
|
1850
|
+
lineItem.qty = update.newValue;
|
|
1851
|
+
break;
|
|
1852
|
+
case 'EFFECTIVE_START_DATE':
|
|
1853
|
+
lineItem.effectiveStartDate = moment__default["default"](update.newValue).format('YYYY-MM-DD');
|
|
1854
|
+
break;
|
|
1855
|
+
case 'END_DATE':
|
|
1856
|
+
lineItem.endDate = moment__default["default"](update.newValue).format('YYYY-MM-DD');
|
|
1857
|
+
break;
|
|
1858
|
+
case 'PRICE_ADJUSTMENT':
|
|
1859
|
+
{
|
|
1860
|
+
var _a = __read(lineItem.chargeItems, 1), charge = _a[0];
|
|
1861
|
+
if (charge) {
|
|
1862
|
+
charge.priceAdjustment = update.newValue;
|
|
1863
|
+
}
|
|
1864
|
+
}
|
|
1865
|
+
break;
|
|
1866
|
+
default:
|
|
1867
|
+
throw new Error("Not suppored AttributeType for LineItem update: " + update.attributeType);
|
|
1868
|
+
}
|
|
1869
|
+
return true;
|
|
1870
|
+
};
|
|
1871
|
+
FlowUpdateService.prototype.applyChargeUpdate = function (lineItem, update) {
|
|
1872
|
+
var foundCharge = lineItem.chargeItems.find(function (_a) {
|
|
1873
|
+
var id = _a.id;
|
|
1874
|
+
return id === update.id;
|
|
1875
|
+
});
|
|
1876
|
+
if (!foundCharge) {
|
|
1877
|
+
return false;
|
|
1878
|
+
}
|
|
1879
|
+
if (update.attributeType === 'PRICE_ADJUSTMENT') {
|
|
1880
|
+
foundCharge.priceAdjustment = update.newValue;
|
|
1881
|
+
}
|
|
1882
|
+
else {
|
|
1883
|
+
throw new Error("Not suppored AttributeType for Charge Item update: " + update.attributeType);
|
|
1884
|
+
}
|
|
1885
|
+
return true;
|
|
1886
|
+
};
|
|
1887
|
+
FlowUpdateService.prototype.applyChargeGroupUpdate = function (lineItem, update) {
|
|
1888
|
+
var foundChargeGroup = lineItem.chargeGroupItems.find(function (_a) {
|
|
1889
|
+
var id = _a.id;
|
|
1890
|
+
return id === update.id;
|
|
1891
|
+
});
|
|
1892
|
+
if (!foundChargeGroup) {
|
|
1893
|
+
return false;
|
|
1894
|
+
}
|
|
1895
|
+
if (update.attributeType === 'PRICE_ADJUSTMENT') {
|
|
1896
|
+
foundChargeGroup.priceAdjustment = update.newValue;
|
|
1897
|
+
}
|
|
1898
|
+
else {
|
|
1899
|
+
throw new Error("Not suppored AttributeType for Charge Group Item update: " + update.attributeType);
|
|
1900
|
+
}
|
|
1901
|
+
return true;
|
|
1899
1902
|
};
|
|
1900
1903
|
return FlowUpdateService;
|
|
1901
1904
|
}());
|
|
@@ -1932,12 +1935,13 @@
|
|
|
1932
1935
|
FlowConfigurationService.prototype.calculate = function (currentState) {
|
|
1933
1936
|
this.calculate$(currentState).subscribe();
|
|
1934
1937
|
};
|
|
1935
|
-
FlowConfigurationService.prototype.update$ = function (
|
|
1938
|
+
FlowConfigurationService.prototype.update$ = function (updates) {
|
|
1936
1939
|
var _this = this;
|
|
1937
|
-
|
|
1940
|
+
var lineItems = lodash.cloneDeep(this.lineItems.value);
|
|
1941
|
+
return rxjs.of([]).pipe(rxjs.tap(function () { return _this.updateService.update(lineItems, updates); }), this.handleError(), rxjs.switchMap(function () { return _this.calculate$(lineItems); }));
|
|
1938
1942
|
};
|
|
1939
|
-
FlowConfigurationService.prototype.update = function (
|
|
1940
|
-
this.update$(
|
|
1943
|
+
FlowConfigurationService.prototype.update = function (updates) {
|
|
1944
|
+
this.update$(updates).subscribe();
|
|
1941
1945
|
};
|
|
1942
1946
|
FlowConfigurationService.prototype.delete$ = function (ids) {
|
|
1943
1947
|
var _this = this;
|