forgedb generate
Transpile a .forge schema into tailored Rust, a REST API, OpenAPI, stubs, or a language runtime binding.
Transpile your schema into code. A target is either a standalone artifact (all,
rust, api, openapi, stubs, ffi, transform) or a runtime (python, node,
bun, go, rust, browser) paired with a mode flag (--sdk, --runtime, or
--replica). The REST client SDKs (--sdk) ship for TypeScript, Python, Rust, and Go.
Synopsis#
forgedb generate [target] [--sdk|--runtime|--replica] [flags]The target defaults to all.
Targets#
| Target | Kind | Produces |
|---|---|---|
all | standalone | Every default artifact (rust, typescript, api, openapi, stubs) — plus the opt-in wasm/ffi when listed in [generate].targets. |
rust | standalone | database.rs — the tailored Rust database. |
api | standalone | api.rs — the REST API + OpenAPI document. |
openapi | standalone | openapi.json — the OpenAPI 3.1 document (offline). |
stubs | standalone | placeholder stubs README (no UI codegen today). |
ffi | standalone | C-ABI FFI bindings. |
transform | standalone | The offline migration transformer crate (requires --from/--to; see migrations). |
node --sdk / bun --sdk | runtime | TypeScript REST client SDK. |
python --sdk | runtime | Python REST client (stdlib urllib). |
rust --sdk | runtime | Rust REST client crate (reqwest). Bare rust is the standalone database above. |
go --sdk | runtime | Go REST client package (stdlib net/http). |
python --runtime | runtime | PyO3 in-process native binding. |
node --runtime / bun --runtime | runtime | NAPI-RS in-process native binding. |
go --runtime | runtime | Experimental cgo in-process binding over the FFI cdylib. |
browser --replica | runtime | WASM in-process read-replica follower. |
Standalone targets take no mode
Passing --sdk/--runtime/--replica to a bare standalone target (e.g. api --sdk)
is an error, and a runtime target requires a mode. The one crossover is rust:
bare rust emits the standalone database, while rust --sdk emits the REST client
crate. The node|bun --replica combination (server-side WASM replica) is not yet
implemented and errors explicitly. The old flat verbs generate typescript /
generate wasm were renamed — use node --sdk / browser --replica.
Flags#
| Flag | Type / default | Meaning |
|---|---|---|
[target] | string (all) | The artifact or runtime to generate. |
--sdk | bool | Mode (runtime targets): network REST client. |
--runtime | bool | Mode (runtime targets): in-process native FFI binding. |
--replica | bool | Mode (runtime targets): in-process read-replica follower. |
--check | bool (false) | Verify nothing needs regeneration (CI mode); do not write. |
-o, --output <DIR> | string ([generate].output, else generated) | Output directory. |
-s, --schema <PATH> | string (auto-discover) | Schema file path. Auto-discovery looks for schema.forge, schema.lang, schema.forgedb. |
-f, --force | bool (false) | Regenerate even if up-to-date; overwrite existing output. |
--from <N> | u32 | Origin format version — transform target only. |
--to <N> | u32 | Destination format version — transform target only. |
Generate-time config is baked in
The schema-blind [runtime]/[storage] knobs in forgedb.toml are baked into
database.rs at generate time, so the emitted code carries the behavior you configured.
See configuration.
Examples#
Generate everything into ./generated:
forgedb generate all --output ./generatedGenerate only the Rust database from a specific schema:
forgedb generate rust --schema ./schema.forgeGenerate the TypeScript REST SDK for Node:
forgedb generate node --sdkGenerate a REST client SDK for another language on your stack:
forgedb generate python --sdk # -> python-sdk/ (urllib)
forgedb generate rust --sdk # -> rust-sdk/ (reqwest)
forgedb generate go --sdk # -> go-sdk/ (net/http)Fail CI if generated code is stale:
forgedb generate all --check