mirror of
https://github.com/DeNNiiInc/dbgate.git
synced 2026-04-24 01:25:59 +00:00
typescript common lib
This commit is contained in:
@@ -6,7 +6,7 @@ const { fork } = require('child_process');
|
||||
const DatabaseAnalyser = require('../engines/default/DatabaseAnalyser');
|
||||
|
||||
module.exports = {
|
||||
/** @type {import('../types').OpenedDatabaseConnection[]} */
|
||||
/** @type {import('@dbgate/lib').OpenedDatabaseConnection[]} */
|
||||
opened: [],
|
||||
requests: {},
|
||||
|
||||
@@ -48,7 +48,7 @@ module.exports = {
|
||||
return newOpened;
|
||||
},
|
||||
|
||||
/** @param {import('../types').OpenedDatabaseConnection} conn */
|
||||
/** @param {import('@dbgate/lib').OpenedDatabaseConnection} conn */
|
||||
async sendRequest(conn, message) {
|
||||
const msgid = uuidv1();
|
||||
const promise = new Promise((resolve, reject) => {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
class DatabaseAnalyser {
|
||||
/**
|
||||
*
|
||||
* @param {import('../../types').EngineDriver} driver
|
||||
* @param {import('@dbgate/lib').EngineDriver} driver
|
||||
*/
|
||||
constructor(pool, driver) {
|
||||
this.pool = pool;
|
||||
@@ -11,7 +11,7 @@ class DatabaseAnalyser {
|
||||
async runAnalysis() {}
|
||||
}
|
||||
|
||||
/** @returns {import('../../types').DatabaseInfo} */
|
||||
/** @returns {import('@dbgate/lib').DatabaseInfo} */
|
||||
DatabaseAnalyser.createEmptyStructure = () => ({
|
||||
tables: [],
|
||||
});
|
||||
|
||||
@@ -1,8 +1,7 @@
|
||||
|
||||
/** @return {import('../types').EngineDriver} */
|
||||
/** @return {import('@dbgate/lib').EngineDriver} */
|
||||
function getDriver(connection) {
|
||||
const { engine } = connection;
|
||||
return require(`./${engine}`);
|
||||
|
||||
}
|
||||
module.exports = getDriver;
|
||||
|
||||
@@ -1,33 +0,0 @@
|
||||
import { ChildProcess } from 'child_process';
|
||||
|
||||
export interface QueryResult {
|
||||
rows: any[];
|
||||
}
|
||||
|
||||
export interface EngineDriver {
|
||||
connect({ server, port, user, password });
|
||||
query(pool, sql: string): Promise<QueryResult>;
|
||||
getVersion(pool): Promise<string>;
|
||||
listDatabases(pool): Promise<{ name: string }[]>;
|
||||
analyseFull(pool): Promise<void>;
|
||||
analyseIncremental(pool): Promise<void>;
|
||||
}
|
||||
|
||||
export interface NamedObjectInfo {
|
||||
pureName: string;
|
||||
schemaName: string;
|
||||
}
|
||||
|
||||
export interface TableInfo extends NamedObjectInfo {
|
||||
}
|
||||
|
||||
export interface DatabaseInfo {
|
||||
tables: TableInfo[];
|
||||
}
|
||||
|
||||
export interface OpenedDatabaseConnection {
|
||||
conid: string;
|
||||
database: string;
|
||||
structure: DatabaseInfo;
|
||||
subprocess: ChildProcess;
|
||||
}
|
||||
Reference in New Issue
Block a user