Skip to content

refactor(adapters): eliminate data-mapper layer - #107

Merged
rghamilton3 merged 4 commits into
mainfrom
chore/camelcase-conv
Apr 13, 2026
Merged

rghamilton3 merged 4 commits into
mainfrom
chore/camelcase-conv

Conversation

@rghamilton3

@rghamilton3 rghamilton3 commented Apr 13, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • Removes data-mapper.ts (1,097 LOC) and its test files (3,155 LOC) entirely
  • Adds src/lib/adapter-utils.ts with a shallow camelizeKeys utility (snake_case → camelCase keys) and parseJsonOrValue
  • Inlines all 54 mapper functions directly into SupabaseAdapter and TauriAdapter — read paths apply camelizeKeys per-call so inline helpers only handle Zod validation and null coercion, not field renaming

New entity authoring flow: adapter file + domain type (2 files, not 4+)

Net: -3,385 LOC across the adapter layer

Post-review fixes (7a7b9ec)

Resolved all 8 findings from the PR review (P17):

  • Critical: mapExercise now reads raw['supports_1rm'] directly — camelizeKeys regex skips digit-adjacent underscores, so supports1RM was silently undefined on every Supabase exercise read
  • High: parseJsonOrValue now requires column param + try/catch; all 6 Supabase call sites updated
  • High: try/catch with console.error added to all 15 mapper methods that lacked it
  • Medium: intToBool requires field param, logs console.warn on null fallback (resolves TODO P14-021)
  • Medium: 4 tauri-adapter parseJsonOrValue call sites reverted to local parseJson helper
  • Medium: Pre-check console.warn removed from mapGym/mapGymMember
  • Low: 16 console.warn calls standardized to [tauri-adapter] bracket format
  • Low: Unsafe (err as Error).message cast fixed in both gym catch blocks

Test plan

  • bun run build — clean, 0 TypeScript errors
  • bun run test — 129 files, 2,290 tests, all passing
  • Review verified — all 12 P17 findings resolved (review-verify PASS)
  • Smoke test Supabase read paths return camelCase fields correctly in dev
  • Smoke test Tauri SQLite read paths (JSONB columns parsed via parseJsonOrValue)

Remove data-mapper.ts (1,097 LOC) and inline all 54 mapper functions
directly into SupabaseAdapter and TauriAdapter. Add adapter-utils.ts
with a shallow camelizeKeys transform (snake_case -> camelCase keys)
applied per-call before read-path mapping, removing the need for manual
field renaming in each to* function.

New entity flow: adapter + domain type (2 files, not 4+).
Build clean, 2,290 tests passing.
@vercel

vercel Bot commented Apr 13, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
ardent-forge Ready Ready Preview, Comment Apr 13, 2026 1:32am

Critical: mapExercise now reads raw['supports_1rm'] directly -- camelizeKeys
regex /_([a-z])/g skips digit-adjacent underscores, so supports_1rm was never
camelized and supports1RM silently evaluated to undefined on every Supabase
exercise read.

- parseJsonOrValue: add required column param + try/catch for context-rich errors
- supabase-adapter: add try/catch to 15 mapper methods missing it; add
  console.error to mapProgram/mapBlock catch blocks; remove misleading
  pre-check console.warn in mapGym/mapGymMember; fix unsafe (err as Error).message
  cast at both gym catch sites; update all 6 parseJsonOrValue call sites
- tauri-adapter: intToBool now requires field param and logs console.warn on
  null fallback (resolves TODO P14-021); revert 4 parseJsonOrValue call sites
  to local parseJson helper; standardize 16 console.warn prefix to [tauri-adapter]

Review: Context/Reviews/0017-pr107-camelcase-conv-2026-04-12.md (P17-001 through P17-006, P17-011, P17-012)
All 8 [FIX] findings resolved. 4 [TASK] findings (test coverage gaps)
added to Context/Backlog/Ideas.md as the P17 adapter test coverage entry.

Review: Context/Reviews/0017-pr107-camelcase-conv-2026-04-12.md
@rghamilton3
rghamilton3 merged commit f0cd894 into main Apr 13, 2026
4 checks passed
@rghamilton3
rghamilton3 deleted the chore/camelcase-conv branch April 13, 2026 01:35

This branch was successfully deployed

1 active deployment
Preview — 73305170 Deployed Apr 13, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant