import type { LogConfig } from '../../../../shared/src/logging.ts';
import type { Database } from '../../../../zqlite/src/db.ts';
import type { ChangeStreamData } from '../change-source/protocol/current/downstream.ts';
import type { ChangeProcessorMode, CommitResult } from './change-processor.ts';
import type { SubscriptionState } from './schema/replication-state.ts';
export type PragmaConfig = {
    busyTimeout: number;
    analysisLimit: number;
    walAutocheckpoint?: number | undefined;
};
type ErrorHandler = (err: Error) => void;
/**
 * Interface for a write worker that processes replication messages.
 */
export interface WriteWorkerClient {
    getSubscriptionState(): Promise<SubscriptionState>;
    processMessage(downstream: ChangeStreamData): Promise<CommitResult | null>;
    abort(): void;
    stop(): Promise<void>;
    onError(handler: ErrorHandler): void;
}
export type ArgsMap = {
    init: [string, ChangeProcessorMode, PragmaConfig, LogConfig];
    getSubscriptionState: [];
    processMessage: [ChangeStreamData];
    abort: [];
    stop: [];
};
export type Method = keyof ArgsMap;
export type Request<M extends Method = Method> = {
    method: M;
    args: ArgsMap[M];
};
export type ResultMap = {
    init: void;
    getSubscriptionState: SubscriptionState;
    processMessage: CommitResult | null;
    abort: void;
    stop: void;
};
export type Response<M extends Method = Method> = {
    method: M;
    result: ResultMap[M];
    error?: undefined;
} | {
    method: M;
    error: unknown;
    result?: undefined;
};
export type WriteError = {
    writeError: Error;
};
export declare function applyPragmas(db: Database, pragmas: PragmaConfig): void;
/**
 * Delegates SQLite writes to a worker_thread,
 * keeping the main event loop free for WebSocket heartbeats and IPC.
 */
export declare class ThreadWriteWorkerClient implements WriteWorkerClient {
    #private;
    constructor();
    init(dbPath: string, mode: ChangeProcessorMode, pragmas: PragmaConfig, logConfig: LogConfig): Promise<void>;
    getSubscriptionState(): Promise<SubscriptionState>;
    processMessage(downstream: ChangeStreamData): Promise<CommitResult | null>;
    abort(): void;
    stop(): Promise<void>;
    onError(handler: ErrorHandler): void;
}
export {};
//# sourceMappingURL=write-worker-client.d.ts.map