git.iko.soy/rowtype-yoga/purescript-supabase
on main help sign in
Add return type to onAuthStateChange
6d02a8eMark Eibes
src/Supabase/Supabase.purs+6−3
@@ -151,9 +151,9 @@ foreign import signOutImpl :: Client -> Effect (Promise Unit)
151signOut ∷ Client → Aff Unit
151signOut ∷ Client → Aff Unit
152signOut client = signOutImpl client # Promise.toAffE
152signOut client = signOutImpl client # Promise.toAffE
153
153
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 } }
155
155
156−onAuthStateChange ∷ Client → (Maybe Session → Effect Unit) → Effect Unit
156+onAuthStateChange ∷ Client → (Maybe Session → Effect Unit) → Effect { data :: { id :: String, unsubscribe :: Effect Unit } }
157onAuthStateChange client handler = onAuthStateChangeImpl client $ mkEffectFn1 (Nullable.toMaybe >>> handler)
157onAuthStateChange client handler = onAuthStateChangeImpl client $ mkEffectFn1 (Nullable.toMaybe >>> handler)
158
158
159type User = { id :: String, email :: String }
159type User = { id :: String, email :: String }
@@ -165,7 +165,10 @@ type ResultError = { code :: Maybe String, details :: Maybe String, message :: S
165type DataR d r = (data :: Maybe d | r)
165type DataR d r = (data :: Maybe d | r)
166type ErrorR r = (error ∷ Maybe ResultError | r)
166type ErrorR r = (error ∷ Maybe ResultError | r)
167type CountR r = (count :: Int | r)
167type CountR r = (count :: Int | r)
168+
169+type StatusR :: forall k. k -> Row Type
168type StatusR r = (status ∷ Maybe Int)
170type StatusR r = (status ∷ Maybe Int)
171+
169type Response d = { data :: Maybe d, error ∷ Maybe ResultError, status ∷ Maybe Int }
172type Response d = { data :: Maybe d, error ∷ Maybe ResultError, status ∷ Maybe Int }
170
173
171foreign import getSessionImpl :: Client -> Effect (Promise Foreign)
174foreign import getSessionImpl :: Client -> Effect (Promise Foreign)
@@ -177,7 +180,7 @@ type InternalFunctionResponse d = { "data" :: Nullable d, error :: Nullable { me
177
180
178foreign import invokeImpl :: forall body headers t. Client -> Fn3 String body headers (Effect $ Promise $ InternalFunctionResponse t)
181foreign import invokeImpl :: forall body headers t. Client -> Fn3 String body headers (Effect $ Promise $ InternalFunctionResponse t)
179
182
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 } }
181
184
182invoke ∷ forall t body headers. ReadForeign t ⇒ Client → String → body → headers → Aff (FunctionResponse t)
185invoke ∷ forall t body headers. ReadForeign t ⇒ Client → String → body → headers → Aff (FunctionResponse t)
183invoke client fn body headers = runFn3 (invokeImpl client) fn body headers # Promise.toAffE <#> convert
186invoke client fn body headers = runFn3 (invokeImpl client) fn body headers # Promise.toAffE <#> convert