@briefkasten/adapter-github 0.0.0-stage → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Lukas Mateffy
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,47 @@
1
- # Temporary Holding Version
1
+ # @briefkasten/adapter-github
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ The GitHub adapter for [briefkasten](https://www.npmjs.com/package/briefkasten): repository and
4
+ organisation webhooks, verified with `X-Hub-Signature-256`, as typed events
5
+ (`github:pull_request.opened`, `github:push`, …). It can also register the webhooks of your
6
+ repositories, and has typed builders that make and sign GitHub's deliveries for tests.
7
+
8
+ ```bash
9
+ npm install briefkasten @briefkasten/adapter-github
10
+ ```
11
+
12
+ ```ts
13
+ import { briefkasten } from "briefkasten";
14
+ import { github } from "@briefkasten/adapter-github";
15
+
16
+ const hooks = briefkasten({
17
+ sources: {
18
+ github: github({ secret: process.env.GITHUB_WEBHOOK_SECRET ?? "", repos: ["acme/shop"] }),
19
+ },
20
+ });
21
+
22
+ hooks.on("github:pull_request.opened", async (event) => {
23
+ console.log(event.body.pull_request.title);
24
+ });
25
+
26
+ // Mount it: a fetch handler, or `hooks.node` for Express and node:http.
27
+ app.post("/webhooks/*", (c) => hooks.fetch(c.req.raw));
28
+ ```
29
+
30
+ The event name is GitHub's `X-GitHub-Event` and, where there is one, the payload's `action`. The
31
+ body is GitHub's payload, typed by the event's name.
32
+
33
+ A test delivery, signed the way GitHub signs it:
34
+
35
+ ```ts
36
+ import { send } from "briefkasten";
37
+
38
+ await send({
39
+ url: "https://example.com/webhooks/github",
40
+ secret,
41
+ delivery: github.events.pullRequest.opened({ repo: "acme/shop", number: 42 }),
42
+ });
43
+ ```
44
+
45
+ Docs: <https://briefkasten.fabrik.computer/docs/adapters/github>
46
+
47
+ MIT licensed.
@@ -0,0 +1,605 @@
1
+ import { Adapter, AdapterBinding } from "briefkasten";
2
+ import { z } from "zod";
3
+ //#region src/github-schemas.d.ts
4
+ declare const events: {
5
+ ping: z.ZodObject<{
6
+ zen: z.ZodOptional<z.ZodString>;
7
+ hook_id: z.ZodOptional<z.ZodNumber>;
8
+ repository: z.ZodOptional<z.ZodObject<{
9
+ id: z.ZodNumber;
10
+ full_name: z.ZodString;
11
+ html_url: z.ZodString;
12
+ default_branch: z.ZodString;
13
+ private: z.ZodOptional<z.ZodBoolean>;
14
+ description: z.ZodOptional<z.ZodNullable<z.ZodString>>;
15
+ }, z.core.$strip>>;
16
+ }, z.core.$strip>;
17
+ push: z.ZodObject<{
18
+ ref: z.ZodString;
19
+ before: z.ZodString;
20
+ after: z.ZodString;
21
+ created: z.ZodOptional<z.ZodBoolean>;
22
+ deleted: z.ZodOptional<z.ZodBoolean>;
23
+ forced: z.ZodOptional<z.ZodBoolean>;
24
+ pusher: z.ZodOptional<z.ZodNullable<z.ZodObject<{
25
+ name: z.ZodString;
26
+ email: z.ZodOptional<z.ZodNullable<z.ZodString>>;
27
+ username: z.ZodOptional<z.ZodNullable<z.ZodString>>;
28
+ }, z.core.$strip>>>;
29
+ repository: z.ZodObject<{
30
+ id: z.ZodNumber;
31
+ full_name: z.ZodString;
32
+ html_url: z.ZodString;
33
+ default_branch: z.ZodString;
34
+ private: z.ZodOptional<z.ZodBoolean>;
35
+ description: z.ZodOptional<z.ZodNullable<z.ZodString>>;
36
+ }, z.core.$strip>;
37
+ commits: z.ZodDefault<z.ZodArray<z.ZodObject<{
38
+ id: z.ZodString;
39
+ message: z.ZodString;
40
+ timestamp: z.ZodString;
41
+ url: z.ZodString;
42
+ author: z.ZodObject<{
43
+ name: z.ZodString;
44
+ email: z.ZodOptional<z.ZodNullable<z.ZodString>>;
45
+ username: z.ZodOptional<z.ZodNullable<z.ZodString>>;
46
+ }, z.core.$strip>;
47
+ committer: z.ZodObject<{
48
+ name: z.ZodString;
49
+ email: z.ZodOptional<z.ZodNullable<z.ZodString>>;
50
+ username: z.ZodOptional<z.ZodNullable<z.ZodString>>;
51
+ }, z.core.$strip>;
52
+ added: z.ZodDefault<z.ZodArray<z.ZodString>>;
53
+ removed: z.ZodDefault<z.ZodArray<z.ZodString>>;
54
+ modified: z.ZodDefault<z.ZodArray<z.ZodString>>;
55
+ }, z.core.$strip>>>;
56
+ head_commit: z.ZodOptional<z.ZodNullable<z.ZodObject<{
57
+ id: z.ZodString;
58
+ message: z.ZodString;
59
+ timestamp: z.ZodString;
60
+ url: z.ZodString;
61
+ author: z.ZodObject<{
62
+ name: z.ZodString;
63
+ email: z.ZodOptional<z.ZodNullable<z.ZodString>>;
64
+ username: z.ZodOptional<z.ZodNullable<z.ZodString>>;
65
+ }, z.core.$strip>;
66
+ committer: z.ZodObject<{
67
+ name: z.ZodString;
68
+ email: z.ZodOptional<z.ZodNullable<z.ZodString>>;
69
+ username: z.ZodOptional<z.ZodNullable<z.ZodString>>;
70
+ }, z.core.$strip>;
71
+ added: z.ZodDefault<z.ZodArray<z.ZodString>>;
72
+ removed: z.ZodDefault<z.ZodArray<z.ZodString>>;
73
+ modified: z.ZodDefault<z.ZodArray<z.ZodString>>;
74
+ }, z.core.$strip>>>;
75
+ sender: z.ZodOptional<z.ZodNullable<z.ZodObject<{
76
+ login: z.ZodString;
77
+ html_url: z.ZodOptional<z.ZodNullable<z.ZodString>>;
78
+ type: z.ZodOptional<z.ZodNullable<z.ZodString>>;
79
+ }, z.core.$strip>>>;
80
+ }, z.core.$strip>;
81
+ pull_request: z.ZodObject<{
82
+ action: z.ZodString;
83
+ number: z.ZodNumber;
84
+ repository: z.ZodObject<{
85
+ id: z.ZodNumber;
86
+ full_name: z.ZodString;
87
+ html_url: z.ZodString;
88
+ default_branch: z.ZodString;
89
+ private: z.ZodOptional<z.ZodBoolean>;
90
+ description: z.ZodOptional<z.ZodNullable<z.ZodString>>;
91
+ }, z.core.$strip>;
92
+ pull_request: z.ZodObject<{
93
+ html_url: z.ZodString;
94
+ title: z.ZodString;
95
+ body: z.ZodOptional<z.ZodNullable<z.ZodString>>;
96
+ state: z.ZodString;
97
+ merged: z.ZodOptional<z.ZodNullable<z.ZodBoolean>>;
98
+ mergeable: z.ZodOptional<z.ZodNullable<z.ZodBoolean>>;
99
+ draft: z.ZodOptional<z.ZodBoolean>;
100
+ number: z.ZodNumber;
101
+ updated_at: z.ZodOptional<z.ZodString>;
102
+ additions: z.ZodOptional<z.ZodNumber>;
103
+ deletions: z.ZodOptional<z.ZodNumber>;
104
+ changed_files: z.ZodOptional<z.ZodNumber>;
105
+ comments: z.ZodOptional<z.ZodNumber>;
106
+ labels: z.ZodOptional<z.ZodArray<z.ZodObject<{
107
+ name: z.ZodString;
108
+ color: z.ZodOptional<z.ZodNullable<z.ZodString>>;
109
+ }, z.core.$strip>>>;
110
+ requested_reviewers: z.ZodOptional<z.ZodArray<z.ZodObject<{
111
+ login: z.ZodString;
112
+ }, z.core.$strip>>>;
113
+ requested_teams: z.ZodOptional<z.ZodArray<z.ZodObject<{
114
+ slug: z.ZodString;
115
+ }, z.core.$strip>>>;
116
+ base: z.ZodObject<{
117
+ ref: z.ZodString;
118
+ }, z.core.$strip>;
119
+ head: z.ZodObject<{
120
+ ref: z.ZodString;
121
+ sha: z.ZodOptional<z.ZodNullable<z.ZodString>>;
122
+ }, z.core.$strip>;
123
+ user: z.ZodOptional<z.ZodNullable<z.ZodObject<{
124
+ login: z.ZodString;
125
+ html_url: z.ZodOptional<z.ZodNullable<z.ZodString>>;
126
+ type: z.ZodOptional<z.ZodNullable<z.ZodString>>;
127
+ }, z.core.$strip>>>;
128
+ }, z.core.$strip>;
129
+ sender: z.ZodOptional<z.ZodNullable<z.ZodObject<{
130
+ login: z.ZodString;
131
+ html_url: z.ZodOptional<z.ZodNullable<z.ZodString>>;
132
+ type: z.ZodOptional<z.ZodNullable<z.ZodString>>;
133
+ }, z.core.$strip>>>;
134
+ }, z.core.$strip>;
135
+ issues: z.ZodObject<{
136
+ action: z.ZodString;
137
+ issue: z.ZodObject<{
138
+ html_url: z.ZodString;
139
+ title: z.ZodString;
140
+ body: z.ZodOptional<z.ZodNullable<z.ZodString>>;
141
+ state: z.ZodString;
142
+ number: z.ZodNumber;
143
+ user: z.ZodOptional<z.ZodNullable<z.ZodObject<{
144
+ login: z.ZodString;
145
+ html_url: z.ZodOptional<z.ZodNullable<z.ZodString>>;
146
+ type: z.ZodOptional<z.ZodNullable<z.ZodString>>;
147
+ }, z.core.$strip>>>;
148
+ pull_request: z.ZodOptional<z.ZodNullable<z.ZodObject<{
149
+ html_url: z.ZodOptional<z.ZodNullable<z.ZodString>>;
150
+ }, z.core.$strip>>>;
151
+ }, z.core.$strip>;
152
+ repository: z.ZodObject<{
153
+ id: z.ZodNumber;
154
+ full_name: z.ZodString;
155
+ html_url: z.ZodString;
156
+ default_branch: z.ZodString;
157
+ private: z.ZodOptional<z.ZodBoolean>;
158
+ description: z.ZodOptional<z.ZodNullable<z.ZodString>>;
159
+ }, z.core.$strip>;
160
+ sender: z.ZodOptional<z.ZodNullable<z.ZodObject<{
161
+ login: z.ZodString;
162
+ html_url: z.ZodOptional<z.ZodNullable<z.ZodString>>;
163
+ type: z.ZodOptional<z.ZodNullable<z.ZodString>>;
164
+ }, z.core.$strip>>>;
165
+ label: z.ZodOptional<z.ZodNullable<z.ZodObject<{
166
+ name: z.ZodString;
167
+ }, z.core.$strip>>>;
168
+ }, z.core.$strip>;
169
+ workflow_run: z.ZodObject<{
170
+ action: z.ZodString;
171
+ repository: z.ZodObject<{
172
+ id: z.ZodNumber;
173
+ full_name: z.ZodString;
174
+ html_url: z.ZodString;
175
+ default_branch: z.ZodString;
176
+ private: z.ZodOptional<z.ZodBoolean>;
177
+ description: z.ZodOptional<z.ZodNullable<z.ZodString>>;
178
+ }, z.core.$strip>;
179
+ workflow_run: z.ZodObject<{
180
+ id: z.ZodNumber;
181
+ name: z.ZodOptional<z.ZodNullable<z.ZodString>>;
182
+ head_branch: z.ZodOptional<z.ZodNullable<z.ZodString>>;
183
+ head_sha: z.ZodString;
184
+ status: z.ZodString;
185
+ conclusion: z.ZodOptional<z.ZodNullable<z.ZodString>>;
186
+ html_url: z.ZodString;
187
+ run_number: z.ZodNumber;
188
+ event: z.ZodString;
189
+ pull_requests: z.ZodDefault<z.ZodArray<z.ZodObject<{
190
+ number: z.ZodNumber;
191
+ }, z.core.$strip>>>;
192
+ }, z.core.$strip>;
193
+ sender: z.ZodOptional<z.ZodNullable<z.ZodObject<{
194
+ login: z.ZodString;
195
+ html_url: z.ZodOptional<z.ZodNullable<z.ZodString>>;
196
+ type: z.ZodOptional<z.ZodNullable<z.ZodString>>;
197
+ }, z.core.$strip>>>;
198
+ }, z.core.$strip>;
199
+ issue_comment: z.ZodObject<{
200
+ action: z.ZodString;
201
+ issue: z.ZodObject<{
202
+ html_url: z.ZodString;
203
+ title: z.ZodString;
204
+ body: z.ZodOptional<z.ZodNullable<z.ZodString>>;
205
+ state: z.ZodString;
206
+ number: z.ZodNumber;
207
+ user: z.ZodOptional<z.ZodNullable<z.ZodObject<{
208
+ login: z.ZodString;
209
+ html_url: z.ZodOptional<z.ZodNullable<z.ZodString>>;
210
+ type: z.ZodOptional<z.ZodNullable<z.ZodString>>;
211
+ }, z.core.$strip>>>;
212
+ pull_request: z.ZodOptional<z.ZodNullable<z.ZodObject<{
213
+ html_url: z.ZodOptional<z.ZodNullable<z.ZodString>>;
214
+ }, z.core.$strip>>>;
215
+ }, z.core.$strip>;
216
+ comment: z.ZodObject<{
217
+ id: z.ZodNumber;
218
+ body: z.ZodOptional<z.ZodNullable<z.ZodString>>;
219
+ html_url: z.ZodOptional<z.ZodNullable<z.ZodString>>;
220
+ user: z.ZodOptional<z.ZodNullable<z.ZodObject<{
221
+ login: z.ZodString;
222
+ html_url: z.ZodOptional<z.ZodNullable<z.ZodString>>;
223
+ type: z.ZodOptional<z.ZodNullable<z.ZodString>>;
224
+ }, z.core.$strip>>>;
225
+ }, z.core.$strip>;
226
+ repository: z.ZodObject<{
227
+ id: z.ZodNumber;
228
+ full_name: z.ZodString;
229
+ html_url: z.ZodString;
230
+ default_branch: z.ZodString;
231
+ private: z.ZodOptional<z.ZodBoolean>;
232
+ description: z.ZodOptional<z.ZodNullable<z.ZodString>>;
233
+ }, z.core.$strip>;
234
+ sender: z.ZodOptional<z.ZodNullable<z.ZodObject<{
235
+ login: z.ZodString;
236
+ html_url: z.ZodOptional<z.ZodNullable<z.ZodString>>;
237
+ type: z.ZodOptional<z.ZodNullable<z.ZodString>>;
238
+ }, z.core.$strip>>>;
239
+ }, z.core.$strip>;
240
+ pull_request_review: z.ZodObject<{
241
+ action: z.ZodString;
242
+ pull_request: z.ZodObject<{
243
+ html_url: z.ZodString;
244
+ title: z.ZodString;
245
+ body: z.ZodOptional<z.ZodNullable<z.ZodString>>;
246
+ state: z.ZodString;
247
+ merged: z.ZodOptional<z.ZodNullable<z.ZodBoolean>>;
248
+ mergeable: z.ZodOptional<z.ZodNullable<z.ZodBoolean>>;
249
+ draft: z.ZodOptional<z.ZodBoolean>;
250
+ number: z.ZodNumber;
251
+ updated_at: z.ZodOptional<z.ZodString>;
252
+ additions: z.ZodOptional<z.ZodNumber>;
253
+ deletions: z.ZodOptional<z.ZodNumber>;
254
+ changed_files: z.ZodOptional<z.ZodNumber>;
255
+ comments: z.ZodOptional<z.ZodNumber>;
256
+ labels: z.ZodOptional<z.ZodArray<z.ZodObject<{
257
+ name: z.ZodString;
258
+ color: z.ZodOptional<z.ZodNullable<z.ZodString>>;
259
+ }, z.core.$strip>>>;
260
+ requested_reviewers: z.ZodOptional<z.ZodArray<z.ZodObject<{
261
+ login: z.ZodString;
262
+ }, z.core.$strip>>>;
263
+ requested_teams: z.ZodOptional<z.ZodArray<z.ZodObject<{
264
+ slug: z.ZodString;
265
+ }, z.core.$strip>>>;
266
+ base: z.ZodObject<{
267
+ ref: z.ZodString;
268
+ }, z.core.$strip>;
269
+ head: z.ZodObject<{
270
+ ref: z.ZodString;
271
+ sha: z.ZodOptional<z.ZodNullable<z.ZodString>>;
272
+ }, z.core.$strip>;
273
+ user: z.ZodOptional<z.ZodNullable<z.ZodObject<{
274
+ login: z.ZodString;
275
+ html_url: z.ZodOptional<z.ZodNullable<z.ZodString>>;
276
+ type: z.ZodOptional<z.ZodNullable<z.ZodString>>;
277
+ }, z.core.$strip>>>;
278
+ }, z.core.$strip>;
279
+ review: z.ZodObject<{
280
+ state: z.ZodString;
281
+ body: z.ZodOptional<z.ZodNullable<z.ZodString>>;
282
+ user: z.ZodOptional<z.ZodNullable<z.ZodObject<{
283
+ login: z.ZodString;
284
+ html_url: z.ZodOptional<z.ZodNullable<z.ZodString>>;
285
+ type: z.ZodOptional<z.ZodNullable<z.ZodString>>;
286
+ }, z.core.$strip>>>;
287
+ }, z.core.$strip>;
288
+ repository: z.ZodObject<{
289
+ id: z.ZodNumber;
290
+ full_name: z.ZodString;
291
+ html_url: z.ZodString;
292
+ default_branch: z.ZodString;
293
+ private: z.ZodOptional<z.ZodBoolean>;
294
+ description: z.ZodOptional<z.ZodNullable<z.ZodString>>;
295
+ }, z.core.$strip>;
296
+ sender: z.ZodOptional<z.ZodNullable<z.ZodObject<{
297
+ login: z.ZodString;
298
+ html_url: z.ZodOptional<z.ZodNullable<z.ZodString>>;
299
+ type: z.ZodOptional<z.ZodNullable<z.ZodString>>;
300
+ }, z.core.$strip>>>;
301
+ }, z.core.$strip>;
302
+ pull_request_review_comment: z.ZodObject<{
303
+ action: z.ZodString;
304
+ pull_request: z.ZodObject<{
305
+ html_url: z.ZodString;
306
+ title: z.ZodString;
307
+ body: z.ZodOptional<z.ZodNullable<z.ZodString>>;
308
+ state: z.ZodString;
309
+ merged: z.ZodOptional<z.ZodNullable<z.ZodBoolean>>;
310
+ mergeable: z.ZodOptional<z.ZodNullable<z.ZodBoolean>>;
311
+ draft: z.ZodOptional<z.ZodBoolean>;
312
+ number: z.ZodNumber;
313
+ updated_at: z.ZodOptional<z.ZodString>;
314
+ additions: z.ZodOptional<z.ZodNumber>;
315
+ deletions: z.ZodOptional<z.ZodNumber>;
316
+ changed_files: z.ZodOptional<z.ZodNumber>;
317
+ comments: z.ZodOptional<z.ZodNumber>;
318
+ labels: z.ZodOptional<z.ZodArray<z.ZodObject<{
319
+ name: z.ZodString;
320
+ color: z.ZodOptional<z.ZodNullable<z.ZodString>>;
321
+ }, z.core.$strip>>>;
322
+ requested_reviewers: z.ZodOptional<z.ZodArray<z.ZodObject<{
323
+ login: z.ZodString;
324
+ }, z.core.$strip>>>;
325
+ requested_teams: z.ZodOptional<z.ZodArray<z.ZodObject<{
326
+ slug: z.ZodString;
327
+ }, z.core.$strip>>>;
328
+ base: z.ZodObject<{
329
+ ref: z.ZodString;
330
+ }, z.core.$strip>;
331
+ head: z.ZodObject<{
332
+ ref: z.ZodString;
333
+ sha: z.ZodOptional<z.ZodNullable<z.ZodString>>;
334
+ }, z.core.$strip>;
335
+ user: z.ZodOptional<z.ZodNullable<z.ZodObject<{
336
+ login: z.ZodString;
337
+ html_url: z.ZodOptional<z.ZodNullable<z.ZodString>>;
338
+ type: z.ZodOptional<z.ZodNullable<z.ZodString>>;
339
+ }, z.core.$strip>>>;
340
+ }, z.core.$strip>;
341
+ comment: z.ZodObject<{
342
+ id: z.ZodNumber;
343
+ body: z.ZodOptional<z.ZodNullable<z.ZodString>>;
344
+ html_url: z.ZodOptional<z.ZodNullable<z.ZodString>>;
345
+ user: z.ZodOptional<z.ZodNullable<z.ZodObject<{
346
+ login: z.ZodString;
347
+ html_url: z.ZodOptional<z.ZodNullable<z.ZodString>>;
348
+ type: z.ZodOptional<z.ZodNullable<z.ZodString>>;
349
+ }, z.core.$strip>>>;
350
+ }, z.core.$strip>;
351
+ repository: z.ZodObject<{
352
+ id: z.ZodNumber;
353
+ full_name: z.ZodString;
354
+ html_url: z.ZodString;
355
+ default_branch: z.ZodString;
356
+ private: z.ZodOptional<z.ZodBoolean>;
357
+ description: z.ZodOptional<z.ZodNullable<z.ZodString>>;
358
+ }, z.core.$strip>;
359
+ sender: z.ZodOptional<z.ZodNullable<z.ZodObject<{
360
+ login: z.ZodString;
361
+ html_url: z.ZodOptional<z.ZodNullable<z.ZodString>>;
362
+ type: z.ZodOptional<z.ZodNullable<z.ZodString>>;
363
+ }, z.core.$strip>>>;
364
+ }, z.core.$strip>;
365
+ pull_request_review_thread: z.ZodObject<{
366
+ action: z.ZodString;
367
+ pull_request: z.ZodObject<{
368
+ html_url: z.ZodString;
369
+ title: z.ZodString;
370
+ body: z.ZodOptional<z.ZodNullable<z.ZodString>>;
371
+ state: z.ZodString;
372
+ merged: z.ZodOptional<z.ZodNullable<z.ZodBoolean>>;
373
+ mergeable: z.ZodOptional<z.ZodNullable<z.ZodBoolean>>;
374
+ draft: z.ZodOptional<z.ZodBoolean>;
375
+ number: z.ZodNumber;
376
+ updated_at: z.ZodOptional<z.ZodString>;
377
+ additions: z.ZodOptional<z.ZodNumber>;
378
+ deletions: z.ZodOptional<z.ZodNumber>;
379
+ changed_files: z.ZodOptional<z.ZodNumber>;
380
+ comments: z.ZodOptional<z.ZodNumber>;
381
+ labels: z.ZodOptional<z.ZodArray<z.ZodObject<{
382
+ name: z.ZodString;
383
+ color: z.ZodOptional<z.ZodNullable<z.ZodString>>;
384
+ }, z.core.$strip>>>;
385
+ requested_reviewers: z.ZodOptional<z.ZodArray<z.ZodObject<{
386
+ login: z.ZodString;
387
+ }, z.core.$strip>>>;
388
+ requested_teams: z.ZodOptional<z.ZodArray<z.ZodObject<{
389
+ slug: z.ZodString;
390
+ }, z.core.$strip>>>;
391
+ base: z.ZodObject<{
392
+ ref: z.ZodString;
393
+ }, z.core.$strip>;
394
+ head: z.ZodObject<{
395
+ ref: z.ZodString;
396
+ sha: z.ZodOptional<z.ZodNullable<z.ZodString>>;
397
+ }, z.core.$strip>;
398
+ user: z.ZodOptional<z.ZodNullable<z.ZodObject<{
399
+ login: z.ZodString;
400
+ html_url: z.ZodOptional<z.ZodNullable<z.ZodString>>;
401
+ type: z.ZodOptional<z.ZodNullable<z.ZodString>>;
402
+ }, z.core.$strip>>>;
403
+ }, z.core.$strip>;
404
+ thread: z.ZodOptional<z.ZodNullable<z.ZodObject<{
405
+ node_id: z.ZodOptional<z.ZodNullable<z.ZodString>>;
406
+ }, z.core.$strip>>>;
407
+ repository: z.ZodObject<{
408
+ id: z.ZodNumber;
409
+ full_name: z.ZodString;
410
+ html_url: z.ZodString;
411
+ default_branch: z.ZodString;
412
+ private: z.ZodOptional<z.ZodBoolean>;
413
+ description: z.ZodOptional<z.ZodNullable<z.ZodString>>;
414
+ }, z.core.$strip>;
415
+ sender: z.ZodOptional<z.ZodNullable<z.ZodObject<{
416
+ login: z.ZodString;
417
+ html_url: z.ZodOptional<z.ZodNullable<z.ZodString>>;
418
+ type: z.ZodOptional<z.ZodNullable<z.ZodString>>;
419
+ }, z.core.$strip>>>;
420
+ }, z.core.$strip>;
421
+ check_suite: z.ZodObject<{
422
+ action: z.ZodString;
423
+ check_suite: z.ZodObject<{
424
+ id: z.ZodNumber;
425
+ head_branch: z.ZodOptional<z.ZodNullable<z.ZodString>>;
426
+ head_sha: z.ZodString;
427
+ status: z.ZodOptional<z.ZodNullable<z.ZodString>>;
428
+ conclusion: z.ZodOptional<z.ZodNullable<z.ZodString>>;
429
+ pull_requests: z.ZodDefault<z.ZodArray<z.ZodObject<{
430
+ number: z.ZodNumber;
431
+ }, z.core.$strip>>>;
432
+ }, z.core.$strip>;
433
+ repository: z.ZodObject<{
434
+ id: z.ZodNumber;
435
+ full_name: z.ZodString;
436
+ html_url: z.ZodString;
437
+ default_branch: z.ZodString;
438
+ private: z.ZodOptional<z.ZodBoolean>;
439
+ description: z.ZodOptional<z.ZodNullable<z.ZodString>>;
440
+ }, z.core.$strip>;
441
+ sender: z.ZodOptional<z.ZodNullable<z.ZodObject<{
442
+ login: z.ZodString;
443
+ html_url: z.ZodOptional<z.ZodNullable<z.ZodString>>;
444
+ type: z.ZodOptional<z.ZodNullable<z.ZodString>>;
445
+ }, z.core.$strip>>>;
446
+ }, z.core.$strip>;
447
+ check_run: z.ZodObject<{
448
+ action: z.ZodString;
449
+ check_run: z.ZodObject<{
450
+ id: z.ZodNumber;
451
+ name: z.ZodString;
452
+ head_sha: z.ZodString;
453
+ status: z.ZodString;
454
+ conclusion: z.ZodOptional<z.ZodNullable<z.ZodString>>;
455
+ html_url: z.ZodOptional<z.ZodNullable<z.ZodString>>;
456
+ check_suite: z.ZodOptional<z.ZodNullable<z.ZodObject<{
457
+ id: z.ZodNumber;
458
+ head_branch: z.ZodOptional<z.ZodNullable<z.ZodString>>;
459
+ }, z.core.$strip>>>;
460
+ pull_requests: z.ZodDefault<z.ZodArray<z.ZodObject<{
461
+ number: z.ZodNumber;
462
+ }, z.core.$strip>>>;
463
+ }, z.core.$strip>;
464
+ repository: z.ZodObject<{
465
+ id: z.ZodNumber;
466
+ full_name: z.ZodString;
467
+ html_url: z.ZodString;
468
+ default_branch: z.ZodString;
469
+ private: z.ZodOptional<z.ZodBoolean>;
470
+ description: z.ZodOptional<z.ZodNullable<z.ZodString>>;
471
+ }, z.core.$strip>;
472
+ sender: z.ZodOptional<z.ZodNullable<z.ZodObject<{
473
+ login: z.ZodString;
474
+ html_url: z.ZodOptional<z.ZodNullable<z.ZodString>>;
475
+ type: z.ZodOptional<z.ZodNullable<z.ZodString>>;
476
+ }, z.core.$strip>>>;
477
+ }, z.core.$strip>;
478
+ status: z.ZodObject<{
479
+ sha: z.ZodString;
480
+ state: z.ZodString;
481
+ context: z.ZodString;
482
+ description: z.ZodOptional<z.ZodNullable<z.ZodString>>;
483
+ target_url: z.ZodOptional<z.ZodNullable<z.ZodString>>;
484
+ branches: z.ZodDefault<z.ZodArray<z.ZodObject<{
485
+ name: z.ZodString;
486
+ }, z.core.$strip>>>;
487
+ repository: z.ZodObject<{
488
+ id: z.ZodNumber;
489
+ full_name: z.ZodString;
490
+ html_url: z.ZodString;
491
+ default_branch: z.ZodString;
492
+ private: z.ZodOptional<z.ZodBoolean>;
493
+ description: z.ZodOptional<z.ZodNullable<z.ZodString>>;
494
+ }, z.core.$strip>;
495
+ sender: z.ZodOptional<z.ZodNullable<z.ZodObject<{
496
+ login: z.ZodString;
497
+ html_url: z.ZodOptional<z.ZodNullable<z.ZodString>>;
498
+ type: z.ZodOptional<z.ZodNullable<z.ZodString>>;
499
+ }, z.core.$strip>>>;
500
+ }, z.core.$strip>;
501
+ };
502
+ //#endregion
503
+ //#region src/app-auth.d.ts
504
+ declare const githubAppAuthSchema: z.ZodObject<{
505
+ appId: z.ZodString;
506
+ privateKey: z.ZodOptional<z.ZodString>;
507
+ privateKeyPath: z.ZodOptional<z.ZodString>;
508
+ installationId: z.ZodOptional<z.ZodNumber>;
509
+ apiUrl: z.ZodOptional<z.ZodString>;
510
+ }, z.core.$strip>;
511
+ type GithubAppAuthInput = z.infer<typeof githubAppAuthSchema>;
512
+ /** Returns a token valid for the given repository (`owner/name`). */
513
+ type TokenFor = (repo: string) => Promise<string>;
514
+ interface InstallationToken {
515
+ readonly token: string;
516
+ readonly expiresAtMs: number;
517
+ }
518
+ interface GithubAppTokenSource {
519
+ readonly tokenFor: TokenFor;
520
+ readonly signJwt: (now: number) => string;
521
+ readonly mint: (installationId: number) => Promise<InstallationToken>;
522
+ }
523
+ /** A signed app JWT. `now` is epoch seconds and defaults to the current time. */
524
+ declare function signJwt(input: {
525
+ readonly appId: string;
526
+ readonly privateKey: string;
527
+ readonly now?: number;
528
+ }): string;
529
+ declare function githubAppTokenSource(input: GithubAppAuthInput): GithubAppTokenSource;
530
+ //#endregion
531
+ //#region src/github.d.ts
532
+ /** The auth half of the options: a static PAT or a GitHub App. */
533
+ declare const githubAuthSchema: z.ZodUnion<readonly [z.ZodObject<{
534
+ kind: z.ZodLiteral<"token">;
535
+ token: z.ZodString;
536
+ }, z.core.$strip>, z.ZodObject<{
537
+ kind: z.ZodLiteral<"app">;
538
+ app: z.ZodObject<{
539
+ appId: z.ZodString;
540
+ privateKey: z.ZodOptional<z.ZodString>;
541
+ privateKeyPath: z.ZodOptional<z.ZodString>;
542
+ installationId: z.ZodOptional<z.ZodNumber>;
543
+ apiUrl: z.ZodOptional<z.ZodString>;
544
+ }, z.core.$strip>;
545
+ }, z.core.$strip>]>;
546
+ type GithubAuth = z.infer<typeof githubAuthSchema>;
547
+ declare const githubOptionsSchema: z.ZodObject<{
548
+ auth: z.ZodOptional<z.ZodUnion<readonly [z.ZodObject<{
549
+ kind: z.ZodLiteral<"token">;
550
+ token: z.ZodString;
551
+ }, z.core.$strip>, z.ZodObject<{
552
+ kind: z.ZodLiteral<"app">;
553
+ app: z.ZodObject<{
554
+ appId: z.ZodString;
555
+ privateKey: z.ZodOptional<z.ZodString>;
556
+ privateKeyPath: z.ZodOptional<z.ZodString>;
557
+ installationId: z.ZodOptional<z.ZodNumber>;
558
+ apiUrl: z.ZodOptional<z.ZodString>;
559
+ }, z.core.$strip>;
560
+ }, z.core.$strip>]>>;
561
+ repos: z.ZodOptional<z.ZodArray<z.ZodString>>;
562
+ registerWebhooks: z.ZodOptional<z.ZodBoolean>;
563
+ webhookEvents: z.ZodOptional<z.ZodArray<z.ZodString>>;
564
+ apiUrl: z.ZodOptional<z.ZodString>;
565
+ }, z.core.$strip>;
566
+ type GithubOptions = z.infer<typeof githubOptionsSchema>;
567
+ /** The `github` adapter's definition, which a JSON config names as `"adapter": "github"`. */
568
+ declare const adapter: Adapter<GithubOptions>;
569
+ /**
570
+ * The `github` adapter builder, for a source in a TypeScript config or an embedded app:
571
+ *
572
+ * sources: {
573
+ * github: github({ secret: env("GITHUB_WEBHOOK_SECRET"), auth: { kind: "token", token: env("GITHUB_TOKEN") } }),
574
+ * }
575
+ *
576
+ * `github.events` builds GitHub's deliveries, typed and signed the way GitHub signs:
577
+ * `send({ url, secret, delivery: github.events.pullRequest.opened({ repo: "acme/shop" }) })`.
578
+ */
579
+ declare const github: ((input: GithubOptions & {
580
+ readonly secret: string | undefined;
581
+ }) => AdapterBinding<"github", typeof events>) & {
582
+ events: {
583
+ readonly push: import("briefkasten").DeliveryBuilder;
584
+ readonly pullRequest: {
585
+ readonly opened: import("briefkasten").DeliveryBuilder;
586
+ readonly closed: import("briefkasten").DeliveryBuilder;
587
+ };
588
+ readonly issues: {
589
+ readonly opened: import("briefkasten").DeliveryBuilder;
590
+ };
591
+ readonly issueComment: {
592
+ readonly created: import("briefkasten").DeliveryBuilder;
593
+ };
594
+ readonly checkRun: {
595
+ readonly completed: import("briefkasten").DeliveryBuilder;
596
+ };
597
+ readonly workflowRun: {
598
+ readonly completed: import("briefkasten").DeliveryBuilder;
599
+ };
600
+ };
601
+ };
602
+ /** GitHub's event tables, for a client's typed handlers: `connect<{ github: GithubEvents }>(…)`. */
603
+ type GithubEvents = typeof events;
604
+ //#endregion
605
+ export { type GithubAppAuthInput, type GithubAuth, type GithubEvents, type GithubOptions, type InstallationToken, type TokenFor, adapter, github, githubAppTokenSource, githubAuthSchema, githubOptionsSchema, signJwt };