/** * Generic settle outcome for a polled async task: it succeeded, it failed, or the * wait was exhausted with the task still running. `CONNECTION_CHECK_STATUS` in * `types/providers.ts` is a connection-specific alias of this same shape, kept as * its own export so a caller that only cares about a connection result does not * have to name a generic task type to use it. */ export const TASK_OUTCOME = { SUCCESS: "success", FAILED: "failed", PENDING: "pending", } as const; export type TaskOutcome = (typeof TASK_OUTCOME)[keyof typeof TASK_OUTCOME]; export type TaskState = | "available" | "scheduled" | "executing" | "completed" | "failed" | "cancelled"; export interface TaskAttributes { state?: TaskState; result?: R; } export interface TaskData { attributes?: TaskAttributes; } export type GetTaskResponse = | { data: TaskData } | { error: string }; export interface PollOptions { maxAttempts?: number; delayMs?: number; } export type PollSettledResult = | { ok: true; state: TaskState; task: TaskData; result: R | undefined; } | { ok: false; error: string; state?: TaskState; task?: TaskData; result?: R; }; export interface TaskDetails { attributes: { state: string; completed_at: string; result: { exc_type?: string; exc_message?: string[]; exc_module?: string; }; task_args: { scan_id: string; provider_id: string; checks_to_execute: string[]; }; }; }