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