dbgate-api-premium 6.5.1 → 6.5.3

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-premium",
3
3
  "main": "src/index.js",
4
- "version": "6.5.1",
4
+ "version": "6.5.3",
5
5
  "homepage": "https://dbgate.org/",
6
6
  "repository": {
7
7
  "type": "git",
@@ -30,10 +30,10 @@
30
30
  "compare-versions": "^3.6.0",
31
31
  "cors": "^2.8.5",
32
32
  "cross-env": "^6.0.3",
33
- "dbgate-datalib": "^6.5.1",
33
+ "dbgate-datalib": "^6.5.3",
34
34
  "dbgate-query-splitter": "^4.11.5",
35
- "dbgate-sqltree": "^6.5.1",
36
- "dbgate-tools": "^6.5.1",
35
+ "dbgate-sqltree": "^6.5.3",
36
+ "dbgate-tools": "^6.5.3",
37
37
  "debug": "^4.3.4",
38
38
  "diff": "^5.0.0",
39
39
  "diff2html": "^3.4.13",
@@ -85,7 +85,7 @@
85
85
  "devDependencies": {
86
86
  "@types/fs-extra": "^9.0.11",
87
87
  "@types/lodash": "^4.14.149",
88
- "dbgate-types": "^6.5.1",
88
+ "dbgate-types": "^6.5.3",
89
89
  "env-cmd": "^10.1.0",
90
90
  "jsdoc-to-markdown": "^9.0.5",
91
91
  "node-loader": "^1.0.2",
@@ -142,6 +142,8 @@ module.exports = {
142
142
  const res = await createDbGateIdentitySession(client);
143
143
  startCloudTokenChecking(res.sid, tokenHolder => {
144
144
  socket.emit('got-cloud-token', tokenHolder);
145
+ socket.emitChanged('cloud-content-changed');
146
+ socket.emit('cloud-content-updated');
145
147
  });
146
148
  return res;
147
149
  },
@@ -313,19 +313,9 @@ module.exports = {
313
313
  return true;
314
314
  });
315
315
  processor.finalize();
316
- return processor.charts;
317
- },
318
-
319
- detectChartColumns_meta: true,
320
- async detectChartColumns({ jslid }) {
321
- const datastore = new JsonLinesDatastore(getJslFileName(jslid));
322
- const processor = new ChartProcessor();
323
- processor.autoDetectCharts = false;
324
- await datastore.enumRows(row => {
325
- processor.addRow(row);
326
- return true;
327
- });
328
- processor.finalize();
329
- return processor.availableColumns;
316
+ return {
317
+ charts: processor.charts,
318
+ columns: processor.availableColumns,
319
+ };
330
320
  },
331
321
  };
@@ -146,7 +146,7 @@ module.exports = {
146
146
  },
147
147
 
148
148
  executeQuery_meta: true,
149
- async executeQuery({ sesid, sql, autoCommit, limitRows, frontMatter }) {
149
+ async executeQuery({ sesid, sql, autoCommit, autoDetectCharts, limitRows, frontMatter }) {
150
150
  const session = this.opened.find(x => x.sesid == sesid);
151
151
  if (!session) {
152
152
  throw new Error('Invalid session');
@@ -154,7 +154,14 @@ module.exports = {
154
154
 
155
155
  logger.info({ sesid, sql }, 'Processing query');
156
156
  this.dispatchMessage(sesid, 'Query execution started');
157
- session.subprocess.send({ msgtype: 'executeQuery', sql, autoCommit, limitRows, frontMatter });
157
+ session.subprocess.send({
158
+ msgtype: 'executeQuery',
159
+ sql,
160
+ autoCommit,
161
+ autoDetectCharts: autoDetectCharts || !!frontMatter?.['selected-chart'],
162
+ limitRows,
163
+ frontMatter,
164
+ });
158
165
 
159
166
  return { state: 'ok' };
160
167
  },
@@ -1,5 +1,5 @@
1
1
 
2
2
  module.exports = {
3
- version: '6.5.1',
4
- buildTime: '2025-06-17T14:10:23.880Z'
3
+ version: '6.5.3',
4
+ buildTime: '2025-06-20T13:03:33.111Z'
5
5
  };
@@ -117,7 +117,7 @@ async function handleExecuteControlCommand({ command }) {
117
117
  }
118
118
  }
119
119
 
120
- async function handleExecuteQuery({ sql, autoCommit, limitRows, frontMatter }) {
120
+ async function handleExecuteQuery({ sql, autoCommit, autoDetectCharts, limitRows, frontMatter }) {
121
121
  lastActivity = new Date().getTime();
122
122
 
123
123
  await waitConnected();
@@ -146,7 +146,16 @@ async function handleExecuteQuery({ sql, autoCommit, limitRows, frontMatter }) {
146
146
  ...driver.getQuerySplitterOptions('stream'),
147
147
  returnRichInfo: true,
148
148
  })) {
149
- await handleQueryStream(dbhan, driver, queryStreamInfoHolder, sqlItem, undefined, limitRows, frontMatter);
149
+ await handleQueryStream(
150
+ dbhan,
151
+ driver,
152
+ queryStreamInfoHolder,
153
+ sqlItem,
154
+ undefined,
155
+ limitRows,
156
+ frontMatter,
157
+ autoDetectCharts
158
+ );
150
159
  // const handler = new StreamHandler(resultIndex);
151
160
  // const stream = await driver.stream(systemConnection, sqlItem, handler);
152
161
  // handler.stream = stream;
@@ -33,18 +33,25 @@ const licenseTypeById = {
33
33
  isForApp: true,
34
34
  },
35
35
  '9682a88b-909f-48b1-adbf-c03622884421': {
36
- name: 'Team Premium',
36
+ // old Team Premium, now Academic
37
+ name: 'Academic',
37
38
  isPremium: true,
38
39
  isForWeb: true,
39
40
  isForApp: true,
40
41
  },
41
42
  '81456363-f167-41e3-9496-b540f4b0c150': {
42
- name: 'Premium Trial',
43
+ name: 'Trial',
43
44
  isPremium: true,
44
45
  isForWeb: true,
45
46
  isForApp: true,
46
47
  isTrial: true,
47
48
  },
49
+ 'f0346efe-ebc2-4822-9a83-4b4668a897e5': {
50
+ name: 'Team Premium',
51
+ isPremium: true,
52
+ isForWeb: true,
53
+ isForApp: true,
54
+ },
48
55
  };
49
56
 
50
57
  function getLicenseByDecoded(decoded) {
@@ -4,6 +4,7 @@ const { getSshTunnelProxy } = require('./sshTunnelProxy');
4
4
  const platformInfo = require('../utility/platformInfo');
5
5
  const connections = require('../controllers/connections');
6
6
  const _ = require('lodash');
7
+ const { getCloudFolderEncryptor } = require('./cloudIntf');
7
8
 
8
9
  async function loadConnection(driver, storedConnection, connectionMode) {
9
10
  const { allowShellConnection, allowConnectionFromEnvVariables } = platformInfo;
@@ -88,13 +89,31 @@ async function extractConnectionSslParams(connection) {
88
89
  return ssl;
89
90
  }
90
91
 
92
+ async function decryptCloudConnection(connection) {
93
+ const m = connection?._id?.match(/^cloud\:\/\/(.+)\/(.+)$/);
94
+ if (!m) {
95
+ throw new Error('Invalid cloud connection ID format');
96
+ }
97
+
98
+ const folid = m[1];
99
+ const cntid = m[2];
100
+
101
+ const folderEncryptor = await getCloudFolderEncryptor(folid);
102
+ return decryptConnection(connection, folderEncryptor);
103
+ }
104
+
91
105
  async function connectUtility(driver, storedConnection, connectionMode, additionalOptions = null) {
92
106
  const connectionLoaded = await loadConnection(driver, storedConnection, connectionMode);
93
107
 
94
- const connection = {
95
- database: connectionLoaded.defaultDatabase,
96
- ...decryptConnection(connectionLoaded),
97
- };
108
+ const connection = connectionLoaded?._id?.startsWith('cloud://')
109
+ ? {
110
+ database: connectionLoaded.defaultDatabase,
111
+ ...(await decryptCloudConnection(connectionLoaded)),
112
+ }
113
+ : {
114
+ database: connectionLoaded.defaultDatabase,
115
+ ...decryptConnection(connectionLoaded),
116
+ };
98
117
 
99
118
  if (!connection.port && driver.defaultPort) {
100
119
  connection.port = driver.defaultPort.toString();
@@ -91,11 +91,11 @@ function encryptObjectPasswordField(obj, field, encryptor = null) {
91
91
  return obj;
92
92
  }
93
93
 
94
- function decryptObjectPasswordField(obj, field) {
94
+ function decryptObjectPasswordField(obj, field, encryptor = null) {
95
95
  if (obj && obj[field] && obj[field].startsWith('crypt:')) {
96
96
  return {
97
97
  ...obj,
98
- [field]: getInternalEncryptor().decrypt(obj[field].substring('crypt:'.length)),
98
+ [field]: (encryptor || getInternalEncryptor()).decrypt(obj[field].substring('crypt:'.length)),
99
99
  };
100
100
  }
101
101
  return obj;
@@ -115,10 +115,10 @@ function maskConnection(connection) {
115
115
  return _.omit(connection, ['password', 'sshPassword', 'sshKeyfilePassword']);
116
116
  }
117
117
 
118
- function decryptConnection(connection) {
119
- connection = decryptObjectPasswordField(connection, 'password');
120
- connection = decryptObjectPasswordField(connection, 'sshPassword');
121
- connection = decryptObjectPasswordField(connection, 'sshKeyfilePassword');
118
+ function decryptConnection(connection, encryptor = null) {
119
+ connection = decryptObjectPasswordField(connection, 'password', encryptor);
120
+ connection = decryptObjectPasswordField(connection, 'sshPassword', encryptor);
121
+ connection = decryptObjectPasswordField(connection, 'sshKeyfilePassword', encryptor);
122
122
  return connection;
123
123
  }
124
124
 
@@ -14,13 +14,9 @@ class QueryStreamTableWriter {
14
14
  this.currentChangeIndex = 1;
15
15
  this.initializedFile = false;
16
16
  this.sesid = sesid;
17
- // if (isProApp()) {
18
- // this.chartProcessor = new ChartProcessor();
19
- // }
20
- this.chartProcessor = new ChartProcessor();
21
17
  }
22
18
 
23
- initializeFromQuery(structure, resultIndex, chartDefinition) {
19
+ initializeFromQuery(structure, resultIndex, chartDefinition, autoDetectCharts = false) {
24
20
  this.jslid = crypto.randomUUID();
25
21
  this.currentFile = path.join(jsldir(), `${this.jslid}.jsonl`);
26
22
  fs.writeFileSync(
@@ -34,8 +30,8 @@ class QueryStreamTableWriter {
34
30
  this.writeCurrentStats(false, false);
35
31
  this.resultIndex = resultIndex;
36
32
  this.initializedFile = true;
37
- if (isProApp() && chartDefinition) {
38
- this.chartProcessor = new ChartProcessor([chartDefinition]);
33
+ if (isProApp() && (chartDefinition || autoDetectCharts)) {
34
+ this.chartProcessor = chartDefinition ? new ChartProcessor([chartDefinition]) : new ChartProcessor();
39
35
  }
40
36
  process.send({ msgtype: 'recordset', jslid: this.jslid, resultIndex, sesid: this.sesid });
41
37
  }
@@ -138,12 +134,14 @@ class StreamHandler {
138
134
  startLine,
139
135
  sesid = undefined,
140
136
  limitRows = undefined,
141
- frontMatter = undefined
137
+ frontMatter = undefined,
138
+ autoDetectCharts = false
142
139
  ) {
143
140
  this.recordset = this.recordset.bind(this);
144
141
  this.startLine = startLine;
145
142
  this.sesid = sesid;
146
143
  this.frontMatter = frontMatter;
144
+ this.autoDetectCharts = autoDetectCharts;
147
145
  this.limitRows = limitRows;
148
146
  this.rowsLimitOverflow = false;
149
147
  this.row = this.row.bind(this);
@@ -177,7 +175,8 @@ class StreamHandler {
177
175
  this.currentWriter.initializeFromQuery(
178
176
  Array.isArray(columns) ? { columns } : columns,
179
177
  this.queryStreamInfoHolder.resultIndex,
180
- this.frontMatter?.[`chart-${this.queryStreamInfoHolder.resultIndex + 1}`]
178
+ this.frontMatter?.[`chart-${this.queryStreamInfoHolder.resultIndex + 1}`],
179
+ this.autoDetectCharts
181
180
  );
182
181
  this.queryStreamInfoHolder.resultIndex += 1;
183
182
  this.rowCounter = 0;
@@ -252,7 +251,8 @@ function handleQueryStream(
252
251
  sqlItem,
253
252
  sesid = undefined,
254
253
  limitRows = undefined,
255
- frontMatter = undefined
254
+ frontMatter = undefined,
255
+ autoDetectCharts = false
256
256
  ) {
257
257
  return new Promise((resolve, reject) => {
258
258
  const start = sqlItem.trimStart || sqlItem.start;
@@ -262,7 +262,8 @@ function handleQueryStream(
262
262
  start && start.line,
263
263
  sesid,
264
264
  limitRows,
265
- frontMatter
265
+ frontMatter,
266
+ autoDetectCharts
266
267
  );
267
268
  driver.stream(dbhan, sqlItem.text, handler);
268
269
  });