@veloceapps/sdk 10.0.0-4 → 10.0.0-41
Sign up to get free protection for your applications and to get access to all the features.
- package/cms/modules/runtime/services/runtime.service.d.ts +3 -1
- package/cms/utils/index.d.ts +1 -0
- package/cms/utils/inject.d.ts +1 -0
- package/cms/utils/ui-definition.utils.d.ts +1 -0
- package/cms/vendor-map.d.ts +1 -0
- package/core/modules/configuration/services/configuration-state.service.d.ts +1 -0
- 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/cms/components/element-renderer/element-renderer.component.mjs +3 -2
- package/esm2020/cms/modules/runtime/services/runtime.service.mjs +3 -1
- package/esm2020/cms/utils/index.mjs +2 -1
- package/esm2020/cms/utils/inject.mjs +27 -0
- package/esm2020/cms/utils/ui-definition.utils.mjs +13 -1
- package/esm2020/cms/vendor-map.mjs +3 -1
- package/esm2020/core/modules/configuration/services/configuration-state.service.mjs +13 -4
- 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 +19 -6
- package/esm2020/core/services/flow-state.service.mjs +19 -6
- 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-cms.mjs +41 -2
- package/fesm2015/veloceapps-sdk-cms.mjs.map +1 -1
- package/fesm2015/veloceapps-sdk-core.mjs +281 -230
- 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-cms.mjs +40 -1
- package/fesm2020/veloceapps-sdk-cms.mjs.map +1 -1
- package/fesm2020/veloceapps-sdk-core.mjs +278 -228
- 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,20 @@ 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
|
+
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(() => {
|
222
345
|
this.params = { ...routeQueryParams, ...flow.properties.queryParams };
|
223
346
|
this.flowSubj$.next(flow);
|
224
|
-
}), map
|
347
|
+
}), map(noop), catchError(e => {
|
225
348
|
this.flowSubj$.next(null);
|
226
349
|
return throwError(() => e);
|
227
350
|
}));
|
@@ -235,7 +358,7 @@ class FlowInfoService {
|
|
235
358
|
return forkJoin([
|
236
359
|
this.templatesApiService.fetchTemplates$(),
|
237
360
|
this.customizationService?.getTemplates?.() ?? of([]),
|
238
|
-
]).pipe(map
|
361
|
+
]).pipe(map(([templates, localTemplates]) => {
|
239
362
|
Object.entries({ ...this.defaultTemplates, ...flow.properties.templates }).forEach(([key, name]) => {
|
240
363
|
const type = this.remapTemplateName(key);
|
241
364
|
if (type) {
|
@@ -272,11 +395,11 @@ class FlowInfoService {
|
|
272
395
|
return undefined;
|
273
396
|
}
|
274
397
|
}
|
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 });
|
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: RuntimeSettingsService }, { token: FLOW_CUSTOMIZATION, optional: true }], target: i0.ɵɵFactoryTarget.Injectable });
|
276
399
|
FlowInfoService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: FlowInfoService });
|
277
400
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: FlowInfoService, decorators: [{
|
278
401
|
type: Injectable
|
279
|
-
}], ctorParameters: function () { return [{ type: i1.FlowsApiService }, { type: i1.UITemplatesApiService }, { type: undefined, decorators: [{
|
402
|
+
}], ctorParameters: function () { return [{ type: i1.FlowsApiService }, { type: i1.UITemplatesApiService }, { type: RuntimeSettingsService }, { type: undefined, decorators: [{
|
280
403
|
type: Optional
|
281
404
|
}, {
|
282
405
|
type: Inject,
|
@@ -305,13 +428,13 @@ class QuoteDraftService {
|
|
305
428
|
}
|
306
429
|
}
|
307
430
|
get hasProducts$() {
|
308
|
-
return this.quoteSubj$.pipe(map(() => this.hasProducts));
|
431
|
+
return this.quoteSubj$.pipe(map$1(() => this.hasProducts));
|
309
432
|
}
|
310
433
|
get hasProducts() {
|
311
434
|
return Boolean(this.quoteSubj$.value?.currentState.length);
|
312
435
|
}
|
313
436
|
get hasAssets$() {
|
314
|
-
return this.assetsSubj$.pipe(map(() => this.hasAssets));
|
437
|
+
return this.assetsSubj$.pipe(map$1(() => this.hasAssets));
|
315
438
|
}
|
316
439
|
get hasAssets() {
|
317
440
|
return Boolean(this.assetsSubj$.value?.currentState.length);
|
@@ -319,11 +442,12 @@ class QuoteDraftService {
|
|
319
442
|
get assetsState() {
|
320
443
|
return this.assetsSubj$.value;
|
321
444
|
}
|
322
|
-
constructor(context, flowInfoService, accountApiService, quoteApiService) {
|
445
|
+
constructor(context, flowInfoService, accountApiService, quoteApiService, runtimeSettingsService) {
|
323
446
|
this.context = context;
|
324
447
|
this.flowInfoService = flowInfoService;
|
325
448
|
this.accountApiService = accountApiService;
|
326
449
|
this.quoteApiService = quoteApiService;
|
450
|
+
this.runtimeSettingsService = runtimeSettingsService;
|
327
451
|
this.quoteSubj$ = new BehaviorSubject(null);
|
328
452
|
this.assetsSubj$ = new BehaviorSubject(null);
|
329
453
|
this.resetSubj$ = new BehaviorSubject(true);
|
@@ -332,7 +456,7 @@ class QuoteDraftService {
|
|
332
456
|
this._hasUnsavedChanges = false;
|
333
457
|
this.reset$ = this.resetSubj$.asObservable();
|
334
458
|
this.isInitializedSubj$
|
335
|
-
.pipe(filter(isInitialized => isInitialized), switchMap
|
459
|
+
.pipe(filter(isInitialized => isInitialized), switchMap(() => this.quoteSubj$.asObservable()), skip(1), tap$1(quote => this.markAsUpdated(quote)))
|
336
460
|
.subscribe();
|
337
461
|
}
|
338
462
|
reset() {
|
@@ -345,21 +469,30 @@ class QuoteDraftService {
|
|
345
469
|
init(headerId, params) {
|
346
470
|
const ctx = this.context.resolve();
|
347
471
|
const isAccountMode = this.context.mode === ConfigurationContextMode.ACCOUNT;
|
348
|
-
const accountId = isAccountMode ? headerId : ctx.properties
|
349
|
-
|
472
|
+
const accountId = isAccountMode ? headerId : ctx.properties?.AccountId;
|
473
|
+
const configurationSettings = this.runtimeSettingsService.configurationSettings;
|
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
|
350
480
|
? of(QuoteDraft.emptyQuote(ConfigurationContextMode.ACCOUNT))
|
351
|
-
: this.quoteApiService.getQuoteState(headerId, params)).pipe(tap(([assets, quote]) => {
|
481
|
+
: this.quoteApiService.getQuoteState(headerId, params)).pipe(tap$1(([assets, quote]) => {
|
352
482
|
if (assets) {
|
353
483
|
this.assetsSubj$.next(assets);
|
354
484
|
}
|
485
|
+
let context;
|
355
486
|
this.quoteSubj$.next(quote);
|
356
487
|
if (assets && isAccountMode) {
|
357
|
-
|
488
|
+
context = assets.context;
|
358
489
|
}
|
359
490
|
else {
|
360
|
-
|
491
|
+
context = quote.context;
|
361
492
|
}
|
362
|
-
|
493
|
+
this.context.update(context);
|
494
|
+
this.runtimeSettingsService.initCurrency(context.properties['CurrencyIsoCode']);
|
495
|
+
}), map$1(() => noop()), take(1));
|
363
496
|
}
|
364
497
|
finalizeInit() {
|
365
498
|
this.isInitialized = true;
|
@@ -408,7 +541,7 @@ class QuoteDraftService {
|
|
408
541
|
this.assetsSubj$.next(assetsState);
|
409
542
|
}
|
410
543
|
get quoteDraft$() {
|
411
|
-
return combineLatest([this.quoteSubj$, this.context.resolve$()]).pipe(map(() => this.quoteDraft), filter((quote) => Boolean(quote)), shareReplay());
|
544
|
+
return combineLatest([this.quoteSubj$, this.context.resolve$()]).pipe(map$1(() => this.quoteDraft), filter((quote) => Boolean(quote)), shareReplay());
|
412
545
|
}
|
413
546
|
get quoteDraft() {
|
414
547
|
const quote = this.quoteSubj$.value;
|
@@ -421,7 +554,7 @@ class QuoteDraftService {
|
|
421
554
|
};
|
422
555
|
}
|
423
556
|
get currentState$() {
|
424
|
-
return this.quoteDraft$.pipe(map(quote => quote.currentState));
|
557
|
+
return this.quoteDraft$.pipe(map$1(quote => quote.currentState));
|
425
558
|
}
|
426
559
|
get currentState() {
|
427
560
|
return this.quoteDraft?.currentState ?? [];
|
@@ -430,13 +563,13 @@ class QuoteDraftService {
|
|
430
563
|
return this.flowInfoService.flow?.properties.standalone ?? false;
|
431
564
|
}
|
432
565
|
get isStandalone$() {
|
433
|
-
return this.flowInfoService.flow$.pipe(map(() => this.isStandalone));
|
566
|
+
return this.flowInfoService.flow$.pipe(map$1(() => this.isStandalone));
|
434
567
|
}
|
435
568
|
getInitialCurrentState() {
|
436
569
|
return this.initialCurrentState;
|
437
570
|
}
|
438
571
|
isEditMode$() {
|
439
|
-
return this.context.resolve$().pipe(map(() => this.isEditMode()));
|
572
|
+
return this.context.resolve$().pipe(map$1(() => this.isEditMode()));
|
440
573
|
}
|
441
574
|
isEditMode() {
|
442
575
|
const context = this.context.resolve();
|
@@ -457,11 +590,11 @@ class QuoteDraftService {
|
|
457
590
|
}
|
458
591
|
}
|
459
592
|
}
|
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 });
|
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 }, { token: RuntimeSettingsService }], target: i0.ɵɵFactoryTarget.Injectable });
|
461
594
|
QuoteDraftService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: QuoteDraftService });
|
462
595
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: QuoteDraftService, decorators: [{
|
463
596
|
type: Injectable
|
464
|
-
}], ctorParameters: function () { return [{ type: ContextService }, { type: FlowInfoService }, { type: i1.AccountApiService }, { type: i1.QuoteApiService }]; } });
|
597
|
+
}], ctorParameters: function () { return [{ type: ContextService }, { type: FlowInfoService }, { type: i1.AccountApiService }, { type: i1.QuoteApiService }, { type: RuntimeSettingsService }]; } });
|
465
598
|
|
466
599
|
class FlowStateService {
|
467
600
|
constructor(contextService, quoteDraftService, flowInfoService, flowConfiguration, processorsApiService, flowStateApiService, quoteApiService, toastService, customizationService) {
|
@@ -492,55 +625,59 @@ class FlowStateService {
|
|
492
625
|
all subscriptions get their updates according to updated QuoteDraft
|
493
626
|
*/
|
494
627
|
this.isInitialized$()
|
495
|
-
.pipe(filter$1(Boolean), filter$1(() => !this.getFlowSafe().properties.stateful), switchMap(() => this.flowConfiguration.updated$), switchMap(() => this.executeRequest$({}, true)))
|
628
|
+
.pipe(filter$1(Boolean), filter$1(() => !this.getFlowSafe().properties.stateful), switchMap$1(() => this.flowConfiguration.updated$), switchMap$1(() => this.executeRequest$({}, true)))
|
496
629
|
.subscribe();
|
497
|
-
this.charges$ = this.flowInfoService.flow$.pipe(filter$1(isDefined), switchMap(() => {
|
630
|
+
this.charges$ = this.flowInfoService.flow$.pipe(filter$1(isDefined), switchMap$1(() => {
|
498
631
|
if (this.flowInfoService.isLegacy) {
|
499
|
-
return this.quoteDraftService.quoteDraft$.pipe(map
|
632
|
+
return this.quoteDraftService.quoteDraft$.pipe(map(quoteDraft => quoteDraft.charges));
|
500
633
|
}
|
501
634
|
else {
|
502
635
|
return this.subscribe$(UITemplateType.FLOW_ENGINE, 'CHARGES', null, {
|
503
636
|
cold: true,
|
504
|
-
}).pipe(map
|
637
|
+
}).pipe(map(response => (response.success ? response.result : {})));
|
505
638
|
}
|
506
639
|
}), shareReplay$1(1));
|
507
640
|
this.charges$.subscribe();
|
508
|
-
this.pricePlans$ = this.flowInfoService.flow$.pipe(filter$1(isDefined), switchMap(() => {
|
641
|
+
this.pricePlans$ = this.flowInfoService.flow$.pipe(filter$1(isDefined), switchMap$1(() => {
|
509
642
|
if (this.flowInfoService.isLegacy) {
|
510
|
-
return this.quoteDraftService.quoteDraft$.pipe(map
|
643
|
+
return this.quoteDraftService.quoteDraft$.pipe(map(quoteDraft => quoteDraft.pricePlans));
|
511
644
|
}
|
512
645
|
else {
|
513
646
|
return this.subscribe$(UITemplateType.FLOW_ENGINE, 'PRICE_PLANS', null, {
|
514
647
|
cold: true,
|
515
|
-
}).pipe(map
|
648
|
+
}).pipe(map(response => (response.success ? response.result : {})));
|
516
649
|
}
|
517
650
|
}), shareReplay$1(1));
|
518
651
|
this.pricePlans$.subscribe();
|
519
|
-
this.activeMetrics$ = this.flowInfoService.flow$.pipe(filter$1(isDefined), switchMap(() => {
|
652
|
+
this.activeMetrics$ = this.flowInfoService.flow$.pipe(filter$1(isDefined), switchMap$1(() => {
|
520
653
|
if (this.flowInfoService.isLegacy) {
|
521
|
-
return this.quoteDraftService.quoteDraft$.pipe(map
|
654
|
+
return this.quoteDraftService.quoteDraft$.pipe(map(quoteDraft => quoteDraft.activeMetrics));
|
522
655
|
}
|
523
656
|
else {
|
524
657
|
return this.subscribe$(UITemplateType.FLOW_ENGINE, 'ACTIVE_METRICS', null, {
|
525
658
|
cold: true,
|
526
|
-
}).pipe(map
|
659
|
+
}).pipe(map(response => (response.success ? response.result : [])));
|
527
660
|
}
|
528
661
|
}), shareReplay$1(1));
|
529
662
|
this.activeMetrics$.subscribe();
|
530
|
-
this.isPriceListLocked$ = this.flowInfoService.flow$.pipe(filter$1(isDefined), switchMap(() => {
|
663
|
+
this.isPriceListLocked$ = this.flowInfoService.flow$.pipe(filter$1(isDefined), switchMap$1(() => {
|
531
664
|
if (this.flowInfoService.isLegacy) {
|
532
665
|
return of(false);
|
533
666
|
}
|
534
667
|
else {
|
535
668
|
return this.subscribe$(UITemplateType.FLOW_ENGINE, 'IS_PRICE_LIST_LOCKED', null, {
|
536
669
|
cold: true,
|
537
|
-
}).pipe(map
|
670
|
+
}).pipe(map(response => (response.success ? response.result : false)));
|
538
671
|
}
|
539
672
|
}), shareReplay$1(1));
|
540
673
|
this.isPriceListLocked$.subscribe();
|
541
674
|
}
|
542
675
|
init$() {
|
543
|
-
|
676
|
+
let processors$ = this.initProcessors$();
|
677
|
+
if (this.flowInfoService.isLegacy) {
|
678
|
+
processors$ = of(undefined);
|
679
|
+
}
|
680
|
+
return processors$.pipe(switchMap$1(() => {
|
544
681
|
if (this.getFlowSafe().properties.stateful) {
|
545
682
|
return this.initStateful$();
|
546
683
|
}
|
@@ -572,14 +709,14 @@ class FlowStateService {
|
|
572
709
|
return this.executionInProgress$.asObservable();
|
573
710
|
}
|
574
711
|
isInitialized$() {
|
575
|
-
return combineLatest([this.stateId$, this.quoteDraftService.isInitialized$]).pipe(map
|
712
|
+
return combineLatest([this.stateId$, this.quoteDraftService.isInitialized$]).pipe(map(values => values.some(Boolean)));
|
576
713
|
}
|
577
714
|
isInitialized() {
|
578
715
|
return Boolean(this.stateId$.value) || this.quoteDraftService.isInitialized;
|
579
716
|
}
|
580
717
|
execute$(scope, exec) {
|
581
718
|
const request = this.execToRequest(scope, exec);
|
582
|
-
return this.executeRequest$(request).pipe(map
|
719
|
+
return this.executeRequest$(request).pipe(map(result => {
|
583
720
|
// Keep only requested results
|
584
721
|
const actualSelectors = Object.entries(result.selectors).reduce((trunk, [requestId, result]) => {
|
585
722
|
if (exec.selectors?.[requestId]) {
|
@@ -591,11 +728,14 @@ class FlowStateService {
|
|
591
728
|
}));
|
592
729
|
}
|
593
730
|
dispatch$(scope, action, inputData) {
|
731
|
+
if (this.flowInfoService.isLegacy) {
|
732
|
+
return of(undefined);
|
733
|
+
}
|
594
734
|
const exec = {
|
595
735
|
actions: [{ name: action, inputData }],
|
596
736
|
};
|
597
737
|
const request = this.execToRequest(scope, exec);
|
598
|
-
return this.executeRequest$(request).pipe(map
|
738
|
+
return this.executeRequest$(request).pipe(map(noop));
|
599
739
|
}
|
600
740
|
select$(scope, selectorName, inputData) {
|
601
741
|
const requestId = this.generateRequestId(scope, selectorName, inputData);
|
@@ -607,9 +747,15 @@ class FlowStateService {
|
|
607
747
|
},
|
608
748
|
},
|
609
749
|
});
|
610
|
-
return this.executeRequest$(request).pipe(map
|
750
|
+
return this.executeRequest$(request).pipe(map(response => response.selectors[requestId]));
|
611
751
|
}
|
612
752
|
subscribe$(scope, selectorName, inputData, options) {
|
753
|
+
if (this.flowInfoService.isLegacy) {
|
754
|
+
return of({
|
755
|
+
success: false,
|
756
|
+
errorMessage: '',
|
757
|
+
});
|
758
|
+
}
|
613
759
|
const requestId = this.generateRequestId(scope, selectorName, inputData);
|
614
760
|
let subscription = this.subscriptions[requestId];
|
615
761
|
if (!subscription) {
|
@@ -633,7 +779,7 @@ class FlowStateService {
|
|
633
779
|
this.executeRequest$(request).subscribe();
|
634
780
|
}
|
635
781
|
}
|
636
|
-
return subscription.data$.pipe(filter$1(data => data != this.NOT_INITIALIZED), map
|
782
|
+
return subscription.data$.pipe(filter$1(data => data != this.NOT_INITIALIZED), map(data => data), finalize(() => {
|
637
783
|
if (!this.subscriptions[requestId]?.data$.observed) {
|
638
784
|
delete this.subscriptions[requestId];
|
639
785
|
}
|
@@ -642,7 +788,7 @@ class FlowStateService {
|
|
642
788
|
save$() {
|
643
789
|
if (this.getFlowSafe().properties.stateful) {
|
644
790
|
if (this.stateId$.value) {
|
645
|
-
return this.flowStateApiService.save(this.stateId$.value).pipe(tap
|
791
|
+
return this.flowStateApiService.save(this.stateId$.value).pipe(tap(() => {
|
646
792
|
Array.from(this.trackedStatefulChangesMap.keys()).forEach(key => {
|
647
793
|
this.trackedStatefulChangesMap.set(key, false);
|
648
794
|
});
|
@@ -652,8 +798,8 @@ class FlowStateService {
|
|
652
798
|
else {
|
653
799
|
const quoteDraft = this.quoteDraftService.quoteDraft;
|
654
800
|
if (quoteDraft) {
|
655
|
-
return this.quoteApiService.upsertQuote(quoteDraft).pipe(tap
|
656
|
-
this.contextService.update({ properties: { ConfigurationId:
|
801
|
+
return this.quoteApiService.upsertQuote(quoteDraft).pipe(tap(({ versionId }) => {
|
802
|
+
this.contextService.update({ properties: { ConfigurationId: versionId } });
|
657
803
|
}));
|
658
804
|
}
|
659
805
|
}
|
@@ -668,8 +814,8 @@ class FlowStateService {
|
|
668
814
|
else {
|
669
815
|
const quoteDraft = this.quoteDraftService.quoteDraft;
|
670
816
|
if (quoteDraft) {
|
671
|
-
return this.quoteApiService.submitQuote(quoteDraft).pipe(tap
|
672
|
-
this.contextService.update({ properties: { ConfigurationId:
|
817
|
+
return this.quoteApiService.submitQuote(quoteDraft).pipe(tap(({ versionId }) => {
|
818
|
+
this.contextService.update({ properties: { ConfigurationId: versionId } });
|
673
819
|
}));
|
674
820
|
}
|
675
821
|
}
|
@@ -714,7 +860,7 @@ class FlowStateService {
|
|
714
860
|
const execution$ = this.getFlowSafe().properties.stateful
|
715
861
|
? this.executeStateful$(fullRequest)
|
716
862
|
: this.executeStateless$(fullRequest);
|
717
|
-
return execution$.pipe(tap
|
863
|
+
return execution$.pipe(tap(result => this.handleSelectorsResponse(result.selectors)));
|
718
864
|
}
|
719
865
|
handleSelectorsResponse(selectors) {
|
720
866
|
Object.entries(selectors).forEach(([requestId, selectorResult]) => {
|
@@ -731,7 +877,7 @@ class FlowStateService {
|
|
731
877
|
initStateful$() {
|
732
878
|
// Subscriptions
|
733
879
|
this.subscribe$(UITemplateType.FLOW_ENGINE, 'CONTEXT', null, { cold: true })
|
734
|
-
.pipe(tap
|
880
|
+
.pipe(tap(response => {
|
735
881
|
if (response.success) {
|
736
882
|
this.contextService.update(response.result);
|
737
883
|
}
|
@@ -753,13 +899,13 @@ class FlowStateService {
|
|
753
899
|
selectors: { ...selectors, ...request.selectors },
|
754
900
|
actions: request.actions,
|
755
901
|
})
|
756
|
-
.pipe(map
|
902
|
+
.pipe(map(({ stateId, selectors }) => {
|
757
903
|
this.handleSelectorsResponse(selectors);
|
758
904
|
this.stateId$.next(stateId);
|
759
905
|
}));
|
760
906
|
}
|
761
907
|
initBufferedRequest$() {
|
762
|
-
return this.statefulRequestStream$.pipe(buffer(this.statefulRequestStream$.pipe(debounceTime(this.EXECUTION_BUFFER_TIME))), switchMap(requests => {
|
908
|
+
return this.statefulRequestStream$.pipe(buffer(this.statefulRequestStream$.pipe(debounceTime(this.EXECUTION_BUFFER_TIME))), switchMap$1(requests => {
|
763
909
|
if (!this.stateId$.value) {
|
764
910
|
throw 'Stateful session is not initialized';
|
765
911
|
}
|
@@ -773,32 +919,32 @@ class FlowStateService {
|
|
773
919
|
};
|
774
920
|
this.executionInProgress$.next(true);
|
775
921
|
return this.flowStateApiService.execute(this.stateId$.value, request);
|
776
|
-
}), tap
|
922
|
+
}), tap(({ stateId }) => this.stateId$.next(stateId)), share(), tap(() => this.executionInProgress$.next(false)), catchError(e => {
|
777
923
|
this.executionInProgress$.next(false);
|
778
924
|
return throwError(() => e);
|
779
925
|
}));
|
780
926
|
}
|
781
927
|
executeStateful$(request) {
|
782
|
-
return this.executionInProgress$.pipe(filter$1(inProgress => !inProgress), take$1(1), switchMap(() =>
|
928
|
+
return this.executionInProgress$.pipe(filter$1(inProgress => !inProgress), take$1(1), switchMap$1(() =>
|
783
929
|
// make sure stream switches to statefulExecutionRequest$ before pushing an execution request
|
784
930
|
combineLatest([
|
785
931
|
this.statefulExecutionRequest$,
|
786
|
-
of(undefined).pipe(tap
|
787
|
-
])), map
|
932
|
+
of(undefined).pipe(tap(() => this.statefulRequestStream$.next(request))),
|
933
|
+
])), map(([response]) => response), take$1(1));
|
788
934
|
}
|
789
935
|
initStateless$() {
|
790
936
|
const { headerId } = this.contextService.resolve();
|
791
|
-
return this.quoteDraftService.init(headerId, this.flowInfoService.params ?? {}).pipe(tap
|
937
|
+
return this.quoteDraftService.init(headerId, this.flowInfoService.params ?? {}).pipe(tap(() => {
|
792
938
|
const assets = this.quoteDraftService.assetsState;
|
793
939
|
if (assets) {
|
794
940
|
this.flowStore = { ...this.flowStore, assets };
|
795
941
|
}
|
796
|
-
}), switchMap(() => {
|
942
|
+
}), switchMap$1(() => {
|
797
943
|
if (this.flowInfoService.isLegacy) {
|
798
944
|
return of(null);
|
799
945
|
}
|
800
946
|
return this.executeRequest$(this.getDefaultExecutionRequestDTO());
|
801
|
-
}), switchMap(() => this.calculate$()), tap
|
947
|
+
}), switchMap$1(() => this.calculate$()), tap(() => this.quoteDraftService.finalizeInit()), map(noop));
|
802
948
|
}
|
803
949
|
calculate$() {
|
804
950
|
const flowState = this.quoteDraftService.quoteDraft;
|
@@ -821,7 +967,7 @@ class FlowStateService {
|
|
821
967
|
}
|
822
968
|
executeStateless$(request) {
|
823
969
|
this.executionInProgress$.next(true);
|
824
|
-
return of(undefined).pipe(tap
|
970
|
+
return of(undefined).pipe(tap(() => this.executeStatelessActions(request)), switchMap$1(() => {
|
825
971
|
/*
|
826
972
|
Skip price calculation in case
|
827
973
|
1. No actions in the request
|
@@ -833,7 +979,7 @@ class FlowStateService {
|
|
833
979
|
else {
|
834
980
|
return this.calculate$();
|
835
981
|
}
|
836
|
-
}), map
|
982
|
+
}), map(() => this.executeStatelessSelectors(request)), tap(() => this.executionInProgress$.next(false)), catchError(e => {
|
837
983
|
this.executionInProgress$.next(false);
|
838
984
|
return throwError(() => e);
|
839
985
|
}));
|
@@ -896,7 +1042,7 @@ class FlowStateService {
|
|
896
1042
|
return;
|
897
1043
|
}
|
898
1044
|
const localProcessors$ = this.customizationService?.getTemplateConfigurationProcessors?.(template.name) ?? of(null);
|
899
|
-
return localProcessors$.pipe(switchMap(processors => processors ? of(processors) : this.processorsApiService.fetchConfigurationProcessors$(template.id)), tap
|
1045
|
+
return localProcessors$.pipe(switchMap$1(processors => processors ? of(processors) : this.processorsApiService.fetchConfigurationProcessors$(template.id)), tap(processors => {
|
900
1046
|
const processorsMap = processors.reduce((acc, p) => {
|
901
1047
|
acc[p.apiName] = p;
|
902
1048
|
return acc;
|
@@ -908,7 +1054,7 @@ class FlowStateService {
|
|
908
1054
|
if (!owners$.length) {
|
909
1055
|
return of(undefined);
|
910
1056
|
}
|
911
|
-
return forkJoin(owners$).pipe(map
|
1057
|
+
return forkJoin(owners$).pipe(map(noop));
|
912
1058
|
}
|
913
1059
|
executeActionScript(request, executable) {
|
914
1060
|
const configurationProcessor = this.processors[executable.ownerId]?.[executable.apiName];
|
@@ -1191,111 +1337,6 @@ var lineItem_utils = /*#__PURE__*/Object.freeze({
|
|
1191
1337
|
upsertAttributes: upsertAttributes
|
1192
1338
|
});
|
1193
1339
|
|
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
1340
|
class LineItemWorker {
|
1300
1341
|
constructor(src) {
|
1301
1342
|
this.li = { ...src };
|
@@ -1359,7 +1400,7 @@ class ConfigurationService {
|
|
1359
1400
|
const prevState = this.configurationState.value;
|
1360
1401
|
this.configurationState.next(prevState ? { ...prevState } : null);
|
1361
1402
|
return throwError(() => error);
|
1362
|
-
}), tap(() => {
|
1403
|
+
}), tap$1(() => {
|
1363
1404
|
if (!this.hasUnsavedChanges) {
|
1364
1405
|
this.hasUnsavedChanges = true;
|
1365
1406
|
}
|
@@ -1372,7 +1413,7 @@ class ConfigurationService {
|
|
1372
1413
|
this.configurableRamp = lineItem;
|
1373
1414
|
}
|
1374
1415
|
get() {
|
1375
|
-
return this.configurationState.pipe(map(state => state?.lineItem), shareReplay$1());
|
1416
|
+
return this.configurationState.pipe(map$1(state => state?.lineItem), shareReplay$1());
|
1376
1417
|
}
|
1377
1418
|
getSnapshot() {
|
1378
1419
|
return this.configurationState.value?.lineItem ? { ...this.configurationState.value?.lineItem } : undefined;
|
@@ -1404,19 +1445,19 @@ class ConfigurationService {
|
|
1404
1445
|
return this.contextService.resolve$();
|
1405
1446
|
}
|
1406
1447
|
get charges$() {
|
1407
|
-
return this.configurationState.pipe(map(state => state?.charges ?? {}));
|
1448
|
+
return this.configurationState.pipe(map$1(state => state?.charges ?? {}));
|
1408
1449
|
}
|
1409
1450
|
get chargesSnapshot() {
|
1410
1451
|
return this.configurationState.value?.charges ?? {};
|
1411
1452
|
}
|
1412
1453
|
get pricePlans$() {
|
1413
|
-
return this.configurationState.pipe(map(state => state?.pricePlans ?? {}));
|
1454
|
+
return this.configurationState.pipe(map$1(state => state?.pricePlans ?? {}));
|
1414
1455
|
}
|
1415
1456
|
get pricePlansSnapshot() {
|
1416
1457
|
return this.configurationState.value?.pricePlans ?? {};
|
1417
1458
|
}
|
1418
1459
|
get procedureContext$() {
|
1419
|
-
return this.configurationState.pipe(map(state => state?.procedureContext ?? {}));
|
1460
|
+
return this.configurationState.pipe(map$1(state => state?.procedureContext ?? {}));
|
1420
1461
|
}
|
1421
1462
|
get procedureContextSnapshot() {
|
1422
1463
|
return this.configurationState.value?.procedureContext ?? {};
|
@@ -1430,7 +1471,7 @@ class ConfigurationService {
|
|
1430
1471
|
const uiDefinitionProperties = this.getUIDefinitionProperties();
|
1431
1472
|
const mainPricingEnabled = runtimeContext.properties?.PricingEnabled;
|
1432
1473
|
const pricingEnabled = mainPricingEnabled ? mainPricingEnabled === 'true' : uiDefinitionProperties.pricingEnabled;
|
1433
|
-
const customPriceApi = this.runtimeSettings.
|
1474
|
+
const customPriceApi = this.runtimeSettings.configurationSettings['CUSTOM_PRICE_API'];
|
1434
1475
|
this.isLoadingSubj$.next(true);
|
1435
1476
|
const configure$ = pricingEnabled && customPriceApi
|
1436
1477
|
? this.configurationApiService.customConfigurePrice({ url: customPriceApi, configurationRequest, runtimeModel })
|
@@ -1439,14 +1480,14 @@ class ConfigurationService {
|
|
1439
1480
|
runtimeModel,
|
1440
1481
|
pricingEnabled,
|
1441
1482
|
});
|
1442
|
-
return configure$.pipe(tap(result => {
|
1483
|
+
return configure$.pipe(tap$1(result => {
|
1443
1484
|
this.contextService.update(result.context);
|
1444
1485
|
this.configurationState.next(result);
|
1445
1486
|
if (result.deletedLineItems?.length) {
|
1446
1487
|
this.showInactiveProductsConfirmation();
|
1447
1488
|
}
|
1448
1489
|
this.configurableRamp = result.lineItem;
|
1449
|
-
}), map(({ lineItem }) => lineItem), catchError$1(error => throwError(() => {
|
1490
|
+
}), map$1(({ lineItem }) => lineItem), catchError$1(error => throwError(() => {
|
1450
1491
|
if (error.error) {
|
1451
1492
|
return extractErrorDetails(error.error).join('. ');
|
1452
1493
|
}
|
@@ -1456,7 +1497,7 @@ class ConfigurationService {
|
|
1456
1497
|
configureExternal$(props) {
|
1457
1498
|
return this.runtimeService
|
1458
1499
|
.init({ productId: props.productId, defaultQty: props.qty, attributesMap: props.attributesMap })
|
1459
|
-
.pipe(switchMap
|
1500
|
+
.pipe(switchMap(() => this.configure()), first(), catchError$1(error => {
|
1460
1501
|
this.messageService.add({ severity: ToastType.error, summary: error });
|
1461
1502
|
throw error;
|
1462
1503
|
}), finalize$1(() => this.reset()));
|
@@ -1692,14 +1733,14 @@ class FlowConfigurationService {
|
|
1692
1733
|
this.updated$ = this.updatedSubj$.asObservable();
|
1693
1734
|
}
|
1694
1735
|
calculate$(quoteDraft) {
|
1695
|
-
return this.proceduresApiService.apply$(quoteDraft).pipe(tap
|
1736
|
+
return this.proceduresApiService.apply$(quoteDraft).pipe(tap(result => {
|
1696
1737
|
// sort the result current state based on the quote draft initial state
|
1697
1738
|
const initialStateIds = quoteDraft.initialState.map(lineItem => lineItem.integrationId);
|
1698
1739
|
result.currentState = result.currentState
|
1699
1740
|
.slice()
|
1700
1741
|
.sort((a, b) => initialStateIds.indexOf(a.integrationId) - initialStateIds.indexOf(b.integrationId));
|
1701
1742
|
this.quoteDraftService.updateQuoteDraft(result);
|
1702
|
-
}), map
|
1743
|
+
}), map(noop));
|
1703
1744
|
}
|
1704
1745
|
calculate(quoteDraft) {
|
1705
1746
|
this.calculate$(quoteDraft).subscribe();
|
@@ -1709,11 +1750,11 @@ class FlowConfigurationService {
|
|
1709
1750
|
if (!quoteDraft) {
|
1710
1751
|
return of(null);
|
1711
1752
|
}
|
1712
|
-
return of([]).pipe(map
|
1753
|
+
return of([]).pipe(map(() => {
|
1713
1754
|
const updatedState = cloneDeep(quoteDraft.currentState);
|
1714
1755
|
this.updateService.update(updatedState, updates, quoteDraft.charges);
|
1715
1756
|
return updatedState;
|
1716
|
-
}), switchMap(updatedState => this.calculate$({ ...quoteDraft, currentState: updatedState })), map
|
1757
|
+
}), switchMap$1(updatedState => this.calculate$({ ...quoteDraft, currentState: updatedState })), map(() => this.quoteDraftService.quoteDraft), tap(() => this.updatedSubj$.next()), this.handleErrorAndBounceBack());
|
1717
1758
|
}
|
1718
1759
|
update(updates) {
|
1719
1760
|
this.update$(updates).subscribe();
|
@@ -1730,9 +1771,9 @@ class FlowConfigurationService {
|
|
1730
1771
|
}
|
1731
1772
|
const updatedState = cloneDeep(currentState);
|
1732
1773
|
updatedState.splice(currentLineItemIndex, 1, initialLineItem);
|
1733
|
-
return of([]).pipe(tap
|
1774
|
+
return of([]).pipe(tap(() => {
|
1734
1775
|
this.quoteDraftService.setCurrentLineItemState(updatedState);
|
1735
|
-
}), switchMap(() => this.calculate$({ ...quoteDraft, currentState: updatedState })), map
|
1776
|
+
}), switchMap$1(() => this.calculate$({ ...quoteDraft, currentState: updatedState })), map(() => this.quoteDraftService.quoteDraft), tap(() => this.updatedSubj$.next()), this.handleErrorAndBounceBack());
|
1736
1777
|
}
|
1737
1778
|
revert(lineItemId) {
|
1738
1779
|
this.revert$(lineItemId).subscribe();
|
@@ -1743,7 +1784,7 @@ class FlowConfigurationService {
|
|
1743
1784
|
if (!quoteDraft) {
|
1744
1785
|
return of(null);
|
1745
1786
|
}
|
1746
|
-
return of([]).pipe(map
|
1787
|
+
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());
|
1747
1788
|
}
|
1748
1789
|
delete(ids) {
|
1749
1790
|
this.delete$(ids).subscribe();
|
@@ -1754,34 +1795,34 @@ class FlowConfigurationService {
|
|
1754
1795
|
return of(null);
|
1755
1796
|
}
|
1756
1797
|
const updatedState = [...quoteDraft.currentState, term];
|
1757
|
-
return of([]).pipe(switchMap(() => this.calculate$({ ...quoteDraft, currentState: updatedState })), map
|
1798
|
+
return of([]).pipe(switchMap$1(() => this.calculate$({ ...quoteDraft, currentState: updatedState })), map(() => this.quoteDraftService.quoteDraft), tap(() => this.updatedSubj$.next()), this.handleErrorAndBounceBack());
|
1758
1799
|
}
|
1759
1800
|
addToCart$(props) {
|
1760
1801
|
const quoteDraft = this.quoteDraftService.quoteDraft;
|
1761
1802
|
if (!quoteDraft) {
|
1762
1803
|
return of(null);
|
1763
1804
|
}
|
1764
|
-
return this.configurationService.configureExternal$(props).pipe(map
|
1805
|
+
return this.configurationService.configureExternal$(props).pipe(map(lineItem => {
|
1765
1806
|
const model = this.configurationService.getRuntimeModel();
|
1766
1807
|
const split = model?.types.find(type => type.name === lineItem.type)?.split ?? false;
|
1767
1808
|
const lineItems = multiplyLineItems(lineItem, props.qty ?? 1, split);
|
1768
1809
|
return [...quoteDraft.currentState, ...lineItems];
|
1769
|
-
}), switchMap(updatedState => this.calculate$({ ...quoteDraft, currentState: updatedState })), map
|
1810
|
+
}), switchMap$1(updatedState => this.calculate$({ ...quoteDraft, currentState: updatedState })), map(() => this.quoteDraftService.quoteDraft), tap(() => this.updatedSubj$.next()), this.handleErrorAndBounceBack());
|
1770
1811
|
}
|
1771
1812
|
get() {
|
1772
|
-
return this.quoteDraftService.quoteDraft$.pipe(map
|
1813
|
+
return this.quoteDraftService.quoteDraft$.pipe(map(() => this.quoteDraftService.currentState), shareReplay$1());
|
1773
1814
|
}
|
1774
1815
|
getSnapshot() {
|
1775
1816
|
return this.quoteDraftService?.currentState.slice() ?? [];
|
1776
1817
|
}
|
1777
1818
|
get charges$() {
|
1778
|
-
return this.quoteDraftService.quoteDraft$.pipe(map
|
1819
|
+
return this.quoteDraftService.quoteDraft$.pipe(map(({ charges }) => charges));
|
1779
1820
|
}
|
1780
1821
|
get pricePlans$() {
|
1781
|
-
return this.quoteDraftService.quoteDraft$.pipe(map
|
1822
|
+
return this.quoteDraftService.quoteDraft$.pipe(map(({ pricePlans }) => pricePlans));
|
1782
1823
|
}
|
1783
1824
|
get activeMetrics$() {
|
1784
|
-
return this.quoteDraftService.quoteDraft$.pipe(map
|
1825
|
+
return this.quoteDraftService.quoteDraft$.pipe(map(({ activeMetrics }) => activeMetrics));
|
1785
1826
|
}
|
1786
1827
|
get chargesSnapshot() {
|
1787
1828
|
return this.quoteDraftService.quoteDraft?.charges ?? {};
|
@@ -1853,18 +1894,18 @@ class FlowStateConfigurationService {
|
|
1853
1894
|
}
|
1854
1895
|
else {
|
1855
1896
|
const lineItem = generateConfigurationLineItem(props, props.qty);
|
1856
|
-
request$ = this.flowStateApiService.newConfiguration(stateId, { lineItem }).pipe(tap
|
1897
|
+
request$ = this.flowStateApiService.newConfiguration(stateId, { lineItem }).pipe(tap(r => this.configurationStateId$.next(r.stateId)), switchMap$1(() => {
|
1857
1898
|
if (!this.configurationStateId) {
|
1858
1899
|
return of();
|
1859
1900
|
}
|
1860
|
-
return this.flowStateApiService.saveConfiguration(stateId, this.configurationStateId).pipe(tap
|
1901
|
+
return this.flowStateApiService.saveConfiguration(stateId, this.configurationStateId).pipe(tap(() => this.configurationStateId$.next(null)), map(noop));
|
1861
1902
|
}));
|
1862
1903
|
}
|
1863
1904
|
}
|
1864
1905
|
else {
|
1865
|
-
request$ = this.flowConfigurationService.addToCart$(props).pipe(map
|
1906
|
+
request$ = this.flowConfigurationService.addToCart$(props).pipe(map(noop));
|
1866
1907
|
}
|
1867
|
-
return request$.pipe(switchMap(() => this.flowStateService.executeRequest$({}, true)), map
|
1908
|
+
return request$.pipe(switchMap$1(() => this.flowStateService.executeRequest$({}, true)), map(noop));
|
1868
1909
|
}
|
1869
1910
|
}
|
1870
1911
|
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 });
|
@@ -1891,7 +1932,7 @@ class IntegrationState {
|
|
1891
1932
|
this.action$.next(action);
|
1892
1933
|
}
|
1893
1934
|
listen$(actionType) {
|
1894
|
-
return this.action$.pipe(filter$1(action => action.type === actionType), map
|
1935
|
+
return this.action$.pipe(filter$1(action => action.type === actionType), map(action => action.payload));
|
1895
1936
|
}
|
1896
1937
|
listenAll$() {
|
1897
1938
|
return this.action$.asObservable();
|
@@ -1916,12 +1957,12 @@ class ProductImagesService {
|
|
1916
1957
|
this.imagesMap$.next({ ...this.imagesMap$.value, [productId]: '' });
|
1917
1958
|
this.fetchProductImage(productId);
|
1918
1959
|
}
|
1919
|
-
return this.imagesMap$.pipe(map
|
1960
|
+
return this.imagesMap$.pipe(map(imagesMap => imagesMap[productId] ?? null), distinctUntilChanged());
|
1920
1961
|
}
|
1921
1962
|
fetchProductImage(productId) {
|
1922
1963
|
this.productApiService
|
1923
1964
|
.fetchImage$(productId)
|
1924
|
-
.pipe(map
|
1965
|
+
.pipe(map(file => URL.createObjectURL(file)), catchError(() => of('')), tap(url => this.imagesMap$.next({ ...this.imagesMap$.value, [productId]: url })))
|
1925
1966
|
.subscribe();
|
1926
1967
|
}
|
1927
1968
|
}
|
@@ -1936,7 +1977,7 @@ class RuntimeContextService {
|
|
1936
1977
|
this.configurationApiService = configurationApiService;
|
1937
1978
|
}
|
1938
1979
|
getRuntimeContext(productId, offeringId) {
|
1939
|
-
return this.configurationApiService.getRuntimeDataByProductId(productId, offeringId).pipe(map(runtimeData => {
|
1980
|
+
return this.configurationApiService.getRuntimeDataByProductId(productId, offeringId).pipe(map$1(runtimeData => {
|
1940
1981
|
const uiDefinitionContainer = this.getUIDefinitionContainer(runtimeData);
|
1941
1982
|
const runtimeModel = RuntimeModel.create(runtimeData.types, runtimeData.products);
|
1942
1983
|
const { productName, properties } = Array.from(runtimeModel.components.values()).find(c => c.productId === productId) ?? {};
|
@@ -1987,7 +2028,7 @@ class ConfigurationRuntimeService {
|
|
1987
2028
|
return combineLatest([
|
1988
2029
|
this.apiService.getRuntimeDataByModelId(uiDefinitionContainer.modelId),
|
1989
2030
|
this.contextService.initTestMode(),
|
1990
|
-
]).pipe(first(), map(([runtimeData, context]) => {
|
2031
|
+
]).pipe(first(), map$1(([runtimeData, context]) => {
|
1991
2032
|
this.contextService.update({
|
1992
2033
|
properties: {
|
1993
2034
|
...this.runtimeContext?.properties,
|
@@ -2006,12 +2047,12 @@ class ConfigurationRuntimeService {
|
|
2006
2047
|
uiDefinitionContainer,
|
2007
2048
|
};
|
2008
2049
|
return this._runtimeContext;
|
2009
|
-
}), tap(() => (this._isInitialized = true)));
|
2050
|
+
}), tap$1(() => (this._isInitialized = true)));
|
2010
2051
|
}
|
2011
2052
|
init(props) {
|
2012
2053
|
this.initializationProps = props;
|
2013
2054
|
const context = this.contextService.resolve();
|
2014
|
-
return this.runtimeContextService.getRuntimeContext(props.productId, props.offeringId).pipe(tap(runtimeContext => {
|
2055
|
+
return this.runtimeContextService.getRuntimeContext(props.productId, props.offeringId).pipe(tap$1(runtimeContext => {
|
2015
2056
|
this.uiDefinitionProperties = runtimeContext.uiDefinitionContainer?.source.properties ?? {};
|
2016
2057
|
const { PriceListId } = context.properties ?? {};
|
2017
2058
|
const mergeContext = {
|
@@ -2033,7 +2074,7 @@ class ConfigurationRuntimeService {
|
|
2033
2074
|
});
|
2034
2075
|
}
|
2035
2076
|
return this._runtimeContext;
|
2036
|
-
}), tap(() => (this._isInitialized = true)));
|
2077
|
+
}), tap$1(() => (this._isInitialized = true)));
|
2037
2078
|
}
|
2038
2079
|
overrideUIDefinition(uiDefinitionContainer) {
|
2039
2080
|
if (!this._runtimeContext) {
|
@@ -2089,6 +2130,7 @@ class ConfigurationStateService {
|
|
2089
2130
|
this.configurationStore = {};
|
2090
2131
|
this.executionInProgress$ = new BehaviorSubject(false);
|
2091
2132
|
this.statefulRequestStream$ = new Subject();
|
2133
|
+
this.statelessExecutionRequest$ = null;
|
2092
2134
|
this.statefulExecutionRequest$ = this.initBufferedRequest$();
|
2093
2135
|
}
|
2094
2136
|
get isExecutionInProgress$() {
|
@@ -2119,7 +2161,7 @@ class ConfigurationStateService {
|
|
2119
2161
|
}
|
2120
2162
|
execute$(exec) {
|
2121
2163
|
const request = this.execToRequest(exec);
|
2122
|
-
return this.executeRequest$(request).pipe(map
|
2164
|
+
return this.executeRequest$(request).pipe(map(result => {
|
2123
2165
|
// Keep only requested results
|
2124
2166
|
const actualSelectors = Object.entries(result.selectors).reduce((trunk, [requestId, result]) => {
|
2125
2167
|
if (exec.selectors?.[requestId]) {
|
@@ -2135,7 +2177,15 @@ class ConfigurationStateService {
|
|
2135
2177
|
actions: [{ name: actionName, inputData }],
|
2136
2178
|
};
|
2137
2179
|
const request = this.execToRequest(exec);
|
2138
|
-
|
2180
|
+
const executionRequest$ = this.executeRequest$(request);
|
2181
|
+
if (this.isStatefulConfiguration) {
|
2182
|
+
return executionRequest$;
|
2183
|
+
}
|
2184
|
+
// prevent parallel configuration requests in stateless mode
|
2185
|
+
if (!this.statelessExecutionRequest$) {
|
2186
|
+
this.statelessExecutionRequest$ = executionRequest$.pipe(shareReplay$1(), take$1(1), finalize(() => (this.statelessExecutionRequest$ = null)));
|
2187
|
+
}
|
2188
|
+
return this.statelessExecutionRequest$;
|
2139
2189
|
}
|
2140
2190
|
select$(selectorName, inputData = {}) {
|
2141
2191
|
const requestId = UUID.UUID();
|
@@ -2147,7 +2197,7 @@ class ConfigurationStateService {
|
|
2147
2197
|
},
|
2148
2198
|
},
|
2149
2199
|
});
|
2150
|
-
return this.executeRequest$(request).pipe(map
|
2200
|
+
return this.executeRequest$(request).pipe(map(response => response.selectors[requestId]));
|
2151
2201
|
}
|
2152
2202
|
subscribe$(selectorName, inputData = {}, options) {
|
2153
2203
|
const requestId = UUID.UUID();
|
@@ -2170,7 +2220,7 @@ class ConfigurationStateService {
|
|
2170
2220
|
this.executeRequest$(request).subscribe();
|
2171
2221
|
}
|
2172
2222
|
}
|
2173
|
-
return subscription.data$.pipe(filter$1(data => data != this.NOT_INITIALIZED), map
|
2223
|
+
return subscription.data$.pipe(filter$1(data => data != this.NOT_INITIALIZED), map(data => data), distinctUntilChanged(), finalize(() => {
|
2174
2224
|
if (!this.subscriptions[requestId]?.data$.observed) {
|
2175
2225
|
delete this.subscriptions[requestId];
|
2176
2226
|
}
|
@@ -2181,7 +2231,7 @@ class ConfigurationStateService {
|
|
2181
2231
|
if (this.isStatefulConfiguration) {
|
2182
2232
|
return this.flowStateApiService
|
2183
2233
|
.saveConfiguration(this.flowStateService.stateId ?? '', this.stateId ?? '')
|
2184
|
-
.pipe(switchMap(r => this.flowStateService.executeRequest$({}, true).pipe(map
|
2234
|
+
.pipe(switchMap$1(r => this.flowStateService.executeRequest$({}, true).pipe(map(() => r))));
|
2185
2235
|
}
|
2186
2236
|
else {
|
2187
2237
|
if (!flow) {
|
@@ -2218,7 +2268,7 @@ class ConfigurationStateService {
|
|
2218
2268
|
}
|
2219
2269
|
return this.flowConfigurationService
|
2220
2270
|
.calculate$({ ...quoteDraft, currentState, initialState })
|
2221
|
-
.pipe(map
|
2271
|
+
.pipe(map(() => ({ quoteId: '' })));
|
2222
2272
|
}
|
2223
2273
|
}
|
2224
2274
|
}
|
@@ -2261,13 +2311,13 @@ class ConfigurationStateService {
|
|
2261
2311
|
selectorsOverride: container?.selectors?.map(processor => ({ ...processor, ownerId: this.ownerId })),
|
2262
2312
|
});
|
2263
2313
|
}
|
2264
|
-
return request$.pipe(map
|
2314
|
+
return request$.pipe(map(r => {
|
2265
2315
|
this.stateId = r.stateId;
|
2266
2316
|
return undefined;
|
2267
2317
|
}));
|
2268
2318
|
}
|
2269
2319
|
initStateless$() {
|
2270
|
-
return this.configurationService.configure().pipe(map
|
2320
|
+
return this.configurationService.configure().pipe(map(() => undefined));
|
2271
2321
|
}
|
2272
2322
|
execToRequest(exec) {
|
2273
2323
|
return {
|
@@ -2308,11 +2358,11 @@ class ConfigurationStateService {
|
|
2308
2358
|
else {
|
2309
2359
|
execution$ = this.executeStateless$(fullRequest);
|
2310
2360
|
}
|
2311
|
-
return execution$.pipe(tap
|
2361
|
+
return execution$.pipe(tap(result => this.handleSelectorsResponse(result.selectors)));
|
2312
2362
|
}
|
2313
2363
|
executeStateless$(request) {
|
2314
2364
|
this.executionInProgress$.next(true);
|
2315
|
-
return of(undefined).pipe(switchMap(() => {
|
2365
|
+
return of(undefined).pipe(switchMap$1(() => {
|
2316
2366
|
// Apply actions and execute configuration/price call
|
2317
2367
|
// No need to run configuration if no actions in the request
|
2318
2368
|
if (!request.actions?.length) {
|
@@ -2324,7 +2374,7 @@ class ConfigurationStateService {
|
|
2324
2374
|
});
|
2325
2375
|
configurationRequest = ConfigurationTranslatorUtils.lightenConfigurationRequest(configurationRequest);
|
2326
2376
|
return this.configurationService.configureRequest$(configurationRequest);
|
2327
|
-
}), map
|
2377
|
+
}), map(() => {
|
2328
2378
|
// Run selectors and apply them to the state
|
2329
2379
|
const configurationState = cloneDeep(this.configurationService.stateSnapshot);
|
2330
2380
|
if (!configurationState) {
|
@@ -2347,7 +2397,7 @@ class ConfigurationStateService {
|
|
2347
2397
|
return result;
|
2348
2398
|
}, { stateId: '', selectors: {} });
|
2349
2399
|
return selectorsResult;
|
2350
|
-
}), tap
|
2400
|
+
}), tap(() => this.executionInProgress$.next(false)), catchError(error => {
|
2351
2401
|
this.executionInProgress$.next(false);
|
2352
2402
|
if (!this.configurationRuntimeService.uiDefinitionProperties.suppressToastMessages) {
|
2353
2403
|
this.toastService.add({ severity: ToastType.error, summary: String(error) });
|
@@ -2356,7 +2406,7 @@ class ConfigurationStateService {
|
|
2356
2406
|
}));
|
2357
2407
|
}
|
2358
2408
|
initBufferedRequest$() {
|
2359
|
-
return this.statefulRequestStream$.pipe(buffer(this.statefulRequestStream$.pipe(debounceTime(this.EXECUTION_BUFFER_TIME))), switchMap(requests => {
|
2409
|
+
return this.statefulRequestStream$.pipe(buffer(this.statefulRequestStream$.pipe(debounceTime(this.EXECUTION_BUFFER_TIME))), switchMap$1(requests => {
|
2360
2410
|
if (!this.flowStateService.stateId || !this.stateId) {
|
2361
2411
|
throw 'Stateful session is not initialized';
|
2362
2412
|
}
|
@@ -2370,18 +2420,18 @@ class ConfigurationStateService {
|
|
2370
2420
|
};
|
2371
2421
|
this.executionInProgress$.next(true);
|
2372
2422
|
return this.flowStateApiService.executeConfiguration(this.flowStateService.stateId, this.stateId, request);
|
2373
|
-
}), tap
|
2423
|
+
}), tap(({ stateId }) => (this.stateId = stateId)), share(), tap(() => this.executionInProgress$.next(false)), catchError(e => {
|
2374
2424
|
this.executionInProgress$.next(false);
|
2375
2425
|
return throwError(() => e);
|
2376
2426
|
}));
|
2377
2427
|
}
|
2378
2428
|
executeStateful$(request) {
|
2379
|
-
return this.executionInProgress$.pipe(filter$1(inProgress => !inProgress), take$1(1), switchMap(() =>
|
2429
|
+
return this.executionInProgress$.pipe(filter$1(inProgress => !inProgress), take$1(1), switchMap$1(() =>
|
2380
2430
|
// make sure stream switches to statefulExecutionRequest$ before pushing an execution request
|
2381
2431
|
combineLatest([
|
2382
2432
|
this.statefulExecutionRequest$,
|
2383
|
-
of(undefined).pipe(tap
|
2384
|
-
])), map
|
2433
|
+
of(undefined).pipe(tap(() => this.statefulRequestStream$.next(request))),
|
2434
|
+
])), map(([response]) => response), take$1(1));
|
2385
2435
|
}
|
2386
2436
|
executeActionScript(request, processor) {
|
2387
2437
|
const { actions } = this.configurationRuntimeService.runtimeContext?.uiDefinitionContainer ?? {};
|