@veloceapps/sdk 11.0.0-16 → 11.0.0-17

Sign up to get free protection for your applications and to get access to all the features.
Files changed (124) hide show
  1. package/cms/cms.actions.d.ts +98 -22
  2. package/cms/components/element-renderer/element-renderer.component.d.ts +3 -10
  3. package/cms/services/element-context.service.d.ts +0 -1
  4. package/cms/types/common.types.d.ts +2 -0
  5. package/cms/types/index.d.ts +0 -1
  6. package/cms/utils/path.utils.d.ts +1 -2
  7. package/cms/vendor-map.d.ts +4 -27
  8. package/core/index.d.ts +0 -1
  9. package/core/modules/configuration/index.d.ts +1 -4
  10. package/core/modules/configuration/services/configuration-runtime.service.d.ts +3 -20
  11. package/core/modules/configuration/services/configuration-state.service.d.ts +3 -3
  12. package/core/modules/configuration/services/configuration.service.d.ts +23 -46
  13. package/core/modules/flow-configuration/index.d.ts +0 -3
  14. package/core/modules/flow-configuration/services/flow-configuration.service.d.ts +5 -13
  15. package/core/services/flow-info.service.d.ts +3 -2
  16. package/core/services/flow-state-configuration.service.d.ts +2 -8
  17. package/core/services/flow-state.service.d.ts +6 -12
  18. package/core/services/index.d.ts +0 -1
  19. package/core/services/integration.state.d.ts +1 -1
  20. package/core/services/sales-transaction.service.d.ts +4 -2
  21. package/core/types/index.d.ts +0 -1
  22. package/core/utils/index.d.ts +2 -2
  23. package/core/utils/transaction-item.utils.d.ts +7 -0
  24. package/core/utils/transaction-item.worker.d.ts +8 -0
  25. package/esm2020/cms/cms.actions.mjs +99 -65
  26. package/esm2020/cms/cms.default.mjs +2 -3
  27. package/esm2020/cms/components/element-renderer/element-renderer.component.mjs +7 -64
  28. package/esm2020/cms/components/preview/preview.component.mjs +3 -3
  29. package/esm2020/cms/services/element-context.service.mjs +1 -1
  30. package/esm2020/cms/types/common.types.mjs +1 -1
  31. package/esm2020/cms/types/index.mjs +1 -2
  32. package/esm2020/cms/utils/element.utils.mjs +3 -3
  33. package/esm2020/cms/utils/path.utils.mjs +1 -10
  34. package/esm2020/cms/vendor-map.mjs +4 -5
  35. package/esm2020/core/core.module.mjs +4 -5
  36. package/esm2020/core/index.mjs +1 -2
  37. package/esm2020/core/modules/configuration/configuration.module.mjs +3 -4
  38. package/esm2020/core/modules/configuration/index.mjs +2 -5
  39. package/esm2020/core/modules/configuration/services/configuration-runtime.service.mjs +9 -67
  40. package/esm2020/core/modules/configuration/services/configuration-state.service.mjs +46 -54
  41. package/esm2020/core/modules/configuration/services/configuration.service.mjs +96 -226
  42. package/esm2020/core/modules/flow-configuration/flow-configuration.module.mjs +3 -4
  43. package/esm2020/core/modules/flow-configuration/index.mjs +1 -4
  44. package/esm2020/core/modules/flow-configuration/services/flow-configuration.service.mjs +15 -32
  45. package/esm2020/core/services/flow-info.service.mjs +9 -3
  46. package/esm2020/core/services/flow-state-configuration.service.mjs +10 -25
  47. package/esm2020/core/services/flow-state.service.mjs +25 -58
  48. package/esm2020/core/services/index.mjs +1 -2
  49. package/esm2020/core/services/integration.state.mjs +2 -2
  50. package/esm2020/core/services/sales-transaction.service.mjs +11 -5
  51. package/esm2020/core/types/index.mjs +1 -2
  52. package/esm2020/core/utils/index.mjs +3 -3
  53. package/esm2020/core/utils/transaction-item.utils.mjs +60 -0
  54. package/esm2020/core/utils/transaction-item.worker.mjs +16 -0
  55. package/esm2020/src/flow-routing.module.mjs +8 -8
  56. package/esm2020/src/guards/flow.guard.mjs +5 -7
  57. package/esm2020/src/guards/product-unload.guard.mjs +7 -7
  58. package/esm2020/src/index.mjs +1 -2
  59. package/esm2020/src/pages/debug/debug.component.mjs +10 -15
  60. package/esm2020/src/pages/product/product.component.mjs +11 -14
  61. package/esm2020/src/pages/record-not-found/record-not-found.component.mjs +5 -6
  62. package/esm2020/src/resolvers/sales-transaction.resolver.mjs +83 -0
  63. package/esm2020/src/resolvers/ui-definition.resolver.mjs +5 -4
  64. package/esm2020/src/services/flow-dialog.service.mjs +1 -1
  65. package/esm2020/src/services/flow-router.service.mjs +17 -24
  66. package/esm2020/src/services/flow.service.mjs +5 -13
  67. package/esm2020/src/types/index.mjs +2 -3
  68. package/esm2020/src/types/route.types.mjs +1 -1
  69. package/fesm2015/veloceapps-sdk-cms.mjs +116 -252
  70. package/fesm2015/veloceapps-sdk-cms.mjs.map +1 -1
  71. package/fesm2015/veloceapps-sdk-core.mjs +318 -1116
  72. package/fesm2015/veloceapps-sdk-core.mjs.map +1 -1
  73. package/fesm2015/veloceapps-sdk.mjs +87 -120
  74. package/fesm2015/veloceapps-sdk.mjs.map +1 -1
  75. package/fesm2020/veloceapps-sdk-cms.mjs +112 -244
  76. package/fesm2020/veloceapps-sdk-cms.mjs.map +1 -1
  77. package/fesm2020/veloceapps-sdk-core.mjs +366 -1162
  78. package/fesm2020/veloceapps-sdk-core.mjs.map +1 -1
  79. package/fesm2020/veloceapps-sdk.mjs +87 -120
  80. package/fesm2020/veloceapps-sdk.mjs.map +1 -1
  81. package/package.json +1 -1
  82. package/src/guards/product-unload.guard.d.ts +3 -3
  83. package/src/index.d.ts +0 -1
  84. package/src/pages/debug/debug.component.d.ts +1 -3
  85. package/src/pages/product/product.component.d.ts +3 -4
  86. package/src/pages/record-not-found/record-not-found.component.d.ts +2 -3
  87. package/src/resolvers/sales-transaction.resolver.d.ts +18 -0
  88. package/src/services/flow-dialog.service.d.ts +2 -1
  89. package/src/services/flow-router.service.d.ts +5 -5
  90. package/src/services/flow.service.d.ts +0 -1
  91. package/src/types/index.d.ts +1 -2
  92. package/src/types/route.types.d.ts +0 -5
  93. package/cms/plugins/configuration.plugin.d.ts +0 -23
  94. package/cms/types/configuration.types.d.ts +0 -21
  95. package/core/modules/configuration/helpers.d.ts +0 -7
  96. package/core/modules/configuration/services/runtime-context.service.d.ts +0 -12
  97. package/core/modules/configuration/types/configuration-runtime.types.d.ts +0 -8
  98. package/core/modules/flow-configuration/services/flow-update.service.d.ts +0 -13
  99. package/core/modules/flow-configuration/types/update.types.d.ts +0 -12
  100. package/core/services/quote-draft.service.d.ts +0 -50
  101. package/core/types/runtime.types.d.ts +0 -30
  102. package/core/utils/line-item.utils.d.ts +0 -25
  103. package/core/utils/line-item.worker.d.ts +0 -9
  104. package/esm2020/cms/plugins/configuration.plugin.mjs +0 -109
  105. package/esm2020/cms/types/configuration.types.mjs +0 -2
  106. package/esm2020/core/modules/configuration/helpers.mjs +0 -67
  107. package/esm2020/core/modules/configuration/services/runtime-context.service.mjs +0 -45
  108. package/esm2020/core/modules/configuration/types/configuration-runtime.types.mjs +0 -2
  109. package/esm2020/core/modules/flow-configuration/services/flow-update.service.mjs +0 -138
  110. package/esm2020/core/modules/flow-configuration/types/update.types.mjs +0 -2
  111. package/esm2020/core/services/quote-draft.service.mjs +0 -174
  112. package/esm2020/core/types/runtime.types.mjs +0 -16
  113. package/esm2020/core/utils/line-item.utils.mjs +0 -187
  114. package/esm2020/core/utils/line-item.worker.mjs +0 -19
  115. package/esm2020/src/resolvers/quote.resolver.mjs +0 -82
  116. package/esm2020/src/types/context-route.types.mjs +0 -2
  117. package/esm2020/src/types/metrics.types.mjs +0 -2
  118. package/esm2020/src/utils/flow.utils.mjs +0 -14
  119. package/esm2020/src/utils/index.mjs +0 -2
  120. package/src/resolvers/quote.resolver.d.ts +0 -18
  121. package/src/types/context-route.types.d.ts +0 -5
  122. package/src/types/metrics.types.d.ts +0 -5
  123. package/src/utils/flow.utils.d.ts +0 -1
  124. package/src/utils/index.d.ts +0 -1
@@ -1,215 +1,37 @@
1
1
  import * as i0 from '@angular/core';
2
- import { InjectionToken, Injectable, Optional, Inject, NgModule, inject, Directive, Input, LOCALE_ID, Pipe } from '@angular/core';
3
- import { UUID, ConfigurationContextMode, RuntimeModel, isNotLegacyUIDefinition, SalesforceIdUtils, DEFAULT_CURRENCY_ISO_CODE, DEFAULT_CURRENCY_SYMBOL, validateDateFormat, DEFAULT_DATE_FORMAT, DEFAULT_DECIMALS_COUNT, getSupportedDateFormats, DEFAULT_DECIMAL_SEPARATOR, DEFAULT_THOUSANDS_SEPARATOR, DEFAULT_ACTION_CODE_LABELS, parseJsonSafely, UITemplateType, ChargeGroupUtils, isDefined, ConfigurationProcessorTypes, EntityUtil, QuoteDraft, ConfigurationMode, extractErrorDetails, ConfigurationTranslatorUtils, DEFAULT_TIME_FORMAT, formatNumber } from '@veloceapps/core';
2
+ import { Injectable, InjectionToken, Optional, Inject, NgModule, inject, Directive, Input, LOCALE_ID, Pipe } from '@angular/core';
3
+ import { DEFAULT_CURRENCY_ISO_CODE, DEFAULT_CURRENCY_SYMBOL, validateDateFormat, DEFAULT_DATE_FORMAT, DEFAULT_DECIMALS_COUNT, getSupportedDateFormats, DEFAULT_DECIMAL_SEPARATOR, DEFAULT_THOUSANDS_SEPARATOR, DEFAULT_ACTION_CODE_LABELS, parseJsonSafely, UITemplateType, SalesforceIdUtils, isDefined, UUID, extractErrorDetails, ConfigurationProcessorTypes, EntityUtil, DEFAULT_TIME_FORMAT, formatNumber } from '@veloceapps/core';
4
4
  import * as i1 from '@veloceapps/api';
5
5
  import { ApiModule } from '@veloceapps/api';
6
- import { map, first, tap, filter as filter$1, switchMap as switchMap$1, skip, take as take$1, shareReplay as shareReplay$1, catchError as catchError$1, finalize as finalize$1 } from 'rxjs/operators';
7
- import { HttpErrorResponse } from '@angular/common/http';
8
6
  import * as i6 from '@veloceapps/components';
9
- import { ToastType, ConfirmationComponent, ConfirmationDialogModule } from '@veloceapps/components';
10
- import { uniqBy, flatten, entries, sortBy, map as map$2, omit, cloneDeep, assign, isEqual, transform } from 'lodash';
11
- import * as i4 from 'primeng/api';
12
- import * as i5 from 'primeng/dynamicdialog';
13
- import { BehaviorSubject, map as map$1, tap as tap$1, switchMap, of, forkJoin, Subject, noop, catchError, throwError, filter, shareReplay, combineLatest, finalize, buffer, debounceTime, share, take, distinctUntilChanged, zip, takeUntil } from 'rxjs';
14
- import * as i2 from '@veloceapps/api/v2';
15
- import moment from 'moment';
7
+ import { ToastType, ConfirmationDialogModule } from '@veloceapps/components';
8
+ import * as i4 from '@veloceapps/api/v2';
9
+ import { uniqBy, flatten, omit, cloneDeep, assign, isEqual } from 'lodash';
10
+ import { BehaviorSubject, map, tap, switchMap, of, forkJoin, throwError, noop, filter as filter$1, Subject, catchError as catchError$1, combineLatest, finalize as finalize$1, buffer, debounceTime, share, take, distinctUntilChanged, shareReplay, takeUntil } from 'rxjs';
11
+ import * as i2 from 'primeng/api';
12
+ import { filter, map as map$1, catchError, tap as tap$1, finalize } from 'rxjs/operators';
16
13
  import { NgControl } from '@angular/forms';
17
14
  import 'primeng/calendar';
18
15
  import { DATE_PIPE_DEFAULT_OPTIONS, formatDate } from '@angular/common';
19
16
 
20
- const getDefaultLineItem = (context, uiDefinitionProperties, qty = 1) => {
21
- const id = UUID.UUID();
22
- const attributes = [];
23
- const lineItems = [];
24
- return {
25
- id,
26
- type: uiDefinitionProperties.rootType ?? '',
27
- cfgStatus: 'Default',
28
- actionCode: 'ADD',
29
- qty,
30
- attributes,
31
- lineItems,
32
- productName: context.properties?.['displayName'] || context.productName,
33
- productId: context.productId ?? '',
34
- ...(uiDefinitionProperties.offeringId ? { offeringId: uiDefinitionProperties.offeringId } : {}),
35
- };
36
- };
37
- const generateEmptyContext = () => {
38
- return {
39
- headerId: '',
40
- mode: ConfigurationContextMode.TEST,
41
- properties: {},
42
- configurationToken: '',
43
- };
44
- };
45
- const getGuidedSellingConfigurationRequest = (data) => {
46
- return {
47
- mode: 'SEARCH',
48
- step: 'START',
49
- attributeDomainMode: 'ALL',
50
- context: generateEmptyContext(),
51
- lineItem: {
52
- actionCode: 'ADD',
53
- cfgStatus: 'Default',
54
- id: UUID.UUID(),
55
- qty: 1,
56
- type: data.modelType,
57
- attributes: Object.entries(data.attributesMap).map(([name, value]) => ({
58
- name,
59
- value,
60
- cfgStatus: 'User',
61
- })),
62
- },
63
- };
64
- };
65
- const generateConfigurationLineItem = (props, qty = 1) => {
66
- const id = UUID.UUID();
67
- const attributes = Object.entries(props.attributesMap ?? {}).map(([name, value]) => ({
68
- name,
69
- value,
70
- cfgStatus: 'User',
71
- }));
72
- const lineItems = [];
73
- return {
74
- id,
75
- type: props.product.typeName ?? '',
76
- cfgStatus: 'Default',
77
- actionCode: 'ADD',
78
- qty,
79
- attributes,
80
- lineItems,
81
- productName: props.product.name,
82
- productId: props.product.id ?? '',
83
- };
84
- };
85
-
86
- const FLOW_CUSTOMIZATION = new InjectionToken('FLOW_CUSTOMIZATION');
87
-
88
- const FORMATTING_SETTINGS_TOKEN = new InjectionToken('Summary of formatting settings for variant types of data, e.g. numbers, text, dates, etc');
89
-
90
- var RuntimeMode;
91
- (function (RuntimeMode) {
92
- RuntimeMode[RuntimeMode["TEST"] = 0] = "TEST";
93
- RuntimeMode[RuntimeMode["PROD"] = 1] = "PROD";
94
- })(RuntimeMode || (RuntimeMode = {}));
95
- var RuntimeOperation;
96
- (function (RuntimeOperation) {
97
- RuntimeOperation["INIT"] = "INIT";
98
- RuntimeOperation["UPDATE"] = "UPDATE";
99
- })(RuntimeOperation || (RuntimeOperation = {}));
100
- var RuntimeStep;
101
- (function (RuntimeStep) {
102
- RuntimeStep["START"] = "START";
103
- RuntimeStep["UPDATE"] = "UPDATE";
104
- })(RuntimeStep || (RuntimeStep = {}));
105
-
106
- const UI_DEFINITION_VERSION = 3;
107
-
108
- class RuntimeContextService {
109
- constructor(configurationApiService) {
110
- this.configurationApiService = configurationApiService;
111
- }
112
- getRuntimeContext(productId, offeringId, defaultUIDefinitionId, requiredUIDefinitionId) {
113
- return this.configurationApiService
114
- .getRuntimeDataByProductId(productId, offeringId, defaultUIDefinitionId, requiredUIDefinitionId)
115
- .pipe(map(runtimeData => {
116
- const uiDefinitionContainer = this.getUIDefinitionContainer(runtimeData);
117
- const runtimeModel = RuntimeModel.create(runtimeData.types, runtimeData.products);
118
- const { productName, properties } = Array.from(runtimeModel.components.values()).find(c => c.productId === productId) ?? {};
119
- const uiDefinitionProperties = uiDefinitionContainer?.source.properties;
120
- return {
121
- modelId: runtimeData.modelId,
122
- uiDefinitionContainer: uiDefinitionContainer,
123
- runtimeModel: runtimeModel,
124
- runtimeMode: RuntimeMode.PROD,
125
- productId: productId,
126
- productType: properties?.['displayName'] || productName,
127
- offeringId: offeringId,
128
- properties: {
129
- PricingEnabled: uiDefinitionProperties?.pricingEnabled ? 'true' : 'false',
130
- PriceListId: uiDefinitionProperties?.priceList,
131
- },
132
- };
133
- }));
134
- }
135
- getUIDefinitionContainer(runtimeData) {
136
- const containers = runtimeData.uiDefinitions.filter(container => isNotLegacyUIDefinition(container.source));
137
- return containers.find(container => container.source.primary) ?? containers[0];
138
- }
139
- }
140
- RuntimeContextService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: RuntimeContextService, deps: [{ token: i1.ConfigurationApiService }], target: i0.ɵɵFactoryTarget.Injectable });
141
- RuntimeContextService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: RuntimeContextService });
142
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: RuntimeContextService, decorators: [{
143
- type: Injectable
144
- }], ctorParameters: function () { return [{ type: i1.ConfigurationApiService }]; } });
145
-
146
17
  class ConfigurationRuntimeService {
147
- constructor(apiService, runtimeContextService) {
148
- this.apiService = apiService;
149
- this.runtimeContextService = runtimeContextService;
150
- this._isInitialized = false;
151
- this.uiDefinitionProperties = {};
152
- }
153
- reset() {
154
- this._isInitialized = false;
155
- this._runtimeContext = undefined;
156
- this.initializationProps = undefined;
157
- this.uiDefinitionProperties = {};
158
- }
159
- initTestMode(uiDefinitionContainer) {
160
- this.uiDefinitionProperties = uiDefinitionContainer.source.properties ?? {};
161
- return this.apiService.getRuntimeDataByModelId(uiDefinitionContainer.modelId).pipe(first(), map(runtimeData => {
162
- this._runtimeContext = {
163
- modelId: uiDefinitionContainer.modelId,
164
- runtimeModel: RuntimeModel.create(runtimeData.types, runtimeData.products),
165
- runtimeMode: RuntimeMode.TEST,
166
- uiDefinitionContainer,
167
- };
168
- return this._runtimeContext;
169
- }), tap(() => (this._isInitialized = true)));
170
- }
171
- init(props) {
172
- this.initializationProps = props;
173
- return this.runtimeContextService
174
- .getRuntimeContext(props.productId, props.offeringId, props.defaultUIDefinitionId, props.requiredUIDefinitionId)
175
- .pipe(tap(runtimeContext => {
176
- this.uiDefinitionProperties = runtimeContext.uiDefinitionContainer?.source.properties ?? {};
177
- this.id15to18('AccountId', runtimeContext.properties);
178
- this._runtimeContext = runtimeContext;
179
- return this._runtimeContext;
180
- }), tap(() => (this._isInitialized = true)));
181
- }
182
- overrideUIDefinition(uiDefinitionContainer) {
183
- if (!this._runtimeContext) {
184
- return;
185
- }
186
- this._runtimeContext.uiDefinitionContainer = uiDefinitionContainer;
187
- this.uiDefinitionProperties = uiDefinitionContainer.source.properties ?? {};
188
- }
189
- id15to18(propertyName, source) {
190
- if (!source) {
191
- return;
192
- }
193
- const value = source[propertyName];
194
- if (typeof value === 'string' && value.length === 15) {
195
- source[propertyName] = SalesforceIdUtils.generateId18FromId15(value);
196
- }
197
- }
198
- get isInitialized() {
199
- return this._isInitialized;
18
+ constructor() {
19
+ this.uiDefinitionContainer = null;
200
20
  }
201
- get runtimeModel() {
202
- return this.runtimeContext?.runtimeModel;
21
+ get uiDefinitionProps() {
22
+ return this.uiDefinitionContainer?.source.properties ?? {};
203
23
  }
204
- get runtimeContext() {
205
- return this._runtimeContext;
24
+ reset() {
25
+ this.uiDefinitionContainer = null;
206
26
  }
207
27
  }
208
- ConfigurationRuntimeService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: ConfigurationRuntimeService, deps: [{ token: i1.ConfigurationApiService }, { token: RuntimeContextService }], target: i0.ɵɵFactoryTarget.Injectable });
28
+ ConfigurationRuntimeService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: ConfigurationRuntimeService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
209
29
  ConfigurationRuntimeService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: ConfigurationRuntimeService });
210
30
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: ConfigurationRuntimeService, decorators: [{
211
31
  type: Injectable
212
- }], ctorParameters: function () { return [{ type: i1.ConfigurationApiService }, { type: RuntimeContextService }]; } });
32
+ }] });
33
+
34
+ const FLOW_CUSTOMIZATION = new InjectionToken('FLOW_CUSTOMIZATION');
213
35
 
214
36
  class RuntimeSettingsService {
215
37
  constructor(configurationSettingsApiService) {
@@ -228,11 +50,11 @@ class RuntimeSettingsService {
228
50
  };
229
51
  }
230
52
  create() {
231
- return this.configurationSettingsApiService.fetchSettings().pipe(map$1(settings => this.parseConfigurationSettings(settings)), tap$1(configurationSettings => {
53
+ return this.configurationSettingsApiService.fetchSettings().pipe(map(settings => this.parseConfigurationSettings(settings)), tap(configurationSettings => {
232
54
  this.configurationSettings$.next(configurationSettings);
233
55
  this.addShoppingCartSettings(configurationSettings['shopping-cart'] ?? []);
234
56
  this.formattingSettings = this.getFormattingSettings();
235
- }), map$1(() => undefined));
57
+ }), map(() => undefined));
236
58
  }
237
59
  initCurrency(iso) {
238
60
  if (iso) {
@@ -336,7 +158,7 @@ class FlowInfoService {
336
158
  return this.templatesSubj$.value;
337
159
  }
338
160
  get isFlowEngineInitialized$() {
339
- return this.templates$.pipe(map$1(v => Boolean(v.FLOW_ENGINE)));
161
+ return this.templates$.pipe(map(v => Boolean(v.FLOW_ENGINE)));
340
162
  }
341
163
  get isStateful() {
342
164
  return !!this.flow?.properties.stateful;
@@ -354,7 +176,7 @@ class FlowInfoService {
354
176
  this.flow$ = this.flowSubj$.asObservable();
355
177
  this.templates$ = this.templatesSubj$.asObservable();
356
178
  }
357
- cleanup() {
179
+ reset() {
358
180
  this.flowSubj$.next(null);
359
181
  this.templatesSubj$.next({});
360
182
  this.contextSubj$.next(null);
@@ -362,6 +184,12 @@ class FlowInfoService {
362
184
  init$(flowId, routeQueryParams) {
363
185
  return this.initFlow$(flowId, routeQueryParams).pipe(switchMap(() => this.initFlowTemplates$()));
364
186
  }
187
+ updateContext(update) {
188
+ this.contextSubj$.next({
189
+ ...this.context,
190
+ ...update,
191
+ });
192
+ }
365
193
  initFlow$(flowId, routeQueryParams) {
366
194
  const flow = this.runtimeSettingsService.getConfigurationSettings()['flows']?.find(({ id }) => flowId === id);
367
195
  if (!flow) {
@@ -389,7 +217,7 @@ class FlowInfoService {
389
217
  return forkJoin([
390
218
  this.templatesApiService.fetchTemplates$(),
391
219
  this.customizationService?.getTemplates?.() ?? of([]),
392
- ]).pipe(map$1(([templates, localTemplates]) => {
220
+ ]).pipe(map(([templates, localTemplates]) => {
393
221
  const newValue = {};
394
222
  Object.entries({ ...this.defaultTemplates, ...(this.flow?.properties.templates ?? {}) }).forEach(([key, name]) => {
395
223
  const type = this.remapTemplateName(key);
@@ -433,239 +261,87 @@ class FlowInfoService {
433
261
  return objectName.toUpperCase();
434
262
  }
435
263
  }
436
- FlowInfoService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: FlowInfoService, deps: [{ token: RuntimeSettingsService }, { token: i2.UITemplatesApiService }, { token: FLOW_CUSTOMIZATION, optional: true }], target: i0.ɵɵFactoryTarget.Injectable });
264
+ FlowInfoService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: FlowInfoService, deps: [{ token: RuntimeSettingsService }, { token: i4.UITemplatesApiService }, { token: FLOW_CUSTOMIZATION, optional: true }], target: i0.ɵɵFactoryTarget.Injectable });
437
265
  FlowInfoService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: FlowInfoService });
438
266
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: FlowInfoService, decorators: [{
439
267
  type: Injectable
440
- }], ctorParameters: function () { return [{ type: RuntimeSettingsService }, { type: i2.UITemplatesApiService }, { type: undefined, decorators: [{
268
+ }], ctorParameters: function () { return [{ type: RuntimeSettingsService }, { type: i4.UITemplatesApiService }, { type: undefined, decorators: [{
441
269
  type: Optional
442
270
  }, {
443
271
  type: Inject,
444
272
  args: [FLOW_CUSTOMIZATION]
445
273
  }] }]; } });
446
274
 
447
- const findLineItem = (id, lineItems) => {
448
- return findLineItemWithComparator(lineItems, (li) => li.id === id);
275
+ const findTransactionItem = (id, items) => {
276
+ return findTransactionItemWithComparator(items, (ti) => ti.id === id);
449
277
  };
450
- const findLineItemWithComparator = (lineItems, comparator) => {
451
- let currentLevel = lineItems;
278
+ const findTransactionItemWithComparator = (items, comparator) => {
279
+ let currentLevel = items;
452
280
  while (currentLevel.length) {
453
281
  const found = currentLevel.find(comparator);
454
282
  if (found) {
455
283
  return found;
456
284
  }
457
- currentLevel = flatten(currentLevel.map(parent => parent.lineItems));
285
+ currentLevel = flatten(currentLevel.map(parent => parent.children));
458
286
  }
459
287
  return;
460
288
  };
461
- const insertLineItem = (lineItem, parentId, toInsert) => {
462
- const insertData = lineItem.id === parentId ? [toInsert] : [];
289
+ const insertTransactionItem = (item, parentId, toInsert) => {
290
+ const insertData = item.id === parentId ? [toInsert] : [];
463
291
  return {
464
- ...lineItem,
465
- lineItems: [
292
+ ...item,
293
+ children: [
466
294
  ...insertData,
467
- ...lineItem.lineItems.map(li => {
468
- return insertLineItem(li, parentId, toInsert);
295
+ ...item.children.map(ti => {
296
+ return insertTransactionItem(ti, parentId, toInsert);
469
297
  }),
470
298
  ],
471
299
  };
472
300
  };
473
- const removeLineItem = (lineItem, idToRemove) => {
301
+ const removeTransactionItem = (item, idToRemove) => {
474
302
  return {
475
- ...lineItem,
476
- lineItems: lineItem.lineItems
477
- .map(li => {
478
- if (li.id === idToRemove) {
303
+ ...item,
304
+ children: item.children
305
+ .map(ti => {
306
+ if (ti.id === idToRemove) {
479
307
  return;
480
308
  }
481
- else if (li.lineItems.length) {
482
- return removeLineItem(li, idToRemove);
309
+ else if (ti.children.length) {
310
+ return removeTransactionItem(ti, idToRemove);
483
311
  }
484
- return li;
312
+ return ti;
485
313
  })
486
- .filter(r => !!r),
314
+ .filter(isDefined),
487
315
  };
488
316
  };
489
- const replaceLineItem = (lineItem, replaceTo, skipCardinalityCalculation = false) => {
490
- if (lineItem.id === replaceTo.id) {
491
- if (!skipCardinalityCalculation) {
492
- return { ...recalculateCardinalityVariables(lineItem, replaceTo) };
493
- }
494
- else {
495
- return { ...replaceTo };
496
- }
317
+ const replaceTransactionItem = (item, replaceTo) => {
318
+ if (item.id === replaceTo.id) {
319
+ return { ...replaceTo };
497
320
  }
498
321
  return {
499
- ...lineItem,
500
- lineItems: lineItem.lineItems.map(li => replaceLineItem(li, replaceTo, skipCardinalityCalculation)),
322
+ ...item,
323
+ children: item.children.map(ti => replaceTransactionItem(ti, replaceTo)),
501
324
  };
502
325
  };
503
- const collectCardinalityComputations = (portDomains) => {
504
- const cardinalityComputations = new Map();
505
- entries(portDomains).forEach(([key, portDomain]) => {
506
- cardinalityComputations.set(key, portDomain.properties['cardinalityComputation'] === 'true');
507
- });
508
- return cardinalityComputations;
509
- };
510
- const calculateCardinalityVariables = (lineItems, cardinalityComputations) => {
511
- const cardVars = new Map();
512
- lineItems
513
- .filter(({ port, type }) => !!port && !!type)
514
- .forEach(li => {
515
- if (cardinalityComputations.get(`${li.port}`)) {
516
- const cardinalityVariableName = `#CV-${li.type}@${li.port}`;
517
- cardVars.set(cardinalityVariableName, (cardVars.get(cardinalityVariableName) ?? 0) + li.qty);
518
- }
519
- });
520
- return cardVars;
521
- };
522
- const cardinalityRegexp = new RegExp('#CV-[a-zA-Z0-9_]+@(?<portName>[a-zA-Z0-9_]+)');
523
- const recalculateCardinalityVariables = (original, updated) => {
524
- const cardinalityComputations = collectCardinalityComputations(updated.portDomains ?? original.portDomains ?? {});
525
- const cardinalityVariables = calculateCardinalityVariables(updated.lineItems, cardinalityComputations);
526
- const originalCardinalityVariables = calculateCardinalityVariables(original.lineItems, cardinalityComputations);
527
- originalCardinalityVariables.forEach((value, key) => {
528
- const execArray = cardinalityRegexp.exec(key);
529
- const portName = execArray?.groups?.['portName'];
530
- if (!portName || cardinalityComputations.get(portName)) {
531
- if (cardinalityVariables.get(key) === value) {
532
- // no need to update cardinality if no changes
533
- cardinalityVariables.delete(key);
534
- }
535
- else if (!cardinalityVariables.has(key)) {
536
- // remove last item from port
537
- cardinalityVariables.set(key, 0);
538
- }
539
- }
540
- });
541
- return {
542
- ...updated,
543
- attributes: upsertAttributes(updated.attributes, [...cardinalityVariables].map(([name, value]) => ({ name, value, cfgStatus: 'Changed' }))),
544
- };
545
- };
546
- const mapAttributes = (attributes) => {
547
- return attributes.reduce((acc, { name, value }) => ({ ...acc, [name]: value }), {});
548
- };
549
- const getAttributes = (attributes, names = []) => {
550
- const filtered = attributes.filter(({ name }) => names.includes(name));
551
- return sortBy(filtered, [({ name }) => names.indexOf(name)]);
552
- };
553
- const upsertAttributes = (originalAttributes, attributesToUpsert) => {
554
- return attributesToUpsert.reduce((acc, { name, value }) => {
555
- const [origAttr] = getAttributes(acc, [name]);
556
- return [
557
- ...acc.filter(attr => attr.name !== name),
558
- { ...(origAttr ?? { name, type: '' }), cfgStatus: origAttr ? 'Changed' : 'User', value },
559
- ];
560
- }, originalAttributes);
561
- };
562
- const patchAttributes = (rootLineItem, id, attrs, skipCardinalityCalculation = false) => {
563
- const lineItem = findLineItem(id, [rootLineItem]);
564
- if (!lineItem) {
565
- return rootLineItem;
566
- }
567
- const attributes = upsertAttributes(lineItem.attributes, attrs);
568
- return replaceLineItem(rootLineItem, { ...lineItem, attributes }, skipCardinalityCalculation);
569
- };
570
- const getAttributeValue = (attributes, name) => attributes.find(attr => attr.name === name)?.value;
571
- const generateLineItem = (port, type, parentId, attributes = [], lineItems = []) => {
326
+ const generateTransactionItem = (productId) => {
572
327
  return {
573
328
  id: UUID.UUID(),
574
- port,
575
- type,
576
- actionCode: 'ADD',
577
- cfgStatus: 'New',
578
- attributes: attributes.map(({ name, value }) => ({ cfgStatus: 'User', name, value })),
579
- lineItems,
580
- parentId,
581
- qty: 1,
329
+ productId,
582
330
  };
583
331
  };
584
- const getRecommendedPrices = (portDomain, type) => {
585
- const domainType = portDomain.domainTypes.find(({ name }) => name === type);
586
- const [net, list] = domainType?.recommendedPrices
587
- ?.filter(({ chargeMethod }) => chargeMethod === 'ONE_TIME')
588
- .reduce((acc, rp) => {
589
- const [netPrice, listPrice] = acc;
590
- return [netPrice + rp.netPrice, listPrice + rp.listPrice];
591
- }, [0, 0]) ?? [0, 0];
592
- return { net, list };
593
- };
594
- const getOriginParent = (lineItems, currentLineItem) => {
595
- let target = currentLineItem;
596
- while (target && target.rampInstanceId) {
597
- target = lineItems.find(sub => sub.id === currentLineItem.rampInstanceId);
598
- }
599
- return target;
600
- };
601
- const assetPredicateFn = (lineItem, assetId) => {
602
- if (!assetId) {
603
- return false;
604
- }
605
- return lineItem.assetId === assetId || lineItem.openOrderLineItemId === assetId;
606
- };
607
- const multiplyLineItems = (lineItem, qty, split) => {
608
- if (split) {
609
- const unifyIds = (lineItem) => ({
610
- ...lineItem,
611
- id: UUID.UUID(),
612
- lineItems: lineItem.lineItems.map(unifyIds),
613
- });
614
- return map$2(new Array(qty), () => unifyIds(lineItem));
615
- }
616
- else {
617
- return [
618
- {
619
- ...lineItem,
620
- qty: qty,
621
- },
622
- ];
623
- }
624
- };
625
- const isTechnicalAttribute = (name) => {
626
- return name.startsWith('#') || name.startsWith('$');
627
- };
628
- const filterOutTechnicalAttributes = (attributes) => {
629
- return attributes.filter(({ name }) => !isTechnicalAttribute(name));
630
- };
631
-
632
- var lineItem_utils = /*#__PURE__*/Object.freeze({
633
- __proto__: null,
634
- assetPredicateFn: assetPredicateFn,
635
- filterOutTechnicalAttributes: filterOutTechnicalAttributes,
636
- findLineItem: findLineItem,
637
- findLineItemWithComparator: findLineItemWithComparator,
638
- generateLineItem: generateLineItem,
639
- getAttributeValue: getAttributeValue,
640
- getAttributes: getAttributes,
641
- getOriginParent: getOriginParent,
642
- getRecommendedPrices: getRecommendedPrices,
643
- insertLineItem: insertLineItem,
644
- isTechnicalAttribute: isTechnicalAttribute,
645
- mapAttributes: mapAttributes,
646
- multiplyLineItems: multiplyLineItems,
647
- patchAttributes: patchAttributes,
648
- recalculateCardinalityVariables: recalculateCardinalityVariables,
649
- removeLineItem: removeLineItem,
650
- replaceLineItem: replaceLineItem,
651
- upsertAttributes: upsertAttributes
652
- });
653
332
 
654
- class LineItemWorker {
333
+ class TransactionItemWorker {
655
334
  constructor(src) {
656
- this.li = { ...src };
335
+ this.ti = { ...src };
657
336
  }
658
337
  insert(parentId, toInsert) {
659
- return new LineItemWorker(insertLineItem(this.li, parentId, toInsert));
338
+ return new TransactionItemWorker(insertTransactionItem(this.ti, parentId, toInsert));
660
339
  }
661
340
  remove(id) {
662
- return new LineItemWorker(removeLineItem(this.li, id));
341
+ return new TransactionItemWorker(removeTransactionItem(this.ti, id));
663
342
  }
664
- replace(toReplace, skipCardinalityCalculation = false) {
665
- return new LineItemWorker(replaceLineItem(this.li, toReplace, skipCardinalityCalculation));
666
- }
667
- patchAttribute(attrs, id, skipCardinalityCalculation = false) {
668
- return new LineItemWorker(patchAttributes(this.li, id ?? this.li.id, attrs, skipCardinalityCalculation));
343
+ replace(toReplace) {
344
+ return new TransactionItemWorker(replaceTransactionItem(this.ti, toReplace));
669
345
  }
670
346
  }
671
347
 
@@ -677,226 +353,125 @@ function extractMetadata(uiDefinition) {
677
353
  ]);
678
354
  }
679
355
 
680
- class FlowUpdateService {
681
- update(rootLineItems, updates, charges) {
682
- let remainingUpdates = [...updates];
683
- let currentLevel = rootLineItems;
684
- while (currentLevel.length && remainingUpdates.length) {
685
- currentLevel.forEach(li => {
686
- const unhandledUpdates = [];
687
- remainingUpdates.forEach(update => {
688
- let updated = false;
689
- switch (update.dataType) {
690
- case 'LINEITEM':
691
- updated = this.applyLineItemUpdate(li, update, charges);
692
- break;
693
- case 'CHARGE':
694
- updated = this.applyChargeUpdate(li, update);
695
- break;
696
- case 'GROUP_CHARGE':
697
- updated = this.applyChargeGroupUpdate(li, update);
698
- break;
699
- default:
700
- // Unknown dataType. Do not try to handle it anymore
701
- updated = true;
702
- }
703
- if (!updated) {
704
- unhandledUpdates.push(update);
705
- }
706
- });
707
- remainingUpdates = unhandledUpdates;
708
- });
709
- currentLevel = flatten(currentLevel.map(parent => parent.lineItems));
710
- }
711
- }
712
- delete(lineItems, id) {
713
- const idsToRemove = [id];
714
- const topLevelLineItem = lineItems.find(li => li.id === id);
715
- if (topLevelLineItem) {
716
- // find term-related line items (which are only top level)
717
- // expired term line items won't be deleted
718
- let foundTermLineItem = topLevelLineItem;
719
- while (foundTermLineItem) {
720
- foundTermLineItem = lineItems.find(li => foundTermLineItem && li.rampInstanceId === foundTermLineItem.id);
721
- if (foundTermLineItem) {
722
- idsToRemove.push(foundTermLineItem.id);
723
- }
724
- }
725
- }
726
- const filtered = lineItems.filter(lineItem => !idsToRemove.includes(lineItem.id));
727
- return filtered.map(lineItem => new LineItemWorker(lineItem).remove(id).li);
356
+ class ConfigurationService {
357
+ get state$() {
358
+ return this.configurationStateSubj$.asObservable().pipe(filter(isDefined));
728
359
  }
729
- applyLineItemUpdate(lineItem, update, charges) {
730
- if (lineItem.id !== update.id) {
731
- return false;
732
- }
733
- switch (update.attributeType) {
734
- case 'QTY':
735
- lineItem.qty = update.newValue;
736
- break;
737
- case 'EFFECTIVE_START_DATE':
738
- lineItem.properties['StartDate'] = moment(update.newValue).format('YYYY-MM-DD');
739
- break;
740
- case 'END_DATE':
741
- lineItem.properties['EndDate'] = moment(update.newValue).format('YYYY-MM-DD');
742
- break;
743
- case 'PRICE_ADJUSTMENT':
744
- {
745
- const charge = lineItem.chargeItems.find(charge => (charges || {})[charge.chargeId]?.main);
746
- if (charge) {
747
- charge.priceAdjustment = update.newValue;
748
- }
749
- }
750
- break;
751
- case 'LIST_PRICE_ADJUSTMENT':
752
- case 'MARGIN_ADJUSTMENT':
753
- {
754
- const charge = lineItem.chargeItems.find(charge => (charges || {})[charge.chargeId]?.main);
755
- if (charge) {
756
- charge.listPriceAdjustment = update.newValue;
757
- }
758
- }
759
- break;
760
- case 'COST_ADJUSTMENT':
761
- {
762
- const charge = lineItem.chargeItems.find(charge => (charges || {})[charge.chargeId]?.main);
763
- if (charge) {
764
- charge.costAdjustment = update.newValue;
765
- }
766
- }
767
- break;
768
- default:
769
- throw new Error(`Not suppored AttributeType for LineItem update: ${update.attributeType}`);
770
- }
771
- return true;
360
+ get state() {
361
+ return this.configurationStateSubj$.getValue();
772
362
  }
773
- applyChargeUpdate(lineItem, update) {
774
- const foundCharge = lineItem.chargeItems.find(({ id }) => id === update.id);
775
- if (!foundCharge) {
776
- return false;
777
- }
778
- if (update.attributeType === 'PRICE_ADJUSTMENT') {
779
- foundCharge.priceAdjustment = update.newValue;
780
- }
781
- else if (update.attributeType === 'LIST_PRICE_ADJUSTMENT') {
782
- foundCharge.listPriceAdjustment = update.newValue;
783
- }
784
- else {
785
- throw new Error(`Not suppored AttributeType for Charge Item update: ${update.attributeType}`);
786
- }
787
- return true;
363
+ get previousState() {
364
+ return this.previousConfigurationStateSubj$.getValue();
788
365
  }
789
- applyChargeGroupUpdate(lineItem, update) {
790
- const foundChargeGroup = ChargeGroupUtils.findChargeGroupById(update.id, lineItem);
791
- if (!foundChargeGroup) {
792
- return false;
793
- }
794
- if (update.attributeType === 'PRICE_ADJUSTMENT') {
795
- foundChargeGroup.priceAdjustment = update.newValue;
796
- }
797
- else if (update.attributeType === 'LIST_PRICE_ADJUSTMENT') {
798
- foundChargeGroup.listPriceAdjustment = update.newValue;
799
- }
800
- else {
801
- throw new Error(`Not suppored AttributeType for Charge Group Item update: ${update.attributeType}`);
802
- }
803
- return true;
366
+ get asset() {
367
+ return this.state?.assets[0] ?? null;
804
368
  }
805
- }
806
- FlowUpdateService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: FlowUpdateService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
807
- FlowUpdateService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: FlowUpdateService });
808
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: FlowUpdateService, decorators: [{
809
- type: Injectable
810
- }] });
811
-
812
- class FlowConfigurationService {
813
- constructor(proceduresApiService,
814
- // private quoteDraftService: QuoteDraftService,
815
- salesTransactionService, updateService, configurationService, flowInfoService) {
816
- this.proceduresApiService = proceduresApiService;
817
- this.salesTransactionService = salesTransactionService;
818
- this.updateService = updateService;
819
- this.configurationService = configurationService;
820
- this.flowInfoService = flowInfoService;
821
- this.updatedSubj$ = new Subject();
822
- this.updated$ = this.updatedSubj$.asObservable();
369
+ get root$() {
370
+ return this.state$.pipe(map$1(state => state.salesTransactionItems[0]), filter(isDefined));
823
371
  }
824
- calculate$(state) {
825
- return this.proceduresApiService.apply$({ salesTransaction: state }).pipe(tap$1(result => this.salesTransactionService.setState(result.salesTransaction)), map$1(noop));
372
+ get root() {
373
+ return this.configurationStateSubj$.getValue()?.salesTransactionItems[0] ?? null;
826
374
  }
827
- calculate(state) {
828
- this.calculate$(state).subscribe();
375
+ constructor(flowInfoService, messageService, configurationRuntimeService, salesTransactionService, proceduresApiService) {
376
+ this.flowInfoService = flowInfoService;
377
+ this.messageService = messageService;
378
+ this.configurationRuntimeService = configurationRuntimeService;
379
+ this.salesTransactionService = salesTransactionService;
380
+ this.proceduresApiService = proceduresApiService;
381
+ this.hasUnsavedChanges = false;
382
+ this.configurationStateSubj$ = new BehaviorSubject(null);
383
+ this.previousConfigurationStateSubj$ = new BehaviorSubject(null);
384
+ this.isLoadingSubj$ = new BehaviorSubject(false);
385
+ this.isLoading$ = this.isLoadingSubj$.asObservable();
829
386
  }
830
- revert$(lineItemId) {
831
- const state = this.salesTransactionService.state;
832
- const initialCurrentState = this.salesTransactionService.getInitialCurrentState();
833
- const currentState = state?.salesTransactionItems ?? [];
834
- const currentLineItemIndex = currentState.findIndex(({ id }) => id === lineItemId);
835
- const currentLineItem = currentState[currentLineItemIndex];
836
- const initialLineItem = initialCurrentState.find(({ integrationId }) => integrationId === currentLineItem?.integrationId);
837
- if (!state || !currentLineItem || !initialLineItem) {
838
- return of(null);
839
- }
840
- const updatedState = cloneDeep(currentState);
841
- updatedState.splice(currentLineItemIndex, 1, initialLineItem);
842
- return of([]).pipe(tap$1(() => {
843
- this.salesTransactionService.setState({ ...state, salesTransactionItems: updatedState });
844
- }), switchMap(() => this.calculate$({ ...state, salesTransactionItems: updatedState })), map$1(() => this.salesTransactionService.state), tap$1(() => this.updatedSubj$.next()), this.handleErrorAndBounceBack());
387
+ reset() {
388
+ this.hasUnsavedChanges = false;
389
+ this.configurationStateSubj$.next(null);
390
+ this.previousConfigurationStateSubj$.next(null);
845
391
  }
846
- revert(lineItemId) {
847
- this.revert$(lineItemId).subscribe();
392
+ init$() {
393
+ const { state } = this.salesTransactionService;
394
+ const { productId, transactionItemId } = this.flowInfoService.context;
395
+ if (!state) {
396
+ return of(undefined);
397
+ }
398
+ let transactionItem = state?.salesTransactionItems.find(item => item.id === transactionItemId);
399
+ if (!transactionItem) {
400
+ transactionItem = state.salesTransactionItems.find(item => item.productId === productId);
401
+ }
402
+ const assetItem = transactionItem ? state?.assets.find(item => item.id === transactionItem?.assetId) : undefined;
403
+ const configurationState = {
404
+ ...state,
405
+ salesTransactionItems: transactionItem ? [transactionItem] : [],
406
+ assets: assetItem ? [assetItem] : [],
407
+ };
408
+ this.configurationStateSubj$.next(configurationState);
409
+ this.previousConfigurationStateSubj$.next(configurationState);
410
+ return of(undefined);
848
411
  }
849
- delete$(ids) {
850
- const state = this.salesTransactionService.state;
412
+ patch$(transactionItem) {
413
+ const { state, root } = this;
851
414
  if (!state) {
852
- return of(null);
415
+ return throwError(() => new Error(`Configuration State is not initialized`));
416
+ }
417
+ if (!root) {
418
+ return throwError(() => new Error(`Root SalesTransactionItem not found`));
853
419
  }
854
- return of([]).pipe(map$1(() => state.salesTransactionItems.filter(({ id }) => !ids.includes(id))), switchMap(updatedState => this.calculate$({ ...state, salesTransactionItems: updatedState })), map$1(() => this.salesTransactionService.state), tap$1(() => this.updatedSubj$.next()), this.handleErrorAndBounceBack());
420
+ const newRoot = new TransactionItemWorker(root).replace(transactionItem).ti;
421
+ const newSalesTransaction = {
422
+ ...state,
423
+ salesTransactionItems: [newRoot],
424
+ };
425
+ return this.configureRequest$(newSalesTransaction).pipe(catchError(error => {
426
+ console.error(error);
427
+ if (!this.configurationRuntimeService.uiDefinitionProps.suppressToastMessages) {
428
+ this.messageService.add({ severity: 'error', summary: error });
429
+ }
430
+ return throwError(() => error);
431
+ }), tap$1(() => {
432
+ if (!this.hasUnsavedChanges) {
433
+ this.hasUnsavedChanges = true;
434
+ }
435
+ }), map$1(noop));
855
436
  }
856
- delete(ids) {
857
- this.delete$(ids).subscribe();
437
+ patch(transactionItem) {
438
+ this.patch$(transactionItem).subscribe();
858
439
  }
859
- addTerm$(term) {
860
- // TODO: implement
861
- return of(this.salesTransactionService.state);
440
+ configureRequest$(salesTransaction) {
441
+ const request = {
442
+ salesTransaction,
443
+ };
444
+ this.isLoadingSubj$.next(true);
445
+ return this.proceduresApiService.apply$(request).pipe(tap$1(result => {
446
+ const newState = result.salesTransaction;
447
+ this.configurationStateSubj$.next(newState);
448
+ this.previousConfigurationStateSubj$.next(cloneDeep(newState));
449
+ }), map$1(response => response.salesTransaction), catchError(error => throwError(() => {
450
+ const resetState = this.previousConfigurationStateSubj$.getValue();
451
+ if (resetState) {
452
+ this.previousConfigurationStateSubj$.next(cloneDeep(resetState));
453
+ this.configurationStateSubj$.next(resetState);
454
+ }
455
+ if (error.error) {
456
+ return extractErrorDetails(error.error).join('. ');
457
+ }
458
+ return error.message || JSON.stringify(error);
459
+ })), finalize(() => this.isLoadingSubj$.next(false)));
862
460
  }
863
- addToCart$(props) {
461
+ configureExternal$(props) {
864
462
  // TODO: implement
865
- return of(this.salesTransactionService.state);
463
+ throw new Error('Not implemented');
866
464
  }
867
- handleErrorAndBounceBack() {
868
- return (source$) => {
869
- return source$.pipe(catchError(error => {
870
- console.error(error);
871
- // bounce back if configuration call has failed
872
- const state = this.salesTransactionService.state;
873
- if (state) {
874
- this.salesTransactionService.setState(state);
875
- this.updatedSubj$.next();
876
- }
877
- return throwError(() => error);
878
- }));
879
- };
465
+ configureGuidedSelling$(data) {
466
+ // TODO: implement
467
+ throw new Error('Not implemented');
880
468
  }
881
469
  }
882
- FlowConfigurationService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: FlowConfigurationService, deps: [{ token: i2.ProceduresApiService }, { token: SalesTransactionService }, { token: FlowUpdateService }, { token: ConfigurationService }, { token: FlowInfoService }], target: i0.ɵɵFactoryTarget.Injectable });
883
- FlowConfigurationService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: FlowConfigurationService });
884
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: FlowConfigurationService, decorators: [{
470
+ ConfigurationService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: ConfigurationService, deps: [{ token: FlowInfoService }, { token: i2.MessageService }, { token: ConfigurationRuntimeService }, { token: SalesTransactionService }, { token: i4.ProceduresApiService }], target: i0.ɵɵFactoryTarget.Injectable });
471
+ ConfigurationService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: ConfigurationService });
472
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: ConfigurationService, decorators: [{
885
473
  type: Injectable
886
- }], ctorParameters: function () { return [{ type: i2.ProceduresApiService }, { type: SalesTransactionService }, { type: FlowUpdateService }, { type: ConfigurationService }, { type: FlowInfoService }]; } });
887
-
888
- class FlowConfigurationModule {
889
- }
890
- FlowConfigurationModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: FlowConfigurationModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
891
- FlowConfigurationModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "15.2.9", ngImport: i0, type: FlowConfigurationModule, imports: [ApiModule] });
892
- FlowConfigurationModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: FlowConfigurationModule, providers: [FlowConfigurationService, FlowUpdateService], imports: [ApiModule] });
893
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: FlowConfigurationModule, decorators: [{
894
- type: NgModule,
895
- args: [{
896
- imports: [ApiModule],
897
- providers: [FlowConfigurationService, FlowUpdateService],
898
- }]
899
- }] });
474
+ }], ctorParameters: function () { return [{ type: FlowInfoService }, { type: i2.MessageService }, { type: ConfigurationRuntimeService }, { type: SalesTransactionService }, { type: i4.ProceduresApiService }]; } });
900
475
 
901
476
  class SalesTransactionService {
902
477
  get isInitialized$() {
@@ -908,7 +483,7 @@ class SalesTransactionService {
908
483
  set hasUnsavedChanges(value) {
909
484
  this.hasUnsavedChangesSubj$.next(value);
910
485
  if (!this.hasUnsavedChanges) {
911
- this.initialCurrentState = this.state?.salesTransactionItems ?? [];
486
+ this.initialState = this.state?.salesTransactionItems ?? [];
912
487
  }
913
488
  }
914
489
  get hasUnsavedChanges() {
@@ -917,18 +492,24 @@ class SalesTransactionService {
917
492
  get state() {
918
493
  return this.stateSubj$.getValue();
919
494
  }
495
+ get hasAssets() {
496
+ return Boolean(this.state?.assets.length);
497
+ }
498
+ get hasProducts() {
499
+ return Boolean(this.state?.salesTransactionItems.length);
500
+ }
920
501
  constructor(flowInfoService, salesTransactionApiService) {
921
502
  this.flowInfoService = flowInfoService;
922
503
  this.salesTransactionApiService = salesTransactionApiService;
923
504
  this.stateSubj$ = new BehaviorSubject(null);
924
505
  this.isInitializedSubj$ = new BehaviorSubject(false);
925
506
  this.hasUnsavedChangesSubj$ = new BehaviorSubject(false);
926
- this.initialCurrentState = [];
507
+ this.initialState = [];
927
508
  this.hasUnsavedChanges$ = this.hasUnsavedChangesSubj$.asObservable();
928
- this.state$ = this.stateSubj$.asObservable().pipe(filter(isDefined));
509
+ this.state$ = this.stateSubj$.asObservable().pipe(filter$1(isDefined));
929
510
  }
930
511
  init(headerId, params) {
931
- return this.salesTransactionApiService.getState(headerId, params).pipe(tap$1(res => this.stateSubj$.next(res.salesTransaction)), map$1(res => res.salesTransaction));
512
+ return this.salesTransactionApiService.getState(headerId, params).pipe(tap(res => this.stateSubj$.next(res.salesTransaction)), map(res => res.salesTransaction));
932
513
  }
933
514
  finalizeInit() {
934
515
  this.isInitializedSubj$.next(true);
@@ -939,27 +520,90 @@ class SalesTransactionService {
939
520
  this.isInitializedSubj$.next(false);
940
521
  this.hasUnsavedChangesSubj$.next(false);
941
522
  }
942
- getInitialCurrentState() {
943
- return this.initialCurrentState;
523
+ getInitialState() {
524
+ return this.initialState;
944
525
  }
945
526
  setState(state) {
946
527
  this.stateSubj$.next(state);
947
528
  }
948
529
  }
949
- SalesTransactionService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: SalesTransactionService, deps: [{ token: FlowInfoService }, { token: i2.SalesTransactionApiService }], target: i0.ɵɵFactoryTarget.Injectable });
530
+ SalesTransactionService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: SalesTransactionService, deps: [{ token: FlowInfoService }, { token: i4.SalesTransactionApiService }], target: i0.ɵɵFactoryTarget.Injectable });
950
531
  SalesTransactionService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: SalesTransactionService });
951
532
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: SalesTransactionService, decorators: [{
952
533
  type: Injectable
953
- }], ctorParameters: function () { return [{ type: FlowInfoService }, { type: i2.SalesTransactionApiService }]; } });
534
+ }], ctorParameters: function () { return [{ type: FlowInfoService }, { type: i4.SalesTransactionApiService }]; } });
954
535
 
955
- class FlowStateService {
956
- constructor(salesTransactionService, flowInfoService, flowConfiguration, processorsApiService, flowStateApiService, salesTransactionApiService, toastService, customizationService) {
536
+ class FlowConfigurationService {
537
+ constructor(proceduresApiService, salesTransactionService) {
538
+ this.proceduresApiService = proceduresApiService;
957
539
  this.salesTransactionService = salesTransactionService;
958
- this.flowInfoService = flowInfoService;
540
+ this.updatedSubj$ = new Subject();
541
+ this.updated$ = this.updatedSubj$.asObservable();
542
+ }
543
+ calculate$(state) {
544
+ return this.proceduresApiService.apply$({ salesTransaction: state }).pipe(tap(result => this.salesTransactionService.setState(result.salesTransaction)), map(noop));
545
+ }
546
+ calculate(state) {
547
+ this.calculate$(state).subscribe();
548
+ }
549
+ revert$(transactionItemId) {
550
+ const state = this.salesTransactionService.state;
551
+ const initialState = this.salesTransactionService.getInitialState();
552
+ const currentState = state?.salesTransactionItems ?? [];
553
+ const currentItemIndex = currentState.findIndex(({ id }) => id === transactionItemId);
554
+ const currentItem = currentState[currentItemIndex];
555
+ const initialItem = initialState.find(({ integrationId }) => integrationId === currentItem?.integrationId);
556
+ if (!state || !currentItem || !initialItem) {
557
+ return of(null);
558
+ }
559
+ const updatedState = cloneDeep(currentState);
560
+ updatedState.splice(currentItemIndex, 1, initialItem);
561
+ return of([]).pipe(tap(() => {
562
+ this.salesTransactionService.setState({ ...state, salesTransactionItems: updatedState });
563
+ }), switchMap(() => this.calculate$({ ...state, salesTransactionItems: updatedState })), map(() => this.salesTransactionService.state), tap(() => this.updatedSubj$.next()), this.handleErrorAndBounceBack());
564
+ }
565
+ revert(transactionItemId) {
566
+ this.revert$(transactionItemId).subscribe();
567
+ }
568
+ delete$(ids) {
569
+ const state = this.salesTransactionService.state;
570
+ if (!state) {
571
+ return of(null);
572
+ }
573
+ return of([]).pipe(map(() => state.salesTransactionItems.filter(({ id }) => !ids.includes(id))), switchMap(updatedState => this.calculate$({ ...state, salesTransactionItems: updatedState })), map(() => this.salesTransactionService.state), tap(() => this.updatedSubj$.next()), this.handleErrorAndBounceBack());
574
+ }
575
+ delete(ids) {
576
+ this.delete$(ids).subscribe();
577
+ }
578
+ handleErrorAndBounceBack() {
579
+ return (source$) => {
580
+ return source$.pipe(catchError$1(error => {
581
+ console.error(error);
582
+ // bounce back if configuration call has failed
583
+ const state = this.salesTransactionService.state;
584
+ if (state) {
585
+ this.salesTransactionService.setState(state);
586
+ this.updatedSubj$.next();
587
+ }
588
+ return throwError(() => error);
589
+ }));
590
+ };
591
+ }
592
+ }
593
+ FlowConfigurationService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: FlowConfigurationService, deps: [{ token: i4.ProceduresApiService }, { token: SalesTransactionService }], target: i0.ɵɵFactoryTarget.Injectable });
594
+ FlowConfigurationService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: FlowConfigurationService });
595
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: FlowConfigurationService, decorators: [{
596
+ type: Injectable
597
+ }], ctorParameters: function () { return [{ type: i4.ProceduresApiService }, { type: SalesTransactionService }]; } });
598
+
599
+ class FlowStateService {
600
+ constructor(flowConfiguration, flowInfoService, flowStateApiService, processorsApiService, salesTransactionApiService, salesTransactionService, toastService, customizationService) {
959
601
  this.flowConfiguration = flowConfiguration;
960
- this.processorsApiService = processorsApiService;
602
+ this.flowInfoService = flowInfoService;
961
603
  this.flowStateApiService = flowStateApiService;
604
+ this.processorsApiService = processorsApiService;
962
605
  this.salesTransactionApiService = salesTransactionApiService;
606
+ this.salesTransactionService = salesTransactionService;
963
607
  this.toastService = toastService;
964
608
  this.customizationService = customizationService;
965
609
  this.NOT_INITIALIZED = Symbol();
@@ -980,44 +624,18 @@ class FlowStateService {
980
624
  all subscriptions get their updates according to updated QuoteDraft
981
625
  */
982
626
  this.isInitialized$()
983
- .pipe(filter(Boolean), filter(() => !this.getFlowSafe().properties.stateful), switchMap(() => this.flowConfiguration.updated$), switchMap(() => this.executeRequest$({}, true)))
627
+ .pipe(filter$1(Boolean), filter$1(() => !this.flowInfoService.flow.properties.stateful), switchMap(() => this.flowConfiguration.updated$), switchMap(() => this.executeRequest$({}, true)))
984
628
  .subscribe();
985
- this.charges$ = this.flowInfoService.isFlowEngineInitialized$.pipe(filter(Boolean), switchMap(() => {
986
- return this.subscribe$(UITemplateType.FLOW_ENGINE, 'CHARGES', null, {
987
- cold: true,
988
- }).pipe(map$1(response => (response.success ? response.result : {})));
989
- }), shareReplay(1));
990
- this.charges$.subscribe();
991
- this.pricePlans$ = this.flowInfoService.isFlowEngineInitialized$.pipe(filter(Boolean), switchMap(() => {
992
- return this.subscribe$(UITemplateType.FLOW_ENGINE, 'PRICE_PLANS', null, {
993
- cold: true,
994
- }).pipe(map$1(response => (response.success ? response.result : {})));
995
- }), shareReplay(1));
996
- this.pricePlans$.subscribe();
997
- this.activeMetrics$ = this.flowInfoService.isFlowEngineInitialized$.pipe(filter(Boolean), switchMap(() => {
998
- return this.subscribe$(UITemplateType.FLOW_ENGINE, 'ACTIVE_METRICS', null, {
999
- cold: true,
1000
- }).pipe(map$1(response => (response.success ? response.result : [])));
1001
- }), shareReplay(1));
1002
- this.activeMetrics$.subscribe();
1003
- this.isPriceListLocked$ = this.flowInfoService.isFlowEngineInitialized$.pipe(filter(Boolean), switchMap(() => {
1004
- return this.subscribe$(UITemplateType.FLOW_ENGINE, 'IS_PRICE_LIST_LOCKED', null, {
1005
- cold: true,
1006
- }).pipe(map$1(response => (response.success ? response.result : false)));
1007
- }), shareReplay(1));
1008
- this.isPriceListLocked$.subscribe();
1009
629
  }
1010
630
  init$() {
1011
- return this.initProcessors$().pipe(switchMap(() => {
1012
- if (this.getFlowSafe().properties.stateful) {
1013
- return this.initStateful$();
1014
- }
1015
- else {
1016
- return this.initStateless$();
1017
- }
1018
- }));
631
+ if (this.flowInfoService.flow.properties.stateful) {
632
+ return this.initProcessors$().pipe(switchMap(() => this.initStateful$()));
633
+ }
634
+ else {
635
+ return forkJoin([this.initStateless$(), this.initProcessors$()]).pipe(map(noop));
636
+ }
1019
637
  }
1020
- cleanup() {
638
+ reset() {
1021
639
  Object.values(this.subscriptions).forEach(({ data$ }) => data$.complete());
1022
640
  this.subscriptions = {};
1023
641
  if (this.stateId$.value) {
@@ -1029,7 +647,7 @@ class FlowStateService {
1029
647
  this.cleanup$.next();
1030
648
  }
1031
649
  get hasUnsavedChanges() {
1032
- return this.getFlowSafe().properties.stateful
650
+ return this.flowInfoService.flow.properties.stateful
1033
651
  ? Array.from(this.trackedStatefulChangesMap.values()).some(Boolean)
1034
652
  : this.salesTransactionService.hasUnsavedChanges;
1035
653
  }
@@ -1040,14 +658,14 @@ class FlowStateService {
1040
658
  return this.executionInProgress$.asObservable();
1041
659
  }
1042
660
  isInitialized$() {
1043
- return combineLatest([this.stateId$, this.salesTransactionService.isInitialized$]).pipe(map$1(values => values.some(Boolean)));
661
+ return combineLatest([this.stateId$, this.salesTransactionService.isInitialized$]).pipe(map(values => values.some(Boolean)));
1044
662
  }
1045
663
  isInitialized() {
1046
664
  return Boolean(this.stateId$.value) || this.salesTransactionService.isInitialized;
1047
665
  }
1048
666
  execute$(scope, exec) {
1049
667
  const request = this.execToRequest(scope, exec);
1050
- return this.executeRequest$(request).pipe(map$1(result => {
668
+ return this.executeRequest$(request).pipe(map(result => {
1051
669
  // Keep only requested results
1052
670
  const actualSelectors = Object.entries(result.selectors).reduce((trunk, [requestId, result]) => {
1053
671
  if (exec.selectors?.[requestId]) {
@@ -1063,7 +681,7 @@ class FlowStateService {
1063
681
  actions: [{ name: action, inputData }],
1064
682
  };
1065
683
  const request = this.execToRequest(scope, exec);
1066
- return this.executeRequest$(request).pipe(map$1(noop));
684
+ return this.executeRequest$(request).pipe(map(noop));
1067
685
  }
1068
686
  select$(scope, selectorName, inputData) {
1069
687
  const requestId = this.generateRequestId(scope, selectorName, inputData);
@@ -1075,7 +693,7 @@ class FlowStateService {
1075
693
  },
1076
694
  },
1077
695
  });
1078
- return this.executeRequest$(request).pipe(map$1(response => response.selectors[requestId]));
696
+ return this.executeRequest$(request).pipe(map(response => response.selectors[requestId]));
1079
697
  }
1080
698
  subscribe$(scope, selectorName, inputData, options) {
1081
699
  const requestId = this.generateRequestId(scope, selectorName, inputData);
@@ -1101,16 +719,16 @@ class FlowStateService {
1101
719
  this.executeRequest$(request).subscribe();
1102
720
  }
1103
721
  }
1104
- return subscription.data$.pipe(filter(data => data != this.NOT_INITIALIZED), map$1(data => data), finalize(() => {
722
+ return subscription.data$.pipe(filter$1(data => data != this.NOT_INITIALIZED), map(data => data), finalize$1(() => {
1105
723
  if (!this.subscriptions[requestId]?.data$.observed) {
1106
724
  delete this.subscriptions[requestId];
1107
725
  }
1108
726
  }));
1109
727
  }
1110
728
  save$() {
1111
- if (this.getFlowSafe().properties.stateful) {
729
+ if (this.flowInfoService.flow.properties.stateful) {
1112
730
  if (this.stateId$.value) {
1113
- return this.flowStateApiService.save(this.stateId$.value).pipe(map$1(({ quoteId }) => ({ id: quoteId })), tap$1(() => {
731
+ return this.flowStateApiService.save(this.stateId$.value).pipe(map(({ quoteId }) => ({ id: quoteId })), tap(() => {
1114
732
  Array.from(this.trackedStatefulChangesMap.keys()).forEach(key => {
1115
733
  this.trackedStatefulChangesMap.set(key, false);
1116
734
  });
@@ -1126,9 +744,9 @@ class FlowStateService {
1126
744
  return of({ id: '' });
1127
745
  }
1128
746
  submit$() {
1129
- if (this.getFlowSafe().properties.stateful) {
747
+ if (this.flowInfoService.flow.properties.stateful) {
1130
748
  if (this.stateId$.value) {
1131
- return this.flowStateApiService.submit(this.stateId$.value).pipe(map$1(({ quoteId }) => ({ id: quoteId })));
749
+ return this.flowStateApiService.submit(this.stateId$.value).pipe(map(({ quoteId }) => ({ id: quoteId })));
1132
750
  }
1133
751
  }
1134
752
  else {
@@ -1175,10 +793,10 @@ class FlowStateService {
1175
793
  fullRequest.selectors = assign(fullRequest.selectors, subscription.request.selectors);
1176
794
  }
1177
795
  }
1178
- const execution$ = this.getFlowSafe().properties.stateful
796
+ const execution$ = this.flowInfoService.flow.properties.stateful
1179
797
  ? this.executeStateful$(fullRequest)
1180
798
  : this.executeStateless$(fullRequest);
1181
- return execution$.pipe(tap$1(result => this.handleSelectorsResponse(result.selectors)));
799
+ return execution$.pipe(tap(result => this.handleSelectorsResponse(result.selectors)));
1182
800
  }
1183
801
  handleSelectorsResponse(selectors) {
1184
802
  Object.entries(selectors).forEach(([requestId, selectorResult]) => {
@@ -1207,7 +825,7 @@ class FlowStateService {
1207
825
  selectorsOverride: processors?.filter(processor => processor.type === ConfigurationProcessorTypes.SELECTOR),
1208
826
  selectors: selectors,
1209
827
  })
1210
- .pipe(map$1(({ stateId, selectors }) => {
828
+ .pipe(map(({ stateId, selectors }) => {
1211
829
  this.handleSelectorsResponse(selectors);
1212
830
  this.stateId$.next(stateId);
1213
831
  }));
@@ -1227,30 +845,30 @@ class FlowStateService {
1227
845
  };
1228
846
  this.executionInProgress$.next(true);
1229
847
  return this.flowStateApiService.execute(this.stateId$.value, request);
1230
- }), tap$1(({ stateId }) => this.stateId$.next(stateId)), share(), tap$1(() => this.executionInProgress$.next(false)), catchError(e => {
848
+ }), tap(({ stateId }) => this.stateId$.next(stateId)), share(), tap(() => this.executionInProgress$.next(false)), catchError$1(e => {
1231
849
  this.executionInProgress$.next(false);
1232
850
  return throwError(() => e);
1233
851
  }));
1234
852
  }
1235
853
  executeStateful$(request) {
1236
- return this.executionInProgress$.pipe(filter(inProgress => !inProgress), take(1), switchMap(() =>
854
+ return this.executionInProgress$.pipe(filter$1(inProgress => !inProgress), take(1), switchMap(() =>
1237
855
  // make sure stream switches to statefulExecutionRequest$ before pushing an execution request
1238
856
  combineLatest([
1239
857
  this.statefulExecutionRequest$,
1240
- of(undefined).pipe(tap$1(() => this.statefulRequestStream$.next(request))),
1241
- ])), map$1(([response]) => response), take(1));
858
+ of(undefined).pipe(tap(() => this.statefulRequestStream$.next(request))),
859
+ ])), map(([response]) => response), take(1));
1242
860
  }
1243
861
  initStateless$() {
1244
- return this.salesTransactionService.init(this.flowInfoService.context.headerId, this.flowInfoService.context).pipe(tap$1(() => {
862
+ return this.salesTransactionService.init(this.flowInfoService.context.headerId, this.flowInfoService.context).pipe(tap(() => {
1245
863
  const assets = this.salesTransactionService.state?.assets;
1246
864
  if (assets) {
1247
865
  this.flowStore = { ...this.flowStore, assets };
1248
866
  }
1249
- }), switchMap(state => this.flowConfiguration.calculate$(state)), tap$1(() => this.salesTransactionService.finalizeInit()), map$1(noop));
867
+ }), switchMap(state => this.flowConfiguration.calculate$(state)), tap(() => this.salesTransactionService.finalizeInit()), map(noop));
1250
868
  }
1251
869
  executeStateless$(request) {
1252
870
  this.executionInProgress$.next(true);
1253
- return of(undefined).pipe(tap$1(() => this.executeStatelessActions(request)), switchMap(() => {
871
+ return of(undefined).pipe(tap(() => this.executeStatelessActions(request)), switchMap(() => {
1254
872
  /*
1255
873
  Skip price calculation in case
1256
874
  1. No actions in the request
@@ -1263,7 +881,7 @@ class FlowStateService {
1263
881
  else {
1264
882
  return this.flowConfiguration.calculate$(state);
1265
883
  }
1266
- }), map$1(() => this.executeStatelessSelectors(request)), tap$1(() => this.executionInProgress$.next(false)), catchError(e => {
884
+ }), map(() => this.executeStatelessSelectors(request)), tap(() => this.executionInProgress$.next(false)), catchError$1(e => {
1267
885
  this.executionInProgress$.next(false);
1268
886
  return throwError(() => e);
1269
887
  }));
@@ -1308,16 +926,9 @@ class FlowStateService {
1308
926
  return result;
1309
927
  }, { stateId: '', selectors: {} });
1310
928
  }
1311
- getFlowSafe() {
1312
- if (!this.flowInfoService.flow) {
1313
- throw 'Flow is not defined';
1314
- }
1315
- return this.flowInfoService.flow;
1316
- }
1317
929
  initProcessors$() {
1318
930
  const hasOverrides = Boolean(this.customizationService?.getTemplateConfigurationProcessors);
1319
- const flow = this.getFlowSafe();
1320
- if (flow.properties.stateful && !hasOverrides) {
931
+ if (this.flowInfoService.flow.properties.stateful && !hasOverrides) {
1321
932
  // Skip initialization as backend will take processors from SF
1322
933
  return of(undefined);
1323
934
  }
@@ -1327,7 +938,7 @@ class FlowStateService {
1327
938
  return;
1328
939
  }
1329
940
  const localProcessors$ = this.customizationService?.getTemplateConfigurationProcessors?.(template.name) ?? of(null);
1330
- return localProcessors$.pipe(switchMap(processors => processors ? of(processors) : this.processorsApiService.fetchConfigurationProcessors$(template.id)), tap$1(processors => {
941
+ return localProcessors$.pipe(switchMap(processors => processors ? of(processors) : this.processorsApiService.fetchConfigurationProcessors$(template.id)), tap(processors => {
1331
942
  const processorsMap = processors.reduce((acc, p) => {
1332
943
  acc[p.apiName] = p;
1333
944
  return acc;
@@ -1339,7 +950,7 @@ class FlowStateService {
1339
950
  if (!owners$.length) {
1340
951
  return of(undefined);
1341
952
  }
1342
- return forkJoin(owners$).pipe(map$1(noop));
953
+ return forkJoin(owners$).pipe(map(noop));
1343
954
  }
1344
955
  executeActionScript(request, executable) {
1345
956
  const configurationProcessor = this.processors[executable.ownerId]?.[executable.apiName];
@@ -1388,11 +999,11 @@ class FlowStateService {
1388
999
  }
1389
1000
  }
1390
1001
  }
1391
- FlowStateService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: FlowStateService, deps: [{ token: SalesTransactionService }, { token: FlowInfoService }, { token: FlowConfigurationService }, { token: i2.ConfigurationProcessorsApiService }, { token: i1.FlowStateApiService }, { token: i2.SalesTransactionApiService }, { token: i6.ToastService }, { token: FLOW_CUSTOMIZATION, optional: true }], target: i0.ɵɵFactoryTarget.Injectable });
1002
+ FlowStateService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: FlowStateService, deps: [{ token: FlowConfigurationService }, { token: FlowInfoService }, { token: i1.FlowStateApiService }, { token: i4.ConfigurationProcessorsApiService }, { token: i4.SalesTransactionApiService }, { token: SalesTransactionService }, { token: i6.ToastService }, { token: FLOW_CUSTOMIZATION, optional: true }], target: i0.ɵɵFactoryTarget.Injectable });
1392
1003
  FlowStateService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: FlowStateService });
1393
1004
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: FlowStateService, decorators: [{
1394
1005
  type: Injectable
1395
- }], ctorParameters: function () { return [{ type: SalesTransactionService }, { type: FlowInfoService }, { type: FlowConfigurationService }, { type: i2.ConfigurationProcessorsApiService }, { type: i1.FlowStateApiService }, { type: i2.SalesTransactionApiService }, { type: i6.ToastService }, { type: undefined, decorators: [{
1006
+ }], ctorParameters: function () { return [{ type: FlowConfigurationService }, { type: FlowInfoService }, { type: i1.FlowStateApiService }, { type: i4.ConfigurationProcessorsApiService }, { type: i4.SalesTransactionApiService }, { type: SalesTransactionService }, { type: i6.ToastService }, { type: undefined, decorators: [{
1396
1007
  type: Optional
1397
1008
  }, {
1398
1009
  type: Inject,
@@ -1400,15 +1011,9 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImpor
1400
1011
  }] }]; } });
1401
1012
 
1402
1013
  class FlowStateConfigurationService {
1403
- constructor(flowInfoService, flowConfigurationService, flowStateApiService, flowStateService) {
1014
+ constructor(flowInfoService, flowStateService) {
1404
1015
  this.flowInfoService = flowInfoService;
1405
- this.flowConfigurationService = flowConfigurationService;
1406
- this.flowStateApiService = flowStateApiService;
1407
1016
  this.flowStateService = flowStateService;
1408
- this.configurationStateId$ = new BehaviorSubject(null);
1409
- }
1410
- get configurationStateId() {
1411
- return this.configurationStateId$.value;
1412
1017
  }
1413
1018
  addToCart$(props) {
1414
1019
  let request$;
@@ -1419,26 +1024,22 @@ class FlowStateConfigurationService {
1419
1024
  request$ = of();
1420
1025
  }
1421
1026
  else {
1422
- const lineItem = generateConfigurationLineItem(props, props.qty);
1423
- request$ = this.flowStateApiService.newConfiguration(stateId, { lineItem }).pipe(tap$1(r => this.configurationStateId$.next(r.stateId)), switchMap(() => {
1424
- if (!this.configurationStateId) {
1425
- return of();
1426
- }
1427
- return this.flowStateApiService.saveConfiguration(stateId, this.configurationStateId).pipe(tap$1(() => this.configurationStateId$.next(null)), map$1(noop));
1428
- }));
1027
+ // TODO: Implement
1028
+ request$ = of();
1429
1029
  }
1430
1030
  }
1431
1031
  else {
1432
- request$ = this.flowConfigurationService.addToCart$(props).pipe(map$1(noop));
1032
+ // TODO: Implement
1033
+ request$ = of();
1433
1034
  }
1434
- return request$.pipe(switchMap(() => this.flowStateService.executeRequest$({}, true)), map$1(noop));
1035
+ return request$.pipe(switchMap(() => this.flowStateService.executeRequest$({}, true)), map(noop));
1435
1036
  }
1436
1037
  }
1437
- FlowStateConfigurationService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: FlowStateConfigurationService, deps: [{ token: FlowInfoService }, { token: FlowConfigurationService }, { token: i1.FlowStateApiService }, { token: FlowStateService }], target: i0.ɵɵFactoryTarget.Injectable });
1038
+ FlowStateConfigurationService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: FlowStateConfigurationService, deps: [{ token: FlowInfoService }, { token: FlowStateService }], target: i0.ɵɵFactoryTarget.Injectable });
1438
1039
  FlowStateConfigurationService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: FlowStateConfigurationService });
1439
1040
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: FlowStateConfigurationService, decorators: [{
1440
1041
  type: Injectable
1441
- }], ctorParameters: function () { return [{ type: FlowInfoService }, { type: FlowConfigurationService }, { type: i1.FlowStateApiService }, { type: FlowStateService }]; } });
1042
+ }], ctorParameters: function () { return [{ type: FlowInfoService }, { type: FlowStateService }]; } });
1442
1043
 
1443
1044
  class IntegrationState {
1444
1045
  constructor() {
@@ -1458,12 +1059,12 @@ class IntegrationState {
1458
1059
  this.action$.next(action);
1459
1060
  }
1460
1061
  listen$(actionType) {
1461
- return this.action$.pipe(filter(action => action.type === actionType), map$1(action => action.payload));
1062
+ return this.action$.pipe(filter$1(action => action.type === actionType), map(action => action.payload));
1462
1063
  }
1463
1064
  listenAll$() {
1464
1065
  return this.action$.asObservable();
1465
1066
  }
1466
- clear() {
1067
+ reset() {
1467
1068
  this.stateSubj$.next({});
1468
1069
  }
1469
1070
  }
@@ -1483,12 +1084,12 @@ class ProductImagesService {
1483
1084
  this.imagesMap$.next({ ...this.imagesMap$.value, [productId]: '' });
1484
1085
  this.fetchProductImage(productId);
1485
1086
  }
1486
- return this.imagesMap$.pipe(map$1(imagesMap => imagesMap[productId] ?? null), distinctUntilChanged());
1087
+ return this.imagesMap$.pipe(map(imagesMap => imagesMap[productId] ?? null), distinctUntilChanged());
1487
1088
  }
1488
1089
  fetchProductImage(productId) {
1489
1090
  this.productApiService
1490
1091
  .fetchImage$(productId)
1491
- .pipe(map$1(file => URL.createObjectURL(file)), catchError(() => of('')), tap$1(url => this.imagesMap$.next({ ...this.imagesMap$.value, [productId]: url })))
1092
+ .pipe(map(file => URL.createObjectURL(file)), catchError$1(() => of('')), tap(url => this.imagesMap$.next({ ...this.imagesMap$.value, [productId]: url })))
1492
1093
  .subscribe();
1493
1094
  }
1494
1095
  }
@@ -1498,424 +1099,17 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImpor
1498
1099
  type: Injectable
1499
1100
  }], ctorParameters: function () { return [{ type: i1.ProductApiService }]; } });
1500
1101
 
1501
- /**
1502
- * @deprecated
1503
- */
1504
- class QuoteDraftService {
1505
- get isInitialized$() {
1506
- return this.isInitializedSubj$.asObservable();
1507
- }
1508
- get isInitialized() {
1509
- return this.isInitializedSubj$.getValue();
1510
- }
1511
- set isInitialized(value) {
1512
- if (this.isInitialized !== value) {
1513
- this.isInitializedSubj$.next(value);
1514
- }
1515
- }
1516
- get hasUnsavedChanges() {
1517
- return this._hasUnsavedChanges;
1518
- }
1519
- set hasUnsavedChanges(value) {
1520
- this._hasUnsavedChanges = value;
1521
- if (!this._hasUnsavedChanges) {
1522
- this.initialCurrentState = this.quoteDraft?.currentState ?? [];
1523
- }
1524
- }
1525
- get hasProducts$() {
1526
- return this.quoteSubj$.pipe(map(() => this.hasProducts));
1527
- }
1528
- get hasProducts() {
1529
- return Boolean(this.quoteSubj$.value?.currentState.length);
1530
- }
1531
- get hasAssets$() {
1532
- return this.assetsSubj$.pipe(map(() => this.hasAssets));
1533
- }
1534
- get hasAssets() {
1535
- return Boolean(this.assetsSubj$.value?.currentState.length);
1536
- }
1537
- get assetsState() {
1538
- return this.assetsSubj$.value;
1539
- }
1540
- constructor(flowInfoService, accountApiService) {
1541
- this.flowInfoService = flowInfoService;
1542
- this.accountApiService = accountApiService;
1543
- this.quoteSubj$ = new BehaviorSubject(null);
1544
- this.assetsSubj$ = new BehaviorSubject(null);
1545
- this.resetSubj$ = new BehaviorSubject(true);
1546
- this.isInitializedSubj$ = new BehaviorSubject(false);
1547
- this.initialCurrentState = [];
1548
- this._hasUnsavedChanges = false;
1549
- this.reset$ = this.resetSubj$.asObservable();
1550
- this.isInitializedSubj$
1551
- .pipe(filter$1(isInitialized => isInitialized), switchMap$1(() => this.quoteSubj$.asObservable()), skip(1), tap(quote => this.markAsUpdated(quote)))
1552
- .subscribe();
1553
- }
1554
- reset() {
1555
- this.resetSubj$.next(true);
1556
- this.quoteSubj$.next(null);
1557
- this.assetsSubj$.next(null);
1558
- this.isInitialized = false;
1559
- this.hasUnsavedChanges = false;
1560
- }
1561
- init(headerId, params) {
1562
- const isAccountMode = this.flowInfoService.context.mode === ConfigurationContextMode.ACCOUNT;
1563
- const accountId = isAccountMode ? headerId : this.flowInfoService.context['accountId'];
1564
- return zip(accountId ? this.accountApiService.getAssetsState(accountId, params) : of(null), isAccountMode
1565
- ? of(QuoteDraft.emptyQuote(ConfigurationContextMode.ACCOUNT))
1566
- : of(QuoteDraft.emptyQuote(ConfigurationContextMode.QUOTE))).pipe(tap(([assets, quote]) => {
1567
- if (assets) {
1568
- this.assetsSubj$.next(assets);
1569
- }
1570
- this.quoteSubj$.next(quote);
1571
- }), map(() => noop()), take$1(1));
1572
- }
1573
- finalizeInit() {
1574
- this.isInitialized = true;
1575
- this.hasUnsavedChanges = false;
1576
- }
1577
- setCurrentLineItemState(lineItems) {
1578
- const quoteDraft = this.quoteSubj$.value;
1579
- if (!quoteDraft) {
1580
- return;
1581
- }
1582
- this.quoteSubj$.next({
1583
- ...quoteDraft,
1584
- currentState: lineItems,
1585
- });
1586
- }
1587
- updateQuoteDraft(update) {
1588
- const quoteDraft = this.quoteSubj$.value;
1589
- if (!quoteDraft) {
1590
- return;
1591
- }
1592
- this.quoteSubj$.next({
1593
- ...quoteDraft,
1594
- ...update,
1595
- });
1596
- }
1597
- updateByPriceSummary(priceSummary) {
1598
- const quoteDraft = this.quoteSubj$.value;
1599
- if (!quoteDraft) {
1600
- return;
1601
- }
1602
- const updatedCurrentState = this.currentState.map(lineItem => {
1603
- const updated = priceSummary.lineItems.find(li => li.id === lineItem.id);
1604
- return updated ?? lineItem;
1605
- });
1606
- this.quoteSubj$.next({
1607
- ...quoteDraft,
1608
- currentState: updatedCurrentState,
1609
- totalPrices: priceSummary.totalPrices,
1610
- approvalItems: priceSummary.approvalItems,
1611
- });
1612
- }
1613
- setAssetsState(assetsState) {
1614
- this.assetsSubj$.next(assetsState);
1615
- }
1616
- get quoteDraft$() {
1617
- return this.quoteSubj$.pipe(map(() => this.quoteDraft), filter$1((quote) => Boolean(quote)), shareReplay$1());
1618
- }
1619
- get quoteDraft() {
1620
- return this.quoteSubj$.value;
1621
- }
1622
- get currentState$() {
1623
- return this.quoteDraft$.pipe(map(quote => quote.currentState));
1624
- }
1625
- get currentState() {
1626
- return this.quoteDraft?.currentState ?? [];
1627
- }
1628
- get isStandalone() {
1629
- return this.flowInfoService.flow?.properties.standalone ?? false;
1630
- }
1631
- get isStandalone$() {
1632
- return this.flowInfoService.flow$.pipe(map(() => this.isStandalone));
1633
- }
1634
- getInitialCurrentState() {
1635
- return this.initialCurrentState;
1636
- }
1637
- isEditMode$() {
1638
- return this.quoteDraft$.pipe(map(() => this.isEditMode()));
1639
- }
1640
- isEditMode() {
1641
- const context = this.quoteDraft?.context;
1642
- if (context?.mode === ConfigurationContextMode.ACCOUNT) {
1643
- return true;
1644
- }
1645
- if (context?.mode === ConfigurationContextMode.QUOTE) {
1646
- return context.properties.Status === 'Draft';
1647
- }
1648
- return false;
1649
- }
1650
- markAsUpdated(quote) {
1651
- if (quote?.context.properties['#mode'] === ConfigurationContextMode.ACCOUNT) {
1652
- this.hasUnsavedChanges = !!quote && !quote.currentState.every(li => li.actionCode === 'EXIST');
1653
- }
1654
- else {
1655
- this.hasUnsavedChanges = !isEqual(this.initialCurrentState, quote?.currentState);
1656
- }
1657
- }
1658
- }
1659
- QuoteDraftService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: QuoteDraftService, deps: [{ token: FlowInfoService }, { token: i1.AccountApiService }], target: i0.ɵɵFactoryTarget.Injectable });
1660
- QuoteDraftService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: QuoteDraftService });
1661
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: QuoteDraftService, decorators: [{
1662
- type: Injectable
1663
- }], ctorParameters: function () { return [{ type: FlowInfoService }, { type: i1.AccountApiService }]; } });
1664
-
1665
- class ConfigurationService {
1666
- constructor(quoteDraftService, runtimeService, configurationApiService, messageService, dialogService, runtimeSettings, flowInfoService) {
1667
- this.quoteDraftService = quoteDraftService;
1668
- this.runtimeService = runtimeService;
1669
- this.configurationApiService = configurationApiService;
1670
- this.messageService = messageService;
1671
- this.dialogService = dialogService;
1672
- this.runtimeSettings = runtimeSettings;
1673
- this.flowInfoService = flowInfoService;
1674
- this.mode = ConfigurationMode.SEARCH;
1675
- this.configurationState = new BehaviorSubject(null);
1676
- this.previousConfigurationState = new BehaviorSubject(null);
1677
- this.isLoadingSubj$ = new BehaviorSubject(false);
1678
- this.isLoading$ = this.isLoadingSubj$.asObservable();
1679
- this.hasUnsavedChanges = false;
1680
- }
1681
- reset() {
1682
- this.hasUnsavedChanges = false;
1683
- this.runtimeService.reset();
1684
- this.configurableRamp = undefined;
1685
- this.configurationState.next(null);
1686
- this.previousConfigurationState.next(null);
1687
- }
1688
- patch$(lineItem) {
1689
- const source = this.getSnapshot();
1690
- if (!source) {
1691
- return throwError(() => new Error(`Source LineItem not found`));
1692
- }
1693
- this.configurableRamp = new LineItemWorker(source).replace(lineItem).li;
1694
- return this.configure().pipe(catchError$1(error => {
1695
- console.error(error);
1696
- if (!this.runtimeService.uiDefinitionProperties.suppressToastMessages) {
1697
- this.messageService.add({ severity: 'error', summary: error });
1698
- }
1699
- // bounce back if configuration call has failed
1700
- const prevState = this.configurationState.value;
1701
- this.configurationState.next(prevState ? { ...prevState } : null);
1702
- return throwError(() => error);
1703
- }), tap(() => {
1704
- if (!this.hasUnsavedChanges) {
1705
- this.hasUnsavedChanges = true;
1706
- }
1707
- }));
1708
- }
1709
- patch(lineItem) {
1710
- this.patch$(lineItem).subscribe();
1711
- }
1712
- setConfigurableRamp(lineItem) {
1713
- this.configurableRamp = lineItem;
1714
- }
1715
- get() {
1716
- return this.configurationState.pipe(map(state => state?.lineItem), shareReplay());
1717
- }
1718
- getSnapshot() {
1719
- return this.configurationState.value?.lineItem ? { ...this.configurationState.value?.lineItem } : undefined;
1720
- }
1721
- getRuntimeModel() {
1722
- const runtimeModel = this.runtimeService.runtimeModel;
1723
- if (!runtimeModel) {
1724
- throw new Error('Runtime model not initialized');
1725
- }
1726
- return runtimeModel;
1727
- }
1728
- getRuntimeContext() {
1729
- const runtimeContext = this.runtimeService.runtimeContext;
1730
- if (!runtimeContext) {
1731
- throw new Error('Runtime context not initialized');
1732
- }
1733
- return runtimeContext;
1734
- }
1735
- get state$() {
1736
- return this.configurationState.asObservable();
1737
- }
1738
- get stateSnapshot() {
1739
- return this.configurationState.value;
1740
- }
1741
- get previousStateSnapshot() {
1742
- return this.previousConfigurationState.value;
1743
- }
1744
- get charges$() {
1745
- return this.configurationState.pipe(map(state => state?.charges ?? {}));
1746
- }
1747
- get chargesSnapshot() {
1748
- return this.configurationState.value?.charges ?? {};
1749
- }
1750
- get pricePlans$() {
1751
- return this.configurationState.pipe(map(state => state?.pricePlans ?? {}));
1752
- }
1753
- get pricePlansSnapshot() {
1754
- return this.configurationState.value?.pricePlans ?? {};
1755
- }
1756
- get procedureContext$() {
1757
- return this.configurationState.pipe(map(state => state?.procedureContext ?? {}));
1758
- }
1759
- get procedureContextSnapshot() {
1760
- return this.configurationState.value?.procedureContext ?? {};
1761
- }
1762
- configure() {
1763
- return this.configureRequest$(this.generateRequest());
1764
- }
1765
- configureRequest$(configurationRequest) {
1766
- const runtimeContext = this.getRuntimeContext();
1767
- const runtimeModel = this.getRuntimeModel();
1768
- const uiDefinitionProperties = this.getUIDefinitionProperties();
1769
- const mainPricingEnabled = runtimeContext.properties?.PricingEnabled;
1770
- const pricingEnabled = mainPricingEnabled ? mainPricingEnabled === 'true' : uiDefinitionProperties.pricingEnabled;
1771
- const customPriceApi = this.runtimeSettings.getConfigurationSettings()['CUSTOM_PRICE_API'];
1772
- this.isLoadingSubj$.next(true);
1773
- const configure$ = pricingEnabled && customPriceApi
1774
- ? this.configurationApiService.customConfigurePrice({
1775
- url: customPriceApi,
1776
- configurationRequest,
1777
- runtimeModel,
1778
- })
1779
- : this.extendedConfigureLineItem$({
1780
- configurationRequest,
1781
- runtimeModel,
1782
- pricingEnabled,
1783
- });
1784
- return configure$.pipe(tap(result => {
1785
- this.configurationState.next(result);
1786
- this.previousConfigurationState.next(cloneDeep(result));
1787
- if (result.deletedLineItems?.length) {
1788
- this.showInactiveProductsConfirmation();
1789
- }
1790
- this.configurableRamp = result.lineItem;
1791
- }), map(({ lineItem }) => lineItem), catchError$1(error => throwError(() => {
1792
- const resetState = this.previousConfigurationState.value;
1793
- if (resetState) {
1794
- this.previousConfigurationState.next(cloneDeep(resetState));
1795
- this.configurationState.next(resetState);
1796
- }
1797
- if (error.error) {
1798
- return extractErrorDetails(error.error).join('. ');
1799
- }
1800
- return error.message || JSON.stringify(error);
1801
- })), finalize$1(() => this.isLoadingSubj$.next(false)));
1802
- }
1803
- configureExternal$(props) {
1804
- return this.runtimeService
1805
- .init({ productId: props.productId, defaultQty: props.qty, attributesMap: props.attributesMap })
1806
- .pipe(switchMap$1(() => this.configure()), first(), catchError$1(error => {
1807
- this.messageService.add({ severity: ToastType.error, summary: error });
1808
- throw error;
1809
- }), finalize$1(() => this.reset()));
1810
- }
1811
- configureGuidedSelling$(data) {
1812
- return this.extendedConfigureLineItem$({
1813
- configurationRequest: getGuidedSellingConfigurationRequest(data),
1814
- }).pipe(catchError$1(error => {
1815
- if (error instanceof HttpErrorResponse) {
1816
- this.messageService.add({ severity: ToastType.error, summary: error.error.message || error.error });
1817
- }
1818
- throw error;
1819
- }));
1820
- }
1821
- generateRequest(lightMode = true) {
1822
- const lineItem = this.generateLineItem();
1823
- let request = {
1824
- lineItem,
1825
- mode: this.mode,
1826
- step: !this.configurationState.value?.lineItem ? RuntimeStep.START : RuntimeStep.UPDATE,
1827
- attributeDomainMode: 'ALL',
1828
- context: this.quoteDraftService.quoteDraft?.context ?? generateEmptyContext(),
1829
- lineItems: this.quoteDraftService.quoteDraft?.currentState || [],
1830
- asset: this.getAsset(),
1831
- };
1832
- if (lightMode) {
1833
- request = ConfigurationTranslatorUtils.lightenConfigurationRequest(request);
1834
- }
1835
- return request;
1836
- }
1837
- generateLineItem() {
1838
- const runtimeContext = this.getRuntimeContext();
1839
- const uiDefinitionProperties = this.getUIDefinitionProperties();
1840
- let lineItem = this.configurableRamp;
1841
- if (!lineItem) {
1842
- const { initializationProps } = this.runtimeService ?? {};
1843
- lineItem = getDefaultLineItem(runtimeContext, uiDefinitionProperties, initializationProps?.defaultQty);
1844
- // Set default attributes
1845
- if (initializationProps?.attributesMap) {
1846
- const attributes = transform(initializationProps?.attributesMap, (acc, value, name) => acc.push({ name, value }), []);
1847
- lineItem = new LineItemWorker(lineItem).patchAttribute(attributes).li;
1848
- }
1849
- }
1850
- return lineItem;
1851
- }
1852
- getAsset() {
1853
- const lineItem = this.configurableRamp;
1854
- if (!lineItem) {
1855
- return;
1856
- }
1857
- const assetId = lineItem.assetId ?? lineItem.openOrderLineItemId;
1858
- return this.quoteDraftService.assetsState?.initialState.find(li => assetPredicateFn(li, assetId));
1859
- }
1860
- getUIDefinitionProperties() {
1861
- return {
1862
- ...(this.getRuntimeContext().uiDefinitionContainer?.source.properties ?? {}),
1863
- ...(this.runtimeService.uiDefinitionProperties ?? {}),
1864
- };
1865
- }
1866
- showInactiveProductsConfirmation() {
1867
- const confirmationConfig = {
1868
- title: ' ',
1869
- description: 'This quote contains inactive products. Do you want to remove them?',
1870
- primaryButtonLabel: 'Remove products',
1871
- secondaryButtonLabel: 'Back to Quote',
1872
- };
1873
- this.dialogService
1874
- .open(ConfirmationComponent, {
1875
- dismissableMask: false,
1876
- closeOnEscape: false,
1877
- closable: false,
1878
- showHeader: true,
1879
- header: `Inactive Products in Quote`,
1880
- width: '440px',
1881
- data: { confirmationConfig },
1882
- })
1883
- .onClose.subscribe(result => {
1884
- if (!result) {
1885
- const Id = this.quoteDraftService.quoteDraft?.context.properties.Id ?? '';
1886
- window['VELO_BACK_FN'].apply(null, [Id]);
1887
- }
1888
- });
1889
- }
1890
- extendedConfigureLineItem$({ configurationRequest, runtimeModel, pricingEnabled, }) {
1891
- return this.configurationApiService.configureLineItem({
1892
- configurationRequest: configurationRequest,
1893
- runtimeModel,
1894
- pricingEnabled,
1895
- });
1896
- }
1897
- }
1898
- ConfigurationService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: ConfigurationService, deps: [{ token: QuoteDraftService }, { token: ConfigurationRuntimeService }, { token: i1.ConfigurationApiService }, { token: i4.MessageService }, { token: i5.DialogService }, { token: RuntimeSettingsService }, { token: FlowInfoService }], target: i0.ɵɵFactoryTarget.Injectable });
1899
- ConfigurationService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: ConfigurationService });
1900
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: ConfigurationService, decorators: [{
1901
- type: Injectable
1902
- }], ctorParameters: function () { return [{ type: QuoteDraftService }, { type: ConfigurationRuntimeService }, { type: i1.ConfigurationApiService }, { type: i4.MessageService }, { type: i5.DialogService }, { type: RuntimeSettingsService }, { type: FlowInfoService }]; } });
1903
-
1904
1102
  class ConfigurationStateService {
1905
- constructor(configurationRuntimeService, configurationService,
1906
- // private quoteDraftService: QuoteDraftService,
1907
- salesTransactionService, toastService, flowStateService, flowInfoService, flowConfigurationService, flowStateApiService,
1908
- // private quoteApiService: QuoteApiService,
1909
- salesTransactionApiService) {
1103
+ constructor(configurationRuntimeService, configurationService, flowStateService, flowInfoService, flowConfigurationService, flowStateApiService, salesTransactionService, salesTransactionApiService, toastService) {
1910
1104
  this.configurationRuntimeService = configurationRuntimeService;
1911
1105
  this.configurationService = configurationService;
1912
- this.salesTransactionService = salesTransactionService;
1913
- this.toastService = toastService;
1914
1106
  this.flowStateService = flowStateService;
1915
1107
  this.flowInfoService = flowInfoService;
1916
1108
  this.flowConfigurationService = flowConfigurationService;
1917
1109
  this.flowStateApiService = flowStateApiService;
1110
+ this.salesTransactionService = salesTransactionService;
1918
1111
  this.salesTransactionApiService = salesTransactionApiService;
1112
+ this.toastService = toastService;
1919
1113
  this.isInitialized$ = new BehaviorSubject(false);
1920
1114
  this.canceledConfiguration$ = new Subject();
1921
1115
  this.NOT_INITIALIZED = Symbol();
@@ -1939,9 +1133,9 @@ class ConfigurationStateService {
1939
1133
  request$ = this.initStateful$();
1940
1134
  }
1941
1135
  else {
1942
- request$ = of(undefined);
1136
+ request$ = this.configurationService.init$();
1943
1137
  }
1944
- return request$.pipe(take(1), tap$1(() => {
1138
+ return request$.pipe(take(1), tap(() => {
1945
1139
  this.isInitialized$.next(true);
1946
1140
  this.canceledConfiguration$ = new Subject();
1947
1141
  }));
@@ -1955,10 +1149,11 @@ class ConfigurationStateService {
1955
1149
  this.configurationStore = {};
1956
1150
  this.executedFunctions = {};
1957
1151
  this.configurationService.reset();
1152
+ this.configurationRuntimeService.reset();
1958
1153
  }
1959
1154
  execute$(exec) {
1960
1155
  const request = this.execToRequest(exec);
1961
- return this.executeRequest$(request).pipe(map$1(result => {
1156
+ return this.executeRequest$(request).pipe(map(result => {
1962
1157
  // Keep only requested results
1963
1158
  const actualSelectors = Object.entries(result.selectors).reduce((trunk, [requestId, result]) => {
1964
1159
  if (exec.selectors?.[requestId]) {
@@ -1980,7 +1175,7 @@ class ConfigurationStateService {
1980
1175
  }
1981
1176
  // prevent parallel configuration requests in stateless mode
1982
1177
  if (!this.statelessExecutionRequest$) {
1983
- this.statelessExecutionRequest$ = executionRequest$.pipe(shareReplay(), take(1), finalize(() => (this.statelessExecutionRequest$ = null)));
1178
+ this.statelessExecutionRequest$ = executionRequest$.pipe(shareReplay(), take(1), finalize$1(() => (this.statelessExecutionRequest$ = null)));
1984
1179
  }
1985
1180
  return this.statelessExecutionRequest$;
1986
1181
  }
@@ -1994,7 +1189,7 @@ class ConfigurationStateService {
1994
1189
  },
1995
1190
  },
1996
1191
  });
1997
- return this.executeRequest$(request).pipe(map$1(response => response.selectors[requestId]));
1192
+ return this.executeRequest$(request).pipe(map(response => response.selectors[requestId]));
1998
1193
  }
1999
1194
  subscribe$(selectorName, inputData = {}, options) {
2000
1195
  const requestId = UUID.UUID();
@@ -2017,7 +1212,7 @@ class ConfigurationStateService {
2017
1212
  this.executeRequest$(request).subscribe();
2018
1213
  }
2019
1214
  }
2020
- return subscription.data$.pipe(filter(data => data != this.NOT_INITIALIZED), map$1(data => data), distinctUntilChanged(), finalize(() => {
1215
+ return subscription.data$.pipe(filter$1(data => data != this.NOT_INITIALIZED), map(data => data), distinctUntilChanged(), finalize$1(() => {
2021
1216
  if (!this.subscriptions[requestId]?.data$.observed) {
2022
1217
  delete this.subscriptions[requestId];
2023
1218
  }
@@ -2025,7 +1220,7 @@ class ConfigurationStateService {
2025
1220
  }
2026
1221
  saveConfiguration() {
2027
1222
  if (this.isStatefulConfiguration) {
2028
- return this.flowStateApiService.saveConfiguration(this.flowStateService.stateId ?? '', this.stateId ?? '').pipe(switchMap(r => this.flowStateService.executeRequest$({}, true).pipe(map$1(() => r))), map$1(r => ({ id: r.quoteId })));
1223
+ return this.flowStateApiService.saveConfiguration(this.flowStateService.stateId ?? '', this.stateId ?? '').pipe(switchMap(r => this.flowStateService.executeRequest$({}, true).pipe(map(() => r))), map(r => ({ id: r.quoteId })));
2029
1224
  }
2030
1225
  const state = this.salesTransactionService.state;
2031
1226
  if (!state) {
@@ -2035,27 +1230,24 @@ class ConfigurationStateService {
2035
1230
  if (standalone) {
2036
1231
  return this.salesTransactionApiService.upsert(state);
2037
1232
  }
2038
- // const lineItem = this.configurationService.getSnapshot();
2039
- // if (!lineItem) {
2040
- // return of({ id: '' });
2041
- // }
2042
- // const isNewLineItem = quoteDraft.currentState.every(li => li.id !== lineItem.id);
2043
- // let currentState: LineItem[];
2044
- // if (isNewLineItem) {
2045
- // currentState = [...quoteDraft.currentState, lineItem];
2046
- // } else {
2047
- // currentState = quoteDraft.currentState.map(li => (li.id === lineItem.id ? lineItem : li));
2048
- // }
2049
- // const asset = this.configurationService.getAsset();
2050
- // const initialState = [...(this.quoteDraftService.quoteDraft?.initialState ?? [])];
2051
- // if (asset) {
2052
- // if (!initialState.some(li => li.id === asset.id)) {
2053
- // initialState.push(asset);
2054
- // }
2055
- // }
2056
- // TODO: adjust the logic for ShoppingCart
2057
- const newState = { ...state };
2058
- return this.flowConfigurationService.calculate$(newState).pipe(map$1(() => ({ id: '' })));
1233
+ const salesTransaction = this.salesTransactionService.state;
1234
+ const configurationRoot = this.configurationService.root;
1235
+ if (!salesTransaction || !configurationRoot) {
1236
+ return of({ id: '' });
1237
+ }
1238
+ const isNewTransactionItem = salesTransaction.salesTransactionItems.every(li => li.id !== configurationRoot.id);
1239
+ let salesTransactionItems;
1240
+ if (isNewTransactionItem) {
1241
+ salesTransactionItems = [...salesTransaction.salesTransactionItems, configurationRoot];
1242
+ }
1243
+ else {
1244
+ salesTransactionItems = salesTransaction.salesTransactionItems.map(ti => ti.id === configurationRoot.id ? configurationRoot : ti);
1245
+ }
1246
+ const newState = {
1247
+ ...salesTransaction,
1248
+ salesTransactionItems,
1249
+ };
1250
+ return this.flowConfigurationService.calculate$(newState).pipe(map(() => ({ id: '' })));
2059
1251
  }
2060
1252
  cancelConfiguration() {
2061
1253
  if (!this.isInitialized$.value) {
@@ -2074,29 +1266,28 @@ class ConfigurationStateService {
2074
1266
  return this.flowInfoService.flow?.properties.stateful ?? false;
2075
1267
  }
2076
1268
  initStateful$() {
2077
- this.ownerId = this.configurationRuntimeService.runtimeContext?.uiDefinitionContainer?.id ?? '';
2078
- const lineItemId = this.configurationRuntimeService.runtimeContext?.properties?.lineItemId;
2079
- if (!this.flowStateService.stateId) {
1269
+ this.ownerId = this.configurationRuntimeService.uiDefinitionContainer?.id ?? '';
1270
+ const { productId, transactionItemId } = this.flowInfoService.context;
1271
+ if (!productId || !this.flowStateService.stateId) {
2080
1272
  return of(undefined);
2081
1273
  }
2082
- const container = this.configurationRuntimeService.runtimeContext?.uiDefinitionContainer;
2083
- const lineItem = this.configurationService.generateLineItem();
1274
+ const container = this.configurationRuntimeService.uiDefinitionContainer;
2084
1275
  let request$;
2085
- if (!lineItemId) {
1276
+ if (!transactionItemId) {
2086
1277
  request$ = this.flowStateApiService.newConfiguration(this.flowStateService.stateId, {
2087
- lineItem,
1278
+ transactionItem: generateTransactionItem(productId),
2088
1279
  actionsOverride: container?.actions?.map(processor => ({ ...processor, ownerId: this.ownerId })),
2089
1280
  selectorsOverride: container?.selectors?.map(processor => ({ ...processor, ownerId: this.ownerId })),
2090
1281
  });
2091
1282
  }
2092
1283
  else {
2093
1284
  request$ = this.flowStateApiService.startConfiguration(this.flowStateService.stateId, {
2094
- lineItemId,
1285
+ transactionItemId,
2095
1286
  actionsOverride: container?.actions?.map(processor => ({ ...processor, ownerId: this.ownerId })),
2096
1287
  selectorsOverride: container?.selectors?.map(processor => ({ ...processor, ownerId: this.ownerId })),
2097
1288
  });
2098
1289
  }
2099
- return request$.pipe(map$1(r => {
1290
+ return request$.pipe(map(r => {
2100
1291
  this.stateId = r.stateId;
2101
1292
  return undefined;
2102
1293
  }));
@@ -2140,37 +1331,35 @@ class ConfigurationStateService {
2140
1331
  else {
2141
1332
  execution$ = this.executeStateless$(fullRequest);
2142
1333
  }
2143
- return execution$.pipe(tap$1(result => this.handleSelectorsResponse(result.selectors)));
1334
+ return execution$.pipe(tap(result => this.handleSelectorsResponse(result.selectors)));
2144
1335
  }
2145
1336
  executeStateless$(request) {
2146
1337
  this.executionInProgress$.next(true);
2147
- return of(undefined).pipe(switchMap(() => {
1338
+ return this.configurationService.state$.pipe(switchMap(state => {
2148
1339
  // Apply actions and execute configuration/price call
2149
1340
  // No need to run configuration if no actions in the request
2150
1341
  if (!request.actions?.length) {
2151
1342
  return of(undefined);
2152
1343
  }
2153
- let configurationRequest = this.configurationService.generateRequest(false);
2154
1344
  request.actions.forEach(action => {
2155
- configurationRequest = this.executeActionScript(configurationRequest, action) ?? configurationRequest;
1345
+ state = this.executeActionScript(state, action) ?? state;
2156
1346
  });
2157
- configurationRequest = ConfigurationTranslatorUtils.lightenConfigurationRequest(configurationRequest);
2158
- return this.configurationService.configureRequest$(configurationRequest);
2159
- }), map$1(() => {
1347
+ return this.configurationService.configureRequest$(state);
1348
+ }), map(() => {
2160
1349
  // Run selectors and apply them to the state
2161
- const configurationState = this.configurationService.stateSnapshot;
1350
+ const configurationState = this.configurationService.state;
2162
1351
  if (!configurationState) {
2163
1352
  return { stateId: '', selectors: {} };
2164
1353
  }
2165
1354
  return this.runStatelessSelectors(request, configurationState);
2166
- }), tap$1(() => this.executionInProgress$.next(false)), catchError(error => {
2167
- const configurationState = this.configurationService.previousStateSnapshot;
1355
+ }), tap(() => this.executionInProgress$.next(false)), catchError$1(error => {
1356
+ const configurationState = this.configurationService.previousState;
2168
1357
  if (configurationState) {
2169
1358
  const selectorsResult = this.runStatelessSelectors(request, configurationState);
2170
1359
  this.handleSelectorsResponse(selectorsResult.selectors);
2171
1360
  }
2172
1361
  this.executionInProgress$.next(false);
2173
- if (!this.configurationRuntimeService.uiDefinitionProperties.suppressToastMessages) {
1362
+ if (!this.configurationRuntimeService.uiDefinitionProps.suppressToastMessages) {
2174
1363
  this.toastService.add({ severity: ToastType.error, summary: String(error) });
2175
1364
  }
2176
1365
  return throwError(() => error);
@@ -2191,21 +1380,21 @@ class ConfigurationStateService {
2191
1380
  };
2192
1381
  this.executionInProgress$.next(true);
2193
1382
  return this.flowStateApiService.executeConfiguration(this.flowStateService.stateId, this.stateId, request);
2194
- }), tap$1(({ stateId }) => (this.stateId = stateId)), share(), tap$1(() => this.executionInProgress$.next(false)), catchError(e => {
1383
+ }), tap(({ stateId }) => (this.stateId = stateId)), share(), tap(() => this.executionInProgress$.next(false)), catchError$1(e => {
2195
1384
  this.executionInProgress$.next(false);
2196
1385
  return throwError(() => e);
2197
1386
  }));
2198
1387
  }
2199
1388
  executeStateful$(request) {
2200
- return this.executionInProgress$.pipe(filter(inProgress => !inProgress), take(1), switchMap(() =>
1389
+ return this.executionInProgress$.pipe(filter$1(inProgress => !inProgress), take(1), switchMap(() =>
2201
1390
  // make sure stream switches to statefulExecutionRequest$ before pushing an execution request
2202
1391
  combineLatest([
2203
1392
  this.statefulExecutionRequest$,
2204
- of(undefined).pipe(tap$1(() => this.statefulRequestStream$.next(request))),
2205
- ])), map$1(([response]) => response), take(1));
1393
+ of(undefined).pipe(tap(() => this.statefulRequestStream$.next(request))),
1394
+ ])), map(([response]) => response), take(1));
2206
1395
  }
2207
1396
  executeActionScript(request, processor) {
2208
- const { actions } = this.configurationRuntimeService.runtimeContext?.uiDefinitionContainer ?? {};
1397
+ const { actions } = this.configurationRuntimeService.uiDefinitionContainer ?? {};
2209
1398
  const configurationProcessor = actions?.find(action => action.apiName === processor.apiName);
2210
1399
  if (!configurationProcessor?.script) {
2211
1400
  throw `ConfigurationProcessor ${processor.apiName} not found`;
@@ -2213,7 +1402,7 @@ class ConfigurationStateService {
2213
1402
  return this.executeProcessorScript(request, configurationProcessor, processor.inputData);
2214
1403
  }
2215
1404
  executeSelectorScript(request, processor) {
2216
- const { selectors } = this.configurationRuntimeService.runtimeContext?.uiDefinitionContainer ?? {};
1405
+ const { selectors } = this.configurationRuntimeService.uiDefinitionContainer ?? {};
2217
1406
  const configurationProcessor = selectors?.find(selector => selector.apiName === processor.apiName);
2218
1407
  if (!configurationProcessor?.script) {
2219
1408
  throw `ConfigurationProcessor ${processor.apiName} not found`;
@@ -2254,29 +1443,42 @@ class ConfigurationStateService {
2254
1443
  }, { stateId: '', selectors: {} });
2255
1444
  }
2256
1445
  }
2257
- ConfigurationStateService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: ConfigurationStateService, deps: [{ token: ConfigurationRuntimeService }, { token: ConfigurationService }, { token: SalesTransactionService }, { token: i6.ToastService }, { token: FlowStateService }, { token: FlowInfoService }, { token: FlowConfigurationService }, { token: i1.FlowStateApiService }, { token: i2.SalesTransactionApiService }], target: i0.ɵɵFactoryTarget.Injectable });
1446
+ ConfigurationStateService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: ConfigurationStateService, deps: [{ token: ConfigurationRuntimeService }, { token: ConfigurationService }, { token: FlowStateService }, { token: FlowInfoService }, { token: FlowConfigurationService }, { token: i1.FlowStateApiService }, { token: SalesTransactionService }, { token: i4.SalesTransactionApiService }, { token: i6.ToastService }], target: i0.ɵɵFactoryTarget.Injectable });
2258
1447
  ConfigurationStateService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: ConfigurationStateService });
2259
1448
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: ConfigurationStateService, decorators: [{
2260
1449
  type: Injectable
2261
- }], ctorParameters: function () { return [{ type: ConfigurationRuntimeService }, { type: ConfigurationService }, { type: SalesTransactionService }, { type: i6.ToastService }, { type: FlowStateService }, { type: FlowInfoService }, { type: FlowConfigurationService }, { type: i1.FlowStateApiService }, { type: i2.SalesTransactionApiService }]; } });
1450
+ }], ctorParameters: function () { return [{ type: ConfigurationRuntimeService }, { type: ConfigurationService }, { type: FlowStateService }, { type: FlowInfoService }, { type: FlowConfigurationService }, { type: i1.FlowStateApiService }, { type: SalesTransactionService }, { type: i4.SalesTransactionApiService }, { type: i6.ToastService }]; } });
2262
1451
 
2263
1452
  class ConfigurationModule {
2264
1453
  }
2265
1454
  ConfigurationModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: ConfigurationModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
2266
1455
  ConfigurationModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "15.2.9", ngImport: i0, type: ConfigurationModule, imports: [ConfirmationDialogModule, ApiModule] });
2267
- ConfigurationModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: ConfigurationModule, providers: [ConfigurationRuntimeService, RuntimeContextService, ConfigurationService, ConfigurationStateService], imports: [ConfirmationDialogModule, ApiModule] });
1456
+ ConfigurationModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: ConfigurationModule, providers: [ConfigurationService, ConfigurationStateService, ConfigurationRuntimeService], imports: [ConfirmationDialogModule, ApiModule] });
2268
1457
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: ConfigurationModule, decorators: [{
2269
1458
  type: NgModule,
2270
1459
  args: [{
2271
1460
  imports: [ConfirmationDialogModule, ApiModule],
2272
- providers: [ConfigurationRuntimeService, RuntimeContextService, ConfigurationService, ConfigurationStateService],
1461
+ providers: [ConfigurationService, ConfigurationStateService, ConfigurationRuntimeService],
1462
+ }]
1463
+ }] });
1464
+
1465
+ class FlowConfigurationModule {
1466
+ }
1467
+ FlowConfigurationModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: FlowConfigurationModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
1468
+ FlowConfigurationModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "15.2.9", ngImport: i0, type: FlowConfigurationModule, imports: [ApiModule] });
1469
+ FlowConfigurationModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: FlowConfigurationModule, providers: [FlowConfigurationService], imports: [ApiModule] });
1470
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: FlowConfigurationModule, decorators: [{
1471
+ type: NgModule,
1472
+ args: [{
1473
+ imports: [ApiModule],
1474
+ providers: [FlowConfigurationService],
2273
1475
  }]
2274
1476
  }] });
2275
1477
 
2276
1478
  class CatalogProductsService {
2277
1479
  constructor() {
2278
1480
  this.stateSubj$ = new BehaviorSubject(null);
2279
- this.state$ = this.stateSubj$.asObservable().pipe(filter(isDefined));
1481
+ this.state$ = this.stateSubj$.asObservable().pipe(filter$1(isDefined));
2280
1482
  }
2281
1483
  get state() {
2282
1484
  return this.stateSubj$.getValue();
@@ -2294,6 +1496,10 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImpor
2294
1496
  type: Injectable
2295
1497
  }] });
2296
1498
 
1499
+ const FORMATTING_SETTINGS_TOKEN = new InjectionToken('Summary of formatting settings for variant types of data, e.g. numbers, text, dates, etc');
1500
+
1501
+ const UI_DEFINITION_VERSION = 3;
1502
+
2297
1503
  const DEFAULT_FORMATTING_SETTINGS = {
2298
1504
  currencySymbol: DEFAULT_CURRENCY_SYMBOL,
2299
1505
  decimalsCount: DEFAULT_DECIMALS_COUNT,
@@ -2308,7 +1514,6 @@ SdkCoreModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "
2308
1514
  SdkCoreModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "15.2.9", ngImport: i0, type: SdkCoreModule, imports: [ConfigurationModule, FlowConfigurationModule] });
2309
1515
  SdkCoreModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: SdkCoreModule, providers: [
2310
1516
  FlowInfoService,
2311
- QuoteDraftService,
2312
1517
  ProductImagesService,
2313
1518
  IntegrationState,
2314
1519
  FlowStateService,
@@ -2327,7 +1532,6 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImpor
2327
1532
  imports: [ConfigurationModule, FlowConfigurationModule],
2328
1533
  providers: [
2329
1534
  FlowInfoService,
2330
- QuoteDraftService,
2331
1535
  ProductImagesService,
2332
1536
  IntegrationState,
2333
1537
  FlowStateService,
@@ -2509,5 +1713,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImpor
2509
1713
  * Generated bundle index. Do not edit.
2510
1714
  */
2511
1715
 
2512
- export { ActionCodePipe, CalendarDirective, ConfigurationRuntimeService, ConfigurationService, ConfigurationStateService, DEFAULT_FORMATTING_SETTINGS, DatePipe, FLOW_CUSTOMIZATION, FORMATTING_SETTINGS_TOKEN, FlowConfigurationModule, FlowConfigurationService, FlowInfoService, FlowStateConfigurationService, FlowStateService, FlowUpdateService, IntegrationState, LineItemWorker, NumberPipe, PricePipe, ProductImagesService, QuoteDraftService, RuntimeMode, RuntimeOperation, RuntimeSettingsService, RuntimeStep, SalesTransactionService, SdkCoreModule, SdkDirectivesModule, SdkPipesModule, UI_DEFINITION_VERSION, assetPredicateFn, extractMetadata, filterOutTechnicalAttributes, findLineItem, findLineItemWithComparator, generateConfigurationLineItem, generateEmptyContext, generateLineItem, getAttributeValue, getAttributes, getDefaultLineItem, getGuidedSellingConfigurationRequest, getOriginParent, getRecommendedPrices, insertLineItem, isTechnicalAttribute, lineItem_utils as lineItemUtils, mapAttributes, multiplyLineItems, patchAttributes, recalculateCardinalityVariables, removeLineItem, replaceLineItem, upsertAttributes };
1716
+ export { ActionCodePipe, CalendarDirective, ConfigurationRuntimeService, ConfigurationService, ConfigurationStateService, DEFAULT_FORMATTING_SETTINGS, DatePipe, FLOW_CUSTOMIZATION, FORMATTING_SETTINGS_TOKEN, FlowConfigurationService, FlowInfoService, FlowStateConfigurationService, FlowStateService, IntegrationState, NumberPipe, PricePipe, ProductImagesService, RuntimeSettingsService, SalesTransactionService, SdkCoreModule, SdkDirectivesModule, SdkPipesModule, TransactionItemWorker, UI_DEFINITION_VERSION, extractMetadata, findTransactionItem, findTransactionItemWithComparator, generateTransactionItem, insertTransactionItem, removeTransactionItem, replaceTransactionItem };
2513
1717
  //# sourceMappingURL=veloceapps-sdk-core.mjs.map