@veloceapps/sdk 8.0.0-132 → 8.0.0-133
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/components/preview/preview.component.d.ts +2 -2
- package/cms/vendor-map.d.ts +2 -2
- package/core/modules/configuration/index.d.ts +1 -1
- package/core/modules/configuration/services/configuration-state.service.d.ts +48 -0
- package/core/modules/configuration/services/configuration.service.d.ts +2 -1
- package/core/services/flow-info.service.d.ts +1 -0
- package/core/services/flow-state-configuration.service.d.ts +3 -4
- package/esm2020/cms/components/preview/preview.component.mjs +4 -4
- package/esm2020/cms/vendor-map.mjs +3 -3
- package/esm2020/core/core.module.mjs +2 -4
- package/esm2020/core/modules/configuration/configuration.module.mjs +4 -4
- package/esm2020/core/modules/configuration/helpers.mjs +1 -1
- package/esm2020/core/modules/configuration/index.mjs +2 -2
- package/esm2020/core/modules/configuration/services/configuration-state.service.mjs +267 -0
- package/esm2020/core/modules/configuration/services/configuration.service.mjs +21 -15
- package/esm2020/core/services/flow-info.service.mjs +4 -1
- package/esm2020/core/services/flow-state-configuration.service.mjs +23 -21
- package/esm2020/core/services/flow-state.service.mjs +13 -4
- package/esm2020/src/guards/context.guard.mjs +1 -2
- package/esm2020/src/pages/product/product.component.mjs +21 -8
- package/esm2020/src/pages/remote/remote.component.mjs +4 -4
- package/esm2020/src/services/flow-router.service.mjs +30 -13
- package/esm2020/src/services/flow.service.mjs +48 -27
- package/fesm2015/veloceapps-sdk-cms.mjs +4 -4
- package/fesm2015/veloceapps-sdk-cms.mjs.map +1 -1
- package/fesm2015/veloceapps-sdk-core.mjs +251 -101
- package/fesm2015/veloceapps-sdk-core.mjs.map +1 -1
- package/fesm2015/veloceapps-sdk.mjs +94 -45
- package/fesm2015/veloceapps-sdk.mjs.map +1 -1
- package/fesm2020/veloceapps-sdk-cms.mjs +4 -4
- package/fesm2020/veloceapps-sdk-cms.mjs.map +1 -1
- package/fesm2020/veloceapps-sdk-core.mjs +240 -100
- package/fesm2020/veloceapps-sdk-core.mjs.map +1 -1
- package/fesm2020/veloceapps-sdk.mjs +93 -44
- package/fesm2020/veloceapps-sdk.mjs.map +1 -1
- package/package.json +1 -1
- package/src/pages/product/product.component.d.ts +6 -4
- package/src/pages/remote/remote.component.d.ts +2 -2
- package/src/services/flow-router.service.d.ts +4 -2
- package/src/services/flow.service.d.ts +7 -3
- package/core/modules/configuration/services/configuration.state.d.ts +0 -30
- package/esm2020/core/modules/configuration/services/configuration.state.mjs +0 -142
|
@@ -167,6 +167,10 @@ class FlowInfoService {
|
|
|
167
167
|
set flow(value) {
|
|
168
168
|
this.flowSubj$.next(value);
|
|
169
169
|
}
|
|
170
|
+
get isLegacy() {
|
|
171
|
+
var _a;
|
|
172
|
+
return !!this.flow && ((_a = this.flow) === null || _a === void 0 ? void 0 : _a.properties.stateful) == null;
|
|
173
|
+
}
|
|
170
174
|
constructor(flowsApiService, templatesApiService, customizationService) {
|
|
171
175
|
this.flowsApiService = flowsApiService;
|
|
172
176
|
this.templatesApiService = templatesApiService;
|
|
@@ -1006,8 +1010,7 @@ class FlowStateService {
|
|
|
1006
1010
|
initStateless$() {
|
|
1007
1011
|
var _a;
|
|
1008
1012
|
const { headerId } = this.contextService.resolve();
|
|
1009
|
-
|
|
1010
|
-
return stateInit$.pipe(tap$1(() => this.quoteDraftService.finalizeInit()), map$1(noop));
|
|
1013
|
+
return this.quoteDraftService.init(headerId, (_a = this.flowInfoService.params) !== null && _a !== void 0 ? _a : {}).pipe(switchMap(() => this.executeRequest$(this.getDefaultExecutionRequestDTO())), switchMap(() => this.calculate$()), tap$1(() => this.quoteDraftService.finalizeInit()), map$1(noop));
|
|
1011
1014
|
}
|
|
1012
1015
|
calculate$() {
|
|
1013
1016
|
var _a;
|
|
@@ -1145,7 +1148,7 @@ class FlowStateService {
|
|
|
1145
1148
|
return `${scope}/${selectorName}/${inputDataHash}`;
|
|
1146
1149
|
}
|
|
1147
1150
|
getDefaultExecutionRequestDTO() {
|
|
1148
|
-
var _a;
|
|
1151
|
+
var _a, _b, _c;
|
|
1149
1152
|
const request = {
|
|
1150
1153
|
actions: [],
|
|
1151
1154
|
selectors: {},
|
|
@@ -1155,10 +1158,20 @@ class FlowStateService {
|
|
|
1155
1158
|
}
|
|
1156
1159
|
const ownerId = this.getOwnerIdByScope(UITemplateType.FLOW_ENGINE);
|
|
1157
1160
|
(_a = request.actions) === null || _a === void 0 ? void 0 : _a.push({
|
|
1158
|
-
apiName: '
|
|
1161
|
+
apiName: 'UPDATE_PRICE_LIST',
|
|
1162
|
+
ownerId,
|
|
1163
|
+
inputData: {},
|
|
1164
|
+
});
|
|
1165
|
+
(_b = request.actions) === null || _b === void 0 ? void 0 : _b.push({
|
|
1166
|
+
apiName: 'UPDATE_ASSET_IDS',
|
|
1159
1167
|
ownerId,
|
|
1160
1168
|
inputData: {},
|
|
1161
1169
|
});
|
|
1170
|
+
(_c = request.actions) === null || _c === void 0 ? void 0 : _c.push({
|
|
1171
|
+
apiName: 'UPDATE_CONTEXT_PROPERTIES',
|
|
1172
|
+
ownerId,
|
|
1173
|
+
inputData: this.contextService.resolve().properties,
|
|
1174
|
+
});
|
|
1162
1175
|
return request;
|
|
1163
1176
|
}
|
|
1164
1177
|
}
|
|
@@ -1562,11 +1575,28 @@ class ConfigurationService {
|
|
|
1562
1575
|
throw error;
|
|
1563
1576
|
}));
|
|
1564
1577
|
}
|
|
1565
|
-
generateRequest() {
|
|
1566
|
-
var _a
|
|
1578
|
+
generateRequest(lightMode = true) {
|
|
1579
|
+
var _a;
|
|
1580
|
+
const lineItem = this.generateLineItem();
|
|
1581
|
+
let request = {
|
|
1582
|
+
lineItem,
|
|
1583
|
+
mode: this.mode,
|
|
1584
|
+
step: !this.lineItem.value ? RuntimeStep.START : RuntimeStep.UPDATE,
|
|
1585
|
+
attributeDomainMode: 'ALL',
|
|
1586
|
+
context: this.contextService.resolve(),
|
|
1587
|
+
lineItems: ((_a = this.quoteDraftService.quoteDraft) === null || _a === void 0 ? void 0 : _a.currentState) || [],
|
|
1588
|
+
asset: this.getAsset(),
|
|
1589
|
+
};
|
|
1590
|
+
if (lightMode) {
|
|
1591
|
+
request = ConfigurationTranslatorUtils.lightenConfigurationRequest(request);
|
|
1592
|
+
}
|
|
1593
|
+
return request;
|
|
1594
|
+
}
|
|
1595
|
+
generateLineItem() {
|
|
1596
|
+
var _a;
|
|
1567
1597
|
const runtimeContext = this.getRuntimeContext();
|
|
1568
1598
|
const uiDefinitionProperties = this.getUIDefinitionProperties();
|
|
1569
|
-
let lineItem = this.configurableRamp;
|
|
1599
|
+
let lineItem = cloneDeep(this.configurableRamp);
|
|
1570
1600
|
if (!lineItem) {
|
|
1571
1601
|
const { initializationProps } = (_a = this.runtimeService) !== null && _a !== void 0 ? _a : {};
|
|
1572
1602
|
lineItem = getDefaultLineItem(runtimeContext, uiDefinitionProperties, initializationProps === null || initializationProps === void 0 ? void 0 : initializationProps.defaultQty);
|
|
@@ -1576,17 +1606,7 @@ class ConfigurationService {
|
|
|
1576
1606
|
lineItem = new LineItemWorker(lineItem).patchAttribute(attributes).li;
|
|
1577
1607
|
}
|
|
1578
1608
|
}
|
|
1579
|
-
|
|
1580
|
-
lineItem,
|
|
1581
|
-
mode: this.mode,
|
|
1582
|
-
step: !this.lineItem.value ? RuntimeStep.START : RuntimeStep.UPDATE,
|
|
1583
|
-
attributeDomainMode: 'ALL',
|
|
1584
|
-
context: this.contextService.resolve(),
|
|
1585
|
-
lineItems: ((_b = this.quoteDraftService.quoteDraft) === null || _b === void 0 ? void 0 : _b.currentState) || [],
|
|
1586
|
-
asset: this.getAsset(),
|
|
1587
|
-
};
|
|
1588
|
-
request = ConfigurationTranslatorUtils.lightenConfigurationRequest(request);
|
|
1589
|
-
return request;
|
|
1609
|
+
return lineItem;
|
|
1590
1610
|
}
|
|
1591
1611
|
getUIDefinitionProperties() {
|
|
1592
1612
|
var _a, _b, _c;
|
|
@@ -1789,12 +1809,11 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImpor
|
|
|
1789
1809
|
}] });
|
|
1790
1810
|
|
|
1791
1811
|
class FlowStateConfigurationService {
|
|
1792
|
-
constructor(
|
|
1793
|
-
this.flowStateService = flowStateService;
|
|
1812
|
+
constructor(flowInfoService, flowConfigurationService, flowStateApiService, flowStateService) {
|
|
1794
1813
|
this.flowInfoService = flowInfoService;
|
|
1795
|
-
this.configurationService = configurationService;
|
|
1796
1814
|
this.flowConfigurationService = flowConfigurationService;
|
|
1797
1815
|
this.flowStateApiService = flowStateApiService;
|
|
1816
|
+
this.flowStateService = flowStateService;
|
|
1798
1817
|
this.configurationStateId$ = new BehaviorSubject(null);
|
|
1799
1818
|
}
|
|
1800
1819
|
get configurationStateId() {
|
|
@@ -1802,31 +1821,35 @@ class FlowStateConfigurationService {
|
|
|
1802
1821
|
}
|
|
1803
1822
|
addToCart$(props) {
|
|
1804
1823
|
var _a;
|
|
1824
|
+
let request$;
|
|
1805
1825
|
const stateful = (_a = this.flowInfoService.flow) === null || _a === void 0 ? void 0 : _a.properties.stateful;
|
|
1806
1826
|
if (stateful) {
|
|
1807
1827
|
const stateId = this.flowStateService.stateId;
|
|
1808
1828
|
if (!stateId) {
|
|
1809
|
-
|
|
1829
|
+
request$ = of();
|
|
1830
|
+
}
|
|
1831
|
+
else {
|
|
1832
|
+
const lineItem = generateConfigurationLineItem(props, props.qty);
|
|
1833
|
+
request$ = this.flowStateApiService.newConfiguration(stateId, { lineItem }).pipe(tap$1(r => this.configurationStateId$.next(r.stateId)), switchMap(() => {
|
|
1834
|
+
if (!this.configurationStateId) {
|
|
1835
|
+
return of();
|
|
1836
|
+
}
|
|
1837
|
+
return this.flowStateApiService.saveConfiguration(stateId, this.configurationStateId).pipe(tap$1(() => this.configurationStateId$.next(null)), map$1(noop));
|
|
1838
|
+
}));
|
|
1810
1839
|
}
|
|
1811
|
-
const lineItem = generateConfigurationLineItem(props, props.qty);
|
|
1812
|
-
return this.flowStateApiService.newConfiguration(stateId, { lineItem }).pipe(tap$1(r => this.configurationStateId$.next(r.stateId)), switchMap(() => {
|
|
1813
|
-
if (!this.configurationStateId) {
|
|
1814
|
-
return of();
|
|
1815
|
-
}
|
|
1816
|
-
return this.flowStateApiService.saveConfiguration(stateId, this.configurationStateId).pipe(switchMap(() => this.flowStateService.executeRequest$({}, true)), tap$1(() => this.configurationStateId$.next(null)), map$1(noop));
|
|
1817
|
-
}));
|
|
1818
1840
|
}
|
|
1819
1841
|
else {
|
|
1820
|
-
|
|
1842
|
+
request$ = this.flowConfigurationService.addToCart$(props).pipe(map$1(noop));
|
|
1821
1843
|
}
|
|
1844
|
+
return request$.pipe(switchMap(() => this.flowStateService.executeRequest$({}, true)), map$1(noop));
|
|
1822
1845
|
}
|
|
1823
1846
|
}
|
|
1824
|
-
FlowStateConfigurationService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: FlowStateConfigurationService, deps: [{ token:
|
|
1847
|
+
FlowStateConfigurationService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: FlowStateConfigurationService, deps: [{ token: FlowInfoService }, { token: FlowConfigurationService }, { token: i1.FlowStateApiService }, { token: FlowStateService }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
1825
1848
|
FlowStateConfigurationService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: FlowStateConfigurationService, providedIn: 'root' });
|
|
1826
1849
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: FlowStateConfigurationService, decorators: [{
|
|
1827
1850
|
type: Injectable,
|
|
1828
1851
|
args: [{ providedIn: 'root' }]
|
|
1829
|
-
}], ctorParameters: function () { return [{ type:
|
|
1852
|
+
}], ctorParameters: function () { return [{ type: FlowInfoService }, { type: FlowConfigurationService }, { type: i1.FlowStateApiService }, { type: FlowStateService }]; } });
|
|
1830
1853
|
|
|
1831
1854
|
function calculateMetricByMethod(lineItems, metric, method) {
|
|
1832
1855
|
const items = getLineItemsByMethod(lineItems, method);
|
|
@@ -2096,60 +2119,191 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImpor
|
|
|
2096
2119
|
type: Injectable
|
|
2097
2120
|
}], ctorParameters: function () { return [{ type: i1.ConfigurationApiService }, { type: ContextService }, { type: RuntimeContextService }]; } });
|
|
2098
2121
|
|
|
2099
|
-
class
|
|
2100
|
-
constructor(
|
|
2101
|
-
this.
|
|
2102
|
-
this.runtimeService = runtimeService;
|
|
2122
|
+
class ConfigurationStateService {
|
|
2123
|
+
constructor(configurationRuntimeService, configurationService, quoteDraftService, toastService, flowStateService, flowInfoService, flowConfigurationService, flowStateApiService, quoteApiService) {
|
|
2124
|
+
this.configurationRuntimeService = configurationRuntimeService;
|
|
2103
2125
|
this.configurationService = configurationService;
|
|
2126
|
+
this.quoteDraftService = quoteDraftService;
|
|
2104
2127
|
this.toastService = toastService;
|
|
2105
|
-
this.
|
|
2106
|
-
this.
|
|
2128
|
+
this.flowStateService = flowStateService;
|
|
2129
|
+
this.flowInfoService = flowInfoService;
|
|
2130
|
+
this.flowConfigurationService = flowConfigurationService;
|
|
2131
|
+
this.flowStateApiService = flowStateApiService;
|
|
2132
|
+
this.quoteApiService = quoteApiService;
|
|
2133
|
+
this.NOT_INITIALIZED = Symbol();
|
|
2107
2134
|
this.stateId = null;
|
|
2135
|
+
this.ownerId = '';
|
|
2136
|
+
this.subscriptions = {};
|
|
2137
|
+
this.isInitialized$ = new BehaviorSubject(false);
|
|
2108
2138
|
}
|
|
2109
2139
|
init$() {
|
|
2110
|
-
|
|
2111
|
-
|
|
2112
|
-
|
|
2113
|
-
|
|
2114
|
-
|
|
2115
|
-
|
|
2116
|
-
|
|
2117
|
-
|
|
2118
|
-
actions: actions === null || actions === void 0 ? void 0 : actions.map(action => ({ name: action.apiName, script: action.script })),
|
|
2119
|
-
selectors: selectors === null || selectors === void 0 ? void 0 : selectors.map(selector => ({ name: selector.apiName, script: selector.script })),
|
|
2120
|
-
});
|
|
2121
|
-
}), tap$1(stateId => (this.stateId = stateId || null)), map$1(() => undefined));
|
|
2140
|
+
let request$;
|
|
2141
|
+
if (this.flowStateService.stateId && this.isStatefulConfiguration) {
|
|
2142
|
+
request$ = this.initStateful$();
|
|
2143
|
+
}
|
|
2144
|
+
else {
|
|
2145
|
+
request$ = this.initStateless$();
|
|
2146
|
+
}
|
|
2147
|
+
return request$.pipe(finalize(() => this.isInitialized$.next(true)));
|
|
2122
2148
|
}
|
|
2123
2149
|
cleanup() {
|
|
2124
2150
|
this.stateId = null;
|
|
2125
2151
|
this.configurationService.reset();
|
|
2126
|
-
this.stateSubj$.next({});
|
|
2127
2152
|
}
|
|
2128
|
-
execute$(req) {
|
|
2153
|
+
execute$(req, forceSubscriptions) {
|
|
2154
|
+
var _a;
|
|
2155
|
+
const fullRequest = cloneDeep(req);
|
|
2156
|
+
if (((_a = fullRequest.actions) === null || _a === void 0 ? void 0 : _a.length) || forceSubscriptions) {
|
|
2157
|
+
for (const subscription of Object.values(this.subscriptions)) {
|
|
2158
|
+
fullRequest.selectors = assign(fullRequest.selectors, subscription.request.selectors);
|
|
2159
|
+
}
|
|
2160
|
+
}
|
|
2161
|
+
let execution$;
|
|
2129
2162
|
if (this.isStatefulConfiguration) {
|
|
2130
|
-
|
|
2163
|
+
execution$ = this.executeStateful$(fullRequest);
|
|
2131
2164
|
}
|
|
2132
2165
|
else {
|
|
2133
|
-
|
|
2166
|
+
execution$ = this.executeStateless$(fullRequest);
|
|
2134
2167
|
}
|
|
2168
|
+
return execution$.pipe(tap$1(result => this.handleSelectorsResponse(result.selectors)));
|
|
2135
2169
|
}
|
|
2136
|
-
|
|
2137
|
-
|
|
2170
|
+
handleSelectorsResponse(selectors) {
|
|
2171
|
+
Object.entries(selectors).forEach(([requestId, selectorResult]) => {
|
|
2172
|
+
var _a;
|
|
2173
|
+
if (!selectorResult.success) {
|
|
2174
|
+
this.toastService.add({ severity: ToastType.error, summary: selectorResult.errorMessage });
|
|
2175
|
+
}
|
|
2176
|
+
const subscription$ = (_a = this.subscriptions[requestId]) === null || _a === void 0 ? void 0 : _a.data$;
|
|
2177
|
+
if (subscription$) {
|
|
2178
|
+
subscription$.next(selectorResult);
|
|
2179
|
+
}
|
|
2180
|
+
});
|
|
2138
2181
|
}
|
|
2139
|
-
|
|
2182
|
+
dispatch$(actionName, inputData = {}) {
|
|
2183
|
+
return this.execute$({ actions: [{ apiName: actionName, inputData, ownerId: this.ownerId }] });
|
|
2184
|
+
}
|
|
2185
|
+
select$(selectorName, inputData = {}) {
|
|
2140
2186
|
const requestId = UUID.UUID();
|
|
2141
2187
|
return this.execute$({
|
|
2142
2188
|
selectors: {
|
|
2143
2189
|
[requestId]: {
|
|
2144
|
-
|
|
2190
|
+
apiName: selectorName,
|
|
2145
2191
|
inputData,
|
|
2192
|
+
ownerId: this.ownerId,
|
|
2146
2193
|
},
|
|
2147
2194
|
},
|
|
2148
|
-
}).pipe(map$1(
|
|
2195
|
+
}).pipe(map$1(response => response.selectors[requestId]));
|
|
2196
|
+
}
|
|
2197
|
+
subscribe$(selectorName, inputData = {}, options) {
|
|
2198
|
+
const requestId = UUID.UUID();
|
|
2199
|
+
if (!this.subscriptions[requestId]) {
|
|
2200
|
+
const request = {
|
|
2201
|
+
selectors: {
|
|
2202
|
+
[requestId]: {
|
|
2203
|
+
apiName: selectorName,
|
|
2204
|
+
inputData,
|
|
2205
|
+
ownerId: this.ownerId,
|
|
2206
|
+
},
|
|
2207
|
+
},
|
|
2208
|
+
};
|
|
2209
|
+
this.subscriptions[requestId] = {
|
|
2210
|
+
request,
|
|
2211
|
+
data$: new BehaviorSubject(this.NOT_INITIALIZED),
|
|
2212
|
+
};
|
|
2213
|
+
if (!(options === null || options === void 0 ? void 0 : options.cold)) {
|
|
2214
|
+
this.execute$(request).subscribe();
|
|
2215
|
+
}
|
|
2216
|
+
}
|
|
2217
|
+
return this.subscriptions[requestId].data$.pipe(filter$1(data => data != this.NOT_INITIALIZED), map$1(data => data), finalize(() => {
|
|
2218
|
+
if (!this.subscriptions[requestId].data$.observed) {
|
|
2219
|
+
delete this.subscriptions[requestId];
|
|
2220
|
+
}
|
|
2221
|
+
}));
|
|
2222
|
+
}
|
|
2223
|
+
saveConfiguration(quoteId, flow) {
|
|
2224
|
+
var _a, _b;
|
|
2225
|
+
if (this.isStatefulConfiguration) {
|
|
2226
|
+
return this.flowStateApiService
|
|
2227
|
+
.saveConfiguration((_a = this.flowStateService.stateId) !== null && _a !== void 0 ? _a : '', (_b = this.stateId) !== null && _b !== void 0 ? _b : '')
|
|
2228
|
+
.pipe(switchMap(r => this.flowStateService.executeRequest$({}, true).pipe(map$1(() => r))));
|
|
2229
|
+
}
|
|
2230
|
+
else {
|
|
2231
|
+
if (!flow) {
|
|
2232
|
+
if (!quoteId) {
|
|
2233
|
+
return of({ quoteId: '' });
|
|
2234
|
+
}
|
|
2235
|
+
const rootLineItem = this.configurationService.getSnapshot();
|
|
2236
|
+
const currentState = rootLineItem ? [rootLineItem] : [];
|
|
2237
|
+
return this.quoteApiService
|
|
2238
|
+
.getQuoteDraft(quoteId)
|
|
2239
|
+
.pipe(switchMap(quoteDraft => this.quoteApiService.upsertQuote(Object.assign(Object.assign({}, quoteDraft), { currentState }))));
|
|
2240
|
+
}
|
|
2241
|
+
else {
|
|
2242
|
+
const quoteDraft = this.quoteDraftService.quoteDraft;
|
|
2243
|
+
const lineItem = this.configurationService.getSnapshot();
|
|
2244
|
+
if (!quoteDraft || !lineItem) {
|
|
2245
|
+
return of({ quoteId: '' });
|
|
2246
|
+
}
|
|
2247
|
+
const isNewLineItem = quoteDraft.currentState.every(li => li.id !== lineItem.id);
|
|
2248
|
+
let updatedState;
|
|
2249
|
+
if (isNewLineItem) {
|
|
2250
|
+
updatedState = [...quoteDraft.currentState, lineItem];
|
|
2251
|
+
}
|
|
2252
|
+
else {
|
|
2253
|
+
updatedState = quoteDraft.currentState.map(li => (li.id === lineItem.id ? lineItem : li));
|
|
2254
|
+
}
|
|
2255
|
+
return this.flowConfigurationService
|
|
2256
|
+
.calculate$(Object.assign(Object.assign({}, quoteDraft), { currentState: updatedState }))
|
|
2257
|
+
.pipe(map$1(() => ({ quoteId: '' })));
|
|
2258
|
+
}
|
|
2259
|
+
}
|
|
2260
|
+
}
|
|
2261
|
+
cancelConfiguration() {
|
|
2262
|
+
var _a, _b;
|
|
2263
|
+
if (!this.isInitialized$.value) {
|
|
2264
|
+
return of(undefined);
|
|
2265
|
+
}
|
|
2266
|
+
this.isInitialized$.next(false);
|
|
2267
|
+
if (!this.isInitialized$.value || !this.isStatefulConfiguration) {
|
|
2268
|
+
return of(undefined);
|
|
2269
|
+
}
|
|
2270
|
+
return this.flowStateApiService.cancelConfiguration((_a = this.flowStateService.stateId) !== null && _a !== void 0 ? _a : '', (_b = this.stateId) !== null && _b !== void 0 ? _b : '');
|
|
2149
2271
|
}
|
|
2150
2272
|
get isStatefulConfiguration() {
|
|
2151
|
-
var _a;
|
|
2152
|
-
return (_a = this.
|
|
2273
|
+
var _a, _b;
|
|
2274
|
+
return (_b = (_a = this.flowInfoService.flow) === null || _a === void 0 ? void 0 : _a.properties.stateful) !== null && _b !== void 0 ? _b : false;
|
|
2275
|
+
}
|
|
2276
|
+
initStateful$() {
|
|
2277
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
|
|
2278
|
+
this.ownerId = (_c = (_b = (_a = this.configurationRuntimeService.runtimeContext) === null || _a === void 0 ? void 0 : _a.uiDefinitionContainer) === null || _b === void 0 ? void 0 : _b.id) !== null && _c !== void 0 ? _c : '';
|
|
2279
|
+
const lineItemId = (_e = (_d = this.configurationRuntimeService.runtimeContext) === null || _d === void 0 ? void 0 : _d.properties) === null || _e === void 0 ? void 0 : _e.lineItemId;
|
|
2280
|
+
if (!this.flowStateService.stateId) {
|
|
2281
|
+
return of(undefined);
|
|
2282
|
+
}
|
|
2283
|
+
const container = (_f = this.configurationRuntimeService.runtimeContext) === null || _f === void 0 ? void 0 : _f.uiDefinitionContainer;
|
|
2284
|
+
const lineItem = this.configurationService.generateLineItem();
|
|
2285
|
+
let request$;
|
|
2286
|
+
if (!lineItemId) {
|
|
2287
|
+
request$ = this.flowStateApiService.newConfiguration(this.flowStateService.stateId, {
|
|
2288
|
+
lineItem,
|
|
2289
|
+
actionsOverride: (_g = container === null || container === void 0 ? void 0 : container.actions) === null || _g === void 0 ? void 0 : _g.map(processor => (Object.assign(Object.assign({}, processor), { ownerId: this.ownerId }))),
|
|
2290
|
+
selectorsOverride: (_h = container === null || container === void 0 ? void 0 : container.selectors) === null || _h === void 0 ? void 0 : _h.map(processor => (Object.assign(Object.assign({}, processor), { ownerId: this.ownerId }))),
|
|
2291
|
+
});
|
|
2292
|
+
}
|
|
2293
|
+
else {
|
|
2294
|
+
request$ = this.flowStateApiService.startConfiguration(this.flowStateService.stateId, {
|
|
2295
|
+
lineItemId,
|
|
2296
|
+
actionsOverride: (_j = container === null || container === void 0 ? void 0 : container.actions) === null || _j === void 0 ? void 0 : _j.map(processor => (Object.assign(Object.assign({}, processor), { ownerId: this.ownerId }))),
|
|
2297
|
+
selectorsOverride: (_k = container === null || container === void 0 ? void 0 : container.selectors) === null || _k === void 0 ? void 0 : _k.map(processor => (Object.assign(Object.assign({}, processor), { ownerId: this.ownerId }))),
|
|
2298
|
+
});
|
|
2299
|
+
}
|
|
2300
|
+
return request$.pipe(map$1(r => {
|
|
2301
|
+
this.stateId = r.stateId;
|
|
2302
|
+
return undefined;
|
|
2303
|
+
}));
|
|
2304
|
+
}
|
|
2305
|
+
initStateless$() {
|
|
2306
|
+
return this.configurationService.configure().pipe(map$1(() => undefined));
|
|
2153
2307
|
}
|
|
2154
2308
|
executeStateless$(request) {
|
|
2155
2309
|
return of(undefined).pipe(switchMap(() => {
|
|
@@ -2165,51 +2319,49 @@ class ConfigurationState {
|
|
|
2165
2319
|
configurationRequest = (_a = this.executeActionScript(configurationRequest, action)) !== null && _a !== void 0 ? _a : configurationRequest;
|
|
2166
2320
|
});
|
|
2167
2321
|
return this.configurationService.configureRequest$(configurationRequest);
|
|
2168
|
-
}),
|
|
2169
|
-
|
|
2170
|
-
return;
|
|
2171
|
-
}
|
|
2322
|
+
}), map$1(() => {
|
|
2323
|
+
var _a;
|
|
2172
2324
|
// Run selectors and apply them to the state
|
|
2173
|
-
const finalConfigurationRequest = this.configurationService.generateRequest();
|
|
2174
|
-
const selectorsResult = EntityUtil.entries(request.selectors).reduce((
|
|
2175
|
-
|
|
2176
|
-
|
|
2177
|
-
|
|
2178
|
-
|
|
2179
|
-
|
|
2325
|
+
const finalConfigurationRequest = this.configurationService.generateRequest(false);
|
|
2326
|
+
const selectorsResult = EntityUtil.entries((_a = request.selectors) !== null && _a !== void 0 ? _a : {}).reduce((result, [key, selector]) => {
|
|
2327
|
+
try {
|
|
2328
|
+
result.selectors[key] = {
|
|
2329
|
+
success: true,
|
|
2330
|
+
result: this.executeSelectorScript(finalConfigurationRequest, selector),
|
|
2331
|
+
};
|
|
2332
|
+
}
|
|
2333
|
+
catch (e) {
|
|
2334
|
+
result.selectors[key] = {
|
|
2335
|
+
success: false,
|
|
2336
|
+
errorMessage: String(e),
|
|
2337
|
+
};
|
|
2338
|
+
}
|
|
2339
|
+
return result;
|
|
2340
|
+
}, { stateId: '', selectors: {} });
|
|
2341
|
+
return selectorsResult;
|
|
2342
|
+
}));
|
|
2180
2343
|
}
|
|
2181
2344
|
executeStateful$(request) {
|
|
2182
|
-
if (!this.stateId) {
|
|
2183
|
-
return of(
|
|
2345
|
+
if (!this.flowStateService.stateId || !this.stateId) {
|
|
2346
|
+
return of();
|
|
2184
2347
|
}
|
|
2185
|
-
return this.
|
|
2348
|
+
return this.flowStateApiService.executeConfiguration(this.flowStateService.stateId, this.stateId, request).pipe(tap$1(response => {
|
|
2186
2349
|
this.stateId = response.stateId;
|
|
2187
|
-
|
|
2188
|
-
EntityUtil.entries(response.selectors).forEach(([key, value]) => {
|
|
2189
|
-
if (!value.success) {
|
|
2190
|
-
if (!this.runtimeService.uiDefinitionProperties.suppressToastMessages) {
|
|
2191
|
-
this.toastService.add({ summary: value.errorMessage, severity: ToastType.error });
|
|
2192
|
-
}
|
|
2193
|
-
return;
|
|
2194
|
-
}
|
|
2195
|
-
updatedState[key] = value.result;
|
|
2196
|
-
});
|
|
2197
|
-
this.stateSubj$.next(updatedState);
|
|
2198
|
-
}), map$1(() => undefined));
|
|
2350
|
+
}));
|
|
2199
2351
|
}
|
|
2200
2352
|
executeActionScript(request, processor) {
|
|
2201
2353
|
var _a, _b, _c;
|
|
2202
|
-
const { actions } = (_b = (_a = this.
|
|
2203
|
-
const script = (_c = actions === null || actions === void 0 ? void 0 : actions.find(action => action.apiName === processor.
|
|
2354
|
+
const { actions } = (_b = (_a = this.configurationRuntimeService.runtimeContext) === null || _a === void 0 ? void 0 : _a.uiDefinitionContainer) !== null && _b !== void 0 ? _b : {};
|
|
2355
|
+
const script = (_c = actions === null || actions === void 0 ? void 0 : actions.find(action => action.apiName === processor.apiName)) === null || _c === void 0 ? void 0 : _c.script;
|
|
2204
2356
|
if (!script) {
|
|
2205
|
-
return
|
|
2357
|
+
return request;
|
|
2206
2358
|
}
|
|
2207
2359
|
return this.executeProcessorScript(request, script, processor.inputData);
|
|
2208
2360
|
}
|
|
2209
2361
|
executeSelectorScript(request, processor) {
|
|
2210
2362
|
var _a, _b, _c;
|
|
2211
|
-
const { selectors } = (_b = (_a = this.
|
|
2212
|
-
const script = (_c = selectors === null || selectors === void 0 ? void 0 : selectors.find(selector => selector.apiName === processor.
|
|
2363
|
+
const { selectors } = (_b = (_a = this.configurationRuntimeService.runtimeContext) === null || _a === void 0 ? void 0 : _a.uiDefinitionContainer) !== null && _b !== void 0 ? _b : {};
|
|
2364
|
+
const script = (_c = selectors === null || selectors === void 0 ? void 0 : selectors.find(selector => selector.apiName === processor.apiName)) === null || _c === void 0 ? void 0 : _c.script;
|
|
2213
2365
|
if (!script) {
|
|
2214
2366
|
return null;
|
|
2215
2367
|
}
|
|
@@ -2222,11 +2374,11 @@ class ConfigurationState {
|
|
|
2222
2374
|
});
|
|
2223
2375
|
}
|
|
2224
2376
|
}
|
|
2225
|
-
|
|
2226
|
-
|
|
2227
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type:
|
|
2377
|
+
ConfigurationStateService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: ConfigurationStateService, deps: [{ token: ConfigurationRuntimeService }, { token: ConfigurationService }, { token: QuoteDraftService }, { token: i6.ToastService }, { token: FlowStateService }, { token: FlowInfoService }, { token: FlowConfigurationService }, { token: i1.FlowStateApiService }, { token: i1.QuoteApiService }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
2378
|
+
ConfigurationStateService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: ConfigurationStateService });
|
|
2379
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: ConfigurationStateService, decorators: [{
|
|
2228
2380
|
type: Injectable
|
|
2229
|
-
}], ctorParameters: function () { return [{ type:
|
|
2381
|
+
}], ctorParameters: function () { return [{ type: ConfigurationRuntimeService }, { type: ConfigurationService }, { type: QuoteDraftService }, { type: i6.ToastService }, { type: FlowStateService }, { type: FlowInfoService }, { type: FlowConfigurationService }, { type: i1.FlowStateApiService }, { type: i1.QuoteApiService }]; } });
|
|
2230
2382
|
|
|
2231
2383
|
class ConfigurationModule {
|
|
2232
2384
|
}
|
|
@@ -2239,7 +2391,7 @@ ConfigurationModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", ver
|
|
|
2239
2391
|
ConfigurationRuntimeService,
|
|
2240
2392
|
RuntimeContextService,
|
|
2241
2393
|
ConfigurationService,
|
|
2242
|
-
|
|
2394
|
+
ConfigurationStateService,
|
|
2243
2395
|
], imports: [ConfirmationDialogModule] });
|
|
2244
2396
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: ConfigurationModule, decorators: [{
|
|
2245
2397
|
type: NgModule,
|
|
@@ -2252,7 +2404,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImpor
|
|
|
2252
2404
|
ConfigurationRuntimeService,
|
|
2253
2405
|
RuntimeContextService,
|
|
2254
2406
|
ConfigurationService,
|
|
2255
|
-
|
|
2407
|
+
ConfigurationStateService,
|
|
2256
2408
|
],
|
|
2257
2409
|
}]
|
|
2258
2410
|
}] });
|
|
@@ -2271,7 +2423,6 @@ SdkCoreModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "
|
|
|
2271
2423
|
SdkCoreModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "15.2.9", ngImport: i0, type: SdkCoreModule, imports: [ConfigurationModule, FlowConfigurationModule] });
|
|
2272
2424
|
SdkCoreModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: SdkCoreModule, providers: [
|
|
2273
2425
|
IntegrationState,
|
|
2274
|
-
FlowStateService,
|
|
2275
2426
|
{
|
|
2276
2427
|
provide: FORMATTING_SETTINGS_TOKEN,
|
|
2277
2428
|
useExisting: RuntimeSettingsService,
|
|
@@ -2283,7 +2434,6 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImpor
|
|
|
2283
2434
|
imports: [ConfigurationModule, FlowConfigurationModule],
|
|
2284
2435
|
providers: [
|
|
2285
2436
|
IntegrationState,
|
|
2286
|
-
FlowStateService,
|
|
2287
2437
|
{
|
|
2288
2438
|
provide: FORMATTING_SETTINGS_TOKEN,
|
|
2289
2439
|
useExisting: RuntimeSettingsService,
|
|
@@ -2468,5 +2618,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImpor
|
|
|
2468
2618
|
* Generated bundle index. Do not edit.
|
|
2469
2619
|
*/
|
|
2470
2620
|
|
|
2471
|
-
export { ActionCodePipe, CalendarDirective, ConfigurationRuntimeService, ConfigurationService,
|
|
2621
|
+
export { ActionCodePipe, CalendarDirective, ConfigurationRuntimeService, ConfigurationService, ConfigurationStateService, ContextService, DEFAULT_FORMATTING_SETTINGS, DatePipe, FLOW_CUSTOMIZATION, FORMATTING_SETTINGS_TOKEN, FlowConfigurationModule, FlowConfigurationService, FlowInfoService, FlowStateConfigurationService, FlowStateService, FlowUpdateService, IntegrationState, LineItemWorker, MetricsCalculationService, NumberPipe, PricePipe, ProductImagesService, QuoteDraftService, RuntimeMode, RuntimeOperation, RuntimeSettingsService, RuntimeStep, SdkCoreModule, SdkDirectivesModule, SdkPipesModule, UI_DEFINITION_VERSION, calculateCardinalityVariables, extractMetadata, filterOutTechnicalAttributes, findLineItem, findLineItemWithComparator, generateConfigurationLineItem, generateLineItem, generateModifiedAssetsMap, getAttributeValue, getAttributes, getDefaultLineItem, getGuidedSellingConfigurationRequest, getOriginParent, getRecommendedPrices, insertLineItem, isLineItemModified, isTechnicalAttribute, lineItem_utils as lineItemUtils, mapAttributes, multiplyLineItems, patchAttributes, recalculateCardinalityVariables, removeLineItem, replaceLineItem, upsertAttributes };
|
|
2472
2622
|
//# sourceMappingURL=veloceapps-sdk-core.mjs.map
|