import { b as AbstractBaseAdapter, c as AuthAdapter, U as UserRole, d as AuthUser, S as Session, a as AuditLogFilter, A as AuditLog } from './base-C6bzgEN1.cjs'; import { F as FindArgs, b as FindResult, c as FindByIDArgs, d as CreateArgs, U as UpdateArgs, D as DeleteArgs, e as FindOneArgs, f as FindVersionsArgs, V as VersionRecord, g as CreateVersionArgs } from './types-BQnOYvym.cjs'; type DatabaseType = 'postgres' | 'sqlite' | 'mongodb'; interface DatabaseConnectionOptions { type: DatabaseType; host?: string; port?: number; database?: string; user?: string; password?: string; url?: string; ssl?: boolean | Record; maxConnections?: number; connectionTimeout?: number; } interface DrizzleAdapterOptions { type?: 'postgres' | 'sqlite'; client?: any; schema?: any; connectionString?: string; connectionOptions?: DatabaseConnectionOptions; } interface MongoDBAdapterOptions { type?: 'mongodb'; client?: any; database?: string; connectionString?: string; connectionOptions?: DatabaseConnectionOptions; /** * Maximum number of connections in the connection pool. * Defaults to 10 (or process.env.MONGODB_MAX_POOL_SIZE). * Note: Default MongoDB driver setting is 100, which can easily overwhelm * MongoDB Atlas free/shared tiers (e.g. M0 limit is 500 connections cluster-wide). */ maxPoolSize?: number; /** * Minimum number of connections in the connection pool. * Defaults to 1 (or process.env.MONGODB_MIN_POOL_SIZE). */ minPoolSize?: number; /** * Maximum number of milliseconds that a connection can remain idle in the pool before being removed. * Defaults to 30000 (30 seconds). */ maxIdleTimeMS?: number; /** * How long the MongoDB driver will attempt to select a server before timing out. * Defaults to 5000 (5 seconds). */ serverSelectionTimeoutMS?: number; /** * How long a connection attempt can take before timing out. * Defaults to 10000 (10 seconds). */ connectTimeoutMS?: number; /** * How long a send or receive on a socket can take before timing out. */ socketTimeoutMS?: number; /** * Additional raw MongoClientOptions passed directly to MongoClient. */ clientOptions?: Record; /** * Whether to disable global client caching across HMR / module reloads in development. * Defaults to false (caching enabled). */ disableGlobalClientCache?: boolean; } type AdapterOptions = DrizzleAdapterOptions | MongoDBAdapterOptions; declare class MongoDBAdapter extends AbstractBaseAdapter { dialect: "mongodb"; client: any; db: any; private database; private connectionString?; private options; constructor(options: MongoDBAdapterOptions); /** * Resolves the default connection pool options for MongoDB to prevent * connection pool exhaustion in serverless / Astro / Next.js environments. */ private getPoolOptions; connect(): Promise; disconnect(options?: { force?: boolean; }): Promise; /** * Helper to retrieve or initialize a singleton MongoDB Db instance. */ static getDb(options?: MongoDBAdapterOptions | string): Promise; /** * Helper to retrieve or initialize a singleton MongoClient instance. */ static getClient(options?: MongoDBAdapterOptions | string): Promise; private getMongoCollection; find(args: FindArgs): Promise>; private buildIdFilter; findByID(args: FindByIDArgs): Promise; create(args: CreateArgs): Promise; update(args: UpdateArgs): Promise; delete(args: DeleteArgs): Promise; count(args: { collection: string; where?: Record; tenantId?: string; }): Promise; findOne(args: FindOneArgs): Promise; findVersions(args: FindVersionsArgs): Promise>; findVersionByID(args: { collection: string; versionId: string; tenantId?: string; }): Promise; createVersion>(args: CreateVersionArgs): Promise>; updateLatestVersion>(args: CreateVersionArgs): Promise>; deleteVersions(args: { collection: string; documentId: string; keepLatest?: number; tenantId?: string; }): Promise; migrate?(): Promise; private getCollectionConfig; private buildFilter; private buildProjection; private processResult; private generateId; } declare function createMongoDBAdapter(options: MongoDBAdapterOptions): MongoDBAdapter; /** * Global helper to access or initialize a pooled MongoDB Db singleton instance. */ declare function getMongoDb(options?: MongoDBAdapterOptions | string): Promise; /** * Global helper to access or initialize a pooled MongoClient singleton instance. */ declare function getMongoClient(options?: MongoDBAdapterOptions | string): Promise; interface MongoDBAuthAdapterOptions { db?: any | (() => any); adapter?: any; client?: any; collectionPrefix?: string; sessionTTL?: number; refreshTokenTTL?: number; } declare class MongoDBAuthAdapter implements AuthAdapter { private db; private adapter; private client; private prefix; private sessionTTL; private refreshTokenTTL; private indexesEnsured; constructor(options: MongoDBAuthAdapterOptions); private getDatabase; private col; connect(): Promise; disconnect(): Promise; private ensureIndexes; createUser(data: { email: string; password: string; name?: string; role?: UserRole; avatar?: string; tenantId?: string; }): Promise; findUserByEmail(email: string): Promise; findUserById(id: string): Promise; updateUser(id: string, data: Partial): Promise; deleteUser(id: string): Promise; verifyPassword(email: string, password: string): Promise; hashPassword(password: string): Promise; createSession(userId: string, data?: { ipAddress?: string; userAgent?: string; }): Promise; findSessionByToken(token: string): Promise; findSessionByRefreshToken(refreshToken: string): Promise; deleteSession(sessionId: string): Promise; deleteUserSessions(userId: string): Promise; hasAnyUsers(): Promise; addPasswordToHistory(userId: string, passwordHash: string): Promise; getPasswordHistory(userId: string, count?: number): Promise; isPasswordInHistory(password: string, userId: string, historyCount?: number): Promise; findAuditLogs(filter: AuditLogFilter): Promise<{ logs: AuditLog[]; total: number; }>; createAuditLog(data: Omit): Promise; private docToAuthUser; private docToSession; createEmailVerificationToken(userId: string): Promise<{ token: string; expiresAt: Date; }>; verifyEmailToken(token: string): Promise<{ success: boolean; userId?: string; error?: string; }>; createPasswordResetToken(email: string): Promise<{ token: string; expiresAt: Date; error?: string; }>; resetPasswordWithToken(token: string, newPassword: string): Promise<{ success: boolean; error?: string; }>; } export { type AdapterOptions as A, type DatabaseConnectionOptions as D, MongoDBAdapter as M, type DatabaseType as a, type DrizzleAdapterOptions as b, type MongoDBAdapterOptions as c, MongoDBAuthAdapter as d, createMongoDBAdapter as e, getMongoDb as f, getMongoClient as g };