@veloceapps/sdk 9.0.0-9 → 10.0.0-0
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 +5 -3
- package/core/services/flow-info.service.d.ts +1 -1
- package/core/services/quote-draft.service.d.ts +3 -1
- package/esm2020/cms/components/preview/preview.component.mjs +3 -4
- package/esm2020/core/modules/configuration/services/configuration-state.service.mjs +67 -37
- package/esm2020/core/modules/configuration/services/configuration.service.mjs +8 -3
- package/esm2020/core/services/flow-info.service.mjs +6 -8
- package/esm2020/core/services/quote-draft.service.mjs +13 -8
- package/esm2020/src/flow.component.mjs +4 -1
- package/esm2020/src/guards/flow.guard.mjs +2 -3
- package/esm2020/src/pages/product/product.component.mjs +2 -2
- package/fesm2015/veloceapps-sdk-cms.mjs +2 -4
- package/fesm2015/veloceapps-sdk-cms.mjs.map +1 -1
- package/fesm2015/veloceapps-sdk-core.mjs +97 -54
- package/fesm2015/veloceapps-sdk-core.mjs.map +1 -1
- package/fesm2015/veloceapps-sdk.mjs +6 -3
- package/fesm2015/veloceapps-sdk.mjs.map +1 -1
- package/fesm2020/veloceapps-sdk-cms.mjs +2 -3
- package/fesm2020/veloceapps-sdk-cms.mjs.map +1 -1
- package/fesm2020/veloceapps-sdk-core.mjs +89 -52
- package/fesm2020/veloceapps-sdk-core.mjs.map +1 -1
- package/fesm2020/veloceapps-sdk.mjs +5 -3
- package/fesm2020/veloceapps-sdk.mjs.map +1 -1
- package/package.json +4 -4
- package/src/flow.component.d.ts +3 -1
@@ -1,11 +1,11 @@
|
|
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, 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';
|
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, extractErrorDetails, 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
|
-
import { BehaviorSubject, switchMap, map as map$1, tap as tap$1, noop, catchError, throwError,
|
6
|
+
import { BehaviorSubject, switchMap, map as map$1, tap as tap$1, noop, catchError, throwError, forkJoin, of, zip, combineLatest, Subject, filter as filter$1, shareReplay as shareReplay$1, finalize, takeUntil, buffer, debounceTime, share, take as take$1, distinctUntilChanged } from 'rxjs';
|
7
7
|
import { map, filter, tap, switchMap as switchMap$1, skip, take, shareReplay, catchError as catchError$1, finalize as finalize$1, first } from 'rxjs/operators';
|
8
|
-
import { merge,
|
8
|
+
import { merge, isEqual, cloneDeep, assign, flatten, entries, sortBy, map as map$2, uniqBy, omit, transform } from 'lodash';
|
9
9
|
import * as i6 from '@veloceapps/components';
|
10
10
|
import { ToastType, ConfirmationComponent, ConfirmationDialogModule } from '@veloceapps/components';
|
11
11
|
import { HttpErrorResponse } from '@angular/common/http';
|
@@ -217,9 +217,11 @@ class FlowInfoService {
|
|
217
217
|
this.flowSubj$ = new BehaviorSubject(null);
|
218
218
|
this.flow$ = this.flowSubj$.asObservable();
|
219
219
|
}
|
220
|
-
init$(flowId,
|
221
|
-
this.
|
222
|
-
|
220
|
+
init$(flowId, routeQueryParams) {
|
221
|
+
return this.flowsApiService.getFlow(flowId).pipe(switchMap(flow => this.initFlowTemplates$(flow).pipe(map$1(() => flow))), tap$1(flow => {
|
222
|
+
this.params = { ...routeQueryParams, ...flow.properties.queryParams };
|
223
|
+
this.flowSubj$.next(flow);
|
224
|
+
}), map$1(noop), catchError(e => {
|
223
225
|
this.flowSubj$.next(null);
|
224
226
|
return throwError(() => e);
|
225
227
|
}));
|
@@ -230,9 +232,6 @@ class FlowInfoService {
|
|
230
232
|
this.templates = {};
|
231
233
|
}
|
232
234
|
initFlowTemplates$(flow) {
|
233
|
-
if (isEmpty(flow.properties.templates)) {
|
234
|
-
return of(undefined);
|
235
|
-
}
|
236
235
|
return forkJoin([
|
237
236
|
this.templatesApiService.fetchTemplates$(),
|
238
237
|
this.customizationService?.getTemplates?.() ?? of([]),
|
@@ -320,8 +319,9 @@ class QuoteDraftService {
|
|
320
319
|
get assetsState() {
|
321
320
|
return this.assetsSubj$.value;
|
322
321
|
}
|
323
|
-
constructor(context, accountApiService, quoteApiService) {
|
322
|
+
constructor(context, flowInfoService, accountApiService, quoteApiService) {
|
324
323
|
this.context = context;
|
324
|
+
this.flowInfoService = flowInfoService;
|
325
325
|
this.accountApiService = accountApiService;
|
326
326
|
this.quoteApiService = quoteApiService;
|
327
327
|
this.quoteSubj$ = new BehaviorSubject(null);
|
@@ -346,7 +346,9 @@ class QuoteDraftService {
|
|
346
346
|
const ctx = this.context.resolve();
|
347
347
|
const isAccountMode = this.context.mode === ConfigurationContextMode.ACCOUNT;
|
348
348
|
const accountId = isAccountMode ? headerId : ctx.properties.AccountId;
|
349
|
-
return zip(accountId ? this.accountApiService.getAssetsState(accountId, params) : of(null), isAccountMode
|
349
|
+
return zip(accountId ? this.accountApiService.getAssetsState(accountId, params) : of(null), isAccountMode
|
350
|
+
? of(QuoteDraft.emptyQuote(ConfigurationContextMode.ACCOUNT))
|
351
|
+
: this.quoteApiService.getQuoteState(headerId, params)).pipe(tap(([assets, quote]) => {
|
350
352
|
if (assets) {
|
351
353
|
this.assetsSubj$.next(assets);
|
352
354
|
}
|
@@ -425,10 +427,10 @@ class QuoteDraftService {
|
|
425
427
|
return this.quoteDraft?.currentState ?? [];
|
426
428
|
}
|
427
429
|
get isStandalone() {
|
428
|
-
return this.
|
430
|
+
return this.flowInfoService.flow?.properties.standalone ?? false;
|
429
431
|
}
|
430
432
|
get isStandalone$() {
|
431
|
-
return this.
|
433
|
+
return this.flowInfoService.flow$.pipe(map(() => this.isStandalone));
|
432
434
|
}
|
433
435
|
getInitialCurrentState() {
|
434
436
|
return this.initialCurrentState;
|
@@ -455,11 +457,11 @@ class QuoteDraftService {
|
|
455
457
|
}
|
456
458
|
}
|
457
459
|
}
|
458
|
-
QuoteDraftService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: QuoteDraftService, deps: [{ token: ContextService }, { token: i1.AccountApiService }, { token: i1.QuoteApiService }], target: i0.ɵɵFactoryTarget.Injectable });
|
460
|
+
QuoteDraftService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: QuoteDraftService, deps: [{ token: ContextService }, { token: FlowInfoService }, { token: i1.AccountApiService }, { token: i1.QuoteApiService }], target: i0.ɵɵFactoryTarget.Injectable });
|
459
461
|
QuoteDraftService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: QuoteDraftService });
|
460
462
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: QuoteDraftService, decorators: [{
|
461
463
|
type: Injectable
|
462
|
-
}], ctorParameters: function () { return [{ type: ContextService }, { type: i1.AccountApiService }, { type: i1.QuoteApiService }]; } });
|
464
|
+
}], ctorParameters: function () { return [{ type: ContextService }, { type: FlowInfoService }, { type: i1.AccountApiService }, { type: i1.QuoteApiService }]; } });
|
463
465
|
|
464
466
|
class FlowStateService {
|
465
467
|
constructor(contextService, quoteDraftService, flowInfoService, flowConfiguration, processorsApiService, flowStateApiService, quoteApiService, toastService, customizationService) {
|
@@ -1426,7 +1428,12 @@ class ConfigurationService {
|
|
1426
1428
|
this.showInactiveProductsConfirmation();
|
1427
1429
|
}
|
1428
1430
|
this.configurableRamp = result.lineItem;
|
1429
|
-
}), map(({ lineItem }) => lineItem), catchError$1(error => throwError(() =>
|
1431
|
+
}), map(({ lineItem }) => lineItem), catchError$1(error => throwError(() => {
|
1432
|
+
if (error.error) {
|
1433
|
+
return extractErrorDetails(error.error).join('. ');
|
1434
|
+
}
|
1435
|
+
return error.message || JSON.stringify(error);
|
1436
|
+
})), finalize$1(() => this.isLoadingSubj$.next(false)));
|
1430
1437
|
}
|
1431
1438
|
configureExternal$(props) {
|
1432
1439
|
return this.runtimeService
|
@@ -2092,68 +2099,57 @@ class ConfigurationStateService {
|
|
2092
2099
|
this.executedFunctions = {};
|
2093
2100
|
this.configurationService.reset();
|
2094
2101
|
}
|
2095
|
-
execute$(
|
2096
|
-
const
|
2097
|
-
|
2098
|
-
|
2099
|
-
|
2100
|
-
|
2101
|
-
|
2102
|
-
|
2103
|
-
|
2104
|
-
|
2105
|
-
|
2106
|
-
|
2107
|
-
execution$ = this.executeStateless$(fullRequest);
|
2108
|
-
}
|
2109
|
-
return execution$.pipe(tap$1(result => this.handleSelectorsResponse(result.selectors)));
|
2110
|
-
}
|
2111
|
-
handleSelectorsResponse(selectors) {
|
2112
|
-
Object.entries(selectors).forEach(([requestId, selectorResult]) => {
|
2113
|
-
if (!selectorResult.success) {
|
2114
|
-
this.toastService.add({ severity: ToastType.error, summary: selectorResult.errorMessage });
|
2115
|
-
}
|
2116
|
-
const subscription$ = this.subscriptions[requestId]?.data$;
|
2117
|
-
if (subscription$) {
|
2118
|
-
subscription$.next(selectorResult);
|
2119
|
-
}
|
2120
|
-
});
|
2102
|
+
execute$(exec) {
|
2103
|
+
const request = this.execToRequest(exec);
|
2104
|
+
return this.executeRequest$(request).pipe(map$1(result => {
|
2105
|
+
// Keep only requested results
|
2106
|
+
const actualSelectors = Object.entries(result.selectors).reduce((trunk, [requestId, result]) => {
|
2107
|
+
if (exec.selectors?.[requestId]) {
|
2108
|
+
trunk[requestId] = result;
|
2109
|
+
}
|
2110
|
+
return trunk;
|
2111
|
+
}, {});
|
2112
|
+
return actualSelectors;
|
2113
|
+
}));
|
2121
2114
|
}
|
2122
2115
|
dispatch$(actionName, inputData = {}) {
|
2123
|
-
|
2116
|
+
const exec = {
|
2117
|
+
actions: [{ name: actionName, inputData }],
|
2118
|
+
};
|
2119
|
+
const request = this.execToRequest(exec);
|
2120
|
+
return this.executeRequest$(request);
|
2124
2121
|
}
|
2125
2122
|
select$(selectorName, inputData = {}) {
|
2126
2123
|
const requestId = UUID.UUID();
|
2127
|
-
|
2124
|
+
const request = this.execToRequest({
|
2128
2125
|
selectors: {
|
2129
2126
|
[requestId]: {
|
2130
|
-
|
2127
|
+
name: selectorName,
|
2131
2128
|
inputData,
|
2132
|
-
ownerId: this.ownerId,
|
2133
2129
|
},
|
2134
2130
|
},
|
2135
|
-
})
|
2131
|
+
});
|
2132
|
+
return this.executeRequest$(request).pipe(map$1(response => response.selectors[requestId]));
|
2136
2133
|
}
|
2137
2134
|
subscribe$(selectorName, inputData = {}, options) {
|
2138
2135
|
const requestId = UUID.UUID();
|
2139
2136
|
let subscription = this.subscriptions[requestId];
|
2140
2137
|
if (!subscription) {
|
2141
|
-
const request = {
|
2138
|
+
const request = this.execToRequest({
|
2142
2139
|
selectors: {
|
2143
2140
|
[requestId]: {
|
2144
|
-
|
2141
|
+
name: selectorName,
|
2145
2142
|
inputData,
|
2146
|
-
ownerId: this.ownerId,
|
2147
2143
|
},
|
2148
2144
|
},
|
2149
|
-
};
|
2145
|
+
});
|
2150
2146
|
subscription = {
|
2151
2147
|
request,
|
2152
2148
|
data$: new BehaviorSubject(this.NOT_INITIALIZED),
|
2153
2149
|
};
|
2154
2150
|
this.subscriptions[requestId] = subscription;
|
2155
2151
|
if (!options?.cold) {
|
2156
|
-
this.
|
2152
|
+
this.executeRequest$(request).subscribe();
|
2157
2153
|
}
|
2158
2154
|
}
|
2159
2155
|
return subscription.data$.pipe(filter$1(data => data != this.NOT_INITIALIZED), map$1(data => data), distinctUntilChanged(), finalize(() => {
|
@@ -2255,6 +2251,47 @@ class ConfigurationStateService {
|
|
2255
2251
|
initStateless$() {
|
2256
2252
|
return this.configurationService.configure().pipe(map$1(() => undefined));
|
2257
2253
|
}
|
2254
|
+
execToRequest(exec) {
|
2255
|
+
return {
|
2256
|
+
actions: exec.actions?.map(action => ({
|
2257
|
+
apiName: action.name,
|
2258
|
+
ownerId: this.ownerId,
|
2259
|
+
inputData: action.inputData ?? {},
|
2260
|
+
})),
|
2261
|
+
selectors: exec.selectors &&
|
2262
|
+
Object.entries(exec.selectors).reduce((trunk, [key, selector]) => ({
|
2263
|
+
...trunk,
|
2264
|
+
[key]: { apiName: selector.name, ownerId: this.ownerId, inputData: selector.inputData ?? {} },
|
2265
|
+
}), {}),
|
2266
|
+
};
|
2267
|
+
}
|
2268
|
+
handleSelectorsResponse(selectors) {
|
2269
|
+
Object.entries(selectors).forEach(([requestId, selectorResult]) => {
|
2270
|
+
if (!selectorResult.success) {
|
2271
|
+
this.toastService.add({ severity: ToastType.error, summary: selectorResult.errorMessage });
|
2272
|
+
}
|
2273
|
+
const subscription$ = this.subscriptions[requestId]?.data$;
|
2274
|
+
if (subscription$) {
|
2275
|
+
subscription$.next(selectorResult);
|
2276
|
+
}
|
2277
|
+
});
|
2278
|
+
}
|
2279
|
+
executeRequest$(req, forceSubscriptions) {
|
2280
|
+
const fullRequest = cloneDeep(req);
|
2281
|
+
if (fullRequest.actions?.length || forceSubscriptions) {
|
2282
|
+
for (const subscription of Object.values(this.subscriptions)) {
|
2283
|
+
fullRequest.selectors = assign(fullRequest.selectors, subscription.request.selectors);
|
2284
|
+
}
|
2285
|
+
}
|
2286
|
+
let execution$;
|
2287
|
+
if (this.isStatefulConfiguration) {
|
2288
|
+
execution$ = this.executeStateful$(fullRequest);
|
2289
|
+
}
|
2290
|
+
else {
|
2291
|
+
execution$ = this.executeStateless$(fullRequest);
|
2292
|
+
}
|
2293
|
+
return execution$.pipe(tap$1(result => this.handleSelectorsResponse(result.selectors)));
|
2294
|
+
}
|
2258
2295
|
executeStateless$(request) {
|
2259
2296
|
this.executionInProgress$.next(true);
|
2260
2297
|
return of(undefined).pipe(switchMap(() => {
|