import { Query } from 'mingo'; import { Document, Filter } from 'mongodb'; import type { ErrorEvents } from './ErrorEvents'; import { PromiseTracker } from './PromiseTracker'; import { TypedEventEmitter } from './TypedEventEmitter'; export interface SubscriptionOptions { /** Local filter to apply on received messages (in-memory). */ filter?: Filter; } export type SubscriptionCallback = (message: TMessage) => void | Promise; export type SubscriptionEvents = ErrorEvents; export declare class Subscription extends TypedEventEmitter> { protected callback: SubscriptionCallback; protected filter?: Filter; protected mingoQuery?: Query; protected promises: PromiseTracker; protected closed: boolean; constructor(callback: SubscriptionCallback, options?: SubscriptionOptions); close(): Promise; handle(message: TMessage): Promise; }