@veloceapps/sdk 8.0.0-17 → 8.0.0-171

Sign up to get free protection for your applications and to get access to all the features.
Files changed (347) hide show
  1. package/README.md +0 -1
  2. package/cms/README.md +0 -20
  3. package/cms/cms.actions.d.ts +7 -1
  4. package/cms/components/preview/preview.component.d.ts +2 -3
  5. package/cms/components/preview/preview.types.d.ts +4 -0
  6. package/cms/index.d.ts +1 -0
  7. package/cms/modules/runtime/services/runtime.service.d.ts +1 -1
  8. package/cms/services/index.d.ts +0 -1
  9. package/cms/types/index.d.ts +0 -1
  10. package/cms/utils/element-metadata-worker.d.ts +11 -0
  11. package/cms/utils/elements-resolver.d.ts +0 -2
  12. package/cms/utils/index.d.ts +3 -0
  13. package/cms/utils/transpilation-worker.d.ts +13 -0
  14. package/cms/vendor-map.d.ts +26 -15
  15. package/core/README.md +20 -0
  16. package/core/modules/configuration/configuration.module.d.ts +2 -1
  17. package/core/modules/configuration/helpers.d.ts +4 -3
  18. package/core/modules/configuration/index.d.ts +1 -1
  19. package/core/modules/configuration/services/configuration-runtime.service.d.ts +1 -1
  20. package/core/modules/configuration/services/configuration-state.service.d.ts +51 -0
  21. package/core/modules/configuration/services/configuration.service.d.ts +10 -5
  22. package/core/modules/configuration/types/configuration.types.d.ts +4 -0
  23. package/core/modules/flow-configuration/flow-configuration.module.d.ts +2 -1
  24. package/core/modules/flow-configuration/services/flow-configuration.service.d.ts +5 -0
  25. package/core/pipes/action-code.pipe.d.ts +8 -0
  26. package/core/pipes/date.pipe.d.ts +2 -1
  27. package/core/pipes/index.d.ts +1 -0
  28. package/core/pipes/pipes.module.d.ts +2 -1
  29. package/core/services/context.service.d.ts +4 -0
  30. package/core/services/flow-info.service.d.ts +29 -0
  31. package/core/services/flow-state-configuration.service.d.ts +19 -0
  32. package/core/services/flow-state.service.d.ts +79 -0
  33. package/core/services/index.d.ts +4 -1
  34. package/core/services/quote-draft.service.d.ts +8 -1
  35. package/core/services/runtime-settings.service.d.ts +4 -1
  36. package/core/types/flow-customization.types.d.ts +22 -0
  37. package/core/types/flow-state.types.d.ts +6 -0
  38. package/core/types/formatting-settings.types.d.ts +2 -0
  39. package/core/types/index.d.ts +3 -0
  40. package/{cms → core}/types/integration.types.d.ts +1 -0
  41. package/core/types/pipe.types.d.ts +1 -0
  42. package/core/utils/line-item.utils.d.ts +0 -1
  43. package/esm2020/cms/cms.actions.mjs +15 -1
  44. package/esm2020/cms/components/element-children/element-children.component.mjs +3 -3
  45. package/esm2020/cms/components/element-children/element-children.module.mjs +4 -4
  46. package/esm2020/cms/components/element-drop-handle/element-drop-handle.component.mjs +3 -3
  47. package/esm2020/cms/components/element-drop-handle/element-drop-handle.module.mjs +4 -4
  48. package/esm2020/cms/components/element-renderer/element-renderer.component.mjs +6 -6
  49. package/esm2020/cms/components/element-renderer/element-renderer.module.mjs +4 -4
  50. package/esm2020/cms/components/element-tools-panel/element-tools-panel.component.mjs +5 -5
  51. package/esm2020/cms/components/plugin.component.mjs +3 -3
  52. package/esm2020/cms/components/preview/preview.component.mjs +11 -11
  53. package/esm2020/cms/components/preview/preview.module.mjs +6 -6
  54. package/esm2020/cms/components/preview/preview.types.mjs +1 -1
  55. package/esm2020/cms/directives/custom-template.directive.mjs +7 -7
  56. package/esm2020/cms/index.mjs +2 -1
  57. package/esm2020/cms/launcher.module.mjs +7 -7
  58. package/esm2020/cms/modules/federated/federated-host.directive.mjs +3 -3
  59. package/esm2020/cms/modules/federated/federated.component.mjs +3 -3
  60. package/esm2020/cms/modules/federated/federated.module.mjs +4 -4
  61. package/esm2020/cms/modules/migrations/migrations.mjs +2 -2
  62. package/esm2020/cms/modules/migrations/migrations.module.mjs +4 -4
  63. package/esm2020/cms/modules/migrations/services/migrations.service.mjs +9 -5
  64. package/esm2020/cms/modules/runtime/runtime.module.mjs +4 -4
  65. package/esm2020/cms/modules/runtime/services/compilation.service.mjs +14 -10
  66. package/esm2020/cms/modules/runtime/services/runtime-editor.service.mjs +3 -3
  67. package/esm2020/cms/modules/runtime/services/runtime.service.mjs +7 -7
  68. package/esm2020/cms/plugins/configuration.plugin.mjs +11 -7
  69. package/esm2020/cms/plugins/element-hover.plugin.mjs +3 -3
  70. package/esm2020/cms/plugins/io.plugin.mjs +3 -3
  71. package/esm2020/cms/plugins/page.plugin.mjs +3 -3
  72. package/esm2020/cms/plugins/region.plugin.mjs +3 -3
  73. package/esm2020/cms/plugins/script.plugin.mjs +3 -3
  74. package/esm2020/cms/services/element-context.service.mjs +3 -3
  75. package/esm2020/cms/services/index.mjs +1 -2
  76. package/esm2020/cms/services/io-provider.service.mjs +13 -12
  77. package/esm2020/cms/services/resources.service.mjs +3 -3
  78. package/esm2020/cms/services/templates.service.mjs +13 -12
  79. package/esm2020/cms/types/index.mjs +1 -2
  80. package/esm2020/cms/utils/element-metadata-worker.mjs +31 -0
  81. package/esm2020/cms/utils/elements-resolver.mjs +14 -28
  82. package/esm2020/cms/utils/index.mjs +4 -1
  83. package/esm2020/cms/utils/path.utils.mjs +3 -3
  84. package/esm2020/cms/utils/transpilation-worker.mjs +52 -0
  85. package/esm2020/cms/vendor-map.mjs +18 -6
  86. package/esm2020/core/core.module.mjs +16 -9
  87. package/esm2020/core/directives/directives.module.mjs +4 -4
  88. package/esm2020/core/directives/primeng-calendar.directive.mjs +3 -3
  89. package/esm2020/core/modules/configuration/configuration.module.mjs +9 -25
  90. package/esm2020/core/modules/configuration/helpers.mjs +28 -3
  91. package/esm2020/core/modules/configuration/index.mjs +2 -2
  92. package/esm2020/core/modules/configuration/services/configuration-runtime.service.mjs +11 -14
  93. package/esm2020/core/modules/configuration/services/configuration-state.service.mjs +299 -0
  94. package/esm2020/core/modules/configuration/services/configuration.service.mjs +70 -47
  95. package/esm2020/core/modules/configuration/services/runtime-context.service.mjs +9 -9
  96. package/esm2020/core/modules/configuration/types/configuration.types.mjs +1 -1
  97. package/esm2020/core/modules/flow-configuration/flow-configuration.module.mjs +8 -8
  98. package/esm2020/core/modules/flow-configuration/services/flow-configuration.service.mjs +13 -10
  99. package/esm2020/core/modules/flow-configuration/services/flow-update.service.mjs +3 -3
  100. package/esm2020/core/pipes/action-code.pipe.mjs +20 -0
  101. package/esm2020/core/pipes/date.pipe.mjs +13 -7
  102. package/esm2020/core/pipes/index.mjs +2 -1
  103. package/esm2020/core/pipes/number.pipe.mjs +3 -3
  104. package/esm2020/core/pipes/pipes.module.mjs +8 -7
  105. package/esm2020/core/pipes/price.pipe.mjs +3 -3
  106. package/esm2020/core/services/context.service.mjs +34 -7
  107. package/esm2020/core/services/flow-info.service.mjs +99 -0
  108. package/esm2020/core/services/flow-state-configuration.service.mjs +53 -0
  109. package/esm2020/core/services/flow-state.service.mjs +502 -0
  110. package/esm2020/core/services/index.mjs +5 -2
  111. package/esm2020/core/services/integration.state.mjs +36 -0
  112. package/esm2020/core/services/product-images.service.mjs +6 -7
  113. package/esm2020/core/services/quote-draft.service.mjs +33 -9
  114. package/esm2020/core/services/runtime-settings.service.mjs +21 -7
  115. package/esm2020/core/types/flow-customization.types.mjs +3 -0
  116. package/esm2020/core/types/flow-state.types.mjs +2 -0
  117. package/esm2020/core/types/formatting-settings.types.mjs +1 -1
  118. package/esm2020/core/types/index.mjs +4 -1
  119. package/esm2020/core/types/integration.types.mjs +2 -0
  120. package/esm2020/core/types/pipe.types.mjs +2 -0
  121. package/esm2020/core/utils/line-item.utils.mjs +30 -15
  122. package/esm2020/src/components/dialog/dialog.component.mjs +3 -3
  123. package/esm2020/src/components/dialog/dialog.module.mjs +4 -4
  124. package/esm2020/src/components/doc-gen/doc-gen.component.mjs +51 -51
  125. package/esm2020/src/components/doc-gen/doc-gen.module.mjs +4 -4
  126. package/esm2020/src/components/flow-header/flow-header.component.mjs +108 -0
  127. package/esm2020/src/components/flow-header/flow-header.module.mjs +19 -0
  128. package/esm2020/src/components/flow-header/index.mjs +2 -0
  129. package/esm2020/src/components/guided-selling/guided-selling.component.mjs +39 -45
  130. package/esm2020/src/components/guided-selling/guided-selling.module.mjs +4 -4
  131. package/esm2020/src/configure-primeng.mjs +33 -0
  132. package/esm2020/src/flow-routing.module.mjs +66 -75
  133. package/esm2020/src/flow.component.mjs +24 -33
  134. package/esm2020/src/flow.module.mjs +11 -9
  135. package/esm2020/src/guards/context.guard.mjs +9 -14
  136. package/esm2020/src/guards/flow.guard.mjs +37 -0
  137. package/esm2020/src/guards/product-unload.guard.mjs +7 -4
  138. package/esm2020/src/guards/root.guard.mjs +17 -13
  139. package/esm2020/src/pages/assets/assets.component.mjs +34 -38
  140. package/esm2020/src/pages/assets/assets.module.mjs +4 -4
  141. package/esm2020/src/pages/catalog/catalog.component.mjs +34 -38
  142. package/esm2020/src/pages/catalog/catalog.module.mjs +4 -4
  143. package/esm2020/src/pages/debug/debug.component.mjs +12 -16
  144. package/esm2020/src/pages/debug/debug.module.mjs +4 -4
  145. package/esm2020/src/pages/empty-account/empty-account.component.mjs +3 -3
  146. package/esm2020/src/pages/empty-account/empty-account.module.mjs +4 -4
  147. package/esm2020/src/pages/product/product.component.mjs +24 -14
  148. package/esm2020/src/pages/product/product.module.mjs +4 -4
  149. package/esm2020/src/pages/record-not-found/record-not-found.component.mjs +8 -5
  150. package/esm2020/src/pages/record-not-found/record-not-found.module.mjs +4 -4
  151. package/esm2020/src/pages/remote/remote.component.mjs +20 -20
  152. package/esm2020/src/pages/remote/remote.module.mjs +4 -4
  153. package/esm2020/src/pages/shopping-cart/shopping-cart.component.mjs +35 -39
  154. package/esm2020/src/pages/shopping-cart/shopping-cart.module.mjs +4 -4
  155. package/esm2020/src/resolvers/flow.resolver.mjs +39 -51
  156. package/esm2020/src/resolvers/quote.resolver.mjs +57 -65
  157. package/esm2020/src/services/doc-gen.service.mjs +7 -6
  158. package/esm2020/src/services/flow-dialog.service.mjs +23 -8
  159. package/esm2020/src/services/flow-router.service.mjs +59 -18
  160. package/esm2020/src/services/flow.service.mjs +72 -25
  161. package/esm2020/src/services/guided-selling.service.mjs +8 -7
  162. package/esm2020/src/services/index.mjs +3 -1
  163. package/esm2020/src/types/index.mjs +1 -2
  164. package/esm2020/src/utils/flow.utils.mjs +6 -2
  165. package/fesm2015/veloceapps-sdk-cms.mjs +355 -271
  166. package/fesm2015/veloceapps-sdk-cms.mjs.map +1 -1
  167. package/fesm2015/veloceapps-sdk-core.mjs +1639 -781
  168. package/fesm2015/veloceapps-sdk-core.mjs.map +1 -1
  169. package/fesm2015/veloceapps-sdk.mjs +828 -1541
  170. package/fesm2015/veloceapps-sdk.mjs.map +1 -1
  171. package/fesm2020/veloceapps-sdk-cms.mjs +357 -283
  172. package/fesm2020/veloceapps-sdk-cms.mjs.map +1 -1
  173. package/fesm2020/veloceapps-sdk-core.mjs +1780 -958
  174. package/fesm2020/veloceapps-sdk-core.mjs.map +1 -1
  175. package/fesm2020/veloceapps-sdk.mjs +888 -1599
  176. package/fesm2020/veloceapps-sdk.mjs.map +1 -1
  177. package/package.json +7 -14
  178. package/src/components/doc-gen/doc-gen.component.d.ts +8 -9
  179. package/src/components/flow-header/flow-header.component.d.ts +25 -0
  180. package/src/components/flow-header/flow-header.module.d.ts +9 -0
  181. package/src/components/flow-header/index.d.ts +1 -0
  182. package/src/components/guided-selling/guided-selling.component.d.ts +6 -8
  183. package/src/configure-primeng.d.ts +1 -0
  184. package/src/flow-routing.module.d.ts +6 -7
  185. package/src/flow.component.d.ts +7 -11
  186. package/src/flow.module.d.ts +2 -2
  187. package/src/guards/context.guard.d.ts +4 -5
  188. package/src/guards/flow.guard.d.ts +2 -0
  189. package/src/guards/product-unload.guard.d.ts +2 -2
  190. package/src/guards/root.guard.d.ts +0 -1
  191. package/src/pages/assets/assets.component.d.ts +5 -7
  192. package/src/pages/catalog/catalog.component.d.ts +5 -7
  193. package/src/pages/debug/debug.component.d.ts +5 -8
  194. package/src/pages/product/product.component.d.ts +7 -6
  195. package/src/pages/record-not-found/record-not-found.component.d.ts +2 -0
  196. package/src/pages/remote/remote.component.d.ts +2 -3
  197. package/src/pages/shopping-cart/shopping-cart.component.d.ts +5 -7
  198. package/src/resolvers/flow.resolver.d.ts +6 -7
  199. package/src/resolvers/quote.resolver.d.ts +7 -12
  200. package/src/services/doc-gen.service.d.ts +1 -1
  201. package/src/services/flow-dialog.service.d.ts +5 -2
  202. package/src/services/flow-router.service.d.ts +7 -3
  203. package/src/services/flow.service.d.ts +10 -4
  204. package/src/services/guided-selling.service.d.ts +1 -1
  205. package/src/services/index.d.ts +2 -0
  206. package/src/types/index.d.ts +0 -1
  207. package/core/modules/configuration/services/configuration.state.d.ts +0 -30
  208. package/core/services/metric-calculation/metric-calculation.service.d.ts +0 -25
  209. package/core/services/metric-calculation/metric-calculation.types.d.ts +0 -1
  210. package/core/services/metric-calculation/metric-calculation.utils.d.ts +0 -5
  211. package/esm2020/cms/services/integration.state.mjs +0 -37
  212. package/esm2020/cms/types/integration.types.mjs +0 -2
  213. package/esm2020/core/modules/configuration/services/configuration.state.mjs +0 -142
  214. package/esm2020/core/services/metric-calculation/metric-calculation.service.mjs +0 -85
  215. package/esm2020/core/services/metric-calculation/metric-calculation.types.mjs +0 -2
  216. package/esm2020/core/services/metric-calculation/metric-calculation.utils.mjs +0 -42
  217. package/esm2020/runtime/components/component-preview/component-preview.component.mjs +0 -125
  218. package/esm2020/runtime/components/index.mjs +0 -5
  219. package/esm2020/runtime/components/section-renderer/section-renderer.component.mjs +0 -67
  220. package/esm2020/runtime/components/ui-runtime/runtime.component.mjs +0 -440
  221. package/esm2020/runtime/components/ui-runtime-preview/runtime-preview.component.mjs +0 -108
  222. package/esm2020/runtime/execution/components/children-placeholder/children-placeholder.component.mjs +0 -60
  223. package/esm2020/runtime/execution/components/context-provider/context-provider.component.mjs +0 -39
  224. package/esm2020/runtime/execution/components/execution-section-renderer/execution-section-renderer.component.mjs +0 -67
  225. package/esm2020/runtime/execution/components/federated/federated.component.mjs +0 -74
  226. package/esm2020/runtime/execution/components/velo-attribute/velo-attribute.component.mjs +0 -60
  227. package/esm2020/runtime/execution/components/velo-multiselect/velo-multiselect.component.mjs +0 -130
  228. package/esm2020/runtime/execution/components/velo-port-checkbox/velo-port-checkbox.component.mjs +0 -72
  229. package/esm2020/runtime/execution/components/velo-port-dropdown/velo-port-dropdown.component.mjs +0 -97
  230. package/esm2020/runtime/execution/components/velo-port-radio/velo-port-radio.component.mjs +0 -142
  231. package/esm2020/runtime/execution/components/velo-type/velo-type.component.mjs +0 -119
  232. package/esm2020/runtime/execution/directives/section-script.directive.mjs +0 -247
  233. package/esm2020/runtime/execution/directives/sf-query.directive.mjs +0 -35
  234. package/esm2020/runtime/execution/directives/velo-attribute.directive.mjs +0 -88
  235. package/esm2020/runtime/execution/directives/velo-port.directive.mjs +0 -376
  236. package/esm2020/runtime/execution/directives/vl-approval.directive.mjs +0 -23
  237. package/esm2020/runtime/execution/directives/vl-document-attachments.directive.mjs +0 -36
  238. package/esm2020/runtime/execution/directives/vl-document-templates.directive.mjs +0 -60
  239. package/esm2020/runtime/execution/directives/vl-quote.directive.mjs +0 -42
  240. package/esm2020/runtime/execution/directives/vl-ramp.directive.mjs +0 -55
  241. package/esm2020/runtime/execution/runtime-execution.module.mjs +0 -133
  242. package/esm2020/runtime/execution/utils/federated.util.mjs +0 -32
  243. package/esm2020/runtime/index.mjs +0 -5
  244. package/esm2020/runtime/runtime.module.mjs +0 -74
  245. package/esm2020/runtime/services/cart.service.mjs +0 -29
  246. package/esm2020/runtime/services/collapsible-state.service.mjs +0 -34
  247. package/esm2020/runtime/services/configuration.service.mjs +0 -119
  248. package/esm2020/runtime/services/current-state.service.mjs +0 -17
  249. package/esm2020/runtime/services/form-scope.service.mjs +0 -30
  250. package/esm2020/runtime/services/index.mjs +0 -4
  251. package/esm2020/runtime/services/product-model-cache.service.mjs +0 -31
  252. package/esm2020/runtime/services/runtime-context.service.mjs +0 -60
  253. package/esm2020/runtime/services/runtime-form.service.mjs +0 -219
  254. package/esm2020/runtime/services/runtime.service.mjs +0 -115
  255. package/esm2020/runtime/services/section-helper.service.mjs +0 -27
  256. package/esm2020/runtime/services/section-scope.service.mjs +0 -36
  257. package/esm2020/runtime/services/section-store.service.mjs +0 -22
  258. package/esm2020/runtime/services/section.service.mjs +0 -117
  259. package/esm2020/runtime/types/bound-data.types.mjs +0 -7
  260. package/esm2020/runtime/types/index.mjs +0 -3
  261. package/esm2020/runtime/types/quote-states.types.mjs +0 -2
  262. package/esm2020/runtime/types/runtime.types.mjs +0 -2
  263. package/esm2020/runtime/types/script-registry.types.mjs +0 -51
  264. package/esm2020/runtime/utils/line-item.util.mjs +0 -270
  265. package/esm2020/runtime/utils/section.utils.mjs +0 -26
  266. package/esm2020/runtime/utils/sections-binder.helper.mjs +0 -105
  267. package/esm2020/runtime/veloceapps-sdk-runtime.mjs +0 -5
  268. package/esm2020/src/components/header/cart-overlay/cart-preview.component.mjs +0 -119
  269. package/esm2020/src/components/header/cart-overlay/cart-preview.module.mjs +0 -47
  270. package/esm2020/src/components/header/header.component.mjs +0 -355
  271. package/esm2020/src/components/header/header.module.mjs +0 -52
  272. package/esm2020/src/components/header/header.types.mjs +0 -2
  273. package/esm2020/src/components/header/metrics/index.mjs +0 -2
  274. package/esm2020/src/components/header/metrics/metrics.component.mjs +0 -255
  275. package/esm2020/src/components/header/metrics/metrics.definitions.mjs +0 -2
  276. package/esm2020/src/components/header/metrics/metrics.module.mjs +0 -69
  277. package/esm2020/src/pages/legacy-product/legacy-product.component.mjs +0 -137
  278. package/esm2020/src/pages/legacy-product/legacy-product.module.mjs +0 -19
  279. package/esm2020/src/types/flow-customization.types.mjs +0 -3
  280. package/fesm2015/veloceapps-sdk-runtime.mjs +0 -3770
  281. package/fesm2015/veloceapps-sdk-runtime.mjs.map +0 -1
  282. package/fesm2020/veloceapps-sdk-runtime.mjs +0 -3767
  283. package/fesm2020/veloceapps-sdk-runtime.mjs.map +0 -1
  284. package/runtime/README.md +0 -5
  285. package/runtime/components/component-preview/component-preview.component.d.ts +0 -27
  286. package/runtime/components/index.d.ts +0 -4
  287. package/runtime/components/section-renderer/section-renderer.component.d.ts +0 -25
  288. package/runtime/components/ui-runtime/runtime.component.d.ts +0 -53
  289. package/runtime/components/ui-runtime-preview/runtime-preview.component.d.ts +0 -27
  290. package/runtime/execution/components/children-placeholder/children-placeholder.component.d.ts +0 -30
  291. package/runtime/execution/components/context-provider/context-provider.component.d.ts +0 -14
  292. package/runtime/execution/components/execution-section-renderer/execution-section-renderer.component.d.ts +0 -25
  293. package/runtime/execution/components/federated/federated.component.d.ts +0 -36
  294. package/runtime/execution/components/velo-attribute/velo-attribute.component.d.ts +0 -19
  295. package/runtime/execution/components/velo-multiselect/velo-multiselect.component.d.ts +0 -35
  296. package/runtime/execution/components/velo-port-checkbox/velo-port-checkbox.component.d.ts +0 -22
  297. package/runtime/execution/components/velo-port-dropdown/velo-port-dropdown.component.d.ts +0 -22
  298. package/runtime/execution/components/velo-port-radio/velo-port-radio.component.d.ts +0 -28
  299. package/runtime/execution/components/velo-type/velo-type.component.d.ts +0 -31
  300. package/runtime/execution/directives/section-script.directive.d.ts +0 -59
  301. package/runtime/execution/directives/sf-query.directive.d.ts +0 -15
  302. package/runtime/execution/directives/velo-attribute.directive.d.ts +0 -26
  303. package/runtime/execution/directives/velo-port.directive.d.ts +0 -74
  304. package/runtime/execution/directives/vl-approval.directive.d.ts +0 -10
  305. package/runtime/execution/directives/vl-document-attachments.directive.d.ts +0 -15
  306. package/runtime/execution/directives/vl-document-templates.directive.d.ts +0 -33
  307. package/runtime/execution/directives/vl-quote.directive.d.ts +0 -14
  308. package/runtime/execution/directives/vl-ramp.directive.d.ts +0 -15
  309. package/runtime/execution/runtime-execution.module.d.ts +0 -25
  310. package/runtime/execution/utils/federated.util.d.ts +0 -6
  311. package/runtime/index.d.ts +0 -4
  312. package/runtime/runtime.module.d.ts +0 -16
  313. package/runtime/services/cart.service.d.ts +0 -15
  314. package/runtime/services/collapsible-state.service.d.ts +0 -15
  315. package/runtime/services/configuration.service.d.ts +0 -20
  316. package/runtime/services/current-state.service.d.ts +0 -8
  317. package/runtime/services/form-scope.service.d.ts +0 -20
  318. package/runtime/services/index.d.ts +0 -3
  319. package/runtime/services/product-model-cache.service.d.ts +0 -14
  320. package/runtime/services/runtime-context.service.d.ts +0 -16
  321. package/runtime/services/runtime-form.service.d.ts +0 -24
  322. package/runtime/services/runtime.service.d.ts +0 -44
  323. package/runtime/services/section-helper.service.d.ts +0 -8
  324. package/runtime/services/section-scope.service.d.ts +0 -14
  325. package/runtime/services/section-store.service.d.ts +0 -11
  326. package/runtime/services/section.service.d.ts +0 -30
  327. package/runtime/types/bound-data.types.d.ts +0 -13
  328. package/runtime/types/index.d.ts +0 -2
  329. package/runtime/types/quote-states.types.d.ts +0 -6
  330. package/runtime/types/runtime.types.d.ts +0 -19
  331. package/runtime/types/script-registry.types.d.ts +0 -13
  332. package/runtime/utils/line-item.util.d.ts +0 -34
  333. package/runtime/utils/section.utils.d.ts +0 -2
  334. package/runtime/utils/sections-binder.helper.d.ts +0 -16
  335. package/src/components/header/cart-overlay/cart-preview.component.d.ts +0 -36
  336. package/src/components/header/cart-overlay/cart-preview.module.d.ts +0 -14
  337. package/src/components/header/header.component.d.ts +0 -70
  338. package/src/components/header/header.module.d.ts +0 -16
  339. package/src/components/header/header.types.d.ts +0 -20
  340. package/src/components/header/metrics/index.d.ts +0 -1
  341. package/src/components/header/metrics/metrics.component.d.ts +0 -67
  342. package/src/components/header/metrics/metrics.definitions.d.ts +0 -1
  343. package/src/components/header/metrics/metrics.module.d.ts +0 -18
  344. package/src/pages/legacy-product/legacy-product.component.d.ts +0 -37
  345. package/src/pages/legacy-product/legacy-product.module.d.ts +0 -9
  346. package/src/types/flow-customization.types.d.ts +0 -12
  347. /package/{cms → core}/services/integration.state.d.ts +0 -0
@@ -1,16 +1,16 @@
1
1
  import * as i0 from '@angular/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';
2
+ import { Injectable, InjectionToken, Optional, Inject, NgModule, inject, Directive, Input, LOCALE_ID, Pipe } from '@angular/core';
3
+ import { UUID, ConfigurationContextMode, ConfigurationContext, UITemplateType, isDefined, ConfigurationProcessorTypes, EntityUtil, 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, ConfigurationMode, ConfigurationTranslatorUtils, ChargeGroupUtils, RuntimeModel, isNotLegacyUIDefinition, SalesforceIdUtils, DEFAULT_TIME_FORMAT, formatNumber } from '@veloceapps/core';
4
4
  import * as i1 from '@veloceapps/api';
5
- import { PriceApiService, ContextApiService, ProductModelApiService, ConfigurationApiService } from '@veloceapps/api';
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
- import { filter, tap, map, first, switchMap, skip, take, shareReplay, catchError, finalize } from 'rxjs/operators';
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';
5
+ import { ApiModule } from '@veloceapps/api';
6
+ import { BehaviorSubject, switchMap, map as map$1, tap as tap$1, noop, catchError, throwError, of, forkJoin, Subject, filter as filter$1, zip, combineLatest, shareReplay as shareReplay$1, finalize, takeUntil, buffer, debounceTime, share, take as take$1, distinctUntilChanged } from 'rxjs';
7
+ import { map, filter, tap, switchMap as switchMap$1, skip, take, shareReplay, catchError as catchError$1, finalize as finalize$1, first } from 'rxjs/operators';
8
+ import { merge, isEmpty, flatten, entries, sortBy, map as map$2, omit, isEqual, cloneDeep, assign, uniqBy, transform } from 'lodash';
9
+ import * as i6 from '@veloceapps/components';
11
10
  import { ToastType, ConfirmationComponent, ConfirmationDialogModule } from '@veloceapps/components';
11
+ import { HttpErrorResponse } from '@angular/common/http';
12
12
  import * as i5 from 'primeng/api';
13
- import * as i6 from 'primeng/dynamicdialog';
13
+ import * as i6$1 from 'primeng/dynamicdialog';
14
14
  import moment from 'moment';
15
15
  import { NgControl } from '@angular/forms';
16
16
  import 'primeng/calendar';
@@ -33,15 +33,20 @@ const getDefaultLineItem = (context, uiDefinitionProperties, qty = 1) => {
33
33
  ...(uiDefinitionProperties.offeringId ? { offeringId: uiDefinitionProperties.offeringId } : {}),
34
34
  };
35
35
  };
36
- const getGuidedSellingConfigurationRequest = (data) => {
36
+ const getGuidedSellingConfigurationRequest = (data, context) => {
37
+ const _context = { ...context };
38
+ delete _context.configurationToken;
39
+ const properties = { ...context.properties };
40
+ delete properties['ConfigurationToken'];
37
41
  return {
38
42
  mode: 'SEARCH',
39
43
  step: 'START',
40
44
  attributeDomainMode: 'ALL',
41
45
  context: {
42
- headerId: 'TestId',
46
+ ..._context,
43
47
  mode: ConfigurationContextMode.TEST,
44
48
  properties: {
49
+ ...properties,
45
50
  ModelId: data.modelId,
46
51
  Name: 'Veloce Guided Selling',
47
52
  PricingEnabled: 'false',
@@ -62,6 +67,26 @@ const getGuidedSellingConfigurationRequest = (data) => {
62
67
  },
63
68
  };
64
69
  };
70
+ const generateConfigurationLineItem = (props, qty = 1) => {
71
+ const id = UUID.UUID();
72
+ const attributes = Object.entries(props.attributesMap ?? {}).map(([name, value]) => ({
73
+ name,
74
+ value,
75
+ cfgStatus: 'User',
76
+ }));
77
+ const lineItems = [];
78
+ return {
79
+ id,
80
+ type: props.product.typeName ?? '',
81
+ cfgStatus: 'Default',
82
+ actionCode: 'ADD',
83
+ qty,
84
+ attributes,
85
+ lineItems,
86
+ productName: props.product.name,
87
+ productId: props.product.id ?? '',
88
+ };
89
+ };
65
90
 
66
91
  class ContextService {
67
92
  constructor(contextApiService) {
@@ -71,9 +96,25 @@ class ContextService {
71
96
  get isInitialized() {
72
97
  return Boolean(this.context.value);
73
98
  }
99
+ get isInitialized$() {
100
+ return this.context.pipe(map(Boolean));
101
+ }
74
102
  get mode() {
75
103
  return this.resolve().properties.mode;
76
104
  }
105
+ get isEditMode$() {
106
+ return this.resolve$().pipe(map(() => this.isEditMode));
107
+ }
108
+ get isEditMode() {
109
+ const context = this.resolve();
110
+ if (context.mode === ConfigurationContextMode.ACCOUNT) {
111
+ return true;
112
+ }
113
+ if (context.mode === ConfigurationContextMode.QUOTE) {
114
+ return context.properties.Status === 'Draft';
115
+ }
116
+ return false;
117
+ }
77
118
  resolve() {
78
119
  if (!this.context.value) {
79
120
  throw new Error('Context is not initialized yet!');
@@ -86,6 +127,18 @@ class ContextService {
86
127
  create(headerId, mode) {
87
128
  return this.contextApiService.getContext(headerId, mode).pipe(tap(context => this.context.next(merge(new ConfigurationContext(headerId, mode), context))), map(() => this.resolve()));
88
129
  }
130
+ initTestMode() {
131
+ return this.create('TestId', ConfigurationContextMode.TEST).pipe(map(context => {
132
+ return this.update({
133
+ properties: {
134
+ ...context.properties,
135
+ RuntimeMode: ConfigurationContextMode.TEST,
136
+ StartDate: new Date().toISOString().substring(0, 10),
137
+ standalone: 'true',
138
+ },
139
+ });
140
+ }));
141
+ }
89
142
  update(partialContext) {
90
143
  const originalContext = this.resolve();
91
144
  const updatedContext = {
@@ -112,13 +165,14 @@ class ContextService {
112
165
  this.context.next(null);
113
166
  }
114
167
  }
115
- ContextService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.8", ngImport: i0, type: ContextService, deps: [{ token: i1.ContextApiService }], target: i0.ɵɵFactoryTarget.Injectable });
116
- ContextService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.8", ngImport: i0, type: ContextService, providedIn: 'root' });
117
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.8", ngImport: i0, type: ContextService, decorators: [{
118
- type: Injectable,
119
- args: [{ providedIn: 'root' }]
168
+ ContextService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: ContextService, deps: [{ token: i1.ContextApiService }], target: i0.ɵɵFactoryTarget.Injectable });
169
+ ContextService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: ContextService });
170
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: ContextService, decorators: [{
171
+ type: Injectable
120
172
  }], ctorParameters: function () { return [{ type: i1.ContextApiService }]; } });
121
173
 
174
+ const FLOW_CUSTOMIZATION = new InjectionToken('FLOW_CUSTOMIZATION');
175
+
122
176
  const FORMATTING_SETTINGS_TOKEN = new InjectionToken('Summary of formatting settings for variant types of data, e.g. numbers, text, dates, etc');
123
177
 
124
178
  var RuntimeMode;
@@ -139,416 +193,146 @@ var RuntimeStep;
139
193
 
140
194
  const UI_DEFINITION_VERSION = 3;
141
195
 
142
- class RuntimeContextService {
143
- constructor(configurationApiService) {
144
- this.configurationApiService = configurationApiService;
145
- }
146
- getRuntimeContext(productId, offeringId) {
147
- return this.configurationApiService.getRuntimeDataByProductId(productId, offeringId).pipe(map(runtimeData => {
148
- const uiDefinitionContainer = this.getUIDefinitionContainer(runtimeData);
149
- const runtimeModel = RuntimeModel.create(runtimeData.types, runtimeData.products);
150
- const { productName, properties } = Array.from(runtimeModel.components.values()).find(c => c.productId === productId) ?? {};
151
- const uiDefinitionProperties = getUIDefinitionProperties(uiDefinitionContainer);
152
- return {
153
- modelId: runtimeData.modelId,
154
- uiDefinitionContainer: uiDefinitionContainer,
155
- runtimeModel: runtimeModel,
156
- runtimeMode: RuntimeMode.PROD,
157
- productId: productId,
158
- productType: properties?.['displayName'] || productName,
159
- offeringId: offeringId,
160
- properties: {
161
- PricingEnabled: uiDefinitionProperties.pricingEnabled ? 'true' : 'false',
162
- PriceListId: uiDefinitionProperties.priceList,
163
- },
164
- };
196
+ class FlowInfoService {
197
+ get flow() {
198
+ return this.flowSubj$.value;
199
+ }
200
+ set flow(value) {
201
+ this.flowSubj$.next(value);
202
+ }
203
+ get isLegacy() {
204
+ return !!this.flow && this.flow?.properties.stateful == null;
205
+ }
206
+ get isStateful() {
207
+ return !!this.flow?.properties.stateful;
208
+ }
209
+ constructor(flowsApiService, templatesApiService, customizationService) {
210
+ this.flowsApiService = flowsApiService;
211
+ this.templatesApiService = templatesApiService;
212
+ this.customizationService = customizationService;
213
+ this.templates = {};
214
+ this.defaultTemplates = {
215
+ flowEngine: 'Flow Engine',
216
+ };
217
+ this.flowSubj$ = new BehaviorSubject(null);
218
+ this.flow$ = this.flowSubj$.asObservable();
219
+ }
220
+ init$(flowId, params) {
221
+ this.params = params;
222
+ return this.flowsApiService.getFlow(flowId).pipe(switchMap(flow => this.initFlowTemplates$(flow).pipe(map$1(() => flow))), tap$1(flow => this.flowSubj$.next(flow)), map$1(noop), catchError(e => {
223
+ this.flowSubj$.next(null);
224
+ return throwError(() => e);
165
225
  }));
166
226
  }
167
- getUIDefinitionContainer(runtimeData) {
168
- const containers = runtimeData.uiDefinitions.filter(container => !isLegacyUIDefinition(container.source));
169
- return containers.find(container => container.source.primary) ?? containers[0];
170
- }
171
- }
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 });
173
- RuntimeContextService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.8", ngImport: i0, type: RuntimeContextService });
174
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.8", ngImport: i0, type: RuntimeContextService, decorators: [{
175
- type: Injectable
176
- }], ctorParameters: function () { return [{ type: i1.ConfigurationApiService }]; } });
177
-
178
- class ConfigurationRuntimeService {
179
- constructor(apiService, contextService, runtimeContextService) {
180
- this.apiService = apiService;
181
- this.contextService = contextService;
182
- this.runtimeContextService = runtimeContextService;
183
- this._isInitialized = false;
184
- this.uiDefinitionProperties = {};
185
- }
186
- reset() {
187
- this._isInitialized = false;
188
- this._runtimeContext = undefined;
189
- this.initializationProps = undefined;
190
- this.uiDefinitionProperties = {};
191
- }
192
- initTestMode(uiDefinitionContainer) {
193
- this.uiDefinitionProperties = getUIDefinitionProperties(uiDefinitionContainer);
194
- const uiDefinitionExternals = uiDefinitionContainer.source.externals ?? {};
195
- return combineLatest([
196
- this.apiService.getRuntimeDataByModelId(uiDefinitionContainer.modelId),
197
- this.contextService.create('TestId', ConfigurationContextMode.TEST),
198
- ]).pipe(first(), map(([runtimeData, context]) => {
199
- this.contextService.update({
200
- properties: {
201
- ...this.runtimeContext?.properties,
202
- ...context.properties,
203
- ModelId: uiDefinitionContainer.modelId,
204
- RuntimeMode: ConfigurationContextMode.TEST,
205
- PricingEnabled: this.uiDefinitionProperties.pricingEnabled ? 'true' : 'false',
206
- StartDate: new Date().toISOString().substring(0, 10),
207
- PriceListId: this.uiDefinitionProperties.priceList,
208
- offeringId: this.uiDefinitionProperties.offeringId,
209
- standalone: 'true',
210
- ...uiDefinitionExternals,
211
- },
212
- });
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)));
221
- }
222
- init(props) {
223
- this.initializationProps = props;
224
- const context = this.contextService.resolve();
225
- return this.runtimeContextService.getRuntimeContext(props.productId, props.offeringId).pipe(tap(runtimeContext => {
226
- this.uiDefinitionProperties = getUIDefinitionProperties(runtimeContext.uiDefinitionContainer);
227
- const { PriceListId } = context.properties ?? {};
228
- const mergeContext = {
229
- ...runtimeContext,
230
- properties: {
231
- ...runtimeContext.properties,
232
- ...context.properties,
233
- PricingEnabled: PriceListId ? 'true' : 'false',
234
- },
235
- };
236
- this.id15to18('AccountId', mergeContext.properties);
237
- this._runtimeContext = mergeContext;
238
- if (context.properties && this._runtimeContext.properties?.StartDate) {
239
- this.contextService.update({
240
- properties: {
241
- ...this._runtimeContext.properties,
242
- ...context.properties,
243
- },
244
- });
245
- }
246
- return this._runtimeContext;
247
- }), tap(() => (this._isInitialized = true)));
227
+ cleanup() {
228
+ this.flowSubj$.next(null);
229
+ this.params = undefined;
230
+ this.templates = {};
248
231
  }
249
- overrideUIDefinition(uiDefinitionContainer) {
250
- if (!this._runtimeContext) {
251
- return;
232
+ initFlowTemplates$(flow) {
233
+ if (isEmpty(flow.properties.templates)) {
234
+ return of(undefined);
252
235
  }
253
- this._runtimeContext.uiDefinitionContainer = uiDefinitionContainer;
254
- this.uiDefinitionProperties = getUIDefinitionProperties(uiDefinitionContainer);
236
+ return forkJoin([
237
+ this.templatesApiService.fetchTemplates$(),
238
+ this.customizationService?.getTemplates?.() ?? of([]),
239
+ ]).pipe(map$1(([templates, localTemplates]) => {
240
+ Object.entries({ ...this.defaultTemplates, ...flow.properties.templates }).forEach(([key, name]) => {
241
+ const type = this.remapTemplateName(key);
242
+ if (type) {
243
+ this.templates[type] =
244
+ localTemplates.find(template => template.name === name && template.type === type) ??
245
+ templates.find(template => template.name === name && template.type === type);
246
+ }
247
+ });
248
+ }));
255
249
  }
256
- id15to18(propertyName, source) {
257
- if (!source) {
258
- return;
250
+ remapTemplateName(templateType) {
251
+ switch (templateType) {
252
+ case 'flowEngine':
253
+ return UITemplateType.FLOW_ENGINE;
254
+ default:
255
+ break;
259
256
  }
260
- const value = source[propertyName];
261
- if (typeof value === 'string' && value.length === 15) {
262
- source[propertyName] = SalesforceIdUtils.generateId18FromId15(value);
257
+ switch (templateType) {
258
+ case 'assets':
259
+ case 'shoppingCart':
260
+ // No separate Assets template at the moment
261
+ return UITemplateType.SHOPPING_CART;
262
+ case 'catalog':
263
+ return UITemplateType.CATALOG;
264
+ case 'docGen':
265
+ return UITemplateType.DOCGEN;
266
+ case 'guidedSelling':
267
+ return UITemplateType.GUIDED_SELLING;
268
+ case 'flowHeader':
269
+ return UITemplateType.FLOW_HEADER;
270
+ default:
271
+ break;
263
272
  }
264
- }
265
- get isInitialized() {
266
- return this._isInitialized;
267
- }
268
- get runtimeModel() {
269
- return this.runtimeContext?.runtimeModel;
270
- }
271
- get runtimeContext() {
272
- return this._runtimeContext;
273
+ return undefined;
273
274
  }
274
275
  }
275
- ConfigurationRuntimeService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.8", ngImport: i0, type: ConfigurationRuntimeService, deps: [{ token: i1.ConfigurationApiService }, { token: ContextService }, { token: RuntimeContextService }], target: i0.ɵɵFactoryTarget.Injectable });
276
- ConfigurationRuntimeService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.8", ngImport: i0, type: ConfigurationRuntimeService });
277
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.8", ngImport: i0, type: ConfigurationRuntimeService, decorators: [{
276
+ FlowInfoService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: FlowInfoService, deps: [{ token: i1.FlowsApiService }, { token: i1.UITemplatesApiService }, { token: FLOW_CUSTOMIZATION, optional: true }], target: i0.ɵɵFactoryTarget.Injectable });
277
+ FlowInfoService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: FlowInfoService });
278
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: FlowInfoService, decorators: [{
278
279
  type: Injectable
279
- }], ctorParameters: function () { return [{ type: i1.ConfigurationApiService }, { type: ContextService }, { type: RuntimeContextService }]; } });
280
+ }], ctorParameters: function () { return [{ type: i1.FlowsApiService }, { type: i1.UITemplatesApiService }, { type: undefined, decorators: [{
281
+ type: Optional
282
+ }, {
283
+ type: Inject,
284
+ args: [FLOW_CUSTOMIZATION]
285
+ }] }]; } });
280
286
 
281
- class QuoteDraftService {
282
- get isInitialized() {
283
- return this.isInitializedSubj$.getValue();
284
- }
285
- set isInitialized(value) {
286
- if (this.isInitialized !== value) {
287
- this.isInitializedSubj$.next(value);
287
+ const findLineItem = (id, lineItems) => {
288
+ return findLineItemWithComparator(lineItems, (li) => li.id === id);
289
+ };
290
+ const findLineItemWithComparator = (lineItems, comparator) => {
291
+ let currentLevel = lineItems;
292
+ while (currentLevel.length) {
293
+ const found = currentLevel.find(comparator);
294
+ if (found) {
295
+ return found;
288
296
  }
297
+ currentLevel = flatten(currentLevel.map(parent => parent.lineItems));
289
298
  }
290
- get hasUnsavedChanges() {
291
- return this._hasUnsavedChanges;
292
- }
293
- set hasUnsavedChanges(value) {
294
- this._hasUnsavedChanges = value;
295
- if (!this._hasUnsavedChanges) {
296
- this.initialCurrentState = this.quoteDraft?.currentState ?? [];
297
- }
298
- }
299
- get hasProducts$() {
300
- return this.quoteSubj$.pipe(map(() => this.hasProducts));
301
- }
302
- get hasProducts() {
303
- const quoteDraft = this.quoteSubj$.value;
304
- return Boolean(quoteDraft && quoteDraft.currentState.length > 0);
305
- }
306
- constructor(context, quoteApiService, priceApiService) {
307
- this.context = context;
308
- this.quoteApiService = quoteApiService;
309
- this.priceApiService = priceApiService;
310
- this.quoteSubj$ = new BehaviorSubject(null);
311
- this.resetSubj$ = new BehaviorSubject(true);
312
- this.isInitializedSubj$ = new BehaviorSubject(false);
313
- this.initialCurrentState = [];
314
- this._hasUnsavedChanges = false;
315
- this.allPriceLists = [];
316
- this.assetPriceLists = [];
317
- this.reset$ = this.resetSubj$.asObservable();
318
- this.activePriceList$ = this.context.resolve$().pipe(map(ctx => this.allPriceLists.find(priceList => priceList.id === ctx.properties.PriceListId)), map(priceList => priceList ?? null));
319
- this.isInitializedSubj$
320
- .pipe(filter(isInitialized => isInitialized), switchMap(() => this.quoteSubj$.asObservable()), skip(1), tap(quote => this.markAsUpdated(quote)))
321
- .subscribe();
322
- }
323
- reset() {
324
- this.resetSubj$.next(true);
325
- this.quoteSubj$.next(null);
326
- this.hasUnsavedChanges = false;
327
- }
328
- init(quoteId, params) {
329
- return zip(this.quoteApiService.getQuoteDraft(quoteId, params), this.priceApiService.getPriceLists()).pipe(tap(([quote, allPriceLists]) => {
330
- this.allPriceLists = allPriceLists;
331
- this.quoteSubj$.next(quote);
332
- this.context.update(quote.context);
333
- this.populateActivePriceLists$();
334
- }), map(() => noop()), take(1));
335
- }
336
- setCurrentLineItemState(lineItems) {
337
- const quoteDraft = this.quoteSubj$.value;
338
- if (!quoteDraft) {
339
- return;
340
- }
341
- this.quoteSubj$.next({
342
- ...quoteDraft,
343
- currentState: lineItems,
344
- });
345
- }
346
- updateQuoteDraft(update) {
347
- const quoteDraft = this.quoteSubj$.value;
348
- if (!quoteDraft) {
349
- return;
350
- }
351
- if (update.context) {
352
- this.context.set(update.context);
353
- }
354
- this.quoteSubj$.next({
355
- ...quoteDraft,
356
- ...update,
357
- });
358
- }
359
- updateByPriceSummary(priceSummary) {
360
- const quoteDraft = this.quoteSubj$.value;
361
- if (!quoteDraft) {
362
- return;
363
- }
364
- const updatedCurrentState = this.currentState.map(lineItem => {
365
- const updated = priceSummary.lineItems.find(li => li.id === lineItem.id);
366
- return updated ?? lineItem;
367
- });
368
- this.quoteSubj$.next({
369
- ...quoteDraft,
370
- currentState: updatedCurrentState,
371
- totalPrices: priceSummary.totalPrices,
372
- approvalItems: priceSummary.approvalItems,
373
- });
374
- }
375
- get quoteDraft$() {
376
- return combineLatest([this.quoteSubj$, this.context.resolve$()]).pipe(map(() => this.quoteDraft), filter((quote) => Boolean(quote)), shareReplay());
377
- }
378
- get quoteDraft() {
379
- const quote = this.quoteSubj$.value;
380
- if (!quote) {
381
- return null;
382
- }
383
- return {
384
- ...quote,
385
- context: this.context.resolve(),
386
- };
387
- }
388
- get quoteDraftForActivePriceList() {
389
- const quoteDraft = this.quoteDraft;
390
- if (!quoteDraft) {
391
- return null;
392
- }
393
- return {
394
- ...quoteDraft,
395
- initialState: this.filterByActivePriceList(quoteDraft.initialState),
396
- currentState: this.filterByActivePriceList(quoteDraft.currentState),
397
- };
398
- }
399
- get currentState$() {
400
- return this.quoteDraft$.pipe(map(quote => quote.currentState));
401
- }
402
- get currentState() {
403
- return this.quoteDraft?.currentState ?? [];
404
- }
405
- /**
406
- * Stream of activeCurrentState
407
- */
408
- get activeCurrentState$() {
409
- return this.quoteDraft$.pipe(map(() => this.activeCurrentState));
410
- }
411
- /**
412
- * activeCurrentState is currentState passed through additional filters
413
- */
414
- get activeCurrentState() {
415
- let currentState = this.quoteDraft?.currentState ?? [];
416
- currentState = this.filterByActivePriceList(currentState);
417
- return currentState;
418
- }
419
- /**
420
- * Stream of activeInitialState
421
- */
422
- get activeInitialState$() {
423
- return this.quoteDraft$.pipe(map(() => this.activeInitialState));
424
- }
425
- /**
426
- * activeInitialState is initialState passed through additional filters
427
- */
428
- get activeInitialState() {
429
- const ctx = this.context.resolve();
430
- let initialState = this.quoteDraft?.initialState ?? [];
431
- if (ctx.mode === ConfigurationContextMode.ACCOUNT) {
432
- initialState = this.filterByActivePriceList(initialState);
433
- }
434
- return initialState;
435
- }
436
- get isStandalone() {
437
- return this.context.resolve().properties.standalone === 'true';
438
- }
439
- get isStandalone$() {
440
- return this.context.resolve$().pipe(map(() => this.isStandalone));
441
- }
442
- getInitialCurrentState() {
443
- return this.initialCurrentState;
444
- }
445
- isEditMode$() {
446
- return this.context.resolve$().pipe(map(() => this.isEditMode()));
447
- }
448
- isEditMode() {
449
- const context = this.context.resolve();
450
- if (context.mode === ConfigurationContextMode.ACCOUNT) {
451
- return true;
452
- }
453
- if (context.mode === ConfigurationContextMode.QUOTE) {
454
- return context.properties.Status === 'Draft';
455
- }
456
- return false;
457
- }
458
- updateActivePriceList(priceListId) {
459
- this.context.update({ properties: { PriceListId: priceListId } });
460
- }
461
- populateActivePriceLists$() {
462
- const ctx = this.context.resolve();
463
- const quoteDraft = this.quoteDraft;
464
- if (!quoteDraft) {
465
- return;
466
- }
467
- // In ACCOUNT mode populate price lists from related assets
468
- if (ctx.mode === ConfigurationContextMode.ACCOUNT) {
469
- // Populate list of price lists
470
- this.assetPriceLists = quoteDraft.currentState
471
- .map(({ priceListId }) => priceListId)
472
- .reduce((trunk, priceListId) => {
473
- if (!priceListId || trunk.some(item => item.id === priceListId)) {
474
- return trunk;
475
- }
476
- return [
477
- ...trunk,
478
- { id: priceListId, name: this.allPriceLists.find(item => item.id === priceListId)?.name ?? '' },
479
- ];
480
- }, []);
481
- }
482
- }
483
- filterByActivePriceList(lineItems) {
484
- const ctx = this.context.resolve();
485
- return lineItems.filter(li => !li.priceListId || li.priceListId === ctx.properties.PriceListId);
486
- }
487
- markAsUpdated(quote) {
488
- if (quote?.context.properties.mode === ConfigurationContextMode.ACCOUNT) {
489
- this.hasUnsavedChanges = !!quote && !quote.currentState.every(li => li.actionCode === 'EXIST');
490
- }
491
- else {
492
- this.hasUnsavedChanges = !isEqual(this.initialCurrentState, quote?.currentState);
493
- }
494
- }
495
- }
496
- QuoteDraftService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.8", ngImport: i0, type: QuoteDraftService, deps: [{ token: ContextService }, { token: i1.QuoteApiService }, { token: i1.PriceApiService }], target: i0.ɵɵFactoryTarget.Injectable });
497
- QuoteDraftService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.8", ngImport: i0, type: QuoteDraftService, providedIn: 'root' });
498
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.8", ngImport: i0, type: QuoteDraftService, decorators: [{
499
- type: Injectable,
500
- args: [{ providedIn: 'root' }]
501
- }], ctorParameters: function () { return [{ type: ContextService }, { type: i1.QuoteApiService }, { type: i1.PriceApiService }]; } });
502
-
503
- const findLineItem = (id, lineItems) => {
504
- return findLineItemWithComparator(lineItems, (li) => li.id === id);
505
- };
506
- const findLineItemWithComparator = (lineItems, comparator) => {
507
- let currentLevel = lineItems;
508
- while (currentLevel.length) {
509
- const found = currentLevel.find(comparator);
510
- if (found) {
511
- return found;
512
- }
513
- currentLevel = flatten(currentLevel.map(parent => parent.lineItems));
514
- }
515
- return;
516
- };
517
- const insertLineItem = (lineItem, parentId, toInsert) => {
518
- const insertData = lineItem.id === parentId ? [toInsert] : [];
519
- return {
520
- ...lineItem,
521
- lineItems: [
522
- ...insertData,
523
- ...lineItem.lineItems.map(li => {
524
- return insertLineItem(li, parentId, toInsert);
525
- }),
526
- ],
527
- };
528
- };
529
- const removeLineItem = (lineItem, idToRemove) => {
530
- return {
531
- ...lineItem,
532
- lineItems: lineItem.lineItems
533
- .map(li => {
534
- if (li.id === idToRemove) {
535
- return;
536
- }
537
- else if (li.lineItems.length) {
538
- return removeLineItem(li, idToRemove);
539
- }
540
- return li;
541
- })
542
- .filter(r => !!r),
543
- };
544
- };
545
- const replaceLineItem = (lineItem, replaceTo, skipCardinalityCalculation = false) => {
546
- if (lineItem.id === replaceTo.id) {
547
- if (!skipCardinalityCalculation) {
548
- return { ...recalculateCardinalityVariables(lineItem, replaceTo) };
549
- }
550
- else {
551
- return { ...replaceTo };
299
+ return;
300
+ };
301
+ const insertLineItem = (lineItem, parentId, toInsert) => {
302
+ const insertData = lineItem.id === parentId ? [toInsert] : [];
303
+ return {
304
+ ...lineItem,
305
+ lineItems: [
306
+ ...insertData,
307
+ ...lineItem.lineItems.map(li => {
308
+ return insertLineItem(li, parentId, toInsert);
309
+ }),
310
+ ],
311
+ };
312
+ };
313
+ const removeLineItem = (lineItem, idToRemove) => {
314
+ return {
315
+ ...lineItem,
316
+ lineItems: lineItem.lineItems
317
+ .map(li => {
318
+ if (li.id === idToRemove) {
319
+ return;
320
+ }
321
+ else if (li.lineItems.length) {
322
+ return removeLineItem(li, idToRemove);
323
+ }
324
+ return li;
325
+ })
326
+ .filter(r => !!r),
327
+ };
328
+ };
329
+ const replaceLineItem = (lineItem, replaceTo, skipCardinalityCalculation = false) => {
330
+ if (lineItem.id === replaceTo.id) {
331
+ if (!skipCardinalityCalculation) {
332
+ return { ...recalculateCardinalityVariables(lineItem, replaceTo) };
333
+ }
334
+ else {
335
+ return { ...replaceTo };
552
336
  }
553
337
  }
554
338
  return {
@@ -556,27 +340,42 @@ const replaceLineItem = (lineItem, replaceTo, skipCardinalityCalculation = false
556
340
  lineItems: lineItem.lineItems.map(li => replaceLineItem(li, replaceTo, skipCardinalityCalculation)),
557
341
  };
558
342
  };
559
- const calculateCardinalityVariables = (lineItems) => {
343
+ const collectCardinalityComputations = (portDomains) => {
344
+ const cardinalityComputations = new Map();
345
+ entries(portDomains).forEach(([key, portDomain]) => {
346
+ cardinalityComputations.set(key, portDomain.properties['cardinalityComputation'] === 'true');
347
+ });
348
+ return cardinalityComputations;
349
+ };
350
+ const calculateCardinalityVariables = (lineItems, cardinalityComputations) => {
560
351
  const cardVars = new Map();
561
352
  lineItems
562
353
  .filter(({ port, type }) => !!port && !!type)
563
354
  .forEach(li => {
564
- const cardinalityVariableName = `#CV-${li.type}@${li.port}`;
565
- cardVars.set(cardinalityVariableName, (cardVars.get(cardinalityVariableName) ?? 0) + li.qty);
355
+ if (cardinalityComputations.get(`${li.port}`)) {
356
+ const cardinalityVariableName = `#CV-${li.type}@${li.port}`;
357
+ cardVars.set(cardinalityVariableName, (cardVars.get(cardinalityVariableName) ?? 0) + li.qty);
358
+ }
566
359
  });
567
360
  return cardVars;
568
361
  };
362
+ const cardinalityRegexp = new RegExp('#CV-[a-zA-Z0-9_]+@(?<portName>[a-zA-Z0-9_]+)');
569
363
  const recalculateCardinalityVariables = (original, updated) => {
570
- const cardinalityVariables = calculateCardinalityVariables(updated.lineItems);
571
- const originalCardinalityVariables = calculateCardinalityVariables(original.lineItems);
364
+ const cardinalityComputations = collectCardinalityComputations(updated.portDomains ?? original.portDomains ?? {});
365
+ const cardinalityVariables = calculateCardinalityVariables(updated.lineItems, cardinalityComputations);
366
+ const originalCardinalityVariables = calculateCardinalityVariables(original.lineItems, cardinalityComputations);
572
367
  originalCardinalityVariables.forEach((value, key) => {
573
- if (cardinalityVariables.get(key) === value) {
574
- // no need to update cardinality if no changes
575
- cardinalityVariables.delete(key);
576
- }
577
- else if (!cardinalityVariables.has(key)) {
578
- // remove last item from port
579
- cardinalityVariables.set(key, 0);
368
+ const execArray = cardinalityRegexp.exec(key);
369
+ const portName = execArray?.groups?.['portName'];
370
+ if (!portName || cardinalityComputations.get(portName)) {
371
+ if (cardinalityVariables.get(key) === value) {
372
+ // no need to update cardinality if no changes
373
+ cardinalityVariables.delete(key);
374
+ }
375
+ else if (!cardinalityVariables.has(key)) {
376
+ // remove last item from port
377
+ cardinalityVariables.set(key, 0);
378
+ }
580
379
  }
581
380
  });
582
381
  return {
@@ -596,7 +395,7 @@ const upsertAttributes = (originalAttributes, attributesToUpsert) => {
596
395
  const [origAttr] = getAttributes(acc, [name]);
597
396
  return [
598
397
  ...acc.filter(attr => attr.name !== name),
599
- { ...(origAttr ?? { name }), cfgStatus: origAttr ? 'Changed' : 'User', value },
398
+ { ...(origAttr ?? { name, type: '' }), cfgStatus: origAttr ? 'Changed' : 'User', value },
600
399
  ];
601
400
  }, originalAttributes);
602
401
  };
@@ -666,7 +465,7 @@ const multiplyLineItems = (lineItem, qty, split) => {
666
465
  id: UUID.UUID(),
667
466
  lineItems: lineItem.lineItems.map(unifyIds),
668
467
  });
669
- return map$1(new Array(qty), () => unifyIds(lineItem));
468
+ return map$2(new Array(qty), () => unifyIds(lineItem));
670
469
  }
671
470
  else {
672
471
  return [
@@ -686,7 +485,6 @@ const filterOutTechnicalAttributes = (attributes) => {
686
485
 
687
486
  var lineItem_utils = /*#__PURE__*/Object.freeze({
688
487
  __proto__: null,
689
- calculateCardinalityVariables: calculateCardinalityVariables,
690
488
  filterOutTechnicalAttributes: filterOutTechnicalAttributes,
691
489
  findLineItem: findLineItem,
692
490
  findLineItemWithComparator: findLineItemWithComparator,
@@ -726,61 +524,930 @@ class LineItemWorker {
726
524
  }
727
525
  }
728
526
 
729
- class ConfigurationService {
730
- constructor(quoteDraftService, runtimeService, contextService, configurationApiService, messageService, dialogService) {
731
- this.quoteDraftService = quoteDraftService;
732
- this.runtimeService = runtimeService;
733
- this.contextService = contextService;
734
- this.configurationApiService = configurationApiService;
735
- this.messageService = messageService;
736
- this.dialogService = dialogService;
737
- this.mode = ConfigurationMode.SEARCH;
738
- this.lineItem = new BehaviorSubject(undefined);
739
- this.charges = new BehaviorSubject({});
740
- this.pricePlans = new BehaviorSubject({});
741
- this.isLoadingSubj$ = new BehaviorSubject(false);
742
- this.isLoading$ = this.isLoadingSubj$.asObservable();
743
- this.hasUnsavedChanges = false;
527
+ function extractMetadata(uiDefinition) {
528
+ return omit(uiDefinition, [
529
+ 'children',
530
+ 'pages',
531
+ 'components',
532
+ ]);
533
+ }
534
+
535
+ class IntegrationState {
536
+ constructor() {
537
+ this.stateSubj$ = new BehaviorSubject({});
538
+ this.action$ = new Subject();
744
539
  }
745
- reset() {
746
- this.hasUnsavedChanges = false;
747
- this.runtimeService.reset();
748
- this.configurableRamp = undefined;
749
- this.lineItem.next(undefined);
750
- this.charges.next({});
751
- this.pricePlans.next({});
540
+ get state$() {
541
+ return this.stateSubj$.asObservable();
752
542
  }
753
- patch$(lineItem, options) {
754
- if (!this.lineItem.value) {
755
- return throwError(() => new Error(`Source LineItem not found`));
756
- }
757
- const skipCardinalityCalculation = options?.skipCardinalityCalculation || this.contextSnapshot.properties['#skipCardinalityCalculation'] === 'true';
758
- this.configurableRamp = new LineItemWorker(this.lineItem.value).replace(lineItem, skipCardinalityCalculation).li;
759
- return this.configure().pipe(catchError(error => {
760
- console.error(error);
761
- if (!this.runtimeService.uiDefinitionProperties.suppressToastMessages) {
762
- this.messageService.add({ severity: 'error', summary: error });
763
- }
764
- // bounce back if configuration call has failed
765
- this.lineItem.next(this.lineItem.value ? { ...this.lineItem.value } : undefined);
766
- return throwError(() => error);
767
- }), tap(() => {
768
- if (!this.hasUnsavedChanges) {
769
- this.hasUnsavedChanges = true;
770
- }
771
- }));
543
+ get state() {
544
+ return this.stateSubj$.getValue();
772
545
  }
773
- patch(lineItem, options) {
546
+ patchState(update) {
547
+ this.stateSubj$.next({ ...this.stateSubj$.getValue(), ...update });
548
+ }
549
+ dispatch(action) {
550
+ this.action$.next(action);
551
+ }
552
+ listen$(actionType) {
553
+ return this.action$.pipe(filter$1(action => action.type === actionType), map$1(action => action.payload));
554
+ }
555
+ listenAll$() {
556
+ return this.action$.asObservable();
557
+ }
558
+ clear() {
559
+ this.stateSubj$.next({});
560
+ }
561
+ }
562
+ IntegrationState.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: IntegrationState, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
563
+ IntegrationState.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: IntegrationState });
564
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: IntegrationState, decorators: [{
565
+ type: Injectable
566
+ }] });
567
+
568
+ class QuoteDraftService {
569
+ get isInitialized$() {
570
+ return this.isInitializedSubj$.asObservable();
571
+ }
572
+ get isInitialized() {
573
+ return this.isInitializedSubj$.getValue();
574
+ }
575
+ set isInitialized(value) {
576
+ if (this.isInitialized !== value) {
577
+ this.isInitializedSubj$.next(value);
578
+ }
579
+ }
580
+ get hasUnsavedChanges() {
581
+ return this._hasUnsavedChanges;
582
+ }
583
+ set hasUnsavedChanges(value) {
584
+ this._hasUnsavedChanges = value;
585
+ if (!this._hasUnsavedChanges) {
586
+ this.initialCurrentState = this.quoteDraft?.currentState ?? [];
587
+ }
588
+ }
589
+ get hasProducts$() {
590
+ return this.quoteSubj$.pipe(map(() => this.hasProducts));
591
+ }
592
+ get hasProducts() {
593
+ const quoteDraft = this.quoteSubj$.value;
594
+ return this.filterByActivePriceList(quoteDraft?.currentState || []).some(li => !li.assetId && !li.openOrderLineItemId);
595
+ }
596
+ get hasAssets$() {
597
+ return this.quoteSubj$.pipe(map(() => this.hasAssets));
598
+ }
599
+ get hasAssets() {
600
+ const quoteDraft = this.quoteSubj$.value;
601
+ return this.filterByActivePriceList(quoteDraft?.currentState || []).some(li => li.assetId || li.openOrderLineItemId);
602
+ }
603
+ constructor(context, quoteApiService, priceApiService, integrationState) {
604
+ this.context = context;
605
+ this.quoteApiService = quoteApiService;
606
+ this.priceApiService = priceApiService;
607
+ this.integrationState = integrationState;
608
+ this.quoteSubj$ = new BehaviorSubject(null);
609
+ this.resetSubj$ = new BehaviorSubject(true);
610
+ this.isInitializedSubj$ = new BehaviorSubject(false);
611
+ this.initialCurrentState = [];
612
+ this._hasUnsavedChanges = false;
613
+ this.allPriceLists = [];
614
+ this.assetPriceLists = [];
615
+ this.reset$ = this.resetSubj$.asObservable();
616
+ this.activePriceList$ = this.context.resolve$().pipe(map(ctx => this.allPriceLists.find(priceList => priceList.id === ctx.properties.PriceListId)), map(priceList => priceList ?? null));
617
+ this.isInitializedSubj$
618
+ .pipe(filter(isInitialized => isInitialized), switchMap$1(() => this.quoteSubj$.asObservable()), skip(1), tap(quote => this.markAsUpdated(quote)))
619
+ .subscribe();
620
+ }
621
+ reset() {
622
+ this.resetSubj$.next(true);
623
+ this.quoteSubj$.next(null);
624
+ this.isInitialized = false;
625
+ this.hasUnsavedChanges = false;
626
+ }
627
+ init(quoteId, params) {
628
+ return zip(this.quoteApiService.getQuoteDraft(quoteId, params), this.priceApiService.getPriceLists()).pipe(tap(([quote, allPriceLists]) => {
629
+ this.allPriceLists = allPriceLists;
630
+ this.quoteSubj$.next(quote);
631
+ this.context.update(quote.context);
632
+ this.populateActivePriceLists$();
633
+ }), map(() => noop()), take(1));
634
+ }
635
+ finalizeInit() {
636
+ this.initializeModifiedAssetsMap();
637
+ this.isInitialized = true;
638
+ this.hasUnsavedChanges = false;
639
+ }
640
+ setCurrentLineItemState(lineItems) {
641
+ const quoteDraft = this.quoteSubj$.value;
642
+ if (!quoteDraft) {
643
+ return;
644
+ }
645
+ this.quoteSubj$.next({
646
+ ...quoteDraft,
647
+ currentState: lineItems,
648
+ });
649
+ }
650
+ updateQuoteDraft(update) {
651
+ const quoteDraft = this.quoteSubj$.value;
652
+ if (!quoteDraft) {
653
+ return;
654
+ }
655
+ if (update.context) {
656
+ this.context.set(update.context);
657
+ }
658
+ this.quoteSubj$.next({
659
+ ...quoteDraft,
660
+ ...update,
661
+ });
662
+ }
663
+ updateByPriceSummary(priceSummary) {
664
+ const quoteDraft = this.quoteSubj$.value;
665
+ if (!quoteDraft) {
666
+ return;
667
+ }
668
+ const updatedCurrentState = this.currentState.map(lineItem => {
669
+ const updated = priceSummary.lineItems.find(li => li.id === lineItem.id);
670
+ return updated ?? lineItem;
671
+ });
672
+ this.quoteSubj$.next({
673
+ ...quoteDraft,
674
+ currentState: updatedCurrentState,
675
+ totalPrices: priceSummary.totalPrices,
676
+ approvalItems: priceSummary.approvalItems,
677
+ });
678
+ }
679
+ get quoteDraft$() {
680
+ return combineLatest([this.quoteSubj$, this.context.resolve$()]).pipe(map(() => this.quoteDraft), filter((quote) => Boolean(quote)), shareReplay());
681
+ }
682
+ get quoteDraft() {
683
+ const quote = this.quoteSubj$.value;
684
+ if (!quote) {
685
+ return null;
686
+ }
687
+ return {
688
+ ...quote,
689
+ context: this.context.resolve(),
690
+ };
691
+ }
692
+ get quoteDraftForActivePriceList() {
693
+ const quoteDraft = this.quoteDraft;
694
+ if (!quoteDraft) {
695
+ return null;
696
+ }
697
+ return {
698
+ ...quoteDraft,
699
+ initialState: this.filterByActivePriceList(quoteDraft.initialState),
700
+ currentState: this.filterByActivePriceList(quoteDraft.currentState),
701
+ };
702
+ }
703
+ get currentState$() {
704
+ return this.quoteDraft$.pipe(map(quote => quote.currentState));
705
+ }
706
+ get currentState() {
707
+ return this.quoteDraft?.currentState ?? [];
708
+ }
709
+ /**
710
+ * Stream of activeCurrentState
711
+ */
712
+ get activeCurrentState$() {
713
+ return this.quoteDraft$.pipe(map(() => this.activeCurrentState));
714
+ }
715
+ /**
716
+ * activeCurrentState is currentState passed through additional filters
717
+ */
718
+ get activeCurrentState() {
719
+ let currentState = this.quoteDraft?.currentState ?? [];
720
+ currentState = this.filterByActivePriceList(currentState);
721
+ return currentState;
722
+ }
723
+ /**
724
+ * Stream of activeInitialState
725
+ */
726
+ get activeInitialState$() {
727
+ return this.quoteDraft$.pipe(map(() => this.activeInitialState));
728
+ }
729
+ /**
730
+ * activeInitialState is initialState passed through additional filters
731
+ */
732
+ get activeInitialState() {
733
+ const ctx = this.context.resolve();
734
+ let initialState = this.quoteDraft?.initialState ?? [];
735
+ if (ctx.mode === ConfigurationContextMode.ACCOUNT) {
736
+ initialState = this.filterByActivePriceList(initialState);
737
+ }
738
+ return initialState;
739
+ }
740
+ get isStandalone() {
741
+ return this.context.resolve().properties.standalone === 'true';
742
+ }
743
+ get isStandalone$() {
744
+ return this.context.resolve$().pipe(map(() => this.isStandalone));
745
+ }
746
+ getInitialCurrentState() {
747
+ return this.initialCurrentState;
748
+ }
749
+ isEditMode$() {
750
+ return this.context.resolve$().pipe(map(() => this.isEditMode()));
751
+ }
752
+ isEditMode() {
753
+ const context = this.context.resolve();
754
+ if (context.mode === ConfigurationContextMode.ACCOUNT) {
755
+ return true;
756
+ }
757
+ if (context.mode === ConfigurationContextMode.QUOTE) {
758
+ return context.properties.Status === 'Draft';
759
+ }
760
+ return false;
761
+ }
762
+ updateActivePriceList(priceListId) {
763
+ this.context.update({ properties: { PriceListId: priceListId } });
764
+ }
765
+ populateActivePriceLists$() {
766
+ const ctx = this.context.resolve();
767
+ const quoteDraft = this.quoteDraft;
768
+ if (!quoteDraft) {
769
+ return;
770
+ }
771
+ // In ACCOUNT mode populate price lists from related assets
772
+ if (ctx.mode === ConfigurationContextMode.ACCOUNT) {
773
+ // Populate list of price lists
774
+ this.assetPriceLists = quoteDraft.currentState
775
+ .map(({ priceListId }) => priceListId)
776
+ .reduce((trunk, priceListId) => {
777
+ if (!priceListId || trunk.some(item => item.id === priceListId)) {
778
+ return trunk;
779
+ }
780
+ return [
781
+ ...trunk,
782
+ { id: priceListId, name: this.allPriceLists.find(item => item.id === priceListId)?.name ?? '' },
783
+ ];
784
+ }, []);
785
+ }
786
+ }
787
+ filterByActivePriceList(lineItems) {
788
+ const ctx = this.context.resolve();
789
+ return lineItems.filter(li => !li.priceListId || li.priceListId === ctx.properties.PriceListId);
790
+ }
791
+ markAsUpdated(quote) {
792
+ if (quote?.context.properties.mode === ConfigurationContextMode.ACCOUNT) {
793
+ this.hasUnsavedChanges = !!quote && !quote.currentState.every(li => li.actionCode === 'EXIST');
794
+ }
795
+ else {
796
+ this.hasUnsavedChanges = !isEqual(this.initialCurrentState, quote?.currentState);
797
+ }
798
+ }
799
+ initializeModifiedAssetsMap() {
800
+ this.integrationState.patchState({
801
+ modifiedAssets: generateModifiedAssetsMap(this.currentState),
802
+ });
803
+ }
804
+ }
805
+ QuoteDraftService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: QuoteDraftService, deps: [{ token: ContextService }, { token: i1.QuoteApiService }, { token: i1.PriceApiService }, { token: IntegrationState }], target: i0.ɵɵFactoryTarget.Injectable });
806
+ QuoteDraftService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: QuoteDraftService });
807
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: QuoteDraftService, decorators: [{
808
+ type: Injectable
809
+ }], ctorParameters: function () { return [{ type: ContextService }, { type: i1.QuoteApiService }, { type: i1.PriceApiService }, { type: IntegrationState }]; } });
810
+
811
+ class FlowStateService {
812
+ constructor(contextService, quoteDraftService, flowInfoService, flowConfiguration, processorsApiService, flowStateApiService, quoteApiService, toastService, customizationService) {
813
+ this.contextService = contextService;
814
+ this.quoteDraftService = quoteDraftService;
815
+ this.flowInfoService = flowInfoService;
816
+ this.flowConfiguration = flowConfiguration;
817
+ this.processorsApiService = processorsApiService;
818
+ this.flowStateApiService = flowStateApiService;
819
+ this.quoteApiService = quoteApiService;
820
+ this.toastService = toastService;
821
+ this.customizationService = customizationService;
822
+ this.NOT_INITIALIZED = Symbol();
823
+ this.EXECUTION_BUFFER_TIME = 100;
824
+ this.executedFunctions = {};
825
+ this.stateId$ = new BehaviorSubject(null);
826
+ this._hasStatefulUnsavedChanges = true;
827
+ this.processors = {};
828
+ this.subscriptions = {};
829
+ this.flowStore = {};
830
+ this.statefulExecutionInProgress$ = new BehaviorSubject(false);
831
+ this.statefulRequestStream$ = new Subject();
832
+ this.cleanup$ = new Subject();
833
+ this.statefulExecutionRequest$ = this.initBufferedRequest$();
834
+ /*
835
+ In stateless mode watch QuoteDraft changes and call executeRequest so that
836
+ all subscriptions get their updates according to updated QuoteDraft
837
+ */
838
+ this.isInitialized$()
839
+ .pipe(filter$1(Boolean), filter$1(() => !this.getFlowSafe().properties.stateful), switchMap(() => this.flowConfiguration.updated$), switchMap(() => this.executeRequest$({}, true)))
840
+ .subscribe();
841
+ this.charges$ = this.flowInfoService.flow$.pipe(filter$1(isDefined), switchMap(flow => {
842
+ if (!flow.properties.stateful) {
843
+ return this.quoteDraftService.quoteDraft$.pipe(map$1(quoteDraft => quoteDraft.charges));
844
+ }
845
+ else {
846
+ return this.subscribe$(UITemplateType.FLOW_ENGINE, 'CHARGES', null, {
847
+ cold: true,
848
+ }).pipe(map$1(response => (response.success ? response.result : {})));
849
+ }
850
+ }), filter$1(isDefined), shareReplay$1());
851
+ this.charges$.subscribe();
852
+ this.pricePlans$ = this.flowInfoService.flow$.pipe(filter$1(isDefined), switchMap(flow => {
853
+ if (!flow.properties.stateful) {
854
+ return this.quoteDraftService.quoteDraft$.pipe(map$1(quoteDraft => quoteDraft.pricePlans));
855
+ }
856
+ else {
857
+ return this.subscribe$(UITemplateType.FLOW_ENGINE, 'PRICE_PLANS', null, {
858
+ cold: true,
859
+ }).pipe(map$1(response => (response.success ? response.result : {})));
860
+ }
861
+ }), filter$1(isDefined), shareReplay$1());
862
+ this.pricePlans$.subscribe();
863
+ this.activeMetrics$ = this.flowInfoService.flow$.pipe(filter$1(isDefined), switchMap(flow => {
864
+ if (!flow.properties.stateful) {
865
+ return this.quoteDraftService.quoteDraft$.pipe(map$1(quoteDraft => quoteDraft.activeMetrics));
866
+ }
867
+ else {
868
+ return this.subscribe$(UITemplateType.FLOW_ENGINE, 'ACTIVE_METRICS', null, {
869
+ cold: true,
870
+ }).pipe(map$1(response => (response.success ? response.result : [])));
871
+ }
872
+ }), filter$1(isDefined), shareReplay$1());
873
+ this.activeMetrics$.subscribe();
874
+ }
875
+ init$() {
876
+ return this.initProcessors$().pipe(switchMap(() => {
877
+ if (this.getFlowSafe().properties.stateful) {
878
+ return this.initStateful$();
879
+ }
880
+ else {
881
+ return this.initStateless$();
882
+ }
883
+ }));
884
+ }
885
+ cleanup() {
886
+ Object.values(this.subscriptions).forEach(({ data$ }) => data$.complete());
887
+ this.subscriptions = {};
888
+ if (this.stateId$.value) {
889
+ this.flowStateApiService.cancel(this.stateId$.value).subscribe();
890
+ this.stateId$.next(null);
891
+ }
892
+ this.processors = {};
893
+ this.flowStore = {};
894
+ this.cleanup$.next();
895
+ }
896
+ get hasUnsavedChanges() {
897
+ return this.getFlowSafe().properties.stateful
898
+ ? this._hasStatefulUnsavedChanges
899
+ : this.quoteDraftService.hasUnsavedChanges;
900
+ }
901
+ get stateId() {
902
+ return this.stateId$.value;
903
+ }
904
+ get isExecutionInProgress$() {
905
+ return this.statefulExecutionInProgress$.asObservable();
906
+ }
907
+ isInitialized$() {
908
+ return combineLatest([this.stateId$, this.quoteDraftService.isInitialized$]).pipe(map$1(values => values.some(Boolean)));
909
+ }
910
+ isInitialized() {
911
+ return Boolean(this.stateId$.value) || this.quoteDraftService.isInitialized;
912
+ }
913
+ execute$(scope, exec) {
914
+ const request = this.execToRequest(scope, exec);
915
+ return this.executeRequest$(request).pipe(map$1(result => {
916
+ // Keep only requested results
917
+ const actualSelectors = Object.entries(result.selectors).reduce((trunk, [requestId, result]) => {
918
+ if (exec.selectors?.[requestId]) {
919
+ trunk[requestId] = result;
920
+ }
921
+ return trunk;
922
+ }, {});
923
+ return actualSelectors;
924
+ }));
925
+ }
926
+ dispatch$(scope, action, inputData) {
927
+ const exec = {
928
+ actions: [{ name: action, inputData }],
929
+ };
930
+ const request = this.execToRequest(scope, exec);
931
+ return this.executeRequest$(request).pipe(map$1(noop));
932
+ }
933
+ select$(scope, selectorName, inputData) {
934
+ const requestId = this.generateRequestId(scope, selectorName, inputData);
935
+ const request = this.execToRequest(scope, {
936
+ selectors: {
937
+ [requestId]: {
938
+ name: selectorName,
939
+ inputData,
940
+ },
941
+ },
942
+ });
943
+ return this.executeRequest$(request).pipe(map$1(response => response.selectors[requestId]));
944
+ }
945
+ subscribe$(scope, selectorName, inputData, options) {
946
+ const requestId = this.generateRequestId(scope, selectorName, inputData);
947
+ let subscription = this.subscriptions[requestId];
948
+ if (!subscription) {
949
+ const request = this.execToRequest(scope, {
950
+ selectors: {
951
+ [requestId]: {
952
+ name: selectorName,
953
+ inputData,
954
+ },
955
+ },
956
+ });
957
+ subscription = {
958
+ request,
959
+ data$: new BehaviorSubject(this.NOT_INITIALIZED),
960
+ };
961
+ this.subscriptions[requestId] = subscription;
962
+ if (!options?.cold) {
963
+ this.executeRequest$(request).subscribe();
964
+ }
965
+ }
966
+ return subscription.data$.pipe(filter$1(data => data != this.NOT_INITIALIZED), map$1(data => data), finalize(() => {
967
+ if (!this.subscriptions[requestId]?.data$.observed) {
968
+ delete this.subscriptions[requestId];
969
+ }
970
+ }));
971
+ }
972
+ save$() {
973
+ if (this.getFlowSafe().properties.stateful) {
974
+ if (this.stateId$.value) {
975
+ return this.flowStateApiService.save(this.stateId$.value);
976
+ }
977
+ }
978
+ else {
979
+ const quoteDraft = this.quoteDraftService.quoteDraftForActivePriceList;
980
+ if (quoteDraft) {
981
+ return this.quoteApiService.upsertQuote(quoteDraft);
982
+ }
983
+ }
984
+ return of({ quoteId: '' });
985
+ }
986
+ submit$() {
987
+ if (this.getFlowSafe().properties.stateful) {
988
+ if (this.stateId$.value) {
989
+ return this.flowStateApiService.submit(this.stateId$.value);
990
+ }
991
+ }
992
+ else {
993
+ const quoteDraft = this.quoteDraftService.quoteDraftForActivePriceList;
994
+ if (quoteDraft) {
995
+ return this.quoteApiService.submitQuote(quoteDraft);
996
+ }
997
+ }
998
+ return of({ quoteId: '' });
999
+ }
1000
+ getFlowStore() {
1001
+ return this.flowStore;
1002
+ }
1003
+ getOwnerIdByScope(scope) {
1004
+ const ownerId = this.flowInfoService.templates[scope]?.id;
1005
+ if (!ownerId) {
1006
+ throw `OwnerId is not found for scope ${scope}`;
1007
+ }
1008
+ return ownerId;
1009
+ }
1010
+ getScopeByOwnerId(id) {
1011
+ for (const template of Object.values(this.flowInfoService.templates)) {
1012
+ if (template.id === id) {
1013
+ return template.type;
1014
+ }
1015
+ }
1016
+ return;
1017
+ }
1018
+ execToRequest(scope, exec) {
1019
+ const ownerId = this.getOwnerIdByScope(scope);
1020
+ return {
1021
+ actions: exec.actions?.map(action => ({ apiName: action.name, ownerId, inputData: action.inputData ?? {} })),
1022
+ selectors: exec.selectors &&
1023
+ Object.entries(exec.selectors).reduce((trunk, [key, selector]) => ({
1024
+ ...trunk,
1025
+ [key]: { apiName: selector.name, ownerId, inputData: selector.inputData ?? {} },
1026
+ }), {}),
1027
+ };
1028
+ }
1029
+ executeRequest$(request, forceSubscriptions = false) {
1030
+ const fullRequest = cloneDeep(request);
1031
+ if (fullRequest.actions?.length || forceSubscriptions) {
1032
+ for (const subscription of Object.values(this.subscriptions)) {
1033
+ fullRequest.selectors = assign(fullRequest.selectors, subscription.request.selectors);
1034
+ }
1035
+ }
1036
+ const execution$ = this.getFlowSafe().properties.stateful
1037
+ ? this.executeStateful$(fullRequest)
1038
+ : this.executeStateless$(fullRequest);
1039
+ return execution$.pipe(tap$1(result => this.handleSelectorsResponse(result.selectors)));
1040
+ }
1041
+ handleSelectorsResponse(selectors) {
1042
+ Object.entries(selectors).forEach(([requestId, selectorResult]) => {
1043
+ if (!selectorResult.success) {
1044
+ this.toastService.add({ severity: ToastType.error, summary: selectorResult.errorMessage });
1045
+ }
1046
+ const subscription$ = this.subscriptions[requestId]?.data$;
1047
+ if (subscription$ && subscription$.value !== selectorResult) {
1048
+ subscription$.next(selectorResult);
1049
+ }
1050
+ });
1051
+ }
1052
+ initStateful$() {
1053
+ // Subscriptions
1054
+ this.subscribe$(UITemplateType.FLOW_ENGINE, 'CONTEXT', null, { cold: true })
1055
+ .pipe(tap$1(response => {
1056
+ if (response.success) {
1057
+ this.contextService.update(response.result);
1058
+ }
1059
+ }), takeUntil(this.cleanup$))
1060
+ .subscribe();
1061
+ const processorsList = flatten(Object.values(this.processors).map(ownerMap => Object.values(ownerMap ?? {})));
1062
+ const processors = processorsList.length ? processorsList : undefined;
1063
+ const selectors = Object.values(this.subscriptions)
1064
+ .map(({ request }) => request.selectors)
1065
+ .filter(isDefined)
1066
+ .reduce((trunk, selectors) => ({ ...trunk, ...selectors }), {});
1067
+ const request = this.getDefaultExecutionRequestDTO();
1068
+ return this.flowStateApiService
1069
+ .init({
1070
+ quoteId: this.contextService.resolve().headerId,
1071
+ params: this.flowInfoService.params ?? {},
1072
+ actionsOverride: processors?.filter(processor => processor.type === ConfigurationProcessorTypes.ACTION),
1073
+ selectorsOverride: processors?.filter(processor => processor.type === ConfigurationProcessorTypes.SELECTOR),
1074
+ selectors: { ...selectors, ...request.selectors },
1075
+ actions: request.actions,
1076
+ })
1077
+ .pipe(map$1(({ stateId, selectors }) => {
1078
+ this.handleSelectorsResponse(selectors);
1079
+ this.stateId$.next(stateId);
1080
+ }));
1081
+ }
1082
+ initBufferedRequest$() {
1083
+ return this.statefulRequestStream$.pipe(buffer(this.statefulRequestStream$.pipe(debounceTime(this.EXECUTION_BUFFER_TIME))), switchMap(requests => {
1084
+ if (!this.stateId$.value) {
1085
+ throw 'Stateful session is not initialized';
1086
+ }
1087
+ // merge buffered requests
1088
+ const request = {
1089
+ actions: requests.flatMap(({ actions }) => actions).filter(isDefined),
1090
+ selectors: requests
1091
+ .map(({ selectors }) => selectors)
1092
+ .filter(isDefined)
1093
+ .reduce((acc, selectorsMap) => Object.assign(acc, selectorsMap), {}),
1094
+ };
1095
+ this.statefulExecutionInProgress$.next(true);
1096
+ return this.flowStateApiService.execute(this.stateId$.value, request);
1097
+ }), tap$1(({ stateId }) => this.stateId$.next(stateId)), share(), tap$1(() => this.statefulExecutionInProgress$.next(false)), catchError(e => {
1098
+ this.statefulExecutionInProgress$.next(false);
1099
+ return throwError(() => e);
1100
+ }));
1101
+ }
1102
+ executeStateful$(request) {
1103
+ return this.statefulExecutionInProgress$.pipe(filter$1(inProgress => !inProgress), take$1(1), switchMap(() =>
1104
+ // make sure stream switches to statefulExecutionRequest$ before pushing an execution request
1105
+ combineLatest([
1106
+ this.statefulExecutionRequest$,
1107
+ of(undefined).pipe(tap$1(() => this.statefulRequestStream$.next(request))),
1108
+ ])), map$1(([response]) => response), take$1(1));
1109
+ }
1110
+ initStateless$() {
1111
+ const { headerId } = this.contextService.resolve();
1112
+ return this.quoteDraftService.init(headerId, this.flowInfoService.params ?? {}).pipe(switchMap(() => this.executeRequest$(this.getDefaultExecutionRequestDTO())), switchMap(() => this.calculate$()), tap$1(() => this.quoteDraftService.finalizeInit()), map$1(noop));
1113
+ }
1114
+ calculate$() {
1115
+ const flowState = this.quoteDraftService.quoteDraft;
1116
+ if (!flowState) {
1117
+ return of(undefined);
1118
+ }
1119
+ /*
1120
+ Don't execute procedures when:
1121
+ * Initializing a standalone product configuration UI, as procedure is execute in /price call
1122
+ * Initializing an empty account (account with no assets)
1123
+ */
1124
+ const isEmptyAccountMode = this.contextService.mode === ConfigurationContextMode.ACCOUNT &&
1125
+ !this.quoteDraftService.hasProducts &&
1126
+ !this.quoteDraftService.hasAssets &&
1127
+ !this.quoteDraftService.quoteDraft?.initialState.length;
1128
+ if (this.quoteDraftService.isStandalone || isEmptyAccountMode) {
1129
+ return of(undefined);
1130
+ }
1131
+ return this.flowConfiguration.calculate$(flowState);
1132
+ }
1133
+ executeStateless$(request) {
1134
+ return of(undefined).pipe(tap$1(() => this.executeStatelessActions(request)), switchMap(() => {
1135
+ /*
1136
+ Skip price calculation in case
1137
+ 1. No actions in the request
1138
+ 2. Initialization process execution (state not initialized yet)
1139
+ */
1140
+ if (!request.actions?.length || !this.isInitialized()) {
1141
+ return of(undefined);
1142
+ }
1143
+ else {
1144
+ return this.calculate$();
1145
+ }
1146
+ }), map$1(() => this.executeStatelessSelectors(request)));
1147
+ }
1148
+ executeStatelessActions(request) {
1149
+ if (!this.quoteDraftService.quoteDraft || !request.actions?.length) {
1150
+ return;
1151
+ }
1152
+ let flowState = this.quoteDraftService.quoteDraft;
1153
+ request.actions.forEach(action => {
1154
+ try {
1155
+ flowState = this.executeActionScript(flowState, action) ?? flowState;
1156
+ }
1157
+ catch (e) {
1158
+ console.error(e);
1159
+ this.toastService.add({ severity: ToastType.error, summary: String(e) });
1160
+ throw e;
1161
+ }
1162
+ });
1163
+ this.quoteDraftService.updateQuoteDraft(flowState);
1164
+ }
1165
+ executeStatelessSelectors(request) {
1166
+ if (!this.quoteDraftService.quoteDraft) {
1167
+ throw 'QuoteDraft is not initialized';
1168
+ }
1169
+ const flowState = this.quoteDraftService.quoteDraft;
1170
+ return EntityUtil.entries(request.selectors ?? {}).reduce((result, [key, selector]) => {
1171
+ try {
1172
+ result.selectors[key] = {
1173
+ success: true,
1174
+ result: this.executeSelectorScript(flowState, selector),
1175
+ };
1176
+ }
1177
+ catch (e) {
1178
+ console.error(e);
1179
+ result.selectors[key] = {
1180
+ success: false,
1181
+ errorMessage: String(e),
1182
+ };
1183
+ }
1184
+ return result;
1185
+ }, { stateId: '', selectors: {} });
1186
+ }
1187
+ getFlowSafe() {
1188
+ if (!this.flowInfoService.flow) {
1189
+ throw 'Flow is not defined';
1190
+ }
1191
+ return this.flowInfoService.flow;
1192
+ }
1193
+ initProcessors$() {
1194
+ const hasOverrides = Boolean(this.customizationService?.getTemplateConfigurationProcessors);
1195
+ const flow = this.getFlowSafe();
1196
+ if (flow.properties.stateful && !hasOverrides) {
1197
+ // Skip initialization as backend will take processors from SF
1198
+ return of(undefined);
1199
+ }
1200
+ const owners$ = Object.values(this.flowInfoService.templates)
1201
+ .map(template => {
1202
+ if (!template) {
1203
+ return;
1204
+ }
1205
+ const localProcessors$ = this.customizationService?.getTemplateConfigurationProcessors?.(template.name) ?? of(null);
1206
+ return localProcessors$.pipe(switchMap(processors => processors ? of(processors) : this.processorsApiService.fetchConfigurationProcessors$(template.id)), tap$1(processors => {
1207
+ const processorsMap = processors.reduce((acc, p) => {
1208
+ acc[p.apiName] = p;
1209
+ return acc;
1210
+ }, {});
1211
+ this.processors[template.id] = processorsMap;
1212
+ }));
1213
+ })
1214
+ .filter(isDefined);
1215
+ if (!owners$.length) {
1216
+ return of(undefined);
1217
+ }
1218
+ return forkJoin(owners$).pipe(map$1(noop));
1219
+ }
1220
+ executeActionScript(request, executable) {
1221
+ const configurationProcessor = this.processors[executable.ownerId]?.[executable.apiName];
1222
+ if (!configurationProcessor?.script) {
1223
+ const scope = this.getScopeByOwnerId(executable.ownerId);
1224
+ const scopeText = scope ? ` in ${scope}` : '';
1225
+ throw `ConfigurationProcessor ${executable.apiName}${scopeText} not found`;
1226
+ }
1227
+ return this.executeProcessorScript(request, configurationProcessor, executable.inputData);
1228
+ }
1229
+ executeSelectorScript(request, executable) {
1230
+ const configurationProcessor = this.processors[executable.ownerId]?.[executable.apiName];
1231
+ if (!configurationProcessor?.script) {
1232
+ const scope = this.getScopeByOwnerId(executable.ownerId);
1233
+ const scopeText = scope ? ` in ${scope}` : '';
1234
+ throw `ConfigurationProcessor ${executable.apiName}${scopeText} not found`;
1235
+ }
1236
+ return this.executeProcessorScript(request, configurationProcessor, executable.inputData);
1237
+ }
1238
+ executeProcessorScript(request, configurationProcessor, inputData) {
1239
+ const scope = this.getScopeByOwnerId(configurationProcessor.ownerId ?? '');
1240
+ let functionToExecute = this.executedFunctions[scope + configurationProcessor.apiName];
1241
+ if (!functionToExecute) {
1242
+ const script = `${configurationProcessor.script}\nreturn transform;`;
1243
+ const sourceMap = `\n//# sourceURL=${scope ? scope + '/' : ''}${configurationProcessor.apiName}.js`;
1244
+ functionToExecute = new Function(script + sourceMap)();
1245
+ this.executedFunctions[scope + configurationProcessor.apiName] = functionToExecute;
1246
+ }
1247
+ return functionToExecute({
1248
+ request,
1249
+ inputData,
1250
+ flowStore: this.flowStore,
1251
+ });
1252
+ }
1253
+ generateRequestId(scope, selectorName, inputData) {
1254
+ const inputDataHash = UUID.hex(JSON.stringify(inputData) || '').slice(0, 8);
1255
+ return `${scope}/${selectorName}/${inputDataHash}`;
1256
+ }
1257
+ getDefaultExecutionRequestDTO() {
1258
+ const request = {
1259
+ actions: [],
1260
+ selectors: {},
1261
+ };
1262
+ if (this.getFlowSafe().properties.standalone) {
1263
+ return request;
1264
+ }
1265
+ const ownerId = this.getOwnerIdByScope(UITemplateType.FLOW_ENGINE);
1266
+ request.actions?.push({
1267
+ apiName: 'UPDATE_PRICE_LIST',
1268
+ ownerId,
1269
+ inputData: {},
1270
+ });
1271
+ request.actions?.push({
1272
+ apiName: 'UPDATE_ASSET_IDS',
1273
+ ownerId,
1274
+ inputData: {},
1275
+ });
1276
+ request.actions?.push({
1277
+ apiName: 'UPDATE_CONTEXT_PROPERTIES',
1278
+ ownerId,
1279
+ inputData: this.contextService.resolve().properties,
1280
+ });
1281
+ return request;
1282
+ }
1283
+ }
1284
+ FlowStateService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: FlowStateService, deps: [{ token: ContextService }, { token: QuoteDraftService }, { token: FlowInfoService }, { token: FlowConfigurationService }, { token: i1.ConfigurationProcessorsApiService }, { token: i1.FlowStateApiService }, { token: i1.QuoteApiService }, { token: i6.ToastService }, { token: FLOW_CUSTOMIZATION, optional: true }], target: i0.ɵɵFactoryTarget.Injectable });
1285
+ FlowStateService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: FlowStateService });
1286
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: FlowStateService, decorators: [{
1287
+ type: Injectable
1288
+ }], ctorParameters: function () { return [{ type: ContextService }, { type: QuoteDraftService }, { type: FlowInfoService }, { type: FlowConfigurationService }, { type: i1.ConfigurationProcessorsApiService }, { type: i1.FlowStateApiService }, { type: i1.QuoteApiService }, { type: i6.ToastService }, { type: undefined, decorators: [{
1289
+ type: Optional
1290
+ }, {
1291
+ type: Inject,
1292
+ args: [FLOW_CUSTOMIZATION]
1293
+ }] }]; } });
1294
+
1295
+ class RuntimeSettingsService {
1296
+ constructor(configurationSettingsApiService) {
1297
+ this.configurationSettingsApiService = configurationSettingsApiService;
1298
+ this.configurationSettings$ = new BehaviorSubject({});
1299
+ this.currencySettings$ = new BehaviorSubject({
1300
+ iso: DEFAULT_CURRENCY_ISO_CODE,
1301
+ symbol: DEFAULT_CURRENCY_SYMBOL,
1302
+ });
1303
+ this.shoppingCartSettings$ = new BehaviorSubject([]);
1304
+ this.getCurrencySymbol = (locale, currency) => {
1305
+ return (0)
1306
+ .toLocaleString(locale, { style: 'currency', currency, minimumFractionDigits: 0, maximumFractionDigits: 0 })
1307
+ .replace(/\d/g, '')
1308
+ .trim();
1309
+ };
1310
+ }
1311
+ create() {
1312
+ return this.configurationSettingsApiService.fetchSettings().pipe(map$1(settings => this.parseConfigurationSettings(settings)), tap$1(configurationSettings => {
1313
+ this.configurationSettings$.next(configurationSettings);
1314
+ this.addShoppingCartSettings(configurationSettings['shopping-cart'] ?? []);
1315
+ this.formattingSettings = this.getFormattingSettings();
1316
+ }), map$1(() => undefined));
1317
+ }
1318
+ initCurrency(iso) {
1319
+ if (iso) {
1320
+ const symbol = this.getCurrencySymbol('en-US', iso);
1321
+ this.currencySettings$.next({ iso, symbol });
1322
+ }
1323
+ }
1324
+ getFormattingSettings() {
1325
+ if (this.formattingSettings) {
1326
+ return this.formattingSettings;
1327
+ }
1328
+ const shoppingCartSettings = this.getConfigurationSettings()['shopping-cart']?.reduce((acc, setting) => {
1329
+ return { ...acc, [setting.id]: setting.properties };
1330
+ }, {});
1331
+ const currencySettings = this.getCurrencySettings();
1332
+ const dateFormat = (validateDateFormat(shoppingCartSettings?.DATE_FORMAT ?? '') && shoppingCartSettings?.DATE_FORMAT) ||
1333
+ DEFAULT_DATE_FORMAT;
1334
+ const decimalSeparator = shoppingCartSettings?.DECIMAL_SEPARATOR;
1335
+ const thousandsSeparator = shoppingCartSettings?.THOUSANDS_SEPARATOR;
1336
+ // the number of decimal places can be 0
1337
+ const priceScale = shoppingCartSettings?.PRICE_SCALE;
1338
+ const decimalsCount = priceScale !== null && priceScale !== '' && !isNaN(Number(priceScale)) && Number(priceScale) >= 0
1339
+ ? Number(priceScale)
1340
+ : DEFAULT_DECIMALS_COUNT;
1341
+ const actionCodeSettings = shoppingCartSettings?.STATUS_LABEL;
1342
+ return {
1343
+ currencySymbol: currencySettings.symbol,
1344
+ dateFormats: getSupportedDateFormats(dateFormat),
1345
+ decimalsCount,
1346
+ decimalSeparator: decimalSeparator !== undefined && ['.', ','].includes(decimalSeparator)
1347
+ ? decimalSeparator
1348
+ : DEFAULT_DECIMAL_SEPARATOR,
1349
+ // thousands separator can be a blank value, so it can also be null
1350
+ thousandsSeparator: thousandsSeparator !== undefined && ['.', ',', '', null].includes(thousandsSeparator)
1351
+ ? thousandsSeparator || ''
1352
+ : DEFAULT_THOUSANDS_SEPARATOR,
1353
+ actionCodeLabels: actionCodeSettings?.length
1354
+ ? actionCodeSettings.reduce((result, setting) => ({ ...result, [setting.status_label]: setting.custom_label }), {})
1355
+ : DEFAULT_ACTION_CODE_LABELS,
1356
+ };
1357
+ }
1358
+ getConfigurationSettings() {
1359
+ return this.configurationSettings$.value;
1360
+ }
1361
+ getShoppingCartSettings() {
1362
+ return this.shoppingCartSettings$.value;
1363
+ }
1364
+ getCurrencySettings() {
1365
+ return this.currencySettings$.value;
1366
+ }
1367
+ parseConfigurationSettings(settings) {
1368
+ return settings.reduce((acc, setting) => {
1369
+ switch (setting.key) {
1370
+ case 'shopping-cart':
1371
+ acc['shopping-cart'] = parseJsonSafely(setting.value, []);
1372
+ break;
1373
+ case 'navigation':
1374
+ acc.navigation = parseJsonSafely(setting.value, {});
1375
+ break;
1376
+ case 'flows':
1377
+ acc.flows = parseJsonSafely(setting.value, []);
1378
+ break;
1379
+ default:
1380
+ acc[setting.key] = setting.value;
1381
+ }
1382
+ return acc;
1383
+ }, {});
1384
+ }
1385
+ addShoppingCartSettings(settings) {
1386
+ // uniqBy removes items with the biggest index
1387
+ const newSettings = uniqBy([...settings, ...this.shoppingCartSettings$.value], 'id');
1388
+ this.shoppingCartSettings$.next(newSettings);
1389
+ }
1390
+ }
1391
+ RuntimeSettingsService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: RuntimeSettingsService, deps: [{ token: i1.ConfigurationSettingsApiService }], target: i0.ɵɵFactoryTarget.Injectable });
1392
+ RuntimeSettingsService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: RuntimeSettingsService });
1393
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: RuntimeSettingsService, decorators: [{
1394
+ type: Injectable
1395
+ }], ctorParameters: function () { return [{ type: i1.ConfigurationSettingsApiService }]; } });
1396
+
1397
+ class ConfigurationService {
1398
+ constructor(quoteDraftService, runtimeService, contextService, configurationApiService, messageService, dialogService, runtimeSettings) {
1399
+ this.quoteDraftService = quoteDraftService;
1400
+ this.runtimeService = runtimeService;
1401
+ this.contextService = contextService;
1402
+ this.configurationApiService = configurationApiService;
1403
+ this.messageService = messageService;
1404
+ this.dialogService = dialogService;
1405
+ this.runtimeSettings = runtimeSettings;
1406
+ this.mode = ConfigurationMode.SEARCH;
1407
+ this.configurationState = new BehaviorSubject(null);
1408
+ this.isLoadingSubj$ = new BehaviorSubject(false);
1409
+ this.isLoading$ = this.isLoadingSubj$.asObservable();
1410
+ this.hasUnsavedChanges = false;
1411
+ }
1412
+ reset() {
1413
+ this.hasUnsavedChanges = false;
1414
+ this.runtimeService.reset();
1415
+ this.configurableRamp = undefined;
1416
+ this.configurationState.next(null);
1417
+ }
1418
+ patch$(lineItem, options) {
1419
+ const source = this.getSnapshot();
1420
+ if (!source) {
1421
+ return throwError(() => new Error(`Source LineItem not found`));
1422
+ }
1423
+ const skipCardinalityCalculation = options?.skipCardinalityCalculation || this.contextSnapshot.properties['#skipCardinalityCalculation'] === 'true';
1424
+ this.configurableRamp = new LineItemWorker(source).replace(lineItem, skipCardinalityCalculation).li;
1425
+ return this.configure().pipe(catchError$1(error => {
1426
+ console.error(error);
1427
+ if (!this.runtimeService.uiDefinitionProperties.suppressToastMessages) {
1428
+ this.messageService.add({ severity: 'error', summary: error });
1429
+ }
1430
+ // bounce back if configuration call has failed
1431
+ const prevState = this.configurationState.value;
1432
+ this.configurationState.next(prevState ? { ...prevState } : null);
1433
+ return throwError(() => error);
1434
+ }), tap(() => {
1435
+ if (!this.hasUnsavedChanges) {
1436
+ this.hasUnsavedChanges = true;
1437
+ }
1438
+ }));
1439
+ }
1440
+ patch(lineItem, options) {
774
1441
  this.patch$(lineItem, options).subscribe();
775
1442
  }
776
1443
  setConfigurableRamp(lineItem) {
777
1444
  this.configurableRamp = lineItem;
778
1445
  }
779
1446
  get() {
780
- return this.lineItem.asObservable().pipe(shareReplay$1());
1447
+ return this.configurationState.pipe(map(state => state?.lineItem), shareReplay$1());
781
1448
  }
782
1449
  getSnapshot() {
783
- return this.lineItem.value ? { ...this.lineItem.value } : undefined;
1450
+ return this.configurationState.value?.lineItem ? { ...this.configurationState.value?.lineItem } : undefined;
784
1451
  }
785
1452
  getRuntimeModel() {
786
1453
  const runtimeModel = this.runtimeService.runtimeModel;
@@ -796,6 +1463,12 @@ class ConfigurationService {
796
1463
  }
797
1464
  return runtimeContext;
798
1465
  }
1466
+ get state$() {
1467
+ return this.configurationState.asObservable();
1468
+ }
1469
+ get stateSnapshot() {
1470
+ return this.configurationState.value;
1471
+ }
799
1472
  get contextSnapshot() {
800
1473
  return this.contextService.resolve();
801
1474
  }
@@ -803,16 +1476,22 @@ class ConfigurationService {
803
1476
  return this.contextService.resolve$();
804
1477
  }
805
1478
  get charges$() {
806
- return this.charges.asObservable();
1479
+ return this.configurationState.pipe(map(state => state?.charges ?? {}));
807
1480
  }
808
1481
  get chargesSnapshot() {
809
- return this.charges.value;
1482
+ return this.configurationState.value?.charges ?? {};
810
1483
  }
811
1484
  get pricePlans$() {
812
- return this.pricePlans.asObservable();
1485
+ return this.configurationState.pipe(map(state => state?.pricePlans ?? {}));
813
1486
  }
814
1487
  get pricePlansSnapshot() {
815
- return this.pricePlans.value;
1488
+ return this.configurationState.value?.pricePlans ?? {};
1489
+ }
1490
+ get procedureContext$() {
1491
+ return this.configurationState.pipe(map(state => state?.procedureContext ?? {}));
1492
+ }
1493
+ get procedureContextSnapshot() {
1494
+ return this.configurationState.value?.procedureContext ?? {};
816
1495
  }
817
1496
  configure() {
818
1497
  return this.configureRequest$(this.generateRequest());
@@ -823,44 +1502,64 @@ class ConfigurationService {
823
1502
  const uiDefinitionProperties = this.getUIDefinitionProperties();
824
1503
  const mainPricingEnabled = runtimeContext.properties?.PricingEnabled;
825
1504
  const pricingEnabled = mainPricingEnabled ? mainPricingEnabled === 'true' : uiDefinitionProperties.pricingEnabled;
1505
+ const customPriceApi = this.runtimeSettings.getConfigurationSettings()['CUSTOM_PRICE_API'];
826
1506
  this.isLoadingSubj$.next(true);
827
- return this.configurationApiService.configureLineItem({ configurationRequest, runtimeModel, pricingEnabled }).pipe(tap(({ lineItem, context, charges, pricePlans, deletedLineItems }) => {
828
- this.contextService.update(context ?? {});
829
- this.charges.next(charges ?? {});
830
- this.pricePlans.next(pricePlans ?? {});
831
- if (lineItem) {
832
- this.lineItem.next(lineItem);
833
- }
834
- if (deletedLineItems?.length) {
1507
+ const configure$ = pricingEnabled && customPriceApi
1508
+ ? this.configurationApiService.customConfigurePrice({ url: customPriceApi, configurationRequest, runtimeModel })
1509
+ : this.configurationApiService.configureLineItem({
1510
+ configurationRequest,
1511
+ runtimeModel,
1512
+ pricingEnabled,
1513
+ });
1514
+ return configure$.pipe(tap(result => {
1515
+ this.contextService.update(result.context);
1516
+ this.configurationState.next(result);
1517
+ if (result.deletedLineItems?.length) {
835
1518
  this.showInactiveProductsConfirmation();
836
1519
  }
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)));
1520
+ this.configurableRamp = result.lineItem;
1521
+ }), map(({ lineItem }) => lineItem), catchError$1(error => throwError(() => new Error(error.error?.message || error.message || JSON.stringify(error)))), finalize$1(() => this.isLoadingSubj$.next(false)));
839
1522
  }
840
1523
  configureExternal$(props) {
841
1524
  return this.runtimeService
842
1525
  .init({ productId: props.productId, defaultQty: props.qty, attributesMap: props.attributesMap })
843
- .pipe(switchMap(() => this.configure()), first(), catchError(error => {
1526
+ .pipe(switchMap$1(() => this.configure()), first(), catchError$1(error => {
844
1527
  this.messageService.add({ severity: ToastType.error, summary: error });
845
1528
  throw error;
846
- }), finalize(() => this.reset()));
1529
+ }), finalize$1(() => this.reset()));
847
1530
  }
848
1531
  configureGuidedSelling$(data) {
849
1532
  return this.configurationApiService
850
1533
  .configureLineItem({
851
- configurationRequest: getGuidedSellingConfigurationRequest(data),
1534
+ configurationRequest: getGuidedSellingConfigurationRequest(data, this.contextService.resolve()),
852
1535
  })
853
- .pipe(catchError(error => {
1536
+ .pipe(catchError$1(error => {
854
1537
  if (error instanceof HttpErrorResponse) {
855
1538
  this.messageService.add({ severity: ToastType.error, summary: error.error.message || error.error });
856
1539
  }
857
1540
  throw error;
858
1541
  }));
859
1542
  }
860
- generateRequest() {
1543
+ generateRequest(lightMode = true) {
1544
+ const lineItem = this.generateLineItem();
1545
+ let request = {
1546
+ lineItem,
1547
+ mode: this.mode,
1548
+ step: !this.configurationState.value?.lineItem ? RuntimeStep.START : RuntimeStep.UPDATE,
1549
+ attributeDomainMode: 'ALL',
1550
+ context: this.contextService.resolve(),
1551
+ lineItems: this.quoteDraftService.quoteDraft?.currentState || [],
1552
+ asset: this.getAsset(),
1553
+ };
1554
+ if (lightMode) {
1555
+ request = ConfigurationTranslatorUtils.lightenConfigurationRequest(request);
1556
+ }
1557
+ return request;
1558
+ }
1559
+ generateLineItem() {
861
1560
  const runtimeContext = this.getRuntimeContext();
862
1561
  const uiDefinitionProperties = this.getUIDefinitionProperties();
863
- let lineItem = this.configurableRamp;
1562
+ let lineItem = cloneDeep(this.configurableRamp);
864
1563
  if (!lineItem) {
865
1564
  const { initializationProps } = this.runtimeService ?? {};
866
1565
  lineItem = getDefaultLineItem(runtimeContext, uiDefinitionProperties, initializationProps?.defaultQty);
@@ -870,21 +1569,11 @@ class ConfigurationService {
870
1569
  lineItem = new LineItemWorker(lineItem).patchAttribute(attributes).li;
871
1570
  }
872
1571
  }
873
- let request = {
874
- lineItem,
875
- mode: this.mode,
876
- step: !this.lineItem.value ? RuntimeStep.START : RuntimeStep.UPDATE,
877
- attributeDomainMode: 'ALL',
878
- context: this.contextService.resolve(),
879
- lineItems: this.quoteDraftService.quoteDraft?.currentState || [],
880
- asset: this.getAsset(),
881
- };
882
- request = ConfigurationTranslatorUtils.lightenConfigurationRequest(request);
883
- return request;
1572
+ return lineItem;
884
1573
  }
885
1574
  getUIDefinitionProperties() {
886
1575
  return {
887
- ...getUIDefinitionProperties(this.getRuntimeContext().uiDefinitionContainer),
1576
+ ...(this.getRuntimeContext().uiDefinitionContainer?.source.properties ?? {}),
888
1577
  ...(this.runtimeService.uiDefinitionProperties ?? {}),
889
1578
  };
890
1579
  }
@@ -920,148 +1609,11 @@ class ConfigurationService {
920
1609
  return this.quoteDraftService.quoteDraft?.initialState.find(a => a.id === lineItem.openOrderLineItemId || a.id === lineItem.assetId);
921
1610
  }
922
1611
  }
923
- ConfigurationService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.8", ngImport: i0, type: ConfigurationService, deps: [{ token: QuoteDraftService }, { token: ConfigurationRuntimeService }, { token: ContextService }, { token: i1.ConfigurationApiService }, { token: i5.MessageService }, { token: i6.DialogService }], target: i0.ɵɵFactoryTarget.Injectable });
924
- ConfigurationService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.8", ngImport: i0, type: ConfigurationService });
925
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.8", ngImport: i0, type: ConfigurationService, decorators: [{
926
- type: Injectable
927
- }], ctorParameters: function () { return [{ type: QuoteDraftService }, { type: ConfigurationRuntimeService }, { type: ContextService }, { type: i1.ConfigurationApiService }, { type: i5.MessageService }, { type: i6.DialogService }]; } });
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: [{
1612
+ ConfigurationService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: ConfigurationService, deps: [{ token: QuoteDraftService }, { token: ConfigurationRuntimeService }, { token: ContextService }, { token: i1.ConfigurationApiService }, { token: i5.MessageService }, { token: i6$1.DialogService }, { token: RuntimeSettingsService }], target: i0.ɵɵFactoryTarget.Injectable });
1613
+ ConfigurationService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: ConfigurationService });
1614
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: ConfigurationService, decorators: [{
1055
1615
  type: Injectable
1056
- }], ctorParameters: function () { return [{ type: i1.StatefulConfigurationApiService }, { type: ConfigurationRuntimeService }, { type: ConfigurationService }, { type: i4.ToastService }]; } });
1057
-
1058
- function extractMetadata(uiDefinition) {
1059
- return omit(uiDefinition, [
1060
- 'children',
1061
- 'pages',
1062
- 'components',
1063
- ]);
1064
- }
1616
+ }], ctorParameters: function () { return [{ type: QuoteDraftService }, { type: ConfigurationRuntimeService }, { type: ContextService }, { type: i1.ConfigurationApiService }, { type: i5.MessageService }, { type: i6$1.DialogService }, { type: RuntimeSettingsService }]; } });
1065
1617
 
1066
1618
  class FlowUpdateService {
1067
1619
  update(rootLineItems, updates, charges) {
@@ -1189,9 +1741,9 @@ class FlowUpdateService {
1189
1741
  return true;
1190
1742
  }
1191
1743
  }
1192
- FlowUpdateService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.8", ngImport: i0, type: FlowUpdateService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
1193
- FlowUpdateService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.8", ngImport: i0, type: FlowUpdateService });
1194
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.8", ngImport: i0, type: FlowUpdateService, decorators: [{
1744
+ FlowUpdateService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: FlowUpdateService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
1745
+ FlowUpdateService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: FlowUpdateService });
1746
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: FlowUpdateService, decorators: [{
1195
1747
  type: Injectable
1196
1748
  }] });
1197
1749
 
@@ -1202,6 +1754,8 @@ class FlowConfigurationService {
1202
1754
  this.quoteDraftService = quoteDraftService;
1203
1755
  this.updateService = updateService;
1204
1756
  this.configurationService = configurationService;
1757
+ this.updatedSubj$ = new Subject();
1758
+ this.updated$ = this.updatedSubj$.asObservable();
1205
1759
  }
1206
1760
  calculate$(quoteDraft) {
1207
1761
  return this.proceduresApiService.apply$(quoteDraft).pipe(tap$1(result => {
@@ -1211,7 +1765,7 @@ class FlowConfigurationService {
1211
1765
  .slice()
1212
1766
  .sort((a, b) => initialStateIds.indexOf(a.integrationId) - initialStateIds.indexOf(b.integrationId));
1213
1767
  this.quoteDraftService.updateQuoteDraft(result);
1214
- }), map$2(noop));
1768
+ }), map$1(noop));
1215
1769
  }
1216
1770
  calculate(quoteDraft) {
1217
1771
  this.calculate$(quoteDraft).subscribe();
@@ -1221,11 +1775,11 @@ class FlowConfigurationService {
1221
1775
  if (!quoteDraft) {
1222
1776
  return of(null);
1223
1777
  }
1224
- return of([]).pipe(map$2(() => {
1778
+ return of([]).pipe(map$1(() => {
1225
1779
  const updatedState = cloneDeep(quoteDraft.currentState);
1226
1780
  this.updateService.update(updatedState, updates, quoteDraft.charges);
1227
1781
  return updatedState;
1228
- }), switchMap$1(updatedState => this.calculate$({ ...quoteDraft, currentState: updatedState })), map$2(() => this.quoteDraftService.quoteDraft), this.handleErrorAndBounceBack());
1782
+ }), switchMap(updatedState => this.calculate$({ ...quoteDraft, currentState: updatedState })), map$1(() => this.quoteDraftService.quoteDraft), tap$1(() => this.updatedSubj$.next()), this.handleErrorAndBounceBack());
1229
1783
  }
1230
1784
  update(updates) {
1231
1785
  this.update$(updates).subscribe();
@@ -1244,7 +1798,7 @@ class FlowConfigurationService {
1244
1798
  updatedState.splice(currentLineItemIndex, 1, initialLineItem);
1245
1799
  return of([]).pipe(tap$1(() => {
1246
1800
  this.quoteDraftService.setCurrentLineItemState(updatedState);
1247
- }), switchMap$1(() => this.calculate$({ ...quoteDraft, currentState: updatedState })), map$2(() => this.quoteDraftService.quoteDraft), this.handleErrorAndBounceBack());
1801
+ }), switchMap(() => this.calculate$({ ...quoteDraft, currentState: updatedState })), map$1(() => this.quoteDraftService.quoteDraft), tap$1(() => this.updatedSubj$.next()), this.handleErrorAndBounceBack());
1248
1802
  }
1249
1803
  revert(lineItemId) {
1250
1804
  this.revert$(lineItemId).subscribe();
@@ -1255,7 +1809,7 @@ class FlowConfigurationService {
1255
1809
  if (!quoteDraft) {
1256
1810
  return of(null);
1257
1811
  }
1258
- return of([]).pipe(map$2(() => ids.reduce((result, id) => this.updateService.delete(result, id), currentState)), switchMap$1(updatedState => this.calculate$({ ...quoteDraft, currentState: updatedState })), map$2(() => this.quoteDraftService.quoteDraft), this.handleErrorAndBounceBack());
1812
+ return of([]).pipe(map$1(() => ids.reduce((result, id) => this.updateService.delete(result, id), currentState)), switchMap(updatedState => this.calculate$({ ...quoteDraft, currentState: updatedState })), map$1(() => this.quoteDraftService.quoteDraft), tap$1(() => this.updatedSubj$.next()), this.handleErrorAndBounceBack());
1259
1813
  }
1260
1814
  delete(ids) {
1261
1815
  this.delete$(ids).subscribe();
@@ -1266,34 +1820,34 @@ class FlowConfigurationService {
1266
1820
  return of(null);
1267
1821
  }
1268
1822
  const updatedState = [...quoteDraft.currentState, term];
1269
- return of([]).pipe(switchMap$1(() => this.calculate$({ ...quoteDraft, currentState: updatedState })), map$2(() => this.quoteDraftService.quoteDraft), this.handleErrorAndBounceBack());
1823
+ return of([]).pipe(switchMap(() => this.calculate$({ ...quoteDraft, currentState: updatedState })), map$1(() => this.quoteDraftService.quoteDraft), tap$1(() => this.updatedSubj$.next()), this.handleErrorAndBounceBack());
1270
1824
  }
1271
1825
  addToCart$(props) {
1272
1826
  const quoteDraft = this.quoteDraftService.quoteDraft;
1273
1827
  if (!quoteDraft) {
1274
1828
  return of(null);
1275
1829
  }
1276
- return this.configurationService.configureExternal$(props).pipe(map$2(lineItem => {
1830
+ return this.configurationService.configureExternal$(props).pipe(map$1(lineItem => {
1277
1831
  const model = this.configurationService.getRuntimeModel();
1278
1832
  const split = model?.types.find(type => type.name === lineItem.type)?.split ?? false;
1279
1833
  const lineItems = multiplyLineItems(lineItem, props.qty ?? 1, split);
1280
1834
  return [...quoteDraft.currentState, ...lineItems];
1281
- }), switchMap$1(updatedState => this.calculate$({ ...quoteDraft, currentState: updatedState })), map$2(() => this.quoteDraftService.quoteDraft), this.handleErrorAndBounceBack());
1835
+ }), switchMap(updatedState => this.calculate$({ ...quoteDraft, currentState: updatedState })), map$1(() => this.quoteDraftService.quoteDraft), tap$1(() => this.updatedSubj$.next()), this.handleErrorAndBounceBack());
1282
1836
  }
1283
1837
  get() {
1284
- return this.quoteDraftService.quoteDraft$.pipe(map$2(() => this.quoteDraftService.activeCurrentState), shareReplay$1());
1838
+ return this.quoteDraftService.quoteDraft$.pipe(map$1(() => this.quoteDraftService.activeCurrentState), shareReplay$1());
1285
1839
  }
1286
1840
  getSnapshot() {
1287
1841
  return this.quoteDraftService?.currentState.slice() ?? [];
1288
1842
  }
1289
1843
  get charges$() {
1290
- return this.quoteDraftService.quoteDraft$.pipe(map$2(({ charges }) => charges));
1844
+ return this.quoteDraftService.quoteDraft$.pipe(map$1(({ charges }) => charges));
1291
1845
  }
1292
1846
  get pricePlans$() {
1293
- return this.quoteDraftService.quoteDraft$.pipe(map$2(({ pricePlans }) => pricePlans));
1847
+ return this.quoteDraftService.quoteDraft$.pipe(map$1(({ pricePlans }) => pricePlans));
1294
1848
  }
1295
1849
  get activeMetrics$() {
1296
- return this.quoteDraftService.quoteDraft$.pipe(map$2(({ activeMetrics }) => activeMetrics));
1850
+ return this.quoteDraftService.quoteDraft$.pipe(map$1(({ activeMetrics }) => activeMetrics));
1297
1851
  }
1298
1852
  get chargesSnapshot() {
1299
1853
  return this.quoteDraftService.quoteDraft?.charges ?? {};
@@ -1301,307 +1855,545 @@ class FlowConfigurationService {
1301
1855
  get pricePlansSnapshot() {
1302
1856
  return this.quoteDraftService.quoteDraft?.pricePlans ?? {};
1303
1857
  }
1304
- get activeMetricsSnapshot() {
1305
- return this.quoteDraftService.quoteDraft?.activeMetrics ?? [];
1858
+ get activeMetricsSnapshot() {
1859
+ return this.quoteDraftService.quoteDraft?.activeMetrics ?? [];
1860
+ }
1861
+ get contextSnapshot() {
1862
+ return this.contextService.resolve();
1863
+ }
1864
+ get context$() {
1865
+ return this.contextService.resolve$();
1866
+ }
1867
+ handleErrorAndBounceBack() {
1868
+ return (source$) => {
1869
+ return source$.pipe(catchError(error => {
1870
+ console.error(error);
1871
+ // bounce back if configuration call has failed
1872
+ const quoteDraft = this.quoteDraftService.quoteDraft;
1873
+ if (quoteDraft) {
1874
+ this.quoteDraftService.updateQuoteDraft(quoteDraft);
1875
+ this.updatedSubj$.next();
1876
+ }
1877
+ return throwError(() => error);
1878
+ }));
1879
+ };
1880
+ }
1881
+ }
1882
+ FlowConfigurationService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: FlowConfigurationService, deps: [{ token: i1.ProceduresApiService }, { token: ContextService }, { token: QuoteDraftService }, { token: FlowUpdateService }, { token: ConfigurationService }], target: i0.ɵɵFactoryTarget.Injectable });
1883
+ FlowConfigurationService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: FlowConfigurationService });
1884
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: FlowConfigurationService, decorators: [{
1885
+ type: Injectable
1886
+ }], ctorParameters: function () { return [{ type: i1.ProceduresApiService }, { type: ContextService }, { type: QuoteDraftService }, { type: FlowUpdateService }, { type: ConfigurationService }]; } });
1887
+
1888
+ class FlowConfigurationModule {
1889
+ }
1890
+ FlowConfigurationModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: FlowConfigurationModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
1891
+ FlowConfigurationModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "15.2.9", ngImport: i0, type: FlowConfigurationModule, imports: [ApiModule] });
1892
+ FlowConfigurationModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: FlowConfigurationModule, providers: [FlowConfigurationService, FlowUpdateService], imports: [ApiModule] });
1893
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: FlowConfigurationModule, decorators: [{
1894
+ type: NgModule,
1895
+ args: [{
1896
+ imports: [ApiModule],
1897
+ providers: [FlowConfigurationService, FlowUpdateService],
1898
+ }]
1899
+ }] });
1900
+
1901
+ class FlowStateConfigurationService {
1902
+ constructor(flowInfoService, flowConfigurationService, flowStateApiService, flowStateService) {
1903
+ this.flowInfoService = flowInfoService;
1904
+ this.flowConfigurationService = flowConfigurationService;
1905
+ this.flowStateApiService = flowStateApiService;
1906
+ this.flowStateService = flowStateService;
1907
+ this.configurationStateId$ = new BehaviorSubject(null);
1908
+ }
1909
+ get configurationStateId() {
1910
+ return this.configurationStateId$.value;
1911
+ }
1912
+ addToCart$(props) {
1913
+ let request$;
1914
+ const stateful = this.flowInfoService.flow?.properties.stateful;
1915
+ if (stateful) {
1916
+ const stateId = this.flowStateService.stateId;
1917
+ if (!stateId) {
1918
+ request$ = of();
1919
+ }
1920
+ else {
1921
+ const lineItem = generateConfigurationLineItem(props, props.qty);
1922
+ request$ = this.flowStateApiService.newConfiguration(stateId, { lineItem }).pipe(tap$1(r => this.configurationStateId$.next(r.stateId)), switchMap(() => {
1923
+ if (!this.configurationStateId) {
1924
+ return of();
1925
+ }
1926
+ return this.flowStateApiService.saveConfiguration(stateId, this.configurationStateId).pipe(tap$1(() => this.configurationStateId$.next(null)), map$1(noop));
1927
+ }));
1928
+ }
1929
+ }
1930
+ else {
1931
+ request$ = this.flowConfigurationService.addToCart$(props).pipe(map$1(noop));
1932
+ }
1933
+ return request$.pipe(switchMap(() => this.flowStateService.executeRequest$({}, true)), map$1(noop));
1934
+ }
1935
+ }
1936
+ 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 });
1937
+ FlowStateConfigurationService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: FlowStateConfigurationService });
1938
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: FlowStateConfigurationService, decorators: [{
1939
+ type: Injectable
1940
+ }], ctorParameters: function () { return [{ type: FlowInfoService }, { type: FlowConfigurationService }, { type: i1.FlowStateApiService }, { type: FlowStateService }]; } });
1941
+
1942
+ class ProductImagesService {
1943
+ constructor(productApiService) {
1944
+ this.productApiService = productApiService;
1945
+ this.imagesMap$ = new BehaviorSubject({});
1946
+ }
1947
+ getImageUrl$(productId) {
1948
+ if (this.imagesMap$.value[productId] == null) {
1949
+ this.imagesMap$.next({ ...this.imagesMap$.value, [productId]: '' });
1950
+ this.fetchProductImage(productId);
1951
+ }
1952
+ return this.imagesMap$.pipe(map$1(imagesMap => imagesMap[productId] ?? null), distinctUntilChanged());
1953
+ }
1954
+ fetchProductImage(productId) {
1955
+ this.productApiService
1956
+ .fetchImage$(productId)
1957
+ .pipe(map$1(file => URL.createObjectURL(file)), catchError(() => of('')), tap$1(url => this.imagesMap$.next({ ...this.imagesMap$.value, [productId]: url })))
1958
+ .subscribe();
1959
+ }
1960
+ }
1961
+ ProductImagesService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: ProductImagesService, deps: [{ token: i1.ProductApiService }], target: i0.ɵɵFactoryTarget.Injectable });
1962
+ ProductImagesService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: ProductImagesService });
1963
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: ProductImagesService, decorators: [{
1964
+ type: Injectable
1965
+ }], ctorParameters: function () { return [{ type: i1.ProductApiService }]; } });
1966
+
1967
+ class RuntimeContextService {
1968
+ constructor(configurationApiService) {
1969
+ this.configurationApiService = configurationApiService;
1970
+ }
1971
+ getRuntimeContext(productId, offeringId) {
1972
+ return this.configurationApiService.getRuntimeDataByProductId(productId, offeringId).pipe(map(runtimeData => {
1973
+ const uiDefinitionContainer = this.getUIDefinitionContainer(runtimeData);
1974
+ const runtimeModel = RuntimeModel.create(runtimeData.types, runtimeData.products);
1975
+ const { productName, properties } = Array.from(runtimeModel.components.values()).find(c => c.productId === productId) ?? {};
1976
+ const uiDefinitionProperties = uiDefinitionContainer?.source.properties;
1977
+ return {
1978
+ modelId: runtimeData.modelId,
1979
+ uiDefinitionContainer: uiDefinitionContainer,
1980
+ runtimeModel: runtimeModel,
1981
+ runtimeMode: RuntimeMode.PROD,
1982
+ productId: productId,
1983
+ productType: properties?.['displayName'] || productName,
1984
+ offeringId: offeringId,
1985
+ properties: {
1986
+ PricingEnabled: uiDefinitionProperties?.pricingEnabled ? 'true' : 'false',
1987
+ PriceListId: uiDefinitionProperties?.priceList,
1988
+ },
1989
+ };
1990
+ }));
1991
+ }
1992
+ getUIDefinitionContainer(runtimeData) {
1993
+ const containers = runtimeData.uiDefinitions.filter(container => isNotLegacyUIDefinition(container.source));
1994
+ return containers.find(container => container.source.primary) ?? containers[0];
1995
+ }
1996
+ }
1997
+ RuntimeContextService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: RuntimeContextService, deps: [{ token: i1.ConfigurationApiService }], target: i0.ɵɵFactoryTarget.Injectable });
1998
+ RuntimeContextService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: RuntimeContextService });
1999
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: RuntimeContextService, decorators: [{
2000
+ type: Injectable
2001
+ }], ctorParameters: function () { return [{ type: i1.ConfigurationApiService }]; } });
2002
+
2003
+ class ConfigurationRuntimeService {
2004
+ constructor(apiService, contextService, runtimeContextService) {
2005
+ this.apiService = apiService;
2006
+ this.contextService = contextService;
2007
+ this.runtimeContextService = runtimeContextService;
2008
+ this._isInitialized = false;
2009
+ this.uiDefinitionProperties = {};
2010
+ }
2011
+ reset() {
2012
+ this._isInitialized = false;
2013
+ this._runtimeContext = undefined;
2014
+ this.initializationProps = undefined;
2015
+ this.uiDefinitionProperties = {};
2016
+ }
2017
+ initTestMode(uiDefinitionContainer) {
2018
+ this.uiDefinitionProperties = uiDefinitionContainer.source.properties ?? {};
2019
+ const uiDefinitionExternals = uiDefinitionContainer.source.externals ?? {};
2020
+ return combineLatest([
2021
+ this.apiService.getRuntimeDataByModelId(uiDefinitionContainer.modelId),
2022
+ this.contextService.initTestMode(),
2023
+ ]).pipe(first(), map(([runtimeData, context]) => {
2024
+ this.contextService.update({
2025
+ properties: {
2026
+ ...this.runtimeContext?.properties,
2027
+ ...context.properties,
2028
+ ModelId: uiDefinitionContainer.modelId,
2029
+ PricingEnabled: this.uiDefinitionProperties.pricingEnabled ? 'true' : 'false',
2030
+ PriceListId: this.uiDefinitionProperties.priceList,
2031
+ offeringId: this.uiDefinitionProperties.offeringId,
2032
+ ...uiDefinitionExternals,
2033
+ },
2034
+ });
2035
+ this._runtimeContext = {
2036
+ modelId: uiDefinitionContainer.modelId,
2037
+ runtimeModel: RuntimeModel.create(runtimeData.types, runtimeData.products),
2038
+ runtimeMode: RuntimeMode.TEST,
2039
+ uiDefinitionContainer,
2040
+ };
2041
+ return this._runtimeContext;
2042
+ }), tap(() => (this._isInitialized = true)));
2043
+ }
2044
+ init(props) {
2045
+ this.initializationProps = props;
2046
+ const context = this.contextService.resolve();
2047
+ return this.runtimeContextService.getRuntimeContext(props.productId, props.offeringId).pipe(tap(runtimeContext => {
2048
+ this.uiDefinitionProperties = runtimeContext.uiDefinitionContainer?.source.properties ?? {};
2049
+ const { PriceListId } = context.properties ?? {};
2050
+ const mergeContext = {
2051
+ ...runtimeContext,
2052
+ properties: {
2053
+ ...runtimeContext.properties,
2054
+ ...context.properties,
2055
+ PricingEnabled: PriceListId ? 'true' : 'false',
2056
+ },
2057
+ };
2058
+ this.id15to18('AccountId', mergeContext.properties);
2059
+ this._runtimeContext = mergeContext;
2060
+ if (context.properties && this._runtimeContext.properties?.StartDate) {
2061
+ this.contextService.update({
2062
+ properties: {
2063
+ ...this._runtimeContext.properties,
2064
+ ...context.properties,
2065
+ },
2066
+ });
2067
+ }
2068
+ return this._runtimeContext;
2069
+ }), tap(() => (this._isInitialized = true)));
2070
+ }
2071
+ overrideUIDefinition(uiDefinitionContainer) {
2072
+ if (!this._runtimeContext) {
2073
+ return;
2074
+ }
2075
+ this._runtimeContext.uiDefinitionContainer = uiDefinitionContainer;
2076
+ this.uiDefinitionProperties = uiDefinitionContainer.source.properties ?? {};
2077
+ }
2078
+ id15to18(propertyName, source) {
2079
+ if (!source) {
2080
+ return;
2081
+ }
2082
+ const value = source[propertyName];
2083
+ if (typeof value === 'string' && value.length === 15) {
2084
+ source[propertyName] = SalesforceIdUtils.generateId18FromId15(value);
2085
+ }
1306
2086
  }
1307
- get contextSnapshot() {
1308
- return this.contextService.resolve();
2087
+ get isInitialized() {
2088
+ return this._isInitialized;
1309
2089
  }
1310
- get context$() {
1311
- return this.contextService.resolve$();
2090
+ get runtimeModel() {
2091
+ return this.runtimeContext?.runtimeModel;
1312
2092
  }
1313
- handleErrorAndBounceBack() {
1314
- return (source$) => {
1315
- return source$.pipe(catchError$1(error => {
1316
- console.error(error);
1317
- // bounce back if configuration call has failed
1318
- const quoteDraft = this.quoteDraftService.quoteDraft;
1319
- if (quoteDraft) {
1320
- this.quoteDraftService.updateQuoteDraft(quoteDraft);
1321
- }
1322
- return throwError(() => error);
1323
- }));
1324
- };
2093
+ get runtimeContext() {
2094
+ return this._runtimeContext;
1325
2095
  }
1326
2096
  }
1327
- FlowConfigurationService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.8", ngImport: i0, type: FlowConfigurationService, deps: [{ token: i1.ProceduresApiService }, { token: ContextService }, { token: QuoteDraftService }, { token: FlowUpdateService }, { token: ConfigurationService }], target: i0.ɵɵFactoryTarget.Injectable });
1328
- FlowConfigurationService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.8", ngImport: i0, type: FlowConfigurationService });
1329
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.8", ngImport: i0, type: FlowConfigurationService, decorators: [{
2097
+ ConfigurationRuntimeService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: ConfigurationRuntimeService, deps: [{ token: i1.ConfigurationApiService }, { token: ContextService }, { token: RuntimeContextService }], target: i0.ɵɵFactoryTarget.Injectable });
2098
+ ConfigurationRuntimeService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: ConfigurationRuntimeService });
2099
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: ConfigurationRuntimeService, decorators: [{
1330
2100
  type: Injectable
1331
- }], ctorParameters: function () { return [{ type: i1.ProceduresApiService }, { type: ContextService }, { type: QuoteDraftService }, { type: FlowUpdateService }, { type: ConfigurationService }]; } });
1332
-
1333
- class FlowConfigurationModule {
1334
- }
1335
- FlowConfigurationModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.8", ngImport: i0, type: FlowConfigurationModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
1336
- FlowConfigurationModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "15.2.8", ngImport: i0, type: FlowConfigurationModule });
1337
- FlowConfigurationModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "15.2.8", ngImport: i0, type: FlowConfigurationModule, providers: [FlowConfigurationService, FlowUpdateService, PriceApiService] });
1338
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.8", ngImport: i0, type: FlowConfigurationModule, decorators: [{
1339
- type: NgModule,
1340
- args: [{
1341
- imports: [],
1342
- providers: [FlowConfigurationService, FlowUpdateService, PriceApiService],
1343
- }]
1344
- }] });
1345
-
1346
- class ConfigurationModule {
1347
- }
1348
- ConfigurationModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.8", ngImport: i0, type: ConfigurationModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
1349
- ConfigurationModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "15.2.8", ngImport: i0, type: ConfigurationModule, imports: [ConfirmationDialogModule] });
1350
- ConfigurationModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "15.2.8", ngImport: i0, type: ConfigurationModule, providers: [
1351
- ContextApiService,
1352
- ProductModelApiService,
1353
- ConfigurationApiService,
1354
- ConfigurationRuntimeService,
1355
- RuntimeContextService,
1356
- ConfigurationService,
1357
- ConfigurationState,
1358
- ], imports: [ConfirmationDialogModule] });
1359
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.8", ngImport: i0, type: ConfigurationModule, decorators: [{
1360
- type: NgModule,
1361
- args: [{
1362
- imports: [ConfirmationDialogModule],
1363
- providers: [
1364
- ContextApiService,
1365
- ProductModelApiService,
1366
- ConfigurationApiService,
1367
- ConfigurationRuntimeService,
1368
- RuntimeContextService,
1369
- ConfigurationService,
1370
- ConfigurationState,
1371
- ],
1372
- }]
1373
- }] });
2101
+ }], ctorParameters: function () { return [{ type: i1.ConfigurationApiService }, { type: ContextService }, { type: RuntimeContextService }]; } });
1374
2102
 
1375
- function calculateMetricByMethod(lineItems, metric, method) {
1376
- const items = getLineItemsByMethod(lineItems, method);
1377
- return items.reduce((acc, li) => {
1378
- let value = li.reduce((accProduct, item) => accProduct + ((item.totalMetrics && item.totalMetrics[metric]) || 0), 0);
1379
- if (method === 'avg' && li.length > 0) {
1380
- value /= li.length;
1381
- }
1382
- return acc + value;
1383
- }, 0);
1384
- }
1385
- function getLineItemsByMethod(lineItems, method) {
1386
- switch (method) {
1387
- case 'first': {
1388
- return lineItems.filter(li => !li.rampInstanceId).map(item => [item]);
1389
- }
1390
- case 'last': {
1391
- const rootTermItems = lineItems.filter(li => !li.rampInstanceId);
1392
- const products = rootTermItems.map(lineItem => [
1393
- lineItem,
1394
- ...lineItems.filter(li => li.rampInstanceId === lineItem.id),
1395
- ]);
1396
- return products
1397
- .map(items => [...items].sort((a, b) => getDateValue(a.endDate || '') - getDateValue(b.endDate || '')).pop())
1398
- .filter((li) => Boolean(li))
1399
- .map(item => [item]);
2103
+ class ConfigurationStateService {
2104
+ constructor(configurationRuntimeService, configurationService, quoteDraftService, toastService, flowStateService, flowInfoService, flowConfigurationService, flowStateApiService, quoteApiService) {
2105
+ this.configurationRuntimeService = configurationRuntimeService;
2106
+ this.configurationService = configurationService;
2107
+ this.quoteDraftService = quoteDraftService;
2108
+ this.toastService = toastService;
2109
+ this.flowStateService = flowStateService;
2110
+ this.flowInfoService = flowInfoService;
2111
+ this.flowConfigurationService = flowConfigurationService;
2112
+ this.flowStateApiService = flowStateApiService;
2113
+ this.quoteApiService = quoteApiService;
2114
+ this.isInitialized$ = new BehaviorSubject(false);
2115
+ this.canceledConfiguration$ = new Subject();
2116
+ this.NOT_INITIALIZED = Symbol();
2117
+ this.executedFunctions = {};
2118
+ this.stateId = null;
2119
+ this.ownerId = '';
2120
+ this.subscriptions = {};
2121
+ this.configurationStore = {};
2122
+ }
2123
+ init$() {
2124
+ let request$;
2125
+ if (this.flowStateService.stateId && this.isStatefulConfiguration) {
2126
+ request$ = this.initStateful$();
2127
+ }
2128
+ else {
2129
+ request$ = this.initStateless$();
1400
2130
  }
1401
- case 'avg': {
1402
- const rootTermItems = lineItems.filter(li => !li.rampInstanceId);
1403
- return rootTermItems.map(lineItem => [lineItem, ...lineItems.filter(li => li.rampInstanceId === lineItem.id)]);
2131
+ return request$.pipe(finalize(() => {
2132
+ this.isInitialized$.next(true);
2133
+ this.canceledConfiguration$ = new Subject();
2134
+ }));
2135
+ }
2136
+ cleanup() {
2137
+ this.stateId = null;
2138
+ this.configurationStore = {};
2139
+ this.configurationService.reset();
2140
+ }
2141
+ execute$(req, forceSubscriptions) {
2142
+ const fullRequest = cloneDeep(req);
2143
+ if (fullRequest.actions?.length || forceSubscriptions) {
2144
+ for (const subscription of Object.values(this.subscriptions)) {
2145
+ fullRequest.selectors = assign(fullRequest.selectors, subscription.request.selectors);
2146
+ }
1404
2147
  }
1405
- case 'sum': {
1406
- return lineItems.map(item => [item]);
2148
+ let execution$;
2149
+ if (this.isStatefulConfiguration) {
2150
+ execution$ = this.executeStateful$(fullRequest);
1407
2151
  }
1408
- default: {
1409
- return lineItems.map(item => [item]);
2152
+ else {
2153
+ execution$ = this.executeStateless$(fullRequest);
1410
2154
  }
2155
+ return execution$.pipe(tap$1(result => this.handleSelectorsResponse(result.selectors)));
1411
2156
  }
1412
- }
1413
- function getDateValue(date) {
1414
- return date ? new Date(date).getTime() : 0;
1415
- }
1416
-
1417
- class MetricsCalculationService {
1418
- get onMetricsUpdate$() {
1419
- return this.metricsUpdated$.asObservable();
1420
- }
1421
- constructor(quoteDraftService, flowConfiguration, settingsService) {
1422
- this.quoteDraftService = quoteDraftService;
1423
- this.flowConfiguration = flowConfiguration;
1424
- this.settingsService = settingsService;
1425
- this.metricsUpdated$ = new Subject();
1426
- this.quoteMetricsSettings = {};
1427
- this.metricsCalculationMethodMap = {};
1428
- this.metricsData = {};
1429
- this.activeMetricRules = [];
1430
- this.activeMetricRules = this.flowConfiguration.activeMetricsSnapshot.filter(metricRule => metricRule.metrics.some(metric => !!metric.totalName));
1431
- combineLatest([
1432
- this.quoteDraftService.currentState$,
1433
- this.settingsService.fetchSetting('QUOTE_LEVEL_METRIC_CALCULATION_METHOD').pipe(take$1(1)),
1434
- ]).subscribe(([lineItems, setting]) => {
1435
- let settingsData = {};
1436
- try {
1437
- settingsData = JSON.parse(setting?.value || '{}');
2157
+ handleSelectorsResponse(selectors) {
2158
+ Object.entries(selectors).forEach(([requestId, selectorResult]) => {
2159
+ if (!selectorResult.success) {
2160
+ this.toastService.add({ severity: ToastType.error, summary: selectorResult.errorMessage });
1438
2161
  }
1439
- catch (error) {
1440
- settingsData = {};
2162
+ const subscription$ = this.subscriptions[requestId]?.data$;
2163
+ if (subscription$) {
2164
+ subscription$.next(selectorResult);
1441
2165
  }
1442
- this.quoteMetricsSettings = settingsData;
1443
- this.updateMetrics(lineItems);
1444
2166
  });
1445
2167
  }
1446
- getMetricValue(metric) {
1447
- return this.metricsData[metric] || 0;
2168
+ dispatch$(actionName, inputData = {}) {
2169
+ return this.execute$({ actions: [{ apiName: actionName, inputData, ownerId: this.ownerId }] });
1448
2170
  }
1449
- updateMetrics(lineItems) {
1450
- const metricKeys = this.collectMetricKeys(lineItems).filter(key => !key.includes('Effective_'));
1451
- this.metricsCalculationMethodMap = this.buildMetricsCalculationMethods(metricKeys, this.metricsCalculationMethodMap);
1452
- this.metricsData = metricKeys.reduce((acc, key) => ({ ...acc, [key]: this.calculateMetric(lineItems, key) }), {});
1453
- this.metricsUpdated$.next();
1454
- }
1455
- calculateMetric(lineItems, metric) {
1456
- return calculateMetricByMethod(lineItems, metric, this.metricsCalculationMethodMap[metric] || 'sum');
2171
+ select$(selectorName, inputData = {}) {
2172
+ const requestId = UUID.UUID();
2173
+ return this.execute$({
2174
+ selectors: {
2175
+ [requestId]: {
2176
+ apiName: selectorName,
2177
+ inputData,
2178
+ ownerId: this.ownerId,
2179
+ },
2180
+ },
2181
+ }).pipe(map$1(response => response.selectors[requestId]));
1457
2182
  }
1458
- buildMetricsCalculationMethods(metricKeys, initial) {
1459
- return metricKeys.reduce((acc, name) => {
1460
- if (acc[name]) {
1461
- return acc;
2183
+ subscribe$(selectorName, inputData = {}, options) {
2184
+ const requestId = UUID.UUID();
2185
+ let subscription = this.subscriptions[requestId];
2186
+ if (!subscription) {
2187
+ const request = {
2188
+ selectors: {
2189
+ [requestId]: {
2190
+ apiName: selectorName,
2191
+ inputData,
2192
+ ownerId: this.ownerId,
2193
+ },
2194
+ },
2195
+ };
2196
+ subscription = {
2197
+ request,
2198
+ data$: new BehaviorSubject(this.NOT_INITIALIZED),
2199
+ };
2200
+ this.subscriptions[requestId] = subscription;
2201
+ if (!options?.cold) {
2202
+ this.execute$(request).subscribe();
1462
2203
  }
1463
- acc = { ...acc, [name]: 'sum' };
1464
- const metricRule = this.getMetricRuleByTotalMetricName(name);
1465
- const settingKey = metricRule?.metrics?.find(metric => metric.totalName === name)?.name || name;
1466
- if (this.quoteMetricsSettings[settingKey]) {
1467
- acc = { ...acc, [name]: this.quoteMetricsSettings[settingKey] };
2204
+ }
2205
+ return subscription.data$.pipe(filter$1(data => data != this.NOT_INITIALIZED), map$1(data => data), distinctUntilChanged(), finalize(() => {
2206
+ if (!this.subscriptions[requestId]?.data$.observed) {
2207
+ delete this.subscriptions[requestId];
1468
2208
  }
1469
- return acc;
1470
- }, initial);
2209
+ }), takeUntil(this.canceledConfiguration$));
1471
2210
  }
1472
- collectMetricKeys(lineItems) {
1473
- const keys = [];
1474
- lineItems.forEach(lineItem => {
1475
- keys.push(...Object.keys(lineItem.totalMetrics || {}));
1476
- keys.push(...this.collectMetricKeys(lineItem.lineItems));
1477
- });
1478
- return uniq(keys);
2211
+ saveConfiguration(quoteId, flow) {
2212
+ if (this.isStatefulConfiguration) {
2213
+ return this.flowStateApiService
2214
+ .saveConfiguration(this.flowStateService.stateId ?? '', this.stateId ?? '')
2215
+ .pipe(switchMap(r => this.flowStateService.executeRequest$({}, true).pipe(map$1(() => r))));
2216
+ }
2217
+ else {
2218
+ if (!flow) {
2219
+ if (!quoteId) {
2220
+ return of({ quoteId: '' });
2221
+ }
2222
+ const rootLineItem = this.configurationService.getSnapshot();
2223
+ const currentState = rootLineItem ? [rootLineItem] : [];
2224
+ return this.quoteApiService
2225
+ .getQuoteDraft(quoteId)
2226
+ .pipe(switchMap(quoteDraft => this.quoteApiService.upsertQuote({ ...quoteDraft, currentState })));
2227
+ }
2228
+ else {
2229
+ const quoteDraft = this.quoteDraftService.quoteDraft;
2230
+ const lineItem = this.configurationService.getSnapshot();
2231
+ if (!quoteDraft || !lineItem) {
2232
+ return of({ quoteId: '' });
2233
+ }
2234
+ const isNewLineItem = quoteDraft.currentState.every(li => li.id !== lineItem.id);
2235
+ let updatedState;
2236
+ if (isNewLineItem) {
2237
+ updatedState = [...quoteDraft.currentState, lineItem];
2238
+ }
2239
+ else {
2240
+ updatedState = quoteDraft.currentState.map(li => (li.id === lineItem.id ? lineItem : li));
2241
+ }
2242
+ return this.flowConfigurationService
2243
+ .calculate$({ ...quoteDraft, currentState: updatedState })
2244
+ .pipe(map$1(() => ({ quoteId: '' })));
2245
+ }
2246
+ }
1479
2247
  }
1480
- getMetricRuleByTotalMetricName(name) {
1481
- return this.activeMetricRules.find(metricRule => metricRule.metrics.find(metric => metric.totalName === name));
2248
+ cancelConfiguration() {
2249
+ if (!this.isInitialized$.value) {
2250
+ return of(undefined);
2251
+ }
2252
+ this.canceledConfiguration$.next();
2253
+ this.canceledConfiguration$.complete();
2254
+ this.subscriptions = {};
2255
+ this.isInitialized$.next(false);
2256
+ if (!this.isInitialized$.value || !this.isStatefulConfiguration) {
2257
+ return of(undefined);
2258
+ }
2259
+ return this.flowStateApiService.cancelConfiguration(this.flowStateService.stateId ?? '', this.stateId ?? '');
1482
2260
  }
1483
- }
1484
- MetricsCalculationService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.8", ngImport: i0, type: MetricsCalculationService, deps: [{ token: QuoteDraftService }, { token: FlowConfigurationService }, { token: i1.ConfigurationSettingsApiService }], target: i0.ɵɵFactoryTarget.Injectable });
1485
- MetricsCalculationService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.8", ngImport: i0, type: MetricsCalculationService, providedIn: 'root' });
1486
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.8", ngImport: i0, type: MetricsCalculationService, decorators: [{
1487
- type: Injectable,
1488
- args: [{ providedIn: 'root' }]
1489
- }], ctorParameters: function () { return [{ type: QuoteDraftService }, { type: FlowConfigurationService }, { type: i1.ConfigurationSettingsApiService }]; } });
1490
-
1491
- class ProductImagesService {
1492
- constructor(productApiService) {
1493
- this.productApiService = productApiService;
1494
- this.imagesMap$ = new BehaviorSubject({});
2261
+ get isStatefulConfiguration() {
2262
+ return this.flowInfoService.flow?.properties.stateful ?? false;
1495
2263
  }
1496
- getImageUrl$(productId) {
1497
- if (this.imagesMap$.value[productId] == null) {
1498
- this.imagesMap$.next({ ...this.imagesMap$.value, [productId]: '' });
1499
- this.fetchProductImage(productId);
2264
+ initStateful$() {
2265
+ this.ownerId = this.configurationRuntimeService.runtimeContext?.uiDefinitionContainer?.id ?? '';
2266
+ const lineItemId = this.configurationRuntimeService.runtimeContext?.properties?.lineItemId;
2267
+ if (!this.flowStateService.stateId) {
2268
+ return of(undefined);
1500
2269
  }
1501
- return this.imagesMap$.pipe(map$2(imagesMap => imagesMap[productId]), distinctUntilChanged());
1502
- }
1503
- fetchProductImage(productId) {
1504
- this.productApiService
1505
- .fetchImage$(productId)
1506
- .pipe(map$2(file => URL.createObjectURL(file)), catchError$1(() => of('')), tap$1(url => this.imagesMap$.next({ ...this.imagesMap$.value, [productId]: url })))
1507
- .subscribe();
2270
+ const container = this.configurationRuntimeService.runtimeContext?.uiDefinitionContainer;
2271
+ const lineItem = this.configurationService.generateLineItem();
2272
+ let request$;
2273
+ if (!lineItemId) {
2274
+ request$ = this.flowStateApiService.newConfiguration(this.flowStateService.stateId, {
2275
+ lineItem,
2276
+ actionsOverride: container?.actions?.map(processor => ({ ...processor, ownerId: this.ownerId })),
2277
+ selectorsOverride: container?.selectors?.map(processor => ({ ...processor, ownerId: this.ownerId })),
2278
+ });
2279
+ }
2280
+ else {
2281
+ request$ = this.flowStateApiService.startConfiguration(this.flowStateService.stateId, {
2282
+ lineItemId,
2283
+ actionsOverride: container?.actions?.map(processor => ({ ...processor, ownerId: this.ownerId })),
2284
+ selectorsOverride: container?.selectors?.map(processor => ({ ...processor, ownerId: this.ownerId })),
2285
+ });
2286
+ }
2287
+ return request$.pipe(map$1(r => {
2288
+ this.stateId = r.stateId;
2289
+ return undefined;
2290
+ }));
1508
2291
  }
1509
- }
1510
- ProductImagesService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.8", ngImport: i0, type: ProductImagesService, deps: [{ token: i1.ProductApiService }], target: i0.ɵɵFactoryTarget.Injectable });
1511
- ProductImagesService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.8", ngImport: i0, type: ProductImagesService, providedIn: 'root' });
1512
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.8", ngImport: i0, type: ProductImagesService, decorators: [{
1513
- type: Injectable,
1514
- args: [{ providedIn: 'root' }]
1515
- }], ctorParameters: function () { return [{ type: i1.ProductApiService }]; } });
1516
-
1517
- class RuntimeSettingsService {
1518
- constructor(configurationSettingsApiService) {
1519
- this.configurationSettingsApiService = configurationSettingsApiService;
1520
- this.configurationSettings$ = new BehaviorSubject({});
1521
- this.currencySettings$ = new BehaviorSubject({
1522
- iso: DEFAULT_CURRENCY_ISO_CODE,
1523
- symbol: DEFAULT_CURRENCY_SYMBOL,
1524
- });
1525
- this.getCurrencySymbol = (locale, currency) => {
1526
- return (0)
1527
- .toLocaleString(locale, { style: 'currency', currency, minimumFractionDigits: 0, maximumFractionDigits: 0 })
1528
- .replace(/\d/g, '')
1529
- .trim();
1530
- };
2292
+ initStateless$() {
2293
+ return this.configurationService.configure().pipe(map$1(() => undefined));
1531
2294
  }
1532
- create() {
1533
- return this.configurationSettingsApiService.fetchSettings().pipe(map$2(settings => this.parseConfigurationSettings(settings)), tap$1(configurationSettings => {
1534
- this.configurationSettings$.next(configurationSettings);
1535
- this.formattingSettings = this.getFormattingSettings();
1536
- }), map$2(() => undefined));
2295
+ executeStateless$(request) {
2296
+ return of(undefined).pipe(switchMap(() => {
2297
+ // Apply actions and execute configuration/price call
2298
+ // No need to run configuration if no actions in the request
2299
+ if (!request.actions?.length) {
2300
+ return of(undefined);
2301
+ }
2302
+ let configurationRequest = this.configurationService.generateRequest();
2303
+ request.actions.forEach(action => {
2304
+ try {
2305
+ configurationRequest = this.executeActionScript(configurationRequest, action) ?? configurationRequest;
2306
+ }
2307
+ catch (e) {
2308
+ console.error(e);
2309
+ this.toastService.add({ severity: ToastType.error, summary: String(e) });
2310
+ throw e;
2311
+ }
2312
+ });
2313
+ return this.configurationService.configureRequest$(configurationRequest);
2314
+ }), map$1(() => {
2315
+ // Run selectors and apply them to the state
2316
+ const configurationState = cloneDeep(this.configurationService.stateSnapshot);
2317
+ if (!configurationState) {
2318
+ return { stateId: '', selectors: {} };
2319
+ }
2320
+ const selectorsResult = EntityUtil.entries(request.selectors ?? {}).reduce((result, [key, selector]) => {
2321
+ try {
2322
+ result.selectors[key] = {
2323
+ success: true,
2324
+ result: this.executeSelectorScript(configurationState, selector),
2325
+ };
2326
+ }
2327
+ catch (e) {
2328
+ console.error(e);
2329
+ result.selectors[key] = {
2330
+ success: false,
2331
+ errorMessage: String(e),
2332
+ };
2333
+ }
2334
+ return result;
2335
+ }, { stateId: '', selectors: {} });
2336
+ return selectorsResult;
2337
+ }));
1537
2338
  }
1538
- initCurrency(iso) {
1539
- if (iso) {
1540
- const symbol = this.getCurrencySymbol('en-US', iso);
1541
- this.currencySettings$.next({ iso, symbol });
2339
+ executeStateful$(request) {
2340
+ if (!this.flowStateService.stateId || !this.stateId) {
2341
+ return of();
1542
2342
  }
2343
+ return this.flowStateApiService.executeConfiguration(this.flowStateService.stateId, this.stateId, request).pipe(tap$1(response => {
2344
+ this.stateId = response.stateId;
2345
+ }));
1543
2346
  }
1544
- getFormattingSettings() {
1545
- if (this.formattingSettings) {
1546
- return this.formattingSettings;
2347
+ executeActionScript(request, processor) {
2348
+ const { actions } = this.configurationRuntimeService.runtimeContext?.uiDefinitionContainer ?? {};
2349
+ const configurationProcessor = actions?.find(action => action.apiName === processor.apiName);
2350
+ if (!configurationProcessor?.script) {
2351
+ throw `ConfigurationProcessor ${processor.apiName} not found`;
1547
2352
  }
1548
- const shoppingCartSettings = this.getConfigurationSettings()['shopping-cart']?.reduce((acc, setting) => {
1549
- return { ...acc, [setting.id]: setting.properties };
1550
- }, {});
1551
- const currencySettings = this.getCurrencySettings();
1552
- const dateFormat = (validateDateFormat(shoppingCartSettings?.DATE_FORMAT ?? '') && shoppingCartSettings?.DATE_FORMAT) ||
1553
- DEFAULT_DATE_FORMAT;
1554
- const decimalSeparator = shoppingCartSettings?.DECIMAL_SEPARATOR;
1555
- const thousandsSeparator = shoppingCartSettings?.THOUSANDS_SEPARATOR;
1556
- // the number of decimal places can be 0
1557
- const priceScale = shoppingCartSettings?.PRICE_SCALE;
1558
- const decimalsCount = priceScale !== null && priceScale !== '' && !isNaN(Number(priceScale)) && Number(priceScale) >= 0
1559
- ? Number(priceScale)
1560
- : DEFAULT_DECIMALS_COUNT;
1561
- return {
1562
- currencySymbol: currencySettings.symbol,
1563
- dateFormats: getSupportedDateFormats(dateFormat),
1564
- decimalsCount,
1565
- decimalSeparator: decimalSeparator !== undefined && ['.', ','].includes(decimalSeparator)
1566
- ? decimalSeparator
1567
- : DEFAULT_DECIMAL_SEPARATOR,
1568
- // thousands separator can be a blank value, so it can also be null
1569
- thousandsSeparator: thousandsSeparator !== undefined && ['.', ',', '', null].includes(thousandsSeparator)
1570
- ? thousandsSeparator || ''
1571
- : DEFAULT_THOUSANDS_SEPARATOR,
1572
- };
1573
- }
1574
- getConfigurationSettings() {
1575
- return this.configurationSettings$.value;
1576
- }
1577
- getCurrencySettings() {
1578
- return this.currencySettings$.value;
2353
+ return this.executeProcessorScript(request, configurationProcessor, processor.inputData);
1579
2354
  }
1580
- parseConfigurationSettings(settings) {
1581
- return settings.reduce((acc, setting) => {
1582
- switch (setting.key) {
1583
- case 'shopping-cart':
1584
- acc['shopping-cart'] = parseJsonSafely(setting.value, []);
1585
- break;
1586
- case 'navigation':
1587
- acc.navigation = parseJsonSafely(setting.value, {});
1588
- break;
1589
- case 'flows':
1590
- acc.flows = parseJsonSafely(setting.value, []);
1591
- break;
1592
- default:
1593
- acc[setting.key] = setting.value;
1594
- }
1595
- return acc;
1596
- }, {});
2355
+ executeSelectorScript(request, processor) {
2356
+ const { selectors } = this.configurationRuntimeService.runtimeContext?.uiDefinitionContainer ?? {};
2357
+ const configurationProcessor = selectors?.find(selector => selector.apiName === processor.apiName);
2358
+ if (!configurationProcessor?.script) {
2359
+ throw `ConfigurationProcessor ${processor.apiName} not found`;
2360
+ }
2361
+ return this.executeProcessorScript(request, configurationProcessor, processor.inputData);
2362
+ }
2363
+ executeProcessorScript(request, configurationProcessor, inputData) {
2364
+ let functionToExecute = this.executedFunctions[configurationProcessor.apiName];
2365
+ if (!functionToExecute) {
2366
+ const script = `${configurationProcessor.script}\nreturn transform;`;
2367
+ const sourceMap = `\n//# sourceURL=${configurationProcessor.apiName}.js`;
2368
+ functionToExecute = new Function(script + sourceMap)();
2369
+ this.executedFunctions[configurationProcessor.apiName] = functionToExecute;
2370
+ }
2371
+ return functionToExecute({
2372
+ request,
2373
+ inputData,
2374
+ flowStore: this.flowStateService.getFlowStore(),
2375
+ configurationStore: this.configurationStore,
2376
+ });
1597
2377
  }
1598
2378
  }
1599
- RuntimeSettingsService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.8", ngImport: i0, type: RuntimeSettingsService, deps: [{ token: i1.ConfigurationSettingsApiService }], target: i0.ɵɵFactoryTarget.Injectable });
1600
- RuntimeSettingsService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.8", ngImport: i0, type: RuntimeSettingsService, providedIn: 'root' });
1601
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.8", ngImport: i0, type: RuntimeSettingsService, decorators: [{
1602
- type: Injectable,
1603
- args: [{ providedIn: 'root' }]
1604
- }], ctorParameters: function () { return [{ type: i1.ConfigurationSettingsApiService }]; } });
2379
+ ConfigurationStateService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: ConfigurationStateService, deps: [{ token: ConfigurationRuntimeService }, { token: ConfigurationService }, { token: QuoteDraftService }, { token: i6.ToastService }, { token: FlowStateService }, { token: FlowInfoService }, { token: FlowConfigurationService }, { token: i1.FlowStateApiService }, { token: i1.QuoteApiService }], target: i0.ɵɵFactoryTarget.Injectable });
2380
+ ConfigurationStateService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: ConfigurationStateService });
2381
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: ConfigurationStateService, decorators: [{
2382
+ type: Injectable
2383
+ }], ctorParameters: function () { return [{ type: ConfigurationRuntimeService }, { type: ConfigurationService }, { type: QuoteDraftService }, { type: i6.ToastService }, { type: FlowStateService }, { type: FlowInfoService }, { type: FlowConfigurationService }, { type: i1.FlowStateApiService }, { type: i1.QuoteApiService }]; } });
2384
+
2385
+ class ConfigurationModule {
2386
+ }
2387
+ ConfigurationModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: ConfigurationModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
2388
+ ConfigurationModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "15.2.9", ngImport: i0, type: ConfigurationModule, imports: [ConfirmationDialogModule, ApiModule] });
2389
+ ConfigurationModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: ConfigurationModule, providers: [ConfigurationRuntimeService, RuntimeContextService, ConfigurationService, ConfigurationStateService], imports: [ConfirmationDialogModule, ApiModule] });
2390
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: ConfigurationModule, decorators: [{
2391
+ type: NgModule,
2392
+ args: [{
2393
+ imports: [ConfirmationDialogModule, ApiModule],
2394
+ providers: [ConfigurationRuntimeService, RuntimeContextService, ConfigurationService, ConfigurationStateService],
2395
+ }]
2396
+ }] });
1605
2397
 
1606
2398
  const DEFAULT_FORMATTING_SETTINGS = {
1607
2399
  currencySymbol: DEFAULT_CURRENCY_SYMBOL,
@@ -1609,31 +2401,38 @@ const DEFAULT_FORMATTING_SETTINGS = {
1609
2401
  dateFormats: getSupportedDateFormats(DEFAULT_DATE_FORMAT),
1610
2402
  decimalSeparator: DEFAULT_DECIMAL_SEPARATOR,
1611
2403
  thousandsSeparator: DEFAULT_THOUSANDS_SEPARATOR,
2404
+ actionCodeLabels: DEFAULT_ACTION_CODE_LABELS,
1612
2405
  };
1613
2406
  class SdkCoreModule {
1614
2407
  }
1615
- SdkCoreModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.8", ngImport: i0, type: SdkCoreModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
1616
- SdkCoreModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "15.2.8", ngImport: i0, type: SdkCoreModule, imports: [ConfigurationModule, FlowConfigurationModule] });
1617
- SdkCoreModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "15.2.8", ngImport: i0, type: SdkCoreModule, providers: [
2408
+ SdkCoreModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: SdkCoreModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
2409
+ SdkCoreModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "15.2.9", ngImport: i0, type: SdkCoreModule, imports: [ConfigurationModule, FlowConfigurationModule] });
2410
+ SdkCoreModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: SdkCoreModule, providers: [
1618
2411
  ContextService,
2412
+ FlowInfoService,
1619
2413
  QuoteDraftService,
1620
2414
  ProductImagesService,
1621
- MetricsCalculationService,
2415
+ IntegrationState,
2416
+ FlowStateService,
2417
+ FlowStateConfigurationService,
1622
2418
  RuntimeSettingsService,
1623
2419
  {
1624
2420
  provide: FORMATTING_SETTINGS_TOKEN,
1625
2421
  useExisting: RuntimeSettingsService,
1626
2422
  },
1627
2423
  ], imports: [ConfigurationModule, FlowConfigurationModule] });
1628
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.8", ngImport: i0, type: SdkCoreModule, decorators: [{
2424
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: SdkCoreModule, decorators: [{
1629
2425
  type: NgModule,
1630
2426
  args: [{
1631
2427
  imports: [ConfigurationModule, FlowConfigurationModule],
1632
2428
  providers: [
1633
2429
  ContextService,
2430
+ FlowInfoService,
1634
2431
  QuoteDraftService,
1635
2432
  ProductImagesService,
1636
- MetricsCalculationService,
2433
+ IntegrationState,
2434
+ FlowStateService,
2435
+ FlowStateConfigurationService,
1637
2436
  RuntimeSettingsService,
1638
2437
  {
1639
2438
  provide: FORMATTING_SETTINGS_TOKEN,
@@ -1666,9 +2465,9 @@ class CalendarDirective {
1666
2465
  }
1667
2466
  }
1668
2467
  }
1669
- CalendarDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.8", ngImport: i0, type: CalendarDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive });
1670
- CalendarDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "15.2.8", type: CalendarDirective, selector: "[vlCalendar]", inputs: { vlCalendar: "vlCalendar" }, ngImport: i0 });
1671
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.8", ngImport: i0, type: CalendarDirective, decorators: [{
2468
+ CalendarDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: CalendarDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive });
2469
+ CalendarDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "15.2.9", type: CalendarDirective, selector: "[vlCalendar]", inputs: { vlCalendar: "vlCalendar" }, ngImport: i0 });
2470
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: CalendarDirective, decorators: [{
1672
2471
  type: Directive,
1673
2472
  args: [{
1674
2473
  selector: '[vlCalendar]',
@@ -1679,10 +2478,10 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.8", ngImpor
1679
2478
 
1680
2479
  class SdkDirectivesModule {
1681
2480
  }
1682
- SdkDirectivesModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.8", ngImport: i0, type: SdkDirectivesModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
1683
- SdkDirectivesModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "15.2.8", ngImport: i0, type: SdkDirectivesModule, declarations: [CalendarDirective], exports: [CalendarDirective] });
1684
- SdkDirectivesModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "15.2.8", ngImport: i0, type: SdkDirectivesModule });
1685
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.8", ngImport: i0, type: SdkDirectivesModule, decorators: [{
2481
+ SdkDirectivesModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: SdkDirectivesModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
2482
+ SdkDirectivesModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "15.2.9", ngImport: i0, type: SdkDirectivesModule, declarations: [CalendarDirective], exports: [CalendarDirective] });
2483
+ SdkDirectivesModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: SdkDirectivesModule });
2484
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: SdkDirectivesModule, decorators: [{
1686
2485
  type: NgModule,
1687
2486
  args: [{
1688
2487
  declarations: [CalendarDirective],
@@ -1701,21 +2500,27 @@ class DatePipe {
1701
2500
  this.destroy$.next();
1702
2501
  this.destroy$.complete();
1703
2502
  }
1704
- transform(date) {
2503
+ transform(date, type = 'date') {
1705
2504
  if (!date) {
1706
2505
  return '';
1707
2506
  }
2507
+ const dateFormat = this.formattingSettings?.dateFormats.datePipeFormat || DEFAULT_DATE_FORMAT;
2508
+ const formatMap = {
2509
+ date: dateFormat,
2510
+ time: DEFAULT_TIME_FORMAT,
2511
+ datetime: `${dateFormat} ${DEFAULT_TIME_FORMAT}`,
2512
+ };
1708
2513
  try {
1709
- return formatDate(date, this.formattingSettings?.dateFormats.datePipeFormat || DEFAULT_DATE_FORMAT, this.locale, this.defaultOptions?.timezone);
2514
+ return formatDate(date, formatMap[type], this.locale, this.defaultOptions?.timezone);
1710
2515
  }
1711
2516
  catch (error) {
1712
2517
  return new Date(date).toString();
1713
2518
  }
1714
2519
  }
1715
2520
  }
1716
- DatePipe.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.8", ngImport: i0, type: DatePipe, deps: [], target: i0.ɵɵFactoryTarget.Pipe });
1717
- DatePipe.ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "15.2.8", ngImport: i0, type: DatePipe, name: "vlDate" });
1718
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.8", ngImport: i0, type: DatePipe, decorators: [{
2521
+ DatePipe.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: DatePipe, deps: [], target: i0.ɵɵFactoryTarget.Pipe });
2522
+ DatePipe.ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "15.2.9", ngImport: i0, type: DatePipe, name: "vlDate" });
2523
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: DatePipe, decorators: [{
1719
2524
  type: Pipe,
1720
2525
  args: [{
1721
2526
  name: 'vlDate',
@@ -1735,9 +2540,9 @@ class NumberPipe {
1735
2540
  return formatNumber(price, this.formattingSettings?.thousandsSeparator, this.formattingSettings?.decimalSeparator, this.formattingSettings?.decimalsCount);
1736
2541
  }
1737
2542
  }
1738
- NumberPipe.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.8", ngImport: i0, type: NumberPipe, deps: [], target: i0.ɵɵFactoryTarget.Pipe });
1739
- NumberPipe.ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "15.2.8", ngImport: i0, type: NumberPipe, name: "vlNumber" });
1740
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.8", ngImport: i0, type: NumberPipe, decorators: [{
2543
+ NumberPipe.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: NumberPipe, deps: [], target: i0.ɵɵFactoryTarget.Pipe });
2544
+ NumberPipe.ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "15.2.9", ngImport: i0, type: NumberPipe, name: "vlNumber" });
2545
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: NumberPipe, decorators: [{
1741
2546
  type: Pipe,
1742
2547
  args: [{
1743
2548
  name: 'vlNumber',
@@ -1760,25 +2565,42 @@ class PricePipe {
1760
2565
  return `${this.formattingSettings?.currencySymbol || DEFAULT_CURRENCY_SYMBOL}${formatNumber(price, this.formattingSettings?.thousandsSeparator, this.formattingSettings?.decimalSeparator, this.formattingSettings?.decimalsCount)}`;
1761
2566
  }
1762
2567
  }
1763
- PricePipe.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.8", ngImport: i0, type: PricePipe, deps: [], target: i0.ɵɵFactoryTarget.Pipe });
1764
- PricePipe.ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "15.2.8", ngImport: i0, type: PricePipe, name: "vlPrice" });
1765
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.8", ngImport: i0, type: PricePipe, decorators: [{
2568
+ PricePipe.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: PricePipe, deps: [], target: i0.ɵɵFactoryTarget.Pipe });
2569
+ PricePipe.ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "15.2.9", ngImport: i0, type: PricePipe, name: "vlPrice" });
2570
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: PricePipe, decorators: [{
1766
2571
  type: Pipe,
1767
2572
  args: [{
1768
2573
  name: 'vlPrice',
1769
2574
  }]
1770
2575
  }] });
1771
2576
 
2577
+ class ActionCodePipe {
2578
+ constructor() {
2579
+ this.formattingSettings = inject(FORMATTING_SETTINGS_TOKEN, { optional: true })?.getFormattingSettings();
2580
+ }
2581
+ transform(actionCode) {
2582
+ return this.formattingSettings?.actionCodeLabels[actionCode] ?? actionCode;
2583
+ }
2584
+ }
2585
+ ActionCodePipe.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: ActionCodePipe, deps: [], target: i0.ɵɵFactoryTarget.Pipe });
2586
+ ActionCodePipe.ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "15.2.9", ngImport: i0, type: ActionCodePipe, name: "vlActionCode" });
2587
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: ActionCodePipe, decorators: [{
2588
+ type: Pipe,
2589
+ args: [{
2590
+ name: 'vlActionCode',
2591
+ }]
2592
+ }] });
2593
+
1772
2594
  class SdkPipesModule {
1773
2595
  }
1774
- SdkPipesModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.8", ngImport: i0, type: SdkPipesModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
1775
- SdkPipesModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "15.2.8", ngImport: i0, type: SdkPipesModule, declarations: [NumberPipe, PricePipe, DatePipe], exports: [NumberPipe, PricePipe, DatePipe] });
1776
- SdkPipesModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "15.2.8", ngImport: i0, type: SdkPipesModule });
1777
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.8", ngImport: i0, type: SdkPipesModule, decorators: [{
2596
+ SdkPipesModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: SdkPipesModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
2597
+ SdkPipesModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "15.2.9", ngImport: i0, type: SdkPipesModule, declarations: [NumberPipe, PricePipe, DatePipe, ActionCodePipe], exports: [NumberPipe, PricePipe, DatePipe, ActionCodePipe] });
2598
+ SdkPipesModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: SdkPipesModule });
2599
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: SdkPipesModule, decorators: [{
1778
2600
  type: NgModule,
1779
2601
  args: [{
1780
- declarations: [NumberPipe, PricePipe, DatePipe],
1781
- exports: [NumberPipe, PricePipe, DatePipe],
2602
+ declarations: [NumberPipe, PricePipe, DatePipe, ActionCodePipe],
2603
+ exports: [NumberPipe, PricePipe, DatePipe, ActionCodePipe],
1782
2604
  }]
1783
2605
  }] });
1784
2606
 
@@ -1786,5 +2608,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.8", ngImpor
1786
2608
  * Generated bundle index. Do not edit.
1787
2609
  */
1788
2610
 
1789
- 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 };
2611
+ export { ActionCodePipe, CalendarDirective, ConfigurationRuntimeService, ConfigurationService, ConfigurationStateService, ContextService, 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, SdkCoreModule, SdkDirectivesModule, SdkPipesModule, UI_DEFINITION_VERSION, extractMetadata, filterOutTechnicalAttributes, findLineItem, findLineItemWithComparator, generateConfigurationLineItem, generateLineItem, generateModifiedAssetsMap, getAttributeValue, getAttributes, getDefaultLineItem, getGuidedSellingConfigurationRequest, getOriginParent, getRecommendedPrices, insertLineItem, isLineItemModified, isTechnicalAttribute, lineItem_utils as lineItemUtils, mapAttributes, multiplyLineItems, patchAttributes, recalculateCardinalityVariables, removeLineItem, replaceLineItem, upsertAttributes };
1790
2612
  //# sourceMappingURL=veloceapps-sdk-core.mjs.map