From a32dc56d2e5447ef8988cb98b8686476cc94e70c Mon Sep 17 00:00:00 2001 From: soryu Date: Tue, 23 Dec 2025 02:14:58 +0000 Subject: Add Postgres for persistence and File cabinet Migrations are local only currently, and must be run manually by setting POSTGRES_CONNECTION_URI --- makima/frontend/src/lib/api.ts | 102 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 102 insertions(+) (limited to 'makima/frontend/src/lib') diff --git a/makima/frontend/src/lib/api.ts b/makima/frontend/src/lib/api.ts index a6f6c3e..ec596ce 100644 --- a/makima/frontend/src/lib/api.ts +++ b/makima/frontend/src/lib/api.ts @@ -38,3 +38,105 @@ export const LISTEN_ENDPOINT = `${WS_BASE}/api/v1/listen`; export function getEnvironment(): Environment { return env; } + +// File API types +export interface TranscriptEntry { + id: string; + speaker: string; + start: number; + end: number; + text: string; + isFinal: boolean; +} + +export interface FileSummary { + id: string; + name: string; + description: string | null; + transcriptCount: number; + duration: number | null; + createdAt: string; + updatedAt: string; +} + +export interface FileDetail { + id: string; + ownerId: string; + name: string; + description: string | null; + transcript: TranscriptEntry[]; + location: string | null; + createdAt: string; + updatedAt: string; +} + +export interface FileListResponse { + files: FileSummary[]; + total: number; +} + +export interface CreateFileRequest { + name?: string; + description?: string; + transcript: TranscriptEntry[]; + location?: string; +} + +export interface UpdateFileRequest { + name?: string; + description?: string; + transcript?: TranscriptEntry[]; +} + +// File API functions +export async function listFiles(): Promise { + const res = await fetch(`${API_BASE}/api/v1/files`); + if (!res.ok) { + throw new Error(`Failed to list files: ${res.statusText}`); + } + return res.json(); +} + +export async function getFile(id: string): Promise { + const res = await fetch(`${API_BASE}/api/v1/files/${id}`); + if (!res.ok) { + throw new Error(`Failed to get file: ${res.statusText}`); + } + return res.json(); +} + +export async function createFile(data: CreateFileRequest): Promise { + const res = await fetch(`${API_BASE}/api/v1/files`, { + method: "POST", + headers: { "Content-Type": "application/json" }, + body: JSON.stringify(data), + }); + if (!res.ok) { + throw new Error(`Failed to create file: ${res.statusText}`); + } + return res.json(); +} + +export async function updateFile( + id: string, + data: UpdateFileRequest +): Promise { + const res = await fetch(`${API_BASE}/api/v1/files/${id}`, { + method: "PUT", + headers: { "Content-Type": "application/json" }, + body: JSON.stringify(data), + }); + if (!res.ok) { + throw new Error(`Failed to update file: ${res.statusText}`); + } + return res.json(); +} + +export async function deleteFile(id: string): Promise { + const res = await fetch(`${API_BASE}/api/v1/files/${id}`, { + method: "DELETE", + }); + if (!res.ok) { + throw new Error(`Failed to delete file: ${res.statusText}`); + } +} -- cgit v1.2.3