mirror of
https://github.com/dbgate/dbgate
synced 2024-11-07 12:13:57 +00:00
refactor
This commit is contained in:
parent
acf6a1ce74
commit
b6dea799c1
@ -6,7 +6,7 @@ const { fork } = require('child_process');
|
||||
const DatabaseAnalyser = require('@dbgate/engines/default/DatabaseAnalyser');
|
||||
|
||||
module.exports = {
|
||||
/** @type {import('dbgate').OpenedDatabaseConnection[]} */
|
||||
/** @type {import('@dbgate/types').OpenedDatabaseConnection[]} */
|
||||
opened: [],
|
||||
requests: {},
|
||||
|
||||
@ -48,7 +48,7 @@ module.exports = {
|
||||
return newOpened;
|
||||
},
|
||||
|
||||
/** @param {import('dbgate').OpenedDatabaseConnection} conn */
|
||||
/** @param {import('@dbgate/types').OpenedDatabaseConnection} conn */
|
||||
async sendRequest(conn, message) {
|
||||
const msgid = uuidv1();
|
||||
const promise = new Promise((resolve, reject) => {
|
||||
|
@ -1,12 +1,12 @@
|
||||
class Command {
|
||||
/** @param driver {import('dbgate').EngineDriver} */
|
||||
/** @param driver {import('@dbgate/types').EngineDriver} */
|
||||
toSql(driver) {
|
||||
const dumper = driver.createDumper();
|
||||
this.dumpSql(dumper);
|
||||
return dumper.s;
|
||||
}
|
||||
|
||||
/** @param dumper {import('dbgate').SqlDumper} */
|
||||
/** @param dumper {import('@dbgate/types').SqlDumper} */
|
||||
dumpSql(dumper) {}
|
||||
}
|
||||
|
||||
|
@ -5,15 +5,15 @@ class Select extends Command {
|
||||
super();
|
||||
/** @type {number} */
|
||||
this.topRecords = undefined;
|
||||
/** @type {import('dbgate').NamedObjectInfo} */
|
||||
/** @type {import('@dbgate/types').NamedObjectInfo} */
|
||||
this.from = undefined;
|
||||
/** @type {import('dbgate').RangeDefinition} */
|
||||
/** @type {import('@dbgate/types').RangeDefinition} */
|
||||
this.range = undefined;
|
||||
this.distinct = false;
|
||||
this.selectAll = false;
|
||||
}
|
||||
|
||||
/** @param dumper {import('dbgate').SqlDumper} */
|
||||
/** @param dumper {import('@dbgate/types').SqlDumper} */
|
||||
dumpSql(dumper) {
|
||||
dumper.put('^select ');
|
||||
if (this.topRecords) {
|
||||
|
@ -5,6 +5,7 @@
|
||||
"checkJs": true,
|
||||
"noEmit": true,
|
||||
"moduleResolution": "node",
|
||||
"skipLibCheck": true,
|
||||
},
|
||||
"include": [
|
||||
"src"
|
||||
|
@ -1,7 +1,7 @@
|
||||
class DatabaseAnalyser {
|
||||
/**
|
||||
*
|
||||
* @param {import('dbgate').EngineDriver} driver
|
||||
* @param {import('@dbgate/types').EngineDriver} driver
|
||||
*/
|
||||
constructor(pool, driver) {
|
||||
this.pool = pool;
|
||||
@ -11,7 +11,7 @@ class DatabaseAnalyser {
|
||||
async runAnalysis() {}
|
||||
}
|
||||
|
||||
/** @returns {import('dbgate').DatabaseInfo} */
|
||||
/** @returns {import('@dbgate/types').DatabaseInfo} */
|
||||
DatabaseAnalyser.createEmptyStructure = () => ({
|
||||
tables: [],
|
||||
});
|
||||
|
@ -1,5 +1,5 @@
|
||||
class SqlDumper {
|
||||
/** @param driver {import('dbgate').EngineDriver} */
|
||||
/** @param driver {import('@dbgate/types').EngineDriver} */
|
||||
constructor(driver) {
|
||||
this.s = '';
|
||||
this.driver = driver;
|
||||
|
@ -1,5 +1,5 @@
|
||||
|
||||
/** @return {import('dbgate').EngineDriver} */
|
||||
/** @return {import('@dbgate/types').EngineDriver} */
|
||||
function getDriver(connection) {
|
||||
const { engine } = connection;
|
||||
return require(`./${engine}`);
|
||||
|
@ -2,7 +2,7 @@ const _ = require("lodash");
|
||||
const MsSqlAnalyser = require("./MsSqlAnalyser");
|
||||
const MsSqlDumper = require("./MsSqlDumper");
|
||||
|
||||
/** @type {import('dbgate').SqlDialect} */
|
||||
/** @type {import('@dbgate/types').SqlDialect} */
|
||||
const dialect = {
|
||||
limitSelect: true,
|
||||
quoteIdentifier(s) {
|
||||
@ -10,7 +10,7 @@ const dialect = {
|
||||
}
|
||||
};
|
||||
|
||||
/** @type {import('dbgate').EngineDriver} */
|
||||
/** @type {import('@dbgate/types').EngineDriver} */
|
||||
const driver = {
|
||||
async connect({ mssql }, { server, port, user, password, database }) {
|
||||
const pool = await mssql.connect({
|
||||
|
@ -1,7 +1,7 @@
|
||||
const MySqlAnalyser = require("./MySqlAnalyser");
|
||||
const MySqlDumper = require("./MySqlDumper");
|
||||
|
||||
/** @type {import('dbgate').SqlDialect} */
|
||||
/** @type {import('@dbgate/types').SqlDialect} */
|
||||
const dialect = {
|
||||
rangeSelect: true,
|
||||
quoteIdentifier(s) {
|
||||
@ -9,7 +9,7 @@ const dialect = {
|
||||
}
|
||||
};
|
||||
|
||||
/** @type {import('dbgate').EngineDriver} */
|
||||
/** @type {import('@dbgate/types').EngineDriver} */
|
||||
const driver = {
|
||||
async connect({ mysql }, { server, port, user, password, database }) {
|
||||
const connection = mysql.createConnection({
|
||||
|
@ -1,7 +1,7 @@
|
||||
const PostgreAnalyser = require('./PostgreAnalyser');
|
||||
const PostgreDumper = require('./PostgreDumper');
|
||||
|
||||
/** @type {import('dbgate').SqlDialect} */
|
||||
/** @type {import('@dbgate/types').SqlDialect} */
|
||||
const dialect = {
|
||||
rangeSelect: true,
|
||||
quoteIdentifier(s) {
|
||||
@ -9,7 +9,7 @@ const dialect = {
|
||||
},
|
||||
};
|
||||
|
||||
/** @type {import('dbgate').EngineDriver} */
|
||||
/** @type {import('@dbgate/types').EngineDriver} */
|
||||
const driver = {
|
||||
async connect({pg}, { server, port, user, password, database }) {
|
||||
const client = new pg.Client({ host: server, port, user, password, database: database || 'postgres' });
|
||||
|
@ -7,13 +7,13 @@ import axios from '../utility/axios';
|
||||
import { openNewTab } from '../utility/common';
|
||||
import { useSetOpenedTabs } from '../utility/globalState';
|
||||
|
||||
/** @param columnProps {import('dbgate').ColumnInfo} */
|
||||
/** @param columnProps {import('@dbgate/types').ColumnInfo} */
|
||||
function getColumnIcon(columnProps) {
|
||||
if (columnProps.autoIncrement) return SequenceIcon;
|
||||
return ColumnIcon;
|
||||
}
|
||||
|
||||
/** @param columnProps {import('dbgate').ColumnInfo} */
|
||||
/** @param columnProps {import('@dbgate/types').ColumnInfo} */
|
||||
export default function columnAppObject(columnProps, { setOpenedTabs }) {
|
||||
const title = columnProps.columnName;
|
||||
const key = title;
|
||||
|
@ -7,14 +7,14 @@ import axios from '../utility/axios';
|
||||
import { openNewTab } from '../utility/common';
|
||||
import { useSetOpenedTabs } from '../utility/globalState';
|
||||
|
||||
/** @param props {import('dbgate').ConstraintInfo} */
|
||||
/** @param props {import('@dbgate/types').ConstraintInfo} */
|
||||
function getConstraintIcon(props) {
|
||||
if (props.constraintType == 'primaryKey') return PrimaryKeyIcon;
|
||||
if (props.constraintType == 'foreignKey') return ForeignKeyIcon;
|
||||
return null;
|
||||
}
|
||||
|
||||
/** @param props {import('dbgate').ConstraintInfo} */
|
||||
/** @param props {import('@dbgate/types').ConstraintInfo} */
|
||||
export default function constraintAppObject(props, { setOpenedTabs }) {
|
||||
const title = props.constraintName;
|
||||
const key = title;
|
||||
|
@ -17,7 +17,7 @@ export default function TableCreateScriptTab({ conid, database, schemaName, pure
|
||||
const sql = `SELECT * FROM MOJE`;
|
||||
const [containerRef, { height, width }] = useDimensions();
|
||||
|
||||
/** @type {import('dbgate').TableInfo} */
|
||||
/** @type {import('@dbgate/types').TableInfo} */
|
||||
const tableInfo = useFetch({
|
||||
url: 'tables/table-info',
|
||||
params: { conid, database, schemaName, pureName },
|
||||
|
@ -18,7 +18,7 @@ const WhitePage = styled.div`
|
||||
`;
|
||||
|
||||
export default function TableStructureTab({ conid, database, schemaName, pureName }) {
|
||||
/** @type {import('dbgate').TableInfo} */
|
||||
/** @type {import('@dbgate/types').TableInfo} */
|
||||
const tableInfo = useFetch({
|
||||
url: 'tables/table-info',
|
||||
params: { conid, database, schemaName, pureName },
|
||||
|
@ -21,10 +21,6 @@
|
||||
"forceConsistentCasingInFileNames": true,
|
||||
"resolveJsonModule": true,
|
||||
"isolatedModules": true,
|
||||
// doesn't work
|
||||
"types": [
|
||||
"dbgate"
|
||||
]
|
||||
},
|
||||
"include": [
|
||||
"src"
|
||||
|
Loading…
Reference in New Issue
Block a user