@tachles/choiry
v1.1.1
Published
Generic-first, type-aware query SDK generator
Maintainers
Readme
Choiry
Choiry is a generic-first, type-aware code generator that watches your schema and generates safe (SELECT-only by default), typed query utilities.
Requirements
- Node.js >= 18
- npm (or your preferred package manager)
Current status (MVP):
- Parse schema inputs (Prisma
.prismaand Postgres-flavored.sqlCREATE TABLE) - Convert to canonical IR + analyze semantics/relations
- Compose deterministic SELECT-only query plans
- Generate a TypeScript SDK via
ts-morph(Kysely or parameterized raw SQL) - Atomic writes with no-op (hash) skipping
watchmode (debounce + single-flight generation)validatemode (IR-only and optional PostgresEXPLAIN)
Install
Published to npm as @tachles/choiry.
- One-off CLI via npx:
npx @tachles/choiry --help - Or install locally:
npm i -D @tachles/choiry
Dev
- Build:
npm run build - Typecheck:
npm run typecheck - Test:
npm test
CLI (dev)
Output formats
Set output.queryFormat in choiry.config.ts:
"kysely"(default): generated functions acceptKysely<DB>."raw-sql": generated code exports*Prompt()helpers that return{ sql, params }and functions that accept a tinySqlExecutorinterface (so you can usepg,better-sqlite3, mysql drivers, etc.). All values are passed as parameters (no string interpolation).
Published (recommended)
After publishing to npm as @tachles/choiry, you can run the CLI with npx:
npx @tachles/choiry initnpx @tachles/choiry generate --config ./choiry.config.tsnpx @tachles/choiry watchnpx @tachles/choiry inspectnpx @tachles/choiry validate
If you prefer the command name choiry explicitly:
npx -p @tachles/choiry choiry generate
Local dev (no publish)
After npm run build, you can run the local package via npx from the repo root:
npx . initnpx . generate --config ./choiry.config.ts
Direct node (also fine)
After npm run build, you can run:
node dist/cli/main.js initnode dist/cli/main.js generatenode dist/cli/main.js watchnode dist/cli/main.js inspectnode dist/cli/main.js validate
Useful flags:
generate --dry-runvalidate --jsonvalidate --strict
Note: the CLI loads choiry.config.ts at runtime using ts-node/register/transpile-only.
For validation.mode: "db-explain", set the env var named by validation.connectionStringEnv (default template uses DATABASE_URL).
Examples
- Prisma SQLite + Express: examples/prisma-sqlite-express/README.md
Contributing
See CONTRIBUTING.md.
Security
See SECURITY.md.
License
ISC — see LICENSE.
