File tree 5 files changed +230
-5
lines changed
js/packages/quary-extension
5 files changed +230
-5
lines changed Original file line number Diff line number Diff line change 209
209
"crypto-browserify" : " ^3.12.0" ,
210
210
"file-loader" : " ^6.2.0" ,
211
211
"lodash" : " ^4.17.21" ,
212
+ "node-polyfill-webpack-plugin" : " ^4.0.0" ,
212
213
"papaparse" : " ^5.4.1" ,
214
+ "postgres" : " ^3.4.4" ,
213
215
"quary-extension-ui" : " workspace:*" ,
214
216
"raw-loader" : " ^4.0.2" ,
215
217
"sql.js" : " 1.10.3" ,
216
218
"stream-browserify" : " ^3.0.0" ,
217
219
"url-loader" : " ^4.1.1" ,
218
220
"vm-browserify" : " ^1.1.2" ,
221
+ "webpack-node-externals" : " ^3.0.0" ,
219
222
"zod" : " ^3.23.8"
220
223
}
221
224
}
Original file line number Diff line number Diff line change @@ -18,6 +18,7 @@ import {
18
18
} from './servicesDatabaseDuckDBNode'
19
19
import { ServicesDatabaseRedshiftNode } from './servicesDatabaseRedshiftNode'
20
20
import { ServicesDatabasePostgresNode } from './servicesDatabasePostgresNode'
21
+ import { ServicesDatabasePostgres } from './servicesDatabasePostgres'
21
22
22
23
/**
23
24
* Creates a database instance from a given configuration.
@@ -156,10 +157,9 @@ export const databaseFromConfig = async (
156
157
case 'postgres' : {
157
158
switch ( vscode . env . uiKind ) {
158
159
case vscode . UIKind . Web : {
159
- return Err ( {
160
- code : ErrorCodes . INVALID_ARGUMENT ,
161
- message : 'Postgres is not supported in the web extension' ,
162
- } )
160
+ const postgres = new ServicesDatabasePostgres ( )
161
+ // @ts -ignore
162
+ return Ok ( postgres )
163
163
}
164
164
case vscode . UIKind . Desktop : {
165
165
const { schema } = config . config . postgres
Original file line number Diff line number Diff line change
1
+ import { Ok } from '@shared/result'
2
+ import * as postgres from 'postgres'
3
+ import { ServicesDatabase } from './servicesDatabase'
4
+
5
+ const DefaultDatabaseDependentSettings = {
6
+ runQueriesByDefault : false ,
7
+ lookForCacheViews : false ,
8
+ }
9
+
10
+ // @ts -ignore
11
+ export class ServicesDatabasePostgres implements ServicesDatabase {
12
+ readonly db : any
13
+
14
+ // @ts -ignore
15
+ async runStatement ( statement : string ) : Promise < Result < QueryResult > > {
16
+ const results = this . db `
17
+ ${ statement }
18
+ `
19
+ console . log ( results )
20
+ throw new Error ( 'Not implemented' )
21
+ }
22
+
23
+ constructor ( ) {
24
+ this . db = postgres ( {
25
+ port : 5432 ,
26
+ host : 'localhost' ,
27
+ database : 'postgres' ,
28
+ username : 'postgres' ,
29
+ password : 'mysecretpassword' ,
30
+ } )
31
+ }
32
+
33
+ async listTables ( ) {
34
+ return Ok ( [ ] )
35
+ }
36
+ }
Original file line number Diff line number Diff line change @@ -80,6 +80,10 @@ module.exports = (
80
80
} ,
81
81
82
82
plugins : [
83
+ new webpack . NormalModuleReplacementPlugin (
84
+ / ^ n e t $ / ,
85
+ 'net-browserify'
86
+ ) ,
83
87
new webpack . optimize . LimitChunkCountPlugin ( {
84
88
maxChunks : 1 , // disable chunks by default since web extensions must be a single bundle
85
89
} ) ,
@@ -94,7 +98,7 @@ module.exports = (
94
98
__PACKAGE_VERSION__ : JSON . stringify ( packageJson . version ) ,
95
99
} ) ,
96
100
] ,
97
- externals : {
101
+ externals : {
98
102
vscode : 'commonjs vscode' , // ignored because it doesn't exist
99
103
} ,
100
104
performance : {
You can’t perform that action at this time.
0 commit comments