diff --git a/package-lock.json b/package-lock.json index 99851b82..5f07dd4d 100644 --- a/package-lock.json +++ b/package-lock.json @@ -12,7 +12,7 @@ "@supabase/auth-js": "2.65.1", "@supabase/functions-js": "2.4.3", "@supabase/node-fetch": "2.6.15", - "@supabase/postgrest-js": "1.16.3", + "@supabase/postgrest-js": "1.17.0", "@supabase/realtime-js": "2.10.7", "@supabase/storage-js": "2.7.1" }, @@ -1196,9 +1196,9 @@ } }, "node_modules/@supabase/postgrest-js": { - "version": "1.16.3", - "resolved": "https://registry.npmjs.org/@supabase/postgrest-js/-/postgrest-js-1.16.3.tgz", - "integrity": "sha512-HI6dsbW68AKlOPofUjDTaosiDBCtW4XAm0D18pPwxoW3zKOE2Ru13Z69Wuys9fd6iTpfDViNco5sgrtnP0666A==", + "version": "1.17.0", + "resolved": "https://registry.npmjs.org/@supabase/postgrest-js/-/postgrest-js-1.17.0.tgz", + "integrity": "sha512-vbtb72VpyCkDjcD95SAW4C+3B6NNEICNlEN9H6LcSfIxk5qPImwZ9hVYLa20i+P8GXmKWDoSjjJEK2j6qlR1qQ==", "dependencies": { "@supabase/node-fetch": "^2.6.14" } diff --git a/package.json b/package.json index fb375584..980a117b 100644 --- a/package.json +++ b/package.json @@ -43,7 +43,7 @@ "@supabase/auth-js": "2.65.1", "@supabase/functions-js": "2.4.3", "@supabase/node-fetch": "2.6.15", - "@supabase/postgrest-js": "1.16.3", + "@supabase/postgrest-js": "1.17.0", "@supabase/realtime-js": "2.10.7", "@supabase/storage-js": "2.7.1" }, diff --git a/src/SupabaseClient.ts b/src/SupabaseClient.ts index 9f0a32c7..996685fb 100644 --- a/src/SupabaseClient.ts +++ b/src/SupabaseClient.ts @@ -221,7 +221,9 @@ export default class SupabaseClient< ? Fn['Returns'][number] : never : never, - Fn['Returns'] + Fn['Returns'], + FnName, + null > { return this.rest.rpc(fn, args, options) } diff --git a/src/lib/types.ts b/src/lib/types.ts index 85531a0e..0b8d3290 100644 --- a/src/lib/types.ts +++ b/src/lib/types.ts @@ -80,16 +80,26 @@ export type SupabaseClientOptions = { accessToken?: () => Promise } +export type GenericRelationship = { + foreignKeyName: string + columns: string[] + isOneToOne?: boolean + referencedRelation: string + referencedColumns: string[] +} + export type GenericTable = { Row: Record Insert: Record Update: Record + Relationships: GenericRelationship[] } export type GenericUpdatableView = GenericTable export type GenericNonUpdatableView = { Row: Record + Relationships: GenericRelationship[] } export type GenericView = GenericUpdatableView | GenericNonUpdatableView diff --git a/test/index.test-d.ts b/test/index.test-d.ts index 13a8df1d..672e4697 100644 --- a/test/index.test-d.ts +++ b/test/index.test-d.ts @@ -84,7 +84,7 @@ const supabase = createClient(URL, KEY) if (error) { throw new Error(error.message) } - expectType(message.user) + expectType(message.user) } // one-to-many relationship @@ -99,8 +99,11 @@ const supabase = createClient(URL, KEY) // referencing missing column { type SelectQueryError = { error: true } & Message + const res = await supabase.from('users').select('username, dat') - expectType[]>>(res) + expectType< + PostgrestSingleResponse[]> + >(res) } // one-to-one relationship