@supabase/supabase-js 2.74.1-canary.6 → 2.74.1-canary.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (57) hide show
  1. package/dist/main/SupabaseClient.d.ts +6 -5
  2. package/dist/main/SupabaseClient.d.ts.map +1 -1
  3. package/dist/main/SupabaseClient.js +6 -2
  4. package/dist/main/SupabaseClient.js.map +1 -1
  5. package/dist/main/lib/rest/types/common/common/common.d.ts +46 -0
  6. package/dist/main/lib/rest/types/common/common/common.d.ts.map +1 -0
  7. package/dist/main/lib/rest/types/common/common/common.js +4 -0
  8. package/dist/main/lib/rest/types/common/common/common.js.map +1 -0
  9. package/dist/main/lib/rest/types/common/common/rpc.d.ts +37 -0
  10. package/dist/main/lib/rest/types/common/common/rpc.d.ts.map +1 -0
  11. package/dist/main/lib/rest/types/common/common/rpc.js +3 -0
  12. package/dist/main/lib/rest/types/common/common/rpc.js.map +1 -0
  13. package/dist/main/lib/rest/types/common/common.d.ts +46 -0
  14. package/dist/main/lib/rest/types/common/common.d.ts.map +1 -0
  15. package/dist/main/lib/rest/types/common/common.js +4 -0
  16. package/dist/main/lib/rest/types/common/common.js.map +1 -0
  17. package/dist/main/lib/rest/types/common/rpc.d.ts +37 -0
  18. package/dist/main/lib/rest/types/common/rpc.d.ts.map +1 -0
  19. package/dist/main/lib/rest/types/common/rpc.js +3 -0
  20. package/dist/main/lib/rest/types/common/rpc.js.map +1 -0
  21. package/dist/main/lib/types.d.ts +2 -29
  22. package/dist/main/lib/types.d.ts.map +1 -1
  23. package/dist/main/lib/version.d.ts +1 -1
  24. package/dist/main/lib/version.js +1 -1
  25. package/dist/module/SupabaseClient.d.ts +6 -5
  26. package/dist/module/SupabaseClient.d.ts.map +1 -1
  27. package/dist/module/SupabaseClient.js +7 -3
  28. package/dist/module/SupabaseClient.js.map +1 -1
  29. package/dist/module/lib/rest/types/common/common/common.d.ts +46 -0
  30. package/dist/module/lib/rest/types/common/common/common.d.ts.map +1 -0
  31. package/dist/module/lib/rest/types/common/common/common.js +3 -0
  32. package/dist/module/lib/rest/types/common/common/common.js.map +1 -0
  33. package/dist/module/lib/rest/types/common/common/rpc.d.ts +37 -0
  34. package/dist/module/lib/rest/types/common/common/rpc.d.ts.map +1 -0
  35. package/dist/module/lib/rest/types/common/common/rpc.js +2 -0
  36. package/dist/module/lib/rest/types/common/common/rpc.js.map +1 -0
  37. package/dist/module/lib/rest/types/common/common.d.ts +46 -0
  38. package/dist/module/lib/rest/types/common/common.d.ts.map +1 -0
  39. package/dist/module/lib/rest/types/common/common.js +3 -0
  40. package/dist/module/lib/rest/types/common/common.js.map +1 -0
  41. package/dist/module/lib/rest/types/common/rpc.d.ts +37 -0
  42. package/dist/module/lib/rest/types/common/rpc.d.ts.map +1 -0
  43. package/dist/module/lib/rest/types/common/rpc.js +2 -0
  44. package/dist/module/lib/rest/types/common/rpc.js.map +1 -0
  45. package/dist/module/lib/types.d.ts +2 -29
  46. package/dist/module/lib/types.d.ts.map +1 -1
  47. package/dist/module/lib/version.d.ts +1 -1
  48. package/dist/module/lib/version.js +1 -1
  49. package/dist/umd/supabase.js +1 -1
  50. package/package.json +6 -6
  51. package/src/SupabaseClient.ts +44 -22
  52. package/src/lib/rest/types/common/common/common.ts +56 -0
  53. package/src/lib/rest/types/common/common/rpc.ts +135 -0
  54. package/src/lib/rest/types/common/common.ts +56 -0
  55. package/src/lib/rest/types/common/rpc.ts +135 -0
  56. package/src/lib/types.ts +18 -35
  57. package/src/lib/version.ts +1 -1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@supabase/supabase-js",
3
- "version": "2.74.1-canary.6",
3
+ "version": "2.74.1-canary.7",
4
4
  "description": "Isomorphic Javascript client for Supabase",
5
5
  "keywords": [
6
6
  "javascript",
@@ -52,11 +52,11 @@
52
52
  "update:test-deps:bun": "npx nx build supabase-js && npm pack && cp supabase-supabase-js-*.tgz test/integration/bun/supabase-supabase-js-0.0.0-automated.tgz && cd test/integration/bun && bun install"
53
53
  },
54
54
  "dependencies": {
55
- "@supabase/auth-js": "2.74.1-canary.6",
56
- "@supabase/functions-js": "2.74.1-canary.6",
57
- "@supabase/postgrest-js": "2.74.1-canary.6",
58
- "@supabase/realtime-js": "2.74.1-canary.6",
59
- "@supabase/storage-js": "2.74.1-canary.6",
55
+ "@supabase/auth-js": "2.74.1-canary.7",
56
+ "@supabase/functions-js": "2.74.1-canary.7",
57
+ "@supabase/postgrest-js": "2.74.1-canary.7",
58
+ "@supabase/realtime-js": "2.74.1-canary.7",
59
+ "@supabase/storage-js": "2.74.1-canary.7",
60
60
  "@supabase/node-fetch": "2.6.15"
61
61
  },
62
62
  "devDependencies": {
@@ -1,27 +1,33 @@
1
+ import type { AuthChangeEvent } from '@supabase/auth-js'
1
2
  import { FunctionsClient } from '@supabase/functions-js'
2
- import { AuthChangeEvent } from '@supabase/auth-js'
3
3
  import {
4
4
  PostgrestClient,
5
- PostgrestFilterBuilder,
6
- PostgrestQueryBuilder,
5
+ type PostgrestFilterBuilder,
6
+ type PostgrestQueryBuilder,
7
7
  } from '@supabase/postgrest-js'
8
8
  import {
9
- RealtimeChannel,
10
- RealtimeChannelOptions,
9
+ type RealtimeChannel,
10
+ type RealtimeChannelOptions,
11
11
  RealtimeClient,
12
- RealtimeClientOptions,
12
+ type RealtimeClientOptions,
13
13
  } from '@supabase/realtime-js'
14
14
  import { StorageClient as SupabaseStorageClient } from '@supabase/storage-js'
15
15
  import {
16
- DEFAULT_GLOBAL_OPTIONS,
17
- DEFAULT_DB_OPTIONS,
18
16
  DEFAULT_AUTH_OPTIONS,
17
+ DEFAULT_DB_OPTIONS,
18
+ DEFAULT_GLOBAL_OPTIONS,
19
19
  DEFAULT_REALTIME_OPTIONS,
20
20
  } from './lib/constants'
21
21
  import { fetchWithAuth } from './lib/fetch'
22
22
  import { applySettingDefaults, validateSupabaseUrl } from './lib/helpers'
23
23
  import { SupabaseAuthClient } from './lib/SupabaseAuthClient'
24
- import { Fetch, GenericSchema, SupabaseClientOptions, SupabaseAuthClientOptions } from './lib/types'
24
+ import type {
25
+ Fetch,
26
+ GenericSchema,
27
+ SupabaseAuthClientOptions,
28
+ SupabaseClientOptions,
29
+ } from './lib/types'
30
+ import { GetRpcFunctionFilterBuilderByArgs } from './lib/rest/types/common/rpc'
25
31
 
26
32
  /**
27
33
  * Supabase Client.
@@ -238,28 +244,44 @@ export default class SupabaseClient<
238
244
  * `"estimated"`: Uses exact count for low numbers and planned count for high
239
245
  * numbers.
240
246
  */
241
- rpc<FnName extends string & keyof Schema['Functions'], Fn extends Schema['Functions'][FnName]>(
247
+ rpc<
248
+ FnName extends string & keyof Schema['Functions'],
249
+ Args extends Schema['Functions'][FnName]['Args'] = never,
250
+ FilterBuilder extends GetRpcFunctionFilterBuilderByArgs<
251
+ Schema,
252
+ FnName,
253
+ Args
254
+ > = GetRpcFunctionFilterBuilderByArgs<Schema, FnName, Args>,
255
+ >(
242
256
  fn: FnName,
243
- args: Fn['Args'] = {},
257
+ args: Args = {} as Args,
244
258
  options: {
245
259
  head?: boolean
246
260
  get?: boolean
247
261
  count?: 'exact' | 'planned' | 'estimated'
248
- } = {}
262
+ } = {
263
+ head: false,
264
+ get: false,
265
+ count: undefined,
266
+ }
249
267
  ): PostgrestFilterBuilder<
250
268
  ClientOptions,
251
269
  Schema,
252
- Fn['Returns'] extends any[]
253
- ? Fn['Returns'][number] extends Record<string, unknown>
254
- ? Fn['Returns'][number]
255
- : never
256
- : never,
257
- Fn['Returns'],
258
- FnName,
259
- null,
270
+ FilterBuilder['Row'],
271
+ FilterBuilder['Result'],
272
+ FilterBuilder['RelationName'],
273
+ FilterBuilder['Relationships'],
260
274
  'RPC'
261
275
  > {
262
- return this.rest.rpc(fn, args, options)
276
+ return this.rest.rpc(fn, args, options) as unknown as PostgrestFilterBuilder<
277
+ ClientOptions,
278
+ Schema,
279
+ FilterBuilder['Row'],
280
+ FilterBuilder['Result'],
281
+ FilterBuilder['RelationName'],
282
+ FilterBuilder['Relationships'],
283
+ 'RPC'
284
+ >
263
285
  }
264
286
 
265
287
  /**
@@ -355,7 +377,7 @@ export default class SupabaseClient<
355
377
  }
356
378
 
357
379
  private _listenForAuthEvents() {
358
- let data = this.auth.onAuthStateChange((event, session) => {
380
+ const data = this.auth.onAuthStateChange((event, session) => {
359
381
  this._handleTokenChanged(event, 'CLIENT', session?.access_token)
360
382
  })
361
383
  return data
@@ -0,0 +1,56 @@
1
+ // Types that are shared between supabase-js and postgrest-js
2
+
3
+ export type Fetch = typeof fetch
4
+
5
+ export type GenericRelationship = {
6
+ foreignKeyName: string
7
+ columns: string[]
8
+ isOneToOne?: boolean
9
+ referencedRelation: string
10
+ referencedColumns: string[]
11
+ }
12
+
13
+ export type GenericTable = {
14
+ Row: Record<string, unknown>
15
+ Insert: Record<string, unknown>
16
+ Update: Record<string, unknown>
17
+ Relationships: GenericRelationship[]
18
+ }
19
+
20
+ export type GenericUpdatableView = {
21
+ Row: Record<string, unknown>
22
+ Insert: Record<string, unknown>
23
+ Update: Record<string, unknown>
24
+ Relationships: GenericRelationship[]
25
+ }
26
+
27
+ export type GenericNonUpdatableView = {
28
+ Row: Record<string, unknown>
29
+ Relationships: GenericRelationship[]
30
+ }
31
+
32
+ export type GenericView = GenericUpdatableView | GenericNonUpdatableView
33
+
34
+ export type GenericSetofOption = {
35
+ isSetofReturn?: boolean | undefined
36
+ isOneToOne?: boolean | undefined
37
+ isNotNullable?: boolean | undefined
38
+ to: string
39
+ from: string
40
+ }
41
+
42
+ export type GenericFunction = {
43
+ Args: Record<string, unknown> | never
44
+ Returns: unknown
45
+ SetofOptions?: GenericSetofOption
46
+ }
47
+
48
+ export type GenericSchema = {
49
+ Tables: Record<string, GenericTable>
50
+ Views: Record<string, GenericView>
51
+ Functions: Record<string, GenericFunction>
52
+ }
53
+
54
+ export type ClientServerOptions = {
55
+ PostgrestVersion?: string
56
+ }
@@ -0,0 +1,135 @@
1
+ import type { GenericFunction, GenericSchema, GenericSetofOption } from './common'
2
+
3
+ // Functions matching utils
4
+ type IsMatchingArgs<
5
+ FnArgs extends GenericFunction['Args'],
6
+ PassedArgs extends GenericFunction['Args'],
7
+ > = [FnArgs] extends [Record<PropertyKey, never>]
8
+ ? PassedArgs extends Record<PropertyKey, never>
9
+ ? true
10
+ : false
11
+ : keyof PassedArgs extends keyof FnArgs
12
+ ? PassedArgs extends FnArgs
13
+ ? true
14
+ : false
15
+ : false
16
+
17
+ type MatchingFunctionArgs<
18
+ Fn extends GenericFunction,
19
+ Args extends GenericFunction['Args'],
20
+ > = Fn extends { Args: infer A extends GenericFunction['Args'] }
21
+ ? IsMatchingArgs<A, Args> extends true
22
+ ? Fn
23
+ : never
24
+ : false
25
+
26
+ type FindMatchingFunctionByArgs<
27
+ FnUnion,
28
+ Args extends GenericFunction['Args'],
29
+ > = FnUnion extends infer Fn extends GenericFunction ? MatchingFunctionArgs<Fn, Args> : false
30
+
31
+ // Types for working with database schemas
32
+ type TablesAndViews<Schema extends GenericSchema> = Schema['Tables'] & Exclude<Schema['Views'], ''>
33
+
34
+ // Utility types for working with unions
35
+ type UnionToIntersection<U> = (U extends any ? (k: U) => void : never) extends (k: infer I) => void
36
+ ? I
37
+ : never
38
+
39
+ type LastOf<T> =
40
+ UnionToIntersection<T extends any ? () => T : never> extends () => infer R ? R : never
41
+
42
+ type IsAny<T> = 0 extends 1 & T ? true : false
43
+
44
+ type ExactMatch<T, S> = [T] extends [S] ? ([S] extends [T] ? true : false) : false
45
+
46
+ type ExtractExactFunction<Fns, Args> = Fns extends infer F
47
+ ? F extends GenericFunction
48
+ ? ExactMatch<F['Args'], Args> extends true
49
+ ? F
50
+ : never
51
+ : never
52
+ : never
53
+
54
+ type IsNever<T> = [T] extends [never] ? true : false
55
+
56
+ type RpcFunctionNotFound<FnName> = {
57
+ Row: any
58
+ Result: {
59
+ error: true
60
+ } & "Couldn't infer function definition matching provided arguments"
61
+ RelationName: FnName
62
+ Relationships: null
63
+ }
64
+
65
+ export type GetRpcFunctionFilterBuilderByArgs<
66
+ Schema extends GenericSchema,
67
+ FnName extends string & keyof Schema['Functions'],
68
+ Args,
69
+ > = {
70
+ 0: Schema['Functions'][FnName]
71
+ // If the Args is exactly never (function call without any params)
72
+ 1: IsAny<Schema> extends true
73
+ ? any
74
+ : IsNever<Args> extends true
75
+ ? // This is for retro compatibility, if the funcition is defined with an single return and an union of Args
76
+ // we fallback to the last function definition matched by name
77
+ IsNever<ExtractExactFunction<Schema['Functions'][FnName], Args>> extends true
78
+ ? LastOf<Schema['Functions'][FnName]>
79
+ : ExtractExactFunction<Schema['Functions'][FnName], Args>
80
+ : Args extends Record<PropertyKey, never>
81
+ ? LastOf<Schema['Functions'][FnName]>
82
+ : // Otherwise, we attempt to match with one of the function definition in the union based
83
+ // on the function arguments provided
84
+ Args extends GenericFunction['Args']
85
+ ? // This is for retro compatibility, if the funcition is defined with an single return and an union of Args
86
+ // we fallback to the last function definition matched by name
87
+ IsNever<
88
+ LastOf<FindMatchingFunctionByArgs<Schema['Functions'][FnName], Args>>
89
+ > extends true
90
+ ? LastOf<Schema['Functions'][FnName]>
91
+ : // Otherwise, we use the arguments based function definition narrowing to get the right value
92
+ LastOf<FindMatchingFunctionByArgs<Schema['Functions'][FnName], Args>>
93
+ : // If we can't find a matching function by args, we try to find one by function name
94
+ ExtractExactFunction<Schema['Functions'][FnName], Args> extends GenericFunction
95
+ ? ExtractExactFunction<Schema['Functions'][FnName], Args>
96
+ : any
97
+ }[1] extends infer Fn
98
+ ? // If we are dealing with an non-typed client everything is any
99
+ IsAny<Fn> extends true
100
+ ? { Row: any; Result: any; RelationName: FnName; Relationships: null }
101
+ : // Otherwise, we use the arguments based function definition narrowing to get the rigt value
102
+ Fn extends GenericFunction
103
+ ? {
104
+ Row: Fn['SetofOptions'] extends GenericSetofOption
105
+ ? Fn['SetofOptions']['isSetofReturn'] extends true
106
+ ? TablesAndViews<Schema>[Fn['SetofOptions']['to']]['Row']
107
+ : TablesAndViews<Schema>[Fn['SetofOptions']['to']]['Row']
108
+ : Fn['Returns'] extends any[]
109
+ ? Fn['Returns'][number] extends Record<string, unknown>
110
+ ? Fn['Returns'][number]
111
+ : never
112
+ : Fn['Returns'] extends Record<string, unknown>
113
+ ? Fn['Returns']
114
+ : never
115
+ Result: Fn['SetofOptions'] extends GenericSetofOption
116
+ ? Fn['SetofOptions']['isSetofReturn'] extends true
117
+ ? Fn['SetofOptions']['isOneToOne'] extends true
118
+ ? Fn['Returns'][]
119
+ : Fn['Returns']
120
+ : Fn['Returns']
121
+ : Fn['Returns']
122
+ RelationName: Fn['SetofOptions'] extends GenericSetofOption
123
+ ? Fn['SetofOptions']['to']
124
+ : FnName
125
+ Relationships: Fn['SetofOptions'] extends GenericSetofOption
126
+ ? Fn['SetofOptions']['to'] extends keyof Schema['Tables']
127
+ ? Schema['Tables'][Fn['SetofOptions']['to']]['Relationships']
128
+ : Schema['Views'][Fn['SetofOptions']['to']]['Relationships']
129
+ : null
130
+ }
131
+ : // If we failed to find the function by argument, we still pass with any but also add an overridable
132
+ Fn extends false
133
+ ? RpcFunctionNotFound<FnName>
134
+ : RpcFunctionNotFound<FnName>
135
+ : RpcFunctionNotFound<FnName>
@@ -0,0 +1,56 @@
1
+ // Types that are shared between supabase-js and postgrest-js
2
+
3
+ export type Fetch = typeof fetch
4
+
5
+ export type GenericRelationship = {
6
+ foreignKeyName: string
7
+ columns: string[]
8
+ isOneToOne?: boolean
9
+ referencedRelation: string
10
+ referencedColumns: string[]
11
+ }
12
+
13
+ export type GenericTable = {
14
+ Row: Record<string, unknown>
15
+ Insert: Record<string, unknown>
16
+ Update: Record<string, unknown>
17
+ Relationships: GenericRelationship[]
18
+ }
19
+
20
+ export type GenericUpdatableView = {
21
+ Row: Record<string, unknown>
22
+ Insert: Record<string, unknown>
23
+ Update: Record<string, unknown>
24
+ Relationships: GenericRelationship[]
25
+ }
26
+
27
+ export type GenericNonUpdatableView = {
28
+ Row: Record<string, unknown>
29
+ Relationships: GenericRelationship[]
30
+ }
31
+
32
+ export type GenericView = GenericUpdatableView | GenericNonUpdatableView
33
+
34
+ export type GenericSetofOption = {
35
+ isSetofReturn?: boolean | undefined
36
+ isOneToOne?: boolean | undefined
37
+ isNotNullable?: boolean | undefined
38
+ to: string
39
+ from: string
40
+ }
41
+
42
+ export type GenericFunction = {
43
+ Args: Record<string, unknown> | never
44
+ Returns: unknown
45
+ SetofOptions?: GenericSetofOption
46
+ }
47
+
48
+ export type GenericSchema = {
49
+ Tables: Record<string, GenericTable>
50
+ Views: Record<string, GenericView>
51
+ Functions: Record<string, GenericFunction>
52
+ }
53
+
54
+ export type ClientServerOptions = {
55
+ PostgrestVersion?: string
56
+ }
@@ -0,0 +1,135 @@
1
+ import type { GenericFunction, GenericSchema, GenericSetofOption } from './common'
2
+
3
+ // Functions matching utils
4
+ type IsMatchingArgs<
5
+ FnArgs extends GenericFunction['Args'],
6
+ PassedArgs extends GenericFunction['Args'],
7
+ > = [FnArgs] extends [Record<PropertyKey, never>]
8
+ ? PassedArgs extends Record<PropertyKey, never>
9
+ ? true
10
+ : false
11
+ : keyof PassedArgs extends keyof FnArgs
12
+ ? PassedArgs extends FnArgs
13
+ ? true
14
+ : false
15
+ : false
16
+
17
+ type MatchingFunctionArgs<
18
+ Fn extends GenericFunction,
19
+ Args extends GenericFunction['Args'],
20
+ > = Fn extends { Args: infer A extends GenericFunction['Args'] }
21
+ ? IsMatchingArgs<A, Args> extends true
22
+ ? Fn
23
+ : never
24
+ : false
25
+
26
+ type FindMatchingFunctionByArgs<
27
+ FnUnion,
28
+ Args extends GenericFunction['Args'],
29
+ > = FnUnion extends infer Fn extends GenericFunction ? MatchingFunctionArgs<Fn, Args> : false
30
+
31
+ // Types for working with database schemas
32
+ type TablesAndViews<Schema extends GenericSchema> = Schema['Tables'] & Exclude<Schema['Views'], ''>
33
+
34
+ // Utility types for working with unions
35
+ type UnionToIntersection<U> = (U extends any ? (k: U) => void : never) extends (k: infer I) => void
36
+ ? I
37
+ : never
38
+
39
+ type LastOf<T> =
40
+ UnionToIntersection<T extends any ? () => T : never> extends () => infer R ? R : never
41
+
42
+ type IsAny<T> = 0 extends 1 & T ? true : false
43
+
44
+ type ExactMatch<T, S> = [T] extends [S] ? ([S] extends [T] ? true : false) : false
45
+
46
+ type ExtractExactFunction<Fns, Args> = Fns extends infer F
47
+ ? F extends GenericFunction
48
+ ? ExactMatch<F['Args'], Args> extends true
49
+ ? F
50
+ : never
51
+ : never
52
+ : never
53
+
54
+ type IsNever<T> = [T] extends [never] ? true : false
55
+
56
+ type RpcFunctionNotFound<FnName> = {
57
+ Row: any
58
+ Result: {
59
+ error: true
60
+ } & "Couldn't infer function definition matching provided arguments"
61
+ RelationName: FnName
62
+ Relationships: null
63
+ }
64
+
65
+ export type GetRpcFunctionFilterBuilderByArgs<
66
+ Schema extends GenericSchema,
67
+ FnName extends string & keyof Schema['Functions'],
68
+ Args,
69
+ > = {
70
+ 0: Schema['Functions'][FnName]
71
+ // If the Args is exactly never (function call without any params)
72
+ 1: IsAny<Schema> extends true
73
+ ? any
74
+ : IsNever<Args> extends true
75
+ ? // This is for retro compatibility, if the funcition is defined with an single return and an union of Args
76
+ // we fallback to the last function definition matched by name
77
+ IsNever<ExtractExactFunction<Schema['Functions'][FnName], Args>> extends true
78
+ ? LastOf<Schema['Functions'][FnName]>
79
+ : ExtractExactFunction<Schema['Functions'][FnName], Args>
80
+ : Args extends Record<PropertyKey, never>
81
+ ? LastOf<Schema['Functions'][FnName]>
82
+ : // Otherwise, we attempt to match with one of the function definition in the union based
83
+ // on the function arguments provided
84
+ Args extends GenericFunction['Args']
85
+ ? // This is for retro compatibility, if the funcition is defined with an single return and an union of Args
86
+ // we fallback to the last function definition matched by name
87
+ IsNever<
88
+ LastOf<FindMatchingFunctionByArgs<Schema['Functions'][FnName], Args>>
89
+ > extends true
90
+ ? LastOf<Schema['Functions'][FnName]>
91
+ : // Otherwise, we use the arguments based function definition narrowing to get the right value
92
+ LastOf<FindMatchingFunctionByArgs<Schema['Functions'][FnName], Args>>
93
+ : // If we can't find a matching function by args, we try to find one by function name
94
+ ExtractExactFunction<Schema['Functions'][FnName], Args> extends GenericFunction
95
+ ? ExtractExactFunction<Schema['Functions'][FnName], Args>
96
+ : any
97
+ }[1] extends infer Fn
98
+ ? // If we are dealing with an non-typed client everything is any
99
+ IsAny<Fn> extends true
100
+ ? { Row: any; Result: any; RelationName: FnName; Relationships: null }
101
+ : // Otherwise, we use the arguments based function definition narrowing to get the rigt value
102
+ Fn extends GenericFunction
103
+ ? {
104
+ Row: Fn['SetofOptions'] extends GenericSetofOption
105
+ ? Fn['SetofOptions']['isSetofReturn'] extends true
106
+ ? TablesAndViews<Schema>[Fn['SetofOptions']['to']]['Row']
107
+ : TablesAndViews<Schema>[Fn['SetofOptions']['to']]['Row']
108
+ : Fn['Returns'] extends any[]
109
+ ? Fn['Returns'][number] extends Record<string, unknown>
110
+ ? Fn['Returns'][number]
111
+ : never
112
+ : Fn['Returns'] extends Record<string, unknown>
113
+ ? Fn['Returns']
114
+ : never
115
+ Result: Fn['SetofOptions'] extends GenericSetofOption
116
+ ? Fn['SetofOptions']['isSetofReturn'] extends true
117
+ ? Fn['SetofOptions']['isOneToOne'] extends true
118
+ ? Fn['Returns'][]
119
+ : Fn['Returns']
120
+ : Fn['Returns']
121
+ : Fn['Returns']
122
+ RelationName: Fn['SetofOptions'] extends GenericSetofOption
123
+ ? Fn['SetofOptions']['to']
124
+ : FnName
125
+ Relationships: Fn['SetofOptions'] extends GenericSetofOption
126
+ ? Fn['SetofOptions']['to'] extends keyof Schema['Tables']
127
+ ? Schema['Tables'][Fn['SetofOptions']['to']]['Relationships']
128
+ : Schema['Views'][Fn['SetofOptions']['to']]['Relationships']
129
+ : null
130
+ }
131
+ : // If we failed to find the function by argument, we still pass with any but also add an overridable
132
+ Fn extends false
133
+ ? RpcFunctionNotFound<FnName>
134
+ : RpcFunctionNotFound<FnName>
135
+ : RpcFunctionNotFound<FnName>
package/src/lib/types.ts CHANGED
@@ -2,6 +2,24 @@ import { AuthClient } from '@supabase/auth-js'
2
2
  import { RealtimeClientOptions } from '@supabase/realtime-js'
3
3
  import { PostgrestError } from '@supabase/postgrest-js'
4
4
  import type { StorageClientOptions } from '@supabase/storage-js'
5
+ import type {
6
+ GenericSchema,
7
+ GenericRelationship,
8
+ GenericTable,
9
+ GenericUpdatableView,
10
+ GenericNonUpdatableView,
11
+ GenericView,
12
+ GenericFunction,
13
+ } from './rest/types/common/common'
14
+ export type {
15
+ GenericSchema,
16
+ GenericRelationship,
17
+ GenericTable,
18
+ GenericUpdatableView,
19
+ GenericNonUpdatableView,
20
+ GenericView,
21
+ GenericFunction,
22
+ }
5
23
 
6
24
  type AuthClientOptions = ConstructorParameters<typeof AuthClient>[0]
7
25
 
@@ -90,41 +108,6 @@ export type SupabaseClientOptions<SchemaName> = {
90
108
  accessToken?: () => Promise<string | null>
91
109
  }
92
110
 
93
- export type GenericRelationship = {
94
- foreignKeyName: string
95
- columns: string[]
96
- isOneToOne?: boolean
97
- referencedRelation: string
98
- referencedColumns: string[]
99
- }
100
-
101
- export type GenericTable = {
102
- Row: Record<string, unknown>
103
- Insert: Record<string, unknown>
104
- Update: Record<string, unknown>
105
- Relationships: GenericRelationship[]
106
- }
107
-
108
- export type GenericUpdatableView = GenericTable
109
-
110
- export type GenericNonUpdatableView = {
111
- Row: Record<string, unknown>
112
- Relationships: GenericRelationship[]
113
- }
114
-
115
- export type GenericView = GenericUpdatableView | GenericNonUpdatableView
116
-
117
- export type GenericFunction = {
118
- Args: Record<string, unknown>
119
- Returns: unknown
120
- }
121
-
122
- export type GenericSchema = {
123
- Tables: Record<string, GenericTable>
124
- Views: Record<string, GenericView>
125
- Functions: Record<string, GenericFunction>
126
- }
127
-
128
111
  /**
129
112
  * Helper types for query results.
130
113
  */
@@ -4,4 +4,4 @@
4
4
  // - Debugging and support (identifying which version is running)
5
5
  // - Telemetry and logging (version reporting in errors/analytics)
6
6
  // - Ensuring build artifacts match the published package version
7
- export const version = '2.74.1-canary.6'
7
+ export const version = '2.74.1-canary.7'