144 files moved with git mv (pure renames). Root package.json delegates dev/typecheck/test:run/lint/build to the packages; Node 24 LTS and pnpm 10.13.1 pinned (.nvmrc, .node-version, engines, packageManager, root devDependency, engine-strict). Dockerfile builds @faunosteo/app on node:24-alpine and copies apps/app/dist; nginx and runtime config unchanged. CI workflow for Gitea Actions. packages/ reserved (README only). Docs synced: WORKSPACE.md, CLAUDE.md, README, DEPLOY, CHANGELOG, plan. 271/271 tests, typecheck, lint, build green from the root.
68 lines
1.9 KiB
TypeScript
68 lines
1.9 KiB
TypeScript
import { z } from 'zod'
|
|
|
|
/**
|
|
* Schema for the species findings tree.
|
|
*
|
|
* Source of truth for what a practitioner can attach to an observation:
|
|
* a hierarchical tree of dysfunctions/observations per anatomical zone,
|
|
* authored by the domain expert in JSON and parsed at boot.
|
|
*
|
|
* Field names match the JSON authoring contract (snake_case).
|
|
* Recursive children are typed via z.lazy + an explicit ZodType annotation
|
|
* so TS can resolve the self-reference.
|
|
*/
|
|
|
|
export const SourceRefSchema = z.object({
|
|
type: z.enum(['manual', 'journal', 'database', 'web']),
|
|
citation: z.string().min(1),
|
|
url: z.string().url().optional(),
|
|
})
|
|
|
|
export type SourceRef = z.infer<typeof SourceRefSchema>
|
|
|
|
export interface FindingNode {
|
|
id: string
|
|
name_fr: string
|
|
name_en: string
|
|
description_fr?: string
|
|
description_en?: string
|
|
requires_vet_referral?: boolean
|
|
sources?: SourceRef[]
|
|
children?: FindingNode[]
|
|
}
|
|
|
|
export const FindingNodeSchema: z.ZodType<FindingNode> = z.lazy(() =>
|
|
z.object({
|
|
id: z.string().min(1),
|
|
name_fr: z.string().min(1),
|
|
name_en: z.string().min(1),
|
|
description_fr: z.string().optional(),
|
|
description_en: z.string().optional(),
|
|
requires_vet_referral: z.boolean().optional(),
|
|
sources: z.array(SourceRefSchema).optional(),
|
|
children: z.array(FindingNodeSchema).optional(),
|
|
}),
|
|
)
|
|
|
|
export const ZoneFindingsSchema = z.object({
|
|
id: z.string().min(1),
|
|
name_fr: z.string().min(1),
|
|
name_en: z.string().min(1),
|
|
categories: z.array(FindingNodeSchema),
|
|
})
|
|
|
|
export type ZoneFindings = z.infer<typeof ZoneFindingsSchema>
|
|
|
|
export const SpeciesFindingsSchema = z.object({
|
|
schema_version: z.string().min(1),
|
|
scope_disclaimer: z.string().min(1),
|
|
species: z.object({
|
|
id: z.string().min(1),
|
|
name_fr: z.string().min(1),
|
|
name_en: z.string().min(1),
|
|
}),
|
|
zones: z.record(z.string(), ZoneFindingsSchema),
|
|
})
|
|
|
|
export type SpeciesFindings = z.infer<typeof SpeciesFindingsSchema>
|