/** * CRDT state types, merge logic, and build helpers. * per-collection CRDT mode: 'lww-map' | 'rga' | 'yjs' * * The encrypted envelope wraps the CRDT state (not the resolved snapshot). * Adapters only ever see ciphertext. `collection.get(id)` returns the * resolved snapshot; `collection.getRaw(id)` returns the full CRDT state. */ import type { CrdtState, LwwMapState, RgaState } from '../../kernel/types.js'; export type { CrdtMode, CrdtState, LwwMapState, RgaState, YjsState } from '../../kernel/types.js'; /** * Resolve a CRDT state into the end-user record snapshot. * * - `lww-map` → `Record` (field values extracted from registers) * - `rga` → `unknown[]` (non-tombstoned items in insertion order) * - `yjs` → `string` (base64 update blob; use @noy-db/yjs for a Y.Doc) */ export declare function resolveCrdtSnapshot(state: CrdtState): unknown; /** * Merge two CRDT states produced by concurrent writes. * Called by the collection-level conflict resolver registered with SyncEngine. * * For `yjs`: core cannot merge Yjs without importing the `yjs` package. * The caller must handle that case by falling back to the higher-`_v` envelope. */ export declare function mergeCrdtStates(a: CrdtState, b: CrdtState): CrdtState; /** * Build (or update) an lww-map state from a new record. * * All fields in the new record win at timestamp `now`. * Fields present in the existing state but absent from the new record * are preserved (they were written by another device). */ export declare function buildLwwMapState(record: Record, existing: LwwMapState | undefined, now: string): LwwMapState; /** * Build (or update) an RGA state from a new array. * * Existing items are matched to new elements by deep-equality of their `v`. * Unmatched existing items are tombstoned. New elements that have no existing * match get a fresh NID via `generateNid()`. */ export declare function buildRgaState(arr: unknown[], existing: RgaState | undefined, generateNid: () => string): RgaState;