Skip to content

Where people and agents ship software together. The open-source git platform for the whole job: issues, agents, checks and deploys to the edge.

g1t.sh
25 linesCodeBlameRaw
1import type { ServiceBinding } from "./clients";
2import type { User } from "./identity";
3import type { Result } from "./result";
4
5export type ErasureStatus = { id: string; requested_at: string; due_at: string; status: "received" | "reviewing" | "completed" | "refused" };
6export type ErasureRequest = ErasureStatus & { user_id: string; username: string; scope: string; evidence: string; updated_at: string; updated_by: string | null; closed_at: string | null; reviews: ErasureReview[] };
7/** One entry in a case's trail: intake notes, a review, a refusal or the completion evidence. Staff only. */
8export type ErasureReview = { at: string; staff: string; status: string; evidence: string };
9export type PurgeJob = { subject_id: string; kind: string; target: string; attempts: number; retry_at: string; last_error: string | null; created_at: string };
10
11export function privacyClient(service: ServiceBinding) {
12 async function rpc<T>(method: string, args: object = {}): Promise<T> {
13 const response = await service.fetch(`https://service/rpc/${method}`, { method: "POST", headers: { "content-type": "application/json" }, body: JSON.stringify(args) });
14 if (!response.ok) throw new Error("Privacy service unavailable");
15 return response.json() as Promise<T>;
16 }
17 return {
18 request: (user: User) => rpc<Result<ErasureStatus>>("request_erasure", { user }),
19 mine: (user: User) => rpc<ErasureStatus | null>("my_erasure", { user }),
20 intake: (username: string, received_at: string, staff: string, evidence: string) => rpc<Result<boolean>>("admin_intake_erasure", { username, received_at, staff, evidence }),
21 requests: () => rpc<ErasureRequest[]>("admin_erasure_requests"),
22 pending: () => rpc<PurgeJob[]>("admin_pending_purges"),
23 review: (id: string, staff: string, status: string, evidence: string) => rpc<Result<boolean>>("admin_review_erasure", { id, staff, status, evidence }),
24 };
25}