|
1 | | -// import type { components } from '@octokit/openapi-types'; |
| 1 | +import type { components } from '@octokit/openapi-types'; |
2 | 2 |
|
3 | 3 | import type { GitifyNotification, GitifySubject, Link } from './types'; |
4 | 4 |
|
5 | 5 | // TODO: #828 Add explicit types for GitHub API response vs Gitify Notifications object |
6 | | -export type Notification = GitHubNotification & GitifyNotification; |
7 | | -export type Subject = GitHubSubject & GitifySubject; |
| 6 | +export type Notification = GitHubNotification & |
| 7 | + GitifyNotification & { |
| 8 | + reason: Reason; |
| 9 | + subject: Subject; |
| 10 | + repository: Repository; |
| 11 | + }; |
| 12 | +export type Subject = GitHubSubject & { |
| 13 | + url: Link; |
| 14 | + latest_comment_url: Link; |
| 15 | + type: SubjectType; |
| 16 | +} & GitifySubject; |
8 | 17 |
|
9 | 18 | /** |
10 | | - * |
11 | 19 | * GitHub REST API Response Types |
12 | | - * |
13 | 20 | **/ |
14 | 21 |
|
15 | 22 | export type Reason = |
@@ -48,254 +55,48 @@ export type UserType = |
48 | 55 | | 'Organization' |
49 | 56 | | 'User'; |
50 | 57 |
|
51 | | -// export type Notification = components['schemas']['thread']; |
52 | | -export interface GitHubNotification { |
53 | | - id: string; |
54 | | - unread: boolean; |
55 | | - reason: Reason; |
56 | | - updated_at: string; |
57 | | - last_read_at: string | null; |
58 | | - subject: Subject; |
59 | | - repository: Repository; |
60 | | - url: Link; |
61 | | - subscription_url: Link; |
62 | | -} |
63 | | - |
64 | | -interface GitHubSubject { |
65 | | - title: string; |
66 | | - url: Link | null; |
67 | | - latest_comment_url: Link | null; |
68 | | - type: SubjectType; |
69 | | -} |
70 | | - |
71 | | -export type UserDetails = User & UserProfile; |
72 | | - |
73 | | -export interface UserProfile { |
74 | | - name: string; |
75 | | - company: string; |
76 | | - blog: string; |
77 | | - location: string; |
78 | | - email: string; |
79 | | - hireable: string; |
80 | | - bio: string; |
81 | | - twitter_username: string; |
82 | | - public_repos: number; |
83 | | - public_gists: number; |
84 | | - followers: number; |
85 | | - following: number; |
86 | | - created_at: string; |
87 | | - updated_at: string; |
88 | | - private_gists: number; |
89 | | - total_private_repos: number; |
90 | | - owned_private_repos: number; |
91 | | - disk_usage: number; |
92 | | - collaborators: number; |
93 | | - two_factor_authentication: boolean; |
94 | | - plan: Plan; |
95 | | -} |
96 | | - |
97 | | -export interface Plan { |
98 | | - name: string; |
99 | | - space: number; |
100 | | - private_repos: number; |
101 | | - collaborators: number; |
102 | | -} |
| 58 | +export type GitHubNotification = components['schemas']['thread']; |
| 59 | +export type GitHubSubject = components['schemas']['thread']['subject']; |
103 | 60 |
|
104 | | -export interface User { |
105 | | - login: string; |
106 | | - id: number; |
107 | | - node_id: string; |
108 | | - avatar_url: Link; |
109 | | - gravatar_url: Link; |
110 | | - url: Link; |
| 61 | +export type Repository = components['schemas']['repository'] & { |
111 | 62 | html_url: Link; |
112 | | - followers_url: Link; |
113 | | - following_url: Link; |
114 | | - gists_url: Link; |
115 | | - starred_url: Link; |
116 | | - subscriptions_url: Link; |
117 | | - organizations_url: Link; |
118 | | - repos_url: Link; |
119 | | - events_url: Link; |
120 | | - received_events_url: Link; |
121 | | - type: UserType; |
122 | | - site_admin: boolean; |
123 | | -} |
124 | | - |
125 | | -// export type Repository = components['schemas']['repository']; |
126 | | -export interface Repository { |
127 | | - id: number; |
128 | | - node_id: string; |
129 | | - name: string; |
130 | | - full_name: string; |
131 | | - private: boolean; |
132 | 63 | owner: Owner; |
133 | | - html_url: Link; |
134 | | - description: string; |
135 | | - fork: boolean; |
136 | | - url: Link; |
137 | | - forks_url: Link; |
138 | | - keys_url: Link; |
139 | | - collaborators_url: Link; |
140 | | - teams_url: Link; |
141 | | - hooks_url: Link; |
142 | | - issue_events_url: Link; |
143 | | - events_url: Link; |
144 | | - assignees_url: Link; |
145 | | - branches_url: Link; |
146 | | - tags_url: Link; |
147 | | - blobs_url: Link; |
148 | | - git_tags_url: Link; |
149 | | - git_refs_url: Link; |
150 | | - trees_url: Link; |
151 | | - statuses_url: Link; |
152 | | - languages_url: Link; |
153 | | - stargazers_url: Link; |
154 | | - contributors_url: Link; |
155 | | - subscribers_url: Link; |
156 | | - subscription_url: Link; |
157 | | - commits_url: Link; |
158 | | - git_commits_url: Link; |
159 | | - comments_url: Link; |
160 | | - issue_comment_url: Link; |
161 | | - contents_url: Link; |
162 | | - compare_url: Link; |
163 | | - merges_url: Link; |
164 | | - archive_url: Link; |
165 | | - downloads_url: Link; |
166 | | - issues_url: Link; |
167 | | - pulls_url: Link; |
168 | | - milestones_url: Link; |
169 | | - notifications_url: Link; |
170 | | - labels_url: Link; |
171 | | - releases_url: Link; |
172 | | - deployments_url: Link; |
173 | | -} |
| 64 | +}; |
174 | 65 |
|
175 | | -export interface Owner { |
176 | | - login: string; |
177 | | - id: number; |
178 | | - node_id: string; |
| 66 | +export type Owner = NonNullable<BaseRepository['owner']> & { |
| 67 | + type: UserType; |
179 | 68 | avatar_url: Link; |
180 | | - gravatar_id: string; |
181 | | - url: Link; |
182 | | - html_url: Link; |
183 | | - followers_url: Link; |
184 | | - following_url: Link; |
185 | | - gists_url: Link; |
186 | | - starred_url: Link; |
187 | | - subscriptions_url: Link; |
188 | | - organizations_url: Link; |
189 | | - repos_url: Link; |
190 | | - events_url: Link; |
191 | | - received_events_url: Link; |
| 69 | +}; |
| 70 | +type BaseRepository = components['schemas']['repository']; |
| 71 | + |
| 72 | +export type Commit = Omit<BaseCommit, 'author'> & { |
| 73 | + author: BaseCommit['author'] extends null ? null : StrongCommitAuthor; |
| 74 | +}; |
| 75 | +type BaseCommit = components['schemas']['commit']; |
| 76 | +type StrongCommitAuthor = NonNullable<BaseCommit['author']> & { |
192 | 77 | type: UserType; |
193 | | - site_admin: boolean; |
194 | | -} |
| 78 | +}; |
195 | 79 |
|
196 | | -// export type Commit = components['schemas']['commit']; |
197 | | -export interface Commit { |
198 | | - sha: string; |
199 | | - node_id: string; |
200 | | - commit: { |
201 | | - author: CommitUser; |
202 | | - committer: CommitUser; |
203 | | - message: string; |
204 | | - tree: { |
205 | | - sha: string; |
206 | | - url: Link; |
207 | | - }; |
208 | | - url: Link; |
209 | | - comment_count: number; |
210 | | - verification: { |
211 | | - verified: boolean; |
212 | | - reason: string; |
213 | | - signature: string | null; |
214 | | - payload: string | null; |
215 | | - }; |
216 | | - }; |
217 | | - url: Link; |
218 | | - html_url: Link; |
219 | | - comments_url: Link; |
220 | | - author: User; |
221 | | - committer: User; |
222 | | - parents: CommitParent[]; |
223 | | - stats: { |
224 | | - total: number; |
225 | | - additions: number; |
226 | | - deletions: number; |
227 | | - }; |
228 | | - files: CommitFiles[]; |
229 | | -} |
230 | | - |
231 | | -interface CommitUser { |
232 | | - name: string; |
233 | | - email: string; |
234 | | - date: string; |
235 | | -} |
236 | | - |
237 | | -interface CommitParent { |
238 | | - sha: string; |
239 | | - url: Link; |
240 | | - html_url: Link; |
241 | | -} |
242 | | - |
243 | | -interface CommitFiles { |
244 | | - sha: string; |
245 | | - filename: string; |
246 | | - status: string; |
247 | | - additions: number; |
248 | | - deletions: number; |
249 | | - changes: number; |
250 | | - blob_url: Link; |
251 | | - raw_url: Link; |
252 | | - contents_url: Link; |
253 | | - patch: string; |
254 | | -} |
| 80 | +export type CommitComment = Omit<BaseCommitComment, 'user'> & { |
| 81 | + user: BaseCommitComment['user'] extends null ? null : StrongCommitCommentUser; |
| 82 | +}; |
| 83 | +type BaseCommitComment = components['schemas']['commit-comment']; |
| 84 | +type StrongCommitCommentUser = NonNullable<BaseCommitComment['user']> & { |
| 85 | + type: UserType; |
| 86 | +}; |
255 | 87 |
|
256 | | -export interface CommitComment { |
257 | | - url: Link; |
258 | | - html_url: Link; |
259 | | - issue_url: Link; |
260 | | - id: number; |
261 | | - node_id: string; |
262 | | - user: User; |
263 | | - created_at: string; |
264 | | - updated_at: string; |
265 | | - body: string; |
266 | | -} |
| 88 | +export type Release = Omit<BaseRelease, 'author'> & { |
| 89 | + author: BaseRelease['author'] extends null ? null : StrongReleaseAuthor; |
| 90 | +}; |
| 91 | +type BaseRelease = components['schemas']['release']; |
| 92 | +type StrongReleaseAuthor = NonNullable<BaseRelease['author']> & { |
| 93 | + type: UserType; |
| 94 | +}; |
267 | 95 |
|
268 | | -// export type Release = components['schemas']['release']; |
269 | | -export interface Release { |
270 | | - url: Link; |
271 | | - assets_url: Link; |
272 | | - upload_url: Link; |
273 | | - html_url: Link; |
274 | | - id: number; |
275 | | - author: User; |
276 | | - node_id: string; |
277 | | - tag_name: string; |
278 | | - target_commitish: string; |
279 | | - name: string | null; |
280 | | - body: string | null; |
281 | | - draft: boolean; |
282 | | - prerelease: boolean; |
283 | | - created_at: string; |
284 | | - published_at: string | null; |
285 | | -} |
| 96 | +export type NotificationThreadSubscription = |
| 97 | + components['schemas']['thread-subscription']; |
286 | 98 |
|
287 | 99 | export interface GitHubRESTError { |
288 | 100 | message: string; |
289 | 101 | documentation_url: Link; |
290 | 102 | } |
291 | | - |
292 | | -// export type NotificationThreadSubscription = |
293 | | -// components['schemas']['thread-subscription']; |
294 | | -export interface NotificationThreadSubscription { |
295 | | - subscribed: boolean; |
296 | | - ignored: boolean; |
297 | | - reason: string | null; |
298 | | - created_at: string; |
299 | | - url: Link; |
300 | | - thread_url: Link; |
301 | | -} |
0 commit comments