| 68 | >; |
| 69 | |
| 70 | export class Github implements TriggerIntegration { |
| 71 | // @internal |
| 72 | private _options: GithubIntegrationOptions; |
| 73 | // @internal |
| 74 | private _client?: Octokit; |
| 75 | // @internal |
| 76 | private _io?: IO; |
| 77 | // @internal |
| 78 | private _connectionKey?: string; |
| 79 | |
| 80 | _repoSource: ReturnType<typeof createRepoEventSource>; |
| 81 | _orgSource: ReturnType<typeof createOrgEventSource>; |
| 82 | _repoTrigger: ReturnType<typeof createRepoTrigger>; |
| 83 | _orgTrigger: ReturnType<typeof createOrgTrigger>; |
| 84 | |
| 85 | constructor(private options: GithubIntegrationOptions) { |
| 86 | if (Object.keys(options).includes("token") && !options.token) { |
| 87 | throw `Can't create GitHub integration (${options.id}) as token was undefined`; |
| 88 | } |
| 89 | |
| 90 | this._options = options; |
| 91 | |
| 92 | this._repoSource = createRepoEventSource(this); |
| 93 | this._orgSource = createOrgEventSource(this); |
| 94 | this._repoTrigger = createRepoTrigger(this._repoSource); |
| 95 | this._orgTrigger = createOrgTrigger(this._orgSource); |
| 96 | } |
| 97 | |
| 98 | get id() { |
| 99 | return this.options.id; |
| 100 | } |
| 101 | |
| 102 | get metadata() { |
| 103 | return { name: "GitHub", id: "github" }; |
| 104 | } |
| 105 | |
| 106 | get authSource() { |
| 107 | return this._options.token ? ("LOCAL" as const) : ("HOSTED" as const); |
| 108 | } |
| 109 | |
| 110 | cloneForRun(io: IO, connectionKey: string, auth?: ConnectionAuth) { |
| 111 | const github = new Github(this._options); |
| 112 | github._io = io; |
| 113 | github._connectionKey = connectionKey; |
| 114 | github._client = createClientFromOptions(this._options, auth); |
| 115 | return github; |
| 116 | } |
| 117 | |
| 118 | get sources(): GithubSources { |
| 119 | return { |
| 120 | repo: this._repoSource, |
| 121 | org: this._orgSource, |
| 122 | }; |
| 123 | } |
| 124 | |
| 125 | get triggers(): GithubTriggers { |
| 126 | return { |
| 127 | repo: this._repoTrigger, |
nothing calls this directly
no outgoing calls
no test coverage detected
searching dependent graphs…