feat: refresh console for QA and refresh-only access (auth M6d)

- web: Refresh console (relation cards, overwrite confirmation, progress,
  cancel, distinct failure messages), rail item, and a single-screen view
  for people who may only refresh
- hub: refresh-only users are authorized; /me exposes refresh_relations
- docs and auth plan record the real rehearsal (Postgres, agent, Keycloak,
  browser) and what was not verified

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-14 19:03:47 +07:00
parent da46453c13
commit d7fe99edd7
9 changed files with 310 additions and 10 deletions

View File

@@ -69,6 +69,8 @@ export type Me = {
admin: boolean;
capabilities: string[];
grants: MyGrant[];
/** Relations this person may refresh through (empty for an administrator, who may use all). */
refresh_relations?: string[];
};
export async function fetchMe(signal?: AbortSignal): Promise<Me> {
@@ -125,6 +127,27 @@ export const grantRelationAccess = (id: string, grant: { principal_type: "user"
api<RelationGrant>(`/api/v1/relations/${id}/access`, json("POST", grant));
export const revokeRelationAccess = (id: string, grant: string) => api<void>(`/api/v1/relations/${id}/access/${grant}`, { method: "DELETE" });
export type RefreshRelation = {
id: string; version: number; source_name: string; source_environment: Environment | null;
target_name: string; target_environment: Environment | null; usable: boolean; unusable_reason: string | null;
};
export type RefreshRun = {
id: string; relation_id: string; source_name: string; target_name: string; status: string; blocked_reason: string | null;
capture_status: string | null; capture_phase: string | null; snapshot_taken_at: number | null;
restore_status: string | null; restore_phase: string | null;
created_at: number; updated_at: number; expires_at: number; requested_by?: string;
};
export const fetchRefreshRelations = () => api<RefreshRelation[]>("/api/v1/refresh-relations");
export const fetchRefreshRuns = () => api<RefreshRun[]>("/api/v1/refresh-runs");
export const startRefresh = (relation: RefreshRelation, idempotency_key: string) =>
api<RefreshRun>("/api/v1/refresh-runs", json("POST", {
relation_id: relation.id,
// exactly what the person was shown, so a relation changed in the meantime is refused
confirmation: `REFRESH ${relation.source_name} TO ${relation.target_name} v${relation.version}`,
idempotency_key,
}));
export const cancelRefresh = (id: string) => api<RefreshRun>(`/api/v1/refresh-runs/${id}`, { method: "DELETE" });
export type Look = "window" | "radar";
/** The account's saved display choices. A hub without this endpoint, or an account without one, yields `{}`. */