git.iko.soy/rowtype-yoga/purescript-octokit
on main help sign in
Add changes
commitcc9d454da6799e66dd0b91334c677d66c862d37a authorsigma-andex <77549848+sigma-andex@users.noreply.github.com> dateFri 1 Jul 2022, 10:09 (4 years ago) parent5dae831
4 files changed+92−45
unifiedsplit
packages.dhall+3−3 spago.dhall−1 src/Octokit/Octokit.js+29−25 src/Octokit/Octokit.purs+60−16
packages.dhall+3−3
@@ -1,6 +1,6 @@
1−
2−
31let upstream =
4− https://github.com/purescript/package-sets/releases/download/psc-0.14.5-20211116/packages.dhall sha256:7ba810597a275e43c83411d2ab0d4b3c54d0b551436f4b1632e9ff3eb62e327a
2+ https://raw.githubusercontent.com/purescript/package-sets/prepare-0.15/src/packages.dhall
3+ sha256:b1c6d06132b7cbf1e93b1e5343044fba1604b50bfbe02d8f80a3002e71569c59
54
65in upstream
6+ with metadata.version = "v0.15.0-alpha-02"
spago.dhall−1
@@ -11,7 +11,6 @@
1111 , "maybe"
1212 , "newtype"
1313 , "prelude"
14− , "psci-support"
1514 ]
1615, packages = ./packages.dhall
1716, sources = [ "src/**/*.purs", "test/**/*.purs" ]
src/Octokit/Octokit.js+29−25
@@ -1,29 +1,33 @@
1−const { Octokit, App } = require("octokit")
2−const { throttling } = require("@octokit/plugin-throttling")
3−const { request } = require("@octokit/request")
1+import { Octokit, App } from "octokit"
2+import { throttling } from "@octokit/plugin-throttling"
3+import { request } from "@octokit/request"
44const ThrottledOctokit = Octokit.plugin(throttling)
55
6−exports.octokit = (auth) => () => new ThrottledOctokit({
7− auth,
8− throttle: {
9− onRateLimit: (retryAfter, options, octokit) => {
10− octokit.log.warn(
11− `Request quota exhausted for request ${options.method} ${options.url}`
12− )
6+export function octokit(auth) {
7+ return () => new ThrottledOctokit({
8+ auth,
9+ throttle: {
10+ onRateLimit: (retryAfter, options, octokit) => {
11+ octokit.log.warn(
12+ `Request quota exhausted for request ${options.method} ${options.url}`
13+ )
1314
14− if (options.request.retryCount === 0) {
15− // only retries once
16− octokit.log.info(`Retrying after ${retryAfter} seconds!`)
17− return true
18− }
19− },
20− onAbuseLimit: (retryAfter, options, octokit) => {
21− // does not retry, only logs a warning
22− octokit.log.warn(
23− `Abuse detected for request ${options.method} ${options.url}`
24− )
25− },
26− }
27−})
15+ if (options.request.retryCount === 0) {
16+ // only retries once
17+ octokit.log.info(`Retrying after ${retryAfter} seconds!`)
18+ return true
19+ }
20+ },
21+ onAbuseLimit: (retryAfter, options, octokit) => {
22+ // does not retry, only logs a warning
23+ octokit.log.warn(
24+ `Abuse detected for request ${options.method} ${options.url}`
25+ )
26+ },
27+ }
28+ })
29+}
2830
29−exports.requestImpl = (client, route, params) => () => client.request(route, params)
31+export function requestImpl(client, route, params) {
32+ return () => client.request(route, params)
33+}
src/Octokit/Octokit.purs+60−16
@@ -11,10 +11,10 @@ module Octokit.Octokit
1111 , Route(..)
1212 , SearchResult
1313 , TreeItem
14+ , User
1415 , octokit
1516 , request
16− )
17− where
17+ ) where
1818
1919import Prelude
2020
@@ -23,12 +23,12 @@ import Control.Promise as Promise
2323import Data.Argonaut (class DecodeJson, Json, decodeJson, printJsonDecodeError)
2424import Data.Argonaut as Argonaut
2525import Data.Bifunctor (bimap)
26−import Data.Either (Either, either)
26+import Data.Either (Either)
2727import Data.Function.Uncurried (Fn3, runFn3)
28−import Data.Maybe (Maybe(..))
28+import Data.Maybe (Maybe)
2929import Data.Newtype (class Newtype)
3030import Effect (Effect)
31−import Effect.Aff (Aff, Error, attempt, error, throwError)
31+import Effect.Aff (Aff, Error, attempt, error)
3232
3333foreign import data Octokit :: Type
3434
@@ -60,8 +60,9 @@ request client (Route route) params = runFn3 requestImpl client route params # P
6060 decoded :: Either Argonaut.JsonDecodeError output
6161 decoded = decodeJson d
6262
63− result = bimap (printJsonDecodeError >>> error) (\decodedData -> { status, "data": decodedData }) decoded
64− in result
63+ result = bimap (printJsonDecodeError >>> error) (\decodedData -> { status, "data": decodedData }) decoded
64+ in
65+ result
6566
6667type CommitActivity = Array
6768 { days :: Array Int
@@ -70,11 +71,11 @@ type CommitActivity = Array
7071 }
7172
7273type License =
73− { key :: Maybe String
74− , name :: Maybe String
74+ { key :: String
75+ , name :: String
7576 , node_id :: Maybe String
7677 , spdx_id :: Maybe String
77− , url :: Maybe String
78+ , html_url :: Maybe String
7879 }
7980
8081type Repo =
@@ -102,7 +103,7 @@ type Repo =
102103 , forks :: Maybe Int
103104 , forks_count :: Maybe Int
104105 , forks_url :: Maybe String
105− , full_name :: Maybe String
106+ , full_name :: String
106107 , git_commits_url :: Maybe String
107108 , git_refs_url :: Maybe String
108109 , git_tags_url :: Maybe String
@@ -115,7 +116,7 @@ type Repo =
115116 , homepage :: Maybe String
116117 , hooks_url :: Maybe String
117118 , html_url :: Maybe String
118− , id :: Maybe Int
119+ , id :: Int
119120 , is_template :: Maybe Boolean
120121 , issue_comment_url :: Maybe String
121122 , issue_events_url :: Maybe String
@@ -128,7 +129,7 @@ type Repo =
128129 , merges_url :: Maybe String
129130 , milestones_url :: Maybe String
130131 , mirror_url :: Maybe String
131− , name :: Maybe String
132+ , name :: String
132133 , node_id :: Maybe String
133134 , notifications_url :: Maybe String
134135 , open_issues :: Maybe Int
@@ -141,8 +142,8 @@ type Repo =
141142 , gists_url :: Maybe String
142143 , gravatar_id :: Maybe String
143144 , html_url :: Maybe String
144− , id :: Maybe Int
145− , login :: Maybe String
145+ , id :: Int
146+ , login :: String
146147 , node_id :: Maybe String
147148 , organizations_url :: Maybe String
148149 , received_events_url :: Maybe String
@@ -157,7 +158,15 @@ type Repo =
157158 Maybe
158159 { language :: String
159160 }
160− , private :: Maybe Boolean
161+ , permissions ::
162+ Maybe
163+ { admin :: Boolean
164+ , maintain :: Boolean
165+ , pull :: Boolean
166+ , push :: Boolean
167+ , triage :: Boolean
168+ }
169+ , private :: Boolean
161170 , pulls_url :: Maybe String
162171 , pushed_at :: Maybe String
163172 , releases_url :: Maybe String
@@ -285,6 +294,41 @@ type Commit =
285294 , url :: String
286295 }
287296
297+type User =
298+ { avatar_url :: Maybe String
299+ , bio :: Maybe String
300+ , blog :: Maybe String
301+ , company :: Maybe String
302+ , created_at :: Maybe String
303+ , email :: Maybe String
304+ , events_url :: Maybe String
305+ , followers :: Maybe Int
306+ , followers_url :: Maybe String
307+ , following :: Maybe Int
308+ , following_url :: Maybe String
309+ , gists_url :: Maybe String
310+ , gravatar_id :: Maybe String
311+ , hireable :: Maybe String
312+ , html_url :: Maybe String
313+ , id :: Int
314+ , location :: Maybe String
315+ , login :: String
316+ , name :: Maybe String
317+ , node_id :: Maybe String
318+ , organizations_url :: Maybe String
319+ , public_gists :: Maybe Int
320+ , public_repos :: Maybe Int
321+ , received_events_url :: Maybe String
322+ , repos_url :: Maybe String
323+ , site_admin :: Maybe Boolean
324+ , starred_url :: Maybe String
325+ , subscriptions_url :: Maybe String
326+ , twitter_username :: Maybe String
327+ , type :: Maybe String
328+ , updated_at :: Maybe String
329+ , url :: Maybe String
330+ }
331+
288332type SearchResult d =
289333 { incomplete_results :: Boolean
290334 , items ::