Add JSON fields to Text module
parent
7fcef60ec6
commit
b0026617cf
|
@ -149,7 +149,39 @@ finishTask uftask =
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|> C.catchWith
|
|> C.catchWith
|
||||||
(\_ ->
|
(\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?
|
{ messages = [] -- TODO: Maybe categorize errors?
|
||||||
, logs = [ log.warn "Encountered unhandled error" ]
|
, logs = [ log.warn "Encountered unhandled error" ]
|
||||||
, contextChange = Context.reset
|
, contextChange = Context.reset
|
||||||
|
|
|
@ -112,7 +112,8 @@ decodedDictSize from to =
|
||||||
{-| Documentation used for all functions and data types in JSON coders
|
{-| Documentation used for all functions and data types in JSON coders
|
||||||
-}
|
-}
|
||||||
docs :
|
docs :
|
||||||
{ context : TypeDocs
|
{ accessToken : TypeDocs
|
||||||
|
, context : TypeDocs
|
||||||
, envelope : TypeDocs
|
, envelope : TypeDocs
|
||||||
, event : TypeDocs
|
, event : TypeDocs
|
||||||
, hashdict : TypeDocs
|
, hashdict : TypeDocs
|
||||||
|
@ -127,9 +128,16 @@ docs :
|
||||||
, timelineFilter : TypeDocs
|
, timelineFilter : TypeDocs
|
||||||
, unsigned : TypeDocs
|
, unsigned : TypeDocs
|
||||||
, vault : TypeDocs
|
, vault : TypeDocs
|
||||||
|
, versions : TypeDocs
|
||||||
}
|
}
|
||||||
docs =
|
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"
|
{ name = "Context"
|
||||||
, description =
|
, description =
|
||||||
[ "The Context is the set of variables that the user (mostly) cannot control."
|
[ "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."
|
[ "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.
|
what they do and what they are for.
|
||||||
-}
|
-}
|
||||||
fields :
|
fields :
|
||||||
{ context :
|
{ accessToken :
|
||||||
|
{ created : Desc
|
||||||
|
, expiryMs : Desc
|
||||||
|
, lastUsed : Desc
|
||||||
|
, refresh : Desc
|
||||||
|
, value : Desc
|
||||||
|
}
|
||||||
|
, context :
|
||||||
{ accessToken : Desc
|
{ accessToken : Desc
|
||||||
, baseUrl : Desc
|
, baseUrl : Desc
|
||||||
|
, deviceId : Desc
|
||||||
, experimental : Desc
|
, experimental : Desc
|
||||||
|
, now : Desc
|
||||||
, password : Desc
|
, password : Desc
|
||||||
, refreshToken : Desc
|
, refreshToken : Desc
|
||||||
, username : Desc
|
, username : Desc
|
||||||
, serverName : Desc
|
, serverName : Desc
|
||||||
|
, suggestedAccessToken : Desc
|
||||||
, transaction : Desc
|
, transaction : Desc
|
||||||
, versions : Desc
|
, versions : Desc
|
||||||
}
|
}
|
||||||
|
@ -321,25 +345,51 @@ fields :
|
||||||
, vault :
|
, vault :
|
||||||
{ accountData : Desc
|
{ accountData : Desc
|
||||||
, rooms : Desc
|
, rooms : Desc
|
||||||
|
, user : Desc
|
||||||
|
}
|
||||||
|
, versions :
|
||||||
|
{ unstableFeatures : Desc
|
||||||
|
, versions : Desc
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
fields =
|
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 =
|
{ accessToken =
|
||||||
[ "The access token used for authentication with the Matrix server."
|
[ "The access token used for authentication with the Matrix server."
|
||||||
]
|
]
|
||||||
, baseUrl =
|
, baseUrl =
|
||||||
[ "The base URL of the Matrix server."
|
[ "The base URL of the Matrix server."
|
||||||
]
|
]
|
||||||
|
, deviceId =
|
||||||
|
[ "The reported device ID according to the API."
|
||||||
|
]
|
||||||
, experimental =
|
, experimental =
|
||||||
[ "Experimental features supported by the homeserver."
|
[ "Experimental features supported by the homeserver."
|
||||||
]
|
]
|
||||||
|
, now =
|
||||||
|
[ "The most recently found timestamp."
|
||||||
|
]
|
||||||
, password =
|
, password =
|
||||||
[ "The user's password for authentication purposes."
|
[ "The user's password for authentication purposes."
|
||||||
]
|
]
|
||||||
, refreshToken =
|
, refreshToken =
|
||||||
[ "The token used to obtain a new access token upon expiration of the current access token."
|
[ "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 =
|
, username =
|
||||||
[ "The username of the Matrix account."
|
[ "The username of the Matrix account."
|
||||||
]
|
]
|
||||||
|
@ -510,6 +560,16 @@ fields =
|
||||||
, rooms =
|
, rooms =
|
||||||
[ "Directory of joined rooms that the user is a member of."
|
[ "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
|
(Json.field.optional.value
|
||||||
{ fieldName = "deviceId"
|
{ fieldName = "deviceId"
|
||||||
, toField = .deviceId
|
, toField = .deviceId
|
||||||
, description = Debug.todo "Needs docs"
|
, description = Text.fields.context.deviceId
|
||||||
, coder = Json.string
|
, coder = Json.string
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
(Json.field.optional.value
|
(Json.field.optional.value
|
||||||
{ fieldName = "now"
|
{ fieldName = "now"
|
||||||
, toField = .now
|
, toField = .now
|
||||||
, description = Debug.todo "Needs docs"
|
, description = Text.fields.context.now
|
||||||
, coder = Timestamp.coder
|
, coder = Timestamp.coder
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
@ -209,7 +209,7 @@ coder =
|
||||||
(Json.field.optional.value
|
(Json.field.optional.value
|
||||||
{ fieldName = "suggestedAccessToken"
|
{ fieldName = "suggestedAccessToken"
|
||||||
, toField = always Nothing -- Do not save
|
, toField = always Nothing -- Do not save
|
||||||
, description = Debug.todo "Needs docs"
|
, description = Text.fields.context.suggestedAccessToken
|
||||||
, coder = Json.string
|
, coder = Json.string
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
@ -241,42 +241,42 @@ coder =
|
||||||
coderAccessToken : Json.Coder AccessToken
|
coderAccessToken : Json.Coder AccessToken
|
||||||
coderAccessToken =
|
coderAccessToken =
|
||||||
Json.object5
|
Json.object5
|
||||||
{ name = Debug.todo "Needs docs"
|
{ name = Text.docs.accessToken.name
|
||||||
, description = Debug.todo "Needs docs"
|
, description = Text.docs.accessToken.description
|
||||||
, init = AccessToken
|
, init = AccessToken
|
||||||
}
|
}
|
||||||
(Json.field.required
|
(Json.field.required
|
||||||
{ fieldName = "created"
|
{ fieldName = "created"
|
||||||
, toField = .created
|
, toField = .created
|
||||||
, description = Debug.todo "Needs docs"
|
, description = Text.fields.accessToken.created
|
||||||
, coder = Timestamp.coder
|
, coder = Timestamp.coder
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
(Json.field.optional.value
|
(Json.field.optional.value
|
||||||
{ fieldName = "expiryMs"
|
{ fieldName = "expiryMs"
|
||||||
, toField = .expiryMs
|
, toField = .expiryMs
|
||||||
, description = Debug.todo "Needs docs"
|
, description = Text.fields.accessToken.expiryMs
|
||||||
, coder = Json.int
|
, coder = Json.int
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
(Json.field.required
|
(Json.field.required
|
||||||
{ fieldName = "lastUsed"
|
{ fieldName = "lastUsed"
|
||||||
, toField = .lastUsed
|
, toField = .lastUsed
|
||||||
, description = Debug.todo "Needs docs"
|
, description = Text.fields.accessToken.lastUsed
|
||||||
, coder = Timestamp.coder
|
, coder = Timestamp.coder
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
(Json.field.optional.value
|
(Json.field.optional.value
|
||||||
{ fieldName = "refresh"
|
{ fieldName = "refresh"
|
||||||
, toField = .refresh
|
, toField = .refresh
|
||||||
, description = Debug.todo "Needs docs"
|
, description = Text.fields.accessToken.refresh
|
||||||
, coder = Json.string
|
, coder = Json.string
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
(Json.field.required
|
(Json.field.required
|
||||||
{ fieldName = "value"
|
{ fieldName = "value"
|
||||||
, toField = .value
|
, toField = .value
|
||||||
, description = Debug.todo "Needs docs"
|
, description = Text.fields.accessToken.value
|
||||||
, coder = Json.string
|
, coder = Json.string
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
@ -422,21 +422,21 @@ setVersions value (APIContext c) =
|
||||||
versionsCoder : Json.Coder Versions
|
versionsCoder : Json.Coder Versions
|
||||||
versionsCoder =
|
versionsCoder =
|
||||||
Json.object2
|
Json.object2
|
||||||
{ name = Debug.todo "Add name" -- Text.docs.versions.name
|
{ name = Text.docs.versions.name
|
||||||
, description = Debug.todo "Add description" -- Text.docs.versions.description
|
, description = Text.docs.versions.description
|
||||||
, init = Versions
|
, init = Versions
|
||||||
}
|
}
|
||||||
(Json.field.required
|
(Json.field.required
|
||||||
{ fieldName = "versions"
|
{ fieldName = "versions"
|
||||||
, toField = .versions
|
, toField = .versions
|
||||||
, description = Debug.todo "Add description"
|
, description = Text.fields.versions.versions
|
||||||
, coder = Json.list Json.string
|
, coder = Json.list Json.string
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
(Json.field.optional.withDefault
|
(Json.field.optional.withDefault
|
||||||
{ fieldName = "unstableFeatures"
|
{ fieldName = "unstableFeatures"
|
||||||
, toField = .unstableFeatures
|
, toField = .unstableFeatures
|
||||||
, description = Debug.todo "Add description"
|
, description = Text.fields.versions.unstableFeatures
|
||||||
, coder = Json.set Json.string
|
, coder = Json.set Json.string
|
||||||
, default = ( Set.empty, [] )
|
, default = ( Set.empty, [] )
|
||||||
, defaultToString = Json.encode (Json.set Json.string) >> E.encode 0
|
, defaultToString = Json.encode (Json.set Json.string) >> E.encode 0
|
||||||
|
|
|
@ -84,7 +84,7 @@ coder =
|
||||||
(Json.field.required
|
(Json.field.required
|
||||||
{ fieldName = "user"
|
{ fieldName = "user"
|
||||||
, toField = .user
|
, toField = .user
|
||||||
, description = Debug.todo "Needs description"
|
, description = Text.fields.vault.user
|
||||||
, coder = User.coder
|
, coder = User.coder
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
Loading…
Reference in New Issue