Generate types
FFDB CLI can inspect a live app, fetch schema metadata, and write a generated Database interface that matches the tables in your instance.
This command is the bridge between your running FFDB instance and the type-safe client. It can read values from the environment or from explicit CLI flags.
Basic usage
ffdb-cli generate --url http://localhost:3000 --token your-admin-token --out ./src/ffdb.types.ts
If your environment already defines the connection values, you can shorten it to:
ffdb-cli generate
Why this command is central
Type generation is the contract between live schema and application code.
- Name
Schema-to-code alignment- Description
Prevents drift between table changes and query typing.
- Name
Safer refactors- Description
Type errors surface quickly when schema fields change.
- Name
Better editor ergonomics- Description
Autocomplete and query hinting become accurate for your actual app schema.
Flags and env fallbacks
- Name
--url <url>- Type
- string
- Description
The FFDB API URL. This overrides
API_URLfrom your.envfile.
- Name
--token <token>- Type
- string
- Description
The admin token or API key. This overrides
FFDB_AUTH_TOKENfrom your.envfile.
- Name
--out <path>- Type
- string
- Description
Output path for the generated types file. Defaults to
./ffdb.types.ts.
- Name
--env <path>- Type
- string
- Description
Optional path to a
.envfile. Defaults to.env.
The generator validates that the API URL starts with http:// or https://, inspects your app schema, and writes the generated types file to disk.
What gets generated
The output is a Database interface plus one interface per table in your app schema. The generated file is intended to be imported by ffdb-client so createClient and the query helpers can stay type-safe.
Typical shape:
export interface User {
id: string
email: string
name: string | null
}
export interface Database {
user: User
// ...other tables
}
- Name
Schema source- Description
The CLI reads schema information from the target FFDB app URL you provide.
- Name
Table mapping- Description
Each table becomes a TypeScript interface, and the final
Databaseinterface maps table names to those interfaces.
- Name
Field typing- Description
Numeric, text, boolean, date/time, and blob columns are converted into TypeScript types.
Notes
Use this command whenever you want the live schema to become a typed Database interface. The generated file is the source of truth for app code that uses ffdb-client.
Regeneration strategy
- Regenerate after schema migrations or table/column changes.
- Commit generated types alongside schema-related app changes.
- Run generation in CI or release workflows when schema can drift from local state.
Treat generated types as derived artifacts. Edit schema, then regenerate; avoid hand-editing generated type files.