Open History to see the last commit
1import * as Issues from "@distilled.cloud/github/issues";
2import * as Effect from "effect/Effect";
3import * as Layer from "effect/Layer";
4import * as BindingHttp from "./BindingHttp.ts";
5import { IssueNotFound } from "./Errors.ts";
6import { UpdateIssue, type UpdateIssueRequest } from "./UpdateIssue.ts";
7
8export 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 */
33export const UpdateIssueHttp = Layer.effect(UpdateIssue, BindingHttp.make(updateIssueOperation));