| 1 | /** |
| 2 | * The `github` group: a GitHub REST v3 facade at `/api/v3`, so `gh api` |
| 3 | * and Octokit work against the host unmodified (DESIGN.md §5). The routes |
| 4 | * answer with GitHub-shaped JSON they build themselves and declare no |
| 5 | * success schema. |
| 6 | */ |
| 7 | import * as HttpApiEndpoint from "effect/http-api/HttpApiEndpoint"; |
| 8 | import * as HttpApiGroup from "effect/http-api/HttpApiGroup"; |
| 9 | |
| 10 | /** `GET /user`: the credential probe `gh` makes; answer it from your own user record. */ |
| 11 | export const GitHubUser = HttpApiEndpoint.get("user", "/user", {}); |
| 12 | |
| 13 | /** `GET /repos/:owner/:repo` */ |
| 14 | export const GitHubRepo = HttpApiEndpoint.get( |
| 15 | "repo", |
| 16 | "/repos/:owner/:repo", |
| 17 | {}, |
| 18 | ); |
| 19 | |
| 20 | /** `GET /repos/:owner/:repo/branches` */ |
| 21 | export const GitHubBranches = HttpApiEndpoint.get( |
| 22 | "branches", |
| 23 | "/repos/:owner/:repo/branches", |
| 24 | {}, |
| 25 | ); |
| 26 | |
| 27 | /** `GET /repos/:owner/:repo/commits` */ |
| 28 | export const GitHubCommits = HttpApiEndpoint.get( |
| 29 | "commits", |
| 30 | "/repos/:owner/:repo/commits", |
| 31 | {}, |
| 32 | ); |
| 33 | |
| 34 | /** `GET /repos/:owner/:repo/commits/:sha` */ |
| 35 | export const GitHubCommit = HttpApiEndpoint.get( |
| 36 | "commit", |
| 37 | "/repos/:owner/:repo/commits/:sha", |
| 38 | {}, |
| 39 | ); |
| 40 | |
| 41 | /** `GET /repos/:owner/:repo/contents/*` */ |
| 42 | export const GitHubContents = HttpApiEndpoint.get( |
| 43 | "contents", |
| 44 | "/repos/:owner/:repo/contents/*", |
| 45 | {}, |
| 46 | ); |
| 47 | |
| 48 | /** `GET /repos/:owner/:repo/pulls` */ |
| 49 | export const GitHubPulls = HttpApiEndpoint.get( |
| 50 | "pulls", |
| 51 | "/repos/:owner/:repo/pulls", |
| 52 | {}, |
| 53 | ); |
| 54 | |
| 55 | /** `POST /repos/:owner/:repo/pulls` */ |
| 56 | export const GitHubCreatePull = HttpApiEndpoint.post( |
| 57 | "createPull", |
| 58 | "/repos/:owner/:repo/pulls", |
| 59 | {}, |
| 60 | ); |
| 61 | |
| 62 | /** `GET /repos/:owner/:repo/pulls/:number` */ |
| 63 | export const GitHubPull = HttpApiEndpoint.get( |
| 64 | "pull", |
| 65 | "/repos/:owner/:repo/pulls/:number", |
| 66 | {}, |
| 67 | ); |
| 68 | |
| 69 | /** `PATCH /repos/:owner/:repo/pulls/:number` */ |
| 70 | export const GitHubUpdatePull = HttpApiEndpoint.patch( |
| 71 | "updatePull", |
| 72 | "/repos/:owner/:repo/pulls/:number", |
| 73 | {}, |
| 74 | ); |
| 75 | |
| 76 | /** `PUT /repos/:owner/:repo/pulls/:number/merge` */ |
| 77 | export const GitHubMergePull = HttpApiEndpoint.put( |
| 78 | "mergePull", |
| 79 | "/repos/:owner/:repo/pulls/:number/merge", |
| 80 | {}, |
| 81 | ); |
| 82 | |
| 83 | /** `GET /repos/:owner/:repo/pulls/:number/files` */ |
| 84 | export const GitHubPullFiles = HttpApiEndpoint.get( |
| 85 | "pullFiles", |
| 86 | "/repos/:owner/:repo/pulls/:number/files", |
| 87 | {}, |
| 88 | ); |
| 89 | |
| 90 | /** The GitHub facade, mounted at `/api/v3`. */ |
| 91 | export class GitHub extends HttpApiGroup.make("github") |
| 92 | .add( |
| 93 | GitHubUser, |
| 94 | GitHubRepo, |
| 95 | GitHubBranches, |
| 96 | GitHubCommits, |
| 97 | GitHubCommit, |
| 98 | GitHubContents, |
| 99 | GitHubPulls, |
| 100 | GitHubCreatePull, |
| 101 | GitHubPull, |
| 102 | GitHubUpdatePull, |
| 103 | GitHubMergePull, |
| 104 | GitHubPullFiles, |
| 105 | ) |
| 106 | .prefix("/api/v3") {} |