Show HN: Reylo – Import .sql files into TypeScript with full type inference Colin, the creator of Zod, released Reylo, an open source project that imports .sql files into TypeScript with full type inference by using the Content Mapper API in TypeScript 7.1, currently in beta. Reylo supports Postgres, MySQL, and SQLite, and its inference engine is written in Rust, relying on prepared queries where possible and augmenting with its own AST; native JSON Schema CHECK constraints for each dialect, such as pg_jsonschema on Postgres, are reflected in return types. The project uses an internal "Reylo Type Defs" spec that can represent a superset of major RDBMS type systems, and Colin plans to add support for other languages, including a Rust/sqlx macro. Colin here, mostly known for creating Zod. Reylo is a new open source project I'm working on that takes advantage of the new Content Mapper API in TypeScript 7.1 currently still in beta . Content mappers are sort of like plugins for TypeScript in that they let you define loaders for external file types. My mind went straight to .sql. This started as an experiment, but it's turned into a serious engineering effort. • Support for Postgres, MySQL, and SQLite • The inference engine is written in Rust. It relies on prepared queries to the greatest extent possible but augments from there with its own AST. • The major JSON schema extensions for each dialect are natively supported e.g. pg jsonschema on Postgres , so JSON Schema CHECK constraints are reflected in the return types • Type information bubbles up through JSON aggregation • We have our own internal type definition spec "Reylo Type Defs" that's sort of like JSON Schema but it can represent a superset of the type systems in all major RDBMSs. Still just an internal representation, but there are a lot of fun ideas in it for anyone who's interested in that kind of design space. • Planning to add support for other languages beyond TypeScript soon, including a macro for Rust/sqlx Docs are here 0 or you can play around with the inference in-browser using the playground 1 locally runs PGlite and Reylo's WASM build . 0 https://reylo.dev/docs https://reylo.dev/docs 1 https://reylo.dev/play https://reylo.dev/play Comments URL: https://news.ycombinator.com/item?id=50634246 https://news.ycombinator.com/item?id=50634246 Points: 1 Comments: 0