@nyaruka/temba-components 0.131.1 → 0.131.3

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 (485) hide show
  1. package/.github/workflows/publish.yml +4 -1
  2. package/CHANGELOG.md +75 -1
  3. package/demo/components/floating-tabs/example.html +400 -0
  4. package/demo/components/flow/index.html +1 -1
  5. package/demo/data/flows/food-order.json +2 -2
  6. package/demo/data/flows/sample-flow.json +113 -125
  7. package/demo/data/flows/voicemail.json +613 -0
  8. package/demo/index.html +6 -0
  9. package/dist/locales/es.js +5 -5
  10. package/dist/locales/es.js.map +1 -1
  11. package/dist/locales/fr.js +5 -5
  12. package/dist/locales/fr.js.map +1 -1
  13. package/dist/locales/locale-codes.js +11 -2
  14. package/dist/locales/locale-codes.js.map +1 -1
  15. package/dist/locales/pt.js +5 -5
  16. package/dist/locales/pt.js.map +1 -1
  17. package/dist/static/svg/index.svg +1 -1
  18. package/dist/temba-components.js +1773 -662
  19. package/dist/temba-components.js.map +1 -1
  20. package/out-tsc/src/Icons.js +4 -1
  21. package/out-tsc/src/Icons.js.map +1 -1
  22. package/out-tsc/src/display/FloatingTab.js +167 -0
  23. package/out-tsc/src/display/FloatingTab.js.map +1 -0
  24. package/out-tsc/src/display/ProgressBar.js +22 -2
  25. package/out-tsc/src/display/ProgressBar.js.map +1 -1
  26. package/out-tsc/src/events.js.map +1 -1
  27. package/out-tsc/src/flow/CanvasMenu.js +200 -0
  28. package/out-tsc/src/flow/CanvasMenu.js.map +1 -0
  29. package/out-tsc/src/flow/CanvasNode.js +489 -47
  30. package/out-tsc/src/flow/CanvasNode.js.map +1 -1
  31. package/out-tsc/src/flow/Editor.js +1417 -67
  32. package/out-tsc/src/flow/Editor.js.map +1 -1
  33. package/out-tsc/src/flow/NodeEditor.js +479 -112
  34. package/out-tsc/src/flow/NodeEditor.js.map +1 -1
  35. package/out-tsc/src/flow/NodeTypeSelector.js +540 -0
  36. package/out-tsc/src/flow/NodeTypeSelector.js.map +1 -0
  37. package/out-tsc/src/flow/StickyNote.js +12 -3
  38. package/out-tsc/src/flow/StickyNote.js.map +1 -1
  39. package/out-tsc/src/flow/actions/add_contact_groups.js +4 -3
  40. package/out-tsc/src/flow/actions/add_contact_groups.js.map +1 -1
  41. package/out-tsc/src/flow/actions/add_contact_urn.js +63 -4
  42. package/out-tsc/src/flow/actions/add_contact_urn.js.map +1 -1
  43. package/out-tsc/src/flow/actions/add_input_labels.js +4 -3
  44. package/out-tsc/src/flow/actions/add_input_labels.js.map +1 -1
  45. package/out-tsc/src/flow/actions/play_audio.js +3 -2
  46. package/out-tsc/src/flow/actions/play_audio.js.map +1 -1
  47. package/out-tsc/src/flow/actions/remove_contact_groups.js +7 -5
  48. package/out-tsc/src/flow/actions/remove_contact_groups.js.map +1 -1
  49. package/out-tsc/src/flow/actions/request_optin.js +3 -2
  50. package/out-tsc/src/flow/actions/request_optin.js.map +1 -1
  51. package/out-tsc/src/flow/actions/say_msg.js +3 -2
  52. package/out-tsc/src/flow/actions/say_msg.js.map +1 -1
  53. package/out-tsc/src/flow/actions/send_broadcast.js +77 -23
  54. package/out-tsc/src/flow/actions/send_broadcast.js.map +1 -1
  55. package/out-tsc/src/flow/actions/send_email.js +5 -5
  56. package/out-tsc/src/flow/actions/send_email.js.map +1 -1
  57. package/out-tsc/src/flow/actions/send_msg.js +101 -21
  58. package/out-tsc/src/flow/actions/send_msg.js.map +1 -1
  59. package/out-tsc/src/flow/actions/set_contact_channel.js +6 -9
  60. package/out-tsc/src/flow/actions/set_contact_channel.js.map +1 -1
  61. package/out-tsc/src/flow/actions/set_contact_field.js +20 -20
  62. package/out-tsc/src/flow/actions/set_contact_field.js.map +1 -1
  63. package/out-tsc/src/flow/actions/set_contact_language.js +3 -2
  64. package/out-tsc/src/flow/actions/set_contact_language.js.map +1 -1
  65. package/out-tsc/src/flow/actions/set_contact_name.js +3 -12
  66. package/out-tsc/src/flow/actions/set_contact_name.js.map +1 -1
  67. package/out-tsc/src/flow/actions/set_contact_status.js +3 -2
  68. package/out-tsc/src/flow/actions/set_contact_status.js.map +1 -1
  69. package/out-tsc/src/flow/actions/set_run_result.js +4 -3
  70. package/out-tsc/src/flow/actions/set_run_result.js.map +1 -1
  71. package/out-tsc/src/flow/actions/start_session.js +181 -6
  72. package/out-tsc/src/flow/actions/start_session.js.map +1 -1
  73. package/out-tsc/src/flow/config.js +11 -23
  74. package/out-tsc/src/flow/config.js.map +1 -1
  75. package/out-tsc/src/flow/currencies.js +45 -0
  76. package/out-tsc/src/flow/currencies.js.map +1 -0
  77. package/out-tsc/src/flow/nodes/shared-rules.js +257 -0
  78. package/out-tsc/src/flow/nodes/shared-rules.js.map +1 -0
  79. package/out-tsc/src/flow/nodes/shared.js +71 -0
  80. package/out-tsc/src/flow/nodes/shared.js.map +1 -0
  81. package/out-tsc/src/flow/nodes/split_by_airtime.js +211 -5
  82. package/out-tsc/src/flow/nodes/split_by_airtime.js.map +1 -1
  83. package/out-tsc/src/flow/nodes/split_by_contact_field.js +152 -3
  84. package/out-tsc/src/flow/nodes/split_by_contact_field.js.map +1 -1
  85. package/out-tsc/src/flow/nodes/split_by_expression.js +73 -2
  86. package/out-tsc/src/flow/nodes/split_by_expression.js.map +1 -1
  87. package/out-tsc/src/flow/nodes/split_by_groups.js +18 -10
  88. package/out-tsc/src/flow/nodes/split_by_groups.js.map +1 -1
  89. package/out-tsc/src/flow/nodes/split_by_intent.js +8 -0
  90. package/out-tsc/src/flow/nodes/split_by_intent.js.map +1 -0
  91. package/out-tsc/src/flow/nodes/split_by_llm.js +11 -3
  92. package/out-tsc/src/flow/nodes/split_by_llm.js.map +1 -1
  93. package/out-tsc/src/flow/nodes/split_by_llm_categorize.js +10 -3
  94. package/out-tsc/src/flow/nodes/split_by_llm_categorize.js.map +1 -1
  95. package/out-tsc/src/flow/nodes/split_by_random.js +10 -4
  96. package/out-tsc/src/flow/nodes/split_by_random.js.map +1 -1
  97. package/out-tsc/src/flow/nodes/split_by_resthook.js +113 -0
  98. package/out-tsc/src/flow/nodes/split_by_resthook.js.map +1 -0
  99. package/out-tsc/src/flow/nodes/split_by_run_result.js +211 -3
  100. package/out-tsc/src/flow/nodes/split_by_run_result.js.map +1 -1
  101. package/out-tsc/src/flow/nodes/split_by_scheme.js +158 -2
  102. package/out-tsc/src/flow/nodes/split_by_scheme.js.map +1 -1
  103. package/out-tsc/src/flow/nodes/split_by_subflow.js +13 -5
  104. package/out-tsc/src/flow/nodes/split_by_subflow.js.map +1 -1
  105. package/out-tsc/src/flow/nodes/split_by_ticket.js +10 -3
  106. package/out-tsc/src/flow/nodes/split_by_ticket.js.map +1 -1
  107. package/out-tsc/src/flow/nodes/split_by_webhook.js +10 -3
  108. package/out-tsc/src/flow/nodes/split_by_webhook.js.map +1 -1
  109. package/out-tsc/src/flow/nodes/wait_for_digits.js +3 -2
  110. package/out-tsc/src/flow/nodes/wait_for_digits.js.map +1 -1
  111. package/out-tsc/src/flow/nodes/wait_for_menu.js +3 -2
  112. package/out-tsc/src/flow/nodes/wait_for_menu.js.map +1 -1
  113. package/out-tsc/src/flow/nodes/wait_for_response.js +38 -568
  114. package/out-tsc/src/flow/nodes/wait_for_response.js.map +1 -1
  115. package/out-tsc/src/flow/types.js +86 -12
  116. package/out-tsc/src/flow/types.js.map +1 -1
  117. package/out-tsc/src/flow/utils.js +101 -14
  118. package/out-tsc/src/flow/utils.js.map +1 -1
  119. package/out-tsc/src/form/FieldRenderer.js +2 -4
  120. package/out-tsc/src/form/FieldRenderer.js.map +1 -1
  121. package/out-tsc/src/interfaces.js +3 -0
  122. package/out-tsc/src/interfaces.js.map +1 -1
  123. package/out-tsc/src/layout/FloatingWindow.js +346 -0
  124. package/out-tsc/src/layout/FloatingWindow.js.map +1 -0
  125. package/out-tsc/src/list/SortableList.js +98 -33
  126. package/out-tsc/src/list/SortableList.js.map +1 -1
  127. package/out-tsc/src/live/ContactChat.js +6 -25
  128. package/out-tsc/src/live/ContactChat.js.map +1 -1
  129. package/out-tsc/src/locales/es.js +5 -5
  130. package/out-tsc/src/locales/es.js.map +1 -1
  131. package/out-tsc/src/locales/fr.js +5 -5
  132. package/out-tsc/src/locales/fr.js.map +1 -1
  133. package/out-tsc/src/locales/locale-codes.js +11 -2
  134. package/out-tsc/src/locales/locale-codes.js.map +1 -1
  135. package/out-tsc/src/locales/pt.js +5 -5
  136. package/out-tsc/src/locales/pt.js.map +1 -1
  137. package/out-tsc/src/store/AppState.js +120 -0
  138. package/out-tsc/src/store/AppState.js.map +1 -1
  139. package/out-tsc/src/utils.js +254 -13
  140. package/out-tsc/src/utils.js.map +1 -1
  141. package/out-tsc/temba-modules.js +8 -0
  142. package/out-tsc/temba-modules.js.map +1 -1
  143. package/out-tsc/test/ActionHelper.js +3 -3
  144. package/out-tsc/test/ActionHelper.js.map +1 -1
  145. package/out-tsc/test/NodeHelper.js +6 -3
  146. package/out-tsc/test/NodeHelper.js.map +1 -1
  147. package/out-tsc/test/actions/add_contact_urn.test.js +202 -0
  148. package/out-tsc/test/actions/add_contact_urn.test.js.map +1 -0
  149. package/out-tsc/test/actions/send_broadcast.test.js +148 -0
  150. package/out-tsc/test/actions/send_broadcast.test.js.map +1 -0
  151. package/out-tsc/test/actions/send_email.test.js +17 -23
  152. package/out-tsc/test/actions/send_email.test.js.map +1 -1
  153. package/out-tsc/test/actions/send_msg.test.js +33 -15
  154. package/out-tsc/test/actions/send_msg.test.js.map +1 -1
  155. package/out-tsc/test/actions/start_session.test.js +116 -0
  156. package/out-tsc/test/actions/start_session.test.js.map +1 -0
  157. package/out-tsc/test/nodes/split_by_airtime.test.js +604 -0
  158. package/out-tsc/test/nodes/split_by_airtime.test.js.map +1 -0
  159. package/out-tsc/test/nodes/split_by_contact_field.test.js +387 -0
  160. package/out-tsc/test/nodes/split_by_contact_field.test.js.map +1 -0
  161. package/out-tsc/test/nodes/split_by_expression.test.js +614 -0
  162. package/out-tsc/test/nodes/split_by_expression.test.js.map +1 -0
  163. package/out-tsc/test/nodes/split_by_random.test.js +3 -3
  164. package/out-tsc/test/nodes/split_by_random.test.js.map +1 -1
  165. package/out-tsc/test/nodes/split_by_resthook.test.js +337 -0
  166. package/out-tsc/test/nodes/split_by_resthook.test.js.map +1 -0
  167. package/out-tsc/test/nodes/split_by_run_result.test.js +920 -0
  168. package/out-tsc/test/nodes/split_by_run_result.test.js.map +1 -0
  169. package/out-tsc/test/nodes/split_by_scheme.test.js +399 -0
  170. package/out-tsc/test/nodes/split_by_scheme.test.js.map +1 -0
  171. package/out-tsc/test/nodes/split_by_subflow.test.js +333 -0
  172. package/out-tsc/test/nodes/split_by_subflow.test.js.map +1 -0
  173. package/out-tsc/test/nodes/wait_for_digits.test.js +2 -2
  174. package/out-tsc/test/nodes/wait_for_digits.test.js.map +1 -1
  175. package/out-tsc/test/nodes/wait_for_response.test.js +2 -1
  176. package/out-tsc/test/nodes/wait_for_response.test.js.map +1 -1
  177. package/out-tsc/test/temba-action-drag-between-nodes.test.js +252 -0
  178. package/out-tsc/test/temba-action-drag-between-nodes.test.js.map +1 -0
  179. package/out-tsc/test/temba-canvas-menu.test.js +122 -0
  180. package/out-tsc/test/temba-canvas-menu.test.js.map +1 -0
  181. package/out-tsc/test/temba-floating-tab.test.js +91 -0
  182. package/out-tsc/test/temba-floating-tab.test.js.map +1 -0
  183. package/out-tsc/test/temba-floating-window.test.js +301 -0
  184. package/out-tsc/test/temba-floating-window.test.js.map +1 -0
  185. package/out-tsc/test/temba-flow-editor-node.test.js +202 -2
  186. package/out-tsc/test/temba-flow-editor-node.test.js.map +1 -1
  187. package/out-tsc/test/temba-flow-editor.test.js +7 -8
  188. package/out-tsc/test/temba-flow-editor.test.js.map +1 -1
  189. package/out-tsc/test/temba-localization.test.js +471 -0
  190. package/out-tsc/test/temba-localization.test.js.map +1 -0
  191. package/out-tsc/test/temba-node-editor.test.js +3 -1
  192. package/out-tsc/test/temba-node-editor.test.js.map +1 -1
  193. package/out-tsc/test/temba-node-type-selector.test.js +265 -0
  194. package/out-tsc/test/temba-node-type-selector.test.js.map +1 -0
  195. package/out-tsc/test/temba-omnibox.test.js +2 -1
  196. package/out-tsc/test/temba-omnibox.test.js.map +1 -1
  197. package/out-tsc/test/temba-sortable-list.test.js +51 -0
  198. package/out-tsc/test/temba-sortable-list.test.js.map +1 -1
  199. package/out-tsc/test/temba-utils-index.test.js +1 -27
  200. package/out-tsc/test/temba-utils-index.test.js.map +1 -1
  201. package/out-tsc/test/utils.test.js +20 -0
  202. package/out-tsc/test/utils.test.js.map +1 -1
  203. package/package.json +2 -1
  204. package/screenshots/truth/actions/add_contact_groups/editor/descriptive-group-names.png +0 -0
  205. package/screenshots/truth/actions/add_contact_groups/editor/long-group-names.png +0 -0
  206. package/screenshots/truth/actions/add_contact_groups/editor/many-groups.png +0 -0
  207. package/screenshots/truth/actions/add_contact_groups/editor/multiple-groups.png +0 -0
  208. package/screenshots/truth/actions/add_contact_groups/editor/single-group.png +0 -0
  209. package/screenshots/truth/actions/add_contact_groups/render/descriptive-group-names.png +0 -0
  210. package/screenshots/truth/actions/add_contact_groups/render/long-group-names.png +0 -0
  211. package/screenshots/truth/actions/add_contact_groups/render/many-groups.png +0 -0
  212. package/screenshots/truth/actions/add_contact_groups/render/multiple-groups.png +0 -0
  213. package/screenshots/truth/actions/add_contact_groups/render/single-group.png +0 -0
  214. package/screenshots/truth/actions/add_contact_urn/editor/expression-facebook.png +0 -0
  215. package/screenshots/truth/actions/add_contact_urn/editor/expression-phone.png +0 -0
  216. package/screenshots/truth/actions/add_contact_urn/editor/facebook-id.png +0 -0
  217. package/screenshots/truth/actions/add_contact_urn/editor/instagram-handle.png +0 -0
  218. package/screenshots/truth/actions/add_contact_urn/editor/line-id.png +0 -0
  219. package/screenshots/truth/actions/add_contact_urn/editor/phone-number.png +0 -0
  220. package/screenshots/truth/actions/add_contact_urn/editor/telegram-id.png +0 -0
  221. package/screenshots/truth/actions/add_contact_urn/editor/viber-id.png +0 -0
  222. package/screenshots/truth/actions/add_contact_urn/editor/wechat-id.png +0 -0
  223. package/screenshots/truth/actions/add_contact_urn/editor/whatsapp.png +0 -0
  224. package/screenshots/truth/actions/add_contact_urn/render/expression-facebook.png +0 -0
  225. package/screenshots/truth/actions/add_contact_urn/render/expression-phone.png +0 -0
  226. package/screenshots/truth/actions/add_contact_urn/render/facebook-id.png +0 -0
  227. package/screenshots/truth/actions/add_contact_urn/render/instagram-handle.png +0 -0
  228. package/screenshots/truth/actions/add_contact_urn/render/line-id.png +0 -0
  229. package/screenshots/truth/actions/add_contact_urn/render/phone-number.png +0 -0
  230. package/screenshots/truth/actions/add_contact_urn/render/telegram-id.png +0 -0
  231. package/screenshots/truth/actions/add_contact_urn/render/viber-id.png +0 -0
  232. package/screenshots/truth/actions/add_contact_urn/render/wechat-id.png +0 -0
  233. package/screenshots/truth/actions/add_contact_urn/render/whatsapp.png +0 -0
  234. package/screenshots/truth/actions/remove_contact_groups/editor/cleanup-groups.png +0 -0
  235. package/screenshots/truth/actions/remove_contact_groups/editor/long-descriptive-group-names.png +0 -0
  236. package/screenshots/truth/actions/remove_contact_groups/editor/many-groups.png +0 -0
  237. package/screenshots/truth/actions/remove_contact_groups/editor/multiple-groups.png +0 -0
  238. package/screenshots/truth/actions/remove_contact_groups/editor/remove-from-all-groups.png +0 -0
  239. package/screenshots/truth/actions/remove_contact_groups/editor/single-group.png +0 -0
  240. package/screenshots/truth/actions/remove_contact_groups/render/cleanup-groups.png +0 -0
  241. package/screenshots/truth/actions/remove_contact_groups/render/long-descriptive-group-names.png +0 -0
  242. package/screenshots/truth/actions/remove_contact_groups/render/many-groups.png +0 -0
  243. package/screenshots/truth/actions/remove_contact_groups/render/multiple-groups.png +0 -0
  244. package/screenshots/truth/actions/remove_contact_groups/render/remove-from-all-groups.png +0 -0
  245. package/screenshots/truth/actions/remove_contact_groups/render/single-group.png +0 -0
  246. package/screenshots/truth/actions/send_broadcast/editor/contacts-only.png +0 -0
  247. package/screenshots/truth/actions/send_broadcast/editor/groups-and-contacts.png +0 -0
  248. package/screenshots/truth/actions/send_broadcast/editor/groups-only.png +0 -0
  249. package/screenshots/truth/actions/send_broadcast/editor/many-groups.png +0 -0
  250. package/screenshots/truth/actions/send_broadcast/editor/multiline-text.png +0 -0
  251. package/screenshots/truth/actions/send_broadcast/editor/with-attachments.png +0 -0
  252. package/screenshots/truth/actions/send_broadcast/render/contacts-only.png +0 -0
  253. package/screenshots/truth/actions/send_broadcast/render/groups-and-contacts.png +0 -0
  254. package/screenshots/truth/actions/send_broadcast/render/groups-only.png +0 -0
  255. package/screenshots/truth/actions/send_broadcast/render/many-groups.png +0 -0
  256. package/screenshots/truth/actions/send_broadcast/render/multiline-text.png +0 -0
  257. package/screenshots/truth/actions/send_broadcast/render/with-attachments.png +0 -0
  258. package/screenshots/truth/actions/send_email/editor/complex-business-email.png +0 -0
  259. package/screenshots/truth/actions/send_email/editor/empty-body.png +0 -0
  260. package/screenshots/truth/actions/send_email/editor/empty-subject.png +0 -0
  261. package/screenshots/truth/actions/send_email/editor/long-subject.png +0 -0
  262. package/screenshots/truth/actions/send_email/editor/multiline-body.png +0 -0
  263. package/screenshots/truth/actions/send_email/editor/multiple-recipients.png +0 -0
  264. package/screenshots/truth/actions/send_email/editor/simple-email.png +0 -0
  265. package/screenshots/truth/actions/send_email/editor/with-expressions.png +0 -0
  266. package/screenshots/truth/actions/send_email/render/complex-business-email.png +0 -0
  267. package/screenshots/truth/actions/send_email/render/empty-body.png +0 -0
  268. package/screenshots/truth/actions/send_email/render/empty-subject.png +0 -0
  269. package/screenshots/truth/actions/send_email/render/long-subject.png +0 -0
  270. package/screenshots/truth/actions/send_email/render/multiline-body.png +0 -0
  271. package/screenshots/truth/actions/send_email/render/multiple-recipients.png +0 -0
  272. package/screenshots/truth/actions/send_email/render/simple-email.png +0 -0
  273. package/screenshots/truth/actions/send_email/render/with-expressions.png +0 -0
  274. package/screenshots/truth/actions/send_msg/editor/long-quick-replies.png +0 -0
  275. package/screenshots/truth/actions/send_msg/editor/multiline-text-with-replies.png +0 -0
  276. package/screenshots/truth/actions/send_msg/editor/simple-text.png +0 -0
  277. package/screenshots/truth/actions/send_msg/editor/text-with-linebreaks.png +0 -0
  278. package/screenshots/truth/actions/send_msg/editor/text-with-many-quick-replies.png +0 -0
  279. package/screenshots/truth/actions/send_msg/editor/text-with-quick-replies.png +0 -0
  280. package/screenshots/truth/actions/send_msg/editor/text-without-quick-replies.png +0 -0
  281. package/screenshots/truth/actions/send_msg/render/long-quick-replies.png +0 -0
  282. package/screenshots/truth/actions/send_msg/render/multiline-text-with-replies.png +0 -0
  283. package/screenshots/truth/actions/send_msg/render/simple-text.png +0 -0
  284. package/screenshots/truth/actions/send_msg/render/text-with-linebreaks.png +0 -0
  285. package/screenshots/truth/actions/send_msg/render/text-with-many-quick-replies.png +0 -0
  286. package/screenshots/truth/actions/send_msg/render/text-with-quick-replies.png +0 -0
  287. package/screenshots/truth/actions/send_msg/render/text-without-quick-replies.png +0 -0
  288. package/screenshots/truth/actions/start_session/editor/contact-query.png +0 -0
  289. package/screenshots/truth/actions/start_session/editor/contacts-only.png +0 -0
  290. package/screenshots/truth/actions/start_session/editor/create-contact.png +0 -0
  291. package/screenshots/truth/actions/start_session/editor/groups-and-contacts.png +0 -0
  292. package/screenshots/truth/actions/start_session/editor/groups-only.png +0 -0
  293. package/screenshots/truth/actions/start_session/editor/many-recipients.png +0 -0
  294. package/screenshots/truth/actions/start_session/render/contact-query.png +0 -0
  295. package/screenshots/truth/actions/start_session/render/contacts-only.png +0 -0
  296. package/screenshots/truth/actions/start_session/render/create-contact.png +0 -0
  297. package/screenshots/truth/actions/start_session/render/groups-and-contacts.png +0 -0
  298. package/screenshots/truth/actions/start_session/render/groups-only.png +0 -0
  299. package/screenshots/truth/actions/start_session/render/many-recipients.png +0 -0
  300. package/screenshots/truth/canvas-menu/open.png +0 -0
  301. package/screenshots/truth/editor/router.png +0 -0
  302. package/screenshots/truth/editor/wait.png +0 -0
  303. package/screenshots/truth/floating-tab/default.png +0 -0
  304. package/screenshots/truth/floating-tab/gray.png +0 -0
  305. package/screenshots/truth/floating-tab/green.png +0 -0
  306. package/screenshots/truth/floating-tab/hidden.png +0 -0
  307. package/screenshots/truth/floating-tab/hover.png +0 -0
  308. package/screenshots/truth/floating-tab/purple.png +0 -0
  309. package/screenshots/truth/floating-window/chromeless.png +0 -0
  310. package/screenshots/truth/floating-window/custom-size.png +0 -0
  311. package/screenshots/truth/floating-window/default.png +0 -0
  312. package/screenshots/truth/floating-window/with-header.png +0 -0
  313. package/screenshots/truth/list/fields-dragging.png +0 -0
  314. package/screenshots/truth/list/sortable-dragging.png +0 -0
  315. package/screenshots/truth/node-type-selector/action-mode.png +0 -0
  316. package/screenshots/truth/node-type-selector/split-mode.png +0 -0
  317. package/screenshots/truth/nodes/split_by_llm/editor/information-extraction.png +0 -0
  318. package/screenshots/truth/nodes/split_by_llm/editor/sentiment-analysis.png +0 -0
  319. package/screenshots/truth/nodes/split_by_llm/editor/summarization.png +0 -0
  320. package/screenshots/truth/nodes/split_by_llm/editor/translation-task.png +0 -0
  321. package/screenshots/truth/nodes/split_by_llm/render/information-extraction.png +0 -0
  322. package/screenshots/truth/nodes/split_by_llm/render/sentiment-analysis.png +0 -0
  323. package/screenshots/truth/nodes/split_by_llm/render/summarization.png +0 -0
  324. package/screenshots/truth/nodes/split_by_llm/render/translation-task.png +0 -0
  325. package/screenshots/truth/nodes/split_by_llm_categorize/editor/basic-categorization.png +0 -0
  326. package/screenshots/truth/nodes/split_by_llm_categorize/editor/custom-input-and-result-name.png +0 -0
  327. package/screenshots/truth/nodes/split_by_llm_categorize/editor/feedback-categorization.png +0 -0
  328. package/screenshots/truth/nodes/split_by_llm_categorize/editor/many-categories.png +0 -0
  329. package/screenshots/truth/nodes/split_by_llm_categorize/editor/minimal-categories.png +0 -0
  330. package/screenshots/truth/nodes/split_by_llm_categorize/render/basic-categorization.png +0 -0
  331. package/screenshots/truth/nodes/split_by_llm_categorize/render/custom-input-and-result-name.png +0 -0
  332. package/screenshots/truth/nodes/split_by_llm_categorize/render/feedback-categorization.png +0 -0
  333. package/screenshots/truth/nodes/split_by_llm_categorize/render/many-categories.png +0 -0
  334. package/screenshots/truth/nodes/split_by_llm_categorize/render/minimal-categories.png +0 -0
  335. package/screenshots/truth/nodes/split_by_random/editor/ab-test-multiple-variants.png +0 -0
  336. package/screenshots/truth/nodes/split_by_random/editor/sampling-split.png +0 -0
  337. package/screenshots/truth/nodes/split_by_random/editor/three-way-split.png +0 -0
  338. package/screenshots/truth/nodes/split_by_random/editor/two-bucket-split.png +0 -0
  339. package/screenshots/truth/nodes/split_by_random/render/ab-test-multiple-variants.png +0 -0
  340. package/screenshots/truth/nodes/split_by_random/render/sampling-split.png +0 -0
  341. package/screenshots/truth/nodes/split_by_random/render/three-way-split.png +0 -0
  342. package/screenshots/truth/nodes/split_by_random/render/two-bucket-split.png +0 -0
  343. package/screenshots/truth/nodes/wait_for_digits/editor/basic-digits-wait.png +0 -0
  344. package/screenshots/truth/nodes/wait_for_digits/editor/phone-number-collection.png +0 -0
  345. package/screenshots/truth/nodes/wait_for_digits/editor/single-digit-with-timeout.png +0 -0
  346. package/screenshots/truth/nodes/wait_for_digits/editor/verification-code.png +0 -0
  347. package/screenshots/truth/nodes/wait_for_digits/render/basic-digits-wait.png +0 -0
  348. package/screenshots/truth/nodes/wait_for_digits/render/phone-number-collection.png +0 -0
  349. package/screenshots/truth/nodes/wait_for_digits/render/single-digit-with-timeout.png +0 -0
  350. package/screenshots/truth/nodes/wait_for_digits/render/verification-code.png +0 -0
  351. package/screenshots/truth/nodes/wait_for_response/editor/basic-wait.png +0 -0
  352. package/screenshots/truth/nodes/wait_for_response/editor/custom-result-name.png +0 -0
  353. package/screenshots/truth/nodes/wait_for_response/editor/no-timeout.png +0 -0
  354. package/screenshots/truth/nodes/wait_for_response/editor/short-timeout.png +0 -0
  355. package/screenshots/truth/nodes/wait_for_response/render/basic-wait.png +0 -0
  356. package/screenshots/truth/nodes/wait_for_response/render/custom-result-name.png +0 -0
  357. package/screenshots/truth/nodes/wait_for_response/render/no-timeout.png +0 -0
  358. package/screenshots/truth/nodes/wait_for_response/render/short-timeout.png +0 -0
  359. package/src/Icons.ts +4 -1
  360. package/src/display/FloatingTab.ts +174 -0
  361. package/src/display/ProgressBar.ts +22 -2
  362. package/src/events.ts +2 -8
  363. package/src/flow/CanvasMenu.ts +217 -0
  364. package/src/flow/CanvasNode.ts +596 -40
  365. package/src/flow/Editor.ts +1721 -45
  366. package/src/flow/NodeEditor.ts +621 -144
  367. package/src/flow/NodeTypeSelector.ts +636 -0
  368. package/src/flow/StickyNote.ts +12 -3
  369. package/src/flow/actions/add_contact_groups.ts +5 -4
  370. package/src/flow/actions/add_contact_urn.ts +78 -4
  371. package/src/flow/actions/add_input_labels.ts +5 -4
  372. package/src/flow/actions/play_audio.ts +3 -2
  373. package/src/flow/actions/remove_contact_groups.ts +16 -6
  374. package/src/flow/actions/request_optin.ts +3 -2
  375. package/src/flow/actions/say_msg.ts +3 -2
  376. package/src/flow/actions/send_broadcast.ts +86 -23
  377. package/src/flow/actions/send_email.ts +12 -6
  378. package/src/flow/actions/send_msg.ts +155 -34
  379. package/src/flow/actions/set_contact_channel.ts +6 -11
  380. package/src/flow/actions/set_contact_field.ts +21 -25
  381. package/src/flow/actions/set_contact_language.ts +11 -4
  382. package/src/flow/actions/set_contact_name.ts +4 -15
  383. package/src/flow/actions/set_contact_status.ts +4 -3
  384. package/src/flow/actions/set_run_result.ts +5 -4
  385. package/src/flow/actions/start_session.ts +210 -6
  386. package/src/flow/config.ts +11 -23
  387. package/src/flow/currencies.ts +51 -0
  388. package/src/flow/nodes/shared-rules.ts +301 -0
  389. package/src/flow/nodes/shared.ts +87 -0
  390. package/src/flow/nodes/split_by_airtime.ts +255 -5
  391. package/src/flow/nodes/split_by_contact_field.ts +195 -3
  392. package/src/flow/nodes/split_by_expression.ts +104 -2
  393. package/src/flow/nodes/split_by_groups.ts +26 -11
  394. package/src/flow/nodes/split_by_intent.ts +8 -0
  395. package/src/flow/nodes/split_by_llm.ts +22 -4
  396. package/src/flow/nodes/split_by_llm_categorize.ts +22 -5
  397. package/src/flow/nodes/split_by_random.ts +16 -6
  398. package/src/flow/nodes/split_by_resthook.ts +140 -0
  399. package/src/flow/nodes/split_by_run_result.ts +259 -3
  400. package/src/flow/nodes/split_by_scheme.ts +202 -2
  401. package/src/flow/nodes/split_by_subflow.ts +17 -5
  402. package/src/flow/nodes/split_by_ticket.ts +15 -4
  403. package/src/flow/nodes/split_by_webhook.ts +17 -6
  404. package/src/flow/nodes/wait_for_digits.ts +3 -2
  405. package/src/flow/nodes/wait_for_menu.ts +3 -2
  406. package/src/flow/nodes/wait_for_response.ts +59 -680
  407. package/src/flow/types.ts +156 -23
  408. package/src/flow/utils.ts +108 -14
  409. package/src/form/FieldRenderer.ts +2 -4
  410. package/src/interfaces.ts +3 -0
  411. package/src/layout/FloatingWindow.ts +386 -0
  412. package/src/list/SortableList.ts +109 -34
  413. package/src/live/ContactChat.ts +7 -25
  414. package/src/locales/es.ts +18 -13
  415. package/src/locales/fr.ts +18 -13
  416. package/src/locales/locale-codes.ts +11 -2
  417. package/src/locales/pt.ts +18 -13
  418. package/src/store/AppState.ts +173 -0
  419. package/src/store/flow-definition.d.ts +2 -5
  420. package/src/utils.ts +332 -12
  421. package/static/api/channels.json +46 -0
  422. package/static/api/llms.json +18 -0
  423. package/static/api/resthooks.json +31 -0
  424. package/static/svg/index.svg +1 -1
  425. package/static/svg/work/traced/lightning-02.svg +1 -0
  426. package/static/svg/work/used/lightning-02.svg +3 -0
  427. package/temba-modules.ts +8 -0
  428. package/test/ActionHelper.ts +3 -3
  429. package/test/NodeHelper.ts +6 -3
  430. package/test/actions/add_contact_urn.test.ts +287 -0
  431. package/test/actions/send_broadcast.test.ts +190 -0
  432. package/test/actions/send_email.test.ts +17 -23
  433. package/test/actions/send_msg.test.ts +39 -15
  434. package/test/actions/start_session.test.ts +151 -0
  435. package/test/nodes/split_by_airtime.test.ts +673 -0
  436. package/test/nodes/split_by_contact_field.test.ts +451 -0
  437. package/test/nodes/split_by_expression.test.ts +751 -0
  438. package/test/nodes/split_by_random.test.ts +3 -3
  439. package/test/nodes/split_by_resthook.test.ts +398 -0
  440. package/test/nodes/split_by_run_result.test.ts +1109 -0
  441. package/test/nodes/split_by_scheme.test.ts +486 -0
  442. package/test/nodes/split_by_subflow.test.ts +381 -0
  443. package/test/nodes/wait_for_digits.test.ts +2 -2
  444. package/test/nodes/wait_for_response.test.ts +2 -1
  445. package/test/temba-action-drag-between-nodes.test.ts +301 -0
  446. package/test/temba-canvas-menu.test.ts +156 -0
  447. package/test/temba-floating-tab.test.ts +110 -0
  448. package/test/temba-floating-window.test.ts +477 -0
  449. package/test/temba-flow-editor-node.test.ts +246 -2
  450. package/test/temba-flow-editor.test.ts +7 -8
  451. package/test/temba-localization.test.ts +611 -0
  452. package/test/temba-node-editor.test.ts +3 -1
  453. package/test/temba-node-type-selector.test.ts +355 -0
  454. package/test/temba-omnibox.test.ts +2 -1
  455. package/test/temba-sortable-list.test.ts +69 -0
  456. package/test/temba-utils-index.test.ts +0 -35
  457. package/test/utils.test.ts +22 -0
  458. package/test-assets/contacts/history.json +14 -21
  459. package/test-assets/select/llms.json +2 -2
  460. package/web-dev-server.config.mjs +49 -1
  461. package/web-test-runner.config.mjs +0 -1
  462. package/out-tsc/src/flow/actions/call_classifier.js +0 -11
  463. package/out-tsc/src/flow/actions/call_classifier.js.map +0 -1
  464. package/out-tsc/src/flow/actions/call_resthook.js +0 -11
  465. package/out-tsc/src/flow/actions/call_resthook.js.map +0 -1
  466. package/out-tsc/src/flow/actions/split_by_expression_example.js +0 -77
  467. package/out-tsc/src/flow/actions/split_by_expression_example.js.map +0 -1
  468. package/out-tsc/src/flow/actions/transfer_airtime.js +0 -11
  469. package/out-tsc/src/flow/actions/transfer_airtime.js.map +0 -1
  470. package/out-tsc/src/flow/nodes/wait_for_audio.js +0 -7
  471. package/out-tsc/src/flow/nodes/wait_for_audio.js.map +0 -1
  472. package/out-tsc/src/flow/nodes/wait_for_image.js +0 -7
  473. package/out-tsc/src/flow/nodes/wait_for_image.js.map +0 -1
  474. package/out-tsc/src/flow/nodes/wait_for_location.js +0 -7
  475. package/out-tsc/src/flow/nodes/wait_for_location.js.map +0 -1
  476. package/out-tsc/src/flow/nodes/wait_for_video.js +0 -7
  477. package/out-tsc/src/flow/nodes/wait_for_video.js.map +0 -1
  478. package/src/flow/actions/call_classifier.ts +0 -12
  479. package/src/flow/actions/call_resthook.ts +0 -12
  480. package/src/flow/actions/split_by_expression_example.ts +0 -88
  481. package/src/flow/actions/transfer_airtime.ts +0 -12
  482. package/src/flow/nodes/wait_for_audio.ts +0 -7
  483. package/src/flow/nodes/wait_for_image.ts +0 -7
  484. package/src/flow/nodes/wait_for_location.ts +0 -7
  485. package/src/flow/nodes/wait_for_video.ts +0 -7
@@ -1,18 +1,19 @@
1
1
  import { html } from 'lit-html';
2
2
  import { unsafeHTML } from 'lit-html/directives/unsafe-html.js';
3
- import { COLORS } from '../types';
3
+ import { ACTION_GROUPS, FlowTypes } from '../types';
4
4
  import { titleCase } from '../../utils';
5
5
  export const send_msg = {
6
6
  name: 'Send Message',
7
- color: COLORS.send,
7
+ group: ACTION_GROUPS.send,
8
+ flowTypes: [FlowTypes.VOICE, FlowTypes.MESSAGE, FlowTypes.BACKGROUND],
8
9
  render: (_node, action) => {
9
10
  var _a;
10
11
  const text = action.text.replace(/\n/g, '<br>');
11
12
  return html `
12
13
  ${unsafeHTML(text)}
13
- ${((_a = action.quick_replies) === null || _a === void 0 ? void 0 : _a.length) > 0
14
+ ${((_a = (action.quick_replies || [])) === null || _a === void 0 ? void 0 : _a.length) > 0
14
15
  ? html `<div class="quick-replies">
15
- ${action.quick_replies.map((reply) => {
16
+ ${(action.quick_replies || []).map((reply) => {
16
17
  return html `<div class="quick-reply">${reply}</div>`;
17
18
  })}
18
19
  ${action.template
@@ -169,35 +170,114 @@ export const send_msg = {
169
170
  formData.text = formData.text.trim();
170
171
  }
171
172
  },
172
- validate: (action) => {
173
+ validate: (formData) => {
173
174
  const errors = {};
174
- if (!action.text || action.text.trim() === '') {
175
- errors.text = 'Message text is required';
176
- }
177
- const attachments = action.attachments || [];
178
- if (attachments.length > 10) {
179
- const staticAttachments = attachments.filter((attachment) => typeof attachment === 'string' &&
180
- attachment.substring(0, attachment.indexOf(':')).includes('/'));
181
- const runtimeAttachments = attachments.filter((attachment) => typeof attachment === 'string' &&
182
- !attachment.substring(0, attachment.indexOf(':')).includes('/'));
175
+ // Check total attachment count (static + runtime should not exceed 10)
176
+ const staticAttachments = formData.attachments || [];
177
+ const runtimeAttachments = (formData.runtime_attachments || []).filter((item) => item && item.expression && item.expression.trim() !== '');
178
+ const totalAttachments = staticAttachments.length + runtimeAttachments.length;
179
+ if (totalAttachments > 10) {
183
180
  if (runtimeAttachments.length > 0) {
184
181
  errors.runtime_attachments =
185
182
  'Each message can only have up to 10 attachments';
186
183
  }
187
184
  if (staticAttachments.length > 0) {
188
- const message = 'Each message can only have up to 10 total attachments';
189
- if (errors.text) {
190
- errors.text += ` ${message}`;
191
- }
192
- else {
193
- errors.text = message;
194
- }
185
+ errors.text = 'Each message can only have up to 10 total attachments';
195
186
  }
196
187
  }
197
188
  return {
198
189
  valid: Object.keys(errors).length === 0,
199
190
  errors
200
191
  };
192
+ },
193
+ localizable: ['text', 'quick_replies', 'attachments'],
194
+ toLocalizationFormData: (action, localization) => {
195
+ // Convert localized values to form data format
196
+ // Localized values are stored as arrays even for single values
197
+ const formData = {
198
+ uuid: action.uuid
199
+ };
200
+ // Handle text (single value, but stored as array in localization)
201
+ if (localization.text && Array.isArray(localization.text)) {
202
+ formData.text = localization.text[0] || '';
203
+ }
204
+ else {
205
+ // Fall back to empty string if no localization
206
+ formData.text = '';
207
+ }
208
+ // Handle attachments (already an array)
209
+ if (localization.attachments && Array.isArray(localization.attachments)) {
210
+ formData.attachments = localization.attachments;
211
+ }
212
+ // Handle quick_replies (already an array)
213
+ if (localization.quick_replies &&
214
+ Array.isArray(localization.quick_replies)) {
215
+ formData.quick_replies = localization.quick_replies.map((reply) => ({
216
+ name: reply,
217
+ value: reply
218
+ }));
219
+ }
220
+ // Extract runtime attachments from localized attachments
221
+ const runtimeAttachments = [];
222
+ const staticAttachments = [];
223
+ if (formData.attachments && Array.isArray(formData.attachments)) {
224
+ formData.attachments.forEach((attachment) => {
225
+ if (typeof attachment === 'string' && attachment.includes(':')) {
226
+ const colonIndex = attachment.indexOf(':');
227
+ const contentType = attachment.substring(0, colonIndex);
228
+ const value = attachment.substring(colonIndex + 1);
229
+ if (!contentType.includes('/')) {
230
+ runtimeAttachments.push({
231
+ type: { name: titleCase(contentType), value: contentType },
232
+ expression: value
233
+ });
234
+ }
235
+ else {
236
+ staticAttachments.push(attachment);
237
+ }
238
+ }
239
+ });
240
+ }
241
+ formData.attachments = staticAttachments;
242
+ formData.runtime_attachments = runtimeAttachments;
243
+ return formData;
244
+ },
245
+ fromLocalizationFormData: (formData, action) => {
246
+ // Convert form data to localization format
247
+ // All values must be stored as arrays
248
+ const localization = {};
249
+ // Handle text (store as single-element array)
250
+ // Only save if not empty and different from base action
251
+ if (formData.text && formData.text.trim() !== '') {
252
+ if (formData.text !== action.text) {
253
+ localization.text = [formData.text];
254
+ }
255
+ }
256
+ // Handle quick_replies (store as array)
257
+ const quickReplies = (formData.quick_replies || [])
258
+ .map((reply) => typeof reply === 'string' ? reply : reply.value || reply.name || reply)
259
+ .filter((reply) => reply && reply.trim() !== '');
260
+ // Only save if there are quick replies and different from base action
261
+ if (quickReplies.length > 0) {
262
+ if (JSON.stringify(quickReplies) !==
263
+ JSON.stringify(action.quick_replies || [])) {
264
+ localization.quick_replies = quickReplies;
265
+ }
266
+ }
267
+ // Handle attachments (combine static and runtime attachments)
268
+ const staticAttachments = (formData.attachments || []).filter((att) => att && att.trim() !== '');
269
+ const runtimeAttachments = (formData.runtime_attachments || [])
270
+ .filter((item) => item && item.type && item.expression && item.expression.trim() !== '')
271
+ .map((item) => `${item.type[0].value}:${item.expression}`);
272
+ const allAttachments = [...staticAttachments, ...runtimeAttachments];
273
+ // Only save if there are attachments and different from base action
274
+ if (allAttachments.length > 0) {
275
+ if (JSON.stringify(allAttachments) !==
276
+ JSON.stringify(action.attachments || [])) {
277
+ localization.attachments = allAttachments;
278
+ }
279
+ }
280
+ return localization;
201
281
  }
202
282
  };
203
283
  //# sourceMappingURL=send_msg.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"send_msg.js","sourceRoot":"","sources":["../../../../src/flow/actions/send_msg.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,UAAU,CAAC;AAChC,OAAO,EAAE,UAAU,EAAE,MAAM,oCAAoC,CAAC;AAChE,OAAO,EAAgB,MAAM,EAAoB,MAAM,UAAU,CAAC;AAElE,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAExC,MAAM,CAAC,MAAM,QAAQ,GAAiB;IACpC,IAAI,EAAE,cAAc;IACpB,KAAK,EAAE,MAAM,CAAC,IAAI;IAClB,MAAM,EAAE,CAAC,KAAW,EAAE,MAAe,EAAE,EAAE;;QACvC,MAAM,IAAI,GAAG,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;QAChD,OAAO,IAAI,CAAA;QACP,UAAU,CAAC,IAAI,CAAC;QAChB,CAAA,MAAA,MAAM,CAAC,aAAa,0CAAE,MAAM,IAAG,CAAC;YAChC,CAAC,CAAC,IAAI,CAAA;cACA,MAAM,CAAC,aAAa,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE;gBACnC,OAAO,IAAI,CAAA,4BAA4B,KAAK,QAAQ,CAAC;YACvD,CAAC,CAAC;cACA,MAAM,CAAC,QAAQ;gBACf,CAAC,CAAC,IAAI,CAAA;;;;mDAI+B,MAAM,CAAC,QAAQ,CAAC,IAAI;uBAChD;gBACT,CAAC,CAAC,IAAI;iBACH;YACT,CAAC,CAA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AC/B,CAAC;qBAAM,CAAC;oBACN,MAAM,CAAC,IAAI,GAAG,OAAO,CAAC;gBACxB,CAAC;YACH,CAAC;QACH,CAAC;QAED,OAAO;YACL,KAAK,EAAE,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,MAAM,KAAK,CAAC;YACvC,MAAM;SACP,CAAC;IACJ,CAAC;CACF,CAAC","sourcesContent":["import { html } from 'lit-html';\nimport { unsafeHTML } from 'lit-html/directives/unsafe-html.js';\nimport { ActionConfig, COLORS, ValidationResult } from '../types';\nimport { Node, SendMsg } from '../../store/flow-definition';\nimport { titleCase } from '../../utils';\n\nexport const send_msg: ActionConfig = {\n name: 'Send Message',\n color: COLORS.send,\n render: (_node: Node, action: SendMsg) => {\n const text = action.text.replace(/\\n/g, '<br>');\n return html`\n ${unsafeHTML(text)}\n ${action.quick_replies?.length > 0\n ? html`<div class=\"quick-replies\">\n ${action.quick_replies.map((reply) => {\n return html`<div class=\"quick-reply\">${reply}</div>`;\n })}\n ${action.template\n ? html`<div\n style=\"border: 1px solid var(--color-widget-border);padding: 0.5em;margin-top: 1em;border-radius: var(--curvature); display:flex;background: rgba(0,0,0,.03);\"\n >\n <temba-icon name=\"channel_wac\"></temba-icon>\n <div style=\"margin-left:0.5em\">${action.template.name}</div>\n </div>`\n : null}\n </div>`\n : null}\n `;\n },\n form: {\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 quick_replies: {\n type: 'select',\n options: [],\n multi: true,\n tags: true,\n searchable: true,\n placeholder: 'Add quick replies...',\n maxItems: 10,\n evaluated: true\n },\n runtime_attachments: {\n type: 'array',\n helpText: 'Add dynamic attachments using expressions',\n itemLabel: 'Attachment',\n sortable: true,\n maxItems: 10,\n isEmptyItem: (item: any) => {\n return !item.expression || item.expression.trim() === '';\n },\n itemConfig: {\n type: {\n type: 'select',\n options: [\n { value: 'image', name: 'Image' },\n { value: 'audio', name: 'Audio' },\n { value: 'video', name: 'Video' },\n { value: 'document', name: 'Document' }\n ],\n required: true,\n searchable: false\n },\n expression: {\n type: 'text',\n placeholder: 'Expression (e.g. @contact.photo)',\n required: true,\n evaluated: true\n }\n }\n }\n },\n layout: [\n 'text',\n {\n type: 'group',\n label: 'Quick Replies',\n items: ['quick_replies'],\n collapsible: true,\n collapsed: (formData: any) => {\n // Collapse only if there are no quick replies\n return !formData.quick_replies || formData.quick_replies.length === 0;\n },\n getGroupValueCount: (formData: any) => {\n return formData.quick_replies?.length || 0;\n }\n },\n {\n type: 'group',\n label: 'Runtime Attachments',\n items: ['runtime_attachments'],\n collapsible: true,\n collapsed: true,\n helpText: 'Add dynamic attachments that are evaluated at runtime',\n getGroupValueCount: (formData: any) => {\n return (\n formData.runtime_attachments?.filter(\n (item: any) =>\n item && item.expression && item.expression.trim() !== ''\n ).length || 0\n );\n }\n }\n ],\n toFormData: (action: SendMsg) => {\n // Extract runtime attachments from the text field attachments\n const runtimeAttachments: {\n type: { name: string; value: string };\n expression: string;\n }[] = [];\n const staticAttachments: string[] = [];\n\n if (action.attachments && Array.isArray(action.attachments)) {\n action.attachments.forEach((attachment) => {\n if (typeof attachment === 'string' && attachment.includes(':')) {\n const colonIndex = attachment.indexOf(':');\n const contentType = attachment.substring(0, colonIndex);\n const value = attachment.substring(colonIndex + 1);\n\n if (!contentType.includes('/')) {\n runtimeAttachments.push({\n type: { name: titleCase(contentType), value: contentType },\n expression: value\n });\n } else {\n staticAttachments.push(attachment);\n }\n }\n });\n }\n\n return {\n uuid: action.uuid,\n text: action.text || '',\n attachments: staticAttachments,\n runtime_attachments: runtimeAttachments,\n quick_replies: (action.quick_replies || []).map((reply) => ({\n name: reply,\n value: reply\n }))\n };\n },\n fromFormData: (data: Record<string, any>) => {\n const result = {\n uuid: data.uuid,\n type: 'send_msg',\n text: data.text || '',\n attachments: [],\n quick_replies: (data.quick_replies || []).map((reply: any) =>\n typeof reply === 'string' ? reply : reply.value || reply.name || reply\n )\n };\n\n // Combine static attachments from text field with runtime attachments\n const staticAttachments = data.attachments || [];\n const runtimeAttachments = (data.runtime_attachments || [])\n .filter(\n (item: {\n type: [{ name: string; value: string }];\n expression: string;\n }) => item && item.type && item.expression\n ) // Filter out invalid items\n .map(\n (item: {\n type: [{ name: string; value: string }];\n expression: string;\n }) => `${item.type[0].value}:${item.expression}`\n );\n\n result.attachments = [...staticAttachments, ...runtimeAttachments];\n\n // Remove quick_replies if empty to match original format\n if (result.quick_replies.length === 0) {\n delete (result as any).quick_replies;\n }\n\n return result as SendMsg;\n },\n sanitize: (formData: any): void => {\n if (formData.text && typeof formData.text === 'string') {\n formData.text = formData.text.trim();\n }\n },\n validate: (action: SendMsg): ValidationResult => {\n const errors: { [key: string]: string } = {};\n\n if (!action.text || action.text.trim() === '') {\n errors.text = 'Message text is required';\n }\n\n const attachments = action.attachments || [];\n if (attachments.length > 10) {\n const staticAttachments = attachments.filter(\n (attachment) =>\n typeof attachment === 'string' &&\n attachment.substring(0, attachment.indexOf(':')).includes('/')\n );\n\n const runtimeAttachments = attachments.filter(\n (attachment) =>\n typeof attachment === 'string' &&\n !attachment.substring(0, attachment.indexOf(':')).includes('/')\n );\n\n if (runtimeAttachments.length > 0) {\n errors.runtime_attachments =\n 'Each message can only have up to 10 attachments';\n }\n\n if (staticAttachments.length > 0) {\n const message = 'Each message can only have up to 10 total attachments';\n if (errors.text) {\n errors.text += ` ${message}`;\n } else {\n errors.text = message;\n }\n }\n }\n\n return {\n valid: Object.keys(errors).length === 0,\n errors\n };\n }\n};\n"]}
1
+ {"version":3,"file":"send_msg.js","sourceRoot":"","sources":["../../../../src/flow/actions/send_msg.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,UAAU,CAAC;AAChC,OAAO,EAAE,UAAU,EAAE,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AC,EAC1C,CAAC;gBACD,YAAY,CAAC,aAAa,GAAG,YAAY,CAAC;YAC5C,CAAC;QACH,CAAC;QAED,8DAA8D;QAC9D,MAAM,iBAAiB,GAAG,CAAC,QAAQ,CAAC,WAAW,IAAI,EAAE,CAAC,CAAC,MAAM,CAC3D,CAAC,GAAW,EAAE,EAAE,CAAC,GAAG,IAAI,GAAG,CAAC,IAAI,EAAE,KAAK,EAAE,CAC1C,CAAC;QACF,MAAM,kBAAkB,GAAG,CAAC,QAAQ,CAAC,mBAAmB,IAAI,EAAE,CAAC;aAC5D,MAAM,CACL,CAAC,IAGA,EAAE,EAAE,CACH,IAAI,IAAI,IAAI,CAAC,IAAI,IAAI,IAAI,CAAC,UAAU,IAAI,IAAI,CAAC,UAAU,CAAC,IAAI,EAAE,KAAK,EAAE,CACxE;aACA,GAAG,CACF,CAAC,IAGA,EAAE,EAAE,CAAC,GAAG,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,KAAK,IAAI,IAAI,CAAC,UAAU,EAAE,CACjD,CAAC;QAEJ,MAAM,cAAc,GAAG,CAAC,GAAG,iBAAiB,EAAE,GAAG,kBAAkB,CAAC,CAAC;QAErE,oEAAoE;QACpE,IAAI,cAAc,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YAC9B,IACE,IAAI,CAAC,SAAS,CAAC,cAAc,CAAC;gBAC9B,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,WAAW,IAAI,EAAE,CAAC,EACxC,CAAC;gBACD,YAAY,CAAC,WAAW,GAAG,cAAc,CAAC;YAC5C,CAAC;QACH,CAAC;QAED,OAAO,YAAY,CAAC;IACtB,CAAC;CACF,CAAC","sourcesContent":["import { html } from 'lit-html';\nimport { unsafeHTML } from 'lit-html/directives/unsafe-html.js';\nimport {\n ActionConfig,\n ACTION_GROUPS,\n FormData,\n ValidationResult,\n FlowTypes\n} from '../types';\nimport { Node, SendMsg } from '../../store/flow-definition';\nimport { titleCase } from '../../utils';\n\nexport const send_msg: ActionConfig = {\n name: 'Send Message',\n group: ACTION_GROUPS.send,\n flowTypes: [FlowTypes.VOICE, FlowTypes.MESSAGE, FlowTypes.BACKGROUND],\n render: (_node: Node, action: SendMsg) => {\n const text = action.text.replace(/\\n/g, '<br>');\n return html`\n ${unsafeHTML(text)}\n ${(action.quick_replies || [])?.length > 0\n ? html`<div class=\"quick-replies\">\n ${(action.quick_replies || []).map((reply) => {\n return html`<div class=\"quick-reply\">${reply}</div>`;\n })}\n ${action.template\n ? html`<div\n style=\"border: 1px solid var(--color-widget-border);padding: 0.5em;margin-top: 1em;border-radius: var(--curvature); display:flex;background: rgba(0,0,0,.03);\"\n >\n <temba-icon name=\"channel_wac\"></temba-icon>\n <div style=\"margin-left:0.5em\">${action.template.name}</div>\n </div>`\n : null}\n </div>`\n : null}\n `;\n },\n form: {\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 quick_replies: {\n type: 'select',\n options: [],\n multi: true,\n tags: true,\n searchable: true,\n placeholder: 'Add quick replies...',\n maxItems: 10,\n evaluated: true\n },\n runtime_attachments: {\n type: 'array',\n helpText: 'Add dynamic attachments using expressions',\n itemLabel: 'Attachment',\n sortable: true,\n maxItems: 10,\n isEmptyItem: (item: any) => {\n return !item.expression || item.expression.trim() === '';\n },\n itemConfig: {\n type: {\n type: 'select',\n options: [\n { value: 'image', name: 'Image' },\n { value: 'audio', name: 'Audio' },\n { value: 'video', name: 'Video' },\n { value: 'document', name: 'Document' }\n ],\n required: true,\n searchable: false\n },\n expression: {\n type: 'text',\n placeholder: 'Expression (e.g. @contact.photo)',\n required: true,\n evaluated: true\n }\n }\n }\n },\n layout: [\n 'text',\n {\n type: 'group',\n label: 'Quick Replies',\n items: ['quick_replies'],\n collapsible: true,\n collapsed: (formData: FormData) => {\n // Collapse only if there are no quick replies\n return !formData.quick_replies || formData.quick_replies.length === 0;\n },\n getGroupValueCount: (formData: FormData) => {\n return formData.quick_replies?.length || 0;\n }\n },\n {\n type: 'group',\n label: 'Runtime Attachments',\n items: ['runtime_attachments'],\n collapsible: true,\n collapsed: true,\n helpText: 'Add dynamic attachments that are evaluated at runtime',\n getGroupValueCount: (formData: FormData) => {\n return (\n formData.runtime_attachments?.filter(\n (item: any) =>\n item && item.expression && item.expression.trim() !== ''\n ).length || 0\n );\n }\n }\n ],\n toFormData: (action: SendMsg) => {\n // Extract runtime attachments from the text field attachments\n const runtimeAttachments: {\n type: { name: string; value: string };\n expression: string;\n }[] = [];\n const staticAttachments: string[] = [];\n\n if (action.attachments && Array.isArray(action.attachments)) {\n action.attachments.forEach((attachment) => {\n if (typeof attachment === 'string' && attachment.includes(':')) {\n const colonIndex = attachment.indexOf(':');\n const contentType = attachment.substring(0, colonIndex);\n const value = attachment.substring(colonIndex + 1);\n\n if (!contentType.includes('/')) {\n runtimeAttachments.push({\n type: { name: titleCase(contentType), value: contentType },\n expression: value\n });\n } else {\n staticAttachments.push(attachment);\n }\n }\n });\n }\n\n return {\n uuid: action.uuid,\n text: action.text || '',\n attachments: staticAttachments,\n runtime_attachments: runtimeAttachments,\n quick_replies: (action.quick_replies || []).map((reply) => ({\n name: reply,\n value: reply\n }))\n };\n },\n fromFormData: (data: FormData) => {\n const result = {\n uuid: data.uuid,\n type: 'send_msg',\n text: data.text || '',\n attachments: [],\n quick_replies: (data.quick_replies || []).map((reply: any) =>\n typeof reply === 'string' ? reply : reply.value || reply.name || reply\n )\n };\n\n // Combine static attachments from text field with runtime attachments\n const staticAttachments = data.attachments || [];\n const runtimeAttachments = (data.runtime_attachments || [])\n .filter(\n (item: {\n type: [{ name: string; value: string }];\n expression: string;\n }) => item && item.type && item.expression\n ) // Filter out invalid items\n .map(\n (item: {\n type: [{ name: string; value: string }];\n expression: string;\n }) => `${item.type[0].value}:${item.expression}`\n );\n\n result.attachments = [...staticAttachments, ...runtimeAttachments];\n\n // Remove quick_replies if empty to match original format\n if (result.quick_replies.length === 0) {\n delete (result as any).quick_replies;\n }\n\n return result as SendMsg;\n },\n sanitize: (formData: FormData): void => {\n if (formData.text && typeof formData.text === 'string') {\n formData.text = formData.text.trim();\n }\n },\n validate: (formData: FormData): ValidationResult => {\n const errors: { [key: string]: string } = {};\n\n // Check total attachment count (static + runtime should not exceed 10)\n const staticAttachments = formData.attachments || [];\n const runtimeAttachments = (formData.runtime_attachments || []).filter(\n (item: any) => item && item.expression && item.expression.trim() !== ''\n );\n\n const totalAttachments =\n staticAttachments.length + runtimeAttachments.length;\n if (totalAttachments > 10) {\n if (runtimeAttachments.length > 0) {\n errors.runtime_attachments =\n 'Each message can only have up to 10 attachments';\n }\n if (staticAttachments.length > 0) {\n errors.text = 'Each message can only have up to 10 total attachments';\n }\n }\n\n return {\n valid: Object.keys(errors).length === 0,\n errors\n };\n },\n localizable: ['text', 'quick_replies', 'attachments'],\n toLocalizationFormData: (\n action: SendMsg,\n localization: Record<string, any>\n ) => {\n // Convert localized values to form data format\n // Localized values are stored as arrays even for single values\n const formData: FormData = {\n uuid: action.uuid\n };\n\n // Handle text (single value, but stored as array in localization)\n if (localization.text && Array.isArray(localization.text)) {\n formData.text = localization.text[0] || '';\n } else {\n // Fall back to empty string if no localization\n formData.text = '';\n }\n\n // Handle attachments (already an array)\n if (localization.attachments && Array.isArray(localization.attachments)) {\n formData.attachments = localization.attachments;\n }\n\n // Handle quick_replies (already an array)\n if (\n localization.quick_replies &&\n Array.isArray(localization.quick_replies)\n ) {\n formData.quick_replies = localization.quick_replies.map((reply) => ({\n name: reply,\n value: reply\n }));\n }\n\n // Extract runtime attachments from localized attachments\n const runtimeAttachments: {\n type: { name: string; value: string };\n expression: string;\n }[] = [];\n const staticAttachments: string[] = [];\n\n if (formData.attachments && Array.isArray(formData.attachments)) {\n formData.attachments.forEach((attachment) => {\n if (typeof attachment === 'string' && attachment.includes(':')) {\n const colonIndex = attachment.indexOf(':');\n const contentType = attachment.substring(0, colonIndex);\n const value = attachment.substring(colonIndex + 1);\n\n if (!contentType.includes('/')) {\n runtimeAttachments.push({\n type: { name: titleCase(contentType), value: contentType },\n expression: value\n });\n } else {\n staticAttachments.push(attachment);\n }\n }\n });\n }\n\n formData.attachments = staticAttachments;\n formData.runtime_attachments = runtimeAttachments;\n\n return formData;\n },\n fromLocalizationFormData: (formData: FormData, action: SendMsg) => {\n // Convert form data to localization format\n // All values must be stored as arrays\n const localization: Record<string, any> = {};\n\n // Handle text (store as single-element array)\n // Only save if not empty and different from base action\n if (formData.text && formData.text.trim() !== '') {\n if (formData.text !== action.text) {\n localization.text = [formData.text];\n }\n }\n\n // Handle quick_replies (store as array)\n const quickReplies = (formData.quick_replies || [])\n .map((reply: any) =>\n typeof reply === 'string' ? reply : reply.value || reply.name || reply\n )\n .filter((reply: string) => reply && reply.trim() !== '');\n\n // Only save if there are quick replies and different from base action\n if (quickReplies.length > 0) {\n if (\n JSON.stringify(quickReplies) !==\n JSON.stringify(action.quick_replies || [])\n ) {\n localization.quick_replies = quickReplies;\n }\n }\n\n // Handle attachments (combine static and runtime attachments)\n const staticAttachments = (formData.attachments || []).filter(\n (att: string) => att && att.trim() !== ''\n );\n const runtimeAttachments = (formData.runtime_attachments || [])\n .filter(\n (item: {\n type: [{ name: string; value: string }];\n expression: string;\n }) =>\n item && item.type && item.expression && item.expression.trim() !== ''\n )\n .map(\n (item: {\n type: [{ name: string; value: string }];\n expression: string;\n }) => `${item.type[0].value}:${item.expression}`\n );\n\n const allAttachments = [...staticAttachments, ...runtimeAttachments];\n\n // Only save if there are attachments and different from base action\n if (allAttachments.length > 0) {\n if (\n JSON.stringify(allAttachments) !==\n JSON.stringify(action.attachments || [])\n ) {\n localization.attachments = allAttachments;\n }\n }\n\n return localization;\n }\n};\n"]}
@@ -1,8 +1,9 @@
1
1
  import { html } from 'lit-html';
2
- import { COLORS } from '../types';
2
+ import { ACTION_GROUPS, FlowTypes } from '../types';
3
3
  export const set_contact_channel = {
4
4
  name: 'Update Channel',
5
- color: COLORS.update,
5
+ group: ACTION_GROUPS.contacts,
6
+ flowTypes: [FlowTypes.VOICE, FlowTypes.MESSAGE, FlowTypes.BACKGROUND],
6
7
  render: (_node, action) => {
7
8
  return html `<div>Set to <strong>${action.channel.name}</strong></div>`;
8
9
  },
@@ -19,14 +20,10 @@ export const set_contact_channel = {
19
20
  helpText: 'Select the channel to set for the contact'
20
21
  }
21
22
  },
22
- validate: (formData) => {
23
- const errors = {};
24
- if (!formData.channel) {
25
- errors.channel = 'Channel is required';
26
- }
23
+ toFormData: (action) => {
27
24
  return {
28
- valid: Object.keys(errors).length === 0,
29
- errors
25
+ uuid: action.uuid,
26
+ channel: action.channel ? [action.channel] : null
30
27
  };
31
28
  }
32
29
  };
@@ -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,MAAM,EAAoB,MAAM,UAAU,CAAC;AAGlE,MAAM,CAAC,MAAM,mBAAmB,GAAiB;IAC/C,IAAI,EAAE,gBAAgB;IACtB,KAAK,EAAE,MAAM,CAAC,MAAM;IACpB,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,QAAQ,EAAE,CAAC,QAA2B,EAAoB,EAAE;QAC1D,MAAM,MAAM,GAA8B,EAAE,CAAC;QAE7C,IAAI,CAAC,QAAQ,CAAC,OAAO,EAAE,CAAC;YACtB,MAAM,CAAC,OAAO,GAAG,qBAAqB,CAAC;QACzC,CAAC;QAED,OAAO;YACL,KAAK,EAAE,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,MAAM,KAAK,CAAC;YACvC,MAAM;SACP,CAAC;IACJ,CAAC;CACF,CAAC","sourcesContent":["import { html } from 'lit-html';\nimport { ActionConfig, COLORS, ValidationResult } from '../types';\nimport { Node, SetContactChannel } from '../../store/flow-definition';\n\nexport const set_contact_channel: ActionConfig = {\n name: 'Update Channel',\n color: COLORS.update,\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 validate: (formData: SetContactChannel): ValidationResult => {\n const errors: { [key: string]: string } = {};\n\n if (!formData.channel) {\n errors.channel = 'Channel is required';\n }\n\n return {\n valid: Object.keys(errors).length === 0,\n errors\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,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,13 +1,19 @@
1
1
  import { html } from 'lit-html';
2
- import { COLORS } from '../types';
2
+ import { ACTION_GROUPS, FlowTypes } from '../types';
3
3
  export const set_contact_field = {
4
4
  name: 'Update Field',
5
- color: COLORS.update,
5
+ group: ACTION_GROUPS.contacts,
6
+ flowTypes: [FlowTypes.VOICE, FlowTypes.MESSAGE, FlowTypes.BACKGROUND],
6
7
  render: (_node, action) => {
7
- return html `<div>
8
- Set <strong>${action.field.name}</strong> to
9
- <strong>${action.value}</strong>
10
- </div>`;
8
+ if (action.value) {
9
+ return html `<div>
10
+ Set <strong>${action.field.name}</strong> to
11
+ <strong>${action.value}</strong>
12
+ </div>`;
13
+ }
14
+ else {
15
+ return html `<div>Clear <strong>${action.field.name}</strong></div>`;
16
+ }
11
17
  },
12
18
  form: {
13
19
  field: {
@@ -16,6 +22,7 @@ export const set_contact_field = {
16
22
  required: true,
17
23
  searchable: true,
18
24
  clearable: false,
25
+ placeholder: 'Search for contact fields...',
19
26
  nameKey: 'name',
20
27
  valueKey: 'key',
21
28
  endpoint: '/api/v2/fields.json',
@@ -27,11 +34,17 @@ export const set_contact_field = {
27
34
  type: 'text',
28
35
  label: 'Value',
29
36
  placeholder: 'Enter field value...',
30
- required: true,
31
37
  evaluated: true,
32
38
  helpText: 'The new value for the contact field. You can use expressions like @contact.name'
33
39
  }
34
40
  },
41
+ toFormData: (action) => {
42
+ return {
43
+ uuid: action.uuid,
44
+ field: action.field ? [action.field] : null,
45
+ value: action.value
46
+ };
47
+ },
35
48
  fromFormData: (formData) => {
36
49
  const field = formData.field[0];
37
50
  return {
@@ -41,19 +54,6 @@ export const set_contact_field = {
41
54
  value: formData.value
42
55
  };
43
56
  },
44
- validate: (formData) => {
45
- const errors = {};
46
- if (!formData.field) {
47
- errors.field = 'Field is required';
48
- }
49
- if (!formData.value || formData.value.trim() === '') {
50
- errors.value = 'Field value is required';
51
- }
52
- return {
53
- valid: Object.keys(errors).length === 0,
54
- errors
55
- };
56
- },
57
57
  sanitize: (formData) => {
58
58
  if (formData.value && typeof formData.value === 'string') {
59
59
  formData.value = formData.value.trim();
@@ -1 +1 @@
1
- {"version":3,"file":"set_contact_field.js","sourceRoot":"","sources":["../../../../src/flow/actions/set_contact_field.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,UAAU,CAAC;AAChC,OAAO,EAAgB,MAAM,EAAoB,MAAM,UAAU,CAAC;AAGlE,MAAM,CAAC,MAAM,iBAAiB,GAAiB;IAC7C,IAAI,EAAE,cAAc;IACpB,KAAK,EAAE,MAAM,CAAC,MAAM;IACpB,MAAM,EAAE,CAAC,KAAW,EAAE,MAAuB,EAAE,EAAE;QAC/C,OAAO,IAAI,CAAA;oBACK,MAAM,CAAC,KAAK,CAAC,IAAI;gBACrB,MAAM,CAAC,KAAK;WACjB,CAAC;IACV,CAAC;IACD,IAAI,EAAE;QACJ,KAAK,EAAE;YACL,IAAI,EAAE,QAAQ;YACd,KAAK,EAAE,OAAO;YACd,QAAQ,EAAE,IAAI;YACd,UAAU,EAAE,IAAI;YAChB,SAAS,EAAE,KAAK;YAChB,OAAO,EAAE,MAAM;YACf,QAAQ,EAAE,KAAK;YACf,QAAQ,EAAE,qBAAqB;YAC/B,QAAQ,EAAE,oCAAoC;YAC9C,WAAW,EAAE,IAAI;YACjB,qBAAqB,EAAE,CAAC,KAAa,EAAE,EAAE,CAAC,CAAC,EAAE,GAAG,EAAE,KAAK,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC;SACxE;QACD,KAAK,EAAE;YACL,IAAI,EAAE,MAAM;YACZ,KAAK,EAAE,OAAO;YACd,WAAW,EAAE,sBAAsB;YACnC,QAAQ,EAAE,IAAI;YACd,SAAS,EAAE,IAAI;YACf,QAAQ,EACN,iFAAiF;SACpF;KACF;IACD,YAAY,EAAE,CAAC,QAAyB,EAAmB,EAAE;QAC3D,MAAM,KAAK,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;QAChC,OAAO;YACL,IAAI,EAAE,QAAQ,CAAC,IAAI;YACnB,IAAI,EAAE,mBAAmB;YACzB,KAAK,EAAE,EAAE,IAAI,EAAE,KAAK,CAAC,IAAI,EAAE,GAAG,EAAE,KAAK,CAAC,GAAG,EAAE;YAC3C,KAAK,EAAE,QAAQ,CAAC,KAAK;SACtB,CAAC;IACJ,CAAC;IACD,QAAQ,EAAE,CAAC,QAAyB,EAAoB,EAAE;QACxD,MAAM,MAAM,GAA8B,EAAE,CAAC;QAE7C,IAAI,CAAC,QAAQ,CAAC,KAAK,EAAE,CAAC;YACpB,MAAM,CAAC,KAAK,GAAG,mBAAmB,CAAC;QACrC,CAAC;QAED,IAAI,CAAC,QAAQ,CAAC,KAAK,IAAI,QAAQ,CAAC,KAAK,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE,CAAC;YACpD,MAAM,CAAC,KAAK,GAAG,yBAAyB,CAAC;QAC3C,CAAC;QAED,OAAO;YACL,KAAK,EAAE,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,MAAM,KAAK,CAAC;YACvC,MAAM;SACP,CAAC;IACJ,CAAC;IACD,QAAQ,EAAE,CAAC,QAAyB,EAAQ,EAAE;QAC5C,IAAI,QAAQ,CAAC,KAAK,IAAI,OAAO,QAAQ,CAAC,KAAK,KAAK,QAAQ,EAAE,CAAC;YACzD,QAAQ,CAAC,KAAK,GAAG,QAAQ,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC;QACzC,CAAC;IACH,CAAC;CACF,CAAC","sourcesContent":["import { html } from 'lit-html';\nimport { ActionConfig, COLORS, ValidationResult } from '../types';\nimport { Node, SetContactField } from '../../store/flow-definition';\n\nexport const set_contact_field: ActionConfig = {\n name: 'Update Field',\n color: COLORS.update,\n render: (_node: Node, action: SetContactField) => {\n return html`<div>\n Set <strong>${action.field.name}</strong> to\n <strong>${action.value}</strong>\n </div>`;\n },\n form: {\n field: {\n type: 'select',\n label: 'Field',\n required: true,\n searchable: true,\n clearable: false,\n nameKey: 'name',\n valueKey: 'key',\n endpoint: '/api/v2/fields.json',\n helpText: 'Select the contact field to update',\n allowCreate: true,\n createArbitraryOption: (input: string) => ({ key: input, name: input })\n },\n value: {\n type: 'text',\n label: 'Value',\n placeholder: 'Enter field value...',\n required: true,\n evaluated: true,\n helpText:\n 'The new value for the contact field. You can use expressions like @contact.name'\n }\n },\n fromFormData: (formData: SetContactField): SetContactField => {\n const field = formData.field[0];\n return {\n uuid: formData.uuid,\n type: 'set_contact_field',\n field: { name: field.name, key: field.key },\n value: formData.value\n };\n },\n validate: (formData: SetContactField): ValidationResult => {\n const errors: { [key: string]: string } = {};\n\n if (!formData.field) {\n errors.field = 'Field is required';\n }\n\n if (!formData.value || formData.value.trim() === '') {\n errors.value = 'Field value is required';\n }\n\n return {\n valid: Object.keys(errors).length === 0,\n errors\n };\n },\n sanitize: (formData: SetContactField): void => {\n if (formData.value && typeof formData.value === 'string') {\n formData.value = formData.value.trim();\n }\n }\n};\n"]}
1
+ {"version":3,"file":"set_contact_field.js","sourceRoot":"","sources":["../../../../src/flow/actions/set_contact_field.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,iBAAiB,GAAiB;IAC7C,IAAI,EAAE,cAAc;IACpB,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,MAAuB,EAAE,EAAE;QAC/C,IAAI,MAAM,CAAC,KAAK,EAAE,CAAC;YACjB,OAAO,IAAI,CAAA;sBACK,MAAM,CAAC,KAAK,CAAC,IAAI;kBACrB,MAAM,CAAC,KAAK;aACjB,CAAC;QACV,CAAC;aAAM,CAAC;YACN,OAAO,IAAI,CAAA,sBAAsB,MAAM,CAAC,KAAK,CAAC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,QAAQ,EAAE,CAAC,QAAkB,EAAQ,EAAE;QACrC,IAAI,QAAQ,CAAC,KAAK,IAAI,OAAO,QAAQ,CAAC,KAAK,KAAK,QAAQ,EAAE,CAAC;YACzD,QAAQ,CAAC,KAAK,GAAG,QAAQ,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC;QACzC,CAAC;IACH,CAAC;CACF,CAAC","sourcesContent":["import { html } from 'lit-html';\nimport { ActionConfig, ACTION_GROUPS, FormData, FlowTypes } from '../types';\nimport { Node, SetContactField } from '../../store/flow-definition';\n\nexport const set_contact_field: ActionConfig = {\n name: 'Update Field',\n group: ACTION_GROUPS.contacts,\n flowTypes: [FlowTypes.VOICE, FlowTypes.MESSAGE, FlowTypes.BACKGROUND],\n render: (_node: Node, action: SetContactField) => {\n if (action.value) {\n return html`<div>\n Set <strong>${action.field.name}</strong> to\n <strong>${action.value}</strong>\n </div>`;\n } else {\n return html`<div>Clear <strong>${action.field.name}</strong></div>`;\n }\n },\n form: {\n field: {\n type: 'select',\n label: 'Field',\n required: true,\n searchable: true,\n clearable: false,\n placeholder: 'Search for contact fields...',\n nameKey: 'name',\n valueKey: 'key',\n endpoint: '/api/v2/fields.json',\n helpText: 'Select the contact field to update',\n allowCreate: true,\n createArbitraryOption: (input: string) => ({ key: input, name: input })\n },\n value: {\n type: 'text',\n label: 'Value',\n placeholder: 'Enter field value...',\n evaluated: true,\n helpText:\n 'The new value for the contact field. You can use expressions like @contact.name'\n }\n },\n toFormData: (action: SetContactField) => {\n return {\n uuid: action.uuid,\n field: action.field ? [action.field] : null,\n value: action.value\n };\n },\n fromFormData: (formData: FormData): SetContactField => {\n const field = formData.field[0];\n return {\n uuid: formData.uuid,\n type: 'set_contact_field',\n field: { name: field.name, key: field.key },\n value: formData.value\n };\n },\n sanitize: (formData: FormData): void => {\n if (formData.value && typeof formData.value === 'string') {\n formData.value = formData.value.trim();\n }\n }\n};\n"]}
@@ -1,9 +1,10 @@
1
1
  import { html } from 'lit-html';
2
- import { COLORS } from '../types';
2
+ import { ACTION_GROUPS, FlowTypes } from '../types';
3
3
  import { getStore } from '../../store/Store';
4
4
  export const set_contact_language = {
5
5
  name: 'Update Language',
6
- color: COLORS.update,
6
+ group: ACTION_GROUPS.contacts,
7
+ flowTypes: [FlowTypes.VOICE, FlowTypes.MESSAGE, FlowTypes.BACKGROUND],
7
8
  render: (_node, action) => {
8
9
  const languageNames = new Intl.DisplayNames(['en'], {
9
10
  type: 'language'
@@ -1 +1 @@
1
- {"version":3,"file":"set_contact_language.js","sourceRoot":"","sources":["../../../../src/flow/actions/set_contact_language.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,UAAU,CAAC;AAChC,OAAO,EAAgB,MAAM,EAAoB,MAAM,UAAU,CAAC;AAElE,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAE7C,MAAM,CAAC,MAAM,oBAAoB,GAAiB;IAChD,IAAI,EAAE,iBAAiB;IACvB,KAAK,EAAE,MAAM,CAAC,MAAM;IACpB,MAAM,EAAE,CAAC,KAAW,EAAE,MAA0B,EAAE,EAAE;QAClD,MAAM,aAAa,GAAG,IAAI,IAAI,CAAC,YAAY,CAAC,CAAC,IAAI,CAAC,EAAE;YAClD,IAAI,EAAE,UAAU;SACjB,CAAC,CAAC;QACH,OAAO,IAAI,CAAA;uBACQ,aAAa,CAAC,EAAE,CAAC,MAAM,CAAC,QAAQ,CAAC;WAC7C,CAAC;IACV,CAAC;IACD,IAAI,EAAE;QACJ,QAAQ,EAAE;YACR,IAAI,EAAE,QAAQ;YACd,KAAK,EAAE,UAAU;YACjB,QAAQ,EAAE,IAAI;YACd,UAAU,EAAE,IAAI;YAChB,SAAS,EAAE,KAAK;YAChB,QAAQ,EAAE,OAAO;YACjB,OAAO,EAAE,MAAM;YACf,QAAQ,EAAE,4CAA4C;YACtD,iBAAiB,EAAE,GAAG,EAAE;gBACtB,MAAM,KAAK,GAAG,QAAQ,EAAE,CAAC;gBACzB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,CAAC,IAAI;YACnB,IAAI,EAAE,sBAAsB;YAC5B,QAAQ,EAAE,QAAQ,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,KAAK;SACrC,CAAC;IACJ,CAAC;IAED,QAAQ,EAAE,CAAC,QAAa,EAAoB,EAAE;QAC5C,MAAM,MAAM,GAA8B,EAAE,CAAC;QAE7C,IAAI,CAAC,QAAQ,CAAC,QAAQ,EAAE,CAAC;YACvB,MAAM,CAAC,QAAQ,GAAG,sBAAsB,CAAC;QAC3C,CAAC;QAED,OAAO;YACL,KAAK,EAAE,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,MAAM,KAAK,CAAC;YACvC,MAAM;SACP,CAAC;IACJ,CAAC;CACF,CAAC","sourcesContent":["import { html } from 'lit-html';\nimport { ActionConfig, COLORS, ValidationResult } from '../types';\nimport { Node, SetContactLanguage } from '../../store/flow-definition';\nimport { getStore } from '../../store/Store';\n\nexport const set_contact_language: ActionConfig = {\n name: 'Update Language',\n color: COLORS.update,\n render: (_node: Node, action: SetContactLanguage) => {\n const languageNames = new Intl.DisplayNames(['en'], {\n type: 'language'\n });\n return html`<div>\n Set to <strong>${languageNames.of(action.language)}</strong>\n </div>`;\n },\n form: {\n language: {\n type: 'select',\n label: 'Language',\n required: true,\n searchable: true,\n clearable: false,\n valueKey: 'value',\n nameKey: 'name',\n helpText: 'Select the language to set for the contact',\n getDynamicOptions: () => {\n const store = getStore();\n const workspace = store?.getState().workspace;\n if (workspace?.languages && Array.isArray(workspace.languages)) {\n const languageNames = new Intl.DisplayNames(['en'], {\n type: 'language'\n });\n return workspace.languages.map((languageCode: string) => ({\n value: languageCode,\n name: languageNames.of(languageCode) || languageCode\n }));\n }\n return [];\n }\n }\n },\n toFormData: (action: SetContactLanguage) => {\n // Convert the language code back to the option object format expected by the form\n if (action.language) {\n const languageNames = new Intl.DisplayNames(['en'], {\n type: 'language'\n });\n return {\n language: [\n {\n value: action.language,\n name: languageNames.of(action.language) || action.language\n }\n ],\n uuid: action.uuid\n };\n }\n return {\n language: null,\n uuid: action.uuid\n };\n },\n fromFormData: (formData: any): SetContactLanguage => {\n return {\n uuid: formData.uuid,\n type: 'set_contact_language',\n language: formData.language[0].value\n };\n },\n\n validate: (formData: any): ValidationResult => {\n const errors: { [key: string]: string } = {};\n\n if (!formData.language) {\n errors.language = 'Language is required';\n }\n\n return {\n valid: Object.keys(errors).length === 0,\n errors\n };\n }\n};\n"]}
1
+ {"version":3,"file":"set_contact_language.js","sourceRoot":"","sources":["../../../../src/flow/actions/set_contact_language.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,UAAU,CAAC;AAChC,OAAO,EAEL,aAAa,EAGb,SAAS,EACV,MAAM,UAAU,CAAC;AAElB,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAE7C,MAAM,CAAC,MAAM,oBAAoB,GAAiB;IAChD,IAAI,EAAE,iBAAiB;IACvB,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,MAA0B,EAAE,EAAE;QAClD,MAAM,aAAa,GAAG,IAAI,IAAI,CAAC,YAAY,CAAC,CAAC,IAAI,CAAC,EAAE;YAClD,IAAI,EAAE,UAAU;SACjB,CAAC,CAAC;QACH,OAAO,IAAI,CAAA;uBACQ,aAAa,CAAC,EAAE,CAAC,MAAM,CAAC,QAAQ,CAAC;WAC7C,CAAC;IACV,CAAC;IACD,IAAI,EAAE;QACJ,QAAQ,EAAE;YACR,IAAI,EAAE,QAAQ;YACd,KAAK,EAAE,UAAU;YACjB,QAAQ,EAAE,IAAI;YACd,UAAU,EAAE,IAAI;YAChB,SAAS,EAAE,KAAK;YAChB,QAAQ,EAAE,OAAO;YACjB,OAAO,EAAE,MAAM;YACf,QAAQ,EAAE,4CAA4C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,CAAC;IACD,YAAY,EAAE,CAAC,QAAkB,EAAsB,EAAE;QACvD,OAAO;YACL,IAAI,EAAE,QAAQ,CAAC,IAAI;YACnB,IAAI,EAAE,sBAAsB;YAC5B,QAAQ,EAAE,QAAQ,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,KAAK;SACrC,CAAC;IACJ,CAAC;IAED,QAAQ,EAAE,CAAC,QAAkB,EAAoB,EAAE;QACjD,MAAM,MAAM,GAA8B,EAAE,CAAC;QAE7C,IAAI,CAAC,QAAQ,CAAC,QAAQ,EAAE,CAAC;YACvB,MAAM,CAAC,QAAQ,GAAG,sBAAsB,CAAC;QAC3C,CAAC;QAED,OAAO;YACL,KAAK,EAAE,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,MAAM,KAAK,CAAC;YACvC,MAAM;SACP,CAAC;IACJ,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, SetContactLanguage } from '../../store/flow-definition';\nimport { getStore } from '../../store/Store';\n\nexport const set_contact_language: ActionConfig = {\n name: 'Update Language',\n group: ACTION_GROUPS.contacts,\n flowTypes: [FlowTypes.VOICE, FlowTypes.MESSAGE, FlowTypes.BACKGROUND],\n render: (_node: Node, action: SetContactLanguage) => {\n const languageNames = new Intl.DisplayNames(['en'], {\n type: 'language'\n });\n return html`<div>\n Set to <strong>${languageNames.of(action.language)}</strong>\n </div>`;\n },\n form: {\n language: {\n type: 'select',\n label: 'Language',\n required: true,\n searchable: true,\n clearable: false,\n valueKey: 'value',\n nameKey: 'name',\n helpText: 'Select the language to set for the contact',\n getDynamicOptions: () => {\n const store = getStore();\n const workspace = store?.getState().workspace;\n if (workspace?.languages && Array.isArray(workspace.languages)) {\n const languageNames = new Intl.DisplayNames(['en'], {\n type: 'language'\n });\n return workspace.languages.map((languageCode: string) => ({\n value: languageCode,\n name: languageNames.of(languageCode) || languageCode\n }));\n }\n return [];\n }\n }\n },\n toFormData: (action: SetContactLanguage) => {\n // Convert the language code back to the option object format expected by the form\n if (action.language) {\n const languageNames = new Intl.DisplayNames(['en'], {\n type: 'language'\n });\n return {\n language: [\n {\n value: action.language,\n name: languageNames.of(action.language) || action.language\n }\n ],\n uuid: action.uuid\n };\n }\n return {\n language: null,\n uuid: action.uuid\n };\n },\n fromFormData: (formData: FormData): SetContactLanguage => {\n return {\n uuid: formData.uuid,\n type: 'set_contact_language',\n language: formData.language[0].value\n };\n },\n\n validate: (formData: FormData): ValidationResult => {\n const errors: { [key: string]: string } = {};\n\n if (!formData.language) {\n errors.language = 'Language is required';\n }\n\n return {\n valid: Object.keys(errors).length === 0,\n errors\n };\n }\n};\n"]}
@@ -1,8 +1,9 @@
1
1
  import { html } from 'lit-html';
2
- import { COLORS } from '../types';
2
+ import { ACTION_GROUPS, FlowTypes } from '../types';
3
3
  export const set_contact_name = {
4
4
  name: 'Update Name',
5
- color: COLORS.update,
5
+ group: ACTION_GROUPS.contacts,
6
+ flowTypes: [FlowTypes.VOICE, FlowTypes.MESSAGE, FlowTypes.BACKGROUND],
6
7
  render: (_node, action) => {
7
8
  return html `<div>Set to <strong>${action.name}</strong></div>`;
8
9
  },
@@ -16,16 +17,6 @@ export const set_contact_name = {
16
17
  helpText: 'The new name for the contact. You can use expressions like @contact.name'
17
18
  }
18
19
  },
19
- validate: (formData) => {
20
- const errors = {};
21
- if (!formData.name || formData.name.trim() === '') {
22
- errors.name = 'Name is required';
23
- }
24
- return {
25
- valid: Object.keys(errors).length === 0,
26
- errors
27
- };
28
- },
29
20
  sanitize: (formData) => {
30
21
  if (formData.name && typeof formData.name === 'string') {
31
22
  formData.name = formData.name.trim();
@@ -1 +1 @@
1
- {"version":3,"file":"set_contact_name.js","sourceRoot":"","sources":["../../../../src/flow/actions/set_contact_name.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,UAAU,CAAC;AAChC,OAAO,EAAgB,MAAM,EAAoB,MAAM,UAAU,CAAC;AAGlE,MAAM,CAAC,MAAM,gBAAgB,GAAiB;IAC5C,IAAI,EAAE,aAAa;IACnB,KAAK,EAAE,MAAM,CAAC,MAAM;IACpB,MAAM,EAAE,CAAC,KAAW,EAAE,MAAsB,EAAE,EAAE;QAC9C,OAAO,IAAI,CAAA,uBAAuB,MAAM,CAAC,IAAI,iBAAiB,CAAC;IACjE,CAAC;IACD,IAAI,EAAE;QACJ,IAAI,EAAE;YACJ,IAAI,EAAE,MAAM;YACZ,KAAK,EAAE,MAAM;YACb,WAAW,EAAE,uBAAuB;YACpC,QAAQ,EAAE,IAAI;YACd,SAAS,EAAE,IAAI;YACf,QAAQ,EACN,0EAA0E;SAC7E;KACF;IACD,QAAQ,EAAE,CAAC,QAAwB,EAAoB,EAAE;QACvD,MAAM,MAAM,GAA8B,EAAE,CAAC;QAE7C,IAAI,CAAC,QAAQ,CAAC,IAAI,IAAI,QAAQ,CAAC,IAAI,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE,CAAC;YAClD,MAAM,CAAC,IAAI,GAAG,kBAAkB,CAAC;QACnC,CAAC;QAED,OAAO;YACL,KAAK,EAAE,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,MAAM,KAAK,CAAC;YACvC,MAAM;SACP,CAAC;IACJ,CAAC;IACD,QAAQ,EAAE,CAAC,QAAwB,EAAQ,EAAE;QAC3C,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, COLORS, ValidationResult } from '../types';\nimport { Node, SetContactName } from '../../store/flow-definition';\n\nexport const set_contact_name: ActionConfig = {\n name: 'Update Name',\n color: COLORS.update,\n render: (_node: Node, action: SetContactName) => {\n return html`<div>Set to <strong>${action.name}</strong></div>`;\n },\n form: {\n name: {\n type: 'text',\n label: 'Name',\n placeholder: 'Enter contact name...',\n required: true,\n evaluated: true,\n helpText:\n 'The new name for the contact. You can use expressions like @contact.name'\n }\n },\n validate: (formData: SetContactName): ValidationResult => {\n const errors: { [key: string]: string } = {};\n\n if (!formData.name || formData.name.trim() === '') {\n errors.name = 'Name is required';\n }\n\n return {\n valid: Object.keys(errors).length === 0,\n errors\n };\n },\n sanitize: (formData: SetContactName): void => {\n if (formData.name && typeof formData.name === 'string') {\n formData.name = formData.name.trim();\n }\n }\n};\n"]}
1
+ {"version":3,"file":"set_contact_name.js","sourceRoot":"","sources":["../../../../src/flow/actions/set_contact_name.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,gBAAgB,GAAiB;IAC5C,IAAI,EAAE,aAAa;IACnB,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,MAAsB,EAAE,EAAE;QAC9C,OAAO,IAAI,CAAA,uBAAuB,MAAM,CAAC,IAAI,iBAAiB,CAAC;IACjE,CAAC;IACD,IAAI,EAAE;QACJ,IAAI,EAAE;YACJ,IAAI,EAAE,MAAM;YACZ,KAAK,EAAE,MAAM;YACb,WAAW,EAAE,uBAAuB;YACpC,QAAQ,EAAE,IAAI;YACd,SAAS,EAAE,IAAI;YACf,QAAQ,EACN,0EAA0E;SAC7E;KACF;IACD,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, SetContactName } from '../../store/flow-definition';\n\nexport const set_contact_name: ActionConfig = {\n name: 'Update Name',\n group: ACTION_GROUPS.contacts,\n flowTypes: [FlowTypes.VOICE, FlowTypes.MESSAGE, FlowTypes.BACKGROUND],\n render: (_node: Node, action: SetContactName) => {\n return html`<div>Set to <strong>${action.name}</strong></div>`;\n },\n form: {\n name: {\n type: 'text',\n label: 'Name',\n placeholder: 'Enter contact name...',\n required: true,\n evaluated: true,\n helpText:\n 'The new name for the contact. You can use expressions like @contact.name'\n }\n },\n sanitize: (formData: FormData): void => {\n if (formData.name && typeof formData.name === 'string') {\n formData.name = formData.name.trim();\n }\n }\n};\n"]}
@@ -1,9 +1,10 @@
1
1
  import { html } from 'lit-html';
2
- import { COLORS } from '../types';
2
+ import { ACTION_GROUPS, FlowTypes } from '../types';
3
3
  import { titleCase } from '../../utils';
4
4
  export const set_contact_status = {
5
5
  name: 'Update Status',
6
- color: COLORS.update,
6
+ group: ACTION_GROUPS.contacts,
7
+ flowTypes: [FlowTypes.VOICE, FlowTypes.MESSAGE, FlowTypes.BACKGROUND],
7
8
  render: (_node, action) => {
8
9
  return html `<div>Set to <strong>${titleCase(action.status)}</strong></div>`;
9
10
  },
@@ -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,MAAM,EAAE,MAAM,UAAU,CAAC;AAEhD,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAExC,MAAM,CAAC,MAAM,kBAAkB,GAAiB;IAC9C,IAAI,EAAE,eAAe;IACrB,KAAK,EAAE,MAAM,CAAC,MAAM;IACpB,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,QAAa,EAAoB,EAAE;QAChD,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, COLORS } 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 color: COLORS.update,\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: any): 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,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,9 +1,10 @@
1
1
  import { html } from 'lit-html';
2
- import { COLORS } from '../types';
2
+ import { ACTION_GROUPS, FlowTypes } from '../types';
3
3
  import { getStore } from '../../store/Store';
4
4
  export const set_run_result = {
5
5
  name: 'Save Flow Result',
6
- color: COLORS.save,
6
+ group: ACTION_GROUPS.save,
7
+ flowTypes: [FlowTypes.VOICE, FlowTypes.MESSAGE, FlowTypes.BACKGROUND],
7
8
  render: (_node, action) => {
8
9
  return html `<div>
9
10
  Save <strong>${action.value}</strong> as <strong>${action.name}</strong>
@@ -55,7 +56,7 @@ export const set_run_result = {
55
56
  toFormData: (action) => {
56
57
  return {
57
58
  uuid: action.uuid,
58
- name: action.name ? [{ name: action.name, value: action.name }] : [],
59
+ name: action.name ? [{ name: action.name, value: action.name }] : null,
59
60
  value: action.value || '',
60
61
  category: action.category || ''
61
62
  };
@@ -1 +1 @@
1
- {"version":3,"file":"set_run_result.js","sourceRoot":"","sources":["../../../../src/flow/actions/set_run_result.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,UAAU,CAAC;AAChC,OAAO,EAAgB,MAAM,EAAE,MAAM,UAAU,CAAC;AAEhD,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAE7C,MAAM,CAAC,MAAM,cAAc,GAAiB;IAC1C,IAAI,EAAE,kBAAkB;IACxB,KAAK,EAAE,MAAM,CAAC,IAAI;IAClB,MAAM,EAAE,CAAC,KAAW,EAAE,MAAoB,EAAE,EAAE;QAC5C,OAAO,IAAI,CAAA;qBACM,MA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YACL,IAAI,EAAE,QAAQ,CAAC,IAAI;YACnB,IAAI,EAAE,gBAAgB;YACtB,IAAI,EAAE,MAAM,CAAC,IAAI,CAAC,EAAE,8BAA8B;YAClD,KAAK,EAAE,QAAQ,CAAC,KAAK,IAAI,EAAE;YAC3B,QAAQ,EAAE,QAAQ,CAAC,QAAQ,IAAI,EAAE;SAClC,CAAC;IACJ,CAAC;CACF,CAAC","sourcesContent":["import { html } from 'lit-html';\nimport { ActionConfig, COLORS } from '../types';\nimport { Node, SetRunResult } from '../../store/flow-definition';\nimport { getStore } from '../../store/Store';\n\nexport const set_run_result: ActionConfig = {\n name: 'Save Flow Result',\n color: COLORS.save,\n render: (_node: Node, action: SetRunResult) => {\n return html`<div>\n Save <strong>${action.value}</strong> as <strong>${action.name}</strong>\n </div>`;\n },\n form: {\n name: {\n type: 'select',\n label: 'Result Name',\n helpText: 'Select an existing result name or type a new one',\n required: true,\n placeholder: 'Select or enter result name...',\n createArbitraryOption: (input, options) => {\n const exists = options.some(\n (option: any) =>\n option.value.toLowerCase() === input.toLowerCase() ||\n option.name.toLowerCase() === input.toLowerCase()\n );\n return !exists && input.trim().length > 0\n ? { value: input, name: input }\n : null;\n },\n searchable: true,\n clearable: false,\n getDynamicOptions: () => {\n const store = getStore();\n return store\n ? store\n .getState()\n .getFlowResults()\n .map((r) => ({ value: r.name, name: r.name }))\n : [];\n }\n },\n value: {\n type: 'text',\n label: 'Value',\n helpText: 'The value to save for this result (can use expressions)',\n required: false,\n evaluated: true,\n placeholder: 'Enter value...'\n },\n category: {\n type: 'text',\n label: 'Category',\n helpText: 'Optional category for this result',\n required: false,\n placeholder: 'Enter category...'\n }\n },\n layout: ['name', 'value', 'category'],\n toFormData: (action: SetRunResult) => {\n return {\n uuid: action.uuid,\n name: action.name ? [{ name: action.name, value: action.name }] : [],\n value: action.value || '',\n category: action.category || ''\n };\n },\n fromFormData: (formData: any): SetRunResult => {\n // Ensure name is a simple string, handling both direct values and select option objects\n let name = formData.name || '';\n if (Array.isArray(name) && name.length > 0) {\n // If it's an array (from multi-select), take the first item\n name = name[0];\n }\n if (typeof name === 'object' && name.value) {\n // If it's an option object, extract the value\n name = name.value;\n }\n if (typeof name === 'object' && name.name) {\n // If it's an option object with name property, extract it\n name = name.name;\n }\n\n return {\n uuid: formData.uuid,\n type: 'set_run_result',\n name: String(name), // Ensure it's always a string\n value: formData.value || '',\n category: formData.category || ''\n };\n }\n};\n"]}
1
+ {"version":3,"file":"set_run_result.js","sourceRoot":"","sources":["../../../../src/flow/actions/set_run_result.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,UAAU,CAAC;AAChC,OAAO,EAAgB,aAAa,EAAY,SAAS,EAAE,MAAM,UAAU,CAAC;AAE5E,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAE7C,MAAM,CAAC,MAAM,cAAc,GAAiB;IAC1C,IAAI,EAAE,kBAAkB;IACxB,KAAK,EAAE,aAAa,CAAC,IAAI;IACzB,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,OAAO,IAAI,CAAA;qBACM,MAAM,CAAC,KAAK,wBAAwB,MAAM,CAAC,IAAI;WACzD,CAAC;IACV,CAAC;IACD,IAAI,EAAE;QACJ,IAAI,EAAE;YACJ,IAAI,EAAE,QAAQ;YACd,KAAK,EAAE,aAAa;YACpB,QAAQ,EAAE,kDAAkD;YAC5D,QAAQ,EAAE,IAAI;YACd,WAAW,EAAE,gCAAgC;YAC7C,qBAAqB,EAAE,CAAC,KAAK,EAAE,OAAO,EAAE,EAAE;gBACxC,MAAM,MAAM,GAAG,OAAO,CAAC,IAAI,CACzB,CAAC,MAAW,EAAE,EAAE,CACd,MAAM,CAAC,KAAK,CAAC,WAAW,EAAE,KAAK,KAAK,CAAC,WAAW,EA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E,MAAM,CAAC,IAAI,EAAE,KAAK,EAAE,MAAM,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC,IAAI;YACtE,KAAK,EAAE,MAAM,CAAC,KAAK,IAAI,EAAE;YACzB,QAAQ,EAAE,MAAM,CAAC,QAAQ,IAAI,EAAE;SAChC,CAAC;IACJ,CAAC;IACD,YAAY,EAAE,CAAC,QAAkB,EAAgB,EAAE;QACjD,wFAAwF;QACxF,IAAI,IAAI,GAAG,QAAQ,CAAC,IAAI,IAAI,EAAE,CAAC;QAC/B,IAAI,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,IAAI,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YAC3C,4DAA4D;YAC5D,IAAI,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC;QACjB,CAAC;QACD,IAAI,OAAO,IAAI,KAAK,QAAQ,IAAI,IAAI,CAAC,KAAK,EAAE,CAAC;YAC3C,8CAA8C;YAC9C,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC;QACpB,CAAC;QACD,IAAI,OAAO,IAAI,KAAK,QAAQ,IAAI,IAAI,CAAC,IAAI,EAAE,CAAC;YAC1C,0DAA0D;YAC1D,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC;QACnB,CAAC;QAED,OAAO;YACL,IAAI,EAAE,QAAQ,CAAC,IAAI;YACnB,IAAI,EAAE,gBAAgB;YACtB,IAAI,EAAE,MAAM,CAAC,IAAI,CAAC,EAAE,8BAA8B;YAClD,KAAK,EAAE,QAAQ,CAAC,KAAK,IAAI,EAAE;YAC3B,QAAQ,EAAE,QAAQ,CAAC,QAAQ,IAAI,EAAE;SAClC,CAAC;IACJ,CAAC;CACF,CAAC","sourcesContent":["import { html } from 'lit-html';\nimport { ActionConfig, ACTION_GROUPS, FormData, FlowTypes } from '../types';\nimport { Node, SetRunResult } from '../../store/flow-definition';\nimport { getStore } from '../../store/Store';\n\nexport const set_run_result: ActionConfig = {\n name: 'Save Flow Result',\n group: ACTION_GROUPS.save,\n flowTypes: [FlowTypes.VOICE, FlowTypes.MESSAGE, FlowTypes.BACKGROUND],\n render: (_node: Node, action: SetRunResult) => {\n return html`<div>\n Save <strong>${action.value}</strong> as <strong>${action.name}</strong>\n </div>`;\n },\n form: {\n name: {\n type: 'select',\n label: 'Result Name',\n helpText: 'Select an existing result name or type a new one',\n required: true,\n placeholder: 'Select or enter result name...',\n createArbitraryOption: (input, options) => {\n const exists = options.some(\n (option: any) =>\n option.value.toLowerCase() === input.toLowerCase() ||\n option.name.toLowerCase() === input.toLowerCase()\n );\n return !exists && input.trim().length > 0\n ? { value: input, name: input }\n : null;\n },\n searchable: true,\n clearable: false,\n getDynamicOptions: () => {\n const store = getStore();\n return store\n ? store\n .getState()\n .getFlowResults()\n .map((r) => ({ value: r.name, name: r.name }))\n : [];\n }\n },\n value: {\n type: 'text',\n label: 'Value',\n helpText: 'The value to save for this result (can use expressions)',\n required: false,\n evaluated: true,\n placeholder: 'Enter value...'\n },\n category: {\n type: 'text',\n label: 'Category',\n helpText: 'Optional category for this result',\n required: false,\n placeholder: 'Enter category...'\n }\n },\n layout: ['name', 'value', 'category'],\n toFormData: (action: SetRunResult) => {\n return {\n uuid: action.uuid,\n name: action.name ? [{ name: action.name, value: action.name }] : null,\n value: action.value || '',\n category: action.category || ''\n };\n },\n fromFormData: (formData: FormData): SetRunResult => {\n // Ensure name is a simple string, handling both direct values and select option objects\n let name = formData.name || '';\n if (Array.isArray(name) && name.length > 0) {\n // If it's an array (from multi-select), take the first item\n name = name[0];\n }\n if (typeof name === 'object' && name.value) {\n // If it's an option object, extract the value\n name = name.value;\n }\n if (typeof name === 'object' && name.name) {\n // If it's an option object with name property, extract it\n name = name.name;\n }\n\n return {\n uuid: formData.uuid,\n type: 'set_run_result',\n name: String(name), // Ensure it's always a string\n value: formData.value || '',\n category: formData.category || ''\n };\n }\n};\n"]}