Types
All types are exported from @queuebase/nextjs and @queuebase/node (re-exported from @queuebase/core).
JobStatus
Section titled “JobStatus”type JobStatus = 'pending' | 'running' | 'completed' | 'failed' | 'cancelled';BackoffStrategy
Section titled “BackoffStrategy”type BackoffStrategy = 'linear' | 'exponential';EnqueueOptions
Section titled “EnqueueOptions”Options for enqueueing a job. Can be set as defaults on a job definition or passed to .enqueue().
interface EnqueueOptions { delay?: string | number; retries?: number; backoff?: BackoffStrategy; backoffDelay?: number; concurrency?: number;}| Field | Type | Description |
|---|---|---|
delay | string | number | Delay before running. Strings: '5s', '5m', '1h', '2d'. Numbers: milliseconds. |
retries | number | Number of retry attempts on failure. |
backoff | BackoffStrategy | Backoff strategy for retries. |
backoffDelay | number | Base delay between retries in ms (default: 1000). |
concurrency | number | Max concurrent executions of this job type per worker. |
JobDefinition<TInput, TOutput>
Section titled “JobDefinition<TInput, TOutput>”A job definition with typed input and output.
interface JobDefinition<TInput = unknown, TOutput = unknown> { input: z.ZodType<TInput>; handler: (ctx: JobContext<TInput>) => Promise<TOutput>; defaults?: EnqueueOptions;}JobContext<TInput>
Section titled “JobContext<TInput>”Context passed to job handlers.
interface JobContext<TInput = unknown> { input: TInput; jobId: string; attempt: number; maxAttempts: number;}| Field | Type | Description |
|---|---|---|
input | TInput | Validated input data |
jobId | string | Unique job ID |
attempt | number | Current attempt (1-indexed) |
maxAttempts | number | Maximum attempts allowed |
EnqueueResult
Section titled “EnqueueResult”Returned from .enqueue().
interface EnqueueResult { jobId: string; getStatus: () => Promise<JobStatusResponse>;}JobStatusResponse
Section titled “JobStatusResponse”Job status as returned by the API.
interface JobStatusResponse { publicId: string; name: string; status: JobStatus; attempt: number; maxAttempts: number; createdAt: string; startedAt: string | null; completedAt: string | null; result: unknown; error: string | null;}JobResult<TOutput>
Section titled “JobResult<TOutput>”Result of a job execution.
interface JobResult<TOutput = unknown> { success: boolean; output?: TOutput; error?: string; duration: number;}QueuebaseConfig
Section titled “QueuebaseConfig”Configuration for Queuebase.
interface QueuebaseConfig { jobsDir: string; callbackUrl?: string; apiKey?: string; apiUrl?: string;}