@veloceapps/sdk 11.0.0-11 → 11.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.
Files changed (89) hide show
  1. package/cms/vendor-map.d.ts +7 -6
  2. package/core/modules/configuration/helpers.d.ts +2 -1
  3. package/core/modules/configuration/services/configuration-runtime.service.d.ts +1 -3
  4. package/core/modules/configuration/services/configuration-state.service.d.ts +7 -7
  5. package/core/modules/configuration/services/configuration.service.d.ts +5 -10
  6. package/core/modules/flow-configuration/services/flow-configuration.service.d.ts +11 -32
  7. package/core/services/catalog-products.service.d.ts +11 -0
  8. package/core/services/flow-info.service.d.ts +23 -10
  9. package/core/services/flow-state.service.d.ts +9 -12
  10. package/core/services/index.d.ts +2 -2
  11. package/core/services/quote-draft.service.d.ts +5 -5
  12. package/core/services/sales-transaction.service.d.ts +28 -0
  13. package/core/types/flow-state.types.d.ts +2 -2
  14. package/esm2020/cms/vendor-map.mjs +8 -7
  15. package/esm2020/core/core.module.mjs +7 -4
  16. package/esm2020/core/modules/configuration/helpers.mjs +11 -17
  17. package/esm2020/core/modules/configuration/services/configuration-runtime.service.mjs +8 -45
  18. package/esm2020/core/modules/configuration/services/configuration-state.service.mjs +46 -54
  19. package/esm2020/core/modules/configuration/services/configuration.service.mjs +21 -39
  20. package/esm2020/core/modules/flow-configuration/services/flow-configuration.service.mjs +34 -110
  21. package/esm2020/core/services/catalog-products.service.mjs +25 -0
  22. package/esm2020/core/services/flow-info.service.mjs +70 -28
  23. package/esm2020/core/services/flow-state.service.mjs +59 -133
  24. package/esm2020/core/services/index.mjs +3 -3
  25. package/esm2020/core/services/quote-draft.service.mjs +20 -38
  26. package/esm2020/core/services/sales-transaction.service.mjs +62 -0
  27. package/esm2020/core/types/flow-state.types.mjs +1 -1
  28. package/esm2020/src/components/flow-header/flow-header.component.mjs +3 -6
  29. package/esm2020/src/components/guided-selling/guided-selling.component.mjs +3 -6
  30. package/esm2020/src/flow-routing.module.mjs +5 -36
  31. package/esm2020/src/flow.component.mjs +5 -5
  32. package/esm2020/src/guards/flow.guard.mjs +10 -9
  33. package/esm2020/src/guards/product-unload.guard.mjs +5 -7
  34. package/esm2020/src/index.mjs +1 -2
  35. package/esm2020/src/pages/assets/assets.component.mjs +3 -3
  36. package/esm2020/src/pages/catalog/catalog.component.mjs +3 -3
  37. package/esm2020/src/pages/debug/debug.component.mjs +7 -11
  38. package/esm2020/src/pages/product/product.component.mjs +47 -67
  39. package/esm2020/src/pages/product/product.module.mjs +5 -5
  40. package/esm2020/src/pages/shopping-cart/shopping-cart.component.mjs +3 -3
  41. package/esm2020/src/resolvers/flow.resolver.mjs +10 -18
  42. package/esm2020/src/resolvers/quote.resolver.mjs +11 -11
  43. package/esm2020/src/services/flow-dialog.service.mjs +8 -8
  44. package/esm2020/src/services/flow-router.service.mjs +11 -21
  45. package/esm2020/src/services/flow.service.mjs +10 -43
  46. package/esm2020/src/utils/flow.utils.mjs +2 -13
  47. package/fesm2015/veloceapps-sdk-cms.mjs +7 -6
  48. package/fesm2015/veloceapps-sdk-cms.mjs.map +1 -1
  49. package/fesm2015/veloceapps-sdk-core.mjs +1483 -1636
  50. package/fesm2015/veloceapps-sdk-core.mjs.map +1 -1
  51. package/fesm2015/veloceapps-sdk.mjs +126 -672
  52. package/fesm2015/veloceapps-sdk.mjs.map +1 -1
  53. package/fesm2020/veloceapps-sdk-cms.mjs +7 -6
  54. package/fesm2020/veloceapps-sdk-cms.mjs.map +1 -1
  55. package/fesm2020/veloceapps-sdk-core.mjs +1515 -1707
  56. package/fesm2020/veloceapps-sdk-core.mjs.map +1 -1
  57. package/fesm2020/veloceapps-sdk.mjs +124 -667
  58. package/fesm2020/veloceapps-sdk.mjs.map +1 -1
  59. package/package.json +1 -1
  60. package/src/components/flow-header/flow-header.component.d.ts +1 -1
  61. package/src/components/guided-selling/guided-selling.component.d.ts +1 -1
  62. package/src/flow-routing.module.d.ts +1 -2
  63. package/src/flow.component.d.ts +2 -2
  64. package/src/guards/product-unload.guard.d.ts +4 -5
  65. package/src/index.d.ts +0 -1
  66. package/src/pages/assets/assets.component.d.ts +1 -1
  67. package/src/pages/catalog/catalog.component.d.ts +1 -1
  68. package/src/pages/debug/debug.component.d.ts +2 -3
  69. package/src/pages/product/product.component.d.ts +9 -10
  70. package/src/pages/product/product.module.d.ts +1 -1
  71. package/src/pages/shopping-cart/shopping-cart.component.d.ts +1 -1
  72. package/src/resolvers/flow.resolver.d.ts +5 -6
  73. package/src/resolvers/quote.resolver.d.ts +5 -6
  74. package/src/services/flow-dialog.service.d.ts +3 -3
  75. package/src/services/flow-router.service.d.ts +2 -4
  76. package/src/services/flow.service.d.ts +2 -6
  77. package/src/utils/flow.utils.d.ts +0 -7
  78. package/core/services/context.service.d.ts +0 -23
  79. package/esm2020/core/services/context.service.mjs +0 -91
  80. package/esm2020/src/guards/context.guard.mjs +0 -91
  81. package/esm2020/src/guards/index.mjs +0 -2
  82. package/esm2020/src/pages/remote/remote.component.mjs +0 -342
  83. package/esm2020/src/pages/remote/remote.module.mjs +0 -20
  84. package/esm2020/src/pages/remote/remote.types.mjs +0 -2
  85. package/src/guards/context.guard.d.ts +0 -19
  86. package/src/guards/index.d.ts +0 -1
  87. package/src/pages/remote/remote.component.d.ts +0 -46
  88. package/src/pages/remote/remote.module.d.ts +0 -10
  89. package/src/pages/remote/remote.types.d.ts +0 -4
@@ -2,22 +2,23 @@ import * as i4 from '@angular/common';
2
2
  import { CommonModule } from '@angular/common';
3
3
  import * as i0 from '@angular/core';
4
4
  import { Component, ChangeDetectionStrategy, NgModule, Optional, Inject, Injectable, inject } from '@angular/core';
5
- import * as i1$1 from '@veloceapps/api';
5
+ import * as i1$3 from '@veloceapps/api';
6
6
  import { ApiModule } from '@veloceapps/api';
7
7
  import * as i2$1 from '@veloceapps/components';
8
8
  import { ToastType, LoaderModule, LetDirectiveModule } from '@veloceapps/components';
9
9
  import * as i5 from '@veloceapps/sdk/cms';
10
10
  import { btoaSafe, PreviewModule, FlowAction, LauncherModule } from '@veloceapps/sdk/cms';
11
11
  import * as i2 from '@veloceapps/sdk/core';
12
- import { FLOW_CUSTOMIZATION, ContextService, FlowStateService, FlowInfoService, QuoteDraftService, ConfigurationService, IntegrationState, SdkCoreModule } from '@veloceapps/sdk/core';
12
+ import { FLOW_CUSTOMIZATION, RuntimeSettingsService, FlowStateService, FlowInfoService, QuoteDraftService, SalesTransactionService, ConfigurationService, IntegrationState, SdkCoreModule } from '@veloceapps/sdk/core';
13
13
  import * as i3 from 'primeng/button';
14
14
  import { ButtonModule } from 'primeng/button';
15
15
  import * as i1 from 'primeng/dynamicdialog';
16
- import { BehaviorSubject, Subject, filter, first, tap, takeUntil, catchError, of, map, switchMap, shareReplay, startWith, distinctUntilChanged, from, take, combineLatest, forkJoin, throwError } from 'rxjs';
16
+ import * as i1$1 from '@veloceapps/api/v2';
17
+ import { BehaviorSubject, Subject, filter, first, tap, takeUntil, catchError, of, map, switchMap, shareReplay, startWith, distinctUntilChanged, from, take, combineLatest, timer, noop } from 'rxjs';
17
18
  import { DomHandler } from 'primeng/dom';
18
19
  import * as i1$2 from '@angular/router';
19
20
  import { NavigationEnd, NavigationStart, NavigationCancel, NavigationError, RouterModule } from '@angular/router';
20
- import { mapShoppingCartSettings, getMaxRenewalTermsValue, UITemplateType, SalesforceIdUtils, ConfigurationContextMode, isVeloceError, extractErrorDetails, UUID } from '@veloceapps/core';
21
+ import { mapShoppingCartSettings, getMaxRenewalTermsValue, UITemplateType, SalesforceIdUtils, isVeloceError, extractErrorDetails, ConfigurationContextMode } from '@veloceapps/core';
21
22
  import { HttpErrorResponse, HttpParams } from '@angular/common/http';
22
23
  import * as i5$1 from '@angular/forms';
23
24
  import { FormGroup, FormControl, FormsModule, ReactiveFormsModule } from '@angular/forms';
@@ -26,7 +27,6 @@ import * as i8 from 'primeng/inputtext';
26
27
  import { InputTextModule } from 'primeng/inputtext';
27
28
  import * as i6 from 'primeng/radiobutton';
28
29
  import { RadioButtonModule } from 'primeng/radiobutton';
29
- import * as i2$2 from 'primeng/api';
30
30
  import { catchError as catchError$1 } from 'rxjs/operators';
31
31
 
32
32
  const VELOCE_FLOW_ROOT_ROUTE = 'VELOCE_FLOW_ROOT_ROUTE';
@@ -97,9 +97,6 @@ class FlowHeaderComponent {
97
97
  }
98
98
  initialize() {
99
99
  this.templateApiName = this.flowInfo.flow?.properties.templates?.flowHeader ?? '';
100
- if (this.flowInfo.isLegacy && !this.templateApiName) {
101
- return;
102
- }
103
100
  this.generateUIDefinition$()
104
101
  .pipe(tap(uiDef => {
105
102
  if (!uiDef) {
@@ -210,9 +207,6 @@ class GuidedSellingComponent {
210
207
  }
211
208
  initialize() {
212
209
  this.templateApiName = this.flowInfo.flow?.properties.templates?.guidedSelling ?? '';
213
- if (this.flowInfo.isLegacy && !this.templateApiName) {
214
- return;
215
- }
216
210
  this.generateUIDefinition$()
217
211
  .pipe(tap(uiDef => {
218
212
  if (!uiDef) {
@@ -334,10 +328,10 @@ const configurePrimengShadowDOM = () => {
334
328
  };
335
329
 
336
330
  class FlowDialogService {
337
- constructor(dialogService, contextService, runtimeSettings) {
331
+ constructor(dialogService, runtimeSettings, flowInfoService) {
338
332
  this.dialogService = dialogService;
339
- this.contextService = contextService;
340
333
  this.runtimeSettings = runtimeSettings;
334
+ this.flowInfoService = flowInfoService;
341
335
  }
342
336
  show(config) {
343
337
  return this.dialogService.open(FlowDialogComponent, {
@@ -358,8 +352,8 @@ class FlowDialogService {
358
352
  });
359
353
  }
360
354
  showReadonlyModeDialog() {
361
- const ctx = this.contextService.resolve();
362
- const objectName = ctx.mode ? ctx.mode[0]?.toUpperCase() + ctx.mode.substring(1).toLowerCase() : 'Object';
355
+ const mode = this.flowInfoService.context.mode;
356
+ const objectName = mode ? mode[0]?.toUpperCase() + mode.substring(1).toLowerCase() : 'Object';
363
357
  return this.show({
364
358
  title: 'Error',
365
359
  description: `${objectName} Cannot be Saved`,
@@ -431,19 +425,17 @@ class FlowDialogService {
431
425
  return dialogFunction(dialog);
432
426
  }
433
427
  }
434
- FlowDialogService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: FlowDialogService, deps: [{ token: i1.DialogService }, { token: i2.ContextService }, { token: i2.RuntimeSettingsService }], target: i0.ɵɵFactoryTarget.Injectable });
428
+ FlowDialogService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: FlowDialogService, deps: [{ token: i1.DialogService }, { token: i2.RuntimeSettingsService }, { token: i2.FlowInfoService }], target: i0.ɵɵFactoryTarget.Injectable });
435
429
  FlowDialogService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: FlowDialogService });
436
430
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: FlowDialogService, decorators: [{
437
431
  type: Injectable
438
- }], ctorParameters: function () { return [{ type: i1.DialogService }, { type: i2.ContextService }, { type: i2.RuntimeSettingsService }]; } });
432
+ }], ctorParameters: function () { return [{ type: i1.DialogService }, { type: i2.RuntimeSettingsService }, { type: i2.FlowInfoService }]; } });
439
433
 
440
434
  class FlowRouterService {
441
- constructor(router, route, contextService, integrationState, flowInfoService, flowStateService) {
435
+ constructor(router, route, integrationState, flowStateService) {
442
436
  this.router = router;
443
437
  this.route = route;
444
- this.contextService = contextService;
445
438
  this.integrationState = integrationState;
446
- this.flowInfoService = flowInfoService;
447
439
  this.flowStateService = flowStateService;
448
440
  this.urlHistory = [];
449
441
  this.getLastChildRoute = (route) => {
@@ -553,19 +545,11 @@ class FlowRouterService {
553
545
  }
554
546
  }
555
547
  navigateToProductConfiguration(productId, lineItemId) {
556
- let updateContext$;
557
- if (this.flowInfoService.isLegacy) {
558
- updateContext$ = of(undefined).pipe(tap(() => {
559
- this.contextService.update({ properties: { productId, lineItemId: lineItemId ?? '' } });
560
- }));
561
- }
562
- else {
563
- updateContext$ = this.flowStateService.dispatch$(UITemplateType.FLOW_ENGINE, 'UPDATE_CONTEXT_PROPERTIES', {
564
- productId,
565
- lineItemId: lineItemId ?? '',
566
- });
567
- }
568
- updateContext$
548
+ this.flowStateService
549
+ .dispatch$(UITemplateType.FLOW_ENGINE, 'UPDATE_CONTEXT_PROPERTIES', {
550
+ productId,
551
+ lineItemId: lineItemId ?? '',
552
+ })
569
553
  .pipe(tap(() => {
570
554
  const routeSnapshot = this.getLastChildRouteSnapshot(this.route.snapshot);
571
555
  const flowRouteUrl = this.getFlowRootPath(routeSnapshot);
@@ -610,23 +594,20 @@ class FlowRouterService {
610
594
  this.router.navigate([], { relativeTo: route, queryParams: { ...routeSnapshot.queryParams, ...queryParams } });
611
595
  }
612
596
  }
613
- FlowRouterService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: FlowRouterService, deps: [{ token: i1$2.Router }, { token: i1$2.ActivatedRoute }, { token: i2.ContextService }, { token: i2.IntegrationState }, { token: i2.FlowInfoService }, { token: i2.FlowStateService }], target: i0.ɵɵFactoryTarget.Injectable });
597
+ FlowRouterService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: FlowRouterService, deps: [{ token: i1$2.Router }, { token: i1$2.ActivatedRoute }, { token: i2.IntegrationState }, { token: i2.FlowStateService }], target: i0.ɵɵFactoryTarget.Injectable });
614
598
  FlowRouterService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: FlowRouterService, providedIn: 'root' });
615
599
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: FlowRouterService, decorators: [{
616
600
  type: Injectable,
617
601
  args: [{ providedIn: 'root' }]
618
- }], ctorParameters: function () { return [{ type: i1$2.Router }, { type: i1$2.ActivatedRoute }, { type: i2.ContextService }, { type: i2.IntegrationState }, { type: i2.FlowInfoService }, { type: i2.FlowStateService }]; } });
602
+ }], ctorParameters: function () { return [{ type: i1$2.Router }, { type: i1$2.ActivatedRoute }, { type: i2.IntegrationState }, { type: i2.FlowStateService }]; } });
619
603
 
620
604
  class FlowService {
621
- constructor(integrationState, flowRouterService, quoteDraftService, configurationService, configurationStateService, flowDialogService, flowConfigurationService, flowInfoService, flowStateService) {
605
+ constructor(integrationState, flowRouterService, configurationService, configurationStateService, flowDialogService, flowStateService) {
622
606
  this.integrationState = integrationState;
623
607
  this.flowRouterService = flowRouterService;
624
- this.quoteDraftService = quoteDraftService;
625
608
  this.configurationService = configurationService;
626
609
  this.configurationStateService = configurationStateService;
627
610
  this.flowDialogService = flowDialogService;
628
- this.flowConfigurationService = flowConfigurationService;
629
- this.flowInfoService = flowInfoService;
630
611
  this.flowStateService = flowStateService;
631
612
  this.cleanup$ = new Subject();
632
613
  }
@@ -636,14 +617,7 @@ class FlowService {
636
617
  initSubscriptions() {
637
618
  this.integrationState
638
619
  .listen$(FlowAction.FLOW_CONFIGURE_PRODUCT)
639
- .pipe(switchMap(payload => {
640
- if (this.flowInfoService.isLegacy) {
641
- const productId = payload.productId ??
642
- this.quoteDraftService.currentState.find(li => li.id === payload.lineItemId)?.productId;
643
- return of({ ...payload, productId });
644
- }
645
- return this.prepareConfiguration$(payload.lineItemId).pipe(map(() => payload));
646
- }), tap(payload => {
620
+ .pipe(switchMap(payload => this.prepareConfiguration$(payload.lineItemId).pipe(map(() => payload))), tap(payload => {
647
621
  if (payload.productId) {
648
622
  this.flowRouterService.navigateToProductConfiguration(payload.productId, payload.lineItemId);
649
623
  }
@@ -689,17 +663,10 @@ class FlowService {
689
663
  .subscribe();
690
664
  this.integrationState
691
665
  .listen$(FlowAction.FLOW_APPLY_PRODUCT_CONFIGURATION)
692
- .pipe(switchMap(() => {
693
- if (this.flowInfoService.isLegacy) {
694
- return this.legacyApplyConfiguration();
695
- }
696
- else {
697
- return this.configurationStateService.saveConfiguration(true).pipe(switchMap(() => this.configurationStateService.cancelConfiguration()), switchMap(() => this.flowStateService.dispatch$(UITemplateType.FLOW_ENGINE, 'MODIFY_ASSETS', {
698
- addConfiguringAssetId: true,
699
- enable: true,
700
- })));
701
- }
702
- }), tap(() => {
666
+ .pipe(switchMap(() => this.configurationStateService.saveConfiguration()), switchMap(() => this.configurationStateService.cancelConfiguration()), switchMap(() => this.flowStateService.dispatch$(UITemplateType.FLOW_ENGINE, 'MODIFY_ASSETS', {
667
+ addConfiguringAssetId: true,
668
+ enable: true,
669
+ })), tap(() => {
703
670
  this.configurationService.hasUnsavedChanges = false;
704
671
  this.flowRouterService.navigateToShoppingCart();
705
672
  }), takeUntil(this.cleanup$))
@@ -723,28 +690,12 @@ class FlowService {
723
690
  lineItemId,
724
691
  });
725
692
  }
726
- legacyApplyConfiguration() {
727
- const quoteDraft = this.quoteDraftService.quoteDraft;
728
- const lineItem = this.configurationService.getSnapshot();
729
- if (!quoteDraft || !lineItem) {
730
- return of(undefined);
731
- }
732
- const isNewLineItem = quoteDraft.currentState.every(li => li.id !== lineItem.id);
733
- let updatedState;
734
- if (isNewLineItem) {
735
- updatedState = [...quoteDraft.currentState, lineItem];
736
- }
737
- else {
738
- updatedState = quoteDraft.currentState.map(li => (li.id === lineItem.id ? lineItem : li));
739
- }
740
- return this.flowConfigurationService.calculate$({ ...quoteDraft, currentState: updatedState });
741
- }
742
693
  }
743
- FlowService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: FlowService, deps: [{ token: i5.IntegrationState }, { token: FlowRouterService }, { token: i2.QuoteDraftService }, { token: i2.ConfigurationService }, { token: i2.ConfigurationStateService }, { token: FlowDialogService }, { token: i2.FlowConfigurationService }, { token: i2.FlowInfoService }, { token: i2.FlowStateService }], target: i0.ɵɵFactoryTarget.Injectable });
694
+ FlowService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: FlowService, deps: [{ token: i5.IntegrationState }, { token: FlowRouterService }, { token: i2.ConfigurationService }, { token: i2.ConfigurationStateService }, { token: FlowDialogService }, { token: i2.FlowStateService }], target: i0.ɵɵFactoryTarget.Injectable });
744
695
  FlowService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: FlowService });
745
696
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: FlowService, decorators: [{
746
697
  type: Injectable
747
- }], ctorParameters: function () { return [{ type: i5.IntegrationState }, { type: FlowRouterService }, { type: i2.QuoteDraftService }, { type: i2.ConfigurationService }, { type: i2.ConfigurationStateService }, { type: FlowDialogService }, { type: i2.FlowConfigurationService }, { type: i2.FlowInfoService }, { type: i2.FlowStateService }]; } });
698
+ }], ctorParameters: function () { return [{ type: i5.IntegrationState }, { type: FlowRouterService }, { type: i2.ConfigurationService }, { type: i2.ConfigurationStateService }, { type: FlowDialogService }, { type: i2.FlowStateService }]; } });
748
699
 
749
700
  class FlowGuidedSellingService {
750
701
  constructor(integrationState) {
@@ -775,14 +726,14 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImpor
775
726
  }], ctorParameters: function () { return [{ type: i2.IntegrationState }]; } });
776
727
 
777
728
  class FlowComponent {
778
- constructor(routerService, flowService, flowInfo, guidedSellingService) {
729
+ constructor(routerService, flowService, flowInfoService, guidedSellingService) {
779
730
  this.routerService = routerService;
780
731
  this.flowService = flowService;
781
- this.flowInfo = flowInfo;
732
+ this.flowInfoService = flowInfoService;
782
733
  this.guidedSellingService = guidedSellingService;
783
734
  this.isLoading$ = this.routerService.loading$;
784
- this.showHeader$ = combineLatest([this.routerService.route$, this.flowInfo.flow$]).pipe(map(([route, flow]) => route.data['showHeader'] && !flow?.properties.standalone));
785
- this.isStandalone$ = this.flowInfo.flow$.pipe(map(flow => Boolean(flow?.properties.standalone)));
735
+ this.showHeader$ = combineLatest([this.routerService.route$, this.flowInfoService.flow$]).pipe(map(([route, flow]) => route.data['showHeader'] && !flow?.properties.standalone));
736
+ this.isStandalone$ = this.flowInfoService.flow$.pipe(map(flow => Boolean(flow?.properties.standalone)));
786
737
  this.guidedSellingVisible$ = this.guidedSellingService.isVisible$;
787
738
  this.flowService.initSubscriptions();
788
739
  }
@@ -797,133 +748,31 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImpor
797
748
  args: [{ selector: 'vl-flow', changeDetection: ChangeDetectionStrategy.OnPush, template: "<vl-flow-new-header *ngIf=\"showHeader$ | async\"></vl-flow-new-header>\n\n<div class=\"flow-content\">\n <div class=\"loading-overlay\" *ngIf=\"isLoading$ | async\">\n <vl-loader label=\"LOADING\"></vl-loader>\n </div>\n\n <router-outlet></router-outlet>\n\n <div class=\"guided-selling\" [ngClass]=\"{ hidden: (guidedSellingVisible$ | async) === false }\">\n <vl-flow-guided-selling *ngIf=\"(isStandalone$ | async) !== true\"></vl-flow-guided-selling>\n </div>\n</div>\n", styles: [":host{display:flex;flex-direction:column;width:100%;height:100%}.flow-content{flex-grow:1;position:relative;overflow:hidden}.loading-overlay{position:absolute;height:100%;width:100%;inset:0;background-color:#fff;z-index:999}.guided-selling{position:absolute;top:0;width:100%;height:100%;z-index:100}.hidden{display:none}\n"] }]
798
749
  }], ctorParameters: function () { return [{ type: FlowRouterService }, { type: FlowService }, { type: i2.FlowInfoService }, { type: FlowGuidedSellingService }]; } });
799
750
 
800
- const getFlowObjectIdPropertyName = (id) => {
801
- const objectName = SalesforceIdUtils.getSfObjectNameById(id);
802
- switch (objectName) {
803
- case 'Account':
804
- return 'accountId';
805
- case 'Order':
806
- return 'orderId';
807
- case 'Quote':
808
- default:
809
- return 'quoteId';
810
- }
811
- };
812
- const getDefaultProperties = (params) => {
813
- const properties = {};
814
- let standalone = params.flowParams?.standalone;
815
- if (params.flowParams?.entryPath.includes('/product') || params.mode === ConfigurationContextMode.REMOTE) {
816
- standalone = standalone ?? true;
817
- }
818
- if (standalone != null) {
819
- properties.standalone = standalone ? 'true' : 'false';
820
- }
821
- return properties;
822
- };
823
-
824
- class ContextGuard {
825
- constructor(router, routerService, contextService, runtimeSettingsService) {
826
- this.router = router;
827
- this.routerService = routerService;
828
- this.contextService = contextService;
829
- this.runtimeSettingsService = runtimeSettingsService;
830
- }
831
- checkActivation(route) {
832
- const { queryParams } = route;
833
- const { accountId, quoteId, orderId } = queryParams;
834
- const rpcMessage = window.RPC_MESSAGE;
835
- const mode = this.getConfigurationContextMode(accountId, quoteId, orderId, rpcMessage);
836
- // Restrict if mode is not defined
837
- if (mode == null) {
838
- return this.routerService.showErrorPage$('Mode is undefined');
839
- }
840
- const headerId = accountId || quoteId || orderId || this.rpcMessageId || 'empty-for-test-mode';
841
- // Allow if context is already initialized with the same headerId
842
- if (this.contextService.isInitialized) {
843
- const currentContext = this.contextService.resolve();
844
- if (headerId && currentContext.headerId === headerId) {
845
- return of(true);
846
- }
847
- }
848
- // Initialize context and runtime settings
849
- return forkJoin([this.contextService.create(headerId, mode), this.runtimeSettingsService.create()]).pipe(tap(([context]) => {
850
- this.contextService.update({
851
- ...context,
852
- properties: {
853
- ...context.properties,
854
- ...(queryParams ?? {}),
855
- ...getDefaultProperties({ mode }),
856
- },
857
- });
858
- // Init currency settings
859
- this.runtimeSettingsService.initCurrency(context.properties['CurrencyIsoCode']);
860
- }), map(() => true), catchError(e => {
861
- const message = e instanceof HttpErrorResponse ? e.error.message : e;
862
- const errorDetails = isVeloceError(e.error) ? extractErrorDetails(e.error) : [];
863
- return this.routerService.showErrorPage$(message, errorDetails);
864
- }));
865
- }
866
- canActivate(route) {
867
- return this.checkActivation(route);
868
- }
869
- canActivateChild(childRoute) {
870
- return this.checkActivation(childRoute);
871
- }
872
- get rpcMessageId() {
873
- if (!window.RPC_MESSAGE) {
874
- return;
875
- }
876
- const rpcMessage = JSON.parse(window.RPC_MESSAGE);
877
- const veloceReferenceId = rpcMessage.configuration?.VeloceReferenceId;
878
- const quoteId = rpcMessage.quote?.Id;
879
- return veloceReferenceId || quoteId;
880
- }
881
- getConfigurationContextMode(accountId, quoteId, orderId, rpcMessage) {
882
- if (accountId) {
883
- return ConfigurationContextMode.ACCOUNT;
884
- }
885
- if (quoteId) {
886
- return ConfigurationContextMode.QUOTE;
887
- }
888
- if (orderId) {
889
- return ConfigurationContextMode.ORDER;
890
- }
891
- if (rpcMessage) {
892
- return ConfigurationContextMode.REMOTE;
893
- }
894
- return;
895
- }
896
- }
897
- ContextGuard.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: ContextGuard, deps: [{ token: i1$2.Router }, { token: FlowRouterService }, { token: i2.ContextService }, { token: i2.RuntimeSettingsService }], target: i0.ɵɵFactoryTarget.Injectable });
898
- ContextGuard.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: ContextGuard });
899
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: ContextGuard, decorators: [{
900
- type: Injectable
901
- }], ctorParameters: function () { return [{ type: i1$2.Router }, { type: FlowRouterService }, { type: i2.ContextService }, { type: i2.RuntimeSettingsService }]; } });
902
-
903
751
  const keepFlowInitialized = (route) => {
904
- const contextService = inject(ContextService);
752
+ const routerService = inject(FlowRouterService);
753
+ const runtimeSettingsService = inject(RuntimeSettingsService);
905
754
  const flowState = inject(FlowStateService);
906
755
  const flowInfoService = inject(FlowInfoService);
907
- const routerService = inject(FlowRouterService);
908
756
  const quoteDraft = inject(QuoteDraftService);
757
+ const salesTrasnsactionService = inject(SalesTransactionService);
909
758
  const configurationService = inject(ConfigurationService);
910
759
  const integrationState = inject(IntegrationState);
911
760
  const { flowId } = route.queryParams;
912
- const flow = flowInfoService.flow;
913
- if (flow && flow?.id === flowId) {
761
+ if (flowInfoService.isFlowInitialized && flowInfoService.flow.id === flowId) {
914
762
  return true;
915
763
  }
916
764
  // Cleanup
917
765
  flowState.cleanup();
918
766
  quoteDraft.reset();
767
+ salesTrasnsactionService.reset();
919
768
  configurationService.reset();
920
769
  integrationState.clear();
921
770
  flowInfoService.cleanup();
922
- contextService.delete();
923
771
  if (!flowId) {
924
772
  return true;
925
773
  }
926
- return flowInfoService.init$(flowId, route.queryParams).pipe(map(() => true), catchError(e => {
774
+ return runtimeSettingsService.create().pipe(tap(() => runtimeSettingsService.initCurrency('USD')), switchMap(() => flowInfoService.init$(flowId, route.queryParams)), map(() => true), catchError(e => {
775
+ console.error(e);
927
776
  const message = e instanceof HttpErrorResponse ? e.error.message : e;
928
777
  const errorDetails = isVeloceError(e.error) ? extractErrorDetails(e.error) : [];
929
778
  return routerService.showErrorPage$(message, errorDetails);
@@ -931,9 +780,8 @@ const keepFlowInitialized = (route) => {
931
780
  };
932
781
 
933
782
  class ProductUnloadGuard {
934
- constructor(router, contextService, quoteDraftService, configurationService, flowDialogService) {
783
+ constructor(router, quoteDraftService, configurationService, flowDialogService) {
935
784
  this.router = router;
936
- this.contextService = contextService;
937
785
  this.quoteDraftService = quoteDraftService;
938
786
  this.configurationService = configurationService;
939
787
  this.flowDialogService = flowDialogService;
@@ -946,7 +794,6 @@ class ProductUnloadGuard {
946
794
  return observable.pipe(map(unload => {
947
795
  if (unload) {
948
796
  this.configurationService.reset();
949
- this.contextService.update({ properties: { productId: undefined, lineItemId: undefined } });
950
797
  if (!nextState || currentState.url === nextState.url) {
951
798
  return true;
952
799
  }
@@ -964,11 +811,11 @@ class ProductUnloadGuard {
964
811
  }));
965
812
  }
966
813
  }
967
- ProductUnloadGuard.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: ProductUnloadGuard, deps: [{ token: i1$2.Router }, { token: i2.ContextService }, { token: i2.QuoteDraftService }, { token: i2.ConfigurationService }, { token: FlowDialogService }], target: i0.ɵɵFactoryTarget.Injectable });
814
+ ProductUnloadGuard.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: ProductUnloadGuard, deps: [{ token: i1$2.Router }, { token: i2.QuoteDraftService }, { token: i2.ConfigurationService }, { token: FlowDialogService }], target: i0.ɵɵFactoryTarget.Injectable });
968
815
  ProductUnloadGuard.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: ProductUnloadGuard });
969
816
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: ProductUnloadGuard, decorators: [{
970
817
  type: Injectable
971
- }], ctorParameters: function () { return [{ type: i1$2.Router }, { type: i2.ContextService }, { type: i2.QuoteDraftService }, { type: i2.ConfigurationService }, { type: FlowDialogService }]; } });
818
+ }], ctorParameters: function () { return [{ type: i1$2.Router }, { type: i2.QuoteDraftService }, { type: i2.ConfigurationService }, { type: FlowDialogService }]; } });
972
819
 
973
820
  class RootGuard {
974
821
  constructor(router, routerService) {
@@ -1229,11 +1076,10 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImpor
1229
1076
  }] });
1230
1077
 
1231
1078
  class DebugComponent {
1232
- constructor(flowsApiService, router, activatedRoute, context, quoteDraftService) {
1079
+ constructor(flowsApiService, router, activatedRoute, quoteDraftService) {
1233
1080
  this.flowsApiService = flowsApiService;
1234
1081
  this.router = router;
1235
1082
  this.activatedRoute = activatedRoute;
1236
- this.context = context;
1237
1083
  this.quoteDraftService = quoteDraftService;
1238
1084
  this.form = new FormGroup({
1239
1085
  id: new FormControl(''),
@@ -1242,17 +1088,15 @@ class DebugComponent {
1242
1088
  }
1243
1089
  runFlow() {
1244
1090
  const { id } = this.form.value;
1245
- const objectPropertyName = id && getFlowObjectIdPropertyName(id);
1246
- if (!id || !objectPropertyName || !this.selectedFlow) {
1091
+ if (!id || !this.selectedFlow) {
1247
1092
  return;
1248
1093
  }
1249
1094
  // Delete context before starting a new flow
1250
- this.context.delete();
1251
1095
  this.quoteDraftService.reset();
1252
1096
  this.router.navigate(['..', 'flows'], {
1253
1097
  queryParams: {
1254
1098
  flowId: this.selectedFlow.id,
1255
- [objectPropertyName]: id,
1099
+ headerId: id,
1256
1100
  ...this.selectedFlow.properties.queryParams,
1257
1101
  },
1258
1102
  relativeTo: this.activatedRoute,
@@ -1262,12 +1106,12 @@ class DebugComponent {
1262
1106
  return new HttpParams({ fromObject: params }).toString();
1263
1107
  }
1264
1108
  }
1265
- DebugComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: DebugComponent, deps: [{ token: i1$1.FlowsApiService }, { token: i1$2.Router }, { token: i1$2.ActivatedRoute }, { token: i2.ContextService }, { token: i2.QuoteDraftService }], target: i0.ɵɵFactoryTarget.Component });
1109
+ DebugComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: DebugComponent, deps: [{ token: i1$3.FlowsApiService }, { token: i1$2.Router }, { token: i1$2.ActivatedRoute }, { token: i2.QuoteDraftService }], target: i0.ɵɵFactoryTarget.Component });
1266
1110
  DebugComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "15.2.9", type: DebugComponent, selector: "vl-flow-debug", ngImport: i0, template: "<form [formGroup]=\"form\">\n <div class=\"fields-container\">\n <div class=\"field\">\n <label>SF Object ID</label>\n <input formControlName=\"id\" pInputText type=\"text\" />\n </div>\n </div>\n\n <p-button\n styleClass=\"p-button-primary\"\n label=\"Run Flow\"\n [disabled]=\"!form.value.id || !selectedFlow\"\n (onClick)=\"runFlow()\"\n ></p-button>\n</form>\n\n<table>\n <thead>\n <tr>\n <th [width]=\"30\"></th>\n <th [width]=\"160\">ID</th>\n <th [width]=\"160\">Entry Path</th>\n <th>QueryParams</th>\n <th [width]=\"100\">Standalone</th>\n <th [width]=\"100\">Stateful</th>\n </tr>\n </thead>\n <tbody>\n <tr *ngFor=\"let flow of flows$ | async\" (click)=\"selectedFlow = flow\">\n <td><p-radioButton [inputId]=\"flow.id\" name=\"flow\" [value]=\"flow\" [(ngModel)]=\"selectedFlow\"></p-radioButton></td>\n <td>{{ flow.id }}</td>\n <td>{{ flow.properties.entryPath }}</td>\n <td class=\"cell-query-params\">{{ getQueryParamsString(flow.properties.queryParams) }}</td>\n <td>{{ flow.properties.standalone }}</td>\n <td>{{ flow.properties.stateful }}</td>\n </tr>\n </tbody>\n</table>\n", styles: [":host{display:block;padding:24px 54px}form{display:flex;align-items:center;justify-content:space-between}.fields-container{display:flex;gap:24px}.field{display:flex;flex-direction:column;width:200px;flex-shrink:0}:host ::ng-deep .p-dropdown{width:100%}table{width:100%;border-collapse:collapse;table-layout:fixed}tbody>tr{cursor:pointer}tbody>tr:hover{background-color:#f0f5fa}th{text-align:left;font-weight:600}th,td{padding:0 10px;height:30px;border-bottom:1px solid var(--vl-border-color);margin-right:16px;line-height:18px}.cell-query-params{word-break:break-all}\n"], dependencies: [{ kind: "directive", type: i4.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { kind: "directive", type: i5$1.ɵNgNoValidate, selector: "form:not([ngNoForm]):not([ngNativeValidate])" }, { kind: "directive", type: i5$1.DefaultValueAccessor, selector: "input:not([type=checkbox])[formControlName],textarea[formControlName],input:not([type=checkbox])[formControl],textarea[formControl],input:not([type=checkbox])[ngModel],textarea[ngModel],[ngDefaultControl]" }, { kind: "directive", type: i5$1.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i5$1.NgControlStatusGroup, selector: "[formGroupName],[formArrayName],[ngModelGroup],[formGroup],form:not([ngNoForm]),[ngForm]" }, { kind: "directive", type: i5$1.NgModel, selector: "[ngModel]:not([formControlName]):not([formControl])", inputs: ["name", "disabled", "ngModel", "ngModelOptions"], outputs: ["ngModelChange"], exportAs: ["ngModel"] }, { kind: "directive", type: i5$1.FormGroupDirective, selector: "[formGroup]", inputs: ["formGroup"], outputs: ["ngSubmit"], exportAs: ["ngForm"] }, { kind: "directive", type: i5$1.FormControlName, selector: "[formControlName]", inputs: ["formControlName", "disabled", "ngModel"], outputs: ["ngModelChange"] }, { kind: "component", type: i6.RadioButton, selector: "p-radioButton", inputs: ["value", "formControlName", "name", "disabled", "label", "tabindex", "inputId", "ariaLabelledBy", "ariaLabel", "style", "styleClass", "labelStyleClass"], outputs: ["onClick", "onFocus", "onBlur"] }, { kind: "component", type: i3.Button, selector: "p-button", inputs: ["type", "iconPos", "icon", "badge", "label", "disabled", "loading", "loadingIcon", "style", "styleClass", "badgeClass"], outputs: ["onClick", "onFocus", "onBlur"] }, { kind: "directive", type: i8.InputText, selector: "[pInputText]" }, { kind: "pipe", type: i4.AsyncPipe, name: "async" }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
1267
1111
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: DebugComponent, decorators: [{
1268
1112
  type: Component,
1269
1113
  args: [{ selector: 'vl-flow-debug', changeDetection: ChangeDetectionStrategy.OnPush, template: "<form [formGroup]=\"form\">\n <div class=\"fields-container\">\n <div class=\"field\">\n <label>SF Object ID</label>\n <input formControlName=\"id\" pInputText type=\"text\" />\n </div>\n </div>\n\n <p-button\n styleClass=\"p-button-primary\"\n label=\"Run Flow\"\n [disabled]=\"!form.value.id || !selectedFlow\"\n (onClick)=\"runFlow()\"\n ></p-button>\n</form>\n\n<table>\n <thead>\n <tr>\n <th [width]=\"30\"></th>\n <th [width]=\"160\">ID</th>\n <th [width]=\"160\">Entry Path</th>\n <th>QueryParams</th>\n <th [width]=\"100\">Standalone</th>\n <th [width]=\"100\">Stateful</th>\n </tr>\n </thead>\n <tbody>\n <tr *ngFor=\"let flow of flows$ | async\" (click)=\"selectedFlow = flow\">\n <td><p-radioButton [inputId]=\"flow.id\" name=\"flow\" [value]=\"flow\" [(ngModel)]=\"selectedFlow\"></p-radioButton></td>\n <td>{{ flow.id }}</td>\n <td>{{ flow.properties.entryPath }}</td>\n <td class=\"cell-query-params\">{{ getQueryParamsString(flow.properties.queryParams) }}</td>\n <td>{{ flow.properties.standalone }}</td>\n <td>{{ flow.properties.stateful }}</td>\n </tr>\n </tbody>\n</table>\n", styles: [":host{display:block;padding:24px 54px}form{display:flex;align-items:center;justify-content:space-between}.fields-container{display:flex;gap:24px}.field{display:flex;flex-direction:column;width:200px;flex-shrink:0}:host ::ng-deep .p-dropdown{width:100%}table{width:100%;border-collapse:collapse;table-layout:fixed}tbody>tr{cursor:pointer}tbody>tr:hover{background-color:#f0f5fa}th{text-align:left;font-weight:600}th,td{padding:0 10px;height:30px;border-bottom:1px solid var(--vl-border-color);margin-right:16px;line-height:18px}.cell-query-params{word-break:break-all}\n"] }]
1270
- }], ctorParameters: function () { return [{ type: i1$1.FlowsApiService }, { type: i1$2.Router }, { type: i1$2.ActivatedRoute }, { type: i2.ContextService }, { type: i2.QuoteDraftService }]; } });
1114
+ }], ctorParameters: function () { return [{ type: i1$3.FlowsApiService }, { type: i1$2.Router }, { type: i1$2.ActivatedRoute }, { type: i2.QuoteDraftService }]; } });
1271
1115
 
1272
1116
  const routes$1 = [{ path: '', component: DebugComponent }];
1273
1117
  class DebugModule {
@@ -1305,97 +1149,75 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImpor
1305
1149
  }] });
1306
1150
 
1307
1151
  class ProductComponent {
1308
- constructor(contextService, configurationRuntimeService, configurationService, configurationStateService, quoteDraftService, flowInfoService, flowStateService, integrationState, customizationService) {
1309
- this.contextService = contextService;
1310
- this.configurationRuntimeService = configurationRuntimeService;
1152
+ constructor(
1153
+ // private configurationRuntimeService: ConfigurationRuntimeService,
1154
+ configurationService, configurationStateService, salesTransactionService, flowInfoService, integrationState, uiDefinitionsApiService, customizationService) {
1311
1155
  this.configurationService = configurationService;
1312
1156
  this.configurationStateService = configurationStateService;
1313
- this.quoteDraftService = quoteDraftService;
1157
+ this.salesTransactionService = salesTransactionService;
1314
1158
  this.flowInfoService = flowInfoService;
1315
- this.flowStateService = flowStateService;
1316
1159
  this.integrationState = integrationState;
1160
+ this.uiDefinitionsApiService = uiDefinitionsApiService;
1317
1161
  this.customizationService = customizationService;
1318
- this.uiDefinition$ = new BehaviorSubject(undefined);
1162
+ this.uiDefinitionContainer$ = new BehaviorSubject(null);
1319
1163
  this.config = {
1320
1164
  init$: () => this.init$(),
1321
1165
  };
1322
1166
  }
1323
1167
  customizeUI$() {
1324
- const { productId } = this.configurationRuntimeService.runtimeContext ?? {};
1168
+ const { productId } = this.flowInfoService.context;
1325
1169
  if (!productId || !this.customizationService?.getUiDefinition) {
1326
1170
  return of(undefined);
1327
1171
  }
1328
1172
  return this.customizationService.getUiDefinition(productId).pipe(map(uiDefinitionContainer => {
1329
- if (uiDefinitionContainer) {
1330
- this.configurationRuntimeService.overrideUIDefinition(uiDefinitionContainer);
1173
+ this.uiDefinitionContainer$.next(uiDefinitionContainer);
1174
+ }));
1175
+ }
1176
+ fetchUIDefinition$() {
1177
+ const flowContext = this.flowInfoService.context;
1178
+ if (flowContext.requiredUIDefinitionId) {
1179
+ return this.uiDefinitionsApiService
1180
+ .fetchUIDefinition$(flowContext.requiredUIDefinitionId)
1181
+ .pipe(map((uiDefContainer) => this.uiDefinitionContainer$.next(uiDefContainer)));
1182
+ }
1183
+ return this.uiDefinitionsApiService
1184
+ .fetchUIDefinitions$({
1185
+ productId: flowContext.productId,
1186
+ defaultUIDefinitionId: flowContext.defaultUIDefinitionId,
1187
+ })
1188
+ .pipe(map((uiDefinitionContainers) => {
1189
+ const uiDefContainer = uiDefinitionContainers[0];
1190
+ if (uiDefContainer) {
1191
+ this.uiDefinitionContainer$.next(uiDefContainer);
1331
1192
  }
1332
1193
  }));
1333
1194
  }
1334
1195
  init$() {
1335
- let quoteDraft$;
1336
- if (this.flowInfoService.isLegacy || !this.flowInfoService.isStateful) {
1337
- quoteDraft$ = this.quoteDraftService.quoteDraft$;
1196
+ let state$;
1197
+ if (!this.flowInfoService.isStateful) {
1198
+ state$ = this.salesTransactionService.state$;
1338
1199
  }
1339
1200
  else {
1340
- quoteDraft$ = of(undefined);
1201
+ state$ = of(undefined);
1341
1202
  }
1342
- return quoteDraft$.pipe(first(), switchMap(quote => {
1343
- const contextProperties = this.contextService.resolve().properties;
1344
- const productId = contextProperties.productId ?? this.flowInfoService.flow?.properties.queryParams['productId'];
1345
- const defaultUIDefinitionId = this.flowInfoService.flow?.properties.queryParams['defaultUIDefinitionId'];
1346
- const requiredUIDefinitionId = this.flowInfoService.flow?.properties.queryParams['requiredUIDefinitionId'];
1347
- if (!productId) {
1203
+ return state$.pipe(first(), tap(() => {
1204
+ if (!this.flowInfoService.context.productId) {
1348
1205
  throw new Error(`Unable to start configuration for 'productId == null'`);
1349
1206
  }
1350
- if (!quote) {
1351
- const offeringId = contextProperties.offeringId;
1352
- return this.configurationRuntimeService.init({ productId, offeringId });
1353
- }
1354
- const lineItem = this.getLineItem(quote, productId, contextProperties.lineItemId);
1355
- if (lineItem) {
1356
- this.configurationService.setConfigurableRamp(lineItem);
1357
- }
1358
- const { offeringId } = lineItem ?? {};
1359
- return this.configurationRuntimeService.init({
1360
- productId,
1361
- offeringId,
1362
- defaultUIDefinitionId,
1363
- requiredUIDefinitionId,
1364
- });
1365
- }), switchMap(() => this.customizeUI$()), tap(() => {
1366
- const uiDefinition = this.configurationRuntimeService.runtimeContext?.uiDefinitionContainer?.source;
1367
- if (uiDefinition) {
1368
- this.uiDefinition$.next(uiDefinition);
1369
- }
1370
- else {
1207
+ }), switchMap(() => this.customizeUI$()), switchMap(() => (this.uiDefinitionContainer$.value ? of(undefined) : this.fetchUIDefinition$())), tap(() => {
1208
+ if (!this.uiDefinitionContainer$.value) {
1371
1209
  throw new Error('Product does not have Configuration UI');
1372
1210
  }
1373
- }), tap(() => {
1374
- if (this.configurationRuntimeService.initializationProps) {
1375
- this.configurationRuntimeService.initializationProps.attributesMap =
1376
- this.integrationState.state.guidedSelling;
1377
- }
1378
- }), switchMap(() => this.configurationStateService.init$()));
1379
- }
1380
- getLineItem(quote, productId, lineItemId) {
1381
- // search by lineItemId first
1382
- let li = quote.currentState.find(li => li.id === lineItemId);
1383
- if (!li && this.quoteDraftService.isStandalone) {
1384
- li = quote.currentState.find(li => li.productId === productId);
1385
- }
1386
- // If still not found, is could be an asset
1387
- if (!li) {
1388
- li = this.quoteDraftService.assetsState?.currentState.find(li => li.id === lineItemId);
1389
- }
1390
- return li;
1211
+ }), switchMap(() => this.configurationStateService.init$()), switchMap(() => timer(1)), // wait until updates inputs on child components
1212
+ map(noop));
1391
1213
  }
1392
1214
  }
1393
- ProductComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: ProductComponent, deps: [{ token: i2.ContextService }, { token: i2.ConfigurationRuntimeService }, { token: i2.ConfigurationService }, { token: i2.ConfigurationStateService }, { token: i2.QuoteDraftService }, { token: i2.FlowInfoService }, { token: i2.FlowStateService }, { token: i2.IntegrationState }, { token: FLOW_CUSTOMIZATION, optional: true }], target: i0.ɵɵFactoryTarget.Component });
1394
- ProductComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "15.2.9", type: ProductComponent, selector: "vl-flow-product", ngImport: i0, template: "<vl-cms-preview [uiDefinition]=\"$any(uiDefinition$ | async)\" [config]=\"config\"></vl-cms-preview>\n", styles: [""], dependencies: [{ kind: "component", type: i5.PreviewComponent, selector: "vl-cms-preview", inputs: ["uiDefinition", "config"] }, { kind: "pipe", type: i4.AsyncPipe, name: "async" }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
1215
+ ProductComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: ProductComponent, deps: [{ token: i2.ConfigurationService }, { token: i2.ConfigurationStateService }, { token: i2.SalesTransactionService }, { token: i2.FlowInfoService }, { token: i2.IntegrationState }, { token: i1$1.UIDefinitionsApiService }, { token: FLOW_CUSTOMIZATION, optional: true }], target: i0.ɵɵFactoryTarget.Component });
1216
+ ProductComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "15.2.9", type: ProductComponent, selector: "vl-flow-product", ngImport: i0, template: "<vl-cms-preview [uiDefinition]=\"(uiDefinitionContainer$ | async)?.source\" [config]=\"config\"></vl-cms-preview>\n", styles: [""], dependencies: [{ kind: "component", type: i5.PreviewComponent, selector: "vl-cms-preview", inputs: ["uiDefinition", "config"] }, { kind: "pipe", type: i4.AsyncPipe, name: "async" }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
1395
1217
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: ProductComponent, decorators: [{
1396
1218
  type: Component,
1397
- args: [{ selector: 'vl-flow-product', changeDetection: ChangeDetectionStrategy.OnPush, template: "<vl-cms-preview [uiDefinition]=\"$any(uiDefinition$ | async)\" [config]=\"config\"></vl-cms-preview>\n" }]
1398
- }], ctorParameters: function () { return [{ type: i2.ContextService }, { type: i2.ConfigurationRuntimeService }, { type: i2.ConfigurationService }, { type: i2.ConfigurationStateService }, { type: i2.QuoteDraftService }, { type: i2.FlowInfoService }, { type: i2.FlowStateService }, { type: i2.IntegrationState }, { type: undefined, decorators: [{
1219
+ args: [{ selector: 'vl-flow-product', changeDetection: ChangeDetectionStrategy.OnPush, template: "<vl-cms-preview [uiDefinition]=\"(uiDefinitionContainer$ | async)?.source\" [config]=\"config\"></vl-cms-preview>\n" }]
1220
+ }], ctorParameters: function () { return [{ type: i2.ConfigurationService }, { type: i2.ConfigurationStateService }, { type: i2.SalesTransactionService }, { type: i2.FlowInfoService }, { type: i2.IntegrationState }, { type: i1$1.UIDefinitionsApiService }, { type: undefined, decorators: [{
1399
1221
  type: Optional
1400
1222
  }, {
1401
1223
  type: Inject,
@@ -1405,13 +1227,13 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImpor
1405
1227
  class ProductModule {
1406
1228
  }
1407
1229
  ProductModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: ProductModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
1408
- ProductModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "15.2.9", ngImport: i0, type: ProductModule, declarations: [ProductComponent], imports: [CommonModule, PreviewModule, LoaderModule], exports: [ProductComponent] });
1409
- ProductModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: ProductModule, imports: [CommonModule, PreviewModule, LoaderModule] });
1230
+ ProductModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "15.2.9", ngImport: i0, type: ProductModule, declarations: [ProductComponent], imports: [CommonModule, PreviewModule, LoaderModule, LetDirectiveModule], exports: [ProductComponent] });
1231
+ ProductModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: ProductModule, imports: [CommonModule, PreviewModule, LoaderModule, LetDirectiveModule] });
1410
1232
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: ProductModule, decorators: [{
1411
1233
  type: NgModule,
1412
1234
  args: [{
1413
1235
  declarations: [ProductComponent],
1414
- imports: [CommonModule, PreviewModule, LoaderModule],
1236
+ imports: [CommonModule, PreviewModule, LoaderModule, LetDirectiveModule],
1415
1237
  exports: [ProductComponent],
1416
1238
  }]
1417
1239
  }] });
@@ -1453,349 +1275,6 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImpor
1453
1275
  }]
1454
1276
  }] });
1455
1277
 
1456
- class RemoteComponent {
1457
- constructor(contextService, quoteDraftService, runtimeService, configurationService, configurationState, messageService, integrationState, location) {
1458
- this.contextService = contextService;
1459
- this.quoteDraftService = quoteDraftService;
1460
- this.runtimeService = runtimeService;
1461
- this.configurationService = configurationService;
1462
- this.configurationState = configurationState;
1463
- this.messageService = messageService;
1464
- this.integrationState = integrationState;
1465
- this.location = location;
1466
- this.state$ = new BehaviorSubject({ loading: true, failure: false });
1467
- this.DYNAMIC_OPTION_PRODUCTS_KEY = 'Dynamic';
1468
- this.destroyed$ = new Subject();
1469
- this.rpcMessage = JSON.parse(window.RPC_MESSAGE);
1470
- this.rpcMessage.options.sort((a, b) => (a.featureNumber ?? 99999) - (b.featureNumber ?? 99999));
1471
- this.updateHasChildrenFlag(this.rpcMessage.product.configuredProductId);
1472
- // update context properties
1473
- if (this.rpcMessage.quote) {
1474
- const properties = {};
1475
- if (this.rpcMessage.quote['SBQQ__Opportunity2__c']) {
1476
- properties.OpportunityId = this.rpcMessage.quote['SBQQ__Opportunity2__c'];
1477
- }
1478
- Object.entries(this.rpcMessage.quote).forEach(([key, value]) => {
1479
- if (value !== undefined && !(value instanceof Object)) {
1480
- properties[key] = value;
1481
- }
1482
- });
1483
- this.contextService.update({ properties });
1484
- }
1485
- this.initSubscriptions();
1486
- this.initConfiguration();
1487
- }
1488
- ngOnDestroy() {
1489
- this.destroyed$.next();
1490
- this.destroyed$.complete();
1491
- }
1492
- initConfiguration() {
1493
- const productId = this.rpcMessage.product.configuredProductId;
1494
- const quote = this.quoteDraftService.quoteDraft;
1495
- if (!productId || !quote) {
1496
- return;
1497
- }
1498
- this.runtimeService
1499
- .init({ productId })
1500
- .pipe(first(), tap(context => {
1501
- const uiDefinitionProperties = context.uiDefinitionContainer?.source.properties ?? {};
1502
- this.uiDefinition = context.uiDefinitionContainer?.source;
1503
- const pricingEnabled = uiDefinitionProperties.pricingEnabled ? 'true' : 'false';
1504
- const priceListId = uiDefinitionProperties.priceList;
1505
- const runtimeContextProperties = this.runtimeService.runtimeContext?.properties;
1506
- if (runtimeContextProperties) {
1507
- runtimeContextProperties.PriceListId = priceListId;
1508
- runtimeContextProperties.PricingEnabled = pricingEnabled;
1509
- }
1510
- this.contextService.update({
1511
- properties: {
1512
- ModelId: context.modelId,
1513
- RuntimeMode: 'TEST',
1514
- PricingEnabled: pricingEnabled,
1515
- PriceListId: priceListId,
1516
- },
1517
- });
1518
- this.configurationService.setConfigurableRamp(this.createLineItem());
1519
- }), this.throwIfNoUIDefinition(), switchMap(() => this.configurationState.init$()), tap(() => this.state$.next({ loading: false, failure: false })), catchError(error => {
1520
- if (!this.uiDefinition?.properties?.suppressToastMessages) {
1521
- this.messageService.add({ severity: 'error', summary: error });
1522
- }
1523
- this.state$.next({ loading: false, failure: true });
1524
- return of();
1525
- }), takeUntil(this.destroyed$))
1526
- .subscribe();
1527
- }
1528
- throwIfNoUIDefinition() {
1529
- return (source$) => {
1530
- return source$.pipe(switchMap(() => {
1531
- if (!this.uiDefinition) {
1532
- return throwError(() => 'Product does not have Configuration UI');
1533
- }
1534
- return source$;
1535
- }));
1536
- };
1537
- }
1538
- initSubscriptions() {
1539
- this.integrationState
1540
- .listen$(FlowAction.REMOTE_CANCEL)
1541
- .pipe(tap(() => this.location.back()), takeUntil(this.destroyed$))
1542
- .subscribe();
1543
- this.integrationState
1544
- .listen$(FlowAction.REMOTE_APPLY)
1545
- .pipe(tap(() => this.saveRpcMessage()), takeUntil(this.destroyed$))
1546
- .subscribe();
1547
- }
1548
- createLineItem() {
1549
- const [quoteDraftLineItem] = this.quoteDraftService.quoteDraft?.currentState ?? [];
1550
- if (quoteDraftLineItem && (quoteDraftLineItem.attributes.length > 0 || quoteDraftLineItem.lineItems.length > 0)) {
1551
- return quoteDraftLineItem;
1552
- }
1553
- const lineItem = this.createRootLineItem();
1554
- const dynamicOptionProducts = this.rpcMessage.product.optionConfigurations[this.DYNAMIC_OPTION_PRODUCTS_KEY];
1555
- if (dynamicOptionProducts) {
1556
- const options = this.toParentChildMap(dynamicOptionProducts);
1557
- let items = [lineItem];
1558
- for (let i = 0; i < items.length; i++) {
1559
- const item = items[i];
1560
- const children = item && options.get(item.id);
1561
- if (children) {
1562
- item.lineItems = children;
1563
- items = items.concat(children);
1564
- }
1565
- }
1566
- }
1567
- return lineItem;
1568
- }
1569
- createRootLineItem() {
1570
- const product = this.rpcMessage.product;
1571
- const runtimeContext = this.runtimeService.runtimeContext;
1572
- const veloceInstanceId = product.configurationAttributes['VeloceInstanceId__c'];
1573
- const quoteId = this.quoteDraftService.quoteDraft?.currentState[0]?.id;
1574
- return {
1575
- id: quoteId || veloceInstanceId || UUID.UUID(),
1576
- type: runtimeContext.productType ?? '',
1577
- name: runtimeContext.properties?.['displayName'] || runtimeContext.productName,
1578
- productName: runtimeContext.productName,
1579
- productId: runtimeContext.productId,
1580
- cfgStatus: 'Default',
1581
- actionCode: 'ADD',
1582
- qty: 1,
1583
- };
1584
- }
1585
- toParentChildMap(remoteOptionProducts) {
1586
- const result = new Map();
1587
- for (const option of remoteOptionProducts) {
1588
- const configurationData = option?.readOnly?.line;
1589
- const id = configurationData?.VeloceInstanceId__c;
1590
- const parentId = configurationData?.VeloceParentInstanceId__c;
1591
- if (!option.selected || !configurationData || !id || !parentId) {
1592
- continue;
1593
- }
1594
- const productId = option.productId;
1595
- const lineItem = {
1596
- id,
1597
- productId,
1598
- parentId,
1599
- type: configurationData.ModelType__c,
1600
- port: configurationData.ModelPort__c,
1601
- cfgStatus: configurationData.ConfigurationStatus__c,
1602
- actionCode: configurationData.ActionCode__c,
1603
- qty: option.Quantity,
1604
- };
1605
- let siblings = result.get(productId);
1606
- if (!siblings) {
1607
- result.set(parentId, (siblings = []));
1608
- }
1609
- siblings.push(lineItem);
1610
- }
1611
- return result;
1612
- }
1613
- saveRpcMessage() {
1614
- const quote = this.quoteDraftService.quoteDraft;
1615
- const lineItem = this.configurationService.getSnapshot();
1616
- if (!quote || !lineItem) {
1617
- return;
1618
- }
1619
- this.rpcMessage.VeloceReferenceId = quote.quoteId;
1620
- this.rpcMessage.product.configurationData.VeloceInstanceId__c = lineItem.id;
1621
- const childItems = this.flattenChildLineItems(lineItem);
1622
- const savingMode = window.SavingMode;
1623
- this.updateContentData(this.rpcMessage.product, lineItem);
1624
- this.rpcMessage.quote = this.mapAttributesTo('Quote', lineItem);
1625
- if (savingMode === 'ALL') {
1626
- const optionConfigurations = this.getOptionConfigurations(this.rpcMessage.product);
1627
- const rootProductOptions = this.rpcMessage.options.filter(po => po.configuredProductId === lineItem.productId);
1628
- childItems.forEach(lineItem => {
1629
- const rootOption = rootProductOptions.find(po => po.optionalProductId === lineItem.productId);
1630
- if (rootOption) {
1631
- const featureOptions = optionConfigurations[rootOption.featureName] ?? (optionConfigurations[rootOption.featureName] = []);
1632
- const originOption = !rootOption.hasChildren
1633
- ? optionConfigurations[rootOption.featureName]?.find(({ optionId }) => optionId === rootOption.optionId)
1634
- : undefined;
1635
- const option = originOption ?? {};
1636
- option.optionId = option.optionId ?? rootOption.optionId;
1637
- this.updateContentData(option, lineItem);
1638
- option.index = option.index ?? featureOptions.length;
1639
- option.selected = true;
1640
- if (!originOption) {
1641
- featureOptions.push(option);
1642
- }
1643
- if (lineItem.parentLineItem) {
1644
- const nestedProductOption = this.rpcMessage.options.find(po => po.configuredProductId === lineItem.parentLineItem?.productId &&
1645
- po.optionalProductId === lineItem.productId);
1646
- if (nestedProductOption) {
1647
- option.configurationData = {
1648
- ...option.configurationData,
1649
- VeloceParentInstanceId__c: lineItem.parentLineItem.id,
1650
- VeloceNestedOptionId__c: nestedProductOption.optionId,
1651
- VeloceNestedFeatureId__c: nestedProductOption.featureId,
1652
- };
1653
- }
1654
- }
1655
- }
1656
- else {
1657
- this.rpcMessage.dynamicFeatures.forEach(feature => {
1658
- const featureOptions = optionConfigurations[feature.name] ?? (optionConfigurations[feature.name] = []);
1659
- const originOption = featureOptions.find(({ productId }) => productId === lineItem.productId);
1660
- const option = originOption ?? {};
1661
- this.updateContentData(option, lineItem);
1662
- option.index = option.index ?? featureOptions.length;
1663
- option.selected = true;
1664
- if (!originOption) {
1665
- featureOptions.push(option);
1666
- }
1667
- });
1668
- }
1669
- });
1670
- this.rpcMessage.product = { ...this.rpcMessage.product, optionConfigurations };
1671
- }
1672
- window.RPC_BROADCAST?.apply(null, [this.rpcMessage]);
1673
- }
1674
- updateHasChildrenFlag(bundleProductId) {
1675
- const bundleOptionsByOptionId = {};
1676
- const notBundleOptions = [];
1677
- for (const productOption of this.rpcMessage.options) {
1678
- if (productOption.configuredProductId === bundleProductId) {
1679
- bundleOptionsByOptionId[productOption.optionalProductId] = productOption;
1680
- }
1681
- else {
1682
- notBundleOptions.push(productOption);
1683
- }
1684
- }
1685
- for (const option of notBundleOptions) {
1686
- const bundleOption = bundleOptionsByOptionId[option.configuredProductId];
1687
- if (bundleOption) {
1688
- bundleOption.hasChildren = true;
1689
- }
1690
- }
1691
- }
1692
- flattenChildLineItems(lineItem) {
1693
- let items = lineItem.lineItems ?? [];
1694
- for (let i = 0; i < items.length; i++) {
1695
- const item = items[i];
1696
- if (item?.lineItems) {
1697
- items = items.concat(item.lineItems.map(li => ({ ...li, parentLineItem: item })));
1698
- }
1699
- }
1700
- return items;
1701
- }
1702
- updateContentData(entity, lineItem) {
1703
- if (lineItem.productId) {
1704
- entity.productId = lineItem.productId;
1705
- }
1706
- const quantityAttribute = lineItem.properties['quantityAttribute'];
1707
- entity.Quantity = quantityAttribute
1708
- ? lineItem.attributes.find(attribute => attribute.name === quantityAttribute)?.value ?? 1
1709
- : lineItem.qty;
1710
- const totalPrice = this.computeNetPrice(lineItem);
1711
- const targetTotalPriceField = lineItem.properties['TargetTotalPriceField'] || 'TotalPrice__c';
1712
- entity.configurationData[targetTotalPriceField] = entity.configurationData[targetTotalPriceField]
1713
- ? entity.configurationData[targetTotalPriceField] + totalPrice
1714
- : totalPrice;
1715
- const targetPriceField = lineItem.properties['TargetPriceField'] || 'SBQQ__ListPrice__c';
1716
- const price = entity.Quantity != null ? entity.configurationData[targetTotalPriceField] / entity.Quantity || 0 : 0;
1717
- const targetPriceValue = Number(entity.configurationData[targetPriceField]) || 0;
1718
- entity.configurationData[targetPriceField] = targetPriceValue
1719
- ? (targetPriceValue + price).toFixed(2)
1720
- : price.toFixed(2);
1721
- entity.configurationAttributes = this.mapAttributesTo('Attribute', lineItem);
1722
- entity.configurationData = {
1723
- ...entity.configurationData,
1724
- ...this.mapAttributesTo('Field', lineItem),
1725
- ...this.mapAttributesTo('', lineItem),
1726
- VeloceInstanceId__c: lineItem.id,
1727
- };
1728
- }
1729
- computeNetPrice(lineItem) {
1730
- if (lineItem.properties['GroupCharges']) {
1731
- return this.sumNetPrice(lineItem.chargeGroupItems, this.getChargeNameSet(lineItem.properties['GroupCharges']));
1732
- }
1733
- return this.sumNetPrice(lineItem.chargeItems, this.getChargeNameSet(lineItem.properties['Charges']));
1734
- }
1735
- getChargeNameSet(property) {
1736
- if (property && property.length > 0) {
1737
- return new Set(property.split(','));
1738
- }
1739
- return new Set();
1740
- }
1741
- sumNetPrice(chargeItems, charges) {
1742
- let netPrice = 0;
1743
- for (const chargeItem of chargeItems) {
1744
- if (!charges || charges.has(chargeItem.chargeType)) {
1745
- netPrice += chargeItem.netPrice ?? 0;
1746
- }
1747
- }
1748
- return netPrice;
1749
- }
1750
- mapAttributesTo(target, lineItem) {
1751
- const result = {};
1752
- const component = this.runtimeService.runtimeModel?.components.get(lineItem.type);
1753
- if (!component) {
1754
- return result;
1755
- }
1756
- const propertyName = 'mapTo' + target;
1757
- component.attributes
1758
- .filter(a => a.properties && a.properties[propertyName])
1759
- .forEach(mapping => {
1760
- const attribute = lineItem.attributes.find(a => a.name === mapping.name);
1761
- if (attribute) {
1762
- new Set(mapping.properties[propertyName]?.split(',')).forEach(k => (result[k] = attribute.value));
1763
- }
1764
- });
1765
- return result;
1766
- }
1767
- getOptionConfigurations(product) {
1768
- const optionConfigurations = {};
1769
- const requestOptionConfigurations = product.optionConfigurations ?? {};
1770
- Object.keys(requestOptionConfigurations).forEach(k => {
1771
- optionConfigurations[k] = (requestOptionConfigurations[k] ?? []).map(opt => {
1772
- return { ...opt, selected: false };
1773
- });
1774
- });
1775
- return optionConfigurations;
1776
- }
1777
- }
1778
- RemoteComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: RemoteComponent, deps: [{ token: i2.ContextService }, { token: i2.QuoteDraftService }, { token: i2.ConfigurationRuntimeService }, { token: i2.ConfigurationService }, { token: i2.ConfigurationStateService }, { token: i2$2.MessageService }, { token: i2.IntegrationState }, { token: i4.Location }], target: i0.ɵɵFactoryTarget.Component });
1779
- RemoteComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "15.2.9", type: RemoteComponent, selector: "vl-flow-remote", ngImport: i0, template: "<ng-container *ngIf=\"state$ | async as state\">\n <vl-loader *ngIf=\"state.loading; else content\" [label]=\"'Loading UI'\"></vl-loader>\n\n <ng-template #content>\n <ng-container *ngIf=\"!state.failure\">\n <vl-cms-preview [uiDefinition]=\"uiDefinition\"></vl-cms-preview>\n </ng-container>\n </ng-template>\n</ng-container>\n", styles: [""], dependencies: [{ kind: "directive", type: i4.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "component", type: i5.PreviewComponent, selector: "vl-cms-preview", inputs: ["uiDefinition", "config"] }, { kind: "component", type: i2$1.LoaderComponent, selector: "vl-loader", inputs: ["label", "overlayVisible"] }, { kind: "pipe", type: i4.AsyncPipe, name: "async" }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
1780
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: RemoteComponent, decorators: [{
1781
- type: Component,
1782
- args: [{ selector: 'vl-flow-remote', changeDetection: ChangeDetectionStrategy.OnPush, template: "<ng-container *ngIf=\"state$ | async as state\">\n <vl-loader *ngIf=\"state.loading; else content\" [label]=\"'Loading UI'\"></vl-loader>\n\n <ng-template #content>\n <ng-container *ngIf=\"!state.failure\">\n <vl-cms-preview [uiDefinition]=\"uiDefinition\"></vl-cms-preview>\n </ng-container>\n </ng-template>\n</ng-container>\n" }]
1783
- }], ctorParameters: function () { return [{ type: i2.ContextService }, { type: i2.QuoteDraftService }, { type: i2.ConfigurationRuntimeService }, { type: i2.ConfigurationService }, { type: i2.ConfigurationStateService }, { type: i2$2.MessageService }, { type: i2.IntegrationState }, { type: i4.Location }]; } });
1784
-
1785
- class RemoteModule {
1786
- }
1787
- RemoteModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: RemoteModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
1788
- RemoteModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "15.2.9", ngImport: i0, type: RemoteModule, declarations: [RemoteComponent], imports: [CommonModule, PreviewModule, LoaderModule], exports: [RemoteComponent] });
1789
- RemoteModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: RemoteModule, imports: [CommonModule, PreviewModule, LoaderModule] });
1790
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: RemoteModule, decorators: [{
1791
- type: NgModule,
1792
- args: [{
1793
- declarations: [RemoteComponent],
1794
- imports: [CommonModule, PreviewModule, LoaderModule],
1795
- exports: [RemoteComponent],
1796
- }]
1797
- }] });
1798
-
1799
1278
  class ShoppingCartComponent {
1800
1279
  constructor(templatesApi, cdr, toastService, flowInfo, customizationService) {
1801
1280
  this.templatesApi = templatesApi;
@@ -1906,30 +1385,22 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImpor
1906
1385
  }] });
1907
1386
 
1908
1387
  class FlowResolver {
1909
- constructor(router, routerService, contextService, flowInfo) {
1388
+ constructor(router, routerService, flowInfoService) {
1910
1389
  this.router = router;
1911
1390
  this.routerService = routerService;
1912
- this.contextService = contextService;
1913
- this.flowInfo = flowInfo;
1391
+ this.flowInfoService = flowInfoService;
1914
1392
  }
1915
1393
  resolve(route) {
1916
- const { queryParams } = route;
1917
- const flow = this.flowInfo.flow;
1918
- if (!flow) {
1394
+ if (!this.flowInfoService.isFlowInitialized) {
1919
1395
  return of(false);
1920
1396
  }
1921
- const { properties } = flow;
1397
+ const { queryParams } = route;
1398
+ const { properties } = this.flowInfoService.flow;
1922
1399
  const { queryParams: flowQueryParams, entryPath } = properties;
1923
1400
  const mergedQueryParams = {
1924
1401
  ...queryParams,
1925
1402
  ...flowQueryParams,
1926
1403
  };
1927
- const contextProperties = Object.entries({
1928
- ...mergedQueryParams,
1929
- ...getDefaultProperties({ flowParams: properties }),
1930
- }).reduce((trunk, [key, value]) => ({ ...trunk, [key]: String(value) }), {});
1931
- this.contextService.update({ properties: contextProperties });
1932
- this.flowInfo.flow = flow;
1933
1404
  const parentUrl = this.routerService.getFlowRootPath(route);
1934
1405
  const entryUrl = String(entryPath ?? '')
1935
1406
  .split('/')
@@ -1938,29 +1409,29 @@ class FlowResolver {
1938
1409
  queryParams: mergedQueryParams,
1939
1410
  replaceUrl: true,
1940
1411
  })).pipe(catchError$1(e => {
1412
+ console.error(e);
1941
1413
  const message = e instanceof HttpErrorResponse ? e.error.message : e;
1942
1414
  const errorDetails = isVeloceError(e.error) ? extractErrorDetails(e.error) : [];
1943
1415
  return this.routerService.showErrorPage$(message, errorDetails);
1944
1416
  }));
1945
1417
  }
1946
1418
  }
1947
- FlowResolver.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: FlowResolver, deps: [{ token: i1$2.Router }, { token: FlowRouterService }, { token: i2.ContextService }, { token: i2.FlowInfoService }], target: i0.ɵɵFactoryTarget.Injectable });
1419
+ FlowResolver.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: FlowResolver, deps: [{ token: i1$2.Router }, { token: FlowRouterService }, { token: i2.FlowInfoService }], target: i0.ɵɵFactoryTarget.Injectable });
1948
1420
  FlowResolver.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: FlowResolver });
1949
1421
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: FlowResolver, decorators: [{
1950
1422
  type: Injectable
1951
- }], ctorParameters: function () { return [{ type: i1$2.Router }, { type: FlowRouterService }, { type: i2.ContextService }, { type: i2.FlowInfoService }]; } });
1423
+ }], ctorParameters: function () { return [{ type: i1$2.Router }, { type: FlowRouterService }, { type: i2.FlowInfoService }]; } });
1952
1424
 
1953
1425
  class QuoteResolver {
1954
- constructor(router, quoteDraftService, routerService, contextService, flowInfo, flowStateService) {
1426
+ constructor(router, quoteDraftService, routerService, flowInfoService, flowStateService) {
1955
1427
  this.router = router;
1956
1428
  this.quoteDraftService = quoteDraftService;
1957
1429
  this.routerService = routerService;
1958
- this.contextService = contextService;
1959
- this.flowInfo = flowInfo;
1430
+ this.flowInfoService = flowInfoService;
1960
1431
  this.flowStateService = flowStateService;
1961
1432
  }
1962
1433
  resolve(route) {
1963
- const flow = this.flowInfo.flow;
1434
+ const flow = this.flowInfoService.flow;
1964
1435
  if (!flow) {
1965
1436
  return of(false);
1966
1437
  }
@@ -1968,13 +1439,14 @@ class QuoteResolver {
1968
1439
  return of(true);
1969
1440
  }
1970
1441
  return this.flowStateService.init$().pipe(switchMap(() => this.checkDynamicNavigation$(route)), catchError(e => {
1442
+ console.error(e);
1971
1443
  const message = e instanceof HttpErrorResponse ? e.error.message : e;
1972
1444
  const errorDetails = isVeloceError(e.error) ? extractErrorDetails(e.error) : [];
1973
1445
  return this.routerService.showErrorPage$(message, errorDetails);
1974
1446
  }));
1975
1447
  }
1976
1448
  checkDynamicNavigation$(route) {
1977
- const flow = this.flowInfo.flow;
1449
+ const flow = this.flowInfoService.flow;
1978
1450
  if (!flow) {
1979
1451
  return of(true);
1980
1452
  }
@@ -1993,7 +1465,7 @@ class QuoteResolver {
1993
1465
  }));
1994
1466
  }
1995
1467
  getNavigateTo() {
1996
- const flow = this.flowInfo.flow;
1468
+ const flow = this.flowInfoService.flow;
1997
1469
  let navigateTo;
1998
1470
  if (flow?.properties.stateful) {
1999
1471
  return this.flowStateService.select$(UITemplateType.FLOW_ENGINE, 'NAVIGATE_TO').pipe(map(r => {
@@ -2004,7 +1476,7 @@ class QuoteResolver {
2004
1476
  }));
2005
1477
  }
2006
1478
  else {
2007
- const isAccountMode = this.contextService.mode === ConfigurationContextMode.ACCOUNT;
1479
+ const isAccountMode = this.flowInfoService.context.mode === ConfigurationContextMode.ACCOUNT;
2008
1480
  if (isAccountMode || this.quoteDraftService.hasAssets) {
2009
1481
  navigateTo = '/assets';
2010
1482
  }
@@ -2015,11 +1487,11 @@ class QuoteResolver {
2015
1487
  return of(navigateTo);
2016
1488
  }
2017
1489
  }
2018
- QuoteResolver.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: QuoteResolver, deps: [{ token: i1$2.Router }, { token: i2.QuoteDraftService }, { token: FlowRouterService }, { token: i2.ContextService }, { token: i2.FlowInfoService }, { token: i2.FlowStateService }], target: i0.ɵɵFactoryTarget.Injectable });
1490
+ QuoteResolver.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: QuoteResolver, deps: [{ token: i1$2.Router }, { token: i2.QuoteDraftService }, { token: FlowRouterService }, { token: i2.FlowInfoService }, { token: i2.FlowStateService }], target: i0.ɵɵFactoryTarget.Injectable });
2019
1491
  QuoteResolver.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: QuoteResolver });
2020
1492
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: QuoteResolver, decorators: [{
2021
1493
  type: Injectable
2022
- }], ctorParameters: function () { return [{ type: i1$2.Router }, { type: i2.QuoteDraftService }, { type: FlowRouterService }, { type: i2.ContextService }, { type: i2.FlowInfoService }, { type: i2.FlowStateService }]; } });
1494
+ }], ctorParameters: function () { return [{ type: i1$2.Router }, { type: i2.QuoteDraftService }, { type: FlowRouterService }, { type: i2.FlowInfoService }, { type: i2.FlowStateService }]; } });
2023
1495
 
2024
1496
  const rootRoute = {
2025
1497
  id: VELOCE_FLOW_ROOT_ROUTE,
@@ -2037,7 +1509,6 @@ const rootRoute = {
2037
1509
  path: 'flows',
2038
1510
  runGuardsAndResolvers: 'paramsOrQueryParamsChange',
2039
1511
  resolve: { flow: FlowResolver },
2040
- canActivate: [ContextGuard],
2041
1512
  children: [],
2042
1513
  },
2043
1514
  {
@@ -2045,7 +1516,6 @@ const rootRoute = {
2045
1516
  component: ProductComponent,
2046
1517
  runGuardsAndResolvers: 'paramsOrQueryParamsChange',
2047
1518
  resolve: { quote: QuoteResolver },
2048
- canActivate: [ContextGuard],
2049
1519
  canDeactivate: [ProductUnloadGuard],
2050
1520
  data: { showHeader: true },
2051
1521
  },
@@ -2054,7 +1524,6 @@ const rootRoute = {
2054
1524
  component: ShoppingCartComponent,
2055
1525
  runGuardsAndResolvers: 'paramsOrQueryParamsChange',
2056
1526
  resolve: { quote: QuoteResolver },
2057
- canActivate: [ContextGuard],
2058
1527
  data: { showHeader: true },
2059
1528
  },
2060
1529
  {
@@ -2062,7 +1531,6 @@ const rootRoute = {
2062
1531
  component: CatalogComponent,
2063
1532
  runGuardsAndResolvers: 'paramsOrQueryParamsChange',
2064
1533
  resolve: { quote: QuoteResolver },
2065
- canActivate: [ContextGuard],
2066
1534
  data: { showHeader: true },
2067
1535
  },
2068
1536
  {
@@ -2070,16 +1538,8 @@ const rootRoute = {
2070
1538
  component: AssetsComponent,
2071
1539
  runGuardsAndResolvers: 'paramsOrQueryParamsChange',
2072
1540
  resolve: { quote: QuoteResolver },
2073
- canActivate: [ContextGuard],
2074
1541
  data: { showHeader: true },
2075
1542
  },
2076
- {
2077
- path: 'remote',
2078
- component: RemoteComponent,
2079
- runGuardsAndResolvers: 'paramsOrQueryParamsChange',
2080
- resolve: { quote: QuoteResolver },
2081
- canActivate: [ContextGuard],
2082
- },
2083
1543
  {
2084
1544
  path: 'debug',
2085
1545
  loadChildren: () => DebugModule,
@@ -2095,30 +1555,14 @@ const rootRoute = {
2095
1555
  class FlowRoutingModule {
2096
1556
  }
2097
1557
  FlowRoutingModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: FlowRoutingModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
2098
- FlowRoutingModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "15.2.9", ngImport: i0, type: FlowRoutingModule, imports: [i1$2.RouterModule, ProductModule,
2099
- ShoppingCartModule,
2100
- CatalogModule,
2101
- AssetsModule,
2102
- RemoteModule], exports: [RouterModule] });
2103
- FlowRoutingModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: FlowRoutingModule, providers: [FlowRouterService, RootGuard, ContextGuard, ProductUnloadGuard, FlowResolver, QuoteResolver], imports: [RouterModule.forChild([rootRoute]),
2104
- ProductModule,
2105
- ShoppingCartModule,
2106
- CatalogModule,
2107
- AssetsModule,
2108
- RemoteModule, RouterModule] });
1558
+ FlowRoutingModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "15.2.9", ngImport: i0, type: FlowRoutingModule, imports: [i1$2.RouterModule, ProductModule, ShoppingCartModule, CatalogModule, AssetsModule], exports: [RouterModule] });
1559
+ FlowRoutingModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: FlowRoutingModule, providers: [FlowRouterService, RootGuard, ProductUnloadGuard, FlowResolver, QuoteResolver], imports: [RouterModule.forChild([rootRoute]), ProductModule, ShoppingCartModule, CatalogModule, AssetsModule, RouterModule] });
2109
1560
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: FlowRoutingModule, decorators: [{
2110
1561
  type: NgModule,
2111
1562
  args: [{
2112
- imports: [
2113
- RouterModule.forChild([rootRoute]),
2114
- ProductModule,
2115
- ShoppingCartModule,
2116
- CatalogModule,
2117
- AssetsModule,
2118
- RemoteModule,
2119
- ],
1563
+ imports: [RouterModule.forChild([rootRoute]), ProductModule, ShoppingCartModule, CatalogModule, AssetsModule],
2120
1564
  exports: [RouterModule],
2121
- providers: [FlowRouterService, RootGuard, ContextGuard, ProductUnloadGuard, FlowResolver, QuoteResolver],
1565
+ providers: [FlowRouterService, RootGuard, ProductUnloadGuard, FlowResolver, QuoteResolver],
2122
1566
  }]
2123
1567
  }] });
2124
1568
 
@@ -2166,9 +1610,22 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImpor
2166
1610
  }]
2167
1611
  }] });
2168
1612
 
1613
+ const getFlowObjectIdPropertyName = (id) => {
1614
+ const objectName = SalesforceIdUtils.getSfObjectNameById(id);
1615
+ switch (objectName) {
1616
+ case 'Account':
1617
+ return 'accountId';
1618
+ case 'Order':
1619
+ return 'orderId';
1620
+ case 'Quote':
1621
+ default:
1622
+ return 'quoteId';
1623
+ }
1624
+ };
1625
+
2169
1626
  /**
2170
1627
  * Generated bundle index. Do not edit.
2171
1628
  */
2172
1629
 
2173
- export { ContextGuard, FlowDialogService, FlowModule, FlowRouterService, FlowService, VELOCE_FLOW_ROOT_ROUTE, getDefaultProperties, getFlowObjectIdPropertyName };
1630
+ export { FlowDialogService, FlowModule, FlowRouterService, FlowService, VELOCE_FLOW_ROOT_ROUTE, getFlowObjectIdPropertyName };
2174
1631
  //# sourceMappingURL=veloceapps-sdk.mjs.map