File tree Expand file tree Collapse file tree 2 files changed +13
-4
lines changed Expand file tree Collapse file tree 2 files changed +13
-4
lines changed Original file line number Diff line number Diff line change 1
1
// helpers.ts
2
+ import { SupabaseClientOptions } from './types'
2
3
3
4
export function uuid ( ) {
4
5
return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx' . replace ( / [ x y ] / g, function ( c ) {
@@ -14,7 +15,12 @@ export function stripTrailingSlash(url: string): string {
14
15
15
16
export const isBrowser = ( ) => typeof window !== 'undefined'
16
17
17
- export function applySettingDefaults (
18
+ export function applySettingDefaults <
19
+ Database = any ,
20
+ SchemaName extends string & keyof Database = 'public' extends keyof Database
21
+ ? 'public'
22
+ : string & keyof Database
23
+ > (
18
24
options : SupabaseClientOptions < SchemaName > ,
19
25
defaults : SupabaseClientOptions < any >
20
26
) : SupabaseClientOptions < SchemaName > {
Original file line number Diff line number Diff line change @@ -33,7 +33,10 @@ test('override setting defaults', async () => {
33
33
} ,
34
34
}
35
35
let settings = helpers . applySettingDefaults ( options , defaults )
36
- expect ( settings . auth . autoRefreshToken ) . toBe ( autoRefreshOption )
37
- expect ( settings . auth . persistSession ) . not . toBeNull ( )
38
- expect ( settings . db . schema ) . toBe ( defaults . db . schema )
36
+ expect ( settings ?. auth ?. autoRefreshToken ) . toBe ( autoRefreshOption )
37
+ // Existing default properties should not be overwritten
38
+ expect ( settings ?. auth ?. persistSession ) . not . toBeNull ( )
39
+ expect ( settings ?. global ?. headers ) . toBe ( DEFAULT_HEADERS )
40
+ // Existing property values should remain constant
41
+ expect ( settings ?. db ?. schema ) . toBe ( defaults . db . schema )
39
42
} )
You can’t perform that action at this time.
0 commit comments