forked from microsoft/vscode-pull-request-github
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtimelineEvent.ts
More file actions
62 lines (52 loc) · 1.81 KB
/
Copy pathtimelineEvent.ts
File metadata and controls
62 lines (52 loc) · 1.81 KB
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
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import * as Github from '@octokit/rest';
import { Comment } from './comment';
type Omit<T, K extends keyof T> = Pick<T, Exclude<keyof T, K>>;
export enum EventType {
Committed,
Mentioned,
Subscribed,
Commented,
Reviewed,
Other
}
export interface CommentEvent extends Omit<Github.IssuesGetEventsTimelineResponseItem, 'commit_id' | 'commit_url' | 'event'> {
html_url: string;
issue_url: string;
body: string;
author_association: string;
updated_at: string;
user: Github.IssuesGetEventsTimelineResponseItem['actor'];
event: EventType;
canEdit?: boolean;
canDelete?: boolean;
eventType: EventType;
}
export interface ReviewEvent extends Github.PullRequestsCreateReviewResponse {
author_association: string;
event: string;
eventType: EventType;
comments: Comment[];
submitted_at: string;
}
export interface CommitEvent extends Github.ReposCreateFileResponseCommit {
author: Github.ReposCreateFileResponseCommit['author'] & {
login: string;
avatar_url: string;
html_url: string;
};
event: string;
}
export type TimelineEvent = CommitEvent | ReviewEvent | CommentEvent;
export function isReviewEvent(event: TimelineEvent): event is ReviewEvent {
return Number(event.event) === EventType.Reviewed;
}
export function isCommitEvent(event: TimelineEvent): event is CommitEvent {
return Number(event.event) === EventType.Committed;
}
export function isCommentEvent(event: TimelineEvent): event is CommentEvent {
return Number(event.event) === EventType.Committed;
}