import { type DbExec } from "../db/client.js"; export declare const collabDocsStore: import("../db/store-registry.js").Store; export declare function ensureTable(): Promise; export interface YDocStateRecord { state: Uint8Array; version: number; } export declare function loadYDocRecord(docId: string): Promise; export declare function loadYDocRecordWithClient(client: DbExec, docId: string): Promise; export type CollabStateMalformedReason = "base64" | "version" | "yjs"; /** A stored `_collab_docs` row that cannot be read. Never treat it as empty. */ export declare class CollabStateMalformedError extends Error { readonly code = "collab_state_malformed"; readonly docId: string; readonly reason: CollabStateMalformedReason; constructor(docId: string, reason: CollabStateMalformedReason, message: string, options?: { cause?: unknown; }); } /** * Absent means no row. A row whose `yjs_state` is `''` is present with a * zero-byte state; callers that seed must update it at its version rather * than insert. */ export type StrictYDocRecord = { kind: "absent"; } | { kind: "present"; state: Uint8Array; version: number; } /** Longer than `maxBytes` allows; its text was never read. */ | { kind: "too_large"; bytes: number; }; /** * Decodes canonical base64, or returns null; `Buffer` silently skips junk. * A round trip instead of a pattern: a repeated-group regex overflows the * stack on a few megabytes. */ export declare function strictBase64ToUint8Array(value: string): Uint8Array | null; export declare function loadYDocRecordStrict(client: DbExec, docId: string, maxBytes: number, options?: { forUpdate?: boolean; }): Promise; export declare function loadYDocVersion(docId: string): Promise; /** * A row's version and a SHA-256 of its stored text. A version alone repeats: * a row deleted and inserted again starts back at 0. */ export interface YDocStamp { version: number; digest: string; } export declare function loadYDocStamp(docId: string): Promise; export declare function loadYDocStampWithClient(client: DbExec, docId: string, options?: { forShare?: boolean; }): Promise; /** The digest `loadYDocStamp` reports for a row this module wrote `state` to. */ export declare function collabStateDigest(state: Uint8Array): Promise; export declare function loadYDocState(docId: string): Promise; export declare function trySaveYDocState(docId: string, state: Uint8Array, textSnapshot: string, expectedVersion: number | null): Promise; export declare function trySaveYDocStateWithClient(client: DbExec, docId: string, state: Uint8Array, textSnapshot: string, expectedVersion: number | null, /** Also requires the stored text to have this digest; see `YDocStamp`. */ expectedDigest?: string): Promise; export declare function saveYDocState(docId: string, state: Uint8Array, textSnapshot: string): Promise; export declare function hasCollabState(docId: string): Promise; export declare function deleteCollabState(docId: string): Promise; declare function uint8ArrayToBase64(arr: Uint8Array): string; declare function base64ToUint8Array(b64: string): Uint8Array; export { uint8ArrayToBase64, base64ToUint8Array };