Repository navigation
Expand file tree
/
Copy pathtypes.ts
More file actions
82 lines (71 loc) · 2.45 KB
/
Copy pathtypes.ts
File metadata and controls
82 lines (71 loc) · 2.45 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
// Core domain types for v2 bounty sync.
//
// Design: both sync commands work by fetching the complete current state of an
// issue or PR from GitHub, deriving the *desired* label set from the rules, and
// computing a minimal patch (add / remove) to reconcile the two.
// ---------------------------------------------------------------------------
// GitHub resource types (as returned by the REST API)
// ---------------------------------------------------------------------------
export interface Label {
name: string;
}
export interface User {
login: string;
}
/// Full issue as returned by GET /repos/:owner/:repo/issues/:number
export interface Issue {
number: number;
title: string;
html_url: string;
state: "open" | "closed";
labels: Label[];
assignees: User[];
pull_request?: unknown; // present when the issue is actually a PR
}
/// Full pull request as returned by GET /repos/:owner/:repo/pulls/:number
export interface PullRequest {
number: number;
title: string;
state: "open" | "closed";
merged: boolean;
body: string | null;
labels: Label[];
user: User;
html_url: string;
}
// ---------------------------------------------------------------------------
// Derived state used by the rules engine
// ---------------------------------------------------------------------------
/// Everything the rules engine needs to know about an issue.
export interface IssueState {
issue: Issue;
/// Current label names on the issue.
currentLabels: Set<string>;
}
/// Everything the rules engine needs to know about a PR and its linked issues.
export interface PrState {
pr: PullRequest;
/// Current label names on the PR.
currentLabels: Set<string>;
/// Full state of each issue linked via "closes/fixes/resolves #N" in the PR body.
linkedIssues: Issue[];
}
// ---------------------------------------------------------------------------
// Patch types — the minimal diff to apply
// ---------------------------------------------------------------------------
/// A label operation on a single target (issue or PR number).
export interface LabelOp {
target: number;
/// Human-readable title of the issue or PR, for display in plan output.
title?: string;
/// URL of the issue or PR, for display in plan output.
url?: string;
add: string[];
remove: string[];
/// Optional comment to post on the target after label ops.
comment?: string;
}
/// The complete set of operations to apply.
export interface Patch {
ops: LabelOp[];
}