/** * Type-preserving deep clone for relation-cache snapshots (ADR-012). * * `#store` hands the consumed-`$attributes` snapshot to the prepare-middleware * pipeline, but `setRelated` has already handed the live related instance to the * caller. A shallow copy shares every nested object by reference, so a prepare * handler that mutates a nested value in place (`context.value.meta.secret = …`) * writes straight through into the live model the caller is holding. Deep-cloning * the snapshot before middleware runs makes the copy's depth the isolation * boundary, so no handler — however it mutates — can reach the live row. * * `structuredClone` is deliberately NOT used: it silently flattens a Luxon * `DateTime` into a method-less plain object (the `isLuxonDateTime` flag survives, * so it still passes `DateTime.isDateTime`), which then crashes `encodeCacheValue` * when it calls `dateTime.toMillis()`. This clone instead recurses the in-place * mutation vectors (plain objects, arrays, `Map`, `Set`, `Date`) and keeps the * encoder's immutable rich leaves (Luxon `DateTime`, typed arrays, `bigint`, and * any other class instance) by reference — those are never mutated in place and * are not safely structurally cloneable. * * @module */ /** * Deep-clones a consumed-`$attributes` snapshot so the prepare-middleware pipeline * can never mutate the live related instance the caller already holds (ADR-012). * * @param snapshot - The post-`consume` attribute snapshot to isolate. * @returns A deep copy safe to hand to user-supplied middleware. */ export declare const deepCloneSnapshot: (snapshot: Record) => Record;