/** * Modular update-patch pipeline for Kit mutations. * * Every product update (`updateTable.set`, `onConflictDoUpdate`, …) runs: * * 1. {@link sanitizeUpdatePatch} — normalize caller intent * 2. {@link mergeUpdateOntoRow} — apply onto the stored row * 3. {@link applyUpdateTimestampDefaults} — refresh `generated: 'now'` when not patched * 4. write phase (delete + put + guards) — remains in the query/txn layer * * Pure steps are exported so unit tests and future bindings share one policy * without re-implementing merge rules inside transaction helpers. */ import type { TableSpec } from './types.js'; import type { DefaultContext } from './defaults.js'; /** Policy knobs for {@link sanitizeUpdatePatch}. Defaults match product semantics. */ export interface UpdatePatchPolicy { /** * When true (default), keys whose value is `undefined` are dropped from the * patch (**omit**). Callers must pass explicit `null` to write SQL NULL. * * When false, `undefined` is left in the object for a custom merge step * (not used by the product path). */ undefinedMeansOmit?: boolean; } export declare const DEFAULT_UPDATE_PATCH_POLICY: Readonly>; /** * Stage 1 — sanitize: drop non-intent keys so merge cannot mis-interpret them. * * Product rule: **`undefined` means omit** (safe for sparse objects and * accidental `{ ...row, field: maybeUndefined }` spreads). Explicit `null` * is preserved so callers can clear nullable columns. */ export declare function sanitizeUpdatePatch(patch: Record, policy?: UpdatePatchPolicy): Record; /** * Stage 2 — merge a **sanitized** patch onto the on-disk row. * * Keys present in `sanitizedPatch` overwrite (including `null` → SQL NULL later). * Keys absent leave the stored value alone. */ export declare function mergeUpdateOntoRow(existingRow: Record, sanitizedPatch: Record): Record; /** * Stage 3 — refresh write-managed timestamps that the caller did not patch. * * Only `generated: 'now'` columns refresh on update. Plain `default: nowDefault()` * is insert-time only and is not touched here. */ export declare function applyUpdateTimestampDefaults(table: TableSpec, merged: Record, sanitizedPatch: Record, ctx: DefaultContext): void; /** * Full pure pipeline through merge (no I/O): sanitize → merge → timestamp defaults. * The live write path uses this then validate + delete + put. */ export declare function prepareMergedUpdateRow(table: TableSpec, existingRow: Record, patch: Record, ctx: DefaultContext, policy?: UpdatePatchPolicy): { sanitizedPatch: Record; merged: Record; }; /** * Column names whose values differ between existing and merged rows. * Useful for future index-delta maintenance and guard narrowing. */ export declare function changedUpdateColumns(existingRow: Record, merged: Record, columnNames: readonly string[]): string[]; /** * True when the sanitized patch mentions any foreign-key column of `table`. */ export declare function patchTouchesForeignKeys(table: TableSpec, sanitizedPatch: Record): boolean; //# sourceMappingURL=updatePatch.d.ts.map