@veloceapps/sdk 11.0.0-82 → 11.0.0-84

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.
Files changed (29) hide show
  1. package/cms/vendor-map.d.ts +2 -1
  2. package/core/modules/configuration/index.d.ts +1 -0
  3. package/core/modules/configuration/services/configuration.service.d.ts +4 -6
  4. package/core/modules/configuration/services/guided-selling.service.d.ts +13 -0
  5. package/core/services/flow-state-configuration.service.d.ts +8 -1
  6. package/esm2020/cms/vendor-map.mjs +3 -2
  7. package/esm2020/core/modules/configuration/configuration.module.mjs +4 -1
  8. package/esm2020/core/modules/configuration/index.mjs +2 -1
  9. package/esm2020/core/modules/configuration/services/configuration-state.service.mjs +3 -3
  10. package/esm2020/core/modules/configuration/services/configuration.service.mjs +29 -32
  11. package/esm2020/core/modules/configuration/services/guided-selling.service.mjs +47 -0
  12. package/esm2020/core/modules/configuration/services/test-mode-configuration.service.mjs +2 -2
  13. package/esm2020/core/services/flow-state-configuration.service.mjs +48 -6
  14. package/esm2020/core/services/flow-state.service.mjs +2 -2
  15. package/esm2020/src/services/flow-dialog.service.mjs +3 -24
  16. package/fesm2015/veloceapps-sdk-cms.mjs +2 -1
  17. package/fesm2015/veloceapps-sdk-cms.mjs.map +1 -1
  18. package/fesm2015/veloceapps-sdk-core.mjs +101 -40
  19. package/fesm2015/veloceapps-sdk-core.mjs.map +1 -1
  20. package/fesm2015/veloceapps-sdk.mjs +2 -23
  21. package/fesm2015/veloceapps-sdk.mjs.map +1 -1
  22. package/fesm2020/veloceapps-sdk-cms.mjs +2 -1
  23. package/fesm2020/veloceapps-sdk-cms.mjs.map +1 -1
  24. package/fesm2020/veloceapps-sdk-core.mjs +179 -103
  25. package/fesm2020/veloceapps-sdk-core.mjs.map +1 -1
  26. package/fesm2020/veloceapps-sdk.mjs +2 -23
  27. package/fesm2020/veloceapps-sdk.mjs.map +1 -1
  28. package/package.json +1 -1
  29. package/src/services/flow-dialog.service.d.ts +1 -4
@@ -392,7 +392,7 @@ class TestModeConfigurationService {
392
392
  initConfiguration$(quoteId) {
393
393
  this.salesTransactionService.setState(this.getTestTransactionContext(quoteId));
394
394
  return this.configurationService.init$().pipe(switchMap(() => this.configurationService.state
395
- ? this.configurationService.configureRequest$(this.configurationService.state)
395
+ ? this.configurationService.configure$(this.configurationService.state)
396
396
  : of(undefined)), map(noop));
397
397
  }
398
398
  getTestTransactionContext(quoteId) {
@@ -421,6 +421,48 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImpor
421
421
  type: Injectable
422
422
  }], ctorParameters: function () { return [{ type: FlowInfoService }, { type: ConfigurationService }, { type: ConfigurationRuntimeService }, { type: SalesTransactionService }, { type: RuntimeSettingsService }]; } });
423
423
 
424
+ class GuidedSellingService {
425
+ constructor(orchestrationsApiService) {
426
+ this.orchestrationsApiService = orchestrationsApiService;
427
+ }
428
+ configureGuidedSelling$(data) {
429
+ return this.orchestrationsApiService.apply$({
430
+ transactionContext: this.getTransactionContext(data.attributesMap),
431
+ orchestrationName: data.orchestrationName,
432
+ });
433
+ }
434
+ getTransactionContext(guidedSellingAttributes) {
435
+ const testTransaction = {
436
+ id: UUID.UUID(),
437
+ businessObjectType: 'Quote',
438
+ salesTransactionItems: [],
439
+ tagAttributes: {},
440
+ };
441
+ return {
442
+ salesTransaction: testTransaction,
443
+ transactionId: UUID.UUID(),
444
+ businessObjectType: 'Quote',
445
+ childNodes: {
446
+ GuidedSelling: [
447
+ {
448
+ id: UUID.UUID(),
449
+ tagAttributes: {},
450
+ childNodes: {},
451
+ properties: { guidedSellingAttributes },
452
+ },
453
+ ],
454
+ },
455
+ id: UUID.UUID(),
456
+ tagAttributes: {},
457
+ };
458
+ }
459
+ }
460
+ GuidedSellingService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: GuidedSellingService, deps: [{ token: i1.OrchestrationsApiService }], target: i0.ɵɵFactoryTarget.Injectable });
461
+ GuidedSellingService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: GuidedSellingService });
462
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: GuidedSellingService, decorators: [{
463
+ type: Injectable
464
+ }], ctorParameters: function () { return [{ type: i1.OrchestrationsApiService }]; } });
465
+
424
466
  class SalesTransactionService {
425
467
  get isInitialized$() {
426
468
  return this.isInitializedSubj$.asObservable();
@@ -697,7 +739,7 @@ class FlowStateService {
697
739
  transactionContext: state,
698
740
  flowId: this.flowInfoService.flow.id,
699
741
  };
700
- return this.salesTransactionApiService.upsert(request).pipe(map(id => ({ id })));
742
+ return this.salesTransactionApiService.save(request).pipe(map(id => ({ id })));
701
743
  }
702
744
  }
703
745
  return of({ id: '' });
@@ -966,9 +1008,12 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImpor
966
1008
  } });
967
1009
 
968
1010
  class FlowStateConfigurationService {
969
- constructor(flowInfoService, flowStateService) {
1011
+ constructor(flowInfoService, flowStateService, configurationService, salesTransactionService, flowConfigurationService) {
970
1012
  this.flowInfoService = flowInfoService;
971
1013
  this.flowStateService = flowStateService;
1014
+ this.configurationService = configurationService;
1015
+ this.salesTransactionService = salesTransactionService;
1016
+ this.flowConfigurationService = flowConfigurationService;
972
1017
  }
973
1018
  addToCart$(props) {
974
1019
  var _a;
@@ -985,17 +1030,34 @@ class FlowStateConfigurationService {
985
1030
  }
986
1031
  }
987
1032
  else {
988
- // TODO: Implement
989
- request$ = of();
1033
+ request$ = this.configureExternal$(props);
990
1034
  }
991
1035
  return request$.pipe(switchMap(() => this.flowStateService.executeRequest$({}, true)), map(noop));
992
1036
  }
1037
+ configureExternal$(props) {
1038
+ var _a, _b;
1039
+ const { state } = this.salesTransactionService;
1040
+ if (!state) {
1041
+ return of();
1042
+ }
1043
+ const stateToConfigure = Object.assign(Object.assign({}, state), { salesTransaction: Object.assign(Object.assign({}, state.salesTransaction), { salesTransactionItems: [
1044
+ Object.assign(Object.assign({}, generateTransactionItem(props.productId)), { qty: (_a = props.qty) !== null && _a !== void 0 ? _a : 1, tagAttributes: (_b = props.attributesMap) !== null && _b !== void 0 ? _b : {} }),
1045
+ ] }) });
1046
+ return this.configurationService.justConfigureRequest$(stateToConfigure).pipe(switchMap(configurationResult => {
1047
+ const state = this.salesTransactionService.state;
1048
+ const addedProduct = configurationResult.salesTransaction.salesTransactionItems[0];
1049
+ if (!state || !addedProduct) {
1050
+ return of();
1051
+ }
1052
+ return this.flowConfigurationService.calculate$(Object.assign(Object.assign({}, state), { salesTransaction: Object.assign(Object.assign({}, state.salesTransaction), { salesTransactionItems: [...state.salesTransaction.salesTransactionItems, addedProduct] }) }));
1053
+ }));
1054
+ }
993
1055
  }
994
- FlowStateConfigurationService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: FlowStateConfigurationService, deps: [{ token: FlowInfoService }, { token: FlowStateService }], target: i0.ɵɵFactoryTarget.Injectable });
1056
+ 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 });
995
1057
  FlowStateConfigurationService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: FlowStateConfigurationService });
996
1058
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: FlowStateConfigurationService, decorators: [{
997
1059
  type: Injectable
998
- }], ctorParameters: function () { return [{ type: FlowInfoService }, { type: FlowStateService }]; } });
1060
+ }], ctorParameters: function () { return [{ type: FlowInfoService }, { type: FlowStateService }, { type: ConfigurationService }, { type: SalesTransactionService }, { type: FlowConfigurationService }]; } });
999
1061
 
1000
1062
  class IntegrationState {
1001
1063
  constructor() {
@@ -1077,6 +1139,18 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImpor
1077
1139
  }] });
1078
1140
 
1079
1141
  class ConfigurationService {
1142
+ constructor(flowInfoService, messageService, configurationRuntimeService, salesTransactionService, orchestrationsApiService) {
1143
+ this.flowInfoService = flowInfoService;
1144
+ this.messageService = messageService;
1145
+ this.configurationRuntimeService = configurationRuntimeService;
1146
+ this.salesTransactionService = salesTransactionService;
1147
+ this.orchestrationsApiService = orchestrationsApiService;
1148
+ this.hasUnsavedChanges = false;
1149
+ this.configurationStateSubj$ = new BehaviorSubject(null);
1150
+ this.previousConfigurationStateSubj$ = new BehaviorSubject(null);
1151
+ this.isLoadingSubj$ = new BehaviorSubject(false);
1152
+ this.isLoading$ = this.isLoadingSubj$.asObservable();
1153
+ }
1080
1154
  get state$() {
1081
1155
  return this.configurationStateSubj$.asObservable().pipe(filter$1(isDefined));
1082
1156
  }
@@ -1093,18 +1167,6 @@ class ConfigurationService {
1093
1167
  var _a, _b;
1094
1168
  return (_b = (_a = this.configurationStateSubj$.getValue()) === null || _a === void 0 ? void 0 : _a.salesTransaction.salesTransactionItems[0]) !== null && _b !== void 0 ? _b : null;
1095
1169
  }
1096
- constructor(flowInfoService, messageService, configurationRuntimeService, salesTransactionService, orchestrationsApiService) {
1097
- this.flowInfoService = flowInfoService;
1098
- this.messageService = messageService;
1099
- this.configurationRuntimeService = configurationRuntimeService;
1100
- this.salesTransactionService = salesTransactionService;
1101
- this.orchestrationsApiService = orchestrationsApiService;
1102
- this.hasUnsavedChanges = false;
1103
- this.configurationStateSubj$ = new BehaviorSubject(null);
1104
- this.previousConfigurationStateSubj$ = new BehaviorSubject(null);
1105
- this.isLoadingSubj$ = new BehaviorSubject(false);
1106
- this.isLoading$ = this.isLoadingSubj$.asObservable();
1107
- }
1108
1170
  reset() {
1109
1171
  this.hasUnsavedChanges = false;
1110
1172
  this.configurationStateSubj$.next(null);
@@ -1128,7 +1190,7 @@ class ConfigurationService {
1128
1190
  isRootGenerated = true;
1129
1191
  }
1130
1192
  const configurationState = Object.assign(Object.assign({}, state), { salesTransaction: Object.assign(Object.assign({}, state.salesTransaction), { salesTransactionItems: transactionItem ? [transactionItem] : [] }) });
1131
- return (isRootGenerated ? this.configureRequest$(configurationState) : of(configurationState)).pipe(tap$1(configurationState => {
1193
+ return (isRootGenerated ? this.configure$(configurationState) : of(configurationState)).pipe(tap$1(configurationState => {
1132
1194
  this.configurationStateSubj$.next(configurationState);
1133
1195
  this.previousConfigurationStateSubj$.next(configurationState);
1134
1196
  }), map$1(noop));
@@ -1143,7 +1205,7 @@ class ConfigurationService {
1143
1205
  }
1144
1206
  const newRoot = new TransactionItemWorker(root).replace(transactionItem).ti;
1145
1207
  const newTransactionContext = Object.assign(Object.assign({}, state), { salesTransaction: Object.assign(Object.assign({}, state.salesTransaction), { salesTransactionItems: [newRoot] }) });
1146
- return this.configureRequest$(newTransactionContext).pipe(catchError$1(error => {
1208
+ return this.configure$(newTransactionContext).pipe(catchError$1(error => {
1147
1209
  console.error(error);
1148
1210
  if (!this.configurationRuntimeService.uiDefinitionProps.suppressToastMessages) {
1149
1211
  this.messageService.add({ severity: 'error', summary: error });
@@ -1158,34 +1220,31 @@ class ConfigurationService {
1158
1220
  patch(transactionItem) {
1159
1221
  this.patch$(transactionItem).subscribe();
1160
1222
  }
1161
- configureRequest$(transactionContext) {
1162
- const request = {
1163
- transactionContext,
1164
- flowId: this.flowInfoService.flow.id,
1165
- };
1223
+ configure$(transactionContext) {
1166
1224
  this.isLoadingSubj$.next(true);
1167
- return this.orchestrationsApiService.apply$(request).pipe(tap$1(result => {
1225
+ return this.justConfigureRequest$(transactionContext).pipe(tap$1(result => {
1168
1226
  this.configurationStateSubj$.next(result);
1169
1227
  this.previousConfigurationStateSubj$.next(cloneDeep(result));
1170
- }), catchError$1(error => throwError(() => {
1228
+ }), catchError$1(e => {
1171
1229
  const resetState = this.previousConfigurationStateSubj$.getValue();
1172
1230
  if (resetState) {
1173
1231
  this.previousConfigurationStateSubj$.next(cloneDeep(resetState));
1174
1232
  this.configurationStateSubj$.next(resetState);
1175
1233
  }
1234
+ return throwError(() => e);
1235
+ }), finalize$1(() => this.isLoadingSubj$.next(false)));
1236
+ }
1237
+ justConfigureRequest$(transactionContext) {
1238
+ const request = {
1239
+ transactionContext,
1240
+ flowId: this.flowInfoService.flow.id,
1241
+ };
1242
+ return this.orchestrationsApiService.apply$(request).pipe(catchError$1(error => throwError(() => {
1176
1243
  if (error.error) {
1177
1244
  return extractErrorDetails(error.error).join('. ');
1178
1245
  }
1179
1246
  return error.message || JSON.stringify(error);
1180
- })), finalize$1(() => this.isLoadingSubj$.next(false)));
1181
- }
1182
- configureExternal$(props) {
1183
- // TODO: implement
1184
- throw new Error('Not implemented');
1185
- }
1186
- configureGuidedSelling$(data) {
1187
- // TODO: implement
1188
- throw new Error('Not implemented');
1247
+ })));
1189
1248
  }
1190
1249
  getPCMModel() {
1191
1250
  const pcmModel = this.configurationRuntimeService.pcmModel;
@@ -1337,7 +1396,7 @@ class ConfigurationStateService {
1337
1396
  transactionContext: state,
1338
1397
  flowId: this.flowInfoService.flow.id,
1339
1398
  };
1340
- return this.salesTransactionApiService.upsert(request).pipe(map(id => ({ id })));
1399
+ return this.salesTransactionApiService.save(request).pipe(map(id => ({ id })));
1341
1400
  }
1342
1401
  const transactionContext = this.salesTransactionService.state;
1343
1402
  const configurationRoot = this.configurationService.root;
@@ -1462,7 +1521,7 @@ class ConfigurationStateService {
1462
1521
  var _a;
1463
1522
  state = (_a = this.executeActionScript(state, action)) !== null && _a !== void 0 ? _a : state;
1464
1523
  });
1465
- return this.configurationService.configureRequest$(state);
1524
+ return this.configurationService.configure$(state);
1466
1525
  }), map(() => {
1467
1526
  // Run selectors and apply them to the state
1468
1527
  const configurationState = this.configurationService.state;
@@ -1579,6 +1638,7 @@ ConfigurationModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", ver
1579
1638
  ConfigurationStateService,
1580
1639
  ConfigurationRuntimeService,
1581
1640
  TestModeConfigurationService,
1641
+ GuidedSellingService,
1582
1642
  ], imports: [ConfirmationDialogModule, ApiModule] });
1583
1643
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: ConfigurationModule, decorators: [{
1584
1644
  type: NgModule,
@@ -1589,6 +1649,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImpor
1589
1649
  ConfigurationStateService,
1590
1650
  ConfigurationRuntimeService,
1591
1651
  TestModeConfigurationService,
1652
+ GuidedSellingService,
1592
1653
  ],
1593
1654
  }]
1594
1655
  }] });
@@ -1837,5 +1898,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImpor
1837
1898
  * Generated bundle index. Do not edit.
1838
1899
  */
1839
1900
 
1840
- export { ActionCodePipe, CalendarDirective, CatalogProductsService, ConfigurationRuntimeService, ConfigurationService, ConfigurationStateService, DEFAULT_FORMATTING_SETTINGS, DatePipe, FLOW_CUSTOMIZATION, FORMATTING_SETTINGS_TOKEN, FlowConfigurationService, FlowInfoService, FlowStateConfigurationService, FlowStateService, IntegrationState, NumberPipe, PricePipe, ProductImagesService, RuntimeSettingsService, SalesTransactionService, SdkCoreModule, SdkDirectivesModule, SdkPipesModule, TestModeConfigurationService, TransactionItemWorker, UI_DEFINITION_VERSION, extractMetadata, filterSuccessfulExecute, findTransactionItem, findTransactionItemWithComparator, generateTransactionItem, insertTransactionItem, removeTransactionItem, replaceTransactionItem };
1901
+ 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 };
1841
1902
  //# sourceMappingURL=veloceapps-sdk-core.mjs.map