Repository navigation
Expand file tree
/
Copy pathgithub1s.d.ts
More file actions
173 lines (138 loc) · 4.2 KB
/
Copy pathgithub1s.d.ts
File metadata and controls
173 lines (138 loc) · 4.2 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
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
/**
* @file GitHub1s Type Definitions
* @author netcon
*/
// prettier-ignore
declare module 'github1s' {
type ReturnType<T> = Promise<T> | T;
enum FileType {
Directory = 'Directory',
File = 'File',
Link = 'Link',
}
interface FileEntry {
path: string;
commitSha: string;
type: FileType;
}
interface Directory {
path: string;
entries: FileEntry[];
// entries doesn't contains all results if `truncated` is true
truncated: boolean;
}
interface File {
path: string;
commitSha: string;
content: Uint8Array;
}
interface Link {
path: string;
commitSha: string;
target: string; // the path
}
interface Branch {
name: string;
commitSha: string;
}
interface Tag {
name: string;
commitSha: string;
}
interface Commit {
sha: string;
author: string;
email: string;
message: string;
committer?: string;
createTime: string;
}
interface CodeSearchOptions {
isCaseSensitive: boolean;
isWordMatch: boolean;
isRegExp: boolean;
includes: string; // glob string
excludes: string; // glob string
}
interface Position {
line: number;
character: number
}
interface Range {
start: Position;
end: Position;
}
// for cross-repository data,
// reference to another repository
interface ResourceScope {
schema: string; // github / github / bitbucket...
repo: string;
ref: string
}
interface CodeLocation {
// we can set `scope` to marked that current
// result is referenced to another repository
scope?: ResourceScope,
path: string;
ranges: Range[];
}
enum CodeReviewStatus {
Opening = 'Opening', // icon: 🟢
Approved = 'Approved', // icon: ✅
Denied = 'Denied', // icon: ❎
Merged = 'Merged', // icon: 🟣
Closed = 'Closed', // icon: 🔴
}
// may be a Pull Request for GitHub,
// or a Merge Request for GitLab,
// or a Change Request for Gerrit
interface CodeReview {
id: number;
status: CodeReviewStatus;
creator: string;
createTime: Date;
approveTime: Date | null;
denyTime: Date | null;
mergeTime: Date | null;
closeTime: Date | null;
head: {
label: string;
commitSha: string;
};
base: {
label: string;
commitSha: string;
};
}
interface FileBlameRange {
age: number;
startingLine: number;
endingLine: number;
commit: Commit;
}
// the string will be rendered use markdown format
type MarkdownString = string;
abstract class DataSourceProvider {
// if `recursive` is true, it should try to return all subtrees
provideDirectory(repo: string, ref: string, path: string, recursive: boolean): ReturnType<Directory[]>;
// the ref here may be a commitSha, branch, tag, or 'HEAD'
provideFile(repo: string, ref: string, path: string): ReturnType<File>;
provideBranches(repo: string, offset: number, limit: number): ReturnType<Branch[]>;
provideBranch(repo: string, branch: string): ReturnType<Branch | null>;
provideTags(repo: string, offset: number, limit: number): ReturnType<Tag[]>;
provideTag(repo: string, tag: string): ReturnType<Tag | null>;
provideCommits(repo: string, offset: number, limit: number): ReturnType<Commit[]>;
// the commit history of a file
provideFileCommits(repo: string, path: string, offset: number, limit: number): ReturnType<Commit[]>;
// the ref here may be a commitSha, branch, tag, or 'HEAD'
provideCommit(repo: string, ref: string): ReturnType<Commit | null>;
// use `report` to populate search results gradually
provideTextSearchResults(repo: string, ref: string, query: string, options: CodeSearchOptions, report: (results: CodeLocation[]) => void): ReturnType<{ limitHit: boolean }>;
provideCodeReviews(repo: string, offset: number, limit: number): ReturnType<CodeReview[]>;
provideCodeReview(repo: string, id: number): ReturnType<CodeReview | null>;
provideFileBlameRanges(repo: string, ref: string, path: string): ReturnType<FileBlameRange[]>;
provideCodeDefinition(repo: string, ref: string, path: string, line: number, character: number): ReturnType<CodeLocation | CodeLocation[]>;
provideCodeReferences(repo: string, ref: string, path: string, line: number, character: number): ReturnType<CodeLocation[]>;
provideCodeHover(repo: string, ref: string, path: string, line: number, character: number): ReturnType<MarkdownString>;
}
}