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 extends unknown ? 0 : never]; export type TestingFacadeSeedData = (facade: TestingFacade) => Promise | void; export interface TestingFacadeOptions { defaultTestHeaders?: Record; seedData?: TestingFacadeSeedData; autoSeedData?: boolean; onBeforeStart?: (facade: TestingFacade) => Promise | void; onStart?: (facade: TestingFacade) => Promise | void; onBeforeStop?: (facade: TestingFacade) => Promise | void; onStop?: (facade: TestingFacade) => Promise | 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 extends Omit, 'enableDatabase' | 'rejectDatabaseAccess'> { excludeProviders?: readonly Token[]; providerOverrides?: readonly Provider[]; } export interface StandardHookOptions { suiteSeedData?: TestingFacadeSeedData; } export declare class TestingFacade { readonly app: App; readonly options: TestingFacadeOptions; 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, options?: TestingFacadeOptions, originalDatabaseEnv?: DatabaseEnvSnapshot); enableDatabaseAccessGuard(): void; start(): Promise; stop(): Promise; createDatabase(): Promise; destroyDatabase(): Promise; truncateTables(): Promise; request(request: HttpRequest): Promise; seed(): Promise; runMigrations(): Promise; resetToSeed(): Promise; createSeedSavepoint(name: string, seedData?: TestingFacadeSeedData): Promise; resetToSeedSavepoint(name: string): Promise; get(token: Parameters['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 = Omit, 'config'> & { config?: CreateAppOptions['config']; }; export type TestingFacadeFactory = (appOptions?: Partial>, options?: TestingFacadeOptions>) => TestingFacade; export type TestingFacadeAppOptionsSelection = Partial> & { imports: NonNullable['imports']>; exports: NonNullable['exports']>; providers: NonNullable['providers']>; controllers: NonNullable['controllers']>; listeners: NonNullable['listeners']>; commands: NonNullable['commands']>; }; export type TestingFacadeAppOptionsResolver = (appOptions: TestingFacadeAppOptionsSelection) => TestingAppOptions; export type TestingFacadeOptionsResolver = (options: TestingFacadeOptions>) => TestingFacadeOptions>; export type TestingFacadeAppOptionsSource = TestingAppOptions | TestingFacadeAppOptionsResolver; export type TestingFacadeOptionsSource = TestingFacadeOptions> | TestingFacadeOptionsResolver>; export declare function createTestingFacade(appOptions: TestingAppOptions, options?: TestingFacadeOptions>): TestingFacade; export declare function createTestingFacadeWithDatabase(appOptions: TestingAppOptions, options?: Omit>, 'enableDatabase'>): TestingFacade; export declare function createUnitTestingFacade(appOptions: TestingAppOptions, options?: UnitTestingFacadeOptions>): TestingFacade; export declare function createTestingFacadeBuilder(defaultAppOptions: TestingFacadeAppOptionsSource, defaultOptions?: TestingFacadeOptionsSource>): TestingFacadeFactory; export type MockMethod = 'GET' | 'PUT' | 'POST' | 'PATCH' | 'DELETE'; type BodylessMockMethod = 'GET'; type BodyMockMethod = Exclude; export type MockHeaders = Record; export type MockBody = unknown; export declare function makeMockRequest(tf: TestingFacade, method: BodylessMockMethod, url: string, headers?: MockHeaders): Promise; export declare function makeMockRequest(tf: TestingFacade, method: BodyMockMethod, url: string, body: MockBody): Promise; export declare function makeMockRequest(tf: TestingFacade, method: BodyMockMethod, url: string, headers: MockHeaders, body: MockBody): Promise; export declare function makeMockRequest(tf: TestingFacade, method: MockMethod, url: string, headers: MockHeaders, body: MockBody): Promise; export declare function installStandardHooks(tf: TestingFacade, options?: StandardHookOptions): void; export declare function resetSrcModuleCache(): void; export declare function setDefaultDatabaseConfig(config: Record): void; export declare function cleanupTestDatabases(prefix?: string, adapter?: TestDbAdapter): Promise; 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>; //# sourceMappingURL=index.d.ts.map