@veloceapps/sdk 8.0.0-16 → 8.0.0-160

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