Add JSON fields to Text module
parent
7fcef60ec6
commit
b0026617cf
|
@ -149,11 +149,43 @@ finishTask uftask =
|
|||
}
|
||||
)
|
||||
|> C.catchWith
|
||||
(\_ ->
|
||||
{ messages = [] -- TODO: Maybe categorize errors?
|
||||
, logs = [ log.warn "Encountered unhandled error" ]
|
||||
, contextChange = Context.reset
|
||||
}
|
||||
(\e ->
|
||||
case e of
|
||||
Request.MissingPassword ->
|
||||
{ messages = []
|
||||
, logs = [ log.error "Cannot log in - password is missing" ]
|
||||
, contextChange = Context.reset
|
||||
}
|
||||
|
||||
Request.MissingUsername ->
|
||||
{ messages = []
|
||||
, logs = [ log.error "Cannot log in - username is missing" ]
|
||||
, contextChange = Context.reset
|
||||
}
|
||||
|
||||
Request.NoSupportedVersion ->
|
||||
{ messages = []
|
||||
, logs = [ log.error "No supported version is available to complete the API interaction." ]
|
||||
, contextChange = Context.reset
|
||||
}
|
||||
|
||||
Request.ServerReturnsBadJSON t ->
|
||||
{ messages = []
|
||||
, logs = [ log.error ("The server returned invalid JSON: " ++ t) ]
|
||||
, contextChange = Context.reset
|
||||
}
|
||||
|
||||
Request.ServerReturnsError name _ ->
|
||||
{ messages = []
|
||||
, logs = [ log.error ("The server returns an error: " ++ name) ]
|
||||
, contextChange = Context.reset
|
||||
}
|
||||
|
||||
_ ->
|
||||
{ messages = [] -- TODO: Maybe categorize errors?
|
||||
, logs = [ log.warn "Encountered unhandled error" ]
|
||||
, contextChange = Context.reset
|
||||
}
|
||||
)
|
||||
|
||||
|
||||
|
|
|
@ -112,7 +112,8 @@ decodedDictSize from to =
|
|||
{-| Documentation used for all functions and data types in JSON coders
|
||||
-}
|
||||
docs :
|
||||
{ context : TypeDocs
|
||||
{ accessToken : TypeDocs
|
||||
, context : TypeDocs
|
||||
, envelope : TypeDocs
|
||||
, event : TypeDocs
|
||||
, hashdict : TypeDocs
|
||||
|
@ -127,9 +128,16 @@ docs :
|
|||
, timelineFilter : TypeDocs
|
||||
, unsigned : TypeDocs
|
||||
, vault : TypeDocs
|
||||
, versions : TypeDocs
|
||||
}
|
||||
docs =
|
||||
{ context =
|
||||
{ accessToken =
|
||||
{ name = "Access Token"
|
||||
, description =
|
||||
[ "The Access Token type stores information about an access token - its value, when it expires, and how one may get a new access token when the current value expires."
|
||||
]
|
||||
}
|
||||
, context =
|
||||
{ name = "Context"
|
||||
, description =
|
||||
[ "The Context is the set of variables that the user (mostly) cannot control."
|
||||
|
@ -223,6 +231,12 @@ docs =
|
|||
[ "Main type storing all relevant information from the Matrix API."
|
||||
]
|
||||
}
|
||||
, versions =
|
||||
{ name = "Versions"
|
||||
, description =
|
||||
[ "Versions type describing the supported spec versions and MSC properties."
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -244,14 +258,24 @@ failures =
|
|||
what they do and what they are for.
|
||||
-}
|
||||
fields :
|
||||
{ context :
|
||||
{ accessToken :
|
||||
{ created : Desc
|
||||
, expiryMs : Desc
|
||||
, lastUsed : Desc
|
||||
, refresh : Desc
|
||||
, value : Desc
|
||||
}
|
||||
, context :
|
||||
{ accessToken : Desc
|
||||
, baseUrl : Desc
|
||||
, deviceId : Desc
|
||||
, experimental : Desc
|
||||
, now : Desc
|
||||
, password : Desc
|
||||
, refreshToken : Desc
|
||||
, username : Desc
|
||||
, serverName : Desc
|
||||
, suggestedAccessToken : Desc
|
||||
, transaction : Desc
|
||||
, versions : Desc
|
||||
}
|
||||
|
@ -321,25 +345,51 @@ fields :
|
|||
, vault :
|
||||
{ accountData : Desc
|
||||
, rooms : Desc
|
||||
, user : Desc
|
||||
}
|
||||
, versions :
|
||||
{ unstableFeatures : Desc
|
||||
, versions : Desc
|
||||
}
|
||||
}
|
||||
fields =
|
||||
{ context =
|
||||
{ accessToken =
|
||||
{ created =
|
||||
[ "Timestamp of when the access token was received." ]
|
||||
, expiryMs =
|
||||
[ "Given time in milliseconds of when the access token might expire." ]
|
||||
, lastUsed =
|
||||
[ "Timestamp of when the access token was last used." ]
|
||||
, refresh =
|
||||
[ "Refresh token used to gain a new access token." ]
|
||||
, value =
|
||||
[ "Secret access token value." ]
|
||||
}
|
||||
, context =
|
||||
{ accessToken =
|
||||
[ "The access token used for authentication with the Matrix server."
|
||||
]
|
||||
, baseUrl =
|
||||
[ "The base URL of the Matrix server."
|
||||
]
|
||||
, deviceId =
|
||||
[ "The reported device ID according to the API."
|
||||
]
|
||||
, experimental =
|
||||
[ "Experimental features supported by the homeserver."
|
||||
]
|
||||
, now =
|
||||
[ "The most recently found timestamp."
|
||||
]
|
||||
, password =
|
||||
[ "The user's password for authentication purposes."
|
||||
]
|
||||
, refreshToken =
|
||||
[ "The token used to obtain a new access token upon expiration of the current access token."
|
||||
]
|
||||
, suggestedAccessToken =
|
||||
[ "An access token provided with no context by the user."
|
||||
]
|
||||
, username =
|
||||
[ "The username of the Matrix account."
|
||||
]
|
||||
|
@ -510,6 +560,16 @@ fields =
|
|||
, rooms =
|
||||
[ "Directory of joined rooms that the user is a member of."
|
||||
]
|
||||
, user =
|
||||
[ "User that the Vault is logging in as."
|
||||
]
|
||||
}
|
||||
, versions =
|
||||
{ unstableFeatures =
|
||||
[ "Unstable features such as experimental MSCs that are supported by a homeserver."
|
||||
]
|
||||
, versions =
|
||||
[ "Spec versions supported by a homeserver." ]
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -174,14 +174,14 @@ coder =
|
|||
(Json.field.optional.value
|
||||
{ fieldName = "deviceId"
|
||||
, toField = .deviceId
|
||||
, description = Debug.todo "Needs docs"
|
||||
, description = Text.fields.context.deviceId
|
||||
, coder = Json.string
|
||||
}
|
||||
)
|
||||
(Json.field.optional.value
|
||||
{ fieldName = "now"
|
||||
, toField = .now
|
||||
, description = Debug.todo "Needs docs"
|
||||
, description = Text.fields.context.now
|
||||
, coder = Timestamp.coder
|
||||
}
|
||||
)
|
||||
|
@ -209,7 +209,7 @@ coder =
|
|||
(Json.field.optional.value
|
||||
{ fieldName = "suggestedAccessToken"
|
||||
, toField = always Nothing -- Do not save
|
||||
, description = Debug.todo "Needs docs"
|
||||
, description = Text.fields.context.suggestedAccessToken
|
||||
, coder = Json.string
|
||||
}
|
||||
)
|
||||
|
@ -241,42 +241,42 @@ coder =
|
|||
coderAccessToken : Json.Coder AccessToken
|
||||
coderAccessToken =
|
||||
Json.object5
|
||||
{ name = Debug.todo "Needs docs"
|
||||
, description = Debug.todo "Needs docs"
|
||||
{ name = Text.docs.accessToken.name
|
||||
, description = Text.docs.accessToken.description
|
||||
, init = AccessToken
|
||||
}
|
||||
(Json.field.required
|
||||
{ fieldName = "created"
|
||||
, toField = .created
|
||||
, description = Debug.todo "Needs docs"
|
||||
, description = Text.fields.accessToken.created
|
||||
, coder = Timestamp.coder
|
||||
}
|
||||
)
|
||||
(Json.field.optional.value
|
||||
{ fieldName = "expiryMs"
|
||||
, toField = .expiryMs
|
||||
, description = Debug.todo "Needs docs"
|
||||
, description = Text.fields.accessToken.expiryMs
|
||||
, coder = Json.int
|
||||
}
|
||||
)
|
||||
(Json.field.required
|
||||
{ fieldName = "lastUsed"
|
||||
, toField = .lastUsed
|
||||
, description = Debug.todo "Needs docs"
|
||||
, description = Text.fields.accessToken.lastUsed
|
||||
, coder = Timestamp.coder
|
||||
}
|
||||
)
|
||||
(Json.field.optional.value
|
||||
{ fieldName = "refresh"
|
||||
, toField = .refresh
|
||||
, description = Debug.todo "Needs docs"
|
||||
, description = Text.fields.accessToken.refresh
|
||||
, coder = Json.string
|
||||
}
|
||||
)
|
||||
(Json.field.required
|
||||
{ fieldName = "value"
|
||||
, toField = .value
|
||||
, description = Debug.todo "Needs docs"
|
||||
, description = Text.fields.accessToken.value
|
||||
, coder = Json.string
|
||||
}
|
||||
)
|
||||
|
@ -422,21 +422,21 @@ setVersions value (APIContext c) =
|
|||
versionsCoder : Json.Coder Versions
|
||||
versionsCoder =
|
||||
Json.object2
|
||||
{ name = Debug.todo "Add name" -- Text.docs.versions.name
|
||||
, description = Debug.todo "Add description" -- Text.docs.versions.description
|
||||
{ name = Text.docs.versions.name
|
||||
, description = Text.docs.versions.description
|
||||
, init = Versions
|
||||
}
|
||||
(Json.field.required
|
||||
{ fieldName = "versions"
|
||||
, toField = .versions
|
||||
, description = Debug.todo "Add description"
|
||||
, description = Text.fields.versions.versions
|
||||
, coder = Json.list Json.string
|
||||
}
|
||||
)
|
||||
(Json.field.optional.withDefault
|
||||
{ fieldName = "unstableFeatures"
|
||||
, toField = .unstableFeatures
|
||||
, description = Debug.todo "Add description"
|
||||
, description = Text.fields.versions.unstableFeatures
|
||||
, coder = Json.set Json.string
|
||||
, default = ( Set.empty, [] )
|
||||
, defaultToString = Json.encode (Json.set Json.string) >> E.encode 0
|
||||
|
|
|
@ -84,7 +84,7 @@ coder =
|
|||
(Json.field.required
|
||||
{ fieldName = "user"
|
||||
, toField = .user
|
||||
, description = Debug.todo "Needs description"
|
||||
, description = Text.fields.vault.user
|
||||
, coder = User.coder
|
||||
}
|
||||
)
|
||||
|
|
Loading…
Reference in New Issue