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

CreatePullRequestReview.ts

51 lines1.6 KB

1import type * as Pulls from "@distilled.cloud/github/pulls";
2import * as Binding from "alchemy/Binding";
3import type { RuntimeContext } from "alchemy/RuntimeContext";
4import type * as Effect from "effect/Effect";
5import type { Repository } from "./Repository.ts";
6​
7export interface CreatePullRequestReviewRequest extends Omit<
8 Pulls.CreateReviewRequest,
9 "owner" | "repo"
10> {}
11​
12export type CreatePullRequestReviewResponse = Pulls.PullRequestReview;
13​
14/**
15 * Submit a pull request review (`pulls.createReview`): a `body`, an `event`
16 * verdict (`APPROVE`, `REQUEST_CHANGES` or `COMMENT`) and inline `comments` on
17 * diff lines, in one submission.
18 *
19 * Provide `GitHub.CreatePullRequestReviewHttp` on a Worker or Function, or
20 * `GitHub.CreatePullRequestReviewLocal` on an Action.
21 *
22 * ### Reviewing Pull Requests at Runtime
23 * **Example:** Request changes with an inline comment
24 * ```typescript
25 * const createReview = yield* GitHub.CreatePullRequestReview(yield* Repo);
26 * yield* createReview({
27 * pull_number: 9,
28 * event: "REQUEST_CHANGES",
29 * body: "One problem, inline.",
30 * comments: [{ path: "src/index.ts", line: 42, body: "Off by one." }],
31 * });
32 * ```
33 *
34 * @binding
35 * @product Pull Request
36 */
37export interface CreatePullRequestReview extends Binding.Service<
38 CreatePullRequestReview,
39 "GitHub.CreatePullRequestReview",
40 (
41 repo: Repository,
42 ) => Effect.Effect<
43 (
44 request: CreatePullRequestReviewRequest,
45 ) => Effect.Effect<CreatePullRequestReviewResponse, Pulls.CreateReviewError, RuntimeContext>
46 >
47> {}
48​
49export const CreatePullRequestReview = Binding.Service<CreatePullRequestReview>(
50 "GitHub.CreatePullRequestReview",
51);