/** * Reference translation for apply (T12344 PR-4; journal spec ยง3.2 "Missing * references", NEW-2, T12782). * * On the wire a reference column carries the target row's uid; in the store * it holds the target's LOCAL key. The applier translates both ways: * * - **Writing** ({@link resolveRef}): the uid becomes the target's local key. * A target the receiver knows only through `tasks_uid_aliases` (re-keyed or * re-minted) is followed to its current uid. A target with a tombstone is * `tombstoned` (the op becomes a `dangling-ref` conflict plus a revivable * void); a target never seen is `missing` (the transaction waits, pending). * - **Reading** ({@link uidOfKey}): the merge compares stream values, so the * row state it reads carries uids, not local keys. * * Read-only. * * @module store/sync/apply/refs * @task T12344 */ import type { DatabaseSync } from 'node:sqlite'; import type { LedgerWireValue } from '@cleocode/contracts/ledger'; /** Where a wire reference points on this replica. */ export type RefResolution = { readonly kind: 'row'; readonly uid: string; readonly key: LedgerWireValue; } | { readonly kind: 'tombstoned'; readonly uid: string; } | { readonly kind: 'missing'; readonly uid: string; }; /** * Resolve a wire reference (a target uid) to the target's local key. * * @param db - The store. * @param target - The referenced table and its local key column. * @param uid - The target uid on the wire. * @returns The row's key, or why there is none. */ export declare function resolveRef(db: DatabaseSync, target: { readonly table: string; readonly key: string; }, uid: string): RefResolution; /** * The uid of the row a local key references, or null when that row has no * uid (or is absent). * * @param db - The store. * @param target - The referenced table and its local key column. * @param key - The local key the reference column holds. * @returns The target's uid, or null. */ export declare function uidOfKey(db: DatabaseSync, target: { readonly table: string; readonly key: string; }, key: LedgerWireValue): string | null; //# sourceMappingURL=refs.d.ts.map