feat(framework)!: immutable queries and automatic row schemas (v5) - #234
Merged
Merged
Conversation
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.
Original request
Expand this PR into the approved breaking release: make Framework query builders immutable, infer projection-aware row schemas automatically, migrate in-repository consumers, and major-bump every published Framework package. Keep this PR against
development. Framework is an independent, application-agnostic project. Current API documentation is separate from v4.x-to-v5 migration guidance.What changed
rowSchema/variantRowSchemas, replace-on-select projections, typed predicates and mapped/nested JSON references, aggregates, ordering and pagination.{ output }object schemas for opaque raw SELECTs; captured SQL/bindings; one output parse per row.Date, SQLnull. Projection/raw results stay detached; full ORM entities retain identity tracking and mutable save workflows. Added variant page tracking, CTI exact-key/update coverage, and rollback-safe generated IDs/versions.Reasoning
Immutability prevents the query's runtime shape from drifting away from its inferred type or an already-registered mapper. Reusable base queries retain predictable types and runtime shapes. Full entity writes remain separate from projections; raw SQL must declare the contract the Framework cannot infer. This deliberately requires consumers to retain returned builders and migrate together.
Native Knex itself is not made immutable. The private SQL/write planner remains internal; the exported Framework query surface is immutable. PostgreSQL is the integration-tested dialect for graph/precision behavior.
Migrating from v4.x to v5
Remove
.withRowSchema()calls and retain each configured query instead of relying on mutation. Use explicit output contracts instead of raw base-query overloads. The migration guides contain historical API comparisons; current READMEs, examples and website guides describe the supported API directly.Documentation follow-up
Removed consumer-application references from package changelogs and PR text while preserving the external website showcase link. Added repository guidance for application-neutral examples and current-API documentation. Removed obsolete variant examples and updated the immutable relation-customizer example. API behavior and deprecation annotations are unchanged.
Blog post
Skipped per the approved scope: this is a breaking library API migration, documented in package READMEs, JSDoc, the docs site and a dedicated migration guide instead of a separate product blog post.
Screenshots / preview evidence
This repository does not provision a hosted PR preview. Browser QA used the local docs site (
localhost:3201) and demo (127.0.0.1:5173) with an isolated QA database. Screenshots below are local QA evidence, not a hosted deployment.Validation
npm run lint— passed.npm run build— passed, all 21 workspace build tasks.npm run test— passed again for this documentation update: 206 files, 4,313 tests; no type errors.npm run test:queries:integration— passed: 53 PostgreSQL tests.npx tsc --noEmit -p libs/knex-schema/tsconfig.typecheck.json— passed.npm run typecheck:schema-siteandnpm run typecheck:docs-site— passed.npm run docs— passed, zero errors; cross-package TypeDoc warnings remain.ff6a30ec: Lint, Build & Test (Node 24) and PostgreSQL Query Integration (run).No merge, npm publication or production deployment has been performed.