@nyaruka/temba-components 0.131.1 → 0.131.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.github/workflows/publish.yml +4 -1
- package/CHANGELOG.md +61 -1
- package/demo/data/flows/food-order.json +2 -2
- package/demo/data/flows/sample-flow.json +74 -125
- package/dist/static/svg/index.svg +1 -1
- package/dist/temba-components.js +1155 -618
- package/dist/temba-components.js.map +1 -1
- package/out-tsc/src/Icons.js +4 -1
- package/out-tsc/src/Icons.js.map +1 -1
- package/out-tsc/src/events.js.map +1 -1
- package/out-tsc/src/flow/CanvasMenu.js +200 -0
- package/out-tsc/src/flow/CanvasMenu.js.map +1 -0
- package/out-tsc/src/flow/CanvasNode.js +327 -19
- package/out-tsc/src/flow/CanvasNode.js.map +1 -1
- package/out-tsc/src/flow/Editor.js +562 -66
- package/out-tsc/src/flow/Editor.js.map +1 -1
- package/out-tsc/src/flow/NodeEditor.js +240 -93
- package/out-tsc/src/flow/NodeEditor.js.map +1 -1
- package/out-tsc/src/flow/NodeTypeSelector.js +499 -0
- package/out-tsc/src/flow/NodeTypeSelector.js.map +1 -0
- package/out-tsc/src/flow/actions/add_contact_groups.js +3 -3
- package/out-tsc/src/flow/actions/add_contact_groups.js.map +1 -1
- package/out-tsc/src/flow/actions/add_contact_urn.js +62 -4
- package/out-tsc/src/flow/actions/add_contact_urn.js.map +1 -1
- package/out-tsc/src/flow/actions/add_input_labels.js +3 -3
- package/out-tsc/src/flow/actions/add_input_labels.js.map +1 -1
- package/out-tsc/src/flow/actions/play_audio.js +2 -2
- package/out-tsc/src/flow/actions/play_audio.js.map +1 -1
- package/out-tsc/src/flow/actions/remove_contact_groups.js +6 -5
- package/out-tsc/src/flow/actions/remove_contact_groups.js.map +1 -1
- package/out-tsc/src/flow/actions/request_optin.js +2 -2
- package/out-tsc/src/flow/actions/request_optin.js.map +1 -1
- package/out-tsc/src/flow/actions/say_msg.js +2 -2
- package/out-tsc/src/flow/actions/say_msg.js.map +1 -1
- package/out-tsc/src/flow/actions/send_broadcast.js +76 -23
- package/out-tsc/src/flow/actions/send_broadcast.js.map +1 -1
- package/out-tsc/src/flow/actions/send_email.js +4 -5
- package/out-tsc/src/flow/actions/send_email.js.map +1 -1
- package/out-tsc/src/flow/actions/send_msg.js +9 -19
- package/out-tsc/src/flow/actions/send_msg.js.map +1 -1
- package/out-tsc/src/flow/actions/set_contact_channel.js +5 -9
- package/out-tsc/src/flow/actions/set_contact_channel.js.map +1 -1
- package/out-tsc/src/flow/actions/set_contact_field.js +19 -20
- package/out-tsc/src/flow/actions/set_contact_field.js.map +1 -1
- package/out-tsc/src/flow/actions/set_contact_language.js +2 -2
- package/out-tsc/src/flow/actions/set_contact_language.js.map +1 -1
- package/out-tsc/src/flow/actions/set_contact_name.js +2 -12
- package/out-tsc/src/flow/actions/set_contact_name.js.map +1 -1
- package/out-tsc/src/flow/actions/set_contact_status.js +2 -2
- package/out-tsc/src/flow/actions/set_contact_status.js.map +1 -1
- package/out-tsc/src/flow/actions/set_run_result.js +3 -3
- package/out-tsc/src/flow/actions/set_run_result.js.map +1 -1
- package/out-tsc/src/flow/actions/start_session.js +180 -6
- package/out-tsc/src/flow/actions/start_session.js.map +1 -1
- package/out-tsc/src/flow/config.js +11 -15
- package/out-tsc/src/flow/config.js.map +1 -1
- package/out-tsc/src/flow/currencies.js +45 -0
- package/out-tsc/src/flow/currencies.js.map +1 -0
- package/out-tsc/src/flow/nodes/shared-rules.js +257 -0
- package/out-tsc/src/flow/nodes/shared-rules.js.map +1 -0
- package/out-tsc/src/flow/nodes/shared.js +17 -0
- package/out-tsc/src/flow/nodes/shared.js.map +1 -0
- package/out-tsc/src/flow/nodes/split_by_airtime.js +205 -5
- package/out-tsc/src/flow/nodes/split_by_airtime.js.map +1 -1
- package/out-tsc/src/flow/nodes/split_by_contact_field.js +147 -3
- package/out-tsc/src/flow/nodes/split_by_contact_field.js.map +1 -1
- package/out-tsc/src/flow/nodes/split_by_expression.js +68 -2
- package/out-tsc/src/flow/nodes/split_by_expression.js.map +1 -1
- package/out-tsc/src/flow/nodes/split_by_groups.js +12 -9
- package/out-tsc/src/flow/nodes/split_by_groups.js.map +1 -1
- package/out-tsc/src/flow/nodes/split_by_intent.js +7 -0
- package/out-tsc/src/flow/nodes/split_by_intent.js.map +1 -0
- package/out-tsc/src/flow/nodes/split_by_llm.js +3 -2
- package/out-tsc/src/flow/nodes/split_by_llm.js.map +1 -1
- package/out-tsc/src/flow/nodes/split_by_llm_categorize.js +2 -2
- package/out-tsc/src/flow/nodes/split_by_llm_categorize.js.map +1 -1
- package/out-tsc/src/flow/nodes/split_by_random.js +3 -3
- package/out-tsc/src/flow/nodes/split_by_random.js.map +1 -1
- package/out-tsc/src/flow/nodes/split_by_resthook.js +108 -0
- package/out-tsc/src/flow/nodes/split_by_resthook.js.map +1 -0
- package/out-tsc/src/flow/nodes/split_by_run_result.js +206 -3
- package/out-tsc/src/flow/nodes/split_by_run_result.js.map +1 -1
- package/out-tsc/src/flow/nodes/split_by_scheme.js +153 -2
- package/out-tsc/src/flow/nodes/split_by_scheme.js.map +1 -1
- package/out-tsc/src/flow/nodes/split_by_subflow.js +6 -4
- package/out-tsc/src/flow/nodes/split_by_subflow.js.map +1 -1
- package/out-tsc/src/flow/nodes/split_by_ticket.js +3 -2
- package/out-tsc/src/flow/nodes/split_by_ticket.js.map +1 -1
- package/out-tsc/src/flow/nodes/split_by_webhook.js +3 -2
- package/out-tsc/src/flow/nodes/split_by_webhook.js.map +1 -1
- package/out-tsc/src/flow/nodes/wait_for_audio.js +2 -2
- package/out-tsc/src/flow/nodes/wait_for_audio.js.map +1 -1
- package/out-tsc/src/flow/nodes/wait_for_digits.js +2 -2
- package/out-tsc/src/flow/nodes/wait_for_digits.js.map +1 -1
- package/out-tsc/src/flow/nodes/wait_for_image.js +2 -2
- package/out-tsc/src/flow/nodes/wait_for_image.js.map +1 -1
- package/out-tsc/src/flow/nodes/wait_for_location.js +2 -2
- package/out-tsc/src/flow/nodes/wait_for_location.js.map +1 -1
- package/out-tsc/src/flow/nodes/wait_for_menu.js +2 -2
- package/out-tsc/src/flow/nodes/wait_for_menu.js.map +1 -1
- package/out-tsc/src/flow/nodes/wait_for_response.js +32 -567
- package/out-tsc/src/flow/nodes/wait_for_response.js.map +1 -1
- package/out-tsc/src/flow/nodes/wait_for_video.js +2 -2
- package/out-tsc/src/flow/nodes/wait_for_video.js.map +1 -1
- package/out-tsc/src/flow/types.js +71 -12
- package/out-tsc/src/flow/types.js.map +1 -1
- package/out-tsc/src/flow/utils.js +101 -14
- package/out-tsc/src/flow/utils.js.map +1 -1
- package/out-tsc/src/form/FieldRenderer.js +2 -4
- package/out-tsc/src/form/FieldRenderer.js.map +1 -1
- package/out-tsc/src/interfaces.js +3 -0
- package/out-tsc/src/interfaces.js.map +1 -1
- package/out-tsc/src/list/SortableList.js +98 -33
- package/out-tsc/src/list/SortableList.js.map +1 -1
- package/out-tsc/src/live/ContactChat.js +15 -18
- package/out-tsc/src/live/ContactChat.js.map +1 -1
- package/out-tsc/src/store/AppState.js +53 -0
- package/out-tsc/src/store/AppState.js.map +1 -1
- package/out-tsc/src/utils.js +254 -13
- package/out-tsc/src/utils.js.map +1 -1
- package/out-tsc/temba-modules.js +4 -0
- package/out-tsc/temba-modules.js.map +1 -1
- package/out-tsc/test/ActionHelper.js +3 -3
- package/out-tsc/test/ActionHelper.js.map +1 -1
- package/out-tsc/test/NodeHelper.js +6 -3
- package/out-tsc/test/NodeHelper.js.map +1 -1
- package/out-tsc/test/actions/add_contact_urn.test.js +202 -0
- package/out-tsc/test/actions/add_contact_urn.test.js.map +1 -0
- package/out-tsc/test/actions/send_broadcast.test.js +148 -0
- package/out-tsc/test/actions/send_broadcast.test.js.map +1 -0
- package/out-tsc/test/actions/send_email.test.js +17 -23
- package/out-tsc/test/actions/send_email.test.js.map +1 -1
- package/out-tsc/test/actions/send_msg.test.js +33 -15
- package/out-tsc/test/actions/send_msg.test.js.map +1 -1
- package/out-tsc/test/actions/start_session.test.js +116 -0
- package/out-tsc/test/actions/start_session.test.js.map +1 -0
- package/out-tsc/test/nodes/split_by_airtime.test.js +604 -0
- package/out-tsc/test/nodes/split_by_airtime.test.js.map +1 -0
- package/out-tsc/test/nodes/split_by_contact_field.test.js +387 -0
- package/out-tsc/test/nodes/split_by_contact_field.test.js.map +1 -0
- package/out-tsc/test/nodes/split_by_expression.test.js +614 -0
- package/out-tsc/test/nodes/split_by_expression.test.js.map +1 -0
- package/out-tsc/test/nodes/split_by_random.test.js +3 -3
- package/out-tsc/test/nodes/split_by_random.test.js.map +1 -1
- package/out-tsc/test/nodes/split_by_resthook.test.js +337 -0
- package/out-tsc/test/nodes/split_by_resthook.test.js.map +1 -0
- package/out-tsc/test/nodes/split_by_run_result.test.js +920 -0
- package/out-tsc/test/nodes/split_by_run_result.test.js.map +1 -0
- package/out-tsc/test/nodes/split_by_scheme.test.js +399 -0
- package/out-tsc/test/nodes/split_by_scheme.test.js.map +1 -0
- package/out-tsc/test/nodes/split_by_subflow.test.js +333 -0
- package/out-tsc/test/nodes/split_by_subflow.test.js.map +1 -0
- package/out-tsc/test/nodes/wait_for_digits.test.js +2 -2
- package/out-tsc/test/nodes/wait_for_digits.test.js.map +1 -1
- package/out-tsc/test/nodes/wait_for_response.test.js +2 -1
- package/out-tsc/test/nodes/wait_for_response.test.js.map +1 -1
- package/out-tsc/test/temba-action-drag-between-nodes.test.js +252 -0
- package/out-tsc/test/temba-action-drag-between-nodes.test.js.map +1 -0
- package/out-tsc/test/temba-canvas-menu.test.js +122 -0
- package/out-tsc/test/temba-canvas-menu.test.js.map +1 -0
- package/out-tsc/test/temba-flow-editor-node.test.js +85 -2
- package/out-tsc/test/temba-flow-editor-node.test.js.map +1 -1
- package/out-tsc/test/temba-flow-editor.test.js +7 -8
- package/out-tsc/test/temba-flow-editor.test.js.map +1 -1
- package/out-tsc/test/temba-node-editor.test.js +3 -1
- package/out-tsc/test/temba-node-editor.test.js.map +1 -1
- package/out-tsc/test/temba-node-type-selector.test.js +115 -0
- package/out-tsc/test/temba-node-type-selector.test.js.map +1 -0
- package/out-tsc/test/temba-omnibox.test.js +2 -1
- package/out-tsc/test/temba-omnibox.test.js.map +1 -1
- package/out-tsc/test/temba-sortable-list.test.js +51 -0
- package/out-tsc/test/temba-sortable-list.test.js.map +1 -1
- package/out-tsc/test/temba-utils-index.test.js +1 -27
- package/out-tsc/test/temba-utils-index.test.js.map +1 -1
- package/out-tsc/test/utils.test.js +2 -0
- package/out-tsc/test/utils.test.js.map +1 -1
- package/package.json +2 -1
- package/screenshots/truth/actions/add_contact_groups/editor/descriptive-group-names.png +0 -0
- package/screenshots/truth/actions/add_contact_groups/editor/long-group-names.png +0 -0
- package/screenshots/truth/actions/add_contact_groups/editor/many-groups.png +0 -0
- package/screenshots/truth/actions/add_contact_groups/editor/multiple-groups.png +0 -0
- package/screenshots/truth/actions/add_contact_groups/editor/single-group.png +0 -0
- package/screenshots/truth/actions/add_contact_groups/render/descriptive-group-names.png +0 -0
- package/screenshots/truth/actions/add_contact_groups/render/long-group-names.png +0 -0
- package/screenshots/truth/actions/add_contact_groups/render/many-groups.png +0 -0
- package/screenshots/truth/actions/add_contact_groups/render/multiple-groups.png +0 -0
- package/screenshots/truth/actions/add_contact_groups/render/single-group.png +0 -0
- package/screenshots/truth/actions/add_contact_urn/editor/expression-facebook.png +0 -0
- package/screenshots/truth/actions/add_contact_urn/editor/expression-phone.png +0 -0
- package/screenshots/truth/actions/add_contact_urn/editor/facebook-id.png +0 -0
- package/screenshots/truth/actions/add_contact_urn/editor/instagram-handle.png +0 -0
- package/screenshots/truth/actions/add_contact_urn/editor/line-id.png +0 -0
- package/screenshots/truth/actions/add_contact_urn/editor/phone-number.png +0 -0
- package/screenshots/truth/actions/add_contact_urn/editor/telegram-id.png +0 -0
- package/screenshots/truth/actions/add_contact_urn/editor/viber-id.png +0 -0
- package/screenshots/truth/actions/add_contact_urn/editor/wechat-id.png +0 -0
- package/screenshots/truth/actions/add_contact_urn/editor/whatsapp.png +0 -0
- package/screenshots/truth/actions/add_contact_urn/render/expression-facebook.png +0 -0
- package/screenshots/truth/actions/add_contact_urn/render/expression-phone.png +0 -0
- package/screenshots/truth/actions/add_contact_urn/render/facebook-id.png +0 -0
- package/screenshots/truth/actions/add_contact_urn/render/instagram-handle.png +0 -0
- package/screenshots/truth/actions/add_contact_urn/render/line-id.png +0 -0
- package/screenshots/truth/actions/add_contact_urn/render/phone-number.png +0 -0
- package/screenshots/truth/actions/add_contact_urn/render/telegram-id.png +0 -0
- package/screenshots/truth/actions/add_contact_urn/render/viber-id.png +0 -0
- package/screenshots/truth/actions/add_contact_urn/render/wechat-id.png +0 -0
- package/screenshots/truth/actions/add_contact_urn/render/whatsapp.png +0 -0
- package/screenshots/truth/actions/remove_contact_groups/editor/cleanup-groups.png +0 -0
- package/screenshots/truth/actions/remove_contact_groups/editor/long-descriptive-group-names.png +0 -0
- package/screenshots/truth/actions/remove_contact_groups/editor/many-groups.png +0 -0
- package/screenshots/truth/actions/remove_contact_groups/editor/multiple-groups.png +0 -0
- package/screenshots/truth/actions/remove_contact_groups/editor/remove-from-all-groups.png +0 -0
- package/screenshots/truth/actions/remove_contact_groups/editor/single-group.png +0 -0
- package/screenshots/truth/actions/remove_contact_groups/render/cleanup-groups.png +0 -0
- package/screenshots/truth/actions/remove_contact_groups/render/long-descriptive-group-names.png +0 -0
- package/screenshots/truth/actions/remove_contact_groups/render/many-groups.png +0 -0
- package/screenshots/truth/actions/remove_contact_groups/render/multiple-groups.png +0 -0
- package/screenshots/truth/actions/remove_contact_groups/render/remove-from-all-groups.png +0 -0
- package/screenshots/truth/actions/remove_contact_groups/render/single-group.png +0 -0
- package/screenshots/truth/actions/send_broadcast/editor/contacts-only.png +0 -0
- package/screenshots/truth/actions/send_broadcast/editor/groups-and-contacts.png +0 -0
- package/screenshots/truth/actions/send_broadcast/editor/groups-only.png +0 -0
- package/screenshots/truth/actions/send_broadcast/editor/many-groups.png +0 -0
- package/screenshots/truth/actions/send_broadcast/editor/multiline-text.png +0 -0
- package/screenshots/truth/actions/send_broadcast/editor/with-attachments.png +0 -0
- package/screenshots/truth/actions/send_broadcast/render/contacts-only.png +0 -0
- package/screenshots/truth/actions/send_broadcast/render/groups-and-contacts.png +0 -0
- package/screenshots/truth/actions/send_broadcast/render/groups-only.png +0 -0
- package/screenshots/truth/actions/send_broadcast/render/many-groups.png +0 -0
- package/screenshots/truth/actions/send_broadcast/render/multiline-text.png +0 -0
- package/screenshots/truth/actions/send_broadcast/render/with-attachments.png +0 -0
- package/screenshots/truth/actions/send_email/editor/complex-business-email.png +0 -0
- package/screenshots/truth/actions/send_email/editor/empty-body.png +0 -0
- package/screenshots/truth/actions/send_email/editor/empty-subject.png +0 -0
- package/screenshots/truth/actions/send_email/editor/long-subject.png +0 -0
- package/screenshots/truth/actions/send_email/editor/multiline-body.png +0 -0
- package/screenshots/truth/actions/send_email/editor/multiple-recipients.png +0 -0
- package/screenshots/truth/actions/send_email/editor/simple-email.png +0 -0
- package/screenshots/truth/actions/send_email/editor/with-expressions.png +0 -0
- package/screenshots/truth/actions/send_email/render/complex-business-email.png +0 -0
- package/screenshots/truth/actions/send_email/render/empty-body.png +0 -0
- package/screenshots/truth/actions/send_email/render/empty-subject.png +0 -0
- package/screenshots/truth/actions/send_email/render/long-subject.png +0 -0
- package/screenshots/truth/actions/send_email/render/multiline-body.png +0 -0
- package/screenshots/truth/actions/send_email/render/multiple-recipients.png +0 -0
- package/screenshots/truth/actions/send_email/render/simple-email.png +0 -0
- package/screenshots/truth/actions/send_email/render/with-expressions.png +0 -0
- package/screenshots/truth/actions/send_msg/editor/long-quick-replies.png +0 -0
- package/screenshots/truth/actions/send_msg/editor/multiline-text-with-replies.png +0 -0
- package/screenshots/truth/actions/send_msg/editor/simple-text.png +0 -0
- package/screenshots/truth/actions/send_msg/editor/text-with-linebreaks.png +0 -0
- package/screenshots/truth/actions/send_msg/editor/text-with-many-quick-replies.png +0 -0
- package/screenshots/truth/actions/send_msg/editor/text-with-quick-replies.png +0 -0
- package/screenshots/truth/actions/send_msg/editor/text-without-quick-replies.png +0 -0
- package/screenshots/truth/actions/send_msg/render/long-quick-replies.png +0 -0
- package/screenshots/truth/actions/send_msg/render/multiline-text-with-replies.png +0 -0
- package/screenshots/truth/actions/send_msg/render/simple-text.png +0 -0
- package/screenshots/truth/actions/send_msg/render/text-with-linebreaks.png +0 -0
- package/screenshots/truth/actions/send_msg/render/text-with-many-quick-replies.png +0 -0
- package/screenshots/truth/actions/send_msg/render/text-with-quick-replies.png +0 -0
- package/screenshots/truth/actions/send_msg/render/text-without-quick-replies.png +0 -0
- package/screenshots/truth/actions/start_session/editor/contact-query.png +0 -0
- package/screenshots/truth/actions/start_session/editor/contacts-only.png +0 -0
- package/screenshots/truth/actions/start_session/editor/create-contact.png +0 -0
- package/screenshots/truth/actions/start_session/editor/groups-and-contacts.png +0 -0
- package/screenshots/truth/actions/start_session/editor/groups-only.png +0 -0
- package/screenshots/truth/actions/start_session/editor/many-recipients.png +0 -0
- package/screenshots/truth/actions/start_session/render/contact-query.png +0 -0
- package/screenshots/truth/actions/start_session/render/contacts-only.png +0 -0
- package/screenshots/truth/actions/start_session/render/create-contact.png +0 -0
- package/screenshots/truth/actions/start_session/render/groups-and-contacts.png +0 -0
- package/screenshots/truth/actions/start_session/render/groups-only.png +0 -0
- package/screenshots/truth/actions/start_session/render/many-recipients.png +0 -0
- package/screenshots/truth/canvas-menu/open.png +0 -0
- package/screenshots/truth/editor/router.png +0 -0
- package/screenshots/truth/editor/wait.png +0 -0
- package/screenshots/truth/list/fields-dragging.png +0 -0
- package/screenshots/truth/list/sortable-dragging.png +0 -0
- package/screenshots/truth/node-type-selector/action-mode.png +0 -0
- package/screenshots/truth/node-type-selector/split-mode.png +0 -0
- package/screenshots/truth/nodes/split_by_llm/editor/information-extraction.png +0 -0
- package/screenshots/truth/nodes/split_by_llm/editor/sentiment-analysis.png +0 -0
- package/screenshots/truth/nodes/split_by_llm/editor/summarization.png +0 -0
- package/screenshots/truth/nodes/split_by_llm/editor/translation-task.png +0 -0
- package/screenshots/truth/nodes/split_by_llm/render/information-extraction.png +0 -0
- package/screenshots/truth/nodes/split_by_llm/render/sentiment-analysis.png +0 -0
- package/screenshots/truth/nodes/split_by_llm/render/summarization.png +0 -0
- package/screenshots/truth/nodes/split_by_llm/render/translation-task.png +0 -0
- package/screenshots/truth/nodes/split_by_llm_categorize/editor/basic-categorization.png +0 -0
- package/screenshots/truth/nodes/split_by_llm_categorize/editor/custom-input-and-result-name.png +0 -0
- package/screenshots/truth/nodes/split_by_llm_categorize/editor/feedback-categorization.png +0 -0
- package/screenshots/truth/nodes/split_by_llm_categorize/editor/many-categories.png +0 -0
- package/screenshots/truth/nodes/split_by_llm_categorize/editor/minimal-categories.png +0 -0
- package/screenshots/truth/nodes/split_by_llm_categorize/render/basic-categorization.png +0 -0
- package/screenshots/truth/nodes/split_by_llm_categorize/render/custom-input-and-result-name.png +0 -0
- package/screenshots/truth/nodes/split_by_llm_categorize/render/feedback-categorization.png +0 -0
- package/screenshots/truth/nodes/split_by_llm_categorize/render/many-categories.png +0 -0
- package/screenshots/truth/nodes/split_by_llm_categorize/render/minimal-categories.png +0 -0
- package/screenshots/truth/nodes/split_by_random/editor/ab-test-multiple-variants.png +0 -0
- package/screenshots/truth/nodes/split_by_random/editor/sampling-split.png +0 -0
- package/screenshots/truth/nodes/split_by_random/editor/three-way-split.png +0 -0
- package/screenshots/truth/nodes/split_by_random/editor/two-bucket-split.png +0 -0
- package/screenshots/truth/nodes/split_by_random/render/ab-test-multiple-variants.png +0 -0
- package/screenshots/truth/nodes/split_by_random/render/sampling-split.png +0 -0
- package/screenshots/truth/nodes/split_by_random/render/three-way-split.png +0 -0
- package/screenshots/truth/nodes/split_by_random/render/two-bucket-split.png +0 -0
- package/screenshots/truth/nodes/wait_for_digits/editor/basic-digits-wait.png +0 -0
- package/screenshots/truth/nodes/wait_for_digits/editor/phone-number-collection.png +0 -0
- package/screenshots/truth/nodes/wait_for_digits/editor/single-digit-with-timeout.png +0 -0
- package/screenshots/truth/nodes/wait_for_digits/editor/verification-code.png +0 -0
- package/screenshots/truth/nodes/wait_for_digits/render/basic-digits-wait.png +0 -0
- package/screenshots/truth/nodes/wait_for_digits/render/phone-number-collection.png +0 -0
- package/screenshots/truth/nodes/wait_for_digits/render/single-digit-with-timeout.png +0 -0
- package/screenshots/truth/nodes/wait_for_digits/render/verification-code.png +0 -0
- package/screenshots/truth/nodes/wait_for_response/editor/basic-wait.png +0 -0
- package/screenshots/truth/nodes/wait_for_response/editor/custom-result-name.png +0 -0
- package/screenshots/truth/nodes/wait_for_response/editor/no-timeout.png +0 -0
- package/screenshots/truth/nodes/wait_for_response/editor/short-timeout.png +0 -0
- package/screenshots/truth/nodes/wait_for_response/render/basic-wait.png +0 -0
- package/screenshots/truth/nodes/wait_for_response/render/custom-result-name.png +0 -0
- package/screenshots/truth/nodes/wait_for_response/render/no-timeout.png +0 -0
- package/screenshots/truth/nodes/wait_for_response/render/short-timeout.png +0 -0
- package/src/Icons.ts +4 -1
- package/src/events.ts +2 -6
- package/src/flow/CanvasMenu.ts +217 -0
- package/src/flow/CanvasNode.ts +408 -10
- package/src/flow/Editor.ts +683 -44
- package/src/flow/NodeEditor.ts +304 -125
- package/src/flow/NodeTypeSelector.ts +592 -0
- package/src/flow/actions/add_contact_groups.ts +4 -4
- package/src/flow/actions/add_contact_urn.ts +76 -4
- package/src/flow/actions/add_input_labels.ts +4 -4
- package/src/flow/actions/play_audio.ts +2 -2
- package/src/flow/actions/remove_contact_groups.ts +14 -6
- package/src/flow/actions/request_optin.ts +2 -2
- package/src/flow/actions/say_msg.ts +2 -2
- package/src/flow/actions/send_broadcast.ts +85 -23
- package/src/flow/actions/send_email.ts +10 -6
- package/src/flow/actions/send_msg.ts +22 -32
- package/src/flow/actions/set_contact_channel.ts +5 -11
- package/src/flow/actions/set_contact_field.ts +20 -25
- package/src/flow/actions/set_contact_language.ts +9 -4
- package/src/flow/actions/set_contact_name.ts +3 -15
- package/src/flow/actions/set_contact_status.ts +3 -3
- package/src/flow/actions/set_run_result.ts +4 -4
- package/src/flow/actions/start_session.ts +208 -6
- package/src/flow/config.ts +13 -15
- package/src/flow/currencies.ts +51 -0
- package/src/flow/nodes/shared-rules.ts +301 -0
- package/src/flow/nodes/shared.ts +18 -0
- package/src/flow/nodes/split_by_airtime.ts +238 -5
- package/src/flow/nodes/split_by_contact_field.ts +185 -3
- package/src/flow/nodes/split_by_expression.ts +94 -2
- package/src/flow/nodes/split_by_groups.ts +15 -10
- package/src/flow/nodes/split_by_intent.ts +7 -0
- package/src/flow/nodes/split_by_llm.ts +4 -3
- package/src/flow/nodes/split_by_llm_categorize.ts +4 -4
- package/src/flow/nodes/split_by_random.ts +5 -5
- package/src/flow/nodes/split_by_resthook.ts +130 -0
- package/src/flow/nodes/split_by_run_result.ts +249 -3
- package/src/flow/nodes/split_by_scheme.ts +192 -2
- package/src/flow/nodes/split_by_subflow.ts +6 -4
- package/src/flow/nodes/split_by_ticket.ts +4 -3
- package/src/flow/nodes/split_by_webhook.ts +6 -5
- package/src/flow/nodes/wait_for_audio.ts +2 -2
- package/src/flow/nodes/wait_for_digits.ts +2 -2
- package/src/flow/nodes/wait_for_image.ts +2 -2
- package/src/flow/nodes/wait_for_location.ts +2 -2
- package/src/flow/nodes/wait_for_menu.ts +2 -2
- package/src/flow/nodes/wait_for_response.ts +48 -679
- package/src/flow/nodes/wait_for_video.ts +2 -2
- package/src/flow/types.ts +109 -23
- package/src/flow/utils.ts +108 -14
- package/src/form/FieldRenderer.ts +2 -4
- package/src/interfaces.ts +3 -0
- package/src/list/SortableList.ts +109 -34
- package/src/live/ContactChat.ts +15 -18
- package/src/store/AppState.ts +69 -0
- package/src/store/flow-definition.d.ts +2 -5
- package/src/utils.ts +332 -12
- package/static/api/channels.json +46 -0
- package/static/api/resthooks.json +31 -0
- package/static/svg/index.svg +1 -1
- package/static/svg/work/traced/lightning-02.svg +1 -0
- package/static/svg/work/used/lightning-02.svg +3 -0
- package/temba-modules.ts +4 -0
- package/test/ActionHelper.ts +3 -3
- package/test/NodeHelper.ts +6 -3
- package/test/actions/add_contact_urn.test.ts +287 -0
- package/test/actions/send_broadcast.test.ts +190 -0
- package/test/actions/send_email.test.ts +17 -23
- package/test/actions/send_msg.test.ts +39 -15
- package/test/actions/start_session.test.ts +151 -0
- package/test/nodes/split_by_airtime.test.ts +673 -0
- package/test/nodes/split_by_contact_field.test.ts +451 -0
- package/test/nodes/split_by_expression.test.ts +751 -0
- package/test/nodes/split_by_random.test.ts +3 -3
- package/test/nodes/split_by_resthook.test.ts +398 -0
- package/test/nodes/split_by_run_result.test.ts +1109 -0
- package/test/nodes/split_by_scheme.test.ts +486 -0
- package/test/nodes/split_by_subflow.test.ts +381 -0
- package/test/nodes/wait_for_digits.test.ts +2 -2
- package/test/nodes/wait_for_response.test.ts +2 -1
- package/test/temba-action-drag-between-nodes.test.ts +301 -0
- package/test/temba-canvas-menu.test.ts +156 -0
- package/test/temba-flow-editor-node.test.ts +102 -2
- package/test/temba-flow-editor.test.ts +7 -8
- package/test/temba-node-editor.test.ts +3 -1
- package/test/temba-node-type-selector.test.ts +152 -0
- package/test/temba-omnibox.test.ts +2 -1
- package/test/temba-sortable-list.test.ts +69 -0
- package/test/temba-utils-index.test.ts +0 -35
- package/test/utils.test.ts +2 -0
- package/test-assets/contacts/history.json +14 -20
- package/web-dev-server.config.mjs +3 -1
- package/out-tsc/src/flow/actions/call_classifier.js +0 -11
- package/out-tsc/src/flow/actions/call_classifier.js.map +0 -1
- package/out-tsc/src/flow/actions/call_resthook.js +0 -11
- package/out-tsc/src/flow/actions/call_resthook.js.map +0 -1
- package/out-tsc/src/flow/actions/split_by_expression_example.js +0 -77
- package/out-tsc/src/flow/actions/split_by_expression_example.js.map +0 -1
- package/out-tsc/src/flow/actions/transfer_airtime.js +0 -11
- package/out-tsc/src/flow/actions/transfer_airtime.js.map +0 -1
- package/src/flow/actions/call_classifier.ts +0 -12
- package/src/flow/actions/call_resthook.ts +0 -12
- package/src/flow/actions/split_by_expression_example.ts +0 -88
- package/src/flow/actions/transfer_airtime.ts +0 -12
|
@@ -1,7 +1,151 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { SPLIT_GROUPS } from '../types';
|
|
2
|
+
import { createRulesRouter } from '../../utils';
|
|
3
|
+
import { getWaitForResponseOperators, operatorsToSelectOptions, getOperatorConfig } from '../operators';
|
|
4
|
+
import { resultNameField } from './shared';
|
|
5
|
+
import { createRulesArrayConfig, extractUserRules, casesToFormRules } from './shared-rules';
|
|
6
|
+
import { SCHEMES } from '../utils';
|
|
7
|
+
import { html } from 'lit';
|
|
8
|
+
// System contact properties that can be split on
|
|
9
|
+
export const CONTACT_PROPERTIES = {
|
|
10
|
+
name: { id: 'name', name: 'Name', type: 'property' },
|
|
11
|
+
language: { id: 'language', name: 'Language', type: 'property' },
|
|
12
|
+
status: { id: 'status', name: 'Status', type: 'property' },
|
|
13
|
+
channel: { id: 'channel', name: 'Channel', type: 'property' }
|
|
14
|
+
};
|
|
15
|
+
// Helper to get operand for the selected field
|
|
16
|
+
const getOperandForField = (field) => {
|
|
17
|
+
// For URN schemes, split on the URN path (the actual ID value like Facebook ID)
|
|
18
|
+
// Note: This is different from split_by_scheme which splits on the scheme type itself
|
|
19
|
+
if (field.type === 'scheme') {
|
|
20
|
+
// field.id or field.value will be the scheme name like 'facebook', 'whatsapp', etc
|
|
21
|
+
const schemeId = field.id || field.value;
|
|
22
|
+
return `@(default(urn_parts(urns.${schemeId}).path, ""))`;
|
|
23
|
+
}
|
|
24
|
+
// For system properties, use the id
|
|
25
|
+
if (field.type === 'property') {
|
|
26
|
+
return `@contact.${field.id}`;
|
|
27
|
+
}
|
|
28
|
+
// Fallback to key
|
|
29
|
+
return `@fields.${field.key}`;
|
|
30
|
+
};
|
|
2
31
|
export const split_by_contact_field = {
|
|
3
32
|
type: 'split_by_contact_field',
|
|
4
|
-
name: 'Split by
|
|
5
|
-
|
|
33
|
+
name: 'Split by Contact Field',
|
|
34
|
+
group: SPLIT_GROUPS.split,
|
|
35
|
+
dialogSize: 'large',
|
|
36
|
+
form: {
|
|
37
|
+
field: {
|
|
38
|
+
type: 'select',
|
|
39
|
+
required: true,
|
|
40
|
+
searchable: true,
|
|
41
|
+
clearable: false,
|
|
42
|
+
endpoint: '/api/v2/fields.json',
|
|
43
|
+
valueKey: 'key',
|
|
44
|
+
nameKey: 'name',
|
|
45
|
+
placeholder: 'Select a field...',
|
|
46
|
+
// Provide system properties as fixed options at the top
|
|
47
|
+
options: [
|
|
48
|
+
...Object.values(CONTACT_PROPERTIES).map((prop) => ({
|
|
49
|
+
value: prop.id,
|
|
50
|
+
name: prop.name,
|
|
51
|
+
type: prop.type
|
|
52
|
+
})),
|
|
53
|
+
// Add all URN scheme options (they represent splitting on the URN value, like Facebook ID)
|
|
54
|
+
...SCHEMES.filter((scheme) => !scheme.excludeFromSplit).map((scheme) => ({
|
|
55
|
+
value: scheme.scheme,
|
|
56
|
+
name: scheme.path,
|
|
57
|
+
type: 'scheme'
|
|
58
|
+
}))
|
|
59
|
+
]
|
|
60
|
+
},
|
|
61
|
+
rules: createRulesArrayConfig(operatorsToSelectOptions(getWaitForResponseOperators()), 'Define rules to split the contact field into categories'),
|
|
62
|
+
result_name: resultNameField
|
|
63
|
+
},
|
|
64
|
+
layout: ['field', 'rules', 'result_name'],
|
|
65
|
+
validate: (formData) => {
|
|
66
|
+
const errors = {};
|
|
67
|
+
if (!formData.field || formData.field.length === 0) {
|
|
68
|
+
errors.field = 'A field is required';
|
|
69
|
+
}
|
|
70
|
+
return {
|
|
71
|
+
valid: Object.keys(errors).length === 0,
|
|
72
|
+
errors
|
|
73
|
+
};
|
|
74
|
+
},
|
|
75
|
+
toFormData: (node, nodeUI) => {
|
|
76
|
+
var _a, _b;
|
|
77
|
+
// Get the field from the UI config operand (source of truth)
|
|
78
|
+
const field = ((_a = nodeUI === null || nodeUI === void 0 ? void 0 : nodeUI.config) === null || _a === void 0 ? void 0 : _a.operand) || CONTACT_PROPERTIES.name;
|
|
79
|
+
// Extract rules from router cases using shared function
|
|
80
|
+
const rules = casesToFormRules(node);
|
|
81
|
+
return {
|
|
82
|
+
uuid: node.uuid,
|
|
83
|
+
field: [field],
|
|
84
|
+
rules: rules,
|
|
85
|
+
result_name: ((_b = node.router) === null || _b === void 0 ? void 0 : _b.result_name) || ''
|
|
86
|
+
};
|
|
87
|
+
},
|
|
88
|
+
fromFormData: (formData, originalNode) => {
|
|
89
|
+
var _a, _b, _c;
|
|
90
|
+
// Get selected field (it's an array from the select component)
|
|
91
|
+
const selectedField = (_a = formData.field) === null || _a === void 0 ? void 0 : _a[0];
|
|
92
|
+
if (!selectedField) {
|
|
93
|
+
return originalNode;
|
|
94
|
+
}
|
|
95
|
+
// Get operand for the selected field
|
|
96
|
+
const operand = getOperandForField(selectedField);
|
|
97
|
+
// Get user rules using shared extraction function
|
|
98
|
+
const userRules = extractUserRules(formData);
|
|
99
|
+
// Get existing router data for preservation
|
|
100
|
+
const existingCategories = ((_b = originalNode.router) === null || _b === void 0 ? void 0 : _b.categories) || [];
|
|
101
|
+
const existingExits = originalNode.exits || [];
|
|
102
|
+
const existingCases = ((_c = originalNode.router) === null || _c === void 0 ? void 0 : _c.cases) || [];
|
|
103
|
+
// Create router and exits using existing data when possible
|
|
104
|
+
const { router, exits } = createRulesRouter(operand, userRules, getOperatorConfig, existingCategories, existingExits, existingCases);
|
|
105
|
+
// Build final router with result_name
|
|
106
|
+
const finalRouter = {
|
|
107
|
+
...router
|
|
108
|
+
};
|
|
109
|
+
// Only set result_name if provided
|
|
110
|
+
if (formData.result_name && formData.result_name.trim() !== '') {
|
|
111
|
+
finalRouter.result_name = formData.result_name.trim();
|
|
112
|
+
}
|
|
113
|
+
return {
|
|
114
|
+
...originalNode,
|
|
115
|
+
router: finalRouter,
|
|
116
|
+
exits: exits
|
|
117
|
+
};
|
|
118
|
+
},
|
|
119
|
+
toUIConfig: (formData) => {
|
|
120
|
+
var _a;
|
|
121
|
+
// Get selected field (it's an array from the select component)
|
|
122
|
+
const selectedField = (_a = formData.field) === null || _a === void 0 ? void 0 : _a[0];
|
|
123
|
+
if (!selectedField) {
|
|
124
|
+
return {};
|
|
125
|
+
}
|
|
126
|
+
// For scheme types, the id should be the scheme name (facebook, whatsapp, etc)
|
|
127
|
+
// For custom fields, the id should be the field key
|
|
128
|
+
// For system properties, the id should be the property id
|
|
129
|
+
let operandId = selectedField.id || selectedField.value || selectedField.key;
|
|
130
|
+
// If this is a scheme type, ensure we use the scheme name as the id
|
|
131
|
+
if (selectedField.type === 'scheme') {
|
|
132
|
+
operandId = selectedField.value || selectedField.id;
|
|
133
|
+
}
|
|
134
|
+
let type = selectedField.type;
|
|
135
|
+
if (type !== 'property' && type !== 'scheme') {
|
|
136
|
+
type = 'field';
|
|
137
|
+
}
|
|
138
|
+
// Return UI config with operand information for persistence
|
|
139
|
+
return {
|
|
140
|
+
operand: {
|
|
141
|
+
id: operandId,
|
|
142
|
+
name: selectedField.name || selectedField.label,
|
|
143
|
+
type
|
|
144
|
+
}
|
|
145
|
+
};
|
|
146
|
+
},
|
|
147
|
+
renderTitle: (node, nodeUI) => {
|
|
148
|
+
return html `<div>Split by ${nodeUI.config.operand.name}</div>`;
|
|
149
|
+
}
|
|
6
150
|
};
|
|
7
151
|
//# sourceMappingURL=split_by_contact_field.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"split_by_contact_field.js","sourceRoot":"","sources":["../../../../src/flow/nodes/split_by_contact_field.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAc,MAAM,UAAU,CAAC;AAE9C,MAAM,CAAC,MAAM,sBAAsB,GAAe;IAChD,IAAI,EAAE,wBAAwB;IAC9B,IAAI,EAAE,+BAA+B;IACrC,KAAK,EAAE,MAAM,CAAC,KAAK;CACpB,CAAC","sourcesContent":["import { COLORS, NodeConfig } from '../types';\n\nexport const split_by_contact_field: NodeConfig = {\n type: 'split_by_contact_field',\n name: 'Split by <Contact Field Name>',\n color: COLORS.split\n};\n"]}
|
|
1
|
+
{"version":3,"file":"split_by_contact_field.js","sourceRoot":"","sources":["../../../../src/flow/nodes/split_by_contact_field.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAwB,MAAM,UAAU,CAAC;AAE9D,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAChD,OAAO,EACL,2BAA2B,EAC3B,wBAAwB,EACxB,iBAAiB,EAClB,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AAC3C,OAAO,EACL,sBAAsB,EACtB,gBAAgB,EAChB,gBAAgB,EACjB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,OAAO,EAAE,MAAM,UAAU,CAAC;AACnC,OAAO,EAAE,IAAI,EAAE,MAAM,KAAK,CAAC;AAE3B,iDAAiD;AACjD,MAAM,CAAC,MAAM,kBAAkB,GAAG;IAChC,IAAI,EAAE,EAAE,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,UAAU,EAAE;IACpD,QAAQ,EAAE,EAAE,EAAE,EAAE,UAAU,EAAE,IAAI,EAAE,UAAU,EAAE,IAAI,EAAE,UAAU,EAAE;IAChE,MAAM,EAAE,EAAE,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,UAAU,EAAE;IAC1D,OAAO,EAAE,EAAE,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,SAAS,EAAE,IAAI,EAAE,UAAU,EAAE;CAC9D,CAAC;AAEF,+CAA+C;AAC/C,MAAM,kBAAkB,GAAG,CAAC,KAAU,EAAU,EAAE;IAChD,gFAAgF;IAChF,sFAAsF;IACtF,IAAI,KAAK,CAAC,IAAI,KAAK,QAAQ,EAAE,CAAC;QAC5B,mFAAmF;QACnF,MAAM,QAAQ,GAA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,EAAE,IAAI,aAAa,CAAC,KAAK,IAAI,aAAa,CAAC,GAAG,CAAC;QAE/D,oEAAoE;QACpE,IAAI,aAAa,CAAC,IAAI,KAAK,QAAQ,EAAE,CAAC;YACpC,SAAS,GAAG,aAAa,CAAC,KAAK,IAAI,aAAa,CAAC,EAAE,CAAC;QACtD,CAAC;QAED,IAAI,IAAI,GAAG,aAAa,CAAC,IAAI,CAAC;QAC9B,IAAI,IAAI,KAAK,UAAU,IAAI,IAAI,KAAK,QAAQ,EAAE,CAAC;YAC7C,IAAI,GAAG,OAAO,CAAC;QACjB,CAAC;QAED,4DAA4D;QAC5D,OAAO;YACL,OAAO,EAAE;gBACP,EAAE,EAAE,SAAS;gBACb,IAAI,EAAE,aAAa,CAAC,IAAI,IAAI,aAAa,CAAC,KAAK;gBAC/C,IAAI;aACL;SACF,CAAC;IACJ,CAAC;IACD,WAAW,EAAE,CAAC,IAAU,EAAE,MAAY,EAAE,EAAE;QACxC,OAAO,IAAI,CAAA,iBAAiB,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,IAAI,QAAQ,CAAC;IACjE,CAAC;CACF,CAAC","sourcesContent":["import { SPLIT_GROUPS, FormData, NodeConfig } from '../types';\nimport { Node } from '../../store/flow-definition';\nimport { createRulesRouter } from '../../utils';\nimport {\n getWaitForResponseOperators,\n operatorsToSelectOptions,\n getOperatorConfig\n} from '../operators';\nimport { resultNameField } from './shared';\nimport {\n createRulesArrayConfig,\n extractUserRules,\n casesToFormRules\n} from './shared-rules';\nimport { SCHEMES } from '../utils';\nimport { html } from 'lit';\n\n// System contact properties that can be split on\nexport const CONTACT_PROPERTIES = {\n name: { id: 'name', name: 'Name', type: 'property' },\n language: { id: 'language', name: 'Language', type: 'property' },\n status: { id: 'status', name: 'Status', type: 'property' },\n channel: { id: 'channel', name: 'Channel', type: 'property' }\n};\n\n// Helper to get operand for the selected field\nconst getOperandForField = (field: any): string => {\n // For URN schemes, split on the URN path (the actual ID value like Facebook ID)\n // Note: This is different from split_by_scheme which splits on the scheme type itself\n if (field.type === 'scheme') {\n // field.id or field.value will be the scheme name like 'facebook', 'whatsapp', etc\n const schemeId = field.id || field.value;\n return `@(default(urn_parts(urns.${schemeId}).path, \"\"))`;\n }\n // For system properties, use the id\n if (field.type === 'property') {\n return `@contact.${field.id}`;\n }\n // Fallback to key\n return `@fields.${field.key}`;\n};\n\nexport const split_by_contact_field: NodeConfig = {\n type: 'split_by_contact_field',\n name: 'Split by Contact Field',\n group: SPLIT_GROUPS.split,\n dialogSize: 'large',\n form: {\n field: {\n type: 'select',\n required: true,\n searchable: true,\n clearable: false,\n endpoint: '/api/v2/fields.json',\n valueKey: 'key',\n nameKey: 'name',\n placeholder: 'Select a field...',\n // Provide system properties as fixed options at the top\n options: [\n ...Object.values(CONTACT_PROPERTIES).map((prop) => ({\n value: prop.id,\n name: prop.name,\n type: prop.type\n })),\n // Add all URN scheme options (they represent splitting on the URN value, like Facebook ID)\n ...SCHEMES.filter((scheme) => !scheme.excludeFromSplit).map(\n (scheme) => ({\n value: scheme.scheme,\n name: scheme.path,\n type: 'scheme'\n })\n )\n ]\n },\n rules: createRulesArrayConfig(\n operatorsToSelectOptions(getWaitForResponseOperators()),\n 'Define rules to split the contact field into categories'\n ),\n result_name: resultNameField\n },\n layout: ['field', 'rules', 'result_name'],\n validate: (formData: FormData) => {\n const errors: { [key: string]: string } = {};\n\n if (!formData.field || formData.field.length === 0) {\n errors.field = 'A field is required';\n }\n\n return {\n valid: Object.keys(errors).length === 0,\n errors\n };\n },\n toFormData: (node: Node, nodeUI?: any) => {\n // Get the field from the UI config operand (source of truth)\n const field = nodeUI?.config?.operand || CONTACT_PROPERTIES.name;\n\n // Extract rules from router cases using shared function\n const rules = casesToFormRules(node);\n\n return {\n uuid: node.uuid,\n field: [field],\n rules: rules,\n result_name: node.router?.result_name || ''\n };\n },\n fromFormData: (formData: FormData, originalNode: Node): Node => {\n // Get selected field (it's an array from the select component)\n const selectedField = formData.field?.[0];\n\n if (!selectedField) {\n return originalNode;\n }\n\n // Get operand for the selected field\n const operand = getOperandForField(selectedField);\n\n // Get user rules using shared extraction function\n const userRules = extractUserRules(formData);\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 } = createRulesRouter(\n operand,\n userRules,\n getOperatorConfig,\n existingCategories,\n existingExits,\n existingCases\n );\n\n // Build final router with 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 return {\n ...originalNode,\n router: finalRouter,\n exits: exits\n };\n },\n toUIConfig: (formData: FormData) => {\n // Get selected field (it's an array from the select component)\n const selectedField = formData.field?.[0];\n\n if (!selectedField) {\n return {};\n }\n\n // For scheme types, the id should be the scheme name (facebook, whatsapp, etc)\n // For custom fields, the id should be the field key\n // For system properties, the id should be the property id\n let operandId =\n selectedField.id || selectedField.value || selectedField.key;\n\n // If this is a scheme type, ensure we use the scheme name as the id\n if (selectedField.type === 'scheme') {\n operandId = selectedField.value || selectedField.id;\n }\n\n let type = selectedField.type;\n if (type !== 'property' && type !== 'scheme') {\n type = 'field';\n }\n\n // Return UI config with operand information for persistence\n return {\n operand: {\n id: operandId,\n name: selectedField.name || selectedField.label,\n type\n }\n };\n },\n renderTitle: (node: Node, nodeUI?: any) => {\n return html`<div>Split by ${nodeUI.config.operand.name}</div>`;\n }\n};\n"]}
|
|
@@ -1,7 +1,73 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { SPLIT_GROUPS } from '../types';
|
|
2
|
+
import { createRulesRouter } from '../../utils';
|
|
3
|
+
import { getWaitForResponseOperators, operatorsToSelectOptions, getOperatorConfig } from '../operators';
|
|
4
|
+
import { resultNameField } from './shared';
|
|
5
|
+
import { createRulesArrayConfig, extractUserRules, casesToFormRules } from './shared-rules';
|
|
2
6
|
export const split_by_expression = {
|
|
3
7
|
type: 'split_by_expression',
|
|
4
8
|
name: 'Split by Expression',
|
|
5
|
-
|
|
9
|
+
group: SPLIT_GROUPS.split,
|
|
10
|
+
dialogSize: 'large',
|
|
11
|
+
form: {
|
|
12
|
+
operand: {
|
|
13
|
+
type: 'text',
|
|
14
|
+
label: 'Expression',
|
|
15
|
+
helpText: 'The expression to evaluate and split on',
|
|
16
|
+
required: true,
|
|
17
|
+
evaluated: true,
|
|
18
|
+
placeholder: '@fields.age'
|
|
19
|
+
},
|
|
20
|
+
rules: createRulesArrayConfig(operatorsToSelectOptions(getWaitForResponseOperators()), 'Define rules to categorize the expression result'),
|
|
21
|
+
result_name: resultNameField
|
|
22
|
+
},
|
|
23
|
+
layout: ['operand', 'rules', 'result_name'],
|
|
24
|
+
validate: (formData) => {
|
|
25
|
+
const errors = {};
|
|
26
|
+
// Validate operand is provided
|
|
27
|
+
if (!formData.operand || formData.operand.trim() === '') {
|
|
28
|
+
errors.operand = 'Expression is required';
|
|
29
|
+
}
|
|
30
|
+
return {
|
|
31
|
+
valid: Object.keys(errors).length === 0,
|
|
32
|
+
errors
|
|
33
|
+
};
|
|
34
|
+
},
|
|
35
|
+
toFormData: (node) => {
|
|
36
|
+
var _a, _b;
|
|
37
|
+
// Extract rules from router cases using shared function
|
|
38
|
+
const rules = casesToFormRules(node);
|
|
39
|
+
return {
|
|
40
|
+
uuid: node.uuid,
|
|
41
|
+
operand: ((_a = node.router) === null || _a === void 0 ? void 0 : _a.operand) || '@input.text',
|
|
42
|
+
rules: rules,
|
|
43
|
+
result_name: ((_b = node.router) === null || _b === void 0 ? void 0 : _b.result_name) || ''
|
|
44
|
+
};
|
|
45
|
+
},
|
|
46
|
+
fromFormData: (formData, originalNode) => {
|
|
47
|
+
var _a, _b, _c;
|
|
48
|
+
// Get user rules using shared extraction function
|
|
49
|
+
const userRules = extractUserRules(formData);
|
|
50
|
+
// Get operand from form data
|
|
51
|
+
const operand = ((_a = formData.operand) === null || _a === void 0 ? void 0 : _a.trim()) || '@input.text';
|
|
52
|
+
// Get existing router data for preservation
|
|
53
|
+
const existingCategories = ((_b = originalNode.router) === null || _b === void 0 ? void 0 : _b.categories) || [];
|
|
54
|
+
const existingExits = originalNode.exits || [];
|
|
55
|
+
const existingCases = ((_c = originalNode.router) === null || _c === void 0 ? void 0 : _c.cases) || [];
|
|
56
|
+
// Create router and exits using existing data when possible
|
|
57
|
+
const { router, exits } = createRulesRouter(operand, userRules, getOperatorConfig, existingCategories, existingExits, existingCases);
|
|
58
|
+
// Build final router with result_name
|
|
59
|
+
const finalRouter = {
|
|
60
|
+
...router
|
|
61
|
+
};
|
|
62
|
+
// Only set result_name if provided
|
|
63
|
+
if (formData.result_name && formData.result_name.trim() !== '') {
|
|
64
|
+
finalRouter.result_name = formData.result_name.trim();
|
|
65
|
+
}
|
|
66
|
+
return {
|
|
67
|
+
...originalNode,
|
|
68
|
+
router: finalRouter,
|
|
69
|
+
exits: exits
|
|
70
|
+
};
|
|
71
|
+
}
|
|
6
72
|
};
|
|
7
73
|
//# sourceMappingURL=split_by_expression.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"split_by_expression.js","sourceRoot":"","sources":["../../../../src/flow/nodes/split_by_expression.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"split_by_expression.js","sourceRoot":"","sources":["../../../../src/flow/nodes/split_by_expression.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAwB,MAAM,UAAU,CAAC;AAE9D,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAChD,OAAO,EACL,2BAA2B,EAC3B,wBAAwB,EACxB,iBAAiB,EAClB,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AAC3C,OAAO,EACL,sBAAsB,EACtB,gBAAgB,EAChB,gBAAgB,EACjB,MAAM,gBAAgB,CAAC;AAExB,MAAM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C,CAAC;IACJ,CAAC;IACD,YAAY,EAAE,CAAC,QAAkB,EAAE,YAAkB,EAAQ,EAAE;;QAC7D,kDAAkD;QAClD,MAAM,SAAS,GAAG,gBAAgB,CAAC,QAAQ,CAAC,CAAC;QAE7C,6BAA6B;QAC7B,MAAM,OAAO,GAAG,CAAA,MAAA,QAAQ,CAAC,OAAO,0CAAE,IAAI,EAAE,KAAI,aAAa,CAAC;QAE1D,4CAA4C;QAC5C,MAAM,kBAAkB,GAAG,CAAA,MAAA,YAAY,CAAC,MAAM,0CAAE,UAAU,KAAI,EAAE,CAAC;QACjE,MAAM,aAAa,GAAG,YAAY,CAAC,KAAK,IAAI,EAAE,CAAC;QAC/C,MAAM,aAAa,GAAG,CAAA,MAAA,YAAY,CAAC,MAAM,0CAAE,KAAK,KAAI,EAAE,CAAC;QAEvD,4DAA4D;QAC5D,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,GAAG,iBAAiB,CACzC,OAAO,EACP,SAAS,EACT,iBAAiB,EACjB,kBAAkB,EAClB,aAAa,EACb,aAAa,CACd,CAAC;QAEF,sCAAsC;QACtC,MAAM,WAAW,GAAQ;YACvB,GAAG,MAAM;SACV,CAAC;QAEF,mCAAmC;QACnC,IAAI,QAAQ,CAAC,WAAW,IAAI,QAAQ,CAAC,WAAW,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE,CAAC;YAC/D,WAAW,CAAC,WAAW,GAAG,QAAQ,CAAC,WAAW,CAAC,IAAI,EAAE,CAAC;QACxD,CAAC;QAED,OAAO;YACL,GAAG,YAAY;YACf,MAAM,EAAE,WAAW;YACnB,KAAK,EAAE,KAAK;SACb,CAAC;IACJ,CAAC;CACF,CAAC","sourcesContent":["import { SPLIT_GROUPS, FormData, NodeConfig } from '../types';\nimport { Node } from '../../store/flow-definition';\nimport { createRulesRouter } from '../../utils';\nimport {\n getWaitForResponseOperators,\n operatorsToSelectOptions,\n getOperatorConfig\n} from '../operators';\nimport { resultNameField } from './shared';\nimport {\n createRulesArrayConfig,\n extractUserRules,\n casesToFormRules\n} from './shared-rules';\n\nexport const split_by_expression: NodeConfig = {\n type: 'split_by_expression',\n name: 'Split by Expression',\n group: SPLIT_GROUPS.split,\n dialogSize: 'large',\n form: {\n operand: {\n type: 'text',\n label: 'Expression',\n helpText: 'The expression to evaluate and split on',\n required: true,\n evaluated: true,\n placeholder: '@fields.age'\n },\n rules: createRulesArrayConfig(\n operatorsToSelectOptions(getWaitForResponseOperators()),\n 'Define rules to categorize the expression result'\n ),\n result_name: resultNameField\n },\n layout: ['operand', 'rules', 'result_name'],\n validate: (formData: FormData) => {\n const errors: { [key: string]: string } = {};\n\n // Validate operand is provided\n if (!formData.operand || formData.operand.trim() === '') {\n errors.operand = 'Expression is required';\n }\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 return {\n uuid: node.uuid,\n operand: node.router?.operand || '@input.text',\n rules: rules,\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 // Get operand from form data\n const operand = formData.operand?.trim() || '@input.text';\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 } = createRulesRouter(\n operand,\n userRules,\n getOperatorConfig,\n existingCategories,\n existingExits,\n existingCases\n );\n\n // Build final router with 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 return {\n ...originalNode,\n router: finalRouter,\n exits: exits\n };\n }\n};\n"]}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { SPLIT_GROUPS } from '../types';
|
|
2
2
|
import { generateUUID } from '../../utils';
|
|
3
|
+
import { resultNameField } from './shared';
|
|
3
4
|
// Helper function to create a switch router with group cases
|
|
4
|
-
const createGroupRouter = (userGroups, existingCategories = [], existingExits = [], existingCases = []) => {
|
|
5
|
+
const createGroupRouter = (userGroups, existingCategories = [], existingExits = [], existingCases = [], resultName = '') => {
|
|
5
6
|
const categories = [];
|
|
6
7
|
const exits = [];
|
|
7
8
|
const cases = [];
|
|
@@ -56,7 +57,7 @@ const createGroupRouter = (userGroups, existingCategories = [], existingExits =
|
|
|
56
57
|
categories: categories,
|
|
57
58
|
default_category_uuid: otherCategoryUuid,
|
|
58
59
|
operand: '@contact.groups',
|
|
59
|
-
result_name:
|
|
60
|
+
result_name: resultName
|
|
60
61
|
},
|
|
61
62
|
exits: exits
|
|
62
63
|
};
|
|
@@ -64,7 +65,7 @@ const createGroupRouter = (userGroups, existingCategories = [], existingExits =
|
|
|
64
65
|
export const split_by_groups = {
|
|
65
66
|
type: 'split_by_groups',
|
|
66
67
|
name: 'Split by Group',
|
|
67
|
-
|
|
68
|
+
group: SPLIT_GROUPS.split,
|
|
68
69
|
form: {
|
|
69
70
|
groups: {
|
|
70
71
|
type: 'select',
|
|
@@ -90,9 +91,10 @@ export const split_by_groups = {
|
|
|
90
91
|
}
|
|
91
92
|
return null;
|
|
92
93
|
}
|
|
93
|
-
}
|
|
94
|
+
},
|
|
95
|
+
result_name: resultNameField
|
|
94
96
|
},
|
|
95
|
-
layout: ['groups'],
|
|
97
|
+
layout: ['groups', 'result_name'],
|
|
96
98
|
validate: (formData) => {
|
|
97
99
|
const errors = {};
|
|
98
100
|
if (!formData.groups ||
|
|
@@ -106,7 +108,7 @@ export const split_by_groups = {
|
|
|
106
108
|
};
|
|
107
109
|
},
|
|
108
110
|
toFormData: (node) => {
|
|
109
|
-
var _a;
|
|
111
|
+
var _a, _b;
|
|
110
112
|
// Extract groups from the existing node structure
|
|
111
113
|
const groups = [];
|
|
112
114
|
if ((_a = node.router) === null || _a === void 0 ? void 0 : _a.cases) {
|
|
@@ -122,7 +124,8 @@ export const split_by_groups = {
|
|
|
122
124
|
}
|
|
123
125
|
return {
|
|
124
126
|
uuid: node.uuid,
|
|
125
|
-
groups: groups
|
|
127
|
+
groups: groups,
|
|
128
|
+
result_name: ((_b = node.router) === null || _b === void 0 ? void 0 : _b.result_name) || ''
|
|
126
129
|
};
|
|
127
130
|
},
|
|
128
131
|
fromFormData: (formData, originalNode) => {
|
|
@@ -138,7 +141,7 @@ export const split_by_groups = {
|
|
|
138
141
|
const existingCategories = ((_a = originalNode.router) === null || _a === void 0 ? void 0 : _a.categories) || [];
|
|
139
142
|
const existingExits = originalNode.exits || [];
|
|
140
143
|
const existingCases = ((_b = originalNode.router) === null || _b === void 0 ? void 0 : _b.cases) || [];
|
|
141
|
-
const { router, exits } = createGroupRouter(selectedGroups, existingCategories, existingExits, existingCases);
|
|
144
|
+
const { router, exits } = createGroupRouter(selectedGroups, existingCategories, existingExits, existingCases, formData.result_name || '');
|
|
142
145
|
// Return the complete node
|
|
143
146
|
return {
|
|
144
147
|
uuid: originalNode.uuid,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"split_by_groups.js","sourceRoot":"","sources":["../../../../src/flow/nodes/split_by_groups.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAc,MAAM,UAAU,CAAC;AAE9C,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAE3C,6DAA6D;AAC7D,MAAM,iBAAiB,GAAG,CACxB,UAA4C,EAC5C,qBAAiC,EAAE,EACnC,gBAAwB,EAAE,EAC1B,gBAAwB,EAAE,EAC1B,EAAE;IACF,MAAM,UAAU,GAAe,EAAE,CAAC;IAClC,MAAM,KAAK,GAAW,EAAE,CAAC;IACzB,MAAM,KAAK,GAAW,EAAE,CAAC;IAEzB,8DAA8D;IAC9D,UAAU,CAAC,OAAO,CAAC,CAAC,KAAK,EAAE,EAAE;QAC3B,8CAA8C;QAC9C,MAAM,gBAAgB,GAAG,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,EAAE,qCAAqC;YACzE,IAAI,EAAE,KAAK,CAAC,IAAI;SACjB,CAAC,CAAC,CAAC;QAEN,4DAA4D;QAC5D,MAAM,kBAAkB,GAAG,CAAA,MAAA,YAAY,CAAC,MAAM,0CAAE,UAAU,KAAI,EAAE,CAAC;QACjE,MAAM,aAAa,GAAG,YAAY,CAAC,KAAK,IAAI,EAAE,CAAC;QAC/C,MAAM,aAAa,GAAG,CAAA,MAAA,YAAY,CAAC,MAAM,0CAAE,KAAK,KAAI,EAAE,CAAC;QAEvD,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,GAAG,iBAAiB,CACzC,cAAc,EACd,kBAAkB,EAClB,aAAa,EACb,aAAa,CACd,CAAC;QAEF,2BAA2B;QAC3B,OAAO;YACL,IAAI,EAAE,YAAY,CAAC,IAAI;YACvB,OAAO,EAAE,YAAY,CAAC,OAAO,IAAI,EAAE;YACnC,MAAM,EAAE,MAAM;YACd,KAAK,EAAE,KAAK;SACb,CAAC;IACJ,CAAC;IACD,MAAM,EAAE;QACN,IAAI,EAAE,QAAQ;QACd,OAAO,EAAE,iBAAiB;KAC3B;CACF,CAAC","sourcesContent":["import { COLORS, NodeConfig } from '../types';\nimport { Node, Category, Exit, Case } from '../../store/flow-definition.d';\nimport { generateUUID } from '../../utils';\n\n// Helper function to create a switch router with group cases\nconst createGroupRouter = (\n userGroups: { uuid: string; name: string }[],\n existingCategories: Category[] = [],\n existingExits: Exit[] = [],\n existingCases: Case[] = []\n) => {\n const categories: Category[] = [];\n const exits: Exit[] = [];\n const cases: Case[] = [];\n\n // Create categories, exits, and cases for each selected group\n userGroups.forEach((group) => {\n // Try to find existing category by group name\n const existingCategory = existingCategories.find(\n (cat) => cat.name === group.name\n );\n const existingExit = existingCategory\n ? existingExits.find((exit) => exit.uuid === existingCategory.exit_uuid)\n : null;\n const existingCase = existingCases.find(\n (c) => c.arguments?.[0] === group.uuid\n );\n\n const exitUuid = existingExit?.uuid || generateUUID();\n const categoryUuid = existingCategory?.uuid || generateUUID();\n const caseUuid = existingCase?.uuid || generateUUID();\n\n categories.push({\n uuid: categoryUuid,\n name: group.name,\n exit_uuid: exitUuid\n });\n\n exits.push({\n uuid: exitUuid,\n destination_uuid: existingExit?.destination_uuid || null\n });\n\n cases.push({\n uuid: caseUuid,\n type: 'has_group',\n arguments: [group.uuid, group.name],\n category_uuid: categoryUuid\n });\n });\n\n // Add default \"Other\" category for contacts not in any selected group\n const existingOtherCategory = existingCategories.find(\n (cat) =>\n cat.name === 'Other' &&\n !userGroups.some((group) => group.name === cat.name)\n );\n const existingOtherExit = existingOtherCategory\n ? existingExits.find(\n (exit) => exit.uuid === existingOtherCategory.exit_uuid\n )\n : null;\n\n const otherExitUuid = existingOtherExit?.uuid || generateUUID();\n const otherCategoryUuid = existingOtherCategory?.uuid || generateUUID();\n\n categories.push({\n uuid: otherCategoryUuid,\n name: 'Other',\n exit_uuid: otherExitUuid\n });\n\n exits.push({\n uuid: otherExitUuid,\n destination_uuid: existingOtherExit?.destination_uuid || null\n });\n\n return {\n router: {\n type: 'switch' as const,\n cases: cases,\n categories: categories,\n default_category_uuid: otherCategoryUuid,\n operand: '@contact.groups',\n result_name: ''\n },\n exits: exits\n };\n};\n\nexport const split_by_groups: NodeConfig = {\n type: 'split_by_groups',\n name: 'Split by Group',\n color: COLORS.split,\n form: {\n groups: {\n type: 'select',\n label: 'Groups',\n helpText:\n 'Select the groups to split contacts by. Contacts will be routed based on their group membership.',\n required: true,\n options: [],\n multi: true,\n searchable: true,\n endpoint: '/api/v2/groups.json',\n valueKey: 'uuid',\n nameKey: 'name',\n placeholder: 'Search for groups...',\n allowCreate: true,\n createArbitraryOption: (input: string, options: any[]) => {\n // Check if a group with this name already exists\n const existing = options.find(\n (option) =>\n option.name.toLowerCase().trim() === input.toLowerCase().trim()\n );\n if (!existing && input.trim()) {\n return {\n name: input.trim(),\n arbitrary: true\n };\n }\n return null;\n }\n }\n },\n layout: ['groups'],\n validate: (formData: any) => {\n const errors: { [key: string]: string } = {};\n\n if (\n !formData.groups ||\n !Array.isArray(formData.groups) ||\n formData.groups.length === 0\n ) {\n errors.groups = 'At least one group is required';\n }\n\n return {\n valid: Object.keys(errors).length === 0,\n errors\n };\n },\n toFormData: (node: Node) => {\n // Extract groups from the existing node structure\n const groups: { uuid: string; name: string }[] = [];\n\n if (node.router?.cases) {\n node.router.cases.forEach((c: Case) => {\n if (c.type === 'has_group' && c.arguments?.length >= 2) {\n groups.push({\n uuid: c.arguments[0],\n name: c.arguments[1]\n });\n }\n });\n }\n\n return {\n uuid: node.uuid,\n groups: groups\n };\n },\n fromFormData: (formData: any, originalNode: Node): Node => {\n // Get selected groups\n const selectedGroups = (formData.groups || [])\n .filter((group: any) => group?.uuid || group?.arbitrary)\n .map((group: any) => ({\n uuid: group.uuid || generateUUID(), // Generate UUID for arbitrary groups\n name: group.name\n }));\n\n // Create router and exits using existing data when possible\n const existingCategories = originalNode.router?.categories || [];\n const existingExits = originalNode.exits || [];\n const existingCases = originalNode.router?.cases || [];\n\n const { router, exits } = createGroupRouter(\n selectedGroups,\n existingCategories,\n existingExits,\n existingCases\n );\n\n // Return the complete node\n return {\n uuid: originalNode.uuid,\n actions: originalNode.actions || [],\n router: router,\n exits: exits\n };\n },\n router: {\n type: 'switch',\n operand: '@contact.groups'\n }\n};\n"]}
|
|
1
|
+
{"version":3,"file":"split_by_groups.js","sourceRoot":"","sources":["../../../../src/flow/nodes/split_by_groups.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAwB,MAAM,UAAU,CAAC;AAE9D,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAC3C,OAAO,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AAE3C,6DAA6D;AAC7D,MAAM,iBAAiB,GAAG,CACxB,UAA4C,EAC5C,qBAAiC,EAAE,EACnC,gBAAwB,EAAE,EAC1B,gBAAwB,EAAE,EAC1B,aAAqB,EAAE,EACvB,EAAE;IACF,MAAM,UAAU,GAAe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AAG,CAAC,QAAQ,CAAC,MAAM,IAAI,EAAE,CAAC;aAC3C,MAAM,CAAC,CAAC,KAAU,EAAE,EAAE,CAAC,CAAA,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,IAAI,MAAI,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,SAAS,CAAA,CAAC;aACvD,GAAG,CAAC,CAAC,KAAU,EAAE,EAAE,CAAC,CAAC;YACpB,IAAI,EAAE,KAAK,CAAC,IAAI,IAAI,YAAY,EAAE,EAAE,qCAAqC;YACzE,IAAI,EAAE,KAAK,CAAC,IAAI;SACjB,CAAC,CAAC,CAAC;QAEN,4DAA4D;QAC5D,MAAM,kBAAkB,GAAG,CAAA,MAAA,YAAY,CAAC,MAAM,0CAAE,UAAU,KAAI,EAAE,CAAC;QACjE,MAAM,aAAa,GAAG,YAAY,CAAC,KAAK,IAAI,EAAE,CAAC;QAC/C,MAAM,aAAa,GAAG,CAAA,MAAA,YAAY,CAAC,MAAM,0CAAE,KAAK,KAAI,EAAE,CAAC;QAEvD,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,GAAG,iBAAiB,CACzC,cAAc,EACd,kBAAkB,EAClB,aAAa,EACb,aAAa,EACb,QAAQ,CAAC,WAAW,IAAI,EAAE,CAC3B,CAAC;QAEF,2BAA2B;QAC3B,OAAO;YACL,IAAI,EAAE,YAAY,CAAC,IAAI;YACvB,OAAO,EAAE,YAAY,CAAC,OAAO,IAAI,EAAE;YACnC,MAAM,EAAE,MAAM;YACd,KAAK,EAAE,KAAK;SACb,CAAC;IACJ,CAAC;IACD,MAAM,EAAE;QACN,IAAI,EAAE,QAAQ;QACd,OAAO,EAAE,iBAAiB;KAC3B;CACF,CAAC","sourcesContent":["import { SPLIT_GROUPS, FormData, NodeConfig } from '../types';\nimport { Node, Category, Exit, Case } from '../../store/flow-definition.d';\nimport { generateUUID } from '../../utils';\nimport { resultNameField } from './shared';\n\n// Helper function to create a switch router with group cases\nconst createGroupRouter = (\n userGroups: { uuid: string; name: string }[],\n existingCategories: Category[] = [],\n existingExits: Exit[] = [],\n existingCases: Case[] = [],\n resultName: string = ''\n) => {\n const categories: Category[] = [];\n const exits: Exit[] = [];\n const cases: Case[] = [];\n\n // Create categories, exits, and cases for each selected group\n userGroups.forEach((group) => {\n // Try to find existing category by group name\n const existingCategory = existingCategories.find(\n (cat) => cat.name === group.name\n );\n const existingExit = existingCategory\n ? existingExits.find((exit) => exit.uuid === existingCategory.exit_uuid)\n : null;\n const existingCase = existingCases.find(\n (c) => c.arguments?.[0] === group.uuid\n );\n\n const exitUuid = existingExit?.uuid || generateUUID();\n const categoryUuid = existingCategory?.uuid || generateUUID();\n const caseUuid = existingCase?.uuid || generateUUID();\n\n categories.push({\n uuid: categoryUuid,\n name: group.name,\n exit_uuid: exitUuid\n });\n\n exits.push({\n uuid: exitUuid,\n destination_uuid: existingExit?.destination_uuid || null\n });\n\n cases.push({\n uuid: caseUuid,\n type: 'has_group',\n arguments: [group.uuid, group.name],\n category_uuid: categoryUuid\n });\n });\n\n // Add default \"Other\" category for contacts not in any selected group\n const existingOtherCategory = existingCategories.find(\n (cat) =>\n cat.name === 'Other' &&\n !userGroups.some((group) => group.name === cat.name)\n );\n const existingOtherExit = existingOtherCategory\n ? existingExits.find(\n (exit) => exit.uuid === existingOtherCategory.exit_uuid\n )\n : null;\n\n const otherExitUuid = existingOtherExit?.uuid || generateUUID();\n const otherCategoryUuid = existingOtherCategory?.uuid || generateUUID();\n\n categories.push({\n uuid: otherCategoryUuid,\n name: 'Other',\n exit_uuid: otherExitUuid\n });\n\n exits.push({\n uuid: otherExitUuid,\n destination_uuid: existingOtherExit?.destination_uuid || null\n });\n\n return {\n router: {\n type: 'switch' as const,\n cases: cases,\n categories: categories,\n default_category_uuid: otherCategoryUuid,\n operand: '@contact.groups',\n result_name: resultName\n },\n exits: exits\n };\n};\n\nexport const split_by_groups: NodeConfig = {\n type: 'split_by_groups',\n name: 'Split by Group',\n group: SPLIT_GROUPS.split,\n form: {\n groups: {\n type: 'select',\n label: 'Groups',\n helpText:\n 'Select the groups to split contacts by. Contacts will be routed based on their group membership.',\n required: true,\n options: [],\n multi: true,\n searchable: true,\n endpoint: '/api/v2/groups.json',\n valueKey: 'uuid',\n nameKey: 'name',\n placeholder: 'Search for groups...',\n allowCreate: true,\n createArbitraryOption: (input: string, options: any[]) => {\n // Check if a group with this name already exists\n const existing = options.find(\n (option) =>\n option.name.toLowerCase().trim() === input.toLowerCase().trim()\n );\n if (!existing && input.trim()) {\n return {\n name: input.trim(),\n arbitrary: true\n };\n }\n return null;\n }\n },\n result_name: resultNameField\n },\n layout: ['groups', 'result_name'],\n validate: (formData: FormData) => {\n const errors: { [key: string]: string } = {};\n\n if (\n !formData.groups ||\n !Array.isArray(formData.groups) ||\n formData.groups.length === 0\n ) {\n errors.groups = 'At least one group is required';\n }\n\n return {\n valid: Object.keys(errors).length === 0,\n errors\n };\n },\n toFormData: (node: Node) => {\n // Extract groups from the existing node structure\n const groups: { uuid: string; name: string }[] = [];\n\n if (node.router?.cases) {\n node.router.cases.forEach((c: Case) => {\n if (c.type === 'has_group' && c.arguments?.length >= 2) {\n groups.push({\n uuid: c.arguments[0],\n name: c.arguments[1]\n });\n }\n });\n }\n\n return {\n uuid: node.uuid,\n groups: groups,\n result_name: node.router?.result_name || ''\n };\n },\n fromFormData: (formData: FormData, originalNode: Node): Node => {\n // Get selected groups\n const selectedGroups = (formData.groups || [])\n .filter((group: any) => group?.uuid || group?.arbitrary)\n .map((group: any) => ({\n uuid: group.uuid || generateUUID(), // Generate UUID for arbitrary groups\n name: group.name\n }));\n\n // Create router and exits using existing data when possible\n const existingCategories = originalNode.router?.categories || [];\n const existingExits = originalNode.exits || [];\n const existingCases = originalNode.router?.cases || [];\n\n const { router, exits } = createGroupRouter(\n selectedGroups,\n existingCategories,\n existingExits,\n existingCases,\n formData.result_name || ''\n );\n\n // Return the complete node\n return {\n uuid: originalNode.uuid,\n actions: originalNode.actions || [],\n router: router,\n exits: exits\n };\n },\n router: {\n type: 'switch',\n operand: '@contact.groups'\n }\n};\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"split_by_intent.js","sourceRoot":"","sources":["../../../../src/flow/nodes/split_by_intent.ts"],"names":[],"mappings":"AAAA,OAAO,EAAc,aAAa,EAAE,MAAM,UAAU,CAAC;AAErD,MAAM,CAAC,MAAM,uBAAuB,GAAe;IACjD,IAAI,EAAE,iBAAiB;IACvB,IAAI,EAAE,iBAAiB;IACvB,KAAK,EAAE,aAAa,CAAC,QAAQ;CAC9B,CAAC","sourcesContent":["import { NodeConfig, ACTION_GROUPS } from '../types';\n\nexport const split_by_llm_categorize: NodeConfig = {\n type: 'split_by_intent',\n name: 'Call classifier',\n group: ACTION_GROUPS.services\n};\n"]}
|
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ACTION_GROUPS } from '../types';
|
|
2
2
|
import { generateUUID, createSuccessFailureRouter } from '../../utils';
|
|
3
3
|
import { html } from 'lit';
|
|
4
4
|
export const split_by_llm = {
|
|
5
5
|
type: 'split_by_llm',
|
|
6
6
|
name: 'Call AI',
|
|
7
|
-
|
|
7
|
+
group: ACTION_GROUPS.services,
|
|
8
|
+
showAsAction: true,
|
|
8
9
|
render: (node) => {
|
|
9
10
|
var _a;
|
|
10
11
|
const callLlmAction = (_a = node.actions) === null || _a === void 0 ? void 0 : _a.find((action) => action.type === 'call_llm');
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"split_by_llm.js","sourceRoot":"","sources":["../../../../src/flow/nodes/split_by_llm.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"split_by_llm.js","sourceRoot":"","sources":["../../../../src/flow/nodes/split_by_llm.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAwB,MAAM,UAAU,CAAC;AAE/D,OAAO,EAAE,YAAY,EAAE,0BAA0B,EAAE,MAAM,aAAa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AI,EAAE,WAAW;YACjB,GAAG,EAAE,YAAY;gBACf,CAAC,CAAC,EAAE,IAAI,EAAE,YAAY,CAAC,KAAK,EAAE,IAAI,EAAE,YAAY,CAAC,IAAI,EAAE;gBACvD,CAAC,CAAC,EAAE,IAAI,EAAE,EAAE,EAAE,IAAI,EAAE,EAAE,EAAE;YAC1B,KAAK,EAAE,QAAQ,CAAC,KAAK,IAAI,QAAQ;YACjC,YAAY,EAAE,QAAQ,CAAC,YAAY,IAAI,EAAE;YACzC,YAAY,EAAE,aAAa;SAC5B,CAAC;QAEF,sDAAsD;QACtD,MAAM,kBAAkB,GAAG,CAAA,MAAA,YAAY,CAAC,MAAM,0CAAE,UAAU,KAAI,EAAE,CAAC;QACjE,MAAM,aAAa,GAAG,YAAY,CAAC,KAAK,IAAI,EAAE,CAAC;QAC/C,MAAM,aAAa,GAAG,CAAA,MAAA,YAAY,CAAC,MAAM,0CAAE,KAAK,KAAI,EAAE,CAAC;QAEvD,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,GAAG,0BAA0B,CAClD,qBAAqB,EACrB;YACE,IAAI,EAAE,UAAU;YAChB,SAAS,EAAE,EAAE;SACd,EACD,kBAAkB,EAClB,aAAa,EACb,aAAa,CACd,CAAC;QAEF,2BAA2B;QAC3B,OAAO;YACL,IAAI,EAAE,YAAY,CAAC,IAAI;YACvB,OAAO,EAAE,CAAC,aAAa,CAAC;YACxB,MAAM,EAAE,MAAM;YACd,KAAK,EAAE,KAAK;SACb,CAAC;IACJ,CAAC;CACF,CAAC","sourcesContent":["import { ACTION_GROUPS, FormData, NodeConfig } from '../types';\nimport { CallLLM, Node } from '../../store/flow-definition';\nimport { generateUUID, createSuccessFailureRouter } from '../../utils';\nimport { html } from 'lit';\n\nexport const split_by_llm: NodeConfig = {\n type: 'split_by_llm',\n name: 'Call AI',\n group: ACTION_GROUPS.services,\n showAsAction: true,\n render: (node: Node) => {\n const callLlmAction = node.actions?.find(\n (action) => action.type === 'call_llm'\n ) as CallLLM;\n return html`\n <div\n class=\"body\"\n style=\"word-wrap: break-word; overflow-wrap: break-word; hyphens: auto; max-width: 180px; max-height: 6.2em; margin-bottom:10px; overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 6; -webkit-box-orient: vertical;\"\n >\n ${callLlmAction?.instructions || 'Configure AI instructions'}\n </div>\n `;\n },\n\n form: {\n llm: {\n type: 'select',\n label: 'LLM',\n required: true,\n options: [],\n endpoint: '/test-assets/select/llms.json',\n searchable: true,\n valueKey: 'uuid',\n nameKey: 'name',\n placeholder: 'Select an LLM...'\n },\n input: {\n type: 'text',\n label: 'Input',\n helpText: 'The input the AI will process',\n required: true,\n evaluated: true,\n placeholder: '@input'\n },\n instructions: {\n type: 'textarea',\n label: 'Instructions',\n helpText:\n 'Tell the AI what to do with the input. The result can be referenced as **`@locals._llm_output`**',\n required: true,\n evaluated: true,\n placeholder: 'Enter instructions for the AI model...',\n minHeight: 130\n }\n },\n layout: ['llm', 'input', 'instructions'],\n toFormData: (node: Node) => {\n // Extract data from the existing node structure\n const callLlmAction = node.actions?.find(\n (action) => action.type === 'call_llm'\n ) as CallLLM;\n\n return {\n uuid: node.uuid,\n llm: callLlmAction?.llm\n ? [{ value: callLlmAction.llm.uuid, name: callLlmAction.llm.name }]\n : [],\n input: callLlmAction?.input || '@input',\n instructions: callLlmAction?.instructions || ''\n };\n },\n fromFormData: (formData: FormData, originalNode: Node): Node => {\n // Get LLM selection\n const llmSelection =\n Array.isArray(formData.llm) && formData.llm.length > 0\n ? formData.llm[0]\n : null;\n\n // Find existing call_llm action to preserve its UUID\n const existingCallLlmAction = originalNode.actions?.find(\n (action) => action.type === 'call_llm'\n );\n const callLlmUuid = existingCallLlmAction?.uuid || generateUUID();\n\n // Create call_llm action\n const callLlmAction: CallLLM = {\n type: 'call_llm',\n uuid: callLlmUuid,\n llm: llmSelection\n ? { uuid: llmSelection.value, name: llmSelection.name }\n : { uuid: '', name: '' },\n input: formData.input || '@input',\n instructions: formData.instructions || '',\n output_local: '_llm_output'\n };\n\n // Create categories and exits for Success and Failure\n const existingCategories = originalNode.router?.categories || [];\n const existingExits = originalNode.exits || [];\n const existingCases = originalNode.router?.cases || [];\n\n const { router, exits } = createSuccessFailureRouter(\n '@locals._llm_output',\n {\n type: 'has_text',\n arguments: []\n },\n existingCategories,\n existingExits,\n existingCases\n );\n\n // Return the complete node\n return {\n uuid: originalNode.uuid,\n actions: [callLlmAction],\n router: router,\n exits: exits\n };\n }\n};\n"]}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ACTION_GROUPS } from '../types';
|
|
2
2
|
import { generateUUID, createMultiCategoryRouter } from '../../utils';
|
|
3
3
|
import { html } from 'lit';
|
|
4
4
|
export const split_by_llm_categorize = {
|
|
5
5
|
type: 'split_by_llm_categorize',
|
|
6
6
|
name: 'Split by AI',
|
|
7
|
-
|
|
7
|
+
group: ACTION_GROUPS.services,
|
|
8
8
|
form: {
|
|
9
9
|
llm: {
|
|
10
10
|
type: 'select',
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"split_by_llm_categorize.js","sourceRoot":"","sources":["../../../../src/flow/nodes/split_by_llm_categorize.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAc,MAAM,UAAU,CAAC;AAE9C,OAAO,EAAE,YAAY,EAAE,yBAAyB,EAAE,MAAM,aAAa,CAAC;AACtE,OAAO,EAAE,IAAI,EAAE,MAAM,KAAK,CAAC;AAE3B,MAAM,CAAC,MAAM,uBAAuB,GAAe;IACjD,IAAI,EAAE,yBAAyB;IAC/B,IAAI,EAAE,aAAa;IACnB,KAAK,EAAE,MAAM,CAAC,IAAI;IAClB,IAAI,EAAE;QACJ,GAAG,EAAE;YACH,IAAI,EAAE,QAAQ;YACd,KAAK,EAAE,KAAK;YACZ,QAAQ,EAAE,0CAA0C;YACpD,QAAQ,EAAE,IAAI;YACd,QAAQ,EAAE,+BAA+B;YACzC,QAAQ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EAAE,CAAC;QAC/C,MAAM,aAAa,GAAG,CAAA,MAAA,YAAY,CAAC,MAAM,0CAAE,KAAK,KAAI,EAAE,CAAC;QAEvD,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,GAAG,yBAAyB,CACjD,qBAAqB,EACrB,cAAc,EACd,CAAC,YAAY,EAAE,EAAE,CAAC,CAAC;YACjB,IAAI,EAAE,eAAe;YACrB,SAAS,EAAE,CAAC,YAAY,CAAC;SAC1B,CAAC,EACF,kBAAkB,EAClB,aAAa,EACb,aAAa,CACd,CAAC;QAEF,2BAA2B;QAC3B,OAAO;YACL,IAAI,EAAE,YAAY,CAAC,IAAI;YACvB,OAAO,EAAE,CAAC,aAAa,CAAC;YACxB,MAAM,EAAE,MAAM;YACd,KAAK,EAAE,KAAK;SACb,CAAC;IACJ,CAAC;CACF,CAAC","sourcesContent":["import { COLORS, NodeConfig } from '../types';\nimport { CallLLM, Node } from '../../store/flow-definition';\nimport { generateUUID, createMultiCategoryRouter } from '../../utils';\nimport { html } from 'lit';\n\nexport const split_by_llm_categorize: NodeConfig = {\n type: 'split_by_llm_categorize',\n name: 'Split by AI',\n color: COLORS.call,\n form: {\n llm: {\n type: 'select',\n label: 'LLM',\n helpText: 'Select the LLM to use for categorization',\n required: true,\n endpoint: '/test-assets/select/llms.json',\n valueKey: 'uuid',\n nameKey: 'name',\n placeholder: 'Select an LLM...'\n },\n input: {\n type: 'text',\n label: 'Input',\n helpText: 'The input to categorize (usually @input)',\n required: true,\n evaluated: true,\n placeholder: '@input'\n },\n categories: {\n type: 'array',\n label: 'Categories',\n helpText: 'Define the categories for classification',\n required: true,\n sortable: true,\n itemLabel: 'Category',\n minItems: 1,\n maxItems: 10,\n isEmptyItem: (item: any) => {\n return !item.name || item.name.trim() === '';\n },\n itemConfig: {\n name: {\n type: 'text',\n placeholder: 'Category name',\n required: true\n }\n }\n }\n },\n layout: ['llm', 'input', 'categories'],\n validate: (formData: any) => {\n const errors: { [key: string]: string } = {};\n\n // Check for duplicate category names\n if (formData.categories && Array.isArray(formData.categories)) {\n const categories = formData.categories.filter(\n (item: any) => item?.name && item.name.trim() !== ''\n );\n\n // Find all categories that have duplicates (case-insensitive)\n const duplicateCategories = [];\n const lowerCaseMap = new Map();\n\n // First pass: map lowercase names to all original cases\n categories.forEach((category) => {\n const lowerName = category.name.trim().toLowerCase();\n if (!lowerCaseMap.has(lowerName)) {\n lowerCaseMap.set(lowerName, []);\n }\n lowerCaseMap.get(lowerName).push(category.name.trim());\n });\n\n // Second pass: collect all names that appear more than once\n lowerCaseMap.forEach((originalNames) => {\n if (originalNames.length > 1) {\n duplicateCategories.push(...originalNames);\n }\n });\n\n if (duplicateCategories.length > 0) {\n const uniqueDuplicates = [...new Set(duplicateCategories)];\n errors.categories = `Duplicate category names found: ${uniqueDuplicates.join(\n ', '\n )}`;\n }\n }\n\n return {\n valid: Object.keys(errors).length === 0,\n errors\n };\n },\n render: (node: Node) => {\n const callLlmAction = node.actions?.find(\n (action) => action.type === 'call_llm'\n ) as CallLLM;\n return html`\n <div class=\"body\">Categorize with ${callLlmAction.llm.name}</div>\n `;\n },\n toFormData: (node: Node) => {\n // Extract data from the existing node structure\n const callLlmAction = node.actions?.find(\n (action) => action.type === 'call_llm'\n ) as any;\n const categories =\n node.router?.categories\n ?.filter((cat) => cat.name !== 'Other' && cat.name !== 'Failure')\n .map((cat) => ({ name: cat.name })) || [];\n\n return {\n uuid: node.uuid,\n llm: callLlmAction?.llm\n ? [{ value: callLlmAction.llm.uuid, name: callLlmAction.llm.name }]\n : [],\n input: callLlmAction?.input || '@input',\n categories: categories\n };\n },\n fromFormData: (formData: any, originalNode: Node): Node => {\n // Get LLM selection\n const llmSelection =\n Array.isArray(formData.llm) && formData.llm.length > 0\n ? formData.llm[0]\n : null;\n\n // Get user categories\n const userCategories = (formData.categories || [])\n .filter((item: any) => item?.name?.trim())\n .map((item: any) => item.name.trim());\n\n // Find existing call_llm action to preserve its UUID\n const existingCallLlmAction = originalNode.actions?.find(\n (action) => action.type === 'call_llm'\n );\n const callLlmUuid = existingCallLlmAction?.uuid || generateUUID();\n\n // Create call_llm action (using any type to match the example format)\n const callLlmAction: CallLLM = {\n type: 'call_llm',\n uuid: callLlmUuid,\n llm: llmSelection\n ? { uuid: llmSelection.value, name: llmSelection.name }\n : { uuid: '', name: '' },\n instructions: `@(prompt(\"categorize\", slice(node.categories, 0, -2)))`,\n input: formData.input || '@input',\n output_local: '_llm_output'\n };\n\n // Create categories and exits\n const existingCategories = originalNode.router?.categories || [];\n const existingExits = originalNode.exits || [];\n const existingCases = originalNode.router?.cases || [];\n\n const { router, exits } = createMultiCategoryRouter(\n '@locals._llm_output',\n userCategories,\n (categoryName) => ({\n type: 'has_only_text',\n arguments: [categoryName]\n }),\n existingCategories,\n existingExits,\n existingCases\n );\n\n // Return the complete node\n return {\n uuid: originalNode.uuid,\n actions: [callLlmAction],\n router: router,\n exits: exits\n };\n }\n};\n"]}
|
|
1
|
+
{"version":3,"file":"split_by_llm_categorize.js","sourceRoot":"","sources":["../../../../src/flow/nodes/split_by_llm_categorize.ts"],"names":[],"mappings":"AAAA,OAAO,EAAwB,aAAa,EAAE,MAAM,UAAU,CAAC;AAE/D,OAAO,EAAE,YAAY,EAAE,yBAAyB,EAAE,MAAM,aAAa,CAAC;AACtE,OAAO,EAAE,IAAI,EAAE,MAAM,KAAK,CAAC;AAE3B,MAAM,CAAC,MAAM,uBAAuB,GAAe;IACjD,IAAI,EAAE,yBAAyB;IAC/B,IAAI,EAAE,aAAa;IACnB,KAAK,EAAE,aAAa,CAAC,QAAQ;IAC7B,IAAI,EAAE;QACJ,GAAG,EAAE;YACH,IAAI,EAAE,QAAQ;YACd,KAAK,EAAE,KAAK;YACZ,QAAQ,EAAE,0CAA0C;YACpD,QAAQ,EAAE,IAAI;YACd,QAAQ,EAAE,+BAA+B;YACzC,QAAQ,EAAE,MAAM;YAChB,OAAO,EAAE,MAAM;YACf,WAAW,EAAE,kBAAkB;SAChC;QACD,KAAK,E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AK,KAAI,EAAE,CAAC;QAEvD,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,GAAG,yBAAyB,CACjD,qBAAqB,EACrB,cAAc,EACd,CAAC,YAAY,EAAE,EAAE,CAAC,CAAC;YACjB,IAAI,EAAE,eAAe;YACrB,SAAS,EAAE,CAAC,YAAY,CAAC;SAC1B,CAAC,EACF,kBAAkB,EAClB,aAAa,EACb,aAAa,CACd,CAAC;QAEF,2BAA2B;QAC3B,OAAO;YACL,IAAI,EAAE,YAAY,CAAC,IAAI;YACvB,OAAO,EAAE,CAAC,aAAa,CAAC;YACxB,MAAM,EAAE,MAAM;YACd,KAAK,EAAE,KAAK;SACb,CAAC;IACJ,CAAC;CACF,CAAC","sourcesContent":["import { FormData, NodeConfig, ACTION_GROUPS } from '../types';\nimport { CallLLM, Node } from '../../store/flow-definition';\nimport { generateUUID, createMultiCategoryRouter } from '../../utils';\nimport { html } from 'lit';\n\nexport const split_by_llm_categorize: NodeConfig = {\n type: 'split_by_llm_categorize',\n name: 'Split by AI',\n group: ACTION_GROUPS.services,\n form: {\n llm: {\n type: 'select',\n label: 'LLM',\n helpText: 'Select the LLM to use for categorization',\n required: true,\n endpoint: '/test-assets/select/llms.json',\n valueKey: 'uuid',\n nameKey: 'name',\n placeholder: 'Select an LLM...'\n },\n input: {\n type: 'text',\n label: 'Input',\n helpText: 'The input to categorize (usually @input)',\n required: true,\n evaluated: true,\n placeholder: '@input'\n },\n categories: {\n type: 'array',\n label: 'Categories',\n helpText: 'Define the categories for classification',\n required: true,\n sortable: true,\n itemLabel: 'Category',\n minItems: 1,\n maxItems: 10,\n isEmptyItem: (item: any) => {\n return !item.name || item.name.trim() === '';\n },\n itemConfig: {\n name: {\n type: 'text',\n placeholder: 'Category name',\n required: true\n }\n }\n }\n },\n layout: ['llm', 'input', 'categories'],\n validate: (formData: FormData) => {\n const errors: { [key: string]: string } = {};\n\n // Check for duplicate category names\n if (formData.categories && Array.isArray(formData.categories)) {\n const categories = formData.categories.filter(\n (item: any) => item?.name && item.name.trim() !== ''\n );\n\n // Find all categories that have duplicates (case-insensitive)\n const duplicateCategories = [];\n const lowerCaseMap = new Map();\n\n // First pass: map lowercase names to all original cases\n categories.forEach((category) => {\n const lowerName = category.name.trim().toLowerCase();\n if (!lowerCaseMap.has(lowerName)) {\n lowerCaseMap.set(lowerName, []);\n }\n lowerCaseMap.get(lowerName).push(category.name.trim());\n });\n\n // Second pass: collect all names that appear more than once\n lowerCaseMap.forEach((originalNames) => {\n if (originalNames.length > 1) {\n duplicateCategories.push(...originalNames);\n }\n });\n\n if (duplicateCategories.length > 0) {\n const uniqueDuplicates = [...new Set(duplicateCategories)];\n errors.categories = `Duplicate category names found: ${uniqueDuplicates.join(\n ', '\n )}`;\n }\n }\n\n return {\n valid: Object.keys(errors).length === 0,\n errors\n };\n },\n render: (node: Node) => {\n const callLlmAction = node.actions?.find(\n (action) => action.type === 'call_llm'\n ) as CallLLM;\n return html`\n <div class=\"body\">Categorize with ${callLlmAction.llm.name}</div>\n `;\n },\n toFormData: (node: Node) => {\n // Extract data from the existing node structure\n const callLlmAction = node.actions?.find(\n (action) => action.type === 'call_llm'\n ) as any;\n const categories =\n node.router?.categories\n ?.filter((cat) => cat.name !== 'Other' && cat.name !== 'Failure')\n .map((cat) => ({ name: cat.name })) || [];\n\n return {\n uuid: node.uuid,\n llm: callLlmAction?.llm\n ? [{ value: callLlmAction.llm.uuid, name: callLlmAction.llm.name }]\n : [],\n input: callLlmAction?.input || '@input',\n categories: categories\n };\n },\n fromFormData: (formData: FormData, originalNode: Node): Node => {\n // Get LLM selection\n const llmSelection =\n Array.isArray(formData.llm) && formData.llm.length > 0\n ? formData.llm[0]\n : null;\n\n // Get user categories\n const userCategories = (formData.categories || [])\n .filter((item: any) => item?.name?.trim())\n .map((item: any) => item.name.trim());\n\n // Find existing call_llm action to preserve its UUID\n const existingCallLlmAction = originalNode.actions?.find(\n (action) => action.type === 'call_llm'\n );\n const callLlmUuid = existingCallLlmAction?.uuid || generateUUID();\n\n // Create call_llm action (using any type to match the example format)\n const callLlmAction: CallLLM = {\n type: 'call_llm',\n uuid: callLlmUuid,\n llm: llmSelection\n ? { uuid: llmSelection.value, name: llmSelection.name }\n : { uuid: '', name: '' },\n instructions: `@(prompt(\"categorize\", slice(node.categories, 0, -2)))`,\n input: formData.input || '@input',\n output_local: '_llm_output'\n };\n\n // Create categories and exits\n const existingCategories = originalNode.router?.categories || [];\n const existingExits = originalNode.exits || [];\n const existingCases = originalNode.router?.cases || [];\n\n const { router, exits } = createMultiCategoryRouter(\n '@locals._llm_output',\n userCategories,\n (categoryName) => ({\n type: 'has_only_text',\n arguments: [categoryName]\n }),\n existingCategories,\n existingExits,\n existingCases\n );\n\n // Return the complete node\n return {\n uuid: originalNode.uuid,\n actions: [callLlmAction],\n router: router,\n exits: exits\n };\n }\n};\n"]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { SPLIT_GROUPS } from '../types';
|
|
2
2
|
import { generateUUID } from '../../utils';
|
|
3
3
|
// Helper function to create a random router with categories
|
|
4
4
|
const createRandomRouter = (userCategories, existingCategories = [], existingExits = []) => {
|
|
@@ -33,8 +33,8 @@ const createRandomRouter = (userCategories, existingCategories = [], existingExi
|
|
|
33
33
|
};
|
|
34
34
|
export const split_by_random = {
|
|
35
35
|
type: 'split_by_random',
|
|
36
|
-
name: 'Split
|
|
37
|
-
|
|
36
|
+
name: 'Random Split',
|
|
37
|
+
group: SPLIT_GROUPS.split,
|
|
38
38
|
form: {
|
|
39
39
|
categories: {
|
|
40
40
|
type: 'array',
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"split_by_random.js","sourceRoot":"","sources":["../../../../src/flow/nodes/split_by_random.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"split_by_random.js","sourceRoot":"","sources":["../../../../src/flow/nodes/split_by_random.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAA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types';\nimport { Node, Category, Exit } from '../../store/flow-definition.d';\nimport { generateUUID } from '../../utils';\n\n// Helper function to create a random router with categories\nconst createRandomRouter = (\n userCategories: string[],\n existingCategories: Category[] = [],\n existingExits: Exit[] = []\n) => {\n const categories: Category[] = [];\n const exits: Exit[] = [];\n\n // Create categories and exits for user-defined buckets\n userCategories.forEach((categoryName) => {\n // Try to find existing category by name\n const existingCategory = existingCategories.find(\n (cat) => cat.name === categoryName\n );\n const existingExit = existingCategory\n ? existingExits.find((exit) => exit.uuid === existingCategory.exit_uuid)\n : null;\n\n const exitUuid = existingExit?.uuid || generateUUID();\n const categoryUuid = existingCategory?.uuid || generateUUID();\n\n categories.push({\n uuid: categoryUuid,\n name: categoryName,\n exit_uuid: exitUuid\n });\n\n exits.push({\n uuid: exitUuid,\n destination_uuid: existingExit?.destination_uuid || null\n });\n });\n\n return {\n router: {\n type: 'random' as const,\n categories: categories\n },\n exits: exits\n };\n};\n\nexport const split_by_random: NodeConfig = {\n type: 'split_by_random',\n name: 'Random Split',\n group: SPLIT_GROUPS.split,\n form: {\n categories: {\n type: 'array',\n label: 'Buckets',\n helpText: 'Define the buckets to randomly split contacts into',\n required: true,\n itemLabel: 'Bucket',\n sortable: true,\n minItems: 2,\n maxItems: 10,\n isEmptyItem: (item: any) => {\n return !item.name || item.name.trim() === '';\n },\n itemConfig: {\n name: {\n type: 'text',\n placeholder: 'Bucket name',\n required: true\n }\n }\n }\n },\n layout: ['categories'],\n validate: (formData: FormData) => {\n const errors: { [key: string]: string } = {};\n\n // Check for duplicate category names\n if (formData.categories && Array.isArray(formData.categories)) {\n const categories = formData.categories.filter(\n (item: any) => item?.name && item.name.trim() !== ''\n );\n\n // Ensure minimum buckets\n if (categories.length < 2) {\n errors.categories = 'At least 2 buckets are required for random split';\n }\n\n // Find all categories that have duplicates (case-insensitive)\n const duplicateCategories = [];\n const lowerCaseMap = new Map();\n\n // First pass: map lowercase names to all original cases\n categories.forEach((category) => {\n const lowerName = category.name.trim().toLowerCase();\n if (!lowerCaseMap.has(lowerName)) {\n lowerCaseMap.set(lowerName, []);\n }\n lowerCaseMap.get(lowerName).push(category.name.trim());\n });\n\n // Second pass: collect all names that appear more than once\n lowerCaseMap.forEach((originalNames) => {\n if (originalNames.length > 1) {\n duplicateCategories.push(...originalNames);\n }\n });\n\n if (duplicateCategories.length > 0) {\n const uniqueDuplicates = [...new Set(duplicateCategories)];\n errors.categories = `Duplicate bucket names found: ${uniqueDuplicates.join(\n ', '\n )}`;\n }\n }\n\n return {\n valid: Object.keys(errors).length === 0,\n errors\n };\n },\n toFormData: (node: Node) => {\n // Extract categories from the existing node structure\n const categories =\n node.router?.categories?.map((cat) => ({ name: cat.name })) || [];\n\n return {\n uuid: node.uuid,\n categories: categories\n };\n },\n fromFormData: (formData: FormData, originalNode: Node): Node => {\n // Get user categories\n const userCategories = (formData.categories || [])\n .filter((item: any) => item?.name?.trim())\n .map((item: any) => item.name.trim());\n\n // Create router and exits using existing data when possible\n const existingCategories = originalNode.router?.categories || [];\n const existingExits = originalNode.exits || [];\n\n const { router, exits } = createRandomRouter(\n userCategories,\n existingCategories,\n existingExits\n );\n\n // Return the complete node\n return {\n uuid: originalNode.uuid,\n actions: originalNode.actions || [],\n router: router,\n exits: exits\n };\n },\n router: {\n type: 'random'\n }\n};\n"]}
|