File tree 2 files changed +14
-0
lines changed
2 files changed +14
-0
lines changed Original file line number Diff line number Diff line change @@ -20,6 +20,7 @@ postgrest-py = ">=0.9.1,<0.11.0"
20
20
realtime = " ^0.0.4"
21
21
gotrue = " ^0.5.0"
22
22
httpx = " ^0.21.3"
23
+ supafunc =" ^0.1.0"
23
24
24
25
[tool .poetry .dev-dependencies ]
25
26
pre-commit = " ^2.17.0"
Original file line number Diff line number Diff line change
1
+ import re
1
2
from typing import Any , Dict
2
3
3
4
from httpx import Response
4
5
from postgrest_py import SyncPostgrestClient , SyncRequestBuilder
6
+ from supafunc import FunctionsClient
5
7
6
8
from supabase .lib .auth_client import SupabaseAuthClient
7
9
from supabase .lib .client_options import ClientOptions
@@ -42,6 +44,14 @@ def __init__(
42
44
self .realtime_url : str = f"{ supabase_url } /realtime/v1" .replace ("http" , "ws" )
43
45
self .auth_url : str = f"{ supabase_url } /auth/v1"
44
46
self .storage_url = f"{ supabase_url } /storage/v1"
47
+ is_platform = re .search (r"(supabase\.co)|(supabase\.in)" , supabase_url )
48
+ if is_platform :
49
+ url_parts = supabase_url .split ("." )
50
+ self .functions_url = (
51
+ f"{ url_parts [0 ]} .functions.{ url_parts [1 ]} .{ url_parts [2 ]} "
52
+ )
53
+ else :
54
+ self .functions_url = f"{ supabase_url } /functions/v1"
45
55
self .schema : str = options .schema
46
56
47
57
# Instantiate clients.
@@ -62,6 +72,9 @@ def __init__(
62
72
headers = options .headers ,
63
73
)
64
74
75
+ def functions (self ):
76
+ return FunctionsClient (self .functions_url , self ._get_auth_headers ())
77
+
65
78
def storage (self ) -> SupabaseStorageClient :
66
79
"""Create instance of the storage client"""
67
80
return SupabaseStorageClient (self .storage_url , self ._get_auth_headers ())
You can’t perform that action at this time.
0 commit comments