@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 { InjectionToken, Injectable, Optional, Inject, NgModule, inject, Directive, Input, LOCALE_ID, Pipe } from '@angular/core';
|
3
|
-
import { UUID, ConfigurationContextMode,
|
4
|
-
import { BehaviorSubject, map, tap
|
5
|
-
import { map
|
3
|
+
import { UUID, ConfigurationContextMode, ConfigurationContext, UITemplateType, QuoteDraft, isDefined, ConfigurationProcessorTypes, EntityUtil, ChargeGroupUtils, DEFAULT_CURRENCY_ISO_CODE, DEFAULT_CURRENCY_SYMBOL, validateDateFormat, DEFAULT_DATE_FORMAT, DEFAULT_DECIMALS_COUNT, getSupportedDateFormats, DEFAULT_DECIMAL_SEPARATOR, DEFAULT_THOUSANDS_SEPARATOR, DEFAULT_ACTION_CODE_LABELS, parseJsonSafely, ConfigurationMode, extractErrorDetails, ConfigurationTranslatorUtils, RuntimeModel, isNotLegacyUIDefinition, SalesforceIdUtils, DEFAULT_TIME_FORMAT, formatNumber } from '@veloceapps/core';
|
4
|
+
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';
|
5
|
+
import { map, filter, tap, switchMap as switchMap$1, skip, take, shareReplay, catchError as catchError$1, finalize as finalize$1, first } from 'rxjs/operators';
|
6
6
|
import * as i1 from '@veloceapps/api';
|
7
7
|
import { ApiModule } from '@veloceapps/api';
|
8
|
-
import {
|
8
|
+
import { merge, isEqual, cloneDeep, assign, flatten, entries, sortBy, map as map$2, omit, uniqBy, transform } from 'lodash';
|
9
9
|
import * as i6 from '@veloceapps/components';
|
10
10
|
import { ToastType, ConfirmationComponent, ConfirmationDialogModule } from '@veloceapps/components';
|
11
11
|
import moment from 'moment';
|
@@ -92,130 +92,22 @@ var RuntimeStep;
|
|
92
92
|
|
93
93
|
const UI_DEFINITION_VERSION = 3;
|
94
94
|
|
95
|
-
class RuntimeSettingsService {
|
96
|
-
constructor(configurationSettingsApiService) {
|
97
|
-
this.configurationSettingsApiService = configurationSettingsApiService;
|
98
|
-
this.configurationSettings$ = new BehaviorSubject({});
|
99
|
-
this.currencySettings$ = new BehaviorSubject({
|
100
|
-
iso: DEFAULT_CURRENCY_ISO_CODE,
|
101
|
-
symbol: DEFAULT_CURRENCY_SYMBOL,
|
102
|
-
});
|
103
|
-
this.shoppingCartSettings$ = new BehaviorSubject([]);
|
104
|
-
this.getCurrencySymbol = (locale, currency) => {
|
105
|
-
return (0)
|
106
|
-
.toLocaleString(locale, { style: 'currency', currency, minimumFractionDigits: 0, maximumFractionDigits: 0 })
|
107
|
-
.replace(/\d/g, '')
|
108
|
-
.trim();
|
109
|
-
};
|
110
|
-
}
|
111
|
-
create() {
|
112
|
-
return this.configurationSettingsApiService.fetchSettings().pipe(map(settings => this.parseConfigurationSettings(settings)), tap(configurationSettings => {
|
113
|
-
var _a;
|
114
|
-
this.configurationSettings$.next(configurationSettings);
|
115
|
-
this.addShoppingCartSettings((_a = configurationSettings['shopping-cart']) !== null && _a !== void 0 ? _a : []);
|
116
|
-
this.formattingSettings = this.getFormattingSettings();
|
117
|
-
}), map(() => undefined));
|
118
|
-
}
|
119
|
-
initCurrency(iso) {
|
120
|
-
if (iso) {
|
121
|
-
const symbol = this.getCurrencySymbol('en-US', iso);
|
122
|
-
this.currencySettings$.next({ iso, symbol });
|
123
|
-
if (this.formattingSettings) {
|
124
|
-
this.formattingSettings.currencySymbol = symbol;
|
125
|
-
}
|
126
|
-
}
|
127
|
-
}
|
128
|
-
getFormattingSettings() {
|
129
|
-
var _a, _b;
|
130
|
-
if (this.formattingSettings) {
|
131
|
-
return this.formattingSettings;
|
132
|
-
}
|
133
|
-
const shoppingCartSettings = (_a = this.configurationSettings['shopping-cart']) === null || _a === void 0 ? void 0 : _a.reduce((acc, setting) => {
|
134
|
-
return Object.assign(Object.assign({}, acc), { [setting.id]: setting.properties });
|
135
|
-
}, {});
|
136
|
-
const currencySettings = this.getCurrencySettings();
|
137
|
-
const dateFormat = (validateDateFormat((_b = shoppingCartSettings === null || shoppingCartSettings === void 0 ? void 0 : shoppingCartSettings.DATE_FORMAT) !== null && _b !== void 0 ? _b : '') && (shoppingCartSettings === null || shoppingCartSettings === void 0 ? void 0 : shoppingCartSettings.DATE_FORMAT)) ||
|
138
|
-
DEFAULT_DATE_FORMAT;
|
139
|
-
const decimalSeparator = shoppingCartSettings === null || shoppingCartSettings === void 0 ? void 0 : shoppingCartSettings.DECIMAL_SEPARATOR;
|
140
|
-
const thousandsSeparator = shoppingCartSettings === null || shoppingCartSettings === void 0 ? void 0 : shoppingCartSettings.THOUSANDS_SEPARATOR;
|
141
|
-
// the number of decimal places can be 0
|
142
|
-
const priceScale = shoppingCartSettings === null || shoppingCartSettings === void 0 ? void 0 : shoppingCartSettings.PRICE_SCALE;
|
143
|
-
const decimalsCount = priceScale !== null && priceScale !== '' && !isNaN(Number(priceScale)) && Number(priceScale) >= 0
|
144
|
-
? Number(priceScale)
|
145
|
-
: DEFAULT_DECIMALS_COUNT;
|
146
|
-
const actionCodeSettings = shoppingCartSettings === null || shoppingCartSettings === void 0 ? void 0 : shoppingCartSettings.STATUS_LABEL;
|
147
|
-
return {
|
148
|
-
currencySymbol: currencySettings.symbol,
|
149
|
-
dateFormats: getSupportedDateFormats(dateFormat),
|
150
|
-
decimalsCount,
|
151
|
-
decimalSeparator: decimalSeparator !== undefined && ['.', ','].includes(decimalSeparator)
|
152
|
-
? decimalSeparator
|
153
|
-
: DEFAULT_DECIMAL_SEPARATOR,
|
154
|
-
// thousands separator can be a blank value, so it can also be null
|
155
|
-
thousandsSeparator: thousandsSeparator !== undefined && ['.', ',', '', null].includes(thousandsSeparator)
|
156
|
-
? thousandsSeparator || ''
|
157
|
-
: DEFAULT_THOUSANDS_SEPARATOR,
|
158
|
-
actionCodeLabels: (actionCodeSettings === null || actionCodeSettings === void 0 ? void 0 : actionCodeSettings.length)
|
159
|
-
? actionCodeSettings.reduce((result, setting) => (Object.assign(Object.assign({}, result), { [setting.status_label]: setting.custom_label })), {})
|
160
|
-
: DEFAULT_ACTION_CODE_LABELS,
|
161
|
-
};
|
162
|
-
}
|
163
|
-
get configurationSettings() {
|
164
|
-
return this.configurationSettings$.value;
|
165
|
-
}
|
166
|
-
getShoppingCartSettings() {
|
167
|
-
return this.shoppingCartSettings$.value;
|
168
|
-
}
|
169
|
-
getCurrencySettings() {
|
170
|
-
return this.currencySettings$.value;
|
171
|
-
}
|
172
|
-
parseConfigurationSettings(settings) {
|
173
|
-
return settings.reduce((acc, setting) => {
|
174
|
-
switch (setting.key) {
|
175
|
-
case 'shopping-cart':
|
176
|
-
acc['shopping-cart'] = parseJsonSafely(setting.value, []);
|
177
|
-
break;
|
178
|
-
case 'navigation':
|
179
|
-
acc.navigation = parseJsonSafely(setting.value, {});
|
180
|
-
break;
|
181
|
-
case 'flows':
|
182
|
-
acc.flows = parseJsonSafely(setting.value, []);
|
183
|
-
break;
|
184
|
-
default:
|
185
|
-
acc[setting.key] = setting.value;
|
186
|
-
}
|
187
|
-
return acc;
|
188
|
-
}, {});
|
189
|
-
}
|
190
|
-
addShoppingCartSettings(settings) {
|
191
|
-
// uniqBy removes items with the biggest index
|
192
|
-
const newSettings = uniqBy([...settings, ...this.shoppingCartSettings$.value], 'id');
|
193
|
-
this.shoppingCartSettings$.next(newSettings);
|
194
|
-
}
|
195
|
-
}
|
196
|
-
RuntimeSettingsService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: RuntimeSettingsService, deps: [{ token: i1.ConfigurationSettingsApiService }], target: i0.ɵɵFactoryTarget.Injectable });
|
197
|
-
RuntimeSettingsService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: RuntimeSettingsService });
|
198
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: RuntimeSettingsService, decorators: [{
|
199
|
-
type: Injectable
|
200
|
-
}], ctorParameters: function () { return [{ type: i1.ConfigurationSettingsApiService }]; } });
|
201
|
-
|
202
95
|
class ContextService {
|
203
|
-
constructor(contextApiService
|
96
|
+
constructor(contextApiService) {
|
204
97
|
this.contextApiService = contextApiService;
|
205
|
-
this.runtimeSettingsService = runtimeSettingsService;
|
206
98
|
this.context = new BehaviorSubject(null);
|
207
99
|
}
|
208
100
|
get isInitialized() {
|
209
101
|
return Boolean(this.context.value);
|
210
102
|
}
|
211
103
|
get isInitialized$() {
|
212
|
-
return this.context.pipe(map
|
104
|
+
return this.context.pipe(map(Boolean));
|
213
105
|
}
|
214
106
|
get mode() {
|
215
107
|
return this.resolve().properties['#mode'];
|
216
108
|
}
|
217
109
|
get isEditMode$() {
|
218
|
-
return this.resolve$().pipe(map
|
110
|
+
return this.resolve$().pipe(map(() => this.isEditMode));
|
219
111
|
}
|
220
112
|
get isEditMode() {
|
221
113
|
const context = this.resolve();
|
@@ -237,16 +129,10 @@ class ContextService {
|
|
237
129
|
return this.context.pipe(filter((ctx) => Boolean(ctx)));
|
238
130
|
}
|
239
131
|
create(headerId, mode) {
|
240
|
-
|
241
|
-
const skipContextRequest = configurationSettings['SKIP_CONTEXT_REQUEST'] === 'true';
|
242
|
-
let contextRequest$ = this.contextApiService.getContext(headerId, mode);
|
243
|
-
if (skipContextRequest) {
|
244
|
-
contextRequest$ = of({});
|
245
|
-
}
|
246
|
-
return contextRequest$.pipe(tap$1(context => this.context.next(merge(new ConfigurationContext(headerId, mode), context))), map$1(() => this.resolve()));
|
132
|
+
return this.contextApiService.getContext(headerId, mode).pipe(tap(context => this.context.next(merge(new ConfigurationContext(headerId, mode), context))), map(() => this.resolve()));
|
247
133
|
}
|
248
134
|
initTestMode() {
|
249
|
-
return this.create('TestId', ConfigurationContextMode.TEST).pipe(map
|
135
|
+
return this.create('TestId', ConfigurationContextMode.TEST).pipe(map(context => {
|
250
136
|
return this.update({
|
251
137
|
properties: Object.assign(Object.assign({}, context.properties), { RuntimeMode: ConfigurationContextMode.TEST, StartDate: new Date().toISOString().substring(0, 10), standalone: 'true' }),
|
252
138
|
});
|
@@ -268,11 +154,11 @@ class ContextService {
|
|
268
154
|
this.context.next(null);
|
269
155
|
}
|
270
156
|
}
|
271
|
-
ContextService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: ContextService, deps: [{ token: i1.ContextApiService }
|
157
|
+
ContextService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: ContextService, deps: [{ token: i1.ContextApiService }], target: i0.ɵɵFactoryTarget.Injectable });
|
272
158
|
ContextService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: ContextService });
|
273
159
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: ContextService, decorators: [{
|
274
160
|
type: Injectable
|
275
|
-
}], ctorParameters: function () { return [{ type: i1.ContextApiService }
|
161
|
+
}], ctorParameters: function () { return [{ type: i1.ContextApiService }]; } });
|
276
162
|
|
277
163
|
class FlowInfoService {
|
278
164
|
get flow() {
|
@@ -289,10 +175,9 @@ class FlowInfoService {
|
|
289
175
|
var _a;
|
290
176
|
return !!((_a = this.flow) === null || _a === void 0 ? void 0 : _a.properties.stateful);
|
291
177
|
}
|
292
|
-
constructor(flowsApiService, templatesApiService,
|
178
|
+
constructor(flowsApiService, templatesApiService, customizationService) {
|
293
179
|
this.flowsApiService = flowsApiService;
|
294
180
|
this.templatesApiService = templatesApiService;
|
295
|
-
this.runtimeSettingsService = runtimeSettingsService;
|
296
181
|
this.customizationService = customizationService;
|
297
182
|
this.templates = {};
|
298
183
|
this.defaultTemplates = {
|
@@ -302,20 +187,10 @@ class FlowInfoService {
|
|
302
187
|
this.flow$ = this.flowSubj$.asObservable();
|
303
188
|
}
|
304
189
|
init$(flowId, routeQueryParams) {
|
305
|
-
|
306
|
-
const flow = flows === null || flows === void 0 ? void 0 : flows.find(({ id }) => id === flowId);
|
307
|
-
if (!flow) {
|
308
|
-
return of(undefined);
|
309
|
-
}
|
310
|
-
const isLegacy = !!flow && (flow === null || flow === void 0 ? void 0 : flow.properties.stateful) == null;
|
311
|
-
let flowTemplates$ = of(undefined);
|
312
|
-
if (!isLegacy) {
|
313
|
-
flowTemplates$ = this.initFlowTemplates$(flow).pipe(map(() => undefined));
|
314
|
-
}
|
315
|
-
return flowTemplates$.pipe(tap(() => {
|
190
|
+
return this.flowsApiService.getFlow(flowId).pipe(switchMap(flow => this.initFlowTemplates$(flow).pipe(map$1(() => flow))), tap$1(flow => {
|
316
191
|
this.params = Object.assign(Object.assign({}, routeQueryParams), flow.properties.queryParams);
|
317
192
|
this.flowSubj$.next(flow);
|
318
|
-
}), map(noop), catchError(e => {
|
193
|
+
}), map$1(noop), catchError(e => {
|
319
194
|
this.flowSubj$.next(null);
|
320
195
|
return throwError(() => e);
|
321
196
|
}));
|
@@ -330,7 +205,7 @@ class FlowInfoService {
|
|
330
205
|
return forkJoin([
|
331
206
|
this.templatesApiService.fetchTemplates$(),
|
332
207
|
(_c = (_b = (_a = this.customizationService) === null || _a === void 0 ? void 0 : _a.getTemplates) === null || _b === void 0 ? void 0 : _b.call(_a)) !== null && _c !== void 0 ? _c : of([]),
|
333
|
-
]).pipe(map(([templates, localTemplates]) => {
|
208
|
+
]).pipe(map$1(([templates, localTemplates]) => {
|
334
209
|
Object.entries(Object.assign(Object.assign({}, this.defaultTemplates), flow.properties.templates)).forEach(([key, name]) => {
|
335
210
|
var _a;
|
336
211
|
const type = this.remapTemplateName(key);
|
@@ -367,12 +242,12 @@ class FlowInfoService {
|
|
367
242
|
return undefined;
|
368
243
|
}
|
369
244
|
}
|
370
|
-
FlowInfoService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: FlowInfoService, deps: [{ token: i1.FlowsApiService }, { token: i1.UITemplatesApiService }, { token:
|
245
|
+
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 });
|
371
246
|
FlowInfoService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: FlowInfoService });
|
372
247
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: FlowInfoService, decorators: [{
|
373
248
|
type: Injectable
|
374
249
|
}], ctorParameters: function () {
|
375
|
-
return [{ type: i1.FlowsApiService }, { type: i1.UITemplatesApiService }, { type:
|
250
|
+
return [{ type: i1.FlowsApiService }, { type: i1.UITemplatesApiService }, { type: undefined, decorators: [{
|
376
251
|
type: Optional
|
377
252
|
}, {
|
378
253
|
type: Inject,
|
@@ -403,14 +278,14 @@ class QuoteDraftService {
|
|
403
278
|
}
|
404
279
|
}
|
405
280
|
get hasProducts$() {
|
406
|
-
return this.quoteSubj$.pipe(map
|
281
|
+
return this.quoteSubj$.pipe(map(() => this.hasProducts));
|
407
282
|
}
|
408
283
|
get hasProducts() {
|
409
284
|
var _a;
|
410
285
|
return Boolean((_a = this.quoteSubj$.value) === null || _a === void 0 ? void 0 : _a.currentState.length);
|
411
286
|
}
|
412
287
|
get hasAssets$() {
|
413
|
-
return this.assetsSubj$.pipe(map
|
288
|
+
return this.assetsSubj$.pipe(map(() => this.hasAssets));
|
414
289
|
}
|
415
290
|
get hasAssets() {
|
416
291
|
var _a;
|
@@ -419,12 +294,11 @@ class QuoteDraftService {
|
|
419
294
|
get assetsState() {
|
420
295
|
return this.assetsSubj$.value;
|
421
296
|
}
|
422
|
-
constructor(context, flowInfoService, accountApiService, quoteApiService
|
297
|
+
constructor(context, flowInfoService, accountApiService, quoteApiService) {
|
423
298
|
this.context = context;
|
424
299
|
this.flowInfoService = flowInfoService;
|
425
300
|
this.accountApiService = accountApiService;
|
426
301
|
this.quoteApiService = quoteApiService;
|
427
|
-
this.runtimeSettingsService = runtimeSettingsService;
|
428
302
|
this.quoteSubj$ = new BehaviorSubject(null);
|
429
303
|
this.assetsSubj$ = new BehaviorSubject(null);
|
430
304
|
this.resetSubj$ = new BehaviorSubject(true);
|
@@ -433,7 +307,7 @@ class QuoteDraftService {
|
|
433
307
|
this._hasUnsavedChanges = false;
|
434
308
|
this.reset$ = this.resetSubj$.asObservable();
|
435
309
|
this.isInitializedSubj$
|
436
|
-
.pipe(filter(isInitialized => isInitialized), switchMap(() => this.quoteSubj$.asObservable()), skip(1), tap
|
310
|
+
.pipe(filter(isInitialized => isInitialized), switchMap$1(() => this.quoteSubj$.asObservable()), skip(1), tap(quote => this.markAsUpdated(quote)))
|
437
311
|
.subscribe();
|
438
312
|
}
|
439
313
|
reset() {
|
@@ -444,33 +318,23 @@ class QuoteDraftService {
|
|
444
318
|
this.hasUnsavedChanges = false;
|
445
319
|
}
|
446
320
|
init(headerId, params) {
|
447
|
-
var _a;
|
448
321
|
const ctx = this.context.resolve();
|
449
322
|
const isAccountMode = this.context.mode === ConfigurationContextMode.ACCOUNT;
|
450
|
-
const accountId = isAccountMode ? headerId :
|
451
|
-
|
452
|
-
const skipAssetsQuery = configurationSettings['SKIP_ASSETS_QUERY'] === 'true';
|
453
|
-
let assetRequest$ = of(null);
|
454
|
-
if (accountId && !skipAssetsQuery) {
|
455
|
-
assetRequest$ = this.accountApiService.getAssetsState(accountId, params);
|
456
|
-
}
|
457
|
-
return zip(assetRequest$, isAccountMode
|
323
|
+
const accountId = isAccountMode ? headerId : ctx.properties.AccountId;
|
324
|
+
return zip(accountId ? this.accountApiService.getAssetsState(accountId, params) : of(null), isAccountMode
|
458
325
|
? of(QuoteDraft.emptyQuote(ConfigurationContextMode.ACCOUNT))
|
459
|
-
: this.quoteApiService.getQuoteState(headerId, params)).pipe(tap
|
326
|
+
: this.quoteApiService.getQuoteState(headerId, params)).pipe(tap(([assets, quote]) => {
|
460
327
|
if (assets) {
|
461
328
|
this.assetsSubj$.next(assets);
|
462
329
|
}
|
463
|
-
let context;
|
464
330
|
this.quoteSubj$.next(quote);
|
465
331
|
if (assets && isAccountMode) {
|
466
|
-
context
|
332
|
+
this.context.update(assets.context);
|
467
333
|
}
|
468
334
|
else {
|
469
|
-
context
|
335
|
+
this.context.update(quote.context);
|
470
336
|
}
|
471
|
-
|
472
|
-
this.runtimeSettingsService.initCurrency(context.properties['CurrencyIsoCode']);
|
473
|
-
}), map$1(() => noop()), take(1));
|
337
|
+
}), map(() => noop()), take(1));
|
474
338
|
}
|
475
339
|
finalizeInit() {
|
476
340
|
this.isInitialized = true;
|
@@ -508,7 +372,7 @@ class QuoteDraftService {
|
|
508
372
|
this.assetsSubj$.next(assetsState);
|
509
373
|
}
|
510
374
|
get quoteDraft$() {
|
511
|
-
return combineLatest([this.quoteSubj$, this.context.resolve$()]).pipe(map
|
375
|
+
return combineLatest([this.quoteSubj$, this.context.resolve$()]).pipe(map(() => this.quoteDraft), filter((quote) => Boolean(quote)), shareReplay());
|
512
376
|
}
|
513
377
|
get quoteDraft() {
|
514
378
|
const quote = this.quoteSubj$.value;
|
@@ -518,7 +382,7 @@ class QuoteDraftService {
|
|
518
382
|
return Object.assign(Object.assign({}, quote), { context: this.context.resolve() });
|
519
383
|
}
|
520
384
|
get currentState$() {
|
521
|
-
return this.quoteDraft$.pipe(map
|
385
|
+
return this.quoteDraft$.pipe(map(quote => quote.currentState));
|
522
386
|
}
|
523
387
|
get currentState() {
|
524
388
|
var _a, _b;
|
@@ -529,13 +393,13 @@ class QuoteDraftService {
|
|
529
393
|
return (_b = (_a = this.flowInfoService.flow) === null || _a === void 0 ? void 0 : _a.properties.standalone) !== null && _b !== void 0 ? _b : false;
|
530
394
|
}
|
531
395
|
get isStandalone$() {
|
532
|
-
return this.flowInfoService.flow$.pipe(map
|
396
|
+
return this.flowInfoService.flow$.pipe(map(() => this.isStandalone));
|
533
397
|
}
|
534
398
|
getInitialCurrentState() {
|
535
399
|
return this.initialCurrentState;
|
536
400
|
}
|
537
401
|
isEditMode$() {
|
538
|
-
return this.context.resolve$().pipe(map
|
402
|
+
return this.context.resolve$().pipe(map(() => this.isEditMode()));
|
539
403
|
}
|
540
404
|
isEditMode() {
|
541
405
|
const context = this.context.resolve();
|
@@ -556,11 +420,11 @@ class QuoteDraftService {
|
|
556
420
|
}
|
557
421
|
}
|
558
422
|
}
|
559
|
-
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 }
|
423
|
+
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 });
|
560
424
|
QuoteDraftService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: QuoteDraftService });
|
561
425
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: QuoteDraftService, decorators: [{
|
562
426
|
type: Injectable
|
563
|
-
}], ctorParameters: function () { return [{ type: ContextService }, { type: FlowInfoService }, { type: i1.AccountApiService }, { type: i1.QuoteApiService }
|
427
|
+
}], ctorParameters: function () { return [{ type: ContextService }, { type: FlowInfoService }, { type: i1.AccountApiService }, { type: i1.QuoteApiService }]; } });
|
564
428
|
|
565
429
|
class FlowStateService {
|
566
430
|
constructor(contextService, quoteDraftService, flowInfoService, flowConfiguration, processorsApiService, flowStateApiService, quoteApiService, toastService, customizationService) {
|
@@ -591,59 +455,55 @@ class FlowStateService {
|
|
591
455
|
all subscriptions get their updates according to updated QuoteDraft
|
592
456
|
*/
|
593
457
|
this.isInitialized$()
|
594
|
-
.pipe(filter$1(Boolean), filter$1(() => !this.getFlowSafe().properties.stateful), switchMap
|
458
|
+
.pipe(filter$1(Boolean), filter$1(() => !this.getFlowSafe().properties.stateful), switchMap(() => this.flowConfiguration.updated$), switchMap(() => this.executeRequest$({}, true)))
|
595
459
|
.subscribe();
|
596
|
-
this.charges$ = this.flowInfoService.flow$.pipe(filter$1(isDefined), switchMap
|
460
|
+
this.charges$ = this.flowInfoService.flow$.pipe(filter$1(isDefined), switchMap(() => {
|
597
461
|
if (this.flowInfoService.isLegacy) {
|
598
|
-
return this.quoteDraftService.quoteDraft$.pipe(map(quoteDraft => quoteDraft.charges));
|
462
|
+
return this.quoteDraftService.quoteDraft$.pipe(map$1(quoteDraft => quoteDraft.charges));
|
599
463
|
}
|
600
464
|
else {
|
601
465
|
return this.subscribe$(UITemplateType.FLOW_ENGINE, 'CHARGES', null, {
|
602
466
|
cold: true,
|
603
|
-
}).pipe(map(response => (response.success ? response.result : {})));
|
467
|
+
}).pipe(map$1(response => (response.success ? response.result : {})));
|
604
468
|
}
|
605
469
|
}), shareReplay$1(1));
|
606
470
|
this.charges$.subscribe();
|
607
|
-
this.pricePlans$ = this.flowInfoService.flow$.pipe(filter$1(isDefined), switchMap
|
471
|
+
this.pricePlans$ = this.flowInfoService.flow$.pipe(filter$1(isDefined), switchMap(() => {
|
608
472
|
if (this.flowInfoService.isLegacy) {
|
609
|
-
return this.quoteDraftService.quoteDraft$.pipe(map(quoteDraft => quoteDraft.pricePlans));
|
473
|
+
return this.quoteDraftService.quoteDraft$.pipe(map$1(quoteDraft => quoteDraft.pricePlans));
|
610
474
|
}
|
611
475
|
else {
|
612
476
|
return this.subscribe$(UITemplateType.FLOW_ENGINE, 'PRICE_PLANS', null, {
|
613
477
|
cold: true,
|
614
|
-
}).pipe(map(response => (response.success ? response.result : {})));
|
478
|
+
}).pipe(map$1(response => (response.success ? response.result : {})));
|
615
479
|
}
|
616
480
|
}), shareReplay$1(1));
|
617
481
|
this.pricePlans$.subscribe();
|
618
|
-
this.activeMetrics$ = this.flowInfoService.flow$.pipe(filter$1(isDefined), switchMap
|
482
|
+
this.activeMetrics$ = this.flowInfoService.flow$.pipe(filter$1(isDefined), switchMap(() => {
|
619
483
|
if (this.flowInfoService.isLegacy) {
|
620
|
-
return this.quoteDraftService.quoteDraft$.pipe(map(quoteDraft => quoteDraft.activeMetrics));
|
484
|
+
return this.quoteDraftService.quoteDraft$.pipe(map$1(quoteDraft => quoteDraft.activeMetrics));
|
621
485
|
}
|
622
486
|
else {
|
623
487
|
return this.subscribe$(UITemplateType.FLOW_ENGINE, 'ACTIVE_METRICS', null, {
|
624
488
|
cold: true,
|
625
|
-
}).pipe(map(response => (response.success ? response.result : [])));
|
489
|
+
}).pipe(map$1(response => (response.success ? response.result : [])));
|
626
490
|
}
|
627
491
|
}), shareReplay$1(1));
|
628
492
|
this.activeMetrics$.subscribe();
|
629
|
-
this.isPriceListLocked$ = this.flowInfoService.flow$.pipe(filter$1(isDefined), switchMap
|
493
|
+
this.isPriceListLocked$ = this.flowInfoService.flow$.pipe(filter$1(isDefined), switchMap(() => {
|
630
494
|
if (this.flowInfoService.isLegacy) {
|
631
495
|
return of(false);
|
632
496
|
}
|
633
497
|
else {
|
634
498
|
return this.subscribe$(UITemplateType.FLOW_ENGINE, 'IS_PRICE_LIST_LOCKED', null, {
|
635
499
|
cold: true,
|
636
|
-
}).pipe(map(response => (response.success ? response.result : false)));
|
500
|
+
}).pipe(map$1(response => (response.success ? response.result : false)));
|
637
501
|
}
|
638
502
|
}), shareReplay$1(1));
|
639
503
|
this.isPriceListLocked$.subscribe();
|
640
504
|
}
|
641
505
|
init$() {
|
642
|
-
|
643
|
-
if (this.flowInfoService.isLegacy) {
|
644
|
-
processors$ = of(undefined);
|
645
|
-
}
|
646
|
-
return processors$.pipe(switchMap$1(() => {
|
506
|
+
return this.initProcessors$().pipe(switchMap(() => {
|
647
507
|
if (this.getFlowSafe().properties.stateful) {
|
648
508
|
return this.initStateful$();
|
649
509
|
}
|
@@ -675,14 +535,14 @@ class FlowStateService {
|
|
675
535
|
return this.executionInProgress$.asObservable();
|
676
536
|
}
|
677
537
|
isInitialized$() {
|
678
|
-
return combineLatest([this.stateId$, this.quoteDraftService.isInitialized$]).pipe(map(values => values.some(Boolean)));
|
538
|
+
return combineLatest([this.stateId$, this.quoteDraftService.isInitialized$]).pipe(map$1(values => values.some(Boolean)));
|
679
539
|
}
|
680
540
|
isInitialized() {
|
681
541
|
return Boolean(this.stateId$.value) || this.quoteDraftService.isInitialized;
|
682
542
|
}
|
683
543
|
execute$(scope, exec) {
|
684
544
|
const request = this.execToRequest(scope, exec);
|
685
|
-
return this.executeRequest$(request).pipe(map(result => {
|
545
|
+
return this.executeRequest$(request).pipe(map$1(result => {
|
686
546
|
// Keep only requested results
|
687
547
|
const actualSelectors = Object.entries(result.selectors).reduce((trunk, [requestId, result]) => {
|
688
548
|
var _a;
|
@@ -695,14 +555,11 @@ class FlowStateService {
|
|
695
555
|
}));
|
696
556
|
}
|
697
557
|
dispatch$(scope, action, inputData) {
|
698
|
-
if (this.flowInfoService.isLegacy) {
|
699
|
-
return of(undefined);
|
700
|
-
}
|
701
558
|
const exec = {
|
702
559
|
actions: [{ name: action, inputData }],
|
703
560
|
};
|
704
561
|
const request = this.execToRequest(scope, exec);
|
705
|
-
return this.executeRequest$(request).pipe(map(noop));
|
562
|
+
return this.executeRequest$(request).pipe(map$1(noop));
|
706
563
|
}
|
707
564
|
select$(scope, selectorName, inputData) {
|
708
565
|
const requestId = this.generateRequestId(scope, selectorName, inputData);
|
@@ -714,15 +571,9 @@ class FlowStateService {
|
|
714
571
|
},
|
715
572
|
},
|
716
573
|
});
|
717
|
-
return this.executeRequest$(request).pipe(map(response => response.selectors[requestId]));
|
574
|
+
return this.executeRequest$(request).pipe(map$1(response => response.selectors[requestId]));
|
718
575
|
}
|
719
576
|
subscribe$(scope, selectorName, inputData, options) {
|
720
|
-
if (this.flowInfoService.isLegacy) {
|
721
|
-
return of({
|
722
|
-
success: false,
|
723
|
-
errorMessage: '',
|
724
|
-
});
|
725
|
-
}
|
726
577
|
const requestId = this.generateRequestId(scope, selectorName, inputData);
|
727
578
|
let subscription = this.subscriptions[requestId];
|
728
579
|
if (!subscription) {
|
@@ -746,7 +597,7 @@ class FlowStateService {
|
|
746
597
|
this.executeRequest$(request).subscribe();
|
747
598
|
}
|
748
599
|
}
|
749
|
-
return subscription.data$.pipe(filter$1(data => data != this.NOT_INITIALIZED), map(data => data), finalize(() => {
|
600
|
+
return subscription.data$.pipe(filter$1(data => data != this.NOT_INITIALIZED), map$1(data => data), finalize(() => {
|
750
601
|
var _a;
|
751
602
|
if (!((_a = this.subscriptions[requestId]) === null || _a === void 0 ? void 0 : _a.data$.observed)) {
|
752
603
|
delete this.subscriptions[requestId];
|
@@ -756,7 +607,7 @@ class FlowStateService {
|
|
756
607
|
save$() {
|
757
608
|
if (this.getFlowSafe().properties.stateful) {
|
758
609
|
if (this.stateId$.value) {
|
759
|
-
return this.flowStateApiService.save(this.stateId$.value).pipe(tap(() => {
|
610
|
+
return this.flowStateApiService.save(this.stateId$.value).pipe(tap$1(() => {
|
760
611
|
Array.from(this.trackedStatefulChangesMap.keys()).forEach(key => {
|
761
612
|
this.trackedStatefulChangesMap.set(key, false);
|
762
613
|
});
|
@@ -766,7 +617,7 @@ class FlowStateService {
|
|
766
617
|
else {
|
767
618
|
const quoteDraft = this.quoteDraftService.quoteDraft;
|
768
619
|
if (quoteDraft) {
|
769
|
-
return this.quoteApiService.upsertQuote(quoteDraft).pipe(tap(({ versionId }) => {
|
620
|
+
return this.quoteApiService.upsertQuote(quoteDraft).pipe(tap$1(({ versionId }) => {
|
770
621
|
this.contextService.update({ properties: { VELOCPQ__VersionId__c: versionId } });
|
771
622
|
}));
|
772
623
|
}
|
@@ -782,7 +633,7 @@ class FlowStateService {
|
|
782
633
|
else {
|
783
634
|
const quoteDraft = this.quoteDraftService.quoteDraft;
|
784
635
|
if (quoteDraft) {
|
785
|
-
return this.quoteApiService.submitQuote(quoteDraft).pipe(tap(({ versionId }) => {
|
636
|
+
return this.quoteApiService.submitQuote(quoteDraft).pipe(tap$1(({ versionId }) => {
|
786
637
|
this.contextService.update({ properties: { VELOCPQ__VersionId__c: versionId } });
|
787
638
|
}));
|
788
639
|
}
|
@@ -831,7 +682,7 @@ class FlowStateService {
|
|
831
682
|
const execution$ = this.getFlowSafe().properties.stateful
|
832
683
|
? this.executeStateful$(fullRequest)
|
833
684
|
: this.executeStateless$(fullRequest);
|
834
|
-
return execution$.pipe(tap(result => this.handleSelectorsResponse(result.selectors)));
|
685
|
+
return execution$.pipe(tap$1(result => this.handleSelectorsResponse(result.selectors)));
|
835
686
|
}
|
836
687
|
handleSelectorsResponse(selectors) {
|
837
688
|
Object.entries(selectors).forEach(([requestId, selectorResult]) => {
|
@@ -850,7 +701,7 @@ class FlowStateService {
|
|
850
701
|
var _a;
|
851
702
|
// Subscriptions
|
852
703
|
this.subscribe$(UITemplateType.FLOW_ENGINE, 'CONTEXT', null, { cold: true })
|
853
|
-
.pipe(tap(response => {
|
704
|
+
.pipe(tap$1(response => {
|
854
705
|
if (response.success) {
|
855
706
|
this.contextService.update(response.result);
|
856
707
|
}
|
@@ -872,13 +723,13 @@ class FlowStateService {
|
|
872
723
|
selectors: Object.assign(Object.assign({}, selectors), request.selectors),
|
873
724
|
actions: request.actions,
|
874
725
|
})
|
875
|
-
.pipe(map(({ stateId, selectors }) => {
|
726
|
+
.pipe(map$1(({ stateId, selectors }) => {
|
876
727
|
this.handleSelectorsResponse(selectors);
|
877
728
|
this.stateId$.next(stateId);
|
878
729
|
}));
|
879
730
|
}
|
880
731
|
initBufferedRequest$() {
|
881
|
-
return this.statefulRequestStream$.pipe(buffer(this.statefulRequestStream$.pipe(debounceTime(this.EXECUTION_BUFFER_TIME))), switchMap
|
732
|
+
return this.statefulRequestStream$.pipe(buffer(this.statefulRequestStream$.pipe(debounceTime(this.EXECUTION_BUFFER_TIME))), switchMap(requests => {
|
882
733
|
if (!this.stateId$.value) {
|
883
734
|
throw 'Stateful session is not initialized';
|
884
735
|
}
|
@@ -892,33 +743,33 @@ class FlowStateService {
|
|
892
743
|
};
|
893
744
|
this.executionInProgress$.next(true);
|
894
745
|
return this.flowStateApiService.execute(this.stateId$.value, request);
|
895
|
-
}), tap(({ stateId }) => this.stateId$.next(stateId)), share(), tap(() => this.executionInProgress$.next(false)), catchError(e => {
|
746
|
+
}), tap$1(({ stateId }) => this.stateId$.next(stateId)), share(), tap$1(() => this.executionInProgress$.next(false)), catchError(e => {
|
896
747
|
this.executionInProgress$.next(false);
|
897
748
|
return throwError(() => e);
|
898
749
|
}));
|
899
750
|
}
|
900
751
|
executeStateful$(request) {
|
901
|
-
return this.executionInProgress$.pipe(filter$1(inProgress => !inProgress), take$1(1), switchMap
|
752
|
+
return this.executionInProgress$.pipe(filter$1(inProgress => !inProgress), take$1(1), switchMap(() =>
|
902
753
|
// make sure stream switches to statefulExecutionRequest$ before pushing an execution request
|
903
754
|
combineLatest([
|
904
755
|
this.statefulExecutionRequest$,
|
905
|
-
of(undefined).pipe(tap(() => this.statefulRequestStream$.next(request))),
|
906
|
-
])), map(([response]) => response), take$1(1));
|
756
|
+
of(undefined).pipe(tap$1(() => this.statefulRequestStream$.next(request))),
|
757
|
+
])), map$1(([response]) => response), take$1(1));
|
907
758
|
}
|
908
759
|
initStateless$() {
|
909
760
|
var _a;
|
910
761
|
const { headerId } = this.contextService.resolve();
|
911
|
-
return this.quoteDraftService.init(headerId, (_a = this.flowInfoService.params) !== null && _a !== void 0 ? _a : {}).pipe(tap(() => {
|
762
|
+
return this.quoteDraftService.init(headerId, (_a = this.flowInfoService.params) !== null && _a !== void 0 ? _a : {}).pipe(tap$1(() => {
|
912
763
|
const assets = this.quoteDraftService.assetsState;
|
913
764
|
if (assets) {
|
914
765
|
this.flowStore = Object.assign(Object.assign({}, this.flowStore), { assets });
|
915
766
|
}
|
916
|
-
}), switchMap
|
767
|
+
}), switchMap(() => {
|
917
768
|
if (this.flowInfoService.isLegacy) {
|
918
769
|
return of(null);
|
919
770
|
}
|
920
771
|
return this.executeRequest$(this.getDefaultExecutionRequestDTO());
|
921
|
-
}), switchMap
|
772
|
+
}), switchMap(() => this.calculate$()), tap$1(() => this.quoteDraftService.finalizeInit()), map$1(noop));
|
922
773
|
}
|
923
774
|
calculate$() {
|
924
775
|
var _a;
|
@@ -942,7 +793,7 @@ class FlowStateService {
|
|
942
793
|
}
|
943
794
|
executeStateless$(request) {
|
944
795
|
this.executionInProgress$.next(true);
|
945
|
-
return of(undefined).pipe(tap(() => this.executeStatelessActions(request)), switchMap
|
796
|
+
return of(undefined).pipe(tap$1(() => this.executeStatelessActions(request)), switchMap(() => {
|
946
797
|
var _a;
|
947
798
|
/*
|
948
799
|
Skip price calculation in case
|
@@ -955,7 +806,7 @@ class FlowStateService {
|
|
955
806
|
else {
|
956
807
|
return this.calculate$();
|
957
808
|
}
|
958
|
-
}), map(() => this.executeStatelessSelectors(request)), tap(() => this.executionInProgress$.next(false)), catchError(e => {
|
809
|
+
}), map$1(() => this.executeStatelessSelectors(request)), tap$1(() => this.executionInProgress$.next(false)), catchError(e => {
|
959
810
|
this.executionInProgress$.next(false);
|
960
811
|
return throwError(() => e);
|
961
812
|
}));
|
@@ -1023,7 +874,7 @@ class FlowStateService {
|
|
1023
874
|
return;
|
1024
875
|
}
|
1025
876
|
const localProcessors$ = (_c = (_b = (_a = this.customizationService) === null || _a === void 0 ? void 0 : _a.getTemplateConfigurationProcessors) === null || _b === void 0 ? void 0 : _b.call(_a, template.name)) !== null && _c !== void 0 ? _c : of(null);
|
1026
|
-
return localProcessors$.pipe(switchMap
|
877
|
+
return localProcessors$.pipe(switchMap(processors => processors ? of(processors) : this.processorsApiService.fetchConfigurationProcessors$(template.id)), tap$1(processors => {
|
1027
878
|
const processorsMap = processors.reduce((acc, p) => {
|
1028
879
|
acc[p.apiName] = p;
|
1029
880
|
return acc;
|
@@ -1035,7 +886,7 @@ class FlowStateService {
|
|
1035
886
|
if (!owners$.length) {
|
1036
887
|
return of(undefined);
|
1037
888
|
}
|
1038
|
-
return forkJoin(owners$).pipe(map(noop));
|
889
|
+
return forkJoin(owners$).pipe(map$1(noop));
|
1039
890
|
}
|
1040
891
|
executeActionScript(request, executable) {
|
1041
892
|
var _a;
|
@@ -1465,6 +1316,113 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImpor
|
|
1465
1316
|
type: Injectable
|
1466
1317
|
}] });
|
1467
1318
|
|
1319
|
+
class RuntimeSettingsService {
|
1320
|
+
constructor(configurationSettingsApiService) {
|
1321
|
+
this.configurationSettingsApiService = configurationSettingsApiService;
|
1322
|
+
this.configurationSettings$ = new BehaviorSubject({});
|
1323
|
+
this.currencySettings$ = new BehaviorSubject({
|
1324
|
+
iso: DEFAULT_CURRENCY_ISO_CODE,
|
1325
|
+
symbol: DEFAULT_CURRENCY_SYMBOL,
|
1326
|
+
});
|
1327
|
+
this.shoppingCartSettings$ = new BehaviorSubject([]);
|
1328
|
+
this.getCurrencySymbol = (locale, currency) => {
|
1329
|
+
return (0)
|
1330
|
+
.toLocaleString(locale, { style: 'currency', currency, minimumFractionDigits: 0, maximumFractionDigits: 0 })
|
1331
|
+
.replace(/\d/g, '')
|
1332
|
+
.trim();
|
1333
|
+
};
|
1334
|
+
}
|
1335
|
+
create() {
|
1336
|
+
return this.configurationSettingsApiService.fetchSettings().pipe(map$1(settings => this.parseConfigurationSettings(settings)), tap$1(configurationSettings => {
|
1337
|
+
var _a;
|
1338
|
+
this.configurationSettings$.next(configurationSettings);
|
1339
|
+
this.addShoppingCartSettings((_a = configurationSettings['shopping-cart']) !== null && _a !== void 0 ? _a : []);
|
1340
|
+
this.formattingSettings = this.getFormattingSettings();
|
1341
|
+
}), map$1(() => undefined));
|
1342
|
+
}
|
1343
|
+
initCurrency(iso) {
|
1344
|
+
if (iso) {
|
1345
|
+
const symbol = this.getCurrencySymbol('en-US', iso);
|
1346
|
+
this.currencySettings$.next({ iso, symbol });
|
1347
|
+
if (this.formattingSettings) {
|
1348
|
+
this.formattingSettings.currencySymbol = symbol;
|
1349
|
+
}
|
1350
|
+
}
|
1351
|
+
}
|
1352
|
+
getFormattingSettings() {
|
1353
|
+
var _a, _b;
|
1354
|
+
if (this.formattingSettings) {
|
1355
|
+
return this.formattingSettings;
|
1356
|
+
}
|
1357
|
+
const shoppingCartSettings = (_a = this.getConfigurationSettings()['shopping-cart']) === null || _a === void 0 ? void 0 : _a.reduce((acc, setting) => {
|
1358
|
+
return Object.assign(Object.assign({}, acc), { [setting.id]: setting.properties });
|
1359
|
+
}, {});
|
1360
|
+
const currencySettings = this.getCurrencySettings();
|
1361
|
+
const dateFormat = (validateDateFormat((_b = shoppingCartSettings === null || shoppingCartSettings === void 0 ? void 0 : shoppingCartSettings.DATE_FORMAT) !== null && _b !== void 0 ? _b : '') && (shoppingCartSettings === null || shoppingCartSettings === void 0 ? void 0 : shoppingCartSettings.DATE_FORMAT)) ||
|
1362
|
+
DEFAULT_DATE_FORMAT;
|
1363
|
+
const decimalSeparator = shoppingCartSettings === null || shoppingCartSettings === void 0 ? void 0 : shoppingCartSettings.DECIMAL_SEPARATOR;
|
1364
|
+
const thousandsSeparator = shoppingCartSettings === null || shoppingCartSettings === void 0 ? void 0 : shoppingCartSettings.THOUSANDS_SEPARATOR;
|
1365
|
+
// the number of decimal places can be 0
|
1366
|
+
const priceScale = shoppingCartSettings === null || shoppingCartSettings === void 0 ? void 0 : shoppingCartSettings.PRICE_SCALE;
|
1367
|
+
const decimalsCount = priceScale !== null && priceScale !== '' && !isNaN(Number(priceScale)) && Number(priceScale) >= 0
|
1368
|
+
? Number(priceScale)
|
1369
|
+
: DEFAULT_DECIMALS_COUNT;
|
1370
|
+
const actionCodeSettings = shoppingCartSettings === null || shoppingCartSettings === void 0 ? void 0 : shoppingCartSettings.STATUS_LABEL;
|
1371
|
+
return {
|
1372
|
+
currencySymbol: currencySettings.symbol,
|
1373
|
+
dateFormats: getSupportedDateFormats(dateFormat),
|
1374
|
+
decimalsCount,
|
1375
|
+
decimalSeparator: decimalSeparator !== undefined && ['.', ','].includes(decimalSeparator)
|
1376
|
+
? decimalSeparator
|
1377
|
+
: DEFAULT_DECIMAL_SEPARATOR,
|
1378
|
+
// thousands separator can be a blank value, so it can also be null
|
1379
|
+
thousandsSeparator: thousandsSeparator !== undefined && ['.', ',', '', null].includes(thousandsSeparator)
|
1380
|
+
? thousandsSeparator || ''
|
1381
|
+
: DEFAULT_THOUSANDS_SEPARATOR,
|
1382
|
+
actionCodeLabels: (actionCodeSettings === null || actionCodeSettings === void 0 ? void 0 : actionCodeSettings.length)
|
1383
|
+
? actionCodeSettings.reduce((result, setting) => (Object.assign(Object.assign({}, result), { [setting.status_label]: setting.custom_label })), {})
|
1384
|
+
: DEFAULT_ACTION_CODE_LABELS,
|
1385
|
+
};
|
1386
|
+
}
|
1387
|
+
getConfigurationSettings() {
|
1388
|
+
return this.configurationSettings$.value;
|
1389
|
+
}
|
1390
|
+
getShoppingCartSettings() {
|
1391
|
+
return this.shoppingCartSettings$.value;
|
1392
|
+
}
|
1393
|
+
getCurrencySettings() {
|
1394
|
+
return this.currencySettings$.value;
|
1395
|
+
}
|
1396
|
+
parseConfigurationSettings(settings) {
|
1397
|
+
return settings.reduce((acc, setting) => {
|
1398
|
+
switch (setting.key) {
|
1399
|
+
case 'shopping-cart':
|
1400
|
+
acc['shopping-cart'] = parseJsonSafely(setting.value, []);
|
1401
|
+
break;
|
1402
|
+
case 'navigation':
|
1403
|
+
acc.navigation = parseJsonSafely(setting.value, {});
|
1404
|
+
break;
|
1405
|
+
case 'flows':
|
1406
|
+
acc.flows = parseJsonSafely(setting.value, []);
|
1407
|
+
break;
|
1408
|
+
default:
|
1409
|
+
acc[setting.key] = setting.value;
|
1410
|
+
}
|
1411
|
+
return acc;
|
1412
|
+
}, {});
|
1413
|
+
}
|
1414
|
+
addShoppingCartSettings(settings) {
|
1415
|
+
// uniqBy removes items with the biggest index
|
1416
|
+
const newSettings = uniqBy([...settings, ...this.shoppingCartSettings$.value], 'id');
|
1417
|
+
this.shoppingCartSettings$.next(newSettings);
|
1418
|
+
}
|
1419
|
+
}
|
1420
|
+
RuntimeSettingsService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: RuntimeSettingsService, deps: [{ token: i1.ConfigurationSettingsApiService }], target: i0.ɵɵFactoryTarget.Injectable });
|
1421
|
+
RuntimeSettingsService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: RuntimeSettingsService });
|
1422
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: RuntimeSettingsService, decorators: [{
|
1423
|
+
type: Injectable
|
1424
|
+
}], ctorParameters: function () { return [{ type: i1.ConfigurationSettingsApiService }]; } });
|
1425
|
+
|
1468
1426
|
class ConfigurationService {
|
1469
1427
|
constructor(quoteDraftService, runtimeService, contextService, configurationApiService, messageService, dialogService, runtimeSettings) {
|
1470
1428
|
this.quoteDraftService = quoteDraftService;
|
@@ -1504,7 +1462,7 @@ class ConfigurationService {
|
|
1504
1462
|
const prevState = this.configurationState.value;
|
1505
1463
|
this.configurationState.next(prevState ? Object.assign({}, prevState) : null);
|
1506
1464
|
return throwError(() => error);
|
1507
|
-
}), tap
|
1465
|
+
}), tap(() => {
|
1508
1466
|
if (!this.hasUnsavedChanges) {
|
1509
1467
|
this.hasUnsavedChanges = true;
|
1510
1468
|
}
|
@@ -1517,7 +1475,7 @@ class ConfigurationService {
|
|
1517
1475
|
this.configurableRamp = lineItem;
|
1518
1476
|
}
|
1519
1477
|
get() {
|
1520
|
-
return this.configurationState.pipe(map
|
1478
|
+
return this.configurationState.pipe(map(state => state === null || state === void 0 ? void 0 : state.lineItem), shareReplay$1());
|
1521
1479
|
}
|
1522
1480
|
getSnapshot() {
|
1523
1481
|
var _a, _b;
|
@@ -1553,21 +1511,21 @@ class ConfigurationService {
|
|
1553
1511
|
return this.contextService.resolve$();
|
1554
1512
|
}
|
1555
1513
|
get charges$() {
|
1556
|
-
return this.configurationState.pipe(map
|
1514
|
+
return this.configurationState.pipe(map(state => { var _a; return (_a = state === null || state === void 0 ? void 0 : state.charges) !== null && _a !== void 0 ? _a : {}; }));
|
1557
1515
|
}
|
1558
1516
|
get chargesSnapshot() {
|
1559
1517
|
var _a, _b;
|
1560
1518
|
return (_b = (_a = this.configurationState.value) === null || _a === void 0 ? void 0 : _a.charges) !== null && _b !== void 0 ? _b : {};
|
1561
1519
|
}
|
1562
1520
|
get pricePlans$() {
|
1563
|
-
return this.configurationState.pipe(map
|
1521
|
+
return this.configurationState.pipe(map(state => { var _a; return (_a = state === null || state === void 0 ? void 0 : state.pricePlans) !== null && _a !== void 0 ? _a : {}; }));
|
1564
1522
|
}
|
1565
1523
|
get pricePlansSnapshot() {
|
1566
1524
|
var _a, _b;
|
1567
1525
|
return (_b = (_a = this.configurationState.value) === null || _a === void 0 ? void 0 : _a.pricePlans) !== null && _b !== void 0 ? _b : {};
|
1568
1526
|
}
|
1569
1527
|
get procedureContext$() {
|
1570
|
-
return this.configurationState.pipe(map
|
1528
|
+
return this.configurationState.pipe(map(state => { var _a; return (_a = state === null || state === void 0 ? void 0 : state.procedureContext) !== null && _a !== void 0 ? _a : {}; }));
|
1571
1529
|
}
|
1572
1530
|
get procedureContextSnapshot() {
|
1573
1531
|
var _a, _b;
|
@@ -1583,7 +1541,7 @@ class ConfigurationService {
|
|
1583
1541
|
const uiDefinitionProperties = this.getUIDefinitionProperties();
|
1584
1542
|
const mainPricingEnabled = (_a = runtimeContext.properties) === null || _a === void 0 ? void 0 : _a.PricingEnabled;
|
1585
1543
|
const pricingEnabled = mainPricingEnabled ? mainPricingEnabled === 'true' : uiDefinitionProperties.pricingEnabled;
|
1586
|
-
const customPriceApi = this.runtimeSettings.
|
1544
|
+
const customPriceApi = this.runtimeSettings.getConfigurationSettings()['CUSTOM_PRICE_API'];
|
1587
1545
|
this.isLoadingSubj$.next(true);
|
1588
1546
|
const configure$ = pricingEnabled && customPriceApi
|
1589
1547
|
? this.configurationApiService.customConfigurePrice({ url: customPriceApi, configurationRequest, runtimeModel })
|
@@ -1592,7 +1550,7 @@ class ConfigurationService {
|
|
1592
1550
|
runtimeModel,
|
1593
1551
|
pricingEnabled,
|
1594
1552
|
});
|
1595
|
-
return configure$.pipe(tap
|
1553
|
+
return configure$.pipe(tap(result => {
|
1596
1554
|
var _a;
|
1597
1555
|
this.contextService.update(result.context);
|
1598
1556
|
this.configurationState.next(result);
|
@@ -1601,7 +1559,7 @@ class ConfigurationService {
|
|
1601
1559
|
this.showInactiveProductsConfirmation();
|
1602
1560
|
}
|
1603
1561
|
this.configurableRamp = result.lineItem;
|
1604
|
-
}), map
|
1562
|
+
}), map(({ lineItem }) => lineItem), catchError$1(error => throwError(() => {
|
1605
1563
|
const resetState = this.previousConfigurationState.value;
|
1606
1564
|
if (resetState) {
|
1607
1565
|
this.previousConfigurationState.next(cloneDeep(resetState));
|
@@ -1616,7 +1574,7 @@ class ConfigurationService {
|
|
1616
1574
|
configureExternal$(props) {
|
1617
1575
|
return this.runtimeService
|
1618
1576
|
.init({ productId: props.productId, defaultQty: props.qty, attributesMap: props.attributesMap })
|
1619
|
-
.pipe(switchMap(() => this.configure()), first(), catchError$1(error => {
|
1577
|
+
.pipe(switchMap$1(() => this.configure()), first(), catchError$1(error => {
|
1620
1578
|
this.messageService.add({ severity: ToastType.error, summary: error });
|
1621
1579
|
throw error;
|
1622
1580
|
}), finalize$1(() => this.reset()));
|
@@ -1722,14 +1680,14 @@ class FlowConfigurationService {
|
|
1722
1680
|
this.updated$ = this.updatedSubj$.asObservable();
|
1723
1681
|
}
|
1724
1682
|
calculate$(quoteDraft) {
|
1725
|
-
return this.extendedApply$(quoteDraft).pipe(tap(result => {
|
1683
|
+
return this.extendedApply$(quoteDraft).pipe(tap$1(result => {
|
1726
1684
|
// sort the result current state based on the quote draft initial state
|
1727
1685
|
const initialStateIds = quoteDraft.initialState.map(lineItem => lineItem.integrationId);
|
1728
1686
|
result.currentState = result.currentState
|
1729
1687
|
.slice()
|
1730
1688
|
.sort((a, b) => initialStateIds.indexOf(a.integrationId) - initialStateIds.indexOf(b.integrationId));
|
1731
1689
|
this.quoteDraftService.updateQuoteDraft(result);
|
1732
|
-
}), map(noop));
|
1690
|
+
}), map$1(noop));
|
1733
1691
|
}
|
1734
1692
|
calculate(quoteDraft) {
|
1735
1693
|
this.calculate$(quoteDraft).subscribe();
|
@@ -1739,11 +1697,11 @@ class FlowConfigurationService {
|
|
1739
1697
|
if (!quoteDraft) {
|
1740
1698
|
return of(null);
|
1741
1699
|
}
|
1742
|
-
return of([]).pipe(map(() => {
|
1700
|
+
return of([]).pipe(map$1(() => {
|
1743
1701
|
const updatedState = cloneDeep(quoteDraft.currentState);
|
1744
1702
|
this.updateService.update(updatedState, updates, quoteDraft.charges);
|
1745
1703
|
return updatedState;
|
1746
|
-
}), switchMap
|
1704
|
+
}), switchMap(updatedState => this.calculate$(Object.assign(Object.assign({}, quoteDraft), { currentState: updatedState }))), map$1(() => this.quoteDraftService.quoteDraft), tap$1(() => this.updatedSubj$.next()), this.handleErrorAndBounceBack());
|
1747
1705
|
}
|
1748
1706
|
update(updates) {
|
1749
1707
|
this.update$(updates).subscribe();
|
@@ -1760,9 +1718,9 @@ class FlowConfigurationService {
|
|
1760
1718
|
}
|
1761
1719
|
const updatedState = cloneDeep(currentState);
|
1762
1720
|
updatedState.splice(currentLineItemIndex, 1, initialLineItem);
|
1763
|
-
return of([]).pipe(tap(() => {
|
1721
|
+
return of([]).pipe(tap$1(() => {
|
1764
1722
|
this.quoteDraftService.setCurrentLineItemState(updatedState);
|
1765
|
-
}), switchMap
|
1723
|
+
}), switchMap(() => this.calculate$(Object.assign(Object.assign({}, quoteDraft), { currentState: updatedState }))), map$1(() => this.quoteDraftService.quoteDraft), tap$1(() => this.updatedSubj$.next()), this.handleErrorAndBounceBack());
|
1766
1724
|
}
|
1767
1725
|
revert(lineItemId) {
|
1768
1726
|
this.revert$(lineItemId).subscribe();
|
@@ -1773,7 +1731,7 @@ class FlowConfigurationService {
|
|
1773
1731
|
if (!quoteDraft) {
|
1774
1732
|
return of(null);
|
1775
1733
|
}
|
1776
|
-
return of([]).pipe(map(() => ids.reduce((result, id) => this.updateService.delete(result, id), currentState)), switchMap
|
1734
|
+
return of([]).pipe(map$1(() => ids.reduce((result, id) => this.updateService.delete(result, id), currentState)), switchMap(updatedState => this.calculate$(Object.assign(Object.assign({}, quoteDraft), { currentState: updatedState }))), map$1(() => this.quoteDraftService.quoteDraft), tap$1(() => this.updatedSubj$.next()), this.handleErrorAndBounceBack());
|
1777
1735
|
}
|
1778
1736
|
delete(ids) {
|
1779
1737
|
this.delete$(ids).subscribe();
|
@@ -1784,36 +1742,36 @@ class FlowConfigurationService {
|
|
1784
1742
|
return of(null);
|
1785
1743
|
}
|
1786
1744
|
const updatedState = [...quoteDraft.currentState, term];
|
1787
|
-
return of([]).pipe(switchMap
|
1745
|
+
return of([]).pipe(switchMap(() => this.calculate$(Object.assign(Object.assign({}, quoteDraft), { currentState: updatedState }))), map$1(() => this.quoteDraftService.quoteDraft), tap$1(() => this.updatedSubj$.next()), this.handleErrorAndBounceBack());
|
1788
1746
|
}
|
1789
1747
|
addToCart$(props) {
|
1790
1748
|
const quoteDraft = this.quoteDraftService.quoteDraft;
|
1791
1749
|
if (!quoteDraft) {
|
1792
1750
|
return of(null);
|
1793
1751
|
}
|
1794
|
-
return this.configurationService.configureExternal$(props).pipe(map(lineItem => {
|
1752
|
+
return this.configurationService.configureExternal$(props).pipe(map$1(lineItem => {
|
1795
1753
|
var _a, _b, _c;
|
1796
1754
|
const model = this.configurationService.getRuntimeModel();
|
1797
1755
|
const split = (_b = (_a = model === null || model === void 0 ? void 0 : model.types.find(type => type.name === lineItem.type)) === null || _a === void 0 ? void 0 : _a.split) !== null && _b !== void 0 ? _b : false;
|
1798
1756
|
const lineItems = multiplyLineItems(lineItem, (_c = props.qty) !== null && _c !== void 0 ? _c : 1, split);
|
1799
1757
|
return [...quoteDraft.currentState, ...lineItems];
|
1800
|
-
}), switchMap
|
1758
|
+
}), switchMap(updatedState => this.calculate$(Object.assign(Object.assign({}, quoteDraft), { currentState: updatedState }))), map$1(() => this.quoteDraftService.quoteDraft), tap$1(() => this.updatedSubj$.next()), this.handleErrorAndBounceBack());
|
1801
1759
|
}
|
1802
1760
|
get() {
|
1803
|
-
return this.quoteDraftService.quoteDraft$.pipe(map(() => this.quoteDraftService.currentState), shareReplay$1());
|
1761
|
+
return this.quoteDraftService.quoteDraft$.pipe(map$1(() => this.quoteDraftService.currentState), shareReplay$1());
|
1804
1762
|
}
|
1805
1763
|
getSnapshot() {
|
1806
1764
|
var _a, _b;
|
1807
1765
|
return (_b = (_a = this.quoteDraftService) === null || _a === void 0 ? void 0 : _a.currentState.slice()) !== null && _b !== void 0 ? _b : [];
|
1808
1766
|
}
|
1809
1767
|
get charges$() {
|
1810
|
-
return this.quoteDraftService.quoteDraft$.pipe(map(({ charges }) => charges));
|
1768
|
+
return this.quoteDraftService.quoteDraft$.pipe(map$1(({ charges }) => charges));
|
1811
1769
|
}
|
1812
1770
|
get pricePlans$() {
|
1813
|
-
return this.quoteDraftService.quoteDraft$.pipe(map(({ pricePlans }) => pricePlans));
|
1771
|
+
return this.quoteDraftService.quoteDraft$.pipe(map$1(({ pricePlans }) => pricePlans));
|
1814
1772
|
}
|
1815
1773
|
get activeMetrics$() {
|
1816
|
-
return this.quoteDraftService.quoteDraft$.pipe(map(({ activeMetrics }) => activeMetrics));
|
1774
|
+
return this.quoteDraftService.quoteDraft$.pipe(map$1(({ activeMetrics }) => activeMetrics));
|
1817
1775
|
}
|
1818
1776
|
get chargesSnapshot() {
|
1819
1777
|
var _a, _b;
|
@@ -1898,18 +1856,18 @@ class FlowStateConfigurationService {
|
|
1898
1856
|
}
|
1899
1857
|
else {
|
1900
1858
|
const lineItem = generateConfigurationLineItem(props, props.qty);
|
1901
|
-
request$ = this.flowStateApiService.newConfiguration(stateId, { lineItem }).pipe(tap(r => this.configurationStateId$.next(r.stateId)), switchMap
|
1859
|
+
request$ = this.flowStateApiService.newConfiguration(stateId, { lineItem }).pipe(tap$1(r => this.configurationStateId$.next(r.stateId)), switchMap(() => {
|
1902
1860
|
if (!this.configurationStateId) {
|
1903
1861
|
return of();
|
1904
1862
|
}
|
1905
|
-
return this.flowStateApiService.saveConfiguration(stateId, this.configurationStateId).pipe(tap(() => this.configurationStateId$.next(null)), map(noop));
|
1863
|
+
return this.flowStateApiService.saveConfiguration(stateId, this.configurationStateId).pipe(tap$1(() => this.configurationStateId$.next(null)), map$1(noop));
|
1906
1864
|
}));
|
1907
1865
|
}
|
1908
1866
|
}
|
1909
1867
|
else {
|
1910
|
-
request$ = this.flowConfigurationService.addToCart$(props).pipe(map(noop));
|
1868
|
+
request$ = this.flowConfigurationService.addToCart$(props).pipe(map$1(noop));
|
1911
1869
|
}
|
1912
|
-
return request$.pipe(switchMap
|
1870
|
+
return request$.pipe(switchMap(() => this.flowStateService.executeRequest$({}, true)), map$1(noop));
|
1913
1871
|
}
|
1914
1872
|
}
|
1915
1873
|
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 });
|
@@ -1936,7 +1894,7 @@ class IntegrationState {
|
|
1936
1894
|
this.action$.next(action);
|
1937
1895
|
}
|
1938
1896
|
listen$(actionType) {
|
1939
|
-
return this.action$.pipe(filter$1(action => action.type === actionType), map(action => action.payload));
|
1897
|
+
return this.action$.pipe(filter$1(action => action.type === actionType), map$1(action => action.payload));
|
1940
1898
|
}
|
1941
1899
|
listenAll$() {
|
1942
1900
|
return this.action$.asObservable();
|
@@ -1961,12 +1919,12 @@ class ProductImagesService {
|
|
1961
1919
|
this.imagesMap$.next(Object.assign(Object.assign({}, this.imagesMap$.value), { [productId]: '' }));
|
1962
1920
|
this.fetchProductImage(productId);
|
1963
1921
|
}
|
1964
|
-
return this.imagesMap$.pipe(map(imagesMap => { var _a; return (_a = imagesMap[productId]) !== null && _a !== void 0 ? _a : null; }), distinctUntilChanged());
|
1922
|
+
return this.imagesMap$.pipe(map$1(imagesMap => { var _a; return (_a = imagesMap[productId]) !== null && _a !== void 0 ? _a : null; }), distinctUntilChanged());
|
1965
1923
|
}
|
1966
1924
|
fetchProductImage(productId) {
|
1967
1925
|
this.productApiService
|
1968
1926
|
.fetchImage$(productId)
|
1969
|
-
.pipe(map(file => URL.createObjectURL(file)), catchError(() => of('')), tap(url => this.imagesMap$.next(Object.assign(Object.assign({}, this.imagesMap$.value), { [productId]: url }))))
|
1927
|
+
.pipe(map$1(file => URL.createObjectURL(file)), catchError(() => of('')), tap$1(url => this.imagesMap$.next(Object.assign(Object.assign({}, this.imagesMap$.value), { [productId]: url }))))
|
1970
1928
|
.subscribe();
|
1971
1929
|
}
|
1972
1930
|
}
|
@@ -1981,7 +1939,7 @@ class RuntimeContextService {
|
|
1981
1939
|
this.configurationApiService = configurationApiService;
|
1982
1940
|
}
|
1983
1941
|
getRuntimeContext(productId, offeringId) {
|
1984
|
-
return this.configurationApiService.getRuntimeDataByProductId(productId, offeringId).pipe(map
|
1942
|
+
return this.configurationApiService.getRuntimeDataByProductId(productId, offeringId).pipe(map(runtimeData => {
|
1985
1943
|
var _a;
|
1986
1944
|
const uiDefinitionContainer = this.getUIDefinitionContainer(runtimeData);
|
1987
1945
|
const runtimeModel = RuntimeModel.create(runtimeData.types, runtimeData.products);
|
@@ -2035,7 +1993,7 @@ class ConfigurationRuntimeService {
|
|
2035
1993
|
return combineLatest([
|
2036
1994
|
this.apiService.getRuntimeDataByModelId(uiDefinitionContainer.modelId),
|
2037
1995
|
this.contextService.initTestMode(),
|
2038
|
-
]).pipe(first(), map
|
1996
|
+
]).pipe(first(), map(([runtimeData, context]) => {
|
2039
1997
|
var _a;
|
2040
1998
|
this.contextService.update({
|
2041
1999
|
properties: Object.assign(Object.assign(Object.assign(Object.assign({}, (_a = this.runtimeContext) === null || _a === void 0 ? void 0 : _a.properties), context.properties), { ModelId: uiDefinitionContainer.modelId, PricingEnabled: this.uiDefinitionProperties.pricingEnabled ? 'true' : 'false', PriceListId: this.uiDefinitionProperties.priceList, offeringId: this.uiDefinitionProperties.offeringId }), uiDefinitionExternals),
|
@@ -2047,12 +2005,12 @@ class ConfigurationRuntimeService {
|
|
2047
2005
|
uiDefinitionContainer,
|
2048
2006
|
};
|
2049
2007
|
return this._runtimeContext;
|
2050
|
-
}), tap
|
2008
|
+
}), tap(() => (this._isInitialized = true)));
|
2051
2009
|
}
|
2052
2010
|
init(props) {
|
2053
2011
|
this.initializationProps = props;
|
2054
2012
|
const context = this.contextService.resolve();
|
2055
|
-
return this.runtimeContextService.getRuntimeContext(props.productId, props.offeringId).pipe(tap
|
2013
|
+
return this.runtimeContextService.getRuntimeContext(props.productId, props.offeringId).pipe(tap(runtimeContext => {
|
2056
2014
|
var _a, _b, _c, _d;
|
2057
2015
|
this.uiDefinitionProperties = (_b = (_a = runtimeContext.uiDefinitionContainer) === null || _a === void 0 ? void 0 : _a.source.properties) !== null && _b !== void 0 ? _b : {};
|
2058
2016
|
const { PriceListId } = (_c = context.properties) !== null && _c !== void 0 ? _c : {};
|
@@ -2065,7 +2023,7 @@ class ConfigurationRuntimeService {
|
|
2065
2023
|
});
|
2066
2024
|
}
|
2067
2025
|
return this._runtimeContext;
|
2068
|
-
}), tap
|
2026
|
+
}), tap(() => (this._isInitialized = true)));
|
2069
2027
|
}
|
2070
2028
|
overrideUIDefinition(uiDefinitionContainer) {
|
2071
2029
|
var _a;
|
@@ -2154,7 +2112,7 @@ class ConfigurationStateService {
|
|
2154
2112
|
}
|
2155
2113
|
execute$(exec) {
|
2156
2114
|
const request = this.execToRequest(exec);
|
2157
|
-
return this.executeRequest$(request).pipe(map(result => {
|
2115
|
+
return this.executeRequest$(request).pipe(map$1(result => {
|
2158
2116
|
// Keep only requested results
|
2159
2117
|
const actualSelectors = Object.entries(result.selectors).reduce((trunk, [requestId, result]) => {
|
2160
2118
|
var _a;
|
@@ -2191,7 +2149,7 @@ class ConfigurationStateService {
|
|
2191
2149
|
},
|
2192
2150
|
},
|
2193
2151
|
});
|
2194
|
-
return this.executeRequest$(request).pipe(map(response => response.selectors[requestId]));
|
2152
|
+
return this.executeRequest$(request).pipe(map$1(response => response.selectors[requestId]));
|
2195
2153
|
}
|
2196
2154
|
subscribe$(selectorName, inputData = {}, options) {
|
2197
2155
|
const requestId = UUID.UUID();
|
@@ -2214,7 +2172,7 @@ class ConfigurationStateService {
|
|
2214
2172
|
this.executeRequest$(request).subscribe();
|
2215
2173
|
}
|
2216
2174
|
}
|
2217
|
-
return subscription.data$.pipe(filter$1(data => data != this.NOT_INITIALIZED), map(data => data), distinctUntilChanged(), finalize(() => {
|
2175
|
+
return subscription.data$.pipe(filter$1(data => data != this.NOT_INITIALIZED), map$1(data => data), distinctUntilChanged(), finalize(() => {
|
2218
2176
|
var _a;
|
2219
2177
|
if (!((_a = this.subscriptions[requestId]) === null || _a === void 0 ? void 0 : _a.data$.observed)) {
|
2220
2178
|
delete this.subscriptions[requestId];
|
@@ -2227,7 +2185,7 @@ class ConfigurationStateService {
|
|
2227
2185
|
if (this.isStatefulConfiguration) {
|
2228
2186
|
return this.flowStateApiService
|
2229
2187
|
.saveConfiguration((_a = this.flowStateService.stateId) !== null && _a !== void 0 ? _a : '', (_b = this.stateId) !== null && _b !== void 0 ? _b : '')
|
2230
|
-
.pipe(switchMap
|
2188
|
+
.pipe(switchMap(r => this.flowStateService.executeRequest$({}, true).pipe(map$1(() => r))));
|
2231
2189
|
}
|
2232
2190
|
else {
|
2233
2191
|
if (!flow) {
|
@@ -2264,7 +2222,7 @@ class ConfigurationStateService {
|
|
2264
2222
|
}
|
2265
2223
|
return this.flowConfigurationService
|
2266
2224
|
.calculate$(Object.assign(Object.assign({}, quoteDraft), { currentState, initialState }))
|
2267
|
-
.pipe(map(() => ({ quoteId: '' })));
|
2225
|
+
.pipe(map$1(() => ({ quoteId: '' })));
|
2268
2226
|
}
|
2269
2227
|
}
|
2270
2228
|
}
|
@@ -2310,13 +2268,13 @@ class ConfigurationStateService {
|
|
2310
2268
|
selectorsOverride: (_k = container === null || container === void 0 ? void 0 : container.selectors) === null || _k === void 0 ? void 0 : _k.map(processor => (Object.assign(Object.assign({}, processor), { ownerId: this.ownerId }))),
|
2311
2269
|
});
|
2312
2270
|
}
|
2313
|
-
return request$.pipe(map(r => {
|
2271
|
+
return request$.pipe(map$1(r => {
|
2314
2272
|
this.stateId = r.stateId;
|
2315
2273
|
return undefined;
|
2316
2274
|
}));
|
2317
2275
|
}
|
2318
2276
|
initStateless$() {
|
2319
|
-
return this.configurationService.configure().pipe(map(() => undefined));
|
2277
|
+
return this.configurationService.configure().pipe(map$1(() => undefined));
|
2320
2278
|
}
|
2321
2279
|
execToRequest(exec) {
|
2322
2280
|
var _a;
|
@@ -2363,11 +2321,11 @@ class ConfigurationStateService {
|
|
2363
2321
|
else {
|
2364
2322
|
execution$ = this.executeStateless$(fullRequest);
|
2365
2323
|
}
|
2366
|
-
return execution$.pipe(tap(result => this.handleSelectorsResponse(result.selectors)));
|
2324
|
+
return execution$.pipe(tap$1(result => this.handleSelectorsResponse(result.selectors)));
|
2367
2325
|
}
|
2368
2326
|
executeStateless$(request) {
|
2369
2327
|
this.executionInProgress$.next(true);
|
2370
|
-
return of(undefined).pipe(switchMap
|
2328
|
+
return of(undefined).pipe(switchMap(() => {
|
2371
2329
|
var _a;
|
2372
2330
|
// Apply actions and execute configuration/price call
|
2373
2331
|
// No need to run configuration if no actions in the request
|
@@ -2381,14 +2339,14 @@ class ConfigurationStateService {
|
|
2381
2339
|
});
|
2382
2340
|
configurationRequest = ConfigurationTranslatorUtils.lightenConfigurationRequest(configurationRequest);
|
2383
2341
|
return this.configurationService.configureRequest$(configurationRequest);
|
2384
|
-
}), map(() => {
|
2342
|
+
}), map$1(() => {
|
2385
2343
|
// Run selectors and apply them to the state
|
2386
2344
|
const configurationState = this.configurationService.stateSnapshot;
|
2387
2345
|
if (!configurationState) {
|
2388
2346
|
return { stateId: '', selectors: {} };
|
2389
2347
|
}
|
2390
2348
|
return this.runStatelessSelectors(request, configurationState);
|
2391
|
-
}), tap(() => this.executionInProgress$.next(false)), catchError(error => {
|
2349
|
+
}), tap$1(() => this.executionInProgress$.next(false)), catchError(error => {
|
2392
2350
|
const configurationState = this.configurationService.previousStateSnapshot;
|
2393
2351
|
if (configurationState) {
|
2394
2352
|
const selectorsResult = this.runStatelessSelectors(request, configurationState);
|
@@ -2402,7 +2360,7 @@ class ConfigurationStateService {
|
|
2402
2360
|
}));
|
2403
2361
|
}
|
2404
2362
|
initBufferedRequest$() {
|
2405
|
-
return this.statefulRequestStream$.pipe(buffer(this.statefulRequestStream$.pipe(debounceTime(this.EXECUTION_BUFFER_TIME))), switchMap
|
2363
|
+
return this.statefulRequestStream$.pipe(buffer(this.statefulRequestStream$.pipe(debounceTime(this.EXECUTION_BUFFER_TIME))), switchMap(requests => {
|
2406
2364
|
if (!this.flowStateService.stateId || !this.stateId) {
|
2407
2365
|
throw 'Stateful session is not initialized';
|
2408
2366
|
}
|
@@ -2416,18 +2374,18 @@ class ConfigurationStateService {
|
|
2416
2374
|
};
|
2417
2375
|
this.executionInProgress$.next(true);
|
2418
2376
|
return this.flowStateApiService.executeConfiguration(this.flowStateService.stateId, this.stateId, request);
|
2419
|
-
}), tap(({ stateId }) => (this.stateId = stateId)), share(), tap(() => this.executionInProgress$.next(false)), catchError(e => {
|
2377
|
+
}), tap$1(({ stateId }) => (this.stateId = stateId)), share(), tap$1(() => this.executionInProgress$.next(false)), catchError(e => {
|
2420
2378
|
this.executionInProgress$.next(false);
|
2421
2379
|
return throwError(() => e);
|
2422
2380
|
}));
|
2423
2381
|
}
|
2424
2382
|
executeStateful$(request) {
|
2425
|
-
return this.executionInProgress$.pipe(filter$1(inProgress => !inProgress), take$1(1), switchMap
|
2383
|
+
return this.executionInProgress$.pipe(filter$1(inProgress => !inProgress), take$1(1), switchMap(() =>
|
2426
2384
|
// make sure stream switches to statefulExecutionRequest$ before pushing an execution request
|
2427
2385
|
combineLatest([
|
2428
2386
|
this.statefulExecutionRequest$,
|
2429
|
-
of(undefined).pipe(tap(() => this.statefulRequestStream$.next(request))),
|
2430
|
-
])), map(([response]) => response), take$1(1));
|
2387
|
+
of(undefined).pipe(tap$1(() => this.statefulRequestStream$.next(request))),
|
2388
|
+
])), map$1(([response]) => response), take$1(1));
|
2431
2389
|
}
|
2432
2390
|
executeActionScript(request, processor) {
|
2433
2391
|
var _a, _b;
|