@delurio/cli 0.6.1 → 0.8.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 +27 -0
- package/README.md +3 -1
- package/SPEC.md +71 -11
- package/dist/changes.d.ts +16 -0
- package/dist/changes.js +13 -7
- package/dist/check.js +71 -10
- package/dist/cli.js +2 -2
- package/dist/graph.d.ts +21 -0
- package/dist/graph.js +50 -0
- package/dist/html.d.ts +3 -0
- package/dist/html.js +26 -0
- package/dist/model.d.ts +22 -0
- package/dist/model.js +104 -0
- package/dist/ui-check.d.ts +8 -0
- package/dist/ui-check.js +91 -0
- package/dist/wireframe.js +1 -4
- package/package.json +1 -1
- package/schemas/domain.schema.json +10 -6
- package/schemas/ui.schema.json +69 -5
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,33 @@
|
|
|
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.8.0 (2026-11-15)
|
|
6
|
+
|
|
7
|
+
- `ui.yaml` may say where the focus goes after a step, what a control holds, and which pages work without JavaScript (SPEC.md §4), so that a replay can check them on the app. Before, the `schema` rule refused all five keys.
|
|
8
|
+
- `focus: { <state>: <node> }`: the node that has focus when the flow enters the state from another one, such as the alert a failed step shows on a page that stays open.
|
|
9
|
+
- The edge `{ returnsFocus: [<dialog>, <node>] }`: when the dialog (a page node whose role is `dialog` or `alertdialog`) closes into a state that shows the node, the node has the focus, usually the one that opened it. This partly answers #3's focus return.
|
|
10
|
+
- Where the focus goes is the first of these that applies: a dialog that closes and its `returnsFocus`, a page that opens and its `initialFocus` (a dialog's before the page's), then `focus`. `@delurio/cli/graph` exports this order as `focusAfter`.
|
|
11
|
+
- A page opens however the browser got there, by a step inside the app or by loading the page anew, and its `initialFocus` holds in both.
|
|
12
|
+
- `value` on a field: what it holds when it is shown, until someone types in it, as `{ key, params }`, `{ literal }` (`""` for an empty field) or `{ oneOf }`.
|
|
13
|
+
- `checked` on a node whose role is `checkbox`, `menuitemcheckbox`, `menuitemradio`, `option`, `radio` or `switch`: whether it is checked, or selected, as an expression over the context, or `true` or `false`.
|
|
14
|
+
- `script` on a page: how much of it works without JavaScript. `optional`: the page and its actions; a replay's second walk, with JavaScript off, checks it and takes its actions. `actions`: the page is drawn and read without JavaScript (rendered on the server) and only its actions need it; that walk checks what it shows but its actions, and ends there.
|
|
15
|
+
- New rules of `check`, which fail `--strict`: `focus-not-shown`, where `focus` gives the focus to a node its state does not show, or a `returnsFocus` to a node that no state the dialog closes into shows; and `returns-focus-not-dialog`, where a `returnsFocus` does not start at a dialog. The `schema` rule refuses `value` on a node that is not a field, `checked` on a node of another role, and `script` on a node that is not a page. The graph cannot be loaded (exit 1) when `focus` names a state the flow does not have, or when a `checked` expression does not parse or names something that is not a variable, a guard or `state`. A `value`'s catalog key and its samples are checked as a node's text is (`catalog-key-missing`, `sample-missing`). Graphs that use none of these keys are judged as before: delurio's 34 graphs give the same findings.
|
|
16
|
+
- `check` checks every folder it is given (`check graphs examples`), each graph and file once though one folder holds another. Before, it checked the first folder and left the others out without a word, and a path that was not a folder stopped it with a stack trace; now that path is refused with the usage, exit 1.
|
|
17
|
+
- `@delurio/cli/model` exports `cover` (#4). It gives event paths that together pass every reachable state (`states`) or take every reachable transition (`transitions`) of a flow, from the starts and through the steps that `explore` is given. Each path is a shortest way to what it is kept for, and has a stable id and the list of what it covers; the result also lists what no situation reaches. The same flow gives the same paths. `transitionsOf` names every transition as a step's `taken` does. A coverage report and a command that reads it are still #4.
|
|
18
|
+
- `@delurio/cli/graph` types the new keys (`UiNode.value`, `checked`, `script`, and now `repeat` and `source`; `Ui.focus` and `Ui.edges`, with `UiEdge`), and exports `shownIn`, `isDialog` and `CHECKABLE`.
|
|
19
|
+
- SPEC.md §7 describes what a binding and a replay add for this. A binding: a locator's `frame`; a scenario's `javaScript: false`; `as: <account>` on an action; `effects`; a node's `count`, how many elements its locator finds, on any node; a state's `call`, and its `as` and `before`, that person's screen and what is done on reaching it, for a step another person takes after arriving by a mailed link; and its `data`, read again after each `run`, a source whose file does not exist yet being allowed until a value of it is used. A scenario's `enter`: the way its walk comes in, by a navigation entry (`{ nav, bind, entry: <from>-><to> }`) or by another flow that starts this one (`{ flow, bind, given, event }`), after which the address it arrives at and the `initialFocus` of the first screen are checked and the flow's walk goes on. A replay: `--cover`, `--to`, `--no-js` and `--absent`. A navigation graph's binding: `nav:` in place of `flow:`; each persona signed in as the account named like it, or `personas.<persona>: { as, setup }` where one account stands for several personas and commands give it their facts; a `setup` run once; `frames` (`find`, `page`, `user`, `picker`), `pages` (`refusal`, `shows`, `skip`) and `entries.<from>-><to>[ <how or label key>]` (a locator, `skip`, `follow`), keyed as an entry is cited; and its replay, with `--persona`, `--page`, `--follow` and `--no-setup`. The checker does not read bindings, so nothing is judged differently.
|
|
20
|
+
- `examples/notes/restore`: its page is `script: actions`, drawn on the server while Restore needs JavaScript.
|
|
21
|
+
- `examples/notes/edit`: a page that works without JavaScript, with a field's value, a checkbox's state, the focus after saving, and a dialog that gives the focus back to the button that opened it. The notes domain gains `editNote`, a server function, and the field `pinned`.
|
|
22
|
+
- SPEC.md §7: a tutorial step may say how it comes out where an effect leaves it to chance (`havoc`): `then { <variable>: <value> }`. The step takes the case in which those variables have those values; without `then` it takes the model's first case. A tutorial can now go through an answer from outside (a host that lists the person's repositories) that the graph leaves open. The checker does not read tutorials, so nothing is judged differently.
|
|
23
|
+
|
|
24
|
+
## 0.7.0 (2026-11-12)
|
|
25
|
+
|
|
26
|
+
- 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`.
|
|
27
|
+
- 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.
|
|
28
|
+
- 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.
|
|
29
|
+
- `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.
|
|
30
|
+
- `examples/notes/restore`: a flow with a screen whose two actions are server functions, one `GET` and one `POST`, in the split notes domain.
|
|
31
|
+
|
|
5
32
|
## 0.6.1 (2026-11-11)
|
|
6
33
|
|
|
7
34
|
- `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.
|
package/README.md
CHANGED
|
@@ -33,6 +33,8 @@ Node 22.18 or later.
|
|
|
33
33
|
npx @delurio/cli check graphs --strict
|
|
34
34
|
```
|
|
35
35
|
|
|
36
|
+
Several folders may be given (`check graphs examples`); a graph under two of them is checked once.
|
|
37
|
+
|
|
36
38
|
- **Findings:** one line each, in the GNU error format that compilers, editors and CI logs read:
|
|
37
39
|
|
|
38
40
|
```
|
|
@@ -56,7 +58,7 @@ npx @delurio/cli check graphs --strict
|
|
|
56
58
|
npx @delurio/cli page examples/qauth-authorize --out viz/qauth-authorize
|
|
57
59
|
```
|
|
58
60
|
|
|
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.
|
|
61
|
+
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
62
|
|
|
61
63
|
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
64
|
|
package/SPEC.md
CHANGED
|
@@ -119,7 +119,9 @@ A configuration is a state together with a value for every context variable. The
|
|
|
119
119
|
|
|
120
120
|
Each assertion is `never: <expression>`: it holds when no reachable configuration satisfies the expression. A violation is reported with the shortest event path from a starting situation. Under `--strict` a violated assertion exits 2.
|
|
121
121
|
|
|
122
|
-
The checker does not yet fail on unreachable states, transitions no situation takes, or states with no way out; the page already shows them. That is [#2](https://github.com/delurio-labs/delurio/issues/2).
|
|
122
|
+
The checker does not yet fail on unreachable states, transitions no situation takes, or states with no way out; the page already shows them. That is [#2](https://github.com/delurio-labs/delurio/issues/2).
|
|
123
|
+
|
|
124
|
+
`cover` in `@delurio/cli/model` gives event paths that together pass every reachable state, or take every reachable transition, from the same starts the checker explores (or the ones a replay is bound to). Each path is a shortest way to the state or transition it is kept for, so it repeats a state only on the way to something not yet covered; the longest are kept first, and a path that covers nothing new is left out. Each has an id, a hash of its start and its transitions, and lists what it covers, and the result lists what no situation reaches. The same flow gives the same paths in the same order. A replay walks them (`--cover`, §7). Why a transition cannot be reached, a coverage report of the walks, and the command that fails on what they did not reach are [#4](https://github.com/delurio-labs/delurio/issues/4).
|
|
123
125
|
|
|
124
126
|
### Several flows
|
|
125
127
|
|
|
@@ -153,8 +155,9 @@ locales: [en]
|
|
|
153
155
|
kit: ../kit # optional: the kit the screens are drawn with
|
|
154
156
|
samples: { client: "Acme Notes" } # values for catalog parameters, on the page and in videos
|
|
155
157
|
changes: { key: Changes.note } # optional: what the flow changes and what follows, in its users' words
|
|
158
|
+
focus: { <state>: <node> } # optional: the node that has focus once a step has led into the state
|
|
156
159
|
nodes: { <node>: { .. } }
|
|
157
|
-
edges: [ { labelledBy: [node, node] }, { triggers: [node, state] } ]
|
|
160
|
+
edges: [ { labelledBy: [node, node] }, { triggers: [node, state] }, { returnsFocus: [dialog, node] } ]
|
|
158
161
|
rules: [ { id, rule } ]
|
|
159
162
|
```
|
|
160
163
|
|
|
@@ -170,16 +173,39 @@ rules: [ { id, rule } ]
|
|
|
170
173
|
| `when` | a guard or context flag that must hold for the node to show |
|
|
171
174
|
| `disabledIn` | states where the node is shown but disabled |
|
|
172
175
|
| `emits` | the event the node sends when pressed |
|
|
173
|
-
| `initialFocus` | on a page: the node that has focus when it opens |
|
|
176
|
+
| `initialFocus` | on a page: the node that has focus when it opens (Focus, below) |
|
|
174
177
|
| `repeat` | the node is drawn once per item of this data (`request.scopes`) |
|
|
175
178
|
| `frame` | for a page: whether it may be framed (`never`) |
|
|
179
|
+
| `value` | on a field: what it holds when it is shown, until someone types in it: `{ key, params }`, `{ literal }` or `{ oneOf }`; `{ literal: "" }` is an empty field |
|
|
180
|
+
| `checked` | on a node whose role is `checkbox`, `menuitemcheckbox`, `menuitemradio`, `option`, `radio` or `switch`: whether it is checked (an `option`: selected) when it is shown, as an expression over the context (§3), or `true` or `false` |
|
|
181
|
+
| `script` | on a page: how much of it works without JavaScript. `optional`: the page and its actions; `actions`: the page is drawn and read without it, and only its actions need it. Without `script`, the page needs JavaScript |
|
|
176
182
|
| `source` | the code that draws it |
|
|
177
183
|
|
|
178
184
|
`changes` is a catalog message that tells the flow's users, in their own words, what the flow changes and what follows from it: what is created, sent, charged or removed, who sees it, and whether it can be undone. Rehber shows it before it guides the flow and again at the step that makes the change, and it guides a flow whose steps write something only when the flow has one (rehber.install, rehber.guide; Taha, 24 Oct 2026: "readonly olmayan her akış için nelerin değişeceğini ve ne etkilerinin olacağını okuyabilecekleri bi not olsun"). The step that makes the change is found from the graph: the one that leads into a step invoking an action that writes. `graph-viz --strict` fails a flow whose steps invoke a writing action of its domain and whose ui has no `changes`, and a `changes` key missing from any locale's catalog (`tools/graph-viz/README.md`).
|
|
179
185
|
|
|
180
186
|
A `role` is a WAI-ARIA 1.2 role, and `name` is the accessible name that Accessible Name and Description Computation 1.2 gives the node; `kit check` reads both from the browser's accessibility tree.
|
|
181
187
|
|
|
182
|
-
A node is shown in a state when the state is in `in`, not in `unless`, and `when` holds. `edges` records relations the page and the checks use: a node labelled by another, an action that leads to a state. `rules` are written but no tool reads them yet; checking them, together with dialogs,
|
|
188
|
+
A node is shown in a state when the state is in `in`, not in `unless`, and `when` holds. `edges` records relations the page and the checks use: a node labelled by another, an action that leads to a state, the node a dialog gives the focus back to. `rules` are written but no tool reads them yet; checking them, together with labelled dialogs, confirmation before a destructive action and events handled where shown, is [#3](https://github.com/delurio-labs/delurio/issues/3). The focus return of #3 is partly answered: a dialog says where the focus returns with `returnsFocus` (below), and `check` holds that it starts at a dialog and gives the focus to a node shown where the dialog closes. That every dialog says it is still #3.
|
|
189
|
+
|
|
190
|
+
### Focus
|
|
191
|
+
|
|
192
|
+
A page that opens gives the focus to its `initialFocus`. `focus` and `returnsFocus` say where it goes after that, when someone acts or a step ends. A page opens when the flow enters a state that shows it from a state that does not, or starts in a state that shows it, however the browser got there: by a step inside the app, or by loading the page anew (a link from an e-mail, a reload, the way back from another site). Its `initialFocus` holds in both; an app that leaves the focus at the document's start after a load does not meet it. The flow moves from one state it stops in to the next: a state with `always` is passed at once, so the focus is never said there. When the flow moves from one state into another, the node that has focus in the new state is the first of these that applies:
|
|
193
|
+
|
|
194
|
+
1. the node of `{ returnsFocus: [<dialog>, <node>] }` in `edges`, when the dialog closes (the state before shows it and the new one does not) and the new state shows the node. The dialog is a page node whose role is `dialog` or `alertdialog`, and the node is usually the one that opened it, as the dialog pattern of the ARIA Authoring Practices Guide asks;
|
|
195
|
+
2. the `initialFocus` of a page that opens and has one; when a dialog opens over a page, the dialog's;
|
|
196
|
+
3. `focus.<state>`, the node that has focus when the flow enters that state from another one: on a page that stays open, the alert a failed step shows, or the status that says a step is done.
|
|
197
|
+
|
|
198
|
+
When none applies, and when the flow moves from a state to itself, the graph says nothing of the focus. `focusAfter` in `@delurio/cli/graph` gives this order. A replay checks, in each state it stops in, that the node the graph gives has the focus: the browser's focused element is that node, found by its role and name or by its binding (§7).
|
|
199
|
+
|
|
200
|
+
A state that `focus` names that is not a state of the flow keeps the graph from loading. `check` gives an error (`focus-not-shown`) where `focus` gives the focus to a node its state does not show (by `in` and `unless`; a replay reads `when`), or a `returnsFocus` to a node no state the dialog closes into shows, and one (`returns-focus-not-dialog`) where a `returnsFocus` starts at a node that is not a dialog.
|
|
201
|
+
|
|
202
|
+
### What a control holds, and pages without JavaScript
|
|
203
|
+
|
|
204
|
+
`value` is what a field holds when it is shown, until someone types in it. It takes the forms of a node's words except `labelledBy`: `{ key, params }` from the catalog, `{ literal }`, or `{ oneOf }`, and `{ literal: "" }` is an empty field. A replay compares it in each state that shows the field, up to the step at which its walk types in that field. `checked` says whether a control is checked, or for an `option` selected, in each state that shows it: an expression over the context there (§3), or `true` or `false`. A control someone checks during the flow is checked by an event, and the expression reads what that event's effect sets; one that the flow finds already checked is said over the context, such as the radio of the role a member already has (`checked: "role == 'admin'"`). A replay compares it in each state that shows the node. On a node drawn more than once (`repeat`, or words given as `oneOf`), `value` and `checked` hold for each control it draws; controls that differ are written as separate nodes.
|
|
205
|
+
|
|
206
|
+
`script` on a page says how much of it works without JavaScript. With `script: optional` the page and its actions work without it: its forms are posted and its links followed by the browser itself, and JavaScript only adds to them. With `script: actions` the page is drawn and can be read without JavaScript, as a page rendered on the server is, but its actions need it. Without `script` the page needs JavaScript, and the graph says nothing of it without. A replay with `--no-js` (§7) walks the flow a second time with JavaScript off. In a state whose page is `optional` it checks what the state shows, as on the first walk, and takes the next step there. In a state whose page is `actions` it checks what the state shows but its actions (the nodes of `type: action`), and takes no step from it: the walk ends there, as it does where a step leads to a page without `script`.
|
|
207
|
+
|
|
208
|
+
The `schema` rule refuses `value` on a node that is not a field, `checked` on a node of another role, and `script` on a node that is not a page. A `checked` expression that names neither a variable, a guard nor `state` keeps the graph from loading. A `value` from the catalog is held as a node's text is (`catalog-key-missing`, `sample-missing`).
|
|
183
209
|
|
|
184
210
|
### Catalog
|
|
185
211
|
|
|
@@ -235,7 +261,22 @@ A capture may carry more words of its own on a field (`owner`, `note`, `editable
|
|
|
235
261
|
|
|
236
262
|
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
263
|
|
|
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
|
|
264
|
+
**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.
|
|
265
|
+
|
|
266
|
+
**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:
|
|
267
|
+
|
|
268
|
+
```yaml
|
|
269
|
+
actions:
|
|
270
|
+
readNote: { serverFn: GET, needs: session, body: { type: object, required: [id] }, result: { returns: Note } }
|
|
271
|
+
restoreNote: { serverFn: POST, needs: session, body: { type: object, required: [id] }, result: { returns: Note } }
|
|
272
|
+
```
|
|
273
|
+
|
|
274
|
+
- `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.
|
|
275
|
+
- 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.
|
|
276
|
+
- 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`.
|
|
277
|
+
- 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.
|
|
278
|
+
|
|
279
|
+
`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
280
|
|
|
240
281
|
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
282
|
|
|
@@ -247,7 +288,7 @@ This form was decided on 22 Oct 2026. Graphs captured before it may still give f
|
|
|
247
288
|
|
|
248
289
|
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
290
|
|
|
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,
|
|
291
|
+
`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
292
|
|
|
252
293
|
## 6. Navigation (`kind: nav`)
|
|
253
294
|
|
|
@@ -279,9 +320,27 @@ notModeled: [ "..." ]
|
|
|
279
320
|
|
|
280
321
|
## 7. Binding (`kind: binding`) and tutorial (`kind: tutorial`)
|
|
281
322
|
|
|
282
|
-
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`)
|
|
323
|
+
A **binding** ties a flow to a running app for replay and recording: `apps` (base addresses), `browser`, `data` (JSON or dotenv sources, read again after each command, secrets masked in reports), `signIn`, `accounts`, `scenarios` (each a `given` start, the account, the page to `open`, `setup` and `teardown`, `javaScript: false` for a walk with JavaScript off, and `enter`, the way the walk comes in), `events` (the actions that cause an event no node on screen sends), `effects` (the checks of what a step changes outside the screen), `states` (a URL glob or a text a state must show, the server `call` a step makes, the account `as` whose screen it is, and `before` actions) and `nodes` (a locator for a node that role and name cannot find, or `before` actions such as opening a menu, `count` for how many elements it finds, 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`), and any action may carry `as`. A locator is `frame`, `role`, `name`, `text`, `label`, `testId`, `css`, `hasText`, `within`, `nth`; `frame` is the CSS selector of the iframe the element is drawn in, such as a payment provider's hosted form, and is looked in first; a string between slashes is a regular expression.
|
|
324
|
+
|
|
325
|
+
`as: <account>` on an action does it in that account's own browser, with its own cookies, opened and signed in the first time it is used: a step another person takes, such as a second member who approves or an invitee who accepts, is bound to actions `as` that person, and the walk goes on in the first browser after them. A state may carry `as` too: its screen is that person's, so it is checked, and its nodes are pressed, in their browser, while a state without `as` is the scenario's own account's. A state's `before: [actions]` runs when the walk reaches the state, before it is checked, such as that person opening the link an e-mail brought them. So a step another person takes after arriving by a mailed link is bound to its state: `as` the invitee, `before` opening the link. `effects: { <id>: [actions] }` checks what a step leaves outside the screen, such as an e-mail sent or a row written. `<id>` is an effect of the flow (§2) or an action of its domain (§5): the actions run after the walk takes a transition that applies that effect, or after a state that invokes that action ends with `DONE`. They are checks, typically a `run` with `expect` that reads a mail catcher's API or queries the database, and one that fails is a mismatch at that step.
|
|
326
|
+
|
|
327
|
+
`count: <number | "{data.path}">` on a node says how many elements its locator finds, as a number or a value of the binding's data: for a `repeat` node (§4), how many items it shows, and for any other node, how many there are, such as four radios and no fifth. Without it a `repeat` node shows at least one item, and more are accepted. `call: <url glob>` on a state names the server call its `invoke` makes. The replay holds the call until it has checked what the state shows, so a step in progress (its status, the controls in `disabledIn`) is seen as it is, and then lets it go; on a walk through `FAIL.<class>` it compares the call's HTTP status with the `status` of the refusals that the class stands for (§2, `failures`; §5). A scenario with `javaScript: false` is walked with JavaScript off, through the pages marked `script` (§4).
|
|
328
|
+
|
|
329
|
+
The binding's `data` is read when a walk starts, after its `setup`, and again after each `run`, so a command can hand the next action a value it has just written, such as the link or the code of an e-mail that it read from a mail catcher. A source whose file does not exist yet is allowed: the walk fails, naming the file, only when an action uses a value of it (`{<source>.<path>}`) while the file is still missing.
|
|
330
|
+
|
|
331
|
+
The **replay** walks a flow on the app through its binding and checks each state it stops in: the nodes the graph shows there (their role, name and text, whether they are disabled, which one has the focus, what a field holds and whether a control is checked, §4), the state's `url` and `text`, and the `effects` of the step that led there. `replay <flow dir> --bind <binding>` walks the main story (§2). `--to <state>` walks the shortest way to that state that the binding can drive. `--cover states` walks paths that together pass every reachable state, and `--cover transitions` paths that together take every reachable transition, from the binding's scenarios and through the steps it can drive (§2, `cover`). `--no-js` walks the pages marked `script` a second time with JavaScript off: those marked `optional` with their actions, those marked `actions` read only (§4). `--absent` also checks that a node the graph does not show in a state is not visible there; without it, the replay checks only what the graph shows, and a node it leaves out of a state may be there or not.
|
|
332
|
+
|
|
333
|
+
`enter` says how a scenario's walk comes into the flow, after the scenario opens its page (`open`). `enter: { nav: <nav graph dir>, bind: <nav binding>, entry: <from>-><to> }` presses that entry of a navigation graph (§6), found as its own replay finds it (below), its menu opened first, and the address must become the route of the entry's page; `bind` may be left out when the entry's label alone finds it. `enter: { flow: <graph dir>, bind: <its binding>, given: { .. }, event: <EVENT> }` walks another flow from `given`, by the shortest way its binding can drive, to the transition on `<EVENT>` whose `starts` names this flow (§2, Several flows), and checks its screens on the way; what that `starts` hands over must be this scenario's own `given`. The paths are relative to the binding's file. On arrival the focus must be on the `initialFocus` of the entered flow's first screen, past its rules and server calls, and the flow's own walk then goes on from its initial state, so that every walk of the flow can begin where a person comes in.
|
|
334
|
+
|
|
335
|
+
A binding may tie a navigation graph (§6) to the app instead of a flow. It names the graph with `nav: <id>` in place of `flow`, has the keys a flow's binding has for the app (`root`, `extends`, `apps`, `browser`, `data`, `signIn`, `accounts`), and gives `samples` for the `:params` of the routes; a page is opened at the first app and its route. Without `personas`, each persona of the graph signs in as the account named like it. `personas.<persona>: { as, setup }` lets one account stand for several personas: `as` names the account, and `setup`, commands (`run`) done before that persona's visits, gives the account the persona's facts, such as its role. A `setup` at the top, also commands only, runs once before the first persona, for instance to sign the people up. The other keys say where the replay finds what the graph names, and each may be left out. `frames.<frame>` gives `find`, the frame's chrome, where its `menu` entries are; `page`, where a page of the frame draws its own entries (`link`, `button`); and `user` and `picker`, each `{ open: [actions], find }`: what opens the person's menu or the switcher, and the open menu, where their entries are found. `pages.<page>` gives `refusal`, a locator for the words in which the page says no (the graph says them in prose, so a refusal is checked only with one); `shows`, what proves the page opened, absent when it refuses; or `skip` with a reason. `entries.<from>-><to>` is keyed by the entry's ends, as a code comment cites it (`N:<from>-><to>`), `<from>` being a page or `frame:<frame>`, followed by its `how` or its label key where two entries share their ends (`frame:workspace->start picker`). It gives a locator for the entry's element, where its label is not its accessible name or the entry needs an item (`data: true`); `skip` with a reason; or `follow`. Without a locator in the binding, an entry is found by its label, as the accessible name of what its `how` draws: a link (`menu`, `link`), a button (`button`) or a menu item (`user`, `picker`), in the frame's `find`, its `page` or the open menu.
|
|
336
|
+
|
|
337
|
+
`replay <nav graph dir> --bind <binding>` opens every page the binding can open, as every persona it binds, and checks what the graph says that persona meets there: the page stays at the address it was opened at, and it opens, or refuses where its `opensFor` does not hold (its `refusal` shown and its `shows` not); each bound frame's chrome is there on the frame's pages and absent on the others; and each entry of the page or of its frame is shown where its `when` holds for the persona and absent where it does not. An entry that needs an item is checked only where the binding gives its locator. `--persona <id>` and `--page <id>`, each given once or more, keep the walk to those personas and pages. `--follow` also takes each entry shown, once per persona, and checks that it lands on its page's route; a `button` acts, so it is taken only with `follow: true`, and `follow: false` keeps an entry from being taken at all (one that signs out or deletes). `--no-setup` skips the top-level `setup` and uses the people of the last run again.
|
|
338
|
+
|
|
339
|
+
Replay over HTTP, with no browser, is an open issue; screenshots of every state on the real app are an open issue.
|
|
340
|
+
|
|
341
|
+
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`, `then`, `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.
|
|
283
342
|
|
|
284
|
-
|
|
343
|
+
`then { <variable>: <value> }` says how a step comes out where an effect leaves it to chance (`havoc`, §2): what the host answered, what a folder held. Of the cases the step's transitions can take, the step takes the one in which these variables have these values. A step without `then` takes the model's first case, and a `then` that no case of the step matches stops the tutorial at that step. So a tutorial can go the way a person meets most, such as a host that lists their repositories, when the graph also allows every other answer.
|
|
285
344
|
|
|
286
345
|
`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.
|
|
287
346
|
|
|
@@ -303,7 +362,7 @@ A kit says how the components of `ui.yaml` look in one product: `tokens` and `da
|
|
|
303
362
|
|---|---|
|
|
304
363
|
| 0 | the graph loads and, under `--strict`, nothing is wrong |
|
|
305
364
|
| 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 |
|
|
306
|
-
| 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) |
|
|
365
|
+
| 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, the focus goes to a node that is not shown or a `returnsFocus` does not start at a dialog (§4), 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) |
|
|
307
366
|
|
|
308
367
|
**As text.** A finding is one line in the GNU error format, which compilers, editors and most CI logs read:
|
|
309
368
|
|
|
@@ -356,10 +415,11 @@ Where a standard covers a part, delurio uses it rather than writing its own. Sur
|
|
|
356
415
|
|---|---|---|
|
|
357
416
|
| YAML 1.2 | every graph file | as it is |
|
|
358
417
|
| 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 |
|
|
359
|
-
| OpenAPI 3.1 | an action with a route is an operation (§5) | export and import: #13 |
|
|
418
|
+
| OpenAPI 3.1 | an action with a route is an operation (§5); a server function is not | export and import: #13 |
|
|
360
419
|
| RFC 9457, problem details | the body of a refusal (§5) | as it is |
|
|
361
420
|
| SCXML (W3C, 2015) | what a flow means (§2) | a subset; export: #14 |
|
|
362
|
-
| WAI-ARIA 1.2, Accessible Name and Description Computation 1.2 | roles and
|
|
421
|
+
| WAI-ARIA 1.2, Accessible Name and Description Computation 1.2 | roles, names and checked states in `ui.yaml` (§4) | as they are |
|
|
422
|
+
| ARIA Authoring Practices Guide (W3C WAI) | where the focus goes when a dialog opens and closes (§4) | its dialog pattern, as it is |
|
|
363
423
|
| WCAG 2.2 | the UI rules (#4), and their taxonomy in SARIF (§10) | as it is |
|
|
364
424
|
| ICU MessageFormat; MessageFormat 2 | catalog messages (§4) | simple arguments today; MF2 when an app uses it |
|
|
365
425
|
| BCP 47 | locale names (§4) | as it is |
|
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
|
@@ -12,13 +12,14 @@ import { stepsByEvents } from './story.js';
|
|
|
12
12
|
import { renderScreens } from './wireframe.js';
|
|
13
13
|
import { checkStarts } from './starts.js';
|
|
14
14
|
import { checkChanges } from './changes.js';
|
|
15
|
+
import { checkUi } from './ui-check.js';
|
|
15
16
|
import { KitError, resolveKit } from './kit.js';
|
|
16
17
|
import { checkGoals, findings, loadNav, viewOf } from './nav.js';
|
|
17
18
|
import { schemaKindOf, validateFile } from './schemas.js';
|
|
18
19
|
import { inReadingOrder, mergeDomain } from './domain.js';
|
|
19
20
|
export const CHECK_USAGE = [
|
|
20
|
-
' node src/cli.ts check <graphs folder
|
|
21
|
-
' checks every graph under the
|
|
21
|
+
' node src/cli.ts check <graphs folder>... [--strict] [--baseline <sarif>] [--format sarif --output <file>]',
|
|
22
|
+
' checks every graph under the folders and writes nothing else: GNU error lines on stdout, or SARIF 2.1.0;',
|
|
22
23
|
' exit 0 clean, 1 a graph cannot be loaded or needs a newer format, 2 an error under --strict (new since --baseline)',
|
|
23
24
|
].join('\n');
|
|
24
25
|
const FORMAT = 'delurio-graph/0';
|
|
@@ -29,6 +30,7 @@ const RULES = [
|
|
|
29
30
|
{ id: 'schema', text: "A graph file does not follow its kind's schema (SPEC.md)", level: 'error' },
|
|
30
31
|
{ id: 'domain-twice', text: 'A value of a domain is given in two of its files (SPEC.md §5)', level: 'error' },
|
|
31
32
|
{ id: 'domain-place', text: 'A domain file is not with the rest of its domain (SPEC.md §1)', level: 'error' },
|
|
33
|
+
{ 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
34
|
{ id: 'assertion-violated', text: 'A guarantee of the flow is broken by a reachable situation', level: 'error' },
|
|
33
35
|
{ id: 'main-story-unwalkable', text: 'The declared main story cannot be walked', level: 'error' },
|
|
34
36
|
{ id: 'catalog-key-missing', text: 'A catalog key the screens use is missing', level: 'error' },
|
|
@@ -40,6 +42,8 @@ const RULES = [
|
|
|
40
42
|
{ id: 'changes-note-missing', text: 'A flow whose steps write has no changes note (SPEC.md §4)', level: 'error' },
|
|
41
43
|
{ id: 'changes-note-locale', text: "The changes note is missing from a locale's catalog", level: 'error' },
|
|
42
44
|
{ id: 'source-missing', text: 'A state of a captured flow names no code (SPEC.md §9)', level: 'error' },
|
|
45
|
+
{ id: 'focus-not-shown', text: 'A focus or a returnsFocus gives the focus to a node that is not shown there (SPEC.md §4)', level: 'error' },
|
|
46
|
+
{ id: 'returns-focus-not-dialog', text: 'A returnsFocus does not start at a dialog (SPEC.md §4)', level: 'error' },
|
|
43
47
|
{ id: 'graph-warning', text: 'Another warning of the graph', level: 'error' },
|
|
44
48
|
{ id: 'nav-problem', text: 'A problem of the navigation graph', level: 'error' },
|
|
45
49
|
{ id: 'nav-note', text: 'A note on the navigation graph', level: 'warning' },
|
|
@@ -146,6 +150,12 @@ function checkFlow(dir) {
|
|
|
146
150
|
if (g.flow.main !== undefined && stepsByEvents(model, g.flow.main) === null)
|
|
147
151
|
warn('the declared main story cannot be walked: an event is not possible where it is sent');
|
|
148
152
|
renderScreens(g, warn, kit);
|
|
153
|
+
if (g.ui.absent !== true) {
|
|
154
|
+
const ui = join(dir, 'ui.yaml');
|
|
155
|
+
const text = readFileSync(ui, 'utf8');
|
|
156
|
+
for (const p of checkUi(g, warn))
|
|
157
|
+
out.push(result(p.rule, ui, keyAt(text, p.path), p.message, g.flow.id, p.element));
|
|
158
|
+
}
|
|
149
159
|
for (const h of checkStarts(g, model, ex))
|
|
150
160
|
for (const p of h.problems)
|
|
151
161
|
warn(`${h.from} starts ${h.flow}: ${p}`);
|
|
@@ -165,8 +175,50 @@ function checkFlow(dir) {
|
|
|
165
175
|
}
|
|
166
176
|
return out;
|
|
167
177
|
}
|
|
178
|
+
// what only an HTTP operation has (SPEC.md §5), and why a server function has none of it
|
|
179
|
+
const HTTP_ONLY = {
|
|
180
|
+
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',
|
|
181
|
+
query: 'a server function\'s input is its body, whatever its method',
|
|
182
|
+
operationId: 'a server function is no operation of an OpenAPI document',
|
|
183
|
+
};
|
|
184
|
+
// a server function that is also given what only an HTTP operation has (SPEC.md §5), at its `serverFn` with a note at
|
|
185
|
+
// the other key; the two may come from two files of a split domain, so the domain is read as one first
|
|
186
|
+
function checkServerFunctions(parts, doc, id) {
|
|
187
|
+
const out = [];
|
|
188
|
+
const read = parts.map((p) => {
|
|
189
|
+
try {
|
|
190
|
+
return readYaml(p.text);
|
|
191
|
+
}
|
|
192
|
+
catch {
|
|
193
|
+
return null;
|
|
194
|
+
}
|
|
195
|
+
});
|
|
196
|
+
// the part that gives the action's key, and where in it
|
|
197
|
+
const given = (name, key) => {
|
|
198
|
+
const i = read.findIndex((d) => d?.actions?.[name]?.[key] !== undefined);
|
|
199
|
+
return i < 0 ? null : { file: parts[i].file, ...keyAt(parts[i].text, ['actions', name, key]) };
|
|
200
|
+
};
|
|
201
|
+
const actions = (doc.actions ?? {});
|
|
202
|
+
for (const [name, a] of Object.entries(actions)) {
|
|
203
|
+
if (a === null || typeof a !== 'object' || a.serverFn === undefined)
|
|
204
|
+
continue;
|
|
205
|
+
const at = given(name, 'serverFn');
|
|
206
|
+
if (at === null)
|
|
207
|
+
continue;
|
|
208
|
+
for (const [key, why] of Object.entries(HTTP_ONLY)) {
|
|
209
|
+
if (a[key] === undefined)
|
|
210
|
+
continue;
|
|
211
|
+
const other = given(name, key);
|
|
212
|
+
const said = key === 'route' ? `a route, ${String(a.route)}` : key === 'query' ? 'a query' : `an operationId, ${String(a.operationId)}`;
|
|
213
|
+
const notes = other === null ? [] : [{ file: rel(other.file), line: other.line, column: other.column, message: `its ${key} is given here` }];
|
|
214
|
+
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));
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
return out;
|
|
218
|
+
}
|
|
168
219
|
// 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,
|
|
220
|
+
// them, a file whose id is not its directory's, a domain whose files sit in two directories, and a server function
|
|
221
|
+
// given what only an HTTP operation has
|
|
170
222
|
function checkDomains(files) {
|
|
171
223
|
const byDir = new Map();
|
|
172
224
|
for (const f of files)
|
|
@@ -175,11 +227,13 @@ function checkDomains(files) {
|
|
|
175
227
|
const out = [];
|
|
176
228
|
const dirsOf = new Map(); // a domain's id -> the directories that hold it
|
|
177
229
|
for (const [dir, list] of byDir) {
|
|
178
|
-
const
|
|
230
|
+
const parts = inReadingOrder(list).map((file) => ({ file, text: readFileSync(file, 'utf8') }));
|
|
231
|
+
const merged = mergeDomain(parts);
|
|
179
232
|
for (const p of merged.problems) {
|
|
180
233
|
const notes = p.first === undefined ? [] : [{ file: rel(p.first.file), line: p.first.line, column: p.first.column, message: 'given first here' }];
|
|
181
234
|
out.push(result(p.rule, p.file, p, p.message, merged.id ?? rel(dir), p.element, notes));
|
|
182
235
|
}
|
|
236
|
+
out.push(...checkServerFunctions(parts, merged.doc, merged.id ?? rel(dir)));
|
|
183
237
|
if (merged.id !== null)
|
|
184
238
|
dirsOf.set(merged.id, [...(dirsOf.get(merged.id) ?? []), dir]);
|
|
185
239
|
}
|
|
@@ -259,12 +313,19 @@ export function checkMain(args) {
|
|
|
259
313
|
return i >= 0 ? args[i + 1] : undefined;
|
|
260
314
|
};
|
|
261
315
|
const withValue = ['--baseline', '--format', '--output'];
|
|
262
|
-
const
|
|
263
|
-
if (
|
|
316
|
+
const dirs = args.filter((a, i) => !a.startsWith('--') && !withValue.includes(args[i - 1] ?? ''));
|
|
317
|
+
if (dirs.length === 0) {
|
|
264
318
|
console.error(`usage:\n${CHECK_USAGE}`);
|
|
265
319
|
return 1;
|
|
266
320
|
}
|
|
267
|
-
const
|
|
321
|
+
const notFolder = dirs.find((d) => !existsSync(d) || !statSync(d).isDirectory());
|
|
322
|
+
if (notFolder !== undefined) {
|
|
323
|
+
console.error(`${notFolder} is not a folder\nusage:\n${CHECK_USAGE}`);
|
|
324
|
+
return 1;
|
|
325
|
+
}
|
|
326
|
+
// every folder given, each graph and file once though one folder holds another
|
|
327
|
+
const roots = dirs.map((d) => resolve(d));
|
|
328
|
+
const dirsOfGraphs = [...new Set(roots.flatMap((r) => graphDirs(r)))];
|
|
268
329
|
const strict = args.includes('--strict');
|
|
269
330
|
const format = flag('--format') ?? 'text';
|
|
270
331
|
const output = flag('--output');
|
|
@@ -275,7 +336,7 @@ export function checkMain(args) {
|
|
|
275
336
|
}
|
|
276
337
|
const results = [];
|
|
277
338
|
let broken = false;
|
|
278
|
-
for (const d of
|
|
339
|
+
for (const d of dirsOfGraphs) {
|
|
279
340
|
const file = existsSync(join(d, 'flow.yaml')) ? join(d, 'flow.yaml') : join(d, 'nav.yaml');
|
|
280
341
|
try {
|
|
281
342
|
const newer = newerFormat(file);
|
|
@@ -295,7 +356,7 @@ export function checkMain(args) {
|
|
|
295
356
|
}
|
|
296
357
|
}
|
|
297
358
|
// every graph file against its kind's schema: what an editor with the schemas marks, check reports
|
|
298
|
-
const files = graphFiles(
|
|
359
|
+
const files = [...new Set(roots.flatMap((r) => graphFiles(r)))];
|
|
299
360
|
for (const file of files) {
|
|
300
361
|
for (const f of validateFile(file))
|
|
301
362
|
results.push(result('schema', file, f, f.message, f.graph ?? rel(file), f.element));
|
|
@@ -323,7 +384,7 @@ export function checkMain(args) {
|
|
|
323
384
|
for (const n of r.notes)
|
|
324
385
|
console.log(`${n.file}:${n.line}:${n.column}: note: ${n.message}`);
|
|
325
386
|
}
|
|
326
|
-
const graphs =
|
|
387
|
+
const graphs = dirsOfGraphs.length;
|
|
327
388
|
const errors = results.filter((r) => r.level === 'error').length;
|
|
328
389
|
const warnings = results.filter((r) => r.level === 'warning').length;
|
|
329
390
|
console.error(`delurio check: ${count(graphs, 'graph')}, ${count(errors, 'error')}, ${count(warnings, 'warning')}; exit ${exitCode}`);
|
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/graph.d.ts
CHANGED
|
@@ -94,8 +94,20 @@ export interface UiNode {
|
|
|
94
94
|
disabledIn?: string[];
|
|
95
95
|
emits?: string;
|
|
96
96
|
initialFocus?: string;
|
|
97
|
+
repeat?: string;
|
|
97
98
|
frame?: string;
|
|
99
|
+
value?: Label;
|
|
100
|
+
checked?: boolean | string;
|
|
101
|
+
script?: 'optional' | 'actions';
|
|
102
|
+
source?: string;
|
|
103
|
+
}
|
|
104
|
+
export interface UiEdge {
|
|
105
|
+
labelledBy?: [string, string];
|
|
106
|
+
triggers?: [string, string];
|
|
107
|
+
returnsFocus?: [string, string];
|
|
98
108
|
}
|
|
109
|
+
export declare const CHECKABLE: readonly ['checkbox', 'menuitemcheckbox', 'menuitemradio', 'option', 'radio', 'switch'];
|
|
110
|
+
export declare const isDialog: (n: UiNode | undefined) => boolean;
|
|
99
111
|
export interface Ui {
|
|
100
112
|
absent?: boolean;
|
|
101
113
|
id: string;
|
|
@@ -107,6 +119,8 @@ export interface Ui {
|
|
|
107
119
|
changes?: {
|
|
108
120
|
key: string;
|
|
109
121
|
};
|
|
122
|
+
focus?: Record<string, string>;
|
|
123
|
+
edges?: UiEdge[];
|
|
110
124
|
}
|
|
111
125
|
export interface Graph {
|
|
112
126
|
dir: string;
|
|
@@ -118,5 +132,12 @@ export declare class GraphError extends Error {
|
|
|
118
132
|
}
|
|
119
133
|
export declare function humanize(id: string): string;
|
|
120
134
|
export declare function titleOf(flow: Flow, state: string): string;
|
|
135
|
+
export declare function shownIn(n: UiNode, state: string): boolean;
|
|
136
|
+
export interface FocusAfter {
|
|
137
|
+
node: string;
|
|
138
|
+
by: 'returnsFocus' | 'initialFocus' | 'focus';
|
|
139
|
+
from?: string;
|
|
140
|
+
}
|
|
141
|
+
export declare function focusAfter(ui: Ui, from: string | null, to: string): FocusAfter | null;
|
|
121
142
|
export declare function alternatives(spec: TransitionSpec): Transition[];
|
|
122
143
|
export declare function load(dir: string, read?: (file: string) => string, exists?: (file: string) => boolean): Graph;
|
package/dist/graph.js
CHANGED
|
@@ -2,6 +2,10 @@ import { existsSync, readFileSync } from 'node:fs';
|
|
|
2
2
|
import { join } from 'node:path';
|
|
3
3
|
import { readYaml } from './yaml.js';
|
|
4
4
|
import { identifiers, parseExpr } from './expr.js';
|
|
5
|
+
// the roles whose node may say whether it is `checked` (WAI-ARIA 1.2: the roles that support aria-checked)
|
|
6
|
+
export const CHECKABLE = ['checkbox', 'menuitemcheckbox', 'menuitemradio', 'option', 'radio', 'switch'];
|
|
7
|
+
// a page node drawn over another page, whose closing `returnsFocus` may give the focus back (SPEC.md §4)
|
|
8
|
+
export const isDialog = (n) => n?.type === 'page' && (n.role === 'dialog' || n.role === 'alertdialog');
|
|
5
9
|
export class GraphError extends Error {
|
|
6
10
|
}
|
|
7
11
|
// 'silentRedirect' -> 'silent redirect'; used only when the graph gives no title
|
|
@@ -12,6 +16,33 @@ export function humanize(id) {
|
|
|
12
16
|
export function titleOf(flow, state) {
|
|
13
17
|
return flow.states[state].title ?? humanize(state);
|
|
14
18
|
}
|
|
19
|
+
// a node is shown in a state when the state is in its `in` and not in its `unless`; `when` is read over the context
|
|
20
|
+
export function shownIn(n, state) {
|
|
21
|
+
return (n.in ?? []).includes(state) && !(n.unless ?? []).includes(state);
|
|
22
|
+
}
|
|
23
|
+
// The node that has focus once the flow has moved from the state `from` (null when it starts) into another state `to`,
|
|
24
|
+
// both states the flow stops in (SPEC.md §4, Focus): a dialog that closes gives it back to its `returnsFocus` node when
|
|
25
|
+
// `to` shows that node; else a page that opens gives it to its `initialFocus`, a dialog's before the page it covers;
|
|
26
|
+
// else `focus.<to>`. null when the graph does not say, and on a move from a state to itself.
|
|
27
|
+
export function focusAfter(ui, from, to) {
|
|
28
|
+
if (from === to)
|
|
29
|
+
return null;
|
|
30
|
+
const nodes = ui.nodes;
|
|
31
|
+
const shown = (id, state) => state !== null && nodes[id] !== undefined && shownIn(nodes[id], state);
|
|
32
|
+
for (const e of ui.edges ?? []) {
|
|
33
|
+
const [dialog, node] = e.returnsFocus ?? [];
|
|
34
|
+
if (dialog === undefined || node === undefined || !isDialog(nodes[dialog]))
|
|
35
|
+
continue;
|
|
36
|
+
if (shown(dialog, from) && !shown(dialog, to) && shown(node, to))
|
|
37
|
+
return { node, by: 'returnsFocus', from: dialog };
|
|
38
|
+
}
|
|
39
|
+
const opened = Object.entries(nodes).filter(([id, n]) => n.type === 'page' && n.initialFocus !== undefined && shown(id, to) && !shown(id, from));
|
|
40
|
+
const page = opened.find(([, n]) => isDialog(n)) ?? opened[0];
|
|
41
|
+
if (page !== undefined)
|
|
42
|
+
return { node: page[1].initialFocus, by: 'initialFocus', from: page[0] };
|
|
43
|
+
const node = from === null ? undefined : ui.focus?.[to];
|
|
44
|
+
return node === undefined ? null : { node, by: 'focus' };
|
|
45
|
+
}
|
|
15
46
|
export function alternatives(spec) {
|
|
16
47
|
const list = Array.isArray(spec) ? spec : [spec];
|
|
17
48
|
return list.map((a) => (typeof a === 'string' ? { target: a } : a));
|
|
@@ -62,6 +93,25 @@ export function load(dir, read = (file) => readFileSync(join(dir, file), 'utf8')
|
|
|
62
93
|
if (flow.states[s] === undefined)
|
|
63
94
|
throw new GraphError(`ui node ${id} names the unknown state ${s}`);
|
|
64
95
|
}
|
|
96
|
+
// `checked` is an expression over the context (SPEC.md §3), read when the node is shown
|
|
97
|
+
if (typeof node.checked === 'string') {
|
|
98
|
+
let names;
|
|
99
|
+
try {
|
|
100
|
+
names = identifiers(parseExpr(node.checked));
|
|
101
|
+
}
|
|
102
|
+
catch (err) {
|
|
103
|
+
throw new GraphError(`ui node ${id}: checked: ${err.message}`);
|
|
104
|
+
}
|
|
105
|
+
for (const n of names) {
|
|
106
|
+
if (n !== 'state' && flow.context[n] === undefined && flow.guards[n] === undefined) {
|
|
107
|
+
throw new GraphError(`ui node ${id}: checked: ${node.checked} names ${n}, which is not a variable or a guard of the flow`);
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
for (const s of Object.keys(ui.focus ?? {})) {
|
|
113
|
+
if (flow.states[s] === undefined)
|
|
114
|
+
throw new GraphError(`ui focus names the unknown state ${s}`);
|
|
65
115
|
}
|
|
66
116
|
return { dir, flow, ui, catalog };
|
|
67
117
|
}
|
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/model.d.ts
CHANGED
|
@@ -74,3 +74,25 @@ export interface FinalPath extends PathResult {
|
|
|
74
74
|
index: number;
|
|
75
75
|
}
|
|
76
76
|
export declare function finalPaths(m: Model, ex: Exploration): FinalPath[];
|
|
77
|
+
export interface CoverPath {
|
|
78
|
+
id: string;
|
|
79
|
+
start: Record<string, Scalar>;
|
|
80
|
+
events: string[];
|
|
81
|
+
states: string[];
|
|
82
|
+
transitions: string[];
|
|
83
|
+
covers: string[];
|
|
84
|
+
}
|
|
85
|
+
export interface Cover {
|
|
86
|
+
by: 'states' | 'transitions';
|
|
87
|
+
paths: CoverPath[];
|
|
88
|
+
unreached: string[];
|
|
89
|
+
}
|
|
90
|
+
export declare function transitionsOf(flow: Flow): string[];
|
|
91
|
+
/**
|
|
92
|
+
* Event paths that together pass every reachable state (`states`) or take every reachable transition (`transitions`)
|
|
93
|
+
* of the flow (#4), from the same starts and through the same steps as `explore(m, from, keep)`. Each is a shortest
|
|
94
|
+
* way to the state or transition it is first kept for, so it repeats a state only on the way to something not yet
|
|
95
|
+
* covered. The longest are kept first and a path that covers nothing new is left out: a small set, never every path.
|
|
96
|
+
* The same flow gives the same paths, in the same order, with the same ids.
|
|
97
|
+
*/
|
|
98
|
+
export declare function cover(m: Model, by: 'states' | 'transitions', from?: Scalar[][], keep?: (at: Config, s: Step) => boolean): Cover;
|
package/dist/model.js
CHANGED
|
@@ -446,3 +446,107 @@ export function finalPaths(m, ex) {
|
|
|
446
446
|
}
|
|
447
447
|
return out;
|
|
448
448
|
}
|
|
449
|
+
// every transition of the flow, named as a Step's `taken` names it
|
|
450
|
+
export function transitionsOf(flow) {
|
|
451
|
+
const out = [];
|
|
452
|
+
for (const [state, st] of Object.entries(flow.states)) {
|
|
453
|
+
if (st.type === 'final')
|
|
454
|
+
continue;
|
|
455
|
+
if (st.always !== undefined)
|
|
456
|
+
st.always.forEach((_, i) => out.push(`${state}|always|${i}`));
|
|
457
|
+
else
|
|
458
|
+
for (const [event, spec] of Object.entries(st.on ?? {}))
|
|
459
|
+
alternatives(spec).forEach((_, i) => out.push(`${state}|${event}|${i}`));
|
|
460
|
+
}
|
|
461
|
+
return out;
|
|
462
|
+
}
|
|
463
|
+
// 53 bits of a string, as 14 hex digits (cyrb53): a stable id with no dependency on a platform's crypto
|
|
464
|
+
function hash(text) {
|
|
465
|
+
let h1 = 0xdeadbeef;
|
|
466
|
+
let h2 = 0x41c6ce57;
|
|
467
|
+
for (let i = 0; i < text.length; i++) {
|
|
468
|
+
const c = text.charCodeAt(i);
|
|
469
|
+
h1 = Math.imul(h1 ^ c, 2654435761);
|
|
470
|
+
h2 = Math.imul(h2 ^ c, 1597334677);
|
|
471
|
+
}
|
|
472
|
+
h1 = Math.imul(h1 ^ (h1 >>> 16), 2246822507) ^ Math.imul(h2 ^ (h2 >>> 13), 3266489909);
|
|
473
|
+
h2 = Math.imul(h2 ^ (h2 >>> 16), 2246822507) ^ Math.imul(h1 ^ (h1 >>> 13), 3266489909);
|
|
474
|
+
return (4294967296 * (2097151 & h2) + (h1 >>> 0)).toString(16).padStart(14, '0');
|
|
475
|
+
}
|
|
476
|
+
/**
|
|
477
|
+
* Event paths that together pass every reachable state (`states`) or take every reachable transition (`transitions`)
|
|
478
|
+
* of the flow (#4), from the same starts and through the same steps as `explore(m, from, keep)`. Each is a shortest
|
|
479
|
+
* way to the state or transition it is first kept for, so it repeats a state only on the way to something not yet
|
|
480
|
+
* covered. The longest are kept first and a path that covers nothing new is left out: a small set, never every path.
|
|
481
|
+
* The same flow gives the same paths, in the same order, with the same ids.
|
|
482
|
+
*/
|
|
483
|
+
export function cover(m, by, from = m.initials(), keep) {
|
|
484
|
+
const ex = explore(m, from, keep);
|
|
485
|
+
const stepsOf = (c) => m.steps(c.state, c.ctx).filter((s) => keep === undefined || keep(c, s));
|
|
486
|
+
// the transition that made a situation: the first step of its parent that leads to it, as explore took it
|
|
487
|
+
const via = new Map();
|
|
488
|
+
const made = (i) => {
|
|
489
|
+
let t = via.get(i);
|
|
490
|
+
if (t === undefined) {
|
|
491
|
+
const c = ex.configs[i];
|
|
492
|
+
const p = ex.configs[c.parent];
|
|
493
|
+
const s = stepsOf(p).find((x) => x.target === c.state && x.event === c.event && x.ctx.every((v, j) => v === c.ctx[j]));
|
|
494
|
+
t = s?.taken ?? `${p.state}|${c.event ?? 'always'}|?`;
|
|
495
|
+
via.set(i, t);
|
|
496
|
+
}
|
|
497
|
+
return t;
|
|
498
|
+
};
|
|
499
|
+
const chain = (i) => {
|
|
500
|
+
const out = [];
|
|
501
|
+
for (let k = i; k >= 0; k = ex.configs[k].parent)
|
|
502
|
+
out.push(k);
|
|
503
|
+
return out.reverse();
|
|
504
|
+
};
|
|
505
|
+
const candidates = [];
|
|
506
|
+
if (by === 'states') {
|
|
507
|
+
const first = new Map();
|
|
508
|
+
ex.configs.forEach((c, i) => {
|
|
509
|
+
if (!first.has(c.state))
|
|
510
|
+
first.set(c.state, i);
|
|
511
|
+
});
|
|
512
|
+
for (const i of first.values())
|
|
513
|
+
candidates.push({ at: i, depth: chain(i).length });
|
|
514
|
+
}
|
|
515
|
+
else {
|
|
516
|
+
// the first situation, in exploration order, at which each transition is taken: the end of a shortest way to it
|
|
517
|
+
const seen = new Set();
|
|
518
|
+
for (let i = 0; i < ex.configs.length && seen.size < ex.taken.size; i++) {
|
|
519
|
+
for (const s of stepsOf(ex.configs[i])) {
|
|
520
|
+
if (seen.has(s.taken))
|
|
521
|
+
continue;
|
|
522
|
+
seen.add(s.taken);
|
|
523
|
+
candidates.push({ at: i, last: s, depth: chain(i).length + 1 });
|
|
524
|
+
}
|
|
525
|
+
}
|
|
526
|
+
}
|
|
527
|
+
const covered = new Set();
|
|
528
|
+
const paths = [];
|
|
529
|
+
const order = (c) => c.at * 2 + (c.last === undefined ? 0 : 1);
|
|
530
|
+
for (const c of [...candidates].sort((a, b) => b.depth - a.depth || order(a) - order(b))) {
|
|
531
|
+
const links = chain(c.at);
|
|
532
|
+
const states = links.map((k) => ex.configs[k].state);
|
|
533
|
+
const transitions = links.slice(1).map(made);
|
|
534
|
+
const events = links.slice(1).flatMap((k) => (ex.configs[k].event === null ? [] : [ex.configs[k].event]));
|
|
535
|
+
if (c.last !== undefined) {
|
|
536
|
+
states.push(c.last.target);
|
|
537
|
+
transitions.push(c.last.taken);
|
|
538
|
+
if (c.last.event !== null)
|
|
539
|
+
events.push(c.last.event);
|
|
540
|
+
}
|
|
541
|
+
const covers = [...new Set(by === 'states' ? states : transitions)].filter((x) => !covered.has(x));
|
|
542
|
+
if (covers.length === 0)
|
|
543
|
+
continue;
|
|
544
|
+
for (const x of covers)
|
|
545
|
+
covered.add(x);
|
|
546
|
+
const start = m.scenario(ex.configs[links[0]].ctx);
|
|
547
|
+
paths.push({ id: hash(JSON.stringify([start, transitions])), start, events, states, transitions, covers, order: order(c) });
|
|
548
|
+
}
|
|
549
|
+
paths.sort((a, b) => a.order - b.order);
|
|
550
|
+
const all = by === 'states' ? Object.keys(m.flow.states) : transitionsOf(m.flow);
|
|
551
|
+
return { by, paths: paths.map(({ order: _, ...p }) => p), unreached: all.filter((x) => !covered.has(x)) };
|
|
552
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { Graph } from './graph.ts';
|
|
2
|
+
export interface UiProblem {
|
|
3
|
+
rule: 'focus-not-shown' | 'returns-focus-not-dialog';
|
|
4
|
+
path: string[];
|
|
5
|
+
message: string;
|
|
6
|
+
element: string;
|
|
7
|
+
}
|
|
8
|
+
export declare function checkUi(g: Graph, warn: (message: string) => void): UiProblem[];
|
package/dist/ui-check.js
ADDED
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
// What `check` holds in ui.yaml beyond its schema (SPEC.md §4): `focus` and `returnsFocus` give the focus to a node
|
|
2
|
+
// that is shown where the focus goes, `returnsFocus` starts at a dialog, and the words a field's `value` takes from
|
|
3
|
+
// the catalog are there, as every other node's are. That `value`, `checked` and `script` sit only on the nodes they
|
|
4
|
+
// are for is the schema's; that a `focus` state exists and that `checked` reads the context is the loader's.
|
|
5
|
+
import { alternatives, isDialog, shownIn } from './graph.js';
|
|
6
|
+
const listed = (xs) => (xs.length <= 1 ? xs.join('') : `${xs.slice(0, -1).join(', ')} and ${xs[xs.length - 1]}`);
|
|
7
|
+
// the states the flow stops in after a transition out of `state`: its targets, and past a state with `always` the
|
|
8
|
+
// targets of that state, as far as they go
|
|
9
|
+
function stopsAfter(g, state) {
|
|
10
|
+
const out = [];
|
|
11
|
+
const seen = new Set();
|
|
12
|
+
const ways = (s) => {
|
|
13
|
+
const st = g.flow.states[s];
|
|
14
|
+
return [...(st.always ?? []).map((a) => a.target), ...Object.values(st.on ?? {}).flatMap((spec) => alternatives(spec).map((a) => a.target))];
|
|
15
|
+
};
|
|
16
|
+
const todo = ways(state);
|
|
17
|
+
while (todo.length > 0) {
|
|
18
|
+
const t = todo.shift();
|
|
19
|
+
if (seen.has(t))
|
|
20
|
+
continue;
|
|
21
|
+
seen.add(t);
|
|
22
|
+
if (g.flow.states[t].always !== undefined)
|
|
23
|
+
todo.push(...ways(t));
|
|
24
|
+
else
|
|
25
|
+
out.push(t);
|
|
26
|
+
}
|
|
27
|
+
return out;
|
|
28
|
+
}
|
|
29
|
+
// the states a dialog closes into: those the flow stops in after a state that shows it, and that do not show it
|
|
30
|
+
function closesInto(g, dialog) {
|
|
31
|
+
const d = g.ui.nodes[dialog];
|
|
32
|
+
const out = new Set();
|
|
33
|
+
for (const s of Object.keys(g.flow.states)) {
|
|
34
|
+
if (!shownIn(d, s))
|
|
35
|
+
continue;
|
|
36
|
+
for (const t of stopsAfter(g, s))
|
|
37
|
+
if (!shownIn(d, t))
|
|
38
|
+
out.add(t);
|
|
39
|
+
}
|
|
40
|
+
return [...out];
|
|
41
|
+
}
|
|
42
|
+
export function checkUi(g, warn) {
|
|
43
|
+
const nodes = g.ui.nodes;
|
|
44
|
+
const out = [];
|
|
45
|
+
for (const [state, node] of Object.entries(g.ui.focus ?? {})) {
|
|
46
|
+
const path = ['focus', state];
|
|
47
|
+
const element = `focus/${state}`;
|
|
48
|
+
if (nodes[node] === undefined)
|
|
49
|
+
out.push({ rule: 'focus-not-shown', path, element, message: `focus.${state} names ${node}, which is no node of ui.yaml` });
|
|
50
|
+
else if (!shownIn(nodes[node], state))
|
|
51
|
+
out.push({ rule: 'focus-not-shown', path, element, message: `focus.${state} gives the focus to ${node}, which ${state} does not show: a node has focus only where it is shown (its in and unless, SPEC.md §4)` });
|
|
52
|
+
}
|
|
53
|
+
(g.ui.edges ?? []).forEach((e, i) => {
|
|
54
|
+
if (e.returnsFocus === undefined)
|
|
55
|
+
return;
|
|
56
|
+
const [dialog, node] = e.returnsFocus;
|
|
57
|
+
const path = ['edges', String(i)];
|
|
58
|
+
const element = `edges/returnsFocus/${dialog}`;
|
|
59
|
+
if (!isDialog(nodes[dialog])) {
|
|
60
|
+
const what = nodes[dialog] === undefined ? 'no node of ui.yaml' : 'not a dialog';
|
|
61
|
+
out.push({ rule: 'returns-focus-not-dialog', path, element, message: `returnsFocus starts at ${dialog}, which is ${what}: it starts at a page node whose role is dialog or alertdialog (SPEC.md §4)` });
|
|
62
|
+
return;
|
|
63
|
+
}
|
|
64
|
+
if (nodes[node] === undefined) {
|
|
65
|
+
out.push({ rule: 'focus-not-shown', path, element, message: `returnsFocus gives the focus of ${dialog} to ${node}, which is no node of ui.yaml` });
|
|
66
|
+
return;
|
|
67
|
+
}
|
|
68
|
+
const into = closesInto(g, dialog);
|
|
69
|
+
if (into.some((s) => shownIn(nodes[node], s)))
|
|
70
|
+
return;
|
|
71
|
+
const where = into.length === 0 ? `the dialog ${dialog} never closes into a state the flow stops in` : `no state ${dialog} closes into shows it (${listed(into)})`;
|
|
72
|
+
out.push({ rule: 'focus-not-shown', path, element, message: `returnsFocus gives the focus of ${dialog} to ${node}, but ${where} (SPEC.md §4)` });
|
|
73
|
+
});
|
|
74
|
+
// a field's value in words of the catalog, held as every other node's words are
|
|
75
|
+
const words = (v) => {
|
|
76
|
+
for (const key of [...(v.key === undefined ? [] : [v.key]), ...(v.oneOf ?? [])]) {
|
|
77
|
+
const message = g.catalog[key];
|
|
78
|
+
if (message === undefined) {
|
|
79
|
+
warn(`catalog key ${key} is missing`);
|
|
80
|
+
continue;
|
|
81
|
+
}
|
|
82
|
+
for (const [, p] of message.matchAll(/\{(\w+)\}/g))
|
|
83
|
+
if (g.ui.samples[p] === undefined)
|
|
84
|
+
warn(`no sample value for {${p}} in ${key}`);
|
|
85
|
+
}
|
|
86
|
+
};
|
|
87
|
+
for (const n of Object.values(nodes))
|
|
88
|
+
if (n.value !== undefined)
|
|
89
|
+
words(n.value);
|
|
90
|
+
return out;
|
|
91
|
+
}
|
package/dist/wireframe.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { titleOf } from './graph.js';
|
|
1
|
+
import { shownIn, titleOf } from './graph.js';
|
|
2
2
|
import { drawWith, mark } from './kit.js';
|
|
3
3
|
const esc = (s) => s.replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>').replace(/"/g, '"');
|
|
4
4
|
function fill(g, key, warn) {
|
|
@@ -42,9 +42,6 @@ function accessibleName(g, n, warn) {
|
|
|
42
42
|
return texts(g, n, warn)[0];
|
|
43
43
|
return undefined;
|
|
44
44
|
}
|
|
45
|
-
function shownIn(n, state) {
|
|
46
|
-
return (n.in ?? []).includes(state) && !(n.unless ?? []).includes(state);
|
|
47
|
-
}
|
|
48
45
|
function chips(it) {
|
|
49
46
|
const n = it.node;
|
|
50
47
|
const parts = [n.role ?? n.type];
|
package/package.json
CHANGED
|
@@ -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",
|
package/schemas/ui.schema.json
CHANGED
|
@@ -51,9 +51,16 @@
|
|
|
51
51
|
"propertyNames": { "$ref": "#/$defs/identifier" },
|
|
52
52
|
"additionalProperties": { "$ref": "#/$defs/node" }
|
|
53
53
|
},
|
|
54
|
+
"focus": {
|
|
55
|
+
"type": "object",
|
|
56
|
+
"description": "The node that has focus when the flow enters a state from another state, after someone acts or a step ends, by state. A page that opens gives the focus to its `initialFocus` instead, and a dialog that closes to its `returnsFocus` node. The node is shown in that state.",
|
|
57
|
+
"propertyNames": { "$ref": "#/$defs/stateRef" },
|
|
58
|
+
"additionalProperties": { "$ref": "#/$defs/nodeRef", "description": "The node that has focus in that state." },
|
|
59
|
+
"examples": [{ "consent": "retryAlert" }]
|
|
60
|
+
},
|
|
54
61
|
"edges": {
|
|
55
62
|
"type": "array",
|
|
56
|
-
"description": "Relations the page and the checks use: a node labelled by another, an action that leads to a state.",
|
|
63
|
+
"description": "Relations the page and the checks use: a node labelled by another, an action that leads to a state, the node a dialog gives the focus back to.",
|
|
57
64
|
"items": { "$ref": "#/$defs/edge" }
|
|
58
65
|
},
|
|
59
66
|
"rules": {
|
|
@@ -165,6 +172,35 @@
|
|
|
165
172
|
}
|
|
166
173
|
]
|
|
167
174
|
},
|
|
175
|
+
"value": {
|
|
176
|
+
"$comment": "exactly one of key, literal or oneOf",
|
|
177
|
+
"type": "object",
|
|
178
|
+
"description": "What a field holds when it is shown, until someone types in it, in one of these forms: `{ key, params }` from the catalog, `{ literal }` (`{ literal: \"\" }` for an empty field), or `{ oneOf: [keys] }`.",
|
|
179
|
+
"additionalProperties": false,
|
|
180
|
+
"properties": {
|
|
181
|
+
"key": { "$ref": "#/$defs/catalogKey", "description": "The catalog key of the message the field holds." },
|
|
182
|
+
"params": {
|
|
183
|
+
"type": "object",
|
|
184
|
+
"description": "The data each `{param}` of the message stands for (e.g. `title: note.title`); the page fills it from `samples`.",
|
|
185
|
+
"additionalProperties": { "type": "string", "description": "The data the parameter stands for." }
|
|
186
|
+
},
|
|
187
|
+
"literal": { "type": "string", "description": "What the field holds, as it is; an empty string for an empty field." },
|
|
188
|
+
"oneOf": {
|
|
189
|
+
"type": "array",
|
|
190
|
+
"description": "Catalog keys of which one is held, depending on the data.",
|
|
191
|
+
"minItems": 1,
|
|
192
|
+
"items": { "$ref": "#/$defs/catalogKey" }
|
|
193
|
+
}
|
|
194
|
+
},
|
|
195
|
+
"oneOf": [{ "required": ["key"] }, { "required": ["literal"] }, { "required": ["oneOf"] }],
|
|
196
|
+
"allOf": [
|
|
197
|
+
{
|
|
198
|
+
"$comment": "params go with key or oneOf",
|
|
199
|
+
"if": { "required": ["literal"] },
|
|
200
|
+
"then": { "properties": { "params": false } }
|
|
201
|
+
}
|
|
202
|
+
]
|
|
203
|
+
},
|
|
168
204
|
"node": {
|
|
169
205
|
"type": "object",
|
|
170
206
|
"description": "A node of a screen.",
|
|
@@ -207,25 +243,46 @@
|
|
|
207
243
|
"description": "The event the node sends when pressed: an event of the flow, UPPER_SNAKE.",
|
|
208
244
|
"pattern": "^[A-Z][A-Z0-9_]*$"
|
|
209
245
|
},
|
|
210
|
-
"initialFocus": { "$ref": "#/$defs/nodeRef", "description": "On a page: the node that has focus when it opens." },
|
|
246
|
+
"initialFocus": { "$ref": "#/$defs/nodeRef", "description": "On a page: the node that has focus when it opens, at the flow's start or when a transition shows it." },
|
|
211
247
|
"repeat": { "type": "string", "description": "The node is drawn once per item of this data.", "examples": ["request.scopes"] },
|
|
212
248
|
"frame": {
|
|
213
249
|
"description": "For a page: whether it may be framed; `never` (served with CSP frame-ancestors 'none').",
|
|
214
250
|
"const": "never"
|
|
215
251
|
},
|
|
252
|
+
"value": { "$ref": "#/$defs/value", "description": "On a field: what it holds when it is shown, until someone types in it. A replay reads the field's value and compares it." },
|
|
253
|
+
"checked": {
|
|
254
|
+
"type": ["boolean", "string"],
|
|
255
|
+
"minLength": 1,
|
|
256
|
+
"description": "On a checkbox, menuitemcheckbox, menuitemradio, option, radio or switch: whether it is checked (or selected) when it is shown, as an expression over the flow's context (SPEC.md §3), or true or false. A replay reads its checked state and compares it.",
|
|
257
|
+
"examples": [true, "pinned", "plan == 'yearly'"]
|
|
258
|
+
},
|
|
259
|
+
"script": {
|
|
260
|
+
"description": "On a page: how much of it works without JavaScript. `optional`: the page and its actions (plain forms and links). `actions`: the page is drawn and read without it (rendered on the server), and only its actions need it. Without it, the page needs JavaScript. A replay's second walk with JavaScript off checks an `optional` page and takes its actions, and checks an `actions` page but its actions, and ends there.",
|
|
261
|
+
"enum": ["optional", "actions"]
|
|
262
|
+
},
|
|
216
263
|
"source": { "$ref": "#/$defs/sourceAnchor" }
|
|
217
264
|
},
|
|
218
265
|
"allOf": [
|
|
219
266
|
{
|
|
220
|
-
"$comment": "initialFocus and
|
|
267
|
+
"$comment": "initialFocus, frame and script are only on a page",
|
|
221
268
|
"if": { "not": { "properties": { "type": { "const": "page" } } } },
|
|
222
|
-
"then": { "properties": { "initialFocus": false, "frame": false } }
|
|
269
|
+
"then": { "properties": { "initialFocus": false, "frame": false, "script": false } }
|
|
270
|
+
},
|
|
271
|
+
{
|
|
272
|
+
"$comment": "value is only on a field: what the field holds",
|
|
273
|
+
"if": { "not": { "properties": { "type": { "const": "field" } } } },
|
|
274
|
+
"then": { "properties": { "value": false } }
|
|
275
|
+
},
|
|
276
|
+
{
|
|
277
|
+
"$comment": "checked is only on a node whose role is checkbox, menuitemcheckbox, menuitemradio, option, radio or switch",
|
|
278
|
+
"if": { "not": { "required": ["role"], "properties": { "role": { "enum": ["checkbox", "menuitemcheckbox", "menuitemradio", "option", "radio", "switch"] } } } },
|
|
279
|
+
"then": { "properties": { "checked": false } }
|
|
223
280
|
}
|
|
224
281
|
]
|
|
225
282
|
},
|
|
226
283
|
"edge": {
|
|
227
284
|
"type": "object",
|
|
228
|
-
"description": "A relation between nodes: `{ labelledBy: [node, labelNode] }
|
|
285
|
+
"description": "A relation between nodes: `{ labelledBy: [node, labelNode] }`, `{ triggers: [node, state] }` or `{ returnsFocus: [dialog, node] }`.",
|
|
229
286
|
"minProperties": 1,
|
|
230
287
|
"maxProperties": 1,
|
|
231
288
|
"additionalProperties": false,
|
|
@@ -243,6 +300,13 @@
|
|
|
243
300
|
"prefixItems": [{ "$ref": "#/$defs/nodeRef" }, { "$ref": "#/$defs/stateRef" }],
|
|
244
301
|
"minItems": 2,
|
|
245
302
|
"maxItems": 2
|
|
303
|
+
},
|
|
304
|
+
"returnsFocus": {
|
|
305
|
+
"type": "array",
|
|
306
|
+
"description": "A dialog (a page node whose role is dialog or alertdialog) and the node that has focus when it closes, usually the one that opened it. It wins over `focus` for the state the dialog closes into, when that state shows the node.",
|
|
307
|
+
"prefixItems": [{ "$ref": "#/$defs/nodeRef" }, { "$ref": "#/$defs/nodeRef" }],
|
|
308
|
+
"minItems": 2,
|
|
309
|
+
"maxItems": 2
|
|
246
310
|
}
|
|
247
311
|
}
|
|
248
312
|
}
|