@nyaruka/temba-components 0.139.0 → 0.141.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.github/workflows/cla.yml +1 -1
- package/.github/workflows/copilot-setup-steps.yml +6 -1
- package/.lintstagedrc.js +10 -0
- package/CHANGELOG.md +32 -0
- package/demo/data/flows/sample-flow.json +24 -0
- package/dist/locales/es.js +5 -5
- package/dist/locales/es.js.map +1 -1
- package/dist/locales/fr.js +5 -5
- package/dist/locales/fr.js.map +1 -1
- package/dist/locales/locale-codes.js +11 -2
- package/dist/locales/locale-codes.js.map +1 -1
- package/dist/locales/pt.js +5 -5
- package/dist/locales/pt.js.map +1 -1
- package/dist/temba-components.js +702 -338
- package/dist/temba-components.js.map +1 -1
- package/out-tsc/src/display/Chat.js +10 -7
- package/out-tsc/src/display/Chat.js.map +1 -1
- package/out-tsc/src/display/Dropdown.js +3 -1
- package/out-tsc/src/display/Dropdown.js.map +1 -1
- package/out-tsc/src/display/FloatingTab.js +4 -4
- package/out-tsc/src/display/FloatingTab.js.map +1 -1
- package/out-tsc/src/display/Thumbnail.js +163 -5
- package/out-tsc/src/display/Thumbnail.js.map +1 -1
- package/out-tsc/src/flow/CanvasNode.js +65 -23
- package/out-tsc/src/flow/CanvasNode.js.map +1 -1
- package/out-tsc/src/flow/Editor.js +369 -49
- package/out-tsc/src/flow/Editor.js.map +1 -1
- package/out-tsc/src/flow/NodeEditor.js +118 -10
- package/out-tsc/src/flow/NodeEditor.js.map +1 -1
- package/out-tsc/src/flow/Plumber.js +61 -14
- package/out-tsc/src/flow/Plumber.js.map +1 -1
- package/out-tsc/src/flow/StickyNote.js +13 -4
- package/out-tsc/src/flow/StickyNote.js.map +1 -1
- package/out-tsc/src/flow/actions/add_contact_groups.js +4 -1
- package/out-tsc/src/flow/actions/add_contact_groups.js.map +1 -1
- package/out-tsc/src/flow/actions/add_input_labels.js +4 -1
- package/out-tsc/src/flow/actions/add_input_labels.js.map +1 -1
- package/out-tsc/src/flow/actions/audio-player.js +112 -0
- package/out-tsc/src/flow/actions/audio-player.js.map +1 -0
- package/out-tsc/src/flow/actions/enter_flow.js +43 -0
- package/out-tsc/src/flow/actions/enter_flow.js.map +1 -0
- package/out-tsc/src/flow/actions/play_audio.js +57 -4
- package/out-tsc/src/flow/actions/play_audio.js.map +1 -1
- package/out-tsc/src/flow/actions/remove_contact_groups.js +6 -1
- package/out-tsc/src/flow/actions/remove_contact_groups.js.map +1 -1
- package/out-tsc/src/flow/actions/say_msg.js +86 -3
- package/out-tsc/src/flow/actions/say_msg.js.map +1 -1
- package/out-tsc/src/flow/actions/send_broadcast.js +6 -2
- package/out-tsc/src/flow/actions/send_broadcast.js.map +1 -1
- package/out-tsc/src/flow/actions/set_contact_channel.js +13 -0
- package/out-tsc/src/flow/actions/set_contact_channel.js.map +1 -1
- package/out-tsc/src/flow/actions/set_contact_status.js +7 -5
- package/out-tsc/src/flow/actions/set_contact_status.js.map +1 -1
- package/out-tsc/src/flow/actions/start_session.js +10 -3
- package/out-tsc/src/flow/actions/start_session.js.map +1 -1
- package/out-tsc/src/flow/config.js +11 -3
- package/out-tsc/src/flow/config.js.map +1 -1
- package/out-tsc/src/flow/nodes/shared-rules.js +1 -1
- package/out-tsc/src/flow/nodes/shared-rules.js.map +1 -1
- package/out-tsc/src/flow/nodes/split_by_contact_field.js +18 -5
- package/out-tsc/src/flow/nodes/split_by_contact_field.js.map +1 -1
- package/out-tsc/src/flow/nodes/split_by_expression.js +1 -1
- package/out-tsc/src/flow/nodes/split_by_expression.js.map +1 -1
- package/out-tsc/src/flow/nodes/split_by_llm_categorize.js +0 -1
- package/out-tsc/src/flow/nodes/split_by_llm_categorize.js.map +1 -1
- package/out-tsc/src/flow/nodes/split_by_random.js +0 -1
- package/out-tsc/src/flow/nodes/split_by_random.js.map +1 -1
- package/out-tsc/src/flow/nodes/split_by_run_result.js +10 -4
- package/out-tsc/src/flow/nodes/split_by_run_result.js.map +1 -1
- package/out-tsc/src/flow/nodes/terminal.js +7 -0
- package/out-tsc/src/flow/nodes/terminal.js.map +1 -0
- package/out-tsc/src/flow/nodes/wait_for_audio.js +77 -0
- package/out-tsc/src/flow/nodes/wait_for_audio.js.map +1 -0
- package/out-tsc/src/flow/nodes/wait_for_dial.js +151 -0
- package/out-tsc/src/flow/nodes/wait_for_dial.js.map +1 -0
- package/out-tsc/src/flow/nodes/wait_for_digits.js +61 -1
- package/out-tsc/src/flow/nodes/wait_for_digits.js.map +1 -1
- package/out-tsc/src/flow/nodes/wait_for_menu.js +173 -2
- package/out-tsc/src/flow/nodes/wait_for_menu.js.map +1 -1
- package/out-tsc/src/flow/nodes/wait_for_response.js +1 -1
- package/out-tsc/src/flow/nodes/wait_for_response.js.map +1 -1
- package/out-tsc/src/flow/operators.js +21 -5
- package/out-tsc/src/flow/operators.js.map +1 -1
- package/out-tsc/src/flow/types.js.map +1 -1
- package/out-tsc/src/flow/utils.js +79 -3
- package/out-tsc/src/flow/utils.js.map +1 -1
- package/out-tsc/src/form/ArrayEditor.js +4 -2
- package/out-tsc/src/form/ArrayEditor.js.map +1 -1
- package/out-tsc/src/form/FieldRenderer.js +56 -0
- package/out-tsc/src/form/FieldRenderer.js.map +1 -1
- package/out-tsc/src/interfaces.js +1 -0
- package/out-tsc/src/interfaces.js.map +1 -1
- package/out-tsc/src/layout/Dialog.js +51 -7
- package/out-tsc/src/layout/Dialog.js.map +1 -1
- package/out-tsc/src/layout/Modax.js +20 -2
- package/out-tsc/src/layout/Modax.js.map +1 -1
- package/out-tsc/src/list/ContentMenu.js +14 -1
- package/out-tsc/src/list/ContentMenu.js.map +1 -1
- package/out-tsc/src/locales/es.js +5 -5
- package/out-tsc/src/locales/es.js.map +1 -1
- package/out-tsc/src/locales/fr.js +5 -5
- package/out-tsc/src/locales/fr.js.map +1 -1
- package/out-tsc/src/locales/locale-codes.js +11 -2
- package/out-tsc/src/locales/locale-codes.js.map +1 -1
- package/out-tsc/src/locales/pt.js +5 -5
- package/out-tsc/src/locales/pt.js.map +1 -1
- package/out-tsc/src/simulator/Simulator.js +21 -4
- package/out-tsc/src/simulator/Simulator.js.map +1 -1
- package/out-tsc/src/store/AppState.js +102 -3
- package/out-tsc/src/store/AppState.js.map +1 -1
- package/out-tsc/test/actions/add_contact_groups.test.js +35 -0
- package/out-tsc/test/actions/add_contact_groups.test.js.map +1 -1
- package/out-tsc/test/actions/add_input_labels.test.js +53 -0
- package/out-tsc/test/actions/add_input_labels.test.js.map +1 -0
- package/out-tsc/test/actions/enter_flow.test.js +71 -0
- package/out-tsc/test/actions/enter_flow.test.js.map +1 -0
- package/out-tsc/test/actions/play_audio.test.js +118 -0
- package/out-tsc/test/actions/play_audio.test.js.map +1 -0
- package/out-tsc/test/actions/remove_contact_groups.test.js +24 -0
- package/out-tsc/test/actions/remove_contact_groups.test.js.map +1 -1
- package/out-tsc/test/actions/say_msg.test.js +158 -0
- package/out-tsc/test/actions/say_msg.test.js.map +1 -0
- package/out-tsc/test/actions/send_broadcast.test.js +41 -0
- package/out-tsc/test/actions/send_broadcast.test.js.map +1 -1
- package/out-tsc/test/actions/set_contact_channel.test.js +67 -0
- package/out-tsc/test/actions/set_contact_channel.test.js.map +1 -0
- package/out-tsc/test/actions/set_contact_field.test.js +52 -0
- package/out-tsc/test/actions/set_contact_field.test.js.map +1 -0
- package/out-tsc/test/actions/set_contact_language.test.js +39 -0
- package/out-tsc/test/actions/set_contact_language.test.js.map +1 -0
- package/out-tsc/test/actions/set_contact_name.test.js +28 -0
- package/out-tsc/test/actions/set_contact_name.test.js.map +1 -0
- package/out-tsc/test/actions/set_contact_status.test.js +44 -0
- package/out-tsc/test/actions/set_contact_status.test.js.map +1 -0
- package/out-tsc/test/actions/set_run_result.test.js +47 -0
- package/out-tsc/test/actions/set_run_result.test.js.map +1 -0
- package/out-tsc/test/actions/start_session.test.js +76 -0
- package/out-tsc/test/actions/start_session.test.js.map +1 -1
- package/out-tsc/test/nodes/split_by_contact_field.test.js +50 -0
- package/out-tsc/test/nodes/split_by_contact_field.test.js.map +1 -1
- package/out-tsc/test/nodes/split_by_run_result.test.js +82 -0
- package/out-tsc/test/nodes/split_by_run_result.test.js.map +1 -1
- package/out-tsc/test/nodes/split_by_ticket.test.js +139 -0
- package/out-tsc/test/nodes/split_by_ticket.test.js.map +1 -0
- package/out-tsc/test/nodes/split_by_webhook.test.js +111 -0
- package/out-tsc/test/nodes/split_by_webhook.test.js.map +1 -0
- package/out-tsc/test/nodes/wait_for_audio.test.js +156 -0
- package/out-tsc/test/nodes/wait_for_audio.test.js.map +1 -0
- package/out-tsc/test/nodes/wait_for_dial.test.js +336 -0
- package/out-tsc/test/nodes/wait_for_dial.test.js.map +1 -0
- package/out-tsc/test/nodes/wait_for_digits.test.js +198 -84
- package/out-tsc/test/nodes/wait_for_digits.test.js.map +1 -1
- package/out-tsc/test/nodes/wait_for_menu.test.js +340 -0
- package/out-tsc/test/nodes/wait_for_menu.test.js.map +1 -0
- package/out-tsc/test/temba-flow-collision.test.js +261 -6
- package/out-tsc/test/temba-flow-collision.test.js.map +1 -1
- package/out-tsc/test/temba-flow-editor.test.js +187 -0
- package/out-tsc/test/temba-flow-editor.test.js.map +1 -1
- package/out-tsc/test/temba-flow-plumber.test.js +19 -0
- package/out-tsc/test/temba-flow-plumber.test.js.map +1 -1
- package/out-tsc/test/temba-node-type-selector.test.js +6 -6
- package/out-tsc/test/temba-node-type-selector.test.js.map +1 -1
- package/out-tsc/test/temba-select.test.js +4 -1
- package/out-tsc/test/temba-select.test.js.map +1 -1
- package/out-tsc/test/utils.test.js +4 -2
- package/out-tsc/test/utils.test.js.map +1 -1
- package/package.json +3 -9
- 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/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/add_input_labels/editor/multiple-labels.png +0 -0
- package/screenshots/truth/actions/add_input_labels/editor/single-label.png +0 -0
- package/screenshots/truth/actions/add_input_labels/render/multiple-labels.png +0 -0
- package/screenshots/truth/actions/add_input_labels/render/single-label.png +0 -0
- package/screenshots/truth/actions/enter_flow/editor/basic-flow.png +0 -0
- package/screenshots/truth/actions/enter_flow/editor/long-flow-name.png +0 -0
- package/screenshots/truth/actions/enter_flow/render/basic-flow.png +0 -0
- package/screenshots/truth/actions/enter_flow/render/long-flow-name.png +0 -0
- package/screenshots/truth/actions/play_audio/editor/expression-url.png +0 -0
- package/screenshots/truth/actions/play_audio/editor/static-url.png +0 -0
- package/screenshots/truth/actions/play_audio/render/expression-url.png +0 -0
- package/screenshots/truth/actions/play_audio/render/static-url.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/say_msg/editor/multiline-text.png +0 -0
- package/screenshots/truth/actions/say_msg/editor/simple-text.png +0 -0
- package/screenshots/truth/actions/say_msg/editor/text-with-audio-url.png +0 -0
- package/screenshots/truth/actions/say_msg/render/multiline-text.png +0 -0
- package/screenshots/truth/actions/say_msg/render/simple-text.png +0 -0
- package/screenshots/truth/actions/say_msg/render/text-with-audio-url.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_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/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/set_contact_channel/editor/sms-channel.png +0 -0
- package/screenshots/truth/actions/set_contact_channel/editor/whatsapp-channel.png +0 -0
- package/screenshots/truth/actions/set_contact_channel/render/sms-channel.png +0 -0
- package/screenshots/truth/actions/set_contact_channel/render/whatsapp-channel.png +0 -0
- package/screenshots/truth/actions/set_contact_field/editor/clear-value.png +0 -0
- package/screenshots/truth/actions/set_contact_field/editor/set-value.png +0 -0
- package/screenshots/truth/actions/set_contact_field/render/clear-value.png +0 -0
- package/screenshots/truth/actions/set_contact_field/render/set-value.png +0 -0
- package/screenshots/truth/actions/set_contact_language/editor/english.png +0 -0
- package/screenshots/truth/actions/set_contact_language/editor/french.png +0 -0
- package/screenshots/truth/actions/set_contact_language/render/english.png +0 -0
- package/screenshots/truth/actions/set_contact_language/render/french.png +0 -0
- package/screenshots/truth/actions/set_contact_name/editor/expression-name.png +0 -0
- package/screenshots/truth/actions/set_contact_name/editor/static-name.png +0 -0
- package/screenshots/truth/actions/set_contact_name/render/expression-name.png +0 -0
- package/screenshots/truth/actions/set_contact_name/render/static-name.png +0 -0
- package/screenshots/truth/actions/set_contact_status/editor/active.png +0 -0
- package/screenshots/truth/actions/set_contact_status/editor/archived.png +0 -0
- package/screenshots/truth/actions/set_contact_status/editor/blocked.png +0 -0
- package/screenshots/truth/actions/set_contact_status/render/active.png +0 -0
- package/screenshots/truth/actions/set_contact_status/render/archived.png +0 -0
- package/screenshots/truth/actions/set_contact_status/render/blocked.png +0 -0
- package/screenshots/truth/actions/set_run_result/editor/expression-value.png +0 -0
- package/screenshots/truth/actions/set_run_result/editor/with-category.png +0 -0
- package/screenshots/truth/actions/set_run_result/render/expression-value.png +0 -0
- package/screenshots/truth/actions/set_run_result/render/with-category.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/editor/router.png +0 -0
- package/screenshots/truth/editor/wait.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_audio/editor/basic-audio-wait.png +0 -0
- package/screenshots/truth/nodes/wait_for_audio/render/basic-audio-wait.png +0 -0
- package/screenshots/truth/nodes/wait_for_dial/editor/basic-dial.png +0 -0
- package/screenshots/truth/nodes/wait_for_dial/editor/dial-with-limits.png +0 -0
- package/screenshots/truth/nodes/wait_for_dial/render/basic-dial.png +0 -0
- package/screenshots/truth/nodes/wait_for_dial/render/dial-with-limits.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/digits-with-rules.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/digits-with-rules.png +0 -0
- package/screenshots/truth/nodes/wait_for_menu/editor/menu-with-digits.png +0 -0
- package/screenshots/truth/nodes/wait_for_menu/render/menu-with-digits.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/display/Chat.ts +13 -7
- package/src/display/Dropdown.ts +3 -1
- package/src/display/FloatingTab.ts +4 -4
- package/src/display/Thumbnail.ts +162 -2
- package/src/flow/CanvasNode.ts +70 -24
- package/src/flow/Editor.ts +440 -99
- package/src/flow/NodeEditor.ts +137 -9
- package/src/flow/Plumber.ts +89 -14
- package/src/flow/StickyNote.ts +14 -4
- package/src/flow/actions/add_contact_groups.ts +4 -1
- package/src/flow/actions/add_input_labels.ts +4 -1
- package/src/flow/actions/audio-player.ts +127 -0
- package/src/flow/actions/enter_flow.ts +44 -0
- package/src/flow/actions/play_audio.ts +64 -5
- package/src/flow/actions/remove_contact_groups.ts +6 -1
- package/src/flow/actions/say_msg.ts +94 -4
- package/src/flow/actions/send_broadcast.ts +6 -2
- package/src/flow/actions/set_contact_channel.ts +13 -1
- package/src/flow/actions/set_contact_status.ts +7 -5
- package/src/flow/actions/start_session.ts +10 -3
- package/src/flow/config.ts +11 -3
- package/src/flow/nodes/shared-rules.ts +1 -1
- package/src/flow/nodes/split_by_contact_field.ts +16 -5
- package/src/flow/nodes/split_by_expression.ts +1 -1
- package/src/flow/nodes/split_by_llm_categorize.ts +0 -1
- package/src/flow/nodes/split_by_random.ts +0 -1
- package/src/flow/nodes/split_by_run_result.ts +10 -4
- package/src/flow/nodes/terminal.ts +9 -0
- package/src/flow/nodes/wait_for_audio.ts +88 -0
- package/src/flow/nodes/wait_for_dial.ts +176 -0
- package/src/flow/nodes/wait_for_digits.ts +87 -2
- package/src/flow/nodes/wait_for_menu.ts +209 -3
- package/src/flow/nodes/wait_for_response.ts +1 -1
- package/src/flow/operators.ts +23 -5
- package/src/flow/types.ts +23 -1
- package/src/flow/utils.ts +82 -3
- package/src/form/ArrayEditor.ts +4 -2
- package/src/form/FieldRenderer.ts +71 -1
- package/src/interfaces.ts +2 -1
- package/src/layout/Dialog.ts +52 -7
- package/src/layout/Modax.ts +19 -2
- package/src/list/ContentMenu.ts +15 -1
- package/src/locales/es.ts +18 -13
- package/src/locales/fr.ts +18 -13
- package/src/locales/locale-codes.ts +11 -2
- package/src/locales/pt.ts +18 -13
- package/src/simulator/Simulator.ts +25 -4
- package/src/store/AppState.ts +120 -1
- package/src/store/flow-definition.d.ts +2 -0
- package/test/actions/add_contact_groups.test.ts +38 -0
- package/test/actions/add_input_labels.test.ts +67 -0
- package/test/actions/enter_flow.test.ts +88 -0
- package/test/actions/play_audio.test.ts +155 -0
- package/test/actions/remove_contact_groups.test.ts +29 -0
- package/test/actions/say_msg.test.ts +196 -0
- package/test/actions/send_broadcast.test.ts +44 -0
- package/test/actions/set_contact_channel.test.ts +88 -0
- package/test/actions/set_contact_field.test.ts +68 -0
- package/test/actions/set_contact_language.test.ts +55 -0
- package/test/actions/set_contact_name.test.ts +39 -0
- package/test/actions/set_contact_status.test.ts +64 -0
- package/test/actions/set_run_result.test.ts +61 -0
- package/test/actions/start_session.test.ts +82 -0
- package/test/nodes/split_by_contact_field.test.ts +59 -0
- package/test/nodes/split_by_run_result.test.ts +100 -0
- package/test/nodes/split_by_ticket.test.ts +157 -0
- package/test/nodes/split_by_webhook.test.ts +131 -0
- package/test/nodes/wait_for_audio.test.ts +182 -0
- package/test/nodes/wait_for_dial.test.ts +382 -0
- package/test/nodes/wait_for_digits.test.ts +233 -109
- package/test/nodes/wait_for_menu.test.ts +383 -0
- package/test/temba-flow-collision.test.ts +286 -6
- package/test/temba-flow-editor.test.ts +240 -0
- package/test/temba-flow-plumber.test.ts +62 -0
- package/test/temba-node-type-selector.test.ts +6 -6
- package/test/temba-select.test.ts +6 -1
- package/test/utils.test.ts +4 -2
- 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/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
|
@@ -1,8 +1,179 @@
|
|
|
1
1
|
import { SPLIT_GROUPS, FlowTypes } from '../types';
|
|
2
|
+
import { generateUUID } from '../../utils';
|
|
3
|
+
import { resultNameField, categoriesToLocalizationFormData, localizationFormDataToCategories } from './shared';
|
|
4
|
+
// Menu digits in display order: 1-9 then 0
|
|
5
|
+
const MENU_DIGITS = ['1', '2', '3', '4', '5', '6', '7', '8', '9', '0'];
|
|
6
|
+
function digitFieldKey(digit) {
|
|
7
|
+
return `digit_${digit}`;
|
|
8
|
+
}
|
|
2
9
|
export const wait_for_menu = {
|
|
3
10
|
type: 'wait_for_menu',
|
|
4
|
-
name: 'Wait for Menu
|
|
11
|
+
name: 'Wait for Menu',
|
|
5
12
|
group: SPLIT_GROUPS.wait,
|
|
6
|
-
flowTypes: [FlowTypes.VOICE]
|
|
13
|
+
flowTypes: [FlowTypes.VOICE],
|
|
14
|
+
form: {
|
|
15
|
+
...Object.fromEntries(MENU_DIGITS.map((digit) => [
|
|
16
|
+
digitFieldKey(digit),
|
|
17
|
+
{
|
|
18
|
+
type: 'text',
|
|
19
|
+
required: false,
|
|
20
|
+
placeholder: '',
|
|
21
|
+
flavor: 'xsmall'
|
|
22
|
+
}
|
|
23
|
+
])),
|
|
24
|
+
result_name: resultNameField
|
|
25
|
+
},
|
|
26
|
+
layout: [
|
|
27
|
+
{
|
|
28
|
+
type: 'row',
|
|
29
|
+
items: ['digit_1', 'digit_2', 'digit_3'],
|
|
30
|
+
gap: '2rem',
|
|
31
|
+
marginBottom: '0.5rem',
|
|
32
|
+
inlineLabels: { digit_1: '1', digit_2: '2', digit_3: '3' }
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
type: 'row',
|
|
36
|
+
items: ['digit_4', 'digit_5', 'digit_6'],
|
|
37
|
+
gap: '2rem',
|
|
38
|
+
marginBottom: '0.5rem',
|
|
39
|
+
inlineLabels: { digit_4: '4', digit_5: '5', digit_6: '6' }
|
|
40
|
+
},
|
|
41
|
+
{
|
|
42
|
+
type: 'row',
|
|
43
|
+
items: ['digit_7', 'digit_8', 'digit_9'],
|
|
44
|
+
gap: '2rem',
|
|
45
|
+
marginBottom: '0.5rem',
|
|
46
|
+
inlineLabels: { digit_7: '7', digit_8: '8', digit_9: '9' }
|
|
47
|
+
},
|
|
48
|
+
{
|
|
49
|
+
type: 'row',
|
|
50
|
+
items: [
|
|
51
|
+
{ type: 'spacer' },
|
|
52
|
+
'digit_0',
|
|
53
|
+
{ type: 'spacer' }
|
|
54
|
+
],
|
|
55
|
+
gap: '2rem',
|
|
56
|
+
inlineLabels: { digit_0: '0' }
|
|
57
|
+
},
|
|
58
|
+
'result_name'
|
|
59
|
+
],
|
|
60
|
+
toFormData: (node) => {
|
|
61
|
+
var _a, _b, _c, _d;
|
|
62
|
+
const formData = {
|
|
63
|
+
uuid: node.uuid,
|
|
64
|
+
result_name: ((_a = node.router) === null || _a === void 0 ? void 0 : _a.result_name) || ''
|
|
65
|
+
};
|
|
66
|
+
// Initialize all digit fields as empty
|
|
67
|
+
for (const digit of MENU_DIGITS) {
|
|
68
|
+
formData[digitFieldKey(digit)] = '';
|
|
69
|
+
}
|
|
70
|
+
// Fill in category names from cases
|
|
71
|
+
if (((_b = node.router) === null || _b === void 0 ? void 0 : _b.cases) && ((_c = node.router) === null || _c === void 0 ? void 0 : _c.categories)) {
|
|
72
|
+
for (const case_ of node.router.cases) {
|
|
73
|
+
if (case_.type === 'has_number_eq' && ((_d = case_.arguments) === null || _d === void 0 ? void 0 : _d[0])) {
|
|
74
|
+
const digit = case_.arguments[0];
|
|
75
|
+
const category = node.router.categories.find((cat) => cat.uuid === case_.category_uuid);
|
|
76
|
+
if (category && MENU_DIGITS.includes(digit)) {
|
|
77
|
+
formData[digitFieldKey(digit)] = category.name;
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
return formData;
|
|
83
|
+
},
|
|
84
|
+
fromFormData: (formData, originalNode) => {
|
|
85
|
+
var _a, _b;
|
|
86
|
+
const existingCategories = ((_a = originalNode.router) === null || _a === void 0 ? void 0 : _a.categories) || [];
|
|
87
|
+
const existingExits = originalNode.exits || [];
|
|
88
|
+
const existingCases = ((_b = originalNode.router) === null || _b === void 0 ? void 0 : _b.cases) || [];
|
|
89
|
+
const categories = [];
|
|
90
|
+
const exits = [];
|
|
91
|
+
const cases = [];
|
|
92
|
+
// Build categories and cases for each filled digit
|
|
93
|
+
for (const digit of MENU_DIGITS) {
|
|
94
|
+
const categoryName = (formData[digitFieldKey(digit)] || '').trim();
|
|
95
|
+
if (!categoryName)
|
|
96
|
+
continue;
|
|
97
|
+
// Check if a category with this name already exists in our new list
|
|
98
|
+
let category = categories.find((c) => c.name === categoryName);
|
|
99
|
+
if (!category) {
|
|
100
|
+
// Try to find existing category with same name to preserve UUIDs
|
|
101
|
+
const existingCat = existingCategories.find((c) => c.name === categoryName);
|
|
102
|
+
if (existingCat) {
|
|
103
|
+
category = existingCat;
|
|
104
|
+
const existingExit = existingExits.find((e) => e.uuid === existingCat.exit_uuid);
|
|
105
|
+
categories.push(category);
|
|
106
|
+
exits.push(existingExit || {
|
|
107
|
+
uuid: existingCat.exit_uuid,
|
|
108
|
+
destination_uuid: null
|
|
109
|
+
});
|
|
110
|
+
}
|
|
111
|
+
else {
|
|
112
|
+
const exitUuid = generateUUID();
|
|
113
|
+
category = {
|
|
114
|
+
uuid: generateUUID(),
|
|
115
|
+
name: categoryName,
|
|
116
|
+
exit_uuid: exitUuid
|
|
117
|
+
};
|
|
118
|
+
categories.push(category);
|
|
119
|
+
exits.push({ uuid: exitUuid, destination_uuid: null });
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
// Find existing case for this digit to preserve UUID
|
|
123
|
+
const existingCase = existingCases.find((c) => { var _a; return c.type === 'has_number_eq' && ((_a = c.arguments) === null || _a === void 0 ? void 0 : _a[0]) === digit; });
|
|
124
|
+
cases.push({
|
|
125
|
+
uuid: (existingCase === null || existingCase === void 0 ? void 0 : existingCase.uuid) || generateUUID(),
|
|
126
|
+
type: 'has_number_eq',
|
|
127
|
+
arguments: [digit],
|
|
128
|
+
category_uuid: category.uuid
|
|
129
|
+
});
|
|
130
|
+
}
|
|
131
|
+
// Add "Other" default category
|
|
132
|
+
const existingOther = existingCategories.find((c) => c.name === 'Other');
|
|
133
|
+
let otherCategory;
|
|
134
|
+
if (existingOther) {
|
|
135
|
+
otherCategory = existingOther;
|
|
136
|
+
const existingExit = existingExits.find((e) => e.uuid === existingOther.exit_uuid);
|
|
137
|
+
exits.push(existingExit || {
|
|
138
|
+
uuid: existingOther.exit_uuid,
|
|
139
|
+
destination_uuid: null
|
|
140
|
+
});
|
|
141
|
+
}
|
|
142
|
+
else {
|
|
143
|
+
const exitUuid = generateUUID();
|
|
144
|
+
otherCategory = {
|
|
145
|
+
uuid: generateUUID(),
|
|
146
|
+
name: 'Other',
|
|
147
|
+
exit_uuid: exitUuid
|
|
148
|
+
};
|
|
149
|
+
exits.push({ uuid: exitUuid, destination_uuid: null });
|
|
150
|
+
}
|
|
151
|
+
categories.push(otherCategory);
|
|
152
|
+
const router = {
|
|
153
|
+
type: 'switch',
|
|
154
|
+
operand: '@input.text',
|
|
155
|
+
default_category_uuid: otherCategory.uuid,
|
|
156
|
+
cases,
|
|
157
|
+
categories,
|
|
158
|
+
wait: {
|
|
159
|
+
type: 'msg',
|
|
160
|
+
hint: {
|
|
161
|
+
type: 'digits',
|
|
162
|
+
count: 1
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
};
|
|
166
|
+
if (formData.result_name && formData.result_name.trim() !== '') {
|
|
167
|
+
router.result_name = formData.result_name.trim();
|
|
168
|
+
}
|
|
169
|
+
return {
|
|
170
|
+
...originalNode,
|
|
171
|
+
router,
|
|
172
|
+
exits
|
|
173
|
+
};
|
|
174
|
+
},
|
|
175
|
+
localizable: 'categories',
|
|
176
|
+
toLocalizationFormData: categoriesToLocalizationFormData,
|
|
177
|
+
fromLocalizationFormData: localizationFormDataToCategories
|
|
7
178
|
};
|
|
8
179
|
//# sourceMappingURL=wait_for_menu.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"wait_for_menu.js","sourceRoot":"","sources":["../../../../src/flow/nodes/wait_for_menu.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAc,SAAS,EAAE,MAAM,UAAU,CAAC;AAE/D,MAAM,CAAC,MAAM,aAAa,GAAe;IACvC,IAAI,EAAE,eAAe;IACrB,IAAI,EAAE,yBAAyB;IAC/B,KAAK,EAAE,YAAY,CAAC,IAAI;IACxB,SAAS,EAAE,CAAC,SAAS,CAAC,KAAK,CAAC;CAC7B,CAAC","sourcesContent":["import { SPLIT_GROUPS, NodeConfig, FlowTypes } from '../types';\n\nexport const wait_for_menu: NodeConfig = {\n type: 'wait_for_menu',\n name: 'Wait for Menu Selection',\n group: SPLIT_GROUPS.wait,\n flowTypes: [FlowTypes.VOICE]\n};\n"]}
|
|
1
|
+
{"version":3,"file":"wait_for_menu.js","sourceRoot":"","sources":["../../../../src/flow/nodes/wait_for_menu.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAwB,SAAS,EAAE,MAAM,UAAU,CAAC;AAEzE,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAC3C,OAAO,EACL,eAAe,EACf,gCAAgC,EAChC,gCAAgC,EACjC,MAAM,UAAU,CAAC;AAElB,2CAA2C;AAC3C,MAAM,WAAW,GAAG,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC;AAEvE,SAAS,aAAa,CAAC,KAAa;IAClC,OAAO,SAAS,KAAK,EAAE,CAAC;AAC1B,CAAC;AAED,MAAM,CAAC,MAAM,aAAa,GAAe;IACvC,IAAI,EAAE,eAAe;IACrB,IAAI,EAAE,eAAe;IACrB,KAAK,EAAE,YAAY,CAAC,IAAI;IACxB,SAAS,EAAE,CAAC,SAAS,CAAC,KAAK,CAAC;IAC5B,IAAI,EAAE;QACJ,GAAG,MAAM,CAAC,WAAW,CACnB,WAAW,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC;YACzB,aAAa,CAAC,KAAK,CAAC;YACpB;gBACE,IAAI,EAAE,MAAe;gBACrB,QAAQ,EAAE,KAAK;gBACf,WAAW,EAAE,EAAE;gBACf,MAAM,EAAE,QAAiB;aAC1B;SACF,CAAC,CACH;QACD,WAAW,EAAE,eAAe;K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,QAAQ,EAAE,gBAAgB,EAAE,IAAI,EAAE,CAAC,CAAC;QACzD,CAAC;QACD,UAAU,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC;QAE/B,MAAM,MAAM,GAAQ;YAClB,IAAI,EAAE,QAAQ;YACd,OAAO,EAAE,aAAa;YACtB,qBAAqB,EAAE,aAAa,CAAC,IAAI;YACzC,KAAK;YACL,UAAU;YACV,IAAI,EAAE;gBACJ,IAAI,EAAE,KAAK;gBACX,IAAI,EAAE;oBACJ,IAAI,EAAE,QAAQ;oBACd,KAAK,EAAE,CAAC;iBACT;aACF;SACF,CAAC;QAEF,IAAI,QAAQ,CAAC,WAAW,IAAI,QAAQ,CAAC,WAAW,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE,CAAC;YAC/D,MAAM,CAAC,WAAW,GAAG,QAAQ,CAAC,WAAW,CAAC,IAAI,EAAE,CAAC;QACnD,CAAC;QAED,OAAO;YACL,GAAG,YAAY;YACf,MAAM;YACN,KAAK;SACN,CAAC;IACJ,CAAC;IACD,WAAW,EAAE,YAAY;IACzB,sBAAsB,EAAE,gCAAgC;IACxD,wBAAwB,EAAE,gCAAgC;CAC3D,CAAC","sourcesContent":["import { SPLIT_GROUPS, FormData, NodeConfig, FlowTypes } from '../types';\nimport { Node, Category, Exit } from '../../store/flow-definition';\nimport { generateUUID } from '../../utils';\nimport {\n resultNameField,\n categoriesToLocalizationFormData,\n localizationFormDataToCategories\n} from './shared';\n\n// Menu digits in display order: 1-9 then 0\nconst MENU_DIGITS = ['1', '2', '3', '4', '5', '6', '7', '8', '9', '0'];\n\nfunction digitFieldKey(digit: string): string {\n return `digit_${digit}`;\n}\n\nexport const wait_for_menu: NodeConfig = {\n type: 'wait_for_menu',\n name: 'Wait for Menu',\n group: SPLIT_GROUPS.wait,\n flowTypes: [FlowTypes.VOICE],\n form: {\n ...Object.fromEntries(\n MENU_DIGITS.map((digit) => [\n digitFieldKey(digit),\n {\n type: 'text' as const,\n required: false,\n placeholder: '',\n flavor: 'xsmall' as const\n }\n ])\n ),\n result_name: resultNameField\n },\n layout: [\n {\n type: 'row' as const,\n items: ['digit_1', 'digit_2', 'digit_3'],\n gap: '2rem',\n marginBottom: '0.5rem',\n inlineLabels: { digit_1: '1', digit_2: '2', digit_3: '3' }\n },\n {\n type: 'row' as const,\n items: ['digit_4', 'digit_5', 'digit_6'],\n gap: '2rem',\n marginBottom: '0.5rem',\n inlineLabels: { digit_4: '4', digit_5: '5', digit_6: '6' }\n },\n {\n type: 'row' as const,\n items: ['digit_7', 'digit_8', 'digit_9'],\n gap: '2rem',\n marginBottom: '0.5rem',\n inlineLabels: { digit_7: '7', digit_8: '8', digit_9: '9' }\n },\n {\n type: 'row' as const,\n items: [\n { type: 'spacer' as const },\n 'digit_0',\n { type: 'spacer' as const }\n ],\n gap: '2rem',\n inlineLabels: { digit_0: '0' }\n },\n 'result_name'\n ],\n toFormData: (node: Node) => {\n const formData: FormData = {\n uuid: node.uuid,\n result_name: node.router?.result_name || ''\n };\n\n // Initialize all digit fields as empty\n for (const digit of MENU_DIGITS) {\n formData[digitFieldKey(digit)] = '';\n }\n\n // Fill in category names from cases\n if (node.router?.cases && node.router?.categories) {\n for (const case_ of node.router.cases) {\n if (case_.type === 'has_number_eq' && case_.arguments?.[0]) {\n const digit = case_.arguments[0];\n const category = node.router.categories.find(\n (cat: Category) => cat.uuid === case_.category_uuid\n );\n if (category && MENU_DIGITS.includes(digit)) {\n formData[digitFieldKey(digit)] = category.name;\n }\n }\n }\n }\n\n return formData;\n },\n fromFormData: (formData: FormData, originalNode: Node): Node => {\n const existingCategories = originalNode.router?.categories || [];\n const existingExits = originalNode.exits || [];\n const existingCases = originalNode.router?.cases || [];\n\n const categories: Category[] = [];\n const exits: Exit[] = [];\n const cases: any[] = [];\n\n // Build categories and cases for each filled digit\n for (const digit of MENU_DIGITS) {\n const categoryName = (formData[digitFieldKey(digit)] || '').trim();\n if (!categoryName) continue;\n\n // Check if a category with this name already exists in our new list\n let category = categories.find((c) => c.name === categoryName);\n\n if (!category) {\n // Try to find existing category with same name to preserve UUIDs\n const existingCat = existingCategories.find(\n (c: Category) => c.name === categoryName\n );\n\n if (existingCat) {\n category = existingCat;\n const existingExit = existingExits.find(\n (e: Exit) => e.uuid === existingCat.exit_uuid\n );\n categories.push(category);\n exits.push(\n existingExit || {\n uuid: existingCat.exit_uuid,\n destination_uuid: null\n }\n );\n } else {\n const exitUuid = generateUUID();\n category = {\n uuid: generateUUID(),\n name: categoryName,\n exit_uuid: exitUuid\n };\n categories.push(category);\n exits.push({ uuid: exitUuid, destination_uuid: null });\n }\n }\n\n // Find existing case for this digit to preserve UUID\n const existingCase = existingCases.find(\n (c: any) => c.type === 'has_number_eq' && c.arguments?.[0] === digit\n );\n\n cases.push({\n uuid: existingCase?.uuid || generateUUID(),\n type: 'has_number_eq',\n arguments: [digit],\n category_uuid: category.uuid\n });\n }\n\n // Add \"Other\" default category\n const existingOther = existingCategories.find(\n (c: Category) => c.name === 'Other'\n );\n\n let otherCategory: Category;\n if (existingOther) {\n otherCategory = existingOther;\n const existingExit = existingExits.find(\n (e: Exit) => e.uuid === existingOther.exit_uuid\n );\n exits.push(\n existingExit || {\n uuid: existingOther.exit_uuid,\n destination_uuid: null\n }\n );\n } else {\n const exitUuid = generateUUID();\n otherCategory = {\n uuid: generateUUID(),\n name: 'Other',\n exit_uuid: exitUuid\n };\n exits.push({ uuid: exitUuid, destination_uuid: null });\n }\n categories.push(otherCategory);\n\n const router: any = {\n type: 'switch',\n operand: '@input.text',\n default_category_uuid: otherCategory.uuid,\n cases,\n categories,\n wait: {\n type: 'msg',\n hint: {\n type: 'digits',\n count: 1\n }\n }\n };\n\n if (formData.result_name && formData.result_name.trim() !== '') {\n router.result_name = formData.result_name.trim();\n }\n\n return {\n ...originalNode,\n router,\n exits\n };\n },\n localizable: 'categories',\n toLocalizationFormData: categoriesToLocalizationFormData,\n fromLocalizationFormData: localizationFormDataToCategories\n};\n"]}
|
|
@@ -48,7 +48,7 @@ export const wait_for_response = {
|
|
|
48
48
|
flowTypes: [FlowTypes.MESSAGE],
|
|
49
49
|
dialogSize: 'large',
|
|
50
50
|
form: {
|
|
51
|
-
rules: createRulesArrayConfig(operatorsToSelectOptions(getWaitForResponseOperators()), '
|
|
51
|
+
rules: createRulesArrayConfig(operatorsToSelectOptions(getWaitForResponseOperators()), 'If the message from the contact...'),
|
|
52
52
|
timeout_enabled: {
|
|
53
53
|
type: 'checkbox',
|
|
54
54
|
label: (formData) => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"wait_for_response.js","sourceRoot":"","sources":["../../../../src/flow/nodes/wait_for_response.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAwB,SAAS,EAAE,MAAM,UAAU,CAAC;AAEzE,OAAO,EAAE,YAAY,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAC9D,OAAO,EACL,2BAA2B,EAC3B,wBAAwB,EACxB,iBAAiB,EAClB,MAAM,cAAc,CAAC;AACtB,OAAO,EACL,eAAe,EACf,gCAAgC,EAChC,gCAAgC,EACjC,MAAM,UAAU,CAAC;AAClB,OAAO,EACL,sBAAsB,EACtB,gBAAgB,EAChB,gBAAgB,EACjB,MAAM,gBAAgB,CAAC;AAExB,MAAM,eAAe,GAAG;IACtB,EAAE,KAAK,EAAE,IAAI,EAAE,IAAI,EAAE,UAAU,EAAE;IACjC,EAAE,KAAK,EAAE,KAAK,EAAE,IAAI,EAAE,WAAW,EAAE;IACnC,EAAE,KAAK,EAAE,KAAK,EAAE,IAAI,EAAE,WAAW,EAAE;IACnC,EAAE,KAAK,EAAE,KAAK,EAAE,IAAI,EAAE,WAAW,EAAE;IACnC,EAAE,KAAK,EAAE,KAAK,EAAE,IAAI,EAAE,WAAW,EAAE;IACnC,EAAE,KAAK,EAAE,KAAK,EAAE,IAAI,EAAE,YAAY,EAAE;IACpC,EAAE,KAAK,EAAE,KAAK,EAAE,IAAI,EAAE,YAAY,EAAE;IACpC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C;oBACF,IAAI,uBAAuB,KAAK,CAAC,CAAC,EAAE,CAAC;wBACnC,MAAM,kBAAkB,GACtB,MAAM,CAAC,UAAU,CAAC,uBAAuB,CAAC,CAAC;wBAE7C,sBAAsB;wBACtB,MAAM,CAAC,UAAU,CAAC,MAAM,CAAC,uBAAuB,EAAE,CAAC,CAAC,CAAC;wBAErD,4BAA4B;wBAC5B,MAAM,SAAS,GAAG,KAAK,CAAC,SAAS,CAC/B,CAAC,IAAS,EAAE,EAAE,CAAC,IAAI,CAAC,IAAI,KAAK,kBAAkB,CAAC,SAAS,CAC1D,CAAC;wBACF,IAAI,SAAS,KAAK,CAAC,CAAC,EAAE,CAAC;4BACrB,KAAK,CAAC,MAAM,CAAC,SAAS,EAAE,CAAC,CAAC,CAAC;wBAC7B,CAAC;oBACH,CAAC;gBACH,CAAC;YACH,CAAC;QACH,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,OAAO,CAAC,KAAK,CAAC,yCAAyC,EAAE,KAAK,CAAC,CAAC;YAChE,4CAA4C;QAC9C,CAAC;QAED,WAAW,CAAC,IAAI,GAAG,UAAU,CAAC;QAC9B,OAAO;YACL,GAAG,YAAY;YACf,MAAM,EAAE,WAAW;YACnB,KAAK,EAAE,KAAK;SACb,CAAC;IACJ,CAAC;IAED,sCAAsC;IACtC,WAAW,EAAE,YAAY;IACzB,sBAAsB,EAAE,gCAAgC;IACxD,wBAAwB,EAAE,gCAAgC;CAC3D,CAAC","sourcesContent":["import { SPLIT_GROUPS, FormData, NodeConfig, FlowTypes } from '../types';\nimport { Node, Category, Exit, Case } from '../../store/flow-definition';\nimport { generateUUID, createRulesRouter } from '../../utils';\nimport {\n getWaitForResponseOperators,\n operatorsToSelectOptions,\n getOperatorConfig\n} from '../operators';\nimport {\n resultNameField,\n categoriesToLocalizationFormData,\n localizationFormDataToCategories\n} from './shared';\nimport {\n createRulesArrayConfig,\n extractUserRules,\n casesToFormRules\n} from './shared-rules';\n\nconst TIMEOUT_OPTIONS = [\n { value: '60', name: '1 minute' },\n { value: '120', name: '2 minutes' },\n { value: '180', name: '3 minutes' },\n { value: '240', name: '4 minutes' },\n { value: '300', name: '5 minutes' },\n { value: '600', name: '10 minutes' },\n { value: '900', name: '15 minutes' },\n { value: '1800', name: '30 minutes' },\n { value: '3600', name: '1 hour' },\n { value: '7200', name: '2 hours' },\n { value: '10800', name: '3 hours' },\n { value: '21600', name: '6 hours' },\n { value: '43200', name: '12 hours' },\n { value: '64800', name: '18 hours' },\n { value: '86400', name: '1 day' },\n { value: '172800', name: '2 days' },\n { value: '259200', name: '3 days' },\n { value: '604800', name: '1 week' }\n];\n\n// Helper function to create a wait_for_response router with user rules\n// This is a thin wrapper around createRulesRouter that adds the No Response category for timeouts\nconst createWaitForResponseRouter = (\n userRules: any[],\n existingCategories: Category[] = [],\n existingExits: Exit[] = [],\n existingCases: Case[] = []\n) => {\n const { router, exits } = createRulesRouter(\n '@input.text',\n userRules,\n getOperatorConfig,\n existingCategories,\n existingExits,\n existingCases\n );\n\n // Add \"No Response\" category last (if it exists in the original)\n const existingNoResponseCategory = existingCategories.find(\n (cat) => cat.name === 'No Response' || cat.name === 'Timeout'\n );\n\n if (existingNoResponseCategory) {\n const existingNoResponseExit = existingExits.find(\n (exit) => exit.uuid === existingNoResponseCategory.exit_uuid\n );\n\n if (existingNoResponseExit) {\n router.categories.push(existingNoResponseCategory);\n exits.push({\n uuid: existingNoResponseExit.uuid,\n destination_uuid: existingNoResponseExit.destination_uuid || null\n });\n }\n }\n\n return { router, exits };\n};\n\nexport const wait_for_response: NodeConfig = {\n type: 'wait_for_response',\n name: 'Wait for Response',\n group: SPLIT_GROUPS.wait,\n flowTypes: [FlowTypes.MESSAGE],\n dialogSize: 'large',\n form: {\n rules: createRulesArrayConfig(\n operatorsToSelectOptions(getWaitForResponseOperators()),\n 'Define rules to categorize responses'\n ),\n timeout_enabled: {\n type: 'checkbox',\n label: (formData: Record<string, any>) => {\n return formData.timeout_enabled\n ? 'Continue when there is no response for'\n : 'Continue when there is no response..';\n },\n labelPadding: '4px 8px'\n },\n timeout_duration: {\n type: 'select',\n placeholder: '5 minutes',\n multi: false,\n maxWidth: '100px',\n flavor: 'xsmall',\n options: TIMEOUT_OPTIONS,\n\n conditions: {\n visible: (formData: Record<string, any>) => {\n return formData.timeout_enabled === true;\n }\n }\n },\n result_name: resultNameField\n },\n layout: ['rules', 'result_name'],\n gutter: [\n {\n type: 'row',\n items: ['timeout_enabled', 'timeout_duration'],\n gap: '0.5rem'\n }\n ],\n validate: (_formData: FormData) => {\n const errors: { [key: string]: string } = {};\n\n // No validation needed - allow multiple rules to use same category name\n // Rules with the same category name will be merged to use the same exit\n\n return {\n valid: Object.keys(errors).length === 0,\n errors\n };\n },\n toFormData: (node: Node) => {\n // Extract rules from router cases using shared function\n const rules = casesToFormRules(node);\n\n // Extract timeout configuration\n const timeoutSeconds = node.router?.wait?.timeout?.seconds;\n let timeoutOption = TIMEOUT_OPTIONS.find(\n (opt) => opt.value === String(timeoutSeconds)\n );\n\n if (!timeoutOption) {\n timeoutOption = { value: '300', name: '5 minutes' };\n }\n\n return {\n uuid: node.uuid,\n rules: rules,\n timeout_enabled: !!timeoutSeconds,\n timeout_duration: timeoutOption,\n result_name: node.router?.result_name || ''\n };\n },\n fromFormData: (formData: FormData, originalNode: Node): Node => {\n // Get user rules using shared extraction function\n const userRules = extractUserRules(formData);\n\n // If no user rules, clear cases but preserve other router config\n if (userRules.length === 0) {\n // Get existing router data for preservation\n let existingCategories = originalNode.router?.categories || [];\n const existingExits = [...(originalNode.exits || [])]; // Create a copy to avoid extensibility issues\n\n // Handle timeout: ensure \"No Response\" category exists if timeout is enabled,\n // or remove it if timeout is disabled\n if (formData.timeout_enabled) {\n let noResponseCategory = existingCategories.find(\n (cat: any) => cat.name === 'No Response'\n );\n\n if (!noResponseCategory) {\n // Create new \"No Response\" category and exit\n const noResponseExitUuid = generateUUID();\n noResponseCategory = {\n uuid: generateUUID(),\n name: 'No Response',\n exit_uuid: noResponseExitUuid\n };\n\n // Add to existing categories for processing\n existingCategories = [...existingCategories, noResponseCategory];\n\n // Add corresponding exit if it doesn't exist\n if (!existingExits.find((exit) => exit.uuid === noResponseExitUuid)) {\n existingExits.push({\n uuid: noResponseExitUuid,\n destination_uuid: null\n });\n }\n }\n } else {\n // If timeout is disabled, remove \"No Response\" category from existing categories\n existingCategories = existingCategories.filter(\n (cat: any) => cat.name !== 'No Response'\n );\n }\n\n // Create router with \"All Responses\" as default category\n // This will now properly handle the \"No Response\" category if it exists\n const { router: noRulesRouter, exits: noRulesExits } =\n createWaitForResponseRouter(\n [], // No user rules\n existingCategories,\n existingExits,\n [] // No cases\n );\n\n const router: any = {\n ...noRulesRouter,\n cases: [] // Clear all cases when no rules\n };\n\n // Only set result_name if provided\n if (formData.result_name && formData.result_name.trim() !== '') {\n router.result_name = formData.result_name.trim();\n }\n\n // Build wait configuration based on form data\n const waitConfig: any = {\n type: 'msg'\n };\n\n // Add timeout if enabled\n if (formData.timeout_enabled) {\n // Extract timeout value (handle both string and object formats)\n let timeoutSeconds;\n\n if (formData.timeout_duration) {\n if (\n Array.isArray(formData.timeout_duration) &&\n formData.timeout_duration.length > 0\n ) {\n // Handle array of selected options (multi-select behavior)\n timeoutSeconds = parseInt(formData.timeout_duration[0].value, 10);\n } else if (typeof formData.timeout_duration === 'string') {\n timeoutSeconds = parseInt(formData.timeout_duration, 10);\n } else if (\n formData.timeout_duration &&\n typeof formData.timeout_duration === 'object' &&\n formData.timeout_duration.value\n ) {\n timeoutSeconds = parseInt(formData.timeout_duration.value, 10);\n } else {\n timeoutSeconds = 300; // Default to 5 minutes\n }\n } else {\n // No duration selected, use default\n timeoutSeconds = 300; // Default to 5 minutes\n }\n\n // Validate that we got a valid number\n if (isNaN(timeoutSeconds) || timeoutSeconds <= 0) {\n timeoutSeconds = 300; // Default to 5 minutes\n }\n\n // Find the \"No Response\" category (should exist now)\n const noResponseCategory = router.categories.find(\n (cat: any) => cat.name === 'No Response'\n );\n\n if (noResponseCategory) {\n waitConfig.timeout = {\n seconds: timeoutSeconds,\n category_uuid: noResponseCategory.uuid\n };\n }\n }\n\n router.wait = waitConfig;\n\n return {\n ...originalNode,\n router,\n exits: noRulesExits\n };\n }\n\n // Get existing router data for preservation\n const existingCategories = originalNode.router?.categories || [];\n const existingExits = originalNode.exits || [];\n const existingCases = originalNode.router?.cases || [];\n\n // Create router and exits using existing data when possible\n const { router, exits } = createWaitForResponseRouter(\n userRules,\n existingCategories,\n existingExits,\n existingCases\n );\n\n // Build final router with wait configuration and result_name\n const finalRouter: any = {\n ...router\n };\n\n // Only set result_name if provided\n if (formData.result_name && formData.result_name.trim() !== '') {\n finalRouter.result_name = formData.result_name.trim();\n }\n\n // Build wait configuration based on form data\n const waitConfig: any = {\n type: 'msg'\n };\n\n try {\n // Handle timeout configuration\n if (formData.timeout_enabled) {\n // Extract timeout value (handle both string and object formats)\n let timeoutSeconds;\n\n if (formData.timeout_duration) {\n try {\n timeoutSeconds = parseInt(formData.timeout_duration[0].value, 10);\n } catch (e) {\n timeoutSeconds = 300; // Default to 5 minutes\n }\n }\n\n // Find or create the \"No Response\" category\n const existingNoResponseCategory =\n originalNode.router?.categories?.find(\n (cat: any) => cat.name === 'No Response'\n );\n\n const noResponseCategory = existingNoResponseCategory || {\n uuid: generateUUID(),\n name: 'No Response',\n exit_uuid: generateUUID()\n };\n\n waitConfig.timeout = {\n seconds: timeoutSeconds,\n category_uuid: noResponseCategory.uuid\n };\n\n // Ensure No Response category and exit exist\n if (\n !router.categories?.some((cat: any) => cat.name === 'No Response')\n ) {\n router.categories = router.categories || [];\n router.categories.push(noResponseCategory);\n\n // Add corresponding exit if it doesn't exist\n if (\n !exits.some(\n (exit: any) => exit.uuid === noResponseCategory.exit_uuid\n )\n ) {\n const noResponseExit = {\n uuid: noResponseCategory.exit_uuid,\n destination_uuid: existingNoResponseCategory?.exit_uuid\n ? originalNode.exits?.find(\n (exit) => exit.uuid === existingNoResponseCategory.exit_uuid\n )?.destination_uuid || null\n : null\n };\n exits.push(noResponseExit);\n }\n }\n } else {\n // Remove \"No Response\" category if timeout is disabled\n if (router.categories) {\n const noResponseCategoryIndex = router.categories.findIndex(\n (cat: any) => cat.name === 'No Response'\n );\n if (noResponseCategoryIndex !== -1) {\n const noResponseCategory =\n router.categories[noResponseCategoryIndex];\n\n // Remove the category\n router.categories.splice(noResponseCategoryIndex, 1);\n\n // Remove corresponding exit\n const exitIndex = exits.findIndex(\n (exit: any) => exit.uuid === noResponseCategory.exit_uuid\n );\n if (exitIndex !== -1) {\n exits.splice(exitIndex, 1);\n }\n }\n }\n }\n } catch (error) {\n console.error('Error processing timeout configuration:', error);\n // Continue without timeout in case of error\n }\n\n finalRouter.wait = waitConfig;\n return {\n ...originalNode,\n router: finalRouter,\n exits: exits\n };\n },\n\n // Localization support for categories\n localizable: 'categories',\n toLocalizationFormData: categoriesToLocalizationFormData,\n fromLocalizationFormData: localizationFormDataToCategories\n};\n"]}
|
|
1
|
+
{"version":3,"file":"wait_for_response.js","sourceRoot":"","sources":["../../../../src/flow/nodes/wait_for_response.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAwB,SAAS,EAAE,MAAM,UAAU,CAAC;AAEzE,OAAO,EAAE,YAAY,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAC9D,OAAO,EACL,2BAA2B,EAC3B,wBAAwB,EACxB,iBAAiB,EAClB,MAAM,cAAc,CAAC;AACtB,OAAO,EACL,eAAe,EACf,gCAAgC,EAChC,gCAAgC,EACjC,MAAM,UAAU,CAAC;AAClB,OAAO,EACL,sBAAsB,EACtB,gBAAgB,EAChB,gBAAgB,EACjB,MAAM,gBAAgB,CAAC;AAExB,MAAM,eAAe,GAAG;IACtB,EAAE,KAAK,EAAE,IAAI,EAAE,IAAI,EAAE,UAAU,EAAE;IACjC,EAAE,KAAK,EAAE,KAAK,EAAE,IAAI,EAAE,WAAW,EAAE;IACnC,EAAE,KAAK,EAAE,KAAK,E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} from '../types';\nimport { Node, Category, Exit, Case } from '../../store/flow-definition';\nimport { generateUUID, createRulesRouter } from '../../utils';\nimport {\n getWaitForResponseOperators,\n operatorsToSelectOptions,\n getOperatorConfig\n} from '../operators';\nimport {\n resultNameField,\n categoriesToLocalizationFormData,\n localizationFormDataToCategories\n} from './shared';\nimport {\n createRulesArrayConfig,\n extractUserRules,\n casesToFormRules\n} from './shared-rules';\n\nconst TIMEOUT_OPTIONS = [\n { value: '60', name: '1 minute' },\n { value: '120', name: '2 minutes' },\n { value: '180', name: '3 minutes' },\n { value: '240', name: '4 minutes' },\n { value: '300', name: '5 minutes' },\n { value: '600', name: '10 minutes' },\n { value: '900', name: '15 minutes' },\n { value: '1800', name: '30 minutes' },\n { value: '3600', name: '1 hour' },\n { value: '7200', name: '2 hours' },\n { value: '10800', name: '3 hours' },\n { value: '21600', name: '6 hours' },\n { value: '43200', name: '12 hours' },\n { value: '64800', name: '18 hours' },\n { value: '86400', name: '1 day' },\n { value: '172800', name: '2 days' },\n { value: '259200', name: '3 days' },\n { value: '604800', name: '1 week' }\n];\n\n// Helper function to create a wait_for_response router with user rules\n// This is a thin wrapper around createRulesRouter that adds the No Response category for timeouts\nconst createWaitForResponseRouter = (\n userRules: any[],\n existingCategories: Category[] = [],\n existingExits: Exit[] = [],\n existingCases: Case[] = []\n) => {\n const { router, exits } = createRulesRouter(\n '@input.text',\n userRules,\n getOperatorConfig,\n existingCategories,\n existingExits,\n existingCases\n );\n\n // Add \"No Response\" category last (if it exists in the original)\n const existingNoResponseCategory = existingCategories.find(\n (cat) => cat.name === 'No Response' || cat.name === 'Timeout'\n );\n\n if (existingNoResponseCategory) {\n const existingNoResponseExit = existingExits.find(\n (exit) => exit.uuid === existingNoResponseCategory.exit_uuid\n );\n\n if (existingNoResponseExit) {\n router.categories.push(existingNoResponseCategory);\n exits.push({\n uuid: existingNoResponseExit.uuid,\n destination_uuid: existingNoResponseExit.destination_uuid || null\n });\n }\n }\n\n return { router, exits };\n};\n\nexport const wait_for_response: NodeConfig = {\n type: 'wait_for_response',\n name: 'Wait for Response',\n group: SPLIT_GROUPS.wait,\n flowTypes: [FlowTypes.MESSAGE],\n dialogSize: 'large',\n form: {\n rules: createRulesArrayConfig(\n operatorsToSelectOptions(getWaitForResponseOperators()),\n 'If the message from the contact...'\n ),\n timeout_enabled: {\n type: 'checkbox',\n label: (formData: Record<string, any>) => {\n return formData.timeout_enabled\n ? 'Continue when there is no response for'\n : 'Continue when there is no response..';\n },\n labelPadding: '4px 8px'\n },\n timeout_duration: {\n type: 'select',\n placeholder: '5 minutes',\n multi: false,\n maxWidth: '100px',\n flavor: 'xsmall',\n options: TIMEOUT_OPTIONS,\n\n conditions: {\n visible: (formData: Record<string, any>) => {\n return formData.timeout_enabled === true;\n }\n }\n },\n result_name: resultNameField\n },\n layout: ['rules', 'result_name'],\n gutter: [\n {\n type: 'row',\n items: ['timeout_enabled', 'timeout_duration'],\n gap: '0.5rem'\n }\n ],\n validate: (_formData: FormData) => {\n const errors: { [key: string]: string } = {};\n\n // No validation needed - allow multiple rules to use same category name\n // Rules with the same category name will be merged to use the same exit\n\n return {\n valid: Object.keys(errors).length === 0,\n errors\n };\n },\n toFormData: (node: Node) => {\n // Extract rules from router cases using shared function\n const rules = casesToFormRules(node);\n\n // Extract timeout configuration\n const timeoutSeconds = node.router?.wait?.timeout?.seconds;\n let timeoutOption = TIMEOUT_OPTIONS.find(\n (opt) => opt.value === String(timeoutSeconds)\n );\n\n if (!timeoutOption) {\n timeoutOption = { value: '300', name: '5 minutes' };\n }\n\n return {\n uuid: node.uuid,\n rules: rules,\n timeout_enabled: !!timeoutSeconds,\n timeout_duration: timeoutOption,\n result_name: node.router?.result_name || ''\n };\n },\n fromFormData: (formData: FormData, originalNode: Node): Node => {\n // Get user rules using shared extraction function\n const userRules = extractUserRules(formData);\n\n // If no user rules, clear cases but preserve other router config\n if (userRules.length === 0) {\n // Get existing router data for preservation\n let existingCategories = originalNode.router?.categories || [];\n const existingExits = [...(originalNode.exits || [])]; // Create a copy to avoid extensibility issues\n\n // Handle timeout: ensure \"No Response\" category exists if timeout is enabled,\n // or remove it if timeout is disabled\n if (formData.timeout_enabled) {\n let noResponseCategory = existingCategories.find(\n (cat: any) => cat.name === 'No Response'\n );\n\n if (!noResponseCategory) {\n // Create new \"No Response\" category and exit\n const noResponseExitUuid = generateUUID();\n noResponseCategory = {\n uuid: generateUUID(),\n name: 'No Response',\n exit_uuid: noResponseExitUuid\n };\n\n // Add to existing categories for processing\n existingCategories = [...existingCategories, noResponseCategory];\n\n // Add corresponding exit if it doesn't exist\n if (!existingExits.find((exit) => exit.uuid === noResponseExitUuid)) {\n existingExits.push({\n uuid: noResponseExitUuid,\n destination_uuid: null\n });\n }\n }\n } else {\n // If timeout is disabled, remove \"No Response\" category from existing categories\n existingCategories = existingCategories.filter(\n (cat: any) => cat.name !== 'No Response'\n );\n }\n\n // Create router with \"All Responses\" as default category\n // This will now properly handle the \"No Response\" category if it exists\n const { router: noRulesRouter, exits: noRulesExits } =\n createWaitForResponseRouter(\n [], // No user rules\n existingCategories,\n existingExits,\n [] // No cases\n );\n\n const router: any = {\n ...noRulesRouter,\n cases: [] // Clear all cases when no rules\n };\n\n // Only set result_name if provided\n if (formData.result_name && formData.result_name.trim() !== '') {\n router.result_name = formData.result_name.trim();\n }\n\n // Build wait configuration based on form data\n const waitConfig: any = {\n type: 'msg'\n };\n\n // Add timeout if enabled\n if (formData.timeout_enabled) {\n // Extract timeout value (handle both string and object formats)\n let timeoutSeconds;\n\n if (formData.timeout_duration) {\n if (\n Array.isArray(formData.timeout_duration) &&\n formData.timeout_duration.length > 0\n ) {\n // Handle array of selected options (multi-select behavior)\n timeoutSeconds = parseInt(formData.timeout_duration[0].value, 10);\n } else if (typeof formData.timeout_duration === 'string') {\n timeoutSeconds = parseInt(formData.timeout_duration, 10);\n } else if (\n formData.timeout_duration &&\n typeof formData.timeout_duration === 'object' &&\n formData.timeout_duration.value\n ) {\n timeoutSeconds = parseInt(formData.timeout_duration.value, 10);\n } else {\n timeoutSeconds = 300; // Default to 5 minutes\n }\n } else {\n // No duration selected, use default\n timeoutSeconds = 300; // Default to 5 minutes\n }\n\n // Validate that we got a valid number\n if (isNaN(timeoutSeconds) || timeoutSeconds <= 0) {\n timeoutSeconds = 300; // Default to 5 minutes\n }\n\n // Find the \"No Response\" category (should exist now)\n const noResponseCategory = router.categories.find(\n (cat: any) => cat.name === 'No Response'\n );\n\n if (noResponseCategory) {\n waitConfig.timeout = {\n seconds: timeoutSeconds,\n category_uuid: noResponseCategory.uuid\n };\n }\n }\n\n router.wait = waitConfig;\n\n return {\n ...originalNode,\n router,\n exits: noRulesExits\n };\n }\n\n // Get existing router data for preservation\n const existingCategories = originalNode.router?.categories || [];\n const existingExits = originalNode.exits || [];\n const existingCases = originalNode.router?.cases || [];\n\n // Create router and exits using existing data when possible\n const { router, exits } = createWaitForResponseRouter(\n userRules,\n existingCategories,\n existingExits,\n existingCases\n );\n\n // Build final router with wait configuration and result_name\n const finalRouter: any = {\n ...router\n };\n\n // Only set result_name if provided\n if (formData.result_name && formData.result_name.trim() !== '') {\n finalRouter.result_name = formData.result_name.trim();\n }\n\n // Build wait configuration based on form data\n const waitConfig: any = {\n type: 'msg'\n };\n\n try {\n // Handle timeout configuration\n if (formData.timeout_enabled) {\n // Extract timeout value (handle both string and object formats)\n let timeoutSeconds;\n\n if (formData.timeout_duration) {\n try {\n timeoutSeconds = parseInt(formData.timeout_duration[0].value, 10);\n } catch (e) {\n timeoutSeconds = 300; // Default to 5 minutes\n }\n }\n\n // Find or create the \"No Response\" category\n const existingNoResponseCategory =\n originalNode.router?.categories?.find(\n (cat: any) => cat.name === 'No Response'\n );\n\n const noResponseCategory = existingNoResponseCategory || {\n uuid: generateUUID(),\n name: 'No Response',\n exit_uuid: generateUUID()\n };\n\n waitConfig.timeout = {\n seconds: timeoutSeconds,\n category_uuid: noResponseCategory.uuid\n };\n\n // Ensure No Response category and exit exist\n if (\n !router.categories?.some((cat: any) => cat.name === 'No Response')\n ) {\n router.categories = router.categories || [];\n router.categories.push(noResponseCategory);\n\n // Add corresponding exit if it doesn't exist\n if (\n !exits.some(\n (exit: any) => exit.uuid === noResponseCategory.exit_uuid\n )\n ) {\n const noResponseExit = {\n uuid: noResponseCategory.exit_uuid,\n destination_uuid: existingNoResponseCategory?.exit_uuid\n ? originalNode.exits?.find(\n (exit) => exit.uuid === existingNoResponseCategory.exit_uuid\n )?.destination_uuid || null\n : null\n };\n exits.push(noResponseExit);\n }\n }\n } else {\n // Remove \"No Response\" category if timeout is disabled\n if (router.categories) {\n const noResponseCategoryIndex = router.categories.findIndex(\n (cat: any) => cat.name === 'No Response'\n );\n if (noResponseCategoryIndex !== -1) {\n const noResponseCategory =\n router.categories[noResponseCategoryIndex];\n\n // Remove the category\n router.categories.splice(noResponseCategoryIndex, 1);\n\n // Remove corresponding exit\n const exitIndex = exits.findIndex(\n (exit: any) => exit.uuid === noResponseCategory.exit_uuid\n );\n if (exitIndex !== -1) {\n exits.splice(exitIndex, 1);\n }\n }\n }\n }\n } catch (error) {\n console.error('Error processing timeout configuration:', error);\n // Continue without timeout in case of error\n }\n\n finalRouter.wait = waitConfig;\n return {\n ...originalNode,\n router: finalRouter,\n exits: exits\n };\n },\n\n // Localization support for categories\n localizable: 'categories',\n toLocalizationFormData: categoriesToLocalizationFormData,\n fromLocalizationFormData: localizationFormDataToCategories\n};\n"]}
|
|
@@ -34,11 +34,6 @@ export const OPERATORS = [
|
|
|
34
34
|
operands: 0,
|
|
35
35
|
categoryName: 'Has Text'
|
|
36
36
|
},
|
|
37
|
-
{
|
|
38
|
-
type: 'has_pattern',
|
|
39
|
-
name: 'matches regex',
|
|
40
|
-
operands: 1
|
|
41
|
-
},
|
|
42
37
|
// Number operators
|
|
43
38
|
{
|
|
44
39
|
type: 'has_number',
|
|
@@ -165,6 +160,11 @@ export const OPERATORS = [
|
|
|
165
160
|
operands: 0,
|
|
166
161
|
categoryName: 'Not Empty',
|
|
167
162
|
visibility: 'hidden'
|
|
163
|
+
},
|
|
164
|
+
{
|
|
165
|
+
type: 'has_pattern',
|
|
166
|
+
name: 'matches regex',
|
|
167
|
+
operands: 1
|
|
168
168
|
}
|
|
169
169
|
];
|
|
170
170
|
// Get operators suitable for wait_for_response rules
|
|
@@ -172,6 +172,22 @@ export const getWaitForResponseOperators = () => {
|
|
|
172
172
|
return OPERATORS.filter((op) => op.visibility !== 'hidden' && !op.filter // For now, exclude location operators unless we support feature detection
|
|
173
173
|
);
|
|
174
174
|
};
|
|
175
|
+
// Number operator types used for digit-based routing
|
|
176
|
+
const DIGIT_OPERATOR_TYPES = new Set([
|
|
177
|
+
'has_beginning',
|
|
178
|
+
'has_number',
|
|
179
|
+
'has_number_between',
|
|
180
|
+
'has_number_lt',
|
|
181
|
+
'has_number_lte',
|
|
182
|
+
'has_number_eq',
|
|
183
|
+
'has_number_gte',
|
|
184
|
+
'has_number_gt',
|
|
185
|
+
'has_pattern'
|
|
186
|
+
]);
|
|
187
|
+
// Get operators suitable for wait_for_digits rules (number operators + regex)
|
|
188
|
+
export const getDigitOperators = () => {
|
|
189
|
+
return OPERATORS.filter((op) => DIGIT_OPERATOR_TYPES.has(op.type));
|
|
190
|
+
};
|
|
175
191
|
// Get operator configuration by type
|
|
176
192
|
export const getOperatorConfig = (type) => {
|
|
177
193
|
return OPERATORS.find((op) => op.type === type);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"operators.js","sourceRoot":"","sources":["../../../src/flow/operators.ts"],"names":[],"mappings":"AAAA,sCAAsC;AACtC,4EAA4E;AAW5E,2CAA2C;AAC3C,MAAM,CAAC,MAAM,SAAS,GAAqB;IACzC,iBAAiB;IACjB;QACE,IAAI,EAAE,cAAc;QACpB,IAAI,EAAE,sBAAsB;QAC5B,QAAQ,EAAE,CAAC;KACZ;IACD;QACE,IAAI,EAAE,eAAe;QACrB,IAAI,EAAE,sBAAsB;QAC5B,QAAQ,EAAE,CAAC;KACZ;IACD;QACE,I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oB,GAAG,IAAI,GAAG,CAAC;IACnC,eAAe;IACf,YAAY;IACZ,oBAAoB;IACpB,eAAe;IACf,gBAAgB;IAChB,eAAe;IACf,gBAAgB;IAChB,eAAe;IACf,aAAa;CACd,CAAC,CAAC;AAEH,8EAA8E;AAC9E,MAAM,CAAC,MAAM,iBAAiB,GAAG,GAAqB,EAAE;IACtD,OAAO,SAAS,CAAC,MAAM,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,oBAAoB,CAAC,GAAG,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC,CAAC;AACrE,CAAC,CAAC;AAEF,qCAAqC;AACrC,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAAC,IAAY,EAA8B,EAAE;IAC5E,OAAO,SAAS,CAAC,IAAI,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,CAAC,IAAI,KAAK,IAAI,CAAC,CAAC;AAClD,CAAC,CAAC;AAEF,sCAAsC;AACtC,MAAM,CAAC,MAAM,wBAAwB,GAAG,CAAC,SAA2B,EAAE,EAAE;IACtE,OAAO,SAAS,CAAC,GAAG,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC;QAC5B,KAAK,EAAE,EAAE,CAAC,IAAI;QACd,IAAI,EAAE,EAAE,CAAC,IAAI;KACd,CAAC,CAAC,CAAC;AACN,CAAC,CAAC;AAEF,kDAAkD;AAClD,MAAM,CAAC,MAAM,oBAAoB,GAAG,CAClC,IAAY,EACqB,EAAE;IACnC,MAAM,MAAM,GAAG,iBAAiB,CAAC,IAAI,CAAC,CAAC;IACvC,OAAO;QACL,KAAK,EAAE,IAAI;QACX,IAAI,EAAE,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI;KAClC,CAAC;AACJ,CAAC,CAAC","sourcesContent":["// Flow router operator configurations\n// These define the available operators for rule-based routing in flow nodes\n\nexport interface OperatorConfig {\n type: string;\n name: string;\n operands: number; // Number of operands required (0 = no input needed, 1 = single value, 2 = two values)\n categoryName?: string; // Default category name when operands is 0\n visibility?: 'hidden' | 'visible'; // Whether to show in UI\n filter?: string; // Feature filter requirement\n}\n\n// All available operators for flow routing\nexport const OPERATORS: OperatorConfig[] = [\n // Text operators\n {\n type: 'has_any_word',\n name: 'has any of the words',\n operands: 1\n },\n {\n type: 'has_all_words',\n name: 'has all of the words',\n operands: 1\n },\n {\n type: 'has_phrase',\n name: 'has the phrase',\n operands: 1\n },\n {\n type: 'has_only_phrase',\n name: 'has only the phrase',\n operands: 1\n },\n {\n type: 'has_beginning',\n name: 'starts with',\n operands: 1\n },\n {\n type: 'has_text',\n name: 'has some text',\n operands: 0,\n categoryName: 'Has Text'\n },\n\n // Number operators\n {\n type: 'has_number',\n name: 'has a number',\n operands: 0,\n categoryName: 'Has Number'\n },\n {\n type: 'has_number_between',\n name: 'has a number between',\n operands: 2\n },\n {\n type: 'has_number_lt',\n name: 'has a number below',\n operands: 1\n },\n {\n type: 'has_number_lte',\n name: 'has a number at or below',\n operands: 1\n },\n {\n type: 'has_number_eq',\n name: 'has a number equal to',\n operands: 1\n },\n {\n type: 'has_number_gte',\n name: 'has a number at or above',\n operands: 1\n },\n {\n type: 'has_number_gt',\n name: 'has a number above',\n operands: 1\n },\n\n // Date operators\n {\n type: 'has_date',\n name: 'has a date',\n operands: 0,\n categoryName: 'Has Date'\n },\n {\n type: 'has_date_lt',\n name: 'has a date before',\n operands: 1\n },\n {\n type: 'has_date_eq',\n name: 'has a date equal to',\n operands: 1\n },\n {\n type: 'has_date_gt',\n name: 'has a date after',\n operands: 1\n },\n {\n type: 'has_time',\n name: 'has a time',\n operands: 0,\n categoryName: 'Has Time'\n },\n\n // Contact data operators\n {\n type: 'has_phone',\n name: 'has a phone number',\n operands: 0,\n categoryName: 'Has Phone'\n },\n {\n type: 'has_email',\n name: 'has an email',\n operands: 0,\n categoryName: 'Has Email'\n },\n\n // Location operators (require location feature)\n {\n type: 'has_state',\n name: 'has state',\n operands: 0,\n categoryName: 'Has State',\n filter: 'HAS_LOCATIONS'\n },\n {\n type: 'has_district',\n name: 'has district',\n operands: 1,\n categoryName: 'Has District',\n filter: 'HAS_LOCATIONS'\n },\n {\n type: 'has_ward',\n name: 'has ward',\n operands: 2,\n categoryName: 'Has Ward',\n filter: 'HAS_LOCATIONS'\n },\n\n // Hidden/system operators\n {\n type: 'has_group',\n name: 'is in the group',\n operands: 1,\n visibility: 'hidden'\n },\n {\n type: 'has_category',\n name: 'has the category',\n operands: 0,\n visibility: 'hidden'\n },\n {\n type: 'has_error',\n name: 'has an error',\n operands: 0,\n categoryName: 'Has Error',\n visibility: 'hidden'\n },\n {\n type: 'has_value',\n name: 'is not empty',\n operands: 0,\n categoryName: 'Not Empty',\n visibility: 'hidden'\n },\n {\n type: 'has_pattern',\n name: 'matches regex',\n operands: 1\n }\n];\n\n// Get operators suitable for wait_for_response rules\nexport const getWaitForResponseOperators = (): OperatorConfig[] => {\n return OPERATORS.filter(\n (op) => op.visibility !== 'hidden' && !op.filter // For now, exclude location operators unless we support feature detection\n );\n};\n\n// Number operator types used for digit-based routing\nconst DIGIT_OPERATOR_TYPES = new Set([\n 'has_beginning',\n 'has_number',\n 'has_number_between',\n 'has_number_lt',\n 'has_number_lte',\n 'has_number_eq',\n 'has_number_gte',\n 'has_number_gt',\n 'has_pattern'\n]);\n\n// Get operators suitable for wait_for_digits rules (number operators + regex)\nexport const getDigitOperators = (): OperatorConfig[] => {\n return OPERATORS.filter((op) => DIGIT_OPERATOR_TYPES.has(op.type));\n};\n\n// Get operator configuration by type\nexport const getOperatorConfig = (type: string): OperatorConfig | undefined => {\n return OPERATORS.find((op) => op.type === type);\n};\n\n// Convert operators to select options\nexport const operatorsToSelectOptions = (operators: OperatorConfig[]) => {\n return operators.map((op) => ({\n value: op.type,\n name: op.name\n }));\n};\n\n// Create an operator object for select components\nexport const createOperatorOption = (\n type: string\n): { value: string; name: string } => {\n const config = getOperatorConfig(type);\n return {\n value: type,\n name: config ? config.name : type\n };\n};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CAAC,EAAE;QACzB,KAAK,EAAE,SAAS;QAChB,KAAK,EAAE,cAAc;QACrB,WAAW,EAAE,qDAAqD;KACnE;IACD,CAAC,aAAa,CAAC,OAAO,CAAC,EAAE;QACvB,KAAK,EAAE,SAAS;QAChB,KAAK,EAAE,SAAS;QAChB,WAAW,EAAE,qCAAqC;KACnD;CACF,CAAC;AAEF;;;GAGG;AACH,MAAM,CAAC,MAAM,oBAAoB,GAAsC;IACrE,CAAC,YAAY,CAAC,IAAI,CAAC,EAAE;QACnB,KAAK,EAAE,SAAS;QAChB,KAAK,EAAE,MAAM;QACb,WAAW,EAAE,2CAA2C;KACzD;IACD,CAAC,YAAY,CAAC,KAAK,CAAC,EAAE;QACpB,KAAK,EAAE,SAAS;QAChB,KAAK,EAAE,OAAO;QACd,WAAW,EAAE,oCAAoC;KAClD;CACF,CAAC","sourcesContent":["import { TemplateResult } from 'lit-html';\nimport { Action, Node, NodeUI } from '../store/flow-definition';\n\nexport interface ValidationResult {\n valid: boolean;\n errors: { [key: string]: string };\n}\n\n/**\n * Flow types - defines the type of flow being edited\n */\nexport const FlowTypes = {\n MESSAGE: 'message',\n VOICE: 'voice',\n BACKGROUND: 'background'\n} as const;\n\nexport type FlowType = (typeof FlowTypes)[keyof typeof FlowTypes];\n\n/**\n * Features - defines the features available in the account\n */\nexport const Features = {\n AI: 'ai',\n AIRTIME: 'airtime'\n} as const;\n\nexport type Feature = (typeof Features)[keyof typeof Features];\n\n// Component attribute interfaces - these define what's allowed for each component type\nexport interface TextInputAttributes {\n type?: 'text' | 'email' | 'number' | 'url' | 'tel';\n placeholder?: string;\n clearable?: boolean;\n maxlength?: number;\n gsm?: boolean;\n autogrow?: boolean;\n textarea?: boolean;\n submitOnEnter?: boolean;\n}\n\nexport interface CompletionAttributes {\n placeholder?: string;\n clearable?: boolean;\n maxlength?: number;\n gsm?: boolean;\n autogrow?: boolean;\n textarea?: boolean;\n expressions?: string;\n counter?: string;\n minHeight?: number;\n}\n\nexport interface SelectAttributes {\n placeholder?: string;\n multi?: boolean;\n searchable?: boolean;\n tags?: boolean;\n emails?: boolean;\n clearable?: boolean;\n endpoint?: string;\n valueKey?: string;\n nameKey?: string;\n queryParam?: string;\n maxItems?: number;\n maxItemsText?: string;\n expressions?: string;\n options?: Array<{ name: string; value: any }>;\n sorted?: boolean;\n allowCreate?: boolean;\n jsonValue?: boolean;\n spaceSelect?: boolean;\n infoText?: string;\n}\n\nexport interface CheckboxAttributes {\n label?: string;\n size?: number;\n disabled?: boolean;\n animateChange?: string;\n}\n\nexport interface SliderAttributes {\n min?: number;\n max?: number;\n range?: boolean;\n}\n\nexport interface FormData extends Record<string, any> {}\n\nexport interface FormConfig {\n form?: Record<string, FieldConfig>;\n layout?: LayoutItem[];\n gutter?: LayoutItem[];\n sanitize?: (formData: FormData) => void;\n validate?: (formData: FormData) => ValidationResult;\n}\n\nexport interface NodeConfig extends FormConfig {\n type: string;\n name?: string;\n aliases?: string[]; // alternate type names for backwards compatibility (won't show in selector)\n group?: ActionGroup | SplitGroup; // Nodes can use either when showAsAction is true\n dialogSize?: 'small' | 'medium' | 'large' | 'xlarge';\n action?: ActionConfig;\n showAsAction?: boolean; // if true, show in action dialog instead of splits (default: false - nodes show in splits)\n flowTypes?: FlowType[]; // which flow types this node is available for (defaults to all if not specified)\n features?: Feature[]; // which features are required for this node (all must be present)\n router?: {\n type: 'switch' | 'random';\n defaultCategory?: string;\n operand?: string;\n configurable?: boolean; // can the rules be configured in the UI\n rules?: {\n type:\n | 'has_number_between'\n | 'has_string'\n | 'has_value'\n | 'has_not_value'\n | 'has_text';\n arguments: string[];\n categoryName: string;\n }[];\n };\n\n toFormData?: (node: Node, nodeUI?: any) => FormData;\n fromFormData?: (formData: FormData, originalNode: Node) => Node;\n toUIConfig?: (formData: FormData) => Record<string, any>;\n render?: (node: Node, nodeUI?: any) => TemplateResult;\n renderTitle?: (node: Node, nodeUI?: NodeUI) => TemplateResult;\n\n // Localization support for router categories\n localizable?: 'categories'; // Only categories are localizable for routers\n toLocalizationFormData?: (\n node: Node,\n localization: Record<string, any>\n ) => FormData;\n fromLocalizationFormData?: (\n formData: FormData,\n node: Node\n ) => Record<string, any>;\n}\n\n// New field configuration system for generic form generation\nexport interface BaseFieldConfig {\n label?: string | ((formData: Record<string, any>) => string);\n required?: boolean;\n evaluated?: boolean;\n dependsOn?: string[];\n computeValue?: (\n values: Record<string, any>,\n currentValue: any,\n originalValues?: Record<string, any>\n ) => any;\n\n // Validation properties\n minLength?: number;\n maxLength?: number;\n pattern?: string;\n helpText?: string;\n\n // Layout properties\n maxWidth?: string;\n width?: string;\n\n // Conditional rendering\n conditions?: {\n visible?: (formData: Record<string, any>) => boolean;\n disabled?: (formData: Record<string, any>) => boolean;\n };\n\n // Optional field with reveal link\n // When set, the field is hidden by default and a link with this text is shown\n // Clicking the link reveals the field permanently (can't be hidden again)\n optionalLink?: string;\n}\n\nexport interface TextFieldConfig extends BaseFieldConfig {\n type: 'text';\n placeholder?: string;\n flavor?: 'xsmall' | 'small' | 'large';\n}\n\nexport interface TextareaFieldConfig extends BaseFieldConfig {\n type: 'textarea';\n placeholder?: string;\n rows?: number;\n minHeight?: number;\n}\n\nexport interface SelectFieldConfig extends BaseFieldConfig {\n type: 'select';\n options?: string[] | { value: string; name: string }[];\n multi?: boolean;\n clearable?: boolean;\n searchable?: boolean;\n tags?: boolean;\n placeholder?: string;\n maxItems?: number;\n valueKey?: string;\n nameKey?: string;\n endpoint?: string;\n emails?: boolean;\n getName?: (item: any) => string;\n flavor?: 'xsmall' | 'small' | 'large';\n createArbitraryOption?: (input: string, options: any[]) => any;\n allowCreate?: boolean;\n getDynamicOptions?: () => Array<{ value: string; name: string }>;\n}\n\nexport interface KeyValueFieldConfig extends BaseFieldConfig {\n type: 'key-value';\n sortable?: boolean;\n keyPlaceholder?: string;\n valuePlaceholder?: string;\n minRows?: number;\n}\n\nexport interface ArrayFieldConfig extends BaseFieldConfig {\n type: 'array';\n itemConfig: Record<string, FieldConfig>;\n sortable?: boolean;\n minItems?: number;\n maxItems?: number;\n itemLabel?: string;\n maintainEmptyItem?: boolean;\n onItemChange?: (\n itemIndex: number,\n field: string,\n value: any,\n allItems: any[]\n ) => any[];\n isEmptyItem?: (item: any) => boolean;\n}\n\nexport interface CheckboxFieldConfig extends BaseFieldConfig {\n type: 'checkbox';\n size?: number;\n animateChange?: string;\n labelPadding?: string;\n}\n\nexport interface MessageEditorFieldConfig extends BaseFieldConfig {\n type: 'message-editor';\n placeholder?: string;\n minHeight?: number;\n maxAttachments?: number;\n accept?: string;\n endpoint?: string;\n counter?: string;\n gsm?: boolean;\n autogrow?: boolean;\n disableCompletion?: boolean;\n}\n\nexport type FieldConfig =\n | TextFieldConfig\n | TextareaFieldConfig\n | SelectFieldConfig\n | KeyValueFieldConfig\n | ArrayFieldConfig\n | CheckboxFieldConfig\n | MessageEditorFieldConfig;\n\n// Layout configurations for better form organization\n// Recursive layout system - any layout item can contain other layout items\n\nexport interface FieldItemConfig {\n type: 'field';\n field: string; // field name to render\n}\n\nexport interface RowLayoutConfig {\n type: 'row';\n items: LayoutItem[]; // can contain fields, groups, or other rows\n gap?: string; // CSS gap value, defaults to '1rem'\n label?: string; // optional label for the entire row\n helpText?: string; // optional help text for the entire row\n}\n\nexport interface GroupLayoutConfig {\n type: 'group';\n label: string;\n items: LayoutItem[]; // can contain fields, rows, or other groups\n collapsible?: boolean;\n collapsed?: boolean | ((formData: FormData) => boolean); // initial state if collapsible - can be a function\n helpText?: string;\n getGroupValueCount?: (formData: FormData) => number; // optional function to get count for bubble display\n}\n\nexport type LayoutItem =\n | FieldItemConfig\n | RowLayoutConfig\n | GroupLayoutConfig\n | string; // string is shorthand for field\n\n/**\n * Action group constants - single source of truth for action categorization\n * Use as const for compile-time type checking\n */\nexport const ACTION_GROUPS = {\n send: 'send',\n contacts: 'contacts',\n save: 'save',\n services: 'services',\n broadcast: 'broadcast',\n trigger: 'trigger'\n} as const;\n\n/**\n * Split group constants - single source of truth for split categorization\n * Use as const for compile-time type checking\n */\nexport const SPLIT_GROUPS = {\n wait: 'wait',\n split: 'split'\n} as const;\n\n// Extract types from const objects for compile-time checking\nexport type ActionGroup = (typeof ACTION_GROUPS)[keyof typeof ACTION_GROUPS];\nexport type SplitGroup = (typeof SPLIT_GROUPS)[keyof typeof SPLIT_GROUPS];\n\n/**\n * Metadata for group display\n */\nexport interface GroupMetadata {\n color: string;\n title: string;\n description: string;\n}\n\n/**\n * Action group metadata - defines display properties for each action group\n * Order in this object determines display order in action selector (top to bottom)\n */\nexport const ACTION_GROUP_METADATA: Record<ActionGroup, GroupMetadata> = {\n [ACTION_GROUPS.send]: {\n color: '#3498db',\n title: 'Send',\n description: 'Actions that send messages or content to contacts'\n },\n [ACTION_GROUPS.contacts]: {\n color: '#01c1af',\n title: 'Contact',\n description: 'Actions that update contact information'\n },\n [ACTION_GROUPS.save]: {\n color: '#1a777c',\n title: 'Save',\n description: 'Actions that save or store data'\n },\n [ACTION_GROUPS.services]: {\n color: '#f79035ff',\n title: 'Services',\n description: 'Call external services and APIs'\n },\n [ACTION_GROUPS.broadcast]: {\n color: '#8e5ea7',\n title: 'Other People',\n description: 'Actions that apply to others instead of the contact'\n },\n [ACTION_GROUPS.trigger]: {\n color: '#df419f',\n title: 'Trigger',\n description: 'Actions that trigger other behavior'\n }\n};\n\n/**\n * Split group metadata - defines display properties for each split group\n * Order in this object determines display order in split selector (top to bottom)\n */\nexport const SPLIT_GROUP_METADATA: Record<SplitGroup, GroupMetadata> = {\n [SPLIT_GROUPS.wait]: {\n color: '#4d7dad',\n title: 'Wait',\n description: 'Wait for user and split on their response'\n },\n [SPLIT_GROUPS.split]: {\n color: '#aaaaaa',\n title: 'Split',\n description: 'Split the flow based on conditions'\n }\n};\n\nexport interface ActionConfig extends FormConfig {\n name: string;\n aliases?: string[]; // alternate type names for backwards compatibility (won't show in selector)\n group: ActionGroup;\n dialogSize?: 'small' | 'medium' | 'large' | 'xlarge';\n evaluated?: string[];\n hideFromActions?: boolean; // if true, don't show in action dialog (default: false - actions show in actions)\n flowTypes?: FlowType[]; // which flow types this action is available for (defaults to all if not specified)\n features?: Feature[]; // which features are required for this action (all must be present)\n render?: (node: any, action: any) => TemplateResult;\n\n form?: Record<string, FieldConfig>;\n layout?: LayoutItem[]; // optional layout configuration - array of layout items\n gutter?: LayoutItem[]; // fields to render in the dialog gutter (left side of buttons)\n\n toFormData?: (action: Action) => FormData;\n fromFormData?: (formData: FormData) => Action;\n\n // Localization support\n localizable?: string[]; // array of field names that can be localized\n toLocalizationFormData?: (\n action: Action,\n localization: Record<string, any>\n ) => FormData;\n fromLocalizationFormData?: (\n formData: FormData,\n action: Action\n ) => Record<string, any>;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/flow/types.ts"],"names":[],"mappings":"AAQA;;GAEG;AACH,MAAM,CAAC,MAAM,SAAS,GAAG;IACvB,OAAO,EAAE,SAAS;IAClB,KAAK,EAAE,OAAO;IACd,UAAU,EAAE,YAAY;CAChB,CAAC;AAIX;;GAEG;AACH,MAAM,CAAC,MAAM,QAAQ,GAAG;IACtB,EAAE,EAAE,IAAI;IACR,OAAO,EAAE,SAAS;CACV,CAAC;AAqSX;;;GAGG;AACH,MAAM,CAAC,MAAM,aAAa,GAAG;IAC3B,IAAI,EAAE,MAAM;IACZ,QAAQ,EAAE,UAAU;IACpB,IAAI,EAAE,MAAM;IACZ,QAAQ,EAAE,UAAU;IACpB,SAAS,EAAE,WAAW;IACtB,OAAO,EAAE,SAAS;CACV,CAAC;AAEX;;;GAGG;AACH,MAAM,CAAC,MAAM,YAAY,GAAG;IAC1B,IAAI,EAAE,MAAM;IACZ,KAAK,EAAE,OAAO;CACN,CAAC;AAeX;;;GAGG;AACH,MAAM,CAAC,MAAM,qBAAqB,GAAuC;IACvE,CAAC,aAAa,CAAC,IAAI,CAAC,EAAE;QACpB,KAAK,EAAE,SAAS;QAChB,KAAK,EAAE,MAAM;QACb,WAAW,EAAE,mDAAmD;KACjE;IACD,CAAC,aAAa,CAAC,QAAQ,CAAC,EAAE;QACxB,KAAK,EAAE,SAAS;QAChB,KAAK,EAAE,SAAS;QAChB,WAAW,EAAE,yCAAyC;KACvD;IACD,CAAC,aAAa,CAAC,IAAI,CAAC,EAAE;QACpB,KAAK,EAAE,SAAS;QAChB,KAAK,EAAE,MAAM;QACb,WAAW,EAAE,iCAAiC;KAC/C;IACD,CAAC,aAAa,CAAC,QAAQ,CAAC,EAAE;QACxB,KAAK,EAAE,WAAW;QAClB,KAAK,EAAE,UAAU;QACjB,WAAW,EAAE,iCAAiC;KAC/C;IACD,CAAC,aAAa,CAAC,SAAS,CAAC,EAAE;QACzB,KAAK,EAAE,SAAS;QAChB,KAAK,EAAE,cAAc;QACrB,WAAW,EAAE,qDAAqD;KACnE;IACD,CAAC,aAAa,CAAC,OAAO,CAAC,EAAE;QACvB,KAAK,EAAE,SAAS;QAChB,KAAK,EAAE,SAAS;QAChB,WAAW,EAAE,qCAAqC;KACnD;CACF,CAAC;AAEF;;;GAGG;AACH,MAAM,CAAC,MAAM,oBAAoB,GAAsC;IACrE,CAAC,YAAY,CAAC,IAAI,CAAC,EAAE;QACnB,KAAK,EAAE,SAAS;QAChB,KAAK,EAAE,MAAM;QACb,WAAW,EAAE,2CAA2C;KACzD;IACD,CAAC,YAAY,CAAC,KAAK,CAAC,EAAE;QACpB,KAAK,EAAE,SAAS;QAChB,KAAK,EAAE,OAAO;QACd,WAAW,EAAE,oCAAoC;KAClD;CACF,CAAC","sourcesContent":["import { TemplateResult } from 'lit-html';\nimport { Action, Node, NodeUI } from '../store/flow-definition';\n\nexport interface ValidationResult {\n valid: boolean;\n errors: { [key: string]: string };\n}\n\n/**\n * Flow types - defines the type of flow being edited\n */\nexport const FlowTypes = {\n MESSAGE: 'message',\n VOICE: 'voice',\n BACKGROUND: 'background'\n} as const;\n\nexport type FlowType = (typeof FlowTypes)[keyof typeof FlowTypes];\n\n/**\n * Features - defines the features available in the account\n */\nexport const Features = {\n AI: 'ai',\n AIRTIME: 'airtime'\n} as const;\n\nexport type Feature = (typeof Features)[keyof typeof Features];\n\n// Component attribute interfaces - these define what's allowed for each component type\nexport interface TextInputAttributes {\n type?: 'text' | 'email' | 'number' | 'url' | 'tel';\n placeholder?: string;\n clearable?: boolean;\n maxlength?: number;\n gsm?: boolean;\n autogrow?: boolean;\n textarea?: boolean;\n submitOnEnter?: boolean;\n}\n\nexport interface CompletionAttributes {\n placeholder?: string;\n clearable?: boolean;\n maxlength?: number;\n gsm?: boolean;\n autogrow?: boolean;\n textarea?: boolean;\n expressions?: string;\n counter?: string;\n minHeight?: number;\n}\n\nexport interface SelectAttributes {\n placeholder?: string;\n multi?: boolean;\n searchable?: boolean;\n tags?: boolean;\n emails?: boolean;\n clearable?: boolean;\n endpoint?: string;\n valueKey?: string;\n nameKey?: string;\n queryParam?: string;\n maxItems?: number;\n maxItemsText?: string;\n expressions?: string;\n options?: Array<{ name: string; value: any }>;\n sorted?: boolean;\n allowCreate?: boolean;\n jsonValue?: boolean;\n spaceSelect?: boolean;\n infoText?: string;\n}\n\nexport interface CheckboxAttributes {\n label?: string;\n size?: number;\n disabled?: boolean;\n animateChange?: string;\n}\n\nexport interface SliderAttributes {\n min?: number;\n max?: number;\n range?: boolean;\n}\n\nexport interface FormData extends Record<string, any> {}\n\nexport interface FormConfig {\n form?: Record<string, FieldConfig>;\n layout?: LayoutItem[];\n gutter?: LayoutItem[];\n sanitize?: (formData: FormData) => void;\n validate?: (formData: FormData) => ValidationResult;\n}\n\nexport interface NodeConfig extends FormConfig {\n type: string;\n name?: string;\n aliases?: string[]; // alternate type names for backwards compatibility (won't show in selector)\n group?: ActionGroup | SplitGroup; // Nodes can use either when showAsAction is true\n dialogSize?: 'small' | 'medium' | 'large' | 'xlarge';\n action?: ActionConfig;\n showAsAction?: boolean; // if true, show in action dialog instead of splits (default: false - nodes show in splits)\n flowTypes?: FlowType[]; // which flow types this node is available for (defaults to all if not specified)\n features?: Feature[]; // which features are required for this node (all must be present)\n router?: {\n type: 'switch' | 'random';\n defaultCategory?: string;\n operand?: string;\n configurable?: boolean; // can the rules be configured in the UI\n rules?: {\n type:\n | 'has_number_between'\n | 'has_number_eq'\n | 'has_only_text'\n | 'has_string'\n | 'has_value'\n | 'has_not_value'\n | 'has_text';\n arguments: string[];\n categoryName: string;\n }[];\n };\n\n toFormData?: (node: Node, nodeUI?: any) => FormData;\n fromFormData?: (formData: FormData, originalNode: Node) => Node;\n toUIConfig?: (formData: FormData) => Record<string, any>;\n render?: (node: Node, nodeUI?: any) => TemplateResult;\n renderTitle?: (node: Node, nodeUI?: NodeUI) => TemplateResult;\n\n // Localization support for router categories\n localizable?: 'categories'; // Only categories are localizable for routers\n toLocalizationFormData?: (\n node: Node,\n localization: Record<string, any>\n ) => FormData;\n fromLocalizationFormData?: (\n formData: FormData,\n node: Node\n ) => Record<string, any>;\n}\n\n// New field configuration system for generic form generation\nexport interface BaseFieldConfig {\n label?: string | ((formData: Record<string, any>) => string);\n required?: boolean;\n evaluated?: boolean;\n dependsOn?: string[];\n computeValue?: (\n values: Record<string, any>,\n currentValue: any,\n originalValues?: Record<string, any>\n ) => any;\n\n // Validation properties\n minLength?: number;\n maxLength?: number;\n pattern?: string;\n helpText?: string;\n\n // Layout properties\n maxWidth?: string;\n width?: string;\n\n // Conditional rendering\n conditions?: {\n visible?: (formData: Record<string, any>) => boolean;\n disabled?: (formData: Record<string, any>) => boolean;\n };\n\n // Optional field with reveal link\n // When set, the field is hidden by default and a link with this text is shown\n // Clicking the link reveals the field permanently (can't be hidden again)\n optionalLink?: string;\n}\n\nexport interface TextFieldConfig extends BaseFieldConfig {\n type: 'text';\n placeholder?: string;\n flavor?: 'xsmall' | 'small' | 'large';\n}\n\nexport interface TextareaFieldConfig extends BaseFieldConfig {\n type: 'textarea';\n placeholder?: string;\n rows?: number;\n minHeight?: number;\n}\n\nexport interface SelectFieldConfig extends BaseFieldConfig {\n type: 'select';\n options?: string[] | { value: string; name: string }[];\n multi?: boolean;\n clearable?: boolean;\n searchable?: boolean;\n tags?: boolean;\n placeholder?: string;\n maxItems?: number;\n valueKey?: string;\n nameKey?: string;\n endpoint?: string;\n emails?: boolean;\n getName?: (item: any) => string;\n flavor?: 'xsmall' | 'small' | 'large';\n createArbitraryOption?: (input: string, options: any[]) => any;\n allowCreate?: boolean;\n getDynamicOptions?: () => Array<{ value: string; name: string }>;\n}\n\nexport interface KeyValueFieldConfig extends BaseFieldConfig {\n type: 'key-value';\n sortable?: boolean;\n keyPlaceholder?: string;\n valuePlaceholder?: string;\n minRows?: number;\n}\n\nexport interface ArrayFieldConfig extends BaseFieldConfig {\n type: 'array';\n itemConfig: Record<string, FieldConfig>;\n sortable?: boolean;\n minItems?: number;\n maxItems?: number;\n itemLabel?: string;\n maintainEmptyItem?: boolean;\n onItemChange?: (\n itemIndex: number,\n field: string,\n value: any,\n allItems: any[]\n ) => any[];\n isEmptyItem?: (item: any) => boolean;\n}\n\nexport interface CheckboxFieldConfig extends BaseFieldConfig {\n type: 'checkbox';\n size?: number;\n animateChange?: string;\n labelPadding?: string;\n}\n\nexport interface MessageEditorFieldConfig extends BaseFieldConfig {\n type: 'message-editor';\n placeholder?: string;\n minHeight?: number;\n maxAttachments?: number;\n accept?: string;\n endpoint?: string;\n counter?: string;\n gsm?: boolean;\n autogrow?: boolean;\n disableCompletion?: boolean;\n}\n\nexport interface MediaFieldConfig extends BaseFieldConfig {\n type: 'media';\n accept?: string; // MIME filter, e.g. 'audio/*'\n endpoint?: string; // upload endpoint, defaults to DEFAULT_MEDIA_ENDPOINT\n}\n\nexport type FieldConfig =\n | TextFieldConfig\n | TextareaFieldConfig\n | SelectFieldConfig\n | KeyValueFieldConfig\n | ArrayFieldConfig\n | CheckboxFieldConfig\n | MessageEditorFieldConfig\n | MediaFieldConfig;\n\n// Layout configurations for better form organization\n// Recursive layout system - any layout item can contain other layout items\n\nexport interface FieldItemConfig {\n type: 'field';\n field: string; // field name to render\n}\n\nexport interface RowLayoutConfig {\n type: 'row';\n items: LayoutItem[]; // can contain fields, groups, or other rows\n gap?: string; // CSS gap value, defaults to '1rem'\n label?: string; // optional label for the entire row\n helpText?: string; // optional help text for the entire row\n inlineLabels?: Record<string, string>; // map of field name to inline label text\n marginBottom?: string; // CSS margin-bottom for spacing below the row\n}\n\nexport interface GroupLayoutConfig {\n type: 'group';\n label: string;\n items: LayoutItem[]; // can contain fields, rows, or other groups\n collapsible?: boolean;\n collapsed?: boolean | ((formData: FormData) => boolean); // initial state if collapsible - can be a function\n helpText?: string;\n getGroupValueCount?: (formData: FormData) => number; // optional function to get count for bubble display\n}\n\nexport interface SpacerLayoutConfig {\n type: 'spacer';\n}\n\nexport interface TextLayoutConfig {\n type: 'text';\n text: string;\n}\n\nexport type LayoutItem =\n | FieldItemConfig\n | RowLayoutConfig\n | GroupLayoutConfig\n | SpacerLayoutConfig\n | TextLayoutConfig\n | string; // string is shorthand for field\n\n/**\n * Action group constants - single source of truth for action categorization\n * Use as const for compile-time type checking\n */\nexport const ACTION_GROUPS = {\n send: 'send',\n contacts: 'contacts',\n save: 'save',\n services: 'services',\n broadcast: 'broadcast',\n trigger: 'trigger'\n} as const;\n\n/**\n * Split group constants - single source of truth for split categorization\n * Use as const for compile-time type checking\n */\nexport const SPLIT_GROUPS = {\n wait: 'wait',\n split: 'split'\n} as const;\n\n// Extract types from const objects for compile-time checking\nexport type ActionGroup = (typeof ACTION_GROUPS)[keyof typeof ACTION_GROUPS];\nexport type SplitGroup = (typeof SPLIT_GROUPS)[keyof typeof SPLIT_GROUPS];\n\n/**\n * Metadata for group display\n */\nexport interface GroupMetadata {\n color: string;\n title: string;\n description: string;\n}\n\n/**\n * Action group metadata - defines display properties for each action group\n * Order in this object determines display order in action selector (top to bottom)\n */\nexport const ACTION_GROUP_METADATA: Record<ActionGroup, GroupMetadata> = {\n [ACTION_GROUPS.send]: {\n color: '#3498db',\n title: 'Send',\n description: 'Actions that send messages or content to contacts'\n },\n [ACTION_GROUPS.contacts]: {\n color: '#01c1af',\n title: 'Contact',\n description: 'Actions that update contact information'\n },\n [ACTION_GROUPS.save]: {\n color: '#1a777c',\n title: 'Save',\n description: 'Actions that save or store data'\n },\n [ACTION_GROUPS.services]: {\n color: '#f79035ff',\n title: 'Services',\n description: 'Call external services and APIs'\n },\n [ACTION_GROUPS.broadcast]: {\n color: '#8e5ea7',\n title: 'Other People',\n description: 'Actions that apply to others instead of the contact'\n },\n [ACTION_GROUPS.trigger]: {\n color: '#df419f',\n title: 'Trigger',\n description: 'Actions that trigger other behavior'\n }\n};\n\n/**\n * Split group metadata - defines display properties for each split group\n * Order in this object determines display order in split selector (top to bottom)\n */\nexport const SPLIT_GROUP_METADATA: Record<SplitGroup, GroupMetadata> = {\n [SPLIT_GROUPS.wait]: {\n color: '#4d7dad',\n title: 'Wait',\n description: 'Wait for user and split on their response'\n },\n [SPLIT_GROUPS.split]: {\n color: '#aaaaaa',\n title: 'Split',\n description: 'Split the flow based on conditions'\n }\n};\n\nexport interface ActionConfig extends FormConfig {\n name: string;\n aliases?: string[]; // alternate type names for backwards compatibility (won't show in selector)\n group: ActionGroup;\n dialogSize?: 'small' | 'medium' | 'large' | 'xlarge';\n evaluated?: string[];\n hideFromActions?: boolean; // if true, don't show in action dialog (default: false - actions show in actions)\n flowTypes?: FlowType[]; // which flow types this action is available for (defaults to all if not specified)\n features?: Feature[]; // which features are required for this action (all must be present)\n render?: (node: any, action: any) => TemplateResult;\n\n form?: Record<string, FieldConfig>;\n layout?: LayoutItem[]; // optional layout configuration - array of layout items\n gutter?: LayoutItem[]; // fields to render in the dialog gutter (left side of buttons)\n\n toFormData?: (action: Action) => FormData;\n fromFormData?: (formData: FormData) => Action;\n\n // Localization support\n localizable?: string[]; // array of field names that can be localized\n toLocalizationFormData?: (\n action: Action,\n localization: Record<string, any>\n ) => FormData;\n fromLocalizationFormData?: (\n formData: FormData,\n action: Action\n ) => Record<string, any>;\n}\n"]}
|
|
@@ -1,4 +1,11 @@
|
|
|
1
1
|
import { html } from 'lit-html';
|
|
2
|
+
export function formatIssueMessage(issue) {
|
|
3
|
+
if (issue.dependency) {
|
|
4
|
+
const name = issue.dependency.name || issue.dependency.key;
|
|
5
|
+
return `Cannot find a ${issue.dependency.type} for ${name}`;
|
|
6
|
+
}
|
|
7
|
+
return issue.description;
|
|
8
|
+
}
|
|
2
9
|
const GRID_SIZE = 20;
|
|
3
10
|
export function snapToGrid(value) {
|
|
4
11
|
const snapped = Math.round(value / GRID_SIZE) * GRID_SIZE;
|
|
@@ -270,6 +277,25 @@ export const calculateReflowPositions = (sacredNodeUuids, allBounds) => {
|
|
|
270
277
|
for (const b of allBounds) {
|
|
271
278
|
currentBounds.set(b.uuid, { ...b });
|
|
272
279
|
}
|
|
280
|
+
// A sacred node yields to an existing node at the top of the canvas when
|
|
281
|
+
// the sacred wasn't dropped above it. The existing node keeps its top
|
|
282
|
+
// position and the sacred node moves below instead.
|
|
283
|
+
for (const sacredUuid of [...sacredSet]) {
|
|
284
|
+
const sacred = currentBounds.get(sacredUuid);
|
|
285
|
+
if (!sacred)
|
|
286
|
+
continue;
|
|
287
|
+
for (const [uuid, bounds] of currentBounds) {
|
|
288
|
+
if (uuid === sacredUuid || sacredSet.has(uuid))
|
|
289
|
+
continue;
|
|
290
|
+
if (!nodesOverlap(sacred, bounds))
|
|
291
|
+
continue;
|
|
292
|
+
if (sacred.top > bounds.top && bounds.top < MIN_NODE_SPACING) {
|
|
293
|
+
sacredSet.delete(sacredUuid);
|
|
294
|
+
sacredSet.add(uuid);
|
|
295
|
+
break;
|
|
296
|
+
}
|
|
297
|
+
}
|
|
298
|
+
}
|
|
273
299
|
// Seed the queue with non-sacred nodes that overlap any sacred node
|
|
274
300
|
const queue = [];
|
|
275
301
|
const inQueue = new Set();
|
|
@@ -308,10 +334,47 @@ export const calculateReflowPositions = (sacredNodeUuids, allBounds) => {
|
|
|
308
334
|
}
|
|
309
335
|
if (fixedOverlaps.length === 0)
|
|
310
336
|
continue;
|
|
311
|
-
//
|
|
337
|
+
// Determine direction constraints and axis bias from sacred node overlaps
|
|
338
|
+
const sacredOverlaps = fixedOverlaps.filter((f) => sacredSet.has(f.uuid));
|
|
339
|
+
const allowedDirections = [...DIRECTIONS];
|
|
340
|
+
let axisBias = null;
|
|
341
|
+
if (sacredOverlaps.length > 0) {
|
|
342
|
+
// Rule 1: don't move a lower node above the sacred node
|
|
343
|
+
// Rule 2: don't move a right-of node to the left of the sacred node
|
|
344
|
+
for (const sacred of sacredOverlaps) {
|
|
345
|
+
if (collider.top > sacred.top) {
|
|
346
|
+
const idx = allowedDirections.indexOf('up');
|
|
347
|
+
if (idx !== -1)
|
|
348
|
+
allowedDirections.splice(idx, 1);
|
|
349
|
+
}
|
|
350
|
+
if (collider.left > sacred.left) {
|
|
351
|
+
const idx = allowedDirections.indexOf('left');
|
|
352
|
+
if (idx !== -1)
|
|
353
|
+
allowedDirections.splice(idx, 1);
|
|
354
|
+
}
|
|
355
|
+
}
|
|
356
|
+
// Rule 3: bias direction based on overlap shape
|
|
357
|
+
let totalOverlapWidth = 0;
|
|
358
|
+
let totalOverlapHeight = 0;
|
|
359
|
+
for (const sacred of sacredOverlaps) {
|
|
360
|
+
totalOverlapWidth +=
|
|
361
|
+
Math.min(collider.right, sacred.right) -
|
|
362
|
+
Math.max(collider.left, sacred.left);
|
|
363
|
+
totalOverlapHeight +=
|
|
364
|
+
Math.min(collider.bottom, sacred.bottom) -
|
|
365
|
+
Math.max(collider.top, sacred.top);
|
|
366
|
+
}
|
|
367
|
+
if (totalOverlapWidth > totalOverlapHeight) {
|
|
368
|
+
axisBias = 'vertical'; // wide overlap = nodes stacked = prefer up/down
|
|
369
|
+
}
|
|
370
|
+
else if (totalOverlapHeight > totalOverlapWidth) {
|
|
371
|
+
axisBias = 'horizontal'; // tall overlap = nodes side-by-side = prefer left/right
|
|
372
|
+
}
|
|
373
|
+
}
|
|
374
|
+
// Try each allowed direction, pick the one with least disruption
|
|
312
375
|
let bestPos = null;
|
|
313
376
|
let bestScore = Infinity;
|
|
314
|
-
for (const dir of
|
|
377
|
+
for (const dir of allowedDirections) {
|
|
315
378
|
const candidate = computeDirectionalClearance(collider, fixedOverlaps, dir);
|
|
316
379
|
if (!candidate)
|
|
317
380
|
continue;
|
|
@@ -334,7 +397,20 @@ export const calculateReflowPositions = (sacredNodeUuids, allBounds) => {
|
|
|
334
397
|
continue;
|
|
335
398
|
const distance = Math.abs(candidate.left - collider.left) +
|
|
336
399
|
Math.abs(candidate.top - collider.top);
|
|
337
|
-
|
|
400
|
+
// When colliding with sacred nodes, use axis bias scoring;
|
|
401
|
+
// for cascading collisions (no sacred overlap), use original scoring
|
|
402
|
+
let score;
|
|
403
|
+
if (sacredOverlaps.length > 0) {
|
|
404
|
+
const isVerticalDir = dir === 'up' || dir === 'down';
|
|
405
|
+
const axisMatch = axisBias === null ||
|
|
406
|
+
(axisBias === 'vertical' && isVerticalDir) ||
|
|
407
|
+
(axisBias === 'horizontal' && !isVerticalDir);
|
|
408
|
+
const axisPenalty = axisMatch ? 0 : 5000;
|
|
409
|
+
score = cascadeCount * 2000 + axisPenalty + distance;
|
|
410
|
+
}
|
|
411
|
+
else {
|
|
412
|
+
score = cascadeCount * 10000 + distance;
|
|
413
|
+
}
|
|
338
414
|
if (score < bestScore) {
|
|
339
415
|
bestScore = score;
|
|
340
416
|
bestPos = candidate;
|