supabase_functions 0.4.7__tar.gz → 0.5.1__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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: supabase_functions
3
- Version: 0.4.7
3
+ Version: 0.5.1
4
4
  Summary: Library for Supabase Functions
5
5
  Home-page: https://github.com/supabase-community/functions-py
6
6
  License: MIT
@@ -1,6 +1,6 @@
1
1
  [tool.poetry]
2
2
  name = "supabase_functions"
3
- version = "0.4.7"
3
+ version = "0.5.1"
4
4
  description = "Library for Supabase Functions"
5
5
  authors = [
6
6
  "Joel Lee <joel@joellee.org>",
@@ -7,7 +7,7 @@ from ..utils import AsyncClient, __version__
7
7
 
8
8
 
9
9
  class AsyncFunctionsClient:
10
- def __init__(self, url: str, headers: Dict, verify: bool = True):
10
+ def __init__(self, url: str, headers: Dict, timeout: int, verify: bool = True):
11
11
  self.url = url
12
12
  self.headers = {
13
13
  "User-Agent": f"supabase-py/functions-py v{__version__}",
@@ -17,6 +17,7 @@ class AsyncFunctionsClient:
17
17
  base_url=self.url,
18
18
  headers=self.headers,
19
19
  verify=bool(verify),
20
+ timeout=timeout,
20
21
  follow_redirects=True,
21
22
  http2=True,
22
23
  )
@@ -64,18 +65,21 @@ class AsyncFunctionsClient:
64
65
  `responseType`: how the response should be parsed. The default is `json`
65
66
  """
66
67
  headers = self.headers
68
+ body = None
69
+ response_type = "text/plain"
67
70
  if invoke_options is not None:
68
71
  headers.update(invoke_options.get("headers", {}))
72
+ response_type = invoke_options.get("responseType", "text/plain")
69
73
 
70
- body = invoke_options.get("body") if invoke_options else None
71
- response_type = (
72
- invoke_options.get("responseType") if invoke_options else "text/plain"
73
- )
74
+ region = invoke_options.get("region")
75
+ if region and isinstance(region, str) and region != "any":
76
+ headers["x-region"] = region.lower().strip()
74
77
 
75
- if type(body) == str:
76
- headers["Content-Type"] = "text/plain"
77
- elif type(body) == dict:
78
- headers["Content-Type"] = "application/json"
78
+ body = invoke_options.get("body")
79
+ if isinstance(body, str):
80
+ headers["Content-Type"] = "text/plain"
81
+ elif isinstance(body, dict):
82
+ headers["Content-Type"] = "application/json"
79
83
 
80
84
  response = await self._request(
81
85
  "POST", f"{self.url}/{function_name}", headers=headers, json=body
@@ -7,7 +7,7 @@ from ..utils import SyncClient, __version__
7
7
 
8
8
 
9
9
  class SyncFunctionsClient:
10
- def __init__(self, url: str, headers: Dict, verify: bool = True):
10
+ def __init__(self, url: str, headers: Dict, timeout: int, verify: bool = True):
11
11
  self.url = url
12
12
  self.headers = {
13
13
  "User-Agent": f"supabase-py/functions-py v{__version__}",
@@ -17,6 +17,7 @@ class SyncFunctionsClient:
17
17
  base_url=self.url,
18
18
  headers=self.headers,
19
19
  verify=bool(verify),
20
+ timeout=timeout,
20
21
  follow_redirects=True,
21
22
  http2=True,
22
23
  )
@@ -64,18 +65,21 @@ class SyncFunctionsClient:
64
65
  `responseType`: how the response should be parsed. The default is `json`
65
66
  """
66
67
  headers = self.headers
68
+ body = None
69
+ response_type = "text/plain"
67
70
  if invoke_options is not None:
68
71
  headers.update(invoke_options.get("headers", {}))
72
+ response_type = invoke_options.get("responseType", "text/plain")
69
73
 
70
- body = invoke_options.get("body") if invoke_options else None
71
- response_type = (
72
- invoke_options.get("responseType") if invoke_options else "text/plain"
73
- )
74
+ region = invoke_options.get("region")
75
+ if region and isinstance(region, str) and region != "any":
76
+ headers["x-region"] = region.lower().strip()
74
77
 
75
- if type(body) == str:
76
- headers["Content-Type"] = "text/plain"
77
- elif type(body) == dict:
78
- headers["Content-Type"] = "application/json"
78
+ body = invoke_options.get("body")
79
+ if isinstance(body, str):
80
+ headers["Content-Type"] = "text/plain"
81
+ elif isinstance(body, dict):
82
+ headers["Content-Type"] = "application/json"
79
83
 
80
84
  response = self._request(
81
85
  "POST", f"{self.url}/{function_name}", headers=headers, json=body
@@ -1,7 +1,9 @@
1
1
  from httpx import AsyncClient as AsyncClient # noqa: F401
2
2
  from httpx import Client as BaseClient
3
3
 
4
- __version__ = "0.4.7"
4
+ __version__ = "0.5.1"
5
+
6
+ DEFAULT_FUNCTION_CLIENT_TIMEOUT = 5
5
7
 
6
8
 
7
9
  class SyncClient(BaseClient):