export interface IUrl {
  urlId: string;
  originalUrl: string;
  shortUrl: string;
  clicks: number;
  createdAt: Date;
  expiresAt?: Date;
}

export interface IDatabaseAdapter {
  connect(): Promise<boolean>;
  disconnect(): Promise<void>;
  isConnected(): boolean;

  // URL operations
  createUrl(url: Omit<IUrl, "createdAt">): Promise<IUrl>;
  findUrlByUrlId(urlId: string): Promise<IUrl | null>;
  findUrlByOriginalUrl(originalUrl: string): Promise<IUrl | null>;
  updateUrlClicks(urlId: string, clicks: number): Promise<void>;
  deleteUrl(urlId: string): Promise<boolean>;

  // Event handling
  on(event: string, listener: (...args: any[]) => void): this;
  emit(event: string, ...args: any[]): boolean;
}

export interface DatabaseConfig {
  type: "mongodb" | "sqlite" | "postgresql" | "mysql";
  connectionString?: string;
  host?: string;
  port?: number;
  database?: string;
  username?: string;
  password?: string;
  maxRetries?: number;
  retryDelay?: number;
  collectionName?: string; // Custom collection name for MongoDB
  tableName?: string; // Custom table name for SQLite, PostgreSQL, MySQL
}

export interface SqliteConfig {
  database: string;
  maxRetries?: number;
  retryDelay?: number;
  tableName?: string;
}

export interface PostgresConfig {
  host: string;
  port: number;
  database: string;
  username: string;
  password: string;
  maxRetries?: number;
  retryDelay?: number;
  tableName?: string;
}

export interface MysqlConfig {
  host: string;
  port: number;
  database: string;
  username: string;
  password: string;
  maxRetries?: number;
  retryDelay?: number;
  tableName?: string;
}
