@veloceapps/sdk 10.0.0-5 → 10.0.0-51
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/cms/modules/runtime/services/runtime.service.d.ts +3 -1
- package/cms/utils/index.d.ts +1 -0
- package/cms/utils/inject.d.ts +1 -0
- package/cms/utils/ui-definition.utils.d.ts +1 -0
- package/cms/vendor-map.d.ts +4 -2
- package/core/modules/configuration/services/configuration-state.service.d.ts +2 -0
- package/core/modules/configuration/services/configuration.service.d.ts +2 -0
- package/core/modules/flow-configuration/services/flow-configuration.service.d.ts +4 -1
- package/core/services/context.service.d.ts +3 -1
- package/core/services/flow-info.service.d.ts +4 -2
- package/core/services/quote-draft.service.d.ts +3 -1
- package/core/services/runtime-settings.service.d.ts +1 -1
- package/esm2020/cms/components/element-renderer/element-renderer.component.mjs +3 -2
- package/esm2020/cms/components/element-tools-panel/element-tools-panel.component.mjs +3 -3
- package/esm2020/cms/modules/runtime/services/runtime.service.mjs +3 -1
- package/esm2020/cms/utils/index.mjs +2 -1
- package/esm2020/cms/utils/inject.mjs +27 -0
- package/esm2020/cms/utils/ui-definition.utils.mjs +13 -1
- package/esm2020/cms/vendor-map.mjs +7 -4
- package/esm2020/core/modules/configuration/services/configuration-state.service.mjs +38 -22
- package/esm2020/core/modules/configuration/services/configuration.service.mjs +14 -3
- package/esm2020/core/modules/flow-configuration/services/flow-configuration.service.mjs +16 -5
- package/esm2020/core/services/context.service.mjs +15 -6
- package/esm2020/core/services/flow-info.service.mjs +19 -6
- package/esm2020/core/services/flow-state.service.mjs +19 -6
- package/esm2020/core/services/quote-draft.service.mjs +21 -9
- package/esm2020/core/services/runtime-settings.service.mjs +3 -3
- package/esm2020/src/guards/context.guard.mjs +4 -6
- package/esm2020/src/guards/flow.guard.mjs +5 -4
- package/fesm2015/veloceapps-sdk-cms.mjs +45 -5
- package/fesm2015/veloceapps-sdk-cms.mjs.map +1 -1
- package/fesm2015/veloceapps-sdk-core.mjs +333 -254
- package/fesm2015/veloceapps-sdk-core.mjs.map +1 -1
- package/fesm2015/veloceapps-sdk.mjs +6 -7
- package/fesm2015/veloceapps-sdk.mjs.map +1 -1
- package/fesm2020/veloceapps-sdk-cms.mjs +44 -4
- package/fesm2020/veloceapps-sdk-cms.mjs.map +1 -1
- package/fesm2020/veloceapps-sdk-core.mjs +328 -251
- 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,8 +766,8 @@ class FlowStateService {
|
|
|
617
766
|
else {
|
|
618
767
|
const quoteDraft = this.quoteDraftService.quoteDraft;
|
|
619
768
|
if (quoteDraft) {
|
|
620
|
-
return this.quoteApiService.upsertQuote(quoteDraft).pipe(tap
|
|
621
|
-
this.contextService.update({ properties: {
|
|
769
|
+
return this.quoteApiService.upsertQuote(quoteDraft).pipe(tap(({ versionId }) => {
|
|
770
|
+
this.contextService.update({ properties: { VELOCPQ__VersionId__c: versionId } });
|
|
622
771
|
}));
|
|
623
772
|
}
|
|
624
773
|
}
|
|
@@ -633,8 +782,8 @@ class FlowStateService {
|
|
|
633
782
|
else {
|
|
634
783
|
const quoteDraft = this.quoteDraftService.quoteDraft;
|
|
635
784
|
if (quoteDraft) {
|
|
636
|
-
return this.quoteApiService.submitQuote(quoteDraft).pipe(tap
|
|
637
|
-
this.contextService.update({ properties: {
|
|
785
|
+
return this.quoteApiService.submitQuote(quoteDraft).pipe(tap(({ versionId }) => {
|
|
786
|
+
this.contextService.update({ properties: { VELOCPQ__VersionId__c: versionId } });
|
|
638
787
|
}));
|
|
639
788
|
}
|
|
640
789
|
}
|
|
@@ -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;
|
|
@@ -1434,6 +1476,7 @@ class ConfigurationService {
|
|
|
1434
1476
|
this.runtimeSettings = runtimeSettings;
|
|
1435
1477
|
this.mode = ConfigurationMode.SEARCH;
|
|
1436
1478
|
this.configurationState = new BehaviorSubject(null);
|
|
1479
|
+
this.previousConfigurationState = new BehaviorSubject(null);
|
|
1437
1480
|
this.isLoadingSubj$ = new BehaviorSubject(false);
|
|
1438
1481
|
this.isLoading$ = this.isLoadingSubj$.asObservable();
|
|
1439
1482
|
this.hasUnsavedChanges = false;
|
|
@@ -1443,6 +1486,7 @@ class ConfigurationService {
|
|
|
1443
1486
|
this.runtimeService.reset();
|
|
1444
1487
|
this.configurableRamp = undefined;
|
|
1445
1488
|
this.configurationState.next(null);
|
|
1489
|
+
this.previousConfigurationState.next(null);
|
|
1446
1490
|
}
|
|
1447
1491
|
patch$(lineItem, options) {
|
|
1448
1492
|
const source = this.getSnapshot();
|
|
@@ -1460,7 +1504,7 @@ class ConfigurationService {
|
|
|
1460
1504
|
const prevState = this.configurationState.value;
|
|
1461
1505
|
this.configurationState.next(prevState ? Object.assign({}, prevState) : null);
|
|
1462
1506
|
return throwError(() => error);
|
|
1463
|
-
}), tap(() => {
|
|
1507
|
+
}), tap$1(() => {
|
|
1464
1508
|
if (!this.hasUnsavedChanges) {
|
|
1465
1509
|
this.hasUnsavedChanges = true;
|
|
1466
1510
|
}
|
|
@@ -1473,7 +1517,7 @@ class ConfigurationService {
|
|
|
1473
1517
|
this.configurableRamp = lineItem;
|
|
1474
1518
|
}
|
|
1475
1519
|
get() {
|
|
1476
|
-
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());
|
|
1477
1521
|
}
|
|
1478
1522
|
getSnapshot() {
|
|
1479
1523
|
var _a, _b;
|
|
@@ -1499,6 +1543,9 @@ class ConfigurationService {
|
|
|
1499
1543
|
get stateSnapshot() {
|
|
1500
1544
|
return this.configurationState.value;
|
|
1501
1545
|
}
|
|
1546
|
+
get previousStateSnapshot() {
|
|
1547
|
+
return this.previousConfigurationState.value;
|
|
1548
|
+
}
|
|
1502
1549
|
get contextSnapshot() {
|
|
1503
1550
|
return this.contextService.resolve();
|
|
1504
1551
|
}
|
|
@@ -1506,21 +1553,21 @@ class ConfigurationService {
|
|
|
1506
1553
|
return this.contextService.resolve$();
|
|
1507
1554
|
}
|
|
1508
1555
|
get charges$() {
|
|
1509
|
-
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 : {}; }));
|
|
1510
1557
|
}
|
|
1511
1558
|
get chargesSnapshot() {
|
|
1512
1559
|
var _a, _b;
|
|
1513
1560
|
return (_b = (_a = this.configurationState.value) === null || _a === void 0 ? void 0 : _a.charges) !== null && _b !== void 0 ? _b : {};
|
|
1514
1561
|
}
|
|
1515
1562
|
get pricePlans$() {
|
|
1516
|
-
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 : {}; }));
|
|
1517
1564
|
}
|
|
1518
1565
|
get pricePlansSnapshot() {
|
|
1519
1566
|
var _a, _b;
|
|
1520
1567
|
return (_b = (_a = this.configurationState.value) === null || _a === void 0 ? void 0 : _a.pricePlans) !== null && _b !== void 0 ? _b : {};
|
|
1521
1568
|
}
|
|
1522
1569
|
get procedureContext$() {
|
|
1523
|
-
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 : {}; }));
|
|
1524
1571
|
}
|
|
1525
1572
|
get procedureContextSnapshot() {
|
|
1526
1573
|
var _a, _b;
|
|
@@ -1536,7 +1583,7 @@ class ConfigurationService {
|
|
|
1536
1583
|
const uiDefinitionProperties = this.getUIDefinitionProperties();
|
|
1537
1584
|
const mainPricingEnabled = (_a = runtimeContext.properties) === null || _a === void 0 ? void 0 : _a.PricingEnabled;
|
|
1538
1585
|
const pricingEnabled = mainPricingEnabled ? mainPricingEnabled === 'true' : uiDefinitionProperties.pricingEnabled;
|
|
1539
|
-
const customPriceApi = this.runtimeSettings.
|
|
1586
|
+
const customPriceApi = this.runtimeSettings.configurationSettings['CUSTOM_PRICE_API'];
|
|
1540
1587
|
this.isLoadingSubj$.next(true);
|
|
1541
1588
|
const configure$ = pricingEnabled && customPriceApi
|
|
1542
1589
|
? this.configurationApiService.customConfigurePrice({ url: customPriceApi, configurationRequest, runtimeModel })
|
|
@@ -1545,15 +1592,21 @@ class ConfigurationService {
|
|
|
1545
1592
|
runtimeModel,
|
|
1546
1593
|
pricingEnabled,
|
|
1547
1594
|
});
|
|
1548
|
-
return configure$.pipe(tap(result => {
|
|
1595
|
+
return configure$.pipe(tap$1(result => {
|
|
1549
1596
|
var _a;
|
|
1550
1597
|
this.contextService.update(result.context);
|
|
1551
1598
|
this.configurationState.next(result);
|
|
1599
|
+
this.previousConfigurationState.next(cloneDeep(result));
|
|
1552
1600
|
if ((_a = result.deletedLineItems) === null || _a === void 0 ? void 0 : _a.length) {
|
|
1553
1601
|
this.showInactiveProductsConfirmation();
|
|
1554
1602
|
}
|
|
1555
1603
|
this.configurableRamp = result.lineItem;
|
|
1556
|
-
}), map(({ lineItem }) => lineItem), catchError$1(error => throwError(() => {
|
|
1604
|
+
}), map$1(({ lineItem }) => lineItem), catchError$1(error => throwError(() => {
|
|
1605
|
+
const resetState = this.previousConfigurationState.value;
|
|
1606
|
+
if (resetState) {
|
|
1607
|
+
this.previousConfigurationState.next(cloneDeep(resetState));
|
|
1608
|
+
this.configurationState.next(resetState);
|
|
1609
|
+
}
|
|
1557
1610
|
if (error.error) {
|
|
1558
1611
|
return extractErrorDetails(error.error).join('. ');
|
|
1559
1612
|
}
|
|
@@ -1563,7 +1616,7 @@ class ConfigurationService {
|
|
|
1563
1616
|
configureExternal$(props) {
|
|
1564
1617
|
return this.runtimeService
|
|
1565
1618
|
.init({ productId: props.productId, defaultQty: props.qty, attributesMap: props.attributesMap })
|
|
1566
|
-
.pipe(switchMap
|
|
1619
|
+
.pipe(switchMap(() => this.configure()), first(), catchError$1(error => {
|
|
1567
1620
|
this.messageService.add({ severity: ToastType.error, summary: error });
|
|
1568
1621
|
throw error;
|
|
1569
1622
|
}), finalize$1(() => this.reset()));
|
|
@@ -1601,7 +1654,7 @@ class ConfigurationService {
|
|
|
1601
1654
|
var _a;
|
|
1602
1655
|
const runtimeContext = this.getRuntimeContext();
|
|
1603
1656
|
const uiDefinitionProperties = this.getUIDefinitionProperties();
|
|
1604
|
-
let lineItem =
|
|
1657
|
+
let lineItem = this.configurableRamp;
|
|
1605
1658
|
if (!lineItem) {
|
|
1606
1659
|
const { initializationProps } = (_a = this.runtimeService) !== null && _a !== void 0 ? _a : {};
|
|
1607
1660
|
lineItem = getDefaultLineItem(runtimeContext, uiDefinitionProperties, initializationProps === null || initializationProps === void 0 ? void 0 : initializationProps.defaultQty);
|
|
@@ -1658,24 +1711,25 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImpor
|
|
|
1658
1711
|
}], ctorParameters: function () { return [{ type: QuoteDraftService }, { type: ConfigurationRuntimeService }, { type: ContextService }, { type: i1.ConfigurationApiService }, { type: i5.MessageService }, { type: i6$1.DialogService }, { type: RuntimeSettingsService }]; } });
|
|
1659
1712
|
|
|
1660
1713
|
class FlowConfigurationService {
|
|
1661
|
-
constructor(proceduresApiService, contextService, quoteDraftService, updateService, configurationService) {
|
|
1714
|
+
constructor(proceduresApiService, contextService, quoteDraftService, updateService, configurationService, flowInfoService) {
|
|
1662
1715
|
this.proceduresApiService = proceduresApiService;
|
|
1663
1716
|
this.contextService = contextService;
|
|
1664
1717
|
this.quoteDraftService = quoteDraftService;
|
|
1665
1718
|
this.updateService = updateService;
|
|
1666
1719
|
this.configurationService = configurationService;
|
|
1720
|
+
this.flowInfoService = flowInfoService;
|
|
1667
1721
|
this.updatedSubj$ = new Subject();
|
|
1668
1722
|
this.updated$ = this.updatedSubj$.asObservable();
|
|
1669
1723
|
}
|
|
1670
1724
|
calculate$(quoteDraft) {
|
|
1671
|
-
return this.
|
|
1725
|
+
return this.extendedApply$(quoteDraft).pipe(tap(result => {
|
|
1672
1726
|
// sort the result current state based on the quote draft initial state
|
|
1673
1727
|
const initialStateIds = quoteDraft.initialState.map(lineItem => lineItem.integrationId);
|
|
1674
1728
|
result.currentState = result.currentState
|
|
1675
1729
|
.slice()
|
|
1676
1730
|
.sort((a, b) => initialStateIds.indexOf(a.integrationId) - initialStateIds.indexOf(b.integrationId));
|
|
1677
1731
|
this.quoteDraftService.updateQuoteDraft(result);
|
|
1678
|
-
}), map
|
|
1732
|
+
}), map(noop));
|
|
1679
1733
|
}
|
|
1680
1734
|
calculate(quoteDraft) {
|
|
1681
1735
|
this.calculate$(quoteDraft).subscribe();
|
|
@@ -1685,11 +1739,11 @@ class FlowConfigurationService {
|
|
|
1685
1739
|
if (!quoteDraft) {
|
|
1686
1740
|
return of(null);
|
|
1687
1741
|
}
|
|
1688
|
-
return of([]).pipe(map
|
|
1742
|
+
return of([]).pipe(map(() => {
|
|
1689
1743
|
const updatedState = cloneDeep(quoteDraft.currentState);
|
|
1690
1744
|
this.updateService.update(updatedState, updates, quoteDraft.charges);
|
|
1691
1745
|
return updatedState;
|
|
1692
|
-
}), 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());
|
|
1693
1747
|
}
|
|
1694
1748
|
update(updates) {
|
|
1695
1749
|
this.update$(updates).subscribe();
|
|
@@ -1706,9 +1760,9 @@ class FlowConfigurationService {
|
|
|
1706
1760
|
}
|
|
1707
1761
|
const updatedState = cloneDeep(currentState);
|
|
1708
1762
|
updatedState.splice(currentLineItemIndex, 1, initialLineItem);
|
|
1709
|
-
return of([]).pipe(tap
|
|
1763
|
+
return of([]).pipe(tap(() => {
|
|
1710
1764
|
this.quoteDraftService.setCurrentLineItemState(updatedState);
|
|
1711
|
-
}), 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());
|
|
1712
1766
|
}
|
|
1713
1767
|
revert(lineItemId) {
|
|
1714
1768
|
this.revert$(lineItemId).subscribe();
|
|
@@ -1719,7 +1773,7 @@ class FlowConfigurationService {
|
|
|
1719
1773
|
if (!quoteDraft) {
|
|
1720
1774
|
return of(null);
|
|
1721
1775
|
}
|
|
1722
|
-
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());
|
|
1723
1777
|
}
|
|
1724
1778
|
delete(ids) {
|
|
1725
1779
|
this.delete$(ids).subscribe();
|
|
@@ -1730,36 +1784,36 @@ class FlowConfigurationService {
|
|
|
1730
1784
|
return of(null);
|
|
1731
1785
|
}
|
|
1732
1786
|
const updatedState = [...quoteDraft.currentState, term];
|
|
1733
|
-
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());
|
|
1734
1788
|
}
|
|
1735
1789
|
addToCart$(props) {
|
|
1736
1790
|
const quoteDraft = this.quoteDraftService.quoteDraft;
|
|
1737
1791
|
if (!quoteDraft) {
|
|
1738
1792
|
return of(null);
|
|
1739
1793
|
}
|
|
1740
|
-
return this.configurationService.configureExternal$(props).pipe(map
|
|
1794
|
+
return this.configurationService.configureExternal$(props).pipe(map(lineItem => {
|
|
1741
1795
|
var _a, _b, _c;
|
|
1742
1796
|
const model = this.configurationService.getRuntimeModel();
|
|
1743
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;
|
|
1744
1798
|
const lineItems = multiplyLineItems(lineItem, (_c = props.qty) !== null && _c !== void 0 ? _c : 1, split);
|
|
1745
1799
|
return [...quoteDraft.currentState, ...lineItems];
|
|
1746
|
-
}), 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());
|
|
1747
1801
|
}
|
|
1748
1802
|
get() {
|
|
1749
|
-
return this.quoteDraftService.quoteDraft$.pipe(map
|
|
1803
|
+
return this.quoteDraftService.quoteDraft$.pipe(map(() => this.quoteDraftService.currentState), shareReplay$1());
|
|
1750
1804
|
}
|
|
1751
1805
|
getSnapshot() {
|
|
1752
1806
|
var _a, _b;
|
|
1753
1807
|
return (_b = (_a = this.quoteDraftService) === null || _a === void 0 ? void 0 : _a.currentState.slice()) !== null && _b !== void 0 ? _b : [];
|
|
1754
1808
|
}
|
|
1755
1809
|
get charges$() {
|
|
1756
|
-
return this.quoteDraftService.quoteDraft$.pipe(map
|
|
1810
|
+
return this.quoteDraftService.quoteDraft$.pipe(map(({ charges }) => charges));
|
|
1757
1811
|
}
|
|
1758
1812
|
get pricePlans$() {
|
|
1759
|
-
return this.quoteDraftService.quoteDraft$.pipe(map
|
|
1813
|
+
return this.quoteDraftService.quoteDraft$.pipe(map(({ pricePlans }) => pricePlans));
|
|
1760
1814
|
}
|
|
1761
1815
|
get activeMetrics$() {
|
|
1762
|
-
return this.quoteDraftService.quoteDraft$.pipe(map
|
|
1816
|
+
return this.quoteDraftService.quoteDraft$.pipe(map(({ activeMetrics }) => activeMetrics));
|
|
1763
1817
|
}
|
|
1764
1818
|
get chargesSnapshot() {
|
|
1765
1819
|
var _a, _b;
|
|
@@ -1793,12 +1847,21 @@ class FlowConfigurationService {
|
|
|
1793
1847
|
}));
|
|
1794
1848
|
};
|
|
1795
1849
|
}
|
|
1850
|
+
extendedApply$(quoteDraft) {
|
|
1851
|
+
var _a;
|
|
1852
|
+
const request = Object.assign({}, quoteDraft);
|
|
1853
|
+
const procedureName = (_a = this.flowInfoService.flow) === null || _a === void 0 ? void 0 : _a.properties.procedureName;
|
|
1854
|
+
if (procedureName) {
|
|
1855
|
+
request.procedureName = procedureName;
|
|
1856
|
+
}
|
|
1857
|
+
return this.proceduresApiService.apply$(request);
|
|
1858
|
+
}
|
|
1796
1859
|
}
|
|
1797
|
-
FlowConfigurationService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: FlowConfigurationService, deps: [{ token: i1.ProceduresApiService }, { token: ContextService }, { token: QuoteDraftService }, { token: FlowUpdateService }, { token: ConfigurationService }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
1860
|
+
FlowConfigurationService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: FlowConfigurationService, deps: [{ token: i1.ProceduresApiService }, { token: ContextService }, { token: QuoteDraftService }, { token: FlowUpdateService }, { token: ConfigurationService }, { token: FlowInfoService }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
1798
1861
|
FlowConfigurationService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: FlowConfigurationService });
|
|
1799
1862
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: FlowConfigurationService, decorators: [{
|
|
1800
1863
|
type: Injectable
|
|
1801
|
-
}], ctorParameters: function () { return [{ type: i1.ProceduresApiService }, { type: ContextService }, { type: QuoteDraftService }, { type: FlowUpdateService }, { type: ConfigurationService }]; } });
|
|
1864
|
+
}], ctorParameters: function () { return [{ type: i1.ProceduresApiService }, { type: ContextService }, { type: QuoteDraftService }, { type: FlowUpdateService }, { type: ConfigurationService }, { type: FlowInfoService }]; } });
|
|
1802
1865
|
|
|
1803
1866
|
class FlowConfigurationModule {
|
|
1804
1867
|
}
|
|
@@ -1835,18 +1898,18 @@ class FlowStateConfigurationService {
|
|
|
1835
1898
|
}
|
|
1836
1899
|
else {
|
|
1837
1900
|
const lineItem = generateConfigurationLineItem(props, props.qty);
|
|
1838
|
-
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(() => {
|
|
1839
1902
|
if (!this.configurationStateId) {
|
|
1840
1903
|
return of();
|
|
1841
1904
|
}
|
|
1842
|
-
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));
|
|
1843
1906
|
}));
|
|
1844
1907
|
}
|
|
1845
1908
|
}
|
|
1846
1909
|
else {
|
|
1847
|
-
request$ = this.flowConfigurationService.addToCart$(props).pipe(map
|
|
1910
|
+
request$ = this.flowConfigurationService.addToCart$(props).pipe(map(noop));
|
|
1848
1911
|
}
|
|
1849
|
-
return request$.pipe(switchMap(() => this.flowStateService.executeRequest$({}, true)), map
|
|
1912
|
+
return request$.pipe(switchMap$1(() => this.flowStateService.executeRequest$({}, true)), map(noop));
|
|
1850
1913
|
}
|
|
1851
1914
|
}
|
|
1852
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 });
|
|
@@ -1873,7 +1936,7 @@ class IntegrationState {
|
|
|
1873
1936
|
this.action$.next(action);
|
|
1874
1937
|
}
|
|
1875
1938
|
listen$(actionType) {
|
|
1876
|
-
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));
|
|
1877
1940
|
}
|
|
1878
1941
|
listenAll$() {
|
|
1879
1942
|
return this.action$.asObservable();
|
|
@@ -1898,12 +1961,12 @@ class ProductImagesService {
|
|
|
1898
1961
|
this.imagesMap$.next(Object.assign(Object.assign({}, this.imagesMap$.value), { [productId]: '' }));
|
|
1899
1962
|
this.fetchProductImage(productId);
|
|
1900
1963
|
}
|
|
1901
|
-
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());
|
|
1902
1965
|
}
|
|
1903
1966
|
fetchProductImage(productId) {
|
|
1904
1967
|
this.productApiService
|
|
1905
1968
|
.fetchImage$(productId)
|
|
1906
|
-
.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 }))))
|
|
1907
1970
|
.subscribe();
|
|
1908
1971
|
}
|
|
1909
1972
|
}
|
|
@@ -1918,7 +1981,7 @@ class RuntimeContextService {
|
|
|
1918
1981
|
this.configurationApiService = configurationApiService;
|
|
1919
1982
|
}
|
|
1920
1983
|
getRuntimeContext(productId, offeringId) {
|
|
1921
|
-
return this.configurationApiService.getRuntimeDataByProductId(productId, offeringId).pipe(map(runtimeData => {
|
|
1984
|
+
return this.configurationApiService.getRuntimeDataByProductId(productId, offeringId).pipe(map$1(runtimeData => {
|
|
1922
1985
|
var _a;
|
|
1923
1986
|
const uiDefinitionContainer = this.getUIDefinitionContainer(runtimeData);
|
|
1924
1987
|
const runtimeModel = RuntimeModel.create(runtimeData.types, runtimeData.products);
|
|
@@ -1972,7 +2035,7 @@ class ConfigurationRuntimeService {
|
|
|
1972
2035
|
return combineLatest([
|
|
1973
2036
|
this.apiService.getRuntimeDataByModelId(uiDefinitionContainer.modelId),
|
|
1974
2037
|
this.contextService.initTestMode(),
|
|
1975
|
-
]).pipe(first(), map(([runtimeData, context]) => {
|
|
2038
|
+
]).pipe(first(), map$1(([runtimeData, context]) => {
|
|
1976
2039
|
var _a;
|
|
1977
2040
|
this.contextService.update({
|
|
1978
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),
|
|
@@ -1984,12 +2047,12 @@ class ConfigurationRuntimeService {
|
|
|
1984
2047
|
uiDefinitionContainer,
|
|
1985
2048
|
};
|
|
1986
2049
|
return this._runtimeContext;
|
|
1987
|
-
}), tap(() => (this._isInitialized = true)));
|
|
2050
|
+
}), tap$1(() => (this._isInitialized = true)));
|
|
1988
2051
|
}
|
|
1989
2052
|
init(props) {
|
|
1990
2053
|
this.initializationProps = props;
|
|
1991
2054
|
const context = this.contextService.resolve();
|
|
1992
|
-
return this.runtimeContextService.getRuntimeContext(props.productId, props.offeringId).pipe(tap(runtimeContext => {
|
|
2055
|
+
return this.runtimeContextService.getRuntimeContext(props.productId, props.offeringId).pipe(tap$1(runtimeContext => {
|
|
1993
2056
|
var _a, _b, _c, _d;
|
|
1994
2057
|
this.uiDefinitionProperties = (_b = (_a = runtimeContext.uiDefinitionContainer) === null || _a === void 0 ? void 0 : _a.source.properties) !== null && _b !== void 0 ? _b : {};
|
|
1995
2058
|
const { PriceListId } = (_c = context.properties) !== null && _c !== void 0 ? _c : {};
|
|
@@ -2002,7 +2065,7 @@ class ConfigurationRuntimeService {
|
|
|
2002
2065
|
});
|
|
2003
2066
|
}
|
|
2004
2067
|
return this._runtimeContext;
|
|
2005
|
-
}), tap(() => (this._isInitialized = true)));
|
|
2068
|
+
}), tap$1(() => (this._isInitialized = true)));
|
|
2006
2069
|
}
|
|
2007
2070
|
overrideUIDefinition(uiDefinitionContainer) {
|
|
2008
2071
|
var _a;
|
|
@@ -2060,6 +2123,7 @@ class ConfigurationStateService {
|
|
|
2060
2123
|
this.configurationStore = {};
|
|
2061
2124
|
this.executionInProgress$ = new BehaviorSubject(false);
|
|
2062
2125
|
this.statefulRequestStream$ = new Subject();
|
|
2126
|
+
this.statelessExecutionRequest$ = null;
|
|
2063
2127
|
this.statefulExecutionRequest$ = this.initBufferedRequest$();
|
|
2064
2128
|
}
|
|
2065
2129
|
get isExecutionInProgress$() {
|
|
@@ -2090,7 +2154,7 @@ class ConfigurationStateService {
|
|
|
2090
2154
|
}
|
|
2091
2155
|
execute$(exec) {
|
|
2092
2156
|
const request = this.execToRequest(exec);
|
|
2093
|
-
return this.executeRequest$(request).pipe(map
|
|
2157
|
+
return this.executeRequest$(request).pipe(map(result => {
|
|
2094
2158
|
// Keep only requested results
|
|
2095
2159
|
const actualSelectors = Object.entries(result.selectors).reduce((trunk, [requestId, result]) => {
|
|
2096
2160
|
var _a;
|
|
@@ -2107,7 +2171,15 @@ class ConfigurationStateService {
|
|
|
2107
2171
|
actions: [{ name: actionName, inputData }],
|
|
2108
2172
|
};
|
|
2109
2173
|
const request = this.execToRequest(exec);
|
|
2110
|
-
|
|
2174
|
+
const executionRequest$ = this.executeRequest$(request);
|
|
2175
|
+
if (this.isStatefulConfiguration) {
|
|
2176
|
+
return executionRequest$;
|
|
2177
|
+
}
|
|
2178
|
+
// prevent parallel configuration requests in stateless mode
|
|
2179
|
+
if (!this.statelessExecutionRequest$) {
|
|
2180
|
+
this.statelessExecutionRequest$ = executionRequest$.pipe(shareReplay$1(), take$1(1), finalize(() => (this.statelessExecutionRequest$ = null)));
|
|
2181
|
+
}
|
|
2182
|
+
return this.statelessExecutionRequest$;
|
|
2111
2183
|
}
|
|
2112
2184
|
select$(selectorName, inputData = {}) {
|
|
2113
2185
|
const requestId = UUID.UUID();
|
|
@@ -2119,7 +2191,7 @@ class ConfigurationStateService {
|
|
|
2119
2191
|
},
|
|
2120
2192
|
},
|
|
2121
2193
|
});
|
|
2122
|
-
return this.executeRequest$(request).pipe(map
|
|
2194
|
+
return this.executeRequest$(request).pipe(map(response => response.selectors[requestId]));
|
|
2123
2195
|
}
|
|
2124
2196
|
subscribe$(selectorName, inputData = {}, options) {
|
|
2125
2197
|
const requestId = UUID.UUID();
|
|
@@ -2142,7 +2214,7 @@ class ConfigurationStateService {
|
|
|
2142
2214
|
this.executeRequest$(request).subscribe();
|
|
2143
2215
|
}
|
|
2144
2216
|
}
|
|
2145
|
-
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(() => {
|
|
2146
2218
|
var _a;
|
|
2147
2219
|
if (!((_a = this.subscriptions[requestId]) === null || _a === void 0 ? void 0 : _a.data$.observed)) {
|
|
2148
2220
|
delete this.subscriptions[requestId];
|
|
@@ -2155,7 +2227,7 @@ class ConfigurationStateService {
|
|
|
2155
2227
|
if (this.isStatefulConfiguration) {
|
|
2156
2228
|
return this.flowStateApiService
|
|
2157
2229
|
.saveConfiguration((_a = this.flowStateService.stateId) !== null && _a !== void 0 ? _a : '', (_b = this.stateId) !== null && _b !== void 0 ? _b : '')
|
|
2158
|
-
.pipe(switchMap(r => this.flowStateService.executeRequest$({}, true).pipe(map
|
|
2230
|
+
.pipe(switchMap$1(r => this.flowStateService.executeRequest$({}, true).pipe(map(() => r))));
|
|
2159
2231
|
}
|
|
2160
2232
|
else {
|
|
2161
2233
|
if (!flow) {
|
|
@@ -2192,7 +2264,7 @@ class ConfigurationStateService {
|
|
|
2192
2264
|
}
|
|
2193
2265
|
return this.flowConfigurationService
|
|
2194
2266
|
.calculate$(Object.assign(Object.assign({}, quoteDraft), { currentState, initialState }))
|
|
2195
|
-
.pipe(map
|
|
2267
|
+
.pipe(map(() => ({ quoteId: '' })));
|
|
2196
2268
|
}
|
|
2197
2269
|
}
|
|
2198
2270
|
}
|
|
@@ -2238,13 +2310,13 @@ class ConfigurationStateService {
|
|
|
2238
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 }))),
|
|
2239
2311
|
});
|
|
2240
2312
|
}
|
|
2241
|
-
return request$.pipe(map
|
|
2313
|
+
return request$.pipe(map(r => {
|
|
2242
2314
|
this.stateId = r.stateId;
|
|
2243
2315
|
return undefined;
|
|
2244
2316
|
}));
|
|
2245
2317
|
}
|
|
2246
2318
|
initStateless$() {
|
|
2247
|
-
return this.configurationService.configure().pipe(map
|
|
2319
|
+
return this.configurationService.configure().pipe(map(() => undefined));
|
|
2248
2320
|
}
|
|
2249
2321
|
execToRequest(exec) {
|
|
2250
2322
|
var _a;
|
|
@@ -2291,49 +2363,37 @@ class ConfigurationStateService {
|
|
|
2291
2363
|
else {
|
|
2292
2364
|
execution$ = this.executeStateless$(fullRequest);
|
|
2293
2365
|
}
|
|
2294
|
-
return execution$.pipe(tap
|
|
2366
|
+
return execution$.pipe(tap(result => this.handleSelectorsResponse(result.selectors)));
|
|
2295
2367
|
}
|
|
2296
2368
|
executeStateless$(request) {
|
|
2297
2369
|
this.executionInProgress$.next(true);
|
|
2298
|
-
return of(undefined).pipe(switchMap(() => {
|
|
2370
|
+
return of(undefined).pipe(switchMap$1(() => {
|
|
2299
2371
|
var _a;
|
|
2300
2372
|
// Apply actions and execute configuration/price call
|
|
2301
2373
|
// No need to run configuration if no actions in the request
|
|
2302
2374
|
if (!((_a = request.actions) === null || _a === void 0 ? void 0 : _a.length)) {
|
|
2303
2375
|
return of(undefined);
|
|
2304
2376
|
}
|
|
2305
|
-
let configurationRequest = this.configurationService.generateRequest();
|
|
2377
|
+
let configurationRequest = this.configurationService.generateRequest(false);
|
|
2306
2378
|
request.actions.forEach(action => {
|
|
2307
2379
|
var _a;
|
|
2308
2380
|
configurationRequest = (_a = this.executeActionScript(configurationRequest, action)) !== null && _a !== void 0 ? _a : configurationRequest;
|
|
2309
2381
|
});
|
|
2310
2382
|
configurationRequest = ConfigurationTranslatorUtils.lightenConfigurationRequest(configurationRequest);
|
|
2311
2383
|
return this.configurationService.configureRequest$(configurationRequest);
|
|
2312
|
-
}), map
|
|
2313
|
-
var _a;
|
|
2384
|
+
}), map(() => {
|
|
2314
2385
|
// Run selectors and apply them to the state
|
|
2315
|
-
const configurationState =
|
|
2386
|
+
const configurationState = this.configurationService.stateSnapshot;
|
|
2316
2387
|
if (!configurationState) {
|
|
2317
2388
|
return { stateId: '', selectors: {} };
|
|
2318
2389
|
}
|
|
2319
|
-
|
|
2320
|
-
|
|
2321
|
-
|
|
2322
|
-
|
|
2323
|
-
|
|
2324
|
-
|
|
2325
|
-
|
|
2326
|
-
catch (e) {
|
|
2327
|
-
console.error(e);
|
|
2328
|
-
result.selectors[key] = {
|
|
2329
|
-
success: false,
|
|
2330
|
-
errorMessage: String(e),
|
|
2331
|
-
};
|
|
2332
|
-
}
|
|
2333
|
-
return result;
|
|
2334
|
-
}, { stateId: '', selectors: {} });
|
|
2335
|
-
return selectorsResult;
|
|
2336
|
-
}), tap$1(() => this.executionInProgress$.next(false)), catchError(error => {
|
|
2390
|
+
return this.runStatelessSelectors(request, configurationState);
|
|
2391
|
+
}), tap(() => this.executionInProgress$.next(false)), catchError(error => {
|
|
2392
|
+
const configurationState = this.configurationService.previousStateSnapshot;
|
|
2393
|
+
if (configurationState) {
|
|
2394
|
+
const selectorsResult = this.runStatelessSelectors(request, configurationState);
|
|
2395
|
+
this.handleSelectorsResponse(selectorsResult.selectors);
|
|
2396
|
+
}
|
|
2337
2397
|
this.executionInProgress$.next(false);
|
|
2338
2398
|
if (!this.configurationRuntimeService.uiDefinitionProperties.suppressToastMessages) {
|
|
2339
2399
|
this.toastService.add({ severity: ToastType.error, summary: String(error) });
|
|
@@ -2342,7 +2402,7 @@ class ConfigurationStateService {
|
|
|
2342
2402
|
}));
|
|
2343
2403
|
}
|
|
2344
2404
|
initBufferedRequest$() {
|
|
2345
|
-
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 => {
|
|
2346
2406
|
if (!this.flowStateService.stateId || !this.stateId) {
|
|
2347
2407
|
throw 'Stateful session is not initialized';
|
|
2348
2408
|
}
|
|
@@ -2356,18 +2416,18 @@ class ConfigurationStateService {
|
|
|
2356
2416
|
};
|
|
2357
2417
|
this.executionInProgress$.next(true);
|
|
2358
2418
|
return this.flowStateApiService.executeConfiguration(this.flowStateService.stateId, this.stateId, request);
|
|
2359
|
-
}), tap
|
|
2419
|
+
}), tap(({ stateId }) => (this.stateId = stateId)), share(), tap(() => this.executionInProgress$.next(false)), catchError(e => {
|
|
2360
2420
|
this.executionInProgress$.next(false);
|
|
2361
2421
|
return throwError(() => e);
|
|
2362
2422
|
}));
|
|
2363
2423
|
}
|
|
2364
2424
|
executeStateful$(request) {
|
|
2365
|
-
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(() =>
|
|
2366
2426
|
// make sure stream switches to statefulExecutionRequest$ before pushing an execution request
|
|
2367
2427
|
combineLatest([
|
|
2368
2428
|
this.statefulExecutionRequest$,
|
|
2369
|
-
of(undefined).pipe(tap
|
|
2370
|
-
])), map
|
|
2429
|
+
of(undefined).pipe(tap(() => this.statefulRequestStream$.next(request))),
|
|
2430
|
+
])), map(([response]) => response), take$1(1));
|
|
2371
2431
|
}
|
|
2372
2432
|
executeActionScript(request, processor) {
|
|
2373
2433
|
var _a, _b;
|
|
@@ -2402,6 +2462,25 @@ class ConfigurationStateService {
|
|
|
2402
2462
|
configurationStore: this.configurationStore,
|
|
2403
2463
|
});
|
|
2404
2464
|
}
|
|
2465
|
+
runStatelessSelectors(request, configurationState) {
|
|
2466
|
+
var _a;
|
|
2467
|
+
return EntityUtil.entries((_a = request.selectors) !== null && _a !== void 0 ? _a : {}).reduce((result, [key, selector]) => {
|
|
2468
|
+
try {
|
|
2469
|
+
result.selectors[key] = {
|
|
2470
|
+
success: true,
|
|
2471
|
+
result: this.executeSelectorScript(configurationState, selector),
|
|
2472
|
+
};
|
|
2473
|
+
}
|
|
2474
|
+
catch (e) {
|
|
2475
|
+
console.error(e);
|
|
2476
|
+
result.selectors[key] = {
|
|
2477
|
+
success: false,
|
|
2478
|
+
errorMessage: String(e),
|
|
2479
|
+
};
|
|
2480
|
+
}
|
|
2481
|
+
return result;
|
|
2482
|
+
}, { stateId: '', selectors: {} });
|
|
2483
|
+
}
|
|
2405
2484
|
}
|
|
2406
2485
|
ConfigurationStateService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: ConfigurationStateService, deps: [{ token: ConfigurationRuntimeService }, { token: ConfigurationService }, { token: QuoteDraftService }, { token: i6.ToastService }, { token: FlowStateService }, { token: FlowInfoService }, { token: FlowConfigurationService }, { token: i1.FlowStateApiService }, { token: i1.QuoteApiService }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
2407
2486
|
ConfigurationStateService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: ConfigurationStateService });
|