dbgate-api-premium 6.7.0 → 6.7.1

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.7.0",
4
+ "version": "6.7.1",
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.7.0",
34
- "dbgate-query-splitter": "^4.11.7",
35
- "dbgate-sqltree": "^6.7.0",
36
- "dbgate-tools": "^6.7.0",
33
+ "dbgate-datalib": "^6.7.1",
34
+ "dbgate-query-splitter": "^4.11.9",
35
+ "dbgate-sqltree": "^6.7.1",
36
+ "dbgate-tools": "^6.7.1",
37
37
  "debug": "^4.3.4",
38
38
  "diff": "^5.0.0",
39
39
  "diff2html": "^3.4.13",
@@ -86,7 +86,7 @@
86
86
  "devDependencies": {
87
87
  "@types/fs-extra": "^9.0.11",
88
88
  "@types/lodash": "^4.14.149",
89
- "dbgate-types": "^6.7.0",
89
+ "dbgate-types": "^6.7.1",
90
90
  "env-cmd": "^10.1.0",
91
91
  "jsdoc-to-markdown": "^9.0.5",
92
92
  "node-loader": "^1.0.2",
@@ -35,8 +35,8 @@ module.exports = {
35
35
  },
36
36
 
37
37
  refreshPublicFiles_meta: true,
38
- async refreshPublicFiles({ isRefresh }) {
39
- await refreshPublicFiles(isRefresh);
38
+ async refreshPublicFiles({ isRefresh }, req) {
39
+ await refreshPublicFiles(isRefresh, req?.headers?.['x-ui-language']);
40
40
  return {
41
41
  status: 'ok',
42
42
  };
@@ -71,6 +71,7 @@ module.exports = {
71
71
  const isLicenseValid = checkedLicense?.status == 'ok';
72
72
  const logoutUrl = storageConnectionError ? null : await authProvider.getLogoutUrl();
73
73
  const adminConfig = storageConnectionError ? null : await storage.readConfig({ group: 'admin' });
74
+ const settingsConfig = storageConnectionError ? null : await storage.readConfig({ group: 'settings' });
74
75
 
75
76
  storage.startRefreshLicense();
76
77
 
@@ -121,6 +122,7 @@ module.exports = {
121
122
  allowPrivateCloud: platformInfo.isElectron || !!process.env.ALLOW_DBGATE_PRIVATE_CLOUD,
122
123
  ...currentVersion,
123
124
  redirectToDbGateCloudLogin: !!process.env.REDIRECT_TO_DBGATE_CLOUD_LOGIN,
125
+ preferrendLanguage: settingsConfig?.['storage.language'] || process.env.LANGUAGE || null,
124
126
  };
125
127
 
126
128
  return configResult;
@@ -14,7 +14,11 @@ const JsonLinesDatabase = require('../utility/JsonLinesDatabase');
14
14
  const processArgs = require('../utility/processArgs');
15
15
  const { safeJsonParse, getLogger, extractErrorLogData } = require('dbgate-tools');
16
16
  const platformInfo = require('../utility/platformInfo');
17
- const { connectionHasPermission, testConnectionPermission, loadPermissionsFromRequest } = require('../utility/hasPermission');
17
+ const {
18
+ connectionHasPermission,
19
+ testConnectionPermission,
20
+ loadPermissionsFromRequest,
21
+ } = require('../utility/hasPermission');
18
22
  const pipeForkLogs = require('../utility/pipeForkLogs');
19
23
  const requireEngineDriver = require('../utility/requireEngineDriver');
20
24
  const { getAuthProviderById } = require('../auth/authProvider');
@@ -116,7 +120,10 @@ function getPortalCollections() {
116
120
  }
117
121
  }
118
122
 
119
- logger.info({ connections: connections.map(pickSafeConnectionInfo) }, 'DBGM-00005 Using connections from ENV variables');
123
+ logger.info(
124
+ { connections: connections.map(pickSafeConnectionInfo) },
125
+ 'DBGM-00005 Using connections from ENV variables'
126
+ );
120
127
  const noengine = connections.filter(x => !x.engine);
121
128
  if (noengine.length > 0) {
122
129
  logger.warn(
@@ -502,7 +509,11 @@ module.exports = {
502
509
  state,
503
510
  client: 'web',
504
511
  });
505
- res.redirect(authResp.url);
512
+ if (authResp?.url) {
513
+ res.redirect(authResp.url);
514
+ return;
515
+ }
516
+ res.json({ error: 'No URL returned from auth provider' });
506
517
  },
507
518
 
508
519
  dbloginApp_meta: true,
@@ -643,7 +643,7 @@ async function storageGetExistingFileWithContent(teamFileId) {
643
643
  }
644
644
  const resp = await storageSelectFmt(
645
645
  `select ~team_files.~id, ~team_files.~file_name, ~team_files.~owner_user_id, ~team_file_types.~name as ~type_name, ~team_files.~file_content,
646
- ~users.login as ~owner_login, ~users.~email as ~owner_email
646
+ ~users.login as ~owner_login, ~users.~email as ~owner_email, ~team_file_types.~format as ~type_format
647
647
  from ~team_files inner join ~team_file_types on ~team_files.~file_type_id = ~team_file_types.~id
648
648
  left join ~users on ~team_files.~owner_user_id = ~users.~id
649
649
  where ~team_files.~id = %v`,
@@ -33,6 +33,12 @@ function extractFileMetadata(data, typeName) {
33
33
  return null;
34
34
  }
35
35
 
36
+ function deserialize(format, text) {
37
+ if (format == 'text') return text;
38
+ if (format == 'json') return JSON.parse(text);
39
+ throw new Error(`Invalid format: ${format}`);
40
+ }
41
+
36
42
  module.exports = {
37
43
  createNew_meta: true,
38
44
  async createNew({ fileType, file, data }, req) {
@@ -143,26 +149,32 @@ module.exports = {
143
149
  let allowUse = false;
144
150
  if (existingFile.type_name == 'sql') {
145
151
  const frontMatter = getSqlFrontMatter(existingFile.file_content, yaml);
146
- allowUse = await this.checkUseAccess(existingFile, req, false);
147
- // TODO
148
- // const loadedPermissions = await loadPermissionsFromRequest(req);
149
- // && !hasPermission('dbops/query', loadedPermissions)
150
- if (allowUse) {
151
- const useToken = jwt.sign(
152
- {
153
- contentHash: crypto.createHash('md5').update(removeSqlFrontMatter(existingFile.file_content)).digest('hex'),
154
- },
155
- getStaticTokenSecret()
156
- // { expiresIn: '1h' }
157
- );
158
-
159
- actualContent = setSqlFrontMatter(actualContent, { ...frontMatter, useToken }, yaml);
152
+ if (frontMatter?.autoExecute) {
153
+ allowUse = await this.checkUseAccess(existingFile, req, false);
154
+ if (allowUse) {
155
+ const useToken = jwt.sign(
156
+ {
157
+ contentHash: crypto
158
+ .createHash('md5')
159
+ .update(removeSqlFrontMatter(existingFile.file_content))
160
+ .digest('hex'),
161
+ },
162
+ getStaticTokenSecret()
163
+ // { expiresIn: '1h' }
164
+ );
165
+
166
+ actualContent = setSqlFrontMatter(actualContent, { ...frontMatter, useToken }, yaml);
167
+ }
160
168
  }
161
169
  }
162
170
  if (!allowUse) {
163
171
  await this.checkReadAccess(existingFile, req);
164
172
  }
165
- return { content: actualContent, file: existingFile.file_name, metadata: existingFile.metadata };
173
+ return {
174
+ content: deserialize(existingFile.type_format, actualContent),
175
+ file: existingFile.file_name,
176
+ metadata: existingFile.metadata,
177
+ };
166
178
  },
167
179
 
168
180
  copy_meta: true,
@@ -1,5 +1,5 @@
1
1
 
2
2
  module.exports = {
3
- version: '6.7.0',
4
- buildTime: '2025-11-19T13:25:17.978Z'
3
+ version: '6.7.1',
4
+ buildTime: '2025-11-25T14:00:30.620Z'
5
5
  };
@@ -1533,6 +1533,12 @@ module.exports = {
1533
1533
  "columnName": "name",
1534
1534
  "dataType": "varchar(250)",
1535
1535
  "notNull": true
1536
+ },
1537
+ {
1538
+ "pureName": "team_file_types",
1539
+ "columnName": "format",
1540
+ "dataType": "varchar(50)",
1541
+ "notNull": false
1536
1542
  }
1537
1543
  ],
1538
1544
  "foreignKeys": [],
@@ -1549,7 +1555,38 @@ module.exports = {
1549
1555
  "preloadedRows": [
1550
1556
  {
1551
1557
  "id": -1,
1552
- "name": "sql"
1558
+ "name": "sql",
1559
+ "format": "text"
1560
+ },
1561
+ {
1562
+ "id": -2,
1563
+ "name": "diagrams",
1564
+ "format": "json"
1565
+ },
1566
+ {
1567
+ "id": -3,
1568
+ "name": "query",
1569
+ "format": "json"
1570
+ },
1571
+ {
1572
+ "id": -4,
1573
+ "name": "perspectives",
1574
+ "format": "json"
1575
+ },
1576
+ {
1577
+ "id": -5,
1578
+ "name": "impexp",
1579
+ "format": "json"
1580
+ },
1581
+ {
1582
+ "id": -6,
1583
+ "name": "shell",
1584
+ "format": "text"
1585
+ },
1586
+ {
1587
+ "id": -7,
1588
+ "name": "dbcompare",
1589
+ "format": "json"
1553
1590
  }
1554
1591
  ]
1555
1592
  },
@@ -193,7 +193,7 @@ async function getCloudSigninHeaders(holder = null) {
193
193
  return null;
194
194
  }
195
195
 
196
- async function updateCloudFiles(isRefresh) {
196
+ async function updateCloudFiles(isRefresh, language) {
197
197
  let lastCloudFilesTags;
198
198
  try {
199
199
  lastCloudFilesTags = await fs.readFile(path.join(datadir(), 'cloud-files-tags.txt'), 'utf-8');
@@ -218,6 +218,7 @@ async function updateCloudFiles(isRefresh) {
218
218
  ...getLicenseHttpHeaders(),
219
219
  ...(await getCloudInstanceHeaders()),
220
220
  'x-app-version': currentVersion.version,
221
+ 'x-app-language': language || 'en',
221
222
  },
222
223
  }
223
224
  );
@@ -274,7 +275,7 @@ async function ensurePromoWidgetDataLoaded() {
274
275
  promoWidgetDataLoaded = true;
275
276
  }
276
277
 
277
- async function updatePremiumPromoWidget() {
278
+ async function updatePremiumPromoWidget(language) {
278
279
  await ensurePromoWidgetDataLoaded();
279
280
 
280
281
  const tags = (await collectCloudFilesSearchTags()).join(',');
@@ -286,6 +287,7 @@ async function updatePremiumPromoWidget() {
286
287
  ...getLicenseHttpHeaders(),
287
288
  ...(await getCloudInstanceHeaders()),
288
289
  'x-app-version': currentVersion.version,
290
+ 'x-app-language': language || 'en',
289
291
  },
290
292
  }
291
293
  );
@@ -300,18 +302,21 @@ async function updatePremiumPromoWidget() {
300
302
  socket.emitChanged(`promo-widget-changed`);
301
303
  }
302
304
 
303
- async function refreshPublicFiles(isRefresh) {
305
+ async function refreshPublicFiles(isRefresh, uiLanguage) {
306
+ const language = platformInfo.isElectron
307
+ ? (await config.getCachedSettings())?.['localization.language'] || 'en'
308
+ : uiLanguage;
304
309
  if (!cloudFiles) {
305
310
  await loadCloudFiles();
306
311
  }
307
312
  try {
308
- await updateCloudFiles(isRefresh);
313
+ await updateCloudFiles(isRefresh, language);
309
314
  } catch (err) {
310
315
  logger.error(extractErrorLogData(err), 'DBGM-00166 Error updating cloud files');
311
316
  }
312
317
  const configSettings = await config.get();
313
318
  if (!isProApp() || configSettings?.trialDaysLeft != null) {
314
- await updatePremiumPromoWidget();
319
+ await updatePremiumPromoWidget(language);
315
320
  }
316
321
  }
317
322