@fabrika/control-contract 0.9.0-dev.13 → 0.9.0-dev.14
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/package.json +4 -4
- package/src/approval-view.ts +75 -5
- package/src/index.ts +91 -5
- package/src/rpc.ts +5 -0
- package/types/src/approval-view.d.ts +33 -1
- package/types/src/index.d.ts +76 -5
- package/types/src/rpc.d.ts +3 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fabrika/control-contract",
|
|
3
|
-
"version": "0.9.0-dev.
|
|
3
|
+
"version": "0.9.0-dev.14",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -26,8 +26,8 @@
|
|
|
26
26
|
},
|
|
27
27
|
"dependencies": {
|
|
28
28
|
"zod": "^3.25.76",
|
|
29
|
-
"@fabrika/auth-core": "0.9.0-dev.
|
|
30
|
-
"@fabrika/app": "0.9.0-dev.
|
|
31
|
-
"@fabrika/provider-contract": "0.9.0-dev.
|
|
29
|
+
"@fabrika/auth-core": "0.9.0-dev.14",
|
|
30
|
+
"@fabrika/app": "0.9.0-dev.14",
|
|
31
|
+
"@fabrika/provider-contract": "0.9.0-dev.14"
|
|
32
32
|
}
|
|
33
33
|
}
|
package/src/approval-view.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// How the approval page shows one access change (ADR-0050 §7): the classification's facts grouped by who reaches an
|
|
2
2
|
// endpoint and by what else they are about, one row per subject with all its lines, ranked by effect, review and
|
|
3
3
|
// reach, and quiet subjects that changed alike folded into one row. Pure, and it decides nothing: whether a run waits is
|
|
4
|
-
//
|
|
4
|
+
// `waitsForApproval` of its lines and its environment's protection alone.
|
|
5
5
|
|
|
6
6
|
import {
|
|
7
7
|
type AccessChangeDto,
|
|
@@ -13,12 +13,25 @@ import {
|
|
|
13
13
|
type SurfaceReach,
|
|
14
14
|
} from './index.js'
|
|
15
15
|
|
|
16
|
-
/**
|
|
16
|
+
/**
|
|
17
|
+
* Whether a change waits for a person on a protected environment (ADR-0050 §3): it has a line that needs closer review,
|
|
18
|
+
* a step off the paved road, something anyone sets off, people becoming visible or a migration that may change stored
|
|
19
|
+
* data. Any other change publishes at once, its lines recorded.
|
|
20
|
+
*/
|
|
21
|
+
export function waitsForApproval(changes: readonly Pick<AccessChangeDto, 'review'>[]): boolean {
|
|
22
|
+
return changes.some((change) => change.review === 'closer')
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* The endpoints of one caller group: everyone a reach admits, or the holders of one link mount's share links. `people`
|
|
27
|
+
* marks the machine endpoints that signed-in people reach too, a group of their own, so its title names both.
|
|
28
|
+
*/
|
|
17
29
|
export interface CallerGroup {
|
|
18
30
|
readonly kind: 'caller'
|
|
19
31
|
readonly key: string
|
|
20
32
|
readonly reach: SurfaceReach
|
|
21
33
|
readonly mount?: string
|
|
34
|
+
readonly people?: true
|
|
22
35
|
}
|
|
23
36
|
|
|
24
37
|
/** The lines about one kind of subject other than an endpoint: tables, roles, migrations, the application. */
|
|
@@ -55,16 +68,38 @@ export interface EffectTally {
|
|
|
55
68
|
readonly closer: number
|
|
56
69
|
}
|
|
57
70
|
|
|
71
|
+
/** A group's subjects by what their lines do: how many there are, how many widen access, how many need closer review. */
|
|
72
|
+
export interface SubjectTally {
|
|
73
|
+
readonly subjects: number
|
|
74
|
+
readonly widening: number
|
|
75
|
+
readonly closer: number
|
|
76
|
+
}
|
|
77
|
+
|
|
58
78
|
export type ChangeGroup = (CallerGroup | SubjectGroup) & {
|
|
59
79
|
readonly rows: readonly ChangeRow[]
|
|
60
80
|
/** How many subjects the group holds, folded ones included. */
|
|
61
81
|
readonly subjects: number
|
|
82
|
+
/** The group's lines by effect. */
|
|
62
83
|
readonly tally: EffectTally
|
|
84
|
+
/** The group's subjects (its rows' endpoints, tables, …) by effect: what its heading counts. */
|
|
85
|
+
readonly standing: SubjectTally
|
|
63
86
|
/** Whether the page collapses the group by default: only when it holds no widening line. */
|
|
64
87
|
readonly collapsed: boolean
|
|
65
88
|
}
|
|
66
89
|
|
|
67
90
|
export interface ApprovalView {
|
|
91
|
+
/**
|
|
92
|
+
* The change in a sentence or two, which the page leads with: the endpoints it adds, changes and removes, and what to
|
|
93
|
+
* check first. `check` is every line that needs closer review, the most important first; without one, the widening
|
|
94
|
+
* line most worth a look: a new endpoint the most exposed callers reach, else the most exposed widening. Empty when
|
|
95
|
+
* nothing widens or needs closer review.
|
|
96
|
+
*/
|
|
97
|
+
readonly summary: {
|
|
98
|
+
readonly added: number
|
|
99
|
+
readonly changed: number
|
|
100
|
+
readonly removed: number
|
|
101
|
+
readonly check: readonly AccessChangeDto[]
|
|
102
|
+
}
|
|
68
103
|
/**
|
|
69
104
|
* Per caller group the endpoints that change, apart from the removed endpoints and mounts its paths reach (a removal
|
|
70
105
|
* that widens stands with whoever its paths reach now), and the migration files the change adds or edits.
|
|
@@ -74,6 +109,7 @@ export interface ApprovalView {
|
|
|
74
109
|
readonly key: string
|
|
75
110
|
readonly reach: SurfaceReach
|
|
76
111
|
readonly mount?: string
|
|
112
|
+
readonly people?: true
|
|
77
113
|
readonly endpoints: number
|
|
78
114
|
readonly removedEndpoints: number
|
|
79
115
|
readonly removedMounts: number
|
|
@@ -110,10 +146,14 @@ export function approvalView(changes: readonly AccessChangeDto[]): ApprovalView
|
|
|
110
146
|
const subject = change.subject
|
|
111
147
|
if (subject === undefined) unsorted.push(change)
|
|
112
148
|
else if (change.audience !== undefined) {
|
|
113
|
-
const { reach, mount } = change.audience
|
|
114
|
-
|
|
149
|
+
const { reach, mount, callers: kinds } = change.audience
|
|
150
|
+
// An endpoint machines and signed-in people both reach is listed under machines, its most exposed caller, in a
|
|
151
|
+
// group of its own whose title names both.
|
|
152
|
+
const people = reach === 'machine' && kinds?.includes('human') === true
|
|
153
|
+
const key = mount !== undefined ? `${reach}:${mount}` : people ? `${reach}+human` : reach
|
|
115
154
|
const group = callers.get(key)
|
|
116
|
-
|
|
155
|
+
const head: CallerGroup = { kind: 'caller', key, reach, ...(mount === undefined ? {} : { mount }), ...(people ? { people: true } : {}) }
|
|
156
|
+
if (group === undefined) callers.set(key, { head, changes: [change] })
|
|
117
157
|
else group.changes.push(change)
|
|
118
158
|
} else {
|
|
119
159
|
const kind = data.get(subject.kind)
|
|
@@ -133,7 +173,16 @@ export function approvalView(changes: readonly AccessChangeDto[]): ApprovalView
|
|
|
133
173
|
entry.rows.flatMap(subjectRows).filter((row) =>
|
|
134
174
|
row.subject.kind === kind && row.changes.some((change) => change.rule === 'endpoint.removed' || change.rule === 'mount.removed') === removed
|
|
135
175
|
).length
|
|
176
|
+
// Each endpoint once, by what its lines say happened to it.
|
|
177
|
+
const fates = new Map<string, 'added' | 'removed' | 'changed'>()
|
|
178
|
+
for (const change of changes) {
|
|
179
|
+
if (change.subject?.kind !== 'endpoint') continue
|
|
180
|
+
const fate = change.rule === 'endpoint.added' ? 'added' : change.rule === 'endpoint.removed' ? 'removed' : 'changed'
|
|
181
|
+
if (fate !== 'changed' || !fates.has(change.subject.name)) fates.set(change.subject.name, fate)
|
|
182
|
+
}
|
|
183
|
+
const fateCount = (fate: 'added' | 'removed' | 'changed') => [...fates.values()].filter((each) => each === fate).length
|
|
136
184
|
return {
|
|
185
|
+
summary: { added: fateCount('added'), changed: fateCount('changed'), removed: fateCount('removed'), check: checkFirst(changes) },
|
|
137
186
|
impact: {
|
|
138
187
|
callers: callerGroups.flatMap((entry) =>
|
|
139
188
|
entry.kind === 'caller'
|
|
@@ -141,6 +190,7 @@ export function approvalView(changes: readonly AccessChangeDto[]): ApprovalView
|
|
|
141
190
|
key: entry.key,
|
|
142
191
|
reach: entry.reach,
|
|
143
192
|
...(entry.mount === undefined ? {} : { mount: entry.mount }),
|
|
193
|
+
...(entry.people === true ? { people: true as const } : {}),
|
|
144
194
|
endpoints: counted(entry, 'endpoint', false),
|
|
145
195
|
removedEndpoints: counted(entry, 'endpoint', true),
|
|
146
196
|
removedMounts: counted(entry, 'mount', true),
|
|
@@ -155,6 +205,21 @@ export function approvalView(changes: readonly AccessChangeDto[]): ApprovalView
|
|
|
155
205
|
}
|
|
156
206
|
}
|
|
157
207
|
|
|
208
|
+
/**
|
|
209
|
+
* What the approver checks first: every line for closer review, by rank; without one, the one widening line most worth a
|
|
210
|
+
* look: a new endpoint before any other line, the most exposed callers first, then the line's place.
|
|
211
|
+
*/
|
|
212
|
+
function checkFirst(changes: readonly AccessChangeDto[]): AccessChangeDto[] {
|
|
213
|
+
const placed = changes.map((change, index) => ({ change, index }))
|
|
214
|
+
const closer = placed.filter(({ change }) => change.review === 'closer')
|
|
215
|
+
if (closer.length > 0) return closer.sort((a, b) => changeRank(a.change) - changeRank(b.change) || a.index - b.index).map(({ change }) => change)
|
|
216
|
+
const reach = (change: AccessChangeDto) => (change.audience === undefined ? SURFACE_REACHES.length : SURFACE_REACHES.indexOf(change.audience.reach))
|
|
217
|
+
const added = (change: AccessChangeDto) => (change.rule === 'endpoint.added' ? 0 : 1)
|
|
218
|
+
const first = placed.filter(({ change }) => change.effect === 'widens')
|
|
219
|
+
.sort((a, b) => added(a.change) - added(b.change) || reach(a.change) - reach(b.change) || a.index - b.index)[0]
|
|
220
|
+
return first === undefined ? [] : [first.change]
|
|
221
|
+
}
|
|
222
|
+
|
|
158
223
|
/** Every line a row holds. */
|
|
159
224
|
export function rowChanges(row: ChangeRow): readonly AccessChangeDto[] {
|
|
160
225
|
return row.kind === 'subject' ? row.changes : row.subjects.flatMap((subject) => subject.changes)
|
|
@@ -194,6 +259,11 @@ function group(head: CallerGroup | SubjectGroup, changes: readonly AccessChangeD
|
|
|
194
259
|
rows: fold(rows.sort((a, b) => rowRank(a) - rowRank(b) || compareText(a.subject.name, b.subject.name))),
|
|
195
260
|
subjects: rows.length,
|
|
196
261
|
tally: tallyOf(changes),
|
|
262
|
+
standing: {
|
|
263
|
+
subjects: rows.length,
|
|
264
|
+
widening: rows.filter((row) => row.changes.some((change) => change.effect === 'widens')).length,
|
|
265
|
+
closer: rows.filter((row) => row.changes.some((change) => change.review === 'closer')).length,
|
|
266
|
+
},
|
|
197
267
|
collapsed: !changes.some((change) => change.effect === 'widens'),
|
|
198
268
|
}
|
|
199
269
|
}
|
package/src/index.ts
CHANGED
|
@@ -53,6 +53,9 @@ export interface GitHubSourceRepositoryDto {
|
|
|
53
53
|
readonly name: string
|
|
54
54
|
}
|
|
55
55
|
|
|
56
|
+
/** Who owns a connection's GitHub App: an organization, or a personal account. */
|
|
57
|
+
export type GitHubSourceOwnerType = 'Organization' | 'User'
|
|
58
|
+
|
|
56
59
|
export interface GitHubSourceConnectionAppDto {
|
|
57
60
|
readonly id: number
|
|
58
61
|
readonly slug: string
|
|
@@ -60,7 +63,7 @@ export interface GitHubSourceConnectionAppDto {
|
|
|
60
63
|
readonly public: boolean
|
|
61
64
|
readonly owner: {
|
|
62
65
|
readonly login: string
|
|
63
|
-
readonly type:
|
|
66
|
+
readonly type: GitHubSourceOwnerType
|
|
64
67
|
}
|
|
65
68
|
readonly permissions: {
|
|
66
69
|
readonly contents: 'read'
|
|
@@ -94,6 +97,8 @@ export interface GitHubSourceConnectionSetupPendingDto extends GitHubSourceConne
|
|
|
94
97
|
readonly phase: 'starting' | 'awaiting-manifest-callback' | 'persisting' | 'activating'
|
|
95
98
|
/** Present only while the same-origin manifest handoff can be resumed. */
|
|
96
99
|
readonly continuePath?: string
|
|
100
|
+
/** Present while a handoff link for an organization owner is outstanding: when it, and the setup, expire. */
|
|
101
|
+
readonly handoff?: { readonly expiresAt: number }
|
|
97
102
|
}
|
|
98
103
|
|
|
99
104
|
export interface GitHubSourceConnectionInstallationRequiredDto extends GitHubSourceConnectionBaseDto {
|
|
@@ -151,7 +156,13 @@ export type GitHubSourceConnectionStatusDto =
|
|
|
151
156
|
| GitHubSourceConnectionRepairRequiredDto
|
|
152
157
|
|
|
153
158
|
export interface StartGitHubSourceConnectionRequest {
|
|
159
|
+
/** The App owner's login: the organization's, or the personal account's when `ownerType` is `User`. */
|
|
154
160
|
readonly organization: string
|
|
161
|
+
/**
|
|
162
|
+
* Absent means `Organization`. GitHub creates a personal account's App on whichever account is signed in, so the
|
|
163
|
+
* person who continues the setup must be signed in to GitHub as that account.
|
|
164
|
+
*/
|
|
165
|
+
readonly ownerType?: GitHubSourceOwnerType
|
|
155
166
|
readonly appName: string
|
|
156
167
|
readonly visibility: 'private' | 'public'
|
|
157
168
|
readonly repositories: readonly GitHubSourceRepositoryDto[]
|
|
@@ -163,6 +174,29 @@ export interface StartGitHubSourceConnectionResponse {
|
|
|
163
174
|
readonly continuePath: string
|
|
164
175
|
}
|
|
165
176
|
|
|
177
|
+
export interface GitHubSourceConnectionHandoffInput {
|
|
178
|
+
readonly connectionId: string
|
|
179
|
+
/** How long the link stays usable: 600 to 86400 seconds, 3600 when omitted. It holds the one setup slot that long. */
|
|
180
|
+
readonly expiresInSeconds?: number
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
/** The setup that was cancelled before GitHub created its App. */
|
|
184
|
+
export interface GitHubSourceConnectionCancelDto {
|
|
185
|
+
readonly connectionId: string
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
/**
|
|
189
|
+
* A link for an owner of the organization who has no console session: opening it posts the manifest, and the owner
|
|
190
|
+
* creates and installs the App from their own browser. Shown once; a new one replaces it.
|
|
191
|
+
*/
|
|
192
|
+
export interface GitHubSourceConnectionHandoffDto {
|
|
193
|
+
readonly connectionId: string
|
|
194
|
+
/** Absolute URL on the console's origin; it carries the token, so treat it as a secret. */
|
|
195
|
+
readonly url: string
|
|
196
|
+
/** Unix seconds after which the link, and the setup it belongs to, expire. */
|
|
197
|
+
readonly expiresAt: number
|
|
198
|
+
}
|
|
199
|
+
|
|
166
200
|
/** One redacted line of deploy output: the runner's NDJSON log line and the control API's view of it. */
|
|
167
201
|
export const runLogLineSchema = z.object({
|
|
168
202
|
ts: z.number().finite(),
|
|
@@ -271,6 +305,43 @@ export interface SurfaceEndpointDto {
|
|
|
271
305
|
requirement: string | null
|
|
272
306
|
/** What else opens the endpoint: another origin, a file it answers, a body limit, a form's protection, a signature. */
|
|
273
307
|
notes: string[]
|
|
308
|
+
/**
|
|
309
|
+
* The same notes, in the same order, each with what it is about. Beside `notes`, never instead of it: a builder
|
|
310
|
+
* daemon of an older release reads `notes` as text and drops a field it does not know. Absent from a Control
|
|
311
|
+
* released before it.
|
|
312
|
+
*/
|
|
313
|
+
noteFacts?: SurfaceNoteDto[]
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
/**
|
|
317
|
+
* What a surface note is about: an opaque root it takes, another origin it is callable from, a file it answers or
|
|
318
|
+
* takes, an upload's body limit, a form's protection, a procedure's buckets and challenge (`guards`), how long it waits
|
|
319
|
+
* for a body of what size and how long it runs (`limits`), a webhook's signature. A line that already says one
|
|
320
|
+
* (`AccessChangeDto.states`) lets the approval page leave that note out of the line's row.
|
|
321
|
+
*/
|
|
322
|
+
export const SURFACE_NOTE_TOPICS = [
|
|
323
|
+
'opaque-root',
|
|
324
|
+
'cross-origin',
|
|
325
|
+
'answers-file',
|
|
326
|
+
'takes-files',
|
|
327
|
+
'body-limit',
|
|
328
|
+
'form',
|
|
329
|
+
'guards',
|
|
330
|
+
'limits',
|
|
331
|
+
'signature',
|
|
332
|
+
] as const
|
|
333
|
+
|
|
334
|
+
export type SurfaceNoteTopic = (typeof SURFACE_NOTE_TOPICS)[number]
|
|
335
|
+
|
|
336
|
+
/** One thing that opens an endpoint or stands in front of it, in the approval's words. */
|
|
337
|
+
export interface SurfaceNoteDto {
|
|
338
|
+
topic: SurfaceNoteTopic
|
|
339
|
+
text: string
|
|
340
|
+
/**
|
|
341
|
+
* The procedure's `limits` are the framework's defaults (its body limit and time limit, without file fields): the
|
|
342
|
+
* approval page says them once for every such row instead of on each.
|
|
343
|
+
*/
|
|
344
|
+
default?: true
|
|
274
345
|
}
|
|
275
346
|
|
|
276
347
|
export interface PutAppEnvRequest {
|
|
@@ -548,14 +619,19 @@ export interface ChangeAudienceDto {
|
|
|
548
619
|
mount?: string
|
|
549
620
|
/** What a caller must hold, as `SurfaceEndpointDto.requirement` words it; null for an anonymous kind. */
|
|
550
621
|
requirement: string | null
|
|
622
|
+
/**
|
|
623
|
+
* Every caller kind the endpoint admits, sorted, as `SurfaceEndpointDto.callers`; empty for an anonymous kind. Absent
|
|
624
|
+
* on a line classified before lines carried it.
|
|
625
|
+
*/
|
|
626
|
+
callers?: string[]
|
|
551
627
|
}
|
|
552
628
|
|
|
553
629
|
/**
|
|
554
630
|
* Why a line needs closer review: a step off the paved road, something anyone without signing in sets off, a mutation
|
|
555
|
-
* served on `GET`, people becoming visible, a file collection adopted or released,
|
|
556
|
-
* in at an enrolled terminal.
|
|
631
|
+
* served on `GET`, people becoming visible, a file collection adopted or released, the application naming who signs
|
|
632
|
+
* in at an enrolled terminal, or a migration statement not known to keep every stored value.
|
|
557
633
|
*/
|
|
558
|
-
export const REVIEW_REASONS = ['off-road', 'anyone-calls', 'get-mutation', 'people', 'adoption', 'terminal'] as const
|
|
634
|
+
export const REVIEW_REASONS = ['off-road', 'anyone-calls', 'get-mutation', 'people', 'adoption', 'terminal', 'deletes-data'] as const
|
|
559
635
|
|
|
560
636
|
export type ReviewReason = (typeof REVIEW_REASONS)[number]
|
|
561
637
|
|
|
@@ -584,12 +660,22 @@ export interface AccessChangeDto {
|
|
|
584
660
|
/** Who reaches the endpoint, on an endpoint subject. */
|
|
585
661
|
audience?: ChangeAudienceDto
|
|
586
662
|
consequence?: ChangeConsequenceDto
|
|
663
|
+
/**
|
|
664
|
+
* The line's words in a row that already names its endpoint, route and audience (the approval page's caller groups):
|
|
665
|
+
* `New endpoint`, `Output \`header\` gains field \`reference\``. Absent where the line has no shorter form.
|
|
666
|
+
*/
|
|
667
|
+
inRow?: string
|
|
668
|
+
/** The surface notes of its endpoint the line already says, so its row does not say them again. */
|
|
669
|
+
states?: SurfaceNoteTopic[]
|
|
587
670
|
}
|
|
588
671
|
|
|
589
672
|
/** A run's access change against its environment's active snapshot (ADR-0050 §3). */
|
|
590
673
|
export interface ApprovalDto {
|
|
591
674
|
run: RunDto
|
|
592
|
-
/**
|
|
675
|
+
/**
|
|
676
|
+
* `none`: no line. `no-widening`: lines that narrow or leave access unchanged. `widening`: a line widens. On a
|
|
677
|
+
* protected environment only a change with a closer-review line waits (`waitsForApproval`); any other publishes at once.
|
|
678
|
+
*/
|
|
593
679
|
outcome: 'none' | 'no-widening' | 'widening'
|
|
594
680
|
changes: AccessChangeDto[]
|
|
595
681
|
/** The digest of the run's snapshot and of the active one it was compared with: an approval is bound to both. */
|
package/src/rpc.ts
CHANGED
|
@@ -25,6 +25,9 @@ import type {
|
|
|
25
25
|
CursorList,
|
|
26
26
|
DeploymentNamespaceDetailDto,
|
|
27
27
|
DeploymentNamespaceListResponse,
|
|
28
|
+
GitHubSourceConnectionCancelDto,
|
|
29
|
+
GitHubSourceConnectionHandoffDto,
|
|
30
|
+
GitHubSourceConnectionHandoffInput,
|
|
28
31
|
GitHubSourceConnectionListInput,
|
|
29
32
|
GitHubSourceConnectionListResponse,
|
|
30
33
|
GitHubSourceConnectionStatusDto,
|
|
@@ -154,6 +157,8 @@ export interface GitHubSourceConnectionInput {
|
|
|
154
157
|
export interface GitHubSourceConnectionRpcContract {
|
|
155
158
|
list: RpcProcedure<GitHubSourceConnectionListInput, GitHubSourceConnectionListResponse>
|
|
156
159
|
start: RpcProcedure<StartGitHubSourceConnectionRequest, StartGitHubSourceConnectionResponse>
|
|
160
|
+
handoff: RpcProcedure<GitHubSourceConnectionHandoffInput, GitHubSourceConnectionHandoffDto>
|
|
161
|
+
cancel: RpcProcedure<GitHubSourceConnectionInput, GitHubSourceConnectionCancelDto>
|
|
157
162
|
verifyInstallation: RpcProcedure<GitHubSourceConnectionInput, GitHubSourceConnectionStatusDto>
|
|
158
163
|
repair: RpcProcedure<GitHubSourceConnectionInput, GitHubSourceConnectionStatusDto>
|
|
159
164
|
reconcile: RpcProcedure<GitHubSourceConnectionInput, GitHubSourceConnectionStatusDto>
|
|
@@ -1,10 +1,20 @@
|
|
|
1
1
|
import { type AccessChangeDto, type ChangeAudienceDto, type ChangeSubjectDto, type ChangeSubjectKind, type SurfaceReach } from './index.js';
|
|
2
|
-
/**
|
|
2
|
+
/**
|
|
3
|
+
* Whether a change waits for a person on a protected environment (ADR-0050 §3): it has a line that needs closer review,
|
|
4
|
+
* a step off the paved road, something anyone sets off, people becoming visible or a migration that may change stored
|
|
5
|
+
* data. Any other change publishes at once, its lines recorded.
|
|
6
|
+
*/
|
|
7
|
+
export declare function waitsForApproval(changes: readonly Pick<AccessChangeDto, 'review'>[]): boolean;
|
|
8
|
+
/**
|
|
9
|
+
* The endpoints of one caller group: everyone a reach admits, or the holders of one link mount's share links. `people`
|
|
10
|
+
* marks the machine endpoints that signed-in people reach too, a group of their own, so its title names both.
|
|
11
|
+
*/
|
|
3
12
|
export interface CallerGroup {
|
|
4
13
|
readonly kind: 'caller';
|
|
5
14
|
readonly key: string;
|
|
6
15
|
readonly reach: SurfaceReach;
|
|
7
16
|
readonly mount?: string;
|
|
17
|
+
readonly people?: true;
|
|
8
18
|
}
|
|
9
19
|
/** The lines about one kind of subject other than an endpoint: tables, roles, migrations, the application. */
|
|
10
20
|
export interface SubjectGroup {
|
|
@@ -38,15 +48,36 @@ export interface EffectTally {
|
|
|
38
48
|
readonly neutral: number;
|
|
39
49
|
readonly closer: number;
|
|
40
50
|
}
|
|
51
|
+
/** A group's subjects by what their lines do: how many there are, how many widen access, how many need closer review. */
|
|
52
|
+
export interface SubjectTally {
|
|
53
|
+
readonly subjects: number;
|
|
54
|
+
readonly widening: number;
|
|
55
|
+
readonly closer: number;
|
|
56
|
+
}
|
|
41
57
|
export type ChangeGroup = (CallerGroup | SubjectGroup) & {
|
|
42
58
|
readonly rows: readonly ChangeRow[];
|
|
43
59
|
/** How many subjects the group holds, folded ones included. */
|
|
44
60
|
readonly subjects: number;
|
|
61
|
+
/** The group's lines by effect. */
|
|
45
62
|
readonly tally: EffectTally;
|
|
63
|
+
/** The group's subjects (its rows' endpoints, tables, …) by effect: what its heading counts. */
|
|
64
|
+
readonly standing: SubjectTally;
|
|
46
65
|
/** Whether the page collapses the group by default: only when it holds no widening line. */
|
|
47
66
|
readonly collapsed: boolean;
|
|
48
67
|
};
|
|
49
68
|
export interface ApprovalView {
|
|
69
|
+
/**
|
|
70
|
+
* The change in a sentence or two, which the page leads with: the endpoints it adds, changes and removes, and what to
|
|
71
|
+
* check first. `check` is every line that needs closer review, the most important first; without one, the widening
|
|
72
|
+
* line most worth a look: a new endpoint the most exposed callers reach, else the most exposed widening. Empty when
|
|
73
|
+
* nothing widens or needs closer review.
|
|
74
|
+
*/
|
|
75
|
+
readonly summary: {
|
|
76
|
+
readonly added: number;
|
|
77
|
+
readonly changed: number;
|
|
78
|
+
readonly removed: number;
|
|
79
|
+
readonly check: readonly AccessChangeDto[];
|
|
80
|
+
};
|
|
50
81
|
/**
|
|
51
82
|
* Per caller group the endpoints that change, apart from the removed endpoints and mounts its paths reach (a removal
|
|
52
83
|
* that widens stands with whoever its paths reach now), and the migration files the change adds or edits.
|
|
@@ -56,6 +87,7 @@ export interface ApprovalView {
|
|
|
56
87
|
readonly key: string;
|
|
57
88
|
readonly reach: SurfaceReach;
|
|
58
89
|
readonly mount?: string;
|
|
90
|
+
readonly people?: true;
|
|
59
91
|
readonly endpoints: number;
|
|
60
92
|
readonly removedEndpoints: number;
|
|
61
93
|
readonly removedMounts: number;
|
package/types/src/index.d.ts
CHANGED
|
@@ -46,6 +46,8 @@ export interface GitHubSourceRepositoryDto {
|
|
|
46
46
|
readonly owner: string;
|
|
47
47
|
readonly name: string;
|
|
48
48
|
}
|
|
49
|
+
/** Who owns a connection's GitHub App: an organization, or a personal account. */
|
|
50
|
+
export type GitHubSourceOwnerType = 'Organization' | 'User';
|
|
49
51
|
export interface GitHubSourceConnectionAppDto {
|
|
50
52
|
readonly id: number;
|
|
51
53
|
readonly slug: string;
|
|
@@ -53,7 +55,7 @@ export interface GitHubSourceConnectionAppDto {
|
|
|
53
55
|
readonly public: boolean;
|
|
54
56
|
readonly owner: {
|
|
55
57
|
readonly login: string;
|
|
56
|
-
readonly type:
|
|
58
|
+
readonly type: GitHubSourceOwnerType;
|
|
57
59
|
};
|
|
58
60
|
readonly permissions: {
|
|
59
61
|
readonly contents: 'read';
|
|
@@ -82,6 +84,10 @@ export interface GitHubSourceConnectionSetupPendingDto extends GitHubSourceConne
|
|
|
82
84
|
readonly phase: 'starting' | 'awaiting-manifest-callback' | 'persisting' | 'activating';
|
|
83
85
|
/** Present only while the same-origin manifest handoff can be resumed. */
|
|
84
86
|
readonly continuePath?: string;
|
|
87
|
+
/** Present while a handoff link for an organization owner is outstanding: when it, and the setup, expire. */
|
|
88
|
+
readonly handoff?: {
|
|
89
|
+
readonly expiresAt: number;
|
|
90
|
+
};
|
|
85
91
|
}
|
|
86
92
|
export interface GitHubSourceConnectionInstallationRequiredDto extends GitHubSourceConnectionBaseDto {
|
|
87
93
|
readonly state: 'installation-required';
|
|
@@ -122,7 +128,13 @@ export interface GitHubSourceConnectionRepairRequiredDto extends GitHubSourceCon
|
|
|
122
128
|
/** Browser-safe setup state. It never carries a private key, webhook secret, token, or source RPC key. */
|
|
123
129
|
export type GitHubSourceConnectionStatusDto = GitHubSourceConnectionAnonymousDto | GitHubSourceConnectionUnavailableDto | GitHubSourceConnectionSetupPendingDto | GitHubSourceConnectionInstallationRequiredDto | GitHubSourceConnectionConnectedDto | GitHubSourceConnectionRepairRequiredDto;
|
|
124
130
|
export interface StartGitHubSourceConnectionRequest {
|
|
131
|
+
/** The App owner's login: the organization's, or the personal account's when `ownerType` is `User`. */
|
|
125
132
|
readonly organization: string;
|
|
133
|
+
/**
|
|
134
|
+
* Absent means `Organization`. GitHub creates a personal account's App on whichever account is signed in, so the
|
|
135
|
+
* person who continues the setup must be signed in to GitHub as that account.
|
|
136
|
+
*/
|
|
137
|
+
readonly ownerType?: GitHubSourceOwnerType;
|
|
126
138
|
readonly appName: string;
|
|
127
139
|
readonly visibility: 'private' | 'public';
|
|
128
140
|
readonly repositories: readonly GitHubSourceRepositoryDto[];
|
|
@@ -132,6 +144,26 @@ export interface StartGitHubSourceConnectionResponse {
|
|
|
132
144
|
/** Same-origin path that starts the GitHub manifest handoff. */
|
|
133
145
|
readonly continuePath: string;
|
|
134
146
|
}
|
|
147
|
+
export interface GitHubSourceConnectionHandoffInput {
|
|
148
|
+
readonly connectionId: string;
|
|
149
|
+
/** How long the link stays usable: 600 to 86400 seconds, 3600 when omitted. It holds the one setup slot that long. */
|
|
150
|
+
readonly expiresInSeconds?: number;
|
|
151
|
+
}
|
|
152
|
+
/** The setup that was cancelled before GitHub created its App. */
|
|
153
|
+
export interface GitHubSourceConnectionCancelDto {
|
|
154
|
+
readonly connectionId: string;
|
|
155
|
+
}
|
|
156
|
+
/**
|
|
157
|
+
* A link for an owner of the organization who has no console session: opening it posts the manifest, and the owner
|
|
158
|
+
* creates and installs the App from their own browser. Shown once; a new one replaces it.
|
|
159
|
+
*/
|
|
160
|
+
export interface GitHubSourceConnectionHandoffDto {
|
|
161
|
+
readonly connectionId: string;
|
|
162
|
+
/** Absolute URL on the console's origin; it carries the token, so treat it as a secret. */
|
|
163
|
+
readonly url: string;
|
|
164
|
+
/** Unix seconds after which the link, and the setup it belongs to, expire. */
|
|
165
|
+
readonly expiresAt: number;
|
|
166
|
+
}
|
|
135
167
|
/** One redacted line of deploy output: the runner's NDJSON log line and the control API's view of it. */
|
|
136
168
|
export declare const runLogLineSchema: z.ZodObject<{
|
|
137
169
|
ts: z.ZodNumber;
|
|
@@ -235,6 +267,30 @@ export interface SurfaceEndpointDto {
|
|
|
235
267
|
requirement: string | null;
|
|
236
268
|
/** What else opens the endpoint: another origin, a file it answers, a body limit, a form's protection, a signature. */
|
|
237
269
|
notes: string[];
|
|
270
|
+
/**
|
|
271
|
+
* The same notes, in the same order, each with what it is about. Beside `notes`, never instead of it: a builder
|
|
272
|
+
* daemon of an older release reads `notes` as text and drops a field it does not know. Absent from a Control
|
|
273
|
+
* released before it.
|
|
274
|
+
*/
|
|
275
|
+
noteFacts?: SurfaceNoteDto[];
|
|
276
|
+
}
|
|
277
|
+
/**
|
|
278
|
+
* What a surface note is about: an opaque root it takes, another origin it is callable from, a file it answers or
|
|
279
|
+
* takes, an upload's body limit, a form's protection, a procedure's buckets and challenge (`guards`), how long it waits
|
|
280
|
+
* for a body of what size and how long it runs (`limits`), a webhook's signature. A line that already says one
|
|
281
|
+
* (`AccessChangeDto.states`) lets the approval page leave that note out of the line's row.
|
|
282
|
+
*/
|
|
283
|
+
export declare const SURFACE_NOTE_TOPICS: readonly ["opaque-root", "cross-origin", "answers-file", "takes-files", "body-limit", "form", "guards", "limits", "signature"];
|
|
284
|
+
export type SurfaceNoteTopic = (typeof SURFACE_NOTE_TOPICS)[number];
|
|
285
|
+
/** One thing that opens an endpoint or stands in front of it, in the approval's words. */
|
|
286
|
+
export interface SurfaceNoteDto {
|
|
287
|
+
topic: SurfaceNoteTopic;
|
|
288
|
+
text: string;
|
|
289
|
+
/**
|
|
290
|
+
* The procedure's `limits` are the framework's defaults (its body limit and time limit, without file fields): the
|
|
291
|
+
* approval page says them once for every such row instead of on each.
|
|
292
|
+
*/
|
|
293
|
+
default?: true;
|
|
238
294
|
}
|
|
239
295
|
export interface PutAppEnvRequest {
|
|
240
296
|
domain?: string | null;
|
|
@@ -464,13 +520,18 @@ export interface ChangeAudienceDto {
|
|
|
464
520
|
mount?: string;
|
|
465
521
|
/** What a caller must hold, as `SurfaceEndpointDto.requirement` words it; null for an anonymous kind. */
|
|
466
522
|
requirement: string | null;
|
|
523
|
+
/**
|
|
524
|
+
* Every caller kind the endpoint admits, sorted, as `SurfaceEndpointDto.callers`; empty for an anonymous kind. Absent
|
|
525
|
+
* on a line classified before lines carried it.
|
|
526
|
+
*/
|
|
527
|
+
callers?: string[];
|
|
467
528
|
}
|
|
468
529
|
/**
|
|
469
530
|
* Why a line needs closer review: a step off the paved road, something anyone without signing in sets off, a mutation
|
|
470
|
-
* served on `GET`, people becoming visible, a file collection adopted or released,
|
|
471
|
-
* in at an enrolled terminal.
|
|
531
|
+
* served on `GET`, people becoming visible, a file collection adopted or released, the application naming who signs
|
|
532
|
+
* in at an enrolled terminal, or a migration statement not known to keep every stored value.
|
|
472
533
|
*/
|
|
473
|
-
export declare const REVIEW_REASONS: readonly ["off-road", "anyone-calls", "get-mutation", "people", "adoption", "terminal"];
|
|
534
|
+
export declare const REVIEW_REASONS: readonly ["off-road", "anyone-calls", "get-mutation", "people", "adoption", "terminal", "deletes-data"];
|
|
474
535
|
export type ReviewReason = (typeof REVIEW_REASONS)[number];
|
|
475
536
|
/** What a call sets off, when the line says so. */
|
|
476
537
|
export interface ChangeConsequenceDto {
|
|
@@ -496,11 +557,21 @@ export interface AccessChangeDto {
|
|
|
496
557
|
/** Who reaches the endpoint, on an endpoint subject. */
|
|
497
558
|
audience?: ChangeAudienceDto;
|
|
498
559
|
consequence?: ChangeConsequenceDto;
|
|
560
|
+
/**
|
|
561
|
+
* The line's words in a row that already names its endpoint, route and audience (the approval page's caller groups):
|
|
562
|
+
* `New endpoint`, `Output \`header\` gains field \`reference\``. Absent where the line has no shorter form.
|
|
563
|
+
*/
|
|
564
|
+
inRow?: string;
|
|
565
|
+
/** The surface notes of its endpoint the line already says, so its row does not say them again. */
|
|
566
|
+
states?: SurfaceNoteTopic[];
|
|
499
567
|
}
|
|
500
568
|
/** A run's access change against its environment's active snapshot (ADR-0050 §3). */
|
|
501
569
|
export interface ApprovalDto {
|
|
502
570
|
run: RunDto;
|
|
503
|
-
/**
|
|
571
|
+
/**
|
|
572
|
+
* `none`: no line. `no-widening`: lines that narrow or leave access unchanged. `widening`: a line widens. On a
|
|
573
|
+
* protected environment only a change with a closer-review line waits (`waitsForApproval`); any other publishes at once.
|
|
574
|
+
*/
|
|
504
575
|
outcome: 'none' | 'no-widening' | 'widening';
|
|
505
576
|
changes: AccessChangeDto[];
|
|
506
577
|
/** The digest of the run's snapshot and of the active one it was compared with: an approval is bound to both. */
|
package/types/src/rpc.d.ts
CHANGED
|
@@ -3,7 +3,7 @@ import type { ExportDescription, OpsContentView, OpsView } from '@fabrika/auth-c
|
|
|
3
3
|
import { z } from 'zod';
|
|
4
4
|
import type { BuilderConnectionReceiptDto, CreateBuilderConnectionReceiptRequest, GetBuilderConnectionReceiptRequest } from './builder-connections.js';
|
|
5
5
|
import type { ApproveDeviceAuthorizationResult, BuilderPairingProofRequest, DenyDeviceAuthorizationResult, InspectDeviceAuthorizationResult, ListOwnBuilderPairingsRequest, ListOwnDeviceAuthorizationsResult, RevokeBuilderPairingRequest, RevokeKeyResult } from './builder-pairing.js';
|
|
6
|
-
import type { AdoptDeploymentNamespaceRequest, AppDto, AppEnvDto, ApprovalDto, AppSecretDto, AppVarDto, CompleteApprovalRequest, ConsoleAccessDto, CreateDeploymentNamespaceRequest, CursorList, DeploymentNamespaceDetailDto, DeploymentNamespaceListResponse, GitHubSourceConnectionListInput, GitHubSourceConnectionListResponse, GitHubSourceConnectionStatusDto, InstallationDto, ListResponse, PlanDeploymentNamespaceRequest, PlanDeploymentNamespaceResponse, PutAppEnvRequest, PutAppSecretRequest, PutAppVarRequest, RegisterAppRequest, RegisterAppResponse, ReleaseNamespaceClaimsResponse, RemoveDeploymentNamespaceResponse, RepublishAllNamespacesResponse, RunDto, RunLogResponse, RunStatus, RunTailResponse, SetEnvironmentProtectionRequest, StartGitHubSourceConnectionRequest, StartGitHubSourceConnectionResponse, TriggerDeployRequest, UpdateAppRequest, UpdateDeploymentNamespaceRequest } from './index.js';
|
|
6
|
+
import type { AdoptDeploymentNamespaceRequest, AppDto, AppEnvDto, ApprovalDto, AppSecretDto, AppVarDto, CompleteApprovalRequest, ConsoleAccessDto, CreateDeploymentNamespaceRequest, CursorList, DeploymentNamespaceDetailDto, DeploymentNamespaceListResponse, GitHubSourceConnectionCancelDto, GitHubSourceConnectionHandoffDto, GitHubSourceConnectionHandoffInput, GitHubSourceConnectionListInput, GitHubSourceConnectionListResponse, GitHubSourceConnectionStatusDto, InstallationDto, ListResponse, PlanDeploymentNamespaceRequest, PlanDeploymentNamespaceResponse, PutAppEnvRequest, PutAppSecretRequest, PutAppVarRequest, RegisterAppRequest, RegisterAppResponse, ReleaseNamespaceClaimsResponse, RemoveDeploymentNamespaceResponse, RepublishAllNamespacesResponse, RunDto, RunLogResponse, RunStatus, RunTailResponse, SetEnvironmentProtectionRequest, StartGitHubSourceConnectionRequest, StartGitHubSourceConnectionResponse, TriggerDeployRequest, UpdateAppRequest, UpdateDeploymentNamespaceRequest } from './index.js';
|
|
7
7
|
import type { MailMessageDetailDto, MailMessageDto, MailMessageIdInput, MailMessageListInput, MailRuleDto, MailRuleIdInput, SetMailRuleInput } from './mail.js';
|
|
8
8
|
type RpcProcedure<TInput, TOutput> = RpcProcedureContract<TInput, TOutput>;
|
|
9
9
|
export interface AppIdInput {
|
|
@@ -78,6 +78,8 @@ export interface GitHubSourceConnectionInput {
|
|
|
78
78
|
export interface GitHubSourceConnectionRpcContract {
|
|
79
79
|
list: RpcProcedure<GitHubSourceConnectionListInput, GitHubSourceConnectionListResponse>;
|
|
80
80
|
start: RpcProcedure<StartGitHubSourceConnectionRequest, StartGitHubSourceConnectionResponse>;
|
|
81
|
+
handoff: RpcProcedure<GitHubSourceConnectionHandoffInput, GitHubSourceConnectionHandoffDto>;
|
|
82
|
+
cancel: RpcProcedure<GitHubSourceConnectionInput, GitHubSourceConnectionCancelDto>;
|
|
81
83
|
verifyInstallation: RpcProcedure<GitHubSourceConnectionInput, GitHubSourceConnectionStatusDto>;
|
|
82
84
|
repair: RpcProcedure<GitHubSourceConnectionInput, GitHubSourceConnectionStatusDto>;
|
|
83
85
|
reconcile: RpcProcedure<GitHubSourceConnectionInput, GitHubSourceConnectionStatusDto>;
|