feat: rebuild the orbital vault as an operational map
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
export type Snapshot = {
|
||||
id: string;
|
||||
orbit_id?: string;
|
||||
taken_at: string;
|
||||
orbit_name: string;
|
||||
size_bytes: number;
|
||||
@@ -25,12 +26,17 @@ export type CreateOrbitInput = {
|
||||
dry_run: boolean;
|
||||
};
|
||||
|
||||
async function api<T>(path: string, init?: RequestInit): Promise<T> {
|
||||
async function request(path: string, init?: RequestInit): Promise<Response> {
|
||||
const r = await fetch(path, init);
|
||||
if (!r.ok) {
|
||||
const text = await r.text().catch(() => "");
|
||||
throw new Error(text || `${path} failed`);
|
||||
}
|
||||
return r;
|
||||
}
|
||||
|
||||
async function api<T>(path: string, init?: RequestInit): Promise<T> {
|
||||
const r = await request(path, init);
|
||||
if (r.status === 204) return undefined as T;
|
||||
return r.json();
|
||||
}
|
||||
@@ -68,9 +74,9 @@ export async function startPairing(): Promise<{ code: string; expires_at: string
|
||||
return api("/api/v1/wormhole/pairing", { method: "POST" });
|
||||
}
|
||||
|
||||
export async function runOrbit(id: string, rehearse = false): Promise<void> {
|
||||
await api(`/api/v1/orbits/${id}/run`, { method: "POST" });
|
||||
if (rehearse) return;
|
||||
export async function runOrbit(id: string): Promise<string | null> {
|
||||
const response = await request(`/api/v1/orbits/${id}/run`, { method: "POST" });
|
||||
return response.headers.get("X-Tessera-Snapshot-Id");
|
||||
}
|
||||
|
||||
export async function startReconstitute(
|
||||
@@ -92,7 +98,8 @@ export async function abortReconstitute(sessionId: string): Promise<void> {
|
||||
}
|
||||
|
||||
export async function pollReconstitute(sessionId: string) {
|
||||
return api<{ state: string; seconds_remaining: number }>(
|
||||
`/api/v1/reconstitute/${sessionId}`,
|
||||
);
|
||||
const response = await fetch(`/api/v1/reconstitute/${sessionId}`);
|
||||
if (response.status === 404) return { state: "unavailable", seconds_remaining: 0 };
|
||||
if (!response.ok) throw new Error("Could not read restore status");
|
||||
return response.json() as Promise<{ state: string; seconds_remaining: number }>;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user