@veloceapps/sdk 3.1.17 → 3.1.19

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 (36) hide show
  1. package/README.md +2 -6
  2. package/bundles/veloce-sdk-core.umd.js +212 -68
  3. package/bundles/veloce-sdk-core.umd.js.map +1 -1
  4. package/bundles/veloce-sdk-runtime.umd.js +5 -6
  5. package/bundles/veloce-sdk-runtime.umd.js.map +1 -1
  6. package/bundles/veloce-sdk.umd.js +52 -38
  7. package/bundles/veloce-sdk.umd.js.map +1 -1
  8. package/core/modules/flow-configuration/services/flow-configuration.service.d.ts +11 -17
  9. package/core/services/quote-draft.service.d.ts +41 -7
  10. package/esm2015/core/modules/configuration/services/configuration.service.js +3 -3
  11. package/esm2015/core/modules/flow-configuration/services/flow-configuration.service.js +43 -49
  12. package/esm2015/core/services/quote-draft.service.js +138 -22
  13. package/esm2015/runtime/components/ui-runtime/runtime.component.js +2 -2
  14. package/esm2015/runtime/execution/directives/section-script.directive.js +2 -2
  15. package/esm2015/runtime/services/cart.service.js +2 -3
  16. package/esm2015/runtime/services/section.service.js +1 -1
  17. package/esm2015/src/components/header/header.component.js +23 -19
  18. package/esm2015/src/components/header/header.types.js +1 -1
  19. package/esm2015/src/pages/legacy-product/legacy-product.component.js +4 -4
  20. package/esm2015/src/pages/product/product.component.js +8 -5
  21. package/esm2015/src/resolvers/flow.resolver.js +8 -4
  22. package/esm2015/src/resolvers/quote.resolver.js +4 -11
  23. package/esm2015/src/services/flow.service.js +6 -5
  24. package/fesm2015/veloce-sdk-core.js +177 -66
  25. package/fesm2015/veloce-sdk-core.js.map +1 -1
  26. package/fesm2015/veloce-sdk-runtime.js +3 -4
  27. package/fesm2015/veloce-sdk-runtime.js.map +1 -1
  28. package/fesm2015/veloce-sdk.js +44 -39
  29. package/fesm2015/veloce-sdk.js.map +1 -1
  30. package/package.json +1 -1
  31. package/runtime/services/cart.service.d.ts +1 -1
  32. package/src/components/header/header.component.d.ts +5 -2
  33. package/src/components/header/header.types.d.ts +0 -1
  34. package/src/pages/product/product.component.d.ts +1 -0
  35. package/src/resolvers/flow.resolver.d.ts +3 -1
  36. package/src/resolvers/quote.resolver.d.ts +0 -1
package/README.md CHANGED
@@ -1,7 +1,3 @@
1
- # sdk
1
+ # Sdk library
2
2
 
3
- This library was generated with [Nx](https://nx.dev).
4
-
5
- ## Running unit tests
6
-
7
- Run `nx test sdk` to execute the unit tests.
3
+ TBD
@@ -450,16 +450,25 @@
450
450
  }], ctorParameters: function () { return [{ type: i1__namespace.ProductApiService }]; } });
451
451
 
452
452
  var QuoteDraftService = /** @class */ (function () {
453
- function QuoteDraftService(context, quoteApiService, priceApiService) {
453
+ function QuoteDraftService(context, quoteApiService, priceApiService, sfApiService) {
454
+ var _this = this;
454
455
  this.context = context;
455
456
  this.quoteApiService = quoteApiService;
456
457
  this.priceApiService = priceApiService;
458
+ this.sfApiService = sfApiService;
457
459
  this.quoteSubj$ = new rxjs.BehaviorSubject(null);
458
460
  this.resetSubj$ = new rxjs.BehaviorSubject(true);
459
- this.priceLists = [];
461
+ /**
462
+ * @key pricePlanId
463
+ * @value priceListId
464
+ */
465
+ this.planIdsMap = {};
460
466
  this.isInitialized = false;
467
+ this.allPriceLists = [];
468
+ this.assetPriceLists = [];
461
469
  this.hasUnsavedChanges = false;
462
470
  this.reset$ = this.resetSubj$.asObservable();
471
+ this.activePriceList$ = this.context.resolve$().pipe(operators.map(function (ctx) { return _this.allPriceLists.find(function (priceList) { return priceList.id === ctx.properties.PriceListId; }); }), operators.filter(function (priceList) { return Boolean(priceList); }));
463
472
  }
464
473
  QuoteDraftService.prototype.reset = function () {
465
474
  this.resetSubj$.next(true);
@@ -467,41 +476,52 @@
467
476
  };
468
477
  QuoteDraftService.prototype.init = function (quoteId, params) {
469
478
  var _this = this;
470
- return rxjs.zip(this.quoteApiService.getQuoteDraft(quoteId, params), this.priceApiService.getPriceLists(), this.context.resolve$()).pipe(operators.tap(function (_a) {
471
- var _b = __read(_a, 3), quote = _b[0], priceLists = _b[1], context = _b[2];
479
+ return rxjs.zip(this.context.resolve$(), this.quoteApiService.getQuoteDraft(quoteId, params), this.priceApiService.getPriceLists()).pipe(operators.tap(function (_c) {
480
+ var _d = __read(_c, 3), context = _d[0], quote = _d[1], allPriceLists = _d[2];
481
+ _this.allPriceLists = allPriceLists;
472
482
  _this.quoteSubj$.next(quote);
473
- _this.priceLists = priceLists;
474
- _this.quotePriceList = priceLists.find(function (p) { return p.id === context.properties.PriceListId; });
475
483
  _this.context.update(Object.assign(Object.assign(Object.assign({}, context), quote.context), { properties: Object.assign(Object.assign({}, context.properties), quote.context.properties) }));
476
- }), operators.map(function () {
477
- _this.isInitialized = true;
478
- }), operators.take(1));
484
+ }), operators.switchMap(function () { return _this.populateActivePriceLists$(); }), operators.map(function () { return rxjs.noop(); }), operators.tap(function () { return (_this.isInitialized = true); }), operators.take(1));
479
485
  };
480
486
  QuoteDraftService.prototype.setCurrentLineItemState = function (lineItems) {
481
- var quote = this.quoteSubj$.value;
482
- if (!quote) {
487
+ var quoteDraft = this.quoteSubj$.value;
488
+ if (!quoteDraft) {
483
489
  return;
484
490
  }
485
- this.quoteSubj$.next(Object.assign(Object.assign({}, quote), { currentState: lineItems }));
491
+ this.quoteSubj$.next(Object.assign(Object.assign({}, quoteDraft), { currentState: lineItems }));
486
492
  this.markAsUpdated();
487
493
  };
494
+ QuoteDraftService.prototype.updateQuoteDraft = function (update) {
495
+ var quoteDraft = this.quoteSubj$.value;
496
+ if (!quoteDraft) {
497
+ return;
498
+ }
499
+ if (update.context) {
500
+ this.context.update(update.context);
501
+ }
502
+ this.quoteSubj$.next(Object.assign(Object.assign({}, quoteDraft), update));
503
+ };
488
504
  QuoteDraftService.prototype.updateByPriceSummary = function (priceSummary) {
489
- var quote = this.quoteSubj$.value;
490
- if (!quote) {
505
+ var quoteDraft = this.quoteSubj$.value;
506
+ if (!quoteDraft) {
491
507
  return;
492
508
  }
493
- this.quoteSubj$.next(Object.assign(Object.assign({}, quote), { currentState: priceSummary.lineItems, totalPrices: priceSummary.totalPrices, approvalItems: priceSummary.approvalItems }));
509
+ var updatedCurrentState = this.currentState.map(function (lineItem) {
510
+ var updated = priceSummary.lineItems.find(function (li) { return li.id === lineItem.id; });
511
+ return updated !== null && updated !== void 0 ? updated : lineItem;
512
+ });
513
+ this.quoteSubj$.next(Object.assign(Object.assign({}, quoteDraft), { currentState: updatedCurrentState, totalPrices: priceSummary.totalPrices, approvalItems: priceSummary.approvalItems }));
494
514
  this.markAsUpdated();
495
515
  };
496
- Object.defineProperty(QuoteDraftService.prototype, "quote$", {
516
+ Object.defineProperty(QuoteDraftService.prototype, "quoteDraft$", {
497
517
  get: function () {
498
518
  var _this = this;
499
- return rxjs.combineLatest([this.quoteSubj$, this.context.resolve$()]).pipe(operators.map(function () { return _this.quoteSnapshot; }), operators.filter(function (quote) { return Boolean(quote); }));
519
+ return rxjs.combineLatest([this.quoteSubj$, this.context.resolve$()]).pipe(operators.map(function () { return _this.quoteDraft; }), operators.filter(function (quote) { return Boolean(quote); }), operators.shareReplay());
500
520
  },
501
521
  enumerable: false,
502
522
  configurable: true
503
523
  });
504
- Object.defineProperty(QuoteDraftService.prototype, "quoteSnapshot", {
524
+ Object.defineProperty(QuoteDraftService.prototype, "quoteDraft", {
505
525
  get: function () {
506
526
  var quote = this.quoteSubj$.value;
507
527
  if (!quote) {
@@ -512,6 +532,75 @@
512
532
  enumerable: false,
513
533
  configurable: true
514
534
  });
535
+ Object.defineProperty(QuoteDraftService.prototype, "currentState$", {
536
+ get: function () {
537
+ return this.quoteDraft$.pipe(operators.map(function (quote) { return quote.currentState; }));
538
+ },
539
+ enumerable: false,
540
+ configurable: true
541
+ });
542
+ Object.defineProperty(QuoteDraftService.prototype, "currentState", {
543
+ get: function () {
544
+ var _a, _b;
545
+ return (_b = (_a = this.quoteDraft) === null || _a === void 0 ? void 0 : _a.currentState) !== null && _b !== void 0 ? _b : [];
546
+ },
547
+ enumerable: false,
548
+ configurable: true
549
+ });
550
+ Object.defineProperty(QuoteDraftService.prototype, "activeCurrentState$", {
551
+ /**
552
+ * Stream of activeCurrentState
553
+ */
554
+ get: function () {
555
+ var _this = this;
556
+ return this.quoteDraft$.pipe(operators.map(function () { return _this.activeCurrentState; }));
557
+ },
558
+ enumerable: false,
559
+ configurable: true
560
+ });
561
+ Object.defineProperty(QuoteDraftService.prototype, "activeCurrentState", {
562
+ /**
563
+ * activeCurrentState is currentState passed through additional filters
564
+ */
565
+ get: function () {
566
+ var _a, _b;
567
+ var ctx = this.context.resolve();
568
+ var currentState = (_b = (_a = this.quoteDraft) === null || _a === void 0 ? void 0 : _a.currentState) !== null && _b !== void 0 ? _b : [];
569
+ if (ctx.mode === core.ConfigurationContextMode.ACCOUNT) {
570
+ currentState = this.filterByActivePriceList(currentState);
571
+ }
572
+ return currentState;
573
+ },
574
+ enumerable: false,
575
+ configurable: true
576
+ });
577
+ Object.defineProperty(QuoteDraftService.prototype, "activeInitialState$", {
578
+ /**
579
+ * Stream of activeInitialState
580
+ */
581
+ get: function () {
582
+ var _this = this;
583
+ return this.quoteDraft$.pipe(operators.map(function () { return _this.activeInitialState; }));
584
+ },
585
+ enumerable: false,
586
+ configurable: true
587
+ });
588
+ Object.defineProperty(QuoteDraftService.prototype, "activeInitialState", {
589
+ /**
590
+ * activeInitialState is initialState passed through additional filters
591
+ */
592
+ get: function () {
593
+ var _a, _b;
594
+ var ctx = this.context.resolve();
595
+ var initialState = (_b = (_a = this.quoteDraft) === null || _a === void 0 ? void 0 : _a.initialState) !== null && _b !== void 0 ? _b : [];
596
+ if (ctx.mode === core.ConfigurationContextMode.ACCOUNT) {
597
+ initialState = this.filterByActivePriceList(initialState);
598
+ }
599
+ return initialState;
600
+ },
601
+ enumerable: false,
602
+ configurable: true
603
+ });
515
604
  Object.defineProperty(QuoteDraftService.prototype, "isStandalone", {
516
605
  get: function () {
517
606
  return this.context.resolve().properties.standalone === 'true';
@@ -533,6 +622,65 @@
533
622
  }
534
623
  return false;
535
624
  };
625
+ QuoteDraftService.prototype.updateActivePriceList = function (priceListId) {
626
+ this.context.update({ properties: { PriceListId: priceListId } });
627
+ };
628
+ /**
629
+ * Query PricePlan infos for the assets
630
+ * TODO: remove when backend will send priceListId for assets
631
+ */
632
+ QuoteDraftService.prototype.getAssetsPlanInfos$ = function (quoteDraft) {
633
+ var _a;
634
+ var pricePlanIds = (_a = quoteDraft === null || quoteDraft === void 0 ? void 0 : quoteDraft.initialState.map(function (li) { return li.planId; }).filter(function (id) { return typeof id === 'string'; }).filter(function (item, i, arr) { return arr.indexOf(item) === i; })) !== null && _a !== void 0 ? _a : [];
635
+ if (!pricePlanIds.length) {
636
+ return rxjs.of([]);
637
+ }
638
+ var priceListIdFieldName = 'VELOCPQ__PriceListId__c';
639
+ var searchRequest = {
640
+ rawCondition: "Id in ('" + pricePlanIds.join("','") + "')",
641
+ fields: ['Id', priceListIdFieldName],
642
+ };
643
+ return this.sfApiService
644
+ .query(searchRequest, 'VELOCPQ__PricePlan__c')
645
+ .pipe(operators.map(function (result) { return result.map(function (item) { return ({ id: item.Id, priceListId: item[priceListIdFieldName] }); }).filter(Boolean); }));
646
+ };
647
+ QuoteDraftService.prototype.populateActivePriceLists$ = function () {
648
+ var _this = this;
649
+ var ctx = this.context.resolve();
650
+ var quoteDraft = this.quoteDraft;
651
+ if (!quoteDraft) {
652
+ return rxjs.of(undefined);
653
+ }
654
+ // In ACCOUNT mode populate price lists from related assets
655
+ if (ctx.mode === core.ConfigurationContextMode.ACCOUNT) {
656
+ return this.getAssetsPlanInfos$(quoteDraft).pipe(operators.tap(function (pricePlanInfos) {
657
+ _this.assetPriceLists = pricePlanInfos.map(function (item) {
658
+ var _a, _b;
659
+ return ({
660
+ id: item.priceListId,
661
+ name: (_b = (_a = _this.allPriceLists.find(function (priceList) { return priceList.id === item.priceListId; })) === null || _a === void 0 ? void 0 : _a.name) !== null && _b !== void 0 ? _b : '',
662
+ });
663
+ });
664
+ _this.planIdsMap = pricePlanInfos.reduce(function (trunk, item) {
665
+ var _c;
666
+ return (Object.assign(Object.assign({}, trunk), (_c = {}, _c[item.id] = item.priceListId, _c)));
667
+ }, {});
668
+ var activePriceList = _this.assetPriceLists[0];
669
+ _this.updateActivePriceList(activePriceList.id);
670
+ // Update PriceListId in context properties
671
+ // TODO: remove it when backend will have such logic
672
+ if (_this.assetPriceLists.length) {
673
+ _this.context.update({ properties: { PriceListId: activePriceList.id } });
674
+ }
675
+ }), operators.map(rxjs.noop));
676
+ }
677
+ return rxjs.of(undefined);
678
+ };
679
+ QuoteDraftService.prototype.filterByActivePriceList = function (lineItems) {
680
+ var _this = this;
681
+ var ctx = this.context.resolve();
682
+ return lineItems.filter(function (li) { return !li.planId || _this.planIdsMap[li.planId] === ctx.properties.PriceListId; });
683
+ };
536
684
  QuoteDraftService.prototype.markAsUpdated = function () {
537
685
  if (this.isInitialized && !this.hasUnsavedChanges) {
538
686
  this.hasUnsavedChanges = true;
@@ -540,12 +688,12 @@
540
688
  };
541
689
  return QuoteDraftService;
542
690
  }());
543
- QuoteDraftService.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: QuoteDraftService, deps: [{ token: ContextService }, { token: i1__namespace.QuoteApiService }, { token: i1__namespace.PriceApiService }], target: i0__namespace.ɵɵFactoryTarget.Injectable });
691
+ QuoteDraftService.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: QuoteDraftService, deps: [{ token: ContextService }, { token: i1__namespace.QuoteApiService }, { token: i1__namespace.PriceApiService }, { token: i1__namespace.SalesforceApiService }], target: i0__namespace.ɵɵFactoryTarget.Injectable });
544
692
  QuoteDraftService.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: QuoteDraftService, providedIn: 'root' });
545
693
  i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: QuoteDraftService, decorators: [{
546
694
  type: i0.Injectable,
547
695
  args: [{ providedIn: 'root' }]
548
- }], ctorParameters: function () { return [{ type: ContextService }, { type: i1__namespace.QuoteApiService }, { type: i1__namespace.PriceApiService }]; } });
696
+ }], ctorParameters: function () { return [{ type: ContextService }, { type: i1__namespace.QuoteApiService }, { type: i1__namespace.PriceApiService }, { type: i1__namespace.SalesforceApiService }]; } });
549
697
 
550
698
  var RuntimeContextService = /** @class */ (function () {
551
699
  function RuntimeContextService(configurationApiService, messageService) {
@@ -955,8 +1103,6 @@
955
1103
  var qty = (_d = this.runtimeService.initializationProps) === null || _d === void 0 ? void 0 : _d.defaultQty;
956
1104
  var lineItem = (_e = this.states.configurableRamp) !== null && _e !== void 0 ? _e : getDefaultLineItem(runtimeContext, uiDefinitionProperties, qty);
957
1105
  var configurationRequest = this.createRequest(lineItem);
958
- configurationRequest.lineItems = this.states.currentState || [];
959
- configurationRequest.asset = this.states.asset;
960
1106
  var mainPricingEnabled = (_f = runtimeContext.properties) === null || _f === void 0 ? void 0 : _f.PricingEnabled;
961
1107
  var pricingEnabled = mainPricingEnabled ? mainPricingEnabled === 'true' : uiDefinitionProperties.pricingEnabled;
962
1108
  return this.configurationApiService
@@ -990,6 +1136,8 @@
990
1136
  step: !this.lineItem.value ? exports.RuntimeStep.START : exports.RuntimeStep.UPDATE,
991
1137
  attributeDomainMode: 'ALL',
992
1138
  context: this.contextService.resolve(),
1139
+ lineItems: this.states.currentState || [],
1140
+ asset: this.states.asset,
993
1141
  };
994
1142
  };
995
1143
  ConfigurationService.prototype.showInactiveProductsConfirmation = function () {
@@ -1146,83 +1294,79 @@
1146
1294
  }] });
1147
1295
 
1148
1296
  var FlowConfigurationService = /** @class */ (function () {
1149
- function FlowConfigurationService(priceApiService, contextService, quoteDraftService, messageService, updateService, configurationService) {
1150
- this.priceApiService = priceApiService;
1297
+ function FlowConfigurationService(proceduresApiService, contextService, quoteDraftService, updateService, configurationService) {
1298
+ this.proceduresApiService = proceduresApiService;
1151
1299
  this.contextService = contextService;
1152
1300
  this.quoteDraftService = quoteDraftService;
1153
- this.messageService = messageService;
1154
1301
  this.updateService = updateService;
1155
1302
  this.configurationService = configurationService;
1156
- this.charges = new rxjs.BehaviorSubject({});
1157
- this.bounceBackUpdate$ = new rxjs.BehaviorSubject(true);
1158
1303
  }
1159
- FlowConfigurationService.prototype.reset = function () {
1160
- this.charges.next({});
1161
- };
1162
- FlowConfigurationService.prototype.initialize$ = function () {
1163
- var _this = this;
1164
- var _a;
1165
- (_a = this.resetSubscription) === null || _a === void 0 ? void 0 : _a.unsubscribe();
1166
- this.resetSubscription = this.quoteDraftService.reset$.subscribe(function () { return _this.reset(); });
1167
- return this.calculate$(this.getSnapshot()).pipe(rxjs.map(rxjs.noop));
1168
- };
1169
- FlowConfigurationService.prototype.calculate$ = function (currentState) {
1304
+ FlowConfigurationService.prototype.calculate$ = function () {
1170
1305
  var _this = this;
1171
- var context = this.contextService.resolve();
1172
- return this.priceApiService.calculate({ context: context, currentState: currentState }).pipe(rxjs.tap(function (result) {
1173
- _this.quoteDraftService.updateByPriceSummary(result);
1174
- _this.charges.next(result.charges);
1175
- if (context) {
1176
- _this.contextService.update({ properties: context.properties });
1177
- }
1178
- }), this.handleError());
1306
+ var quoteDraft = this.quoteDraftService.quoteDraft;
1307
+ if (!quoteDraft || !quoteDraft.currentState.length) {
1308
+ return rxjs.of(undefined);
1309
+ }
1310
+ return this.proceduresApiService.apply$(quoteDraft).pipe(rxjs.tap(function (result) { return _this.quoteDraftService.updateQuoteDraft(result); }), rxjs.map(rxjs.noop));
1179
1311
  };
1180
- FlowConfigurationService.prototype.calculate = function (currentState) {
1181
- this.calculate$(currentState).subscribe();
1312
+ FlowConfigurationService.prototype.calculate = function () {
1313
+ this.calculate$().subscribe();
1182
1314
  };
1183
1315
  FlowConfigurationService.prototype.update$ = function (updates) {
1184
1316
  var _this = this;
1185
- var lineItems = lodash.cloneDeep(this.getSnapshot());
1186
- return rxjs.of([]).pipe(rxjs.tap(function () { return _this.updateService.update(lineItems, updates); }), this.handleError(), rxjs.switchMap(function () { return _this.calculate$(lineItems); }));
1317
+ var currentState = this.quoteDraftService.currentState;
1318
+ return rxjs.of([]).pipe(rxjs.tap(function () {
1319
+ var updatedState = lodash.cloneDeep(currentState);
1320
+ _this.updateService.update(updatedState, updates);
1321
+ _this.quoteDraftService.setCurrentLineItemState(updatedState);
1322
+ }), rxjs.switchMap(function () { return _this.calculate$(); }), rxjs.map(function () { return _this.quoteDraftService.quoteDraft; }), this.handleErrorAndBounceBack(currentState));
1187
1323
  };
1188
1324
  FlowConfigurationService.prototype.update = function (updates) {
1189
1325
  this.update$(updates).subscribe();
1190
1326
  };
1191
1327
  FlowConfigurationService.prototype.delete$ = function (ids) {
1192
1328
  var _this = this;
1193
- return rxjs.of([]).pipe(rxjs.map(function () { return ids.reduce(function (result, id) { return _this.updateService.delete(result, id); }, _this.getSnapshot()); }), this.handleError(), rxjs.switchMap(function (currentState) { return _this.calculate$(currentState); }));
1329
+ var currentState = this.quoteDraftService.currentState;
1330
+ return rxjs.of([]).pipe(rxjs.tap(function () {
1331
+ var updatedState = ids.reduce(function (result, id) { return _this.updateService.delete(result, id); }, currentState);
1332
+ _this.quoteDraftService.setCurrentLineItemState(updatedState);
1333
+ }), rxjs.switchMap(function () { return _this.calculate$(); }), rxjs.map(function () { return _this.quoteDraftService.quoteDraft; }), this.handleErrorAndBounceBack(currentState));
1194
1334
  };
1195
1335
  FlowConfigurationService.prototype.delete = function (ids) {
1196
1336
  this.delete$(ids).subscribe();
1197
1337
  };
1198
- FlowConfigurationService.prototype.get = function () {
1199
- return rxjs.combineLatest([this.quoteDraftService.quote$, this.bounceBackUpdate$]).pipe(rxjs.map(function (_c) {
1200
- var _d = __read(_c, 1), quoteDraft = _d[0];
1201
- return quoteDraft.currentState;
1202
- }), rxjs.shareReplay());
1338
+ FlowConfigurationService.prototype.addTerm$ = function (term) {
1339
+ var _this = this;
1340
+ var currentState = this.quoteDraftService.currentState;
1341
+ return rxjs.of([]).pipe(rxjs.tap(function () { return _this.quoteDraftService.setCurrentLineItemState(__spreadArray(__spreadArray([], __read(currentState)), [term])); }), rxjs.switchMap(function () { return _this.calculate$(); }), rxjs.map(function () { return _this.quoteDraftService.quoteDraft; }), this.handleErrorAndBounceBack(currentState));
1203
1342
  };
1204
1343
  FlowConfigurationService.prototype.addToCart$ = function (productId, qty) {
1205
1344
  var _this = this;
1206
- return this.configurationService.configureExternal$(productId, qty).pipe(rxjs.tap(function (lineItem) {
1207
- var _a, _b;
1208
- var currentState = (_b = (_a = _this.quoteDraftService.quoteSnapshot) === null || _a === void 0 ? void 0 : _a.currentState) !== null && _b !== void 0 ? _b : [];
1209
- _this.quoteDraftService.setCurrentLineItemState(__spreadArray(__spreadArray([], __read(currentState)), [lineItem]));
1210
- }), rxjs.map(rxjs.noop));
1345
+ var currentState = this.quoteDraftService.currentState;
1346
+ return this.configurationService.configureExternal$(productId, qty).pipe(rxjs.tap(function (lineItem) { return _this.quoteDraftService.setCurrentLineItemState(__spreadArray(__spreadArray([], __read(currentState)), [lineItem])); }), rxjs.switchMap(function () { return _this.calculate$(); }), rxjs.map(function () { return _this.quoteDraftService.quoteDraft; }), this.handleErrorAndBounceBack(currentState));
1347
+ };
1348
+ FlowConfigurationService.prototype.get = function () {
1349
+ var _this = this;
1350
+ return this.quoteDraftService.quoteDraft$.pipe(rxjs.map(function () { return _this.quoteDraftService.activeCurrentState; }), rxjs.shareReplay());
1211
1351
  };
1212
1352
  FlowConfigurationService.prototype.getSnapshot = function () {
1213
1353
  var _a, _b;
1214
- return (_b = (_a = this.quoteDraftService.quoteSnapshot) === null || _a === void 0 ? void 0 : _a.currentState.slice()) !== null && _b !== void 0 ? _b : [];
1354
+ return (_b = (_a = this.quoteDraftService) === null || _a === void 0 ? void 0 : _a.currentState.slice()) !== null && _b !== void 0 ? _b : [];
1215
1355
  };
1216
1356
  Object.defineProperty(FlowConfigurationService.prototype, "charges$", {
1217
1357
  get: function () {
1218
- return this.charges.asObservable();
1358
+ return this.quoteDraftService.quoteDraft$.pipe(rxjs.map(function (_c) {
1359
+ var charges = _c.charges;
1360
+ return charges;
1361
+ }));
1219
1362
  },
1220
1363
  enumerable: false,
1221
1364
  configurable: true
1222
1365
  });
1223
1366
  Object.defineProperty(FlowConfigurationService.prototype, "chargesSnapshot", {
1224
1367
  get: function () {
1225
- return this.charges.value;
1368
+ var _a, _b;
1369
+ return (_b = (_a = this.quoteDraftService.quoteDraft) === null || _a === void 0 ? void 0 : _a.charges) !== null && _b !== void 0 ? _b : {};
1226
1370
  },
1227
1371
  enumerable: false,
1228
1372
  configurable: true
@@ -1241,24 +1385,24 @@
1241
1385
  enumerable: false,
1242
1386
  configurable: true
1243
1387
  });
1244
- FlowConfigurationService.prototype.handleError = function () {
1388
+ FlowConfigurationService.prototype.handleErrorAndBounceBack = function (stateToRestore) {
1245
1389
  var _this = this;
1246
1390
  return function (source$) {
1247
1391
  return source$.pipe(rxjs.catchError(function (error) {
1248
1392
  console.error(error);
1249
1393
  // bounce back if configuration call has failed
1250
- _this.bounceBackUpdate$.next(true);
1394
+ _this.quoteDraftService.setCurrentLineItemState(stateToRestore);
1251
1395
  return rxjs.throwError(function () { return error; });
1252
1396
  }));
1253
1397
  };
1254
1398
  };
1255
1399
  return FlowConfigurationService;
1256
1400
  }());
1257
- FlowConfigurationService.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: FlowConfigurationService, deps: [{ token: i1__namespace.PriceApiService }, { token: ContextService }, { token: QuoteDraftService }, { token: i2__namespace.MessageService }, { token: FlowUpdateService }, { token: ConfigurationService }], target: i0__namespace.ɵɵFactoryTarget.Injectable });
1401
+ FlowConfigurationService.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: FlowConfigurationService, deps: [{ token: i1__namespace.ProceduresApiService }, { token: ContextService }, { token: QuoteDraftService }, { token: FlowUpdateService }, { token: ConfigurationService }], target: i0__namespace.ɵɵFactoryTarget.Injectable });
1258
1402
  FlowConfigurationService.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: FlowConfigurationService });
1259
1403
  i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: FlowConfigurationService, decorators: [{
1260
1404
  type: i0.Injectable
1261
- }], ctorParameters: function () { return [{ type: i1__namespace.PriceApiService }, { type: ContextService }, { type: QuoteDraftService }, { type: i2__namespace.MessageService }, { type: FlowUpdateService }, { type: ConfigurationService }]; } });
1405
+ }], ctorParameters: function () { return [{ type: i1__namespace.ProceduresApiService }, { type: ContextService }, { type: QuoteDraftService }, { type: FlowUpdateService }, { type: ConfigurationService }]; } });
1262
1406
 
1263
1407
  var FlowConfigurationModule = /** @class */ (function () {
1264
1408
  function FlowConfigurationModule() {