@supabase/supabase-js 2.87.4-canary.3 → 2.87.4-canary.4
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/dist/index.cjs +452 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +362 -0
- package/dist/index.d.cts.map +1 -0
- package/dist/index.d.mts +362 -0
- package/dist/index.d.mts.map +1 -0
- package/dist/index.mjs +405 -0
- package/dist/index.mjs.map +1 -0
- package/dist/umd/supabase.js +23 -1
- package/package.json +21 -22
- package/src/lib/version.ts +1 -1
- package/dist/esm/wrapper.mjs +0 -94
- package/dist/main/SupabaseClient.d.ts +0 -139
- package/dist/main/SupabaseClient.d.ts.map +0 -1
- package/dist/main/SupabaseClient.js +0 -235
- package/dist/main/SupabaseClient.js.map +0 -1
- package/dist/main/index.d.ts +0 -24
- package/dist/main/index.d.ts.map +0 -1
- package/dist/main/index.js +0 -76
- package/dist/main/index.js.map +0 -1
- package/dist/main/lib/SupabaseAuthClient.d.ts +0 -6
- package/dist/main/lib/SupabaseAuthClient.d.ts.map +0 -1
- package/dist/main/lib/SupabaseAuthClient.js +0 -11
- package/dist/main/lib/SupabaseAuthClient.js.map +0 -1
- package/dist/main/lib/constants.d.ts +0 -16
- package/dist/main/lib/constants.d.ts.map +0 -1
- package/dist/main/lib/constants.js +0 -33
- package/dist/main/lib/constants.js.map +0 -1
- package/dist/main/lib/fetch.d.ts +0 -9
- package/dist/main/lib/fetch.d.ts.map +0 -1
- package/dist/main/lib/fetch.js +0 -32
- package/dist/main/lib/fetch.js.map +0 -1
- package/dist/main/lib/helpers.d.ts +0 -14
- package/dist/main/lib/helpers.d.ts.map +0 -1
- package/dist/main/lib/helpers.js +0 -62
- package/dist/main/lib/helpers.js.map +0 -1
- package/dist/main/lib/rest/types/common/common.d.ts +0 -55
- package/dist/main/lib/rest/types/common/common.d.ts.map +0 -1
- package/dist/main/lib/rest/types/common/common.js +0 -12
- package/dist/main/lib/rest/types/common/common.js.map +0 -1
- package/dist/main/lib/rest/types/common/rpc.d.ts +0 -49
- package/dist/main/lib/rest/types/common/rpc.d.ts.map +0 -1
- package/dist/main/lib/rest/types/common/rpc.js +0 -12
- package/dist/main/lib/rest/types/common/rpc.js.map +0 -1
- package/dist/main/lib/types.d.ts +0 -122
- package/dist/main/lib/types.d.ts.map +0 -1
- package/dist/main/lib/types.js +0 -3
- package/dist/main/lib/types.js.map +0 -1
- package/dist/main/lib/version.d.ts +0 -2
- package/dist/main/lib/version.d.ts.map +0 -1
- package/dist/main/lib/version.js +0 -11
- package/dist/main/lib/version.js.map +0 -1
- package/dist/module/SupabaseClient.d.ts +0 -139
- package/dist/module/SupabaseClient.d.ts.map +0 -1
- package/dist/module/SupabaseClient.js +0 -232
- package/dist/module/SupabaseClient.js.map +0 -1
- package/dist/module/index.d.ts +0 -24
- package/dist/module/index.d.ts.map +0 -1
- package/dist/module/index.js +0 -48
- package/dist/module/index.js.map +0 -1
- package/dist/module/lib/SupabaseAuthClient.d.ts +0 -6
- package/dist/module/lib/SupabaseAuthClient.d.ts.map +0 -1
- package/dist/module/lib/SupabaseAuthClient.js +0 -7
- package/dist/module/lib/SupabaseAuthClient.js.map +0 -1
- package/dist/module/lib/constants.d.ts +0 -16
- package/dist/module/lib/constants.d.ts.map +0 -1
- package/dist/module/lib/constants.js +0 -30
- package/dist/module/lib/constants.js.map +0 -1
- package/dist/module/lib/fetch.d.ts +0 -9
- package/dist/module/lib/fetch.d.ts.map +0 -1
- package/dist/module/lib/fetch.js +0 -26
- package/dist/module/lib/fetch.js.map +0 -1
- package/dist/module/lib/helpers.d.ts +0 -14
- package/dist/module/lib/helpers.d.ts.map +0 -1
- package/dist/module/lib/helpers.js +0 -54
- package/dist/module/lib/helpers.js.map +0 -1
- package/dist/module/lib/rest/types/common/common.d.ts +0 -55
- package/dist/module/lib/rest/types/common/common.d.ts.map +0 -1
- package/dist/module/lib/rest/types/common/common.js +0 -11
- package/dist/module/lib/rest/types/common/common.js.map +0 -1
- package/dist/module/lib/rest/types/common/rpc.d.ts +0 -49
- package/dist/module/lib/rest/types/common/rpc.d.ts.map +0 -1
- package/dist/module/lib/rest/types/common/rpc.js +0 -11
- package/dist/module/lib/rest/types/common/rpc.js.map +0 -1
- package/dist/module/lib/types.d.ts +0 -122
- package/dist/module/lib/types.d.ts.map +0 -1
- package/dist/module/lib/types.js +0 -2
- package/dist/module/lib/types.js.map +0 -1
- package/dist/module/lib/version.d.ts +0 -2
- package/dist/module/lib/version.d.ts.map +0 -1
- package/dist/module/lib/version.js +0 -8
- package/dist/module/lib/version.js.map +0 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@supabase/supabase-js",
|
|
3
|
-
"version": "2.87.4-canary.
|
|
3
|
+
"version": "2.87.4-canary.4",
|
|
4
4
|
"description": "Isomorphic Javascript SDK for Supabase",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"javascript",
|
|
@@ -15,16 +15,21 @@
|
|
|
15
15
|
"dist",
|
|
16
16
|
"src"
|
|
17
17
|
],
|
|
18
|
-
"main": "dist/
|
|
19
|
-
"module": "dist/
|
|
20
|
-
"types": "dist/
|
|
18
|
+
"main": "dist/index.cjs",
|
|
19
|
+
"module": "dist/index.mjs",
|
|
20
|
+
"types": "dist/index.d.cts",
|
|
21
21
|
"exports": {
|
|
22
22
|
".": {
|
|
23
|
-
"
|
|
24
|
-
|
|
25
|
-
|
|
23
|
+
"import": {
|
|
24
|
+
"types": "./dist/index.d.mts",
|
|
25
|
+
"default": "./dist/index.mjs"
|
|
26
|
+
},
|
|
27
|
+
"require": {
|
|
28
|
+
"types": "./dist/index.d.cts",
|
|
29
|
+
"default": "./dist/index.cjs"
|
|
30
|
+
}
|
|
26
31
|
},
|
|
27
|
-
"./dist
|
|
32
|
+
"./dist/*": "./dist/*",
|
|
28
33
|
"./package.json": "./package.json"
|
|
29
34
|
},
|
|
30
35
|
"sideEffects": false,
|
|
@@ -34,11 +39,8 @@
|
|
|
34
39
|
"directory": "packages/core/supabase-js"
|
|
35
40
|
},
|
|
36
41
|
"scripts": {
|
|
37
|
-
"build": "
|
|
38
|
-
"build:
|
|
39
|
-
"build:module": "tsc -p tsconfig.module.json && node scripts/fix-esm-extensions.cjs",
|
|
40
|
-
"build:esm": "node scripts/copy-wrapper.cjs",
|
|
41
|
-
"build:umd": "webpack --env mode=production",
|
|
42
|
+
"build": "tsdown",
|
|
43
|
+
"build:watch": "tsdown --watch",
|
|
42
44
|
"test": "npm run test:types && npm run test:run",
|
|
43
45
|
"test:all": "npm run test:types && npm run test:run && npm run test:integration && npm run test:integration:browser",
|
|
44
46
|
"test:run": "jest --runInBand --detectOpenHandles",
|
|
@@ -64,20 +66,17 @@
|
|
|
64
66
|
"update:test-deps:bun": "cd test/integration/bun && bun install"
|
|
65
67
|
},
|
|
66
68
|
"dependencies": {
|
|
67
|
-
"@supabase/auth-js": "2.87.4-canary.
|
|
68
|
-
"@supabase/functions-js": "2.87.4-canary.
|
|
69
|
-
"@supabase/postgrest-js": "2.87.4-canary.
|
|
70
|
-
"@supabase/realtime-js": "2.87.4-canary.
|
|
71
|
-
"@supabase/storage-js": "2.87.4-canary.
|
|
69
|
+
"@supabase/auth-js": "2.87.4-canary.4",
|
|
70
|
+
"@supabase/functions-js": "2.87.4-canary.4",
|
|
71
|
+
"@supabase/postgrest-js": "2.87.4-canary.4",
|
|
72
|
+
"@supabase/realtime-js": "2.87.4-canary.4",
|
|
73
|
+
"@supabase/storage-js": "2.87.4-canary.4"
|
|
72
74
|
},
|
|
73
75
|
"devDependencies": {
|
|
74
76
|
"jsr": "^0.13.5",
|
|
75
77
|
"puppeteer": "^24.9.0",
|
|
76
78
|
"serve": "^14.2.1",
|
|
77
|
-
"
|
|
78
|
-
"tsd": "^0.30.4",
|
|
79
|
-
"webpack": "^5.69.1",
|
|
80
|
-
"webpack-cli": "^4.9.2"
|
|
79
|
+
"tsd": "^0.33.0"
|
|
81
80
|
},
|
|
82
81
|
"jsdelivr": "dist/umd/supabase.js",
|
|
83
82
|
"unpkg": "dist/umd/supabase.js",
|
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.87.4-canary.
|
|
7
|
+
export const version = '2.87.4-canary.4'
|
package/dist/esm/wrapper.mjs
DELETED
|
@@ -1,94 +0,0 @@
|
|
|
1
|
-
import * as index from '../module/index.js'
|
|
2
|
-
const {
|
|
3
|
-
PostgrestError,
|
|
4
|
-
FunctionsHttpError,
|
|
5
|
-
FunctionsFetchError,
|
|
6
|
-
FunctionsRelayError,
|
|
7
|
-
FunctionsError,
|
|
8
|
-
FunctionRegion,
|
|
9
|
-
SupabaseClient,
|
|
10
|
-
createClient,
|
|
11
|
-
GoTrueAdminApi,
|
|
12
|
-
GoTrueClient,
|
|
13
|
-
AuthAdminApi,
|
|
14
|
-
AuthClient,
|
|
15
|
-
navigatorLock,
|
|
16
|
-
NavigatorLockAcquireTimeoutError,
|
|
17
|
-
lockInternals,
|
|
18
|
-
processLock,
|
|
19
|
-
SIGN_OUT_SCOPES,
|
|
20
|
-
AuthError,
|
|
21
|
-
AuthApiError,
|
|
22
|
-
AuthUnknownError,
|
|
23
|
-
CustomAuthError,
|
|
24
|
-
AuthSessionMissingError,
|
|
25
|
-
AuthInvalidTokenResponseError,
|
|
26
|
-
AuthInvalidCredentialsError,
|
|
27
|
-
AuthImplicitGrantRedirectError,
|
|
28
|
-
AuthPKCEGrantCodeExchangeError,
|
|
29
|
-
AuthRetryableFetchError,
|
|
30
|
-
AuthWeakPasswordError,
|
|
31
|
-
AuthInvalidJwtError,
|
|
32
|
-
isAuthError,
|
|
33
|
-
isAuthApiError,
|
|
34
|
-
isAuthSessionMissingError,
|
|
35
|
-
isAuthImplicitGrantRedirectError,
|
|
36
|
-
isAuthRetryableFetchError,
|
|
37
|
-
isAuthWeakPasswordError,
|
|
38
|
-
RealtimePresence,
|
|
39
|
-
RealtimeChannel,
|
|
40
|
-
RealtimeClient,
|
|
41
|
-
REALTIME_LISTEN_TYPES,
|
|
42
|
-
REALTIME_POSTGRES_CHANGES_LISTEN_EVENT,
|
|
43
|
-
REALTIME_PRESENCE_LISTEN_EVENTS,
|
|
44
|
-
REALTIME_SUBSCRIBE_STATES,
|
|
45
|
-
REALTIME_CHANNEL_STATES,
|
|
46
|
-
} = index.default || index
|
|
47
|
-
|
|
48
|
-
export {
|
|
49
|
-
PostgrestError,
|
|
50
|
-
FunctionsHttpError,
|
|
51
|
-
FunctionsFetchError,
|
|
52
|
-
FunctionsRelayError,
|
|
53
|
-
FunctionsError,
|
|
54
|
-
FunctionRegion,
|
|
55
|
-
SupabaseClient,
|
|
56
|
-
createClient,
|
|
57
|
-
GoTrueAdminApi,
|
|
58
|
-
GoTrueClient,
|
|
59
|
-
AuthAdminApi,
|
|
60
|
-
AuthClient,
|
|
61
|
-
navigatorLock,
|
|
62
|
-
NavigatorLockAcquireTimeoutError,
|
|
63
|
-
lockInternals,
|
|
64
|
-
processLock,
|
|
65
|
-
SIGN_OUT_SCOPES,
|
|
66
|
-
AuthError,
|
|
67
|
-
AuthApiError,
|
|
68
|
-
AuthUnknownError,
|
|
69
|
-
CustomAuthError,
|
|
70
|
-
AuthSessionMissingError,
|
|
71
|
-
AuthInvalidTokenResponseError,
|
|
72
|
-
AuthInvalidCredentialsError,
|
|
73
|
-
AuthImplicitGrantRedirectError,
|
|
74
|
-
AuthPKCEGrantCodeExchangeError,
|
|
75
|
-
AuthRetryableFetchError,
|
|
76
|
-
AuthWeakPasswordError,
|
|
77
|
-
AuthInvalidJwtError,
|
|
78
|
-
isAuthError,
|
|
79
|
-
isAuthApiError,
|
|
80
|
-
isAuthSessionMissingError,
|
|
81
|
-
isAuthImplicitGrantRedirectError,
|
|
82
|
-
isAuthRetryableFetchError,
|
|
83
|
-
isAuthWeakPasswordError,
|
|
84
|
-
RealtimePresence,
|
|
85
|
-
RealtimeChannel,
|
|
86
|
-
RealtimeClient,
|
|
87
|
-
REALTIME_LISTEN_TYPES,
|
|
88
|
-
REALTIME_POSTGRES_CHANGES_LISTEN_EVENT,
|
|
89
|
-
REALTIME_PRESENCE_LISTEN_EVENTS,
|
|
90
|
-
REALTIME_SUBSCRIBE_STATES,
|
|
91
|
-
REALTIME_CHANNEL_STATES,
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
export default index.default || index
|
|
@@ -1,139 +0,0 @@
|
|
|
1
|
-
import { FunctionsClient } from '@supabase/functions-js';
|
|
2
|
-
import { PostgrestClient, type PostgrestFilterBuilder, type PostgrestQueryBuilder } from '@supabase/postgrest-js';
|
|
3
|
-
import { type RealtimeChannel, type RealtimeChannelOptions, RealtimeClient } from '@supabase/realtime-js';
|
|
4
|
-
import { StorageClient as SupabaseStorageClient } from '@supabase/storage-js';
|
|
5
|
-
import { SupabaseAuthClient } from './lib/SupabaseAuthClient';
|
|
6
|
-
import type { Fetch, GenericSchema, SupabaseClientOptions } from './lib/types';
|
|
7
|
-
import { GetRpcFunctionFilterBuilderByArgs } from './lib/rest/types/common/rpc';
|
|
8
|
-
/**
|
|
9
|
-
* Supabase Client.
|
|
10
|
-
*
|
|
11
|
-
* An isomorphic Javascript client for interacting with Postgres.
|
|
12
|
-
*/
|
|
13
|
-
export default class SupabaseClient<Database = any, SchemaNameOrClientOptions extends (string & keyof Omit<Database, '__InternalSupabase'>) | {
|
|
14
|
-
PostgrestVersion: string;
|
|
15
|
-
} = 'public' extends keyof Omit<Database, '__InternalSupabase'> ? 'public' : string & keyof Omit<Database, '__InternalSupabase'>, SchemaName extends string & keyof Omit<Database, '__InternalSupabase'> = SchemaNameOrClientOptions extends string & keyof Omit<Database, '__InternalSupabase'> ? SchemaNameOrClientOptions : 'public' extends keyof Omit<Database, '__InternalSupabase'> ? 'public' : string & keyof Omit<Omit<Database, '__InternalSupabase'>, '__InternalSupabase'>, Schema extends Omit<Database, '__InternalSupabase'>[SchemaName] extends GenericSchema ? Omit<Database, '__InternalSupabase'>[SchemaName] : never = Omit<Database, '__InternalSupabase'>[SchemaName] extends GenericSchema ? Omit<Database, '__InternalSupabase'>[SchemaName] : never, ClientOptions extends {
|
|
16
|
-
PostgrestVersion: string;
|
|
17
|
-
} = SchemaNameOrClientOptions extends string & keyof Omit<Database, '__InternalSupabase'> ? Database extends {
|
|
18
|
-
__InternalSupabase: {
|
|
19
|
-
PostgrestVersion: string;
|
|
20
|
-
};
|
|
21
|
-
} ? Database['__InternalSupabase'] : {
|
|
22
|
-
PostgrestVersion: '12';
|
|
23
|
-
} : SchemaNameOrClientOptions extends {
|
|
24
|
-
PostgrestVersion: string;
|
|
25
|
-
} ? SchemaNameOrClientOptions : never> {
|
|
26
|
-
protected supabaseUrl: string;
|
|
27
|
-
protected supabaseKey: string;
|
|
28
|
-
/**
|
|
29
|
-
* Supabase Auth allows you to create and manage user sessions for access to data that is secured by access policies.
|
|
30
|
-
*/
|
|
31
|
-
auth: SupabaseAuthClient;
|
|
32
|
-
realtime: RealtimeClient;
|
|
33
|
-
/**
|
|
34
|
-
* Supabase Storage allows you to manage user-generated content, such as photos or videos.
|
|
35
|
-
*/
|
|
36
|
-
storage: SupabaseStorageClient;
|
|
37
|
-
protected realtimeUrl: URL;
|
|
38
|
-
protected authUrl: URL;
|
|
39
|
-
protected storageUrl: URL;
|
|
40
|
-
protected functionsUrl: URL;
|
|
41
|
-
protected rest: PostgrestClient<Database, ClientOptions, SchemaName>;
|
|
42
|
-
protected storageKey: string;
|
|
43
|
-
protected fetch?: Fetch;
|
|
44
|
-
protected changedAccessToken?: string;
|
|
45
|
-
protected accessToken?: () => Promise<string | null>;
|
|
46
|
-
protected headers: Record<string, string>;
|
|
47
|
-
/**
|
|
48
|
-
* Create a new client for use in the browser.
|
|
49
|
-
* @param supabaseUrl The unique Supabase URL which is supplied when you create a new project in your project dashboard.
|
|
50
|
-
* @param supabaseKey The unique Supabase Key which is supplied when you create a new project in your project dashboard.
|
|
51
|
-
* @param options.db.schema You can switch in between schemas. The schema needs to be on the list of exposed schemas inside Supabase.
|
|
52
|
-
* @param options.auth.autoRefreshToken Set to "true" if you want to automatically refresh the token before expiring.
|
|
53
|
-
* @param options.auth.persistSession Set to "true" if you want to automatically save the user session into local storage.
|
|
54
|
-
* @param options.auth.detectSessionInUrl Set to "true" if you want to automatically detects OAuth grants in the URL and signs in the user.
|
|
55
|
-
* @param options.realtime Options passed along to realtime-js constructor.
|
|
56
|
-
* @param options.storage Options passed along to the storage-js constructor.
|
|
57
|
-
* @param options.global.fetch A custom fetch implementation.
|
|
58
|
-
* @param options.global.headers Any additional headers to send with each network request.
|
|
59
|
-
* @example
|
|
60
|
-
* ```ts
|
|
61
|
-
* import { createClient } from '@supabase/supabase-js'
|
|
62
|
-
*
|
|
63
|
-
* const supabase = createClient('https://xyzcompany.supabase.co', 'public-anon-key')
|
|
64
|
-
* const { data } = await supabase.from('profiles').select('*')
|
|
65
|
-
* ```
|
|
66
|
-
*/
|
|
67
|
-
constructor(supabaseUrl: string, supabaseKey: string, options?: SupabaseClientOptions<SchemaName>);
|
|
68
|
-
/**
|
|
69
|
-
* Supabase Functions allows you to deploy and invoke edge functions.
|
|
70
|
-
*/
|
|
71
|
-
get functions(): FunctionsClient;
|
|
72
|
-
from<TableName extends string & keyof Schema['Tables'], Table extends Schema['Tables'][TableName]>(relation: TableName): PostgrestQueryBuilder<ClientOptions, Schema, Table, TableName>;
|
|
73
|
-
from<ViewName extends string & keyof Schema['Views'], View extends Schema['Views'][ViewName]>(relation: ViewName): PostgrestQueryBuilder<ClientOptions, Schema, View, ViewName>;
|
|
74
|
-
/**
|
|
75
|
-
* Select a schema to query or perform an function (rpc) call.
|
|
76
|
-
*
|
|
77
|
-
* The schema needs to be on the list of exposed schemas inside Supabase.
|
|
78
|
-
*
|
|
79
|
-
* @param schema - The schema to query
|
|
80
|
-
*/
|
|
81
|
-
schema<DynamicSchema extends string & keyof Omit<Database, '__InternalSupabase'>>(schema: DynamicSchema): PostgrestClient<Database, ClientOptions, DynamicSchema, Database[DynamicSchema] extends GenericSchema ? Database[DynamicSchema] : any>;
|
|
82
|
-
/**
|
|
83
|
-
* Perform a function call.
|
|
84
|
-
*
|
|
85
|
-
* @param fn - The function name to call
|
|
86
|
-
* @param args - The arguments to pass to the function call
|
|
87
|
-
* @param options - Named parameters
|
|
88
|
-
* @param options.head - When set to `true`, `data` will not be returned.
|
|
89
|
-
* Useful if you only need the count.
|
|
90
|
-
* @param options.get - When set to `true`, the function will be called with
|
|
91
|
-
* read-only access mode.
|
|
92
|
-
* @param options.count - Count algorithm to use to count rows returned by the
|
|
93
|
-
* function. Only applicable for [set-returning
|
|
94
|
-
* functions](https://www.postgresql.org/docs/current/functions-srf.html).
|
|
95
|
-
*
|
|
96
|
-
* `"exact"`: Exact but slow count algorithm. Performs a `COUNT(*)` under the
|
|
97
|
-
* hood.
|
|
98
|
-
*
|
|
99
|
-
* `"planned"`: Approximated but fast count algorithm. Uses the Postgres
|
|
100
|
-
* statistics under the hood.
|
|
101
|
-
*
|
|
102
|
-
* `"estimated"`: Uses exact count for low numbers and planned count for high
|
|
103
|
-
* numbers.
|
|
104
|
-
*/
|
|
105
|
-
rpc<FnName extends string & keyof Schema['Functions'], Args extends Schema['Functions'][FnName]['Args'] = never, FilterBuilder extends GetRpcFunctionFilterBuilderByArgs<Schema, FnName, Args> = GetRpcFunctionFilterBuilderByArgs<Schema, FnName, Args>>(fn: FnName, args?: Args, options?: {
|
|
106
|
-
head?: boolean;
|
|
107
|
-
get?: boolean;
|
|
108
|
-
count?: 'exact' | 'planned' | 'estimated';
|
|
109
|
-
}): PostgrestFilterBuilder<ClientOptions, Schema, FilterBuilder['Row'], FilterBuilder['Result'], FilterBuilder['RelationName'], FilterBuilder['Relationships'], 'RPC'>;
|
|
110
|
-
/**
|
|
111
|
-
* Creates a Realtime channel with Broadcast, Presence, and Postgres Changes.
|
|
112
|
-
*
|
|
113
|
-
* @param {string} name - The name of the Realtime channel.
|
|
114
|
-
* @param {Object} opts - The options to pass to the Realtime channel.
|
|
115
|
-
*
|
|
116
|
-
*/
|
|
117
|
-
channel(name: string, opts?: RealtimeChannelOptions): RealtimeChannel;
|
|
118
|
-
/**
|
|
119
|
-
* Returns all Realtime channels.
|
|
120
|
-
*/
|
|
121
|
-
getChannels(): RealtimeChannel[];
|
|
122
|
-
/**
|
|
123
|
-
* Unsubscribes and removes Realtime channel from Realtime client.
|
|
124
|
-
*
|
|
125
|
-
* @param {RealtimeChannel} channel - The name of the Realtime channel.
|
|
126
|
-
*
|
|
127
|
-
*/
|
|
128
|
-
removeChannel(channel: RealtimeChannel): Promise<'ok' | 'timed out' | 'error'>;
|
|
129
|
-
/**
|
|
130
|
-
* Unsubscribes and removes all Realtime channels from Realtime client.
|
|
131
|
-
*/
|
|
132
|
-
removeAllChannels(): Promise<('ok' | 'timed out' | 'error')[]>;
|
|
133
|
-
private _getAccessToken;
|
|
134
|
-
private _initSupabaseAuthClient;
|
|
135
|
-
private _initRealtimeClient;
|
|
136
|
-
private _listenForAuthEvents;
|
|
137
|
-
private _handleTokenChanged;
|
|
138
|
-
}
|
|
139
|
-
//# sourceMappingURL=SupabaseClient.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"SupabaseClient.d.ts","sourceRoot":"","sources":["../../src/SupabaseClient.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAA;AACxD,OAAO,EACL,eAAe,EACf,KAAK,sBAAsB,EAC3B,KAAK,qBAAqB,EAC3B,MAAM,wBAAwB,CAAA;AAC/B,OAAO,EACL,KAAK,eAAe,EACpB,KAAK,sBAAsB,EAC3B,cAAc,EAEf,MAAM,uBAAuB,CAAA;AAC9B,OAAO,EAAE,aAAa,IAAI,qBAAqB,EAAE,MAAM,sBAAsB,CAAA;AAS7E,OAAO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AAO,CAAA;QACb,KAAK,CAAC,EAAE,OAAO,GAAG,SAAS,GAAG,WAAW,CAAA;KAK1C,GACA,sBAAsB,CACvB,aAAa,EACb,MAAM,EACN,aAAa,CAAC,KAAK,CAAC,EACpB,aAAa,CAAC,QAAQ,CAAC,EACvB,aAAa,CAAC,cAAc,CAAC,EAC7B,aAAa,CAAC,eAAe,CAAC,EAC9B,KAAK,CACN;IAYD;;;;;;OAMG;IACH,OAAO,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,GAAE,sBAAuC,GAAG,eAAe;IAIrF;;OAEG;IACH,WAAW,IAAI,eAAe,EAAE;IAIhC;;;;;OAKG;IACH,aAAa,CAAC,OAAO,EAAE,eAAe,GAAG,OAAO,CAAC,IAAI,GAAG,WAAW,GAAG,OAAO,CAAC;IAI9E;;OAEG;IACH,iBAAiB,IAAI,OAAO,CAAC,CAAC,IAAI,GAAG,WAAW,GAAG,OAAO,CAAC,EAAE,CAAC;YAIhD,eAAe;IAU7B,OAAO,CAAC,uBAAuB;IA0C/B,OAAO,CAAC,mBAAmB;IAO3B,OAAO,CAAC,oBAAoB;IAO5B,OAAO,CAAC,mBAAmB;CAiB5B"}
|
|
@@ -1,235 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const functions_js_1 = require("@supabase/functions-js");
|
|
4
|
-
const postgrest_js_1 = require("@supabase/postgrest-js");
|
|
5
|
-
const realtime_js_1 = require("@supabase/realtime-js");
|
|
6
|
-
const storage_js_1 = require("@supabase/storage-js");
|
|
7
|
-
const constants_1 = require("./lib/constants");
|
|
8
|
-
const fetch_1 = require("./lib/fetch");
|
|
9
|
-
const helpers_1 = require("./lib/helpers");
|
|
10
|
-
const SupabaseAuthClient_1 = require("./lib/SupabaseAuthClient");
|
|
11
|
-
/**
|
|
12
|
-
* Supabase Client.
|
|
13
|
-
*
|
|
14
|
-
* An isomorphic Javascript client for interacting with Postgres.
|
|
15
|
-
*/
|
|
16
|
-
class SupabaseClient {
|
|
17
|
-
/**
|
|
18
|
-
* Create a new client for use in the browser.
|
|
19
|
-
* @param supabaseUrl The unique Supabase URL which is supplied when you create a new project in your project dashboard.
|
|
20
|
-
* @param supabaseKey The unique Supabase Key which is supplied when you create a new project in your project dashboard.
|
|
21
|
-
* @param options.db.schema You can switch in between schemas. The schema needs to be on the list of exposed schemas inside Supabase.
|
|
22
|
-
* @param options.auth.autoRefreshToken Set to "true" if you want to automatically refresh the token before expiring.
|
|
23
|
-
* @param options.auth.persistSession Set to "true" if you want to automatically save the user session into local storage.
|
|
24
|
-
* @param options.auth.detectSessionInUrl Set to "true" if you want to automatically detects OAuth grants in the URL and signs in the user.
|
|
25
|
-
* @param options.realtime Options passed along to realtime-js constructor.
|
|
26
|
-
* @param options.storage Options passed along to the storage-js constructor.
|
|
27
|
-
* @param options.global.fetch A custom fetch implementation.
|
|
28
|
-
* @param options.global.headers Any additional headers to send with each network request.
|
|
29
|
-
* @example
|
|
30
|
-
* ```ts
|
|
31
|
-
* import { createClient } from '@supabase/supabase-js'
|
|
32
|
-
*
|
|
33
|
-
* const supabase = createClient('https://xyzcompany.supabase.co', 'public-anon-key')
|
|
34
|
-
* const { data } = await supabase.from('profiles').select('*')
|
|
35
|
-
* ```
|
|
36
|
-
*/
|
|
37
|
-
constructor(supabaseUrl, supabaseKey, options) {
|
|
38
|
-
var _a, _b, _c;
|
|
39
|
-
this.supabaseUrl = supabaseUrl;
|
|
40
|
-
this.supabaseKey = supabaseKey;
|
|
41
|
-
const baseUrl = (0, helpers_1.validateSupabaseUrl)(supabaseUrl);
|
|
42
|
-
if (!supabaseKey)
|
|
43
|
-
throw new Error('supabaseKey is required.');
|
|
44
|
-
this.realtimeUrl = new URL('realtime/v1', baseUrl);
|
|
45
|
-
this.realtimeUrl.protocol = this.realtimeUrl.protocol.replace('http', 'ws');
|
|
46
|
-
this.authUrl = new URL('auth/v1', baseUrl);
|
|
47
|
-
this.storageUrl = new URL('storage/v1', baseUrl);
|
|
48
|
-
this.functionsUrl = new URL('functions/v1', baseUrl);
|
|
49
|
-
// default storage key uses the supabase project ref as a namespace
|
|
50
|
-
const defaultStorageKey = `sb-${baseUrl.hostname.split('.')[0]}-auth-token`;
|
|
51
|
-
const DEFAULTS = {
|
|
52
|
-
db: constants_1.DEFAULT_DB_OPTIONS,
|
|
53
|
-
realtime: constants_1.DEFAULT_REALTIME_OPTIONS,
|
|
54
|
-
auth: Object.assign(Object.assign({}, constants_1.DEFAULT_AUTH_OPTIONS), { storageKey: defaultStorageKey }),
|
|
55
|
-
global: constants_1.DEFAULT_GLOBAL_OPTIONS,
|
|
56
|
-
};
|
|
57
|
-
const settings = (0, helpers_1.applySettingDefaults)(options !== null && options !== void 0 ? options : {}, DEFAULTS);
|
|
58
|
-
this.storageKey = (_a = settings.auth.storageKey) !== null && _a !== void 0 ? _a : '';
|
|
59
|
-
this.headers = (_b = settings.global.headers) !== null && _b !== void 0 ? _b : {};
|
|
60
|
-
if (!settings.accessToken) {
|
|
61
|
-
this.auth = this._initSupabaseAuthClient((_c = settings.auth) !== null && _c !== void 0 ? _c : {}, this.headers, settings.global.fetch);
|
|
62
|
-
}
|
|
63
|
-
else {
|
|
64
|
-
this.accessToken = settings.accessToken;
|
|
65
|
-
this.auth = new Proxy({}, {
|
|
66
|
-
get: (_, prop) => {
|
|
67
|
-
throw new Error(`@supabase/supabase-js: Supabase Client is configured with the accessToken option, accessing supabase.auth.${String(prop)} is not possible`);
|
|
68
|
-
},
|
|
69
|
-
});
|
|
70
|
-
}
|
|
71
|
-
this.fetch = (0, fetch_1.fetchWithAuth)(supabaseKey, this._getAccessToken.bind(this), settings.global.fetch);
|
|
72
|
-
this.realtime = this._initRealtimeClient(Object.assign({ headers: this.headers, accessToken: this._getAccessToken.bind(this) }, settings.realtime));
|
|
73
|
-
if (this.accessToken) {
|
|
74
|
-
// Start auth immediately to avoid race condition with channel subscriptions
|
|
75
|
-
this.accessToken()
|
|
76
|
-
.then((token) => this.realtime.setAuth(token))
|
|
77
|
-
.catch((e) => console.warn('Failed to set initial Realtime auth token:', e));
|
|
78
|
-
}
|
|
79
|
-
this.rest = new postgrest_js_1.PostgrestClient(new URL('rest/v1', baseUrl).href, {
|
|
80
|
-
headers: this.headers,
|
|
81
|
-
schema: settings.db.schema,
|
|
82
|
-
fetch: this.fetch,
|
|
83
|
-
});
|
|
84
|
-
this.storage = new storage_js_1.StorageClient(this.storageUrl.href, this.headers, this.fetch, options === null || options === void 0 ? void 0 : options.storage);
|
|
85
|
-
if (!settings.accessToken) {
|
|
86
|
-
this._listenForAuthEvents();
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
/**
|
|
90
|
-
* Supabase Functions allows you to deploy and invoke edge functions.
|
|
91
|
-
*/
|
|
92
|
-
get functions() {
|
|
93
|
-
return new functions_js_1.FunctionsClient(this.functionsUrl.href, {
|
|
94
|
-
headers: this.headers,
|
|
95
|
-
customFetch: this.fetch,
|
|
96
|
-
});
|
|
97
|
-
}
|
|
98
|
-
/**
|
|
99
|
-
* Perform a query on a table or a view.
|
|
100
|
-
*
|
|
101
|
-
* @param relation - The table or view name to query
|
|
102
|
-
*/
|
|
103
|
-
from(relation) {
|
|
104
|
-
return this.rest.from(relation);
|
|
105
|
-
}
|
|
106
|
-
// NOTE: signatures must be kept in sync with PostgrestClient.schema
|
|
107
|
-
/**
|
|
108
|
-
* Select a schema to query or perform an function (rpc) call.
|
|
109
|
-
*
|
|
110
|
-
* The schema needs to be on the list of exposed schemas inside Supabase.
|
|
111
|
-
*
|
|
112
|
-
* @param schema - The schema to query
|
|
113
|
-
*/
|
|
114
|
-
schema(schema) {
|
|
115
|
-
return this.rest.schema(schema);
|
|
116
|
-
}
|
|
117
|
-
// NOTE: signatures must be kept in sync with PostgrestClient.rpc
|
|
118
|
-
/**
|
|
119
|
-
* Perform a function call.
|
|
120
|
-
*
|
|
121
|
-
* @param fn - The function name to call
|
|
122
|
-
* @param args - The arguments to pass to the function call
|
|
123
|
-
* @param options - Named parameters
|
|
124
|
-
* @param options.head - When set to `true`, `data` will not be returned.
|
|
125
|
-
* Useful if you only need the count.
|
|
126
|
-
* @param options.get - When set to `true`, the function will be called with
|
|
127
|
-
* read-only access mode.
|
|
128
|
-
* @param options.count - Count algorithm to use to count rows returned by the
|
|
129
|
-
* function. Only applicable for [set-returning
|
|
130
|
-
* functions](https://www.postgresql.org/docs/current/functions-srf.html).
|
|
131
|
-
*
|
|
132
|
-
* `"exact"`: Exact but slow count algorithm. Performs a `COUNT(*)` under the
|
|
133
|
-
* hood.
|
|
134
|
-
*
|
|
135
|
-
* `"planned"`: Approximated but fast count algorithm. Uses the Postgres
|
|
136
|
-
* statistics under the hood.
|
|
137
|
-
*
|
|
138
|
-
* `"estimated"`: Uses exact count for low numbers and planned count for high
|
|
139
|
-
* numbers.
|
|
140
|
-
*/
|
|
141
|
-
rpc(fn, args = {}, options = {
|
|
142
|
-
head: false,
|
|
143
|
-
get: false,
|
|
144
|
-
count: undefined,
|
|
145
|
-
}) {
|
|
146
|
-
return this.rest.rpc(fn, args, options);
|
|
147
|
-
}
|
|
148
|
-
/**
|
|
149
|
-
* Creates a Realtime channel with Broadcast, Presence, and Postgres Changes.
|
|
150
|
-
*
|
|
151
|
-
* @param {string} name - The name of the Realtime channel.
|
|
152
|
-
* @param {Object} opts - The options to pass to the Realtime channel.
|
|
153
|
-
*
|
|
154
|
-
*/
|
|
155
|
-
channel(name, opts = { config: {} }) {
|
|
156
|
-
return this.realtime.channel(name, opts);
|
|
157
|
-
}
|
|
158
|
-
/**
|
|
159
|
-
* Returns all Realtime channels.
|
|
160
|
-
*/
|
|
161
|
-
getChannels() {
|
|
162
|
-
return this.realtime.getChannels();
|
|
163
|
-
}
|
|
164
|
-
/**
|
|
165
|
-
* Unsubscribes and removes Realtime channel from Realtime client.
|
|
166
|
-
*
|
|
167
|
-
* @param {RealtimeChannel} channel - The name of the Realtime channel.
|
|
168
|
-
*
|
|
169
|
-
*/
|
|
170
|
-
removeChannel(channel) {
|
|
171
|
-
return this.realtime.removeChannel(channel);
|
|
172
|
-
}
|
|
173
|
-
/**
|
|
174
|
-
* Unsubscribes and removes all Realtime channels from Realtime client.
|
|
175
|
-
*/
|
|
176
|
-
removeAllChannels() {
|
|
177
|
-
return this.realtime.removeAllChannels();
|
|
178
|
-
}
|
|
179
|
-
async _getAccessToken() {
|
|
180
|
-
var _a, _b;
|
|
181
|
-
if (this.accessToken) {
|
|
182
|
-
return await this.accessToken();
|
|
183
|
-
}
|
|
184
|
-
const { data } = await this.auth.getSession();
|
|
185
|
-
return (_b = (_a = data.session) === null || _a === void 0 ? void 0 : _a.access_token) !== null && _b !== void 0 ? _b : this.supabaseKey;
|
|
186
|
-
}
|
|
187
|
-
_initSupabaseAuthClient({ autoRefreshToken, persistSession, detectSessionInUrl, storage, userStorage, storageKey, flowType, lock, debug, throwOnError, }, headers, fetch) {
|
|
188
|
-
const authHeaders = {
|
|
189
|
-
Authorization: `Bearer ${this.supabaseKey}`,
|
|
190
|
-
apikey: `${this.supabaseKey}`,
|
|
191
|
-
};
|
|
192
|
-
return new SupabaseAuthClient_1.SupabaseAuthClient({
|
|
193
|
-
url: this.authUrl.href,
|
|
194
|
-
headers: Object.assign(Object.assign({}, authHeaders), headers),
|
|
195
|
-
storageKey: storageKey,
|
|
196
|
-
autoRefreshToken,
|
|
197
|
-
persistSession,
|
|
198
|
-
detectSessionInUrl,
|
|
199
|
-
storage,
|
|
200
|
-
userStorage,
|
|
201
|
-
flowType,
|
|
202
|
-
lock,
|
|
203
|
-
debug,
|
|
204
|
-
throwOnError,
|
|
205
|
-
fetch,
|
|
206
|
-
// auth checks if there is a custom authorizaiton header using this flag
|
|
207
|
-
// so it knows whether to return an error when getUser is called with no session
|
|
208
|
-
hasCustomAuthorizationHeader: Object.keys(this.headers).some((key) => key.toLowerCase() === 'authorization'),
|
|
209
|
-
});
|
|
210
|
-
}
|
|
211
|
-
_initRealtimeClient(options) {
|
|
212
|
-
return new realtime_js_1.RealtimeClient(this.realtimeUrl.href, Object.assign(Object.assign({}, options), { params: Object.assign({ apikey: this.supabaseKey }, options === null || options === void 0 ? void 0 : options.params) }));
|
|
213
|
-
}
|
|
214
|
-
_listenForAuthEvents() {
|
|
215
|
-
const data = this.auth.onAuthStateChange((event, session) => {
|
|
216
|
-
this._handleTokenChanged(event, 'CLIENT', session === null || session === void 0 ? void 0 : session.access_token);
|
|
217
|
-
});
|
|
218
|
-
return data;
|
|
219
|
-
}
|
|
220
|
-
_handleTokenChanged(event, source, token) {
|
|
221
|
-
if ((event === 'TOKEN_REFRESHED' || event === 'SIGNED_IN') &&
|
|
222
|
-
this.changedAccessToken !== token) {
|
|
223
|
-
this.changedAccessToken = token;
|
|
224
|
-
this.realtime.setAuth(token);
|
|
225
|
-
}
|
|
226
|
-
else if (event === 'SIGNED_OUT') {
|
|
227
|
-
this.realtime.setAuth();
|
|
228
|
-
if (source == 'STORAGE')
|
|
229
|
-
this.auth.signOut();
|
|
230
|
-
this.changedAccessToken = undefined;
|
|
231
|
-
}
|
|
232
|
-
}
|
|
233
|
-
}
|
|
234
|
-
exports.default = SupabaseClient;
|
|
235
|
-
//# sourceMappingURL=SupabaseClient.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"SupabaseClient.js","sourceRoot":"","sources":["../../src/SupabaseClient.ts"],"names":[],"mappings":";;AACA,yDAAwD;AACxD,yDAI+B;AAC/B,uDAK8B;AAC9B,qDAA6E;AAC7E,+CAKwB;AACxB,uCAA2C;AAC3C,2CAAyE;AACzE,iEAA6D;AAS7D;;;;GAIG;AACH,MAAqB,cAAc;IAuDjC;;;;;;;;;;;;;;;;;;;OAmBG;IACH,YACY,WAAmB,EACnB,WAAmB,EAC7B,OAA2C;;QAFjC,gBAAW,GAAX,WAAW,CAAQ;QACnB,gBAAW,GAAX,WAAW,CAAQ;QAG7B,MAAM,OAAO,GAAG,IAAA,6BAAmB,EAAC,WAAW,CAAC,CAAA;QA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AC5C,IAAI,CAAC,kBAAkB,GAAG,SAAS,CAAA;QACrC,CAAC;IACH,CAAC;CACF;AA9XD,iCA8XC"}
|
package/dist/main/index.d.ts
DELETED
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import SupabaseClient from './SupabaseClient';
|
|
2
|
-
import type { SupabaseClientOptions } from './lib/types';
|
|
3
|
-
export * from '@supabase/auth-js';
|
|
4
|
-
export type { User as AuthUser, Session as AuthSession } from '@supabase/auth-js';
|
|
5
|
-
export { type PostgrestResponse, type PostgrestSingleResponse, type PostgrestMaybeSingleResponse, PostgrestError, } from '@supabase/postgrest-js';
|
|
6
|
-
export { FunctionsHttpError, FunctionsFetchError, FunctionsRelayError, FunctionsError, type FunctionInvokeOptions, FunctionRegion, } from '@supabase/functions-js';
|
|
7
|
-
export * from '@supabase/realtime-js';
|
|
8
|
-
export { default as SupabaseClient } from './SupabaseClient';
|
|
9
|
-
export type { SupabaseClientOptions, QueryResult, QueryData, QueryError } from './lib/types';
|
|
10
|
-
/**
|
|
11
|
-
* Creates a new Supabase Client.
|
|
12
|
-
*
|
|
13
|
-
* @example
|
|
14
|
-
* ```ts
|
|
15
|
-
* import { createClient } from '@supabase/supabase-js'
|
|
16
|
-
*
|
|
17
|
-
* const supabase = createClient('https://xyzcompany.supabase.co', 'public-anon-key')
|
|
18
|
-
* const { data, error } = await supabase.from('profiles').select('*')
|
|
19
|
-
* ```
|
|
20
|
-
*/
|
|
21
|
-
export declare const createClient: <Database = any, SchemaNameOrClientOptions extends (string & keyof Omit<Database, "__InternalSupabase">) | {
|
|
22
|
-
PostgrestVersion: string;
|
|
23
|
-
} = "public" extends keyof Omit<Database, "__InternalSupabase"> ? "public" : string & keyof Omit<Database, "__InternalSupabase">, SchemaName extends string & keyof Omit<Database, "__InternalSupabase"> = SchemaNameOrClientOptions extends string & keyof Omit<Database, "__InternalSupabase"> ? SchemaNameOrClientOptions : "public" extends keyof Omit<Database, "__InternalSupabase"> ? "public" : string & keyof Omit<Omit<Database, "__InternalSupabase">, "__InternalSupabase">>(supabaseUrl: string, supabaseKey: string, options?: SupabaseClientOptions<SchemaName>) => SupabaseClient<Database, SchemaNameOrClientOptions, SchemaName>;
|
|
24
|
-
//# sourceMappingURL=index.d.ts.map
|
package/dist/main/index.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,cAAc,MAAM,kBAAkB,CAAA;AAC7C,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAA;AAExD,cAAc,mBAAmB,CAAA;AACjC,YAAY,EAAE,IAAI,IAAI,QAAQ,EAAE,OAAO,IAAI,WAAW,EAAE,MAAM,mBAAmB,CAAA;AACjF,OAAO,EACL,KAAK,iBAAiB,EACtB,KAAK,uBAAuB,EAC5B,KAAK,4BAA4B,EACjC,cAAc,GACf,MAAM,wBAAwB,CAAA;AAC/B,OAAO,EACL,kBAAkB,EAClB,mBAAmB,EACnB,mBAAmB,EACnB,cAAc,EACd,KAAK,qBAAqB,EAC1B,cAAc,GACf,MAAM,wBAAwB,CAAA;AAC/B,cAAc,uBAAuB,CAAA;AACrC,OAAO,EAAE,OAAO,IAAI,cAAc,EAAE,MAAM,kBAAkB,CAAA;AAC5D,YAAY,EAAE,qBAAqB,EAAE,WAAW,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;AAE5F;;;;;;;;;;GAUG;AACH,eAAO,MAAM,YAAY,GACvB,QAAQ,GAAG,GAAG,EACd,yBAAyB,SACrB,CAAC,MAAM,GAAG,MAAM,IAAI,CAAC,QAAQ,EAAE,oBAAoB,CAAC,CAAC,GACrD;IAAE,gBAAgB,EAAE,MAAM,CAAA;CAAE,GAAG,QAAQ,SAAS,MAAM,IAAI,CAAC,QAAQ,EAAE,oBAAoB,CAAC,GAC1F,QAAQ,GACR,MAAM,GAAG,MAAM,IAAI,CAAC,QAAQ,E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