-
Notifications
You must be signed in to change notification settings - Fork 272
/
Copy pathtypesGitHub.ts
242 lines (200 loc) · 5.08 KB
/
typesGitHub.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
import type { components } from '@octokit/openapi-types';
import type { Account, Link } from './types';
export type Reason =
| 'approval_requested'
| 'assign'
| 'author'
| 'ci_activity'
| 'comment'
| 'invitation'
| 'manual'
| 'member_feature_requested'
| 'mention'
| 'review_requested'
| 'security_advisory_credit'
| 'security_alert'
| 'state_change'
| 'subscribed'
| 'team_mention';
export type SubjectType =
| 'CheckSuite'
| 'Commit'
| 'Discussion'
| 'Issue'
| 'PullRequest'
| 'Release'
| 'RepositoryDependabotAlertsThread'
| 'RepositoryInvitation'
| 'RepositoryVulnerabilityAlert'
| 'WorkflowRun';
export type IssueStateType = 'closed' | 'open';
export type IssueStateReasonType = 'completed' | 'not_planned' | 'reopened';
export type UserType =
| 'Bot'
| 'EnterpriseUserAccount'
| 'Mannequin'
| 'Organization'
| 'User';
/**
* Note: draft and merged are not official states in the GitHub API.
* These are derived from the pull request's `merged` and `draft` properties.
*/
export type PullRequestStateType = 'closed' | 'draft' | 'merged' | 'open';
export type StateType =
| CheckSuiteStatus
| DiscussionStateType
| IssueStateType
| IssueStateReasonType
| PullRequestStateType;
export type PullRequestReviewState =
| 'APPROVED'
| 'CHANGES_REQUESTED'
| 'COMMENTED'
| 'DISMISSED'
| 'PENDING';
export type GitHubNotification = components['schemas']['thread'];
export type UserDetails = User & UserProfile;
export type User = components['schemas']['simple-user'];
export type UserProfile = components['schemas']['public-user'];
export type Repository = components['schemas']['repository'];
interface GitHubSubject {
title: string;
url: Link | null;
latest_comment_url: Link | null;
type: SubjectType;
}
export type PullRequest = components['schemas']['pull-request'];
export type PullRequestReview = components['schemas']['pull-request-review'];
export type Commit = components['schemas']['commit'];
export type CommitComment = components['schemas']['commit-comment'];
export type Issue = components['schemas']['issue'];
export interface IssueOrPullRequestComment {
url: Link;
html_url: Link;
issue_url: Link;
id: number;
node_id: string;
user: User;
created_at: string;
updated_at: string;
body: string;
}
export type Milestone = components['schemas']['milestone'];
export type Release = components['schemas']['release'];
export interface GitHubRESTError {
message: string;
documentation_url: Link;
}
export type NotificationThreadSubscription =
components['schemas']['thread-subscription'];
/**
* GitHub GraphQL API Types
*/
export interface GraphQLSearch<T> {
data: {
search: {
nodes: T[];
};
};
}
export interface Discussion {
number: number;
title: string;
stateReason: DiscussionStateType;
isAnswered: boolean;
url: Link;
author: DiscussionAuthor;
comments: DiscussionComments;
labels: DiscussionLabels | null;
}
// Note: ANSWERED and OPEN are not an official discussion state type in the GitHub API
export type DiscussionStateType =
| 'ANSWERED'
| 'DUPLICATE'
| 'OPEN'
| 'OUTDATED'
| 'REOPENED'
| 'RESOLVED';
export interface DiscussionAuthor {
login: string;
url: Link;
avatar_url: Link;
type: UserType;
}
export interface DiscussionLabels {
nodes: DiscussionLabel[];
}
export interface DiscussionLabel {
name: string;
}
export interface DiscussionComments {
nodes: DiscussionComment[];
totalCount: number;
}
export interface DiscussionComment {
databaseId: string | number;
createdAt: string;
author: DiscussionAuthor;
replies?: {
nodes: DiscussionComment[];
};
}
/**
* Gitify Type Extensions
*/
// TODO: Add explicit types for GitHub API response vs Gitify Notifications object
export type Notification = GitHubNotification & GitifyNotification;
// Note: This is not in the official GitHub API. We add this to make notification interactions easier.
export interface GitifyNotification {
account: Account;
reason: Reason;
subject: Subject;
}
// This is not in the GitHub API, but we add it to the type to make it easier to work with
export type Subject = GitHubSubject & GitifySubject;
export interface GitifySubject {
number?: number;
state?: StateType;
user?: SubjectUser;
reviews?: GitifyPullRequestReview[];
linkedIssues?: string[];
comments?: number;
labels?: string[];
milestone?: Milestone;
}
export interface SubjectUser {
login: string;
html_url: Link;
avatar_url: Link;
type: UserType;
}
export interface GitifyPullRequestReview {
state: PullRequestReviewState;
users: string[];
}
export interface CheckSuiteAttributes {
workflowName: string;
attemptNumber?: number;
statusDisplayName: string;
status: CheckSuiteStatus | null;
branchName: string;
}
export interface WorkflowRunAttributes {
user: string;
statusDisplayName: string;
status: CheckSuiteStatus | null;
}
export type CheckSuiteStatus =
| 'action_required'
| 'cancelled'
| 'completed'
| 'failure'
| 'in_progress'
| 'pending'
| 'queued'
| 'requested'
| 'skipped'
| 'stale'
| 'success'
| 'timed_out'
| 'waiting';