mirror of
https://github.com/MBombeck/HealthLog.git
synced 2026-11-18 08:02:12 +00:00
perf(bundle): keep zod out of the documents and Coach client routes
Both routes reached the schema library through a constant: the list of document kinds, the list and bulk limits, the attachment cap, the Coach data clusters and preference defaults, the conversation title length, the scope source list and the report leaf order. Each sat in a schema module, so importing the number shipped the library. The constants now live in zod-free modules (lib/documents/inbound-constants, lib/ai/coach/prefs-constants, lib/ai/coach/scope-sources, lib/report-selection/catalogue) and the schema modules re-export them for server code; the Coach page checks its scope parameter against the closed list instead of parsing it. A guard walks each route's static client graph with the TypeScript parser and fails on a zod import. Two guards follow earlier commits in this branch: the fetch-limit allowlist names the shared document picker sheet, and the card density test states a floor on the cards it finds.
This commit is contained in:
1 parent
3bae93256d
commit
d0677adac9
26 files changed
+421
-190
No files matched your search
@@ -0,0 +1,56 @@
|
||||
/**
|
||||
* The document-vault constants a client component needs, without the schema
|
||||
* library: the kind labels, the content-index sources, the list and bulk
|
||||
* limits, the coach attachment cap. `src/lib/validations/inbound-documents.ts`
|
||||
* builds its zod schemas from these and re-exports them, so server code keeps
|
||||
* its import; client code imports from here (a guard holds the documents and
|
||||
* Coach routes to that).
|
||||
*/
|
||||
|
||||
/** The document-kind labels (no interpretation — a label only). */
|
||||
export const INBOUND_DOCUMENT_KINDS = [
|
||||
"DOCTOR_REPORT",
|
||||
"DISCHARGE_LETTER",
|
||||
"LAB_RESULT",
|
||||
"IMAGING",
|
||||
"PRESCRIPTION",
|
||||
"REFERRAL",
|
||||
"INSURANCE",
|
||||
"VACCINATION",
|
||||
"SICK_NOTE",
|
||||
"OTHER",
|
||||
] as const;
|
||||
export type InboundDocumentKindValue = (typeof INBOUND_DOCUMENT_KINDS)[number];
|
||||
|
||||
/**
|
||||
* How a document's content index was produced (mirrors the server `source`
|
||||
* column). `vision` means an AI provider read the original (the AI-first path);
|
||||
* every other value is a provider-free local extraction. The UI reads it to
|
||||
* tell an AI-read document from a locally-indexed one — the former already had
|
||||
* the richer read, the latter can still be offered "Read with AI".
|
||||
*/
|
||||
export const DOCUMENT_CONTENT_INDEX_SOURCES = [
|
||||
"vision",
|
||||
"text-ocr",
|
||||
"local-pdf",
|
||||
"local-ocr",
|
||||
] as const;
|
||||
export type DocumentContentIndexSourceValue =
|
||||
(typeof DOCUMENT_CONTENT_INDEX_SOURCES)[number];
|
||||
|
||||
/** True when the index was produced by an AI provider reading the original. */
|
||||
export function isAiReadSource(
|
||||
source: DocumentContentIndexSourceValue | string | null,
|
||||
): boolean {
|
||||
return source === "vision";
|
||||
}
|
||||
|
||||
export const DOCUMENT_LIST_DEFAULT_LIMIT = 50;
|
||||
|
||||
/** Max document ids one bulk request may touch. */
|
||||
export const DOCUMENT_BULK_MAX_IDS = 100;
|
||||
|
||||
/** Max documents attachable to one coach conversation. Bounds prompt size + the
|
||||
* numeric-grounding union; five labelled documents is already past the point a
|
||||
* chat answer stays useful. */
|
||||
export const MAX_COACH_ATTACHMENTS = 5;
|
||||
Reference in new issue
Block a user