FEAT-4: pedigree data module - depth-limited ancestor traversal, lazy expand, cycle guard, rd3t conversion (15 tests)

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-06-06 00:17:49 +02:00
parent 01923d1b87
commit 61cfab046a
7 changed files with 654 additions and 0 deletions

View File

@@ -0,0 +1,7 @@
/** Typed API functions for the Würfe (litters) resource. */
import { api, resources } from './client'
import type { Litter } from './types'
export function getLitter(id: string): Promise<Litter> {
return api.get<Litter>(`${resources.litters}/${id}`)
}

View File

@@ -0,0 +1,22 @@
/**
* FEAT-4: Stammbaum-bezogene API-Aufrufe.
*
* Der Inzuchtkoeffizient wird serverseitig über die VOLLE Ahnentiefe berechnet
* (Board-Entscheidung; UI zeigt 4 Generationen, Koeffizient zählt alle).
* Endpunkt entsteht in DATA-2-Folgearbeit — bis dahin antwortet er mit 404 und
* die UI zeigt einen „wird berechnet …“-Zustand.
*/
import { api, resources } from './client'
export interface InbreedingCoefficient {
/** Koeffizient nach Wright, 0..1. */
coefficient: number
}
export async function getInbreedingCoefficient(gerbilId: string): Promise<number> {
const raw = await api.get<InbreedingCoefficient | number>(
`${resources.gerbils}/${gerbilId}/inbreeding-coefficient`,
)
// Defensiv: Endpunkt-Form ist noch nicht final (nacktes number vs. Objekt).
return typeof raw === 'number' ? raw : raw.coefficient
}