Copyright | (C) 2014 Alp Mestanogullari |
---|---|
License | BSD3 |
Maintainer | Alp Mestanogullari <alpmestan@gmail.com> |
Stability | experimental |
Portability | non-portable |
Safe Haskell | None |
Language | Haskell2010 |
- jquery :: HasJQ layout => Proxy layout -> JQ layout
- generateJS :: AjaxReq -> String
- jsForAPI :: (HasJQ api, GenerateCode (JQ api)) => Proxy api -> String
- printJS :: AjaxReq -> IO ()
- type Arg = String
- data Segment = Segment {
- _segment :: SegmentType
- _matrix :: [MatrixArg]
- data SegmentType
- type Path = [Segment]
- data ArgType
- data QueryArg = QueryArg {}
- data HeaderArg
- = HeaderArg { }
- | ReplaceHeaderArg { }
- toValidFunctionName :: String -> String
- type MatrixArg = QueryArg
- data Url = Url {}
- defUrl :: Url
- type FunctionName = String
- type Method = String
- data AjaxReq = AjaxReq {
- _reqUrl :: Url
- _reqMethod :: Method
- _reqHeaders :: [HeaderArg]
- _reqBody :: Bool
- _funcName :: FunctionName
- argType :: Lens' QueryArg ArgType
- argName :: Lens' QueryArg Arg
- segment :: Lens' Segment SegmentType
- matrix :: Lens' Segment [MatrixArg]
- queryStr :: Lens' Url [QueryArg]
- path :: Lens' Url Path
- reqUrl :: Lens' AjaxReq Url
- reqMethod :: Lens' AjaxReq Method
- reqHeaders :: Lens' AjaxReq [HeaderArg]
- reqBody :: Lens' AjaxReq Bool
- funcName :: Lens' AjaxReq FunctionName
- isCapture :: Segment -> Bool
- hasMatrixArgs :: Segment -> Bool
- hasArgs :: Segment -> Bool
- matrixArgs :: Segment -> [MatrixArg]
- captureArg :: Segment -> Arg
- jsSegments :: [Segment] -> String
- segmentToStr :: Segment -> Bool -> String
- segmentTypeToStr :: SegmentType -> String
- jsGParams :: String -> [QueryArg] -> String
- jsParams :: [QueryArg] -> String
- jsMParams :: [MatrixArg] -> String
- paramToStr :: QueryArg -> Bool -> String
- defReq :: AjaxReq
- type family Elem a ls :: Constraint
- class HasJQ layout where
- class GenerateCode reqs where
Documentation
generateJS :: AjaxReq -> String Source
jsForAPI :: (HasJQ api, GenerateCode (JQ api)) => Proxy api -> String Source
Directly generate all the javascript functions for your API
from a Proxy
for your API type. You can then write it to
a file or integrate it in a page, for example.
data SegmentType Source
toValidFunctionName :: String -> String Source
Attempts to reduce the function name provided to that allowed by JS. https://mathiasbynens.be/notes/javascript-identifiers Couldn't work out how to handle zero-width characters. @TODO: specify better default function name, or throw error?
type FunctionName = String Source
AjaxReq | |
|
Eq AjaxReq | |
Show AjaxReq | |
GenerateCode AjaxReq | |
GenerateCode rest => GenerateCode ((:<|>) AjaxReq rest) |
hasMatrixArgs :: Segment -> Bool Source
matrixArgs :: Segment -> [MatrixArg] Source
captureArg :: Segment -> Arg Source
jsSegments :: [Segment] -> String Source
segmentToStr :: Segment -> Bool -> String Source
paramToStr :: QueryArg -> Bool -> String Source
type family Elem a ls :: Constraint Source
class HasJQ layout where Source
HasJQ Raw | |
(HasJQ a, HasJQ b) => HasJQ ((:<|>) a b) | |
Elem JSON list => HasJQ (Get list a) | |
Elem JSON list => HasJQ (Post list a) | |
Elem JSON list => HasJQ (Delete list a) | |
Elem JSON list => HasJQ (Put list a) | |
(KnownSymbol sym, HasJQ sublayout) => HasJQ ((:>) * * (Capture * sym a) sublayout) | |
(KnownSymbol sym, HasJQ sublayout) => HasJQ ((:>) * * (Header sym a) sublayout) | |
(KnownSymbol sym, HasJQ sublayout) => HasJQ ((:>) * * (QueryParam * sym a) sublayout) | |
(KnownSymbol sym, HasJQ sublayout) => HasJQ ((:>) * * (QueryParams * sym a) sublayout) | |
(KnownSymbol sym, HasJQ sublayout) => HasJQ ((:>) * * (QueryFlag sym) sublayout) | |
(Elem JSON list, HasJQ sublayout) => HasJQ ((:>) * * (ReqBody * list a) sublayout) | |
(KnownSymbol sym, HasJQ sublayout) => HasJQ ((:>) * * (MatrixParam * sym a) sublayout) | |
(KnownSymbol sym, HasJQ sublayout) => HasJQ ((:>) * * (MatrixParams * sym a) sublayout) | |
(KnownSymbol sym, HasJQ sublayout) => HasJQ ((:>) * * (MatrixFlag sym) sublayout) | |
(KnownSymbol path, HasJQ sublayout) => HasJQ ((:>) Symbol * path sublayout) |
class GenerateCode reqs where Source
Utility class used by jsForAPI
which will
directly hand you all the Javascript code
instead of handing you a :<|>
-separated list
of AjaxReq
like jquery
and then having to
use generateJS
on each AjaxReq
.
GenerateCode AjaxReq | |
GenerateCode rest => GenerateCode ((:<|>) AjaxReq rest) |