feat(m7.5b): TypeScript ORM adapter — fromDrizzle - #32
Merged
Conversation
Auto-expose your Drizzle models as intent-level capabilities — the TS mirror of Go's GORM FromORM and Python's from_orm. - reins/orm subpath (package.json exports + optional peerDependency drizzle-orm), so the core reins package never depends on an ORM. - src/orm/build.ts: the ORM-neutral generation engine (ZERO deps) — a faithful port of Go's orm.go behind a Backend interface. Intent-level names, natural-key-over-id lookups (unique string preferred, hint-ranked), lean params, trimmed responses, a schema index, and gated writes; every generated capability must pass the linter or it is dropped. Another ORM means implementing only introspection + the six ops. - src/orm/drizzle.ts: the Drizzle adapter. introspect() reflects a Drizzle table object via getTableColumns/getTableName (no database needed) into ORM-neutral ModelInfo (jsonType/nullable/autoincrement/hasDefault/unique); DrizzleBackend runs find/count/get/create/update/delete through Drizzle's query builder; fromDrizzle() wires it to buildCapabilities. Drizzle's db/table types are deeply generic, so they're treated structurally. - tests: orm-build.test.ts drives the engine with a fake Backend (read/write generation, natural-key vs pk fallback, keyless models, required-column inference, handler dispatch, not-found errors, untrusted-arg filtering); orm-drizzle.test.ts covers introspection (no DB) and a full create/get/count/find/update/delete round-trip against in-memory libsql. Verified: make js-check green — format, typecheck, 125 tests (124 pass, 1 skip); the reins/orm subpath builds and imports cleanly as ESM.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Auto-expose your Drizzle models as intent-level capabilities — the TS mirror of Go's GORM FromORM and Python's from_orm.
Verified: make js-check green — format, typecheck, 125 tests (124 pass, 1 skip); the reins/orm subpath builds and imports cleanly as ESM.