@veloceapps/sdk 9.0.0-6 → 9.0.0-8
Sign up to get free protection for your applications and to get access to all the features.
- package/core/modules/configuration/services/configuration-state.service.d.ts +6 -1
- package/core/services/flow-state.service.d.ts +1 -1
- package/esm2020/core/modules/configuration/services/configuration-state.service.mjs +19 -13
- package/esm2020/core/services/flow-state.service.mjs +12 -8
- package/esm2020/src/services/flow.service.mjs +2 -2
- package/fesm2015/veloceapps-sdk-core.mjs +28 -18
- package/fesm2015/veloceapps-sdk-core.mjs.map +1 -1
- package/fesm2015/veloceapps-sdk.mjs +1 -1
- package/fesm2015/veloceapps-sdk.mjs.map +1 -1
- package/fesm2020/veloceapps-sdk-core.mjs +28 -18
- package/fesm2020/veloceapps-sdk-core.mjs.map +1 -1
- package/fesm2020/veloceapps-sdk.mjs +1 -1
- package/fesm2020/veloceapps-sdk.mjs.map +1 -1
- package/package.json +1 -1
@@ -480,7 +480,7 @@ class FlowStateService {
|
|
480
480
|
this.processors = {};
|
481
481
|
this.subscriptions = {};
|
482
482
|
this.flowStore = {};
|
483
|
-
this.
|
483
|
+
this.executionInProgress$ = new BehaviorSubject(false);
|
484
484
|
this.statefulRequestStream$ = new Subject();
|
485
485
|
this.cleanup$ = new Subject();
|
486
486
|
this.statefulExecutionRequest$ = this.initBufferedRequest$();
|
@@ -566,7 +566,7 @@ class FlowStateService {
|
|
566
566
|
return this.stateId$.value;
|
567
567
|
}
|
568
568
|
get isExecutionInProgress$() {
|
569
|
-
return this.
|
569
|
+
return this.executionInProgress$.asObservable();
|
570
570
|
}
|
571
571
|
isInitialized$() {
|
572
572
|
return combineLatest([this.stateId$, this.quoteDraftService.isInitialized$]).pipe(map$1(values => values.some(Boolean)));
|
@@ -760,15 +760,15 @@ class FlowStateService {
|
|
760
760
|
.filter(isDefined)
|
761
761
|
.reduce((acc, selectorsMap) => Object.assign(acc, selectorsMap), {}),
|
762
762
|
};
|
763
|
-
this.
|
763
|
+
this.executionInProgress$.next(true);
|
764
764
|
return this.flowStateApiService.execute(this.stateId$.value, request);
|
765
|
-
}), tap$1(({ stateId }) => this.stateId$.next(stateId)), share(), tap$1(() => this.
|
766
|
-
this.
|
765
|
+
}), tap$1(({ stateId }) => this.stateId$.next(stateId)), share(), tap$1(() => this.executionInProgress$.next(false)), catchError(e => {
|
766
|
+
this.executionInProgress$.next(false);
|
767
767
|
return throwError(() => e);
|
768
768
|
}));
|
769
769
|
}
|
770
770
|
executeStateful$(request) {
|
771
|
-
return this.
|
771
|
+
return this.executionInProgress$.pipe(filter$1(inProgress => !inProgress), take$1(1), switchMap(() =>
|
772
772
|
// make sure stream switches to statefulExecutionRequest$ before pushing an execution request
|
773
773
|
combineLatest([
|
774
774
|
this.statefulExecutionRequest$,
|
@@ -809,6 +809,7 @@ class FlowStateService {
|
|
809
809
|
return this.flowConfiguration.calculate$(flowState);
|
810
810
|
}
|
811
811
|
executeStateless$(request) {
|
812
|
+
this.executionInProgress$.next(true);
|
812
813
|
return of(undefined).pipe(tap$1(() => this.executeStatelessActions(request)), switchMap(() => {
|
813
814
|
/*
|
814
815
|
Skip price calculation in case
|
@@ -821,7 +822,10 @@ class FlowStateService {
|
|
821
822
|
else {
|
822
823
|
return this.calculate$();
|
823
824
|
}
|
824
|
-
}), map$1(() => this.executeStatelessSelectors(request)))
|
825
|
+
}), map$1(() => this.executeStatelessSelectors(request)), tap$1(() => this.executionInProgress$.next(false)), catchError(e => {
|
826
|
+
this.executionInProgress$.next(false);
|
827
|
+
return throwError(() => e);
|
828
|
+
}));
|
825
829
|
}
|
826
830
|
executeStatelessActions(request) {
|
827
831
|
if (!this.quoteDraftService.quoteDraft || !request.actions?.length) {
|
@@ -2058,10 +2062,13 @@ class ConfigurationStateService {
|
|
2058
2062
|
this.ownerId = '';
|
2059
2063
|
this.subscriptions = {};
|
2060
2064
|
this.configurationStore = {};
|
2061
|
-
this.
|
2065
|
+
this.executionInProgress$ = new BehaviorSubject(false);
|
2062
2066
|
this.statefulRequestStream$ = new Subject();
|
2063
2067
|
this.statefulExecutionRequest$ = this.initBufferedRequest$();
|
2064
2068
|
}
|
2069
|
+
get isExecutionInProgress$() {
|
2070
|
+
return this.executionInProgress$.asObservable();
|
2071
|
+
}
|
2065
2072
|
init$() {
|
2066
2073
|
let request$;
|
2067
2074
|
if (this.flowStateService.stateId && this.isStatefulConfiguration) {
|
@@ -2155,7 +2162,8 @@ class ConfigurationStateService {
|
|
2155
2162
|
}
|
2156
2163
|
}), takeUntil(this.canceledConfiguration$));
|
2157
2164
|
}
|
2158
|
-
saveConfiguration(
|
2165
|
+
saveConfiguration(first, second) {
|
2166
|
+
const flow = typeof first === 'boolean' ? first : second;
|
2159
2167
|
if (this.isStatefulConfiguration) {
|
2160
2168
|
return this.flowStateApiService
|
2161
2169
|
.saveConfiguration(this.flowStateService.stateId ?? '', this.stateId ?? '')
|
@@ -2163,16 +2171,15 @@ class ConfigurationStateService {
|
|
2163
2171
|
}
|
2164
2172
|
else {
|
2165
2173
|
if (!flow) {
|
2166
|
-
|
2174
|
+
const quoteDraft = this.quoteDraftService.quoteDraft;
|
2175
|
+
if (!quoteDraft) {
|
2167
2176
|
return of({ quoteId: '' });
|
2168
2177
|
}
|
2169
2178
|
const rootLineItem = this.configurationService.getSnapshot();
|
2170
2179
|
const asset = this.configurationService.getAsset();
|
2171
2180
|
const currentState = rootLineItem ? [rootLineItem] : [];
|
2172
2181
|
const initialState = asset ? [asset] : [];
|
2173
|
-
return this.quoteApiService
|
2174
|
-
.getQuoteState(quoteId)
|
2175
|
-
.pipe(switchMap(quoteDraft => this.quoteApiService.upsertQuote({ ...quoteDraft, currentState, initialState })));
|
2182
|
+
return this.quoteApiService.upsertQuote({ ...quoteDraft, currentState, initialState });
|
2176
2183
|
}
|
2177
2184
|
else {
|
2178
2185
|
const quoteDraft = this.quoteDraftService.quoteDraft;
|
@@ -2249,6 +2256,7 @@ class ConfigurationStateService {
|
|
2249
2256
|
return this.configurationService.configure().pipe(map$1(() => undefined));
|
2250
2257
|
}
|
2251
2258
|
executeStateless$(request) {
|
2259
|
+
this.executionInProgress$.next(true);
|
2252
2260
|
return of(undefined).pipe(switchMap(() => {
|
2253
2261
|
// Apply actions and execute configuration/price call
|
2254
2262
|
// No need to run configuration if no actions in the request
|
@@ -2259,6 +2267,7 @@ class ConfigurationStateService {
|
|
2259
2267
|
request.actions.forEach(action => {
|
2260
2268
|
configurationRequest = this.executeActionScript(configurationRequest, action) ?? configurationRequest;
|
2261
2269
|
});
|
2270
|
+
configurationRequest = ConfigurationTranslatorUtils.lightenConfigurationRequest(configurationRequest);
|
2262
2271
|
return this.configurationService.configureRequest$(configurationRequest);
|
2263
2272
|
}), map$1(() => {
|
2264
2273
|
// Run selectors and apply them to the state
|
@@ -2283,7 +2292,8 @@ class ConfigurationStateService {
|
|
2283
2292
|
return result;
|
2284
2293
|
}, { stateId: '', selectors: {} });
|
2285
2294
|
return selectorsResult;
|
2286
|
-
}), catchError(error => {
|
2295
|
+
}), tap$1(() => this.executionInProgress$.next(false)), catchError(error => {
|
2296
|
+
this.executionInProgress$.next(false);
|
2287
2297
|
if (!this.configurationRuntimeService.uiDefinitionProperties.suppressToastMessages) {
|
2288
2298
|
this.toastService.add({ severity: ToastType.error, summary: String(error) });
|
2289
2299
|
}
|
@@ -2303,15 +2313,15 @@ class ConfigurationStateService {
|
|
2303
2313
|
.filter(isDefined)
|
2304
2314
|
.reduce((acc, selectorsMap) => Object.assign(acc, selectorsMap), {}),
|
2305
2315
|
};
|
2306
|
-
this.
|
2316
|
+
this.executionInProgress$.next(true);
|
2307
2317
|
return this.flowStateApiService.executeConfiguration(this.flowStateService.stateId, this.stateId, request);
|
2308
|
-
}), tap$1(({ stateId }) => (this.stateId = stateId)), share(), tap$1(() => this.
|
2309
|
-
this.
|
2318
|
+
}), tap$1(({ stateId }) => (this.stateId = stateId)), share(), tap$1(() => this.executionInProgress$.next(false)), catchError(e => {
|
2319
|
+
this.executionInProgress$.next(false);
|
2310
2320
|
return throwError(() => e);
|
2311
2321
|
}));
|
2312
2322
|
}
|
2313
2323
|
executeStateful$(request) {
|
2314
|
-
return this.
|
2324
|
+
return this.executionInProgress$.pipe(filter$1(inProgress => !inProgress), take$1(1), switchMap(() =>
|
2315
2325
|
// make sure stream switches to statefulExecutionRequest$ before pushing an execution request
|
2316
2326
|
combineLatest([
|
2317
2327
|
this.statefulExecutionRequest$,
|