summaryrefslogtreecommitdiff
path: root/makima/frontend/src/lib
diff options
context:
space:
mode:
Diffstat (limited to 'makima/frontend/src/lib')
-rw-r--r--makima/frontend/src/lib/api.ts30
1 files changed, 30 insertions, 0 deletions
diff --git a/makima/frontend/src/lib/api.ts b/makima/frontend/src/lib/api.ts
index 6f7071d..f1e3a9f 100644
--- a/makima/frontend/src/lib/api.ts
+++ b/makima/frontend/src/lib/api.ts
@@ -34,6 +34,7 @@ const env = detectEnvironment();
export const API_BASE = API_CONFIG[env].http;
export const WS_BASE = API_CONFIG[env].ws;
export const LISTEN_ENDPOINT = `${WS_BASE}/api/v1/listen`;
+export const FILE_SUBSCRIBE_ENDPOINT = `${WS_BASE}/api/v1/files/subscribe`;
export function getEnvironment(): Environment {
return env;
@@ -71,6 +72,7 @@ export interface FileSummary {
description: string | null;
transcriptCount: number;
duration: number | null;
+ version: number;
createdAt: string;
updatedAt: string;
}
@@ -84,6 +86,7 @@ export interface FileDetail {
location: string | null;
summary: string | null;
body: BodyElement[];
+ version: number;
createdAt: string;
updatedAt: string;
}
@@ -106,6 +109,27 @@ export interface UpdateFileRequest {
transcript?: TranscriptEntry[];
summary?: string;
body?: BodyElement[];
+ version?: number;
+}
+
+// Conflict error types
+export interface ConflictErrorResponse {
+ code: "VERSION_CONFLICT";
+ message: string;
+ expectedVersion: number;
+ actualVersion: number;
+}
+
+export class VersionConflictError extends Error {
+ expectedVersion: number;
+ actualVersion: number;
+
+ constructor(conflict: ConflictErrorResponse) {
+ super(conflict.message);
+ this.name = "VersionConflictError";
+ this.expectedVersion = conflict.expectedVersion;
+ this.actualVersion = conflict.actualVersion;
+ }
}
// Available LLM models
@@ -170,6 +194,12 @@ export async function updateFile(
headers: { "Content-Type": "application/json" },
body: JSON.stringify(data),
});
+
+ if (res.status === 409) {
+ const conflict = (await res.json()) as ConflictErrorResponse;
+ throw new VersionConflictError(conflict);
+ }
+
if (!res.ok) {
throw new Error(`Failed to update file: ${res.statusText}`);
}