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

CreateIssue.ts

43 lines1.2 KB

1import type * as Issues from "@distilled.cloud/github/issues";
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 CreateIssueRequest extends Omit<Issues.CreateRequest, "owner" | "repo"> {}
8​
9export type CreateIssueResponse = Issues.Issue;
10​
11/**
12 * Open an issue in the bound repository (`issues.create`).
13 *
14 * Provide `GitHub.CreateIssueHttp` on a Worker or Function, or
15 * `GitHub.CreateIssueLocal` on an Action.
16 *
17 * ### Opening Issues at Runtime
18 * **Example:** Open an issue from a Worker
19 * ```typescript
20 * const createIssue = yield* GitHub.CreateIssue(yield* Repo);
21 * const issue = yield* createIssue({
22 * title: "Deploy failed",
23 * body: "See the logs for details.",
24 * labels: ["incident"],
25 * });
26 * ```
27 *
28 * @binding
29 * @product Issue
30 */
31export interface CreateIssue extends Binding.Service<
32 CreateIssue,
33 "GitHub.CreateIssue",
34 (
35 repo: Repository,
36 ) => Effect.Effect<
37 (
38 request: CreateIssueRequest,
39 ) => Effect.Effect<CreateIssueResponse, Issues.CreateError, RuntimeContext>
40 >
41> {}
42​
43export const CreateIssue = Binding.Service<CreateIssue>("GitHub.CreateIssue");