Zurück zu Projekte

SurrealDB Client Generator

Keep SurrealDB schemas, validation, and TypeScript clients in sync.

surql-gen reads SurrealDB schema definitions from a live database or .surql files and generates Zod schemas, TypeScript types, and optional client helpers while preserving customization points outside regenerated code.

Die deutsche Route nutzt bewusst englische Projektinhalte, bis Übersetzungen vorliegen.

Warum es zählt

SurrealDB projects move fast, and drift is easy to hide. The database schema says one thing, TypeScript says another, Zod says a third, and client wrappers become a collection of guesses.

Was sich ändert

surql-gen treats SurrealDB schema information as the source for generated application contracts. It can connect to an existing database or load .surql/.surrealql files through a temporary SurrealDB container, then emit Zod schemas, TypeScript types, and optional basic CRUD helpers.

How the model holds

Configuration points the generator at a live SurrealDB instance, a schema file, or a schema directory; the tool introspects definitions through SurrealDB and writes Zod schemas, inferred types, optional client helpers, and preserved extension points.
schema pipeline surql-gen
SurrealQL DEFINE FIELD email ON user
Zod z.object validation
types client helpers schema extensions

Configuration points the generator at a live SurrealDB instance, a schema file, or a schema directory; the tool introspects definitions through SurrealDB and writes Zod schemas, inferred types, optional client helpers, and preserved extension points.

SurrealDB Client Generator is for teams that want SurrealDB’s flexibility without letting the application drift away from the database contract.

The enterprise problem is mundane but expensive: schemas evolve, product teams move fast, and TypeScript interfaces become stale. That drift shows up later as runtime validation bugs, broken assumptions, and slower delivery because nobody fully trusts the data boundary.

The generator reads a live SurrealDB instance or .surql files, then produces Zod schemas, inferred TypeScript types, and optional client helpers. Generated files can be refreshed while customization stays outside the regenerated output.

The value is not a heavy ORM promise. The value is a repeatable contract workflow: database definition in, validation and TypeScript surface out, with enough structure for CI and enough flexibility for real SurrealDB projects.

Wo es Enterprise-Druck konkret adressiert.

Data contracts become generated artifacts that can be reviewed in pull requests and CI instead of living in tribal memory.
Runtime validation with Zod helps teams detect schema drift before it becomes product behavior.
Maintainability improves because regenerated files and customization points are separated.
Delivery stays faster because developers use typed client surfaces while the database schema remains the source input.

SurrealDB Client Generator macht Druck zu einem Betriebsmodell.

Schema-file mode with a temporary SurrealDB Docker container

Existing database mode through configured connection parameters

Generated Zod schemas, inferred TypeScript types, and optional client helpers

Regenerated _generated files separated from preserved schema extension files

CLI usage through npx, project install, or global installation

Wo Entscheider hinschauen sollten.

When SurrealDB access code should start generated, not hand-maintained
When schema files are part of setup, migrations, or local development
When runtime validation must match the actual database contract
When teams want repeatable code generation to expose drift before it becomes product behavior