mirror of
https://github.com/sqlchat/sqlchat.git
synced 2025-09-26 01:23:18 +08:00
chore: move encrypt
to connection (#34)
This commit is contained in:
@ -46,6 +46,7 @@
|
||||
"@nem035/gpt-3-encoder": "^1.1.7",
|
||||
"@tailwindcss/typography": "^0.5.9",
|
||||
"@types/lodash-es": "^4.17.7",
|
||||
"@types/mssql": "^8.1.2",
|
||||
"@types/node": "^18.11.18",
|
||||
"@types/pg": "^8.6.6",
|
||||
"@types/react": "^18.0.26",
|
||||
|
17
pnpm-lock.yaml
generated
17
pnpm-lock.yaml
generated
@ -108,6 +108,9 @@ devDependencies:
|
||||
'@types/lodash-es':
|
||||
specifier: ^4.17.7
|
||||
version: 4.17.7
|
||||
'@types/mssql':
|
||||
specifier: ^8.1.2
|
||||
version: 8.1.2
|
||||
'@types/node':
|
||||
specifier: ^18.11.18
|
||||
version: 18.15.3
|
||||
@ -1493,6 +1496,14 @@ packages:
|
||||
resolution: {integrity: sha512-iiUgKzV9AuaEkZqkOLDIvlQiL6ltuZd9tGcW3gwpnX8JbuiuhFlEGmmFXEXkN50Cvq7Os88IY2v0dkDqXYWVgA==}
|
||||
dev: false
|
||||
|
||||
/@types/mssql@8.1.2:
|
||||
resolution: {integrity: sha512-hoDM+mZUClfXu0J1pyVdbhv2Ve0dl0TdagAE3M5rd1slqoVEEHuNObPD+giwtJgyo99CcS58qbF9ektVKdxSfQ==}
|
||||
dependencies:
|
||||
'@types/node': 18.15.3
|
||||
'@types/tedious': 4.0.9
|
||||
tarn: 3.0.2
|
||||
dev: true
|
||||
|
||||
/@types/node@18.15.3:
|
||||
resolution: {integrity: sha512-p6ua9zBxz5otCmbpb5D3U4B5Nanw6Pk3PPyX05xnxbB/fRv71N7CPmORg7uAD5P70T0xmx1pzAx/FUfa5X+3cw==}
|
||||
dev: true
|
||||
@ -1546,6 +1557,12 @@ packages:
|
||||
/@types/scheduler@0.16.2:
|
||||
resolution: {integrity: sha512-hppQEBDmlwhFAXKJX2KnWLYu5yMfi91yazPb2l+lbJiwW+wdo1gNeRA+3RgNSO39WYX2euey41KEwnqesU2Jew==}
|
||||
|
||||
/@types/tedious@4.0.9:
|
||||
resolution: {integrity: sha512-ipwFvfy9b2m0gjHsIX0D6NAAwGCKokzf5zJqUZHUGt+7uWVlBIy6n2eyMgiKQ8ChLFVxic/zwQUhjLYNzbHDRA==}
|
||||
dependencies:
|
||||
'@types/node': 18.15.3
|
||||
dev: true
|
||||
|
||||
/@types/unist@2.0.6:
|
||||
resolution: {integrity: sha512-PBjIUxZHOuj0R15/xuwJYjFi+KZdNFrehocChv4g5hu6aFroHue8m0lBP0POdK2nKzbw0cgV1mws8+V/JAcEkQ==}
|
||||
|
||||
|
@ -255,7 +255,7 @@ const CreateConnectionModal = (props: Props) => {
|
||||
<label className="block text-sm font-medium text-gray-700 mb-1">SSL</label>
|
||||
<div className="w-full flex flex-row justify-start items-start flex-wrap">
|
||||
{SSLTypeOptions.map((option) => (
|
||||
<label key={option.value} className="w-auto flex flex-row justify-start items-center cursor-pointer mr-3 mb-2">
|
||||
<label key={option.value} className="w-auto flex flex-row justify-start items-center cursor-pointer mr-3 mb-3">
|
||||
<input
|
||||
type="radio"
|
||||
className="radio w-4 h-4 mr-1"
|
||||
@ -323,16 +323,16 @@ const CreateConnectionModal = (props: Props) => {
|
||||
)}
|
||||
{connection.engineType === Engine.MSSQL && (
|
||||
<div className="w-full flex flex-col">
|
||||
<label className="block text-sm font-medium text-gray-700 mb-1">Encrypt?</label>
|
||||
<label className="block text-sm font-medium text-gray-700 mb-1">Encrypt</label>
|
||||
<div className="w-full flex flex-row justify-start items-start flex-wrap">
|
||||
<label className="flex items-center">
|
||||
<input
|
||||
type="checkbox"
|
||||
className="form-checkbox h-4 w-4 text-indigo-600 transition duration-150 ease-in-out"
|
||||
checked={connection.ssl && connection.ssl['encrypt']}
|
||||
onChange={(e) => setPartialConnection({ ssl: { ...connection.ssl, encrypt: e.target.checked } })}
|
||||
checked={connection.encrypt}
|
||||
onChange={(e) => setPartialConnection({ encrypt: e.target.checked })}
|
||||
/>
|
||||
<span className="ml-2 text-sm">Encrypt connection?</span>
|
||||
<span className="ml-2 text-sm">Encrypt connection</span>
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -1,18 +1,18 @@
|
||||
import { ConnectionPool, ConnectionPoolConfig } from "mssql";
|
||||
import { ConnectionPool } from "mssql";
|
||||
import { Connection } from "@/types";
|
||||
import { Connector } from "..";
|
||||
|
||||
const systemDatabases = ["master", "tempdb", "model", "msdb"];
|
||||
|
||||
const getMSSQLConnection = async (connection: Connection): Promise<ConnectionPool> => {
|
||||
const connectionOptions: ConnectionPoolConfig = {
|
||||
const connectionOptions: any = {
|
||||
server: connection.host,
|
||||
port: parseInt(connection.port),
|
||||
user: connection.username,
|
||||
password: connection.password,
|
||||
database: connection.database,
|
||||
options: {
|
||||
encrypt: connection.ssl?.encrypt === true,
|
||||
encrypt: connection.encrypt === true,
|
||||
},
|
||||
};
|
||||
if (connection.ssl) {
|
||||
@ -70,7 +70,7 @@ const getTables = async (connection: Connection, databaseName: string): Promise<
|
||||
return tableList;
|
||||
};
|
||||
|
||||
const getTableStructure = async (connection: ConnectionPool, databaseName: string, tableName: string): Promise<string> => {
|
||||
const getTableStructure = async (connection: Connection, databaseName: string, tableName: string): Promise<string> => {
|
||||
const pool = await getMSSQLConnection(connection);
|
||||
const request = pool.request();
|
||||
const { recordset } = await request.query(
|
||||
|
@ -10,7 +10,6 @@ export interface SSLOptions {
|
||||
ca?: string;
|
||||
cert?: string;
|
||||
key?: string;
|
||||
encrypt?: boolean;
|
||||
}
|
||||
|
||||
export interface Connection {
|
||||
@ -23,5 +22,7 @@ export interface Connection {
|
||||
password: string;
|
||||
// database is only required for PostgreSQL.
|
||||
database?: string;
|
||||
// encrypt is only required for MSSQL.
|
||||
encrypt?: boolean;
|
||||
ssl?: SSLOptions;
|
||||
}
|
||||
|
Reference in New Issue
Block a user