| 1 | import { z } from "zod"; |
| 2 | |
| 3 | import type { components |
| 4 | |
| 5 | export type WebhookEvent |
| 6 | |
| 7 | /** In the order the picker lists them. */ |
| 8 | export const webhookEventLabels: |
| 9 | push: "Someone pushes to a branch or tag", |
| 10 | "issue.opened": "An issue or pull request is opened", |
| 11 | "issue.commented": "Someone comments on an issue or pull request", |
| 12 | "issue.assigned": "Someone is assigned", |
| 13 | "issue.closed": "An issue or pull request is closed", |
| 14 | "issue.reopened": "An issue or pull request is reopened", |
| 15 | "pull_request.reviewed": "A pull request is reviewed", |
| 16 | "pull_request.review_commented": "Someone comments on a pull request's code", |
| 17 | "pull_request.merged": "A pull request is merged", |
| 18 | }; |
| 19 | |
| 20 | export const webhookEvents = |
| 21 | WebhookEvent, |
| 22 | ...WebhookEvent[] |
| 23 | ]; |
| 24 | |
| 25 | export const webhookOwnerSchema = |
| 26 | z.object({ |
| 27 | kind: z.literal |
| 28 | username: z.string |
| 29 | repo: z.string |
| 30 | }), |
| 31 | z.object({ |
| 32 | ]); |
| 33 | |
| 34 | export type WebhookOwner |
| 35 | |
| 36 | /** Where the owner's webhook settings live. */ |
| 37 | export function webhooksPath(owner |
| 38 | return owner.kind |
| 39 | ? `/${owner. |
| 40 | : `/${owner. |
| 41 | } |