import type { EntityManager, EntityTarget, SelectQueryBuilder } from 'typeorm'; /** * **Can this database hold a row for us while we decide?** — `SELECT … FOR UPDATE` where it exists. * * True only inside an open transaction on a driver that has row locks. sqlite has none, and TypeORM throws * `LockNotSupportedOnGivenDriverError` if asked; it does not need one, because a single writer makes a second * writing transaction wait for the first as a whole. Every other driver this platform runs on (postgres, * mysql, mssql, oracle) takes the lock. * * Outside a transaction a lock would be released as soon as the statement ends, so it is not asked for. * * ```ts * repository.findOne({ where, ...(writeLockSupported(tx) ? { lock: { mode: 'pessimistic_write' } } : {}) }) * ``` */ export declare function writeLockSupported(manager: Pick): boolean; /** * **A write lock on the rows of one table only** - the find option every locking read takes. * * A plain `FOR UPDATE` locks every row the query reads: a read filtered by its domain joins the domain row, so every * locking read in a site waited on every other (the warehouse, 2026-10-23), and every insert in the domain holds a * key-share lock on that row for its foreign key, so two writers deadlocked (`40P01`, warehouse `fb055e0d`). A read * that loads a revision with its lines LEFT JOINs them - postgres refuses `FOR UPDATE` on the nullable side of an outer * join (`0A000`, ops-master's recipe publish). Postgres names the table to lock (`FOR UPDATE OF`); the other drivers that * lock are left as they were. * * The name is `tableNameWithoutPrefix` - what TypeORM matches `lock.tables` against; the prefixed `tableName` throws * `"…" is not part of this query` wherever an entity prefix is configured. Moved here from ops-master on 2026-11-18, * where it was right, so the products' copies (warehouse, yard - which used `tableName`) could go. * * ```ts * repository.findOne({ where, ...writeLockOn(tx, Stock) }) * ``` */ export declare function writeLockOn(manager: EntityManager, entity: EntityTarget): { lock?: undefined; } | { lock: { tables?: string[]; mode: "pessimistic_write"; }; }; /** The same lock on a query builder's own alias - `setLock` takes the alias as written into the SQL. */ export declare function lockRowsOf(manager: EntityManager, query: SelectQueryBuilder): SelectQueryBuilder;