@osdlc/typed-gh 0.5.0 → 0.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/types.ts DELETED
@@ -1,186 +0,0 @@
1
- /**
2
- * The GitHub model, typed.
3
- *
4
- * `gh` returns GraphQL-shaped JSON whose fields depend on what you asked for,
5
- * so every field here is total: a value, or the enum member that means "not
6
- * known". Absent and unknowable are the same answer to a caller, and giving
7
- * them one representation is what keeps a consumer from reading a field it
8
- * never requested as a fact.
9
- *
10
- * Most enums are open on purpose. GitHub adds members, and a client that
11
- * crashes on an unrecognized one is worse than a client that carries it
12
- * through: unions end in `(string & {})` so a new value still types as the
13
- * enum while the known members keep their autocomplete.
14
- *
15
- * Two are closed: {@link MergeableState} and {@link ReviewDecision}. Callers
16
- * compare them member by member to decide whether to merge, so the parser
17
- * maps a value it does not know to `UNKNOWN` or `null` instead of passing it
18
- * on.
19
- */
20
-
21
- /**
22
- * Can this PR merge? `UNKNOWN` also covers "GitHub has not computed it yet".
23
- * Closed: a value the parser does not know reads as `UNKNOWN`.
24
- */
25
- export type MergeableState = 'MERGEABLE' | 'CONFLICTING' | 'UNKNOWN'
26
-
27
- /**
28
- * The merge-button state.
29
- *
30
- * `BEHIND` only ever appears when branch protection *requires* an up-to-date
31
- * branch. Without that rule a branch a hundred commits behind still reports
32
- * `CLEAN`, so this is a corroborating hint about staleness and never the
33
- * measure of it — compute that from the commit graph.
34
- */
35
- export type MergeStateStatus =
36
- | 'BEHIND'
37
- | 'BLOCKED'
38
- | 'CLEAN'
39
- | 'DIRTY'
40
- | 'DRAFT'
41
- | 'HAS_HOOKS'
42
- | 'UNKNOWN'
43
- | 'UNSTABLE'
44
- | (string & {})
45
-
46
- /** Where a pull request is in its life: open, closed without a merge, or merged. */
47
- export type PullRequestState = 'OPEN' | 'CLOSED' | 'MERGED' | (string & {})
48
-
49
- /**
50
- * The review state branch protection reads: approved, changes requested, or a
51
- * review still required. `null` when there is no decision, or the repository
52
- * requires no review. Closed: a value the parser does not know reads as `null`.
53
- */
54
- export type ReviewDecision = 'APPROVED' | 'CHANGES_REQUESTED' | 'REVIEW_REQUIRED' | null
55
-
56
- /** The state of one review. `PENDING` is a review its author has not submitted yet. */
57
- export type ReviewState =
58
- 'APPROVED' | 'CHANGES_REQUESTED' | 'COMMENTED' | 'DISMISSED' | 'PENDING' | (string & {})
59
-
60
- /** Who wrote something. `login` is normalized — a `[bot]` suffix is stripped. */
61
- export interface Actor {
62
- login: string
63
- /** True when GitHub marks the account as a bot, or the login carried `[bot]`. */
64
- isBot: boolean
65
- }
66
-
67
- /** A repository label. `color` is hex digits such as `d73a4a`; a field the payload lacks is `''`. */
68
- export interface Label {
69
- name: string
70
- color: string
71
- description: string
72
- }
73
-
74
- /**
75
- * A GitHub issue, off `gh issue list`/`gh issue view --json
76
- * number,title,body,labels,state`. Deliberately a small field set — not the
77
- * full PR-sized model, since nothing here reads reviews, checks or comments
78
- * off an issue.
79
- */
80
- export interface IssueRow {
81
- number: number
82
- title: string
83
- body: string
84
- labels: Label[]
85
- state: string
86
- }
87
-
88
- /**
89
- * How a finished check ended, as GitHub reports it. Null while the check is
90
- * still running, and always null for a legacy status context. Read
91
- * {@link CheckRun.verdict} for the answer folded across both node types.
92
- */
93
- export type CheckConclusion =
94
- | 'SUCCESS'
95
- | 'FAILURE'
96
- | 'NEUTRAL'
97
- | 'CANCELLED'
98
- | 'TIMED_OUT'
99
- | 'ACTION_REQUIRED'
100
- | 'SKIPPED'
101
- | 'STALE'
102
- | 'STARTUP_FAILURE'
103
- | (string & {})
104
- | null
105
-
106
- /** One rolled-up check, with the two GitHub shapes folded into one. */
107
- export interface CheckRun {
108
- /** A CheckRun's `name`, or a legacy StatusContext's `context`. */
109
- name: string
110
- /** `QUEUED` / `IN_PROGRESS` / `COMPLETED`; null for a status context. */
111
- status: string | null
112
- conclusion: CheckConclusion
113
- /**
114
- * The normalized verdict. A check still running is `pending`, not a pass —
115
- * treating "no failure yet" as green is how a red build merges.
116
- */
117
- verdict: 'pending' | 'success' | 'failure' | 'neutral'
118
- /** A CheckRun's `detailsUrl`, or a legacy StatusContext's `targetUrl` — where to read the log. Null when the code host gives none. */
119
- url: string | null
120
- }
121
-
122
- /** One conversation comment on a pull request. */
123
- export interface Comment {
124
- /**
125
- * GitHub's id for this comment, as a string: a GraphQL node id, or a REST id
126
- * turned into text. Null only when the payload omits it (`gh` always sends
127
- * one). A REST id of 2^53 or more loses precision when `gh` output is
128
- * parsed. Current ids are far below that.
129
- */
130
- id: string | null
131
- author: Actor | null
132
- body: string
133
- createdAt: string | null
134
- }
135
-
136
- /** One review on a pull request. */
137
- export interface Review {
138
- /** Same as {@link Comment.id}. A REST id of 2^53 or more loses precision when `gh` output is parsed. */
139
- id: string | null
140
- author: Actor | null
141
- body: string
142
- state: ReviewState
143
- submittedAt: string | null
144
- }
145
-
146
- /**
147
- * A pull request.
148
- *
149
- * Fields `gh` was not asked for come back at their "not known" value, so this
150
- * type is safe to build from any field subset. `number` is the only field
151
- * without one — a PR with no number is not a PR, and parsing returns null.
152
- */
153
- export interface PullRequest {
154
- number: number
155
- state: PullRequestState
156
- title: string
157
- body: string
158
- url: string
159
- isDraft: boolean
160
- baseRefName: string
161
- headRefName: string
162
- /** Head commit sha, when requested — the thing to pin a force-push lease to. */
163
- headRefOid: string | null
164
- /**
165
- * True when the head branch lives in a fork. Its ref is then not on the
166
- * base repository's `origin`; fetch `refs/pull/<n>/head` instead.
167
- */
168
- isCrossRepository: boolean
169
- mergeable: MergeableState
170
- mergeStateStatus: MergeStateStatus
171
- reviewDecision: ReviewDecision
172
- author: Actor | null
173
- labels: Label[]
174
- checks: CheckRun[]
175
- comments: Comment[]
176
- reviews: Review[]
177
- mergedAt: string | null
178
- createdAt: string | null
179
- updatedAt: string | null
180
- }
181
-
182
- /** A repository coordinate. */
183
- export interface OwnerRepo {
184
- owner: string
185
- repo: string
186
- }