@veloceapps/sdk 8.0.0-131 → 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
|
@@ -200,6 +200,9 @@ class FlowInfoService {
|
|
|
200
200
|
set flow(value) {
|
|
201
201
|
this.flowSubj$.next(value);
|
|
202
202
|
}
|
|
203
|
+
get isLegacy() {
|
|
204
|
+
return !!this.flow && this.flow?.properties.stateful == null;
|
|
205
|
+
}
|
|
203
206
|
constructor(flowsApiService, templatesApiService, customizationService) {
|
|
204
207
|
this.flowsApiService = flowsApiService;
|
|
205
208
|
this.templatesApiService = templatesApiService;
|
|
@@ -1059,8 +1062,7 @@ class FlowStateService {
|
|
|
1059
1062
|
}
|
|
1060
1063
|
initStateless$() {
|
|
1061
1064
|
const { headerId } = this.contextService.resolve();
|
|
1062
|
-
|
|
1063
|
-
return stateInit$.pipe(tap$1(() => this.quoteDraftService.finalizeInit()), map$1(noop));
|
|
1065
|
+
return this.quoteDraftService.init(headerId, this.flowInfoService.params ?? {}).pipe(switchMap(() => this.executeRequest$(this.getDefaultExecutionRequestDTO())), switchMap(() => this.calculate$()), tap$1(() => this.quoteDraftService.finalizeInit()), map$1(noop));
|
|
1064
1066
|
}
|
|
1065
1067
|
calculate$() {
|
|
1066
1068
|
const flowState = this.quoteDraftService.quoteDraft;
|
|
@@ -1198,10 +1200,20 @@ class FlowStateService {
|
|
|
1198
1200
|
}
|
|
1199
1201
|
const ownerId = this.getOwnerIdByScope(UITemplateType.FLOW_ENGINE);
|
|
1200
1202
|
request.actions?.push({
|
|
1201
|
-
apiName: '
|
|
1203
|
+
apiName: 'UPDATE_PRICE_LIST',
|
|
1204
|
+
ownerId,
|
|
1205
|
+
inputData: {},
|
|
1206
|
+
});
|
|
1207
|
+
request.actions?.push({
|
|
1208
|
+
apiName: 'UPDATE_ASSET_IDS',
|
|
1202
1209
|
ownerId,
|
|
1203
1210
|
inputData: {},
|
|
1204
1211
|
});
|
|
1212
|
+
request.actions?.push({
|
|
1213
|
+
apiName: 'UPDATE_CONTEXT_PROPERTIES',
|
|
1214
|
+
ownerId,
|
|
1215
|
+
inputData: this.contextService.resolve().properties,
|
|
1216
|
+
});
|
|
1205
1217
|
return request;
|
|
1206
1218
|
}
|
|
1207
1219
|
}
|
|
@@ -1468,10 +1480,26 @@ class ConfigurationService {
|
|
|
1468
1480
|
throw error;
|
|
1469
1481
|
}));
|
|
1470
1482
|
}
|
|
1471
|
-
generateRequest() {
|
|
1483
|
+
generateRequest(lightMode = true) {
|
|
1484
|
+
const lineItem = this.generateLineItem();
|
|
1485
|
+
let request = {
|
|
1486
|
+
lineItem,
|
|
1487
|
+
mode: this.mode,
|
|
1488
|
+
step: !this.lineItem.value ? RuntimeStep.START : RuntimeStep.UPDATE,
|
|
1489
|
+
attributeDomainMode: 'ALL',
|
|
1490
|
+
context: this.contextService.resolve(),
|
|
1491
|
+
lineItems: this.quoteDraftService.quoteDraft?.currentState || [],
|
|
1492
|
+
asset: this.getAsset(),
|
|
1493
|
+
};
|
|
1494
|
+
if (lightMode) {
|
|
1495
|
+
request = ConfigurationTranslatorUtils.lightenConfigurationRequest(request);
|
|
1496
|
+
}
|
|
1497
|
+
return request;
|
|
1498
|
+
}
|
|
1499
|
+
generateLineItem() {
|
|
1472
1500
|
const runtimeContext = this.getRuntimeContext();
|
|
1473
1501
|
const uiDefinitionProperties = this.getUIDefinitionProperties();
|
|
1474
|
-
let lineItem = this.configurableRamp;
|
|
1502
|
+
let lineItem = cloneDeep(this.configurableRamp);
|
|
1475
1503
|
if (!lineItem) {
|
|
1476
1504
|
const { initializationProps } = this.runtimeService ?? {};
|
|
1477
1505
|
lineItem = getDefaultLineItem(runtimeContext, uiDefinitionProperties, initializationProps?.defaultQty);
|
|
@@ -1481,17 +1509,7 @@ class ConfigurationService {
|
|
|
1481
1509
|
lineItem = new LineItemWorker(lineItem).patchAttribute(attributes).li;
|
|
1482
1510
|
}
|
|
1483
1511
|
}
|
|
1484
|
-
|
|
1485
|
-
lineItem,
|
|
1486
|
-
mode: this.mode,
|
|
1487
|
-
step: !this.lineItem.value ? RuntimeStep.START : RuntimeStep.UPDATE,
|
|
1488
|
-
attributeDomainMode: 'ALL',
|
|
1489
|
-
context: this.contextService.resolve(),
|
|
1490
|
-
lineItems: this.quoteDraftService.quoteDraft?.currentState || [],
|
|
1491
|
-
asset: this.getAsset(),
|
|
1492
|
-
};
|
|
1493
|
-
request = ConfigurationTranslatorUtils.lightenConfigurationRequest(request);
|
|
1494
|
-
return request;
|
|
1512
|
+
return lineItem;
|
|
1495
1513
|
}
|
|
1496
1514
|
getUIDefinitionProperties() {
|
|
1497
1515
|
return {
|
|
@@ -1822,43 +1840,46 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImpor
|
|
|
1822
1840
|
}] });
|
|
1823
1841
|
|
|
1824
1842
|
class FlowStateConfigurationService {
|
|
1825
|
-
constructor(
|
|
1826
|
-
this.flowStateService = flowStateService;
|
|
1843
|
+
constructor(flowInfoService, flowConfigurationService, flowStateApiService, flowStateService) {
|
|
1827
1844
|
this.flowInfoService = flowInfoService;
|
|
1828
|
-
this.configurationService = configurationService;
|
|
1829
1845
|
this.flowConfigurationService = flowConfigurationService;
|
|
1830
1846
|
this.flowStateApiService = flowStateApiService;
|
|
1847
|
+
this.flowStateService = flowStateService;
|
|
1831
1848
|
this.configurationStateId$ = new BehaviorSubject(null);
|
|
1832
1849
|
}
|
|
1833
1850
|
get configurationStateId() {
|
|
1834
1851
|
return this.configurationStateId$.value;
|
|
1835
1852
|
}
|
|
1836
1853
|
addToCart$(props) {
|
|
1854
|
+
let request$;
|
|
1837
1855
|
const stateful = this.flowInfoService.flow?.properties.stateful;
|
|
1838
1856
|
if (stateful) {
|
|
1839
1857
|
const stateId = this.flowStateService.stateId;
|
|
1840
1858
|
if (!stateId) {
|
|
1841
|
-
|
|
1859
|
+
request$ = of();
|
|
1860
|
+
}
|
|
1861
|
+
else {
|
|
1862
|
+
const lineItem = generateConfigurationLineItem(props, props.qty);
|
|
1863
|
+
request$ = this.flowStateApiService.newConfiguration(stateId, { lineItem }).pipe(tap$1(r => this.configurationStateId$.next(r.stateId)), switchMap(() => {
|
|
1864
|
+
if (!this.configurationStateId) {
|
|
1865
|
+
return of();
|
|
1866
|
+
}
|
|
1867
|
+
return this.flowStateApiService.saveConfiguration(stateId, this.configurationStateId).pipe(tap$1(() => this.configurationStateId$.next(null)), map$1(noop));
|
|
1868
|
+
}));
|
|
1842
1869
|
}
|
|
1843
|
-
const lineItem = generateConfigurationLineItem(props, props.qty);
|
|
1844
|
-
return this.flowStateApiService.newConfiguration(stateId, { lineItem }).pipe(tap$1(r => this.configurationStateId$.next(r.stateId)), switchMap(() => {
|
|
1845
|
-
if (!this.configurationStateId) {
|
|
1846
|
-
return of();
|
|
1847
|
-
}
|
|
1848
|
-
return this.flowStateApiService.saveConfiguration(stateId, this.configurationStateId).pipe(switchMap(() => this.flowStateService.executeRequest$({}, true)), tap$1(() => this.configurationStateId$.next(null)), map$1(noop));
|
|
1849
|
-
}));
|
|
1850
1870
|
}
|
|
1851
1871
|
else {
|
|
1852
|
-
|
|
1872
|
+
request$ = this.flowConfigurationService.addToCart$(props).pipe(map$1(noop));
|
|
1853
1873
|
}
|
|
1874
|
+
return request$.pipe(switchMap(() => this.flowStateService.executeRequest$({}, true)), map$1(noop));
|
|
1854
1875
|
}
|
|
1855
1876
|
}
|
|
1856
|
-
FlowStateConfigurationService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: FlowStateConfigurationService, deps: [{ token:
|
|
1877
|
+
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 });
|
|
1857
1878
|
FlowStateConfigurationService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: FlowStateConfigurationService, providedIn: 'root' });
|
|
1858
1879
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: FlowStateConfigurationService, decorators: [{
|
|
1859
1880
|
type: Injectable,
|
|
1860
1881
|
args: [{ providedIn: 'root' }]
|
|
1861
|
-
}], ctorParameters: function () { return [{ type:
|
|
1882
|
+
}], ctorParameters: function () { return [{ type: FlowInfoService }, { type: FlowConfigurationService }, { type: i1.FlowStateApiService }, { type: FlowStateService }]; } });
|
|
1862
1883
|
|
|
1863
1884
|
function calculateMetricByMethod(lineItems, metric, method) {
|
|
1864
1885
|
const items = getLineItemsByMethod(lineItems, method);
|
|
@@ -2138,58 +2159,185 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImpor
|
|
|
2138
2159
|
type: Injectable
|
|
2139
2160
|
}], ctorParameters: function () { return [{ type: i1.ConfigurationApiService }, { type: ContextService }, { type: RuntimeContextService }]; } });
|
|
2140
2161
|
|
|
2141
|
-
class
|
|
2142
|
-
constructor(
|
|
2143
|
-
this.
|
|
2144
|
-
this.runtimeService = runtimeService;
|
|
2162
|
+
class ConfigurationStateService {
|
|
2163
|
+
constructor(configurationRuntimeService, configurationService, quoteDraftService, toastService, flowStateService, flowInfoService, flowConfigurationService, flowStateApiService, quoteApiService) {
|
|
2164
|
+
this.configurationRuntimeService = configurationRuntimeService;
|
|
2145
2165
|
this.configurationService = configurationService;
|
|
2166
|
+
this.quoteDraftService = quoteDraftService;
|
|
2146
2167
|
this.toastService = toastService;
|
|
2147
|
-
this.
|
|
2148
|
-
this.
|
|
2168
|
+
this.flowStateService = flowStateService;
|
|
2169
|
+
this.flowInfoService = flowInfoService;
|
|
2170
|
+
this.flowConfigurationService = flowConfigurationService;
|
|
2171
|
+
this.flowStateApiService = flowStateApiService;
|
|
2172
|
+
this.quoteApiService = quoteApiService;
|
|
2173
|
+
this.NOT_INITIALIZED = Symbol();
|
|
2149
2174
|
this.stateId = null;
|
|
2175
|
+
this.ownerId = '';
|
|
2176
|
+
this.subscriptions = {};
|
|
2177
|
+
this.isInitialized$ = new BehaviorSubject(false);
|
|
2150
2178
|
}
|
|
2151
2179
|
init$() {
|
|
2152
|
-
|
|
2153
|
-
|
|
2154
|
-
|
|
2155
|
-
|
|
2156
|
-
|
|
2157
|
-
|
|
2158
|
-
|
|
2159
|
-
|
|
2160
|
-
selectors: selectors?.map(selector => ({ name: selector.apiName, script: selector.script })),
|
|
2161
|
-
});
|
|
2162
|
-
}), tap$1(stateId => (this.stateId = stateId || null)), map$1(() => undefined));
|
|
2180
|
+
let request$;
|
|
2181
|
+
if (this.flowStateService.stateId && this.isStatefulConfiguration) {
|
|
2182
|
+
request$ = this.initStateful$();
|
|
2183
|
+
}
|
|
2184
|
+
else {
|
|
2185
|
+
request$ = this.initStateless$();
|
|
2186
|
+
}
|
|
2187
|
+
return request$.pipe(finalize(() => this.isInitialized$.next(true)));
|
|
2163
2188
|
}
|
|
2164
2189
|
cleanup() {
|
|
2165
2190
|
this.stateId = null;
|
|
2166
2191
|
this.configurationService.reset();
|
|
2167
|
-
this.stateSubj$.next({});
|
|
2168
2192
|
}
|
|
2169
|
-
execute$(req) {
|
|
2193
|
+
execute$(req, forceSubscriptions) {
|
|
2194
|
+
const fullRequest = cloneDeep(req);
|
|
2195
|
+
if (fullRequest.actions?.length || forceSubscriptions) {
|
|
2196
|
+
for (const subscription of Object.values(this.subscriptions)) {
|
|
2197
|
+
fullRequest.selectors = assign(fullRequest.selectors, subscription.request.selectors);
|
|
2198
|
+
}
|
|
2199
|
+
}
|
|
2200
|
+
let execution$;
|
|
2170
2201
|
if (this.isStatefulConfiguration) {
|
|
2171
|
-
|
|
2202
|
+
execution$ = this.executeStateful$(fullRequest);
|
|
2172
2203
|
}
|
|
2173
2204
|
else {
|
|
2174
|
-
|
|
2205
|
+
execution$ = this.executeStateless$(fullRequest);
|
|
2175
2206
|
}
|
|
2207
|
+
return execution$.pipe(tap$1(result => this.handleSelectorsResponse(result.selectors)));
|
|
2208
|
+
}
|
|
2209
|
+
handleSelectorsResponse(selectors) {
|
|
2210
|
+
Object.entries(selectors).forEach(([requestId, selectorResult]) => {
|
|
2211
|
+
if (!selectorResult.success) {
|
|
2212
|
+
this.toastService.add({ severity: ToastType.error, summary: selectorResult.errorMessage });
|
|
2213
|
+
}
|
|
2214
|
+
const subscription$ = this.subscriptions[requestId]?.data$;
|
|
2215
|
+
if (subscription$) {
|
|
2216
|
+
subscription$.next(selectorResult);
|
|
2217
|
+
}
|
|
2218
|
+
});
|
|
2176
2219
|
}
|
|
2177
|
-
dispatch$(actionName, inputData) {
|
|
2178
|
-
return this.execute$({ actions: [{
|
|
2220
|
+
dispatch$(actionName, inputData = {}) {
|
|
2221
|
+
return this.execute$({ actions: [{ apiName: actionName, inputData, ownerId: this.ownerId }] });
|
|
2179
2222
|
}
|
|
2180
|
-
select$(selectorName, inputData) {
|
|
2223
|
+
select$(selectorName, inputData = {}) {
|
|
2181
2224
|
const requestId = UUID.UUID();
|
|
2182
2225
|
return this.execute$({
|
|
2183
2226
|
selectors: {
|
|
2184
2227
|
[requestId]: {
|
|
2185
|
-
|
|
2228
|
+
apiName: selectorName,
|
|
2186
2229
|
inputData,
|
|
2230
|
+
ownerId: this.ownerId,
|
|
2187
2231
|
},
|
|
2188
2232
|
},
|
|
2189
|
-
}).pipe(map$1(
|
|
2233
|
+
}).pipe(map$1(response => response.selectors[requestId]));
|
|
2234
|
+
}
|
|
2235
|
+
subscribe$(selectorName, inputData = {}, options) {
|
|
2236
|
+
const requestId = UUID.UUID();
|
|
2237
|
+
if (!this.subscriptions[requestId]) {
|
|
2238
|
+
const request = {
|
|
2239
|
+
selectors: {
|
|
2240
|
+
[requestId]: {
|
|
2241
|
+
apiName: selectorName,
|
|
2242
|
+
inputData,
|
|
2243
|
+
ownerId: this.ownerId,
|
|
2244
|
+
},
|
|
2245
|
+
},
|
|
2246
|
+
};
|
|
2247
|
+
this.subscriptions[requestId] = {
|
|
2248
|
+
request,
|
|
2249
|
+
data$: new BehaviorSubject(this.NOT_INITIALIZED),
|
|
2250
|
+
};
|
|
2251
|
+
if (!options?.cold) {
|
|
2252
|
+
this.execute$(request).subscribe();
|
|
2253
|
+
}
|
|
2254
|
+
}
|
|
2255
|
+
return this.subscriptions[requestId].data$.pipe(filter$1(data => data != this.NOT_INITIALIZED), map$1(data => data), finalize(() => {
|
|
2256
|
+
if (!this.subscriptions[requestId].data$.observed) {
|
|
2257
|
+
delete this.subscriptions[requestId];
|
|
2258
|
+
}
|
|
2259
|
+
}));
|
|
2260
|
+
}
|
|
2261
|
+
saveConfiguration(quoteId, flow) {
|
|
2262
|
+
if (this.isStatefulConfiguration) {
|
|
2263
|
+
return this.flowStateApiService
|
|
2264
|
+
.saveConfiguration(this.flowStateService.stateId ?? '', this.stateId ?? '')
|
|
2265
|
+
.pipe(switchMap(r => this.flowStateService.executeRequest$({}, true).pipe(map$1(() => r))));
|
|
2266
|
+
}
|
|
2267
|
+
else {
|
|
2268
|
+
if (!flow) {
|
|
2269
|
+
if (!quoteId) {
|
|
2270
|
+
return of({ quoteId: '' });
|
|
2271
|
+
}
|
|
2272
|
+
const rootLineItem = this.configurationService.getSnapshot();
|
|
2273
|
+
const currentState = rootLineItem ? [rootLineItem] : [];
|
|
2274
|
+
return this.quoteApiService
|
|
2275
|
+
.getQuoteDraft(quoteId)
|
|
2276
|
+
.pipe(switchMap(quoteDraft => this.quoteApiService.upsertQuote({ ...quoteDraft, currentState })));
|
|
2277
|
+
}
|
|
2278
|
+
else {
|
|
2279
|
+
const quoteDraft = this.quoteDraftService.quoteDraft;
|
|
2280
|
+
const lineItem = this.configurationService.getSnapshot();
|
|
2281
|
+
if (!quoteDraft || !lineItem) {
|
|
2282
|
+
return of({ quoteId: '' });
|
|
2283
|
+
}
|
|
2284
|
+
const isNewLineItem = quoteDraft.currentState.every(li => li.id !== lineItem.id);
|
|
2285
|
+
let updatedState;
|
|
2286
|
+
if (isNewLineItem) {
|
|
2287
|
+
updatedState = [...quoteDraft.currentState, lineItem];
|
|
2288
|
+
}
|
|
2289
|
+
else {
|
|
2290
|
+
updatedState = quoteDraft.currentState.map(li => (li.id === lineItem.id ? lineItem : li));
|
|
2291
|
+
}
|
|
2292
|
+
return this.flowConfigurationService
|
|
2293
|
+
.calculate$({ ...quoteDraft, currentState: updatedState })
|
|
2294
|
+
.pipe(map$1(() => ({ quoteId: '' })));
|
|
2295
|
+
}
|
|
2296
|
+
}
|
|
2297
|
+
}
|
|
2298
|
+
cancelConfiguration() {
|
|
2299
|
+
if (!this.isInitialized$.value) {
|
|
2300
|
+
return of(undefined);
|
|
2301
|
+
}
|
|
2302
|
+
this.isInitialized$.next(false);
|
|
2303
|
+
if (!this.isInitialized$.value || !this.isStatefulConfiguration) {
|
|
2304
|
+
return of(undefined);
|
|
2305
|
+
}
|
|
2306
|
+
return this.flowStateApiService.cancelConfiguration(this.flowStateService.stateId ?? '', this.stateId ?? '');
|
|
2190
2307
|
}
|
|
2191
2308
|
get isStatefulConfiguration() {
|
|
2192
|
-
return this.
|
|
2309
|
+
return this.flowInfoService.flow?.properties.stateful ?? false;
|
|
2310
|
+
}
|
|
2311
|
+
initStateful$() {
|
|
2312
|
+
this.ownerId = this.configurationRuntimeService.runtimeContext?.uiDefinitionContainer?.id ?? '';
|
|
2313
|
+
const lineItemId = this.configurationRuntimeService.runtimeContext?.properties?.lineItemId;
|
|
2314
|
+
if (!this.flowStateService.stateId) {
|
|
2315
|
+
return of(undefined);
|
|
2316
|
+
}
|
|
2317
|
+
const container = this.configurationRuntimeService.runtimeContext?.uiDefinitionContainer;
|
|
2318
|
+
const lineItem = this.configurationService.generateLineItem();
|
|
2319
|
+
let request$;
|
|
2320
|
+
if (!lineItemId) {
|
|
2321
|
+
request$ = this.flowStateApiService.newConfiguration(this.flowStateService.stateId, {
|
|
2322
|
+
lineItem,
|
|
2323
|
+
actionsOverride: container?.actions?.map(processor => ({ ...processor, ownerId: this.ownerId })),
|
|
2324
|
+
selectorsOverride: container?.selectors?.map(processor => ({ ...processor, ownerId: this.ownerId })),
|
|
2325
|
+
});
|
|
2326
|
+
}
|
|
2327
|
+
else {
|
|
2328
|
+
request$ = this.flowStateApiService.startConfiguration(this.flowStateService.stateId, {
|
|
2329
|
+
lineItemId,
|
|
2330
|
+
actionsOverride: container?.actions?.map(processor => ({ ...processor, ownerId: this.ownerId })),
|
|
2331
|
+
selectorsOverride: container?.selectors?.map(processor => ({ ...processor, ownerId: this.ownerId })),
|
|
2332
|
+
});
|
|
2333
|
+
}
|
|
2334
|
+
return request$.pipe(map$1(r => {
|
|
2335
|
+
this.stateId = r.stateId;
|
|
2336
|
+
return undefined;
|
|
2337
|
+
}));
|
|
2338
|
+
}
|
|
2339
|
+
initStateless$() {
|
|
2340
|
+
return this.configurationService.configure().pipe(map$1(() => undefined));
|
|
2193
2341
|
}
|
|
2194
2342
|
executeStateless$(request) {
|
|
2195
2343
|
return of(undefined).pipe(switchMap(() => {
|
|
@@ -2203,52 +2351,46 @@ class ConfigurationState {
|
|
|
2203
2351
|
configurationRequest = this.executeActionScript(configurationRequest, action) ?? configurationRequest;
|
|
2204
2352
|
});
|
|
2205
2353
|
return this.configurationService.configureRequest$(configurationRequest);
|
|
2206
|
-
}),
|
|
2207
|
-
if (!request.selectors) {
|
|
2208
|
-
return;
|
|
2209
|
-
}
|
|
2354
|
+
}), map$1(() => {
|
|
2210
2355
|
// Run selectors and apply them to the state
|
|
2211
|
-
const finalConfigurationRequest = this.configurationService.generateRequest();
|
|
2212
|
-
const selectorsResult = EntityUtil.entries(request.selectors).reduce((
|
|
2213
|
-
|
|
2214
|
-
|
|
2215
|
-
|
|
2216
|
-
|
|
2217
|
-
|
|
2218
|
-
|
|
2219
|
-
|
|
2220
|
-
|
|
2356
|
+
const finalConfigurationRequest = this.configurationService.generateRequest(false);
|
|
2357
|
+
const selectorsResult = EntityUtil.entries(request.selectors ?? {}).reduce((result, [key, selector]) => {
|
|
2358
|
+
try {
|
|
2359
|
+
result.selectors[key] = {
|
|
2360
|
+
success: true,
|
|
2361
|
+
result: this.executeSelectorScript(finalConfigurationRequest, selector),
|
|
2362
|
+
};
|
|
2363
|
+
}
|
|
2364
|
+
catch (e) {
|
|
2365
|
+
result.selectors[key] = {
|
|
2366
|
+
success: false,
|
|
2367
|
+
errorMessage: String(e),
|
|
2368
|
+
};
|
|
2369
|
+
}
|
|
2370
|
+
return result;
|
|
2371
|
+
}, { stateId: '', selectors: {} });
|
|
2372
|
+
return selectorsResult;
|
|
2373
|
+
}));
|
|
2221
2374
|
}
|
|
2222
2375
|
executeStateful$(request) {
|
|
2223
|
-
if (!this.stateId) {
|
|
2224
|
-
return of(
|
|
2376
|
+
if (!this.flowStateService.stateId || !this.stateId) {
|
|
2377
|
+
return of();
|
|
2225
2378
|
}
|
|
2226
|
-
return this.
|
|
2379
|
+
return this.flowStateApiService.executeConfiguration(this.flowStateService.stateId, this.stateId, request).pipe(tap$1(response => {
|
|
2227
2380
|
this.stateId = response.stateId;
|
|
2228
|
-
|
|
2229
|
-
EntityUtil.entries(response.selectors).forEach(([key, value]) => {
|
|
2230
|
-
if (!value.success) {
|
|
2231
|
-
if (!this.runtimeService.uiDefinitionProperties.suppressToastMessages) {
|
|
2232
|
-
this.toastService.add({ summary: value.errorMessage, severity: ToastType.error });
|
|
2233
|
-
}
|
|
2234
|
-
return;
|
|
2235
|
-
}
|
|
2236
|
-
updatedState[key] = value.result;
|
|
2237
|
-
});
|
|
2238
|
-
this.stateSubj$.next(updatedState);
|
|
2239
|
-
}), map$1(() => undefined));
|
|
2381
|
+
}));
|
|
2240
2382
|
}
|
|
2241
2383
|
executeActionScript(request, processor) {
|
|
2242
|
-
const { actions } = this.
|
|
2243
|
-
const script = actions?.find(action => action.apiName === processor.
|
|
2384
|
+
const { actions } = this.configurationRuntimeService.runtimeContext?.uiDefinitionContainer ?? {};
|
|
2385
|
+
const script = actions?.find(action => action.apiName === processor.apiName)?.script;
|
|
2244
2386
|
if (!script) {
|
|
2245
|
-
return
|
|
2387
|
+
return request;
|
|
2246
2388
|
}
|
|
2247
2389
|
return this.executeProcessorScript(request, script, processor.inputData);
|
|
2248
2390
|
}
|
|
2249
2391
|
executeSelectorScript(request, processor) {
|
|
2250
|
-
const { selectors } = this.
|
|
2251
|
-
const script = selectors?.find(selector => selector.apiName === processor.
|
|
2392
|
+
const { selectors } = this.configurationRuntimeService.runtimeContext?.uiDefinitionContainer ?? {};
|
|
2393
|
+
const script = selectors?.find(selector => selector.apiName === processor.apiName)?.script;
|
|
2252
2394
|
if (!script) {
|
|
2253
2395
|
return null;
|
|
2254
2396
|
}
|
|
@@ -2261,11 +2403,11 @@ class ConfigurationState {
|
|
|
2261
2403
|
});
|
|
2262
2404
|
}
|
|
2263
2405
|
}
|
|
2264
|
-
|
|
2265
|
-
|
|
2266
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type:
|
|
2406
|
+
ConfigurationStateService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: ConfigurationStateService, deps: [{ token: ConfigurationRuntimeService }, { token: ConfigurationService }, { token: QuoteDraftService }, { token: i6.ToastService }, { token: FlowStateService }, { token: FlowInfoService }, { token: FlowConfigurationService }, { token: i1.FlowStateApiService }, { token: i1.QuoteApiService }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
2407
|
+
ConfigurationStateService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: ConfigurationStateService });
|
|
2408
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: ConfigurationStateService, decorators: [{
|
|
2267
2409
|
type: Injectable
|
|
2268
|
-
}], ctorParameters: function () { return [{ type:
|
|
2410
|
+
}], ctorParameters: function () { return [{ type: ConfigurationRuntimeService }, { type: ConfigurationService }, { type: QuoteDraftService }, { type: i6.ToastService }, { type: FlowStateService }, { type: FlowInfoService }, { type: FlowConfigurationService }, { type: i1.FlowStateApiService }, { type: i1.QuoteApiService }]; } });
|
|
2269
2411
|
|
|
2270
2412
|
class ConfigurationModule {
|
|
2271
2413
|
}
|
|
@@ -2278,7 +2420,7 @@ ConfigurationModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", ver
|
|
|
2278
2420
|
ConfigurationRuntimeService,
|
|
2279
2421
|
RuntimeContextService,
|
|
2280
2422
|
ConfigurationService,
|
|
2281
|
-
|
|
2423
|
+
ConfigurationStateService,
|
|
2282
2424
|
], imports: [ConfirmationDialogModule] });
|
|
2283
2425
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: ConfigurationModule, decorators: [{
|
|
2284
2426
|
type: NgModule,
|
|
@@ -2291,7 +2433,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImpor
|
|
|
2291
2433
|
ConfigurationRuntimeService,
|
|
2292
2434
|
RuntimeContextService,
|
|
2293
2435
|
ConfigurationService,
|
|
2294
|
-
|
|
2436
|
+
ConfigurationStateService,
|
|
2295
2437
|
],
|
|
2296
2438
|
}]
|
|
2297
2439
|
}] });
|
|
@@ -2310,7 +2452,6 @@ SdkCoreModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "
|
|
|
2310
2452
|
SdkCoreModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "15.2.9", ngImport: i0, type: SdkCoreModule, imports: [ConfigurationModule, FlowConfigurationModule] });
|
|
2311
2453
|
SdkCoreModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: SdkCoreModule, providers: [
|
|
2312
2454
|
IntegrationState,
|
|
2313
|
-
FlowStateService,
|
|
2314
2455
|
{
|
|
2315
2456
|
provide: FORMATTING_SETTINGS_TOKEN,
|
|
2316
2457
|
useExisting: RuntimeSettingsService,
|
|
@@ -2322,7 +2463,6 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImpor
|
|
|
2322
2463
|
imports: [ConfigurationModule, FlowConfigurationModule],
|
|
2323
2464
|
providers: [
|
|
2324
2465
|
IntegrationState,
|
|
2325
|
-
FlowStateService,
|
|
2326
2466
|
{
|
|
2327
2467
|
provide: FORMATTING_SETTINGS_TOKEN,
|
|
2328
2468
|
useExisting: RuntimeSettingsService,
|
|
@@ -2497,5 +2637,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImpor
|
|
|
2497
2637
|
* Generated bundle index. Do not edit.
|
|
2498
2638
|
*/
|
|
2499
2639
|
|
|
2500
|
-
export { ActionCodePipe, CalendarDirective, ConfigurationRuntimeService, ConfigurationService,
|
|
2640
|
+
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 };
|
|
2501
2641
|
//# sourceMappingURL=veloceapps-sdk-core.mjs.map
|