@veloceapps/sdk 7.0.2-9 → 8.0.0-0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (201) hide show
  1. package/cms/cms.actions.d.ts +102 -11
  2. package/cms/cms.default.d.ts +2 -2
  3. package/cms/components/element-children/element-children.component.d.ts +3 -1
  4. package/cms/components/element-tools-panel/element-tools-panel.component.d.ts +14 -0
  5. package/cms/components/preview/preview.component.d.ts +10 -12
  6. package/cms/components/preview/preview.module.d.ts +2 -1
  7. package/cms/components/preview/preview.types.d.ts +9 -0
  8. package/cms/definitions/index.d.ts +1 -0
  9. package/cms/definitions/ui-builder.definitions.d.ts +6 -0
  10. package/cms/index.d.ts +2 -0
  11. package/cms/injection-tokens.d.ts +2 -4
  12. package/cms/modules/migrations/services/migrations.service.d.ts +1 -1
  13. package/cms/modules/migrations/types/migrations.types.d.ts +1 -1
  14. package/cms/modules/runtime/index.d.ts +1 -0
  15. package/cms/modules/runtime/services/compilation.service.d.ts +3 -2
  16. package/cms/modules/runtime/services/runtime-editor.service.d.ts +6 -4
  17. package/cms/modules/runtime/services/runtime.service.d.ts +6 -2
  18. package/cms/modules/runtime/types/runtime.actions.d.ts +5 -2
  19. package/cms/plugins/element-hover.plugin.d.ts +33 -0
  20. package/cms/plugins/page.plugin.d.ts +15 -0
  21. package/cms/plugins/script.plugin.d.ts +0 -3
  22. package/cms/services/resources.service.d.ts +9 -0
  23. package/cms/types/common.types.d.ts +11 -1
  24. package/cms/types/index.d.ts +2 -0
  25. package/cms/types/integration.types.d.ts +1 -0
  26. package/cms/types/layouts.types.d.ts +30 -2
  27. package/cms/types/pages.types.d.ts +1 -0
  28. package/cms/utils/element.utils.d.ts +1 -1
  29. package/cms/utils/elements-resolver.d.ts +6 -2
  30. package/cms/utils/encoding.utils.d.ts +2 -0
  31. package/cms/utils/index.d.ts +1 -0
  32. package/cms/utils/script.utils.d.ts +2 -0
  33. package/cms/utils/ui-builder-layout.utils.d.ts +4 -0
  34. package/cms/vendor-map.d.ts +16 -19
  35. package/core/core.module.d.ts +2 -0
  36. package/core/directives/directives.module.d.ts +7 -0
  37. package/core/directives/index.d.ts +2 -0
  38. package/core/directives/primeng-calendar.directive.d.ts +14 -0
  39. package/core/index.d.ts +2 -0
  40. package/core/modules/configuration/helpers.d.ts +4 -2
  41. package/core/modules/configuration/index.d.ts +2 -0
  42. package/core/modules/configuration/services/configuration-runtime.service.d.ts +5 -4
  43. package/core/modules/configuration/services/configuration.service.d.ts +13 -7
  44. package/core/modules/configuration/services/configuration.state.d.ts +30 -0
  45. package/core/modules/configuration/services/runtime-context.service.d.ts +1 -1
  46. package/core/modules/configuration/types/configuration-runtime.types.d.ts +1 -0
  47. package/core/modules/configuration/types/configuration.types.d.ts +10 -0
  48. package/core/modules/flow-configuration/services/flow-configuration.service.d.ts +2 -1
  49. package/core/pipes/date.pipe.d.ts +12 -0
  50. package/core/pipes/index.d.ts +4 -0
  51. package/core/pipes/number.pipe.d.ts +10 -0
  52. package/core/pipes/pipes.module.d.ts +9 -0
  53. package/core/pipes/price.pipe.d.ts +10 -0
  54. package/core/services/index.d.ts +1 -0
  55. package/core/services/runtime-settings.service.d.ts +21 -0
  56. package/core/types/formatting-settings.types.d.ts +11 -0
  57. package/core/types/index.d.ts +1 -0
  58. package/core/types/runtime.types.d.ts +2 -3
  59. package/core/types/ui-definition.types.d.ts +0 -40
  60. package/core/utils/line-item.utils.d.ts +10 -15
  61. package/core/utils/line-item.worker.d.ts +3 -6
  62. package/core/utils/ui-definition.utils.d.ts +1 -1
  63. package/esm2020/cms/cms.actions.mjs +140 -40
  64. package/esm2020/cms/cms.default.mjs +1 -1
  65. package/esm2020/cms/cms.elements.mjs +16 -4
  66. package/esm2020/cms/cms.layouts.mjs +73 -13
  67. package/esm2020/cms/components/element-children/element-children.component.mjs +11 -6
  68. package/esm2020/cms/components/element-drop-handle/element-drop-handle.component.mjs +2 -2
  69. package/esm2020/cms/components/element-tools-panel/element-tools-panel.component.mjs +35 -0
  70. package/esm2020/cms/components/preview/preview.component.mjs +30 -48
  71. package/esm2020/cms/components/preview/preview.module.mjs +22 -4
  72. package/esm2020/cms/components/preview/preview.types.mjs +1 -1
  73. package/esm2020/cms/definitions/index.mjs +2 -0
  74. package/esm2020/cms/definitions/ui-builder.definitions.mjs +18 -0
  75. package/esm2020/cms/index.mjs +3 -1
  76. package/esm2020/cms/injection-tokens.mjs +1 -2
  77. package/esm2020/cms/modules/migrations/migrations.mjs +10 -3
  78. package/esm2020/cms/modules/migrations/services/migrations.service.mjs +1 -1
  79. package/esm2020/cms/modules/migrations/types/migrations.types.mjs +1 -1
  80. package/esm2020/cms/modules/runtime/index.mjs +2 -1
  81. package/esm2020/cms/modules/runtime/services/compilation.service.mjs +5 -3
  82. package/esm2020/cms/modules/runtime/services/runtime-editor.service.mjs +5 -3
  83. package/esm2020/cms/modules/runtime/services/runtime.service.mjs +41 -6
  84. package/esm2020/cms/modules/runtime/types/runtime.actions.mjs +1 -1
  85. package/esm2020/cms/plugins/element-hover.plugin.mjs +121 -0
  86. package/esm2020/cms/plugins/page.plugin.mjs +37 -0
  87. package/esm2020/cms/plugins/region.plugin.mjs +3 -2
  88. package/esm2020/cms/plugins/script.plugin.mjs +6 -40
  89. package/esm2020/cms/services/integration.state.mjs +3 -6
  90. package/esm2020/cms/services/io-provider.service.mjs +7 -5
  91. package/esm2020/cms/services/resources.service.mjs +19 -1
  92. package/esm2020/cms/types/common.types.mjs +1 -1
  93. package/esm2020/cms/types/index.mjs +3 -1
  94. package/esm2020/cms/types/integration.types.mjs +1 -1
  95. package/esm2020/cms/types/layouts.types.mjs +70 -1
  96. package/esm2020/cms/types/pages.types.mjs +2 -0
  97. package/esm2020/cms/utils/element.utils.mjs +9 -9
  98. package/esm2020/cms/utils/elements-resolver.mjs +22 -8
  99. package/esm2020/cms/utils/encoding.utils.mjs +28 -0
  100. package/esm2020/cms/utils/index.mjs +2 -1
  101. package/esm2020/cms/utils/script.utils.mjs +42 -0
  102. package/esm2020/cms/utils/ui-builder-layout.utils.mjs +46 -0
  103. package/esm2020/cms/vendor-map.mjs +6 -3
  104. package/esm2020/core/core.module.mjs +33 -4
  105. package/esm2020/core/directives/directives.module.mjs +16 -0
  106. package/esm2020/core/directives/index.mjs +3 -0
  107. package/esm2020/core/directives/primeng-calendar.directive.mjs +41 -0
  108. package/esm2020/core/index.mjs +3 -1
  109. package/esm2020/core/modules/configuration/configuration.module.mjs +5 -2
  110. package/esm2020/core/modules/configuration/helpers.mjs +37 -7
  111. package/esm2020/core/modules/configuration/index.mjs +3 -1
  112. package/esm2020/core/modules/configuration/services/configuration-runtime.service.mjs +28 -19
  113. package/esm2020/core/modules/configuration/services/configuration.service.mjs +68 -28
  114. package/esm2020/core/modules/configuration/services/configuration.state.mjs +142 -0
  115. package/esm2020/core/modules/configuration/services/runtime-context.service.mjs +10 -17
  116. package/esm2020/core/modules/configuration/types/configuration-runtime.types.mjs +1 -1
  117. package/esm2020/core/modules/configuration/types/configuration.types.mjs +2 -0
  118. package/esm2020/core/modules/flow-configuration/services/flow-configuration.service.mjs +4 -4
  119. package/esm2020/core/pipes/date.pipe.mjs +38 -0
  120. package/esm2020/core/pipes/index.mjs +5 -0
  121. package/esm2020/core/pipes/number.pipe.mjs +27 -0
  122. package/esm2020/core/pipes/pipes.module.mjs +18 -0
  123. package/esm2020/core/pipes/price.pipe.mjs +30 -0
  124. package/esm2020/core/services/index.mjs +2 -1
  125. package/esm2020/core/services/quote-draft.service.mjs +1 -1
  126. package/esm2020/core/services/runtime-settings.service.mjs +95 -0
  127. package/esm2020/core/types/formatting-settings.types.mjs +3 -0
  128. package/esm2020/core/types/index.mjs +2 -1
  129. package/esm2020/core/types/runtime.types.mjs +1 -1
  130. package/esm2020/core/types/ui-definition.types.mjs +1 -1
  131. package/esm2020/core/utils/line-item.utils.mjs +24 -11
  132. package/esm2020/core/utils/line-item.worker.mjs +5 -5
  133. package/esm2020/core/utils/ui-definition.utils.mjs +1 -1
  134. package/esm2020/runtime/components/ui-runtime-preview/runtime-preview.component.mjs +2 -2
  135. package/esm2020/runtime/services/runtime-context.service.mjs +8 -5
  136. package/esm2020/runtime/services/runtime.service.mjs +1 -1
  137. package/esm2020/runtime/types/runtime.types.mjs +1 -1
  138. package/esm2020/src/components/dialog/dialog.component.mjs +3 -3
  139. package/esm2020/src/components/doc-gen/doc-gen.component.mjs +31 -8
  140. package/esm2020/src/components/guided-selling/guided-selling.component.mjs +117 -0
  141. package/esm2020/src/components/guided-selling/guided-selling.module.mjs +19 -0
  142. package/esm2020/src/components/header/cart-overlay/cart-preview.component.mjs +5 -6
  143. package/esm2020/src/components/header/cart-overlay/cart-preview.module.mjs +7 -4
  144. package/esm2020/src/components/header/header.component.mjs +46 -36
  145. package/esm2020/src/components/header/header.module.mjs +7 -3
  146. package/esm2020/src/components/header/metrics/metrics.component.mjs +35 -7
  147. package/esm2020/src/components/header/metrics/metrics.module.mjs +7 -3
  148. package/esm2020/src/flow-routing.module.mjs +1 -1
  149. package/esm2020/src/flow.component.mjs +4 -3
  150. package/esm2020/src/flow.module.mjs +11 -6
  151. package/esm2020/src/guards/context.guard.mjs +11 -8
  152. package/esm2020/src/pages/assets/assets.component.mjs +3 -3
  153. package/esm2020/src/pages/catalog/catalog.component.mjs +4 -4
  154. package/esm2020/src/pages/legacy-product/legacy-product.component.mjs +4 -4
  155. package/esm2020/src/pages/product/product.component.mjs +52 -61
  156. package/esm2020/src/pages/remote/remote.component.mjs +19 -19
  157. package/esm2020/src/pages/shopping-cart/shopping-cart.component.mjs +4 -4
  158. package/esm2020/src/services/flow-dialog.service.mjs +15 -15
  159. package/esm2020/src/services/flow-router.service.mjs +10 -5
  160. package/esm2020/src/services/flow.service.mjs +2 -2
  161. package/esm2020/src/services/guided-selling.service.mjs +33 -0
  162. package/esm2020/src/types/flow-customization.types.mjs +1 -1
  163. package/fesm2015/veloceapps-sdk-cms.mjs +947 -440
  164. package/fesm2015/veloceapps-sdk-cms.mjs.map +1 -1
  165. package/fesm2015/veloceapps-sdk-core.mjs +578 -89
  166. package/fesm2015/veloceapps-sdk-core.mjs.map +1 -1
  167. package/fesm2015/veloceapps-sdk-runtime.mjs +7 -4
  168. package/fesm2015/veloceapps-sdk-runtime.mjs.map +1 -1
  169. package/fesm2015/veloceapps-sdk.mjs +408 -186
  170. package/fesm2015/veloceapps-sdk.mjs.map +1 -1
  171. package/fesm2020/veloceapps-sdk-cms.mjs +1027 -442
  172. package/fesm2020/veloceapps-sdk-cms.mjs.map +1 -1
  173. package/fesm2020/veloceapps-sdk-core.mjs +563 -85
  174. package/fesm2020/veloceapps-sdk-core.mjs.map +1 -1
  175. package/fesm2020/veloceapps-sdk-runtime.mjs +7 -4
  176. package/fesm2020/veloceapps-sdk-runtime.mjs.map +1 -1
  177. package/fesm2020/veloceapps-sdk.mjs +397 -182
  178. package/fesm2020/veloceapps-sdk.mjs.map +1 -1
  179. package/package.json +4 -4
  180. package/runtime/components/ui-runtime-preview/runtime-preview.component.d.ts +3 -3
  181. package/runtime/services/runtime.service.d.ts +2 -2
  182. package/runtime/types/runtime.types.d.ts +2 -2
  183. package/src/components/doc-gen/doc-gen.component.d.ts +7 -3
  184. package/src/components/guided-selling/guided-selling.component.d.ts +29 -0
  185. package/src/components/guided-selling/guided-selling.module.d.ts +9 -0
  186. package/src/components/header/cart-overlay/cart-preview.component.d.ts +1 -1
  187. package/src/components/header/cart-overlay/cart-preview.module.d.ts +1 -1
  188. package/src/components/header/header.component.d.ts +3 -4
  189. package/src/components/header/header.module.d.ts +2 -1
  190. package/src/components/header/metrics/metrics.component.d.ts +10 -2
  191. package/src/components/header/metrics/metrics.module.d.ts +2 -1
  192. package/src/flow.module.d.ts +6 -5
  193. package/src/guards/context.guard.d.ts +3 -2
  194. package/src/pages/assets/assets.component.d.ts +2 -1
  195. package/src/pages/catalog/catalog.component.d.ts +2 -1
  196. package/src/pages/product/product.component.d.ts +13 -21
  197. package/src/pages/remote/remote.component.d.ts +4 -4
  198. package/src/pages/shopping-cart/shopping-cart.component.d.ts +2 -1
  199. package/src/services/flow-router.service.d.ts +3 -1
  200. package/src/services/guided-selling.service.d.ts +13 -0
  201. package/src/types/flow-customization.types.d.ts +4 -4
@@ -1,31 +1,66 @@
1
1
  import * as i0 from '@angular/core';
2
- import { Injectable, NgModule } from '@angular/core';
3
- import { UUID, ConfigurationContext, RuntimeModel, ConfigurationContextMode, SalesforceIdUtils, ConfigurationMode, ConfigurationTranslatorUtils, ChargeGroupUtils } from '@veloceapps/core';
2
+ import { Injectable, InjectionToken, NgModule, inject, Directive, Input, LOCALE_ID, Pipe } from '@angular/core';
3
+ import { UUID, ConfigurationContextMode, ConfigurationContext, RuntimeModel, getUIDefinitionProperties, isLegacyUIDefinition, SalesforceIdUtils, ConfigurationMode, ConfigurationTranslatorUtils, EntityUtil, ChargeGroupUtils, DEFAULT_CURRENCY_ISO_CODE, DEFAULT_CURRENCY_SYMBOL, validateDateFormat, DEFAULT_DATE_FORMAT, DEFAULT_DECIMALS_COUNT, getSupportedDateFormats, DEFAULT_DECIMAL_SEPARATOR, DEFAULT_THOUSANDS_SEPARATOR, parseJsonSafely, formatNumber } from '@veloceapps/core';
4
4
  import * as i1 from '@veloceapps/api';
5
5
  import { PriceApiService, ContextApiService, ProductModelApiService, ConfigurationApiService } from '@veloceapps/api';
6
- import { BehaviorSubject, combineLatest, zip, noop, throwError, shareReplay as shareReplay$1, tap as tap$1, map as map$2, of, switchMap as switchMap$1, catchError as catchError$1, Subject, take as take$1, distinctUntilChanged } from 'rxjs';
6
+ import { BehaviorSubject, combineLatest, zip, noop, throwError, shareReplay as shareReplay$1, switchMap as switchMap$1, of, tap as tap$1, map as map$2, catchError as catchError$1, Subject, take as take$1, distinctUntilChanged } from 'rxjs';
7
7
  import { filter, tap, map, first, switchMap, skip, take, shareReplay, catchError, finalize } from 'rxjs/operators';
8
- import { merge, isEqual, flatten, sortBy, map as map$1, omit, cloneDeep, uniq } from 'lodash';
8
+ import { merge, isEqual, flatten, sortBy, map as map$1, transform, omit, cloneDeep, uniq } from 'lodash';
9
+ import { HttpErrorResponse } from '@angular/common/http';
10
+ import * as i4 from '@veloceapps/components';
9
11
  import { ToastType, ConfirmationComponent, ConfirmationDialogModule } from '@veloceapps/components';
10
12
  import * as i5 from 'primeng/api';
11
13
  import * as i6 from 'primeng/dynamicdialog';
12
14
  import moment from 'moment';
15
+ import { NgControl } from '@angular/forms';
16
+ import 'primeng/calendar';
17
+ import { DATE_PIPE_DEFAULT_OPTIONS, formatDate } from '@angular/common';
13
18
 
14
19
  const getDefaultLineItem = (context, uiDefinitionProperties, qty = 1) => {
15
20
  const id = UUID.UUID();
16
- const lineItem = {
21
+ const attributes = [];
22
+ const lineItems = [];
23
+ return {
17
24
  id,
18
25
  type: uiDefinitionProperties.rootType ?? '',
19
26
  cfgStatus: 'Default',
20
27
  actionCode: 'ADD',
21
28
  qty,
29
+ attributes,
30
+ lineItems,
22
31
  productName: context.properties?.['displayName'] || context.productName,
23
32
  productId: context.productId ?? '',
24
- ...(context.offeringId
25
- ? { offeringId: context.offeringId, offeringInstanceId: context.offeringInstanceId || id }
26
- : {}),
33
+ ...(uiDefinitionProperties.offeringId ? { offeringId: uiDefinitionProperties.offeringId } : {}),
34
+ };
35
+ };
36
+ const getGuidedSellingConfigurationRequest = (data) => {
37
+ return {
38
+ mode: 'SEARCH',
39
+ step: 'START',
40
+ attributeDomainMode: 'ALL',
41
+ context: {
42
+ headerId: 'TestId',
43
+ mode: ConfigurationContextMode.TEST,
44
+ properties: {
45
+ ModelId: data.modelId,
46
+ Name: 'Veloce Guided Selling',
47
+ PricingEnabled: 'false',
48
+ RuntimeMode: 'TEST',
49
+ },
50
+ },
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
+ },
27
63
  };
28
- return lineItem;
29
64
  };
30
65
 
31
66
  class ContextService {
@@ -84,6 +119,8 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.8", ngImpor
84
119
  args: [{ providedIn: 'root' }]
85
120
  }], ctorParameters: function () { return [{ type: i1.ContextApiService }]; } });
86
121
 
122
+ const FORMATTING_SETTINGS_TOKEN = new InjectionToken('Summary of formatting settings for variant types of data, e.g. numbers, text, dates, etc');
123
+
87
124
  var RuntimeMode;
88
125
  (function (RuntimeMode) {
89
126
  RuntimeMode[RuntimeMode["TEST"] = 0] = "TEST";
@@ -108,35 +145,28 @@ class RuntimeContextService {
108
145
  }
109
146
  getRuntimeContext(productId, offeringId) {
110
147
  return this.configurationApiService.getRuntimeDataByProductId(productId, offeringId).pipe(map(runtimeData => {
111
- const uiDefinition = this.getUIDefinition(runtimeData);
148
+ const uiDefinitionContainer = this.getUIDefinitionContainer(runtimeData);
112
149
  const runtimeModel = RuntimeModel.create(runtimeData.types, runtimeData.products);
113
150
  const { productName, properties } = Array.from(runtimeModel.components.values()).find(c => c.productId === productId) ?? {};
151
+ const uiDefinitionProperties = getUIDefinitionProperties(uiDefinitionContainer);
114
152
  return {
115
153
  modelId: runtimeData.modelId,
116
- uiDefinition: uiDefinition,
154
+ uiDefinitionContainer: uiDefinitionContainer,
117
155
  runtimeModel: runtimeModel,
118
156
  runtimeMode: RuntimeMode.PROD,
119
157
  productId: productId,
120
158
  productType: properties?.['displayName'] || productName,
121
159
  offeringId: offeringId,
122
160
  properties: {
123
- PricingEnabled: uiDefinition?.properties?.pricingEnabled ? 'true' : 'false',
124
- PriceListId: uiDefinition?.properties?.priceList,
161
+ PricingEnabled: uiDefinitionProperties.pricingEnabled ? 'true' : 'false',
162
+ PriceListId: uiDefinitionProperties.priceList,
125
163
  },
126
164
  };
127
165
  }));
128
166
  }
129
- getUIDefinition(runtimeData) {
130
- let rawUiDefinitions;
131
- try {
132
- rawUiDefinitions = JSON.parse(runtimeData.uiDefinitionsSource);
133
- }
134
- catch (e) {
135
- return;
136
- }
137
- const uiDefinitions = rawUiDefinitions.filter(uiDef => uiDef.version);
138
- const uiDefinition = uiDefinitions.find(uiDef => uiDef.primary) ?? uiDefinitions[0];
139
- return uiDefinition;
167
+ getUIDefinitionContainer(runtimeData) {
168
+ const containers = runtimeData.uiDefinitions.filter(container => !isLegacyUIDefinition(container.source));
169
+ return containers.find(container => container.source.primary) ?? containers[0];
140
170
  }
141
171
  }
142
172
  RuntimeContextService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.8", ngImport: i0, type: RuntimeContextService, deps: [{ token: i1.ConfigurationApiService }], target: i0.ɵɵFactoryTarget.Injectable });
@@ -159,39 +189,41 @@ class ConfigurationRuntimeService {
159
189
  this.initializationProps = undefined;
160
190
  this.uiDefinitionProperties = {};
161
191
  }
162
- initTestMode(modelId, uiDefinition) {
163
- this.uiDefinitionProperties = uiDefinition.properties ?? {};
164
- const uiDefinitionExternals = uiDefinition.externals ?? {};
192
+ initTestMode(uiDefinitionContainer) {
193
+ this.uiDefinitionProperties = getUIDefinitionProperties(uiDefinitionContainer);
194
+ const uiDefinitionExternals = uiDefinitionContainer.source.externals ?? {};
165
195
  return combineLatest([
166
- this.apiService.getRuntimeDataByModelId(modelId),
196
+ this.apiService.getRuntimeDataByModelId(uiDefinitionContainer.modelId),
167
197
  this.contextService.create('TestId', ConfigurationContextMode.TEST),
168
- ]).pipe(first(), tap(([runtimeData, context]) => {
169
- this._runtimeContext = {
170
- modelId: modelId,
171
- runtimeModel: RuntimeModel.create(runtimeData.types, runtimeData.products),
172
- runtimeMode: RuntimeMode.TEST,
173
- };
198
+ ]).pipe(first(), map(([runtimeData, context]) => {
174
199
  this.contextService.update({
175
200
  properties: {
176
201
  ...this.runtimeContext?.properties,
177
202
  ...context.properties,
178
- ModelId: modelId,
203
+ ModelId: uiDefinitionContainer.modelId,
179
204
  RuntimeMode: ConfigurationContextMode.TEST,
180
205
  PricingEnabled: this.uiDefinitionProperties.pricingEnabled ? 'true' : 'false',
181
206
  StartDate: new Date().toISOString().substring(0, 10),
182
207
  PriceListId: this.uiDefinitionProperties.priceList,
208
+ offeringId: this.uiDefinitionProperties.offeringId,
183
209
  standalone: 'true',
184
210
  ...uiDefinitionExternals,
185
211
  },
186
212
  });
187
- this._isInitialized = true;
188
- }));
213
+ this._runtimeContext = {
214
+ modelId: uiDefinitionContainer.modelId,
215
+ runtimeModel: RuntimeModel.create(runtimeData.types, runtimeData.products),
216
+ runtimeMode: RuntimeMode.TEST,
217
+ uiDefinitionContainer,
218
+ };
219
+ return this._runtimeContext;
220
+ }), tap(() => (this._isInitialized = true)));
189
221
  }
190
222
  init(props) {
191
223
  this.initializationProps = props;
192
224
  const context = this.contextService.resolve();
193
225
  return this.runtimeContextService.getRuntimeContext(props.productId, props.offeringId).pipe(tap(runtimeContext => {
194
- this.uiDefinitionProperties = runtimeContext.uiDefinition?.properties ?? {};
226
+ this.uiDefinitionProperties = getUIDefinitionProperties(runtimeContext.uiDefinitionContainer);
195
227
  const { PriceListId } = context.properties ?? {};
196
228
  const mergeContext = {
197
229
  ...runtimeContext,
@@ -211,8 +243,15 @@ class ConfigurationRuntimeService {
211
243
  },
212
244
  });
213
245
  }
214
- this._isInitialized = true;
215
- }));
246
+ return this._runtimeContext;
247
+ }), tap(() => (this._isInitialized = true)));
248
+ }
249
+ overrideUIDefinition(uiDefinitionContainer) {
250
+ if (!this._runtimeContext) {
251
+ return;
252
+ }
253
+ this._runtimeContext.uiDefinitionContainer = uiDefinitionContainer;
254
+ this.uiDefinitionProperties = getUIDefinitionProperties(uiDefinitionContainer);
216
255
  }
217
256
  id15to18(propertyName, source) {
218
257
  if (!source) {
@@ -503,18 +542,25 @@ const removeLineItem = (lineItem, idToRemove) => {
503
542
  .filter(r => !!r),
504
543
  };
505
544
  };
506
- const replaceLineItem = (lineItem, replaceTo) => {
545
+ const replaceLineItem = (lineItem, replaceTo, skipCardinalityCalculation = false) => {
507
546
  if (lineItem.id === replaceTo.id) {
508
- return { ...recalculateCardinalityVariables(lineItem, replaceTo) };
547
+ if (!skipCardinalityCalculation) {
548
+ return { ...recalculateCardinalityVariables(lineItem, replaceTo) };
549
+ }
550
+ else {
551
+ return { ...replaceTo };
552
+ }
509
553
  }
510
554
  return {
511
555
  ...lineItem,
512
- lineItems: lineItem.lineItems.map(li => replaceLineItem(li, replaceTo)),
556
+ lineItems: lineItem.lineItems.map(li => replaceLineItem(li, replaceTo, skipCardinalityCalculation)),
513
557
  };
514
558
  };
515
559
  const calculateCardinalityVariables = (lineItems) => {
516
560
  const cardVars = new Map();
517
- lineItems.forEach(li => {
561
+ lineItems
562
+ .filter(({ port, type }) => !!port && !!type)
563
+ .forEach(li => {
518
564
  const cardinalityVariableName = `#CV-${li.type}@${li.port}`;
519
565
  cardVars.set(cardinalityVariableName, (cardVars.get(cardinalityVariableName) ?? 0) + li.qty);
520
566
  });
@@ -535,7 +581,7 @@ const recalculateCardinalityVariables = (original, updated) => {
535
581
  });
536
582
  return {
537
583
  ...updated,
538
- attributes: upsertAttributes(updated.attributes, [...cardinalityVariables].map(([name, value]) => ({ name, value }))),
584
+ attributes: upsertAttributes(updated.attributes, [...cardinalityVariables].map(([name, value]) => ({ name, value, cfgStatus: 'Changed' }))),
539
585
  };
540
586
  };
541
587
  const mapAttributes = (attributes) => {
@@ -550,17 +596,17 @@ const upsertAttributes = (originalAttributes, attributesToUpsert) => {
550
596
  const [origAttr] = getAttributes(acc, [name]);
551
597
  return [
552
598
  ...acc.filter(attr => attr.name !== name),
553
- { ...(origAttr ?? { name }), cfgStatus: 'User', value },
599
+ { ...(origAttr ?? { name }), cfgStatus: origAttr ? 'Changed' : 'User', value },
554
600
  ];
555
601
  }, originalAttributes);
556
602
  };
557
- const patchAttributes = (rootLineItem, id, attrs) => {
603
+ const patchAttributes = (rootLineItem, id, attrs, skipCardinalityCalculation = false) => {
558
604
  const lineItem = findLineItem(id, [rootLineItem]);
559
605
  if (!lineItem) {
560
606
  return rootLineItem;
561
607
  }
562
608
  const attributes = upsertAttributes(lineItem.attributes, attrs);
563
- return replaceLineItem(rootLineItem, { ...lineItem, attributes });
609
+ return replaceLineItem(rootLineItem, { ...lineItem, attributes }, skipCardinalityCalculation);
564
610
  };
565
611
  const getAttributeValue = (attributes, name) => attributes.find(attr => attr.name === name)?.value;
566
612
  const generateLineItem = (port, type, parentId, attributes = [], lineItems = []) => {
@@ -608,10 +654,10 @@ const getOriginParent = (lineItems, currentLineItem) => {
608
654
  return target;
609
655
  };
610
656
  const isLineItemModified = (lineItem) => {
611
- if (lineItem.status === 'PENDING' && lineItem.actionCode === 'EXIST') {
657
+ if (lineItem.actionCode === 'EXIST' && lineItem.status === 'PENDING') {
612
658
  return false;
613
659
  }
614
- return lineItem.status !== 'EXIST';
660
+ return lineItem.actionCode !== 'EXIST';
615
661
  };
616
662
  const multiplyLineItems = (lineItem, qty, split) => {
617
663
  if (split) {
@@ -631,10 +677,17 @@ const multiplyLineItems = (lineItem, qty, split) => {
631
677
  ];
632
678
  }
633
679
  };
680
+ const isTechnicalAttribute = (name) => {
681
+ return name.startsWith('#') || name.startsWith('$');
682
+ };
683
+ const filterOutTechnicalAttributes = (attributes) => {
684
+ return attributes.filter(({ name }) => !isTechnicalAttribute(name));
685
+ };
634
686
 
635
687
  var lineItem_utils = /*#__PURE__*/Object.freeze({
636
688
  __proto__: null,
637
689
  calculateCardinalityVariables: calculateCardinalityVariables,
690
+ filterOutTechnicalAttributes: filterOutTechnicalAttributes,
638
691
  findLineItem: findLineItem,
639
692
  findLineItemWithComparator: findLineItemWithComparator,
640
693
  generateLineItem: generateLineItem,
@@ -645,6 +698,7 @@ var lineItem_utils = /*#__PURE__*/Object.freeze({
645
698
  getRecommendedPrices: getRecommendedPrices,
646
699
  insertLineItem: insertLineItem,
647
700
  isLineItemModified: isLineItemModified,
701
+ isTechnicalAttribute: isTechnicalAttribute,
648
702
  mapAttributes: mapAttributes,
649
703
  multiplyLineItems: multiplyLineItems,
650
704
  patchAttributes: patchAttributes,
@@ -664,11 +718,11 @@ class LineItemWorker {
664
718
  remove(id) {
665
719
  return new LineItemWorker(removeLineItem(this.li, id));
666
720
  }
667
- replace(toReplace) {
668
- return new LineItemWorker(replaceLineItem(this.li, toReplace));
721
+ replace(toReplace, skipCardinalityCalculation = false) {
722
+ return new LineItemWorker(replaceLineItem(this.li, toReplace, skipCardinalityCalculation));
669
723
  }
670
- patchAttribute(attrs, id) {
671
- return new LineItemWorker(patchAttributes(this.li, id ?? this.li.id, attrs));
724
+ patchAttribute(attrs, id, skipCardinalityCalculation = false) {
725
+ return new LineItemWorker(patchAttributes(this.li, id ?? this.li.id, attrs, skipCardinalityCalculation));
672
726
  }
673
727
  }
674
728
 
@@ -684,6 +738,8 @@ class ConfigurationService {
684
738
  this.lineItem = new BehaviorSubject(undefined);
685
739
  this.charges = new BehaviorSubject({});
686
740
  this.pricePlans = new BehaviorSubject({});
741
+ this.isLoadingSubj$ = new BehaviorSubject(false);
742
+ this.isLoading$ = this.isLoadingSubj$.asObservable();
687
743
  this.hasUnsavedChanges = false;
688
744
  }
689
745
  reset() {
@@ -694,11 +750,12 @@ class ConfigurationService {
694
750
  this.charges.next({});
695
751
  this.pricePlans.next({});
696
752
  }
697
- patch$(lineItem) {
753
+ patch$(lineItem, options) {
698
754
  if (!this.lineItem.value) {
699
755
  return throwError(() => new Error(`Source LineItem not found`));
700
756
  }
701
- this.configurableRamp = new LineItemWorker(this.lineItem.value).replace(lineItem).li;
757
+ const skipCardinalityCalculation = options?.skipCardinalityCalculation || this.contextSnapshot.properties['#skipCardinalityCalculation'] === 'true';
758
+ this.configurableRamp = new LineItemWorker(this.lineItem.value).replace(lineItem, skipCardinalityCalculation).li;
702
759
  return this.configure().pipe(catchError(error => {
703
760
  console.error(error);
704
761
  if (!this.runtimeService.uiDefinitionProperties.suppressToastMessages) {
@@ -713,8 +770,8 @@ class ConfigurationService {
713
770
  }
714
771
  }));
715
772
  }
716
- patch(lineItem) {
717
- this.patch$(lineItem).subscribe();
773
+ patch(lineItem, options) {
774
+ this.patch$(lineItem, options).subscribe();
718
775
  }
719
776
  setConfigurableRamp(lineItem) {
720
777
  this.configurableRamp = lineItem;
@@ -726,10 +783,18 @@ class ConfigurationService {
726
783
  return this.lineItem.value ? { ...this.lineItem.value } : undefined;
727
784
  }
728
785
  getRuntimeModel() {
729
- return this.runtimeService.runtimeModel;
786
+ const runtimeModel = this.runtimeService.runtimeModel;
787
+ if (!runtimeModel) {
788
+ throw new Error('Runtime model not initialized');
789
+ }
790
+ return runtimeModel;
730
791
  }
731
792
  getRuntimeContext() {
732
- return this.runtimeService.runtimeContext;
793
+ const runtimeContext = this.runtimeService.runtimeContext;
794
+ if (!runtimeContext) {
795
+ throw new Error('Runtime context not initialized');
796
+ }
797
+ return runtimeContext;
733
798
  }
734
799
  get contextSnapshot() {
735
800
  return this.contextService.resolve();
@@ -750,40 +815,61 @@ class ConfigurationService {
750
815
  return this.pricePlans.value;
751
816
  }
752
817
  configure() {
818
+ return this.configureRequest$(this.generateRequest());
819
+ }
820
+ configureRequest$(configurationRequest) {
753
821
  const runtimeContext = this.getRuntimeContext();
754
822
  const runtimeModel = this.getRuntimeModel();
755
- if (!runtimeContext || !runtimeModel) {
756
- return throwError(() => new Error('Runtime context/model not initialized'));
757
- }
758
- const uiDefinitionProperties = {
759
- ...(runtimeContext.uiDefinition?.properties ?? {}),
760
- ...(this.runtimeService.uiDefinitionProperties ?? {}),
761
- };
762
- const qty = this.runtimeService.initializationProps?.defaultQty;
763
- const lineItem = this.configurableRamp ?? getDefaultLineItem(runtimeContext, uiDefinitionProperties, qty);
764
- const configurationRequest = this.createRequest(lineItem);
823
+ const uiDefinitionProperties = this.getUIDefinitionProperties();
765
824
  const mainPricingEnabled = runtimeContext.properties?.PricingEnabled;
766
825
  const pricingEnabled = mainPricingEnabled ? mainPricingEnabled === 'true' : uiDefinitionProperties.pricingEnabled;
767
- return this.configurationApiService
768
- .configureLineItem({ configurationRequest, runtimeModel, pricingEnabled })
769
- .pipe(map(({ lineItem, context, charges, pricePlans, deletedLineItems }) => {
826
+ this.isLoadingSubj$.next(true);
827
+ return this.configurationApiService.configureLineItem({ configurationRequest, runtimeModel, pricingEnabled }).pipe(tap(({ lineItem, context, charges, pricePlans, deletedLineItems }) => {
770
828
  this.contextService.update(context ?? {});
771
829
  this.charges.next(charges ?? {});
772
830
  this.pricePlans.next(pricePlans ?? {});
831
+ if (lineItem) {
832
+ this.lineItem.next(lineItem);
833
+ }
773
834
  if (deletedLineItems?.length) {
774
835
  this.showInactiveProductsConfirmation();
775
836
  }
776
- return lineItem;
777
- }))
778
- .pipe(tap(lineItem => lineItem && this.lineItem.next(lineItem)), catchError(error => throwError(() => new Error(error.error?.message || error.message || JSON.stringify(error)))));
837
+ this.configurableRamp = lineItem;
838
+ }), map(({ lineItem }) => lineItem), catchError(error => throwError(() => new Error(error.error?.message || error.message || JSON.stringify(error)))), finalize(() => this.isLoadingSubj$.next(false)));
779
839
  }
780
- configureExternal$(productId, qty) {
781
- return this.runtimeService.init({ productId, defaultQty: qty }).pipe(switchMap(() => this.configure()), first(), catchError(error => {
840
+ configureExternal$(props) {
841
+ return this.runtimeService
842
+ .init({ productId: props.productId, defaultQty: props.qty, attributesMap: props.attributesMap })
843
+ .pipe(switchMap(() => this.configure()), first(), catchError(error => {
782
844
  this.messageService.add({ severity: ToastType.error, summary: error });
783
845
  throw error;
784
846
  }), finalize(() => this.reset()));
785
847
  }
786
- createRequest(lineItem) {
848
+ configureGuidedSelling$(data) {
849
+ return this.configurationApiService
850
+ .configureLineItem({
851
+ configurationRequest: getGuidedSellingConfigurationRequest(data),
852
+ })
853
+ .pipe(catchError(error => {
854
+ if (error instanceof HttpErrorResponse) {
855
+ this.messageService.add({ severity: ToastType.error, summary: error.error.message || error.error });
856
+ }
857
+ throw error;
858
+ }));
859
+ }
860
+ generateRequest() {
861
+ const runtimeContext = this.getRuntimeContext();
862
+ const uiDefinitionProperties = this.getUIDefinitionProperties();
863
+ let lineItem = this.configurableRamp;
864
+ if (!lineItem) {
865
+ const { initializationProps } = this.runtimeService ?? {};
866
+ lineItem = getDefaultLineItem(runtimeContext, uiDefinitionProperties, initializationProps?.defaultQty);
867
+ // Set default attributes
868
+ if (initializationProps?.attributesMap) {
869
+ const attributes = transform(initializationProps?.attributesMap, (acc, value, name) => acc.push({ name, value }), []);
870
+ lineItem = new LineItemWorker(lineItem).patchAttribute(attributes).li;
871
+ }
872
+ }
787
873
  let request = {
788
874
  lineItem,
789
875
  mode: this.mode,
@@ -796,6 +882,12 @@ class ConfigurationService {
796
882
  request = ConfigurationTranslatorUtils.lightenConfigurationRequest(request);
797
883
  return request;
798
884
  }
885
+ getUIDefinitionProperties() {
886
+ return {
887
+ ...getUIDefinitionProperties(this.getRuntimeContext().uiDefinitionContainer),
888
+ ...(this.runtimeService.uiDefinitionProperties ?? {}),
889
+ };
890
+ }
799
891
  showInactiveProductsConfirmation() {
800
892
  const confirmationConfig = {
801
893
  title: ' ',
@@ -834,6 +926,135 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.8", ngImpor
834
926
  type: Injectable
835
927
  }], ctorParameters: function () { return [{ type: QuoteDraftService }, { type: ConfigurationRuntimeService }, { type: ContextService }, { type: i1.ConfigurationApiService }, { type: i5.MessageService }, { type: i6.DialogService }]; } });
836
928
 
929
+ class ConfigurationState {
930
+ constructor(statefulConfigurationApiService, runtimeService, configurationService, toastService) {
931
+ this.statefulConfigurationApiService = statefulConfigurationApiService;
932
+ this.runtimeService = runtimeService;
933
+ this.configurationService = configurationService;
934
+ this.toastService = toastService;
935
+ this.stateSubj$ = new BehaviorSubject({});
936
+ this.state$ = this.stateSubj$.asObservable();
937
+ this.stateId = null;
938
+ }
939
+ init$() {
940
+ return this.configurationService.configure().pipe(switchMap$1(() => {
941
+ if (!this.isStatefulConfiguration) {
942
+ return of(undefined);
943
+ }
944
+ const { actions, selectors } = this.runtimeService.runtimeContext?.uiDefinitionContainer ?? {};
945
+ return this.statefulConfigurationApiService.init({
946
+ request: this.configurationService.generateRequest(),
947
+ actions: actions?.map(action => ({ name: action.apiName, script: action.script })),
948
+ selectors: selectors?.map(selector => ({ name: selector.apiName, script: selector.script })),
949
+ });
950
+ }), tap$1(stateId => (this.stateId = stateId || null)), map$2(() => undefined));
951
+ }
952
+ cleanup() {
953
+ this.stateId = null;
954
+ this.configurationService.reset();
955
+ this.stateSubj$.next({});
956
+ }
957
+ execute$(req) {
958
+ if (this.isStatefulConfiguration) {
959
+ return this.executeStateful$(req);
960
+ }
961
+ else {
962
+ return this.executeStateless$(req);
963
+ }
964
+ }
965
+ dispatch$(actionName, inputData) {
966
+ return this.execute$({ actions: [{ name: actionName, inputData }] });
967
+ }
968
+ select$(selectorName, inputData) {
969
+ const requestId = UUID.UUID();
970
+ return this.execute$({
971
+ selectors: {
972
+ [requestId]: {
973
+ name: selectorName,
974
+ inputData,
975
+ },
976
+ },
977
+ }).pipe(map$2(() => this.stateSubj$.value[requestId]), tap$1(() => this.stateSubj$.next(omit(this.stateSubj$.value, requestId))));
978
+ }
979
+ get isStatefulConfiguration() {
980
+ return this.runtimeService.uiDefinitionProperties.statefulConfigurationEnabled ?? false;
981
+ }
982
+ executeStateless$(request) {
983
+ return of(undefined).pipe(switchMap$1(() => {
984
+ // Apply actions and execute configuration/price call
985
+ // No need to run configuration if no actions in the request
986
+ if (!request.actions?.length) {
987
+ return of(undefined);
988
+ }
989
+ let configurationRequest = this.configurationService.generateRequest();
990
+ request.actions.forEach(action => {
991
+ configurationRequest = this.executeActionScript(configurationRequest, action) ?? configurationRequest;
992
+ });
993
+ return this.configurationService.configureRequest$(configurationRequest);
994
+ }), tap$1(() => {
995
+ if (!request.selectors) {
996
+ return;
997
+ }
998
+ // Run selectors and apply them to the state
999
+ const finalConfigurationRequest = this.configurationService.generateRequest();
1000
+ const selectorsResult = EntityUtil.entries(request.selectors).reduce((trunk, [key, selector]) => {
1001
+ trunk[key] = this.executeSelectorScript(finalConfigurationRequest, selector);
1002
+ return trunk;
1003
+ }, {});
1004
+ this.stateSubj$.next({
1005
+ ...this.stateSubj$.value,
1006
+ ...selectorsResult,
1007
+ });
1008
+ }), map$2(() => undefined));
1009
+ }
1010
+ executeStateful$(request) {
1011
+ if (!this.stateId) {
1012
+ return of(undefined);
1013
+ }
1014
+ return this.statefulConfigurationApiService.execute(this.stateId, request).pipe(tap$1(response => {
1015
+ this.stateId = response.stateId;
1016
+ const updatedState = this.stateSubj$.value;
1017
+ EntityUtil.entries(response.selectors).forEach(([key, value]) => {
1018
+ if (!value.success) {
1019
+ if (!this.runtimeService.uiDefinitionProperties.suppressToastMessages) {
1020
+ this.toastService.add({ summary: value.errorMessage, severity: ToastType.error });
1021
+ }
1022
+ return;
1023
+ }
1024
+ updatedState[key] = value.result;
1025
+ });
1026
+ this.stateSubj$.next(updatedState);
1027
+ }), map$2(() => undefined));
1028
+ }
1029
+ executeActionScript(request, processor) {
1030
+ const { actions } = this.runtimeService.runtimeContext?.uiDefinitionContainer ?? {};
1031
+ const script = actions?.find(action => action.apiName === processor.name)?.script;
1032
+ if (!script) {
1033
+ return null;
1034
+ }
1035
+ return this.executeProcessorScript(request, script, processor.inputData);
1036
+ }
1037
+ executeSelectorScript(request, processor) {
1038
+ const { selectors } = this.runtimeService.runtimeContext?.uiDefinitionContainer ?? {};
1039
+ const script = selectors?.find(selector => selector.apiName === processor.name)?.script;
1040
+ if (!script) {
1041
+ return null;
1042
+ }
1043
+ return this.executeProcessorScript(request, script, processor.inputData);
1044
+ }
1045
+ executeProcessorScript(request, script, inputData) {
1046
+ return new Function(`${script}\nreturn transform;`)()({
1047
+ request,
1048
+ inputData: inputData,
1049
+ });
1050
+ }
1051
+ }
1052
+ ConfigurationState.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.8", ngImport: i0, type: ConfigurationState, deps: [{ token: i1.StatefulConfigurationApiService }, { token: ConfigurationRuntimeService }, { token: ConfigurationService }, { token: i4.ToastService }], target: i0.ɵɵFactoryTarget.Injectable });
1053
+ ConfigurationState.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.8", ngImport: i0, type: ConfigurationState });
1054
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.8", ngImport: i0, type: ConfigurationState, decorators: [{
1055
+ type: Injectable
1056
+ }], ctorParameters: function () { return [{ type: i1.StatefulConfigurationApiService }, { type: ConfigurationRuntimeService }, { type: ConfigurationService }, { type: i4.ToastService }]; } });
1057
+
837
1058
  function extractMetadata(uiDefinition) {
838
1059
  return omit(uiDefinition, [
839
1060
  'children',
@@ -1038,15 +1259,15 @@ class FlowConfigurationService {
1038
1259
  const updatedState = [...quoteDraft.currentState, term];
1039
1260
  return of([]).pipe(switchMap$1(() => this.calculate$({ ...quoteDraft, currentState: updatedState })), map$2(() => this.quoteDraftService.quoteDraft), this.handleErrorAndBounceBack());
1040
1261
  }
1041
- addToCart$(productId, qty) {
1262
+ addToCart$(props) {
1042
1263
  const quoteDraft = this.quoteDraftService.quoteDraft;
1043
1264
  if (!quoteDraft) {
1044
1265
  return of(null);
1045
1266
  }
1046
- return this.configurationService.configureExternal$(productId, qty).pipe(map$2(lineItem => {
1267
+ return this.configurationService.configureExternal$(props).pipe(map$2(lineItem => {
1047
1268
  const model = this.configurationService.getRuntimeModel();
1048
1269
  const split = model?.types.find(type => type.name === lineItem.type)?.split ?? false;
1049
- const lineItems = multiplyLineItems(lineItem, qty ?? 1, split);
1270
+ const lineItems = multiplyLineItems(lineItem, props.qty ?? 1, split);
1050
1271
  return [...quoteDraft.currentState, ...lineItems];
1051
1272
  }), switchMap$1(updatedState => this.calculate$({ ...quoteDraft, currentState: updatedState })), map$2(() => this.quoteDraftService.quoteDraft), this.handleErrorAndBounceBack());
1052
1273
  }
@@ -1124,6 +1345,7 @@ ConfigurationModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", ver
1124
1345
  ConfigurationRuntimeService,
1125
1346
  RuntimeContextService,
1126
1347
  ConfigurationService,
1348
+ ConfigurationState,
1127
1349
  ], imports: [ConfirmationDialogModule] });
1128
1350
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.8", ngImport: i0, type: ConfigurationModule, decorators: [{
1129
1351
  type: NgModule,
@@ -1136,6 +1358,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.8", ngImpor
1136
1358
  ConfigurationRuntimeService,
1137
1359
  RuntimeContextService,
1138
1360
  ConfigurationService,
1361
+ ConfigurationState,
1139
1362
  ],
1140
1363
  }]
1141
1364
  }] });
@@ -1282,16 +1505,271 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.8", ngImpor
1282
1505
  args: [{ providedIn: 'root' }]
1283
1506
  }], ctorParameters: function () { return [{ type: i1.ProductApiService }]; } });
1284
1507
 
1508
+ class RuntimeSettingsService {
1509
+ constructor(configurationSettingsApiService) {
1510
+ this.configurationSettingsApiService = configurationSettingsApiService;
1511
+ this.configurationSettings$ = new BehaviorSubject({});
1512
+ this.currencySettings$ = new BehaviorSubject({
1513
+ iso: DEFAULT_CURRENCY_ISO_CODE,
1514
+ symbol: DEFAULT_CURRENCY_SYMBOL,
1515
+ });
1516
+ this.getCurrencySymbol = (locale, currency) => {
1517
+ return (0)
1518
+ .toLocaleString(locale, { style: 'currency', currency, minimumFractionDigits: 0, maximumFractionDigits: 0 })
1519
+ .replace(/\d/g, '')
1520
+ .trim();
1521
+ };
1522
+ }
1523
+ create() {
1524
+ return this.configurationSettingsApiService.fetchSettings().pipe(map$2(settings => this.parseConfigurationSettings(settings)), tap$1(configurationSettings => {
1525
+ this.configurationSettings$.next(configurationSettings);
1526
+ this.formattingSettings = this.getFormattingSettings();
1527
+ }), map$2(() => undefined));
1528
+ }
1529
+ initCurrency(iso) {
1530
+ if (iso) {
1531
+ const symbol = this.getCurrencySymbol('en-US', iso);
1532
+ this.currencySettings$.next({ iso, symbol });
1533
+ }
1534
+ }
1535
+ getFormattingSettings() {
1536
+ if (this.formattingSettings) {
1537
+ return this.formattingSettings;
1538
+ }
1539
+ const shoppingCartSettings = this.getConfigurationSettings()['shopping-cart']?.reduce((acc, setting) => {
1540
+ return { ...acc, [setting.id]: setting.properties };
1541
+ }, {});
1542
+ const currencySettings = this.getCurrencySettings();
1543
+ const dateFormat = (validateDateFormat(shoppingCartSettings?.DATE_FORMAT ?? '') && shoppingCartSettings?.DATE_FORMAT) ||
1544
+ DEFAULT_DATE_FORMAT;
1545
+ const decimalSeparator = shoppingCartSettings?.DECIMAL_SEPARATOR;
1546
+ const thousandsSeparator = shoppingCartSettings?.THOUSANDS_SEPARATOR;
1547
+ // the number of decimal places can be 0
1548
+ const priceScale = shoppingCartSettings?.PRICE_SCALE;
1549
+ const decimalsCount = priceScale !== null && priceScale !== '' && !isNaN(Number(priceScale)) && Number(priceScale) >= 0
1550
+ ? Number(priceScale)
1551
+ : DEFAULT_DECIMALS_COUNT;
1552
+ return {
1553
+ currencySymbol: currencySettings.symbol,
1554
+ dateFormats: getSupportedDateFormats(dateFormat),
1555
+ decimalsCount,
1556
+ decimalSeparator: decimalSeparator !== undefined && ['.', ','].includes(decimalSeparator)
1557
+ ? decimalSeparator
1558
+ : DEFAULT_DECIMAL_SEPARATOR,
1559
+ // thousands separator can be a blank value, so it can also be null
1560
+ thousandsSeparator: thousandsSeparator !== undefined && ['.', ',', '', null].includes(thousandsSeparator)
1561
+ ? thousandsSeparator || ''
1562
+ : DEFAULT_THOUSANDS_SEPARATOR,
1563
+ };
1564
+ }
1565
+ getConfigurationSettings() {
1566
+ return this.configurationSettings$.value;
1567
+ }
1568
+ getCurrencySettings() {
1569
+ return this.currencySettings$.value;
1570
+ }
1571
+ parseConfigurationSettings(settings) {
1572
+ return settings.reduce((acc, setting) => {
1573
+ switch (setting.key) {
1574
+ case 'shopping-cart':
1575
+ acc['shopping-cart'] = parseJsonSafely(setting.value, []);
1576
+ break;
1577
+ case 'navigation':
1578
+ acc.navigation = parseJsonSafely(setting.value, {});
1579
+ break;
1580
+ case 'flows':
1581
+ acc.flows = parseJsonSafely(setting.value, []);
1582
+ break;
1583
+ default:
1584
+ acc[setting.key] = setting.value;
1585
+ }
1586
+ return acc;
1587
+ }, {});
1588
+ }
1589
+ }
1590
+ RuntimeSettingsService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.8", ngImport: i0, type: RuntimeSettingsService, deps: [{ token: i1.ConfigurationSettingsApiService }], target: i0.ɵɵFactoryTarget.Injectable });
1591
+ RuntimeSettingsService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.8", ngImport: i0, type: RuntimeSettingsService, providedIn: 'root' });
1592
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.8", ngImport: i0, type: RuntimeSettingsService, decorators: [{
1593
+ type: Injectable,
1594
+ args: [{ providedIn: 'root' }]
1595
+ }], ctorParameters: function () { return [{ type: i1.ConfigurationSettingsApiService }]; } });
1596
+
1597
+ const DEFAULT_FORMATTING_SETTINGS = {
1598
+ currencySymbol: DEFAULT_CURRENCY_SYMBOL,
1599
+ decimalsCount: DEFAULT_DECIMALS_COUNT,
1600
+ dateFormats: getSupportedDateFormats(DEFAULT_DATE_FORMAT),
1601
+ decimalSeparator: DEFAULT_DECIMAL_SEPARATOR,
1602
+ thousandsSeparator: DEFAULT_THOUSANDS_SEPARATOR,
1603
+ };
1285
1604
  class SdkCoreModule {
1286
1605
  }
1287
1606
  SdkCoreModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.8", ngImport: i0, type: SdkCoreModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
1288
1607
  SdkCoreModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "15.2.8", ngImport: i0, type: SdkCoreModule, imports: [ConfigurationModule, FlowConfigurationModule] });
1289
- SdkCoreModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "15.2.8", ngImport: i0, type: SdkCoreModule, providers: [ContextService, QuoteDraftService, ProductImagesService, MetricsCalculationService], imports: [ConfigurationModule, FlowConfigurationModule] });
1608
+ SdkCoreModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "15.2.8", ngImport: i0, type: SdkCoreModule, providers: [
1609
+ ContextService,
1610
+ QuoteDraftService,
1611
+ ProductImagesService,
1612
+ MetricsCalculationService,
1613
+ RuntimeSettingsService,
1614
+ {
1615
+ provide: FORMATTING_SETTINGS_TOKEN,
1616
+ useExisting: RuntimeSettingsService,
1617
+ },
1618
+ ], imports: [ConfigurationModule, FlowConfigurationModule] });
1290
1619
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.8", ngImport: i0, type: SdkCoreModule, decorators: [{
1291
1620
  type: NgModule,
1292
1621
  args: [{
1293
1622
  imports: [ConfigurationModule, FlowConfigurationModule],
1294
- providers: [ContextService, QuoteDraftService, ProductImagesService, MetricsCalculationService],
1623
+ providers: [
1624
+ ContextService,
1625
+ QuoteDraftService,
1626
+ ProductImagesService,
1627
+ MetricsCalculationService,
1628
+ RuntimeSettingsService,
1629
+ {
1630
+ provide: FORMATTING_SETTINGS_TOKEN,
1631
+ useExisting: RuntimeSettingsService,
1632
+ },
1633
+ ],
1634
+ }]
1635
+ }] });
1636
+
1637
+ class CalendarDirective {
1638
+ constructor() {
1639
+ this.ngControl = inject(NgControl, { host: true, optional: true });
1640
+ this.formattingSettings = inject(FORMATTING_SETTINGS_TOKEN, { optional: true })?.getFormattingSettings();
1641
+ this.destroy$ = new Subject();
1642
+ }
1643
+ set vlCalendar(calendar) {
1644
+ this.calendar = calendar;
1645
+ }
1646
+ ngOnDestroy() {
1647
+ this.destroy$.next();
1648
+ this.destroy$.complete();
1649
+ }
1650
+ ngOnInit() {
1651
+ if (this.calendar) {
1652
+ this.calendar.dateFormat = this.formattingSettings?.dateFormats.primengFormat ?? DEFAULT_DATE_FORMAT;
1653
+ if (this.ngControl && this.ngControl.control) {
1654
+ const control = this.ngControl.control;
1655
+ control.setValue(control.value, { emitEvent: false });
1656
+ }
1657
+ }
1658
+ }
1659
+ }
1660
+ CalendarDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.8", ngImport: i0, type: CalendarDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive });
1661
+ CalendarDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "15.2.8", type: CalendarDirective, selector: "[vlCalendar]", inputs: { vlCalendar: "vlCalendar" }, ngImport: i0 });
1662
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.8", ngImport: i0, type: CalendarDirective, decorators: [{
1663
+ type: Directive,
1664
+ args: [{
1665
+ selector: '[vlCalendar]',
1666
+ }]
1667
+ }], propDecorators: { vlCalendar: [{
1668
+ type: Input
1669
+ }] } });
1670
+
1671
+ class SdkDirectivesModule {
1672
+ }
1673
+ SdkDirectivesModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.8", ngImport: i0, type: SdkDirectivesModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
1674
+ SdkDirectivesModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "15.2.8", ngImport: i0, type: SdkDirectivesModule, declarations: [CalendarDirective], exports: [CalendarDirective] });
1675
+ SdkDirectivesModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "15.2.8", ngImport: i0, type: SdkDirectivesModule });
1676
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.8", ngImport: i0, type: SdkDirectivesModule, decorators: [{
1677
+ type: NgModule,
1678
+ args: [{
1679
+ declarations: [CalendarDirective],
1680
+ exports: [CalendarDirective],
1681
+ }]
1682
+ }] });
1683
+
1684
+ class DatePipe {
1685
+ constructor() {
1686
+ this.locale = inject(LOCALE_ID);
1687
+ this.defaultOptions = inject(DATE_PIPE_DEFAULT_OPTIONS, { optional: true });
1688
+ this.formattingSettings = inject(FORMATTING_SETTINGS_TOKEN, { optional: true })?.getFormattingSettings();
1689
+ this.destroy$ = new Subject();
1690
+ }
1691
+ ngOnDestroy() {
1692
+ this.destroy$.next();
1693
+ this.destroy$.complete();
1694
+ }
1695
+ transform(date) {
1696
+ if (!date) {
1697
+ return '';
1698
+ }
1699
+ try {
1700
+ return formatDate(date, this.formattingSettings?.dateFormats.datePipeFormat || DEFAULT_DATE_FORMAT, this.locale, this.defaultOptions?.timezone);
1701
+ }
1702
+ catch (error) {
1703
+ return new Date(date).toString();
1704
+ }
1705
+ }
1706
+ }
1707
+ DatePipe.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.8", ngImport: i0, type: DatePipe, deps: [], target: i0.ɵɵFactoryTarget.Pipe });
1708
+ DatePipe.ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "15.2.8", ngImport: i0, type: DatePipe, name: "vlDate" });
1709
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.8", ngImport: i0, type: DatePipe, decorators: [{
1710
+ type: Pipe,
1711
+ args: [{
1712
+ name: 'vlDate',
1713
+ }]
1714
+ }] });
1715
+
1716
+ class NumberPipe {
1717
+ constructor() {
1718
+ this.formattingSettings = inject(FORMATTING_SETTINGS_TOKEN, { optional: true })?.getFormattingSettings();
1719
+ this.destroy$ = new Subject();
1720
+ }
1721
+ ngOnDestroy() {
1722
+ this.destroy$.next();
1723
+ this.destroy$.complete();
1724
+ }
1725
+ transform(price) {
1726
+ return formatNumber(price, this.formattingSettings?.thousandsSeparator, this.formattingSettings?.decimalSeparator, this.formattingSettings?.decimalsCount);
1727
+ }
1728
+ }
1729
+ NumberPipe.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.8", ngImport: i0, type: NumberPipe, deps: [], target: i0.ɵɵFactoryTarget.Pipe });
1730
+ NumberPipe.ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "15.2.8", ngImport: i0, type: NumberPipe, name: "vlNumber" });
1731
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.8", ngImport: i0, type: NumberPipe, decorators: [{
1732
+ type: Pipe,
1733
+ args: [{
1734
+ name: 'vlNumber',
1735
+ }]
1736
+ }] });
1737
+
1738
+ class PricePipe {
1739
+ constructor() {
1740
+ this.formattingSettings = inject(FORMATTING_SETTINGS_TOKEN, { optional: true })?.getFormattingSettings();
1741
+ this.destroy$ = new Subject();
1742
+ }
1743
+ ngOnDestroy() {
1744
+ this.destroy$.next();
1745
+ this.destroy$.complete();
1746
+ }
1747
+ transform(price) {
1748
+ if (price == null || price === '') {
1749
+ return '';
1750
+ }
1751
+ return `${this.formattingSettings?.currencySymbol || DEFAULT_CURRENCY_SYMBOL}${formatNumber(price, this.formattingSettings?.thousandsSeparator, this.formattingSettings?.decimalSeparator, this.formattingSettings?.decimalsCount)}`;
1752
+ }
1753
+ }
1754
+ PricePipe.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.8", ngImport: i0, type: PricePipe, deps: [], target: i0.ɵɵFactoryTarget.Pipe });
1755
+ PricePipe.ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "15.2.8", ngImport: i0, type: PricePipe, name: "vlPrice" });
1756
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.8", ngImport: i0, type: PricePipe, decorators: [{
1757
+ type: Pipe,
1758
+ args: [{
1759
+ name: 'vlPrice',
1760
+ }]
1761
+ }] });
1762
+
1763
+ class SdkPipesModule {
1764
+ }
1765
+ SdkPipesModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.8", ngImport: i0, type: SdkPipesModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
1766
+ SdkPipesModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "15.2.8", ngImport: i0, type: SdkPipesModule, declarations: [NumberPipe, PricePipe, DatePipe], exports: [NumberPipe, PricePipe, DatePipe] });
1767
+ SdkPipesModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "15.2.8", ngImport: i0, type: SdkPipesModule });
1768
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.8", ngImport: i0, type: SdkPipesModule, decorators: [{
1769
+ type: NgModule,
1770
+ args: [{
1771
+ declarations: [NumberPipe, PricePipe, DatePipe],
1772
+ exports: [NumberPipe, PricePipe, DatePipe],
1295
1773
  }]
1296
1774
  }] });
1297
1775
 
@@ -1299,5 +1777,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.8", ngImpor
1299
1777
  * Generated bundle index. Do not edit.
1300
1778
  */
1301
1779
 
1302
- export { ConfigurationRuntimeService, ConfigurationService, ContextService, FlowConfigurationModule, FlowConfigurationService, FlowUpdateService, LineItemWorker, MetricsCalculationService, ProductImagesService, QuoteDraftService, RuntimeMode, RuntimeOperation, RuntimeStep, SdkCoreModule, UI_DEFINITION_VERSION, calculateCardinalityVariables, extractMetadata, findLineItem, findLineItemWithComparator, generateLineItem, generateModifiedAssetsMap, getAttributeValue, getAttributes, getDefaultLineItem, getOriginParent, getRecommendedPrices, insertLineItem, isLineItemModified, lineItem_utils as lineItemUtils, mapAttributes, multiplyLineItems, patchAttributes, recalculateCardinalityVariables, removeLineItem, replaceLineItem, upsertAttributes };
1780
+ export { CalendarDirective, ConfigurationRuntimeService, ConfigurationService, ConfigurationState, ContextService, DEFAULT_FORMATTING_SETTINGS, DatePipe, FORMATTING_SETTINGS_TOKEN, FlowConfigurationModule, FlowConfigurationService, FlowUpdateService, LineItemWorker, MetricsCalculationService, NumberPipe, PricePipe, ProductImagesService, QuoteDraftService, RuntimeMode, RuntimeOperation, RuntimeSettingsService, RuntimeStep, SdkCoreModule, SdkDirectivesModule, SdkPipesModule, UI_DEFINITION_VERSION, calculateCardinalityVariables, extractMetadata, filterOutTechnicalAttributes, findLineItem, findLineItemWithComparator, generateLineItem, generateModifiedAssetsMap, getAttributeValue, getAttributes, getDefaultLineItem, getGuidedSellingConfigurationRequest, getOriginParent, getRecommendedPrices, insertLineItem, isLineItemModified, isTechnicalAttribute, lineItem_utils as lineItemUtils, mapAttributes, multiplyLineItems, patchAttributes, recalculateCardinalityVariables, removeLineItem, replaceLineItem, upsertAttributes };
1303
1781
  //# sourceMappingURL=veloceapps-sdk-core.mjs.map