aur 6.1.0 → 6.1.0.1
raw patch · 8 files changed
+218/−205 lines, 8 filesdep ~aesondep ~basedep ~errorsPVP ok
version bump matches the API change (PVP)
Dependency ranges changed: aeson, base, errors, http-client, http-client-tls, servant, servant-client, tasty
API changes (from Hackage documentation)
Files
- CHANGELOG.md +4/−0
- Linux/Arch/Aur.hs +0/−6
- Linux/Arch/Aur/Rpc.hs +0/−55
- Linux/Arch/Aur/Types.hs +0/−105
- aur.cabal +44/−39
- lib/Linux/Arch/Aur.hs +6/−0
- lib/Linux/Arch/Aur/Rpc.hs +59/−0
- lib/Linux/Arch/Aur/Types.hs +105/−0
CHANGELOG.md view
@@ -1,5 +1,9 @@ # Changelog +## 6.1.0.1++- Massaged various bounds for future-proofing.+ ## 6.1.0 - RPC functions now return in `Maybe`, for occasions where connection to the AUR
− Linux/Arch/Aur.hs
@@ -1,6 +0,0 @@-module Linux.Arch.Aur- ( module Linux.Arch.Aur.Rpc- , module Linux.Arch.Aur.Types ) where--import Linux.Arch.Aur.Rpc-import Linux.Arch.Aur.Types
− Linux/Arch/Aur/Rpc.hs
@@ -1,55 +0,0 @@-{-# LANGUAGE OverloadedStrings, TypeOperators, DataKinds #-}---- |--- Module : Linux.Arch.Aur.Rpc--- Copyright : (c) Colin Woodbury, 2014 - 2018--- License : GPL3--- Maintainer: Colin Woodbury <colin@fosskers.ca>------ See https://aur.archlinux.org/rpc for details.--module Linux.Arch.Aur.Rpc ( info, search ) where--import Control.Error.Util (hush)-import Data.Proxy-import Data.Text (Text)-import Linux.Arch.Aur.Types-import Network.HTTP.Client (Manager)-import Servant.API-import Servant.Client-------type Info = "rpc" :> QueryParam "v" Text- :> QueryParam "type" Text- :> QueryParams "arg[]" Text- :> Get '[JSON] RPCResp--type Search = "rpc" :> QueryParam "v" Text- :> QueryParam "type" Text- :> QueryParam "arg" Text- :> Get '[JSON] RPCResp--type API = Info :<|> Search--api :: Proxy API-api = Proxy--url :: BaseUrl-url = BaseUrl Https "aur.archlinux.org" 443 ""---- | Make a call to the AUR RPC. Assumes version 5 of the API.-rpcI :<|> rpcS = client api---- | Perform an @info@ call on one or more package names.--- Will fail with a `Nothing` if there was a connection/decoding error.-info :: Manager -> [Text] -> IO (Maybe [AurInfo])-info m ps = unwrap m $ rpcI (Just "5") (Just "info") ps---- | Perform a @search@ call on a package name or description text.--- Will fail with a `Nothing` if there was a connection/decoding error.-search :: Manager -> Text -> IO (Maybe [AurInfo])-search m p = unwrap m $ rpcS (Just "5") (Just "search") (Just p)--unwrap :: Manager -> ClientM RPCResp -> IO (Maybe [AurInfo])-unwrap m r = fmap _results . hush <$> runClientM r (ClientEnv m url Nothing)
− Linux/Arch/Aur/Types.hs
@@ -1,105 +0,0 @@-{-# LANGUAGE OverloadedStrings #-}---- |--- Module : Linux.Arch.Aur.Types--- Copyright : (c) Colin Woodbury, 2014 - 2018--- License : GPL3--- Maintainer: Colin Woodbury <colin@fosskers.ca>--module Linux.Arch.Aur.Types- ( RPCResp(..)- , AurInfo(..)- ) where--import Control.Applicative ((<|>))-import Control.Monad (mzero)-import Data.Aeson-import Data.Text-------data RPCResp = RPCResp { _version :: Int- , _type :: Text- , _resultCount :: Int- , _results :: [AurInfo] } deriving (Show)--instance FromJSON RPCResp where- parseJSON (Object v) = RPCResp <$>- v .: "version" <*>- v .: "type" <*>- v .: "resultcount" <*>- v .: "results"-- parseJSON _ = mzero--data AurInfo = AurInfo { aurIdOf :: Int- , aurNameOf :: Text- , pkgBaseIdOf :: Int- , pkgBaseOf :: Text- , aurVersionOf :: Text- , aurDescriptionOf :: Maybe Text- , urlOf :: Maybe Text- , aurVotesOf :: Int- , popularityOf :: Float- , dateObsoleteOf :: Maybe Int- , aurMaintainerOf :: Maybe Text- , submissionDateOf :: Int- , modifiedDateOf :: Int- , urlPathOf :: Maybe Text- , dependsOf :: [Text]- , makeDepsOf :: [Text]- , optDepsOf :: [Text]- , conflictsOf :: [Text]- , providesOf :: [Text]- , licenseOf :: [Text]- , keywordsOf :: [Text] } deriving (Eq,Show)--instance FromJSON AurInfo where- parseJSON (Object v) = AurInfo <$>- v .: "ID" <*>- v .: "Name" <*>- v .: "PackageBaseID" <*>- v .: "PackageBase" <*>- v .: "Version" <*>- v .:? "Description" <*>- v .:? "URL" <*>- v .: "NumVotes" <*>- v .: "Popularity" <*>- (v .: "OutOfDate" <|> pure Nothing) <*>- (v .: "Maintainer" <|> pure Nothing) <*>- v .: "FirstSubmitted" <*>- v .: "LastModified" <*>- v .:? "URLPath" <*>- v .:? "Depends" .!= [] <*>- v .:? "MakeDepends" .!= [] <*>- v .:? "OptDepends" .!= [] <*>- v .:? "Conflicts" .!= [] <*>- v .:? "Provides" .!= [] <*>- v .:? "License" .!= [] <*>- v .:? "Keywords" .!= []-- parseJSON _ = mzero--instance ToJSON AurInfo where- toJSON ai = object- [ "ID" .= aurIdOf ai- , "Name" .= aurNameOf ai- , "PackageBaseID" .= pkgBaseIdOf ai- , "PackageBase" .= pkgBaseOf ai- , "Version" .= aurVersionOf ai- , "Description" .= aurDescriptionOf ai- , "URL" .= urlOf ai- , "NumVotes" .= aurVotesOf ai- , "Popularity" .= popularityOf ai- , "OutOfDate" .= dateObsoleteOf ai- , "Maintainer" .= aurMaintainerOf ai- , "FirstSubmitted" .= submissionDateOf ai- , "LastModified" .= modifiedDateOf ai- , "URLPath" .= urlPathOf ai- , "Depends" .= dependsOf ai- , "MakeDepends" .= makeDepsOf ai- , "OptDepends" .= optDepsOf ai- , "Conflicts" .= conflictsOf ai- , "Provides" .= providesOf ai- , "License" .= licenseOf ai- , "Keywords" .= keywordsOf ai ]
aur.cabal view
@@ -1,58 +1,63 @@-cabal-version: 1.12+cabal-version: 2.2 --- This file has been generated from package.yaml by hpack version 0.30.0.------ see: https://github.com/sol/hpack------ hash: 9af215c031bd05af2173f07269067c3c3a903e8f9227649fdf2f833699c8f4e8+name: aur+version: 6.1.0.1+synopsis: Access metadata from the Arch Linux User Repository. -name: aur-version: 6.1.0-synopsis: Access metadata from the Arch Linux User Repository.-description: Access package information from Arch Linux\'s AUR via its RPC interface. The main exposed functions reflect those of the RPC.- `info` gets metadata for one package. `search` gets limited metadata for packages that match a given regex.- By default this library supports version 5 of the RPC, and hence version 4.2+ of the AUR.-category: Linux-homepage: https://github.com/aurapm/aura-author: Colin Woodbury-maintainer: colin@fosskers.ca-copyright: 2018 Colin Woodbury-license: GPL-3-license-file: LICENSE-build-type: Simple+description:+ Access package information from Arch Linux's AUR via its RPC interface. The+ main exposed functions reflect those of the RPC. `info` gets metadata for+ one package. `search` gets limited metadata for packages that match a given+ regex. By default this library supports version 5 of the RPC, and hence+ version 4.2+ of the AUR.++category: Linux+homepage: https://github.com/aurapm/aura+author: Colin Woodbury+maintainer: colin@fosskers.ca+copyright: 2014 - 2019 Colin Woodbury+license: GPL-3.0-only+license-file: LICENSE+build-type: Simple+ extra-source-files: README.md CHANGELOG.md +common commons+ default-language: Haskell2010+ ghc-options:+ -Wall+ -Wincomplete-record-updates+ -Wincomplete-uni-patterns+ -Wredundant-constraints+ -Widentities+ build-depends:+ base >= 4.10 && < 5+ , http-client ^>= 0.5+ library+ import: commons+ hs-source-dirs: lib exposed-modules: Linux.Arch.Aur Linux.Arch.Aur.Rpc Linux.Arch.Aur.Types- hs-source-dirs:- ./.- ghc-options: -fwarn-unused-imports -fwarn-unused-binds -fwarn-name-shadowing -fwarn-unused-matches -fwarn-incomplete-patterns -fwarn-redundant-constraints -Wincomplete-uni-patterns build-depends:- aeson >=0.9 && <1.4- , base >=4.10 && <4.12- , errors >=2.3 && <2.4- , http-client >=0.5 && <0.6- , servant >=0.9 && <0.15- , servant-client >=0.13 && <0.15+ aeson >= 0.9 && < 1.5+ , errors ^>= 2.3+ , servant >= 0.9 && < 0.17+ , servant-client >= 0.13 && < 0.17 , text- default-language: Haskell2010 test-suite aur-test+ import: commons type: exitcode-stdio-1.0 main-is: Test.hs- hs-source-dirs:- tests- ghc-options: -fwarn-unused-imports -fwarn-unused-binds -fwarn-name-shadowing -fwarn-unused-matches -fwarn-incomplete-patterns -fwarn-redundant-constraints -Wincomplete-uni-patterns -threaded -with-rtsopts=-N+ hs-source-dirs: tests+ ghc-options: -threaded -with-rtsopts=-N build-depends: aur- , base >=4.10 && <4.12- , http-client >=0.5 && <0.6- , http-client-tls >=0.3 && <0.4- , tasty >=0.11 && <2.0- , tasty-hunit >=0.9 && <0.11- default-language: Haskell2010+ , http-client-tls ^>= 0.3+ , tasty >= 0.11 && < 1.3+ , tasty-hunit >= 0.9 && < 0.11
+ lib/Linux/Arch/Aur.hs view
@@ -0,0 +1,6 @@+module Linux.Arch.Aur+ ( module Linux.Arch.Aur.Rpc+ , module Linux.Arch.Aur.Types ) where++import Linux.Arch.Aur.Rpc+import Linux.Arch.Aur.Types
+ lib/Linux/Arch/Aur/Rpc.hs view
@@ -0,0 +1,59 @@+{-# LANGUAGE DataKinds #-}+{-# LANGUAGE OverloadedStrings #-}+{-# LANGUAGE TypeOperators #-}++-- |+-- Module : Linux.Arch.Aur.Rpc+-- Copyright : (c) Colin Woodbury, 2014 - 2019+-- License : GPL3+-- Maintainer: Colin Woodbury <colin@fosskers.ca>+--+-- See https://aur.archlinux.org/rpc for details.++module Linux.Arch.Aur.Rpc ( info, search ) where++import Control.Error.Util (hush)+import Data.Proxy+import Data.Text (Text)+import Linux.Arch.Aur.Types+import Network.HTTP.Client (Manager)+import Servant.API+import Servant.Client++---++type Info = "rpc" :> QueryParam "v" Text+ :> QueryParam "type" Text+ :> QueryParams "arg[]" Text+ :> Get '[JSON] RPCResp++type Search = "rpc" :> QueryParam "v" Text+ :> QueryParam "type" Text+ :> QueryParam "arg" Text+ :> Get '[JSON] RPCResp++type API = Info :<|> Search++api :: Proxy API+api = Proxy++url :: BaseUrl+url = BaseUrl Https "aur.archlinux.org" 443 ""++-- | Make a call to the AUR RPC. Assumes version 5 of the API.+rpcI :: Maybe Text -> Maybe Text -> [Text] -> ClientM RPCResp+rpcS :: Maybe Text -> Maybe Text -> Maybe Text -> ClientM RPCResp+rpcI :<|> rpcS = client api++-- | Perform an @info@ call on one or more package names.+-- Will fail with a `Nothing` if there was a connection/decoding error.+info :: Manager -> [Text] -> IO (Maybe [AurInfo])+info m ps = unwrap m $ rpcI (Just "5") (Just "info") ps++-- | Perform a @search@ call on a package name or description text.+-- Will fail with a `Nothing` if there was a connection/decoding error.+search :: Manager -> Text -> IO (Maybe [AurInfo])+search m p = unwrap m $ rpcS (Just "5") (Just "search") (Just p)++unwrap :: Manager -> ClientM RPCResp -> IO (Maybe [AurInfo])+unwrap m r = fmap _results . hush <$> runClientM r (ClientEnv m url Nothing)
+ lib/Linux/Arch/Aur/Types.hs view
@@ -0,0 +1,105 @@+{-# LANGUAGE OverloadedStrings #-}++-- |+-- Module : Linux.Arch.Aur.Types+-- Copyright : (c) Colin Woodbury, 2014 - 2019+-- License : GPL3+-- Maintainer: Colin Woodbury <colin@fosskers.ca>++module Linux.Arch.Aur.Types+ ( RPCResp(..)+ , AurInfo(..)+ ) where++import Control.Applicative ((<|>))+import Control.Monad (mzero)+import Data.Aeson+import Data.Text++---++data RPCResp = RPCResp { _version :: Int+ , _type :: Text+ , _resultCount :: Int+ , _results :: [AurInfo] } deriving (Show)++instance FromJSON RPCResp where+ parseJSON (Object v) = RPCResp <$>+ v .: "version" <*>+ v .: "type" <*>+ v .: "resultcount" <*>+ v .: "results"++ parseJSON _ = mzero++data AurInfo = AurInfo { aurIdOf :: Int+ , aurNameOf :: Text+ , pkgBaseIdOf :: Int+ , pkgBaseOf :: Text+ , aurVersionOf :: Text+ , aurDescriptionOf :: Maybe Text+ , urlOf :: Maybe Text+ , aurVotesOf :: Int+ , popularityOf :: Float+ , dateObsoleteOf :: Maybe Int+ , aurMaintainerOf :: Maybe Text+ , submissionDateOf :: Int+ , modifiedDateOf :: Int+ , urlPathOf :: Maybe Text+ , dependsOf :: [Text]+ , makeDepsOf :: [Text]+ , optDepsOf :: [Text]+ , conflictsOf :: [Text]+ , providesOf :: [Text]+ , licenseOf :: [Text]+ , keywordsOf :: [Text] } deriving (Eq,Show)++instance FromJSON AurInfo where+ parseJSON (Object v) = AurInfo <$>+ v .: "ID" <*>+ v .: "Name" <*>+ v .: "PackageBaseID" <*>+ v .: "PackageBase" <*>+ v .: "Version" <*>+ v .:? "Description" <*>+ v .:? "URL" <*>+ v .: "NumVotes" <*>+ v .: "Popularity" <*>+ (v .: "OutOfDate" <|> pure Nothing) <*>+ (v .: "Maintainer" <|> pure Nothing) <*>+ v .: "FirstSubmitted" <*>+ v .: "LastModified" <*>+ v .:? "URLPath" <*>+ v .:? "Depends" .!= [] <*>+ v .:? "MakeDepends" .!= [] <*>+ v .:? "OptDepends" .!= [] <*>+ v .:? "Conflicts" .!= [] <*>+ v .:? "Provides" .!= [] <*>+ v .:? "License" .!= [] <*>+ v .:? "Keywords" .!= []++ parseJSON _ = mzero++instance ToJSON AurInfo where+ toJSON ai = object+ [ "ID" .= aurIdOf ai+ , "Name" .= aurNameOf ai+ , "PackageBaseID" .= pkgBaseIdOf ai+ , "PackageBase" .= pkgBaseOf ai+ , "Version" .= aurVersionOf ai+ , "Description" .= aurDescriptionOf ai+ , "URL" .= urlOf ai+ , "NumVotes" .= aurVotesOf ai+ , "Popularity" .= popularityOf ai+ , "OutOfDate" .= dateObsoleteOf ai+ , "Maintainer" .= aurMaintainerOf ai+ , "FirstSubmitted" .= submissionDateOf ai+ , "LastModified" .= modifiedDateOf ai+ , "URLPath" .= urlPathOf ai+ , "Depends" .= dependsOf ai+ , "MakeDepends" .= makeDepsOf ai+ , "OptDepends" .= optDepsOf ai+ , "Conflicts" .= conflictsOf ai+ , "Provides" .= providesOf ai+ , "License" .= licenseOf ai+ , "Keywords" .= keywordsOf ai ]