@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
|
@@ -0,0 +1,614 @@
|
|
|
1
|
+
import { expect } from '@open-wc/testing';
|
|
2
|
+
import { split_by_expression } from '../../src/flow/nodes/split_by_expression';
|
|
3
|
+
import { NodeTest } from '../NodeHelper';
|
|
4
|
+
/**
|
|
5
|
+
* Test suite for the split_by_expression node configuration.
|
|
6
|
+
*/
|
|
7
|
+
describe('split_by_expression node config', () => {
|
|
8
|
+
const helper = new NodeTest(split_by_expression, 'split_by_expression');
|
|
9
|
+
describe('basic properties', () => {
|
|
10
|
+
helper.testBasicProperties();
|
|
11
|
+
it('has correct name', () => {
|
|
12
|
+
expect(split_by_expression.name).to.equal('Split by Expression');
|
|
13
|
+
});
|
|
14
|
+
it('has correct type', () => {
|
|
15
|
+
expect(split_by_expression.type).to.equal('split_by_expression');
|
|
16
|
+
});
|
|
17
|
+
});
|
|
18
|
+
describe('toFormData', () => {
|
|
19
|
+
it('should transform node with rules to form data correctly', () => {
|
|
20
|
+
const node = {
|
|
21
|
+
uuid: 'test-node-uuid',
|
|
22
|
+
actions: [],
|
|
23
|
+
router: {
|
|
24
|
+
type: 'switch',
|
|
25
|
+
operand: '@fields.age',
|
|
26
|
+
cases: [
|
|
27
|
+
{
|
|
28
|
+
uuid: 'case-1',
|
|
29
|
+
type: 'has_number_gte',
|
|
30
|
+
arguments: ['18'],
|
|
31
|
+
category_uuid: 'cat-1'
|
|
32
|
+
},
|
|
33
|
+
{
|
|
34
|
+
uuid: 'case-2',
|
|
35
|
+
type: 'has_number_between',
|
|
36
|
+
arguments: ['13', '17'],
|
|
37
|
+
category_uuid: 'cat-2'
|
|
38
|
+
},
|
|
39
|
+
{
|
|
40
|
+
uuid: 'case-3',
|
|
41
|
+
type: 'has_number_lt',
|
|
42
|
+
arguments: ['13'],
|
|
43
|
+
category_uuid: 'cat-3'
|
|
44
|
+
}
|
|
45
|
+
],
|
|
46
|
+
categories: [
|
|
47
|
+
{ uuid: 'cat-1', name: 'Adult', exit_uuid: 'exit-1' },
|
|
48
|
+
{ uuid: 'cat-2', name: 'Teen', exit_uuid: 'exit-2' },
|
|
49
|
+
{ uuid: 'cat-3', name: 'Child', exit_uuid: 'exit-3' },
|
|
50
|
+
{ uuid: 'cat-other', name: 'Other', exit_uuid: 'exit-other' }
|
|
51
|
+
],
|
|
52
|
+
default_category_uuid: 'cat-other'
|
|
53
|
+
},
|
|
54
|
+
exits: [
|
|
55
|
+
{ uuid: 'exit-1', destination_uuid: null },
|
|
56
|
+
{ uuid: 'exit-2', destination_uuid: null },
|
|
57
|
+
{ uuid: 'exit-3', destination_uuid: null },
|
|
58
|
+
{ uuid: 'exit-other', destination_uuid: null }
|
|
59
|
+
]
|
|
60
|
+
};
|
|
61
|
+
const formData = split_by_expression.toFormData(node);
|
|
62
|
+
expect(formData.uuid).to.equal('test-node-uuid');
|
|
63
|
+
expect(formData.operand).to.equal('@fields.age');
|
|
64
|
+
expect(formData.rules).to.have.lengthOf(3);
|
|
65
|
+
// Check first rule
|
|
66
|
+
expect(formData.rules[0].operator.value).to.equal('has_number_gte');
|
|
67
|
+
expect(formData.rules[0].value1).to.equal('18');
|
|
68
|
+
expect(formData.rules[0].category).to.equal('Adult');
|
|
69
|
+
// Check second rule (two operands)
|
|
70
|
+
expect(formData.rules[1].operator.value).to.equal('has_number_between');
|
|
71
|
+
expect(formData.rules[1].value1).to.equal('13');
|
|
72
|
+
expect(formData.rules[1].value2).to.equal('17');
|
|
73
|
+
expect(formData.rules[1].category).to.equal('Teen');
|
|
74
|
+
// Check third rule
|
|
75
|
+
expect(formData.rules[2].operator.value).to.equal('has_number_lt');
|
|
76
|
+
expect(formData.rules[2].value1).to.equal('13');
|
|
77
|
+
expect(formData.rules[2].category).to.equal('Child');
|
|
78
|
+
});
|
|
79
|
+
it('should transform node with no rules to form data correctly', () => {
|
|
80
|
+
const node = {
|
|
81
|
+
uuid: 'test-node-uuid',
|
|
82
|
+
actions: [],
|
|
83
|
+
router: {
|
|
84
|
+
type: 'switch',
|
|
85
|
+
operand: '@input.text',
|
|
86
|
+
cases: [],
|
|
87
|
+
categories: [
|
|
88
|
+
{
|
|
89
|
+
uuid: 'cat-all',
|
|
90
|
+
name: 'All Responses',
|
|
91
|
+
exit_uuid: 'exit-all'
|
|
92
|
+
}
|
|
93
|
+
],
|
|
94
|
+
default_category_uuid: 'cat-all'
|
|
95
|
+
},
|
|
96
|
+
exits: [{ uuid: 'exit-all', destination_uuid: null }]
|
|
97
|
+
};
|
|
98
|
+
const formData = split_by_expression.toFormData(node);
|
|
99
|
+
expect(formData.uuid).to.equal('test-node-uuid');
|
|
100
|
+
expect(formData.operand).to.equal('@input.text');
|
|
101
|
+
expect(formData.rules).to.have.lengthOf(0);
|
|
102
|
+
});
|
|
103
|
+
it('should handle result_name in toFormData', () => {
|
|
104
|
+
const node = {
|
|
105
|
+
uuid: 'test-node-uuid',
|
|
106
|
+
actions: [],
|
|
107
|
+
router: {
|
|
108
|
+
type: 'switch',
|
|
109
|
+
operand: '@fields.color',
|
|
110
|
+
result_name: 'Color Choice',
|
|
111
|
+
cases: [],
|
|
112
|
+
categories: [
|
|
113
|
+
{
|
|
114
|
+
uuid: 'cat-all',
|
|
115
|
+
name: 'All Responses',
|
|
116
|
+
exit_uuid: 'exit-all'
|
|
117
|
+
}
|
|
118
|
+
],
|
|
119
|
+
default_category_uuid: 'cat-all'
|
|
120
|
+
},
|
|
121
|
+
exits: [{ uuid: 'exit-all', destination_uuid: null }]
|
|
122
|
+
};
|
|
123
|
+
const formData = split_by_expression.toFormData(node);
|
|
124
|
+
expect(formData.result_name).to.equal('Color Choice');
|
|
125
|
+
});
|
|
126
|
+
it('should handle zero-operand operators', () => {
|
|
127
|
+
const node = {
|
|
128
|
+
uuid: 'test-node-uuid',
|
|
129
|
+
actions: [],
|
|
130
|
+
router: {
|
|
131
|
+
type: 'switch',
|
|
132
|
+
operand: '@input.text',
|
|
133
|
+
cases: [
|
|
134
|
+
{
|
|
135
|
+
uuid: 'case-1',
|
|
136
|
+
type: 'has_number',
|
|
137
|
+
arguments: [],
|
|
138
|
+
category_uuid: 'cat-1'
|
|
139
|
+
}
|
|
140
|
+
],
|
|
141
|
+
categories: [
|
|
142
|
+
{ uuid: 'cat-1', name: 'Has Number', exit_uuid: 'exit-1' },
|
|
143
|
+
{ uuid: 'cat-other', name: 'Other', exit_uuid: 'exit-other' }
|
|
144
|
+
],
|
|
145
|
+
default_category_uuid: 'cat-other'
|
|
146
|
+
},
|
|
147
|
+
exits: [
|
|
148
|
+
{ uuid: 'exit-1', destination_uuid: null },
|
|
149
|
+
{ uuid: 'exit-other', destination_uuid: null }
|
|
150
|
+
]
|
|
151
|
+
};
|
|
152
|
+
const formData = split_by_expression.toFormData(node);
|
|
153
|
+
expect(formData.rules).to.have.lengthOf(1);
|
|
154
|
+
expect(formData.rules[0].operator.value).to.equal('has_number');
|
|
155
|
+
expect(formData.rules[0].value1).to.equal('');
|
|
156
|
+
expect(formData.rules[0].value2).to.equal('');
|
|
157
|
+
});
|
|
158
|
+
});
|
|
159
|
+
describe('fromFormData', () => {
|
|
160
|
+
it('should transform form data with rules to node correctly', () => {
|
|
161
|
+
const formData = {
|
|
162
|
+
uuid: 'test-node-uuid',
|
|
163
|
+
operand: '@fields.age',
|
|
164
|
+
rules: [
|
|
165
|
+
{
|
|
166
|
+
operator: {
|
|
167
|
+
value: 'has_number_gte',
|
|
168
|
+
name: 'has a number at or above'
|
|
169
|
+
},
|
|
170
|
+
value1: '18',
|
|
171
|
+
value2: '',
|
|
172
|
+
category: 'Adult'
|
|
173
|
+
},
|
|
174
|
+
{
|
|
175
|
+
operator: {
|
|
176
|
+
value: 'has_number_between',
|
|
177
|
+
name: 'has a number between'
|
|
178
|
+
},
|
|
179
|
+
value1: '13',
|
|
180
|
+
value2: '17',
|
|
181
|
+
category: 'Teen'
|
|
182
|
+
}
|
|
183
|
+
],
|
|
184
|
+
result_name: ''
|
|
185
|
+
};
|
|
186
|
+
const originalNode = {
|
|
187
|
+
uuid: 'test-node-uuid',
|
|
188
|
+
actions: [],
|
|
189
|
+
router: {
|
|
190
|
+
type: 'switch',
|
|
191
|
+
operand: '@input.text',
|
|
192
|
+
cases: [],
|
|
193
|
+
categories: [],
|
|
194
|
+
default_category_uuid: ''
|
|
195
|
+
},
|
|
196
|
+
exits: []
|
|
197
|
+
};
|
|
198
|
+
const resultNode = split_by_expression.fromFormData(formData, originalNode);
|
|
199
|
+
expect(resultNode.uuid).to.equal('test-node-uuid');
|
|
200
|
+
expect(resultNode.router).to.exist;
|
|
201
|
+
expect(resultNode.router.operand).to.equal('@fields.age');
|
|
202
|
+
expect(resultNode.router.type).to.equal('switch');
|
|
203
|
+
expect(resultNode.router.cases).to.have.lengthOf(2);
|
|
204
|
+
expect(resultNode.router.categories).to.have.lengthOf(3); // 2 rules + Other
|
|
205
|
+
// Check first case
|
|
206
|
+
const case1 = resultNode.router.cases[0];
|
|
207
|
+
expect(case1.type).to.equal('has_number_gte');
|
|
208
|
+
expect(case1.arguments).to.deep.equal(['18']);
|
|
209
|
+
// Check second case (should split into two arguments)
|
|
210
|
+
const case2 = resultNode.router.cases[1];
|
|
211
|
+
expect(case2.type).to.equal('has_number_between');
|
|
212
|
+
expect(case2.arguments).to.deep.equal(['13', '17']);
|
|
213
|
+
// Check categories
|
|
214
|
+
const adultCategory = resultNode.router.categories.find((cat) => cat.name === 'Adult');
|
|
215
|
+
expect(adultCategory).to.exist;
|
|
216
|
+
const teenCategory = resultNode.router.categories.find((cat) => cat.name === 'Teen');
|
|
217
|
+
expect(teenCategory).to.exist;
|
|
218
|
+
const otherCategory = resultNode.router.categories.find((cat) => cat.name === 'Other');
|
|
219
|
+
expect(otherCategory).to.exist;
|
|
220
|
+
// Check exits match categories
|
|
221
|
+
expect(resultNode.exits).to.have.lengthOf(3);
|
|
222
|
+
});
|
|
223
|
+
it('should handle empty rules', () => {
|
|
224
|
+
const formData = {
|
|
225
|
+
uuid: 'test-node-uuid',
|
|
226
|
+
operand: '@fields.status',
|
|
227
|
+
rules: [],
|
|
228
|
+
result_name: ''
|
|
229
|
+
};
|
|
230
|
+
const originalNode = {
|
|
231
|
+
uuid: 'test-node-uuid',
|
|
232
|
+
actions: [],
|
|
233
|
+
router: {
|
|
234
|
+
type: 'switch',
|
|
235
|
+
operand: '@input.text',
|
|
236
|
+
cases: [],
|
|
237
|
+
categories: [],
|
|
238
|
+
default_category_uuid: ''
|
|
239
|
+
},
|
|
240
|
+
exits: []
|
|
241
|
+
};
|
|
242
|
+
const resultNode = split_by_expression.fromFormData(formData, originalNode);
|
|
243
|
+
expect(resultNode.router).to.exist;
|
|
244
|
+
expect(resultNode.router.operand).to.equal('@fields.status');
|
|
245
|
+
expect(resultNode.router.cases).to.have.lengthOf(0);
|
|
246
|
+
expect(resultNode.router.categories).to.have.lengthOf(1);
|
|
247
|
+
expect(resultNode.router.categories[0].name).to.equal('All Responses');
|
|
248
|
+
});
|
|
249
|
+
it('should preserve UUIDs when editing existing node', () => {
|
|
250
|
+
const existingNode = {
|
|
251
|
+
uuid: 'test-node-uuid',
|
|
252
|
+
actions: [],
|
|
253
|
+
router: {
|
|
254
|
+
type: 'switch',
|
|
255
|
+
operand: '@fields.age',
|
|
256
|
+
cases: [
|
|
257
|
+
{
|
|
258
|
+
uuid: 'existing-case-1',
|
|
259
|
+
type: 'has_number_gte',
|
|
260
|
+
arguments: ['18'],
|
|
261
|
+
category_uuid: 'existing-cat-1'
|
|
262
|
+
}
|
|
263
|
+
],
|
|
264
|
+
categories: [
|
|
265
|
+
{
|
|
266
|
+
uuid: 'existing-cat-1',
|
|
267
|
+
name: 'Adult',
|
|
268
|
+
exit_uuid: 'existing-exit-1'
|
|
269
|
+
},
|
|
270
|
+
{
|
|
271
|
+
uuid: 'existing-cat-other',
|
|
272
|
+
name: 'Other',
|
|
273
|
+
exit_uuid: 'existing-exit-other'
|
|
274
|
+
}
|
|
275
|
+
],
|
|
276
|
+
default_category_uuid: 'existing-cat-other'
|
|
277
|
+
},
|
|
278
|
+
exits: [
|
|
279
|
+
{ uuid: 'existing-exit-1', destination_uuid: 'next-node-1' },
|
|
280
|
+
{ uuid: 'existing-exit-other', destination_uuid: 'next-node-2' }
|
|
281
|
+
]
|
|
282
|
+
};
|
|
283
|
+
const formData = {
|
|
284
|
+
uuid: 'test-node-uuid',
|
|
285
|
+
operand: '@fields.age',
|
|
286
|
+
rules: [
|
|
287
|
+
{
|
|
288
|
+
operator: {
|
|
289
|
+
value: 'has_number_gte',
|
|
290
|
+
name: 'has a number at or above'
|
|
291
|
+
},
|
|
292
|
+
value1: '18',
|
|
293
|
+
value2: '',
|
|
294
|
+
category: 'Adult'
|
|
295
|
+
}
|
|
296
|
+
],
|
|
297
|
+
result_name: ''
|
|
298
|
+
};
|
|
299
|
+
const resultNode = split_by_expression.fromFormData(formData, existingNode);
|
|
300
|
+
// Check that UUIDs are preserved
|
|
301
|
+
const adultCategory = resultNode.router.categories.find((cat) => cat.name === 'Adult');
|
|
302
|
+
expect(adultCategory.uuid).to.equal('existing-cat-1');
|
|
303
|
+
expect(adultCategory.exit_uuid).to.equal('existing-exit-1');
|
|
304
|
+
// Check that destination_uuid is preserved
|
|
305
|
+
const adultExit = resultNode.exits.find((exit) => exit.uuid === 'existing-exit-1');
|
|
306
|
+
expect(adultExit.destination_uuid).to.equal('next-node-1');
|
|
307
|
+
// Check Other category UUID is preserved
|
|
308
|
+
const otherCategory = resultNode.router.categories.find((cat) => cat.name === 'Other');
|
|
309
|
+
expect(otherCategory.uuid).to.equal('existing-cat-other');
|
|
310
|
+
});
|
|
311
|
+
it('should handle multiple rules with same category', () => {
|
|
312
|
+
const formData = {
|
|
313
|
+
uuid: 'test-node-uuid',
|
|
314
|
+
operand: '@fields.color',
|
|
315
|
+
rules: [
|
|
316
|
+
{
|
|
317
|
+
operator: { value: 'has_any_word', name: 'has any of the words' },
|
|
318
|
+
value1: 'red',
|
|
319
|
+
value2: '',
|
|
320
|
+
category: 'Warm'
|
|
321
|
+
},
|
|
322
|
+
{
|
|
323
|
+
operator: { value: 'has_any_word', name: 'has any of the words' },
|
|
324
|
+
value1: 'orange',
|
|
325
|
+
value2: '',
|
|
326
|
+
category: 'Warm'
|
|
327
|
+
},
|
|
328
|
+
{
|
|
329
|
+
operator: { value: 'has_any_word', name: 'has any of the words' },
|
|
330
|
+
value1: 'blue',
|
|
331
|
+
value2: '',
|
|
332
|
+
category: 'Cool'
|
|
333
|
+
}
|
|
334
|
+
],
|
|
335
|
+
result_name: ''
|
|
336
|
+
};
|
|
337
|
+
const originalNode = {
|
|
338
|
+
uuid: 'test-node-uuid',
|
|
339
|
+
actions: [],
|
|
340
|
+
router: {
|
|
341
|
+
type: 'switch',
|
|
342
|
+
operand: '@input.text',
|
|
343
|
+
cases: [],
|
|
344
|
+
categories: [],
|
|
345
|
+
default_category_uuid: ''
|
|
346
|
+
},
|
|
347
|
+
exits: []
|
|
348
|
+
};
|
|
349
|
+
const resultNode = split_by_expression.fromFormData(formData, originalNode);
|
|
350
|
+
// Should have 3 cases but only 3 categories (Warm, Cool, Other)
|
|
351
|
+
expect(resultNode.router.cases).to.have.lengthOf(3);
|
|
352
|
+
expect(resultNode.router.categories).to.have.lengthOf(3);
|
|
353
|
+
// Check that both "Warm" rules point to the same category
|
|
354
|
+
const warmCategory = resultNode.router.categories.find((cat) => cat.name === 'Warm');
|
|
355
|
+
expect(warmCategory).to.exist;
|
|
356
|
+
const warmCases = resultNode.router.cases.filter((case_) => case_.category_uuid === warmCategory.uuid);
|
|
357
|
+
expect(warmCases).to.have.lengthOf(2);
|
|
358
|
+
// Should only have 3 exits (Warm, Cool, Other)
|
|
359
|
+
expect(resultNode.exits).to.have.lengthOf(3);
|
|
360
|
+
});
|
|
361
|
+
it('should handle result_name in fromFormData', () => {
|
|
362
|
+
const formData = {
|
|
363
|
+
uuid: 'test-node-uuid',
|
|
364
|
+
operand: '@fields.priority',
|
|
365
|
+
rules: [],
|
|
366
|
+
result_name: 'Priority Level'
|
|
367
|
+
};
|
|
368
|
+
const originalNode = {
|
|
369
|
+
uuid: 'test-node-uuid',
|
|
370
|
+
actions: [],
|
|
371
|
+
router: {
|
|
372
|
+
type: 'switch',
|
|
373
|
+
operand: '@input.text',
|
|
374
|
+
cases: [],
|
|
375
|
+
categories: [],
|
|
376
|
+
default_category_uuid: ''
|
|
377
|
+
},
|
|
378
|
+
exits: []
|
|
379
|
+
};
|
|
380
|
+
const resultNode = split_by_expression.fromFormData(formData, originalNode);
|
|
381
|
+
expect(resultNode.router.result_name).to.equal('Priority Level');
|
|
382
|
+
});
|
|
383
|
+
it('should not set result_name if empty', () => {
|
|
384
|
+
const formData = {
|
|
385
|
+
uuid: 'test-node-uuid',
|
|
386
|
+
operand: '@fields.status',
|
|
387
|
+
rules: [],
|
|
388
|
+
result_name: ''
|
|
389
|
+
};
|
|
390
|
+
const originalNode = {
|
|
391
|
+
uuid: 'test-node-uuid',
|
|
392
|
+
actions: [],
|
|
393
|
+
router: {
|
|
394
|
+
type: 'switch',
|
|
395
|
+
operand: '@input.text',
|
|
396
|
+
cases: [],
|
|
397
|
+
categories: [],
|
|
398
|
+
default_category_uuid: ''
|
|
399
|
+
},
|
|
400
|
+
exits: []
|
|
401
|
+
};
|
|
402
|
+
const resultNode = split_by_expression.fromFormData(formData, originalNode);
|
|
403
|
+
expect(resultNode.router.result_name).to.be.undefined;
|
|
404
|
+
});
|
|
405
|
+
it('should handle zero-operand operators in fromFormData', () => {
|
|
406
|
+
const formData = {
|
|
407
|
+
uuid: 'test-node-uuid',
|
|
408
|
+
operand: '@input.text',
|
|
409
|
+
rules: [
|
|
410
|
+
{
|
|
411
|
+
operator: { value: 'has_number', name: 'has a number' },
|
|
412
|
+
value1: '',
|
|
413
|
+
value2: '',
|
|
414
|
+
category: 'Has Number'
|
|
415
|
+
}
|
|
416
|
+
],
|
|
417
|
+
result_name: ''
|
|
418
|
+
};
|
|
419
|
+
const originalNode = {
|
|
420
|
+
uuid: 'test-node-uuid',
|
|
421
|
+
actions: [],
|
|
422
|
+
router: {
|
|
423
|
+
type: 'switch',
|
|
424
|
+
operand: '@input.text',
|
|
425
|
+
cases: [],
|
|
426
|
+
categories: [],
|
|
427
|
+
default_category_uuid: ''
|
|
428
|
+
},
|
|
429
|
+
exits: []
|
|
430
|
+
};
|
|
431
|
+
const resultNode = split_by_expression.fromFormData(formData, originalNode);
|
|
432
|
+
expect(resultNode.router.cases).to.have.lengthOf(1);
|
|
433
|
+
expect(resultNode.router.cases[0].type).to.equal('has_number');
|
|
434
|
+
expect(resultNode.router.cases[0].arguments).to.deep.equal([]);
|
|
435
|
+
});
|
|
436
|
+
it('should filter out incomplete rules', () => {
|
|
437
|
+
const formData = {
|
|
438
|
+
uuid: 'test-node-uuid',
|
|
439
|
+
operand: '@fields.age',
|
|
440
|
+
rules: [
|
|
441
|
+
{
|
|
442
|
+
operator: {
|
|
443
|
+
value: 'has_number_gte',
|
|
444
|
+
name: 'has a number at or above'
|
|
445
|
+
},
|
|
446
|
+
value1: '18',
|
|
447
|
+
value2: '',
|
|
448
|
+
category: 'Adult'
|
|
449
|
+
},
|
|
450
|
+
{
|
|
451
|
+
operator: { value: 'has_number_lt', name: 'has a number below' },
|
|
452
|
+
value1: '', // Missing value1
|
|
453
|
+
value2: '',
|
|
454
|
+
category: 'Child'
|
|
455
|
+
},
|
|
456
|
+
{
|
|
457
|
+
operator: {
|
|
458
|
+
value: 'has_number_between',
|
|
459
|
+
name: 'has a number between'
|
|
460
|
+
},
|
|
461
|
+
value1: '10',
|
|
462
|
+
value2: '', // Missing value2 for 2-operand operator
|
|
463
|
+
category: 'Teen'
|
|
464
|
+
}
|
|
465
|
+
],
|
|
466
|
+
result_name: ''
|
|
467
|
+
};
|
|
468
|
+
const originalNode = {
|
|
469
|
+
uuid: 'test-node-uuid',
|
|
470
|
+
actions: [],
|
|
471
|
+
router: {
|
|
472
|
+
type: 'switch',
|
|
473
|
+
operand: '@input.text',
|
|
474
|
+
cases: [],
|
|
475
|
+
categories: [],
|
|
476
|
+
default_category_uuid: ''
|
|
477
|
+
},
|
|
478
|
+
exits: []
|
|
479
|
+
};
|
|
480
|
+
const resultNode = split_by_expression.fromFormData(formData, originalNode);
|
|
481
|
+
// Only the first complete rule should be included
|
|
482
|
+
expect(resultNode.router.cases).to.have.lengthOf(1);
|
|
483
|
+
expect(resultNode.router.cases[0].type).to.equal('has_number_gte');
|
|
484
|
+
expect(resultNode.router.categories).to.have.lengthOf(2); // Adult + Other
|
|
485
|
+
});
|
|
486
|
+
it('should handle string operator format', () => {
|
|
487
|
+
const formData = {
|
|
488
|
+
uuid: 'test-node-uuid',
|
|
489
|
+
operand: '@fields.name',
|
|
490
|
+
rules: [
|
|
491
|
+
{
|
|
492
|
+
operator: 'has_any_word', // String format instead of object
|
|
493
|
+
value1: 'john',
|
|
494
|
+
value2: '',
|
|
495
|
+
category: 'Name'
|
|
496
|
+
}
|
|
497
|
+
],
|
|
498
|
+
result_name: ''
|
|
499
|
+
};
|
|
500
|
+
const originalNode = {
|
|
501
|
+
uuid: 'test-node-uuid',
|
|
502
|
+
actions: [],
|
|
503
|
+
router: {
|
|
504
|
+
type: 'switch',
|
|
505
|
+
operand: '@input.text',
|
|
506
|
+
cases: [],
|
|
507
|
+
categories: [],
|
|
508
|
+
default_category_uuid: ''
|
|
509
|
+
},
|
|
510
|
+
exits: []
|
|
511
|
+
};
|
|
512
|
+
const resultNode = split_by_expression.fromFormData(formData, originalNode);
|
|
513
|
+
expect(resultNode.router.cases).to.have.lengthOf(1);
|
|
514
|
+
expect(resultNode.router.cases[0].type).to.equal('has_any_word');
|
|
515
|
+
expect(resultNode.router.cases[0].arguments).to.deep.equal(['john']);
|
|
516
|
+
});
|
|
517
|
+
it('should default operand to @input.text if not provided', () => {
|
|
518
|
+
const formData = {
|
|
519
|
+
uuid: 'test-node-uuid',
|
|
520
|
+
operand: '', // Empty operand
|
|
521
|
+
rules: [],
|
|
522
|
+
result_name: ''
|
|
523
|
+
};
|
|
524
|
+
const originalNode = {
|
|
525
|
+
uuid: 'test-node-uuid',
|
|
526
|
+
actions: [],
|
|
527
|
+
router: {
|
|
528
|
+
type: 'switch',
|
|
529
|
+
operand: '@input.text',
|
|
530
|
+
cases: [],
|
|
531
|
+
categories: [],
|
|
532
|
+
default_category_uuid: ''
|
|
533
|
+
},
|
|
534
|
+
exits: []
|
|
535
|
+
};
|
|
536
|
+
const resultNode = split_by_expression.fromFormData(formData, originalNode);
|
|
537
|
+
expect(resultNode.router.operand).to.equal('@input.text');
|
|
538
|
+
});
|
|
539
|
+
});
|
|
540
|
+
describe('validate', () => {
|
|
541
|
+
it('should validate that operand is required', () => {
|
|
542
|
+
const formData = {
|
|
543
|
+
operand: '',
|
|
544
|
+
rules: []
|
|
545
|
+
};
|
|
546
|
+
const result = split_by_expression.validate(formData);
|
|
547
|
+
expect(result.valid).to.be.false;
|
|
548
|
+
expect(result.errors.operand).to.exist;
|
|
549
|
+
});
|
|
550
|
+
it('should validate successfully with operand', () => {
|
|
551
|
+
const formData = {
|
|
552
|
+
operand: '@fields.age',
|
|
553
|
+
rules: []
|
|
554
|
+
};
|
|
555
|
+
const result = split_by_expression.validate(formData);
|
|
556
|
+
expect(result.valid).to.be.true;
|
|
557
|
+
expect(Object.keys(result.errors)).to.have.lengthOf(0);
|
|
558
|
+
});
|
|
559
|
+
});
|
|
560
|
+
describe('round-trip transformation', () => {
|
|
561
|
+
it('should preserve node structure through toFormData -> fromFormData', () => {
|
|
562
|
+
const originalNode = {
|
|
563
|
+
uuid: 'test-node-uuid',
|
|
564
|
+
actions: [],
|
|
565
|
+
router: {
|
|
566
|
+
type: 'switch',
|
|
567
|
+
operand: '@fields.temperature',
|
|
568
|
+
result_name: 'Temp Category',
|
|
569
|
+
cases: [
|
|
570
|
+
{
|
|
571
|
+
uuid: 'case-hot',
|
|
572
|
+
type: 'has_number_gt',
|
|
573
|
+
arguments: ['30'],
|
|
574
|
+
category_uuid: 'cat-hot'
|
|
575
|
+
},
|
|
576
|
+
{
|
|
577
|
+
uuid: 'case-cold',
|
|
578
|
+
type: 'has_number_lt',
|
|
579
|
+
arguments: ['10'],
|
|
580
|
+
category_uuid: 'cat-cold'
|
|
581
|
+
}
|
|
582
|
+
],
|
|
583
|
+
categories: [
|
|
584
|
+
{ uuid: 'cat-hot', name: 'Hot', exit_uuid: 'exit-hot' },
|
|
585
|
+
{ uuid: 'cat-cold', name: 'Cold', exit_uuid: 'exit-cold' },
|
|
586
|
+
{ uuid: 'cat-other', name: 'Other', exit_uuid: 'exit-other' }
|
|
587
|
+
],
|
|
588
|
+
default_category_uuid: 'cat-other'
|
|
589
|
+
},
|
|
590
|
+
exits: [
|
|
591
|
+
{ uuid: 'exit-hot', destination_uuid: 'next-1' },
|
|
592
|
+
{ uuid: 'exit-cold', destination_uuid: 'next-2' },
|
|
593
|
+
{ uuid: 'exit-other', destination_uuid: 'next-3' }
|
|
594
|
+
]
|
|
595
|
+
};
|
|
596
|
+
const formData = split_by_expression.toFormData(originalNode);
|
|
597
|
+
const resultNode = split_by_expression.fromFormData(formData, originalNode);
|
|
598
|
+
// Check basic structure
|
|
599
|
+
expect(resultNode.uuid).to.equal(originalNode.uuid);
|
|
600
|
+
expect(resultNode.router.operand).to.equal(originalNode.router.operand);
|
|
601
|
+
expect(resultNode.router.result_name).to.equal(originalNode.router.result_name);
|
|
602
|
+
// Check that all UUIDs are preserved
|
|
603
|
+
expect(resultNode.router.categories).to.have.lengthOf(3);
|
|
604
|
+
expect(resultNode.exits).to.have.lengthOf(3);
|
|
605
|
+
const hotCategory = resultNode.router.categories.find((cat) => cat.name === 'Hot');
|
|
606
|
+
expect(hotCategory.uuid).to.equal('cat-hot');
|
|
607
|
+
expect(hotCategory.exit_uuid).to.equal('exit-hot');
|
|
608
|
+
// Check destinations are preserved
|
|
609
|
+
const hotExit = resultNode.exits.find((exit) => exit.uuid === 'exit-hot');
|
|
610
|
+
expect(hotExit.destination_uuid).to.equal('next-1');
|
|
611
|
+
});
|
|
612
|
+
});
|
|
613
|
+
});
|
|
614
|
+
//# sourceMappingURL=split_by_expression.test.js.map
|