Separate gift-links types into database, queries and models modules#28783
Separate gift-links types into database, queries and models modules#28783rob-ghost wants to merge 1 commit into
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (7)
💤 Files with no reviewable changes (1)
✅ Files skipped from review due to trivial changes (1)
🚧 Files skipped from review as they are similar to previous changes (1)
WalkthroughThe PR splits the single Possibly related PRs
Suggested reviewers
🚥 Pre-merge checks | ✅ 4✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
| Command | Status | Duration | Result |
|---|---|---|---|
nx run ghost:test:ci:integration:no-coverage |
✅ Succeeded | 2m 26s | View ↗ |
nx run ghost:test:ci:integration |
✅ Succeeded | 2m 6s | View ↗ |
nx build @tryghost/signup-form |
✅ Succeeded | <1s | View ↗ |
nx run ghost:test:ci:legacy |
✅ Succeeded | 2m 57s | View ↗ |
nx build @tryghost/portal |
✅ Succeeded | <1s | View ↗ |
nx build @tryghost/admin-toolbar |
✅ Succeeded | <1s | View ↗ |
nx build @tryghost/sodo-search |
✅ Succeeded | <1s | View ↗ |
nx build @tryghost/activitypub |
✅ Succeeded | 1s | View ↗ |
Additional runs (10) |
✅ Succeeded | ... | View ↗ |
💡 Verify your cache is correct by running tasks in a sandbox. Read docs ↗
☁️ Nx Cloud last updated this comment at 2026-06-22 16:02:05 UTC
Splits the single model.ts into database.ts (table schemas + knex types), queries.ts (read projection, the row->domain codec, and query statements), and models.ts (the domain types, no codecs). Each row shape still has one source: the projection and knex types both derive from the DbGiftLink schema.
098626b to
77a8b3b
Compare
|
FYI @jonatansberg I was finding it increasingly hard to reason about which models and types related to which layer of the data, so I split them into specific modules. Now everything should flow nicely between database -> domain -> api with codecs in the appropriate edges. Moving serialisation into this structure to co-locate everything gift-links related will follow. |

Problem
The gift-links module declared the DB row shape, the read projection, the codec, the domain types, and the knex table types all in a single
model.ts. It was hard to follow which type represented what state — stored row vs query result vs domain — and where the mappings between them lived.Solution
Split the types by the state they represent, each file owning a state plus the mapping out of it:
database.ts— the stored table schemas and the knex typesqueries.ts— the read projection, the row-to-domain codec, and the query statementsmodels.ts— the domain types only, no codecsEach row shape keeps a single source: the read projection and the knex types both derive from the one table schema. No behaviour change — typecheck, gift-links unit, integration, and e2e-api suites all green, lint clean.