@veloceapps/sdk 10.0.0-2 → 10.0.0-21

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/modules/runtime/services/runtime.service.d.ts +3 -1
  2. package/cms/utils/index.d.ts +1 -0
  3. package/cms/utils/inject.d.ts +1 -0
  4. package/cms/utils/ui-definition.utils.d.ts +1 -0
  5. package/cms/vendor-map.d.ts +1 -0
  6. package/core/modules/configuration/services/configuration-state.service.d.ts +1 -0
  7. package/core/modules/flow-configuration/services/flow-configuration.service.d.ts +4 -1
  8. package/core/services/flow-state.service.d.ts +3 -1
  9. package/core/types/flow-state.types.d.ts +1 -0
  10. package/esm2020/cms/components/element-renderer/element-renderer.component.mjs +3 -2
  11. package/esm2020/cms/components/element-tools-panel/element-tools-panel.component.mjs +3 -3
  12. package/esm2020/cms/modules/runtime/services/runtime.service.mjs +3 -1
  13. package/esm2020/cms/utils/index.mjs +2 -1
  14. package/esm2020/cms/utils/inject.mjs +27 -0
  15. package/esm2020/cms/utils/ui-definition.utils.mjs +13 -1
  16. package/esm2020/cms/vendor-map.mjs +3 -1
  17. package/esm2020/core/modules/configuration/services/configuration-state.service.mjs +13 -4
  18. package/esm2020/core/modules/flow-configuration/services/flow-configuration.service.mjs +16 -5
  19. package/esm2020/core/services/flow-state.service.mjs +27 -9
  20. package/esm2020/core/types/flow-state.types.mjs +1 -1
  21. package/fesm2015/veloceapps-sdk-cms.mjs +43 -4
  22. package/fesm2015/veloceapps-sdk-cms.mjs.map +1 -1
  23. package/fesm2015/veloceapps-sdk-core.mjs +49 -12
  24. package/fesm2015/veloceapps-sdk-core.mjs.map +1 -1
  25. package/fesm2020/veloceapps-sdk-cms.mjs +42 -3
  26. package/fesm2020/veloceapps-sdk-cms.mjs.map +1 -1
  27. package/fesm2020/veloceapps-sdk-core.mjs +48 -12
  28. package/fesm2020/veloceapps-sdk-core.mjs.map +1 -1
  29. package/package.json +1 -1
@@ -478,7 +478,8 @@ class FlowStateService {
478
478
  this.EXECUTION_BUFFER_TIME = 100;
479
479
  this.executedFunctions = {};
480
480
  this.stateId$ = new BehaviorSubject(null);
481
- this._hasStatefulUnsavedChanges = true;
481
+ this.initialStatefulData = {};
482
+ this.trackedStatefulChangesMap = new Map();
482
483
  this.processors = {};
483
484
  this.subscriptions = {};
484
485
  this.flowStore = {};
@@ -561,7 +562,7 @@ class FlowStateService {
561
562
  }
562
563
  get hasUnsavedChanges() {
563
564
  return this.getFlowSafe().properties.stateful
564
- ? this._hasStatefulUnsavedChanges
565
+ ? Array.from(this.trackedStatefulChangesMap.values()).some(Boolean)
565
566
  : this.quoteDraftService.hasUnsavedChanges;
566
567
  }
567
568
  get stateId() {
@@ -625,6 +626,9 @@ class FlowStateService {
625
626
  data$: new BehaviorSubject(this.NOT_INITIALIZED),
626
627
  };
627
628
  this.subscriptions[requestId] = subscription;
629
+ if (options?.trackedChanges) {
630
+ this.trackedStatefulChangesMap.set(requestId, false);
631
+ }
628
632
  if (!options?.cold) {
629
633
  this.executeRequest$(request).subscribe();
630
634
  }
@@ -638,14 +642,18 @@ class FlowStateService {
638
642
  save$() {
639
643
  if (this.getFlowSafe().properties.stateful) {
640
644
  if (this.stateId$.value) {
641
- return this.flowStateApiService.save(this.stateId$.value);
645
+ return this.flowStateApiService.save(this.stateId$.value).pipe(tap$1(() => {
646
+ Array.from(this.trackedStatefulChangesMap.keys()).forEach(key => {
647
+ this.trackedStatefulChangesMap.set(key, false);
648
+ });
649
+ }));
642
650
  }
643
651
  }
644
652
  else {
645
653
  const quoteDraft = this.quoteDraftService.quoteDraft;
646
654
  if (quoteDraft) {
647
- return this.quoteApiService.upsertQuote(quoteDraft).pipe(tap$1(({ configurationId }) => {
648
- this.contextService.update({ properties: { ConfigurationId: configurationId } });
655
+ return this.quoteApiService.upsertQuote(quoteDraft).pipe(tap$1(({ versionId }) => {
656
+ this.contextService.update({ properties: { VELOCPQ__VersionId__c: versionId } });
649
657
  }));
650
658
  }
651
659
  }
@@ -660,8 +668,8 @@ class FlowStateService {
660
668
  else {
661
669
  const quoteDraft = this.quoteDraftService.quoteDraft;
662
670
  if (quoteDraft) {
663
- return this.quoteApiService.submitQuote(quoteDraft).pipe(tap$1(({ configurationId }) => {
664
- this.contextService.update({ properties: { ConfigurationId: configurationId } });
671
+ return this.quoteApiService.submitQuote(quoteDraft).pipe(tap$1(({ versionId }) => {
672
+ this.contextService.update({ properties: { VELOCPQ__VersionId__c: versionId } });
665
673
  }));
666
674
  }
667
675
  }
@@ -715,6 +723,7 @@ class FlowStateService {
715
723
  }
716
724
  const subscription$ = this.subscriptions[requestId]?.data$;
717
725
  if (subscription$ && subscription$.value !== selectorResult) {
726
+ this.checkStatefulChanges(requestId, selectorResult);
718
727
  subscription$.next(selectorResult);
719
728
  }
720
729
  });
@@ -954,6 +963,15 @@ class FlowStateService {
954
963
  });
955
964
  return request;
956
965
  }
966
+ checkStatefulChanges(requestId, selectorResult) {
967
+ if (this.trackedStatefulChangesMap.has(requestId)) {
968
+ if (!this.initialStatefulData[requestId]) {
969
+ this.initialStatefulData[requestId] = selectorResult;
970
+ }
971
+ const hasChanges = !isEqual(this.initialStatefulData[requestId], selectorResult);
972
+ this.trackedStatefulChangesMap.set(requestId, hasChanges);
973
+ }
974
+ }
957
975
  }
958
976
  FlowStateService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: FlowStateService, deps: [{ token: ContextService }, { token: QuoteDraftService }, { token: FlowInfoService }, { token: FlowConfigurationService }, { token: i1.ConfigurationProcessorsApiService }, { token: i1.FlowStateApiService }, { token: i1.QuoteApiService }, { token: i6.ToastService }, { token: FLOW_CUSTOMIZATION, optional: true }], target: i0.ɵɵFactoryTarget.Injectable });
959
977
  FlowStateService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: FlowStateService });
@@ -1664,17 +1682,18 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImpor
1664
1682
  }] });
1665
1683
 
1666
1684
  class FlowConfigurationService {
1667
- constructor(proceduresApiService, contextService, quoteDraftService, updateService, configurationService) {
1685
+ constructor(proceduresApiService, contextService, quoteDraftService, updateService, configurationService, flowInfoService) {
1668
1686
  this.proceduresApiService = proceduresApiService;
1669
1687
  this.contextService = contextService;
1670
1688
  this.quoteDraftService = quoteDraftService;
1671
1689
  this.updateService = updateService;
1672
1690
  this.configurationService = configurationService;
1691
+ this.flowInfoService = flowInfoService;
1673
1692
  this.updatedSubj$ = new Subject();
1674
1693
  this.updated$ = this.updatedSubj$.asObservable();
1675
1694
  }
1676
1695
  calculate$(quoteDraft) {
1677
- return this.proceduresApiService.apply$(quoteDraft).pipe(tap$1(result => {
1696
+ return this.extendedApply$(quoteDraft).pipe(tap$1(result => {
1678
1697
  // sort the result current state based on the quote draft initial state
1679
1698
  const initialStateIds = quoteDraft.initialState.map(lineItem => lineItem.integrationId);
1680
1699
  result.currentState = result.currentState
@@ -1794,12 +1813,20 @@ class FlowConfigurationService {
1794
1813
  }));
1795
1814
  };
1796
1815
  }
1816
+ extendedApply$(quoteDraft) {
1817
+ const request = { ...quoteDraft };
1818
+ const procedureName = this.flowInfoService.flow?.properties.procedureName;
1819
+ if (procedureName) {
1820
+ request.procedureName = procedureName;
1821
+ }
1822
+ return this.proceduresApiService.apply$(request);
1823
+ }
1797
1824
  }
1798
- FlowConfigurationService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: FlowConfigurationService, deps: [{ token: i1.ProceduresApiService }, { token: ContextService }, { token: QuoteDraftService }, { token: FlowUpdateService }, { token: ConfigurationService }], target: i0.ɵɵFactoryTarget.Injectable });
1825
+ FlowConfigurationService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: FlowConfigurationService, deps: [{ token: i1.ProceduresApiService }, { token: ContextService }, { token: QuoteDraftService }, { token: FlowUpdateService }, { token: ConfigurationService }, { token: FlowInfoService }], target: i0.ɵɵFactoryTarget.Injectable });
1799
1826
  FlowConfigurationService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: FlowConfigurationService });
1800
1827
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: FlowConfigurationService, decorators: [{
1801
1828
  type: Injectable
1802
- }], ctorParameters: function () { return [{ type: i1.ProceduresApiService }, { type: ContextService }, { type: QuoteDraftService }, { type: FlowUpdateService }, { type: ConfigurationService }]; } });
1829
+ }], ctorParameters: function () { return [{ type: i1.ProceduresApiService }, { type: ContextService }, { type: QuoteDraftService }, { type: FlowUpdateService }, { type: ConfigurationService }, { type: FlowInfoService }]; } });
1803
1830
 
1804
1831
  class FlowConfigurationModule {
1805
1832
  }
@@ -2071,6 +2098,7 @@ class ConfigurationStateService {
2071
2098
  this.configurationStore = {};
2072
2099
  this.executionInProgress$ = new BehaviorSubject(false);
2073
2100
  this.statefulRequestStream$ = new Subject();
2101
+ this.statelessExecutionRequest$ = null;
2074
2102
  this.statefulExecutionRequest$ = this.initBufferedRequest$();
2075
2103
  }
2076
2104
  get isExecutionInProgress$() {
@@ -2117,7 +2145,15 @@ class ConfigurationStateService {
2117
2145
  actions: [{ name: actionName, inputData }],
2118
2146
  };
2119
2147
  const request = this.execToRequest(exec);
2120
- return this.executeRequest$(request);
2148
+ const executionRequest$ = this.executeRequest$(request);
2149
+ if (this.isStatefulConfiguration) {
2150
+ return executionRequest$;
2151
+ }
2152
+ // prevent parallel configuration requests in stateless mode
2153
+ if (!this.statelessExecutionRequest$) {
2154
+ this.statelessExecutionRequest$ = executionRequest$.pipe(shareReplay$1(), take$1(1), finalize(() => (this.statelessExecutionRequest$ = null)));
2155
+ }
2156
+ return this.statelessExecutionRequest$;
2121
2157
  }
2122
2158
  select$(selectorName, inputData = {}) {
2123
2159
  const requestId = UUID.UUID();