git.iko.soy/rowtype-yoga/purescript-supabase
on main help sign in
Add return type to onAuthStateChange
commit6d02a8ec0c0fa835102f8369d7c3ec031d3c2611 authorMark Eibes <mark.eibes@gmail.com> dateMon 20 Mar 2023, 20:12 (4 years ago) parent75c988e
1 file changed+6−3
src/Supabase/Supabase.purs+6−3
src/Supabase/Supabase.purs+6−3
@@ -151,9 +151,9 @@ foreign import signOutImpl :: Client -> Effect (Promise Unit)
151151signOut ∷ Client → Aff Unit
152152signOut client = signOutImpl client # Promise.toAffE
153153
154−foreign import onAuthStateChangeImpl :: Client -> (EffectFn1 (Nullable Session) Unit) -> Effect Unit
154+foreign import onAuthStateChangeImpl :: Client -> (EffectFn1 (Nullable Session) Unit) -> Effect { data :: { id :: String, unsubscribe :: Effect Unit } }
155155
156−onAuthStateChange ∷ Client → (Maybe Session → Effect Unit) → Effect Unit
156+onAuthStateChange ∷ Client → (Maybe Session → Effect Unit) → Effect { data :: { id :: String, unsubscribe :: Effect Unit } }
157157onAuthStateChange client handler = onAuthStateChangeImpl client $ mkEffectFn1 (Nullable.toMaybe >>> handler)
158158
159159type User = { id :: String, email :: String }
@@ -165,7 +165,10 @@ type ResultError = { code :: Maybe String, details :: Maybe String, message :: S
165165type DataR d r = (data :: Maybe d | r)
166166type ErrorR r = (error ∷ Maybe ResultError | r)
167167type CountR r = (count :: Int | r)
168+
169+type StatusR :: forall k. k -> Row Type
168170type StatusR r = (status ∷ Maybe Int)
171+
169172type Response d = { data :: Maybe d, error ∷ Maybe ResultError, status ∷ Maybe Int }
170173
171174foreign import getSessionImpl :: Client -> Effect (Promise Foreign)
@@ -177,7 +180,7 @@ type InternalFunctionResponse d = { "data" :: Nullable d, error :: Nullable { me
177180
178181foreign import invokeImpl :: forall body headers t. Client -> Fn3 String body headers (Effect $ Promise $ InternalFunctionResponse t)
179182
180−type FunctionResponse d = { "data" :: Maybe d, error :: Maybe { message :: String, context :: Fetch.Response }}
183+type FunctionResponse d = { "data" :: Maybe d, error :: Maybe { message :: String, context :: Fetch.Response } }
181184
182185invoke ∷ forall t body headers. ReadForeign t ⇒ Client → String → body → headers → Aff (FunctionResponse t)
183186invoke client fn body headers = runFn3 (invokeImpl client) fn body headers # Promise.toAffE <#> convert