c0dfa8048a
* feat: BYO Auth Define client-side auth resolvers to be able to supply custom authentication credentials for integrations before a run is performed - Added new defineAuthResolver - Update all integrations to support the new auth resolvers - Strip internal symbols from .d.ts in integrations and trigger-sdk - Added BYO Auth docs - Update Dynamic Schedule to support associated account IDs - Create external accounts just-in-time - Added Account ID field to test job when there are external auth integrations - Show Account ID on run dashboard - Added new Run error state called “Unresolved auth” * Added changeset * Remove @internal from TriggerIntegration public methods * Add void to the result union * DynamicTriggers now work with the new BYO auth system, and added a bunch of docs and docs changes * Add additional key material for registering dynamic trigger task * Add new define* instance methods to the overview
60 lines
1.5 KiB
TypeScript
60 lines
1.5 KiB
TypeScript
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 {
|
|
constructor(
|
|
private runTask: GitHubRunTask,
|
|
public issues: Issues,
|
|
public 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
|
|
);
|
|
}
|
|
}
|