@veloceapps/sdk 8.0.0-185 → 8.0.0-187

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 (29) hide show
  1. package/cms/vendor-map.d.ts +3 -4
  2. package/core/modules/configuration/services/configuration-state.service.d.ts +2 -4
  3. package/core/modules/configuration/services/configuration.service.d.ts +1 -1
  4. package/core/services/flow-state.service.d.ts +1 -0
  5. package/core/services/quote-draft.service.d.ts +8 -31
  6. package/core/types/flow-state.types.d.ts +5 -0
  7. package/core/types/integration.types.d.ts +0 -1
  8. package/core/utils/line-item.utils.d.ts +1 -2
  9. package/esm2020/core/modules/configuration/services/configuration-state.service.mjs +16 -7
  10. package/esm2020/core/modules/configuration/services/configuration.service.mjs +10 -8
  11. package/esm2020/core/modules/flow-configuration/services/flow-configuration.service.mjs +3 -3
  12. package/esm2020/core/services/flow-state.service.mjs +31 -25
  13. package/esm2020/core/services/quote-draft.service.mjs +27 -100
  14. package/esm2020/core/types/flow-state.types.mjs +1 -1
  15. package/esm2020/core/types/integration.types.mjs +1 -1
  16. package/esm2020/core/utils/line-item.utils.mjs +4 -18
  17. package/esm2020/src/pages/product/product.component.mjs +15 -12
  18. package/esm2020/src/services/flow.service.mjs +38 -18
  19. package/fesm2015/veloceapps-sdk-core.mjs +455 -522
  20. package/fesm2015/veloceapps-sdk-core.mjs.map +1 -1
  21. package/fesm2015/veloceapps-sdk.mjs +47 -28
  22. package/fesm2015/veloceapps-sdk.mjs.map +1 -1
  23. package/fesm2020/veloceapps-sdk-core.mjs +418 -487
  24. package/fesm2020/veloceapps-sdk-core.mjs.map +1 -1
  25. package/fesm2020/veloceapps-sdk.mjs +50 -27
  26. package/fesm2020/veloceapps-sdk.mjs.map +1 -1
  27. package/package.json +1 -1
  28. package/src/pages/product/product.component.d.ts +1 -1
  29. package/src/services/flow.service.d.ts +1 -0
@@ -767,11 +767,16 @@ class FlowService {
767
767
  initSubscriptions() {
768
768
  this.integrationState
769
769
  .listen$(FlowAction.FLOW_CONFIGURE_PRODUCT)
770
- .pipe(tap(payload => {
770
+ .pipe(switchMap(payload => {
771
771
  var _a, _b;
772
- const productId = (_a = payload.productId) !== null && _a !== void 0 ? _a : (_b = this.quoteDraftService.currentState.find(li => li.id === payload.lineItemId)) === null || _b === void 0 ? void 0 : _b.productId;
773
- if (productId) {
774
- this.flowRouterService.navigateToProductConfiguration(productId, payload.lineItemId);
772
+ if (this.flowInfoService.isLegacy) {
773
+ const productId = (_a = payload.productId) !== null && _a !== void 0 ? _a : (_b = this.quoteDraftService.currentState.find(li => li.id === payload.lineItemId)) === null || _b === void 0 ? void 0 : _b.productId;
774
+ return of(Object.assign(Object.assign({}, payload), { productId }));
775
+ }
776
+ return this.prepareConfiguration$(payload);
777
+ }), tap(payload => {
778
+ if (payload.productId) {
779
+ this.flowRouterService.navigateToProductConfiguration(payload.productId, payload.lineItemId);
775
780
  }
776
781
  else {
777
782
  console.warn("Parameter 'productId' is needed to start configuration");
@@ -820,9 +825,9 @@ class FlowService {
820
825
  return this.legacyApplyConfiguration();
821
826
  }
822
827
  else {
823
- return this.configurationStateService.saveConfiguration('', true).pipe(switchMap(() => this.configurationStateService.cancelConfiguration()), switchMap(() => this.flowStateService.dispatch$(UITemplateType.FLOW_ENGINE, 'UPDATE_ASSET_IDS', {
824
- addConfiguringAssetId: true,
825
- })));
828
+ return this.configurationStateService
829
+ .saveConfiguration('', true)
830
+ .pipe(switchMap(() => this.configurationStateService.cancelConfiguration()));
826
831
  }
827
832
  }), tap(() => {
828
833
  this.configurationService.hasUnsavedChanges = false;
@@ -840,6 +845,26 @@ class FlowService {
840
845
  .pipe(map(path => path.queryParams['productId']), takeUntil(this.cleanup$))
841
846
  .subscribe(productId => this.integrationState.patchState({ productId }));
842
847
  }
848
+ prepareConfiguration$(payload) {
849
+ if (!payload.productId && !payload.lineItemId) {
850
+ return of(payload);
851
+ }
852
+ // When reconfiguring asset, PriceList should be updated with priceListId of an asset
853
+ const actions = [
854
+ { name: 'UPDATE_PRICE_LIST', inputData: { lineItemId: payload.lineItemId } },
855
+ ];
856
+ const selectors = {};
857
+ if (!payload.productId) {
858
+ selectors['productIdResult'] = { name: 'FIND_PRODUCT_ID', inputData: { lineItemId: payload.lineItemId } };
859
+ }
860
+ return this.flowStateService.execute$(UITemplateType.FLOW_ENGINE, { actions, selectors }).pipe(map(({ productIdResult }) => {
861
+ if (!productIdResult) {
862
+ return payload;
863
+ }
864
+ const productId = productIdResult.success && typeof productIdResult.result === 'string' ? productIdResult.result : undefined;
865
+ return Object.assign(Object.assign({}, payload), { productId });
866
+ }));
867
+ }
843
868
  legacyApplyConfiguration() {
844
869
  const quoteDraft = this.quoteDraftService.quoteDraft;
845
870
  const lineItem = this.configurationService.getSnapshot();
@@ -847,7 +872,6 @@ class FlowService {
847
872
  return of(undefined);
848
873
  }
849
874
  const isNewLineItem = quoteDraft.currentState.every(li => li.id !== lineItem.id);
850
- const assetId = lineItem.assetId || lineItem.openOrderLineItemId;
851
875
  let updatedState;
852
876
  if (isNewLineItem) {
853
877
  updatedState = [...quoteDraft.currentState, lineItem];
@@ -855,15 +879,7 @@ class FlowService {
855
879
  else {
856
880
  updatedState = quoteDraft.currentState.map(li => (li.id === lineItem.id ? lineItem : li));
857
881
  }
858
- return this.flowConfigurationService.calculate$(Object.assign(Object.assign({}, quoteDraft), { currentState: updatedState })).pipe(tap(() => {
859
- var _a;
860
- if (assetId) {
861
- const modifiedAssets = (_a = this.integrationState.state.modifiedAssets) !== null && _a !== void 0 ? _a : {};
862
- this.integrationState.patchState({
863
- modifiedAssets: Object.assign(Object.assign({}, modifiedAssets), { [assetId]: true }),
864
- });
865
- }
866
- }));
882
+ return this.flowConfigurationService.calculate$(Object.assign(Object.assign({}, quoteDraft), { currentState: updatedState }));
867
883
  }
868
884
  }
869
885
  FlowService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: FlowService, deps: [{ token: i5.IntegrationState }, { token: FlowRouterService }, { token: i2.QuoteDraftService }, { token: i2.ConfigurationService }, { token: i2.ConfigurationStateService }, { token: FlowDialogService }, { token: i2.FlowConfigurationService }, { token: i2.FlowInfoService }, { token: i2.FlowStateService }], target: i0.ɵɵFactoryTarget.Injectable });
@@ -1498,12 +1514,11 @@ class ProductComponent {
1498
1514
  const offeringId = contextProperties.offeringId;
1499
1515
  return this.configurationRuntimeService.init({ productId, offeringId });
1500
1516
  }
1501
- const lineItemId = this.getLineItemId(quote, productId, contextProperties.lineItemId);
1502
- const currentStateItem = quote.currentState.find(({ id }) => id === lineItemId);
1503
- if (currentStateItem) {
1504
- this.configurationService.setConfigurableRamp(currentStateItem);
1517
+ const lineItem = this.getLineItem(quote, productId, contextProperties.lineItemId);
1518
+ if (lineItem) {
1519
+ this.configurationService.setConfigurableRamp(lineItem);
1505
1520
  }
1506
- const { offeringId } = currentStateItem !== null && currentStateItem !== void 0 ? currentStateItem : {};
1521
+ const { offeringId } = lineItem !== null && lineItem !== void 0 ? lineItem : {};
1507
1522
  return this.configurationRuntimeService.init({ productId, offeringId });
1508
1523
  }), switchMap(() => this.customizeUI$()), tap(() => {
1509
1524
  var _a, _b;
@@ -1521,14 +1536,18 @@ class ProductComponent {
1521
1536
  }
1522
1537
  }), switchMap(() => this.configurationStateService.init$()));
1523
1538
  }
1524
- getLineItemId(quote, productId, lineItemId) {
1525
- var _a, _b;
1539
+ getLineItem(quote, productId, lineItemId) {
1540
+ var _a;
1526
1541
  // search by lineItemId first
1527
- let id = (_a = quote.currentState.find(li => li.id === lineItemId)) === null || _a === void 0 ? void 0 : _a.id;
1528
- if (!id && this.quoteDraftService.isStandalone) {
1529
- id = (_b = quote.currentState.find(li => li.productId === productId)) === null || _b === void 0 ? void 0 : _b.id;
1542
+ let li = quote.currentState.find(li => li.id === lineItemId);
1543
+ if (!li && this.quoteDraftService.isStandalone) {
1544
+ li = quote.currentState.find(li => li.productId === productId);
1545
+ }
1546
+ // If still not found, is could be an asset
1547
+ if (!li) {
1548
+ li = (_a = this.quoteDraftService.assetsState) === null || _a === void 0 ? void 0 : _a.currentState.find(li => li.id === lineItemId);
1530
1549
  }
1531
- return id;
1550
+ return li;
1532
1551
  }
1533
1552
  }
1534
1553
  ProductComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: ProductComponent, deps: [{ token: i2.ContextService }, { token: i2.ConfigurationRuntimeService }, { token: i2.ConfigurationService }, { token: i2.ConfigurationStateService }, { token: i2.QuoteDraftService }, { token: i2.FlowInfoService }, { token: i2.FlowStateService }, { token: i2.IntegrationState }, { token: FLOW_CUSTOMIZATION, optional: true }], target: i0.ɵɵFactoryTarget.Component });