Skip to content

Commit 7e9fbd6

Browse files
committed
wip: exclude __InternalSupabase
1 parent 2ab66c0 commit 7e9fbd6

File tree

3 files changed

+10
-6
lines changed

3 files changed

+10
-6
lines changed

src/SupabaseClient.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,10 @@ export default class SupabaseClient<
3434
// support both cases.
3535
// TODO: Allow setting db_schema from ClientOptions.
3636
SchemaNameOrClientOptions extends
37-
| (string & keyof Database)
38-
| { PostgrestVersion: string } = 'public' extends keyof Database
37+
| (string & keyof Omit<Database, '__InternalSupabase'>)
38+
| { PostgrestVersion: string } = 'public' extends keyof Omit<Database, '__InternalSupabase'>
3939
? 'public'
40-
: string & keyof Database,
40+
: string & keyof Omit<Database, '__InternalSupabase'>,
4141
SchemaName extends string &
4242
keyof Omit<Database, '__InternalSupabase'> = SchemaNameOrClientOptions extends string &
4343
keyof Omit<Database, '__InternalSupabase'>

src/index.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,10 @@ export type { SupabaseClientOptions, QueryResult, QueryData, QueryError } from '
2727
export const createClient = <
2828
Database = any,
2929
SchemaNameOrClientOptions extends
30-
| (string & keyof Database)
31-
| { PostgrestVersion: string } = 'public' extends keyof Database
30+
| (string & keyof Omit<Database, '__InternalSupabase'>)
31+
| { PostgrestVersion: string } = 'public' extends keyof Omit<Database, '__InternalSupabase'>
3232
? 'public'
33-
: string & keyof Database,
33+
: string & keyof Omit<Database, '__InternalSupabase'>,
3434
SchemaName extends string &
3535
keyof Omit<Database, '__InternalSupabase'> = SchemaNameOrClientOptions extends string &
3636
keyof Omit<Database, '__InternalSupabase'>

test/types/index.test-d.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,10 @@ const supabase = createClient<Database>(URL, KEY)
188188
// Note: The template argument properties (PostgrestVersion) will not be autocompleted
189189
// due to a Typescript bug tracked here: https://github.com/microsoft/TypeScript/issues/56299
190190
const pg13Client = createClient<DatabaseWithInternals>('HTTP://localhost:3000', KEY)
191+
// @ts-expect-error should raise error if providing __InternalSupabase as schema name
192+
createClient<DatabaseWithInternals, '__InternalSupabase'>('HTTP://localhost:3000', KEY)
193+
// @ts-expect-error should raise error if providing __InternalSupabase as schema name
194+
new SupabaseClient<DatabaseWithInternals, '__InternalSupabase'>('HTTP://localhost:3000', KEY)
191195
const pg12Client = createClient<Database>('HTTP://localhost:3000', KEY)
192196
const res13 = await pg13Client.from('shops').update({ id: 21 }).maxAffected(1)
193197
const res12 = await pg12Client.from('shops').update({ id: 21 }).maxAffected(1)

0 commit comments

Comments
 (0)