import { ByteReader, ByteWriter } from './bytes.js'; export type ColumnType = 'string' | 'integer' | 'float' | 'boolean' | 'json' | 'bytes' | 'blob_ref' | 'crdt'; export interface RowColumn { readonly name: string; readonly type: ColumnType; readonly nullable: boolean; /** * For a `crdt` column (§2.4 tag 8, §5.10.1): the named merger the server * selects (this rung defines exactly `'yjs-doc'`). Schema-IR metadata * ONLY — never on the wire (the SSG2 column table carries name/type/ * nullable, and `crdt` shares the `bytes` tag). Ignored for other types. */ readonly crdtType?: string; /** * §5.11: this column is encrypted end-to-end. When set, `type` is `bytes` * (the wire/stored type — the ciphertext envelope rides the bytes machinery) * and `declaredType` is the pre-flip app type. Both are schema-IR metadata, * never on the wire (like `crdtType`). The row codec ignores these — it * only ever sees a `bytes` value; encryption/decryption is the client * encode/apply seam (§5.11). */ readonly encrypted?: boolean; /** §5.11: the app-side type of an encrypted column (its type before the * wire flip to `bytes`). Present iff `encrypted` is set. */ readonly declaredType?: ColumnType; } /** * `integer` is `i64` within the ±(2^53−1) contract; `json` is the raw JSON * document string, preserved byte-for-byte on round-trip. */ export type RowValue = string | number | boolean | Uint8Array | null; export declare function columnTypeTag(type: ColumnType): number; export declare function columnTypeFromTag(tag: number): ColumnType; /** * A sparse-row slot (RFC §6.1): `undefined` when the column is absent from * the payload (an apply leaves the stored value untouched), `null` when the * column is present and NULL. */ export type SparseRowValue = RowValue | undefined; /** * Encode one standalone sparse row (RFC §6.1, SPEC.md §2.4). * * `primaryKeyIndex` is the row's primary-key column; a payload without it is * encoder misuse and throws, like a NULL in a non-nullable column. */ export declare function encodeSparseRow(columns: readonly RowColumn[], primaryKeyIndex: number, values: readonly SparseRowValue[]): Uint8Array; /** * Decode one standalone sparse row; the bytes must contain exactly one row. * * Decode checks, in order (each a decode error, RFC §6.1): a set presence * padding bit, an absent primary-key column, a set null-bitmap padding bit * (a null for an absent column), a null bit for a non-nullable column. */ export declare function decodeSparseRow(columns: readonly RowColumn[], primaryKeyIndex: number, bytes: Uint8Array): SparseRowValue[]; export declare function writeRow(writer: ByteWriter, columns: readonly RowColumn[], values: readonly RowValue[]): void; export declare function readRow(reader: ByteReader, columns: readonly RowColumn[]): RowValue[]; /** Encode one standalone row (e.g. a push payload or conflict serverRow). */ export declare function encodeRow(columns: readonly RowColumn[], values: readonly RowValue[]): Uint8Array; /** Decode one standalone row; the bytes must contain exactly one row. */ export declare function decodeRow(columns: readonly RowColumn[], bytes: Uint8Array): RowValue[];