chore: initial scaffold + design spec + implementation plan
Skeleton for Osteo Report MVP. Build passes, 7 smoke tests green, real Horse.svg + Horse_head.svg in public/species/equine/. Zod schemas are the contract; store/anatomy/pdf modules are typed stubs throwing "not implemented" awaiting implementation. Spec: docs/superpowers/specs/2026-05-18-osteo-report-mvp-design.md Plan: docs/superpowers/plans/2026-05-18-osteo-report-mvp.md (23 phases, ~70 TDD tasks) Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
1 parent
12a3e48fdf
commit
8ca36b5ccd
104 files changed
+12448
No files matched your search
@@ -0,0 +1,42 @@
|
||||
import type { Bone, BoneCategory } from './types'
|
||||
|
||||
const VALID_CATEGORIES: BoneCategory[] = [
|
||||
'articulation',
|
||||
'charniere',
|
||||
'spine-zone',
|
||||
'os',
|
||||
'os-overlay',
|
||||
'head',
|
||||
'cadran-crane',
|
||||
]
|
||||
|
||||
/**
|
||||
* Parses an inline SVG document and returns a map of boneId → Bone.
|
||||
* Throws SvgConventionError if a required attribute is missing or invalid.
|
||||
*/
|
||||
export function parseSvgBones(_svgRoot: SVGSVGElement): Map<string, Bone> {
|
||||
throw new Error('not implemented')
|
||||
}
|
||||
|
||||
/**
|
||||
* Walks up from event.target to find the nearest element with data-bone-id.
|
||||
* Returns null if no bone element is found.
|
||||
*/
|
||||
export function getBoneIdFromEvent(_event: Event): string | null {
|
||||
throw new Error('not implemented')
|
||||
}
|
||||
|
||||
/**
|
||||
* Validates that all required data attributes are present on an element.
|
||||
* Throws SvgConventionError on the first missing attribute.
|
||||
*/
|
||||
export function validateBoneElement(_el: Element): void {
|
||||
throw new Error('not implemented')
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if the category string is a valid BoneCategory.
|
||||
*/
|
||||
export function isValidCategory(value: string): value is BoneCategory {
|
||||
return (VALID_CATEGORIES as string[]).includes(value)
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
/**
|
||||
* Fetches an SVG file and parses it into a live DOM element.
|
||||
* Uses DOMParser so the SVG is fully controlled by the app's CSS.
|
||||
*/
|
||||
export async function loadSvg(_publicPath: string): Promise<SVGSVGElement> {
|
||||
throw new Error('not implemented')
|
||||
}
|
||||
|
||||
/**
|
||||
* Rasterizes an SVGSVGElement to a PNG data URL at the given scale factor.
|
||||
* Uses canvg under the hood for A4 print quality.
|
||||
*/
|
||||
export async function svgToPngDataUrl(
|
||||
_svgEl: SVGSVGElement,
|
||||
_scale: number,
|
||||
): Promise<string> {
|
||||
throw new Error('not implemented')
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
/** Valid data-category values per the SVG convention. */
|
||||
export type BoneCategory =
|
||||
| 'articulation'
|
||||
| 'charniere'
|
||||
| 'spine-zone'
|
||||
| 'os'
|
||||
| 'os-overlay'
|
||||
| 'head'
|
||||
| 'cadran-crane'
|
||||
|
||||
/** A logical bone as parsed from an SVG — groups hitbox + visible elements. */
|
||||
export interface Bone {
|
||||
id: string
|
||||
/** French label from data-bone-fr */
|
||||
fr: string
|
||||
/** English label from data-bone-en */
|
||||
en: string
|
||||
category: BoneCategory
|
||||
/** Detail popup id from data-opens-detail, if present */
|
||||
opensDetail?: string
|
||||
/** Elements with class containing "hitbox" */
|
||||
hitboxEls: Element[]
|
||||
/** Elements with class containing "visible" */
|
||||
visibleEls: Element[]
|
||||
}
|
||||
|
||||
/** Visual state applied to SVG elements for multi-observation colorization. */
|
||||
export type BoneState = 'current' | 'linked' | 'multi' | 'default'
|
||||
|
||||
/** Error thrown when SVG violates the convention. */
|
||||
export class SvgConventionError extends Error {
|
||||
constructor(
|
||||
message: string,
|
||||
public readonly boneId: string,
|
||||
public readonly missingAttribute: string,
|
||||
) {
|
||||
super(message)
|
||||
this.name = 'SvgConventionError'
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
import { BrowserRouter, Routes, Route } from 'react-router-dom'
|
||||
import { ConfigProvider } from './providers/ConfigProvider'
|
||||
import HomeRoute from './routes/HomeRoute'
|
||||
import NewReportRoute from './routes/NewReportRoute'
|
||||
import EditorRoute from './routes/EditorRoute'
|
||||
import NotFoundRoute from './routes/NotFoundRoute'
|
||||
|
||||
export default function App() {
|
||||
return (
|
||||
<ConfigProvider>
|
||||
<BrowserRouter>
|
||||
<Routes>
|
||||
<Route path="/" element={<HomeRoute />} />
|
||||
<Route path="/new" element={<NewReportRoute />} />
|
||||
<Route path="/editor" element={<EditorRoute />} />
|
||||
<Route path="*" element={<NotFoundRoute />} />
|
||||
</Routes>
|
||||
</BrowserRouter>
|
||||
</ConfigProvider>
|
||||
)
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
import { createContext, useContext, type ReactNode } from 'react'
|
||||
import { appConfig, type AppConfig } from '@/config/env'
|
||||
|
||||
const ConfigContext = createContext<AppConfig>(appConfig)
|
||||
|
||||
export function ConfigProvider({ children }: { children: ReactNode }) {
|
||||
return (
|
||||
<ConfigContext.Provider value={appConfig}>
|
||||
{children}
|
||||
</ConfigContext.Provider>
|
||||
)
|
||||
}
|
||||
|
||||
/** Returns the resolved app config. Never returns undefined. */
|
||||
export function useConfig(): AppConfig {
|
||||
return useContext(ConfigContext)
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
export default function EditorRoute() {
|
||||
return <div>EditorRoute placeholder</div>
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
export default function HomeRoute() {
|
||||
return <div>HomeRoute placeholder</div>
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
export default function NewReportRoute() {
|
||||
return <div>NewReportRoute placeholder</div>
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
export default function NotFoundRoute() {
|
||||
return <div>NotFoundRoute placeholder</div>
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
export default function Brand() {
|
||||
return <div>Brand placeholder</div>
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
export default function AnatomyCanvas() {
|
||||
return <div>AnatomyCanvas placeholder</div>
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
export default function DetailModal() {
|
||||
return <div>DetailModal placeholder</div>
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
export default function ZoneTooltip() {
|
||||
return <div>ZoneTooltip placeholder</div>
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
export default function FreeTextPathologyInput() {
|
||||
return <div>FreeTextPathologyInput placeholder</div>
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
export default function ObservationCard() {
|
||||
return <div>ObservationCard placeholder</div>
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
export default function ObservationEditor() {
|
||||
return <div>ObservationEditor placeholder</div>
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
export default function ObservationList() {
|
||||
return <div>ObservationList placeholder</div>
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
export default function PathologyPicker() {
|
||||
return <div>PathologyPicker placeholder</div>
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
export default function SeveritySelector() {
|
||||
return <div>SeveritySelector placeholder</div>
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
export default function VertebraPicker() {
|
||||
return <div>VertebraPicker placeholder</div>
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
export default function AnimalForm() {
|
||||
return <div>AnimalForm placeholder</div>
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
export default function ConclusionPanel() {
|
||||
return <div>ConclusionPanel placeholder</div>
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
export default function NextAppointmentPicker() {
|
||||
return <div>NextAppointmentPicker placeholder</div>
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
export default function PractitionerForm() {
|
||||
return <div>PractitionerForm placeholder</div>
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
export default function ReportHeader() {
|
||||
return <div>ReportHeader placeholder</div>
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
export default function Badge() {
|
||||
return <div>Badge placeholder</div>
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
export default function Button() {
|
||||
return <div>Button placeholder</div>
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
export default function Card() {
|
||||
return <div>Card placeholder</div>
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
export default function Chip() {
|
||||
return <div>Chip placeholder</div>
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
export default function Dialog() {
|
||||
return <div>Dialog placeholder</div>
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
export default function Input() {
|
||||
return <div>Input placeholder</div>
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
export default function Label() {
|
||||
return <div>Label placeholder</div>
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
export default function Select() {
|
||||
return <div>Select placeholder</div>
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
export default function Textarea() {
|
||||
return <div>Textarea placeholder</div>
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
export default function Toast() {
|
||||
return <div>Toast placeholder</div>
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
/// <reference types="vite/client" />
|
||||
|
||||
/**
|
||||
* Runtime application config.
|
||||
* Resolution order:
|
||||
* 1. window.__APP_CONFIG__ (injected by docker/entrypoint.sh)
|
||||
* 2. import.meta.env.VITE_APP_* (build-time Vite defines)
|
||||
* 3. Hard-coded defaults
|
||||
*/
|
||||
export interface AppConfig {
|
||||
siteName: string
|
||||
brandName: string
|
||||
footerName: string
|
||||
tagline: string
|
||||
}
|
||||
|
||||
declare global {
|
||||
interface Window {
|
||||
__APP_CONFIG__?: Partial<AppConfig>
|
||||
}
|
||||
}
|
||||
|
||||
const DEFAULTS: AppConfig = {
|
||||
siteName: 'Osteo Report',
|
||||
brandName: 'Osteo Report',
|
||||
footerName: 'Osteo Report',
|
||||
tagline: "Bilans d'ostéopathie animalière",
|
||||
}
|
||||
|
||||
function resolveConfig(): AppConfig {
|
||||
const runtime = typeof window !== 'undefined' ? window.__APP_CONFIG__ : {}
|
||||
return {
|
||||
siteName:
|
||||
runtime?.siteName ??
|
||||
import.meta.env.VITE_APP_SITE_NAME ??
|
||||
DEFAULTS.siteName,
|
||||
brandName:
|
||||
runtime?.brandName ??
|
||||
import.meta.env.VITE_APP_BRAND_NAME ??
|
||||
DEFAULTS.brandName,
|
||||
footerName:
|
||||
runtime?.footerName ??
|
||||
import.meta.env.VITE_APP_FOOTER_NAME ??
|
||||
DEFAULTS.footerName,
|
||||
tagline:
|
||||
runtime?.tagline ??
|
||||
import.meta.env.VITE_APP_TAGLINE ??
|
||||
DEFAULTS.tagline,
|
||||
}
|
||||
}
|
||||
|
||||
export const appConfig: AppConfig = resolveConfig()
|
||||
@@ -0,0 +1,17 @@
|
||||
import { z } from 'zod'
|
||||
|
||||
export const AnimalSchema = z.object({
|
||||
/** Must match a registered species id (e.g. 'equine') */
|
||||
speciesId: z.string().min(1),
|
||||
name: z.string().min(1),
|
||||
breed: z.string().optional(),
|
||||
age: z.string().optional(),
|
||||
})
|
||||
|
||||
export type Animal = z.infer<typeof AnimalSchema>
|
||||
|
||||
export const OwnerSchema = z.object({
|
||||
name: z.string().min(1),
|
||||
})
|
||||
|
||||
export type Owner = z.infer<typeof OwnerSchema>
|
||||
@@ -0,0 +1,38 @@
|
||||
import { z } from 'zod'
|
||||
|
||||
export const SeveritySchema = z.enum(['légère', 'modérée', 'sévère'])
|
||||
|
||||
export type Severity = z.infer<typeof SeveritySchema>
|
||||
|
||||
export const VertebralRegionSchema = z.enum(['C', 'T', 'L', 'S', 'Cd'])
|
||||
|
||||
export type VertebralRegion = z.infer<typeof VertebralRegionSchema>
|
||||
|
||||
export const VertebraSchema = z.object({
|
||||
region: VertebralRegionSchema,
|
||||
index: z.number().int().positive(),
|
||||
})
|
||||
|
||||
export type Vertebra = z.infer<typeof VertebraSchema>
|
||||
|
||||
export const ObservationZoneSchema = z.object({
|
||||
/** Must match data-bone-id attribute on the SVG element */
|
||||
boneId: z.string().min(1),
|
||||
/** Set when zone originates from a detail popup SVG */
|
||||
detailSourceId: z.string().optional(),
|
||||
/** Set when boneId is a spine-zone; replaces the block semantically */
|
||||
vertebrae: z.array(VertebraSchema).optional(),
|
||||
})
|
||||
|
||||
export type ObservationZone = z.infer<typeof ObservationZoneSchema>
|
||||
|
||||
export const ObservationSchema = z.object({
|
||||
id: z.string().min(1),
|
||||
zones: z.array(ObservationZoneSchema),
|
||||
pathologyIds: z.array(z.string()),
|
||||
freeTextPathologies: z.array(z.string()),
|
||||
severity: SeveritySchema.optional(),
|
||||
comment: z.string(),
|
||||
})
|
||||
|
||||
export type Observation = z.infer<typeof ObservationSchema>
|
||||
@@ -0,0 +1,47 @@
|
||||
import { z } from 'zod'
|
||||
|
||||
export const PathologyCategorySchema = z.enum([
|
||||
'osseux',
|
||||
'articulaire',
|
||||
'musculaire',
|
||||
'tendino-ligamentaire',
|
||||
'fascial',
|
||||
'visceral',
|
||||
'cranio-sacre',
|
||||
'nerveux',
|
||||
'autre',
|
||||
])
|
||||
|
||||
export type PathologyCategory = z.infer<typeof PathologyCategorySchema>
|
||||
|
||||
export const PathologyRefTypeSchema = z.enum([
|
||||
'manual',
|
||||
'journal',
|
||||
'database',
|
||||
'web',
|
||||
])
|
||||
|
||||
export const PathologyRefSchema = z.object({
|
||||
type: PathologyRefTypeSchema,
|
||||
/** Human-readable citation — no raw URLs in PDF output */
|
||||
citation: z.string().min(1),
|
||||
url: z.string().url().optional(),
|
||||
})
|
||||
|
||||
export type PathologyRef = z.infer<typeof PathologyRefSchema>
|
||||
|
||||
export const PathologySchema = z.object({
|
||||
/** Stable kebab-case identifier */
|
||||
id: z.string().min(1),
|
||||
labelFr: z.string().min(1),
|
||||
description: z.string().min(1),
|
||||
category: PathologyCategorySchema,
|
||||
/** Empty array = applicable to all species */
|
||||
speciesIds: z.array(z.string()),
|
||||
/** Empty array = applicable to all zones */
|
||||
boneIds: z.array(z.string()),
|
||||
/** At least one source required */
|
||||
sources: z.array(PathologyRefSchema).min(1),
|
||||
})
|
||||
|
||||
export type Pathology = z.infer<typeof PathologySchema>
|
||||
@@ -0,0 +1,11 @@
|
||||
import { z } from 'zod'
|
||||
|
||||
export const PractitionerSchema = z.object({
|
||||
name: z.string().min(1),
|
||||
cabinet: z.string().optional(),
|
||||
contact: z.string().optional(),
|
||||
/** SIRET — 14-digit French business identifier */
|
||||
siret: z.string().optional(),
|
||||
})
|
||||
|
||||
export type Practitioner = z.infer<typeof PractitionerSchema>
|
||||
@@ -0,0 +1,30 @@
|
||||
import { z } from 'zod'
|
||||
import { PractitionerSchema } from './practitioner'
|
||||
import { AnimalSchema, OwnerSchema } from './animal'
|
||||
import { ObservationSchema } from './observation'
|
||||
|
||||
const NextAppointmentSchema = z.discriminatedUnion('kind', [
|
||||
z.object({ kind: z.literal('date'), date: z.string() }),
|
||||
z.object({ kind: z.literal('period'), text: z.string() }),
|
||||
])
|
||||
|
||||
export type NextAppointment = z.infer<typeof NextAppointmentSchema>
|
||||
|
||||
export const ReportSchema = z.object({
|
||||
/** Schema version — always 1 for MVP. Bump on breaking changes. */
|
||||
version: z.literal(1),
|
||||
id: z.string().min(1),
|
||||
/** ISO timestamp of report creation */
|
||||
createdAt: z.string(),
|
||||
/** ISO date of clinical encounter */
|
||||
date: z.string(),
|
||||
practitioner: PractitionerSchema,
|
||||
animal: AnimalSchema,
|
||||
owner: OwnerSchema,
|
||||
observations: z.array(ObservationSchema),
|
||||
conclusion: z.string(),
|
||||
recommendations: z.string(),
|
||||
nextAppointment: NextAppointmentSchema.optional(),
|
||||
})
|
||||
|
||||
export type Report = z.infer<typeof ReportSchema>
|
||||
@@ -0,0 +1,13 @@
|
||||
import type { SpeciesManifest } from '@/domain/species/types'
|
||||
import { EQUINE_VERTEBRAL_FORMULA } from './vertebrae'
|
||||
|
||||
export const equine: SpeciesManifest = {
|
||||
id: 'equine',
|
||||
labelFr: 'Cheval',
|
||||
mainSvg: '/species/equine/Horse.svg',
|
||||
details: {
|
||||
head: '/species/equine/Horse_head.svg',
|
||||
},
|
||||
vertebralFormula: EQUINE_VERTEBRAL_FORMULA,
|
||||
pathologies: () => import('./pathologies'),
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
import type { Pathology } from '@/domain/schema/pathology'
|
||||
|
||||
/**
|
||||
* Equine pathology database.
|
||||
* To be authored post-scaffold (40–60 entries, source-cited).
|
||||
* Each entry must pass PathologySchema.parse() and have ≥1 source.
|
||||
*/
|
||||
const EQUINE_PATHOLOGIES: Pathology[] = []
|
||||
|
||||
export default EQUINE_PATHOLOGIES
|
||||
@@ -0,0 +1,13 @@
|
||||
import type { VertebralFormula } from '@/domain/species/types'
|
||||
|
||||
/**
|
||||
* Vertebral formula for the horse (Equus caballus).
|
||||
* Cd count capped at 18 for the picker — actual count varies 15–21.
|
||||
*/
|
||||
export const EQUINE_VERTEBRAL_FORMULA: VertebralFormula = {
|
||||
C: 7,
|
||||
T: 18,
|
||||
L: 6,
|
||||
S: 5,
|
||||
Cd: 18,
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
import type { SpeciesManifest } from './types'
|
||||
import { equine } from './equine'
|
||||
|
||||
/** Map of speciesId → manifest. Add new species here. */
|
||||
const SPECIES_REGISTRY: Record<string, SpeciesManifest> = {
|
||||
[equine.id]: equine,
|
||||
}
|
||||
|
||||
/** Returns a species manifest by id, or undefined if not registered. */
|
||||
export function getSpecies(id: string): SpeciesManifest | undefined {
|
||||
return SPECIES_REGISTRY[id]
|
||||
}
|
||||
|
||||
/** Returns all registered species manifests. */
|
||||
export function getAllSpecies(): SpeciesManifest[] {
|
||||
return Object.values(SPECIES_REGISTRY)
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
import type { Pathology } from '@/domain/schema/pathology'
|
||||
|
||||
/** Vertebral formula defines segment counts for a species. */
|
||||
export interface VertebralFormula {
|
||||
C: number
|
||||
T: number
|
||||
L: number
|
||||
S: number
|
||||
Cd: number
|
||||
}
|
||||
|
||||
/** Lazy import returning a module with a default export of Pathology[]. */
|
||||
export type PathologiesLoader = () => Promise<{ default: Pathology[] }>
|
||||
|
||||
/** Species manifest — one per registered species. */
|
||||
export interface SpeciesManifest {
|
||||
id: string
|
||||
/** Display name in French */
|
||||
labelFr: string
|
||||
/** Absolute public path to the main anatomy SVG */
|
||||
mainSvg: string
|
||||
/**
|
||||
* Map of detail popup id → absolute public path to detail SVG.
|
||||
* Keys match data-opens-detail attribute values in the main SVG.
|
||||
*/
|
||||
details: Record<string, string>
|
||||
vertebralFormula: VertebralFormula
|
||||
/** Lazy-loaded pathology database for this species */
|
||||
pathologies: PathologiesLoader
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
/**
|
||||
* Asserts a condition is truthy; throws with the given message otherwise.
|
||||
* Use to enforce invariants at runtime boundaries.
|
||||
*/
|
||||
export function assert(condition: unknown, message: string): asserts condition {
|
||||
if (!condition) {
|
||||
throw new Error(`Assertion failed: ${message}`)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Marks a code path as unreachable for exhaustive switch coverage.
|
||||
* TypeScript will error at compile time if the path is reachable.
|
||||
*/
|
||||
export function assertNever(value: never, message?: string): never {
|
||||
throw new Error(message ?? `Unexpected value: ${JSON.stringify(value)}`)
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
/**
|
||||
* Returns today's date as an ISO date string (YYYY-MM-DD).
|
||||
*/
|
||||
export function todayIso(): string {
|
||||
return new Date().toISOString().slice(0, 10)
|
||||
}
|
||||
|
||||
/**
|
||||
* Formats an ISO date string as a French locale date (e.g. "18 mai 2026").
|
||||
*/
|
||||
export function formatDateFr(_isoDate: string): string {
|
||||
throw new Error('not implemented')
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the current instant as an ISO timestamp string.
|
||||
*/
|
||||
export function nowIso(): string {
|
||||
return new Date().toISOString()
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
/**
|
||||
* Generates a collision-resistant unique id using crypto.randomUUID().
|
||||
* Falls back to a timestamp-based id in environments without crypto.
|
||||
*/
|
||||
export function generateId(): string {
|
||||
if (
|
||||
typeof crypto !== 'undefined' &&
|
||||
typeof crypto.randomUUID === 'function'
|
||||
) {
|
||||
return crypto.randomUUID()
|
||||
}
|
||||
return `${Date.now()}-${Math.random().toString(36).slice(2, 9)}`
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
import { StrictMode } from 'react'
|
||||
import { createRoot } from 'react-dom/client'
|
||||
import '@/styles/index.css'
|
||||
import App from '@/app/App'
|
||||
|
||||
const rootEl = document.getElementById('root')
|
||||
|
||||
if (!rootEl) {
|
||||
throw new Error('Root element #root not found in the document')
|
||||
}
|
||||
|
||||
createRoot(rootEl).render(
|
||||
<StrictMode>
|
||||
<App />
|
||||
</StrictMode>,
|
||||
)
|
||||
@@ -0,0 +1,23 @@
|
||||
import type { PDFDocument } from 'pdf-lib'
|
||||
import type { Report } from '@/domain/schema/report'
|
||||
|
||||
/**
|
||||
* Attaches the serialized Report JSON to the PDF document as a native
|
||||
* embedded file with afRelationship 'Data'.
|
||||
* Filename: 'osteo-report.json', mimeType: 'application/json'.
|
||||
*/
|
||||
export async function attachReportJson(
|
||||
_pdfDoc: PDFDocument,
|
||||
_report: Report,
|
||||
): Promise<void> {
|
||||
throw new Error('not implemented')
|
||||
}
|
||||
|
||||
/**
|
||||
* Extracts and parses the first embedded file named 'osteo-report*'
|
||||
* with mime 'application/json' from the PDF document.
|
||||
* Throws ImportError if not found or invalid.
|
||||
*/
|
||||
export async function extractReportJson(_pdfDoc: PDFDocument): Promise<Report> {
|
||||
throw new Error('not implemented')
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
import type { Report } from '@/domain/schema/report'
|
||||
|
||||
/**
|
||||
* Generates a self-contained A4 PDF for the given report.
|
||||
* The full report JSON is attached as a native PDF embedded file.
|
||||
* Returns a Uint8Array of the PDF bytes for download.
|
||||
*/
|
||||
export async function exportReportToPdf(_report: Report): Promise<Uint8Array> {
|
||||
throw new Error('not implemented')
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
import type { PDFDocument, PDFFont } from 'pdf-lib'
|
||||
|
||||
export interface EmbeddedFonts {
|
||||
bodyRegular: PDFFont
|
||||
bodyBold: PDFFont
|
||||
headingRegular: PDFFont
|
||||
}
|
||||
|
||||
/**
|
||||
* Embeds Inter (body) and Fraunces (headings) into the PDF document.
|
||||
* Font files are fetched from /fonts/ in the public directory.
|
||||
* Both fonts must be TTF (pdf-lib does not support woff2 directly).
|
||||
*/
|
||||
export async function embedFonts(
|
||||
_pdfDoc: PDFDocument,
|
||||
): Promise<EmbeddedFonts> {
|
||||
throw new Error('not implemented')
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
import type { Report } from '@/domain/schema/report'
|
||||
|
||||
/**
|
||||
* Raised when the PDF does not contain a valid osteo-report JSON attachment.
|
||||
* The message is the French user-facing error string.
|
||||
*/
|
||||
export class ImportError extends Error {
|
||||
constructor() {
|
||||
super(
|
||||
"Ce PDF n'a pas été généré par Osteo Report (pas de données détectées).",
|
||||
)
|
||||
this.name = 'ImportError'
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Loads a PDF from bytes, extracts the attached report JSON, validates it
|
||||
* with Zod, and returns a hydrated Report.
|
||||
* Throws ImportError on any failure.
|
||||
*/
|
||||
export async function importReportFromPdf(
|
||||
_pdfBytes: Uint8Array,
|
||||
): Promise<Report> {
|
||||
throw new Error('not implemented')
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
import type { PDFDocument } from 'pdf-lib'
|
||||
import type { EmbeddedFonts } from '@/pdf/fonts'
|
||||
import type { Report } from '@/domain/schema/report'
|
||||
|
||||
/**
|
||||
* Appends the final page to the PDF: conclusion, recommendations,
|
||||
* next appointment.
|
||||
*/
|
||||
export async function addConclusionPage(
|
||||
_pdfDoc: PDFDocument,
|
||||
_report: Report,
|
||||
_fonts: EmbeddedFonts,
|
||||
): Promise<void> {
|
||||
throw new Error('not implemented')
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
import type { PDFPage } from 'pdf-lib'
|
||||
import type { EmbeddedFonts } from '@/pdf/fonts'
|
||||
|
||||
/**
|
||||
* Draws the page footer: brand name (from config), export date, page x/y.
|
||||
* Brand name comes from env-driven appConfig — never hardcoded.
|
||||
*/
|
||||
export function drawFooter(
|
||||
_page: PDFPage,
|
||||
_fonts: EmbeddedFonts,
|
||||
_pageNumber: number,
|
||||
_totalPages: number,
|
||||
): void {
|
||||
throw new Error('not implemented')
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
import type { PDFPage } from 'pdf-lib'
|
||||
import type { EmbeddedFonts } from '@/pdf/fonts'
|
||||
import type { Report } from '@/domain/schema/report'
|
||||
|
||||
/**
|
||||
* Draws the page header: practitioner block (left) + animal/owner/date (right).
|
||||
*/
|
||||
export function drawHeader(
|
||||
_page: PDFPage,
|
||||
_report: Report,
|
||||
_fonts: EmbeddedFonts,
|
||||
): void {
|
||||
throw new Error('not implemented')
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
import type { PDFDocument } from 'pdf-lib'
|
||||
import type { EmbeddedFonts } from '@/pdf/fonts'
|
||||
import type { Report } from '@/domain/schema/report'
|
||||
import type { Observation } from '@/domain/schema/observation'
|
||||
|
||||
/**
|
||||
* Appends one page per observation to the PDF document.
|
||||
* Each page includes: rasterized main SVG, optional detail SVG raster,
|
||||
* zones block, pathologies + severity + comment, abbreviated citations.
|
||||
*/
|
||||
export async function addObservationPage(
|
||||
_pdfDoc: PDFDocument,
|
||||
_report: Report,
|
||||
_observation: Observation,
|
||||
_obsIndex: number,
|
||||
_fonts: EmbeddedFonts,
|
||||
): Promise<void> {
|
||||
throw new Error('not implemented')
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
/**
|
||||
* Rasterizes an SVG string to a PNG Uint8Array using canvg.
|
||||
* Scale factor 2 = A4 print quality.
|
||||
* Returns raw PNG bytes suitable for pdf-lib embedPng().
|
||||
*/
|
||||
export async function rasterizeSvg(
|
||||
_svgString: string,
|
||||
_scale: number,
|
||||
): Promise<Uint8Array> {
|
||||
throw new Error('not implemented')
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
import type { Practitioner } from '@/domain/schema/practitioner'
|
||||
|
||||
const STORAGE_KEY = 'osteo:lastPractitioner'
|
||||
|
||||
/**
|
||||
* Reads the last-used practitioner block from localStorage.
|
||||
* Returns undefined if no cache entry exists or data is invalid.
|
||||
*/
|
||||
export function readCachedPractitioner(): Practitioner | undefined {
|
||||
throw new Error('not implemented')
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes the practitioner block to localStorage for prefill on next session.
|
||||
* Silently no-ops if localStorage is unavailable.
|
||||
*/
|
||||
export function writeCachedPractitioner(_practitioner: Practitioner): void {
|
||||
throw new Error('not implemented')
|
||||
}
|
||||
|
||||
/**
|
||||
* Clears the practitioner cache from localStorage.
|
||||
*/
|
||||
export function clearPractitionerCache(): void {
|
||||
if (typeof localStorage !== 'undefined') {
|
||||
localStorage.removeItem(STORAGE_KEY)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,83 @@
|
||||
import { create } from 'zustand'
|
||||
import type { Report } from '@/domain/schema/report'
|
||||
import type { Observation } from '@/domain/schema/observation'
|
||||
|
||||
export interface ReportStore {
|
||||
/** Currently open report, or null if no session active */
|
||||
report: Report | null
|
||||
|
||||
/** Index of the currently active observation (0-based) */
|
||||
activeObservationIndex: number
|
||||
|
||||
/** Starts a new report from a partial template */
|
||||
initReport: (draft: Omit<Report, 'id' | 'createdAt' | 'version'>) => void
|
||||
|
||||
/** Replaces the entire report (used after PDF import) */
|
||||
hydrateReport: (report: Report) => void
|
||||
|
||||
/** Adds a new empty observation and sets it as active */
|
||||
addObservation: () => void
|
||||
|
||||
/** Removes observation at given index */
|
||||
removeObservation: (index: number) => void
|
||||
|
||||
/** Moves observation up (index - 1) */
|
||||
moveObservationUp: (index: number) => void
|
||||
|
||||
/** Moves observation down (index + 1) */
|
||||
moveObservationDown: (index: number) => void
|
||||
|
||||
/** Replaces the observation at given index */
|
||||
updateObservation: (index: number, obs: Observation) => void
|
||||
|
||||
/** Sets active observation index */
|
||||
setActiveObservation: (index: number) => void
|
||||
|
||||
/** Updates conclusion text */
|
||||
setConclusion: (text: string) => void
|
||||
|
||||
/** Updates recommendations text */
|
||||
setRecommendations: (text: string) => void
|
||||
|
||||
/** Clears the store (after export or cancel) */
|
||||
reset: () => void
|
||||
}
|
||||
|
||||
export const useReportStore = create<ReportStore>(() => ({
|
||||
report: null,
|
||||
activeObservationIndex: 0,
|
||||
|
||||
initReport: () => {
|
||||
throw new Error('not implemented')
|
||||
},
|
||||
hydrateReport: () => {
|
||||
throw new Error('not implemented')
|
||||
},
|
||||
addObservation: () => {
|
||||
throw new Error('not implemented')
|
||||
},
|
||||
removeObservation: () => {
|
||||
throw new Error('not implemented')
|
||||
},
|
||||
moveObservationUp: () => {
|
||||
throw new Error('not implemented')
|
||||
},
|
||||
moveObservationDown: () => {
|
||||
throw new Error('not implemented')
|
||||
},
|
||||
updateObservation: () => {
|
||||
throw new Error('not implemented')
|
||||
},
|
||||
setActiveObservation: () => {
|
||||
throw new Error('not implemented')
|
||||
},
|
||||
setConclusion: () => {
|
||||
throw new Error('not implemented')
|
||||
},
|
||||
setRecommendations: () => {
|
||||
throw new Error('not implemented')
|
||||
},
|
||||
reset: () => {
|
||||
throw new Error('not implemented')
|
||||
},
|
||||
}))
|
||||
@@ -0,0 +1,29 @@
|
||||
@import 'tailwindcss';
|
||||
@import './tokens.css';
|
||||
|
||||
/*
|
||||
Global base styles.
|
||||
Tailwind v4 uses CSS-first config — no tailwind.config.js required.
|
||||
Add @plugin directives here if needed in the future.
|
||||
*/
|
||||
|
||||
*,
|
||||
*::before,
|
||||
*::after {
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
html {
|
||||
font-family: var(--font-body);
|
||||
-webkit-font-smoothing: antialiased;
|
||||
-moz-osx-font-smoothing: grayscale;
|
||||
}
|
||||
|
||||
body {
|
||||
margin: 0;
|
||||
min-height: 100dvh;
|
||||
}
|
||||
|
||||
#root {
|
||||
min-height: 100dvh;
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
/*
|
||||
Design tokens — imported by index.css via @import.
|
||||
Extend @theme here when implementing the design system.
|
||||
Source of truth for colors, spacing, typography scales.
|
||||
*/
|
||||
|
||||
@theme {
|
||||
/* Typography */
|
||||
--font-body: 'Inter', system-ui, sans-serif;
|
||||
--font-heading: 'Fraunces', Georgia, serif;
|
||||
|
||||
/* Clinical-warm observation accent palette (6 tones) */
|
||||
--color-obs-1: hsl(15 60% 50%); /* terracotta */
|
||||
--color-obs-2: hsl(150 25% 45%); /* sauge */
|
||||
--color-obs-3: hsl(185 50% 35%); /* bleu canard */
|
||||
--color-obs-4: hsl(38 70% 50%); /* ambre */
|
||||
--color-obs-5: hsl(290 30% 40%); /* prune */
|
||||
--color-obs-6: hsl(45 55% 45%); /* ocre */
|
||||
}
|
||||
Reference in new issue
Block a user