@nyaruka/temba-components 0.139.0 → 0.141.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (385) hide show
  1. package/.github/workflows/cla.yml +1 -1
  2. package/.github/workflows/copilot-setup-steps.yml +6 -1
  3. package/.lintstagedrc.js +10 -0
  4. package/CHANGELOG.md +32 -0
  5. package/demo/data/flows/sample-flow.json +24 -0
  6. package/dist/locales/es.js +5 -5
  7. package/dist/locales/es.js.map +1 -1
  8. package/dist/locales/fr.js +5 -5
  9. package/dist/locales/fr.js.map +1 -1
  10. package/dist/locales/locale-codes.js +11 -2
  11. package/dist/locales/locale-codes.js.map +1 -1
  12. package/dist/locales/pt.js +5 -5
  13. package/dist/locales/pt.js.map +1 -1
  14. package/dist/temba-components.js +702 -338
  15. package/dist/temba-components.js.map +1 -1
  16. package/out-tsc/src/display/Chat.js +10 -7
  17. package/out-tsc/src/display/Chat.js.map +1 -1
  18. package/out-tsc/src/display/Dropdown.js +3 -1
  19. package/out-tsc/src/display/Dropdown.js.map +1 -1
  20. package/out-tsc/src/display/FloatingTab.js +4 -4
  21. package/out-tsc/src/display/FloatingTab.js.map +1 -1
  22. package/out-tsc/src/display/Thumbnail.js +163 -5
  23. package/out-tsc/src/display/Thumbnail.js.map +1 -1
  24. package/out-tsc/src/flow/CanvasNode.js +65 -23
  25. package/out-tsc/src/flow/CanvasNode.js.map +1 -1
  26. package/out-tsc/src/flow/Editor.js +369 -49
  27. package/out-tsc/src/flow/Editor.js.map +1 -1
  28. package/out-tsc/src/flow/NodeEditor.js +118 -10
  29. package/out-tsc/src/flow/NodeEditor.js.map +1 -1
  30. package/out-tsc/src/flow/Plumber.js +61 -14
  31. package/out-tsc/src/flow/Plumber.js.map +1 -1
  32. package/out-tsc/src/flow/StickyNote.js +13 -4
  33. package/out-tsc/src/flow/StickyNote.js.map +1 -1
  34. package/out-tsc/src/flow/actions/add_contact_groups.js +4 -1
  35. package/out-tsc/src/flow/actions/add_contact_groups.js.map +1 -1
  36. package/out-tsc/src/flow/actions/add_input_labels.js +4 -1
  37. package/out-tsc/src/flow/actions/add_input_labels.js.map +1 -1
  38. package/out-tsc/src/flow/actions/audio-player.js +112 -0
  39. package/out-tsc/src/flow/actions/audio-player.js.map +1 -0
  40. package/out-tsc/src/flow/actions/enter_flow.js +43 -0
  41. package/out-tsc/src/flow/actions/enter_flow.js.map +1 -0
  42. package/out-tsc/src/flow/actions/play_audio.js +57 -4
  43. package/out-tsc/src/flow/actions/play_audio.js.map +1 -1
  44. package/out-tsc/src/flow/actions/remove_contact_groups.js +6 -1
  45. package/out-tsc/src/flow/actions/remove_contact_groups.js.map +1 -1
  46. package/out-tsc/src/flow/actions/say_msg.js +86 -3
  47. package/out-tsc/src/flow/actions/say_msg.js.map +1 -1
  48. package/out-tsc/src/flow/actions/send_broadcast.js +6 -2
  49. package/out-tsc/src/flow/actions/send_broadcast.js.map +1 -1
  50. package/out-tsc/src/flow/actions/set_contact_channel.js +13 -0
  51. package/out-tsc/src/flow/actions/set_contact_channel.js.map +1 -1
  52. package/out-tsc/src/flow/actions/set_contact_status.js +7 -5
  53. package/out-tsc/src/flow/actions/set_contact_status.js.map +1 -1
  54. package/out-tsc/src/flow/actions/start_session.js +10 -3
  55. package/out-tsc/src/flow/actions/start_session.js.map +1 -1
  56. package/out-tsc/src/flow/config.js +11 -3
  57. package/out-tsc/src/flow/config.js.map +1 -1
  58. package/out-tsc/src/flow/nodes/shared-rules.js +1 -1
  59. package/out-tsc/src/flow/nodes/shared-rules.js.map +1 -1
  60. package/out-tsc/src/flow/nodes/split_by_contact_field.js +18 -5
  61. package/out-tsc/src/flow/nodes/split_by_contact_field.js.map +1 -1
  62. package/out-tsc/src/flow/nodes/split_by_expression.js +1 -1
  63. package/out-tsc/src/flow/nodes/split_by_expression.js.map +1 -1
  64. package/out-tsc/src/flow/nodes/split_by_llm_categorize.js +0 -1
  65. package/out-tsc/src/flow/nodes/split_by_llm_categorize.js.map +1 -1
  66. package/out-tsc/src/flow/nodes/split_by_random.js +0 -1
  67. package/out-tsc/src/flow/nodes/split_by_random.js.map +1 -1
  68. package/out-tsc/src/flow/nodes/split_by_run_result.js +10 -4
  69. package/out-tsc/src/flow/nodes/split_by_run_result.js.map +1 -1
  70. package/out-tsc/src/flow/nodes/terminal.js +7 -0
  71. package/out-tsc/src/flow/nodes/terminal.js.map +1 -0
  72. package/out-tsc/src/flow/nodes/wait_for_audio.js +77 -0
  73. package/out-tsc/src/flow/nodes/wait_for_audio.js.map +1 -0
  74. package/out-tsc/src/flow/nodes/wait_for_dial.js +151 -0
  75. package/out-tsc/src/flow/nodes/wait_for_dial.js.map +1 -0
  76. package/out-tsc/src/flow/nodes/wait_for_digits.js +61 -1
  77. package/out-tsc/src/flow/nodes/wait_for_digits.js.map +1 -1
  78. package/out-tsc/src/flow/nodes/wait_for_menu.js +173 -2
  79. package/out-tsc/src/flow/nodes/wait_for_menu.js.map +1 -1
  80. package/out-tsc/src/flow/nodes/wait_for_response.js +1 -1
  81. package/out-tsc/src/flow/nodes/wait_for_response.js.map +1 -1
  82. package/out-tsc/src/flow/operators.js +21 -5
  83. package/out-tsc/src/flow/operators.js.map +1 -1
  84. package/out-tsc/src/flow/types.js.map +1 -1
  85. package/out-tsc/src/flow/utils.js +79 -3
  86. package/out-tsc/src/flow/utils.js.map +1 -1
  87. package/out-tsc/src/form/ArrayEditor.js +4 -2
  88. package/out-tsc/src/form/ArrayEditor.js.map +1 -1
  89. package/out-tsc/src/form/FieldRenderer.js +56 -0
  90. package/out-tsc/src/form/FieldRenderer.js.map +1 -1
  91. package/out-tsc/src/interfaces.js +1 -0
  92. package/out-tsc/src/interfaces.js.map +1 -1
  93. package/out-tsc/src/layout/Dialog.js +51 -7
  94. package/out-tsc/src/layout/Dialog.js.map +1 -1
  95. package/out-tsc/src/layout/Modax.js +20 -2
  96. package/out-tsc/src/layout/Modax.js.map +1 -1
  97. package/out-tsc/src/list/ContentMenu.js +14 -1
  98. package/out-tsc/src/list/ContentMenu.js.map +1 -1
  99. package/out-tsc/src/locales/es.js +5 -5
  100. package/out-tsc/src/locales/es.js.map +1 -1
  101. package/out-tsc/src/locales/fr.js +5 -5
  102. package/out-tsc/src/locales/fr.js.map +1 -1
  103. package/out-tsc/src/locales/locale-codes.js +11 -2
  104. package/out-tsc/src/locales/locale-codes.js.map +1 -1
  105. package/out-tsc/src/locales/pt.js +5 -5
  106. package/out-tsc/src/locales/pt.js.map +1 -1
  107. package/out-tsc/src/simulator/Simulator.js +21 -4
  108. package/out-tsc/src/simulator/Simulator.js.map +1 -1
  109. package/out-tsc/src/store/AppState.js +102 -3
  110. package/out-tsc/src/store/AppState.js.map +1 -1
  111. package/out-tsc/test/actions/add_contact_groups.test.js +35 -0
  112. package/out-tsc/test/actions/add_contact_groups.test.js.map +1 -1
  113. package/out-tsc/test/actions/add_input_labels.test.js +53 -0
  114. package/out-tsc/test/actions/add_input_labels.test.js.map +1 -0
  115. package/out-tsc/test/actions/enter_flow.test.js +71 -0
  116. package/out-tsc/test/actions/enter_flow.test.js.map +1 -0
  117. package/out-tsc/test/actions/play_audio.test.js +118 -0
  118. package/out-tsc/test/actions/play_audio.test.js.map +1 -0
  119. package/out-tsc/test/actions/remove_contact_groups.test.js +24 -0
  120. package/out-tsc/test/actions/remove_contact_groups.test.js.map +1 -1
  121. package/out-tsc/test/actions/say_msg.test.js +158 -0
  122. package/out-tsc/test/actions/say_msg.test.js.map +1 -0
  123. package/out-tsc/test/actions/send_broadcast.test.js +41 -0
  124. package/out-tsc/test/actions/send_broadcast.test.js.map +1 -1
  125. package/out-tsc/test/actions/set_contact_channel.test.js +67 -0
  126. package/out-tsc/test/actions/set_contact_channel.test.js.map +1 -0
  127. package/out-tsc/test/actions/set_contact_field.test.js +52 -0
  128. package/out-tsc/test/actions/set_contact_field.test.js.map +1 -0
  129. package/out-tsc/test/actions/set_contact_language.test.js +39 -0
  130. package/out-tsc/test/actions/set_contact_language.test.js.map +1 -0
  131. package/out-tsc/test/actions/set_contact_name.test.js +28 -0
  132. package/out-tsc/test/actions/set_contact_name.test.js.map +1 -0
  133. package/out-tsc/test/actions/set_contact_status.test.js +44 -0
  134. package/out-tsc/test/actions/set_contact_status.test.js.map +1 -0
  135. package/out-tsc/test/actions/set_run_result.test.js +47 -0
  136. package/out-tsc/test/actions/set_run_result.test.js.map +1 -0
  137. package/out-tsc/test/actions/start_session.test.js +76 -0
  138. package/out-tsc/test/actions/start_session.test.js.map +1 -1
  139. package/out-tsc/test/nodes/split_by_contact_field.test.js +50 -0
  140. package/out-tsc/test/nodes/split_by_contact_field.test.js.map +1 -1
  141. package/out-tsc/test/nodes/split_by_run_result.test.js +82 -0
  142. package/out-tsc/test/nodes/split_by_run_result.test.js.map +1 -1
  143. package/out-tsc/test/nodes/split_by_ticket.test.js +139 -0
  144. package/out-tsc/test/nodes/split_by_ticket.test.js.map +1 -0
  145. package/out-tsc/test/nodes/split_by_webhook.test.js +111 -0
  146. package/out-tsc/test/nodes/split_by_webhook.test.js.map +1 -0
  147. package/out-tsc/test/nodes/wait_for_audio.test.js +156 -0
  148. package/out-tsc/test/nodes/wait_for_audio.test.js.map +1 -0
  149. package/out-tsc/test/nodes/wait_for_dial.test.js +336 -0
  150. package/out-tsc/test/nodes/wait_for_dial.test.js.map +1 -0
  151. package/out-tsc/test/nodes/wait_for_digits.test.js +198 -84
  152. package/out-tsc/test/nodes/wait_for_digits.test.js.map +1 -1
  153. package/out-tsc/test/nodes/wait_for_menu.test.js +340 -0
  154. package/out-tsc/test/nodes/wait_for_menu.test.js.map +1 -0
  155. package/out-tsc/test/temba-flow-collision.test.js +261 -6
  156. package/out-tsc/test/temba-flow-collision.test.js.map +1 -1
  157. package/out-tsc/test/temba-flow-editor.test.js +187 -0
  158. package/out-tsc/test/temba-flow-editor.test.js.map +1 -1
  159. package/out-tsc/test/temba-flow-plumber.test.js +19 -0
  160. package/out-tsc/test/temba-flow-plumber.test.js.map +1 -1
  161. package/out-tsc/test/temba-node-type-selector.test.js +6 -6
  162. package/out-tsc/test/temba-node-type-selector.test.js.map +1 -1
  163. package/out-tsc/test/temba-select.test.js +4 -1
  164. package/out-tsc/test/temba-select.test.js.map +1 -1
  165. package/out-tsc/test/utils.test.js +4 -2
  166. package/out-tsc/test/utils.test.js.map +1 -1
  167. package/package.json +3 -9
  168. package/screenshots/truth/actions/add_contact_groups/render/descriptive-group-names.png +0 -0
  169. package/screenshots/truth/actions/add_contact_groups/render/long-group-names.png +0 -0
  170. package/screenshots/truth/actions/add_contact_groups/render/many-groups.png +0 -0
  171. package/screenshots/truth/actions/add_contact_groups/render/multiple-groups.png +0 -0
  172. package/screenshots/truth/actions/add_contact_groups/render/single-group.png +0 -0
  173. package/screenshots/truth/actions/add_contact_urn/render/expression-facebook.png +0 -0
  174. package/screenshots/truth/actions/add_contact_urn/render/expression-phone.png +0 -0
  175. package/screenshots/truth/actions/add_contact_urn/render/facebook-id.png +0 -0
  176. package/screenshots/truth/actions/add_contact_urn/render/instagram-handle.png +0 -0
  177. package/screenshots/truth/actions/add_contact_urn/render/line-id.png +0 -0
  178. package/screenshots/truth/actions/add_contact_urn/render/phone-number.png +0 -0
  179. package/screenshots/truth/actions/add_contact_urn/render/telegram-id.png +0 -0
  180. package/screenshots/truth/actions/add_contact_urn/render/viber-id.png +0 -0
  181. package/screenshots/truth/actions/add_contact_urn/render/wechat-id.png +0 -0
  182. package/screenshots/truth/actions/add_contact_urn/render/whatsapp.png +0 -0
  183. package/screenshots/truth/actions/add_input_labels/editor/multiple-labels.png +0 -0
  184. package/screenshots/truth/actions/add_input_labels/editor/single-label.png +0 -0
  185. package/screenshots/truth/actions/add_input_labels/render/multiple-labels.png +0 -0
  186. package/screenshots/truth/actions/add_input_labels/render/single-label.png +0 -0
  187. package/screenshots/truth/actions/enter_flow/editor/basic-flow.png +0 -0
  188. package/screenshots/truth/actions/enter_flow/editor/long-flow-name.png +0 -0
  189. package/screenshots/truth/actions/enter_flow/render/basic-flow.png +0 -0
  190. package/screenshots/truth/actions/enter_flow/render/long-flow-name.png +0 -0
  191. package/screenshots/truth/actions/play_audio/editor/expression-url.png +0 -0
  192. package/screenshots/truth/actions/play_audio/editor/static-url.png +0 -0
  193. package/screenshots/truth/actions/play_audio/render/expression-url.png +0 -0
  194. package/screenshots/truth/actions/play_audio/render/static-url.png +0 -0
  195. package/screenshots/truth/actions/remove_contact_groups/render/cleanup-groups.png +0 -0
  196. package/screenshots/truth/actions/remove_contact_groups/render/long-descriptive-group-names.png +0 -0
  197. package/screenshots/truth/actions/remove_contact_groups/render/many-groups.png +0 -0
  198. package/screenshots/truth/actions/remove_contact_groups/render/multiple-groups.png +0 -0
  199. package/screenshots/truth/actions/remove_contact_groups/render/remove-from-all-groups.png +0 -0
  200. package/screenshots/truth/actions/remove_contact_groups/render/single-group.png +0 -0
  201. package/screenshots/truth/actions/say_msg/editor/multiline-text.png +0 -0
  202. package/screenshots/truth/actions/say_msg/editor/simple-text.png +0 -0
  203. package/screenshots/truth/actions/say_msg/editor/text-with-audio-url.png +0 -0
  204. package/screenshots/truth/actions/say_msg/render/multiline-text.png +0 -0
  205. package/screenshots/truth/actions/say_msg/render/simple-text.png +0 -0
  206. package/screenshots/truth/actions/say_msg/render/text-with-audio-url.png +0 -0
  207. package/screenshots/truth/actions/send_broadcast/render/contacts-only.png +0 -0
  208. package/screenshots/truth/actions/send_broadcast/render/groups-and-contacts.png +0 -0
  209. package/screenshots/truth/actions/send_broadcast/render/groups-only.png +0 -0
  210. package/screenshots/truth/actions/send_broadcast/render/many-groups.png +0 -0
  211. package/screenshots/truth/actions/send_broadcast/render/multiline-text.png +0 -0
  212. package/screenshots/truth/actions/send_email/render/complex-business-email.png +0 -0
  213. package/screenshots/truth/actions/send_email/render/empty-body.png +0 -0
  214. package/screenshots/truth/actions/send_email/render/empty-subject.png +0 -0
  215. package/screenshots/truth/actions/send_email/render/long-subject.png +0 -0
  216. package/screenshots/truth/actions/send_email/render/multiline-body.png +0 -0
  217. package/screenshots/truth/actions/send_email/render/multiple-recipients.png +0 -0
  218. package/screenshots/truth/actions/send_email/render/simple-email.png +0 -0
  219. package/screenshots/truth/actions/send_email/render/with-expressions.png +0 -0
  220. package/screenshots/truth/actions/send_msg/render/long-quick-replies.png +0 -0
  221. package/screenshots/truth/actions/send_msg/render/multiline-text-with-replies.png +0 -0
  222. package/screenshots/truth/actions/send_msg/render/simple-text.png +0 -0
  223. package/screenshots/truth/actions/send_msg/render/text-with-linebreaks.png +0 -0
  224. package/screenshots/truth/actions/send_msg/render/text-with-many-quick-replies.png +0 -0
  225. package/screenshots/truth/actions/send_msg/render/text-with-quick-replies.png +0 -0
  226. package/screenshots/truth/actions/send_msg/render/text-without-quick-replies.png +0 -0
  227. package/screenshots/truth/actions/set_contact_channel/editor/sms-channel.png +0 -0
  228. package/screenshots/truth/actions/set_contact_channel/editor/whatsapp-channel.png +0 -0
  229. package/screenshots/truth/actions/set_contact_channel/render/sms-channel.png +0 -0
  230. package/screenshots/truth/actions/set_contact_channel/render/whatsapp-channel.png +0 -0
  231. package/screenshots/truth/actions/set_contact_field/editor/clear-value.png +0 -0
  232. package/screenshots/truth/actions/set_contact_field/editor/set-value.png +0 -0
  233. package/screenshots/truth/actions/set_contact_field/render/clear-value.png +0 -0
  234. package/screenshots/truth/actions/set_contact_field/render/set-value.png +0 -0
  235. package/screenshots/truth/actions/set_contact_language/editor/english.png +0 -0
  236. package/screenshots/truth/actions/set_contact_language/editor/french.png +0 -0
  237. package/screenshots/truth/actions/set_contact_language/render/english.png +0 -0
  238. package/screenshots/truth/actions/set_contact_language/render/french.png +0 -0
  239. package/screenshots/truth/actions/set_contact_name/editor/expression-name.png +0 -0
  240. package/screenshots/truth/actions/set_contact_name/editor/static-name.png +0 -0
  241. package/screenshots/truth/actions/set_contact_name/render/expression-name.png +0 -0
  242. package/screenshots/truth/actions/set_contact_name/render/static-name.png +0 -0
  243. package/screenshots/truth/actions/set_contact_status/editor/active.png +0 -0
  244. package/screenshots/truth/actions/set_contact_status/editor/archived.png +0 -0
  245. package/screenshots/truth/actions/set_contact_status/editor/blocked.png +0 -0
  246. package/screenshots/truth/actions/set_contact_status/render/active.png +0 -0
  247. package/screenshots/truth/actions/set_contact_status/render/archived.png +0 -0
  248. package/screenshots/truth/actions/set_contact_status/render/blocked.png +0 -0
  249. package/screenshots/truth/actions/set_run_result/editor/expression-value.png +0 -0
  250. package/screenshots/truth/actions/set_run_result/editor/with-category.png +0 -0
  251. package/screenshots/truth/actions/set_run_result/render/expression-value.png +0 -0
  252. package/screenshots/truth/actions/set_run_result/render/with-category.png +0 -0
  253. package/screenshots/truth/actions/start_session/render/contact-query.png +0 -0
  254. package/screenshots/truth/actions/start_session/render/contacts-only.png +0 -0
  255. package/screenshots/truth/actions/start_session/render/create-contact.png +0 -0
  256. package/screenshots/truth/actions/start_session/render/groups-and-contacts.png +0 -0
  257. package/screenshots/truth/actions/start_session/render/groups-only.png +0 -0
  258. package/screenshots/truth/actions/start_session/render/many-recipients.png +0 -0
  259. package/screenshots/truth/editor/router.png +0 -0
  260. package/screenshots/truth/editor/wait.png +0 -0
  261. package/screenshots/truth/nodes/split_by_llm/render/information-extraction.png +0 -0
  262. package/screenshots/truth/nodes/split_by_llm/render/sentiment-analysis.png +0 -0
  263. package/screenshots/truth/nodes/split_by_llm/render/summarization.png +0 -0
  264. package/screenshots/truth/nodes/split_by_llm/render/translation-task.png +0 -0
  265. package/screenshots/truth/nodes/split_by_llm_categorize/editor/basic-categorization.png +0 -0
  266. package/screenshots/truth/nodes/split_by_llm_categorize/editor/custom-input-and-result-name.png +0 -0
  267. package/screenshots/truth/nodes/split_by_llm_categorize/editor/feedback-categorization.png +0 -0
  268. package/screenshots/truth/nodes/split_by_llm_categorize/editor/many-categories.png +0 -0
  269. package/screenshots/truth/nodes/split_by_llm_categorize/editor/minimal-categories.png +0 -0
  270. package/screenshots/truth/nodes/split_by_llm_categorize/render/basic-categorization.png +0 -0
  271. package/screenshots/truth/nodes/split_by_llm_categorize/render/custom-input-and-result-name.png +0 -0
  272. package/screenshots/truth/nodes/split_by_llm_categorize/render/feedback-categorization.png +0 -0
  273. package/screenshots/truth/nodes/split_by_llm_categorize/render/many-categories.png +0 -0
  274. package/screenshots/truth/nodes/split_by_llm_categorize/render/minimal-categories.png +0 -0
  275. package/screenshots/truth/nodes/split_by_random/editor/ab-test-multiple-variants.png +0 -0
  276. package/screenshots/truth/nodes/split_by_random/editor/sampling-split.png +0 -0
  277. package/screenshots/truth/nodes/split_by_random/editor/three-way-split.png +0 -0
  278. package/screenshots/truth/nodes/split_by_random/editor/two-bucket-split.png +0 -0
  279. package/screenshots/truth/nodes/split_by_random/render/ab-test-multiple-variants.png +0 -0
  280. package/screenshots/truth/nodes/split_by_random/render/sampling-split.png +0 -0
  281. package/screenshots/truth/nodes/split_by_random/render/three-way-split.png +0 -0
  282. package/screenshots/truth/nodes/split_by_random/render/two-bucket-split.png +0 -0
  283. package/screenshots/truth/nodes/wait_for_audio/editor/basic-audio-wait.png +0 -0
  284. package/screenshots/truth/nodes/wait_for_audio/render/basic-audio-wait.png +0 -0
  285. package/screenshots/truth/nodes/wait_for_dial/editor/basic-dial.png +0 -0
  286. package/screenshots/truth/nodes/wait_for_dial/editor/dial-with-limits.png +0 -0
  287. package/screenshots/truth/nodes/wait_for_dial/render/basic-dial.png +0 -0
  288. package/screenshots/truth/nodes/wait_for_dial/render/dial-with-limits.png +0 -0
  289. package/screenshots/truth/nodes/wait_for_digits/editor/basic-digits-wait.png +0 -0
  290. package/screenshots/truth/nodes/wait_for_digits/editor/digits-with-rules.png +0 -0
  291. package/screenshots/truth/nodes/wait_for_digits/render/basic-digits-wait.png +0 -0
  292. package/screenshots/truth/nodes/wait_for_digits/render/digits-with-rules.png +0 -0
  293. package/screenshots/truth/nodes/wait_for_menu/editor/menu-with-digits.png +0 -0
  294. package/screenshots/truth/nodes/wait_for_menu/render/menu-with-digits.png +0 -0
  295. package/screenshots/truth/nodes/wait_for_response/editor/basic-wait.png +0 -0
  296. package/screenshots/truth/nodes/wait_for_response/editor/custom-result-name.png +0 -0
  297. package/screenshots/truth/nodes/wait_for_response/editor/no-timeout.png +0 -0
  298. package/screenshots/truth/nodes/wait_for_response/editor/short-timeout.png +0 -0
  299. package/screenshots/truth/nodes/wait_for_response/render/basic-wait.png +0 -0
  300. package/screenshots/truth/nodes/wait_for_response/render/custom-result-name.png +0 -0
  301. package/screenshots/truth/nodes/wait_for_response/render/no-timeout.png +0 -0
  302. package/screenshots/truth/nodes/wait_for_response/render/short-timeout.png +0 -0
  303. package/src/display/Chat.ts +13 -7
  304. package/src/display/Dropdown.ts +3 -1
  305. package/src/display/FloatingTab.ts +4 -4
  306. package/src/display/Thumbnail.ts +162 -2
  307. package/src/flow/CanvasNode.ts +70 -24
  308. package/src/flow/Editor.ts +440 -99
  309. package/src/flow/NodeEditor.ts +137 -9
  310. package/src/flow/Plumber.ts +89 -14
  311. package/src/flow/StickyNote.ts +14 -4
  312. package/src/flow/actions/add_contact_groups.ts +4 -1
  313. package/src/flow/actions/add_input_labels.ts +4 -1
  314. package/src/flow/actions/audio-player.ts +127 -0
  315. package/src/flow/actions/enter_flow.ts +44 -0
  316. package/src/flow/actions/play_audio.ts +64 -5
  317. package/src/flow/actions/remove_contact_groups.ts +6 -1
  318. package/src/flow/actions/say_msg.ts +94 -4
  319. package/src/flow/actions/send_broadcast.ts +6 -2
  320. package/src/flow/actions/set_contact_channel.ts +13 -1
  321. package/src/flow/actions/set_contact_status.ts +7 -5
  322. package/src/flow/actions/start_session.ts +10 -3
  323. package/src/flow/config.ts +11 -3
  324. package/src/flow/nodes/shared-rules.ts +1 -1
  325. package/src/flow/nodes/split_by_contact_field.ts +16 -5
  326. package/src/flow/nodes/split_by_expression.ts +1 -1
  327. package/src/flow/nodes/split_by_llm_categorize.ts +0 -1
  328. package/src/flow/nodes/split_by_random.ts +0 -1
  329. package/src/flow/nodes/split_by_run_result.ts +10 -4
  330. package/src/flow/nodes/terminal.ts +9 -0
  331. package/src/flow/nodes/wait_for_audio.ts +88 -0
  332. package/src/flow/nodes/wait_for_dial.ts +176 -0
  333. package/src/flow/nodes/wait_for_digits.ts +87 -2
  334. package/src/flow/nodes/wait_for_menu.ts +209 -3
  335. package/src/flow/nodes/wait_for_response.ts +1 -1
  336. package/src/flow/operators.ts +23 -5
  337. package/src/flow/types.ts +23 -1
  338. package/src/flow/utils.ts +82 -3
  339. package/src/form/ArrayEditor.ts +4 -2
  340. package/src/form/FieldRenderer.ts +71 -1
  341. package/src/interfaces.ts +2 -1
  342. package/src/layout/Dialog.ts +52 -7
  343. package/src/layout/Modax.ts +19 -2
  344. package/src/list/ContentMenu.ts +15 -1
  345. package/src/locales/es.ts +18 -13
  346. package/src/locales/fr.ts +18 -13
  347. package/src/locales/locale-codes.ts +11 -2
  348. package/src/locales/pt.ts +18 -13
  349. package/src/simulator/Simulator.ts +25 -4
  350. package/src/store/AppState.ts +120 -1
  351. package/src/store/flow-definition.d.ts +2 -0
  352. package/test/actions/add_contact_groups.test.ts +38 -0
  353. package/test/actions/add_input_labels.test.ts +67 -0
  354. package/test/actions/enter_flow.test.ts +88 -0
  355. package/test/actions/play_audio.test.ts +155 -0
  356. package/test/actions/remove_contact_groups.test.ts +29 -0
  357. package/test/actions/say_msg.test.ts +196 -0
  358. package/test/actions/send_broadcast.test.ts +44 -0
  359. package/test/actions/set_contact_channel.test.ts +88 -0
  360. package/test/actions/set_contact_field.test.ts +68 -0
  361. package/test/actions/set_contact_language.test.ts +55 -0
  362. package/test/actions/set_contact_name.test.ts +39 -0
  363. package/test/actions/set_contact_status.test.ts +64 -0
  364. package/test/actions/set_run_result.test.ts +61 -0
  365. package/test/actions/start_session.test.ts +82 -0
  366. package/test/nodes/split_by_contact_field.test.ts +59 -0
  367. package/test/nodes/split_by_run_result.test.ts +100 -0
  368. package/test/nodes/split_by_ticket.test.ts +157 -0
  369. package/test/nodes/split_by_webhook.test.ts +131 -0
  370. package/test/nodes/wait_for_audio.test.ts +182 -0
  371. package/test/nodes/wait_for_dial.test.ts +382 -0
  372. package/test/nodes/wait_for_digits.test.ts +233 -109
  373. package/test/nodes/wait_for_menu.test.ts +383 -0
  374. package/test/temba-flow-collision.test.ts +286 -6
  375. package/test/temba-flow-editor.test.ts +240 -0
  376. package/test/temba-flow-plumber.test.ts +62 -0
  377. package/test/temba-node-type-selector.test.ts +6 -6
  378. package/test/temba-select.test.ts +6 -1
  379. package/test/utils.test.ts +4 -2
  380. package/screenshots/truth/nodes/wait_for_digits/editor/phone-number-collection.png +0 -0
  381. package/screenshots/truth/nodes/wait_for_digits/editor/single-digit-with-timeout.png +0 -0
  382. package/screenshots/truth/nodes/wait_for_digits/editor/verification-code.png +0 -0
  383. package/screenshots/truth/nodes/wait_for_digits/render/phone-number-collection.png +0 -0
  384. package/screenshots/truth/nodes/wait_for_digits/render/single-digit-with-timeout.png +0 -0
  385. package/screenshots/truth/nodes/wait_for_digits/render/verification-code.png +0 -0
@@ -1 +1 @@
1
- {"version":3,"file":"send_broadcast.js","sourceRoot":"","sources":["../../../../src/flow/actions/send_broadcast.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,UAAU,CAAC;AAChC,OAAO,EAAgB,aAAa,EAAY,SAAS,EAAE,MAAM,UAAU,CAAC;AAE5E,OAAO,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AAC5C,OAAO,EAAE,IAAI,EAAE,MAAM,aAAa,CAAC;AAEnC,MAAM,CAAC,MAAM,cAAc,GAAiB;IAC1C,IAAI,EAAE,gBAAgB;IACtB,KAAK,EAAE,aAAa,CAAC,SAAS;IAC9B,SAAS,EAAE,CAAC,SAAS,CAAC,KAAK,EAAE,SAAS,CAAC,OAAO,EAAE,SAAS,CAAC,UAAU,CAAC;IACrE,MAAM,EAAE,CAAC,KAAW,EAAE,MAAqB,EAAE,EAAE;QAC7C,MAAM,UAAU,GAAG;YACjB,GAAG,CAAC,MAAM,CAAC,QAAQ,IAAI,EAAE,CAAC,CAAC,GA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AAI,EAAE,CAAC,CAAC;YAClE,IAAI,EAAE,MAAM,CAAC,IAAI,IAAI,EAAE;YACvB,WAAW,EAAE,MAAM,CAAC,WAAW,IAAI,EAAE;SACtC,CAAC;IACJ,CAAC;IAED,YAAY,EAAE,CAAC,QAAkB,EAAiB,EAAE;QAClD,MAAM,UAAU,GAAG,QAAQ,CAAC,UAAU,IAAI,EAAE,CAAC;QAC7C,MAAM,QAAQ,GAAG,UAAU,CAAC,MAAM,CAAC,CAAC,CAAM,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC;QACzD,MAAM,MAAM,GAAG,UAAU,CAAC,MAAM,CAAC,CAAC,CAAM,EAAE,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC;QAEtD,MAAM,MAAM,GAAkB;YAC5B,IAAI,EAAE,QAAQ,CAAC,IAAI;YACnB,IAAI,EAAE,gBAAgB;YACtB,IAAI,EAAE,QAAQ,CAAC,IAAI,IAAI,EAAE;YACzB,QAAQ;YACR,MAAM;YACN,WAAW,EAAE,QAAQ,CAAC,WAAW,IAAI,EAAE;SACxC,CAAC;QAEF,0DAA0D;QAC1D,IAAI,MAAM,CAAC,WAAW,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YACpC,OAAO,MAAM,CAAC,WAAW,CAAC;QAC5B,CAAC;QAED,OAAO,MAAM,CAAC;IAChB,CAAC;IAED,QAAQ,EAAE,CAAC,QAAkB,EAAQ,EAAE;QACrC,IAAI,QAAQ,CAAC,IAAI,IAAI,OAAO,QAAQ,CAAC,IAAI,KAAK,QAAQ,EAAE,CAAC;YACvD,QAAQ,CAAC,IAAI,GAAG,QAAQ,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC;QACvC,CAAC;IACH,CAAC;CACF,CAAC","sourcesContent":["import { html } from 'lit-html';\nimport { ActionConfig, ACTION_GROUPS, FormData, FlowTypes } from '../types';\nimport { Node, SendBroadcast } from '../../store/flow-definition';\nimport { renderStringList } from '../utils';\nimport { Icon } from '../../Icons';\n\nexport const send_broadcast: ActionConfig = {\n name: 'Send Broadcast',\n group: ACTION_GROUPS.broadcast,\n flowTypes: [FlowTypes.VOICE, FlowTypes.MESSAGE, FlowTypes.BACKGROUND],\n render: (_node: Node, action: SendBroadcast) => {\n const recipients = [\n ...(action.contacts || []).map((c) => c.name),\n ...(action.groups || []).map((g) => g.name)\n ];\n\n return html`<div>\n <div>${renderStringList(recipients, Icon.contacts)}</div>\n <div style=\"margin-top: 0.5em\">\n <div\n style=\"word-wrap: break-word; overflow-wrap: break-word; hyphens: auto;\"\n >\n ${action.text}\n </div>\n </div>\n </div>`;\n },\n\n form: {\n recipients: {\n type: 'select',\n label: 'Recipients',\n helpText: 'Select the contacts or groups to receive the broadcast',\n options: [],\n multi: true,\n searchable: true,\n endpoint: '/api/v2/contacts.json',\n valueKey: 'uuid',\n nameKey: 'name',\n placeholder: 'Search for contacts or groups...',\n required: true\n },\n text: {\n type: 'message-editor',\n label: 'Message',\n helpText:\n 'Enter the message to send with optional attachments. You can use expressions like @contact.name',\n required: true,\n evaluated: true,\n placeholder: 'Type your message here...',\n maxAttachments: 10,\n accept: '',\n endpoint: '/api/v2/media.json',\n counter: 'temba-charcount',\n gsm: true,\n autogrow: true\n }\n },\n\n layout: ['recipients', 'text'],\n\n toFormData: (action: SendBroadcast) => {\n return {\n uuid: action.uuid,\n recipients: [...(action.contacts || []), ...(action.groups || [])],\n text: action.text || '',\n attachments: action.attachments || []\n };\n },\n\n fromFormData: (formData: FormData): SendBroadcast => {\n const recipients = formData.recipients || [];\n const contacts = recipients.filter((r: any) => !r.group);\n const groups = recipients.filter((r: any) => r.group);\n\n const result: SendBroadcast = {\n uuid: formData.uuid,\n type: 'send_broadcast',\n text: formData.text || '',\n contacts,\n groups,\n attachments: formData.attachments || []\n };\n\n // Remove empty attachments array to match original format\n if (result.attachments.length === 0) {\n delete result.attachments;\n }\n\n return result;\n },\n\n sanitize: (formData: FormData): void => {\n if (formData.text && typeof formData.text === 'string') {\n formData.text = formData.text.trim();\n }\n }\n};\n"]}
1
+ {"version":3,"file":"send_broadcast.js","sourceRoot":"","sources":["../../../../src/flow/actions/send_broadcast.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,UAAU,CAAC;AAChC,OAAO,EAAgB,aAAa,EAAY,SAAS,EAAE,MAAM,UAAU,CAAC;AAE5E,OAAO,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AAC5C,OAAO,EAAE,IAAI,EAAE,MAAM,aAAa,CAAC;AAEnC,MAAM,CAAC,MAAM,cAAc,GAAiB;IAC1C,IAAI,EAAE,gBAAgB;IACtB,KAAK,EAAE,aAAa,CAAC,SAAS;IAC9B,SAAS,EAAE,CAAC,SAAS,CAAC,KAAK,EAAE,SAAS,CAAC,OAAO,EAAE,SAAS,CAAC,UAAU,CAAC;IACrE,MAAM,EAAE,CAAC,KAAW,EAAE,MAAqB,EAAE,EAAE;QAC7C,MAAM,UAAU,GAAG;YACjB,GAAG,CAAC,MAAM,CAAC,QAAQ,IAAI,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC;YAC7C,GAAG,CAAC,MAAM,CAAC,MAAM,IAAI,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC;SAC5C,CAAC;QAEF,OAAO,IAAI,CAAA;aACF,gBAAgB,CAAC,UAAU,EAAE,IAAI,CAAC,QAAQ,CAAC;;;;;YAK5C,MAAM,CAAC,IAAI;;;WAGZ,CAAC;IACV,CAAC;IAED,IAAI,EAAE;QACJ,UAAU,EAAE;YACV,IAAI,EAAE,QAAQ;YACd,KAAK,EAAE,YAAY;YACnB,QAAQ,EAAE,wDAAwD;YAClE,OAAO,EAAE,EAAE;YACX,KAAK,EAAE,IAAI;YACX,UAAU,EAAE,IAAI;YAChB,QAAQ,EAAE,uBAAuB;Y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M,CAAC,CAAC,CAAM,EAAE,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC;aAC3B,GAAG,CAAC,CAAC,CAAM,EAAE,EAAE,CAAC,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC;QAErD,MAAM,MAAM,GAAkB;YAC5B,IAAI,EAAE,QAAQ,CAAC,IAAI;YACnB,IAAI,EAAE,gBAAgB;YACtB,IAAI,EAAE,QAAQ,CAAC,IAAI,IAAI,EAAE;YACzB,QAAQ;YACR,MAAM;YACN,WAAW,EAAE,QAAQ,CAAC,WAAW,IAAI,EAAE;SACxC,CAAC;QAEF,0DAA0D;QAC1D,IAAI,MAAM,CAAC,WAAW,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YACpC,OAAO,MAAM,CAAC,WAAW,CAAC;QAC5B,CAAC;QAED,OAAO,MAAM,CAAC;IAChB,CAAC;IAED,QAAQ,EAAE,CAAC,QAAkB,EAAQ,EAAE;QACrC,IAAI,QAAQ,CAAC,IAAI,IAAI,OAAO,QAAQ,CAAC,IAAI,KAAK,QAAQ,EAAE,CAAC;YACvD,QAAQ,CAAC,IAAI,GAAG,QAAQ,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC;QACvC,CAAC;IACH,CAAC;CACF,CAAC","sourcesContent":["import { html } from 'lit-html';\nimport { ActionConfig, ACTION_GROUPS, FormData, FlowTypes } from '../types';\nimport { Node, SendBroadcast } from '../../store/flow-definition';\nimport { renderStringList } from '../utils';\nimport { Icon } from '../../Icons';\n\nexport const send_broadcast: ActionConfig = {\n name: 'Send Broadcast',\n group: ACTION_GROUPS.broadcast,\n flowTypes: [FlowTypes.VOICE, FlowTypes.MESSAGE, FlowTypes.BACKGROUND],\n render: (_node: Node, action: SendBroadcast) => {\n const recipients = [\n ...(action.contacts || []).map((c) => c.name),\n ...(action.groups || []).map((g) => g.name)\n ];\n\n return html`<div>\n <div>${renderStringList(recipients, Icon.contacts)}</div>\n <div style=\"margin-top: 0.5em\">\n <div\n style=\"word-wrap: break-word; overflow-wrap: break-word; hyphens: auto;\"\n >\n ${action.text}\n </div>\n </div>\n </div>`;\n },\n\n form: {\n recipients: {\n type: 'select',\n label: 'Recipients',\n helpText: 'Select the contacts or groups to receive the broadcast',\n options: [],\n multi: true,\n searchable: true,\n endpoint: '/api/v2/contacts.json',\n valueKey: 'uuid',\n nameKey: 'name',\n placeholder: 'Search for contacts or groups...',\n required: true\n },\n text: {\n type: 'message-editor',\n label: 'Message',\n helpText:\n 'Enter the message to send with optional attachments. You can use expressions like @contact.name',\n required: true,\n evaluated: true,\n placeholder: 'Type your message here...',\n maxAttachments: 10,\n accept: '',\n endpoint: '/api/v2/media.json',\n counter: 'temba-charcount',\n gsm: true,\n autogrow: true\n }\n },\n\n layout: ['recipients', 'text'],\n\n toFormData: (action: SendBroadcast) => {\n return {\n uuid: action.uuid,\n recipients: [...(action.contacts || []), ...(action.groups || [])],\n text: action.text || '',\n attachments: action.attachments || []\n };\n },\n\n fromFormData: (formData: FormData): SendBroadcast => {\n const recipients = formData.recipients || [];\n const contacts = recipients\n .filter((r: any) => !r.group)\n .map((c: any) => ({ uuid: c.uuid, name: c.name }));\n const groups = recipients\n .filter((r: any) => r.group)\n .map((g: any) => ({ uuid: g.uuid, name: g.name }));\n\n const result: SendBroadcast = {\n uuid: formData.uuid,\n type: 'send_broadcast',\n text: formData.text || '',\n contacts,\n groups,\n attachments: formData.attachments || []\n };\n\n // Remove empty attachments array to match original format\n if (result.attachments.length === 0) {\n delete result.attachments;\n }\n\n return result;\n },\n\n sanitize: (formData: FormData): void => {\n if (formData.text && typeof formData.text === 'string') {\n formData.text = formData.text.trim();\n }\n }\n};\n"]}
@@ -17,6 +17,7 @@ export const set_contact_channel = {
17
17
  endpoint: '/api/v2/channels.json',
18
18
  valueKey: 'uuid',
19
19
  nameKey: 'name',
20
+ placeholder: 'Select channel',
20
21
  helpText: 'Select the channel to set for the contact'
21
22
  }
22
23
  },
@@ -25,6 +26,18 @@ export const set_contact_channel = {
25
26
  uuid: action.uuid,
26
27
  channel: action.channel ? [action.channel] : null
27
28
  };
29
+ },
30
+ fromFormData: (formData) => {
31
+ var _a;
32
+ const channel = (_a = formData.channel) === null || _a === void 0 ? void 0 : _a[0];
33
+ return {
34
+ uuid: formData.uuid,
35
+ type: 'set_contact_channel',
36
+ channel: {
37
+ uuid: channel.uuid || channel.value,
38
+ name: channel.name
39
+ }
40
+ };
28
41
  }
29
42
  };
30
43
  //# sourceMappingURL=set_contact_channel.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"set_contact_channel.js","sourceRoot":"","sources":["../../../../src/flow/actions/set_contact_channel.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,UAAU,CAAC;AAChC,OAAO,EAAgB,aAAa,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AAGlE,MAAM,CAAC,MAAM,mBAAmB,GAAiB;IAC/C,IAAI,EAAE,gBAAgB;IACtB,KAAK,EAAE,aAAa,CAAC,QAAQ;IAC7B,SAAS,EAAE,CAAC,SAAS,CAAC,KAAK,EAAE,SAAS,CAAC,OAAO,EAAE,SAAS,CAAC,UAAU,CAAC;IACrE,MAAM,EAAE,CAAC,KAAW,EAAE,MAAyB,EAAE,EAAE;QACjD,OAAO,IAAI,CAAA,uBAAuB,MAAM,CAAC,OAAO,CAAC,IAAI,iBAAiB,CAAC;IACzE,CAAC;IACD,IAAI,EAAE;QACJ,OAAO,EAAE;YACP,IAAI,EAAE,QAAQ;YACd,KAAK,EAAE,SAAS;YAChB,QAAQ,EAAE,IAAI;YACd,UAAU,EAAE,IAAI;YAChB,SAAS,EAAE,KAAK;YAChB,QAAQ,EAAE,uBAAuB;YACjC,QAAQ,EAAE,MAAM;YAChB,OAAO,EAAE,MAAM;YACf,QAAQ,EAAE,2CAA2C;SACtD;KACF;IACD,UAAU,EAAE,CAAC,MAAyB,EAAE,EAAE;QACxC,OAAO;YACL,IAAI,EAAE,MAAM,CAAC,IAAI;YACjB,OAAO,EAAE,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,IAAI;SAClD,CAAC;IACJ,CAAC;CACF,CAAC","sourcesContent":["import { html } from 'lit-html';\nimport { ActionConfig, ACTION_GROUPS, FlowTypes } from '../types';\nimport { Node, SetContactChannel } from '../../store/flow-definition';\n\nexport const set_contact_channel: ActionConfig = {\n name: 'Update Channel',\n group: ACTION_GROUPS.contacts,\n flowTypes: [FlowTypes.VOICE, FlowTypes.MESSAGE, FlowTypes.BACKGROUND],\n render: (_node: Node, action: SetContactChannel) => {\n return html`<div>Set to <strong>${action.channel.name}</strong></div>`;\n },\n form: {\n channel: {\n type: 'select',\n label: 'Channel',\n required: true,\n searchable: true,\n clearable: false,\n endpoint: '/api/v2/channels.json',\n valueKey: 'uuid',\n nameKey: 'name',\n helpText: 'Select the channel to set for the contact'\n }\n },\n toFormData: (action: SetContactChannel) => {\n return {\n uuid: action.uuid,\n channel: action.channel ? [action.channel] : null\n };\n }\n};\n"]}
1
+ {"version":3,"file":"set_contact_channel.js","sourceRoot":"","sources":["../../../../src/flow/actions/set_contact_channel.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,UAAU,CAAC;AAChC,OAAO,EAAgB,aAAa,EAAY,SAAS,EAAE,MAAM,UAAU,CAAC;AAG5E,MAAM,CAAC,MAAM,mBAAmB,GAAiB;IAC/C,IAAI,EAAE,gBAAgB;IACtB,KAAK,EAAE,aAAa,CAAC,QAAQ;IAC7B,SAAS,EAAE,CAAC,SAAS,CAAC,KAAK,EAAE,SAAS,CAAC,OAAO,EAAE,SAAS,CAAC,UAAU,CAAC;IACrE,MAAM,EAAE,CAAC,KAAW,EAAE,MAAyB,EAAE,EAAE;QACjD,OAAO,IAAI,CAAA,uBAAuB,MAAM,CAAC,OAAO,CAAC,IAAI,iBAAiB,CAAC;IACzE,CAAC;IACD,IAAI,EAAE;QACJ,OAAO,EAAE;YACP,IAAI,EAAE,QAAQ;YACd,KAAK,EAAE,SAAS;YAChB,QAAQ,EAAE,IAAI;YACd,UAAU,EAAE,IAAI;YAChB,SAAS,EAAE,KAAK;YAChB,QAAQ,EAAE,uBAAuB;YACjC,QAAQ,EAAE,MAAM;YAChB,OAAO,EAAE,MAAM;YACf,WAAW,EAAE,gBAAgB;YAC7B,QAAQ,EAAE,2CAA2C;SACtD;KACF;IACD,UAAU,EAAE,CAAC,MAAyB,EAAE,EAAE;QACxC,OAAO;YACL,IAAI,EAAE,MAAM,CAAC,IAAI;YACjB,OAAO,EAAE,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,IAAI;SAClD,CAAC;IACJ,CAAC;IACD,YAAY,EAAE,CAAC,QAAkB,EAAqB,EAAE;;QACtD,MAAM,OAAO,GAAG,MAAA,QAAQ,CAAC,OAAO,0CAAG,CAAC,CAAC,CAAC;QACtC,OAAO;YACL,IAAI,EAAE,QAAQ,CAAC,IAAI;YACnB,IAAI,EAAE,qBAAqB;YAC3B,OAAO,EAAE;gBACP,IAAI,EAAE,OAAO,CAAC,IAAI,IAAI,OAAO,CAAC,KAAK;gBACnC,IAAI,EAAE,OAAO,CAAC,IAAI;aACnB;SACF,CAAC;IACJ,CAAC;CACF,CAAC","sourcesContent":["import { html } from 'lit-html';\nimport { ActionConfig, ACTION_GROUPS, FormData, FlowTypes } from '../types';\nimport { Node, SetContactChannel } from '../../store/flow-definition';\n\nexport const set_contact_channel: ActionConfig = {\n name: 'Update Channel',\n group: ACTION_GROUPS.contacts,\n flowTypes: [FlowTypes.VOICE, FlowTypes.MESSAGE, FlowTypes.BACKGROUND],\n render: (_node: Node, action: SetContactChannel) => {\n return html`<div>Set to <strong>${action.channel.name}</strong></div>`;\n },\n form: {\n channel: {\n type: 'select',\n label: 'Channel',\n required: true,\n searchable: true,\n clearable: false,\n endpoint: '/api/v2/channels.json',\n valueKey: 'uuid',\n nameKey: 'name',\n placeholder: 'Select channel',\n helpText: 'Select the channel to set for the contact'\n }\n },\n toFormData: (action: SetContactChannel) => {\n return {\n uuid: action.uuid,\n channel: action.channel ? [action.channel] : null\n };\n },\n fromFormData: (formData: FormData): SetContactChannel => {\n const channel = formData.channel?.[0];\n return {\n uuid: formData.uuid,\n type: 'set_contact_channel',\n channel: {\n uuid: channel.uuid || channel.value,\n name: channel.name\n }\n };\n }\n};\n"]}
@@ -10,11 +10,13 @@ export const set_contact_status = {
10
10
  },
11
11
  toFormData: (action) => {
12
12
  return {
13
- ...action,
14
- status: {
15
- name: titleCase(action.status || 'active'),
16
- value: action.status || 'active'
17
- }
13
+ uuid: action.uuid,
14
+ status: [
15
+ {
16
+ name: titleCase(action.status || 'active'),
17
+ value: action.status || 'active'
18
+ }
19
+ ]
18
20
  };
19
21
  },
20
22
  fromFormData: (formData) => {
@@ -1 +1 @@
1
- {"version":3,"file":"set_contact_status.js","sourceRoot":"","sources":["../../../../src/flow/actions/set_contact_status.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,UAAU,CAAC;AAChC,OAAO,EAAgB,aAAa,EAAY,SAAS,EAAE,MAAM,UAAU,CAAC;AAE5E,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAExC,MAAM,CAAC,MAAM,kBAAkB,GAAiB;IAC9C,IAAI,EAAE,eAAe;IACrB,KAAK,EAAE,aAAa,CAAC,QAAQ;IAC7B,SAAS,EAAE,CAAC,SAAS,CAAC,KAAK,EAAE,SAAS,CAAC,OAAO,EAAE,SAAS,CAAC,UAAU,CAAC;IACrE,MAAM,EAAE,CAAC,KAAW,EAAE,MAAwB,EAAE,EAAE;QAChD,OAAO,IAAI,CAAA,uBAAuB,SAAS,CAAC,MAAM,CAAC,MAAM,CAAC,iBAAiB,CAAC;IAC9E,CAAC;IACD,UAAU,EAAE,CAAC,MAAwB,EAAE,EAAE;QACvC,OAAO;YACL,GAAG,MAAM;YACT,MAAM,EAAE;gBACN,IAAI,EAAE,SAAS,CAAC,MAAM,CAAC,MAAM,IAAI,QAAQ,CAAC;gBAC1C,KAAK,EAAE,MAAM,CAAC,MAAM,IAAI,QAAQ;aACjC;SACF,CAAC;IACJ,CAAC;IACD,YAAY,EAAE,CAAC,QAAkB,EAAoB,EAAE;QACrD,OAAO;YACL,MAAM,EAAE,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,KAAK;YAChC,IAAI,EAAE,oBAAoB;YAC1B,IAAI,EAAE,QAAQ,CAAC,IAAI;SACpB,CAAC;IACJ,CAAC;IACD,IAAI,EAAE;QACJ,MAAM,EAAE;YACN,IAAI,EAAE,QAAQ;YACd,KAAK,EAAE,QAAQ;YACf,QAAQ,EAAE,IAAI;YACd,UAAU,EAAE,KAAK;YACjB,SAAS,EAAE,KAAK;YAChB,OAAO,EAAE;gBACP,EAAE,KAAK,EAAE,QAAQ,EAAE,IAAI,EAAE,QAAQ,EAAE;gBACnC,EAAE,KAAK,EAAE,UAAU,EAAE,IAAI,EAAE,UAAU,EAAE;gBACvC,EAAE,KAAK,EAAE,SAAS,EAAE,IAAI,EAAE,SAAS,EAAE;gBACrC,EAAE,KAAK,EAAE,SAAS,EAAE,IAAI,EAAE,SAAS,EAAE;aACtC;YACD,QAAQ,EAAE,0CAA0C;SACrD;KACF;CACF,CAAC","sourcesContent":["import { html } from 'lit-html';\nimport { ActionConfig, ACTION_GROUPS, FormData, FlowTypes } from '../types';\nimport { Node, SetContactStatus } from '../../store/flow-definition';\nimport { titleCase } from '../../utils';\n\nexport const set_contact_status: ActionConfig = {\n name: 'Update Status',\n group: ACTION_GROUPS.contacts,\n flowTypes: [FlowTypes.VOICE, FlowTypes.MESSAGE, FlowTypes.BACKGROUND],\n render: (_node: Node, action: SetContactStatus) => {\n return html`<div>Set to <strong>${titleCase(action.status)}</strong></div>`;\n },\n toFormData: (action: SetContactStatus) => {\n return {\n ...action,\n status: {\n name: titleCase(action.status || 'active'),\n value: action.status || 'active'\n }\n };\n },\n fromFormData: (formData: FormData): SetContactStatus => {\n return {\n status: formData.status[0].value,\n type: 'set_contact_status',\n uuid: formData.uuid\n };\n },\n form: {\n status: {\n type: 'select',\n label: 'Status',\n required: true,\n searchable: false,\n clearable: false,\n options: [\n { value: 'active', name: 'Active' },\n { value: 'archived', name: 'Archived' },\n { value: 'stopped', name: 'Stopped' },\n { value: 'blocked', name: 'Blocked' }\n ],\n helpText: 'Select the status to set for the contact'\n }\n }\n};\n"]}
1
+ {"version":3,"file":"set_contact_status.js","sourceRoot":"","sources":["../../../../src/flow/actions/set_contact_status.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,UAAU,CAAC;AAChC,OAAO,EAAgB,aAAa,EAAY,SAAS,EAAE,MAAM,UAAU,CAAC;AAE5E,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAExC,MAAM,CAAC,MAAM,kBAAkB,GAAiB;IAC9C,IAAI,EAAE,eAAe;IACrB,KAAK,EAAE,aAAa,CAAC,QAAQ;IAC7B,SAAS,EAAE,CAAC,SAAS,CAAC,KAAK,EAAE,SAAS,CAAC,OAAO,EAAE,SAAS,CAAC,UAAU,CAAC;IACrE,MAAM,EAAE,CAAC,KAAW,EAAE,MAAwB,EAAE,EAAE;QAChD,OAAO,IAAI,CAAA,uBAAuB,SAAS,CAAC,MAAM,CAAC,MAAM,CAAC,iBAAiB,CAAC;IAC9E,CAAC;IACD,UAAU,EAAE,CAAC,MAAwB,EAAE,EAAE;QACvC,OAAO;YACL,IAAI,EAAE,MAAM,CAAC,IAAI;YACjB,MAAM,EAAE;gBACN;oBACE,IAAI,EAAE,SAAS,CAAC,MAAM,CAAC,MAAM,IAAI,QAAQ,CAAC;oBAC1C,KAAK,EAAE,MAAM,CAAC,MAAM,IAAI,QAAQ;iBACjC;aACF;SACF,CAAC;IACJ,CAAC;IACD,YAAY,EAAE,CAAC,QAAkB,EAAoB,EAAE;QACrD,OAAO;YACL,MAAM,EAAE,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,KAAK;YAChC,IAAI,EAAE,oBAAoB;YAC1B,IAAI,EAAE,QAAQ,CAAC,IAAI;SACpB,CAAC;IACJ,CAAC;IACD,IAAI,EAAE;QACJ,MAAM,EAAE;YACN,IAAI,EAAE,QAAQ;YACd,KAAK,EAAE,QAAQ;YACf,QAAQ,EAAE,IAAI;YACd,UAAU,EAAE,KAAK;YACjB,SAAS,EAAE,KAAK;YAChB,OAAO,EAAE;gBACP,EAAE,KAAK,EAAE,QAAQ,EAAE,IAAI,EAAE,QAAQ,EAAE;gBACnC,EAAE,KAAK,EAAE,UAAU,EAAE,IAAI,EAAE,UAAU,EAAE;gBACvC,EAAE,KAAK,EAAE,SAAS,EAAE,IAAI,EAAE,SAAS,EAAE;gBACrC,EAAE,KAAK,EAAE,SAAS,EAAE,IAAI,EAAE,SAAS,EAAE;aACtC;YACD,QAAQ,EAAE,0CAA0C;SACrD;KACF;CACF,CAAC","sourcesContent":["import { html } from 'lit-html';\nimport { ActionConfig, ACTION_GROUPS, FormData, FlowTypes } from '../types';\nimport { Node, SetContactStatus } from '../../store/flow-definition';\nimport { titleCase } from '../../utils';\n\nexport const set_contact_status: ActionConfig = {\n name: 'Update Status',\n group: ACTION_GROUPS.contacts,\n flowTypes: [FlowTypes.VOICE, FlowTypes.MESSAGE, FlowTypes.BACKGROUND],\n render: (_node: Node, action: SetContactStatus) => {\n return html`<div>Set to <strong>${titleCase(action.status)}</strong></div>`;\n },\n toFormData: (action: SetContactStatus) => {\n return {\n uuid: action.uuid,\n status: [\n {\n name: titleCase(action.status || 'active'),\n value: action.status || 'active'\n }\n ]\n };\n },\n fromFormData: (formData: FormData): SetContactStatus => {\n return {\n status: formData.status[0].value,\n type: 'set_contact_status',\n uuid: formData.uuid\n };\n },\n form: {\n status: {\n type: 'select',\n label: 'Status',\n required: true,\n searchable: false,\n clearable: false,\n options: [\n { value: 'active', name: 'Active' },\n { value: 'archived', name: 'Archived' },\n { value: 'stopped', name: 'Stopped' },\n { value: 'blocked', name: 'Blocked' }\n ],\n helpText: 'Select the status to set for the contact'\n }\n }\n};\n"]}
@@ -157,7 +157,10 @@ export const start_session = {
157
157
  const action = {
158
158
  uuid: formData.uuid,
159
159
  type: 'start_session',
160
- flow: formData.flow[0],
160
+ flow: {
161
+ uuid: formData.flow[0].uuid || formData.flow[0].value,
162
+ name: formData.flow[0].name
163
+ },
161
164
  groups: [],
162
165
  contacts: []
163
166
  };
@@ -173,8 +176,12 @@ export const start_session = {
173
176
  else {
174
177
  // Manual selection - separate contacts and groups
175
178
  const recipients = formData.recipients || [];
176
- action.contacts = recipients.filter((r) => !r.group);
177
- action.groups = recipients.filter((r) => r.group);
179
+ action.contacts = recipients
180
+ .filter((r) => !r.group)
181
+ .map((c) => ({ uuid: c.uuid, name: c.name }));
182
+ action.groups = recipients
183
+ .filter((r) => r.group)
184
+ .map((g) => ({ uuid: g.uuid, name: g.name }));
178
185
  }
179
186
  // Add exclusions if set
180
187
  if (formData.skipContactsInFlow) {
@@ -1 +1 @@
1
- {"version":3,"file":"start_session.js","sourceRoot":"","sources":["../../../../src/flow/actions/start_session.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,UAAU,CAAC;AAChC,OAAO,EAEL,aAAa,EAGb,SAAS,EACV,MAAM,UAAU,CAAC;AAElB,OAAO,EAAE,kBAAkB,EAAE,MAAM,UAAU,CAAC;AAE9C,MAAM,CAAC,MAAM,aAAa,GAAiB;IACzC,IAAI,EAAE,YAAY;IAClB,KAAK,EAAE,aAAa,CAAC,SAAS;IAC9B,SAAS,EAAE,CAAC,SAAS,CAAC,KAAK,EAAE,SAAS,CAAC,OAAO,EAAE,SAAS,CAAC,UAAU,CAAC;IACrE,MAAM,EAAE,CAAC,KAAW,EAAE,MAAoB,EAAE,EAAE;QAC5C,MAAM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MAAM,CAAC,cAAc,GAAG,IAAI,CAAC;QAC/B,CAAC;aAAM,IAAI,cAAc,KAAK,OAAO,EAAE,CAAC;YACtC,MAAM,CAAC,aAAa,GAAG,QAAQ,CAAC,YAAY,IAAI,EAAE,CAAC;QACrD,CAAC;aAAM,CAAC;YACN,kDAAkD;YAClD,MAAM,UAAU,GAAG,QAAQ,CAAC,UAAU,IAAI,EAAE,CAAC;YAC7C,MAAM,CAAC,QAAQ,GAAG,UAAU,CAAC,MAAM,CAAC,CAAC,CAAM,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC;YAC1D,MAAM,CAAC,MAAM,GAAG,UAAU,CAAC,MAAM,CAAC,CAAC,CAAM,EAAE,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC;QACzD,CAAC;QAED,wBAAwB;QACxB,IAAI,QAAQ,CAAC,kBAAkB,EAAE,CAAC;YAChC,MAAM,CAAC,UAAU,GAAG,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC;QAC1C,CAAC;QAED,OAAO,MAAM,CAAC;IAChB,CAAC;CACF,CAAC","sourcesContent":["import { html } from 'lit-html';\nimport {\n ActionConfig,\n ACTION_GROUPS,\n FormData,\n ValidationResult,\n FlowTypes\n} from '../types';\nimport { Node, StartSession } from '../../store/flow-definition';\nimport { renderNamedObjects } from '../utils';\n\nexport const start_session: ActionConfig = {\n name: 'Start Flow',\n group: ACTION_GROUPS.broadcast,\n flowTypes: [FlowTypes.VOICE, FlowTypes.MESSAGE, FlowTypes.BACKGROUND],\n render: (_node: Node, action: StartSession) => {\n const hasGroups = action.groups && action.groups.length > 0;\n const hasContacts = action.contacts && action.contacts.length > 0;\n const hasRecipients = hasGroups || hasContacts;\n\n // Build the recipients display\n let recipientsDisplay = html``;\n if (action.create_contact) {\n recipientsDisplay = html`Create a new contact`;\n } else if ((action as any).contact_query) {\n recipientsDisplay = html`${(action as any).contact_query}`;\n } else if (hasRecipients) {\n const allRecipients = [\n ...(action.contacts || []),\n ...(action.groups || [])\n ];\n recipientsDisplay = html`${renderNamedObjects(\n allRecipients,\n hasGroups ? 'group' : 'contact'\n )}`;\n }\n\n return html`\n <div>\n <div\n style=\"padding: 3px 10px; background: #f5f5f5; padding-bottom: 0px; font-size: 11px; border-radius: var(--curvature); margin-bottom: 10px;\"\n >\n ${recipientsDisplay}\n </div>\n <div style=\"padding: 0px 10px;\">\n ${renderNamedObjects([action.flow], 'flow')}\n </div>\n </div>\n `;\n },\n\n toFormData: (action: StartSession) => {\n const extendedAction = action as StartSession & {\n contact_query?: string;\n exclusions?: { in_a_flow?: boolean };\n };\n\n // Determine start type based on action properties\n let startTypeValue = 'manual';\n if (action.create_contact) {\n startTypeValue = 'create';\n } else if (extendedAction.contact_query) {\n startTypeValue = 'query';\n }\n\n // Map value to full option object for proper display\n const startTypeOptions = [\n { value: 'manual', name: 'Select recipients manually' },\n { value: 'query', name: 'Select a contact with a query' },\n { value: 'create', name: 'Create a new contact' }\n ];\n const startType =\n startTypeOptions.find((opt) => opt.value === startTypeValue) ||\n startTypeOptions[0];\n\n return {\n flow: action.flow ? [action.flow] : null,\n recipients: [...(action.contacts || []), ...(action.groups || [])],\n startType: [startType],\n contactQuery: extendedAction.contact_query || '',\n skipContactsInFlow: extendedAction.exclusions?.in_a_flow || false,\n uuid: action.uuid\n };\n },\n\n form: {\n flow: {\n type: 'select',\n label: 'Flow',\n helpText: 'Select the flow to start',\n required: true,\n searchable: true,\n endpoint: '/api/v2/flows.json',\n valueKey: 'uuid',\n nameKey: 'name',\n placeholder: 'Select a flow...'\n },\n startType: {\n type: 'select',\n label: 'Start Type',\n helpText: 'How should contacts be selected?',\n required: true,\n options: [\n { value: 'manual', name: 'Select recipients manually' },\n { value: 'query', name: 'Select a contact with a query' },\n { value: 'create', name: 'Create a new contact' }\n ]\n },\n recipients: {\n type: 'select',\n label: 'Recipients',\n helpText: 'Select who should be started in the flow',\n options: [],\n multi: true,\n searchable: true,\n endpoint: '/api/v2/contacts.json',\n valueKey: 'uuid',\n nameKey: 'name',\n placeholder: 'Search for contacts or groups...',\n conditions: {\n visible: (formData: FormData) => {\n const startType = formData.startType?.[0]?.value;\n return startType === 'manual';\n }\n }\n },\n contactQuery: {\n type: 'text',\n evaluated: true,\n label: 'Contact Query',\n helpText: 'Only one matching contact will be started',\n placeholder: 'household_id = @fields.household_id',\n conditions: {\n visible: (formData: FormData) => {\n const startType = formData.startType?.[0]?.value;\n return startType === 'query';\n }\n }\n },\n skipContactsInFlow: {\n type: 'checkbox',\n label: 'Skip contacts currently in a flow',\n helpText: 'Avoid interrupting a contact who is already in a flow'\n }\n },\n\n layout: [\n 'flow',\n 'startType',\n 'recipients',\n 'contactQuery',\n 'skipContactsInFlow'\n ],\n\n validate: (formData: FormData): ValidationResult => {\n const errors: { [key: string]: string } = {};\n\n const startType = formData.startType?.[0]?.value;\n\n // Check if manual selection has recipients\n if (\n startType === 'manual' &&\n (!formData.recipients || formData.recipients.length === 0)\n ) {\n errors.recipients = 'At least one contact or group must be selected';\n }\n\n // Check if query has a query string\n if (\n startType === 'query' &&\n (!formData.contactQuery || !formData.contactQuery.trim())\n ) {\n errors.contactQuery = 'Contact query is required';\n }\n\n return {\n valid: Object.keys(errors).length === 0,\n errors\n };\n },\n\n fromFormData: (formData: FormData): StartSession => {\n const action: StartSession & {\n contact_query?: string;\n exclusions?: { in_a_flow: boolean };\n } = {\n uuid: formData.uuid,\n type: 'start_session',\n flow: formData.flow[0],\n groups: [],\n contacts: []\n };\n\n // Get the start type value from array\n const startTypeValue = formData.startType[0].value;\n\n // Handle different start types\n if (startTypeValue === 'create') {\n action.create_contact = true;\n } else if (startTypeValue === 'query') {\n action.contact_query = formData.contactQuery || '';\n } else {\n // Manual selection - separate contacts and groups\n const recipients = formData.recipients || [];\n action.contacts = recipients.filter((r: any) => !r.group);\n action.groups = recipients.filter((r: any) => r.group);\n }\n\n // Add exclusions if set\n if (formData.skipContactsInFlow) {\n action.exclusions = { in_a_flow: true };\n }\n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GAAG,UAAU;iBACvB,MAAM,CAAC,CAAC,CAAM,EAAE,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC;iBAC3B,GAAG,CAAC,CAAC,CAAM,EAAE,EAAE,CAAC,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC;QACvD,CAAC;QAED,wBAAwB;QACxB,IAAI,QAAQ,CAAC,kBAAkB,EAAE,CAAC;YAChC,MAAM,CAAC,UAAU,GAAG,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC;QAC1C,CAAC;QAED,OAAO,MAAM,CAAC;IAChB,CAAC;CACF,CAAC","sourcesContent":["import { html } from 'lit-html';\nimport {\n ActionConfig,\n ACTION_GROUPS,\n FormData,\n ValidationResult,\n FlowTypes\n} from '../types';\nimport { Node, StartSession } from '../../store/flow-definition';\nimport { renderNamedObjects } from '../utils';\n\nexport const start_session: ActionConfig = {\n name: 'Start Flow',\n group: ACTION_GROUPS.broadcast,\n flowTypes: [FlowTypes.VOICE, FlowTypes.MESSAGE, FlowTypes.BACKGROUND],\n render: (_node: Node, action: StartSession) => {\n const hasGroups = action.groups && action.groups.length > 0;\n const hasContacts = action.contacts && action.contacts.length > 0;\n const hasRecipients = hasGroups || hasContacts;\n\n // Build the recipients display\n let recipientsDisplay = html``;\n if (action.create_contact) {\n recipientsDisplay = html`Create a new contact`;\n } else if ((action as any).contact_query) {\n recipientsDisplay = html`${(action as any).contact_query}`;\n } else if (hasRecipients) {\n const allRecipients = [\n ...(action.contacts || []),\n ...(action.groups || [])\n ];\n recipientsDisplay = html`${renderNamedObjects(\n allRecipients,\n hasGroups ? 'group' : 'contact'\n )}`;\n }\n\n return html`\n <div>\n <div\n style=\"padding: 3px 10px; background: #f5f5f5; padding-bottom: 0px; font-size: 11px; border-radius: var(--curvature); margin-bottom: 10px;\"\n >\n ${recipientsDisplay}\n </div>\n <div style=\"padding: 0px 10px;\">\n ${renderNamedObjects([action.flow], 'flow')}\n </div>\n </div>\n `;\n },\n\n toFormData: (action: StartSession) => {\n const extendedAction = action as StartSession & {\n contact_query?: string;\n exclusions?: { in_a_flow?: boolean };\n };\n\n // Determine start type based on action properties\n let startTypeValue = 'manual';\n if (action.create_contact) {\n startTypeValue = 'create';\n } else if (extendedAction.contact_query) {\n startTypeValue = 'query';\n }\n\n // Map value to full option object for proper display\n const startTypeOptions = [\n { value: 'manual', name: 'Select recipients manually' },\n { value: 'query', name: 'Select a contact with a query' },\n { value: 'create', name: 'Create a new contact' }\n ];\n const startType =\n startTypeOptions.find((opt) => opt.value === startTypeValue) ||\n startTypeOptions[0];\n\n return {\n flow: action.flow ? [action.flow] : null,\n recipients: [...(action.contacts || []), ...(action.groups || [])],\n startType: [startType],\n contactQuery: extendedAction.contact_query || '',\n skipContactsInFlow: extendedAction.exclusions?.in_a_flow || false,\n uuid: action.uuid\n };\n },\n\n form: {\n flow: {\n type: 'select',\n label: 'Flow',\n helpText: 'Select the flow to start',\n required: true,\n searchable: true,\n endpoint: '/api/v2/flows.json',\n valueKey: 'uuid',\n nameKey: 'name',\n placeholder: 'Select a flow...'\n },\n startType: {\n type: 'select',\n label: 'Start Type',\n helpText: 'How should contacts be selected?',\n required: true,\n options: [\n { value: 'manual', name: 'Select recipients manually' },\n { value: 'query', name: 'Select a contact with a query' },\n { value: 'create', name: 'Create a new contact' }\n ]\n },\n recipients: {\n type: 'select',\n label: 'Recipients',\n helpText: 'Select who should be started in the flow',\n options: [],\n multi: true,\n searchable: true,\n endpoint: '/api/v2/contacts.json',\n valueKey: 'uuid',\n nameKey: 'name',\n placeholder: 'Search for contacts or groups...',\n conditions: {\n visible: (formData: FormData) => {\n const startType = formData.startType?.[0]?.value;\n return startType === 'manual';\n }\n }\n },\n contactQuery: {\n type: 'text',\n evaluated: true,\n label: 'Contact Query',\n helpText: 'Only one matching contact will be started',\n placeholder: 'household_id = @fields.household_id',\n conditions: {\n visible: (formData: FormData) => {\n const startType = formData.startType?.[0]?.value;\n return startType === 'query';\n }\n }\n },\n skipContactsInFlow: {\n type: 'checkbox',\n label: 'Skip contacts currently in a flow',\n helpText: 'Avoid interrupting a contact who is already in a flow'\n }\n },\n\n layout: [\n 'flow',\n 'startType',\n 'recipients',\n 'contactQuery',\n 'skipContactsInFlow'\n ],\n\n validate: (formData: FormData): ValidationResult => {\n const errors: { [key: string]: string } = {};\n\n const startType = formData.startType?.[0]?.value;\n\n // Check if manual selection has recipients\n if (\n startType === 'manual' &&\n (!formData.recipients || formData.recipients.length === 0)\n ) {\n errors.recipients = 'At least one contact or group must be selected';\n }\n\n // Check if query has a query string\n if (\n startType === 'query' &&\n (!formData.contactQuery || !formData.contactQuery.trim())\n ) {\n errors.contactQuery = 'Contact query is required';\n }\n\n return {\n valid: Object.keys(errors).length === 0,\n errors\n };\n },\n\n fromFormData: (formData: FormData): StartSession => {\n const action: StartSession & {\n contact_query?: string;\n exclusions?: { in_a_flow: boolean };\n } = {\n uuid: formData.uuid,\n type: 'start_session',\n flow: {\n uuid: formData.flow[0].uuid || formData.flow[0].value,\n name: formData.flow[0].name\n },\n groups: [],\n contacts: []\n };\n\n // Get the start type value from array\n const startTypeValue = formData.startType[0].value;\n\n // Handle different start types\n if (startTypeValue === 'create') {\n action.create_contact = true;\n } else if (startTypeValue === 'query') {\n action.contact_query = formData.contactQuery || '';\n } else {\n // Manual selection - separate contacts and groups\n const recipients = formData.recipients || [];\n action.contacts = recipients\n .filter((r: any) => !r.group)\n .map((c: any) => ({ uuid: c.uuid, name: c.name }));\n action.groups = recipients\n .filter((r: any) => r.group)\n .map((g: any) => ({ uuid: g.uuid, name: g.name }));\n }\n\n // Add exclusions if set\n if (formData.skipContactsInFlow) {\n action.exclusions = { in_a_flow: true };\n }\n\n return action;\n }\n};\n"]}
@@ -18,6 +18,7 @@ import { remove_contact_groups } from './actions/remove_contact_groups';
18
18
  import { request_optin } from './actions/request_optin';
19
19
  import { say_msg } from './actions/say_msg';
20
20
  import { play_audio } from './actions/play_audio';
21
+ import { enter_flow } from './actions/enter_flow';
21
22
  // Import all node configurations
22
23
  import { execute_actions } from './nodes/execute_actions';
23
24
  import { split_by_airtime } from './nodes/split_by_airtime';
@@ -28,11 +29,14 @@ import { split_by_random } from './nodes/split_by_random';
28
29
  import { split_by_run_result } from './nodes/split_by_run_result';
29
30
  import { split_by_scheme } from './nodes/split_by_scheme';
30
31
  import { split_by_subflow } from './nodes/split_by_subflow';
32
+ import { terminal } from './nodes/terminal';
31
33
  import { split_by_ticket } from './nodes/split_by_ticket';
32
34
  import { split_by_webhook } from './nodes/split_by_webhook';
33
35
  import { split_by_resthook } from './nodes/split_by_resthook';
34
36
  import { split_by_llm } from './nodes/split_by_llm';
35
37
  import { split_by_llm_categorize } from './nodes/split_by_llm_categorize';
38
+ import { wait_for_audio } from './nodes/wait_for_audio';
39
+ import { wait_for_dial } from './nodes/wait_for_dial';
36
40
  import { wait_for_digits } from './nodes/wait_for_digits';
37
41
  import { wait_for_menu } from './nodes/wait_for_menu';
38
42
  import { wait_for_response } from './nodes/wait_for_response';
@@ -53,7 +57,8 @@ export const ACTION_CONFIG = registerConfigWithAliases({
53
57
  set_contact_status,
54
58
  add_contact_urn,
55
59
  add_input_labels,
56
- request_optin
60
+ request_optin,
61
+ enter_flow
57
62
  });
58
63
  // Helper to register a config and its aliases
59
64
  function registerConfigWithAliases(config) {
@@ -82,9 +87,12 @@ export const NODE_CONFIG = registerConfigWithAliases({
82
87
  split_by_ticket,
83
88
  split_by_webhook,
84
89
  split_by_resthook,
85
- wait_for_digits,
86
90
  wait_for_menu,
91
+ wait_for_digits,
92
+ wait_for_audio,
93
+ wait_for_dial,
87
94
  wait_for_response,
88
- split_by_airtime
95
+ split_by_airtime,
96
+ terminal // Temporary: legacy support for terminal nodes (see AppState.ts)
89
97
  });
90
98
  //# sourceMappingURL=config.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"config.js","sourceRoot":"","sources":["../../../src/flow/config.ts"],"names":[],"mapp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AM,CAAC,KAAK,CAAC,GAAG,GAAG,CAAC;YACtB,CAAC,CAAC,CAAC;QACL,CAAC;IACH,CAAC,CAAC,CAAC;IAEH,OAAO,MAAM,CAAC;AAChB,CAAC;AAED,MAAM,CAAC,MAAM,WAAW,GAEpB,yBAAyB,CAAC;IAC5B,eAAe;IACf,sBAAsB;IACtB,mBAAmB;IACnB,eAAe;IACf,YAAY;IACZ,uBAAuB;IACvB,eAAe;IACf,mBAAmB;IACnB,eAAe;IACf,gBAAgB;IAChB,eAAe;IACf,gBAAgB;IAChB,iBAAiB;IACjB,eAAe;IACf,aAAa;IACb,iBAAiB;IACjB,gBAAgB;CACjB,CAAC,CAAC","sourcesContent":["// Re-export all types and utilities\nexport * from './types';\nimport type { ActionConfig, NodeConfig } from './types';\n\n// Import all action configurations\nimport { add_input_labels } from './actions/add_input_labels';\nimport { add_contact_urn } from './actions/add_contact_urn';\nimport { set_contact_field } from './actions/set_contact_field';\nimport { set_contact_channel } from './actions/set_contact_channel';\nimport { set_contact_language } from './actions/set_contact_language';\nimport { set_contact_status } from './actions/set_contact_status';\nimport { send_broadcast } from './actions/send_broadcast';\nimport { set_run_result } from './actions/set_run_result';\nimport { send_msg } from './actions/send_msg';\nimport { send_email } from './actions/send_email';\nimport { start_session } from './actions/start_session';\nimport { set_contact_name } from './actions/set_contact_name';\nimport { add_contact_groups } from './actions/add_contact_groups';\nimport { remove_contact_groups } from './actions/remove_contact_groups';\nimport { request_optin } from './actions/request_optin';\nimport { say_msg } from './actions/say_msg';\nimport { play_audio } from './actions/play_audio';\n\n// Import all node configurations\nimport { execute_actions } from './nodes/execute_actions';\nimport { split_by_airtime } from './nodes/split_by_airtime';\nimport { split_by_contact_field } from './nodes/split_by_contact_field';\nimport { split_by_expression } from './nodes/split_by_expression';\nimport { split_by_groups } from './nodes/split_by_groups';\nimport { split_by_random } from './nodes/split_by_random';\nimport { split_by_run_result } from './nodes/split_by_run_result';\nimport { split_by_scheme } from './nodes/split_by_scheme';\nimport { split_by_subflow } from './nodes/split_by_subflow';\nimport { split_by_ticket } from './nodes/split_by_ticket';\nimport { split_by_webhook } from './nodes/split_by_webhook';\nimport { split_by_resthook } from './nodes/split_by_resthook';\nimport { split_by_llm } from './nodes/split_by_llm';\nimport { split_by_llm_categorize } from './nodes/split_by_llm_categorize';\nimport { wait_for_digits } from './nodes/wait_for_digits';\nimport { wait_for_menu } from './nodes/wait_for_menu';\nimport { wait_for_response } from './nodes/wait_for_response';\n\nexport const ACTION_CONFIG: {\n [key: string]: ActionConfig;\n} = registerConfigWithAliases({\n say_msg,\n play_audio,\n set_contact_field,\n send_broadcast,\n set_run_result,\n send_msg,\n send_email,\n start_session,\n set_contact_name,\n add_contact_groups,\n remove_contact_groups,\n set_contact_channel,\n set_contact_language,\n set_contact_status,\n add_contact_urn,\n add_input_labels,\n request_optin\n});\n\n// Helper to register a config and its aliases\nfunction registerConfigWithAliases<T extends NodeConfig | ActionConfig>(\n config: Record<string, T>\n): Record<string, T> {\n const result = { ...config };\n\n // Register aliases for each config\n Object.values(config).forEach((cfg) => {\n if (cfg.aliases) {\n cfg.aliases.forEach((alias) => {\n result[alias] = cfg;\n });\n }\n });\n\n return result;\n}\n\nexport const NODE_CONFIG: {\n [key: string]: NodeConfig;\n} = registerConfigWithAliases({\n execute_actions,\n split_by_contact_field,\n split_by_expression,\n split_by_groups,\n split_by_llm,\n split_by_llm_categorize,\n split_by_random,\n split_by_run_result,\n split_by_scheme,\n split_by_subflow,\n split_by_ticket,\n split_by_webhook,\n split_by_resthook,\n wait_for_digits,\n wait_for_menu,\n wait_for_response,\n split_by_airtime\n});\n"]}
1
+ {"version":3,"file":"config.js","sourceRoot":"","sources":["../../../src/flow/config.ts"],"names":[],"mappings":"AAAA,oCAAoC;AACpC,cAAc,SAAS,CAAC;AAGxB,mCAAmC;AACnC,OAAO,EAAE,gBAAgB,EAAE,MAAM,4BAA4B,CAAC;AAC9D,OAAO,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAC;A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AAC,OAAO,CAAC,CAAC,KAAK,EAAE,EAAE;gBAC5B,MAAM,CAAC,KAAK,CAAC,GAAG,GAAG,CAAC;YACtB,CAAC,CAAC,CAAC;QACL,CAAC;IACH,CAAC,CAAC,CAAC;IAEH,OAAO,MAAM,CAAC;AAChB,CAAC;AAED,MAAM,CAAC,MAAM,WAAW,GAEpB,yBAAyB,CAAC;IAC5B,eAAe;IACf,sBAAsB;IACtB,mBAAmB;IACnB,eAAe;IACf,YAAY;IACZ,uBAAuB;IACvB,eAAe;IACf,mBAAmB;IACnB,eAAe;IACf,gBAAgB;IAChB,eAAe;IACf,gBAAgB;IAChB,iBAAiB;IACjB,aAAa;IACb,eAAe;IACf,cAAc;IACd,aAAa;IACb,iBAAiB;IACjB,gBAAgB;IAChB,QAAQ,CAAC,iEAAiE;CAC3E,CAAC,CAAC","sourcesContent":["// Re-export all types and utilities\nexport * from './types';\nimport type { ActionConfig, NodeConfig } from './types';\n\n// Import all action configurations\nimport { add_input_labels } from './actions/add_input_labels';\nimport { add_contact_urn } from './actions/add_contact_urn';\nimport { set_contact_field } from './actions/set_contact_field';\nimport { set_contact_channel } from './actions/set_contact_channel';\nimport { set_contact_language } from './actions/set_contact_language';\nimport { set_contact_status } from './actions/set_contact_status';\nimport { send_broadcast } from './actions/send_broadcast';\nimport { set_run_result } from './actions/set_run_result';\nimport { send_msg } from './actions/send_msg';\nimport { send_email } from './actions/send_email';\nimport { start_session } from './actions/start_session';\nimport { set_contact_name } from './actions/set_contact_name';\nimport { add_contact_groups } from './actions/add_contact_groups';\nimport { remove_contact_groups } from './actions/remove_contact_groups';\nimport { request_optin } from './actions/request_optin';\nimport { say_msg } from './actions/say_msg';\nimport { play_audio } from './actions/play_audio';\nimport { enter_flow } from './actions/enter_flow';\n\n// Import all node configurations\nimport { execute_actions } from './nodes/execute_actions';\nimport { split_by_airtime } from './nodes/split_by_airtime';\nimport { split_by_contact_field } from './nodes/split_by_contact_field';\nimport { split_by_expression } from './nodes/split_by_expression';\nimport { split_by_groups } from './nodes/split_by_groups';\nimport { split_by_random } from './nodes/split_by_random';\nimport { split_by_run_result } from './nodes/split_by_run_result';\nimport { split_by_scheme } from './nodes/split_by_scheme';\nimport { split_by_subflow } from './nodes/split_by_subflow';\nimport { terminal } from './nodes/terminal';\nimport { split_by_ticket } from './nodes/split_by_ticket';\nimport { split_by_webhook } from './nodes/split_by_webhook';\nimport { split_by_resthook } from './nodes/split_by_resthook';\nimport { split_by_llm } from './nodes/split_by_llm';\nimport { split_by_llm_categorize } from './nodes/split_by_llm_categorize';\nimport { wait_for_audio } from './nodes/wait_for_audio';\nimport { wait_for_dial } from './nodes/wait_for_dial';\nimport { wait_for_digits } from './nodes/wait_for_digits';\nimport { wait_for_menu } from './nodes/wait_for_menu';\nimport { wait_for_response } from './nodes/wait_for_response';\n\nexport const ACTION_CONFIG: {\n [key: string]: ActionConfig;\n} = registerConfigWithAliases({\n say_msg,\n play_audio,\n set_contact_field,\n send_broadcast,\n set_run_result,\n send_msg,\n send_email,\n start_session,\n set_contact_name,\n add_contact_groups,\n remove_contact_groups,\n set_contact_channel,\n set_contact_language,\n set_contact_status,\n add_contact_urn,\n add_input_labels,\n request_optin,\n enter_flow\n});\n\n// Helper to register a config and its aliases\nfunction registerConfigWithAliases<T extends NodeConfig | ActionConfig>(\n config: Record<string, T>\n): Record<string, T> {\n const result = { ...config };\n\n // Register aliases for each config\n Object.values(config).forEach((cfg) => {\n if (cfg.aliases) {\n cfg.aliases.forEach((alias) => {\n result[alias] = cfg;\n });\n }\n });\n\n return result;\n}\n\nexport const NODE_CONFIG: {\n [key: string]: NodeConfig;\n} = registerConfigWithAliases({\n execute_actions,\n split_by_contact_field,\n split_by_expression,\n split_by_groups,\n split_by_llm,\n split_by_llm_categorize,\n split_by_random,\n split_by_run_result,\n split_by_scheme,\n split_by_subflow,\n split_by_ticket,\n split_by_webhook,\n split_by_resthook,\n wait_for_menu,\n wait_for_digits,\n wait_for_audio,\n wait_for_dial,\n wait_for_response,\n split_by_airtime,\n terminal // Temporary: legacy support for terminal nodes (see AppState.ts)\n});\n"]}
@@ -103,7 +103,7 @@ export const createRulesItemConfig = () => ({
103
103
  multi: false,
104
104
  options: [], // Will be set by the caller
105
105
  flavor: 'xsmall',
106
- width: '200px'
106
+ width: '220px'
107
107
  },
108
108
  value1: {
109
109
  type: 'text',
@@ -1 +1 @@
1
- {"version":3,"file":"shared-rules.js","sourceRoot":"","sources":["../../../../src/flow/nodes/shared-rules.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AACjD,OAAO,EAAE,2BAA2B,EAAE,MAAM,aAAa,CAAC;AAG1D;;;GAGG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,QAAa,EAAU,EAAE;IACxD,IAAI,OAAO,QAAQ,KAAK,QAAQ,EAAE,CAAC;QACjC,OAAO,QAAQ,CAAC,IAAI,EAAE,CAAC;IACzB,CAAC;SAAM,IAAI,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC,IAAI,QAAQ,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QAC1D,MAAM,aAAa,GAAG,QAAQ,CAAC,CAAC,CAAC,CAAC;QAClC,IACE,aAAa;YACb,OAAO,aAAa,KAAK,QAAQ;YACjC,aAAa,CAAC,KAAK,EACnB,CAAC;YACD,OAAO,aAAa,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC;QACpC,CAAC;IACH,CAAC;SAAM,IAAI,QAAQ,IAAI,OAAO,QAAQ,KAAK,QAAQ,IAAI,QAAQ,CAAC,KAAK,EAAE,CAAC;QACtE,OAAO,QAAQ,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC;IAC/B,CAAC;IACD,OAAO,EAAE,CAAC;AACZ,CAAC,CAAC;AAEF;;;GAGG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG,CAAC,IAAS,EAAW,EAAE;IACpD,8CAA8C;IAC9C,MAAM,aAAa,GAAG,gBAAgB,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MAAM;oBACd,QAAQ,EAAE,QAAQ,CAAC,IAAI;iBACxB,CAAC,CAAC;YACL,CAAC;QACH,CAAC,CAAC,CAAC;IACL,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC,CAAC;AAEF;;GAEG;AACH,SAAS,gBAAgB,CAAC,YAAoB;IAC5C,OAAO,CAAC,aAAa,EAAE,OAAO,EAAE,eAAe,EAAE,SAAS,CAAC,CAAC,QAAQ,CAClE,YAAY,CACb,CAAC;AACJ,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,sBAAsB,GAAG,CACpC,eAAsB,EACtB,WAAmB,sCAAsC,EACzD,EAAE,CAAC,CAAC;IACJ,IAAI,EAAE,OAAgB;IACtB,QAAQ;IACR,SAAS,EAAE,MAAM;IACjB,QAAQ,EAAE,CAAC;IACX,QAAQ,EAAE,GAAG;IACb,QAAQ,EAAE,IAAI;IACd,iBAAiB,EAAE,IAAI;IACvB,WAAW,EAAE,eAAe;IAC5B,YAAY,EAAE,2BAA2B,EAAE;IAC3C,UAAU,EAAE;QACV,GAAG,qBAAqB,EAAE;QAC1B,QAAQ,EAAE;YACR,GAAG,qBAAqB,EAAE,CAAC,QAAQ;YACnC,OAAO,EAAE,eAAe;SACzB;KACF;CACF,CAAC,CAAC","sourcesContent":["import { getOperatorConfig } from '../operators';\nimport { generateDefaultCategoryName } from '../../utils';\nimport { FormData } from '../types';\n\n/**\n * Shared helper function to get operator value from various formats.\n * Handles string, object, and array formats that can come from the form system.\n */\nexport const getOperatorValue = (operator: any): string => {\n if (typeof operator === 'string') {\n return operator.trim();\n } else if (Array.isArray(operator) && operator.length > 0) {\n const firstOperator = operator[0];\n if (\n firstOperator &&\n typeof firstOperator === 'object' &&\n firstOperator.value\n ) {\n return firstOperator.value.trim();\n }\n } else if (operator && typeof operator === 'object' && operator.value) {\n return operator.value.trim();\n }\n return '';\n};\n\n/**\n * Shared isEmptyItem function for rules array.\n * Determines if a rule item is considered empty and should be filtered out.\n */\nexport const isEmptyRuleItem = (item: any): boolean => {\n // Check if operator and category are provided\n const operatorValue = getOperatorValue(item.operator);\n if (!operatorValue || !item.category || item.category.trim() === '') {\n return true;\n }\n\n // Check if value is required based on operator configuration\n const operatorConfig = getOperatorConfig(operatorValue);\n if (operatorConfig && operatorConfig.operands === 1) {\n return !item.value1 || item.value1.trim() === '';\n } else if (operatorConfig && operatorConfig.operands === 2) {\n return (\n !item.value1 ||\n item.value1.trim() === '' ||\n !item.value2 ||\n item.value2.trim() === ''\n );\n }\n\n return false;\n};\n\n/**\n * Shared onItemChange function for rules array.\n * Handles auto-updating category names based on operator and value changes.\n */\nexport const createRuleItemChangeHandler = () => {\n return (itemIndex: number, field: string, value: any, allItems: any[]) => {\n const updatedItems = [...allItems];\n const item = { ...updatedItems[itemIndex] };\n\n // Update the changed field\n item[field] = value;\n\n // Get operator values (before and after the change)\n const oldItem = allItems[itemIndex] || {};\n const oldOperatorValue =\n field === 'operator'\n ? getOperatorValue(oldItem.operator)\n : getOperatorValue(item.operator);\n const newOperatorValue = getOperatorValue(item.operator);\n\n // Calculate what the default category name should be before the change\n const oldDefaultCategory = generateDefaultCategoryName(\n oldOperatorValue,\n getOperatorConfig,\n field === 'value1' ? oldItem.value1 : item.value1,\n field === 'value2' ? oldItem.value2 : item.value2\n );\n\n // Calculate what the new default category name should be after the change\n const newDefaultCategory = generateDefaultCategoryName(\n newOperatorValue,\n getOperatorConfig,\n item.value1,\n item.value2\n );\n\n // Determine if we should auto-update the category\n const shouldUpdateCategory =\n !item.category ||\n item.category.trim() === '' ||\n item.category === oldDefaultCategory;\n\n // Auto-populate or update category if conditions are met\n if (shouldUpdateCategory && newDefaultCategory) {\n item.category = newDefaultCategory;\n }\n\n updatedItems[itemIndex] = item;\n return updatedItems;\n };\n};\n\n/**\n * Shared visibility condition for value1 field.\n */\nexport const value1VisibilityCondition = (formData: Record<string, any>) => {\n const operatorValue = getOperatorValue(formData.operator);\n const operatorConfig = getOperatorConfig(operatorValue);\n return operatorConfig ? operatorConfig.operands >= 1 : true;\n};\n\n/**\n * Shared visibility condition for value2 field.\n */\nexport const value2VisibilityCondition = (formData: Record<string, any>) => {\n const operatorValue = getOperatorValue(formData.operator);\n const operatorConfig = getOperatorConfig(operatorValue);\n return operatorConfig ? operatorConfig.operands === 2 : false;\n};\n\n/**\n * Shared item configuration for rules array.\n * This defines the operator, value1, value2, and category fields.\n */\nexport const createRulesItemConfig = () => ({\n operator: {\n type: 'select' as const,\n required: true,\n multi: false,\n options: [], // Will be set by the caller\n flavor: 'xsmall' as const,\n width: '200px'\n },\n value1: {\n type: 'text' as const,\n flavor: 'xsmall' as const,\n conditions: {\n visible: value1VisibilityCondition\n }\n },\n value2: {\n type: 'text' as const,\n flavor: 'xsmall' as const,\n conditions: {\n visible: value2VisibilityCondition\n }\n },\n category: {\n type: 'text' as const,\n placeholder: 'Category',\n required: true,\n maxWidth: '120px',\n flavor: 'xsmall' as const\n }\n});\n\n/**\n * Shared function to extract rules from form data.\n * Filters and transforms form rules into the format expected by createRulesRouter.\n */\nexport const extractUserRules = (formData: FormData) => {\n return (formData.rules || [])\n .filter((rule: any) => {\n const operatorValue = getOperatorValue(rule?.operator);\n if (\n !operatorValue ||\n !rule?.category ||\n operatorValue === '' ||\n rule.category.trim() === ''\n ) {\n return false;\n }\n\n const operatorConfig = getOperatorConfig(operatorValue);\n if (operatorConfig && operatorConfig.operands === 1) {\n return rule?.value1 && rule.value1.trim() !== '';\n } else if (operatorConfig && operatorConfig.operands === 2) {\n return (\n rule?.value1 &&\n rule.value1.trim() !== '' &&\n rule?.value2 &&\n rule.value2.trim() !== ''\n );\n }\n\n return true;\n })\n .map((rule: any) => {\n const operatorValue = getOperatorValue(rule.operator);\n const operatorConfig = getOperatorConfig(operatorValue);\n\n let value = '';\n\n if (operatorConfig && operatorConfig.operands === 1) {\n value = rule.value1 ? rule.value1.trim() : '';\n } else if (operatorConfig && operatorConfig.operands === 2) {\n const val1 = rule.value1 ? rule.value1.trim() : '';\n const val2 = rule.value2 ? rule.value2.trim() : '';\n value = `${val1} ${val2}`.trim();\n } else {\n value = '';\n }\n\n return {\n operator: operatorValue,\n value: value,\n category: rule.category.trim()\n };\n });\n};\n\n/**\n * Shared function to transform router cases to form rules.\n * Converts node router cases back into the form data structure.\n */\nexport const casesToFormRules = (node: any) => {\n const rules = [];\n if (node.router?.cases && node.router?.categories) {\n node.router.cases.forEach((case_: any) => {\n // Find the category for this case\n const category = node.router!.categories.find(\n (cat: any) => cat.uuid === case_.category_uuid\n );\n\n // Skip system categories\n if (category && !isSystemCategory(category.name)) {\n // Handle different operator types\n const operatorConfig = getOperatorConfig(case_.type);\n const operatorDisplayName = operatorConfig\n ? operatorConfig.name\n : case_.type;\n let value1 = '';\n let value2 = '';\n\n if (operatorConfig && operatorConfig.operands === 0) {\n value1 = '';\n value2 = '';\n } else if (operatorConfig && operatorConfig.operands === 1) {\n value1 = case_.arguments.join(' ');\n value2 = '';\n } else if (operatorConfig && operatorConfig.operands === 2) {\n value1 = case_.arguments[0] || '';\n value2 = case_.arguments[1] || '';\n } else {\n value1 = case_.arguments.join(' ');\n value2 = '';\n }\n\n rules.push({\n operator: { value: case_.type, name: operatorDisplayName },\n value1: value1,\n value2: value2,\n category: category.name\n });\n }\n });\n }\n return rules;\n};\n\n/**\n * Helper to check if a category is a system category\n */\nfunction isSystemCategory(categoryName: string): boolean {\n return ['No Response', 'Other', 'All Responses', 'Timeout'].includes(\n categoryName\n );\n}\n\n/**\n * Creates a complete rules array configuration for forms.\n * This is the shared configuration used by both wait_for_response and split_by_expression.\n *\n * @param operatorOptions - The operator options to use (from operatorsToSelectOptions)\n * @param helpText - The help text to display for the rules array\n * @returns A complete array field configuration object\n */\nexport const createRulesArrayConfig = (\n operatorOptions: any[],\n helpText: string = 'Define rules to categorize responses'\n) => ({\n type: 'array' as const,\n helpText,\n itemLabel: 'Rule',\n minItems: 0,\n maxItems: 100,\n sortable: true,\n maintainEmptyItem: true,\n isEmptyItem: isEmptyRuleItem,\n onItemChange: createRuleItemChangeHandler(),\n itemConfig: {\n ...createRulesItemConfig(),\n operator: {\n ...createRulesItemConfig().operator,\n options: operatorOptions\n }\n }\n});\n"]}
1
+ {"version":3,"file":"shared-rules.js","sourceRoot":"","sources":["../../../../src/flow/nodes/shared-rules.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AACjD,OAAO,EAAE,2BAA2B,EAAE,MAAM,aAAa,CAAC;AAG1D;;;GAGG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,QAAa,EAAU,EAAE;IACxD,IAAI,OAAO,QAAQ,KAAK,QAAQ,EAAE,CAAC;QACjC,OAAO,QAAQ,CAAC,IAAI,EAAE,CAAC;IACzB,CAAC;SAAM,IAAI,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC,IAAI,QAAQ,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QAC1D,MAAM,aAAa,GAAG,QAAQ,CAAC,CAAC,CAAC,CAAC;QAClC,IACE,aAAa;YACb,OAAO,aAAa,KAAK,QAAQ;YACjC,aAAa,CAAC,KAAK,EACnB,CAAC;YACD,OAAO,aAAa,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC;QACpC,CAAC;IACH,CAAC;SAAM,IAAI,QAAQ,IAAI,OAAO,QAAQ,KAAK,QAAQ,IAAI,QAAQ,CAAC,KAAK,EAAE,CAAC;QACtE,OAAO,QAAQ,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC;IAC/B,CAAC;IACD,OAAO,EAAE,CAAC;AACZ,CAAC,CAAC;AAEF;;;GAGG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG,CAAC,IAAS,EAAW,EAAE;IACpD,8CAA8C;IAC9C,MAAM,aAAa,GAAG,gBAAgB,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;IACtD,IAAI,CAAC,aAAa,IAAI,CAAC,IAAI,CAAC,QAAQ,IAAI,IAAI,CAAC,QAA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AAO,KAAK,CAAC;AACf,CAAC,CAAC;AAEF;;GAEG;AACH,SAAS,gBAAgB,CAAC,YAAoB;IAC5C,OAAO,CAAC,aAAa,EAAE,OAAO,EAAE,eAAe,EAAE,SAAS,CAAC,CAAC,QAAQ,CAClE,YAAY,CACb,CAAC;AACJ,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,sBAAsB,GAAG,CACpC,eAAsB,EACtB,WAAmB,sCAAsC,EACzD,EAAE,CAAC,CAAC;IACJ,IAAI,EAAE,OAAgB;IACtB,QAAQ;IACR,SAAS,EAAE,MAAM;IACjB,QAAQ,EAAE,CAAC;IACX,QAAQ,EAAE,GAAG;IACb,QAAQ,EAAE,IAAI;IACd,iBAAiB,EAAE,IAAI;IACvB,WAAW,EAAE,eAAe;IAC5B,YAAY,EAAE,2BAA2B,EAAE;IAC3C,UAAU,EAAE;QACV,GAAG,qBAAqB,EAAE;QAC1B,QAAQ,EAAE;YACR,GAAG,qBAAqB,EAAE,CAAC,QAAQ;YACnC,OAAO,EAAE,eAAe;SACzB;KACF;CACF,CAAC,CAAC","sourcesContent":["import { getOperatorConfig } from '../operators';\nimport { generateDefaultCategoryName } from '../../utils';\nimport { FormData } from '../types';\n\n/**\n * Shared helper function to get operator value from various formats.\n * Handles string, object, and array formats that can come from the form system.\n */\nexport const getOperatorValue = (operator: any): string => {\n if (typeof operator === 'string') {\n return operator.trim();\n } else if (Array.isArray(operator) && operator.length > 0) {\n const firstOperator = operator[0];\n if (\n firstOperator &&\n typeof firstOperator === 'object' &&\n firstOperator.value\n ) {\n return firstOperator.value.trim();\n }\n } else if (operator && typeof operator === 'object' && operator.value) {\n return operator.value.trim();\n }\n return '';\n};\n\n/**\n * Shared isEmptyItem function for rules array.\n * Determines if a rule item is considered empty and should be filtered out.\n */\nexport const isEmptyRuleItem = (item: any): boolean => {\n // Check if operator and category are provided\n const operatorValue = getOperatorValue(item.operator);\n if (!operatorValue || !item.category || item.category.trim() === '') {\n return true;\n }\n\n // Check if value is required based on operator configuration\n const operatorConfig = getOperatorConfig(operatorValue);\n if (operatorConfig && operatorConfig.operands === 1) {\n return !item.value1 || item.value1.trim() === '';\n } else if (operatorConfig && operatorConfig.operands === 2) {\n return (\n !item.value1 ||\n item.value1.trim() === '' ||\n !item.value2 ||\n item.value2.trim() === ''\n );\n }\n\n return false;\n};\n\n/**\n * Shared onItemChange function for rules array.\n * Handles auto-updating category names based on operator and value changes.\n */\nexport const createRuleItemChangeHandler = () => {\n return (itemIndex: number, field: string, value: any, allItems: any[]) => {\n const updatedItems = [...allItems];\n const item = { ...updatedItems[itemIndex] };\n\n // Update the changed field\n item[field] = value;\n\n // Get operator values (before and after the change)\n const oldItem = allItems[itemIndex] || {};\n const oldOperatorValue =\n field === 'operator'\n ? getOperatorValue(oldItem.operator)\n : getOperatorValue(item.operator);\n const newOperatorValue = getOperatorValue(item.operator);\n\n // Calculate what the default category name should be before the change\n const oldDefaultCategory = generateDefaultCategoryName(\n oldOperatorValue,\n getOperatorConfig,\n field === 'value1' ? oldItem.value1 : item.value1,\n field === 'value2' ? oldItem.value2 : item.value2\n );\n\n // Calculate what the new default category name should be after the change\n const newDefaultCategory = generateDefaultCategoryName(\n newOperatorValue,\n getOperatorConfig,\n item.value1,\n item.value2\n );\n\n // Determine if we should auto-update the category\n const shouldUpdateCategory =\n !item.category ||\n item.category.trim() === '' ||\n item.category === oldDefaultCategory;\n\n // Auto-populate or update category if conditions are met\n if (shouldUpdateCategory && newDefaultCategory) {\n item.category = newDefaultCategory;\n }\n\n updatedItems[itemIndex] = item;\n return updatedItems;\n };\n};\n\n/**\n * Shared visibility condition for value1 field.\n */\nexport const value1VisibilityCondition = (formData: Record<string, any>) => {\n const operatorValue = getOperatorValue(formData.operator);\n const operatorConfig = getOperatorConfig(operatorValue);\n return operatorConfig ? operatorConfig.operands >= 1 : true;\n};\n\n/**\n * Shared visibility condition for value2 field.\n */\nexport const value2VisibilityCondition = (formData: Record<string, any>) => {\n const operatorValue = getOperatorValue(formData.operator);\n const operatorConfig = getOperatorConfig(operatorValue);\n return operatorConfig ? operatorConfig.operands === 2 : false;\n};\n\n/**\n * Shared item configuration for rules array.\n * This defines the operator, value1, value2, and category fields.\n */\nexport const createRulesItemConfig = () => ({\n operator: {\n type: 'select' as const,\n required: true,\n multi: false,\n options: [], // Will be set by the caller\n flavor: 'xsmall' as const,\n width: '220px'\n },\n value1: {\n type: 'text' as const,\n flavor: 'xsmall' as const,\n conditions: {\n visible: value1VisibilityCondition\n }\n },\n value2: {\n type: 'text' as const,\n flavor: 'xsmall' as const,\n conditions: {\n visible: value2VisibilityCondition\n }\n },\n category: {\n type: 'text' as const,\n placeholder: 'Category',\n required: true,\n maxWidth: '120px',\n flavor: 'xsmall' as const\n }\n});\n\n/**\n * Shared function to extract rules from form data.\n * Filters and transforms form rules into the format expected by createRulesRouter.\n */\nexport const extractUserRules = (formData: FormData) => {\n return (formData.rules || [])\n .filter((rule: any) => {\n const operatorValue = getOperatorValue(rule?.operator);\n if (\n !operatorValue ||\n !rule?.category ||\n operatorValue === '' ||\n rule.category.trim() === ''\n ) {\n return false;\n }\n\n const operatorConfig = getOperatorConfig(operatorValue);\n if (operatorConfig && operatorConfig.operands === 1) {\n return rule?.value1 && rule.value1.trim() !== '';\n } else if (operatorConfig && operatorConfig.operands === 2) {\n return (\n rule?.value1 &&\n rule.value1.trim() !== '' &&\n rule?.value2 &&\n rule.value2.trim() !== ''\n );\n }\n\n return true;\n })\n .map((rule: any) => {\n const operatorValue = getOperatorValue(rule.operator);\n const operatorConfig = getOperatorConfig(operatorValue);\n\n let value = '';\n\n if (operatorConfig && operatorConfig.operands === 1) {\n value = rule.value1 ? rule.value1.trim() : '';\n } else if (operatorConfig && operatorConfig.operands === 2) {\n const val1 = rule.value1 ? rule.value1.trim() : '';\n const val2 = rule.value2 ? rule.value2.trim() : '';\n value = `${val1} ${val2}`.trim();\n } else {\n value = '';\n }\n\n return {\n operator: operatorValue,\n value: value,\n category: rule.category.trim()\n };\n });\n};\n\n/**\n * Shared function to transform router cases to form rules.\n * Converts node router cases back into the form data structure.\n */\nexport const casesToFormRules = (node: any) => {\n const rules = [];\n if (node.router?.cases && node.router?.categories) {\n node.router.cases.forEach((case_: any) => {\n // Find the category for this case\n const category = node.router!.categories.find(\n (cat: any) => cat.uuid === case_.category_uuid\n );\n\n // Skip system categories\n if (category && !isSystemCategory(category.name)) {\n // Handle different operator types\n const operatorConfig = getOperatorConfig(case_.type);\n const operatorDisplayName = operatorConfig\n ? operatorConfig.name\n : case_.type;\n let value1 = '';\n let value2 = '';\n\n if (operatorConfig && operatorConfig.operands === 0) {\n value1 = '';\n value2 = '';\n } else if (operatorConfig && operatorConfig.operands === 1) {\n value1 = case_.arguments.join(' ');\n value2 = '';\n } else if (operatorConfig && operatorConfig.operands === 2) {\n value1 = case_.arguments[0] || '';\n value2 = case_.arguments[1] || '';\n } else {\n value1 = case_.arguments.join(' ');\n value2 = '';\n }\n\n rules.push({\n operator: { value: case_.type, name: operatorDisplayName },\n value1: value1,\n value2: value2,\n category: category.name\n });\n }\n });\n }\n return rules;\n};\n\n/**\n * Helper to check if a category is a system category\n */\nfunction isSystemCategory(categoryName: string): boolean {\n return ['No Response', 'Other', 'All Responses', 'Timeout'].includes(\n categoryName\n );\n}\n\n/**\n * Creates a complete rules array configuration for forms.\n * This is the shared configuration used by both wait_for_response and split_by_expression.\n *\n * @param operatorOptions - The operator options to use (from operatorsToSelectOptions)\n * @param helpText - The help text to display for the rules array\n * @returns A complete array field configuration object\n */\nexport const createRulesArrayConfig = (\n operatorOptions: any[],\n helpText: string = 'Define rules to categorize responses'\n) => ({\n type: 'array' as const,\n helpText,\n itemLabel: 'Rule',\n minItems: 0,\n maxItems: 100,\n sortable: true,\n maintainEmptyItem: true,\n isEmptyItem: isEmptyRuleItem,\n onItemChange: createRuleItemChangeHandler(),\n itemConfig: {\n ...createRulesItemConfig(),\n operator: {\n ...createRulesItemConfig().operator,\n options: operatorOptions\n }\n }\n});\n"]}
@@ -23,10 +23,10 @@ const getOperandForField = (field) => {
23
23
  }
24
24
  // For system properties, use the id
25
25
  if (field.type === 'property') {
26
- return `@contact.${field.id}`;
26
+ return `@contact.${field.id || field.value}`;
27
27
  }
28
- // Fallback to key
29
- return `@fields.${field.key}`;
28
+ // For custom fields, use key with fallbacks
29
+ return `@fields.${field.key || field.id || field.value}`;
30
30
  };
31
31
  export const split_by_contact_field = {
32
32
  type: 'split_by_contact_field',
@@ -59,7 +59,7 @@ export const split_by_contact_field = {
59
59
  }))
60
60
  ]
61
61
  },
62
- rules: createRulesArrayConfig(operatorsToSelectOptions(getWaitForResponseOperators()), 'Define rules to split the contact field into categories'),
62
+ rules: createRulesArrayConfig(operatorsToSelectOptions(getWaitForResponseOperators()), ''),
63
63
  result_name: resultNameField
64
64
  },
65
65
  layout: ['field', 'rules', 'result_name'],
@@ -76,7 +76,20 @@ export const split_by_contact_field = {
76
76
  toFormData: (node, nodeUI) => {
77
77
  var _a, _b;
78
78
  // Get the field from the UI config operand (source of truth)
79
- const field = ((_a = nodeUI === null || nodeUI === void 0 ? void 0 : nodeUI.config) === null || _a === void 0 ? void 0 : _a.operand) || CONTACT_PROPERTIES.name;
79
+ const operand = ((_a = nodeUI === null || nodeUI === void 0 ? void 0 : nodeUI.config) === null || _a === void 0 ? void 0 : _a.operand) || CONTACT_PROPERTIES.name;
80
+ // Normalize the field object to include properties expected by
81
+ // the Select component (valueKey: 'key') and getOperandForField.
82
+ // toUIConfig saves only { id, name, type }, so we need to add
83
+ // 'key' for custom fields and 'value' for static option matching.
84
+ const field = { ...operand };
85
+ if (field.type === 'field') {
86
+ if (!field.key)
87
+ field.key = field.id;
88
+ }
89
+ else {
90
+ if (!field.value)
91
+ field.value = field.id;
92
+ }
80
93
  // Extract rules from router cases using shared function
81
94
  const rules = casesToFormRules(node);
82
95
  return {
@@ -1 +1 @@
1
- {"version":3,"file":"split_by_contact_field.js","sourceRoot":"","sources":["../../../../src/flow/nodes/split_by_contact_field.ts"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IAAI,aAAa,CAAC,GAAG,CAAC;QAE/D,oEAAoE;QACpE,IAAI,aAAa,CAAC,IAAI,KAAK,QAAQ,EAAE,CAAC;YACpC,SAAS,GAAG,aAAa,CAAC,KAAK,IAAI,aAAa,CAAC,EAAE,CAAC;QACtD,CAAC;QAED,IAAI,IAAI,GAAG,aAAa,CAAC,IAAI,CAAC;QAC9B,IAAI,IAAI,KAAK,UAAU,IAAI,IAAI,KAAK,QAAQ,EAAE,CAAC;YAC7C,IAAI,GAAG,OAAO,CAAC;QACjB,CAAC;QAED,4DAA4D;QAC5D,OAAO;YACL,OAAO,EAAE;gBACP,EAAE,EAAE,SAAS;gBACb,IAAI,EAAE,aAAa,CAAC,IAAI,IAAI,aAAa,CAAC,KAAK;gBAC/C,IAAI;aACL;SACF,CAAC;IACJ,CAAC;IACD,WAAW,EAAE,CAAC,IAAU,EAAE,MAAY,EAAE,EAAE;QACxC,OAAO,IAAI,CAAA,iBAAiB,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,IAAI,QAAQ,CAAC;IACjE,CAAC;IAED,sCAAsC;IACtC,WAAW,EAAE,YAAY;IACzB,sBAAsB,EAAE,gCAAgC;IACxD,wBAAwB,EAAE,gCAAgC;CAC3D,CAAC","sourcesContent":["import { SPLIT_GROUPS, FormData, NodeConfig, FlowTypes } from '../types';\nimport { Node } from '../../store/flow-definition';\nimport { createRulesRouter } from '../../utils';\nimport {\n getWaitForResponseOperators,\n operatorsToSelectOptions,\n getOperatorConfig\n} from '../operators';\nimport {\n resultNameField,\n categoriesToLocalizationFormData,\n localizationFormDataToCategories\n} from './shared';\nimport {\n createRulesArrayConfig,\n extractUserRules,\n casesToFormRules\n} from './shared-rules';\nimport { SCHEMES } from '../utils';\nimport { html } from 'lit';\n\n// System contact properties that can be split on\nexport const CONTACT_PROPERTIES = {\n name: { id: 'name', name: 'Name', type: 'property' },\n language: { id: 'language', name: 'Language', type: 'property' },\n status: { id: 'status', name: 'Status', type: 'property' },\n channel: { id: 'channel', name: 'Channel', type: 'property' }\n};\n\n// Helper to get operand for the selected field\nconst getOperandForField = (field: any): string => {\n // For URN schemes, split on the URN path (the actual ID value like Facebook ID)\n // Note: This is different from split_by_scheme which splits on the scheme type itself\n if (field.type === 'scheme') {\n // field.id or field.value will be the scheme name like 'facebook', 'whatsapp', etc\n const schemeId = field.id || field.value;\n return `@(default(urn_parts(urns.${schemeId}).path, \"\"))`;\n }\n // For system properties, use the id\n if (field.type === 'property') {\n return `@contact.${field.id}`;\n }\n // Fallback to key\n return `@fields.${field.key}`;\n};\n\nexport const split_by_contact_field: NodeConfig = {\n type: 'split_by_contact_field',\n name: 'Split by Contact Field',\n group: SPLIT_GROUPS.split,\n flowTypes: [FlowTypes.VOICE, FlowTypes.MESSAGE, FlowTypes.BACKGROUND],\n dialogSize: 'large',\n form: {\n field: {\n type: 'select',\n required: true,\n searchable: true,\n clearable: false,\n endpoint: '/api/v2/fields.json',\n valueKey: 'key',\n nameKey: 'name',\n placeholder: 'Select a field...',\n // Provide system properties as fixed options at the top\n options: [\n ...Object.values(CONTACT_PROPERTIES).map((prop) => ({\n value: prop.id,\n name: prop.name,\n type: prop.type\n })),\n // Add all URN scheme options (they represent splitting on the URN value, like Facebook ID)\n ...SCHEMES.filter((scheme) => !scheme.excludeFromSplit).map(\n (scheme) => ({\n value: scheme.scheme,\n name: scheme.path,\n type: 'scheme'\n })\n )\n ]\n },\n rules: createRulesArrayConfig(\n operatorsToSelectOptions(getWaitForResponseOperators()),\n 'Define rules to split the contact field into categories'\n ),\n result_name: resultNameField\n },\n layout: ['field', 'rules', 'result_name'],\n validate: (formData: FormData) => {\n const errors: { [key: string]: string } = {};\n\n if (!formData.field || formData.field.length === 0) {\n errors.field = 'A field is required';\n }\n\n return {\n valid: Object.keys(errors).length === 0,\n errors\n };\n },\n toFormData: (node: Node, nodeUI?: any) => {\n // Get the field from the UI config operand (source of truth)\n const field = nodeUI?.config?.operand || CONTACT_PROPERTIES.name;\n\n // Extract rules from router cases using shared function\n const rules = casesToFormRules(node);\n\n return {\n uuid: node.uuid,\n field: [field],\n rules: rules,\n result_name: node.router?.result_name || ''\n };\n },\n fromFormData: (formData: FormData, originalNode: Node): Node => {\n // Get selected field (it's an array from the select component)\n const selectedField = formData.field?.[0];\n\n if (!selectedField) {\n return originalNode;\n }\n\n // Get operand for the selected field\n const operand = getOperandForField(selectedField);\n\n // Get user rules using shared extraction function\n const userRules = extractUserRules(formData);\n\n // Get existing router data for preservation\n const existingCategories = originalNode.router?.categories || [];\n const existingExits = originalNode.exits || [];\n const existingCases = originalNode.router?.cases || [];\n\n // Create router and exits using existing data when possible\n const { router, exits } = createRulesRouter(\n operand,\n userRules,\n getOperatorConfig,\n existingCategories,\n existingExits,\n existingCases\n );\n\n // Build final router with result_name\n const finalRouter: any = {\n ...router\n };\n\n // Only set result_name if provided\n if (formData.result_name && formData.result_name.trim() !== '') {\n finalRouter.result_name = formData.result_name.trim();\n }\n\n return {\n ...originalNode,\n router: finalRouter,\n exits: exits\n };\n },\n toUIConfig: (formData: FormData) => {\n // Get selected field (it's an array from the select component)\n const selectedField = formData.field?.[0];\n\n if (!selectedField) {\n return {};\n }\n\n // For scheme types, the id should be the scheme name (facebook, whatsapp, etc)\n // For custom fields, the id should be the field key\n // For system properties, the id should be the property id\n let operandId =\n selectedField.id || selectedField.value || selectedField.key;\n\n // If this is a scheme type, ensure we use the scheme name as the id\n if (selectedField.type === 'scheme') {\n operandId = selectedField.value || selectedField.id;\n }\n\n let type = selectedField.type;\n if (type !== 'property' && type !== 'scheme') {\n type = 'field';\n }\n\n // Return UI config with operand information for persistence\n return {\n operand: {\n id: operandId,\n name: selectedField.name || selectedField.label,\n type\n }\n };\n },\n renderTitle: (node: Node, nodeUI?: any) => {\n return html`<div>Split by ${nodeUI.config.operand.name}</div>`;\n },\n\n // Localization support for categories\n localizable: 'categories',\n toLocalizationFormData: categoriesToLocalizationFormData,\n fromLocalizationFormData: localizationFormDataToCategories\n};\n"]}
1
+ {"version":3,"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B,EAAE,gCAAgC;IACxD,wBAAwB,EAAE,gCAAgC;CAC3D,CAAC","sourcesContent":["import { SPLIT_GROUPS, FormData, NodeConfig, FlowTypes } from '../types';\nimport { Node } from '../../store/flow-definition';\nimport { createRulesRouter } from '../../utils';\nimport {\n getWaitForResponseOperators,\n operatorsToSelectOptions,\n getOperatorConfig\n} from '../operators';\nimport {\n resultNameField,\n categoriesToLocalizationFormData,\n localizationFormDataToCategories\n} from './shared';\nimport {\n createRulesArrayConfig,\n extractUserRules,\n casesToFormRules\n} from './shared-rules';\nimport { SCHEMES } from '../utils';\nimport { html } from 'lit';\n\n// System contact properties that can be split on\nexport const CONTACT_PROPERTIES = {\n name: { id: 'name', name: 'Name', type: 'property' },\n language: { id: 'language', name: 'Language', type: 'property' },\n status: { id: 'status', name: 'Status', type: 'property' },\n channel: { id: 'channel', name: 'Channel', type: 'property' }\n};\n\n// Helper to get operand for the selected field\nconst getOperandForField = (field: any): string => {\n // For URN schemes, split on the URN path (the actual ID value like Facebook ID)\n // Note: This is different from split_by_scheme which splits on the scheme type itself\n if (field.type === 'scheme') {\n // field.id or field.value will be the scheme name like 'facebook', 'whatsapp', etc\n const schemeId = field.id || field.value;\n return `@(default(urn_parts(urns.${schemeId}).path, \"\"))`;\n }\n // For system properties, use the id\n if (field.type === 'property') {\n return `@contact.${field.id || field.value}`;\n }\n // For custom fields, use key with fallbacks\n return `@fields.${field.key || field.id || field.value}`;\n};\n\nexport const split_by_contact_field: NodeConfig = {\n type: 'split_by_contact_field',\n name: 'Split by Contact Field',\n group: SPLIT_GROUPS.split,\n flowTypes: [FlowTypes.VOICE, FlowTypes.MESSAGE, FlowTypes.BACKGROUND],\n dialogSize: 'large',\n form: {\n field: {\n type: 'select',\n required: true,\n searchable: true,\n clearable: false,\n endpoint: '/api/v2/fields.json',\n valueKey: 'key',\n nameKey: 'name',\n placeholder: 'Select a field...',\n // Provide system properties as fixed options at the top\n options: [\n ...Object.values(CONTACT_PROPERTIES).map((prop) => ({\n value: prop.id,\n name: prop.name,\n type: prop.type\n })),\n // Add all URN scheme options (they represent splitting on the URN value, like Facebook ID)\n ...SCHEMES.filter((scheme) => !scheme.excludeFromSplit).map(\n (scheme) => ({\n value: scheme.scheme,\n name: scheme.path,\n type: 'scheme'\n })\n )\n ]\n },\n rules: createRulesArrayConfig(\n operatorsToSelectOptions(getWaitForResponseOperators()),\n ''\n ),\n result_name: resultNameField\n },\n layout: ['field', 'rules', 'result_name'],\n validate: (formData: FormData) => {\n const errors: { [key: string]: string } = {};\n\n if (!formData.field || formData.field.length === 0) {\n errors.field = 'A field is required';\n }\n\n return {\n valid: Object.keys(errors).length === 0,\n errors\n };\n },\n toFormData: (node: Node, nodeUI?: any) => {\n // Get the field from the UI config operand (source of truth)\n const operand = nodeUI?.config?.operand || CONTACT_PROPERTIES.name;\n\n // Normalize the field object to include properties expected by\n // the Select component (valueKey: 'key') and getOperandForField.\n // toUIConfig saves only { id, name, type }, so we need to add\n // 'key' for custom fields and 'value' for static option matching.\n const field = { ...operand };\n if (field.type === 'field') {\n if (!field.key) field.key = field.id;\n } else {\n if (!field.value) field.value = field.id;\n }\n\n // Extract rules from router cases using shared function\n const rules = casesToFormRules(node);\n\n return {\n uuid: node.uuid,\n field: [field],\n rules: rules,\n result_name: node.router?.result_name || ''\n };\n },\n fromFormData: (formData: FormData, originalNode: Node): Node => {\n // Get selected field (it's an array from the select component)\n const selectedField = formData.field?.[0];\n\n if (!selectedField) {\n return originalNode;\n }\n\n // Get operand for the selected field\n const operand = getOperandForField(selectedField);\n\n // Get user rules using shared extraction function\n const userRules = extractUserRules(formData);\n\n // Get existing router data for preservation\n const existingCategories = originalNode.router?.categories || [];\n const existingExits = originalNode.exits || [];\n const existingCases = originalNode.router?.cases || [];\n\n // Create router and exits using existing data when possible\n const { router, exits } = createRulesRouter(\n operand,\n userRules,\n getOperatorConfig,\n existingCategories,\n existingExits,\n existingCases\n );\n\n // Build final router with result_name\n const finalRouter: any = {\n ...router\n };\n\n // Only set result_name if provided\n if (formData.result_name && formData.result_name.trim() !== '') {\n finalRouter.result_name = formData.result_name.trim();\n }\n\n return {\n ...originalNode,\n router: finalRouter,\n exits: exits\n };\n },\n toUIConfig: (formData: FormData) => {\n // Get selected field (it's an array from the select component)\n const selectedField = formData.field?.[0];\n\n if (!selectedField) {\n return {};\n }\n\n // For scheme types, the id should be the scheme name (facebook, whatsapp, etc)\n // For custom fields, the id should be the field key\n // For system properties, the id should be the property id\n let operandId =\n selectedField.id || selectedField.value || selectedField.key;\n\n // If this is a scheme type, ensure we use the scheme name as the id\n if (selectedField.type === 'scheme') {\n operandId = selectedField.value || selectedField.id;\n }\n\n let type = selectedField.type;\n if (type !== 'property' && type !== 'scheme') {\n type = 'field';\n }\n\n // Return UI config with operand information for persistence\n return {\n operand: {\n id: operandId,\n name: selectedField.name || selectedField.label,\n type\n }\n };\n },\n renderTitle: (node: Node, nodeUI?: any) => {\n return html`<div>Split by ${nodeUI.config.operand.name}</div>`;\n },\n\n // Localization support for categories\n localizable: 'categories',\n toLocalizationFormData: categoriesToLocalizationFormData,\n fromLocalizationFormData: localizationFormDataToCategories\n};\n"]}
@@ -18,7 +18,7 @@ export const split_by_expression = {
18
18
  evaluated: true,
19
19
  placeholder: '@fields.age'
20
20
  },
21
- rules: createRulesArrayConfig(operatorsToSelectOptions(getWaitForResponseOperators()), 'Define rules to categorize the expression result'),
21
+ rules: createRulesArrayConfig(operatorsToSelectOptions(getWaitForResponseOperators()), ''),
22
22
  result_name: resultNameField
23
23
  },
24
24
  layout: ['operand', 'rules', 'result_name'],
@@ -1 +1 @@
1
- {"version":3,"file":"split_by_expression.js","sourceRoot":"","sources":["../../../../src/flow/nodes/split_by_expression.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAwB,SAAS,EAAE,MAAM,UAAU,CAAC;AAEzE,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAChD,OAAO,EACL,2BAA2B,EAC3B,wBAAwB,EACxB,iB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AED,OAAO;YACL,GAAG,YAAY;YACf,MAAM,EAAE,WAAW;YACnB,KAAK,EAAE,KAAK;SACb,CAAC;IACJ,CAAC;IAED,sCAAsC;IACtC,WAAW,EAAE,YAAY;IACzB,sBAAsB,EAAE,gCAAgC;IACxD,wBAAwB,EAAE,gCAAgC;CAC3D,CAAC","sourcesContent":["import { SPLIT_GROUPS, FormData, NodeConfig, FlowTypes } from '../types';\nimport { Node } from '../../store/flow-definition';\nimport { createRulesRouter } from '../../utils';\nimport {\n getWaitForResponseOperators,\n operatorsToSelectOptions,\n getOperatorConfig\n} from '../operators';\nimport {\n resultNameField,\n categoriesToLocalizationFormData,\n localizationFormDataToCategories\n} from './shared';\nimport {\n createRulesArrayConfig,\n extractUserRules,\n casesToFormRules\n} from './shared-rules';\n\nexport const split_by_expression: NodeConfig = {\n type: 'split_by_expression',\n name: 'Split by Expression',\n group: SPLIT_GROUPS.split,\n flowTypes: [FlowTypes.VOICE, FlowTypes.MESSAGE, FlowTypes.BACKGROUND],\n dialogSize: 'large',\n form: {\n operand: {\n type: 'text',\n label: 'Expression',\n helpText: 'The expression to evaluate and split on',\n required: true,\n evaluated: true,\n placeholder: '@fields.age'\n },\n rules: createRulesArrayConfig(\n operatorsToSelectOptions(getWaitForResponseOperators()),\n 'Define rules to categorize the expression result'\n ),\n result_name: resultNameField\n },\n layout: ['operand', 'rules', 'result_name'],\n validate: (formData: FormData) => {\n const errors: { [key: string]: string } = {};\n\n // Validate operand is provided\n if (!formData.operand || formData.operand.trim() === '') {\n errors.operand = 'Expression is required';\n }\n\n return {\n valid: Object.keys(errors).length === 0,\n errors\n };\n },\n toFormData: (node: Node) => {\n // Extract rules from router cases using shared function\n const rules = casesToFormRules(node);\n\n return {\n uuid: node.uuid,\n operand: node.router?.operand || '@input.text',\n rules: rules,\n result_name: node.router?.result_name || ''\n };\n },\n fromFormData: (formData: FormData, originalNode: Node): Node => {\n // Get user rules using shared extraction function\n const userRules = extractUserRules(formData);\n\n // Get operand from form data\n const operand = formData.operand?.trim() || '@input.text';\n\n // Get existing router data for preservation\n const existingCategories = originalNode.router?.categories || [];\n const existingExits = originalNode.exits || [];\n const existingCases = originalNode.router?.cases || [];\n\n // Create router and exits using existing data when possible\n const { router, exits } = createRulesRouter(\n operand,\n userRules,\n getOperatorConfig,\n existingCategories,\n existingExits,\n existingCases\n );\n\n // Build final router with result_name\n const finalRouter: any = {\n ...router\n };\n\n // Only set result_name if provided\n if (formData.result_name && formData.result_name.trim() !== '') {\n finalRouter.result_name = formData.result_name.trim();\n }\n\n return {\n ...originalNode,\n router: finalRouter,\n exits: exits\n };\n },\n\n // Localization support for categories\n localizable: 'categories',\n toLocalizationFormData: categoriesToLocalizationFormData,\n fromLocalizationFormData: localizationFormDataToCategories\n};\n"]}
1
+ {"version":3,"file":"split_by_expression.js","sourceRoot":"","sources":["../../../../src/flow/nodes/split_by_expression.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAwB,SAAS,EAAE,MAAM,UAAU,CAAC;AAEzE,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAChD,OAAO,EACL,2BAA2B,EAC3B,wBAAwB,EACxB,iBAAiB,EAClB,MAAM,cAAc,CAAC;AACtB,OAAO,EACL,eAAe,EACf,gCAAgC,EAChC,gCAAgC,EACjC,MAAM,UAAU,CAAC;AAClB,OAAO,EACL,sBAAsB,EACtB,gBAAgB,EAChB,gBAAgB,EACjB,MAAM,gBAAgB,CAAC;AAExB,MAAM,CAAC,MAAM,mBAAmB,GAAe;IAC7C,IAAI,EAAE,qBAAqB;IAC3B,IAAI,EAAE,qBAAqB;IAC3B,KAAK,EAAE,YAAY,CAAC,KAAK;IACzB,SAAS,EAAE,CAAC,SAAS,CAAC,KAAK,EAAE,SAAS,CAAC,OAAO,EAAE,SAAS,CAAC,UAAU,CAAC;IACrE,UAAU,EAAE,OAAO;IACnB,IAAI,EAAE;QACJ,OAAO,EAAE;YACP,IAAI,EAAE,MAAM;YACZ,KA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C,OAAO,0CAAE,IAAI,EAAE,KAAI,aAAa,CAAC;QAE1D,4CAA4C;QAC5C,MAAM,kBAAkB,GAAG,CAAA,MAAA,YAAY,CAAC,MAAM,0CAAE,UAAU,KAAI,EAAE,CAAC;QACjE,MAAM,aAAa,GAAG,YAAY,CAAC,KAAK,IAAI,EAAE,CAAC;QAC/C,MAAM,aAAa,GAAG,CAAA,MAAA,YAAY,CAAC,MAAM,0CAAE,KAAK,KAAI,EAAE,CAAC;QAEvD,4DAA4D;QAC5D,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,GAAG,iBAAiB,CACzC,OAAO,EACP,SAAS,EACT,iBAAiB,EACjB,kBAAkB,EAClB,aAAa,EACb,aAAa,CACd,CAAC;QAEF,sCAAsC;QACtC,MAAM,WAAW,GAAQ;YACvB,GAAG,MAAM;SACV,CAAC;QAEF,mCAAmC;QACnC,IAAI,QAAQ,CAAC,WAAW,IAAI,QAAQ,CAAC,WAAW,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE,CAAC;YAC/D,WAAW,CAAC,WAAW,GAAG,QAAQ,CAAC,WAAW,CAAC,IAAI,EAAE,CAAC;QACxD,CAAC;QAED,OAAO;YACL,GAAG,YAAY;YACf,MAAM,EAAE,WAAW;YACnB,KAAK,EAAE,KAAK;SACb,CAAC;IACJ,CAAC;IAED,sCAAsC;IACtC,WAAW,EAAE,YAAY;IACzB,sBAAsB,EAAE,gCAAgC;IACxD,wBAAwB,EAAE,gCAAgC;CAC3D,CAAC","sourcesContent":["import { SPLIT_GROUPS, FormData, NodeConfig, FlowTypes } from '../types';\nimport { Node } from '../../store/flow-definition';\nimport { createRulesRouter } from '../../utils';\nimport {\n getWaitForResponseOperators,\n operatorsToSelectOptions,\n getOperatorConfig\n} from '../operators';\nimport {\n resultNameField,\n categoriesToLocalizationFormData,\n localizationFormDataToCategories\n} from './shared';\nimport {\n createRulesArrayConfig,\n extractUserRules,\n casesToFormRules\n} from './shared-rules';\n\nexport const split_by_expression: NodeConfig = {\n type: 'split_by_expression',\n name: 'Split by Expression',\n group: SPLIT_GROUPS.split,\n flowTypes: [FlowTypes.VOICE, FlowTypes.MESSAGE, FlowTypes.BACKGROUND],\n dialogSize: 'large',\n form: {\n operand: {\n type: 'text',\n label: 'Expression',\n helpText: 'The expression to evaluate and split on',\n required: true,\n evaluated: true,\n placeholder: '@fields.age'\n },\n rules: createRulesArrayConfig(\n operatorsToSelectOptions(getWaitForResponseOperators()),\n ''\n ),\n result_name: resultNameField\n },\n layout: ['operand', 'rules', 'result_name'],\n validate: (formData: FormData) => {\n const errors: { [key: string]: string } = {};\n\n // Validate operand is provided\n if (!formData.operand || formData.operand.trim() === '') {\n errors.operand = 'Expression is required';\n }\n\n return {\n valid: Object.keys(errors).length === 0,\n errors\n };\n },\n toFormData: (node: Node) => {\n // Extract rules from router cases using shared function\n const rules = casesToFormRules(node);\n\n return {\n uuid: node.uuid,\n operand: node.router?.operand || '@input.text',\n rules: rules,\n result_name: node.router?.result_name || ''\n };\n },\n fromFormData: (formData: FormData, originalNode: Node): Node => {\n // Get user rules using shared extraction function\n const userRules = extractUserRules(formData);\n\n // Get operand from form data\n const operand = formData.operand?.trim() || '@input.text';\n\n // Get existing router data for preservation\n const existingCategories = originalNode.router?.categories || [];\n const existingExits = originalNode.exits || [];\n const existingCases = originalNode.router?.cases || [];\n\n // Create router and exits using existing data when possible\n const { router, exits } = createRulesRouter(\n operand,\n userRules,\n getOperatorConfig,\n existingCategories,\n existingExits,\n existingCases\n );\n\n // Build final router with result_name\n const finalRouter: any = {\n ...router\n };\n\n // Only set result_name if provided\n if (formData.result_name && formData.result_name.trim() !== '') {\n finalRouter.result_name = formData.result_name.trim();\n }\n\n return {\n ...originalNode,\n router: finalRouter,\n exits: exits\n };\n },\n\n // Localization support for categories\n localizable: 'categories',\n toLocalizationFormData: categoriesToLocalizationFormData,\n fromLocalizationFormData: localizationFormDataToCategories\n};\n"]}
@@ -29,7 +29,6 @@ export const split_by_llm_categorize = {
29
29
  },
30
30
  categories: {
31
31
  type: 'array',
32
- label: 'Categories',
33
32
  helpText: 'Define the categories for classification',
34
33
  required: true,
35
34
  sortable: true,
@@ -1 +1 @@
1
- {"version":3,"file":"split_by_llm_categorize.js","sourceRoot":"","sources":["../../../../src/flow/nodes/split_by_llm_categorize.ts"],"names":[],"mappings":"AAAA,OAAO,EAAwB,aAAa,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;AAEzE,OAAO,EAAE,YAAY,EAAE,yBAAyB,EAAE,MAAM,aAAa,CAAC;AACtE,OAAO,EAAE,IAAI,EAAE,MAAM,KAAK,CAAC;AAC3B,OAAO,EACL,gCAAgC,EAChC,gCAAgC,EACjC,MAAM,UAAU,CAAC;AAElB,MAAM,CAAC,MAAM,uBAAuB,GAAe;IACjD,IAAI,EAAE,yBAAyB;IAC/B,IAAI,EAAE,aAAa;IACnB,KAAK,EAAE,aAAa,CAAC,QAAQ;IAC7B,SAAS,EAAE,EAAE;IACb,QAAQ,EAAE,CAAC,QAAQ,CAAC,EAAE,CAAC;IACvB,IAAI,EAAE;QACJ,GAAG,EAAE;YACH,IAAI,EAAE,QAAQ;YACd,KAAK,EAAE,KAAK;YACZ,QAAQ,EAAE,0CAA0C;YACpD,QAAQ,EAAE,IAAI;YACd,QAAQ,EAAE,+BAA+B;YACzC,QAAQ,EAAE,MAAM;YAChB,OAAO,EAAE,MAAM;YACf,WAAW,EAAE,kBAAkB;SAChC;QACD,KAAK,EAAE;YACL,IAAI,EAAE,MAAM;YACZ,KAAK,EAAE,OAAO;YACd,QAAQ,EAAE,0CAA0C;YACpD,QAAQ,EAAE,IAAI;YACd,SAAS,EAAE,IAAI;YACf,WAAW,EAAE,QAAQ;SACtB;QACD,UAAU,EAAE;YACV,IAAI,EAAE,OAAO;YACb,KAAK,EAAE,YAAY;YACnB,QAAQ,EAAE,0CAA0C;YACpD,QAAQ,EAAE,IAAI;YACd,QAAQ,EAAE,IAAI;YACd,SAAS,EAAE,UAAU;YACrB,QAAQ,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vB,OAAO,EAAE,CAAC,aAAa,CAAC;YACxB,MAAM,EAAE,MAAM;YACd,KAAK,EAAE,KAAK;SACb,CAAC;IACJ,CAAC;IAED,sCAAsC;IACtC,WAAW,EAAE,YAAY;IACzB,sBAAsB,EAAE,gCAAgC;IACxD,wBAAwB,EAAE,gCAAgC;CAC3D,CAAC","sourcesContent":["import { FormData, NodeConfig, ACTION_GROUPS, Features } from '../types';\nimport { CallLLM, Node } from '../../store/flow-definition';\nimport { generateUUID, createMultiCategoryRouter } from '../../utils';\nimport { html } from 'lit';\nimport {\n categoriesToLocalizationFormData,\n localizationFormDataToCategories\n} from './shared';\n\nexport const split_by_llm_categorize: NodeConfig = {\n type: 'split_by_llm_categorize',\n name: 'Split by AI',\n group: ACTION_GROUPS.services,\n flowTypes: [],\n features: [Features.AI],\n form: {\n llm: {\n type: 'select',\n label: 'LLM',\n helpText: 'Select the LLM to use for categorization',\n required: true,\n endpoint: '/test-assets/select/llms.json',\n valueKey: 'uuid',\n nameKey: 'name',\n placeholder: 'Select an LLM...'\n },\n input: {\n type: 'text',\n label: 'Input',\n helpText: 'The input to categorize (usually @input)',\n required: true,\n evaluated: true,\n placeholder: '@input'\n },\n categories: {\n type: 'array',\n label: 'Categories',\n helpText: 'Define the categories for classification',\n required: true,\n sortable: true,\n itemLabel: 'Category',\n minItems: 1,\n maxItems: 10,\n isEmptyItem: (item: any) => {\n return !item.name || item.name.trim() === '';\n },\n itemConfig: {\n name: {\n type: 'text',\n placeholder: 'Category name',\n required: true\n }\n }\n }\n },\n layout: ['llm', 'input', 'categories'],\n validate: (formData: FormData) => {\n const errors: { [key: string]: string } = {};\n\n // Check for duplicate category names\n if (formData.categories && Array.isArray(formData.categories)) {\n const categories = formData.categories.filter(\n (item: any) => item?.name && item.name.trim() !== ''\n );\n\n // Find all categories that have duplicates (case-insensitive)\n const duplicateCategories = [];\n const lowerCaseMap = new Map();\n\n // First pass: map lowercase names to all original cases\n categories.forEach((category) => {\n const lowerName = category.name.trim().toLowerCase();\n if (!lowerCaseMap.has(lowerName)) {\n lowerCaseMap.set(lowerName, []);\n }\n lowerCaseMap.get(lowerName).push(category.name.trim());\n });\n\n // Second pass: collect all names that appear more than once\n lowerCaseMap.forEach((originalNames) => {\n if (originalNames.length > 1) {\n duplicateCategories.push(...originalNames);\n }\n });\n\n if (duplicateCategories.length > 0) {\n const uniqueDuplicates = [...new Set(duplicateCategories)];\n errors.categories = `Duplicate category names found: ${uniqueDuplicates.join(\n ', '\n )}`;\n }\n }\n\n return {\n valid: Object.keys(errors).length === 0,\n errors\n };\n },\n render: (node: Node) => {\n const callLlmAction = node.actions?.find(\n (action) => action.type === 'call_llm'\n ) as CallLLM;\n return html`\n <div class=\"body\">Categorize with ${callLlmAction.llm.name}</div>\n `;\n },\n toFormData: (node: Node) => {\n // Extract data from the existing node structure\n const callLlmAction = node.actions?.find(\n (action) => action.type === 'call_llm'\n ) as any;\n const categories =\n node.router?.categories\n ?.filter((cat) => cat.name !== 'Other' && cat.name !== 'Failure')\n .map((cat) => ({ name: cat.name })) || [];\n\n return {\n uuid: node.uuid,\n llm: callLlmAction?.llm\n ? [{ value: callLlmAction.llm.uuid, name: callLlmAction.llm.name }]\n : [],\n input: callLlmAction?.input || '@input',\n categories: categories\n };\n },\n fromFormData: (formData: FormData, originalNode: Node): Node => {\n // Get LLM selection\n const llmSelection =\n Array.isArray(formData.llm) && formData.llm.length > 0\n ? formData.llm[0]\n : null;\n\n // Get user categories\n const userCategories = (formData.categories || [])\n .filter((item: any) => item?.name?.trim())\n .map((item: any) => item.name.trim());\n\n // Find existing call_llm action to preserve its UUID\n const existingCallLlmAction = originalNode.actions?.find(\n (action) => action.type === 'call_llm'\n );\n const callLlmUuid = existingCallLlmAction?.uuid || generateUUID();\n\n // Create call_llm action (using any type to match the example format)\n const callLlmAction: CallLLM = {\n type: 'call_llm',\n uuid: callLlmUuid,\n llm: llmSelection\n ? { uuid: llmSelection.value, name: llmSelection.name }\n : { uuid: '', name: '' },\n instructions: `@(prompt(\"categorize\", slice(node.categories, 0, -2)))`,\n input: formData.input || '@input',\n output_local: '_llm_output'\n };\n\n // Create categories and exits\n const existingCategories = originalNode.router?.categories || [];\n const existingExits = originalNode.exits || [];\n const existingCases = originalNode.router?.cases || [];\n\n const { router, exits } = createMultiCategoryRouter(\n '@locals._llm_output',\n userCategories,\n (categoryName) => ({\n type: 'has_only_text',\n arguments: [categoryName]\n }),\n existingCategories,\n existingExits,\n existingCases\n );\n\n // Return the complete node\n return {\n uuid: originalNode.uuid,\n actions: [callLlmAction],\n router: router,\n exits: exits\n };\n },\n\n // Localization support for categories\n localizable: 'categories',\n toLocalizationFormData: categoriesToLocalizationFormData,\n fromLocalizationFormData: localizationFormDataToCategories\n};\n"]}
1
+ {"version":3,"file":"split_by_llm_categorize.js","sourceRoot":"","sources":["../../../../src/flow/nodes/split_by_llm_categorize.ts"],"names":[],"mappings":"AAAA,OAAO,EAAwB,aAAa,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;AAEzE,OAAO,EAAE,YAAY,EAAE,yBAAyB,EAAE,MAAM,aAAa,CAAC;AACtE,OAAO,EAAE,IAAI,EAAE,MAAM,KAAK,CAAC;AAC3B,OAAO,EACL,gCAAgC,EAChC,gCAAgC,EACjC,MAAM,UAAU,CAAC;AAElB,MAAM,CAAC,MAAM,uBAAuB,GAAe;IACjD,IAAI,EAAE,yBAAyB;IAC/B,IAAI,EAAE,aAAa;IACnB,KAAK,EAAE,aAAa,CAAC,QAAQ;IAC7B,SAAS,EAAE,EAAE;IACb,QAAQ,EAAE,CAAC,QAAQ,CAAC,EAAE,CAAC;IACvB,IAAI,EAAE;QACJ,GAAG,EAAE;YACH,IAAI,EAAE,QAAQ;YACd,KAAK,EAAE,KAAK;YACZ,QAAQ,EAAE,0CAA0C;YACpD,QAAQ,EAAE,IAAI;YACd,QAAQ,EAAE,+BAA+B;YACzC,QAAQ,EAAE,MAAM;YAChB,OAAO,EAAE,MAAM;YACf,WAAW,EAAE,kBA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K,KAAI,EAAE,CAAC;QAEvD,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,GAAG,yBAAyB,CACjD,qBAAqB,EACrB,cAAc,EACd,CAAC,YAAY,EAAE,EAAE,CAAC,CAAC;YACjB,IAAI,EAAE,eAAe;YACrB,SAAS,EAAE,CAAC,YAAY,CAAC;SAC1B,CAAC,EACF,kBAAkB,EAClB,aAAa,EACb,aAAa,CACd,CAAC;QAEF,2BAA2B;QAC3B,OAAO;YACL,IAAI,EAAE,YAAY,CAAC,IAAI;YACvB,OAAO,EAAE,CAAC,aAAa,CAAC;YACxB,MAAM,EAAE,MAAM;YACd,KAAK,EAAE,KAAK;SACb,CAAC;IACJ,CAAC;IAED,sCAAsC;IACtC,WAAW,EAAE,YAAY;IACzB,sBAAsB,EAAE,gCAAgC;IACxD,wBAAwB,EAAE,gCAAgC;CAC3D,CAAC","sourcesContent":["import { FormData, NodeConfig, ACTION_GROUPS, Features } from '../types';\nimport { CallLLM, Node } from '../../store/flow-definition';\nimport { generateUUID, createMultiCategoryRouter } from '../../utils';\nimport { html } from 'lit';\nimport {\n categoriesToLocalizationFormData,\n localizationFormDataToCategories\n} from './shared';\n\nexport const split_by_llm_categorize: NodeConfig = {\n type: 'split_by_llm_categorize',\n name: 'Split by AI',\n group: ACTION_GROUPS.services,\n flowTypes: [],\n features: [Features.AI],\n form: {\n llm: {\n type: 'select',\n label: 'LLM',\n helpText: 'Select the LLM to use for categorization',\n required: true,\n endpoint: '/test-assets/select/llms.json',\n valueKey: 'uuid',\n nameKey: 'name',\n placeholder: 'Select an LLM...'\n },\n input: {\n type: 'text',\n label: 'Input',\n helpText: 'The input to categorize (usually @input)',\n required: true,\n evaluated: true,\n placeholder: '@input'\n },\n categories: {\n type: 'array',\n helpText: 'Define the categories for classification',\n required: true,\n sortable: true,\n itemLabel: 'Category',\n minItems: 1,\n maxItems: 10,\n isEmptyItem: (item: any) => {\n return !item.name || item.name.trim() === '';\n },\n itemConfig: {\n name: {\n type: 'text',\n placeholder: 'Category name',\n required: true\n }\n }\n }\n },\n layout: ['llm', 'input', 'categories'],\n validate: (formData: FormData) => {\n const errors: { [key: string]: string } = {};\n\n // Check for duplicate category names\n if (formData.categories && Array.isArray(formData.categories)) {\n const categories = formData.categories.filter(\n (item: any) => item?.name && item.name.trim() !== ''\n );\n\n // Find all categories that have duplicates (case-insensitive)\n const duplicateCategories = [];\n const lowerCaseMap = new Map();\n\n // First pass: map lowercase names to all original cases\n categories.forEach((category) => {\n const lowerName = category.name.trim().toLowerCase();\n if (!lowerCaseMap.has(lowerName)) {\n lowerCaseMap.set(lowerName, []);\n }\n lowerCaseMap.get(lowerName).push(category.name.trim());\n });\n\n // Second pass: collect all names that appear more than once\n lowerCaseMap.forEach((originalNames) => {\n if (originalNames.length > 1) {\n duplicateCategories.push(...originalNames);\n }\n });\n\n if (duplicateCategories.length > 0) {\n const uniqueDuplicates = [...new Set(duplicateCategories)];\n errors.categories = `Duplicate category names found: ${uniqueDuplicates.join(\n ', '\n )}`;\n }\n }\n\n return {\n valid: Object.keys(errors).length === 0,\n errors\n };\n },\n render: (node: Node) => {\n const callLlmAction = node.actions?.find(\n (action) => action.type === 'call_llm'\n ) as CallLLM;\n return html`\n <div class=\"body\">Categorize with ${callLlmAction.llm.name}</div>\n `;\n },\n toFormData: (node: Node) => {\n // Extract data from the existing node structure\n const callLlmAction = node.actions?.find(\n (action) => action.type === 'call_llm'\n ) as any;\n const categories =\n node.router?.categories\n ?.filter((cat) => cat.name !== 'Other' && cat.name !== 'Failure')\n .map((cat) => ({ name: cat.name })) || [];\n\n return {\n uuid: node.uuid,\n llm: callLlmAction?.llm\n ? [{ value: callLlmAction.llm.uuid, name: callLlmAction.llm.name }]\n : [],\n input: callLlmAction?.input || '@input',\n categories: categories\n };\n },\n fromFormData: (formData: FormData, originalNode: Node): Node => {\n // Get LLM selection\n const llmSelection =\n Array.isArray(formData.llm) && formData.llm.length > 0\n ? formData.llm[0]\n : null;\n\n // Get user categories\n const userCategories = (formData.categories || [])\n .filter((item: any) => item?.name?.trim())\n .map((item: any) => item.name.trim());\n\n // Find existing call_llm action to preserve its UUID\n const existingCallLlmAction = originalNode.actions?.find(\n (action) => action.type === 'call_llm'\n );\n const callLlmUuid = existingCallLlmAction?.uuid || generateUUID();\n\n // Create call_llm action (using any type to match the example format)\n const callLlmAction: CallLLM = {\n type: 'call_llm',\n uuid: callLlmUuid,\n llm: llmSelection\n ? { uuid: llmSelection.value, name: llmSelection.name }\n : { uuid: '', name: '' },\n instructions: `@(prompt(\"categorize\", slice(node.categories, 0, -2)))`,\n input: formData.input || '@input',\n output_local: '_llm_output'\n };\n\n // Create categories and exits\n const existingCategories = originalNode.router?.categories || [];\n const existingExits = originalNode.exits || [];\n const existingCases = originalNode.router?.cases || [];\n\n const { router, exits } = createMultiCategoryRouter(\n '@locals._llm_output',\n userCategories,\n (categoryName) => ({\n type: 'has_only_text',\n arguments: [categoryName]\n }),\n existingCategories,\n existingExits,\n existingCases\n );\n\n // Return the complete node\n return {\n uuid: originalNode.uuid,\n actions: [callLlmAction],\n router: router,\n exits: exits\n };\n },\n\n // Localization support for categories\n localizable: 'categories',\n toLocalizationFormData: categoriesToLocalizationFormData,\n fromLocalizationFormData: localizationFormDataToCategories\n};\n"]}