mirror of
https://github.com/DeNNiiInc/dbgate.git
synced 2026-04-19 00:16:00 +00:00
Merge branch 'master' into feature/cassandra
This commit is contained in:
@@ -34,6 +34,8 @@ const pipeForkLogs = require('../utility/pipeForkLogs');
|
||||
const crypto = require('crypto');
|
||||
const loadModelTransform = require('../utility/loadModelTransform');
|
||||
const exportDbModelSql = require('../utility/exportDbModelSql');
|
||||
const axios = require('axios');
|
||||
const { callTextToSqlApi, callCompleteOnCursorApi, callRefactorSqlQueryApi } = require('../utility/authProxy');
|
||||
|
||||
const logger = getLogger('databaseConnections');
|
||||
|
||||
@@ -562,4 +564,47 @@ module.exports = {
|
||||
|
||||
return true;
|
||||
},
|
||||
|
||||
textToSql_meta: true,
|
||||
async textToSql({ conid, database, text, dialect }) {
|
||||
const existing = this.opened.find(x => x.conid == conid && x.database == database);
|
||||
const { structure } = existing || {};
|
||||
if (!structure) return { errorMessage: 'No database structure' };
|
||||
|
||||
const res = await callTextToSqlApi(text, structure, dialect);
|
||||
|
||||
if (!res?.sql) {
|
||||
return { errorMessage: 'No SQL generated' };
|
||||
}
|
||||
|
||||
return res;
|
||||
},
|
||||
|
||||
completeOnCursor_meta: true,
|
||||
async completeOnCursor({ conid, database, text, dialect, line }) {
|
||||
const existing = this.opened.find(x => x.conid == conid && x.database == database);
|
||||
const { structure } = existing || {};
|
||||
if (!structure) return { errorMessage: 'No database structure' };
|
||||
const res = await callCompleteOnCursorApi(text, structure, dialect, line);
|
||||
|
||||
if (!res?.variants) {
|
||||
return { errorMessage: 'No SQL generated' };
|
||||
}
|
||||
|
||||
return res;
|
||||
},
|
||||
|
||||
refactorSqlQuery_meta: true,
|
||||
async refactorSqlQuery({ conid, database, query, task, dialect }) {
|
||||
const existing = this.opened.find(x => x.conid == conid && x.database == database);
|
||||
const { structure } = existing || {};
|
||||
if (!structure) return { errorMessage: 'No database structure' };
|
||||
const res = await callRefactorSqlQueryApi(query, task, structure, dialect);
|
||||
|
||||
if (!res?.sql) {
|
||||
return { errorMessage: 'No SQL generated' };
|
||||
}
|
||||
|
||||
return res;
|
||||
},
|
||||
};
|
||||
|
||||
@@ -24,6 +24,18 @@ async function getAwsIamToken(params) {
|
||||
return null;
|
||||
}
|
||||
|
||||
async function callTextToSqlApi(text, structure, dialect) {
|
||||
return null;
|
||||
}
|
||||
|
||||
async function callCompleteOnCursorApi(cursorId, query, position, dialect) {
|
||||
return null;
|
||||
}
|
||||
|
||||
async function callRefactorSqlQueryApi(query, task, structure, dialect) {
|
||||
return null;
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
isAuthProxySupported,
|
||||
authProxyGetRedirectUrl,
|
||||
@@ -32,4 +44,7 @@ module.exports = {
|
||||
getAuthProxyUrl,
|
||||
supportsAwsIam,
|
||||
getAwsIamToken,
|
||||
callTextToSqlApi,
|
||||
callCompleteOnCursorApi,
|
||||
callRefactorSqlQueryApi,
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user