@veloceapps/sdk 10.0.0-35 → 10.0.0-37
Sign up to get free protection for your applications and to get access to all the features.
- package/core/services/context.service.d.ts +3 -1
- package/core/services/flow-info.service.d.ts +4 -2
- package/core/services/quote-draft.service.d.ts +3 -1
- package/core/services/runtime-settings.service.d.ts +1 -1
- package/esm2020/core/modules/configuration/services/configuration.service.mjs +2 -2
- package/esm2020/core/services/context.service.mjs +15 -6
- package/esm2020/core/services/flow-info.service.mjs +18 -6
- package/esm2020/core/services/flow-state.service.mjs +15 -2
- package/esm2020/core/services/quote-draft.service.mjs +21 -9
- package/esm2020/core/services/runtime-settings.service.mjs +3 -3
- package/esm2020/src/guards/context.guard.mjs +4 -6
- package/esm2020/src/guards/flow.guard.mjs +5 -4
- package/fesm2015/veloceapps-sdk-core.mjs +268 -227
- package/fesm2015/veloceapps-sdk-core.mjs.map +1 -1
- package/fesm2015/veloceapps-sdk.mjs +6 -7
- package/fesm2015/veloceapps-sdk.mjs.map +1 -1
- package/fesm2020/veloceapps-sdk-core.mjs +265 -225
- package/fesm2020/veloceapps-sdk-core.mjs.map +1 -1
- package/fesm2020/veloceapps-sdk.mjs +6 -7
- package/fesm2020/veloceapps-sdk.mjs.map +1 -1
- package/package.json +1 -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,
|
3
|
+
import { UUID, ConfigurationContextMode, 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, ConfigurationContext, UITemplateType, QuoteDraft, isDefined, ConfigurationProcessorTypes, EntityUtil, 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,
|
7
|
-
import { map, filter, tap
|
8
|
-
import { merge, isEqual, cloneDeep, assign, flatten, entries, sortBy, map as map$2,
|
6
|
+
import { BehaviorSubject, map, tap, of, noop, catchError, throwError, forkJoin, zip, combineLatest, Subject, filter as filter$1, switchMap as switchMap$1, shareReplay as shareReplay$1, finalize, takeUntil, buffer, debounceTime, share, take as take$1, distinctUntilChanged } from 'rxjs';
|
7
|
+
import { map as map$1, filter, tap as tap$1, switchMap, skip, take, shareReplay, catchError as catchError$1, finalize as finalize$1, first } from 'rxjs/operators';
|
8
|
+
import { uniqBy, merge, isEqual, cloneDeep, assign, flatten, entries, sortBy, map as map$2, 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';
|
@@ -88,22 +88,128 @@ const generateConfigurationLineItem = (props, qty = 1) => {
|
|
88
88
|
};
|
89
89
|
};
|
90
90
|
|
91
|
+
class RuntimeSettingsService {
|
92
|
+
constructor(configurationSettingsApiService) {
|
93
|
+
this.configurationSettingsApiService = configurationSettingsApiService;
|
94
|
+
this.configurationSettings$ = new BehaviorSubject({});
|
95
|
+
this.currencySettings$ = new BehaviorSubject({
|
96
|
+
iso: DEFAULT_CURRENCY_ISO_CODE,
|
97
|
+
symbol: DEFAULT_CURRENCY_SYMBOL,
|
98
|
+
});
|
99
|
+
this.shoppingCartSettings$ = new BehaviorSubject([]);
|
100
|
+
this.getCurrencySymbol = (locale, currency) => {
|
101
|
+
return (0)
|
102
|
+
.toLocaleString(locale, { style: 'currency', currency, minimumFractionDigits: 0, maximumFractionDigits: 0 })
|
103
|
+
.replace(/\d/g, '')
|
104
|
+
.trim();
|
105
|
+
};
|
106
|
+
}
|
107
|
+
create() {
|
108
|
+
return this.configurationSettingsApiService.fetchSettings().pipe(map(settings => this.parseConfigurationSettings(settings)), tap(configurationSettings => {
|
109
|
+
this.configurationSettings$.next(configurationSettings);
|
110
|
+
this.addShoppingCartSettings(configurationSettings['shopping-cart'] ?? []);
|
111
|
+
this.formattingSettings = this.getFormattingSettings();
|
112
|
+
}), map(() => undefined));
|
113
|
+
}
|
114
|
+
initCurrency(iso) {
|
115
|
+
if (iso) {
|
116
|
+
const symbol = this.getCurrencySymbol('en-US', iso);
|
117
|
+
this.currencySettings$.next({ iso, symbol });
|
118
|
+
if (this.formattingSettings) {
|
119
|
+
this.formattingSettings.currencySymbol = symbol;
|
120
|
+
}
|
121
|
+
}
|
122
|
+
}
|
123
|
+
getFormattingSettings() {
|
124
|
+
if (this.formattingSettings) {
|
125
|
+
return this.formattingSettings;
|
126
|
+
}
|
127
|
+
const shoppingCartSettings = this.configurationSettings['shopping-cart']?.reduce((acc, setting) => {
|
128
|
+
return { ...acc, [setting.id]: setting.properties };
|
129
|
+
}, {});
|
130
|
+
const currencySettings = this.getCurrencySettings();
|
131
|
+
const dateFormat = (validateDateFormat(shoppingCartSettings?.DATE_FORMAT ?? '') && shoppingCartSettings?.DATE_FORMAT) ||
|
132
|
+
DEFAULT_DATE_FORMAT;
|
133
|
+
const decimalSeparator = shoppingCartSettings?.DECIMAL_SEPARATOR;
|
134
|
+
const thousandsSeparator = shoppingCartSettings?.THOUSANDS_SEPARATOR;
|
135
|
+
// the number of decimal places can be 0
|
136
|
+
const priceScale = shoppingCartSettings?.PRICE_SCALE;
|
137
|
+
const decimalsCount = priceScale !== null && priceScale !== '' && !isNaN(Number(priceScale)) && Number(priceScale) >= 0
|
138
|
+
? Number(priceScale)
|
139
|
+
: DEFAULT_DECIMALS_COUNT;
|
140
|
+
const actionCodeSettings = shoppingCartSettings?.STATUS_LABEL;
|
141
|
+
return {
|
142
|
+
currencySymbol: currencySettings.symbol,
|
143
|
+
dateFormats: getSupportedDateFormats(dateFormat),
|
144
|
+
decimalsCount,
|
145
|
+
decimalSeparator: decimalSeparator !== undefined && ['.', ','].includes(decimalSeparator)
|
146
|
+
? decimalSeparator
|
147
|
+
: DEFAULT_DECIMAL_SEPARATOR,
|
148
|
+
// thousands separator can be a blank value, so it can also be null
|
149
|
+
thousandsSeparator: thousandsSeparator !== undefined && ['.', ',', '', null].includes(thousandsSeparator)
|
150
|
+
? thousandsSeparator || ''
|
151
|
+
: DEFAULT_THOUSANDS_SEPARATOR,
|
152
|
+
actionCodeLabels: actionCodeSettings?.length
|
153
|
+
? actionCodeSettings.reduce((result, setting) => ({ ...result, [setting.status_label]: setting.custom_label }), {})
|
154
|
+
: DEFAULT_ACTION_CODE_LABELS,
|
155
|
+
};
|
156
|
+
}
|
157
|
+
get configurationSettings() {
|
158
|
+
return this.configurationSettings$.value;
|
159
|
+
}
|
160
|
+
getShoppingCartSettings() {
|
161
|
+
return this.shoppingCartSettings$.value;
|
162
|
+
}
|
163
|
+
getCurrencySettings() {
|
164
|
+
return this.currencySettings$.value;
|
165
|
+
}
|
166
|
+
parseConfigurationSettings(settings) {
|
167
|
+
return settings.reduce((acc, setting) => {
|
168
|
+
switch (setting.key) {
|
169
|
+
case 'shopping-cart':
|
170
|
+
acc['shopping-cart'] = parseJsonSafely(setting.value, []);
|
171
|
+
break;
|
172
|
+
case 'navigation':
|
173
|
+
acc.navigation = parseJsonSafely(setting.value, {});
|
174
|
+
break;
|
175
|
+
case 'flows':
|
176
|
+
acc.flows = parseJsonSafely(setting.value, []);
|
177
|
+
break;
|
178
|
+
default:
|
179
|
+
acc[setting.key] = setting.value;
|
180
|
+
}
|
181
|
+
return acc;
|
182
|
+
}, {});
|
183
|
+
}
|
184
|
+
addShoppingCartSettings(settings) {
|
185
|
+
// uniqBy removes items with the biggest index
|
186
|
+
const newSettings = uniqBy([...settings, ...this.shoppingCartSettings$.value], 'id');
|
187
|
+
this.shoppingCartSettings$.next(newSettings);
|
188
|
+
}
|
189
|
+
}
|
190
|
+
RuntimeSettingsService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: RuntimeSettingsService, deps: [{ token: i1.ConfigurationSettingsApiService }], target: i0.ɵɵFactoryTarget.Injectable });
|
191
|
+
RuntimeSettingsService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: RuntimeSettingsService });
|
192
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: RuntimeSettingsService, decorators: [{
|
193
|
+
type: Injectable
|
194
|
+
}], ctorParameters: function () { return [{ type: i1.ConfigurationSettingsApiService }]; } });
|
195
|
+
|
91
196
|
class ContextService {
|
92
|
-
constructor(contextApiService) {
|
197
|
+
constructor(contextApiService, runtimeSettingsService) {
|
93
198
|
this.contextApiService = contextApiService;
|
199
|
+
this.runtimeSettingsService = runtimeSettingsService;
|
94
200
|
this.context = new BehaviorSubject(null);
|
95
201
|
}
|
96
202
|
get isInitialized() {
|
97
203
|
return Boolean(this.context.value);
|
98
204
|
}
|
99
205
|
get isInitialized$() {
|
100
|
-
return this.context.pipe(map(Boolean));
|
206
|
+
return this.context.pipe(map$1(Boolean));
|
101
207
|
}
|
102
208
|
get mode() {
|
103
209
|
return this.resolve().properties['#mode'];
|
104
210
|
}
|
105
211
|
get isEditMode$() {
|
106
|
-
return this.resolve$().pipe(map(() => this.isEditMode));
|
212
|
+
return this.resolve$().pipe(map$1(() => this.isEditMode));
|
107
213
|
}
|
108
214
|
get isEditMode() {
|
109
215
|
const context = this.resolve();
|
@@ -125,10 +231,16 @@ class ContextService {
|
|
125
231
|
return this.context.pipe(filter((ctx) => Boolean(ctx)));
|
126
232
|
}
|
127
233
|
create(headerId, mode) {
|
128
|
-
|
234
|
+
const configurationSettings = this.runtimeSettingsService.configurationSettings;
|
235
|
+
const skipContextRequest = configurationSettings['SKIP_CONTEXT_REQUEST'] === 'true';
|
236
|
+
let contextRequest$ = this.contextApiService.getContext(headerId, mode);
|
237
|
+
if (skipContextRequest) {
|
238
|
+
contextRequest$ = of({});
|
239
|
+
}
|
240
|
+
return contextRequest$.pipe(tap$1(context => this.context.next(merge(new ConfigurationContext(headerId, mode), context))), map$1(() => this.resolve()));
|
129
241
|
}
|
130
242
|
initTestMode() {
|
131
|
-
return this.create('TestId', ConfigurationContextMode.TEST).pipe(map(context => {
|
243
|
+
return this.create('TestId', ConfigurationContextMode.TEST).pipe(map$1(context => {
|
132
244
|
return this.update({
|
133
245
|
properties: {
|
134
246
|
...context.properties,
|
@@ -165,11 +277,11 @@ class ContextService {
|
|
165
277
|
this.context.next(null);
|
166
278
|
}
|
167
279
|
}
|
168
|
-
ContextService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: ContextService, deps: [{ token: i1.ContextApiService }], target: i0.ɵɵFactoryTarget.Injectable });
|
280
|
+
ContextService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: ContextService, deps: [{ token: i1.ContextApiService }, { token: RuntimeSettingsService }], target: i0.ɵɵFactoryTarget.Injectable });
|
169
281
|
ContextService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: ContextService });
|
170
282
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: ContextService, decorators: [{
|
171
283
|
type: Injectable
|
172
|
-
}], ctorParameters: function () { return [{ type: i1.ContextApiService }]; } });
|
284
|
+
}], ctorParameters: function () { return [{ type: i1.ContextApiService }, { type: RuntimeSettingsService }]; } });
|
173
285
|
|
174
286
|
const FLOW_CUSTOMIZATION = new InjectionToken('FLOW_CUSTOMIZATION');
|
175
287
|
|
@@ -206,9 +318,10 @@ class FlowInfoService {
|
|
206
318
|
get isStateful() {
|
207
319
|
return !!this.flow?.properties.stateful;
|
208
320
|
}
|
209
|
-
constructor(flowsApiService, templatesApiService, customizationService) {
|
321
|
+
constructor(flowsApiService, templatesApiService, runtimeSettingsService, customizationService) {
|
210
322
|
this.flowsApiService = flowsApiService;
|
211
323
|
this.templatesApiService = templatesApiService;
|
324
|
+
this.runtimeSettingsService = runtimeSettingsService;
|
212
325
|
this.customizationService = customizationService;
|
213
326
|
this.templates = {};
|
214
327
|
this.defaultTemplates = {
|
@@ -218,10 +331,19 @@ class FlowInfoService {
|
|
218
331
|
this.flow$ = this.flowSubj$.asObservable();
|
219
332
|
}
|
220
333
|
init$(flowId, routeQueryParams) {
|
221
|
-
|
334
|
+
const flows = this.runtimeSettingsService.configurationSettings['flows'];
|
335
|
+
const flow = flows?.find(({ id }) => id === flowId);
|
336
|
+
if (!flow) {
|
337
|
+
return of(undefined);
|
338
|
+
}
|
339
|
+
let flowTemplates$ = of(undefined);
|
340
|
+
if (!this.isLegacy) {
|
341
|
+
flowTemplates$ = this.initFlowTemplates$(flow).pipe(map(() => undefined));
|
342
|
+
}
|
343
|
+
return flowTemplates$.pipe(tap(() => {
|
222
344
|
this.params = { ...routeQueryParams, ...flow.properties.queryParams };
|
223
345
|
this.flowSubj$.next(flow);
|
224
|
-
}), map
|
346
|
+
}), map(noop), catchError(e => {
|
225
347
|
this.flowSubj$.next(null);
|
226
348
|
return throwError(() => e);
|
227
349
|
}));
|
@@ -235,7 +357,7 @@ class FlowInfoService {
|
|
235
357
|
return forkJoin([
|
236
358
|
this.templatesApiService.fetchTemplates$(),
|
237
359
|
this.customizationService?.getTemplates?.() ?? of([]),
|
238
|
-
]).pipe(map
|
360
|
+
]).pipe(map(([templates, localTemplates]) => {
|
239
361
|
Object.entries({ ...this.defaultTemplates, ...flow.properties.templates }).forEach(([key, name]) => {
|
240
362
|
const type = this.remapTemplateName(key);
|
241
363
|
if (type) {
|
@@ -272,11 +394,11 @@ class FlowInfoService {
|
|
272
394
|
return undefined;
|
273
395
|
}
|
274
396
|
}
|
275
|
-
FlowInfoService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: FlowInfoService, deps: [{ token: i1.FlowsApiService }, { token: i1.UITemplatesApiService }, { token: FLOW_CUSTOMIZATION, optional: true }], target: i0.ɵɵFactoryTarget.Injectable });
|
397
|
+
FlowInfoService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: FlowInfoService, deps: [{ token: i1.FlowsApiService }, { token: i1.UITemplatesApiService }, { token: RuntimeSettingsService }, { token: FLOW_CUSTOMIZATION, optional: true }], target: i0.ɵɵFactoryTarget.Injectable });
|
276
398
|
FlowInfoService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: FlowInfoService });
|
277
399
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: FlowInfoService, decorators: [{
|
278
400
|
type: Injectable
|
279
|
-
}], ctorParameters: function () { return [{ type: i1.FlowsApiService }, { type: i1.UITemplatesApiService }, { type: undefined, decorators: [{
|
401
|
+
}], ctorParameters: function () { return [{ type: i1.FlowsApiService }, { type: i1.UITemplatesApiService }, { type: RuntimeSettingsService }, { type: undefined, decorators: [{
|
280
402
|
type: Optional
|
281
403
|
}, {
|
282
404
|
type: Inject,
|
@@ -305,13 +427,13 @@ class QuoteDraftService {
|
|
305
427
|
}
|
306
428
|
}
|
307
429
|
get hasProducts$() {
|
308
|
-
return this.quoteSubj$.pipe(map(() => this.hasProducts));
|
430
|
+
return this.quoteSubj$.pipe(map$1(() => this.hasProducts));
|
309
431
|
}
|
310
432
|
get hasProducts() {
|
311
433
|
return Boolean(this.quoteSubj$.value?.currentState.length);
|
312
434
|
}
|
313
435
|
get hasAssets$() {
|
314
|
-
return this.assetsSubj$.pipe(map(() => this.hasAssets));
|
436
|
+
return this.assetsSubj$.pipe(map$1(() => this.hasAssets));
|
315
437
|
}
|
316
438
|
get hasAssets() {
|
317
439
|
return Boolean(this.assetsSubj$.value?.currentState.length);
|
@@ -319,11 +441,12 @@ class QuoteDraftService {
|
|
319
441
|
get assetsState() {
|
320
442
|
return this.assetsSubj$.value;
|
321
443
|
}
|
322
|
-
constructor(context, flowInfoService, accountApiService, quoteApiService) {
|
444
|
+
constructor(context, flowInfoService, accountApiService, quoteApiService, runtimeSettingsService) {
|
323
445
|
this.context = context;
|
324
446
|
this.flowInfoService = flowInfoService;
|
325
447
|
this.accountApiService = accountApiService;
|
326
448
|
this.quoteApiService = quoteApiService;
|
449
|
+
this.runtimeSettingsService = runtimeSettingsService;
|
327
450
|
this.quoteSubj$ = new BehaviorSubject(null);
|
328
451
|
this.assetsSubj$ = new BehaviorSubject(null);
|
329
452
|
this.resetSubj$ = new BehaviorSubject(true);
|
@@ -332,7 +455,7 @@ class QuoteDraftService {
|
|
332
455
|
this._hasUnsavedChanges = false;
|
333
456
|
this.reset$ = this.resetSubj$.asObservable();
|
334
457
|
this.isInitializedSubj$
|
335
|
-
.pipe(filter(isInitialized => isInitialized), switchMap
|
458
|
+
.pipe(filter(isInitialized => isInitialized), switchMap(() => this.quoteSubj$.asObservable()), skip(1), tap$1(quote => this.markAsUpdated(quote)))
|
336
459
|
.subscribe();
|
337
460
|
}
|
338
461
|
reset() {
|
@@ -345,21 +468,30 @@ class QuoteDraftService {
|
|
345
468
|
init(headerId, params) {
|
346
469
|
const ctx = this.context.resolve();
|
347
470
|
const isAccountMode = this.context.mode === ConfigurationContextMode.ACCOUNT;
|
348
|
-
const accountId = isAccountMode ? headerId : ctx.properties
|
349
|
-
|
471
|
+
const accountId = isAccountMode ? headerId : ctx.properties?.AccountId;
|
472
|
+
const configurationSettings = this.runtimeSettingsService.configurationSettings;
|
473
|
+
const skipAssetsQuery = configurationSettings['SKIP_ASSETS_QUERY'] === 'true';
|
474
|
+
let assetRequest$ = of(null);
|
475
|
+
if (accountId && !skipAssetsQuery) {
|
476
|
+
assetRequest$ = this.accountApiService.getAssetsState(accountId, params);
|
477
|
+
}
|
478
|
+
return zip(assetRequest$, isAccountMode
|
350
479
|
? of(QuoteDraft.emptyQuote(ConfigurationContextMode.ACCOUNT))
|
351
|
-
: this.quoteApiService.getQuoteState(headerId, params)).pipe(tap(([assets, quote]) => {
|
480
|
+
: this.quoteApiService.getQuoteState(headerId, params)).pipe(tap$1(([assets, quote]) => {
|
352
481
|
if (assets) {
|
353
482
|
this.assetsSubj$.next(assets);
|
354
483
|
}
|
484
|
+
let context;
|
355
485
|
this.quoteSubj$.next(quote);
|
356
486
|
if (assets && isAccountMode) {
|
357
|
-
|
487
|
+
context = assets.context;
|
358
488
|
}
|
359
489
|
else {
|
360
|
-
|
490
|
+
context = quote.context;
|
361
491
|
}
|
362
|
-
|
492
|
+
this.context.update(context);
|
493
|
+
this.runtimeSettingsService.initCurrency(context.properties['CurrencyIsoCode']);
|
494
|
+
}), map$1(() => noop()), take(1));
|
363
495
|
}
|
364
496
|
finalizeInit() {
|
365
497
|
this.isInitialized = true;
|
@@ -408,7 +540,7 @@ class QuoteDraftService {
|
|
408
540
|
this.assetsSubj$.next(assetsState);
|
409
541
|
}
|
410
542
|
get quoteDraft$() {
|
411
|
-
return combineLatest([this.quoteSubj$, this.context.resolve$()]).pipe(map(() => this.quoteDraft), filter((quote) => Boolean(quote)), shareReplay());
|
543
|
+
return combineLatest([this.quoteSubj$, this.context.resolve$()]).pipe(map$1(() => this.quoteDraft), filter((quote) => Boolean(quote)), shareReplay());
|
412
544
|
}
|
413
545
|
get quoteDraft() {
|
414
546
|
const quote = this.quoteSubj$.value;
|
@@ -421,7 +553,7 @@ class QuoteDraftService {
|
|
421
553
|
};
|
422
554
|
}
|
423
555
|
get currentState$() {
|
424
|
-
return this.quoteDraft$.pipe(map(quote => quote.currentState));
|
556
|
+
return this.quoteDraft$.pipe(map$1(quote => quote.currentState));
|
425
557
|
}
|
426
558
|
get currentState() {
|
427
559
|
return this.quoteDraft?.currentState ?? [];
|
@@ -430,13 +562,13 @@ class QuoteDraftService {
|
|
430
562
|
return this.flowInfoService.flow?.properties.standalone ?? false;
|
431
563
|
}
|
432
564
|
get isStandalone$() {
|
433
|
-
return this.flowInfoService.flow$.pipe(map(() => this.isStandalone));
|
565
|
+
return this.flowInfoService.flow$.pipe(map$1(() => this.isStandalone));
|
434
566
|
}
|
435
567
|
getInitialCurrentState() {
|
436
568
|
return this.initialCurrentState;
|
437
569
|
}
|
438
570
|
isEditMode$() {
|
439
|
-
return this.context.resolve$().pipe(map(() => this.isEditMode()));
|
571
|
+
return this.context.resolve$().pipe(map$1(() => this.isEditMode()));
|
440
572
|
}
|
441
573
|
isEditMode() {
|
442
574
|
const context = this.context.resolve();
|
@@ -457,11 +589,11 @@ class QuoteDraftService {
|
|
457
589
|
}
|
458
590
|
}
|
459
591
|
}
|
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 });
|
592
|
+
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 }, { token: RuntimeSettingsService }], target: i0.ɵɵFactoryTarget.Injectable });
|
461
593
|
QuoteDraftService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: QuoteDraftService });
|
462
594
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: QuoteDraftService, decorators: [{
|
463
595
|
type: Injectable
|
464
|
-
}], ctorParameters: function () { return [{ type: ContextService }, { type: FlowInfoService }, { type: i1.AccountApiService }, { type: i1.QuoteApiService }]; } });
|
596
|
+
}], ctorParameters: function () { return [{ type: ContextService }, { type: FlowInfoService }, { type: i1.AccountApiService }, { type: i1.QuoteApiService }, { type: RuntimeSettingsService }]; } });
|
465
597
|
|
466
598
|
class FlowStateService {
|
467
599
|
constructor(contextService, quoteDraftService, flowInfoService, flowConfiguration, processorsApiService, flowStateApiService, quoteApiService, toastService, customizationService) {
|
@@ -492,55 +624,59 @@ class FlowStateService {
|
|
492
624
|
all subscriptions get their updates according to updated QuoteDraft
|
493
625
|
*/
|
494
626
|
this.isInitialized$()
|
495
|
-
.pipe(filter$1(Boolean), filter$1(() => !this.getFlowSafe().properties.stateful), switchMap(() => this.flowConfiguration.updated$), switchMap(() => this.executeRequest$({}, true)))
|
627
|
+
.pipe(filter$1(Boolean), filter$1(() => !this.getFlowSafe().properties.stateful), switchMap$1(() => this.flowConfiguration.updated$), switchMap$1(() => this.executeRequest$({}, true)))
|
496
628
|
.subscribe();
|
497
|
-
this.charges$ = this.flowInfoService.flow$.pipe(filter$1(isDefined), switchMap(() => {
|
629
|
+
this.charges$ = this.flowInfoService.flow$.pipe(filter$1(isDefined), switchMap$1(() => {
|
498
630
|
if (this.flowInfoService.isLegacy) {
|
499
|
-
return this.quoteDraftService.quoteDraft$.pipe(map
|
631
|
+
return this.quoteDraftService.quoteDraft$.pipe(map(quoteDraft => quoteDraft.charges));
|
500
632
|
}
|
501
633
|
else {
|
502
634
|
return this.subscribe$(UITemplateType.FLOW_ENGINE, 'CHARGES', null, {
|
503
635
|
cold: true,
|
504
|
-
}).pipe(map
|
636
|
+
}).pipe(map(response => (response.success ? response.result : {})));
|
505
637
|
}
|
506
638
|
}), shareReplay$1(1));
|
507
639
|
this.charges$.subscribe();
|
508
|
-
this.pricePlans$ = this.flowInfoService.flow$.pipe(filter$1(isDefined), switchMap(() => {
|
640
|
+
this.pricePlans$ = this.flowInfoService.flow$.pipe(filter$1(isDefined), switchMap$1(() => {
|
509
641
|
if (this.flowInfoService.isLegacy) {
|
510
|
-
return this.quoteDraftService.quoteDraft$.pipe(map
|
642
|
+
return this.quoteDraftService.quoteDraft$.pipe(map(quoteDraft => quoteDraft.pricePlans));
|
511
643
|
}
|
512
644
|
else {
|
513
645
|
return this.subscribe$(UITemplateType.FLOW_ENGINE, 'PRICE_PLANS', null, {
|
514
646
|
cold: true,
|
515
|
-
}).pipe(map
|
647
|
+
}).pipe(map(response => (response.success ? response.result : {})));
|
516
648
|
}
|
517
649
|
}), shareReplay$1(1));
|
518
650
|
this.pricePlans$.subscribe();
|
519
|
-
this.activeMetrics$ = this.flowInfoService.flow$.pipe(filter$1(isDefined), switchMap(() => {
|
651
|
+
this.activeMetrics$ = this.flowInfoService.flow$.pipe(filter$1(isDefined), switchMap$1(() => {
|
520
652
|
if (this.flowInfoService.isLegacy) {
|
521
|
-
return this.quoteDraftService.quoteDraft$.pipe(map
|
653
|
+
return this.quoteDraftService.quoteDraft$.pipe(map(quoteDraft => quoteDraft.activeMetrics));
|
522
654
|
}
|
523
655
|
else {
|
524
656
|
return this.subscribe$(UITemplateType.FLOW_ENGINE, 'ACTIVE_METRICS', null, {
|
525
657
|
cold: true,
|
526
|
-
}).pipe(map
|
658
|
+
}).pipe(map(response => (response.success ? response.result : [])));
|
527
659
|
}
|
528
660
|
}), shareReplay$1(1));
|
529
661
|
this.activeMetrics$.subscribe();
|
530
|
-
this.isPriceListLocked$ = this.flowInfoService.flow$.pipe(filter$1(isDefined), switchMap(() => {
|
662
|
+
this.isPriceListLocked$ = this.flowInfoService.flow$.pipe(filter$1(isDefined), switchMap$1(() => {
|
531
663
|
if (this.flowInfoService.isLegacy) {
|
532
664
|
return of(false);
|
533
665
|
}
|
534
666
|
else {
|
535
667
|
return this.subscribe$(UITemplateType.FLOW_ENGINE, 'IS_PRICE_LIST_LOCKED', null, {
|
536
668
|
cold: true,
|
537
|
-
}).pipe(map
|
669
|
+
}).pipe(map(response => (response.success ? response.result : false)));
|
538
670
|
}
|
539
671
|
}), shareReplay$1(1));
|
540
672
|
this.isPriceListLocked$.subscribe();
|
541
673
|
}
|
542
674
|
init$() {
|
543
|
-
|
675
|
+
let processors$ = this.initProcessors$();
|
676
|
+
if (this.flowInfoService.isLegacy) {
|
677
|
+
processors$ = of(undefined);
|
678
|
+
}
|
679
|
+
return processors$.pipe(switchMap$1(() => {
|
544
680
|
if (this.getFlowSafe().properties.stateful) {
|
545
681
|
return this.initStateful$();
|
546
682
|
}
|
@@ -572,14 +708,14 @@ class FlowStateService {
|
|
572
708
|
return this.executionInProgress$.asObservable();
|
573
709
|
}
|
574
710
|
isInitialized$() {
|
575
|
-
return combineLatest([this.stateId$, this.quoteDraftService.isInitialized$]).pipe(map
|
711
|
+
return combineLatest([this.stateId$, this.quoteDraftService.isInitialized$]).pipe(map(values => values.some(Boolean)));
|
576
712
|
}
|
577
713
|
isInitialized() {
|
578
714
|
return Boolean(this.stateId$.value) || this.quoteDraftService.isInitialized;
|
579
715
|
}
|
580
716
|
execute$(scope, exec) {
|
581
717
|
const request = this.execToRequest(scope, exec);
|
582
|
-
return this.executeRequest$(request).pipe(map
|
718
|
+
return this.executeRequest$(request).pipe(map(result => {
|
583
719
|
// Keep only requested results
|
584
720
|
const actualSelectors = Object.entries(result.selectors).reduce((trunk, [requestId, result]) => {
|
585
721
|
if (exec.selectors?.[requestId]) {
|
@@ -591,11 +727,14 @@ class FlowStateService {
|
|
591
727
|
}));
|
592
728
|
}
|
593
729
|
dispatch$(scope, action, inputData) {
|
730
|
+
if (this.flowInfoService.isLegacy) {
|
731
|
+
return of(undefined);
|
732
|
+
}
|
594
733
|
const exec = {
|
595
734
|
actions: [{ name: action, inputData }],
|
596
735
|
};
|
597
736
|
const request = this.execToRequest(scope, exec);
|
598
|
-
return this.executeRequest$(request).pipe(map
|
737
|
+
return this.executeRequest$(request).pipe(map(noop));
|
599
738
|
}
|
600
739
|
select$(scope, selectorName, inputData) {
|
601
740
|
const requestId = this.generateRequestId(scope, selectorName, inputData);
|
@@ -607,9 +746,15 @@ class FlowStateService {
|
|
607
746
|
},
|
608
747
|
},
|
609
748
|
});
|
610
|
-
return this.executeRequest$(request).pipe(map
|
749
|
+
return this.executeRequest$(request).pipe(map(response => response.selectors[requestId]));
|
611
750
|
}
|
612
751
|
subscribe$(scope, selectorName, inputData, options) {
|
752
|
+
if (this.flowInfoService.isLegacy) {
|
753
|
+
return of({
|
754
|
+
success: false,
|
755
|
+
errorMessage: '',
|
756
|
+
});
|
757
|
+
}
|
613
758
|
const requestId = this.generateRequestId(scope, selectorName, inputData);
|
614
759
|
let subscription = this.subscriptions[requestId];
|
615
760
|
if (!subscription) {
|
@@ -633,7 +778,7 @@ class FlowStateService {
|
|
633
778
|
this.executeRequest$(request).subscribe();
|
634
779
|
}
|
635
780
|
}
|
636
|
-
return subscription.data$.pipe(filter$1(data => data != this.NOT_INITIALIZED), map
|
781
|
+
return subscription.data$.pipe(filter$1(data => data != this.NOT_INITIALIZED), map(data => data), finalize(() => {
|
637
782
|
if (!this.subscriptions[requestId]?.data$.observed) {
|
638
783
|
delete this.subscriptions[requestId];
|
639
784
|
}
|
@@ -642,7 +787,7 @@ class FlowStateService {
|
|
642
787
|
save$() {
|
643
788
|
if (this.getFlowSafe().properties.stateful) {
|
644
789
|
if (this.stateId$.value) {
|
645
|
-
return this.flowStateApiService.save(this.stateId$.value).pipe(tap
|
790
|
+
return this.flowStateApiService.save(this.stateId$.value).pipe(tap(() => {
|
646
791
|
Array.from(this.trackedStatefulChangesMap.keys()).forEach(key => {
|
647
792
|
this.trackedStatefulChangesMap.set(key, false);
|
648
793
|
});
|
@@ -652,7 +797,7 @@ class FlowStateService {
|
|
652
797
|
else {
|
653
798
|
const quoteDraft = this.quoteDraftService.quoteDraft;
|
654
799
|
if (quoteDraft) {
|
655
|
-
return this.quoteApiService.upsertQuote(quoteDraft).pipe(tap
|
800
|
+
return this.quoteApiService.upsertQuote(quoteDraft).pipe(tap(({ versionId }) => {
|
656
801
|
this.contextService.update({ properties: { VELOCPQ__VersionId__c: versionId } });
|
657
802
|
}));
|
658
803
|
}
|
@@ -668,7 +813,7 @@ class FlowStateService {
|
|
668
813
|
else {
|
669
814
|
const quoteDraft = this.quoteDraftService.quoteDraft;
|
670
815
|
if (quoteDraft) {
|
671
|
-
return this.quoteApiService.submitQuote(quoteDraft).pipe(tap
|
816
|
+
return this.quoteApiService.submitQuote(quoteDraft).pipe(tap(({ versionId }) => {
|
672
817
|
this.contextService.update({ properties: { VELOCPQ__VersionId__c: versionId } });
|
673
818
|
}));
|
674
819
|
}
|
@@ -714,7 +859,7 @@ class FlowStateService {
|
|
714
859
|
const execution$ = this.getFlowSafe().properties.stateful
|
715
860
|
? this.executeStateful$(fullRequest)
|
716
861
|
: this.executeStateless$(fullRequest);
|
717
|
-
return execution$.pipe(tap
|
862
|
+
return execution$.pipe(tap(result => this.handleSelectorsResponse(result.selectors)));
|
718
863
|
}
|
719
864
|
handleSelectorsResponse(selectors) {
|
720
865
|
Object.entries(selectors).forEach(([requestId, selectorResult]) => {
|
@@ -731,7 +876,7 @@ class FlowStateService {
|
|
731
876
|
initStateful$() {
|
732
877
|
// Subscriptions
|
733
878
|
this.subscribe$(UITemplateType.FLOW_ENGINE, 'CONTEXT', null, { cold: true })
|
734
|
-
.pipe(tap
|
879
|
+
.pipe(tap(response => {
|
735
880
|
if (response.success) {
|
736
881
|
this.contextService.update(response.result);
|
737
882
|
}
|
@@ -753,13 +898,13 @@ class FlowStateService {
|
|
753
898
|
selectors: { ...selectors, ...request.selectors },
|
754
899
|
actions: request.actions,
|
755
900
|
})
|
756
|
-
.pipe(map
|
901
|
+
.pipe(map(({ stateId, selectors }) => {
|
757
902
|
this.handleSelectorsResponse(selectors);
|
758
903
|
this.stateId$.next(stateId);
|
759
904
|
}));
|
760
905
|
}
|
761
906
|
initBufferedRequest$() {
|
762
|
-
return this.statefulRequestStream$.pipe(buffer(this.statefulRequestStream$.pipe(debounceTime(this.EXECUTION_BUFFER_TIME))), switchMap(requests => {
|
907
|
+
return this.statefulRequestStream$.pipe(buffer(this.statefulRequestStream$.pipe(debounceTime(this.EXECUTION_BUFFER_TIME))), switchMap$1(requests => {
|
763
908
|
if (!this.stateId$.value) {
|
764
909
|
throw 'Stateful session is not initialized';
|
765
910
|
}
|
@@ -773,32 +918,32 @@ class FlowStateService {
|
|
773
918
|
};
|
774
919
|
this.executionInProgress$.next(true);
|
775
920
|
return this.flowStateApiService.execute(this.stateId$.value, request);
|
776
|
-
}), tap
|
921
|
+
}), tap(({ stateId }) => this.stateId$.next(stateId)), share(), tap(() => this.executionInProgress$.next(false)), catchError(e => {
|
777
922
|
this.executionInProgress$.next(false);
|
778
923
|
return throwError(() => e);
|
779
924
|
}));
|
780
925
|
}
|
781
926
|
executeStateful$(request) {
|
782
|
-
return this.executionInProgress$.pipe(filter$1(inProgress => !inProgress), take$1(1), switchMap(() =>
|
927
|
+
return this.executionInProgress$.pipe(filter$1(inProgress => !inProgress), take$1(1), switchMap$1(() =>
|
783
928
|
// make sure stream switches to statefulExecutionRequest$ before pushing an execution request
|
784
929
|
combineLatest([
|
785
930
|
this.statefulExecutionRequest$,
|
786
|
-
of(undefined).pipe(tap
|
787
|
-
])), map
|
931
|
+
of(undefined).pipe(tap(() => this.statefulRequestStream$.next(request))),
|
932
|
+
])), map(([response]) => response), take$1(1));
|
788
933
|
}
|
789
934
|
initStateless$() {
|
790
935
|
const { headerId } = this.contextService.resolve();
|
791
|
-
return this.quoteDraftService.init(headerId, this.flowInfoService.params ?? {}).pipe(tap
|
936
|
+
return this.quoteDraftService.init(headerId, this.flowInfoService.params ?? {}).pipe(tap(() => {
|
792
937
|
const assets = this.quoteDraftService.assetsState;
|
793
938
|
if (assets) {
|
794
939
|
this.flowStore = { ...this.flowStore, assets };
|
795
940
|
}
|
796
|
-
}), switchMap(() => {
|
941
|
+
}), switchMap$1(() => {
|
797
942
|
if (this.flowInfoService.isLegacy) {
|
798
943
|
return of(null);
|
799
944
|
}
|
800
945
|
return this.executeRequest$(this.getDefaultExecutionRequestDTO());
|
801
|
-
}), switchMap(() => this.calculate$()), tap
|
946
|
+
}), switchMap$1(() => this.calculate$()), tap(() => this.quoteDraftService.finalizeInit()), map(noop));
|
802
947
|
}
|
803
948
|
calculate$() {
|
804
949
|
const flowState = this.quoteDraftService.quoteDraft;
|
@@ -821,7 +966,7 @@ class FlowStateService {
|
|
821
966
|
}
|
822
967
|
executeStateless$(request) {
|
823
968
|
this.executionInProgress$.next(true);
|
824
|
-
return of(undefined).pipe(tap
|
969
|
+
return of(undefined).pipe(tap(() => this.executeStatelessActions(request)), switchMap$1(() => {
|
825
970
|
/*
|
826
971
|
Skip price calculation in case
|
827
972
|
1. No actions in the request
|
@@ -833,7 +978,7 @@ class FlowStateService {
|
|
833
978
|
else {
|
834
979
|
return this.calculate$();
|
835
980
|
}
|
836
|
-
}), map
|
981
|
+
}), map(() => this.executeStatelessSelectors(request)), tap(() => this.executionInProgress$.next(false)), catchError(e => {
|
837
982
|
this.executionInProgress$.next(false);
|
838
983
|
return throwError(() => e);
|
839
984
|
}));
|
@@ -896,7 +1041,7 @@ class FlowStateService {
|
|
896
1041
|
return;
|
897
1042
|
}
|
898
1043
|
const localProcessors$ = this.customizationService?.getTemplateConfigurationProcessors?.(template.name) ?? of(null);
|
899
|
-
return localProcessors$.pipe(switchMap(processors => processors ? of(processors) : this.processorsApiService.fetchConfigurationProcessors$(template.id)), tap
|
1044
|
+
return localProcessors$.pipe(switchMap$1(processors => processors ? of(processors) : this.processorsApiService.fetchConfigurationProcessors$(template.id)), tap(processors => {
|
900
1045
|
const processorsMap = processors.reduce((acc, p) => {
|
901
1046
|
acc[p.apiName] = p;
|
902
1047
|
return acc;
|
@@ -908,7 +1053,7 @@ class FlowStateService {
|
|
908
1053
|
if (!owners$.length) {
|
909
1054
|
return of(undefined);
|
910
1055
|
}
|
911
|
-
return forkJoin(owners$).pipe(map
|
1056
|
+
return forkJoin(owners$).pipe(map(noop));
|
912
1057
|
}
|
913
1058
|
executeActionScript(request, executable) {
|
914
1059
|
const configurationProcessor = this.processors[executable.ownerId]?.[executable.apiName];
|
@@ -1191,111 +1336,6 @@ var lineItem_utils = /*#__PURE__*/Object.freeze({
|
|
1191
1336
|
upsertAttributes: upsertAttributes
|
1192
1337
|
});
|
1193
1338
|
|
1194
|
-
class RuntimeSettingsService {
|
1195
|
-
constructor(configurationSettingsApiService) {
|
1196
|
-
this.configurationSettingsApiService = configurationSettingsApiService;
|
1197
|
-
this.configurationSettings$ = new BehaviorSubject({});
|
1198
|
-
this.currencySettings$ = new BehaviorSubject({
|
1199
|
-
iso: DEFAULT_CURRENCY_ISO_CODE,
|
1200
|
-
symbol: DEFAULT_CURRENCY_SYMBOL,
|
1201
|
-
});
|
1202
|
-
this.shoppingCartSettings$ = new BehaviorSubject([]);
|
1203
|
-
this.getCurrencySymbol = (locale, currency) => {
|
1204
|
-
return (0)
|
1205
|
-
.toLocaleString(locale, { style: 'currency', currency, minimumFractionDigits: 0, maximumFractionDigits: 0 })
|
1206
|
-
.replace(/\d/g, '')
|
1207
|
-
.trim();
|
1208
|
-
};
|
1209
|
-
}
|
1210
|
-
create() {
|
1211
|
-
return this.configurationSettingsApiService.fetchSettings().pipe(map$1(settings => this.parseConfigurationSettings(settings)), tap$1(configurationSettings => {
|
1212
|
-
this.configurationSettings$.next(configurationSettings);
|
1213
|
-
this.addShoppingCartSettings(configurationSettings['shopping-cart'] ?? []);
|
1214
|
-
this.formattingSettings = this.getFormattingSettings();
|
1215
|
-
}), map$1(() => undefined));
|
1216
|
-
}
|
1217
|
-
initCurrency(iso) {
|
1218
|
-
if (iso) {
|
1219
|
-
const symbol = this.getCurrencySymbol('en-US', iso);
|
1220
|
-
this.currencySettings$.next({ iso, symbol });
|
1221
|
-
if (this.formattingSettings) {
|
1222
|
-
this.formattingSettings.currencySymbol = symbol;
|
1223
|
-
}
|
1224
|
-
}
|
1225
|
-
}
|
1226
|
-
getFormattingSettings() {
|
1227
|
-
if (this.formattingSettings) {
|
1228
|
-
return this.formattingSettings;
|
1229
|
-
}
|
1230
|
-
const shoppingCartSettings = this.getConfigurationSettings()['shopping-cart']?.reduce((acc, setting) => {
|
1231
|
-
return { ...acc, [setting.id]: setting.properties };
|
1232
|
-
}, {});
|
1233
|
-
const currencySettings = this.getCurrencySettings();
|
1234
|
-
const dateFormat = (validateDateFormat(shoppingCartSettings?.DATE_FORMAT ?? '') && shoppingCartSettings?.DATE_FORMAT) ||
|
1235
|
-
DEFAULT_DATE_FORMAT;
|
1236
|
-
const decimalSeparator = shoppingCartSettings?.DECIMAL_SEPARATOR;
|
1237
|
-
const thousandsSeparator = shoppingCartSettings?.THOUSANDS_SEPARATOR;
|
1238
|
-
// the number of decimal places can be 0
|
1239
|
-
const priceScale = shoppingCartSettings?.PRICE_SCALE;
|
1240
|
-
const decimalsCount = priceScale !== null && priceScale !== '' && !isNaN(Number(priceScale)) && Number(priceScale) >= 0
|
1241
|
-
? Number(priceScale)
|
1242
|
-
: DEFAULT_DECIMALS_COUNT;
|
1243
|
-
const actionCodeSettings = shoppingCartSettings?.STATUS_LABEL;
|
1244
|
-
return {
|
1245
|
-
currencySymbol: currencySettings.symbol,
|
1246
|
-
dateFormats: getSupportedDateFormats(dateFormat),
|
1247
|
-
decimalsCount,
|
1248
|
-
decimalSeparator: decimalSeparator !== undefined && ['.', ','].includes(decimalSeparator)
|
1249
|
-
? decimalSeparator
|
1250
|
-
: DEFAULT_DECIMAL_SEPARATOR,
|
1251
|
-
// thousands separator can be a blank value, so it can also be null
|
1252
|
-
thousandsSeparator: thousandsSeparator !== undefined && ['.', ',', '', null].includes(thousandsSeparator)
|
1253
|
-
? thousandsSeparator || ''
|
1254
|
-
: DEFAULT_THOUSANDS_SEPARATOR,
|
1255
|
-
actionCodeLabels: actionCodeSettings?.length
|
1256
|
-
? actionCodeSettings.reduce((result, setting) => ({ ...result, [setting.status_label]: setting.custom_label }), {})
|
1257
|
-
: DEFAULT_ACTION_CODE_LABELS,
|
1258
|
-
};
|
1259
|
-
}
|
1260
|
-
getConfigurationSettings() {
|
1261
|
-
return this.configurationSettings$.value;
|
1262
|
-
}
|
1263
|
-
getShoppingCartSettings() {
|
1264
|
-
return this.shoppingCartSettings$.value;
|
1265
|
-
}
|
1266
|
-
getCurrencySettings() {
|
1267
|
-
return this.currencySettings$.value;
|
1268
|
-
}
|
1269
|
-
parseConfigurationSettings(settings) {
|
1270
|
-
return settings.reduce((acc, setting) => {
|
1271
|
-
switch (setting.key) {
|
1272
|
-
case 'shopping-cart':
|
1273
|
-
acc['shopping-cart'] = parseJsonSafely(setting.value, []);
|
1274
|
-
break;
|
1275
|
-
case 'navigation':
|
1276
|
-
acc.navigation = parseJsonSafely(setting.value, {});
|
1277
|
-
break;
|
1278
|
-
case 'flows':
|
1279
|
-
acc.flows = parseJsonSafely(setting.value, []);
|
1280
|
-
break;
|
1281
|
-
default:
|
1282
|
-
acc[setting.key] = setting.value;
|
1283
|
-
}
|
1284
|
-
return acc;
|
1285
|
-
}, {});
|
1286
|
-
}
|
1287
|
-
addShoppingCartSettings(settings) {
|
1288
|
-
// uniqBy removes items with the biggest index
|
1289
|
-
const newSettings = uniqBy([...settings, ...this.shoppingCartSettings$.value], 'id');
|
1290
|
-
this.shoppingCartSettings$.next(newSettings);
|
1291
|
-
}
|
1292
|
-
}
|
1293
|
-
RuntimeSettingsService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: RuntimeSettingsService, deps: [{ token: i1.ConfigurationSettingsApiService }], target: i0.ɵɵFactoryTarget.Injectable });
|
1294
|
-
RuntimeSettingsService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: RuntimeSettingsService });
|
1295
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: RuntimeSettingsService, decorators: [{
|
1296
|
-
type: Injectable
|
1297
|
-
}], ctorParameters: function () { return [{ type: i1.ConfigurationSettingsApiService }]; } });
|
1298
|
-
|
1299
1339
|
class LineItemWorker {
|
1300
1340
|
constructor(src) {
|
1301
1341
|
this.li = { ...src };
|
@@ -1361,7 +1401,7 @@ class ConfigurationService {
|
|
1361
1401
|
const prevState = this.configurationState.value;
|
1362
1402
|
this.configurationState.next(prevState ? { ...prevState } : null);
|
1363
1403
|
return throwError(() => error);
|
1364
|
-
}), tap(() => {
|
1404
|
+
}), tap$1(() => {
|
1365
1405
|
if (!this.hasUnsavedChanges) {
|
1366
1406
|
this.hasUnsavedChanges = true;
|
1367
1407
|
}
|
@@ -1374,7 +1414,7 @@ class ConfigurationService {
|
|
1374
1414
|
this.configurableRamp = lineItem;
|
1375
1415
|
}
|
1376
1416
|
get() {
|
1377
|
-
return this.configurationState.pipe(map(state => state?.lineItem), shareReplay$1());
|
1417
|
+
return this.configurationState.pipe(map$1(state => state?.lineItem), shareReplay$1());
|
1378
1418
|
}
|
1379
1419
|
getSnapshot() {
|
1380
1420
|
return this.configurationState.value?.lineItem ? { ...this.configurationState.value?.lineItem } : undefined;
|
@@ -1409,19 +1449,19 @@ class ConfigurationService {
|
|
1409
1449
|
return this.contextService.resolve$();
|
1410
1450
|
}
|
1411
1451
|
get charges$() {
|
1412
|
-
return this.configurationState.pipe(map(state => state?.charges ?? {}));
|
1452
|
+
return this.configurationState.pipe(map$1(state => state?.charges ?? {}));
|
1413
1453
|
}
|
1414
1454
|
get chargesSnapshot() {
|
1415
1455
|
return this.configurationState.value?.charges ?? {};
|
1416
1456
|
}
|
1417
1457
|
get pricePlans$() {
|
1418
|
-
return this.configurationState.pipe(map(state => state?.pricePlans ?? {}));
|
1458
|
+
return this.configurationState.pipe(map$1(state => state?.pricePlans ?? {}));
|
1419
1459
|
}
|
1420
1460
|
get pricePlansSnapshot() {
|
1421
1461
|
return this.configurationState.value?.pricePlans ?? {};
|
1422
1462
|
}
|
1423
1463
|
get procedureContext$() {
|
1424
|
-
return this.configurationState.pipe(map(state => state?.procedureContext ?? {}));
|
1464
|
+
return this.configurationState.pipe(map$1(state => state?.procedureContext ?? {}));
|
1425
1465
|
}
|
1426
1466
|
get procedureContextSnapshot() {
|
1427
1467
|
return this.configurationState.value?.procedureContext ?? {};
|
@@ -1435,7 +1475,7 @@ class ConfigurationService {
|
|
1435
1475
|
const uiDefinitionProperties = this.getUIDefinitionProperties();
|
1436
1476
|
const mainPricingEnabled = runtimeContext.properties?.PricingEnabled;
|
1437
1477
|
const pricingEnabled = mainPricingEnabled ? mainPricingEnabled === 'true' : uiDefinitionProperties.pricingEnabled;
|
1438
|
-
const customPriceApi = this.runtimeSettings.
|
1478
|
+
const customPriceApi = this.runtimeSettings.configurationSettings['CUSTOM_PRICE_API'];
|
1439
1479
|
this.isLoadingSubj$.next(true);
|
1440
1480
|
const configure$ = pricingEnabled && customPriceApi
|
1441
1481
|
? this.configurationApiService.customConfigurePrice({ url: customPriceApi, configurationRequest, runtimeModel })
|
@@ -1444,7 +1484,7 @@ class ConfigurationService {
|
|
1444
1484
|
runtimeModel,
|
1445
1485
|
pricingEnabled,
|
1446
1486
|
});
|
1447
|
-
return configure$.pipe(tap(result => {
|
1487
|
+
return configure$.pipe(tap$1(result => {
|
1448
1488
|
this.contextService.update(result.context);
|
1449
1489
|
this.configurationState.next(result);
|
1450
1490
|
this.previousConfigurationState.next(cloneDeep(result));
|
@@ -1452,7 +1492,7 @@ class ConfigurationService {
|
|
1452
1492
|
this.showInactiveProductsConfirmation();
|
1453
1493
|
}
|
1454
1494
|
this.configurableRamp = result.lineItem;
|
1455
|
-
}), map(({ lineItem }) => lineItem), catchError$1(error => throwError(() => {
|
1495
|
+
}), map$1(({ lineItem }) => lineItem), catchError$1(error => throwError(() => {
|
1456
1496
|
const resetState = this.previousConfigurationState.value;
|
1457
1497
|
if (resetState) {
|
1458
1498
|
this.previousConfigurationState.next(cloneDeep(resetState));
|
@@ -1467,7 +1507,7 @@ class ConfigurationService {
|
|
1467
1507
|
configureExternal$(props) {
|
1468
1508
|
return this.runtimeService
|
1469
1509
|
.init({ productId: props.productId, defaultQty: props.qty, attributesMap: props.attributesMap })
|
1470
|
-
.pipe(switchMap
|
1510
|
+
.pipe(switchMap(() => this.configure()), first(), catchError$1(error => {
|
1471
1511
|
this.messageService.add({ severity: ToastType.error, summary: error });
|
1472
1512
|
throw error;
|
1473
1513
|
}), finalize$1(() => this.reset()));
|
@@ -1704,14 +1744,14 @@ class FlowConfigurationService {
|
|
1704
1744
|
this.updated$ = this.updatedSubj$.asObservable();
|
1705
1745
|
}
|
1706
1746
|
calculate$(quoteDraft) {
|
1707
|
-
return this.extendedApply$(quoteDraft).pipe(tap
|
1747
|
+
return this.extendedApply$(quoteDraft).pipe(tap(result => {
|
1708
1748
|
// sort the result current state based on the quote draft initial state
|
1709
1749
|
const initialStateIds = quoteDraft.initialState.map(lineItem => lineItem.integrationId);
|
1710
1750
|
result.currentState = result.currentState
|
1711
1751
|
.slice()
|
1712
1752
|
.sort((a, b) => initialStateIds.indexOf(a.integrationId) - initialStateIds.indexOf(b.integrationId));
|
1713
1753
|
this.quoteDraftService.updateQuoteDraft(result);
|
1714
|
-
}), map
|
1754
|
+
}), map(noop));
|
1715
1755
|
}
|
1716
1756
|
calculate(quoteDraft) {
|
1717
1757
|
this.calculate$(quoteDraft).subscribe();
|
@@ -1721,11 +1761,11 @@ class FlowConfigurationService {
|
|
1721
1761
|
if (!quoteDraft) {
|
1722
1762
|
return of(null);
|
1723
1763
|
}
|
1724
|
-
return of([]).pipe(map
|
1764
|
+
return of([]).pipe(map(() => {
|
1725
1765
|
const updatedState = cloneDeep(quoteDraft.currentState);
|
1726
1766
|
this.updateService.update(updatedState, updates, quoteDraft.charges);
|
1727
1767
|
return updatedState;
|
1728
|
-
}), switchMap(updatedState => this.calculate$({ ...quoteDraft, currentState: updatedState })), map
|
1768
|
+
}), switchMap$1(updatedState => this.calculate$({ ...quoteDraft, currentState: updatedState })), map(() => this.quoteDraftService.quoteDraft), tap(() => this.updatedSubj$.next()), this.handleErrorAndBounceBack());
|
1729
1769
|
}
|
1730
1770
|
update(updates) {
|
1731
1771
|
this.update$(updates).subscribe();
|
@@ -1742,9 +1782,9 @@ class FlowConfigurationService {
|
|
1742
1782
|
}
|
1743
1783
|
const updatedState = cloneDeep(currentState);
|
1744
1784
|
updatedState.splice(currentLineItemIndex, 1, initialLineItem);
|
1745
|
-
return of([]).pipe(tap
|
1785
|
+
return of([]).pipe(tap(() => {
|
1746
1786
|
this.quoteDraftService.setCurrentLineItemState(updatedState);
|
1747
|
-
}), switchMap(() => this.calculate$({ ...quoteDraft, currentState: updatedState })), map
|
1787
|
+
}), switchMap$1(() => this.calculate$({ ...quoteDraft, currentState: updatedState })), map(() => this.quoteDraftService.quoteDraft), tap(() => this.updatedSubj$.next()), this.handleErrorAndBounceBack());
|
1748
1788
|
}
|
1749
1789
|
revert(lineItemId) {
|
1750
1790
|
this.revert$(lineItemId).subscribe();
|
@@ -1755,7 +1795,7 @@ class FlowConfigurationService {
|
|
1755
1795
|
if (!quoteDraft) {
|
1756
1796
|
return of(null);
|
1757
1797
|
}
|
1758
|
-
return of([]).pipe(map
|
1798
|
+
return of([]).pipe(map(() => ids.reduce((result, id) => this.updateService.delete(result, id), currentState)), switchMap$1(updatedState => this.calculate$({ ...quoteDraft, currentState: updatedState })), map(() => this.quoteDraftService.quoteDraft), tap(() => this.updatedSubj$.next()), this.handleErrorAndBounceBack());
|
1759
1799
|
}
|
1760
1800
|
delete(ids) {
|
1761
1801
|
this.delete$(ids).subscribe();
|
@@ -1766,34 +1806,34 @@ class FlowConfigurationService {
|
|
1766
1806
|
return of(null);
|
1767
1807
|
}
|
1768
1808
|
const updatedState = [...quoteDraft.currentState, term];
|
1769
|
-
return of([]).pipe(switchMap(() => this.calculate$({ ...quoteDraft, currentState: updatedState })), map
|
1809
|
+
return of([]).pipe(switchMap$1(() => this.calculate$({ ...quoteDraft, currentState: updatedState })), map(() => this.quoteDraftService.quoteDraft), tap(() => this.updatedSubj$.next()), this.handleErrorAndBounceBack());
|
1770
1810
|
}
|
1771
1811
|
addToCart$(props) {
|
1772
1812
|
const quoteDraft = this.quoteDraftService.quoteDraft;
|
1773
1813
|
if (!quoteDraft) {
|
1774
1814
|
return of(null);
|
1775
1815
|
}
|
1776
|
-
return this.configurationService.configureExternal$(props).pipe(map
|
1816
|
+
return this.configurationService.configureExternal$(props).pipe(map(lineItem => {
|
1777
1817
|
const model = this.configurationService.getRuntimeModel();
|
1778
1818
|
const split = model?.types.find(type => type.name === lineItem.type)?.split ?? false;
|
1779
1819
|
const lineItems = multiplyLineItems(lineItem, props.qty ?? 1, split);
|
1780
1820
|
return [...quoteDraft.currentState, ...lineItems];
|
1781
|
-
}), switchMap(updatedState => this.calculate$({ ...quoteDraft, currentState: updatedState })), map
|
1821
|
+
}), switchMap$1(updatedState => this.calculate$({ ...quoteDraft, currentState: updatedState })), map(() => this.quoteDraftService.quoteDraft), tap(() => this.updatedSubj$.next()), this.handleErrorAndBounceBack());
|
1782
1822
|
}
|
1783
1823
|
get() {
|
1784
|
-
return this.quoteDraftService.quoteDraft$.pipe(map
|
1824
|
+
return this.quoteDraftService.quoteDraft$.pipe(map(() => this.quoteDraftService.currentState), shareReplay$1());
|
1785
1825
|
}
|
1786
1826
|
getSnapshot() {
|
1787
1827
|
return this.quoteDraftService?.currentState.slice() ?? [];
|
1788
1828
|
}
|
1789
1829
|
get charges$() {
|
1790
|
-
return this.quoteDraftService.quoteDraft$.pipe(map
|
1830
|
+
return this.quoteDraftService.quoteDraft$.pipe(map(({ charges }) => charges));
|
1791
1831
|
}
|
1792
1832
|
get pricePlans$() {
|
1793
|
-
return this.quoteDraftService.quoteDraft$.pipe(map
|
1833
|
+
return this.quoteDraftService.quoteDraft$.pipe(map(({ pricePlans }) => pricePlans));
|
1794
1834
|
}
|
1795
1835
|
get activeMetrics$() {
|
1796
|
-
return this.quoteDraftService.quoteDraft$.pipe(map
|
1836
|
+
return this.quoteDraftService.quoteDraft$.pipe(map(({ activeMetrics }) => activeMetrics));
|
1797
1837
|
}
|
1798
1838
|
get chargesSnapshot() {
|
1799
1839
|
return this.quoteDraftService.quoteDraft?.charges ?? {};
|
@@ -1873,18 +1913,18 @@ class FlowStateConfigurationService {
|
|
1873
1913
|
}
|
1874
1914
|
else {
|
1875
1915
|
const lineItem = generateConfigurationLineItem(props, props.qty);
|
1876
|
-
request$ = this.flowStateApiService.newConfiguration(stateId, { lineItem }).pipe(tap
|
1916
|
+
request$ = this.flowStateApiService.newConfiguration(stateId, { lineItem }).pipe(tap(r => this.configurationStateId$.next(r.stateId)), switchMap$1(() => {
|
1877
1917
|
if (!this.configurationStateId) {
|
1878
1918
|
return of();
|
1879
1919
|
}
|
1880
|
-
return this.flowStateApiService.saveConfiguration(stateId, this.configurationStateId).pipe(tap
|
1920
|
+
return this.flowStateApiService.saveConfiguration(stateId, this.configurationStateId).pipe(tap(() => this.configurationStateId$.next(null)), map(noop));
|
1881
1921
|
}));
|
1882
1922
|
}
|
1883
1923
|
}
|
1884
1924
|
else {
|
1885
|
-
request$ = this.flowConfigurationService.addToCart$(props).pipe(map
|
1925
|
+
request$ = this.flowConfigurationService.addToCart$(props).pipe(map(noop));
|
1886
1926
|
}
|
1887
|
-
return request$.pipe(switchMap(() => this.flowStateService.executeRequest$({}, true)), map
|
1927
|
+
return request$.pipe(switchMap$1(() => this.flowStateService.executeRequest$({}, true)), map(noop));
|
1888
1928
|
}
|
1889
1929
|
}
|
1890
1930
|
FlowStateConfigurationService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: FlowStateConfigurationService, deps: [{ token: FlowInfoService }, { token: FlowConfigurationService }, { token: i1.FlowStateApiService }, { token: FlowStateService }], target: i0.ɵɵFactoryTarget.Injectable });
|
@@ -1911,7 +1951,7 @@ class IntegrationState {
|
|
1911
1951
|
this.action$.next(action);
|
1912
1952
|
}
|
1913
1953
|
listen$(actionType) {
|
1914
|
-
return this.action$.pipe(filter$1(action => action.type === actionType), map
|
1954
|
+
return this.action$.pipe(filter$1(action => action.type === actionType), map(action => action.payload));
|
1915
1955
|
}
|
1916
1956
|
listenAll$() {
|
1917
1957
|
return this.action$.asObservable();
|
@@ -1936,12 +1976,12 @@ class ProductImagesService {
|
|
1936
1976
|
this.imagesMap$.next({ ...this.imagesMap$.value, [productId]: '' });
|
1937
1977
|
this.fetchProductImage(productId);
|
1938
1978
|
}
|
1939
|
-
return this.imagesMap$.pipe(map
|
1979
|
+
return this.imagesMap$.pipe(map(imagesMap => imagesMap[productId] ?? null), distinctUntilChanged());
|
1940
1980
|
}
|
1941
1981
|
fetchProductImage(productId) {
|
1942
1982
|
this.productApiService
|
1943
1983
|
.fetchImage$(productId)
|
1944
|
-
.pipe(map
|
1984
|
+
.pipe(map(file => URL.createObjectURL(file)), catchError(() => of('')), tap(url => this.imagesMap$.next({ ...this.imagesMap$.value, [productId]: url })))
|
1945
1985
|
.subscribe();
|
1946
1986
|
}
|
1947
1987
|
}
|
@@ -1956,7 +1996,7 @@ class RuntimeContextService {
|
|
1956
1996
|
this.configurationApiService = configurationApiService;
|
1957
1997
|
}
|
1958
1998
|
getRuntimeContext(productId, offeringId) {
|
1959
|
-
return this.configurationApiService.getRuntimeDataByProductId(productId, offeringId).pipe(map(runtimeData => {
|
1999
|
+
return this.configurationApiService.getRuntimeDataByProductId(productId, offeringId).pipe(map$1(runtimeData => {
|
1960
2000
|
const uiDefinitionContainer = this.getUIDefinitionContainer(runtimeData);
|
1961
2001
|
const runtimeModel = RuntimeModel.create(runtimeData.types, runtimeData.products);
|
1962
2002
|
const { productName, properties } = Array.from(runtimeModel.components.values()).find(c => c.productId === productId) ?? {};
|
@@ -2007,7 +2047,7 @@ class ConfigurationRuntimeService {
|
|
2007
2047
|
return combineLatest([
|
2008
2048
|
this.apiService.getRuntimeDataByModelId(uiDefinitionContainer.modelId),
|
2009
2049
|
this.contextService.initTestMode(),
|
2010
|
-
]).pipe(first(), map(([runtimeData, context]) => {
|
2050
|
+
]).pipe(first(), map$1(([runtimeData, context]) => {
|
2011
2051
|
this.contextService.update({
|
2012
2052
|
properties: {
|
2013
2053
|
...this.runtimeContext?.properties,
|
@@ -2026,12 +2066,12 @@ class ConfigurationRuntimeService {
|
|
2026
2066
|
uiDefinitionContainer,
|
2027
2067
|
};
|
2028
2068
|
return this._runtimeContext;
|
2029
|
-
}), tap(() => (this._isInitialized = true)));
|
2069
|
+
}), tap$1(() => (this._isInitialized = true)));
|
2030
2070
|
}
|
2031
2071
|
init(props) {
|
2032
2072
|
this.initializationProps = props;
|
2033
2073
|
const context = this.contextService.resolve();
|
2034
|
-
return this.runtimeContextService.getRuntimeContext(props.productId, props.offeringId).pipe(tap(runtimeContext => {
|
2074
|
+
return this.runtimeContextService.getRuntimeContext(props.productId, props.offeringId).pipe(tap$1(runtimeContext => {
|
2035
2075
|
this.uiDefinitionProperties = runtimeContext.uiDefinitionContainer?.source.properties ?? {};
|
2036
2076
|
const { PriceListId } = context.properties ?? {};
|
2037
2077
|
const mergeContext = {
|
@@ -2053,7 +2093,7 @@ class ConfigurationRuntimeService {
|
|
2053
2093
|
});
|
2054
2094
|
}
|
2055
2095
|
return this._runtimeContext;
|
2056
|
-
}), tap(() => (this._isInitialized = true)));
|
2096
|
+
}), tap$1(() => (this._isInitialized = true)));
|
2057
2097
|
}
|
2058
2098
|
overrideUIDefinition(uiDefinitionContainer) {
|
2059
2099
|
if (!this._runtimeContext) {
|
@@ -2140,7 +2180,7 @@ class ConfigurationStateService {
|
|
2140
2180
|
}
|
2141
2181
|
execute$(exec) {
|
2142
2182
|
const request = this.execToRequest(exec);
|
2143
|
-
return this.executeRequest$(request).pipe(map
|
2183
|
+
return this.executeRequest$(request).pipe(map(result => {
|
2144
2184
|
// Keep only requested results
|
2145
2185
|
const actualSelectors = Object.entries(result.selectors).reduce((trunk, [requestId, result]) => {
|
2146
2186
|
if (exec.selectors?.[requestId]) {
|
@@ -2176,7 +2216,7 @@ class ConfigurationStateService {
|
|
2176
2216
|
},
|
2177
2217
|
},
|
2178
2218
|
});
|
2179
|
-
return this.executeRequest$(request).pipe(map
|
2219
|
+
return this.executeRequest$(request).pipe(map(response => response.selectors[requestId]));
|
2180
2220
|
}
|
2181
2221
|
subscribe$(selectorName, inputData = {}, options) {
|
2182
2222
|
const requestId = UUID.UUID();
|
@@ -2199,7 +2239,7 @@ class ConfigurationStateService {
|
|
2199
2239
|
this.executeRequest$(request).subscribe();
|
2200
2240
|
}
|
2201
2241
|
}
|
2202
|
-
return subscription.data$.pipe(filter$1(data => data != this.NOT_INITIALIZED), map
|
2242
|
+
return subscription.data$.pipe(filter$1(data => data != this.NOT_INITIALIZED), map(data => data), distinctUntilChanged(), finalize(() => {
|
2203
2243
|
if (!this.subscriptions[requestId]?.data$.observed) {
|
2204
2244
|
delete this.subscriptions[requestId];
|
2205
2245
|
}
|
@@ -2210,7 +2250,7 @@ class ConfigurationStateService {
|
|
2210
2250
|
if (this.isStatefulConfiguration) {
|
2211
2251
|
return this.flowStateApiService
|
2212
2252
|
.saveConfiguration(this.flowStateService.stateId ?? '', this.stateId ?? '')
|
2213
|
-
.pipe(switchMap(r => this.flowStateService.executeRequest$({}, true).pipe(map
|
2253
|
+
.pipe(switchMap$1(r => this.flowStateService.executeRequest$({}, true).pipe(map(() => r))));
|
2214
2254
|
}
|
2215
2255
|
else {
|
2216
2256
|
if (!flow) {
|
@@ -2247,7 +2287,7 @@ class ConfigurationStateService {
|
|
2247
2287
|
}
|
2248
2288
|
return this.flowConfigurationService
|
2249
2289
|
.calculate$({ ...quoteDraft, currentState, initialState })
|
2250
|
-
.pipe(map
|
2290
|
+
.pipe(map(() => ({ quoteId: '' })));
|
2251
2291
|
}
|
2252
2292
|
}
|
2253
2293
|
}
|
@@ -2290,13 +2330,13 @@ class ConfigurationStateService {
|
|
2290
2330
|
selectorsOverride: container?.selectors?.map(processor => ({ ...processor, ownerId: this.ownerId })),
|
2291
2331
|
});
|
2292
2332
|
}
|
2293
|
-
return request$.pipe(map
|
2333
|
+
return request$.pipe(map(r => {
|
2294
2334
|
this.stateId = r.stateId;
|
2295
2335
|
return undefined;
|
2296
2336
|
}));
|
2297
2337
|
}
|
2298
2338
|
initStateless$() {
|
2299
|
-
return this.configurationService.configure().pipe(map
|
2339
|
+
return this.configurationService.configure().pipe(map(() => undefined));
|
2300
2340
|
}
|
2301
2341
|
execToRequest(exec) {
|
2302
2342
|
return {
|
@@ -2337,11 +2377,11 @@ class ConfigurationStateService {
|
|
2337
2377
|
else {
|
2338
2378
|
execution$ = this.executeStateless$(fullRequest);
|
2339
2379
|
}
|
2340
|
-
return execution$.pipe(tap
|
2380
|
+
return execution$.pipe(tap(result => this.handleSelectorsResponse(result.selectors)));
|
2341
2381
|
}
|
2342
2382
|
executeStateless$(request) {
|
2343
2383
|
this.executionInProgress$.next(true);
|
2344
|
-
return of(undefined).pipe(switchMap(() => {
|
2384
|
+
return of(undefined).pipe(switchMap$1(() => {
|
2345
2385
|
// Apply actions and execute configuration/price call
|
2346
2386
|
// No need to run configuration if no actions in the request
|
2347
2387
|
if (!request.actions?.length) {
|
@@ -2353,14 +2393,14 @@ class ConfigurationStateService {
|
|
2353
2393
|
});
|
2354
2394
|
configurationRequest = ConfigurationTranslatorUtils.lightenConfigurationRequest(configurationRequest);
|
2355
2395
|
return this.configurationService.configureRequest$(configurationRequest);
|
2356
|
-
}), map
|
2396
|
+
}), map(() => {
|
2357
2397
|
// Run selectors and apply them to the state
|
2358
2398
|
const configurationState = this.configurationService.stateSnapshot;
|
2359
2399
|
if (!configurationState) {
|
2360
2400
|
return { stateId: '', selectors: {} };
|
2361
2401
|
}
|
2362
2402
|
return this.runStatelessSelectors(request, configurationState);
|
2363
|
-
}), tap
|
2403
|
+
}), tap(() => this.executionInProgress$.next(false)), catchError(error => {
|
2364
2404
|
const configurationState = this.configurationService.previousStateSnapshot;
|
2365
2405
|
if (configurationState) {
|
2366
2406
|
const selectorsResult = this.runStatelessSelectors(request, configurationState);
|
@@ -2374,7 +2414,7 @@ class ConfigurationStateService {
|
|
2374
2414
|
}));
|
2375
2415
|
}
|
2376
2416
|
initBufferedRequest$() {
|
2377
|
-
return this.statefulRequestStream$.pipe(buffer(this.statefulRequestStream$.pipe(debounceTime(this.EXECUTION_BUFFER_TIME))), switchMap(requests => {
|
2417
|
+
return this.statefulRequestStream$.pipe(buffer(this.statefulRequestStream$.pipe(debounceTime(this.EXECUTION_BUFFER_TIME))), switchMap$1(requests => {
|
2378
2418
|
if (!this.flowStateService.stateId || !this.stateId) {
|
2379
2419
|
throw 'Stateful session is not initialized';
|
2380
2420
|
}
|
@@ -2388,18 +2428,18 @@ class ConfigurationStateService {
|
|
2388
2428
|
};
|
2389
2429
|
this.executionInProgress$.next(true);
|
2390
2430
|
return this.flowStateApiService.executeConfiguration(this.flowStateService.stateId, this.stateId, request);
|
2391
|
-
}), tap
|
2431
|
+
}), tap(({ stateId }) => (this.stateId = stateId)), share(), tap(() => this.executionInProgress$.next(false)), catchError(e => {
|
2392
2432
|
this.executionInProgress$.next(false);
|
2393
2433
|
return throwError(() => e);
|
2394
2434
|
}));
|
2395
2435
|
}
|
2396
2436
|
executeStateful$(request) {
|
2397
|
-
return this.executionInProgress$.pipe(filter$1(inProgress => !inProgress), take$1(1), switchMap(() =>
|
2437
|
+
return this.executionInProgress$.pipe(filter$1(inProgress => !inProgress), take$1(1), switchMap$1(() =>
|
2398
2438
|
// make sure stream switches to statefulExecutionRequest$ before pushing an execution request
|
2399
2439
|
combineLatest([
|
2400
2440
|
this.statefulExecutionRequest$,
|
2401
|
-
of(undefined).pipe(tap
|
2402
|
-
])), map
|
2441
|
+
of(undefined).pipe(tap(() => this.statefulRequestStream$.next(request))),
|
2442
|
+
])), map(([response]) => response), take$1(1));
|
2403
2443
|
}
|
2404
2444
|
executeActionScript(request, processor) {
|
2405
2445
|
const { actions } = this.configurationRuntimeService.runtimeContext?.uiDefinitionContainer ?? {};
|