-- Generated by scripts/generate.mjs. Do not edit. module Dagger.JSONValue ( asArray , asBoolean , asInteger , asString , contents , contentsWith , ContentsOpts , defaultContentsOpts , field , fields , id , newBoolean , newInteger , newString , withContents , withField ) where import Data.Maybe (Maybe(..)) import Effect.Aff (Aff) import Dagger.Internal.Runtime as R import Dagger.Types as T -- | Decode an array from json asArray :: T.JSONValue -> Aff (Array T.JSONValue) asArray = R.objectList "JSONValue" "asArray" [] -- | Decode a boolean from json asBoolean :: T.JSONValue -> Aff Boolean asBoolean = R.scalar "asBoolean" [] -- | Decode an integer from json asInteger :: T.JSONValue -> Aff Int asInteger = R.scalar "asInteger" [] -- | Decode a string from json asString :: T.JSONValue -> Aff String asString = R.scalar "asString" [] type ContentsOpts = { pretty :: Maybe Boolean , indent :: Maybe String } defaultContentsOpts :: ContentsOpts defaultContentsOpts = { pretty: Nothing , indent: Nothing } -- | Return the value encoded as json contents :: T.JSONValue -> Aff T.JSON contents = contentsWith defaultContentsOpts -- | Return the value encoded as json contentsWith :: ContentsOpts -> T.JSONValue -> Aff T.JSON contentsWith opts = R.scalar "contents" [R.optional (R.argument "pretty" "Boolean") opts.pretty, R.optional (R.argument "indent" "String") opts.indent] -- | Lookup the field at the given path, and return its value. field :: (Array String) -> T.JSONValue -> T.JSONValue field argPath = R.select "field" [R.argument "path" "[String!]!" argPath] -- | List fields of the encoded object fields :: T.JSONValue -> Aff (Array String) fields = R.scalar "fields" [] -- | A unique identifier for this JSONValue. id :: T.JSONValue -> Aff T.ID id = R.scalar "id" [] -- | Encode a boolean to json newBoolean :: Boolean -> T.JSONValue -> T.JSONValue newBoolean argValue = R.select "newBoolean" [R.argument "value" "Boolean!" argValue] -- | Encode an integer to json newInteger :: Int -> T.JSONValue -> T.JSONValue newInteger argValue = R.select "newInteger" [R.argument "value" "Int!" argValue] -- | Encode a string to json newString :: String -> T.JSONValue -> T.JSONValue newString argValue = R.select "newString" [R.argument "value" "String!" argValue] -- | Return a new json value, decoded from the given content withContents :: T.JSON -> T.JSONValue -> T.JSONValue withContents argContents = R.select "withContents" [R.argument "contents" "JSON!" argContents] -- | Set a new field at the given path withField :: (Array String) -> T.JSONValue -> T.JSONValue -> T.JSONValue withField argPath argValue = R.select "withField" [R.argument "path" "[String!]!" argPath, R.objectArgument "value" "ID!" argValue]