diff --git a/elm.json b/elm.json index d81df1c..c41f50f 100644 --- a/elm.json +++ b/elm.json @@ -7,6 +7,7 @@ "exposed-modules": [ "Matrix", "Internal.Config.Default", + "Internal.Config.Text", "Internal.Tools.Hashdict", "Internal.Tools.Iddict", "Internal.Tools.Timestamp", diff --git a/src/Internal/Config/Text.elm b/src/Internal/Config/Text.elm new file mode 100644 index 0000000..f8bc7c2 --- /dev/null +++ b/src/Internal/Config/Text.elm @@ -0,0 +1,108 @@ +module Internal.Config.Text exposing + ( versionsFoundLocally, versionsReceived, versionsFailedToDecode + , accessTokenFoundLocally, accessTokenExpired, accessTokenInvalid + , unsupportedVersionForEndpoint + ) + +{-| Throughout the Elm SDK, there are lots of pieces of text being used for +various purposes. Some of these are: + + - To log on what is happening during an API call. + - To fail with custom decoder errors. + - To describe custom values in a human readable format. + +All magic values of text are gathered in this module, to form a monolithic +source of text. This allows people to learn more about the Elm SDK, and it + + +## API Versions + +Messages sent as API logs while the Elm SDK is figuring out how modern the +homeserver is and how it can best communicate. + +@docs versionsFoundLocally, versionsReceived, versionsFailedToDecode + + +## API Authentication + +Messages sent as API logs during the authentication phase of the API +interaction. + +@docs accessTokenFoundLocally, accessTokenExpired, accessTokenInvalid + +offers room for translation, re-wording and refactors. + + +## API miscellaneous messages + +Messages sent as API logs during communication with the API. + +@docs unsupportedVersionForEndpoint + +-} + + +{-| Logs when the Matrix API returns that an access token is no longer valid. +-} +accessTokenExpired : String +accessTokenExpired = + "Matrix API reports access token as no longer valid" + + +{-| Logs when the Vault has an access token that is still (locally) considered +valid. +-} +accessTokenFoundLocally : String +accessTokenFoundLocally = + "Found locally cached access token" + + +{-| Logs when the Matrix API rejects an access token without explicitly +mentioning a reason. +-} +accessTokenInvalid : String +accessTokenInvalid = + "Matrix API rejected access token as invalid" + + +{-| The Matrix homeserver can specify how it wishes to communicate, and the Elm +SDK aims to communicate accordingly. This may fail in some scenarios, however, +in which case it will throw this error. + +Most of the time, the error is caused by one of two options: + +1. The homeserver is very archaic and does not (yet) support API endpoints that + are nowadays considered mature. + +2. The homeserver is much more modern than the Elm SDK and either uses + exclusively API endpoints that the Elm SDK doesn't (yet) support, or it uses + spec versions that aren't considered "official" Matrix spec versions and + were designed by a third party. + +-} +unsupportedVersionForEndpoint : String +unsupportedVersionForEndpoint = + "This Matrix homeserver and the Elm SDK do not share a common spec version for this endpoint" + + +{-| Occasionally, the Matrix homeserver fails to communicate how it is best +communicated with. Most of the time, this means that the homeserver is somehow +unreachable or some gateway error has occured. +-} +versionsFailedToDecode : String +versionsFailedToDecode = + "Matrix API returned an invalid version list" + + +{-| Logs when the Vault remembers how to communicate with the Matrix homeserver +-} +versionsFoundLocally : String +versionsFoundLocally = + "Found locally cached version list" + + +{-| Logs when the Matrix API has returned how to best communicate with them +-} +versionsReceived : String +versionsReceived = + "Matrix API returned a version list"