From b6dea799c12ab48c854e423f55cb6945a12eb4b0 Mon Sep 17 00:00:00 2001 From: Jan Prochazka Date: Mon, 3 Feb 2020 19:52:02 +0100 Subject: [PATCH] refactor --- packages/api/src/controllers/databaseConnections.js | 4 ++-- packages/api/src/dmlf/command.js | 4 ++-- packages/api/src/dmlf/select.js | 6 +++--- packages/api/tsconfig.json | 1 + packages/engines/default/DatabaseAnalyser.js | 4 ++-- packages/engines/default/SqlDumper.js | 2 +- packages/engines/index.js | 2 +- packages/engines/mssql/index.js | 4 ++-- packages/engines/mysql/index.js | 4 ++-- packages/engines/postgres/index.js | 4 ++-- packages/web/src/appobj/columnAppObject.js | 4 ++-- packages/web/src/appobj/constraintAppObject.js | 4 ++-- packages/web/src/tabs/TableCreateScriptTab.js | 2 +- packages/web/src/tabs/TableStructureTab.js | 2 +- packages/web/tsconfig.json | 4 ---- 15 files changed, 24 insertions(+), 27 deletions(-) diff --git a/packages/api/src/controllers/databaseConnections.js b/packages/api/src/controllers/databaseConnections.js index ca626b4a..d5b15086 100644 --- a/packages/api/src/controllers/databaseConnections.js +++ b/packages/api/src/controllers/databaseConnections.js @@ -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) => { diff --git a/packages/api/src/dmlf/command.js b/packages/api/src/dmlf/command.js index 78a6ce71..297d6988 100644 --- a/packages/api/src/dmlf/command.js +++ b/packages/api/src/dmlf/command.js @@ -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) {} } diff --git a/packages/api/src/dmlf/select.js b/packages/api/src/dmlf/select.js index deae22f8..72153baf 100644 --- a/packages/api/src/dmlf/select.js +++ b/packages/api/src/dmlf/select.js @@ -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) { diff --git a/packages/api/tsconfig.json b/packages/api/tsconfig.json index e5459c4c..1dc69527 100644 --- a/packages/api/tsconfig.json +++ b/packages/api/tsconfig.json @@ -5,6 +5,7 @@ "checkJs": true, "noEmit": true, "moduleResolution": "node", + "skipLibCheck": true, }, "include": [ "src" diff --git a/packages/engines/default/DatabaseAnalyser.js b/packages/engines/default/DatabaseAnalyser.js index b265134c..6e78e850 100644 --- a/packages/engines/default/DatabaseAnalyser.js +++ b/packages/engines/default/DatabaseAnalyser.js @@ -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: [], }); diff --git a/packages/engines/default/SqlDumper.js b/packages/engines/default/SqlDumper.js index 82e02994..d3d814d1 100644 --- a/packages/engines/default/SqlDumper.js +++ b/packages/engines/default/SqlDumper.js @@ -1,5 +1,5 @@ class SqlDumper { - /** @param driver {import('dbgate').EngineDriver} */ + /** @param driver {import('@dbgate/types').EngineDriver} */ constructor(driver) { this.s = ''; this.driver = driver; diff --git a/packages/engines/index.js b/packages/engines/index.js index 79789135..42c428bf 100644 --- a/packages/engines/index.js +++ b/packages/engines/index.js @@ -1,5 +1,5 @@ -/** @return {import('dbgate').EngineDriver} */ +/** @return {import('@dbgate/types').EngineDriver} */ function getDriver(connection) { const { engine } = connection; return require(`./${engine}`); diff --git a/packages/engines/mssql/index.js b/packages/engines/mssql/index.js index e2a0a1f6..632bf9e5 100644 --- a/packages/engines/mssql/index.js +++ b/packages/engines/mssql/index.js @@ -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({ diff --git a/packages/engines/mysql/index.js b/packages/engines/mysql/index.js index 293896a0..bcc1f1b9 100644 --- a/packages/engines/mysql/index.js +++ b/packages/engines/mysql/index.js @@ -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({ diff --git a/packages/engines/postgres/index.js b/packages/engines/postgres/index.js index 1f934166..2fbbbea4 100644 --- a/packages/engines/postgres/index.js +++ b/packages/engines/postgres/index.js @@ -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' }); diff --git a/packages/web/src/appobj/columnAppObject.js b/packages/web/src/appobj/columnAppObject.js index 95a4db8b..8b2eddc5 100644 --- a/packages/web/src/appobj/columnAppObject.js +++ b/packages/web/src/appobj/columnAppObject.js @@ -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; diff --git a/packages/web/src/appobj/constraintAppObject.js b/packages/web/src/appobj/constraintAppObject.js index abb6d9a7..3e53371d 100644 --- a/packages/web/src/appobj/constraintAppObject.js +++ b/packages/web/src/appobj/constraintAppObject.js @@ -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; diff --git a/packages/web/src/tabs/TableCreateScriptTab.js b/packages/web/src/tabs/TableCreateScriptTab.js index 6f9e7202..66846834 100644 --- a/packages/web/src/tabs/TableCreateScriptTab.js +++ b/packages/web/src/tabs/TableCreateScriptTab.js @@ -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 }, diff --git a/packages/web/src/tabs/TableStructureTab.js b/packages/web/src/tabs/TableStructureTab.js index 9ca2010d..09ac6339 100644 --- a/packages/web/src/tabs/TableStructureTab.js +++ b/packages/web/src/tabs/TableStructureTab.js @@ -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 }, diff --git a/packages/web/tsconfig.json b/packages/web/tsconfig.json index b947b36f..1dccaa15 100644 --- a/packages/web/tsconfig.json +++ b/packages/web/tsconfig.json @@ -21,10 +21,6 @@ "forceConsistentCasingInFileNames": true, "resolveJsonModule": true, "isolatedModules": true, - // doesn't work - "types": [ - "dbgate" - ] }, "include": [ "src"