@delurio/cli 0.1.1 → 0.3.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/CHANGELOG.md +26 -0
- package/README.md +42 -0
- package/SPEC.md +10 -8
- package/dist/changes.d.ts +7 -0
- package/dist/check.d.ts +23 -0
- package/dist/check.js +20 -0
- package/dist/cli.d.ts +2 -0
- package/dist/cli.js +45 -14
- package/dist/compare.d.ts +34 -0
- package/dist/diff-flow.d.ts +33 -0
- package/dist/diff-nav.d.ts +20 -0
- package/dist/diff.d.ts +23 -0
- package/dist/edges.d.ts +21 -0
- package/dist/expr.d.ts +26 -0
- package/dist/graph.d.ts +121 -0
- package/dist/html.d.ts +20 -0
- package/dist/index-page.d.ts +12 -0
- package/dist/kit.d.ts +53 -0
- package/dist/mermaid.d.ts +3 -0
- package/dist/model.d.ts +56 -0
- package/dist/nav-page.d.ts +15 -0
- package/dist/nav.d.ts +153 -0
- package/dist/schemas.d.ts +10 -0
- package/dist/schemas.js +256 -0
- package/dist/spine.d.ts +5 -0
- package/dist/starts.d.ts +11 -0
- package/dist/story.d.ts +17 -0
- package/dist/watch.d.ts +5 -0
- package/dist/watch.js +114 -0
- package/dist/wireframe.d.ts +19 -0
- package/package.json +16 -2
- package/schemas/catalog.schema.json +13 -0
- package/schemas/domain.schema.json +305 -0
- package/schemas/flow.schema.json +346 -0
- package/schemas/nav.schema.json +292 -0
- package/schemas/ui.schema.json +250 -0
package/dist/html.d.ts
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { Graph } from './graph.ts';
|
|
2
|
+
import type { AssertionResult, Exploration, FinalPath, Model } from './model.ts';
|
|
3
|
+
import type { Story } from './story.ts';
|
|
4
|
+
import type { Kit } from './kit.ts';
|
|
5
|
+
import type { HandOver } from './starts.ts';
|
|
6
|
+
export declare const CSS = "\n:root { --bg:#fafaf9; --surface:#ffffff; --ink:#1c1917; --muted:#6b6560; --line:#d6d3d1; --accent:#1d4ed8; --accent-bg:#eef3ff; --ok:#15803d; --bad:#b91c1c; --server:#eeeeec; --focus:#1d4ed8; --ai:#7e22ce; --ai-bg:#f5edff; --agent:#c2410c; --agent-bg:#fff1e8; --ci:#0f766e; --ci-bg:#e6f6f3; --ok-bg:#eaf7ee; }\n@media (prefers-color-scheme: dark) { :root { --bg:#161513; --surface:#1f1d1b; --ink:#f2efec; --muted:#a8a29e; --line:#44403c; --accent:#8fb0ff; --accent-bg:#1c2438; --ok:#5fcf85; --bad:#f08080; --server:#2a2826; --focus:#8fb0ff; --ai:#c99bff; --ai-bg:#2a2135; --agent:#ff9a66; --agent-bg:#33241b; --ci:#5fd4c4; --ci-bg:#1a2e2b; --ok-bg:#16291d; } }\n* { box-sizing: border-box; }\nbody { margin: 0; background: var(--bg); color: var(--ink); font: 16px/1.55 system-ui, -apple-system, \"Segoe UI\", sans-serif; }\nmain { max-width: 1000px; margin: 0 auto; padding: 28px 16px 80px; }\nh1 { font-size: 30px; line-height: 1.2; margin: 6px 0 8px; } h2 { font-size: 21px; margin: 44px 0 12px; } h3 { font-size: 16px; margin: 0; }\ncode, pre, .mono { font-family: ui-monospace, \"SF Mono\", Menlo, Consolas, monospace; font-size: 13px; }\n.muted { color: var(--muted); } .label { margin: 0 0 6px; font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }\n.eyebrow { margin: 0; color: var(--muted); } .lede { font-size: 18px; max-width: 46em; margin: 0; }\n.tag { display: inline-block; padding: 1px 8px; border: 1px solid var(--line); border-radius: 99px; font-size: 12px; color: var(--muted); vertical-align: middle; }\n.scroll { overflow-x: auto; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); }\ntable { border-collapse: collapse; width: 100%; } th, td { text-align: left; vertical-align: top; padding: 8px 12px; border-bottom: 1px solid var(--line); } th { font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); } tr:last-child td { border-bottom: 0; }\ntd ol { margin: 0; padding-left: 20px; }\n.ok { color: var(--ok); font-weight: 600; } .bad { color: var(--bad); font-weight: 600; }\n.story { margin-top: 28px; padding: 18px 22px; border: 1px solid var(--line); border-left: 5px solid var(--accent); border-radius: 10px; background: var(--surface); }\n.story h2 { margin: 0 0 6px; } .story .given { margin: 0 0 8px; } .story ol { margin: 0; padding-left: 26px; } .story li { margin: 5px 0; padding-left: 4px; } .story .result { margin: 10px 0 0; font-weight: 600; }\n.views input { margin-right: 8px; accent-color: var(--accent); } .views label { display: inline-block; margin: 0 0 10px; cursor: pointer; }\n.views .panel-full { display: none; } .views input:checked ~ .panel-main { display: none; } .views input:checked ~ .panel-full { display: block; }\nsvg.spine { display: block; width: 100%; height: auto; padding: 8px; background: var(--surface); margin: 0 auto; }\n.spine .edge { fill: none; stroke-width: 1.5; } .spine .edge-user { stroke: var(--muted); } .spine .edge-system { stroke: var(--muted); } .spine .edge-route { stroke: var(--muted); stroke-dasharray: 2 4; } .spine .edge-fail { stroke: var(--bad); stroke-dasharray: 7 4; } .spine .edge-unused { stroke: var(--line); }\n.spine .edge-main { stroke: var(--accent); stroke-width: 3.5; stroke-dasharray: none; }\n.spine .arrow { fill: var(--muted); } .spine .arrow-fail { fill: var(--bad); } .spine .arrow-main { fill: var(--accent); }\n.spine .elabel rect { fill: var(--surface); stroke: var(--line); } .spine .elabel text { fill: var(--ink); font: 13px system-ui, sans-serif; } .spine .elabel-fail text { fill: var(--bad); } .spine .elabel-main rect { stroke: var(--accent); }\n.spine .node rect { fill: var(--surface); stroke: var(--ink); stroke-width: 1.6; } .spine .node-server rect { fill: var(--server); stroke: var(--muted); stroke-dasharray: 5 3; }\n.spine .node-subflow rect { stroke: var(--accent); } .spine .node-subflow rect.inner { fill: none; stroke-width: 1; }\n.spine .on-main rect { stroke-width: 3; } .spine .node-server.on-main rect { stroke: var(--accent); }\n.spine .exit-never rect { stroke: var(--bad); stroke-width: 3; } .spine .exit-error rect { stroke-dasharray: 6 3; } .spine .exit-left rect { stroke-dasharray: 2 3; stroke: var(--muted); } .spine .exit-success rect { stroke: var(--ok); stroke-width: 3; }\n.spine .node.by-human rect { fill: var(--surface); stroke: var(--ink); stroke-dasharray: none; }\n.spine .node.by-ai rect { fill: var(--ai-bg); stroke: var(--ai); stroke-dasharray: none; }\n.spine .node.by-agent rect { fill: var(--agent-bg); stroke: var(--agent); stroke-dasharray: none; } .spine .node.by-agent rect.inner { fill: none; stroke-width: 1; }\n.spine .node.by-ci rect { fill: var(--ci-bg); stroke: var(--ci); stroke-dasharray: none; }\n.spine .node.goal rect { fill: var(--ok-bg); stroke: var(--ok); stroke-width: 3.5; stroke-dasharray: none; }\n.spine .node.on-main rect { stroke-width: 3.5; }\n.spine .nmore { fill: var(--muted); font: 600 11px system-ui, sans-serif; }\n.legend .sw { display: inline-flex; align-items: center; gap: 6px; } .legend svg { flex: none; }\n.legend .sw-node rect { stroke-width: 1.6; }\n.legend .sw-human rect { fill: var(--surface); stroke: var(--ink); } .legend .sw-ai rect { fill: var(--ai-bg); stroke: var(--ai); } .legend .sw-agent rect { fill: var(--agent-bg); stroke: var(--agent); } .legend .sw-agent rect.inner { fill: none; stroke-width: 1; }\n.legend .sw-ci rect { fill: var(--ci-bg); stroke: var(--ci); } .legend .sw-goal rect { fill: var(--ok-bg); stroke: var(--ok); stroke-width: 3; } .legend .sw-server rect { fill: var(--server); stroke: var(--muted); stroke-dasharray: 4 2; }\n.legend .sw-screen rect { fill: var(--surface); stroke: var(--ink); } .legend .sw-subflow rect { fill: var(--surface); stroke: var(--accent); }\n.legend .sw-node.sw-fail rect { fill: var(--surface); stroke: var(--bad); stroke-width: 3; }\n.legend .sw-line path { fill: none; stroke-width: 3; } .legend .sw-main path { stroke: var(--accent); stroke-width: 3.5; } .legend .sw-fail path { stroke: var(--bad); stroke-dasharray: 6 3; } .legend .sw-route path { stroke: var(--muted); stroke-dasharray: 2 3; }\n.covers { display: grid; gap: 10px; } .covers .cv { border: 1px solid var(--line); border-radius: 10px; background: var(--surface); padding: 10px 14px; } .covers ul { margin: 4px 0 0; padding-left: 20px; }\n.spine .node-unreachable rect { stroke: var(--bad); fill: none; }\n.spine .nname { fill: var(--ink); font: 600 14.5px system-ui, sans-serif; } .spine .nline { fill: var(--muted); font: 11.5px ui-monospace, Menlo, Consolas, monospace; } .spine .start { fill: var(--ink); }\n.spine a:focus-visible .node rect, .spine a:hover .node rect { stroke: var(--focus); stroke-width: 3; }\n.legend { display: flex; flex-wrap: wrap; gap: 4px 18px; margin: 10px 0 0; font-size: 14px; color: var(--muted); }\n.screens { display: grid; gap: 18px; }\n.screen { border: 1px solid var(--line); border-radius: 10px; background: var(--surface); padding: 14px 16px 16px; scroll-margin-top: 16px; }\n.screen:target { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-bg); }\n.screen header { display: flex; align-items: center; gap: 10px; } .screen > p { margin: 4px 0 10px; }\n.wf { border: 1px dashed var(--line); border-radius: 8px; padding: 14px; display: grid; gap: 10px; background: var(--bg); max-width: 560px; }\n.wf-item { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; padding: 2px; border-radius: 4px; }\n.wf-cond { outline: 1.5px dashed var(--muted); outline-offset: 2px; } .wf-focus { outline: 2.5px solid var(--focus); outline-offset: 2px; }\n.wf-h { margin: 0; font-size: 17px; } .wf-t { margin: 0; color: var(--muted); }\n.wf-row { display: flex; flex-wrap: wrap; gap: 10px; }\n.wf-btn, .wf-link { font: inherit; border-radius: 6px; padding: 6px 14px; border: 1px solid var(--ink); background: var(--surface); color: var(--ink); }\n.wf-confirm { background: var(--ink); color: var(--bg); } .wf-link { border: 0; background: none; color: var(--accent); text-decoration: underline; padding: 0; }\n.wf button:disabled { opacity: .45; }\n.wf-list { margin: 0; padding-left: 20px; display: grid; gap: 2px; }\n.wf-status { color: var(--muted); font-style: italic; } .wf-alert { border: 1.5px solid var(--bad); border-radius: 6px; padding: 6px 10px; }\n.wf-field { display: grid; gap: 4px; } .wf-input { font: inherit; border: 1px solid var(--muted); border-radius: 6px; padding: 6px 10px; background: var(--surface); color: var(--ink); }\n.wf-unmapped { border: 1.5px solid var(--bad); padding: 6px 10px; }\n.chip { font: 11px ui-monospace, Menlo, Consolas, monospace; color: var(--muted); border: 1px solid var(--line); border-radius: 4px; padding: 0 5px; white-space: nowrap; }\ndetails { margin-top: 12px; } summary { cursor: pointer; color: var(--muted); }\ndetails.ax-wrap { margin-top: 10px; } pre.ax { margin: 8px 0 0; padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px; white-space: pre-wrap; overflow-wrap: anywhere; background: var(--bg); line-height: 1.55; }\ndl.guards { margin: 10px 0 0; display: grid; grid-template-columns: max-content 1fr; gap: 3px 14px; } dl.guards dt { font-weight: 600; } dl.guards dd { margin: 0; }\nul.checks { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; } ul.checks li { padding-left: 26px; position: relative; } ul.checks li::before { content: \"\u2713\"; position: absolute; left: 4px; color: var(--ok); font-weight: 700; } ul.checks li.fail::before { content: \"\u2717\"; color: var(--bad); }\nfooter { margin-top: 56px; color: var(--muted); font-size: 13px; }\n";
|
|
7
|
+
export interface PageInput {
|
|
8
|
+
g: Graph;
|
|
9
|
+
m: Model;
|
|
10
|
+
ex: Exploration;
|
|
11
|
+
assertions: AssertionResult[];
|
|
12
|
+
finals: FinalPath[];
|
|
13
|
+
main: Story | null;
|
|
14
|
+
spineMain: string;
|
|
15
|
+
spineFull: string;
|
|
16
|
+
screens: string;
|
|
17
|
+
kit?: Kit | null;
|
|
18
|
+
handOvers?: HandOver[];
|
|
19
|
+
}
|
|
20
|
+
export declare function renderPage(p: PageInput): string;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export interface IndexEntry {
|
|
2
|
+
path: string;
|
|
3
|
+
kind: 'flow' | 'nav';
|
|
4
|
+
id: string | null;
|
|
5
|
+
title: string;
|
|
6
|
+
status: string | null;
|
|
7
|
+
holds: number;
|
|
8
|
+
total: number;
|
|
9
|
+
warnings: string[];
|
|
10
|
+
error: string | null;
|
|
11
|
+
}
|
|
12
|
+
export declare function renderIndexPage(root: string, entries: IndexEntry[]): string;
|
package/dist/kit.d.ts
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
export declare class KitError extends Error {
|
|
2
|
+
}
|
|
3
|
+
declare const SLOTS: readonly ['text', 'name', 'id', 'intent', 'children'];
|
|
4
|
+
declare const FLAGS: readonly ['disabled', 'named', 'conditional'];
|
|
5
|
+
type Slot = (typeof SLOTS)[number];
|
|
6
|
+
type Flag = (typeof FLAGS)[number];
|
|
7
|
+
type Part = {
|
|
8
|
+
lit: string;
|
|
9
|
+
} | {
|
|
10
|
+
slot: Slot;
|
|
11
|
+
ctx: 'text' | 'dq' | 'sq';
|
|
12
|
+
} | {
|
|
13
|
+
flag: Flag;
|
|
14
|
+
negate: boolean;
|
|
15
|
+
parts: Part[];
|
|
16
|
+
};
|
|
17
|
+
export interface Template {
|
|
18
|
+
source: string;
|
|
19
|
+
parts: Part[];
|
|
20
|
+
}
|
|
21
|
+
export interface KitComponent {
|
|
22
|
+
template: Template;
|
|
23
|
+
roles: Record<string, Template>;
|
|
24
|
+
intents?: Record<string, string>;
|
|
25
|
+
}
|
|
26
|
+
export interface Kit {
|
|
27
|
+
id: string;
|
|
28
|
+
title: string;
|
|
29
|
+
file: string;
|
|
30
|
+
components: Record<string, KitComponent>;
|
|
31
|
+
light: Array<[string, string]>;
|
|
32
|
+
dark: Array<[string, string]>;
|
|
33
|
+
css: string;
|
|
34
|
+
zoom: number;
|
|
35
|
+
}
|
|
36
|
+
export interface Fill {
|
|
37
|
+
id: string;
|
|
38
|
+
text: string;
|
|
39
|
+
name: string;
|
|
40
|
+
intent: string | undefined;
|
|
41
|
+
role: string | undefined;
|
|
42
|
+
children?: string;
|
|
43
|
+
disabled: boolean;
|
|
44
|
+
named: boolean;
|
|
45
|
+
conditional: boolean;
|
|
46
|
+
}
|
|
47
|
+
export declare function drawWith(kit: Kit, component: string, f: Fill, warn: (m: string) => void): string | null;
|
|
48
|
+
export declare function mark(html: string, id: string, chips: string): string;
|
|
49
|
+
export declare function loadKit(path: string): Kit;
|
|
50
|
+
export declare function resolveKit(graphDir: string, uiKit: string | undefined, flagValue: string | undefined): Kit | null;
|
|
51
|
+
export declare function kitCss(kit: Kit, target: 'page' | 'stage'): string;
|
|
52
|
+
export declare function kitStageScript(kit: Kit): string;
|
|
53
|
+
export {};
|
package/dist/model.d.ts
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import type { Flow, Scalar } from './graph.ts';
|
|
2
|
+
import type { Value } from './expr.ts';
|
|
3
|
+
export declare class ModelError extends Error {
|
|
4
|
+
}
|
|
5
|
+
export interface Step {
|
|
6
|
+
event: string | null;
|
|
7
|
+
target: string;
|
|
8
|
+
ctx: Scalar[];
|
|
9
|
+
taken: string;
|
|
10
|
+
}
|
|
11
|
+
export interface Config {
|
|
12
|
+
state: string;
|
|
13
|
+
ctx: Scalar[];
|
|
14
|
+
parent: number;
|
|
15
|
+
event: string | null;
|
|
16
|
+
}
|
|
17
|
+
export declare class Model {
|
|
18
|
+
readonly flow: Flow;
|
|
19
|
+
readonly vars: string[];
|
|
20
|
+
readonly domains: Scalar[][];
|
|
21
|
+
constructor(flow: Flow);
|
|
22
|
+
private lookup;
|
|
23
|
+
test(expr: string, state: string, ctx: Scalar[]): boolean;
|
|
24
|
+
value(expr: string, state: string, ctx: Scalar[]): Value;
|
|
25
|
+
private apply;
|
|
26
|
+
steps(state: string, ctx: Scalar[]): Step[];
|
|
27
|
+
initials(): Scalar[][];
|
|
28
|
+
scenario(ctx: Scalar[]): Record<string, Scalar>;
|
|
29
|
+
}
|
|
30
|
+
export interface Exploration {
|
|
31
|
+
configs: Config[];
|
|
32
|
+
starts: number;
|
|
33
|
+
taken: Set<string>;
|
|
34
|
+
atState: Map<string, number>;
|
|
35
|
+
branchCounts: Map<string, number[]>;
|
|
36
|
+
}
|
|
37
|
+
export declare function explore(m: Model, from?: Scalar[][], keep?: (at: Config, s: Step) => boolean): Exploration;
|
|
38
|
+
export interface PathResult {
|
|
39
|
+
events: string[];
|
|
40
|
+
start: Record<string, Scalar>;
|
|
41
|
+
}
|
|
42
|
+
export declare function pathTo(m: Model, ex: Exploration, index: number): PathResult;
|
|
43
|
+
export interface AssertionResult {
|
|
44
|
+
id: string;
|
|
45
|
+
never: string;
|
|
46
|
+
say?: string;
|
|
47
|
+
violation?: PathResult & {
|
|
48
|
+
state: string;
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
export declare function checkAssertions(m: Model, ex: Exploration): AssertionResult[];
|
|
52
|
+
export interface FinalPath extends PathResult {
|
|
53
|
+
state: string;
|
|
54
|
+
index: number;
|
|
55
|
+
}
|
|
56
|
+
export declare function finalPaths(m: Model, ex: Exploration): FinalPath[];
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { Finding, Goalcheck, MenuRow, NavGraph, PersonaView, RepoCheck } from './nav.ts';
|
|
2
|
+
export interface NavPageInput {
|
|
3
|
+
g: NavGraph;
|
|
4
|
+
views: PersonaView[];
|
|
5
|
+
rows: MenuRow[];
|
|
6
|
+
goals: Goalcheck[];
|
|
7
|
+
found: Finding[];
|
|
8
|
+
repo: {
|
|
9
|
+
checks: RepoCheck[];
|
|
10
|
+
head: string | null;
|
|
11
|
+
} | null;
|
|
12
|
+
warnings: string[];
|
|
13
|
+
}
|
|
14
|
+
export declare function renderNavPage(p: NavPageInput): string;
|
|
15
|
+
export declare function renderNavMermaid(g: NavGraph): string;
|
package/dist/nav.d.ts
ADDED
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
import type { Value } from './expr.ts';
|
|
2
|
+
export type PageKind = 'screen' | 'placeholder' | 'missing' | 'redirect' | 'external';
|
|
3
|
+
export type FrameId = string;
|
|
4
|
+
export type How = 'auto' | 'menu' | 'picker' | 'user' | 'link' | 'button';
|
|
5
|
+
export interface FrameSpec {
|
|
6
|
+
title: string;
|
|
7
|
+
menu?: string;
|
|
8
|
+
shows?: {
|
|
9
|
+
fact: string;
|
|
10
|
+
};
|
|
11
|
+
}
|
|
12
|
+
interface FactSpec {
|
|
13
|
+
values?: Value[];
|
|
14
|
+
of?: string[];
|
|
15
|
+
say?: string;
|
|
16
|
+
}
|
|
17
|
+
interface EntrySpec {
|
|
18
|
+
id?: string;
|
|
19
|
+
from: string | string[];
|
|
20
|
+
to: string;
|
|
21
|
+
how: string;
|
|
22
|
+
label?: string;
|
|
23
|
+
when?: string;
|
|
24
|
+
clicks?: number;
|
|
25
|
+
data?: boolean;
|
|
26
|
+
back?: boolean;
|
|
27
|
+
}
|
|
28
|
+
export interface ExtractCfg {
|
|
29
|
+
adapter?: string;
|
|
30
|
+
names?: Record<string, string>;
|
|
31
|
+
titles?: Record<string, string>;
|
|
32
|
+
locales?: string[];
|
|
33
|
+
}
|
|
34
|
+
export interface Page {
|
|
35
|
+
id: string;
|
|
36
|
+
route: string;
|
|
37
|
+
title: string;
|
|
38
|
+
titleKey: string | null;
|
|
39
|
+
kind: PageKind;
|
|
40
|
+
frame: FrameId;
|
|
41
|
+
source: string | null;
|
|
42
|
+
opensFor: string | null;
|
|
43
|
+
pageCodes: string | null;
|
|
44
|
+
evidence: string | null;
|
|
45
|
+
refusal: string | null;
|
|
46
|
+
}
|
|
47
|
+
export interface Entry {
|
|
48
|
+
id: string;
|
|
49
|
+
spec: number;
|
|
50
|
+
from: string;
|
|
51
|
+
ofFrame: FrameId | null;
|
|
52
|
+
to: string;
|
|
53
|
+
how: How;
|
|
54
|
+
label: string;
|
|
55
|
+
labelKey: string | null;
|
|
56
|
+
when: string | null;
|
|
57
|
+
clicks: number;
|
|
58
|
+
data: boolean;
|
|
59
|
+
back: boolean;
|
|
60
|
+
order: number;
|
|
61
|
+
}
|
|
62
|
+
export interface Persona {
|
|
63
|
+
id: string;
|
|
64
|
+
title: string;
|
|
65
|
+
say: string;
|
|
66
|
+
facts: Record<string, Value>;
|
|
67
|
+
}
|
|
68
|
+
export interface Goal {
|
|
69
|
+
id: string;
|
|
70
|
+
say: string;
|
|
71
|
+
page: string;
|
|
72
|
+
for: string[];
|
|
73
|
+
within: number;
|
|
74
|
+
}
|
|
75
|
+
export interface NavGraph {
|
|
76
|
+
dir: string;
|
|
77
|
+
adapter: string | null;
|
|
78
|
+
frames: Record<string, FrameSpec>;
|
|
79
|
+
menuFrames: string[];
|
|
80
|
+
id: string;
|
|
81
|
+
title: string;
|
|
82
|
+
status: string;
|
|
83
|
+
summary: string;
|
|
84
|
+
locale: string;
|
|
85
|
+
source: Record<string, string>;
|
|
86
|
+
facts: Record<string, FactSpec>;
|
|
87
|
+
guards: Record<string, string>;
|
|
88
|
+
pages: Record<string, Page>;
|
|
89
|
+
entries: Entry[];
|
|
90
|
+
specs: EntrySpec[];
|
|
91
|
+
personas: Persona[];
|
|
92
|
+
goals: Goal[];
|
|
93
|
+
notModeled: string[];
|
|
94
|
+
catalog: Record<string, string>;
|
|
95
|
+
}
|
|
96
|
+
export declare const frameLevel: (e: Entry) => boolean;
|
|
97
|
+
export declare function loadNav(dir: string, locale?: string, read?: (file: string) => string): {
|
|
98
|
+
g: NavGraph;
|
|
99
|
+
warnings: string[];
|
|
100
|
+
};
|
|
101
|
+
export declare function holds(g: NavGraph, p: Persona, expr: string | null): boolean;
|
|
102
|
+
export declare const refusedFor: (g: NavGraph, p: Persona, page: string) => boolean;
|
|
103
|
+
export interface Reach {
|
|
104
|
+
page: string;
|
|
105
|
+
clicks: number;
|
|
106
|
+
via: Entry | null;
|
|
107
|
+
prev: string | null;
|
|
108
|
+
usesData: boolean;
|
|
109
|
+
}
|
|
110
|
+
export declare function walk(g: NavGraph, p: Persona): Map<string, Reach>;
|
|
111
|
+
export declare function pathTo(reach: Map<string, Reach>, page: string): Entry[];
|
|
112
|
+
export type Standing = 'ok' | 'placeholder' | 'missing' | 'refused' | 'unreachable';
|
|
113
|
+
export interface PersonaView {
|
|
114
|
+
persona: Persona;
|
|
115
|
+
reach: Map<string, Reach>;
|
|
116
|
+
standing: Record<string, Standing>;
|
|
117
|
+
landing: string | null;
|
|
118
|
+
}
|
|
119
|
+
export declare function viewOf(g: NavGraph, p: Persona): PersonaView;
|
|
120
|
+
export declare const frameReached: (g: NavGraph, v: PersonaView, frame: FrameId) => boolean;
|
|
121
|
+
export interface MenuCell {
|
|
122
|
+
shown: boolean;
|
|
123
|
+
standing: Standing | null;
|
|
124
|
+
}
|
|
125
|
+
export interface MenuRow {
|
|
126
|
+
spec: number;
|
|
127
|
+
frame: FrameId;
|
|
128
|
+
entry: Entry;
|
|
129
|
+
cells: MenuCell[];
|
|
130
|
+
frameKnown: boolean[];
|
|
131
|
+
}
|
|
132
|
+
export declare function menuRows(g: NavGraph, views: PersonaView[]): MenuRow[];
|
|
133
|
+
export interface Finding {
|
|
134
|
+
level: 'problem' | 'note';
|
|
135
|
+
code: string;
|
|
136
|
+
say: string;
|
|
137
|
+
detail: string[];
|
|
138
|
+
}
|
|
139
|
+
export interface Goalcheck {
|
|
140
|
+
goal: Goal;
|
|
141
|
+
persona: Persona;
|
|
142
|
+
outcome: 'ok' | 'too many clicks' | 'not built' | 'does not exist' | 'refused' | 'cannot reach';
|
|
143
|
+
clicks: number | null;
|
|
144
|
+
}
|
|
145
|
+
export declare function checkGoals(g: NavGraph, views: PersonaView[]): Goalcheck[];
|
|
146
|
+
export declare function findings(g: NavGraph, views: PersonaView[], goals: Goalcheck[]): Finding[];
|
|
147
|
+
export interface RepoCheck {
|
|
148
|
+
ok: boolean;
|
|
149
|
+
what: string;
|
|
150
|
+
detail: string;
|
|
151
|
+
}
|
|
152
|
+
export declare function guardCodes(g: NavGraph, src: string, depth?: number): Set<string>;
|
|
153
|
+
export {};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export type SchemaKind = 'flow' | 'ui' | 'domain' | 'nav' | 'catalog';
|
|
2
|
+
export interface SchemaFinding {
|
|
3
|
+
line: number;
|
|
4
|
+
column: number;
|
|
5
|
+
message: string;
|
|
6
|
+
graph: string | null;
|
|
7
|
+
element: string;
|
|
8
|
+
}
|
|
9
|
+
export declare function schemaKindOf(file: string): SchemaKind | null;
|
|
10
|
+
export declare function validateFile(file: string): SchemaFinding[];
|
package/dist/schemas.js
ADDED
|
@@ -0,0 +1,256 @@
|
|
|
1
|
+
// The JSON Schemas of schemas/ (one per kind of graph file, SPEC.md §12) as `check` applies them: a file is validated
|
|
2
|
+
// against its kind's schema, and each failure is placed at its line and column through the YAML document and said in
|
|
3
|
+
// words a writer can act on: the key that is not one, the key it was probably meant to be, why an if/then rule exists
|
|
4
|
+
// (its `$comment`), and the comma that cut a value inside `{ }`. The schemas are read from the package's own folder,
|
|
5
|
+
// beside src/ and dist/ alike.
|
|
6
|
+
import { existsSync, readFileSync } from 'node:fs';
|
|
7
|
+
import { basename, dirname, join } from 'node:path';
|
|
8
|
+
import { Ajv2020 } from 'ajv/dist/2020.js';
|
|
9
|
+
import addFormatsModule from 'ajv-formats';
|
|
10
|
+
import { isMap, isSeq, LineCounter, parse, parseDocument } from 'yaml';
|
|
11
|
+
const FORMAT = 'delurio-graph/0';
|
|
12
|
+
const KINDS = ['flow', 'ui', 'domain', 'nav', 'catalog'];
|
|
13
|
+
// the kind of graph file, by its name: null for a file no schema covers (binding, tutorial, kit, anchors.lock)
|
|
14
|
+
export function schemaKindOf(file) {
|
|
15
|
+
const name = basename(file);
|
|
16
|
+
if (name === 'flow.yaml' || name === 'ui.yaml' || name === 'domain.yaml')
|
|
17
|
+
return name.slice(0, -'.yaml'.length);
|
|
18
|
+
if (name === 'nav.yaml' || name === 'nav.extracted.yaml')
|
|
19
|
+
return 'nav';
|
|
20
|
+
if (name.endsWith('.json') && basename(dirname(file)) === 'catalog')
|
|
21
|
+
return 'catalog';
|
|
22
|
+
return null;
|
|
23
|
+
}
|
|
24
|
+
let compiled = null;
|
|
25
|
+
// compiled once, on first use; strictRequired is off because an if/then names keys its branch does not declare
|
|
26
|
+
function schemas() {
|
|
27
|
+
if (compiled !== null)
|
|
28
|
+
return compiled;
|
|
29
|
+
const ajv = new Ajv2020({ allErrors: true, verbose: true, strict: true, strictRequired: false, allowUnionTypes: true });
|
|
30
|
+
addFormatsModule.default(ajv);
|
|
31
|
+
const roots = {};
|
|
32
|
+
const validators = {};
|
|
33
|
+
for (const kind of KINDS)
|
|
34
|
+
roots[kind] = JSON.parse(readFileSync(new URL(`../schemas/${kind}.schema.json`, import.meta.url), 'utf8'));
|
|
35
|
+
for (const kind of KINDS)
|
|
36
|
+
validators[kind] = ajv.compile(roots[kind]);
|
|
37
|
+
compiled = { roots, validators };
|
|
38
|
+
return compiled;
|
|
39
|
+
}
|
|
40
|
+
const steps = (pointer) => (pointer === '' ? [] : pointer.slice(1).split('/').map((t) => t.replace(/~1/g, '/').replace(/~0/g, '~')));
|
|
41
|
+
const escape = (step) => step.replace(/~/g, '~0').replace(/\//g, '~1');
|
|
42
|
+
const within = (path, base) => path === base || path.startsWith(`${base}/`);
|
|
43
|
+
const keyOf = (pair) => String(pair.key?.value ?? pair.key);
|
|
44
|
+
// the YAML node at a JSON pointer; with `name`, the key `name` of the map there, that map and the key's value
|
|
45
|
+
function place(doc, pointer, name) {
|
|
46
|
+
let node = doc.contents;
|
|
47
|
+
for (const t of steps(pointer)) {
|
|
48
|
+
const next = isMap(node) ? node.items.find((p) => keyOf(p) === t)?.value : isSeq(node) ? node.items[Number(t)] : undefined;
|
|
49
|
+
if (next === undefined || next === null)
|
|
50
|
+
break;
|
|
51
|
+
node = next;
|
|
52
|
+
}
|
|
53
|
+
if (name === undefined || !isMap(node))
|
|
54
|
+
return { at: node };
|
|
55
|
+
const pair = node.items.find((p) => keyOf(p) === name);
|
|
56
|
+
return { at: pair?.key ?? node, map: node, value: pair?.value };
|
|
57
|
+
}
|
|
58
|
+
// a schema and the ones its `$ref`s name, inside the same file
|
|
59
|
+
function chain(root, schema) {
|
|
60
|
+
const out = [];
|
|
61
|
+
for (let s = schema; s !== null && typeof s === 'object' && out.length < 8;) {
|
|
62
|
+
const here = s;
|
|
63
|
+
out.push(here);
|
|
64
|
+
const ref = here.$ref;
|
|
65
|
+
s = typeof ref === 'string' && ref.startsWith('#/') ? ref.slice(2).split('/').reduce((x, k) => x?.[k], root) : undefined;
|
|
66
|
+
}
|
|
67
|
+
return out;
|
|
68
|
+
}
|
|
69
|
+
// edits between two names, a swap of two neighbours counting as one (titel, title)
|
|
70
|
+
function distance(a, b) {
|
|
71
|
+
const d = Array.from({ length: a.length + 1 }, (_, i) => [i, ...Array(b.length).fill(0)]);
|
|
72
|
+
for (let j = 1; j <= b.length; j++)
|
|
73
|
+
d[0][j] = j;
|
|
74
|
+
for (let i = 1; i <= a.length; i++) {
|
|
75
|
+
for (let j = 1; j <= b.length; j++) {
|
|
76
|
+
d[i][j] = Math.min(d[i - 1][j] + 1, d[i][j - 1] + 1, d[i - 1][j - 1] + (a[i - 1] === b[j - 1] ? 0 : 1));
|
|
77
|
+
if (i > 1 && j > 1 && a[i - 1] === b[j - 2] && a[i - 2] === b[j - 1])
|
|
78
|
+
d[i][j] = Math.min(d[i][j], d[i - 2][j - 2] + 1);
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
return d[a.length][b.length];
|
|
82
|
+
}
|
|
83
|
+
const KIND_WORDS = { object: 'an object', array: 'a list', string: 'a string', integer: 'an integer', number: 'a number', boolean: 'true or false', null: 'null' };
|
|
84
|
+
const either = (xs) => (xs.length <= 1 ? xs.join('') : `${xs.slice(0, -1).join(', ')} or ${xs[xs.length - 1]}`);
|
|
85
|
+
const quoted = (xs) => either(xs.map((x) => JSON.stringify(x)));
|
|
86
|
+
function message(e, root) {
|
|
87
|
+
const p = e.params;
|
|
88
|
+
switch (e.keyword) {
|
|
89
|
+
case 'additionalProperties':
|
|
90
|
+
case 'unevaluatedProperties': {
|
|
91
|
+
const name = String(p.additionalProperty ?? p.unevaluatedProperty);
|
|
92
|
+
const known = chain(root, e.parentSchema).flatMap((x) => Object.keys(x.properties ?? {}));
|
|
93
|
+
const near = known.filter((k) => distance(k.toLowerCase(), name.toLowerCase()) <= Math.min(2, Math.max(1, Math.floor(k.length / 3))));
|
|
94
|
+
return `"${name}" is not a key here${near.length > 0 ? `; did you mean ${quoted(near)}?` : ''}`;
|
|
95
|
+
}
|
|
96
|
+
case 'required':
|
|
97
|
+
return `${p.missingProperty.map((k) => JSON.stringify(k)).join(' or ')} is missing`;
|
|
98
|
+
case 'enum': {
|
|
99
|
+
const allowed = p.allowedValues;
|
|
100
|
+
return allowed.length <= 12 ? `must be ${quoted(allowed)}` : `${JSON.stringify(e.data)} is not one of its ${allowed.length} values`;
|
|
101
|
+
}
|
|
102
|
+
case 'const':
|
|
103
|
+
return `must be ${JSON.stringify(p.allowedValue)}`;
|
|
104
|
+
case 'type':
|
|
105
|
+
return `must be ${either(p.type.map((t) => KIND_WORDS[t] ?? t))}`;
|
|
106
|
+
case 'pattern':
|
|
107
|
+
return `${JSON.stringify(e.data)} does not match ${String(p.pattern)}`;
|
|
108
|
+
case 'propertyNames': {
|
|
109
|
+
const said = chain(root, e.parentSchema?.propertyNames).find((x) => typeof x.description === 'string')?.description;
|
|
110
|
+
return `the name "${String(p.propertyName)}" is not allowed${said === undefined ? '' : `: ${said.split('. ')[0].replace(/\.$/, '')}`}`;
|
|
111
|
+
}
|
|
112
|
+
case 'false schema':
|
|
113
|
+
return 'is not allowed here';
|
|
114
|
+
case 'oneOf':
|
|
115
|
+
return 'matches more than one of its forms';
|
|
116
|
+
case 'minItems':
|
|
117
|
+
case 'maxItems':
|
|
118
|
+
case 'minProperties':
|
|
119
|
+
case 'maxProperties': {
|
|
120
|
+
const n = Number(p.limit);
|
|
121
|
+
const what = e.keyword.endsWith('Items') ? (n === 1 ? 'item' : 'items') : n === 1 ? 'key' : 'keys';
|
|
122
|
+
return e.keyword.startsWith('min') ? `needs at least ${n} ${what}` : `has more than ${n} ${what}`;
|
|
123
|
+
}
|
|
124
|
+
default:
|
|
125
|
+
return e.message ?? e.keyword;
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
// Ajv reports every alternative of an anyOf and every rule around a then; keep what the writer can act on
|
|
129
|
+
function simplify(errors) {
|
|
130
|
+
// the reason for an if/then rule, from its $comment, goes onto the errors its then or else gave (just before it)
|
|
131
|
+
errors.forEach((e, i) => {
|
|
132
|
+
const comment = e.parentSchema?.$comment;
|
|
133
|
+
if (e.keyword !== 'if' || typeof comment !== 'string')
|
|
134
|
+
return;
|
|
135
|
+
const base = e.schemaPath.slice(0, -'/if'.length);
|
|
136
|
+
for (let j = i - 1; j >= 0; j--) {
|
|
137
|
+
const x = errors[j];
|
|
138
|
+
if (!within(x.instancePath, e.instancePath) || !(x.schemaPath.startsWith(`${base}/then/`) || x.schemaPath.startsWith(`${base}/else/`)))
|
|
139
|
+
break;
|
|
140
|
+
x.because = comment;
|
|
141
|
+
}
|
|
142
|
+
});
|
|
143
|
+
const wrapper = (x) => ['if', 'anyOf', 'oneOf'].includes(x.keyword);
|
|
144
|
+
const explained = (e) => errors.some((x) => x !== e && !wrapper(x) && ((x.instancePath !== e.instancePath && within(x.instancePath, e.instancePath)) || (x.instancePath === e.instancePath && x.keyword !== 'type')));
|
|
145
|
+
const kept = errors.filter((e) => {
|
|
146
|
+
if (e.keyword === 'if')
|
|
147
|
+
return false; // its then or else said it
|
|
148
|
+
if (e.keyword === 'anyOf' || (e.keyword === 'oneOf' && e.params.passingSchemas === null)) {
|
|
149
|
+
return !explained(e) && !errors.some((x) => x !== e && x.keyword === 'type' && x.instancePath === e.instancePath);
|
|
150
|
+
}
|
|
151
|
+
if (e.keyword === 'type')
|
|
152
|
+
return !explained(e); // an alternative of the right type is there, and failed further in
|
|
153
|
+
if (e.propertyName !== undefined)
|
|
154
|
+
return false; // the name's own failure; its propertyNames error says it
|
|
155
|
+
return true;
|
|
156
|
+
});
|
|
157
|
+
// what is left at one place in one form is one line: the types the alternatives want, the keys of which one is needed
|
|
158
|
+
const out = [];
|
|
159
|
+
for (const e of kept) {
|
|
160
|
+
const alternative = e.keyword === 'required' && /\/(anyOf|oneOf)\/\d+\/required$/.test(e.schemaPath);
|
|
161
|
+
const twin = out.find((x) => x.instancePath === e.instancePath && x.keyword === e.keyword && (e.keyword === 'type' || (alternative && x.alternative === true)));
|
|
162
|
+
const p = e.params;
|
|
163
|
+
if (twin !== undefined && e.keyword === 'type')
|
|
164
|
+
twin.params.type = [...new Set([...twin.params.type, ...[p.type].flat()])];
|
|
165
|
+
else if (twin !== undefined)
|
|
166
|
+
twin.params.missingProperty.push(p.missingProperty);
|
|
167
|
+
else {
|
|
168
|
+
const params = e.keyword === 'type' ? { type: [p.type].flat() } : e.keyword === 'required' ? { missingProperty: [p.missingProperty] } : e.params;
|
|
169
|
+
out.push({ ...e, alternative, params });
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
return out;
|
|
173
|
+
}
|
|
174
|
+
// the id of the graph a file belongs to, when the file does not say it: the flow, nav or ui graph beside it
|
|
175
|
+
function graphIdBeside(dir) {
|
|
176
|
+
for (const name of ['flow.yaml', 'nav.yaml', 'ui.yaml']) {
|
|
177
|
+
const file = join(dir, name);
|
|
178
|
+
if (!existsSync(file))
|
|
179
|
+
continue;
|
|
180
|
+
try {
|
|
181
|
+
const id = parse(readFileSync(file, 'utf8'))?.id;
|
|
182
|
+
if (typeof id === 'string')
|
|
183
|
+
return id;
|
|
184
|
+
}
|
|
185
|
+
catch {
|
|
186
|
+
// a graph file that does not parse names no graph; its own check says why
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
return null;
|
|
190
|
+
}
|
|
191
|
+
// every place where the file does not follow its kind's schema; a file written for another format is left to the
|
|
192
|
+
// format check
|
|
193
|
+
export function validateFile(file) {
|
|
194
|
+
const kind = schemaKindOf(file);
|
|
195
|
+
if (kind === null)
|
|
196
|
+
return [];
|
|
197
|
+
const text = readFileSync(file, 'utf8');
|
|
198
|
+
const lineCounter = new LineCounter();
|
|
199
|
+
const doc = parseDocument(text, { lineCounter, prettyErrors: false });
|
|
200
|
+
const at = (offset) => {
|
|
201
|
+
const { line, col } = lineCounter.linePos(offset ?? 0);
|
|
202
|
+
return { line, column: col };
|
|
203
|
+
};
|
|
204
|
+
const ownFile = kind === 'catalog' ? `catalog/${basename(file)}` : basename(file);
|
|
205
|
+
let graph = null;
|
|
206
|
+
const failure = (where, said, pointer) => {
|
|
207
|
+
graph ??= graphIdBeside(kind === 'catalog' ? dirname(dirname(file)) : dirname(file));
|
|
208
|
+
return { ...where, message: said, graph, element: `${ownFile}#${pointer}` };
|
|
209
|
+
};
|
|
210
|
+
// the first YAML error only: the ones after it mostly follow from it
|
|
211
|
+
if (doc.errors.length > 0)
|
|
212
|
+
return [failure(at(doc.errors[0].pos[0]), `not YAML: ${doc.errors[0].message.split('\n')[0]}`, '')];
|
|
213
|
+
let data;
|
|
214
|
+
if (kind === 'catalog') {
|
|
215
|
+
try {
|
|
216
|
+
data = JSON.parse(text);
|
|
217
|
+
}
|
|
218
|
+
catch (err) {
|
|
219
|
+
return [failure({ line: 1, column: 1 }, `not JSON: ${err.message}`, '')];
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
else
|
|
223
|
+
data = doc.toJS();
|
|
224
|
+
const own = data ?? {};
|
|
225
|
+
if (kind !== 'catalog' && typeof own.schema === 'string' && own.schema !== FORMAT)
|
|
226
|
+
return [];
|
|
227
|
+
if (kind !== 'catalog' && typeof own.id === 'string')
|
|
228
|
+
graph = own.id;
|
|
229
|
+
const { roots, validators } = schemas();
|
|
230
|
+
const validate = validators[kind];
|
|
231
|
+
if (validate(data))
|
|
232
|
+
return [];
|
|
233
|
+
const out = [];
|
|
234
|
+
for (const e of simplify((validate.errors ?? []))) {
|
|
235
|
+
const p = e.params;
|
|
236
|
+
const named = p.additionalProperty ?? p.unevaluatedProperty ?? p.propertyName;
|
|
237
|
+
const name = named === undefined ? undefined : String(named);
|
|
238
|
+
const where = place(doc, e.instancePath, name);
|
|
239
|
+
const path = steps(e.instancePath).join('.');
|
|
240
|
+
let said = `${path === '' ? 'the file' : path}: ${message(e, roots[kind])}`;
|
|
241
|
+
const because = e.because ?? (e.keyword === 'false schema' ? undefined : e.parentSchema?.$comment);
|
|
242
|
+
if (typeof because === 'string')
|
|
243
|
+
said += ` (${because})`;
|
|
244
|
+
// `{ title: Done, and paid }` is a title and a key "and paid": YAML ends a flow mapping's value at the comma
|
|
245
|
+
const empty = where.value === null || where.value?.value === null;
|
|
246
|
+
if (name !== undefined && where.map?.flow === true && empty)
|
|
247
|
+
said += '; a comma inside { } ends the value before it: quote that value';
|
|
248
|
+
const missing = e.keyword === 'required' ? p.missingProperty.join('|') : undefined;
|
|
249
|
+
const pointer = name !== undefined ? `${e.instancePath}/${escape(name)}` : missing !== undefined ? `${e.instancePath}/${escape(missing)}` : e.instancePath;
|
|
250
|
+
const range = where.at?.range;
|
|
251
|
+
const finding = failure(at(range?.[0]), said, pointer);
|
|
252
|
+
if (!out.some((x) => x.line === finding.line && x.column === finding.column && x.message === finding.message))
|
|
253
|
+
out.push(finding);
|
|
254
|
+
}
|
|
255
|
+
return out;
|
|
256
|
+
}
|
package/dist/spine.d.ts
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { Graph } from './graph.ts';
|
|
2
|
+
import type { Exploration } from './model.ts';
|
|
3
|
+
import type { PathStep } from './story.ts';
|
|
4
|
+
export type View = 'main' | 'full';
|
|
5
|
+
export declare function renderSpine(g: Graph, ex: Exploration, view: View, story: PathStep[] | null): Promise<string>;
|
package/dist/starts.d.ts
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { Graph } from './graph.ts';
|
|
2
|
+
import type { Exploration, Model } from './model.ts';
|
|
3
|
+
export interface HandOver {
|
|
4
|
+
from: string;
|
|
5
|
+
event: string | null;
|
|
6
|
+
flow: string;
|
|
7
|
+
given: Record<string, string | number | boolean>;
|
|
8
|
+
found: boolean;
|
|
9
|
+
problems: string[];
|
|
10
|
+
}
|
|
11
|
+
export declare function checkStarts(g: Graph, m: Model, ex: Exploration): HandOver[];
|
package/dist/story.d.ts
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { Graph, Scalar } from './graph.ts';
|
|
2
|
+
import type { Exploration, Model } from './model.ts';
|
|
3
|
+
export interface PathStep {
|
|
4
|
+
state: string;
|
|
5
|
+
ctx: Scalar[];
|
|
6
|
+
event: string | null;
|
|
7
|
+
taken: string | null;
|
|
8
|
+
}
|
|
9
|
+
export interface Story {
|
|
10
|
+
given: string;
|
|
11
|
+
steps: string[];
|
|
12
|
+
result: string;
|
|
13
|
+
}
|
|
14
|
+
export declare function stepsTo(m: Model, ex: Exploration, index: number): PathStep[];
|
|
15
|
+
export declare function stepsByEvents(m: Model, main: NonNullable<Graph['flow']['main']>): PathStep[] | null;
|
|
16
|
+
export declare function mainStoryIndex(g: Graph, ex: Exploration): number | null;
|
|
17
|
+
export declare function narrate(g: Graph, m: Model, steps: PathStep[]): Story;
|