mirror of
https://github.com/dbgate/dbgate
synced 2024-11-07 20:26:23 +00:00
typings refactor - no compilation, renamed package
This commit is contained in:
parent
af80a2799f
commit
4fe2912707
@ -16,7 +16,6 @@
|
|||||||
"nedb-promises": "^4.0.1",
|
"nedb-promises": "^4.0.1",
|
||||||
"pg": "^7.17.0",
|
"pg": "^7.17.0",
|
||||||
"socket.io": "^2.3.0",
|
"socket.io": "^2.3.0",
|
||||||
"@dbgate/lib": "file:../lib",
|
|
||||||
"uuid": "^3.4.0"
|
"uuid": "^3.4.0"
|
||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
@ -26,6 +25,7 @@
|
|||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@types/lodash": "^4.14.149",
|
"@types/lodash": "^4.14.149",
|
||||||
"nodemon": "^2.0.2",
|
"nodemon": "^2.0.2",
|
||||||
"typescript": "^3.7.4"
|
"typescript": "^3.7.4",
|
||||||
|
"@types/dbgate": "file:../lib"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -6,7 +6,7 @@ const { fork } = require('child_process');
|
|||||||
const DatabaseAnalyser = require('../engines/default/DatabaseAnalyser');
|
const DatabaseAnalyser = require('../engines/default/DatabaseAnalyser');
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
/** @type {import('@dbgate/lib').OpenedDatabaseConnection[]} */
|
/** @type {import('dbgate').OpenedDatabaseConnection[]} */
|
||||||
opened: [],
|
opened: [],
|
||||||
requests: {},
|
requests: {},
|
||||||
|
|
||||||
@ -48,7 +48,7 @@ module.exports = {
|
|||||||
return newOpened;
|
return newOpened;
|
||||||
},
|
},
|
||||||
|
|
||||||
/** @param {import('@dbgate/lib').OpenedDatabaseConnection} conn */
|
/** @param {import('dbgate').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) => {
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
class DatabaseAnalyser {
|
class DatabaseAnalyser {
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @param {import('@dbgate/lib').EngineDriver} driver
|
* @param {import('dbgate').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/lib').DatabaseInfo} */
|
/** @returns {import('dbgate').DatabaseInfo} */
|
||||||
DatabaseAnalyser.createEmptyStructure = () => ({
|
DatabaseAnalyser.createEmptyStructure = () => ({
|
||||||
tables: [],
|
tables: [],
|
||||||
});
|
});
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
|
|
||||||
/** @return {import('@dbgate/lib').EngineDriver} */
|
/** @return {import('dbgate').EngineDriver} */
|
||||||
function getDriver(connection) {
|
function getDriver(connection) {
|
||||||
const { engine } = connection;
|
const { engine } = connection;
|
||||||
return require(`./${engine}`);
|
return require(`./${engine}`);
|
||||||
|
1
lib/.gitignore
vendored
1
lib/.gitignore
vendored
@ -1 +0,0 @@
|
|||||||
lib
|
|
@ -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"
|
|
||||||
}
|
|
||||||
}
|
|
@ -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[];
|
|
||||||
}
|
|
@ -1,11 +0,0 @@
|
|||||||
import { QueryResult } from "./query";
|
|
||||||
|
|
||||||
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>;
|
|
||||||
}
|
|
||||||
|
|
@ -1,5 +0,0 @@
|
|||||||
import { ChildProcess } from "child_process";
|
|
||||||
|
|
||||||
export interface QueryResult {
|
|
||||||
rows: any[];
|
|
||||||
}
|
|
@ -1,11 +0,0 @@
|
|||||||
{
|
|
||||||
"compilerOptions": {
|
|
||||||
"target": "ES2015",
|
|
||||||
"module": "commonjs",
|
|
||||||
"declaration": true,
|
|
||||||
"outDir": "lib"
|
|
||||||
},
|
|
||||||
"include": [
|
|
||||||
"src/**/*"
|
|
||||||
]
|
|
||||||
}
|
|
@ -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==
|
|
24
types/dbinfo.d.ts
vendored
Normal file
24
types/dbinfo.d.ts
vendored
Normal file
@ -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[];
|
||||||
|
}
|
16
types/engines.d.ts
vendored
Normal file
16
types/engines.d.ts
vendored
Normal file
@ -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<QueryResult>;
|
||||||
|
getVersion(pool: any): Promise<string>;
|
||||||
|
listDatabases(pool: any): Promise<{
|
||||||
|
name: string;
|
||||||
|
}[]>;
|
||||||
|
analyseFull(pool: any): Promise<void>;
|
||||||
|
analyseIncremental(pool: any): Promise<void>;
|
||||||
|
}
|
3
lib/src/index.ts → types/index.d.ts
vendored
3
lib/src/index.ts → types/index.d.ts
vendored
@ -1,13 +1,12 @@
|
|||||||
|
/// <reference types="node" />
|
||||||
import { ChildProcess } from "child_process";
|
import { ChildProcess } from "child_process";
|
||||||
import { DatabaseInfo } from "./dbinfo";
|
import { DatabaseInfo } from "./dbinfo";
|
||||||
|
|
||||||
export interface OpenedDatabaseConnection {
|
export interface OpenedDatabaseConnection {
|
||||||
conid: string;
|
conid: string;
|
||||||
database: string;
|
database: string;
|
||||||
structure: DatabaseInfo;
|
structure: DatabaseInfo;
|
||||||
subprocess: ChildProcess;
|
subprocess: ChildProcess;
|
||||||
}
|
}
|
||||||
|
|
||||||
export * from "./engines";
|
export * from "./engines";
|
||||||
export * from "./dbinfo";
|
export * from "./dbinfo";
|
||||||
export * from "./query";
|
export * from "./query";
|
7
types/package.json
Normal file
7
types/package.json
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
{
|
||||||
|
"version": "0.1.0",
|
||||||
|
"name": "@types/dbgate",
|
||||||
|
"types": "index.d.ts",
|
||||||
|
"main": "",
|
||||||
|
"typeScriptVersion": "2.8"
|
||||||
|
}
|
3
types/query.d.ts
vendored
Normal file
3
types/query.d.ts
vendored
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
export interface QueryResult {
|
||||||
|
rows: any[];
|
||||||
|
}
|
@ -19,7 +19,6 @@
|
|||||||
"resize-observer-polyfill": "^1.5.1",
|
"resize-observer-polyfill": "^1.5.1",
|
||||||
"socket.io-client": "^2.3.0",
|
"socket.io-client": "^2.3.0",
|
||||||
"styled-components": "^4.4.1",
|
"styled-components": "^4.4.1",
|
||||||
"@dbgate/lib": "file:../lib",
|
|
||||||
"uuid": "^3.4.0"
|
"uuid": "^3.4.0"
|
||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
@ -46,6 +45,7 @@
|
|||||||
"@fortawesome/fontawesome-free": "^5.12.0",
|
"@fortawesome/fontawesome-free": "^5.12.0",
|
||||||
"@types/react": "^16.9.17",
|
"@types/react": "^16.9.17",
|
||||||
"@types/styled-components": "^4.4.2",
|
"@types/styled-components": "^4.4.2",
|
||||||
|
"@types/dbgate": "file:../lib",
|
||||||
"typescript": "^3.7.4"
|
"typescript": "^3.7.4"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -7,7 +7,7 @@ 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/lib').ColumnInfo} */
|
/** @param columnProps {import('dbgate').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;
|
||||||
|
@ -15,7 +15,7 @@ const WhitePage = styled.div`
|
|||||||
`;
|
`;
|
||||||
|
|
||||||
export default function TableStructureTab({ conid, database, schemaName, pureName }) {
|
export default function TableStructureTab({ conid, database, schemaName, pureName }) {
|
||||||
/** @type {import('@dbgate/lib').TableInfo} */
|
/** @type {import('dbgate').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 },
|
||||||
|
@ -21,6 +21,9 @@
|
|||||||
"forceConsistentCasingInFileNames": true,
|
"forceConsistentCasingInFileNames": true,
|
||||||
"resolveJsonModule": true,
|
"resolveJsonModule": true,
|
||||||
"isolatedModules": true,
|
"isolatedModules": true,
|
||||||
|
"types": [
|
||||||
|
"dbgate"
|
||||||
|
]
|
||||||
},
|
},
|
||||||
"include": [
|
"include": [
|
||||||
"src"
|
"src"
|
||||||
|
Loading…
Reference in New Issue
Block a user