@veloceapps/sdk 8.0.0-116 → 8.0.0-117
Sign up to get free protection for your applications and to get access to all the features.
- package/core/services/flow-state.service.d.ts +2 -0
- package/esm2020/core/services/flow-state.service.mjs +48 -36
- package/fesm2015/veloceapps-sdk-core.mjs +49 -36
- package/fesm2015/veloceapps-sdk-core.mjs.map +1 -1
- package/fesm2020/veloceapps-sdk-core.mjs +47 -35
- package/fesm2020/veloceapps-sdk-core.mjs.map +1 -1
- package/package.json +1 -1
@@ -784,7 +784,7 @@ class FlowStateService {
|
|
784
784
|
.pipe(filter$1(Boolean), filter$1(() => !this.getFlowSafe().properties.stateful), switchMap(() => this.quoteDraftService.quoteDraft$), skip$1(1), switchMap(() => this.executeRequest$({}, true)))
|
785
785
|
.subscribe();
|
786
786
|
this.charges$ = this.flowInfoService.flow$.pipe(filter$1(isDefined), switchMap(flow => {
|
787
|
-
if (!flow
|
787
|
+
if (!flow.properties.stateful) {
|
788
788
|
return this.quoteDraftService.quoteDraft$.pipe(map$1(quoteDraft => quoteDraft.charges));
|
789
789
|
}
|
790
790
|
else {
|
@@ -792,7 +792,7 @@ class FlowStateService {
|
|
792
792
|
cold: true,
|
793
793
|
}).pipe(map$1(response => (response.success ? response.result : {})));
|
794
794
|
}
|
795
|
-
}), shareReplay$1());
|
795
|
+
}), filter$1(isDefined), shareReplay$1());
|
796
796
|
this.charges$.subscribe();
|
797
797
|
this.pricePlans$ = this.flowInfoService.flow$.pipe(filter$1(isDefined), switchMap(flow => {
|
798
798
|
if (!flow.properties.stateful) {
|
@@ -803,10 +803,10 @@ class FlowStateService {
|
|
803
803
|
cold: true,
|
804
804
|
}).pipe(map$1(response => (response.success ? response.result : {})));
|
805
805
|
}
|
806
|
-
}), shareReplay$1());
|
806
|
+
}), filter$1(isDefined), shareReplay$1());
|
807
807
|
this.pricePlans$.subscribe();
|
808
808
|
this.activeMetrics$ = this.flowInfoService.flow$.pipe(filter$1(isDefined), switchMap(flow => {
|
809
|
-
if (!flow
|
809
|
+
if (!flow.properties.stateful) {
|
810
810
|
return this.quoteDraftService.quoteDraft$.pipe(map$1(quoteDraft => quoteDraft.activeMetrics));
|
811
811
|
}
|
812
812
|
else {
|
@@ -814,7 +814,7 @@ class FlowStateService {
|
|
814
814
|
cold: true,
|
815
815
|
}).pipe(map$1(response => (response.success ? response.result : [])));
|
816
816
|
}
|
817
|
-
}), shareReplay$1());
|
817
|
+
}), filter$1(isDefined), shareReplay$1());
|
818
818
|
this.activeMetrics$.subscribe();
|
819
819
|
}
|
820
820
|
init$() {
|
@@ -1018,7 +1018,7 @@ class FlowStateService {
|
|
1018
1018
|
if (!this.stateId$.value) {
|
1019
1019
|
throw 'Stateful session is not initialized';
|
1020
1020
|
}
|
1021
|
-
return this.flowStateApiService.execute(this.stateId$.value, request).pipe(tap$1(
|
1021
|
+
return this.flowStateApiService.execute(this.stateId$.value, request).pipe(tap$1(() => {
|
1022
1022
|
if (request.actions?.length) {
|
1023
1023
|
this._hasStatefulUnsavedChanges = true;
|
1024
1024
|
}
|
@@ -1046,38 +1046,50 @@ class FlowStateService {
|
|
1046
1046
|
return this.flowConfiguration.calculate$(flowState);
|
1047
1047
|
}
|
1048
1048
|
executeStateless$(request) {
|
1049
|
-
return of(undefined).pipe(switchMap(() => {
|
1050
|
-
|
1049
|
+
return of(undefined).pipe(tap$1(() => this.executeStatelessActions(request)), switchMap(() => {
|
1050
|
+
/*
|
1051
|
+
Skip price calculation in case
|
1052
|
+
1. No actions in the request
|
1053
|
+
2. Initialization process execution (state not initialized yet)
|
1054
|
+
*/
|
1055
|
+
if (!request.actions?.length || !this.isInitialized()) {
|
1051
1056
|
return of(undefined);
|
1052
1057
|
}
|
1053
|
-
|
1054
|
-
|
1055
|
-
flowState = this.executeActionScript(flowState, action) ?? flowState;
|
1056
|
-
});
|
1057
|
-
this.quoteDraftService.updateQuoteDraft(flowState);
|
1058
|
-
return this.calculate$();
|
1059
|
-
}), map$1(() => {
|
1060
|
-
if (!this.quoteDraftService.quoteDraft) {
|
1061
|
-
throw 'QuoteDraft is not initialized';
|
1058
|
+
else {
|
1059
|
+
return this.calculate$();
|
1062
1060
|
}
|
1063
|
-
|
1064
|
-
|
1065
|
-
|
1066
|
-
|
1067
|
-
|
1068
|
-
|
1069
|
-
|
1070
|
-
|
1071
|
-
|
1072
|
-
|
1073
|
-
|
1074
|
-
|
1075
|
-
|
1076
|
-
|
1077
|
-
|
1078
|
-
|
1079
|
-
|
1080
|
-
}))
|
1061
|
+
}), map$1(() => this.executeStatelessSelectors(request)));
|
1062
|
+
}
|
1063
|
+
executeStatelessActions(request) {
|
1064
|
+
if (!this.quoteDraftService.quoteDraft || !request.actions?.length) {
|
1065
|
+
return;
|
1066
|
+
}
|
1067
|
+
let flowState = this.quoteDraftService.quoteDraft;
|
1068
|
+
request.actions.forEach(action => {
|
1069
|
+
flowState = this.executeActionScript(flowState, action) ?? flowState;
|
1070
|
+
});
|
1071
|
+
this.quoteDraftService.updateQuoteDraft(flowState);
|
1072
|
+
}
|
1073
|
+
executeStatelessSelectors(request) {
|
1074
|
+
if (!this.quoteDraftService.quoteDraft) {
|
1075
|
+
throw 'QuoteDraft is not initialized';
|
1076
|
+
}
|
1077
|
+
const flowState = this.quoteDraftService.quoteDraft;
|
1078
|
+
return EntityUtil.entries(request.selectors ?? {}).reduce((result, [key, selector]) => {
|
1079
|
+
try {
|
1080
|
+
result.selectors[key] = {
|
1081
|
+
success: true,
|
1082
|
+
result: this.executeSelectorScript(flowState, selector),
|
1083
|
+
};
|
1084
|
+
}
|
1085
|
+
catch (e) {
|
1086
|
+
result.selectors[key] = {
|
1087
|
+
success: false,
|
1088
|
+
errorMessage: String(e),
|
1089
|
+
};
|
1090
|
+
}
|
1091
|
+
return result;
|
1092
|
+
}, { stateId: '', selectors: {} });
|
1081
1093
|
}
|
1082
1094
|
getFlowSafe() {
|
1083
1095
|
if (!this.flowInfoService.flow) {
|