dbgate-api 5.1.3 → 5.1.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dbgate-api",
|
|
3
3
|
"main": "src/index.js",
|
|
4
|
-
"version": "5.1.
|
|
4
|
+
"version": "5.1.4",
|
|
5
5
|
"homepage": "https://dbgate.org/",
|
|
6
6
|
"repository": {
|
|
7
7
|
"type": "git",
|
|
@@ -25,9 +25,9 @@
|
|
|
25
25
|
"compare-versions": "^3.6.0",
|
|
26
26
|
"cors": "^2.8.5",
|
|
27
27
|
"cross-env": "^6.0.3",
|
|
28
|
-
"dbgate-query-splitter": "^4.9.
|
|
29
|
-
"dbgate-sqltree": "^5.1.
|
|
30
|
-
"dbgate-tools": "^5.1.
|
|
28
|
+
"dbgate-query-splitter": "^4.9.2",
|
|
29
|
+
"dbgate-sqltree": "^5.1.4",
|
|
30
|
+
"dbgate-tools": "^5.1.4",
|
|
31
31
|
"debug": "^4.3.4",
|
|
32
32
|
"diff": "^5.0.0",
|
|
33
33
|
"diff2html": "^3.4.13",
|
|
@@ -65,7 +65,7 @@
|
|
|
65
65
|
"devDependencies": {
|
|
66
66
|
"@types/fs-extra": "^9.0.11",
|
|
67
67
|
"@types/lodash": "^4.14.149",
|
|
68
|
-
"dbgate-types": "^5.1.
|
|
68
|
+
"dbgate-types": "^5.1.4",
|
|
69
69
|
"env-cmd": "^10.1.0",
|
|
70
70
|
"node-loader": "^1.0.2",
|
|
71
71
|
"nodemon": "^2.0.2",
|
|
@@ -152,4 +152,13 @@ module.exports = {
|
|
|
152
152
|
opened.subprocess.send({ msgtype: 'createDatabase', name });
|
|
153
153
|
return { status: 'ok' };
|
|
154
154
|
},
|
|
155
|
+
|
|
156
|
+
dropDatabase_meta: true,
|
|
157
|
+
async dropDatabase({ conid, name }, req) {
|
|
158
|
+
testConnectionPermission(conid, req);
|
|
159
|
+
const opened = await this.ensureOpened(conid);
|
|
160
|
+
if (opened.connection.isReadOnly) return false;
|
|
161
|
+
opened.subprocess.send({ msgtype: 'dropDatabase', name });
|
|
162
|
+
return { status: 'ok' };
|
|
163
|
+
},
|
|
155
164
|
};
|
package/src/currentVersion.js
CHANGED
|
@@ -2,7 +2,6 @@ const stableStringify = require('json-stable-stringify');
|
|
|
2
2
|
const { extractBoolSettingsValue, extractIntSettingsValue } = require('dbgate-tools');
|
|
3
3
|
const childProcessChecker = require('../utility/childProcessChecker');
|
|
4
4
|
const requireEngineDriver = require('../utility/requireEngineDriver');
|
|
5
|
-
const { decryptConnection } = require('../utility/crypting');
|
|
6
5
|
const connectUtility = require('../utility/connectUtility');
|
|
7
6
|
const { handleProcessCommunication } = require('../utility/processComm');
|
|
8
7
|
|
|
@@ -81,14 +80,16 @@ function handlePing() {
|
|
|
81
80
|
lastPing = new Date().getTime();
|
|
82
81
|
}
|
|
83
82
|
|
|
84
|
-
async function
|
|
83
|
+
async function handleDatabaseOp(op, { name }) {
|
|
85
84
|
const driver = requireEngineDriver(storedConnection);
|
|
86
85
|
systemConnection = await connectUtility(driver, storedConnection, 'app');
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
await driver.createDatabase(systemConnection, name);
|
|
86
|
+
if (driver[op]) {
|
|
87
|
+
await driver[op](systemConnection, name);
|
|
90
88
|
} else {
|
|
91
|
-
|
|
89
|
+
const dmp = driver.createDumper();
|
|
90
|
+
dmp[op](name);
|
|
91
|
+
console.log(`RUNNING SCRIPT: ${dmp.s}`);
|
|
92
|
+
await driver.query(systemConnection, dmp.s);
|
|
92
93
|
}
|
|
93
94
|
await handleRefresh();
|
|
94
95
|
}
|
|
@@ -96,7 +97,8 @@ async function handleCreateDatabase({ name }) {
|
|
|
96
97
|
const messageHandlers = {
|
|
97
98
|
connect: handleConnect,
|
|
98
99
|
ping: handlePing,
|
|
99
|
-
createDatabase:
|
|
100
|
+
createDatabase: props => handleDatabaseOp('createDatabase', props),
|
|
101
|
+
dropDatabase: props => handleDatabaseOp('dropDatabase', props),
|
|
100
102
|
};
|
|
101
103
|
|
|
102
104
|
async function handleMessage({ msgtype, ...other }) {
|
|
@@ -47,7 +47,7 @@ async function importDatabase({ connection = undefined, systemConnection = undef
|
|
|
47
47
|
const downloadedFile = await download(inputFile);
|
|
48
48
|
|
|
49
49
|
const fileStream = fs.createReadStream(downloadedFile, 'utf-8');
|
|
50
|
-
const splittedStream = splitQueryStream(fileStream, driver.getQuerySplitterOptions());
|
|
50
|
+
const splittedStream = splitQueryStream(fileStream, driver.getQuerySplitterOptions('script'));
|
|
51
51
|
const importStream = new ImportStream(pool, driver);
|
|
52
52
|
// @ts-ignore
|
|
53
53
|
splittedStream.pipe(importStream);
|