@guestcraft/codegen
Questi contenuti non sono ancora disponibili nella tua lingua.
Isolated Hey API 0.99.0 / TypeScript 6 compiler API workspace. generate.ts generates
SDK operations/types/Zod response schemas and React query factories from openapi/v1.json
(hey-api.ts), splits them into one module per OpenAPI tag (split.ts; a request body’s schema
goes with the tags of the operations that take it), then emits JavaScript
and declarations into the owning packages. Hey API interprets the contract; the split only moves
its declarations, reading each operation’s tag. Before it runs, tags.ts checks that every
operation has an ID and exactly one tag, and that no two IDs name the same function; the split
refuses generated shapes it cannot place (a statement declaring several names, an import without
bindings, a top-level value that is no operation) with the file and line. The generator marks the
GuestCraft-Workspace-Id header optional in its copy of the contract: the SDK’s client sends it.
A binary response (format: binary, such as a maintenance photo) is validated as a Blob,
which Hey API’s client answers for it, rather than as the string its Zod plugin would expect.
See ADR 0022 and its 2026-10-30 amendment for the split and the upstream optional-property
compatibility setting; handwritten code keeps the strict TS7 preset.
The problem schema is an additional root in zod/problem.gen: every transport uses it,
so its dependency graph stays separate from shared guest and reservation response schemas.
This changes module placement only; validation and the original barrel exports stay intact.
The handwritten facade inputs are roots of their existing property and Channex tag modules
for the same reason. They validate configuration without initializing guest/stay schemas.
pnpm --filter @guestcraft/codegen test runs the unit tests. They include a golden fixture:
the pinned Hey API’s output for the small contract in fixtures/contract.json, kept in
fixtures/hey-api/, which the test regenerates, splits and compiles. A Hey API upgrade that
changes its output fails the test; review the new shapes, then update the files with
pnpm --filter @guestcraft/codegen test -- -u.
The temporary compiler project resolves Zod, TanStack Query and React declarations
from this workspace. Those devDependencies are intentional compiler inputs, listed
in Knip. generate:check compares both output trees without changing them.
Temporary compiler inputs live in .cache/ inside this workspace, keeping module
resolution local and interrupted generations out of source checks. Normal completion
removes its own unique staging directory. No handwritten source is excluded.