@@ -13,6 +13,7 @@ module Yoga.Fetch.Om
1313 , module Yoga.HTTP.API.Route
1414 , module Yoga.HTTP.API.Path
1515 , plainText
16+ , class HasAllFields
1617 , module Yoga.Fetch.Om.StreamDecode
1718 , module Yoga.Fetch.Om.Simple
1819 ) where
@@ -100,6 +101,8 @@ instance
100101 , RowToList headers headersRL
101102 , ToHeaders headersRL headers
102103 , CheckBodyIsUnit body bodyFlag
104+ , RowToList pathParams pathParamsRL
105+ , HasAllFields pathParamsRL given
103106 , Row.Union routeErrors extraErr errRow
104107 , BuildClientFn pathQueryRL headersRL bodyFlag body pathQuery headers given { | ctx } errRow result fn
105108 ) =>
@@ -144,6 +147,13 @@ client baseUrl = deriveClientImpl @ctx @extraErr baseUrl (Proxy :: _ { | routesR
144147deriveClient :: forall @routesRow ctx extraErr clientsRow. DeriveClient ctx extraErr routesRow clientsRow => String -> Record clientsRow
145148deriveClient baseUrl = deriveClientImpl @ctx @extraErr baseUrl (Proxy :: _ { | routesRow })
146149
150+-- | Checks that all fields in the RowList exist in the given row.
151+-- | Used to enforce required path params are present in the client argument.
152+class HasAllFields (rl :: RL.RowList Type) (given :: Row Type)
153+
154+instance HasAllFields RL.Nil given
155+instance (Row.Cons name ty rest given, HasAllFields tail given) => HasAllFields (RL.Cons name ty tail) given
156+
147157plainText :: PlainText -> String
148158plainText = unsafeCoerce
149159