@delurio/cli 0.6.0 → 0.7.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 +14 -0
- package/README.md +1 -1
- package/SPEC.md +22 -5
- package/dist/changes.d.ts +16 -0
- package/dist/changes.js +13 -7
- package/dist/check.js +47 -2
- package/dist/cli.js +2 -2
- package/dist/html.d.ts +3 -0
- package/dist/html.js +26 -0
- package/dist/spine.d.ts +5 -0
- package/dist/spine.js +10 -3
- package/package.json +2 -1
- package/schemas/domain.schema.json +10 -6
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,20 @@
|
|
|
2
2
|
|
|
3
3
|
While the version is 0.x, a release that can judge the same graphs differently (a new check, a stricter schema) bumps the minor; a fix that judges nothing differently bumps the patch.
|
|
4
4
|
|
|
5
|
+
## 0.7.0 (2026-11-12)
|
|
6
|
+
|
|
7
|
+
- An action may be a server function (SPEC.md §5): `serverFn: GET` or `serverFn: POST` in place of a route, for a call that the product's own pages make to its server through their framework, such as TanStack Start's `createServerFn` or React's server functions, at an address the framework gives it. It is not part of the product's HTTP API: it is no OpenAPI operation, its input is its `body`, and it has no `query` and no `operationId`. `GET` reads and changes nothing; `POST` may write. An address that the browser itself opens, such as a link in an e-mail or a sign-in callback, keeps its route even when a server function answers it. Before, such an action could only be written with a route, as an operation that others may call, or with none, as a step inside the service; the `schema` rule refused `serverFn`.
|
|
8
|
+
- New rule of `check`, which fails `--strict`: `server-fn-http`, a server function that also has a `route`, a `query` or an `operationId`. It is given at the `serverFn`, with a note at the other key, in whichever files of a split domain each is given. A method other than `GET` or `POST` is an error of the `schema` rule.
|
|
9
|
+
- The `changes` rule (SPEC.md §4) reads a server function's method as it reads a route's: a `POST` writes and a `GET` does not, even when it returns an entity. Graphs with no `serverFn` are judged as before.
|
|
10
|
+
- `page`: a flow's page lists what each of its steps calls, under "What each step calls": the action, and how it is called (an HTTP operation and its route, a server function and its method, or a step inside the service). It reads the flow's domain where the `changes` rule finds it; a flow whose domain is not found gets no list. The other parts of the examples' pages are unchanged.
|
|
11
|
+
- `examples/notes/restore`: a flow with a screen whose two actions are server functions, one `GET` and one `POST`, in the split notes domain.
|
|
12
|
+
|
|
13
|
+
## 0.6.1 (2026-11-11)
|
|
14
|
+
|
|
15
|
+
- `page`: in the flow's diagram, every state's group carries `data-state`, and every edge and its label `data-from` and `data-to`. One edge is drawn per pair of states, so a transition is found by its two states. A tool on top of the CLI can now find a state or a transition in the drawing, to move to it or link to it. The pages of the examples differ from 0.6.0's only by these attributes. Nothing is judged differently.
|
|
16
|
+
- `@delurio/cli/spine` exports `renderSpine`, which draws that diagram, with the states to draw as the story.
|
|
17
|
+
- SPEC.md §7: a tutorial may be told on the flow's diagram instead of its screens (`stage: diagram`), for a flow with no screens. `show` and `end` walk the flow to their state along its normal way, and every other event is given with `after`; an ending needs no card. The checker does not read tutorials, so nothing is judged differently.
|
|
18
|
+
|
|
5
19
|
## 0.6.0 (2026-11-10)
|
|
6
20
|
|
|
7
21
|
- A graph file with an anchor (`&name`), an alias (`*name`), a tag (`!name`) or a key that is a list or a map cannot be loaded (SPEC.md §1): `check` gives `load` and `schema` errors at its line, "unsupported YAML", and exits 1; `page`, `diff` and the other commands stop the same way. The yaml library resolves these in time far beyond a file's size. On a 40 KB file, maps used as keys kept it busy for more than 30 seconds, and aliases of an anchor that holds only aliases of an empty list for more than two minutes. Its alias limit does not catch these cases. Every reader of a graph file now looks for them first, in one pass that resolves nothing: such a file is refused in under a second. A value is written where it is used, and a key is a string. Of the graphs of delurio, Medaris and QAuth, only QAuth's has them: seven flows use anchors for a `response` they repeat.
|
package/README.md
CHANGED
|
@@ -56,7 +56,7 @@ npx @delurio/cli check graphs --strict
|
|
|
56
56
|
npx @delurio/cli page examples/qauth-authorize --out viz/qauth-authorize
|
|
57
57
|
```
|
|
58
58
|
|
|
59
|
-
The page shows the flow in words: its main story, every way it ends, its guarantees and whether they hold, its screens as wireframes, and its diagram, which opens fitted to the window and moves like a design tool's canvas (drag to move, Ctrl or ⌘ + scroll or a pinch to zoom, Shift+1 to fit). `examples/qauth-authorize` is a small graph to try it on.
|
|
59
|
+
The page shows the flow in words: its main story, every way it ends, its guarantees and whether they hold, its screens as wireframes, what each step calls (an HTTP operation, a server function of the product's own pages, or a step inside the service), and its diagram, which opens fitted to the window and moves like a design tool's canvas (drag to move, Ctrl or ⌘ + scroll or a pinch to zoom, Shift+1 to fit). `examples/qauth-authorize` is a small graph to try it on.
|
|
60
60
|
|
|
61
61
|
Given a folder of graphs instead, it writes the page of every graph under it, each at its own path, and `index.html` listing them all with what their check found:
|
|
62
62
|
|
package/SPEC.md
CHANGED
|
@@ -235,7 +235,22 @@ A capture may carry more words of its own on a field (`owner`, `note`, `editable
|
|
|
235
235
|
|
|
236
236
|
An action, a refusal and an invariant may carry `note`: the author's own words, which no tool reads. An invariant the code does not keep is still written, with `holds: false` and the `finding` that reports it: the finding's id in the graph's report, such as `MS-7`. A capture describes the code, so the invariant says what should hold and the finding says where it does not. Decided on 25 Oct 2026.
|
|
237
237
|
|
|
238
|
-
**The API.** An action with a `route` (`METHOD /path`) is one OpenAPI 3.1 operation: its name is the `operationId`, `needs` its security requirement, `query` (a JSON Schema object) its query parameters, `body` its request body, `result` its response (`returns` an entity, a `redirect`, a `status`, or a JSON Schema), and each refusal one more response. When a refusal has a body, it is RFC 9457 problem details with the refusal code as its `type`. So a domain can be written out as an OpenAPI document, and an app that already publishes one names it at the top (`openapi: <file>`) and each action's operation by `operationId`, instead of copying them. An action with
|
|
238
|
+
**The API.** An action with a `route` (`METHOD /path`) is one OpenAPI 3.1 operation: its name is the `operationId`, `needs` its security requirement, `query` (a JSON Schema object) its query parameters, `body` its request body, `result` its response (`returns` an entity, a `redirect`, a `status`, or a JSON Schema), and each refusal one more response. When a refusal has a body, it is RFC 9457 problem details with the refusal code as its `type`. So a domain can be written out as an OpenAPI document, and an app that already publishes one names it at the top (`openapi: <file>`) and each action's operation by `operationId`, instead of copying them. An action with `serverFn` is a server function (below), and an action with neither is a step inside the service. `needs`, `policies`, `sideEffects`, `refusals.<code>.redirect` and `invariants` are delurio's own: no standard says who may do what to which data, or what must always hold.
|
|
239
|
+
|
|
240
|
+
**Server functions.** Full-stack frameworks let a product's own pages call code on its server as if it were a function: TanStack Start's `createServerFn`, or React's server functions. The framework gives each one an address of its own and makes the call from the product's pages; it is not a public HTTP API, and nothing else is meant to call it. Such an action says so with `serverFn` and its HTTP method, `GET` or `POST`, in place of a route:
|
|
241
|
+
|
|
242
|
+
```yaml
|
|
243
|
+
actions:
|
|
244
|
+
readNote: { serverFn: GET, needs: session, body: { type: object, required: [id] }, result: { returns: Note } }
|
|
245
|
+
restoreNote: { serverFn: POST, needs: session, body: { type: object, required: [id] }, result: { returns: Note } }
|
|
246
|
+
```
|
|
247
|
+
|
|
248
|
+
- `GET` reads: it changes nothing, so the framework may call it ahead of time (a page's loader, a preload) or keep its answer. `POST` may write, and every server function that changes something is one.
|
|
249
|
+
- Its input is its `body`, whatever its method: a framework puts a `GET`'s input in the address under a name of its own, so a server function has no `query`. `needs`, `result`, `refusals` and `sideEffects` mean what they mean for a route. The function is reached over HTTP like any request, so what it `needs` is checked by the function itself, never only by the page that calls it.
|
|
250
|
+
- It is no OpenAPI operation: the OpenAPI document of a domain ([#8](https://github.com/delurio-labs/delurio/issues/8)) leaves it out, and it has no `operationId`.
|
|
251
|
+
- An action has a route or `serverFn`, never both. An address that the browser itself opens, such as a link in an e-mail, a sign-in callback, or a link that sends the browser on to another site, keeps its `route` even when a server function answers it: the address is what is called, and others may link to it, so it is part of the API.
|
|
252
|
+
|
|
253
|
+
`check` gives an error (`server-fn-http`) at the `serverFn` of an action that also has a `route`, a `query` or an `operationId`, in whichever of the domain's files each is given, with a note where the other key is; a method other than `GET` or `POST` is a `schema` error. Decided on 12 Nov 2026.
|
|
239
254
|
|
|
240
255
|
This form was decided on 22 Oct 2026. Graphs captured before it may still give fields as `{ kind: text }`; they are converted when a tool first reads fields. The OpenAPI export and import are [#8](https://github.com/delurio-labs/delurio/issues/8).
|
|
241
256
|
|
|
@@ -247,7 +262,7 @@ This form was decided on 22 Oct 2026. Graphs captured before it may still give f
|
|
|
247
262
|
|
|
248
263
|
A value given in two files is an error of `check` at the second one's line (`domain-twice`); so is a file whose id is not its directory's domain, and a domain whose files sit in two directories (`domain-place`). A split keeps a large domain one entity per file, and lets a part generated from the code ([#6](https://github.com/delurio-labs/delurio/issues/6)) and a part written by hand sit side by side; how a generator marks the files it owns is decided there. Decided on 1 Nov 2026.
|
|
249
264
|
|
|
250
|
-
`check` validates every file of a domain against its schema and reads its files as one, the `changes` rule (§4) reads its actions, the revision diff compares it,
|
|
265
|
+
`check` validates every file of a domain against its schema and reads its files as one, the `changes` rule (§4) reads its actions (one writes when its route or its server function is not a `GET`, when a policy lets someone `write` with it, or when it is a step inside the service that returns an entity), the revision diff compares it, anchors lock its `source:` keys, and the page of a flow that names it lists what each of its steps calls and how: an HTTP operation and its route, a server function and its method, or a step inside the service. Loading it with the flow and checking policies, secrets and `invoke` names is [#5](https://github.com/delurio-labs/delurio/issues/5); generating it from Drizzle and Zod is [#6](https://github.com/delurio-labs/delurio/issues/6); a registry that every API operation and route is covered by a graph is [#7](https://github.com/delurio-labs/delurio/issues/7).
|
|
251
266
|
|
|
252
267
|
## 6. Navigation (`kind: nav`)
|
|
253
268
|
|
|
@@ -281,7 +296,9 @@ notModeled: [ "..." ]
|
|
|
281
296
|
|
|
282
297
|
A **binding** ties a flow to a running app for replay and recording: `apps` (base addresses), `browser`, `data` (JSON or dotenv sources, secrets masked in reports), `signIn`, `accounts`, `scenarios` (each a `given` start, the account, the page to `open`, `setup` and `teardown`), `events` (the actions that cause an event no node on screen sends), `states` (a URL glob or a text a state must show) and `nodes` (a locator for a node that role and name cannot find, or `before` actions such as opening a menu, or `skip` with a reason). It may `extends` a shared binding. An action is one of `goto`, `reload`, `click`, `fill`, `key`, `waitUrl`, `waitText`, `waitResponse`, `run` (a command, with `expect`). A locator is `role`, `name`, `text`, `label`, `testId`, `css`, `hasText`, `within`, `nth`; a string between slashes is a regular expression. Replay over HTTP, with no browser, is an open issue; screenshots of every state on the real app are an open issue.
|
|
283
298
|
|
|
284
|
-
A **tutorial** is written against a flow: `title`, `audience`, `locale`, `appName`, `voice`, the `scenario` (the starting context), and `steps`. A step is `intro`, `chapter`, `show <state>`, `cut <state>` (jump, through a scenario the binding names), `reveal`/`focus` (nodes), `press <node>`, `after`, `card { title, body }`, `end`, and `say`. Every step is replayed on the flow, so a tutorial that no longer matches the graph stops at that step. `{word}` in `say` is a sample value or a node's visible text.
|
|
299
|
+
A **tutorial** is written against a flow: `title`, `audience`, `locale`, `appName`, `voice`, `stage`, the `scenario` (the starting context), and `steps`. A step is `intro`, `chapter`, `show <state>`, `cut <state>` (jump, through a scenario the binding names), `reveal`/`focus` (nodes), `press <node>`, `after`, `card { title, body }`, `end`, and `say`. Every step is replayed on the flow, so a tutorial that no longer matches the graph stops at that step. `{word}` in `say` is a sample value or a node's visible text.
|
|
300
|
+
|
|
301
|
+
`stage` says what the video shows: the flow's screens (`screen`, the default), or its diagram (`diagram`), for a flow with no screens, such as two programs talking or a job in the background. On the diagram the camera goes from state to state, and the tutorial's own way is drawn as the story, whether or not it is the flow's `main` story; the diagram holds every transition, failures included. No state is passed on its own there: `show <state>` and `end <state>` walk the flow to their state along its normal way (a transition with no event, then `DONE`) and stop the tutorial when that way does not reach it, and every other event is given with `after`. `press`, `reveal` and `focus` point at nodes a diagram does not have, and stop it too. An `end` on the diagram needs no `card`; one it has is shown after the ending.
|
|
285
302
|
|
|
286
303
|
A video is an MP4 file. Its captions are WebVTT (`tutorial.vtt`, what an HTML `<track>` plays, with `tutorial.srt` beside it), and its chapters a WebVTT chapters track (`chapters.vtt`). Every video delurio makes is marked as AI-made in three ways, none of which can be turned off: a first card that says the whole video is made with AI, an imperceptible watermark in the sound and the picture, and signed, time-stamped provenance metadata (C2PA is the candidate). The watermark and the metadata are the machine-readable marking that Art. 50(2) of the EU AI Act asks of a system that generates synthetic audio and video, and the Commission's Code of Practice of 10 June 2026 describes. The disclosure is there because every voice is made from real people's recordings and may resemble one of them, which Art. 50(4) treats as a deep fake to disclose; a catalogue voice is no different from a cloned one in that, and delurio cannot tell which listener would recognise which voice (Taha, 24 Oct 2026: "Klon olmayan sesler de gerçek insan sesinden"). It opens the video, since Art. 50(5) asks for it at the latest at the first exposure, and nothing is burnt into the picture after it (Taha, 25 Oct 2026: "en başta 'videonun tamamı' diye belirtip yazsak yetmez mi"); a clip cut from the middle loses the card but keeps the watermark and the metadata. A lawyer is to confirm this reading. The video tool does not add the watermark or the metadata yet; that is an open issue.
|
|
287
304
|
|
|
@@ -301,7 +318,7 @@ A kit says how the components of `ui.yaml` look in one product: `tokens` and `da
|
|
|
301
318
|
|---|---|
|
|
302
319
|
| 0 | the graph loads and, under `--strict`, nothing is wrong |
|
|
303
320
|
| 1 | the graph cannot be loaded: a YAML error, unsupported YAML (§1), an unknown state, an unknown name in an expression, a non-exhaustive `always`, an unsupported construct |
|
|
304
|
-
| 2 | under `--strict`: an assertion is violated, a catalog key or a sample value is missing, a component has no renderer, the kit does not cover a component, the main story cannot be walked, a domain's files clash (§5), or a state of a captured flow names no code (§9) |
|
|
321
|
+
| 2 | under `--strict`: an assertion is violated, a catalog key or a sample value is missing, a component has no renderer, the kit does not cover a component, the main story cannot be walked, a domain's files clash or a server function has what only a route has (§5), or a state of a captured flow names no code (§9) |
|
|
305
322
|
|
|
306
323
|
**As text.** A finding is one line in the GNU error format, which compilers, editors and most CI logs read:
|
|
307
324
|
|
|
@@ -354,7 +371,7 @@ Where a standard covers a part, delurio uses it rather than writing its own. Sur
|
|
|
354
371
|
|---|---|---|
|
|
355
372
|
| YAML 1.2 | every graph file | as it is |
|
|
356
373
|
| JSON Schema 2020-12 | the fields of entities, bodies and results (§5); a schema of every kind of graph file, so that editors check and complete them (#1) | as it is, plus the keywords of §5 |
|
|
357
|
-
| OpenAPI 3.1 | an action with a route is an operation (§5) | export and import: #13 |
|
|
374
|
+
| OpenAPI 3.1 | an action with a route is an operation (§5); a server function is not | export and import: #13 |
|
|
358
375
|
| RFC 9457, problem details | the body of a refusal (§5) | as it is |
|
|
359
376
|
| SCXML (W3C, 2015) | what a flow means (§2) | a subset; export: #14 |
|
|
360
377
|
| WAI-ARIA 1.2, Accessible Name and Description Computation 1.2 | roles and names in `ui.yaml` (§4) | as they are |
|
package/dist/changes.d.ts
CHANGED
|
@@ -1,7 +1,23 @@
|
|
|
1
1
|
import type { Graph } from './graph.ts';
|
|
2
|
+
export interface DomainAction {
|
|
3
|
+
route?: string;
|
|
4
|
+
serverFn?: string;
|
|
5
|
+
result?: {
|
|
6
|
+
returns?: string;
|
|
7
|
+
};
|
|
8
|
+
}
|
|
9
|
+
export interface Domain {
|
|
10
|
+
id?: string;
|
|
11
|
+
actions?: Record<string, DomainAction | null>;
|
|
12
|
+
policies?: Array<{
|
|
13
|
+
do?: string[];
|
|
14
|
+
write?: string[];
|
|
15
|
+
}>;
|
|
16
|
+
}
|
|
2
17
|
export interface ChangesCheck {
|
|
3
18
|
writes: string[];
|
|
4
19
|
key: string | null;
|
|
5
20
|
problems: string[];
|
|
6
21
|
}
|
|
22
|
+
export declare function flowDomain(g: Graph): Domain | null;
|
|
7
23
|
export declare function checkChanges(g: Graph): ChangesCheck | null;
|
package/dist/changes.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
// `changes:` in ui.yaml (SPEC.md §4): a flow whose steps write something tells its users, in its own note, what it
|
|
2
|
-
// changes and what follows. An action writes when its route is not a GET, when a policy lets
|
|
3
|
-
// when it is a step inside the service (
|
|
4
|
-
// looked up by id among the graphs beside this one, all its files
|
|
5
|
-
// whose domain is not found, is not checked.
|
|
2
|
+
// changes and what follows. An action writes when its route or its server function is not a GET, when a policy lets
|
|
3
|
+
// someone `write` with it, or when it is a step inside the service (neither a route nor a server function) that returns
|
|
4
|
+
// an entity; all three are read from the flow's domain, looked up by id among the graphs beside this one, all its files
|
|
5
|
+
// read as one (SPEC.md §5). A flow with no screens, or whose domain is not found, is not checked.
|
|
6
6
|
import { existsSync, readdirSync, readFileSync, statSync } from 'node:fs';
|
|
7
7
|
import { basename, dirname, join } from 'node:path';
|
|
8
8
|
import { inReadingOrder, isDomainText, mayBeDomain, mergeDomain } from './domain.js';
|
|
@@ -38,15 +38,21 @@ function domainUnder(root, id, depth = 4) {
|
|
|
38
38
|
}
|
|
39
39
|
return null;
|
|
40
40
|
}
|
|
41
|
+
// the domain the flow names, looked up by id among the graphs beside it; null when it names none or it is not found
|
|
42
|
+
export function flowDomain(g) {
|
|
43
|
+
return g.flow.domain === undefined ? null : domainUnder(rootOf(g.dir), g.flow.domain);
|
|
44
|
+
}
|
|
45
|
+
// the HTTP method of an action's route or server function; undefined for a step inside the service
|
|
46
|
+
const methodOf = (a) => (a?.route ?? a?.serverFn)?.trim().split(/\s+/)[0]?.toUpperCase();
|
|
41
47
|
export function checkChanges(g) {
|
|
42
|
-
if (g.ui.absent === true
|
|
48
|
+
if (g.ui.absent === true)
|
|
43
49
|
return null;
|
|
44
|
-
const domain =
|
|
50
|
+
const domain = flowDomain(g);
|
|
45
51
|
if (domain === null)
|
|
46
52
|
return null;
|
|
47
53
|
const writing = new Set();
|
|
48
54
|
for (const [name, a] of Object.entries(domain.actions ?? {})) {
|
|
49
|
-
const method = a
|
|
55
|
+
const method = methodOf(a);
|
|
50
56
|
if ((method !== undefined && method !== 'GET') || (method === undefined && a?.result?.returns !== undefined))
|
|
51
57
|
writing.add(name);
|
|
52
58
|
}
|
package/dist/check.js
CHANGED
|
@@ -29,6 +29,7 @@ const RULES = [
|
|
|
29
29
|
{ id: 'schema', text: "A graph file does not follow its kind's schema (SPEC.md)", level: 'error' },
|
|
30
30
|
{ id: 'domain-twice', text: 'A value of a domain is given in two of its files (SPEC.md §5)', level: 'error' },
|
|
31
31
|
{ id: 'domain-place', text: 'A domain file is not with the rest of its domain (SPEC.md §1)', level: 'error' },
|
|
32
|
+
{ id: 'server-fn-http', text: 'A server function is given a route, a query or an operationId, which only an HTTP operation has (SPEC.md §5)', level: 'error' },
|
|
32
33
|
{ id: 'assertion-violated', text: 'A guarantee of the flow is broken by a reachable situation', level: 'error' },
|
|
33
34
|
{ id: 'main-story-unwalkable', text: 'The declared main story cannot be walked', level: 'error' },
|
|
34
35
|
{ id: 'catalog-key-missing', text: 'A catalog key the screens use is missing', level: 'error' },
|
|
@@ -165,8 +166,50 @@ function checkFlow(dir) {
|
|
|
165
166
|
}
|
|
166
167
|
return out;
|
|
167
168
|
}
|
|
169
|
+
// what only an HTTP operation has (SPEC.md §5), and why a server function has none of it
|
|
170
|
+
const HTTP_ONLY = {
|
|
171
|
+
route: 'a route is an operation that others call over HTTP, and a server function is called only by the product\'s own pages: give one of them',
|
|
172
|
+
query: 'a server function\'s input is its body, whatever its method',
|
|
173
|
+
operationId: 'a server function is no operation of an OpenAPI document',
|
|
174
|
+
};
|
|
175
|
+
// a server function that is also given what only an HTTP operation has (SPEC.md §5), at its `serverFn` with a note at
|
|
176
|
+
// the other key; the two may come from two files of a split domain, so the domain is read as one first
|
|
177
|
+
function checkServerFunctions(parts, doc, id) {
|
|
178
|
+
const out = [];
|
|
179
|
+
const read = parts.map((p) => {
|
|
180
|
+
try {
|
|
181
|
+
return readYaml(p.text);
|
|
182
|
+
}
|
|
183
|
+
catch {
|
|
184
|
+
return null;
|
|
185
|
+
}
|
|
186
|
+
});
|
|
187
|
+
// the part that gives the action's key, and where in it
|
|
188
|
+
const given = (name, key) => {
|
|
189
|
+
const i = read.findIndex((d) => d?.actions?.[name]?.[key] !== undefined);
|
|
190
|
+
return i < 0 ? null : { file: parts[i].file, ...keyAt(parts[i].text, ['actions', name, key]) };
|
|
191
|
+
};
|
|
192
|
+
const actions = (doc.actions ?? {});
|
|
193
|
+
for (const [name, a] of Object.entries(actions)) {
|
|
194
|
+
if (a === null || typeof a !== 'object' || a.serverFn === undefined)
|
|
195
|
+
continue;
|
|
196
|
+
const at = given(name, 'serverFn');
|
|
197
|
+
if (at === null)
|
|
198
|
+
continue;
|
|
199
|
+
for (const [key, why] of Object.entries(HTTP_ONLY)) {
|
|
200
|
+
if (a[key] === undefined)
|
|
201
|
+
continue;
|
|
202
|
+
const other = given(name, key);
|
|
203
|
+
const said = key === 'route' ? `a route, ${String(a.route)}` : key === 'query' ? 'a query' : `an operationId, ${String(a.operationId)}`;
|
|
204
|
+
const notes = other === null ? [] : [{ file: rel(other.file), line: other.line, column: other.column, message: `its ${key} is given here` }];
|
|
205
|
+
out.push(result('server-fn-http', at.file, at, `the action ${name} is a server function (serverFn: ${String(a.serverFn)}) and has ${said}: ${why} (SPEC.md §5)`, id, `actions/${name}/${key}`, notes));
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
return out;
|
|
209
|
+
}
|
|
168
210
|
// the domains under root, each the domain files of one directory read as one (SPEC.md §5): a value given in two of
|
|
169
|
-
// them, a file whose id is not its directory's,
|
|
211
|
+
// them, a file whose id is not its directory's, a domain whose files sit in two directories, and a server function
|
|
212
|
+
// given what only an HTTP operation has
|
|
170
213
|
function checkDomains(files) {
|
|
171
214
|
const byDir = new Map();
|
|
172
215
|
for (const f of files)
|
|
@@ -175,11 +218,13 @@ function checkDomains(files) {
|
|
|
175
218
|
const out = [];
|
|
176
219
|
const dirsOf = new Map(); // a domain's id -> the directories that hold it
|
|
177
220
|
for (const [dir, list] of byDir) {
|
|
178
|
-
const
|
|
221
|
+
const parts = inReadingOrder(list).map((file) => ({ file, text: readFileSync(file, 'utf8') }));
|
|
222
|
+
const merged = mergeDomain(parts);
|
|
179
223
|
for (const p of merged.problems) {
|
|
180
224
|
const notes = p.first === undefined ? [] : [{ file: rel(p.first.file), line: p.first.line, column: p.first.column, message: 'given first here' }];
|
|
181
225
|
out.push(result(p.rule, p.file, p, p.message, merged.id ?? rel(dir), p.element, notes));
|
|
182
226
|
}
|
|
227
|
+
out.push(...checkServerFunctions(parts, merged.doc, merged.id ?? rel(dir)));
|
|
183
228
|
if (merged.id !== null)
|
|
184
229
|
dirsOf.set(merged.id, [...(dirsOf.get(merged.id) ?? []), dir]);
|
|
185
230
|
}
|
package/dist/cli.js
CHANGED
|
@@ -10,7 +10,7 @@ import { renderMermaid } from './mermaid.js';
|
|
|
10
10
|
import { renderSpine } from './spine.js';
|
|
11
11
|
import { renderScreens } from './wireframe.js';
|
|
12
12
|
import { renderPage } from './html.js';
|
|
13
|
-
import { checkChanges } from './changes.js';
|
|
13
|
+
import { checkChanges, flowDomain } from './changes.js';
|
|
14
14
|
import { checkStarts } from './starts.js';
|
|
15
15
|
import { mainStoryIndex, narrate, stepsByEvents, stepsTo } from './story.js';
|
|
16
16
|
import { checkGoals, findings, loadNav, menuRows, viewOf } from './nav.js';
|
|
@@ -80,7 +80,7 @@ async function flowPage(dir, out, args) {
|
|
|
80
80
|
for (const p of checkChanges(g)?.problems ?? [])
|
|
81
81
|
warn(p);
|
|
82
82
|
mkdirSync(out, { recursive: true });
|
|
83
|
-
writeFileSync(join(out, 'index.html'), renderPage({ g, m: model, ex, assertions, finals, main, spineMain, spineFull, screens, kit, handOvers }));
|
|
83
|
+
writeFileSync(join(out, 'index.html'), renderPage({ g, m: model, ex, assertions, finals, main, spineMain, spineFull, screens, kit, handOvers, domain: flowDomain(g) }));
|
|
84
84
|
writeFileSync(join(out, 'flow.mmd'), renderMermaid(g, ex));
|
|
85
85
|
const violated = assertions.filter((a) => a.violation !== undefined);
|
|
86
86
|
console.log(`${g.flow.id}: ${count(Object.keys(g.flow.states).length, 'state')}, ${count(ex.configs.length, 'configuration')} from ${count(ex.starts, 'start')}, ${assertions.length - violated.length}/${assertions.length} assertions hold`);
|
package/dist/html.d.ts
CHANGED
|
@@ -3,6 +3,7 @@ import type { AssertionResult, Exploration, FinalPath, Model } from './model.ts'
|
|
|
3
3
|
import type { Story } from './story.ts';
|
|
4
4
|
import type { Kit } from './kit.ts';
|
|
5
5
|
import type { HandOver } from './starts.ts';
|
|
6
|
+
import type { Domain, DomainAction } from './changes.ts';
|
|
6
7
|
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
8
|
export interface PageInput {
|
|
8
9
|
g: Graph;
|
|
@@ -16,5 +17,7 @@ export interface PageInput {
|
|
|
16
17
|
screens: string;
|
|
17
18
|
kit?: Kit | null;
|
|
18
19
|
handOvers?: HandOver[];
|
|
20
|
+
domain?: Domain | null;
|
|
19
21
|
}
|
|
22
|
+
export declare function callLine(a: DomainAction | null | undefined): string;
|
|
20
23
|
export declare function renderPage(p: PageInput): string;
|
package/dist/html.js
CHANGED
|
@@ -76,6 +76,19 @@ dl.guards { margin: 10px 0 0; display: grid; grid-template-columns: max-content
|
|
|
76
76
|
ul.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: "✓"; position: absolute; left: 4px; color: var(--ok); font-weight: 700; } ul.checks li.fail::before { content: "✗"; color: var(--bad); }
|
|
77
77
|
footer { margin-top: 56px; color: var(--muted); font-size: 13px; }
|
|
78
78
|
`;
|
|
79
|
+
// how an action of the domain is called (SPEC.md §5): an HTTP operation others call, a server function only the
|
|
80
|
+
// product's own pages call, or a step inside the service
|
|
81
|
+
export function callLine(a) {
|
|
82
|
+
if (a === undefined)
|
|
83
|
+
return 'not in its domain';
|
|
84
|
+
if (a === null)
|
|
85
|
+
return 'named, not written yet';
|
|
86
|
+
if (a.route !== undefined)
|
|
87
|
+
return `an HTTP operation, ${a.route}`;
|
|
88
|
+
if (a.serverFn !== undefined)
|
|
89
|
+
return `a server function, ${a.serverFn}, called only by the product's own pages`;
|
|
90
|
+
return 'a step inside the service';
|
|
91
|
+
}
|
|
79
92
|
function routingSection(g, ex) {
|
|
80
93
|
const out = [];
|
|
81
94
|
for (const [name, st] of Object.entries(g.flow.states)) {
|
|
@@ -223,6 +236,19 @@ export function renderPage(p) {
|
|
|
223
236
|
out.push(`<tr><td>${esc(titleOf(g.flow, name))}<br><span class="mono muted">${esc(name)}</span></td><td>${esc(responseLine(st.response ?? {}))}</td></tr>`);
|
|
224
237
|
out.push('</tbody></table></div>');
|
|
225
238
|
}
|
|
239
|
+
const actions = p.domain?.actions ?? null;
|
|
240
|
+
const calls = Object.entries(g.flow.states).filter(([, st]) => st.invoke?.action !== undefined);
|
|
241
|
+
if (actions !== null && calls.length > 0) {
|
|
242
|
+
out.push('<h2>What each step calls</h2>');
|
|
243
|
+
out.push(`<p class="muted" style="margin-top:-4px">The actions of its domain, <span class="mono">${esc(g.flow.domain ?? '')}</span>, and how each is called.</p>`);
|
|
244
|
+
out.push('<div class="scroll"><table><thead><tr><th>Step</th><th>Action</th><th>How it is called</th></tr></thead><tbody>');
|
|
245
|
+
for (const [name, st] of calls) {
|
|
246
|
+
const action = st.invoke?.action ?? '';
|
|
247
|
+
const a = Object.hasOwn(actions, action) ? actions[action] : undefined;
|
|
248
|
+
out.push(`<tr><td>${esc(titleOf(g.flow, name))}<br><span class="mono muted">${esc(name)}</span></td><td>${code(action)}</td><td>${esc(callLine(a))}</td></tr>`);
|
|
249
|
+
}
|
|
250
|
+
out.push('</tbody></table></div>');
|
|
251
|
+
}
|
|
226
252
|
const routing = routingSection(g, ex);
|
|
227
253
|
if (routing !== '') {
|
|
228
254
|
out.push('<h2>How it decides what happens next</h2>');
|
package/dist/spine.d.ts
CHANGED
|
@@ -2,4 +2,9 @@ import type { Graph } from './graph.ts';
|
|
|
2
2
|
import type { Exploration } from './model.ts';
|
|
3
3
|
import type { PathStep } from './story.ts';
|
|
4
4
|
export type View = 'main' | 'full';
|
|
5
|
+
/**
|
|
6
|
+
* The flow's diagram as an SVG. Every state's group carries `data-state`, and every edge and its label `data-from` and
|
|
7
|
+
* `data-to`: one edge is drawn per pair of states, its label holding every transition between them. `story`: the
|
|
8
|
+
* states to draw as the story (`on-main`), in order.
|
|
9
|
+
*/
|
|
5
10
|
export declare function renderSpine(g: Graph, ex: Exploration, view: View, story: PathStep[] | null): Promise<string>;
|
package/dist/spine.js
CHANGED
|
@@ -13,6 +13,11 @@ const r1 = (n) => Math.round(n * 10) / 10;
|
|
|
13
13
|
function labelLines(e, view) {
|
|
14
14
|
return e.labels.flatMap((l) => wrap(l, LABEL_WRAP[view]));
|
|
15
15
|
}
|
|
16
|
+
/**
|
|
17
|
+
* The flow's diagram as an SVG. Every state's group carries `data-state`, and every edge and its label `data-from` and
|
|
18
|
+
* `data-to`: one edge is drawn per pair of states, its label holding every transition between them. `story`: the
|
|
19
|
+
* states to draw as the story (`on-main`), in order.
|
|
20
|
+
*/
|
|
16
21
|
export async function renderSpine(g, ex, view, story) {
|
|
17
22
|
const all = collectEdges(g, ex);
|
|
18
23
|
// main view: the story without failure branches and without "the user closes the page"
|
|
@@ -82,6 +87,8 @@ export async function renderSpine(g, ex, view, story) {
|
|
|
82
87
|
edges.forEach((e, i) => byId.set(`e${i}`, e));
|
|
83
88
|
const drawn = (laid.edges ?? []).filter((e) => e.sections?.[0] !== undefined);
|
|
84
89
|
const isMain = (e) => e !== undefined && mainEdges.has(`${e.from}>${e.to}`);
|
|
90
|
+
// which states an edge joins, so a tool can find the drawing of a transition: one edge per pair of states
|
|
91
|
+
const ends = (e) => `data-from="${esc(e.from)}" data-to="${esc(e.to)}"`;
|
|
85
92
|
const path = (e) => {
|
|
86
93
|
const section = e.sections?.[0];
|
|
87
94
|
if (section === undefined)
|
|
@@ -99,7 +106,7 @@ export async function renderSpine(g, ex, view, story) {
|
|
|
99
106
|
if (viz === undefined || isMain(viz) !== pass)
|
|
100
107
|
continue;
|
|
101
108
|
const kind = pass ? 'main' : viz.kind;
|
|
102
|
-
out.push(`<path class="edge edge-${kind}${viz.unused ? ' edge-unused' : ''}" d="${path(e)}" marker-end="url(#arrow-${view}-${kind})"/>`);
|
|
109
|
+
out.push(`<path class="edge edge-${kind}${viz.unused ? ' edge-unused' : ''}" ${ends(viz)} d="${path(e)}" marker-end="url(#arrow-${view}-${kind})"/>`);
|
|
103
110
|
}
|
|
104
111
|
}
|
|
105
112
|
for (const e of drawn) {
|
|
@@ -110,7 +117,7 @@ export async function renderSpine(g, ex, view, story) {
|
|
|
110
117
|
const lines = labelLines(viz, view);
|
|
111
118
|
const x = label.x ?? 0;
|
|
112
119
|
const y = label.y ?? 0;
|
|
113
|
-
out.push(`<g class="elabel${isMain(viz) ? ' elabel-main' : ''}${viz.kind === 'fail' ? ' elabel-fail' : ''}"><rect x="${r1(x)}" y="${r1(y)}" width="${label.width ?? 0}" height="${label.height ?? 0}" rx="4"/>`);
|
|
120
|
+
out.push(`<g class="elabel${isMain(viz) ? ' elabel-main' : ''}${viz.kind === 'fail' ? ' elabel-fail' : ''}" ${ends(viz)}><rect x="${r1(x)}" y="${r1(y)}" width="${label.width ?? 0}" height="${label.height ?? 0}" rx="4"/>`);
|
|
114
121
|
lines.forEach((l, i) => out.push(`<text x="${r1(x + 7)}" y="${r1(y + 17 + i * 17)}">${esc(l)}</text>`));
|
|
115
122
|
out.push('</g>');
|
|
116
123
|
}
|
|
@@ -131,7 +138,7 @@ export async function renderSpine(g, ex, view, story) {
|
|
|
131
138
|
const close = kind === 'screen' ? '</a>' : '';
|
|
132
139
|
const by = st.by === undefined ? '' : ` by-${st.by}`;
|
|
133
140
|
const tip = [st.description ?? n.id, ...(st.includes ?? []).map((s) => `+ ${s}`)].join('\n');
|
|
134
|
-
out.push(`${open}<g class="node node-${kind}${by}${st.goal === true ? ' goal' : ''}${exitClass}${mainNodes.has(n.id) ? ' on-main' : ''}${unreachable ? ' node-unreachable' : ''}"><title>${esc(tip)}</title>`);
|
|
141
|
+
out.push(`${open}<g class="node node-${kind}${by}${st.goal === true ? ' goal' : ''}${exitClass}${mainNodes.has(n.id) ? ' on-main' : ''}${unreachable ? ' node-unreachable' : ''}" data-state="${esc(n.id)}"><title>${esc(tip)}</title>`);
|
|
135
142
|
const rx = kind === 'exit' || st.by === 'ai' ? 28 : st.by === 'ci' ? 0 : 8;
|
|
136
143
|
out.push(`<rect x="${x}" y="${y}" width="${w}" height="${h}" rx="${rx}"/>`);
|
|
137
144
|
if (st.by === 'agent')
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@delurio/cli",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.7.0",
|
|
4
4
|
"description": "The open checker and page of delurio-graph/0: check every graph in a project's own CI, offline, with GNU error lines and SARIF.",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"type": "module",
|
|
@@ -15,6 +15,7 @@
|
|
|
15
15
|
"./html": { "types": "./dist/html.d.ts", "default": "./dist/html.js" },
|
|
16
16
|
"./nav": { "types": "./dist/nav.d.ts", "default": "./dist/nav.js" },
|
|
17
17
|
"./expr": { "types": "./dist/expr.d.ts", "default": "./dist/expr.js" },
|
|
18
|
+
"./spine": { "types": "./dist/spine.d.ts", "default": "./dist/spine.js" },
|
|
18
19
|
"./yaml": { "types": "./dist/yaml.d.ts", "default": "./dist/yaml.js" },
|
|
19
20
|
"./package.json": "./package.json"
|
|
20
21
|
},
|
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
},
|
|
28
28
|
"actions": {
|
|
29
29
|
"type": "object",
|
|
30
|
-
"description": "The API and the steps inside the service, by action name. An action with a `route` is one OpenAPI 3.1 operation whose operationId is its name; one with
|
|
30
|
+
"description": "The API and the steps inside the service, by action name. An action with a `route` is one OpenAPI 3.1 operation whose operationId is its name; one with `serverFn` is a server function that only the product's own pages call; one with neither is a step inside the service. An action may be named before it is written (an empty value).",
|
|
31
31
|
"additionalProperties": { "$ref": "#/$defs/action" }
|
|
32
32
|
},
|
|
33
33
|
"invariants": {
|
|
@@ -212,21 +212,25 @@
|
|
|
212
212
|
},
|
|
213
213
|
"action": {
|
|
214
214
|
"type": ["object", "null"],
|
|
215
|
-
"description": "An action. With a `route` it is one OpenAPI 3.1 operation: its name is the operationId, `needs` its security requirement, `query` its query parameters, `body` its request body, `result` its response, and each refusal one more response.",
|
|
215
|
+
"description": "An action. With a `route` it is one OpenAPI 3.1 operation: its name is the operationId, `needs` its security requirement, `query` its query parameters, `body` its request body, `result` its response, and each refusal one more response. With `serverFn` it is a server function, called only by the product's own pages: `body` is its input, and it is no OpenAPI operation. An action has a route or a server function, never both.",
|
|
216
216
|
"additionalProperties": false,
|
|
217
217
|
"properties": {
|
|
218
218
|
"route": {
|
|
219
219
|
"type": "string",
|
|
220
|
-
"description": "`METHOD /path`: the HTTP method and the path of the operation. An action with
|
|
220
|
+
"description": "`METHOD /path`: the HTTP method and the path of the operation, which others call over HTTP. An action with neither a route nor `serverFn` is a step inside the service.",
|
|
221
221
|
"pattern": "^(GET|HEAD|POST|PUT|PATCH|DELETE|OPTIONS|TRACE) /\\S*$",
|
|
222
222
|
"examples": ["POST /authorize/consent", "GET /w/{workspace}/projects"]
|
|
223
223
|
},
|
|
224
|
-
"
|
|
224
|
+
"serverFn": {
|
|
225
|
+
"description": "The action is a server function: the product's own pages call it through their framework (such as TanStack Start's `createServerFn`), at an address the framework gives it, and nobody else calls it. Its method: `GET` reads and changes nothing, `POST` may write. It is no OpenAPI operation, so it has no `route`, no `query` and no `operationId`; its input is its `body`, whatever its method (SPEC.md §5).",
|
|
226
|
+
"enum": ["GET", "POST"]
|
|
227
|
+
},
|
|
228
|
+
"operationId": { "type": "string", "description": "The operation in the app's own OpenAPI document (named at the top with `openapi:`), when it is not this action's name. Only a route has one." },
|
|
225
229
|
"summary": { "type": "string", "description": "OpenAPI: the operation in a few words." },
|
|
226
230
|
"description": { "type": "string", "description": "OpenAPI: what the operation or the step does, in words." },
|
|
227
231
|
"needs": { "type": "string", "description": "delurio: what the caller must hold (the operation's security requirement).", "examples": ["session"] },
|
|
228
|
-
"query": { "$ref": "#/$defs/schema", "description": "The query parameters: a JSON Schema object." },
|
|
229
|
-
"body": { "$ref": "#/$defs/schema", "description": "The request body: a JSON Schema." },
|
|
232
|
+
"query": { "$ref": "#/$defs/schema", "description": "The query parameters of a route: a JSON Schema object." },
|
|
233
|
+
"body": { "$ref": "#/$defs/schema", "description": "The request body of a route, or the input of a server function: a JSON Schema." },
|
|
230
234
|
"result": { "$ref": "#/$defs/result" },
|
|
231
235
|
"refusals": {
|
|
232
236
|
"type": "object",
|