add login support (wonky still)

This commit is contained in:
2024-07-08 18:41:12 +02:00
parent 7b9f93448b
commit d85df4c308
21 changed files with 1183 additions and 304 deletions

View File

@@ -0,0 +1,51 @@
export type WithSort<T> = T & { sortField?: string; sortDesc?: boolean };
export type WithPagination<T> = T & { perPage: number; page: number };
export type WithSortPagination<T> = WithPagination<WithSort<T>>;
export type Credentials =
| {
username: string;
password: string;
host: string;
type: string;
port: string;
database: string;
ssl: string;
}
| {
connectionString: string;
};
export interface Driver {
getAllDatabases(credentials: Credentials): Promise<string[]>;
getAllTables(
credentials: Credentials,
args: WithSort<{ dbName: string }>,
): Promise<any[]>;
getTableData(
credentials: Credentials,
args: WithSortPagination<{ tableName: string; dbName: string }>,
): Promise<{
count: number;
data: Record<string, any>[];
}>;
getTableColumns(
credentials: Credentials,
args: { dbName: string; tableName: string },
): Promise<any[]>;
getTableIndexes(
credentials: Credentials,
args: { dbName: string; tableName: string },
): Promise<any[]>;
getTableForeignKeys(
credentials: Credentials,
args: { dbName: string; tableName: string },
): Promise<any[]>;
executeQuery(
credentials: Credentials,
query: string,
): Promise<{
count: number;
data: Record<string, any>[];
}>;
}