@veloceapps/sdk 11.0.0-83 → 11.0.0-85

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.
@@ -419,7 +419,7 @@ class ConfigurationService {
419
419
  salesTransactionItems: transactionItem ? [transactionItem] : [],
420
420
  },
421
421
  };
422
- return (isRootGenerated ? this.configureRequest$(configurationState) : of(configurationState)).pipe(tap$1(configurationState => {
422
+ return (isRootGenerated ? this.configure$(configurationState) : of(configurationState)).pipe(tap$1(configurationState => {
423
423
  this.configurationStateSubj$.next(configurationState);
424
424
  this.previousConfigurationStateSubj$.next(configurationState);
425
425
  }), map$1(noop));
@@ -440,7 +440,7 @@ class ConfigurationService {
440
440
  salesTransactionItems: [newRoot],
441
441
  },
442
442
  };
443
- return this.configureRequest$(newTransactionContext).pipe(catchError(error => {
443
+ return this.configure$(newTransactionContext).pipe(catchError(error => {
444
444
  console.error(error);
445
445
  if (!this.configurationRuntimeService.uiDefinitionProps.suppressToastMessages) {
446
446
  this.messageService.add({ severity: 'error', summary: error });
@@ -455,30 +455,31 @@ class ConfigurationService {
455
455
  patch(transactionItem) {
456
456
  this.patch$(transactionItem).subscribe();
457
457
  }
458
- configureRequest$(transactionContext) {
459
- const request = {
460
- transactionContext,
461
- flowId: this.flowInfoService.flow.id,
462
- };
458
+ configure$(transactionContext) {
463
459
  this.isLoadingSubj$.next(true);
464
- return this.orchestrationsApiService.apply$(request).pipe(tap$1(result => {
460
+ return this.justConfigureRequest$(transactionContext).pipe(tap$1(result => {
465
461
  this.configurationStateSubj$.next(result);
466
462
  this.previousConfigurationStateSubj$.next(cloneDeep(result));
467
- }), catchError(error => throwError(() => {
463
+ }), catchError(e => {
468
464
  const resetState = this.previousConfigurationStateSubj$.getValue();
469
465
  if (resetState) {
470
466
  this.previousConfigurationStateSubj$.next(cloneDeep(resetState));
471
467
  this.configurationStateSubj$.next(resetState);
472
468
  }
469
+ return throwError(() => e);
470
+ }), finalize(() => this.isLoadingSubj$.next(false)));
471
+ }
472
+ justConfigureRequest$(transactionContext) {
473
+ const request = {
474
+ transactionContext,
475
+ flowId: this.flowInfoService.flow.id,
476
+ };
477
+ return this.orchestrationsApiService.apply$(request).pipe(catchError(error => throwError(() => {
473
478
  if (error.error) {
474
479
  return extractErrorDetails(error.error).join('. ');
475
480
  }
476
481
  return error.message || JSON.stringify(error);
477
- })), finalize(() => this.isLoadingSubj$.next(false)));
478
- }
479
- configureExternal$(props) {
480
- // TODO: implement
481
- throw new Error('Not implemented');
482
+ })));
482
483
  }
483
484
  getPCMModel() {
484
485
  const pcmModel = this.configurationRuntimeService.pcmModel;
@@ -494,112 +495,6 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImpor
494
495
  type: Injectable
495
496
  }], ctorParameters: function () { return [{ type: FlowInfoService }, { type: i2.MessageService }, { type: ConfigurationRuntimeService }, { type: SalesTransactionService }, { type: i1.OrchestrationsApiService }]; } });
496
497
 
497
- class TestModeConfigurationService {
498
- constructor(flowInfoService, configurationService, configurationRuntimeService, salesTransactionService, runtimeSettingsService) {
499
- this.flowInfoService = flowInfoService;
500
- this.configurationService = configurationService;
501
- this.configurationRuntimeService = configurationRuntimeService;
502
- this.salesTransactionService = salesTransactionService;
503
- this.runtimeSettingsService = runtimeSettingsService;
504
- this.isInitialized = false;
505
- }
506
- initTestMode$(uiDefinitionContainer, options) {
507
- this.configurationRuntimeService.uiDefinitionContainer = uiDefinitionContainer;
508
- if (this.checkInitialized(uiDefinitionContainer)) {
509
- this.configurationRuntimeService.pcmModel = this.pcmModel;
510
- return of(undefined);
511
- }
512
- this.configurationService.reset();
513
- const { productId, quoteId, flowId } = uiDefinitionContainer.source.properties ?? {};
514
- if (!productId) {
515
- return throwError(() => 'Unable to start the Configuration Preview: Product is missing.');
516
- }
517
- if (!quoteId) {
518
- return throwError(() => `Unable to start the Configuration Preview: Quote is missing.`);
519
- }
520
- if (!flowId) {
521
- return throwError(() => `Unable to start the Configuration Preview: Flow is missing.`);
522
- }
523
- return this.runtimeSettingsService.create().pipe(switchMap(() => this.flowInfoService.init$(flowId, { productId, headerId: quoteId })), switchMap(() => this.configurationRuntimeService.init$({ productId })), tap(pcmModel => (this.pcmModel = pcmModel)), switchMap(() => {
524
- if (options?.customizationMode) {
525
- return of(undefined);
526
- }
527
- return this.initConfiguration$(quoteId);
528
- }), tap(() => (this.isInitialized = true)), map(noop));
529
- }
530
- initConfiguration$(quoteId) {
531
- this.salesTransactionService.setState(this.getTestTransactionContext(quoteId));
532
- return this.configurationService.init$().pipe(switchMap(() => this.configurationService.state
533
- ? this.configurationService.configureRequest$(this.configurationService.state)
534
- : of(undefined)), map(noop));
535
- }
536
- getTestTransactionContext(quoteId) {
537
- const testTransaction = {
538
- id: quoteId,
539
- businessObjectType: 'Quote',
540
- salesTransactionItems: [],
541
- };
542
- return {
543
- salesTransaction: testTransaction,
544
- transactionId: quoteId,
545
- businessObjectType: 'Quote',
546
- childNodes: {},
547
- id: UUID.UUID(),
548
- tagAttributes: {},
549
- };
550
- }
551
- checkInitialized(uiDefinitionContainer) {
552
- return this.isInitialized && !!uiDefinitionContainer.source.properties?.persistTestState;
553
- }
554
- }
555
- TestModeConfigurationService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: TestModeConfigurationService, deps: [{ token: FlowInfoService }, { token: ConfigurationService }, { token: ConfigurationRuntimeService }, { token: SalesTransactionService }, { token: RuntimeSettingsService }], target: i0.ɵɵFactoryTarget.Injectable });
556
- TestModeConfigurationService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: TestModeConfigurationService });
557
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: TestModeConfigurationService, decorators: [{
558
- type: Injectable
559
- }], ctorParameters: function () { return [{ type: FlowInfoService }, { type: ConfigurationService }, { type: ConfigurationRuntimeService }, { type: SalesTransactionService }, { type: RuntimeSettingsService }]; } });
560
-
561
- class GuidedSellingService {
562
- constructor(orchestrationsApiService) {
563
- this.orchestrationsApiService = orchestrationsApiService;
564
- }
565
- configureGuidedSelling$(data) {
566
- return this.orchestrationsApiService.apply$({
567
- transactionContext: this.getTransactionContext(data.attributesMap),
568
- orchestrationName: data.orchestrationName,
569
- });
570
- }
571
- getTransactionContext(guidedSellingAttributes) {
572
- const testTransaction = {
573
- id: UUID.UUID(),
574
- businessObjectType: 'Quote',
575
- salesTransactionItems: [],
576
- tagAttributes: {},
577
- };
578
- return {
579
- salesTransaction: testTransaction,
580
- transactionId: UUID.UUID(),
581
- businessObjectType: 'Quote',
582
- childNodes: {
583
- GuidedSelling: [
584
- {
585
- id: UUID.UUID(),
586
- tagAttributes: {},
587
- childNodes: {},
588
- properties: { guidedSellingAttributes },
589
- },
590
- ],
591
- },
592
- id: UUID.UUID(),
593
- tagAttributes: {},
594
- };
595
- }
596
- }
597
- GuidedSellingService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: GuidedSellingService, deps: [{ token: i1.OrchestrationsApiService }], target: i0.ɵɵFactoryTarget.Injectable });
598
- GuidedSellingService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: GuidedSellingService });
599
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: GuidedSellingService, decorators: [{
600
- type: Injectable
601
- }], ctorParameters: function () { return [{ type: i1.OrchestrationsApiService }]; } });
602
-
603
498
  class SalesTransactionService {
604
499
  get isInitialized$() {
605
500
  return this.isInitializedSubj$.asObservable();
@@ -731,6 +626,112 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImpor
731
626
  type: Injectable
732
627
  }], ctorParameters: function () { return [{ type: i1.OrchestrationsApiService }, { type: SalesTransactionService }, { type: FlowInfoService }]; } });
733
628
 
629
+ class TestModeConfigurationService {
630
+ constructor(flowInfoService, configurationService, configurationRuntimeService, salesTransactionService, runtimeSettingsService) {
631
+ this.flowInfoService = flowInfoService;
632
+ this.configurationService = configurationService;
633
+ this.configurationRuntimeService = configurationRuntimeService;
634
+ this.salesTransactionService = salesTransactionService;
635
+ this.runtimeSettingsService = runtimeSettingsService;
636
+ this.isInitialized = false;
637
+ }
638
+ initTestMode$(uiDefinitionContainer, options) {
639
+ this.configurationRuntimeService.uiDefinitionContainer = uiDefinitionContainer;
640
+ if (this.checkInitialized(uiDefinitionContainer)) {
641
+ this.configurationRuntimeService.pcmModel = this.pcmModel;
642
+ return of(undefined);
643
+ }
644
+ this.configurationService.reset();
645
+ const { productId, quoteId, flowId } = uiDefinitionContainer.source.properties ?? {};
646
+ if (!productId) {
647
+ return throwError(() => 'Unable to start the Configuration Preview: Product is missing.');
648
+ }
649
+ if (!quoteId) {
650
+ return throwError(() => `Unable to start the Configuration Preview: Quote is missing.`);
651
+ }
652
+ if (!flowId) {
653
+ return throwError(() => `Unable to start the Configuration Preview: Flow is missing.`);
654
+ }
655
+ return this.runtimeSettingsService.create().pipe(switchMap(() => this.flowInfoService.init$(flowId, { productId, headerId: quoteId })), switchMap(() => this.configurationRuntimeService.init$({ productId })), tap(pcmModel => (this.pcmModel = pcmModel)), switchMap(() => {
656
+ if (options?.customizationMode) {
657
+ return of(undefined);
658
+ }
659
+ return this.initConfiguration$(quoteId);
660
+ }), tap(() => (this.isInitialized = true)), map(noop));
661
+ }
662
+ initConfiguration$(quoteId) {
663
+ this.salesTransactionService.setState(this.getTestTransactionContext(quoteId));
664
+ return this.configurationService.init$().pipe(switchMap(() => this.configurationService.state
665
+ ? this.configurationService.configure$(this.configurationService.state)
666
+ : of(undefined)), map(noop));
667
+ }
668
+ getTestTransactionContext(quoteId) {
669
+ const testTransaction = {
670
+ id: quoteId,
671
+ businessObjectType: 'Quote',
672
+ salesTransactionItems: [],
673
+ };
674
+ return {
675
+ salesTransaction: testTransaction,
676
+ transactionId: quoteId,
677
+ businessObjectType: 'Quote',
678
+ childNodes: {},
679
+ id: UUID.UUID(),
680
+ tagAttributes: {},
681
+ };
682
+ }
683
+ checkInitialized(uiDefinitionContainer) {
684
+ return this.isInitialized && !!uiDefinitionContainer.source.properties?.persistTestState;
685
+ }
686
+ }
687
+ TestModeConfigurationService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: TestModeConfigurationService, deps: [{ token: FlowInfoService }, { token: ConfigurationService }, { token: ConfigurationRuntimeService }, { token: SalesTransactionService }, { token: RuntimeSettingsService }], target: i0.ɵɵFactoryTarget.Injectable });
688
+ TestModeConfigurationService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: TestModeConfigurationService });
689
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: TestModeConfigurationService, decorators: [{
690
+ type: Injectable
691
+ }], ctorParameters: function () { return [{ type: FlowInfoService }, { type: ConfigurationService }, { type: ConfigurationRuntimeService }, { type: SalesTransactionService }, { type: RuntimeSettingsService }]; } });
692
+
693
+ class GuidedSellingService {
694
+ constructor(orchestrationsApiService) {
695
+ this.orchestrationsApiService = orchestrationsApiService;
696
+ }
697
+ configureGuidedSelling$(data) {
698
+ return this.orchestrationsApiService.apply$({
699
+ transactionContext: this.getTransactionContext(data.attributesMap),
700
+ orchestrationName: data.orchestrationName,
701
+ });
702
+ }
703
+ getTransactionContext(guidedSellingAttributes) {
704
+ const testTransaction = {
705
+ id: UUID.UUID(),
706
+ businessObjectType: 'Quote',
707
+ salesTransactionItems: [],
708
+ tagAttributes: {},
709
+ };
710
+ return {
711
+ salesTransaction: testTransaction,
712
+ transactionId: UUID.UUID(),
713
+ businessObjectType: 'Quote',
714
+ childNodes: {
715
+ GuidedSelling: [
716
+ {
717
+ id: UUID.UUID(),
718
+ tagAttributes: {},
719
+ childNodes: {},
720
+ properties: { guidedSellingAttributes },
721
+ },
722
+ ],
723
+ },
724
+ id: UUID.UUID(),
725
+ tagAttributes: {},
726
+ };
727
+ }
728
+ }
729
+ GuidedSellingService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: GuidedSellingService, deps: [{ token: i1.OrchestrationsApiService }], target: i0.ɵɵFactoryTarget.Injectable });
730
+ GuidedSellingService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: GuidedSellingService });
731
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: GuidedSellingService, decorators: [{
732
+ type: Injectable
733
+ }], ctorParameters: function () { return [{ type: i1.OrchestrationsApiService }]; } });
734
+
734
735
  class FlowStateService {
735
736
  constructor(flowConfiguration, flowInfoService, flowStateApiService, processorsApiService, salesTransactionApiService, salesTransactionService, toastService, customizationService) {
736
737
  this.flowConfiguration = flowConfiguration;
@@ -877,7 +878,7 @@ class FlowStateService {
877
878
  transactionContext: state,
878
879
  flowId: this.flowInfoService.flow.id,
879
880
  };
880
- return this.salesTransactionApiService.upsert(request).pipe(map(id => ({ id })));
881
+ return this.salesTransactionApiService.save(request).pipe(map(id => ({ id })));
881
882
  }
882
883
  }
883
884
  return of({ id: '' });
@@ -1131,9 +1132,12 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImpor
1131
1132
  }] }]; } });
1132
1133
 
1133
1134
  class FlowStateConfigurationService {
1134
- constructor(flowInfoService, flowStateService) {
1135
+ constructor(flowInfoService, flowStateService, configurationService, salesTransactionService, flowConfigurationService) {
1135
1136
  this.flowInfoService = flowInfoService;
1136
1137
  this.flowStateService = flowStateService;
1138
+ this.configurationService = configurationService;
1139
+ this.salesTransactionService = salesTransactionService;
1140
+ this.flowConfigurationService = flowConfigurationService;
1137
1141
  }
1138
1142
  addToCart$(props) {
1139
1143
  let request$;
@@ -1149,17 +1153,49 @@ class FlowStateConfigurationService {
1149
1153
  }
1150
1154
  }
1151
1155
  else {
1152
- // TODO: Implement
1153
- request$ = of();
1156
+ request$ = this.configureExternal$(props);
1154
1157
  }
1155
1158
  return request$.pipe(switchMap(() => this.flowStateService.executeRequest$({}, true)), map(noop));
1156
1159
  }
1160
+ configureExternal$(props) {
1161
+ const { state } = this.salesTransactionService;
1162
+ if (!state) {
1163
+ return of();
1164
+ }
1165
+ const stateToConfigure = {
1166
+ ...state,
1167
+ salesTransaction: {
1168
+ ...state.salesTransaction,
1169
+ salesTransactionItems: [
1170
+ {
1171
+ ...generateTransactionItem(props.productId),
1172
+ qty: props.qty ?? 1,
1173
+ tagAttributes: props.attributesMap ?? {},
1174
+ },
1175
+ ],
1176
+ },
1177
+ };
1178
+ return this.configurationService.justConfigureRequest$(stateToConfigure).pipe(switchMap(configurationResult => {
1179
+ const state = this.salesTransactionService.state;
1180
+ const addedProduct = configurationResult.salesTransaction.salesTransactionItems[0];
1181
+ if (!state || !addedProduct) {
1182
+ return of();
1183
+ }
1184
+ return this.flowConfigurationService.calculate$({
1185
+ ...state,
1186
+ salesTransaction: {
1187
+ ...state.salesTransaction,
1188
+ salesTransactionItems: [...state.salesTransaction.salesTransactionItems, addedProduct],
1189
+ },
1190
+ });
1191
+ }));
1192
+ }
1157
1193
  }
1158
- 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 });
1194
+ 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 });
1159
1195
  FlowStateConfigurationService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: FlowStateConfigurationService });
1160
1196
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: FlowStateConfigurationService, decorators: [{
1161
1197
  type: Injectable
1162
- }], ctorParameters: function () { return [{ type: FlowInfoService }, { type: FlowStateService }]; } });
1198
+ }], ctorParameters: function () { return [{ type: FlowInfoService }, { type: FlowStateService }, { type: ConfigurationService }, { type: SalesTransactionService }, { type: FlowConfigurationService }]; } });
1163
1199
 
1164
1200
  class IntegrationState {
1165
1201
  constructor() {
@@ -1373,7 +1409,7 @@ class ConfigurationStateService {
1373
1409
  transactionContext: state,
1374
1410
  flowId: this.flowInfoService.flow.id,
1375
1411
  };
1376
- return this.salesTransactionApiService.upsert(request).pipe(map(id => ({ id })));
1412
+ return this.salesTransactionApiService.save(request).pipe(map(id => ({ id })));
1377
1413
  }
1378
1414
  const transactionContext = this.salesTransactionService.state;
1379
1415
  const configurationRoot = this.configurationService.root;
@@ -1493,7 +1529,7 @@ class ConfigurationStateService {
1493
1529
  request.actions.forEach(action => {
1494
1530
  state = this.executeActionScript(state, action) ?? state;
1495
1531
  });
1496
- return this.configurationService.configureRequest$(state);
1532
+ return this.configurationService.configure$(state);
1497
1533
  }), map(() => {
1498
1534
  // Run selectors and apply them to the state
1499
1535
  const configurationState = this.configurationService.state;