import axios from 'axios' import type { LiveTelemetryResponse, RecordingManifest, StartRecordingRequest, UseCaseSession, CreateSessionRequest, StartRunRequest, SessionRun, UseCase, Game, } from '@/types' const api = axios.create({ baseURL: '/api', timeout: 10000, headers: { 'Content-Type': 'application/json', }, }) // ── Live Telemetry ── export async function getLiveTelemetry(): Promise { const res = await api.get('/live') return res.data } // ── Recordings ── export async function listRecordings(): Promise { const res = await api.get('/recordings') return res.data } export async function getRecording(id: string): Promise { const res = await api.get(`/recordings/${id}`) return res.data } export async function startRecording(req?: StartRecordingRequest): Promise { const res = await api.post('/recordings', req ?? {}) return res.data } export async function stopActiveRecording(): Promise { const res = await api.post('/recordings/stop') return res.data } export async function stopRecording(id: string): Promise { const res = await api.post(`/recordings/${id}/stop`) return res.data } export async function deleteRecording(id: string): Promise { await api.delete(`/recordings/${id}`) } // ── Sessions ── export async function listSessions(): Promise { const res = await api.get('/sessions') return res.data } export async function getSession(id: string): Promise { const res = await api.get(`/sessions/${id}`) return res.data } export async function createSession(req: CreateSessionRequest): Promise { const res = await api.post('/sessions', req) return res.data } export async function deleteSession(id: string): Promise { await api.delete(`/sessions/${id}`) } export async function startRun(sessionId: string, req: StartRunRequest): Promise { const res = await api.post(`/sessions/${sessionId}/runs`, req) return res.data } export async function stopRun(sessionId: string, runId: string): Promise { const res = await api.post(`/sessions/${sessionId}/runs/${runId}/stop`) return res.data } export async function completeSession(id: string): Promise { const res = await api.post(`/sessions/${id}/complete`) return res.data } export async function getAnalysis(id: string): Promise> { const res = await api.get>(`/sessions/${id}/analysis`) return res.data } export async function reAnalyze(id: string): Promise> { const res = await api.post>(`/sessions/${id}/analyze`) return res.data } // ── Metadata ── export async function getUseCases(): Promise { const res = await api.get('/use-cases') return res.data } export async function getGames(): Promise { const res = await api.get('/games') return res.data } export default api