feat(api-client): generated typed client + TanStack Query hooks (#182) #197
No reviewers
Labels
No labels
area:auth
area:ci
area:db
area:infra
area:native
area:pwa
area:service
epic
feature
foundation
No milestone
No project
No assignees
2 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
james/carol!197
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "182-generated-api-client"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
Fills in
packages/api-client(the placeholder from #181) with a typed HTTP client + TanStack Query hooks the universal Expo client (#183) will consume. ADR-0027 §5 mandated the shape: "The hook layer is hand-written and thin; the OpenAPI tooling generates typed fetch calls, and the hooks wire them into TanStack Query." This PR is that shape, literally.Two commits:
d147811— package + source (3179-line types generated fromopenapi.json; client wrapper with auth-injection + Problem Details normalization; ~30 hooks across 13 resources; tests covering the client / error / keys layers; RN-gated setup under./native).723c47b— CI gate additions (@carol/api-clientlint/typecheck/test/check joined to the existing jobs),docs/api-conventions.md§"Consumer-side codegen",CLAUDE.mdTanStack bullet extension.Decisions baked in
openapi-typescript+openapi-fetch+ hand-written hooks. Rejectedorval/kubb(own hooks layer; contradicts ADR-0027) andopenapi-zod-client(duplicates server contract enforcement at runtime).openapi.json. CI gate (pnpm -F @carol/api-client check) hard-fails on drift.createApiClient({ baseUrl, getAuthHeader? }). Web omits the callback (cookies flow viacredentials: "include"); native passes an async reader fromSecureStore.CarolApiErrorwith the RFC 7807 fields. TanStack Query'serroris a typed object, not a raw fetch failure.useNotesInfinitefor the one paginated endpoint +useMove*for skills.@carol/api-client/nativeexportssetupNativeQuery()wiring TanStack'sonlineManager/focusManagerto NetInfo + AppState. Inline-typed dynamic imports — no RN deps in the core.apps/api/app/(app)/notes/notes-client.tsxand friends keepfetch(...)directly until #185 deletes them.Out of scope
apps/client/(#183).Test plan
pnpm installclean.pnpm -F @carol/api-client typecheckgreen.pnpm -F @carol/api-client lintgreen.pnpm -F @carol/api-client testgreen (16 tests across client / error / keys).pnpm -F @carol/api-client checkexits 0.pnpm -F @carol/api openapi:checkandopenapi:coveragestill green (54 routes).Closes #182. Fourth ticket under epic #176. Unblocks #183 (Expo client scaffolding).
OSV-Scanner
Threshold:
high· Total findings: 7 · At/above threshold: 24.1.08.0.16📊 Test coverage
Patch coverage: no testable lines changed.
Overall (
app/,lib/,db/, excluding UI per ADR-0019):Soft thresholds per ADR-0019. Coverage is informational and does not block merge.
Trivy (container image)
Threshold:
high· Total findings: 121 · At/above threshold: 16.27.0, 7.28.0, 8.5.0