rasa-pro 3.13.0.dev3__py3-none-any.whl → 3.13.0.dev7__py3-none-any.whl
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.
Potentially problematic release.
This version of rasa-pro might be problematic. Click here for more details.
- rasa/__main__.py +3 -1
- rasa/api.py +4 -0
- rasa/cli/arguments/default_arguments.py +13 -1
- rasa/cli/arguments/train.py +2 -0
- rasa/cli/evaluate.py +1 -1
- rasa/cli/export.py +2 -2
- rasa/cli/inspect.py +8 -4
- rasa/cli/project_templates/default/config.yml +5 -32
- rasa/cli/project_templates/{calm → default}/e2e_tests/cancelations/user_cancels_during_a_correction.yml +1 -1
- rasa/cli/project_templates/{calm → default}/e2e_tests/cancelations/user_changes_mind_on_a_whim.yml +1 -1
- rasa/cli/project_templates/{calm → default}/e2e_tests/corrections/user_corrects_contact_handle.yml +1 -1
- rasa/cli/project_templates/{calm → default}/e2e_tests/corrections/user_corrects_contact_name.yml +1 -1
- rasa/cli/project_templates/{calm → default}/e2e_tests/happy_paths/user_adds_contact_to_their_list.yml +1 -1
- rasa/cli/project_templates/{calm → default}/e2e_tests/happy_paths/user_lists_contacts.yml +1 -1
- rasa/cli/project_templates/{calm → default}/e2e_tests/happy_paths/user_removes_contact.yml +1 -1
- rasa/cli/project_templates/{calm → default}/e2e_tests/happy_paths/user_removes_contact_from_list.yml +1 -1
- rasa/cli/project_templates/default/endpoints.yml +18 -2
- rasa/cli/scaffold.py +3 -4
- rasa/cli/studio/download.py +1 -1
- rasa/cli/studio/upload.py +0 -6
- rasa/cli/train.py +1 -0
- rasa/constants.py +2 -0
- rasa/core/agent.py +2 -2
- rasa/core/brokers/kafka.py +4 -0
- rasa/core/brokers/pika.py +4 -0
- rasa/core/brokers/sql.py +1 -1
- rasa/core/channels/channel.py +68 -5
- rasa/core/channels/inspector/.eslintrc.cjs +12 -6
- rasa/core/channels/inspector/.prettierrc +5 -0
- rasa/core/channels/inspector/README.md +10 -4
- rasa/core/channels/inspector/dist/assets/{arc-c7691751.js → arc-c4b064fc.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{blockDiagram-38ab4fdb-ab99dff7.js → blockDiagram-38ab4fdb-215b5026.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{c4Diagram-3d4e48cf-08c35a6b.js → c4Diagram-3d4e48cf-2b54a0a3.js} +1 -1
- rasa/core/channels/inspector/dist/assets/channel-3730f5fd.js +1 -0
- rasa/core/channels/inspector/dist/assets/{classDiagram-70f12bd4-9e9c71c9.js → classDiagram-70f12bd4-daacea5f.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{classDiagram-v2-f2320105-15e7e2bf.js → classDiagram-v2-f2320105-930d4dc2.js} +1 -1
- rasa/core/channels/inspector/dist/assets/clone-e847561e.js +1 -0
- rasa/core/channels/inspector/dist/assets/{createText-2e5e7dd3-9c105cb1.js → createText-2e5e7dd3-83c206ba.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{edges-e0da2a9e-77e89e48.js → edges-e0da2a9e-b0eb01d0.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{erDiagram-9861fffd-7a011646.js → erDiagram-9861fffd-17586500.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{flowDb-956e92f1-b6f105ac.js → flowDb-956e92f1-be2a1776.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{flowDiagram-66a62f08-ce4f18c2.js → flowDiagram-66a62f08-c2120ebd.js} +1 -1
- rasa/core/channels/inspector/dist/assets/flowDiagram-v2-96b9c2cf-efbbfe00.js +1 -0
- rasa/core/channels/inspector/dist/assets/{flowchart-elk-definition-4a651766-cb5f6da4.js → flowchart-elk-definition-4a651766-a6ab5c48.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{ganttDiagram-c361ad54-e4d19e28.js → ganttDiagram-c361ad54-ef613457.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{gitGraphDiagram-72cf32ee-727b1c33.js → gitGraphDiagram-72cf32ee-d59185b3.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{graph-6e2ab9a7.js → graph-0f155405.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{index-3862675e-84ec700f.js → index-3862675e-d5f1d1b7.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{index-098a1a24.js → index-47737d3a.js} +162 -149
- rasa/core/channels/inspector/dist/assets/{infoDiagram-f8f76790-78dda442.js → infoDiagram-f8f76790-b07d141f.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{journeyDiagram-49397b02-f1cc6dd1.js → journeyDiagram-49397b02-1936d429.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{layout-d98dcd0c.js → layout-dde8d0f3.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{line-838e3d82.js → line-0c2c7ee0.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{linear-eae72406.js → linear-35dd89a4.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{mindmap-definition-fc14e90a-c96fd84b.js → mindmap-definition-fc14e90a-56192851.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{pieDiagram-8a3498a8-c936d4e2.js → pieDiagram-8a3498a8-fc21ed78.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{quadrantDiagram-120e2f19-b338eb8f.js → quadrantDiagram-120e2f19-25e98518.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{requirementDiagram-deff3bca-c6b6c0d5.js → requirementDiagram-deff3bca-546ff1f5.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{sankeyDiagram-04a897e0-b9372e19.js → sankeyDiagram-04a897e0-02d8b82d.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{sequenceDiagram-704730f1-479e0a3f.js → sequenceDiagram-704730f1-3ca5a92e.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{stateDiagram-587899a1-fd26eebc.js → stateDiagram-587899a1-128ea07c.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{stateDiagram-v2-d93cdb3a-3233e0ae.js → stateDiagram-v2-d93cdb3a-95f290af.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{styles-6aaf32cf-1fdd392b.js → styles-6aaf32cf-4984898a.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{styles-9a916d00-6d7bfa1b.js → styles-9a916d00-1bf266ba.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{styles-c10674c1-f86aab11.js → styles-c10674c1-60521c63.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{svgDrawCommon-08f97a94-e3e49d7a.js → svgDrawCommon-08f97a94-a25b6e12.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{timeline-definition-85554ec2-6fe08b4d.js → timeline-definition-85554ec2-0fc086bf.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{xychartDiagram-e933f94c-c2e06fd6.js → xychartDiagram-e933f94c-44ee592e.js} +1 -1
- rasa/core/channels/inspector/dist/index.html +1 -1
- rasa/core/channels/inspector/package.json +3 -1
- rasa/core/channels/inspector/src/App.tsx +92 -90
- rasa/core/channels/inspector/src/components/Chat.tsx +61 -36
- rasa/core/channels/inspector/src/components/DiagramFlow.tsx +40 -43
- rasa/core/channels/inspector/src/components/DialogueInformation.tsx +57 -57
- rasa/core/channels/inspector/src/components/DialogueStack.tsx +36 -27
- rasa/core/channels/inspector/src/components/ExpandIcon.tsx +4 -4
- rasa/core/channels/inspector/src/components/FullscreenButton.tsx +7 -7
- rasa/core/channels/inspector/src/components/LoadingSpinner.tsx +28 -12
- rasa/core/channels/inspector/src/components/NoActiveFlow.tsx +9 -9
- rasa/core/channels/inspector/src/components/RasaLogo.tsx +5 -5
- rasa/core/channels/inspector/src/components/RecruitmentPanel.tsx +55 -60
- rasa/core/channels/inspector/src/components/SaraDiagrams.tsx +5 -5
- rasa/core/channels/inspector/src/components/Slots.tsx +22 -22
- rasa/core/channels/inspector/src/components/Welcome.tsx +28 -31
- rasa/core/channels/inspector/src/helpers/audio/audiostream.ts +245 -0
- rasa/core/channels/inspector/src/helpers/audio/microphone-processor.js +12 -0
- rasa/core/channels/inspector/src/helpers/audio/playback-processor.js +36 -0
- rasa/core/channels/inspector/src/helpers/conversation.ts +16 -0
- rasa/core/channels/inspector/src/helpers/formatters.test.ts +181 -181
- rasa/core/channels/inspector/src/helpers/formatters.ts +111 -111
- rasa/core/channels/inspector/src/helpers/utils.ts +78 -61
- rasa/core/channels/inspector/src/main.tsx +8 -8
- rasa/core/channels/inspector/src/theme/Button/Button.ts +8 -8
- rasa/core/channels/inspector/src/theme/Heading/Heading.ts +7 -7
- rasa/core/channels/inspector/src/theme/Input/Input.ts +9 -9
- rasa/core/channels/inspector/src/theme/Link/Link.ts +6 -6
- rasa/core/channels/inspector/src/theme/Modal/Modal.ts +13 -13
- rasa/core/channels/inspector/src/theme/Table/Table.tsx +10 -10
- rasa/core/channels/inspector/src/theme/Tooltip/Tooltip.ts +5 -5
- rasa/core/channels/inspector/src/theme/base/breakpoints.ts +7 -7
- rasa/core/channels/inspector/src/theme/base/colors.ts +64 -64
- rasa/core/channels/inspector/src/theme/base/fonts/fontFaces.css +21 -18
- rasa/core/channels/inspector/src/theme/base/radii.ts +8 -8
- rasa/core/channels/inspector/src/theme/base/shadows.ts +5 -5
- rasa/core/channels/inspector/src/theme/base/sizes.ts +5 -5
- rasa/core/channels/inspector/src/theme/base/space.ts +12 -12
- rasa/core/channels/inspector/src/theme/base/styles.ts +5 -5
- rasa/core/channels/inspector/src/theme/base/typography.ts +12 -12
- rasa/core/channels/inspector/src/theme/base/zIndices.ts +3 -3
- rasa/core/channels/inspector/src/theme/index.ts +38 -38
- rasa/core/channels/inspector/src/types.ts +56 -50
- rasa/core/channels/inspector/yarn.lock +5 -0
- rasa/core/channels/voice_ready/audiocodes.py +75 -32
- rasa/core/channels/voice_ready/twilio_voice.py +48 -1
- rasa/core/channels/voice_stream/tts/azure.py +11 -2
- rasa/core/channels/voice_stream/twilio_media_streams.py +101 -26
- rasa/core/channels/voice_stream/voice_channel.py +28 -2
- rasa/core/concurrent_lock_store.py +24 -10
- rasa/core/evaluation/marker_tracker_loader.py +1 -1
- rasa/core/exporter.py +1 -1
- rasa/core/lock_store.py +151 -60
- rasa/core/nlg/contextual_response_rephraser.py +4 -2
- rasa/core/nlg/summarize.py +1 -1
- rasa/core/persistor.py +55 -20
- rasa/core/policies/enterprise_search_policy.py +7 -4
- rasa/core/policies/intentless_policy.py +15 -9
- rasa/core/processor.py +2 -2
- rasa/core/run.py +7 -2
- rasa/core/{auth_retry_tracker_store.py → tracker_stores/auth_retry_tracker_store.py} +5 -1
- rasa/core/tracker_stores/dynamo_tracker_store.py +218 -0
- rasa/core/tracker_stores/mongo_tracker_store.py +206 -0
- rasa/core/tracker_stores/redis_tracker_store.py +219 -0
- rasa/core/tracker_stores/sql_tracker_store.py +555 -0
- rasa/core/tracker_stores/tracker_store.py +805 -0
- rasa/core/utils.py +6 -0
- rasa/dialogue_understanding/coexistence/llm_based_router.py +8 -3
- rasa/dialogue_understanding/commands/clarify_command.py +2 -2
- rasa/dialogue_understanding/commands/knowledge_answer_command.py +2 -2
- rasa/dialogue_understanding/generator/constants.py +2 -2
- rasa/dialogue_understanding/generator/llm_based_command_generator.py +1 -1
- rasa/dialogue_understanding/generator/prompt_templates/command_prompt_v2_gpt_4o_2024_11_20_template.jinja2 +33 -12
- rasa/dialogue_understanding/generator/single_step/compact_llm_command_generator.py +2 -2
- rasa/dialogue_understanding_test/du_test_case.py +16 -8
- rasa/hooks.py +2 -2
- rasa/keys +1 -0
- rasa/llm_fine_tuning/paraphrasing/conversation_rephraser.py +4 -2
- rasa/model_manager/config.py +3 -1
- rasa/model_manager/model_api.py +1 -2
- rasa/model_manager/runner_service.py +8 -4
- rasa/model_manager/trainer_service.py +1 -0
- rasa/model_training.py +12 -3
- rasa/nlu/extractors/crf_entity_extractor.py +66 -16
- rasa/plugin.py +1 -4
- rasa/server.py +6 -2
- rasa/shared/constants.py +4 -0
- rasa/shared/core/domain.py +165 -11
- rasa/shared/core/events.py +68 -2
- rasa/shared/core/flows/flow.py +155 -131
- rasa/shared/core/flows/flow_step.py +19 -3
- rasa/shared/core/flows/flow_step_links.py +15 -0
- rasa/shared/core/flows/flow_step_sequence.py +6 -0
- rasa/shared/core/flows/nlu_trigger.py +13 -0
- rasa/shared/core/flows/steps/action.py +7 -4
- rasa/shared/core/flows/steps/call.py +11 -4
- rasa/shared/core/flows/steps/collect.py +27 -6
- rasa/shared/core/flows/steps/internal.py +6 -1
- rasa/shared/core/flows/steps/link.py +7 -4
- rasa/shared/core/flows/steps/no_operation.py +7 -4
- rasa/shared/core/flows/steps/set_slots.py +8 -4
- rasa/shared/core/flows/yaml_flows_io.py +106 -5
- rasa/shared/importers/importer.py +8 -0
- rasa/shared/providers/_configs/azure_openai_client_config.py +4 -0
- rasa/shared/providers/_configs/openai_client_config.py +4 -0
- rasa/shared/providers/_utils.py +83 -0
- rasa/shared/providers/embedding/_base_litellm_embedding_client.py +3 -0
- rasa/shared/providers/llm/_base_litellm_client.py +11 -5
- rasa/shared/providers/llm/azure_openai_llm_client.py +6 -68
- rasa/shared/providers/router/_base_litellm_router_client.py +53 -1
- rasa/shared/utils/common.py +42 -0
- rasa/studio/download/__init__.py +0 -0
- rasa/studio/download/domains.py +49 -0
- rasa/studio/download/download.py +439 -0
- rasa/studio/download/flows.py +359 -0
- rasa/studio/results_logger.py +6 -1
- rasa/studio/upload.py +69 -5
- rasa/telemetry.py +2 -2
- rasa/tracing/config.py +1 -1
- rasa/tracing/instrumentation/attribute_extractors.py +1 -1
- rasa/tracing/instrumentation/instrumentation.py +1 -1
- rasa/utils/common.py +36 -0
- rasa/utils/endpoints.py +22 -1
- rasa/utils/licensing.py +2 -3
- rasa/validator.py +1 -2
- rasa/version.py +1 -1
- {rasa_pro-3.13.0.dev3.dist-info → rasa_pro-3.13.0.dev7.dist-info}/METADATA +10 -10
- {rasa_pro-3.13.0.dev3.dist-info → rasa_pro-3.13.0.dev7.dist-info}/RECORD +213 -210
- rasa/cli/project_templates/calm/config.yml +0 -10
- rasa/cli/project_templates/calm/credentials.yml +0 -33
- rasa/cli/project_templates/calm/endpoints.yml +0 -58
- rasa/cli/project_templates/default/actions/actions.py +0 -27
- rasa/cli/project_templates/default/data/nlu.yml +0 -91
- rasa/cli/project_templates/default/data/rules.yml +0 -13
- rasa/cli/project_templates/default/data/stories.yml +0 -30
- rasa/cli/project_templates/default/domain.yml +0 -34
- rasa/cli/project_templates/default/tests/test_stories.yml +0 -91
- rasa/core/channels/inspector/dist/assets/channel-11268142.js +0 -1
- rasa/core/channels/inspector/dist/assets/clone-ff7f2ce7.js +0 -1
- rasa/core/channels/inspector/dist/assets/flowDiagram-v2-96b9c2cf-cba7ae20.js +0 -1
- rasa/core/channels/inspector/src/helpers/audiostream.ts +0 -191
- rasa/core/tracker_store.py +0 -1792
- rasa/studio/download.py +0 -489
- /rasa/cli/project_templates/{calm → default}/actions/action_template.py +0 -0
- /rasa/cli/project_templates/{calm → default}/actions/add_contact.py +0 -0
- /rasa/cli/project_templates/{calm → default}/actions/db.py +0 -0
- /rasa/cli/project_templates/{calm → default}/actions/list_contacts.py +0 -0
- /rasa/cli/project_templates/{calm → default}/actions/remove_contact.py +0 -0
- /rasa/cli/project_templates/{calm → default}/data/flows/add_contact.yml +0 -0
- /rasa/cli/project_templates/{calm → default}/data/flows/list_contacts.yml +0 -0
- /rasa/cli/project_templates/{calm → default}/data/flows/remove_contact.yml +0 -0
- /rasa/cli/project_templates/{calm → default}/db/contacts.json +0 -0
- /rasa/cli/project_templates/{calm → default}/domain/add_contact.yml +0 -0
- /rasa/cli/project_templates/{calm → default}/domain/list_contacts.yml +0 -0
- /rasa/cli/project_templates/{calm → default}/domain/remove_contact.yml +0 -0
- /rasa/cli/project_templates/{calm → default}/domain/shared.yml +0 -0
- /rasa/{cli/project_templates/calm/actions → core/tracker_stores}/__init__.py +0 -0
- {rasa_pro-3.13.0.dev3.dist-info → rasa_pro-3.13.0.dev7.dist-info}/NOTICE +0 -0
- {rasa_pro-3.13.0.dev3.dist-info → rasa_pro-3.13.0.dev7.dist-info}/WHEEL +0 -0
- {rasa_pro-3.13.0.dev3.dist-info → rasa_pro-3.13.0.dev7.dist-info}/entry_points.txt +0 -0
|
@@ -1,84 +1,84 @@
|
|
|
1
|
-
import { rasaColors } from
|
|
2
|
-
import type { Event, Flow, Slot, Stack } from
|
|
1
|
+
import { rasaColors } from '../theme/base/colors'
|
|
2
|
+
import type { Event, Flow, Slot, Stack } from '../types'
|
|
3
3
|
|
|
4
4
|
export function formatSlots(slots: { [key: string]: unknown }) {
|
|
5
5
|
if (!slots) {
|
|
6
|
-
return []
|
|
6
|
+
return []
|
|
7
7
|
}
|
|
8
8
|
|
|
9
9
|
return Object.entries(slots)
|
|
10
10
|
.filter(
|
|
11
11
|
(slotDuple) =>
|
|
12
|
-
slotDuple[0] !==
|
|
13
|
-
slotDuple[0] !==
|
|
14
|
-
slotDuple[1] != null
|
|
12
|
+
slotDuple[0] !== 'dialogue_stack' &&
|
|
13
|
+
slotDuple[0] !== 'flow_hashes' &&
|
|
14
|
+
slotDuple[1] != null,
|
|
15
15
|
)
|
|
16
|
-
.map((slotDuple) => ({ name: slotDuple[0], value: slotDuple[1] }))
|
|
16
|
+
.map((slotDuple) => ({ name: slotDuple[0], value: slotDuple[1] }))
|
|
17
17
|
}
|
|
18
18
|
|
|
19
19
|
export const formatTestCases = (events: Event[], sessionId: string) => {
|
|
20
20
|
let testCases = `test_cases:
|
|
21
21
|
- test_case: ${sessionId}
|
|
22
|
-
steps
|
|
22
|
+
steps:`
|
|
23
23
|
|
|
24
24
|
const steps = events
|
|
25
25
|
.map((event) => {
|
|
26
|
-
const escapedText = JSON.stringify(event.text)
|
|
27
|
-
if (event.event ===
|
|
28
|
-
return ` - user: ${escapedText}
|
|
29
|
-
} else if (event.event ===
|
|
26
|
+
const escapedText = JSON.stringify(event.text)
|
|
27
|
+
if (event.event === 'user') {
|
|
28
|
+
return ` - user: ${escapedText}`
|
|
29
|
+
} else if (event.event === 'bot') {
|
|
30
30
|
return `${
|
|
31
31
|
event.metadata?.utter_action
|
|
32
32
|
? ` - utter: ${event.metadata.utter_action}`
|
|
33
33
|
: ` - bot: ${escapedText}`
|
|
34
|
-
}
|
|
34
|
+
}`
|
|
35
35
|
}
|
|
36
36
|
})
|
|
37
|
-
.filter(Boolean)
|
|
37
|
+
.filter(Boolean)
|
|
38
38
|
|
|
39
39
|
if (steps.length === 0) {
|
|
40
|
-
testCases = `${testCases} []
|
|
40
|
+
testCases = `${testCases} []`
|
|
41
41
|
} else {
|
|
42
42
|
testCases = `${testCases}
|
|
43
|
-
${steps.join(
|
|
43
|
+
${steps.join('\n')}`
|
|
44
44
|
}
|
|
45
45
|
|
|
46
|
-
return testCases
|
|
47
|
-
}
|
|
46
|
+
return testCases
|
|
47
|
+
}
|
|
48
48
|
|
|
49
49
|
function hashCode(str: string) {
|
|
50
50
|
var hash = 0,
|
|
51
51
|
i,
|
|
52
|
-
chr
|
|
53
|
-
if (str.length === 0) return hash
|
|
52
|
+
chr
|
|
53
|
+
if (str.length === 0) return hash
|
|
54
54
|
for (i = 0; i < str.length; i++) {
|
|
55
|
-
chr = str.charCodeAt(i)
|
|
56
|
-
hash = (hash << 5) - hash + chr
|
|
57
|
-
hash |= 0
|
|
55
|
+
chr = str.charCodeAt(i)
|
|
56
|
+
hash = (hash << 5) - hash + chr
|
|
57
|
+
hash |= 0 // Convert to 32bit integer
|
|
58
58
|
}
|
|
59
|
-
return hash
|
|
59
|
+
return hash
|
|
60
60
|
}
|
|
61
61
|
|
|
62
62
|
function mermaidIdForTitle(title: string) {
|
|
63
|
-
return `id${hashCode(title)}
|
|
63
|
+
return `id${hashCode(title)}`
|
|
64
64
|
}
|
|
65
65
|
|
|
66
66
|
const encodeDoubleQuotes = (str: string) =>
|
|
67
67
|
/**
|
|
68
68
|
* Transforms all " characters of a string into html codes.
|
|
69
69
|
*/
|
|
70
|
-
str.replace(/"/g, `#34;`)
|
|
70
|
+
str.replace(/"/g, `#34;`)
|
|
71
71
|
|
|
72
72
|
export const formatFlow = (
|
|
73
73
|
slots: Slot[],
|
|
74
74
|
currentStack?: Stack,
|
|
75
75
|
flow?: Flow,
|
|
76
|
-
stepTrail?: string[]
|
|
76
|
+
stepTrail?: string[],
|
|
77
77
|
) => {
|
|
78
|
-
const activeStep = currentStack?.step_id
|
|
78
|
+
const activeStep = currentStack?.step_id
|
|
79
79
|
|
|
80
80
|
if (!flow) {
|
|
81
|
-
return
|
|
81
|
+
return ''
|
|
82
82
|
}
|
|
83
83
|
|
|
84
84
|
const mermaidText = [
|
|
@@ -91,189 +91,189 @@ classDef endstep fill:#ccc,stroke:#444
|
|
|
91
91
|
classDef previous stroke:${rasaColors.rasaOrange[400]},stroke-width:1px
|
|
92
92
|
classDef active stroke:${rasaColors.rasaOrange[400]},stroke-width:3px,fill:${rasaColors.warning[50]}
|
|
93
93
|
`,
|
|
94
|
-
]
|
|
94
|
+
]
|
|
95
95
|
try {
|
|
96
96
|
const text = renderStepSequence(
|
|
97
97
|
flow.steps,
|
|
98
98
|
slots,
|
|
99
99
|
currentStack,
|
|
100
100
|
activeStep,
|
|
101
|
-
stepTrail
|
|
102
|
-
)
|
|
103
|
-
mermaidText.push(text)
|
|
104
|
-
mermaidText.push(colorDoubleEdges(mermaidText.join(
|
|
105
|
-
return mermaidText.join(
|
|
101
|
+
stepTrail,
|
|
102
|
+
)
|
|
103
|
+
mermaidText.push(text)
|
|
104
|
+
mermaidText.push(colorDoubleEdges(mermaidText.join('')))
|
|
105
|
+
return mermaidText.join('')
|
|
106
106
|
} catch (e) {
|
|
107
|
-
return `${mermaidText}\nA["Something went wrong!"]\nB["${e}"]
|
|
107
|
+
return `${mermaidText}\nA["Something went wrong!"]\nB["${e}"]`
|
|
108
108
|
}
|
|
109
|
-
}
|
|
109
|
+
}
|
|
110
110
|
|
|
111
111
|
function truncate(str: string, limit = 35) {
|
|
112
112
|
// if a string is too long, use an ellipsis
|
|
113
113
|
if (str.length > limit) {
|
|
114
|
-
return str.substring(0, limit) +
|
|
114
|
+
return str.substring(0, limit) + '...'
|
|
115
115
|
}
|
|
116
|
-
return str
|
|
116
|
+
return str
|
|
117
117
|
}
|
|
118
118
|
|
|
119
119
|
function colorDoubleEdges(mermaidText: string) {
|
|
120
120
|
// go through the lines of mermaid text. keep a counter counting edges
|
|
121
121
|
// ("-->"" or "==>"). if "==>" is found in a line, add the line number to
|
|
122
122
|
// a list.
|
|
123
|
-
const lines = mermaidText.split(
|
|
124
|
-
const coloredEdges = []
|
|
125
|
-
let edgeCounter = 0
|
|
123
|
+
const lines = mermaidText.split('\n')
|
|
124
|
+
const coloredEdges = []
|
|
125
|
+
let edgeCounter = 0
|
|
126
126
|
for (let i = 0; i < lines.length; i++) {
|
|
127
|
-
if (lines[i].includes(
|
|
128
|
-
edgeCounter
|
|
129
|
-
} else if (lines[i].includes(
|
|
130
|
-
coloredEdges.push(edgeCounter)
|
|
131
|
-
edgeCounter
|
|
127
|
+
if (lines[i].includes('-->')) {
|
|
128
|
+
edgeCounter++
|
|
129
|
+
} else if (lines[i].includes('==>')) {
|
|
130
|
+
coloredEdges.push(edgeCounter)
|
|
131
|
+
edgeCounter++
|
|
132
132
|
}
|
|
133
133
|
}
|
|
134
|
-
if(coloredEdges.length > 0) {
|
|
135
|
-
return `linkStyle ${coloredEdges.join(
|
|
134
|
+
if (coloredEdges.length > 0) {
|
|
135
|
+
return `linkStyle ${coloredEdges.join(',')} stroke:${
|
|
136
136
|
rasaColors.rasaOrange[400]
|
|
137
|
-
}, ;\n
|
|
137
|
+
}, ;\n`
|
|
138
138
|
} else {
|
|
139
|
-
return
|
|
139
|
+
return ''
|
|
140
140
|
}
|
|
141
141
|
}
|
|
142
142
|
|
|
143
143
|
export function parseFieldUsingStack(name: string, stack?: Stack): string {
|
|
144
144
|
// name might be in the `{{context.field_in_stack}}` format so we're stripping everything except the field in the stack name
|
|
145
|
-
const parsedField = name.split(/{{context\.|}}/)
|
|
145
|
+
const parsedField = name.split(/{{context\.|}}/)
|
|
146
146
|
if (parsedField.length === 1) {
|
|
147
|
-
return parsedField[0]
|
|
147
|
+
return parsedField[0]
|
|
148
148
|
}
|
|
149
149
|
|
|
150
|
-
const stackField = parsedField[1]
|
|
150
|
+
const stackField = parsedField[1]
|
|
151
151
|
|
|
152
152
|
// @ts-expect-error `stack[stackField]` doesn't necessary exists this might return `undefined`
|
|
153
|
-
const stackValue = stack ? stack[stackField] : undefined
|
|
153
|
+
const stackValue = stack ? stack[stackField] : undefined
|
|
154
154
|
|
|
155
155
|
// name might also be in the `condition {{context.field_in_stack}} condition` format
|
|
156
156
|
// so we want to keep that if there is any
|
|
157
|
-
if (parsedField[2] && parsedField[2] !==
|
|
158
|
-
return `${parsedField[0]}${stackValue}${parsedField[2]}
|
|
157
|
+
if (parsedField[2] && parsedField[2] !== '') {
|
|
158
|
+
return `${parsedField[0]}${stackValue}${parsedField[2]}`
|
|
159
159
|
}
|
|
160
160
|
|
|
161
|
-
return `${parsedField[0]}${stackValue}
|
|
161
|
+
return `${parsedField[0]}${stackValue}`
|
|
162
162
|
}
|
|
163
163
|
|
|
164
164
|
function arrowTypeFor(stepId: string, nextId: string, stepTrail?: string[]) {
|
|
165
165
|
return stepTrail?.includes(stepId) && stepTrail?.includes(nextId)
|
|
166
|
-
?
|
|
167
|
-
:
|
|
166
|
+
? '==>'
|
|
167
|
+
: '-->'
|
|
168
168
|
}
|
|
169
169
|
|
|
170
170
|
function renderStepSequence(
|
|
171
|
-
steps: Flow[
|
|
171
|
+
steps: Flow['steps'],
|
|
172
172
|
slots: Slot[],
|
|
173
173
|
currentStack?: Stack,
|
|
174
174
|
activeStep?: string,
|
|
175
|
-
stepTrail?: string[]
|
|
175
|
+
stepTrail?: string[],
|
|
176
176
|
) {
|
|
177
|
-
let hasUsedEndStep = false
|
|
178
|
-
let mermaidTextFragment =
|
|
177
|
+
let hasUsedEndStep = false
|
|
178
|
+
let mermaidTextFragment = ''
|
|
179
179
|
steps.forEach((step) => {
|
|
180
|
-
const stepId = parseFieldUsingStack(step.id, currentStack)
|
|
181
|
-
const mermaidId = mermaidIdForTitle(stepId)
|
|
180
|
+
const stepId = parseFieldUsingStack(step.id, currentStack)
|
|
181
|
+
const mermaidId = mermaidIdForTitle(stepId)
|
|
182
182
|
|
|
183
183
|
if (step.collect) {
|
|
184
|
-
const slot = slots.find((slot) => slot.name === step.collect)
|
|
184
|
+
const slot = slots.find((slot) => slot.name === step.collect)
|
|
185
185
|
const slotValue =
|
|
186
|
-
slot && typeof slot.value ===
|
|
186
|
+
slot && typeof slot.value === 'string'
|
|
187
187
|
? `"${encodeDoubleQuotes(truncate(slot.value))}"`
|
|
188
|
-
:
|
|
188
|
+
: '💬'
|
|
189
189
|
mermaidTextFragment += `${mermaidId}["${encodeDoubleQuotes(
|
|
190
|
-
truncate(parseFieldUsingStack(step.collect, currentStack))
|
|
191
|
-
)}\n${slotValue}"]:::collect\n
|
|
190
|
+
truncate(parseFieldUsingStack(step.collect, currentStack)),
|
|
191
|
+
)}\n${slotValue}"]:::collect\n`
|
|
192
192
|
}
|
|
193
193
|
|
|
194
194
|
if (step.action) {
|
|
195
195
|
mermaidTextFragment += `${mermaidId}["${encodeDoubleQuotes(
|
|
196
|
-
truncate(parseFieldUsingStack(step.action, currentStack))
|
|
197
|
-
)}"]:::action\n
|
|
196
|
+
truncate(parseFieldUsingStack(step.action, currentStack)),
|
|
197
|
+
)}"]:::action\n`
|
|
198
198
|
}
|
|
199
199
|
|
|
200
200
|
if (step.link) {
|
|
201
201
|
mermaidTextFragment += `${mermaidId}["\uD83D\uDD17 ${parseFieldUsingStack(
|
|
202
202
|
step.link,
|
|
203
|
-
currentStack
|
|
204
|
-
)}"]:::link\n
|
|
203
|
+
currentStack,
|
|
204
|
+
)}"]:::link\n`
|
|
205
205
|
}
|
|
206
206
|
|
|
207
207
|
if (step.set_slots) {
|
|
208
208
|
mermaidTextFragment += `${mermaidId}["✍️ ${encodeDoubleQuotes(
|
|
209
|
-
stepId
|
|
210
|
-
)}"]:::slot\n
|
|
209
|
+
stepId,
|
|
210
|
+
)}"]:::slot\n`
|
|
211
211
|
}
|
|
212
212
|
|
|
213
213
|
if (activeStep && stepId === activeStep) {
|
|
214
|
-
mermaidTextFragment += `class ${mermaidId} active\n
|
|
214
|
+
mermaidTextFragment += `class ${mermaidId} active\n`
|
|
215
215
|
} else if (stepTrail?.includes(stepId)) {
|
|
216
|
-
mermaidTextFragment += `class ${mermaidId} previous\n
|
|
216
|
+
mermaidTextFragment += `class ${mermaidId} previous\n`
|
|
217
217
|
}
|
|
218
218
|
|
|
219
219
|
// if next is an id, then it is a link
|
|
220
|
-
if (step.next && typeof step.next ===
|
|
221
|
-
const nextId = parseFieldUsingStack(step.next, currentStack)
|
|
220
|
+
if (step.next && typeof step.next === 'string') {
|
|
221
|
+
const nextId = parseFieldUsingStack(step.next, currentStack)
|
|
222
222
|
|
|
223
223
|
mermaidTextFragment += `${mermaidId} ${arrowTypeFor(
|
|
224
224
|
stepId,
|
|
225
225
|
nextId,
|
|
226
|
-
stepTrail
|
|
227
|
-
)} ${mermaidIdForTitle(nextId)}\n
|
|
228
|
-
if (step.next ==
|
|
229
|
-
hasUsedEndStep = true
|
|
226
|
+
stepTrail,
|
|
227
|
+
)} ${mermaidIdForTitle(nextId)}\n`
|
|
228
|
+
if (step.next == 'END') {
|
|
229
|
+
hasUsedEndStep = true
|
|
230
230
|
}
|
|
231
231
|
}
|
|
232
232
|
|
|
233
233
|
// if next is an array, then it is a list of conditions
|
|
234
234
|
if (step.next && Array.isArray(step.next)) {
|
|
235
235
|
step.next.forEach((condition) => {
|
|
236
|
-
if (condition.then && typeof condition.then ===
|
|
236
|
+
if (condition.then && typeof condition.then === 'string') {
|
|
237
237
|
mermaidTextFragment += `${mermaidId} ${arrowTypeFor(
|
|
238
238
|
stepId,
|
|
239
239
|
condition.then,
|
|
240
|
-
stepTrail
|
|
240
|
+
stepTrail,
|
|
241
241
|
)}|"${encodeDoubleQuotes(
|
|
242
|
-
parseFieldUsingStack(condition.if, currentStack)
|
|
243
|
-
)}"| ${mermaidIdForTitle(condition.then)}\n
|
|
244
|
-
if (condition.then ==
|
|
245
|
-
hasUsedEndStep = true
|
|
242
|
+
parseFieldUsingStack(condition.if, currentStack),
|
|
243
|
+
)}"| ${mermaidIdForTitle(condition.then)}\n`
|
|
244
|
+
if (condition.then == 'END') {
|
|
245
|
+
hasUsedEndStep = true
|
|
246
246
|
}
|
|
247
247
|
} else if (condition.then) {
|
|
248
248
|
mermaidTextFragment += `${mermaidId} ${arrowTypeFor(
|
|
249
249
|
stepId,
|
|
250
250
|
condition.then[0].id,
|
|
251
|
-
stepTrail
|
|
251
|
+
stepTrail,
|
|
252
252
|
)}|"${encodeDoubleQuotes(
|
|
253
|
-
parseFieldUsingStack(condition.if, currentStack)
|
|
254
|
-
)}"| ${mermaidIdForTitle(condition.then[0].id)}\n
|
|
253
|
+
parseFieldUsingStack(condition.if, currentStack),
|
|
254
|
+
)}"| ${mermaidIdForTitle(condition.then[0].id)}\n`
|
|
255
255
|
mermaidTextFragment += renderStepSequence(
|
|
256
256
|
// @ts-expect-error Currently the param for renderStepSequence only accepts a Step, for further improvements we need to change the type to know that it can also be a then step
|
|
257
257
|
condition.then,
|
|
258
258
|
slots,
|
|
259
259
|
currentStack,
|
|
260
260
|
activeStep,
|
|
261
|
-
stepTrail
|
|
262
|
-
)
|
|
261
|
+
stepTrail,
|
|
262
|
+
)
|
|
263
263
|
}
|
|
264
264
|
|
|
265
265
|
// @ts-expect-error Currently the param for renderStepSequence only accepts a Step, for further improvements we need to change the type to know that it can also be a then step
|
|
266
|
-
if (condition.else && typeof condition.else ===
|
|
266
|
+
if (condition.else && typeof condition.else === 'string') {
|
|
267
267
|
mermaidTextFragment += `${mermaidId} ${arrowTypeFor(
|
|
268
268
|
stepId,
|
|
269
269
|
// @ts-expect-error Currently the param for renderStepSequence only accepts a Step, for further improvements we need to change the type to know that it can also be a then step
|
|
270
270
|
condition.else,
|
|
271
|
-
stepTrail
|
|
271
|
+
stepTrail,
|
|
272
272
|
// @ts-expect-error Currently the param for renderStepSequence only accepts a Step, for further improvements we need to change the type to know that it can also be a then step
|
|
273
|
-
)}|else| ${mermaidIdForTitle(condition.else)}\n
|
|
273
|
+
)}|else| ${mermaidIdForTitle(condition.else)}\n`
|
|
274
274
|
// @ts-expect-error Currently the param for renderStepSequence only accepts a Step, for further improvements we need to change the type to know that it can also be a then step
|
|
275
|
-
if (condition.else ==
|
|
276
|
-
hasUsedEndStep = true
|
|
275
|
+
if (condition.else == 'END') {
|
|
276
|
+
hasUsedEndStep = true
|
|
277
277
|
}
|
|
278
278
|
// @ts-expect-error Currently the param for renderStepSequence only accepts a Step, for further improvements we need to change the type to know that it can also be a then step
|
|
279
279
|
} else if (condition.else) {
|
|
@@ -281,26 +281,26 @@ function renderStepSequence(
|
|
|
281
281
|
stepId,
|
|
282
282
|
// @ts-expect-error Currently the param for renderStepSequence only accepts a Step, for further improvements we need to change the type to know that it can also be a then step
|
|
283
283
|
condition.else[0].id,
|
|
284
|
-
stepTrail
|
|
284
|
+
stepTrail,
|
|
285
285
|
// @ts-expect-error Currently the param for renderStepSequence only accepts a Step, for further improvements we need to change the type to know that it can also be a then step
|
|
286
|
-
)}|else| ${mermaidIdForTitle(condition.else[0].id)}\n
|
|
286
|
+
)}|else| ${mermaidIdForTitle(condition.else[0].id)}\n`
|
|
287
287
|
mermaidTextFragment += renderStepSequence(
|
|
288
288
|
// @ts-expect-error Currently the param for renderStepSequence only accepts a Step, for further improvements we need to change the type to know that it can also be a then step
|
|
289
289
|
condition.else,
|
|
290
290
|
slots,
|
|
291
291
|
currentStack,
|
|
292
292
|
activeStep,
|
|
293
|
-
stepTrail
|
|
294
|
-
)
|
|
293
|
+
stepTrail,
|
|
294
|
+
)
|
|
295
295
|
}
|
|
296
|
-
})
|
|
296
|
+
})
|
|
297
297
|
}
|
|
298
|
-
})
|
|
298
|
+
})
|
|
299
299
|
if (hasUsedEndStep) {
|
|
300
|
-
mermaidTextFragment += `${mermaidIdForTitle(
|
|
301
|
-
if (activeStep &&
|
|
302
|
-
mermaidTextFragment += `class ${mermaidIdForTitle(
|
|
300
|
+
mermaidTextFragment += `${mermaidIdForTitle('END')}["🏁 END"]:::endstep\n`
|
|
301
|
+
if (activeStep && 'END' === activeStep) {
|
|
302
|
+
mermaidTextFragment += `class ${mermaidIdForTitle('END')} active\n`
|
|
303
303
|
}
|
|
304
304
|
}
|
|
305
|
-
return mermaidTextFragment
|
|
305
|
+
return mermaidTextFragment
|
|
306
306
|
}
|
|
@@ -1,131 +1,148 @@
|
|
|
1
|
-
import { SelectedStack, Stack, Event } from
|
|
2
|
-
import { immutableJSONPatch} from 'immutable-json-patch'
|
|
1
|
+
import { SelectedStack, Stack, Event } from '../types'
|
|
2
|
+
import { immutableJSONPatch } from 'immutable-json-patch'
|
|
3
3
|
|
|
4
4
|
export const shouldShowTooltip = (text: string) => {
|
|
5
5
|
if (!text) {
|
|
6
|
-
return false
|
|
6
|
+
return false
|
|
7
7
|
}
|
|
8
8
|
|
|
9
|
-
const textLength = text.length
|
|
9
|
+
const textLength = text.length
|
|
10
10
|
|
|
11
11
|
if (textLength > 10 && textLength < 89) {
|
|
12
|
-
return true
|
|
12
|
+
return true
|
|
13
13
|
}
|
|
14
14
|
|
|
15
|
-
return false
|
|
16
|
-
}
|
|
15
|
+
return false
|
|
16
|
+
}
|
|
17
17
|
|
|
18
|
-
export const createHistoricalStack = (
|
|
18
|
+
export const createHistoricalStack = (
|
|
19
|
+
activeStack: Stack[],
|
|
20
|
+
events: Event[],
|
|
21
|
+
): Stack[] => {
|
|
19
22
|
let stackFrames = activeStack.map((frame) => ({
|
|
20
23
|
...frame,
|
|
21
24
|
ended: false,
|
|
22
|
-
}))
|
|
25
|
+
}))
|
|
23
26
|
// go through the events looking for flow_completed and append them to the stack
|
|
24
|
-
let historicalStack: Stack[] = []
|
|
25
|
-
let pastStackFrames: Stack[] = []
|
|
27
|
+
let historicalStack: Stack[] = []
|
|
28
|
+
let pastStackFrames: Stack[] = []
|
|
26
29
|
for (const event of events) {
|
|
27
|
-
if (event.event ===
|
|
28
|
-
historicalStack = []
|
|
29
|
-
stackFrames = []
|
|
30
|
-
} else if (event.event ===
|
|
31
|
-
let stackUpdate = JSON.parse(event.update ||
|
|
30
|
+
if (event.event === 'restart') {
|
|
31
|
+
historicalStack = []
|
|
32
|
+
stackFrames = []
|
|
33
|
+
} else if (event.event === 'stack') {
|
|
34
|
+
let stackUpdate = JSON.parse(event.update || '')
|
|
32
35
|
historicalStack = immutableJSONPatch(historicalStack, stackUpdate)
|
|
33
36
|
for (const frame of historicalStack) {
|
|
34
|
-
if(!frame.flow_id){
|
|
37
|
+
if (!frame.flow_id) {
|
|
35
38
|
// this is not a stack frame from the flow handler
|
|
36
|
-
continue
|
|
39
|
+
continue
|
|
37
40
|
}
|
|
38
41
|
// if the frame is already in stackFrames, skip it
|
|
39
|
-
if(stackFrames.find((f) => f.frame_id === frame.frame_id)) {
|
|
40
|
-
continue
|
|
42
|
+
if (stackFrames.find((f) => f.frame_id === frame.frame_id)) {
|
|
43
|
+
continue
|
|
41
44
|
}
|
|
42
45
|
// if the frame is in pastStackFrames, update the step_id otherwise add it
|
|
43
|
-
const pastFrame = pastStackFrames.find(
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
46
|
+
const pastFrame = pastStackFrames.find(
|
|
47
|
+
(f) => f.frame_id === frame.frame_id,
|
|
48
|
+
)
|
|
49
|
+
if (pastFrame) {
|
|
50
|
+
pastFrame.step_id = frame.step_id
|
|
51
|
+
continue
|
|
47
52
|
}
|
|
48
|
-
pastStackFrames.push({...frame, ended: true})
|
|
53
|
+
pastStackFrames.push({ ...frame, ended: true })
|
|
49
54
|
}
|
|
50
55
|
}
|
|
51
56
|
}
|
|
52
57
|
// filter out pattern_collect_information frames
|
|
53
|
-
pastStackFrames = pastStackFrames.filter(
|
|
54
|
-
|
|
58
|
+
pastStackFrames = pastStackFrames.filter(
|
|
59
|
+
(frame) => frame.flow_id !== 'pattern_collect_information',
|
|
60
|
+
)
|
|
61
|
+
return [...pastStackFrames, ...stackFrames]
|
|
55
62
|
}
|
|
56
63
|
|
|
57
64
|
export const flowStepTrail = (events: Event[]): Record<string, string[]> => {
|
|
58
|
-
let stack: Stack[] = []
|
|
65
|
+
let stack: Stack[] = []
|
|
59
66
|
// mapping from flow id to the steps that were active in that flow
|
|
60
|
-
let activeSteps: { [key: string]: string[] } = {}
|
|
67
|
+
let activeSteps: { [key: string]: string[] } = {}
|
|
61
68
|
for (const event of events) {
|
|
62
|
-
if (event.event ===
|
|
63
|
-
stack = []
|
|
64
|
-
activeSteps = {}
|
|
65
|
-
} else if (event.event ===
|
|
66
|
-
let stackUpdate = JSON.parse(event.update ||
|
|
69
|
+
if (event.event === 'restart') {
|
|
70
|
+
stack = []
|
|
71
|
+
activeSteps = {}
|
|
72
|
+
} else if (event.event === 'stack') {
|
|
73
|
+
let stackUpdate = JSON.parse(event.update || '')
|
|
67
74
|
stack = immutableJSONPatch(stack, stackUpdate)
|
|
68
75
|
if (stack.length > 0) {
|
|
69
|
-
let topFrame = stack[stack.length - 1]
|
|
76
|
+
let topFrame = stack[stack.length - 1]
|
|
70
77
|
if (!topFrame.flow_id) {
|
|
71
78
|
// this is not a stack frame from the flow handler
|
|
72
|
-
continue
|
|
79
|
+
continue
|
|
73
80
|
}
|
|
74
|
-
if (!activeSteps[topFrame.flow_id] ||
|
|
75
|
-
activeSteps[topFrame.flow_id] = []
|
|
81
|
+
if (!activeSteps[topFrame.flow_id] || topFrame.step_id === 'START') {
|
|
82
|
+
activeSteps[topFrame.flow_id] = []
|
|
76
83
|
}
|
|
77
84
|
if (!activeSteps[topFrame.flow_id].includes(topFrame.step_id)) {
|
|
78
85
|
activeSteps[topFrame.flow_id].push(topFrame.step_id)
|
|
79
86
|
}
|
|
80
87
|
}
|
|
81
|
-
|
|
82
88
|
}
|
|
83
89
|
}
|
|
84
|
-
return activeSteps
|
|
85
|
-
}
|
|
90
|
+
return activeSteps
|
|
91
|
+
}
|
|
86
92
|
|
|
87
|
-
export const updatedActiveFrame = (
|
|
93
|
+
export const updatedActiveFrame = (
|
|
94
|
+
previous: SelectedStack | undefined,
|
|
95
|
+
updatedStack: Stack[],
|
|
96
|
+
events: Event[],
|
|
97
|
+
) => {
|
|
88
98
|
// try to find the currently active frame in the updated stack
|
|
89
99
|
// if it isn't there anymore, we will show the first non-pattern frame
|
|
90
100
|
// instead
|
|
91
101
|
|
|
92
102
|
// reset previously active stack frame, if it was not user selected
|
|
93
|
-
if(!previous?.isUserSelected){
|
|
103
|
+
if (!previous?.isUserSelected) {
|
|
94
104
|
previous = undefined
|
|
95
105
|
}
|
|
96
106
|
|
|
97
107
|
const activeFrame = updatedStack.find(
|
|
98
|
-
(stackFrame) => stackFrame.frame_id === previous?.stack.frame_id
|
|
99
|
-
)
|
|
108
|
+
(stackFrame) => stackFrame.frame_id === previous?.stack.frame_id,
|
|
109
|
+
)
|
|
100
110
|
if (!activeFrame || activeFrame.ended) {
|
|
101
|
-
if (!updatedStack){
|
|
102
|
-
return undefined
|
|
111
|
+
if (!updatedStack) {
|
|
112
|
+
return undefined
|
|
103
113
|
}
|
|
104
114
|
// iterate over the stack. select the first frame where the name does not
|
|
105
115
|
// contain "pattern" and that has not
|
|
106
116
|
// ended yet. If there is no such frame, select the topmost frame that has
|
|
107
117
|
// not ended yet. If there is no such frame, select the topmost frame.
|
|
108
|
-
const updatedFrame =
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
118
|
+
const updatedFrame =
|
|
119
|
+
updatedStack
|
|
120
|
+
.slice()
|
|
121
|
+
.reverse()
|
|
122
|
+
.find(
|
|
123
|
+
(frame) => !frame.flow_id?.startsWith('pattern_') && !frame.ended,
|
|
124
|
+
) ||
|
|
125
|
+
updatedStack
|
|
126
|
+
.slice()
|
|
127
|
+
.reverse()
|
|
128
|
+
.find((frame) => !frame.ended) ||
|
|
129
|
+
updatedStack[updatedStack.length - 1]
|
|
114
130
|
|
|
115
|
-
if(updatedFrame !== undefined) {
|
|
131
|
+
if (updatedFrame !== undefined) {
|
|
116
132
|
return {
|
|
117
133
|
stack: updatedFrame,
|
|
118
134
|
isUserSelected: false,
|
|
119
135
|
activatedSteps: flowStepTrail(events)[updatedFrame.flow_id] || [],
|
|
120
|
-
}
|
|
136
|
+
}
|
|
121
137
|
} else {
|
|
122
|
-
return undefined
|
|
138
|
+
return undefined
|
|
123
139
|
}
|
|
124
140
|
} else {
|
|
125
|
-
if(previous){
|
|
126
|
-
previous.activatedSteps =
|
|
127
|
-
|
|
141
|
+
if (previous) {
|
|
142
|
+
previous.activatedSteps =
|
|
143
|
+
flowStepTrail(events)[previous.stack.flow_id] || []
|
|
144
|
+
previous.stack = activeFrame
|
|
128
145
|
}
|
|
129
|
-
return previous
|
|
146
|
+
return previous
|
|
130
147
|
}
|
|
131
|
-
}
|
|
148
|
+
}
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import React from
|
|
2
|
-
import ReactDOM from
|
|
3
|
-
import { App } from
|
|
4
|
-
import { ChakraProvider } from
|
|
5
|
-
import { theme } from
|
|
1
|
+
import React from 'react'
|
|
2
|
+
import ReactDOM from 'react-dom/client'
|
|
3
|
+
import { App } from './App.tsx'
|
|
4
|
+
import { ChakraProvider } from '@chakra-ui/react'
|
|
5
|
+
import { theme } from './theme'
|
|
6
6
|
|
|
7
|
-
ReactDOM.createRoot(document.getElementById(
|
|
7
|
+
ReactDOM.createRoot(document.getElementById('root')!).render(
|
|
8
8
|
<React.StrictMode>
|
|
9
9
|
<ChakraProvider theme={theme}>
|
|
10
10
|
<App />
|
|
11
11
|
</ChakraProvider>
|
|
12
|
-
</React.StrictMode
|
|
13
|
-
)
|
|
12
|
+
</React.StrictMode>,
|
|
13
|
+
)
|