import { createDb } from '../db/index.js'; import type { Environment } from '../env.js'; /** * Base repository class with connection management and common patterns * * Features: * - Connection pooling and caching for better performance * - Query performance monitoring with slow query detection * - Standardized error handling and logging * - Memory management utilities */ export declare abstract class BaseRepository { protected static dbCache: Map>; private static healthCheckCache; private static readonly HEALTH_CHECK_TTL; /** * Get database connection with caching for performance * Uses environment-specific cache keys to handle multiple databases */ protected getDb(env: Environment): import("drizzle-orm/d1").DrizzleD1Database> & { $client: any; }; /** * Execute query with error handling and performance monitoring * * @param env - Environment configuration * @param operation - Database operation to execute * @param operationName - Name for logging and monitoring * @returns Promise with operation result */ protected executeQuery(env: Environment, operation: (db: ReturnType) => Promise, operationName?: string): Promise; /** * Execute batch operations with transaction support * * @param env - Environment configuration * @param operations - Array of database operations * @param operationName - Name for logging * @returns Promise with all operation results */ protected executeBatch(env: Environment, operations: Array<(db: ReturnType) => Promise>, operationName?: string): Promise; /** * Execute query with retry logic for transient failures * * @param env - Environment configuration * @param operation - Database operation to execute * @param operationName - Name for logging * @param maxRetries - Maximum number of retries (default: 3) * @returns Promise with operation result */ protected executeQueryWithRetry(env: Environment, operation: (db: ReturnType) => Promise, operationName?: string, maxRetries?: number): Promise; /** * Determine if an error should not be retried */ private shouldNotRetry; /** * Check database connection health * Cached for 30 seconds to avoid excessive health checks */ protected checkDatabaseHealth(env: Environment): Promise; /** * Execute query with health check validation */ protected executeQueryWithHealthCheck(env: Environment, operation: (db: ReturnType) => Promise, operationName?: string): Promise; /** * Get database health status for monitoring endpoints */ getDatabaseHealthStatus(env: Environment): Promise<{ status: 'healthy' | 'unhealthy'; timestamp: string; responseTime?: number; }>; /** * Clear connection cache (useful for testing or memory management) * Uses standardized cache clearing from @g-1/util */ static clearDbCache(): void; /** * Get cache statistics for monitoring * Combines local db cache stats with global cache stats from @g-1/util */ protected getDbCacheStats(): { dbCache: { size: number; keys: string[]; }; globalCache: { size: number; hits: number; misses: number; }; }; } export declare function clearRepositoryCaches(): void; //# sourceMappingURL=base-repository.d.ts.map