mirror of
https://github.com/Start9Labs/registry.git
synced 2026-03-26 02:11:53 +00:00
rewire the api to be clean and consistent (#92)
fix route documentation fix sorting scheme to be more clear for release notes
This commit is contained in:
@@ -1,14 +1,18 @@
|
|||||||
/eos/latest EosVersionR GET -- get eos information
|
-- EOS API V0
|
||||||
/eos/eos.img EosR GET -- get eos.img
|
/eos/v0/latest EosVersionR GET -- get eos information
|
||||||
/latest-version VersionLatestR GET -- get latest version of apps in query param id
|
/eos/v0/eos.img EosR GET -- get eos.img
|
||||||
!/package/#S9PK AppR GET -- get most recent appId at appversion spec, defaults to >=0.0.0 -- ?spec={semver-spec}
|
|
||||||
/package/data InfoR GET -- get all marketplace categories
|
|
||||||
/package/index PackageListR GET -- filter marketplace services by various query params
|
|
||||||
/package/manifest/#PkgId AppManifestR GET -- get app manifest from appmgr -- ?version={semver-spec}
|
|
||||||
/package/release-notes ReleaseNotesR GET -- get release notes for package - expects query param of id=<pacakge-id>
|
|
||||||
/package/icon/#PkgId IconsR GET -- get icons - can specify version with ?spec=<emver>
|
|
||||||
/package/license/#PkgId LicenseR GET -- get icons - can specify version with ?spec=<emver>
|
|
||||||
/package/instructions/#PkgId InstructionsR GET -- get icons - can specify version with ?spec=<emver>
|
|
||||||
/package/version/#PkgId PkgVersionR GET -- get most recent appId version
|
|
||||||
|
|
||||||
/support/error-logs ErrorLogsR POST
|
-- PACKAGE API V0
|
||||||
|
/package/v0/info InfoR GET -- get all marketplace categories
|
||||||
|
/package/v0/index PackageListR GET -- filter marketplace services by various query params
|
||||||
|
/package/v0/latest VersionLatestR GET -- get latest version of apps in query param id
|
||||||
|
!/package/v0/#S9PK AppR GET -- get most recent appId at appversion spec, defaults to >=0.0.0 -- ?spec=<emver>
|
||||||
|
/package/v0/manifest/#PkgId AppManifestR GET -- get app manifest from appmgr -- ?spec=<emver>
|
||||||
|
/package/v0/release-notes/#PkgId ReleaseNotesR GET -- get release notes for all versions of a package
|
||||||
|
/package/v0/icon/#PkgId IconsR GET -- get icons - can specify version with ?spec=<emver>
|
||||||
|
/package/v0/license/#PkgId LicenseR GET -- get license - can specify version with ?spec=<emver>
|
||||||
|
/package/v0/instructions/#PkgId InstructionsR GET -- get instructions - can specify version with ?spec=<emver>
|
||||||
|
/package/v0/version/#PkgId PkgVersionR GET -- get most recent appId version
|
||||||
|
|
||||||
|
-- SUPPORT API V0
|
||||||
|
/support/v0/error-logs ErrorLogsR POST
|
||||||
@@ -87,8 +87,7 @@ import Lib.PkgRepository ( PkgRepo
|
|||||||
, getIcon
|
, getIcon
|
||||||
, getManifest
|
, getManifest
|
||||||
)
|
)
|
||||||
import Lib.Types.AppIndex ( PkgId(PkgId) )
|
import Lib.Types.AppIndex ( PkgId )
|
||||||
import Lib.Types.AppIndex ( )
|
|
||||||
import Lib.Types.Category ( CategoryTitle(..) )
|
import Lib.Types.Category ( CategoryTitle(..) )
|
||||||
import Lib.Types.Emver ( Version
|
import Lib.Types.Emver ( Version
|
||||||
, VersionRange
|
, VersionRange
|
||||||
@@ -167,19 +166,19 @@ getEosVersionR = do
|
|||||||
, eosResReleaseNotes = mappedVersions
|
, eosResReleaseNotes = mappedVersions
|
||||||
}
|
}
|
||||||
|
|
||||||
getReleaseNotesR :: Handler ReleaseNotes
|
getReleaseNotesR :: PkgId -> Handler ReleaseNotes
|
||||||
getReleaseNotesR = do
|
getReleaseNotesR pkg = do
|
||||||
getParameters <- reqGetParams <$> getRequest
|
appConnPool <- appConnPool <$> getYesod
|
||||||
case lookup "id" getParameters of
|
versionRecords <- runDB $ fetchAllAppVersions appConnPool pkg
|
||||||
Nothing -> sendResponseStatus status400 (InvalidParamsE "get:id" "<MISSING>")
|
pure $ constructReleaseNotesApiRes versionRecords
|
||||||
Just package -> do
|
|
||||||
appConnPool <- appConnPool <$> getYesod
|
|
||||||
versionRecords <- runDB $ fetchAllAppVersions appConnPool (PkgId package)
|
|
||||||
pure $ constructReleaseNotesApiRes versionRecords
|
|
||||||
where
|
where
|
||||||
constructReleaseNotesApiRes :: [VersionRecord] -> ReleaseNotes
|
constructReleaseNotesApiRes :: [VersionRecord] -> ReleaseNotes
|
||||||
constructReleaseNotesApiRes vers = do
|
constructReleaseNotesApiRes vers = do
|
||||||
ReleaseNotes $ HM.fromList $ sortOn Down $ (versionRecordNumber &&& versionRecordReleaseNotes) <$> vers
|
ReleaseNotes
|
||||||
|
$ HM.fromList
|
||||||
|
$ sortOn (Down . fst)
|
||||||
|
$ (versionRecordNumber &&& versionRecordReleaseNotes)
|
||||||
|
<$> vers
|
||||||
|
|
||||||
getEosR :: Handler TypedContent
|
getEosR :: Handler TypedContent
|
||||||
getEosR = do
|
getEosR = do
|
||||||
|
|||||||
@@ -68,7 +68,7 @@ instance FromJSON PackageRes where
|
|||||||
packageResDependencies <- o .: "dependency-metadata"
|
packageResDependencies <- o .: "dependency-metadata"
|
||||||
pure PackageRes { .. }
|
pure PackageRes { .. }
|
||||||
data DependencyRes = DependencyRes
|
data DependencyRes = DependencyRes
|
||||||
{ dependencyResTitle :: Text -- TODO switch to `Text` to display actual title in Marketplace. Confirm with FE that this will not break loading. Perhaps return title and id?
|
{ dependencyResTitle :: Text
|
||||||
, dependencyResIcon :: Text
|
, dependencyResIcon :: Text
|
||||||
}
|
}
|
||||||
deriving (Eq, Show)
|
deriving (Eq, Show)
|
||||||
|
|||||||
Reference in New Issue
Block a user