Skip to content
Source
Sign inSign up
pingdotgg/t3code
Open History to see the last commit

UpdateIssue.ts

50 lines1.5 KB

1import type { NotFound } from "@distilled.cloud/github/Errors";
2import type * as Issues from "@distilled.cloud/github/issues";
3import * as Binding from "alchemy/Binding";
4import type { RuntimeContext } from "alchemy/RuntimeContext";
5import type * as Effect from "effect/Effect";
6import type { IssueNotFound } from "./Errors.ts";
7import type { Repository } from "./Repository.ts";
8​
9export interface UpdateIssueRequest extends Omit<Issues.UpdateRequest, "owner" | "repo"> {}
10​
11export type UpdateIssueResponse = Issues.UpdateResponse;
12​
13/**
14 * Update one issue by number (`issues.update`): state, title, body, labels,
15 * assignees. A missing issue fails with the typed {@link IssueNotFound}.
16 *
17 * Provide `GitHub.UpdateIssueHttp` on a Worker or Function, or
18 * `GitHub.UpdateIssueLocal` on an Action.
19 *
20 * ### Updating Issues at Runtime
21 * **Example:** Close an issue as completed
22 * ```typescript
23 * const updateIssue = yield* GitHub.UpdateIssue(yield* Repo);
24 * yield* updateIssue({
25 * issue_number: 7,
26 * state: "closed",
27 * state_reason: "completed",
28 * });
29 * ```
30 *
31 * @binding
32 * @product Issue
33 */
34export interface UpdateIssue extends Binding.Service<
35 UpdateIssue,
36 "GitHub.UpdateIssue",
37 (
38 repo: Repository,
39 ) => Effect.Effect<
40 (
41 request: UpdateIssueRequest,
42 ) => Effect.Effect<
43 UpdateIssueResponse,
44 Exclude<Issues.UpdateError, NotFound> | IssueNotFound,
45 RuntimeContext
46 >
47 >
48> {}
49​
50export const UpdateIssue = Binding.Service<UpdateIssue>("GitHub.UpdateIssue");