Commands
extract
Extract marked TypeScript types into a Type Bus manifest. Runs in your API repo.
Sweeps your API repo for bus-marked types, validates them, and writes chowbea.bus.json.
This is the only command that runs in your API repo rather than your frontend. It's the backend half of the Type Bus.
chowbea-axios extract✓ done Wrote 14 type(s) to /repo/chowbea.bus.jsonFlags
| Flag | Default | Purpose |
|---|---|---|
-p, --project <path> | nearest tsconfig.json | Use a specific TypeScript config |
-o, --out <path> | ./chowbea.bus.json | Write the manifest elsewhere (parent dirs are created) |
--check | off | Validate only, never write. Non-zero exit on violations. |
--diff <url|file> | — | Compare against a baseline manifest; reports added / changed / removed |
--fail-on-removed | off | With --diff, exit non-zero when types disappeared |
--watch | off | Re-extract on source change (300ms debounce; ignores build output, node_modules, and .d.ts) |
What it does
- Loads your
tsconfig.jsonand builds a TypeScript program — it needs real type information to enforce the closed-world rule. - Sweeps both marking channels:
*.chowbea.tsbarrels and/** @chowbea-export */tags. - Validates everything — types-only, closed world, duplicate names, reserved keys,
rootDircontainment. - Slices each declaration's source text verbatim.
- Writes the manifest — unless its content hash matches the manifest already on disk, in which case the write is skipped and you get
Type bus unchanged — N type(s).A missing or corrupt manifest is always rewritten.
On any violation, nothing is written and every error is reported at once:
src/bus.chowbea.ts:3 "GradeMap" references "Grade" (src/exams/models.ts:12) which is not
on the bus — add it to a .chowbea.ts barrel or mark it @chowbea-export.
Type bus extraction failed with 1 error(s).Common invocations
# dev loop — pairs with busHandler()'s file mode, no server restarts
chowbea-axios extract --watch
# CI: is the bus valid?
chowbea-axios extract --check
# CI: does this PR break a consumer?
chowbea-axios extract --check --diff "$STAGING_BUS_URL" --fail-on-removed
# monorepo with a build-specific config
chowbea-axios extract --project tsconfig.build.jsonIn your build
The manifest must ship with your deploy — a running server has no TypeScript source to extract from:
{
"scripts": {
"prebuild": "chowbea-axios extract",
"build": "nest build"
}
}Don't commit chowbea.bus.json. It's a build output, regenerated from the source being deployed, which is what makes drift impossible.
See also
- How the Type Bus works — concepts and wire format
- Authoring bus types — marking channels and rules
- Extract & serve — the backend endpoint
- CI & breaking changes — gates in depth