import { IIntegrationRunRecorder, RecordItemInput, StartRunInput, CompleteRunInput, IntegrationRunSummary } from './integration-run-recorder.protocol.js';
import './integration-field-diff.protocol.js';
import 'zod';

/**
 * Optional per-subscription metadata a test can seed on the memory backend
 * so `listRecent` can surface `connectionId`. The memory recorder's write
 * path never persists subscription rows (it only stores runs + items), so
 * `listRecent` has no way to derive `connectionId` on its own. Tests that
 * care about the field should populate `subscriptions` before calling
 * `listRecent`; calls that don't seed get an empty string and a stable
 * shape (see `listRecent` below).
 */
interface MemoryIntegrationSubscription {
    connectionId: string;
    adapter: string;
    domain: string;
    externalRef: string | null;
    lastIntegrationAt?: Date | null;
    updatedAt: Date;
}
/**
 * Concrete run row as held in memory. Shape mirrors the interesting
 * columns on `integration_runs` so assertions read like DB queries.
 */
interface MemoryRunRecord {
    id: string;
    subscriptionId: string;
    direction: 'inbound' | 'outbound';
    action: 'poll' | 'cdc' | 'webhook' | 'manual' | 'writeback';
    status: 'running' | 'success' | 'no_changes' | 'failed';
    cursorBefore: unknown | null;
    cursorAfter: unknown | null;
    recordsFound: number;
    recordsProcessed: number;
    durationMs: number | null;
    error: string | null;
    tenantId: string | null;
    startedAt: Date;
    completedAt: Date | null;
}
declare class MemoryRunRecorder implements IIntegrationRunRecorder {
    /**
     * All started runs keyed by id. Public so tests can inspect lifecycle
     * transitions without poking through recording methods.
     */
    readonly runs: Map<string, MemoryRunRecord>;
    /**
     * Items keyed by `integration_run_id`, array order matches insertion order —
     * mirrors the timeline the `(integration_run_id, created_at)` index produces
     * in Postgres.
     */
    readonly items: Map<string, RecordItemInput[]>;
    /**
     * Seedable subscription metadata — tests populate this to make
     * `listRecent` return meaningful `connectionId` values. The memory
     * backend doesn't track subscriptions on its own (only runs + items), so
     * this map is the intentional extension point: tests write entries for
     * the subscription ids they use, production code never touches it.
     */
    readonly subscriptions: Map<string, MemoryIntegrationSubscription>;
    startRun(input: StartRunInput): Promise<{
        id: string;
    }>;
    recordItem(input: RecordItemInput): Promise<void>;
    completeRun(runId: string, input: CompleteRunInput): Promise<void>;
    listRecent(limit: number, subscriptionId?: string, _tenantId?: string | null): Promise<IntegrationRunSummary[]>;
    /** Reset state. Tests call this in `beforeEach`. */
    clear(): void;
    /** All runs for a subscription, newest first. Timeline reads. */
    getRunsForSubscription(subscriptionId: string): MemoryRunRecord[];
    /** All item rows for a run, insertion-ordered. */
    getItemsForRun(runId: string): RecordItemInput[];
}

export { type MemoryIntegrationSubscription, type MemoryRunRecord, MemoryRunRecorder };
