@veloceapps/sdk 8.0.0-18 → 8.0.0-180

Sign up to get free protection for your applications and to get access to all the features.
Files changed (312) 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/services/resources.service.d.ts +2 -0
  10. package/cms/types/index.d.ts +0 -1
  11. package/cms/utils/element-metadata-worker.d.ts +11 -0
  12. package/cms/utils/elements-resolver.d.ts +0 -2
  13. package/cms/utils/index.d.ts +3 -0
  14. package/cms/utils/transpilation-worker.d.ts +13 -0
  15. package/cms/vendor-map.d.ts +26 -15
  16. package/core/README.md +20 -0
  17. package/core/modules/configuration/configuration.module.d.ts +2 -1
  18. package/core/modules/configuration/helpers.d.ts +4 -3
  19. package/core/modules/configuration/index.d.ts +1 -1
  20. package/core/modules/configuration/services/configuration-runtime.service.d.ts +1 -1
  21. package/core/modules/configuration/services/configuration-state.service.d.ts +51 -0
  22. package/core/modules/configuration/services/configuration.service.d.ts +10 -5
  23. package/core/modules/configuration/types/configuration.types.d.ts +4 -0
  24. package/core/modules/flow-configuration/flow-configuration.module.d.ts +2 -1
  25. package/core/modules/flow-configuration/services/flow-configuration.service.d.ts +5 -0
  26. package/core/pipes/action-code.pipe.d.ts +8 -0
  27. package/core/pipes/date.pipe.d.ts +2 -1
  28. package/core/pipes/index.d.ts +1 -0
  29. package/core/pipes/pipes.module.d.ts +2 -1
  30. package/core/services/context.service.d.ts +4 -0
  31. package/core/services/flow-info.service.d.ts +29 -0
  32. package/core/services/flow-state-configuration.service.d.ts +19 -0
  33. package/core/services/flow-state.service.d.ts +79 -0
  34. package/core/services/index.d.ts +4 -1
  35. package/core/services/quote-draft.service.d.ts +8 -1
  36. package/core/services/runtime-settings.service.d.ts +4 -1
  37. package/core/types/flow-customization.types.d.ts +22 -0
  38. package/core/types/flow-state.types.d.ts +6 -0
  39. package/core/types/formatting-settings.types.d.ts +2 -0
  40. package/core/types/index.d.ts +3 -0
  41. package/{cms → core}/types/integration.types.d.ts +1 -0
  42. package/core/types/pipe.types.d.ts +1 -0
  43. package/core/utils/line-item.utils.d.ts +0 -1
  44. package/esm2020/cms/cms.actions.mjs +15 -1
  45. package/esm2020/cms/components/element-renderer/element-renderer.component.mjs +3 -3
  46. package/esm2020/cms/components/element-tools-panel/element-tools-panel.component.mjs +3 -3
  47. package/esm2020/cms/components/preview/preview.component.mjs +10 -10
  48. package/esm2020/cms/components/preview/preview.module.mjs +2 -2
  49. package/esm2020/cms/components/preview/preview.types.mjs +1 -1
  50. package/esm2020/cms/index.mjs +2 -1
  51. package/esm2020/cms/launcher.module.mjs +4 -4
  52. package/esm2020/cms/modules/migrations/migrations.mjs +2 -2
  53. package/esm2020/cms/modules/migrations/services/migrations.service.mjs +6 -2
  54. package/esm2020/cms/modules/runtime/services/compilation.service.mjs +11 -7
  55. package/esm2020/cms/modules/runtime/services/runtime.service.mjs +4 -4
  56. package/esm2020/cms/plugins/configuration.plugin.mjs +8 -4
  57. package/esm2020/cms/services/index.mjs +1 -2
  58. package/esm2020/cms/services/io-provider.service.mjs +10 -9
  59. package/esm2020/cms/services/resources.service.mjs +10 -6
  60. package/esm2020/cms/services/templates.service.mjs +10 -9
  61. package/esm2020/cms/types/index.mjs +1 -2
  62. package/esm2020/cms/utils/element-metadata-worker.mjs +31 -0
  63. package/esm2020/cms/utils/elements-resolver.mjs +14 -28
  64. package/esm2020/cms/utils/index.mjs +4 -1
  65. package/esm2020/cms/utils/path.utils.mjs +3 -3
  66. package/esm2020/cms/utils/script.utils.mjs +19 -15
  67. package/esm2020/cms/utils/transpilation-worker.mjs +52 -0
  68. package/esm2020/cms/vendor-map.mjs +18 -6
  69. package/esm2020/core/core.module.mjs +12 -5
  70. package/esm2020/core/modules/configuration/configuration.module.mjs +7 -23
  71. package/esm2020/core/modules/configuration/helpers.mjs +28 -3
  72. package/esm2020/core/modules/configuration/index.mjs +2 -2
  73. package/esm2020/core/modules/configuration/services/configuration-runtime.service.mjs +8 -11
  74. package/esm2020/core/modules/configuration/services/configuration-state.service.mjs +304 -0
  75. package/esm2020/core/modules/configuration/services/configuration.service.mjs +68 -45
  76. package/esm2020/core/modules/configuration/services/runtime-context.service.mjs +6 -6
  77. package/esm2020/core/modules/configuration/types/configuration.types.mjs +1 -1
  78. package/esm2020/core/modules/flow-configuration/flow-configuration.module.mjs +6 -6
  79. package/esm2020/core/modules/flow-configuration/services/flow-configuration.service.mjs +10 -7
  80. package/esm2020/core/pipes/action-code.pipe.mjs +20 -0
  81. package/esm2020/core/pipes/date.pipe.mjs +10 -4
  82. package/esm2020/core/pipes/index.mjs +2 -1
  83. package/esm2020/core/pipes/pipes.module.mjs +5 -4
  84. package/esm2020/core/services/context.service.mjs +32 -5
  85. package/esm2020/core/services/flow-info.service.mjs +99 -0
  86. package/esm2020/core/services/flow-state-configuration.service.mjs +53 -0
  87. package/esm2020/core/services/flow-state.service.mjs +506 -0
  88. package/esm2020/core/services/index.mjs +5 -2
  89. package/esm2020/core/services/integration.state.mjs +36 -0
  90. package/esm2020/core/services/product-images.service.mjs +4 -5
  91. package/esm2020/core/services/quote-draft.service.mjs +32 -8
  92. package/esm2020/core/services/runtime-settings.service.mjs +19 -5
  93. package/esm2020/core/types/flow-customization.types.mjs +3 -0
  94. package/esm2020/core/types/flow-state.types.mjs +2 -0
  95. package/esm2020/core/types/formatting-settings.types.mjs +1 -1
  96. package/esm2020/core/types/index.mjs +4 -1
  97. package/esm2020/core/types/integration.types.mjs +2 -0
  98. package/esm2020/core/types/pipe.types.mjs +2 -0
  99. package/esm2020/core/utils/line-item.utils.mjs +30 -15
  100. package/esm2020/src/components/doc-gen/doc-gen.component.mjs +49 -49
  101. package/esm2020/src/components/flow-header/flow-header.component.mjs +108 -0
  102. package/esm2020/src/components/flow-header/flow-header.module.mjs +19 -0
  103. package/esm2020/src/components/flow-header/index.mjs +2 -0
  104. package/esm2020/src/components/guided-selling/guided-selling.component.mjs +37 -43
  105. package/esm2020/src/configure-primeng.mjs +33 -0
  106. package/esm2020/src/flow-routing.module.mjs +62 -71
  107. package/esm2020/src/flow.component.mjs +23 -32
  108. package/esm2020/src/flow.module.mjs +7 -5
  109. package/esm2020/src/guards/context.guard.mjs +6 -11
  110. package/esm2020/src/guards/flow.guard.mjs +37 -0
  111. package/esm2020/src/guards/product-unload.guard.mjs +4 -1
  112. package/esm2020/src/guards/root.guard.mjs +14 -10
  113. package/esm2020/src/pages/assets/assets.component.mjs +33 -37
  114. package/esm2020/src/pages/catalog/catalog.component.mjs +33 -37
  115. package/esm2020/src/pages/debug/debug.component.mjs +10 -14
  116. package/esm2020/src/pages/product/product.component.mjs +22 -12
  117. package/esm2020/src/pages/record-not-found/record-not-found.component.mjs +6 -3
  118. package/esm2020/src/pages/remote/remote.component.mjs +19 -19
  119. package/esm2020/src/pages/shopping-cart/shopping-cart.component.mjs +34 -38
  120. package/esm2020/src/resolvers/flow.resolver.mjs +37 -49
  121. package/esm2020/src/resolvers/quote.resolver.mjs +55 -63
  122. package/esm2020/src/services/doc-gen.service.mjs +4 -3
  123. package/esm2020/src/services/flow-dialog.service.mjs +21 -6
  124. package/esm2020/src/services/flow-router.service.mjs +57 -16
  125. package/esm2020/src/services/flow.service.mjs +72 -23
  126. package/esm2020/src/services/guided-selling.service.mjs +5 -4
  127. package/esm2020/src/services/index.mjs +3 -1
  128. package/esm2020/src/types/index.mjs +1 -2
  129. package/esm2020/src/utils/flow.utils.mjs +6 -2
  130. package/fesm2015/veloceapps-sdk-cms.mjs +287 -195
  131. package/fesm2015/veloceapps-sdk-cms.mjs.map +1 -1
  132. package/fesm2015/veloceapps-sdk-core.mjs +1595 -728
  133. package/fesm2015/veloceapps-sdk-core.mjs.map +1 -1
  134. package/fesm2015/veloceapps-sdk.mjs +740 -1451
  135. package/fesm2015/veloceapps-sdk.mjs.map +1 -1
  136. package/fesm2020/veloceapps-sdk-cms.mjs +291 -209
  137. package/fesm2020/veloceapps-sdk-cms.mjs.map +1 -1
  138. package/fesm2020/veloceapps-sdk-core.mjs +1741 -910
  139. package/fesm2020/veloceapps-sdk-core.mjs.map +1 -1
  140. package/fesm2020/veloceapps-sdk.mjs +802 -1511
  141. package/fesm2020/veloceapps-sdk.mjs.map +1 -1
  142. package/package.json +5 -12
  143. package/src/components/doc-gen/doc-gen.component.d.ts +8 -9
  144. package/src/components/flow-header/flow-header.component.d.ts +25 -0
  145. package/src/components/flow-header/flow-header.module.d.ts +9 -0
  146. package/src/components/flow-header/index.d.ts +1 -0
  147. package/src/components/guided-selling/guided-selling.component.d.ts +6 -8
  148. package/src/configure-primeng.d.ts +1 -0
  149. package/src/flow-routing.module.d.ts +6 -7
  150. package/src/flow.component.d.ts +7 -11
  151. package/src/flow.module.d.ts +2 -2
  152. package/src/guards/context.guard.d.ts +4 -5
  153. package/src/guards/flow.guard.d.ts +2 -0
  154. package/src/guards/product-unload.guard.d.ts +2 -2
  155. package/src/guards/root.guard.d.ts +0 -1
  156. package/src/pages/assets/assets.component.d.ts +5 -7
  157. package/src/pages/catalog/catalog.component.d.ts +5 -7
  158. package/src/pages/debug/debug.component.d.ts +5 -8
  159. package/src/pages/product/product.component.d.ts +7 -6
  160. package/src/pages/record-not-found/record-not-found.component.d.ts +2 -0
  161. package/src/pages/remote/remote.component.d.ts +2 -3
  162. package/src/pages/shopping-cart/shopping-cart.component.d.ts +5 -7
  163. package/src/resolvers/flow.resolver.d.ts +6 -7
  164. package/src/resolvers/quote.resolver.d.ts +7 -12
  165. package/src/services/doc-gen.service.d.ts +1 -1
  166. package/src/services/flow-dialog.service.d.ts +5 -2
  167. package/src/services/flow-router.service.d.ts +7 -3
  168. package/src/services/flow.service.d.ts +10 -4
  169. package/src/services/guided-selling.service.d.ts +1 -1
  170. package/src/services/index.d.ts +2 -0
  171. package/src/types/index.d.ts +0 -1
  172. package/core/modules/configuration/services/configuration.state.d.ts +0 -30
  173. package/core/services/metric-calculation/metric-calculation.service.d.ts +0 -25
  174. package/core/services/metric-calculation/metric-calculation.types.d.ts +0 -1
  175. package/core/services/metric-calculation/metric-calculation.utils.d.ts +0 -5
  176. package/esm2020/cms/services/integration.state.mjs +0 -37
  177. package/esm2020/cms/types/integration.types.mjs +0 -2
  178. package/esm2020/core/modules/configuration/services/configuration.state.mjs +0 -142
  179. package/esm2020/core/services/metric-calculation/metric-calculation.service.mjs +0 -85
  180. package/esm2020/core/services/metric-calculation/metric-calculation.types.mjs +0 -2
  181. package/esm2020/core/services/metric-calculation/metric-calculation.utils.mjs +0 -42
  182. package/esm2020/runtime/components/component-preview/component-preview.component.mjs +0 -125
  183. package/esm2020/runtime/components/index.mjs +0 -5
  184. package/esm2020/runtime/components/section-renderer/section-renderer.component.mjs +0 -67
  185. package/esm2020/runtime/components/ui-runtime/runtime.component.mjs +0 -440
  186. package/esm2020/runtime/components/ui-runtime-preview/runtime-preview.component.mjs +0 -108
  187. package/esm2020/runtime/execution/components/children-placeholder/children-placeholder.component.mjs +0 -60
  188. package/esm2020/runtime/execution/components/context-provider/context-provider.component.mjs +0 -39
  189. package/esm2020/runtime/execution/components/execution-section-renderer/execution-section-renderer.component.mjs +0 -67
  190. package/esm2020/runtime/execution/components/federated/federated.component.mjs +0 -74
  191. package/esm2020/runtime/execution/components/velo-attribute/velo-attribute.component.mjs +0 -60
  192. package/esm2020/runtime/execution/components/velo-multiselect/velo-multiselect.component.mjs +0 -130
  193. package/esm2020/runtime/execution/components/velo-port-checkbox/velo-port-checkbox.component.mjs +0 -72
  194. package/esm2020/runtime/execution/components/velo-port-dropdown/velo-port-dropdown.component.mjs +0 -97
  195. package/esm2020/runtime/execution/components/velo-port-radio/velo-port-radio.component.mjs +0 -142
  196. package/esm2020/runtime/execution/components/velo-type/velo-type.component.mjs +0 -119
  197. package/esm2020/runtime/execution/directives/section-script.directive.mjs +0 -247
  198. package/esm2020/runtime/execution/directives/sf-query.directive.mjs +0 -35
  199. package/esm2020/runtime/execution/directives/velo-attribute.directive.mjs +0 -88
  200. package/esm2020/runtime/execution/directives/velo-port.directive.mjs +0 -376
  201. package/esm2020/runtime/execution/directives/vl-approval.directive.mjs +0 -23
  202. package/esm2020/runtime/execution/directives/vl-document-attachments.directive.mjs +0 -36
  203. package/esm2020/runtime/execution/directives/vl-document-templates.directive.mjs +0 -60
  204. package/esm2020/runtime/execution/directives/vl-quote.directive.mjs +0 -42
  205. package/esm2020/runtime/execution/directives/vl-ramp.directive.mjs +0 -55
  206. package/esm2020/runtime/execution/runtime-execution.module.mjs +0 -133
  207. package/esm2020/runtime/execution/utils/federated.util.mjs +0 -32
  208. package/esm2020/runtime/index.mjs +0 -5
  209. package/esm2020/runtime/runtime.module.mjs +0 -74
  210. package/esm2020/runtime/services/cart.service.mjs +0 -29
  211. package/esm2020/runtime/services/collapsible-state.service.mjs +0 -34
  212. package/esm2020/runtime/services/configuration.service.mjs +0 -119
  213. package/esm2020/runtime/services/current-state.service.mjs +0 -17
  214. package/esm2020/runtime/services/form-scope.service.mjs +0 -30
  215. package/esm2020/runtime/services/index.mjs +0 -4
  216. package/esm2020/runtime/services/product-model-cache.service.mjs +0 -31
  217. package/esm2020/runtime/services/runtime-context.service.mjs +0 -60
  218. package/esm2020/runtime/services/runtime-form.service.mjs +0 -219
  219. package/esm2020/runtime/services/runtime.service.mjs +0 -115
  220. package/esm2020/runtime/services/section-helper.service.mjs +0 -27
  221. package/esm2020/runtime/services/section-scope.service.mjs +0 -36
  222. package/esm2020/runtime/services/section-store.service.mjs +0 -22
  223. package/esm2020/runtime/services/section.service.mjs +0 -117
  224. package/esm2020/runtime/types/bound-data.types.mjs +0 -7
  225. package/esm2020/runtime/types/index.mjs +0 -3
  226. package/esm2020/runtime/types/quote-states.types.mjs +0 -2
  227. package/esm2020/runtime/types/runtime.types.mjs +0 -2
  228. package/esm2020/runtime/types/script-registry.types.mjs +0 -51
  229. package/esm2020/runtime/utils/line-item.util.mjs +0 -270
  230. package/esm2020/runtime/utils/section.utils.mjs +0 -26
  231. package/esm2020/runtime/utils/sections-binder.helper.mjs +0 -105
  232. package/esm2020/runtime/veloceapps-sdk-runtime.mjs +0 -5
  233. package/esm2020/src/components/header/cart-overlay/cart-preview.component.mjs +0 -119
  234. package/esm2020/src/components/header/cart-overlay/cart-preview.module.mjs +0 -47
  235. package/esm2020/src/components/header/header.component.mjs +0 -355
  236. package/esm2020/src/components/header/header.module.mjs +0 -52
  237. package/esm2020/src/components/header/header.types.mjs +0 -2
  238. package/esm2020/src/components/header/metrics/index.mjs +0 -2
  239. package/esm2020/src/components/header/metrics/metrics.component.mjs +0 -255
  240. package/esm2020/src/components/header/metrics/metrics.definitions.mjs +0 -2
  241. package/esm2020/src/components/header/metrics/metrics.module.mjs +0 -69
  242. package/esm2020/src/pages/legacy-product/legacy-product.component.mjs +0 -137
  243. package/esm2020/src/pages/legacy-product/legacy-product.module.mjs +0 -19
  244. package/esm2020/src/types/flow-customization.types.mjs +0 -3
  245. package/fesm2015/veloceapps-sdk-runtime.mjs +0 -3770
  246. package/fesm2015/veloceapps-sdk-runtime.mjs.map +0 -1
  247. package/fesm2020/veloceapps-sdk-runtime.mjs +0 -3767
  248. package/fesm2020/veloceapps-sdk-runtime.mjs.map +0 -1
  249. package/runtime/README.md +0 -5
  250. package/runtime/components/component-preview/component-preview.component.d.ts +0 -27
  251. package/runtime/components/index.d.ts +0 -4
  252. package/runtime/components/section-renderer/section-renderer.component.d.ts +0 -25
  253. package/runtime/components/ui-runtime/runtime.component.d.ts +0 -53
  254. package/runtime/components/ui-runtime-preview/runtime-preview.component.d.ts +0 -27
  255. package/runtime/execution/components/children-placeholder/children-placeholder.component.d.ts +0 -30
  256. package/runtime/execution/components/context-provider/context-provider.component.d.ts +0 -14
  257. package/runtime/execution/components/execution-section-renderer/execution-section-renderer.component.d.ts +0 -25
  258. package/runtime/execution/components/federated/federated.component.d.ts +0 -36
  259. package/runtime/execution/components/velo-attribute/velo-attribute.component.d.ts +0 -19
  260. package/runtime/execution/components/velo-multiselect/velo-multiselect.component.d.ts +0 -35
  261. package/runtime/execution/components/velo-port-checkbox/velo-port-checkbox.component.d.ts +0 -22
  262. package/runtime/execution/components/velo-port-dropdown/velo-port-dropdown.component.d.ts +0 -22
  263. package/runtime/execution/components/velo-port-radio/velo-port-radio.component.d.ts +0 -28
  264. package/runtime/execution/components/velo-type/velo-type.component.d.ts +0 -31
  265. package/runtime/execution/directives/section-script.directive.d.ts +0 -59
  266. package/runtime/execution/directives/sf-query.directive.d.ts +0 -15
  267. package/runtime/execution/directives/velo-attribute.directive.d.ts +0 -26
  268. package/runtime/execution/directives/velo-port.directive.d.ts +0 -74
  269. package/runtime/execution/directives/vl-approval.directive.d.ts +0 -10
  270. package/runtime/execution/directives/vl-document-attachments.directive.d.ts +0 -15
  271. package/runtime/execution/directives/vl-document-templates.directive.d.ts +0 -33
  272. package/runtime/execution/directives/vl-quote.directive.d.ts +0 -14
  273. package/runtime/execution/directives/vl-ramp.directive.d.ts +0 -15
  274. package/runtime/execution/runtime-execution.module.d.ts +0 -25
  275. package/runtime/execution/utils/federated.util.d.ts +0 -6
  276. package/runtime/index.d.ts +0 -4
  277. package/runtime/runtime.module.d.ts +0 -16
  278. package/runtime/services/cart.service.d.ts +0 -15
  279. package/runtime/services/collapsible-state.service.d.ts +0 -15
  280. package/runtime/services/configuration.service.d.ts +0 -20
  281. package/runtime/services/current-state.service.d.ts +0 -8
  282. package/runtime/services/form-scope.service.d.ts +0 -20
  283. package/runtime/services/index.d.ts +0 -3
  284. package/runtime/services/product-model-cache.service.d.ts +0 -14
  285. package/runtime/services/runtime-context.service.d.ts +0 -16
  286. package/runtime/services/runtime-form.service.d.ts +0 -24
  287. package/runtime/services/runtime.service.d.ts +0 -44
  288. package/runtime/services/section-helper.service.d.ts +0 -8
  289. package/runtime/services/section-scope.service.d.ts +0 -14
  290. package/runtime/services/section-store.service.d.ts +0 -11
  291. package/runtime/services/section.service.d.ts +0 -30
  292. package/runtime/types/bound-data.types.d.ts +0 -13
  293. package/runtime/types/index.d.ts +0 -2
  294. package/runtime/types/quote-states.types.d.ts +0 -6
  295. package/runtime/types/runtime.types.d.ts +0 -19
  296. package/runtime/types/script-registry.types.d.ts +0 -13
  297. package/runtime/utils/line-item.util.d.ts +0 -34
  298. package/runtime/utils/section.utils.d.ts +0 -2
  299. package/runtime/utils/sections-binder.helper.d.ts +0 -16
  300. package/src/components/header/cart-overlay/cart-preview.component.d.ts +0 -36
  301. package/src/components/header/cart-overlay/cart-preview.module.d.ts +0 -14
  302. package/src/components/header/header.component.d.ts +0 -70
  303. package/src/components/header/header.module.d.ts +0 -16
  304. package/src/components/header/header.types.d.ts +0 -20
  305. package/src/components/header/metrics/index.d.ts +0 -1
  306. package/src/components/header/metrics/metrics.component.d.ts +0 -67
  307. package/src/components/header/metrics/metrics.definitions.d.ts +0 -1
  308. package/src/components/header/metrics/metrics.module.d.ts +0 -18
  309. package/src/pages/legacy-product/legacy-product.component.d.ts +0 -37
  310. package/src/pages/legacy-product/legacy-product.module.d.ts +0 -9
  311. package/src/types/flow-customization.types.d.ts +0 -12
  312. /package/{cms → core}/services/integration.state.d.ts +0 -0
@@ -0,0 +1,304 @@
1
+ import { Injectable } from '@angular/core';
2
+ import { FlowStateApiService, QuoteApiService } from '@veloceapps/api';
3
+ import { ToastService, ToastType } from '@veloceapps/components';
4
+ import { EntityUtil, UUID, } from '@veloceapps/core';
5
+ import { assign, cloneDeep } from 'lodash';
6
+ import { BehaviorSubject, distinctUntilChanged, filter, finalize, map, of, Subject, switchMap, takeUntil, tap, } from 'rxjs';
7
+ import { FlowInfoService, FlowStateService, QuoteDraftService } from '../../../services';
8
+ import { FlowConfigurationService } from '../../flow-configuration';
9
+ import { ConfigurationRuntimeService } from './configuration-runtime.service';
10
+ import { ConfigurationService } from './configuration.service';
11
+ import * as i0 from "@angular/core";
12
+ import * as i1 from "./configuration-runtime.service";
13
+ import * as i2 from "./configuration.service";
14
+ import * as i3 from "../../../services";
15
+ import * as i4 from "@veloceapps/components";
16
+ import * as i5 from "../../flow-configuration";
17
+ import * as i6 from "@veloceapps/api";
18
+ export class ConfigurationStateService {
19
+ constructor(configurationRuntimeService, configurationService, quoteDraftService, toastService, flowStateService, flowInfoService, flowConfigurationService, flowStateApiService, quoteApiService) {
20
+ this.configurationRuntimeService = configurationRuntimeService;
21
+ this.configurationService = configurationService;
22
+ this.quoteDraftService = quoteDraftService;
23
+ this.toastService = toastService;
24
+ this.flowStateService = flowStateService;
25
+ this.flowInfoService = flowInfoService;
26
+ this.flowConfigurationService = flowConfigurationService;
27
+ this.flowStateApiService = flowStateApiService;
28
+ this.quoteApiService = quoteApiService;
29
+ this.isInitialized$ = new BehaviorSubject(false);
30
+ this.canceledConfiguration$ = new Subject();
31
+ this.NOT_INITIALIZED = Symbol();
32
+ this.executedFunctions = {};
33
+ this.stateId = null;
34
+ this.ownerId = '';
35
+ this.subscriptions = {};
36
+ this.configurationStore = {};
37
+ }
38
+ init$() {
39
+ let request$;
40
+ if (this.flowStateService.stateId && this.isStatefulConfiguration) {
41
+ request$ = this.initStateful$();
42
+ }
43
+ else {
44
+ request$ = this.initStateless$();
45
+ }
46
+ return request$.pipe(finalize(() => {
47
+ this.isInitialized$.next(true);
48
+ this.canceledConfiguration$ = new Subject();
49
+ }));
50
+ }
51
+ cleanup() {
52
+ Object.values(this.subscriptions).forEach(({ data$ }) => data$.complete());
53
+ this.subscriptions = {};
54
+ if (this.stateId) {
55
+ this.cancelConfiguration();
56
+ }
57
+ this.configurationStore = {};
58
+ this.executedFunctions = {};
59
+ this.configurationService.reset();
60
+ }
61
+ execute$(req, forceSubscriptions) {
62
+ const fullRequest = cloneDeep(req);
63
+ if (fullRequest.actions?.length || forceSubscriptions) {
64
+ for (const subscription of Object.values(this.subscriptions)) {
65
+ fullRequest.selectors = assign(fullRequest.selectors, subscription.request.selectors);
66
+ }
67
+ }
68
+ let execution$;
69
+ if (this.isStatefulConfiguration) {
70
+ execution$ = this.executeStateful$(fullRequest);
71
+ }
72
+ else {
73
+ execution$ = this.executeStateless$(fullRequest);
74
+ }
75
+ return execution$.pipe(tap(result => this.handleSelectorsResponse(result.selectors)));
76
+ }
77
+ handleSelectorsResponse(selectors) {
78
+ Object.entries(selectors).forEach(([requestId, selectorResult]) => {
79
+ if (!selectorResult.success) {
80
+ this.toastService.add({ severity: ToastType.error, summary: selectorResult.errorMessage });
81
+ }
82
+ const subscription$ = this.subscriptions[requestId]?.data$;
83
+ if (subscription$) {
84
+ subscription$.next(selectorResult);
85
+ }
86
+ });
87
+ }
88
+ dispatch$(actionName, inputData = {}) {
89
+ return this.execute$({ actions: [{ apiName: actionName, inputData, ownerId: this.ownerId }] });
90
+ }
91
+ select$(selectorName, inputData = {}) {
92
+ const requestId = UUID.UUID();
93
+ return this.execute$({
94
+ selectors: {
95
+ [requestId]: {
96
+ apiName: selectorName,
97
+ inputData,
98
+ ownerId: this.ownerId,
99
+ },
100
+ },
101
+ }).pipe(map(response => response.selectors[requestId]));
102
+ }
103
+ subscribe$(selectorName, inputData = {}, options) {
104
+ const requestId = UUID.UUID();
105
+ let subscription = this.subscriptions[requestId];
106
+ if (!subscription) {
107
+ const request = {
108
+ selectors: {
109
+ [requestId]: {
110
+ apiName: selectorName,
111
+ inputData,
112
+ ownerId: this.ownerId,
113
+ },
114
+ },
115
+ };
116
+ subscription = {
117
+ request,
118
+ data$: new BehaviorSubject(this.NOT_INITIALIZED),
119
+ };
120
+ this.subscriptions[requestId] = subscription;
121
+ if (!options?.cold) {
122
+ this.execute$(request).subscribe();
123
+ }
124
+ }
125
+ return subscription.data$.pipe(filter(data => data != this.NOT_INITIALIZED), map(data => data), distinctUntilChanged(), finalize(() => {
126
+ if (!this.subscriptions[requestId]?.data$.observed) {
127
+ delete this.subscriptions[requestId];
128
+ }
129
+ }), takeUntil(this.canceledConfiguration$));
130
+ }
131
+ saveConfiguration(quoteId, flow) {
132
+ if (this.isStatefulConfiguration) {
133
+ return this.flowStateApiService
134
+ .saveConfiguration(this.flowStateService.stateId ?? '', this.stateId ?? '')
135
+ .pipe(switchMap(r => this.flowStateService.executeRequest$({}, true).pipe(map(() => r))));
136
+ }
137
+ else {
138
+ if (!flow) {
139
+ if (!quoteId) {
140
+ return of({ quoteId: '' });
141
+ }
142
+ const rootLineItem = this.configurationService.getSnapshot();
143
+ const currentState = rootLineItem ? [rootLineItem] : [];
144
+ return this.quoteApiService
145
+ .getQuoteDraft(quoteId)
146
+ .pipe(switchMap(quoteDraft => this.quoteApiService.upsertQuote({ ...quoteDraft, currentState })));
147
+ }
148
+ else {
149
+ const quoteDraft = this.quoteDraftService.quoteDraft;
150
+ const lineItem = this.configurationService.getSnapshot();
151
+ if (!quoteDraft || !lineItem) {
152
+ return of({ quoteId: '' });
153
+ }
154
+ const isNewLineItem = quoteDraft.currentState.every(li => li.id !== lineItem.id);
155
+ let updatedState;
156
+ if (isNewLineItem) {
157
+ updatedState = [...quoteDraft.currentState, lineItem];
158
+ }
159
+ else {
160
+ updatedState = quoteDraft.currentState.map(li => (li.id === lineItem.id ? lineItem : li));
161
+ }
162
+ return this.flowConfigurationService
163
+ .calculate$({ ...quoteDraft, currentState: updatedState })
164
+ .pipe(map(() => ({ quoteId: '' })));
165
+ }
166
+ }
167
+ }
168
+ cancelConfiguration() {
169
+ if (!this.isInitialized$.value) {
170
+ return of(undefined);
171
+ }
172
+ this.canceledConfiguration$.next();
173
+ this.canceledConfiguration$.complete();
174
+ this.subscriptions = {};
175
+ this.isInitialized$.next(false);
176
+ if (!this.isInitialized$.value || !this.isStatefulConfiguration) {
177
+ return of(undefined);
178
+ }
179
+ return this.flowStateApiService.cancelConfiguration(this.flowStateService.stateId ?? '', this.stateId ?? '');
180
+ }
181
+ get isStatefulConfiguration() {
182
+ return this.flowInfoService.flow?.properties.stateful ?? false;
183
+ }
184
+ initStateful$() {
185
+ this.ownerId = this.configurationRuntimeService.runtimeContext?.uiDefinitionContainer?.id ?? '';
186
+ const lineItemId = this.configurationRuntimeService.runtimeContext?.properties?.lineItemId;
187
+ if (!this.flowStateService.stateId) {
188
+ return of(undefined);
189
+ }
190
+ const container = this.configurationRuntimeService.runtimeContext?.uiDefinitionContainer;
191
+ const lineItem = this.configurationService.generateLineItem();
192
+ let request$;
193
+ if (!lineItemId) {
194
+ request$ = this.flowStateApiService.newConfiguration(this.flowStateService.stateId, {
195
+ lineItem,
196
+ actionsOverride: container?.actions?.map(processor => ({ ...processor, ownerId: this.ownerId })),
197
+ selectorsOverride: container?.selectors?.map(processor => ({ ...processor, ownerId: this.ownerId })),
198
+ });
199
+ }
200
+ else {
201
+ request$ = this.flowStateApiService.startConfiguration(this.flowStateService.stateId, {
202
+ lineItemId,
203
+ actionsOverride: container?.actions?.map(processor => ({ ...processor, ownerId: this.ownerId })),
204
+ selectorsOverride: container?.selectors?.map(processor => ({ ...processor, ownerId: this.ownerId })),
205
+ });
206
+ }
207
+ return request$.pipe(map(r => {
208
+ this.stateId = r.stateId;
209
+ return undefined;
210
+ }));
211
+ }
212
+ initStateless$() {
213
+ return this.configurationService.configure().pipe(map(() => undefined));
214
+ }
215
+ executeStateless$(request) {
216
+ return of(undefined).pipe(switchMap(() => {
217
+ // Apply actions and execute configuration/price call
218
+ // No need to run configuration if no actions in the request
219
+ if (!request.actions?.length) {
220
+ return of(undefined);
221
+ }
222
+ let configurationRequest = this.configurationService.generateRequest();
223
+ request.actions.forEach(action => {
224
+ try {
225
+ configurationRequest = this.executeActionScript(configurationRequest, action) ?? configurationRequest;
226
+ }
227
+ catch (e) {
228
+ console.error(e);
229
+ this.toastService.add({ severity: ToastType.error, summary: String(e) });
230
+ throw e;
231
+ }
232
+ });
233
+ return this.configurationService.configureRequest$(configurationRequest);
234
+ }), map(() => {
235
+ // Run selectors and apply them to the state
236
+ const configurationState = cloneDeep(this.configurationService.stateSnapshot);
237
+ if (!configurationState) {
238
+ return { stateId: '', selectors: {} };
239
+ }
240
+ const selectorsResult = EntityUtil.entries(request.selectors ?? {}).reduce((result, [key, selector]) => {
241
+ try {
242
+ result.selectors[key] = {
243
+ success: true,
244
+ result: this.executeSelectorScript(configurationState, selector),
245
+ };
246
+ }
247
+ catch (e) {
248
+ console.error(e);
249
+ result.selectors[key] = {
250
+ success: false,
251
+ errorMessage: String(e),
252
+ };
253
+ }
254
+ return result;
255
+ }, { stateId: '', selectors: {} });
256
+ return selectorsResult;
257
+ }));
258
+ }
259
+ executeStateful$(request) {
260
+ if (!this.flowStateService.stateId || !this.stateId) {
261
+ return of();
262
+ }
263
+ return this.flowStateApiService.executeConfiguration(this.flowStateService.stateId, this.stateId, request).pipe(tap(response => {
264
+ this.stateId = response.stateId;
265
+ }));
266
+ }
267
+ executeActionScript(request, processor) {
268
+ const { actions } = this.configurationRuntimeService.runtimeContext?.uiDefinitionContainer ?? {};
269
+ const configurationProcessor = actions?.find(action => action.apiName === processor.apiName);
270
+ if (!configurationProcessor?.script) {
271
+ throw `ConfigurationProcessor ${processor.apiName} not found`;
272
+ }
273
+ return this.executeProcessorScript(request, configurationProcessor, processor.inputData);
274
+ }
275
+ executeSelectorScript(request, processor) {
276
+ const { selectors } = this.configurationRuntimeService.runtimeContext?.uiDefinitionContainer ?? {};
277
+ const configurationProcessor = selectors?.find(selector => selector.apiName === processor.apiName);
278
+ if (!configurationProcessor?.script) {
279
+ throw `ConfigurationProcessor ${processor.apiName} not found`;
280
+ }
281
+ return this.executeProcessorScript(request, configurationProcessor, processor.inputData);
282
+ }
283
+ executeProcessorScript(request, configurationProcessor, inputData) {
284
+ let functionToExecute = this.executedFunctions[configurationProcessor.apiName];
285
+ if (!functionToExecute) {
286
+ const script = `${configurationProcessor.script}\nreturn transform;`;
287
+ const sourceMap = `\n//# sourceURL=${configurationProcessor.apiName}.js`;
288
+ functionToExecute = new Function(script + sourceMap)();
289
+ this.executedFunctions[configurationProcessor.apiName] = functionToExecute;
290
+ }
291
+ return functionToExecute({
292
+ request,
293
+ inputData,
294
+ flowStore: this.flowStateService.getFlowStore(),
295
+ configurationStore: this.configurationStore,
296
+ });
297
+ }
298
+ }
299
+ ConfigurationStateService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: ConfigurationStateService, deps: [{ token: i1.ConfigurationRuntimeService }, { token: i2.ConfigurationService }, { token: i3.QuoteDraftService }, { token: i4.ToastService }, { token: i3.FlowStateService }, { token: i3.FlowInfoService }, { token: i5.FlowConfigurationService }, { token: i6.FlowStateApiService }, { token: i6.QuoteApiService }], target: i0.ɵɵFactoryTarget.Injectable });
300
+ ConfigurationStateService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: ConfigurationStateService });
301
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: ConfigurationStateService, decorators: [{
302
+ type: Injectable
303
+ }], ctorParameters: function () { return [{ type: i1.ConfigurationRuntimeService }, { type: i2.ConfigurationService }, { type: i3.QuoteDraftService }, { type: i4.ToastService }, { type: i3.FlowStateService }, { type: i3.FlowInfoService }, { type: i5.FlowConfigurationService }, { type: i6.FlowStateApiService }, { type: i6.QuoteApiService }]; } });
304
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiY29uZmlndXJhdGlvbi1zdGF0ZS5zZXJ2aWNlLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vLi4vLi4vLi4vLi4vLi4vLi4vbGlicy9zZGsvY29yZS9tb2R1bGVzL2NvbmZpZ3VyYXRpb24vc2VydmljZXMvY29uZmlndXJhdGlvbi1zdGF0ZS5zZXJ2aWNlLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBLE9BQU8sRUFBRSxVQUFVLEVBQUUsTUFBTSxlQUFlLENBQUM7QUFDM0MsT0FBTyxFQUFFLG1CQUFtQixFQUFFLGVBQWUsRUFBRSxN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