import type { AgendaBackend, JobRepository, NotificationChannel, JobLogger } from 'agenda'; import type { PostgresBackendConfig } from './types.js'; /** * PostgreSQL backend for Agenda * * Provides both storage (via PostgresJobRepository) and real-time notifications * (via PostgresNotificationChannel using LISTEN/NOTIFY). * * @example * ```typescript * import { Agenda } from 'agenda'; * import { PostgresBackend } from '@agendajs/postgres-backend'; * * // Using connection string * const agenda = new Agenda({ * backend: new PostgresBackend({ * connectionString: 'postgresql://user:pass@localhost:5432/mydb' * }) * }); * * // Or using an existing pool (e.g., shared with your app) * // The pool will NOT be closed when Agenda disconnects * import { Pool } from 'pg'; * const pool = new Pool({ connectionString: '...' }); * * const agenda = new Agenda({ * backend: new PostgresBackend({ pool }) * }); * * // Your app can continue using the pool after agenda.stop() * * agenda.define('myJob', async (job) => { * console.log('Running job:', job.attrs.name); * }); * * await agenda.start(); * await agenda.every('5 minutes', 'myJob'); * ``` */ export declare class PostgresBackend implements AgendaBackend { readonly name = "PostgreSQL"; private _repository; private _notificationChannel?; private _logger; private config; private _ownsConnection; constructor(config: PostgresBackendConfig); /** * The job repository for storage operations */ get repository(): JobRepository; /** * Whether this backend owns its database connection. * True if created from connectionString/poolConfig, false if pool was passed in. */ get ownsConnection(): boolean; /** * The job logger for persistent event logging. * Always available; Agenda decides whether to activate it via its `logging` config. */ get logger(): JobLogger; /** * The notification channel for real-time notifications via LISTEN/NOTIFY * Returns undefined if notifications are disabled */ get notificationChannel(): NotificationChannel | undefined; /** * Connect to PostgreSQL * * - Establishes database connection pool * - Creates table and indexes if ensureSchema is true * - Sets up LISTEN for real-time notifications */ connect(): Promise; /** * Disconnect from PostgreSQL * * - Stops LISTEN on notification channel * - Closes database connection pool */ disconnect(): Promise; }