/**
 * api-client/types.ts — Response types for the AILF API.
 *
 * These are the client-side types derived from the API's standard response
 * envelope pattern (Stripe-style: `object`, `createdAt`, `apiVersion` on
 * every response). They mirror the shapes returned by the API routes but
 * are defined independently — the client doesn't import from the API
 * package.
 *
 * @see packages/api/src/lib/envelope.ts — server-side envelope builders
 * @see packages/api/src/routes/pipeline.ts — POST /v1/pipeline response
 * @see packages/api/src/routes/jobs.ts — GET /v1/jobs/:id response
 */
import type { ValidationIssue } from "../../_vendor/ailf-core/index.d.ts";
export type { ValidationIssue } from "../../_vendor/ailf-core/index.d.ts";
/** Standard envelope fields present on every API response. */
export interface ApiEnvelope {
    object: string;
    createdAt: string;
    apiVersion: string;
}
/** Possible terminal and non-terminal job statuses. */
export type JobStatus = "received" | "queued" | "running" | "completed" | "failed" | "timed-out";
/** Structured error detail attached to failed/timed-out jobs. */
export interface JobError {
    message: string;
    step?: string;
}
/** Step-level progress info for running jobs. */
export interface JobProgress {
    step: string;
    current: number;
    total: number;
}
/** Execution backend info. */
export interface JobExecution {
    backend: string;
    runId?: string | null;
    runUrl?: string | null;
}
/** Full job response from GET /v1/jobs/:id. */
export interface JobResponse extends ApiEnvelope {
    object: "job";
    jobId: string;
    status: JobStatus;
    startedAt?: string | null;
    completedAt?: string | null;
    progress?: JobProgress | null;
    execution?: JobExecution | null;
    reportId?: string | null;
    reportUrl?: string | null;
    error?: JobError | null;
}
/** Response from POST /v1/pipeline. */
export interface SubmitResponse extends ApiEnvelope {
    object: "job";
    jobId: string;
    status: string;
    statusUrl: string;
    backend: string;
    estimatedDurationMs?: number;
    runUrl?: string;
}
export interface ValidationResponse extends ApiEnvelope {
    object: "validation";
    valid: boolean;
    issues?: ValidationIssue[];
}
export interface ApiErrorDetail {
    code: string;
    message: string;
    param?: string;
    issues?: ValidationIssue[];
    retryAfter?: string;
}
export interface ApiErrorResponse extends ApiEnvelope {
    object: "error";
    error: ApiErrorDetail;
}
/** Configuration for creating an ApiClient instance. */
export interface ApiClientOptions {
    /** AILF API key (starts with ailf_live_sk_ or ailf_test_sk_). */
    apiKey: string;
    /** Base URL for the AILF API. Defaults to https://ailf-api.sanity.build. */
    baseUrl?: string;
}
/** Options for the waitForCompletion() polling method. */
export interface WaitOptions {
    /** Maximum time to wait in milliseconds (default: 20 minutes). */
    timeoutMs?: number;
    /** Called after each poll with the current job state. */
    onProgress?: (job: JobResponse) => void;
    /** Long-poll wait time in seconds sent via Prefer header (default: 25, max: 25). */
    longPollSeconds?: number;
}
