@nyaruka/temba-components 0.139.0 → 0.141.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (385) hide show
  1. package/.github/workflows/cla.yml +1 -1
  2. package/.github/workflows/copilot-setup-steps.yml +6 -1
  3. package/.lintstagedrc.js +10 -0
  4. package/CHANGELOG.md +32 -0
  5. package/demo/data/flows/sample-flow.json +24 -0
  6. package/dist/locales/es.js +5 -5
  7. package/dist/locales/es.js.map +1 -1
  8. package/dist/locales/fr.js +5 -5
  9. package/dist/locales/fr.js.map +1 -1
  10. package/dist/locales/locale-codes.js +11 -2
  11. package/dist/locales/locale-codes.js.map +1 -1
  12. package/dist/locales/pt.js +5 -5
  13. package/dist/locales/pt.js.map +1 -1
  14. package/dist/temba-components.js +702 -338
  15. package/dist/temba-components.js.map +1 -1
  16. package/out-tsc/src/display/Chat.js +10 -7
  17. package/out-tsc/src/display/Chat.js.map +1 -1
  18. package/out-tsc/src/display/Dropdown.js +3 -1
  19. package/out-tsc/src/display/Dropdown.js.map +1 -1
  20. package/out-tsc/src/display/FloatingTab.js +4 -4
  21. package/out-tsc/src/display/FloatingTab.js.map +1 -1
  22. package/out-tsc/src/display/Thumbnail.js +163 -5
  23. package/out-tsc/src/display/Thumbnail.js.map +1 -1
  24. package/out-tsc/src/flow/CanvasNode.js +65 -23
  25. package/out-tsc/src/flow/CanvasNode.js.map +1 -1
  26. package/out-tsc/src/flow/Editor.js +369 -49
  27. package/out-tsc/src/flow/Editor.js.map +1 -1
  28. package/out-tsc/src/flow/NodeEditor.js +118 -10
  29. package/out-tsc/src/flow/NodeEditor.js.map +1 -1
  30. package/out-tsc/src/flow/Plumber.js +61 -14
  31. package/out-tsc/src/flow/Plumber.js.map +1 -1
  32. package/out-tsc/src/flow/StickyNote.js +13 -4
  33. package/out-tsc/src/flow/StickyNote.js.map +1 -1
  34. package/out-tsc/src/flow/actions/add_contact_groups.js +4 -1
  35. package/out-tsc/src/flow/actions/add_contact_groups.js.map +1 -1
  36. package/out-tsc/src/flow/actions/add_input_labels.js +4 -1
  37. package/out-tsc/src/flow/actions/add_input_labels.js.map +1 -1
  38. package/out-tsc/src/flow/actions/audio-player.js +112 -0
  39. package/out-tsc/src/flow/actions/audio-player.js.map +1 -0
  40. package/out-tsc/src/flow/actions/enter_flow.js +43 -0
  41. package/out-tsc/src/flow/actions/enter_flow.js.map +1 -0
  42. package/out-tsc/src/flow/actions/play_audio.js +57 -4
  43. package/out-tsc/src/flow/actions/play_audio.js.map +1 -1
  44. package/out-tsc/src/flow/actions/remove_contact_groups.js +6 -1
  45. package/out-tsc/src/flow/actions/remove_contact_groups.js.map +1 -1
  46. package/out-tsc/src/flow/actions/say_msg.js +86 -3
  47. package/out-tsc/src/flow/actions/say_msg.js.map +1 -1
  48. package/out-tsc/src/flow/actions/send_broadcast.js +6 -2
  49. package/out-tsc/src/flow/actions/send_broadcast.js.map +1 -1
  50. package/out-tsc/src/flow/actions/set_contact_channel.js +13 -0
  51. package/out-tsc/src/flow/actions/set_contact_channel.js.map +1 -1
  52. package/out-tsc/src/flow/actions/set_contact_status.js +7 -5
  53. package/out-tsc/src/flow/actions/set_contact_status.js.map +1 -1
  54. package/out-tsc/src/flow/actions/start_session.js +10 -3
  55. package/out-tsc/src/flow/actions/start_session.js.map +1 -1
  56. package/out-tsc/src/flow/config.js +11 -3
  57. package/out-tsc/src/flow/config.js.map +1 -1
  58. package/out-tsc/src/flow/nodes/shared-rules.js +1 -1
  59. package/out-tsc/src/flow/nodes/shared-rules.js.map +1 -1
  60. package/out-tsc/src/flow/nodes/split_by_contact_field.js +18 -5
  61. package/out-tsc/src/flow/nodes/split_by_contact_field.js.map +1 -1
  62. package/out-tsc/src/flow/nodes/split_by_expression.js +1 -1
  63. package/out-tsc/src/flow/nodes/split_by_expression.js.map +1 -1
  64. package/out-tsc/src/flow/nodes/split_by_llm_categorize.js +0 -1
  65. package/out-tsc/src/flow/nodes/split_by_llm_categorize.js.map +1 -1
  66. package/out-tsc/src/flow/nodes/split_by_random.js +0 -1
  67. package/out-tsc/src/flow/nodes/split_by_random.js.map +1 -1
  68. package/out-tsc/src/flow/nodes/split_by_run_result.js +10 -4
  69. package/out-tsc/src/flow/nodes/split_by_run_result.js.map +1 -1
  70. package/out-tsc/src/flow/nodes/terminal.js +7 -0
  71. package/out-tsc/src/flow/nodes/terminal.js.map +1 -0
  72. package/out-tsc/src/flow/nodes/wait_for_audio.js +77 -0
  73. package/out-tsc/src/flow/nodes/wait_for_audio.js.map +1 -0
  74. package/out-tsc/src/flow/nodes/wait_for_dial.js +151 -0
  75. package/out-tsc/src/flow/nodes/wait_for_dial.js.map +1 -0
  76. package/out-tsc/src/flow/nodes/wait_for_digits.js +61 -1
  77. package/out-tsc/src/flow/nodes/wait_for_digits.js.map +1 -1
  78. package/out-tsc/src/flow/nodes/wait_for_menu.js +173 -2
  79. package/out-tsc/src/flow/nodes/wait_for_menu.js.map +1 -1
  80. package/out-tsc/src/flow/nodes/wait_for_response.js +1 -1
  81. package/out-tsc/src/flow/nodes/wait_for_response.js.map +1 -1
  82. package/out-tsc/src/flow/operators.js +21 -5
  83. package/out-tsc/src/flow/operators.js.map +1 -1
  84. package/out-tsc/src/flow/types.js.map +1 -1
  85. package/out-tsc/src/flow/utils.js +79 -3
  86. package/out-tsc/src/flow/utils.js.map +1 -1
  87. package/out-tsc/src/form/ArrayEditor.js +4 -2
  88. package/out-tsc/src/form/ArrayEditor.js.map +1 -1
  89. package/out-tsc/src/form/FieldRenderer.js +56 -0
  90. package/out-tsc/src/form/FieldRenderer.js.map +1 -1
  91. package/out-tsc/src/interfaces.js +1 -0
  92. package/out-tsc/src/interfaces.js.map +1 -1
  93. package/out-tsc/src/layout/Dialog.js +51 -7
  94. package/out-tsc/src/layout/Dialog.js.map +1 -1
  95. package/out-tsc/src/layout/Modax.js +20 -2
  96. package/out-tsc/src/layout/Modax.js.map +1 -1
  97. package/out-tsc/src/list/ContentMenu.js +14 -1
  98. package/out-tsc/src/list/ContentMenu.js.map +1 -1
  99. package/out-tsc/src/locales/es.js +5 -5
  100. package/out-tsc/src/locales/es.js.map +1 -1
  101. package/out-tsc/src/locales/fr.js +5 -5
  102. package/out-tsc/src/locales/fr.js.map +1 -1
  103. package/out-tsc/src/locales/locale-codes.js +11 -2
  104. package/out-tsc/src/locales/locale-codes.js.map +1 -1
  105. package/out-tsc/src/locales/pt.js +5 -5
  106. package/out-tsc/src/locales/pt.js.map +1 -1
  107. package/out-tsc/src/simulator/Simulator.js +21 -4
  108. package/out-tsc/src/simulator/Simulator.js.map +1 -1
  109. package/out-tsc/src/store/AppState.js +102 -3
  110. package/out-tsc/src/store/AppState.js.map +1 -1
  111. package/out-tsc/test/actions/add_contact_groups.test.js +35 -0
  112. package/out-tsc/test/actions/add_contact_groups.test.js.map +1 -1
  113. package/out-tsc/test/actions/add_input_labels.test.js +53 -0
  114. package/out-tsc/test/actions/add_input_labels.test.js.map +1 -0
  115. package/out-tsc/test/actions/enter_flow.test.js +71 -0
  116. package/out-tsc/test/actions/enter_flow.test.js.map +1 -0
  117. package/out-tsc/test/actions/play_audio.test.js +118 -0
  118. package/out-tsc/test/actions/play_audio.test.js.map +1 -0
  119. package/out-tsc/test/actions/remove_contact_groups.test.js +24 -0
  120. package/out-tsc/test/actions/remove_contact_groups.test.js.map +1 -1
  121. package/out-tsc/test/actions/say_msg.test.js +158 -0
  122. package/out-tsc/test/actions/say_msg.test.js.map +1 -0
  123. package/out-tsc/test/actions/send_broadcast.test.js +41 -0
  124. package/out-tsc/test/actions/send_broadcast.test.js.map +1 -1
  125. package/out-tsc/test/actions/set_contact_channel.test.js +67 -0
  126. package/out-tsc/test/actions/set_contact_channel.test.js.map +1 -0
  127. package/out-tsc/test/actions/set_contact_field.test.js +52 -0
  128. package/out-tsc/test/actions/set_contact_field.test.js.map +1 -0
  129. package/out-tsc/test/actions/set_contact_language.test.js +39 -0
  130. package/out-tsc/test/actions/set_contact_language.test.js.map +1 -0
  131. package/out-tsc/test/actions/set_contact_name.test.js +28 -0
  132. package/out-tsc/test/actions/set_contact_name.test.js.map +1 -0
  133. package/out-tsc/test/actions/set_contact_status.test.js +44 -0
  134. package/out-tsc/test/actions/set_contact_status.test.js.map +1 -0
  135. package/out-tsc/test/actions/set_run_result.test.js +47 -0
  136. package/out-tsc/test/actions/set_run_result.test.js.map +1 -0
  137. package/out-tsc/test/actions/start_session.test.js +76 -0
  138. package/out-tsc/test/actions/start_session.test.js.map +1 -1
  139. package/out-tsc/test/nodes/split_by_contact_field.test.js +50 -0
  140. package/out-tsc/test/nodes/split_by_contact_field.test.js.map +1 -1
  141. package/out-tsc/test/nodes/split_by_run_result.test.js +82 -0
  142. package/out-tsc/test/nodes/split_by_run_result.test.js.map +1 -1
  143. package/out-tsc/test/nodes/split_by_ticket.test.js +139 -0
  144. package/out-tsc/test/nodes/split_by_ticket.test.js.map +1 -0
  145. package/out-tsc/test/nodes/split_by_webhook.test.js +111 -0
  146. package/out-tsc/test/nodes/split_by_webhook.test.js.map +1 -0
  147. package/out-tsc/test/nodes/wait_for_audio.test.js +156 -0
  148. package/out-tsc/test/nodes/wait_for_audio.test.js.map +1 -0
  149. package/out-tsc/test/nodes/wait_for_dial.test.js +336 -0
  150. package/out-tsc/test/nodes/wait_for_dial.test.js.map +1 -0
  151. package/out-tsc/test/nodes/wait_for_digits.test.js +198 -84
  152. package/out-tsc/test/nodes/wait_for_digits.test.js.map +1 -1
  153. package/out-tsc/test/nodes/wait_for_menu.test.js +340 -0
  154. package/out-tsc/test/nodes/wait_for_menu.test.js.map +1 -0
  155. package/out-tsc/test/temba-flow-collision.test.js +261 -6
  156. package/out-tsc/test/temba-flow-collision.test.js.map +1 -1
  157. package/out-tsc/test/temba-flow-editor.test.js +187 -0
  158. package/out-tsc/test/temba-flow-editor.test.js.map +1 -1
  159. package/out-tsc/test/temba-flow-plumber.test.js +19 -0
  160. package/out-tsc/test/temba-flow-plumber.test.js.map +1 -1
  161. package/out-tsc/test/temba-node-type-selector.test.js +6 -6
  162. package/out-tsc/test/temba-node-type-selector.test.js.map +1 -1
  163. package/out-tsc/test/temba-select.test.js +4 -1
  164. package/out-tsc/test/temba-select.test.js.map +1 -1
  165. package/out-tsc/test/utils.test.js +4 -2
  166. package/out-tsc/test/utils.test.js.map +1 -1
  167. package/package.json +3 -9
  168. package/screenshots/truth/actions/add_contact_groups/render/descriptive-group-names.png +0 -0
  169. package/screenshots/truth/actions/add_contact_groups/render/long-group-names.png +0 -0
  170. package/screenshots/truth/actions/add_contact_groups/render/many-groups.png +0 -0
  171. package/screenshots/truth/actions/add_contact_groups/render/multiple-groups.png +0 -0
  172. package/screenshots/truth/actions/add_contact_groups/render/single-group.png +0 -0
  173. package/screenshots/truth/actions/add_contact_urn/render/expression-facebook.png +0 -0
  174. package/screenshots/truth/actions/add_contact_urn/render/expression-phone.png +0 -0
  175. package/screenshots/truth/actions/add_contact_urn/render/facebook-id.png +0 -0
  176. package/screenshots/truth/actions/add_contact_urn/render/instagram-handle.png +0 -0
  177. package/screenshots/truth/actions/add_contact_urn/render/line-id.png +0 -0
  178. package/screenshots/truth/actions/add_contact_urn/render/phone-number.png +0 -0
  179. package/screenshots/truth/actions/add_contact_urn/render/telegram-id.png +0 -0
  180. package/screenshots/truth/actions/add_contact_urn/render/viber-id.png +0 -0
  181. package/screenshots/truth/actions/add_contact_urn/render/wechat-id.png +0 -0
  182. package/screenshots/truth/actions/add_contact_urn/render/whatsapp.png +0 -0
  183. package/screenshots/truth/actions/add_input_labels/editor/multiple-labels.png +0 -0
  184. package/screenshots/truth/actions/add_input_labels/editor/single-label.png +0 -0
  185. package/screenshots/truth/actions/add_input_labels/render/multiple-labels.png +0 -0
  186. package/screenshots/truth/actions/add_input_labels/render/single-label.png +0 -0
  187. package/screenshots/truth/actions/enter_flow/editor/basic-flow.png +0 -0
  188. package/screenshots/truth/actions/enter_flow/editor/long-flow-name.png +0 -0
  189. package/screenshots/truth/actions/enter_flow/render/basic-flow.png +0 -0
  190. package/screenshots/truth/actions/enter_flow/render/long-flow-name.png +0 -0
  191. package/screenshots/truth/actions/play_audio/editor/expression-url.png +0 -0
  192. package/screenshots/truth/actions/play_audio/editor/static-url.png +0 -0
  193. package/screenshots/truth/actions/play_audio/render/expression-url.png +0 -0
  194. package/screenshots/truth/actions/play_audio/render/static-url.png +0 -0
  195. package/screenshots/truth/actions/remove_contact_groups/render/cleanup-groups.png +0 -0
  196. package/screenshots/truth/actions/remove_contact_groups/render/long-descriptive-group-names.png +0 -0
  197. package/screenshots/truth/actions/remove_contact_groups/render/many-groups.png +0 -0
  198. package/screenshots/truth/actions/remove_contact_groups/render/multiple-groups.png +0 -0
  199. package/screenshots/truth/actions/remove_contact_groups/render/remove-from-all-groups.png +0 -0
  200. package/screenshots/truth/actions/remove_contact_groups/render/single-group.png +0 -0
  201. package/screenshots/truth/actions/say_msg/editor/multiline-text.png +0 -0
  202. package/screenshots/truth/actions/say_msg/editor/simple-text.png +0 -0
  203. package/screenshots/truth/actions/say_msg/editor/text-with-audio-url.png +0 -0
  204. package/screenshots/truth/actions/say_msg/render/multiline-text.png +0 -0
  205. package/screenshots/truth/actions/say_msg/render/simple-text.png +0 -0
  206. package/screenshots/truth/actions/say_msg/render/text-with-audio-url.png +0 -0
  207. package/screenshots/truth/actions/send_broadcast/render/contacts-only.png +0 -0
  208. package/screenshots/truth/actions/send_broadcast/render/groups-and-contacts.png +0 -0
  209. package/screenshots/truth/actions/send_broadcast/render/groups-only.png +0 -0
  210. package/screenshots/truth/actions/send_broadcast/render/many-groups.png +0 -0
  211. package/screenshots/truth/actions/send_broadcast/render/multiline-text.png +0 -0
  212. package/screenshots/truth/actions/send_email/render/complex-business-email.png +0 -0
  213. package/screenshots/truth/actions/send_email/render/empty-body.png +0 -0
  214. package/screenshots/truth/actions/send_email/render/empty-subject.png +0 -0
  215. package/screenshots/truth/actions/send_email/render/long-subject.png +0 -0
  216. package/screenshots/truth/actions/send_email/render/multiline-body.png +0 -0
  217. package/screenshots/truth/actions/send_email/render/multiple-recipients.png +0 -0
  218. package/screenshots/truth/actions/send_email/render/simple-email.png +0 -0
  219. package/screenshots/truth/actions/send_email/render/with-expressions.png +0 -0
  220. package/screenshots/truth/actions/send_msg/render/long-quick-replies.png +0 -0
  221. package/screenshots/truth/actions/send_msg/render/multiline-text-with-replies.png +0 -0
  222. package/screenshots/truth/actions/send_msg/render/simple-text.png +0 -0
  223. package/screenshots/truth/actions/send_msg/render/text-with-linebreaks.png +0 -0
  224. package/screenshots/truth/actions/send_msg/render/text-with-many-quick-replies.png +0 -0
  225. package/screenshots/truth/actions/send_msg/render/text-with-quick-replies.png +0 -0
  226. package/screenshots/truth/actions/send_msg/render/text-without-quick-replies.png +0 -0
  227. package/screenshots/truth/actions/set_contact_channel/editor/sms-channel.png +0 -0
  228. package/screenshots/truth/actions/set_contact_channel/editor/whatsapp-channel.png +0 -0
  229. package/screenshots/truth/actions/set_contact_channel/render/sms-channel.png +0 -0
  230. package/screenshots/truth/actions/set_contact_channel/render/whatsapp-channel.png +0 -0
  231. package/screenshots/truth/actions/set_contact_field/editor/clear-value.png +0 -0
  232. package/screenshots/truth/actions/set_contact_field/editor/set-value.png +0 -0
  233. package/screenshots/truth/actions/set_contact_field/render/clear-value.png +0 -0
  234. package/screenshots/truth/actions/set_contact_field/render/set-value.png +0 -0
  235. package/screenshots/truth/actions/set_contact_language/editor/english.png +0 -0
  236. package/screenshots/truth/actions/set_contact_language/editor/french.png +0 -0
  237. package/screenshots/truth/actions/set_contact_language/render/english.png +0 -0
  238. package/screenshots/truth/actions/set_contact_language/render/french.png +0 -0
  239. package/screenshots/truth/actions/set_contact_name/editor/expression-name.png +0 -0
  240. package/screenshots/truth/actions/set_contact_name/editor/static-name.png +0 -0
  241. package/screenshots/truth/actions/set_contact_name/render/expression-name.png +0 -0
  242. package/screenshots/truth/actions/set_contact_name/render/static-name.png +0 -0
  243. package/screenshots/truth/actions/set_contact_status/editor/active.png +0 -0
  244. package/screenshots/truth/actions/set_contact_status/editor/archived.png +0 -0
  245. package/screenshots/truth/actions/set_contact_status/editor/blocked.png +0 -0
  246. package/screenshots/truth/actions/set_contact_status/render/active.png +0 -0
  247. package/screenshots/truth/actions/set_contact_status/render/archived.png +0 -0
  248. package/screenshots/truth/actions/set_contact_status/render/blocked.png +0 -0
  249. package/screenshots/truth/actions/set_run_result/editor/expression-value.png +0 -0
  250. package/screenshots/truth/actions/set_run_result/editor/with-category.png +0 -0
  251. package/screenshots/truth/actions/set_run_result/render/expression-value.png +0 -0
  252. package/screenshots/truth/actions/set_run_result/render/with-category.png +0 -0
  253. package/screenshots/truth/actions/start_session/render/contact-query.png +0 -0
  254. package/screenshots/truth/actions/start_session/render/contacts-only.png +0 -0
  255. package/screenshots/truth/actions/start_session/render/create-contact.png +0 -0
  256. package/screenshots/truth/actions/start_session/render/groups-and-contacts.png +0 -0
  257. package/screenshots/truth/actions/start_session/render/groups-only.png +0 -0
  258. package/screenshots/truth/actions/start_session/render/many-recipients.png +0 -0
  259. package/screenshots/truth/editor/router.png +0 -0
  260. package/screenshots/truth/editor/wait.png +0 -0
  261. package/screenshots/truth/nodes/split_by_llm/render/information-extraction.png +0 -0
  262. package/screenshots/truth/nodes/split_by_llm/render/sentiment-analysis.png +0 -0
  263. package/screenshots/truth/nodes/split_by_llm/render/summarization.png +0 -0
  264. package/screenshots/truth/nodes/split_by_llm/render/translation-task.png +0 -0
  265. package/screenshots/truth/nodes/split_by_llm_categorize/editor/basic-categorization.png +0 -0
  266. package/screenshots/truth/nodes/split_by_llm_categorize/editor/custom-input-and-result-name.png +0 -0
  267. package/screenshots/truth/nodes/split_by_llm_categorize/editor/feedback-categorization.png +0 -0
  268. package/screenshots/truth/nodes/split_by_llm_categorize/editor/many-categories.png +0 -0
  269. package/screenshots/truth/nodes/split_by_llm_categorize/editor/minimal-categories.png +0 -0
  270. package/screenshots/truth/nodes/split_by_llm_categorize/render/basic-categorization.png +0 -0
  271. package/screenshots/truth/nodes/split_by_llm_categorize/render/custom-input-and-result-name.png +0 -0
  272. package/screenshots/truth/nodes/split_by_llm_categorize/render/feedback-categorization.png +0 -0
  273. package/screenshots/truth/nodes/split_by_llm_categorize/render/many-categories.png +0 -0
  274. package/screenshots/truth/nodes/split_by_llm_categorize/render/minimal-categories.png +0 -0
  275. package/screenshots/truth/nodes/split_by_random/editor/ab-test-multiple-variants.png +0 -0
  276. package/screenshots/truth/nodes/split_by_random/editor/sampling-split.png +0 -0
  277. package/screenshots/truth/nodes/split_by_random/editor/three-way-split.png +0 -0
  278. package/screenshots/truth/nodes/split_by_random/editor/two-bucket-split.png +0 -0
  279. package/screenshots/truth/nodes/split_by_random/render/ab-test-multiple-variants.png +0 -0
  280. package/screenshots/truth/nodes/split_by_random/render/sampling-split.png +0 -0
  281. package/screenshots/truth/nodes/split_by_random/render/three-way-split.png +0 -0
  282. package/screenshots/truth/nodes/split_by_random/render/two-bucket-split.png +0 -0
  283. package/screenshots/truth/nodes/wait_for_audio/editor/basic-audio-wait.png +0 -0
  284. package/screenshots/truth/nodes/wait_for_audio/render/basic-audio-wait.png +0 -0
  285. package/screenshots/truth/nodes/wait_for_dial/editor/basic-dial.png +0 -0
  286. package/screenshots/truth/nodes/wait_for_dial/editor/dial-with-limits.png +0 -0
  287. package/screenshots/truth/nodes/wait_for_dial/render/basic-dial.png +0 -0
  288. package/screenshots/truth/nodes/wait_for_dial/render/dial-with-limits.png +0 -0
  289. package/screenshots/truth/nodes/wait_for_digits/editor/basic-digits-wait.png +0 -0
  290. package/screenshots/truth/nodes/wait_for_digits/editor/digits-with-rules.png +0 -0
  291. package/screenshots/truth/nodes/wait_for_digits/render/basic-digits-wait.png +0 -0
  292. package/screenshots/truth/nodes/wait_for_digits/render/digits-with-rules.png +0 -0
  293. package/screenshots/truth/nodes/wait_for_menu/editor/menu-with-digits.png +0 -0
  294. package/screenshots/truth/nodes/wait_for_menu/render/menu-with-digits.png +0 -0
  295. package/screenshots/truth/nodes/wait_for_response/editor/basic-wait.png +0 -0
  296. package/screenshots/truth/nodes/wait_for_response/editor/custom-result-name.png +0 -0
  297. package/screenshots/truth/nodes/wait_for_response/editor/no-timeout.png +0 -0
  298. package/screenshots/truth/nodes/wait_for_response/editor/short-timeout.png +0 -0
  299. package/screenshots/truth/nodes/wait_for_response/render/basic-wait.png +0 -0
  300. package/screenshots/truth/nodes/wait_for_response/render/custom-result-name.png +0 -0
  301. package/screenshots/truth/nodes/wait_for_response/render/no-timeout.png +0 -0
  302. package/screenshots/truth/nodes/wait_for_response/render/short-timeout.png +0 -0
  303. package/src/display/Chat.ts +13 -7
  304. package/src/display/Dropdown.ts +3 -1
  305. package/src/display/FloatingTab.ts +4 -4
  306. package/src/display/Thumbnail.ts +162 -2
  307. package/src/flow/CanvasNode.ts +70 -24
  308. package/src/flow/Editor.ts +440 -99
  309. package/src/flow/NodeEditor.ts +137 -9
  310. package/src/flow/Plumber.ts +89 -14
  311. package/src/flow/StickyNote.ts +14 -4
  312. package/src/flow/actions/add_contact_groups.ts +4 -1
  313. package/src/flow/actions/add_input_labels.ts +4 -1
  314. package/src/flow/actions/audio-player.ts +127 -0
  315. package/src/flow/actions/enter_flow.ts +44 -0
  316. package/src/flow/actions/play_audio.ts +64 -5
  317. package/src/flow/actions/remove_contact_groups.ts +6 -1
  318. package/src/flow/actions/say_msg.ts +94 -4
  319. package/src/flow/actions/send_broadcast.ts +6 -2
  320. package/src/flow/actions/set_contact_channel.ts +13 -1
  321. package/src/flow/actions/set_contact_status.ts +7 -5
  322. package/src/flow/actions/start_session.ts +10 -3
  323. package/src/flow/config.ts +11 -3
  324. package/src/flow/nodes/shared-rules.ts +1 -1
  325. package/src/flow/nodes/split_by_contact_field.ts +16 -5
  326. package/src/flow/nodes/split_by_expression.ts +1 -1
  327. package/src/flow/nodes/split_by_llm_categorize.ts +0 -1
  328. package/src/flow/nodes/split_by_random.ts +0 -1
  329. package/src/flow/nodes/split_by_run_result.ts +10 -4
  330. package/src/flow/nodes/terminal.ts +9 -0
  331. package/src/flow/nodes/wait_for_audio.ts +88 -0
  332. package/src/flow/nodes/wait_for_dial.ts +176 -0
  333. package/src/flow/nodes/wait_for_digits.ts +87 -2
  334. package/src/flow/nodes/wait_for_menu.ts +209 -3
  335. package/src/flow/nodes/wait_for_response.ts +1 -1
  336. package/src/flow/operators.ts +23 -5
  337. package/src/flow/types.ts +23 -1
  338. package/src/flow/utils.ts +82 -3
  339. package/src/form/ArrayEditor.ts +4 -2
  340. package/src/form/FieldRenderer.ts +71 -1
  341. package/src/interfaces.ts +2 -1
  342. package/src/layout/Dialog.ts +52 -7
  343. package/src/layout/Modax.ts +19 -2
  344. package/src/list/ContentMenu.ts +15 -1
  345. package/src/locales/es.ts +18 -13
  346. package/src/locales/fr.ts +18 -13
  347. package/src/locales/locale-codes.ts +11 -2
  348. package/src/locales/pt.ts +18 -13
  349. package/src/simulator/Simulator.ts +25 -4
  350. package/src/store/AppState.ts +120 -1
  351. package/src/store/flow-definition.d.ts +2 -0
  352. package/test/actions/add_contact_groups.test.ts +38 -0
  353. package/test/actions/add_input_labels.test.ts +67 -0
  354. package/test/actions/enter_flow.test.ts +88 -0
  355. package/test/actions/play_audio.test.ts +155 -0
  356. package/test/actions/remove_contact_groups.test.ts +29 -0
  357. package/test/actions/say_msg.test.ts +196 -0
  358. package/test/actions/send_broadcast.test.ts +44 -0
  359. package/test/actions/set_contact_channel.test.ts +88 -0
  360. package/test/actions/set_contact_field.test.ts +68 -0
  361. package/test/actions/set_contact_language.test.ts +55 -0
  362. package/test/actions/set_contact_name.test.ts +39 -0
  363. package/test/actions/set_contact_status.test.ts +64 -0
  364. package/test/actions/set_run_result.test.ts +61 -0
  365. package/test/actions/start_session.test.ts +82 -0
  366. package/test/nodes/split_by_contact_field.test.ts +59 -0
  367. package/test/nodes/split_by_run_result.test.ts +100 -0
  368. package/test/nodes/split_by_ticket.test.ts +157 -0
  369. package/test/nodes/split_by_webhook.test.ts +131 -0
  370. package/test/nodes/wait_for_audio.test.ts +182 -0
  371. package/test/nodes/wait_for_dial.test.ts +382 -0
  372. package/test/nodes/wait_for_digits.test.ts +233 -109
  373. package/test/nodes/wait_for_menu.test.ts +383 -0
  374. package/test/temba-flow-collision.test.ts +286 -6
  375. package/test/temba-flow-editor.test.ts +240 -0
  376. package/test/temba-flow-plumber.test.ts +62 -0
  377. package/test/temba-node-type-selector.test.ts +6 -6
  378. package/test/temba-select.test.ts +6 -1
  379. package/test/utils.test.ts +4 -2
  380. package/screenshots/truth/nodes/wait_for_digits/editor/phone-number-collection.png +0 -0
  381. package/screenshots/truth/nodes/wait_for_digits/editor/single-digit-with-timeout.png +0 -0
  382. package/screenshots/truth/nodes/wait_for_digits/editor/verification-code.png +0 -0
  383. package/screenshots/truth/nodes/wait_for_digits/render/phone-number-collection.png +0 -0
  384. package/screenshots/truth/nodes/wait_for_digits/render/single-digit-with-timeout.png +0 -0
  385. package/screenshots/truth/nodes/wait_for_digits/render/verification-code.png +0 -0
@@ -0,0 +1,52 @@
1
+ import { expect } from '@open-wc/testing';
2
+ import { set_contact_field } from '../../src/flow/actions/set_contact_field';
3
+ import { ActionTest } from '../ActionHelper';
4
+ /**
5
+ * Test suite for the set_contact_field action configuration.
6
+ */
7
+ describe('set_contact_field action config', () => {
8
+ const helper = new ActionTest(set_contact_field, 'set_contact_field');
9
+ describe('basic properties', () => {
10
+ helper.testBasicProperties();
11
+ it('has correct name', () => {
12
+ expect(set_contact_field.name).to.equal('Update Field');
13
+ });
14
+ });
15
+ describe('action scenarios', () => {
16
+ helper.testAction({
17
+ uuid: 'test-action-1',
18
+ type: 'set_contact_field',
19
+ field: { key: 'favorite_color', name: 'Favorite Color' },
20
+ value: 'Blue'
21
+ }, 'set-value');
22
+ helper.testAction({
23
+ uuid: 'test-action-2',
24
+ type: 'set_contact_field',
25
+ field: { key: 'age', name: 'Age' },
26
+ value: ''
27
+ }, 'clear-value');
28
+ });
29
+ describe('metadata stripping', () => {
30
+ it('should strip superfluous API metadata from field', () => {
31
+ const formData = {
32
+ uuid: 'test-uuid',
33
+ field: [
34
+ {
35
+ key: 'favorite_color',
36
+ name: 'Favorite Color',
37
+ value_type: 'text',
38
+ featured: true,
39
+ usages: { campaign_events: 0, flows: 3, groups: 1 }
40
+ }
41
+ ],
42
+ value: 'Red'
43
+ };
44
+ const action = set_contact_field.fromFormData(formData);
45
+ expect(action.field).to.deep.equal({
46
+ key: 'favorite_color',
47
+ name: 'Favorite Color'
48
+ });
49
+ });
50
+ });
51
+ });
52
+ //# sourceMappingURL=set_contact_field.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"set_contact_field.test.js","sourceRoot":"","sources":["../../../test/actions/set_contact_field.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAC1C,OAAO,EAAE,iBAAiB,EAAE,MAAM,0CAA0C,CAAC;AAE7E,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAE7C;;GAEG;AACH,QAAQ,CAAC,iCAAiC,EAAE,GAAG,EAAE;IAC/C,MAAM,MAAM,GAAG,IAAI,UAAU,CAAC,iBAAiB,EAAE,mBAAmB,CAAC,CAAC;IAEtE,QAAQ,CAAC,kBAAkB,EAAE,GAAG,EAAE;QAChC,MAAM,CAAC,mBAAmB,EAAE,CAAC;QAE7B,EAAE,CAAC,kBAAkB,EAAE,GAAG,EAAE;YAC1B,MAAM,CAAC,iBAAiB,CAAC,IAAI,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,cAAc,CAAC,CAAC;QAC1D,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;IAEH,QAAQ,CAAC,kBAAkB,EAAE,GAAG,EAAE;QAChC,MAAM,CAAC,UAAU,CACf;YACE,IAAI,EAAE,eAAe;YACrB,IAAI,EAAE,mBAAmB;YACzB,KAAK,EAAE,EAAE,GAAG,EAAE,gBAAgB,EAAE,IAAI,EAAE,gBAAgB,EAAE;YACxD,KAAK,EAAE,MAAM;SACK,EACpB,WAAW,CACZ,CAAC;QAEF,MAAM,CAAC,UAAU,CACf;YACE,IAAI,EAAE,eAAe;YACrB,IAAI,EAAE,mBAAmB;YACzB,KAAK,EAAE,EAAE,GAAG,EAAE,KAAK,EAAE,IAAI,EAAE,KAAK,EAAE;YAClC,KAAK,EAAE,EAAE;SACS,EACpB,aAAa,CACd,CAAC;IACJ,CAAC,CAAC,CAAC;IAEH,QAAQ,CAAC,oBAAoB,EAAE,GAAG,EAAE;QAClC,EAAE,CAAC,kDAAkD,EAAE,GAAG,EAAE;YAC1D,MAAM,QAAQ,GAAG;gBACf,IAAI,EAAE,WAAW;gBACjB,KAAK,EAAE;oBACL;wBACE,GAAG,EAAE,gBAAgB;wBACrB,IAAI,EAAE,gBAAgB;wBACtB,UAAU,EAAE,MAAM;wBAClB,QAAQ,EAAE,IAAI;wBACd,MAAM,EAAE,EAAE,eAAe,EAAE,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE;qBACpD;iBACF;gBACD,KAAK,EAAE,KAAK;aACb,CAAC;YAEF,MAAM,MAAM,GAAG,iBAAiB,CAAC,YAAY,CAC3C,QAAQ,CACU,CAAC;YAErB,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC;gBACjC,GAAG,EAAE,gBAAgB;gBACrB,IAAI,EAAE,gBAAgB;aACvB,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC","sourcesContent":["import { expect } from '@open-wc/testing';\nimport { set_contact_field } from '../../src/flow/actions/set_contact_field';\nimport { SetContactField } from '../../src/store/flow-definition';\nimport { ActionTest } from '../ActionHelper';\n\n/**\n * Test suite for the set_contact_field action configuration.\n */\ndescribe('set_contact_field action config', () => {\n const helper = new ActionTest(set_contact_field, 'set_contact_field');\n\n describe('basic properties', () => {\n helper.testBasicProperties();\n\n it('has correct name', () => {\n expect(set_contact_field.name).to.equal('Update Field');\n });\n });\n\n describe('action scenarios', () => {\n helper.testAction(\n {\n uuid: 'test-action-1',\n type: 'set_contact_field',\n field: { key: 'favorite_color', name: 'Favorite Color' },\n value: 'Blue'\n } as SetContactField,\n 'set-value'\n );\n\n helper.testAction(\n {\n uuid: 'test-action-2',\n type: 'set_contact_field',\n field: { key: 'age', name: 'Age' },\n value: ''\n } as SetContactField,\n 'clear-value'\n );\n });\n\n describe('metadata stripping', () => {\n it('should strip superfluous API metadata from field', () => {\n const formData = {\n uuid: 'test-uuid',\n field: [\n {\n key: 'favorite_color',\n name: 'Favorite Color',\n value_type: 'text',\n featured: true,\n usages: { campaign_events: 0, flows: 3, groups: 1 }\n }\n ],\n value: 'Red'\n };\n\n const action = set_contact_field.fromFormData(\n formData\n ) as SetContactField;\n\n expect(action.field).to.deep.equal({\n key: 'favorite_color',\n name: 'Favorite Color'\n });\n });\n });\n});\n"]}
@@ -0,0 +1,39 @@
1
+ import { expect } from '@open-wc/testing';
2
+ import { set_contact_language } from '../../src/flow/actions/set_contact_language';
3
+ import { ActionTest } from '../ActionHelper';
4
+ /**
5
+ * Test suite for the set_contact_language action configuration.
6
+ */
7
+ describe('set_contact_language action config', () => {
8
+ const helper = new ActionTest(set_contact_language, 'set_contact_language');
9
+ describe('basic properties', () => {
10
+ helper.testBasicProperties();
11
+ it('has correct name', () => {
12
+ expect(set_contact_language.name).to.equal('Update Language');
13
+ });
14
+ });
15
+ describe('action scenarios', () => {
16
+ helper.testAction({
17
+ uuid: 'test-action-1',
18
+ type: 'set_contact_language',
19
+ language: 'eng'
20
+ }, 'english');
21
+ helper.testAction({
22
+ uuid: 'test-action-2',
23
+ type: 'set_contact_language',
24
+ language: 'fra'
25
+ }, 'french');
26
+ });
27
+ describe('round-trip', () => {
28
+ it('should extract language code from select option', () => {
29
+ const formData = {
30
+ uuid: 'test-uuid',
31
+ language: [{ value: 'spa', name: 'Spanish' }]
32
+ };
33
+ const action = set_contact_language.fromFormData(formData);
34
+ expect(action.language).to.equal('spa');
35
+ expect(action.type).to.equal('set_contact_language');
36
+ });
37
+ });
38
+ });
39
+ //# sourceMappingURL=set_contact_language.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"set_contact_language.test.js","sourceRoot":"","sources":["../../../test/actions/set_contact_language.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAC1C,OAAO,EAAE,oBAAoB,EAAE,MAAM,6CAA6C,CAAC;AAEnF,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAE7C;;GAEG;AACH,QAAQ,CAAC,oCAAoC,EAAE,GAAG,EAAE;IAClD,MAAM,MAAM,GAAG,IAAI,UAAU,CAAC,oBAAoB,EAAE,sBAAsB,CAAC,CAAC;IAE5E,QAAQ,CAAC,kBAAkB,EAAE,GAAG,EAAE;QAChC,MAAM,CAAC,mBAAmB,EAAE,CAAC;QAE7B,EAAE,CAAC,kBAAkB,EAAE,GAAG,EAAE;YAC1B,MAAM,CAAC,oBAAoB,CAAC,IAAI,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,iBAAiB,CAAC,CAAC;QAChE,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;IAEH,QAAQ,CAAC,kBAAkB,EAAE,GAAG,EAAE;QAChC,MAAM,CAAC,UAAU,CACf;YACE,IAAI,EAAE,eAAe;YACrB,IAAI,EAAE,sBAAsB;YAC5B,QAAQ,EAAE,KAAK;SACM,EACvB,SAAS,CACV,CAAC;QAEF,MAAM,CAAC,UAAU,CACf;YACE,IAAI,EAAE,eAAe;YACrB,IAAI,EAAE,sBAAsB;YAC5B,QAAQ,EAAE,KAAK;SACM,EACvB,QAAQ,CACT,CAAC;IACJ,CAAC,CAAC,CAAC;IAEH,QAAQ,CAAC,YAAY,EAAE,GAAG,EAAE;QAC1B,EAAE,CAAC,iDAAiD,EAAE,GAAG,EAAE;YACzD,MAAM,QAAQ,GAAG;gBACf,IAAI,EAAE,WAAW;gBACjB,QAAQ,EAAE,CAAC,EAAE,KAAK,EAAE,KAAK,EAAE,IAAI,EAAE,SAAS,EAAE,CAAC;aAC9C,CAAC;YAEF,MAAM,MAAM,GAAG,oBAAoB,CAAC,YAAY,CAC9C,QAAQ,CACa,CAAC;YAExB,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;YACxC,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,sBAAsB,CAAC,CAAC;QACvD,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC","sourcesContent":["import { expect } from '@open-wc/testing';\nimport { set_contact_language } from '../../src/flow/actions/set_contact_language';\nimport { SetContactLanguage } from '../../src/store/flow-definition';\nimport { ActionTest } from '../ActionHelper';\n\n/**\n * Test suite for the set_contact_language action configuration.\n */\ndescribe('set_contact_language action config', () => {\n const helper = new ActionTest(set_contact_language, 'set_contact_language');\n\n describe('basic properties', () => {\n helper.testBasicProperties();\n\n it('has correct name', () => {\n expect(set_contact_language.name).to.equal('Update Language');\n });\n });\n\n describe('action scenarios', () => {\n helper.testAction(\n {\n uuid: 'test-action-1',\n type: 'set_contact_language',\n language: 'eng'\n } as SetContactLanguage,\n 'english'\n );\n\n helper.testAction(\n {\n uuid: 'test-action-2',\n type: 'set_contact_language',\n language: 'fra'\n } as SetContactLanguage,\n 'french'\n );\n });\n\n describe('round-trip', () => {\n it('should extract language code from select option', () => {\n const formData = {\n uuid: 'test-uuid',\n language: [{ value: 'spa', name: 'Spanish' }]\n };\n\n const action = set_contact_language.fromFormData(\n formData\n ) as SetContactLanguage;\n\n expect(action.language).to.equal('spa');\n expect(action.type).to.equal('set_contact_language');\n });\n });\n});\n"]}
@@ -0,0 +1,28 @@
1
+ import { expect } from '@open-wc/testing';
2
+ import { set_contact_name } from '../../src/flow/actions/set_contact_name';
3
+ import { ActionTest } from '../ActionHelper';
4
+ /**
5
+ * Test suite for the set_contact_name action configuration.
6
+ */
7
+ describe('set_contact_name action config', () => {
8
+ const helper = new ActionTest(set_contact_name, 'set_contact_name');
9
+ describe('basic properties', () => {
10
+ helper.testBasicProperties();
11
+ it('has correct name', () => {
12
+ expect(set_contact_name.name).to.equal('Update Name');
13
+ });
14
+ });
15
+ describe('action scenarios', () => {
16
+ helper.testAction({
17
+ uuid: 'test-action-1',
18
+ type: 'set_contact_name',
19
+ name: 'Alice Johnson'
20
+ }, 'static-name');
21
+ helper.testAction({
22
+ uuid: 'test-action-2',
23
+ type: 'set_contact_name',
24
+ name: '@(title(input))'
25
+ }, 'expression-name');
26
+ });
27
+ });
28
+ //# sourceMappingURL=set_contact_name.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"set_contact_name.test.js","sourceRoot":"","sources":["../../../test/actions/set_contact_name.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAC1C,OAAO,EAAE,gBAAgB,EAAE,MAAM,yCAAyC,CAAC;AAE3E,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAE7C;;GAEG;AACH,QAAQ,CAAC,gCAAgC,EAAE,GAAG,EAAE;IAC9C,MAAM,MAAM,GAAG,IAAI,UAAU,CAAC,gBAAgB,EAAE,kBAAkB,CAAC,CAAC;IAEpE,QAAQ,CAAC,kBAAkB,EAAE,GAAG,EAAE;QAChC,MAAM,CAAC,mBAAmB,EAAE,CAAC;QAE7B,EAAE,CAAC,kBAAkB,EAAE,GAAG,EAAE;YAC1B,MAAM,CAAC,gBAAgB,CAAC,IAAI,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,aAAa,CAAC,CAAC;QACxD,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;IAEH,QAAQ,CAAC,kBAAkB,EAAE,GAAG,EAAE;QAChC,MAAM,CAAC,UAAU,CACf;YACE,IAAI,EAAE,eAAe;YACrB,IAAI,EAAE,kBAAkB;YACxB,IAAI,EAAE,eAAe;SACJ,EACnB,aAAa,CACd,CAAC;QAEF,MAAM,CAAC,UAAU,CACf;YACE,IAAI,EAAE,eAAe;YACrB,IAAI,EAAE,kBAAkB;YACxB,IAAI,EAAE,iBAAiB;SACN,EACnB,iBAAiB,CAClB,CAAC;IACJ,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC","sourcesContent":["import { expect } from '@open-wc/testing';\nimport { set_contact_name } from '../../src/flow/actions/set_contact_name';\nimport { SetContactName } from '../../src/store/flow-definition';\nimport { ActionTest } from '../ActionHelper';\n\n/**\n * Test suite for the set_contact_name action configuration.\n */\ndescribe('set_contact_name action config', () => {\n const helper = new ActionTest(set_contact_name, 'set_contact_name');\n\n describe('basic properties', () => {\n helper.testBasicProperties();\n\n it('has correct name', () => {\n expect(set_contact_name.name).to.equal('Update Name');\n });\n });\n\n describe('action scenarios', () => {\n helper.testAction(\n {\n uuid: 'test-action-1',\n type: 'set_contact_name',\n name: 'Alice Johnson'\n } as SetContactName,\n 'static-name'\n );\n\n helper.testAction(\n {\n uuid: 'test-action-2',\n type: 'set_contact_name',\n name: '@(title(input))'\n } as SetContactName,\n 'expression-name'\n );\n });\n});\n"]}
@@ -0,0 +1,44 @@
1
+ import { expect } from '@open-wc/testing';
2
+ import { set_contact_status } from '../../src/flow/actions/set_contact_status';
3
+ import { ActionTest } from '../ActionHelper';
4
+ /**
5
+ * Test suite for the set_contact_status action configuration.
6
+ */
7
+ describe('set_contact_status action config', () => {
8
+ const helper = new ActionTest(set_contact_status, 'set_contact_status');
9
+ describe('basic properties', () => {
10
+ helper.testBasicProperties();
11
+ it('has correct name', () => {
12
+ expect(set_contact_status.name).to.equal('Update Status');
13
+ });
14
+ });
15
+ describe('action scenarios', () => {
16
+ helper.testAction({
17
+ uuid: 'test-action-1',
18
+ type: 'set_contact_status',
19
+ status: 'active'
20
+ }, 'active');
21
+ helper.testAction({
22
+ uuid: 'test-action-2',
23
+ type: 'set_contact_status',
24
+ status: 'blocked'
25
+ }, 'blocked');
26
+ helper.testAction({
27
+ uuid: 'test-action-3',
28
+ type: 'set_contact_status',
29
+ status: 'archived'
30
+ }, 'archived');
31
+ });
32
+ describe('round-trip', () => {
33
+ it('should extract status value from select option', () => {
34
+ const formData = {
35
+ uuid: 'test-uuid',
36
+ status: [{ value: 'stopped', name: 'Stopped' }]
37
+ };
38
+ const action = set_contact_status.fromFormData(formData);
39
+ expect(action.status).to.equal('stopped');
40
+ expect(action.type).to.equal('set_contact_status');
41
+ });
42
+ });
43
+ });
44
+ //# sourceMappingURL=set_contact_status.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"set_contact_status.test.js","sourceRoot":"","sources":["../../../test/actions/set_contact_status.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAC1C,OAAO,EAAE,kBAAkB,EAAE,MAAM,2CAA2C,CAAC;AAE/E,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAE7C;;GAEG;AACH,QAAQ,CAAC,kCAAkC,EAAE,GAAG,EAAE;IAChD,MAAM,MAAM,GAAG,IAAI,UAAU,CAAC,kBAAkB,EAAE,oBAAoB,CAAC,CAAC;IAExE,QAAQ,CAAC,kBAAkB,EAAE,GAAG,EAAE;QAChC,MAAM,CAAC,mBAAmB,EAAE,CAAC;QAE7B,EAAE,CAAC,kBAAkB,EAAE,GAAG,EAAE;YAC1B,MAAM,CAAC,kBAAkB,CAAC,IAAI,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,eAAe,CAAC,CAAC;QAC5D,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;IAEH,QAAQ,CAAC,kBAAkB,EAAE,GAAG,EAAE;QAChC,MAAM,CAAC,UAAU,CACf;YACE,IAAI,EAAE,eAAe;YACrB,IAAI,EAAE,oBAAoB;YAC1B,MAAM,EAAE,QAAQ;SACG,EACrB,QAAQ,CACT,CAAC;QAEF,MAAM,CAAC,UAAU,CACf;YACE,IAAI,EAAE,eAAe;YACrB,IAAI,EAAE,oBAAoB;YAC1B,MAAM,EAAE,SAAS;SACE,EACrB,SAAS,CACV,CAAC;QAEF,MAAM,CAAC,UAAU,CACf;YACE,IAAI,EAAE,eAAe;YACrB,IAAI,EAAE,oBAAoB;YAC1B,MAAM,EAAE,UAAU;SACC,EACrB,UAAU,CACX,CAAC;IACJ,CAAC,CAAC,CAAC;IAEH,QAAQ,CAAC,YAAY,EAAE,GAAG,EAAE;QAC1B,EAAE,CAAC,gDAAgD,EAAE,GAAG,EAAE;YACxD,MAAM,QAAQ,GAAG;gBACf,IAAI,EAAE,WAAW;gBACjB,MAAM,EAAE,CAAC,EAAE,KAAK,EAAE,SAAS,EAAE,IAAI,EAAE,SAAS,EAAE,CAAC;aAChD,CAAC;YAEF,MAAM,MAAM,GAAG,kBAAkB,CAAC,YAAY,CAC5C,QAAQ,CACW,CAAC;YAEtB,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC;YAC1C,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,oBAAoB,CAAC,CAAC;QACrD,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC","sourcesContent":["import { expect } from '@open-wc/testing';\nimport { set_contact_status } from '../../src/flow/actions/set_contact_status';\nimport { SetContactStatus } from '../../src/store/flow-definition';\nimport { ActionTest } from '../ActionHelper';\n\n/**\n * Test suite for the set_contact_status action configuration.\n */\ndescribe('set_contact_status action config', () => {\n const helper = new ActionTest(set_contact_status, 'set_contact_status');\n\n describe('basic properties', () => {\n helper.testBasicProperties();\n\n it('has correct name', () => {\n expect(set_contact_status.name).to.equal('Update Status');\n });\n });\n\n describe('action scenarios', () => {\n helper.testAction(\n {\n uuid: 'test-action-1',\n type: 'set_contact_status',\n status: 'active'\n } as SetContactStatus,\n 'active'\n );\n\n helper.testAction(\n {\n uuid: 'test-action-2',\n type: 'set_contact_status',\n status: 'blocked'\n } as SetContactStatus,\n 'blocked'\n );\n\n helper.testAction(\n {\n uuid: 'test-action-3',\n type: 'set_contact_status',\n status: 'archived'\n } as SetContactStatus,\n 'archived'\n );\n });\n\n describe('round-trip', () => {\n it('should extract status value from select option', () => {\n const formData = {\n uuid: 'test-uuid',\n status: [{ value: 'stopped', name: 'Stopped' }]\n };\n\n const action = set_contact_status.fromFormData(\n formData\n ) as SetContactStatus;\n\n expect(action.status).to.equal('stopped');\n expect(action.type).to.equal('set_contact_status');\n });\n });\n});\n"]}
@@ -0,0 +1,47 @@
1
+ import { expect } from '@open-wc/testing';
2
+ import { set_run_result } from '../../src/flow/actions/set_run_result';
3
+ import { ActionTest } from '../ActionHelper';
4
+ /**
5
+ * Test suite for the set_run_result action configuration.
6
+ */
7
+ describe('set_run_result action config', () => {
8
+ const helper = new ActionTest(set_run_result, 'set_run_result');
9
+ describe('basic properties', () => {
10
+ helper.testBasicProperties();
11
+ it('has correct name', () => {
12
+ expect(set_run_result.name).to.equal('Save Flow Result');
13
+ });
14
+ });
15
+ describe('action scenarios', () => {
16
+ helper.testAction({
17
+ uuid: 'test-action-1',
18
+ type: 'set_run_result',
19
+ name: 'Score',
20
+ value: '100',
21
+ category: 'High'
22
+ }, 'with-category');
23
+ helper.testAction({
24
+ uuid: 'test-action-2',
25
+ type: 'set_run_result',
26
+ name: 'Response',
27
+ value: '@input.text',
28
+ category: ''
29
+ }, 'expression-value');
30
+ });
31
+ describe('round-trip', () => {
32
+ it('should extract name from select option array', () => {
33
+ const formData = {
34
+ uuid: 'test-uuid',
35
+ name: [{ value: 'Score', name: 'Score' }],
36
+ value: '42',
37
+ category: 'Medium'
38
+ };
39
+ const action = set_run_result.fromFormData(formData);
40
+ expect(action.name).to.equal('Score');
41
+ expect(action.value).to.equal('42');
42
+ expect(action.category).to.equal('Medium');
43
+ expect(action.type).to.equal('set_run_result');
44
+ });
45
+ });
46
+ });
47
+ //# sourceMappingURL=set_run_result.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"set_run_result.test.js","sourceRoot":"","sources":["../../../test/actions/set_run_result.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAC1C,OAAO,EAAE,cAAc,EAAE,MAAM,uCAAuC,CAAC;AAEvE,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAE7C;;GAEG;AACH,QAAQ,CAAC,8BAA8B,EAAE,GAAG,EAAE;IAC5C,MAAM,MAAM,GAAG,IAAI,UAAU,CAAC,cAAc,EAAE,gBAAgB,CAAC,CAAC;IAEhE,QAAQ,CAAC,kBAAkB,EAAE,GAAG,EAAE;QAChC,MAAM,CAAC,mBAAmB,EAAE,CAAC;QAE7B,EAAE,CAAC,kBAAkB,EAAE,GAAG,EAAE;YAC1B,MAAM,CAAC,cAAc,CAAC,IAAI,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,kBAAkB,CAAC,CAAC;QAC3D,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;IAEH,QAAQ,CAAC,kBAAkB,EAAE,GAAG,EAAE;QAChC,MAAM,CAAC,UAAU,CACf;YACE,IAAI,EAAE,eAAe;YACrB,IAAI,EAAE,gBAAgB;YACtB,IAAI,EAAE,OAAO;YACb,KAAK,EAAE,KAAK;YACZ,QAAQ,EAAE,MAAM;SACD,EACjB,eAAe,CAChB,CAAC;QAEF,MAAM,CAAC,UAAU,CACf;YACE,IAAI,EAAE,eAAe;YACrB,IAAI,EAAE,gBAAgB;YACtB,IAAI,EAAE,UAAU;YAChB,KAAK,EAAE,aAAa;YACpB,QAAQ,EAAE,EAAE;SACG,EACjB,kBAAkB,CACnB,CAAC;IACJ,CAAC,CAAC,CAAC;IAEH,QAAQ,CAAC,YAAY,EAAE,GAAG,EAAE;QAC1B,EAAE,CAAC,8CAA8C,EAAE,GAAG,EAAE;YACtD,MAAM,QAAQ,GAAG;gBACf,IAAI,EAAE,WAAW;gBACjB,IAAI,EAAE,CAAC,EAAE,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;gBACzC,KAAK,EAAE,IAAI;gBACX,QAAQ,EAAE,QAAQ;aACnB,CAAC;YAEF,MAAM,MAAM,GAAG,cAAc,CAAC,YAAY,CAAC,QAAQ,CAAiB,CAAC;YAErE,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;YACtC,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;YACpC,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC;YAC3C,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,gBAAgB,CAAC,CAAC;QACjD,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC","sourcesContent":["import { expect } from '@open-wc/testing';\nimport { set_run_result } from '../../src/flow/actions/set_run_result';\nimport { SetRunResult } from '../../src/store/flow-definition';\nimport { ActionTest } from '../ActionHelper';\n\n/**\n * Test suite for the set_run_result action configuration.\n */\ndescribe('set_run_result action config', () => {\n const helper = new ActionTest(set_run_result, 'set_run_result');\n\n describe('basic properties', () => {\n helper.testBasicProperties();\n\n it('has correct name', () => {\n expect(set_run_result.name).to.equal('Save Flow Result');\n });\n });\n\n describe('action scenarios', () => {\n helper.testAction(\n {\n uuid: 'test-action-1',\n type: 'set_run_result',\n name: 'Score',\n value: '100',\n category: 'High'\n } as SetRunResult,\n 'with-category'\n );\n\n helper.testAction(\n {\n uuid: 'test-action-2',\n type: 'set_run_result',\n name: 'Response',\n value: '@input.text',\n category: ''\n } as SetRunResult,\n 'expression-value'\n );\n });\n\n describe('round-trip', () => {\n it('should extract name from select option array', () => {\n const formData = {\n uuid: 'test-uuid',\n name: [{ value: 'Score', name: 'Score' }],\n value: '42',\n category: 'Medium'\n };\n\n const action = set_run_result.fromFormData(formData) as SetRunResult;\n\n expect(action.name).to.equal('Score');\n expect(action.value).to.equal('42');\n expect(action.category).to.equal('Medium');\n expect(action.type).to.equal('set_run_result');\n });\n });\n});\n"]}
@@ -112,5 +112,81 @@ describe('start_session action config', () => {
112
112
  expect(result.valid).to.be.true;
113
113
  expect(Object.keys(result.errors).length).to.equal(0);
114
114
  });
115
+ describe('metadata stripping', () => {
116
+ it('should strip superfluous API metadata from flow', () => {
117
+ const formData = {
118
+ uuid: 'test-uuid',
119
+ flow: [
120
+ {
121
+ uuid: 'flow-1',
122
+ name: 'Registration Flow',
123
+ type: 'message',
124
+ archived: false,
125
+ labels: [],
126
+ expires: 720,
127
+ runs: {
128
+ active: 0,
129
+ waiting: 5,
130
+ completed: 100,
131
+ interrupted: 2,
132
+ expired: 1,
133
+ failed: 0
134
+ },
135
+ results: [],
136
+ parent_refs: [],
137
+ created_on: '2024-01-01T00:00:00.000Z',
138
+ modified_on: '2024-06-15T12:00:00.000Z'
139
+ }
140
+ ],
141
+ startType: [{ value: 'create', name: 'Create a new contact' }]
142
+ };
143
+ const action = start_session.fromFormData(formData);
144
+ expect(action.flow).to.deep.equal({
145
+ uuid: 'flow-1',
146
+ name: 'Registration Flow'
147
+ });
148
+ });
149
+ it('should strip superfluous API metadata from contacts and groups', () => {
150
+ const formData = {
151
+ uuid: 'test-uuid',
152
+ flow: [{ uuid: 'flow-1', name: 'Test Flow' }],
153
+ startType: [{ value: 'manual', name: 'Select recipients manually' }],
154
+ recipients: [
155
+ {
156
+ uuid: 'contact-1',
157
+ name: 'Alice',
158
+ status: 'active',
159
+ language: 'eng',
160
+ urns: ['tel:+250788123456'],
161
+ groups: [{ uuid: 'g-1', name: 'G1' }],
162
+ fields: { age: '30' },
163
+ created_on: '2024-01-01T00:00:00.000Z',
164
+ modified_on: '2024-06-15T12:00:00.000Z',
165
+ last_seen_on: '2024-06-14T10:00:00.000Z'
166
+ },
167
+ {
168
+ uuid: 'group-1',
169
+ name: 'VIP',
170
+ group: true,
171
+ query: 'status = vip',
172
+ status: 'ready',
173
+ count: 42,
174
+ system: false
175
+ }
176
+ ]
177
+ };
178
+ const action = start_session.fromFormData(formData);
179
+ expect(action.contacts).to.have.lengthOf(1);
180
+ expect(action.contacts[0]).to.deep.equal({
181
+ uuid: 'contact-1',
182
+ name: 'Alice'
183
+ });
184
+ expect(action.groups).to.have.lengthOf(1);
185
+ expect(action.groups[0]).to.deep.equal({
186
+ uuid: 'group-1',
187
+ name: 'VIP'
188
+ });
189
+ });
190
+ });
115
191
  });
116
192
  //# sourceMappingURL=start_session.test.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"start_session.test.js","sourceRoot":"","sources":["../../../test/actions/start_session.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAC1C,OAAO,EAAE,aAAa,EAAE,MAAM,sCAAsC,CAAC;AAErE,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAE7C;;GAEG;AACH,QAAQ,CAAC,6BAA6B,EAAE,GAAG,EAAE;IAC3C,MAAM,MAAM,GAAG,IAAI,UAAU,CAAC,aAAa,EAAE,eAAe,CAAC,CAAC;IAE9D,QAAQ,CAAC,kBAAkB,EAAE,GAAG,EAAE;QAChC,MAAM,CAAC,mBAAmB,EAAE,CAAC;QAE7B,EAAE,CAAC,kBAAkB,EAAE,GAAG,EAAE;YAC1B,MAAM,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,YAAY,CAAC,CAAC;QACpD,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;IAEH,QAAQ,CAAC,kBAAkB,EAAE,GAAG,EAAE;QAChC,MAAM,CAAC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AClB,IAAI,EAAE,CAAC,EAAE,IAAI,EAAE,WAAW,EAAE,IAAI,EAAE,mBAAmB,EAAE,CAAC;YACxD,SAAS,EAAE,CAAC,EAAE,KAAK,EAAE,QAAQ,EAAE,IAAI,EAAE,sBAAsB,EAAE,CAAC;SAC/D,CAAC;QAEF,MAAM,MAAM,GAAG,aAAa,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;QAChD,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,IAAI,CAAC;QAChC,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;IACxD,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC","sourcesContent":["import { expect } from '@open-wc/testing';\nimport { start_session } from '../../src/flow/actions/start_session';\nimport { StartSession } from '../../src/store/flow-definition';\nimport { ActionTest } from '../ActionHelper';\n\n/**\n * Test suite for the start_session action configuration.\n */\ndescribe('start_session action config', () => {\n const helper = new ActionTest(start_session, 'start_session');\n\n describe('basic properties', () => {\n helper.testBasicProperties();\n\n it('has correct name', () => {\n expect(start_session.name).to.equal('Start Flow');\n });\n });\n\n describe('action scenarios', () => {\n helper.testAction(\n {\n uuid: 'test-action-1',\n type: 'start_session',\n flow: { uuid: 'flow-1', name: 'Registration Flow' },\n groups: [\n { uuid: 'group-1', name: 'Subscribers' },\n { uuid: 'group-2', name: 'Volunteers' }\n ],\n contacts: [\n { uuid: 'contact-1', name: 'Norbert Kwizera' },\n { uuid: 'contact-2', name: 'Rowan Seymour' }\n ]\n } as StartSession,\n 'groups-and-contacts'\n );\n\n helper.testAction(\n {\n uuid: 'test-action-2',\n type: 'start_session',\n flow: { uuid: 'flow-1', name: 'Welcome Flow' },\n groups: [],\n contacts: [],\n create_contact: true\n } as StartSession,\n 'create-contact'\n );\n\n helper.testAction(\n {\n uuid: 'test-action-3',\n type: 'start_session',\n flow: { uuid: 'flow-1', name: 'Survey Flow' },\n groups: [],\n contacts: [],\n contact_query: 'household_id = @fields.household_id'\n } as StartSession & { contact_query?: string },\n 'contact-query'\n );\n\n helper.testAction(\n {\n uuid: 'test-action-4',\n type: 'start_session',\n flow: { uuid: 'flow-1', name: 'Broadcast Flow' },\n groups: [\n { uuid: 'group-1', name: 'Subscribers' },\n { uuid: 'group-2', name: 'VIP Members' },\n { uuid: 'group-3', name: 'Newsletter' }\n ],\n contacts: []\n } as StartSession,\n 'groups-only'\n );\n\n helper.testAction(\n {\n uuid: 'test-action-5',\n type: 'start_session',\n flow: { uuid: 'flow-1', name: 'Personal Flow' },\n groups: [],\n contacts: [\n { uuid: 'contact-1', name: 'Alice Johnson' },\n { uuid: 'contact-2', name: 'Bob Smith' }\n ]\n } as StartSession,\n 'contacts-only'\n );\n\n helper.testAction(\n {\n uuid: 'test-action-6',\n type: 'start_session',\n flow: { uuid: 'flow-1', name: 'Mass Flow' },\n groups: [\n { uuid: 'group-1', name: 'Group 1' },\n { uuid: 'group-2', name: 'Group 2' },\n { uuid: 'group-3', name: 'Group 3' },\n { uuid: 'group-4', name: 'Group 4' },\n { uuid: 'group-5', name: 'Group 5' }\n ],\n contacts: [\n { uuid: 'contact-1', name: 'Contact 1' },\n { uuid: 'contact-2', name: 'Contact 2' }\n ]\n } as StartSession,\n 'many-recipients'\n );\n });\n\n it('validates manual selection requires recipients', async () => {\n const formData = {\n uuid: 'start-uuid',\n flow: [{ uuid: 'flow-uuid', name: 'Registration Flow' }],\n startType: [{ value: 'manual', name: 'Select contacts and groups' }],\n recipients: []\n };\n\n const result = start_session.validate(formData);\n expect(result.valid).to.be.false;\n expect(result.errors.recipients).to.equal(\n 'At least one contact or group must be selected'\n );\n });\n\n it('validates query requires contact_query value', async () => {\n const formData = {\n uuid: 'start-uuid',\n flow: [{ uuid: 'flow-uuid', name: 'Registration Flow' }],\n startType: [{ value: 'query', name: 'Query for a contact' }],\n contactQuery: ''\n };\n\n const result = start_session.validate(formData);\n expect(result.valid).to.be.false;\n expect(result.errors.contactQuery).to.equal('Contact query is required');\n });\n\n it('validates create_contact requires no additional fields', async () => {\n const formData = {\n uuid: 'start-uuid',\n flow: [{ uuid: 'flow-uuid', name: 'Registration Flow' }],\n startType: [{ value: 'create', name: 'Create a new contact' }]\n };\n\n const result = start_session.validate(formData);\n expect(result.valid).to.be.true;\n expect(Object.keys(result.errors).length).to.equal(0);\n });\n});\n"]}
1
+ {"version":3,"file":"start_session.test.js","sourceRoot":"","sources":["../../../test/actions/start_session.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAC1C,OAAO,EAAE,aAAa,EAAE,MAAM,sCAAsC,CAAC;AAErE,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAE7C;;GAEG;AACH,QAAQ,CAAC,6BAA6B,EAAE,GAAG,EAAE;IAC3C,MAAM,MAAM,GAAG,IAAI,UAAU,CAAC,aAAa,EAAE,eAAe,CAAC,CAAC;IAE9D,QAAQ,CAAC,kBAAkB,EAAE,GAAG,EAAE;QAChC,MAAM,CAAC,mBAAmB,EAAE,CAAC;QAE7B,EAAE,CAAC,kBAAkB,EAAE,GAAG,EAAE;YAC1B,MAAM,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,YAAY,CAAC,CAAC;QACpD,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;IAEH,QAAQ,CAAC,kBAAkB,EAAE,GAAG,EAAE;QAChC,MAAM,CAAC,UAAU,CACf;YACE,IAAI,EAAE,eAAe;YACrB,IAAI,EAAE,eAAe;YACrB,IAAI,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,mBAAmB,EAAE;YACnD,MAAM,EAAE;gBACN,EAAE,IAAI,EAAE,SAAS,EAAE,IAAI,EAAE,aAAa,EAAE;gBACxC,EAAE,IAA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C,CAAC,EAAE,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC;YAC1C,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC;gBACrC,IAAI,EAAE,SAAS;gBACf,IAAI,EAAE,KAAK;aACZ,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC","sourcesContent":["import { expect } from '@open-wc/testing';\nimport { start_session } from '../../src/flow/actions/start_session';\nimport { StartSession } from '../../src/store/flow-definition';\nimport { ActionTest } from '../ActionHelper';\n\n/**\n * Test suite for the start_session action configuration.\n */\ndescribe('start_session action config', () => {\n const helper = new ActionTest(start_session, 'start_session');\n\n describe('basic properties', () => {\n helper.testBasicProperties();\n\n it('has correct name', () => {\n expect(start_session.name).to.equal('Start Flow');\n });\n });\n\n describe('action scenarios', () => {\n helper.testAction(\n {\n uuid: 'test-action-1',\n type: 'start_session',\n flow: { uuid: 'flow-1', name: 'Registration Flow' },\n groups: [\n { uuid: 'group-1', name: 'Subscribers' },\n { uuid: 'group-2', name: 'Volunteers' }\n ],\n contacts: [\n { uuid: 'contact-1', name: 'Norbert Kwizera' },\n { uuid: 'contact-2', name: 'Rowan Seymour' }\n ]\n } as StartSession,\n 'groups-and-contacts'\n );\n\n helper.testAction(\n {\n uuid: 'test-action-2',\n type: 'start_session',\n flow: { uuid: 'flow-1', name: 'Welcome Flow' },\n groups: [],\n contacts: [],\n create_contact: true\n } as StartSession,\n 'create-contact'\n );\n\n helper.testAction(\n {\n uuid: 'test-action-3',\n type: 'start_session',\n flow: { uuid: 'flow-1', name: 'Survey Flow' },\n groups: [],\n contacts: [],\n contact_query: 'household_id = @fields.household_id'\n } as StartSession & { contact_query?: string },\n 'contact-query'\n );\n\n helper.testAction(\n {\n uuid: 'test-action-4',\n type: 'start_session',\n flow: { uuid: 'flow-1', name: 'Broadcast Flow' },\n groups: [\n { uuid: 'group-1', name: 'Subscribers' },\n { uuid: 'group-2', name: 'VIP Members' },\n { uuid: 'group-3', name: 'Newsletter' }\n ],\n contacts: []\n } as StartSession,\n 'groups-only'\n );\n\n helper.testAction(\n {\n uuid: 'test-action-5',\n type: 'start_session',\n flow: { uuid: 'flow-1', name: 'Personal Flow' },\n groups: [],\n contacts: [\n { uuid: 'contact-1', name: 'Alice Johnson' },\n { uuid: 'contact-2', name: 'Bob Smith' }\n ]\n } as StartSession,\n 'contacts-only'\n );\n\n helper.testAction(\n {\n uuid: 'test-action-6',\n type: 'start_session',\n flow: { uuid: 'flow-1', name: 'Mass Flow' },\n groups: [\n { uuid: 'group-1', name: 'Group 1' },\n { uuid: 'group-2', name: 'Group 2' },\n { uuid: 'group-3', name: 'Group 3' },\n { uuid: 'group-4', name: 'Group 4' },\n { uuid: 'group-5', name: 'Group 5' }\n ],\n contacts: [\n { uuid: 'contact-1', name: 'Contact 1' },\n { uuid: 'contact-2', name: 'Contact 2' }\n ]\n } as StartSession,\n 'many-recipients'\n );\n });\n\n it('validates manual selection requires recipients', async () => {\n const formData = {\n uuid: 'start-uuid',\n flow: [{ uuid: 'flow-uuid', name: 'Registration Flow' }],\n startType: [{ value: 'manual', name: 'Select contacts and groups' }],\n recipients: []\n };\n\n const result = start_session.validate(formData);\n expect(result.valid).to.be.false;\n expect(result.errors.recipients).to.equal(\n 'At least one contact or group must be selected'\n );\n });\n\n it('validates query requires contact_query value', async () => {\n const formData = {\n uuid: 'start-uuid',\n flow: [{ uuid: 'flow-uuid', name: 'Registration Flow' }],\n startType: [{ value: 'query', name: 'Query for a contact' }],\n contactQuery: ''\n };\n\n const result = start_session.validate(formData);\n expect(result.valid).to.be.false;\n expect(result.errors.contactQuery).to.equal('Contact query is required');\n });\n\n it('validates create_contact requires no additional fields', async () => {\n const formData = {\n uuid: 'start-uuid',\n flow: [{ uuid: 'flow-uuid', name: 'Registration Flow' }],\n startType: [{ value: 'create', name: 'Create a new contact' }]\n };\n\n const result = start_session.validate(formData);\n expect(result.valid).to.be.true;\n expect(Object.keys(result.errors).length).to.equal(0);\n });\n\n describe('metadata stripping', () => {\n it('should strip superfluous API metadata from flow', () => {\n const formData = {\n uuid: 'test-uuid',\n flow: [\n {\n uuid: 'flow-1',\n name: 'Registration Flow',\n type: 'message',\n archived: false,\n labels: [],\n expires: 720,\n runs: {\n active: 0,\n waiting: 5,\n completed: 100,\n interrupted: 2,\n expired: 1,\n failed: 0\n },\n results: [],\n parent_refs: [],\n created_on: '2024-01-01T00:00:00.000Z',\n modified_on: '2024-06-15T12:00:00.000Z'\n }\n ],\n startType: [{ value: 'create', name: 'Create a new contact' }]\n };\n\n const action = start_session.fromFormData(formData) as StartSession;\n\n expect(action.flow).to.deep.equal({\n uuid: 'flow-1',\n name: 'Registration Flow'\n });\n });\n\n it('should strip superfluous API metadata from contacts and groups', () => {\n const formData = {\n uuid: 'test-uuid',\n flow: [{ uuid: 'flow-1', name: 'Test Flow' }],\n startType: [{ value: 'manual', name: 'Select recipients manually' }],\n recipients: [\n {\n uuid: 'contact-1',\n name: 'Alice',\n status: 'active',\n language: 'eng',\n urns: ['tel:+250788123456'],\n groups: [{ uuid: 'g-1', name: 'G1' }],\n fields: { age: '30' },\n created_on: '2024-01-01T00:00:00.000Z',\n modified_on: '2024-06-15T12:00:00.000Z',\n last_seen_on: '2024-06-14T10:00:00.000Z'\n },\n {\n uuid: 'group-1',\n name: 'VIP',\n group: true,\n query: 'status = vip',\n status: 'ready',\n count: 42,\n system: false\n }\n ]\n };\n\n const action = start_session.fromFormData(formData) as StartSession;\n\n expect(action.contacts).to.have.lengthOf(1);\n expect(action.contacts[0]).to.deep.equal({\n uuid: 'contact-1',\n name: 'Alice'\n });\n expect(action.groups).to.have.lengthOf(1);\n expect(action.groups[0]).to.deep.equal({\n uuid: 'group-1',\n name: 'VIP'\n });\n });\n });\n});\n"]}
@@ -383,5 +383,55 @@ describe('split_by_contact_field', () => {
383
383
  expect(uiConfig.operand.name).to.equal('Facebook');
384
384
  expect(uiConfig.operand.type).to.equal('scheme');
385
385
  });
386
+ it('should handle round-trip for custom field without re-selecting', () => {
387
+ // Reproduces the bug: toUIConfig saves { id, name, type } without 'key',
388
+ // then toFormData loads it, and fromFormData must still produce a valid operand.
389
+ const originalNode = {
390
+ uuid: 'test-node-uuid',
391
+ actions: [],
392
+ router: {
393
+ type: 'switch',
394
+ cases: [
395
+ {
396
+ uuid: 'case-1',
397
+ type: 'has_text',
398
+ arguments: ['red'],
399
+ category_uuid: 'cat-1'
400
+ }
401
+ ],
402
+ categories: [
403
+ { uuid: 'cat-1', name: 'Red', exit_uuid: 'exit-1' },
404
+ { uuid: 'cat-other', name: 'Other', exit_uuid: 'exit-other' }
405
+ ],
406
+ default_category_uuid: 'cat-other',
407
+ operand: '@fields.favorite_color',
408
+ result_name: ''
409
+ },
410
+ exits: [
411
+ { uuid: 'exit-1', destination_uuid: null },
412
+ { uuid: 'exit-other', destination_uuid: null }
413
+ ]
414
+ };
415
+ // nodeUI as saved by toUIConfig - note: NO 'key' property, only 'id'
416
+ const nodeUI = {
417
+ type: 'split_by_contact_field',
418
+ position: { left: 0, top: 0 },
419
+ config: {
420
+ operand: {
421
+ id: 'favorite_color',
422
+ name: 'Favorite Color',
423
+ type: 'field'
424
+ }
425
+ }
426
+ };
427
+ // Step 1: toFormData (opening the editor)
428
+ const formData = split_by_contact_field.toFormData(originalNode, nodeUI);
429
+ // The field should have 'key' normalized from 'id'
430
+ expect(formData.field[0].key).to.equal('favorite_color');
431
+ // Step 2: fromFormData (saving without re-selecting the field)
432
+ const updatedNode = split_by_contact_field.fromFormData(formData, originalNode);
433
+ // The operand must NOT be @fields.undefined
434
+ expect(updatedNode.router.operand).to.equal('@fields.favorite_color');
435
+ });
386
436
  });
387
437
  //# sourceMappingURL=split_by_contact_field.test.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"split_by_contact_field.test.js","sourceRoot":"","sources":["../../../test/nodes/split_by_contact_field.test.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AQ,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC;QACpD,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC;QAClD,MAAM,CAAC,QAAQ,CAAC,WAAW,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,iBAAiB,CAAC,CAAC;IAC3D,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,yDAAyD,EAAE,GAAG,EAAE;QACjE,MAAM,QAAQ,GAAG;YACf,KAAK,EAAE,CAAC,EAAE,KAAK,EAAE,UAAU,EAAE,IAAI,EAAE,UAAU,EAAE,IAAI,EAAE,QAAQ,EAAE,CAAC;YAChE,KAAK,EAAE,EAAE;YACT,WAAW,EAAE,EAAE;SAChB,CAAC;QAEF,MAAM,QAAQ,GAAG,sBAAsB,CAAC,UAAW,CAAC,QAAQ,CAAC,CAAC;QAE9D,MAAM,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC;QAClC,MAAM,CAAC,QAAQ,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC;QACjD,MAAM,CAAC,QAAQ,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC;QACnD,MAAM,CAAC,QAAQ,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC;IACnD,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC","sourcesContent":["import { expect } from '@open-wc/testing';\nimport { split_by_contact_field } from '../../src/flow/nodes/split_by_contact_field';\nimport { Node } from '../../src/store/flow-definition';\n\ndescribe('split_by_contact_field', () => {\n it('should have correct configuration', () => {\n expect(split_by_contact_field.type).to.equal('split_by_contact_field');\n expect(split_by_contact_field.name).to.equal('Split by Contact Field');\n expect(split_by_contact_field.dialogSize).to.equal('large');\n });\n\n it('should have field select configuration', () => {\n const fieldConfig = split_by_contact_field.form!.field as any;\n expect(fieldConfig).to.exist;\n expect(fieldConfig.type).to.equal('select');\n expect(fieldConfig.required).to.be.true;\n expect(fieldConfig.searchable).to.be.true;\n expect(fieldConfig.endpoint).to.equal('/api/v2/fields.json');\n });\n\n it('should provide system properties and URN schemes as options', () => {\n const fieldConfig = split_by_contact_field.form!.field as any;\n const options = fieldConfig.options;\n expect(options).to.exist;\n expect(Array.isArray(options)).to.be.true;\n\n // Should have 4 system properties + multiple URN schemes\n expect(options.length).to.be.greaterThan(4);\n\n // Check that system properties are present\n const names = options.map((opt: any) => opt.name);\n expect(names).to.include('Name');\n expect(names).to.include('Language');\n expect(names).to.include('Status');\n expect(names).to.include('Channel');\n\n // Check that some URN schemes are present\n expect(names).to.include('WhatsApp Number');\n expect(names).to.include('Facebook ID');\n });\n\n it('should have rules configuration', () => {\n expect(split_by_contact_field.form!.rules).to.exist;\n expect(split_by_contact_field.form!.rules.type).to.equal('array');\n });\n\n it('should have result_name configuration', () => {\n expect(split_by_contact_field.form!.result_name).to.exist;\n expect(split_by_contact_field.form!.result_name.type).to.equal('text');\n expect(split_by_contact_field.form!.result_name.required).to.be.false;\n });\n\n it('should validate that field is required', () => {\n const result = split_by_contact_field.validate!({});\n expect(result.valid).to.be.false;\n expect(result.errors).to.have.property('field');\n });\n\n it('should validate successfully with a field', () => {\n const result = split_by_contact_field.validate!({\n field: [{ id: 'name', name: 'Name', type: 'property' }]\n });\n expect(result.valid).to.be.true;\n expect(Object.keys(result.errors).length).to.equal(0);\n });\n\n it('should transform from flow definition to form data for system property', () => {\n const node: Node = {\n uuid: 'test-node-uuid',\n actions: [],\n router: {\n type: 'switch',\n cases: [\n {\n uuid: 'case-1',\n type: 'has_text',\n arguments: ['John'],\n category_uuid: 'cat-1'\n }\n ],\n categories: [\n { uuid: 'cat-1', name: 'John', exit_uuid: 'exit-1' },\n { uuid: 'cat-other', name: 'Other', exit_uuid: 'exit-other' }\n ],\n default_category_uuid: 'cat-other',\n operand: '@contact.name',\n result_name: 'contact_name'\n },\n exits: [\n { uuid: 'exit-1', destination_uuid: null },\n { uuid: 'exit-other', destination_uuid: null }\n ]\n };\n\n const nodeUI = {\n type: 'split_by_contact_field',\n position: { left: 0, top: 0 },\n config: {\n operand: {\n id: 'name',\n name: 'Name',\n type: 'property'\n }\n }\n };\n\n const formData = split_by_contact_field.toFormData!(node, nodeUI);\n\n expect(formData.uuid).to.equal('test-node-uuid');\n expect(formData.field).to.have.lengthOf(1);\n expect(formData.field[0].id).to.equal('name');\n expect(formData.field[0].name).to.equal('Name');\n expect(formData.field[0].type).to.equal('property');\n expect(formData.result_name).to.equal('contact_name');\n });\n\n it('should transform from flow definition to form data for custom field', () => {\n const node: Node = {\n uuid: 'test-node-uuid',\n actions: [],\n router: {\n type: 'switch',\n cases: [\n {\n uuid: 'case-1',\n type: 'has_text',\n arguments: ['red'],\n category_uuid: 'cat-1'\n }\n ],\n categories: [\n { uuid: 'cat-1', name: 'Red', exit_uuid: 'exit-1' },\n { uuid: 'cat-other', name: 'Other', exit_uuid: 'exit-other' }\n ],\n default_category_uuid: 'cat-other',\n operand: '@fields.favorite_color',\n result_name: ''\n },\n exits: [\n { uuid: 'exit-1', destination_uuid: null },\n { uuid: 'exit-other', destination_uuid: null }\n ]\n };\n\n const nodeUI = {\n type: 'split_by_contact_field',\n position: { left: 0, top: 0 },\n config: {\n operand: {\n key: 'favorite_color',\n id: 'favorite_color',\n name: 'Favorite Color',\n type: 'field'\n }\n }\n };\n\n const formData = split_by_contact_field.toFormData!(node, nodeUI);\n\n expect(formData.uuid).to.equal('test-node-uuid');\n expect(formData.field).to.have.lengthOf(1);\n expect(formData.field[0].key).to.equal('favorite_color');\n expect(formData.field[0].id).to.equal('favorite_color');\n expect(formData.field[0].name).to.equal('Favorite Color');\n expect(formData.field[0].type).to.equal('field');\n expect(formData.result_name).to.equal('');\n });\n\n it('should transform from form data to flow definition for system property', () => {\n const originalNode: Node = {\n uuid: 'test-node-uuid',\n actions: [],\n router: {\n type: 'switch',\n cases: [],\n categories: [],\n default_category_uuid: '',\n operand: '@input.text'\n },\n exits: []\n };\n\n const formData = {\n uuid: 'test-node-uuid',\n field: [{ id: 'language', name: 'Language', type: 'property' }],\n rules: [\n {\n operator: 'has_only_phrase', // Requires 1 operand\n value1: 'eng',\n value2: '',\n category: 'English'\n }\n ],\n result_name: 'user_language'\n };\n\n const updatedNode = split_by_contact_field.fromFormData!(\n formData,\n originalNode\n );\n\n expect(updatedNode.router!.operand).to.equal('@contact.language');\n expect(updatedNode.router!.result_name).to.equal('user_language');\n\n // Should have at least an \"Other\" category from createRulesRouter\n expect(updatedNode.router!.categories.length).to.be.greaterThan(0);\n expect(updatedNode.exits.length).to.be.greaterThan(0);\n\n // Check if the case was created (it should be if the rule is valid)\n expect(updatedNode.router!.cases.length).to.be.greaterThan(0);\n expect(updatedNode.router!.cases[0].type).to.equal('has_only_phrase');\n expect(updatedNode.router!.cases[0].arguments).to.deep.equal(['eng']);\n });\n\n it('should transform from form data to flow definition for custom field', () => {\n const originalNode: Node = {\n uuid: 'test-node-uuid',\n actions: [],\n router: {\n type: 'switch',\n cases: [],\n categories: [],\n default_category_uuid: '',\n operand: '@input.text'\n },\n exits: []\n };\n\n const formData = {\n uuid: 'test-node-uuid',\n field: [{ key: 'age', name: 'Age', type: 'field' }],\n rules: [\n {\n operator: { value: 'has_number_gte', name: 'has a number >= to' },\n value1: '18',\n value2: '',\n category: 'Adult'\n }\n ],\n result_name: ''\n };\n\n const updatedNode = split_by_contact_field.fromFormData!(\n formData,\n originalNode\n );\n\n expect(updatedNode.router!.operand).to.equal('@fields.age');\n expect(updatedNode.router!.result_name).to.be.undefined;\n expect(updatedNode.router!.cases.length).to.equal(1);\n expect(updatedNode.router!.cases[0].type).to.equal('has_number_gte');\n });\n\n it('should preserve existing exits when updating', () => {\n const originalNode: Node = {\n uuid: 'test-node-uuid',\n actions: [],\n router: {\n type: 'switch',\n cases: [\n {\n uuid: 'case-1',\n type: 'has_text',\n arguments: ['red'],\n category_uuid: 'cat-1'\n }\n ],\n categories: [\n { uuid: 'cat-1', name: 'Red', exit_uuid: 'exit-1' },\n { uuid: 'cat-other', name: 'Other', exit_uuid: 'exit-other' }\n ],\n default_category_uuid: 'cat-other',\n operand: '@fields.color'\n },\n exits: [\n { uuid: 'exit-1', destination_uuid: 'next-node-uuid' },\n { uuid: 'exit-other', destination_uuid: null }\n ]\n };\n\n const formData = {\n uuid: 'test-node-uuid',\n field: [{ key: 'color', name: 'Color', type: 'field' }],\n rules: [\n {\n operator: { value: 'has_text', name: 'has some text' },\n value1: 'blue',\n value2: '',\n category: 'Blue'\n }\n ],\n result_name: ''\n };\n\n const updatedNode = split_by_contact_field.fromFormData!(\n formData,\n originalNode\n );\n\n // Should have at least 2 exits (Blue and Other)\n expect(updatedNode.exits.length).to.be.at.least(2);\n\n // Check that the operand is correct\n expect(updatedNode.router!.operand).to.equal('@fields.color');\n });\n\n it('should generate UI config from form data for system property', () => {\n const formData = {\n field: [{ id: 'language', name: 'Language', type: 'property' }],\n rules: [],\n result_name: ''\n };\n\n const uiConfig = split_by_contact_field.toUIConfig!(formData);\n\n expect(uiConfig.operand).to.exist;\n expect(uiConfig.operand.id).to.equal('language');\n expect(uiConfig.operand.name).to.equal('Language');\n expect(uiConfig.operand.type).to.equal('property');\n });\n\n it('should generate UI config from form data for custom field', () => {\n const formData = {\n field: [\n {\n key: 'favorite_color',\n id: 'favorite_color',\n name: 'Favorite Color',\n type: 'field'\n }\n ],\n rules: [],\n result_name: ''\n };\n\n const uiConfig = split_by_contact_field.toUIConfig!(formData);\n\n expect(uiConfig.operand).to.exist;\n expect(uiConfig.operand.id).to.equal('favorite_color');\n expect(uiConfig.operand.name).to.equal('Favorite Color');\n expect(uiConfig.operand.type).to.equal('field');\n });\n\n it('should transform from form data to flow definition for URN scheme', () => {\n const originalNode: Node = {\n uuid: 'test-node-uuid',\n actions: [],\n router: {\n type: 'switch',\n cases: [],\n categories: [],\n default_category_uuid: '',\n operand: '@input.text'\n },\n exits: []\n };\n\n const formData = {\n uuid: 'test-node-uuid',\n field: [{ value: 'facebook', name: 'Facebook', type: 'scheme' }],\n rules: [\n {\n operator: { value: 'has_only_phrase', name: 'has only the phrase' },\n value1: '123456789',\n value2: '',\n category: 'Valid Facebook ID'\n }\n ],\n result_name: 'facebook_id'\n };\n\n const updatedNode = split_by_contact_field.fromFormData!(\n formData,\n originalNode\n );\n\n // The operand should be splitting on the Facebook URN path (the ID)\n expect(updatedNode.router!.operand).to.equal(\n '@(default(urn_parts(urns.facebook).path, \"\"))'\n );\n expect(updatedNode.router!.result_name).to.equal('facebook_id');\n expect(updatedNode.router!.cases.length).to.equal(1);\n expect(updatedNode.router!.cases[0].type).to.equal('has_only_phrase');\n expect(updatedNode.router!.cases[0].arguments).to.deep.equal(['123456789']);\n });\n\n it('should transform from flow definition to form data for URN scheme', () => {\n const node: Node = {\n uuid: 'test-node-uuid',\n actions: [],\n router: {\n type: 'switch',\n cases: [\n {\n uuid: 'case-1',\n type: 'has_only_phrase',\n arguments: ['987654321'],\n category_uuid: 'cat-1'\n }\n ],\n categories: [\n { uuid: 'cat-1', name: 'Valid WhatsApp', exit_uuid: 'exit-1' },\n { uuid: 'cat-other', name: 'Other', exit_uuid: 'exit-other' }\n ],\n default_category_uuid: 'cat-other',\n operand: '@(default(urn_parts(urns.whatsapp).path, \"\"))',\n result_name: 'whatsapp_number'\n },\n exits: [\n { uuid: 'exit-1', destination_uuid: null },\n { uuid: 'exit-other', destination_uuid: null }\n ]\n };\n\n const nodeUI = {\n type: 'split_by_contact_field',\n position: { left: 0, top: 0 },\n config: {\n operand: {\n id: 'whatsapp',\n name: 'WhatsApp',\n type: 'scheme'\n }\n }\n };\n\n const formData = split_by_contact_field.toFormData!(node, nodeUI);\n\n expect(formData.uuid).to.equal('test-node-uuid');\n expect(formData.field).to.have.lengthOf(1);\n expect(formData.field[0].id).to.equal('whatsapp');\n expect(formData.field[0].name).to.equal('WhatsApp');\n expect(formData.field[0].type).to.equal('scheme');\n expect(formData.result_name).to.equal('whatsapp_number');\n });\n\n it('should generate UI config from form data for URN scheme', () => {\n const formData = {\n field: [{ value: 'facebook', name: 'Facebook', type: 'scheme' }],\n rules: [],\n result_name: ''\n };\n\n const uiConfig = split_by_contact_field.toUIConfig!(formData);\n\n expect(uiConfig.operand).to.exist;\n expect(uiConfig.operand.id).to.equal('facebook');\n expect(uiConfig.operand.name).to.equal('Facebook');\n expect(uiConfig.operand.type).to.equal('scheme');\n });\n});\n"]}
1
+ {"version":3,"file":"split_by_contact_field.test.js","sourceRoot":"","sources":["../../../test/nodes/split_by_contact_field.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAC1C,OAAO,EAAE,sBAAsB,EAAE,MAAM,6CAA6C,CAAC;AAGrF,QAAQ,CAAC,wBAAwB,EAAE,GAAG,EAAE;IACtC,EAAE,CAAC,mCAAmC,EAAE,GAAG,EAAE;QAC3C,MAAM,CAAC,sBAAsB,CAAC,IAAI,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,wBAAwB,CAAC,CAAC;QACvE,MAAM,CAAC,sBAAsB,CAAC,IAAI,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,wBAAwB,CAAC,CAAC;QACvE,MAAM,CAAC,sBAAsB,CAAC,UAAU,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;IAC9D,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,wCAAwC,EAAE,GAAG,EAAE;QAChD,MAAM,WAAW,GAAG,sBAAsB,CAAC,IAAK,CAAC,KAAY,CAAC;QAC9D,MAAM,CAAC,WAAW,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC;QAC7B,MAAM,C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AAI,EAAE,CAAC,EAAE,GAAG,EAAE,CAAC,EAAE;YAC7B,MAAM,EAAE;gBACN,OAAO,EAAE;oBACP,EAAE,EAAE,gBAAgB;oBACpB,IAAI,EAAE,gBAAgB;oBACtB,IAAI,EAAE,OAAO;iBACd;aACF;SACF,CAAC;QAEF,0CAA0C;QAC1C,MAAM,QAAQ,GAAG,sBAAsB,CAAC,UAAW,CAAC,YAAY,EAAE,MAAM,CAAC,CAAC;QAE1E,mDAAmD;QACnD,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,gBAAgB,CAAC,CAAC;QAEzD,+DAA+D;QAC/D,MAAM,WAAW,GAAG,sBAAsB,CAAC,YAAa,CACtD,QAAQ,EACR,YAAY,CACb,CAAC;QAEF,4CAA4C;QAC5C,MAAM,CAAC,WAAW,CAAC,MAAO,CAAC,OAAO,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,wBAAwB,CAAC,CAAC;IACzE,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC","sourcesContent":["import { expect } from '@open-wc/testing';\nimport { split_by_contact_field } from '../../src/flow/nodes/split_by_contact_field';\nimport { Node } from '../../src/store/flow-definition';\n\ndescribe('split_by_contact_field', () => {\n it('should have correct configuration', () => {\n expect(split_by_contact_field.type).to.equal('split_by_contact_field');\n expect(split_by_contact_field.name).to.equal('Split by Contact Field');\n expect(split_by_contact_field.dialogSize).to.equal('large');\n });\n\n it('should have field select configuration', () => {\n const fieldConfig = split_by_contact_field.form!.field as any;\n expect(fieldConfig).to.exist;\n expect(fieldConfig.type).to.equal('select');\n expect(fieldConfig.required).to.be.true;\n expect(fieldConfig.searchable).to.be.true;\n expect(fieldConfig.endpoint).to.equal('/api/v2/fields.json');\n });\n\n it('should provide system properties and URN schemes as options', () => {\n const fieldConfig = split_by_contact_field.form!.field as any;\n const options = fieldConfig.options;\n expect(options).to.exist;\n expect(Array.isArray(options)).to.be.true;\n\n // Should have 4 system properties + multiple URN schemes\n expect(options.length).to.be.greaterThan(4);\n\n // Check that system properties are present\n const names = options.map((opt: any) => opt.name);\n expect(names).to.include('Name');\n expect(names).to.include('Language');\n expect(names).to.include('Status');\n expect(names).to.include('Channel');\n\n // Check that some URN schemes are present\n expect(names).to.include('WhatsApp Number');\n expect(names).to.include('Facebook ID');\n });\n\n it('should have rules configuration', () => {\n expect(split_by_contact_field.form!.rules).to.exist;\n expect(split_by_contact_field.form!.rules.type).to.equal('array');\n });\n\n it('should have result_name configuration', () => {\n expect(split_by_contact_field.form!.result_name).to.exist;\n expect(split_by_contact_field.form!.result_name.type).to.equal('text');\n expect(split_by_contact_field.form!.result_name.required).to.be.false;\n });\n\n it('should validate that field is required', () => {\n const result = split_by_contact_field.validate!({});\n expect(result.valid).to.be.false;\n expect(result.errors).to.have.property('field');\n });\n\n it('should validate successfully with a field', () => {\n const result = split_by_contact_field.validate!({\n field: [{ id: 'name', name: 'Name', type: 'property' }]\n });\n expect(result.valid).to.be.true;\n expect(Object.keys(result.errors).length).to.equal(0);\n });\n\n it('should transform from flow definition to form data for system property', () => {\n const node: Node = {\n uuid: 'test-node-uuid',\n actions: [],\n router: {\n type: 'switch',\n cases: [\n {\n uuid: 'case-1',\n type: 'has_text',\n arguments: ['John'],\n category_uuid: 'cat-1'\n }\n ],\n categories: [\n { uuid: 'cat-1', name: 'John', exit_uuid: 'exit-1' },\n { uuid: 'cat-other', name: 'Other', exit_uuid: 'exit-other' }\n ],\n default_category_uuid: 'cat-other',\n operand: '@contact.name',\n result_name: 'contact_name'\n },\n exits: [\n { uuid: 'exit-1', destination_uuid: null },\n { uuid: 'exit-other', destination_uuid: null }\n ]\n };\n\n const nodeUI = {\n type: 'split_by_contact_field',\n position: { left: 0, top: 0 },\n config: {\n operand: {\n id: 'name',\n name: 'Name',\n type: 'property'\n }\n }\n };\n\n const formData = split_by_contact_field.toFormData!(node, nodeUI);\n\n expect(formData.uuid).to.equal('test-node-uuid');\n expect(formData.field).to.have.lengthOf(1);\n expect(formData.field[0].id).to.equal('name');\n expect(formData.field[0].name).to.equal('Name');\n expect(formData.field[0].type).to.equal('property');\n expect(formData.result_name).to.equal('contact_name');\n });\n\n it('should transform from flow definition to form data for custom field', () => {\n const node: Node = {\n uuid: 'test-node-uuid',\n actions: [],\n router: {\n type: 'switch',\n cases: [\n {\n uuid: 'case-1',\n type: 'has_text',\n arguments: ['red'],\n category_uuid: 'cat-1'\n }\n ],\n categories: [\n { uuid: 'cat-1', name: 'Red', exit_uuid: 'exit-1' },\n { uuid: 'cat-other', name: 'Other', exit_uuid: 'exit-other' }\n ],\n default_category_uuid: 'cat-other',\n operand: '@fields.favorite_color',\n result_name: ''\n },\n exits: [\n { uuid: 'exit-1', destination_uuid: null },\n { uuid: 'exit-other', destination_uuid: null }\n ]\n };\n\n const nodeUI = {\n type: 'split_by_contact_field',\n position: { left: 0, top: 0 },\n config: {\n operand: {\n key: 'favorite_color',\n id: 'favorite_color',\n name: 'Favorite Color',\n type: 'field'\n }\n }\n };\n\n const formData = split_by_contact_field.toFormData!(node, nodeUI);\n\n expect(formData.uuid).to.equal('test-node-uuid');\n expect(formData.field).to.have.lengthOf(1);\n expect(formData.field[0].key).to.equal('favorite_color');\n expect(formData.field[0].id).to.equal('favorite_color');\n expect(formData.field[0].name).to.equal('Favorite Color');\n expect(formData.field[0].type).to.equal('field');\n expect(formData.result_name).to.equal('');\n });\n\n it('should transform from form data to flow definition for system property', () => {\n const originalNode: Node = {\n uuid: 'test-node-uuid',\n actions: [],\n router: {\n type: 'switch',\n cases: [],\n categories: [],\n default_category_uuid: '',\n operand: '@input.text'\n },\n exits: []\n };\n\n const formData = {\n uuid: 'test-node-uuid',\n field: [{ id: 'language', name: 'Language', type: 'property' }],\n rules: [\n {\n operator: 'has_only_phrase', // Requires 1 operand\n value1: 'eng',\n value2: '',\n category: 'English'\n }\n ],\n result_name: 'user_language'\n };\n\n const updatedNode = split_by_contact_field.fromFormData!(\n formData,\n originalNode\n );\n\n expect(updatedNode.router!.operand).to.equal('@contact.language');\n expect(updatedNode.router!.result_name).to.equal('user_language');\n\n // Should have at least an \"Other\" category from createRulesRouter\n expect(updatedNode.router!.categories.length).to.be.greaterThan(0);\n expect(updatedNode.exits.length).to.be.greaterThan(0);\n\n // Check if the case was created (it should be if the rule is valid)\n expect(updatedNode.router!.cases.length).to.be.greaterThan(0);\n expect(updatedNode.router!.cases[0].type).to.equal('has_only_phrase');\n expect(updatedNode.router!.cases[0].arguments).to.deep.equal(['eng']);\n });\n\n it('should transform from form data to flow definition for custom field', () => {\n const originalNode: Node = {\n uuid: 'test-node-uuid',\n actions: [],\n router: {\n type: 'switch',\n cases: [],\n categories: [],\n default_category_uuid: '',\n operand: '@input.text'\n },\n exits: []\n };\n\n const formData = {\n uuid: 'test-node-uuid',\n field: [{ key: 'age', name: 'Age', type: 'field' }],\n rules: [\n {\n operator: { value: 'has_number_gte', name: 'has a number >= to' },\n value1: '18',\n value2: '',\n category: 'Adult'\n }\n ],\n result_name: ''\n };\n\n const updatedNode = split_by_contact_field.fromFormData!(\n formData,\n originalNode\n );\n\n expect(updatedNode.router!.operand).to.equal('@fields.age');\n expect(updatedNode.router!.result_name).to.be.undefined;\n expect(updatedNode.router!.cases.length).to.equal(1);\n expect(updatedNode.router!.cases[0].type).to.equal('has_number_gte');\n });\n\n it('should preserve existing exits when updating', () => {\n const originalNode: Node = {\n uuid: 'test-node-uuid',\n actions: [],\n router: {\n type: 'switch',\n cases: [\n {\n uuid: 'case-1',\n type: 'has_text',\n arguments: ['red'],\n category_uuid: 'cat-1'\n }\n ],\n categories: [\n { uuid: 'cat-1', name: 'Red', exit_uuid: 'exit-1' },\n { uuid: 'cat-other', name: 'Other', exit_uuid: 'exit-other' }\n ],\n default_category_uuid: 'cat-other',\n operand: '@fields.color'\n },\n exits: [\n { uuid: 'exit-1', destination_uuid: 'next-node-uuid' },\n { uuid: 'exit-other', destination_uuid: null }\n ]\n };\n\n const formData = {\n uuid: 'test-node-uuid',\n field: [{ key: 'color', name: 'Color', type: 'field' }],\n rules: [\n {\n operator: { value: 'has_text', name: 'has some text' },\n value1: 'blue',\n value2: '',\n category: 'Blue'\n }\n ],\n result_name: ''\n };\n\n const updatedNode = split_by_contact_field.fromFormData!(\n formData,\n originalNode\n );\n\n // Should have at least 2 exits (Blue and Other)\n expect(updatedNode.exits.length).to.be.at.least(2);\n\n // Check that the operand is correct\n expect(updatedNode.router!.operand).to.equal('@fields.color');\n });\n\n it('should generate UI config from form data for system property', () => {\n const formData = {\n field: [{ id: 'language', name: 'Language', type: 'property' }],\n rules: [],\n result_name: ''\n };\n\n const uiConfig = split_by_contact_field.toUIConfig!(formData);\n\n expect(uiConfig.operand).to.exist;\n expect(uiConfig.operand.id).to.equal('language');\n expect(uiConfig.operand.name).to.equal('Language');\n expect(uiConfig.operand.type).to.equal('property');\n });\n\n it('should generate UI config from form data for custom field', () => {\n const formData = {\n field: [\n {\n key: 'favorite_color',\n id: 'favorite_color',\n name: 'Favorite Color',\n type: 'field'\n }\n ],\n rules: [],\n result_name: ''\n };\n\n const uiConfig = split_by_contact_field.toUIConfig!(formData);\n\n expect(uiConfig.operand).to.exist;\n expect(uiConfig.operand.id).to.equal('favorite_color');\n expect(uiConfig.operand.name).to.equal('Favorite Color');\n expect(uiConfig.operand.type).to.equal('field');\n });\n\n it('should transform from form data to flow definition for URN scheme', () => {\n const originalNode: Node = {\n uuid: 'test-node-uuid',\n actions: [],\n router: {\n type: 'switch',\n cases: [],\n categories: [],\n default_category_uuid: '',\n operand: '@input.text'\n },\n exits: []\n };\n\n const formData = {\n uuid: 'test-node-uuid',\n field: [{ value: 'facebook', name: 'Facebook', type: 'scheme' }],\n rules: [\n {\n operator: { value: 'has_only_phrase', name: 'has only the phrase' },\n value1: '123456789',\n value2: '',\n category: 'Valid Facebook ID'\n }\n ],\n result_name: 'facebook_id'\n };\n\n const updatedNode = split_by_contact_field.fromFormData!(\n formData,\n originalNode\n );\n\n // The operand should be splitting on the Facebook URN path (the ID)\n expect(updatedNode.router!.operand).to.equal(\n '@(default(urn_parts(urns.facebook).path, \"\"))'\n );\n expect(updatedNode.router!.result_name).to.equal('facebook_id');\n expect(updatedNode.router!.cases.length).to.equal(1);\n expect(updatedNode.router!.cases[0].type).to.equal('has_only_phrase');\n expect(updatedNode.router!.cases[0].arguments).to.deep.equal(['123456789']);\n });\n\n it('should transform from flow definition to form data for URN scheme', () => {\n const node: Node = {\n uuid: 'test-node-uuid',\n actions: [],\n router: {\n type: 'switch',\n cases: [\n {\n uuid: 'case-1',\n type: 'has_only_phrase',\n arguments: ['987654321'],\n category_uuid: 'cat-1'\n }\n ],\n categories: [\n { uuid: 'cat-1', name: 'Valid WhatsApp', exit_uuid: 'exit-1' },\n { uuid: 'cat-other', name: 'Other', exit_uuid: 'exit-other' }\n ],\n default_category_uuid: 'cat-other',\n operand: '@(default(urn_parts(urns.whatsapp).path, \"\"))',\n result_name: 'whatsapp_number'\n },\n exits: [\n { uuid: 'exit-1', destination_uuid: null },\n { uuid: 'exit-other', destination_uuid: null }\n ]\n };\n\n const nodeUI = {\n type: 'split_by_contact_field',\n position: { left: 0, top: 0 },\n config: {\n operand: {\n id: 'whatsapp',\n name: 'WhatsApp',\n type: 'scheme'\n }\n }\n };\n\n const formData = split_by_contact_field.toFormData!(node, nodeUI);\n\n expect(formData.uuid).to.equal('test-node-uuid');\n expect(formData.field).to.have.lengthOf(1);\n expect(formData.field[0].id).to.equal('whatsapp');\n expect(formData.field[0].name).to.equal('WhatsApp');\n expect(formData.field[0].type).to.equal('scheme');\n expect(formData.result_name).to.equal('whatsapp_number');\n });\n\n it('should generate UI config from form data for URN scheme', () => {\n const formData = {\n field: [{ value: 'facebook', name: 'Facebook', type: 'scheme' }],\n rules: [],\n result_name: ''\n };\n\n const uiConfig = split_by_contact_field.toUIConfig!(formData);\n\n expect(uiConfig.operand).to.exist;\n expect(uiConfig.operand.id).to.equal('facebook');\n expect(uiConfig.operand.name).to.equal('Facebook');\n expect(uiConfig.operand.type).to.equal('scheme');\n });\n\n it('should handle round-trip for custom field without re-selecting', () => {\n // Reproduces the bug: toUIConfig saves { id, name, type } without 'key',\n // then toFormData loads it, and fromFormData must still produce a valid operand.\n const originalNode: Node = {\n uuid: 'test-node-uuid',\n actions: [],\n router: {\n type: 'switch',\n cases: [\n {\n uuid: 'case-1',\n type: 'has_text',\n arguments: ['red'],\n category_uuid: 'cat-1'\n }\n ],\n categories: [\n { uuid: 'cat-1', name: 'Red', exit_uuid: 'exit-1' },\n { uuid: 'cat-other', name: 'Other', exit_uuid: 'exit-other' }\n ],\n default_category_uuid: 'cat-other',\n operand: '@fields.favorite_color',\n result_name: ''\n },\n exits: [\n { uuid: 'exit-1', destination_uuid: null },\n { uuid: 'exit-other', destination_uuid: null }\n ]\n };\n\n // nodeUI as saved by toUIConfig - note: NO 'key' property, only 'id'\n const nodeUI = {\n type: 'split_by_contact_field',\n position: { left: 0, top: 0 },\n config: {\n operand: {\n id: 'favorite_color',\n name: 'Favorite Color',\n type: 'field'\n }\n }\n };\n\n // Step 1: toFormData (opening the editor)\n const formData = split_by_contact_field.toFormData!(originalNode, nodeUI);\n\n // The field should have 'key' normalized from 'id'\n expect(formData.field[0].key).to.equal('favorite_color');\n\n // Step 2: fromFormData (saving without re-selecting the field)\n const updatedNode = split_by_contact_field.fromFormData!(\n formData,\n originalNode\n );\n\n // The operand must NOT be @fields.undefined\n expect(updatedNode.router!.operand).to.equal('@fields.favorite_color');\n });\n});\n"]}