-
Notifications
You must be signed in to change notification settings - Fork 2.4k
/
types.ts
190 lines (179 loc) · 4.93 KB
/
types.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
import type { MergeStrategy } from '../config/types';
import type { BranchStatus, PrState, VulnerabilityAlert } from '../types';
type VulnerabilityKey = string;
type VulnerabilityRangeKey = string;
type VulnerabilityPatch = string;
export type AggregatedVulnerabilities = Record<
VulnerabilityKey,
Record<VulnerabilityRangeKey, VulnerabilityPatch>
>;
export interface PlatformParams {
endpoint?: string;
token?: string;
username?: string;
password?: string;
gitAuthor?: string;
}
export interface PlatformResult {
endpoint: string;
renovateUsername?: string;
gitAuthor?: string;
}
export interface RepoResult {
defaultBranch: string;
isFork: boolean;
}
export type GitUrlOption = 'default' | 'ssh' | 'endpoint';
export interface RepoParams {
repository: string;
endpoint?: string;
gitUrl?: GitUrlOption;
forkMode?: string;
forkToken?: string;
includeForks?: boolean;
renovateUsername?: string;
cloneSubmodules?: boolean;
ignorePrAuthor?: boolean;
}
/**
*
*/
export interface Pr {
body?: string;
sourceBranch: string;
canMerge?: boolean;
canMergeReason?: string;
createdAt?: string;
closedAt?: string;
displayNumber?: string;
hasAssignees?: boolean;
hasReviewers?: boolean;
isConflicted?: boolean;
labels?: string[];
number?: number;
reviewers?: string[];
sha?: string;
sourceRepo?: string;
state: string;
targetBranch?: string;
title: string;
isDraft?: boolean;
}
/**
* TODO: Proper typing
*/
export interface Issue {
body?: string;
number?: number;
state?: string;
title?: string;
}
export type PlatformPrOptions = {
azureAutoApprove?: boolean;
azureWorkItemId?: number;
bbUseDefaultReviewers?: boolean;
gitLabIgnoreApprovals?: boolean;
usePlatformAutomerge?: boolean;
};
export interface CreatePRConfig {
sourceBranch: string;
targetBranch: string;
prTitle: string;
prBody: string;
labels?: string[] | null;
platformOptions?: PlatformPrOptions;
draftPR?: boolean;
}
export interface UpdatePrConfig {
number: number;
platformOptions?: PlatformPrOptions;
prTitle: string;
prBody?: string;
state?: PrState.Open | PrState.Closed;
}
export interface EnsureIssueConfig {
title: string;
reuseTitle?: string;
body: string;
labels?: string[];
once?: boolean;
shouldReOpen?: boolean;
}
export interface BranchStatusConfig {
branchName: string;
context: string;
description: string;
state: BranchStatus;
url?: string;
}
export interface FindPRConfig {
branchName: string;
prTitle?: string | null;
state?: PrState.Open | PrState.Closed | PrState.NotOpen | PrState.All;
refreshCache?: boolean;
}
export interface MergePRConfig {
branchName?: string;
id: number;
strategy?: MergeStrategy;
}
export interface EnsureCommentConfig {
number: number;
topic: string;
content: string;
}
export interface EnsureCommentRemovalConfigByTopic {
number: number;
topic: string;
}
export interface EnsureCommentRemovalConfigByContent {
number: number;
content: string;
}
export interface EnsureCommentRemovalConfig {
number: number;
content?: string;
topic?: string;
}
export type EnsureIssueResult = 'updated' | 'created';
export interface Platform {
findIssue(title: string): Promise<Issue | null>;
getIssueList(): Promise<Issue[]>;
getIssue?(number: number, useCache?: boolean): Promise<Issue>;
getVulnerabilityAlerts(): Promise<VulnerabilityAlert[]>;
getRawFile(fileName: string, repo?: string): Promise<string | null>;
getJsonFile(fileName: string, repo?: string): Promise<any | null>;
initRepo(config: RepoParams): Promise<RepoResult>;
getPrList(): Promise<Pr[]>;
ensureIssueClosing(title: string): Promise<void>;
ensureIssue(
issueConfig: EnsureIssueConfig
): Promise<EnsureIssueResult | null>;
massageMarkdown(prBody: string): string;
updatePr(prConfig: UpdatePrConfig): Promise<void>;
mergePr(config: MergePRConfig): Promise<boolean>;
addReviewers(number: number, reviewers: string[]): Promise<void>;
addAssignees(number: number, assignees: string[]): Promise<void>;
createPr(prConfig: CreatePRConfig): Promise<Pr>;
getRepos(): Promise<string[]>;
getRepoForceRebase(): Promise<boolean>;
deleteLabel(number: number, label: string): Promise<void>;
setBranchStatus(branchStatusConfig: BranchStatusConfig): Promise<void>;
getBranchStatusCheck(
branchName: string,
context: string
): Promise<BranchStatus | null>;
ensureCommentRemoval(
ensureCommentRemoval:
| EnsureCommentRemovalConfigByTopic
| EnsureCommentRemovalConfigByContent
): Promise<void>;
ensureComment(ensureComment: EnsureCommentConfig): Promise<boolean>;
getPr(number: number): Promise<Pr>;
findPr(findPRConfig: FindPRConfig): Promise<Pr>;
refreshPr?(number: number): Promise<void>;
getBranchStatus(branchName: string): Promise<BranchStatus>;
getBranchPr(branchName: string): Promise<Pr | null>;
initPlatform(config: PlatformParams): Promise<PlatformResult>;
filterUnavailableUsers?(users: string[]): Promise<string[]>;
}