forked from triggerdotdev/trigger.dev
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcompound.ts
More file actions
63 lines (60 loc) · 1.57 KB
/
compound.ts
File metadata and controls
63 lines (60 loc) · 1.57 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
import { IntegrationTaskKey } from "@trigger.dev/sdk";
import { Octokit } from "octokit";
import { GitHubReturnType, GitHubRunTask, onError } from "./index";
import { Issues } from "./issues";
import { ReactionContent, Reactions } from "./reactions";
export class Compound {
runTask: GitHubRunTask;
issues: Issues;
reactions: Reactions;
constructor(runTask: GitHubRunTask, issues: Issues, reactions: Reactions) {
this.runTask = runTask;
this.issues = issues;
this.reactions = reactions;
}
createIssueCommentWithReaction(
key: IntegrationTaskKey,
params: {
body: string;
owner: string;
repo: string;
issueNumber: number;
reaction: ReactionContent;
}
): GitHubReturnType<Octokit["rest"]["issues"]["createComment"]> {
return this.runTask(
key,
async () => {
const comment = await this.issues.createComment(
`Comment on Issue #${params.issueNumber}`,
params
);
const reaction = await this.reactions.createForIssueComment(
`React with ${params.reaction}`,
{
owner: params.owner,
repo: params.repo,
commentId: comment.id,
content: params.reaction,
}
);
return comment;
},
{
name: "Create Issue Comment",
params,
properties: [
{
label: "Repo",
text: params.repo,
},
{
label: "Issue",
text: `#${params.issueNumber}`,
},
],
},
onError
);
}
}