@veloceapps/sdk 11.0.0-124 → 11.0.0-126
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/vendor-map.d.ts +1 -0
- package/core/modules/configuration/services/configuration-state.service.d.ts +3 -2
- package/core/services/flow-state-configuration.service.d.ts +3 -1
- package/core/utils/transaction-item.utils.d.ts +3 -2
- package/esm2020/cms/vendor-map.mjs +3 -2
- package/esm2020/core/modules/configuration/services/configuration-state.service.mjs +14 -11
- package/esm2020/core/modules/configuration/services/configuration.service.mjs +3 -2
- package/esm2020/core/services/flow-state-configuration.service.mjs +38 -32
- package/esm2020/core/utils/transaction-item.utils.mjs +47 -4
- package/fesm2015/veloceapps-sdk-cms.mjs +2 -1
- package/fesm2015/veloceapps-sdk-cms.mjs.map +1 -1
- package/fesm2015/veloceapps-sdk-core.mjs +91 -36
- package/fesm2015/veloceapps-sdk-core.mjs.map +1 -1
- package/fesm2020/veloceapps-sdk-cms.mjs +2 -1
- package/fesm2020/veloceapps-sdk-cms.mjs.map +1 -1
- package/fesm2020/veloceapps-sdk-core.mjs +94 -43
- package/fesm2020/veloceapps-sdk-core.mjs.map +1 -1
- package/package.json +1 -1
@@ -333,11 +333,54 @@ const replaceTransactionItem = (item, replaceTo) => {
|
|
333
333
|
children: item.children.map(ti => replaceTransactionItem(ti, replaceTo)),
|
334
334
|
};
|
335
335
|
};
|
336
|
-
const generateTransactionItem = (
|
337
|
-
|
336
|
+
const generateTransactionItem = (pcm, salesTransactionId) => {
|
337
|
+
const defaultSTI = {
|
338
338
|
id: UUID.UUID(),
|
339
|
-
productId,
|
339
|
+
productId: pcm.id,
|
340
|
+
};
|
341
|
+
const defaultChildren = pcm.productComponentGroups.reduce((acc, group) => {
|
342
|
+
group.components.forEach(component => {
|
343
|
+
const { isComponentRequired, isDefaultComponent } = component.productRelatedComponent ?? {};
|
344
|
+
if (isComponentRequired || isDefaultComponent) {
|
345
|
+
acc.push(generateTransactionItemFromPCM(component, defaultSTI, salesTransactionId));
|
346
|
+
}
|
347
|
+
});
|
348
|
+
return acc;
|
349
|
+
}, []);
|
350
|
+
if (!defaultChildren.length) {
|
351
|
+
return defaultSTI;
|
352
|
+
}
|
353
|
+
return { ...defaultSTI, children: defaultChildren };
|
354
|
+
};
|
355
|
+
const generateTransactionItemFromPCM = (option, parentTi, salesTransactionId) => {
|
356
|
+
const childId = UUID.UUID();
|
357
|
+
const newItem = {
|
358
|
+
id: childId,
|
359
|
+
productId: option.id,
|
360
|
+
productName: option.name,
|
361
|
+
productCode: option.productCode,
|
362
|
+
productRelatedComponentId: option.productRelatedComponent?.id,
|
363
|
+
stiAttributes: [],
|
364
|
+
attributes: {
|
365
|
+
ParentReference: salesTransactionId,
|
366
|
+
ItemPath: option.id,
|
367
|
+
SalesTransactionItemSource: childId,
|
368
|
+
SalesTransactionItemParent: salesTransactionId,
|
369
|
+
ProductSellingModel: option.productSellingModelOptions?.[0]?.productSellingModel.id,
|
370
|
+
},
|
371
|
+
parentId: parentTi.id,
|
372
|
+
qty: option.productRelatedComponent?.quantity ?? 1,
|
340
373
|
};
|
374
|
+
newItem.children = option.productComponentGroups.reduce((acc, group) => {
|
375
|
+
group.components.forEach(component => {
|
376
|
+
if (component.productRelatedComponent?.isComponentRequired ||
|
377
|
+
component.productRelatedComponent?.isDefaultComponent) {
|
378
|
+
acc.push(generateTransactionItemFromPCM(component, newItem, salesTransactionId));
|
379
|
+
}
|
380
|
+
});
|
381
|
+
return acc;
|
382
|
+
}, []);
|
383
|
+
return newItem;
|
341
384
|
};
|
342
385
|
|
343
386
|
class TransactionItemWorker {
|
@@ -467,7 +510,7 @@ class ConfigurationService {
|
|
467
510
|
transactionItem = salesTransactionItems.find(item => item.productId === productId);
|
468
511
|
}
|
469
512
|
if (!transactionItem) {
|
470
|
-
transactionItem = generateTransactionItem(
|
513
|
+
transactionItem = generateTransactionItem(this.getPCMModel(), this.state?.salesTransaction.id);
|
471
514
|
if (typeof newProductQty === 'number' && newProductQty > 0) {
|
472
515
|
transactionItem.qty = newProductQty;
|
473
516
|
}
|
@@ -550,6 +593,7 @@ class ConfigurationService {
|
|
550
593
|
})));
|
551
594
|
}
|
552
595
|
getPCMModel() {
|
596
|
+
console.log('GET PCM');
|
553
597
|
const pcmModel = this.configurationRuntimeService.pcmModel;
|
554
598
|
if (!pcmModel) {
|
555
599
|
throw new Error('PCM model not initialized');
|
@@ -1179,14 +1223,16 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImpor
|
|
1179
1223
|
}] }]; } });
|
1180
1224
|
|
1181
1225
|
class FlowStateConfigurationService {
|
1182
|
-
constructor(flowInfoService, flowStateService, configurationService, salesTransactionService, flowConfigurationService) {
|
1226
|
+
constructor(flowInfoService, flowStateService, configurationService, salesTransactionService, flowConfigurationService, pcmApiService) {
|
1183
1227
|
this.flowInfoService = flowInfoService;
|
1184
1228
|
this.flowStateService = flowStateService;
|
1185
1229
|
this.configurationService = configurationService;
|
1186
1230
|
this.salesTransactionService = salesTransactionService;
|
1187
1231
|
this.flowConfigurationService = flowConfigurationService;
|
1232
|
+
this.pcmApiService = pcmApiService;
|
1188
1233
|
}
|
1189
1234
|
addToCart$(props) {
|
1235
|
+
console.log(props);
|
1190
1236
|
let request$;
|
1191
1237
|
const stateful = this.flowInfoService.flow?.properties.stateful;
|
1192
1238
|
if (stateful) {
|
@@ -1205,47 +1251,49 @@ class FlowStateConfigurationService {
|
|
1205
1251
|
return request$.pipe(switchMap(() => this.flowStateService.executeRequest$({}, true)), map(noop));
|
1206
1252
|
}
|
1207
1253
|
configureExternal$(props) {
|
1208
|
-
|
1209
|
-
|
1210
|
-
|
1211
|
-
}
|
1212
|
-
const stateToConfigure = {
|
1213
|
-
...state,
|
1214
|
-
salesTransaction: {
|
1215
|
-
...state.salesTransaction,
|
1216
|
-
salesTransactionItems: [
|
1217
|
-
{
|
1218
|
-
...generateTransactionItem(props.productId),
|
1219
|
-
qty: props.qty ?? 1,
|
1220
|
-
stiAttributes: Object.entries(props.attributesMap ?? {}).map(([attributeName, value]) => ({
|
1221
|
-
attributeName,
|
1222
|
-
value,
|
1223
|
-
})),
|
1224
|
-
},
|
1225
|
-
],
|
1226
|
-
},
|
1227
|
-
};
|
1228
|
-
return this.configurationService.justConfigureRequest$(stateToConfigure).pipe(switchMap(configurationResult => {
|
1229
|
-
const state = this.salesTransactionService.state;
|
1230
|
-
const addedProduct = configurationResult.salesTransaction.salesTransactionItems[0];
|
1231
|
-
if (!state || !addedProduct) {
|
1254
|
+
return this.pcmApiService.fetchPCMByProductId(props.productId).pipe(switchMap(pcm => {
|
1255
|
+
const { state } = this.salesTransactionService;
|
1256
|
+
if (!state) {
|
1232
1257
|
return of();
|
1233
1258
|
}
|
1234
|
-
|
1259
|
+
const stateToConfigure = {
|
1235
1260
|
...state,
|
1236
1261
|
salesTransaction: {
|
1237
1262
|
...state.salesTransaction,
|
1238
|
-
salesTransactionItems: [
|
1263
|
+
salesTransactionItems: [
|
1264
|
+
{
|
1265
|
+
...generateTransactionItem(pcm, this.configurationService.state?.salesTransaction.id),
|
1266
|
+
qty: props.qty ?? 1,
|
1267
|
+
stiAttributes: Object.entries(props.attributesMap ?? {}).map(([attributeName, value]) => ({
|
1268
|
+
attributeName,
|
1269
|
+
value,
|
1270
|
+
})),
|
1271
|
+
},
|
1272
|
+
],
|
1239
1273
|
},
|
1240
|
-
}
|
1274
|
+
};
|
1275
|
+
return this.configurationService.justConfigureRequest$(stateToConfigure).pipe(switchMap(configurationResult => {
|
1276
|
+
const state = this.salesTransactionService.state;
|
1277
|
+
const addedProduct = configurationResult.salesTransaction.salesTransactionItems[0];
|
1278
|
+
if (!state || !addedProduct) {
|
1279
|
+
return of();
|
1280
|
+
}
|
1281
|
+
return this.flowConfigurationService.calculate$({
|
1282
|
+
...state,
|
1283
|
+
salesTransaction: {
|
1284
|
+
...state.salesTransaction,
|
1285
|
+
salesTransactionItems: [...state.salesTransaction.salesTransactionItems, addedProduct],
|
1286
|
+
},
|
1287
|
+
});
|
1288
|
+
}));
|
1241
1289
|
}));
|
1242
1290
|
}
|
1243
1291
|
}
|
1244
|
-
FlowStateConfigurationService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: FlowStateConfigurationService, deps: [{ token: FlowInfoService }, { token: FlowStateService }, { token: ConfigurationService }, { token: SalesTransactionService }, { token: FlowConfigurationService }], target: i0.ɵɵFactoryTarget.Injectable });
|
1292
|
+
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 });
|
1245
1293
|
FlowStateConfigurationService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: FlowStateConfigurationService });
|
1246
1294
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: FlowStateConfigurationService, decorators: [{
|
1247
1295
|
type: Injectable
|
1248
|
-
}], ctorParameters: function () { return [{ type: FlowInfoService }, { type: FlowStateService }, { type: ConfigurationService }, { type: SalesTransactionService }, { type: FlowConfigurationService }]; } });
|
1296
|
+
}], ctorParameters: function () { return [{ type: FlowInfoService }, { type: FlowStateService }, { type: ConfigurationService }, { type: SalesTransactionService }, { type: FlowConfigurationService }, { type: i1.PCMApiService }]; } });
|
1249
1297
|
|
1250
1298
|
class IntegrationState {
|
1251
1299
|
constructor() {
|
@@ -1327,7 +1375,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImpor
|
|
1327
1375
|
}] });
|
1328
1376
|
|
1329
1377
|
class ConfigurationStateService {
|
1330
|
-
constructor(configurationRuntimeService, configurationService, flowStateService, flowInfoService, flowConfigurationService, flowStateApiService, salesTransactionService, salesTransactionApiService, toastService) {
|
1378
|
+
constructor(configurationRuntimeService, configurationService, flowStateService, flowInfoService, flowConfigurationService, flowStateApiService, salesTransactionService, salesTransactionApiService, toastService, pcmApiService) {
|
1331
1379
|
this.configurationRuntimeService = configurationRuntimeService;
|
1332
1380
|
this.configurationService = configurationService;
|
1333
1381
|
this.flowStateService = flowStateService;
|
@@ -1337,6 +1385,7 @@ class ConfigurationStateService {
|
|
1337
1385
|
this.salesTransactionService = salesTransactionService;
|
1338
1386
|
this.salesTransactionApiService = salesTransactionApiService;
|
1339
1387
|
this.toastService = toastService;
|
1388
|
+
this.pcmApiService = pcmApiService;
|
1340
1389
|
this.isInitialized$ = new BehaviorSubject(false);
|
1341
1390
|
this.canceledConfiguration$ = new Subject();
|
1342
1391
|
this.NOT_INITIALIZED = Symbol();
|
@@ -1509,11 +1558,13 @@ class ConfigurationStateService {
|
|
1509
1558
|
const container = this.configurationRuntimeService.uiDefinitionContainer;
|
1510
1559
|
let request$;
|
1511
1560
|
if (!transactionItemId) {
|
1512
|
-
request$ = this.
|
1513
|
-
|
1514
|
-
|
1515
|
-
|
1516
|
-
|
1561
|
+
request$ = this.pcmApiService.fetchPCMByProductId(productId).pipe(switchMap(pcm => {
|
1562
|
+
return this.flowStateApiService.newConfiguration(this.flowStateService.stateId || '', {
|
1563
|
+
transactionItem: generateTransactionItem(pcm, this.configurationService.state?.salesTransaction.id),
|
1564
|
+
actionsOverride: container?.actions?.map(processor => ({ ...processor, ownerId: this.ownerId })),
|
1565
|
+
selectorsOverride: container?.selectors?.map(processor => ({ ...processor, ownerId: this.ownerId })),
|
1566
|
+
});
|
1567
|
+
}));
|
1517
1568
|
}
|
1518
1569
|
else {
|
1519
1570
|
request$ = this.flowStateApiService.startConfiguration(this.flowStateService.stateId, {
|
@@ -1678,11 +1729,11 @@ class ConfigurationStateService {
|
|
1678
1729
|
}, { stateId: '', selectors: {} });
|
1679
1730
|
}
|
1680
1731
|
}
|
1681
|
-
ConfigurationStateService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: ConfigurationStateService, deps: [{ token: ConfigurationRuntimeService }, { token: ConfigurationService }, { token: FlowStateService }, { token: FlowInfoService }, { token: FlowConfigurationService }, { token: i3.FlowStateApiService }, { token: SalesTransactionService }, { token: i1.SalesTransactionApiService }, { token: i6.ToastService }], target: i0.ɵɵFactoryTarget.Injectable });
|
1732
|
+
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 });
|
1682
1733
|
ConfigurationStateService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: ConfigurationStateService });
|
1683
1734
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: ConfigurationStateService, decorators: [{
|
1684
1735
|
type: Injectable
|
1685
|
-
}], ctorParameters: function () { return [{ type: ConfigurationRuntimeService }, { type: ConfigurationService }, { type: FlowStateService }, { type: FlowInfoService }, { type: FlowConfigurationService }, { type: i3.FlowStateApiService }, { type: SalesTransactionService }, { type: i1.SalesTransactionApiService }, { type: i6.ToastService }]; } });
|
1736
|
+
}], 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 }]; } });
|
1686
1737
|
|
1687
1738
|
class ConfigurationModule {
|
1688
1739
|
}
|
@@ -1943,5 +1994,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImpor
|
|
1943
1994
|
* Generated bundle index. Do not edit.
|
1944
1995
|
*/
|
1945
1996
|
|
1946
|
-
export { ActionCodePipe, CalendarDirective, CatalogProductsService, ConfigurationRuntimeService, ConfigurationService, ConfigurationStateService, DEFAULT_FORMATTING_SETTINGS, DatePipe, FLOW_CUSTOMIZATION, FORMATTING_SETTINGS_TOKEN, FlowConfigurationService, FlowInfoService, FlowStateConfigurationService, FlowStateService, GuidedSellingService, IntegrationState, NumberPipe, PricePipe, ProductImagesService, RuntimeSettingsService, SalesTransactionService, SdkCoreModule, SdkDirectivesModule, SdkPipesModule, TestModeConfigurationService, TransactionItemWorker, UI_DEFINITION_VERSION, extractMetadata, filterSuccessfulExecute, findTransactionItem, findTransactionItemWithComparator, generateTransactionItem, insertTransactionItem, removeTransactionItem, replaceTransactionItem };
|
1997
|
+
export { ActionCodePipe, CalendarDirective, CatalogProductsService, ConfigurationRuntimeService, ConfigurationService, ConfigurationStateService, DEFAULT_FORMATTING_SETTINGS, DatePipe, FLOW_CUSTOMIZATION, FORMATTING_SETTINGS_TOKEN, FlowConfigurationService, FlowInfoService, FlowStateConfigurationService, FlowStateService, GuidedSellingService, IntegrationState, NumberPipe, PricePipe, ProductImagesService, RuntimeSettingsService, SalesTransactionService, SdkCoreModule, SdkDirectivesModule, SdkPipesModule, TestModeConfigurationService, TransactionItemWorker, UI_DEFINITION_VERSION, extractMetadata, filterSuccessfulExecute, findTransactionItem, findTransactionItemWithComparator, generateTransactionItem, generateTransactionItemFromPCM, insertTransactionItem, removeTransactionItem, replaceTransactionItem };
|
1947
1998
|
//# sourceMappingURL=veloceapps-sdk-core.mjs.map
|