Skip to content

feat(m7.5b): TypeScript ORM adapter — fromDrizzle - #32

Merged
shamspias merged 1 commit into
mainfrom
build/m7.5b-ts-orm
Jul 5, 2026
Merged

feat(m7.5b): TypeScript ORM adapter — fromDrizzle#32
shamspias merged 1 commit into
mainfrom
build/m7.5b-ts-orm

Conversation

@shamspias

Copy link
Copy Markdown
Owner

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.

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.
@shamspias
shamspias merged commit fda1e6e into main Jul 5, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant