supabase 2.28.2__tar.gz → 3.0.0a1__tar.gz
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.
- {supabase-2.28.2 → supabase-3.0.0a1}/PKG-INFO +13 -8
- {supabase-2.28.2 → supabase-3.0.0a1}/pyproject.toml +14 -8
- {supabase-2.28.2 → supabase-3.0.0a1}/src/supabase/__init__.py +2 -11
- {supabase-2.28.2 → supabase-3.0.0a1}/src/supabase/_async/client.py +79 -106
- {supabase-2.28.2 → supabase-3.0.0a1}/src/supabase/_sync/client.py +77 -162
- supabase-3.0.0a1/src/supabase/aiohttp.py +20 -0
- {supabase-2.28.2 → supabase-3.0.0a1}/src/supabase/client.py +1 -12
- supabase-3.0.0a1/src/supabase/httpx.py +43 -0
- supabase-3.0.0a1/src/supabase/lib/__init__.py +1 -0
- supabase-3.0.0a1/src/supabase/lib/client_options.py +98 -0
- supabase-3.0.0a1/src/supabase/version.py +1 -0
- supabase-2.28.2/src/supabase/_async/auth_client.py +0 -57
- supabase-2.28.2/src/supabase/_sync/auth_client.py +0 -57
- supabase-2.28.2/src/supabase/lib/__init__.py +0 -3
- supabase-2.28.2/src/supabase/lib/client_options.py +0 -144
- supabase-2.28.2/src/supabase/version.py +0 -1
- {supabase-2.28.2 → supabase-3.0.0a1}/LICENSE +0 -0
- {supabase-2.28.2 → supabase-3.0.0a1}/README.md +0 -0
- {supabase-2.28.2 → supabase-3.0.0a1}/src/supabase/_async/__init__.py +0 -0
- {supabase-2.28.2 → supabase-3.0.0a1}/src/supabase/_sync/__init__.py +0 -0
- {supabase-2.28.2 → supabase-3.0.0a1}/src/supabase/py.typed +0 -0
- {supabase-2.28.2 → supabase-3.0.0a1}/src/supabase/types.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: supabase
|
|
3
|
-
Version:
|
|
3
|
+
Version: 3.0.0a1
|
|
4
4
|
Summary: Supabase client for Python.
|
|
5
5
|
Author: Joel Lee, Leon Fedden, Daniel Reinón García, Leynier Gutiérrez González, Anand, Andrew Smith
|
|
6
6
|
Author-email: Joel Lee <joel@joellee.org>, Leon Fedden <leonfedden@gmail.com>, Daniel Reinón García <danielreinon@outlook.com>, Leynier Gutiérrez González <leynier41@gmail.com>, Andrew Smith <a.smith@silentworks.co.uk>
|
|
@@ -8,20 +8,25 @@ License-Expression: MIT
|
|
|
8
8
|
License-File: LICENSE
|
|
9
9
|
Classifier: Programming Language :: Python :: 3
|
|
10
10
|
Classifier: Operating System :: OS Independent
|
|
11
|
-
Requires-Dist: realtime==
|
|
12
|
-
Requires-Dist: supabase-functions==
|
|
13
|
-
Requires-Dist: storage3==
|
|
14
|
-
Requires-Dist: supabase-auth==
|
|
15
|
-
Requires-Dist:
|
|
16
|
-
Requires-Dist:
|
|
11
|
+
Requires-Dist: realtime==3.0.0a1
|
|
12
|
+
Requires-Dist: supabase-functions==3.0.0a1
|
|
13
|
+
Requires-Dist: storage3==3.0.0a1
|
|
14
|
+
Requires-Dist: supabase-auth==3.0.0a1
|
|
15
|
+
Requires-Dist: supabase-utils==3.0.0a1
|
|
16
|
+
Requires-Dist: postgrest==3.0.0a1
|
|
17
|
+
Requires-Dist: supabase-utils==3.0.0a1
|
|
17
18
|
Requires-Dist: yarl>=1.22.0
|
|
19
|
+
Requires-Dist: supabase-utils[aiohttp] ; extra == 'aiohttp'
|
|
20
|
+
Requires-Dist: supabase-utils[httpx] ; extra == 'httpx'
|
|
18
21
|
Maintainer: Leonardo Santiago
|
|
19
22
|
Maintainer-email: Leonardo Santiago <leonardo.santiago@supabase.io>
|
|
20
|
-
Requires-Python: >=3.
|
|
23
|
+
Requires-Python: >=3.10
|
|
21
24
|
Project-URL: changelog, https://github.com/supabase/supabase-py/tree/main/CHANGELOG.md
|
|
22
25
|
Project-URL: documentation, https://github.com/supabase/supabase-py/src/supabase
|
|
23
26
|
Project-URL: homepage, https://github.com/supabase/supabase-py
|
|
24
27
|
Project-URL: repository, https://github.com/supabase/supabase-py
|
|
28
|
+
Provides-Extra: aiohttp
|
|
29
|
+
Provides-Extra: httpx
|
|
25
30
|
Description-Content-Type: text/markdown
|
|
26
31
|
|
|
27
32
|
# `supabase-py`
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
[project]
|
|
2
2
|
name = "supabase"
|
|
3
|
-
version = "
|
|
3
|
+
version = "3.0.0a1" # {x-release-please-version}
|
|
4
4
|
description = "Supabase client for Python."
|
|
5
5
|
authors = [
|
|
6
6
|
{ name = "Joel Lee", email = "joel@joellee.org" },
|
|
@@ -20,14 +20,15 @@ classifiers = [
|
|
|
20
20
|
"Programming Language :: Python :: 3",
|
|
21
21
|
"Operating System :: OS Independent"
|
|
22
22
|
]
|
|
23
|
-
requires-python = ">=3.
|
|
23
|
+
requires-python = ">=3.10"
|
|
24
24
|
dependencies = [
|
|
25
|
-
"realtime ==
|
|
26
|
-
"supabase_functions ==
|
|
27
|
-
"storage3 ==
|
|
28
|
-
"supabase_auth ==
|
|
29
|
-
"
|
|
30
|
-
"
|
|
25
|
+
"realtime == 3.0.0a1", # x-release-please-version
|
|
26
|
+
"supabase_functions == 3.0.0a1", # x-release-please-version
|
|
27
|
+
"storage3 == 3.0.0a1", # x-release-please-version
|
|
28
|
+
"supabase_auth == 3.0.0a1", # x-release-please-version
|
|
29
|
+
"supabase_utils == 3.0.0a1", # x-release-please-version
|
|
30
|
+
"postgrest == 3.0.0a1", # x-release-please-version
|
|
31
|
+
"supabase_utils==3.0.0a1", # x-release-please-version
|
|
31
32
|
"yarl>=1.22.0",
|
|
32
33
|
]
|
|
33
34
|
|
|
@@ -37,6 +38,10 @@ repository = "https://github.com/supabase/supabase-py"
|
|
|
37
38
|
documentation = "https://github.com/supabase/supabase-py/src/supabase"
|
|
38
39
|
changelog = "https://github.com/supabase/supabase-py/tree/main/CHANGELOG.md"
|
|
39
40
|
|
|
41
|
+
[project.optional-dependencies]
|
|
42
|
+
httpx = ["supabase_utils[httpx]"]
|
|
43
|
+
aiohttp = ["supabase_utils[aiohttp]"]
|
|
44
|
+
|
|
40
45
|
[dependency-groups]
|
|
41
46
|
dev = [
|
|
42
47
|
{ include-group = "tests" },
|
|
@@ -48,6 +53,7 @@ tests = [
|
|
|
48
53
|
"pytest-asyncio >=0.24,<1.1",
|
|
49
54
|
"python-dotenv >= 1.1.1",
|
|
50
55
|
"mypy>=1.18.2",
|
|
56
|
+
"supabase_utils[all]",
|
|
51
57
|
]
|
|
52
58
|
lints = [
|
|
53
59
|
"unasync >=0.6.0",
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
from postgrest import APIError as PostgrestAPIError
|
|
2
2
|
from postgrest import APIResponse as PostgrestAPIResponse
|
|
3
3
|
from realtime import AuthorizationError, NotConnectedError
|
|
4
|
-
from storage3.
|
|
4
|
+
from storage3.exceptions import StorageException
|
|
5
5
|
from supabase_auth.errors import (
|
|
6
6
|
AuthApiError,
|
|
7
7
|
AuthError,
|
|
@@ -19,18 +19,12 @@ from supabase_functions.errors import (
|
|
|
19
19
|
)
|
|
20
20
|
|
|
21
21
|
# Async Client
|
|
22
|
-
from ._async.auth_client import AsyncSupabaseAuthClient as ASupabaseAuthClient
|
|
23
22
|
from ._async.client import AsyncClient
|
|
24
23
|
from ._async.client import AsyncClient as AClient
|
|
25
24
|
from ._async.client import AsyncStorageClient as ASupabaseStorageClient
|
|
26
25
|
from ._async.client import SupabaseException as ASupabaseException
|
|
27
26
|
from ._async.client import SupabaseException as AsyncSupabaseException
|
|
28
|
-
from .
|
|
29
|
-
from ._async.client import create_client as create_async_client
|
|
30
|
-
|
|
31
|
-
# Sync Client
|
|
32
|
-
from ._sync.auth_client import SyncSupabaseAuthClient as SupabaseAuthClient
|
|
33
|
-
from ._sync.client import Client, SupabaseException, create_client
|
|
27
|
+
from ._sync.client import Client
|
|
34
28
|
from ._sync.client import SupabaseException as SyncSupabaseException
|
|
35
29
|
from ._sync.client import SyncStorageClient as SupabaseStorageClient
|
|
36
30
|
|
|
@@ -43,15 +37,12 @@ from .lib.client_options import SyncClientOptions as ClientOptions
|
|
|
43
37
|
from .version import __version__
|
|
44
38
|
|
|
45
39
|
__all__ = (
|
|
46
|
-
"acreate_client",
|
|
47
|
-
"create_async_client",
|
|
48
40
|
"AClient",
|
|
49
41
|
"ASupabaseAuthClient",
|
|
50
42
|
"ASupabaseStorageClient",
|
|
51
43
|
"AClientOptions",
|
|
52
44
|
"AsyncClient",
|
|
53
45
|
"AsyncClientOptions",
|
|
54
|
-
"create_client",
|
|
55
46
|
"Client",
|
|
56
47
|
"SupabaseAuthClient",
|
|
57
48
|
"SupabaseStorageClient",
|
|
@@ -1,28 +1,26 @@
|
|
|
1
1
|
import asyncio
|
|
2
2
|
import copy
|
|
3
3
|
import re
|
|
4
|
-
from
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
from postgrest import
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
4
|
+
from types import TracebackType
|
|
5
|
+
from typing import Dict, List, Literal, overload
|
|
6
|
+
|
|
7
|
+
from postgrest import AsyncPostgrestClient
|
|
8
|
+
from postgrest.request_builder import (
|
|
9
|
+
RequestBuilder,
|
|
10
|
+
RPCCountRequestBuilder,
|
|
11
|
+
RPCFilterRequestBuilder,
|
|
11
12
|
)
|
|
12
|
-
from postgrest.constants import DEFAULT_POSTGREST_CLIENT_TIMEOUT
|
|
13
13
|
from postgrest.types import CountMethod
|
|
14
14
|
from realtime import AsyncRealtimeChannel, AsyncRealtimeClient, RealtimeChannelOptions
|
|
15
15
|
from storage3 import AsyncStorageClient
|
|
16
|
-
from
|
|
17
|
-
from supabase_auth import AsyncMemoryStorage
|
|
16
|
+
from supabase_auth import AsyncMemoryStorage, AsyncSupabaseAuthClient
|
|
18
17
|
from supabase_auth.types import AuthChangeEvent, Session
|
|
19
18
|
from supabase_functions import AsyncFunctionsClient
|
|
19
|
+
from supabase_utils.http.io import AsyncHttpIO, AsyncHttpSession
|
|
20
20
|
from yarl import URL
|
|
21
21
|
|
|
22
22
|
from ..lib.client_options import AsyncClientOptions as ClientOptions
|
|
23
|
-
from ..lib.client_options import AsyncHttpxClient
|
|
24
23
|
from ..types import RealtimeClientOptions
|
|
25
|
-
from .auth_client import AsyncSupabaseAuthClient
|
|
26
24
|
|
|
27
25
|
|
|
28
26
|
# Create an exception class when user does not provide a valid url or key.
|
|
@@ -39,7 +37,8 @@ class AsyncClient:
|
|
|
39
37
|
self,
|
|
40
38
|
supabase_url: str,
|
|
41
39
|
supabase_key: str,
|
|
42
|
-
|
|
40
|
+
http_session: AsyncHttpSession,
|
|
41
|
+
options: ClientOptions | None = None,
|
|
43
42
|
) -> None:
|
|
44
43
|
"""Instantiate the client.
|
|
45
44
|
|
|
@@ -66,6 +65,8 @@ class AsyncClient:
|
|
|
66
65
|
if options is None:
|
|
67
66
|
options = ClientOptions(storage=AsyncMemoryStorage())
|
|
68
67
|
|
|
68
|
+
self.http_session: AsyncHttpSession = http_session
|
|
69
|
+
|
|
69
70
|
self.supabase_url = (
|
|
70
71
|
URL(supabase_url) if supabase_url.endswith("/") else URL(supabase_url + "/")
|
|
71
72
|
)
|
|
@@ -88,26 +89,39 @@ class AsyncClient:
|
|
|
88
89
|
self.auth = self._init_supabase_auth_client(
|
|
89
90
|
auth_url=str(self.auth_url),
|
|
90
91
|
client_options=self.options,
|
|
92
|
+
http_session=self.http_session,
|
|
91
93
|
)
|
|
92
94
|
self.realtime = self._init_realtime_client(
|
|
93
95
|
realtime_url=self.realtime_url,
|
|
94
96
|
supabase_key=self.supabase_key,
|
|
95
97
|
options=self.options.realtime if self.options else None,
|
|
96
98
|
)
|
|
97
|
-
self._postgrest:
|
|
98
|
-
self._storage:
|
|
99
|
-
self._functions:
|
|
99
|
+
self._postgrest: AsyncPostgrestClient | None = None
|
|
100
|
+
self._storage: AsyncStorageClient | None = None
|
|
101
|
+
self._functions: AsyncFunctionsClient | None = None
|
|
100
102
|
self.auth.on_auth_state_change(self._listen_to_auth_events)
|
|
101
103
|
|
|
104
|
+
async def __aenter__(self) -> "AsyncClient":
|
|
105
|
+
return self
|
|
106
|
+
|
|
107
|
+
async def __aexit__(
|
|
108
|
+
self,
|
|
109
|
+
exc_type: type[Exception] | None,
|
|
110
|
+
exc: Exception | None,
|
|
111
|
+
tb: TracebackType | None,
|
|
112
|
+
) -> None:
|
|
113
|
+
await self.http_session.__aexit__(exc_type, exc, tb)
|
|
114
|
+
|
|
102
115
|
@classmethod
|
|
103
116
|
async def create(
|
|
104
117
|
cls,
|
|
105
118
|
supabase_url: str,
|
|
106
119
|
supabase_key: str,
|
|
107
|
-
|
|
120
|
+
http_session: AsyncHttpSession,
|
|
121
|
+
options: ClientOptions | None = None,
|
|
108
122
|
) -> "AsyncClient":
|
|
109
123
|
auth_header = options.headers.get("Authorization") if options else None
|
|
110
|
-
client = cls(supabase_url, supabase_key, options)
|
|
124
|
+
client = cls(supabase_url, supabase_key, http_session, options)
|
|
111
125
|
|
|
112
126
|
if auth_header is None:
|
|
113
127
|
try:
|
|
@@ -126,7 +140,7 @@ class AsyncClient:
|
|
|
126
140
|
|
|
127
141
|
return client
|
|
128
142
|
|
|
129
|
-
def table(self, table_name: str) ->
|
|
143
|
+
def table(self, table_name: str) -> RequestBuilder[AsyncHttpIO]:
|
|
130
144
|
"""Perform a table operation.
|
|
131
145
|
|
|
132
146
|
Note that the supabase client uses the `from` method, but in Python,
|
|
@@ -142,21 +156,47 @@ class AsyncClient:
|
|
|
142
156
|
"""
|
|
143
157
|
return self.postgrest.schema(schema)
|
|
144
158
|
|
|
145
|
-
def from_(self, table_name: str) ->
|
|
159
|
+
def from_(self, table_name: str) -> RequestBuilder[AsyncHttpIO]:
|
|
146
160
|
"""Perform a table operation.
|
|
147
161
|
|
|
148
162
|
See the `table` method.
|
|
149
163
|
"""
|
|
150
164
|
return self.postgrest.from_(table_name)
|
|
151
165
|
|
|
166
|
+
@overload
|
|
167
|
+
def rpc(
|
|
168
|
+
self,
|
|
169
|
+
fn: str,
|
|
170
|
+
head: Literal[False],
|
|
171
|
+
params: Dict[str, str] | None = None,
|
|
172
|
+
count: CountMethod | None = None,
|
|
173
|
+
get: bool = False,
|
|
174
|
+
) -> RPCFilterRequestBuilder[AsyncHttpIO]: ...
|
|
175
|
+
|
|
176
|
+
@overload
|
|
177
|
+
def rpc(
|
|
178
|
+
self,
|
|
179
|
+
fn: str,
|
|
180
|
+
head: Literal[True],
|
|
181
|
+
params: Dict[str, str] | None = None,
|
|
182
|
+
count: CountMethod | None = None,
|
|
183
|
+
get: bool = False,
|
|
184
|
+
) -> RPCCountRequestBuilder[AsyncHttpIO]: ...
|
|
185
|
+
|
|
186
|
+
@overload
|
|
187
|
+
def rpc(
|
|
188
|
+
self,
|
|
189
|
+
fn: str,
|
|
190
|
+
) -> RPCFilterRequestBuilder[AsyncHttpIO]: ...
|
|
191
|
+
|
|
152
192
|
def rpc(
|
|
153
193
|
self,
|
|
154
194
|
fn: str,
|
|
155
|
-
params: Optional[Dict[Any, Any]] = None,
|
|
156
|
-
count: Optional[CountMethod] = None,
|
|
157
195
|
head: bool = False,
|
|
196
|
+
params: Dict[str, str] | None = None,
|
|
197
|
+
count: CountMethod | None = None,
|
|
158
198
|
get: bool = False,
|
|
159
|
-
) ->
|
|
199
|
+
) -> RPCFilterRequestBuilder[AsyncHttpIO] | RPCCountRequestBuilder[AsyncHttpIO]:
|
|
160
200
|
"""Performs a stored procedure call.
|
|
161
201
|
|
|
162
202
|
Parameters
|
|
@@ -177,7 +217,7 @@ class AsyncClient:
|
|
|
177
217
|
"""
|
|
178
218
|
if params is None:
|
|
179
219
|
params = {}
|
|
180
|
-
return self.postgrest.rpc(fn, params, count, head, get)
|
|
220
|
+
return self.postgrest.rpc(fn, params, count=count, head=head, get=get)
|
|
181
221
|
|
|
182
222
|
@property
|
|
183
223
|
def postgrest(self) -> AsyncPostgrestClient:
|
|
@@ -186,8 +226,7 @@ class AsyncClient:
|
|
|
186
226
|
rest_url=str(self.rest_url),
|
|
187
227
|
headers=self.options.headers,
|
|
188
228
|
schema=self.options.schema,
|
|
189
|
-
|
|
190
|
-
http_client=self.options.httpx_client,
|
|
229
|
+
http_session=self.http_session,
|
|
191
230
|
)
|
|
192
231
|
|
|
193
232
|
return self._postgrest
|
|
@@ -198,8 +237,7 @@ class AsyncClient:
|
|
|
198
237
|
self._storage = self._init_storage_client(
|
|
199
238
|
storage_url=str(self.storage_url),
|
|
200
239
|
headers=self.options.headers,
|
|
201
|
-
|
|
202
|
-
http_client=self.options.httpx_client,
|
|
240
|
+
http_session=self.http_session,
|
|
203
241
|
)
|
|
204
242
|
return self._storage
|
|
205
243
|
|
|
@@ -209,17 +247,11 @@ class AsyncClient:
|
|
|
209
247
|
self._functions = AsyncFunctionsClient(
|
|
210
248
|
url=str(self.functions_url),
|
|
211
249
|
headers=self.options.headers,
|
|
212
|
-
timeout=(
|
|
213
|
-
self.options.function_client_timeout
|
|
214
|
-
if self.options.httpx_client is None
|
|
215
|
-
else None
|
|
216
|
-
),
|
|
217
|
-
http_client=self.options.httpx_client,
|
|
218
250
|
)
|
|
219
251
|
return self._functions
|
|
220
252
|
|
|
221
253
|
def channel(
|
|
222
|
-
self, topic: str, params:
|
|
254
|
+
self, topic: str, params: RealtimeChannelOptions | None = None
|
|
223
255
|
) -> AsyncRealtimeChannel:
|
|
224
256
|
"""Creates a Realtime channel with Broadcast, Presence, and Postgres Changes."""
|
|
225
257
|
return self.realtime.channel(topic, params or {})
|
|
@@ -240,7 +272,7 @@ class AsyncClient:
|
|
|
240
272
|
def _init_realtime_client(
|
|
241
273
|
realtime_url: URL,
|
|
242
274
|
supabase_key: str,
|
|
243
|
-
options:
|
|
275
|
+
options: RealtimeClientOptions | None = None,
|
|
244
276
|
) -> AsyncRealtimeClient:
|
|
245
277
|
realtime_options = options or {}
|
|
246
278
|
"""Private method for creating an instance of the realtime-py client."""
|
|
@@ -252,31 +284,19 @@ class AsyncClient:
|
|
|
252
284
|
def _init_storage_client(
|
|
253
285
|
storage_url: str,
|
|
254
286
|
headers: Dict[str, str],
|
|
255
|
-
|
|
256
|
-
verify: bool = True,
|
|
257
|
-
proxy: Optional[str] = None,
|
|
258
|
-
http_client: Union[AsyncHttpxClient, None] = None,
|
|
287
|
+
http_session: AsyncHttpSession,
|
|
259
288
|
) -> AsyncStorageClient:
|
|
260
|
-
if http_client is not None:
|
|
261
|
-
# If an http client is provided, use it
|
|
262
|
-
return AsyncStorageClient(
|
|
263
|
-
url=storage_url, headers=headers, http_client=http_client
|
|
264
|
-
)
|
|
265
289
|
return AsyncStorageClient(
|
|
266
290
|
url=storage_url,
|
|
267
291
|
headers=headers,
|
|
268
|
-
|
|
269
|
-
verify=verify,
|
|
270
|
-
proxy=proxy,
|
|
271
|
-
http_client=None,
|
|
292
|
+
http_session=http_session,
|
|
272
293
|
)
|
|
273
294
|
|
|
274
295
|
@staticmethod
|
|
275
296
|
def _init_supabase_auth_client(
|
|
276
297
|
auth_url: str,
|
|
277
298
|
client_options: ClientOptions,
|
|
278
|
-
|
|
279
|
-
proxy: Optional[str] = None,
|
|
299
|
+
http_session: AsyncHttpSession,
|
|
280
300
|
) -> AsyncSupabaseAuthClient:
|
|
281
301
|
"""Creates a wrapped instance of the GoTrue Client."""
|
|
282
302
|
return AsyncSupabaseAuthClient(
|
|
@@ -286,9 +306,7 @@ class AsyncClient:
|
|
|
286
306
|
storage=client_options.storage,
|
|
287
307
|
headers=client_options.headers,
|
|
288
308
|
flow_type=client_options.flow_type,
|
|
289
|
-
|
|
290
|
-
proxy=proxy,
|
|
291
|
-
http_client=client_options.httpx_client,
|
|
309
|
+
http_session=http_session,
|
|
292
310
|
)
|
|
293
311
|
|
|
294
312
|
@staticmethod
|
|
@@ -296,31 +314,20 @@ class AsyncClient:
|
|
|
296
314
|
rest_url: str,
|
|
297
315
|
headers: Dict[str, str],
|
|
298
316
|
schema: str,
|
|
299
|
-
|
|
300
|
-
verify: bool = True,
|
|
301
|
-
proxy: Optional[str] = None,
|
|
302
|
-
http_client: Union[AsyncHttpxClient, None] = None,
|
|
317
|
+
http_session: AsyncHttpSession,
|
|
303
318
|
) -> AsyncPostgrestClient:
|
|
304
319
|
"""Private helper for creating an instance of the Postgrest client."""
|
|
305
|
-
if http_client is not None:
|
|
306
|
-
# If an http client is provided, use it
|
|
307
|
-
return AsyncPostgrestClient(
|
|
308
|
-
rest_url, headers=headers, schema=schema, http_client=http_client
|
|
309
|
-
)
|
|
310
320
|
return AsyncPostgrestClient(
|
|
311
321
|
rest_url,
|
|
312
322
|
headers=headers,
|
|
313
323
|
schema=schema,
|
|
314
|
-
|
|
315
|
-
verify=verify,
|
|
316
|
-
proxy=proxy,
|
|
317
|
-
http_client=None,
|
|
324
|
+
http_session=http_session,
|
|
318
325
|
)
|
|
319
326
|
|
|
320
327
|
def _create_auth_header(self, token: str) -> str:
|
|
321
328
|
return f"Bearer {token}"
|
|
322
329
|
|
|
323
|
-
def _get_auth_headers(self, authorization:
|
|
330
|
+
def _get_auth_headers(self, authorization: str | None = None) -> Dict[str, str]:
|
|
324
331
|
if authorization is None:
|
|
325
332
|
authorization = self.options.headers.get(
|
|
326
333
|
"Authorization", self._create_auth_header(self.supabase_key)
|
|
@@ -333,7 +340,7 @@ class AsyncClient:
|
|
|
333
340
|
}
|
|
334
341
|
|
|
335
342
|
def _listen_to_auth_events(
|
|
336
|
-
self, event: AuthChangeEvent, session:
|
|
343
|
+
self, event: AuthChangeEvent, session: Session | None
|
|
337
344
|
) -> None:
|
|
338
345
|
access_token = self.supabase_key
|
|
339
346
|
if event in ["SIGNED_IN", "TOKEN_REFRESHED", "SIGNED_OUT"]:
|
|
@@ -344,41 +351,7 @@ class AsyncClient:
|
|
|
344
351
|
access_token = session.access_token if session else self.supabase_key
|
|
345
352
|
auth_header = self._create_auth_header(access_token)
|
|
346
353
|
self.options.headers["Authorization"] = auth_header
|
|
347
|
-
self.auth.
|
|
354
|
+
self.auth.default_headers = self.auth.default_headers.override(
|
|
355
|
+
"Authorization", auth_header
|
|
356
|
+
)
|
|
348
357
|
asyncio.create_task(self.realtime.set_auth(access_token))
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
async def create_client(
|
|
352
|
-
supabase_url: str,
|
|
353
|
-
supabase_key: str,
|
|
354
|
-
options: Optional[ClientOptions] = None,
|
|
355
|
-
) -> AsyncClient:
|
|
356
|
-
"""Create client function to instantiate supabase client like JS runtime.
|
|
357
|
-
|
|
358
|
-
Parameters
|
|
359
|
-
----------
|
|
360
|
-
supabase_url: str
|
|
361
|
-
The URL to the Supabase instance that should be connected to.
|
|
362
|
-
supabase_key: str
|
|
363
|
-
The API key to the Supabase instance that should be connected to.
|
|
364
|
-
**options
|
|
365
|
-
Any extra settings to be optionally specified - also see the
|
|
366
|
-
`DEFAULT_OPTIONS` dict.
|
|
367
|
-
|
|
368
|
-
Examples
|
|
369
|
-
--------
|
|
370
|
-
Instantiating the client.
|
|
371
|
-
>>> import os
|
|
372
|
-
>>> from supabase import create_client, Client
|
|
373
|
-
>>>
|
|
374
|
-
>>> url: str = os.environ.get("SUPABASE_TEST_URL")
|
|
375
|
-
>>> key: str = os.environ.get("SUPABASE_TEST_KEY")
|
|
376
|
-
>>> supabase: Client = create_client(url, key)
|
|
377
|
-
|
|
378
|
-
Returns
|
|
379
|
-
-------
|
|
380
|
-
Client
|
|
381
|
-
"""
|
|
382
|
-
return await AsyncClient.create(
|
|
383
|
-
supabase_url=supabase_url, supabase_key=supabase_key, options=options
|
|
384
|
-
)
|