dbgate-api 4.5.1 → 4.6.0

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": "4.5.1",
4
+ "version": "4.6.0",
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.5.1",
29
- "dbgate-sqltree": "^4.5.1",
30
- "dbgate-tools": "^4.5.1",
28
+ "dbgate-query-splitter": "^4.6.0",
29
+ "dbgate-sqltree": "^4.6.0",
30
+ "dbgate-tools": "^4.6.0",
31
31
  "diff": "^5.0.0",
32
32
  "diff2html": "^3.4.13",
33
33
  "eslint": "^6.8.0",
@@ -64,7 +64,7 @@
64
64
  "devDependencies": {
65
65
  "@types/fs-extra": "^9.0.11",
66
66
  "@types/lodash": "^4.14.149",
67
- "dbgate-types": "^4.5.1",
67
+ "dbgate-types": "^4.6.0",
68
68
  "env-cmd": "^10.1.0",
69
69
  "node-loader": "^1.0.2",
70
70
  "nodemon": "^2.0.2",
@@ -6,6 +6,7 @@ const getChartExport = require('../utility/getChartExport');
6
6
  const hasPermission = require('../utility/hasPermission');
7
7
  const socket = require('../utility/socket');
8
8
  const scheduler = require('./scheduler');
9
+ const getDiagramExport = require('../utility/getDiagramExport');
9
10
 
10
11
  function serialize(format, data) {
11
12
  if (format == 'text') return data;
@@ -86,8 +87,9 @@ module.exports = {
86
87
  const dir = resolveArchiveFolder(folder.substring('archive:'.length));
87
88
  await fs.writeFile(path.join(dir, file), serialize(format, data));
88
89
  socket.emitChanged(`archive-files-changed-${folder.substring('archive:'.length)}`);
90
+ return true;
89
91
  } else {
90
- if (!hasPermission(`files/${folder}/write`)) return;
92
+ if (!hasPermission(`files/${folder}/write`)) return false;
91
93
  const dir = path.join(filesdir(), folder);
92
94
  if (!(await fs.exists(dir))) {
93
95
  await fs.mkdir(dir);
@@ -98,6 +100,7 @@ module.exports = {
98
100
  if (folder == 'shell') {
99
101
  scheduler.reload();
100
102
  }
103
+ return true;
101
104
  }
102
105
  },
103
106
 
@@ -150,4 +153,10 @@ module.exports = {
150
153
  }
151
154
  return true;
152
155
  },
156
+
157
+ exportDiagram_meta: true,
158
+ async exportDiagram({ filePath, html, css, themeType, themeClassName }) {
159
+ await fs.writeFile(filePath, getDiagramExport(html, css, themeType, themeClassName));
160
+ return true;
161
+ },
153
162
  };
@@ -1,5 +1,5 @@
1
1
 
2
2
  module.exports = {
3
- version: '4.5.1',
4
- buildTime: '2022-01-06T12:53:17.733Z'
3
+ version: '4.6.0',
4
+ buildTime: '2022-01-26T16:57:37.630Z'
5
5
  };
@@ -0,0 +1,25 @@
1
+ const getDiagramExport = (html, css, themeType, themeClassName) => {
2
+ return `<html>
3
+ <meta charset='utf-8'>
4
+
5
+ <head>
6
+ <style>
7
+ ${css}
8
+
9
+ body {
10
+ background: var(--theme-bg-1);
11
+ color: var(--theme-font-1);
12
+ }
13
+ </style>
14
+
15
+ <link rel="stylesheet" href='https://cdn.jsdelivr.net/npm/@mdi/font@6.5.95/css/materialdesignicons.css' />
16
+ </head>
17
+
18
+ <body class='${themeType == 'dark' ? 'theme-type-dark' : 'theme-type-light'} ${themeClassName}'>
19
+ ${html}
20
+ </body>
21
+
22
+ </html>`;
23
+ };
24
+
25
+ module.exports = getDiagramExport;