@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 { InjectionToken, Injectable, Optional, Inject, NgModule, inject, Directive, Input, LOCALE_ID, Pipe } from '@angular/core';
|
3
|
-
import { UUID, ConfigurationContextMode, ConfigurationContext, UITemplateType, isDefined, ConfigurationProcessorTypes, EntityUtil, ChargeGroupUtils, 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, RuntimeModel, isNotLegacyUIDefinition, SalesforceIdUtils, DEFAULT_TIME_FORMAT, formatNumber } from '@veloceapps/core';
|
3
|
+
import { UUID, ConfigurationContextMode, ConfigurationContext, UITemplateType, QuoteDraft, isDefined, ConfigurationProcessorTypes, EntityUtil, ChargeGroupUtils, 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, RuntimeModel, isNotLegacyUIDefinition, SalesforceIdUtils, DEFAULT_TIME_FORMAT, formatNumber } from '@veloceapps/core';
|
4
4
|
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';
|
5
5
|
import { map, filter, tap, switchMap as switchMap$1, skip, take, shareReplay, catchError as catchError$1, finalize as finalize$1, first } from 'rxjs/operators';
|
6
6
|
import * as i1 from '@veloceapps/api';
|
@@ -319,13 +319,19 @@ class QuoteDraftService {
|
|
319
319
|
}
|
320
320
|
init(headerId, params) {
|
321
321
|
const ctx = this.context.resolve();
|
322
|
-
const
|
323
|
-
|
322
|
+
const isAccountMode = this.context.mode === ConfigurationContextMode.ACCOUNT;
|
323
|
+
const accountId = isAccountMode ? headerId : ctx.properties.AccountId;
|
324
|
+
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]) => {
|
324
325
|
if (assets) {
|
325
326
|
this.assetsSubj$.next(assets);
|
326
327
|
}
|
327
328
|
this.quoteSubj$.next(quote);
|
328
|
-
|
329
|
+
if (assets && isAccountMode) {
|
330
|
+
this.context.update(assets.context);
|
331
|
+
}
|
332
|
+
else {
|
333
|
+
this.context.update(quote.context);
|
334
|
+
}
|
329
335
|
}), map(() => noop()), take(1));
|
330
336
|
}
|
331
337
|
finalizeInit() {
|
@@ -436,7 +442,7 @@ class FlowStateService {
|
|
436
442
|
this.processors = {};
|
437
443
|
this.subscriptions = {};
|
438
444
|
this.flowStore = {};
|
439
|
-
this.
|
445
|
+
this.executionInProgress$ = new BehaviorSubject(false);
|
440
446
|
this.statefulRequestStream$ = new Subject();
|
441
447
|
this.cleanup$ = new Subject();
|
442
448
|
this.statefulExecutionRequest$ = this.initBufferedRequest$();
|
@@ -522,7 +528,7 @@ class FlowStateService {
|
|
522
528
|
return this.stateId$.value;
|
523
529
|
}
|
524
530
|
get isExecutionInProgress$() {
|
525
|
-
return this.
|
531
|
+
return this.executionInProgress$.asObservable();
|
526
532
|
}
|
527
533
|
isInitialized$() {
|
528
534
|
return combineLatest([this.stateId$, this.quoteDraftService.isInitialized$]).pipe(map$1(values => values.some(Boolean)));
|
@@ -723,15 +729,15 @@ class FlowStateService {
|
|
723
729
|
.filter(isDefined)
|
724
730
|
.reduce((acc, selectorsMap) => Object.assign(acc, selectorsMap), {}),
|
725
731
|
};
|
726
|
-
this.
|
732
|
+
this.executionInProgress$.next(true);
|
727
733
|
return this.flowStateApiService.execute(this.stateId$.value, request);
|
728
|
-
}), tap$1(({ stateId }) => this.stateId$.next(stateId)), share(), tap$1(() => this.
|
729
|
-
this.
|
734
|
+
}), tap$1(({ stateId }) => this.stateId$.next(stateId)), share(), tap$1(() => this.executionInProgress$.next(false)), catchError(e => {
|
735
|
+
this.executionInProgress$.next(false);
|
730
736
|
return throwError(() => e);
|
731
737
|
}));
|
732
738
|
}
|
733
739
|
executeStateful$(request) {
|
734
|
-
return this.
|
740
|
+
return this.executionInProgress$.pipe(filter$1(inProgress => !inProgress), take$1(1), switchMap(() =>
|
735
741
|
// make sure stream switches to statefulExecutionRequest$ before pushing an execution request
|
736
742
|
combineLatest([
|
737
743
|
this.statefulExecutionRequest$,
|
@@ -774,6 +780,7 @@ class FlowStateService {
|
|
774
780
|
return this.flowConfiguration.calculate$(flowState);
|
775
781
|
}
|
776
782
|
executeStateless$(request) {
|
783
|
+
this.executionInProgress$.next(true);
|
777
784
|
return of(undefined).pipe(tap$1(() => this.executeStatelessActions(request)), switchMap(() => {
|
778
785
|
var _a;
|
779
786
|
/*
|
@@ -787,7 +794,10 @@ class FlowStateService {
|
|
787
794
|
else {
|
788
795
|
return this.calculate$();
|
789
796
|
}
|
790
|
-
}), map$1(() => this.executeStatelessSelectors(request)))
|
797
|
+
}), map$1(() => this.executeStatelessSelectors(request)), tap$1(() => this.executionInProgress$.next(false)), catchError(e => {
|
798
|
+
this.executionInProgress$.next(false);
|
799
|
+
return throwError(() => e);
|
800
|
+
}));
|
791
801
|
}
|
792
802
|
executeStatelessActions(request) {
|
793
803
|
var _a;
|
@@ -2022,10 +2032,13 @@ class ConfigurationStateService {
|
|
2022
2032
|
this.ownerId = '';
|
2023
2033
|
this.subscriptions = {};
|
2024
2034
|
this.configurationStore = {};
|
2025
|
-
this.
|
2035
|
+
this.executionInProgress$ = new BehaviorSubject(false);
|
2026
2036
|
this.statefulRequestStream$ = new Subject();
|
2027
2037
|
this.statefulExecutionRequest$ = this.initBufferedRequest$();
|
2028
2038
|
}
|
2039
|
+
get isExecutionInProgress$() {
|
2040
|
+
return this.executionInProgress$.asObservable();
|
2041
|
+
}
|
2029
2042
|
init$() {
|
2030
2043
|
let request$;
|
2031
2044
|
if (this.flowStateService.stateId && this.isStatefulConfiguration) {
|
@@ -2122,8 +2135,9 @@ class ConfigurationStateService {
|
|
2122
2135
|
}
|
2123
2136
|
}), takeUntil(this.canceledConfiguration$));
|
2124
2137
|
}
|
2125
|
-
saveConfiguration(
|
2138
|
+
saveConfiguration(first, second) {
|
2126
2139
|
var _a, _b, _c, _d;
|
2140
|
+
const flow = typeof first === 'boolean' ? first : second;
|
2127
2141
|
if (this.isStatefulConfiguration) {
|
2128
2142
|
return this.flowStateApiService
|
2129
2143
|
.saveConfiguration((_a = this.flowStateService.stateId) !== null && _a !== void 0 ? _a : '', (_b = this.stateId) !== null && _b !== void 0 ? _b : '')
|
@@ -2131,16 +2145,15 @@ class ConfigurationStateService {
|
|
2131
2145
|
}
|
2132
2146
|
else {
|
2133
2147
|
if (!flow) {
|
2134
|
-
|
2148
|
+
const quoteDraft = this.quoteDraftService.quoteDraft;
|
2149
|
+
if (!quoteDraft) {
|
2135
2150
|
return of({ quoteId: '' });
|
2136
2151
|
}
|
2137
2152
|
const rootLineItem = this.configurationService.getSnapshot();
|
2138
2153
|
const asset = this.configurationService.getAsset();
|
2139
2154
|
const currentState = rootLineItem ? [rootLineItem] : [];
|
2140
2155
|
const initialState = asset ? [asset] : [];
|
2141
|
-
return this.quoteApiService
|
2142
|
-
.getQuoteState(quoteId)
|
2143
|
-
.pipe(switchMap(quoteDraft => this.quoteApiService.upsertQuote(Object.assign(Object.assign({}, quoteDraft), { currentState, initialState }))));
|
2156
|
+
return this.quoteApiService.upsertQuote(Object.assign(Object.assign({}, quoteDraft), { currentState, initialState }));
|
2144
2157
|
}
|
2145
2158
|
else {
|
2146
2159
|
const quoteDraft = this.quoteDraftService.quoteDraft;
|
@@ -2220,6 +2233,7 @@ class ConfigurationStateService {
|
|
2220
2233
|
return this.configurationService.configure().pipe(map$1(() => undefined));
|
2221
2234
|
}
|
2222
2235
|
executeStateless$(request) {
|
2236
|
+
this.executionInProgress$.next(true);
|
2223
2237
|
return of(undefined).pipe(switchMap(() => {
|
2224
2238
|
var _a;
|
2225
2239
|
// Apply actions and execute configuration/price call
|
@@ -2257,7 +2271,8 @@ class ConfigurationStateService {
|
|
2257
2271
|
return result;
|
2258
2272
|
}, { stateId: '', selectors: {} });
|
2259
2273
|
return selectorsResult;
|
2260
|
-
}), catchError(error => {
|
2274
|
+
}), tap$1(() => this.executionInProgress$.next(false)), catchError(error => {
|
2275
|
+
this.executionInProgress$.next(false);
|
2261
2276
|
if (!this.configurationRuntimeService.uiDefinitionProperties.suppressToastMessages) {
|
2262
2277
|
this.toastService.add({ severity: ToastType.error, summary: String(error) });
|
2263
2278
|
}
|
@@ -2277,15 +2292,15 @@ class ConfigurationStateService {
|
|
2277
2292
|
.filter(isDefined)
|
2278
2293
|
.reduce((acc, selectorsMap) => Object.assign(acc, selectorsMap), {}),
|
2279
2294
|
};
|
2280
|
-
this.
|
2295
|
+
this.executionInProgress$.next(true);
|
2281
2296
|
return this.flowStateApiService.executeConfiguration(this.flowStateService.stateId, this.stateId, request);
|
2282
|
-
}), tap$1(({ stateId }) => (this.stateId = stateId)), share(), tap$1(() => this.
|
2283
|
-
this.
|
2297
|
+
}), tap$1(({ stateId }) => (this.stateId = stateId)), share(), tap$1(() => this.executionInProgress$.next(false)), catchError(e => {
|
2298
|
+
this.executionInProgress$.next(false);
|
2284
2299
|
return throwError(() => e);
|
2285
2300
|
}));
|
2286
2301
|
}
|
2287
2302
|
executeStateful$(request) {
|
2288
|
-
return this.
|
2303
|
+
return this.executionInProgress$.pipe(filter$1(inProgress => !inProgress), take$1(1), switchMap(() =>
|
2289
2304
|
// make sure stream switches to statefulExecutionRequest$ before pushing an execution request
|
2290
2305
|
combineLatest([
|
2291
2306
|
this.statefulExecutionRequest$,
|