import * as v from '../../shared/src/valita.ts';
/**
 * Pokes use a multi-part format. Pokes send entity data to the client and can
 * be multiple mega-bytes in size. Using a multi-part format allows the server
 * to avoid having to have the full poke in memory at one time.
 *
 * Each poke is assigned a `pokeID`, a unique id (within the context of the
 * connection) for identifying the poke.  All messages for a poke will have the
 * same `pokeID`.
 *
 * A poke begins with a `poke-start` message which contains the `baseCookie`
 * the poke is updating from and the `cookie` the poke is updating to.
 *
 * The poke continues with zero to many `poke-part` messages, each of which
 * can contain patch parts.  These patch parts should be merged in the order
 * received.
 *
 * Finally, the poke ends with a `poke-end` message.  The merged `poke-parts`
 * can now be applied as a whole to update from `baseCookie` to `cookie`.
 *
 * Poke messages can be intermingled with other `down` messages, but cannot be
 * intermingled with poke messages for a different `pokeID`. If this is
 * observed it is an unexpected error; the client should ignore both pokes,
 * disconnect, and reconnect.
 */
export declare const pokeStartBodySchema: v.ObjectType<{
    pokeID: v.Type<string>;
    baseCookie: v.UnionType<[v.Type<string>, v.Type<null>]>;
    /**
     * This field is always set if the poke contains a `rowsPatch`.
     * It may be absent for patches that only update clients and queries.
     */
    schemaVersions: v.Optional<{
        minSupportedVersion: number;
        maxSupportedVersion: number;
    }>;
    timestamp: v.Optional<number>;
}, undefined>;
export declare const pokePartBodySchema: v.ObjectType<{
    pokeID: v.Type<string>;
    lastMutationIDChanges: v.Optional<Record<string, number>>;
    desiredQueriesPatches: v.Optional<Record<string, ({
        ttl?: number | undefined;
        op: "put";
        hash: string;
    } | {
        op: "del";
        hash: string;
    } | {
        op: "clear";
    })[]>>;
    gotQueriesPatch: v.Optional<({
        ttl?: number | undefined;
        op: "put";
        hash: string;
    } | {
        op: "del";
        hash: string;
    } | {
        op: "clear";
    })[]>;
    rowsPatch: v.Optional<({
        op: "put";
        tableName: string;
        value: Readonly<Record<string, import("../../shared/src/json.ts").ReadonlyJSONValue | undefined>>;
    } | {
        merge?: import("../../shared/src/json.ts").ReadonlyJSONObject | undefined;
        constrain?: string[] | undefined;
        op: "update";
        tableName: string;
        id: Readonly<Record<string, string | number | boolean>>;
    } | {
        op: "del";
        tableName: string;
        id: Readonly<Record<string, string | number | boolean>>;
    } | {
        op: "clear";
    })[]>;
    mutationsPatch: v.Optional<({
        op: "put";
        mutation: {
            id: {
                id: number;
                clientID: string;
            };
            result: {
                details?: import("../../shared/src/json.ts").ReadonlyJSONValue | undefined;
                error: "app";
            } | {
                details?: import("../../shared/src/json.ts").ReadonlyJSONValue | undefined;
                error: "oooMutation" | "alreadyProcessed";
            } | {
                data?: import("../../shared/src/json.ts").ReadonlyJSONValue | undefined;
            };
        };
    } | {
        op: "del";
        id: {
            id: number;
            clientID: string;
        };
    })[]>;
}, undefined>;
export declare const pokeEndBodySchema: v.ObjectType<{
    pokeID: v.Type<string>;
    cookie: v.Type<string>;
    cancel: v.Optional<boolean>;
}, undefined>;
export declare const pokeStartMessageSchema: v.TupleType<[v.Type<"pokeStart">, v.ObjectType<{
    pokeID: v.Type<string>;
    baseCookie: v.UnionType<[v.Type<string>, v.Type<null>]>;
    /**
     * This field is always set if the poke contains a `rowsPatch`.
     * It may be absent for patches that only update clients and queries.
     */
    schemaVersions: v.Optional<{
        minSupportedVersion: number;
        maxSupportedVersion: number;
    }>;
    timestamp: v.Optional<number>;
}, undefined>]>;
export declare const pokePartMessageSchema: v.TupleType<[v.Type<"pokePart">, v.ObjectType<{
    pokeID: v.Type<string>;
    lastMutationIDChanges: v.Optional<Record<string, number>>;
    desiredQueriesPatches: v.Optional<Record<string, ({
        ttl?: number | undefined;
        op: "put";
        hash: string;
    } | {
        op: "del";
        hash: string;
    } | {
        op: "clear";
    })[]>>;
    gotQueriesPatch: v.Optional<({
        ttl?: number | undefined;
        op: "put";
        hash: string;
    } | {
        op: "del";
        hash: string;
    } | {
        op: "clear";
    })[]>;
    rowsPatch: v.Optional<({
        op: "put";
        tableName: string;
        value: Readonly<Record<string, import("../../shared/src/json.ts").ReadonlyJSONValue | undefined>>;
    } | {
        merge?: import("../../shared/src/json.ts").ReadonlyJSONObject | undefined;
        constrain?: string[] | undefined;
        op: "update";
        tableName: string;
        id: Readonly<Record<string, string | number | boolean>>;
    } | {
        op: "del";
        tableName: string;
        id: Readonly<Record<string, string | number | boolean>>;
    } | {
        op: "clear";
    })[]>;
    mutationsPatch: v.Optional<({
        op: "put";
        mutation: {
            id: {
                id: number;
                clientID: string;
            };
            result: {
                details?: import("../../shared/src/json.ts").ReadonlyJSONValue | undefined;
                error: "app";
            } | {
                details?: import("../../shared/src/json.ts").ReadonlyJSONValue | undefined;
                error: "oooMutation" | "alreadyProcessed";
            } | {
                data?: import("../../shared/src/json.ts").ReadonlyJSONValue | undefined;
            };
        };
    } | {
        op: "del";
        id: {
            id: number;
            clientID: string;
        };
    })[]>;
}, undefined>]>;
export declare const pokeEndMessageSchema: v.TupleType<[v.Type<"pokeEnd">, v.ObjectType<{
    pokeID: v.Type<string>;
    cookie: v.Type<string>;
    cancel: v.Optional<boolean>;
}, undefined>]>;
export type PokeStartBody = v.Infer<typeof pokeStartBodySchema>;
export type PokePartBody = v.Infer<typeof pokePartBodySchema>;
export type PokeEndBody = v.Infer<typeof pokeEndBodySchema>;
export type PokeStartMessage = v.Infer<typeof pokeStartMessageSchema>;
export type PokePartMessage = v.Infer<typeof pokePartMessageSchema>;
export type PokeEndMessage = v.Infer<typeof pokeEndMessageSchema>;
//# sourceMappingURL=poke.d.ts.map