import { IModelDescriptor, IValueConverter } from './interfaces.js'; /** * The diff baseline for one model instance. * * `Columns` holds a *value copy* of every column at the moment the model was hydrated from * the database. `Relations` holds, per relation name, the primary keys of the members that * were present when that relation was populated. * * Both must be copies. If a snapshot aliases live state, a later mutation changes the * baseline as well, the diff is empty, and `save()` silently does nothing. */ export interface IModelSnapshot { Columns: Map; Relations: Map; } export declare function createSnapshot(): IModelSnapshot; /** * Marker held in a snapshot in place of a value the ORM cannot copy. * * A baseline that ALIASES a mutable object is the worst possible answer: the baseline * mutates along with the model, the diff comes out empty, and `save()` silently drops the * caller's edit. This marker is never equal to anything, so such a column is reported as * changed on every save — a redundant write instead of a lost one. A converter opts out of * the redundancy by implementing `snapshotValue` / `snapshotEquals`. */ export declare const UNCOPYABLE: unique symbol; /** One column-level difference between a model's baseline and its current values. */ export interface IModelChange { Column: string; OldValue: unknown; NewValue: unknown; } /** * The baseline value as a change record may carry it. `UNCOPYABLE` is an internal marker for a * value the snapshot could not copy; it must never leak out of the ORM, so it is reported as * `undefined` ( "no usable old value" ) while the column itself is still reported as changed. */ export declare function baselineValue(value: unknown): unknown; /** * Takes a value copy suitable for a diff baseline. * * Immutable values (primitives, luxon `DateTime`) are returned as-is. Everything the ORM can * put in a column and that can be mutated in place — `Buffer` (binary/UUID columns), `Date`, * plain arrays and plain objects (JSON columns) — is copied. * * A mutable instance of a class the ORM does not own cannot be copied safely: cloning it * could break its invariants. Such a value is replaced by {@link UNCOPYABLE} unless its * column's converter supplies a `snapshotValue` hook. * * @param value - the in-memory column value * @param converter - the column's converter, when it has one */ export declare function snapshotValue(value: unknown, converter?: IValueConverter | null): unknown; /** * Value equality for a diff. Deliberately stricter than `==`: `null` and `undefined` are * different (one is "explicitly cleared", the other "never set"), and `0`/`''`/`false` are * never equal to each other. * * @param a - baseline value * @param b - current value * @param converter - the column's converter, when it has one */ export declare function snapshotEquals(a: unknown, b: unknown, converter?: IValueConverter | null): boolean; /** * Builds a column snapshot straight from a raw database row, applying the same converters * hydration applies. Used by `save({ reload: true })`, which needs the *database's* current * values as the baseline without disturbing the user's in-memory edits. */ export declare function snapshotFromRow(descriptor: IModelDescriptor, row: Record): Map; //# sourceMappingURL=snapshot.d.ts.map