From 9342f1f96deff2b4f0929ade212b18b33d4a67cf Mon Sep 17 00:00:00 2001 From: Juan Carlos Date: Mon, 22 Jul 2024 17:12:16 -0300 Subject: [PATCH 01/12] Add x-region support --- supabase_functions/_async/functions_client.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/supabase_functions/_async/functions_client.py b/supabase_functions/_async/functions_client.py index 8e84acd..67b1e4e 100644 --- a/supabase_functions/_async/functions_client.py +++ b/supabase_functions/_async/functions_client.py @@ -77,6 +77,11 @@ async def invoke( elif type(body) == dict: headers["Content-Type"] = "application/json" + # https://github.com/supabase/functions-js/blob/098537a0f5e1c2b2aca8891625c4deca846b0591/src/FunctionsClient.ts#L60-L62 + region = invoke_options.get("region") + if region and isinstance(region, str) and region != "any": + headers["x-region"] = region.lower().strip() + response = await self._request( "POST", f"{self.url}/{function_name}", headers=headers, json=body ) From da854e1848ecfae854e75ba8fb1946cb6e939410 Mon Sep 17 00:00:00 2001 From: Juan Carlos Date: Mon, 22 Jul 2024 17:12:25 -0300 Subject: [PATCH 02/12] Add x-region support --- supabase_functions/_sync/functions_client.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/supabase_functions/_sync/functions_client.py b/supabase_functions/_sync/functions_client.py index d09d66c..9df5540 100644 --- a/supabase_functions/_sync/functions_client.py +++ b/supabase_functions/_sync/functions_client.py @@ -77,6 +77,11 @@ def invoke( elif type(body) == dict: headers["Content-Type"] = "application/json" + # https://github.com/supabase/functions-js/blob/098537a0f5e1c2b2aca8891625c4deca846b0591/src/FunctionsClient.ts#L60-L62 + region = invoke_options.get("region") + if region and isinstance(region, str) and region != "any": + headers["x-region"] = region.lower().strip() + response = self._request( "POST", f"{self.url}/{function_name}", headers=headers, json=body ) From 68cde73ac6c5a6831108e1f86eeafe151c13d2d2 Mon Sep 17 00:00:00 2001 From: Juan Carlos Date: Mon, 22 Jul 2024 17:34:07 -0300 Subject: [PATCH 03/12] Add x-region support --- supabase_functions/_async/functions_client.py | 27 +++++++++---------- 1 file changed, 12 insertions(+), 15 deletions(-) diff --git a/supabase_functions/_async/functions_client.py b/supabase_functions/_async/functions_client.py index 67b1e4e..a4370c9 100644 --- a/supabase_functions/_async/functions_client.py +++ b/supabase_functions/_async/functions_client.py @@ -66,21 +66,18 @@ async def invoke( headers = self.headers if invoke_options is not None: headers.update(invoke_options.get("headers", {})) - - body = invoke_options.get("body") if invoke_options else None - response_type = ( - invoke_options.get("responseType") if invoke_options else "text/plain" - ) - - if type(body) == str: - headers["Content-Type"] = "text/plain" - elif type(body) == dict: - headers["Content-Type"] = "application/json" - - # https://github.com/supabase/functions-js/blob/098537a0f5e1c2b2aca8891625c4deca846b0591/src/FunctionsClient.ts#L60-L62 - region = invoke_options.get("region") - if region and isinstance(region, str) and region != "any": - headers["x-region"] = region.lower().strip() + response_type = invoke_options.get("responseType", "text/plain") + + # https://github.com/supabase/functions-js/blob/098537a0f5e1c2b2aca8891625c4deca846b0591/src/FunctionsClient.ts#L60-L62 + region = invoke_options.get("region") + if region and isinstance(region, str) and region != "any": + headers["x-region"] = region.lower().strip() + + body = invoke_options.get("body") + if isinstance(body, str): + headers["Content-Type"] = "text/plain" + elif isinstance(body, dict): + headers["Content-Type"] = "application/json" response = await self._request( "POST", f"{self.url}/{function_name}", headers=headers, json=body From a05baf9ca284a6304e99505c8cda0a409f580d79 Mon Sep 17 00:00:00 2001 From: Juan Carlos Date: Mon, 22 Jul 2024 17:34:14 -0300 Subject: [PATCH 04/12] Add x-region support --- supabase_functions/_sync/functions_client.py | 27 +++++++++----------- 1 file changed, 12 insertions(+), 15 deletions(-) diff --git a/supabase_functions/_sync/functions_client.py b/supabase_functions/_sync/functions_client.py index 9df5540..29b3375 100644 --- a/supabase_functions/_sync/functions_client.py +++ b/supabase_functions/_sync/functions_client.py @@ -66,21 +66,18 @@ def invoke( headers = self.headers if invoke_options is not None: headers.update(invoke_options.get("headers", {})) - - body = invoke_options.get("body") if invoke_options else None - response_type = ( - invoke_options.get("responseType") if invoke_options else "text/plain" - ) - - if type(body) == str: - headers["Content-Type"] = "text/plain" - elif type(body) == dict: - headers["Content-Type"] = "application/json" - - # https://github.com/supabase/functions-js/blob/098537a0f5e1c2b2aca8891625c4deca846b0591/src/FunctionsClient.ts#L60-L62 - region = invoke_options.get("region") - if region and isinstance(region, str) and region != "any": - headers["x-region"] = region.lower().strip() + response_type = invoke_options.get("responseType", "text/plain") + + # https://github.com/supabase/functions-js/blob/098537a0f5e1c2b2aca8891625c4deca846b0591/src/FunctionsClient.ts#L60-L62 + region = invoke_options.get("region") + if region and isinstance(region, str) and region != "any": + headers["x-region"] = region.lower().strip() + + body = invoke_options.get("body") + if isinstance(body, str): + headers["Content-Type"] = "text/plain" + elif isinstance(body, dict): + headers["Content-Type"] = "application/json" response = self._request( "POST", f"{self.url}/{function_name}", headers=headers, json=body From c2c5d0d4c85cbb96af6a3ff1f5265c812fa7f156 Mon Sep 17 00:00:00 2001 From: Juan Carlos Date: Mon, 22 Jul 2024 17:36:23 -0300 Subject: [PATCH 05/12] Add x-region support --- supabase_functions/_async/functions_client.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/supabase_functions/_async/functions_client.py b/supabase_functions/_async/functions_client.py index a4370c9..392461e 100644 --- a/supabase_functions/_async/functions_client.py +++ b/supabase_functions/_async/functions_client.py @@ -73,11 +73,11 @@ async def invoke( if region and isinstance(region, str) and region != "any": headers["x-region"] = region.lower().strip() - body = invoke_options.get("body") - if isinstance(body, str): - headers["Content-Type"] = "text/plain" - elif isinstance(body, dict): - headers["Content-Type"] = "application/json" + body = invoke_options.get("body") + if isinstance(body, str): + headers["Content-Type"] = "text/plain" + elif isinstance(body, dict): + headers["Content-Type"] = "application/json" response = await self._request( "POST", f"{self.url}/{function_name}", headers=headers, json=body From 4456135767255fb8609eca77a924cc7cbd27d18f Mon Sep 17 00:00:00 2001 From: Juan Carlos Date: Mon, 22 Jul 2024 17:36:31 -0300 Subject: [PATCH 06/12] Add x-region support --- supabase_functions/_sync/functions_client.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/supabase_functions/_sync/functions_client.py b/supabase_functions/_sync/functions_client.py index 29b3375..6e351b9 100644 --- a/supabase_functions/_sync/functions_client.py +++ b/supabase_functions/_sync/functions_client.py @@ -73,11 +73,11 @@ def invoke( if region and isinstance(region, str) and region != "any": headers["x-region"] = region.lower().strip() - body = invoke_options.get("body") - if isinstance(body, str): - headers["Content-Type"] = "text/plain" - elif isinstance(body, dict): - headers["Content-Type"] = "application/json" + body = invoke_options.get("body") + if isinstance(body, str): + headers["Content-Type"] = "text/plain" + elif isinstance(body, dict): + headers["Content-Type"] = "application/json" response = self._request( "POST", f"{self.url}/{function_name}", headers=headers, json=body From eccfadd25ab6bba373d6b9c9e9109b7cec041890 Mon Sep 17 00:00:00 2001 From: Juan Carlos Date: Mon, 22 Jul 2024 17:41:52 -0300 Subject: [PATCH 07/12] Add x-region support --- supabase_functions/_async/functions_client.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/supabase_functions/_async/functions_client.py b/supabase_functions/_async/functions_client.py index 392461e..40ab192 100644 --- a/supabase_functions/_async/functions_client.py +++ b/supabase_functions/_async/functions_client.py @@ -64,6 +64,7 @@ async def invoke( `responseType`: how the response should be parsed. The default is `json` """ headers = self.headers + body = None if invoke_options is not None: headers.update(invoke_options.get("headers", {})) response_type = invoke_options.get("responseType", "text/plain") @@ -73,11 +74,11 @@ async def invoke( if region and isinstance(region, str) and region != "any": headers["x-region"] = region.lower().strip() - body = invoke_options.get("body") - if isinstance(body, str): - headers["Content-Type"] = "text/plain" - elif isinstance(body, dict): - headers["Content-Type"] = "application/json" + body = invoke_options.get("body") + if isinstance(body, str): + headers["Content-Type"] = "text/plain" + elif isinstance(body, dict): + headers["Content-Type"] = "application/json" response = await self._request( "POST", f"{self.url}/{function_name}", headers=headers, json=body From 072571d16b43d32c9d2600b310710c8ae374fdb8 Mon Sep 17 00:00:00 2001 From: Juan Carlos Date: Mon, 22 Jul 2024 17:41:55 -0300 Subject: [PATCH 08/12] Add x-region support --- supabase_functions/_sync/functions_client.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/supabase_functions/_sync/functions_client.py b/supabase_functions/_sync/functions_client.py index 6e351b9..57304db 100644 --- a/supabase_functions/_sync/functions_client.py +++ b/supabase_functions/_sync/functions_client.py @@ -64,6 +64,7 @@ def invoke( `responseType`: how the response should be parsed. The default is `json` """ headers = self.headers + body = None if invoke_options is not None: headers.update(invoke_options.get("headers", {})) response_type = invoke_options.get("responseType", "text/plain") @@ -73,11 +74,11 @@ def invoke( if region and isinstance(region, str) and region != "any": headers["x-region"] = region.lower().strip() - body = invoke_options.get("body") - if isinstance(body, str): - headers["Content-Type"] = "text/plain" - elif isinstance(body, dict): - headers["Content-Type"] = "application/json" + body = invoke_options.get("body") + if isinstance(body, str): + headers["Content-Type"] = "text/plain" + elif isinstance(body, dict): + headers["Content-Type"] = "application/json" response = self._request( "POST", f"{self.url}/{function_name}", headers=headers, json=body From 77ccb7c85baafe930e6eb07f151c9c73d79d7546 Mon Sep 17 00:00:00 2001 From: Juan Carlos Date: Mon, 22 Jul 2024 17:44:26 -0300 Subject: [PATCH 09/12] Add x-region support --- supabase_functions/_async/functions_client.py | 1 + 1 file changed, 1 insertion(+) diff --git a/supabase_functions/_async/functions_client.py b/supabase_functions/_async/functions_client.py index 40ab192..8022dcf 100644 --- a/supabase_functions/_async/functions_client.py +++ b/supabase_functions/_async/functions_client.py @@ -65,6 +65,7 @@ async def invoke( """ headers = self.headers body = None + response_type = "text/plain" if invoke_options is not None: headers.update(invoke_options.get("headers", {})) response_type = invoke_options.get("responseType", "text/plain") From d2aba7d54e46622d60c647aa2d7925e47bf7a012 Mon Sep 17 00:00:00 2001 From: Juan Carlos Date: Mon, 22 Jul 2024 17:44:28 -0300 Subject: [PATCH 10/12] Add x-region support --- supabase_functions/_sync/functions_client.py | 1 + 1 file changed, 1 insertion(+) diff --git a/supabase_functions/_sync/functions_client.py b/supabase_functions/_sync/functions_client.py index 57304db..4037a75 100644 --- a/supabase_functions/_sync/functions_client.py +++ b/supabase_functions/_sync/functions_client.py @@ -65,6 +65,7 @@ def invoke( """ headers = self.headers body = None + response_type = "text/plain" if invoke_options is not None: headers.update(invoke_options.get("headers", {})) response_type = invoke_options.get("responseType", "text/plain") From 986b3f86e5a2047d98f9ab32bc02cc6def46b9c0 Mon Sep 17 00:00:00 2001 From: Juan Carlos Date: Wed, 24 Jul 2024 20:52:44 -0300 Subject: [PATCH 11/12] Clean out old dev comments --- supabase_functions/_sync/functions_client.py | 1 - 1 file changed, 1 deletion(-) diff --git a/supabase_functions/_sync/functions_client.py b/supabase_functions/_sync/functions_client.py index 4037a75..d7b5593 100644 --- a/supabase_functions/_sync/functions_client.py +++ b/supabase_functions/_sync/functions_client.py @@ -70,7 +70,6 @@ def invoke( headers.update(invoke_options.get("headers", {})) response_type = invoke_options.get("responseType", "text/plain") - # https://github.com/supabase/functions-js/blob/098537a0f5e1c2b2aca8891625c4deca846b0591/src/FunctionsClient.ts#L60-L62 region = invoke_options.get("region") if region and isinstance(region, str) and region != "any": headers["x-region"] = region.lower().strip() From 0588be9fd0dda849181a346eb5ed43c707eab227 Mon Sep 17 00:00:00 2001 From: Juan Carlos Date: Wed, 24 Jul 2024 20:52:53 -0300 Subject: [PATCH 12/12] Clean out old dev comments --- supabase_functions/_async/functions_client.py | 1 - 1 file changed, 1 deletion(-) diff --git a/supabase_functions/_async/functions_client.py b/supabase_functions/_async/functions_client.py index 8022dcf..07ee12e 100644 --- a/supabase_functions/_async/functions_client.py +++ b/supabase_functions/_async/functions_client.py @@ -70,7 +70,6 @@ async def invoke( headers.update(invoke_options.get("headers", {})) response_type = invoke_options.get("responseType", "text/plain") - # https://github.com/supabase/functions-js/blob/098537a0f5e1c2b2aca8891625c4deca846b0591/src/FunctionsClient.ts#L60-L62 region = invoke_options.get("region") if region and isinstance(region, str) and region != "any": headers["x-region"] = region.lower().strip()