diff --git a/agent/src/Lib/Types/Emver.hs b/agent/src/Lib/Types/Emver.hs index 0cceeed9e..534d6642c 100644 --- a/agent/src/Lib/Types/Emver.hs +++ b/agent/src/Lib/Types/Emver.hs @@ -56,6 +56,8 @@ instance Show Version where let postfix = if q == 0 then "" else '.' : show q in show x <> "." <> show y <> "." <> show z <> postfix instance IsString Version where fromString s = either error id $ Atto.parseOnly parseVersion (T.pack s) +instance Read Version where + readsPrec i = -- | A change in the value found at 'major' implies a breaking change in the API that this version number describes major :: Version -> Word diff --git a/agent/src/Lib/Types/Emver/Orphans.hs b/agent/src/Lib/Types/Emver/Orphans.hs index 1af62533d..84c04956c 100644 --- a/agent/src/Lib/Types/Emver/Orphans.hs +++ b/agent/src/Lib/Types/Emver/Orphans.hs @@ -3,16 +3,17 @@ module Lib.Types.Emver.Orphans where import Startlude +import Control.Monad.Fail import Data.Aeson - -import Lib.Types.Emver +import qualified Data.Attoparsec.Text as Atto +import qualified Data.Text as T import Database.Persist import Database.Persist.Sql -import qualified Data.Attoparsec.Text as Atto -import Control.Monad.Fail -import qualified Data.Text as T +import Web.HttpApiData import Yesod.Core.Dispatch +import Lib.Types.Emver + instance ToJSON Version where toJSON = String . show instance FromJSON Version where @@ -38,3 +39,10 @@ instance PersistFieldSql Version where instance PathPiece VersionRange where toPathPiece = show fromPathPiece = hush . Atto.parseOnly parseRange + +instance FromHttpApiData Version where + parseUrlPiece = first toS . Atto.parseOnly parseVersion + +instance PathPiece Version where + toPathPiece = show + fromPathPiece = hush . Atto.parseOnly parseVersion diff --git a/agent/src/Model.hs b/agent/src/Model.hs index 308c813d1..336548d7d 100644 --- a/agent/src/Model.hs +++ b/agent/src/Model.hs @@ -59,4 +59,7 @@ BackupRecord sql=backup IconDigest Id AppId tag (Digest MD5) + +WelcomeAck + Id Version |]