Skip to content

Types

All types are exported from @queuebase/nextjs and @queuebase/node (re-exported from @queuebase/core).

type JobStatus = 'pending' | 'running' | 'completed' | 'failed' | 'cancelled';
type BackoffStrategy = 'linear' | 'exponential';

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;
}
FieldTypeDescription
delaystring | numberDelay before running. Strings: '5s', '5m', '1h', '2d'. Numbers: milliseconds.
retriesnumberNumber of retry attempts on failure.
backoffBackoffStrategyBackoff strategy for retries.
backoffDelaynumberBase delay between retries in ms (default: 1000).

Schedule configuration for a job. Only available on jobs with an empty input schema.

type ScheduleInput = string | ScheduleConfig;

When a string, it can be a plain English expression ("every day at 9am") or a raw cron expression ("0 9 * * *").

Full schedule configuration object.

interface ScheduleConfig {
cron: string;
timezone?: string;
enabled?: boolean;
overlap?: OverlapPolicy;
}
FieldTypeDescriptionDefault
cronstringCron expression or plain English string(required)
timezonestringIANA timezone'UTC'
enabledbooleanWhether the schedule is activetrue
overlapOverlapPolicyBehavior when previous run is still executing'skip'
type OverlapPolicy = 'skip' | 'allow';

Internal normalized form of a schedule after parsing and validation.

interface ResolvedSchedule {
cronExpression: string;
timezone: string;
enabled: boolean;
overlap: OverlapPolicy;
}

A job definition with typed input and output.

interface JobDefinition<TInput = unknown, TOutput = unknown> {
input: StandardSchemaV1<TInput>;
handler: (ctx: JobContext<TInput>) => Promise<TOutput>;
defaults?: EnqueueOptions;
config?: JobTypeConfig;
schedule?: ScheduleInput; // only when TInput is Record<string, never>
}

The input field accepts any Standard Schema-compatible validator (Zod, Valibot, ArkType, etc.).

Per-job-type configuration for timeout and concurrency.

interface JobTypeConfig {
timeout?: string | number;
concurrency?: number;
}
FieldTypeDescription
timeoutstring | numberMax execution time ('5m', '30s', or milliseconds)
concurrencynumberMax concurrent executions of this job type per worker

Context passed to job handlers.

interface JobContext<TInput = unknown> {
input: TInput;
jobId: string;
attempt: number;
maxAttempts: number;
fail: (reason: string) => never;
}
FieldTypeDescription
inputTInputValidated input data
jobIdstringUnique job ID
attemptnumberCurrent attempt (1-indexed)
maxAttemptsnumberMaximum attempts allowed
fail(reason: string) => neverExplicitly mark the job as failed. See Defining Jobs.

Returned from .enqueue().

interface EnqueueResult {
jobId: string;
getStatus: () => Promise<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;
}

Result of a job execution.

interface JobResult<TOutput = unknown> {
success: boolean;
output?: TOutput;
error?: string;
duration: number;
}

Configuration for Queuebase.

interface QueuebaseConfig {
jobsDir: string;
callbackUrl?: string;
apiKey?: string;
apiUrl?: string;
}