import { FileSourceResponse, fileSourceResponseSchema, ListRepositoriesResponse, listRepositoriesResponseSchema, SearchRequest, SearchResponse, searchResponseSchema } from "@/lib/schemas"; export const search = async (body: SearchRequest): Promise => { const result = await fetch(`/api/search`, { method: "POST", headers: { "Content-Type": "application/json", }, body: JSON.stringify(body), }).then(response => response.json()); return searchResponseSchema.parse(result); } export const fetchFileSource = async (fileName: string, repository: string): Promise => { const result = await fetch(`/api/source`, { method: "POST", headers: { "Content-Type": "application/json", }, body: JSON.stringify({ fileName, repository, }), }).then(response => response.json()); return fileSourceResponseSchema.parse(result); } export const getRepos = async (): Promise => { const result = await fetch('/api/repos', { method: "GET", headers: { "Content-Type": "application/json", }, }).then(response => response.json()); return listRepositoriesResponseSchema.parse(result); }