@veloceapps/sdk 4.0.0 → 4.0.1
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-core.umd.js +35 -31
- package/bundles/veloce-sdk-core.umd.js.map +1 -1
- package/bundles/veloce-sdk.umd.js +17 -16
- package/bundles/veloce-sdk.umd.js.map +1 -1
- package/core/modules/flow-configuration/services/flow-configuration.service.d.ts +2 -6
- package/esm2015/core/modules/flow-configuration/services/flow-configuration.service.js +36 -31
- package/esm2015/src/components/header/cart-overlay/cart-preview.component.js +6 -6
- package/esm2015/src/components/header/header.component.js +3 -2
- package/esm2015/src/components/header/header.types.js +1 -1
- package/esm2015/src/resolvers/quote.resolver.js +4 -3
- package/esm2015/src/services/flow.service.js +7 -8
- package/fesm2015/veloce-sdk-core.js +35 -30
- package/fesm2015/veloce-sdk-core.js.map +1 -1
- package/fesm2015/veloce-sdk.js +16 -15
- package/fesm2015/veloce-sdk.js.map +1 -1
- package/package.json +4 -4
- package/src/components/header/header.types.d.ts +1 -0
@@ -1285,31 +1285,31 @@
|
|
1285
1285
|
this.updateService = updateService;
|
1286
1286
|
this.configurationService = configurationService;
|
1287
1287
|
}
|
1288
|
-
FlowConfigurationService.prototype.calculate$ = function () {
|
1288
|
+
FlowConfigurationService.prototype.calculate$ = function (quoteDraft) {
|
1289
1289
|
var _this = this;
|
1290
|
-
var quoteDraft = this.quoteDraftService.quoteDraft;
|
1291
|
-
if (!quoteDraft || !quoteDraft.currentState.length) {
|
1292
|
-
return rxjs.of(undefined);
|
1293
|
-
}
|
1294
1290
|
return this.proceduresApiService.apply$(quoteDraft).pipe(rxjs.tap(function (result) { return _this.quoteDraftService.updateQuoteDraft(result); }), rxjs.map(rxjs.noop));
|
1295
1291
|
};
|
1296
|
-
FlowConfigurationService.prototype.calculate = function () {
|
1297
|
-
this.calculate$().subscribe();
|
1292
|
+
FlowConfigurationService.prototype.calculate = function (quoteDraft) {
|
1293
|
+
this.calculate$(quoteDraft).subscribe();
|
1298
1294
|
};
|
1299
1295
|
FlowConfigurationService.prototype.update$ = function (updates) {
|
1300
1296
|
var _this = this;
|
1301
|
-
var
|
1302
|
-
|
1303
|
-
|
1297
|
+
var quoteDraft = this.quoteDraftService.quoteDraft;
|
1298
|
+
if (!quoteDraft) {
|
1299
|
+
return rxjs.of(null);
|
1300
|
+
}
|
1301
|
+
return rxjs.of([]).pipe(rxjs.map(function () {
|
1302
|
+
var updatedState = lodash.cloneDeep(quoteDraft.currentState);
|
1304
1303
|
_this.updateService.update(updatedState, updates);
|
1305
|
-
|
1306
|
-
}), rxjs.switchMap(function () { return _this.calculate$(); }), rxjs.map(function () { return _this.quoteDraftService.quoteDraft; }), this.handleErrorAndBounceBack(
|
1304
|
+
return updatedState;
|
1305
|
+
}), rxjs.switchMap(function (updatedState) { return _this.calculate$(Object.assign(Object.assign({}, quoteDraft), { currentState: updatedState })); }), rxjs.map(function () { return _this.quoteDraftService.quoteDraft; }), this.handleErrorAndBounceBack());
|
1307
1306
|
};
|
1308
1307
|
FlowConfigurationService.prototype.update = function (updates) {
|
1309
1308
|
this.update$(updates).subscribe();
|
1310
1309
|
};
|
1311
1310
|
FlowConfigurationService.prototype.revert$ = function (lineItemId) {
|
1312
1311
|
var _this = this;
|
1312
|
+
var quoteDraft = this.quoteDraftService.quoteDraft;
|
1313
1313
|
var initialState = this.quoteDraftService.activeInitialState;
|
1314
1314
|
var currentState = this.quoteDraftService.activeCurrentState;
|
1315
1315
|
var currentLineItemIndex = currentState.findIndex(function (_c) {
|
@@ -1321,50 +1321,51 @@
|
|
1321
1321
|
var integrationId = _c.integrationId;
|
1322
1322
|
return integrationId === (currentLineItem === null || currentLineItem === void 0 ? void 0 : currentLineItem.integrationId);
|
1323
1323
|
});
|
1324
|
-
if (!currentLineItem || !initialLineItem) {
|
1324
|
+
if (!quoteDraft || !currentLineItem || !initialLineItem) {
|
1325
1325
|
return rxjs.of(null);
|
1326
1326
|
}
|
1327
1327
|
var updatedState = lodash.cloneDeep(currentState);
|
1328
1328
|
updatedState.splice(currentLineItemIndex, 1, initialLineItem);
|
1329
1329
|
return rxjs.of([]).pipe(rxjs.tap(function () {
|
1330
1330
|
_this.quoteDraftService.setCurrentLineItemState(updatedState);
|
1331
|
-
}), rxjs.switchMap(function () { return _this.calculate$(); }), rxjs.map(function () { return _this.quoteDraftService.quoteDraft; }), this.handleErrorAndBounceBack(
|
1331
|
+
}), rxjs.switchMap(function () { return _this.calculate$(Object.assign(Object.assign({}, quoteDraft), { currentState: updatedState })); }), rxjs.map(function () { return _this.quoteDraftService.quoteDraft; }), this.handleErrorAndBounceBack());
|
1332
1332
|
};
|
1333
1333
|
FlowConfigurationService.prototype.revert = function (lineItemId) {
|
1334
1334
|
this.revert$(lineItemId).subscribe();
|
1335
1335
|
};
|
1336
1336
|
FlowConfigurationService.prototype.delete$ = function (ids) {
|
1337
1337
|
var _this = this;
|
1338
|
+
var quoteDraft = this.quoteDraftService.quoteDraft;
|
1338
1339
|
var currentState = this.quoteDraftService.currentState;
|
1339
|
-
|
1340
|
-
|
1341
|
-
|
1342
|
-
}), rxjs.switchMap(function () { return _this.calculate$(); }), rxjs.map(function () { return _this.quoteDraftService.quoteDraft; }), this.handleErrorAndBounceBack(
|
1340
|
+
if (!quoteDraft) {
|
1341
|
+
return rxjs.of(null);
|
1342
|
+
}
|
1343
|
+
return rxjs.of([]).pipe(rxjs.map(function () { return ids.reduce(function (result, id) { return _this.updateService.delete(result, id); }, currentState); }), rxjs.switchMap(function (updatedState) { return _this.calculate$(Object.assign(Object.assign({}, quoteDraft), { currentState: updatedState })); }), rxjs.map(function () { return _this.quoteDraftService.quoteDraft; }), this.handleErrorAndBounceBack());
|
1343
1344
|
};
|
1344
1345
|
FlowConfigurationService.prototype.delete = function (ids) {
|
1345
1346
|
this.delete$(ids).subscribe();
|
1346
1347
|
};
|
1347
1348
|
FlowConfigurationService.prototype.addTerm$ = function (term) {
|
1348
1349
|
var _this = this;
|
1349
|
-
var
|
1350
|
-
|
1350
|
+
var quoteDraft = this.quoteDraftService.quoteDraft;
|
1351
|
+
if (!quoteDraft) {
|
1352
|
+
return rxjs.of(null);
|
1353
|
+
}
|
1354
|
+
var updatedState = __spreadArray(__spreadArray([], __read(quoteDraft.currentState)), [term]);
|
1355
|
+
return rxjs.of([]).pipe(rxjs.switchMap(function () { return _this.calculate$(Object.assign(Object.assign({}, quoteDraft), { currentState: updatedState })); }), rxjs.map(function () { return _this.quoteDraftService.quoteDraft; }), this.handleErrorAndBounceBack());
|
1351
1356
|
};
|
1352
1357
|
FlowConfigurationService.prototype.addToCart$ = function (productId, qty) {
|
1353
1358
|
var _this = this;
|
1354
|
-
var
|
1355
|
-
|
1359
|
+
var quoteDraft = this.quoteDraftService.quoteDraft;
|
1360
|
+
if (!quoteDraft) {
|
1361
|
+
return rxjs.of(null);
|
1362
|
+
}
|
1363
|
+
return this.configurationService.configureExternal$(productId, qty).pipe(rxjs.map(function (lineItem) { return __spreadArray(__spreadArray([], __read(quoteDraft.currentState)), [lineItem]); }), rxjs.switchMap(function (updatedState) { return _this.calculate$(Object.assign(Object.assign({}, quoteDraft), { currentState: updatedState })); }), rxjs.map(function () { return _this.quoteDraftService.quoteDraft; }), this.handleErrorAndBounceBack());
|
1356
1364
|
};
|
1357
1365
|
FlowConfigurationService.prototype.get = function () {
|
1358
1366
|
var _this = this;
|
1359
1367
|
return this.quoteDraftService.quoteDraft$.pipe(rxjs.map(function () { return _this.quoteDraftService.activeCurrentState; }), rxjs.shareReplay());
|
1360
1368
|
};
|
1361
|
-
/**
|
1362
|
-
* Returns only active lineItems with `actionCode !== 'DELETE'`.
|
1363
|
-
*/
|
1364
|
-
FlowConfigurationService.prototype.getActive = function () {
|
1365
|
-
var _this = this;
|
1366
|
-
return this.quoteDraftService.quoteDraft$.pipe(rxjs.map(function () { return _this.quoteDraftService.activeCurrentState.filter(function (li) { return li.actionCode !== 'DELETE'; }); }), rxjs.shareReplay());
|
1367
|
-
};
|
1368
1369
|
FlowConfigurationService.prototype.getSnapshot = function () {
|
1369
1370
|
var _a, _b;
|
1370
1371
|
return (_b = (_a = this.quoteDraftService) === null || _a === void 0 ? void 0 : _a.currentState.slice()) !== null && _b !== void 0 ? _b : [];
|
@@ -1401,13 +1402,16 @@
|
|
1401
1402
|
enumerable: false,
|
1402
1403
|
configurable: true
|
1403
1404
|
});
|
1404
|
-
FlowConfigurationService.prototype.handleErrorAndBounceBack = function (
|
1405
|
+
FlowConfigurationService.prototype.handleErrorAndBounceBack = function () {
|
1405
1406
|
var _this = this;
|
1406
1407
|
return function (source$) {
|
1407
1408
|
return source$.pipe(rxjs.catchError(function (error) {
|
1408
1409
|
console.error(error);
|
1409
1410
|
// bounce back if configuration call has failed
|
1410
|
-
_this.quoteDraftService.
|
1411
|
+
var quoteDraft = _this.quoteDraftService.quoteDraft;
|
1412
|
+
if (quoteDraft) {
|
1413
|
+
_this.quoteDraftService.updateQuoteDraft(quoteDraft);
|
1414
|
+
}
|
1411
1415
|
return rxjs.throwError(function () { return error; });
|
1412
1416
|
}));
|
1413
1417
|
};
|