From 1fa68a0ad817741955776473ca5692657e5c328a Mon Sep 17 00:00:00 2001 From: Lucy Cifferello <12953208+elvece@users.noreply.github.com> Date: Tue, 11 May 2021 22:16:25 -0600 Subject: [PATCH 1/3] get system status endpoint --- config/routes | 3 ++- src/Handler/Types/Status.hs | 21 +++++++++++++++++++++ src/Handler/Version.hs | 5 +++++ src/Lib/Registry.hs | 1 + 4 files changed, 29 insertions(+), 1 deletion(-) diff --git a/config/routes b/config/routes index 50d46b9..e5b5994 100644 --- a/config/routes +++ b/config/routes @@ -12,4 +12,5 @@ /icons/#PNG IconsR GET -- get icons !/apps/#S9PK AppR GET -- get most recent appId at appversion spec, defaults to >=0.0.0 -- ?spec={semver-spec} -!/sys/#SYS_EXTENSIONLESS SysR GET -- get most recent sys app -- ?spec={semver-spec} \ No newline at end of file +!/sys/#SYS_EXTENSIONLESS SysR GET -- get most recent sys app -- ?spec={semver-spec} +/sys/status SystemStatusR GET -- get system update status and version \ No newline at end of file diff --git a/src/Handler/Types/Status.hs b/src/Handler/Types/Status.hs index cada3de..24a8c63 100644 --- a/src/Handler/Types/Status.hs +++ b/src/Handler/Types/Status.hs @@ -1,3 +1,4 @@ +{-# LANGUAGE RecordWildCards #-} {-# LANGUAGE FlexibleInstances #-} {-# LANGUAGE NamedFieldPuns #-} module Handler.Types.Status where @@ -9,6 +10,7 @@ import Yesod.Core.Content import Lib.Types.Emver import Orphans.Emver ( ) +import Data.Text data AppVersionRes = AppVersionRes { appVersionVersion :: Version @@ -35,3 +37,22 @@ instance ToContent (Maybe AppVersionRes) where toContent = toContent . toJSON instance ToTypedContent (Maybe AppVersionRes) where toTypedContent = toTypedContent . toJSON + +-- status - nothing, available, instuctions +-- version - semver string + +data SystemStatus = NOTHING | AVAILABLE | INSTRUCTIONS + deriving (Eq, Show) +instance ToJSON SystemStatus where + toJSON = String . toLower . show + +data OSVersionRes = OSVersionRes + { osVersionStatus :: SystemStatus + , osVersionVersion :: Version + } deriving (Eq, Show) +instance ToJSON OSVersionRes where + toJSON OSVersionRes { .. } = object ["status" .= osVersionStatus, "version" .= osVersionVersion] +instance ToContent OSVersionRes where + toContent = toContent . toJSON +instance ToTypedContent OSVersionRes where + toTypedContent = toTypedContent . toJSON \ No newline at end of file diff --git a/src/Handler/Version.hs b/src/Handler/Version.hs index 4886c19..9c314ee 100644 --- a/src/Handler/Version.hs +++ b/src/Handler/Version.hs @@ -44,3 +44,8 @@ getVersionWSpec :: KnownSymbol a => FilePath -> Extension a -> Handler (Maybe Ap getVersionWSpec rootDir ext = do av <- getVersionFromQuery rootDir ext pure $ liftA3 AppVersionRes av (pure Nothing) (pure Nothing) + +getSystemStatusR :: Handler OSVersionRes +getSystemStatusR = do + -- hardcoded since this will be last OS version release on this registry before 1.0 + pure $ OSVersionRes NOTHING $ Version (0,2,13,0) \ No newline at end of file diff --git a/src/Lib/Registry.hs b/src/Lib/Registry.hs index 15694c5..d586245 100644 --- a/src/Lib/Registry.hs +++ b/src/Lib/Registry.hs @@ -37,6 +37,7 @@ getAvailableAppVersions rootDirectory ext@(Extension appId) = do getSubDirectories path = (fmap (fromRight []) . try @SomeException $ listDirectory path) >>= filterM (doesDirectoryExist . (path )) +-- this works for both service versions and embassyOS versions getMostRecentAppVersion :: KnownSymbol a => FilePath -> Extension a -> IO (Maybe RegisteredAppVersion) getMostRecentAppVersion rootDirectory ext = do allVersions <- liftIO $ getAvailableAppVersions rootDirectory ext From cd4d392a74b32746ac950599e5f32200d6b5ac74 Mon Sep 17 00:00:00 2001 From: Lucy Cifferello <12953208+elvece@users.noreply.github.com> Date: Wed, 12 May 2021 09:11:10 -0600 Subject: [PATCH 2/3] route ordering --- config/routes | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/config/routes b/config/routes index e5b5994..99210a6 100644 --- a/config/routes +++ b/config/routes @@ -12,5 +12,5 @@ /icons/#PNG IconsR GET -- get icons !/apps/#S9PK AppR GET -- get most recent appId at appversion spec, defaults to >=0.0.0 -- ?spec={semver-spec} -!/sys/#SYS_EXTENSIONLESS SysR GET -- get most recent sys app -- ?spec={semver-spec} -/sys/status SystemStatusR GET -- get system update status and version \ No newline at end of file +/sys/status SystemStatusR GET -- get system update status and version +!/sys/#SYS_EXTENSIONLESS SysR GET -- get most recent sys app -- ?spec={semver-spec} \ No newline at end of file From b362fcf6574cf4df1603251fb8ac189a38c0447e Mon Sep 17 00:00:00 2001 From: Lucy Cifferello <12953208+elvece@users.noreply.github.com> Date: Wed, 12 May 2021 10:49:28 -0600 Subject: [PATCH 3/3] update version number --- src/Handler/Version.hs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Handler/Version.hs b/src/Handler/Version.hs index 9c314ee..c71ff76 100644 --- a/src/Handler/Version.hs +++ b/src/Handler/Version.hs @@ -47,5 +47,5 @@ getVersionWSpec rootDir ext = do getSystemStatusR :: Handler OSVersionRes getSystemStatusR = do - -- hardcoded since this will be last OS version release on this registry before 1.0 - pure $ OSVersionRes NOTHING $ Version (0,2,13,0) \ No newline at end of file + -- hardcoded to the next major version release so the UI can by dynamic. this might change depending on the version number we decide to release. + pure $ OSVersionRes NOTHING $ Version (1,0,0,0) \ No newline at end of file