Repository navigation
Add a flat case-key mapper for the gift-links codec and serializer - #28811
Conversation
|
Caution Review failedThe pull request is closed. ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (3)
WalkthroughA new local module 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 |
✅ Succeeded | 2m 42s | View ↗ |
nx run ghost:test:ci:integration:no-coverage |
✅ Succeeded | 2m 37s | View ↗ |
nx run ghost:test:ci:legacy |
✅ Succeeded | 2m 51s | View ↗ |
nx run ghost:test:ci:e2e:no-coverage |
✅ Succeeded | 2m 15s | View ↗ |
nx build @tryghost/comments-ui |
✅ Succeeded | <1s | View ↗ |
nx build @tryghost/activitypub |
✅ Succeeded | 2s | View ↗ |
nx build @tryghost/admin-toolbar |
✅ Succeeded | <1s | View ↗ |
nx build @tryghost/portal |
✅ Succeeded | <1s | View ↗ |
Additional runs (9) |
✅ Succeeded | ... | View ↗ |
💡 Verify your cache is correct by running tasks in a sandbox. Read docs ↗
☁️ Nx Cloud last updated this comment at 2026-06-24 11:40:26 UTC
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## chore/gift-links-colocate-db-concerns #28811 +/- ##
========================================================================
Coverage ? 73.83%
========================================================================
Files ? 1558
Lines ? 134537
Branches ? 16175
========================================================================
Hits ? 99331
Misses ? 34197
Partials ? 1009
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
1b3fd5e to
fed7436
Compare
fed7436 to
2f8214b
Compare
6923141 to
e1561e7
Compare
2f8214b to
3495e23
Compare
e1561e7 to
3f5e093
Compare
no ref Replaces the hand-written snake_case to camelCase object literals in the codec (decode/encode) and the serializer with camelKeys/snakeKeys from a small in-house mapper. It renames top-level keys only and copies values by reference, so the branded token, Date and null pass through untouched. z.codec and the response schema still check the result, so adding, removing or retyping any field (the token included) is a compile error. No third-party dependency: a deep case-convert library recurses into the branded token type and mangles it.
3f5e093 to
ce9b003
Compare

Problem
The gift-links codec (database row to domain) and the response serializer (domain to API) each mapped fields with hand-written snake_case to camelCase object literals. The field list was repeated across the row schema, the domain schema, and the literal bodies, and it was hard to tell the deliberate, type-checked projection from incidental boilerplate.
Solution
Replace the literals in both places with a small in-house flat key mapper. It renames top-level keys only and copies values by reference, so the branded token, dates and nulls pass through untouched. The codec and the response schema still check the result, so adding, removing, or retyping any field - the token included - is a compile error, not a runtime surprise or a silent pass-through.
A deep third-party case-convert library was evaluated and rejected: it recurses into value types and mangles the branded token type, so it could not type-check the serializer at all.
Stacked on #28809. Retargets to main once that merges.