import { App, BaseAppConfig, type CreateAppOptions } from '../app';
import { type Provider, type Token } from '../di';
import { type CreateMigrationPlanOptions, type DatabaseDialect, type Migration, type MigrationExecution } from '../database';
import { HttpRequest, MemoryHttpResponse } from '../http';
import { defineEntityFixtures, loadEntityFixtures, prepareEntityFixtures } from './fixtures';
import { SqlTestingHelper } from './sql';
export * from './expect';
export * from './fixtures';
export * from './sql';
export type TestDbAdapter = DatabaseDialect;
type NoInferConfig<C> = [C][C extends unknown ? 0 : never];
export type TestingFacadeSeedData<C extends BaseAppConfig = any> = (facade: TestingFacade<C>) => Promise<void> | void;
export interface TestingFacadeOptions<C extends BaseAppConfig = any> {
    defaultTestHeaders?: Record<string, string>;
    seedData?: TestingFacadeSeedData<C>;
    autoSeedData?: boolean;
    onBeforeStart?: (facade: TestingFacade<C>) => Promise<void> | void;
    onStart?: (facade: TestingFacade<C>) => Promise<void> | void;
    onBeforeStop?: (facade: TestingFacade<C>) => Promise<void> | void;
    onStop?: (facade: TestingFacade<C>) => Promise<void> | void;
    enableDatabase?: boolean;
    rejectDatabaseAccess?: boolean;
    dbAdapter?: TestDbAdapter;
    useSavepoints?: boolean;
    databasePrefix?: string;
    keepDatabase?: boolean;
    enableMigrations?: boolean;
    schemaFromEntities?: boolean | CreateMigrationPlanOptions;
    migrations?: readonly Migration[];
    migrationsDir?: string | readonly string[];
    truncateAfterMigrations?: boolean;
}
export interface UnitTestingFacadeOptions<C extends BaseAppConfig = BaseAppConfig> extends Omit<TestingFacadeOptions<C>, 'enableDatabase' | 'rejectDatabaseAccess'> {
    excludeProviders?: readonly Token[];
    providerOverrides?: readonly Provider[];
}
export interface StandardHookOptions<C extends BaseAppConfig = any> {
    suiteSeedData?: TestingFacadeSeedData<C>;
}
export declare class TestingFacade<C extends BaseAppConfig = any> {
    readonly app: App<any>;
    readonly options: TestingFacadeOptions<any>;
    databaseName?: string;
    readonly dbAdapter?: TestDbAdapter;
    readonly migrationExecutions: MigrationExecution[];
    readonly sql: SqlTestingHelper;
    savepointIsolationActive: boolean;
    private readonly originalDatabaseEnv?;
    private readonly originalAppDatabaseConfig;
    private savepointConnection?;
    private savepointCleanup?;
    private savepointIsolationLocksReady;
    private sharedDatabaseState?;
    private sharedMySQLSessionKey?;
    private sharedMySQLSessionLeaseId?;
    private databaseCreated;
    private databaseAccessGuardEnabled;
    private databaseAccessGuardCleanup?;
    private readonly logger;
    constructor(app: App<any>, options?: TestingFacadeOptions<any>, originalDatabaseEnv?: DatabaseEnvSnapshot);
    enableDatabaseAccessGuard(): void;
    start(): Promise<void>;
    stop(): Promise<void>;
    createDatabase(): Promise<void>;
    destroyDatabase(): Promise<void>;
    truncateTables(): Promise<void>;
    request(request: HttpRequest): Promise<MemoryHttpResponse>;
    seed(): Promise<void>;
    runMigrations(): Promise<MigrationExecution[]>;
    resetToSeed(): Promise<void>;
    createSeedSavepoint(name: string, seedData?: TestingFacadeSeedData<C>): Promise<boolean>;
    resetToSeedSavepoint(name: string): Promise<boolean>;
    get<T>(token: Parameters<App<C>['get']>[0]): T;
    private cleanupDatabase;
    private prepareDatabaseSchema;
    private prepareManagedSharedMySQLSchema;
    private closeDatabaseProvider;
    private installDatabaseAccessGuard;
    private restoreDatabaseAccessGuard;
    private createAdminDatabase;
    private dropDatabase;
    private createSharedDatabase;
    private createManagedSharedMySQLDatabase;
    private initializeSharedDatabase;
    private releaseSharedDatabase;
    private applyDatabaseConfig;
    private restoreDatabaseConfig;
    private requireDbAdapter;
    private shouldRunMigrations;
    private shouldCreateSchemaFromEntities;
    private shouldPrepareDatabaseSchema;
    private createSchemaFromEntities;
    private shouldTruncateAfterMigrations;
    private shouldPrepareWorkerJobsTable;
    private prepareInternalMigrationTables;
    private prepareWorkerJobsTableForDatabase;
    private loadTestingMigrations;
    private getMigrationDirectories;
    private get shouldUseSavepoints();
    private getSharedDatabaseKey;
    private getDatabaseProvider;
    private initSavepointIsolation;
    private teardownSavepointIsolation;
    private ensureSavepointIsolationLocksReady;
}
type TestingAppOptions<C extends BaseAppConfig> = Omit<CreateAppOptions<C>, 'config'> & {
    config?: CreateAppOptions<C>['config'];
};
export type TestingFacadeFactory<C extends BaseAppConfig = BaseAppConfig> = (appOptions?: Partial<TestingAppOptions<C>>, options?: TestingFacadeOptions<NoInferConfig<C>>) => TestingFacade<C>;
export type TestingFacadeAppOptionsSelection<C extends BaseAppConfig = any> = Partial<TestingAppOptions<C>> & {
    imports: NonNullable<TestingAppOptions<C>['imports']>;
    exports: NonNullable<TestingAppOptions<C>['exports']>;
    providers: NonNullable<TestingAppOptions<C>['providers']>;
    controllers: NonNullable<TestingAppOptions<C>['controllers']>;
    listeners: NonNullable<TestingAppOptions<C>['listeners']>;
    commands: NonNullable<TestingAppOptions<C>['commands']>;
};
export type TestingFacadeAppOptionsResolver<C extends BaseAppConfig = any> = (appOptions: TestingFacadeAppOptionsSelection<C>) => TestingAppOptions<C>;
export type TestingFacadeOptionsResolver<C extends BaseAppConfig = any> = (options: TestingFacadeOptions<NoInferConfig<C>>) => TestingFacadeOptions<NoInferConfig<C>>;
export type TestingFacadeAppOptionsSource<C extends BaseAppConfig = any> = TestingAppOptions<C> | TestingFacadeAppOptionsResolver<C>;
export type TestingFacadeOptionsSource<C extends BaseAppConfig = any> = TestingFacadeOptions<NoInferConfig<C>> | TestingFacadeOptionsResolver<NoInferConfig<C>>;
export declare function createTestingFacade<C extends BaseAppConfig = BaseAppConfig>(appOptions: TestingAppOptions<C>, options?: TestingFacadeOptions<NoInferConfig<C>>): TestingFacade<C>;
export declare function createTestingFacadeWithDatabase<C extends BaseAppConfig = BaseAppConfig>(appOptions: TestingAppOptions<C>, options?: Omit<TestingFacadeOptions<NoInferConfig<C>>, 'enableDatabase'>): TestingFacade<C>;
export declare function createUnitTestingFacade<C extends BaseAppConfig = BaseAppConfig>(appOptions: TestingAppOptions<C>, options?: UnitTestingFacadeOptions<NoInferConfig<C>>): TestingFacade<C>;
export declare function createTestingFacadeBuilder<C extends BaseAppConfig = any>(defaultAppOptions: TestingFacadeAppOptionsSource<C>, defaultOptions?: TestingFacadeOptionsSource<NoInferConfig<C>>): TestingFacadeFactory<C>;
export type MockMethod = 'GET' | 'PUT' | 'POST' | 'PATCH' | 'DELETE';
type BodylessMockMethod = 'GET';
type BodyMockMethod = Exclude<MockMethod, BodylessMockMethod>;
export type MockHeaders = Record<string, unknown>;
export type MockBody = unknown;
export declare function makeMockRequest(tf: TestingFacade, method: BodylessMockMethod, url: string, headers?: MockHeaders): Promise<MemoryHttpResponse>;
export declare function makeMockRequest(tf: TestingFacade, method: BodyMockMethod, url: string, body: MockBody): Promise<MemoryHttpResponse>;
export declare function makeMockRequest(tf: TestingFacade, method: BodyMockMethod, url: string, headers: MockHeaders, body: MockBody): Promise<MemoryHttpResponse>;
export declare function makeMockRequest(tf: TestingFacade, method: MockMethod, url: string, headers: MockHeaders, body: MockBody): Promise<MemoryHttpResponse>;
export declare function installStandardHooks<C extends BaseAppConfig = BaseAppConfig>(tf: TestingFacade<C>, options?: StandardHookOptions<C>): void;
export declare function resetSrcModuleCache(): void;
export declare function setDefaultDatabaseConfig(config: Record<string, string | number | boolean | undefined>): void;
export declare function cleanupTestDatabases(prefix?: string, adapter?: TestDbAdapter): Promise<void>;
export declare const TestingHelpers: {
    cleanupTestDatabases: typeof cleanupTestDatabases;
    createTestingFacade: typeof createTestingFacade;
    createTestingFacadeBuilder: typeof createTestingFacadeBuilder;
    createTestingFacadeWithDatabase: typeof createTestingFacadeWithDatabase;
    createUnitTestingFacade: typeof createUnitTestingFacade;
    defineEntityFixtures: typeof defineEntityFixtures;
    installStandardHooks: typeof installStandardHooks;
    loadEntityFixtures: typeof loadEntityFixtures;
    makeMockRequest: typeof makeMockRequest;
    prepareEntityFixtures: typeof prepareEntityFixtures;
    resetSrcModuleCache: typeof resetSrcModuleCache;
    SqlTestingHelper: typeof SqlTestingHelper;
    setDefaultDatabaseConfig: typeof setDefaultDatabaseConfig;
};
declare const DATABASE_ENV_KEYS: readonly ['DB_ADAPTER', 'MYSQL_HOST', 'MYSQL_PORT', 'MYSQL_USER', 'MYSQL_PASSWORD_SECRET', 'MYSQL_DATABASE', 'MYSQL_CONNECTION_LIMIT', 'MYSQL_MIN_IDLE_CONNECTIONS', 'MYSQL_IDLE_TIMEOUT_SECONDS', 'PG_HOST', 'PG_PORT', 'PG_USER', 'PG_PASSWORD_SECRET', 'PG_DATABASE', 'PG_SCHEMA', 'PG_SSL', 'PG_SSL_REJECT_UNAUTHORIZED', 'PG_CONNECTION_LIMIT', 'PG_IDLE_TIMEOUT_SECONDS', 'TSF_TEST_DATABASE_NAME', 'TSF_TEST_ALLOW_SAVEPOINTS', 'TSF_TEST_MYSQL_SESSION_KEY', 'TSF_TEST_MYSQL_SESSION_LEASE_ID', 'TSF_TEST_MYSQL_SESSION_DATABASE'];
type DatabaseEnvSnapshot = Partial<Record<(typeof DATABASE_ENV_KEYS)[number], string>>;
//# sourceMappingURL=index.d.ts.map