@veloceapps/sdk 9.0.0-5 → 9.0.0-7
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 +17 -12
- package/esm2020/core/services/flow-state.service.mjs +12 -8
- package/esm2020/core/services/quote-draft.service.mjs +11 -5
- package/esm2020/src/services/flow.service.mjs +2 -2
- package/fesm2015/veloceapps-sdk-core.mjs +37 -22
- 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 +37 -22
- 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
@@ -1,6 +1,6 @@
|
|
1
1
|
import * as i0 from '@angular/core';
|
2
2
|
import { Injectable, InjectionToken, Optional, Inject, NgModule, inject, Directive, Input, LOCALE_ID, Pipe } from '@angular/core';
|
3
|
-
import { UUID, ConfigurationContextMode, ConfigurationContext, UITemplateType, isDefined, ConfigurationProcessorTypes, EntityUtil, DEFAULT_CURRENCY_ISO_CODE, DEFAULT_CURRENCY_SYMBOL, validateDateFormat, DEFAULT_DATE_FORMAT, DEFAULT_DECIMALS_COUNT, getSupportedDateFormats, DEFAULT_DECIMAL_SEPARATOR, DEFAULT_THOUSANDS_SEPARATOR, DEFAULT_ACTION_CODE_LABELS, parseJsonSafely, ConfigurationMode, ConfigurationTranslatorUtils, ChargeGroupUtils, RuntimeModel, isNotLegacyUIDefinition, SalesforceIdUtils, DEFAULT_TIME_FORMAT, formatNumber } from '@veloceapps/core';
|
3
|
+
import { UUID, ConfigurationContextMode, ConfigurationContext, UITemplateType, QuoteDraft, isDefined, ConfigurationProcessorTypes, EntityUtil, DEFAULT_CURRENCY_ISO_CODE, DEFAULT_CURRENCY_SYMBOL, validateDateFormat, DEFAULT_DATE_FORMAT, DEFAULT_DECIMALS_COUNT, getSupportedDateFormats, DEFAULT_DECIMAL_SEPARATOR, DEFAULT_THOUSANDS_SEPARATOR, DEFAULT_ACTION_CODE_LABELS, parseJsonSafely, ConfigurationMode, ConfigurationTranslatorUtils, ChargeGroupUtils, RuntimeModel, isNotLegacyUIDefinition, SalesforceIdUtils, DEFAULT_TIME_FORMAT, formatNumber } from '@veloceapps/core';
|
4
4
|
import * as i1 from '@veloceapps/api';
|
5
5
|
import { ApiModule } from '@veloceapps/api';
|
6
6
|
import { BehaviorSubject, switchMap, map as map$1, tap as tap$1, noop, catchError, throwError, of, forkJoin, zip, combineLatest, Subject, filter as filter$1, shareReplay as shareReplay$1, finalize, takeUntil, buffer, debounceTime, share, take as take$1, distinctUntilChanged } from 'rxjs';
|
@@ -344,13 +344,19 @@ class QuoteDraftService {
|
|
344
344
|
}
|
345
345
|
init(headerId, params) {
|
346
346
|
const ctx = this.context.resolve();
|
347
|
-
const
|
348
|
-
|
347
|
+
const isAccountMode = this.context.mode === ConfigurationContextMode.ACCOUNT;
|
348
|
+
const accountId = isAccountMode ? headerId : ctx.properties.AccountId;
|
349
|
+
return zip(accountId ? this.accountApiService.getAssetsState(accountId, params) : of(null), isAccountMode ? of(QuoteDraft.emptyQuote(ConfigurationContextMode.ACCOUNT)) : this.quoteApiService.getQuoteState(headerId, params)).pipe(tap(([assets, quote]) => {
|
349
350
|
if (assets) {
|
350
351
|
this.assetsSubj$.next(assets);
|
351
352
|
}
|
352
353
|
this.quoteSubj$.next(quote);
|
353
|
-
|
354
|
+
if (assets && isAccountMode) {
|
355
|
+
this.context.update(assets.context);
|
356
|
+
}
|
357
|
+
else {
|
358
|
+
this.context.update(quote.context);
|
359
|
+
}
|
354
360
|
}), map(() => noop()), take(1));
|
355
361
|
}
|
356
362
|
finalizeInit() {
|
@@ -474,7 +480,7 @@ class FlowStateService {
|
|
474
480
|
this.processors = {};
|
475
481
|
this.subscriptions = {};
|
476
482
|
this.flowStore = {};
|
477
|
-
this.
|
483
|
+
this.executionInProgress$ = new BehaviorSubject(false);
|
478
484
|
this.statefulRequestStream$ = new Subject();
|
479
485
|
this.cleanup$ = new Subject();
|
480
486
|
this.statefulExecutionRequest$ = this.initBufferedRequest$();
|
@@ -560,7 +566,7 @@ class FlowStateService {
|
|
560
566
|
return this.stateId$.value;
|
561
567
|
}
|
562
568
|
get isExecutionInProgress$() {
|
563
|
-
return this.
|
569
|
+
return this.executionInProgress$.asObservable();
|
564
570
|
}
|
565
571
|
isInitialized$() {
|
566
572
|
return combineLatest([this.stateId$, this.quoteDraftService.isInitialized$]).pipe(map$1(values => values.some(Boolean)));
|
@@ -754,15 +760,15 @@ class FlowStateService {
|
|
754
760
|
.filter(isDefined)
|
755
761
|
.reduce((acc, selectorsMap) => Object.assign(acc, selectorsMap), {}),
|
756
762
|
};
|
757
|
-
this.
|
763
|
+
this.executionInProgress$.next(true);
|
758
764
|
return this.flowStateApiService.execute(this.stateId$.value, request);
|
759
|
-
}), tap$1(({ stateId }) => this.stateId$.next(stateId)), share(), tap$1(() => this.
|
760
|
-
this.
|
765
|
+
}), tap$1(({ stateId }) => this.stateId$.next(stateId)), share(), tap$1(() => this.executionInProgress$.next(false)), catchError(e => {
|
766
|
+
this.executionInProgress$.next(false);
|
761
767
|
return throwError(() => e);
|
762
768
|
}));
|
763
769
|
}
|
764
770
|
executeStateful$(request) {
|
765
|
-
return this.
|
771
|
+
return this.executionInProgress$.pipe(filter$1(inProgress => !inProgress), take$1(1), switchMap(() =>
|
766
772
|
// make sure stream switches to statefulExecutionRequest$ before pushing an execution request
|
767
773
|
combineLatest([
|
768
774
|
this.statefulExecutionRequest$,
|
@@ -803,6 +809,7 @@ class FlowStateService {
|
|
803
809
|
return this.flowConfiguration.calculate$(flowState);
|
804
810
|
}
|
805
811
|
executeStateless$(request) {
|
812
|
+
this.executionInProgress$.next(true);
|
806
813
|
return of(undefined).pipe(tap$1(() => this.executeStatelessActions(request)), switchMap(() => {
|
807
814
|
/*
|
808
815
|
Skip price calculation in case
|
@@ -815,7 +822,10 @@ class FlowStateService {
|
|
815
822
|
else {
|
816
823
|
return this.calculate$();
|
817
824
|
}
|
818
|
-
}), 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
|
+
}));
|
819
829
|
}
|
820
830
|
executeStatelessActions(request) {
|
821
831
|
if (!this.quoteDraftService.quoteDraft || !request.actions?.length) {
|
@@ -2052,10 +2062,13 @@ class ConfigurationStateService {
|
|
2052
2062
|
this.ownerId = '';
|
2053
2063
|
this.subscriptions = {};
|
2054
2064
|
this.configurationStore = {};
|
2055
|
-
this.
|
2065
|
+
this.executionInProgress$ = new BehaviorSubject(false);
|
2056
2066
|
this.statefulRequestStream$ = new Subject();
|
2057
2067
|
this.statefulExecutionRequest$ = this.initBufferedRequest$();
|
2058
2068
|
}
|
2069
|
+
get isExecutionInProgress$() {
|
2070
|
+
return this.executionInProgress$.asObservable();
|
2071
|
+
}
|
2059
2072
|
init$() {
|
2060
2073
|
let request$;
|
2061
2074
|
if (this.flowStateService.stateId && this.isStatefulConfiguration) {
|
@@ -2149,7 +2162,8 @@ class ConfigurationStateService {
|
|
2149
2162
|
}
|
2150
2163
|
}), takeUntil(this.canceledConfiguration$));
|
2151
2164
|
}
|
2152
|
-
saveConfiguration(
|
2165
|
+
saveConfiguration(first, second) {
|
2166
|
+
const flow = typeof first === 'boolean' ? first : second;
|
2153
2167
|
if (this.isStatefulConfiguration) {
|
2154
2168
|
return this.flowStateApiService
|
2155
2169
|
.saveConfiguration(this.flowStateService.stateId ?? '', this.stateId ?? '')
|
@@ -2157,16 +2171,15 @@ class ConfigurationStateService {
|
|
2157
2171
|
}
|
2158
2172
|
else {
|
2159
2173
|
if (!flow) {
|
2160
|
-
|
2174
|
+
const quoteDraft = this.quoteDraftService.quoteDraft;
|
2175
|
+
if (!quoteDraft) {
|
2161
2176
|
return of({ quoteId: '' });
|
2162
2177
|
}
|
2163
2178
|
const rootLineItem = this.configurationService.getSnapshot();
|
2164
2179
|
const asset = this.configurationService.getAsset();
|
2165
2180
|
const currentState = rootLineItem ? [rootLineItem] : [];
|
2166
2181
|
const initialState = asset ? [asset] : [];
|
2167
|
-
return this.quoteApiService
|
2168
|
-
.getQuoteState(quoteId)
|
2169
|
-
.pipe(switchMap(quoteDraft => this.quoteApiService.upsertQuote({ ...quoteDraft, currentState, initialState })));
|
2182
|
+
return this.quoteApiService.upsertQuote({ ...quoteDraft, currentState, initialState });
|
2170
2183
|
}
|
2171
2184
|
else {
|
2172
2185
|
const quoteDraft = this.quoteDraftService.quoteDraft;
|
@@ -2243,6 +2256,7 @@ class ConfigurationStateService {
|
|
2243
2256
|
return this.configurationService.configure().pipe(map$1(() => undefined));
|
2244
2257
|
}
|
2245
2258
|
executeStateless$(request) {
|
2259
|
+
this.executionInProgress$.next(true);
|
2246
2260
|
return of(undefined).pipe(switchMap(() => {
|
2247
2261
|
// Apply actions and execute configuration/price call
|
2248
2262
|
// No need to run configuration if no actions in the request
|
@@ -2277,7 +2291,8 @@ class ConfigurationStateService {
|
|
2277
2291
|
return result;
|
2278
2292
|
}, { stateId: '', selectors: {} });
|
2279
2293
|
return selectorsResult;
|
2280
|
-
}), catchError(error => {
|
2294
|
+
}), tap$1(() => this.executionInProgress$.next(false)), catchError(error => {
|
2295
|
+
this.executionInProgress$.next(false);
|
2281
2296
|
if (!this.configurationRuntimeService.uiDefinitionProperties.suppressToastMessages) {
|
2282
2297
|
this.toastService.add({ severity: ToastType.error, summary: String(error) });
|
2283
2298
|
}
|
@@ -2297,15 +2312,15 @@ class ConfigurationStateService {
|
|
2297
2312
|
.filter(isDefined)
|
2298
2313
|
.reduce((acc, selectorsMap) => Object.assign(acc, selectorsMap), {}),
|
2299
2314
|
};
|
2300
|
-
this.
|
2315
|
+
this.executionInProgress$.next(true);
|
2301
2316
|
return this.flowStateApiService.executeConfiguration(this.flowStateService.stateId, this.stateId, request);
|
2302
|
-
}), tap$1(({ stateId }) => (this.stateId = stateId)), share(), tap$1(() => this.
|
2303
|
-
this.
|
2317
|
+
}), tap$1(({ stateId }) => (this.stateId = stateId)), share(), tap$1(() => this.executionInProgress$.next(false)), catchError(e => {
|
2318
|
+
this.executionInProgress$.next(false);
|
2304
2319
|
return throwError(() => e);
|
2305
2320
|
}));
|
2306
2321
|
}
|
2307
2322
|
executeStateful$(request) {
|
2308
|
-
return this.
|
2323
|
+
return this.executionInProgress$.pipe(filter$1(inProgress => !inProgress), take$1(1), switchMap(() =>
|
2309
2324
|
// make sure stream switches to statefulExecutionRequest$ before pushing an execution request
|
2310
2325
|
combineLatest([
|
2311
2326
|
this.statefulExecutionRequest$,
|