feat: add configurable GFS retention per orbit
This commit is contained in:
@@ -15,16 +15,25 @@ export type Orbit = {
|
||||
dry_run: boolean;
|
||||
schedule?: string | null;
|
||||
decay_preset?: string;
|
||||
retention?: RetentionPolicy | null;
|
||||
};
|
||||
|
||||
export type RetentionPolicy = {
|
||||
keep_daily: number;
|
||||
keep_weekly: number;
|
||||
keep_monthly: number;
|
||||
keep_yearly: number;
|
||||
};
|
||||
|
||||
export type RetentionSettings = { decay_preset: string } | { retention: RetentionPolicy };
|
||||
|
||||
export type CreateOrbitInput = {
|
||||
name: string;
|
||||
provider: "filesystem" | "postgres";
|
||||
paths: string[];
|
||||
schedule?: string;
|
||||
decay_preset: string;
|
||||
dry_run: boolean;
|
||||
};
|
||||
} & RetentionSettings;
|
||||
|
||||
async function request(path: string, init?: RequestInit): Promise<Response> {
|
||||
const r = await fetch(path, init);
|
||||
@@ -64,12 +73,20 @@ export async function createOrbit(input: CreateOrbitInput): Promise<Orbit> {
|
||||
provider: input.provider,
|
||||
provider_config: { paths: input.paths },
|
||||
schedule: input.schedule || null,
|
||||
decay_preset: input.decay_preset,
|
||||
...("retention" in input ? { retention: input.retention } : { decay_preset: input.decay_preset }),
|
||||
dry_run: input.dry_run,
|
||||
}),
|
||||
});
|
||||
}
|
||||
|
||||
export async function updateOrbitRetention(id: string, settings: RetentionSettings): Promise<void> {
|
||||
await api(`/api/v1/orbits/${id}/retention`, {
|
||||
method: "PUT",
|
||||
headers: { "Content-Type": "application/json" },
|
||||
body: JSON.stringify(settings),
|
||||
});
|
||||
}
|
||||
|
||||
export async function startPairing(): Promise<{ code: string; expires_at: string }> {
|
||||
return api("/api/v1/wormhole/pairing", { method: "POST" });
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user