import { Knex } from 'knex'; declare const isDeadlockError: (error: unknown) => boolean; declare const waitForDeadlockRetry: (attempt: number) => Promise; export type Callback = (...args: any[]) => Promise | any; export interface TransactionObject { commit: () => Promise; rollback: () => Promise; get: () => Knex.Transaction; } export interface Store { trx: Knex.Transaction | null; commitCallbacks: Callback[]; rollbackCallbacks: Callback[]; /** Database that opened the transaction. Its `destroy()` waits for these hooks. */ owner: object; } /** * How long `Database.destroy` waits for commit and rollback hooks. A hook * still running after this stays running, and the pool closes. There is no * setting for it: a stuck hook must not hold process exit. */ declare const HOOK_DRAIN_TIMEOUT_MS = 10000; declare const transactionCtx: { run(trx: Knex.Transaction, cb: TCallback, owner?: object): ReturnType; get(): Knex.Transaction | null | undefined; commit(trx: Knex.Transaction, reportCommitHookError?: (error: unknown) => void): Promise; rollback(trx: Knex.Transaction, reportRollbackHookError?: (error: unknown) => void): Promise; /** * Wait for commit and rollback hooks of one database, including hooks those * hooks start. Returns false when hooks are still running at the deadline. * `Database.destroy` calls this before closing that database's pool. */ settleHooks: (owner?: object, timeoutMs?: number) => Promise; onCommit(cb: Callback): void; onRollback(cb: Callback): void; /** * Runs `cb` in a savepoint of the current transaction, with its own commit and rollback * callbacks. Once `cb` resolves, the savepoint is released and its callbacks wait for the * outer transaction. If `cb` throws, only its writes are rolled back, its commit callbacks * are dropped, its rollback callbacks run, and the error is rethrown. If the database rejects * the release or the rollback (e.g. MySQL already rolled back the whole transaction), it throws * a `SavepointError`, after running the rollback callbacks: the transaction must fail with it. */ savepoint(cb: () => Promise | T): Promise; }; export { HOOK_DRAIN_TIMEOUT_MS, isDeadlockError, transactionCtx, waitForDeadlockRetry }; //# sourceMappingURL=transaction-context.d.ts.map