import { Querier, Dialect } from './index.js';
import 'drizzle-orm/pg-core';
import 'drizzle-orm';

/**
 * Execute fn under an advisory lock.
 * - Postgres: acquires pg_advisory_xact_lock(key) within the transaction
 * - SQLite: passthrough (single-writer serializes at write-lock grain)
 *
 * BEHAVIORAL NOTE: PG blocks concurrent callers per-key; SQLite serializes
 * at coarser grain (the write lock). Callers needing fine-grained fairness
 * must know SQLite has different timing characteristics.
 */
declare function withAdvisoryLock<T>(db: Querier<any>, key: bigint, fn: () => Promise<T>, dialect: Dialect): Promise<T>;

export { withAdvisoryLock };
