29 lines
1.0 KiB
TypeScript
29 lines
1.0 KiB
TypeScript
import { apiFetch } from "./client";
|
|
import type { SessionSummary, UiResponse } from "./types";
|
|
|
|
export const createSession = (i: { question: string; name?: string }) =>
|
|
apiFetch<{ id: string }>("/sessions", { method: "POST", body: JSON.stringify(i) });
|
|
|
|
export const listSessions = () => apiFetch<SessionSummary[]>("/sessions");
|
|
|
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
export const getSession = (id: string) => apiFetch<any>(`/sessions/${id}`);
|
|
|
|
export const postResponse = (id: string, uiResponse: UiResponse) =>
|
|
apiFetch<void>(`/sessions/${id}/response`, {
|
|
method: "POST",
|
|
body: JSON.stringify({ ui_response: uiResponse }),
|
|
});
|
|
|
|
export const postSteer = (id: string, text: string) =>
|
|
apiFetch<void>(`/sessions/${id}/steer`, {
|
|
method: "POST",
|
|
body: JSON.stringify({ text }),
|
|
});
|
|
|
|
export const closeSession = (id: string) =>
|
|
apiFetch<void>(`/sessions/${id}/close`, { method: "POST" });
|
|
|
|
export const resumeSession = (id: string) =>
|
|
apiFetch<void>(`/sessions/${id}/resume`, { method: "POST" });
|