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

main
ts 48 lines 1.43 KB
Raw
1 import type { NotFound } from "@distilled.cloud/github/Errors";
2 import type * as Issues from "@distilled.cloud/github/issues";
3 import * as Binding from "alchemy/Binding";
4 import type { RuntimeContext } from "alchemy/RuntimeContext";
5 import type * as Effect from "effect/Effect";
6 import type { IssueNotFound } from "./Errors.ts";
7 import type { Repository } from "./Repository.ts";
8
9 export interface GetIssueRequest extends Omit<Issues.GetRequest, "owner" | "repo"> {}
10
11 export type GetIssueResponse = Issues.Issue;
12
13 /**
14 * Get one issue by number (`issues.get`). A missing issue fails with the typed
15 * {@link IssueNotFound}.
16 *
17 * Provide `GitHub.GetIssueHttp` on a Worker or Function, or
18 * `GitHub.GetIssueLocal` on an Action.
19 *
20 * ### Reading Issues at Runtime
21 * **Example:** Get an issue, treating a missing one as absent
22 * ```typescript
23 * const getIssue = yield* GitHub.GetIssue(yield* Repo);
24 * const issue = yield* getIssue({ issue_number: 7 }).pipe(
25 * Effect.catchTag("IssueNotFound", () => Effect.succeed(undefined)),
26 * );
27 * ```
28 *
29 * @binding
30 * @product Issue
31 */
32 export interface GetIssue extends Binding.Service<
33 GetIssue,
34 "GitHub.GetIssue",
35 (
36 repo: Repository,
37 ) => Effect.Effect<
38 (
39 request: GetIssueRequest,
40 ) => Effect.Effect<
41 GetIssueResponse,
42 Exclude<Issues.GetError, NotFound> | IssueNotFound,
43 RuntimeContext
44 >
45 >
46 > {}
47
48 export const GetIssue = Binding.Service<GetIssue>("GitHub.GetIssue");