@supabase/supabase-js 2.79.1-canary.1 → 2.80.0
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.
- package/README.md +50 -283
- package/dist/main/SupabaseClient.d.ts +6 -5
- package/dist/main/SupabaseClient.d.ts.map +1 -1
- package/dist/main/SupabaseClient.js +15 -21
- package/dist/main/SupabaseClient.js.map +1 -1
- package/dist/main/lib/fetch.d.ts +4 -1
- package/dist/main/lib/fetch.d.ts.map +1 -1
- package/dist/main/lib/fetch.js +5 -59
- package/dist/main/lib/fetch.js.map +1 -1
- package/dist/main/lib/helpers.js +1 -10
- package/dist/main/lib/helpers.js.map +1 -1
- package/dist/main/lib/rest/types/common/common.d.ts +55 -0
- package/dist/main/lib/rest/types/common/common.d.ts.map +1 -0
- package/dist/main/lib/rest/types/common/common.js +12 -0
- package/dist/main/lib/rest/types/common/common.js.map +1 -0
- package/dist/main/lib/rest/types/common/rpc.d.ts +46 -0
- package/dist/main/lib/rest/types/common/rpc.d.ts.map +1 -0
- package/dist/main/lib/rest/types/common/rpc.js +12 -0
- package/dist/main/lib/rest/types/common/rpc.js.map +1 -0
- package/dist/main/lib/types.d.ts +11 -34
- package/dist/main/lib/types.d.ts.map +1 -1
- package/dist/main/lib/version.d.ts +1 -1
- package/dist/main/lib/version.d.ts.map +1 -1
- package/dist/main/lib/version.js +1 -1
- package/dist/main/lib/version.js.map +1 -1
- package/dist/module/SupabaseClient.d.ts +6 -5
- package/dist/module/SupabaseClient.d.ts.map +1 -1
- package/dist/module/SupabaseClient.js +16 -22
- package/dist/module/SupabaseClient.js.map +1 -1
- package/dist/module/lib/fetch.d.ts +4 -1
- package/dist/module/lib/fetch.d.ts.map +1 -1
- package/dist/module/lib/fetch.js +5 -26
- package/dist/module/lib/fetch.js.map +1 -1
- package/dist/module/lib/helpers.js +1 -10
- package/dist/module/lib/helpers.js.map +1 -1
- package/dist/module/lib/rest/types/common/common.d.ts +55 -0
- package/dist/module/lib/rest/types/common/common.d.ts.map +1 -0
- package/dist/module/lib/rest/types/common/common.js +11 -0
- package/dist/module/lib/rest/types/common/common.js.map +1 -0
- package/dist/module/lib/rest/types/common/rpc.d.ts +46 -0
- package/dist/module/lib/rest/types/common/rpc.d.ts.map +1 -0
- package/dist/module/lib/rest/types/common/rpc.js +11 -0
- package/dist/module/lib/rest/types/common/rpc.js.map +1 -0
- package/dist/module/lib/types.d.ts +11 -34
- package/dist/module/lib/types.d.ts.map +1 -1
- package/dist/module/lib/version.d.ts +1 -1
- package/dist/module/lib/version.d.ts.map +1 -1
- package/dist/module/lib/version.js +1 -1
- package/dist/module/lib/version.js.map +1 -1
- package/dist/umd/supabase.js +1 -1
- package/package.json +48 -24
- package/src/SupabaseClient.ts +46 -22
- package/src/lib/fetch.ts +2 -14
- package/src/lib/rest/types/common/common.ts +66 -0
- package/src/lib/rest/types/common/rpc.ts +145 -0
- package/src/lib/types.ts +27 -41
- package/src/lib/version.ts +1 -1
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@supabase/supabase-js",
|
|
3
|
-
"version": "2.
|
|
4
|
-
"description": "Isomorphic Javascript
|
|
3
|
+
"version": "2.80.0",
|
|
4
|
+
"description": "Isomorphic Javascript SDK for Supabase",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"javascript",
|
|
7
7
|
"typescript",
|
|
@@ -25,53 +25,77 @@
|
|
|
25
25
|
"directory": "packages/core/supabase-js"
|
|
26
26
|
},
|
|
27
27
|
"scripts": {
|
|
28
|
-
"
|
|
29
|
-
"build": "npm run clean && npx nx build:main supabase-js && npx nx build:module supabase-js && npx nx build:umd supabase-js",
|
|
28
|
+
"build": "npm run build:main && npm run build:module && npm run build:umd",
|
|
30
29
|
"build:main": "tsc -p tsconfig.json",
|
|
31
30
|
"build:module": "tsc -p tsconfig.module.json",
|
|
32
31
|
"build:umd": "webpack --env mode=production",
|
|
33
|
-
"test": "
|
|
34
|
-
"test:all": "
|
|
32
|
+
"test": "npm run test:types && npm run test:run",
|
|
33
|
+
"test:all": "npm run test:types && npm run test:run && npm run test:integration && npm run test:integration:browser",
|
|
35
34
|
"test:run": "jest --runInBand --detectOpenHandles",
|
|
36
35
|
"test:unit": "jest --runInBand --detectOpenHandles test/unit",
|
|
37
36
|
"test:coverage": "jest --runInBand --coverage --testPathIgnorePatterns=\"test/integration|test/deno\"",
|
|
38
37
|
"test:integration": "jest --runInBand --detectOpenHandles test/integration.test.ts",
|
|
39
38
|
"test:integration:browser": "deno test --allow-all test/integration.browser.test.ts",
|
|
40
|
-
"test:edge-functions": "
|
|
39
|
+
"test:edge-functions": "cd test/deno && npm run test:edge-functions",
|
|
40
|
+
"test:deno": "cd test/deno && npm run test",
|
|
41
41
|
"test:watch": "jest --watch --verbose false --silent false",
|
|
42
42
|
"test:node:playwright": "cd test/integration/node-browser && npm install && cp ../../../dist/umd/supabase.js . && npm run test",
|
|
43
43
|
"test:bun": "cd test/integration/bun && bun install && bun test",
|
|
44
|
-
"test:
|
|
44
|
+
"test:expo": "cd test/integration/expo && npm test",
|
|
45
|
+
"test:next": "cd test/integration/next && npm test",
|
|
46
|
+
"test:types": "tsd --files test/types/*.test-d.ts && jsr publish --dry-run --allow-dirty",
|
|
45
47
|
"docs": "typedoc --entryPoints src/index.ts --out docs/v2",
|
|
46
48
|
"docs:json": "typedoc --entryPoints src/index.ts --json docs/v2/spec.json --excludeExternals",
|
|
47
49
|
"serve:coverage": "npx nx test:coverage supabase-js && serve test/coverage",
|
|
48
|
-
"update:test-deps": "
|
|
49
|
-
"update:test-deps:expo": "
|
|
50
|
-
"update:test-deps:next": "
|
|
51
|
-
"update:test-deps:deno": "
|
|
52
|
-
"update:test-deps:bun": "
|
|
50
|
+
"update:test-deps": "npm run update:test-deps:expo && npm run update:test-deps:next && npm run update:test-deps:deno && npm run update:test-deps:bun",
|
|
51
|
+
"update:test-deps:expo": "cd test/integration/expo && npm install",
|
|
52
|
+
"update:test-deps:next": "cd test/integration/next && npm install --legacy-peer-deps",
|
|
53
|
+
"update:test-deps:deno": "cd test/deno && npm install",
|
|
54
|
+
"update:test-deps:bun": "cd test/integration/bun && bun install"
|
|
53
55
|
},
|
|
54
56
|
"dependencies": {
|
|
55
|
-
"@supabase/auth-js": "2.
|
|
56
|
-
"@supabase/functions-js": "2.
|
|
57
|
-
"@supabase/postgrest-js": "2.
|
|
58
|
-
"@supabase/realtime-js": "2.
|
|
59
|
-
"@supabase/storage-js": "2.
|
|
60
|
-
"@supabase/node-fetch": "2.6.15"
|
|
57
|
+
"@supabase/auth-js": "2.80.0",
|
|
58
|
+
"@supabase/functions-js": "2.80.0",
|
|
59
|
+
"@supabase/postgrest-js": "2.80.0",
|
|
60
|
+
"@supabase/realtime-js": "2.80.0",
|
|
61
|
+
"@supabase/storage-js": "2.80.0"
|
|
61
62
|
},
|
|
62
63
|
"devDependencies": {
|
|
63
|
-
"@sebbo2002/semantic-release-jsr": "^1.0.0",
|
|
64
64
|
"jsr": "^0.13.5",
|
|
65
|
-
"pretty-quick": "^3.1.3",
|
|
66
65
|
"puppeteer": "^24.9.0",
|
|
67
66
|
"serve": "^14.2.1",
|
|
68
|
-
"ts-jest": "^29.0.5",
|
|
69
67
|
"ts-loader": "^9.5.4",
|
|
70
68
|
"tsd": "^0.30.4",
|
|
71
|
-
"eslint-formatter-pretty": "^4.1.0",
|
|
72
69
|
"webpack": "^5.69.1",
|
|
73
70
|
"webpack-cli": "^4.9.2"
|
|
74
71
|
},
|
|
75
72
|
"jsdelivr": "dist/umd/supabase.js",
|
|
76
|
-
"unpkg": "dist/umd/supabase.js"
|
|
73
|
+
"unpkg": "dist/umd/supabase.js",
|
|
74
|
+
"nx": {
|
|
75
|
+
"targets": {
|
|
76
|
+
"test:integration:browser": {
|
|
77
|
+
"dependsOn": [
|
|
78
|
+
{
|
|
79
|
+
"projects": [
|
|
80
|
+
"storage-js"
|
|
81
|
+
],
|
|
82
|
+
"target": "build"
|
|
83
|
+
}
|
|
84
|
+
]
|
|
85
|
+
},
|
|
86
|
+
"test:edge-functions": {
|
|
87
|
+
"dependsOn": [
|
|
88
|
+
{
|
|
89
|
+
"projects": [
|
|
90
|
+
"storage-js"
|
|
91
|
+
],
|
|
92
|
+
"target": "build"
|
|
93
|
+
}
|
|
94
|
+
]
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
},
|
|
98
|
+
"engines": {
|
|
99
|
+
"node": ">=20.0.0"
|
|
100
|
+
}
|
|
77
101
|
}
|
package/src/SupabaseClient.ts
CHANGED
|
@@ -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 {
|
|
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<
|
|
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:
|
|
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
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
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
|
/**
|
|
@@ -318,6 +340,7 @@ export default class SupabaseClient<
|
|
|
318
340
|
flowType,
|
|
319
341
|
lock,
|
|
320
342
|
debug,
|
|
343
|
+
throwOnError,
|
|
321
344
|
}: SupabaseAuthClientOptions,
|
|
322
345
|
headers?: Record<string, string>,
|
|
323
346
|
fetch?: Fetch
|
|
@@ -338,6 +361,7 @@ export default class SupabaseClient<
|
|
|
338
361
|
flowType,
|
|
339
362
|
lock,
|
|
340
363
|
debug,
|
|
364
|
+
throwOnError,
|
|
341
365
|
fetch,
|
|
342
366
|
// auth checks if there is a custom authorizaiton header using this flag
|
|
343
367
|
// so it knows whether to return an error when getUser is called with no session
|
|
@@ -355,7 +379,7 @@ export default class SupabaseClient<
|
|
|
355
379
|
}
|
|
356
380
|
|
|
357
381
|
private _listenForAuthEvents() {
|
|
358
|
-
|
|
382
|
+
const data = this.auth.onAuthStateChange((event, session) => {
|
|
359
383
|
this._handleTokenChanged(event, 'CLIENT', session?.access_token)
|
|
360
384
|
})
|
|
361
385
|
return data
|
package/src/lib/fetch.ts
CHANGED
|
@@ -1,25 +1,13 @@
|
|
|
1
|
-
// @ts-ignore
|
|
2
|
-
import nodeFetch, { Headers as NodeFetchHeaders } from '@supabase/node-fetch'
|
|
3
|
-
|
|
4
1
|
type Fetch = typeof fetch
|
|
5
2
|
|
|
6
3
|
export const resolveFetch = (customFetch?: Fetch): Fetch => {
|
|
7
|
-
let _fetch: Fetch
|
|
8
4
|
if (customFetch) {
|
|
9
|
-
|
|
10
|
-
} else if (typeof fetch === 'undefined') {
|
|
11
|
-
_fetch = nodeFetch as unknown as Fetch
|
|
12
|
-
} else {
|
|
13
|
-
_fetch = fetch
|
|
5
|
+
return (...args: Parameters<Fetch>) => customFetch(...args)
|
|
14
6
|
}
|
|
15
|
-
return (...args: Parameters<Fetch>) =>
|
|
7
|
+
return (...args: Parameters<Fetch>) => fetch(...args)
|
|
16
8
|
}
|
|
17
9
|
|
|
18
10
|
export const resolveHeadersConstructor = () => {
|
|
19
|
-
if (typeof Headers === 'undefined') {
|
|
20
|
-
return NodeFetchHeaders
|
|
21
|
-
}
|
|
22
|
-
|
|
23
11
|
return Headers
|
|
24
12
|
}
|
|
25
13
|
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* AUTO-GENERATED FILE - DO NOT EDIT
|
|
3
|
+
*
|
|
4
|
+
* This file is automatically synchronized from @supabase/postgrest-js
|
|
5
|
+
* Source: packages/core/postgrest-js/src/types/common/
|
|
6
|
+
*
|
|
7
|
+
* To update this file, modify the source in postgrest-js and run:
|
|
8
|
+
* npm run codegen
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
// Types that are shared between supabase-js and postgrest-js
|
|
12
|
+
|
|
13
|
+
export type Fetch = typeof fetch
|
|
14
|
+
|
|
15
|
+
export type GenericRelationship = {
|
|
16
|
+
foreignKeyName: string
|
|
17
|
+
columns: string[]
|
|
18
|
+
isOneToOne?: boolean
|
|
19
|
+
referencedRelation: string
|
|
20
|
+
referencedColumns: string[]
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export type GenericTable = {
|
|
24
|
+
Row: Record<string, unknown>
|
|
25
|
+
Insert: Record<string, unknown>
|
|
26
|
+
Update: Record<string, unknown>
|
|
27
|
+
Relationships: GenericRelationship[]
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export type GenericUpdatableView = {
|
|
31
|
+
Row: Record<string, unknown>
|
|
32
|
+
Insert: Record<string, unknown>
|
|
33
|
+
Update: Record<string, unknown>
|
|
34
|
+
Relationships: GenericRelationship[]
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export type GenericNonUpdatableView = {
|
|
38
|
+
Row: Record<string, unknown>
|
|
39
|
+
Relationships: GenericRelationship[]
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export type GenericView = GenericUpdatableView | GenericNonUpdatableView
|
|
43
|
+
|
|
44
|
+
export type GenericSetofOption = {
|
|
45
|
+
isSetofReturn?: boolean | undefined
|
|
46
|
+
isOneToOne?: boolean | undefined
|
|
47
|
+
isNotNullable?: boolean | undefined
|
|
48
|
+
to: string
|
|
49
|
+
from: string
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
export type GenericFunction = {
|
|
53
|
+
Args: Record<string, unknown> | never
|
|
54
|
+
Returns: unknown
|
|
55
|
+
SetofOptions?: GenericSetofOption
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
export type GenericSchema = {
|
|
59
|
+
Tables: Record<string, GenericTable>
|
|
60
|
+
Views: Record<string, GenericView>
|
|
61
|
+
Functions: Record<string, GenericFunction>
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
export type ClientServerOptions = {
|
|
65
|
+
PostgrestVersion?: string
|
|
66
|
+
}
|
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* AUTO-GENERATED FILE - DO NOT EDIT
|
|
3
|
+
*
|
|
4
|
+
* This file is automatically synchronized from @supabase/postgrest-js
|
|
5
|
+
* Source: packages/core/postgrest-js/src/types/common/
|
|
6
|
+
*
|
|
7
|
+
* To update this file, modify the source in postgrest-js and run:
|
|
8
|
+
* npm run codegen
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
import type { GenericFunction, GenericSchema, GenericSetofOption } from './common'
|
|
12
|
+
|
|
13
|
+
// Functions matching utils
|
|
14
|
+
type IsMatchingArgs<
|
|
15
|
+
FnArgs extends GenericFunction['Args'],
|
|
16
|
+
PassedArgs extends GenericFunction['Args'],
|
|
17
|
+
> = [FnArgs] extends [Record<PropertyKey, never>]
|
|
18
|
+
? PassedArgs extends Record<PropertyKey, never>
|
|
19
|
+
? true
|
|
20
|
+
: false
|
|
21
|
+
: keyof PassedArgs extends keyof FnArgs
|
|
22
|
+
? PassedArgs extends FnArgs
|
|
23
|
+
? true
|
|
24
|
+
: false
|
|
25
|
+
: false
|
|
26
|
+
|
|
27
|
+
type MatchingFunctionArgs<
|
|
28
|
+
Fn extends GenericFunction,
|
|
29
|
+
Args extends GenericFunction['Args'],
|
|
30
|
+
> = Fn extends { Args: infer A extends GenericFunction['Args'] }
|
|
31
|
+
? IsMatchingArgs<A, Args> extends true
|
|
32
|
+
? Fn
|
|
33
|
+
: never
|
|
34
|
+
: false
|
|
35
|
+
|
|
36
|
+
type FindMatchingFunctionByArgs<
|
|
37
|
+
FnUnion,
|
|
38
|
+
Args extends GenericFunction['Args'],
|
|
39
|
+
> = FnUnion extends infer Fn extends GenericFunction ? MatchingFunctionArgs<Fn, Args> : false
|
|
40
|
+
|
|
41
|
+
// Types for working with database schemas
|
|
42
|
+
type TablesAndViews<Schema extends GenericSchema> = Schema['Tables'] & Exclude<Schema['Views'], ''>
|
|
43
|
+
|
|
44
|
+
// Utility types for working with unions
|
|
45
|
+
type UnionToIntersection<U> = (U extends any ? (k: U) => void : never) extends (k: infer I) => void
|
|
46
|
+
? I
|
|
47
|
+
: never
|
|
48
|
+
|
|
49
|
+
type LastOf<T> =
|
|
50
|
+
UnionToIntersection<T extends any ? () => T : never> extends () => infer R ? R : never
|
|
51
|
+
|
|
52
|
+
type IsAny<T> = 0 extends 1 & T ? true : false
|
|
53
|
+
|
|
54
|
+
type ExactMatch<T, S> = [T] extends [S] ? ([S] extends [T] ? true : false) : false
|
|
55
|
+
|
|
56
|
+
type ExtractExactFunction<Fns, Args> = Fns extends infer F
|
|
57
|
+
? F extends GenericFunction
|
|
58
|
+
? ExactMatch<F['Args'], Args> extends true
|
|
59
|
+
? F
|
|
60
|
+
: never
|
|
61
|
+
: never
|
|
62
|
+
: never
|
|
63
|
+
|
|
64
|
+
type IsNever<T> = [T] extends [never] ? true : false
|
|
65
|
+
|
|
66
|
+
type RpcFunctionNotFound<FnName> = {
|
|
67
|
+
Row: any
|
|
68
|
+
Result: {
|
|
69
|
+
error: true
|
|
70
|
+
} & "Couldn't infer function definition matching provided arguments"
|
|
71
|
+
RelationName: FnName
|
|
72
|
+
Relationships: null
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
export type GetRpcFunctionFilterBuilderByArgs<
|
|
76
|
+
Schema extends GenericSchema,
|
|
77
|
+
FnName extends string & keyof Schema['Functions'],
|
|
78
|
+
Args,
|
|
79
|
+
> = {
|
|
80
|
+
0: Schema['Functions'][FnName]
|
|
81
|
+
// If the Args is exactly never (function call without any params)
|
|
82
|
+
1: IsAny<Schema> extends true
|
|
83
|
+
? any
|
|
84
|
+
: IsNever<Args> extends true
|
|
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<ExtractExactFunction<Schema['Functions'][FnName], Args>> extends true
|
|
88
|
+
? LastOf<Schema['Functions'][FnName]>
|
|
89
|
+
: ExtractExactFunction<Schema['Functions'][FnName], Args>
|
|
90
|
+
: Args extends Record<PropertyKey, never>
|
|
91
|
+
? LastOf<Schema['Functions'][FnName]>
|
|
92
|
+
: // Otherwise, we attempt to match with one of the function definition in the union based
|
|
93
|
+
// on the function arguments provided
|
|
94
|
+
Args extends GenericFunction['Args']
|
|
95
|
+
? // This is for retro compatibility, if the funcition is defined with an single return and an union of Args
|
|
96
|
+
// we fallback to the last function definition matched by name
|
|
97
|
+
IsNever<
|
|
98
|
+
LastOf<FindMatchingFunctionByArgs<Schema['Functions'][FnName], Args>>
|
|
99
|
+
> extends true
|
|
100
|
+
? LastOf<Schema['Functions'][FnName]>
|
|
101
|
+
: // Otherwise, we use the arguments based function definition narrowing to get the right value
|
|
102
|
+
LastOf<FindMatchingFunctionByArgs<Schema['Functions'][FnName], Args>>
|
|
103
|
+
: // If we can't find a matching function by args, we try to find one by function name
|
|
104
|
+
ExtractExactFunction<Schema['Functions'][FnName], Args> extends GenericFunction
|
|
105
|
+
? ExtractExactFunction<Schema['Functions'][FnName], Args>
|
|
106
|
+
: any
|
|
107
|
+
}[1] extends infer Fn
|
|
108
|
+
? // If we are dealing with an non-typed client everything is any
|
|
109
|
+
IsAny<Fn> extends true
|
|
110
|
+
? { Row: any; Result: any; RelationName: FnName; Relationships: null }
|
|
111
|
+
: // Otherwise, we use the arguments based function definition narrowing to get the rigt value
|
|
112
|
+
Fn extends GenericFunction
|
|
113
|
+
? {
|
|
114
|
+
Row: Fn['SetofOptions'] extends GenericSetofOption
|
|
115
|
+
? Fn['SetofOptions']['isSetofReturn'] extends true
|
|
116
|
+
? TablesAndViews<Schema>[Fn['SetofOptions']['to']]['Row']
|
|
117
|
+
: TablesAndViews<Schema>[Fn['SetofOptions']['to']]['Row']
|
|
118
|
+
: Fn['Returns'] extends any[]
|
|
119
|
+
? Fn['Returns'][number] extends Record<string, unknown>
|
|
120
|
+
? Fn['Returns'][number]
|
|
121
|
+
: never
|
|
122
|
+
: Fn['Returns'] extends Record<string, unknown>
|
|
123
|
+
? Fn['Returns']
|
|
124
|
+
: never
|
|
125
|
+
Result: Fn['SetofOptions'] extends GenericSetofOption
|
|
126
|
+
? Fn['SetofOptions']['isSetofReturn'] extends true
|
|
127
|
+
? Fn['SetofOptions']['isOneToOne'] extends true
|
|
128
|
+
? Fn['Returns'][]
|
|
129
|
+
: Fn['Returns']
|
|
130
|
+
: Fn['Returns']
|
|
131
|
+
: Fn['Returns']
|
|
132
|
+
RelationName: Fn['SetofOptions'] extends GenericSetofOption
|
|
133
|
+
? Fn['SetofOptions']['to']
|
|
134
|
+
: FnName
|
|
135
|
+
Relationships: Fn['SetofOptions'] extends GenericSetofOption
|
|
136
|
+
? Fn['SetofOptions']['to'] extends keyof Schema['Tables']
|
|
137
|
+
? Schema['Tables'][Fn['SetofOptions']['to']]['Relationships']
|
|
138
|
+
: Schema['Views'][Fn['SetofOptions']['to']]['Relationships']
|
|
139
|
+
: null
|
|
140
|
+
}
|
|
141
|
+
: // If we failed to find the function by argument, we still pass with any but also add an overridable
|
|
142
|
+
Fn extends false
|
|
143
|
+
? RpcFunctionNotFound<FnName>
|
|
144
|
+
: RpcFunctionNotFound<FnName>
|
|
145
|
+
: RpcFunctionNotFound<FnName>
|
package/src/lib/types.ts
CHANGED
|
@@ -1,11 +1,27 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { GoTrueClientOptions } 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
|
-
|
|
7
|
-
|
|
8
|
-
export interface SupabaseAuthClientOptions extends AuthClientOptions {}
|
|
24
|
+
export interface SupabaseAuthClientOptions extends GoTrueClientOptions {}
|
|
9
25
|
|
|
10
26
|
export type Fetch = typeof fetch
|
|
11
27
|
|
|
@@ -60,6 +76,11 @@ export type SupabaseClientOptions<SchemaName> = {
|
|
|
60
76
|
* @experimental
|
|
61
77
|
*/
|
|
62
78
|
lock?: SupabaseAuthClientOptions['lock']
|
|
79
|
+
/**
|
|
80
|
+
* If there is an error with the query, throwOnError will reject the promise by
|
|
81
|
+
* throwing the error instead of returning it as part of a successful response.
|
|
82
|
+
*/
|
|
83
|
+
throwOnError?: SupabaseAuthClientOptions['throwOnError']
|
|
63
84
|
}
|
|
64
85
|
/**
|
|
65
86
|
* Options passed to the realtime-js instance
|
|
@@ -79,9 +100,9 @@ export type SupabaseClientOptions<SchemaName> = {
|
|
|
79
100
|
/**
|
|
80
101
|
* Optional function for using a third-party authentication system with
|
|
81
102
|
* Supabase. The function should return an access token or ID token (JWT) by
|
|
82
|
-
* obtaining it from the third-party auth
|
|
103
|
+
* obtaining it from the third-party auth SDK. Note that this
|
|
83
104
|
* function may be called concurrently and many times. Use memoization and
|
|
84
|
-
* locking techniques if this is not supported by the
|
|
105
|
+
* locking techniques if this is not supported by the SDKs.
|
|
85
106
|
*
|
|
86
107
|
* When set, the `auth` namespace of the Supabase client cannot be used.
|
|
87
108
|
* Create another client if you wish to use Supabase Auth and third-party
|
|
@@ -90,41 +111,6 @@ export type SupabaseClientOptions<SchemaName> = {
|
|
|
90
111
|
accessToken?: () => Promise<string | null>
|
|
91
112
|
}
|
|
92
113
|
|
|
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
114
|
/**
|
|
129
115
|
* Helper types for query results.
|
|
130
116
|
*/
|
package/src/lib/version.ts
CHANGED
|
@@ -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.
|
|
7
|
+
export const version = '2.80.0'
|