Skip to content

Commit 3bff547

Browse files
authored
✨ Add server webhooks (#4)
1 parent e2f1d84 commit 3bff547

33 files changed

+1802
-1
lines changed

src/server/index.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
export * from "./client.js"
2-
export * as server from "./openapi/index.js"
2+
export * from "./openapi/index.js"
3+
export * from "./webhooks/index.js"

src/server/webhooks/events/event.ts

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import type { PrEvent } from "./pr/event.js"
2+
import type { ProjectEvent } from "./project/event.js"
3+
import type { RepoEvent } from "./repo/event.js"
4+
5+
export type Event = PrEvent | ProjectEvent | RepoEvent
6+
export type EventKey =
7+
| PrEvent["eventKey"]
8+
| ProjectEvent["eventKey"]
9+
| RepoEvent["eventKey"]

src/server/webhooks/events/index.ts

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
export * from "./event.js"
2+
export * as pr from "./pr/index.js"
3+
export * as project from "./project/index.js"
4+
export * as repo from "./repo/index.js"
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
export interface Actor {
2+
readonly active: boolean
3+
readonly displayName: string
4+
readonly emailAddress: string
5+
readonly id: number
6+
readonly name: string
7+
readonly slug: string
8+
readonly type: string
9+
}
10+
11+
export interface Author {
12+
readonly approved: boolean
13+
readonly role: string
14+
readonly status: string
15+
readonly user: Actor
16+
}
17+
18+
export interface Comment {
19+
readonly author: Actor
20+
readonly comments: unknown[]
21+
readonly createdDate: number
22+
readonly id: number
23+
readonly properties: Properties
24+
readonly tasks: unknown[]
25+
readonly text: string
26+
readonly updatedDate: number
27+
readonly version: number
28+
}
29+
30+
/** A user comments on a pull request. This payload comes with an event key of `pr:comment:added`. */
31+
export interface PRCommentAdded {
32+
/** The user that created the comment. */
33+
readonly actor: Actor
34+
/** The comment created. */
35+
readonly comment: Comment
36+
/** Id of the parent comment if one exists. */
37+
readonly commentParentId: number
38+
readonly date: string
39+
readonly eventKey: "pr:comment:added"
40+
/** The pull request comment on. */
41+
readonly pullRequest: PullRequest
42+
}
43+
44+
export interface Project {
45+
readonly id: number
46+
readonly key: string
47+
readonly name: string
48+
readonly public: boolean
49+
readonly type: string
50+
}
51+
52+
export interface Properties {
53+
readonly repositoryId: number
54+
}
55+
56+
export interface PullRequest {
57+
readonly author: Author
58+
readonly closed: boolean
59+
readonly createdDate: number
60+
readonly draft: boolean
61+
readonly fromRef: Ref
62+
readonly id: number
63+
readonly locked: boolean
64+
readonly open: boolean
65+
readonly participants: unknown[]
66+
readonly reviewers: unknown[]
67+
readonly state: string
68+
readonly title: string
69+
readonly toRef: Ref
70+
readonly updatedDate: number
71+
readonly version: number
72+
}
73+
74+
export interface Ref {
75+
readonly displayId: string
76+
readonly id: string
77+
readonly latestCommit: string
78+
readonly repository: Repository
79+
}
80+
81+
export interface Repository {
82+
readonly forkable: boolean
83+
readonly id: number
84+
readonly name: string
85+
readonly project: Project
86+
readonly public: boolean
87+
readonly scmId: string
88+
readonly slug: string
89+
readonly state: string
90+
readonly statusMessage: string
91+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
export interface Actor {
2+
readonly active: boolean
3+
readonly displayName: string
4+
readonly emailAddress: string
5+
readonly id: number
6+
readonly name: string
7+
readonly slug: string
8+
readonly type: string
9+
}
10+
11+
export interface Author {
12+
readonly approved: boolean
13+
readonly role: string
14+
readonly status: string
15+
readonly user: Actor
16+
}
17+
18+
export interface Comment {
19+
readonly author: Actor
20+
readonly comments: unknown[]
21+
readonly createdDate: number
22+
readonly id: number
23+
readonly tasks: unknown[]
24+
readonly text: string
25+
readonly updatedDate: number
26+
readonly version: number
27+
}
28+
29+
/** A user deletes a comment on a pull request. This payload comes with an event
30+
* key of `pr:comment:deleted`. */
31+
export interface PRCommentDeleted {
32+
/** The user that deleted the comment. */
33+
readonly actor: Actor
34+
/** The comment deleted. */
35+
readonly comment: Comment
36+
/** Id of the parent comment if one exists. */
37+
readonly commentParentId: number
38+
readonly date: string
39+
readonly eventKey: "pr:comment:deleted"
40+
/** The pull request where the comment existed. */
41+
readonly pullRequest: PullRequest
42+
}
43+
44+
export interface Project {
45+
readonly id: number
46+
readonly key: string
47+
readonly name: string
48+
readonly public: boolean
49+
readonly type: string
50+
}
51+
52+
export interface PullRequest {
53+
readonly author: Author
54+
readonly closed: boolean
55+
readonly createdDate: number
56+
readonly draft: boolean
57+
readonly fromRef: Ref
58+
readonly id: number
59+
readonly locked: boolean
60+
readonly open: boolean
61+
readonly participants: unknown[]
62+
readonly reviewers: unknown[]
63+
readonly state: string
64+
readonly title: string
65+
readonly toRef: Ref
66+
readonly updatedDate: number
67+
readonly version: number
68+
}
69+
70+
export interface Ref {
71+
readonly displayId: string
72+
readonly id: string
73+
readonly latestCommit: string
74+
readonly repository: Repository
75+
}
76+
77+
export interface Repository {
78+
readonly forkable: boolean
79+
readonly id: number
80+
readonly name: string
81+
readonly project: Project
82+
readonly public: boolean
83+
readonly scmId: string
84+
readonly slug: string
85+
readonly state: string
86+
readonly statusMessage: string
87+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
export interface Actor {
2+
readonly active: boolean
3+
readonly displayName: string
4+
readonly emailAddress: string
5+
readonly id: number
6+
readonly name: string
7+
readonly slug: string
8+
readonly type: string
9+
}
10+
11+
export interface Author {
12+
readonly approved: boolean
13+
readonly role: string
14+
readonly status: string
15+
readonly user: Actor
16+
}
17+
18+
export interface Comment {
19+
readonly author: Actor
20+
readonly comments: unknown[]
21+
readonly createdDate: number
22+
readonly id: number
23+
readonly properties: Properties
24+
readonly tasks: unknown[]
25+
readonly text: string
26+
readonly updatedDate: number
27+
readonly version: number
28+
}
29+
30+
/** This payload comes with an event key of `pr:comment:edited`. */
31+
export interface PRCommentEdited {
32+
/** The user that edited the comment. */
33+
readonly actor: Actor
34+
/** The comment edited. */
35+
readonly comment: Comment
36+
/** Id of the parent comment if one exists. */
37+
readonly commentParentId: number
38+
readonly date: string
39+
readonly eventKey: "pr:comment:edited"
40+
/** Text of the previous comment. */
41+
readonly previousComment: string
42+
/** The pull request where the comment exists. */
43+
readonly pullRequest: PullRequest
44+
}
45+
46+
export interface Project {
47+
readonly id: number
48+
readonly key: string
49+
readonly name: string
50+
readonly public: boolean
51+
readonly type: string
52+
}
53+
54+
export interface Properties {
55+
readonly repositoryId: number
56+
}
57+
58+
export interface PullRequest {
59+
readonly author: Author
60+
readonly closed: boolean
61+
readonly createdDate: number
62+
readonly draft: boolean
63+
readonly fromRef: Ref
64+
readonly id: number
65+
readonly locked: boolean
66+
readonly open: boolean
67+
readonly participants: unknown[]
68+
readonly reviewers: unknown[]
69+
readonly state: string
70+
readonly title: string
71+
readonly toRef: Ref
72+
readonly updatedDate: number
73+
readonly version: number
74+
}
75+
76+
export interface Ref {
77+
readonly displayId: string
78+
readonly id: string
79+
readonly latestCommit: string
80+
readonly repository: Repository
81+
}
82+
83+
export interface Repository {
84+
readonly forkable: boolean
85+
readonly id: number
86+
readonly name: string
87+
readonly project: Project
88+
readonly public: boolean
89+
readonly scmId: string
90+
readonly slug: string
91+
readonly state: string
92+
readonly statusMessage: string
93+
}
+73
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
export interface Actor {
2+
readonly active: boolean
3+
readonly displayName: string
4+
readonly emailAddress: string
5+
readonly id: number
6+
readonly name: string
7+
readonly slug: string
8+
readonly type: string
9+
}
10+
11+
export interface Author {
12+
readonly approved: boolean
13+
readonly role: string
14+
readonly status: string
15+
readonly user: Actor
16+
}
17+
18+
/** A user declines a pull request for a repository. This payload comes with an
19+
* event key of `pr:declined`. */
20+
export interface PRDeclined {
21+
/** The user who declined the pull request. */
22+
readonly actor: Actor
23+
readonly date: string
24+
readonly eventKey: "pr:declined"
25+
/** Details of the pull request declined. */
26+
readonly pullRequest: PullRequest
27+
}
28+
29+
export interface Project {
30+
readonly id: number
31+
readonly key: string
32+
readonly name: string
33+
readonly public: boolean
34+
readonly type: string
35+
}
36+
37+
export interface PullRequest {
38+
readonly author: Author
39+
readonly closed: boolean
40+
readonly closedDate: number
41+
readonly createdDate: number
42+
readonly draft: boolean
43+
readonly fromRef: Ref
44+
readonly id: number
45+
readonly locked: boolean
46+
readonly open: boolean
47+
readonly participants: unknown[]
48+
readonly reviewers: Author[]
49+
readonly state: string
50+
readonly title: string
51+
readonly toRef: Ref
52+
readonly updatedDate: number
53+
readonly version: number
54+
}
55+
56+
export interface Ref {
57+
readonly displayId: string
58+
readonly id: string
59+
readonly latestCommit: string
60+
readonly repository: Repository
61+
}
62+
63+
export interface Repository {
64+
readonly forkable: boolean
65+
readonly id: number
66+
readonly name: string
67+
readonly project: Project
68+
readonly public: boolean
69+
readonly scmId: string
70+
readonly slug: string
71+
readonly state: string
72+
readonly statusMessage: string
73+
}

0 commit comments

Comments
 (0)