mirror of
https://github.com/DeNNiiInc/dbgate.git
synced 2026-04-30 15:03:57 +00:00
typescript common lib
This commit is contained in:
3373
api/package-lock.json
generated
Normal file
3373
api/package-lock.json
generated
Normal file
File diff suppressed because it is too large
Load Diff
@@ -16,6 +16,7 @@
|
||||
"nedb-promises": "^4.0.1",
|
||||
"pg": "^7.17.0",
|
||||
"socket.io": "^2.3.0",
|
||||
"@dbgate/lib": "file:../lib",
|
||||
"uuid": "^3.4.0"
|
||||
},
|
||||
"scripts": {
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
@@ -3,7 +3,8 @@
|
||||
"module": "commonjs",
|
||||
"allowJs": true,
|
||||
"checkJs": true,
|
||||
"noEmit": true
|
||||
"noEmit": true,
|
||||
"moduleResolution": "node",
|
||||
},
|
||||
"include": [
|
||||
"src"
|
||||
|
||||
@@ -46,6 +46,9 @@
|
||||
esutils "^2.0.2"
|
||||
js-tokens "^4.0.0"
|
||||
|
||||
"@dbgate/lib@file:../lib":
|
||||
version "0.1.0"
|
||||
|
||||
"@types/lodash@^4.14.149":
|
||||
version "4.14.149"
|
||||
resolved "https://registry.yarnpkg.com/@types/lodash/-/lodash-4.14.149.tgz#1342d63d948c6062838fbf961012f74d4e638440"
|
||||
|
||||
Reference in New Issue
Block a user