1
- import { createClient , SupabaseClient } from "@supabase/supabase-js" ;
2
- import type {
3
- GenericSchema ,
1
+ import {
2
+ createClient ,
3
+ SupabaseClient ,
4
4
SupabaseClientOptions ,
5
- } from "@supabase/supabase-js/dist/module/lib/types " ;
5
+ } from "@supabase/supabase-js" ;
6
6
7
7
import { VERSION } from "./version" ;
8
8
import { isBrowser } from "./utils" ;
@@ -36,12 +36,13 @@ let cachedBrowserClient: SupabaseClient<any, any, any> | undefined;
36
36
*/
37
37
export function createBrowserClient <
38
38
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
+ >
40
44
? "public"
41
- : string & keyof Database ,
42
- Schema extends GenericSchema = Database [ SchemaName ] extends GenericSchema
43
- ? Database [ SchemaName ]
44
- : any ,
45
+ : string & keyof Omit < Database , "__InternalSupabase" > ,
45
46
> (
46
47
supabaseUrl : string ,
47
48
supabaseKey : string ,
@@ -51,7 +52,7 @@ export function createBrowserClient<
51
52
cookieEncoding ?: "raw" | "base64url" ;
52
53
isSingleton ?: boolean ;
53
54
} ,
54
- ) : SupabaseClient < Database , SchemaName , Schema > ;
55
+ ) : SupabaseClient < Database , SchemaName > ;
55
56
56
57
/**
57
58
* @deprecated Please specify `getAll` and `setAll` cookie methods instead of
@@ -60,12 +61,13 @@ export function createBrowserClient<
60
61
*/
61
62
export function createBrowserClient <
62
63
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
+ >
64
69
? "public"
65
- : string & keyof Database ,
66
- Schema extends GenericSchema = Database [ SchemaName ] extends GenericSchema
67
- ? Database [ SchemaName ]
68
- : any ,
70
+ : string & keyof Omit < Database , "__InternalSupabase" > ,
69
71
> (
70
72
supabaseUrl : string ,
71
73
supabaseKey : string ,
@@ -75,16 +77,17 @@ export function createBrowserClient<
75
77
cookieEncoding ?: "raw" | "base64url" ;
76
78
isSingleton ?: boolean ;
77
79
} ,
78
- ) : SupabaseClient < Database , SchemaName , Schema > ;
80
+ ) : SupabaseClient < Database , SchemaName > ;
79
81
80
82
export function createBrowserClient <
81
83
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
+ >
83
89
? "public"
84
- : string & keyof Database ,
85
- Schema extends GenericSchema = Database [ SchemaName ] extends GenericSchema
86
- ? Database [ SchemaName ]
87
- : any ,
90
+ : string & keyof Omit < Database , "__InternalSupabase" > ,
88
91
> (
89
92
supabaseUrl : string ,
90
93
supabaseKey : string ,
@@ -94,7 +97,7 @@ export function createBrowserClient<
94
97
cookieEncoding ?: "raw" | "base64url" ;
95
98
isSingleton ?: boolean ;
96
99
} ,
97
- ) : SupabaseClient < Database , SchemaName , Schema > {
100
+ ) : SupabaseClient < Database , SchemaName > {
98
101
// singleton client is created only if isSingleton is set to true, or if isSingleton is not defined and we detect a browser
99
102
const shouldUseSingleton =
100
103
options ?. isSingleton === true ||
@@ -118,31 +121,28 @@ export function createBrowserClient<
118
121
false ,
119
122
) ;
120
123
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` ,
143
132
} ,
144
133
} ,
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
+ } ) ;
146
146
147
147
if ( shouldUseSingleton ) {
148
148
cachedBrowserClient = client ;
0 commit comments