dbgate-api 5.5.4-alpha.3 → 5.5.4-alpha.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.5.4-alpha.3",
4
+ "version": "5.5.4-alpha.4",
5
5
  "homepage": "https://dbgate.org/",
6
6
  "repository": {
7
7
  "type": "git",
@@ -26,10 +26,10 @@
26
26
  "compare-versions": "^3.6.0",
27
27
  "cors": "^2.8.5",
28
28
  "cross-env": "^6.0.3",
29
- "dbgate-datalib": "^5.5.4-alpha.3",
29
+ "dbgate-datalib": "^5.5.4-alpha.4",
30
30
  "dbgate-query-splitter": "^4.10.5",
31
- "dbgate-sqltree": "^5.5.4-alpha.3",
32
- "dbgate-tools": "^5.5.4-alpha.3",
31
+ "dbgate-sqltree": "^5.5.4-alpha.4",
32
+ "dbgate-tools": "^5.5.4-alpha.4",
33
33
  "debug": "^4.3.4",
34
34
  "diff": "^5.0.0",
35
35
  "diff2html": "^3.4.13",
@@ -75,7 +75,7 @@
75
75
  "devDependencies": {
76
76
  "@types/fs-extra": "^9.0.11",
77
77
  "@types/lodash": "^4.14.149",
78
- "dbgate-types": "^5.5.4-alpha.3",
78
+ "dbgate-types": "^5.5.4-alpha.4",
79
79
  "env-cmd": "^10.1.0",
80
80
  "node-loader": "^1.0.2",
81
81
  "nodemon": "^2.0.2",
@@ -6,7 +6,7 @@ const { archivedir, clearArchiveLinksCache, resolveArchiveFolder } = require('..
6
6
  const socket = require('../utility/socket');
7
7
  const loadFilesRecursive = require('../utility/loadFilesRecursive');
8
8
  const getJslFileName = require('../utility/getJslFileName');
9
- const { getLogger } = require('dbgate-tools');
9
+ const { getLogger, extractErrorLogData } = require('dbgate-tools');
10
10
  const dbgateApi = require('../shell');
11
11
  const jsldata = require('./jsldata');
12
12
  const platformInfo = require('../utility/platformInfo');
@@ -74,7 +74,7 @@ module.exports = {
74
74
  ...fileType('.matview.sql', 'matview.sql'),
75
75
  ];
76
76
  } catch (err) {
77
- logger.error({ err }, 'Error reading archive files');
77
+ logger.error(extractErrorLogData(err), 'Error reading archive files');
78
78
  return [];
79
79
  }
80
80
  },
@@ -1,7 +1,7 @@
1
1
  const axios = require('axios');
2
2
  const jwt = require('jsonwebtoken');
3
3
  const getExpressPath = require('../utility/getExpressPath');
4
- const { getLogger } = require('dbgate-tools');
4
+ const { getLogger, extractErrorLogData } = require('dbgate-tools');
5
5
  const AD = require('activedirectory2').promiseWrapper;
6
6
  const crypto = require('crypto');
7
7
  const { getTokenSecret, getTokenLifetime } = require('../auth/authCommon');
@@ -71,7 +71,7 @@ function authMiddleware(req, res, next) {
71
71
  return next();
72
72
  }
73
73
 
74
- logger.error({ err }, 'Sending invalid token error');
74
+ logger.error(extractErrorLogData(err), 'Sending invalid token error');
75
75
 
76
76
  return unauthorizedResponse(req, res, 'invalid token');
77
77
  }
@@ -12,7 +12,7 @@ const { pickSafeConnectionInfo } = require('../utility/crypting');
12
12
  const JsonLinesDatabase = require('../utility/JsonLinesDatabase');
13
13
 
14
14
  const processArgs = require('../utility/processArgs');
15
- const { safeJsonParse, getLogger } = require('dbgate-tools');
15
+ const { safeJsonParse, getLogger, extractErrorLogData } = require('dbgate-tools');
16
16
  const platformInfo = require('../utility/platformInfo');
17
17
  const { connectionHasPermission, testConnectionPermission } = require('../utility/hasPermission');
18
18
  const pipeForkLogs = require('../utility/pipeForkLogs');
@@ -430,7 +430,7 @@ module.exports = {
430
430
  socket.emit('got-volatile-token', { strmid, savedConId: conid, volatileConId: volatile._id });
431
431
  return { success: true };
432
432
  } catch (err) {
433
- logger.error({ err }, 'Error getting DB token');
433
+ logger.error(extractErrorLogData(err), 'Error getting DB token');
434
434
  return { error: err.message };
435
435
  }
436
436
  },
@@ -446,7 +446,7 @@ module.exports = {
446
446
  const resp = await authProvider.login(null, null, { conid: volatile._id });
447
447
  return resp;
448
448
  } catch (err) {
449
- logger.error({ err }, 'Error getting DB token');
449
+ logger.error(extractErrorLogData(err), 'Error getting DB token');
450
450
  return { error: err.message };
451
451
  }
452
452
  },
@@ -12,6 +12,7 @@ const {
12
12
  extendDatabaseInfo,
13
13
  modelCompareDbDiffOptions,
14
14
  getLogger,
15
+ extractErrorLogData,
15
16
  } = require('dbgate-tools');
16
17
  const { html, parse } = require('diff2html');
17
18
  const { handleProcessCommunication } = require('../utility/processComm');
@@ -146,7 +147,7 @@ module.exports = {
146
147
  try {
147
148
  conn.subprocess.send({ msgid, ...message });
148
149
  } catch (err) {
149
- logger.error({ err }, 'Error sending request do process');
150
+ logger.error(extractErrorLogData(err), 'Error sending request do process');
150
151
  this.close(conn.conid, conn.database);
151
152
  }
152
153
  });
@@ -318,7 +319,7 @@ module.exports = {
318
319
  try {
319
320
  existing.subprocess.send({ msgtype: 'ping' });
320
321
  } catch (err) {
321
- logger.error({ err }, 'Error pinging DB connection');
322
+ logger.error(extractErrorLogData(err), 'Error pinging DB connection');
322
323
  this.close(conid, database);
323
324
 
324
325
  return {
@@ -362,7 +363,7 @@ module.exports = {
362
363
  try {
363
364
  existing.subprocess.kill();
364
365
  } catch (err) {
365
- logger.error({ err }, 'Error killing subprocess');
366
+ logger.error(extractErrorLogData(err), 'Error killing subprocess');
366
367
  }
367
368
  }
368
369
  this.opened = this.opened.filter(x => x.conid != conid || x.database != database);
@@ -11,7 +11,7 @@ const processArgs = require('../utility/processArgs');
11
11
  const { testConnectionPermission } = require('../utility/hasPermission');
12
12
  const { MissingCredentialsError } = require('../utility/exceptions');
13
13
  const pipeForkLogs = require('../utility/pipeForkLogs');
14
- const { getLogger } = require('dbgate-tools');
14
+ const { getLogger, extractErrorLogData } = require('dbgate-tools');
15
15
 
16
16
  const logger = getLogger('serverConnection');
17
17
 
@@ -112,7 +112,7 @@ module.exports = {
112
112
  try {
113
113
  existing.subprocess.kill();
114
114
  } catch (err) {
115
- logger.error({ err }, 'Error killing subprocess');
115
+ logger.error(extractErrorLogData(err), 'Error killing subprocess');
116
116
  }
117
117
  }
118
118
  this.opened = this.opened.filter(x => x.conid != conid);
@@ -167,7 +167,7 @@ module.exports = {
167
167
  try {
168
168
  opened.subprocess.send({ msgtype: 'ping' });
169
169
  } catch (err) {
170
- logger.error({ err }, 'Error pinging server connection');
170
+ logger.error(extractErrorLogData(err), 'Error pinging server connection');
171
171
  this.close(conid);
172
172
  }
173
173
  })
@@ -217,7 +217,7 @@ module.exports = {
217
217
  try {
218
218
  conn.subprocess.send({ msgid, ...message });
219
219
  } catch (err) {
220
- logger.error({ err }, 'Error sending request');
220
+ logger.error(extractErrorLogData(err), 'Error sending request');
221
221
  this.close(conn.conid);
222
222
  }
223
223
  });
@@ -8,7 +8,7 @@ const path = require('path');
8
8
  const { handleProcessCommunication } = require('../utility/processComm');
9
9
  const processArgs = require('../utility/processArgs');
10
10
  const { appdir } = require('../utility/directories');
11
- const { getLogger } = require('dbgate-tools');
11
+ const { getLogger, extractErrorLogData } = require('dbgate-tools');
12
12
  const pipeForkLogs = require('../utility/pipeForkLogs');
13
13
  const config = require('./config');
14
14
 
@@ -222,7 +222,7 @@ module.exports = {
222
222
  try {
223
223
  session.subprocess.send({ msgtype: 'ping' });
224
224
  } catch (err) {
225
- logger.error({ err }, 'Error pinging session');
225
+ logger.error(extractErrorLogData(err), 'Error pinging session');
226
226
 
227
227
  return {
228
228
  status: 'error',
@@ -1,7 +1,7 @@
1
1
  const crypto = require('crypto');
2
2
  const path = require('path');
3
3
  const { uploadsdir, getLogsFilePath } = require('../utility/directories');
4
- const { getLogger } = require('dbgate-tools');
4
+ const { getLogger, extractErrorLogData } = require('dbgate-tools');
5
5
  const logger = getLogger('uploads');
6
6
  const axios = require('axios');
7
7
  const os = require('os');
@@ -110,7 +110,7 @@ module.exports = {
110
110
 
111
111
  return response.data;
112
112
  } catch (err) {
113
- logger.error({ err }, 'Error uploading gist');
113
+ logger.error(extractErrorLogData(err), 'Error uploading gist');
114
114
 
115
115
  return {
116
116
  apiErrorMessage: err.message,
@@ -1,5 +1,5 @@
1
1
 
2
2
  module.exports = {
3
- version: '5.5.4-alpha.3',
4
- buildTime: '2024-10-01T09:09:17.169Z'
3
+ version: '5.5.4-alpha.4',
4
+ buildTime: '2024-10-01T10:23:19.199Z'
5
5
  };
@@ -7,6 +7,8 @@ const {
7
7
  getLogger,
8
8
  isCompositeDbName,
9
9
  dbNameLogCategory,
10
+ extractErrorMessage,
11
+ extractErrorLogData,
10
12
  } = require('dbgate-tools');
11
13
  const requireEngineDriver = require('../utility/requireEngineDriver');
12
14
  const connectUtility = require('../utility/connectUtility');
@@ -34,25 +36,6 @@ function getStatusCounter() {
34
36
  return statusCounter;
35
37
  }
36
38
 
37
- function extractErrorMessage(err, defaultMessage) {
38
- if (!err) {
39
- return defaultMessage;
40
- }
41
- if (err.errors) {
42
- try {
43
- return err.errors.map(x => x.message).join('\n');
44
- } catch (e2) {}
45
- }
46
- if (err.message) {
47
- return err.message;
48
- }
49
- const s = `${err}`;
50
- if (s && (!s.endsWith('Error') || s.includes(' '))) {
51
- return s;
52
- }
53
- return defaultMessage;
54
- }
55
-
56
39
  async function checkedAsyncCall(promise) {
57
40
  try {
58
41
  const res = await promise;
@@ -261,7 +244,7 @@ async function handleDriverDataCore(msgid, callMethod, { logName }) {
261
244
  const result = await callMethod(driver);
262
245
  process.send({ msgtype: 'response', msgid, result });
263
246
  } catch (err) {
264
- logger.error(err, `Error when handling message ${logName}`);
247
+ logger.error(extractErrorLogData(err, { logName }), `Error when handling message ${logName}`);
265
248
  process.send({ msgtype: 'response', msgid, errorMessage: extractErrorMessage(err, 'Error executing DB data') });
266
249
  }
267
250
  }
@@ -436,7 +419,7 @@ function start() {
436
419
  try {
437
420
  await handleMessage(message);
438
421
  } catch (err) {
439
- logger.error({ err }, 'Error in DB connection');
422
+ logger.error(extractErrorLogData(err), 'Error in DB connection');
440
423
  process.send({ msgtype: 'error', error: extractErrorMessage(err, 'Error processing message') });
441
424
  }
442
425
  });
@@ -3,7 +3,7 @@ const platformInfo = require('../utility/platformInfo');
3
3
  const childProcessChecker = require('../utility/childProcessChecker');
4
4
  const { handleProcessCommunication } = require('../utility/processComm');
5
5
  const { SSHConnection } = require('../utility/SSHConnection');
6
- const { getLogger } = require('dbgate-tools');
6
+ const { getLogger, extractErrorLogData } = require('dbgate-tools');
7
7
 
8
8
  const logger = getLogger('sshProcess');
9
9
 
@@ -40,7 +40,7 @@ async function handleStart({ connection, tunnelConfig }) {
40
40
  tunnelConfig,
41
41
  });
42
42
  } catch (err) {
43
- logger.error({ err }, 'Error creating SSH tunnel connection:');
43
+ logger.error(extractErrorLogData(err), 'Error creating SSH tunnel connection:');
44
44
 
45
45
  process.send({
46
46
  msgtype: 'error',
@@ -1,4 +1,4 @@
1
- const { getLogger } = require('dbgate-tools');
1
+ const { getLogger, extractErrorLogData } = require('dbgate-tools');
2
2
  const childProcessChecker = require('../utility/childProcessChecker');
3
3
  const processArgs = require('../utility/processArgs');
4
4
  const logger = getLogger();
@@ -11,7 +11,7 @@ async function runScript(func) {
11
11
  await func();
12
12
  process.exit(0);
13
13
  } catch (err) {
14
- logger.error({ err }, `Error running script: ${err.message || err}`);
14
+ logger.error(extractErrorLogData(err), `Error running script`);
15
15
  process.exit(1);
16
16
  }
17
17
  }
@@ -3,7 +3,7 @@ const { fork } = require('child_process');
3
3
  const { handleProcessCommunication } = require('./processComm');
4
4
  const processArgs = require('../utility/processArgs');
5
5
  const pipeForkLogs = require('./pipeForkLogs');
6
- const { getLogger } = require('dbgate-tools');
6
+ const { getLogger, extractErrorLogData } = require('dbgate-tools');
7
7
  const logger = getLogger('DatastoreProxy');
8
8
 
9
9
  class DatastoreProxy {
@@ -73,7 +73,7 @@ class DatastoreProxy {
73
73
  try {
74
74
  this.subprocess.send({ msgtype: 'read', msgid, offset, limit });
75
75
  } catch (err) {
76
- logger.error({ err }, 'Error getting rows');
76
+ logger.error(extractErrorLogData(err), 'Error getting rows');
77
77
  this.subprocess = null;
78
78
  }
79
79
  });
@@ -87,7 +87,7 @@ class DatastoreProxy {
87
87
  try {
88
88
  this.subprocess.send({ msgtype: 'notify', msgid });
89
89
  } catch (err) {
90
- logger.error({ err }, 'Error notifying subprocess');
90
+ logger.error(extractErrorLogData(err), 'Error notifying subprocess');
91
91
  this.subprocess = null;
92
92
  }
93
93
  });
@@ -1,4 +1,4 @@
1
- const { getLogger } = require('dbgate-tools');
1
+ const { getLogger, extractErrorLogData } = require('dbgate-tools');
2
2
 
3
3
  const logger = getLogger('childProcessChecked');
4
4
 
@@ -12,7 +12,7 @@ function childProcessChecker() {
12
12
  // This will come once parent dies.
13
13
  // One way can be to check for error code ERR_IPC_CHANNEL_CLOSED
14
14
  // and call process.exit()
15
- logger.error({ err }, 'parent died');
15
+ logger.error(extractErrorLogData(err), 'parent died');
16
16
  process.exit(1);
17
17
  }
18
18
  }, 1000);
@@ -37,8 +37,8 @@ async function loadConnection(driver, storedConnection, connectionMode) {
37
37
 
38
38
  if (allowConnectionFromEnvVariables) {
39
39
  return _.mapValues(storedConnection, (value, key) => {
40
- if (_.isString(value) && value.startsWith('$')) {
41
- return process.env[value.substring(1)];
40
+ if (_.isString(value) && value.startsWith('${') && value.endsWith('}')) {
41
+ return process.env[value.slice(2, -1)];
42
42
  }
43
43
  return value;
44
44
  });
@@ -5,7 +5,7 @@ const AsyncLock = require('async-lock');
5
5
  const lock = new AsyncLock();
6
6
  const { fork } = require('child_process');
7
7
  const processArgs = require('../utility/processArgs');
8
- const { getLogger } = require('dbgate-tools');
8
+ const { getLogger, extractErrorLogData } = require('dbgate-tools');
9
9
  const pipeForkLogs = require('./pipeForkLogs');
10
10
  const logger = getLogger('sshTunnel');
11
11
 
@@ -40,7 +40,7 @@ function callForwardProcess(connection, tunnelConfig, tunnelCacheKey) {
40
40
  tunnelConfig,
41
41
  });
42
42
  } catch (err) {
43
- logger.error({ err }, 'Error connecting SSH');
43
+ logger.error(extractErrorLogData(err), 'Error connecting SSH');
44
44
  }
45
45
  return new Promise((resolve, reject) => {
46
46
  subprocess.on('message', resp => {
@@ -1,5 +1,5 @@
1
1
  const crypto = require('crypto');
2
- const { getLogger } = require('dbgate-tools');
2
+ const { getLogger, extractErrorLogData } = require('dbgate-tools');
3
3
  const { getSshTunnel } = require('./sshTunnel');
4
4
  const logger = getLogger('sshTunnelProxy');
5
5
 
@@ -10,7 +10,7 @@ async function handleGetSshTunnelRequest({ msgid, connection }, subprocess) {
10
10
  try {
11
11
  subprocess.send({ msgtype: 'getsshtunnel-response', msgid, response });
12
12
  } catch (err) {
13
- logger.error({ err }, 'Error sending to SSH tunnel');
13
+ logger.error(extractErrorLogData(err), 'Error sending to SSH tunnel');
14
14
  }
15
15
  }
16
16
 
@@ -2,7 +2,7 @@ const _ = require('lodash');
2
2
  const express = require('express');
3
3
  const getExpressPath = require('./getExpressPath');
4
4
  const { MissingCredentialsError } = require('./exceptions');
5
- const { getLogger } = require('dbgate-tools');
5
+ const { getLogger, extractErrorLogData } = require('dbgate-tools');
6
6
 
7
7
  const logger = getLogger('useController');
8
8
  /**
@@ -16,7 +16,7 @@ module.exports = function useController(app, electron, route, controller) {
16
16
  try {
17
17
  controller._init();
18
18
  } catch (err) {
19
- logger.error({ err }, `Error initializing controller, exiting application`);
19
+ logger.error(extractErrorLogData(err), `Error initializing controller, exiting application`);
20
20
  process.exit(1);
21
21
  }
22
22
  }
@@ -78,7 +78,7 @@ module.exports = function useController(app, electron, route, controller) {
78
78
  const data = await controller[key]({ ...req.body, ...req.query }, req);
79
79
  res.json(data);
80
80
  } catch (err) {
81
- logger.error({ err }, `Error when processing route ${route}/${key}`);
81
+ logger.error(extractErrorLogData(err), `Error when processing route ${route}/${key}`);
82
82
  if (err instanceof MissingCredentialsError) {
83
83
  res.json({
84
84
  missingCredentials: true,