supabase_functions 2.19.0__tar.gz → 2.21.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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: supabase-functions
3
- Version: 2.19.0
3
+ Version: 2.21.0
4
4
  Summary: Library for Supabase Functions
5
5
  Author: Joel Lee, Andrew Smith
6
6
  Author-email: Joel Lee <joel@joellee.org>, Andrew Smith <a.smith@silentworks.co.uk>
@@ -10,6 +10,7 @@ Requires-Dist: strenum>=0.4.15
10
10
  Maintainer: Leonardo Santiago
11
11
  Maintainer-email: Leonardo Santiago <leonardo.santiago@supabase.io>
12
12
  Requires-Python: >=3.9
13
+ Project-URL: changelog, https://github.com/supabase/supabase-py/CHANGELOG.md
13
14
  Project-URL: homepage, https://github.com/supabase/supabase/tree/main/src/functions
14
15
  Project-URL: repository, https://github.com/supabase/supabase-py
15
16
  Description-Content-Type: text/markdown
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "supabase_functions"
3
- version = "2.19.0" # {x-release-please-version}
3
+ version = "2.21.0" # {x-release-please-version}
4
4
  description = "Library for Supabase Functions"
5
5
  authors = [
6
6
  { name = "Joel Lee", email = "joel@joellee.org" },
@@ -21,6 +21,7 @@ dependencies = [
21
21
  [project.urls]
22
22
  repository = "https://github.com/supabase/supabase-py"
23
23
  homepage = "https://github.com/supabase/supabase/tree/main/src/functions"
24
+ changelog = "https://github.com/supabase/supabase-py/CHANGELOG.md"
24
25
 
25
26
  [dependency-groups]
26
27
  tests = [
@@ -32,7 +33,9 @@ tests = [
32
33
  lints = [
33
34
  "unasync>=0.6.0",
34
35
  "ruff >=0.12.1",
35
- "pre-commit >=3.4,<5.0"
36
+ "python-lsp-server (>=1.12.2,<2.0.0)",
37
+ "pylsp-mypy (>=0.7.0,<0.8.0)",
38
+ "python-lsp-ruff (>=2.2.2,<3.0.0)",
36
39
  ]
37
40
  dev = [{ include-group = "lints" }, {include-group = "tests" }]
38
41
 
@@ -1,7 +1,7 @@
1
1
  from typing import Any, Dict, Literal, Optional, Union
2
2
  from warnings import warn
3
3
 
4
- from httpx import AsyncClient, HTTPError, Response
4
+ from httpx import AsyncClient, HTTPError, Response, QueryParams
5
5
 
6
6
  from ..errors import FunctionsHttpError, FunctionsRelayError
7
7
  from ..utils import (
@@ -73,10 +73,17 @@ class AsyncFunctionsClient:
73
73
  url: str,
74
74
  headers: Optional[Dict[str, str]] = None,
75
75
  json: Optional[Dict[Any, Any]] = None,
76
+ params: Optional[QueryParams] = None,
76
77
  ) -> Response:
77
- user_data = {"data": json} if isinstance(json, str) else {"json": json}
78
- response = await self._client.request(method, url, **user_data, headers=headers)
79
-
78
+ response = (
79
+ await self._client.request(
80
+ method, url, data=json, headers=headers, params=params
81
+ )
82
+ if isinstance(json, str)
83
+ else await self._client.request(
84
+ method, url, json=json, headers=headers, params=params
85
+ )
86
+ )
80
87
  try:
81
88
  response.raise_for_status()
82
89
  except HTTPError as exc:
@@ -119,8 +126,11 @@ class AsyncFunctionsClient:
119
126
  if not is_valid_str_arg(function_name):
120
127
  raise ValueError("function_name must a valid string value.")
121
128
  headers = self.headers
129
+ params = QueryParams()
122
130
  body = None
123
131
  response_type = "text/plain"
132
+ url = f"{self.url}/{function_name}"
133
+
124
134
  if invoke_options is not None:
125
135
  headers.update(invoke_options.get("headers", {}))
126
136
  response_type = invoke_options.get("responseType", "text/plain")
@@ -133,6 +143,8 @@ class AsyncFunctionsClient:
133
143
 
134
144
  if region.value != "any":
135
145
  headers["x-region"] = region.value
146
+ # Add region as query parameter
147
+ params = params.set("forceFunctionRegion", region.value)
136
148
 
137
149
  body = invoke_options.get("body")
138
150
  if isinstance(body, str):
@@ -141,7 +153,7 @@ class AsyncFunctionsClient:
141
153
  headers["Content-Type"] = "application/json"
142
154
 
143
155
  response = await self._request(
144
- "POST", f"{self.url}/{function_name}", headers=headers, json=body
156
+ "POST", url, headers=headers, json=body, params=params
145
157
  )
146
158
  is_relay_error = response.headers.get("x-relay-header")
147
159
 
@@ -1,7 +1,7 @@
1
1
  from typing import Any, Dict, Literal, Optional, Union
2
2
  from warnings import warn
3
3
 
4
- from httpx import Client, HTTPError, Response
4
+ from httpx import Client, HTTPError, Response, QueryParams
5
5
 
6
6
  from ..errors import FunctionsHttpError, FunctionsRelayError
7
7
  from ..utils import (
@@ -73,10 +73,15 @@ class SyncFunctionsClient:
73
73
  url: str,
74
74
  headers: Optional[Dict[str, str]] = None,
75
75
  json: Optional[Dict[Any, Any]] = None,
76
+ params: Optional[QueryParams] = None,
76
77
  ) -> Response:
77
- user_data = {"data": json} if isinstance(json, str) else {"json": json}
78
- response = self._client.request(method, url, **user_data, headers=headers)
79
-
78
+ response = (
79
+ self._client.request(method, url, data=json, headers=headers, params=params)
80
+ if isinstance(json, str)
81
+ else self._client.request(
82
+ method, url, json=json, headers=headers, params=params
83
+ )
84
+ )
80
85
  try:
81
86
  response.raise_for_status()
82
87
  except HTTPError as exc:
@@ -119,8 +124,11 @@ class SyncFunctionsClient:
119
124
  if not is_valid_str_arg(function_name):
120
125
  raise ValueError("function_name must a valid string value.")
121
126
  headers = self.headers
127
+ params = QueryParams()
122
128
  body = None
123
129
  response_type = "text/plain"
130
+ url = f"{self.url}/{function_name}"
131
+
124
132
  if invoke_options is not None:
125
133
  headers.update(invoke_options.get("headers", {}))
126
134
  response_type = invoke_options.get("responseType", "text/plain")
@@ -133,6 +141,8 @@ class SyncFunctionsClient:
133
141
 
134
142
  if region.value != "any":
135
143
  headers["x-region"] = region.value
144
+ # Add region as query parameter
145
+ params = params.set("forceFunctionRegion", region.value)
136
146
 
137
147
  body = invoke_options.get("body")
138
148
  if isinstance(body, str):
@@ -140,9 +150,7 @@ class SyncFunctionsClient:
140
150
  elif isinstance(body, dict):
141
151
  headers["Content-Type"] = "application/json"
142
152
 
143
- response = self._request(
144
- "POST", f"{self.url}/{function_name}", headers=headers, json=body
145
- )
153
+ response = self._request("POST", url, headers=headers, json=body, params=params)
146
154
  is_relay_error = response.headers.get("x-relay-header")
147
155
 
148
156
  if is_relay_error and is_relay_error == "true":
@@ -0,0 +1 @@
1
+ __version__ = "2.21.0" # {x-release-please-version}
@@ -1 +0,0 @@
1
- __version__ = "2.19.0" # {x-release-please-version}