The best way to control Claude Code, Codex and more from any computer or phone

main
ts 33 lines 1.1 KB
Raw
1 import * as Issues from "@distilled.cloud/github/issues";
2 import * as Effect from "effect/Effect";
3 import * as Layer from "effect/Layer";
4 import * as BindingHttp from "./BindingHttp.ts";
5 import { IssueNotFound } from "./Errors.ts";
6 import { UpdateIssue, type UpdateIssueRequest } from "./UpdateIssue.ts";
7
8 export const updateIssueOperation = BindingHttp.operation(
9 "issues.update",
10 (repo) => (request: UpdateIssueRequest) =>
11 Issues.update({ owner: repo.owner, repo: repo.repository, ...request }).pipe(
12 Effect.catchTag("NotFound", () =>
13 Effect.fail(
14 new IssueNotFound({
15 owner: repo.owner,
16 repository: repo.repository,
17 number: request.issue_number,
18 }),
19 ),
20 ),
21 ),
22 );
23
24 /**
25 * Token-backed implementation of {@link UpdateIssue}. Provide it on a Worker or
26 * Function: it captures a `GitHub.PersonalAccessToken` for the host and binds
27 * the token and the repository into it.
28 *
29 * @layer
30 * @product Issue
31 * @provides GitHub.UpdateIssue
32 */
33 export const UpdateIssueHttp = Layer.effect(UpdateIssue, BindingHttp.make(updateIssueOperation));