import './assert_dev_env.js';
import type { Db } from '../db/db.js';
/**
 * CI detection — `CI=true` is set automatically by GitHub Actions, GitLab CI, etc.
 */
export declare const IS_CI: boolean;
/**
 * Factory interface for creating test database instances.
 */
export interface DbFactory {
    name: string;
    create: () => Promise<Db>;
    close: (db: Db) => Promise<void>;
    skip: boolean;
    skip_reason?: string;
}
/**
 * Reset a PGlite database to a clean state by dropping and recreating the public schema.
 *
 * Removes all tables, sequences, indexes, types, and functions.
 * The database instance remains usable after reset.
 *
 * @mutates db - drops the `public` schema and recreates it; all rows in all
 *   tables are gone after this returns.
 */
export declare const reset_pglite: (db: Db) => Promise<void>;
/**
 * Create a pglite (in-memory) database factory for tests.
 *
 * Always enabled — no external dependencies required.
 * Shares a single PGlite WASM instance across all factories in the same
 * vitest worker thread (one test file). Subsequent `create()` calls reset
 * the schema via `DROP SCHEMA public CASCADE` instead of paying the WASM
 * cold-start cost again.
 *
 * @param init_schema - callback to initialize the database schema
 */
export declare const create_pglite_factory: (init_schema: (db: Db) => Promise<void>) => DbFactory;
/**
 * Create a pg (PostgreSQL) database factory for tests.
 *
 * Skipped when `test_url` is not provided.
 * Drops `schema_version` before running `init_schema`, forcing migrations
 * to re-evaluate against the actual tables. Prevents stale tracker rows
 * from skipping migrations when DDL changes between test sessions.
 *
 * For full clean-slate behavior (recommended), call `drop_auth_schema(db)`
 * at the start of `init_schema` before running migrations. This handles
 * upstream schema changes that go beyond adding new tables/columns.
 *
 * @param init_schema - callback to initialize the database schema
 * @param test_url - PostgreSQL connection URL (e.g. from `TEST_DATABASE_URL`)
 * @returns a factory that creates pg databases. The returned `create()`
 *   throws when `test_url` is unset (despite the `skip: true` flag — defense
 *   against direct invocation), and rewrites Postgres "database does not
 *   exist" errors into a `createdb` hint message.
 */
export declare const create_pg_factory: (init_schema: (db: Db) => Promise<void>, test_url?: string) => DbFactory;
/**
 * Auth table names in truncation order (children first for FK safety).
 *
 * Consumer projects can spread this into their own list and append app-specific tables.
 */
export declare const auth_truncate_tables: string[];
/**
 * Auth tables including `audit_log` — for integration tests that exercise
 * the full middleware stack (login, admin, rate limiting).
 *
 * Separate from `auth_truncate_tables` because unit-level DB tests that don't
 * touch audit logging don't need to truncate it.
 */
export declare const auth_integration_truncate_tables: string[];
/**
 * All auth tables in drop order (children first for FK safety).
 *
 * The full set created by `auth_migrations` — use for clean-slate
 * test DB initialization. `auth_truncate_tables` is the subset for
 * between-test data cleanup (excludes `audit_log`).
 *
 * When adding tables to `auth_migrations`, add them here too.
 */
export declare const auth_drop_tables: readonly ["app_settings", "invite", "audit_log", "api_token", "auth_session", "role_grant", "role_grant_offer", "actor", "account", "bootstrap_lock"];
/**
 * Drop all auth tables and schema version tracking for a clean slate.
 *
 * Recommended at the start of `init_schema` callbacks for `create_pg_factory`.
 * Persistent test databases can accumulate stale schema from previous fuz_app
 * versions — this ensures migrations run against a truly empty database.
 * Safe on fresh databases (`IF EXISTS` on all statements). No-op effect for
 * PGlite (already fresh), but harmless to call unconditionally.
 *
 * @mutates db - drops every table in `auth_drop_tables` plus `schema_version`.
 */
export declare const drop_auth_schema: (db: Db) => Promise<void>;
/**
 * Create a `describe_db` function bound to specific factories and truncate tables.
 *
 * Returns a 2-arg `(name, fn)` function that runs the test suite against each
 * factory. Each factory gets its own `describe` block with a shared database
 * instance, automatic `beforeEach` truncation, and `afterAll` cleanup.
 * Skipped factories use `describe.skip`.
 *
 * @param factories - one or more database factories to run suites against
 * @param truncate_tables - tables to truncate between tests (children first for FK safety)
 * @mutates the underlying database between tests — `beforeEach` issues
 *   `TRUNCATE <truncate_tables> CASCADE` against the shared instance.
 */
export declare const create_describe_db: (factories: DbFactory | Array<DbFactory>, truncate_tables: Array<string>) => ((name: string, fn: (get_db: () => Db) => void) => void);
/**
 * Log factory status to console.
 */
export declare const log_db_factory_status: (factories: Array<DbFactory>) => void;
//# sourceMappingURL=db.d.ts.map