/** * osClient.ts * ----------- * Fetches Operating System topic data from the Go backend. */ const API_BASE = ''; export interface OSSection { section_no: number; section: string; topic_count: number; level: string; } export interface OSTopic { id: string; section: string; topic: string; type: string; subtopic?: string; content: Record; } /** * Fetches all OS sections (grouped, deduplicated list). */ export async function fetchOSSections(): Promise { const res = await fetch(`${API_BASE}/api/os/sections`, { method: 'GET', headers: { 'Content-Type': 'application/json' }, }); if (!res.ok) throw new Error(`OS sections fetch failed: ${res.status}`); const data = await res.json(); return data.sections ?? []; } /** * Fetches all topics for a given OS section number. */ export async function fetchOSSectionContent(sectionNo: number): Promise<{ section: string; topics: OSTopic[] }> { const res = await fetch(`${API_BASE}/api/os/sections/${sectionNo}`, { method: 'GET', headers: { 'Content-Type': 'application/json' }, }); if (!res.ok) throw new Error(`OS section content fetch failed: ${res.status}`); return res.json(); }