/**
 * Code starting point (though modified for typescript) courtesy of the authors in this repo:
 * https://github.com/GraphQLCollege/graphql-postgres-subscriptions/blob/master/postgres-pubsub.js
 *
 * Repo seems abandoned, so moved here to be able to keep dependencies up to date.
 */
import { EventEmitter } from 'events';
import { PubSubEngine } from 'graphql-subscriptions';
import { Client, type ClientConfig } from 'pg';
interface PgIPCInstance extends EventEmitter {
    notify(channel: string, payload?: any): void;
    send(channel: string, payload?: any): void;
    end(): void;
}
type OptionsClientExtension = {
    client?: Client;
};
type PostgresPubSubOptions = ClientConfig & OptionsClientExtension;
type MessageHandler<T = any> = (message: any) => T;
declare class PostgresPubSub extends PubSubEngine {
    client: Client;
    protected ee: PgIPCInstance;
    private subscriptions;
    private subIdCounter;
    commonMessageHandler: MessageHandler<any>;
    constructor(options?: PostgresPubSubOptions);
    publish(triggerName: string, payload: any): Promise<void>;
    subscribe(triggerName: string, onMessage: (...args: any[]) => void): Promise<number>;
    unsubscribe(subId: number): void;
    asyncIterator<T = any>(triggers: string | string[]): AsyncIterableIterator<T>;
}
export default PostgresPubSub;
//# sourceMappingURL=PostgresPubSub.d.ts.map