This commit is contained in:
Jan Prochazka 2020-02-03 19:52:02 +01:00
parent acf6a1ce74
commit b6dea799c1
15 changed files with 24 additions and 27 deletions

View File

@ -6,7 +6,7 @@ const { fork } = require('child_process');
const DatabaseAnalyser = require('@dbgate/engines/default/DatabaseAnalyser'); const DatabaseAnalyser = require('@dbgate/engines/default/DatabaseAnalyser');
module.exports = { module.exports = {
/** @type {import('dbgate').OpenedDatabaseConnection[]} */ /** @type {import('@dbgate/types').OpenedDatabaseConnection[]} */
opened: [], opened: [],
requests: {}, requests: {},
@ -48,7 +48,7 @@ module.exports = {
return newOpened; return newOpened;
}, },
/** @param {import('dbgate').OpenedDatabaseConnection} conn */ /** @param {import('@dbgate/types').OpenedDatabaseConnection} conn */
async sendRequest(conn, message) { async sendRequest(conn, message) {
const msgid = uuidv1(); const msgid = uuidv1();
const promise = new Promise((resolve, reject) => { const promise = new Promise((resolve, reject) => {

View File

@ -1,12 +1,12 @@
class Command { class Command {
/** @param driver {import('dbgate').EngineDriver} */ /** @param driver {import('@dbgate/types').EngineDriver} */
toSql(driver) { toSql(driver) {
const dumper = driver.createDumper(); const dumper = driver.createDumper();
this.dumpSql(dumper); this.dumpSql(dumper);
return dumper.s; return dumper.s;
} }
/** @param dumper {import('dbgate').SqlDumper} */ /** @param dumper {import('@dbgate/types').SqlDumper} */
dumpSql(dumper) {} dumpSql(dumper) {}
} }

View File

@ -5,15 +5,15 @@ class Select extends Command {
super(); super();
/** @type {number} */ /** @type {number} */
this.topRecords = undefined; this.topRecords = undefined;
/** @type {import('dbgate').NamedObjectInfo} */ /** @type {import('@dbgate/types').NamedObjectInfo} */
this.from = undefined; this.from = undefined;
/** @type {import('dbgate').RangeDefinition} */ /** @type {import('@dbgate/types').RangeDefinition} */
this.range = undefined; this.range = undefined;
this.distinct = false; this.distinct = false;
this.selectAll = false; this.selectAll = false;
} }
/** @param dumper {import('dbgate').SqlDumper} */ /** @param dumper {import('@dbgate/types').SqlDumper} */
dumpSql(dumper) { dumpSql(dumper) {
dumper.put('^select '); dumper.put('^select ');
if (this.topRecords) { if (this.topRecords) {

View File

@ -5,6 +5,7 @@
"checkJs": true, "checkJs": true,
"noEmit": true, "noEmit": true,
"moduleResolution": "node", "moduleResolution": "node",
"skipLibCheck": true,
}, },
"include": [ "include": [
"src" "src"

View File

@ -1,7 +1,7 @@
class DatabaseAnalyser { class DatabaseAnalyser {
/** /**
* *
* @param {import('dbgate').EngineDriver} driver * @param {import('@dbgate/types').EngineDriver} driver
*/ */
constructor(pool, driver) { constructor(pool, driver) {
this.pool = pool; this.pool = pool;
@ -11,7 +11,7 @@ class DatabaseAnalyser {
async runAnalysis() {} async runAnalysis() {}
} }
/** @returns {import('dbgate').DatabaseInfo} */ /** @returns {import('@dbgate/types').DatabaseInfo} */
DatabaseAnalyser.createEmptyStructure = () => ({ DatabaseAnalyser.createEmptyStructure = () => ({
tables: [], tables: [],
}); });

View File

@ -1,5 +1,5 @@
class SqlDumper { class SqlDumper {
/** @param driver {import('dbgate').EngineDriver} */ /** @param driver {import('@dbgate/types').EngineDriver} */
constructor(driver) { constructor(driver) {
this.s = ''; this.s = '';
this.driver = driver; this.driver = driver;

View File

@ -1,5 +1,5 @@
/** @return {import('dbgate').EngineDriver} */ /** @return {import('@dbgate/types').EngineDriver} */
function getDriver(connection) { function getDriver(connection) {
const { engine } = connection; const { engine } = connection;
return require(`./${engine}`); return require(`./${engine}`);

View File

@ -2,7 +2,7 @@ const _ = require("lodash");
const MsSqlAnalyser = require("./MsSqlAnalyser"); const MsSqlAnalyser = require("./MsSqlAnalyser");
const MsSqlDumper = require("./MsSqlDumper"); const MsSqlDumper = require("./MsSqlDumper");
/** @type {import('dbgate').SqlDialect} */ /** @type {import('@dbgate/types').SqlDialect} */
const dialect = { const dialect = {
limitSelect: true, limitSelect: true,
quoteIdentifier(s) { quoteIdentifier(s) {
@ -10,7 +10,7 @@ const dialect = {
} }
}; };
/** @type {import('dbgate').EngineDriver} */ /** @type {import('@dbgate/types').EngineDriver} */
const driver = { const driver = {
async connect({ mssql }, { server, port, user, password, database }) { async connect({ mssql }, { server, port, user, password, database }) {
const pool = await mssql.connect({ const pool = await mssql.connect({

View File

@ -1,7 +1,7 @@
const MySqlAnalyser = require("./MySqlAnalyser"); const MySqlAnalyser = require("./MySqlAnalyser");
const MySqlDumper = require("./MySqlDumper"); const MySqlDumper = require("./MySqlDumper");
/** @type {import('dbgate').SqlDialect} */ /** @type {import('@dbgate/types').SqlDialect} */
const dialect = { const dialect = {
rangeSelect: true, rangeSelect: true,
quoteIdentifier(s) { quoteIdentifier(s) {
@ -9,7 +9,7 @@ const dialect = {
} }
}; };
/** @type {import('dbgate').EngineDriver} */ /** @type {import('@dbgate/types').EngineDriver} */
const driver = { const driver = {
async connect({ mysql }, { server, port, user, password, database }) { async connect({ mysql }, { server, port, user, password, database }) {
const connection = mysql.createConnection({ const connection = mysql.createConnection({

View File

@ -1,7 +1,7 @@
const PostgreAnalyser = require('./PostgreAnalyser'); const PostgreAnalyser = require('./PostgreAnalyser');
const PostgreDumper = require('./PostgreDumper'); const PostgreDumper = require('./PostgreDumper');
/** @type {import('dbgate').SqlDialect} */ /** @type {import('@dbgate/types').SqlDialect} */
const dialect = { const dialect = {
rangeSelect: true, rangeSelect: true,
quoteIdentifier(s) { quoteIdentifier(s) {
@ -9,7 +9,7 @@ const dialect = {
}, },
}; };
/** @type {import('dbgate').EngineDriver} */ /** @type {import('@dbgate/types').EngineDriver} */
const driver = { const driver = {
async connect({pg}, { server, port, user, password, database }) { async connect({pg}, { server, port, user, password, database }) {
const client = new pg.Client({ host: server, port, user, password, database: database || 'postgres' }); const client = new pg.Client({ host: server, port, user, password, database: database || 'postgres' });

View File

@ -7,13 +7,13 @@ import axios from '../utility/axios';
import { openNewTab } from '../utility/common'; import { openNewTab } from '../utility/common';
import { useSetOpenedTabs } from '../utility/globalState'; import { useSetOpenedTabs } from '../utility/globalState';
/** @param columnProps {import('dbgate').ColumnInfo} */ /** @param columnProps {import('@dbgate/types').ColumnInfo} */
function getColumnIcon(columnProps) { function getColumnIcon(columnProps) {
if (columnProps.autoIncrement) return SequenceIcon; if (columnProps.autoIncrement) return SequenceIcon;
return ColumnIcon; return ColumnIcon;
} }
/** @param columnProps {import('dbgate').ColumnInfo} */ /** @param columnProps {import('@dbgate/types').ColumnInfo} */
export default function columnAppObject(columnProps, { setOpenedTabs }) { export default function columnAppObject(columnProps, { setOpenedTabs }) {
const title = columnProps.columnName; const title = columnProps.columnName;
const key = title; const key = title;

View File

@ -7,14 +7,14 @@ import axios from '../utility/axios';
import { openNewTab } from '../utility/common'; import { openNewTab } from '../utility/common';
import { useSetOpenedTabs } from '../utility/globalState'; import { useSetOpenedTabs } from '../utility/globalState';
/** @param props {import('dbgate').ConstraintInfo} */ /** @param props {import('@dbgate/types').ConstraintInfo} */
function getConstraintIcon(props) { function getConstraintIcon(props) {
if (props.constraintType == 'primaryKey') return PrimaryKeyIcon; if (props.constraintType == 'primaryKey') return PrimaryKeyIcon;
if (props.constraintType == 'foreignKey') return ForeignKeyIcon; if (props.constraintType == 'foreignKey') return ForeignKeyIcon;
return null; return null;
} }
/** @param props {import('dbgate').ConstraintInfo} */ /** @param props {import('@dbgate/types').ConstraintInfo} */
export default function constraintAppObject(props, { setOpenedTabs }) { export default function constraintAppObject(props, { setOpenedTabs }) {
const title = props.constraintName; const title = props.constraintName;
const key = title; const key = title;

View File

@ -17,7 +17,7 @@ export default function TableCreateScriptTab({ conid, database, schemaName, pure
const sql = `SELECT * FROM MOJE`; const sql = `SELECT * FROM MOJE`;
const [containerRef, { height, width }] = useDimensions(); const [containerRef, { height, width }] = useDimensions();
/** @type {import('dbgate').TableInfo} */ /** @type {import('@dbgate/types').TableInfo} */
const tableInfo = useFetch({ const tableInfo = useFetch({
url: 'tables/table-info', url: 'tables/table-info',
params: { conid, database, schemaName, pureName }, params: { conid, database, schemaName, pureName },

View File

@ -18,7 +18,7 @@ const WhitePage = styled.div`
`; `;
export default function TableStructureTab({ conid, database, schemaName, pureName }) { export default function TableStructureTab({ conid, database, schemaName, pureName }) {
/** @type {import('dbgate').TableInfo} */ /** @type {import('@dbgate/types').TableInfo} */
const tableInfo = useFetch({ const tableInfo = useFetch({
url: 'tables/table-info', url: 'tables/table-info',
params: { conid, database, schemaName, pureName }, params: { conid, database, schemaName, pureName },

View File

@ -21,10 +21,6 @@
"forceConsistentCasingInFileNames": true, "forceConsistentCasingInFileNames": true,
"resolveJsonModule": true, "resolveJsonModule": true,
"isolatedModules": true, "isolatedModules": true,
// doesn't work
"types": [
"dbgate"
]
}, },
"include": [ "include": [
"src" "src"