@veloceapps/sdk 11.0.0-12 → 11.0.0-121

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (160) hide show
  1. package/cms/cms.actions.d.ts +94 -29
  2. package/cms/components/element-renderer/element-renderer.component.d.ts +3 -10
  3. package/cms/components/preview/preview.component.d.ts +5 -6
  4. package/cms/components/preview/preview.types.d.ts +0 -4
  5. package/cms/services/element-context.service.d.ts +0 -1
  6. package/cms/types/common.types.d.ts +2 -0
  7. package/cms/types/index.d.ts +0 -1
  8. package/cms/utils/path.utils.d.ts +1 -2
  9. package/cms/vendor-map.d.ts +17 -40
  10. package/core/index.d.ts +1 -1
  11. package/core/modules/configuration/index.d.ts +4 -4
  12. package/core/modules/configuration/services/configuration-runtime.service.d.ts +8 -17
  13. package/core/modules/configuration/services/configuration-state.service.d.ts +3 -3
  14. package/core/modules/configuration/services/configuration.service.d.ts +24 -47
  15. package/core/modules/configuration/services/guided-selling.service.d.ts +15 -0
  16. package/core/modules/configuration/services/test-mode-configuration.service.d.ts +26 -0
  17. package/core/modules/configuration/types/configuration-runtime.types.d.ts +0 -5
  18. package/core/modules/configuration/types/configuration.types.d.ts +4 -2
  19. package/core/modules/configuration/types/index.d.ts +2 -0
  20. package/core/modules/flow-configuration/index.d.ts +0 -3
  21. package/core/modules/flow-configuration/services/flow-configuration.service.d.ts +11 -17
  22. package/core/operators/filter-successful-execute.operator.d.ts +3 -0
  23. package/core/operators/index.d.ts +1 -0
  24. package/core/services/flow-info.service.d.ts +7 -5
  25. package/core/services/flow-state-configuration.service.d.ts +9 -8
  26. package/core/services/flow-state.service.d.ts +6 -15
  27. package/core/services/index.d.ts +1 -1
  28. package/core/services/integration.state.d.ts +1 -1
  29. package/core/services/product-images.service.d.ts +3 -3
  30. package/core/services/runtime-settings.service.d.ts +1 -1
  31. package/core/services/sales-transaction.service.d.ts +9 -10
  32. package/core/types/flow-customization.types.d.ts +2 -2
  33. package/core/types/index.d.ts +0 -1
  34. package/core/utils/index.d.ts +2 -2
  35. package/core/utils/transaction-item.utils.d.ts +7 -0
  36. package/core/utils/transaction-item.worker.d.ts +8 -0
  37. package/esm2020/cms/cms.actions.mjs +93 -71
  38. package/esm2020/cms/cms.default.mjs +2 -3
  39. package/esm2020/cms/components/element-renderer/element-renderer.component.mjs +7 -64
  40. package/esm2020/cms/components/element-tools-panel/element-tools-panel.component.mjs +3 -3
  41. package/esm2020/cms/components/preview/preview.component.mjs +19 -28
  42. package/esm2020/cms/components/preview/preview.types.mjs +1 -1
  43. package/esm2020/cms/services/element-context.service.mjs +1 -1
  44. package/esm2020/cms/types/common.types.mjs +1 -1
  45. package/esm2020/cms/types/index.mjs +1 -2
  46. package/esm2020/cms/utils/element.utils.mjs +3 -3
  47. package/esm2020/cms/utils/elements-resolver.mjs +16 -5
  48. package/esm2020/cms/utils/path.utils.mjs +1 -10
  49. package/esm2020/cms/vendor-map.mjs +17 -18
  50. package/esm2020/core/core.module.mjs +3 -6
  51. package/esm2020/core/index.mjs +2 -2
  52. package/esm2020/core/modules/configuration/configuration.module.mjs +17 -4
  53. package/esm2020/core/modules/configuration/index.mjs +5 -5
  54. package/esm2020/core/modules/configuration/services/configuration-runtime.service.mjs +16 -64
  55. package/esm2020/core/modules/configuration/services/configuration-state.service.mjs +58 -58
  56. package/esm2020/core/modules/configuration/services/configuration.service.mjs +125 -229
  57. package/esm2020/core/modules/configuration/services/guided-selling.service.mjs +62 -0
  58. package/esm2020/core/modules/configuration/services/test-mode-configuration.service.mjs +97 -0
  59. package/esm2020/core/modules/configuration/types/configuration-runtime.types.mjs +1 -1
  60. package/esm2020/core/modules/configuration/types/configuration.types.mjs +1 -1
  61. package/esm2020/core/modules/configuration/types/index.mjs +3 -0
  62. package/esm2020/core/modules/flow-configuration/flow-configuration.module.mjs +3 -4
  63. package/esm2020/core/modules/flow-configuration/index.mjs +1 -4
  64. package/esm2020/core/modules/flow-configuration/services/flow-configuration.service.mjs +31 -39
  65. package/esm2020/core/operators/filter-successful-execute.operator.mjs +5 -0
  66. package/esm2020/core/operators/index.mjs +2 -0
  67. package/esm2020/core/services/flow-info.service.mjs +20 -11
  68. package/esm2020/core/services/flow-state-configuration.service.mjs +55 -25
  69. package/esm2020/core/services/flow-state.service.mjs +34 -82
  70. package/esm2020/core/services/index.mjs +2 -2
  71. package/esm2020/core/services/integration.state.mjs +2 -2
  72. package/esm2020/core/services/product-images.service.mjs +8 -8
  73. package/esm2020/core/services/runtime-settings.service.mjs +3 -3
  74. package/esm2020/core/services/sales-transaction.service.mjs +18 -13
  75. package/esm2020/core/types/flow-customization.types.mjs +1 -1
  76. package/esm2020/core/types/index.mjs +1 -2
  77. package/esm2020/core/utils/index.mjs +3 -3
  78. package/esm2020/core/utils/transaction-item.utils.mjs +60 -0
  79. package/esm2020/core/utils/transaction-item.worker.mjs +16 -0
  80. package/esm2020/src/components/flow-header/flow-header.component.mjs +7 -8
  81. package/esm2020/src/components/guided-selling/guided-selling.component.mjs +7 -8
  82. package/esm2020/src/flow-routing.module.mjs +10 -8
  83. package/esm2020/src/guards/flow.guard.mjs +5 -7
  84. package/esm2020/src/guards/product-unload.guard.mjs +7 -7
  85. package/esm2020/src/index.mjs +1 -2
  86. package/esm2020/src/pages/assets/assets.component.mjs +7 -8
  87. package/esm2020/src/pages/catalog/catalog.component.mjs +7 -8
  88. package/esm2020/src/pages/debug/debug.component.mjs +12 -17
  89. package/esm2020/src/pages/product/product.component.mjs +16 -70
  90. package/esm2020/src/pages/record-not-found/record-not-found.component.mjs +5 -6
  91. package/esm2020/src/pages/shopping-cart/shopping-cart.component.mjs +7 -8
  92. package/esm2020/src/resolvers/pcm-model.resolver.mjs +12 -0
  93. package/esm2020/src/resolvers/sales-transaction.resolver.mjs +64 -0
  94. package/esm2020/src/resolvers/ui-definition.resolver.mjs +44 -0
  95. package/esm2020/src/services/flow-dialog.service.mjs +3 -24
  96. package/esm2020/src/services/flow-router.service.mjs +17 -24
  97. package/esm2020/src/services/flow.service.mjs +11 -17
  98. package/esm2020/src/types/index.mjs +2 -3
  99. package/esm2020/src/types/route.types.mjs +1 -1
  100. package/fesm2015/veloceapps-sdk-cms.mjs +162 -309
  101. package/fesm2015/veloceapps-sdk-cms.mjs.map +1 -1
  102. package/fesm2015/veloceapps-sdk-core.mjs +571 -1166
  103. package/fesm2015/veloceapps-sdk-core.mjs.map +1 -1
  104. package/fesm2015/veloceapps-sdk.mjs +161 -242
  105. package/fesm2015/veloceapps-sdk.mjs.map +1 -1
  106. package/fesm2020/veloceapps-sdk-cms.mjs +158 -300
  107. package/fesm2020/veloceapps-sdk-cms.mjs.map +1 -1
  108. package/fesm2020/veloceapps-sdk-core.mjs +631 -1197
  109. package/fesm2020/veloceapps-sdk-core.mjs.map +1 -1
  110. package/fesm2020/veloceapps-sdk.mjs +161 -239
  111. package/fesm2020/veloceapps-sdk.mjs.map +1 -1
  112. package/package.json +1 -1
  113. package/src/components/flow-header/flow-header.component.d.ts +3 -3
  114. package/src/components/guided-selling/guided-selling.component.d.ts +3 -3
  115. package/src/guards/product-unload.guard.d.ts +3 -3
  116. package/src/index.d.ts +0 -1
  117. package/src/pages/assets/assets.component.d.ts +3 -3
  118. package/src/pages/catalog/catalog.component.d.ts +3 -3
  119. package/src/pages/debug/debug.component.d.ts +2 -4
  120. package/src/pages/product/product.component.d.ts +5 -12
  121. package/src/pages/record-not-found/record-not-found.component.d.ts +2 -3
  122. package/src/pages/shopping-cart/shopping-cart.component.d.ts +3 -3
  123. package/src/resolvers/pcm-model.resolver.d.ts +3 -0
  124. package/src/resolvers/sales-transaction.resolver.d.ts +18 -0
  125. package/src/resolvers/ui-definition.resolver.d.ts +3 -0
  126. package/src/services/flow-dialog.service.d.ts +3 -5
  127. package/src/services/flow-router.service.d.ts +5 -5
  128. package/src/services/flow.service.d.ts +3 -3
  129. package/src/types/index.d.ts +1 -2
  130. package/src/types/route.types.d.ts +0 -5
  131. package/cms/plugins/configuration.plugin.d.ts +0 -23
  132. package/cms/types/configuration.types.d.ts +0 -21
  133. package/core/modules/configuration/helpers.d.ts +0 -7
  134. package/core/modules/configuration/services/runtime-context.service.d.ts +0 -12
  135. package/core/modules/flow-configuration/services/flow-update.service.d.ts +0 -13
  136. package/core/modules/flow-configuration/types/update.types.d.ts +0 -12
  137. package/core/services/quote-draft.service.d.ts +0 -50
  138. package/core/types/runtime.types.d.ts +0 -30
  139. package/core/utils/line-item.utils.d.ts +0 -25
  140. package/core/utils/line-item.worker.d.ts +0 -9
  141. package/esm2020/cms/plugins/configuration.plugin.mjs +0 -109
  142. package/esm2020/cms/types/configuration.types.mjs +0 -2
  143. package/esm2020/core/modules/configuration/helpers.mjs +0 -67
  144. package/esm2020/core/modules/configuration/services/runtime-context.service.mjs +0 -45
  145. package/esm2020/core/modules/flow-configuration/services/flow-update.service.mjs +0 -138
  146. package/esm2020/core/modules/flow-configuration/types/update.types.mjs +0 -2
  147. package/esm2020/core/services/quote-draft.service.mjs +0 -174
  148. package/esm2020/core/types/runtime.types.mjs +0 -16
  149. package/esm2020/core/utils/line-item.utils.mjs +0 -187
  150. package/esm2020/core/utils/line-item.worker.mjs +0 -19
  151. package/esm2020/src/resolvers/quote.resolver.mjs +0 -82
  152. package/esm2020/src/types/context-route.types.mjs +0 -2
  153. package/esm2020/src/types/metrics.types.mjs +0 -2
  154. package/esm2020/src/utils/flow.utils.mjs +0 -14
  155. package/esm2020/src/utils/index.mjs +0 -2
  156. package/src/resolvers/quote.resolver.d.ts +0 -18
  157. package/src/types/context-route.types.d.ts +0 -5
  158. package/src/types/metrics.types.d.ts +0 -5
  159. package/src/utils/flow.utils.d.ts +0 -1
  160. package/src/utils/index.d.ts +0 -1
@@ -1,215 +1,44 @@
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';
4
- import * as i1 from '@veloceapps/api';
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, isDefined, UITemplateType, SalesforceIdUtils, UUID, extractErrorDetails, ConfigurationProcessorTypes, EntityUtil, DEFAULT_TIME_FORMAT, formatNumber } from '@veloceapps/core';
4
+ import * as i3 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 i1 from '@veloceapps/api/v2';
9
+ import { tap, BehaviorSubject, map, filter, switchMap, of, forkJoin, noop, throwError, Subject, catchError as catchError$1, combineLatest, finalize as finalize$1, buffer, debounceTime, share, take, distinctUntilChanged, shareReplay, takeUntil, first } from 'rxjs';
10
+ import { uniqBy, flatten, omit, cloneDeep, assign, isEqual } from 'lodash';
11
+ import * as i2 from 'primeng/api';
12
+ import { filter as filter$1, map as map$1, tap as tap$1, catchError, 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 = {};
18
+ constructor(pcmApiService) {
19
+ this.pcmApiService = pcmApiService;
20
+ this.uiDefinitionContainer = null;
21
+ }
22
+ get uiDefinitionProps() {
23
+ return this.uiDefinitionContainer?.source.properties ?? {};
152
24
  }
153
25
  reset() {
154
- this._isInitialized = false;
155
- this._runtimeContext = undefined;
26
+ this.uiDefinitionContainer = null;
156
27
  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)));
28
+ this.pcmModel = undefined;
170
29
  }
171
- init(props) {
30
+ init$(props) {
172
31
  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;
200
- }
201
- get runtimeModel() {
202
- return this.runtimeContext?.runtimeModel;
203
- }
204
- get runtimeContext() {
205
- return this._runtimeContext;
32
+ return this.pcmApiService.fetchPCMByProductId(props.productId).pipe(tap(pcmModel => (this.pcmModel = pcmModel)));
206
33
  }
207
34
  }
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 });
35
+ ConfigurationRuntimeService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: ConfigurationRuntimeService, deps: [{ token: i1.PCMApiService }], target: i0.ɵɵFactoryTarget.Injectable });
209
36
  ConfigurationRuntimeService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: ConfigurationRuntimeService });
210
37
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: ConfigurationRuntimeService, decorators: [{
211
38
  type: Injectable
212
- }], ctorParameters: function () { return [{ type: i1.ConfigurationApiService }, { type: RuntimeContextService }]; } });
39
+ }], ctorParameters: function () { return [{ type: i1.PCMApiService }]; } });
40
+
41
+ const FLOW_CUSTOMIZATION = new InjectionToken('FLOW_CUSTOMIZATION');
213
42
 
214
43
  class RuntimeSettingsService {
215
44
  constructor(configurationSettingsApiService) {
@@ -228,11 +57,11 @@ class RuntimeSettingsService {
228
57
  };
229
58
  }
230
59
  create() {
231
- return this.configurationSettingsApiService.fetchSettings().pipe(map$1(settings => this.parseConfigurationSettings(settings)), tap$1(configurationSettings => {
60
+ return this.configurationSettingsApiService.fetchSettings().pipe(map(settings => this.parseConfigurationSettings(settings)), tap(configurationSettings => {
232
61
  this.configurationSettings$.next(configurationSettings);
233
62
  this.addShoppingCartSettings(configurationSettings['shopping-cart'] ?? []);
234
63
  this.formattingSettings = this.getFormattingSettings();
235
- }), map$1(() => undefined));
64
+ }), map(() => undefined));
236
65
  }
237
66
  initCurrency(iso) {
238
67
  if (iso) {
@@ -332,18 +161,21 @@ class FlowInfoService {
332
161
  }
333
162
  return { ...this.contextSubj$.value };
334
163
  }
164
+ get context$() {
165
+ return this.contextSubj$.asObservable().pipe(filter(isDefined));
166
+ }
335
167
  get templates() {
336
168
  return this.templatesSubj$.value;
337
169
  }
338
170
  get isFlowEngineInitialized$() {
339
- return this.templates$.pipe(map$1(v => Boolean(v.FLOW_ENGINE)));
171
+ return this.templates$.pipe(map(v => Boolean(v.FLOW_ENGINE)));
340
172
  }
341
173
  get isStateful() {
342
174
  return !!this.flow?.properties.stateful;
343
175
  }
344
- constructor(runtimeSettingsService, templatesApiService, customizationService) {
176
+ constructor(runtimeSettingsService, templatesAdminApiService, customizationService) {
345
177
  this.runtimeSettingsService = runtimeSettingsService;
346
- this.templatesApiService = templatesApiService;
178
+ this.templatesAdminApiService = templatesAdminApiService;
347
179
  this.customizationService = customizationService;
348
180
  this.defaultTemplates = {
349
181
  flowEngine: 'Flow Engine',
@@ -354,7 +186,7 @@ class FlowInfoService {
354
186
  this.flow$ = this.flowSubj$.asObservable();
355
187
  this.templates$ = this.templatesSubj$.asObservable();
356
188
  }
357
- cleanup() {
189
+ reset() {
358
190
  this.flowSubj$.next(null);
359
191
  this.templatesSubj$.next({});
360
192
  this.contextSubj$.next(null);
@@ -362,6 +194,12 @@ class FlowInfoService {
362
194
  init$(flowId, routeQueryParams) {
363
195
  return this.initFlow$(flowId, routeQueryParams).pipe(switchMap(() => this.initFlowTemplates$()));
364
196
  }
197
+ updateContext(update) {
198
+ this.contextSubj$.next({
199
+ ...this.context,
200
+ ...update,
201
+ });
202
+ }
365
203
  initFlow$(flowId, routeQueryParams) {
366
204
  const flow = this.runtimeSettingsService.getConfigurationSettings()['flows']?.find(({ id }) => flowId === id);
367
205
  if (!flow) {
@@ -387,9 +225,9 @@ class FlowInfoService {
387
225
  }
388
226
  initFlowTemplates$() {
389
227
  return forkJoin([
390
- this.templatesApiService.fetchTemplates$(),
228
+ this.templatesAdminApiService.fetchTemplates$(),
391
229
  this.customizationService?.getTemplates?.() ?? of([]),
392
- ]).pipe(map$1(([templates, localTemplates]) => {
230
+ ]).pipe(map(([templates, localTemplates]) => {
393
231
  const newValue = {};
394
232
  Object.entries({ ...this.defaultTemplates, ...(this.flow?.properties.templates ?? {}) }).forEach(([key, name]) => {
395
233
  const type = this.remapTemplateName(key);
@@ -433,239 +271,87 @@ class FlowInfoService {
433
271
  return objectName.toUpperCase();
434
272
  }
435
273
  }
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 });
274
+ FlowInfoService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: FlowInfoService, deps: [{ token: RuntimeSettingsService }, { token: i1.UITemplatesAdminApiService }, { token: FLOW_CUSTOMIZATION, optional: true }], target: i0.ɵɵFactoryTarget.Injectable });
437
275
  FlowInfoService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: FlowInfoService });
438
276
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: FlowInfoService, decorators: [{
439
277
  type: Injectable
440
- }], ctorParameters: function () { return [{ type: RuntimeSettingsService }, { type: i2.UITemplatesApiService }, { type: undefined, decorators: [{
278
+ }], ctorParameters: function () { return [{ type: RuntimeSettingsService }, { type: i1.UITemplatesAdminApiService }, { type: undefined, decorators: [{
441
279
  type: Optional
442
280
  }, {
443
281
  type: Inject,
444
282
  args: [FLOW_CUSTOMIZATION]
445
283
  }] }]; } });
446
284
 
447
- const findLineItem = (id, lineItems) => {
448
- return findLineItemWithComparator(lineItems, (li) => li.id === id);
285
+ const findTransactionItem = (id, items) => {
286
+ return findTransactionItemWithComparator(items, (ti) => ti.id === id);
449
287
  };
450
- const findLineItemWithComparator = (lineItems, comparator) => {
451
- let currentLevel = lineItems;
288
+ const findTransactionItemWithComparator = (items, comparator) => {
289
+ let currentLevel = items;
452
290
  while (currentLevel.length) {
453
291
  const found = currentLevel.find(comparator);
454
292
  if (found) {
455
293
  return found;
456
294
  }
457
- currentLevel = flatten(currentLevel.map(parent => parent.lineItems));
295
+ currentLevel = flatten(currentLevel.map(parent => parent.children));
458
296
  }
459
297
  return;
460
298
  };
461
- const insertLineItem = (lineItem, parentId, toInsert) => {
462
- const insertData = lineItem.id === parentId ? [toInsert] : [];
299
+ const insertTransactionItem = (item, parentId, toInsert) => {
300
+ const insertData = item.id === parentId ? [toInsert] : [];
463
301
  return {
464
- ...lineItem,
465
- lineItems: [
302
+ ...item,
303
+ children: [
466
304
  ...insertData,
467
- ...lineItem.lineItems.map(li => {
468
- return insertLineItem(li, parentId, toInsert);
305
+ ...item.children.map(ti => {
306
+ return insertTransactionItem(ti, parentId, toInsert);
469
307
  }),
470
308
  ],
471
309
  };
472
310
  };
473
- const removeLineItem = (lineItem, idToRemove) => {
311
+ const removeTransactionItem = (item, idToRemove) => {
474
312
  return {
475
- ...lineItem,
476
- lineItems: lineItem.lineItems
477
- .map(li => {
478
- if (li.id === idToRemove) {
313
+ ...item,
314
+ children: item.children
315
+ .map(ti => {
316
+ if (ti.id === idToRemove) {
479
317
  return;
480
318
  }
481
- else if (li.lineItems.length) {
482
- return removeLineItem(li, idToRemove);
319
+ else if (ti.children.length) {
320
+ return removeTransactionItem(ti, idToRemove);
483
321
  }
484
- return li;
322
+ return ti;
485
323
  })
486
- .filter(r => !!r),
324
+ .filter(isDefined),
487
325
  };
488
326
  };
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
- }
327
+ const replaceTransactionItem = (item, replaceTo) => {
328
+ if (item.id === replaceTo.id) {
329
+ return { ...replaceTo };
497
330
  }
498
331
  return {
499
- ...lineItem,
500
- lineItems: lineItem.lineItems.map(li => replaceLineItem(li, replaceTo, skipCardinalityCalculation)),
332
+ ...item,
333
+ children: item.children.map(ti => replaceTransactionItem(ti, replaceTo)),
501
334
  };
502
335
  };
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 = []) => {
336
+ const generateTransactionItem = (productId) => {
572
337
  return {
573
338
  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,
339
+ productId,
582
340
  };
583
341
  };
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
342
 
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
-
654
- class LineItemWorker {
343
+ class TransactionItemWorker {
655
344
  constructor(src) {
656
- this.li = { ...src };
345
+ this.ti = { ...src };
657
346
  }
658
347
  insert(parentId, toInsert) {
659
- return new LineItemWorker(insertLineItem(this.li, parentId, toInsert));
348
+ return new TransactionItemWorker(insertTransactionItem(this.ti, parentId, toInsert));
660
349
  }
661
350
  remove(id) {
662
- return new LineItemWorker(removeLineItem(this.li, id));
663
- }
664
- replace(toReplace, skipCardinalityCalculation = false) {
665
- return new LineItemWorker(replaceLineItem(this.li, toReplace, skipCardinalityCalculation));
351
+ return new TransactionItemWorker(removeTransactionItem(this.ti, id));
666
352
  }
667
- patchAttribute(attrs, id, skipCardinalityCalculation = false) {
668
- return new LineItemWorker(patchAttributes(this.li, id ?? this.li.id, attrs, skipCardinalityCalculation));
353
+ replace(toReplace) {
354
+ return new TransactionItemWorker(replaceTransactionItem(this.ti, toReplace));
669
355
  }
670
356
  }
671
357
 
@@ -677,196 +363,319 @@ function extractMetadata(uiDefinition) {
677
363
  ]);
678
364
  }
679
365
 
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);
366
+ class GuidedSellingService {
367
+ constructor(orchestrationsApiService) {
368
+ this.orchestrationsApiService = orchestrationsApiService;
369
+ this.guidedSellingResult$ = new BehaviorSubject({});
728
370
  }
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;
371
+ get guidedSellingResult() {
372
+ return this.guidedSellingResult$.value;
373
+ }
374
+ configureGuidedSelling$(data) {
375
+ return this.orchestrationsApiService
376
+ .apply$({
377
+ transactionContext: this.getTransactionContext(data.attributesMap),
378
+ orchestrationName: data.orchestrationName,
379
+ })
380
+ .pipe(map(transactionContext => {
381
+ const guidedSellingNode = transactionContext.nodes['GuidedSelling']?.[0];
382
+ const guidedSellingResult = guidedSellingNode?.attributes?.['result'] || {};
383
+ this.guidedSellingResult$.next(guidedSellingResult);
384
+ return guidedSellingResult;
385
+ }));
386
+ }
387
+ clearGuidedSelling$() {
388
+ this.guidedSellingResult$.next({});
772
389
  }
773
- applyChargeUpdate(lineItem, update) {
774
- const foundCharge = lineItem.chargeItems.find(({ id }) => id === update.id);
775
- if (!foundCharge) {
776
- return false;
390
+ getTransactionContext(guidedSellingAttributes) {
391
+ const testTransaction = {
392
+ id: UUID.UUID(),
393
+ businessObjectType: 'Quote',
394
+ salesTransactionItems: [],
395
+ attributes: {},
396
+ };
397
+ return {
398
+ salesTransaction: testTransaction,
399
+ transactionId: UUID.UUID(),
400
+ businessObjectType: 'Quote',
401
+ nodes: {
402
+ GuidedSelling: [
403
+ {
404
+ id: UUID.UUID(),
405
+ attributes: {},
406
+ nodes: {},
407
+ properties: { guidedSellingAttributes },
408
+ },
409
+ ],
410
+ },
411
+ id: UUID.UUID(),
412
+ attributes: {},
413
+ };
414
+ }
415
+ }
416
+ GuidedSellingService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: GuidedSellingService, deps: [{ token: i1.OrchestrationsApiService }], target: i0.ɵɵFactoryTarget.Injectable });
417
+ GuidedSellingService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: GuidedSellingService });
418
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: GuidedSellingService, decorators: [{
419
+ type: Injectable
420
+ }], ctorParameters: function () { return [{ type: i1.OrchestrationsApiService }]; } });
421
+
422
+ class ConfigurationService {
423
+ constructor(flowInfoService, messageService, configurationRuntimeService, salesTransactionService, orchestrationsApiService, guidedSellingService) {
424
+ this.flowInfoService = flowInfoService;
425
+ this.messageService = messageService;
426
+ this.configurationRuntimeService = configurationRuntimeService;
427
+ this.salesTransactionService = salesTransactionService;
428
+ this.orchestrationsApiService = orchestrationsApiService;
429
+ this.guidedSellingService = guidedSellingService;
430
+ this.hasUnsavedChanges = false;
431
+ this.configurationStateSubj$ = new BehaviorSubject(null);
432
+ this.previousConfigurationStateSubj$ = new BehaviorSubject(null);
433
+ this.isLoadingSubj$ = new BehaviorSubject(false);
434
+ this.isLoading$ = this.isLoadingSubj$.asObservable();
435
+ }
436
+ get state$() {
437
+ return this.configurationStateSubj$.asObservable().pipe(filter$1(isDefined));
438
+ }
439
+ get state() {
440
+ return this.configurationStateSubj$.getValue();
441
+ }
442
+ get previousState() {
443
+ return this.previousConfigurationStateSubj$.getValue();
444
+ }
445
+ get root$() {
446
+ return this.state$.pipe(map$1(state => state.salesTransaction.salesTransactionItems[0]), filter$1(isDefined));
447
+ }
448
+ get root() {
449
+ return this.configurationStateSubj$.getValue()?.salesTransaction.salesTransactionItems[0] ?? null;
450
+ }
451
+ reset() {
452
+ this.hasUnsavedChanges = false;
453
+ this.configurationStateSubj$.next(null);
454
+ this.previousConfigurationStateSubj$.next(null);
455
+ }
456
+ init$() {
457
+ const { state } = this.salesTransactionService;
458
+ const { standalone } = this.flowInfoService.flow.properties;
459
+ const { productId, transactionItemId, newProductQty } = this.flowInfoService.context;
460
+ if (!state || !productId) {
461
+ return of(undefined);
777
462
  }
778
- if (update.attributeType === 'PRICE_ADJUSTMENT') {
779
- foundCharge.priceAdjustment = update.newValue;
463
+ const salesTransactionItems = state?.salesTransaction.salesTransactionItems ?? [];
464
+ let isRootGenerated = false;
465
+ let transactionItem = salesTransactionItems.find(item => item.id === transactionItemId);
466
+ if (!transactionItem && standalone) {
467
+ transactionItem = salesTransactionItems.find(item => item.productId === productId);
780
468
  }
781
- else if (update.attributeType === 'LIST_PRICE_ADJUSTMENT') {
782
- foundCharge.listPriceAdjustment = update.newValue;
469
+ if (!transactionItem) {
470
+ transactionItem = generateTransactionItem(productId);
471
+ if (typeof newProductQty === 'number' && newProductQty > 0) {
472
+ transactionItem.qty = newProductQty;
473
+ }
474
+ isRootGenerated = true;
783
475
  }
784
- else {
785
- throw new Error(`Not suppored AttributeType for Charge Item update: ${update.attributeType}`);
476
+ const guidedSellingResult = this.guidedSellingService.guidedSellingResult;
477
+ if (transactionItem && Object.keys(guidedSellingResult).length && isRootGenerated) {
478
+ transactionItem.stiAttributes = Object.entries(guidedSellingResult).map(([attributeName, value]) => ({
479
+ attributeName,
480
+ value,
481
+ }));
786
482
  }
787
- return true;
483
+ const configurationState = {
484
+ ...state,
485
+ salesTransaction: {
486
+ ...state.salesTransaction,
487
+ salesTransactionItems: transactionItem ? [transactionItem] : [],
488
+ },
489
+ };
490
+ return (isRootGenerated ? this.configure$(configurationState) : of(configurationState)).pipe(tap$1(configurationState => {
491
+ this.configurationStateSubj$.next(configurationState);
492
+ this.previousConfigurationStateSubj$.next(configurationState);
493
+ }), map$1(noop));
788
494
  }
789
- applyChargeGroupUpdate(lineItem, update) {
790
- const foundChargeGroup = ChargeGroupUtils.findChargeGroupById(update.id, lineItem);
791
- if (!foundChargeGroup) {
792
- return false;
495
+ patch$(transactionItem) {
496
+ const { state, root } = this;
497
+ if (!state) {
498
+ return throwError(() => new Error(`Configuration State is not initialized`));
793
499
  }
794
- if (update.attributeType === 'PRICE_ADJUSTMENT') {
795
- foundChargeGroup.priceAdjustment = update.newValue;
500
+ if (!root) {
501
+ return throwError(() => new Error(`Root SalesTransactionItem not found`));
796
502
  }
797
- else if (update.attributeType === 'LIST_PRICE_ADJUSTMENT') {
798
- foundChargeGroup.listPriceAdjustment = update.newValue;
503
+ const newRoot = new TransactionItemWorker(root).replace(transactionItem).ti;
504
+ const newTransactionContext = {
505
+ ...state,
506
+ salesTransaction: {
507
+ ...state.salesTransaction,
508
+ salesTransactionItems: [newRoot],
509
+ },
510
+ };
511
+ return this.configure$(newTransactionContext).pipe(catchError(error => {
512
+ console.error(error);
513
+ if (!this.configurationRuntimeService.uiDefinitionProps.suppressToastMessages) {
514
+ this.messageService.add({ severity: 'error', summary: error });
515
+ }
516
+ return throwError(() => error);
517
+ }), tap$1(() => {
518
+ if (!this.hasUnsavedChanges) {
519
+ this.hasUnsavedChanges = true;
520
+ }
521
+ }), map$1(noop));
522
+ }
523
+ patch(transactionItem) {
524
+ this.patch$(transactionItem).subscribe();
525
+ }
526
+ configure$(transactionContext) {
527
+ this.isLoadingSubj$.next(true);
528
+ return this.justConfigureRequest$(transactionContext).pipe(tap$1(result => {
529
+ this.configurationStateSubj$.next(result);
530
+ this.previousConfigurationStateSubj$.next(cloneDeep(result));
531
+ }), catchError(e => {
532
+ const resetState = this.previousConfigurationStateSubj$.getValue();
533
+ if (resetState) {
534
+ this.previousConfigurationStateSubj$.next(cloneDeep(resetState));
535
+ this.configurationStateSubj$.next(resetState);
536
+ }
537
+ return throwError(() => e);
538
+ }), finalize(() => this.isLoadingSubj$.next(false)));
539
+ }
540
+ justConfigureRequest$(transactionContext) {
541
+ const request = {
542
+ transactionContext,
543
+ flowId: this.flowInfoService.flow.id,
544
+ };
545
+ return this.orchestrationsApiService.apply$(request).pipe(catchError(error => throwError(() => {
546
+ if (error.error) {
547
+ return extractErrorDetails(error.error).join('. ');
548
+ }
549
+ return error.message || JSON.stringify(error);
550
+ })));
551
+ }
552
+ getPCMModel() {
553
+ const pcmModel = this.configurationRuntimeService.pcmModel;
554
+ if (!pcmModel) {
555
+ throw new Error('PCM model not initialized');
799
556
  }
800
- else {
801
- throw new Error(`Not suppored AttributeType for Charge Group Item update: ${update.attributeType}`);
557
+ return pcmModel;
558
+ }
559
+ }
560
+ ConfigurationService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: ConfigurationService, deps: [{ token: FlowInfoService }, { token: i2.MessageService }, { token: ConfigurationRuntimeService }, { token: SalesTransactionService }, { token: i1.OrchestrationsApiService }, { token: GuidedSellingService }], target: i0.ɵɵFactoryTarget.Injectable });
561
+ ConfigurationService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: ConfigurationService });
562
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: ConfigurationService, decorators: [{
563
+ type: Injectable
564
+ }], ctorParameters: function () { return [{ type: FlowInfoService }, { type: i2.MessageService }, { type: ConfigurationRuntimeService }, { type: SalesTransactionService }, { type: i1.OrchestrationsApiService }, { type: GuidedSellingService }]; } });
565
+
566
+ class SalesTransactionService {
567
+ get isInitialized$() {
568
+ return this.isInitializedSubj$.asObservable();
569
+ }
570
+ get isInitialized() {
571
+ return this.isInitializedSubj$.getValue();
572
+ }
573
+ set hasUnsavedChanges(value) {
574
+ this.hasUnsavedChangesSubj$.next(value);
575
+ if (!this.hasUnsavedChanges) {
576
+ this.initialState = this.state?.salesTransaction.salesTransactionItems ?? [];
802
577
  }
803
- return true;
578
+ }
579
+ get hasUnsavedChanges() {
580
+ return this.hasUnsavedChangesSubj$.getValue();
581
+ }
582
+ get state() {
583
+ return this.stateSubj$.getValue();
584
+ }
585
+ get hasProducts() {
586
+ return Boolean(this.state?.salesTransaction.salesTransactionItems.length);
587
+ }
588
+ constructor(salesTransactionApiService) {
589
+ this.salesTransactionApiService = salesTransactionApiService;
590
+ this.stateSubj$ = new BehaviorSubject(null);
591
+ this.isInitializedSubj$ = new BehaviorSubject(false);
592
+ this.hasUnsavedChangesSubj$ = new BehaviorSubject(false);
593
+ this.initialState = [];
594
+ this.hasUnsavedChanges$ = this.hasUnsavedChangesSubj$.asObservable();
595
+ this.state$ = this.stateSubj$.asObservable().pipe(filter(isDefined));
596
+ }
597
+ init(headerId, params) {
598
+ return this.salesTransactionApiService.query(headerId, params).pipe(tap(res => {
599
+ if (!res.salesTransaction) {
600
+ throw new Error('SalesTransaction is not defined. Please check Query Orchestration.');
601
+ }
602
+ this.stateSubj$.next(res);
603
+ }));
604
+ }
605
+ finalizeInit() {
606
+ this.isInitializedSubj$.next(true);
607
+ this.hasUnsavedChanges = false;
608
+ }
609
+ reset() {
610
+ this.stateSubj$.next(null);
611
+ this.isInitializedSubj$.next(false);
612
+ this.hasUnsavedChangesSubj$.next(false);
613
+ }
614
+ getInitialState() {
615
+ return this.initialState;
616
+ }
617
+ setState(state) {
618
+ this.stateSubj$.next(state);
804
619
  }
805
620
  }
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: [{
621
+ SalesTransactionService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: SalesTransactionService, deps: [{ token: i1.SalesTransactionApiService }], target: i0.ɵɵFactoryTarget.Injectable });
622
+ SalesTransactionService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: SalesTransactionService });
623
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: SalesTransactionService, decorators: [{
809
624
  type: Injectable
810
- }] });
625
+ }], ctorParameters: function () { return [{ type: i1.SalesTransactionApiService }]; } });
811
626
 
812
627
  class FlowConfigurationService {
813
- constructor(proceduresApiService,
814
- // private quoteDraftService: QuoteDraftService,
815
- salesTransactionService, updateService, configurationService, flowInfoService) {
816
- this.proceduresApiService = proceduresApiService;
628
+ constructor(orchestrationsApiService, salesTransactionService, flowInfoService) {
629
+ this.orchestrationsApiService = orchestrationsApiService;
817
630
  this.salesTransactionService = salesTransactionService;
818
- this.updateService = updateService;
819
- this.configurationService = configurationService;
820
631
  this.flowInfoService = flowInfoService;
821
632
  this.updatedSubj$ = new Subject();
822
633
  this.updated$ = this.updatedSubj$.asObservable();
823
634
  }
824
635
  calculate$(state) {
825
- return this.proceduresApiService.apply$({ salesTransaction: state }).pipe(tap$1(result => this.salesTransactionService.setState(result.salesTransaction)), map$1(noop));
636
+ return this.orchestrationsApiService
637
+ .apply$({ transactionContext: state, flowId: this.flowInfoService.flow.id })
638
+ .pipe(tap(result => this.salesTransactionService.setState(result)), map(noop));
826
639
  }
827
640
  calculate(state) {
828
641
  this.calculate$(state).subscribe();
829
642
  }
830
- revert$(lineItemId) {
643
+ revert$(transactionItemId) {
831
644
  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) {
645
+ const initialState = this.salesTransactionService.getInitialState();
646
+ const currentState = state?.salesTransaction.salesTransactionItems ?? [];
647
+ const currentItemIndex = currentState.findIndex(({ id }) => id === transactionItemId);
648
+ const currentItem = currentState[currentItemIndex];
649
+ const initialItem = initialState.find(({ integrationId }) => integrationId === currentItem?.integrationId);
650
+ if (!state || !currentItem || !initialItem) {
838
651
  return of(null);
839
652
  }
840
653
  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());
654
+ updatedState.splice(currentItemIndex, 1, initialItem);
655
+ return of([]).pipe(map(() => ({
656
+ ...state,
657
+ salesTransaction: { ...state.salesTransaction, salesTransactionItems: updatedState },
658
+ })), tap(newState => this.salesTransactionService.setState(newState)), switchMap(newState => this.calculate$(newState)), map(() => this.salesTransactionService.state), tap(() => this.updatedSubj$.next()), this.handleErrorAndBounceBack());
845
659
  }
846
- revert(lineItemId) {
847
- this.revert$(lineItemId).subscribe();
660
+ revert(transactionItemId) {
661
+ this.revert$(transactionItemId).subscribe();
848
662
  }
849
663
  delete$(ids) {
850
664
  const state = this.salesTransactionService.state;
851
665
  if (!state) {
852
666
  return of(null);
853
667
  }
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());
668
+ return of([]).pipe(map(() => state.salesTransaction.salesTransactionItems.filter(({ id }) => !ids.includes(id))), switchMap(updatedState => this.calculate$({
669
+ ...state,
670
+ salesTransaction: { ...state.salesTransaction, salesTransactionItems: updatedState },
671
+ })), map(() => this.salesTransactionService.state), tap(() => this.updatedSubj$.next()), this.handleErrorAndBounceBack());
855
672
  }
856
673
  delete(ids) {
857
674
  this.delete$(ids).subscribe();
858
675
  }
859
- addTerm$(term) {
860
- // TODO: implement
861
- return of(this.salesTransactionService.state);
862
- }
863
- addToCart$(props) {
864
- // TODO: implement
865
- return of(this.salesTransactionService.state);
866
- }
867
676
  handleErrorAndBounceBack() {
868
677
  return (source$) => {
869
- return source$.pipe(catchError(error => {
678
+ return source$.pipe(catchError$1(error => {
870
679
  console.error(error);
871
680
  // bounce back if configuration call has failed
872
681
  const state = this.salesTransactionService.state;
@@ -879,87 +688,105 @@ class FlowConfigurationService {
879
688
  };
880
689
  }
881
690
  }
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 });
691
+ FlowConfigurationService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: FlowConfigurationService, deps: [{ token: i1.OrchestrationsApiService }, { token: SalesTransactionService }, { token: FlowInfoService }], target: i0.ɵɵFactoryTarget.Injectable });
883
692
  FlowConfigurationService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: FlowConfigurationService });
884
693
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: FlowConfigurationService, decorators: [{
885
694
  type: Injectable
886
- }], ctorParameters: function () { return [{ type: i2.ProceduresApiService }, { type: SalesTransactionService }, { type: FlowUpdateService }, { type: ConfigurationService }, { type: FlowInfoService }]; } });
695
+ }], ctorParameters: function () { return [{ type: i1.OrchestrationsApiService }, { type: SalesTransactionService }, { type: FlowInfoService }]; } });
887
696
 
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
- }] });
900
-
901
- class SalesTransactionService {
902
- get isInitialized$() {
903
- return this.isInitializedSubj$.asObservable();
904
- }
905
- get isInitialized() {
906
- return this.isInitializedSubj$.getValue();
907
- }
908
- set hasUnsavedChanges(value) {
909
- this.hasUnsavedChangesSubj$.next(value);
910
- if (!this.hasUnsavedChanges) {
911
- this.initialCurrentState = this.state?.salesTransactionItems ?? [];
912
- }
913
- }
914
- get hasUnsavedChanges() {
915
- return this.hasUnsavedChangesSubj$.getValue();
916
- }
917
- get state() {
918
- return this.stateSubj$.getValue();
919
- }
920
- constructor(flowInfoService, salesTransactionApiService) {
697
+ class TestModeConfigurationService {
698
+ constructor(flowInfoService, configurationService, configurationRuntimeService, salesTransactionService, runtimeSettingsService, sfApiService) {
921
699
  this.flowInfoService = flowInfoService;
922
- this.salesTransactionApiService = salesTransactionApiService;
923
- this.stateSubj$ = new BehaviorSubject(null);
924
- this.isInitializedSubj$ = new BehaviorSubject(false);
925
- this.hasUnsavedChangesSubj$ = new BehaviorSubject(false);
926
- this.initialCurrentState = [];
927
- this.hasUnsavedChanges$ = this.hasUnsavedChangesSubj$.asObservable();
928
- this.state$ = this.stateSubj$.asObservable().pipe(filter(isDefined));
929
- }
930
- init(headerId, params) {
931
- return this.salesTransactionApiService.getState(headerId, params).pipe(tap$1(res => this.stateSubj$.next(res)));
932
- }
933
- finalizeInit() {
934
- this.isInitializedSubj$.next(true);
935
- this.hasUnsavedChanges = false;
936
- }
937
- reset() {
938
- this.stateSubj$.next(null);
939
- this.isInitializedSubj$.next(false);
940
- this.hasUnsavedChangesSubj$.next(false);
700
+ this.configurationService = configurationService;
701
+ this.configurationRuntimeService = configurationRuntimeService;
702
+ this.salesTransactionService = salesTransactionService;
703
+ this.runtimeSettingsService = runtimeSettingsService;
704
+ this.sfApiService = sfApiService;
705
+ this.isInitialized = false;
941
706
  }
942
- getInitialCurrentState() {
943
- return this.initialCurrentState;
707
+ initTestMode$(uiDefinitionContainer, options) {
708
+ this.configurationRuntimeService.uiDefinitionContainer = uiDefinitionContainer;
709
+ if (this.checkInitialized(uiDefinitionContainer)) {
710
+ this.configurationRuntimeService.pcmModel = this.pcmModel;
711
+ return of(undefined);
712
+ }
713
+ this.configurationService.reset();
714
+ const { productId, quoteId, flowId } = uiDefinitionContainer.source.properties ?? {};
715
+ if (!productId) {
716
+ return throwError(() => 'Unable to start the Configuration Preview: Product is missing.');
717
+ }
718
+ if (!quoteId) {
719
+ return throwError(() => `Unable to start the Configuration Preview: Quote is missing.`);
720
+ }
721
+ if (!flowId) {
722
+ return throwError(() => `Unable to start the Configuration Preview: Flow is missing.`);
723
+ }
724
+ return this.runtimeSettingsService.create().pipe(switchMap(() => this.flowInfoService.init$(flowId, { productId, headerId: quoteId, testMode: true })), switchMap(() => this.configurationRuntimeService.init$({ productId })), tap(pcmModel => (this.pcmModel = pcmModel)), switchMap(() => {
725
+ if (options?.customizationMode) {
726
+ return of(undefined);
727
+ }
728
+ return this.initConfiguration$(quoteId);
729
+ }), tap(() => (this.isInitialized = true)), map(noop));
730
+ }
731
+ initConfiguration$(quoteId) {
732
+ return this.getPriceBookId(quoteId).pipe(map(priceBookId => this.getTestTransactionContext(quoteId, priceBookId)), tap(state => this.salesTransactionService.setState(state)), switchMap(() => this.configurationService.init$()), switchMap(() => this.configurationService.state
733
+ ? this.configurationService.configure$(this.configurationService.state)
734
+ : of(undefined)), map(noop));
735
+ }
736
+ getPriceBookId(quoteId) {
737
+ return this.sfApiService
738
+ .query({ count: 1, fields: ['Pricebook2Id'], rawCondition: `Id = '${quoteId}'` }, 'Quote')
739
+ .pipe(map(r => r?.[0]?.Pricebook2Id ?? null));
740
+ }
741
+ getTestTransactionContext(quoteId, priceBookId) {
742
+ const dateStr = new Date().toISOString().split('T')[0] ?? '';
743
+ const testTransaction = {
744
+ id: quoteId,
745
+ businessObjectType: 'Quote',
746
+ salesTransactionItems: [],
747
+ salesTransactionName: 'Test Quote',
748
+ account: '',
749
+ quoteAccount: '',
750
+ pricebook: '',
751
+ status: 'Draft',
752
+ totalAmount: 0,
753
+ subtotal: 0,
754
+ activatedDate: dateStr,
755
+ effectiveDate: dateStr,
756
+ startDate: dateStr,
757
+ attributes: {},
758
+ nodes: {},
759
+ };
760
+ if (priceBookId) {
761
+ testTransaction.pricebook = priceBookId;
762
+ }
763
+ return {
764
+ salesTransaction: testTransaction,
765
+ transactionId: quoteId,
766
+ businessObjectType: 'Quote',
767
+ nodes: {},
768
+ id: UUID.UUID(),
769
+ attributes: {},
770
+ };
944
771
  }
945
- setState(state) {
946
- this.stateSubj$.next(state);
772
+ checkInitialized(uiDefinitionContainer) {
773
+ return this.isInitialized && !!uiDefinitionContainer.source.properties?.persistTestState;
947
774
  }
948
775
  }
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 });
950
- SalesTransactionService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: SalesTransactionService });
951
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: SalesTransactionService, decorators: [{
776
+ TestModeConfigurationService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: TestModeConfigurationService, deps: [{ token: FlowInfoService }, { token: ConfigurationService }, { token: ConfigurationRuntimeService }, { token: SalesTransactionService }, { token: RuntimeSettingsService }, { token: i1.SalesforceApiService }], target: i0.ɵɵFactoryTarget.Injectable });
777
+ TestModeConfigurationService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: TestModeConfigurationService });
778
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: TestModeConfigurationService, decorators: [{
952
779
  type: Injectable
953
- }], ctorParameters: function () { return [{ type: FlowInfoService }, { type: i2.SalesTransactionApiService }]; } });
780
+ }], ctorParameters: function () { return [{ type: FlowInfoService }, { type: ConfigurationService }, { type: ConfigurationRuntimeService }, { type: SalesTransactionService }, { type: RuntimeSettingsService }, { type: i1.SalesforceApiService }]; } });
954
781
 
955
782
  class FlowStateService {
956
- constructor(salesTransactionService, flowInfoService, flowConfiguration, processorsApiService, flowStateApiService, salesTransactionApiService, toastService, customizationService) {
957
- this.salesTransactionService = salesTransactionService;
958
- this.flowInfoService = flowInfoService;
783
+ constructor(flowConfiguration, flowInfoService, flowStateApiService, processorsApiService, salesTransactionApiService, salesTransactionService, toastService, customizationService) {
959
784
  this.flowConfiguration = flowConfiguration;
960
- this.processorsApiService = processorsApiService;
785
+ this.flowInfoService = flowInfoService;
961
786
  this.flowStateApiService = flowStateApiService;
787
+ this.processorsApiService = processorsApiService;
962
788
  this.salesTransactionApiService = salesTransactionApiService;
789
+ this.salesTransactionService = salesTransactionService;
963
790
  this.toastService = toastService;
964
791
  this.customizationService = customizationService;
965
792
  this.NOT_INITIALIZED = Symbol();
@@ -976,48 +803,22 @@ class FlowStateService {
976
803
  this.cleanup$ = new Subject();
977
804
  this.statefulExecutionRequest$ = this.initBufferedRequest$();
978
805
  /*
979
- In stateless mode watch QuoteDraft changes and call executeRequest so that
980
- all subscriptions get their updates according to updated QuoteDraft
806
+ In stateless mode watch State changes and call executeRequest so that
807
+ all subscriptions get their updates according to updated State
981
808
  */
982
809
  this.isInitialized$()
983
- .pipe(filter(Boolean), filter(() => !this.getFlowSafe().properties.stateful), switchMap(() => this.flowConfiguration.updated$), switchMap(() => this.executeRequest$({}, true)))
810
+ .pipe(filter(Boolean), filter(() => !this.flowInfoService.flow.properties.stateful), switchMap(() => this.flowConfiguration.updated$), switchMap(() => this.executeRequest$({}, true)))
984
811
  .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
812
  }
1010
813
  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
- }));
814
+ if (this.flowInfoService.flow.properties.stateful) {
815
+ return this.initProcessors$().pipe(switchMap(() => this.initStateful$()));
816
+ }
817
+ else {
818
+ return forkJoin([this.initStateless$(), this.initProcessors$()]).pipe(map(noop));
819
+ }
1019
820
  }
1020
- cleanup() {
821
+ reset() {
1021
822
  Object.values(this.subscriptions).forEach(({ data$ }) => data$.complete());
1022
823
  this.subscriptions = {};
1023
824
  if (this.stateId$.value) {
@@ -1029,7 +830,7 @@ class FlowStateService {
1029
830
  this.cleanup$.next();
1030
831
  }
1031
832
  get hasUnsavedChanges() {
1032
- return this.getFlowSafe().properties.stateful
833
+ return this.flowInfoService.flow.properties.stateful
1033
834
  ? Array.from(this.trackedStatefulChangesMap.values()).some(Boolean)
1034
835
  : this.salesTransactionService.hasUnsavedChanges;
1035
836
  }
@@ -1040,14 +841,14 @@ class FlowStateService {
1040
841
  return this.executionInProgress$.asObservable();
1041
842
  }
1042
843
  isInitialized$() {
1043
- return combineLatest([this.stateId$, this.salesTransactionService.isInitialized$]).pipe(map$1(values => values.some(Boolean)));
844
+ return combineLatest([this.stateId$, this.salesTransactionService.isInitialized$]).pipe(map(values => values.some(Boolean)));
1044
845
  }
1045
846
  isInitialized() {
1046
847
  return Boolean(this.stateId$.value) || this.salesTransactionService.isInitialized;
1047
848
  }
1048
849
  execute$(scope, exec) {
1049
850
  const request = this.execToRequest(scope, exec);
1050
- return this.executeRequest$(request).pipe(map$1(result => {
851
+ return this.executeRequest$(request).pipe(map(result => {
1051
852
  // Keep only requested results
1052
853
  const actualSelectors = Object.entries(result.selectors).reduce((trunk, [requestId, result]) => {
1053
854
  if (exec.selectors?.[requestId]) {
@@ -1063,7 +864,7 @@ class FlowStateService {
1063
864
  actions: [{ name: action, inputData }],
1064
865
  };
1065
866
  const request = this.execToRequest(scope, exec);
1066
- return this.executeRequest$(request).pipe(map$1(noop));
867
+ return this.executeRequest$(request).pipe(map(noop));
1067
868
  }
1068
869
  select$(scope, selectorName, inputData) {
1069
870
  const requestId = this.generateRequestId(scope, selectorName, inputData);
@@ -1075,7 +876,7 @@ class FlowStateService {
1075
876
  },
1076
877
  },
1077
878
  });
1078
- return this.executeRequest$(request).pipe(map$1(response => response.selectors[requestId]));
879
+ return this.executeRequest$(request).pipe(map(response => response.selectors[requestId]));
1079
880
  }
1080
881
  subscribe$(scope, selectorName, inputData, options) {
1081
882
  const requestId = this.generateRequestId(scope, selectorName, inputData);
@@ -1101,16 +902,16 @@ class FlowStateService {
1101
902
  this.executeRequest$(request).subscribe();
1102
903
  }
1103
904
  }
1104
- return subscription.data$.pipe(filter(data => data != this.NOT_INITIALIZED), map$1(data => data), finalize(() => {
905
+ return subscription.data$.pipe(filter(data => data != this.NOT_INITIALIZED), map(data => data), finalize$1(() => {
1105
906
  if (!this.subscriptions[requestId]?.data$.observed) {
1106
907
  delete this.subscriptions[requestId];
1107
908
  }
1108
909
  }));
1109
910
  }
1110
911
  save$() {
1111
- if (this.getFlowSafe().properties.stateful) {
912
+ if (this.flowInfoService.flow.properties.stateful) {
1112
913
  if (this.stateId$.value) {
1113
- return this.flowStateApiService.save(this.stateId$.value).pipe(map$1(({ quoteId }) => ({ id: quoteId })), tap$1(() => {
914
+ return this.flowStateApiService.save(this.stateId$.value).pipe(map(({ quoteId }) => ({ id: quoteId })), tap(() => {
1114
915
  Array.from(this.trackedStatefulChangesMap.keys()).forEach(key => {
1115
916
  this.trackedStatefulChangesMap.set(key, false);
1116
917
  });
@@ -1120,21 +921,11 @@ class FlowStateService {
1120
921
  else {
1121
922
  const state = this.salesTransactionService.state;
1122
923
  if (state) {
1123
- return this.salesTransactionApiService.upsert(state);
1124
- }
1125
- }
1126
- return of({ id: '' });
1127
- }
1128
- submit$() {
1129
- if (this.getFlowSafe().properties.stateful) {
1130
- if (this.stateId$.value) {
1131
- return this.flowStateApiService.submit(this.stateId$.value).pipe(map$1(({ quoteId }) => ({ id: quoteId })));
1132
- }
1133
- }
1134
- else {
1135
- const state = this.salesTransactionService.state;
1136
- if (state) {
1137
- return this.salesTransactionApiService.submit(state);
924
+ const request = {
925
+ transactionContext: state,
926
+ flowId: this.flowInfoService.flow.id,
927
+ };
928
+ return this.salesTransactionApiService.save(request).pipe(map(id => ({ id })));
1138
929
  }
1139
930
  }
1140
931
  return of({ id: '' });
@@ -1175,10 +966,10 @@ class FlowStateService {
1175
966
  fullRequest.selectors = assign(fullRequest.selectors, subscription.request.selectors);
1176
967
  }
1177
968
  }
1178
- const execution$ = this.getFlowSafe().properties.stateful
969
+ const execution$ = this.flowInfoService.flow.properties.stateful
1179
970
  ? this.executeStateful$(fullRequest)
1180
971
  : this.executeStateless$(fullRequest);
1181
- return execution$.pipe(tap$1(result => this.handleSelectorsResponse(result.selectors)));
972
+ return execution$.pipe(tap(result => this.handleSelectorsResponse(result.selectors)));
1182
973
  }
1183
974
  handleSelectorsResponse(selectors) {
1184
975
  Object.entries(selectors).forEach(([requestId, selectorResult]) => {
@@ -1207,7 +998,7 @@ class FlowStateService {
1207
998
  selectorsOverride: processors?.filter(processor => processor.type === ConfigurationProcessorTypes.SELECTOR),
1208
999
  selectors: selectors,
1209
1000
  })
1210
- .pipe(map$1(({ stateId, selectors }) => {
1001
+ .pipe(map(({ stateId, selectors }) => {
1211
1002
  this.handleSelectorsResponse(selectors);
1212
1003
  this.stateId$.next(stateId);
1213
1004
  }));
@@ -1227,7 +1018,7 @@ class FlowStateService {
1227
1018
  };
1228
1019
  this.executionInProgress$.next(true);
1229
1020
  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 => {
1021
+ }), tap(({ stateId }) => this.stateId$.next(stateId)), share(), tap(() => this.executionInProgress$.next(false)), catchError$1(e => {
1231
1022
  this.executionInProgress$.next(false);
1232
1023
  return throwError(() => e);
1233
1024
  }));
@@ -1237,20 +1028,15 @@ class FlowStateService {
1237
1028
  // make sure stream switches to statefulExecutionRequest$ before pushing an execution request
1238
1029
  combineLatest([
1239
1030
  this.statefulExecutionRequest$,
1240
- of(undefined).pipe(tap$1(() => this.statefulRequestStream$.next(request))),
1241
- ])), map$1(([response]) => response), take(1));
1031
+ of(undefined).pipe(tap(() => this.statefulRequestStream$.next(request))),
1032
+ ])), map(([response]) => response), take(1));
1242
1033
  }
1243
1034
  initStateless$() {
1244
- return this.salesTransactionService.init(this.flowInfoService.context.headerId, this.flowInfoService.context).pipe(tap$1(() => {
1245
- const assets = this.salesTransactionService.state?.assets;
1246
- if (assets) {
1247
- this.flowStore = { ...this.flowStore, assets };
1248
- }
1249
- }), switchMap(state => this.flowConfiguration.calculate$(state)), tap$1(() => this.salesTransactionService.finalizeInit()), map$1(noop));
1035
+ return this.salesTransactionService.init(this.flowInfoService.context.headerId, this.flowInfoService.context).pipe(switchMap(state => this.flowConfiguration.calculate$(state)), tap(() => this.salesTransactionService.finalizeInit()), map(noop));
1250
1036
  }
1251
1037
  executeStateless$(request) {
1252
1038
  this.executionInProgress$.next(true);
1253
- return of(undefined).pipe(tap$1(() => this.executeStatelessActions(request)), switchMap(() => {
1039
+ return of(undefined).pipe(tap(() => this.executeStatelessActions(request)), switchMap(() => {
1254
1040
  /*
1255
1041
  Skip price calculation in case
1256
1042
  1. No actions in the request
@@ -1263,7 +1049,7 @@ class FlowStateService {
1263
1049
  else {
1264
1050
  return this.flowConfiguration.calculate$(state);
1265
1051
  }
1266
- }), map$1(() => this.executeStatelessSelectors(request)), tap$1(() => this.executionInProgress$.next(false)), catchError(e => {
1052
+ }), map(() => this.executeStatelessSelectors(request)), tap(() => this.executionInProgress$.next(false)), catchError$1(e => {
1267
1053
  this.executionInProgress$.next(false);
1268
1054
  return throwError(() => e);
1269
1055
  }));
@@ -1288,7 +1074,7 @@ class FlowStateService {
1288
1074
  }
1289
1075
  executeStatelessSelectors(request) {
1290
1076
  if (!this.salesTransactionService.state) {
1291
- throw 'QuoteDraft is not initialized';
1077
+ throw 'State is not initialized';
1292
1078
  }
1293
1079
  const flowState = this.salesTransactionService.state;
1294
1080
  return EntityUtil.entries(request.selectors ?? {}).reduce((result, [key, selector]) => {
@@ -1308,16 +1094,9 @@ class FlowStateService {
1308
1094
  return result;
1309
1095
  }, { stateId: '', selectors: {} });
1310
1096
  }
1311
- getFlowSafe() {
1312
- if (!this.flowInfoService.flow) {
1313
- throw 'Flow is not defined';
1314
- }
1315
- return this.flowInfoService.flow;
1316
- }
1317
1097
  initProcessors$() {
1318
1098
  const hasOverrides = Boolean(this.customizationService?.getTemplateConfigurationProcessors);
1319
- const flow = this.getFlowSafe();
1320
- if (flow.properties.stateful && !hasOverrides) {
1099
+ if (this.flowInfoService.flow.properties.stateful && !hasOverrides) {
1321
1100
  // Skip initialization as backend will take processors from SF
1322
1101
  return of(undefined);
1323
1102
  }
@@ -1327,7 +1106,7 @@ class FlowStateService {
1327
1106
  return;
1328
1107
  }
1329
1108
  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 => {
1109
+ return localProcessors$.pipe(switchMap(processors => processors ? of(processors) : this.processorsApiService.fetchConfigurationProcessors$(template.id)), tap(processors => {
1331
1110
  const processorsMap = processors.reduce((acc, p) => {
1332
1111
  acc[p.apiName] = p;
1333
1112
  return acc;
@@ -1339,7 +1118,7 @@ class FlowStateService {
1339
1118
  if (!owners$.length) {
1340
1119
  return of(undefined);
1341
1120
  }
1342
- return forkJoin(owners$).pipe(map$1(noop));
1121
+ return forkJoin(owners$).pipe(map(noop));
1343
1122
  }
1344
1123
  executeActionScript(request, executable) {
1345
1124
  const configurationProcessor = this.processors[executable.ownerId]?.[executable.apiName];
@@ -1388,11 +1167,11 @@ class FlowStateService {
1388
1167
  }
1389
1168
  }
1390
1169
  }
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 });
1170
+ FlowStateService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: FlowStateService, deps: [{ token: FlowConfigurationService }, { token: FlowInfoService }, { token: i3.FlowStateApiService }, { token: i1.ConfigurationProcessorsApiService }, { token: i1.SalesTransactionApiService }, { token: SalesTransactionService }, { token: i6.ToastService }, { token: FLOW_CUSTOMIZATION, optional: true }], target: i0.ɵɵFactoryTarget.Injectable });
1392
1171
  FlowStateService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: FlowStateService });
1393
1172
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: FlowStateService, decorators: [{
1394
1173
  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: [{
1174
+ }], ctorParameters: function () { return [{ type: FlowConfigurationService }, { type: FlowInfoService }, { type: i3.FlowStateApiService }, { type: i1.ConfigurationProcessorsApiService }, { type: i1.SalesTransactionApiService }, { type: SalesTransactionService }, { type: i6.ToastService }, { type: undefined, decorators: [{
1396
1175
  type: Optional
1397
1176
  }, {
1398
1177
  type: Inject,
@@ -1400,15 +1179,12 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImpor
1400
1179
  }] }]; } });
1401
1180
 
1402
1181
  class FlowStateConfigurationService {
1403
- constructor(flowInfoService, flowConfigurationService, flowStateApiService, flowStateService) {
1182
+ constructor(flowInfoService, flowStateService, configurationService, salesTransactionService, flowConfigurationService) {
1404
1183
  this.flowInfoService = flowInfoService;
1405
- this.flowConfigurationService = flowConfigurationService;
1406
- this.flowStateApiService = flowStateApiService;
1407
1184
  this.flowStateService = flowStateService;
1408
- this.configurationStateId$ = new BehaviorSubject(null);
1409
- }
1410
- get configurationStateId() {
1411
- return this.configurationStateId$.value;
1185
+ this.configurationService = configurationService;
1186
+ this.salesTransactionService = salesTransactionService;
1187
+ this.flowConfigurationService = flowConfigurationService;
1412
1188
  }
1413
1189
  addToCart$(props) {
1414
1190
  let request$;
@@ -1419,26 +1195,57 @@ class FlowStateConfigurationService {
1419
1195
  request$ = of();
1420
1196
  }
1421
1197
  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
- }));
1198
+ // TODO: Implement
1199
+ request$ = of();
1429
1200
  }
1430
1201
  }
1431
1202
  else {
1432
- request$ = this.flowConfigurationService.addToCart$(props).pipe(map$1(noop));
1203
+ request$ = this.configureExternal$(props);
1433
1204
  }
1434
- return request$.pipe(switchMap(() => this.flowStateService.executeRequest$({}, true)), map$1(noop));
1205
+ return request$.pipe(switchMap(() => this.flowStateService.executeRequest$({}, true)), map(noop));
1206
+ }
1207
+ configureExternal$(props) {
1208
+ const { state } = this.salesTransactionService;
1209
+ if (!state) {
1210
+ return of();
1211
+ }
1212
+ const stateToConfigure = {
1213
+ ...state,
1214
+ salesTransaction: {
1215
+ ...state.salesTransaction,
1216
+ salesTransactionItems: [
1217
+ {
1218
+ ...generateTransactionItem(props.productId),
1219
+ qty: props.qty ?? 1,
1220
+ stiAttributes: Object.entries(props.attributesMap ?? {}).map(([attributeName, value]) => ({
1221
+ attributeName,
1222
+ value,
1223
+ })),
1224
+ },
1225
+ ],
1226
+ },
1227
+ };
1228
+ return this.configurationService.justConfigureRequest$(stateToConfigure).pipe(switchMap(configurationResult => {
1229
+ const state = this.salesTransactionService.state;
1230
+ const addedProduct = configurationResult.salesTransaction.salesTransactionItems[0];
1231
+ if (!state || !addedProduct) {
1232
+ return of();
1233
+ }
1234
+ return this.flowConfigurationService.calculate$({
1235
+ ...state,
1236
+ salesTransaction: {
1237
+ ...state.salesTransaction,
1238
+ salesTransactionItems: [...state.salesTransaction.salesTransactionItems, addedProduct],
1239
+ },
1240
+ });
1241
+ }));
1435
1242
  }
1436
1243
  }
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 });
1244
+ FlowStateConfigurationService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: FlowStateConfigurationService, deps: [{ token: FlowInfoService }, { token: FlowStateService }, { token: ConfigurationService }, { token: SalesTransactionService }, { token: FlowConfigurationService }], target: i0.ɵɵFactoryTarget.Injectable });
1438
1245
  FlowStateConfigurationService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: FlowStateConfigurationService });
1439
1246
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: FlowStateConfigurationService, decorators: [{
1440
1247
  type: Injectable
1441
- }], ctorParameters: function () { return [{ type: FlowInfoService }, { type: FlowConfigurationService }, { type: i1.FlowStateApiService }, { type: FlowStateService }]; } });
1248
+ }], ctorParameters: function () { return [{ type: FlowInfoService }, { type: FlowStateService }, { type: ConfigurationService }, { type: SalesTransactionService }, { type: FlowConfigurationService }]; } });
1442
1249
 
1443
1250
  class IntegrationState {
1444
1251
  constructor() {
@@ -1458,12 +1265,12 @@ class IntegrationState {
1458
1265
  this.action$.next(action);
1459
1266
  }
1460
1267
  listen$(actionType) {
1461
- return this.action$.pipe(filter(action => action.type === actionType), map$1(action => action.payload));
1268
+ return this.action$.pipe(filter(action => action.type === actionType), map(action => action.payload));
1462
1269
  }
1463
1270
  listenAll$() {
1464
1271
  return this.action$.asObservable();
1465
1272
  }
1466
- clear() {
1273
+ reset() {
1467
1274
  this.stateSubj$.next({});
1468
1275
  }
1469
1276
  }
@@ -1474,8 +1281,8 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImpor
1474
1281
  }] });
1475
1282
 
1476
1283
  class ProductImagesService {
1477
- constructor(productApiService) {
1478
- this.productApiService = productApiService;
1284
+ constructor(productsAdminApiService) {
1285
+ this.productsAdminApiService = productsAdminApiService;
1479
1286
  this.imagesMap$ = new BehaviorSubject({});
1480
1287
  }
1481
1288
  getImageUrl$(productId) {
@@ -1483,439 +1290,53 @@ class ProductImagesService {
1483
1290
  this.imagesMap$.next({ ...this.imagesMap$.value, [productId]: '' });
1484
1291
  this.fetchProductImage(productId);
1485
1292
  }
1486
- return this.imagesMap$.pipe(map$1(imagesMap => imagesMap[productId] ?? null), distinctUntilChanged());
1293
+ return this.imagesMap$.pipe(map(imagesMap => imagesMap[productId] ?? null), distinctUntilChanged());
1487
1294
  }
1488
1295
  fetchProductImage(productId) {
1489
- this.productApiService
1296
+ this.productsAdminApiService
1490
1297
  .fetchImage$(productId)
1491
- .pipe(map$1(file => URL.createObjectURL(file)), catchError(() => of('')), tap$1(url => this.imagesMap$.next({ ...this.imagesMap$.value, [productId]: url })))
1298
+ .pipe(map(file => URL.createObjectURL(file)), catchError$1(() => of('')), tap(url => this.imagesMap$.next({ ...this.imagesMap$.value, [productId]: url })))
1492
1299
  .subscribe();
1493
1300
  }
1494
1301
  }
1495
- ProductImagesService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: ProductImagesService, deps: [{ token: i1.ProductApiService }], target: i0.ɵɵFactoryTarget.Injectable });
1302
+ ProductImagesService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: ProductImagesService, deps: [{ token: i1.ProductsAdminApiService }], target: i0.ɵɵFactoryTarget.Injectable });
1496
1303
  ProductImagesService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: ProductImagesService });
1497
1304
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: ProductImagesService, decorators: [{
1498
1305
  type: Injectable
1499
- }], ctorParameters: function () { return [{ type: i1.ProductApiService }]; } });
1306
+ }], ctorParameters: function () { return [{ type: i1.ProductsAdminApiService }]; } });
1500
1307
 
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
- }
1308
+ class CatalogProductsService {
1309
+ constructor() {
1310
+ this.stateSubj$ = new BehaviorSubject(null);
1311
+ this.state$ = this.stateSubj$.asObservable().pipe(filter(isDefined));
1657
1312
  }
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;
1313
+ get state() {
1314
+ return this.stateSubj$.getValue();
1680
1315
  }
1681
1316
  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
- });
1317
+ this.stateSubj$.next(null);
1889
1318
  }
1890
- extendedConfigureLineItem$({ configurationRequest, runtimeModel, pricingEnabled, }) {
1891
- return this.configurationApiService.configureLineItem({
1892
- configurationRequest: configurationRequest,
1893
- runtimeModel,
1894
- pricingEnabled,
1895
- });
1319
+ setState(state) {
1320
+ this.stateSubj$.next(state);
1896
1321
  }
1897
1322
  }
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: [{
1323
+ CatalogProductsService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: CatalogProductsService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
1324
+ CatalogProductsService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: CatalogProductsService });
1325
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: CatalogProductsService, decorators: [{
1901
1326
  type: Injectable
1902
- }], ctorParameters: function () { return [{ type: QuoteDraftService }, { type: ConfigurationRuntimeService }, { type: i1.ConfigurationApiService }, { type: i4.MessageService }, { type: i5.DialogService }, { type: RuntimeSettingsService }, { type: FlowInfoService }]; } });
1327
+ }] });
1903
1328
 
1904
1329
  class ConfigurationStateService {
1905
- constructor(configurationRuntimeService, configurationService,
1906
- // private quoteDraftService: QuoteDraftService,
1907
- salesTransactionService, toastService, flowStateService, flowInfoService, flowConfigurationService, flowStateApiService,
1908
- // private quoteApiService: QuoteApiService,
1909
- salesTransactionApiService) {
1330
+ constructor(configurationRuntimeService, configurationService, flowStateService, flowInfoService, flowConfigurationService, flowStateApiService, salesTransactionService, salesTransactionApiService, toastService) {
1910
1331
  this.configurationRuntimeService = configurationRuntimeService;
1911
1332
  this.configurationService = configurationService;
1912
- this.salesTransactionService = salesTransactionService;
1913
- this.toastService = toastService;
1914
1333
  this.flowStateService = flowStateService;
1915
1334
  this.flowInfoService = flowInfoService;
1916
1335
  this.flowConfigurationService = flowConfigurationService;
1917
1336
  this.flowStateApiService = flowStateApiService;
1337
+ this.salesTransactionService = salesTransactionService;
1918
1338
  this.salesTransactionApiService = salesTransactionApiService;
1339
+ this.toastService = toastService;
1919
1340
  this.isInitialized$ = new BehaviorSubject(false);
1920
1341
  this.canceledConfiguration$ = new Subject();
1921
1342
  this.NOT_INITIALIZED = Symbol();
@@ -1939,9 +1360,9 @@ class ConfigurationStateService {
1939
1360
  request$ = this.initStateful$();
1940
1361
  }
1941
1362
  else {
1942
- request$ = of(undefined);
1363
+ request$ = this.configurationService.init$();
1943
1364
  }
1944
- return request$.pipe(take(1), tap$1(() => {
1365
+ return request$.pipe(take(1), tap(() => {
1945
1366
  this.isInitialized$.next(true);
1946
1367
  this.canceledConfiguration$ = new Subject();
1947
1368
  }));
@@ -1955,10 +1376,11 @@ class ConfigurationStateService {
1955
1376
  this.configurationStore = {};
1956
1377
  this.executedFunctions = {};
1957
1378
  this.configurationService.reset();
1379
+ this.configurationRuntimeService.reset();
1958
1380
  }
1959
1381
  execute$(exec) {
1960
1382
  const request = this.execToRequest(exec);
1961
- return this.executeRequest$(request).pipe(map$1(result => {
1383
+ return this.executeRequest$(request).pipe(map(result => {
1962
1384
  // Keep only requested results
1963
1385
  const actualSelectors = Object.entries(result.selectors).reduce((trunk, [requestId, result]) => {
1964
1386
  if (exec.selectors?.[requestId]) {
@@ -1980,7 +1402,7 @@ class ConfigurationStateService {
1980
1402
  }
1981
1403
  // prevent parallel configuration requests in stateless mode
1982
1404
  if (!this.statelessExecutionRequest$) {
1983
- this.statelessExecutionRequest$ = executionRequest$.pipe(shareReplay(), take(1), finalize(() => (this.statelessExecutionRequest$ = null)));
1405
+ this.statelessExecutionRequest$ = executionRequest$.pipe(shareReplay(), take(1), finalize$1(() => (this.statelessExecutionRequest$ = null)));
1984
1406
  }
1985
1407
  return this.statelessExecutionRequest$;
1986
1408
  }
@@ -1994,7 +1416,7 @@ class ConfigurationStateService {
1994
1416
  },
1995
1417
  },
1996
1418
  });
1997
- return this.executeRequest$(request).pipe(map$1(response => response.selectors[requestId]));
1419
+ return this.executeRequest$(request).pipe(map(response => response.selectors[requestId]));
1998
1420
  }
1999
1421
  subscribe$(selectorName, inputData = {}, options) {
2000
1422
  const requestId = UUID.UUID();
@@ -2017,7 +1439,7 @@ class ConfigurationStateService {
2017
1439
  this.executeRequest$(request).subscribe();
2018
1440
  }
2019
1441
  }
2020
- return subscription.data$.pipe(filter(data => data != this.NOT_INITIALIZED), map$1(data => data), distinctUntilChanged(), finalize(() => {
1442
+ return subscription.data$.pipe(filter(data => data != this.NOT_INITIALIZED), map(data => data), distinctUntilChanged(), finalize$1(() => {
2021
1443
  if (!this.subscriptions[requestId]?.data$.observed) {
2022
1444
  delete this.subscriptions[requestId];
2023
1445
  }
@@ -2025,7 +1447,7 @@ class ConfigurationStateService {
2025
1447
  }
2026
1448
  saveConfiguration() {
2027
1449
  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 })));
1450
+ 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
1451
  }
2030
1452
  const state = this.salesTransactionService.state;
2031
1453
  if (!state) {
@@ -2033,29 +1455,34 @@ class ConfigurationStateService {
2033
1455
  }
2034
1456
  const { standalone } = this.flowInfoService.flow.properties;
2035
1457
  if (standalone) {
2036
- return this.salesTransactionApiService.upsert(state);
2037
- }
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: '' })));
1458
+ const request = {
1459
+ transactionContext: state,
1460
+ flowId: this.flowInfoService.flow.id,
1461
+ };
1462
+ return this.salesTransactionApiService.save(request).pipe(switchMap(r => this.flowStateService.executeRequest$({}, true).pipe(map(() => r))), map(id => ({ id })));
1463
+ }
1464
+ const transactionContext = this.salesTransactionService.state;
1465
+ const configurationRoot = this.configurationService.root;
1466
+ if (!transactionContext || !configurationRoot) {
1467
+ return of({ id: '' });
1468
+ }
1469
+ const stateItems = transactionContext.salesTransaction.salesTransactionItems;
1470
+ const isNewTransactionItem = stateItems.every(ti => ti.id !== configurationRoot.id);
1471
+ let salesTransactionItems;
1472
+ if (isNewTransactionItem) {
1473
+ salesTransactionItems = [...stateItems, configurationRoot];
1474
+ }
1475
+ else {
1476
+ salesTransactionItems = stateItems.map(ti => (ti.id === configurationRoot.id ? configurationRoot : ti));
1477
+ }
1478
+ const newState = {
1479
+ ...transactionContext,
1480
+ salesTransaction: {
1481
+ ...transactionContext.salesTransaction,
1482
+ salesTransactionItems,
1483
+ },
1484
+ };
1485
+ return this.flowConfigurationService.calculate$(newState).pipe(switchMap(() => this.flowStateService.executeRequest$({}, true)), map(() => ({ id: '' })));
2059
1486
  }
2060
1487
  cancelConfiguration() {
2061
1488
  if (!this.isInitialized$.value) {
@@ -2074,29 +1501,28 @@ class ConfigurationStateService {
2074
1501
  return this.flowInfoService.flow?.properties.stateful ?? false;
2075
1502
  }
2076
1503
  initStateful$() {
2077
- this.ownerId = this.configurationRuntimeService.runtimeContext?.uiDefinitionContainer?.id ?? '';
2078
- const lineItemId = this.configurationRuntimeService.runtimeContext?.properties?.lineItemId;
2079
- if (!this.flowStateService.stateId) {
1504
+ this.ownerId = this.configurationRuntimeService.uiDefinitionContainer?.id ?? '';
1505
+ const { productId, transactionItemId } = this.flowInfoService.context;
1506
+ if (!productId || !this.flowStateService.stateId) {
2080
1507
  return of(undefined);
2081
1508
  }
2082
- const container = this.configurationRuntimeService.runtimeContext?.uiDefinitionContainer;
2083
- const lineItem = this.configurationService.generateLineItem();
1509
+ const container = this.configurationRuntimeService.uiDefinitionContainer;
2084
1510
  let request$;
2085
- if (!lineItemId) {
1511
+ if (!transactionItemId) {
2086
1512
  request$ = this.flowStateApiService.newConfiguration(this.flowStateService.stateId, {
2087
- lineItem,
1513
+ transactionItem: generateTransactionItem(productId),
2088
1514
  actionsOverride: container?.actions?.map(processor => ({ ...processor, ownerId: this.ownerId })),
2089
1515
  selectorsOverride: container?.selectors?.map(processor => ({ ...processor, ownerId: this.ownerId })),
2090
1516
  });
2091
1517
  }
2092
1518
  else {
2093
1519
  request$ = this.flowStateApiService.startConfiguration(this.flowStateService.stateId, {
2094
- lineItemId,
1520
+ transactionItemId,
2095
1521
  actionsOverride: container?.actions?.map(processor => ({ ...processor, ownerId: this.ownerId })),
2096
1522
  selectorsOverride: container?.selectors?.map(processor => ({ ...processor, ownerId: this.ownerId })),
2097
1523
  });
2098
1524
  }
2099
- return request$.pipe(map$1(r => {
1525
+ return request$.pipe(map(r => {
2100
1526
  this.stateId = r.stateId;
2101
1527
  return undefined;
2102
1528
  }));
@@ -2140,37 +1566,35 @@ class ConfigurationStateService {
2140
1566
  else {
2141
1567
  execution$ = this.executeStateless$(fullRequest);
2142
1568
  }
2143
- return execution$.pipe(tap$1(result => this.handleSelectorsResponse(result.selectors)));
1569
+ return execution$.pipe(tap(result => this.handleSelectorsResponse(result.selectors)));
2144
1570
  }
2145
1571
  executeStateless$(request) {
2146
1572
  this.executionInProgress$.next(true);
2147
- return of(undefined).pipe(switchMap(() => {
1573
+ return this.configurationService.state$.pipe(first(), switchMap(state => {
2148
1574
  // Apply actions and execute configuration/price call
2149
1575
  // No need to run configuration if no actions in the request
2150
1576
  if (!request.actions?.length) {
2151
1577
  return of(undefined);
2152
1578
  }
2153
- let configurationRequest = this.configurationService.generateRequest(false);
2154
1579
  request.actions.forEach(action => {
2155
- configurationRequest = this.executeActionScript(configurationRequest, action) ?? configurationRequest;
1580
+ state = this.executeActionScript(state, action) ?? state;
2156
1581
  });
2157
- configurationRequest = ConfigurationTranslatorUtils.lightenConfigurationRequest(configurationRequest);
2158
- return this.configurationService.configureRequest$(configurationRequest);
2159
- }), map$1(() => {
1582
+ return this.configurationService.configure$(state);
1583
+ }), map(() => {
2160
1584
  // Run selectors and apply them to the state
2161
- const configurationState = this.configurationService.stateSnapshot;
1585
+ const configurationState = this.configurationService.state;
2162
1586
  if (!configurationState) {
2163
1587
  return { stateId: '', selectors: {} };
2164
1588
  }
2165
1589
  return this.runStatelessSelectors(request, configurationState);
2166
- }), tap$1(() => this.executionInProgress$.next(false)), catchError(error => {
2167
- const configurationState = this.configurationService.previousStateSnapshot;
1590
+ }), tap(() => this.executionInProgress$.next(false)), catchError$1(error => {
1591
+ const configurationState = this.configurationService.previousState;
2168
1592
  if (configurationState) {
2169
1593
  const selectorsResult = this.runStatelessSelectors(request, configurationState);
2170
1594
  this.handleSelectorsResponse(selectorsResult.selectors);
2171
1595
  }
2172
1596
  this.executionInProgress$.next(false);
2173
- if (!this.configurationRuntimeService.uiDefinitionProperties.suppressToastMessages) {
1597
+ if (!this.configurationRuntimeService.uiDefinitionProps.suppressToastMessages) {
2174
1598
  this.toastService.add({ severity: ToastType.error, summary: String(error) });
2175
1599
  }
2176
1600
  return throwError(() => error);
@@ -2191,7 +1615,7 @@ class ConfigurationStateService {
2191
1615
  };
2192
1616
  this.executionInProgress$.next(true);
2193
1617
  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 => {
1618
+ }), tap(({ stateId }) => (this.stateId = stateId)), share(), tap(() => this.executionInProgress$.next(false)), catchError$1(e => {
2195
1619
  this.executionInProgress$.next(false);
2196
1620
  return throwError(() => e);
2197
1621
  }));
@@ -2201,11 +1625,11 @@ class ConfigurationStateService {
2201
1625
  // make sure stream switches to statefulExecutionRequest$ before pushing an execution request
2202
1626
  combineLatest([
2203
1627
  this.statefulExecutionRequest$,
2204
- of(undefined).pipe(tap$1(() => this.statefulRequestStream$.next(request))),
2205
- ])), map$1(([response]) => response), take(1));
1628
+ of(undefined).pipe(tap(() => this.statefulRequestStream$.next(request))),
1629
+ ])), map(([response]) => response), take(1));
2206
1630
  }
2207
1631
  executeActionScript(request, processor) {
2208
- const { actions } = this.configurationRuntimeService.runtimeContext?.uiDefinitionContainer ?? {};
1632
+ const { actions } = this.configurationRuntimeService.uiDefinitionContainer ?? {};
2209
1633
  const configurationProcessor = actions?.find(action => action.apiName === processor.apiName);
2210
1634
  if (!configurationProcessor?.script) {
2211
1635
  throw `ConfigurationProcessor ${processor.apiName} not found`;
@@ -2213,7 +1637,7 @@ class ConfigurationStateService {
2213
1637
  return this.executeProcessorScript(request, configurationProcessor, processor.inputData);
2214
1638
  }
2215
1639
  executeSelectorScript(request, processor) {
2216
- const { selectors } = this.configurationRuntimeService.runtimeContext?.uiDefinitionContainer ?? {};
1640
+ const { selectors } = this.configurationRuntimeService.uiDefinitionContainer ?? {};
2217
1641
  const configurationProcessor = selectors?.find(selector => selector.apiName === processor.apiName);
2218
1642
  if (!configurationProcessor?.script) {
2219
1643
  throw `ConfigurationProcessor ${processor.apiName} not found`;
@@ -2254,46 +1678,54 @@ class ConfigurationStateService {
2254
1678
  }, { stateId: '', selectors: {} });
2255
1679
  }
2256
1680
  }
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 });
1681
+ 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: i3.FlowStateApiService }, { token: SalesTransactionService }, { token: i1.SalesTransactionApiService }, { token: i6.ToastService }], target: i0.ɵɵFactoryTarget.Injectable });
2258
1682
  ConfigurationStateService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: ConfigurationStateService });
2259
1683
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: ConfigurationStateService, decorators: [{
2260
1684
  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 }]; } });
1685
+ }], ctorParameters: function () { return [{ type: ConfigurationRuntimeService }, { type: ConfigurationService }, { type: FlowStateService }, { type: FlowInfoService }, { type: FlowConfigurationService }, { type: i3.FlowStateApiService }, { type: SalesTransactionService }, { type: i1.SalesTransactionApiService }, { type: i6.ToastService }]; } });
2262
1686
 
2263
1687
  class ConfigurationModule {
2264
1688
  }
2265
1689
  ConfigurationModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: ConfigurationModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
2266
1690
  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] });
1691
+ ConfigurationModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: ConfigurationModule, providers: [
1692
+ ConfigurationService,
1693
+ ConfigurationStateService,
1694
+ ConfigurationRuntimeService,
1695
+ TestModeConfigurationService,
1696
+ GuidedSellingService,
1697
+ ], imports: [ConfirmationDialogModule, ApiModule] });
2268
1698
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: ConfigurationModule, decorators: [{
2269
1699
  type: NgModule,
2270
1700
  args: [{
2271
1701
  imports: [ConfirmationDialogModule, ApiModule],
2272
- providers: [ConfigurationRuntimeService, RuntimeContextService, ConfigurationService, ConfigurationStateService],
1702
+ providers: [
1703
+ ConfigurationService,
1704
+ ConfigurationStateService,
1705
+ ConfigurationRuntimeService,
1706
+ TestModeConfigurationService,
1707
+ GuidedSellingService,
1708
+ ],
2273
1709
  }]
2274
1710
  }] });
2275
1711
 
2276
- class CatalogProductsService {
2277
- constructor() {
2278
- this.stateSubj$ = new BehaviorSubject(null);
2279
- this.state$ = this.stateSubj$.asObservable().pipe(filter(isDefined));
2280
- }
2281
- get state() {
2282
- return this.stateSubj$.getValue();
2283
- }
2284
- reset() {
2285
- this.stateSubj$.next(null);
2286
- }
2287
- setState(state) {
2288
- this.stateSubj$.next(state);
2289
- }
1712
+ class FlowConfigurationModule {
2290
1713
  }
2291
- CatalogProductsService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: CatalogProductsService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
2292
- CatalogProductsServiceprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: CatalogProductsService });
2293
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: CatalogProductsService, decorators: [{
2294
- type: Injectable
1714
+ FlowConfigurationModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: FlowConfigurationModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
1715
+ FlowConfigurationModulemod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "15.2.9", ngImport: i0, type: FlowConfigurationModule, imports: [ApiModule] });
1716
+ FlowConfigurationModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: FlowConfigurationModule, providers: [FlowConfigurationService], imports: [ApiModule] });
1717
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: FlowConfigurationModule, decorators: [{
1718
+ type: NgModule,
1719
+ args: [{
1720
+ imports: [ApiModule],
1721
+ providers: [FlowConfigurationService],
1722
+ }]
2295
1723
  }] });
2296
1724
 
1725
+ const FORMATTING_SETTINGS_TOKEN = new InjectionToken('Summary of formatting settings for variant types of data, e.g. numbers, text, dates, etc');
1726
+
1727
+ const UI_DEFINITION_VERSION = 3;
1728
+
2297
1729
  const DEFAULT_FORMATTING_SETTINGS = {
2298
1730
  currencySymbol: DEFAULT_CURRENCY_SYMBOL,
2299
1731
  decimalsCount: DEFAULT_DECIMALS_COUNT,
@@ -2308,7 +1740,6 @@ SdkCoreModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "
2308
1740
  SdkCoreModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "15.2.9", ngImport: i0, type: SdkCoreModule, imports: [ConfigurationModule, FlowConfigurationModule] });
2309
1741
  SdkCoreModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: SdkCoreModule, providers: [
2310
1742
  FlowInfoService,
2311
- QuoteDraftService,
2312
1743
  ProductImagesService,
2313
1744
  IntegrationState,
2314
1745
  FlowStateService,
@@ -2327,7 +1758,6 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImpor
2327
1758
  imports: [ConfigurationModule, FlowConfigurationModule],
2328
1759
  providers: [
2329
1760
  FlowInfoService,
2330
- QuoteDraftService,
2331
1761
  ProductImagesService,
2332
1762
  IntegrationState,
2333
1763
  FlowStateService,
@@ -2390,6 +1820,10 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImpor
2390
1820
  }]
2391
1821
  }] });
2392
1822
 
1823
+ function filterSuccessfulExecute() {
1824
+ return (source) => source.pipe(filter((result) => result.success), map(r => r.result));
1825
+ }
1826
+
2393
1827
  class DatePipe {
2394
1828
  constructor() {
2395
1829
  this.locale = inject(LOCALE_ID);
@@ -2509,5 +1943,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImpor
2509
1943
  * Generated bundle index. Do not edit.
2510
1944
  */
2511
1945
 
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 };
1946
+ export { ActionCodePipe, CalendarDirective, CatalogProductsService, ConfigurationRuntimeService, ConfigurationService, ConfigurationStateService, DEFAULT_FORMATTING_SETTINGS, DatePipe, FLOW_CUSTOMIZATION, FORMATTING_SETTINGS_TOKEN, FlowConfigurationService, FlowInfoService, FlowStateConfigurationService, FlowStateService, GuidedSellingService, IntegrationState, NumberPipe, PricePipe, ProductImagesService, RuntimeSettingsService, SalesTransactionService, SdkCoreModule, SdkDirectivesModule, SdkPipesModule, TestModeConfigurationService, TransactionItemWorker, UI_DEFINITION_VERSION, extractMetadata, filterSuccessfulExecute, findTransactionItem, findTransactionItemWithComparator, generateTransactionItem, insertTransactionItem, removeTransactionItem, replaceTransactionItem };
2513
1947
  //# sourceMappingURL=veloceapps-sdk-core.mjs.map