@supabase/supabase-js 1.36.0-next.2 → 1.36.0-next.22
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/main/SupabaseClient.d.ts +33 -58
- package/dist/main/SupabaseClient.d.ts.map +1 -1
- package/dist/main/SupabaseClient.js +59 -159
- package/dist/main/SupabaseClient.js.map +1 -1
- package/dist/main/index.d.ts +6 -5
- package/dist/main/index.d.ts.map +1 -1
- package/dist/main/index.js +3 -2
- package/dist/main/index.js.map +1 -1
- package/dist/main/lib/constants.d.ts +0 -1
- package/dist/main/lib/constants.d.ts.map +1 -1
- package/dist/main/lib/constants.js +1 -2
- package/dist/main/lib/constants.js.map +1 -1
- package/dist/main/lib/helpers.d.ts +2 -0
- package/dist/main/lib/helpers.d.ts.map +1 -1
- package/dist/main/lib/helpers.js +12 -2
- package/dist/main/lib/helpers.js.map +1 -1
- package/dist/main/lib/types.d.ts +52 -52
- package/dist/main/lib/types.d.ts.map +1 -1
- package/dist/main/lib/version.d.ts +1 -1
- package/dist/main/lib/version.js +1 -1
- package/dist/module/SupabaseClient.d.ts +33 -58
- package/dist/module/SupabaseClient.d.ts.map +1 -1
- package/dist/module/SupabaseClient.js +63 -163
- package/dist/module/SupabaseClient.js.map +1 -1
- package/dist/module/index.d.ts +6 -5
- package/dist/module/index.d.ts.map +1 -1
- package/dist/module/index.js +2 -2
- package/dist/module/index.js.map +1 -1
- package/dist/module/lib/constants.d.ts +0 -1
- package/dist/module/lib/constants.d.ts.map +1 -1
- package/dist/module/lib/constants.js +0 -1
- package/dist/module/lib/constants.js.map +1 -1
- package/dist/module/lib/helpers.d.ts +2 -0
- package/dist/module/lib/helpers.d.ts.map +1 -1
- package/dist/module/lib/helpers.js +10 -1
- package/dist/module/lib/helpers.js.map +1 -1
- package/dist/module/lib/types.d.ts +52 -52
- package/dist/module/lib/types.d.ts.map +1 -1
- package/dist/module/lib/version.d.ts +1 -1
- package/dist/module/lib/version.js +1 -1
- package/dist/umd/supabase.js +1 -1
- package/package.json +6 -6
- package/src/SupabaseClient.ts +123 -201
- package/src/index.ts +17 -15
- package/src/lib/constants.ts +0 -1
- package/src/lib/helpers.ts +43 -0
- package/src/lib/types.ts +52 -53
- package/src/lib/version.ts +1 -1
- package/dist/main/lib/SupabaseQueryBuilder.d.ts +0 -26
- package/dist/main/lib/SupabaseQueryBuilder.d.ts.map +0 -1
- package/dist/main/lib/SupabaseQueryBuilder.js +0 -31
- package/dist/main/lib/SupabaseQueryBuilder.js.map +0 -1
- package/dist/main/lib/SupabaseRealtimeClient.d.ts +0 -19
- package/dist/main/lib/SupabaseRealtimeClient.d.ts.map +0 -1
- package/dist/main/lib/SupabaseRealtimeClient.js +0 -65
- package/dist/main/lib/SupabaseRealtimeClient.js.map +0 -1
- package/dist/module/lib/SupabaseQueryBuilder.d.ts +0 -26
- package/dist/module/lib/SupabaseQueryBuilder.d.ts.map +0 -1
- package/dist/module/lib/SupabaseQueryBuilder.js +0 -27
- package/dist/module/lib/SupabaseQueryBuilder.js.map +0 -1
- package/dist/module/lib/SupabaseRealtimeClient.d.ts +0 -19
- package/dist/module/lib/SupabaseRealtimeClient.d.ts.map +0 -1
- package/dist/module/lib/SupabaseRealtimeClient.js +0 -61
- package/dist/module/lib/SupabaseRealtimeClient.js.map +0 -1
- package/src/lib/SupabaseQueryBuilder.ts +0 -61
- package/src/lib/SupabaseRealtimeClient.ts +0 -74
|
@@ -1,32 +1,30 @@
|
|
|
1
1
|
import { FunctionsClient } from '@supabase/functions-js';
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
2
|
+
import { PostgrestClient, PostgrestFilterBuilder, PostgrestQueryBuilder } from '@supabase/postgrest-js';
|
|
3
|
+
import { RealtimeChannel, RealtimeClient } from '@supabase/realtime-js';
|
|
4
|
+
import { StorageClient as SupabaseStorageClient } from '@supabase/storage-js';
|
|
4
5
|
import { SupabaseAuthClient } from './lib/SupabaseAuthClient';
|
|
5
|
-
import {
|
|
6
|
-
import { Fetch, SupabaseClientOptions } from './lib/types';
|
|
6
|
+
import { Fetch, GenericSchema, SupabaseClientOptions } from './lib/types';
|
|
7
7
|
/**
|
|
8
8
|
* Supabase Client.
|
|
9
9
|
*
|
|
10
10
|
* An isomorphic Javascript client for interacting with Postgres.
|
|
11
11
|
*/
|
|
12
|
-
export default class SupabaseClient {
|
|
12
|
+
export default class SupabaseClient<Database = any, SchemaName extends string & keyof Database = 'public' extends keyof Database ? 'public' : string & keyof Database, Schema extends GenericSchema = Database[SchemaName] extends GenericSchema ? Database[SchemaName] : any> {
|
|
13
13
|
protected supabaseUrl: string;
|
|
14
14
|
protected supabaseKey: string;
|
|
15
15
|
/**
|
|
16
16
|
* Supabase Auth allows you to create and manage user sessions for access to data that is secured by access policies.
|
|
17
17
|
*/
|
|
18
18
|
auth: SupabaseAuthClient;
|
|
19
|
-
protected schema: string;
|
|
20
|
-
protected restUrl: string;
|
|
21
19
|
protected realtimeUrl: string;
|
|
22
20
|
protected authUrl: string;
|
|
23
21
|
protected storageUrl: string;
|
|
24
22
|
protected functionsUrl: string;
|
|
25
23
|
protected realtime: RealtimeClient;
|
|
26
|
-
protected
|
|
24
|
+
protected rest: PostgrestClient<Database, SchemaName>;
|
|
25
|
+
protected storageKey: string;
|
|
27
26
|
protected fetch?: Fetch;
|
|
28
27
|
protected changedAccessToken: string | undefined;
|
|
29
|
-
protected shouldThrowOnError: boolean;
|
|
30
28
|
protected headers: {
|
|
31
29
|
[key: string]: string;
|
|
32
30
|
};
|
|
@@ -34,16 +32,15 @@ export default class SupabaseClient {
|
|
|
34
32
|
* Create a new client for use in the browser.
|
|
35
33
|
* @param supabaseUrl The unique Supabase URL which is supplied when you create a new project in your project dashboard.
|
|
36
34
|
* @param supabaseKey The unique Supabase Key which is supplied when you create a new project in your project dashboard.
|
|
37
|
-
* @param options.schema You can switch in between schemas. The schema needs to be on the list of exposed schemas inside Supabase.
|
|
38
|
-
* @param options.autoRefreshToken Set to "true" if you want to automatically refresh the token before expiring.
|
|
39
|
-
* @param options.persistSession Set to "true" if you want to automatically save the user session into local storage.
|
|
40
|
-
* @param options.detectSessionInUrl Set to "true" if you want to automatically detects OAuth grants in the URL and signs in the user.
|
|
41
|
-
* @param options.headers Any additional headers to send with each network request.
|
|
35
|
+
* @param options.db.schema You can switch in between schemas. The schema needs to be on the list of exposed schemas inside Supabase.
|
|
36
|
+
* @param options.auth.autoRefreshToken Set to "true" if you want to automatically refresh the token before expiring.
|
|
37
|
+
* @param options.auth.persistSession Set to "true" if you want to automatically save the user session into local storage.
|
|
38
|
+
* @param options.auth.detectSessionInUrl Set to "true" if you want to automatically detects OAuth grants in the URL and signs in the user.
|
|
42
39
|
* @param options.realtime Options passed along to realtime-js constructor.
|
|
43
|
-
* @param options.
|
|
44
|
-
* @param options.
|
|
40
|
+
* @param options.global.fetch A custom fetch implementation.
|
|
41
|
+
* @param options.global.headers Any additional headers to send with each network request.
|
|
45
42
|
*/
|
|
46
|
-
constructor(supabaseUrl: string, supabaseKey: string, options?: SupabaseClientOptions);
|
|
43
|
+
constructor(supabaseUrl: string, supabaseKey: string, options?: SupabaseClientOptions<SchemaName>);
|
|
47
44
|
/**
|
|
48
45
|
* Supabase Functions allows you to deploy and invoke edge functions.
|
|
49
46
|
*/
|
|
@@ -57,7 +54,8 @@ export default class SupabaseClient {
|
|
|
57
54
|
*
|
|
58
55
|
* @param table The table name to operate on.
|
|
59
56
|
*/
|
|
60
|
-
from<
|
|
57
|
+
from<TableName extends string & keyof Schema['Tables'], Table extends Schema['Tables'][TableName]>(table: TableName): PostgrestQueryBuilder<Table>;
|
|
58
|
+
from(table: string): PostgrestQueryBuilder<any>;
|
|
61
59
|
/**
|
|
62
60
|
* Perform a function call.
|
|
63
61
|
*
|
|
@@ -67,61 +65,38 @@ export default class SupabaseClient {
|
|
|
67
65
|
* @param count Count algorithm to use to count rows in a table.
|
|
68
66
|
*
|
|
69
67
|
*/
|
|
70
|
-
rpc<
|
|
68
|
+
rpc<FunctionName extends string & keyof Schema['Functions'], Function_ extends Schema['Functions'][FunctionName]>(fn: FunctionName, args?: Function_['Args'], options?: {
|
|
71
69
|
head?: boolean;
|
|
72
|
-
count?:
|
|
73
|
-
}):
|
|
70
|
+
count?: 'exact' | 'planned' | 'estimated';
|
|
71
|
+
}): PostgrestFilterBuilder<Function_['Returns'] extends any[] ? Function_['Returns'][number] extends Record<string, unknown> ? Function_['Returns'][number] : never : never, Function_['Returns']>;
|
|
74
72
|
/**
|
|
75
|
-
* Creates a channel with Broadcast and
|
|
76
|
-
*
|
|
73
|
+
* Creates a Realtime channel with Broadcast, Presence, and Postgres Changes.
|
|
74
|
+
*
|
|
75
|
+
* @param {string} name - The name of the Realtime channel.
|
|
76
|
+
* @param {Object} opts - The options to pass to the Realtime channel.
|
|
77
|
+
*
|
|
77
78
|
*/
|
|
78
|
-
channel(name: string, opts
|
|
79
|
-
selfBroadcast: boolean;
|
|
79
|
+
channel(name: string, opts?: {
|
|
80
80
|
[key: string]: any;
|
|
81
81
|
}): RealtimeChannel;
|
|
82
82
|
/**
|
|
83
|
-
*
|
|
84
|
-
* subscriptions and their errors.
|
|
83
|
+
* Returns all Realtime channels.
|
|
85
84
|
*/
|
|
86
|
-
|
|
87
|
-
data: {
|
|
88
|
-
subscription: RealtimeSubscription;
|
|
89
|
-
};
|
|
90
|
-
error: Error | null;
|
|
91
|
-
}[]>;
|
|
85
|
+
getChannels(): RealtimeChannel[];
|
|
92
86
|
/**
|
|
93
|
-
*
|
|
87
|
+
* Unsubscribes and removes Realtime channel from Realtime client.
|
|
94
88
|
*
|
|
95
|
-
* @param channel The
|
|
96
|
-
*/
|
|
97
|
-
removeChannel(channel: RealtimeChannel): Promise<{
|
|
98
|
-
data: {
|
|
99
|
-
openChannels: number;
|
|
100
|
-
};
|
|
101
|
-
error: Error | null;
|
|
102
|
-
}>;
|
|
103
|
-
/**
|
|
104
|
-
* Closes and removes a subscription and returns the number of open subscriptions.
|
|
89
|
+
* @param {RealtimeChannel} channel - The name of the Realtime channel.
|
|
105
90
|
*
|
|
106
|
-
* @param subscription The subscription you want to close and remove.
|
|
107
91
|
*/
|
|
108
|
-
|
|
109
|
-
data: {
|
|
110
|
-
openSubscriptions: number;
|
|
111
|
-
};
|
|
112
|
-
error: Error | null;
|
|
113
|
-
}>;
|
|
114
|
-
private _getAccessToken;
|
|
115
|
-
private _closeSubscription;
|
|
116
|
-
private _unsubscribeSubscription;
|
|
92
|
+
removeChannel(channel: RealtimeChannel): Promise<'ok' | 'timed out' | 'error'>;
|
|
117
93
|
/**
|
|
118
|
-
*
|
|
94
|
+
* Unsubscribes and removes all Realtime channels from Realtime client.
|
|
119
95
|
*/
|
|
120
|
-
|
|
96
|
+
removeAllChannels(): Promise<('ok' | 'timed out' | 'error')[]>;
|
|
97
|
+
private _getAccessToken;
|
|
121
98
|
private _initSupabaseAuthClient;
|
|
122
99
|
private _initRealtimeClient;
|
|
123
|
-
private _initPostgRESTClient;
|
|
124
|
-
private _listenForMultiTabEvents;
|
|
125
100
|
private _listenForAuthEvents;
|
|
126
101
|
private _handleTokenChanged;
|
|
127
102
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SupabaseClient.d.ts","sourceRoot":"","sources":["../../src/SupabaseClient.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAA;
|
|
1
|
+
{"version":3,"file":"SupabaseClient.d.ts","sourceRoot":"","sources":["../../src/SupabaseClient.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAA;AAExD,OAAO,EACL,eAAe,EACf,sBAAsB,EACtB,qBAAqB,EACtB,MAAM,wBAAwB,CAAA;AAC/B,OAAO,EAAE,eAAe,EAAE,cAAc,EAAyB,MAAM,uBAAuB,CAAA;AAC9F,OAAO,EAAE,aAAa,IAAI,qBAAqB,EAAE,MAAM,sBAAsB,CAAA;AAI7E,OAAO,EAAE,kBAAkB,EAAE,MA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AAC,IAAI,GAAG,WAAW,GAAG,OAAO,CAAC,EAAE,CAAC;YAIhD,eAAe;IAM7B,OAAO,CAAC,uBAAuB;IA6B/B,OAAO,CAAC,mBAAmB;IAO3B,OAAO,CAAC,oBAAoB;IAO5B,OAAO,CAAC,mBAAmB;CAmB5B"}
|
|
@@ -17,15 +17,18 @@ const constants_1 = require("./lib/constants");
|
|
|
17
17
|
const fetch_1 = require("./lib/fetch");
|
|
18
18
|
const helpers_1 = require("./lib/helpers");
|
|
19
19
|
const SupabaseAuthClient_1 = require("./lib/SupabaseAuthClient");
|
|
20
|
-
const
|
|
21
|
-
|
|
20
|
+
const DEFAULT_GLOBAL_OPTIONS = {
|
|
21
|
+
headers: constants_1.DEFAULT_HEADERS,
|
|
22
|
+
};
|
|
23
|
+
const DEFAULT_DB_OPTIONS = {
|
|
22
24
|
schema: 'public',
|
|
25
|
+
};
|
|
26
|
+
const DEFAULT_AUTH_OPTIONS = {
|
|
23
27
|
autoRefreshToken: true,
|
|
24
28
|
persistSession: true,
|
|
25
29
|
detectSessionInUrl: true,
|
|
26
|
-
multiTab: true,
|
|
27
|
-
headers: constants_1.DEFAULT_HEADERS,
|
|
28
30
|
};
|
|
31
|
+
const DEFAULT_REALTIME_OPTIONS = {};
|
|
29
32
|
/**
|
|
30
33
|
* Supabase Client.
|
|
31
34
|
*
|
|
@@ -36,16 +39,16 @@ class SupabaseClient {
|
|
|
36
39
|
* Create a new client for use in the browser.
|
|
37
40
|
* @param supabaseUrl The unique Supabase URL which is supplied when you create a new project in your project dashboard.
|
|
38
41
|
* @param supabaseKey The unique Supabase Key which is supplied when you create a new project in your project dashboard.
|
|
39
|
-
* @param options.schema You can switch in between schemas. The schema needs to be on the list of exposed schemas inside Supabase.
|
|
40
|
-
* @param options.autoRefreshToken Set to "true" if you want to automatically refresh the token before expiring.
|
|
41
|
-
* @param options.persistSession Set to "true" if you want to automatically save the user session into local storage.
|
|
42
|
-
* @param options.detectSessionInUrl Set to "true" if you want to automatically detects OAuth grants in the URL and signs in the user.
|
|
43
|
-
* @param options.headers Any additional headers to send with each network request.
|
|
42
|
+
* @param options.db.schema You can switch in between schemas. The schema needs to be on the list of exposed schemas inside Supabase.
|
|
43
|
+
* @param options.auth.autoRefreshToken Set to "true" if you want to automatically refresh the token before expiring.
|
|
44
|
+
* @param options.auth.persistSession Set to "true" if you want to automatically save the user session into local storage.
|
|
45
|
+
* @param options.auth.detectSessionInUrl Set to "true" if you want to automatically detects OAuth grants in the URL and signs in the user.
|
|
44
46
|
* @param options.realtime Options passed along to realtime-js constructor.
|
|
45
|
-
* @param options.
|
|
46
|
-
* @param options.
|
|
47
|
+
* @param options.global.fetch A custom fetch implementation.
|
|
48
|
+
* @param options.global.headers Any additional headers to send with each network request.
|
|
47
49
|
*/
|
|
48
50
|
constructor(supabaseUrl, supabaseKey, options) {
|
|
51
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
49
52
|
this.supabaseUrl = supabaseUrl;
|
|
50
53
|
this.supabaseKey = supabaseKey;
|
|
51
54
|
if (!supabaseUrl)
|
|
@@ -53,8 +56,6 @@ class SupabaseClient {
|
|
|
53
56
|
if (!supabaseKey)
|
|
54
57
|
throw new Error('supabaseKey is required.');
|
|
55
58
|
const _supabaseUrl = (0, helpers_1.stripTrailingSlash)(supabaseUrl);
|
|
56
|
-
const settings = Object.assign(Object.assign({}, DEFAULT_OPTIONS), options);
|
|
57
|
-
this.restUrl = `${_supabaseUrl}/rest/v1`;
|
|
58
59
|
this.realtimeUrl = `${_supabaseUrl}/realtime/v1`.replace('http', 'ws');
|
|
59
60
|
this.authUrl = `${_supabaseUrl}/auth/v1`;
|
|
60
61
|
this.storageUrl = `${_supabaseUrl}/storage/v1`;
|
|
@@ -66,19 +67,26 @@ class SupabaseClient {
|
|
|
66
67
|
else {
|
|
67
68
|
this.functionsUrl = `${_supabaseUrl}/functions/v1`;
|
|
68
69
|
}
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
70
|
+
// default storage key uses the supabase project ref as a namespace
|
|
71
|
+
const defaultStorageKey = `sb-${new URL(this.authUrl).hostname.split('.')[0]}-auth-token`;
|
|
72
|
+
const DEFAULTS = {
|
|
73
|
+
db: DEFAULT_DB_OPTIONS,
|
|
74
|
+
realtime: DEFAULT_REALTIME_OPTIONS,
|
|
75
|
+
auth: Object.assign(Object.assign({}, DEFAULT_AUTH_OPTIONS), { storageKey: defaultStorageKey }),
|
|
76
|
+
global: DEFAULT_GLOBAL_OPTIONS,
|
|
77
|
+
};
|
|
78
|
+
const settings = (0, helpers_1.applySettingDefaults)(options !== null && options !== void 0 ? options : {}, DEFAULTS);
|
|
79
|
+
this.storageKey = (_b = (_a = settings.auth) === null || _a === void 0 ? void 0 : _a.storageKey) !== null && _b !== void 0 ? _b : '';
|
|
80
|
+
this.headers = (_d = (_c = settings.global) === null || _c === void 0 ? void 0 : _c.headers) !== null && _d !== void 0 ? _d : {};
|
|
81
|
+
this.auth = this._initSupabaseAuthClient((_e = settings.auth) !== null && _e !== void 0 ? _e : {}, this.headers, (_f = settings.global) === null || _f === void 0 ? void 0 : _f.fetch);
|
|
82
|
+
this.fetch = (0, fetch_1.fetchWithAuth)(supabaseKey, this._getAccessToken.bind(this), (_g = settings.global) === null || _g === void 0 ? void 0 : _g.fetch);
|
|
74
83
|
this.realtime = this._initRealtimeClient(Object.assign({ headers: this.headers }, settings.realtime));
|
|
75
|
-
this.
|
|
84
|
+
this.rest = new postgrest_js_1.PostgrestClient(`${_supabaseUrl}/rest/v1`, {
|
|
85
|
+
headers: this.headers,
|
|
86
|
+
schema: (_h = settings.db) === null || _h === void 0 ? void 0 : _h.schema,
|
|
87
|
+
fetch: this.fetch,
|
|
88
|
+
});
|
|
76
89
|
this._listenForAuthEvents();
|
|
77
|
-
this._listenForMultiTabEvents();
|
|
78
|
-
// In the future we might allow the user to pass in a logger to receive these events.
|
|
79
|
-
// this.realtime.onOpen(() => console.log('OPEN'))
|
|
80
|
-
// this.realtime.onClose(() => console.log('CLOSED'))
|
|
81
|
-
// this.realtime.onError((e: Error) => console.log('Socket error', e))
|
|
82
90
|
}
|
|
83
91
|
/**
|
|
84
92
|
* Supabase Functions allows you to deploy and invoke edge functions.
|
|
@@ -93,23 +101,10 @@ class SupabaseClient {
|
|
|
93
101
|
* Supabase Storage allows you to manage user-generated content, such as photos or videos.
|
|
94
102
|
*/
|
|
95
103
|
get storage() {
|
|
96
|
-
return new storage_js_1.
|
|
104
|
+
return new storage_js_1.StorageClient(this.storageUrl, this.headers, this.fetch);
|
|
97
105
|
}
|
|
98
|
-
/**
|
|
99
|
-
* Perform a table operation.
|
|
100
|
-
*
|
|
101
|
-
* @param table The table name to operate on.
|
|
102
|
-
*/
|
|
103
106
|
from(table) {
|
|
104
|
-
|
|
105
|
-
return new SupabaseQueryBuilder_1.SupabaseQueryBuilder(url, {
|
|
106
|
-
headers: this.headers,
|
|
107
|
-
schema: this.schema,
|
|
108
|
-
realtime: this.realtime,
|
|
109
|
-
table,
|
|
110
|
-
fetch: this.fetch,
|
|
111
|
-
shouldThrowOnError: this.shouldThrowOnError,
|
|
112
|
-
});
|
|
107
|
+
return this.rest.from(table);
|
|
113
108
|
}
|
|
114
109
|
/**
|
|
115
110
|
* Perform a function call.
|
|
@@ -120,68 +115,39 @@ class SupabaseClient {
|
|
|
120
115
|
* @param count Count algorithm to use to count rows in a table.
|
|
121
116
|
*
|
|
122
117
|
*/
|
|
123
|
-
rpc(fn,
|
|
124
|
-
|
|
125
|
-
return rest.rpc(fn, params, { head, count });
|
|
118
|
+
rpc(fn, args = {}, options) {
|
|
119
|
+
return this.rest.rpc(fn, args, options);
|
|
126
120
|
}
|
|
127
121
|
/**
|
|
128
|
-
* Creates a channel with Broadcast and
|
|
129
|
-
*
|
|
122
|
+
* Creates a Realtime channel with Broadcast, Presence, and Postgres Changes.
|
|
123
|
+
*
|
|
124
|
+
* @param {string} name - The name of the Realtime channel.
|
|
125
|
+
* @param {Object} opts - The options to pass to the Realtime channel.
|
|
126
|
+
*
|
|
130
127
|
*/
|
|
131
|
-
channel(name, opts) {
|
|
132
|
-
|
|
133
|
-
const userToken = (_b = (_a = this.auth.session()) === null || _a === void 0 ? void 0 : _a.access_token) !== null && _b !== void 0 ? _b : this.supabaseKey;
|
|
134
|
-
if (!this.realtime.isConnected()) {
|
|
135
|
-
this.realtime.connect();
|
|
136
|
-
}
|
|
137
|
-
return this.realtime.channel(name, Object.assign(Object.assign({}, opts), { user_token: userToken }));
|
|
128
|
+
channel(name, opts = {}) {
|
|
129
|
+
return this.realtime.channel(name, opts);
|
|
138
130
|
}
|
|
139
131
|
/**
|
|
140
|
-
*
|
|
141
|
-
* subscriptions and their errors.
|
|
132
|
+
* Returns all Realtime channels.
|
|
142
133
|
*/
|
|
143
|
-
|
|
144
|
-
return
|
|
145
|
-
const allSubs = this.getSubscriptions().slice();
|
|
146
|
-
const allSubPromises = allSubs.map((sub) => this.removeSubscription(sub));
|
|
147
|
-
const allRemovedSubs = yield Promise.all(allSubPromises);
|
|
148
|
-
return allRemovedSubs.map(({ error }, i) => {
|
|
149
|
-
return {
|
|
150
|
-
data: { subscription: allSubs[i] },
|
|
151
|
-
error,
|
|
152
|
-
};
|
|
153
|
-
});
|
|
154
|
-
});
|
|
134
|
+
getChannels() {
|
|
135
|
+
return this.realtime.getChannels();
|
|
155
136
|
}
|
|
156
137
|
/**
|
|
157
|
-
*
|
|
138
|
+
* Unsubscribes and removes Realtime channel from Realtime client.
|
|
139
|
+
*
|
|
140
|
+
* @param {RealtimeChannel} channel - The name of the Realtime channel.
|
|
158
141
|
*
|
|
159
|
-
* @param channel The channel you want to close and remove.
|
|
160
142
|
*/
|
|
161
143
|
removeChannel(channel) {
|
|
162
|
-
return
|
|
163
|
-
const { error } = yield this._closeSubscription(channel);
|
|
164
|
-
const allChans = this.getSubscriptions();
|
|
165
|
-
const openChanCount = allChans.filter((chan) => chan.isJoined()).length;
|
|
166
|
-
if (allChans.length === 0)
|
|
167
|
-
yield this.realtime.disconnect();
|
|
168
|
-
return { data: { openChannels: openChanCount }, error };
|
|
169
|
-
});
|
|
144
|
+
return this.realtime.removeChannel(channel);
|
|
170
145
|
}
|
|
171
146
|
/**
|
|
172
|
-
*
|
|
173
|
-
*
|
|
174
|
-
* @param subscription The subscription you want to close and remove.
|
|
147
|
+
* Unsubscribes and removes all Realtime channels from Realtime client.
|
|
175
148
|
*/
|
|
176
|
-
|
|
177
|
-
return
|
|
178
|
-
const { error } = yield this._closeSubscription(subscription);
|
|
179
|
-
const allSubs = this.getSubscriptions();
|
|
180
|
-
const openSubCount = allSubs.filter((chan) => chan.isJoined()).length;
|
|
181
|
-
if (allSubs.length === 0)
|
|
182
|
-
yield this.realtime.disconnect();
|
|
183
|
-
return { data: { openSubscriptions: openSubCount }, error };
|
|
184
|
-
});
|
|
149
|
+
removeAllChannels() {
|
|
150
|
+
return this.realtime.removeAllChannels();
|
|
185
151
|
}
|
|
186
152
|
_getAccessToken() {
|
|
187
153
|
var _a;
|
|
@@ -190,33 +156,7 @@ class SupabaseClient {
|
|
|
190
156
|
return (_a = session === null || session === void 0 ? void 0 : session.access_token) !== null && _a !== void 0 ? _a : null;
|
|
191
157
|
});
|
|
192
158
|
}
|
|
193
|
-
|
|
194
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
195
|
-
let error = null;
|
|
196
|
-
if (!subscription.isClosed()) {
|
|
197
|
-
const { error: unsubError } = yield this._unsubscribeSubscription(subscription);
|
|
198
|
-
error = unsubError;
|
|
199
|
-
}
|
|
200
|
-
this.realtime.remove(subscription);
|
|
201
|
-
return { error };
|
|
202
|
-
});
|
|
203
|
-
}
|
|
204
|
-
_unsubscribeSubscription(subscription) {
|
|
205
|
-
return new Promise((resolve) => {
|
|
206
|
-
subscription
|
|
207
|
-
.unsubscribe()
|
|
208
|
-
.receive('ok', () => resolve({ error: null }))
|
|
209
|
-
.receive('error', (error) => resolve({ error }))
|
|
210
|
-
.receive('timeout', () => resolve({ error: new Error('timed out') }));
|
|
211
|
-
});
|
|
212
|
-
}
|
|
213
|
-
/**
|
|
214
|
-
* Returns an array of all your subscriptions.
|
|
215
|
-
*/
|
|
216
|
-
getSubscriptions() {
|
|
217
|
-
return this.realtime.channels;
|
|
218
|
-
}
|
|
219
|
-
_initSupabaseAuthClient({ autoRefreshToken, persistSession, detectSessionInUrl, localStorage, headers, fetch, cookieOptions, multiTab, }) {
|
|
159
|
+
_initSupabaseAuthClient({ autoRefreshToken, persistSession, detectSessionInUrl, storage, cookieOptions, storageKey, }, headers, fetch) {
|
|
220
160
|
const authHeaders = {
|
|
221
161
|
Authorization: `Bearer ${this.supabaseKey}`,
|
|
222
162
|
apikey: `${this.supabaseKey}`,
|
|
@@ -224,56 +164,20 @@ class SupabaseClient {
|
|
|
224
164
|
return new SupabaseAuthClient_1.SupabaseAuthClient({
|
|
225
165
|
url: this.authUrl,
|
|
226
166
|
headers: Object.assign(Object.assign({}, headers), authHeaders),
|
|
167
|
+
storageKey: storageKey,
|
|
227
168
|
autoRefreshToken,
|
|
228
169
|
persistSession,
|
|
229
170
|
detectSessionInUrl,
|
|
230
|
-
|
|
171
|
+
storage,
|
|
231
172
|
fetch,
|
|
232
173
|
cookieOptions,
|
|
233
|
-
multiTab,
|
|
234
174
|
});
|
|
235
175
|
}
|
|
236
176
|
_initRealtimeClient(options) {
|
|
237
|
-
return new realtime_js_1.RealtimeClient(this.realtimeUrl, Object.assign(Object.assign({}, options), { params: Object.assign(
|
|
238
|
-
}
|
|
239
|
-
_initPostgRESTClient() {
|
|
240
|
-
return new postgrest_js_1.PostgrestClient(this.restUrl, {
|
|
241
|
-
headers: this.headers,
|
|
242
|
-
schema: this.schema,
|
|
243
|
-
fetch: this.fetch,
|
|
244
|
-
throwOnError: this.shouldThrowOnError,
|
|
245
|
-
});
|
|
246
|
-
}
|
|
247
|
-
_listenForMultiTabEvents() {
|
|
248
|
-
if (!this.multiTab || !(0, helpers_1.isBrowser)() || !(window === null || window === void 0 ? void 0 : window.addEventListener)) {
|
|
249
|
-
return null;
|
|
250
|
-
}
|
|
251
|
-
try {
|
|
252
|
-
return window === null || window === void 0 ? void 0 : window.addEventListener('storage', (e) => {
|
|
253
|
-
var _a, _b, _c;
|
|
254
|
-
if (e.key === constants_1.STORAGE_KEY) {
|
|
255
|
-
const newSession = JSON.parse(String(e.newValue));
|
|
256
|
-
const accessToken = (_b = (_a = newSession === null || newSession === void 0 ? void 0 : newSession.currentSession) === null || _a === void 0 ? void 0 : _a.access_token) !== null && _b !== void 0 ? _b : undefined;
|
|
257
|
-
const previousAccessToken = (_c = this.auth.session()) === null || _c === void 0 ? void 0 : _c.access_token;
|
|
258
|
-
if (!accessToken) {
|
|
259
|
-
this._handleTokenChanged('SIGNED_OUT', accessToken, 'STORAGE');
|
|
260
|
-
}
|
|
261
|
-
else if (!previousAccessToken && accessToken) {
|
|
262
|
-
this._handleTokenChanged('SIGNED_IN', accessToken, 'STORAGE');
|
|
263
|
-
}
|
|
264
|
-
else if (previousAccessToken !== accessToken) {
|
|
265
|
-
this._handleTokenChanged('TOKEN_REFRESHED', accessToken, 'STORAGE');
|
|
266
|
-
}
|
|
267
|
-
}
|
|
268
|
-
});
|
|
269
|
-
}
|
|
270
|
-
catch (error) {
|
|
271
|
-
console.error('_listenForMultiTabEvents', error);
|
|
272
|
-
return null;
|
|
273
|
-
}
|
|
177
|
+
return new realtime_js_1.RealtimeClient(this.realtimeUrl, Object.assign(Object.assign({}, options), { params: Object.assign({ apikey: this.supabaseKey }, options === null || options === void 0 ? void 0 : options.params) }));
|
|
274
178
|
}
|
|
275
179
|
_listenForAuthEvents() {
|
|
276
|
-
let
|
|
180
|
+
let data = this.auth.onAuthStateChange((event, session) => {
|
|
277
181
|
this._handleTokenChanged(event, session === null || session === void 0 ? void 0 : session.access_token, 'CLIENT');
|
|
278
182
|
});
|
|
279
183
|
return data;
|
|
@@ -282,11 +186,7 @@ class SupabaseClient {
|
|
|
282
186
|
if ((event === 'TOKEN_REFRESHED' || event === 'SIGNED_IN') &&
|
|
283
187
|
this.changedAccessToken !== token) {
|
|
284
188
|
// Token has changed
|
|
285
|
-
this.realtime.setAuth(token);
|
|
286
|
-
// Ideally we should call this.auth.recoverSession() - need to make public
|
|
287
|
-
// to trigger a "SIGNED_IN" event on this client.
|
|
288
|
-
if (source == 'STORAGE')
|
|
289
|
-
this.auth.setAuth(token);
|
|
189
|
+
this.realtime.setAuth(token !== null && token !== void 0 ? token : null);
|
|
290
190
|
this.changedAccessToken = token;
|
|
291
191
|
}
|
|
292
192
|
else if (event === 'SIGNED_OUT' || event === 'USER_DELETED') {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SupabaseClient.js","sourceRoot":"","sources":["../../src/SupabaseClient.ts"],"names":[],"mappings":";;;;;;;;;;;AAAA,yDAAwD;AAExD,
|
|
1
|
+
{"version":3,"file":"SupabaseClient.js","sourceRoot":"","sources":["../../src/SupabaseClient.ts"],"names":[],"mappings":";;;;;;;;;;;AAAA,yDAAwD;AAExD,yDAI+B;AAC/B,uDAA8F;AAC9F,qDAA6E;AAC7E,+CAAiD;AACjD,uCAA2C;AAC3C,2CAAwE;AACxE,iEAA6D;AAG7D,MAAM,sBAAsB,GAAG;IAC7B,OAAO,EAAE,2BAAe;CACzB,CAAA;AAED,MAAM,kBAAkB,GAAG;IACzB,MAAM,EAAE,QAAQ;CACjB,CAAA;AAED,MAAM,oBAAoB,GAA8B;IACtD,gBAAgB,EAAE,IAAI;IACtB,cAAc,EAAE,IAAI;IACpB,kBAAkB,EAAE,IAAI;CACzB,CAAA;AAED,MAAM,wBAAwB,GAA0B,EAAE,CAAA;AAE1D;;;;GAIG;AACH,MAAqB,cAAc;IA4BjC;;;;;;;;;;;OAWG;IACH,YACY,WAAmB,EACnB,WAAmB,EAC7B,OAA2C;;QAFjC,gBAAW,GAAX,WAAW,CAAQ;QACnB,gBAAW,GAAX,WAAW,CAAQ;QAG7B,IAAI,CAAC,WAAW;YAAE,MAAM,IAAI,KAA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AI,CAAC,OAAO,EAAE,CAAA;SAC7C;IACH,CAAC;CACF;AAhQD,iCAgQC"}
|
package/dist/main/index.d.ts
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import SupabaseClient from './SupabaseClient';
|
|
2
|
-
import {
|
|
3
|
-
import { User as AuthUser, Session as AuthSession } from '@supabase/gotrue-js';
|
|
2
|
+
import type { GenericSchema, SupabaseClientOptions } from './lib/types';
|
|
4
3
|
export * from '@supabase/gotrue-js';
|
|
5
|
-
export {
|
|
4
|
+
export type { User as AuthUser, Session as AuthSession } from '@supabase/gotrue-js';
|
|
5
|
+
export type { PostgrestResponse, PostgrestSingleResponse, PostgrestMaybeSingleResponse, PostgrestError, } from '@supabase/postgrest-js';
|
|
6
6
|
export * from '@supabase/realtime-js';
|
|
7
|
+
export { default as SupabaseClient } from './SupabaseClient';
|
|
8
|
+
export type { SupabaseClientOptions } from './lib/types';
|
|
7
9
|
/**
|
|
8
10
|
* Creates a new Supabase Client.
|
|
9
11
|
*/
|
|
10
|
-
declare const createClient: (supabaseUrl: string, supabaseKey: string, options?: SupabaseClientOptions | undefined) => SupabaseClient
|
|
11
|
-
export { createClient, SupabaseClient, SupabaseClientOptions, SupabaseRealtimePayload, AuthUser, AuthSession, };
|
|
12
|
+
export declare const createClient: <Database = any, SchemaName extends string & keyof Database = "public" extends keyof Database ? "public" : string & keyof Database, Schema extends GenericSchema = Database[SchemaName] extends GenericSchema ? Database[SchemaName] : any>(supabaseUrl: string, supabaseKey: string, options?: SupabaseClientOptions<SchemaName> | undefined) => SupabaseClient<Database, SchemaName, Schema>;
|
|
12
13
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/main/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,cAAc,MAAM,kBAAkB,CAAA;AAC7C,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,cAAc,MAAM,kBAAkB,CAAA;AAC7C,OAAO,KAAK,EAAE,aAAa,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAA;AAEvE,cAAc,qBAAqB,CAAA;AACnC,YAAY,EAAE,IAAI,IAAI,QAAQ,EAAE,OAAO,IAAI,WAAW,EAAE,MAAM,qBAAqB,CAAA;AACnF,YAAY,EACV,iBAAiB,EACjB,uBAAuB,EACvB,4BAA4B,EAC5B,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,MAAM,aAAa,CAAA;AAExD;;GAEG;AACH,eAAO,MAAM,YAAY,2PASV,MAAM,eACN,MAAM,0GAIpB,CAAA"}
|
package/dist/main/index.js
CHANGED
|
@@ -17,11 +17,12 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
17
17
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
18
18
|
};
|
|
19
19
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
20
|
-
exports.
|
|
20
|
+
exports.createClient = exports.SupabaseClient = void 0;
|
|
21
21
|
const SupabaseClient_1 = __importDefault(require("./SupabaseClient"));
|
|
22
|
-
exports.SupabaseClient = SupabaseClient_1.default;
|
|
23
22
|
__exportStar(require("@supabase/gotrue-js"), exports);
|
|
24
23
|
__exportStar(require("@supabase/realtime-js"), exports);
|
|
24
|
+
var SupabaseClient_2 = require("./SupabaseClient");
|
|
25
|
+
Object.defineProperty(exports, "SupabaseClient", { enumerable: true, get: function () { return __importDefault(SupabaseClient_2).default; } });
|
|
25
26
|
/**
|
|
26
27
|
* Creates a new Supabase Client.
|
|
27
28
|
*/
|
package/dist/main/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA,sEAA6C;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA,sEAA6C;AAG7C,sDAAmC;AAQnC,wDAAqC;AACrC,mDAA4D;AAAnD,iIAAA,OAAO,OAAkB;AAGlC;;GAEG;AACI,MAAM,YAAY,GAAG,CAS1B,WAAmB,EACnB,WAAmB,EACnB,OAA2C,EACG,EAAE;IAChD,OAAO,IAAI,wBAAc,CAAC,WAAW,EAAE,WAAW,EAAE,OAAO,CAAC,CAAA;AAC9D,CAAC,CAAA;AAdY,QAAA,YAAY,gBAcxB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../../src/lib/constants.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,eAAe;;CAAgD,CAAA
|
|
1
|
+
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../../src/lib/constants.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,eAAe;;CAAgD,CAAA"}
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.DEFAULT_HEADERS = void 0;
|
|
4
4
|
// constants.ts
|
|
5
5
|
const version_1 = require("./version");
|
|
6
6
|
exports.DEFAULT_HEADERS = { 'X-Client-Info': `supabase-js/${version_1.version}` };
|
|
7
|
-
exports.STORAGE_KEY = 'supabase.auth.token';
|
|
8
7
|
//# sourceMappingURL=constants.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../../src/lib/constants.ts"],"names":[],"mappings":";;;AAAA,eAAe;AACf,uCAAmC;AACtB,QAAA,eAAe,GAAG,EAAE,eAAe,EAAE,eAAe,iBAAO,EAAE,EAAE,CAAA
|
|
1
|
+
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../../src/lib/constants.ts"],"names":[],"mappings":";;;AAAA,eAAe;AACf,uCAAmC;AACtB,QAAA,eAAe,GAAG,EAAE,eAAe,EAAE,eAAe,iBAAO,EAAE,EAAE,CAAA"}
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
+
import { SupabaseClientOptions } from './types';
|
|
1
2
|
export declare function uuid(): string;
|
|
2
3
|
export declare function stripTrailingSlash(url: string): string;
|
|
3
4
|
export declare const isBrowser: () => boolean;
|
|
5
|
+
export declare function applySettingDefaults<Database = any, SchemaName extends string & keyof Database = 'public' extends keyof Database ? 'public' : string & keyof Database>(options: SupabaseClientOptions<SchemaName>, defaults: SupabaseClientOptions<any>): SupabaseClientOptions<SchemaName>;
|
|
4
6
|
//# sourceMappingURL=helpers.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"helpers.d.ts","sourceRoot":"","sources":["../../../src/lib/helpers.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"helpers.d.ts","sourceRoot":"","sources":["../../../src/lib/helpers.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,qBAAqB,EAAE,MAAM,SAAS,CAAA;AAE/C,wBAAgB,IAAI,WAMnB;AAED,wBAAgB,kBAAkB,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAEtD;AAED,eAAO,MAAM,SAAS,eAAsC,CAAA;AAE5D,wBAAgB,oBAAoB,CAClC,QAAQ,GAAG,GAAG,EACd,UAAU,SAAS,MAAM,GAAG,MAAM,QAAQ,GAAG,QAAQ,SAAS,MAAM,QAAQ,GACxE,QAAQ,GACR,MAAM,GAAG,MAAM,QAAQ,EAE3B,OAAO,EAAE,qBAAqB,CAAC,UAAU,CAAC,EAC1C,QAAQ,EAAE,qBAAqB,CAAC,GAAG,CAAC,GACnC,qBAAqB,CAAC,UAAU,CAAC,CAgCnC"}
|