Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

✨ Add server webhooks #4

Merged
merged 1 commit into from
Sep 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/server/index.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
export * from "./client.js"
export * as server from "./openapi/index.js"
export * from "./openapi/index.js"
export * from "./webhooks/index.js"
9 changes: 9 additions & 0 deletions src/server/webhooks/events/event.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import type { PrEvent } from "./pr/event.js"
import type { ProjectEvent } from "./project/event.js"
import type { RepoEvent } from "./repo/event.js"

export type Event = PrEvent | ProjectEvent | RepoEvent
export type EventKey =
| PrEvent["eventKey"]
| ProjectEvent["eventKey"]
| RepoEvent["eventKey"]
4 changes: 4 additions & 0 deletions src/server/webhooks/events/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
export * from "./event.js"
export * as pr from "./pr/index.js"
export * as project from "./project/index.js"
export * as repo from "./repo/index.js"
91 changes: 91 additions & 0 deletions src/server/webhooks/events/pr/comment_added.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
export interface Actor {
readonly active: boolean
readonly displayName: string
readonly emailAddress: string
readonly id: number
readonly name: string
readonly slug: string
readonly type: string
}

export interface Author {
readonly approved: boolean
readonly role: string
readonly status: string
readonly user: Actor
}

export interface Comment {
readonly author: Actor
readonly comments: unknown[]
readonly createdDate: number
readonly id: number
readonly properties: Properties
readonly tasks: unknown[]
readonly text: string
readonly updatedDate: number
readonly version: number
}
NatoBoram marked this conversation as resolved.
Show resolved Hide resolved

/** A user comments on a pull request. This payload comes with an event key of `pr:comment:added`. */
export interface PRCommentAdded {
/** The user that created the comment. */
readonly actor: Actor
/** The comment created. */
readonly comment: Comment
/** Id of the parent comment if one exists. */
readonly commentParentId: number
readonly date: string
readonly eventKey: "pr:comment:added"
/** The pull request comment on. */
readonly pullRequest: PullRequest
}

export interface Project {
readonly id: number
readonly key: string
readonly name: string
readonly public: boolean
readonly type: string
}

export interface Properties {
readonly repositoryId: number
}

export interface PullRequest {
readonly author: Author
readonly closed: boolean
readonly createdDate: number
readonly draft: boolean
readonly fromRef: Ref
readonly id: number
readonly locked: boolean
readonly open: boolean
readonly participants: unknown[]
readonly reviewers: unknown[]
readonly state: string
readonly title: string
readonly toRef: Ref
readonly updatedDate: number
readonly version: number
}
NatoBoram marked this conversation as resolved.
Show resolved Hide resolved

export interface Ref {
readonly displayId: string
readonly id: string
readonly latestCommit: string
readonly repository: Repository
}

export interface Repository {
readonly forkable: boolean
readonly id: number
readonly name: string
readonly project: Project
readonly public: boolean
readonly scmId: string
readonly slug: string
readonly state: string
readonly statusMessage: string
}
87 changes: 87 additions & 0 deletions src/server/webhooks/events/pr/comment_deleted.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
export interface Actor {
readonly active: boolean
readonly displayName: string
readonly emailAddress: string
readonly id: number
readonly name: string
readonly slug: string
readonly type: string
}

export interface Author {
readonly approved: boolean
readonly role: string
readonly status: string
readonly user: Actor
}

export interface Comment {
readonly author: Actor
readonly comments: unknown[]
readonly createdDate: number
readonly id: number
readonly tasks: unknown[]
readonly text: string
readonly updatedDate: number
readonly version: number
}

/** A user deletes a comment on a pull request. This payload comes with an event
* key of `pr:comment:deleted`. */
export interface PRCommentDeleted {
/** The user that deleted the comment. */
readonly actor: Actor
/** The comment deleted. */
readonly comment: Comment
/** Id of the parent comment if one exists. */
readonly commentParentId: number
readonly date: string
readonly eventKey: "pr:comment:deleted"
/** The pull request where the comment existed. */
readonly pullRequest: PullRequest
}

export interface Project {
readonly id: number
readonly key: string
readonly name: string
readonly public: boolean
readonly type: string
}

export interface PullRequest {
readonly author: Author
readonly closed: boolean
readonly createdDate: number
readonly draft: boolean
readonly fromRef: Ref
readonly id: number
readonly locked: boolean
readonly open: boolean
readonly participants: unknown[]
readonly reviewers: unknown[]
readonly state: string
readonly title: string
readonly toRef: Ref
readonly updatedDate: number
readonly version: number
}

export interface Ref {
readonly displayId: string
readonly id: string
readonly latestCommit: string
readonly repository: Repository
}

export interface Repository {
readonly forkable: boolean
readonly id: number
readonly name: string
readonly project: Project
readonly public: boolean
readonly scmId: string
readonly slug: string
readonly state: string
readonly statusMessage: string
}
93 changes: 93 additions & 0 deletions src/server/webhooks/events/pr/comment_edited.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
export interface Actor {
readonly active: boolean
readonly displayName: string
readonly emailAddress: string
readonly id: number
readonly name: string
readonly slug: string
readonly type: string
}

export interface Author {
readonly approved: boolean
readonly role: string
readonly status: string
readonly user: Actor
}

export interface Comment {
readonly author: Actor
readonly comments: unknown[]
readonly createdDate: number
readonly id: number
readonly properties: Properties
readonly tasks: unknown[]
readonly text: string
readonly updatedDate: number
readonly version: number
}

/** This payload comes with an event key of `pr:comment:edited`. */
export interface PRCommentEdited {
/** The user that edited the comment. */
readonly actor: Actor
/** The comment edited. */
readonly comment: Comment
/** Id of the parent comment if one exists. */
readonly commentParentId: number
readonly date: string
readonly eventKey: "pr:comment:edited"
/** Text of the previous comment. */
readonly previousComment: string
/** The pull request where the comment exists. */
readonly pullRequest: PullRequest
}

export interface Project {
readonly id: number
readonly key: string
readonly name: string
readonly public: boolean
readonly type: string
}

export interface Properties {
readonly repositoryId: number
}

export interface PullRequest {
readonly author: Author
readonly closed: boolean
readonly createdDate: number
readonly draft: boolean
readonly fromRef: Ref
readonly id: number
readonly locked: boolean
readonly open: boolean
readonly participants: unknown[]
readonly reviewers: unknown[]
readonly state: string
readonly title: string
readonly toRef: Ref
readonly updatedDate: number
readonly version: number
}

export interface Ref {
readonly displayId: string
readonly id: string
readonly latestCommit: string
readonly repository: Repository
}

export interface Repository {
readonly forkable: boolean
readonly id: number
readonly name: string
readonly project: Project
readonly public: boolean
readonly scmId: string
readonly slug: string
readonly state: string
readonly statusMessage: string
}
73 changes: 73 additions & 0 deletions src/server/webhooks/events/pr/declined.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
export interface Actor {
readonly active: boolean
readonly displayName: string
readonly emailAddress: string
readonly id: number
readonly name: string
readonly slug: string
readonly type: string
}

export interface Author {
readonly approved: boolean
readonly role: string
readonly status: string
readonly user: Actor
}

/** A user declines a pull request for a repository. This payload comes with an
* event key of `pr:declined`. */
export interface PRDeclined {
/** The user who declined the pull request. */
readonly actor: Actor
readonly date: string
readonly eventKey: "pr:declined"
/** Details of the pull request declined. */
readonly pullRequest: PullRequest
}

export interface Project {
readonly id: number
readonly key: string
readonly name: string
readonly public: boolean
readonly type: string
}

export interface PullRequest {
readonly author: Author
readonly closed: boolean
readonly closedDate: number
readonly createdDate: number
readonly draft: boolean
readonly fromRef: Ref
readonly id: number
readonly locked: boolean
readonly open: boolean
readonly participants: unknown[]
readonly reviewers: Author[]
readonly state: string
readonly title: string
readonly toRef: Ref
readonly updatedDate: number
readonly version: number
}

export interface Ref {
readonly displayId: string
readonly id: string
readonly latestCommit: string
readonly repository: Repository
}

export interface Repository {
readonly forkable: boolean
readonly id: number
readonly name: string
readonly project: Project
readonly public: boolean
readonly scmId: string
readonly slug: string
readonly state: string
readonly statusMessage: string
}
Loading