/**
 * Abstract base class for all ingestor types.
 *
 * Provides common functionality: ring buffer management, event counting,
 * status reporting, and a standard interface for start/stop lifecycle.
 *
 * Subclasses implement `start()` and `stop()` for their specific protocol
 * (WebSocket, webhook listener, HTTP poller, etc.) and call `pushEvent()`
 * whenever they receive data from the external service.
 */
import { EventEmitter } from 'node:events';
import type { IngestedEvent, IngestorState, IngestorStatus } from './types.js';
import { RingBuffer } from './ring-buffer.js';
export declare abstract class BaseIngestor extends EventEmitter {
    /** The connection alias (e.g., 'discord-bot'). */
    protected readonly connectionAlias: string;
    /** The ingestor type (for status reporting). */
    protected readonly ingestorType: 'websocket' | 'webhook' | 'poll';
    /** Resolved secrets for the parent connection. */
    protected readonly secrets: Record<string, string>;
    /** Optional instance identifier for multi-instance support.
     *  When set, this ingestor is one of N instances for the same connection
     *  (e.g., watching different Trello boards or Reddit subreddits). */
    protected readonly instanceId?: string | undefined;
    protected state: IngestorState;
    protected buffer: RingBuffer<IngestedEvent>;
    protected counter: number;
    protected lastEventAt: string | null;
    protected errorMessage?: string;
    /** Caller alias that owns this ingestor. Set by IngestorManager after creation. */
    callerAlias: string;
    /** Per-instance epoch for event ID generation.
     *  Each instance claims a unique epoch so IDs never collide across restarts. */
    private readonly bootEpoch;
    /** Recently seen idempotency keys for deduplication. */
    private readonly seenKeys;
    constructor(
    /** The connection alias (e.g., 'discord-bot'). */
    connectionAlias: string, 
    /** The ingestor type (for status reporting). */
    ingestorType: 'websocket' | 'webhook' | 'poll', 
    /** Resolved secrets for the parent connection. */
    secrets: Record<string, string>, 
    /** Buffer capacity (defaults to DEFAULT_BUFFER_SIZE). */
    bufferSize?: number, 
    /** Optional instance identifier for multi-instance support.
     *  When set, this ingestor is one of N instances for the same connection
     *  (e.g., watching different Trello boards or Reddit subreddits). */
    instanceId?: string | undefined);
    /** Start the ingestor (connect WebSocket, begin polling, etc.). */
    abstract start(): Promise<void>;
    /** Stop the ingestor cleanly (close connections, clear timers).
     *  @param permanent  When true, indicates a permanent shutdown (server exit
     *                    or instance deletion). Webhook ingestors use this to
     *                    unregister webhooks from the external service. */
    abstract stop(permanent?: boolean): Promise<void>;
    /**
     * Push a new event into the ring buffer.
     * Called by subclasses when they receive data from an external service.
     *
     * @param eventType  The event type/name (e.g., 'push', 'MESSAGE_CREATE').
     * @param data       The raw event payload from the external service.
     * @param idempotencyKey  Optional service-specific unique key for deduplication.
     *                        When provided, duplicate events with the same key are silently dropped.
     *                        When omitted, a fallback key is generated from `${source}:${uuid-v4}`.
     */
    protected pushEvent(eventType: string, data: unknown, idempotencyKey?: string): void;
    /**
     * Prune the seen-keys set to prevent unbounded memory growth.
     * Removes the oldest half of entries (Set preserves insertion order).
     */
    private pruneSeenKeys;
    /**
     * Retrieve events since a cursor.
     * @param afterId  Return events with id > afterId. Pass -1 (or omit) for all buffered events.
     */
    getEvents(afterId?: number): IngestedEvent[];
    /** Return the current status of this ingestor. */
    getStatus(): IngestorStatus;
}
//# sourceMappingURL=base-ingestor.d.ts.map