Repository navigation
feat: adopt Framework immutable queries and synchronous mappings - #99
Merged
Merged
Conversation
This branch was previously deployed
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.
Summary
Adopt Framework
0.0.0-beta-20261001112349across Xpenser, including immutable queries and projection-aware synchronous DTO mappings.Original request
Adopt the newly published Framework beta in Xpenser using the PR workflow. The approved scope includes the complete immutable-query migration and synchronous/projection-derived mapping cleanup, with tests, documentation, and a reviewable preview. Framework itself remains unchanged.
What changed
Pin all 15 directly used Framework packages to the exact beta; preserve a single shared schema installation in the lockfile.
Capture immutable query branches and return predicate/include callback results. Count and page reads share a filtered source; correlated subqueries use typed references.
Separate reusable read definitions, feature-owned mapper modules, and service orchestration. Cache only definitions/registrations per Knex connection using weak references; retain independent transaction/tenant branches.
Use query-derived
rowSchemaandgetSyncMapper()for pure DTO conversions. Keep asynchronous database enrichment batched and parallel.Correct storage metadata to match existing migrations: decimal(18,2) amounts, decimal(18,8) rates, and date-only exchange-rate dates. Preserve numeric DTO amounts/rates and YYYY-MM-DD public dates. No database migration or public contract change.
Project only public API-key fields and filter owner/revocation in SQL. Keep full credential reads confined to authentication.
Update immutable test doubles, database-accurate fixtures, consumer reference documentation, and preview regressions for DTOs and API-key listing/revocation.
The temporary
framework-consumer-experience.mdremains local and is not included in this PR.Use a shared PostgreSQL pool factory with explicit UTC Date parameter encoding. This prevents date-only values shifting under non-UTC host timezones. The driver setting is process-wide; TIMESTAMPTZ instants remain unchanged. CI checks both default and non-UTC processes.
Reasoning
This adopts the beta's actual read contract rather than casting driver values to public DTO types. PostgreSQL regression tests caught and fixed the existing string/date storage mismatch. Shared query definitions avoid rebuilding mapping registrations for every row without sharing user filters or result caches. Application authorization, numbered pagination, enrichment, and money/date conversion policies remain explicit.
Blog post
Skipped: internal dependency/API-consumer refactor with no new public-facing feature.
Validation
npm ci --no-audit --no-fundnpm run lintnpm run typechecknpm test: 1,928 tests in 122 filesnpm run buildnpm run test:queries:integration: 29 tests in each of UTC and America/Los_Angeles on isolated PostgreSQL 16, using actual application migrations in disposable schemas40793db40793db40793dbxpenser-api-pr-99andxpenser-web-pr-99.Telemetry evidence and limits
Query-plan timings are diagnostic only; no production latency improvement is claimed from synchronous mapping alone.
Preview regression found and fixed
The first browser run exposed a tagged-transaction write failure: a plain schema query included the ORM-only
tagnavigation property in generatedRETURNINGcolumns. The write now uses a storage-only schema. A new PostgreSQL test reproduces the original failure and verifies tagged transaction creation, replacement, deletion, pruning, and budget isolation; all 29 database tests now pass. A separate non-UTC run also reproduced a calendar-date shift in the driver's default parameter encoding; the shared UTC driver policy fixes it, and both timezone runs pass.Screenshots / Preview
Preview: https://xpenser-pr-099.cleverbrush.com
No visual design changes. The passing Playwright report artifact includes the transaction screenshot from the typed-query adoption test. Final workflow run.
Manual browser QA independently verified a tagged transaction changing from $12.34 to $18.75, surviving a full reload, and remaining isolated to its budget. Cleanup restored the seeded Main budget as active.
Checklist