import type { CodingResult, GalleryItem } from "./types"; const JSON_HEADERS = { "Content-Type": "application/json" }; export async function codeNote(text: string, noteId = "adhoc"): Promise { const res = await fetch("/api/code", { method: "POST", headers: JSON_HEADERS, body: JSON.stringify({ text, note_id: noteId }), }); if (!res.ok) throw new Error(`API error: ${res.status} ${await res.text()}`); return res.json(); } export async function fetchGallery(): Promise { const res = await fetch("/api/gallery"); if (!res.ok) throw new Error(`Gallery fetch failed: ${res.status}`); return res.json(); } export interface ServerStatus { status: "ok" | "degraded"; version: string; pipeline_ready: boolean; reference_counts: { hcc_labels?: number; hcc_crosswalk_icd10?: number; }; gallery_size: number; metrics_available: boolean; meat_llm_configured?: boolean; meat_llm_model?: string | null; meat_llm_ready?: boolean | null; startup_errors?: Record; } export async function fetchStatus(): Promise { const res = await fetch("/api/status"); if (!res.ok) throw new Error(`Status fetch failed: ${res.status}`); return res.json(); }