import { readFileSync } from "node:fs"; import { birthSkyCaption } from "../src/lib/birth-sky/caption.ts"; import { birthSkyFromEngine, type BirthSkyOk, type BirthSkyPhase } from "../src/lib/birth-sky/contract.ts"; /** Real engine responses (scripts/generate_birth_sky_golden.py), fictional sample birth. */ export const birthSkyGolden = JSON.parse( readFileSync(new URL("./fixtures/birth-sky-golden.json", import.meta.url), "utf8"), ) as { times: Record; responses: Record> }; /** Fictional sample place label, in the China picker's `省 · 市 · 区` shape. */ export const GOLDEN_PLACE_LABEL = "浙江省 · 杭州市 · 西湖区"; /** The caption the BFF would build for the fictional sample at this phase's time. */ export function goldenCaption(phase: BirthSkyPhase): string { const caption = birthSkyCaption({ date: "1994-05-18", time: birthSkyGolden.times[phase], placeLabel: GOLDEN_PLACE_LABEL }); if (!caption) throw new Error(`golden ${phase} has no caption`); return caption; } export function goldenSky(phase: BirthSkyPhase, timeBasis: BirthSkyOk["timeBasis"] = "reported"): BirthSkyOk { const sky = birthSkyFromEngine(birthSkyGolden.responses[phase], timeBasis, goldenCaption(phase)); if (!sky) throw new Error(`golden ${phase} does not satisfy the contract`); return sky; }