@xyne/workflow-sdk 3.2.46 → 3.2.48
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/dist/agents/host-agent-step.d.ts +2 -2
- package/dist/connectors/builtin/steps/classifier-agent.step.d.ts +2 -2
- package/dist/connectors/builtin/steps/map.step.d.ts +15 -4
- package/dist/connectors/builtin/steps/map.step.d.ts.map +1 -1
- package/dist/connectors/builtin/steps/map.step.js +51 -18
- package/dist/connectors/builtin/steps/map.step.js.map +1 -1
- package/dist/connectors/builtin/steps/parallel.step.d.ts +4 -4
- package/dist/connectors/builtin/steps/wait.step.d.ts +28 -0
- package/dist/connectors/builtin/steps/wait.step.d.ts.map +1 -1
- package/dist/connectors/builtin/steps/wait.step.js +26 -1
- package/dist/connectors/builtin/steps/wait.step.js.map +1 -1
- package/dist/conversational-flow/calls.d.ts +20 -0
- package/dist/conversational-flow/calls.d.ts.map +1 -0
- package/dist/conversational-flow/calls.js +59 -0
- package/dist/conversational-flow/calls.js.map +1 -0
- package/dist/conversational-flow/conditions.d.ts +24 -0
- package/dist/conversational-flow/conditions.d.ts.map +1 -0
- package/dist/conversational-flow/conditions.js +69 -0
- package/dist/conversational-flow/conditions.js.map +1 -0
- package/dist/conversational-flow/create.d.ts +23 -18
- package/dist/conversational-flow/create.d.ts.map +1 -1
- package/dist/conversational-flow/create.js +73 -96
- package/dist/conversational-flow/create.js.map +1 -1
- package/dist/conversational-flow/edit/build.d.ts +112 -0
- package/dist/conversational-flow/edit/build.d.ts.map +1 -0
- package/dist/conversational-flow/edit/build.js +249 -0
- package/dist/conversational-flow/edit/build.js.map +1 -0
- package/dist/conversational-flow/edit/calls.d.ts +61 -0
- package/dist/conversational-flow/edit/calls.d.ts.map +1 -0
- package/dist/conversational-flow/edit/calls.js +296 -0
- package/dist/conversational-flow/edit/calls.js.map +1 -0
- package/dist/conversational-flow/edit/cases.d.ts +29 -0
- package/dist/conversational-flow/edit/cases.d.ts.map +1 -0
- package/dist/conversational-flow/edit/cases.js +83 -0
- package/dist/conversational-flow/edit/cases.js.map +1 -0
- package/dist/conversational-flow/edit/endings.d.ts +16 -0
- package/dist/conversational-flow/edit/endings.d.ts.map +1 -0
- package/dist/conversational-flow/edit/endings.js +53 -0
- package/dist/conversational-flow/edit/endings.js.map +1 -0
- package/dist/conversational-flow/edit/followups.d.ts +28 -0
- package/dist/conversational-flow/edit/followups.d.ts.map +1 -0
- package/dist/conversational-flow/edit/followups.js +103 -0
- package/dist/conversational-flow/edit/followups.js.map +1 -0
- package/dist/conversational-flow/edit/inputs.d.ts +24 -0
- package/dist/conversational-flow/edit/inputs.d.ts.map +1 -0
- package/dist/conversational-flow/edit/inputs.js +53 -0
- package/dist/conversational-flow/edit/inputs.js.map +1 -0
- package/dist/conversational-flow/edit/kinds.d.ts +29 -0
- package/dist/conversational-flow/edit/kinds.d.ts.map +1 -0
- package/dist/conversational-flow/edit/kinds.js +142 -0
- package/dist/conversational-flow/edit/kinds.js.map +1 -0
- package/dist/conversational-flow/edit/options.d.ts +68 -0
- package/dist/conversational-flow/edit/options.d.ts.map +1 -0
- package/dist/conversational-flow/edit/options.js +209 -0
- package/dist/conversational-flow/edit/options.js.map +1 -0
- package/dist/conversational-flow/edit/picklist.d.ts +28 -0
- package/dist/conversational-flow/edit/picklist.d.ts.map +1 -0
- package/dist/conversational-flow/edit/picklist.js +58 -0
- package/dist/conversational-flow/edit/picklist.js.map +1 -0
- package/dist/conversational-flow/edit/prompts.d.ts +24 -0
- package/dist/conversational-flow/edit/prompts.d.ts.map +1 -0
- package/dist/conversational-flow/edit/prompts.js +180 -0
- package/dist/conversational-flow/edit/prompts.js.map +1 -0
- package/dist/conversational-flow/edit/routers.d.ts +65 -0
- package/dist/conversational-flow/edit/routers.d.ts.map +1 -0
- package/dist/conversational-flow/edit/routers.js +208 -0
- package/dist/conversational-flow/edit/routers.js.map +1 -0
- package/dist/conversational-flow/edit/screens.d.ts +44 -0
- package/dist/conversational-flow/edit/screens.d.ts.map +1 -0
- package/dist/conversational-flow/edit/screens.js +137 -0
- package/dist/conversational-flow/edit/screens.js.map +1 -0
- package/dist/conversational-flow/edit/versions.d.ts +43 -0
- package/dist/conversational-flow/edit/versions.d.ts.map +1 -0
- package/dist/conversational-flow/edit/versions.js +189 -0
- package/dist/conversational-flow/edit/versions.js.map +1 -0
- package/dist/conversational-flow/index.d.ts +33 -16
- package/dist/conversational-flow/index.d.ts.map +1 -1
- package/dist/conversational-flow/index.js +42 -9
- package/dist/conversational-flow/index.js.map +1 -1
- package/dist/conversational-flow/json.d.ts +15 -0
- package/dist/conversational-flow/json.d.ts.map +1 -0
- package/dist/conversational-flow/json.js +14 -0
- package/dist/conversational-flow/json.js.map +1 -0
- package/dist/conversational-flow/jumps.d.ts +22 -0
- package/dist/conversational-flow/jumps.d.ts.map +1 -0
- package/dist/conversational-flow/jumps.js +160 -0
- package/dist/conversational-flow/jumps.js.map +1 -0
- package/dist/conversational-flow/locate.d.ts +30 -0
- package/dist/conversational-flow/locate.d.ts.map +1 -0
- package/dist/conversational-flow/locate.js +73 -0
- package/dist/conversational-flow/locate.js.map +1 -0
- package/dist/conversational-flow/paths.d.ts +31 -0
- package/dist/conversational-flow/paths.d.ts.map +1 -0
- package/dist/conversational-flow/paths.js +50 -0
- package/dist/conversational-flow/paths.js.map +1 -0
- package/dist/conversational-flow/prompt.d.ts +48 -0
- package/dist/conversational-flow/prompt.d.ts.map +1 -0
- package/dist/conversational-flow/prompt.js +161 -0
- package/dist/conversational-flow/prompt.js.map +1 -0
- package/dist/conversational-flow/read.d.ts +9 -17
- package/dist/conversational-flow/read.d.ts.map +1 -1
- package/dist/conversational-flow/read.js +217 -384
- package/dist/conversational-flow/read.js.map +1 -1
- package/dist/conversational-flow/rounds.d.ts +29 -0
- package/dist/conversational-flow/rounds.d.ts.map +1 -0
- package/dist/conversational-flow/rounds.js +41 -0
- package/dist/conversational-flow/rounds.js.map +1 -0
- package/dist/conversational-flow/routers.d.ts +24 -80
- package/dist/conversational-flow/routers.d.ts.map +1 -1
- package/dist/conversational-flow/routers.js +76 -262
- package/dist/conversational-flow/routers.js.map +1 -1
- package/dist/conversational-flow/settle.d.ts +21 -15
- package/dist/conversational-flow/settle.d.ts.map +1 -1
- package/dist/conversational-flow/settle.js +240 -38
- package/dist/conversational-flow/settle.js.map +1 -1
- package/dist/conversational-flow/shape.d.ts +114 -0
- package/dist/conversational-flow/shape.d.ts.map +1 -0
- package/dist/conversational-flow/shape.js +209 -0
- package/dist/conversational-flow/shape.js.map +1 -0
- package/dist/conversational-flow/testing.d.ts +54 -0
- package/dist/conversational-flow/testing.d.ts.map +1 -0
- package/dist/conversational-flow/testing.js +119 -0
- package/dist/conversational-flow/testing.js.map +1 -0
- package/dist/conversational-flow/tree.d.ts +28 -17
- package/dist/conversational-flow/tree.d.ts.map +1 -1
- package/dist/conversational-flow/tree.js +60 -47
- package/dist/conversational-flow/tree.js.map +1 -1
- package/dist/conversational-flow/turn.d.ts +20 -22
- package/dist/conversational-flow/turn.d.ts.map +1 -1
- package/dist/conversational-flow/turn.js +69 -48
- package/dist/conversational-flow/turn.js.map +1 -1
- package/dist/conversational-flow/types.d.ts +154 -118
- package/dist/conversational-flow/types.d.ts.map +1 -1
- package/dist/conversational-flow/types.js +27 -51
- package/dist/conversational-flow/types.js.map +1 -1
- package/dist/conversational-flow/typing.d.ts +31 -0
- package/dist/conversational-flow/typing.d.ts.map +1 -0
- package/dist/conversational-flow/typing.js +53 -0
- package/dist/conversational-flow/typing.js.map +1 -0
- package/dist/engine/config-validator.js +2 -2
- package/dist/engine/config-validator.js.map +1 -1
- package/dist/engine/variable-resolver.d.ts +16 -0
- package/dist/engine/variable-resolver.d.ts.map +1 -1
- package/dist/engine/variable-resolver.js +46 -2
- package/dist/engine/variable-resolver.js.map +1 -1
- package/dist/engine/workflow-executor.d.ts.map +1 -1
- package/dist/engine/workflow-executor.js +10 -0
- package/dist/engine/workflow-executor.js.map +1 -1
- package/dist/runtime/workflow-runtime.d.ts.map +1 -1
- package/dist/runtime/workflow-runtime.js +3 -0
- package/dist/runtime/workflow-runtime.js.map +1 -1
- package/dist/steps/base-step.d.ts.map +1 -1
- package/dist/steps/base-step.js +1 -0
- package/dist/steps/base-step.js.map +1 -1
- package/dist/testing/mock-context.d.ts.map +1 -1
- package/dist/testing/mock-context.js +1 -0
- package/dist/testing/mock-context.js.map +1 -1
- package/dist/types/context.d.ts +15 -0
- package/dist/types/context.d.ts.map +1 -1
- package/dist/types/pause-state.d.ts +9 -0
- package/dist/types/pause-state.d.ts.map +1 -1
- package/dist/util/variable-ref.d.ts +1 -1
- package/dist/util/variable-ref.d.ts.map +1 -1
- package/dist/util/variable-ref.js +1 -1
- package/dist/util/variable-ref.js.map +1 -1
- package/package.json +1 -1
- package/dist/conversational-flow/edit.d.ts +0 -101
- package/dist/conversational-flow/edit.d.ts.map +0 -1
- package/dist/conversational-flow/edit.js +0 -785
- package/dist/conversational-flow/edit.js.map +0 -1
- package/dist/conversational-flow/internals.d.ts +0 -51
- package/dist/conversational-flow/internals.d.ts.map +0 -1
- package/dist/conversational-flow/internals.js +0 -163
- package/dist/conversational-flow/internals.js.map +0 -1
- package/dist/conversational-flow/lookup-edit.d.ts +0 -96
- package/dist/conversational-flow/lookup-edit.d.ts.map +0 -1
- package/dist/conversational-flow/lookup-edit.js +0 -266
- package/dist/conversational-flow/lookup-edit.js.map +0 -1
- package/dist/conversational-flow/lookups.d.ts +0 -46
- package/dist/conversational-flow/lookups.d.ts.map +0 -1
- package/dist/conversational-flow/lookups.js +0 -145
- package/dist/conversational-flow/lookups.js.map +0 -1
- package/dist/conversational-flow/router-edit.d.ts +0 -53
- package/dist/conversational-flow/router-edit.d.ts.map +0 -1
- package/dist/conversational-flow/router-edit.js +0 -191
- package/dist/conversational-flow/router-edit.js.map +0 -1
|
@@ -0,0 +1,249 @@
|
|
|
1
|
+
import { asArray, asRec, str } from '../json.js';
|
|
2
|
+
import { caseFor } from '../locate.js';
|
|
3
|
+
import { carriedTo, textKeyOf } from '../rounds.js';
|
|
4
|
+
import { finishStep, jumpStep, partsOf } from '../shape.js';
|
|
5
|
+
import { AGENT_STEP_TYPE, CLASSIFIER_STEP_TYPE, END_MESSAGE_KEY, HANDOFF_SECTION, optionsOf, QUESTION_SEPARATOR, } from '../types.js';
|
|
6
|
+
/**
|
|
7
|
+
* What a screen of this kind is made of — the one place that decides, so a screen
|
|
8
|
+
* created as a Finish and a screen turned into one are the same screen.
|
|
9
|
+
*/
|
|
10
|
+
export function stepsForKind(draft, flow, kind, args) {
|
|
11
|
+
if (kind === 'end')
|
|
12
|
+
return endingSteps(flow, args);
|
|
13
|
+
if (kind === 'handoff')
|
|
14
|
+
return handoffSteps(draft, flow, args);
|
|
15
|
+
if (kind === 'ask-ai') {
|
|
16
|
+
return askAiSteps(draft, flow, { ...args, prompt: args.prompt || `Ask me anything about ${args.title.toLowerCase()}.` });
|
|
17
|
+
}
|
|
18
|
+
if (kind === 'message') {
|
|
19
|
+
// Somewhere to go when it is done, if the flow has an ending that belongs to
|
|
20
|
+
// no branch in particular.
|
|
21
|
+
const exit = sharedExit(flow, args.screenId);
|
|
22
|
+
if (exit)
|
|
23
|
+
args.options.push({ label: 'That’s all', value: exit.id });
|
|
24
|
+
}
|
|
25
|
+
return questionSteps(draft, flow, { ...args, branches: kind === 'questions' });
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* A screen that asks: the question, and where each answer goes.
|
|
29
|
+
*
|
|
30
|
+
* `branches` makes it a screen with follow-ups — the jump moves into a SWITCH
|
|
31
|
+
* whose cases are the answers that ask something more before moving on.
|
|
32
|
+
*/
|
|
33
|
+
export function questionSteps(draft, flow, args) {
|
|
34
|
+
const waitId = `ask_${args.screenId}`;
|
|
35
|
+
const fields = fieldsFor(draft, flow, modelPrompt(flow));
|
|
36
|
+
const select = fields.find((f) => f['type'] === 'select');
|
|
37
|
+
if (select)
|
|
38
|
+
select['options'] = args.options;
|
|
39
|
+
// Without a heading, `settle` writes where the screen sits once it knows.
|
|
40
|
+
const wait = {
|
|
41
|
+
id: waitId,
|
|
42
|
+
type: 'WAIT',
|
|
43
|
+
config: { mode: 'approval', ...(args.header !== undefined ? { reason: args.header } : {}), prompt: args.prompt, form: { fields } },
|
|
44
|
+
};
|
|
45
|
+
const pick = jumpStep(args.branches ? `leave_${args.screenId}` : `go_${args.screenId}`, flow.rootScreen, {
|
|
46
|
+
...carriedTo(draft, flow, flow.rootScreen),
|
|
47
|
+
[flow.routeKey]: `{{steps.${waitId}.output.resumeData.data.${str(select?.['name']) ?? 'choice'}}}`,
|
|
48
|
+
});
|
|
49
|
+
// With follow-ups, what they tapped is answered here before it is carried on.
|
|
50
|
+
const tapped = args.branches
|
|
51
|
+
? [{ id: `pick_${args.screenId}`, type: 'SWITCH', config: { cases: [], default: [pick] } }]
|
|
52
|
+
: [pick];
|
|
53
|
+
const textField = str(fields.find((f) => f['type'] === 'text')?.['name']);
|
|
54
|
+
const router = args.router ?? flow.screens.find((s) => s.kind === 'router')?.id;
|
|
55
|
+
if (!router || !textField)
|
|
56
|
+
return [wait, ...tapped];
|
|
57
|
+
return [wait, typedGate(draft, flow, args.screenId, waitId, textField, router, tapped)];
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* The end of the conversation. Whatever the screen said becomes its last word,
|
|
61
|
+
* so turning a Message into a Finish keeps its wording instead of dropping it.
|
|
62
|
+
*/
|
|
63
|
+
export function endingSteps(flow, args) {
|
|
64
|
+
return [
|
|
65
|
+
finishStep(`finish_${args.screenId}`, flow.rootScreen, {
|
|
66
|
+
...(args.prompt ? { [END_MESSAGE_KEY]: args.prompt } : {}),
|
|
67
|
+
outcome: args.screenId,
|
|
68
|
+
}),
|
|
69
|
+
];
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* A person has it from here.
|
|
73
|
+
*
|
|
74
|
+
* The run pauses on a WAIT only they answer — no text box, since the customer is
|
|
75
|
+
* talking to them now — and a jump carries their answer on: an ending closes the
|
|
76
|
+
* conversation, a screen sends it back into the flow. What they may choose is
|
|
77
|
+
* written by `settle`.
|
|
78
|
+
*/
|
|
79
|
+
export function handoffSteps(draft, flow, args) {
|
|
80
|
+
const waitId = `handoff_${args.screenId}`;
|
|
81
|
+
const fields = fieldsFor(draft, flow, modelPrompt(flow)).filter((f) => f['type'] === 'select');
|
|
82
|
+
for (const field of fields)
|
|
83
|
+
field['options'] = [];
|
|
84
|
+
const select = fields[0];
|
|
85
|
+
return [
|
|
86
|
+
{
|
|
87
|
+
id: waitId,
|
|
88
|
+
type: 'WAIT',
|
|
89
|
+
config: {
|
|
90
|
+
mode: 'approval',
|
|
91
|
+
prompt: '',
|
|
92
|
+
display: [{ id: HANDOFF_SECTION, label: 'Handed off to a person', value: '' }],
|
|
93
|
+
form: { fields },
|
|
94
|
+
},
|
|
95
|
+
},
|
|
96
|
+
jumpStep(`go_${args.screenId}`, flow.rootScreen, {
|
|
97
|
+
...carriedTo(draft, flow, flow.rootScreen),
|
|
98
|
+
[flow.routeKey]: `{{steps.${waitId}.output.resumeData.data.${str(select?.['name']) ?? 'choice'}}}`,
|
|
99
|
+
}),
|
|
100
|
+
];
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* An agent that answers until they leave.
|
|
104
|
+
*
|
|
105
|
+
* It opens like any screen — the intro, the ways out, a text box — and a typed
|
|
106
|
+
* question goes to an agent that answers and then waits for a reply: another
|
|
107
|
+
* question is answered in place, and tapping one of the ways out carries them
|
|
108
|
+
* there. So the whole exchange is one round of the conversation.
|
|
109
|
+
*/
|
|
110
|
+
export function askAiSteps(draft, flow, args) {
|
|
111
|
+
const built = questionSteps(draft, flow, args);
|
|
112
|
+
const gate = built[1];
|
|
113
|
+
if (gate?.type !== 'CONDITIONAL') {
|
|
114
|
+
throw new AskAiUnsupported('Ask AI needs a flow whose screens take typed messages.');
|
|
115
|
+
}
|
|
116
|
+
const waitId = `ask_${args.screenId}`;
|
|
117
|
+
const agentId = `ai_${args.screenId}`;
|
|
118
|
+
const textField = str(asArray(asRec(asRec(built[0]['config'])['form'])['fields']).map(asRec).find((f) => f['type'] === 'text')?.['name']);
|
|
119
|
+
const agent = {
|
|
120
|
+
id: agentId,
|
|
121
|
+
type: AGENT_STEP_TYPE,
|
|
122
|
+
config: {
|
|
123
|
+
agentSlug: args.agentSlug ?? flow.screens.find((s) => s.router?.mode === 'agent')?.router?.agent ?? '',
|
|
124
|
+
task: `Answer their questions about ${args.title}. Use your connected systems and sources, and say so plainly when you are not sure.` +
|
|
125
|
+
QUESTION_SEPARATOR +
|
|
126
|
+
`{{steps.${waitId}.output.resumeData.data.${textField ?? 'message'}}}`,
|
|
127
|
+
outputType: 'string',
|
|
128
|
+
waitForReply: true,
|
|
129
|
+
},
|
|
130
|
+
};
|
|
131
|
+
// The agent is told to name one of the ways out; that is what ends the exchange.
|
|
132
|
+
gate.config['if_true'] = [
|
|
133
|
+
agent,
|
|
134
|
+
jumpStep(`leave_${args.screenId}`, flow.rootScreen, {
|
|
135
|
+
...carriedTo(draft, flow, flow.rootScreen),
|
|
136
|
+
[flow.routeKey]: `{{steps.${agentId}.output.choice}}`,
|
|
137
|
+
}),
|
|
138
|
+
];
|
|
139
|
+
return built;
|
|
140
|
+
}
|
|
141
|
+
export class AskAiUnsupported extends Error {
|
|
142
|
+
name = 'AskAiUnsupported';
|
|
143
|
+
}
|
|
144
|
+
/**
|
|
145
|
+
* A router: the step that reads a typed message and names a screen, and the jump
|
|
146
|
+
* that carries its answer on.
|
|
147
|
+
*
|
|
148
|
+
* What it is told, the screens it may choose and where an unsure message goes are
|
|
149
|
+
* all written by `settle`, from the frame the router ends up in.
|
|
150
|
+
*/
|
|
151
|
+
export function routerSteps(draft, flow, args) {
|
|
152
|
+
const stepId = args.stepId ?? `decide_${args.screenId}`;
|
|
153
|
+
const step = decidingStep(stepId, args.wanted);
|
|
154
|
+
return [
|
|
155
|
+
step,
|
|
156
|
+
jumpStep(`go_${args.screenId}`, flow.rootScreen, {
|
|
157
|
+
...carriedTo(draft, flow, flow.rootScreen),
|
|
158
|
+
[flow.routeKey]: routerAnswer(stepId, args.wanted, flow.routeKey),
|
|
159
|
+
}),
|
|
160
|
+
];
|
|
161
|
+
}
|
|
162
|
+
/** The deciding step itself, keeping anything the author wrote on the old one. */
|
|
163
|
+
export function decidingStep(stepId, wanted, description) {
|
|
164
|
+
const kept = { id: stepId, ...(description ? { description } : {}) };
|
|
165
|
+
if (wanted.mode === 'agent') {
|
|
166
|
+
// Its brief and the shape of its answer are written by `settle`.
|
|
167
|
+
return { ...kept, type: AGENT_STEP_TYPE, config: { agentSlug: wanted.agentSlug.trim(), task: '', outputType: 'json' } };
|
|
168
|
+
}
|
|
169
|
+
return {
|
|
170
|
+
...kept,
|
|
171
|
+
type: CLASSIFIER_STEP_TYPE,
|
|
172
|
+
config: {
|
|
173
|
+
input: '',
|
|
174
|
+
instructions: '',
|
|
175
|
+
classes: {},
|
|
176
|
+
...(wanted.model ? { model: wanted.model } : {}),
|
|
177
|
+
...(wanted.credentialName ? { credentialName: wanted.credentialName } : {}),
|
|
178
|
+
...(wanted.minConfidence !== undefined ? { minConfidence: wanted.minConfidence } : {}),
|
|
179
|
+
},
|
|
180
|
+
};
|
|
181
|
+
}
|
|
182
|
+
/** How the jump after a router names what it chose. */
|
|
183
|
+
export function routerAnswer(stepId, wanted, routeKey) {
|
|
184
|
+
return wanted.mode === 'classifier' ? `{{steps.${stepId}.output.class}}` : `{{steps.${stepId}.output.response.${routeKey}}}`;
|
|
185
|
+
}
|
|
186
|
+
/**
|
|
187
|
+
* The ending a new Message screen offers as "That's all": a way out of the
|
|
188
|
+
* conversation that belongs to no branch in particular.
|
|
189
|
+
*
|
|
190
|
+
* A Finish that says something ("Your driver is 3 minutes away") is that
|
|
191
|
+
* branch's own ending, and offering it from an unrelated screen would put words
|
|
192
|
+
* in its mouth. So: a silent Finish first, then whichever ending the most
|
|
193
|
+
* screens already lead to, and none at all when every ending belongs somewhere.
|
|
194
|
+
*/
|
|
195
|
+
export function sharedExit(flow, exclude) {
|
|
196
|
+
const ends = flow.screens.filter((s) => s.kind === 'end' && s.id !== exclude);
|
|
197
|
+
const silent = ends.filter((s) => s.endMessage === undefined);
|
|
198
|
+
if (silent.length > 0)
|
|
199
|
+
return silent[0];
|
|
200
|
+
const leads = (id) => flow.screens.filter((s) => optionsOf(s).some((o) => o.to.kind === 'screen' && o.to.screen === id)).length;
|
|
201
|
+
return ends.filter((s) => leads(s.id) > 1).sort((a, b) => leads(b.id) - leads(a.id))[0];
|
|
202
|
+
}
|
|
203
|
+
// ─── What every question shares ───
|
|
204
|
+
/** Typing goes to the router; tapping goes wherever the tap says. */
|
|
205
|
+
function typedGate(draft, flow, screenId, waitId, textField, routerId, tapped) {
|
|
206
|
+
const typed = `{{steps.${waitId}.output.resumeData.data.${textField}}}`;
|
|
207
|
+
return {
|
|
208
|
+
id: `typed_${screenId}`,
|
|
209
|
+
type: 'CONDITIONAL',
|
|
210
|
+
config: {
|
|
211
|
+
condition: {
|
|
212
|
+
all: [
|
|
213
|
+
{ variable: typed, operator: 'exists' },
|
|
214
|
+
{ variable: typed, operator: 'neq', value: '' },
|
|
215
|
+
],
|
|
216
|
+
},
|
|
217
|
+
if_true: [jumpStep(`typed_go_${screenId}`, flow.rootScreen, { ...carriedTo(draft, flow, routerId), [textKeyOf(draft, flow)]: typed })],
|
|
218
|
+
if_false: tapped,
|
|
219
|
+
},
|
|
220
|
+
};
|
|
221
|
+
}
|
|
222
|
+
/** A question this flow already has, to model a new one on. */
|
|
223
|
+
function modelPrompt(flow) {
|
|
224
|
+
return flow.screens.find((s) => (s.kind === 'menu' || s.kind === 'message') && s.prompts[0])?.prompts[0]?.id;
|
|
225
|
+
}
|
|
226
|
+
/** The form fields this flow uses, with the options emptied for a new screen. */
|
|
227
|
+
function fieldsFor(draft, flow, promptId) {
|
|
228
|
+
const fallback = [
|
|
229
|
+
{ type: 'select', name: 'choice', label: 'Choose one', options: [] },
|
|
230
|
+
{ type: 'text', name: 'message', label: 'Or type your question' },
|
|
231
|
+
];
|
|
232
|
+
if (!promptId)
|
|
233
|
+
return fallback;
|
|
234
|
+
for (const screen of flow.screens) {
|
|
235
|
+
if (!screen.prompts.some((p) => p.id === promptId))
|
|
236
|
+
continue;
|
|
237
|
+
const entry = caseFor(draft, flow, screen);
|
|
238
|
+
const wait = entry ? partsOf(entry, flow.routeKey).rest.find((s) => s.id === promptId) : undefined;
|
|
239
|
+
const fields = asArray(asRec(wait?.config['form'])['fields']).map(asRec);
|
|
240
|
+
if (fields.length === 0)
|
|
241
|
+
break;
|
|
242
|
+
return fields.map((field) => ({ ...clone(field), ...(field['type'] === 'select' ? { options: [] } : {}) }));
|
|
243
|
+
}
|
|
244
|
+
return fallback;
|
|
245
|
+
}
|
|
246
|
+
function clone(value) {
|
|
247
|
+
return JSON.parse(JSON.stringify(value));
|
|
248
|
+
}
|
|
249
|
+
//# sourceMappingURL=build.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"build.js","sourceRoot":"","sources":["../../../src/conversational-flow/edit/build.ts"],"names":[],"mappings":"AAYA,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,GAAG,EAAuB,MAAM,YAAY,CAAC;AACtE,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AACvC,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACpD,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAC5D,OAAO,EACL,eAAe,EACf,oBAAoB,EACpB,eAAe,EACf,eAAe,EACf,SAAS,EACT,kBAAkB,GAGnB,MAAM,aAAa,CAAC;AAoBrB;;;GAGG;AACH,MAAM,UAAU,YAAY,CAC1B,KAAqB,EACrB,IAAwB,EACxB,IAAiF,EACjF,IAAuC;IAEvC,IAAI,IAAI,KAAK,KAAK;QAAE,OAAO,WAAW,CAAC,IAAI,EAAE,IAAI,CAAC,CA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/B,OAAO,MAAM,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC,EAAE,GAAG,KAAK,CAAC,KAAK,CAAC,EAAE,GAAG,CAAC,KAAK,CAAC,MAAM,CAAC,KAAK,QAAQ,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;IAC9G,CAAC;IACD,OAAO,QAAQ,CAAC;AAClB,CAAC;AAED,SAAS,KAAK,CAAI,KAAQ;IACxB,OAAO,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CAAM,CAAC;AAChD,CAAC"}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Calls: what a frame fetches on the way in.
|
|
3
|
+
*
|
|
4
|
+
* Where the step sits is the whole meaning, so that is the only thing these
|
|
5
|
+
* edits decide:
|
|
6
|
+
*
|
|
7
|
+
* before the first screen's cycle once per conversation, in scope everywhere
|
|
8
|
+
* before a section's cycle once per entry to it, in scope inside it
|
|
9
|
+
* before a question every visit, in scope on that screen
|
|
10
|
+
*
|
|
11
|
+
* However someone arrives — tapped down, typed and routed straight in, came
|
|
12
|
+
* back — they pass through the frames above them, so what those frames fetched
|
|
13
|
+
* has been fetched. That is the property the whole shape exists for, and it is
|
|
14
|
+
* not maintained anywhere: it is where the step is.
|
|
15
|
+
*/
|
|
16
|
+
import type { WorkflowConfig } from '../../types/workflow-config.js';
|
|
17
|
+
import type { CallScope, ConversationalFlow } from '../types.js';
|
|
18
|
+
export interface CallDraft {
|
|
19
|
+
/** What to call it — shown in the editor and in the run's trace. */
|
|
20
|
+
title: string;
|
|
21
|
+
/** The HTTP step's own config: `url`, `method`, `headers`, `body`, `response`, … */
|
|
22
|
+
request: Record<string, unknown>;
|
|
23
|
+
}
|
|
24
|
+
/** How a call's answer is quoted, from anywhere inside its frame. */
|
|
25
|
+
export declare function callRef(callId: string, path?: string): string;
|
|
26
|
+
/**
|
|
27
|
+
* Fetch something on the way into `screenId`.
|
|
28
|
+
*
|
|
29
|
+
* The scope follows the screen unless it is asked for: a section fetches for
|
|
30
|
+
* everything inside it, a leaf for itself, and the first screen for the whole
|
|
31
|
+
* conversation — which is what an id passed in at the start is usually for.
|
|
32
|
+
*/
|
|
33
|
+
export declare function addCall(config: WorkflowConfig, screenId: string, draft: CallDraft, scope?: CallScope): {
|
|
34
|
+
config: WorkflowConfig;
|
|
35
|
+
callId: string;
|
|
36
|
+
};
|
|
37
|
+
/**
|
|
38
|
+
* Move a lookup so it runs in front of a different screen.
|
|
39
|
+
*
|
|
40
|
+
* Where it sits *is* its scope, so this is the only way to change one — and it
|
|
41
|
+
* is the honest way to say it: not "pick a scope" but "pick what it runs before".
|
|
42
|
+
* Its guard moves with it; where a failed one goes is unchanged unless the new
|
|
43
|
+
* place cannot have one.
|
|
44
|
+
*/
|
|
45
|
+
export declare function moveCall(config: WorkflowConfig, callId: string, screenId: string, scope?: CallScope): WorkflowConfig;
|
|
46
|
+
/**
|
|
47
|
+
* Rewrite a call. The request replaces what was there — the editor holds the
|
|
48
|
+
* whole request, so merging halves of two would be guesswork — and where a
|
|
49
|
+
* failed one goes is `setCallFallback`'s, so it is left alone.
|
|
50
|
+
*/
|
|
51
|
+
export declare function setCall(config: WorkflowConfig, callId: string, draft: CallDraft): WorkflowConfig;
|
|
52
|
+
/** Stop fetching it, and take the guard that said where a failed one goes. */
|
|
53
|
+
export declare function removeCall(config: WorkflowConfig, callId: string): WorkflowConfig;
|
|
54
|
+
/**
|
|
55
|
+
* Where to go when it cannot be reached — or `null` to drop that, after which
|
|
56
|
+
* an unanswered call fails the conversation.
|
|
57
|
+
*/
|
|
58
|
+
export declare function setCallFallback(config: WorkflowConfig, callId: string, to: string | null): WorkflowConfig;
|
|
59
|
+
/** Where a call's answer is quoted, in the author's terms. */
|
|
60
|
+
export declare function quotedIn(flow: ConversationalFlow, callId: string): string[];
|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,MAAM,EAAE,EAAE,EAAE,MAAM,GAAG,IAAI,GAAG,cAAc,CAiDzG;AAED,8DAA8D;AAC9D,wBAAgB,QAAQ,CAAC,IAAI,EAAE,kBAAkB,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM,EAAE,CAiB3E"}
|
|
@@ -0,0 +1,296 @@
|
|
|
1
|
+
import { asArray, asRec, asSteps } from '../json.js';
|
|
2
|
+
import { caseFor, sectionCaseFor } from '../locate.js';
|
|
3
|
+
import { guardTarget, isCall, isCycle } from '../shape.js';
|
|
4
|
+
import { ConversationalFlowEditError, requireFlow, settle } from '../settle.js';
|
|
5
|
+
/** What this layer is willing to write. Anything else is somebody's typo. */
|
|
6
|
+
const METHODS = new Set(['GET', 'POST', 'PUT', 'PATCH', 'DELETE', 'HEAD']);
|
|
7
|
+
/** How a call's answer is quoted, from anywhere inside its frame. */
|
|
8
|
+
export function callRef(callId, path = 'body') {
|
|
9
|
+
return `{{steps.${callId}.output.${path}}}`;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Fetch something on the way into `screenId`.
|
|
13
|
+
*
|
|
14
|
+
* The scope follows the screen unless it is asked for: a section fetches for
|
|
15
|
+
* everything inside it, a leaf for itself, and the first screen for the whole
|
|
16
|
+
* conversation — which is what an id passed in at the start is usually for.
|
|
17
|
+
*/
|
|
18
|
+
export function addCall(config, screenId, draft, scope) {
|
|
19
|
+
const flow = requireFlow(config);
|
|
20
|
+
const screen = requireScreen(flow, screenId);
|
|
21
|
+
const at = scope ?? defaultScope(flow, screen);
|
|
22
|
+
refuseImpossible(flow, screen, at);
|
|
23
|
+
const request = checked(draft.request);
|
|
24
|
+
const title = draft.title.trim();
|
|
25
|
+
let callId = '';
|
|
26
|
+
const next = settle(config, (draft2) => {
|
|
27
|
+
const flow2 = requireFlow(draft2);
|
|
28
|
+
const where = placeFor(draft2, flow2, requireScreen(flow2, screenId), at);
|
|
29
|
+
callId = unique(slug(title || 'call'), takenIds(draft2));
|
|
30
|
+
where.steps.splice(where.at, 0, { id: callId, type: 'HTTP_REQUEST', ...(title ? { title } : {}), config: request });
|
|
31
|
+
});
|
|
32
|
+
return { config: next, callId };
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Move a lookup so it runs in front of a different screen.
|
|
36
|
+
*
|
|
37
|
+
* Where it sits *is* its scope, so this is the only way to change one — and it
|
|
38
|
+
* is the honest way to say it: not "pick a scope" but "pick what it runs before".
|
|
39
|
+
* Its guard moves with it; where a failed one goes is unchanged unless the new
|
|
40
|
+
* place cannot have one.
|
|
41
|
+
*/
|
|
42
|
+
export function moveCall(config, callId, screenId, scope) {
|
|
43
|
+
const flow = requireFlow(config);
|
|
44
|
+
const { screen: from, call } = ownerOf(flow, callId);
|
|
45
|
+
const to = requireScreen(flow, screenId);
|
|
46
|
+
const at = scope ?? defaultScope(flow, to);
|
|
47
|
+
if (from.id === screenId && call.scope === at)
|
|
48
|
+
return config;
|
|
49
|
+
refuseImpossible(flow, to, at);
|
|
50
|
+
return settle(config, (draft) => {
|
|
51
|
+
const live = requireFlow(draft);
|
|
52
|
+
const taken = cut(draft, live, callId);
|
|
53
|
+
const where = placeFor(draft, live, requireScreen(live, screenId), at);
|
|
54
|
+
where.steps.splice(where.at, 0, ...taken);
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
/** Take a call and its guard out of wherever they are, and hand them back. */
|
|
58
|
+
function cut(draft, flow, callId) {
|
|
59
|
+
const { screen } = ownerOf(flow, callId);
|
|
60
|
+
for (const entry of [sectionCaseFor(draft, flow, screen), caseFor(draft, flow, screen), { steps: draft.steps }]) {
|
|
61
|
+
if (!entry)
|
|
62
|
+
continue;
|
|
63
|
+
const steps = asArray(entry['steps']);
|
|
64
|
+
const at = steps.findIndex((step) => asRec(step)['id'] === callId);
|
|
65
|
+
if (at === -1)
|
|
66
|
+
continue;
|
|
67
|
+
const guard = guardTarget(asSteps(steps)[at + 1], callId, flow.routeKey) === undefined ? 1 : 2;
|
|
68
|
+
return steps.splice(at, guard);
|
|
69
|
+
}
|
|
70
|
+
throw new ConversationalFlowEditError(`“${callId}” is not where it says it is.`);
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Rewrite a call. The request replaces what was there — the editor holds the
|
|
74
|
+
* whole request, so merging halves of two would be guesswork — and where a
|
|
75
|
+
* failed one goes is `setCallFallback`'s, so it is left alone.
|
|
76
|
+
*/
|
|
77
|
+
export function setCall(config, callId, draft) {
|
|
78
|
+
const flow = requireFlow(config);
|
|
79
|
+
ownerOf(flow, callId);
|
|
80
|
+
const request = checked(draft.request);
|
|
81
|
+
const title = draft.title.trim();
|
|
82
|
+
return settle(config, (d) => {
|
|
83
|
+
const step = callStep(d, requireFlow(d), callId);
|
|
84
|
+
step.config = request;
|
|
85
|
+
if (title)
|
|
86
|
+
step.title = title;
|
|
87
|
+
else
|
|
88
|
+
delete step.title;
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
/** Stop fetching it, and take the guard that said where a failed one goes. */
|
|
92
|
+
export function removeCall(config, callId) {
|
|
93
|
+
const flow = requireFlow(config);
|
|
94
|
+
const { call } = ownerOf(flow, callId);
|
|
95
|
+
const used = quotedIn(flow, callId);
|
|
96
|
+
if (used.length > 0) {
|
|
97
|
+
throw new ConversationalFlowEditError(`“${call.title}” is quoted in ${used.join(', ')}. Take it out of the wording first.`);
|
|
98
|
+
}
|
|
99
|
+
return settle(config, (d) => {
|
|
100
|
+
const flow2 = requireFlow(d);
|
|
101
|
+
const { steps, index } = stepsAround(d, flow2, callId);
|
|
102
|
+
steps.splice(index, call.onFail === undefined ? 1 : 2);
|
|
103
|
+
});
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* Where to go when it cannot be reached — or `null` to drop that, after which
|
|
107
|
+
* an unanswered call fails the conversation.
|
|
108
|
+
*/
|
|
109
|
+
export function setCallFallback(config, callId, to) {
|
|
110
|
+
const flow = requireFlow(config);
|
|
111
|
+
const { screen, call } = ownerOf(flow, callId);
|
|
112
|
+
if (call.scope === 'conversation') {
|
|
113
|
+
throw new ConversationalFlowEditError(`“${call.title}” runs before the conversation starts, so there is nowhere to send anyone if it fails. Move it onto “${screen.title}” to give it one.`);
|
|
114
|
+
}
|
|
115
|
+
if (to !== null) {
|
|
116
|
+
const target = requireScreen(flow, to);
|
|
117
|
+
if (target.id === screen.id) {
|
|
118
|
+
throw new ConversationalFlowEditError(`“${screen.title}” can’t fall back to itself — it would fetch the same thing again.`);
|
|
119
|
+
}
|
|
120
|
+
if (target.kind === 'router') {
|
|
121
|
+
throw new ConversationalFlowEditError('A router reads typed messages. Send a failed call to a screen that says something.');
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
return settle(config, (d) => {
|
|
125
|
+
const flow2 = requireFlow(d);
|
|
126
|
+
const { steps, index } = stepsAround(d, flow2, callId);
|
|
127
|
+
const step = asRec(steps[index]);
|
|
128
|
+
const had = call.onFail !== undefined;
|
|
129
|
+
if (to === null) {
|
|
130
|
+
if (had)
|
|
131
|
+
steps.splice(index + 1, 1);
|
|
132
|
+
const settings = asRec(step['settings']);
|
|
133
|
+
delete settings['onError'];
|
|
134
|
+
if (Object.keys(settings).length > 0)
|
|
135
|
+
step['settings'] = settings;
|
|
136
|
+
else
|
|
137
|
+
delete step['settings'];
|
|
138
|
+
return;
|
|
139
|
+
}
|
|
140
|
+
// Without this the run stops where the call failed and the conversation is
|
|
141
|
+
// simply gone; with it, the guard below decides what the person sees.
|
|
142
|
+
step['settings'] = { ...asRec(step['settings']), onError: 'continue' };
|
|
143
|
+
const guard = {
|
|
144
|
+
id: `${callId}_failed`,
|
|
145
|
+
type: 'CONDITIONAL',
|
|
146
|
+
config: {
|
|
147
|
+
// An answer that never arrived has no `ok` at all, which is not `true` either.
|
|
148
|
+
condition: { variable: callRef(callId, 'ok'), operator: 'neq', value: true },
|
|
149
|
+
// `settle` aims it at the frame that encloses it.
|
|
150
|
+
if_true: [{ id: `${callId}_failed_go`, type: 'GO_TO', config: { target: flow2.rootScreen, with: carried(d, flow2, to) } }],
|
|
151
|
+
if_false: [],
|
|
152
|
+
},
|
|
153
|
+
};
|
|
154
|
+
steps.splice(index + 1, had ? 1 : 0, guard);
|
|
155
|
+
});
|
|
156
|
+
}
|
|
157
|
+
/** Where a call's answer is quoted, in the author's terms. */
|
|
158
|
+
export function quotedIn(flow, callId) {
|
|
159
|
+
const needle = `steps.${callId}.`;
|
|
160
|
+
const out = [];
|
|
161
|
+
for (const screen of flow.screens) {
|
|
162
|
+
for (const prompt of screen.prompts) {
|
|
163
|
+
if (prompt.text.includes(needle))
|
|
164
|
+
out.push(`what “${screen.title}” says`);
|
|
165
|
+
for (const option of prompt.options)
|
|
166
|
+
if (option.label.includes(needle))
|
|
167
|
+
out.push(`an option on “${screen.title}”`);
|
|
168
|
+
}
|
|
169
|
+
if (screen.endMessage?.includes(needle))
|
|
170
|
+
out.push(`the farewell on “${screen.title}”`);
|
|
171
|
+
for (const [key, value] of Object.entries(screen.endValue ?? {})) {
|
|
172
|
+
if (typeof value === 'string' && value.includes(needle))
|
|
173
|
+
out.push(`“${screen.title}” → ${key}`);
|
|
174
|
+
}
|
|
175
|
+
for (const call of screen.calls) {
|
|
176
|
+
if (call.id !== callId && JSON.stringify(call.request).includes(needle))
|
|
177
|
+
out.push(`the request of “${call.title}”`);
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
return out;
|
|
181
|
+
}
|
|
182
|
+
// ─── Where a call goes ───
|
|
183
|
+
function defaultScope(flow, screen) {
|
|
184
|
+
if (screen.id === flow.rootScreen)
|
|
185
|
+
return 'conversation';
|
|
186
|
+
return screen.children.length > 0 ? 'section' : 'screen';
|
|
187
|
+
}
|
|
188
|
+
function refuseImpossible(flow, screen, scope) {
|
|
189
|
+
if (screen.kind === 'router') {
|
|
190
|
+
throw new ConversationalFlowEditError('A router only decides where a typed message goes; it has nothing to fetch.');
|
|
191
|
+
}
|
|
192
|
+
if (scope === 'conversation' && screen.id !== flow.rootScreen) {
|
|
193
|
+
throw new ConversationalFlowEditError(`Only “${flow.rootScreen}” runs before the conversation starts.`);
|
|
194
|
+
}
|
|
195
|
+
if (scope === 'section' && screen.children.length === 0) {
|
|
196
|
+
throw new ConversationalFlowEditError(`Nothing sits inside “${screen.title}”, so there is no section to fetch for.`);
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
/** The list a call belongs in, and where its turn comes in that list. */
|
|
200
|
+
function placeFor(config, flow, screen, scope) {
|
|
201
|
+
if (scope === 'conversation') {
|
|
202
|
+
const steps = asArray(config.steps);
|
|
203
|
+
return { steps, at: steps.findIndex((step) => isCycle(step)) };
|
|
204
|
+
}
|
|
205
|
+
const entry = scope === 'section' ? sectionCaseFor(config, flow, screen) : caseFor(config, flow, screen);
|
|
206
|
+
if (!entry)
|
|
207
|
+
throw new ConversationalFlowEditError(`“${screen.title}” is not somewhere a call can go.`);
|
|
208
|
+
const steps = asArray(entry['steps']);
|
|
209
|
+
entry['steps'] = steps;
|
|
210
|
+
return { steps, at: leading(steps) };
|
|
211
|
+
}
|
|
212
|
+
/** How many steps at the top of a list are already calls (and their guards). */
|
|
213
|
+
function leading(steps) {
|
|
214
|
+
let at = 0;
|
|
215
|
+
while (at < steps.length && isCall(steps[at])) {
|
|
216
|
+
at += 1;
|
|
217
|
+
if (asRec(steps[at])['type'] === 'CONDITIONAL')
|
|
218
|
+
at += 1;
|
|
219
|
+
}
|
|
220
|
+
return at;
|
|
221
|
+
}
|
|
222
|
+
/** The list holding a call, and where in it the call sits. */
|
|
223
|
+
function stepsAround(config, flow, callId) {
|
|
224
|
+
const { screen, call } = ownerOf(flow, callId);
|
|
225
|
+
const { steps } = placeFor(config, flow, screen, call.scope);
|
|
226
|
+
const index = steps.findIndex((step) => asRec(step)['id'] === callId);
|
|
227
|
+
if (index < 0)
|
|
228
|
+
throw new ConversationalFlowEditError(`Step “${callId}” is missing.`);
|
|
229
|
+
return { steps, index };
|
|
230
|
+
}
|
|
231
|
+
function callStep(config, flow, callId) {
|
|
232
|
+
const { steps, index } = stepsAround(config, flow, callId);
|
|
233
|
+
return steps[index];
|
|
234
|
+
}
|
|
235
|
+
function ownerOf(flow, callId) {
|
|
236
|
+
for (const screen of flow.screens) {
|
|
237
|
+
const call = screen.calls.find((c) => c.id === callId);
|
|
238
|
+
if (call)
|
|
239
|
+
return { screen, call };
|
|
240
|
+
}
|
|
241
|
+
throw new ConversationalFlowEditError(`There is nothing called “${callId}” to fetch.`);
|
|
242
|
+
}
|
|
243
|
+
function requireScreen(flow, id) {
|
|
244
|
+
const screen = flow.screens.find((s) => s.id === id);
|
|
245
|
+
if (!screen)
|
|
246
|
+
throw new ConversationalFlowEditError(`There is no screen “${id}”.`);
|
|
247
|
+
return screen;
|
|
248
|
+
}
|
|
249
|
+
/** What a jump carries: every key a round starts with, and where it is going. */
|
|
250
|
+
function carried(config, flow, screen) {
|
|
251
|
+
const root = asArray(config.steps).find((step) => isCycle(step));
|
|
252
|
+
const out = {};
|
|
253
|
+
for (const key of Object.keys(asRec(root?.config['input'])))
|
|
254
|
+
out[key] = key === flow.routeKey ? screen : '';
|
|
255
|
+
out[flow.routeKey] = screen;
|
|
256
|
+
return out;
|
|
257
|
+
}
|
|
258
|
+
/** A request this layer is willing to write, with what it insists on settled. */
|
|
259
|
+
function checked(request) {
|
|
260
|
+
const url = typeof request['url'] === 'string' ? request['url'].trim() : '';
|
|
261
|
+
if (!url)
|
|
262
|
+
throw new ConversationalFlowEditError('A call needs an address.');
|
|
263
|
+
const method = typeof request['method'] === 'string' ? request['method'].toUpperCase() : 'GET';
|
|
264
|
+
if (!METHODS.has(method))
|
|
265
|
+
throw new ConversationalFlowEditError(`“${method}” isn’t a method this can call.`);
|
|
266
|
+
return { ...JSON.parse(JSON.stringify(request)), url, method };
|
|
267
|
+
}
|
|
268
|
+
function takenIds(config) {
|
|
269
|
+
const out = new Set();
|
|
270
|
+
const walk = (steps) => {
|
|
271
|
+
for (const raw of steps) {
|
|
272
|
+
const step = asRec(raw);
|
|
273
|
+
if (typeof step['id'] === 'string')
|
|
274
|
+
out.add(step['id']);
|
|
275
|
+
for (const value of Object.values(asRec(step['config']))) {
|
|
276
|
+
if (!Array.isArray(value))
|
|
277
|
+
continue;
|
|
278
|
+
walk(value);
|
|
279
|
+
for (const entry of value)
|
|
280
|
+
walk(asArray(asRec(entry)['steps']));
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
};
|
|
284
|
+
walk(asArray(config.steps));
|
|
285
|
+
return out;
|
|
286
|
+
}
|
|
287
|
+
function unique(base, taken) {
|
|
288
|
+
let name = base;
|
|
289
|
+
for (let n = 2; taken.has(name); n += 1)
|
|
290
|
+
name = `${base}_${n}`;
|
|
291
|
+
return name;
|
|
292
|
+
}
|
|
293
|
+
function slug(title) {
|
|
294
|
+
return title.toLowerCase().normalize('NFKD').replace(/[^a-z0-9]+/g, '_').replace(/^_+|_+$/g, '') || 'call';
|
|
295
|
+
}
|
|
296
|
+
//# sourceMappingURL=calls.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"calls.js","sourceRoot":"","sources":["../../../src/conversational-flow/edit/calls.ts"],"names":[],"mappings":"AAgBA,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,OAAO,EAAuB,MAAM,YAAY,CAAC;AAC1E,OAAO,EAAE,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AACvD,OAAO,EAAE,WAAW,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAC3D,OAAO,EAAE,2BAA2B,EAAE,WAAW,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAGhF,6EAA6E;AAC7E,MAAM,OAAO,GAAG,IAAI,GAAG,CAAC,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,CAAC,CAAC,CAAC;AAS3E,qEAAqE;AACrE,MAAM,UAAU,OAAO,CAAC,MAAc,EAAE,IAAI,GAAG,MA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