import { Dispatchable } from "./dispatchable.js"; import { Schedulable } from "./schedulable.js"; import PgBoss, { ConstructorOptions, DatabaseOptions, Job as PgBossJob, JobInsert, JobOptions, JobStates, JobWithMetadata, MaintenanceOptions, QueueOptions, ScheduleOptions as PgBossScheduleOptions, SchedulingOptions, SendOptions, WorkHandler, WorkOptions as PgBossWorkOptions, WorkWithMetadataHandler, Worker } from "pg-boss"; //#region src/types.d.ts /** * Job handler constructor type (supports both Dispatchable and Schedulable) */ interface JobHandlerConstructor { new (...args: any[]): Dispatchable | Schedulable; queue?: string; workOptions?: PgBoss.WorkOptions; scheduleOptions?: PgBoss.ScheduleOptions; schedule?: string; } /** * Allowed job types for dispatch/schedule (class or lazy import) */ type AllowedJobTypes = JobHandlerConstructor | (() => Promise<{ default: JobHandlerConstructor; }>); /** * Type for Dispatchable jobs only (for type-safe dispatch) */ type DispatchableJobType = (new (...args: any[]) => Dispatchable) | (() => Promise<{ default: new (...args: any[]) => Dispatchable; }>); interface PgBossConfig extends PgBoss.ConstructorOptions { /** * Graceful shutdown timeout in milliseconds */ shutdownTimeoutMs?: number; jobsPath?: string; cronPath?: string; /** * Available queue names for type safety * Jobs can specify static queue property that must match one of these */ queues?: readonly string[]; /** * Default queue for jobs that don't specify a static queue * Must be one of the queues defined above * Default: 'default' */ defaultQueue?: string; } /** * Helper type to infer queue names from config */ type InferQueues = T['queues'] extends readonly string[] ? T['queues'][number] : string; //#endregion export { AllowedJobTypes, type ConstructorOptions, type DatabaseOptions, DispatchableJobType, InferQueues, JobHandlerConstructor, type JobInsert, type JobOptions, type JobStates, type JobWithMetadata, type MaintenanceOptions, PgBossConfig, type PgBossJob, type PgBossScheduleOptions, type PgBossWorkOptions, type QueueOptions, type SchedulingOptions, type SendOptions, type WorkHandler, type WorkWithMetadataHandler, type Worker };