import type { LogContext } from '@rocicorp/logger';
import type { JSONObject } from '../../../../shared/src/bigint-json.ts';
import { type JSONObject as SafeJSONObject } from '../../../../shared/src/json.ts';
import type { Downstream } from '../../../../zero-protocol/src/down.ts';
import type { InspectDownBody } from '../../../../zero-protocol/src/inspect-down.ts';
import { type SchemaVersions } from '../../types/schema-versions.ts';
import { type ShardID } from '../../types/shards.ts';
import type { Subscription } from '../../types/subscription.ts';
import { type CVRVersion, type DelQueryPatch, type NullableCVRVersion, type PutQueryPatch, type RowID } from './schema/types.ts';
import type { ErroredQuery } from '../../../../zero-protocol/src/custom-queries.ts';
export type PutRowPatch = {
    type: 'row';
    op: 'put';
    id: RowID;
    contents: JSONObject;
};
export type DeleteRowPatch = {
    type: 'row';
    op: 'del';
    id: RowID;
};
export type RowPatch = PutRowPatch | DeleteRowPatch;
export type ConfigPatch = DelQueryPatch | PutQueryPatch;
export type Patch = ConfigPatch | RowPatch;
export type PatchToVersion = {
    patch: Patch;
    toVersion: CVRVersion;
};
export interface PokeHandler {
    addPatch(patch: PatchToVersion): Promise<void>;
    cancel(): Promise<void>;
    end(finalVersion: CVRVersion): Promise<void>;
}
/** Wraps PokeHandlers for multiple clients in a single PokeHandler. */
export declare function startPoke(clients: ClientHandler[], tentativeVersion: CVRVersion, schemaVersions?: SchemaVersions): PokeHandler;
/**
 * Handles a single `ViewSyncer` connection.
 */
export declare class ClientHandler {
    #private;
    readonly clientID: string;
    readonly wsID: string;
    constructor(lc: LogContext, clientGroupID: string, clientID: string, wsID: string, shard: ShardID, baseCookie: string | null, schemaVersion: number | null, downstream: Subscription<Downstream>);
    version(): NullableCVRVersion;
    fail(e: unknown): void;
    close(reason: string): void;
    startPoke(tentativeVersion: CVRVersion, schemaVersions?: SchemaVersions): PokeHandler;
    sendDeleteClients(lc: LogContext, deletedClientIDs: string[], deletedClientGroupIDs: string[]): Promise<void>;
    sendQueryTransformErrors(errors: ErroredQuery[]): void;
    sendInspectResponse(lc: LogContext, response: InspectDownBody): void;
}
/**
 * Column values of type INT8 are returned as the `bigint` from the
 * Postgres library. These are converted to `number` if they are within
 * the safe Number range, allowing the protocol to support numbers larger
 * than 32-bits. Values outside of the safe number range (e.g. > 2^53) will
 * result in an Error.
 */
export declare function ensureSafeJSON(row: JSONObject): SafeJSONObject;
//# sourceMappingURL=client-handler.d.ts.map