supabase_functions 0.9.3__tar.gz → 0.10.0__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_functions-0.9.3 → supabase_functions-0.10.0}/PKG-INFO +1 -1
- {supabase_functions-0.9.3 → supabase_functions-0.10.0}/pyproject.toml +5 -2
- {supabase_functions-0.9.3 → supabase_functions-0.10.0}/supabase_functions/__init__.py +7 -2
- {supabase_functions-0.9.3 → supabase_functions-0.10.0}/supabase_functions/_async/functions_client.py +47 -14
- {supabase_functions-0.9.3 → supabase_functions-0.10.0}/supabase_functions/_sync/functions_client.py +47 -14
- {supabase_functions-0.9.3 → supabase_functions-0.10.0}/supabase_functions/errors.py +4 -4
- {supabase_functions-0.9.3 → supabase_functions-0.10.0}/supabase_functions/utils.py +15 -0
- supabase_functions-0.10.0/supabase_functions/version.py +1 -0
- supabase_functions-0.9.3/supabase_functions/version.py +0 -1
- {supabase_functions-0.9.3 → supabase_functions-0.10.0}/LICENSE +0 -0
- {supabase_functions-0.9.3 → supabase_functions-0.10.0}/README.md +0 -0
- {supabase_functions-0.9.3 → supabase_functions-0.10.0}/supabase_functions/_async/__init__.py +0 -0
- {supabase_functions-0.9.3 → supabase_functions-0.10.0}/supabase_functions/_sync/__init__.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
[tool.poetry]
|
|
2
2
|
name = "supabase_functions"
|
|
3
|
-
version = "0.
|
|
3
|
+
version = "0.10.0" # {x-release-please-version}
|
|
4
4
|
description = "Library for Supabase Functions"
|
|
5
5
|
authors = [
|
|
6
6
|
"Joel Lee <joel@joellee.org>",
|
|
@@ -23,12 +23,15 @@ pyjwt = "^2.8.0"
|
|
|
23
23
|
pytest = ">=7.4.2,<9.0.0"
|
|
24
24
|
pytest-cov = ">=4,<7"
|
|
25
25
|
unasync-cli = "^0.0.9"
|
|
26
|
-
pytest-asyncio = ">=0.21.1,<
|
|
26
|
+
pytest-asyncio = ">=0.21.1,<1.1.0"
|
|
27
27
|
coveralls = "^3.3.0"
|
|
28
28
|
|
|
29
29
|
[tool.pytest.ini_options]
|
|
30
30
|
asyncio_mode = "auto"
|
|
31
31
|
addopts = "tests"
|
|
32
|
+
filterwarnings = [
|
|
33
|
+
"ignore::DeprecationWarning", # ignore deprecation warnings globally
|
|
34
|
+
]
|
|
32
35
|
|
|
33
36
|
[build-system]
|
|
34
37
|
requires = ["poetry-core>=1.0.0"]
|
|
@@ -1,12 +1,17 @@
|
|
|
1
1
|
from __future__ import annotations
|
|
2
2
|
|
|
3
|
-
from typing import Literal,
|
|
3
|
+
from typing import Literal, Union, overload
|
|
4
4
|
|
|
5
5
|
from ._async.functions_client import AsyncFunctionsClient
|
|
6
6
|
from ._sync.functions_client import SyncFunctionsClient
|
|
7
7
|
from .utils import FunctionRegion
|
|
8
8
|
|
|
9
|
-
__all__ = [
|
|
9
|
+
__all__ = [
|
|
10
|
+
"create_client",
|
|
11
|
+
"FunctionRegion",
|
|
12
|
+
"AsyncFunctionsClient",
|
|
13
|
+
"SyncFunctionsClient",
|
|
14
|
+
]
|
|
10
15
|
|
|
11
16
|
|
|
12
17
|
@overload
|
{supabase_functions-0.9.3 → supabase_functions-0.10.0}/supabase_functions/_async/functions_client.py
RENAMED
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
from typing import Any, Dict, Literal, Optional, Union
|
|
2
2
|
from warnings import warn
|
|
3
3
|
|
|
4
|
-
from httpx import HTTPError, Response
|
|
4
|
+
from httpx import AsyncClient, HTTPError, Response
|
|
5
5
|
|
|
6
6
|
from ..errors import FunctionsHttpError, FunctionsRelayError
|
|
7
7
|
from ..utils import (
|
|
8
|
-
AsyncClient,
|
|
9
8
|
FunctionRegion,
|
|
10
9
|
is_http_url,
|
|
11
10
|
is_valid_jwt,
|
|
@@ -19,9 +18,10 @@ class AsyncFunctionsClient:
|
|
|
19
18
|
self,
|
|
20
19
|
url: str,
|
|
21
20
|
headers: Dict,
|
|
22
|
-
timeout: int,
|
|
23
|
-
verify: bool =
|
|
21
|
+
timeout: Optional[int] = None,
|
|
22
|
+
verify: Optional[bool] = None,
|
|
24
23
|
proxy: Optional[str] = None,
|
|
24
|
+
http_client: Optional[AsyncClient] = None,
|
|
25
25
|
):
|
|
26
26
|
if not is_http_url(url):
|
|
27
27
|
raise ValueError("url must be a valid HTTP URL string")
|
|
@@ -30,15 +30,43 @@ class AsyncFunctionsClient:
|
|
|
30
30
|
"User-Agent": f"supabase-py/functions-py v{__version__}",
|
|
31
31
|
**headers,
|
|
32
32
|
}
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
33
|
+
|
|
34
|
+
if timeout is not None:
|
|
35
|
+
warn(
|
|
36
|
+
"The 'timeout' parameter is deprecated. Please configure it in the http client instead.",
|
|
37
|
+
DeprecationWarning,
|
|
38
|
+
stacklevel=2,
|
|
39
|
+
)
|
|
40
|
+
if verify is not None:
|
|
41
|
+
warn(
|
|
42
|
+
"The 'verify' parameter is deprecated. Please configure it in the http client instead.",
|
|
43
|
+
DeprecationWarning,
|
|
44
|
+
stacklevel=2,
|
|
45
|
+
)
|
|
46
|
+
if proxy is not None:
|
|
47
|
+
warn(
|
|
48
|
+
"The 'proxy' parameter is deprecated. Please configure it in the http client instead.",
|
|
49
|
+
DeprecationWarning,
|
|
50
|
+
stacklevel=2,
|
|
51
|
+
)
|
|
52
|
+
|
|
53
|
+
self.verify = bool(verify) if verify is not None else True
|
|
54
|
+
self.timeout = int(abs(timeout)) if timeout is not None else 60
|
|
55
|
+
|
|
56
|
+
if http_client is not None:
|
|
57
|
+
http_client.base_url = self.url
|
|
58
|
+
http_client.headers.update({**self.headers})
|
|
59
|
+
self._client = http_client
|
|
60
|
+
else:
|
|
61
|
+
self._client = AsyncClient(
|
|
62
|
+
base_url=self.url,
|
|
63
|
+
headers=self.headers,
|
|
64
|
+
verify=self.verify,
|
|
65
|
+
timeout=self.timeout,
|
|
66
|
+
proxy=proxy,
|
|
67
|
+
follow_redirects=True,
|
|
68
|
+
http2=True,
|
|
69
|
+
)
|
|
42
70
|
|
|
43
71
|
async def _request(
|
|
44
72
|
self,
|
|
@@ -54,9 +82,14 @@ class AsyncFunctionsClient:
|
|
|
54
82
|
try:
|
|
55
83
|
response.raise_for_status()
|
|
56
84
|
except HTTPError as exc:
|
|
85
|
+
status_code = None
|
|
86
|
+
if hasattr(response, "status_code"):
|
|
87
|
+
status_code = response.status_code
|
|
88
|
+
|
|
57
89
|
raise FunctionsHttpError(
|
|
58
90
|
response.json().get("error")
|
|
59
|
-
or f"An error occurred while requesting your edge function at {exc.request.url!r}."
|
|
91
|
+
or f"An error occurred while requesting your edge function at {exc.request.url!r}.",
|
|
92
|
+
status_code,
|
|
60
93
|
) from exc
|
|
61
94
|
|
|
62
95
|
return response
|
{supabase_functions-0.9.3 → supabase_functions-0.10.0}/supabase_functions/_sync/functions_client.py
RENAMED
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
from typing import Any, Dict, Literal, Optional, Union
|
|
2
2
|
from warnings import warn
|
|
3
3
|
|
|
4
|
-
from httpx import HTTPError, Response
|
|
4
|
+
from httpx import Client, HTTPError, Response
|
|
5
5
|
|
|
6
6
|
from ..errors import FunctionsHttpError, FunctionsRelayError
|
|
7
7
|
from ..utils import (
|
|
8
8
|
FunctionRegion,
|
|
9
|
-
SyncClient,
|
|
10
9
|
is_http_url,
|
|
11
10
|
is_valid_jwt,
|
|
12
11
|
is_valid_str_arg,
|
|
@@ -19,9 +18,10 @@ class SyncFunctionsClient:
|
|
|
19
18
|
self,
|
|
20
19
|
url: str,
|
|
21
20
|
headers: Dict,
|
|
22
|
-
timeout: int,
|
|
23
|
-
verify: bool =
|
|
21
|
+
timeout: Optional[int] = None,
|
|
22
|
+
verify: Optional[bool] = None,
|
|
24
23
|
proxy: Optional[str] = None,
|
|
24
|
+
http_client: Optional[Client] = None,
|
|
25
25
|
):
|
|
26
26
|
if not is_http_url(url):
|
|
27
27
|
raise ValueError("url must be a valid HTTP URL string")
|
|
@@ -30,15 +30,43 @@ class SyncFunctionsClient:
|
|
|
30
30
|
"User-Agent": f"supabase-py/functions-py v{__version__}",
|
|
31
31
|
**headers,
|
|
32
32
|
}
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
33
|
+
|
|
34
|
+
if timeout is not None:
|
|
35
|
+
warn(
|
|
36
|
+
"The 'timeout' parameter is deprecated. Please configure it in the http client instead.",
|
|
37
|
+
DeprecationWarning,
|
|
38
|
+
stacklevel=2,
|
|
39
|
+
)
|
|
40
|
+
if verify is not None:
|
|
41
|
+
warn(
|
|
42
|
+
"The 'verify' parameter is deprecated. Please configure it in the http client instead.",
|
|
43
|
+
DeprecationWarning,
|
|
44
|
+
stacklevel=2,
|
|
45
|
+
)
|
|
46
|
+
if proxy is not None:
|
|
47
|
+
warn(
|
|
48
|
+
"The 'proxy' parameter is deprecated. Please configure it in the http client instead.",
|
|
49
|
+
DeprecationWarning,
|
|
50
|
+
stacklevel=2,
|
|
51
|
+
)
|
|
52
|
+
|
|
53
|
+
self.verify = bool(verify) if verify is not None else True
|
|
54
|
+
self.timeout = int(abs(timeout)) if timeout is not None else 60
|
|
55
|
+
|
|
56
|
+
if http_client is not None:
|
|
57
|
+
http_client.base_url = self.url
|
|
58
|
+
http_client.headers.update({**self.headers})
|
|
59
|
+
self._client = http_client
|
|
60
|
+
else:
|
|
61
|
+
self._client = Client(
|
|
62
|
+
base_url=self.url,
|
|
63
|
+
headers=self.headers,
|
|
64
|
+
verify=self.verify,
|
|
65
|
+
timeout=self.timeout,
|
|
66
|
+
proxy=proxy,
|
|
67
|
+
follow_redirects=True,
|
|
68
|
+
http2=True,
|
|
69
|
+
)
|
|
42
70
|
|
|
43
71
|
def _request(
|
|
44
72
|
self,
|
|
@@ -54,9 +82,14 @@ class SyncFunctionsClient:
|
|
|
54
82
|
try:
|
|
55
83
|
response.raise_for_status()
|
|
56
84
|
except HTTPError as exc:
|
|
85
|
+
status_code = None
|
|
86
|
+
if hasattr(response, "status_code"):
|
|
87
|
+
status_code = response.status_code
|
|
88
|
+
|
|
57
89
|
raise FunctionsHttpError(
|
|
58
90
|
response.json().get("error")
|
|
59
|
-
or f"An error occurred while requesting your edge function at {exc.request.url!r}."
|
|
91
|
+
or f"An error occurred while requesting your edge function at {exc.request.url!r}.",
|
|
92
|
+
status_code,
|
|
60
93
|
) from exc
|
|
61
94
|
|
|
62
95
|
return response
|
|
@@ -25,20 +25,20 @@ class FunctionsError(Exception):
|
|
|
25
25
|
|
|
26
26
|
|
|
27
27
|
class FunctionsHttpError(FunctionsError):
|
|
28
|
-
def __init__(self, message: str) -> None:
|
|
28
|
+
def __init__(self, message: str, code: int | None = None) -> None:
|
|
29
29
|
super().__init__(
|
|
30
30
|
message,
|
|
31
31
|
"FunctionsHttpError",
|
|
32
|
-
400,
|
|
32
|
+
400 if code is None else code,
|
|
33
33
|
)
|
|
34
34
|
|
|
35
35
|
|
|
36
36
|
class FunctionsRelayError(FunctionsError):
|
|
37
37
|
"""Base exception for relay errors."""
|
|
38
38
|
|
|
39
|
-
def __init__(self, message: str) -> None:
|
|
39
|
+
def __init__(self, message: str, code: int | None = None) -> None:
|
|
40
40
|
super().__init__(
|
|
41
41
|
message,
|
|
42
42
|
"FunctionsRelayError",
|
|
43
|
-
400,
|
|
43
|
+
400 if code is None else code,
|
|
44
44
|
)
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import re
|
|
2
2
|
import sys
|
|
3
3
|
from urllib.parse import urlparse
|
|
4
|
+
from warnings import warn
|
|
4
5
|
|
|
5
6
|
from httpx import AsyncClient as AsyncClient # noqa: F401
|
|
6
7
|
from httpx import Client as BaseClient
|
|
@@ -34,7 +35,21 @@ class FunctionRegion(StrEnum):
|
|
|
34
35
|
|
|
35
36
|
|
|
36
37
|
class SyncClient(BaseClient):
|
|
38
|
+
def __init__(self, *args, **kwargs):
|
|
39
|
+
warn(
|
|
40
|
+
"The 'SyncClient' class is deprecated. Please use `Client` from the httpx package instead.",
|
|
41
|
+
DeprecationWarning,
|
|
42
|
+
stacklevel=2,
|
|
43
|
+
)
|
|
44
|
+
|
|
45
|
+
super().__init__(*args, **kwargs)
|
|
46
|
+
|
|
37
47
|
def aclose(self) -> None:
|
|
48
|
+
warn(
|
|
49
|
+
"The 'aclose' method is deprecated. Please use `close` method from `Client` in the httpx package instead.",
|
|
50
|
+
DeprecationWarning,
|
|
51
|
+
stacklevel=2,
|
|
52
|
+
)
|
|
38
53
|
self.close()
|
|
39
54
|
|
|
40
55
|
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
__version__ = "0.10.0" # {x-release-please-version}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
__version__ = "0.9.3" # {x-release-please-version}
|
|
File without changes
|
|
File without changes
|
{supabase_functions-0.9.3 → supabase_functions-0.10.0}/supabase_functions/_async/__init__.py
RENAMED
|
File without changes
|
|
File without changes
|