feat(cli): add dbx node packages
This commit is contained in:
1 parent
19f7cbd2ba
commit
1917c0855b
47 files changed
+2643
-4959
No files matched your search
@@ -0,0 +1,39 @@
|
||||
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<ConnectionConfig[]>;
|
||||
findConnection(name: string): Promise<ConnectionConfig | undefined>;
|
||||
addConnection(config: Omit<ConnectionConfig, "id">): Promise<ConnectionConfig>;
|
||||
removeConnection(name: string): Promise<boolean>;
|
||||
listTables(config: ConnectionConfig, schema?: string): Promise<TableInfo[]>;
|
||||
describeTable(config: ConnectionConfig, table: string, schema?: string): Promise<ColumnInfo[]>;
|
||||
executeQuery(config: ConnectionConfig, sql: string, options?: QueryOptions): Promise<QueryResult>;
|
||||
}
|
||||
|
||||
export async function createBackend(env: NodeJS.ProcessEnv = process.env): Promise<Backend> {
|
||||
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,
|
||||
};
|
||||
}
|
||||
Reference in new issue
Block a user