@veloceapps/sdk 2.0.4 → 2.0.6

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 (142) hide show
  1. package/bundles/veloce-sdk-cms.umd.js +519 -352
  2. package/bundles/veloce-sdk-cms.umd.js.map +1 -1
  3. package/bundles/veloce-sdk-runtime.umd.js +145 -144
  4. package/bundles/veloce-sdk-runtime.umd.js.map +1 -1
  5. package/bundles/veloce-sdk.umd.js +1104 -8
  6. package/bundles/veloce-sdk.umd.js.map +1 -1
  7. package/cms/components/preview/preview.component.d.ts +4 -1
  8. package/cms/modules/configuration/index.d.ts +2 -0
  9. package/cms/modules/configuration/services/configuration-runtime.service.d.ts +30 -0
  10. package/cms/modules/configuration/services/configuration.service.d.ts +6 -9
  11. package/cms/modules/configuration/services/runtime-context.service.d.ts +14 -0
  12. package/cms/modules/configuration/types/configuration-runtime.types.d.ts +6 -0
  13. package/cms/modules/configuration/types/configuration.types.d.ts +2 -0
  14. package/esm2015/cms/components/element-children/element-children.component.js +3 -3
  15. package/esm2015/cms/components/element-children/element-children.module.js +4 -4
  16. package/esm2015/cms/components/element-renderer/element-renderer.component.js +3 -3
  17. package/esm2015/cms/components/element-renderer/element-renderer.module.js +4 -4
  18. package/esm2015/cms/components/federated/federated.component.js +3 -3
  19. package/esm2015/cms/components/federated/federated.module.js +4 -4
  20. package/esm2015/cms/components/plugin.component.js +3 -3
  21. package/esm2015/cms/components/preview/preview.component.js +33 -24
  22. package/esm2015/cms/components/preview/preview.module.js +4 -4
  23. package/esm2015/cms/directives/custom-template.directive.js +3 -3
  24. package/esm2015/cms/launcher.module.js +4 -4
  25. package/esm2015/cms/modules/configuration/configuration.module.js +25 -6
  26. package/esm2015/cms/modules/configuration/index.js +3 -1
  27. package/esm2015/cms/modules/configuration/services/configuration-runtime.service.js +83 -0
  28. package/esm2015/cms/modules/configuration/services/configuration.service.js +35 -41
  29. package/esm2015/cms/modules/configuration/services/runtime-context.service.js +60 -0
  30. package/esm2015/cms/modules/configuration/types/configuration-runtime.types.js +2 -0
  31. package/esm2015/cms/modules/configuration/types/configuration.types.js +1 -1
  32. package/esm2015/cms/plugins/configuration.plugin.js +3 -3
  33. package/esm2015/cms/plugins/io.plugin.js +3 -3
  34. package/esm2015/cms/plugins/script.plugin.js +3 -3
  35. package/esm2015/cms/services/dynamic-module.service.js +3 -3
  36. package/esm2015/cms/services/element-context.service.js +3 -3
  37. package/esm2015/cms/services/io-provider.service.js +3 -3
  38. package/esm2015/cms/services/launcher.service.js +3 -3
  39. package/esm2015/cms/services/templates.service.js +3 -3
  40. package/esm2015/index.js +2 -2
  41. package/esm2015/runtime/components/component-preview/component-preview.component.js +3 -3
  42. package/esm2015/runtime/components/section-renderer/section-renderer.component.js +3 -3
  43. package/esm2015/runtime/components/ui-runtime/runtime.component.js +3 -3
  44. package/esm2015/runtime/components/ui-runtime-preview/runtime-preview.component.js +3 -3
  45. package/esm2015/runtime/execution/components/children-placeholder/children-placeholder.component.js +6 -6
  46. package/esm2015/runtime/execution/components/context-provider/context-provider.component.js +3 -3
  47. package/esm2015/runtime/execution/components/execution-section-renderer/execution-section-renderer.component.js +3 -3
  48. package/esm2015/runtime/execution/components/federated/federated.component.js +3 -3
  49. package/esm2015/runtime/execution/components/velo-attribute/velo-attribute.component.js +3 -3
  50. package/esm2015/runtime/execution/components/velo-multiselect/velo-multiselect.component.js +3 -3
  51. package/esm2015/runtime/execution/components/velo-port-checkbox/velo-port-checkbox.component.js +3 -3
  52. package/esm2015/runtime/execution/components/velo-port-dropdown/velo-port-dropdown.component.js +3 -3
  53. package/esm2015/runtime/execution/components/velo-port-radio/velo-port-radio.component.js +3 -3
  54. package/esm2015/runtime/execution/components/velo-type/velo-type.component.js +3 -3
  55. package/esm2015/runtime/execution/directives/section-script.directive.js +3 -3
  56. package/esm2015/runtime/execution/directives/sf-query.directive.js +3 -3
  57. package/esm2015/runtime/execution/directives/velo-attribute.directive.js +3 -3
  58. package/esm2015/runtime/execution/directives/velo-port.directive.js +18 -18
  59. package/esm2015/runtime/execution/directives/vl-approval.directive.js +3 -3
  60. package/esm2015/runtime/execution/directives/vl-document-attachments.directive.js +3 -3
  61. package/esm2015/runtime/execution/directives/vl-document-templates.directive.js +3 -3
  62. package/esm2015/runtime/execution/directives/vl-quote.directive.js +3 -3
  63. package/esm2015/runtime/execution/directives/vl-ramp.directive.js +3 -3
  64. package/esm2015/runtime/execution/runtime-execution.module.js +4 -4
  65. package/esm2015/runtime/runtime.module.js +4 -4
  66. package/esm2015/runtime/services/cart.service.js +3 -3
  67. package/esm2015/runtime/services/collapsible-state.service.js +3 -3
  68. package/esm2015/runtime/services/configuration.service.js +3 -3
  69. package/esm2015/runtime/services/context.service.js +6 -5
  70. package/esm2015/runtime/services/current-state.service.js +3 -3
  71. package/esm2015/runtime/services/form-scope.service.js +3 -3
  72. package/esm2015/runtime/services/product-model-cache.service.js +3 -3
  73. package/esm2015/runtime/services/quote.service.js +3 -3
  74. package/esm2015/runtime/services/runtime-context.service.js +3 -3
  75. package/esm2015/runtime/services/runtime-form.service.js +3 -3
  76. package/esm2015/runtime/services/runtime.service.js +3 -3
  77. package/esm2015/runtime/services/section-helper.service.js +3 -3
  78. package/esm2015/runtime/services/section-scope.service.js +3 -3
  79. package/esm2015/runtime/services/section-store.service.js +3 -3
  80. package/esm2015/runtime/services/section.service.js +6 -6
  81. package/esm2015/src/constants.js +2 -0
  82. package/esm2015/src/flow-routing.module.js +75 -0
  83. package/esm2015/src/flow.component.js +23 -0
  84. package/esm2015/src/flow.module.js +24 -0
  85. package/esm2015/src/guards/context.guard.js +63 -0
  86. package/esm2015/src/guards/index.js +2 -0
  87. package/esm2015/src/guards/root.guard.js +41 -0
  88. package/esm2015/src/index.js +6 -0
  89. package/esm2015/src/pages/debug/debug.component.js +54 -0
  90. package/esm2015/src/pages/debug/debug.module.js +44 -0
  91. package/esm2015/src/pages/legacy-product/legacy-product.component.js +117 -0
  92. package/esm2015/src/pages/legacy-product/legacy-product.module.js +20 -0
  93. package/esm2015/src/pages/product/product.component.js +95 -0
  94. package/esm2015/src/pages/product/product.module.js +20 -0
  95. package/esm2015/src/pages/record-not-found/record-not-found.component.js +26 -0
  96. package/esm2015/src/pages/record-not-found/record-not-found.module.js +20 -0
  97. package/esm2015/src/resolvers/context.resolver.js +42 -0
  98. package/esm2015/src/resolvers/flow.resolver.js +58 -0
  99. package/esm2015/src/resolvers/quote.resolver.js +36 -0
  100. package/esm2015/src/services/flow.service.js +24 -0
  101. package/esm2015/src/services/index.js +2 -0
  102. package/esm2015/src/services/router.service.js +47 -0
  103. package/esm2015/src/types/context-route.types.js +2 -0
  104. package/esm2015/src/types/flow-customization.types.js +3 -0
  105. package/esm2015/src/types/flow.types.js +2 -0
  106. package/esm2015/src/types/index.js +4 -0
  107. package/esm2015/src/types/route.types.js +2 -0
  108. package/fesm2015/veloce-sdk-cms.js +461 -316
  109. package/fesm2015/veloce-sdk-cms.js.map +1 -1
  110. package/fesm2015/veloce-sdk-runtime.js +145 -144
  111. package/fesm2015/veloce-sdk-runtime.js.map +1 -1
  112. package/fesm2015/veloce-sdk.js +725 -1
  113. package/fesm2015/veloce-sdk.js.map +1 -1
  114. package/index.d.ts +1 -2
  115. package/package.json +1 -1
  116. package/src/constants.d.ts +1 -0
  117. package/src/flow-routing.module.d.ts +9 -0
  118. package/src/flow.component.d.ts +8 -0
  119. package/src/flow.module.d.ts +12 -0
  120. package/src/guards/context.guard.d.ts +16 -0
  121. package/src/guards/index.d.ts +1 -0
  122. package/src/guards/root.guard.d.ts +15 -0
  123. package/src/index.d.ts +5 -0
  124. package/src/pages/debug/debug.component.d.ts +24 -0
  125. package/src/pages/debug/debug.module.d.ts +13 -0
  126. package/src/pages/legacy-product/legacy-product.component.d.ts +33 -0
  127. package/src/pages/legacy-product/legacy-product.module.d.ts +10 -0
  128. package/src/pages/product/product.component.d.ts +32 -0
  129. package/src/pages/product/product.module.d.ts +10 -0
  130. package/src/pages/record-not-found/record-not-found.component.d.ts +11 -0
  131. package/src/pages/record-not-found/record-not-found.module.d.ts +9 -0
  132. package/src/resolvers/context.resolver.d.ts +16 -0
  133. package/src/resolvers/flow.resolver.d.ts +14 -0
  134. package/src/resolvers/quote.resolver.d.ts +15 -0
  135. package/src/services/flow.service.d.ts +13 -0
  136. package/src/services/index.d.ts +1 -0
  137. package/src/services/router.service.d.ts +12 -0
  138. package/src/types/context-route.types.d.ts +5 -0
  139. package/src/types/flow-customization.types.d.ts +7 -0
  140. package/src/types/flow.types.d.ts +5 -0
  141. package/src/types/index.d.ts +3 -0
  142. package/src/types/route.types.d.ts +4 -0
@@ -1,6 +1,730 @@
1
- var index = {};
1
+ import * as i3 from '@angular/common';
2
+ import { CommonModule } from '@angular/common';
3
+ import * as i0 from '@angular/core';
4
+ import { Injectable, Component, ChangeDetectionStrategy, NgModule, InjectionToken, Optional, Inject } from '@angular/core';
5
+ import * as i1$1 from '@veloce/api';
6
+ import { ApiModule } from '@veloce/api';
7
+ import * as i2 from '@veloce/components';
8
+ import { LoaderModule } from '@veloce/components';
9
+ import * as i1$2 from '@veloce/sdk/cms';
10
+ import { PreviewModule, LauncherModule } from '@veloce/sdk/cms';
11
+ import * as i2$1 from '@veloce/sdk/runtime';
12
+ import { RuntimeOperation, RuntimeModule, ContextService } from '@veloce/sdk/runtime';
13
+ import * as i1 from '@angular/router';
14
+ import { NavigationStart, NavigationCancel, NavigationEnd, NavigationError, RouterModule } from '@angular/router';
15
+ import { filter, map, startWith, distinctUntilChanged, shareReplay, Subject, BehaviorSubject, first as first$1, takeUntil as takeUntil$1, of, tap, switchMap, catchError, from } from 'rxjs';
16
+ import { ConfigurationContextMode, EntityUtil } from '@veloce/core';
17
+ import * as i5 from '@angular/forms';
18
+ import { FormGroup, FormControl, FormsModule, ReactiveFormsModule } from '@angular/forms';
19
+ import * as i3$1 from 'primeng/button';
20
+ import { ButtonModule } from 'primeng/button';
21
+ import * as i6 from 'primeng/inputtext';
22
+ import { InputTextModule } from 'primeng/inputtext';
23
+ import * as i4 from 'primeng/radiobutton';
24
+ import { RadioButtonModule } from 'primeng/radiobutton';
25
+ import { map as map$1, first, takeUntil, take, tap as tap$1, catchError as catchError$1 } from 'rxjs/operators';
26
+ import { TooltipModule } from 'ngx-bootstrap/tooltip';
27
+ import * as i4$1 from 'primeng/api';
28
+ import { HttpErrorResponse } from '@angular/common/http';
29
+
30
+ const VELOCE_FLOW_ROOT_ROUTE = 'VELOCE_FLOW_ROOT_ROUTE';
31
+
32
+ class RouterService {
33
+ constructor(router) {
34
+ this.router = router;
35
+ this.loading$ = this.router.events.pipe(filter(e => e instanceof NavigationStart ||
36
+ e instanceof NavigationCancel ||
37
+ e instanceof NavigationEnd ||
38
+ e instanceof NavigationError), map(e => e instanceof NavigationStart), startWith(false), distinctUntilChanged());
39
+ }
40
+ getFlowRootRoute(route) {
41
+ var _a;
42
+ const path = [...route.pathFromRoot];
43
+ while (path.length) {
44
+ const parent = path.pop();
45
+ if (!parent) {
46
+ break;
47
+ }
48
+ if (((_a = parent.routeConfig) === null || _a === void 0 ? void 0 : _a.id) === VELOCE_FLOW_ROOT_ROUTE) {
49
+ return parent;
50
+ }
51
+ }
52
+ return;
53
+ }
54
+ getFlowRootPath(route) {
55
+ const rootRoute = this.getFlowRootRoute(route);
56
+ if (!rootRoute) {
57
+ return '';
58
+ }
59
+ const path = rootRoute.pathFromRoot
60
+ .map(r => { var _a; return (_a = r.routeConfig) === null || _a === void 0 ? void 0 : _a.path; })
61
+ .filter(Boolean)
62
+ .join('/');
63
+ return '/' + path;
64
+ }
65
+ }
66
+ RouterService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: RouterService, deps: [{ token: i1.Router }], target: i0.ɵɵFactoryTarget.Injectable });
67
+ RouterService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: RouterService, providedIn: 'root' });
68
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: RouterService, decorators: [{
69
+ type: Injectable,
70
+ args: [{ providedIn: 'root' }]
71
+ }], ctorParameters: function () { return [{ type: i1.Router }]; } });
72
+
73
+ class FlowComponent {
74
+ constructor(routerService) {
75
+ this.routerService = routerService;
76
+ }
77
+ }
78
+ FlowComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: FlowComponent, deps: [{ token: RouterService }], target: i0.ɵɵFactoryTarget.Component });
79
+ FlowComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "12.2.16", type: FlowComponent, selector: "vl-flow", ngImport: i0, template: "<div class=\"loading-overlay\" *ngIf=\"routerService.loading$ | async\">\n <vl-loader label=\"LOADING\"></vl-loader>\n</div>\n\n<router-outlet></router-outlet>\n", styles: [".loading-overlay{position:absolute;height:100%;width:100%;left:0;right:0;top:0;bottom:0;background-color:#ffffff80;z-index:4}\n"], components: [{ type: i2.LoaderComponent, selector: "vl-loader", inputs: ["label"] }], directives: [{ type: i3.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { type: i1.RouterOutlet, selector: "router-outlet", outputs: ["activate", "deactivate"], exportAs: ["outlet"] }], pipes: { "async": i3.AsyncPipe }, changeDetection: i0.ChangeDetectionStrategy.OnPush });
80
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: FlowComponent, decorators: [{
81
+ type: Component,
82
+ args: [{
83
+ selector: 'vl-flow',
84
+ templateUrl: './flow.component.html',
85
+ styleUrls: ['./flow.component.scss'],
86
+ changeDetection: ChangeDetectionStrategy.OnPush,
87
+ }]
88
+ }], ctorParameters: function () { return [{ type: RouterService }]; } });
89
+
90
+ class ContextGuard {
91
+ constructor(router, routerService) {
92
+ this.router = router;
93
+ this.routerService = routerService;
94
+ }
95
+ getConfigurationContextMode(accountId, quoteId, orderId, rpcMessage) {
96
+ if (accountId) {
97
+ return ConfigurationContextMode.ACCOUNT;
98
+ }
99
+ if (quoteId) {
100
+ return ConfigurationContextMode.QUOTE;
101
+ }
102
+ if (orderId) {
103
+ return ConfigurationContextMode.ORDER;
104
+ }
105
+ if (rpcMessage) {
106
+ return ConfigurationContextMode.REMOTE;
107
+ }
108
+ return;
109
+ }
110
+ checkActivation(route) {
111
+ var _a, _b;
112
+ const { queryParams } = route;
113
+ const { accountId, quoteId, orderId } = queryParams;
114
+ const rpcMessage = window['RPC_MESSAGE'];
115
+ const rpcMessageId = rpcMessage && ((_b = (_a = JSON.parse(rpcMessage)) === null || _a === void 0 ? void 0 : _a.quote) === null || _b === void 0 ? void 0 : _b.Id);
116
+ const headerId = accountId || quoteId || orderId || rpcMessageId || 'empty-for-test-mode';
117
+ const mode = this.getConfigurationContextMode(accountId, quoteId, orderId, rpcMessage);
118
+ if (mode === void 0) {
119
+ return this.reject(route, 'Mode is undefined');
120
+ }
121
+ const contextRouteData = {
122
+ headerId,
123
+ mode,
124
+ };
125
+ route.data = Object.assign(Object.assign({}, route.data), contextRouteData);
126
+ return true;
127
+ }
128
+ canActivate(route) {
129
+ return this.checkActivation(route);
130
+ }
131
+ canActivateChild(childRoute) {
132
+ return this.checkActivation(childRoute);
133
+ }
134
+ reject(route, message) {
135
+ const parentUrl = this.routerService.getFlowRootPath(route);
136
+ this.router.navigate([parentUrl, '404'], {
137
+ state: { message },
138
+ });
139
+ return false;
140
+ }
141
+ }
142
+ ContextGuard.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: ContextGuard, deps: [{ token: i1.Router }, { token: RouterService }], target: i0.ɵɵFactoryTarget.Injectable });
143
+ ContextGuard.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: ContextGuard });
144
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: ContextGuard, decorators: [{
145
+ type: Injectable
146
+ }], ctorParameters: function () { return [{ type: i1.Router }, { type: RouterService }]; } });
147
+
148
+ class RootGuard {
149
+ constructor(router, routerService) {
150
+ this.router = router;
151
+ this.routerService = routerService;
152
+ this.initialized = false;
153
+ this.navToRestore = null;
154
+ }
155
+ canActivate(route) {
156
+ // We always need to initialize root component first, and only then start checking guards/resolvers
157
+ var _a;
158
+ if (!this.initialized) {
159
+ this.initialized = true;
160
+ this.navToRestore = this.router.getCurrentNavigation();
161
+ const rootUrl = this.routerService.getFlowRootPath(route);
162
+ this.router.navigate([rootUrl], { replaceUrl: !((_a = this.navToRestore) === null || _a === void 0 ? void 0 : _a.previousNavigation) });
163
+ }
164
+ else if (this.navToRestore) {
165
+ const nav = this.navToRestore;
166
+ setTimeout(() => {
167
+ this.router.navigateByUrl(nav.extractedUrl, nav.extras);
168
+ this.navToRestore = null;
169
+ });
170
+ }
171
+ return true;
172
+ }
173
+ canDeactivate() {
174
+ this.initialized = false;
175
+ return true;
176
+ }
177
+ }
178
+ RootGuard.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: RootGuard, deps: [{ token: i1.Router }, { token: RouterService }], target: i0.ɵɵFactoryTarget.Injectable });
179
+ RootGuard.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: RootGuard, providedIn: 'root' });
180
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: RootGuard, decorators: [{
181
+ type: Injectable,
182
+ args: [{ providedIn: 'root' }]
183
+ }], ctorParameters: function () { return [{ type: i1.Router }, { type: RouterService }]; } });
184
+
185
+ class FlowService {
186
+ constructor(configurationSettingsApiService) {
187
+ this.configurationSettingsApiService = configurationSettingsApiService;
188
+ this.flowsKey = 'flows';
189
+ }
190
+ getFlow(id) {
191
+ return this.fetchFlows().pipe(map$1(flows => flows.find(flow => flow.id == id)));
192
+ }
193
+ fetchFlows() {
194
+ return this.configurationSettingsApiService
195
+ .fetchSetting(this.flowsKey)
196
+ .pipe(map$1(({ value }) => (value ? JSON.parse(value) : [])));
197
+ }
198
+ }
199
+ FlowService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: FlowService, deps: [{ token: i1$1.ConfigurationSettingsApiService }], target: i0.ɵɵFactoryTarget.Injectable });
200
+ FlowService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: FlowService });
201
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: FlowService, decorators: [{
202
+ type: Injectable
203
+ }], ctorParameters: function () { return [{ type: i1$1.ConfigurationSettingsApiService }]; } });
204
+
205
+ class DebugComponent {
206
+ constructor(flowService, router, activatedRoute) {
207
+ this.flowService = flowService;
208
+ this.router = router;
209
+ this.activatedRoute = activatedRoute;
210
+ this.form = new FormGroup({
211
+ id: new FormControl(''),
212
+ });
213
+ this.flows$ = this.flowService.fetchFlows().pipe(map(flows => flows.map(flow => {
214
+ var _a, _b, _c;
215
+ const queryParams = (_b = (_a = flow === null || flow === void 0 ? void 0 : flow.properties) === null || _a === void 0 ? void 0 : _a.queryParams) !== null && _b !== void 0 ? _b : {};
216
+ return {
217
+ id: flow.id,
218
+ entryPath: (_c = flow === null || flow === void 0 ? void 0 : flow.properties) === null || _c === void 0 ? void 0 : _c.entryPath,
219
+ queryParams,
220
+ queryParamsStr: JSON.stringify(queryParams),
221
+ };
222
+ })), shareReplay());
223
+ }
224
+ runFlow() {
225
+ const { id } = this.form.value;
226
+ if (!id || !this.selectedFlow) {
227
+ return;
228
+ }
229
+ const paths = this.selectedFlow.entryPath.split('/').filter(Boolean);
230
+ this.router.navigate(['..', ...paths], {
231
+ queryParams: Object.assign({ flowId: this.selectedFlow.id, quoteId: id }, this.selectedFlow.queryParams),
232
+ relativeTo: this.activatedRoute,
233
+ });
234
+ }
235
+ }
236
+ DebugComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: DebugComponent, deps: [{ token: FlowService }, { token: i1.Router }, { token: i1.ActivatedRoute }], target: i0.ɵɵFactoryTarget.Component });
237
+ DebugComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "12.2.16", type: DebugComponent, selector: "vl-flow-debug", ngImport: i0, template: "<form [formGroup]=\"form\">\n <div class=\"field\">\n <label>SF Object ID</label>\n <input formControlName=\"id\" pInputText type=\"text\" />\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 </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.entryPath }}</td>\n <td>{{ flow.queryParamsStr }}</td>\n </tr>\n </tbody>\n</table>\n", styles: ["form{display:flex;align-items:center;justify-content:space-between}.field{display:flex;flex-direction:column;width:200px;flex-shrink:0}table{width:100%;border-collapse:collapse}tr{cursor:pointer}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}\n"], components: [{ type: i3$1.Button, selector: "p-button", inputs: ["type", "iconPos", "icon", "badge", "label", "disabled", "loading", "loadingIcon", "style", "styleClass", "badgeClass"], outputs: ["onClick", "onFocus", "onBlur"] }, { type: i4.RadioButton, selector: "p-radioButton", inputs: ["value", "formControlName", "name", "disabled", "label", "tabindex", "inputId", "ariaLabelledBy", "ariaLabel", "style", "styleClass", "labelStyleClass"], outputs: ["onClick", "onFocus", "onBlur"] }], directives: [{ type: i5.ɵNgNoValidate, selector: "form:not([ngNoForm]):not([ngNativeValidate])" }, { type: i5.NgControlStatusGroup, selector: "[formGroupName],[formArrayName],[ngModelGroup],[formGroup],form:not([ngNoForm]),[ngForm]" }, { type: i5.FormGroupDirective, selector: "[formGroup]", inputs: ["formGroup"], outputs: ["ngSubmit"], exportAs: ["ngForm"] }, { type: i5.DefaultValueAccessor, selector: "input:not([type=checkbox])[formControlName],textarea[formControlName],input:not([type=checkbox])[formControl],textarea[formControl],input:not([type=checkbox])[ngModel],textarea[ngModel],[ngDefaultControl]" }, { type: i5.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { type: i5.FormControlName, selector: "[formControlName]", inputs: ["disabled", "formControlName", "ngModel"], outputs: ["ngModelChange"] }, { type: i6.InputText, selector: "[pInputText]" }, { type: i3.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { type: i5.NgModel, selector: "[ngModel]:not([formControlName]):not([formControl])", inputs: ["name", "disabled", "ngModel", "ngModelOptions"], outputs: ["ngModelChange"], exportAs: ["ngModel"] }], pipes: { "async": i3.AsyncPipe }, changeDetection: i0.ChangeDetectionStrategy.OnPush });
238
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: DebugComponent, decorators: [{
239
+ type: Component,
240
+ args: [{
241
+ selector: 'vl-flow-debug',
242
+ templateUrl: './debug.component.html',
243
+ styleUrls: ['./debug.component.scss'],
244
+ changeDetection: ChangeDetectionStrategy.OnPush,
245
+ }]
246
+ }], ctorParameters: function () { return [{ type: FlowService }, { type: i1.Router }, { type: i1.ActivatedRoute }]; } });
247
+
248
+ const routes$1 = [{ path: '', component: DebugComponent }];
249
+ class DebugModule {
250
+ }
251
+ DebugModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: DebugModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
252
+ DebugModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: DebugModule, declarations: [DebugComponent], imports: [CommonModule,
253
+ FormsModule,
254
+ ReactiveFormsModule, i1.RouterModule, RadioButtonModule,
255
+ ButtonModule,
256
+ InputTextModule] });
257
+ DebugModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: DebugModule, imports: [[
258
+ CommonModule,
259
+ FormsModule,
260
+ ReactiveFormsModule,
261
+ RouterModule.forChild(routes$1),
262
+ RadioButtonModule,
263
+ ButtonModule,
264
+ InputTextModule,
265
+ ]] });
266
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: DebugModule, decorators: [{
267
+ type: NgModule,
268
+ args: [{
269
+ declarations: [DebugComponent],
270
+ imports: [
271
+ CommonModule,
272
+ FormsModule,
273
+ ReactiveFormsModule,
274
+ RouterModule.forChild(routes$1),
275
+ RadioButtonModule,
276
+ ButtonModule,
277
+ InputTextModule,
278
+ ],
279
+ }]
280
+ }] });
281
+
282
+ class LegacyProductComponent {
283
+ constructor(route, quoteService, quoteApiService, contextService, runtimeContextService, runtimeService, currentStateService) {
284
+ this.route = route;
285
+ this.quoteService = quoteService;
286
+ this.quoteApiService = quoteApiService;
287
+ this.contextService = contextService;
288
+ this.runtimeContextService = runtimeContextService;
289
+ this.runtimeService = runtimeService;
290
+ this.currentStateService = currentStateService;
291
+ this.destroyed$ = new Subject();
292
+ }
293
+ ngOnInit() {
294
+ this.quoteService.quote$
295
+ .pipe(first(), takeUntil(this.destroyed$))
296
+ .subscribe(quote => this.init(quote, this.route.snapshot.queryParams));
297
+ this.runtimeService.onSolutionStopEvent.pipe(take(1)).subscribe(lineItem => this.onSolutionStop(lineItem));
298
+ this.runtimeService.onSolutionReadyEvent.pipe(take(1)).subscribe(event => this.onSolutionReady(event));
299
+ this.runtimeService.onSolutionCancelEvent.pipe(take(1)).subscribe(() => this.onSolutionCancel());
300
+ }
301
+ ngOnDestroy() {
302
+ this.destroyed$.next();
303
+ this.destroyed$.complete();
304
+ }
305
+ onSolutionReady(lineItem) {
306
+ var _a;
307
+ lineItem.actionCode = (_a = lineItem.actionCode) !== null && _a !== void 0 ? _a : 'ADD';
308
+ }
309
+ onSolutionCancel() {
310
+ this.quoteService.quote$.pipe(first(), takeUntil(this.destroyed$)).subscribe(quote => {
311
+ window['VELO_BACK_FN'].apply(null, [quote.quoteId]);
312
+ });
313
+ }
314
+ onSolutionUpdated(lineItem) {
315
+ const states = {
316
+ configurableRamp: lineItem,
317
+ currentState: this.currentStateService.currentState,
318
+ asset: this.getAsset(lineItem),
319
+ };
320
+ this.runtimeService.updateRuntime(states);
321
+ }
322
+ onSolutionStop(lineItem) {
323
+ this.quoteService.quote$.pipe(first(), takeUntil(this.destroyed$)).subscribe(quote => {
324
+ const quoteToUpsert = Object.assign(Object.assign({}, quote), { context: this.contextService.resolve(), currentState: [...(this.currentStateService.currentState || []).filter(li => li.id !== lineItem.id), lineItem] });
325
+ this.quoteApiService
326
+ .upsertQuote(quoteToUpsert)
327
+ .pipe(take(1))
328
+ .subscribe(quote => {
329
+ window['VELO_BACK_FN'].apply(null, [quote.quoteId]);
330
+ });
331
+ });
332
+ }
333
+ init(quote, queryParams) {
334
+ const productId = queryParams['productId'];
335
+ const lineItemId = this.getLineItemId(quote, queryParams);
336
+ this.assets = quote.initialState;
337
+ lineItemId && quote.currentState ? this.reConfigure(lineItemId, quote.currentState) : this.configure(productId);
338
+ }
339
+ getLineItemId(quote, queryParams) {
340
+ if (EntityUtil.isPresent(queryParams['lineItemId'])) {
341
+ return queryParams['lineItemId'];
342
+ }
343
+ return quote.currentState
344
+ .filter(lineItem => lineItem.productId === queryParams['productId'])
345
+ .map(lineItem => lineItem.id)
346
+ .find(id => id);
347
+ }
348
+ configure(productId) {
349
+ const runtimeContext = this.getRuntimeContext(productId, '', RuntimeOperation.INIT);
350
+ this.startRuntime({}, runtimeContext);
351
+ }
352
+ reConfigure(lineItemId, currentState) {
353
+ const currentStateItem = EntityUtil.findById(lineItemId, currentState);
354
+ const runtimeContext = this.getRuntimeContext(currentStateItem.productId, currentStateItem.offeringId, RuntimeOperation.UPDATE);
355
+ const states = {
356
+ configurableRamp: currentStateItem,
357
+ currentState,
358
+ asset: this.getAsset(currentStateItem),
359
+ };
360
+ this.currentStateService.update(currentState);
361
+ this.startRuntime(states, runtimeContext);
362
+ }
363
+ getAsset(lineItem) {
364
+ return this.assets && this.assets.find(a => a.id === lineItem.openOrderLineItemId || a.id === lineItem.assetId);
365
+ }
366
+ startRuntime(states, runtimeContext$) {
367
+ runtimeContext$
368
+ .pipe(take(1), map$1(runtimeContext => {
369
+ this.runtimeService.startRuntime(runtimeContext, states);
370
+ }))
371
+ .subscribe();
372
+ }
373
+ getRuntimeContext(productId, offeringId, runtimeOperation) {
374
+ return this.runtimeContextService.getRuntimeContext(productId, offeringId).pipe(map$1(runtimeContext => {
375
+ runtimeContext.invocationContext = { runtimeOperation: RuntimeOperation[runtimeOperation] };
376
+ return runtimeContext;
377
+ }));
378
+ }
379
+ }
380
+ LegacyProductComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: LegacyProductComponent, deps: [{ token: i1.ActivatedRoute }, { token: i2$1.QuoteService }, { token: i1$1.QuoteApiService }, { token: i2$1.ContextService }, { token: i2$1.RuntimeContextService }, { token: i2$1.RuntimeService }, { token: i2$1.CurrentStateService }], target: i0.ɵɵFactoryTarget.Component });
381
+ LegacyProductComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "12.2.16", type: LegacyProductComponent, selector: "ng-component", ngImport: i0, template: "<vl-runtime #runtimeView (solutionUpdated)=\"onSolutionUpdated($event)\"></vl-runtime>\n", styles: [":host{display:block;height:100%}\n"], components: [{ type: i2$1.RuntimeComponent, selector: "vl-runtime", outputs: ["solutionUpdated"] }] });
382
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: LegacyProductComponent, decorators: [{
383
+ type: Component,
384
+ args: [{
385
+ templateUrl: './legacy-product.component.html',
386
+ styleUrls: ['./legacy-product.component.scss'],
387
+ }]
388
+ }], ctorParameters: function () { return [{ type: i1.ActivatedRoute }, { type: i2$1.QuoteService }, { type: i1$1.QuoteApiService }, { type: i2$1.ContextService }, { type: i2$1.RuntimeContextService }, { type: i2$1.RuntimeService }, { type: i2$1.CurrentStateService }]; } });
389
+
390
+ class LegacyProductModule {
391
+ }
392
+ LegacyProductModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: LegacyProductModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
393
+ LegacyProductModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: LegacyProductModule, declarations: [LegacyProductComponent], imports: [CommonModule, RuntimeModule, TooltipModule], exports: [LegacyProductComponent] });
394
+ LegacyProductModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: LegacyProductModule, imports: [[CommonModule, RuntimeModule, TooltipModule]] });
395
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: LegacyProductModule, decorators: [{
396
+ type: NgModule,
397
+ args: [{
398
+ declarations: [LegacyProductComponent],
399
+ imports: [CommonModule, RuntimeModule, TooltipModule],
400
+ exports: [LegacyProductComponent],
401
+ }]
402
+ }] });
403
+
404
+ const FLOW_CUSTOMIZATION = new InjectionToken('FLOW_CUSTOMIZATION');
405
+
406
+ class ProductComponent {
407
+ constructor(runtimeService, conigurationService, quoteService, route, messageService, customizationService) {
408
+ this.runtimeService = runtimeService;
409
+ this.conigurationService = conigurationService;
410
+ this.quoteService = quoteService;
411
+ this.route = route;
412
+ this.messageService = messageService;
413
+ this.customizationService = customizationService;
414
+ this.destroy$ = new Subject();
415
+ this.state$ = new BehaviorSubject({ loading: true, failure: false });
416
+ }
417
+ ngOnInit() {
418
+ this.quoteService.quote$
419
+ .pipe(first$1(), takeUntil$1(this.destroy$))
420
+ .subscribe(quote => this.init(quote, this.route.snapshot.queryParams));
421
+ }
422
+ ngOnDestroy() {
423
+ this.destroy$.next();
424
+ this.destroy$.complete();
425
+ }
426
+ customize(productId) {
427
+ var _a;
428
+ if (!((_a = this.customizationService) === null || _a === void 0 ? void 0 : _a.getUiDefinition)) {
429
+ return of(null);
430
+ }
431
+ return this.customizationService.getUiDefinition(productId).pipe(tap(uiDef => {
432
+ var _a;
433
+ if (uiDef) {
434
+ this.uiDefinition = uiDef;
435
+ this.runtimeService.uiDefinitionProperties = (_a = uiDef.properties) !== null && _a !== void 0 ? _a : {};
436
+ }
437
+ }));
438
+ }
439
+ init(quote, queryParams) {
440
+ var _a;
441
+ const lineItemId = this.getLineItemId(quote, queryParams);
442
+ const currentStateItem = EntityUtil.findById(lineItemId, quote.currentState);
443
+ const productId = (_a = currentStateItem === null || currentStateItem === void 0 ? void 0 : currentStateItem.productId) !== null && _a !== void 0 ? _a : queryParams['productId'];
444
+ const { offeringId } = currentStateItem !== null && currentStateItem !== void 0 ? currentStateItem : {};
445
+ if (currentStateItem) {
446
+ this.conigurationService.updateCurrentStates({
447
+ configurableRamp: currentStateItem,
448
+ currentState: quote.currentState,
449
+ });
450
+ }
451
+ this.runtimeService
452
+ .init({ productId, offeringId })
453
+ .pipe(tap(context => (this.uiDefinition = context === null || context === void 0 ? void 0 : context.uiDefinition)), switchMap(() => this.customize(productId)), switchMap(() => this.conigurationService.configure()), tap(() => this.state$.next({ loading: false, failure: false })), catchError(error => {
454
+ this.messageService.add({
455
+ severity: 'error',
456
+ summary: error,
457
+ });
458
+ this.state$.next({ loading: false, failure: true });
459
+ return of();
460
+ }), takeUntil$1(this.destroy$))
461
+ .subscribe();
462
+ }
463
+ getLineItemId(quote, queryParams) {
464
+ if (EntityUtil.isPresent(queryParams['lineItemId'])) {
465
+ return queryParams['lineItemId'];
466
+ }
467
+ return quote.currentState
468
+ .filter(lineItem => lineItem.productId === queryParams['productId'])
469
+ .map(lineItem => lineItem.id)
470
+ .find(id => id);
471
+ }
472
+ }
473
+ ProductComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: ProductComponent, deps: [{ token: i1$2.ConfigurationRuntimeService }, { token: i1$2.ConfigurationService }, { token: i2$1.QuoteService }, { token: i1.ActivatedRoute }, { token: i4$1.MessageService }, { token: FLOW_CUSTOMIZATION, optional: true }], target: i0.ɵɵFactoryTarget.Component });
474
+ ProductComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "12.2.16", type: ProductComponent, selector: "vl-flow-product", 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: [""], components: [{ type: i2.LoaderComponent, selector: "vl-loader", inputs: ["label"] }, { type: i1$2.PreviewComponent, selector: "vl-cms-preview", inputs: ["modelId", "uiDefinition"] }], directives: [{ type: i3.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }], pipes: { "async": i3.AsyncPipe }, changeDetection: i0.ChangeDetectionStrategy.OnPush });
475
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: ProductComponent, decorators: [{
476
+ type: Component,
477
+ args: [{
478
+ selector: 'vl-flow-product',
479
+ templateUrl: './product.component.html',
480
+ styleUrls: ['./product.component.scss'],
481
+ changeDetection: ChangeDetectionStrategy.OnPush,
482
+ }]
483
+ }], ctorParameters: function () { return [{ type: i1$2.ConfigurationRuntimeService }, { type: i1$2.ConfigurationService }, { type: i2$1.QuoteService }, { type: i1.ActivatedRoute }, { type: i4$1.MessageService }, { type: undefined, decorators: [{
484
+ type: Optional
485
+ }, {
486
+ type: Inject,
487
+ args: [FLOW_CUSTOMIZATION]
488
+ }] }]; } });
489
+
490
+ class ProductModule {
491
+ }
492
+ ProductModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: ProductModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
493
+ ProductModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: ProductModule, declarations: [ProductComponent], imports: [CommonModule, PreviewModule, LoaderModule], exports: [ProductComponent] });
494
+ ProductModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: ProductModule, imports: [[CommonModule, PreviewModule, LoaderModule]] });
495
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: ProductModule, decorators: [{
496
+ type: NgModule,
497
+ args: [{
498
+ declarations: [ProductComponent],
499
+ imports: [CommonModule, PreviewModule, LoaderModule],
500
+ exports: [ProductComponent],
501
+ }]
502
+ }] });
503
+
504
+ class RecordNotFoundComponent {
505
+ constructor(router, route) {
506
+ var _a;
507
+ this.router = router;
508
+ this.route = route;
509
+ const navigation = this.router.getCurrentNavigation();
510
+ const { state } = (navigation === null || navigation === void 0 ? void 0 : navigation.extras) || {};
511
+ this.message = state === null || state === void 0 ? void 0 : state.message;
512
+ this.subMessage = ((_a = this.message) === null || _a === void 0 ? void 0 : _a.includes('/describe')) ? 'A potential problem with permissions' : '';
513
+ }
514
+ }
515
+ RecordNotFoundComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: RecordNotFoundComponent, deps: [{ token: i1.Router }, { token: i1.ActivatedRoute }], target: i0.ɵɵFactoryTarget.Component });
516
+ RecordNotFoundComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "12.2.16", type: RecordNotFoundComponent, selector: "vl-flow-record-not-found", ngImport: i0, template: "<div class=\"row\">\n <div class=\"col-md-12\">\n <div class=\"message-wrapper\">\n <div class=\"msg\">\n <div *ngIf=\"message; else defaultMessage\" class=\"message-title\">\n <p>{{ message }}</p>\n\n <p *ngIf=\"subMessage\" class=\"message-title\">{{ subMessage }}</p>\n </div>\n\n <ng-template #defaultMessage>Record not found</ng-template>\n </div>\n </div>\n </div>\n</div>\n", directives: [{ type: i3.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
517
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: RecordNotFoundComponent, decorators: [{
518
+ type: Component,
519
+ args: [{
520
+ selector: 'vl-flow-record-not-found',
521
+ templateUrl: './record-not-found.component.html',
522
+ changeDetection: ChangeDetectionStrategy.OnPush,
523
+ }]
524
+ }], ctorParameters: function () { return [{ type: i1.Router }, { type: i1.ActivatedRoute }]; } });
525
+
526
+ const routes = [{ path: '', component: RecordNotFoundComponent }];
527
+ class RecordNotFoundModule {
528
+ }
529
+ RecordNotFoundModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: RecordNotFoundModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
530
+ RecordNotFoundModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: RecordNotFoundModule, declarations: [RecordNotFoundComponent], imports: [CommonModule, i1.RouterModule] });
531
+ RecordNotFoundModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: RecordNotFoundModule, imports: [[CommonModule, RouterModule.forChild(routes)]] });
532
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: RecordNotFoundModule, decorators: [{
533
+ type: NgModule,
534
+ args: [{
535
+ declarations: [RecordNotFoundComponent],
536
+ imports: [CommonModule, RouterModule.forChild(routes)],
537
+ }]
538
+ }] });
539
+
540
+ class ContextResolver {
541
+ constructor(contextService, router, routerService) {
542
+ this.contextService = contextService;
543
+ this.router = router;
544
+ this.routerService = routerService;
545
+ }
546
+ handleError(route, message) {
547
+ this.contextService.delete();
548
+ const parentUrl = this.routerService.getFlowRootPath(route);
549
+ return from(this.router.navigate([parentUrl, '404'], { state: { message } }));
550
+ }
551
+ resolve(route) {
552
+ const { queryParams, data } = route;
553
+ const { uiDefinitionId } = queryParams;
554
+ const { headerId, mode } = data !== null && data !== void 0 ? data : {};
555
+ const currentContext = this.contextService.resolve();
556
+ if (headerId && (currentContext === null || currentContext === void 0 ? void 0 : currentContext.headerId) === headerId) {
557
+ return of(currentContext);
558
+ }
559
+ return this.contextService.create(headerId, mode).pipe(tap$1((context) => {
560
+ this.contextService.update(Object.assign(Object.assign({}, context), { uiDefinitionId, properties: Object.assign(Object.assign(Object.assign({}, currentContext === null || currentContext === void 0 ? void 0 : currentContext.properties), context.properties), (queryParams !== null && queryParams !== void 0 ? queryParams : {})) }));
561
+ }), catchError$1(e => {
562
+ const message = e instanceof HttpErrorResponse ? e.error.message : e;
563
+ this.handleError(route, message);
564
+ return of(null);
565
+ }));
566
+ }
567
+ }
568
+ ContextResolver.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: ContextResolver, deps: [{ token: i2$1.ContextService }, { token: i1.Router }, { token: RouterService }], target: i0.ɵɵFactoryTarget.Injectable });
569
+ ContextResolver.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: ContextResolver });
570
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: ContextResolver, decorators: [{
571
+ type: Injectable
572
+ }], ctorParameters: function () { return [{ type: i2$1.ContextService }, { type: i1.Router }, { type: RouterService }]; } });
573
+
574
+ class FlowResolver {
575
+ constructor(router, flowService, routerService) {
576
+ this.router = router;
577
+ this.flowService = flowService;
578
+ this.routerService = routerService;
579
+ }
580
+ handleError(route, message, queryParams) {
581
+ const parentUrl = this.routerService.getFlowRootPath(route);
582
+ return this.router.navigate([parentUrl, '404'], {
583
+ queryParams,
584
+ state: {
585
+ message: message,
586
+ },
587
+ });
588
+ }
589
+ resolve(route) {
590
+ const { queryParams } = route;
591
+ const { flowId } = queryParams;
592
+ if (!flowId) {
593
+ return this.handleError(route);
594
+ }
595
+ return this.flowService.getFlow(flowId).pipe(map$1(flow => {
596
+ if (!flow) {
597
+ return this.handleError(route, `Flow with flowId=${flowId} is not defined`);
598
+ }
599
+ const { properties } = flow;
600
+ const { entryPath } = properties;
601
+ const { queryParams: flowQueryParams } = properties;
602
+ const mergedParams = Object.assign(Object.assign({}, queryParams), flowQueryParams);
603
+ const parentUrl = this.routerService.getFlowRootPath(route);
604
+ const entryUrl = String(entryPath !== null && entryPath !== void 0 ? entryPath : '')
605
+ .split('/')
606
+ .filter(Boolean);
607
+ return this.router
608
+ .navigate([parentUrl, ...entryUrl], {
609
+ queryParams: mergedParams,
610
+ replaceUrl: true,
611
+ })
612
+ .catch(e => {
613
+ const message = e instanceof HttpErrorResponse ? e.error.message : e;
614
+ return this.handleError(route, message, mergedParams);
615
+ });
616
+ }));
617
+ }
618
+ }
619
+ FlowResolver.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: FlowResolver, deps: [{ token: i1.Router }, { token: FlowService }, { token: RouterService }], target: i0.ɵɵFactoryTarget.Injectable });
620
+ FlowResolver.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: FlowResolver });
621
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: FlowResolver, decorators: [{
622
+ type: Injectable
623
+ }], ctorParameters: function () { return [{ type: i1.Router }, { type: FlowService }, { type: RouterService }]; } });
624
+
625
+ class QuoteResolver {
626
+ constructor(router, quoteService, routerService) {
627
+ this.router = router;
628
+ this.quoteService = quoteService;
629
+ this.routerService = routerService;
630
+ }
631
+ handleError(route, message) {
632
+ const parentUrl = this.routerService.getFlowRootPath(route);
633
+ return from(this.router.navigate([parentUrl, '404'], { state: { message } }));
634
+ }
635
+ resolve(route) {
636
+ const { headerId } = route.data;
637
+ const quote = this.quoteService.getQuote();
638
+ if (quote && quote.quoteId === headerId) {
639
+ return of(true);
640
+ }
641
+ const { queryParams } = route;
642
+ return this.quoteService.init(headerId, queryParams).pipe(catchError(e => {
643
+ const message = e instanceof HttpErrorResponse ? e.error.message : e;
644
+ return this.handleError(route, message);
645
+ }));
646
+ }
647
+ }
648
+ QuoteResolver.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: QuoteResolver, deps: [{ token: i1.Router }, { token: i2$1.QuoteService }, { token: RouterService }], target: i0.ɵɵFactoryTarget.Injectable });
649
+ QuoteResolver.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: QuoteResolver });
650
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: QuoteResolver, decorators: [{
651
+ type: Injectable
652
+ }], ctorParameters: function () { return [{ type: i1.Router }, { type: i2$1.QuoteService }, { type: RouterService }]; } });
653
+
654
+ const rootRoute = {
655
+ id: VELOCE_FLOW_ROOT_ROUTE,
656
+ path: '',
657
+ component: FlowComponent,
658
+ canActivate: [RootGuard],
659
+ canDeactivate: [RootGuard],
660
+ children: [
661
+ {
662
+ path: 'flows',
663
+ runGuardsAndResolvers: 'paramsOrQueryParamsChange',
664
+ resolve: { quote: FlowResolver },
665
+ canActivate: [ContextGuard],
666
+ children: [],
667
+ },
668
+ {
669
+ path: 'legacy',
670
+ children: [
671
+ {
672
+ path: 'product',
673
+ component: LegacyProductComponent,
674
+ runGuardsAndResolvers: 'paramsOrQueryParamsChange',
675
+ resolve: { context: ContextResolver, quote: QuoteResolver },
676
+ canActivate: [ContextGuard],
677
+ },
678
+ ],
679
+ },
680
+ {
681
+ path: 'product',
682
+ component: ProductComponent,
683
+ runGuardsAndResolvers: 'paramsOrQueryParamsChange',
684
+ resolve: { context: ContextResolver, quote: QuoteResolver },
685
+ canActivate: [ContextGuard],
686
+ },
687
+ {
688
+ path: 'debug',
689
+ loadChildren: () => DebugModule,
690
+ },
691
+ {
692
+ path: '404',
693
+ loadChildren: () => RecordNotFoundModule,
694
+ },
695
+ ],
696
+ };
697
+ class FlowRoutingModule {
698
+ }
699
+ FlowRoutingModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: FlowRoutingModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
700
+ FlowRoutingModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: FlowRoutingModule, imports: [i1.RouterModule, ProductModule, LegacyProductModule], exports: [RouterModule] });
701
+ FlowRoutingModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: FlowRoutingModule, providers: [RouterService, RootGuard, ContextGuard, ContextResolver, FlowResolver, QuoteResolver], imports: [[RouterModule.forChild([rootRoute]), ProductModule, LegacyProductModule], RouterModule] });
702
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: FlowRoutingModule, decorators: [{
703
+ type: NgModule,
704
+ args: [{
705
+ imports: [RouterModule.forChild([rootRoute]), ProductModule, LegacyProductModule],
706
+ exports: [RouterModule],
707
+ providers: [RouterService, RootGuard, ContextGuard, ContextResolver, FlowResolver, QuoteResolver],
708
+ }]
709
+ }] });
710
+
711
+ class FlowModule {
712
+ }
713
+ FlowModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: FlowModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
714
+ FlowModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: FlowModule, declarations: [FlowComponent], imports: [CommonModule, FlowRoutingModule, ApiModule, LauncherModule, LoaderModule] });
715
+ FlowModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: FlowModule, providers: [FlowService, ContextService], imports: [[CommonModule, FlowRoutingModule, ApiModule, LauncherModule, LoaderModule]] });
716
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: FlowModule, decorators: [{
717
+ type: NgModule,
718
+ args: [{
719
+ declarations: [FlowComponent],
720
+ imports: [CommonModule, FlowRoutingModule, ApiModule, LauncherModule, LoaderModule],
721
+ providers: [FlowService, ContextService],
722
+ }]
723
+ }] });
2
724
 
3
725
  /**
4
726
  * Generated bundle index. Do not edit.
5
727
  */
728
+
729
+ export { ContextGuard, FLOW_CUSTOMIZATION, FlowModule, FlowService, VELOCE_FLOW_ROOT_ROUTE };
6
730
  //# sourceMappingURL=veloce-sdk.js.map