openvibe-sdk/jobs

Generated at from openvibe-contracts v0.33.0 and openvibe-sdk v0.5.0.

From types/jobs.d.ts (both). Declarations are shown verbatim.

type JobState

export type JobState = 'queued' | 'running' | 'succeeded' | 'failed' | 'cancelled';

interface Job

export interface Job {
    id: string;
    object: 'tools.job';
    service: string;
    type: string;
    type_version: number;
    state: JobState;
    progress: { percent: number | null; message: string | null };
    attempts: number;
    max_attempts: number;
    cancel_requested?: boolean;
    created_at?: string | null;
    started_at?: string | null;
    finished_at?: string | null;
    expires_at?: string | null;
    result: { files: Array<{ name: string; mime: string; size: number; url: string; [k: string]: unknown }>; data: Record<string, unknown> } | null;
    error: { code: string; detail?: string; [k: string]: unknown } | null;
    retryable: boolean;
    links: { self: string; events: string; cancel: string | null };
    [field: string]: unknown;
}

interface JobEvent

export interface JobEvent { id: number | null; event: string; job: Job | null; }

type JobFile

export type JobFile = Blob | { name?: string; data: Blob | ArrayBuffer | ArrayBufferView | string; type?: string };

interface SubmitJob

export interface SubmitJob {
    type: string;
    input?: Record<string, unknown>;
    files?: JobFile | JobFile[];
    /** Same key + same request = same job. Generated when omitted (returned). */
    idempotencyKey?: string;
    signal?: AbortSignal;
}

interface JobEventsOptions

export interface JobEventsOptions { lastEventId?: number | string; signal?: AbortSignal; maxReconnects?: number; reconnectDelayMs?: number; }

interface JobsClient

export interface JobsClient {
    submit(input: SubmitJob): Promise<{ job: Job; replayed: boolean; idempotencyKey: string }>;
    get(id: string, opts?: { signal?: AbortSignal }): Promise<Job | null>;
    cancel(id: string, opts?: { signal?: AbortSignal }): Promise<Job>;
    events(id: string, opts?: JobEventsOptions): AsyncGenerator<JobEvent, void, unknown>;
    wait(id: string, opts?: JobEventsOptions & { onEvent?: (e: JobEvent) => void | Promise<void> }): Promise<Job | null>;
    /** The raw Response of a result file (body unread). */
    file(id: string, n?: number, opts?: { signal?: AbortSignal; inline?: boolean }): Promise<Response>;
}

function createJobsClient

baseUrl: the satellite that runs the job type (e.g. https://img.openvibe.tools); default the registry's `tools` origin.

export declare function createJobsClient(client: OpenVibeClient, opts?: { baseUrl?: string; service?: string; audience?: string }): JobsClient;

function isTerminal

export declare function isTerminal(job: Pick<Job, 'state'> | null | undefined): boolean;

const TERMINAL_STATES

export declare const TERMINAL_STATES: JobState[];