The best way to control Claude Code, Codex and more from any computer or phone
Mirrored from https://github.com/Camo67/t3code.git
Synced Nov 21, 04:45 UTC
| 1 | import type { GithubOpContext } from "@distilled.cloud/github"; |
| 2 | import * as Pulls from "@distilled.cloud/github/pulls"; |
| 3 | import type { Self } from "alchemy/Self"; |
| 4 | import type * as Effect from "effect/Effect"; |
| 5 | import * as Layer from "effect/Layer"; |
| 6 | import * as BindingHttp from "./BindingHttp.ts"; |
| 7 | import { GetPullRequest, type GetPullRequestRequest } from "./GetPullRequest.ts"; |
| 8 | |
| 9 | export const getPullRequestOperation = BindingHttp.operation( |
| 10 | "pulls.get", |
| 11 | (repo) => |
| 12 | ({ |
| 13 | accept, |
| 14 | ...request |
| 15 | }: GetPullRequestRequest): Effect.Effect< |
| 16 | Pulls.PullRequest | string, |
| 17 | Pulls.GetError, |
| 18 | GithubOpContext |
| 19 | > => { |
| 20 | // One branch per overload: the JSON object, or the text media type's text. |
| 21 | const scope = { owner: repo.owner, repo: repo.repository, ...request }; |
| 22 | return accept === undefined || accept === "application/vnd.github+json" |
| 23 | ? Pulls.get({ ...scope, accept }) |
| 24 | : Pulls.get({ ...scope, accept }); |
| 25 | }, |
| 26 | ); |
| 27 | |
| 28 | /** |
| 29 | * Token-backed implementation of {@link GetPullRequest}. Provide it on a Worker or |
| 30 | * Function: it captures a `GitHub.PersonalAccessToken` for the host and binds |
| 31 | * the token and the repository into it. |
| 32 | * |
| 33 | * @layer |
| 34 | * @product Pull Request |
| 35 | * @provides GitHub.GetPullRequest |
| 36 | */ |
| 37 | export const GetPullRequestHttp: Layer.Layer<GetPullRequest, never, Self> = Layer.effect( |
| 38 | GetPullRequest, |
| 39 | BindingHttp.make(getPullRequestOperation) as never, |
| 40 | ); |