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