@veloceapps/sdk 8.0.0-2 → 8.0.0-200

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