Skip to content

Commit e845632

Browse files
committed
fix: stop using unstable type params from postgrest-js
1 parent 80050b5 commit e845632

File tree

1 file changed

+8
-30
lines changed

1 file changed

+8
-30
lines changed

src/SupabaseClient.ts

Lines changed: 8 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,6 @@
11
import { FunctionsClient } from '@supabase/functions-js'
22
import { AuthChangeEvent } from '@supabase/gotrue-js'
3-
import {
4-
PostgrestClient,
5-
PostgrestFilterBuilder,
6-
PostgrestQueryBuilder,
7-
} from '@supabase/postgrest-js'
3+
import { PostgrestClient } from '@supabase/postgrest-js'
84
import {
95
RealtimeChannel,
106
RealtimeChannelOptions,
@@ -143,20 +139,12 @@ export default class SupabaseClient<
143139
return new SupabaseStorageClient(this.storageUrl, this.headers, this.fetch)
144140
}
145141

146-
from<
147-
TableName extends string & keyof Schema['Tables'],
148-
Table extends Schema['Tables'][TableName]
149-
>(relation: TableName): PostgrestQueryBuilder<Schema, Table>
150-
from<ViewName extends string & keyof Schema['Views'], View extends Schema['Views'][ViewName]>(
151-
relation: ViewName
152-
): PostgrestQueryBuilder<Schema, View>
153-
from(relation: string): PostgrestQueryBuilder<Schema, any>
154142
/**
155143
* Perform a query on a table or a view.
156144
*
157145
* @param relation - The table or view name to query
158146
*/
159-
from(relation: string): PostgrestQueryBuilder<Schema, any> {
147+
from: PostgrestClient<Database, SchemaName>['from'] = (relation: string) => {
160148
return this.rest.from(relation)
161149
}
162150

@@ -168,13 +156,11 @@ export default class SupabaseClient<
168156
*
169157
* @param schema - The name of the schema to query
170158
*/
171-
schema<DynamicSchema extends string & keyof Database>(
159+
schema: PostgrestClient<Database, SchemaName>['schema'] = <
160+
DynamicSchema extends string & keyof Database
161+
>(
172162
schema: DynamicSchema
173-
): PostgrestClient<
174-
Database,
175-
DynamicSchema,
176-
Database[DynamicSchema] extends GenericSchema ? Database[DynamicSchema] : any
177-
> {
163+
) => {
178164
return this.rest.schema<DynamicSchema>(schema)
179165
}
180166

@@ -199,7 +185,7 @@ export default class SupabaseClient<
199185
* `"estimated"`: Uses exact count for low numbers and planned count for high
200186
* numbers.
201187
*/
202-
rpc<
188+
rpc: PostgrestClient<Database, SchemaName>['rpc'] = <
203189
FunctionName extends string & keyof Schema['Functions'],
204190
Function_ extends Schema['Functions'][FunctionName]
205191
>(
@@ -209,15 +195,7 @@ export default class SupabaseClient<
209195
head?: boolean
210196
count?: 'exact' | 'planned' | 'estimated'
211197
}
212-
): PostgrestFilterBuilder<
213-
Schema,
214-
Function_['Returns'] extends any[]
215-
? Function_['Returns'][number] extends Record<string, unknown>
216-
? Function_['Returns'][number]
217-
: never
218-
: never,
219-
Function_['Returns']
220-
> {
198+
) => {
221199
return this.rest.rpc(fn, args, options)
222200
}
223201

0 commit comments

Comments
 (0)