Files
HealthLog/src/lib/query-keys/allergies.ts
T
Marc-André Bombeck 5052b2cc08 feat(records): CRUD API + OpenAPI for allergies and family history
Add the `/api/allergies` and `/api/family-history` endpoints (list / create /
read / update / soft-delete), each wrapped in `apiHandler` with Zod
`safeParse` + `returnAllZodIssues`. `userId` is always narrowed from the
session/Bearer — never a body field — and the Prisma `data` is built
field-by-field (no mass assignment). Creates wrap in `withIdempotency`. The
free-text reaction/note are encrypted before write and decrypted fail-soft on
read via the server-authoritative DTOs.

Register the query-key factory entries and the OpenAPI route tables (new
`Records` tag); regenerate `docs/api/openapi.yaml`.
2026-06-28 16:03:05 +02:00

18 lines
744 B
TypeScript

/**
* Query keys — allergies (v1.25, W-RECORDS). The allergy list + a single
* allergy read. Part of the centralized factory; aggregated in `./index.ts`.
*/
export const allergyKeys = {
/**
* `allergies()` is the root prefix every allergy write invalidates through.
* `allergyList(includeInactive)` keys the list (the inactive toggle is part
* of the key so the two response sets cache distinctly). Any allergy write
* evicts the whole `["allergies"]` prefix so the list + open sheet repaint
* in lockstep.
*/
allergies: () => ["allergies"] as const,
allergyList: (includeInactive: boolean) =>
["allergies", "list", includeInactive] as const,
allergy: (id: string) => ["allergies", "detail", id] as const,
};