4
4
PostgrestClient ,
5
5
PostgrestFilterBuilder ,
6
6
PostgrestQueryBuilder ,
7
+ ClientServerOptions as PostgrestClientServerOption ,
8
+ GetGenericDatabaseWithOptions ,
7
9
} from '@supabase/postgrest-js'
8
10
import {
9
11
RealtimeChannel ,
@@ -28,13 +30,18 @@ import { Fetch, GenericSchema, SupabaseClientOptions, SupabaseAuthClientOptions
28
30
*
29
31
* An isomorphic Javascript client for interacting with Postgres.
30
32
*/
33
+
34
+ export type ServicesOptions = PostgrestClientServerOption & { }
35
+
31
36
export default class SupabaseClient <
32
37
Database = any ,
33
- SchemaName extends string & keyof Database = 'public' extends keyof Database
38
+ ClientOptions extends ServicesOptions = { PostgrestVersion : '12' } ,
39
+ SchemaName extends string &
40
+ keyof GetGenericDatabaseWithOptions < Database > [ 'db' ] = 'public' extends keyof GetGenericDatabaseWithOptions < Database > [ 'db' ]
34
41
? 'public'
35
- : string & keyof Database ,
36
- Schema extends GenericSchema = Database [ SchemaName ] extends GenericSchema
37
- ? Database [ SchemaName ]
42
+ : string & keyof GetGenericDatabaseWithOptions < Database > [ 'db' ] ,
43
+ Schema extends GenericSchema = GetGenericDatabaseWithOptions < Database > [ 'db' ] [ SchemaName ] extends GenericSchema
44
+ ? GetGenericDatabaseWithOptions < Database > [ 'db' ] [ SchemaName ]
38
45
: any
39
46
> {
40
47
/**
@@ -47,7 +54,7 @@ export default class SupabaseClient<
47
54
protected authUrl : URL
48
55
protected storageUrl : URL
49
56
protected functionsUrl : URL
50
- protected rest : PostgrestClient < Database , SchemaName , Schema >
57
+ protected rest : PostgrestClient < Database , ClientOptions , SchemaName , Schema >
51
58
protected storageKey : string
52
59
protected fetch ?: Fetch
53
60
protected changedAccessToken ?: string
@@ -156,16 +163,16 @@ export default class SupabaseClient<
156
163
from <
157
164
TableName extends string & keyof Schema [ 'Tables' ] ,
158
165
Table extends Schema [ 'Tables' ] [ TableName ]
159
- > ( relation : TableName ) : PostgrestQueryBuilder < Schema , Table , TableName >
166
+ > ( relation : TableName ) : PostgrestQueryBuilder < ClientOptions , Schema , Table , TableName >
160
167
from < ViewName extends string & keyof Schema [ 'Views' ] , View extends Schema [ 'Views' ] [ ViewName ] > (
161
168
relation : ViewName
162
- ) : PostgrestQueryBuilder < Schema , View , ViewName >
169
+ ) : PostgrestQueryBuilder < ClientOptions , Schema , View , ViewName >
163
170
/**
164
171
* Perform a query on a table or a view.
165
172
*
166
173
* @param relation - The table or view name to query
167
174
*/
168
- from ( relation : string ) : PostgrestQueryBuilder < Schema , any , any > {
175
+ from ( relation : string ) : PostgrestQueryBuilder < ClientOptions , Schema , any , any > {
169
176
return this . rest . from ( relation )
170
177
}
171
178
@@ -177,10 +184,11 @@ export default class SupabaseClient<
177
184
*
178
185
* @param schema - The schema to query
179
186
*/
180
- schema < DynamicSchema extends string & keyof Database > (
187
+ schema < DynamicSchema extends string & keyof GetGenericDatabaseWithOptions < Database > [ 'db' ] > (
181
188
schema : DynamicSchema
182
189
) : PostgrestClient <
183
190
Database ,
191
+ ClientOptions ,
184
192
DynamicSchema ,
185
193
Database [ DynamicSchema ] extends GenericSchema ? Database [ DynamicSchema ] : any
186
194
> {
@@ -220,6 +228,7 @@ export default class SupabaseClient<
220
228
count ?: 'exact' | 'planned' | 'estimated'
221
229
} = { }
222
230
) : PostgrestFilterBuilder <
231
+ ClientOptions ,
223
232
Schema ,
224
233
Fn [ 'Returns' ] extends any [ ]
225
234
? Fn [ 'Returns' ] [ number ] extends Record < string , unknown >
@@ -228,7 +237,8 @@ export default class SupabaseClient<
228
237
: never ,
229
238
Fn [ 'Returns' ] ,
230
239
FnName ,
231
- null
240
+ null ,
241
+ 'RPC'
232
242
> {
233
243
return this . rest . rpc ( fn , args , options )
234
244
}
0 commit comments