Polish Tessera web canvas: multi-tab vault UI
Vault ring scene, orbits editor, wormhole pairing, decay presets, reconstitute grace UI, shared components, and API wiring per SPEC.
This commit is contained in:
@@ -9,49 +9,90 @@ export type Orbit = {
|
||||
id: string;
|
||||
name: string;
|
||||
provider: string;
|
||||
provider_config?: string;
|
||||
last_status: string;
|
||||
dry_run: boolean;
|
||||
schedule?: string | null;
|
||||
decay_preset?: string;
|
||||
};
|
||||
|
||||
export async function fetchSnapshots(): Promise<Snapshot[]> {
|
||||
const r = await fetch("/api/v1/snapshots");
|
||||
if (!r.ok) throw new Error("snapshots");
|
||||
export type CreateOrbitInput = {
|
||||
name: string;
|
||||
provider: "filesystem" | "postgres";
|
||||
paths: string[];
|
||||
schedule?: string;
|
||||
decay_preset: string;
|
||||
dry_run: boolean;
|
||||
};
|
||||
|
||||
async function api<T>(path: string, init?: RequestInit): Promise<T> {
|
||||
const r = await fetch(path, init);
|
||||
if (!r.ok) {
|
||||
const text = await r.text().catch(() => "");
|
||||
throw new Error(text || `${path} failed`);
|
||||
}
|
||||
if (r.status === 204) return undefined as T;
|
||||
return r.json();
|
||||
}
|
||||
|
||||
export async function fetchHealth(): Promise<string> {
|
||||
const r = await fetch("/health");
|
||||
if (!r.ok) throw new Error("hub offline");
|
||||
return r.text();
|
||||
}
|
||||
|
||||
export async function fetchSnapshots(): Promise<Snapshot[]> {
|
||||
return api("/api/v1/snapshots");
|
||||
}
|
||||
|
||||
export async function fetchOrbits(): Promise<Orbit[]> {
|
||||
const r = await fetch("/api/v1/orbits");
|
||||
if (!r.ok) throw new Error("orbits");
|
||||
return r.json();
|
||||
return api("/api/v1/orbits");
|
||||
}
|
||||
|
||||
export async function createOrbit(input: CreateOrbitInput): Promise<Orbit> {
|
||||
return api("/api/v1/orbits", {
|
||||
method: "POST",
|
||||
headers: { "Content-Type": "application/json" },
|
||||
body: JSON.stringify({
|
||||
name: input.name,
|
||||
provider: input.provider,
|
||||
provider_config: { paths: input.paths },
|
||||
schedule: input.schedule || null,
|
||||
decay_preset: input.decay_preset,
|
||||
dry_run: input.dry_run,
|
||||
}),
|
||||
});
|
||||
}
|
||||
|
||||
export async function startPairing(): Promise<{ code: string; expires_at: string }> {
|
||||
const r = await fetch("/api/v1/wormhole/pairing", { method: "POST" });
|
||||
return r.json();
|
||||
return api("/api/v1/wormhole/pairing", { method: "POST" });
|
||||
}
|
||||
|
||||
export async function runOrbit(id: string): Promise<void> {
|
||||
await fetch(`/api/v1/orbits/${id}/run`, { 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 startReconstitute(snapshotId: string, target: string): Promise<{
|
||||
export async function startReconstitute(
|
||||
snapshotId: string,
|
||||
target: string,
|
||||
): Promise<{
|
||||
session_id: string;
|
||||
session: { seconds_remaining: number; state: string };
|
||||
}> {
|
||||
const r = await fetch("/api/v1/reconstitute", {
|
||||
return api("/api/v1/reconstitute", {
|
||||
method: "POST",
|
||||
headers: { "Content-Type": "application/json" },
|
||||
body: JSON.stringify({ snapshot_id: snapshotId, target_path: target }),
|
||||
});
|
||||
return r.json();
|
||||
}
|
||||
|
||||
export async function abortReconstitute(sessionId: string): Promise<void> {
|
||||
await fetch(`/api/v1/reconstitute/${sessionId}`, { method: "DELETE" });
|
||||
await api(`/api/v1/reconstitute/${sessionId}`, { method: "DELETE" });
|
||||
}
|
||||
|
||||
export async function pollReconstitute(sessionId: string) {
|
||||
const r = await fetch(`/api/v1/reconstitute/${sessionId}`);
|
||||
return r.json();
|
||||
return api<{ state: string; seconds_remaining: number }>(
|
||||
`/api/v1/reconstitute/${sessionId}`,
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user