Spaces:
Paused
Paused
File size: 2,023 Bytes
4e7644b | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 | import { request } from "../request";
import type {
CheckpointGcSettings,
CheckpointGraphResponse,
CheckpointStatus,
GcRequest,
GcResult,
RestoreRequest,
RestoreResult,
} from "../types/checkpoints";
const base = "/workspace/checkpoints";
export const checkpointsApi = {
status: (signal?: AbortSignal) =>
request<CheckpointStatus>(`${base}/status`, { signal }),
graph: (limit = 500, signal?: AbortSignal) =>
request<CheckpointGraphResponse>(`${base}/graph?limit=${limit}`, {
signal,
}),
setAuto: (enabled: boolean) =>
request<{ auto_enabled: boolean }>(`${base}/auto`, {
method: "PATCH",
body: JSON.stringify({ enabled }),
}),
snapshot: (body: {
session_id: string;
user_id: string;
channel: string;
name: string;
}) =>
request<{ ref: string; commit: string }>(`${base}/snapshot`, {
method: "POST",
body: JSON.stringify(body),
}),
previewRestore: (body: RestoreRequest) =>
request<RestoreResult>(`${base}/restore/preview`, {
method: "POST",
body: JSON.stringify(body),
timeout: 120_000,
}),
restore: (body: RestoreRequest) =>
request<RestoreResult>(`${base}/restore`, {
method: "POST",
body: JSON.stringify(body),
timeout: 120_000,
}),
previewGc: (body: GcRequest = {}) =>
request<GcResult>(`${base}/gc/preview`, {
method: "POST",
body: JSON.stringify(body),
timeout: 120_000,
}),
gc: (body: GcRequest = {}) =>
request<GcResult>(`${base}/gc`, {
method: "POST",
body: JSON.stringify(body),
timeout: 120_000,
}),
getGcSettings: () => request<CheckpointGcSettings>(`${base}/gc/settings`),
updateGcSettings: (body: CheckpointGcSettings) =>
request<CheckpointGcSettings>(`${base}/gc/settings`, {
method: "PATCH",
body: JSON.stringify(body),
}),
reset: () =>
request<{ reset: boolean; auto_enabled: boolean }>(base, {
method: "DELETE",
timeout: 120_000,
}),
};
|