@fabrika/control-contract 0.9.0-dev.3 → 0.9.0-dev.31
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 +5 -5
- package/src/access.ts +12 -0
- package/src/approval-view.ts +335 -0
- package/src/index.ts +273 -6
- package/src/mail.ts +2 -0
- package/src/rpc.ts +212 -1
- package/types/src/access.d.ts +12 -0
- package/types/src/approval-view.d.ts +111 -0
- package/types/src/builder-connections.d.ts +15 -15
- package/types/src/index.d.ts +226 -8
- package/types/src/mail.d.ts +2 -0
- package/types/src/rpc.d.ts +227 -2
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 {
|
|
@@ -137,7 +142,7 @@ export interface GitHubSourceConnectionListResponse {
|
|
|
137
142
|
export interface GitHubSourceConnectionRepairRequiredDto extends GitHubSourceConnectionBaseDto {
|
|
138
143
|
readonly state: 'repair-required'
|
|
139
144
|
readonly connectionId: string
|
|
140
|
-
readonly reason: 'interrupted-setup' | 'credential-activation' | 'installation-verification'
|
|
145
|
+
readonly reason: 'interrupted-setup' | 'credential-activation' | 'installation-verification' | 'rate-limited'
|
|
141
146
|
readonly app?: GitHubSourceConnectionAppDto
|
|
142
147
|
}
|
|
143
148
|
|
|
@@ -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(),
|
|
@@ -237,6 +271,11 @@ export interface AppEnvDto {
|
|
|
237
271
|
deviationSubjects: DeviationSubjectDto[]
|
|
238
272
|
/** The published snapshot's endpoints as the outside reaches them, most exposed first; empty until a run publishes one. */
|
|
239
273
|
surface: SurfaceEndpointDto[]
|
|
274
|
+
/**
|
|
275
|
+
* The published snapshot's roles and what each action of theirs reaches; empty until a run publishes one. Absent from
|
|
276
|
+
* a Control released before it.
|
|
277
|
+
*/
|
|
278
|
+
accessMap?: AccessMapDto
|
|
240
279
|
namespaceId: string | null
|
|
241
280
|
provider: string
|
|
242
281
|
target: ProviderEnvelopeDto
|
|
@@ -244,6 +283,62 @@ export interface AppEnvDto {
|
|
|
244
283
|
createdAt: number
|
|
245
284
|
}
|
|
246
285
|
|
|
286
|
+
/**
|
|
287
|
+
* A contract's access read by role: each role and the actions it holds, and, once per action, the endpoints that require
|
|
288
|
+
* it and the tables it reaches. Actions are listed once, so a large contract does not repeat its endpoints per role.
|
|
289
|
+
*/
|
|
290
|
+
export interface AccessMapDto {
|
|
291
|
+
roles: AccessMapRoleDto[]
|
|
292
|
+
/** Every action a role holds, by name, in name order. */
|
|
293
|
+
actions: AccessMapActionDto[]
|
|
294
|
+
/** The endpoints any member reaches, whatever role it holds, by path. */
|
|
295
|
+
memberEndpoints: AccessMapEndpointDto[]
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
export interface AccessMapRoleDto {
|
|
299
|
+
role: string
|
|
300
|
+
/** The dimension a membership role is granted in; null for an application-wide role, granted globally. */
|
|
301
|
+
scope: string | null
|
|
302
|
+
/** The roles whose holders assign it in a value of `scope`; empty for an application-wide role. */
|
|
303
|
+
assignableBy: string[]
|
|
304
|
+
/** The dimensions whose new values grant it to their creator, in name order. */
|
|
305
|
+
creatorOf: string[]
|
|
306
|
+
/** An external principal may hold it (ADR-0051). */
|
|
307
|
+
external: boolean
|
|
308
|
+
/** The actions it grants, in name order. */
|
|
309
|
+
actions: string[]
|
|
310
|
+
/** The actions its holder holds at each node a row of the relation names them at, by relation, in name order. */
|
|
311
|
+
via: { relation: string; dimension: string; actions: string[]; conferredBy: string[] }[]
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
/** An endpoint a role's holder may call: `access` says where its action must be held (`on deal`, `app-wide`). */
|
|
315
|
+
export interface AccessMapEndpointDto {
|
|
316
|
+
id: string
|
|
317
|
+
method: EndpointMethod
|
|
318
|
+
path: string
|
|
319
|
+
access: string
|
|
320
|
+
/** The callers among role holders: `human` (a person), `machine` (a script's key). */
|
|
321
|
+
callers: string[]
|
|
322
|
+
}
|
|
323
|
+
|
|
324
|
+
export interface AccessMapActionDto {
|
|
325
|
+
action: string
|
|
326
|
+
description: string
|
|
327
|
+
/** The endpoints whose requirement names it and that a person or a script calls, by path. */
|
|
328
|
+
endpoints: AccessMapEndpointDto[]
|
|
329
|
+
/** What it does to people: `manage the members of each org`, `list the application's members`. */
|
|
330
|
+
members: string[]
|
|
331
|
+
/** The share links it issues: `issue share links of shared to a note, which grant notes.read`. */
|
|
332
|
+
links: string[]
|
|
333
|
+
/**
|
|
334
|
+
* The tables it reaches, by name: what it does there, where their rows lie (in org, app-wide), and `also` the other
|
|
335
|
+
* paths it reaches them through or that their rows open (a path column, a reveal, an access view, a condition).
|
|
336
|
+
*/
|
|
337
|
+
tables: { table: string; lies: string; operations: string[]; also: string[] }[]
|
|
338
|
+
/** The stored files it reads, uploads or deletes: `read, upload the files of attachments (rows of notes)`. */
|
|
339
|
+
files: string[]
|
|
340
|
+
}
|
|
341
|
+
|
|
247
342
|
/** One endpoint, job or migration of a published snapshot and its steps off the paved road. */
|
|
248
343
|
export interface DeviationSubjectDto {
|
|
249
344
|
/** `Endpoint \`id\``, `Job \`name\`` or `Migration \`file\``. */
|
|
@@ -271,6 +366,43 @@ export interface SurfaceEndpointDto {
|
|
|
271
366
|
requirement: string | null
|
|
272
367
|
/** What else opens the endpoint: another origin, a file it answers, a body limit, a form's protection, a signature. */
|
|
273
368
|
notes: string[]
|
|
369
|
+
/**
|
|
370
|
+
* The same notes, in the same order, each with what it is about. Beside `notes`, never instead of it: a builder
|
|
371
|
+
* daemon of an older release reads `notes` as text and drops a field it does not know. Absent from a Control
|
|
372
|
+
* released before it.
|
|
373
|
+
*/
|
|
374
|
+
noteFacts?: SurfaceNoteDto[]
|
|
375
|
+
}
|
|
376
|
+
|
|
377
|
+
/**
|
|
378
|
+
* What a surface note is about: an opaque root it takes, another origin it is callable from, a file it answers or
|
|
379
|
+
* takes, an upload's body limit, a form's protection, a procedure's buckets and challenge (`guards`), how long it waits
|
|
380
|
+
* for a body of what size and how long it runs (`limits`), a webhook's signature. A line that already says one
|
|
381
|
+
* (`AccessChangeDto.states`) lets the approval page leave that note out of the line's row.
|
|
382
|
+
*/
|
|
383
|
+
export const SURFACE_NOTE_TOPICS = [
|
|
384
|
+
'opaque-root',
|
|
385
|
+
'cross-origin',
|
|
386
|
+
'answers-file',
|
|
387
|
+
'takes-files',
|
|
388
|
+
'body-limit',
|
|
389
|
+
'form',
|
|
390
|
+
'guards',
|
|
391
|
+
'limits',
|
|
392
|
+
'signature',
|
|
393
|
+
] as const
|
|
394
|
+
|
|
395
|
+
export type SurfaceNoteTopic = (typeof SURFACE_NOTE_TOPICS)[number]
|
|
396
|
+
|
|
397
|
+
/** One thing that opens an endpoint or stands in front of it, in the approval's words. */
|
|
398
|
+
export interface SurfaceNoteDto {
|
|
399
|
+
topic: SurfaceNoteTopic
|
|
400
|
+
text: string
|
|
401
|
+
/**
|
|
402
|
+
* The procedure's `limits` are the framework's defaults (its body limit and time limit, without file fields): the
|
|
403
|
+
* approval page says them once for every such row instead of on each.
|
|
404
|
+
*/
|
|
405
|
+
default?: true
|
|
274
406
|
}
|
|
275
407
|
|
|
276
408
|
export interface PutAppEnvRequest {
|
|
@@ -396,6 +528,16 @@ export interface RemoveDeploymentNamespaceResponse {
|
|
|
396
528
|
readonly removed: DeploymentNamespaceDetailDto
|
|
397
529
|
}
|
|
398
530
|
|
|
531
|
+
/** The namespaces whose proxy rebuild `namespaces.republishAll` submitted. */
|
|
532
|
+
export interface RepublishAllNamespacesResponse {
|
|
533
|
+
readonly namespaceIds: readonly string[]
|
|
534
|
+
}
|
|
535
|
+
|
|
536
|
+
/** The resource keys released; each was confirmed gone at the provider in the same call. */
|
|
537
|
+
export interface ReleaseNamespaceClaimsResponse {
|
|
538
|
+
readonly released: readonly string[]
|
|
539
|
+
}
|
|
540
|
+
|
|
399
541
|
export interface PlanDeploymentNamespaceRequest {
|
|
400
542
|
id: string
|
|
401
543
|
env: string
|
|
@@ -451,6 +593,11 @@ export interface PutAppVarRequest {
|
|
|
451
593
|
name: string
|
|
452
594
|
value: string
|
|
453
595
|
env?: string | null
|
|
596
|
+
/**
|
|
597
|
+
* The caller checked the value is not a credential. Without it Control refuses a variable whose name or value looks
|
|
598
|
+
* like one, because a variable is shown in clear to everyone who manages the application; a credential is a secret.
|
|
599
|
+
*/
|
|
600
|
+
notSecret?: boolean
|
|
454
601
|
}
|
|
455
602
|
|
|
456
603
|
export interface RegisterAppRequest extends AppOptionalFields {
|
|
@@ -492,25 +639,104 @@ export interface RunDto {
|
|
|
492
639
|
createdAt: number
|
|
493
640
|
startedAt: number | null
|
|
494
641
|
finishedAt: number | null
|
|
642
|
+
/** When someone asked to cancel the run; a run that finished with it set was cancelled, unless it succeeded first. */
|
|
643
|
+
cancelRequestedAt: number | null
|
|
644
|
+
}
|
|
645
|
+
|
|
646
|
+
/** What a change line is about (ADR-0050 §3). */
|
|
647
|
+
export const CHANGE_SUBJECT_KINDS = [
|
|
648
|
+
'application',
|
|
649
|
+
'endpoint',
|
|
650
|
+
'mount',
|
|
651
|
+
'dimension',
|
|
652
|
+
'action',
|
|
653
|
+
'role',
|
|
654
|
+
'table',
|
|
655
|
+
'file-collection',
|
|
656
|
+
'file-kind',
|
|
657
|
+
'job',
|
|
658
|
+
'export',
|
|
659
|
+
'import',
|
|
660
|
+
'token',
|
|
661
|
+
'csp',
|
|
662
|
+
'migration',
|
|
663
|
+
] as const
|
|
664
|
+
|
|
665
|
+
export type ChangeSubjectKind = (typeof CHANGE_SUBJECT_KINDS)[number]
|
|
666
|
+
|
|
667
|
+
export interface ChangeSubjectDto {
|
|
668
|
+
kind: ChangeSubjectKind
|
|
669
|
+
/** The endpoint id, the table, the role, the migration file, the CSP directive; the application's id for `application`. */
|
|
670
|
+
name: string
|
|
671
|
+
/** An endpoint's route: the candidate's row, or the baseline's for a removed endpoint. */
|
|
672
|
+
method?: EndpointMethod
|
|
673
|
+
path?: string
|
|
674
|
+
}
|
|
675
|
+
|
|
676
|
+
/** Who reaches an endpoint: the candidate's row, or the baseline's for a removed endpoint, in the surface's terms. */
|
|
677
|
+
export interface ChangeAudienceDto {
|
|
678
|
+
reach: SurfaceReach
|
|
679
|
+
/** The link mount whose share links reach it, for a `link` reach. */
|
|
680
|
+
mount?: string
|
|
681
|
+
/** What a caller must hold, as `SurfaceEndpointDto.requirement` words it; null for an anonymous kind. */
|
|
682
|
+
requirement: string | null
|
|
683
|
+
/**
|
|
684
|
+
* Every caller kind the endpoint admits, sorted, as `SurfaceEndpointDto.callers`; empty for an anonymous kind. Absent
|
|
685
|
+
* on a line classified before lines carried it.
|
|
686
|
+
*/
|
|
687
|
+
callers?: string[]
|
|
688
|
+
}
|
|
689
|
+
|
|
690
|
+
/**
|
|
691
|
+
* Why a line needs closer review: a step off the paved road, something anyone without signing in sets off, a mutation
|
|
692
|
+
* served on `GET`, people becoming visible, a file collection adopted or released, the application naming who signs
|
|
693
|
+
* in at an enrolled terminal, or a migration statement not known to keep every stored value.
|
|
694
|
+
*/
|
|
695
|
+
export const REVIEW_REASONS = ['off-road', 'anyone-calls', 'get-mutation', 'people', 'adoption', 'terminal', 'deletes-data'] as const
|
|
696
|
+
|
|
697
|
+
export type ReviewReason = (typeof REVIEW_REASONS)[number]
|
|
698
|
+
|
|
699
|
+
/** What a call sets off, when the line says so. */
|
|
700
|
+
export interface ChangeConsequenceDto {
|
|
701
|
+
kind: 'starts-job'
|
|
702
|
+
job: string
|
|
495
703
|
}
|
|
496
704
|
|
|
497
705
|
/**
|
|
498
706
|
* One plain-language line of an access change. `effect` is `widens` when it can grant access the baseline did not,
|
|
499
707
|
* `narrows` when it can only take access away, and `neutral` when it admits no one new and takes nothing away.
|
|
500
|
-
* `review: 'closer'` marks a
|
|
708
|
+
* `review: 'closer'` marks a line the approver reads the code behind (a step off the paved road, a call anyone sets off,
|
|
709
|
+
* …), and `reason` says which. A line classified before lines carried facts has no `rule`, `subject` or `reason`.
|
|
501
710
|
*/
|
|
502
711
|
export interface AccessChangeDto {
|
|
503
712
|
effect: 'widens' | 'narrows' | 'neutral'
|
|
504
713
|
line: string
|
|
505
714
|
review?: 'closer'
|
|
715
|
+
reason?: ReviewReason
|
|
506
716
|
/** The line opens an endpoint to the pages on the origins the environment lists; `ApprovalDto.crossOrigins` names them. */
|
|
507
717
|
environmentOrigins?: true
|
|
718
|
+
/** The comparison that produced the line, a stable code (`endpoint.body-limit`); it never holds an application's name. */
|
|
719
|
+
rule?: string
|
|
720
|
+
subject?: ChangeSubjectDto
|
|
721
|
+
/** Who reaches the endpoint, on an endpoint subject. */
|
|
722
|
+
audience?: ChangeAudienceDto
|
|
723
|
+
consequence?: ChangeConsequenceDto
|
|
724
|
+
/**
|
|
725
|
+
* The line's words in a row that already names its endpoint, route and audience (the approval page's caller groups):
|
|
726
|
+
* `New endpoint`, `Output \`header\` gains field \`reference\``. Absent where the line has no shorter form.
|
|
727
|
+
*/
|
|
728
|
+
inRow?: string
|
|
729
|
+
/** The surface notes of its endpoint the line already says, so its row does not say them again. */
|
|
730
|
+
states?: SurfaceNoteTopic[]
|
|
508
731
|
}
|
|
509
732
|
|
|
510
733
|
/** A run's access change against its environment's active snapshot (ADR-0050 §3). */
|
|
511
734
|
export interface ApprovalDto {
|
|
512
735
|
run: RunDto
|
|
513
|
-
/**
|
|
736
|
+
/**
|
|
737
|
+
* `none`: no line. `no-widening`: lines that narrow or leave access unchanged. `widening`: a line widens. On a
|
|
738
|
+
* protected environment only a change with a closer-review line waits (`waitsForApproval`); any other publishes at once.
|
|
739
|
+
*/
|
|
514
740
|
outcome: 'none' | 'no-widening' | 'widening'
|
|
515
741
|
changes: AccessChangeDto[]
|
|
516
742
|
/** The digest of the run's snapshot and of the active one it was compared with: an approval is bound to both. */
|
|
@@ -526,8 +752,29 @@ export interface ApprovalDto {
|
|
|
526
752
|
* empty when the environment lists none.
|
|
527
753
|
*/
|
|
528
754
|
crossOrigins?: string[]
|
|
529
|
-
/**
|
|
530
|
-
|
|
755
|
+
/**
|
|
756
|
+
* The candidate's endpoints the change names, as the environment page's surface words them: who reaches each, what it
|
|
757
|
+
* requires, and what else opens it or stands in front of it (another origin, a body limit, rate buckets, a challenge).
|
|
758
|
+
* A removed endpoint is not among them. Empty for a run that stored no snapshot, and on the approvals list.
|
|
759
|
+
*/
|
|
760
|
+
endpoints: SurfaceEndpointDto[]
|
|
761
|
+
/**
|
|
762
|
+
* The candidate's roles and what each action of theirs reaches: the access the run would publish to people and
|
|
763
|
+
* scripts, by role (workloads and other applications are the change's). Absent on the approvals list, for a run that
|
|
764
|
+
* stored no snapshot, and from a Control released before it.
|
|
765
|
+
*/
|
|
766
|
+
accessMap?: AccessMapDto
|
|
767
|
+
/**
|
|
768
|
+
* The human who approved it, once one did. `holds` is false once the approval lapsed: an older run of the environment
|
|
769
|
+
* published another change first, the change still widens against it, and the run waits for a new approval (ADR-0050
|
|
770
|
+
* §2). A refusal or a cancellation of such a run drops the approval, so a decided run's approval always held.
|
|
771
|
+
*/
|
|
772
|
+
approval: { principalId: string; label: string; approvedAt: number; holds: boolean } | null
|
|
773
|
+
/**
|
|
774
|
+
* The newer run of the environment whose success stopped this one before it started: an older run never deploys over
|
|
775
|
+
* a newer one (ADR-0050 §6). Only on one approval read, of a run that failed without starting.
|
|
776
|
+
*/
|
|
777
|
+
supersededBy?: string
|
|
531
778
|
}
|
|
532
779
|
|
|
533
780
|
/** Approve or refuse one parked run. The digests are the ones the approver read; a reclassified run refuses them. */
|
|
@@ -563,6 +810,8 @@ export interface RunLogResponse {
|
|
|
563
810
|
status?: RunStatus
|
|
564
811
|
}
|
|
565
812
|
|
|
813
|
+
export { OPS_ROW_COUNT_CAP, type OpsContentView, type OpsView } from '@fabrika/auth-core'
|
|
814
|
+
export * from './approval-view.js'
|
|
566
815
|
export type {
|
|
567
816
|
AdoptNamespaceInput,
|
|
568
817
|
AppEnvironmentInput,
|
|
@@ -578,6 +827,7 @@ export type {
|
|
|
578
827
|
PutAppEnvironmentInput,
|
|
579
828
|
PutAppSecretInput,
|
|
580
829
|
PutAppVarInput,
|
|
830
|
+
ReleaseNamespaceClaimsInput,
|
|
581
831
|
RotateTokenKeyResponse,
|
|
582
832
|
RunIdInput,
|
|
583
833
|
RunListInput,
|
|
@@ -586,3 +836,20 @@ export type {
|
|
|
586
836
|
TailRunInput,
|
|
587
837
|
UpdateNamespaceInput,
|
|
588
838
|
} from './rpc.js'
|
|
839
|
+
export type {
|
|
840
|
+
DataBackupDto,
|
|
841
|
+
DataBackupScheduleDto,
|
|
842
|
+
DataBackupState,
|
|
843
|
+
DataOperationDto,
|
|
844
|
+
DataOperationKind,
|
|
845
|
+
DataOperationListInput,
|
|
846
|
+
DataOperationResolution,
|
|
847
|
+
DataOperationState,
|
|
848
|
+
DataOperationStep,
|
|
849
|
+
DataRehearsalOutcome,
|
|
850
|
+
MaintenanceMode,
|
|
851
|
+
RecoverDataOperationInput,
|
|
852
|
+
SetDataBackupScheduleInput,
|
|
853
|
+
StartDataOperationInput,
|
|
854
|
+
} from './rpc.js'
|
|
855
|
+
export { DATA_OPERATION_MAX_PAGE_SIZE, dataOperationListInputSchema, recoverDataOperationInputSchema, startDataOperationInputSchema } from './rpc.js'
|
package/src/mail.ts
CHANGED
|
@@ -47,6 +47,8 @@ export interface MailMessageContentDto {
|
|
|
47
47
|
readonly replyTo?: string
|
|
48
48
|
readonly fromName?: string
|
|
49
49
|
readonly unsubscribeUrl?: string
|
|
50
|
+
/** A message of a send to many recipients, which the provider keeps apart from transactional mail. */
|
|
51
|
+
readonly broadcast?: true
|
|
50
52
|
readonly attachments: readonly MailAttachmentDto[]
|
|
51
53
|
}
|
|
52
54
|
|
package/src/rpc.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { RpcProcedureContract } from '@fabrika/app'
|
|
2
|
-
import type { ExportDescription } from '@fabrika/auth-core'
|
|
2
|
+
import type { ExportDescription, OpsContentView, OpsView } from '@fabrika/auth-core'
|
|
3
|
+
import { z } from 'zod'
|
|
3
4
|
import type { BuilderConnectionReceiptDto, CreateBuilderConnectionReceiptRequest, GetBuilderConnectionReceiptRequest } from './builder-connections.js'
|
|
4
5
|
import type {
|
|
5
6
|
ApproveDeviceAuthorizationResult,
|
|
@@ -24,6 +25,9 @@ import type {
|
|
|
24
25
|
CursorList,
|
|
25
26
|
DeploymentNamespaceDetailDto,
|
|
26
27
|
DeploymentNamespaceListResponse,
|
|
28
|
+
GitHubSourceConnectionCancelDto,
|
|
29
|
+
GitHubSourceConnectionHandoffDto,
|
|
30
|
+
GitHubSourceConnectionHandoffInput,
|
|
27
31
|
GitHubSourceConnectionListInput,
|
|
28
32
|
GitHubSourceConnectionListResponse,
|
|
29
33
|
GitHubSourceConnectionStatusDto,
|
|
@@ -36,9 +40,12 @@ import type {
|
|
|
36
40
|
PutAppVarRequest,
|
|
37
41
|
RegisterAppRequest,
|
|
38
42
|
RegisterAppResponse,
|
|
43
|
+
ReleaseNamespaceClaimsResponse,
|
|
39
44
|
RemoveDeploymentNamespaceResponse,
|
|
45
|
+
RepublishAllNamespacesResponse,
|
|
40
46
|
RunDto,
|
|
41
47
|
RunLogResponse,
|
|
48
|
+
RunStatus,
|
|
42
49
|
RunTailResponse,
|
|
43
50
|
SetEnvironmentProtectionRequest,
|
|
44
51
|
StartGitHubSourceConnectionRequest,
|
|
@@ -119,9 +126,17 @@ export interface UpdateNamespaceInput extends NamespaceIdInput {
|
|
|
119
126
|
readonly namespace: UpdateDeploymentNamespaceRequest
|
|
120
127
|
}
|
|
121
128
|
|
|
129
|
+
/** The app environment whose claims in the namespace are released. */
|
|
130
|
+
export interface ReleaseNamespaceClaimsInput extends NamespaceIdInput {
|
|
131
|
+
readonly appId: string
|
|
132
|
+
readonly env: string
|
|
133
|
+
}
|
|
134
|
+
|
|
122
135
|
export interface RunListInput {
|
|
123
136
|
readonly appId?: string
|
|
124
137
|
readonly env?: string
|
|
138
|
+
/** Filter before pagination, so an old queued or running deploy is not hidden by newer finished runs. */
|
|
139
|
+
readonly statuses?: RunStatus[]
|
|
125
140
|
readonly before?: string
|
|
126
141
|
readonly limit?: number
|
|
127
142
|
}
|
|
@@ -142,6 +157,8 @@ export interface GitHubSourceConnectionInput {
|
|
|
142
157
|
export interface GitHubSourceConnectionRpcContract {
|
|
143
158
|
list: RpcProcedure<GitHubSourceConnectionListInput, GitHubSourceConnectionListResponse>
|
|
144
159
|
start: RpcProcedure<StartGitHubSourceConnectionRequest, StartGitHubSourceConnectionResponse>
|
|
160
|
+
handoff: RpcProcedure<GitHubSourceConnectionHandoffInput, GitHubSourceConnectionHandoffDto>
|
|
161
|
+
cancel: RpcProcedure<GitHubSourceConnectionInput, GitHubSourceConnectionCancelDto>
|
|
145
162
|
verifyInstallation: RpcProcedure<GitHubSourceConnectionInput, GitHubSourceConnectionStatusDto>
|
|
146
163
|
repair: RpcProcedure<GitHubSourceConnectionInput, GitHubSourceConnectionStatusDto>
|
|
147
164
|
reconcile: RpcProcedure<GitHubSourceConnectionInput, GitHubSourceConnectionStatusDto>
|
|
@@ -207,6 +224,16 @@ export interface ControlRpcContract {
|
|
|
207
224
|
update: RpcProcedure<UpdateNamespaceInput, DeploymentNamespaceDetailDto>
|
|
208
225
|
/** Free a namespace id. Refused while any app environment is registered in it (backlog 73). */
|
|
209
226
|
remove: RpcProcedure<NamespaceIdInput, RemoveDeploymentNamespaceResponse>
|
|
227
|
+
/**
|
|
228
|
+
* Republish the proxy of every ready namespace, as after a change of the installation's client logo (ADR-0066).
|
|
229
|
+
* Returns once each rebuild is submitted; a failure is a 502 naming the namespaces to reconcile.
|
|
230
|
+
*/
|
|
231
|
+
republishAll: RpcProcedure<void, RepublishAllNamespacesResponse>
|
|
232
|
+
/**
|
|
233
|
+
* Release one app environment's resource claims in the namespace, only when the provider confirms every claimed
|
|
234
|
+
* resource gone. The operator deletes the resources first; fabrika deletes none (ADR-0034).
|
|
235
|
+
*/
|
|
236
|
+
releaseClaims: RpcProcedure<ReleaseNamespaceClaimsInput, ReleaseNamespaceClaimsResponse>
|
|
210
237
|
}
|
|
211
238
|
runs: {
|
|
212
239
|
list: RpcProcedure<RunListInput, CursorList<RunDto>>
|
|
@@ -249,6 +276,27 @@ export interface ControlRpcContract {
|
|
|
249
276
|
remove: RpcProcedure<MailRuleIdInput, OkResponse>
|
|
250
277
|
}
|
|
251
278
|
}
|
|
279
|
+
/**
|
|
280
|
+
* An application environment's data (ADR-0069): `data.read` and `data.manage` at the coordinates,
|
|
281
|
+
* `data.content.read` as a global grant only; every denial is the 404 of an absent environment.
|
|
282
|
+
*/
|
|
283
|
+
data: {
|
|
284
|
+
operations: {
|
|
285
|
+
list: RpcProcedure<DataOperationListInput, CursorList<DataOperationDto>>
|
|
286
|
+
get: RpcProcedure<{ operationId: string }, DataOperationDto>
|
|
287
|
+
}
|
|
288
|
+
/** The metadata view; never content. */
|
|
289
|
+
view: RpcProcedure<AppEnvironmentInput, OpsView>
|
|
290
|
+
content: RpcProcedure<AppEnvironmentInput, OpsContentView>
|
|
291
|
+
start: RpcProcedure<StartDataOperationInput, DataOperationDto>
|
|
292
|
+
recover: RpcProcedure<RecoverDataOperationInput, DataOperationDto>
|
|
293
|
+
/** Consistent backups (ADR-0070): listed and their schedule read under `data.read`, the schedule set under `data.manage`. */
|
|
294
|
+
backups: {
|
|
295
|
+
list: RpcProcedure<DataOperationListInput, CursorList<DataBackupDto>>
|
|
296
|
+
schedule: RpcProcedure<AppEnvironmentInput, DataBackupScheduleDto>
|
|
297
|
+
setSchedule: RpcProcedure<SetDataBackupScheduleInput, DataBackupScheduleDto>
|
|
298
|
+
}
|
|
299
|
+
}
|
|
252
300
|
}
|
|
253
301
|
|
|
254
302
|
/**
|
|
@@ -262,3 +310,166 @@ export interface DescribeConnectorRequest {
|
|
|
262
310
|
readonly export: string
|
|
263
311
|
readonly version: number
|
|
264
312
|
}
|
|
313
|
+
|
|
314
|
+
// ── Data operations (ADR-0069) ───────────────────────────────────────────────
|
|
315
|
+
|
|
316
|
+
/** What an application environment's object admits (ADR-0069 §3). */
|
|
317
|
+
export type MaintenanceMode = 'open' | 'read-only' | 'closed' | 'inspect'
|
|
318
|
+
|
|
319
|
+
export type DataOperationKind = 'maintenance' | 'backup' | 'migrate' | 'recovery' | 'restore'
|
|
320
|
+
|
|
321
|
+
/**
|
|
322
|
+
* Where an operation stands: `reconcile` reads the record and the object's published state (a recovery's first step),
|
|
323
|
+
* `restrict` publishes a generation in a restricting mode, `backup` and `verify` take and check a consistent backup,
|
|
324
|
+
* `deploy` runs the operation's own deploy, `migrate` runs the pending migrations, `resume` continues the interrupted
|
|
325
|
+
* operation from its recorded step, and `open` publishes the generation that opens the object. A side restore (ADR-0070
|
|
326
|
+
* §9) also `list`s its clone with a deploy, `import`s the backup into it, `promote`s it (the clone `open`, the original
|
|
327
|
+
* `inspect`), `point`s ordinary traffic at it with a deploy, waits for it to `serve`, `rewind`s the original to the
|
|
328
|
+
* target time and `check`s the original's schema; `revert` points traffic back at the original with a deploy.
|
|
329
|
+
*/
|
|
330
|
+
export type DataOperationStep =
|
|
331
|
+
| 'reconcile'
|
|
332
|
+
| 'restrict'
|
|
333
|
+
| 'backup'
|
|
334
|
+
| 'verify'
|
|
335
|
+
| 'deploy'
|
|
336
|
+
| 'migrate'
|
|
337
|
+
| 'resume'
|
|
338
|
+
| 'open'
|
|
339
|
+
| 'list'
|
|
340
|
+
| 'import'
|
|
341
|
+
| 'promote'
|
|
342
|
+
| 'point'
|
|
343
|
+
| 'serve'
|
|
344
|
+
| 'rewind'
|
|
345
|
+
| 'check'
|
|
346
|
+
| 'revert'
|
|
347
|
+
|
|
348
|
+
export type DataOperationState = 'running' | 'succeeded' | 'failed'
|
|
349
|
+
|
|
350
|
+
/** What a recovery does after its closed fence: resume the interrupted operation, or open the object. */
|
|
351
|
+
export type DataOperationResolution = 'resume' | 'open'
|
|
352
|
+
|
|
353
|
+
/**
|
|
354
|
+
* One operation as `data.read` shows it: an allowlisted projection of Control's record, with identifiers, states,
|
|
355
|
+
* codes and timestamps only. It carries no free text and no content.
|
|
356
|
+
*/
|
|
357
|
+
export interface DataOperationDto {
|
|
358
|
+
readonly id: string
|
|
359
|
+
readonly appId: string
|
|
360
|
+
readonly env: string
|
|
361
|
+
readonly kind: DataOperationKind
|
|
362
|
+
readonly step: DataOperationStep
|
|
363
|
+
/** The mode the operation requires of the object at its step; a successor publishes its fresh generation in it. */
|
|
364
|
+
readonly targetMode: MaintenanceMode
|
|
365
|
+
/** The latest generation the operation reserved. */
|
|
366
|
+
readonly generation: number
|
|
367
|
+
readonly state: DataOperationState
|
|
368
|
+
/** A code once it failed, never an error message. */
|
|
369
|
+
readonly errorCode: string | null
|
|
370
|
+
/** An opaque principal id (as `runActor`), never an email or label. */
|
|
371
|
+
readonly actor: string
|
|
372
|
+
readonly createdAt: number
|
|
373
|
+
readonly updatedAt: number
|
|
374
|
+
readonly finishedAt: number | null
|
|
375
|
+
/** A recovery's interrupted operation, of the same environment; `null` for every other kind. */
|
|
376
|
+
readonly recoversOperationId: string | null
|
|
377
|
+
/** A recovery's choice after its closed fence; `null` for every other kind. */
|
|
378
|
+
readonly resolution: DataOperationResolution | null
|
|
379
|
+
/** A `migrate` operation's deploy run; `null` for every other kind. */
|
|
380
|
+
readonly runId: string | null
|
|
381
|
+
}
|
|
382
|
+
|
|
383
|
+
export const DATA_OPERATION_MAX_PAGE_SIZE = 100
|
|
384
|
+
|
|
385
|
+
const nonEmpty = z.string().min(1)
|
|
386
|
+
const maintenanceMode = z.enum(['open', 'read-only', 'closed', 'inspect'])
|
|
387
|
+
|
|
388
|
+
/** One environment's operations, newest first; `before` is the last id of the previous page. */
|
|
389
|
+
export const dataOperationListInputSchema = z.object({
|
|
390
|
+
appId: nonEmpty,
|
|
391
|
+
env: nonEmpty,
|
|
392
|
+
before: nonEmpty.optional(),
|
|
393
|
+
limit: z.number().int().min(1).max(DATA_OPERATION_MAX_PAGE_SIZE).optional(),
|
|
394
|
+
}).strict()
|
|
395
|
+
|
|
396
|
+
export type DataOperationListInput = z.infer<typeof dataOperationListInputSchema>
|
|
397
|
+
|
|
398
|
+
/**
|
|
399
|
+
* An operation a person starts. A migration starts inside a deploy and a recovery has its own request, so neither is
|
|
400
|
+
* started here. A restore names the time `at` (ISO 8601 with an offset) its environment's data is recovered as of.
|
|
401
|
+
*/
|
|
402
|
+
export const startDataOperationInputSchema = z.discriminatedUnion('kind', [
|
|
403
|
+
z.object({ appId: nonEmpty, env: nonEmpty, kind: z.literal('maintenance'), mode: maintenanceMode }).strict(),
|
|
404
|
+
z.object({ appId: nonEmpty, env: nonEmpty, kind: z.literal('backup') }).strict(),
|
|
405
|
+
z.object({ appId: nonEmpty, env: nonEmpty, kind: z.literal('restore'), at: z.string().datetime({ offset: true }) }).strict(),
|
|
406
|
+
])
|
|
407
|
+
|
|
408
|
+
export type StartDataOperationInput = z.infer<typeof startDataOperationInputSchema>
|
|
409
|
+
|
|
410
|
+
/**
|
|
411
|
+
* Recover an environment whose operation `operationId` is stuck: fence it with a fresh generation in `closed`, then
|
|
412
|
+
* resume that operation from its recorded step, or open the object at a new generation.
|
|
413
|
+
*/
|
|
414
|
+
export const recoverDataOperationInputSchema = z.object({
|
|
415
|
+
appId: nonEmpty,
|
|
416
|
+
env: nonEmpty,
|
|
417
|
+
operationId: nonEmpty,
|
|
418
|
+
resolution: z.enum(['resume', 'open']),
|
|
419
|
+
}).strict()
|
|
420
|
+
|
|
421
|
+
export type RecoverDataOperationInput = z.infer<typeof recoverDataOperationInputSchema>
|
|
422
|
+
|
|
423
|
+
/** `succeeded` only once its rehearsal passed. */
|
|
424
|
+
export type DataBackupState = 'running' | 'succeeded' | 'failed'
|
|
425
|
+
|
|
426
|
+
export type DataRehearsalOutcome = 'pending' | 'passed' | 'failed'
|
|
427
|
+
|
|
428
|
+
/**
|
|
429
|
+
* One consistent backup as `data.read` shows it: identifiers, states, codes, sizes and timestamps. It carries no free
|
|
430
|
+
* text and no content; downloading a dump is `data.content.read`.
|
|
431
|
+
*/
|
|
432
|
+
export interface DataBackupDto {
|
|
433
|
+
/** The backup's record. */
|
|
434
|
+
readonly id: string
|
|
435
|
+
readonly appId: string
|
|
436
|
+
readonly env: string
|
|
437
|
+
/** The `backup` operation that took it. */
|
|
438
|
+
readonly operationId: string
|
|
439
|
+
/** The object it was taken from. */
|
|
440
|
+
readonly object: string
|
|
441
|
+
/** The dump's key in the bucket; a resumed backup whose dump started again carries the new one. */
|
|
442
|
+
readonly dumpId: string
|
|
443
|
+
/** Taken by a deploy's migration phase, not by the daily schedule. */
|
|
444
|
+
readonly preMigration: boolean
|
|
445
|
+
readonly state: DataBackupState
|
|
446
|
+
/** A code once it failed, never an error message. */
|
|
447
|
+
readonly errorCode: string | null
|
|
448
|
+
readonly createdAt: number
|
|
449
|
+
readonly finishedAt: number | null
|
|
450
|
+
/** The object's bookmark when the dump began. */
|
|
451
|
+
readonly bookmark: string | null
|
|
452
|
+
/** Set once the upload completed. */
|
|
453
|
+
readonly sizeBytes: number | null
|
|
454
|
+
readonly parts: number | null
|
|
455
|
+
/** How many tables the manifest lists. */
|
|
456
|
+
readonly tables: number | null
|
|
457
|
+
readonly rehearsal: DataRehearsalOutcome
|
|
458
|
+
/** The code the rehearsal failed with. */
|
|
459
|
+
readonly rehearsalCode: string | null
|
|
460
|
+
/** Past its 30-day retention: never offered for a restore. */
|
|
461
|
+
readonly expired: boolean
|
|
462
|
+
}
|
|
463
|
+
|
|
464
|
+
/** Whether the environment takes daily backups: on unless it opted out. Opting out leaves the pre-migration backup. */
|
|
465
|
+
export interface DataBackupScheduleDto {
|
|
466
|
+
readonly appId: string
|
|
467
|
+
readonly env: string
|
|
468
|
+
readonly daily: boolean
|
|
469
|
+
/** When it was last set; `null` while it keeps the default. */
|
|
470
|
+
readonly updatedAt: number | null
|
|
471
|
+
}
|
|
472
|
+
|
|
473
|
+
export interface SetDataBackupScheduleInput extends AppEnvironmentInput {
|
|
474
|
+
readonly daily: boolean
|
|
475
|
+
}
|