Expand description
Codegen — emit typed bindings for a ClickHouse table in two directions:
- ClickHouse → Rust rows (
ch_type_to_rust/rust_row_struct): the TS→Rust bridge. TypeScript owns a (static) table; this turns its live/spec columns into a Rust#[derive(Row)]struct so the Rust services get faithful, drift-checked rows instead of hand-writing them. Pair withintrospect+check_drift. Temporal types map toString(the works-everywhere default over the HTTP/RowBinary boundary; refine totime/chronobehind features). TableSpec→ TS + Zod (emit_row_interface/emit_select_schema/emit_insert_schema/emit_ts_module): acreateSelectSchema/createInsertSchemastyle emitter (parity with smooai-postgres-kit). Useful for handing a runtime (dynamic) table’s shape to a TypeScript client as a row interface + Zod schemas.
Functions§
- ch_
type_ to_ rust - Map a ClickHouse type string to the Rust type a
clickhouse-crate row uses. Wrappers recurse; unknown scalars fall back toString(safe over the wire). - emit_
insert_ schema - Emit the Zod insert schema — columns with a
DEFAULTbecome.optional(). - emit_
row_ interface - Emit the TS row
interfacefor a table (one field per column). - emit_
select_ schema - Emit the Zod select schema (
z.object(...)) for a table. - emit_
ts_ module - Emit a full TS module for a table: the
zodimport, the row interface, and the select + insert schemas, separated by blank lines. - insert_
schema_ name - The Zod insert-schema const name, e.g.
observabilityTracesInsertSchema. - row_
type_ name - The TS interface name for a table, e.g.
observability_traces→ObservabilityTracesRow. - rust_
row_ struct - Emit a Rust row struct for a table’s columns —
(column_name, clickhouse_type)pairs. Derives theclickhousecrate’sRow+ serde, so it deserializes straight from a query. The emitted source referencesclickhouse::Row(a dev/consumer dependency); this function only produces the string. - select_
schema_ name - The Zod select-schema const name, e.g.
observabilityTracesSelectSchema.