@nyaruka/temba-components 0.131.0 → 0.131.2
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.
- package/.github/workflows/publish.yml +4 -1
- package/CHANGELOG.md +67 -1
- package/demo/data/flows/food-order.json +2 -2
- package/demo/data/flows/sample-flow.json +74 -125
- package/dist/static/svg/index.svg +1 -1
- package/dist/temba-components.js +1156 -619
- package/dist/temba-components.js.map +1 -1
- package/out-tsc/src/Icons.js +4 -1
- package/out-tsc/src/Icons.js.map +1 -1
- package/out-tsc/src/events.js.map +1 -1
- package/out-tsc/src/flow/CanvasMenu.js +200 -0
- package/out-tsc/src/flow/CanvasMenu.js.map +1 -0
- package/out-tsc/src/flow/CanvasNode.js +327 -19
- package/out-tsc/src/flow/CanvasNode.js.map +1 -1
- package/out-tsc/src/flow/Editor.js +562 -66
- package/out-tsc/src/flow/Editor.js.map +1 -1
- package/out-tsc/src/flow/NodeEditor.js +240 -93
- package/out-tsc/src/flow/NodeEditor.js.map +1 -1
- package/out-tsc/src/flow/NodeTypeSelector.js +499 -0
- package/out-tsc/src/flow/NodeTypeSelector.js.map +1 -0
- package/out-tsc/src/flow/actions/add_contact_groups.js +3 -3
- package/out-tsc/src/flow/actions/add_contact_groups.js.map +1 -1
- package/out-tsc/src/flow/actions/add_contact_urn.js +62 -4
- package/out-tsc/src/flow/actions/add_contact_urn.js.map +1 -1
- package/out-tsc/src/flow/actions/add_input_labels.js +3 -3
- package/out-tsc/src/flow/actions/add_input_labels.js.map +1 -1
- package/out-tsc/src/flow/actions/play_audio.js +2 -2
- package/out-tsc/src/flow/actions/play_audio.js.map +1 -1
- package/out-tsc/src/flow/actions/remove_contact_groups.js +6 -5
- package/out-tsc/src/flow/actions/remove_contact_groups.js.map +1 -1
- package/out-tsc/src/flow/actions/request_optin.js +2 -2
- package/out-tsc/src/flow/actions/request_optin.js.map +1 -1
- package/out-tsc/src/flow/actions/say_msg.js +2 -2
- package/out-tsc/src/flow/actions/say_msg.js.map +1 -1
- package/out-tsc/src/flow/actions/send_broadcast.js +76 -23
- package/out-tsc/src/flow/actions/send_broadcast.js.map +1 -1
- package/out-tsc/src/flow/actions/send_email.js +4 -5
- package/out-tsc/src/flow/actions/send_email.js.map +1 -1
- package/out-tsc/src/flow/actions/send_msg.js +9 -19
- package/out-tsc/src/flow/actions/send_msg.js.map +1 -1
- package/out-tsc/src/flow/actions/set_contact_channel.js +5 -9
- package/out-tsc/src/flow/actions/set_contact_channel.js.map +1 -1
- package/out-tsc/src/flow/actions/set_contact_field.js +19 -20
- package/out-tsc/src/flow/actions/set_contact_field.js.map +1 -1
- package/out-tsc/src/flow/actions/set_contact_language.js +2 -2
- package/out-tsc/src/flow/actions/set_contact_language.js.map +1 -1
- package/out-tsc/src/flow/actions/set_contact_name.js +2 -12
- package/out-tsc/src/flow/actions/set_contact_name.js.map +1 -1
- package/out-tsc/src/flow/actions/set_contact_status.js +2 -2
- package/out-tsc/src/flow/actions/set_contact_status.js.map +1 -1
- package/out-tsc/src/flow/actions/set_run_result.js +3 -3
- package/out-tsc/src/flow/actions/set_run_result.js.map +1 -1
- package/out-tsc/src/flow/actions/start_session.js +180 -6
- package/out-tsc/src/flow/actions/start_session.js.map +1 -1
- package/out-tsc/src/flow/config.js +11 -15
- package/out-tsc/src/flow/config.js.map +1 -1
- package/out-tsc/src/flow/currencies.js +45 -0
- package/out-tsc/src/flow/currencies.js.map +1 -0
- package/out-tsc/src/flow/nodes/shared-rules.js +257 -0
- package/out-tsc/src/flow/nodes/shared-rules.js.map +1 -0
- package/out-tsc/src/flow/nodes/shared.js +17 -0
- package/out-tsc/src/flow/nodes/shared.js.map +1 -0
- package/out-tsc/src/flow/nodes/split_by_airtime.js +205 -5
- package/out-tsc/src/flow/nodes/split_by_airtime.js.map +1 -1
- package/out-tsc/src/flow/nodes/split_by_contact_field.js +147 -3
- package/out-tsc/src/flow/nodes/split_by_contact_field.js.map +1 -1
- package/out-tsc/src/flow/nodes/split_by_expression.js +68 -2
- package/out-tsc/src/flow/nodes/split_by_expression.js.map +1 -1
- package/out-tsc/src/flow/nodes/split_by_groups.js +12 -9
- package/out-tsc/src/flow/nodes/split_by_groups.js.map +1 -1
- package/out-tsc/src/flow/nodes/split_by_intent.js +7 -0
- package/out-tsc/src/flow/nodes/split_by_intent.js.map +1 -0
- package/out-tsc/src/flow/nodes/split_by_llm.js +3 -2
- package/out-tsc/src/flow/nodes/split_by_llm.js.map +1 -1
- package/out-tsc/src/flow/nodes/split_by_llm_categorize.js +2 -2
- package/out-tsc/src/flow/nodes/split_by_llm_categorize.js.map +1 -1
- package/out-tsc/src/flow/nodes/split_by_random.js +3 -3
- package/out-tsc/src/flow/nodes/split_by_random.js.map +1 -1
- package/out-tsc/src/flow/nodes/split_by_resthook.js +108 -0
- package/out-tsc/src/flow/nodes/split_by_resthook.js.map +1 -0
- package/out-tsc/src/flow/nodes/split_by_run_result.js +206 -3
- package/out-tsc/src/flow/nodes/split_by_run_result.js.map +1 -1
- package/out-tsc/src/flow/nodes/split_by_scheme.js +153 -2
- package/out-tsc/src/flow/nodes/split_by_scheme.js.map +1 -1
- package/out-tsc/src/flow/nodes/split_by_subflow.js +6 -4
- package/out-tsc/src/flow/nodes/split_by_subflow.js.map +1 -1
- package/out-tsc/src/flow/nodes/split_by_ticket.js +3 -2
- package/out-tsc/src/flow/nodes/split_by_ticket.js.map +1 -1
- package/out-tsc/src/flow/nodes/split_by_webhook.js +3 -2
- package/out-tsc/src/flow/nodes/split_by_webhook.js.map +1 -1
- package/out-tsc/src/flow/nodes/wait_for_audio.js +2 -2
- package/out-tsc/src/flow/nodes/wait_for_audio.js.map +1 -1
- package/out-tsc/src/flow/nodes/wait_for_digits.js +2 -2
- package/out-tsc/src/flow/nodes/wait_for_digits.js.map +1 -1
- package/out-tsc/src/flow/nodes/wait_for_image.js +2 -2
- package/out-tsc/src/flow/nodes/wait_for_image.js.map +1 -1
- package/out-tsc/src/flow/nodes/wait_for_location.js +2 -2
- package/out-tsc/src/flow/nodes/wait_for_location.js.map +1 -1
- package/out-tsc/src/flow/nodes/wait_for_menu.js +2 -2
- package/out-tsc/src/flow/nodes/wait_for_menu.js.map +1 -1
- package/out-tsc/src/flow/nodes/wait_for_response.js +32 -567
- package/out-tsc/src/flow/nodes/wait_for_response.js.map +1 -1
- package/out-tsc/src/flow/nodes/wait_for_video.js +2 -2
- package/out-tsc/src/flow/nodes/wait_for_video.js.map +1 -1
- package/out-tsc/src/flow/types.js +71 -12
- package/out-tsc/src/flow/types.js.map +1 -1
- package/out-tsc/src/flow/utils.js +101 -14
- package/out-tsc/src/flow/utils.js.map +1 -1
- package/out-tsc/src/form/ContactSearch.js +1 -1
- package/out-tsc/src/form/ContactSearch.js.map +1 -1
- package/out-tsc/src/form/FieldRenderer.js +2 -4
- package/out-tsc/src/form/FieldRenderer.js.map +1 -1
- package/out-tsc/src/interfaces.js +3 -0
- package/out-tsc/src/interfaces.js.map +1 -1
- package/out-tsc/src/list/SortableList.js +98 -33
- package/out-tsc/src/list/SortableList.js.map +1 -1
- package/out-tsc/src/live/ContactChat.js +15 -18
- package/out-tsc/src/live/ContactChat.js.map +1 -1
- package/out-tsc/src/store/AppState.js +53 -0
- package/out-tsc/src/store/AppState.js.map +1 -1
- package/out-tsc/src/utils.js +254 -13
- package/out-tsc/src/utils.js.map +1 -1
- package/out-tsc/temba-modules.js +4 -0
- package/out-tsc/temba-modules.js.map +1 -1
- package/out-tsc/test/ActionHelper.js +3 -3
- package/out-tsc/test/ActionHelper.js.map +1 -1
- package/out-tsc/test/NodeHelper.js +6 -3
- package/out-tsc/test/NodeHelper.js.map +1 -1
- package/out-tsc/test/actions/add_contact_urn.test.js +202 -0
- package/out-tsc/test/actions/add_contact_urn.test.js.map +1 -0
- package/out-tsc/test/actions/send_broadcast.test.js +148 -0
- package/out-tsc/test/actions/send_broadcast.test.js.map +1 -0
- package/out-tsc/test/actions/send_email.test.js +17 -23
- package/out-tsc/test/actions/send_email.test.js.map +1 -1
- package/out-tsc/test/actions/send_msg.test.js +33 -15
- package/out-tsc/test/actions/send_msg.test.js.map +1 -1
- package/out-tsc/test/actions/start_session.test.js +116 -0
- package/out-tsc/test/actions/start_session.test.js.map +1 -0
- package/out-tsc/test/nodes/split_by_airtime.test.js +604 -0
- package/out-tsc/test/nodes/split_by_airtime.test.js.map +1 -0
- package/out-tsc/test/nodes/split_by_contact_field.test.js +387 -0
- package/out-tsc/test/nodes/split_by_contact_field.test.js.map +1 -0
- package/out-tsc/test/nodes/split_by_expression.test.js +614 -0
- package/out-tsc/test/nodes/split_by_expression.test.js.map +1 -0
- package/out-tsc/test/nodes/split_by_random.test.js +3 -3
- package/out-tsc/test/nodes/split_by_random.test.js.map +1 -1
- package/out-tsc/test/nodes/split_by_resthook.test.js +337 -0
- package/out-tsc/test/nodes/split_by_resthook.test.js.map +1 -0
- package/out-tsc/test/nodes/split_by_run_result.test.js +920 -0
- package/out-tsc/test/nodes/split_by_run_result.test.js.map +1 -0
- package/out-tsc/test/nodes/split_by_scheme.test.js +399 -0
- package/out-tsc/test/nodes/split_by_scheme.test.js.map +1 -0
- package/out-tsc/test/nodes/split_by_subflow.test.js +333 -0
- package/out-tsc/test/nodes/split_by_subflow.test.js.map +1 -0
- package/out-tsc/test/nodes/wait_for_digits.test.js +2 -2
- package/out-tsc/test/nodes/wait_for_digits.test.js.map +1 -1
- package/out-tsc/test/nodes/wait_for_response.test.js +2 -1
- package/out-tsc/test/nodes/wait_for_response.test.js.map +1 -1
- package/out-tsc/test/temba-action-drag-between-nodes.test.js +252 -0
- package/out-tsc/test/temba-action-drag-between-nodes.test.js.map +1 -0
- package/out-tsc/test/temba-canvas-menu.test.js +122 -0
- package/out-tsc/test/temba-canvas-menu.test.js.map +1 -0
- package/out-tsc/test/temba-flow-editor-node.test.js +85 -2
- package/out-tsc/test/temba-flow-editor-node.test.js.map +1 -1
- package/out-tsc/test/temba-flow-editor.test.js +7 -8
- package/out-tsc/test/temba-flow-editor.test.js.map +1 -1
- package/out-tsc/test/temba-node-editor.test.js +3 -1
- package/out-tsc/test/temba-node-editor.test.js.map +1 -1
- package/out-tsc/test/temba-node-type-selector.test.js +115 -0
- package/out-tsc/test/temba-node-type-selector.test.js.map +1 -0
- package/out-tsc/test/temba-omnibox.test.js +2 -1
- package/out-tsc/test/temba-omnibox.test.js.map +1 -1
- package/out-tsc/test/temba-sortable-list.test.js +51 -0
- package/out-tsc/test/temba-sortable-list.test.js.map +1 -1
- package/out-tsc/test/temba-utils-index.test.js +1 -27
- package/out-tsc/test/temba-utils-index.test.js.map +1 -1
- package/out-tsc/test/utils.test.js +2 -0
- package/out-tsc/test/utils.test.js.map +1 -1
- package/package.json +2 -1
- package/screenshots/truth/actions/add_contact_groups/editor/descriptive-group-names.png +0 -0
- package/screenshots/truth/actions/add_contact_groups/editor/long-group-names.png +0 -0
- package/screenshots/truth/actions/add_contact_groups/editor/many-groups.png +0 -0
- package/screenshots/truth/actions/add_contact_groups/editor/multiple-groups.png +0 -0
- package/screenshots/truth/actions/add_contact_groups/editor/single-group.png +0 -0
- package/screenshots/truth/actions/add_contact_groups/render/descriptive-group-names.png +0 -0
- package/screenshots/truth/actions/add_contact_groups/render/long-group-names.png +0 -0
- package/screenshots/truth/actions/add_contact_groups/render/many-groups.png +0 -0
- package/screenshots/truth/actions/add_contact_groups/render/multiple-groups.png +0 -0
- package/screenshots/truth/actions/add_contact_groups/render/single-group.png +0 -0
- package/screenshots/truth/actions/add_contact_urn/editor/expression-facebook.png +0 -0
- package/screenshots/truth/actions/add_contact_urn/editor/expression-phone.png +0 -0
- package/screenshots/truth/actions/add_contact_urn/editor/facebook-id.png +0 -0
- package/screenshots/truth/actions/add_contact_urn/editor/instagram-handle.png +0 -0
- package/screenshots/truth/actions/add_contact_urn/editor/line-id.png +0 -0
- package/screenshots/truth/actions/add_contact_urn/editor/phone-number.png +0 -0
- package/screenshots/truth/actions/add_contact_urn/editor/telegram-id.png +0 -0
- package/screenshots/truth/actions/add_contact_urn/editor/viber-id.png +0 -0
- package/screenshots/truth/actions/add_contact_urn/editor/wechat-id.png +0 -0
- package/screenshots/truth/actions/add_contact_urn/editor/whatsapp.png +0 -0
- package/screenshots/truth/actions/add_contact_urn/render/expression-facebook.png +0 -0
- package/screenshots/truth/actions/add_contact_urn/render/expression-phone.png +0 -0
- package/screenshots/truth/actions/add_contact_urn/render/facebook-id.png +0 -0
- package/screenshots/truth/actions/add_contact_urn/render/instagram-handle.png +0 -0
- package/screenshots/truth/actions/add_contact_urn/render/line-id.png +0 -0
- package/screenshots/truth/actions/add_contact_urn/render/phone-number.png +0 -0
- package/screenshots/truth/actions/add_contact_urn/render/telegram-id.png +0 -0
- package/screenshots/truth/actions/add_contact_urn/render/viber-id.png +0 -0
- package/screenshots/truth/actions/add_contact_urn/render/wechat-id.png +0 -0
- package/screenshots/truth/actions/add_contact_urn/render/whatsapp.png +0 -0
- package/screenshots/truth/actions/remove_contact_groups/editor/cleanup-groups.png +0 -0
- package/screenshots/truth/actions/remove_contact_groups/editor/long-descriptive-group-names.png +0 -0
- package/screenshots/truth/actions/remove_contact_groups/editor/many-groups.png +0 -0
- package/screenshots/truth/actions/remove_contact_groups/editor/multiple-groups.png +0 -0
- package/screenshots/truth/actions/remove_contact_groups/editor/remove-from-all-groups.png +0 -0
- package/screenshots/truth/actions/remove_contact_groups/editor/single-group.png +0 -0
- package/screenshots/truth/actions/remove_contact_groups/render/cleanup-groups.png +0 -0
- package/screenshots/truth/actions/remove_contact_groups/render/long-descriptive-group-names.png +0 -0
- package/screenshots/truth/actions/remove_contact_groups/render/many-groups.png +0 -0
- package/screenshots/truth/actions/remove_contact_groups/render/multiple-groups.png +0 -0
- package/screenshots/truth/actions/remove_contact_groups/render/remove-from-all-groups.png +0 -0
- package/screenshots/truth/actions/remove_contact_groups/render/single-group.png +0 -0
- package/screenshots/truth/actions/send_broadcast/editor/contacts-only.png +0 -0
- package/screenshots/truth/actions/send_broadcast/editor/groups-and-contacts.png +0 -0
- package/screenshots/truth/actions/send_broadcast/editor/groups-only.png +0 -0
- package/screenshots/truth/actions/send_broadcast/editor/many-groups.png +0 -0
- package/screenshots/truth/actions/send_broadcast/editor/multiline-text.png +0 -0
- package/screenshots/truth/actions/send_broadcast/editor/with-attachments.png +0 -0
- package/screenshots/truth/actions/send_broadcast/render/contacts-only.png +0 -0
- package/screenshots/truth/actions/send_broadcast/render/groups-and-contacts.png +0 -0
- package/screenshots/truth/actions/send_broadcast/render/groups-only.png +0 -0
- package/screenshots/truth/actions/send_broadcast/render/many-groups.png +0 -0
- package/screenshots/truth/actions/send_broadcast/render/multiline-text.png +0 -0
- package/screenshots/truth/actions/send_broadcast/render/with-attachments.png +0 -0
- package/screenshots/truth/actions/send_email/editor/complex-business-email.png +0 -0
- package/screenshots/truth/actions/send_email/editor/empty-body.png +0 -0
- package/screenshots/truth/actions/send_email/editor/empty-subject.png +0 -0
- package/screenshots/truth/actions/send_email/editor/long-subject.png +0 -0
- package/screenshots/truth/actions/send_email/editor/multiline-body.png +0 -0
- package/screenshots/truth/actions/send_email/editor/multiple-recipients.png +0 -0
- package/screenshots/truth/actions/send_email/editor/simple-email.png +0 -0
- package/screenshots/truth/actions/send_email/editor/with-expressions.png +0 -0
- package/screenshots/truth/actions/send_email/render/complex-business-email.png +0 -0
- package/screenshots/truth/actions/send_email/render/empty-body.png +0 -0
- package/screenshots/truth/actions/send_email/render/empty-subject.png +0 -0
- package/screenshots/truth/actions/send_email/render/long-subject.png +0 -0
- package/screenshots/truth/actions/send_email/render/multiline-body.png +0 -0
- package/screenshots/truth/actions/send_email/render/multiple-recipients.png +0 -0
- package/screenshots/truth/actions/send_email/render/simple-email.png +0 -0
- package/screenshots/truth/actions/send_email/render/with-expressions.png +0 -0
- package/screenshots/truth/actions/send_msg/editor/long-quick-replies.png +0 -0
- package/screenshots/truth/actions/send_msg/editor/multiline-text-with-replies.png +0 -0
- package/screenshots/truth/actions/send_msg/editor/simple-text.png +0 -0
- package/screenshots/truth/actions/send_msg/editor/text-with-linebreaks.png +0 -0
- package/screenshots/truth/actions/send_msg/editor/text-with-many-quick-replies.png +0 -0
- package/screenshots/truth/actions/send_msg/editor/text-with-quick-replies.png +0 -0
- package/screenshots/truth/actions/send_msg/editor/text-without-quick-replies.png +0 -0
- package/screenshots/truth/actions/send_msg/render/long-quick-replies.png +0 -0
- package/screenshots/truth/actions/send_msg/render/multiline-text-with-replies.png +0 -0
- package/screenshots/truth/actions/send_msg/render/simple-text.png +0 -0
- package/screenshots/truth/actions/send_msg/render/text-with-linebreaks.png +0 -0
- package/screenshots/truth/actions/send_msg/render/text-with-many-quick-replies.png +0 -0
- package/screenshots/truth/actions/send_msg/render/text-with-quick-replies.png +0 -0
- package/screenshots/truth/actions/send_msg/render/text-without-quick-replies.png +0 -0
- package/screenshots/truth/actions/start_session/editor/contact-query.png +0 -0
- package/screenshots/truth/actions/start_session/editor/contacts-only.png +0 -0
- package/screenshots/truth/actions/start_session/editor/create-contact.png +0 -0
- package/screenshots/truth/actions/start_session/editor/groups-and-contacts.png +0 -0
- package/screenshots/truth/actions/start_session/editor/groups-only.png +0 -0
- package/screenshots/truth/actions/start_session/editor/many-recipients.png +0 -0
- package/screenshots/truth/actions/start_session/render/contact-query.png +0 -0
- package/screenshots/truth/actions/start_session/render/contacts-only.png +0 -0
- package/screenshots/truth/actions/start_session/render/create-contact.png +0 -0
- package/screenshots/truth/actions/start_session/render/groups-and-contacts.png +0 -0
- package/screenshots/truth/actions/start_session/render/groups-only.png +0 -0
- package/screenshots/truth/actions/start_session/render/many-recipients.png +0 -0
- package/screenshots/truth/canvas-menu/open.png +0 -0
- package/screenshots/truth/editor/router.png +0 -0
- package/screenshots/truth/editor/wait.png +0 -0
- package/screenshots/truth/list/fields-dragging.png +0 -0
- package/screenshots/truth/list/sortable-dragging.png +0 -0
- package/screenshots/truth/node-type-selector/action-mode.png +0 -0
- package/screenshots/truth/node-type-selector/split-mode.png +0 -0
- package/screenshots/truth/nodes/split_by_llm/editor/information-extraction.png +0 -0
- package/screenshots/truth/nodes/split_by_llm/editor/sentiment-analysis.png +0 -0
- package/screenshots/truth/nodes/split_by_llm/editor/summarization.png +0 -0
- package/screenshots/truth/nodes/split_by_llm/editor/translation-task.png +0 -0
- package/screenshots/truth/nodes/split_by_llm/render/information-extraction.png +0 -0
- package/screenshots/truth/nodes/split_by_llm/render/sentiment-analysis.png +0 -0
- package/screenshots/truth/nodes/split_by_llm/render/summarization.png +0 -0
- package/screenshots/truth/nodes/split_by_llm/render/translation-task.png +0 -0
- package/screenshots/truth/nodes/split_by_llm_categorize/editor/basic-categorization.png +0 -0
- package/screenshots/truth/nodes/split_by_llm_categorize/editor/custom-input-and-result-name.png +0 -0
- package/screenshots/truth/nodes/split_by_llm_categorize/editor/feedback-categorization.png +0 -0
- package/screenshots/truth/nodes/split_by_llm_categorize/editor/many-categories.png +0 -0
- package/screenshots/truth/nodes/split_by_llm_categorize/editor/minimal-categories.png +0 -0
- package/screenshots/truth/nodes/split_by_llm_categorize/render/basic-categorization.png +0 -0
- package/screenshots/truth/nodes/split_by_llm_categorize/render/custom-input-and-result-name.png +0 -0
- package/screenshots/truth/nodes/split_by_llm_categorize/render/feedback-categorization.png +0 -0
- package/screenshots/truth/nodes/split_by_llm_categorize/render/many-categories.png +0 -0
- package/screenshots/truth/nodes/split_by_llm_categorize/render/minimal-categories.png +0 -0
- package/screenshots/truth/nodes/split_by_random/editor/ab-test-multiple-variants.png +0 -0
- package/screenshots/truth/nodes/split_by_random/editor/sampling-split.png +0 -0
- package/screenshots/truth/nodes/split_by_random/editor/three-way-split.png +0 -0
- package/screenshots/truth/nodes/split_by_random/editor/two-bucket-split.png +0 -0
- package/screenshots/truth/nodes/split_by_random/render/ab-test-multiple-variants.png +0 -0
- package/screenshots/truth/nodes/split_by_random/render/sampling-split.png +0 -0
- package/screenshots/truth/nodes/split_by_random/render/three-way-split.png +0 -0
- package/screenshots/truth/nodes/split_by_random/render/two-bucket-split.png +0 -0
- package/screenshots/truth/nodes/wait_for_digits/editor/basic-digits-wait.png +0 -0
- package/screenshots/truth/nodes/wait_for_digits/editor/phone-number-collection.png +0 -0
- package/screenshots/truth/nodes/wait_for_digits/editor/single-digit-with-timeout.png +0 -0
- package/screenshots/truth/nodes/wait_for_digits/editor/verification-code.png +0 -0
- package/screenshots/truth/nodes/wait_for_digits/render/basic-digits-wait.png +0 -0
- package/screenshots/truth/nodes/wait_for_digits/render/phone-number-collection.png +0 -0
- package/screenshots/truth/nodes/wait_for_digits/render/single-digit-with-timeout.png +0 -0
- package/screenshots/truth/nodes/wait_for_digits/render/verification-code.png +0 -0
- package/screenshots/truth/nodes/wait_for_response/editor/basic-wait.png +0 -0
- package/screenshots/truth/nodes/wait_for_response/editor/custom-result-name.png +0 -0
- package/screenshots/truth/nodes/wait_for_response/editor/no-timeout.png +0 -0
- package/screenshots/truth/nodes/wait_for_response/editor/short-timeout.png +0 -0
- package/screenshots/truth/nodes/wait_for_response/render/basic-wait.png +0 -0
- package/screenshots/truth/nodes/wait_for_response/render/custom-result-name.png +0 -0
- package/screenshots/truth/nodes/wait_for_response/render/no-timeout.png +0 -0
- package/screenshots/truth/nodes/wait_for_response/render/short-timeout.png +0 -0
- package/src/Icons.ts +4 -1
- package/src/events.ts +2 -6
- package/src/flow/CanvasMenu.ts +217 -0
- package/src/flow/CanvasNode.ts +408 -10
- package/src/flow/Editor.ts +683 -44
- package/src/flow/NodeEditor.ts +304 -125
- package/src/flow/NodeTypeSelector.ts +592 -0
- package/src/flow/actions/add_contact_groups.ts +4 -4
- package/src/flow/actions/add_contact_urn.ts +76 -4
- package/src/flow/actions/add_input_labels.ts +4 -4
- package/src/flow/actions/play_audio.ts +2 -2
- package/src/flow/actions/remove_contact_groups.ts +14 -6
- package/src/flow/actions/request_optin.ts +2 -2
- package/src/flow/actions/say_msg.ts +2 -2
- package/src/flow/actions/send_broadcast.ts +85 -23
- package/src/flow/actions/send_email.ts +10 -6
- package/src/flow/actions/send_msg.ts +22 -32
- package/src/flow/actions/set_contact_channel.ts +5 -11
- package/src/flow/actions/set_contact_field.ts +20 -25
- package/src/flow/actions/set_contact_language.ts +9 -4
- package/src/flow/actions/set_contact_name.ts +3 -15
- package/src/flow/actions/set_contact_status.ts +3 -3
- package/src/flow/actions/set_run_result.ts +4 -4
- package/src/flow/actions/start_session.ts +208 -6
- package/src/flow/config.ts +13 -15
- package/src/flow/currencies.ts +51 -0
- package/src/flow/nodes/shared-rules.ts +301 -0
- package/src/flow/nodes/shared.ts +18 -0
- package/src/flow/nodes/split_by_airtime.ts +238 -5
- package/src/flow/nodes/split_by_contact_field.ts +185 -3
- package/src/flow/nodes/split_by_expression.ts +94 -2
- package/src/flow/nodes/split_by_groups.ts +15 -10
- package/src/flow/nodes/split_by_intent.ts +7 -0
- package/src/flow/nodes/split_by_llm.ts +4 -3
- package/src/flow/nodes/split_by_llm_categorize.ts +4 -4
- package/src/flow/nodes/split_by_random.ts +5 -5
- package/src/flow/nodes/split_by_resthook.ts +130 -0
- package/src/flow/nodes/split_by_run_result.ts +249 -3
- package/src/flow/nodes/split_by_scheme.ts +192 -2
- package/src/flow/nodes/split_by_subflow.ts +6 -4
- package/src/flow/nodes/split_by_ticket.ts +4 -3
- package/src/flow/nodes/split_by_webhook.ts +6 -5
- package/src/flow/nodes/wait_for_audio.ts +2 -2
- package/src/flow/nodes/wait_for_digits.ts +2 -2
- package/src/flow/nodes/wait_for_image.ts +2 -2
- package/src/flow/nodes/wait_for_location.ts +2 -2
- package/src/flow/nodes/wait_for_menu.ts +2 -2
- package/src/flow/nodes/wait_for_response.ts +48 -679
- package/src/flow/nodes/wait_for_video.ts +2 -2
- package/src/flow/types.ts +109 -23
- package/src/flow/utils.ts +108 -14
- package/src/form/ContactSearch.ts +1 -1
- package/src/form/FieldRenderer.ts +2 -4
- package/src/interfaces.ts +3 -0
- package/src/list/SortableList.ts +109 -34
- package/src/live/ContactChat.ts +15 -18
- package/src/store/AppState.ts +69 -0
- package/src/store/flow-definition.d.ts +2 -5
- package/src/utils.ts +332 -12
- package/static/api/channels.json +46 -0
- package/static/api/resthooks.json +31 -0
- package/static/svg/index.svg +1 -1
- package/static/svg/work/traced/lightning-02.svg +1 -0
- package/static/svg/work/used/lightning-02.svg +3 -0
- package/temba-modules.ts +4 -0
- package/test/ActionHelper.ts +3 -3
- package/test/NodeHelper.ts +6 -3
- package/test/actions/add_contact_urn.test.ts +287 -0
- package/test/actions/send_broadcast.test.ts +190 -0
- package/test/actions/send_email.test.ts +17 -23
- package/test/actions/send_msg.test.ts +39 -15
- package/test/actions/start_session.test.ts +151 -0
- package/test/nodes/split_by_airtime.test.ts +673 -0
- package/test/nodes/split_by_contact_field.test.ts +451 -0
- package/test/nodes/split_by_expression.test.ts +751 -0
- package/test/nodes/split_by_random.test.ts +3 -3
- package/test/nodes/split_by_resthook.test.ts +398 -0
- package/test/nodes/split_by_run_result.test.ts +1109 -0
- package/test/nodes/split_by_scheme.test.ts +486 -0
- package/test/nodes/split_by_subflow.test.ts +381 -0
- package/test/nodes/wait_for_digits.test.ts +2 -2
- package/test/nodes/wait_for_response.test.ts +2 -1
- package/test/temba-action-drag-between-nodes.test.ts +301 -0
- package/test/temba-canvas-menu.test.ts +156 -0
- package/test/temba-flow-editor-node.test.ts +102 -2
- package/test/temba-flow-editor.test.ts +7 -8
- package/test/temba-node-editor.test.ts +3 -1
- package/test/temba-node-type-selector.test.ts +152 -0
- package/test/temba-omnibox.test.ts +2 -1
- package/test/temba-sortable-list.test.ts +69 -0
- package/test/temba-utils-index.test.ts +0 -35
- package/test/utils.test.ts +2 -0
- package/test-assets/contacts/history.json +14 -20
- package/web-dev-server.config.mjs +3 -1
- package/out-tsc/src/flow/actions/call_classifier.js +0 -11
- package/out-tsc/src/flow/actions/call_classifier.js.map +0 -1
- package/out-tsc/src/flow/actions/call_resthook.js +0 -11
- package/out-tsc/src/flow/actions/call_resthook.js.map +0 -1
- package/out-tsc/src/flow/actions/split_by_expression_example.js +0 -77
- package/out-tsc/src/flow/actions/split_by_expression_example.js.map +0 -1
- package/out-tsc/src/flow/actions/transfer_airtime.js +0 -11
- package/out-tsc/src/flow/actions/transfer_airtime.js.map +0 -1
- package/src/flow/actions/call_classifier.ts +0 -12
- package/src/flow/actions/call_resthook.ts +0 -12
- package/src/flow/actions/split_by_expression_example.ts +0 -88
- package/src/flow/actions/transfer_airtime.ts +0 -12
|
@@ -1,17 +1,89 @@
|
|
|
1
1
|
import { html } from 'lit-html';
|
|
2
|
-
import {
|
|
2
|
+
import {
|
|
3
|
+
ActionConfig,
|
|
4
|
+
ACTION_GROUPS,
|
|
5
|
+
FormData,
|
|
6
|
+
ValidationResult
|
|
7
|
+
} from '../types';
|
|
3
8
|
import { Node, AddContactUrn } from '../../store/flow-definition';
|
|
4
|
-
import {
|
|
9
|
+
import { SCHEMES } from '../utils';
|
|
5
10
|
|
|
6
11
|
export const add_contact_urn: ActionConfig = {
|
|
7
12
|
name: 'Add URN',
|
|
8
|
-
|
|
13
|
+
group: ACTION_GROUPS.contacts,
|
|
9
14
|
render: (_node: Node, action: AddContactUrn) => {
|
|
10
|
-
const
|
|
15
|
+
const schemeObj = SCHEMES.find((s) => s.scheme === action.scheme);
|
|
16
|
+
const friendlyScheme = schemeObj?.path || action.scheme;
|
|
11
17
|
return html`<div
|
|
12
18
|
style="word-wrap: break-word; overflow-wrap: break-word; hyphens: auto;"
|
|
13
19
|
>
|
|
14
20
|
Add ${friendlyScheme} <strong>${action.path}</strong>
|
|
15
21
|
</div>`;
|
|
22
|
+
},
|
|
23
|
+
|
|
24
|
+
toFormData: (action: AddContactUrn) => {
|
|
25
|
+
const schemeObj = SCHEMES.find((s) => s.scheme === action.scheme);
|
|
26
|
+
return {
|
|
27
|
+
uuid: action.uuid,
|
|
28
|
+
scheme: schemeObj
|
|
29
|
+
? [{ name: schemeObj.path, value: action.scheme }]
|
|
30
|
+
: null,
|
|
31
|
+
path: action.path || ''
|
|
32
|
+
};
|
|
33
|
+
},
|
|
34
|
+
|
|
35
|
+
fromFormData: (formData: FormData): AddContactUrn => {
|
|
36
|
+
// Extract scheme value from select format
|
|
37
|
+
const schemeValue =
|
|
38
|
+
Array.isArray(formData.scheme) && formData.scheme.length > 0
|
|
39
|
+
? formData.scheme[0].value
|
|
40
|
+
: 'tel';
|
|
41
|
+
|
|
42
|
+
return {
|
|
43
|
+
uuid: formData.uuid,
|
|
44
|
+
type: 'add_contact_urn',
|
|
45
|
+
scheme: schemeValue,
|
|
46
|
+
path: formData.path || ''
|
|
47
|
+
};
|
|
48
|
+
},
|
|
49
|
+
|
|
50
|
+
form: {
|
|
51
|
+
scheme: {
|
|
52
|
+
type: 'select',
|
|
53
|
+
label: 'URN Type',
|
|
54
|
+
helpText: 'Select the type of URN to add to the contact',
|
|
55
|
+
required: true,
|
|
56
|
+
searchable: false,
|
|
57
|
+
multi: false,
|
|
58
|
+
options: SCHEMES.map((scheme) => ({
|
|
59
|
+
name: scheme.path,
|
|
60
|
+
value: scheme.scheme
|
|
61
|
+
}))
|
|
62
|
+
},
|
|
63
|
+
path: {
|
|
64
|
+
type: 'text',
|
|
65
|
+
label: 'URN Value',
|
|
66
|
+
helpText: 'Enter the URN value (e.g., phone number, Facebook ID, etc.)',
|
|
67
|
+
required: true,
|
|
68
|
+
placeholder: 'Enter the URN value...',
|
|
69
|
+
evaluated: true
|
|
70
|
+
}
|
|
71
|
+
},
|
|
72
|
+
|
|
73
|
+
validate: (formData: FormData): ValidationResult => {
|
|
74
|
+
const errors: { [key: string]: string } = {};
|
|
75
|
+
|
|
76
|
+
if (!formData.scheme || formData.scheme.length === 0) {
|
|
77
|
+
errors.scheme = 'URN type is required';
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
if (!formData.path || formData.path.trim() === '') {
|
|
81
|
+
errors.path = 'URN value is required';
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
return {
|
|
85
|
+
valid: Object.keys(errors).length === 0,
|
|
86
|
+
errors
|
|
87
|
+
};
|
|
16
88
|
}
|
|
17
89
|
};
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { html } from 'lit-html';
|
|
2
|
-
import { ActionConfig,
|
|
2
|
+
import { ActionConfig, ACTION_GROUPS, FormData } from '../types';
|
|
3
3
|
import { Node, AddInputLabels } from '../../store/flow-definition';
|
|
4
4
|
import { renderNamedObjects } from '../utils';
|
|
5
5
|
|
|
6
6
|
export const add_input_labels: ActionConfig = {
|
|
7
7
|
name: 'Add Input Labels',
|
|
8
|
-
|
|
8
|
+
group: ACTION_GROUPS.save,
|
|
9
9
|
render: (_node: Node, action: AddInputLabels) => {
|
|
10
10
|
return html`<div>${renderNamedObjects(action.labels, 'label')}</div>`;
|
|
11
11
|
},
|
|
@@ -13,7 +13,7 @@ export const add_input_labels: ActionConfig = {
|
|
|
13
13
|
// Form-level transformations
|
|
14
14
|
toFormData: (action: AddInputLabels) => {
|
|
15
15
|
return {
|
|
16
|
-
labels: action.labels ||
|
|
16
|
+
labels: action.labels || null,
|
|
17
17
|
uuid: action.uuid
|
|
18
18
|
};
|
|
19
19
|
},
|
|
@@ -48,7 +48,7 @@ export const add_input_labels: ActionConfig = {
|
|
|
48
48
|
}
|
|
49
49
|
}
|
|
50
50
|
},
|
|
51
|
-
fromFormData: (formData:
|
|
51
|
+
fromFormData: (formData: FormData): AddInputLabels => {
|
|
52
52
|
return {
|
|
53
53
|
uuid: formData.uuid,
|
|
54
54
|
type: 'add_input_labels',
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { html } from 'lit-html';
|
|
2
|
-
import { ActionConfig,
|
|
2
|
+
import { ActionConfig, ACTION_GROUPS } from '../types';
|
|
3
3
|
import { Node, PlayAudio } from '../../store/flow-definition';
|
|
4
4
|
|
|
5
5
|
export const play_audio: ActionConfig = {
|
|
6
6
|
name: 'Play Audio',
|
|
7
|
-
|
|
7
|
+
group: ACTION_GROUPS.send,
|
|
8
8
|
render: (_node: Node, _action: PlayAudio) => {
|
|
9
9
|
// This will need to be implemented based on the actual render logic
|
|
10
10
|
return html`<div>Play Audio</div>`;
|
|
@@ -1,11 +1,16 @@
|
|
|
1
1
|
import { html } from 'lit-html';
|
|
2
|
-
import {
|
|
2
|
+
import {
|
|
3
|
+
ActionConfig,
|
|
4
|
+
ACTION_GROUPS,
|
|
5
|
+
FormData,
|
|
6
|
+
ValidationResult
|
|
7
|
+
} from '../types';
|
|
3
8
|
import { Node, RemoveFromGroup } from '../../store/flow-definition';
|
|
4
9
|
import { renderNamedObjects } from '../utils';
|
|
5
10
|
|
|
6
11
|
export const remove_contact_groups: ActionConfig = {
|
|
7
12
|
name: 'Remove from Group',
|
|
8
|
-
|
|
13
|
+
group: ACTION_GROUPS.contacts,
|
|
9
14
|
render: (_node: Node, action: RemoveFromGroup) => {
|
|
10
15
|
if (action.all_groups) {
|
|
11
16
|
return html`<div>Remove from all groups</div>`;
|
|
@@ -16,7 +21,7 @@ export const remove_contact_groups: ActionConfig = {
|
|
|
16
21
|
return {
|
|
17
22
|
uuid: action.uuid,
|
|
18
23
|
all_groups: action.all_groups || false,
|
|
19
|
-
groups: action.groups ||
|
|
24
|
+
groups: action.groups || null
|
|
20
25
|
};
|
|
21
26
|
},
|
|
22
27
|
form: {
|
|
@@ -42,10 +47,13 @@ export const remove_contact_groups: ActionConfig = {
|
|
|
42
47
|
'Check this to remove the contact from all groups instead of specific ones'
|
|
43
48
|
}
|
|
44
49
|
},
|
|
45
|
-
validate: (
|
|
50
|
+
validate: (formData: FormData): ValidationResult => {
|
|
46
51
|
const errors: { [key: string]: string } = {};
|
|
47
52
|
|
|
48
|
-
if (
|
|
53
|
+
if (
|
|
54
|
+
!formData.all_groups &&
|
|
55
|
+
(!formData.groups || formData.groups.length === 0)
|
|
56
|
+
) {
|
|
49
57
|
errors.groups =
|
|
50
58
|
'At least one group must be selected or check "Remove from All Groups"';
|
|
51
59
|
}
|
|
@@ -55,7 +63,7 @@ export const remove_contact_groups: ActionConfig = {
|
|
|
55
63
|
errors
|
|
56
64
|
};
|
|
57
65
|
},
|
|
58
|
-
fromFormData: (formData:
|
|
66
|
+
fromFormData: (formData: FormData): RemoveFromGroup => {
|
|
59
67
|
return {
|
|
60
68
|
uuid: formData.uuid,
|
|
61
69
|
type: 'remove_contact_groups',
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { html } from 'lit-html';
|
|
2
|
-
import { ActionConfig,
|
|
2
|
+
import { ActionConfig, ACTION_GROUPS } from '../types';
|
|
3
3
|
import { Node, RequestOptin } from '../../store/flow-definition';
|
|
4
4
|
|
|
5
5
|
export const request_optin: ActionConfig = {
|
|
6
6
|
name: 'Request Opt-in',
|
|
7
|
-
|
|
7
|
+
group: ACTION_GROUPS.send,
|
|
8
8
|
render: (_node: Node, _action: RequestOptin) => {
|
|
9
9
|
// This will need to be implemented based on the actual render logic
|
|
10
10
|
return html`<div>Request Opt-in</div>`;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { html } from 'lit-html';
|
|
2
|
-
import { ActionConfig,
|
|
2
|
+
import { ActionConfig, ACTION_GROUPS } from '../types';
|
|
3
3
|
import { Node, SayMsg } from '../../store/flow-definition';
|
|
4
4
|
|
|
5
5
|
export const say_msg: ActionConfig = {
|
|
6
6
|
name: 'Say Message',
|
|
7
|
-
|
|
7
|
+
group: ACTION_GROUPS.send,
|
|
8
8
|
render: (_node: Node, _action: SayMsg) => {
|
|
9
9
|
// This will need to be implemented based on the actual render logic
|
|
10
10
|
return html`<div>Say Message</div>`;
|
|
@@ -1,35 +1,97 @@
|
|
|
1
1
|
import { html } from 'lit-html';
|
|
2
|
-
import { ActionConfig,
|
|
2
|
+
import { ActionConfig, ACTION_GROUPS, FormData } from '../types';
|
|
3
3
|
import { Node, SendBroadcast } from '../../store/flow-definition';
|
|
4
|
-
import {
|
|
4
|
+
import { renderStringList } from '../utils';
|
|
5
|
+
import { Icon } from '../../Icons';
|
|
5
6
|
|
|
6
7
|
export const send_broadcast: ActionConfig = {
|
|
7
8
|
name: 'Send Broadcast',
|
|
8
|
-
|
|
9
|
+
group: ACTION_GROUPS.broadcast,
|
|
9
10
|
render: (_node: Node, action: SendBroadcast) => {
|
|
10
|
-
const
|
|
11
|
-
|
|
11
|
+
const recipients = [
|
|
12
|
+
...(action.contacts || []).map((c) => c.name),
|
|
13
|
+
...(action.groups || []).map((g) => g.name)
|
|
14
|
+
];
|
|
12
15
|
|
|
13
16
|
return html`<div>
|
|
14
|
-
<div
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
17
|
+
<div>${renderStringList(recipients, Icon.contacts)}</div>
|
|
18
|
+
<div style="margin-top: 0.5em">
|
|
19
|
+
<div
|
|
20
|
+
style="word-wrap: break-word; overflow-wrap: break-word; hyphens: auto;"
|
|
21
|
+
>
|
|
22
|
+
${action.text}
|
|
23
|
+
</div>
|
|
18
24
|
</div>
|
|
19
|
-
${hasGroups
|
|
20
|
-
? html`<div style="margin-bottom: 0.25em">
|
|
21
|
-
<div style="font-weight: bold; margin-bottom: 0.25em">Groups:</div>
|
|
22
|
-
${renderNamedObjects(action.groups, 'group')}
|
|
23
|
-
</div>`
|
|
24
|
-
: null}
|
|
25
|
-
${hasContacts
|
|
26
|
-
? html`<div>
|
|
27
|
-
<div style="font-weight: bold; margin-bottom: 0.25em">
|
|
28
|
-
Contacts:
|
|
29
|
-
</div>
|
|
30
|
-
${renderNamedObjects(action.contacts, 'contact')}
|
|
31
|
-
</div>`
|
|
32
|
-
: null}
|
|
33
25
|
</div>`;
|
|
26
|
+
},
|
|
27
|
+
|
|
28
|
+
form: {
|
|
29
|
+
recipients: {
|
|
30
|
+
type: 'select',
|
|
31
|
+
label: 'Recipients',
|
|
32
|
+
helpText: 'Select the contacts or groups to receive the broadcast',
|
|
33
|
+
options: [],
|
|
34
|
+
multi: true,
|
|
35
|
+
searchable: true,
|
|
36
|
+
endpoint: '/api/v2/contacts.json',
|
|
37
|
+
valueKey: 'uuid',
|
|
38
|
+
nameKey: 'name',
|
|
39
|
+
placeholder: 'Search for contacts or groups...',
|
|
40
|
+
required: true
|
|
41
|
+
},
|
|
42
|
+
text: {
|
|
43
|
+
type: 'message-editor',
|
|
44
|
+
label: 'Message',
|
|
45
|
+
helpText:
|
|
46
|
+
'Enter the message to send with optional attachments. You can use expressions like @contact.name',
|
|
47
|
+
required: true,
|
|
48
|
+
evaluated: true,
|
|
49
|
+
placeholder: 'Type your message here...',
|
|
50
|
+
maxAttachments: 10,
|
|
51
|
+
accept: '',
|
|
52
|
+
endpoint: '/api/v2/media.json',
|
|
53
|
+
counter: 'temba-charcount',
|
|
54
|
+
gsm: true,
|
|
55
|
+
autogrow: true
|
|
56
|
+
}
|
|
57
|
+
},
|
|
58
|
+
|
|
59
|
+
layout: ['recipients', 'text'],
|
|
60
|
+
|
|
61
|
+
toFormData: (action: SendBroadcast) => {
|
|
62
|
+
return {
|
|
63
|
+
uuid: action.uuid,
|
|
64
|
+
recipients: [...(action.contacts || []), ...(action.groups || [])],
|
|
65
|
+
text: action.text || '',
|
|
66
|
+
attachments: action.attachments || []
|
|
67
|
+
};
|
|
68
|
+
},
|
|
69
|
+
|
|
70
|
+
fromFormData: (formData: FormData): SendBroadcast => {
|
|
71
|
+
const recipients = formData.recipients || [];
|
|
72
|
+
const contacts = recipients.filter((r: any) => !r.group);
|
|
73
|
+
const groups = recipients.filter((r: any) => r.group);
|
|
74
|
+
|
|
75
|
+
const result: SendBroadcast = {
|
|
76
|
+
uuid: formData.uuid,
|
|
77
|
+
type: 'send_broadcast',
|
|
78
|
+
text: formData.text || '',
|
|
79
|
+
contacts,
|
|
80
|
+
groups,
|
|
81
|
+
attachments: formData.attachments || []
|
|
82
|
+
};
|
|
83
|
+
|
|
84
|
+
// Remove empty attachments array to match original format
|
|
85
|
+
if (result.attachments.length === 0) {
|
|
86
|
+
delete result.attachments;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
return result;
|
|
90
|
+
},
|
|
91
|
+
|
|
92
|
+
sanitize: (formData: FormData): void => {
|
|
93
|
+
if (formData.text && typeof formData.text === 'string') {
|
|
94
|
+
formData.text = formData.text.trim();
|
|
95
|
+
}
|
|
34
96
|
}
|
|
35
97
|
};
|
|
@@ -1,12 +1,17 @@
|
|
|
1
1
|
import { html } from 'lit-html';
|
|
2
|
-
import {
|
|
2
|
+
import {
|
|
3
|
+
ActionConfig,
|
|
4
|
+
ACTION_GROUPS,
|
|
5
|
+
FormData,
|
|
6
|
+
ValidationResult
|
|
7
|
+
} from '../types';
|
|
3
8
|
import { Node, SendEmail } from '../../store/flow-definition';
|
|
4
9
|
import { renderStringList } from '../utils';
|
|
5
10
|
import { Icon } from '../../Icons';
|
|
6
11
|
|
|
7
12
|
export const send_email: ActionConfig = {
|
|
8
13
|
name: 'Send Email',
|
|
9
|
-
|
|
14
|
+
group: ACTION_GROUPS.broadcast,
|
|
10
15
|
render: (_node: Node, action: SendEmail) => {
|
|
11
16
|
return html`<div>
|
|
12
17
|
<div>${renderStringList(action.addresses, Icon.email)}</div>
|
|
@@ -23,7 +28,6 @@ export const send_email: ActionConfig = {
|
|
|
23
28
|
addresses: {
|
|
24
29
|
type: 'select',
|
|
25
30
|
label: 'Recipients',
|
|
26
|
-
options: [],
|
|
27
31
|
multi: true,
|
|
28
32
|
searchable: true,
|
|
29
33
|
placeholder: 'Search for contacts...',
|
|
@@ -43,7 +47,7 @@ export const send_email: ActionConfig = {
|
|
|
43
47
|
minHeight: 175
|
|
44
48
|
}
|
|
45
49
|
},
|
|
46
|
-
fromFormData: (formData:
|
|
50
|
+
fromFormData: (formData: FormData): SendEmail => {
|
|
47
51
|
return {
|
|
48
52
|
uuid: formData.uuid,
|
|
49
53
|
type: 'send_email',
|
|
@@ -54,10 +58,10 @@ export const send_email: ActionConfig = {
|
|
|
54
58
|
body: formData.body
|
|
55
59
|
};
|
|
56
60
|
},
|
|
57
|
-
validate: (
|
|
61
|
+
validate: (formData: FormData): ValidationResult => {
|
|
58
62
|
const errors: { [key: string]: string } = {};
|
|
59
63
|
|
|
60
|
-
if (!
|
|
64
|
+
if (!formData.addresses || formData.addresses.length === 0) {
|
|
61
65
|
errors.addresses = 'At least one recipient email address is required';
|
|
62
66
|
}
|
|
63
67
|
|
|
@@ -1,12 +1,17 @@
|
|
|
1
1
|
import { html } from 'lit-html';
|
|
2
2
|
import { unsafeHTML } from 'lit-html/directives/unsafe-html.js';
|
|
3
|
-
import {
|
|
3
|
+
import {
|
|
4
|
+
ActionConfig,
|
|
5
|
+
ACTION_GROUPS,
|
|
6
|
+
FormData,
|
|
7
|
+
ValidationResult
|
|
8
|
+
} from '../types';
|
|
4
9
|
import { Node, SendMsg } from '../../store/flow-definition';
|
|
5
10
|
import { titleCase } from '../../utils';
|
|
6
11
|
|
|
7
12
|
export const send_msg: ActionConfig = {
|
|
8
13
|
name: 'Send Message',
|
|
9
|
-
|
|
14
|
+
group: ACTION_GROUPS.send,
|
|
10
15
|
render: (_node: Node, action: SendMsg) => {
|
|
11
16
|
const text = action.text.replace(/\n/g, '<br>');
|
|
12
17
|
return html`
|
|
@@ -91,11 +96,11 @@ export const send_msg: ActionConfig = {
|
|
|
91
96
|
label: 'Quick Replies',
|
|
92
97
|
items: ['quick_replies'],
|
|
93
98
|
collapsible: true,
|
|
94
|
-
collapsed: (formData:
|
|
99
|
+
collapsed: (formData: FormData) => {
|
|
95
100
|
// Collapse only if there are no quick replies
|
|
96
101
|
return !formData.quick_replies || formData.quick_replies.length === 0;
|
|
97
102
|
},
|
|
98
|
-
getGroupValueCount: (formData:
|
|
103
|
+
getGroupValueCount: (formData: FormData) => {
|
|
99
104
|
return formData.quick_replies?.length || 0;
|
|
100
105
|
}
|
|
101
106
|
},
|
|
@@ -106,7 +111,7 @@ export const send_msg: ActionConfig = {
|
|
|
106
111
|
collapsible: true,
|
|
107
112
|
collapsed: true,
|
|
108
113
|
helpText: 'Add dynamic attachments that are evaluated at runtime',
|
|
109
|
-
getGroupValueCount: (formData:
|
|
114
|
+
getGroupValueCount: (formData: FormData) => {
|
|
110
115
|
return (
|
|
111
116
|
formData.runtime_attachments?.filter(
|
|
112
117
|
(item: any) =>
|
|
@@ -154,7 +159,7 @@ export const send_msg: ActionConfig = {
|
|
|
154
159
|
}))
|
|
155
160
|
};
|
|
156
161
|
},
|
|
157
|
-
fromFormData: (data:
|
|
162
|
+
fromFormData: (data: FormData) => {
|
|
158
163
|
const result = {
|
|
159
164
|
uuid: data.uuid,
|
|
160
165
|
type: 'send_msg',
|
|
@@ -190,44 +195,29 @@ export const send_msg: ActionConfig = {
|
|
|
190
195
|
|
|
191
196
|
return result as SendMsg;
|
|
192
197
|
},
|
|
193
|
-
sanitize: (formData:
|
|
198
|
+
sanitize: (formData: FormData): void => {
|
|
194
199
|
if (formData.text && typeof formData.text === 'string') {
|
|
195
200
|
formData.text = formData.text.trim();
|
|
196
201
|
}
|
|
197
202
|
},
|
|
198
|
-
validate: (
|
|
203
|
+
validate: (formData: FormData): ValidationResult => {
|
|
199
204
|
const errors: { [key: string]: string } = {};
|
|
200
205
|
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
if (attachments.length > 10) {
|
|
207
|
-
const staticAttachments = attachments.filter(
|
|
208
|
-
(attachment) =>
|
|
209
|
-
typeof attachment === 'string' &&
|
|
210
|
-
attachment.substring(0, attachment.indexOf(':')).includes('/')
|
|
211
|
-
);
|
|
212
|
-
|
|
213
|
-
const runtimeAttachments = attachments.filter(
|
|
214
|
-
(attachment) =>
|
|
215
|
-
typeof attachment === 'string' &&
|
|
216
|
-
!attachment.substring(0, attachment.indexOf(':')).includes('/')
|
|
217
|
-
);
|
|
206
|
+
// Check total attachment count (static + runtime should not exceed 10)
|
|
207
|
+
const staticAttachments = formData.attachments || [];
|
|
208
|
+
const runtimeAttachments = (formData.runtime_attachments || []).filter(
|
|
209
|
+
(item: any) => item && item.expression && item.expression.trim() !== ''
|
|
210
|
+
);
|
|
218
211
|
|
|
212
|
+
const totalAttachments =
|
|
213
|
+
staticAttachments.length + runtimeAttachments.length;
|
|
214
|
+
if (totalAttachments > 10) {
|
|
219
215
|
if (runtimeAttachments.length > 0) {
|
|
220
216
|
errors.runtime_attachments =
|
|
221
217
|
'Each message can only have up to 10 attachments';
|
|
222
218
|
}
|
|
223
|
-
|
|
224
219
|
if (staticAttachments.length > 0) {
|
|
225
|
-
|
|
226
|
-
if (errors.text) {
|
|
227
|
-
errors.text += ` ${message}`;
|
|
228
|
-
} else {
|
|
229
|
-
errors.text = message;
|
|
230
|
-
}
|
|
220
|
+
errors.text = 'Each message can only have up to 10 total attachments';
|
|
231
221
|
}
|
|
232
222
|
}
|
|
233
223
|
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { html } from 'lit-html';
|
|
2
|
-
import { ActionConfig,
|
|
2
|
+
import { ActionConfig, ACTION_GROUPS } from '../types';
|
|
3
3
|
import { Node, SetContactChannel } from '../../store/flow-definition';
|
|
4
4
|
|
|
5
5
|
export const set_contact_channel: ActionConfig = {
|
|
6
6
|
name: 'Update Channel',
|
|
7
|
-
|
|
7
|
+
group: ACTION_GROUPS.contacts,
|
|
8
8
|
render: (_node: Node, action: SetContactChannel) => {
|
|
9
9
|
return html`<div>Set to <strong>${action.channel.name}</strong></div>`;
|
|
10
10
|
},
|
|
@@ -21,16 +21,10 @@ export const set_contact_channel: ActionConfig = {
|
|
|
21
21
|
helpText: 'Select the channel to set for the contact'
|
|
22
22
|
}
|
|
23
23
|
},
|
|
24
|
-
|
|
25
|
-
const errors: { [key: string]: string } = {};
|
|
26
|
-
|
|
27
|
-
if (!formData.channel) {
|
|
28
|
-
errors.channel = 'Channel is required';
|
|
29
|
-
}
|
|
30
|
-
|
|
24
|
+
toFormData: (action: SetContactChannel) => {
|
|
31
25
|
return {
|
|
32
|
-
|
|
33
|
-
|
|
26
|
+
uuid: action.uuid,
|
|
27
|
+
channel: action.channel ? [action.channel] : null
|
|
34
28
|
};
|
|
35
29
|
}
|
|
36
30
|
};
|
|
@@ -1,15 +1,19 @@
|
|
|
1
1
|
import { html } from 'lit-html';
|
|
2
|
-
import { ActionConfig,
|
|
2
|
+
import { ActionConfig, ACTION_GROUPS, FormData } from '../types';
|
|
3
3
|
import { Node, SetContactField } from '../../store/flow-definition';
|
|
4
4
|
|
|
5
5
|
export const set_contact_field: ActionConfig = {
|
|
6
6
|
name: 'Update Field',
|
|
7
|
-
|
|
7
|
+
group: ACTION_GROUPS.contacts,
|
|
8
8
|
render: (_node: Node, action: SetContactField) => {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
9
|
+
if (action.value) {
|
|
10
|
+
return html`<div>
|
|
11
|
+
Set <strong>${action.field.name}</strong> to
|
|
12
|
+
<strong>${action.value}</strong>
|
|
13
|
+
</div>`;
|
|
14
|
+
} else {
|
|
15
|
+
return html`<div>Clear <strong>${action.field.name}</strong></div>`;
|
|
16
|
+
}
|
|
13
17
|
},
|
|
14
18
|
form: {
|
|
15
19
|
field: {
|
|
@@ -18,6 +22,7 @@ export const set_contact_field: ActionConfig = {
|
|
|
18
22
|
required: true,
|
|
19
23
|
searchable: true,
|
|
20
24
|
clearable: false,
|
|
25
|
+
placeholder: 'Search for contact fields...',
|
|
21
26
|
nameKey: 'name',
|
|
22
27
|
valueKey: 'key',
|
|
23
28
|
endpoint: '/api/v2/fields.json',
|
|
@@ -29,13 +34,19 @@ export const set_contact_field: ActionConfig = {
|
|
|
29
34
|
type: 'text',
|
|
30
35
|
label: 'Value',
|
|
31
36
|
placeholder: 'Enter field value...',
|
|
32
|
-
required: true,
|
|
33
37
|
evaluated: true,
|
|
34
38
|
helpText:
|
|
35
39
|
'The new value for the contact field. You can use expressions like @contact.name'
|
|
36
40
|
}
|
|
37
41
|
},
|
|
38
|
-
|
|
42
|
+
toFormData: (action: SetContactField) => {
|
|
43
|
+
return {
|
|
44
|
+
uuid: action.uuid,
|
|
45
|
+
field: action.field ? [action.field] : null,
|
|
46
|
+
value: action.value
|
|
47
|
+
};
|
|
48
|
+
},
|
|
49
|
+
fromFormData: (formData: FormData): SetContactField => {
|
|
39
50
|
const field = formData.field[0];
|
|
40
51
|
return {
|
|
41
52
|
uuid: formData.uuid,
|
|
@@ -44,23 +55,7 @@ export const set_contact_field: ActionConfig = {
|
|
|
44
55
|
value: formData.value
|
|
45
56
|
};
|
|
46
57
|
},
|
|
47
|
-
|
|
48
|
-
const errors: { [key: string]: string } = {};
|
|
49
|
-
|
|
50
|
-
if (!formData.field) {
|
|
51
|
-
errors.field = 'Field is required';
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
if (!formData.value || formData.value.trim() === '') {
|
|
55
|
-
errors.value = 'Field value is required';
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
return {
|
|
59
|
-
valid: Object.keys(errors).length === 0,
|
|
60
|
-
errors
|
|
61
|
-
};
|
|
62
|
-
},
|
|
63
|
-
sanitize: (formData: SetContactField): void => {
|
|
58
|
+
sanitize: (formData: FormData): void => {
|
|
64
59
|
if (formData.value && typeof formData.value === 'string') {
|
|
65
60
|
formData.value = formData.value.trim();
|
|
66
61
|
}
|
|
@@ -1,11 +1,16 @@
|
|
|
1
1
|
import { html } from 'lit-html';
|
|
2
|
-
import {
|
|
2
|
+
import {
|
|
3
|
+
ActionConfig,
|
|
4
|
+
ACTION_GROUPS,
|
|
5
|
+
FormData,
|
|
6
|
+
ValidationResult
|
|
7
|
+
} from '../types';
|
|
3
8
|
import { Node, SetContactLanguage } from '../../store/flow-definition';
|
|
4
9
|
import { getStore } from '../../store/Store';
|
|
5
10
|
|
|
6
11
|
export const set_contact_language: ActionConfig = {
|
|
7
12
|
name: 'Update Language',
|
|
8
|
-
|
|
13
|
+
group: ACTION_GROUPS.contacts,
|
|
9
14
|
render: (_node: Node, action: SetContactLanguage) => {
|
|
10
15
|
const languageNames = new Intl.DisplayNames(['en'], {
|
|
11
16
|
type: 'language'
|
|
@@ -61,7 +66,7 @@ export const set_contact_language: ActionConfig = {
|
|
|
61
66
|
uuid: action.uuid
|
|
62
67
|
};
|
|
63
68
|
},
|
|
64
|
-
fromFormData: (formData:
|
|
69
|
+
fromFormData: (formData: FormData): SetContactLanguage => {
|
|
65
70
|
return {
|
|
66
71
|
uuid: formData.uuid,
|
|
67
72
|
type: 'set_contact_language',
|
|
@@ -69,7 +74,7 @@ export const set_contact_language: ActionConfig = {
|
|
|
69
74
|
};
|
|
70
75
|
},
|
|
71
76
|
|
|
72
|
-
validate: (formData:
|
|
77
|
+
validate: (formData: FormData): ValidationResult => {
|
|
73
78
|
const errors: { [key: string]: string } = {};
|
|
74
79
|
|
|
75
80
|
if (!formData.language) {
|