@nyaruka/temba-components 0.138.6 → 0.140.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.github/workflows/cla.yml +1 -1
- package/.github/workflows/copilot-setup-steps.yml +6 -1
- package/CHANGELOG.md +26 -0
- package/demo/data/flows/sample-flow.json +24 -0
- package/dist/locales/es.js +5 -5
- package/dist/locales/es.js.map +1 -1
- package/dist/locales/fr.js +5 -5
- package/dist/locales/fr.js.map +1 -1
- package/dist/locales/locale-codes.js +2 -11
- package/dist/locales/locale-codes.js.map +1 -1
- package/dist/locales/pt.js +5 -5
- package/dist/locales/pt.js.map +1 -1
- package/dist/temba-components.js +1112 -882
- package/dist/temba-components.js.map +1 -1
- package/out-tsc/src/display/Chat.js +10 -7
- package/out-tsc/src/display/Chat.js.map +1 -1
- package/out-tsc/src/display/Dropdown.js +3 -1
- package/out-tsc/src/display/Dropdown.js.map +1 -1
- package/out-tsc/src/display/FloatingTab.js +25 -32
- package/out-tsc/src/display/FloatingTab.js.map +1 -1
- package/out-tsc/src/display/Thumbnail.js +163 -5
- package/out-tsc/src/display/Thumbnail.js.map +1 -1
- package/out-tsc/src/flow/CanvasMenu.js +5 -3
- package/out-tsc/src/flow/CanvasMenu.js.map +1 -1
- package/out-tsc/src/flow/CanvasNode.js +70 -29
- package/out-tsc/src/flow/CanvasNode.js.map +1 -1
- package/out-tsc/src/flow/Editor.js +290 -239
- package/out-tsc/src/flow/Editor.js.map +1 -1
- package/out-tsc/src/flow/NodeEditor.js +118 -10
- package/out-tsc/src/flow/NodeEditor.js.map +1 -1
- package/out-tsc/src/flow/Plumber.js +757 -403
- package/out-tsc/src/flow/Plumber.js.map +1 -1
- package/out-tsc/src/flow/StickyNote.js +13 -4
- package/out-tsc/src/flow/StickyNote.js.map +1 -1
- package/out-tsc/src/flow/actions/audio-player.js +112 -0
- package/out-tsc/src/flow/actions/audio-player.js.map +1 -0
- package/out-tsc/src/flow/actions/enter_flow.js +43 -0
- package/out-tsc/src/flow/actions/enter_flow.js.map +1 -0
- package/out-tsc/src/flow/actions/play_audio.js +57 -4
- package/out-tsc/src/flow/actions/play_audio.js.map +1 -1
- package/out-tsc/src/flow/actions/say_msg.js +86 -3
- package/out-tsc/src/flow/actions/say_msg.js.map +1 -1
- package/out-tsc/src/flow/config.js +11 -3
- package/out-tsc/src/flow/config.js.map +1 -1
- package/out-tsc/src/flow/nodes/shared-rules.js +1 -1
- package/out-tsc/src/flow/nodes/shared-rules.js.map +1 -1
- package/out-tsc/src/flow/nodes/terminal.js +7 -0
- package/out-tsc/src/flow/nodes/terminal.js.map +1 -0
- package/out-tsc/src/flow/nodes/wait_for_audio.js +77 -0
- package/out-tsc/src/flow/nodes/wait_for_audio.js.map +1 -0
- package/out-tsc/src/flow/nodes/wait_for_dial.js +151 -0
- package/out-tsc/src/flow/nodes/wait_for_dial.js.map +1 -0
- package/out-tsc/src/flow/nodes/wait_for_digits.js +61 -1
- package/out-tsc/src/flow/nodes/wait_for_digits.js.map +1 -1
- package/out-tsc/src/flow/nodes/wait_for_menu.js +173 -2
- package/out-tsc/src/flow/nodes/wait_for_menu.js.map +1 -1
- package/out-tsc/src/flow/operators.js +21 -5
- package/out-tsc/src/flow/operators.js.map +1 -1
- package/out-tsc/src/flow/types.js.map +1 -1
- package/out-tsc/src/flow/utils.js +213 -65
- package/out-tsc/src/flow/utils.js.map +1 -1
- package/out-tsc/src/form/ArrayEditor.js +4 -2
- package/out-tsc/src/form/ArrayEditor.js.map +1 -1
- package/out-tsc/src/form/FieldRenderer.js +49 -0
- package/out-tsc/src/form/FieldRenderer.js.map +1 -1
- package/out-tsc/src/interfaces.js +2 -0
- package/out-tsc/src/interfaces.js.map +1 -1
- package/out-tsc/src/layout/Dialog.js +52 -7
- package/out-tsc/src/layout/Dialog.js.map +1 -1
- package/out-tsc/src/list/TicketList.js +4 -1
- package/out-tsc/src/list/TicketList.js.map +1 -1
- package/out-tsc/src/live/TembaChart.js.map +1 -1
- package/out-tsc/src/locales/es.js +5 -5
- package/out-tsc/src/locales/es.js.map +1 -1
- package/out-tsc/src/locales/fr.js +5 -5
- package/out-tsc/src/locales/fr.js.map +1 -1
- package/out-tsc/src/locales/locale-codes.js +2 -11
- package/out-tsc/src/locales/locale-codes.js.map +1 -1
- package/out-tsc/src/locales/pt.js +5 -5
- package/out-tsc/src/locales/pt.js.map +1 -1
- package/out-tsc/src/simulator/Simulator.js +10 -3
- package/out-tsc/src/simulator/Simulator.js.map +1 -1
- package/out-tsc/src/store/AppState.js +89 -3
- package/out-tsc/src/store/AppState.js.map +1 -1
- package/out-tsc/test/actions/play_audio.test.js +118 -0
- package/out-tsc/test/actions/play_audio.test.js.map +1 -0
- package/out-tsc/test/actions/say_msg.test.js +158 -0
- package/out-tsc/test/actions/say_msg.test.js.map +1 -0
- package/out-tsc/test/nodes/wait_for_audio.test.js +156 -0
- package/out-tsc/test/nodes/wait_for_audio.test.js.map +1 -0
- package/out-tsc/test/nodes/wait_for_dial.test.js +336 -0
- package/out-tsc/test/nodes/wait_for_dial.test.js.map +1 -0
- package/out-tsc/test/nodes/wait_for_digits.test.js +198 -84
- package/out-tsc/test/nodes/wait_for_digits.test.js.map +1 -1
- package/out-tsc/test/nodes/wait_for_menu.test.js +340 -0
- package/out-tsc/test/nodes/wait_for_menu.test.js.map +1 -0
- package/out-tsc/test/temba-floating-tab.test.js +4 -6
- package/out-tsc/test/temba-floating-tab.test.js.map +1 -1
- package/out-tsc/test/temba-flow-collision.test.js +473 -220
- package/out-tsc/test/temba-flow-collision.test.js.map +1 -1
- package/out-tsc/test/temba-flow-editor.test.js +0 -2
- package/out-tsc/test/temba-flow-editor.test.js.map +1 -1
- package/out-tsc/test/temba-flow-plumber-connections.test.js +83 -84
- package/out-tsc/test/temba-flow-plumber-connections.test.js.map +1 -1
- package/out-tsc/test/temba-flow-plumber.test.js +102 -93
- package/out-tsc/test/temba-flow-plumber.test.js.map +1 -1
- package/out-tsc/test/temba-node-type-selector.test.js +6 -6
- package/out-tsc/test/temba-node-type-selector.test.js.map +1 -1
- package/package.json +1 -1
- package/screenshots/truth/actions/play_audio/editor/expression-url.png +0 -0
- package/screenshots/truth/actions/play_audio/editor/static-url.png +0 -0
- package/screenshots/truth/actions/play_audio/render/expression-url.png +0 -0
- package/screenshots/truth/actions/play_audio/render/static-url.png +0 -0
- package/screenshots/truth/actions/say_msg/editor/multiline-text.png +0 -0
- package/screenshots/truth/actions/say_msg/editor/simple-text.png +0 -0
- package/screenshots/truth/actions/say_msg/editor/text-with-audio-url.png +0 -0
- package/screenshots/truth/actions/say_msg/render/multiline-text.png +0 -0
- package/screenshots/truth/actions/say_msg/render/simple-text.png +0 -0
- package/screenshots/truth/actions/say_msg/render/text-with-audio-url.png +0 -0
- package/screenshots/truth/editor/router.png +0 -0
- package/screenshots/truth/editor/wait.png +0 -0
- package/screenshots/truth/nodes/wait_for_audio/editor/basic-audio-wait.png +0 -0
- package/screenshots/truth/nodes/wait_for_audio/render/basic-audio-wait.png +0 -0
- package/screenshots/truth/nodes/wait_for_dial/editor/basic-dial.png +0 -0
- package/screenshots/truth/nodes/wait_for_dial/editor/dial-with-limits.png +0 -0
- package/screenshots/truth/nodes/wait_for_dial/render/basic-dial.png +0 -0
- package/screenshots/truth/nodes/wait_for_dial/render/dial-with-limits.png +0 -0
- package/screenshots/truth/nodes/wait_for_digits/editor/basic-digits-wait.png +0 -0
- package/screenshots/truth/nodes/wait_for_digits/editor/digits-with-rules.png +0 -0
- package/screenshots/truth/nodes/wait_for_digits/render/basic-digits-wait.png +0 -0
- package/screenshots/truth/nodes/wait_for_digits/render/digits-with-rules.png +0 -0
- package/screenshots/truth/nodes/wait_for_menu/editor/menu-with-digits.png +0 -0
- package/screenshots/truth/nodes/wait_for_menu/render/menu-with-digits.png +0 -0
- package/screenshots/truth/nodes/wait_for_response/editor/basic-wait.png +0 -0
- package/screenshots/truth/nodes/wait_for_response/editor/custom-result-name.png +0 -0
- package/screenshots/truth/nodes/wait_for_response/editor/no-timeout.png +0 -0
- package/screenshots/truth/nodes/wait_for_response/editor/short-timeout.png +0 -0
- package/screenshots/truth/nodes/wait_for_response/render/basic-wait.png +0 -0
- package/screenshots/truth/nodes/wait_for_response/render/custom-result-name.png +0 -0
- package/screenshots/truth/nodes/wait_for_response/render/no-timeout.png +0 -0
- package/screenshots/truth/nodes/wait_for_response/render/short-timeout.png +0 -0
- package/src/display/Chat.ts +13 -7
- package/src/display/Dropdown.ts +3 -1
- package/src/display/FloatingTab.ts +24 -33
- package/src/display/Thumbnail.ts +162 -2
- package/src/flow/CanvasMenu.ts +8 -3
- package/src/flow/CanvasNode.ts +75 -30
- package/src/flow/Editor.ts +336 -288
- package/src/flow/NodeEditor.ts +137 -9
- package/src/flow/Plumber.ts +1011 -457
- package/src/flow/StickyNote.ts +14 -4
- package/src/flow/actions/audio-player.ts +127 -0
- package/src/flow/actions/enter_flow.ts +44 -0
- package/src/flow/actions/play_audio.ts +64 -5
- package/src/flow/actions/say_msg.ts +94 -4
- package/src/flow/config.ts +11 -3
- package/src/flow/nodes/shared-rules.ts +1 -1
- package/src/flow/nodes/terminal.ts +9 -0
- package/src/flow/nodes/wait_for_audio.ts +88 -0
- package/src/flow/nodes/wait_for_dial.ts +176 -0
- package/src/flow/nodes/wait_for_digits.ts +86 -2
- package/src/flow/nodes/wait_for_menu.ts +209 -3
- package/src/flow/operators.ts +23 -5
- package/src/flow/types.ts +23 -1
- package/src/flow/utils.ts +238 -81
- package/src/form/ArrayEditor.ts +4 -2
- package/src/form/FieldRenderer.ts +64 -1
- package/src/interfaces.ts +3 -1
- package/src/layout/Dialog.ts +53 -7
- package/src/list/TicketList.ts +4 -1
- package/src/live/TembaChart.ts +1 -1
- package/src/locales/es.ts +13 -18
- package/src/locales/fr.ts +13 -18
- package/src/locales/locale-codes.ts +2 -11
- package/src/locales/pt.ts +13 -18
- package/src/simulator/Simulator.ts +13 -3
- package/src/store/AppState.ts +105 -1
- package/src/store/flow-definition.d.ts +2 -0
- package/test/actions/play_audio.test.ts +155 -0
- package/test/actions/say_msg.test.ts +196 -0
- package/test/nodes/wait_for_audio.test.ts +182 -0
- package/test/nodes/wait_for_dial.test.ts +382 -0
- package/test/nodes/wait_for_digits.test.ts +233 -109
- package/test/nodes/wait_for_menu.test.ts +383 -0
- package/test/temba-floating-tab.test.ts +4 -6
- package/test/temba-flow-collision.test.ts +495 -293
- package/test/temba-flow-editor.test.ts +0 -2
- package/test/temba-flow-plumber-connections.test.ts +97 -97
- package/test/temba-flow-plumber.test.ts +116 -103
- package/test/temba-node-type-selector.test.ts +6 -6
- package/screenshots/truth/nodes/wait_for_digits/editor/phone-number-collection.png +0 -0
- package/screenshots/truth/nodes/wait_for_digits/editor/single-digit-with-timeout.png +0 -0
- package/screenshots/truth/nodes/wait_for_digits/editor/verification-code.png +0 -0
- package/screenshots/truth/nodes/wait_for_digits/render/phone-number-collection.png +0 -0
- package/screenshots/truth/nodes/wait_for_digits/render/single-digit-with-timeout.png +0 -0
- package/screenshots/truth/nodes/wait_for_digits/render/verification-code.png +0 -0
|
@@ -1,12 +1,65 @@
|
|
|
1
1
|
import { html } from 'lit-html';
|
|
2
2
|
import { ACTION_GROUPS, FlowTypes } from '../types';
|
|
3
3
|
export const play_audio = {
|
|
4
|
-
name: 'Play
|
|
4
|
+
name: 'Play Recording',
|
|
5
5
|
group: ACTION_GROUPS.send,
|
|
6
6
|
flowTypes: [FlowTypes.VOICE],
|
|
7
|
-
render: (_node,
|
|
8
|
-
|
|
9
|
-
|
|
7
|
+
render: (_node, action) => {
|
|
8
|
+
return html `
|
|
9
|
+
<div style="display: flex; align-items: center; gap: 0.3em;">
|
|
10
|
+
<temba-icon name="recording" size="1"></temba-icon>
|
|
11
|
+
<div
|
|
12
|
+
style="overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0;"
|
|
13
|
+
title="${action.audio_url || ''}"
|
|
14
|
+
>
|
|
15
|
+
${action.audio_url || ''}
|
|
16
|
+
</div>
|
|
17
|
+
</div>
|
|
18
|
+
`;
|
|
19
|
+
},
|
|
20
|
+
form: {
|
|
21
|
+
audio_url: {
|
|
22
|
+
type: 'text',
|
|
23
|
+
label: 'Recording URL',
|
|
24
|
+
required: true,
|
|
25
|
+
evaluated: true
|
|
26
|
+
}
|
|
27
|
+
},
|
|
28
|
+
layout: ['audio_url'],
|
|
29
|
+
toFormData: (action) => {
|
|
30
|
+
return {
|
|
31
|
+
uuid: action.uuid,
|
|
32
|
+
audio_url: action.audio_url || ''
|
|
33
|
+
};
|
|
34
|
+
},
|
|
35
|
+
fromFormData: (data) => {
|
|
36
|
+
return {
|
|
37
|
+
uuid: data.uuid,
|
|
38
|
+
type: 'play_audio',
|
|
39
|
+
audio_url: (data.audio_url || '').trim()
|
|
40
|
+
};
|
|
41
|
+
},
|
|
42
|
+
localizable: ['audio_url'],
|
|
43
|
+
toLocalizationFormData: (action, localization) => {
|
|
44
|
+
const formData = {
|
|
45
|
+
uuid: action.uuid
|
|
46
|
+
};
|
|
47
|
+
if (localization.audio_url && Array.isArray(localization.audio_url)) {
|
|
48
|
+
formData.audio_url = localization.audio_url[0] || '';
|
|
49
|
+
}
|
|
50
|
+
else {
|
|
51
|
+
formData.audio_url = '';
|
|
52
|
+
}
|
|
53
|
+
return formData;
|
|
54
|
+
},
|
|
55
|
+
fromLocalizationFormData: (formData, action) => {
|
|
56
|
+
const localization = {};
|
|
57
|
+
if (formData.audio_url && formData.audio_url.trim() !== '') {
|
|
58
|
+
if (formData.audio_url !== action.audio_url) {
|
|
59
|
+
localization.audio_url = [formData.audio_url];
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
return localization;
|
|
10
63
|
}
|
|
11
64
|
};
|
|
12
65
|
//# sourceMappingURL=play_audio.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"play_audio.js","sourceRoot":"","sources":["../../../../src/flow/actions/play_audio.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,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QAAQ,GAAa;YACzB,IAAI,EAAE,MAAM,CAAC,IAAI;SAClB,CAAC;QAEF,IAAI,YAAY,CAAC,SAAS,IAAI,KAAK,CAAC,OAAO,CAAC,YAAY,CAAC,SAAS,CAAC,EAAE,CAAC;YACpE,QAAQ,CAAC,SAAS,GAAG,YAAY,CAAC,SAAS,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC;QACvD,CAAC;aAAM,CAAC;YACN,QAAQ,CAAC,SAAS,GAAG,EAAE,CAAC;QAC1B,CAAC;QAED,OAAO,QAAQ,CAAC;IAClB,CAAC;IACD,wBAAwB,EAAE,CAAC,QAAkB,EAAE,MAAiB,EAAE,EAAE;QAClE,MAAM,YAAY,GAAwB,EAAE,CAAC;QAE7C,IAAI,QAAQ,CAAC,SAAS,IAAI,QAAQ,CAAC,SAAS,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE,CAAC;YAC3D,IAAI,QAAQ,CAAC,SAAS,KAAK,MAAM,CAAC,SAAS,EAAE,CAAC;gBAC5C,YAAY,CAAC,SAAS,GAAG,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAC;YAChD,CAAC;QACH,CAAC;QAED,OAAO,YAAY,CAAC;IACtB,CAAC;CACF,CAAC","sourcesContent":["import { html } from 'lit-html';\nimport { ActionConfig, ACTION_GROUPS, FormData, FlowTypes } from '../types';\nimport { Node, PlayAudio } from '../../store/flow-definition';\n\nexport const play_audio: ActionConfig = {\n name: 'Play Recording',\n group: ACTION_GROUPS.send,\n flowTypes: [FlowTypes.VOICE],\n render: (_node: Node, action: PlayAudio) => {\n return html`\n <div style=\"display: flex; align-items: center; gap: 0.3em;\">\n <temba-icon name=\"recording\" size=\"1\"></temba-icon>\n <div\n style=\"overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0;\"\n title=\"${action.audio_url || ''}\"\n >\n ${action.audio_url || ''}\n </div>\n </div>\n `;\n },\n form: {\n audio_url: {\n type: 'text',\n label: 'Recording URL',\n required: true,\n evaluated: true\n }\n },\n layout: ['audio_url'],\n toFormData: (action: PlayAudio) => {\n return {\n uuid: action.uuid,\n audio_url: action.audio_url || ''\n };\n },\n fromFormData: (data: FormData) => {\n return {\n uuid: data.uuid,\n type: 'play_audio',\n audio_url: (data.audio_url || '').trim()\n } as PlayAudio;\n },\n localizable: ['audio_url'],\n toLocalizationFormData: (\n action: PlayAudio,\n localization: Record<string, any>\n ) => {\n const formData: FormData = {\n uuid: action.uuid\n };\n\n if (localization.audio_url && Array.isArray(localization.audio_url)) {\n formData.audio_url = localization.audio_url[0] || '';\n } else {\n formData.audio_url = '';\n }\n\n return formData;\n },\n fromLocalizationFormData: (formData: FormData, action: PlayAudio) => {\n const localization: Record<string, any> = {};\n\n if (formData.audio_url && formData.audio_url.trim() !== '') {\n if (formData.audio_url !== action.audio_url) {\n localization.audio_url = [formData.audio_url];\n }\n }\n\n return localization;\n }\n};\n"]}
|
|
@@ -1,12 +1,95 @@
|
|
|
1
1
|
import { html } from 'lit-html';
|
|
2
|
+
import { unsafeHTML } from 'lit-html/directives/unsafe-html.js';
|
|
2
3
|
import { ACTION_GROUPS, FlowTypes } from '../types';
|
|
4
|
+
import { renderAudioPlayer } from './audio-player';
|
|
3
5
|
export const say_msg = {
|
|
4
6
|
name: 'Say Message',
|
|
5
7
|
group: ACTION_GROUPS.send,
|
|
6
8
|
flowTypes: [FlowTypes.VOICE],
|
|
7
|
-
render: (_node,
|
|
8
|
-
|
|
9
|
-
return html
|
|
9
|
+
render: (_node, action) => {
|
|
10
|
+
const text = (action.text || '').replace(/\n/g, '<br>');
|
|
11
|
+
return html `
|
|
12
|
+
${unsafeHTML(text)}
|
|
13
|
+
${action.audio_url
|
|
14
|
+
? html `<div style="margin-top: 0.5em;">
|
|
15
|
+
${renderAudioPlayer(action.audio_url)}
|
|
16
|
+
</div>`
|
|
17
|
+
: null}
|
|
18
|
+
`;
|
|
19
|
+
},
|
|
20
|
+
form: {
|
|
21
|
+
text: {
|
|
22
|
+
type: 'textarea',
|
|
23
|
+
label: 'Message',
|
|
24
|
+
required: true,
|
|
25
|
+
evaluated: true,
|
|
26
|
+
placeholder: 'Enter message to speak...',
|
|
27
|
+
minHeight: 80
|
|
28
|
+
},
|
|
29
|
+
audio_url: {
|
|
30
|
+
type: 'media',
|
|
31
|
+
label: 'Recording',
|
|
32
|
+
required: false,
|
|
33
|
+
accept: 'audio/*',
|
|
34
|
+
optionalLink: 'Add a recording'
|
|
35
|
+
}
|
|
36
|
+
},
|
|
37
|
+
layout: ['text', 'audio_url'],
|
|
38
|
+
toFormData: (action) => {
|
|
39
|
+
return {
|
|
40
|
+
uuid: action.uuid,
|
|
41
|
+
text: action.text || '',
|
|
42
|
+
audio_url: action.audio_url || ''
|
|
43
|
+
};
|
|
44
|
+
},
|
|
45
|
+
fromFormData: (data) => {
|
|
46
|
+
const result = {
|
|
47
|
+
uuid: data.uuid,
|
|
48
|
+
type: 'say_msg',
|
|
49
|
+
text: data.text || ''
|
|
50
|
+
};
|
|
51
|
+
if (data.audio_url && data.audio_url.trim() !== '') {
|
|
52
|
+
result.audio_url = data.audio_url.trim();
|
|
53
|
+
}
|
|
54
|
+
return result;
|
|
55
|
+
},
|
|
56
|
+
sanitize: (formData) => {
|
|
57
|
+
if (formData.text && typeof formData.text === 'string') {
|
|
58
|
+
formData.text = formData.text.trim();
|
|
59
|
+
}
|
|
60
|
+
},
|
|
61
|
+
localizable: ['text', 'audio_url'],
|
|
62
|
+
toLocalizationFormData: (action, localization) => {
|
|
63
|
+
const formData = {
|
|
64
|
+
uuid: action.uuid
|
|
65
|
+
};
|
|
66
|
+
if (localization.text && Array.isArray(localization.text)) {
|
|
67
|
+
formData.text = localization.text[0] || '';
|
|
68
|
+
}
|
|
69
|
+
else {
|
|
70
|
+
formData.text = '';
|
|
71
|
+
}
|
|
72
|
+
if (localization.audio_url && Array.isArray(localization.audio_url)) {
|
|
73
|
+
formData.audio_url = localization.audio_url[0] || '';
|
|
74
|
+
}
|
|
75
|
+
else {
|
|
76
|
+
formData.audio_url = '';
|
|
77
|
+
}
|
|
78
|
+
return formData;
|
|
79
|
+
},
|
|
80
|
+
fromLocalizationFormData: (formData, action) => {
|
|
81
|
+
const localization = {};
|
|
82
|
+
if (formData.text && formData.text.trim() !== '') {
|
|
83
|
+
if (formData.text !== action.text) {
|
|
84
|
+
localization.text = [formData.text];
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
if (formData.audio_url && formData.audio_url.trim() !== '') {
|
|
88
|
+
if (formData.audio_url !== action.audio_url) {
|
|
89
|
+
localization.audio_url = [formData.audio_url];
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
return localization;
|
|
10
93
|
}
|
|
11
94
|
};
|
|
12
95
|
//# sourceMappingURL=say_msg.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"say_msg.js","sourceRoot":"","sources":["../../../../src/flow/actions/say_msg.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,UAAU,CAAC;AAChC,OAAO,EAAgB,aAAa,
|
|
1
|
+
{"version":3,"file":"say_msg.js","sourceRoot":"","sources":["../../../../src/flow/actions/say_msg.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,UAAU,CAAC;AAChC,OAAO,EAAE,UAAU,EAAE,MAAM,oCAAoC,CAAC;AAChE,OAAO,EAAgB,aAAa,EAAY,SAAS,EAAE,MAAM,UAAU,CAAC;AAE5E,OAAO,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AAEnD,MAAM,CAAC,MAAM,OAAO,GAAiB;IACnC,IAAI,EAAE,aAAa;IACnB,KAAK,EAAE,aAAa,CAAC,IAAI;IACzB,SAAS,EAAE,CAAC,SAAS,CAAC,KAAK,CAAC;IAC5B,MAAM,EAAE,CAAC,KAAW,EAAE,MAAc,EAAE,EAAE;QACtC,MAAM,IAAI,GAAG,CAAC,MAAM,CAAC,IAAI,IAAI,EAAE,CAAC,CAAC,OAAO,C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C,YAAY,CAAC,IAAI,GAAG,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;YACtC,CAAC;QACH,CAAC;QAED,IAAI,QAAQ,CAAC,SAAS,IAAI,QAAQ,CAAC,SAAS,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE,CAAC;YAC3D,IAAI,QAAQ,CAAC,SAAS,KAAK,MAAM,CAAC,SAAS,EAAE,CAAC;gBAC5C,YAAY,CAAC,SAAS,GAAG,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAC;YAChD,CAAC;QACH,CAAC;QAED,OAAO,YAAY,CAAC;IACtB,CAAC;CACF,CAAC","sourcesContent":["import { html } from 'lit-html';\nimport { unsafeHTML } from 'lit-html/directives/unsafe-html.js';\nimport { ActionConfig, ACTION_GROUPS, FormData, FlowTypes } from '../types';\nimport { Node, SayMsg } from '../../store/flow-definition';\nimport { renderAudioPlayer } from './audio-player';\n\nexport const say_msg: ActionConfig = {\n name: 'Say Message',\n group: ACTION_GROUPS.send,\n flowTypes: [FlowTypes.VOICE],\n render: (_node: Node, action: SayMsg) => {\n const text = (action.text || '').replace(/\\n/g, '<br>');\n return html`\n ${unsafeHTML(text)}\n ${action.audio_url\n ? html`<div style=\"margin-top: 0.5em;\">\n ${renderAudioPlayer(action.audio_url)}\n </div>`\n : null}\n `;\n },\n form: {\n text: {\n type: 'textarea',\n label: 'Message',\n required: true,\n evaluated: true,\n placeholder: 'Enter message to speak...',\n minHeight: 80\n },\n audio_url: {\n type: 'media',\n label: 'Recording',\n required: false,\n accept: 'audio/*',\n optionalLink: 'Add a recording'\n }\n },\n layout: ['text', 'audio_url'],\n toFormData: (action: SayMsg) => {\n return {\n uuid: action.uuid,\n text: action.text || '',\n audio_url: action.audio_url || ''\n };\n },\n fromFormData: (data: FormData) => {\n const result: any = {\n uuid: data.uuid,\n type: 'say_msg',\n text: data.text || ''\n };\n if (data.audio_url && data.audio_url.trim() !== '') {\n result.audio_url = data.audio_url.trim();\n }\n return result as SayMsg;\n },\n sanitize: (formData: FormData): void => {\n if (formData.text && typeof formData.text === 'string') {\n formData.text = formData.text.trim();\n }\n },\n localizable: ['text', 'audio_url'],\n toLocalizationFormData: (\n action: SayMsg,\n localization: Record<string, any>\n ) => {\n const formData: FormData = {\n uuid: action.uuid\n };\n\n if (localization.text && Array.isArray(localization.text)) {\n formData.text = localization.text[0] || '';\n } else {\n formData.text = '';\n }\n\n if (localization.audio_url && Array.isArray(localization.audio_url)) {\n formData.audio_url = localization.audio_url[0] || '';\n } else {\n formData.audio_url = '';\n }\n\n return formData;\n },\n fromLocalizationFormData: (formData: FormData, action: SayMsg) => {\n const localization: Record<string, any> = {};\n\n if (formData.text && formData.text.trim() !== '') {\n if (formData.text !== action.text) {\n localization.text = [formData.text];\n }\n }\n\n if (formData.audio_url && formData.audio_url.trim() !== '') {\n if (formData.audio_url !== action.audio_url) {\n localization.audio_url = [formData.audio_url];\n }\n }\n\n return localization;\n }\n};\n"]}
|
|
@@ -18,6 +18,7 @@ import { remove_contact_groups } from './actions/remove_contact_groups';
|
|
|
18
18
|
import { request_optin } from './actions/request_optin';
|
|
19
19
|
import { say_msg } from './actions/say_msg';
|
|
20
20
|
import { play_audio } from './actions/play_audio';
|
|
21
|
+
import { enter_flow } from './actions/enter_flow';
|
|
21
22
|
// Import all node configurations
|
|
22
23
|
import { execute_actions } from './nodes/execute_actions';
|
|
23
24
|
import { split_by_airtime } from './nodes/split_by_airtime';
|
|
@@ -28,11 +29,14 @@ import { split_by_random } from './nodes/split_by_random';
|
|
|
28
29
|
import { split_by_run_result } from './nodes/split_by_run_result';
|
|
29
30
|
import { split_by_scheme } from './nodes/split_by_scheme';
|
|
30
31
|
import { split_by_subflow } from './nodes/split_by_subflow';
|
|
32
|
+
import { terminal } from './nodes/terminal';
|
|
31
33
|
import { split_by_ticket } from './nodes/split_by_ticket';
|
|
32
34
|
import { split_by_webhook } from './nodes/split_by_webhook';
|
|
33
35
|
import { split_by_resthook } from './nodes/split_by_resthook';
|
|
34
36
|
import { split_by_llm } from './nodes/split_by_llm';
|
|
35
37
|
import { split_by_llm_categorize } from './nodes/split_by_llm_categorize';
|
|
38
|
+
import { wait_for_audio } from './nodes/wait_for_audio';
|
|
39
|
+
import { wait_for_dial } from './nodes/wait_for_dial';
|
|
36
40
|
import { wait_for_digits } from './nodes/wait_for_digits';
|
|
37
41
|
import { wait_for_menu } from './nodes/wait_for_menu';
|
|
38
42
|
import { wait_for_response } from './nodes/wait_for_response';
|
|
@@ -53,7 +57,8 @@ export const ACTION_CONFIG = registerConfigWithAliases({
|
|
|
53
57
|
set_contact_status,
|
|
54
58
|
add_contact_urn,
|
|
55
59
|
add_input_labels,
|
|
56
|
-
request_optin
|
|
60
|
+
request_optin,
|
|
61
|
+
enter_flow
|
|
57
62
|
});
|
|
58
63
|
// Helper to register a config and its aliases
|
|
59
64
|
function registerConfigWithAliases(config) {
|
|
@@ -82,9 +87,12 @@ export const NODE_CONFIG = registerConfigWithAliases({
|
|
|
82
87
|
split_by_ticket,
|
|
83
88
|
split_by_webhook,
|
|
84
89
|
split_by_resthook,
|
|
85
|
-
wait_for_digits,
|
|
86
90
|
wait_for_menu,
|
|
91
|
+
wait_for_digits,
|
|
92
|
+
wait_for_audio,
|
|
93
|
+
wait_for_dial,
|
|
87
94
|
wait_for_response,
|
|
88
|
-
split_by_airtime
|
|
95
|
+
split_by_airtime,
|
|
96
|
+
terminal // Temporary: legacy support for terminal nodes (see AppState.ts)
|
|
89
97
|
});
|
|
90
98
|
//# sourceMappingURL=config.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.js","sourceRoot":"","sources":["../../../src/flow/config.ts"],"names":[],"mappings":"AAAA,oCAAoC;AACpC,cAAc,SAAS,CAAC;AAGxB,mCAAmC;AACnC,OAAO,EAAE,gBAAgB,EAAE,MAAM,4BAA4B,CAAC;AAC9D,OAAO,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAC;AAC5D,OAAO,EAAE,iBAAiB,EAAE,MA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,uBAAuB;IACvB,eAAe;IACf,mBAAmB;IACnB,eAAe;IACf,gBAAgB;IAChB,eAAe;IACf,gBAAgB;IAChB,iBAAiB;IACjB,aAAa;IACb,eAAe;IACf,cAAc;IACd,aAAa;IACb,iBAAiB;IACjB,gBAAgB;IAChB,QAAQ,CAAC,iEAAiE;CAC3E,CAAC,CAAC","sourcesContent":["// Re-export all types and utilities\nexport * from './types';\nimport type { ActionConfig, NodeConfig } from './types';\n\n// Import all action configurations\nimport { add_input_labels } from './actions/add_input_labels';\nimport { add_contact_urn } from './actions/add_contact_urn';\nimport { set_contact_field } from './actions/set_contact_field';\nimport { set_contact_channel } from './actions/set_contact_channel';\nimport { set_contact_language } from './actions/set_contact_language';\nimport { set_contact_status } from './actions/set_contact_status';\nimport { send_broadcast } from './actions/send_broadcast';\nimport { set_run_result } from './actions/set_run_result';\nimport { send_msg } from './actions/send_msg';\nimport { send_email } from './actions/send_email';\nimport { start_session } from './actions/start_session';\nimport { set_contact_name } from './actions/set_contact_name';\nimport { add_contact_groups } from './actions/add_contact_groups';\nimport { remove_contact_groups } from './actions/remove_contact_groups';\nimport { request_optin } from './actions/request_optin';\nimport { say_msg } from './actions/say_msg';\nimport { play_audio } from './actions/play_audio';\nimport { enter_flow } from './actions/enter_flow';\n\n// Import all node configurations\nimport { execute_actions } from './nodes/execute_actions';\nimport { split_by_airtime } from './nodes/split_by_airtime';\nimport { split_by_contact_field } from './nodes/split_by_contact_field';\nimport { split_by_expression } from './nodes/split_by_expression';\nimport { split_by_groups } from './nodes/split_by_groups';\nimport { split_by_random } from './nodes/split_by_random';\nimport { split_by_run_result } from './nodes/split_by_run_result';\nimport { split_by_scheme } from './nodes/split_by_scheme';\nimport { split_by_subflow } from './nodes/split_by_subflow';\nimport { terminal } from './nodes/terminal';\nimport { split_by_ticket } from './nodes/split_by_ticket';\nimport { split_by_webhook } from './nodes/split_by_webhook';\nimport { split_by_resthook } from './nodes/split_by_resthook';\nimport { split_by_llm } from './nodes/split_by_llm';\nimport { split_by_llm_categorize } from './nodes/split_by_llm_categorize';\nimport { wait_for_audio } from './nodes/wait_for_audio';\nimport { wait_for_dial } from './nodes/wait_for_dial';\nimport { wait_for_digits } from './nodes/wait_for_digits';\nimport { wait_for_menu } from './nodes/wait_for_menu';\nimport { wait_for_response } from './nodes/wait_for_response';\n\nexport const ACTION_CONFIG: {\n [key: string]: ActionConfig;\n} = registerConfigWithAliases({\n say_msg,\n play_audio,\n set_contact_field,\n send_broadcast,\n set_run_result,\n send_msg,\n send_email,\n start_session,\n set_contact_name,\n add_contact_groups,\n remove_contact_groups,\n set_contact_channel,\n set_contact_language,\n set_contact_status,\n add_contact_urn,\n add_input_labels,\n request_optin,\n enter_flow\n});\n\n// Helper to register a config and its aliases\nfunction registerConfigWithAliases<T extends NodeConfig | ActionConfig>(\n config: Record<string, T>\n): Record<string, T> {\n const result = { ...config };\n\n // Register aliases for each config\n Object.values(config).forEach((cfg) => {\n if (cfg.aliases) {\n cfg.aliases.forEach((alias) => {\n result[alias] = cfg;\n });\n }\n });\n\n return result;\n}\n\nexport const NODE_CONFIG: {\n [key: string]: NodeConfig;\n} = registerConfigWithAliases({\n execute_actions,\n split_by_contact_field,\n split_by_expression,\n split_by_groups,\n split_by_llm,\n split_by_llm_categorize,\n split_by_random,\n split_by_run_result,\n split_by_scheme,\n split_by_subflow,\n split_by_ticket,\n split_by_webhook,\n split_by_resthook,\n wait_for_menu,\n wait_for_digits,\n wait_for_audio,\n wait_for_dial,\n wait_for_response,\n split_by_airtime,\n terminal // Temporary: legacy support for terminal nodes (see AppState.ts)\n});\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shared-rules.js","sourceRoot":"","sources":["../../../../src/flow/nodes/shared-rules.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AACjD,OAAO,EAAE,2BAA2B,EAAE,MAAM,aAAa,CAAC;AAG1D;;;GAGG;AACH,MAAM,CA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AgB;IACtB,QAAQ;IACR,SAAS,EAAE,MAAM;IACjB,QAAQ,EAAE,CAAC;IACX,QAAQ,EAAE,GAAG;IACb,QAAQ,EAAE,IAAI;IACd,iBAAiB,EAAE,IAAI;IACvB,WAAW,EAAE,eAAe;IAC5B,YAAY,EAAE,2BAA2B,EAAE;IAC3C,UAAU,EAAE;QACV,GAAG,qBAAqB,EAAE;QAC1B,QAAQ,EAAE;YACR,GAAG,qBAAqB,EAAE,CAAC,QAAQ;YACnC,OAAO,EAAE,eAAe;SACzB;KACF;CACF,CAAC,CAAC","sourcesContent":["import { getOperatorConfig } from '../operators';\nimport { generateDefaultCategoryName } from '../../utils';\nimport { FormData } from '../types';\n\n/**\n * Shared helper function to get operator value from various formats.\n * Handles string, object, and array formats that can come from the form system.\n */\nexport const getOperatorValue = (operator: any): string => {\n if (typeof operator === 'string') {\n return operator.trim();\n } else if (Array.isArray(operator) && operator.length > 0) {\n const firstOperator = operator[0];\n if (\n firstOperator &&\n typeof firstOperator === 'object' &&\n firstOperator.value\n ) {\n return firstOperator.value.trim();\n }\n } else if (operator && typeof operator === 'object' && operator.value) {\n return operator.value.trim();\n }\n return '';\n};\n\n/**\n * Shared isEmptyItem function for rules array.\n * Determines if a rule item is considered empty and should be filtered out.\n */\nexport const isEmptyRuleItem = (item: any): boolean => {\n // Check if operator and category are provided\n const operatorValue = getOperatorValue(item.operator);\n if (!operatorValue || !item.category || item.category.trim() === '') {\n return true;\n }\n\n // Check if value is required based on operator configuration\n const operatorConfig = getOperatorConfig(operatorValue);\n if (operatorConfig && operatorConfig.operands === 1) {\n return !item.value1 || item.value1.trim() === '';\n } else if (operatorConfig && operatorConfig.operands === 2) {\n return (\n !item.value1 ||\n item.value1.trim() === '' ||\n !item.value2 ||\n item.value2.trim() === ''\n );\n }\n\n return false;\n};\n\n/**\n * Shared onItemChange function for rules array.\n * Handles auto-updating category names based on operator and value changes.\n */\nexport const createRuleItemChangeHandler = () => {\n return (itemIndex: number, field: string, value: any, allItems: any[]) => {\n const updatedItems = [...allItems];\n const item = { ...updatedItems[itemIndex] };\n\n // Update the changed field\n item[field] = value;\n\n // Get operator values (before and after the change)\n const oldItem = allItems[itemIndex] || {};\n const oldOperatorValue =\n field === 'operator'\n ? getOperatorValue(oldItem.operator)\n : getOperatorValue(item.operator);\n const newOperatorValue = getOperatorValue(item.operator);\n\n // Calculate what the default category name should be before the change\n const oldDefaultCategory = generateDefaultCategoryName(\n oldOperatorValue,\n getOperatorConfig,\n field === 'value1' ? oldItem.value1 : item.value1,\n field === 'value2' ? oldItem.value2 : item.value2\n );\n\n // Calculate what the new default category name should be after the change\n const newDefaultCategory = generateDefaultCategoryName(\n newOperatorValue,\n getOperatorConfig,\n item.value1,\n item.value2\n );\n\n // Determine if we should auto-update the category\n const shouldUpdateCategory =\n !item.category ||\n item.category.trim() === '' ||\n item.category === oldDefaultCategory;\n\n // Auto-populate or update category if conditions are met\n if (shouldUpdateCategory && newDefaultCategory) {\n item.category = newDefaultCategory;\n }\n\n updatedItems[itemIndex] = item;\n return updatedItems;\n };\n};\n\n/**\n * Shared visibility condition for value1 field.\n */\nexport const value1VisibilityCondition = (formData: Record<string, any>) => {\n const operatorValue = getOperatorValue(formData.operator);\n const operatorConfig = getOperatorConfig(operatorValue);\n return operatorConfig ? operatorConfig.operands >= 1 : true;\n};\n\n/**\n * Shared visibility condition for value2 field.\n */\nexport const value2VisibilityCondition = (formData: Record<string, any>) => {\n const operatorValue = getOperatorValue(formData.operator);\n const operatorConfig = getOperatorConfig(operatorValue);\n return operatorConfig ? operatorConfig.operands === 2 : false;\n};\n\n/**\n * Shared item configuration for rules array.\n * This defines the operator, value1, value2, and category fields.\n */\nexport const createRulesItemConfig = () => ({\n operator: {\n type: 'select' as const,\n required: true,\n multi: false,\n options: [], // Will be set by the caller\n flavor: 'xsmall' as const,\n width: '200px'\n },\n value1: {\n type: 'text' as const,\n flavor: 'xsmall' as const,\n conditions: {\n visible: value1VisibilityCondition\n }\n },\n value2: {\n type: 'text' as const,\n flavor: 'xsmall' as const,\n conditions: {\n visible: value2VisibilityCondition\n }\n },\n category: {\n type: 'text' as const,\n placeholder: 'Category',\n required: true,\n maxWidth: '120px',\n flavor: 'xsmall' as const\n }\n});\n\n/**\n * Shared function to extract rules from form data.\n * Filters and transforms form rules into the format expected by createRulesRouter.\n */\nexport const extractUserRules = (formData: FormData) => {\n return (formData.rules || [])\n .filter((rule: any) => {\n const operatorValue = getOperatorValue(rule?.operator);\n if (\n !operatorValue ||\n !rule?.category ||\n operatorValue === '' ||\n rule.category.trim() === ''\n ) {\n return false;\n }\n\n const operatorConfig = getOperatorConfig(operatorValue);\n if (operatorConfig && operatorConfig.operands === 1) {\n return rule?.value1 && rule.value1.trim() !== '';\n } else if (operatorConfig && operatorConfig.operands === 2) {\n return (\n rule?.value1 &&\n rule.value1.trim() !== '' &&\n rule?.value2 &&\n rule.value2.trim() !== ''\n );\n }\n\n return true;\n })\n .map((rule: any) => {\n const operatorValue = getOperatorValue(rule.operator);\n const operatorConfig = getOperatorConfig(operatorValue);\n\n let value = '';\n\n if (operatorConfig && operatorConfig.operands === 1) {\n value = rule.value1 ? rule.value1.trim() : '';\n } else if (operatorConfig && operatorConfig.operands === 2) {\n const val1 = rule.value1 ? rule.value1.trim() : '';\n const val2 = rule.value2 ? rule.value2.trim() : '';\n value = `${val1} ${val2}`.trim();\n } else {\n value = '';\n }\n\n return {\n operator: operatorValue,\n value: value,\n category: rule.category.trim()\n };\n });\n};\n\n/**\n * Shared function to transform router cases to form rules.\n * Converts node router cases back into the form data structure.\n */\nexport const casesToFormRules = (node: any) => {\n const rules = [];\n if (node.router?.cases && node.router?.categories) {\n node.router.cases.forEach((case_: any) => {\n // Find the category for this case\n const category = node.router!.categories.find(\n (cat: any) => cat.uuid === case_.category_uuid\n );\n\n // Skip system categories\n if (category && !isSystemCategory(category.name)) {\n // Handle different operator types\n const operatorConfig = getOperatorConfig(case_.type);\n const operatorDisplayName = operatorConfig\n ? operatorConfig.name\n : case_.type;\n let value1 = '';\n let value2 = '';\n\n if (operatorConfig && operatorConfig.operands === 0) {\n value1 = '';\n value2 = '';\n } else if (operatorConfig && operatorConfig.operands === 1) {\n value1 = case_.arguments.join(' ');\n value2 = '';\n } else if (operatorConfig && operatorConfig.operands === 2) {\n value1 = case_.arguments[0] || '';\n value2 = case_.arguments[1] || '';\n } else {\n value1 = case_.arguments.join(' ');\n value2 = '';\n }\n\n rules.push({\n operator: { value: case_.type, name: operatorDisplayName },\n value1: value1,\n value2: value2,\n category: category.name\n });\n }\n });\n }\n return rules;\n};\n\n/**\n * Helper to check if a category is a system category\n */\nfunction isSystemCategory(categoryName: string): boolean {\n return ['No Response', 'Other', 'All Responses', 'Timeout'].includes(\n categoryName\n );\n}\n\n/**\n * Creates a complete rules array configuration for forms.\n * This is the shared configuration used by both wait_for_response and split_by_expression.\n *\n * @param operatorOptions - The operator options to use (from operatorsToSelectOptions)\n * @param helpText - The help text to display for the rules array\n * @returns A complete array field configuration object\n */\nexport const createRulesArrayConfig = (\n operatorOptions: any[],\n helpText: string = 'Define rules to categorize responses'\n) => ({\n type: 'array' as const,\n helpText,\n itemLabel: 'Rule',\n minItems: 0,\n maxItems: 100,\n sortable: true,\n maintainEmptyItem: true,\n isEmptyItem: isEmptyRuleItem,\n onItemChange: createRuleItemChangeHandler(),\n itemConfig: {\n ...createRulesItemConfig(),\n operator: {\n ...createRulesItemConfig().operator,\n options: operatorOptions\n }\n }\n});\n"]}
|
|
1
|
+
{"version":3,"file":"shared-rules.js","sourceRoot":"","sources":["../../../../src/flow/nodes/shared-rules.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AACjD,OAAO,EAAE,2BAA2B,EAAE,MAAM,aAAa,CAAC;AAG1D;;;GAGG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,QAAa,EAAU,EAAE;IACxD,IAAI,OAAO,QAAQ,KAAK,QAAQ,EAAE,CAAC;QACjC,OA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,IAAI;IACd,iBAAiB,EAAE,IAAI;IACvB,WAAW,EAAE,eAAe;IAC5B,YAAY,EAAE,2BAA2B,EAAE;IAC3C,UAAU,EAAE;QACV,GAAG,qBAAqB,EAAE;QAC1B,QAAQ,EAAE;YACR,GAAG,qBAAqB,EAAE,CAAC,QAAQ;YACnC,OAAO,EAAE,eAAe;SACzB;KACF;CACF,CAAC,CAAC","sourcesContent":["import { getOperatorConfig } from '../operators';\nimport { generateDefaultCategoryName } from '../../utils';\nimport { FormData } from '../types';\n\n/**\n * Shared helper function to get operator value from various formats.\n * Handles string, object, and array formats that can come from the form system.\n */\nexport const getOperatorValue = (operator: any): string => {\n if (typeof operator === 'string') {\n return operator.trim();\n } else if (Array.isArray(operator) && operator.length > 0) {\n const firstOperator = operator[0];\n if (\n firstOperator &&\n typeof firstOperator === 'object' &&\n firstOperator.value\n ) {\n return firstOperator.value.trim();\n }\n } else if (operator && typeof operator === 'object' && operator.value) {\n return operator.value.trim();\n }\n return '';\n};\n\n/**\n * Shared isEmptyItem function for rules array.\n * Determines if a rule item is considered empty and should be filtered out.\n */\nexport const isEmptyRuleItem = (item: any): boolean => {\n // Check if operator and category are provided\n const operatorValue = getOperatorValue(item.operator);\n if (!operatorValue || !item.category || item.category.trim() === '') {\n return true;\n }\n\n // Check if value is required based on operator configuration\n const operatorConfig = getOperatorConfig(operatorValue);\n if (operatorConfig && operatorConfig.operands === 1) {\n return !item.value1 || item.value1.trim() === '';\n } else if (operatorConfig && operatorConfig.operands === 2) {\n return (\n !item.value1 ||\n item.value1.trim() === '' ||\n !item.value2 ||\n item.value2.trim() === ''\n );\n }\n\n return false;\n};\n\n/**\n * Shared onItemChange function for rules array.\n * Handles auto-updating category names based on operator and value changes.\n */\nexport const createRuleItemChangeHandler = () => {\n return (itemIndex: number, field: string, value: any, allItems: any[]) => {\n const updatedItems = [...allItems];\n const item = { ...updatedItems[itemIndex] };\n\n // Update the changed field\n item[field] = value;\n\n // Get operator values (before and after the change)\n const oldItem = allItems[itemIndex] || {};\n const oldOperatorValue =\n field === 'operator'\n ? getOperatorValue(oldItem.operator)\n : getOperatorValue(item.operator);\n const newOperatorValue = getOperatorValue(item.operator);\n\n // Calculate what the default category name should be before the change\n const oldDefaultCategory = generateDefaultCategoryName(\n oldOperatorValue,\n getOperatorConfig,\n field === 'value1' ? oldItem.value1 : item.value1,\n field === 'value2' ? oldItem.value2 : item.value2\n );\n\n // Calculate what the new default category name should be after the change\n const newDefaultCategory = generateDefaultCategoryName(\n newOperatorValue,\n getOperatorConfig,\n item.value1,\n item.value2\n );\n\n // Determine if we should auto-update the category\n const shouldUpdateCategory =\n !item.category ||\n item.category.trim() === '' ||\n item.category === oldDefaultCategory;\n\n // Auto-populate or update category if conditions are met\n if (shouldUpdateCategory && newDefaultCategory) {\n item.category = newDefaultCategory;\n }\n\n updatedItems[itemIndex] = item;\n return updatedItems;\n };\n};\n\n/**\n * Shared visibility condition for value1 field.\n */\nexport const value1VisibilityCondition = (formData: Record<string, any>) => {\n const operatorValue = getOperatorValue(formData.operator);\n const operatorConfig = getOperatorConfig(operatorValue);\n return operatorConfig ? operatorConfig.operands >= 1 : true;\n};\n\n/**\n * Shared visibility condition for value2 field.\n */\nexport const value2VisibilityCondition = (formData: Record<string, any>) => {\n const operatorValue = getOperatorValue(formData.operator);\n const operatorConfig = getOperatorConfig(operatorValue);\n return operatorConfig ? operatorConfig.operands === 2 : false;\n};\n\n/**\n * Shared item configuration for rules array.\n * This defines the operator, value1, value2, and category fields.\n */\nexport const createRulesItemConfig = () => ({\n operator: {\n type: 'select' as const,\n required: true,\n multi: false,\n options: [], // Will be set by the caller\n flavor: 'xsmall' as const,\n width: '220px'\n },\n value1: {\n type: 'text' as const,\n flavor: 'xsmall' as const,\n conditions: {\n visible: value1VisibilityCondition\n }\n },\n value2: {\n type: 'text' as const,\n flavor: 'xsmall' as const,\n conditions: {\n visible: value2VisibilityCondition\n }\n },\n category: {\n type: 'text' as const,\n placeholder: 'Category',\n required: true,\n maxWidth: '120px',\n flavor: 'xsmall' as const\n }\n});\n\n/**\n * Shared function to extract rules from form data.\n * Filters and transforms form rules into the format expected by createRulesRouter.\n */\nexport const extractUserRules = (formData: FormData) => {\n return (formData.rules || [])\n .filter((rule: any) => {\n const operatorValue = getOperatorValue(rule?.operator);\n if (\n !operatorValue ||\n !rule?.category ||\n operatorValue === '' ||\n rule.category.trim() === ''\n ) {\n return false;\n }\n\n const operatorConfig = getOperatorConfig(operatorValue);\n if (operatorConfig && operatorConfig.operands === 1) {\n return rule?.value1 && rule.value1.trim() !== '';\n } else if (operatorConfig && operatorConfig.operands === 2) {\n return (\n rule?.value1 &&\n rule.value1.trim() !== '' &&\n rule?.value2 &&\n rule.value2.trim() !== ''\n );\n }\n\n return true;\n })\n .map((rule: any) => {\n const operatorValue = getOperatorValue(rule.operator);\n const operatorConfig = getOperatorConfig(operatorValue);\n\n let value = '';\n\n if (operatorConfig && operatorConfig.operands === 1) {\n value = rule.value1 ? rule.value1.trim() : '';\n } else if (operatorConfig && operatorConfig.operands === 2) {\n const val1 = rule.value1 ? rule.value1.trim() : '';\n const val2 = rule.value2 ? rule.value2.trim() : '';\n value = `${val1} ${val2}`.trim();\n } else {\n value = '';\n }\n\n return {\n operator: operatorValue,\n value: value,\n category: rule.category.trim()\n };\n });\n};\n\n/**\n * Shared function to transform router cases to form rules.\n * Converts node router cases back into the form data structure.\n */\nexport const casesToFormRules = (node: any) => {\n const rules = [];\n if (node.router?.cases && node.router?.categories) {\n node.router.cases.forEach((case_: any) => {\n // Find the category for this case\n const category = node.router!.categories.find(\n (cat: any) => cat.uuid === case_.category_uuid\n );\n\n // Skip system categories\n if (category && !isSystemCategory(category.name)) {\n // Handle different operator types\n const operatorConfig = getOperatorConfig(case_.type);\n const operatorDisplayName = operatorConfig\n ? operatorConfig.name\n : case_.type;\n let value1 = '';\n let value2 = '';\n\n if (operatorConfig && operatorConfig.operands === 0) {\n value1 = '';\n value2 = '';\n } else if (operatorConfig && operatorConfig.operands === 1) {\n value1 = case_.arguments.join(' ');\n value2 = '';\n } else if (operatorConfig && operatorConfig.operands === 2) {\n value1 = case_.arguments[0] || '';\n value2 = case_.arguments[1] || '';\n } else {\n value1 = case_.arguments.join(' ');\n value2 = '';\n }\n\n rules.push({\n operator: { value: case_.type, name: operatorDisplayName },\n value1: value1,\n value2: value2,\n category: category.name\n });\n }\n });\n }\n return rules;\n};\n\n/**\n * Helper to check if a category is a system category\n */\nfunction isSystemCategory(categoryName: string): boolean {\n return ['No Response', 'Other', 'All Responses', 'Timeout'].includes(\n categoryName\n );\n}\n\n/**\n * Creates a complete rules array configuration for forms.\n * This is the shared configuration used by both wait_for_response and split_by_expression.\n *\n * @param operatorOptions - The operator options to use (from operatorsToSelectOptions)\n * @param helpText - The help text to display for the rules array\n * @returns A complete array field configuration object\n */\nexport const createRulesArrayConfig = (\n operatorOptions: any[],\n helpText: string = 'Define rules to categorize responses'\n) => ({\n type: 'array' as const,\n helpText,\n itemLabel: 'Rule',\n minItems: 0,\n maxItems: 100,\n sortable: true,\n maintainEmptyItem: true,\n isEmptyItem: isEmptyRuleItem,\n onItemChange: createRuleItemChangeHandler(),\n itemConfig: {\n ...createRulesItemConfig(),\n operator: {\n ...createRulesItemConfig().operator,\n options: operatorOptions\n }\n }\n});\n"]}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
// Temporary: Legacy support for terminal nodes (nodes with a terminal action
|
|
2
|
+
// like enter_flow with terminal: true). This node type and its reclassification
|
|
3
|
+
// logic in AppState.ts can be removed once we stop supporting terminal nodes.
|
|
4
|
+
export const terminal = {
|
|
5
|
+
type: 'terminal'
|
|
6
|
+
};
|
|
7
|
+
//# sourceMappingURL=terminal.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"terminal.js","sourceRoot":"","sources":["../../../../src/flow/nodes/terminal.ts"],"names":[],"mappings":"AAAA,6EAA6E;AAC7E,gFAAgF;AAChF,8EAA8E;AAI9E,MAAM,CAAC,MAAM,QAAQ,GAAe;IAClC,IAAI,EAAE,UAAU;CACjB,CAAC","sourcesContent":["// Temporary: Legacy support for terminal nodes (nodes with a terminal action\n// like enter_flow with terminal: true). This node type and its reclassification\n// logic in AppState.ts can be removed once we stop supporting terminal nodes.\n\nimport { NodeConfig } from '../types';\n\nexport const terminal: NodeConfig = {\n type: 'terminal'\n};\n"]}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import { SPLIT_GROUPS, FlowTypes } from '../types';
|
|
2
|
+
import { generateUUID } from '../../utils';
|
|
3
|
+
import { categoriesToLocalizationFormData, localizationFormDataToCategories } from './shared';
|
|
4
|
+
export const wait_for_audio = {
|
|
5
|
+
type: 'wait_for_audio',
|
|
6
|
+
name: 'Make Recording',
|
|
7
|
+
group: SPLIT_GROUPS.wait,
|
|
8
|
+
flowTypes: [FlowTypes.VOICE],
|
|
9
|
+
form: {
|
|
10
|
+
result_name: {
|
|
11
|
+
type: 'text',
|
|
12
|
+
label: 'Result Name',
|
|
13
|
+
required: false,
|
|
14
|
+
placeholder: '(optional)',
|
|
15
|
+
helpText: 'The name to use to reference this result in the flow'
|
|
16
|
+
}
|
|
17
|
+
},
|
|
18
|
+
layout: ['result_name'],
|
|
19
|
+
toFormData: (node) => {
|
|
20
|
+
var _a;
|
|
21
|
+
return {
|
|
22
|
+
uuid: node.uuid,
|
|
23
|
+
result_name: ((_a = node.router) === null || _a === void 0 ? void 0 : _a.result_name) || ''
|
|
24
|
+
};
|
|
25
|
+
},
|
|
26
|
+
fromFormData: (formData, originalNode) => {
|
|
27
|
+
var _a;
|
|
28
|
+
// Preserve or create "All Responses" category
|
|
29
|
+
const existingCategories = ((_a = originalNode.router) === null || _a === void 0 ? void 0 : _a.categories) || [];
|
|
30
|
+
const existingExits = originalNode.exits || [];
|
|
31
|
+
let allResponsesCategory = existingCategories.find((cat) => cat.name === 'All Responses');
|
|
32
|
+
let allResponsesExit;
|
|
33
|
+
if (allResponsesCategory) {
|
|
34
|
+
allResponsesExit = existingExits.find((exit) => exit.uuid === allResponsesCategory.exit_uuid) || {
|
|
35
|
+
uuid: allResponsesCategory.exit_uuid,
|
|
36
|
+
destination_uuid: null
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
else {
|
|
40
|
+
const exitUuid = generateUUID();
|
|
41
|
+
allResponsesCategory = {
|
|
42
|
+
uuid: generateUUID(),
|
|
43
|
+
name: 'All Responses',
|
|
44
|
+
exit_uuid: exitUuid
|
|
45
|
+
};
|
|
46
|
+
allResponsesExit = {
|
|
47
|
+
uuid: exitUuid,
|
|
48
|
+
destination_uuid: null
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
const router = {
|
|
52
|
+
type: 'switch',
|
|
53
|
+
operand: '@input',
|
|
54
|
+
default_category_uuid: allResponsesCategory.uuid,
|
|
55
|
+
cases: [],
|
|
56
|
+
categories: [allResponsesCategory],
|
|
57
|
+
wait: {
|
|
58
|
+
type: 'msg',
|
|
59
|
+
hint: {
|
|
60
|
+
type: 'audio'
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
};
|
|
64
|
+
if (formData.result_name && formData.result_name.trim() !== '') {
|
|
65
|
+
router.result_name = formData.result_name.trim();
|
|
66
|
+
}
|
|
67
|
+
return {
|
|
68
|
+
...originalNode,
|
|
69
|
+
router,
|
|
70
|
+
exits: [allResponsesExit]
|
|
71
|
+
};
|
|
72
|
+
},
|
|
73
|
+
localizable: 'categories',
|
|
74
|
+
toLocalizationFormData: categoriesToLocalizationFormData,
|
|
75
|
+
fromLocalizationFormData: localizationFormDataToCategories
|
|
76
|
+
};
|
|
77
|
+
//# sourceMappingURL=wait_for_audio.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"wait_for_audio.js","sourceRoot":"","sources":["../../../../src/flow/nodes/wait_for_audio.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAwB,SAAS,EAAE,MAAM,UAAU,CAAC;AAEzE,OAAO,EAAE,YAAY,E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S;gBACpC,gBAAgB,EAAE,IAAI;aACvB,CAAC;QACJ,CAAC;aAAM,CAAC;YACN,MAAM,QAAQ,GAAG,YAAY,EAAE,CAAC;YAChC,oBAAoB,GAAG;gBACrB,IAAI,EAAE,YAAY,EAAE;gBACpB,IAAI,EAAE,eAAe;gBACrB,SAAS,EAAE,QAAQ;aACpB,CAAC;YACF,gBAAgB,GAAG;gBACjB,IAAI,EAAE,QAAQ;gBACd,gBAAgB,EAAE,IAAI;aACvB,CAAC;QACJ,CAAC;QAED,MAAM,MAAM,GAAQ;YAClB,IAAI,EAAE,QAAQ;YACd,OAAO,EAAE,QAAQ;YACjB,qBAAqB,EAAE,oBAAoB,CAAC,IAAI;YAChD,KAAK,EAAE,EAAE;YACT,UAAU,EAAE,CAAC,oBAAoB,CAAC;YAClC,IAAI,EAAE;gBACJ,IAAI,EAAE,KAAK;gBACX,IAAI,EAAE;oBACJ,IAAI,EAAE,OAAO;iBACd;aACF;SACF,CAAC;QAEF,IAAI,QAAQ,CAAC,WAAW,IAAI,QAAQ,CAAC,WAAW,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE,CAAC;YAC/D,MAAM,CAAC,WAAW,GAAG,QAAQ,CAAC,WAAW,CAAC,IAAI,EAAE,CAAC;QACnD,CAAC;QAED,OAAO;YACL,GAAG,YAAY;YACf,MAAM;YACN,KAAK,EAAE,CAAC,gBAAgB,CAAC;SAC1B,CAAC;IACJ,CAAC;IACD,WAAW,EAAE,YAAY;IACzB,sBAAsB,EAAE,gCAAgC;IACxD,wBAAwB,EAAE,gCAAgC;CAC3D,CAAC","sourcesContent":["import { SPLIT_GROUPS, FormData, NodeConfig, FlowTypes } from '../types';\nimport { Node, Category, Exit } from '../../store/flow-definition';\nimport { generateUUID } from '../../utils';\nimport {\n categoriesToLocalizationFormData,\n localizationFormDataToCategories\n} from './shared';\n\nexport const wait_for_audio: NodeConfig = {\n type: 'wait_for_audio',\n name: 'Make Recording',\n group: SPLIT_GROUPS.wait,\n flowTypes: [FlowTypes.VOICE],\n form: {\n result_name: {\n type: 'text',\n label: 'Result Name',\n required: false,\n placeholder: '(optional)',\n helpText: 'The name to use to reference this result in the flow'\n }\n },\n layout: ['result_name'],\n toFormData: (node: Node) => {\n return {\n uuid: node.uuid,\n result_name: node.router?.result_name || ''\n };\n },\n fromFormData: (formData: FormData, originalNode: Node): Node => {\n // Preserve or create \"All Responses\" category\n const existingCategories = originalNode.router?.categories || [];\n const existingExits = originalNode.exits || [];\n\n let allResponsesCategory = existingCategories.find(\n (cat: Category) => cat.name === 'All Responses'\n );\n\n let allResponsesExit: Exit;\n\n if (allResponsesCategory) {\n allResponsesExit = existingExits.find(\n (exit: Exit) => exit.uuid === allResponsesCategory!.exit_uuid\n ) || {\n uuid: allResponsesCategory.exit_uuid,\n destination_uuid: null\n };\n } else {\n const exitUuid = generateUUID();\n allResponsesCategory = {\n uuid: generateUUID(),\n name: 'All Responses',\n exit_uuid: exitUuid\n };\n allResponsesExit = {\n uuid: exitUuid,\n destination_uuid: null\n };\n }\n\n const router: any = {\n type: 'switch',\n operand: '@input',\n default_category_uuid: allResponsesCategory.uuid,\n cases: [],\n categories: [allResponsesCategory],\n wait: {\n type: 'msg',\n hint: {\n type: 'audio'\n }\n }\n };\n\n if (formData.result_name && formData.result_name.trim() !== '') {\n router.result_name = formData.result_name.trim();\n }\n\n return {\n ...originalNode,\n router,\n exits: [allResponsesExit]\n };\n },\n localizable: 'categories',\n toLocalizationFormData: categoriesToLocalizationFormData,\n fromLocalizationFormData: localizationFormDataToCategories\n};\n"]}
|
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
import { SPLIT_GROUPS, FlowTypes } from '../types';
|
|
2
|
+
import { generateUUID } from '../../utils';
|
|
3
|
+
import { resultNameField, categoriesToLocalizationFormData, localizationFormDataToCategories } from './shared';
|
|
4
|
+
const DIAL_CATEGORIES = ['Answered', 'No Answer', 'Busy', 'Failed'];
|
|
5
|
+
const DIAL_CASES = [
|
|
6
|
+
{ type: 'has_only_text', arguments: ['answered'], categoryName: 'Answered' },
|
|
7
|
+
{
|
|
8
|
+
type: 'has_only_text',
|
|
9
|
+
arguments: ['no_answer'],
|
|
10
|
+
categoryName: 'No Answer'
|
|
11
|
+
},
|
|
12
|
+
{ type: 'has_only_text', arguments: ['busy'], categoryName: 'Busy' }
|
|
13
|
+
];
|
|
14
|
+
export const wait_for_dial = {
|
|
15
|
+
type: 'wait_for_dial',
|
|
16
|
+
name: 'Redirect Call',
|
|
17
|
+
group: SPLIT_GROUPS.wait,
|
|
18
|
+
flowTypes: [FlowTypes.VOICE],
|
|
19
|
+
router: {
|
|
20
|
+
type: 'switch',
|
|
21
|
+
defaultCategory: 'Failed',
|
|
22
|
+
rules: DIAL_CASES.map((c) => ({
|
|
23
|
+
type: c.type,
|
|
24
|
+
arguments: c.arguments,
|
|
25
|
+
categoryName: c.categoryName
|
|
26
|
+
}))
|
|
27
|
+
},
|
|
28
|
+
form: {
|
|
29
|
+
phone: {
|
|
30
|
+
type: 'text',
|
|
31
|
+
label: 'Phone Number',
|
|
32
|
+
required: true,
|
|
33
|
+
evaluated: true,
|
|
34
|
+
placeholder: 'Phone number or expression'
|
|
35
|
+
},
|
|
36
|
+
dial_limit_seconds: {
|
|
37
|
+
type: 'text',
|
|
38
|
+
label: 'Dial Limit (seconds)',
|
|
39
|
+
required: false,
|
|
40
|
+
placeholder: '60'
|
|
41
|
+
},
|
|
42
|
+
call_limit_seconds: {
|
|
43
|
+
type: 'text',
|
|
44
|
+
label: 'Call Limit (seconds)',
|
|
45
|
+
required: false,
|
|
46
|
+
placeholder: '7200'
|
|
47
|
+
},
|
|
48
|
+
result_name: resultNameField
|
|
49
|
+
},
|
|
50
|
+
layout: [
|
|
51
|
+
'phone',
|
|
52
|
+
{
|
|
53
|
+
type: 'row',
|
|
54
|
+
items: ['dial_limit_seconds', 'call_limit_seconds']
|
|
55
|
+
},
|
|
56
|
+
'result_name'
|
|
57
|
+
],
|
|
58
|
+
toFormData: (node) => {
|
|
59
|
+
var _a, _b;
|
|
60
|
+
const wait = (_a = node.router) === null || _a === void 0 ? void 0 : _a.wait;
|
|
61
|
+
return {
|
|
62
|
+
uuid: node.uuid,
|
|
63
|
+
phone: (wait === null || wait === void 0 ? void 0 : wait.phone) || '',
|
|
64
|
+
dial_limit_seconds: (wait === null || wait === void 0 ? void 0 : wait.dial_limit_seconds)
|
|
65
|
+
? String(wait.dial_limit_seconds)
|
|
66
|
+
: '',
|
|
67
|
+
call_limit_seconds: (wait === null || wait === void 0 ? void 0 : wait.call_limit_seconds)
|
|
68
|
+
? String(wait.call_limit_seconds)
|
|
69
|
+
: '',
|
|
70
|
+
result_name: ((_b = node.router) === null || _b === void 0 ? void 0 : _b.result_name) || ''
|
|
71
|
+
};
|
|
72
|
+
},
|
|
73
|
+
fromFormData: (formData, originalNode) => {
|
|
74
|
+
var _a, _b;
|
|
75
|
+
const existingCategories = ((_a = originalNode.router) === null || _a === void 0 ? void 0 : _a.categories) || [];
|
|
76
|
+
const existingExits = originalNode.exits || [];
|
|
77
|
+
const existingCases = ((_b = originalNode.router) === null || _b === void 0 ? void 0 : _b.cases) || [];
|
|
78
|
+
const categories = [];
|
|
79
|
+
const exits = [];
|
|
80
|
+
const cases = [];
|
|
81
|
+
// Build categories and cases for each dial outcome
|
|
82
|
+
for (const catName of DIAL_CATEGORIES) {
|
|
83
|
+
const existing = existingCategories.find((c) => c.name === catName);
|
|
84
|
+
if (existing) {
|
|
85
|
+
categories.push(existing);
|
|
86
|
+
const existingExit = existingExits.find((e) => e.uuid === existing.exit_uuid);
|
|
87
|
+
exits.push(existingExit || {
|
|
88
|
+
uuid: existing.exit_uuid,
|
|
89
|
+
destination_uuid: null
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
else {
|
|
93
|
+
const exitUuid = generateUUID();
|
|
94
|
+
categories.push({
|
|
95
|
+
uuid: generateUUID(),
|
|
96
|
+
name: catName,
|
|
97
|
+
exit_uuid: exitUuid
|
|
98
|
+
});
|
|
99
|
+
exits.push({ uuid: exitUuid, destination_uuid: null });
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
// Build cases for non-default categories
|
|
103
|
+
for (const dialCase of DIAL_CASES) {
|
|
104
|
+
const category = categories.find((c) => c.name === dialCase.categoryName);
|
|
105
|
+
if (!category)
|
|
106
|
+
continue;
|
|
107
|
+
const existingCase = existingCases.find((c) => { var _a; return c.type === dialCase.type && ((_a = c.arguments) === null || _a === void 0 ? void 0 : _a[0]) === dialCase.arguments[0]; });
|
|
108
|
+
cases.push({
|
|
109
|
+
uuid: (existingCase === null || existingCase === void 0 ? void 0 : existingCase.uuid) || generateUUID(),
|
|
110
|
+
type: dialCase.type,
|
|
111
|
+
arguments: dialCase.arguments,
|
|
112
|
+
category_uuid: category.uuid
|
|
113
|
+
});
|
|
114
|
+
}
|
|
115
|
+
const failedCategory = categories.find((c) => c.name === 'Failed');
|
|
116
|
+
// Build wait config
|
|
117
|
+
const phone = (formData.phone || '').trim();
|
|
118
|
+
const dialLimit = parseInt(formData.dial_limit_seconds, 10);
|
|
119
|
+
const callLimit = parseInt(formData.call_limit_seconds, 10);
|
|
120
|
+
const waitConfig = {
|
|
121
|
+
type: 'dial',
|
|
122
|
+
phone
|
|
123
|
+
};
|
|
124
|
+
if (!isNaN(dialLimit) && dialLimit > 0) {
|
|
125
|
+
waitConfig.dial_limit_seconds = dialLimit;
|
|
126
|
+
}
|
|
127
|
+
if (!isNaN(callLimit) && callLimit > 0) {
|
|
128
|
+
waitConfig.call_limit_seconds = callLimit;
|
|
129
|
+
}
|
|
130
|
+
const router = {
|
|
131
|
+
type: 'switch',
|
|
132
|
+
operand: '@(default(resume.dial.status, ""))',
|
|
133
|
+
default_category_uuid: failedCategory === null || failedCategory === void 0 ? void 0 : failedCategory.uuid,
|
|
134
|
+
cases,
|
|
135
|
+
categories,
|
|
136
|
+
wait: waitConfig
|
|
137
|
+
};
|
|
138
|
+
if (formData.result_name && formData.result_name.trim() !== '') {
|
|
139
|
+
router.result_name = formData.result_name.trim();
|
|
140
|
+
}
|
|
141
|
+
return {
|
|
142
|
+
...originalNode,
|
|
143
|
+
router,
|
|
144
|
+
exits
|
|
145
|
+
};
|
|
146
|
+
},
|
|
147
|
+
localizable: 'categories',
|
|
148
|
+
toLocalizationFormData: categoriesToLocalizationFormData,
|
|
149
|
+
fromLocalizationFormData: localizationFormDataToCategories
|
|
150
|
+
};
|
|
151
|
+
//# sourceMappingURL=wait_for_dial.js.map
|