usedesign 1.5.0 → 1.5.2

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/README.md CHANGED
@@ -1,27 +1,27 @@
1
1
  # usedesign — TypeScript
2
2
 
3
- The reference implementation: validates Operation Cards and runs the five checks against a
4
- repository.
3
+ The reference implementation: validates Operation Cards and form contracts, and runs the five
4
+ checks against a repository.
5
5
 
6
6
  ```bash
7
7
  npx usedesign validate examples/library/
8
8
  npx usedesign check usedesign.config.yaml
9
9
  ```
10
10
 
11
- Exit status is `1` when anything reported an error, `0` otherwise, `2` on misuse. That is the
12
- whole CI contract.
11
+ Exit status is `1` when anything reported an error, `0` otherwise, `2` on misuse or on input that
12
+ cannot be read. That is the whole CI contract.
13
13
 
14
14
  ## Status
15
15
 
16
- **Complete against the corpus, published to npm as `usedesign`.** Everything below runs from a
16
+ **Complete against both corpora, published to npm as `usedesign`.** Everything below runs from a
17
17
  clone as well as through `npx usedesign`.
18
18
 
19
19
  | | |
20
20
  |---|---|
21
- | Cards corpus | **84 / 84** |
22
- | Repository corpus | **55 / 55** |
21
+ | Cards corpus | every case passes (`tests/conformance/cards/`) |
22
+ | Repository corpus | every case passes (`tests/conformance/checks/`) |
23
23
  | Runtime | Node ≥ 20, no native modules |
24
- | Dependencies | `ajv`, `ajv-formats`, `yaml`, `fast-xml-parser` |
24
+ | Dependencies | `ajv`, `ajv-formats`, `yaml`, `saxes` |
25
25
 
26
26
  ```bash
27
27
  npm install && npm run build
@@ -29,30 +29,31 @@ npm test # both corpora
29
29
  node dist/cli.js check ../../tests/fixtures/library-service/usedesign.config.yaml
30
30
  ```
31
31
 
32
- The last command is expected to report **six errors** — the fixture is deliberately rotten, and
33
- a clean run there would mean the checks had stopped working.
32
+ The last command is expected to exit `1`: the fixture is deliberately rotten — two wild
33
+ endpoints, three unproven steps, one missing evidence path — and it has no storage inventory,
34
+ which check 4 reports as not run. A clean run there would mean the checks had stopped working.
34
35
 
35
36
  ## Commands
36
37
 
37
38
  | Command | What it does |
38
39
  |---|---|
39
- | `validate <path…>` | Cards against the JSON Schema **and** the cross-card rules. `--no-schema` keeps only the latter |
40
- | `check <config>` | The three invariants: no wild endpoints, no unproven steps, no maturity beyond its evidence |
40
+ | `validate <path…>` | Cards and form contracts against the JSON Schema **and** the cross-card rules. `--no-schema` keeps only the latter |
41
+ | `check <config>` | Checks 1–5: no wild endpoints, no unproven steps, no maturity beyond its evidence, no imagined storage, the form matches its contract. A config's `checks:` names the ones that apply to the repository |
42
+ | `scaffold <openapi.json> --out <dir>` | A draft card per route the cards do not declare yet, read from the application's own OpenAPI. Every draft fails validation on purpose |
43
+ | `preview <config> --out <file.html>` | Form contracts as a three-rail wireframe page |
44
+ | `gen openapi <config> --out <file.json>` | An OpenAPI contract derived from the cards — the opposite direction to `scaffold` |
41
45
  | `conformance` | Both corpora. `--cards` / `--checks` to run one |
42
46
 
43
47
  ## What validation is, in two halves
44
48
 
45
49
  `validate` runs the published schema and the cross-reference rules, and the split is not
46
- cosmetic. Measured on the 10 invalid corpus cases:
50
+ cosmetic. The schema catches what a field looks like — a missing required field, an enum out of
51
+ range, a malformed step id, an interface with no transport. It cannot see a test covering a step
52
+ that does not exist, a screen covering a step that does not exist, or one step id used twice.
47
53
 
48
- - **7** are caught by the schema — a missing required field, an enum out of range, a malformed
49
- step id, an interface with no transport;
50
- - **3** are invisible to it — a test covering a step that does not exist, a UI screen covering a
51
- step that does not exist, and the same step id used twice.
52
-
53
- All three of the invisible ones are the same shape: *a name that points at nothing*. A schema can
54
- say what a field looks like; only a checker holding the whole card can say whether the thing it
55
- names is there.
54
+ Those invisible ones are the same shape: *a name that points at nothing*. A schema can say what a
55
+ field looks like; only a checker holding the whole card — and every other card of the run — can
56
+ say whether the thing it names is there.
56
57
 
57
58
  That second group is the reason this tool exists rather than a bare `ajv` invocation. A schema
58
59
  validates *form*; the rules validate *meaning*, and meaning is where cards rot.
@@ -66,19 +67,27 @@ The schema itself is never vendored: the compiled package carries a copy of the
66
67
  return after the closing fence; scalars came back with `\r` attached, ids stopped matching
67
68
  their pattern, and one card would not parse at all. Every symptom looked like a format problem
68
69
  and none of them was. `frontMatter` normalises before parsing.
69
- - **The three checks are ported line for line from the Python prototype**, including the noise
70
+ - **A field is read only in its type.** A list is read as a list, a map as a map, a name as text;
71
+ a value of another type is absent to the rules and to the checks, and the schema names it. A
72
+ rule that trusts the shape of its input stops with a stack trace on the first card that lies.
73
+ - **The Python implementation prints what this one prints, line for line**, including the noise
70
74
  suppressions — a dead exclusion is not reported when there are no routes, and a step whose only
71
75
  test failed is reported once, not twice. Two implementations that disagree about what to stay
72
- quiet about are two dialects.
76
+ quiet about are two dialects; CI compares them on the corpora and on the fixtures.
73
77
 
74
78
  ## Layout
75
79
 
76
80
  | File | What is in it |
77
81
  |---|---|
78
- | `src/core.ts` | Findings, front matter, config, globbing — no rules |
79
- | `src/validate.ts` | The schema and the cross-card rules |
80
- | `src/checks.ts` | The three checks |
82
+ | `src/core.ts` | Findings, front matter, config, file collection, typed reads — no rules |
83
+ | `src/validate.ts` | The schema and the cross-card rules for cards and form contracts |
84
+ | `src/checks.ts` | The five checks |
81
85
  | `src/conformance.ts` | The corpus runners |
86
+ | `src/scaffold.ts` | Draft cards from an OpenAPI document |
87
+ | `src/gen.ts` | `gen openapi`: an OpenAPI document from the cards |
88
+ | `src/preview.ts` | The wireframe page of form contracts |
89
+ | `src/formInventory.ts` | Helper for producing the form inventory check 5 reads |
90
+ | `src/index.ts` | Library entry point: findings, front matter, config, card collection, card validation, checks 1–3 and the `CHECKS` map of all five, the corpus runners, the form-inventory helpers |
82
91
  | `src/cli.ts` | Argument handling and output |
83
92
 
84
93
  Rules never live in a helper: a rule that hides inside a utility is a rule nobody reviews.
package/dist/checks.d.ts CHANGED
@@ -22,7 +22,10 @@ type Index = Map<string, TestCase[]>;
22
22
  /** Resolve a card's test id to report entries. Full-id matching only — never a substring. */
23
23
  export declare function findCases(testId: string, byFull: Index, byName: Index): TestCase[];
24
24
  export declare function checkCoverage(config: Config, base: string): CheckResult;
25
- /** `implemented` is one path or several — one example joins two with ' + '. */
25
+ /**
26
+ * `implemented` is one path or several — one example joins two with ' + '. A value that is not a
27
+ * string is absent (1.5.1): `true` was the path `true` here and `True` in the Python prototype.
28
+ */
26
29
  export declare function evidencePaths(value: unknown): string[];
27
30
  export declare function checkMaturity(config: Config, base: string, today?: Date): CheckResult;
28
31
  export declare function checkStorage(config: Config, base: string): CheckResult;