@fabrika/control-contract 0.9.0-cloudflare.2 → 0.9.0-cloudflare.3
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 +265 -0
- package/src/index.ts +90 -4
- package/src/rpc.ts +85 -3
- package/types/src/approval-view.d.ts +79 -0
- package/types/src/builder-connections.d.ts +15 -15
- package/types/src/index.d.ts +63 -4
- package/types/src/rpc.d.ts +78 -3
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fabrika/control-contract",
|
|
3
|
-
"version": "0.9.0-cloudflare.
|
|
3
|
+
"version": "0.9.0-cloudflare.3",
|
|
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-cloudflare.
|
|
30
|
-
"@fabrika/app": "0.9.0-cloudflare.
|
|
31
|
-
"@fabrika/provider-contract": "0.9.0-cloudflare.
|
|
29
|
+
"@fabrika/auth-core": "0.9.0-cloudflare.3",
|
|
30
|
+
"@fabrika/app": "0.9.0-cloudflare.3",
|
|
31
|
+
"@fabrika/provider-contract": "0.9.0-cloudflare.3"
|
|
32
32
|
}
|
|
33
33
|
}
|
|
@@ -0,0 +1,265 @@
|
|
|
1
|
+
// How the approval page shows one access change (ADR-0050 §7): the classification's facts grouped by who reaches an
|
|
2
|
+
// endpoint and by what else they are about, one row per subject with all its lines, ranked by effect, review and
|
|
3
|
+
// reach, and quiet subjects that changed alike folded into one row. Pure, and it decides nothing: whether a run waits is
|
|
4
|
+
// the classification's outcome alone.
|
|
5
|
+
|
|
6
|
+
import {
|
|
7
|
+
type AccessChangeDto,
|
|
8
|
+
CHANGE_SUBJECT_KINDS,
|
|
9
|
+
type ChangeAudienceDto,
|
|
10
|
+
type ChangeSubjectDto,
|
|
11
|
+
type ChangeSubjectKind,
|
|
12
|
+
SURFACE_REACHES,
|
|
13
|
+
type SurfaceReach,
|
|
14
|
+
} from './index.js'
|
|
15
|
+
|
|
16
|
+
/** The endpoints of one caller group: everyone a reach admits, or the holders of one link mount's share links. */
|
|
17
|
+
export interface CallerGroup {
|
|
18
|
+
readonly kind: 'caller'
|
|
19
|
+
readonly key: string
|
|
20
|
+
readonly reach: SurfaceReach
|
|
21
|
+
readonly mount?: string
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/** The lines about one kind of subject other than an endpoint: tables, roles, migrations, the application. */
|
|
25
|
+
export interface SubjectGroup {
|
|
26
|
+
readonly kind: 'subject'
|
|
27
|
+
readonly key: string
|
|
28
|
+
readonly subject: ChangeSubjectKind
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/** One subject and its lines, most important first. */
|
|
32
|
+
export interface SubjectRow {
|
|
33
|
+
readonly kind: 'subject'
|
|
34
|
+
readonly subject: ChangeSubjectDto
|
|
35
|
+
readonly audience?: ChangeAudienceDto
|
|
36
|
+
readonly changes: readonly AccessChangeDto[]
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Quiet subjects that changed alike: each has lines of exactly these rules and effects, and none of them widens or needs
|
|
41
|
+
* closer review (`rules` in order, as `rule` and `effect`).
|
|
42
|
+
*/
|
|
43
|
+
export interface FoldedRow {
|
|
44
|
+
readonly kind: 'folded'
|
|
45
|
+
readonly rules: readonly { readonly rule: string; readonly effect: 'narrows' | 'neutral' }[]
|
|
46
|
+
readonly subjects: readonly SubjectRow[]
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
export type ChangeRow = SubjectRow | FoldedRow
|
|
50
|
+
|
|
51
|
+
export interface EffectTally {
|
|
52
|
+
readonly widens: number
|
|
53
|
+
readonly narrows: number
|
|
54
|
+
readonly neutral: number
|
|
55
|
+
readonly closer: number
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
export type ChangeGroup = (CallerGroup | SubjectGroup) & {
|
|
59
|
+
readonly rows: readonly ChangeRow[]
|
|
60
|
+
/** How many subjects the group holds, folded ones included. */
|
|
61
|
+
readonly subjects: number
|
|
62
|
+
readonly tally: EffectTally
|
|
63
|
+
/** Whether the page collapses the group by default: only when it holds no widening line. */
|
|
64
|
+
readonly collapsed: boolean
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
export interface ApprovalView {
|
|
68
|
+
/**
|
|
69
|
+
* Per caller group the endpoints that change, apart from the removed endpoints and mounts its paths reach (a removal
|
|
70
|
+
* that widens stands with whoever its paths reach now), and the migration files the change adds or edits.
|
|
71
|
+
*/
|
|
72
|
+
readonly impact: {
|
|
73
|
+
readonly callers: readonly {
|
|
74
|
+
readonly key: string
|
|
75
|
+
readonly reach: SurfaceReach
|
|
76
|
+
readonly mount?: string
|
|
77
|
+
readonly endpoints: number
|
|
78
|
+
readonly removedEndpoints: number
|
|
79
|
+
readonly removedMounts: number
|
|
80
|
+
}[]
|
|
81
|
+
readonly migrations: number
|
|
82
|
+
}
|
|
83
|
+
readonly callers: readonly ChangeGroup[]
|
|
84
|
+
readonly data: readonly ChangeGroup[]
|
|
85
|
+
/** The lines of a run classified before lines carried facts, in their stored order. */
|
|
86
|
+
readonly unsorted: readonly AccessChangeDto[]
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
/** Quiet subjects that changed alike fold from this many on. */
|
|
90
|
+
export const FOLD_AT = 3
|
|
91
|
+
|
|
92
|
+
/**
|
|
93
|
+
* A line's rank: a widening for closer review first, then a widening, a narrowing for closer review, a line that leaves
|
|
94
|
+
* access unchanged, a narrowing. Nothing else enters it, so it cannot disagree with the classification.
|
|
95
|
+
*/
|
|
96
|
+
export function changeRank(change: Pick<AccessChangeDto, 'effect' | 'review'>): number {
|
|
97
|
+
const closer = change.review === 'closer'
|
|
98
|
+
if (change.effect === 'widens') return closer ? 0 : 1
|
|
99
|
+
if (closer) return 2
|
|
100
|
+
return change.effect === 'neutral' ? 3 : 4
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
export function approvalView(changes: readonly AccessChangeDto[]): ApprovalView {
|
|
104
|
+
const callers = new Map<string, { readonly head: CallerGroup; readonly changes: AccessChangeDto[] }>()
|
|
105
|
+
const data = new Map<ChangeSubjectKind, AccessChangeDto[]>()
|
|
106
|
+
const unsorted: AccessChangeDto[] = []
|
|
107
|
+
// A line with an audience is about who reaches something: an endpoint, or a removed mount whose paths now reach a
|
|
108
|
+
// more exposed endpoint. Every other line is about data and runtime.
|
|
109
|
+
for (const change of changes) {
|
|
110
|
+
const subject = change.subject
|
|
111
|
+
if (subject === undefined) unsorted.push(change)
|
|
112
|
+
else if (change.audience !== undefined) {
|
|
113
|
+
const { reach, mount } = change.audience
|
|
114
|
+
const key = mount === undefined ? reach : `${reach}:${mount}`
|
|
115
|
+
const group = callers.get(key)
|
|
116
|
+
if (group === undefined) callers.set(key, { head: { kind: 'caller', key, reach, ...(mount === undefined ? {} : { mount }) }, changes: [change] })
|
|
117
|
+
else group.changes.push(change)
|
|
118
|
+
} else {
|
|
119
|
+
const kind = data.get(subject.kind)
|
|
120
|
+
if (kind === undefined) data.set(subject.kind, [change])
|
|
121
|
+
else kind.push(change)
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
const callerGroups = sortGroups([...callers.values()].map(({ head, changes }) => group(head, changes)), reachIndex)
|
|
125
|
+
const dataGroups = sortGroups([...data].map(([subject, changes]) => group({ kind: 'subject', key: subject, subject }, changes)), subjectIndex)
|
|
126
|
+
// A migration file the change adds or edits; a removed file runs nowhere.
|
|
127
|
+
const migrations = new Set(
|
|
128
|
+
changes.flatMap((change) =>
|
|
129
|
+
change.subject?.kind === 'migration' && (change.rule === 'migration.added' || change.rule === 'migration.changed') ? [change.subject.name] : []
|
|
130
|
+
),
|
|
131
|
+
)
|
|
132
|
+
const counted = (entry: ChangeGroup, kind: 'endpoint' | 'mount', removed: boolean) =>
|
|
133
|
+
entry.rows.flatMap(subjectRows).filter((row) =>
|
|
134
|
+
row.subject.kind === kind && row.changes.some((change) => change.rule === 'endpoint.removed' || change.rule === 'mount.removed') === removed
|
|
135
|
+
).length
|
|
136
|
+
return {
|
|
137
|
+
impact: {
|
|
138
|
+
callers: callerGroups.flatMap((entry) =>
|
|
139
|
+
entry.kind === 'caller'
|
|
140
|
+
? [{
|
|
141
|
+
key: entry.key,
|
|
142
|
+
reach: entry.reach,
|
|
143
|
+
...(entry.mount === undefined ? {} : { mount: entry.mount }),
|
|
144
|
+
endpoints: counted(entry, 'endpoint', false),
|
|
145
|
+
removedEndpoints: counted(entry, 'endpoint', true),
|
|
146
|
+
removedMounts: counted(entry, 'mount', true),
|
|
147
|
+
}]
|
|
148
|
+
: []
|
|
149
|
+
),
|
|
150
|
+
migrations: migrations.size,
|
|
151
|
+
},
|
|
152
|
+
callers: callerGroups,
|
|
153
|
+
data: dataGroups,
|
|
154
|
+
unsorted,
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
/** Every line a row holds. */
|
|
159
|
+
export function rowChanges(row: ChangeRow): readonly AccessChangeDto[] {
|
|
160
|
+
return row.kind === 'subject' ? row.changes : row.subjects.flatMap((subject) => subject.changes)
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
/** Every subject a row holds. */
|
|
164
|
+
function subjectRows(row: ChangeRow): readonly SubjectRow[] {
|
|
165
|
+
return row.kind === 'subject' ? [row] : row.subjects
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
/** Groups in rank order: the group whose most important line ranks first, then by `index` (reach or subject kind). */
|
|
169
|
+
function sortGroups(groups: readonly ChangeGroup[], index: (entry: ChangeGroup) => number): ChangeGroup[] {
|
|
170
|
+
const ranked = groups.map((entry) => ({ entry, rank: Math.min(...entry.rows.flatMap(rowChanges).map(changeRank)) }))
|
|
171
|
+
return ranked.sort((a, b) => a.rank - b.rank || index(a.entry) - index(b.entry) || compareText(a.entry.key, b.entry.key)).map(({ entry }) => entry)
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
function group(head: CallerGroup | SubjectGroup, changes: readonly AccessChangeDto[]): ChangeGroup {
|
|
175
|
+
const bySubject = new Map<string, { subject: ChangeSubjectDto; audience?: ChangeAudienceDto; changes: AccessChangeDto[] }>()
|
|
176
|
+
for (const change of changes) {
|
|
177
|
+
const subject = change.subject
|
|
178
|
+
if (subject === undefined) continue
|
|
179
|
+
// A removed mount and an endpoint may share a name; a subject is its kind and its name.
|
|
180
|
+
const key = `${subject.kind}:${subject.name}`
|
|
181
|
+
const entry = bySubject.get(key)
|
|
182
|
+
if (entry === undefined) bySubject.set(key, { subject, ...(change.audience === undefined ? {} : { audience: change.audience }), changes: [change] })
|
|
183
|
+
else entry.changes.push(change)
|
|
184
|
+
}
|
|
185
|
+
const rows = [...bySubject.values()].map((entry): SubjectRow => ({
|
|
186
|
+
kind: 'subject',
|
|
187
|
+
subject: entry.subject,
|
|
188
|
+
...(entry.audience === undefined ? {} : { audience: entry.audience }),
|
|
189
|
+
changes: entry.changes.map((change, index) => ({ change, index })).sort((a, b) => changeRank(a.change) - changeRank(b.change) || a.index - b.index)
|
|
190
|
+
.map(({ change }) => change),
|
|
191
|
+
}))
|
|
192
|
+
return {
|
|
193
|
+
...head,
|
|
194
|
+
rows: fold(rows.sort((a, b) => rowRank(a) - rowRank(b) || compareText(a.subject.name, b.subject.name))),
|
|
195
|
+
subjects: rows.length,
|
|
196
|
+
tally: tallyOf(changes),
|
|
197
|
+
collapsed: !changes.some((change) => change.effect === 'widens'),
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
/**
|
|
202
|
+
* A subject is quiet when none of its lines widens or needs closer review. Quiet subjects whose lines have the same rules
|
|
203
|
+
* and effects become one row, from `FOLD_AT` of them on, at the place of the first; every other subject keeps its row,
|
|
204
|
+
* so every widening and every line for closer review is in view without expanding anything.
|
|
205
|
+
*/
|
|
206
|
+
function fold(rows: readonly SubjectRow[]): ChangeRow[] {
|
|
207
|
+
const keys = new Map(rows.map((row) => [row, quietKey(row)]))
|
|
208
|
+
const families = new Map<string, SubjectRow[]>()
|
|
209
|
+
for (const [row, key] of keys) {
|
|
210
|
+
if (key === undefined) continue
|
|
211
|
+
const family = families.get(key)
|
|
212
|
+
if (family === undefined) families.set(key, [row])
|
|
213
|
+
else family.push(row)
|
|
214
|
+
}
|
|
215
|
+
const folded: ChangeRow[] = []
|
|
216
|
+
const placed = new Set<string>()
|
|
217
|
+
for (const row of rows) {
|
|
218
|
+
const key = keys.get(row)
|
|
219
|
+
const family = key === undefined ? [] : (families.get(key) ?? [])
|
|
220
|
+
if (key === undefined || family.length < FOLD_AT) folded.push(row)
|
|
221
|
+
else if (!placed.has(key)) {
|
|
222
|
+
placed.add(key)
|
|
223
|
+
folded.push({ kind: 'folded', rules: quietRules(row), subjects: family })
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
return folded
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
function quietRules(row: SubjectRow): { rule: string; effect: 'narrows' | 'neutral' }[] {
|
|
230
|
+
const rules = new Map<string, { rule: string; effect: 'narrows' | 'neutral' }>()
|
|
231
|
+
for (const change of row.changes) {
|
|
232
|
+
if (change.rule !== undefined && change.effect !== 'widens') {
|
|
233
|
+
rules.set(`${change.rule} ${change.effect}`, { rule: change.rule, effect: change.effect })
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
return [...rules.values()]
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
function quietKey(row: SubjectRow): string | undefined {
|
|
240
|
+
const quiet = row.changes.every((change) => change.effect !== 'widens' && change.review !== 'closer' && change.rule !== undefined)
|
|
241
|
+
return quiet ? quietRules(row).map(({ rule, effect }) => `${rule} ${effect}`).join('|') : undefined
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
function tallyOf(changes: readonly AccessChangeDto[]): EffectTally {
|
|
245
|
+
return {
|
|
246
|
+
widens: changes.filter((change) => change.effect === 'widens').length,
|
|
247
|
+
narrows: changes.filter((change) => change.effect === 'narrows').length,
|
|
248
|
+
neutral: changes.filter((change) => change.effect === 'neutral').length,
|
|
249
|
+
closer: changes.filter((change) => change.review === 'closer').length,
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
function rowRank(row: SubjectRow): number {
|
|
254
|
+
return Math.min(...row.changes.map(changeRank))
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
function reachIndex(entry: ChangeGroup): number {
|
|
258
|
+
return entry.kind === 'caller' ? SURFACE_REACHES.indexOf(entry.reach) : 0
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
function subjectIndex(entry: ChangeGroup): number {
|
|
262
|
+
return entry.kind === 'subject' ? CHANGE_SUBJECT_KINDS.indexOf(entry.subject) : 0
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
const compareText = (a: string, b: string): number => (a < b ? -1 : a > b ? 1 : 0)
|
package/src/index.ts
CHANGED
|
@@ -137,7 +137,7 @@ export interface GitHubSourceConnectionListResponse {
|
|
|
137
137
|
export interface GitHubSourceConnectionRepairRequiredDto extends GitHubSourceConnectionBaseDto {
|
|
138
138
|
readonly state: 'repair-required'
|
|
139
139
|
readonly connectionId: string
|
|
140
|
-
readonly reason: 'interrupted-setup' | 'credential-activation' | 'installation-verification'
|
|
140
|
+
readonly reason: 'interrupted-setup' | 'credential-activation' | 'installation-verification' | 'rate-limited'
|
|
141
141
|
readonly app?: GitHubSourceConnectionAppDto
|
|
142
142
|
}
|
|
143
143
|
|
|
@@ -502,19 +502,83 @@ export interface RunDto {
|
|
|
502
502
|
createdAt: number
|
|
503
503
|
startedAt: number | null
|
|
504
504
|
finishedAt: number | null
|
|
505
|
+
/** When someone asked to cancel the run; a run that finished with it set was cancelled, unless it succeeded first. */
|
|
506
|
+
cancelRequestedAt: number | null
|
|
507
|
+
}
|
|
508
|
+
|
|
509
|
+
/** What a change line is about (ADR-0050 §3). */
|
|
510
|
+
export const CHANGE_SUBJECT_KINDS = [
|
|
511
|
+
'application',
|
|
512
|
+
'endpoint',
|
|
513
|
+
'mount',
|
|
514
|
+
'dimension',
|
|
515
|
+
'action',
|
|
516
|
+
'role',
|
|
517
|
+
'table',
|
|
518
|
+
'file-collection',
|
|
519
|
+
'file-kind',
|
|
520
|
+
'job',
|
|
521
|
+
'export',
|
|
522
|
+
'import',
|
|
523
|
+
'token',
|
|
524
|
+
'csp',
|
|
525
|
+
'migration',
|
|
526
|
+
] as const
|
|
527
|
+
|
|
528
|
+
export type ChangeSubjectKind = (typeof CHANGE_SUBJECT_KINDS)[number]
|
|
529
|
+
|
|
530
|
+
export interface ChangeSubjectDto {
|
|
531
|
+
kind: ChangeSubjectKind
|
|
532
|
+
/** The endpoint id, the table, the role, the migration file, the CSP directive; the application's id for `application`. */
|
|
533
|
+
name: string
|
|
534
|
+
/** An endpoint's route: the candidate's row, or the baseline's for a removed endpoint. */
|
|
535
|
+
method?: EndpointMethod
|
|
536
|
+
path?: string
|
|
537
|
+
}
|
|
538
|
+
|
|
539
|
+
/** Who reaches an endpoint: the candidate's row, or the baseline's for a removed endpoint, in the surface's terms. */
|
|
540
|
+
export interface ChangeAudienceDto {
|
|
541
|
+
reach: SurfaceReach
|
|
542
|
+
/** The link mount whose share links reach it, for a `link` reach. */
|
|
543
|
+
mount?: string
|
|
544
|
+
/** What a caller must hold, as `SurfaceEndpointDto.requirement` words it; null for an anonymous kind. */
|
|
545
|
+
requirement: string | null
|
|
546
|
+
}
|
|
547
|
+
|
|
548
|
+
/**
|
|
549
|
+
* Why a line needs closer review: a step off the paved road, something anyone without signing in sets off, a mutation
|
|
550
|
+
* served on `GET`, people becoming visible, a file collection adopted or released, or the application naming who signs
|
|
551
|
+
* in at an enrolled terminal.
|
|
552
|
+
*/
|
|
553
|
+
export const REVIEW_REASONS = ['off-road', 'anyone-calls', 'get-mutation', 'people', 'adoption', 'terminal'] as const
|
|
554
|
+
|
|
555
|
+
export type ReviewReason = (typeof REVIEW_REASONS)[number]
|
|
556
|
+
|
|
557
|
+
/** What a call sets off, when the line says so. */
|
|
558
|
+
export interface ChangeConsequenceDto {
|
|
559
|
+
kind: 'starts-job'
|
|
560
|
+
job: string
|
|
505
561
|
}
|
|
506
562
|
|
|
507
563
|
/**
|
|
508
564
|
* One plain-language line of an access change. `effect` is `widens` when it can grant access the baseline did not,
|
|
509
565
|
* `narrows` when it can only take access away, and `neutral` when it admits no one new and takes nothing away.
|
|
510
|
-
* `review: 'closer'` marks a
|
|
566
|
+
* `review: 'closer'` marks a line the approver reads the code behind (a step off the paved road, a call anyone sets off,
|
|
567
|
+
* …), and `reason` says which. A line classified before lines carried facts has no `rule`, `subject` or `reason`.
|
|
511
568
|
*/
|
|
512
569
|
export interface AccessChangeDto {
|
|
513
570
|
effect: 'widens' | 'narrows' | 'neutral'
|
|
514
571
|
line: string
|
|
515
572
|
review?: 'closer'
|
|
573
|
+
reason?: ReviewReason
|
|
516
574
|
/** The line opens an endpoint to the pages on the origins the environment lists; `ApprovalDto.crossOrigins` names them. */
|
|
517
575
|
environmentOrigins?: true
|
|
576
|
+
/** The comparison that produced the line, a stable code (`endpoint.body-limit`); it never holds an application's name. */
|
|
577
|
+
rule?: string
|
|
578
|
+
subject?: ChangeSubjectDto
|
|
579
|
+
/** Who reaches the endpoint, on an endpoint subject. */
|
|
580
|
+
audience?: ChangeAudienceDto
|
|
581
|
+
consequence?: ChangeConsequenceDto
|
|
518
582
|
}
|
|
519
583
|
|
|
520
584
|
/** A run's access change against its environment's active snapshot (ADR-0050 §3). */
|
|
@@ -536,8 +600,23 @@ export interface ApprovalDto {
|
|
|
536
600
|
* empty when the environment lists none.
|
|
537
601
|
*/
|
|
538
602
|
crossOrigins?: string[]
|
|
539
|
-
/**
|
|
540
|
-
|
|
603
|
+
/**
|
|
604
|
+
* The candidate's endpoints the change names, as the environment page's surface words them: who reaches each, what it
|
|
605
|
+
* requires, and what else opens it or stands in front of it (another origin, a body limit, rate buckets, a challenge).
|
|
606
|
+
* A removed endpoint is not among them. Empty for a run that stored no snapshot, and on the approvals list.
|
|
607
|
+
*/
|
|
608
|
+
endpoints: SurfaceEndpointDto[]
|
|
609
|
+
/**
|
|
610
|
+
* The human who approved it, once one did. `holds` is false once the approval lapsed: an older run of the environment
|
|
611
|
+
* published another change first, the change still widens against it, and the run waits for a new approval (ADR-0050
|
|
612
|
+
* §2). A refusal or a cancellation of such a run drops the approval, so a decided run's approval always held.
|
|
613
|
+
*/
|
|
614
|
+
approval: { principalId: string; label: string; approvedAt: number; holds: boolean } | null
|
|
615
|
+
/**
|
|
616
|
+
* The newer run of the environment whose success stopped this one before it started: an older run never deploys over
|
|
617
|
+
* a newer one (ADR-0050 §6). Only on one approval read, of a run that failed without starting.
|
|
618
|
+
*/
|
|
619
|
+
supersededBy?: string
|
|
541
620
|
}
|
|
542
621
|
|
|
543
622
|
/** Approve or refuse one parked run. The digests are the ones the approver read; a reclassified run refuses them. */
|
|
@@ -573,6 +652,8 @@ export interface RunLogResponse {
|
|
|
573
652
|
status?: RunStatus
|
|
574
653
|
}
|
|
575
654
|
|
|
655
|
+
export { OPS_ROW_COUNT_CAP, type OpsContentView, type OpsView } from '@fabrika/auth-core'
|
|
656
|
+
export * from './approval-view.js'
|
|
576
657
|
export type {
|
|
577
658
|
AdoptNamespaceInput,
|
|
578
659
|
AppEnvironmentInput,
|
|
@@ -598,14 +679,19 @@ export type {
|
|
|
598
679
|
UpdateNamespaceInput,
|
|
599
680
|
} from './rpc.js'
|
|
600
681
|
export type {
|
|
682
|
+
DataBackupDto,
|
|
683
|
+
DataBackupScheduleDto,
|
|
684
|
+
DataBackupState,
|
|
601
685
|
DataOperationDto,
|
|
602
686
|
DataOperationKind,
|
|
603
687
|
DataOperationListInput,
|
|
604
688
|
DataOperationResolution,
|
|
605
689
|
DataOperationState,
|
|
606
690
|
DataOperationStep,
|
|
691
|
+
DataRehearsalOutcome,
|
|
607
692
|
MaintenanceMode,
|
|
608
693
|
RecoverDataOperationInput,
|
|
694
|
+
SetDataBackupScheduleInput,
|
|
609
695
|
StartDataOperationInput,
|
|
610
696
|
} from './rpc.js'
|
|
611
697
|
export { DATA_OPERATION_MAX_PAGE_SIZE, dataOperationListInputSchema, recoverDataOperationInputSchema, startDataOperationInputSchema } from './rpc.js'
|
package/src/rpc.ts
CHANGED
|
@@ -285,6 +285,12 @@ export interface ControlRpcContract {
|
|
|
285
285
|
content: RpcProcedure<AppEnvironmentInput, OpsContentView>
|
|
286
286
|
start: RpcProcedure<StartDataOperationInput, DataOperationDto>
|
|
287
287
|
recover: RpcProcedure<RecoverDataOperationInput, DataOperationDto>
|
|
288
|
+
/** Consistent backups (ADR-0070): listed and their schedule read under `data.read`, the schedule set under `data.manage`. */
|
|
289
|
+
backups: {
|
|
290
|
+
list: RpcProcedure<DataOperationListInput, CursorList<DataBackupDto>>
|
|
291
|
+
schedule: RpcProcedure<AppEnvironmentInput, DataBackupScheduleDto>
|
|
292
|
+
setSchedule: RpcProcedure<SetDataBackupScheduleInput, DataBackupScheduleDto>
|
|
293
|
+
}
|
|
288
294
|
}
|
|
289
295
|
}
|
|
290
296
|
|
|
@@ -311,9 +317,28 @@ export type DataOperationKind = 'maintenance' | 'backup' | 'migrate' | 'recovery
|
|
|
311
317
|
* Where an operation stands: `reconcile` reads the record and the object's published state (a recovery's first step),
|
|
312
318
|
* `restrict` publishes a generation in a restricting mode, `backup` and `verify` take and check a consistent backup,
|
|
313
319
|
* `deploy` runs the operation's own deploy, `migrate` runs the pending migrations, `resume` continues the interrupted
|
|
314
|
-
* operation from its recorded step, and `open` publishes the generation that opens the object.
|
|
320
|
+
* operation from its recorded step, and `open` publishes the generation that opens the object. A side restore (ADR-0070
|
|
321
|
+
* §9) also `list`s its clone with a deploy, `import`s the backup into it, `promote`s it (the clone `open`, the original
|
|
322
|
+
* `inspect`), `point`s ordinary traffic at it with a deploy, waits for it to `serve`, `rewind`s the original to the
|
|
323
|
+
* target time and `check`s the original's schema; `revert` points traffic back at the original with a deploy.
|
|
315
324
|
*/
|
|
316
|
-
export type DataOperationStep =
|
|
325
|
+
export type DataOperationStep =
|
|
326
|
+
| 'reconcile'
|
|
327
|
+
| 'restrict'
|
|
328
|
+
| 'backup'
|
|
329
|
+
| 'verify'
|
|
330
|
+
| 'deploy'
|
|
331
|
+
| 'migrate'
|
|
332
|
+
| 'resume'
|
|
333
|
+
| 'open'
|
|
334
|
+
| 'list'
|
|
335
|
+
| 'import'
|
|
336
|
+
| 'promote'
|
|
337
|
+
| 'point'
|
|
338
|
+
| 'serve'
|
|
339
|
+
| 'rewind'
|
|
340
|
+
| 'check'
|
|
341
|
+
| 'revert'
|
|
317
342
|
|
|
318
343
|
export type DataOperationState = 'running' | 'succeeded' | 'failed'
|
|
319
344
|
|
|
@@ -346,6 +371,8 @@ export interface DataOperationDto {
|
|
|
346
371
|
readonly recoversOperationId: string | null
|
|
347
372
|
/** A recovery's choice after its closed fence; `null` for every other kind. */
|
|
348
373
|
readonly resolution: DataOperationResolution | null
|
|
374
|
+
/** A `migrate` operation's deploy run; `null` for every other kind. */
|
|
375
|
+
readonly runId: string | null
|
|
349
376
|
}
|
|
350
377
|
|
|
351
378
|
export const DATA_OPERATION_MAX_PAGE_SIZE = 100
|
|
@@ -365,11 +392,12 @@ export type DataOperationListInput = z.infer<typeof dataOperationListInputSchema
|
|
|
365
392
|
|
|
366
393
|
/**
|
|
367
394
|
* An operation a person starts. A migration starts inside a deploy and a recovery has its own request, so neither is
|
|
368
|
-
* started here.
|
|
395
|
+
* started here. A restore names the time `at` (ISO 8601 with an offset) its environment's data is recovered as of.
|
|
369
396
|
*/
|
|
370
397
|
export const startDataOperationInputSchema = z.discriminatedUnion('kind', [
|
|
371
398
|
z.object({ appId: nonEmpty, env: nonEmpty, kind: z.literal('maintenance'), mode: maintenanceMode }).strict(),
|
|
372
399
|
z.object({ appId: nonEmpty, env: nonEmpty, kind: z.literal('backup') }).strict(),
|
|
400
|
+
z.object({ appId: nonEmpty, env: nonEmpty, kind: z.literal('restore'), at: z.string().datetime({ offset: true }) }).strict(),
|
|
373
401
|
])
|
|
374
402
|
|
|
375
403
|
export type StartDataOperationInput = z.infer<typeof startDataOperationInputSchema>
|
|
@@ -386,3 +414,57 @@ export const recoverDataOperationInputSchema = z.object({
|
|
|
386
414
|
}).strict()
|
|
387
415
|
|
|
388
416
|
export type RecoverDataOperationInput = z.infer<typeof recoverDataOperationInputSchema>
|
|
417
|
+
|
|
418
|
+
/** `succeeded` only once its rehearsal passed. */
|
|
419
|
+
export type DataBackupState = 'running' | 'succeeded' | 'failed'
|
|
420
|
+
|
|
421
|
+
export type DataRehearsalOutcome = 'pending' | 'passed' | 'failed'
|
|
422
|
+
|
|
423
|
+
/**
|
|
424
|
+
* One consistent backup as `data.read` shows it: identifiers, states, codes, sizes and timestamps. It carries no free
|
|
425
|
+
* text and no content; downloading a dump is `data.content.read`.
|
|
426
|
+
*/
|
|
427
|
+
export interface DataBackupDto {
|
|
428
|
+
/** The backup's record. */
|
|
429
|
+
readonly id: string
|
|
430
|
+
readonly appId: string
|
|
431
|
+
readonly env: string
|
|
432
|
+
/** The `backup` operation that took it. */
|
|
433
|
+
readonly operationId: string
|
|
434
|
+
/** The object it was taken from. */
|
|
435
|
+
readonly object: string
|
|
436
|
+
/** The dump's key in the bucket; a resumed backup whose dump started again carries the new one. */
|
|
437
|
+
readonly dumpId: string
|
|
438
|
+
/** Taken by a deploy's migration phase, not by the daily schedule. */
|
|
439
|
+
readonly preMigration: boolean
|
|
440
|
+
readonly state: DataBackupState
|
|
441
|
+
/** A code once it failed, never an error message. */
|
|
442
|
+
readonly errorCode: string | null
|
|
443
|
+
readonly createdAt: number
|
|
444
|
+
readonly finishedAt: number | null
|
|
445
|
+
/** The object's bookmark when the dump began. */
|
|
446
|
+
readonly bookmark: string | null
|
|
447
|
+
/** Set once the upload completed. */
|
|
448
|
+
readonly sizeBytes: number | null
|
|
449
|
+
readonly parts: number | null
|
|
450
|
+
/** How many tables the manifest lists. */
|
|
451
|
+
readonly tables: number | null
|
|
452
|
+
readonly rehearsal: DataRehearsalOutcome
|
|
453
|
+
/** The code the rehearsal failed with. */
|
|
454
|
+
readonly rehearsalCode: string | null
|
|
455
|
+
/** Past its 30-day retention: never offered for a restore. */
|
|
456
|
+
readonly expired: boolean
|
|
457
|
+
}
|
|
458
|
+
|
|
459
|
+
/** Whether the environment takes daily backups: on unless it opted out. Opting out leaves the pre-migration backup. */
|
|
460
|
+
export interface DataBackupScheduleDto {
|
|
461
|
+
readonly appId: string
|
|
462
|
+
readonly env: string
|
|
463
|
+
readonly daily: boolean
|
|
464
|
+
/** When it was last set; `null` while it keeps the default. */
|
|
465
|
+
readonly updatedAt: number | null
|
|
466
|
+
}
|
|
467
|
+
|
|
468
|
+
export interface SetDataBackupScheduleInput extends AppEnvironmentInput {
|
|
469
|
+
readonly daily: boolean
|
|
470
|
+
}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import { type AccessChangeDto, type ChangeAudienceDto, type ChangeSubjectDto, type ChangeSubjectKind, type SurfaceReach } from './index.js';
|
|
2
|
+
/** The endpoints of one caller group: everyone a reach admits, or the holders of one link mount's share links. */
|
|
3
|
+
export interface CallerGroup {
|
|
4
|
+
readonly kind: 'caller';
|
|
5
|
+
readonly key: string;
|
|
6
|
+
readonly reach: SurfaceReach;
|
|
7
|
+
readonly mount?: string;
|
|
8
|
+
}
|
|
9
|
+
/** The lines about one kind of subject other than an endpoint: tables, roles, migrations, the application. */
|
|
10
|
+
export interface SubjectGroup {
|
|
11
|
+
readonly kind: 'subject';
|
|
12
|
+
readonly key: string;
|
|
13
|
+
readonly subject: ChangeSubjectKind;
|
|
14
|
+
}
|
|
15
|
+
/** One subject and its lines, most important first. */
|
|
16
|
+
export interface SubjectRow {
|
|
17
|
+
readonly kind: 'subject';
|
|
18
|
+
readonly subject: ChangeSubjectDto;
|
|
19
|
+
readonly audience?: ChangeAudienceDto;
|
|
20
|
+
readonly changes: readonly AccessChangeDto[];
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Quiet subjects that changed alike: each has lines of exactly these rules and effects, and none of them widens or needs
|
|
24
|
+
* closer review (`rules` in order, as `rule` and `effect`).
|
|
25
|
+
*/
|
|
26
|
+
export interface FoldedRow {
|
|
27
|
+
readonly kind: 'folded';
|
|
28
|
+
readonly rules: readonly {
|
|
29
|
+
readonly rule: string;
|
|
30
|
+
readonly effect: 'narrows' | 'neutral';
|
|
31
|
+
}[];
|
|
32
|
+
readonly subjects: readonly SubjectRow[];
|
|
33
|
+
}
|
|
34
|
+
export type ChangeRow = SubjectRow | FoldedRow;
|
|
35
|
+
export interface EffectTally {
|
|
36
|
+
readonly widens: number;
|
|
37
|
+
readonly narrows: number;
|
|
38
|
+
readonly neutral: number;
|
|
39
|
+
readonly closer: number;
|
|
40
|
+
}
|
|
41
|
+
export type ChangeGroup = (CallerGroup | SubjectGroup) & {
|
|
42
|
+
readonly rows: readonly ChangeRow[];
|
|
43
|
+
/** How many subjects the group holds, folded ones included. */
|
|
44
|
+
readonly subjects: number;
|
|
45
|
+
readonly tally: EffectTally;
|
|
46
|
+
/** Whether the page collapses the group by default: only when it holds no widening line. */
|
|
47
|
+
readonly collapsed: boolean;
|
|
48
|
+
};
|
|
49
|
+
export interface ApprovalView {
|
|
50
|
+
/**
|
|
51
|
+
* Per caller group the endpoints that change, apart from the removed endpoints and mounts its paths reach (a removal
|
|
52
|
+
* that widens stands with whoever its paths reach now), and the migration files the change adds or edits.
|
|
53
|
+
*/
|
|
54
|
+
readonly impact: {
|
|
55
|
+
readonly callers: readonly {
|
|
56
|
+
readonly key: string;
|
|
57
|
+
readonly reach: SurfaceReach;
|
|
58
|
+
readonly mount?: string;
|
|
59
|
+
readonly endpoints: number;
|
|
60
|
+
readonly removedEndpoints: number;
|
|
61
|
+
readonly removedMounts: number;
|
|
62
|
+
}[];
|
|
63
|
+
readonly migrations: number;
|
|
64
|
+
};
|
|
65
|
+
readonly callers: readonly ChangeGroup[];
|
|
66
|
+
readonly data: readonly ChangeGroup[];
|
|
67
|
+
/** The lines of a run classified before lines carried facts, in their stored order. */
|
|
68
|
+
readonly unsorted: readonly AccessChangeDto[];
|
|
69
|
+
}
|
|
70
|
+
/** Quiet subjects that changed alike fold from this many on. */
|
|
71
|
+
export declare const FOLD_AT = 3;
|
|
72
|
+
/**
|
|
73
|
+
* A line's rank: a widening for closer review first, then a widening, a narrowing for closer review, a line that leaves
|
|
74
|
+
* access unchanged, a narrowing. Nothing else enters it, so it cannot disagree with the classification.
|
|
75
|
+
*/
|
|
76
|
+
export declare function changeRank(change: Pick<AccessChangeDto, 'effect' | 'review'>): number;
|
|
77
|
+
export declare function approvalView(changes: readonly AccessChangeDto[]): ApprovalView;
|
|
78
|
+
/** Every line a row holds. */
|
|
79
|
+
export declare function rowChanges(row: ChangeRow): readonly AccessChangeDto[];
|
|
@@ -41,23 +41,23 @@ export declare const builderConnectionAppSchema: z.ZodEffects<z.ZodObject<{
|
|
|
41
41
|
createdAt: z.ZodNumber;
|
|
42
42
|
}, "strict", z.ZodTypeAny, {
|
|
43
43
|
id: string;
|
|
44
|
+
createdAt: number;
|
|
44
45
|
repoUrl: string;
|
|
45
46
|
defaultBranch: string;
|
|
46
47
|
workerDir: string | null;
|
|
47
48
|
buildCmd: string | null;
|
|
48
49
|
configPath: string | null;
|
|
49
50
|
githubInstallationId: number | null;
|
|
50
|
-
createdAt: number;
|
|
51
51
|
githubConnectionId?: string | null | undefined;
|
|
52
52
|
}, {
|
|
53
53
|
id: string;
|
|
54
|
+
createdAt: number;
|
|
54
55
|
repoUrl: string;
|
|
55
56
|
defaultBranch: string;
|
|
56
57
|
workerDir: string | null;
|
|
57
58
|
buildCmd: string | null;
|
|
58
59
|
configPath: string | null;
|
|
59
60
|
githubInstallationId: number | null;
|
|
60
|
-
createdAt: number;
|
|
61
61
|
githubConnectionId?: string | null | undefined;
|
|
62
62
|
}>, {
|
|
63
63
|
githubInstallationId: number | null;
|
|
@@ -71,13 +71,13 @@ export declare const builderConnectionAppSchema: z.ZodEffects<z.ZodObject<{
|
|
|
71
71
|
configPath: string | null;
|
|
72
72
|
}, {
|
|
73
73
|
id: string;
|
|
74
|
+
createdAt: number;
|
|
74
75
|
repoUrl: string;
|
|
75
76
|
defaultBranch: string;
|
|
76
77
|
workerDir: string | null;
|
|
77
78
|
buildCmd: string | null;
|
|
78
79
|
configPath: string | null;
|
|
79
80
|
githubInstallationId: number | null;
|
|
80
|
-
createdAt: number;
|
|
81
81
|
githubConnectionId?: string | null | undefined;
|
|
82
82
|
}>;
|
|
83
83
|
export declare const builderConnectionEnvironmentSchema: z.ZodObject<{
|
|
@@ -88,16 +88,16 @@ export declare const builderConnectionEnvironmentSchema: z.ZodObject<{
|
|
|
88
88
|
triggerRef: z.ZodNullable<z.ZodString>;
|
|
89
89
|
}, "strict", z.ZodTypeAny, {
|
|
90
90
|
env: string;
|
|
91
|
+
namespaceId: string | null;
|
|
91
92
|
domain: string | null;
|
|
92
93
|
publicOrigin: string | null;
|
|
93
94
|
triggerRef: string | null;
|
|
94
|
-
namespaceId: string | null;
|
|
95
95
|
}, {
|
|
96
96
|
env: string;
|
|
97
|
+
namespaceId: string | null;
|
|
97
98
|
domain: string | null;
|
|
98
99
|
publicOrigin: string | null;
|
|
99
100
|
triggerRef: string | null;
|
|
100
|
-
namespaceId: string | null;
|
|
101
101
|
}>;
|
|
102
102
|
export declare const builderConnectionReceiptSchema: z.ZodObject<{
|
|
103
103
|
version: z.ZodLiteral<1>;
|
|
@@ -115,23 +115,23 @@ export declare const builderConnectionReceiptSchema: z.ZodObject<{
|
|
|
115
115
|
createdAt: z.ZodNumber;
|
|
116
116
|
}, "strict", z.ZodTypeAny, {
|
|
117
117
|
id: string;
|
|
118
|
+
createdAt: number;
|
|
118
119
|
repoUrl: string;
|
|
119
120
|
defaultBranch: string;
|
|
120
121
|
workerDir: string | null;
|
|
121
122
|
buildCmd: string | null;
|
|
122
123
|
configPath: string | null;
|
|
123
124
|
githubInstallationId: number | null;
|
|
124
|
-
createdAt: number;
|
|
125
125
|
githubConnectionId?: string | null | undefined;
|
|
126
126
|
}, {
|
|
127
127
|
id: string;
|
|
128
|
+
createdAt: number;
|
|
128
129
|
repoUrl: string;
|
|
129
130
|
defaultBranch: string;
|
|
130
131
|
workerDir: string | null;
|
|
131
132
|
buildCmd: string | null;
|
|
132
133
|
configPath: string | null;
|
|
133
134
|
githubInstallationId: number | null;
|
|
134
|
-
createdAt: number;
|
|
135
135
|
githubConnectionId?: string | null | undefined;
|
|
136
136
|
}>, {
|
|
137
137
|
githubInstallationId: number | null;
|
|
@@ -145,13 +145,13 @@ export declare const builderConnectionReceiptSchema: z.ZodObject<{
|
|
|
145
145
|
configPath: string | null;
|
|
146
146
|
}, {
|
|
147
147
|
id: string;
|
|
148
|
+
createdAt: number;
|
|
148
149
|
repoUrl: string;
|
|
149
150
|
defaultBranch: string;
|
|
150
151
|
workerDir: string | null;
|
|
151
152
|
buildCmd: string | null;
|
|
152
153
|
configPath: string | null;
|
|
153
154
|
githubInstallationId: number | null;
|
|
154
|
-
createdAt: number;
|
|
155
155
|
githubConnectionId?: string | null | undefined;
|
|
156
156
|
}>;
|
|
157
157
|
environment: z.ZodObject<{
|
|
@@ -162,16 +162,16 @@ export declare const builderConnectionReceiptSchema: z.ZodObject<{
|
|
|
162
162
|
triggerRef: z.ZodNullable<z.ZodString>;
|
|
163
163
|
}, "strict", z.ZodTypeAny, {
|
|
164
164
|
env: string;
|
|
165
|
+
namespaceId: string | null;
|
|
165
166
|
domain: string | null;
|
|
166
167
|
publicOrigin: string | null;
|
|
167
168
|
triggerRef: string | null;
|
|
168
|
-
namespaceId: string | null;
|
|
169
169
|
}, {
|
|
170
170
|
env: string;
|
|
171
|
+
namespaceId: string | null;
|
|
171
172
|
domain: string | null;
|
|
172
173
|
publicOrigin: string | null;
|
|
173
174
|
triggerRef: string | null;
|
|
174
|
-
namespaceId: string | null;
|
|
175
175
|
}>;
|
|
176
176
|
createdAt: z.ZodNumber;
|
|
177
177
|
}, "strict", z.ZodTypeAny, {
|
|
@@ -188,36 +188,36 @@ export declare const builderConnectionReceiptSchema: z.ZodObject<{
|
|
|
188
188
|
};
|
|
189
189
|
environment: {
|
|
190
190
|
env: string;
|
|
191
|
+
namespaceId: string | null;
|
|
191
192
|
domain: string | null;
|
|
192
193
|
publicOrigin: string | null;
|
|
193
194
|
triggerRef: string | null;
|
|
194
|
-
namespaceId: string | null;
|
|
195
195
|
};
|
|
196
196
|
attemptId: string;
|
|
197
197
|
version: 1;
|
|
198
|
-
provider: string;
|
|
199
198
|
createdAt: number;
|
|
199
|
+
provider: string;
|
|
200
200
|
}, {
|
|
201
201
|
app: {
|
|
202
202
|
id: string;
|
|
203
|
+
createdAt: number;
|
|
203
204
|
repoUrl: string;
|
|
204
205
|
defaultBranch: string;
|
|
205
206
|
workerDir: string | null;
|
|
206
207
|
buildCmd: string | null;
|
|
207
208
|
configPath: string | null;
|
|
208
209
|
githubInstallationId: number | null;
|
|
209
|
-
createdAt: number;
|
|
210
210
|
githubConnectionId?: string | null | undefined;
|
|
211
211
|
};
|
|
212
212
|
environment: {
|
|
213
213
|
env: string;
|
|
214
|
+
namespaceId: string | null;
|
|
214
215
|
domain: string | null;
|
|
215
216
|
publicOrigin: string | null;
|
|
216
217
|
triggerRef: string | null;
|
|
217
|
-
namespaceId: string | null;
|
|
218
218
|
};
|
|
219
219
|
attemptId: string;
|
|
220
220
|
version: 1;
|
|
221
|
-
provider: string;
|
|
222
221
|
createdAt: number;
|
|
222
|
+
provider: string;
|
|
223
223
|
}>;
|
package/types/src/index.d.ts
CHANGED
|
@@ -116,7 +116,7 @@ export interface GitHubSourceConnectionListResponse {
|
|
|
116
116
|
export interface GitHubSourceConnectionRepairRequiredDto extends GitHubSourceConnectionBaseDto {
|
|
117
117
|
readonly state: 'repair-required';
|
|
118
118
|
readonly connectionId: string;
|
|
119
|
-
readonly reason: 'interrupted-setup' | 'credential-activation' | 'installation-verification';
|
|
119
|
+
readonly reason: 'interrupted-setup' | 'credential-activation' | 'installation-verification' | 'rate-limited';
|
|
120
120
|
readonly app?: GitHubSourceConnectionAppDto;
|
|
121
121
|
}
|
|
122
122
|
/** Browser-safe setup state. It never carries a private key, webhook secret, token, or source RPC key. */
|
|
@@ -438,18 +438,59 @@ export interface RunDto {
|
|
|
438
438
|
createdAt: number;
|
|
439
439
|
startedAt: number | null;
|
|
440
440
|
finishedAt: number | null;
|
|
441
|
+
/** When someone asked to cancel the run; a run that finished with it set was cancelled, unless it succeeded first. */
|
|
442
|
+
cancelRequestedAt: number | null;
|
|
443
|
+
}
|
|
444
|
+
/** What a change line is about (ADR-0050 §3). */
|
|
445
|
+
export declare const CHANGE_SUBJECT_KINDS: readonly ["application", "endpoint", "mount", "dimension", "action", "role", "table", "file-collection", "file-kind", "job", "export", "import", "token", "csp", "migration"];
|
|
446
|
+
export type ChangeSubjectKind = (typeof CHANGE_SUBJECT_KINDS)[number];
|
|
447
|
+
export interface ChangeSubjectDto {
|
|
448
|
+
kind: ChangeSubjectKind;
|
|
449
|
+
/** The endpoint id, the table, the role, the migration file, the CSP directive; the application's id for `application`. */
|
|
450
|
+
name: string;
|
|
451
|
+
/** An endpoint's route: the candidate's row, or the baseline's for a removed endpoint. */
|
|
452
|
+
method?: EndpointMethod;
|
|
453
|
+
path?: string;
|
|
454
|
+
}
|
|
455
|
+
/** Who reaches an endpoint: the candidate's row, or the baseline's for a removed endpoint, in the surface's terms. */
|
|
456
|
+
export interface ChangeAudienceDto {
|
|
457
|
+
reach: SurfaceReach;
|
|
458
|
+
/** The link mount whose share links reach it, for a `link` reach. */
|
|
459
|
+
mount?: string;
|
|
460
|
+
/** What a caller must hold, as `SurfaceEndpointDto.requirement` words it; null for an anonymous kind. */
|
|
461
|
+
requirement: string | null;
|
|
462
|
+
}
|
|
463
|
+
/**
|
|
464
|
+
* Why a line needs closer review: a step off the paved road, something anyone without signing in sets off, a mutation
|
|
465
|
+
* served on `GET`, people becoming visible, a file collection adopted or released, or the application naming who signs
|
|
466
|
+
* in at an enrolled terminal.
|
|
467
|
+
*/
|
|
468
|
+
export declare const REVIEW_REASONS: readonly ["off-road", "anyone-calls", "get-mutation", "people", "adoption", "terminal"];
|
|
469
|
+
export type ReviewReason = (typeof REVIEW_REASONS)[number];
|
|
470
|
+
/** What a call sets off, when the line says so. */
|
|
471
|
+
export interface ChangeConsequenceDto {
|
|
472
|
+
kind: 'starts-job';
|
|
473
|
+
job: string;
|
|
441
474
|
}
|
|
442
475
|
/**
|
|
443
476
|
* One plain-language line of an access change. `effect` is `widens` when it can grant access the baseline did not,
|
|
444
477
|
* `narrows` when it can only take access away, and `neutral` when it admits no one new and takes nothing away.
|
|
445
|
-
* `review: 'closer'` marks a
|
|
478
|
+
* `review: 'closer'` marks a line the approver reads the code behind (a step off the paved road, a call anyone sets off,
|
|
479
|
+
* …), and `reason` says which. A line classified before lines carried facts has no `rule`, `subject` or `reason`.
|
|
446
480
|
*/
|
|
447
481
|
export interface AccessChangeDto {
|
|
448
482
|
effect: 'widens' | 'narrows' | 'neutral';
|
|
449
483
|
line: string;
|
|
450
484
|
review?: 'closer';
|
|
485
|
+
reason?: ReviewReason;
|
|
451
486
|
/** The line opens an endpoint to the pages on the origins the environment lists; `ApprovalDto.crossOrigins` names them. */
|
|
452
487
|
environmentOrigins?: true;
|
|
488
|
+
/** The comparison that produced the line, a stable code (`endpoint.body-limit`); it never holds an application's name. */
|
|
489
|
+
rule?: string;
|
|
490
|
+
subject?: ChangeSubjectDto;
|
|
491
|
+
/** Who reaches the endpoint, on an endpoint subject. */
|
|
492
|
+
audience?: ChangeAudienceDto;
|
|
493
|
+
consequence?: ChangeConsequenceDto;
|
|
453
494
|
}
|
|
454
495
|
/** A run's access change against its environment's active snapshot (ADR-0050 §3). */
|
|
455
496
|
export interface ApprovalDto {
|
|
@@ -470,12 +511,28 @@ export interface ApprovalDto {
|
|
|
470
511
|
* empty when the environment lists none.
|
|
471
512
|
*/
|
|
472
513
|
crossOrigins?: string[];
|
|
473
|
-
/**
|
|
514
|
+
/**
|
|
515
|
+
* The candidate's endpoints the change names, as the environment page's surface words them: who reaches each, what it
|
|
516
|
+
* requires, and what else opens it or stands in front of it (another origin, a body limit, rate buckets, a challenge).
|
|
517
|
+
* A removed endpoint is not among them. Empty for a run that stored no snapshot, and on the approvals list.
|
|
518
|
+
*/
|
|
519
|
+
endpoints: SurfaceEndpointDto[];
|
|
520
|
+
/**
|
|
521
|
+
* The human who approved it, once one did. `holds` is false once the approval lapsed: an older run of the environment
|
|
522
|
+
* published another change first, the change still widens against it, and the run waits for a new approval (ADR-0050
|
|
523
|
+
* §2). A refusal or a cancellation of such a run drops the approval, so a decided run's approval always held.
|
|
524
|
+
*/
|
|
474
525
|
approval: {
|
|
475
526
|
principalId: string;
|
|
476
527
|
label: string;
|
|
477
528
|
approvedAt: number;
|
|
529
|
+
holds: boolean;
|
|
478
530
|
} | null;
|
|
531
|
+
/**
|
|
532
|
+
* The newer run of the environment whose success stopped this one before it started: an older run never deploys over
|
|
533
|
+
* a newer one (ADR-0050 §6). Only on one approval read, of a run that failed without starting.
|
|
534
|
+
*/
|
|
535
|
+
supersededBy?: string;
|
|
479
536
|
}
|
|
480
537
|
/** Approve or refuse one parked run. The digests are the ones the approver read; a reclassified run refuses them. */
|
|
481
538
|
export interface CompleteApprovalRequest {
|
|
@@ -505,6 +562,8 @@ export interface RunLogResponse {
|
|
|
505
562
|
lines: RunLogLine[];
|
|
506
563
|
status?: RunStatus;
|
|
507
564
|
}
|
|
565
|
+
export { OPS_ROW_COUNT_CAP, type OpsContentView, type OpsView } from '@fabrika/auth-core';
|
|
566
|
+
export * from './approval-view.js';
|
|
508
567
|
export type { AdoptNamespaceInput, AppEnvironmentInput, AppIdInput, AppNamedValueInput, ControlRpcContract, CreateAppRequest, DescribeConnectorRequest, GitHubSourceConnectionInput, GitHubSourceConnectionRpcContract, NamespaceIdInput, OkResponse, PutAppEnvironmentInput, PutAppSecretInput, PutAppVarInput, ReleaseNamespaceClaimsInput, RotateTokenKeyResponse, RunIdInput, RunListInput, SecretValueInput, SecretValueResponse, TailRunInput, UpdateNamespaceInput, } from './rpc.js';
|
|
509
|
-
export type { DataOperationDto, DataOperationKind, DataOperationListInput, DataOperationResolution, DataOperationState, DataOperationStep, MaintenanceMode, RecoverDataOperationInput, StartDataOperationInput, } from './rpc.js';
|
|
568
|
+
export type { DataBackupDto, DataBackupScheduleDto, DataBackupState, DataOperationDto, DataOperationKind, DataOperationListInput, DataOperationResolution, DataOperationState, DataOperationStep, DataRehearsalOutcome, MaintenanceMode, RecoverDataOperationInput, SetDataBackupScheduleInput, StartDataOperationInput, } from './rpc.js';
|
|
510
569
|
export { DATA_OPERATION_MAX_PAGE_SIZE, dataOperationListInputSchema, recoverDataOperationInputSchema, startDataOperationInputSchema } from './rpc.js';
|
package/types/src/rpc.d.ts
CHANGED
|
@@ -212,6 +212,12 @@ export interface ControlRpcContract {
|
|
|
212
212
|
content: RpcProcedure<AppEnvironmentInput, OpsContentView>;
|
|
213
213
|
start: RpcProcedure<StartDataOperationInput, DataOperationDto>;
|
|
214
214
|
recover: RpcProcedure<RecoverDataOperationInput, DataOperationDto>;
|
|
215
|
+
/** Consistent backups (ADR-0070): listed and their schedule read under `data.read`, the schedule set under `data.manage`. */
|
|
216
|
+
backups: {
|
|
217
|
+
list: RpcProcedure<DataOperationListInput, CursorList<DataBackupDto>>;
|
|
218
|
+
schedule: RpcProcedure<AppEnvironmentInput, DataBackupScheduleDto>;
|
|
219
|
+
setSchedule: RpcProcedure<SetDataBackupScheduleInput, DataBackupScheduleDto>;
|
|
220
|
+
};
|
|
215
221
|
};
|
|
216
222
|
}
|
|
217
223
|
/**
|
|
@@ -232,9 +238,12 @@ export type DataOperationKind = 'maintenance' | 'backup' | 'migrate' | 'recovery
|
|
|
232
238
|
* Where an operation stands: `reconcile` reads the record and the object's published state (a recovery's first step),
|
|
233
239
|
* `restrict` publishes a generation in a restricting mode, `backup` and `verify` take and check a consistent backup,
|
|
234
240
|
* `deploy` runs the operation's own deploy, `migrate` runs the pending migrations, `resume` continues the interrupted
|
|
235
|
-
* operation from its recorded step, and `open` publishes the generation that opens the object.
|
|
241
|
+
* operation from its recorded step, and `open` publishes the generation that opens the object. A side restore (ADR-0070
|
|
242
|
+
* §9) also `list`s its clone with a deploy, `import`s the backup into it, `promote`s it (the clone `open`, the original
|
|
243
|
+
* `inspect`), `point`s ordinary traffic at it with a deploy, waits for it to `serve`, `rewind`s the original to the
|
|
244
|
+
* target time and `check`s the original's schema; `revert` points traffic back at the original with a deploy.
|
|
236
245
|
*/
|
|
237
|
-
export type DataOperationStep = 'reconcile' | 'restrict' | 'backup' | 'verify' | 'deploy' | 'migrate' | 'resume' | 'open';
|
|
246
|
+
export type DataOperationStep = 'reconcile' | 'restrict' | 'backup' | 'verify' | 'deploy' | 'migrate' | 'resume' | 'open' | 'list' | 'import' | 'promote' | 'point' | 'serve' | 'rewind' | 'check' | 'revert';
|
|
238
247
|
export type DataOperationState = 'running' | 'succeeded' | 'failed';
|
|
239
248
|
/** What a recovery does after its closed fence: resume the interrupted operation, or open the object. */
|
|
240
249
|
export type DataOperationResolution = 'resume' | 'open';
|
|
@@ -264,6 +273,8 @@ export interface DataOperationDto {
|
|
|
264
273
|
readonly recoversOperationId: string | null;
|
|
265
274
|
/** A recovery's choice after its closed fence; `null` for every other kind. */
|
|
266
275
|
readonly resolution: DataOperationResolution | null;
|
|
276
|
+
/** A `migrate` operation's deploy run; `null` for every other kind. */
|
|
277
|
+
readonly runId: string | null;
|
|
267
278
|
}
|
|
268
279
|
export declare const DATA_OPERATION_MAX_PAGE_SIZE = 100;
|
|
269
280
|
/** One environment's operations, newest first; `before` is the last id of the previous page. */
|
|
@@ -286,7 +297,7 @@ export declare const dataOperationListInputSchema: z.ZodObject<{
|
|
|
286
297
|
export type DataOperationListInput = z.infer<typeof dataOperationListInputSchema>;
|
|
287
298
|
/**
|
|
288
299
|
* An operation a person starts. A migration starts inside a deploy and a recovery has its own request, so neither is
|
|
289
|
-
* started here.
|
|
300
|
+
* started here. A restore names the time `at` (ISO 8601 with an offset) its environment's data is recovered as of.
|
|
290
301
|
*/
|
|
291
302
|
export declare const startDataOperationInputSchema: z.ZodDiscriminatedUnion<"kind", [z.ZodObject<{
|
|
292
303
|
appId: z.ZodString;
|
|
@@ -315,6 +326,21 @@ export declare const startDataOperationInputSchema: z.ZodDiscriminatedUnion<"kin
|
|
|
315
326
|
env: string;
|
|
316
327
|
kind: "backup";
|
|
317
328
|
appId: string;
|
|
329
|
+
}>, z.ZodObject<{
|
|
330
|
+
appId: z.ZodString;
|
|
331
|
+
env: z.ZodString;
|
|
332
|
+
kind: z.ZodLiteral<"restore">;
|
|
333
|
+
at: z.ZodString;
|
|
334
|
+
}, "strict", z.ZodTypeAny, {
|
|
335
|
+
env: string;
|
|
336
|
+
at: string;
|
|
337
|
+
kind: "restore";
|
|
338
|
+
appId: string;
|
|
339
|
+
}, {
|
|
340
|
+
env: string;
|
|
341
|
+
at: string;
|
|
342
|
+
kind: "restore";
|
|
343
|
+
appId: string;
|
|
318
344
|
}>]>;
|
|
319
345
|
export type StartDataOperationInput = z.infer<typeof startDataOperationInputSchema>;
|
|
320
346
|
/**
|
|
@@ -338,4 +364,53 @@ export declare const recoverDataOperationInputSchema: z.ZodObject<{
|
|
|
338
364
|
resolution: "open" | "resume";
|
|
339
365
|
}>;
|
|
340
366
|
export type RecoverDataOperationInput = z.infer<typeof recoverDataOperationInputSchema>;
|
|
367
|
+
/** `succeeded` only once its rehearsal passed. */
|
|
368
|
+
export type DataBackupState = 'running' | 'succeeded' | 'failed';
|
|
369
|
+
export type DataRehearsalOutcome = 'pending' | 'passed' | 'failed';
|
|
370
|
+
/**
|
|
371
|
+
* One consistent backup as `data.read` shows it: identifiers, states, codes, sizes and timestamps. It carries no free
|
|
372
|
+
* text and no content; downloading a dump is `data.content.read`.
|
|
373
|
+
*/
|
|
374
|
+
export interface DataBackupDto {
|
|
375
|
+
/** The backup's record. */
|
|
376
|
+
readonly id: string;
|
|
377
|
+
readonly appId: string;
|
|
378
|
+
readonly env: string;
|
|
379
|
+
/** The `backup` operation that took it. */
|
|
380
|
+
readonly operationId: string;
|
|
381
|
+
/** The object it was taken from. */
|
|
382
|
+
readonly object: string;
|
|
383
|
+
/** The dump's key in the bucket; a resumed backup whose dump started again carries the new one. */
|
|
384
|
+
readonly dumpId: string;
|
|
385
|
+
/** Taken by a deploy's migration phase, not by the daily schedule. */
|
|
386
|
+
readonly preMigration: boolean;
|
|
387
|
+
readonly state: DataBackupState;
|
|
388
|
+
/** A code once it failed, never an error message. */
|
|
389
|
+
readonly errorCode: string | null;
|
|
390
|
+
readonly createdAt: number;
|
|
391
|
+
readonly finishedAt: number | null;
|
|
392
|
+
/** The object's bookmark when the dump began. */
|
|
393
|
+
readonly bookmark: string | null;
|
|
394
|
+
/** Set once the upload completed. */
|
|
395
|
+
readonly sizeBytes: number | null;
|
|
396
|
+
readonly parts: number | null;
|
|
397
|
+
/** How many tables the manifest lists. */
|
|
398
|
+
readonly tables: number | null;
|
|
399
|
+
readonly rehearsal: DataRehearsalOutcome;
|
|
400
|
+
/** The code the rehearsal failed with. */
|
|
401
|
+
readonly rehearsalCode: string | null;
|
|
402
|
+
/** Past its 30-day retention: never offered for a restore. */
|
|
403
|
+
readonly expired: boolean;
|
|
404
|
+
}
|
|
405
|
+
/** Whether the environment takes daily backups: on unless it opted out. Opting out leaves the pre-migration backup. */
|
|
406
|
+
export interface DataBackupScheduleDto {
|
|
407
|
+
readonly appId: string;
|
|
408
|
+
readonly env: string;
|
|
409
|
+
readonly daily: boolean;
|
|
410
|
+
/** When it was last set; `null` while it keeps the default. */
|
|
411
|
+
readonly updatedAt: number | null;
|
|
412
|
+
}
|
|
413
|
+
export interface SetDataBackupScheduleInput extends AppEnvironmentInput {
|
|
414
|
+
readonly daily: boolean;
|
|
415
|
+
}
|
|
341
416
|
export {};
|