@veloceapps/sdk 12.0.0-11 → 12.0.0-13

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.
@@ -6,7 +6,7 @@ import { ApiModule } from '@veloceapps/api';
6
6
  import * as i6 from '@veloceapps/components';
7
7
  import { ToastType, ConfirmationDialogModule } from '@veloceapps/components';
8
8
  import * as i1 from '@veloceapps/api/v2';
9
- import { tap, BehaviorSubject, map, filter, switchMap, of, forkJoin, noop, throwError, Subject, catchError as catchError$1, combineLatest, finalize as finalize$1, buffer, debounceTime, share, take, distinctUntilChanged, shareReplay, takeUntil, first } from 'rxjs';
9
+ import { BehaviorSubject, tap, map, filter, switchMap, of, forkJoin, noop, throwError, distinctUntilChanged, Subject, catchError as catchError$1, combineLatest, finalize as finalize$1, buffer, debounceTime, share, take, shareReplay, takeUntil, first } from 'rxjs';
10
10
  import { uniqBy, flatten, omit, cloneDeep, assign, isEqual } from 'lodash';
11
11
  import * as i2 from 'primeng/api';
12
12
  import { filter as filter$1, map as map$1, tap as tap$1, catchError, finalize } from 'rxjs/operators';
@@ -18,18 +18,27 @@ class ConfigurationRuntimeService {
18
18
  constructor(pcmApiService) {
19
19
  this.pcmApiService = pcmApiService;
20
20
  this.uiDefinitionContainer = null;
21
+ this.pcmModelSubj$ = new BehaviorSubject(null);
21
22
  }
22
23
  get uiDefinitionProps() {
23
24
  return this.uiDefinitionContainer?.source.properties ?? {};
24
25
  }
26
+ get pcmModel() {
27
+ return this.pcmModelSubj$.value;
28
+ }
29
+ get pcmModel$() {
30
+ return this.pcmModelSubj$;
31
+ }
25
32
  reset() {
26
33
  this.uiDefinitionContainer = null;
27
34
  this.initializationProps = undefined;
28
- this.pcmModel = undefined;
35
+ this.pcmModelSubj$.next(null);
29
36
  }
30
37
  init$(props) {
31
38
  this.initializationProps = props;
32
- return this.pcmApiService.fetchPCMByProductId(props.productId).pipe(tap(pcmModel => (this.pcmModel = pcmModel)));
39
+ return this.pcmApiService
40
+ .fetchPCMByProductId(props.productId)
41
+ .pipe(tap(pcmModel => this.pcmModelSubj$.next(pcmModel)));
33
42
  }
34
43
  }
35
44
  ConfigurationRuntimeService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: ConfigurationRuntimeService, deps: [{ token: i1.PCMApiService }], target: i0.ɵɵFactoryTarget.Injectable });
@@ -652,6 +661,19 @@ class ConfigurationService {
652
661
  }
653
662
  return pcmModel;
654
663
  }
664
+ getPCMModel$() {
665
+ return this.configurationRuntimeService.pcmModel$.pipe(distinctUntilChanged((prev, curr) => prev?.id === curr?.id));
666
+ }
667
+ swapProduct$(productId) {
668
+ const rootTransactionItem = this.root;
669
+ this.flowInfoService.updateContext({ productId });
670
+ return this.configurationRuntimeService.init$({ productId }).pipe(map$1(pcm => generateTransactionItem(pcm, this.state?.salesTransaction.id, rootTransactionItem?.qty)), switchMap(salesTransactionItem => {
671
+ return this.patch$({
672
+ ...salesTransactionItem,
673
+ id: rootTransactionItem?.id ?? salesTransactionItem.id,
674
+ });
675
+ }));
676
+ }
655
677
  }
656
678
  ConfigurationService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: ConfigurationService, deps: [{ token: FlowInfoService }, { token: i2.MessageService }, { token: ConfigurationRuntimeService }, { token: SalesTransactionService }, { token: i1.OrchestrationsApiService }, { token: GuidedSellingService }], target: i0.ɵɵFactoryTarget.Injectable });
657
679
  ConfigurationService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: ConfigurationService });
@@ -803,7 +825,7 @@ class TestModeConfigurationService {
803
825
  initTestMode$(uiDefinitionContainer, options) {
804
826
  this.configurationRuntimeService.uiDefinitionContainer = uiDefinitionContainer;
805
827
  if (this.checkInitialized(uiDefinitionContainer)) {
806
- this.configurationRuntimeService.pcmModel = this.pcmModel;
828
+ this.configurationRuntimeService.pcmModelSubj$.next(this.pcmModel || null);
807
829
  return of(undefined);
808
830
  }
809
831
  this.configurationService.reset();