From 5191baf0d01ad4c6abd2b9f02a126a4697ef8562 Mon Sep 17 00:00:00 2001 From: "joel@joellee.org" Date: Tue, 3 Oct 2023 22:13:41 +0800 Subject: [PATCH 1/4] feat: add functions property --- supabase/client.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/supabase/client.py b/supabase/client.py index b69115b7..93504861 100644 --- a/supabase/client.py +++ b/supabase/client.py @@ -81,8 +81,10 @@ def __init__( self.realtime = None self._postgrest = None self._storage = None + self._functions = None self.auth.on_auth_state_change(self._listen_to_auth_events) + @deprecated("1.1.1", "1.3.0", details="Use `.functions` instead") def functions(self) -> FunctionsClient: return FunctionsClient(self.functions_url, self._get_auth_headers()) @@ -144,6 +146,14 @@ def storage(self): ) return self._storage + @property + def functions(self): + if self._functions is None: + headers = self._get_auth_headers() + headers.update(self._get_token_header()) + self._functions = FunctionsClient(self.functions_url, headers) + return self._functions + # async def remove_subscription_helper(resolve): # try: # await self._close_subscription(subscription) From b7692cb7a0e1df49c30af0888c6c403a0cee59f4 Mon Sep 17 00:00:00 2001 From: "joel@joellee.org" Date: Tue, 3 Oct 2023 22:17:06 +0800 Subject: [PATCH 2/4] fix: add deprecation import --- supabase/client.py | 1 + 1 file changed, 1 insertion(+) diff --git a/supabase/client.py b/supabase/client.py index 93504861..4dd5c2b3 100644 --- a/supabase/client.py +++ b/supabase/client.py @@ -1,6 +1,7 @@ import re from typing import Any, Dict, Union +from deprecation import deprecated from gotrue.types import AuthChangeEvent from httpx import Timeout from postgrest import SyncFilterRequestBuilder, SyncPostgrestClient, SyncRequestBuilder From 5f052ee0d064e67b68f27fc77a08a0c6d4fc2257 Mon Sep 17 00:00:00 2001 From: "joel@joellee.org" Date: Tue, 3 Oct 2023 22:21:47 +0800 Subject: [PATCH 3/4] test: remove call to functions --- tests/test_function_configuration.py | 1 - 1 file changed, 1 deletion(-) diff --git a/tests/test_function_configuration.py b/tests/test_function_configuration.py index 876cb05c..0e451d03 100644 --- a/tests/test_function_configuration.py +++ b/tests/test_function_configuration.py @@ -7,7 +7,6 @@ def test_functions_client_initialization() -> None: # Sample JWT Key key = "xxxxxxxxxxxxxx.xxxxxxxxxxxxxxx.xxxxxxxxxxxxxxx" sp = supabase.Client(url, key) - sp.functions() assert sp.functions_url == f"https://{ref}.supabase.co/functions/v1" url = "https://localhost:54322" From c283c8c39033fd4094c4fd22b2255f39f9be907d Mon Sep 17 00:00:00 2001 From: Joel Lee Date: Wed, 4 Oct 2023 14:35:42 +0800 Subject: [PATCH 4/4] Update client.py --- supabase/client.py | 1 + 1 file changed, 1 insertion(+) diff --git a/supabase/client.py b/supabase/client.py index 4dd5c2b3..c27a4e70 100644 --- a/supabase/client.py +++ b/supabase/client.py @@ -247,6 +247,7 @@ def _listen_to_auth_events(self, event: AuthChangeEvent, session): # reset postgrest and storage instance on event change self._postgrest = None self._storage = None + self._functions = None def create_client(