Add a flat case-key mapper for the gift-links codec and serializer#28811
Add a flat case-key mapper for the gift-links codec and serializer#28811rob-ghost wants to merge 1 commit into
Conversation
🚥 Pre-merge checks | ✅ 4✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 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 20s | View ↗ |
nx run ghost:test:ci:integration |
✅ Succeeded | 2m 3s | View ↗ |
nx run ghost:test:ci:e2e |
✅ Succeeded | 7m 30s | View ↗ |
nx run ghost:test:ci:e2e:no-coverage |
✅ Succeeded | 7m 6s | View ↗ |
nx build @tryghost/activitypub |
✅ Succeeded | 3s | View ↗ |
nx build @tryghost/sodo-search |
✅ Succeeded | <1s | View ↗ |
nx build @tryghost/comments-ui |
✅ Succeeded | <1s | View ↗ |
nx build @tryghost/portal |
✅ 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-23 00:27:38 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
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.

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.