@@ -8,7 +8,6 @@ import type { Database as PostgresDatabase } from './postgres/schema'
88import { PORTS } from '@conar/shared/ports'
99import { Kysely } from 'kysely'
1010import { memoize } from 'memoza'
11- import { connectionStringStorage } from '~/lib/connection-string-storage'
1211import { createProxyClient , orpcProxy } from '~/lib/orpc'
1312import { getConnectionStore } from '../store'
1413import { connectionsCollection , connectionsResourcesCollection } from '../sync'
@@ -19,7 +18,7 @@ import { mysqlColdDialect, mysqlDialect } from './mysql'
1918import { postgresColdDialect , postgresDialect } from './postgres'
2019
2120export interface DialectOptions {
22- connectionString ? : string
21+ connectionString : string
2322 connectionId ?: string
2423 resourceId ?: string
2524 log ?: ( params : {
@@ -37,21 +36,7 @@ function resolveProxyIdParams(options: DialectOptions) {
3736 return { resourceId : options . resourceId }
3837 if ( options . connectionId )
3938 return { connectionId : options . connectionId }
40- return { connectionString : options . connectionString ! }
41- }
42-
43- async function resolveElectronConnectionString ( options : DialectOptions , connectionId : string | undefined ) : Promise < string > {
44- if ( options . connectionString ) {
45- return options . connectionString
46- }
47-
48- if ( connectionId ) {
49- if ( connectionStringStorage . has ( connectionId ) ) {
50- return connectionStringStorage . decrypt ( connectionId )
51- }
52- }
53-
54- throw new Error ( 'No connection string available for this connection' )
39+ return { connectionString : options . connectionString }
5540}
5641
5742interface QueryPayload {
@@ -88,20 +73,16 @@ export function createDialectProvider(type: ConnectionType, options: DialectOpti
8873 }
8974
9075 return {
91- async execute ( payload : QueryPayload ) {
76+ execute ( payload : QueryPayload ) {
9277 const t = resolveTransport ( )
93- if ( t . kind === 'electron' ) {
94- const connectionString = await resolveElectronConnectionString ( options , connectionId )
95- return t . electron . execute ( { connectionString, ...payload } )
96- }
78+ if ( t . kind === 'electron' )
79+ return t . electron . execute ( { connectionString : options . connectionString , ...payload } )
9780 return t . proxy . execute ( { ...resolveProxyIdParams ( options ) , ...payload } )
9881 } ,
99- async beginTransaction ( ) {
82+ beginTransaction ( ) {
10083 const t = resolveTransport ( )
101- if ( t . kind === 'electron' ) {
102- const connectionString = await resolveElectronConnectionString ( options , connectionId )
103- return t . electron . beginTransaction ( { connectionString } )
104- }
84+ if ( t . kind === 'electron' )
85+ return t . electron . beginTransaction ( { connectionString : options . connectionString } )
10586 return t . proxy . beginTransaction ( resolveProxyIdParams ( options ) )
10687 } ,
10788 executeTransaction ( params : TxQueryPayload ) {
0 commit comments