export interface ApiSuccessResponse { status: "success"; data: T; message: string; status_code: number; } export interface ApiErrorResponse { status: "error"; data: null; message: string; status_code: number; } export type ApiResponse = ApiSuccessResponse | ApiErrorResponse; export interface ClientResult { success: boolean; data: T | null; message: string; statusCode: number; /** * The backend's machine-readable refusal code (`render_error(code:)`), when it sent one: * `name_taken`, `run_in_progress`, `no_scale_bounds`, `data_access_required` and so on. * Only set on a failure. A tool reads it to explain a refusal instead of relaying a bare 422. */ code?: string; /** The `data` an error response carried (a SQL error's `position`, an upscale's event pid). */ errorData?: unknown; /** * The paging block a list sent beside `data` (`{page, limit, total_records, total_pages, * next_page, prev_page}` on the activity feed). Only set on a success that carried one. */ pagination?: Record; } export type HttpMethod = "GET" | "POST" | "PUT" | "PATCH" | "DELETE";