adds deleting

This commit is contained in:
2026-02-14 01:10:27 -08:00
parent 6f6dd434af
commit bec25aa943
4 changed files with 165 additions and 5 deletions

View File

@@ -96,7 +96,10 @@ export function setAuthToken(token: string | null) {
async function api<T>(path: string, init?: RequestInit): Promise<T> {
const headers = new Headers(init?.headers ?? {});
headers.set("Content-Type", "application/json");
const hasBody = init?.body !== undefined && init.body !== null;
if (hasBody && !headers.has("Content-Type")) {
headers.set("Content-Type", "application/json");
}
if (authToken) {
headers.set("Authorization", `Bearer ${authToken}`);
}
@@ -143,6 +146,10 @@ export async function getChat(chatId: string) {
return data.chat;
}
export async function deleteChat(chatId: string) {
await api<{ deleted: true }>(`/v1/chats/${chatId}`, { method: "DELETE" });
}
export async function listSearches() {
const data = await api<{ searches: SearchSummary[] }>("/v1/searches");
return data.searches;
@@ -161,6 +168,10 @@ export async function getSearch(searchId: string) {
return data.search;
}
export async function deleteSearch(searchId: string) {
await api<{ deleted: true }>(`/v1/searches/${searchId}`, { method: "DELETE" });
}
export async function runSearch(
searchId: string,
body: {