import { type SyncAuthLeaseIssueRequest, type SyncOperation } from '@syncular/core';
import { type Dialect } from 'kysely';
import type { SyncularBlobClientLike, SyncularClientLike } from './client';
import { type MutationReceipt } from './mutations';
import type { SyncularAuthLeaseRecord, SyncularClientEventSink, SyncularClientEventType, SyncularConflictResolution, SyncularConflictStats, SyncularConflictSummary, SyncularConnectionState, SyncularDiagnosticSnapshot, SyncularLifecycleState, SyncularOutboxStats, SyncularPresenceEntry, SyncularPresenceSink, SyncularSubscriptionSpec, SyncularSyncRequestOptions, SyncularSyncResult } from './types';
export interface SyncularBridgeQueryRequest {
    sql: string;
    parameters: readonly unknown[];
}
export interface SyncularBridgeQueryResult<Row extends Record<string, unknown> = Record<string, unknown>> {
    rows: Row[];
    numAffectedRows?: bigint | number | string;
    insertId?: bigint | number | string | null;
}
export interface SyncularBridgeMutationBatch {
    operations: SyncOperation[];
}
export interface SyncularBridgeStatus {
    lifecycle?: SyncularLifecycleState;
    connection?: SyncularConnectionState;
    outbox?: SyncularOutboxStats | null;
    conflicts?: SyncularConflictStats | null;
}
export interface SyncularBridgePresence {
    get<TMetadata = Record<string, unknown>>(scopeKey: string): SyncularPresenceEntry<TMetadata>[];
    join(scopeKey: string, metadata?: Record<string, unknown>): void;
    leave(scopeKey: string): void;
    updateMetadata(scopeKey: string, metadata: Record<string, unknown>): void;
    onChange<TMetadata = Record<string, unknown>>(listener: SyncularPresenceSink<TMetadata>): () => void;
}
export interface SyncularBridgeConflicts {
    list(): Promise<SyncularConflictSummary[]>;
    retryKeepLocal(id: string): Promise<string>;
    resolve(id: string, resolution: SyncularConflictResolution): Promise<void>;
}
export interface SyncularBridge {
    open?(): Promise<void> | void;
    close?(): Promise<void> | void;
    executeSql<Row extends Record<string, unknown> = Record<string, unknown>>(request: SyncularBridgeQueryRequest): Promise<SyncularBridgeQueryResult<Row>> | SyncularBridgeQueryResult<Row>;
    applyMutationsCommit(batch: SyncularBridgeMutationBatch): Promise<string | MutationReceipt> | string | MutationReceipt;
    applyLeasedMutationsCommit?(batch: SyncularBridgeMutationBatch): Promise<string | MutationReceipt> | string | MutationReceipt;
    sync?(): Promise<SyncularSyncResult>;
    resumeFromBackground?(options?: SyncularSyncRequestOptions): Promise<SyncularSyncResult>;
    start?(): Promise<void>;
    stop?(): Promise<void>;
    setSubscriptions?(subscriptions: readonly SyncularSubscriptionSpec[]): Promise<void>;
    getStatus?(): Promise<SyncularBridgeStatus> | SyncularBridgeStatus;
    issueAuthLease?(request: SyncAuthLeaseIssueRequest): Promise<SyncularAuthLeaseRecord>;
    upsertAuthLease?(lease: SyncularAuthLeaseRecord): Promise<void>;
    authLease?(leaseId: string): Promise<SyncularAuthLeaseRecord | null>;
    activeAuthLeases?(actorId?: string | null, nowMs?: number): Promise<SyncularAuthLeaseRecord[]>;
    diagnosticSnapshot?(): Promise<SyncularDiagnosticSnapshot>;
    on?<T extends SyncularClientEventType>(event: T, listener: SyncularClientEventSink<T>): () => void;
    presence?: SyncularBridgePresence;
    conflicts?: SyncularBridgeConflicts;
    blobs?: Partial<SyncularBlobClientLike>;
}
export interface CreateSyncularBridgeClientOptions {
    bridge: SyncularBridge;
    sync?: {
        autoSyncAfterMutation?: boolean;
    };
    idColumn?: string;
    versionColumn?: string | null;
    omitColumns?: readonly string[];
}
export declare function createSyncularBridgeDialect(bridge: SyncularBridge): Dialect;
export declare function createSyncularBridgeClient<DB>(options: CreateSyncularBridgeClientOptions): Promise<SyncularClientLike<DB>>;
//# sourceMappingURL=bridge-client.d.ts.map