@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.
@@ -5,7 +5,7 @@ import * as i3 from '@veloceapps/api';
5
5
  import { ApiModule } from '@veloceapps/api';
6
6
  import * as i6 from '@veloceapps/components';
7
7
  import { ToastType, ConfirmationDialogModule } from '@veloceapps/components';
8
- import { tap, BehaviorSubject, map, filter, switchMap, of, forkJoin, throwError, noop, Subject, catchError, combineLatest, finalize, buffer, debounceTime, share, take, distinctUntilChanged, shareReplay, takeUntil, first } from 'rxjs';
8
+ import { BehaviorSubject, tap, map, filter, switchMap, of, forkJoin, throwError, noop, Subject, catchError, combineLatest, finalize, buffer, debounceTime, share, take, distinctUntilChanged, shareReplay, takeUntil, first } from 'rxjs';
9
9
  import * as i1 from '@veloceapps/api/v2';
10
10
  import { flatten, omit, uniqBy, cloneDeep, assign, isEqual } from 'lodash';
11
11
  import { filter as filter$1, map as map$1, tap as tap$1, catchError as catchError$1, finalize as finalize$1 } from 'rxjs/operators';
@@ -17,19 +17,28 @@ class ConfigurationRuntimeService {
17
17
  constructor(pcmApiService) {
18
18
  this.pcmApiService = pcmApiService;
19
19
  this.uiDefinitionContainer = null;
20
+ this.pcmModelSubj$ = new BehaviorSubject(null);
20
21
  }
21
22
  get uiDefinitionProps() {
22
23
  var _a, _b;
23
24
  return (_b = (_a = this.uiDefinitionContainer) === null || _a === void 0 ? void 0 : _a.source.properties) !== null && _b !== void 0 ? _b : {};
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 });
@@ -466,7 +475,7 @@ class TestModeConfigurationService {
466
475
  var _a;
467
476
  this.configurationRuntimeService.uiDefinitionContainer = uiDefinitionContainer;
468
477
  if (this.checkInitialized(uiDefinitionContainer)) {
469
- this.configurationRuntimeService.pcmModel = this.pcmModel;
478
+ this.configurationRuntimeService.pcmModelSubj$.next(this.pcmModel || null);
470
479
  return of(undefined);
471
480
  }
472
481
  this.configurationService.reset();
@@ -1431,6 +1440,17 @@ class ConfigurationService {
1431
1440
  }
1432
1441
  return pcmModel;
1433
1442
  }
1443
+ getPCMModel$() {
1444
+ return this.configurationRuntimeService.pcmModel$.pipe(distinctUntilChanged((prev, curr) => (prev === null || prev === void 0 ? void 0 : prev.id) === (curr === null || curr === void 0 ? void 0 : curr.id)));
1445
+ }
1446
+ swapProduct$(productId) {
1447
+ const rootTransactionItem = this.root;
1448
+ this.flowInfoService.updateContext({ productId });
1449
+ return this.configurationRuntimeService.init$({ productId }).pipe(map$1(pcm => { var _a; return generateTransactionItem(pcm, (_a = this.state) === null || _a === void 0 ? void 0 : _a.salesTransaction.id, rootTransactionItem === null || rootTransactionItem === void 0 ? void 0 : rootTransactionItem.qty); }), switchMap(salesTransactionItem => {
1450
+ var _a;
1451
+ return this.patch$(Object.assign(Object.assign({}, salesTransactionItem), { id: (_a = rootTransactionItem === null || rootTransactionItem === void 0 ? void 0 : rootTransactionItem.id) !== null && _a !== void 0 ? _a : salesTransactionItem.id }));
1452
+ }));
1453
+ }
1434
1454
  }
1435
1455
  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 });
1436
1456
  ConfigurationService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: ConfigurationService });