@veloceapps/sdk 8.0.0-14 → 8.0.0-140

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