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