supabase_functions 2.20.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.20.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.20.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,6 @@ tests = [
32
33
  lints = [
33
34
  "unasync>=0.6.0",
34
35
  "ruff >=0.12.1",
35
- "pre-commit >=3.4,<5.0",
36
36
  "python-lsp-server (>=1.12.2,<2.0.0)",
37
37
  "pylsp-mypy (>=0.7.0,<0.8.0)",
38
38
  "python-lsp-ruff (>=2.2.2,<3.0.0)",
@@ -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,11 +73,16 @@ 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
78
  response = (
78
- await self._client.request(method, url, data=json, headers=headers)
79
+ await self._client.request(
80
+ method, url, data=json, headers=headers, params=params
81
+ )
79
82
  if isinstance(json, str)
80
- else await self._client.request(method, url, json=json, headers=headers)
83
+ else await self._client.request(
84
+ method, url, json=json, headers=headers, params=params
85
+ )
81
86
  )
82
87
  try:
83
88
  response.raise_for_status()
@@ -121,8 +126,11 @@ class AsyncFunctionsClient:
121
126
  if not is_valid_str_arg(function_name):
122
127
  raise ValueError("function_name must a valid string value.")
123
128
  headers = self.headers
129
+ params = QueryParams()
124
130
  body = None
125
131
  response_type = "text/plain"
132
+ url = f"{self.url}/{function_name}"
133
+
126
134
  if invoke_options is not None:
127
135
  headers.update(invoke_options.get("headers", {}))
128
136
  response_type = invoke_options.get("responseType", "text/plain")
@@ -135,6 +143,8 @@ class AsyncFunctionsClient:
135
143
 
136
144
  if region.value != "any":
137
145
  headers["x-region"] = region.value
146
+ # Add region as query parameter
147
+ params = params.set("forceFunctionRegion", region.value)
138
148
 
139
149
  body = invoke_options.get("body")
140
150
  if isinstance(body, str):
@@ -143,7 +153,7 @@ class AsyncFunctionsClient:
143
153
  headers["Content-Type"] = "application/json"
144
154
 
145
155
  response = await self._request(
146
- "POST", f"{self.url}/{function_name}", headers=headers, json=body
156
+ "POST", url, headers=headers, json=body, params=params
147
157
  )
148
158
  is_relay_error = response.headers.get("x-relay-header")
149
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,11 +73,14 @@ 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
78
  response = (
78
- self._client.request(method, url, data=json, headers=headers)
79
+ self._client.request(method, url, data=json, headers=headers, params=params)
79
80
  if isinstance(json, str)
80
- else self._client.request(method, url, json=json, headers=headers)
81
+ else self._client.request(
82
+ method, url, json=json, headers=headers, params=params
83
+ )
81
84
  )
82
85
  try:
83
86
  response.raise_for_status()
@@ -121,8 +124,11 @@ class SyncFunctionsClient:
121
124
  if not is_valid_str_arg(function_name):
122
125
  raise ValueError("function_name must a valid string value.")
123
126
  headers = self.headers
127
+ params = QueryParams()
124
128
  body = None
125
129
  response_type = "text/plain"
130
+ url = f"{self.url}/{function_name}"
131
+
126
132
  if invoke_options is not None:
127
133
  headers.update(invoke_options.get("headers", {}))
128
134
  response_type = invoke_options.get("responseType", "text/plain")
@@ -135,6 +141,8 @@ class SyncFunctionsClient:
135
141
 
136
142
  if region.value != "any":
137
143
  headers["x-region"] = region.value
144
+ # Add region as query parameter
145
+ params = params.set("forceFunctionRegion", region.value)
138
146
 
139
147
  body = invoke_options.get("body")
140
148
  if isinstance(body, str):
@@ -142,9 +150,7 @@ class SyncFunctionsClient:
142
150
  elif isinstance(body, dict):
143
151
  headers["Content-Type"] = "application/json"
144
152
 
145
- response = self._request(
146
- "POST", f"{self.url}/{function_name}", headers=headers, json=body
147
- )
153
+ response = self._request("POST", url, headers=headers, json=body, params=params)
148
154
  is_relay_error = response.headers.get("x-relay-header")
149
155
 
150
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.20.0" # {x-release-please-version}