dbgate-api-premium 6.5.1 → 6.5.2

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.2",
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.2",
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.2",
36
+ "dbgate-tools": "^6.5.2",
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.2",
89
89
  "env-cmd": "^10.1.0",
90
90
  "jsdoc-to-markdown": "^9.0.5",
91
91
  "node-loader": "^1.0.2",
@@ -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.2',
4
+ buildTime: '2025-06-18T09:02:31.307Z'
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;
@@ -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
  });