@xyne/workflow-sdk 3.2.47 → 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/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/variable-resolver.d.ts +16 -0
- package/dist/engine/variable-resolver.d.ts.map +1 -1
- package/dist/engine/variable-resolver.js +45 -1
- package/dist/engine/variable-resolver.js.map +1 -1
- package/dist/types/pause-state.d.ts +9 -0
- package/dist/types/pause-state.d.ts.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,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[];
|
|
61
|
+
//# sourceMappingURL=calls.d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M,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,MAAM;IACnD,OAAO,WAAW,MAAM,W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a case somewhere, and taking one out.
|
|
3
|
+
*
|
|
4
|
+
* A screen is a case; where that case sits is where the screen is. So the only
|
|
5
|
+
* structural move in the whole layer is lifting a case out of one switch and
|
|
6
|
+
* putting it in another — and the one thing that takes care is that a screen with
|
|
7
|
+
* nothing inside it and a screen with screens inside it are written differently:
|
|
8
|
+
*
|
|
9
|
+
* a leaf case eq(screen) [its calls…, its question]
|
|
10
|
+
* a section case any(subtree) [its calls…, CYCLE [ its own case, its children ]]
|
|
11
|
+
*
|
|
12
|
+
* So giving a leaf its first child promotes it — its steps move inside the new
|
|
13
|
+
* loop unchanged, and its calls with them, which is why promotion changes nothing
|
|
14
|
+
* about what it fetches or when. Taking the last child away demotes it back.
|
|
15
|
+
*
|
|
16
|
+
* Everything that adds, moves or removes anything goes through here, screens and
|
|
17
|
+
* routers alike, so the shape is maintained in one place.
|
|
18
|
+
*/
|
|
19
|
+
import type { WorkflowConfig } from '../../types/workflow-config.js';
|
|
20
|
+
import { type Rec } from '../json.js';
|
|
21
|
+
import type { ConversationalFlow } from '../types.js';
|
|
22
|
+
/**
|
|
23
|
+
* The switch a screen's children live in — making one if this is the first
|
|
24
|
+
* child, which is what turns a screen into a section.
|
|
25
|
+
*/
|
|
26
|
+
export declare function frameFor(draft: WorkflowConfig, flow: ConversationalFlow, screenId: string): Rec[];
|
|
27
|
+
/** Take a screen's case out of the switch it sits in, demoting its parent if it was the last. */
|
|
28
|
+
export declare function lift(draft: WorkflowConfig, flow: ConversationalFlow, screenId: string): Rec;
|
|
29
|
+
//# sourceMappingURL=cases.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cases.d.ts","sourceRoot":"","sources":["../../../src/conversational-flow/edit/cases.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AACH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gCAAgC,CAAC;AACrE,OAAO,EAAoB,KAAK,GAAG,EAAE,MAAM,YAAY,CAAC;AAKxD,OAAO,KAAK,EAAE,kBAAkB,EAAU,MAAM,aAAa,CAAC;AAE9D;;;GAGG;AACH,wBAAgB,QAAQ,CAAC,KAAK,EAAE,cAAc,EAAE,IAAI,EAAE,kBAAkB,EAAE,QAAQ,EAAE,MAAM,GAAG,GAAG,EAAE,CAmBjG;AAED,iGAAiG;AACjG,wBAAgB,IAAI,CAAC,KAAK,EAAE,cAAc,EAAE,IAAI,EAAE,kBAAkB,EAAE,QAAQ,EAAE,MAAM,GAAG,GAAG,CAY3F"}
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import { asArray, asSteps } from '../json.js';
|
|
2
|
+
import { caseFor, cycleAt, sectionCaseFor } from '../locate.js';
|
|
3
|
+
import { carriedTo, inheritedInput } from '../rounds.js';
|
|
4
|
+
import { ConversationalFlowEditError } from '../settle.js';
|
|
5
|
+
import { caseListIn, caseKind, cycleStep, isCycle, jumpStep, partsOf, screenCase, sectionCase, switchIn, switchStep } from '../shape.js';
|
|
6
|
+
/**
|
|
7
|
+
* The switch a screen's children live in — making one if this is the first
|
|
8
|
+
* child, which is what turns a screen into a section.
|
|
9
|
+
*/
|
|
10
|
+
export function frameFor(draft, flow, screenId) {
|
|
11
|
+
const screen = requireScreen(flow, screenId);
|
|
12
|
+
if (screen.children.length > 0 || screen.id === flow.rootScreen) {
|
|
13
|
+
const cycle = cycleAt(draft, [...screen.frames], flow.routeKey);
|
|
14
|
+
const routing = cycle ? switchIn(cycle) : undefined;
|
|
15
|
+
if (!routing)
|
|
16
|
+
throw new ConversationalFlowEditError(`“${screen.title}” has nowhere to hold a screen.`);
|
|
17
|
+
return caseListIn(routing);
|
|
18
|
+
}
|
|
19
|
+
// Promotion: the leaf's own case, steps and all, moves inside a new loop.
|
|
20
|
+
const own = caseFor(draft, flow, screen);
|
|
21
|
+
const holder = holderOf(draft, flow, screen);
|
|
22
|
+
if (!own || !holder)
|
|
23
|
+
throw new ConversationalFlowEditError(`“${screen.title}” is not somewhere a screen can go.`);
|
|
24
|
+
const at = holder.findIndex((entry) => entry === own);
|
|
25
|
+
const routing = switchStep(`${screen.id}_route`, [screenCase(screen.id, screen.title, asArray(own['steps']), flow.routeKey)], [
|
|
26
|
+
jumpStep(`${screen.id}_unknown`, flow.rootScreen, carriedTo(draft, flow, flow.rootScreen)),
|
|
27
|
+
]);
|
|
28
|
+
holder.splice(at, 1, sectionCase([screen.id], screen.title, [cycleStep(screen.id, inheritedInput(draft, flow), [routing])], flow.routeKey));
|
|
29
|
+
return caseListIn(routing);
|
|
30
|
+
}
|
|
31
|
+
/** Take a screen's case out of the switch it sits in, demoting its parent if it was the last. */
|
|
32
|
+
export function lift(draft, flow, screenId) {
|
|
33
|
+
const screen = requireScreen(flow, screenId);
|
|
34
|
+
const holder = holderOf(draft, flow, screen);
|
|
35
|
+
if (!holder)
|
|
36
|
+
throw new ConversationalFlowEditError(`“${screen.title}” is not in a switch.`);
|
|
37
|
+
const own = screen.children.length > 0 ? sectionCaseFor(draft, flow, screen) : caseFor(draft, flow, screen);
|
|
38
|
+
const at = holder.findIndex((entry) => entry === own);
|
|
39
|
+
if (at < 0)
|
|
40
|
+
throw new ConversationalFlowEditError(`“${screen.title}” is not where it says it is.`);
|
|
41
|
+
const [lifted] = holder.splice(at, 1);
|
|
42
|
+
const parent = screen.parent ? flow.screens.find((s) => s.id === screen.parent) : undefined;
|
|
43
|
+
if (parent && parent.id !== flow.rootScreen && parent.children.length === 1)
|
|
44
|
+
demote(draft, flow, parent);
|
|
45
|
+
return lifted;
|
|
46
|
+
}
|
|
47
|
+
/** A section with nothing left inside it is a screen again: its loop comes off. */
|
|
48
|
+
function demote(draft, flow, screen) {
|
|
49
|
+
const section = sectionCaseFor(draft, flow, screen);
|
|
50
|
+
const holder = holderOf(draft, flow, screen);
|
|
51
|
+
if (!section || !holder)
|
|
52
|
+
return;
|
|
53
|
+
const cycle = partsOf(section, flow.routeKey).rest.find(isCycle);
|
|
54
|
+
const routing = cycle ? switchIn(cycle) : undefined;
|
|
55
|
+
if (!routing)
|
|
56
|
+
return;
|
|
57
|
+
const own = caseListIn(routing).find((entry) => {
|
|
58
|
+
const kind = caseKind(entry, flow.routeKey);
|
|
59
|
+
return kind?.kind === 'screen' && kind.screen === screen.id;
|
|
60
|
+
});
|
|
61
|
+
if (!own)
|
|
62
|
+
return;
|
|
63
|
+
// Whatever the section itself fetched now belongs to the screen it was.
|
|
64
|
+
const calls = partsOf(section, flow.routeKey).calls.map((c) => c.step);
|
|
65
|
+
const at = holder.findIndex((entry) => entry === section);
|
|
66
|
+
holder.splice(at, 1, screenCase(screen.id, screen.title, [...calls, ...asSteps(own['steps'])], flow.routeKey));
|
|
67
|
+
}
|
|
68
|
+
/** The list of cases a screen's own case sits in. */
|
|
69
|
+
function holderOf(draft, flow, screen) {
|
|
70
|
+
const frames = screen.children.length > 0 ? screen.frames.slice(0, -1) : screen.frames;
|
|
71
|
+
if (frames.length === 0)
|
|
72
|
+
return undefined;
|
|
73
|
+
const cycle = cycleAt(draft, frames, flow.routeKey);
|
|
74
|
+
const routing = cycle ? switchIn(cycle) : undefined;
|
|
75
|
+
return routing ? caseListIn(routing) : undefined;
|
|
76
|
+
}
|
|
77
|
+
function requireScreen(flow, id) {
|
|
78
|
+
const screen = flow.screens.find((s) => s.id === id);
|
|
79
|
+
if (!screen)
|
|
80
|
+
throw new ConversationalFlowEditError(`There is no screen “${id}”.`);
|
|
81
|
+
return screen;
|
|
82
|
+
}
|
|
83
|
+
//# sourceMappingURL=cases.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cases.js","sourceRoot":"","sources":["../../../src/conversational-flow/edit/cases.ts"],"names":[],"mappings":"AAmBA,OAAO,EAAE,OAAO,EAAE,OAAO,EAAY,MAAM,YAAY,CAAC;AACxD,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAChE,OAAO,EAAE,SAAS,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AACzD,O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,MAAM,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,SAAS,CAAC;IAC1C,MAAM,KAAK,GAAG,OAAO,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,CAAC,QAAQ,CAAC,CAAC;IACpD,MAAM,OAAO,GAAG,KAAK,CAAC,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;IACpD,OAAO,OAAO,CAAC,CAAC,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;AACnD,CAAC;AAED,SAAS,aAAa,CAAC,IAAwB,EAAE,EAAU;IACzD,MAAM,MAAM,GAAG,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,CAAC;IACrD,IAAI,CAAC,MAAM;QAAE,MAAM,IAAI,2BAA2B,CAAC,uBAAuB,EAAE,IAAI,CAAC,CAAC;IAClF,OAAO,MAAM,CAAC;AAChB,CAAC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A Finish: what the conversation says as it closes, and what it reports.
|
|
3
|
+
*
|
|
4
|
+
* Both ride in what the FINISH carries — the value the conversation's own cycle
|
|
5
|
+
* returns. `message` is reserved for the farewell, because a person reads it;
|
|
6
|
+
* everything else is for whoever runs the flow.
|
|
7
|
+
*/
|
|
8
|
+
import type { WorkflowConfig } from '../../types/workflow-config.js';
|
|
9
|
+
/** What it says as it closes. Empty for a silent ending. */
|
|
10
|
+
export declare function setEndMessage(config: WorkflowConfig, screenId: string, message: string): WorkflowConfig;
|
|
11
|
+
/**
|
|
12
|
+
* What the run reports when it ends here — a category, a team, a reference.
|
|
13
|
+
* The farewell rides in the same object and is kept.
|
|
14
|
+
*/
|
|
15
|
+
export declare function setEndResult(config: WorkflowConfig, screenId: string, value: Record<string, unknown>): WorkflowConfig;
|
|
16
|
+
//# sourceMappingURL=endings.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"endings.d.ts","sourceRoot":"","sources":["../../../src/conversational-flow/edit/endings.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gCAAgC,CAAC;AAOrE,4DAA4D;AAC5D,wBAAgB,aAAa,CAAC,MAAM,EAAE,cAAc,EAAE,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,cAAc,CAQvG;AAED;;;GAGG;AACH,wBAAgB,YAAY,CAAC,MAAM,EAAE,cAAc,EAAE,QAAQ,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,cAAc,CASrH"}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { asRec } from '../json.js';
|
|
2
|
+
import { caseFor } from '../locate.js';
|
|
3
|
+
import { ConversationalFlowEditError, requireFlow, settle } from '../settle.js';
|
|
4
|
+
import { partsOf } from '../shape.js';
|
|
5
|
+
import { END_MESSAGE_KEY } from '../types.js';
|
|
6
|
+
/** What it says as it closes. Empty for a silent ending. */
|
|
7
|
+
export function setEndMessage(config, screenId, message) {
|
|
8
|
+
requireEnding(requireFlow(config), screenId);
|
|
9
|
+
const text = message.trim();
|
|
10
|
+
return settle(config, (draft) => {
|
|
11
|
+
const carried = carriedBy(draft, requireFlow(draft), screenId);
|
|
12
|
+
if (text)
|
|
13
|
+
carried[END_MESSAGE_KEY] = text;
|
|
14
|
+
else
|
|
15
|
+
delete carried[END_MESSAGE_KEY];
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* What the run reports when it ends here — a category, a team, a reference.
|
|
20
|
+
* The farewell rides in the same object and is kept.
|
|
21
|
+
*/
|
|
22
|
+
export function setEndResult(config, screenId, value) {
|
|
23
|
+
requireEnding(requireFlow(config), screenId);
|
|
24
|
+
return settle(config, (draft) => {
|
|
25
|
+
const carried = carriedBy(draft, requireFlow(draft), screenId);
|
|
26
|
+
const farewell = carried[END_MESSAGE_KEY];
|
|
27
|
+
for (const key of Object.keys(carried))
|
|
28
|
+
delete carried[key];
|
|
29
|
+
Object.assign(carried, value);
|
|
30
|
+
if (typeof farewell === 'string' && farewell)
|
|
31
|
+
carried[END_MESSAGE_KEY] = farewell;
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
/** The object the Finish carries, live, so a caller can change it in place. */
|
|
35
|
+
function carriedBy(config, flow, screenId) {
|
|
36
|
+
const screen = requireEnding(flow, screenId);
|
|
37
|
+
const entry = caseFor(config, flow, screen);
|
|
38
|
+
const finish = entry ? partsOf(entry, flow.routeKey).rest.find((step) => step.type === 'FINISH') : undefined;
|
|
39
|
+
if (!finish)
|
|
40
|
+
throw new ConversationalFlowEditError(`“${screen.title}” doesn’t end the conversation.`);
|
|
41
|
+
if (!finish.config['with'])
|
|
42
|
+
finish.config['with'] = {};
|
|
43
|
+
return asRec(finish.config['with']);
|
|
44
|
+
}
|
|
45
|
+
function requireEnding(flow, id) {
|
|
46
|
+
const screen = flow.screens.find((s) => s.id === id);
|
|
47
|
+
if (!screen)
|
|
48
|
+
throw new ConversationalFlowEditError(`There is no screen “${id}”.`);
|
|
49
|
+
if (screen.kind !== 'end')
|
|
50
|
+
throw new ConversationalFlowEditError(`“${screen.title}” isn’t a Finish screen.`);
|
|
51
|
+
return screen;
|
|
52
|
+
}
|
|
53
|
+
//# sourceMappingURL=endings.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"endings.js","sourceRoot":"","sources":["../../../src/conversational-flow/edit/endings.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,KAAK,EAAY,MAAM,YAAY,CAAC;AAC7C,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AACvC,OAAO,EAAE,2BAA2B,EAAE,WAAW,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAChF,OAAO,E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+
/**
|
|
2
|
+
* Follow-up questions: an answer that asks something more before moving on.
|
|
3
|
+
*
|
|
4
|
+
* A screen with follow-ups carries a SWITCH after its question, and each answer
|
|
5
|
+
* that leads to one is a case in it. So the follow-up is asked in the same round
|
|
6
|
+
* of the conversation, inside the screen that asked first — it is not a screen of
|
|
7
|
+
* its own, has no place in the tree, and nothing else can link to it.
|
|
8
|
+
*
|
|
9
|
+
* Which is exactly why removing one is safe, and why turning such a screen into
|
|
10
|
+
* another kind is refused while it still has any.
|
|
11
|
+
*/
|
|
12
|
+
import type { WorkflowConfig } from '../../types/workflow-config.js';
|
|
13
|
+
/**
|
|
14
|
+
* Add an answer that asks something more.
|
|
15
|
+
*
|
|
16
|
+
* The follow-up offers the same ways back as the question above it, so someone
|
|
17
|
+
* who has changed their mind is never stuck inside an answer.
|
|
18
|
+
*/
|
|
19
|
+
export declare function addFollowUp(config: WorkflowConfig, promptId: string, args: {
|
|
20
|
+
label: string;
|
|
21
|
+
question: string;
|
|
22
|
+
}): {
|
|
23
|
+
config: WorkflowConfig;
|
|
24
|
+
promptId: string;
|
|
25
|
+
};
|
|
26
|
+
/** Take an answer's follow-up away, and the answer with it. */
|
|
27
|
+
export declare function removeFollowUp(config: WorkflowConfig, promptId: string, value: string): WorkflowConfig;
|
|
28
|
+
//# sourceMappingURL=followups.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"followups.d.ts","sourceRoot":"","sources":["../../../src/conversational-flow/edit/followups.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AACH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gCAAgC,CAAC;AAUrE;;;;;GAKG;AACH,wBAAgB,WAAW,CACzB,MAAM,EAAE,cAAc,EACtB,QAAQ,EAAE,MAAM,EAChB,IAAI,EAAE;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAA;CAAE,GACxC;IAAE,MAAM,EAAE,cAAc,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAA;CAAE,CAoC9C;AAED,+DAA+D;AAC/D,wBAAgB,cAAc,CAAC,MAAM,EAAE,cAAc,EAAE,QAAQ,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,cAAc,CAkBtG"}
|