import type { Db, ResumeToken } from 'mongodb';
import type { JobNotification, NotificationChannelConfig } from 'agenda';
import { BaseNotificationChannel } from 'agenda';
/**
 * Configuration for MongoChangeStreamNotificationChannel
 */
export interface MongoChangeStreamNotificationChannelConfig extends NotificationChannelConfig {
    /**
     * MongoDB database instance.
     * Required - must be connected to a replica set.
     */
    db?: Db;
    /**
     * Collection name to watch (default: 'agendaJobs')
     */
    collection?: string;
    /**
     * Resume token to resume watching from a specific point.
     * Useful for recovering from disconnections.
     */
    resumeToken?: ResumeToken;
    /**
     * Whether to use fullDocument: 'updateLookup' for update events.
     * This fetches the full document on updates but adds latency.
     * Default: true (required for proper notification data)
     */
    fullDocument?: boolean;
}
/**
 * MongoDB Change Stream notification channel.
 *
 * Uses MongoDB Change Streams to watch for job changes in real-time.
 * This eliminates the need for polling and provides instant notifications
 * when jobs are created or updated.
 *
 * **Requirements:**
 * - MongoDB must be deployed as a replica set (even single-node replica sets work)
 * - WiredTiger storage engine (default since MongoDB 3.2)
 *
 * **How it works:**
 * - Watches the jobs collection for insert/update/replace operations
 * - When a job with `nextRunAt` is modified, handlers are notified
 * - The `publish()` method is a no-op since Change Streams automatically
 *   detect job changes from any source
 *
 * @example
 * ```typescript
 * import { Agenda } from 'agenda';
 * import { MongoBackend, MongoChangeStreamNotificationChannel } from '@agendajs/mongo-backend';
 *
 * const backend = new MongoBackend({ mongo: db });
 * const channel = new MongoChangeStreamNotificationChannel({ db });
 *
 * const agenda = new Agenda({
 *   backend,
 *   notificationChannel: channel
 * });
 * ```
 */
export declare class MongoChangeStreamNotificationChannel extends BaseNotificationChannel {
    private db?;
    private collectionName;
    private collection?;
    private changeStream?;
    private resumeToken?;
    private useFullDocument;
    constructor(config?: MongoChangeStreamNotificationChannelConfig);
    /**
     * Set the MongoDB database instance.
     * Used when the channel is created before the database connection.
     */
    setDb(db: Db): void;
    /**
     * Get the last resume token for reconnection purposes.
     * Store this token to resume watching from the same point after restart.
     */
    getResumeToken(): ResumeToken | undefined;
    connect(): Promise<void>;
    private handleChange;
    private extractFullDocument;
    private buildNotification;
    private handleConnectionLoss;
    disconnect(): Promise<void>;
    /**
     * Publish a job notification.
     *
     * **Note:** This method is a no-op for Change Stream notifications.
     * Change Streams automatically detect job changes in the database,
     * so explicit publishing is not required. This method exists only
     * to satisfy the NotificationChannel interface.
     *
     * All job saves to the watched collection will automatically trigger
     * notifications to all subscribers.
     */
    publish(_notification: JobNotification): Promise<void>;
}
