Yoga.Fetch.Om
- Package
- purescript-yoga-fetch-om
- Repository
- rowtype-yoga/purescript-yoga-fetch-om
#client Source
client :: forall @routes routesRow clientsRow polyClientsRow. RecordRow routes routesRow => DeriveClient routesRow clientsRow => String -> Record polyClientsRowDerive API client functions from route definitions using VTA
type UserAPI = { getUser :: Route ... }
api = client @UserAPI "https://api.example.com"
#deriveClient Source
deriveClient :: forall @routesRow clientsRow polyClientsRow. DeriveClient routesRow clientsRow => String -> Record polyClientsRowDeprecated: Use client with VTA instead
api = deriveClient @UserAPI "https://api.example.com"
#DeriveClient Source
class DeriveClient :: Row Type -> Row Type -> Constraintclass DeriveClient routesRow clientsRow | routesRow -> clientsRow where
Members
deriveClientImpl :: String -> Proxy (Record routesRow) -> Record clientsRow
Instances
(RowToList routesRow rl, DeriveClientRL rl () clientsRow) => DeriveClient routesRow clientsRow
#DeriveClientRL Source
class DeriveClientRL :: RowList Type -> Row Type -> Row Type -> Constraintclass DeriveClientRL rl acc out | rl acc -> out where
Members
deriveClientRL :: String -> Proxy rl -> Record acc -> Record out
Instances
DeriveClientRL Nil acc acc(IsSymbol label, DeriveClientFn method segments request response routeErrors successRow result fn, DeriveClientRL tail acc1 acc2, Cons label fn acc2 out, Lacks label acc2, Cons label (Route method segments request response) routeTail routeRow) => DeriveClientRL (Cons label (Route method segments request response) tail) acc1 out
#DeriveClientFn Source
class DeriveClientFn :: forall k1. Type -> k1 -> Type -> Row Type -> Row Type -> Row Type -> Type -> Type -> Constraintclass DeriveClientFn method segments request response routeErrors successRow result fn | method segments request response -> routeErrors successRow result fn where
Members
deriveClientFn :: String -> Proxy (Route method segments request response) -> fn
Instances
(SegmentPathParams segments pathParams, SegmentQueryParams segments queryParams, ExtractRequestBody request body, ExtractRequestHeaders request headers, PathPattern segments, BuildUrl segments pathParams queryParams, MakeRequest method, SerializeBody body, ContentType body, SplitResponses response successRow routeErrors, ParseResponse routeErrors successRow, RowToList successRow successRL, VariantOrValue successRL successRow result, Union pathParams queryParams pathQuery, Nub pathQuery pathQuery, RowToList pathQuery pathQueryRL, RowToList headers headersRL, ToHeaders headersRL headers, CheckBodyIsUnit body bodyFlag, BuildClientFn pathQueryRL headersRL bodyFlag body pathQuery headers routeErrors result fn) => DeriveClientFn method segments request response routeErrors successRow result fn
Re-exports from Yoga.Fetch.Om.Simple
#FetchResponse Source
type FetchResponse a = { body :: a, headers :: Headers }#FetchError Source
type FetchError = { body :: String, status :: Int }#DecodeResponse Source
class DecodeResponse :: forall k. k -> Type -> Constraintclass DecodeResponse a result | a -> result where
Members
decodeResponse :: String -> Either String result
Instances
(ReadForeign a) => DecodeResponse a a
#put_ Source
put_ :: forall headers body ctx err. Homogeneous headers String => WriteForeign body => String -> Record headers -> body -> Om ctx (fetchError :: FetchError | err) Unit#putWithHeaders Source
putWithHeaders :: forall @a result headers body ctx err. DecodeResponse a result => Homogeneous headers String => WriteForeign body => String -> Record headers -> body -> Om ctx (fetchError :: FetchError | err) (FetchResponse result)#put Source
put :: forall @a result headers body ctx err. DecodeResponse a result => Homogeneous headers String => WriteForeign body => String -> Record headers -> body -> Om ctx (fetchError :: FetchError | err) result#post_ Source
post_ :: forall headers body ctx err. Homogeneous headers String => WriteForeign body => String -> Record headers -> body -> Om ctx (fetchError :: FetchError | err) Unit#postWithHeaders Source
postWithHeaders :: forall @a result headers body ctx err. DecodeResponse a result => Homogeneous headers String => WriteForeign body => String -> Record headers -> body -> Om ctx (fetchError :: FetchError | err) (FetchResponse result)#post Source
post :: forall @a result headers body ctx err. DecodeResponse a result => Homogeneous headers String => WriteForeign body => String -> Record headers -> body -> Om ctx (fetchError :: FetchError | err) result#patch_ Source
patch_ :: forall headers body ctx err. Homogeneous headers String => WriteForeign body => String -> Record headers -> body -> Om ctx (fetchError :: FetchError | err) Unit#patchWithHeaders Source
patchWithHeaders :: forall @a result headers body ctx err. DecodeResponse a result => Homogeneous headers String => WriteForeign body => String -> Record headers -> body -> Om ctx (fetchError :: FetchError | err) (FetchResponse result)#patch Source
patch :: forall @a result headers body ctx err. DecodeResponse a result => Homogeneous headers String => WriteForeign body => String -> Record headers -> body -> Om ctx (fetchError :: FetchError | err) result#getWithHeaders Source
getWithHeaders :: forall @a result headers ctx err. DecodeResponse a result => Homogeneous headers String => String -> Record headers -> Om ctx (fetchError :: FetchError | err) (FetchResponse result)#get Source
get :: forall @a result headers ctx err. DecodeResponse a result => Homogeneous headers String => String -> Record headers -> Om ctx (fetchError :: FetchError | err) result#delete_ Source
delete_ :: forall headers ctx err. Homogeneous headers String => String -> Record headers -> Om ctx (fetchError :: FetchError | err) Unit#deleteWithHeaders Source
deleteWithHeaders :: forall @a result headers ctx err. DecodeResponse a result => Homogeneous headers String => String -> Record headers -> Om ctx (fetchError :: FetchError | err) (FetchResponse result)#delete Source
delete :: forall @a result headers ctx err. DecodeResponse a result => Homogeneous headers String => String -> Record headers -> Om ctx (fetchError :: FetchError | err) resultRe-exports from Yoga.Fetch.Om.StreamDecode
#StreamDecode Source
class StreamDecode a whereMembers
decodeStream :: Strom (Record ()) () Uint8Array -> Strom (Record ()) () a
Instances
Re-exports from Yoga.HTTP.API.Path
#Required Source
data Required aMarker for required query parameters (default is optional → Maybe)
Example: Path ("users") :? (limit :: Int, offset :: Required Int) -- limit parses as Maybe Int, offset parses as Int (fails if missing)
#QueryParams Source
data QueryParams :: forall k. k -> Type -> Typedata QueryParams path params
Attach query parameters to a path
Example: Path ("users" / "id" : Int) :? { limit :: Int, offset :: Required Int }
Instances
(PathPattern path) => PathPattern (QueryParams path params)
#PathCons Source
data PathCons :: forall k1 k2. k1 -> k2 -> Typedata PathCons left right
Instances
(IsSymbol s, PathPatternSegs rest) => PathPatternSegs (PathCons (Lit s) rest)(IsSymbol name, PathPatternSegs rest) => PathPatternSegs (PathCons (Capture name ty) rest)(IsSymbol name, PathPatternSegs rest) => PathPatternSegs (PathCons (Param name ty) rest)(IsSymbol s, PathPatternSegs rest) => PathPatternSegs (PathCons s rest)(IsSymbol s, ParsePath (Path rest) params) => ParsePath (Path (PathCons (Lit s) rest)) params(IsSymbol name, ParseParam ty, ParsePath (Path rest) restParams, Cons name ty restParams fullParams, Lacks name restParams) => ParsePath (Path (PathCons (Capture name ty) rest)) fullParams
#Path Source
data Path :: forall k. k -> Typedata Path segments
Type-level path representation
Examples: Path Root -- / Path (Lit "users") -- /users Path (Lit "users" / Capture "id" Int) -- /users/:id Path (Lit "users" / Capture "id" Int / Lit "posts") -- /users/:id/posts
Instances
(PathPatternSegs segs) => PathPattern (Path segs)(PathPatternSegs segs) => PathPatternSegs (Path segs)ParsePath (Path Root) ()(IsSymbol s) => ParsePath (Path (Lit s)) ()(IsSymbol name, ParseParam ty) => ParsePath (Path (Capture name ty)) (name :: ty)(IsSymbol s, ParsePath (Path rest) params) => ParsePath (Path (PathCons (Lit s) rest)) params(IsSymbol name, ParseParam ty, ParsePath (Path rest) restParams, Cons name ty restParams fullParams, Lacks name restParams) => ParsePath (Path (PathCons (Capture name ty) rest)) fullParams
#Param Source
data Param :: Symbol -> Type -> Typedata Param (name :: Symbol) (ty :: Type)
Sugar for Capture — use with bare Symbols in the path DSL
Example: Path ("users" / "id" : Int / "posts") -- equivalent to: Path (Lit "users" / Capture "id" Int / Lit "posts")
Instances
(IsSymbol name) => PathPatternSegs (Param name ty)(IsSymbol name, PathPatternSegs rest) => PathPatternSegs (PathCons (Param name ty) rest)
#Lit Source
data Lit :: Symbol -> Typedata Lit (segment :: Symbol)
Literal path segment (wrapper for Symbol to work around PureScript 0.15 limitations)
In PureScript 0.15, we can't use bare Symbols like Path "users" due to kind inference. Instead, use: Path (Lit "users")
Example: Path (Lit "users") -- /users Path (Lit "users" / Capture "id" Int) -- /users/:id
Instances
#Capture Source
data Capture :: Symbol -> Type -> Typedata Capture (name :: Symbol) (ty :: Type)
Capture a path parameter with a name and type
Example: Capture "id" Int -- captures :id as an Int Capture "name" String -- captures :name as a String
Instances
(IsSymbol name) => PathPatternSegs (Capture name ty)(IsSymbol name, PathPatternSegs rest) => PathPatternSegs (PathCons (Capture name ty) rest)(IsSymbol name, ParseParam ty) => ParsePath (Path (Capture name ty)) (name :: ty)(IsSymbol name, ParseParam ty, ParsePath (Path rest) restParams, Cons name ty restParams fullParams, Lacks name restParams) => ParsePath (Path (PathCons (Capture name ty) rest)) fullParams
#PathPattern Source
class PathPattern :: forall k. k -> Constraintclass PathPattern path
Generate a Fastify-compatible URL pattern from a path type
Examples: pathPattern (Proxy :: _ (Path Root)) = "/" pathPattern (Proxy :: _ (Path (Lit "users"))) = "/users" pathPattern (Proxy :: _ (Path (Lit "users" / Capture "id" Int))) = "/users/:id" pathPattern (Proxy :: _ ("users" / "id" : Int)) = "/users/:id"
Instances
(PathPattern path) => PathPattern (QueryParams path params)(PathPatternSegs segs) => PathPattern (Path segs)(PathPatternSegs segs) => PathPattern segs
#type (:?) Source
Operator alias for Yoga.HTTP.API.Path.QueryParams (left-associative / precedence 1)
#type (/) Source
Operator alias for Yoga.HTTP.API.Path.PathCons (right-associative / precedence 6)
Infix operator for building paths
Example: Lit "users" / Capture "id" Int / Lit "posts"
Re-exports from Yoga.HTTP.API.Route
#Streaming Source
data Streaming aStreaming response body (returns a Strom of decoded chunks)
Example: { body :: Streaming Uint8Array } -- raw binary { body :: Streaming String } -- text
#Route Source
data Route :: forall k. Type -> k -> Type -> Row Type -> Typedata Route method segments request respVariant
Constructors
Instances
(RenderMethod method, PathPattern segments, DefaultRequestFields partialRequest reqHeaders reqCookies encoding, RenderHeadersSchema reqHeaders, RenderCookieParamsSchema reqCookies, DetectSecurity reqHeaders, DetectCookieSecurity reqCookies, SegmentPathParams segments pathParams, RenderPathParamsSchema pathParams, SegmentQueryParams segments queryParams, RenderQueryParamsSchema queryParams, RenderRequestBodySchema encoding, RowToList userResp rl, RenderVariantResponseSchemaRL rl, HasOperationMetadata (Route method segments (Record partialRequest) userResp)) => ToOpenAPI (Route method segments (Record partialRequest) userResp)(ToOpenAPI (Route method segments (Record partialRequest) userResp)) => ToOpenAPI (Route method segments (Request (Record partialRequest)) userResp)(RenderMethod method, PathPattern segments, ToOpenAPI (Route method segments request resp)) => CollectOperations (Route method segments request resp)(DefaultRequestFields partialRequest reqHeaders reqCookies encoding, CollectSchemas encoding, RowToList userResp rl, CollectVariantSchemasRL rl) => CollectRouteSchemas (Route method segments (Record partialRequest) userResp)(CollectRouteSchemas (Route method segments (Record partialRequest) userResp)) => CollectRouteSchemas (Route method segments (Request (Record partialRequest)) userResp)(DefaultRequestFields partialRequest reqHeaders reqCookies encoding, CollectSchemaNames encoding reqNames, RowToList userResp rl, CollectVariantSchemaNames rl respNames, Union reqNames respNames names) => CollectRouteSchemaNames (Route method segments (Record partialRequest) userResp) names(CollectRouteSchemaNames (Route method segments (Record partialRequest) userResp) names) => CollectRouteSchemaNames (Route method segments (Request (Record partialRequest)) userResp) names
#NoBody Source
data NoBodyNo request body (for GET, DELETE, etc.)
Example: Request {} -- NoBody is the default when body is omitted