1- import { createClient , SupabaseClient } from "@supabase/supabase-js" ;
2- import type {
3- GenericSchema ,
1+ import {
2+ createClient ,
3+ SupabaseClient ,
44 SupabaseClientOptions ,
5- } from "@supabase/supabase-js/dist/module/lib/types " ;
5+ } from "@supabase/supabase-js" ;
66
77import { VERSION } from "./version" ;
88import { isBrowser } from "./utils" ;
@@ -36,12 +36,13 @@ let cachedBrowserClient: SupabaseClient<any, any, any> | undefined;
3636 */
3737export function createBrowserClient <
3838 Database = any ,
39- SchemaName extends string & keyof Database = "public" extends keyof Database
39+ SchemaName extends string &
40+ keyof Omit < Database , "__InternalSupabase" > = "public" extends keyof Omit <
41+ Database ,
42+ "__InternalSupabase"
43+ >
4044 ? "public"
41- : string & keyof Database ,
42- Schema extends GenericSchema = Database [ SchemaName ] extends GenericSchema
43- ? Database [ SchemaName ]
44- : any ,
45+ : string & keyof Omit < Database , "__InternalSupabase" > ,
4546> (
4647 supabaseUrl : string ,
4748 supabaseKey : string ,
@@ -51,7 +52,7 @@ export function createBrowserClient<
5152 cookieEncoding ?: "raw" | "base64url" ;
5253 isSingleton ?: boolean ;
5354 } ,
54- ) : SupabaseClient < Database , SchemaName , Schema > ;
55+ ) : SupabaseClient < Database , SchemaName > ;
5556
5657/**
5758 * @deprecated Please specify `getAll` and `setAll` cookie methods instead of
@@ -60,12 +61,13 @@ export function createBrowserClient<
6061 */
6162export function createBrowserClient <
6263 Database = any ,
63- SchemaName extends string & keyof Database = "public" extends keyof Database
64+ SchemaName extends string &
65+ keyof Omit < Database , "__InternalSupabase" > = "public" extends keyof Omit <
66+ Database ,
67+ "__InternalSupabase"
68+ >
6469 ? "public"
65- : string & keyof Database ,
66- Schema extends GenericSchema = Database [ SchemaName ] extends GenericSchema
67- ? Database [ SchemaName ]
68- : any ,
70+ : string & keyof Omit < Database , "__InternalSupabase" > ,
6971> (
7072 supabaseUrl : string ,
7173 supabaseKey : string ,
@@ -75,16 +77,17 @@ export function createBrowserClient<
7577 cookieEncoding ?: "raw" | "base64url" ;
7678 isSingleton ?: boolean ;
7779 } ,
78- ) : SupabaseClient < Database , SchemaName , Schema > ;
80+ ) : SupabaseClient < Database , SchemaName > ;
7981
8082export function createBrowserClient <
8183 Database = any ,
82- SchemaName extends string & keyof Database = "public" extends keyof Database
84+ SchemaName extends string &
85+ keyof Omit < Database , "__InternalSupabase" > = "public" extends keyof Omit <
86+ Database ,
87+ "__InternalSupabase"
88+ >
8389 ? "public"
84- : string & keyof Database ,
85- Schema extends GenericSchema = Database [ SchemaName ] extends GenericSchema
86- ? Database [ SchemaName ]
87- : any ,
90+ : string & keyof Omit < Database , "__InternalSupabase" > ,
8891> (
8992 supabaseUrl : string ,
9093 supabaseKey : string ,
@@ -94,7 +97,7 @@ export function createBrowserClient<
9497 cookieEncoding ?: "raw" | "base64url" ;
9598 isSingleton ?: boolean ;
9699 } ,
97- ) : SupabaseClient < Database , SchemaName , Schema > {
100+ ) : SupabaseClient < Database , SchemaName > {
98101 // singleton client is created only if isSingleton is set to true, or if isSingleton is not defined and we detect a browser
99102 const shouldUseSingleton =
100103 options ?. isSingleton === true ||
@@ -118,31 +121,28 @@ export function createBrowserClient<
118121 false ,
119122 ) ;
120123
121- const client = createClient < Database , SchemaName , Schema > (
122- supabaseUrl ,
123- supabaseKey ,
124- {
125- ...options ,
126- global : {
127- ...options ?. global ,
128- headers : {
129- ...options ?. global ?. headers ,
130- "X-Client-Info" : `supabase-ssr/${ VERSION } createBrowserClient` ,
131- } ,
132- } ,
133- auth : {
134- ...options ?. auth ,
135- ...( options ?. cookieOptions ?. name
136- ? { storageKey : options . cookieOptions . name }
137- : null ) ,
138- flowType : "pkce" ,
139- autoRefreshToken : isBrowser ( ) ,
140- detectSessionInUrl : isBrowser ( ) ,
141- persistSession : true ,
142- storage,
124+ const client = createClient < Database , SchemaName > ( supabaseUrl , supabaseKey , {
125+ // TODO: resolve type error
126+ ...( options as any ) ,
127+ global : {
128+ ...options ?. global ,
129+ headers : {
130+ ...options ?. global ?. headers ,
131+ "X-Client-Info" : `supabase-ssr/${ VERSION } createBrowserClient` ,
143132 } ,
144133 } ,
145- ) ;
134+ auth : {
135+ ...options ?. auth ,
136+ ...( options ?. cookieOptions ?. name
137+ ? { storageKey : options . cookieOptions . name }
138+ : null ) ,
139+ flowType : "pkce" ,
140+ autoRefreshToken : isBrowser ( ) ,
141+ detectSessionInUrl : isBrowser ( ) ,
142+ persistSession : true ,
143+ storage,
144+ } ,
145+ } ) ;
146146
147147 if ( shouldUseSingleton ) {
148148 cachedBrowserClient = client ;
0 commit comments