@automate.ax/integration-contracts 0.86.2 → 0.87.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/dist/github/additional-events.d.ts +16879 -0
- package/dist/github/additional-events.js +170 -0
- package/dist/github/index.d.ts +61 -1
- package/dist/github/index.js +241 -1
- package/dist/github/resources.d.ts +18379 -0
- package/dist/github/resources.js +141 -0
- package/dist/github/schemas.d.ts +2 -1
- package/dist/github/schemas.js +2 -0
- package/dist/linear/schemas.d.ts +2 -2
- package/package.json +2 -2
- package/src/github/additional-events.ts +704 -0
- package/src/github/index.ts +480 -0
- package/src/github/resources.ts +357 -0
- package/src/github/schemas.ts +3 -0
|
@@ -0,0 +1,704 @@
|
|
|
1
|
+
import type { Encodable } from "@automate.ax/codec"
|
|
2
|
+
import type { webhooks } from "@octokit/openapi-webhooks-types"
|
|
3
|
+
import * as z from "zod"
|
|
4
|
+
|
|
5
|
+
type GitHubWebhookPayload<TKey extends keyof webhooks> =
|
|
6
|
+
webhooks[TKey]["post"] extends {
|
|
7
|
+
requestBody: {
|
|
8
|
+
content: { "application/json": infer TPayload }
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
? TPayload & Record<string, Encodable>
|
|
12
|
+
: never
|
|
13
|
+
|
|
14
|
+
/** Official GitHub check-run webhook payload union. */
|
|
15
|
+
export type GitHubCheckRunEvent = GitHubWebhookPayload<
|
|
16
|
+
Extract<keyof webhooks, `check-run-${string}`>
|
|
17
|
+
>
|
|
18
|
+
export type GitHubCheckRunCreatedEvent =
|
|
19
|
+
GitHubWebhookPayload<"check-run-created">
|
|
20
|
+
export type GitHubCheckRunRerequestedEvent =
|
|
21
|
+
GitHubWebhookPayload<"check-run-rerequested">
|
|
22
|
+
export type GitHubCheckRunRequestedActionEvent =
|
|
23
|
+
GitHubWebhookPayload<"check-run-requested-action">
|
|
24
|
+
export type GitHubCheckRunCompletedEvent =
|
|
25
|
+
GitHubWebhookPayload<"check-run-completed">
|
|
26
|
+
export type GitHubCheckRunSucceededEvent = GitHubCheckRunCompletedEvent & {
|
|
27
|
+
check_run: GitHubCheckRunCompletedEvent["check_run"] & {
|
|
28
|
+
conclusion: "success"
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
export type GitHubCheckRunFailedEvent = GitHubCheckRunCompletedEvent & {
|
|
32
|
+
check_run: GitHubCheckRunCompletedEvent["check_run"] & {
|
|
33
|
+
conclusion: "failure"
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
export type GitHubCheckRunCancelledEvent = GitHubCheckRunCompletedEvent & {
|
|
37
|
+
check_run: GitHubCheckRunCompletedEvent["check_run"] & {
|
|
38
|
+
conclusion: "cancelled"
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
export type GitHubCheckRunTimedOutEvent = GitHubCheckRunCompletedEvent & {
|
|
42
|
+
check_run: GitHubCheckRunCompletedEvent["check_run"] & {
|
|
43
|
+
conclusion: "timed_out"
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
export type GitHubCheckRunStartupFailedEvent = GitHubCheckRunCompletedEvent & {
|
|
47
|
+
check_run: GitHubCheckRunCompletedEvent["check_run"] & {
|
|
48
|
+
conclusion: "startup_failure"
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
export type GitHubCheckRunActionRequiredEvent = GitHubCheckRunCompletedEvent & {
|
|
52
|
+
check_run: GitHubCheckRunCompletedEvent["check_run"] & {
|
|
53
|
+
conclusion: "action_required"
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/** Official GitHub check-suite webhook payload union. */
|
|
58
|
+
export type GitHubCheckSuiteEvent = GitHubWebhookPayload<
|
|
59
|
+
Extract<keyof webhooks, `check-suite-${string}`>
|
|
60
|
+
>
|
|
61
|
+
export type GitHubCheckSuiteCompletedEvent =
|
|
62
|
+
GitHubWebhookPayload<"check-suite-completed">
|
|
63
|
+
export type GitHubCheckSuiteRequestedEvent =
|
|
64
|
+
GitHubWebhookPayload<"check-suite-requested">
|
|
65
|
+
export type GitHubCheckSuiteRerequestedEvent =
|
|
66
|
+
GitHubWebhookPayload<"check-suite-rerequested">
|
|
67
|
+
export type GitHubCheckSuiteSucceededEvent = GitHubCheckSuiteCompletedEvent & {
|
|
68
|
+
check_suite: GitHubCheckSuiteCompletedEvent["check_suite"] & {
|
|
69
|
+
conclusion: "success"
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
export type GitHubCheckSuiteFailedEvent = GitHubCheckSuiteCompletedEvent & {
|
|
73
|
+
check_suite: GitHubCheckSuiteCompletedEvent["check_suite"] & {
|
|
74
|
+
conclusion: "failure"
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
export type GitHubCheckSuiteCancelledEvent = GitHubCheckSuiteCompletedEvent & {
|
|
78
|
+
check_suite: GitHubCheckSuiteCompletedEvent["check_suite"] & {
|
|
79
|
+
conclusion: "cancelled"
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
export type GitHubCheckSuiteTimedOutEvent = GitHubCheckSuiteCompletedEvent & {
|
|
83
|
+
check_suite: GitHubCheckSuiteCompletedEvent["check_suite"] & {
|
|
84
|
+
conclusion: "timed_out"
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
export type GitHubCheckSuiteStartupFailedEvent =
|
|
88
|
+
GitHubCheckSuiteCompletedEvent & {
|
|
89
|
+
check_suite: GitHubCheckSuiteCompletedEvent["check_suite"] & {
|
|
90
|
+
conclusion: "startup_failure"
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
export type GitHubCheckSuiteActionRequiredEvent =
|
|
94
|
+
GitHubCheckSuiteCompletedEvent & {
|
|
95
|
+
check_suite: GitHubCheckSuiteCompletedEvent["check_suite"] & {
|
|
96
|
+
conclusion: "action_required"
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
/** GitHub branch-or-tag creation webhook payload. */
|
|
101
|
+
export type GitHubRefCreatedEvent = GitHubWebhookPayload<"create">
|
|
102
|
+
export type GitHubBranchCreatedEvent = GitHubRefCreatedEvent & {
|
|
103
|
+
ref_type: "branch"
|
|
104
|
+
}
|
|
105
|
+
export type GitHubTagCreatedEvent = GitHubRefCreatedEvent & { ref_type: "tag" }
|
|
106
|
+
|
|
107
|
+
/** GitHub branch-or-tag deletion webhook payload. */
|
|
108
|
+
export type GitHubRefDeletedEvent = GitHubWebhookPayload<"delete">
|
|
109
|
+
export type GitHubBranchDeletedEvent = GitHubRefDeletedEvent & {
|
|
110
|
+
ref_type: "branch"
|
|
111
|
+
}
|
|
112
|
+
export type GitHubTagDeletedEvent = GitHubRefDeletedEvent & { ref_type: "tag" }
|
|
113
|
+
|
|
114
|
+
/** Official GitHub issue-comment webhook payload union. */
|
|
115
|
+
export type GitHubIssueCommentEvent = GitHubWebhookPayload<
|
|
116
|
+
Extract<keyof webhooks, `issue-comment-${string}`>
|
|
117
|
+
>
|
|
118
|
+
export type GitHubIssueCommentCreatedEvent =
|
|
119
|
+
GitHubWebhookPayload<"issue-comment-created">
|
|
120
|
+
export type GitHubIssueCommentEditedEvent =
|
|
121
|
+
GitHubWebhookPayload<"issue-comment-edited">
|
|
122
|
+
export type GitHubIssueCommentDeletedEvent =
|
|
123
|
+
GitHubWebhookPayload<"issue-comment-deleted">
|
|
124
|
+
|
|
125
|
+
/** Official GitHub pull-request review-comment webhook payload union. */
|
|
126
|
+
export type GitHubPullRequestReviewCommentEvent = GitHubWebhookPayload<
|
|
127
|
+
Extract<keyof webhooks, `pull-request-review-comment-${string}`>
|
|
128
|
+
>
|
|
129
|
+
export type GitHubPullRequestReviewCommentCreatedEvent =
|
|
130
|
+
GitHubWebhookPayload<"pull-request-review-comment-created">
|
|
131
|
+
export type GitHubPullRequestReviewCommentEditedEvent =
|
|
132
|
+
GitHubWebhookPayload<"pull-request-review-comment-edited">
|
|
133
|
+
export type GitHubPullRequestReviewCommentDeletedEvent =
|
|
134
|
+
GitHubWebhookPayload<"pull-request-review-comment-deleted">
|
|
135
|
+
|
|
136
|
+
/** Official GitHub workflow-job webhook payload union. */
|
|
137
|
+
export type GitHubWorkflowJobEvent = GitHubWebhookPayload<
|
|
138
|
+
Extract<keyof webhooks, `workflow-job-${string}`>
|
|
139
|
+
>
|
|
140
|
+
export type GitHubWorkflowJobQueuedEvent =
|
|
141
|
+
GitHubWebhookPayload<"workflow-job-queued">
|
|
142
|
+
export type GitHubWorkflowJobStartedEvent =
|
|
143
|
+
GitHubWebhookPayload<"workflow-job-in-progress">
|
|
144
|
+
export type GitHubWorkflowJobWaitingEvent =
|
|
145
|
+
GitHubWebhookPayload<"workflow-job-waiting">
|
|
146
|
+
export type GitHubWorkflowJobCompletedEvent =
|
|
147
|
+
GitHubWebhookPayload<"workflow-job-completed">
|
|
148
|
+
export type GitHubWorkflowJobSucceededEvent =
|
|
149
|
+
GitHubWorkflowJobCompletedEvent & {
|
|
150
|
+
workflow_job: GitHubWorkflowJobCompletedEvent["workflow_job"] & {
|
|
151
|
+
conclusion: "success"
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
export type GitHubWorkflowJobFailedEvent = GitHubWorkflowJobCompletedEvent & {
|
|
155
|
+
workflow_job: GitHubWorkflowJobCompletedEvent["workflow_job"] & {
|
|
156
|
+
conclusion: "failure"
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
export type GitHubWorkflowJobCancelledEvent =
|
|
160
|
+
GitHubWorkflowJobCompletedEvent & {
|
|
161
|
+
workflow_job: GitHubWorkflowJobCompletedEvent["workflow_job"] & {
|
|
162
|
+
conclusion: "cancelled"
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
export type GitHubWorkflowJobTimedOutEvent = GitHubWorkflowJobCompletedEvent & {
|
|
166
|
+
workflow_job: GitHubWorkflowJobCompletedEvent["workflow_job"] & {
|
|
167
|
+
conclusion: "timed_out"
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
/** GitHub repository-dispatch webhook payload. */
|
|
172
|
+
export type GitHubRepositoryDispatchEvent =
|
|
173
|
+
GitHubWebhookPayload<"repository-dispatch-sample.collected">
|
|
174
|
+
|
|
175
|
+
/** GitHub workflow-dispatch webhook payload. */
|
|
176
|
+
export type GitHubWorkflowDispatchEvent =
|
|
177
|
+
GitHubWebhookPayload<"workflow-dispatch">
|
|
178
|
+
|
|
179
|
+
/** GitHub deployment-created webhook payload. */
|
|
180
|
+
export type GitHubDeploymentEvent = GitHubWebhookPayload<"deployment-created">
|
|
181
|
+
|
|
182
|
+
/** GitHub deployment-status webhook payload. */
|
|
183
|
+
export type GitHubDeploymentStatusEvent =
|
|
184
|
+
GitHubWebhookPayload<"deployment-status-created">
|
|
185
|
+
export type GitHubDeploymentQueuedEvent = GitHubDeploymentStatusEvent & {
|
|
186
|
+
deployment_status: GitHubDeploymentStatusEvent["deployment_status"] & {
|
|
187
|
+
state: "queued"
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
export type GitHubDeploymentStartedEvent = GitHubDeploymentStatusEvent & {
|
|
191
|
+
deployment_status: GitHubDeploymentStatusEvent["deployment_status"] & {
|
|
192
|
+
state: "in_progress"
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
export type GitHubDeploymentPendingEvent = GitHubDeploymentStatusEvent & {
|
|
196
|
+
deployment_status: GitHubDeploymentStatusEvent["deployment_status"] & {
|
|
197
|
+
state: "pending"
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
export type GitHubDeploymentInactiveEvent = GitHubDeploymentStatusEvent & {
|
|
201
|
+
deployment_status: GitHubDeploymentStatusEvent["deployment_status"] & {
|
|
202
|
+
state: "inactive"
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
export type GitHubDeploymentSucceededEvent = GitHubDeploymentStatusEvent & {
|
|
206
|
+
deployment_status: GitHubDeploymentStatusEvent["deployment_status"] & {
|
|
207
|
+
state: "success"
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
export type GitHubDeploymentFailedEvent = GitHubDeploymentStatusEvent & {
|
|
211
|
+
deployment_status: GitHubDeploymentStatusEvent["deployment_status"] & {
|
|
212
|
+
state: "failure"
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
export type GitHubDeploymentErroredEvent = GitHubDeploymentStatusEvent & {
|
|
216
|
+
deployment_status: GitHubDeploymentStatusEvent["deployment_status"] & {
|
|
217
|
+
state: "error"
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
/** GitHub commit-status webhook payload. */
|
|
222
|
+
export type GitHubStatusEvent = GitHubWebhookPayload<"status">
|
|
223
|
+
export type GitHubStatusPendingEvent = GitHubStatusEvent & { state: "pending" }
|
|
224
|
+
export type GitHubStatusSucceededEvent = GitHubStatusEvent & {
|
|
225
|
+
state: "success"
|
|
226
|
+
}
|
|
227
|
+
export type GitHubStatusFailedEvent = GitHubStatusEvent & { state: "failure" }
|
|
228
|
+
export type GitHubStatusErroredEvent = GitHubStatusEvent & { state: "error" }
|
|
229
|
+
|
|
230
|
+
const GITHUB_EVENT_BASE_SCHEMA = z.looseObject({
|
|
231
|
+
installation: z.looseObject({ id: z.number().int().positive() }),
|
|
232
|
+
repository: z.looseObject({
|
|
233
|
+
full_name: z.string(),
|
|
234
|
+
id: z.number().int().positive(),
|
|
235
|
+
}),
|
|
236
|
+
sender: z.looseObject({ id: z.number().int().positive(), login: z.string() }),
|
|
237
|
+
})
|
|
238
|
+
const GITHUB_CHECK_RUN_EVENT_BASE_SCHEMA = GITHUB_EVENT_BASE_SCHEMA.extend({
|
|
239
|
+
action: z.string(),
|
|
240
|
+
check_run: z.looseObject({
|
|
241
|
+
conclusion: z.string().nullable(),
|
|
242
|
+
id: z.number().int().positive(),
|
|
243
|
+
status: z.string(),
|
|
244
|
+
}),
|
|
245
|
+
})
|
|
246
|
+
const GITHUB_CHECK_SUITE_EVENT_BASE_SCHEMA = GITHUB_EVENT_BASE_SCHEMA.extend({
|
|
247
|
+
action: z.string(),
|
|
248
|
+
check_suite: z.looseObject({
|
|
249
|
+
conclusion: z.string().nullable(),
|
|
250
|
+
id: z.number().int().positive(),
|
|
251
|
+
status: z.string(),
|
|
252
|
+
}),
|
|
253
|
+
})
|
|
254
|
+
const GITHUB_REF_EVENT_BASE_SCHEMA = GITHUB_EVENT_BASE_SCHEMA.extend({
|
|
255
|
+
ref: z.string(),
|
|
256
|
+
ref_type: z.enum(["branch", "tag"]),
|
|
257
|
+
})
|
|
258
|
+
const GITHUB_ISSUE_COMMENT_EVENT_BASE_SCHEMA = GITHUB_EVENT_BASE_SCHEMA.extend({
|
|
259
|
+
action: z.string(),
|
|
260
|
+
comment: z.looseObject({ id: z.number().int().positive() }),
|
|
261
|
+
issue: z.looseObject({ id: z.number(), number: z.number().int() }),
|
|
262
|
+
})
|
|
263
|
+
const GITHUB_PULL_REQUEST_REVIEW_COMMENT_EVENT_BASE_SCHEMA =
|
|
264
|
+
GITHUB_EVENT_BASE_SCHEMA.extend({
|
|
265
|
+
action: z.string(),
|
|
266
|
+
comment: z.looseObject({ id: z.number().int().positive() }),
|
|
267
|
+
pull_request: z.looseObject({
|
|
268
|
+
id: z.number(),
|
|
269
|
+
number: z.number().int(),
|
|
270
|
+
}),
|
|
271
|
+
})
|
|
272
|
+
const GITHUB_WORKFLOW_JOB_EVENT_BASE_SCHEMA = GITHUB_EVENT_BASE_SCHEMA.extend({
|
|
273
|
+
action: z.string(),
|
|
274
|
+
workflow_job: z.looseObject({
|
|
275
|
+
conclusion: z.string().nullable(),
|
|
276
|
+
id: z.number().int().positive(),
|
|
277
|
+
status: z.string(),
|
|
278
|
+
}),
|
|
279
|
+
})
|
|
280
|
+
const GITHUB_REPOSITORY_DISPATCH_EVENT_BASE_SCHEMA =
|
|
281
|
+
GITHUB_EVENT_BASE_SCHEMA.extend({
|
|
282
|
+
action: z.string(),
|
|
283
|
+
branch: z.string(),
|
|
284
|
+
client_payload: z.record(z.string(), z.json()).nullable(),
|
|
285
|
+
})
|
|
286
|
+
const GITHUB_WORKFLOW_DISPATCH_EVENT_BASE_SCHEMA =
|
|
287
|
+
GITHUB_EVENT_BASE_SCHEMA.extend({
|
|
288
|
+
inputs: z.record(z.string(), z.json()).nullable(),
|
|
289
|
+
ref: z.string(),
|
|
290
|
+
workflow: z.string(),
|
|
291
|
+
})
|
|
292
|
+
const GITHUB_DEPLOYMENT_EVENT_BASE_SCHEMA = GITHUB_EVENT_BASE_SCHEMA.extend({
|
|
293
|
+
action: z.literal("created"),
|
|
294
|
+
deployment: z.looseObject({ id: z.number().int().positive() }),
|
|
295
|
+
})
|
|
296
|
+
const GITHUB_DEPLOYMENT_STATUS_EVENT_BASE_SCHEMA =
|
|
297
|
+
GITHUB_EVENT_BASE_SCHEMA.extend({
|
|
298
|
+
action: z.literal("created"),
|
|
299
|
+
deployment: z.looseObject({ id: z.number().int().positive() }),
|
|
300
|
+
deployment_status: z.looseObject({
|
|
301
|
+
id: z.number().int().positive(),
|
|
302
|
+
state: z.string(),
|
|
303
|
+
}),
|
|
304
|
+
})
|
|
305
|
+
const GITHUB_STATUS_EVENT_BASE_SCHEMA = GITHUB_EVENT_BASE_SCHEMA.extend({
|
|
306
|
+
context: z.string(),
|
|
307
|
+
sha: z.string(),
|
|
308
|
+
state: z.string(),
|
|
309
|
+
})
|
|
310
|
+
|
|
311
|
+
export const GITHUB_CHECK_RUN_EVENT_SCHEMA =
|
|
312
|
+
githubEventSchema<GitHubCheckRunEvent>(GITHUB_CHECK_RUN_EVENT_BASE_SCHEMA)
|
|
313
|
+
export const GITHUB_CHECK_RUN_CREATED_EVENT_SCHEMA = githubSemanticEventSchema<
|
|
314
|
+
GitHubCheckRunEvent,
|
|
315
|
+
GitHubCheckRunCreatedEvent
|
|
316
|
+
>(GITHUB_CHECK_RUN_EVENT_SCHEMA, (event) => event.action === "created")
|
|
317
|
+
export const GITHUB_CHECK_RUN_COMPLETED_EVENT_SCHEMA =
|
|
318
|
+
githubSemanticEventSchema<GitHubCheckRunEvent, GitHubCheckRunCompletedEvent>(
|
|
319
|
+
GITHUB_CHECK_RUN_EVENT_SCHEMA,
|
|
320
|
+
(event) => event.action === "completed",
|
|
321
|
+
)
|
|
322
|
+
export const GITHUB_CHECK_RUN_REREQUESTED_EVENT_SCHEMA =
|
|
323
|
+
githubSemanticEventSchema<
|
|
324
|
+
GitHubCheckRunEvent,
|
|
325
|
+
GitHubCheckRunRerequestedEvent
|
|
326
|
+
>(GITHUB_CHECK_RUN_EVENT_SCHEMA, (event) => event.action === "rerequested")
|
|
327
|
+
export const GITHUB_CHECK_RUN_REQUESTED_ACTION_EVENT_SCHEMA =
|
|
328
|
+
githubSemanticEventSchema<
|
|
329
|
+
GitHubCheckRunEvent,
|
|
330
|
+
GitHubCheckRunRequestedActionEvent
|
|
331
|
+
>(
|
|
332
|
+
GITHUB_CHECK_RUN_EVENT_SCHEMA,
|
|
333
|
+
(event) => event.action === "requested_action",
|
|
334
|
+
)
|
|
335
|
+
export const GITHUB_CHECK_RUN_SUCCEEDED_EVENT_SCHEMA =
|
|
336
|
+
githubSemanticEventSchema<GitHubCheckRunEvent, GitHubCheckRunSucceededEvent>(
|
|
337
|
+
GITHUB_CHECK_RUN_EVENT_SCHEMA,
|
|
338
|
+
(event) =>
|
|
339
|
+
event.action === "completed" && event.check_run.conclusion === "success",
|
|
340
|
+
)
|
|
341
|
+
export const GITHUB_CHECK_RUN_FAILED_EVENT_SCHEMA = githubSemanticEventSchema<
|
|
342
|
+
GitHubCheckRunEvent,
|
|
343
|
+
GitHubCheckRunFailedEvent
|
|
344
|
+
>(
|
|
345
|
+
GITHUB_CHECK_RUN_EVENT_SCHEMA,
|
|
346
|
+
(event) =>
|
|
347
|
+
event.action === "completed" && event.check_run.conclusion === "failure",
|
|
348
|
+
)
|
|
349
|
+
export const GITHUB_CHECK_RUN_CANCELLED_EVENT_SCHEMA =
|
|
350
|
+
githubSemanticEventSchema<GitHubCheckRunEvent, GitHubCheckRunCancelledEvent>(
|
|
351
|
+
GITHUB_CHECK_RUN_EVENT_SCHEMA,
|
|
352
|
+
(event) =>
|
|
353
|
+
event.action === "completed" &&
|
|
354
|
+
event.check_run.conclusion === "cancelled",
|
|
355
|
+
)
|
|
356
|
+
export const GITHUB_CHECK_RUN_TIMED_OUT_EVENT_SCHEMA =
|
|
357
|
+
githubSemanticEventSchema<GitHubCheckRunEvent, GitHubCheckRunTimedOutEvent>(
|
|
358
|
+
GITHUB_CHECK_RUN_EVENT_SCHEMA,
|
|
359
|
+
(event) =>
|
|
360
|
+
event.action === "completed" &&
|
|
361
|
+
event.check_run.conclusion === "timed_out",
|
|
362
|
+
)
|
|
363
|
+
export const GITHUB_CHECK_RUN_STARTUP_FAILED_EVENT_SCHEMA =
|
|
364
|
+
githubSemanticEventSchema<
|
|
365
|
+
GitHubCheckRunEvent,
|
|
366
|
+
GitHubCheckRunStartupFailedEvent
|
|
367
|
+
>(
|
|
368
|
+
GITHUB_CHECK_RUN_EVENT_SCHEMA,
|
|
369
|
+
(event) =>
|
|
370
|
+
event.action === "completed" &&
|
|
371
|
+
event.check_run.conclusion === "startup_failure",
|
|
372
|
+
)
|
|
373
|
+
export const GITHUB_CHECK_RUN_ACTION_REQUIRED_EVENT_SCHEMA =
|
|
374
|
+
githubSemanticEventSchema<
|
|
375
|
+
GitHubCheckRunEvent,
|
|
376
|
+
GitHubCheckRunActionRequiredEvent
|
|
377
|
+
>(
|
|
378
|
+
GITHUB_CHECK_RUN_EVENT_SCHEMA,
|
|
379
|
+
(event) =>
|
|
380
|
+
event.action === "completed" &&
|
|
381
|
+
event.check_run.conclusion === "action_required",
|
|
382
|
+
)
|
|
383
|
+
|
|
384
|
+
export const GITHUB_CHECK_SUITE_EVENT_SCHEMA =
|
|
385
|
+
githubEventSchema<GitHubCheckSuiteEvent>(GITHUB_CHECK_SUITE_EVENT_BASE_SCHEMA)
|
|
386
|
+
export const GITHUB_CHECK_SUITE_COMPLETED_EVENT_SCHEMA =
|
|
387
|
+
githubSemanticEventSchema<
|
|
388
|
+
GitHubCheckSuiteEvent,
|
|
389
|
+
GitHubCheckSuiteCompletedEvent
|
|
390
|
+
>(GITHUB_CHECK_SUITE_EVENT_SCHEMA, (event) => event.action === "completed")
|
|
391
|
+
export const GITHUB_CHECK_SUITE_REQUESTED_EVENT_SCHEMA =
|
|
392
|
+
githubSemanticEventSchema<
|
|
393
|
+
GitHubCheckSuiteEvent,
|
|
394
|
+
GitHubCheckSuiteRequestedEvent
|
|
395
|
+
>(GITHUB_CHECK_SUITE_EVENT_SCHEMA, (event) => event.action === "requested")
|
|
396
|
+
export const GITHUB_CHECK_SUITE_REREQUESTED_EVENT_SCHEMA =
|
|
397
|
+
githubSemanticEventSchema<
|
|
398
|
+
GitHubCheckSuiteEvent,
|
|
399
|
+
GitHubCheckSuiteRerequestedEvent
|
|
400
|
+
>(GITHUB_CHECK_SUITE_EVENT_SCHEMA, (event) => event.action === "rerequested")
|
|
401
|
+
export const GITHUB_CHECK_SUITE_SUCCEEDED_EVENT_SCHEMA =
|
|
402
|
+
githubSemanticEventSchema<
|
|
403
|
+
GitHubCheckSuiteEvent,
|
|
404
|
+
GitHubCheckSuiteSucceededEvent
|
|
405
|
+
>(
|
|
406
|
+
GITHUB_CHECK_SUITE_EVENT_SCHEMA,
|
|
407
|
+
(event) =>
|
|
408
|
+
event.action === "completed" &&
|
|
409
|
+
event.check_suite.conclusion === "success",
|
|
410
|
+
)
|
|
411
|
+
export const GITHUB_CHECK_SUITE_FAILED_EVENT_SCHEMA = githubSemanticEventSchema<
|
|
412
|
+
GitHubCheckSuiteEvent,
|
|
413
|
+
GitHubCheckSuiteFailedEvent
|
|
414
|
+
>(
|
|
415
|
+
GITHUB_CHECK_SUITE_EVENT_SCHEMA,
|
|
416
|
+
(event) =>
|
|
417
|
+
event.action === "completed" && event.check_suite.conclusion === "failure",
|
|
418
|
+
)
|
|
419
|
+
export const GITHUB_CHECK_SUITE_CANCELLED_EVENT_SCHEMA =
|
|
420
|
+
githubSemanticEventSchema<
|
|
421
|
+
GitHubCheckSuiteEvent,
|
|
422
|
+
GitHubCheckSuiteCancelledEvent
|
|
423
|
+
>(
|
|
424
|
+
GITHUB_CHECK_SUITE_EVENT_SCHEMA,
|
|
425
|
+
(event) =>
|
|
426
|
+
event.action === "completed" &&
|
|
427
|
+
event.check_suite.conclusion === "cancelled",
|
|
428
|
+
)
|
|
429
|
+
export const GITHUB_CHECK_SUITE_TIMED_OUT_EVENT_SCHEMA =
|
|
430
|
+
githubSemanticEventSchema<
|
|
431
|
+
GitHubCheckSuiteEvent,
|
|
432
|
+
GitHubCheckSuiteTimedOutEvent
|
|
433
|
+
>(
|
|
434
|
+
GITHUB_CHECK_SUITE_EVENT_SCHEMA,
|
|
435
|
+
(event) =>
|
|
436
|
+
event.action === "completed" &&
|
|
437
|
+
event.check_suite.conclusion === "timed_out",
|
|
438
|
+
)
|
|
439
|
+
export const GITHUB_CHECK_SUITE_STARTUP_FAILED_EVENT_SCHEMA =
|
|
440
|
+
githubSemanticEventSchema<
|
|
441
|
+
GitHubCheckSuiteEvent,
|
|
442
|
+
GitHubCheckSuiteStartupFailedEvent
|
|
443
|
+
>(
|
|
444
|
+
GITHUB_CHECK_SUITE_EVENT_SCHEMA,
|
|
445
|
+
(event) =>
|
|
446
|
+
event.action === "completed" &&
|
|
447
|
+
event.check_suite.conclusion === "startup_failure",
|
|
448
|
+
)
|
|
449
|
+
export const GITHUB_CHECK_SUITE_ACTION_REQUIRED_EVENT_SCHEMA =
|
|
450
|
+
githubSemanticEventSchema<
|
|
451
|
+
GitHubCheckSuiteEvent,
|
|
452
|
+
GitHubCheckSuiteActionRequiredEvent
|
|
453
|
+
>(
|
|
454
|
+
GITHUB_CHECK_SUITE_EVENT_SCHEMA,
|
|
455
|
+
(event) =>
|
|
456
|
+
event.action === "completed" &&
|
|
457
|
+
event.check_suite.conclusion === "action_required",
|
|
458
|
+
)
|
|
459
|
+
|
|
460
|
+
export const GITHUB_REF_CREATED_EVENT_SCHEMA =
|
|
461
|
+
githubEventSchema<GitHubRefCreatedEvent>(GITHUB_REF_EVENT_BASE_SCHEMA)
|
|
462
|
+
export const GITHUB_BRANCH_CREATED_EVENT_SCHEMA = githubSemanticEventSchema<
|
|
463
|
+
GitHubRefCreatedEvent,
|
|
464
|
+
GitHubBranchCreatedEvent
|
|
465
|
+
>(GITHUB_REF_CREATED_EVENT_SCHEMA, (event) => event.ref_type === "branch")
|
|
466
|
+
export const GITHUB_TAG_CREATED_EVENT_SCHEMA = githubSemanticEventSchema<
|
|
467
|
+
GitHubRefCreatedEvent,
|
|
468
|
+
GitHubTagCreatedEvent
|
|
469
|
+
>(GITHUB_REF_CREATED_EVENT_SCHEMA, (event) => event.ref_type === "tag")
|
|
470
|
+
export const GITHUB_REF_DELETED_EVENT_SCHEMA =
|
|
471
|
+
githubEventSchema<GitHubRefDeletedEvent>(GITHUB_REF_EVENT_BASE_SCHEMA)
|
|
472
|
+
export const GITHUB_BRANCH_DELETED_EVENT_SCHEMA = githubSemanticEventSchema<
|
|
473
|
+
GitHubRefDeletedEvent,
|
|
474
|
+
GitHubBranchDeletedEvent
|
|
475
|
+
>(GITHUB_REF_DELETED_EVENT_SCHEMA, (event) => event.ref_type === "branch")
|
|
476
|
+
export const GITHUB_TAG_DELETED_EVENT_SCHEMA = githubSemanticEventSchema<
|
|
477
|
+
GitHubRefDeletedEvent,
|
|
478
|
+
GitHubTagDeletedEvent
|
|
479
|
+
>(GITHUB_REF_DELETED_EVENT_SCHEMA, (event) => event.ref_type === "tag")
|
|
480
|
+
|
|
481
|
+
export const GITHUB_ISSUE_COMMENT_EVENT_SCHEMA =
|
|
482
|
+
githubEventSchema<GitHubIssueCommentEvent>(
|
|
483
|
+
GITHUB_ISSUE_COMMENT_EVENT_BASE_SCHEMA,
|
|
484
|
+
)
|
|
485
|
+
export const GITHUB_ISSUE_COMMENT_CREATED_EVENT_SCHEMA =
|
|
486
|
+
githubSemanticEventSchema<
|
|
487
|
+
GitHubIssueCommentEvent,
|
|
488
|
+
GitHubIssueCommentCreatedEvent
|
|
489
|
+
>(GITHUB_ISSUE_COMMENT_EVENT_SCHEMA, (event) => event.action === "created")
|
|
490
|
+
export const GITHUB_ISSUE_COMMENT_EDITED_EVENT_SCHEMA =
|
|
491
|
+
githubSemanticEventSchema<
|
|
492
|
+
GitHubIssueCommentEvent,
|
|
493
|
+
GitHubIssueCommentEditedEvent
|
|
494
|
+
>(GITHUB_ISSUE_COMMENT_EVENT_SCHEMA, (event) => event.action === "edited")
|
|
495
|
+
export const GITHUB_ISSUE_COMMENT_DELETED_EVENT_SCHEMA =
|
|
496
|
+
githubSemanticEventSchema<
|
|
497
|
+
GitHubIssueCommentEvent,
|
|
498
|
+
GitHubIssueCommentDeletedEvent
|
|
499
|
+
>(GITHUB_ISSUE_COMMENT_EVENT_SCHEMA, (event) => event.action === "deleted")
|
|
500
|
+
|
|
501
|
+
export const GITHUB_PULL_REQUEST_REVIEW_COMMENT_EVENT_SCHEMA =
|
|
502
|
+
githubEventSchema<GitHubPullRequestReviewCommentEvent>(
|
|
503
|
+
GITHUB_PULL_REQUEST_REVIEW_COMMENT_EVENT_BASE_SCHEMA,
|
|
504
|
+
)
|
|
505
|
+
export const GITHUB_PULL_REQUEST_REVIEW_COMMENT_CREATED_EVENT_SCHEMA =
|
|
506
|
+
githubSemanticEventSchema<
|
|
507
|
+
GitHubPullRequestReviewCommentEvent,
|
|
508
|
+
GitHubPullRequestReviewCommentCreatedEvent
|
|
509
|
+
>(
|
|
510
|
+
GITHUB_PULL_REQUEST_REVIEW_COMMENT_EVENT_SCHEMA,
|
|
511
|
+
(event) => event.action === "created",
|
|
512
|
+
)
|
|
513
|
+
export const GITHUB_PULL_REQUEST_REVIEW_COMMENT_EDITED_EVENT_SCHEMA =
|
|
514
|
+
githubSemanticEventSchema<
|
|
515
|
+
GitHubPullRequestReviewCommentEvent,
|
|
516
|
+
GitHubPullRequestReviewCommentEditedEvent
|
|
517
|
+
>(
|
|
518
|
+
GITHUB_PULL_REQUEST_REVIEW_COMMENT_EVENT_SCHEMA,
|
|
519
|
+
(event) => event.action === "edited",
|
|
520
|
+
)
|
|
521
|
+
export const GITHUB_PULL_REQUEST_REVIEW_COMMENT_DELETED_EVENT_SCHEMA =
|
|
522
|
+
githubSemanticEventSchema<
|
|
523
|
+
GitHubPullRequestReviewCommentEvent,
|
|
524
|
+
GitHubPullRequestReviewCommentDeletedEvent
|
|
525
|
+
>(
|
|
526
|
+
GITHUB_PULL_REQUEST_REVIEW_COMMENT_EVENT_SCHEMA,
|
|
527
|
+
(event) => event.action === "deleted",
|
|
528
|
+
)
|
|
529
|
+
|
|
530
|
+
export const GITHUB_WORKFLOW_JOB_EVENT_SCHEMA =
|
|
531
|
+
githubEventSchema<GitHubWorkflowJobEvent>(
|
|
532
|
+
GITHUB_WORKFLOW_JOB_EVENT_BASE_SCHEMA,
|
|
533
|
+
)
|
|
534
|
+
export const GITHUB_WORKFLOW_JOB_QUEUED_EVENT_SCHEMA =
|
|
535
|
+
githubSemanticEventSchema<
|
|
536
|
+
GitHubWorkflowJobEvent,
|
|
537
|
+
GitHubWorkflowJobQueuedEvent
|
|
538
|
+
>(GITHUB_WORKFLOW_JOB_EVENT_SCHEMA, (event) => event.action === "queued")
|
|
539
|
+
export const GITHUB_WORKFLOW_JOB_STARTED_EVENT_SCHEMA =
|
|
540
|
+
githubSemanticEventSchema<
|
|
541
|
+
GitHubWorkflowJobEvent,
|
|
542
|
+
GitHubWorkflowJobStartedEvent
|
|
543
|
+
>(GITHUB_WORKFLOW_JOB_EVENT_SCHEMA, (event) => event.action === "in_progress")
|
|
544
|
+
export const GITHUB_WORKFLOW_JOB_WAITING_EVENT_SCHEMA =
|
|
545
|
+
githubSemanticEventSchema<
|
|
546
|
+
GitHubWorkflowJobEvent,
|
|
547
|
+
GitHubWorkflowJobWaitingEvent
|
|
548
|
+
>(GITHUB_WORKFLOW_JOB_EVENT_SCHEMA, (event) => event.action === "waiting")
|
|
549
|
+
export const GITHUB_WORKFLOW_JOB_COMPLETED_EVENT_SCHEMA =
|
|
550
|
+
githubSemanticEventSchema<
|
|
551
|
+
GitHubWorkflowJobEvent,
|
|
552
|
+
GitHubWorkflowJobCompletedEvent
|
|
553
|
+
>(GITHUB_WORKFLOW_JOB_EVENT_SCHEMA, (event) => event.action === "completed")
|
|
554
|
+
export const GITHUB_WORKFLOW_JOB_SUCCEEDED_EVENT_SCHEMA =
|
|
555
|
+
githubSemanticEventSchema<
|
|
556
|
+
GitHubWorkflowJobEvent,
|
|
557
|
+
GitHubWorkflowJobSucceededEvent
|
|
558
|
+
>(
|
|
559
|
+
GITHUB_WORKFLOW_JOB_EVENT_SCHEMA,
|
|
560
|
+
(event) =>
|
|
561
|
+
event.action === "completed" &&
|
|
562
|
+
event.workflow_job.conclusion === "success",
|
|
563
|
+
)
|
|
564
|
+
export const GITHUB_WORKFLOW_JOB_FAILED_EVENT_SCHEMA =
|
|
565
|
+
githubSemanticEventSchema<
|
|
566
|
+
GitHubWorkflowJobEvent,
|
|
567
|
+
GitHubWorkflowJobFailedEvent
|
|
568
|
+
>(
|
|
569
|
+
GITHUB_WORKFLOW_JOB_EVENT_SCHEMA,
|
|
570
|
+
(event) =>
|
|
571
|
+
event.action === "completed" &&
|
|
572
|
+
event.workflow_job.conclusion === "failure",
|
|
573
|
+
)
|
|
574
|
+
export const GITHUB_WORKFLOW_JOB_CANCELLED_EVENT_SCHEMA =
|
|
575
|
+
githubSemanticEventSchema<
|
|
576
|
+
GitHubWorkflowJobEvent,
|
|
577
|
+
GitHubWorkflowJobCancelledEvent
|
|
578
|
+
>(
|
|
579
|
+
GITHUB_WORKFLOW_JOB_EVENT_SCHEMA,
|
|
580
|
+
(event) =>
|
|
581
|
+
event.action === "completed" &&
|
|
582
|
+
event.workflow_job.conclusion === "cancelled",
|
|
583
|
+
)
|
|
584
|
+
export const GITHUB_WORKFLOW_JOB_TIMED_OUT_EVENT_SCHEMA =
|
|
585
|
+
githubSemanticEventSchema<
|
|
586
|
+
GitHubWorkflowJobEvent,
|
|
587
|
+
GitHubWorkflowJobTimedOutEvent
|
|
588
|
+
>(
|
|
589
|
+
GITHUB_WORKFLOW_JOB_EVENT_SCHEMA,
|
|
590
|
+
(event) =>
|
|
591
|
+
event.action === "completed" &&
|
|
592
|
+
event.workflow_job.conclusion === "timed_out",
|
|
593
|
+
)
|
|
594
|
+
|
|
595
|
+
export const GITHUB_REPOSITORY_DISPATCH_EVENT_SCHEMA =
|
|
596
|
+
githubEventSchema<GitHubRepositoryDispatchEvent>(
|
|
597
|
+
GITHUB_REPOSITORY_DISPATCH_EVENT_BASE_SCHEMA,
|
|
598
|
+
)
|
|
599
|
+
export const GITHUB_WORKFLOW_DISPATCH_EVENT_SCHEMA =
|
|
600
|
+
githubEventSchema<GitHubWorkflowDispatchEvent>(
|
|
601
|
+
GITHUB_WORKFLOW_DISPATCH_EVENT_BASE_SCHEMA,
|
|
602
|
+
)
|
|
603
|
+
export const GITHUB_DEPLOYMENT_EVENT_SCHEMA =
|
|
604
|
+
githubEventSchema<GitHubDeploymentEvent>(GITHUB_DEPLOYMENT_EVENT_BASE_SCHEMA)
|
|
605
|
+
export const GITHUB_DEPLOYMENT_STATUS_EVENT_SCHEMA =
|
|
606
|
+
githubEventSchema<GitHubDeploymentStatusEvent>(
|
|
607
|
+
GITHUB_DEPLOYMENT_STATUS_EVENT_BASE_SCHEMA,
|
|
608
|
+
)
|
|
609
|
+
export const GITHUB_DEPLOYMENT_QUEUED_EVENT_SCHEMA = githubSemanticEventSchema<
|
|
610
|
+
GitHubDeploymentStatusEvent,
|
|
611
|
+
GitHubDeploymentQueuedEvent
|
|
612
|
+
>(
|
|
613
|
+
GITHUB_DEPLOYMENT_STATUS_EVENT_SCHEMA,
|
|
614
|
+
(event) => event.deployment_status.state === "queued",
|
|
615
|
+
)
|
|
616
|
+
export const GITHUB_DEPLOYMENT_STARTED_EVENT_SCHEMA = githubSemanticEventSchema<
|
|
617
|
+
GitHubDeploymentStatusEvent,
|
|
618
|
+
GitHubDeploymentStartedEvent
|
|
619
|
+
>(
|
|
620
|
+
GITHUB_DEPLOYMENT_STATUS_EVENT_SCHEMA,
|
|
621
|
+
(event) => event.deployment_status.state === "in_progress",
|
|
622
|
+
)
|
|
623
|
+
export const GITHUB_DEPLOYMENT_PENDING_EVENT_SCHEMA = githubSemanticEventSchema<
|
|
624
|
+
GitHubDeploymentStatusEvent,
|
|
625
|
+
GitHubDeploymentPendingEvent
|
|
626
|
+
>(
|
|
627
|
+
GITHUB_DEPLOYMENT_STATUS_EVENT_SCHEMA,
|
|
628
|
+
(event) => event.deployment_status.state === "pending",
|
|
629
|
+
)
|
|
630
|
+
export const GITHUB_DEPLOYMENT_INACTIVE_EVENT_SCHEMA =
|
|
631
|
+
githubSemanticEventSchema<
|
|
632
|
+
GitHubDeploymentStatusEvent,
|
|
633
|
+
GitHubDeploymentInactiveEvent
|
|
634
|
+
>(
|
|
635
|
+
GITHUB_DEPLOYMENT_STATUS_EVENT_SCHEMA,
|
|
636
|
+
(event) => event.deployment_status.state === "inactive",
|
|
637
|
+
)
|
|
638
|
+
export const GITHUB_DEPLOYMENT_SUCCEEDED_EVENT_SCHEMA =
|
|
639
|
+
githubSemanticEventSchema<
|
|
640
|
+
GitHubDeploymentStatusEvent,
|
|
641
|
+
GitHubDeploymentSucceededEvent
|
|
642
|
+
>(
|
|
643
|
+
GITHUB_DEPLOYMENT_STATUS_EVENT_SCHEMA,
|
|
644
|
+
(event) => event.deployment_status.state === "success",
|
|
645
|
+
)
|
|
646
|
+
export const GITHUB_DEPLOYMENT_FAILED_EVENT_SCHEMA = githubSemanticEventSchema<
|
|
647
|
+
GitHubDeploymentStatusEvent,
|
|
648
|
+
GitHubDeploymentFailedEvent
|
|
649
|
+
>(
|
|
650
|
+
GITHUB_DEPLOYMENT_STATUS_EVENT_SCHEMA,
|
|
651
|
+
(event) => event.deployment_status.state === "failure",
|
|
652
|
+
)
|
|
653
|
+
export const GITHUB_DEPLOYMENT_ERRORED_EVENT_SCHEMA = githubSemanticEventSchema<
|
|
654
|
+
GitHubDeploymentStatusEvent,
|
|
655
|
+
GitHubDeploymentErroredEvent
|
|
656
|
+
>(
|
|
657
|
+
GITHUB_DEPLOYMENT_STATUS_EVENT_SCHEMA,
|
|
658
|
+
(event) => event.deployment_status.state === "error",
|
|
659
|
+
)
|
|
660
|
+
|
|
661
|
+
export const GITHUB_STATUS_EVENT_SCHEMA = githubEventSchema<GitHubStatusEvent>(
|
|
662
|
+
GITHUB_STATUS_EVENT_BASE_SCHEMA,
|
|
663
|
+
)
|
|
664
|
+
export const GITHUB_STATUS_PENDING_EVENT_SCHEMA = githubSemanticEventSchema<
|
|
665
|
+
GitHubStatusEvent,
|
|
666
|
+
GitHubStatusPendingEvent
|
|
667
|
+
>(GITHUB_STATUS_EVENT_SCHEMA, (event) => event.state === "pending")
|
|
668
|
+
export const GITHUB_STATUS_SUCCEEDED_EVENT_SCHEMA = githubSemanticEventSchema<
|
|
669
|
+
GitHubStatusEvent,
|
|
670
|
+
GitHubStatusSucceededEvent
|
|
671
|
+
>(GITHUB_STATUS_EVENT_SCHEMA, (event) => event.state === "success")
|
|
672
|
+
export const GITHUB_STATUS_FAILED_EVENT_SCHEMA = githubSemanticEventSchema<
|
|
673
|
+
GitHubStatusEvent,
|
|
674
|
+
GitHubStatusFailedEvent
|
|
675
|
+
>(GITHUB_STATUS_EVENT_SCHEMA, (event) => event.state === "failure")
|
|
676
|
+
export const GITHUB_STATUS_ERRORED_EVENT_SCHEMA = githubSemanticEventSchema<
|
|
677
|
+
GitHubStatusEvent,
|
|
678
|
+
GitHubStatusErroredEvent
|
|
679
|
+
>(GITHUB_STATUS_EVENT_SCHEMA, (event) => event.state === "error")
|
|
680
|
+
|
|
681
|
+
/**
|
|
682
|
+
* Validates a typed GitHub webhook family.
|
|
683
|
+
*
|
|
684
|
+
* @param schema - Runtime schema for the webhook family.
|
|
685
|
+
*/
|
|
686
|
+
function githubEventSchema<TEvent>(schema: z.ZodType): z.ZodType<TEvent> {
|
|
687
|
+
return z.custom<TEvent>((value) => schema.safeParse(value).success)
|
|
688
|
+
}
|
|
689
|
+
|
|
690
|
+
/**
|
|
691
|
+
* Narrows a broad GitHub webhook family to one semantic event.
|
|
692
|
+
*
|
|
693
|
+
* @param schema - Runtime schema for the broad webhook family.
|
|
694
|
+
* @param matches - Whether the payload belongs to the semantic event.
|
|
695
|
+
*/
|
|
696
|
+
function githubSemanticEventSchema<TEvent, TSemanticEvent extends TEvent>(
|
|
697
|
+
schema: z.ZodType<TEvent>,
|
|
698
|
+
matches: (event: TEvent) => boolean,
|
|
699
|
+
): z.ZodType<TSemanticEvent> {
|
|
700
|
+
return z.custom<TSemanticEvent>((value) => {
|
|
701
|
+
const event = schema.safeParse(value)
|
|
702
|
+
return event.success && matches(event.data)
|
|
703
|
+
})
|
|
704
|
+
}
|