diff --git a/api/package.json b/api/package.json index 2f403f82..6c7f49f3 100644 --- a/api/package.json +++ b/api/package.json @@ -16,7 +16,6 @@ "nedb-promises": "^4.0.1", "pg": "^7.17.0", "socket.io": "^2.3.0", - "@dbgate/lib": "file:../lib", "uuid": "^3.4.0" }, "scripts": { @@ -26,6 +25,7 @@ "devDependencies": { "@types/lodash": "^4.14.149", "nodemon": "^2.0.2", - "typescript": "^3.7.4" + "typescript": "^3.7.4", + "@types/dbgate": "file:../lib" } } diff --git a/api/src/controllers/databaseConnections.js b/api/src/controllers/databaseConnections.js index 8f1c8a6e..eb2bc273 100644 --- a/api/src/controllers/databaseConnections.js +++ b/api/src/controllers/databaseConnections.js @@ -6,7 +6,7 @@ const { fork } = require('child_process'); const DatabaseAnalyser = require('../engines/default/DatabaseAnalyser'); module.exports = { - /** @type {import('@dbgate/lib').OpenedDatabaseConnection[]} */ + /** @type {import('dbgate').OpenedDatabaseConnection[]} */ opened: [], requests: {}, @@ -48,7 +48,7 @@ module.exports = { return newOpened; }, - /** @param {import('@dbgate/lib').OpenedDatabaseConnection} conn */ + /** @param {import('dbgate').OpenedDatabaseConnection} conn */ async sendRequest(conn, message) { const msgid = uuidv1(); const promise = new Promise((resolve, reject) => { diff --git a/api/src/engines/default/DatabaseAnalyser.js b/api/src/engines/default/DatabaseAnalyser.js index e4a2c847..b265134c 100644 --- a/api/src/engines/default/DatabaseAnalyser.js +++ b/api/src/engines/default/DatabaseAnalyser.js @@ -1,7 +1,7 @@ class DatabaseAnalyser { /** * - * @param {import('@dbgate/lib').EngineDriver} driver + * @param {import('dbgate').EngineDriver} driver */ constructor(pool, driver) { this.pool = pool; @@ -11,7 +11,7 @@ class DatabaseAnalyser { async runAnalysis() {} } -/** @returns {import('@dbgate/lib').DatabaseInfo} */ +/** @returns {import('dbgate').DatabaseInfo} */ DatabaseAnalyser.createEmptyStructure = () => ({ tables: [], }); diff --git a/api/src/engines/index.js b/api/src/engines/index.js index dc2266e2..79789135 100644 --- a/api/src/engines/index.js +++ b/api/src/engines/index.js @@ -1,5 +1,5 @@ -/** @return {import('@dbgate/lib').EngineDriver} */ +/** @return {import('dbgate').EngineDriver} */ function getDriver(connection) { const { engine } = connection; return require(`./${engine}`); diff --git a/lib/.gitignore b/lib/.gitignore deleted file mode 100644 index a65b4177..00000000 --- a/lib/.gitignore +++ /dev/null @@ -1 +0,0 @@ -lib diff --git a/lib/package.json b/lib/package.json deleted file mode 100644 index 2fcfe8ee..00000000 --- a/lib/package.json +++ /dev/null @@ -1,17 +0,0 @@ -{ - "version": "0.1.0", - "name": "@dbgate/lib", - "main": "lib/index.js", - "typings": "lib/index.d.ts", - "scripts": { - "prepare": "yarn build", - "build": "tsc" - }, - "files": [ - "lib" - ], - "devDependencies": { - "@types/node": "^13.7.0", - "typescript": "^3.7.5" - } -} diff --git a/lib/src/dbinfo.ts b/lib/src/dbinfo.ts deleted file mode 100644 index 368df8a6..00000000 --- a/lib/src/dbinfo.ts +++ /dev/null @@ -1,29 +0,0 @@ -import { ChildProcess } from "child_process"; - -export interface NamedObjectInfo { - pureName: string; - schemaName: string; -} - -export interface ColumnInfo { - columnName: string; - notNull: boolean; - autoIncrement: boolean; - dataType: string; - precision: number; - scale: number; - length: number; - computedExpression: string; - isPersisted: boolean; - isSparse: boolean; - defaultValue: string; - defaultConstraint: string; -} - -export interface TableInfo extends NamedObjectInfo { - columns: ColumnInfo[]; -} - -export interface DatabaseInfo { - tables: TableInfo[]; -} diff --git a/lib/src/engines.ts b/lib/src/engines.ts deleted file mode 100644 index cd749125..00000000 --- a/lib/src/engines.ts +++ /dev/null @@ -1,11 +0,0 @@ -import { QueryResult } from "./query"; - -export interface EngineDriver { - connect({ server, port, user, password }); - query(pool, sql: string): Promise; - getVersion(pool): Promise; - listDatabases(pool): Promise<{ name: string }[]>; - analyseFull(pool): Promise; - analyseIncremental(pool): Promise; - } - \ No newline at end of file diff --git a/lib/src/query.ts b/lib/src/query.ts deleted file mode 100644 index 587146ae..00000000 --- a/lib/src/query.ts +++ /dev/null @@ -1,5 +0,0 @@ -import { ChildProcess } from "child_process"; - -export interface QueryResult { - rows: any[]; -} diff --git a/lib/tsconfig.json b/lib/tsconfig.json deleted file mode 100644 index 8916df97..00000000 --- a/lib/tsconfig.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "compilerOptions": { - "target": "ES2015", - "module": "commonjs", - "declaration": true, - "outDir": "lib" - }, - "include": [ - "src/**/*" - ] -} diff --git a/lib/yarn.lock b/lib/yarn.lock deleted file mode 100644 index 94ad8f4b..00000000 --- a/lib/yarn.lock +++ /dev/null @@ -1,13 +0,0 @@ -# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. -# yarn lockfile v1 - - -"@types/node@^13.7.0": - version "13.7.0" - resolved "https://registry.yarnpkg.com/@types/node/-/node-13.7.0.tgz#b417deda18cf8400f278733499ad5547ed1abec4" - integrity sha512-GnZbirvmqZUzMgkFn70c74OQpTTUcCzlhQliTzYjQMqg+hVKcDnxdL19Ne3UdYzdMA/+W3eb646FWn/ZaT1NfQ== - -typescript@^3.7.5: - version "3.7.5" - resolved "https://registry.yarnpkg.com/typescript/-/typescript-3.7.5.tgz#0692e21f65fd4108b9330238aac11dd2e177a1ae" - integrity sha512-/P5lkRXkWHNAbcJIiHPfRoKqyd7bsyCma1hZNUGfn20qm64T6ZBlrzprymeu918H+mB/0rIg2gGK/BXkhhYgBw== diff --git a/types/dbinfo.d.ts b/types/dbinfo.d.ts new file mode 100644 index 00000000..b751051b --- /dev/null +++ b/types/dbinfo.d.ts @@ -0,0 +1,24 @@ +export interface NamedObjectInfo { + pureName: string; + schemaName: string; +} +export interface ColumnInfo { + columnName: string; + notNull: boolean; + autoIncrement: boolean; + dataType: string; + precision: number; + scale: number; + length: number; + computedExpression: string; + isPersisted: boolean; + isSparse: boolean; + defaultValue: string; + defaultConstraint: string; +} +export interface TableInfo extends NamedObjectInfo { + columns: ColumnInfo[]; +} +export interface DatabaseInfo { + tables: TableInfo[]; +} diff --git a/types/engines.d.ts b/types/engines.d.ts new file mode 100644 index 00000000..cbe0161b --- /dev/null +++ b/types/engines.d.ts @@ -0,0 +1,16 @@ +import { QueryResult } from "./query"; +export interface EngineDriver { + connect({ server, port, user, password }: { + server: any; + port: any; + user: any; + password: any; + }): any; + query(pool: any, sql: string): Promise; + getVersion(pool: any): Promise; + listDatabases(pool: any): Promise<{ + name: string; + }[]>; + analyseFull(pool: any): Promise; + analyseIncremental(pool: any): Promise; +} diff --git a/lib/src/index.ts b/types/index.d.ts similarity index 61% rename from lib/src/index.ts rename to types/index.d.ts index a87b47ff..d6d61ab9 100644 --- a/lib/src/index.ts +++ b/types/index.d.ts @@ -1,13 +1,12 @@ +/// import { ChildProcess } from "child_process"; import { DatabaseInfo } from "./dbinfo"; - export interface OpenedDatabaseConnection { - conid: string; - database: string; - structure: DatabaseInfo; - subprocess: ChildProcess; + conid: string; + database: string; + structure: DatabaseInfo; + subprocess: ChildProcess; } - export * from "./engines"; export * from "./dbinfo"; export * from "./query"; diff --git a/types/package.json b/types/package.json new file mode 100644 index 00000000..25efbb72 --- /dev/null +++ b/types/package.json @@ -0,0 +1,7 @@ +{ + "version": "0.1.0", + "name": "@types/dbgate", + "types": "index.d.ts", + "main": "", + "typeScriptVersion": "2.8" +} diff --git a/types/query.d.ts b/types/query.d.ts new file mode 100644 index 00000000..b18e8fe7 --- /dev/null +++ b/types/query.d.ts @@ -0,0 +1,3 @@ +export interface QueryResult { + rows: any[]; +} diff --git a/web/package.json b/web/package.json index dcc4e499..d7c9173d 100644 --- a/web/package.json +++ b/web/package.json @@ -19,7 +19,6 @@ "resize-observer-polyfill": "^1.5.1", "socket.io-client": "^2.3.0", "styled-components": "^4.4.1", - "@dbgate/lib": "file:../lib", "uuid": "^3.4.0" }, "scripts": { @@ -46,6 +45,7 @@ "@fortawesome/fontawesome-free": "^5.12.0", "@types/react": "^16.9.17", "@types/styled-components": "^4.4.2", + "@types/dbgate": "file:../lib", "typescript": "^3.7.4" } } diff --git a/web/src/appobj/columnAppObject.js b/web/src/appobj/columnAppObject.js index 0bc956a6..097a18cc 100644 --- a/web/src/appobj/columnAppObject.js +++ b/web/src/appobj/columnAppObject.js @@ -7,7 +7,7 @@ import axios from '../utility/axios'; import { openNewTab } from '../utility/common'; import { useSetOpenedTabs } from '../utility/globalState'; -/** @param columnProps {import('@dbgate/lib').ColumnInfo} */ +/** @param columnProps {import('dbgate').ColumnInfo} */ export default function columnAppObject(columnProps, { setOpenedTabs }) { const title = columnProps.columnName; const key = title; diff --git a/web/src/tabs/TableStructureTab.js b/web/src/tabs/TableStructureTab.js index be2c7817..f8840029 100644 --- a/web/src/tabs/TableStructureTab.js +++ b/web/src/tabs/TableStructureTab.js @@ -15,7 +15,7 @@ const WhitePage = styled.div` `; export default function TableStructureTab({ conid, database, schemaName, pureName }) { - /** @type {import('@dbgate/lib').TableInfo} */ + /** @type {import('dbgate').TableInfo} */ const tableInfo = useFetch({ url: 'tables/table-info', params: { conid, database, schemaName, pureName }, diff --git a/web/tsconfig.json b/web/tsconfig.json index efee3070..9a0ecbb2 100644 --- a/web/tsconfig.json +++ b/web/tsconfig.json @@ -21,6 +21,9 @@ "forceConsistentCasingInFileNames": true, "resolveJsonModule": true, "isolatedModules": true, + "types": [ + "dbgate" + ] }, "include": [ "src"