| 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.edited": "An issue or pull request's title or description is edited", |
| 12 | "issue.closed": "An issue or pull request is closed", |
| 13 | "issue.reopened": "An issue or pull request is reopened", |
| 14 | "issue.assigned": "Someone is assigned", |
| 15 | "issue.unassigned": "Someone is unassigned", |
| 16 | "issue.labeled": "A label is added to an issue or pull request", |
| 17 | "issue.unlabeled": "A label is removed from an issue or pull request", |
| 18 | "issue.commented": "Someone comments on an issue or pull request", |
| 19 | "issue.comment_edited": "A comment on an issue or pull request is edited", |
| 20 | "issue.comment_deleted": "A comment on an issue or pull request is deleted", |
| 21 | "pull_request.ready_for_review": |
| 22 | "A draft pull request is marked ready for review", |
| 23 | "pull_request.converted_to_draft": "A pull request is converted to a draft", |
| 24 | "pull_request.synchronized": "Someone pushes commits to a pull request", |
| 25 | "pull_request.reviewed": "A pull request is reviewed", |
| 26 | "pull_request.review_dismissed": "A pull request review is dismissed", |
| 27 | "pull_request.review_commented": "Someone comments on a pull request's code", |
| 28 | "pull_request.merged": "A pull request is merged", |
| 29 | "label.created": "A label is created", |
| 30 | "label.edited": "A label is edited", |
| 31 | "label.deleted": "A label is deleted", |
| 32 | "release.created": "A release is created, draft or not", |
| 33 | "release.published": "A release is published", |
| 34 | "release.edited": "A release is edited", |
| 35 | "release.deleted": "A release is deleted", |
| 36 | "star.created": "Someone stars the repository", |
| 37 | "star.deleted": "Someone unstars the repository", |
| 38 | "watch.started": "Someone starts watching the repository", |
| 39 | "fork.created": "Someone forks the repository", |
| 40 | "repository.edited": |
| 41 | "The repository's name, description, visibility or default branch changes", |
| 42 | "repository.transferred": "The repository moves to another owner", |
| 43 | "member.added": "A collaborator accepts an invitation", |
| 44 | "member.removed": "A collaborator is removed or leaves", |
| 45 | }; |
| 46 | |
| 47 | export const webhookEvents = |
| 48 | WebhookEvent, |
| 49 | ...WebhookEvent[] |
| 50 | ]; |
| 51 | |
| 52 | export const webhookOwnerSchema = |
| 53 | z.object({ |
| 54 | kind: z.literal |
| 55 | username: z.string |
| 56 | repo: z.string |
| 57 | }), |
| 58 | z.object({ |
| 59 | ]); |
| 60 | |
| 61 | export type WebhookOwner |
| 62 | |
| 63 | /** Where the owner's webhook settings live. */ |
| 64 | export function webhooksPath(owner |
| 65 | return owner.kind |
| 66 | ? `/${owner. |
| 67 | : `/${owner. |
| 68 | } |