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 [1] https://reylo.dev/play
Comments URL: https://news.ycombinator.com/item?id=50634246
Points: 1
# Comments: 0

