This commit is contained in:
orion 2023-11-28 00:16:40 -06:00
parent 3fe42d78ff
commit bd2d3ff486
Signed by: orion
GPG Key ID: 6D4165AE4C928719
3 changed files with 19 additions and 3 deletions

View File

@ -1,6 +1,7 @@
package:
dependencies:
- aff
- arrays
- effect
- either
- exceptions
@ -11,6 +12,7 @@ package:
- node-buffer
- prelude
- simple-json
- tailrec
- transformers
- tuples
- typelevel-prelude

View File

@ -29,7 +29,7 @@ reposURL (Username owner) (RepoName repo) =
build <$> ask
repoTopicsPageURL :: forall m. Monad m => Username -> RepoName -> { page :: Int, limit :: Int } -> GiteaT m URL
repoTopicsPageURL o repo {page, limit} = (\repos -> repos / "topics" ? "limit" /\ show limit & "page" /\ show page) <$> reposURL o repo
repoTopicsPageURL o repo { page, limit } = (\repos -> repos / "topics" ? "limit" /\ show limit & "page" /\ show page) <$> reposURL o repo
repoTopicsURL :: forall m. Monad m => Username -> RepoName -> GiteaT m URL
repoTopicsURL o repo = (\repos -> repos / "topics") <$> reposURL o repo
@ -123,7 +123,7 @@ getTopics owner repo =
{ auth } <- ask
url <- repoTopicsPageURL owner repo { limit, page: n }
rep <- HTTP.fetch $ HTTP.GET /\ url /\ Auth.headers auth
{topics} <- Error.tryGetRepJSON @{topics :: Array TopicName} rep
{ topics } <- Error.tryGetRepJSON @{ topics :: Array TopicName } rep
pure topics
in
tailRecM paginate ([] /\ 1)
@ -139,5 +139,5 @@ setTopics :: forall m. MonadAff m => Username -> RepoName -> Array TopicName ->
setTopics owner repo topics = do
{ auth } <- ask
url <- repoTopicsURL owner repo
rep <- HTTP.fetch $ HTTP.PUT /\ url /\ HTTP.json {topics} /\ Auth.headers auth
rep <- HTTP.fetch $ HTTP.PUT /\ url /\ HTTP.json { topics } /\ Auth.headers auth
Error.guardStatusOk rep

View File

@ -13,6 +13,7 @@ newtype RepoName = RepoName String
derive instance Newtype RepoName _
derive newtype instance Eq RepoName
derive newtype instance Ord RepoName
derive newtype instance Show RepoName
derive newtype instance WriteForeign RepoName
derive newtype instance ReadForeign RepoName
@ -21,6 +22,7 @@ newtype TopicName = TopicName String
derive instance Newtype TopicName _
derive newtype instance Eq TopicName
derive newtype instance Ord TopicName
derive newtype instance Show TopicName
derive newtype instance WriteForeign TopicName
derive newtype instance ReadForeign TopicName
@ -29,6 +31,7 @@ newtype OrgName = OrgName String
derive instance Newtype OrgName _
derive newtype instance Eq OrgName
derive newtype instance Ord OrgName
derive newtype instance Show OrgName
derive newtype instance WriteForeign OrgName
derive newtype instance ReadForeign OrgName
@ -37,6 +40,7 @@ newtype TagName = TagName String
derive instance Newtype TagName _
derive newtype instance Eq TagName
derive newtype instance Ord TagName
derive newtype instance Show TagName
derive newtype instance WriteForeign TagName
derive newtype instance ReadForeign TagName
@ -45,6 +49,7 @@ newtype CommitId = CommitId String
derive instance Newtype CommitId _
derive newtype instance Eq CommitId
derive newtype instance Ord CommitId
derive newtype instance Show CommitId
derive newtype instance WriteForeign CommitId
derive newtype instance ReadForeign CommitId
@ -53,6 +58,7 @@ newtype BranchName = BranchName String
derive instance Newtype BranchName _
derive newtype instance Eq BranchName
derive newtype instance Ord BranchName
derive newtype instance Show BranchName
derive newtype instance WriteForeign BranchName
derive newtype instance ReadForeign BranchName
@ -61,6 +67,7 @@ newtype BranchProtectionName = BranchProtectionName String
derive instance Newtype BranchProtectionName _
derive newtype instance Eq BranchProtectionName
derive newtype instance Ord BranchProtectionName
derive newtype instance Show BranchProtectionName
derive newtype instance WriteForeign BranchProtectionName
derive newtype instance ReadForeign BranchProtectionName
@ -69,6 +76,7 @@ newtype TeamName = TeamName String
derive instance Newtype TeamName _
derive newtype instance Eq TeamName
derive newtype instance Ord TeamName
derive newtype instance Show TeamName
derive newtype instance WriteForeign TeamName
derive newtype instance ReadForeign TeamName
@ -77,6 +85,7 @@ newtype SecretName = SecretName String
derive instance Newtype SecretName _
derive newtype instance Eq SecretName
derive newtype instance Ord SecretName
derive newtype instance Show SecretName
derive newtype instance WriteForeign SecretName
derive newtype instance ReadForeign SecretName
@ -85,6 +94,7 @@ newtype RepoId = RepoId Int
derive instance Newtype RepoId _
derive newtype instance Eq RepoId
derive newtype instance Ord RepoId
derive newtype instance Show RepoId
derive newtype instance WriteForeign RepoId
derive newtype instance ReadForeign RepoId
@ -93,6 +103,7 @@ newtype Username = Username String
derive instance Newtype Username _
derive newtype instance Eq Username
derive newtype instance Ord Username
derive newtype instance Show Username
derive newtype instance WriteForeign Username
derive newtype instance ReadForeign Username
@ -101,6 +112,7 @@ newtype UserId = UserId Int
derive instance Newtype UserId _
derive newtype instance Eq UserId
derive newtype instance Ord UserId
derive newtype instance Show UserId
derive newtype instance WriteForeign UserId
derive newtype instance ReadForeign UserId
@ -109,6 +121,7 @@ newtype OrgId = OrgId Int
derive instance Newtype OrgId _
derive newtype instance Eq OrgId
derive newtype instance Ord OrgId
derive newtype instance Show OrgId
derive newtype instance WriteForeign OrgId
derive newtype instance ReadForeign OrgId
@ -117,6 +130,7 @@ newtype TeamId = TeamId Int
derive instance Newtype TeamId _
derive newtype instance Eq TeamId
derive newtype instance Ord TeamId
derive newtype instance Show TeamId
derive newtype instance WriteForeign TeamId
derive newtype instance ReadForeign TeamId