dbgate-api 5.0.3 → 5.0.4-alpha.8
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.0.
|
|
4
|
+
"version": "5.0.4-alpha.8",
|
|
5
5
|
"homepage": "https://dbgate.org/",
|
|
6
6
|
"repository": {
|
|
7
7
|
"type": "git",
|
|
@@ -26,8 +26,8 @@
|
|
|
26
26
|
"cors": "^2.8.5",
|
|
27
27
|
"cross-env": "^6.0.3",
|
|
28
28
|
"dbgate-query-splitter": "^4.9.0",
|
|
29
|
-
"dbgate-sqltree": "^5.0.
|
|
30
|
-
"dbgate-tools": "^5.0.
|
|
29
|
+
"dbgate-sqltree": "^5.0.4-alpha.8",
|
|
30
|
+
"dbgate-tools": "^5.0.4-alpha.8",
|
|
31
31
|
"diff": "^5.0.0",
|
|
32
32
|
"diff2html": "^3.4.13",
|
|
33
33
|
"eslint": "^6.8.0",
|
|
@@ -52,18 +52,18 @@
|
|
|
52
52
|
"uuid": "^3.4.0"
|
|
53
53
|
},
|
|
54
54
|
"scripts": {
|
|
55
|
-
"start": "env-cmd node src/index.js",
|
|
56
|
-
"start:portal": "env-cmd -f env/portal/.env node src/index.js",
|
|
57
|
-
"start:singledb": "env-cmd -f env/singledb/.env node src/index.js",
|
|
58
|
-
"start:filedb": "env-cmd node src/index.js /home/jena/test/chinook/Chinook.db",
|
|
59
|
-
"start:singleconn": "env-cmd node src/index.js --server localhost --user root --port 3307 --engine mysql@dbgate-plugin-mysql --password test",
|
|
55
|
+
"start": "env-cmd node src/index.js --listen-api",
|
|
56
|
+
"start:portal": "env-cmd -f env/portal/.env node src/index.js --listen-api",
|
|
57
|
+
"start:singledb": "env-cmd -f env/singledb/.env node src/index.js --listen-api",
|
|
58
|
+
"start:filedb": "env-cmd node src/index.js /home/jena/test/chinook/Chinook.db --listen-api",
|
|
59
|
+
"start:singleconn": "env-cmd node src/index.js --server localhost --user root --port 3307 --engine mysql@dbgate-plugin-mysql --password test --listen-api",
|
|
60
60
|
"ts": "tsc",
|
|
61
61
|
"build": "webpack"
|
|
62
62
|
},
|
|
63
63
|
"devDependencies": {
|
|
64
64
|
"@types/fs-extra": "^9.0.11",
|
|
65
65
|
"@types/lodash": "^4.14.149",
|
|
66
|
-
"dbgate-types": "^5.0.
|
|
66
|
+
"dbgate-types": "^5.0.4-alpha.8",
|
|
67
67
|
"env-cmd": "^10.1.0",
|
|
68
68
|
"node-loader": "^1.0.2",
|
|
69
69
|
"nodemon": "^2.0.2",
|
|
@@ -1,11 +1,8 @@
|
|
|
1
1
|
const fs = require('fs-extra');
|
|
2
|
-
const stream = require('stream');
|
|
3
2
|
const readline = require('readline');
|
|
4
3
|
const path = require('path');
|
|
5
|
-
const { formatWithOptions } = require('util');
|
|
6
4
|
const { archivedir, clearArchiveLinksCache, resolveArchiveFolder } = require('../utility/directories');
|
|
7
5
|
const socket = require('../utility/socket');
|
|
8
|
-
const JsonLinesDatastore = require('../utility/JsonLinesDatastore');
|
|
9
6
|
const { saveFreeTableData } = require('../utility/freeTableStorage');
|
|
10
7
|
const loadFilesRecursive = require('../utility/loadFilesRecursive');
|
|
11
8
|
|
|
@@ -45,29 +42,34 @@ module.exports = {
|
|
|
45
42
|
|
|
46
43
|
files_meta: true,
|
|
47
44
|
async files({ folder }) {
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
name
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
45
|
+
try {
|
|
46
|
+
const dir = resolveArchiveFolder(folder);
|
|
47
|
+
if (!(await fs.exists(dir))) return [];
|
|
48
|
+
const files = await loadFilesRecursive(dir); // fs.readdir(dir);
|
|
49
|
+
|
|
50
|
+
function fileType(ext, type) {
|
|
51
|
+
return files
|
|
52
|
+
.filter(name => name.endsWith(ext))
|
|
53
|
+
.map(name => ({
|
|
54
|
+
name: name.slice(0, -ext.length),
|
|
55
|
+
label: path.parse(name.slice(0, -ext.length)).base,
|
|
56
|
+
type,
|
|
57
|
+
}));
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
return [
|
|
61
|
+
...fileType('.jsonl', 'jsonl'),
|
|
62
|
+
...fileType('.table.yaml', 'table.yaml'),
|
|
63
|
+
...fileType('.view.sql', 'view.sql'),
|
|
64
|
+
...fileType('.proc.sql', 'proc.sql'),
|
|
65
|
+
...fileType('.func.sql', 'func.sql'),
|
|
66
|
+
...fileType('.trigger.sql', 'trigger.sql'),
|
|
67
|
+
...fileType('.matview.sql', 'matview.sql'),
|
|
68
|
+
];
|
|
69
|
+
} catch (err) {
|
|
70
|
+
console.log('Error reading archive files', err.message);
|
|
71
|
+
return [];
|
|
60
72
|
}
|
|
61
|
-
|
|
62
|
-
return [
|
|
63
|
-
...fileType('.jsonl', 'jsonl'),
|
|
64
|
-
...fileType('.table.yaml', 'table.yaml'),
|
|
65
|
-
...fileType('.view.sql', 'view.sql'),
|
|
66
|
-
...fileType('.proc.sql', 'proc.sql'),
|
|
67
|
-
...fileType('.func.sql', 'func.sql'),
|
|
68
|
-
...fileType('.trigger.sql', 'trigger.sql'),
|
|
69
|
-
...fileType('.matview.sql', 'matview.sql'),
|
|
70
|
-
];
|
|
71
73
|
},
|
|
72
74
|
|
|
73
75
|
refreshFiles_meta: true,
|
package/src/controllers/files.js
CHANGED
|
@@ -8,6 +8,7 @@ const socket = require('../utility/socket');
|
|
|
8
8
|
const scheduler = require('./scheduler');
|
|
9
9
|
const getDiagramExport = require('../utility/getDiagramExport');
|
|
10
10
|
const apps = require('./apps');
|
|
11
|
+
const getMapExport = require('../utility/getMapExport');
|
|
11
12
|
|
|
12
13
|
function serialize(format, data) {
|
|
13
14
|
if (format == 'text') return data;
|
|
@@ -187,6 +188,12 @@ module.exports = {
|
|
|
187
188
|
return true;
|
|
188
189
|
},
|
|
189
190
|
|
|
191
|
+
exportMap_meta: true,
|
|
192
|
+
async exportMap({ filePath, geoJson }) {
|
|
193
|
+
await fs.writeFile(filePath, getMapExport(geoJson));
|
|
194
|
+
return true;
|
|
195
|
+
},
|
|
196
|
+
|
|
190
197
|
exportDiagram_meta: true,
|
|
191
198
|
async exportDiagram({ filePath, html, css, themeType, themeClassName }) {
|
|
192
199
|
await fs.writeFile(filePath, getDiagramExport(html, css, themeType, themeClassName));
|
package/src/currentVersion.js
CHANGED
package/src/index.js
CHANGED
|
@@ -8,9 +8,10 @@ if (processArgs.startProcess) {
|
|
|
8
8
|
const proc = require('./proc');
|
|
9
9
|
const module = proc[processArgs.startProcess];
|
|
10
10
|
module.start();
|
|
11
|
-
}
|
|
12
|
-
const main = require('./main');
|
|
11
|
+
}
|
|
13
12
|
|
|
13
|
+
if (processArgs.listenApi) {
|
|
14
|
+
const main = require('./main');
|
|
14
15
|
main.start();
|
|
15
16
|
}
|
|
16
17
|
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
const getMapExport = (geoJson) => {
|
|
2
|
+
return `<html>
|
|
3
|
+
<meta charset='utf-8'>
|
|
4
|
+
|
|
5
|
+
<head>
|
|
6
|
+
<link rel="stylesheet" href="https://unpkg.com/leaflet@1.8.0/dist/leaflet.css"
|
|
7
|
+
integrity="sha512-hoalWLoI8r4UszCkZ5kL8vayOGVae1oxXe/2A4AO6J9+580uKHDO3JdHb7NzwwzK5xr/Fs0W40kiNHxM9vyTtQ=="
|
|
8
|
+
crossorigin=""/>
|
|
9
|
+
|
|
10
|
+
<script src="https://unpkg.com/leaflet@1.8.0/dist/leaflet.js"
|
|
11
|
+
integrity="sha512-BB3hKbKWOc9Ez/TAwyWxNXeoV9c1v6FIeYiBieIWkpLjauysF18NzgR1MBNBXf8/KABdlkX68nAhlwcDFLGPCQ=="
|
|
12
|
+
crossorigin=""></script>
|
|
13
|
+
|
|
14
|
+
<script>
|
|
15
|
+
function createMap() {
|
|
16
|
+
map = leaflet.map('map').setView([50, 15], 13);
|
|
17
|
+
|
|
18
|
+
leaflet
|
|
19
|
+
.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {
|
|
20
|
+
maxZoom: 19,
|
|
21
|
+
attribution: '<a href="https://dbgate.org" title="Exported from DbGate">DbGate</a> | © OpenStreetMap',
|
|
22
|
+
})
|
|
23
|
+
.addTo(map);
|
|
24
|
+
|
|
25
|
+
const geoJsonObj = leaflet
|
|
26
|
+
.geoJSON(${JSON.stringify(geoJson)}, {
|
|
27
|
+
style: function () {
|
|
28
|
+
return {
|
|
29
|
+
weight: 2,
|
|
30
|
+
fillColor: '#ff7800',
|
|
31
|
+
color: '#ff7800',
|
|
32
|
+
opacity: 0.8,
|
|
33
|
+
fillOpacity: 0.4,
|
|
34
|
+
};
|
|
35
|
+
},
|
|
36
|
+
pointToLayer: (feature, latlng) => {
|
|
37
|
+
return leaflet.circleMarker(latlng, {
|
|
38
|
+
radius: 7,
|
|
39
|
+
weight: 2,
|
|
40
|
+
fillColor: '#ff0000',
|
|
41
|
+
color: '#ff0000',
|
|
42
|
+
opacity: 0.9,
|
|
43
|
+
fillOpacity: 0.9,
|
|
44
|
+
});
|
|
45
|
+
},
|
|
46
|
+
onEachFeature: (feature, layer) => {
|
|
47
|
+
// does this feature have a property named popupContent?
|
|
48
|
+
if (feature.properties && feature.properties.popupContent) {
|
|
49
|
+
layer.bindPopup(feature.properties.popupContent);
|
|
50
|
+
layer.bindTooltip(feature.properties.popupContent);
|
|
51
|
+
}
|
|
52
|
+
},
|
|
53
|
+
})
|
|
54
|
+
.addTo(map);
|
|
55
|
+
map.fitBounds(geoJsonObj.getBounds());
|
|
56
|
+
}
|
|
57
|
+
</script>
|
|
58
|
+
|
|
59
|
+
<style>
|
|
60
|
+
#map {
|
|
61
|
+
position: fixed;
|
|
62
|
+
left: 0;
|
|
63
|
+
top: 0;
|
|
64
|
+
right: 0;
|
|
65
|
+
bottom: 0;
|
|
66
|
+
}
|
|
67
|
+
</style>
|
|
68
|
+
</head>
|
|
69
|
+
|
|
70
|
+
<body onload='createMap()'>
|
|
71
|
+
<div id='map'></div>
|
|
72
|
+
</body>
|
|
73
|
+
|
|
74
|
+
</html>`;
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
module.exports = getMapExport;
|
|
@@ -39,8 +39,8 @@ const platformInfo = {
|
|
|
39
39
|
environment: process.env.NODE_ENV,
|
|
40
40
|
platform,
|
|
41
41
|
runningInWebpack: !!process.env.WEBPACK_DEV_SERVER_URL,
|
|
42
|
-
allowShellConnection: !!process.env.SHELL_CONNECTION || !!isElectron(),
|
|
43
|
-
allowShellScripting: !!process.env.SHELL_SCRIPTING || !!isElectron(),
|
|
42
|
+
allowShellConnection: !processArgs.listenApiChild || !!process.env.SHELL_CONNECTION || !!isElectron(),
|
|
43
|
+
allowShellScripting: !processArgs.listenApiChild || !!process.env.SHELL_SCRIPTING || !!isElectron(),
|
|
44
44
|
defaultKeyfile: path.join(os.homedir(), '.ssh/id_rsa'),
|
|
45
45
|
};
|
|
46
46
|
|
|
@@ -11,6 +11,8 @@ const startProcess = getNamedArg('--start-process');
|
|
|
11
11
|
const isForkedApi = process.argv.includes('--is-forked-api');
|
|
12
12
|
const pluginsDir = getNamedArg('--plugins-dir');
|
|
13
13
|
const workspaceDir = getNamedArg('--workspace-dir');
|
|
14
|
+
const listenApi = process.argv.includes('--listen-api');
|
|
15
|
+
const listenApiChild = process.argv.includes('--listen-api-child') || listenApi;
|
|
14
16
|
|
|
15
17
|
function getPassArgs() {
|
|
16
18
|
const res = [];
|
|
@@ -20,6 +22,9 @@ function getPassArgs() {
|
|
|
20
22
|
if (global['PLUGINS_DIR']) {
|
|
21
23
|
res.push('--plugins-dir', global['PLUGINS_DIR']);
|
|
22
24
|
}
|
|
25
|
+
if (listenApiChild) {
|
|
26
|
+
res.push('listen-api-child');
|
|
27
|
+
}
|
|
23
28
|
return res;
|
|
24
29
|
}
|
|
25
30
|
|
|
@@ -30,4 +35,6 @@ module.exports = {
|
|
|
30
35
|
getPassArgs,
|
|
31
36
|
pluginsDir,
|
|
32
37
|
workspaceDir,
|
|
38
|
+
listenApi,
|
|
39
|
+
listenApiChild,
|
|
33
40
|
};
|