@veloceapps/sdk 11.0.0-11 → 11.0.0-111
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/cms.actions.d.ts +94 -29
- package/cms/components/element-renderer/element-renderer.component.d.ts +3 -10
- package/cms/components/preview/preview.component.d.ts +5 -6
- package/cms/components/preview/preview.types.d.ts +0 -4
- package/cms/services/element-context.service.d.ts +0 -1
- package/cms/types/common.types.d.ts +2 -0
- package/cms/types/index.d.ts +0 -1
- package/cms/utils/path.utils.d.ts +1 -2
- package/cms/vendor-map.d.ts +18 -40
- package/core/index.d.ts +1 -1
- package/core/modules/configuration/index.d.ts +4 -4
- package/core/modules/configuration/services/configuration-runtime.service.d.ts +8 -19
- package/core/modules/configuration/services/configuration-state.service.d.ts +8 -8
- package/core/modules/configuration/services/configuration.service.d.ts +24 -52
- package/core/modules/configuration/services/guided-selling.service.d.ts +15 -0
- package/core/modules/configuration/services/test-mode-configuration.service.d.ts +26 -0
- package/core/modules/configuration/types/configuration-runtime.types.d.ts +0 -5
- package/core/modules/configuration/types/configuration.types.d.ts +4 -2
- package/core/modules/configuration/types/index.d.ts +2 -0
- package/core/modules/flow-configuration/index.d.ts +0 -3
- package/core/modules/flow-configuration/services/flow-configuration.service.d.ts +11 -38
- package/core/operators/filter-successful-execute.operator.d.ts +3 -0
- package/core/operators/index.d.ts +1 -0
- package/core/services/catalog-products.service.d.ts +11 -0
- package/core/services/flow-info.service.d.ts +27 -12
- package/core/services/flow-state-configuration.service.d.ts +9 -8
- package/core/services/flow-state.service.d.ts +12 -24
- package/core/services/index.d.ts +3 -3
- package/core/services/integration.state.d.ts +1 -1
- package/core/services/product-images.service.d.ts +3 -3
- package/core/services/runtime-settings.service.d.ts +1 -1
- package/core/services/sales-transaction.service.d.ts +27 -0
- package/core/types/flow-customization.types.d.ts +2 -2
- package/core/types/flow-state.types.d.ts +2 -2
- package/core/types/index.d.ts +0 -1
- package/core/utils/index.d.ts +2 -2
- package/core/utils/transaction-item.utils.d.ts +7 -0
- package/core/utils/transaction-item.worker.d.ts +8 -0
- package/esm2020/cms/cms.actions.mjs +93 -71
- package/esm2020/cms/cms.default.mjs +2 -3
- package/esm2020/cms/components/element-renderer/element-renderer.component.mjs +7 -64
- package/esm2020/cms/components/element-tools-panel/element-tools-panel.component.mjs +3 -3
- package/esm2020/cms/components/preview/preview.component.mjs +19 -28
- package/esm2020/cms/components/preview/preview.types.mjs +1 -1
- package/esm2020/cms/services/element-context.service.mjs +1 -1
- package/esm2020/cms/types/common.types.mjs +1 -1
- package/esm2020/cms/types/index.mjs +1 -2
- package/esm2020/cms/utils/element.utils.mjs +3 -3
- package/esm2020/cms/utils/elements-resolver.mjs +16 -5
- package/esm2020/cms/utils/path.utils.mjs +1 -10
- package/esm2020/cms/vendor-map.mjs +18 -18
- package/esm2020/core/core.module.mjs +7 -7
- package/esm2020/core/index.mjs +2 -2
- package/esm2020/core/modules/configuration/configuration.module.mjs +17 -4
- package/esm2020/core/modules/configuration/index.mjs +5 -5
- package/esm2020/core/modules/configuration/services/configuration-runtime.service.mjs +16 -101
- package/esm2020/core/modules/configuration/services/configuration-state.service.mjs +69 -77
- package/esm2020/core/modules/configuration/services/configuration.service.mjs +125 -247
- package/esm2020/core/modules/configuration/services/guided-selling.service.mjs +62 -0
- package/esm2020/core/modules/configuration/services/test-mode-configuration.service.mjs +97 -0
- package/esm2020/core/modules/configuration/types/configuration-runtime.types.mjs +1 -1
- package/esm2020/core/modules/configuration/types/configuration.types.mjs +1 -1
- package/esm2020/core/modules/configuration/types/index.mjs +3 -0
- package/esm2020/core/modules/flow-configuration/flow-configuration.module.mjs +3 -4
- package/esm2020/core/modules/flow-configuration/index.mjs +1 -4
- package/esm2020/core/modules/flow-configuration/services/flow-configuration.service.mjs +44 -128
- package/esm2020/core/operators/filter-successful-execute.operator.mjs +5 -0
- package/esm2020/core/operators/index.mjs +2 -0
- package/esm2020/core/services/catalog-products.service.mjs +25 -0
- package/esm2020/core/services/flow-info.service.mjs +82 -31
- package/esm2020/core/services/flow-state-configuration.service.mjs +55 -25
- package/esm2020/core/services/flow-state.service.mjs +58 -180
- package/esm2020/core/services/index.mjs +4 -4
- package/esm2020/core/services/integration.state.mjs +2 -2
- package/esm2020/core/services/product-images.service.mjs +8 -8
- package/esm2020/core/services/runtime-settings.service.mjs +3 -3
- package/esm2020/core/services/sales-transaction.service.mjs +67 -0
- package/esm2020/core/types/flow-customization.types.mjs +1 -1
- package/esm2020/core/types/flow-state.types.mjs +1 -1
- package/esm2020/core/types/index.mjs +1 -2
- package/esm2020/core/utils/index.mjs +3 -3
- package/esm2020/core/utils/transaction-item.utils.mjs +60 -0
- package/esm2020/core/utils/transaction-item.worker.mjs +16 -0
- package/esm2020/src/components/flow-header/flow-header.component.mjs +8 -12
- package/esm2020/src/components/guided-selling/guided-selling.component.mjs +8 -12
- package/esm2020/src/flow-routing.module.mjs +12 -41
- package/esm2020/src/flow.component.mjs +5 -5
- package/esm2020/src/guards/flow.guard.mjs +13 -14
- package/esm2020/src/guards/product-unload.guard.mjs +7 -9
- package/esm2020/src/index.mjs +1 -3
- package/esm2020/src/pages/assets/assets.component.mjs +8 -9
- package/esm2020/src/pages/catalog/catalog.component.mjs +8 -9
- package/esm2020/src/pages/debug/debug.component.mjs +14 -23
- package/esm2020/src/pages/product/product.component.mjs +17 -91
- package/esm2020/src/pages/product/product.module.mjs +5 -5
- package/esm2020/src/pages/record-not-found/record-not-found.component.mjs +5 -6
- package/esm2020/src/pages/shopping-cart/shopping-cart.component.mjs +8 -9
- package/esm2020/src/resolvers/flow.resolver.mjs +10 -18
- package/esm2020/src/resolvers/pcm-model.resolver.mjs +12 -0
- package/esm2020/src/resolvers/sales-transaction.resolver.mjs +64 -0
- package/esm2020/src/resolvers/ui-definition.resolver.mjs +44 -0
- package/esm2020/src/services/flow-dialog.service.mjs +10 -31
- package/esm2020/src/services/flow-router.service.mjs +16 -33
- package/esm2020/src/services/flow.service.mjs +15 -54
- package/esm2020/src/types/index.mjs +2 -3
- package/esm2020/src/types/route.types.mjs +1 -1
- package/fesm2015/veloceapps-sdk-cms.mjs +163 -309
- package/fesm2015/veloceapps-sdk-cms.mjs.map +1 -1
- package/fesm2015/veloceapps-sdk-core.mjs +922 -1670
- package/fesm2015/veloceapps-sdk-core.mjs.map +1 -1
- package/fesm2015/veloceapps-sdk.mjs +197 -824
- package/fesm2015/veloceapps-sdk.mjs.map +1 -1
- package/fesm2020/veloceapps-sdk-cms.mjs +159 -300
- package/fesm2020/veloceapps-sdk-cms.mjs.map +1 -1
- package/fesm2020/veloceapps-sdk-core.mjs +997 -1755
- package/fesm2020/veloceapps-sdk-core.mjs.map +1 -1
- package/fesm2020/veloceapps-sdk.mjs +197 -818
- package/fesm2020/veloceapps-sdk.mjs.map +1 -1
- package/package.json +1 -1
- package/src/components/flow-header/flow-header.component.d.ts +3 -3
- package/src/components/guided-selling/guided-selling.component.d.ts +3 -3
- package/src/flow-routing.module.d.ts +1 -2
- package/src/flow.component.d.ts +2 -2
- package/src/guards/product-unload.guard.d.ts +5 -6
- package/src/index.d.ts +0 -2
- package/src/pages/assets/assets.component.d.ts +3 -3
- package/src/pages/catalog/catalog.component.d.ts +3 -3
- package/src/pages/debug/debug.component.d.ts +2 -5
- package/src/pages/product/product.component.d.ts +6 -14
- package/src/pages/product/product.module.d.ts +1 -1
- package/src/pages/record-not-found/record-not-found.component.d.ts +2 -3
- package/src/pages/shopping-cart/shopping-cart.component.d.ts +3 -3
- package/src/resolvers/flow.resolver.d.ts +5 -6
- package/src/resolvers/pcm-model.resolver.d.ts +3 -0
- package/src/resolvers/sales-transaction.resolver.d.ts +18 -0
- package/src/resolvers/ui-definition.resolver.d.ts +3 -0
- package/src/services/flow-dialog.service.d.ts +6 -8
- package/src/services/flow-router.service.d.ts +4 -6
- package/src/services/flow.service.d.ts +3 -7
- package/src/types/index.d.ts +1 -2
- package/src/types/route.types.d.ts +0 -5
- package/cms/plugins/configuration.plugin.d.ts +0 -23
- package/cms/types/configuration.types.d.ts +0 -21
- package/core/modules/configuration/helpers.d.ts +0 -6
- package/core/modules/configuration/services/runtime-context.service.d.ts +0 -12
- package/core/modules/flow-configuration/services/flow-update.service.d.ts +0 -13
- package/core/modules/flow-configuration/types/update.types.d.ts +0 -12
- package/core/services/context.service.d.ts +0 -23
- package/core/services/quote-draft.service.d.ts +0 -50
- package/core/types/runtime.types.d.ts +0 -30
- package/core/utils/line-item.utils.d.ts +0 -25
- package/core/utils/line-item.worker.d.ts +0 -9
- package/esm2020/cms/plugins/configuration.plugin.mjs +0 -109
- package/esm2020/cms/types/configuration.types.mjs +0 -2
- package/esm2020/core/modules/configuration/helpers.mjs +0 -73
- package/esm2020/core/modules/configuration/services/runtime-context.service.mjs +0 -45
- package/esm2020/core/modules/flow-configuration/services/flow-update.service.mjs +0 -138
- package/esm2020/core/modules/flow-configuration/types/update.types.mjs +0 -2
- package/esm2020/core/services/context.service.mjs +0 -91
- package/esm2020/core/services/quote-draft.service.mjs +0 -192
- package/esm2020/core/types/runtime.types.mjs +0 -16
- package/esm2020/core/utils/line-item.utils.mjs +0 -187
- package/esm2020/core/utils/line-item.worker.mjs +0 -19
- package/esm2020/src/guards/context.guard.mjs +0 -91
- package/esm2020/src/guards/index.mjs +0 -2
- package/esm2020/src/pages/remote/remote.component.mjs +0 -342
- package/esm2020/src/pages/remote/remote.module.mjs +0 -20
- package/esm2020/src/pages/remote/remote.types.mjs +0 -2
- package/esm2020/src/resolvers/quote.resolver.mjs +0 -82
- package/esm2020/src/types/context-route.types.mjs +0 -2
- package/esm2020/src/types/metrics.types.mjs +0 -2
- package/esm2020/src/utils/flow.utils.mjs +0 -25
- package/esm2020/src/utils/index.mjs +0 -2
- package/src/guards/context.guard.d.ts +0 -19
- package/src/guards/index.d.ts +0 -1
- package/src/pages/remote/remote.component.d.ts +0 -46
- package/src/pages/remote/remote.module.d.ts +0 -10
- package/src/pages/remote/remote.types.d.ts +0 -4
- package/src/resolvers/quote.resolver.d.ts +0 -19
- package/src/types/context-route.types.d.ts +0 -5
- package/src/types/metrics.types.d.ts +0 -5
- package/src/utils/flow.utils.d.ts +0 -8
- package/src/utils/index.d.ts +0 -1
@@ -1,249 +1,243 @@
|
|
1
1
|
import * as i0 from '@angular/core';
|
2
2
|
import { Injectable, InjectionToken, Optional, Inject, NgModule, inject, Directive, Input, LOCALE_ID, Pipe } from '@angular/core';
|
3
|
-
import {
|
4
|
-
import * as
|
3
|
+
import { 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, isDefined, UITemplateType, SalesforceIdUtils, UUID, extractErrorDetails, ConfigurationProcessorTypes, EntityUtil, DEFAULT_TIME_FORMAT, formatNumber } from '@veloceapps/core';
|
4
|
+
import * as i3 from '@veloceapps/api';
|
5
5
|
import { ApiModule } from '@veloceapps/api';
|
6
|
-
import { BehaviorSubject, switchMap, map as map$1, tap as tap$1, noop, catchError, throwError, forkJoin, of, zip, combineLatest, Subject, filter as filter$1, shareReplay as shareReplay$1, finalize, takeUntil, buffer, debounceTime, share, take as take$1, distinctUntilChanged } from 'rxjs';
|
7
|
-
import { map, filter, tap, switchMap as switchMap$1, skip, take, shareReplay, catchError as catchError$1, finalize as finalize$1, first } from 'rxjs/operators';
|
8
|
-
import { merge, isEqual, cloneDeep, assign, flatten, entries, sortBy, map as map$2, uniqBy, omit, transform } from 'lodash';
|
9
6
|
import * as i6 from '@veloceapps/components';
|
10
|
-
import { ToastType,
|
11
|
-
import
|
12
|
-
import
|
13
|
-
import
|
14
|
-
import
|
7
|
+
import { ToastType, ConfirmationDialogModule } from '@veloceapps/components';
|
8
|
+
import * as i1 from '@veloceapps/api/v2';
|
9
|
+
import { tap, BehaviorSubject, map, filter, switchMap, of, forkJoin, noop, throwError, Subject, catchError as catchError$1, combineLatest, finalize as finalize$1, buffer, debounceTime, share, take, distinctUntilChanged, shareReplay, takeUntil, first } from 'rxjs';
|
10
|
+
import { uniqBy, flatten, omit, cloneDeep, assign, isEqual } from 'lodash';
|
11
|
+
import * as i2 from 'primeng/api';
|
12
|
+
import { filter as filter$1, map as map$1, tap as tap$1, catchError, finalize } from 'rxjs/operators';
|
15
13
|
import { NgControl } from '@angular/forms';
|
16
14
|
import 'primeng/calendar';
|
17
15
|
import { DATE_PIPE_DEFAULT_OPTIONS, formatDate } from '@angular/common';
|
18
16
|
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
return {
|
24
|
-
id,
|
25
|
-
type: uiDefinitionProperties.rootType ?? '',
|
26
|
-
cfgStatus: 'Default',
|
27
|
-
actionCode: 'ADD',
|
28
|
-
qty,
|
29
|
-
attributes,
|
30
|
-
lineItems,
|
31
|
-
productName: context.properties?.['displayName'] || context.productName,
|
32
|
-
productId: context.productId ?? '',
|
33
|
-
...(uiDefinitionProperties.offeringId ? { offeringId: uiDefinitionProperties.offeringId } : {}),
|
34
|
-
};
|
35
|
-
};
|
36
|
-
const getGuidedSellingConfigurationRequest = (data, context) => {
|
37
|
-
const _context = { ...context };
|
38
|
-
delete _context.configurationToken;
|
39
|
-
const properties = { ...context.properties };
|
40
|
-
delete properties['ConfigurationToken'];
|
41
|
-
return {
|
42
|
-
mode: 'SEARCH',
|
43
|
-
step: 'START',
|
44
|
-
attributeDomainMode: 'ALL',
|
45
|
-
context: {
|
46
|
-
..._context,
|
47
|
-
mode: ConfigurationContextMode.TEST,
|
48
|
-
properties: {
|
49
|
-
...properties,
|
50
|
-
ModelId: data.modelId,
|
51
|
-
Name: 'Veloce Guided Selling',
|
52
|
-
PricingEnabled: 'false',
|
53
|
-
RuntimeMode: 'TEST',
|
54
|
-
},
|
55
|
-
},
|
56
|
-
lineItem: {
|
57
|
-
actionCode: 'ADD',
|
58
|
-
cfgStatus: 'Default',
|
59
|
-
id: UUID.UUID(),
|
60
|
-
qty: 1,
|
61
|
-
type: data.modelType,
|
62
|
-
attributes: Object.entries(data.attributesMap).map(([name, value]) => ({
|
63
|
-
name,
|
64
|
-
value,
|
65
|
-
cfgStatus: 'User',
|
66
|
-
})),
|
67
|
-
},
|
68
|
-
};
|
69
|
-
};
|
70
|
-
const generateConfigurationLineItem = (props, qty = 1) => {
|
71
|
-
const id = UUID.UUID();
|
72
|
-
const attributes = Object.entries(props.attributesMap ?? {}).map(([name, value]) => ({
|
73
|
-
name,
|
74
|
-
value,
|
75
|
-
cfgStatus: 'User',
|
76
|
-
}));
|
77
|
-
const lineItems = [];
|
78
|
-
return {
|
79
|
-
id,
|
80
|
-
type: props.product.typeName ?? '',
|
81
|
-
cfgStatus: 'Default',
|
82
|
-
actionCode: 'ADD',
|
83
|
-
qty,
|
84
|
-
attributes,
|
85
|
-
lineItems,
|
86
|
-
productName: props.product.name,
|
87
|
-
productId: props.product.id ?? '',
|
88
|
-
};
|
89
|
-
};
|
90
|
-
|
91
|
-
class ContextService {
|
92
|
-
constructor(contextApiService) {
|
93
|
-
this.contextApiService = contextApiService;
|
94
|
-
this.context = new BehaviorSubject(null);
|
17
|
+
class ConfigurationRuntimeService {
|
18
|
+
constructor(pcmApiService) {
|
19
|
+
this.pcmApiService = pcmApiService;
|
20
|
+
this.uiDefinitionContainer = null;
|
95
21
|
}
|
96
|
-
get
|
97
|
-
return
|
22
|
+
get uiDefinitionProps() {
|
23
|
+
return this.uiDefinitionContainer?.source.properties ?? {};
|
98
24
|
}
|
99
|
-
|
100
|
-
|
25
|
+
reset() {
|
26
|
+
this.uiDefinitionContainer = null;
|
27
|
+
this.initializationProps = undefined;
|
28
|
+
this.pcmModel = undefined;
|
29
|
+
}
|
30
|
+
init$(props) {
|
31
|
+
this.initializationProps = props;
|
32
|
+
return this.pcmApiService.fetchPCMByProductId(props.productId).pipe(tap(pcmModel => (this.pcmModel = pcmModel)));
|
101
33
|
}
|
102
|
-
|
103
|
-
|
34
|
+
}
|
35
|
+
ConfigurationRuntimeService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: ConfigurationRuntimeService, deps: [{ token: i1.PCMApiService }], target: i0.ɵɵFactoryTarget.Injectable });
|
36
|
+
ConfigurationRuntimeService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: ConfigurationRuntimeService });
|
37
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: ConfigurationRuntimeService, decorators: [{
|
38
|
+
type: Injectable
|
39
|
+
}], ctorParameters: function () { return [{ type: i1.PCMApiService }]; } });
|
40
|
+
|
41
|
+
const FLOW_CUSTOMIZATION = new InjectionToken('FLOW_CUSTOMIZATION');
|
42
|
+
|
43
|
+
class RuntimeSettingsService {
|
44
|
+
constructor(configurationSettingsApiService) {
|
45
|
+
this.configurationSettingsApiService = configurationSettingsApiService;
|
46
|
+
this.configurationSettings$ = new BehaviorSubject({});
|
47
|
+
this.currencySettings$ = new BehaviorSubject({
|
48
|
+
iso: DEFAULT_CURRENCY_ISO_CODE,
|
49
|
+
symbol: DEFAULT_CURRENCY_SYMBOL,
|
50
|
+
});
|
51
|
+
this.shoppingCartSettings$ = new BehaviorSubject([]);
|
52
|
+
this.getCurrencySymbol = (locale, currency) => {
|
53
|
+
return (0)
|
54
|
+
.toLocaleString(locale, { style: 'currency', currency, minimumFractionDigits: 0, maximumFractionDigits: 0 })
|
55
|
+
.replace(/\d/g, '')
|
56
|
+
.trim();
|
57
|
+
};
|
104
58
|
}
|
105
|
-
|
106
|
-
return this.
|
59
|
+
create() {
|
60
|
+
return this.configurationSettingsApiService.fetchSettings().pipe(map(settings => this.parseConfigurationSettings(settings)), tap(configurationSettings => {
|
61
|
+
this.configurationSettings$.next(configurationSettings);
|
62
|
+
this.addShoppingCartSettings(configurationSettings['shopping-cart'] ?? []);
|
63
|
+
this.formattingSettings = this.getFormattingSettings();
|
64
|
+
}), map(() => undefined));
|
107
65
|
}
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
66
|
+
initCurrency(iso) {
|
67
|
+
if (iso) {
|
68
|
+
const symbol = this.getCurrencySymbol('en-US', iso);
|
69
|
+
this.currencySettings$.next({ iso, symbol });
|
70
|
+
if (this.formattingSettings) {
|
71
|
+
this.formattingSettings.currencySymbol = symbol;
|
72
|
+
}
|
115
73
|
}
|
116
|
-
return false;
|
117
74
|
}
|
118
|
-
|
119
|
-
if (
|
120
|
-
|
75
|
+
getFormattingSettings() {
|
76
|
+
if (this.formattingSettings) {
|
77
|
+
return this.formattingSettings;
|
121
78
|
}
|
122
|
-
|
79
|
+
const shoppingCartSettings = this.getConfigurationSettings()['shopping-cart']?.reduce((acc, setting) => {
|
80
|
+
return { ...acc, [setting.id]: setting.properties };
|
81
|
+
}, {});
|
82
|
+
const currencySettings = this.getCurrencySettings();
|
83
|
+
const dateFormat = (validateDateFormat(shoppingCartSettings?.DATE_FORMAT ?? '') && shoppingCartSettings?.DATE_FORMAT) ||
|
84
|
+
DEFAULT_DATE_FORMAT;
|
85
|
+
const decimalSeparator = shoppingCartSettings?.DECIMAL_SEPARATOR;
|
86
|
+
const thousandsSeparator = shoppingCartSettings?.THOUSANDS_SEPARATOR;
|
87
|
+
// the number of decimal places can be 0
|
88
|
+
const priceScale = shoppingCartSettings?.PRICE_SCALE;
|
89
|
+
const decimalsCount = priceScale !== null && priceScale !== '' && !isNaN(Number(priceScale)) && Number(priceScale) >= 0
|
90
|
+
? Number(priceScale)
|
91
|
+
: DEFAULT_DECIMALS_COUNT;
|
92
|
+
const actionCodeSettings = shoppingCartSettings?.STATUS_LABEL;
|
93
|
+
return {
|
94
|
+
currencySymbol: currencySettings.symbol,
|
95
|
+
dateFormats: getSupportedDateFormats(dateFormat),
|
96
|
+
decimalsCount,
|
97
|
+
decimalSeparator: decimalSeparator !== undefined && ['.', ','].includes(decimalSeparator)
|
98
|
+
? decimalSeparator
|
99
|
+
: DEFAULT_DECIMAL_SEPARATOR,
|
100
|
+
// thousands separator can be a blank value, so it can also be null
|
101
|
+
thousandsSeparator: thousandsSeparator !== undefined && ['.', ',', '', null].includes(thousandsSeparator)
|
102
|
+
? thousandsSeparator || ''
|
103
|
+
: DEFAULT_THOUSANDS_SEPARATOR,
|
104
|
+
actionCodeLabels: actionCodeSettings?.length
|
105
|
+
? actionCodeSettings.reduce((result, setting) => ({ ...result, [setting.status_label]: setting.custom_label }), {})
|
106
|
+
: DEFAULT_ACTION_CODE_LABELS,
|
107
|
+
};
|
123
108
|
}
|
124
|
-
|
125
|
-
return this.
|
109
|
+
getConfigurationSettings() {
|
110
|
+
return this.configurationSettings$.value;
|
126
111
|
}
|
127
|
-
|
128
|
-
return this.
|
112
|
+
getShoppingCartSettings() {
|
113
|
+
return this.shoppingCartSettings$.value;
|
129
114
|
}
|
130
|
-
|
131
|
-
return this.
|
132
|
-
return this.update({
|
133
|
-
properties: {
|
134
|
-
...context.properties,
|
135
|
-
RuntimeMode: ConfigurationContextMode.TEST,
|
136
|
-
StartDate: new Date().toISOString().substring(0, 10),
|
137
|
-
standalone: 'true',
|
138
|
-
},
|
139
|
-
});
|
140
|
-
}));
|
115
|
+
getCurrencySettings() {
|
116
|
+
return this.currencySettings$.value;
|
141
117
|
}
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
...context,
|
160
|
-
};
|
161
|
-
this.context.next(updatedContext);
|
162
|
-
return updatedContext;
|
118
|
+
parseConfigurationSettings(settings) {
|
119
|
+
return settings.reduce((acc, setting) => {
|
120
|
+
switch (setting.key) {
|
121
|
+
case 'shopping-cart':
|
122
|
+
acc['shopping-cart'] = parseJsonSafely(setting.value, []);
|
123
|
+
break;
|
124
|
+
case 'navigation':
|
125
|
+
acc.navigation = parseJsonSafely(setting.value, {});
|
126
|
+
break;
|
127
|
+
case 'flows':
|
128
|
+
acc.flows = parseJsonSafely(setting.value, []);
|
129
|
+
break;
|
130
|
+
default:
|
131
|
+
acc[setting.key] = setting.value;
|
132
|
+
}
|
133
|
+
return acc;
|
134
|
+
}, {});
|
163
135
|
}
|
164
|
-
|
165
|
-
|
136
|
+
addShoppingCartSettings(settings) {
|
137
|
+
// uniqBy removes items with the biggest index
|
138
|
+
const newSettings = uniqBy([...settings, ...this.shoppingCartSettings$.value], 'id');
|
139
|
+
this.shoppingCartSettings$.next(newSettings);
|
166
140
|
}
|
167
141
|
}
|
168
|
-
|
169
|
-
|
170
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type:
|
142
|
+
RuntimeSettingsService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: RuntimeSettingsService, deps: [{ token: i1.ConfigurationSettingsApiService }], target: i0.ɵɵFactoryTarget.Injectable });
|
143
|
+
RuntimeSettingsService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: RuntimeSettingsService });
|
144
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: RuntimeSettingsService, decorators: [{
|
171
145
|
type: Injectable
|
172
|
-
}], ctorParameters: function () { return [{ type: i1.
|
173
|
-
|
174
|
-
const FLOW_CUSTOMIZATION = new InjectionToken('FLOW_CUSTOMIZATION');
|
175
|
-
|
176
|
-
const FORMATTING_SETTINGS_TOKEN = new InjectionToken('Summary of formatting settings for variant types of data, e.g. numbers, text, dates, etc');
|
177
|
-
|
178
|
-
var RuntimeMode;
|
179
|
-
(function (RuntimeMode) {
|
180
|
-
RuntimeMode[RuntimeMode["TEST"] = 0] = "TEST";
|
181
|
-
RuntimeMode[RuntimeMode["PROD"] = 1] = "PROD";
|
182
|
-
})(RuntimeMode || (RuntimeMode = {}));
|
183
|
-
var RuntimeOperation;
|
184
|
-
(function (RuntimeOperation) {
|
185
|
-
RuntimeOperation["INIT"] = "INIT";
|
186
|
-
RuntimeOperation["UPDATE"] = "UPDATE";
|
187
|
-
})(RuntimeOperation || (RuntimeOperation = {}));
|
188
|
-
var RuntimeStep;
|
189
|
-
(function (RuntimeStep) {
|
190
|
-
RuntimeStep["START"] = "START";
|
191
|
-
RuntimeStep["UPDATE"] = "UPDATE";
|
192
|
-
})(RuntimeStep || (RuntimeStep = {}));
|
193
|
-
|
194
|
-
const UI_DEFINITION_VERSION = 3;
|
146
|
+
}], ctorParameters: function () { return [{ type: i1.ConfigurationSettingsApiService }]; } });
|
195
147
|
|
196
148
|
class FlowInfoService {
|
197
149
|
get flow() {
|
150
|
+
if (!this.flowSubj$.value) {
|
151
|
+
throw new Error(`Flow not initialized yet`);
|
152
|
+
}
|
198
153
|
return this.flowSubj$.value;
|
199
154
|
}
|
200
|
-
|
201
|
-
this.flowSubj$.
|
155
|
+
get isFlowInitialized() {
|
156
|
+
return Boolean(this.flowSubj$.value);
|
157
|
+
}
|
158
|
+
get context() {
|
159
|
+
if (!this.contextSubj$.value) {
|
160
|
+
throw new Error('Context is not initialized yet!');
|
161
|
+
}
|
162
|
+
return { ...this.contextSubj$.value };
|
163
|
+
}
|
164
|
+
get context$() {
|
165
|
+
return this.contextSubj$.asObservable().pipe(filter(isDefined));
|
202
166
|
}
|
203
|
-
get
|
204
|
-
return
|
167
|
+
get templates() {
|
168
|
+
return this.templatesSubj$.value;
|
169
|
+
}
|
170
|
+
get isFlowEngineInitialized$() {
|
171
|
+
return this.templates$.pipe(map(v => Boolean(v.FLOW_ENGINE)));
|
205
172
|
}
|
206
173
|
get isStateful() {
|
207
174
|
return !!this.flow?.properties.stateful;
|
208
175
|
}
|
209
|
-
constructor(
|
210
|
-
this.
|
211
|
-
this.
|
176
|
+
constructor(runtimeSettingsService, templatesAdminApiService, customizationService) {
|
177
|
+
this.runtimeSettingsService = runtimeSettingsService;
|
178
|
+
this.templatesAdminApiService = templatesAdminApiService;
|
212
179
|
this.customizationService = customizationService;
|
213
|
-
this.templates = {};
|
214
180
|
this.defaultTemplates = {
|
215
181
|
flowEngine: 'Flow Engine',
|
216
182
|
};
|
217
183
|
this.flowSubj$ = new BehaviorSubject(null);
|
184
|
+
this.templatesSubj$ = new BehaviorSubject({});
|
185
|
+
this.contextSubj$ = new BehaviorSubject(null);
|
218
186
|
this.flow$ = this.flowSubj$.asObservable();
|
187
|
+
this.templates$ = this.templatesSubj$.asObservable();
|
188
|
+
}
|
189
|
+
reset() {
|
190
|
+
this.flowSubj$.next(null);
|
191
|
+
this.templatesSubj$.next({});
|
192
|
+
this.contextSubj$.next(null);
|
219
193
|
}
|
220
194
|
init$(flowId, routeQueryParams) {
|
221
|
-
return this.
|
222
|
-
this.params = { ...routeQueryParams, ...flow.properties.queryParams };
|
223
|
-
this.flowSubj$.next(flow);
|
224
|
-
}), map$1(noop), catchError(e => {
|
225
|
-
this.flowSubj$.next(null);
|
226
|
-
return throwError(() => e);
|
227
|
-
}));
|
195
|
+
return this.initFlow$(flowId, routeQueryParams).pipe(switchMap(() => this.initFlowTemplates$()));
|
228
196
|
}
|
229
|
-
|
230
|
-
this.
|
231
|
-
|
232
|
-
|
197
|
+
updateContext(update) {
|
198
|
+
this.contextSubj$.next({
|
199
|
+
...this.context,
|
200
|
+
...update,
|
201
|
+
});
|
202
|
+
}
|
203
|
+
initFlow$(flowId, routeQueryParams) {
|
204
|
+
const flow = this.runtimeSettingsService.getConfigurationSettings()['flows']?.find(({ id }) => flowId === id);
|
205
|
+
if (!flow) {
|
206
|
+
this.flowSubj$.next(null);
|
207
|
+
throw new Error(`Flow with flowId=${flowId} is not defined`);
|
208
|
+
}
|
209
|
+
const headerId = routeQueryParams['headerId'];
|
210
|
+
if (typeof headerId !== 'string') {
|
211
|
+
throw new Error(`Please provide 'headerId'`);
|
212
|
+
}
|
213
|
+
const mode = this.getFlowContextMode(headerId);
|
214
|
+
// Restrict if mode is not defined
|
215
|
+
if (mode == null) {
|
216
|
+
throw new Error('Mode is undefined');
|
217
|
+
}
|
218
|
+
this.contextSubj$.next({
|
219
|
+
...flow.properties.queryParams,
|
220
|
+
...routeQueryParams,
|
221
|
+
mode,
|
222
|
+
});
|
223
|
+
this.flowSubj$.next(flow);
|
224
|
+
return of(undefined);
|
233
225
|
}
|
234
|
-
initFlowTemplates$(
|
226
|
+
initFlowTemplates$() {
|
235
227
|
return forkJoin([
|
236
|
-
this.
|
228
|
+
this.templatesAdminApiService.fetchTemplates$(),
|
237
229
|
this.customizationService?.getTemplates?.() ?? of([]),
|
238
|
-
]).pipe(map
|
239
|
-
|
230
|
+
]).pipe(map(([templates, localTemplates]) => {
|
231
|
+
const newValue = {};
|
232
|
+
Object.entries({ ...this.defaultTemplates, ...(this.flow?.properties.templates ?? {}) }).forEach(([key, name]) => {
|
240
233
|
const type = this.remapTemplateName(key);
|
241
234
|
if (type) {
|
242
|
-
|
235
|
+
newValue[type] =
|
243
236
|
localTemplates.find(template => template.name === name && template.type === type) ??
|
244
237
|
templates.find(template => template.name === name && template.type === type);
|
245
238
|
}
|
246
239
|
});
|
240
|
+
this.templatesSubj$.next(newValue);
|
247
241
|
}));
|
248
242
|
}
|
249
243
|
remapTemplateName(templateType) {
|
@@ -269,207 +263,530 @@ class FlowInfoService {
|
|
269
263
|
}
|
270
264
|
return undefined;
|
271
265
|
}
|
266
|
+
getFlowContextMode(headerId) {
|
267
|
+
const objectName = SalesforceIdUtils.getSfObjectNameById(headerId);
|
268
|
+
if (!objectName) {
|
269
|
+
return;
|
270
|
+
}
|
271
|
+
return objectName.toUpperCase();
|
272
|
+
}
|
272
273
|
}
|
273
|
-
FlowInfoService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: FlowInfoService, deps: [{ token:
|
274
|
+
FlowInfoService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: FlowInfoService, deps: [{ token: RuntimeSettingsService }, { token: i1.UITemplatesAdminApiService }, { token: FLOW_CUSTOMIZATION, optional: true }], target: i0.ɵɵFactoryTarget.Injectable });
|
274
275
|
FlowInfoService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: FlowInfoService });
|
275
276
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: FlowInfoService, decorators: [{
|
276
277
|
type: Injectable
|
277
|
-
}], ctorParameters: function () { return [{ type:
|
278
|
+
}], ctorParameters: function () { return [{ type: RuntimeSettingsService }, { type: i1.UITemplatesAdminApiService }, { type: undefined, decorators: [{
|
278
279
|
type: Optional
|
279
280
|
}, {
|
280
281
|
type: Inject,
|
281
282
|
args: [FLOW_CUSTOMIZATION]
|
282
283
|
}] }]; } });
|
283
284
|
|
284
|
-
|
285
|
-
|
286
|
-
|
287
|
-
|
288
|
-
|
289
|
-
|
290
|
-
|
291
|
-
|
292
|
-
|
293
|
-
this.isInitializedSubj$.next(value);
|
285
|
+
const findTransactionItem = (id, items) => {
|
286
|
+
return findTransactionItemWithComparator(items, (ti) => ti.id === id);
|
287
|
+
};
|
288
|
+
const findTransactionItemWithComparator = (items, comparator) => {
|
289
|
+
let currentLevel = items;
|
290
|
+
while (currentLevel.length) {
|
291
|
+
const found = currentLevel.find(comparator);
|
292
|
+
if (found) {
|
293
|
+
return found;
|
294
294
|
}
|
295
|
+
currentLevel = flatten(currentLevel.map(parent => parent.children));
|
295
296
|
}
|
296
|
-
|
297
|
-
|
297
|
+
return;
|
298
|
+
};
|
299
|
+
const insertTransactionItem = (item, parentId, toInsert) => {
|
300
|
+
const insertData = item.id === parentId ? [toInsert] : [];
|
301
|
+
return {
|
302
|
+
...item,
|
303
|
+
children: [
|
304
|
+
...insertData,
|
305
|
+
...item.children.map(ti => {
|
306
|
+
return insertTransactionItem(ti, parentId, toInsert);
|
307
|
+
}),
|
308
|
+
],
|
309
|
+
};
|
310
|
+
};
|
311
|
+
const removeTransactionItem = (item, idToRemove) => {
|
312
|
+
return {
|
313
|
+
...item,
|
314
|
+
children: item.children
|
315
|
+
.map(ti => {
|
316
|
+
if (ti.id === idToRemove) {
|
317
|
+
return;
|
318
|
+
}
|
319
|
+
else if (ti.children.length) {
|
320
|
+
return removeTransactionItem(ti, idToRemove);
|
321
|
+
}
|
322
|
+
return ti;
|
323
|
+
})
|
324
|
+
.filter(isDefined),
|
325
|
+
};
|
326
|
+
};
|
327
|
+
const replaceTransactionItem = (item, replaceTo) => {
|
328
|
+
if (item.id === replaceTo.id) {
|
329
|
+
return { ...replaceTo };
|
298
330
|
}
|
299
|
-
|
300
|
-
|
301
|
-
|
302
|
-
|
303
|
-
|
331
|
+
return {
|
332
|
+
...item,
|
333
|
+
children: item.children.map(ti => replaceTransactionItem(ti, replaceTo)),
|
334
|
+
};
|
335
|
+
};
|
336
|
+
const generateTransactionItem = (productId) => {
|
337
|
+
return {
|
338
|
+
id: UUID.UUID(),
|
339
|
+
productId,
|
340
|
+
};
|
341
|
+
};
|
342
|
+
|
343
|
+
class TransactionItemWorker {
|
344
|
+
constructor(src) {
|
345
|
+
this.ti = { ...src };
|
304
346
|
}
|
305
|
-
|
306
|
-
return this.
|
347
|
+
insert(parentId, toInsert) {
|
348
|
+
return new TransactionItemWorker(insertTransactionItem(this.ti, parentId, toInsert));
|
307
349
|
}
|
308
|
-
|
309
|
-
return
|
350
|
+
remove(id) {
|
351
|
+
return new TransactionItemWorker(removeTransactionItem(this.ti, id));
|
310
352
|
}
|
311
|
-
|
312
|
-
return
|
353
|
+
replace(toReplace) {
|
354
|
+
return new TransactionItemWorker(replaceTransactionItem(this.ti, toReplace));
|
313
355
|
}
|
314
|
-
|
315
|
-
|
356
|
+
}
|
357
|
+
|
358
|
+
function extractMetadata(uiDefinition) {
|
359
|
+
return omit(uiDefinition, [
|
360
|
+
'children',
|
361
|
+
'pages',
|
362
|
+
'components',
|
363
|
+
]);
|
364
|
+
}
|
365
|
+
|
366
|
+
class GuidedSellingService {
|
367
|
+
constructor(orchestrationsApiService) {
|
368
|
+
this.orchestrationsApiService = orchestrationsApiService;
|
369
|
+
this.guidedSellingResult$ = new BehaviorSubject({});
|
316
370
|
}
|
317
|
-
get
|
318
|
-
return this.
|
371
|
+
get guidedSellingResult() {
|
372
|
+
return this.guidedSellingResult$.value;
|
319
373
|
}
|
320
|
-
|
321
|
-
this.
|
322
|
-
|
323
|
-
|
324
|
-
|
325
|
-
|
326
|
-
|
327
|
-
|
328
|
-
|
329
|
-
|
330
|
-
|
331
|
-
|
332
|
-
this.isInitializedSubj$
|
333
|
-
.pipe(filter(isInitialized => isInitialized), switchMap$1(() => this.quoteSubj$.asObservable()), skip(1), tap(quote => this.markAsUpdated(quote)))
|
334
|
-
.subscribe();
|
374
|
+
configureGuidedSelling$(data) {
|
375
|
+
return this.orchestrationsApiService
|
376
|
+
.apply$({
|
377
|
+
transactionContext: this.getTransactionContext(data.attributesMap),
|
378
|
+
orchestrationName: data.orchestrationName,
|
379
|
+
})
|
380
|
+
.pipe(map(transactionContext => {
|
381
|
+
const guidedSellingNode = transactionContext.nodes['GuidedSelling']?.[0];
|
382
|
+
const guidedSellingResult = guidedSellingNode?.attributes?.['result'] || {};
|
383
|
+
this.guidedSellingResult$.next(guidedSellingResult);
|
384
|
+
return guidedSellingResult;
|
385
|
+
}));
|
335
386
|
}
|
336
|
-
|
337
|
-
this.
|
338
|
-
this.quoteSubj$.next(null);
|
339
|
-
this.assetsSubj$.next(null);
|
340
|
-
this.isInitialized = false;
|
341
|
-
this.hasUnsavedChanges = false;
|
387
|
+
clearGuidedSelling$() {
|
388
|
+
this.guidedSellingResult$.next({});
|
342
389
|
}
|
343
|
-
|
344
|
-
const
|
345
|
-
|
346
|
-
|
347
|
-
|
348
|
-
|
349
|
-
|
350
|
-
|
351
|
-
|
352
|
-
|
353
|
-
|
354
|
-
|
355
|
-
|
356
|
-
|
357
|
-
|
358
|
-
|
359
|
-
|
360
|
-
|
390
|
+
getTransactionContext(guidedSellingAttributes) {
|
391
|
+
const testTransaction = {
|
392
|
+
id: UUID.UUID(),
|
393
|
+
businessObjectType: 'Quote',
|
394
|
+
salesTransactionItems: [],
|
395
|
+
attributes: {},
|
396
|
+
};
|
397
|
+
return {
|
398
|
+
salesTransaction: testTransaction,
|
399
|
+
transactionId: UUID.UUID(),
|
400
|
+
businessObjectType: 'Quote',
|
401
|
+
nodes: {
|
402
|
+
GuidedSelling: [
|
403
|
+
{
|
404
|
+
id: UUID.UUID(),
|
405
|
+
attributes: {},
|
406
|
+
nodes: {},
|
407
|
+
properties: { guidedSellingAttributes },
|
408
|
+
},
|
409
|
+
],
|
410
|
+
},
|
411
|
+
id: UUID.UUID(),
|
412
|
+
attributes: {},
|
413
|
+
};
|
361
414
|
}
|
362
|
-
|
363
|
-
|
415
|
+
}
|
416
|
+
GuidedSellingService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: GuidedSellingService, deps: [{ token: i1.OrchestrationsApiService }], target: i0.ɵɵFactoryTarget.Injectable });
|
417
|
+
GuidedSellingService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: GuidedSellingService });
|
418
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: GuidedSellingService, decorators: [{
|
419
|
+
type: Injectable
|
420
|
+
}], ctorParameters: function () { return [{ type: i1.OrchestrationsApiService }]; } });
|
421
|
+
|
422
|
+
class ConfigurationService {
|
423
|
+
constructor(flowInfoService, messageService, configurationRuntimeService, salesTransactionService, orchestrationsApiService, guidedSellingService) {
|
424
|
+
this.flowInfoService = flowInfoService;
|
425
|
+
this.messageService = messageService;
|
426
|
+
this.configurationRuntimeService = configurationRuntimeService;
|
427
|
+
this.salesTransactionService = salesTransactionService;
|
428
|
+
this.orchestrationsApiService = orchestrationsApiService;
|
429
|
+
this.guidedSellingService = guidedSellingService;
|
364
430
|
this.hasUnsavedChanges = false;
|
431
|
+
this.configurationStateSubj$ = new BehaviorSubject(null);
|
432
|
+
this.previousConfigurationStateSubj$ = new BehaviorSubject(null);
|
433
|
+
this.isLoadingSubj$ = new BehaviorSubject(false);
|
434
|
+
this.isLoading$ = this.isLoadingSubj$.asObservable();
|
365
435
|
}
|
366
|
-
|
367
|
-
|
368
|
-
if (!quoteDraft) {
|
369
|
-
return;
|
370
|
-
}
|
371
|
-
this.quoteSubj$.next({
|
372
|
-
...quoteDraft,
|
373
|
-
currentState: lineItems,
|
374
|
-
});
|
436
|
+
get state$() {
|
437
|
+
return this.configurationStateSubj$.asObservable().pipe(filter$1(isDefined));
|
375
438
|
}
|
376
|
-
|
377
|
-
|
378
|
-
if (!quoteDraft) {
|
379
|
-
return;
|
380
|
-
}
|
381
|
-
if (update.context) {
|
382
|
-
this.context.set(update.context);
|
383
|
-
}
|
384
|
-
this.quoteSubj$.next({
|
385
|
-
...quoteDraft,
|
386
|
-
...update,
|
387
|
-
});
|
439
|
+
get state() {
|
440
|
+
return this.configurationStateSubj$.getValue();
|
388
441
|
}
|
389
|
-
|
390
|
-
|
391
|
-
if (!quoteDraft) {
|
392
|
-
return;
|
393
|
-
}
|
394
|
-
const updatedCurrentState = this.currentState.map(lineItem => {
|
395
|
-
const updated = priceSummary.lineItems.find(li => li.id === lineItem.id);
|
396
|
-
return updated ?? lineItem;
|
397
|
-
});
|
398
|
-
this.quoteSubj$.next({
|
399
|
-
...quoteDraft,
|
400
|
-
currentState: updatedCurrentState,
|
401
|
-
totalPrices: priceSummary.totalPrices,
|
402
|
-
approvalItems: priceSummary.approvalItems,
|
403
|
-
});
|
442
|
+
get previousState() {
|
443
|
+
return this.previousConfigurationStateSubj$.getValue();
|
404
444
|
}
|
405
|
-
|
406
|
-
this.
|
445
|
+
get root$() {
|
446
|
+
return this.state$.pipe(map$1(state => state.salesTransaction.salesTransactionItems[0]), filter$1(isDefined));
|
407
447
|
}
|
408
|
-
get
|
409
|
-
return
|
448
|
+
get root() {
|
449
|
+
return this.configurationStateSubj$.getValue()?.salesTransaction.salesTransactionItems[0] ?? null;
|
410
450
|
}
|
411
|
-
|
412
|
-
|
413
|
-
|
414
|
-
|
451
|
+
reset() {
|
452
|
+
this.hasUnsavedChanges = false;
|
453
|
+
this.configurationStateSubj$.next(null);
|
454
|
+
this.previousConfigurationStateSubj$.next(null);
|
455
|
+
}
|
456
|
+
init$() {
|
457
|
+
const { state } = this.salesTransactionService;
|
458
|
+
const { standalone } = this.flowInfoService.flow.properties;
|
459
|
+
const { productId, transactionItemId, newProductQty } = this.flowInfoService.context;
|
460
|
+
if (!state || !productId) {
|
461
|
+
return of(undefined);
|
415
462
|
}
|
416
|
-
|
417
|
-
|
418
|
-
|
463
|
+
const salesTransactionItems = state?.salesTransaction.salesTransactionItems ?? [];
|
464
|
+
let isRootGenerated = false;
|
465
|
+
let transactionItem = salesTransactionItems.find(item => item.id === transactionItemId);
|
466
|
+
if (!transactionItem && standalone) {
|
467
|
+
transactionItem = salesTransactionItems.find(item => item.productId === productId);
|
468
|
+
}
|
469
|
+
if (!transactionItem) {
|
470
|
+
transactionItem = generateTransactionItem(productId);
|
471
|
+
if (typeof newProductQty === 'number' && newProductQty > 0) {
|
472
|
+
transactionItem.qty = newProductQty;
|
473
|
+
}
|
474
|
+
isRootGenerated = true;
|
475
|
+
}
|
476
|
+
const guidedSellingResult = this.guidedSellingService.guidedSellingResult;
|
477
|
+
if (transactionItem && Object.keys(guidedSellingResult).length && isRootGenerated) {
|
478
|
+
transactionItem.stiAttributes = Object.entries(guidedSellingResult).map(([attributeName, value]) => ({
|
479
|
+
attributeName,
|
480
|
+
value,
|
481
|
+
}));
|
482
|
+
}
|
483
|
+
const configurationState = {
|
484
|
+
...state,
|
485
|
+
salesTransaction: {
|
486
|
+
...state.salesTransaction,
|
487
|
+
salesTransactionItems: transactionItem ? [transactionItem] : [],
|
488
|
+
},
|
489
|
+
};
|
490
|
+
return (isRootGenerated ? this.configure$(configurationState) : of(configurationState)).pipe(tap$1(configurationState => {
|
491
|
+
this.configurationStateSubj$.next(configurationState);
|
492
|
+
this.previousConfigurationStateSubj$.next(configurationState);
|
493
|
+
}), map$1(noop));
|
494
|
+
}
|
495
|
+
patch$(transactionItem) {
|
496
|
+
const { state, root } = this;
|
497
|
+
if (!state) {
|
498
|
+
return throwError(() => new Error(`Configuration State is not initialized`));
|
499
|
+
}
|
500
|
+
if (!root) {
|
501
|
+
return throwError(() => new Error(`Root SalesTransactionItem not found`));
|
502
|
+
}
|
503
|
+
const newRoot = new TransactionItemWorker(root).replace(transactionItem).ti;
|
504
|
+
const newTransactionContext = {
|
505
|
+
...state,
|
506
|
+
salesTransaction: {
|
507
|
+
...state.salesTransaction,
|
508
|
+
salesTransactionItems: [newRoot],
|
509
|
+
},
|
510
|
+
};
|
511
|
+
return this.configure$(newTransactionContext).pipe(catchError(error => {
|
512
|
+
console.error(error);
|
513
|
+
if (!this.configurationRuntimeService.uiDefinitionProps.suppressToastMessages) {
|
514
|
+
this.messageService.add({ severity: 'error', summary: error });
|
515
|
+
}
|
516
|
+
return throwError(() => error);
|
517
|
+
}), tap$1(() => {
|
518
|
+
if (!this.hasUnsavedChanges) {
|
519
|
+
this.hasUnsavedChanges = true;
|
520
|
+
}
|
521
|
+
}), map$1(noop));
|
522
|
+
}
|
523
|
+
patch(transactionItem) {
|
524
|
+
this.patch$(transactionItem).subscribe();
|
525
|
+
}
|
526
|
+
configure$(transactionContext) {
|
527
|
+
this.isLoadingSubj$.next(true);
|
528
|
+
return this.justConfigureRequest$(transactionContext).pipe(tap$1(result => {
|
529
|
+
this.configurationStateSubj$.next(result);
|
530
|
+
this.previousConfigurationStateSubj$.next(cloneDeep(result));
|
531
|
+
}), catchError(e => {
|
532
|
+
const resetState = this.previousConfigurationStateSubj$.getValue();
|
533
|
+
if (resetState) {
|
534
|
+
this.previousConfigurationStateSubj$.next(cloneDeep(resetState));
|
535
|
+
this.configurationStateSubj$.next(resetState);
|
536
|
+
}
|
537
|
+
return throwError(() => e);
|
538
|
+
}), finalize(() => this.isLoadingSubj$.next(false)));
|
539
|
+
}
|
540
|
+
justConfigureRequest$(transactionContext) {
|
541
|
+
const request = {
|
542
|
+
transactionContext,
|
543
|
+
flowId: this.flowInfoService.flow.id,
|
419
544
|
};
|
545
|
+
return this.orchestrationsApiService.apply$(request).pipe(catchError(error => throwError(() => {
|
546
|
+
if (error.error) {
|
547
|
+
return extractErrorDetails(error.error).join('. ');
|
548
|
+
}
|
549
|
+
return error.message || JSON.stringify(error);
|
550
|
+
})));
|
551
|
+
}
|
552
|
+
getPCMModel() {
|
553
|
+
const pcmModel = this.configurationRuntimeService.pcmModel;
|
554
|
+
if (!pcmModel) {
|
555
|
+
throw new Error('PCM model not initialized');
|
556
|
+
}
|
557
|
+
return pcmModel;
|
558
|
+
}
|
559
|
+
}
|
560
|
+
ConfigurationService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: ConfigurationService, deps: [{ token: FlowInfoService }, { token: i2.MessageService }, { token: ConfigurationRuntimeService }, { token: SalesTransactionService }, { token: i1.OrchestrationsApiService }, { token: GuidedSellingService }], target: i0.ɵɵFactoryTarget.Injectable });
|
561
|
+
ConfigurationService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: ConfigurationService });
|
562
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: ConfigurationService, decorators: [{
|
563
|
+
type: Injectable
|
564
|
+
}], ctorParameters: function () { return [{ type: FlowInfoService }, { type: i2.MessageService }, { type: ConfigurationRuntimeService }, { type: SalesTransactionService }, { type: i1.OrchestrationsApiService }, { type: GuidedSellingService }]; } });
|
565
|
+
|
566
|
+
class SalesTransactionService {
|
567
|
+
get isInitialized$() {
|
568
|
+
return this.isInitializedSubj$.asObservable();
|
569
|
+
}
|
570
|
+
get isInitialized() {
|
571
|
+
return this.isInitializedSubj$.getValue();
|
572
|
+
}
|
573
|
+
set hasUnsavedChanges(value) {
|
574
|
+
this.hasUnsavedChangesSubj$.next(value);
|
575
|
+
if (!this.hasUnsavedChanges) {
|
576
|
+
this.initialState = this.state?.salesTransaction.salesTransactionItems ?? [];
|
577
|
+
}
|
578
|
+
}
|
579
|
+
get hasUnsavedChanges() {
|
580
|
+
return this.hasUnsavedChangesSubj$.getValue();
|
581
|
+
}
|
582
|
+
get state() {
|
583
|
+
return this.stateSubj$.getValue();
|
584
|
+
}
|
585
|
+
get hasProducts() {
|
586
|
+
return Boolean(this.state?.salesTransaction.salesTransactionItems.length);
|
587
|
+
}
|
588
|
+
constructor(salesTransactionApiService) {
|
589
|
+
this.salesTransactionApiService = salesTransactionApiService;
|
590
|
+
this.stateSubj$ = new BehaviorSubject(null);
|
591
|
+
this.isInitializedSubj$ = new BehaviorSubject(false);
|
592
|
+
this.hasUnsavedChangesSubj$ = new BehaviorSubject(false);
|
593
|
+
this.initialState = [];
|
594
|
+
this.hasUnsavedChanges$ = this.hasUnsavedChangesSubj$.asObservable();
|
595
|
+
this.state$ = this.stateSubj$.asObservable().pipe(filter(isDefined));
|
420
596
|
}
|
421
|
-
|
422
|
-
return this.
|
597
|
+
init(headerId, params) {
|
598
|
+
return this.salesTransactionApiService.query(headerId, params).pipe(tap(res => {
|
599
|
+
if (!res.salesTransaction) {
|
600
|
+
throw new Error('SalesTransaction is not defined. Please check Query Orchestration.');
|
601
|
+
}
|
602
|
+
this.stateSubj$.next(res);
|
603
|
+
}));
|
423
604
|
}
|
424
|
-
|
425
|
-
|
605
|
+
finalizeInit() {
|
606
|
+
this.isInitializedSubj$.next(true);
|
607
|
+
this.hasUnsavedChanges = false;
|
426
608
|
}
|
427
|
-
|
428
|
-
|
609
|
+
reset() {
|
610
|
+
this.stateSubj$.next(null);
|
611
|
+
this.isInitializedSubj$.next(false);
|
612
|
+
this.hasUnsavedChangesSubj$.next(false);
|
429
613
|
}
|
430
|
-
|
431
|
-
return this.
|
614
|
+
getInitialState() {
|
615
|
+
return this.initialState;
|
432
616
|
}
|
433
|
-
|
434
|
-
|
617
|
+
setState(state) {
|
618
|
+
this.stateSubj$.next(state);
|
435
619
|
}
|
436
|
-
|
437
|
-
|
620
|
+
}
|
621
|
+
SalesTransactionService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: SalesTransactionService, deps: [{ token: i1.SalesTransactionApiService }], target: i0.ɵɵFactoryTarget.Injectable });
|
622
|
+
SalesTransactionService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: SalesTransactionService });
|
623
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: SalesTransactionService, decorators: [{
|
624
|
+
type: Injectable
|
625
|
+
}], ctorParameters: function () { return [{ type: i1.SalesTransactionApiService }]; } });
|
626
|
+
|
627
|
+
class FlowConfigurationService {
|
628
|
+
constructor(orchestrationsApiService, salesTransactionService, flowInfoService) {
|
629
|
+
this.orchestrationsApiService = orchestrationsApiService;
|
630
|
+
this.salesTransactionService = salesTransactionService;
|
631
|
+
this.flowInfoService = flowInfoService;
|
632
|
+
this.updatedSubj$ = new Subject();
|
633
|
+
this.updated$ = this.updatedSubj$.asObservable();
|
438
634
|
}
|
439
|
-
|
440
|
-
|
441
|
-
|
442
|
-
|
635
|
+
calculate$(state) {
|
636
|
+
return this.orchestrationsApiService
|
637
|
+
.apply$({ transactionContext: state, flowId: this.flowInfoService.flow.id })
|
638
|
+
.pipe(tap(result => this.salesTransactionService.setState(result)), map(noop));
|
639
|
+
}
|
640
|
+
calculate(state) {
|
641
|
+
this.calculate$(state).subscribe();
|
642
|
+
}
|
643
|
+
revert$(transactionItemId) {
|
644
|
+
const state = this.salesTransactionService.state;
|
645
|
+
const initialState = this.salesTransactionService.getInitialState();
|
646
|
+
const currentState = state?.salesTransaction.salesTransactionItems ?? [];
|
647
|
+
const currentItemIndex = currentState.findIndex(({ id }) => id === transactionItemId);
|
648
|
+
const currentItem = currentState[currentItemIndex];
|
649
|
+
const initialItem = initialState.find(({ integrationId }) => integrationId === currentItem?.integrationId);
|
650
|
+
if (!state || !currentItem || !initialItem) {
|
651
|
+
return of(null);
|
443
652
|
}
|
444
|
-
|
445
|
-
|
653
|
+
const updatedState = cloneDeep(currentState);
|
654
|
+
updatedState.splice(currentItemIndex, 1, initialItem);
|
655
|
+
return of([]).pipe(map(() => ({
|
656
|
+
...state,
|
657
|
+
salesTransaction: { ...state.salesTransaction, salesTransactionItems: updatedState },
|
658
|
+
})), tap(newState => this.salesTransactionService.setState(newState)), switchMap(newState => this.calculate$(newState)), map(() => this.salesTransactionService.state), tap(() => this.updatedSubj$.next()), this.handleErrorAndBounceBack());
|
659
|
+
}
|
660
|
+
revert(transactionItemId) {
|
661
|
+
this.revert$(transactionItemId).subscribe();
|
662
|
+
}
|
663
|
+
delete$(ids) {
|
664
|
+
const state = this.salesTransactionService.state;
|
665
|
+
if (!state) {
|
666
|
+
return of(null);
|
446
667
|
}
|
447
|
-
return
|
668
|
+
return of([]).pipe(map(() => state.salesTransaction.salesTransactionItems.filter(({ id }) => !ids.includes(id))), switchMap(updatedState => this.calculate$({
|
669
|
+
...state,
|
670
|
+
salesTransaction: { ...state.salesTransaction, salesTransactionItems: updatedState },
|
671
|
+
})), map(() => this.salesTransactionService.state), tap(() => this.updatedSubj$.next()), this.handleErrorAndBounceBack());
|
672
|
+
}
|
673
|
+
delete(ids) {
|
674
|
+
this.delete$(ids).subscribe();
|
675
|
+
}
|
676
|
+
handleErrorAndBounceBack() {
|
677
|
+
return (source$) => {
|
678
|
+
return source$.pipe(catchError$1(error => {
|
679
|
+
console.error(error);
|
680
|
+
// bounce back if configuration call has failed
|
681
|
+
const state = this.salesTransactionService.state;
|
682
|
+
if (state) {
|
683
|
+
this.salesTransactionService.setState(state);
|
684
|
+
this.updatedSubj$.next();
|
685
|
+
}
|
686
|
+
return throwError(() => error);
|
687
|
+
}));
|
688
|
+
};
|
689
|
+
}
|
690
|
+
}
|
691
|
+
FlowConfigurationService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: FlowConfigurationService, deps: [{ token: i1.OrchestrationsApiService }, { token: SalesTransactionService }, { token: FlowInfoService }], target: i0.ɵɵFactoryTarget.Injectable });
|
692
|
+
FlowConfigurationService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: FlowConfigurationService });
|
693
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: FlowConfigurationService, decorators: [{
|
694
|
+
type: Injectable
|
695
|
+
}], ctorParameters: function () { return [{ type: i1.OrchestrationsApiService }, { type: SalesTransactionService }, { type: FlowInfoService }]; } });
|
696
|
+
|
697
|
+
class TestModeConfigurationService {
|
698
|
+
constructor(flowInfoService, configurationService, configurationRuntimeService, salesTransactionService, runtimeSettingsService, sfApiService) {
|
699
|
+
this.flowInfoService = flowInfoService;
|
700
|
+
this.configurationService = configurationService;
|
701
|
+
this.configurationRuntimeService = configurationRuntimeService;
|
702
|
+
this.salesTransactionService = salesTransactionService;
|
703
|
+
this.runtimeSettingsService = runtimeSettingsService;
|
704
|
+
this.sfApiService = sfApiService;
|
705
|
+
this.isInitialized = false;
|
448
706
|
}
|
449
|
-
|
450
|
-
|
451
|
-
|
707
|
+
initTestMode$(uiDefinitionContainer, options) {
|
708
|
+
this.configurationRuntimeService.uiDefinitionContainer = uiDefinitionContainer;
|
709
|
+
if (this.checkInitialized(uiDefinitionContainer)) {
|
710
|
+
this.configurationRuntimeService.pcmModel = this.pcmModel;
|
711
|
+
return of(undefined);
|
452
712
|
}
|
453
|
-
|
454
|
-
|
713
|
+
this.configurationService.reset();
|
714
|
+
const { productId, quoteId, flowId } = uiDefinitionContainer.source.properties ?? {};
|
715
|
+
if (!productId) {
|
716
|
+
return throwError(() => 'Unable to start the Configuration Preview: Product is missing.');
|
717
|
+
}
|
718
|
+
if (!quoteId) {
|
719
|
+
return throwError(() => `Unable to start the Configuration Preview: Quote is missing.`);
|
720
|
+
}
|
721
|
+
if (!flowId) {
|
722
|
+
return throwError(() => `Unable to start the Configuration Preview: Flow is missing.`);
|
455
723
|
}
|
724
|
+
return this.runtimeSettingsService.create().pipe(switchMap(() => this.flowInfoService.init$(flowId, { productId, headerId: quoteId, testMode: true })), switchMap(() => this.configurationRuntimeService.init$({ productId })), tap(pcmModel => (this.pcmModel = pcmModel)), switchMap(() => {
|
725
|
+
if (options?.customizationMode) {
|
726
|
+
return of(undefined);
|
727
|
+
}
|
728
|
+
return this.initConfiguration$(quoteId);
|
729
|
+
}), tap(() => (this.isInitialized = true)), map(noop));
|
730
|
+
}
|
731
|
+
initConfiguration$(quoteId) {
|
732
|
+
return this.getPriceBookId(quoteId).pipe(map(priceBookId => this.getTestTransactionContext(quoteId, priceBookId)), tap(state => this.salesTransactionService.setState(state)), switchMap(() => this.configurationService.init$()), switchMap(() => this.configurationService.state
|
733
|
+
? this.configurationService.configure$(this.configurationService.state)
|
734
|
+
: of(undefined)), map(noop));
|
735
|
+
}
|
736
|
+
getPriceBookId(quoteId) {
|
737
|
+
return this.sfApiService
|
738
|
+
.query({ count: 1, fields: ['Pricebook2Id'], rawCondition: `Id = '${quoteId}'` }, 'Quote')
|
739
|
+
.pipe(map(r => r?.[0]?.Pricebook2Id ?? null));
|
740
|
+
}
|
741
|
+
getTestTransactionContext(quoteId, priceBookId) {
|
742
|
+
const dateStr = new Date().toISOString().split('T')[0] ?? '';
|
743
|
+
const testTransaction = {
|
744
|
+
id: quoteId,
|
745
|
+
businessObjectType: 'Quote',
|
746
|
+
salesTransactionItems: [],
|
747
|
+
salesTransactionName: 'Test Quote',
|
748
|
+
account: '',
|
749
|
+
quoteAccount: '',
|
750
|
+
pricebook: '',
|
751
|
+
status: 'Draft',
|
752
|
+
totalAmount: 0,
|
753
|
+
subtotal: 0,
|
754
|
+
activatedDate: dateStr,
|
755
|
+
effectiveDate: dateStr,
|
756
|
+
startDate: dateStr,
|
757
|
+
attributes: {},
|
758
|
+
nodes: {},
|
759
|
+
};
|
760
|
+
if (priceBookId) {
|
761
|
+
testTransaction.pricebook = priceBookId;
|
762
|
+
}
|
763
|
+
return {
|
764
|
+
salesTransaction: testTransaction,
|
765
|
+
transactionId: quoteId,
|
766
|
+
businessObjectType: 'Quote',
|
767
|
+
nodes: {},
|
768
|
+
id: UUID.UUID(),
|
769
|
+
attributes: {},
|
770
|
+
};
|
771
|
+
}
|
772
|
+
checkInitialized(uiDefinitionContainer) {
|
773
|
+
return this.isInitialized && !!uiDefinitionContainer.source.properties?.persistTestState;
|
456
774
|
}
|
457
775
|
}
|
458
|
-
|
459
|
-
|
460
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type:
|
776
|
+
TestModeConfigurationService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: TestModeConfigurationService, deps: [{ token: FlowInfoService }, { token: ConfigurationService }, { token: ConfigurationRuntimeService }, { token: SalesTransactionService }, { token: RuntimeSettingsService }, { token: i1.SalesforceApiService }], target: i0.ɵɵFactoryTarget.Injectable });
|
777
|
+
TestModeConfigurationService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: TestModeConfigurationService });
|
778
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: TestModeConfigurationService, decorators: [{
|
461
779
|
type: Injectable
|
462
|
-
}], ctorParameters: function () { return [{ type:
|
780
|
+
}], ctorParameters: function () { return [{ type: FlowInfoService }, { type: ConfigurationService }, { type: ConfigurationRuntimeService }, { type: SalesTransactionService }, { type: RuntimeSettingsService }, { type: i1.SalesforceApiService }]; } });
|
463
781
|
|
464
782
|
class FlowStateService {
|
465
|
-
constructor(
|
466
|
-
this.contextService = contextService;
|
467
|
-
this.quoteDraftService = quoteDraftService;
|
468
|
-
this.flowInfoService = flowInfoService;
|
783
|
+
constructor(flowConfiguration, flowInfoService, flowStateApiService, processorsApiService, salesTransactionApiService, salesTransactionService, toastService, customizationService) {
|
469
784
|
this.flowConfiguration = flowConfiguration;
|
470
|
-
this.
|
785
|
+
this.flowInfoService = flowInfoService;
|
471
786
|
this.flowStateApiService = flowStateApiService;
|
472
|
-
this.
|
787
|
+
this.processorsApiService = processorsApiService;
|
788
|
+
this.salesTransactionApiService = salesTransactionApiService;
|
789
|
+
this.salesTransactionService = salesTransactionService;
|
473
790
|
this.toastService = toastService;
|
474
791
|
this.customizationService = customizationService;
|
475
792
|
this.NOT_INITIALIZED = Symbol();
|
@@ -486,68 +803,22 @@ class FlowStateService {
|
|
486
803
|
this.cleanup$ = new Subject();
|
487
804
|
this.statefulExecutionRequest$ = this.initBufferedRequest$();
|
488
805
|
/*
|
489
|
-
In stateless mode watch
|
490
|
-
all subscriptions get their updates according to updated
|
806
|
+
In stateless mode watch State changes and call executeRequest so that
|
807
|
+
all subscriptions get their updates according to updated State
|
491
808
|
*/
|
492
809
|
this.isInitialized$()
|
493
|
-
.pipe(filter
|
810
|
+
.pipe(filter(Boolean), filter(() => !this.flowInfoService.flow.properties.stateful), switchMap(() => this.flowConfiguration.updated$), switchMap(() => this.executeRequest$({}, true)))
|
494
811
|
.subscribe();
|
495
|
-
this.charges$ = this.flowInfoService.flow$.pipe(filter$1(isDefined), switchMap(() => {
|
496
|
-
if (this.flowInfoService.isLegacy) {
|
497
|
-
return this.quoteDraftService.quoteDraft$.pipe(map$1(quoteDraft => quoteDraft.charges));
|
498
|
-
}
|
499
|
-
else {
|
500
|
-
return this.subscribe$(UITemplateType.FLOW_ENGINE, 'CHARGES', null, {
|
501
|
-
cold: true,
|
502
|
-
}).pipe(map$1(response => (response.success ? response.result : {})));
|
503
|
-
}
|
504
|
-
}), shareReplay$1(1));
|
505
|
-
this.charges$.subscribe();
|
506
|
-
this.pricePlans$ = this.flowInfoService.flow$.pipe(filter$1(isDefined), switchMap(() => {
|
507
|
-
if (this.flowInfoService.isLegacy) {
|
508
|
-
return this.quoteDraftService.quoteDraft$.pipe(map$1(quoteDraft => quoteDraft.pricePlans));
|
509
|
-
}
|
510
|
-
else {
|
511
|
-
return this.subscribe$(UITemplateType.FLOW_ENGINE, 'PRICE_PLANS', null, {
|
512
|
-
cold: true,
|
513
|
-
}).pipe(map$1(response => (response.success ? response.result : {})));
|
514
|
-
}
|
515
|
-
}), shareReplay$1(1));
|
516
|
-
this.pricePlans$.subscribe();
|
517
|
-
this.activeMetrics$ = this.flowInfoService.flow$.pipe(filter$1(isDefined), switchMap(() => {
|
518
|
-
if (this.flowInfoService.isLegacy) {
|
519
|
-
return this.quoteDraftService.quoteDraft$.pipe(map$1(quoteDraft => quoteDraft.activeMetrics));
|
520
|
-
}
|
521
|
-
else {
|
522
|
-
return this.subscribe$(UITemplateType.FLOW_ENGINE, 'ACTIVE_METRICS', null, {
|
523
|
-
cold: true,
|
524
|
-
}).pipe(map$1(response => (response.success ? response.result : [])));
|
525
|
-
}
|
526
|
-
}), shareReplay$1(1));
|
527
|
-
this.activeMetrics$.subscribe();
|
528
|
-
this.isPriceListLocked$ = this.flowInfoService.flow$.pipe(filter$1(isDefined), switchMap(() => {
|
529
|
-
if (this.flowInfoService.isLegacy) {
|
530
|
-
return of(false);
|
531
|
-
}
|
532
|
-
else {
|
533
|
-
return this.subscribe$(UITemplateType.FLOW_ENGINE, 'IS_PRICE_LIST_LOCKED', null, {
|
534
|
-
cold: true,
|
535
|
-
}).pipe(map$1(response => (response.success ? response.result : false)));
|
536
|
-
}
|
537
|
-
}), shareReplay$1(1));
|
538
|
-
this.isPriceListLocked$.subscribe();
|
539
812
|
}
|
540
813
|
init$() {
|
541
|
-
|
542
|
-
|
543
|
-
|
544
|
-
|
545
|
-
|
546
|
-
|
547
|
-
}
|
548
|
-
}));
|
814
|
+
if (this.flowInfoService.flow.properties.stateful) {
|
815
|
+
return this.initProcessors$().pipe(switchMap(() => this.initStateful$()));
|
816
|
+
}
|
817
|
+
else {
|
818
|
+
return forkJoin([this.initStateless$(), this.initProcessors$()]).pipe(map(noop));
|
819
|
+
}
|
549
820
|
}
|
550
|
-
|
821
|
+
reset() {
|
551
822
|
Object.values(this.subscriptions).forEach(({ data$ }) => data$.complete());
|
552
823
|
this.subscriptions = {};
|
553
824
|
if (this.stateId$.value) {
|
@@ -559,9 +830,9 @@ class FlowStateService {
|
|
559
830
|
this.cleanup$.next();
|
560
831
|
}
|
561
832
|
get hasUnsavedChanges() {
|
562
|
-
return this.
|
833
|
+
return this.flowInfoService.flow.properties.stateful
|
563
834
|
? Array.from(this.trackedStatefulChangesMap.values()).some(Boolean)
|
564
|
-
: this.
|
835
|
+
: this.salesTransactionService.hasUnsavedChanges;
|
565
836
|
}
|
566
837
|
get stateId() {
|
567
838
|
return this.stateId$.value;
|
@@ -570,14 +841,14 @@ class FlowStateService {
|
|
570
841
|
return this.executionInProgress$.asObservable();
|
571
842
|
}
|
572
843
|
isInitialized$() {
|
573
|
-
return combineLatest([this.stateId$, this.
|
844
|
+
return combineLatest([this.stateId$, this.salesTransactionService.isInitialized$]).pipe(map(values => values.some(Boolean)));
|
574
845
|
}
|
575
846
|
isInitialized() {
|
576
|
-
return Boolean(this.stateId$.value) || this.
|
847
|
+
return Boolean(this.stateId$.value) || this.salesTransactionService.isInitialized;
|
577
848
|
}
|
578
849
|
execute$(scope, exec) {
|
579
850
|
const request = this.execToRequest(scope, exec);
|
580
|
-
return this.executeRequest$(request).pipe(map
|
851
|
+
return this.executeRequest$(request).pipe(map(result => {
|
581
852
|
// Keep only requested results
|
582
853
|
const actualSelectors = Object.entries(result.selectors).reduce((trunk, [requestId, result]) => {
|
583
854
|
if (exec.selectors?.[requestId]) {
|
@@ -593,7 +864,7 @@ class FlowStateService {
|
|
593
864
|
actions: [{ name: action, inputData }],
|
594
865
|
};
|
595
866
|
const request = this.execToRequest(scope, exec);
|
596
|
-
return this.executeRequest$(request).pipe(map
|
867
|
+
return this.executeRequest$(request).pipe(map(noop));
|
597
868
|
}
|
598
869
|
select$(scope, selectorName, inputData) {
|
599
870
|
const requestId = this.generateRequestId(scope, selectorName, inputData);
|
@@ -605,7 +876,7 @@ class FlowStateService {
|
|
605
876
|
},
|
606
877
|
},
|
607
878
|
});
|
608
|
-
return this.executeRequest$(request).pipe(map
|
879
|
+
return this.executeRequest$(request).pipe(map(response => response.selectors[requestId]));
|
609
880
|
}
|
610
881
|
subscribe$(scope, selectorName, inputData, options) {
|
611
882
|
const requestId = this.generateRequestId(scope, selectorName, inputData);
|
@@ -631,16 +902,16 @@ class FlowStateService {
|
|
631
902
|
this.executeRequest$(request).subscribe();
|
632
903
|
}
|
633
904
|
}
|
634
|
-
return subscription.data$.pipe(filter
|
905
|
+
return subscription.data$.pipe(filter(data => data != this.NOT_INITIALIZED), map(data => data), finalize$1(() => {
|
635
906
|
if (!this.subscriptions[requestId]?.data$.observed) {
|
636
907
|
delete this.subscriptions[requestId];
|
637
908
|
}
|
638
909
|
}));
|
639
910
|
}
|
640
911
|
save$() {
|
641
|
-
if (this.
|
912
|
+
if (this.flowInfoService.flow.properties.stateful) {
|
642
913
|
if (this.stateId$.value) {
|
643
|
-
return this.flowStateApiService.save(this.stateId$.value).pipe(tap
|
914
|
+
return this.flowStateApiService.save(this.stateId$.value).pipe(map(({ quoteId }) => ({ id: quoteId })), tap(() => {
|
644
915
|
Array.from(this.trackedStatefulChangesMap.keys()).forEach(key => {
|
645
916
|
this.trackedStatefulChangesMap.set(key, false);
|
646
917
|
});
|
@@ -648,30 +919,16 @@ class FlowStateService {
|
|
648
919
|
}
|
649
920
|
}
|
650
921
|
else {
|
651
|
-
const
|
652
|
-
if (
|
653
|
-
|
654
|
-
|
655
|
-
|
656
|
-
|
657
|
-
|
658
|
-
return of({ quoteId: '' });
|
659
|
-
}
|
660
|
-
submit$() {
|
661
|
-
if (this.getFlowSafe().properties.stateful) {
|
662
|
-
if (this.stateId$.value) {
|
663
|
-
return this.flowStateApiService.submit(this.stateId$.value);
|
664
|
-
}
|
665
|
-
}
|
666
|
-
else {
|
667
|
-
const quoteDraft = this.quoteDraftService.quoteDraft;
|
668
|
-
if (quoteDraft) {
|
669
|
-
return this.quoteApiService.submitQuote(quoteDraft).pipe(tap$1(({ versionId }) => {
|
670
|
-
this.contextService.update({ properties: { VELOCE_PRISM__VersionId__c: versionId } });
|
671
|
-
}));
|
922
|
+
const state = this.salesTransactionService.state;
|
923
|
+
if (state) {
|
924
|
+
const request = {
|
925
|
+
transactionContext: state,
|
926
|
+
flowId: this.flowInfoService.flow.id,
|
927
|
+
};
|
928
|
+
return this.salesTransactionApiService.save(request).pipe(map(id => ({ id })));
|
672
929
|
}
|
673
930
|
}
|
674
|
-
return of({
|
931
|
+
return of({ id: '' });
|
675
932
|
}
|
676
933
|
getFlowStore() {
|
677
934
|
return this.flowStore;
|
@@ -709,10 +966,10 @@ class FlowStateService {
|
|
709
966
|
fullRequest.selectors = assign(fullRequest.selectors, subscription.request.selectors);
|
710
967
|
}
|
711
968
|
}
|
712
|
-
const execution$ = this.
|
969
|
+
const execution$ = this.flowInfoService.flow.properties.stateful
|
713
970
|
? this.executeStateful$(fullRequest)
|
714
971
|
: this.executeStateless$(fullRequest);
|
715
|
-
return execution$.pipe(tap
|
972
|
+
return execution$.pipe(tap(result => this.handleSelectorsResponse(result.selectors)));
|
716
973
|
}
|
717
974
|
handleSelectorsResponse(selectors) {
|
718
975
|
Object.entries(selectors).forEach(([requestId, selectorResult]) => {
|
@@ -727,31 +984,21 @@ class FlowStateService {
|
|
727
984
|
});
|
728
985
|
}
|
729
986
|
initStateful$() {
|
730
|
-
// Subscriptions
|
731
|
-
this.subscribe$(UITemplateType.FLOW_ENGINE, 'CONTEXT', null, { cold: true })
|
732
|
-
.pipe(tap$1(response => {
|
733
|
-
if (response.success) {
|
734
|
-
this.contextService.update(response.result);
|
735
|
-
}
|
736
|
-
}), takeUntil(this.cleanup$))
|
737
|
-
.subscribe();
|
738
987
|
const processorsList = flatten(Object.values(this.processors).map(ownerMap => Object.values(ownerMap ?? {})));
|
739
988
|
const processors = processorsList.length ? processorsList : undefined;
|
740
989
|
const selectors = Object.values(this.subscriptions)
|
741
990
|
.map(({ request }) => request.selectors)
|
742
991
|
.filter(isDefined)
|
743
992
|
.reduce((trunk, selectors) => ({ ...trunk, ...selectors }), {});
|
744
|
-
const request = this.getDefaultExecutionRequestDTO();
|
745
993
|
return this.flowStateApiService
|
746
994
|
.init({
|
747
|
-
quoteId: this.
|
748
|
-
params: this.flowInfoService.
|
995
|
+
quoteId: this.flowInfoService.context.headerId,
|
996
|
+
params: this.flowInfoService.context,
|
749
997
|
actionsOverride: processors?.filter(processor => processor.type === ConfigurationProcessorTypes.ACTION),
|
750
998
|
selectorsOverride: processors?.filter(processor => processor.type === ConfigurationProcessorTypes.SELECTOR),
|
751
|
-
selectors:
|
752
|
-
actions: request.actions,
|
999
|
+
selectors: selectors,
|
753
1000
|
})
|
754
|
-
.pipe(map
|
1001
|
+
.pipe(map(({ stateId, selectors }) => {
|
755
1002
|
this.handleSelectorsResponse(selectors);
|
756
1003
|
this.stateId$.next(stateId);
|
757
1004
|
}));
|
@@ -771,1112 +1018,173 @@ class FlowStateService {
|
|
771
1018
|
};
|
772
1019
|
this.executionInProgress$.next(true);
|
773
1020
|
return this.flowStateApiService.execute(this.stateId$.value, request);
|
774
|
-
}), tap
|
1021
|
+
}), tap(({ stateId }) => this.stateId$.next(stateId)), share(), tap(() => this.executionInProgress$.next(false)), catchError$1(e => {
|
775
1022
|
this.executionInProgress$.next(false);
|
776
1023
|
return throwError(() => e);
|
777
1024
|
}));
|
778
1025
|
}
|
779
1026
|
executeStateful$(request) {
|
780
|
-
return this.executionInProgress$.pipe(filter
|
1027
|
+
return this.executionInProgress$.pipe(filter(inProgress => !inProgress), take(1), switchMap(() =>
|
781
1028
|
// make sure stream switches to statefulExecutionRequest$ before pushing an execution request
|
782
1029
|
combineLatest([
|
783
1030
|
this.statefulExecutionRequest$,
|
784
|
-
of(undefined).pipe(tap
|
785
|
-
])), map
|
1031
|
+
of(undefined).pipe(tap(() => this.statefulRequestStream$.next(request))),
|
1032
|
+
])), map(([response]) => response), take(1));
|
786
1033
|
}
|
787
1034
|
initStateless$() {
|
788
|
-
|
789
|
-
return this.quoteDraftService.init(headerId, this.flowInfoService.params ?? {}).pipe(tap$1(() => {
|
790
|
-
const assets = this.quoteDraftService.assetsState;
|
791
|
-
if (assets) {
|
792
|
-
this.flowStore = { ...this.flowStore, assets };
|
793
|
-
}
|
794
|
-
}), switchMap(() => {
|
795
|
-
if (this.flowInfoService.isLegacy) {
|
796
|
-
return of(null);
|
797
|
-
}
|
798
|
-
return this.executeRequest$(this.getDefaultExecutionRequestDTO());
|
799
|
-
}), switchMap(() => this.calculate$()), tap$1(() => this.quoteDraftService.finalizeInit()), map$1(noop));
|
800
|
-
}
|
801
|
-
calculate$() {
|
802
|
-
const flowState = this.quoteDraftService.quoteDraft;
|
803
|
-
if (!flowState) {
|
804
|
-
return of(undefined);
|
805
|
-
}
|
806
|
-
/*
|
807
|
-
Don't execute procedures when:
|
808
|
-
* Initializing a standalone product configuration UI, as procedure is execute in /price call
|
809
|
-
* Initializing an empty account (account with no assets)
|
810
|
-
*/
|
811
|
-
const isEmptyAccountMode = this.contextService.mode === ConfigurationContextMode.ACCOUNT &&
|
812
|
-
!this.quoteDraftService.hasProducts &&
|
813
|
-
!this.quoteDraftService.hasAssets &&
|
814
|
-
!this.quoteDraftService.quoteDraft?.initialState.length;
|
815
|
-
if (this.quoteDraftService.isStandalone || isEmptyAccountMode) {
|
816
|
-
return of(undefined);
|
817
|
-
}
|
818
|
-
return this.flowConfiguration.calculate$(flowState);
|
1035
|
+
return this.salesTransactionService.init(this.flowInfoService.context.headerId, this.flowInfoService.context).pipe(switchMap(state => this.flowConfiguration.calculate$(state)), tap(() => this.salesTransactionService.finalizeInit()), map(noop));
|
819
1036
|
}
|
820
1037
|
executeStateless$(request) {
|
821
1038
|
this.executionInProgress$.next(true);
|
822
|
-
return of(undefined).pipe(tap
|
1039
|
+
return of(undefined).pipe(tap(() => this.executeStatelessActions(request)), switchMap(() => {
|
823
1040
|
/*
|
824
1041
|
Skip price calculation in case
|
825
1042
|
1. No actions in the request
|
826
1043
|
2. Initialization process execution (state not initialized yet)
|
827
|
-
*/
|
828
|
-
|
829
|
-
|
830
|
-
|
831
|
-
|
832
|
-
|
833
|
-
|
834
|
-
|
835
|
-
|
836
|
-
|
837
|
-
|
838
|
-
|
839
|
-
executeStatelessActions(request) {
|
840
|
-
if (!this.quoteDraftService.quoteDraft || !request.actions?.length) {
|
841
|
-
return;
|
842
|
-
}
|
843
|
-
let flowState = this.quoteDraftService.quoteDraft;
|
844
|
-
request.actions.forEach(action => {
|
845
|
-
try {
|
846
|
-
flowState = this.executeActionScript(flowState, action) ?? flowState;
|
847
|
-
}
|
848
|
-
catch (e) {
|
849
|
-
console.error(e);
|
850
|
-
this.toastService.add({ severity: ToastType.error, summary: String(e) });
|
851
|
-
throw e;
|
852
|
-
}
|
853
|
-
});
|
854
|
-
this.quoteDraftService.updateQuoteDraft(flowState);
|
855
|
-
}
|
856
|
-
executeStatelessSelectors(request) {
|
857
|
-
if (!this.quoteDraftService.quoteDraft) {
|
858
|
-
throw 'QuoteDraft is not initialized';
|
859
|
-
}
|
860
|
-
const flowState = this.quoteDraftService.quoteDraft;
|
861
|
-
return EntityUtil.entries(request.selectors ?? {}).reduce((result, [key, selector]) => {
|
862
|
-
try {
|
863
|
-
result.selectors[key] = {
|
864
|
-
success: true,
|
865
|
-
result: this.executeSelectorScript(flowState, selector),
|
866
|
-
};
|
867
|
-
}
|
868
|
-
catch (e) {
|
869
|
-
console.error(e);
|
870
|
-
result.selectors[key] = {
|
871
|
-
success: false,
|
872
|
-
errorMessage: String(e),
|
873
|
-
};
|
874
|
-
}
|
875
|
-
return result;
|
876
|
-
}, { stateId: '', selectors: {} });
|
877
|
-
}
|
878
|
-
getFlowSafe() {
|
879
|
-
if (!this.flowInfoService.flow) {
|
880
|
-
throw 'Flow is not defined';
|
881
|
-
}
|
882
|
-
return this.flowInfoService.flow;
|
883
|
-
}
|
884
|
-
initProcessors$() {
|
885
|
-
const hasOverrides = Boolean(this.customizationService?.getTemplateConfigurationProcessors);
|
886
|
-
const flow = this.getFlowSafe();
|
887
|
-
if (flow.properties.stateful && !hasOverrides) {
|
888
|
-
// Skip initialization as backend will take processors from SF
|
889
|
-
return of(undefined);
|
890
|
-
}
|
891
|
-
const owners$ = Object.values(this.flowInfoService.templates)
|
892
|
-
.map(template => {
|
893
|
-
if (!template) {
|
894
|
-
return;
|
895
|
-
}
|
896
|
-
const localProcessors$ = this.customizationService?.getTemplateConfigurationProcessors?.(template.name) ?? of(null);
|
897
|
-
return localProcessors$.pipe(switchMap(processors => processors ? of(processors) : this.processorsApiService.fetchConfigurationProcessors$(template.id)), tap$1(processors => {
|
898
|
-
const processorsMap = processors.reduce((acc, p) => {
|
899
|
-
acc[p.apiName] = p;
|
900
|
-
return acc;
|
901
|
-
}, {});
|
902
|
-
this.processors[template.id] = processorsMap;
|
903
|
-
}));
|
904
|
-
})
|
905
|
-
.filter(isDefined);
|
906
|
-
if (!owners$.length) {
|
907
|
-
return of(undefined);
|
908
|
-
}
|
909
|
-
return forkJoin(owners$).pipe(map$1(noop));
|
910
|
-
}
|
911
|
-
executeActionScript(request, executable) {
|
912
|
-
const configurationProcessor = this.processors[executable.ownerId]?.[executable.apiName];
|
913
|
-
if (!configurationProcessor?.script) {
|
914
|
-
const scope = this.getScopeByOwnerId(executable.ownerId);
|
915
|
-
const scopeText = scope ? ` in ${scope}` : '';
|
916
|
-
throw `ConfigurationProcessor ${executable.apiName}${scopeText} not found`;
|
917
|
-
}
|
918
|
-
return this.executeProcessorScript(request, configurationProcessor, executable.inputData);
|
919
|
-
}
|
920
|
-
executeSelectorScript(request, executable) {
|
921
|
-
const configurationProcessor = this.processors[executable.ownerId]?.[executable.apiName];
|
922
|
-
if (!configurationProcessor?.script) {
|
923
|
-
const scope = this.getScopeByOwnerId(executable.ownerId);
|
924
|
-
const scopeText = scope ? ` in ${scope}` : '';
|
925
|
-
throw `ConfigurationProcessor ${executable.apiName}${scopeText} not found`;
|
926
|
-
}
|
927
|
-
return this.executeProcessorScript(request, configurationProcessor, executable.inputData);
|
928
|
-
}
|
929
|
-
executeProcessorScript(request, configurationProcessor, inputData) {
|
930
|
-
const scope = this.getScopeByOwnerId(configurationProcessor.ownerId ?? '');
|
931
|
-
let functionToExecute = this.executedFunctions[scope + configurationProcessor.apiName];
|
932
|
-
if (!functionToExecute) {
|
933
|
-
const script = `${configurationProcessor.script}\nreturn transform;`;
|
934
|
-
const sourceMap = `\n//# sourceURL=${scope ? scope + '/' : ''}${configurationProcessor.apiName}.js`;
|
935
|
-
functionToExecute = new Function(script + sourceMap)();
|
936
|
-
this.executedFunctions[scope + configurationProcessor.apiName] = functionToExecute;
|
937
|
-
}
|
938
|
-
return functionToExecute({
|
939
|
-
request,
|
940
|
-
inputData,
|
941
|
-
flowStore: this.flowStore,
|
942
|
-
});
|
943
|
-
}
|
944
|
-
generateRequestId(scope, selectorName, inputData) {
|
945
|
-
const inputDataHash = UUID.hex(JSON.stringify(inputData) || '').slice(0, 8);
|
946
|
-
return `${scope}/${selectorName}/${inputDataHash}`;
|
947
|
-
}
|
948
|
-
getDefaultExecutionRequestDTO() {
|
949
|
-
const request = {
|
950
|
-
actions: [],
|
951
|
-
selectors: {},
|
952
|
-
};
|
953
|
-
if (this.getFlowSafe().properties.standalone) {
|
954
|
-
return request;
|
955
|
-
}
|
956
|
-
const flowEngineTemplateId = this.getOwnerIdByScope(UITemplateType.FLOW_ENGINE);
|
957
|
-
request.actions?.push({
|
958
|
-
apiName: 'UPDATE_CONTEXT_PROPERTIES',
|
959
|
-
ownerId: flowEngineTemplateId,
|
960
|
-
inputData: this.contextService.resolve().properties,
|
961
|
-
});
|
962
|
-
return request;
|
963
|
-
}
|
964
|
-
checkStatefulChanges(requestId, selectorResult) {
|
965
|
-
if (this.trackedStatefulChangesMap.has(requestId)) {
|
966
|
-
if (!this.initialStatefulData[requestId]) {
|
967
|
-
this.initialStatefulData[requestId] = selectorResult;
|
968
|
-
}
|
969
|
-
const hasChanges = !isEqual(this.initialStatefulData[requestId], selectorResult);
|
970
|
-
this.trackedStatefulChangesMap.set(requestId, hasChanges);
|
971
|
-
}
|
972
|
-
}
|
973
|
-
}
|
974
|
-
FlowStateService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: FlowStateService, deps: [{ token: ContextService }, { token: QuoteDraftService }, { token: FlowInfoService }, { token: FlowConfigurationService }, { token: i1.ConfigurationProcessorsApiService }, { token: i1.FlowStateApiService }, { token: i1.QuoteApiService }, { token: i6.ToastService }, { token: FLOW_CUSTOMIZATION, optional: true }], target: i0.ɵɵFactoryTarget.Injectable });
|
975
|
-
FlowStateService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: FlowStateService });
|
976
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: FlowStateService, decorators: [{
|
977
|
-
type: Injectable
|
978
|
-
}], ctorParameters: function () { return [{ type: ContextService }, { type: QuoteDraftService }, { type: FlowInfoService }, { type: FlowConfigurationService }, { type: i1.ConfigurationProcessorsApiService }, { type: i1.FlowStateApiService }, { type: i1.QuoteApiService }, { type: i6.ToastService }, { type: undefined, decorators: [{
|
979
|
-
type: Optional
|
980
|
-
}, {
|
981
|
-
type: Inject,
|
982
|
-
args: [FLOW_CUSTOMIZATION]
|
983
|
-
}] }]; } });
|
984
|
-
|
985
|
-
const findLineItem = (id, lineItems) => {
|
986
|
-
return findLineItemWithComparator(lineItems, (li) => li.id === id);
|
987
|
-
};
|
988
|
-
const findLineItemWithComparator = (lineItems, comparator) => {
|
989
|
-
let currentLevel = lineItems;
|
990
|
-
while (currentLevel.length) {
|
991
|
-
const found = currentLevel.find(comparator);
|
992
|
-
if (found) {
|
993
|
-
return found;
|
994
|
-
}
|
995
|
-
currentLevel = flatten(currentLevel.map(parent => parent.lineItems));
|
996
|
-
}
|
997
|
-
return;
|
998
|
-
};
|
999
|
-
const insertLineItem = (lineItem, parentId, toInsert) => {
|
1000
|
-
const insertData = lineItem.id === parentId ? [toInsert] : [];
|
1001
|
-
return {
|
1002
|
-
...lineItem,
|
1003
|
-
lineItems: [
|
1004
|
-
...insertData,
|
1005
|
-
...lineItem.lineItems.map(li => {
|
1006
|
-
return insertLineItem(li, parentId, toInsert);
|
1007
|
-
}),
|
1008
|
-
],
|
1009
|
-
};
|
1010
|
-
};
|
1011
|
-
const removeLineItem = (lineItem, idToRemove) => {
|
1012
|
-
return {
|
1013
|
-
...lineItem,
|
1014
|
-
lineItems: lineItem.lineItems
|
1015
|
-
.map(li => {
|
1016
|
-
if (li.id === idToRemove) {
|
1017
|
-
return;
|
1018
|
-
}
|
1019
|
-
else if (li.lineItems.length) {
|
1020
|
-
return removeLineItem(li, idToRemove);
|
1021
|
-
}
|
1022
|
-
return li;
|
1023
|
-
})
|
1024
|
-
.filter(r => !!r),
|
1025
|
-
};
|
1026
|
-
};
|
1027
|
-
const replaceLineItem = (lineItem, replaceTo, skipCardinalityCalculation = false) => {
|
1028
|
-
if (lineItem.id === replaceTo.id) {
|
1029
|
-
if (!skipCardinalityCalculation) {
|
1030
|
-
return { ...recalculateCardinalityVariables(lineItem, replaceTo) };
|
1031
|
-
}
|
1032
|
-
else {
|
1033
|
-
return { ...replaceTo };
|
1034
|
-
}
|
1035
|
-
}
|
1036
|
-
return {
|
1037
|
-
...lineItem,
|
1038
|
-
lineItems: lineItem.lineItems.map(li => replaceLineItem(li, replaceTo, skipCardinalityCalculation)),
|
1039
|
-
};
|
1040
|
-
};
|
1041
|
-
const collectCardinalityComputations = (portDomains) => {
|
1042
|
-
const cardinalityComputations = new Map();
|
1043
|
-
entries(portDomains).forEach(([key, portDomain]) => {
|
1044
|
-
cardinalityComputations.set(key, portDomain.properties['cardinalityComputation'] === 'true');
|
1045
|
-
});
|
1046
|
-
return cardinalityComputations;
|
1047
|
-
};
|
1048
|
-
const calculateCardinalityVariables = (lineItems, cardinalityComputations) => {
|
1049
|
-
const cardVars = new Map();
|
1050
|
-
lineItems
|
1051
|
-
.filter(({ port, type }) => !!port && !!type)
|
1052
|
-
.forEach(li => {
|
1053
|
-
if (cardinalityComputations.get(`${li.port}`)) {
|
1054
|
-
const cardinalityVariableName = `#CV-${li.type}@${li.port}`;
|
1055
|
-
cardVars.set(cardinalityVariableName, (cardVars.get(cardinalityVariableName) ?? 0) + li.qty);
|
1056
|
-
}
|
1057
|
-
});
|
1058
|
-
return cardVars;
|
1059
|
-
};
|
1060
|
-
const cardinalityRegexp = new RegExp('#CV-[a-zA-Z0-9_]+@(?<portName>[a-zA-Z0-9_]+)');
|
1061
|
-
const recalculateCardinalityVariables = (original, updated) => {
|
1062
|
-
const cardinalityComputations = collectCardinalityComputations(updated.portDomains ?? original.portDomains ?? {});
|
1063
|
-
const cardinalityVariables = calculateCardinalityVariables(updated.lineItems, cardinalityComputations);
|
1064
|
-
const originalCardinalityVariables = calculateCardinalityVariables(original.lineItems, cardinalityComputations);
|
1065
|
-
originalCardinalityVariables.forEach((value, key) => {
|
1066
|
-
const execArray = cardinalityRegexp.exec(key);
|
1067
|
-
const portName = execArray?.groups?.['portName'];
|
1068
|
-
if (!portName || cardinalityComputations.get(portName)) {
|
1069
|
-
if (cardinalityVariables.get(key) === value) {
|
1070
|
-
// no need to update cardinality if no changes
|
1071
|
-
cardinalityVariables.delete(key);
|
1072
|
-
}
|
1073
|
-
else if (!cardinalityVariables.has(key)) {
|
1074
|
-
// remove last item from port
|
1075
|
-
cardinalityVariables.set(key, 0);
|
1076
|
-
}
|
1077
|
-
}
|
1078
|
-
});
|
1079
|
-
return {
|
1080
|
-
...updated,
|
1081
|
-
attributes: upsertAttributes(updated.attributes, [...cardinalityVariables].map(([name, value]) => ({ name, value, cfgStatus: 'Changed' }))),
|
1082
|
-
};
|
1083
|
-
};
|
1084
|
-
const mapAttributes = (attributes) => {
|
1085
|
-
return attributes.reduce((acc, { name, value }) => ({ ...acc, [name]: value }), {});
|
1086
|
-
};
|
1087
|
-
const getAttributes = (attributes, names = []) => {
|
1088
|
-
const filtered = attributes.filter(({ name }) => names.includes(name));
|
1089
|
-
return sortBy(filtered, [({ name }) => names.indexOf(name)]);
|
1090
|
-
};
|
1091
|
-
const upsertAttributes = (originalAttributes, attributesToUpsert) => {
|
1092
|
-
return attributesToUpsert.reduce((acc, { name, value }) => {
|
1093
|
-
const [origAttr] = getAttributes(acc, [name]);
|
1094
|
-
return [
|
1095
|
-
...acc.filter(attr => attr.name !== name),
|
1096
|
-
{ ...(origAttr ?? { name, type: '' }), cfgStatus: origAttr ? 'Changed' : 'User', value },
|
1097
|
-
];
|
1098
|
-
}, originalAttributes);
|
1099
|
-
};
|
1100
|
-
const patchAttributes = (rootLineItem, id, attrs, skipCardinalityCalculation = false) => {
|
1101
|
-
const lineItem = findLineItem(id, [rootLineItem]);
|
1102
|
-
if (!lineItem) {
|
1103
|
-
return rootLineItem;
|
1104
|
-
}
|
1105
|
-
const attributes = upsertAttributes(lineItem.attributes, attrs);
|
1106
|
-
return replaceLineItem(rootLineItem, { ...lineItem, attributes }, skipCardinalityCalculation);
|
1107
|
-
};
|
1108
|
-
const getAttributeValue = (attributes, name) => attributes.find(attr => attr.name === name)?.value;
|
1109
|
-
const generateLineItem = (port, type, parentId, attributes = [], lineItems = []) => {
|
1110
|
-
return {
|
1111
|
-
id: UUID.UUID(),
|
1112
|
-
port,
|
1113
|
-
type,
|
1114
|
-
actionCode: 'ADD',
|
1115
|
-
cfgStatus: 'New',
|
1116
|
-
attributes: attributes.map(({ name, value }) => ({ cfgStatus: 'User', name, value })),
|
1117
|
-
lineItems,
|
1118
|
-
parentId,
|
1119
|
-
qty: 1,
|
1120
|
-
};
|
1121
|
-
};
|
1122
|
-
const getRecommendedPrices = (portDomain, type) => {
|
1123
|
-
const domainType = portDomain.domainTypes.find(({ name }) => name === type);
|
1124
|
-
const [net, list] = domainType?.recommendedPrices
|
1125
|
-
?.filter(({ chargeMethod }) => chargeMethod === 'ONE_TIME')
|
1126
|
-
.reduce((acc, rp) => {
|
1127
|
-
const [netPrice, listPrice] = acc;
|
1128
|
-
return [netPrice + rp.netPrice, listPrice + rp.listPrice];
|
1129
|
-
}, [0, 0]) ?? [0, 0];
|
1130
|
-
return { net, list };
|
1131
|
-
};
|
1132
|
-
const getOriginParent = (lineItems, currentLineItem) => {
|
1133
|
-
let target = currentLineItem;
|
1134
|
-
while (target && target.rampInstanceId) {
|
1135
|
-
target = lineItems.find(sub => sub.id === currentLineItem.rampInstanceId);
|
1136
|
-
}
|
1137
|
-
return target;
|
1138
|
-
};
|
1139
|
-
const assetPredicateFn = (lineItem, assetId) => {
|
1140
|
-
if (!assetId) {
|
1141
|
-
return false;
|
1142
|
-
}
|
1143
|
-
return lineItem.assetId === assetId || lineItem.openOrderLineItemId === assetId;
|
1144
|
-
};
|
1145
|
-
const multiplyLineItems = (lineItem, qty, split) => {
|
1146
|
-
if (split) {
|
1147
|
-
const unifyIds = (lineItem) => ({
|
1148
|
-
...lineItem,
|
1149
|
-
id: UUID.UUID(),
|
1150
|
-
lineItems: lineItem.lineItems.map(unifyIds),
|
1151
|
-
});
|
1152
|
-
return map$2(new Array(qty), () => unifyIds(lineItem));
|
1153
|
-
}
|
1154
|
-
else {
|
1155
|
-
return [
|
1156
|
-
{
|
1157
|
-
...lineItem,
|
1158
|
-
qty: qty,
|
1159
|
-
},
|
1160
|
-
];
|
1161
|
-
}
|
1162
|
-
};
|
1163
|
-
const isTechnicalAttribute = (name) => {
|
1164
|
-
return name.startsWith('#') || name.startsWith('$');
|
1165
|
-
};
|
1166
|
-
const filterOutTechnicalAttributes = (attributes) => {
|
1167
|
-
return attributes.filter(({ name }) => !isTechnicalAttribute(name));
|
1168
|
-
};
|
1169
|
-
|
1170
|
-
var lineItem_utils = /*#__PURE__*/Object.freeze({
|
1171
|
-
__proto__: null,
|
1172
|
-
assetPredicateFn: assetPredicateFn,
|
1173
|
-
filterOutTechnicalAttributes: filterOutTechnicalAttributes,
|
1174
|
-
findLineItem: findLineItem,
|
1175
|
-
findLineItemWithComparator: findLineItemWithComparator,
|
1176
|
-
generateLineItem: generateLineItem,
|
1177
|
-
getAttributeValue: getAttributeValue,
|
1178
|
-
getAttributes: getAttributes,
|
1179
|
-
getOriginParent: getOriginParent,
|
1180
|
-
getRecommendedPrices: getRecommendedPrices,
|
1181
|
-
insertLineItem: insertLineItem,
|
1182
|
-
isTechnicalAttribute: isTechnicalAttribute,
|
1183
|
-
mapAttributes: mapAttributes,
|
1184
|
-
multiplyLineItems: multiplyLineItems,
|
1185
|
-
patchAttributes: patchAttributes,
|
1186
|
-
recalculateCardinalityVariables: recalculateCardinalityVariables,
|
1187
|
-
removeLineItem: removeLineItem,
|
1188
|
-
replaceLineItem: replaceLineItem,
|
1189
|
-
upsertAttributes: upsertAttributes
|
1190
|
-
});
|
1191
|
-
|
1192
|
-
class RuntimeSettingsService {
|
1193
|
-
constructor(configurationSettingsApiService) {
|
1194
|
-
this.configurationSettingsApiService = configurationSettingsApiService;
|
1195
|
-
this.configurationSettings$ = new BehaviorSubject({});
|
1196
|
-
this.currencySettings$ = new BehaviorSubject({
|
1197
|
-
iso: DEFAULT_CURRENCY_ISO_CODE,
|
1198
|
-
symbol: DEFAULT_CURRENCY_SYMBOL,
|
1199
|
-
});
|
1200
|
-
this.shoppingCartSettings$ = new BehaviorSubject([]);
|
1201
|
-
this.getCurrencySymbol = (locale, currency) => {
|
1202
|
-
return (0)
|
1203
|
-
.toLocaleString(locale, { style: 'currency', currency, minimumFractionDigits: 0, maximumFractionDigits: 0 })
|
1204
|
-
.replace(/\d/g, '')
|
1205
|
-
.trim();
|
1206
|
-
};
|
1207
|
-
}
|
1208
|
-
create() {
|
1209
|
-
return this.configurationSettingsApiService.fetchSettings().pipe(map$1(settings => this.parseConfigurationSettings(settings)), tap$1(configurationSettings => {
|
1210
|
-
this.configurationSettings$.next(configurationSettings);
|
1211
|
-
this.addShoppingCartSettings(configurationSettings['shopping-cart'] ?? []);
|
1212
|
-
this.formattingSettings = this.getFormattingSettings();
|
1213
|
-
}), map$1(() => undefined));
|
1214
|
-
}
|
1215
|
-
initCurrency(iso) {
|
1216
|
-
if (iso) {
|
1217
|
-
const symbol = this.getCurrencySymbol('en-US', iso);
|
1218
|
-
this.currencySettings$.next({ iso, symbol });
|
1219
|
-
if (this.formattingSettings) {
|
1220
|
-
this.formattingSettings.currencySymbol = symbol;
|
1221
|
-
}
|
1222
|
-
}
|
1223
|
-
}
|
1224
|
-
getFormattingSettings() {
|
1225
|
-
if (this.formattingSettings) {
|
1226
|
-
return this.formattingSettings;
|
1227
|
-
}
|
1228
|
-
const shoppingCartSettings = this.getConfigurationSettings()['shopping-cart']?.reduce((acc, setting) => {
|
1229
|
-
return { ...acc, [setting.id]: setting.properties };
|
1230
|
-
}, {});
|
1231
|
-
const currencySettings = this.getCurrencySettings();
|
1232
|
-
const dateFormat = (validateDateFormat(shoppingCartSettings?.DATE_FORMAT ?? '') && shoppingCartSettings?.DATE_FORMAT) ||
|
1233
|
-
DEFAULT_DATE_FORMAT;
|
1234
|
-
const decimalSeparator = shoppingCartSettings?.DECIMAL_SEPARATOR;
|
1235
|
-
const thousandsSeparator = shoppingCartSettings?.THOUSANDS_SEPARATOR;
|
1236
|
-
// the number of decimal places can be 0
|
1237
|
-
const priceScale = shoppingCartSettings?.PRICE_SCALE;
|
1238
|
-
const decimalsCount = priceScale !== null && priceScale !== '' && !isNaN(Number(priceScale)) && Number(priceScale) >= 0
|
1239
|
-
? Number(priceScale)
|
1240
|
-
: DEFAULT_DECIMALS_COUNT;
|
1241
|
-
const actionCodeSettings = shoppingCartSettings?.STATUS_LABEL;
|
1242
|
-
return {
|
1243
|
-
currencySymbol: currencySettings.symbol,
|
1244
|
-
dateFormats: getSupportedDateFormats(dateFormat),
|
1245
|
-
decimalsCount,
|
1246
|
-
decimalSeparator: decimalSeparator !== undefined && ['.', ','].includes(decimalSeparator)
|
1247
|
-
? decimalSeparator
|
1248
|
-
: DEFAULT_DECIMAL_SEPARATOR,
|
1249
|
-
// thousands separator can be a blank value, so it can also be null
|
1250
|
-
thousandsSeparator: thousandsSeparator !== undefined && ['.', ',', '', null].includes(thousandsSeparator)
|
1251
|
-
? thousandsSeparator || ''
|
1252
|
-
: DEFAULT_THOUSANDS_SEPARATOR,
|
1253
|
-
actionCodeLabels: actionCodeSettings?.length
|
1254
|
-
? actionCodeSettings.reduce((result, setting) => ({ ...result, [setting.status_label]: setting.custom_label }), {})
|
1255
|
-
: DEFAULT_ACTION_CODE_LABELS,
|
1256
|
-
};
|
1257
|
-
}
|
1258
|
-
getConfigurationSettings() {
|
1259
|
-
return this.configurationSettings$.value;
|
1260
|
-
}
|
1261
|
-
getShoppingCartSettings() {
|
1262
|
-
return this.shoppingCartSettings$.value;
|
1263
|
-
}
|
1264
|
-
getCurrencySettings() {
|
1265
|
-
return this.currencySettings$.value;
|
1266
|
-
}
|
1267
|
-
parseConfigurationSettings(settings) {
|
1268
|
-
return settings.reduce((acc, setting) => {
|
1269
|
-
switch (setting.key) {
|
1270
|
-
case 'shopping-cart':
|
1271
|
-
acc['shopping-cart'] = parseJsonSafely(setting.value, []);
|
1272
|
-
break;
|
1273
|
-
case 'navigation':
|
1274
|
-
acc.navigation = parseJsonSafely(setting.value, {});
|
1275
|
-
break;
|
1276
|
-
case 'flows':
|
1277
|
-
acc.flows = parseJsonSafely(setting.value, []);
|
1278
|
-
break;
|
1279
|
-
default:
|
1280
|
-
acc[setting.key] = setting.value;
|
1281
|
-
}
|
1282
|
-
return acc;
|
1283
|
-
}, {});
|
1284
|
-
}
|
1285
|
-
addShoppingCartSettings(settings) {
|
1286
|
-
// uniqBy removes items with the biggest index
|
1287
|
-
const newSettings = uniqBy([...settings, ...this.shoppingCartSettings$.value], 'id');
|
1288
|
-
this.shoppingCartSettings$.next(newSettings);
|
1289
|
-
}
|
1290
|
-
}
|
1291
|
-
RuntimeSettingsService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: RuntimeSettingsService, deps: [{ token: i1.ConfigurationSettingsApiService }], target: i0.ɵɵFactoryTarget.Injectable });
|
1292
|
-
RuntimeSettingsService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: RuntimeSettingsService });
|
1293
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: RuntimeSettingsService, decorators: [{
|
1294
|
-
type: Injectable
|
1295
|
-
}], ctorParameters: function () { return [{ type: i1.ConfigurationSettingsApiService }]; } });
|
1296
|
-
|
1297
|
-
class LineItemWorker {
|
1298
|
-
constructor(src) {
|
1299
|
-
this.li = { ...src };
|
1300
|
-
}
|
1301
|
-
insert(parentId, toInsert) {
|
1302
|
-
return new LineItemWorker(insertLineItem(this.li, parentId, toInsert));
|
1303
|
-
}
|
1304
|
-
remove(id) {
|
1305
|
-
return new LineItemWorker(removeLineItem(this.li, id));
|
1306
|
-
}
|
1307
|
-
replace(toReplace, skipCardinalityCalculation = false) {
|
1308
|
-
return new LineItemWorker(replaceLineItem(this.li, toReplace, skipCardinalityCalculation));
|
1309
|
-
}
|
1310
|
-
patchAttribute(attrs, id, skipCardinalityCalculation = false) {
|
1311
|
-
return new LineItemWorker(patchAttributes(this.li, id ?? this.li.id, attrs, skipCardinalityCalculation));
|
1312
|
-
}
|
1313
|
-
}
|
1314
|
-
|
1315
|
-
function extractMetadata(uiDefinition) {
|
1316
|
-
return omit(uiDefinition, [
|
1317
|
-
'children',
|
1318
|
-
'pages',
|
1319
|
-
'components',
|
1320
|
-
]);
|
1321
|
-
}
|
1322
|
-
|
1323
|
-
class ConfigurationService {
|
1324
|
-
constructor(quoteDraftService, runtimeService, contextService, configurationApiService, messageService, dialogService, runtimeSettings, flowInfoService) {
|
1325
|
-
this.quoteDraftService = quoteDraftService;
|
1326
|
-
this.runtimeService = runtimeService;
|
1327
|
-
this.contextService = contextService;
|
1328
|
-
this.configurationApiService = configurationApiService;
|
1329
|
-
this.messageService = messageService;
|
1330
|
-
this.dialogService = dialogService;
|
1331
|
-
this.runtimeSettings = runtimeSettings;
|
1332
|
-
this.flowInfoService = flowInfoService;
|
1333
|
-
this.mode = ConfigurationMode.SEARCH;
|
1334
|
-
this.configurationState = new BehaviorSubject(null);
|
1335
|
-
this.previousConfigurationState = new BehaviorSubject(null);
|
1336
|
-
this.isLoadingSubj$ = new BehaviorSubject(false);
|
1337
|
-
this.isLoading$ = this.isLoadingSubj$.asObservable();
|
1338
|
-
this.hasUnsavedChanges = false;
|
1339
|
-
}
|
1340
|
-
reset() {
|
1341
|
-
this.hasUnsavedChanges = false;
|
1342
|
-
this.runtimeService.reset();
|
1343
|
-
this.configurableRamp = undefined;
|
1344
|
-
this.configurationState.next(null);
|
1345
|
-
this.previousConfigurationState.next(null);
|
1346
|
-
}
|
1347
|
-
patch$(lineItem, options) {
|
1348
|
-
const source = this.getSnapshot();
|
1349
|
-
if (!source) {
|
1350
|
-
return throwError(() => new Error(`Source LineItem not found`));
|
1351
|
-
}
|
1352
|
-
const skipCardinalityCalculation = options?.skipCardinalityCalculation || this.contextSnapshot.properties['#skipCardinalityCalculation'] === 'true';
|
1353
|
-
this.configurableRamp = new LineItemWorker(source).replace(lineItem, skipCardinalityCalculation).li;
|
1354
|
-
return this.configure().pipe(catchError$1(error => {
|
1355
|
-
console.error(error);
|
1356
|
-
if (!this.runtimeService.uiDefinitionProperties.suppressToastMessages) {
|
1357
|
-
this.messageService.add({ severity: 'error', summary: error });
|
1358
|
-
}
|
1359
|
-
// bounce back if configuration call has failed
|
1360
|
-
const prevState = this.configurationState.value;
|
1361
|
-
this.configurationState.next(prevState ? { ...prevState } : null);
|
1362
|
-
return throwError(() => error);
|
1363
|
-
}), tap(() => {
|
1364
|
-
if (!this.hasUnsavedChanges) {
|
1365
|
-
this.hasUnsavedChanges = true;
|
1366
|
-
}
|
1367
|
-
}));
|
1368
|
-
}
|
1369
|
-
patch(lineItem, options) {
|
1370
|
-
this.patch$(lineItem, options).subscribe();
|
1371
|
-
}
|
1372
|
-
setConfigurableRamp(lineItem) {
|
1373
|
-
this.configurableRamp = lineItem;
|
1374
|
-
}
|
1375
|
-
get() {
|
1376
|
-
return this.configurationState.pipe(map(state => state?.lineItem), shareReplay$1());
|
1377
|
-
}
|
1378
|
-
getSnapshot() {
|
1379
|
-
return this.configurationState.value?.lineItem ? { ...this.configurationState.value?.lineItem } : undefined;
|
1380
|
-
}
|
1381
|
-
getRuntimeModel() {
|
1382
|
-
const runtimeModel = this.runtimeService.runtimeModel;
|
1383
|
-
if (!runtimeModel) {
|
1384
|
-
throw new Error('Runtime model not initialized');
|
1385
|
-
}
|
1386
|
-
return runtimeModel;
|
1387
|
-
}
|
1388
|
-
getRuntimeContext() {
|
1389
|
-
const runtimeContext = this.runtimeService.runtimeContext;
|
1390
|
-
if (!runtimeContext) {
|
1391
|
-
throw new Error('Runtime context not initialized');
|
1392
|
-
}
|
1393
|
-
return runtimeContext;
|
1394
|
-
}
|
1395
|
-
get state$() {
|
1396
|
-
return this.configurationState.asObservable();
|
1397
|
-
}
|
1398
|
-
get stateSnapshot() {
|
1399
|
-
return this.configurationState.value;
|
1400
|
-
}
|
1401
|
-
get previousStateSnapshot() {
|
1402
|
-
return this.previousConfigurationState.value;
|
1403
|
-
}
|
1404
|
-
get contextSnapshot() {
|
1405
|
-
return this.contextService.resolve();
|
1406
|
-
}
|
1407
|
-
get context$() {
|
1408
|
-
return this.contextService.resolve$();
|
1409
|
-
}
|
1410
|
-
get charges$() {
|
1411
|
-
return this.configurationState.pipe(map(state => state?.charges ?? {}));
|
1412
|
-
}
|
1413
|
-
get chargesSnapshot() {
|
1414
|
-
return this.configurationState.value?.charges ?? {};
|
1415
|
-
}
|
1416
|
-
get pricePlans$() {
|
1417
|
-
return this.configurationState.pipe(map(state => state?.pricePlans ?? {}));
|
1418
|
-
}
|
1419
|
-
get pricePlansSnapshot() {
|
1420
|
-
return this.configurationState.value?.pricePlans ?? {};
|
1421
|
-
}
|
1422
|
-
get procedureContext$() {
|
1423
|
-
return this.configurationState.pipe(map(state => state?.procedureContext ?? {}));
|
1424
|
-
}
|
1425
|
-
get procedureContextSnapshot() {
|
1426
|
-
return this.configurationState.value?.procedureContext ?? {};
|
1427
|
-
}
|
1428
|
-
configure() {
|
1429
|
-
return this.configureRequest$(this.generateRequest());
|
1430
|
-
}
|
1431
|
-
configureRequest$(configurationRequest) {
|
1432
|
-
const runtimeContext = this.getRuntimeContext();
|
1433
|
-
const runtimeModel = this.getRuntimeModel();
|
1434
|
-
const uiDefinitionProperties = this.getUIDefinitionProperties();
|
1435
|
-
const mainPricingEnabled = runtimeContext.properties?.PricingEnabled;
|
1436
|
-
const pricingEnabled = mainPricingEnabled ? mainPricingEnabled === 'true' : uiDefinitionProperties.pricingEnabled;
|
1437
|
-
const customPriceApi = this.runtimeSettings.getConfigurationSettings()['CUSTOM_PRICE_API'];
|
1438
|
-
this.isLoadingSubj$.next(true);
|
1439
|
-
const configure$ = pricingEnabled && customPriceApi
|
1440
|
-
? this.configurationApiService.customConfigurePrice({
|
1441
|
-
url: customPriceApi,
|
1442
|
-
configurationRequest: this.extendConfigurationRequest(configurationRequest),
|
1443
|
-
runtimeModel,
|
1444
|
-
})
|
1445
|
-
: this.extendedConfigureLineItem$({
|
1446
|
-
configurationRequest,
|
1447
|
-
runtimeModel,
|
1448
|
-
pricingEnabled,
|
1449
|
-
});
|
1450
|
-
return configure$.pipe(tap(result => {
|
1451
|
-
this.contextService.update(result.context);
|
1452
|
-
this.configurationState.next(result);
|
1453
|
-
this.previousConfigurationState.next(cloneDeep(result));
|
1454
|
-
if (result.deletedLineItems?.length) {
|
1455
|
-
this.showInactiveProductsConfirmation();
|
1456
|
-
}
|
1457
|
-
this.configurableRamp = result.lineItem;
|
1458
|
-
}), map(({ lineItem }) => lineItem), catchError$1(error => throwError(() => {
|
1459
|
-
const resetState = this.previousConfigurationState.value;
|
1460
|
-
if (resetState) {
|
1461
|
-
this.previousConfigurationState.next(cloneDeep(resetState));
|
1462
|
-
this.configurationState.next(resetState);
|
1463
|
-
}
|
1464
|
-
if (error.error) {
|
1465
|
-
return extractErrorDetails(error.error).join('. ');
|
1466
|
-
}
|
1467
|
-
return error.message || JSON.stringify(error);
|
1468
|
-
})), finalize$1(() => this.isLoadingSubj$.next(false)));
|
1469
|
-
}
|
1470
|
-
configureExternal$(props) {
|
1471
|
-
return this.runtimeService
|
1472
|
-
.init({ productId: props.productId, defaultQty: props.qty, attributesMap: props.attributesMap })
|
1473
|
-
.pipe(switchMap$1(() => this.configure()), first(), catchError$1(error => {
|
1474
|
-
this.messageService.add({ severity: ToastType.error, summary: error });
|
1475
|
-
throw error;
|
1476
|
-
}), finalize$1(() => this.reset()));
|
1477
|
-
}
|
1478
|
-
configureGuidedSelling$(data) {
|
1479
|
-
return this.extendedConfigureLineItem$({
|
1480
|
-
configurationRequest: getGuidedSellingConfigurationRequest(data, this.contextService.resolve()),
|
1481
|
-
}).pipe(catchError$1(error => {
|
1482
|
-
if (error instanceof HttpErrorResponse) {
|
1483
|
-
this.messageService.add({ severity: ToastType.error, summary: error.error.message || error.error });
|
1484
|
-
}
|
1485
|
-
throw error;
|
1486
|
-
}));
|
1487
|
-
}
|
1488
|
-
generateRequest(lightMode = true) {
|
1489
|
-
const lineItem = this.generateLineItem();
|
1490
|
-
let request = {
|
1491
|
-
lineItem,
|
1492
|
-
mode: this.mode,
|
1493
|
-
step: !this.configurationState.value?.lineItem ? RuntimeStep.START : RuntimeStep.UPDATE,
|
1494
|
-
attributeDomainMode: 'ALL',
|
1495
|
-
context: this.contextService.resolve(),
|
1496
|
-
lineItems: this.quoteDraftService.quoteDraft?.currentState || [],
|
1497
|
-
asset: this.getAsset(),
|
1498
|
-
};
|
1499
|
-
if (lightMode) {
|
1500
|
-
request = ConfigurationTranslatorUtils.lightenConfigurationRequest(request);
|
1501
|
-
}
|
1502
|
-
return request;
|
1503
|
-
}
|
1504
|
-
generateLineItem() {
|
1505
|
-
const runtimeContext = this.getRuntimeContext();
|
1506
|
-
const uiDefinitionProperties = this.getUIDefinitionProperties();
|
1507
|
-
let lineItem = this.configurableRamp;
|
1508
|
-
if (!lineItem) {
|
1509
|
-
const { initializationProps } = this.runtimeService ?? {};
|
1510
|
-
lineItem = getDefaultLineItem(runtimeContext, uiDefinitionProperties, initializationProps?.defaultQty);
|
1511
|
-
// Set default attributes
|
1512
|
-
if (initializationProps?.attributesMap) {
|
1513
|
-
const attributes = transform(initializationProps?.attributesMap, (acc, value, name) => acc.push({ name, value }), []);
|
1514
|
-
lineItem = new LineItemWorker(lineItem).patchAttribute(attributes).li;
|
1515
|
-
}
|
1516
|
-
}
|
1517
|
-
return lineItem;
|
1518
|
-
}
|
1519
|
-
getAsset() {
|
1520
|
-
const lineItem = this.configurableRamp;
|
1521
|
-
if (!lineItem) {
|
1522
|
-
return;
|
1523
|
-
}
|
1524
|
-
const assetId = lineItem.assetId ?? lineItem.openOrderLineItemId;
|
1525
|
-
return this.quoteDraftService.assetsState?.initialState.find(li => assetPredicateFn(li, assetId));
|
1526
|
-
}
|
1527
|
-
getUIDefinitionProperties() {
|
1528
|
-
return {
|
1529
|
-
...(this.getRuntimeContext().uiDefinitionContainer?.source.properties ?? {}),
|
1530
|
-
...(this.runtimeService.uiDefinitionProperties ?? {}),
|
1531
|
-
};
|
1532
|
-
}
|
1533
|
-
showInactiveProductsConfirmation() {
|
1534
|
-
const confirmationConfig = {
|
1535
|
-
title: ' ',
|
1536
|
-
description: 'This quote contains inactive products. Do you want to remove them?',
|
1537
|
-
primaryButtonLabel: 'Remove products',
|
1538
|
-
secondaryButtonLabel: 'Back to Quote',
|
1539
|
-
};
|
1540
|
-
this.dialogService
|
1541
|
-
.open(ConfirmationComponent, {
|
1542
|
-
dismissableMask: false,
|
1543
|
-
closeOnEscape: false,
|
1544
|
-
closable: false,
|
1545
|
-
showHeader: true,
|
1546
|
-
header: `Inactive Products in Quote`,
|
1547
|
-
width: '440px',
|
1548
|
-
data: { confirmationConfig },
|
1549
|
-
})
|
1550
|
-
.onClose.subscribe(result => {
|
1551
|
-
if (!result) {
|
1552
|
-
const context = this.contextService.resolve();
|
1553
|
-
window['VELO_BACK_FN'].apply(null, [context.headerId]);
|
1554
|
-
}
|
1555
|
-
});
|
1556
|
-
}
|
1557
|
-
extendedConfigureLineItem$({ configurationRequest, runtimeModel, pricingEnabled, }) {
|
1558
|
-
return this.configurationApiService.configureLineItem({
|
1559
|
-
configurationRequest: this.extendConfigurationRequest(configurationRequest),
|
1560
|
-
runtimeModel,
|
1561
|
-
pricingEnabled,
|
1562
|
-
});
|
1563
|
-
}
|
1564
|
-
extendConfigurationRequest(configurationRequest) {
|
1565
|
-
const procedureName = this.flowInfoService.flow?.properties.procedureName;
|
1566
|
-
return {
|
1567
|
-
...configurationRequest,
|
1568
|
-
...(procedureName ? { procedureName } : {}),
|
1569
|
-
};
|
1570
|
-
}
|
1571
|
-
}
|
1572
|
-
ConfigurationService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: ConfigurationService, deps: [{ token: QuoteDraftService }, { token: ConfigurationRuntimeService }, { token: ContextService }, { token: i1.ConfigurationApiService }, { token: i5.MessageService }, { token: i6$1.DialogService }, { token: RuntimeSettingsService }, { token: FlowInfoService }], target: i0.ɵɵFactoryTarget.Injectable });
|
1573
|
-
ConfigurationService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: ConfigurationService });
|
1574
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: ConfigurationService, decorators: [{
|
1575
|
-
type: Injectable
|
1576
|
-
}], ctorParameters: function () { return [{ type: QuoteDraftService }, { type: ConfigurationRuntimeService }, { type: ContextService }, { type: i1.ConfigurationApiService }, { type: i5.MessageService }, { type: i6$1.DialogService }, { type: RuntimeSettingsService }, { type: FlowInfoService }]; } });
|
1577
|
-
|
1578
|
-
class FlowUpdateService {
|
1579
|
-
update(rootLineItems, updates, charges) {
|
1580
|
-
let remainingUpdates = [...updates];
|
1581
|
-
let currentLevel = rootLineItems;
|
1582
|
-
while (currentLevel.length && remainingUpdates.length) {
|
1583
|
-
currentLevel.forEach(li => {
|
1584
|
-
const unhandledUpdates = [];
|
1585
|
-
remainingUpdates.forEach(update => {
|
1586
|
-
let updated = false;
|
1587
|
-
switch (update.dataType) {
|
1588
|
-
case 'LINEITEM':
|
1589
|
-
updated = this.applyLineItemUpdate(li, update, charges);
|
1590
|
-
break;
|
1591
|
-
case 'CHARGE':
|
1592
|
-
updated = this.applyChargeUpdate(li, update);
|
1593
|
-
break;
|
1594
|
-
case 'GROUP_CHARGE':
|
1595
|
-
updated = this.applyChargeGroupUpdate(li, update);
|
1596
|
-
break;
|
1597
|
-
default:
|
1598
|
-
// Unknown dataType. Do not try to handle it anymore
|
1599
|
-
updated = true;
|
1600
|
-
}
|
1601
|
-
if (!updated) {
|
1602
|
-
unhandledUpdates.push(update);
|
1603
|
-
}
|
1604
|
-
});
|
1605
|
-
remainingUpdates = unhandledUpdates;
|
1606
|
-
});
|
1607
|
-
currentLevel = flatten(currentLevel.map(parent => parent.lineItems));
|
1608
|
-
}
|
1609
|
-
}
|
1610
|
-
delete(lineItems, id) {
|
1611
|
-
const idsToRemove = [id];
|
1612
|
-
const topLevelLineItem = lineItems.find(li => li.id === id);
|
1613
|
-
if (topLevelLineItem) {
|
1614
|
-
// find term-related line items (which are only top level)
|
1615
|
-
// expired term line items won't be deleted
|
1616
|
-
let foundTermLineItem = topLevelLineItem;
|
1617
|
-
while (foundTermLineItem) {
|
1618
|
-
foundTermLineItem = lineItems.find(li => foundTermLineItem && li.rampInstanceId === foundTermLineItem.id);
|
1619
|
-
if (foundTermLineItem) {
|
1620
|
-
idsToRemove.push(foundTermLineItem.id);
|
1621
|
-
}
|
1622
|
-
}
|
1623
|
-
}
|
1624
|
-
const filtered = lineItems.filter(lineItem => !idsToRemove.includes(lineItem.id));
|
1625
|
-
return filtered.map(lineItem => new LineItemWorker(lineItem).remove(id).li);
|
1626
|
-
}
|
1627
|
-
applyLineItemUpdate(lineItem, update, charges) {
|
1628
|
-
if (lineItem.id !== update.id) {
|
1629
|
-
return false;
|
1630
|
-
}
|
1631
|
-
switch (update.attributeType) {
|
1632
|
-
case 'QTY':
|
1633
|
-
lineItem.qty = update.newValue;
|
1634
|
-
break;
|
1635
|
-
case 'EFFECTIVE_START_DATE':
|
1636
|
-
lineItem.properties['StartDate'] = moment(update.newValue).format('YYYY-MM-DD');
|
1637
|
-
break;
|
1638
|
-
case 'END_DATE':
|
1639
|
-
lineItem.properties['EndDate'] = moment(update.newValue).format('YYYY-MM-DD');
|
1640
|
-
break;
|
1641
|
-
case 'PRICE_ADJUSTMENT':
|
1642
|
-
{
|
1643
|
-
const charge = lineItem.chargeItems.find(charge => (charges || {})[charge.chargeId]?.main);
|
1644
|
-
if (charge) {
|
1645
|
-
charge.priceAdjustment = update.newValue;
|
1646
|
-
}
|
1647
|
-
}
|
1648
|
-
break;
|
1649
|
-
case 'LIST_PRICE_ADJUSTMENT':
|
1650
|
-
case 'MARGIN_ADJUSTMENT':
|
1651
|
-
{
|
1652
|
-
const charge = lineItem.chargeItems.find(charge => (charges || {})[charge.chargeId]?.main);
|
1653
|
-
if (charge) {
|
1654
|
-
charge.listPriceAdjustment = update.newValue;
|
1655
|
-
}
|
1656
|
-
}
|
1657
|
-
break;
|
1658
|
-
case 'COST_ADJUSTMENT':
|
1659
|
-
{
|
1660
|
-
const charge = lineItem.chargeItems.find(charge => (charges || {})[charge.chargeId]?.main);
|
1661
|
-
if (charge) {
|
1662
|
-
charge.costAdjustment = update.newValue;
|
1663
|
-
}
|
1664
|
-
}
|
1665
|
-
break;
|
1666
|
-
default:
|
1667
|
-
throw new Error(`Not suppored AttributeType for LineItem update: ${update.attributeType}`);
|
1668
|
-
}
|
1669
|
-
return true;
|
1044
|
+
*/
|
1045
|
+
const { state } = this.salesTransactionService;
|
1046
|
+
if (!state || !request.actions?.length || !this.isInitialized()) {
|
1047
|
+
return of(undefined);
|
1048
|
+
}
|
1049
|
+
else {
|
1050
|
+
return this.flowConfiguration.calculate$(state);
|
1051
|
+
}
|
1052
|
+
}), map(() => this.executeStatelessSelectors(request)), tap(() => this.executionInProgress$.next(false)), catchError$1(e => {
|
1053
|
+
this.executionInProgress$.next(false);
|
1054
|
+
return throwError(() => e);
|
1055
|
+
}));
|
1670
1056
|
}
|
1671
|
-
|
1672
|
-
const
|
1673
|
-
if (!
|
1674
|
-
return
|
1675
|
-
}
|
1676
|
-
if (update.attributeType === 'PRICE_ADJUSTMENT') {
|
1677
|
-
foundCharge.priceAdjustment = update.newValue;
|
1678
|
-
}
|
1679
|
-
else if (update.attributeType === 'LIST_PRICE_ADJUSTMENT') {
|
1680
|
-
foundCharge.listPriceAdjustment = update.newValue;
|
1681
|
-
}
|
1682
|
-
else {
|
1683
|
-
throw new Error(`Not suppored AttributeType for Charge Item update: ${update.attributeType}`);
|
1057
|
+
executeStatelessActions(request) {
|
1058
|
+
const state = this.salesTransactionService.state;
|
1059
|
+
if (!state || !request.actions?.length) {
|
1060
|
+
return;
|
1684
1061
|
}
|
1685
|
-
|
1062
|
+
let flowState = state;
|
1063
|
+
request.actions.forEach(action => {
|
1064
|
+
try {
|
1065
|
+
flowState = this.executeActionScript(flowState, action) ?? flowState;
|
1066
|
+
}
|
1067
|
+
catch (e) {
|
1068
|
+
console.error(e);
|
1069
|
+
this.toastService.add({ severity: ToastType.error, summary: String(e) });
|
1070
|
+
throw e;
|
1071
|
+
}
|
1072
|
+
});
|
1073
|
+
this.salesTransactionService.setState(flowState);
|
1686
1074
|
}
|
1687
|
-
|
1688
|
-
|
1689
|
-
|
1690
|
-
return false;
|
1691
|
-
}
|
1692
|
-
if (update.attributeType === 'PRICE_ADJUSTMENT') {
|
1693
|
-
foundChargeGroup.priceAdjustment = update.newValue;
|
1694
|
-
}
|
1695
|
-
else if (update.attributeType === 'LIST_PRICE_ADJUSTMENT') {
|
1696
|
-
foundChargeGroup.listPriceAdjustment = update.newValue;
|
1697
|
-
}
|
1698
|
-
else {
|
1699
|
-
throw new Error(`Not suppored AttributeType for Charge Group Item update: ${update.attributeType}`);
|
1075
|
+
executeStatelessSelectors(request) {
|
1076
|
+
if (!this.salesTransactionService.state) {
|
1077
|
+
throw 'State is not initialized';
|
1700
1078
|
}
|
1701
|
-
|
1702
|
-
|
1703
|
-
|
1704
|
-
|
1705
|
-
|
1706
|
-
|
1707
|
-
|
1708
|
-
|
1709
|
-
|
1710
|
-
|
1711
|
-
|
1712
|
-
|
1713
|
-
|
1714
|
-
|
1715
|
-
|
1716
|
-
|
1717
|
-
|
1718
|
-
this.updatedSubj$ = new Subject();
|
1719
|
-
this.updated$ = this.updatedSubj$.asObservable();
|
1720
|
-
}
|
1721
|
-
calculate$(quoteDraft) {
|
1722
|
-
return this.extendedApply$(quoteDraft).pipe(tap$1(result => {
|
1723
|
-
// sort the result current state based on the quote draft initial state
|
1724
|
-
const initialStateIds = quoteDraft.initialState.map(lineItem => lineItem.integrationId);
|
1725
|
-
result.currentState = result.currentState
|
1726
|
-
.slice()
|
1727
|
-
.sort((a, b) => initialStateIds.indexOf(a.integrationId) - initialStateIds.indexOf(b.integrationId));
|
1728
|
-
this.quoteDraftService.updateQuoteDraft(result);
|
1729
|
-
}), map$1(noop));
|
1730
|
-
}
|
1731
|
-
calculate(quoteDraft) {
|
1732
|
-
this.calculate$(quoteDraft).subscribe();
|
1079
|
+
const flowState = this.salesTransactionService.state;
|
1080
|
+
return EntityUtil.entries(request.selectors ?? {}).reduce((result, [key, selector]) => {
|
1081
|
+
try {
|
1082
|
+
result.selectors[key] = {
|
1083
|
+
success: true,
|
1084
|
+
result: this.executeSelectorScript(flowState, selector),
|
1085
|
+
};
|
1086
|
+
}
|
1087
|
+
catch (e) {
|
1088
|
+
console.error(e);
|
1089
|
+
result.selectors[key] = {
|
1090
|
+
success: false,
|
1091
|
+
errorMessage: String(e),
|
1092
|
+
};
|
1093
|
+
}
|
1094
|
+
return result;
|
1095
|
+
}, { stateId: '', selectors: {} });
|
1733
1096
|
}
|
1734
|
-
|
1735
|
-
const
|
1736
|
-
if (!
|
1737
|
-
|
1097
|
+
initProcessors$() {
|
1098
|
+
const hasOverrides = Boolean(this.customizationService?.getTemplateConfigurationProcessors);
|
1099
|
+
if (this.flowInfoService.flow.properties.stateful && !hasOverrides) {
|
1100
|
+
// Skip initialization as backend will take processors from SF
|
1101
|
+
return of(undefined);
|
1738
1102
|
}
|
1739
|
-
|
1740
|
-
|
1741
|
-
|
1742
|
-
|
1743
|
-
|
1744
|
-
|
1745
|
-
|
1746
|
-
|
1747
|
-
|
1748
|
-
|
1749
|
-
|
1750
|
-
|
1751
|
-
|
1752
|
-
|
1753
|
-
|
1754
|
-
|
1755
|
-
|
1756
|
-
return of(null);
|
1103
|
+
const owners$ = Object.values(this.flowInfoService.templates)
|
1104
|
+
.map(template => {
|
1105
|
+
if (!template) {
|
1106
|
+
return;
|
1107
|
+
}
|
1108
|
+
const localProcessors$ = this.customizationService?.getTemplateConfigurationProcessors?.(template.name) ?? of(null);
|
1109
|
+
return localProcessors$.pipe(switchMap(processors => processors ? of(processors) : this.processorsApiService.fetchConfigurationProcessors$(template.id)), tap(processors => {
|
1110
|
+
const processorsMap = processors.reduce((acc, p) => {
|
1111
|
+
acc[p.apiName] = p;
|
1112
|
+
return acc;
|
1113
|
+
}, {});
|
1114
|
+
this.processors[template.id] = processorsMap;
|
1115
|
+
}));
|
1116
|
+
})
|
1117
|
+
.filter(isDefined);
|
1118
|
+
if (!owners$.length) {
|
1119
|
+
return of(undefined);
|
1757
1120
|
}
|
1758
|
-
|
1759
|
-
updatedState.splice(currentLineItemIndex, 1, initialLineItem);
|
1760
|
-
return of([]).pipe(tap$1(() => {
|
1761
|
-
this.quoteDraftService.setCurrentLineItemState(updatedState);
|
1762
|
-
}), switchMap(() => this.calculate$({ ...quoteDraft, currentState: updatedState })), map$1(() => this.quoteDraftService.quoteDraft), tap$1(() => this.updatedSubj$.next()), this.handleErrorAndBounceBack());
|
1763
|
-
}
|
1764
|
-
revert(lineItemId) {
|
1765
|
-
this.revert$(lineItemId).subscribe();
|
1121
|
+
return forkJoin(owners$).pipe(map(noop));
|
1766
1122
|
}
|
1767
|
-
|
1768
|
-
const
|
1769
|
-
|
1770
|
-
|
1771
|
-
|
1123
|
+
executeActionScript(request, executable) {
|
1124
|
+
const configurationProcessor = this.processors[executable.ownerId]?.[executable.apiName];
|
1125
|
+
if (!configurationProcessor?.script) {
|
1126
|
+
const scope = this.getScopeByOwnerId(executable.ownerId);
|
1127
|
+
const scopeText = scope ? ` in ${scope}` : '';
|
1128
|
+
throw `ConfigurationProcessor ${executable.apiName}${scopeText} not found`;
|
1772
1129
|
}
|
1773
|
-
return
|
1774
|
-
}
|
1775
|
-
delete(ids) {
|
1776
|
-
this.delete$(ids).subscribe();
|
1130
|
+
return this.executeProcessorScript(request, configurationProcessor, executable.inputData);
|
1777
1131
|
}
|
1778
|
-
|
1779
|
-
const
|
1780
|
-
if (!
|
1781
|
-
|
1132
|
+
executeSelectorScript(request, executable) {
|
1133
|
+
const configurationProcessor = this.processors[executable.ownerId]?.[executable.apiName];
|
1134
|
+
if (!configurationProcessor?.script) {
|
1135
|
+
const scope = this.getScopeByOwnerId(executable.ownerId);
|
1136
|
+
const scopeText = scope ? ` in ${scope}` : '';
|
1137
|
+
throw `ConfigurationProcessor ${executable.apiName}${scopeText} not found`;
|
1782
1138
|
}
|
1783
|
-
|
1784
|
-
return of([]).pipe(switchMap(() => this.calculate$({ ...quoteDraft, currentState: updatedState })), map$1(() => this.quoteDraftService.quoteDraft), tap$1(() => this.updatedSubj$.next()), this.handleErrorAndBounceBack());
|
1139
|
+
return this.executeProcessorScript(request, configurationProcessor, executable.inputData);
|
1785
1140
|
}
|
1786
|
-
|
1787
|
-
const
|
1788
|
-
|
1789
|
-
|
1141
|
+
executeProcessorScript(request, configurationProcessor, inputData) {
|
1142
|
+
const scope = this.getScopeByOwnerId(configurationProcessor.ownerId ?? '');
|
1143
|
+
let functionToExecute = this.executedFunctions[scope + configurationProcessor.apiName];
|
1144
|
+
if (!functionToExecute) {
|
1145
|
+
const script = `${configurationProcessor.script}\nreturn transform;`;
|
1146
|
+
const sourceMap = `\n//# sourceURL=${scope ? scope + '/' : ''}${configurationProcessor.apiName}.js`;
|
1147
|
+
functionToExecute = new Function(script + sourceMap)();
|
1148
|
+
this.executedFunctions[scope + configurationProcessor.apiName] = functionToExecute;
|
1790
1149
|
}
|
1791
|
-
return
|
1792
|
-
|
1793
|
-
|
1794
|
-
|
1795
|
-
|
1796
|
-
}), switchMap(updatedState => this.calculate$({ ...quoteDraft, currentState: updatedState })), map$1(() => this.quoteDraftService.quoteDraft), tap$1(() => this.updatedSubj$.next()), this.handleErrorAndBounceBack());
|
1797
|
-
}
|
1798
|
-
get() {
|
1799
|
-
return this.quoteDraftService.quoteDraft$.pipe(map$1(() => this.quoteDraftService.currentState), shareReplay$1());
|
1800
|
-
}
|
1801
|
-
getSnapshot() {
|
1802
|
-
return this.quoteDraftService?.currentState.slice() ?? [];
|
1803
|
-
}
|
1804
|
-
get charges$() {
|
1805
|
-
return this.quoteDraftService.quoteDraft$.pipe(map$1(({ charges }) => charges));
|
1806
|
-
}
|
1807
|
-
get pricePlans$() {
|
1808
|
-
return this.quoteDraftService.quoteDraft$.pipe(map$1(({ pricePlans }) => pricePlans));
|
1809
|
-
}
|
1810
|
-
get activeMetrics$() {
|
1811
|
-
return this.quoteDraftService.quoteDraft$.pipe(map$1(({ activeMetrics }) => activeMetrics));
|
1812
|
-
}
|
1813
|
-
get chargesSnapshot() {
|
1814
|
-
return this.quoteDraftService.quoteDraft?.charges ?? {};
|
1815
|
-
}
|
1816
|
-
get pricePlansSnapshot() {
|
1817
|
-
return this.quoteDraftService.quoteDraft?.pricePlans ?? {};
|
1818
|
-
}
|
1819
|
-
get activeMetricsSnapshot() {
|
1820
|
-
return this.quoteDraftService.quoteDraft?.activeMetrics ?? [];
|
1821
|
-
}
|
1822
|
-
get contextSnapshot() {
|
1823
|
-
return this.contextService.resolve();
|
1824
|
-
}
|
1825
|
-
get context$() {
|
1826
|
-
return this.contextService.resolve$();
|
1150
|
+
return functionToExecute({
|
1151
|
+
request,
|
1152
|
+
inputData,
|
1153
|
+
flowStore: this.flowStore,
|
1154
|
+
});
|
1827
1155
|
}
|
1828
|
-
|
1829
|
-
|
1830
|
-
|
1831
|
-
console.error(error);
|
1832
|
-
// bounce back if configuration call has failed
|
1833
|
-
const quoteDraft = this.quoteDraftService.quoteDraft;
|
1834
|
-
if (quoteDraft) {
|
1835
|
-
this.quoteDraftService.updateQuoteDraft(quoteDraft);
|
1836
|
-
this.updatedSubj$.next();
|
1837
|
-
}
|
1838
|
-
return throwError(() => error);
|
1839
|
-
}));
|
1840
|
-
};
|
1156
|
+
generateRequestId(scope, selectorName, inputData) {
|
1157
|
+
const inputDataHash = UUID.hex(JSON.stringify(inputData) || '').slice(0, 8);
|
1158
|
+
return `${scope}/${selectorName}/${inputDataHash}`;
|
1841
1159
|
}
|
1842
|
-
|
1843
|
-
|
1844
|
-
|
1845
|
-
|
1846
|
-
|
1160
|
+
checkStatefulChanges(requestId, selectorResult) {
|
1161
|
+
if (this.trackedStatefulChangesMap.has(requestId)) {
|
1162
|
+
if (!this.initialStatefulData[requestId]) {
|
1163
|
+
this.initialStatefulData[requestId] = selectorResult;
|
1164
|
+
}
|
1165
|
+
const hasChanges = !isEqual(this.initialStatefulData[requestId], selectorResult);
|
1166
|
+
this.trackedStatefulChangesMap.set(requestId, hasChanges);
|
1847
1167
|
}
|
1848
|
-
return this.proceduresApiService.apply$(request);
|
1849
1168
|
}
|
1850
1169
|
}
|
1851
|
-
|
1852
|
-
|
1853
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type:
|
1170
|
+
FlowStateService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: FlowStateService, deps: [{ token: FlowConfigurationService }, { token: FlowInfoService }, { token: i3.FlowStateApiService }, { token: i1.ConfigurationProcessorsApiService }, { token: i1.SalesTransactionApiService }, { token: SalesTransactionService }, { token: i6.ToastService }, { token: FLOW_CUSTOMIZATION, optional: true }], target: i0.ɵɵFactoryTarget.Injectable });
|
1171
|
+
FlowStateService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: FlowStateService });
|
1172
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: FlowStateService, decorators: [{
|
1854
1173
|
type: Injectable
|
1855
|
-
}], ctorParameters: function () { return [{ type:
|
1856
|
-
|
1857
|
-
|
1858
|
-
|
1859
|
-
|
1860
|
-
|
1861
|
-
FlowConfigurationModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: FlowConfigurationModule, providers: [FlowConfigurationService, FlowUpdateService], imports: [ApiModule] });
|
1862
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: FlowConfigurationModule, decorators: [{
|
1863
|
-
type: NgModule,
|
1864
|
-
args: [{
|
1865
|
-
imports: [ApiModule],
|
1866
|
-
providers: [FlowConfigurationService, FlowUpdateService],
|
1867
|
-
}]
|
1868
|
-
}] });
|
1174
|
+
}], ctorParameters: function () { return [{ type: FlowConfigurationService }, { type: FlowInfoService }, { type: i3.FlowStateApiService }, { type: i1.ConfigurationProcessorsApiService }, { type: i1.SalesTransactionApiService }, { type: SalesTransactionService }, { type: i6.ToastService }, { type: undefined, decorators: [{
|
1175
|
+
type: Optional
|
1176
|
+
}, {
|
1177
|
+
type: Inject,
|
1178
|
+
args: [FLOW_CUSTOMIZATION]
|
1179
|
+
}] }]; } });
|
1869
1180
|
|
1870
1181
|
class FlowStateConfigurationService {
|
1871
|
-
constructor(flowInfoService,
|
1182
|
+
constructor(flowInfoService, flowStateService, configurationService, salesTransactionService, flowConfigurationService) {
|
1872
1183
|
this.flowInfoService = flowInfoService;
|
1873
|
-
this.flowConfigurationService = flowConfigurationService;
|
1874
|
-
this.flowStateApiService = flowStateApiService;
|
1875
1184
|
this.flowStateService = flowStateService;
|
1876
|
-
this.
|
1877
|
-
|
1878
|
-
|
1879
|
-
return this.configurationStateId$.value;
|
1185
|
+
this.configurationService = configurationService;
|
1186
|
+
this.salesTransactionService = salesTransactionService;
|
1187
|
+
this.flowConfigurationService = flowConfigurationService;
|
1880
1188
|
}
|
1881
1189
|
addToCart$(props) {
|
1882
1190
|
let request$;
|
@@ -1887,26 +1195,57 @@ class FlowStateConfigurationService {
|
|
1887
1195
|
request$ = of();
|
1888
1196
|
}
|
1889
1197
|
else {
|
1890
|
-
|
1891
|
-
request$ =
|
1892
|
-
if (!this.configurationStateId) {
|
1893
|
-
return of();
|
1894
|
-
}
|
1895
|
-
return this.flowStateApiService.saveConfiguration(stateId, this.configurationStateId).pipe(tap$1(() => this.configurationStateId$.next(null)), map$1(noop));
|
1896
|
-
}));
|
1198
|
+
// TODO: Implement
|
1199
|
+
request$ = of();
|
1897
1200
|
}
|
1898
1201
|
}
|
1899
1202
|
else {
|
1900
|
-
request$ = this.
|
1203
|
+
request$ = this.configureExternal$(props);
|
1901
1204
|
}
|
1902
|
-
return request$.pipe(switchMap(() => this.flowStateService.executeRequest$({}, true)), map
|
1205
|
+
return request$.pipe(switchMap(() => this.flowStateService.executeRequest$({}, true)), map(noop));
|
1206
|
+
}
|
1207
|
+
configureExternal$(props) {
|
1208
|
+
const { state } = this.salesTransactionService;
|
1209
|
+
if (!state) {
|
1210
|
+
return of();
|
1211
|
+
}
|
1212
|
+
const stateToConfigure = {
|
1213
|
+
...state,
|
1214
|
+
salesTransaction: {
|
1215
|
+
...state.salesTransaction,
|
1216
|
+
salesTransactionItems: [
|
1217
|
+
{
|
1218
|
+
...generateTransactionItem(props.productId),
|
1219
|
+
qty: props.qty ?? 1,
|
1220
|
+
stiAttributes: Object.entries(props.attributesMap ?? {}).map(([attributeName, value]) => ({
|
1221
|
+
attributeName,
|
1222
|
+
value,
|
1223
|
+
})),
|
1224
|
+
},
|
1225
|
+
],
|
1226
|
+
},
|
1227
|
+
};
|
1228
|
+
return this.configurationService.justConfigureRequest$(stateToConfigure).pipe(switchMap(configurationResult => {
|
1229
|
+
const state = this.salesTransactionService.state;
|
1230
|
+
const addedProduct = configurationResult.salesTransaction.salesTransactionItems[0];
|
1231
|
+
if (!state || !addedProduct) {
|
1232
|
+
return of();
|
1233
|
+
}
|
1234
|
+
return this.flowConfigurationService.calculate$({
|
1235
|
+
...state,
|
1236
|
+
salesTransaction: {
|
1237
|
+
...state.salesTransaction,
|
1238
|
+
salesTransactionItems: [...state.salesTransaction.salesTransactionItems, addedProduct],
|
1239
|
+
},
|
1240
|
+
});
|
1241
|
+
}));
|
1903
1242
|
}
|
1904
1243
|
}
|
1905
|
-
FlowStateConfigurationService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: FlowStateConfigurationService, deps: [{ token: FlowInfoService }, { token:
|
1244
|
+
FlowStateConfigurationService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: FlowStateConfigurationService, deps: [{ token: FlowInfoService }, { token: FlowStateService }, { token: ConfigurationService }, { token: SalesTransactionService }, { token: FlowConfigurationService }], target: i0.ɵɵFactoryTarget.Injectable });
|
1906
1245
|
FlowStateConfigurationService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: FlowStateConfigurationService });
|
1907
1246
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: FlowStateConfigurationService, decorators: [{
|
1908
1247
|
type: Injectable
|
1909
|
-
}], ctorParameters: function () { return [{ type: FlowInfoService }, { type:
|
1248
|
+
}], ctorParameters: function () { return [{ type: FlowInfoService }, { type: FlowStateService }, { type: ConfigurationService }, { type: SalesTransactionService }, { type: FlowConfigurationService }]; } });
|
1910
1249
|
|
1911
1250
|
class IntegrationState {
|
1912
1251
|
constructor() {
|
@@ -1926,12 +1265,12 @@ class IntegrationState {
|
|
1926
1265
|
this.action$.next(action);
|
1927
1266
|
}
|
1928
1267
|
listen$(actionType) {
|
1929
|
-
return this.action$.pipe(filter
|
1268
|
+
return this.action$.pipe(filter(action => action.type === actionType), map(action => action.payload));
|
1930
1269
|
}
|
1931
1270
|
listenAll$() {
|
1932
1271
|
return this.action$.asObservable();
|
1933
1272
|
}
|
1934
|
-
|
1273
|
+
reset() {
|
1935
1274
|
this.stateSubj$.next({});
|
1936
1275
|
}
|
1937
1276
|
}
|
@@ -1942,8 +1281,8 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImpor
|
|
1942
1281
|
}] });
|
1943
1282
|
|
1944
1283
|
class ProductImagesService {
|
1945
|
-
constructor(
|
1946
|
-
this.
|
1284
|
+
constructor(productsAdminApiService) {
|
1285
|
+
this.productsAdminApiService = productsAdminApiService;
|
1947
1286
|
this.imagesMap$ = new BehaviorSubject({});
|
1948
1287
|
}
|
1949
1288
|
getImageUrl$(productId) {
|
@@ -1951,172 +1290,53 @@ class ProductImagesService {
|
|
1951
1290
|
this.imagesMap$.next({ ...this.imagesMap$.value, [productId]: '' });
|
1952
1291
|
this.fetchProductImage(productId);
|
1953
1292
|
}
|
1954
|
-
return this.imagesMap$.pipe(map
|
1293
|
+
return this.imagesMap$.pipe(map(imagesMap => imagesMap[productId] ?? null), distinctUntilChanged());
|
1955
1294
|
}
|
1956
1295
|
fetchProductImage(productId) {
|
1957
|
-
this.
|
1296
|
+
this.productsAdminApiService
|
1958
1297
|
.fetchImage$(productId)
|
1959
|
-
.pipe(map
|
1298
|
+
.pipe(map(file => URL.createObjectURL(file)), catchError$1(() => of('')), tap(url => this.imagesMap$.next({ ...this.imagesMap$.value, [productId]: url })))
|
1960
1299
|
.subscribe();
|
1961
1300
|
}
|
1962
1301
|
}
|
1963
|
-
ProductImagesService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: ProductImagesService, deps: [{ token: i1.
|
1302
|
+
ProductImagesService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: ProductImagesService, deps: [{ token: i1.ProductsAdminApiService }], target: i0.ɵɵFactoryTarget.Injectable });
|
1964
1303
|
ProductImagesService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: ProductImagesService });
|
1965
1304
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: ProductImagesService, decorators: [{
|
1966
1305
|
type: Injectable
|
1967
|
-
}], ctorParameters: function () { return [{ type: i1.
|
1306
|
+
}], ctorParameters: function () { return [{ type: i1.ProductsAdminApiService }]; } });
|
1968
1307
|
|
1969
|
-
class
|
1970
|
-
constructor(
|
1971
|
-
this.
|
1972
|
-
|
1973
|
-
getRuntimeContext(productId, offeringId, defaultUIDefinitionId, requiredUIDefinitionId) {
|
1974
|
-
return this.configurationApiService
|
1975
|
-
.getRuntimeDataByProductId(productId, offeringId, defaultUIDefinitionId, requiredUIDefinitionId)
|
1976
|
-
.pipe(map(runtimeData => {
|
1977
|
-
const uiDefinitionContainer = this.getUIDefinitionContainer(runtimeData);
|
1978
|
-
const runtimeModel = RuntimeModel.create(runtimeData.types, runtimeData.products);
|
1979
|
-
const { productName, properties } = Array.from(runtimeModel.components.values()).find(c => c.productId === productId) ?? {};
|
1980
|
-
const uiDefinitionProperties = uiDefinitionContainer?.source.properties;
|
1981
|
-
return {
|
1982
|
-
modelId: runtimeData.modelId,
|
1983
|
-
uiDefinitionContainer: uiDefinitionContainer,
|
1984
|
-
runtimeModel: runtimeModel,
|
1985
|
-
runtimeMode: RuntimeMode.PROD,
|
1986
|
-
productId: productId,
|
1987
|
-
productType: properties?.['displayName'] || productName,
|
1988
|
-
offeringId: offeringId,
|
1989
|
-
properties: {
|
1990
|
-
PricingEnabled: uiDefinitionProperties?.pricingEnabled ? 'true' : 'false',
|
1991
|
-
PriceListId: uiDefinitionProperties?.priceList,
|
1992
|
-
},
|
1993
|
-
};
|
1994
|
-
}));
|
1995
|
-
}
|
1996
|
-
getUIDefinitionContainer(runtimeData) {
|
1997
|
-
const containers = runtimeData.uiDefinitions.filter(container => isNotLegacyUIDefinition(container.source));
|
1998
|
-
return containers.find(container => container.source.primary) ?? containers[0];
|
1308
|
+
class CatalogProductsService {
|
1309
|
+
constructor() {
|
1310
|
+
this.stateSubj$ = new BehaviorSubject(null);
|
1311
|
+
this.state$ = this.stateSubj$.asObservable().pipe(filter(isDefined));
|
1999
1312
|
}
|
2000
|
-
|
2001
|
-
|
2002
|
-
RuntimeContextService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: RuntimeContextService });
|
2003
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: RuntimeContextService, decorators: [{
|
2004
|
-
type: Injectable
|
2005
|
-
}], ctorParameters: function () { return [{ type: i1.ConfigurationApiService }]; } });
|
2006
|
-
|
2007
|
-
class ConfigurationRuntimeService {
|
2008
|
-
constructor(apiService, contextService, runtimeContextService) {
|
2009
|
-
this.apiService = apiService;
|
2010
|
-
this.contextService = contextService;
|
2011
|
-
this.runtimeContextService = runtimeContextService;
|
2012
|
-
this._isInitialized = false;
|
2013
|
-
this.uiDefinitionProperties = {};
|
1313
|
+
get state() {
|
1314
|
+
return this.stateSubj$.getValue();
|
2014
1315
|
}
|
2015
1316
|
reset() {
|
2016
|
-
this.
|
2017
|
-
this._runtimeContext = undefined;
|
2018
|
-
this.initializationProps = undefined;
|
2019
|
-
this.uiDefinitionProperties = {};
|
2020
|
-
}
|
2021
|
-
initTestMode(uiDefinitionContainer) {
|
2022
|
-
this.uiDefinitionProperties = uiDefinitionContainer.source.properties ?? {};
|
2023
|
-
const uiDefinitionExternals = uiDefinitionContainer.source.externals ?? {};
|
2024
|
-
return combineLatest([
|
2025
|
-
this.apiService.getRuntimeDataByModelId(uiDefinitionContainer.modelId),
|
2026
|
-
this.contextService.initTestMode(),
|
2027
|
-
]).pipe(first(), map(([runtimeData, context]) => {
|
2028
|
-
this.contextService.update({
|
2029
|
-
properties: {
|
2030
|
-
...this.runtimeContext?.properties,
|
2031
|
-
...context.properties,
|
2032
|
-
ModelId: uiDefinitionContainer.modelId,
|
2033
|
-
PricingEnabled: this.uiDefinitionProperties.pricingEnabled ? 'true' : 'false',
|
2034
|
-
PriceListId: this.uiDefinitionProperties.priceList,
|
2035
|
-
offeringId: this.uiDefinitionProperties.offeringId,
|
2036
|
-
...uiDefinitionExternals,
|
2037
|
-
},
|
2038
|
-
});
|
2039
|
-
this._runtimeContext = {
|
2040
|
-
modelId: uiDefinitionContainer.modelId,
|
2041
|
-
runtimeModel: RuntimeModel.create(runtimeData.types, runtimeData.products),
|
2042
|
-
runtimeMode: RuntimeMode.TEST,
|
2043
|
-
uiDefinitionContainer,
|
2044
|
-
};
|
2045
|
-
return this._runtimeContext;
|
2046
|
-
}), tap(() => (this._isInitialized = true)));
|
2047
|
-
}
|
2048
|
-
init(props) {
|
2049
|
-
this.initializationProps = props;
|
2050
|
-
const context = this.contextService.resolve();
|
2051
|
-
return this.runtimeContextService
|
2052
|
-
.getRuntimeContext(props.productId, props.offeringId, props.defaultUIDefinitionId, props.requiredUIDefinitionId)
|
2053
|
-
.pipe(tap(runtimeContext => {
|
2054
|
-
this.uiDefinitionProperties = runtimeContext.uiDefinitionContainer?.source.properties ?? {};
|
2055
|
-
const { PriceListId } = context.properties ?? {};
|
2056
|
-
const mergeContext = {
|
2057
|
-
...runtimeContext,
|
2058
|
-
properties: {
|
2059
|
-
...runtimeContext.properties,
|
2060
|
-
...context.properties,
|
2061
|
-
PricingEnabled: PriceListId ? 'true' : 'false',
|
2062
|
-
},
|
2063
|
-
};
|
2064
|
-
this.id15to18('AccountId', mergeContext.properties);
|
2065
|
-
this._runtimeContext = mergeContext;
|
2066
|
-
if (context.properties && this._runtimeContext.properties?.StartDate) {
|
2067
|
-
this.contextService.update({
|
2068
|
-
properties: {
|
2069
|
-
...this._runtimeContext.properties,
|
2070
|
-
...context.properties,
|
2071
|
-
},
|
2072
|
-
});
|
2073
|
-
}
|
2074
|
-
return this._runtimeContext;
|
2075
|
-
}), tap(() => (this._isInitialized = true)));
|
2076
|
-
}
|
2077
|
-
overrideUIDefinition(uiDefinitionContainer) {
|
2078
|
-
if (!this._runtimeContext) {
|
2079
|
-
return;
|
2080
|
-
}
|
2081
|
-
this._runtimeContext.uiDefinitionContainer = uiDefinitionContainer;
|
2082
|
-
this.uiDefinitionProperties = uiDefinitionContainer.source.properties ?? {};
|
2083
|
-
}
|
2084
|
-
id15to18(propertyName, source) {
|
2085
|
-
if (!source) {
|
2086
|
-
return;
|
2087
|
-
}
|
2088
|
-
const value = source[propertyName];
|
2089
|
-
if (typeof value === 'string' && value.length === 15) {
|
2090
|
-
source[propertyName] = SalesforceIdUtils.generateId18FromId15(value);
|
2091
|
-
}
|
2092
|
-
}
|
2093
|
-
get isInitialized() {
|
2094
|
-
return this._isInitialized;
|
2095
|
-
}
|
2096
|
-
get runtimeModel() {
|
2097
|
-
return this.runtimeContext?.runtimeModel;
|
1317
|
+
this.stateSubj$.next(null);
|
2098
1318
|
}
|
2099
|
-
|
2100
|
-
|
1319
|
+
setState(state) {
|
1320
|
+
this.stateSubj$.next(state);
|
2101
1321
|
}
|
2102
1322
|
}
|
2103
|
-
|
2104
|
-
|
2105
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type:
|
1323
|
+
CatalogProductsService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: CatalogProductsService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
|
1324
|
+
CatalogProductsService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: CatalogProductsService });
|
1325
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: CatalogProductsService, decorators: [{
|
2106
1326
|
type: Injectable
|
2107
|
-
}]
|
1327
|
+
}] });
|
2108
1328
|
|
2109
1329
|
class ConfigurationStateService {
|
2110
|
-
constructor(configurationRuntimeService, configurationService,
|
1330
|
+
constructor(configurationRuntimeService, configurationService, flowStateService, flowInfoService, flowConfigurationService, flowStateApiService, salesTransactionService, salesTransactionApiService, toastService) {
|
2111
1331
|
this.configurationRuntimeService = configurationRuntimeService;
|
2112
1332
|
this.configurationService = configurationService;
|
2113
|
-
this.quoteDraftService = quoteDraftService;
|
2114
|
-
this.toastService = toastService;
|
2115
1333
|
this.flowStateService = flowStateService;
|
2116
1334
|
this.flowInfoService = flowInfoService;
|
2117
1335
|
this.flowConfigurationService = flowConfigurationService;
|
2118
1336
|
this.flowStateApiService = flowStateApiService;
|
2119
|
-
this.
|
1337
|
+
this.salesTransactionService = salesTransactionService;
|
1338
|
+
this.salesTransactionApiService = salesTransactionApiService;
|
1339
|
+
this.toastService = toastService;
|
2120
1340
|
this.isInitialized$ = new BehaviorSubject(false);
|
2121
1341
|
this.canceledConfiguration$ = new Subject();
|
2122
1342
|
this.NOT_INITIALIZED = Symbol();
|
@@ -2140,9 +1360,9 @@ class ConfigurationStateService {
|
|
2140
1360
|
request$ = this.initStateful$();
|
2141
1361
|
}
|
2142
1362
|
else {
|
2143
|
-
request$ = this.
|
1363
|
+
request$ = this.configurationService.init$();
|
2144
1364
|
}
|
2145
|
-
return request$.pipe(
|
1365
|
+
return request$.pipe(take(1), tap(() => {
|
2146
1366
|
this.isInitialized$.next(true);
|
2147
1367
|
this.canceledConfiguration$ = new Subject();
|
2148
1368
|
}));
|
@@ -2156,10 +1376,11 @@ class ConfigurationStateService {
|
|
2156
1376
|
this.configurationStore = {};
|
2157
1377
|
this.executedFunctions = {};
|
2158
1378
|
this.configurationService.reset();
|
1379
|
+
this.configurationRuntimeService.reset();
|
2159
1380
|
}
|
2160
1381
|
execute$(exec) {
|
2161
1382
|
const request = this.execToRequest(exec);
|
2162
|
-
return this.executeRequest$(request).pipe(map
|
1383
|
+
return this.executeRequest$(request).pipe(map(result => {
|
2163
1384
|
// Keep only requested results
|
2164
1385
|
const actualSelectors = Object.entries(result.selectors).reduce((trunk, [requestId, result]) => {
|
2165
1386
|
if (exec.selectors?.[requestId]) {
|
@@ -2181,7 +1402,7 @@ class ConfigurationStateService {
|
|
2181
1402
|
}
|
2182
1403
|
// prevent parallel configuration requests in stateless mode
|
2183
1404
|
if (!this.statelessExecutionRequest$) {
|
2184
|
-
this.statelessExecutionRequest$ = executionRequest$.pipe(shareReplay
|
1405
|
+
this.statelessExecutionRequest$ = executionRequest$.pipe(shareReplay(), take(1), finalize$1(() => (this.statelessExecutionRequest$ = null)));
|
2185
1406
|
}
|
2186
1407
|
return this.statelessExecutionRequest$;
|
2187
1408
|
}
|
@@ -2195,7 +1416,7 @@ class ConfigurationStateService {
|
|
2195
1416
|
},
|
2196
1417
|
},
|
2197
1418
|
});
|
2198
|
-
return this.executeRequest$(request).pipe(map
|
1419
|
+
return this.executeRequest$(request).pipe(map(response => response.selectors[requestId]));
|
2199
1420
|
}
|
2200
1421
|
subscribe$(selectorName, inputData = {}, options) {
|
2201
1422
|
const requestId = UUID.UUID();
|
@@ -2218,56 +1439,50 @@ class ConfigurationStateService {
|
|
2218
1439
|
this.executeRequest$(request).subscribe();
|
2219
1440
|
}
|
2220
1441
|
}
|
2221
|
-
return subscription.data$.pipe(filter
|
1442
|
+
return subscription.data$.pipe(filter(data => data != this.NOT_INITIALIZED), map(data => data), distinctUntilChanged(), finalize$1(() => {
|
2222
1443
|
if (!this.subscriptions[requestId]?.data$.observed) {
|
2223
1444
|
delete this.subscriptions[requestId];
|
2224
1445
|
}
|
2225
1446
|
}), takeUntil(this.canceledConfiguration$));
|
2226
1447
|
}
|
2227
|
-
saveConfiguration(
|
1448
|
+
saveConfiguration() {
|
2228
1449
|
if (this.isStatefulConfiguration) {
|
2229
|
-
return this.flowStateApiService
|
2230
|
-
|
2231
|
-
|
1450
|
+
return this.flowStateApiService.saveConfiguration(this.flowStateService.stateId ?? '', this.stateId ?? '').pipe(switchMap(r => this.flowStateService.executeRequest$({}, true).pipe(map(() => r))), map(r => ({ id: r.quoteId })));
|
1451
|
+
}
|
1452
|
+
const state = this.salesTransactionService.state;
|
1453
|
+
if (!state) {
|
1454
|
+
return of({ id: '' });
|
1455
|
+
}
|
1456
|
+
const { standalone } = this.flowInfoService.flow.properties;
|
1457
|
+
if (standalone) {
|
1458
|
+
const request = {
|
1459
|
+
transactionContext: state,
|
1460
|
+
flowId: this.flowInfoService.flow.id,
|
1461
|
+
};
|
1462
|
+
return this.salesTransactionApiService.save(request).pipe(switchMap(r => this.flowStateService.executeRequest$({}, true).pipe(map(() => r))), map(id => ({ id })));
|
1463
|
+
}
|
1464
|
+
const transactionContext = this.salesTransactionService.state;
|
1465
|
+
const configurationRoot = this.configurationService.root;
|
1466
|
+
if (!transactionContext || !configurationRoot) {
|
1467
|
+
return of({ id: '' });
|
1468
|
+
}
|
1469
|
+
const stateItems = transactionContext.salesTransaction.salesTransactionItems;
|
1470
|
+
const isNewTransactionItem = stateItems.every(ti => ti.id !== configurationRoot.id);
|
1471
|
+
let salesTransactionItems;
|
1472
|
+
if (isNewTransactionItem) {
|
1473
|
+
salesTransactionItems = [...stateItems, configurationRoot];
|
2232
1474
|
}
|
2233
1475
|
else {
|
2234
|
-
|
2235
|
-
const quoteDraft = this.quoteDraftService.quoteDraft;
|
2236
|
-
if (!quoteDraft) {
|
2237
|
-
return of({ quoteId: '' });
|
2238
|
-
}
|
2239
|
-
const rootLineItem = this.configurationService.getSnapshot();
|
2240
|
-
const asset = this.configurationService.getAsset();
|
2241
|
-
const currentState = rootLineItem ? [rootLineItem] : [];
|
2242
|
-
const initialState = asset ? [asset] : [];
|
2243
|
-
return this.quoteApiService.upsertQuote({ ...quoteDraft, currentState, initialState });
|
2244
|
-
}
|
2245
|
-
else {
|
2246
|
-
const quoteDraft = this.quoteDraftService.quoteDraft;
|
2247
|
-
const lineItem = this.configurationService.getSnapshot();
|
2248
|
-
if (!quoteDraft || !lineItem) {
|
2249
|
-
return of({ quoteId: '' });
|
2250
|
-
}
|
2251
|
-
const isNewLineItem = quoteDraft.currentState.every(li => li.id !== lineItem.id);
|
2252
|
-
let currentState;
|
2253
|
-
if (isNewLineItem) {
|
2254
|
-
currentState = [...quoteDraft.currentState, lineItem];
|
2255
|
-
}
|
2256
|
-
else {
|
2257
|
-
currentState = quoteDraft.currentState.map(li => (li.id === lineItem.id ? lineItem : li));
|
2258
|
-
}
|
2259
|
-
const asset = this.configurationService.getAsset();
|
2260
|
-
const initialState = [...(this.quoteDraftService.quoteDraft?.initialState ?? [])];
|
2261
|
-
if (asset) {
|
2262
|
-
if (!initialState.some(li => li.id === asset.id)) {
|
2263
|
-
initialState.push(asset);
|
2264
|
-
}
|
2265
|
-
}
|
2266
|
-
return this.flowConfigurationService
|
2267
|
-
.calculate$({ ...quoteDraft, currentState, initialState })
|
2268
|
-
.pipe(map$1(() => ({ quoteId: '' })));
|
2269
|
-
}
|
1476
|
+
salesTransactionItems = stateItems.map(ti => (ti.id === configurationRoot.id ? configurationRoot : ti));
|
2270
1477
|
}
|
1478
|
+
const newState = {
|
1479
|
+
...transactionContext,
|
1480
|
+
salesTransaction: {
|
1481
|
+
...transactionContext.salesTransaction,
|
1482
|
+
salesTransactionItems,
|
1483
|
+
},
|
1484
|
+
};
|
1485
|
+
return this.flowConfigurationService.calculate$(newState).pipe(switchMap(() => this.flowStateService.executeRequest$({}, true)), map(() => ({ id: '' })));
|
2271
1486
|
}
|
2272
1487
|
cancelConfiguration() {
|
2273
1488
|
if (!this.isInitialized$.value) {
|
@@ -2286,36 +1501,32 @@ class ConfigurationStateService {
|
|
2286
1501
|
return this.flowInfoService.flow?.properties.stateful ?? false;
|
2287
1502
|
}
|
2288
1503
|
initStateful$() {
|
2289
|
-
this.ownerId = this.configurationRuntimeService.
|
2290
|
-
const
|
2291
|
-
if (!this.flowStateService.stateId) {
|
1504
|
+
this.ownerId = this.configurationRuntimeService.uiDefinitionContainer?.id ?? '';
|
1505
|
+
const { productId, transactionItemId } = this.flowInfoService.context;
|
1506
|
+
if (!productId || !this.flowStateService.stateId) {
|
2292
1507
|
return of(undefined);
|
2293
1508
|
}
|
2294
|
-
const container = this.configurationRuntimeService.
|
2295
|
-
const lineItem = this.configurationService.generateLineItem();
|
1509
|
+
const container = this.configurationRuntimeService.uiDefinitionContainer;
|
2296
1510
|
let request$;
|
2297
|
-
if (!
|
1511
|
+
if (!transactionItemId) {
|
2298
1512
|
request$ = this.flowStateApiService.newConfiguration(this.flowStateService.stateId, {
|
2299
|
-
|
1513
|
+
transactionItem: generateTransactionItem(productId),
|
2300
1514
|
actionsOverride: container?.actions?.map(processor => ({ ...processor, ownerId: this.ownerId })),
|
2301
1515
|
selectorsOverride: container?.selectors?.map(processor => ({ ...processor, ownerId: this.ownerId })),
|
2302
1516
|
});
|
2303
1517
|
}
|
2304
1518
|
else {
|
2305
1519
|
request$ = this.flowStateApiService.startConfiguration(this.flowStateService.stateId, {
|
2306
|
-
|
1520
|
+
transactionItemId,
|
2307
1521
|
actionsOverride: container?.actions?.map(processor => ({ ...processor, ownerId: this.ownerId })),
|
2308
1522
|
selectorsOverride: container?.selectors?.map(processor => ({ ...processor, ownerId: this.ownerId })),
|
2309
1523
|
});
|
2310
1524
|
}
|
2311
|
-
return request$.pipe(map
|
1525
|
+
return request$.pipe(map(r => {
|
2312
1526
|
this.stateId = r.stateId;
|
2313
1527
|
return undefined;
|
2314
1528
|
}));
|
2315
1529
|
}
|
2316
|
-
initStateless$() {
|
2317
|
-
return this.configurationService.configure().pipe(map$1(() => undefined));
|
2318
|
-
}
|
2319
1530
|
execToRequest(exec) {
|
2320
1531
|
return {
|
2321
1532
|
actions: exec.actions?.map(action => ({
|
@@ -2355,37 +1566,35 @@ class ConfigurationStateService {
|
|
2355
1566
|
else {
|
2356
1567
|
execution$ = this.executeStateless$(fullRequest);
|
2357
1568
|
}
|
2358
|
-
return execution$.pipe(tap
|
1569
|
+
return execution$.pipe(tap(result => this.handleSelectorsResponse(result.selectors)));
|
2359
1570
|
}
|
2360
1571
|
executeStateless$(request) {
|
2361
1572
|
this.executionInProgress$.next(true);
|
2362
|
-
return
|
1573
|
+
return this.configurationService.state$.pipe(first(), switchMap(state => {
|
2363
1574
|
// Apply actions and execute configuration/price call
|
2364
1575
|
// No need to run configuration if no actions in the request
|
2365
1576
|
if (!request.actions?.length) {
|
2366
1577
|
return of(undefined);
|
2367
1578
|
}
|
2368
|
-
let configurationRequest = this.configurationService.generateRequest(false);
|
2369
1579
|
request.actions.forEach(action => {
|
2370
|
-
|
1580
|
+
state = this.executeActionScript(state, action) ?? state;
|
2371
1581
|
});
|
2372
|
-
|
2373
|
-
|
2374
|
-
}), map$1(() => {
|
1582
|
+
return this.configurationService.configure$(state);
|
1583
|
+
}), map(() => {
|
2375
1584
|
// Run selectors and apply them to the state
|
2376
|
-
const configurationState = this.configurationService.
|
1585
|
+
const configurationState = this.configurationService.state;
|
2377
1586
|
if (!configurationState) {
|
2378
1587
|
return { stateId: '', selectors: {} };
|
2379
1588
|
}
|
2380
1589
|
return this.runStatelessSelectors(request, configurationState);
|
2381
|
-
}), tap
|
2382
|
-
const configurationState = this.configurationService.
|
1590
|
+
}), tap(() => this.executionInProgress$.next(false)), catchError$1(error => {
|
1591
|
+
const configurationState = this.configurationService.previousState;
|
2383
1592
|
if (configurationState) {
|
2384
1593
|
const selectorsResult = this.runStatelessSelectors(request, configurationState);
|
2385
1594
|
this.handleSelectorsResponse(selectorsResult.selectors);
|
2386
1595
|
}
|
2387
1596
|
this.executionInProgress$.next(false);
|
2388
|
-
if (!this.configurationRuntimeService.
|
1597
|
+
if (!this.configurationRuntimeService.uiDefinitionProps.suppressToastMessages) {
|
2389
1598
|
this.toastService.add({ severity: ToastType.error, summary: String(error) });
|
2390
1599
|
}
|
2391
1600
|
return throwError(() => error);
|
@@ -2406,21 +1615,21 @@ class ConfigurationStateService {
|
|
2406
1615
|
};
|
2407
1616
|
this.executionInProgress$.next(true);
|
2408
1617
|
return this.flowStateApiService.executeConfiguration(this.flowStateService.stateId, this.stateId, request);
|
2409
|
-
}), tap
|
1618
|
+
}), tap(({ stateId }) => (this.stateId = stateId)), share(), tap(() => this.executionInProgress$.next(false)), catchError$1(e => {
|
2410
1619
|
this.executionInProgress$.next(false);
|
2411
1620
|
return throwError(() => e);
|
2412
1621
|
}));
|
2413
1622
|
}
|
2414
1623
|
executeStateful$(request) {
|
2415
|
-
return this.executionInProgress$.pipe(filter
|
1624
|
+
return this.executionInProgress$.pipe(filter(inProgress => !inProgress), take(1), switchMap(() =>
|
2416
1625
|
// make sure stream switches to statefulExecutionRequest$ before pushing an execution request
|
2417
1626
|
combineLatest([
|
2418
1627
|
this.statefulExecutionRequest$,
|
2419
|
-
of(undefined).pipe(tap
|
2420
|
-
])), map
|
1628
|
+
of(undefined).pipe(tap(() => this.statefulRequestStream$.next(request))),
|
1629
|
+
])), map(([response]) => response), take(1));
|
2421
1630
|
}
|
2422
1631
|
executeActionScript(request, processor) {
|
2423
|
-
const { actions } = this.configurationRuntimeService.
|
1632
|
+
const { actions } = this.configurationRuntimeService.uiDefinitionContainer ?? {};
|
2424
1633
|
const configurationProcessor = actions?.find(action => action.apiName === processor.apiName);
|
2425
1634
|
if (!configurationProcessor?.script) {
|
2426
1635
|
throw `ConfigurationProcessor ${processor.apiName} not found`;
|
@@ -2428,7 +1637,7 @@ class ConfigurationStateService {
|
|
2428
1637
|
return this.executeProcessorScript(request, configurationProcessor, processor.inputData);
|
2429
1638
|
}
|
2430
1639
|
executeSelectorScript(request, processor) {
|
2431
|
-
const { selectors } = this.configurationRuntimeService.
|
1640
|
+
const { selectors } = this.configurationRuntimeService.uiDefinitionContainer ?? {};
|
2432
1641
|
const configurationProcessor = selectors?.find(selector => selector.apiName === processor.apiName);
|
2433
1642
|
if (!configurationProcessor?.script) {
|
2434
1643
|
throw `ConfigurationProcessor ${processor.apiName} not found`;
|
@@ -2469,25 +1678,54 @@ class ConfigurationStateService {
|
|
2469
1678
|
}, { stateId: '', selectors: {} });
|
2470
1679
|
}
|
2471
1680
|
}
|
2472
|
-
ConfigurationStateService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: ConfigurationStateService, deps: [{ token: ConfigurationRuntimeService }, { token: ConfigurationService }, { token:
|
1681
|
+
ConfigurationStateService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: ConfigurationStateService, deps: [{ token: ConfigurationRuntimeService }, { token: ConfigurationService }, { token: FlowStateService }, { token: FlowInfoService }, { token: FlowConfigurationService }, { token: i3.FlowStateApiService }, { token: SalesTransactionService }, { token: i1.SalesTransactionApiService }, { token: i6.ToastService }], target: i0.ɵɵFactoryTarget.Injectable });
|
2473
1682
|
ConfigurationStateService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: ConfigurationStateService });
|
2474
1683
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: ConfigurationStateService, decorators: [{
|
2475
1684
|
type: Injectable
|
2476
|
-
}], ctorParameters: function () { return [{ type: ConfigurationRuntimeService }, { type: ConfigurationService }, { type:
|
1685
|
+
}], ctorParameters: function () { return [{ type: ConfigurationRuntimeService }, { type: ConfigurationService }, { type: FlowStateService }, { type: FlowInfoService }, { type: FlowConfigurationService }, { type: i3.FlowStateApiService }, { type: SalesTransactionService }, { type: i1.SalesTransactionApiService }, { type: i6.ToastService }]; } });
|
2477
1686
|
|
2478
1687
|
class ConfigurationModule {
|
2479
1688
|
}
|
2480
1689
|
ConfigurationModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: ConfigurationModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
|
2481
1690
|
ConfigurationModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "15.2.9", ngImport: i0, type: ConfigurationModule, imports: [ConfirmationDialogModule, ApiModule] });
|
2482
|
-
ConfigurationModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: ConfigurationModule, providers: [
|
1691
|
+
ConfigurationModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: ConfigurationModule, providers: [
|
1692
|
+
ConfigurationService,
|
1693
|
+
ConfigurationStateService,
|
1694
|
+
ConfigurationRuntimeService,
|
1695
|
+
TestModeConfigurationService,
|
1696
|
+
GuidedSellingService,
|
1697
|
+
], imports: [ConfirmationDialogModule, ApiModule] });
|
2483
1698
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: ConfigurationModule, decorators: [{
|
2484
1699
|
type: NgModule,
|
2485
1700
|
args: [{
|
2486
1701
|
imports: [ConfirmationDialogModule, ApiModule],
|
2487
|
-
providers: [
|
1702
|
+
providers: [
|
1703
|
+
ConfigurationService,
|
1704
|
+
ConfigurationStateService,
|
1705
|
+
ConfigurationRuntimeService,
|
1706
|
+
TestModeConfigurationService,
|
1707
|
+
GuidedSellingService,
|
1708
|
+
],
|
1709
|
+
}]
|
1710
|
+
}] });
|
1711
|
+
|
1712
|
+
class FlowConfigurationModule {
|
1713
|
+
}
|
1714
|
+
FlowConfigurationModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: FlowConfigurationModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
|
1715
|
+
FlowConfigurationModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "15.2.9", ngImport: i0, type: FlowConfigurationModule, imports: [ApiModule] });
|
1716
|
+
FlowConfigurationModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: FlowConfigurationModule, providers: [FlowConfigurationService], imports: [ApiModule] });
|
1717
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: FlowConfigurationModule, decorators: [{
|
1718
|
+
type: NgModule,
|
1719
|
+
args: [{
|
1720
|
+
imports: [ApiModule],
|
1721
|
+
providers: [FlowConfigurationService],
|
2488
1722
|
}]
|
2489
1723
|
}] });
|
2490
1724
|
|
1725
|
+
const FORMATTING_SETTINGS_TOKEN = new InjectionToken('Summary of formatting settings for variant types of data, e.g. numbers, text, dates, etc');
|
1726
|
+
|
1727
|
+
const UI_DEFINITION_VERSION = 3;
|
1728
|
+
|
2491
1729
|
const DEFAULT_FORMATTING_SETTINGS = {
|
2492
1730
|
currencySymbol: DEFAULT_CURRENCY_SYMBOL,
|
2493
1731
|
decimalsCount: DEFAULT_DECIMALS_COUNT,
|
@@ -2501,14 +1739,14 @@ class SdkCoreModule {
|
|
2501
1739
|
SdkCoreModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: SdkCoreModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
|
2502
1740
|
SdkCoreModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "15.2.9", ngImport: i0, type: SdkCoreModule, imports: [ConfigurationModule, FlowConfigurationModule] });
|
2503
1741
|
SdkCoreModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: SdkCoreModule, providers: [
|
2504
|
-
ContextService,
|
2505
1742
|
FlowInfoService,
|
2506
|
-
QuoteDraftService,
|
2507
1743
|
ProductImagesService,
|
2508
1744
|
IntegrationState,
|
2509
1745
|
FlowStateService,
|
2510
1746
|
FlowStateConfigurationService,
|
2511
1747
|
RuntimeSettingsService,
|
1748
|
+
SalesTransactionService,
|
1749
|
+
CatalogProductsService,
|
2512
1750
|
{
|
2513
1751
|
provide: FORMATTING_SETTINGS_TOKEN,
|
2514
1752
|
useExisting: RuntimeSettingsService,
|
@@ -2519,14 +1757,14 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImpor
|
|
2519
1757
|
args: [{
|
2520
1758
|
imports: [ConfigurationModule, FlowConfigurationModule],
|
2521
1759
|
providers: [
|
2522
|
-
ContextService,
|
2523
1760
|
FlowInfoService,
|
2524
|
-
QuoteDraftService,
|
2525
1761
|
ProductImagesService,
|
2526
1762
|
IntegrationState,
|
2527
1763
|
FlowStateService,
|
2528
1764
|
FlowStateConfigurationService,
|
2529
1765
|
RuntimeSettingsService,
|
1766
|
+
SalesTransactionService,
|
1767
|
+
CatalogProductsService,
|
2530
1768
|
{
|
2531
1769
|
provide: FORMATTING_SETTINGS_TOKEN,
|
2532
1770
|
useExisting: RuntimeSettingsService,
|
@@ -2582,6 +1820,10 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImpor
|
|
2582
1820
|
}]
|
2583
1821
|
}] });
|
2584
1822
|
|
1823
|
+
function filterSuccessfulExecute() {
|
1824
|
+
return (source) => source.pipe(filter((result) => result.success), map(r => r.result));
|
1825
|
+
}
|
1826
|
+
|
2585
1827
|
class DatePipe {
|
2586
1828
|
constructor() {
|
2587
1829
|
this.locale = inject(LOCALE_ID);
|
@@ -2701,5 +1943,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImpor
|
|
2701
1943
|
* Generated bundle index. Do not edit.
|
2702
1944
|
*/
|
2703
1945
|
|
2704
|
-
export { ActionCodePipe, CalendarDirective, ConfigurationRuntimeService, ConfigurationService, ConfigurationStateService,
|
1946
|
+
export { ActionCodePipe, CalendarDirective, CatalogProductsService, ConfigurationRuntimeService, ConfigurationService, ConfigurationStateService, DEFAULT_FORMATTING_SETTINGS, DatePipe, FLOW_CUSTOMIZATION, FORMATTING_SETTINGS_TOKEN, FlowConfigurationService, FlowInfoService, FlowStateConfigurationService, FlowStateService, GuidedSellingService, IntegrationState, NumberPipe, PricePipe, ProductImagesService, RuntimeSettingsService, SalesTransactionService, SdkCoreModule, SdkDirectivesModule, SdkPipesModule, TestModeConfigurationService, TransactionItemWorker, UI_DEFINITION_VERSION, extractMetadata, filterSuccessfulExecute, findTransactionItem, findTransactionItemWithComparator, generateTransactionItem, insertTransactionItem, removeTransactionItem, replaceTransactionItem };
|
2705
1947
|
//# sourceMappingURL=veloceapps-sdk-core.mjs.map
|