import type { Database as NativeDatabase, Transaction, Cell, RowJs } from '@visorcraft/mongreldb/native.js'; import type { Schema } from './schema.js'; import type { TableSpec, PkValue } from './types.js'; export interface ConstraintKit { db: MongrelDatabase; schema: Schema; } type MongrelDatabase = NativeDatabase & { transaction(fn: (txn: Transaction) => void | Promise, opts?: { maxRetries?: number; baseDelayMs?: number; }): Promise; }; /** True when some table in the schema has a foreign key referencing `tableName`. */ export declare function isReferencedTable(schema: Schema, tableName: string): boolean; export declare function toCells(table: TableSpec, row: Record): Cell[]; export declare function findByPk(db: NativeDatabase, table: TableSpec, pkValue: PkValue): RowJs | null; export declare function pkValueFromRow(table: TableSpec, row: Record): PkValue; export declare function pkValuesEqual(a: PkValue, b: PkValue): boolean; export declare function stageUniqueGuards(kit: ConstraintKit, txn: Transaction, table: TableSpec, row: Record, pkValue: PkValue): void; export declare function stagePkGuard(kit: ConstraintKit, txn: Transaction, table: TableSpec, pkValue: PkValue, pkExplicit: boolean, pkSeen?: Set): void; export declare function deletePkGuard(kit: ConstraintKit, txn: Transaction, table: TableSpec, pkValue: PkValue): void; export declare function deleteUniqueGuards(kit: ConstraintKit, txn: Transaction, table: TableSpec, pkValue: PkValue, onlyConstraints?: string[]): void; export declare function touchRowGuard(kit: ConstraintKit, txn: Transaction, tableName: string, pkValue: PkValue): void; export declare function deleteRowGuard(kit: ConstraintKit, txn: Transaction, tableName: string, pkValue: PkValue): void; export declare function parentExists(kit: ConstraintKit, tableName: string, pkValue: PkValue): boolean; export declare function enforceForeignKeys(kit: ConstraintKit, txn: Transaction, table: TableSpec, row: Record): void; export declare function planDelete(kit: ConstraintKit, txn: Transaction, table: TableSpec, pkValue: PkValue, known?: { row: Record; rowId: bigint; }): void; /** Delete every Kit guard row owned by `tableName` (used by `truncateTable`). */ export declare function deleteGuardsForTable(kit: ConstraintKit, txn: Transaction, tableName: string): void; export {}; //# sourceMappingURL=constraints.d.ts.map