import { Connection, Engine } from "@/types"; import mysql from "./mysql"; import postgres from "./postgres"; export interface Connector { testConnection: () => Promise; execute: (databaseName: string, statement: string) => Promise; getDatabases: () => Promise; getTables: (databaseName: string) => Promise; getTableStructure: (databaseName: string, tableName: string) => Promise; } export const newConnector = (connection: Connection): Connector => { switch (connection.engineType) { case Engine.MySQL: return mysql(connection); case Engine.PostgreSQL: return postgres(connection); default: throw new Error("Unsupported engine type."); } };