import type { Database as DatabaseType } from "better-sqlite3"; export type { DatabaseType }; /** * Returns the database for the current context: * 1. If inside a tenant-scoped AsyncLocalStorage context, returns the tenant DB. * 2. Otherwise returns (or lazily creates) the singleton DB for self-hosted / CLI use. */ export declare function getDb(): DatabaseType; /** * Sets the AsyncLocalStorage context so that all downstream `getDb()` calls * within the current async context return the given tenant's database. * Use in Fastify onRequest hooks via `enterWith`. */ export declare function enterTenantScope(slug: string): void; /** * Runs `fn` in an AsyncLocalStorage context scoped to the given tenant's DB. * All `getDb()` calls inside `fn` (sync or async) return the tenant DB. */ export declare function runWithTenantDb(slug: string, fn: () => T): T; /** * Closes the singleton database connection and clears the cached instance. * Useful for graceful shutdown and testing. */ export declare function closeDb(): void; /** Base directory for per-tenant database files. */ export declare function getDataDir(): string; /** * Returns a database connection for the given tenant slug. * Creates the file + runs migrations on first access (lazy provisioning). * Evicts the oldest connection if the pool exceeds MAX_TENANT_POOL_SIZE. */ export declare function getTenantDb(slug: string): DatabaseType; /** Closes and removes a single tenant connection from the pool. */ export declare function closeTenantDb(slug: string): void; /** Closes the singleton DB and every pooled tenant DB. */ export declare function closeAllDbs(): void; //# sourceMappingURL=connection.d.ts.map