import { addConnection as desktopAddConnection, findConnection as desktopFindConnection, loadConnections as desktopLoadConnections, removeConnection as desktopRemoveConnection, } from "./connections.js"; import { describeTable as desktopDescribeTable, executeQuery as desktopExecuteQuery, listTables as desktopListTables, } from "./database.js"; import type { ConnectionConfig } from "./connections.js"; import type { ColumnInfo, QueryOptions, QueryResult, TableInfo } from "./database.js"; export interface Backend { loadConnections(): Promise; findConnection(name: string): Promise; addConnection(config: Omit): Promise; removeConnection(name: string): Promise; listTables(config: ConnectionConfig, schema?: string): Promise; describeTable(config: ConnectionConfig, table: string, schema?: string): Promise; executeQuery(config: ConnectionConfig, sql: string, options?: QueryOptions): Promise; } export async function createBackend(env: NodeJS.ProcessEnv = process.env): Promise { if (env.DBX_WEB_URL) { return await import("./web-backend.js"); } return { loadConnections: desktopLoadConnections, findConnection: desktopFindConnection, addConnection: desktopAddConnection, removeConnection: desktopRemoveConnection, listTables: desktopListTables, describeTable: desktopDescribeTable, executeQuery: desktopExecuteQuery, }; }