@openupstream/sdk 0.5.0 → 0.10.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/model.d.ts CHANGED
@@ -6,9 +6,140 @@
6
6
  */
7
7
  export type Id = string;
8
8
  export type Timestamp = string;
9
- /** Compute Sites, where Databases, Services and Jobs run. Both are in Germany. */
10
- export declare const COMPUTE_SITES: readonly ["hetzner-fsn1", "ovh-lim"];
11
- export type Site = (typeof COMPUTE_SITES)[number];
9
+ /**
10
+ * A Site's id: its nodes' `topology.kubernetes.io/zone` label, so a
11
+ * Kubernetes label value (ADR-0007). Which Sites exist is the
12
+ * installation's: `GET /v1/sites` lists the compute Sites, where Databases,
13
+ * Services and Jobs run.
14
+ */
15
+ export type Site = string;
16
+ export declare const SITE_ID: RegExp;
17
+ /** A compute Site (`GET /v1/sites`). */
18
+ export interface SiteInfo {
19
+ id: Site;
20
+ /** What the installation's admins call it (e.g. `Falkenstein (Hetzner)`); null until they name it. */
21
+ description: string | null;
22
+ /** Whether it is the Home site of what is created without one. */
23
+ default: boolean;
24
+ }
25
+ /**
26
+ * What can be wrong with the nodes' Site labels (ADR-0008): the rules the
27
+ * install checks, which the control plane checks again while the cluster
28
+ * runs. Each has an alert of its own.
29
+ */
30
+ export declare const SITE_PROBLEMS: readonly ["node-without-site", "node-neither-compute-nor-quorum", "node-compute-and-quorum", "site-mixed-compute", "site-mixed-default", "default-site-missing", "default-site-not-unique", "default-site-not-compute", "compute-sites-below-two", "sites-below-three"];
31
+ export type SiteProblemKind = (typeof SITE_PROBLEMS)[number];
32
+ /** One thing wrong with the Site labels, and the command that fixes it. */
33
+ export interface SiteProblem {
34
+ kind: SiteProblemKind;
35
+ /** The node it is about; null when it is about a Site or the whole cluster. */
36
+ node: string | null;
37
+ /** The Site it is about; null when it is about the whole cluster or a node without one. */
38
+ site: Site | null;
39
+ /** What is wrong, in a sentence. */
40
+ message: string;
41
+ /** The `kubectl` command that fixes it; `<…>` marks what the operator chooses. */
42
+ fix: string;
43
+ }
44
+ /** A node of the cluster as its labels place it (`GET /v1/admin/nodes`). */
45
+ export interface NodeInfo {
46
+ name: string;
47
+ /** Its Site (its zone label); null when it has none. */
48
+ site: Site | null;
49
+ /** Labelled a node of a compute Site. */
50
+ compute: boolean;
51
+ /** Labelled a node of the default Site. */
52
+ default: boolean;
53
+ /** Tainted quorum-only: only etcd, Garage, Loki and the node agents run there. */
54
+ quorumOnly: boolean;
55
+ /** Kubernetes reports it Ready. */
56
+ ready: boolean;
57
+ createdAt: Timestamp;
58
+ }
59
+ /** A Site as the installation's admins see it: compute or not, with its description (`GET /v1/admin/nodes`). */
60
+ export interface SiteDetails extends SiteInfo {
61
+ /** Its nodes are labelled compute: Databases, Services and Jobs run there. */
62
+ compute: boolean;
63
+ }
64
+ /** A Site's description, set by an admin; null removes it, so the id is shown alone (ADR-0009). */
65
+ export interface SiteDescriptionInput {
66
+ description: string | null;
67
+ }
68
+ /** Every Site and node and what is wrong with the Site labels, for the installation's admins. */
69
+ export interface NodesReport {
70
+ /** Every Site that has a node, by id. */
71
+ sites: SiteDetails[];
72
+ nodes: NodeInfo[];
73
+ problems: SiteProblem[];
74
+ }
75
+ /**
76
+ * One pod of a platform Database or component (`GET /v1/admin/platform`):
77
+ * where it runs and whether it runs.
78
+ */
79
+ export interface PlatformInstance {
80
+ /** The pod's name. */
81
+ name: string;
82
+ /** Its node's Site; null before it is scheduled, or on a node without one. */
83
+ site: Site | null;
84
+ /** Running with every container started, and not being deleted. */
85
+ running: boolean;
86
+ }
87
+ /** An instance of a platform Database: its primary, or the standby. */
88
+ export interface PlatformDatabaseInstance extends PlatformInstance {
89
+ /** CloudNativePG's current primary; false for the standby, and for every instance while the Cluster cannot be read. */
90
+ primary: boolean;
91
+ }
92
+ /** One of the platform's own Databases, read live like a customer's (`GET /v1/admin/platform`). */
93
+ export interface PlatformDatabase {
94
+ id: Id;
95
+ name: string;
96
+ /** Where the primary runs when nothing has failed. */
97
+ homeSite: Site;
98
+ memoryMb: number;
99
+ storageGb: number;
100
+ state: DatabaseState;
101
+ /** The primary runs outside the Home site: a failover moved it, and it stays there until a switchover moves it back. */
102
+ failedOver: boolean;
103
+ instances: PlatformDatabaseInstance[];
104
+ }
105
+ /**
106
+ * - `running`: every replica available
107
+ * - `deploying`: a rollout is under way
108
+ * - `degraded`: some replicas available, not all
109
+ * - `down`: none available
110
+ * - `absent`: no Deployment of that name (e.g. an installation without the dashboard)
111
+ * - `unknown`: the platform could not check just now
112
+ */
113
+ export type PlatformComponentState = 'running' | 'deploying' | 'degraded' | 'down' | 'absent' | 'unknown';
114
+ /** A component of the platform: a Deployment in the platform Project's namespace. */
115
+ export interface PlatformComponent {
116
+ /** The Deployment's name: `control-plane`, `madauth` or `dashboard`. */
117
+ name: string;
118
+ state: PlatformComponentState;
119
+ /** The replicas it asks for, and those available; 0 and 0 when absent or unknown. */
120
+ replicas: number;
121
+ availableReplicas: number;
122
+ instances: PlatformInstance[];
123
+ }
124
+ /**
125
+ * The platform's own Account and Project, read-only, for the installation's
126
+ * admins, who are never Members of it (decision 164): its Databases and the
127
+ * platform's components, where each runs and how it is.
128
+ */
129
+ export interface PlatformReport {
130
+ account: {
131
+ id: Id;
132
+ name: string;
133
+ };
134
+ project: {
135
+ id: Id;
136
+ name: string;
137
+ };
138
+ databases: PlatformDatabase[];
139
+ components: PlatformComponent[];
140
+ /** The compute Sites with their descriptions, to name the Sites above. */
141
+ sites: SiteInfo[];
142
+ }
12
143
  /** The customer: pays, receives one invoice, owns Projects. */
13
144
  export interface Account {
14
145
  id: Id;
@@ -19,7 +150,16 @@ export interface Account {
19
150
  * empty when it may. Existing Resources keep running.
20
151
  */
21
152
  holds: string[];
153
+ /** The caller's role in the Account (`GET /v1/accounts`); null without one. */
154
+ role?: MemberRole | null;
22
155
  }
156
+ /**
157
+ * What a Member may do in the whole Account (decision 138): `owner`
158
+ * everything, the Account's Members included; `developer` every Project and
159
+ * everything in it.
160
+ */
161
+ export declare const MEMBER_ROLES: readonly ["owner", "developer"];
162
+ export type MemberRole = (typeof MEMBER_ROLES)[number];
23
163
  /** A person who can sign in to an Account. Sign-in is madAuth's. */
24
164
  export interface Member {
25
165
  id: Id;
@@ -27,8 +167,94 @@ export interface Member {
27
167
  /** The madAuth subject this Member signs in as. */
28
168
  authSubject: string;
29
169
  email: string;
170
+ /** null: the Member reaches only what their grants give them. */
171
+ role: MemberRole | null;
172
+ /** Their grants, oldest first; they count only while the Member has no role (decision 139). */
173
+ grants: Grant[];
30
174
  createdAt: Timestamp;
31
175
  }
176
+ /**
177
+ * Changes a Member's role; only an owner may, with a session or `oup login`,
178
+ * never an API key. null leaves them only their grants: their Postgres roles
179
+ * above what the grants allow are dropped (decision 143).
180
+ */
181
+ export interface MemberPatch {
182
+ role: MemberRole | null;
183
+ }
184
+ /**
185
+ * Access for one Member to one Database at a level (decision 139): they see
186
+ * the Database and its Project's name and open `oup pg proxy` at that level
187
+ * or below (decision 140), nothing else of the Project. A Member with a role
188
+ * needs none.
189
+ */
190
+ export interface Grant {
191
+ databaseId: Id;
192
+ databaseName: string;
193
+ projectId: Id;
194
+ projectName: string;
195
+ access: DatabaseAccess;
196
+ createdAt: Timestamp;
197
+ }
198
+ /** Gives a Member or an Account token a grant, or another level; owners only, never with an API key. */
199
+ export interface GrantInput {
200
+ access: DatabaseAccess;
201
+ }
202
+ /**
203
+ * What an Account token may do in the whole Account (decision 144):
204
+ * `developer`, as a Member with that role; never `owner`, so a token
205
+ * cannot manage the Account.
206
+ */
207
+ export declare const ACCOUNT_TOKEN_ROLES: readonly ["developer"];
208
+ export type AccountTokenRole = (typeof ACCOUNT_TOKEN_ROLES)[number];
209
+ /** How an Account token's secret starts; `oup` and the SDK send it like an API key (`OUP_API_KEY`). */
210
+ export declare const ACCOUNT_TOKEN_PREFIX = "oup_tok_";
211
+ /** An Account token expires at most this many days after it is created or rolled. */
212
+ export declare const ACCOUNT_TOKEN_MAX_DAYS = 365;
213
+ /**
214
+ * A named secret that belongs to the Account, not to a person, for CI, BI
215
+ * tools and scripts outside the platform (decision 144). It has the
216
+ * developer role or grants, and keeps working when the Member who made it
217
+ * leaves. The secret is shown once, when it is created or rolled.
218
+ */
219
+ export interface AccountToken {
220
+ id: Id;
221
+ accountId: Id;
222
+ /** DNS label, unique within the Account. */
223
+ name: string;
224
+ /** null: the token reaches only what its grants give. */
225
+ role: AccountTokenRole | null;
226
+ /** Its grants, oldest first; they count only while the token has no role. */
227
+ grants: Grant[];
228
+ expiresAt: Timestamp;
229
+ /** The last request made with it, to the minute; null if none yet. */
230
+ lastUsedAt: Timestamp | null;
231
+ createdAt: Timestamp;
232
+ }
233
+ /** A new Account token; owners only, with a session or `oup login`. */
234
+ export interface AccountTokenInput {
235
+ name: string;
236
+ /** Default null: only its grants, given afterwards. */
237
+ role?: AccountTokenRole | null;
238
+ /** In the future, at most ACCOUNT_TOKEN_MAX_DAYS away. */
239
+ expiresAt: Timestamp;
240
+ }
241
+ /** Renames an Account token or changes its role; a lost role drops its Postgres roles its grants do not allow. */
242
+ export interface AccountTokenPatch {
243
+ name?: string;
244
+ role?: AccountTokenRole | null;
245
+ }
246
+ /** A new secret for an Account token, with a new expiry; its name, rights and Postgres roles stay. */
247
+ export interface AccountTokenRoll {
248
+ /** In the future, at most ACCOUNT_TOKEN_MAX_DAYS away. */
249
+ expiresAt: Timestamp;
250
+ }
251
+ /** The answer to creating or rolling an Account token: the only time its secret is shown. */
252
+ export interface AccountTokenWithSecret extends AccountToken {
253
+ /** `oup_tok_…`. */
254
+ secret: string;
255
+ /** After a roll: until when the previous secret still works (24 hours at most); absent when none does. */
256
+ previousSecretValidUntil?: Timestamp;
257
+ }
32
258
  /** The unit of isolation and lifecycle; deleting it deletes everything in it. */
33
259
  export interface Project {
34
260
  id: Id;
@@ -36,6 +262,19 @@ export interface Project {
36
262
  /** DNS label, unique within the Account. */
37
263
  name: string;
38
264
  createdAt: Timestamp;
265
+ /**
266
+ * How many Resources of each kind the Project holds (`GET /v1/projects`
267
+ * only); left out for a caller who reaches the Project through a grant
268
+ * alone, who sees nothing else of it (decision 139).
269
+ */
270
+ resources?: ProjectResources;
271
+ }
272
+ /** A Project's Resources counted per kind; deleted ones do not count. */
273
+ export interface ProjectResources {
274
+ databases: number;
275
+ services: number;
276
+ jobs: number;
277
+ buckets: number;
39
278
  }
40
279
  /** Postgres always runs with at least this much memory. */
41
280
  export declare const DATABASE_MIN_MEMORY_MB = 256;
@@ -87,7 +326,7 @@ export interface ProjectInput {
87
326
  name: string;
88
327
  }
89
328
  /**
90
- * Creates a Database; homeSite defaults to `hetzner-fsn1`. With
329
+ * Creates a Database; homeSite defaults to the default Site (`GET /v1/sites`). With
91
330
  * `restoreFrom`, it starts as a copy of that Database instead of empty.
92
331
  */
93
332
  export interface DatabaseInput {
@@ -139,6 +378,16 @@ export interface DatabaseConnection {
139
378
  export interface DatabaseDetails extends Database {
140
379
  state: DatabaseState;
141
380
  connection: DatabaseConnection;
381
+ /**
382
+ * Where the Project's Services and Jobs reach the Database's standby,
383
+ * read-only (decision 157): for queries that must not load the primary
384
+ * and may read data a moment old. They get it as
385
+ * `DATABASE_READ_URL_<NAME>`, the oldest Database's also as
386
+ * `DATABASE_READ_URL`. Connections fail while no standby is ready (a
387
+ * restart of the standby; after a failover until the other Site is
388
+ * back), and always on an installation with a single node.
389
+ */
390
+ readConnection: DatabaseConnection;
142
391
  }
143
392
  /**
144
393
  * How much a caller's own Postgres role may do through `oup pg proxy`
@@ -183,7 +432,8 @@ export interface BucketInput {
183
432
  /**
184
433
  * How to reach a Bucket with any S3 client: virtual-hosted style only, at
185
434
  * `endpoint` (the Bucket's own hostname), with the Bucket's key. The key
186
- * reads and writes this Bucket and no other.
435
+ * reads and writes this Bucket and no other, and sets its CORS rules
436
+ * (`PutBucketCors`).
187
437
  */
188
438
  export interface BucketAccess {
189
439
  /** `https://<name>.s3.<customer domain>`. */
@@ -247,13 +497,54 @@ export interface Service {
247
497
  port: number | null;
248
498
  /**
249
499
  * Where a single replica runs; null: the Home site of the Project's oldest
250
- * Database, or `hetzner-fsn1`. Two or more replicas run in both Sites.
500
+ * Database, or the default Site. Two or more replicas spread over the compute Sites.
251
501
  */
252
502
  homeSite: Site | null;
253
503
  /** Whether the image is pulled with registry credentials. */
254
504
  registryAuth: boolean;
505
+ /** The Project's Secrets its containers read, by name: each is an environment variable of that name (decision 170). */
506
+ secrets: string[];
507
+ /** Its plain settings, environment variables anyone who may read the Project can see; not for credentials. */
508
+ variables: Record<string, string>;
509
+ /**
510
+ * The Databases of its Project that its containers reach, in its order
511
+ * (decision 173): each as a Postgres role of its own, or as the
512
+ * Database's owner. One that names none gets no `DATABASE_URL` and
513
+ * holds no database password. The first one's URL is also
514
+ * `DATABASE_URL`.
515
+ */
516
+ databases: NamedDatabase[];
517
+ /**
518
+ * Its pre-deploy Job (decision 173): a Job of its Project that is run,
519
+ * and waited for, before each of its rollouts; null when it has none.
520
+ */
521
+ preDeployJobId: Id | null;
522
+ /**
523
+ * The pre-deploy run of its latest deploy: `pending` until it is
524
+ * started (it waits for the Job to be ready), `running`, then
525
+ * `succeeded` or `failed`. Unless it succeeded, the Service runs what
526
+ * it ran before. Null when its latest deploy had no pre-deploy Job.
527
+ */
528
+ preDeploy: {
529
+ state: PreDeployState;
530
+ runId: string | null;
531
+ } | null;
255
532
  createdAt: Timestamp;
256
533
  }
534
+ /**
535
+ * Limits of what a Service's or Job's definition names for its containers'
536
+ * environment (decision 170). The values of the Secrets a definition names
537
+ * share one Kubernetes Secret, hence their total.
538
+ */
539
+ export declare const ENVIRONMENT_LIMITS: {
540
+ readonly maxSecrets: 256;
541
+ readonly maxVariables: 256;
542
+ readonly maxVariableValueBytes: number;
543
+ readonly maxVariablesTotalBytes: number;
544
+ readonly maxNamedSecretsTotalBytes: number;
545
+ };
546
+ /** Names starting with this are the platform's own variables and cannot be a Secret's or a Variable's in a definition. */
547
+ export declare const RESERVED_ENVIRONMENT_PREFIX = "OUP_";
257
548
  /** Creates a Service; the tag is resolved to a digest while the request waits. */
258
549
  export interface ServiceInput {
259
550
  name: string;
@@ -266,6 +557,14 @@ export interface ServiceInput {
266
557
  cpuMillicores: number;
267
558
  homeSite?: Site;
268
559
  registryAuth?: RegistryAuth;
560
+ /** Names of Secrets of the Project; default none. An unknown name is refused. */
561
+ secrets?: string[];
562
+ /** Default none. */
563
+ variables?: Record<string, string>;
564
+ /** The Databases it reaches; default none. An unknown name is refused. */
565
+ databases?: NamedDatabaseInput[];
566
+ /** A Job of the Project to run before each rollout; default none. */
567
+ preDeployJobId?: Id;
269
568
  }
270
569
  /**
271
570
  * Changes a Service. A new `image` or `registryAuth` resolves the tag again;
@@ -280,16 +579,58 @@ export interface ServicePatch {
280
579
  cpuMillicores?: number;
281
580
  homeSite?: Site | null;
282
581
  registryAuth?: RegistryAuth | null;
582
+ /** Replaces the whole list. */
583
+ secrets?: string[];
584
+ /** Replaces the whole map. */
585
+ variables?: Record<string, string>;
586
+ /** Replaces the whole list. */
587
+ databases?: NamedDatabaseInput[];
588
+ /** Another pre-deploy Job, or null for none. */
589
+ preDeployJobId?: Id | null;
283
590
  }
284
591
  /**
285
592
  * Read live from its Deployment: `deploying` until the first replica is
286
593
  * up and while a new version rolls out, `running` with every replica
287
594
  * available, `degraded` with some, `unknown` when Kubernetes cannot be asked.
595
+ * Before a rollout of a Service with a pre-deploy Job: `pre-deploy` while
596
+ * that Job's run is waited for, `pre-deploy-failed` when it failed, and
597
+ * the Service then keeps running what it ran before.
288
598
  */
289
- export type ServiceState = 'deploying' | 'running' | 'degraded' | 'unknown';
599
+ /**
600
+ * How a Service or Job reaches a Database it names (decision 173): `own`,
601
+ * as a Postgres role of its own (`svc_<name>`, `job_<name>`) that can
602
+ * connect and nothing else until the Database's owner grants it rights in
603
+ * SQL; `owner`, as the role that owns the Database, for what changes the
604
+ * schema and gives those rights.
605
+ */
606
+ export declare const DEFINITION_DATABASE_ACCESS: readonly ["own", "owner"];
607
+ export type DefinitionDatabaseAccess = (typeof DEFINITION_DATABASE_ACCESS)[number];
608
+ /** A Database a Service or Job names, by its name. */
609
+ export interface NamedDatabase {
610
+ name: string;
611
+ access: DefinitionDatabaseAccess;
612
+ }
613
+ /** A Database to name: `access` is `own` when left out. */
614
+ export interface NamedDatabaseInput {
615
+ name: string;
616
+ access?: DefinitionDatabaseAccess;
617
+ }
618
+ /** A Service or Job names at most this many Databases. */
619
+ export declare const MAX_NAMED_DATABASES = 16;
620
+ /** The longest name of a Service or Job that can have a role of its own: Postgres's names end at 63, and the role's has a prefix of 4. */
621
+ export declare const MAX_NAME_WITH_OWN_ROLE = 59;
622
+ export type ServiceState = 'pre-deploy' | 'pre-deploy-failed' | 'deploying' | 'running' | 'degraded' | 'unknown';
623
+ /** How the pre-deploy run of a Service's deploy stands. */
624
+ export type PreDeployState = 'pending' | 'running' | 'succeeded' | 'failed';
290
625
  /** A Service as the API returns it. */
291
626
  export interface ServiceDetails extends Service {
292
627
  state: ServiceState;
628
+ /**
629
+ * Those of its `secrets` and `variables` whose value its containers do
630
+ * not get, because the platform sets a variable of that name for the
631
+ * Project's Databases (`DATABASE_URL…`, decision 97) and its value wins.
632
+ */
633
+ overridden: string[];
293
634
  }
294
635
  /** Limits of a Job, checked by the API; memory and CPU as for a Service. */
295
636
  export declare const JOB_LIMITS: {
@@ -336,10 +677,16 @@ export interface Job {
336
677
  schedule: string | null;
337
678
  /** IANA time zone the schedule is read in, e.g. `Europe/Berlin`; null: UTC. */
338
679
  timeZone: string | null;
339
- /** Where its runs go; null: the Home site of the Project's oldest Database, or `hetzner-fsn1`. */
680
+ /** Where its runs go; null: the Home site of the Project's oldest Database, or the default Site. */
340
681
  homeSite: Site | null;
341
682
  /** Whether the image is pulled with registry credentials. */
342
683
  registryAuth: boolean;
684
+ /** The Project's Secrets its runs read, by name, as a Service's. */
685
+ secrets: string[];
686
+ /** Its plain settings, as a Service's. A run's own `env` wins over both. */
687
+ variables: Record<string, string>;
688
+ /** The Databases its runs reach, as a Service's. */
689
+ databases: NamedDatabase[];
343
690
  createdAt: Timestamp;
344
691
  }
345
692
  /** Creates a Job; the tag is resolved to a digest while the request waits. */
@@ -356,6 +703,12 @@ export interface JobInput {
356
703
  timeZone?: string;
357
704
  homeSite?: Site;
358
705
  registryAuth?: RegistryAuth;
706
+ /** Names of Secrets of the Project; default none. */
707
+ secrets?: string[];
708
+ /** Default none. */
709
+ variables?: Record<string, string>;
710
+ /** The Databases its runs reach; default none. */
711
+ databases?: NamedDatabaseInput[];
359
712
  }
360
713
  /**
361
714
  * Changes a Job. A new `image` or `registryAuth` resolves the tag again;
@@ -373,6 +726,12 @@ export interface JobPatch {
373
726
  timeZone?: string | null;
374
727
  homeSite?: Site | null;
375
728
  registryAuth?: RegistryAuth | null;
729
+ /** Replaces the whole list. */
730
+ secrets?: string[];
731
+ /** Replaces the whole map. */
732
+ variables?: Record<string, string>;
733
+ /** Replaces the whole list. */
734
+ databases?: NamedDatabaseInput[];
376
735
  }
377
736
  /**
378
737
  * Read live from its CronJob: `deploying` until the Jobs operator has
@@ -383,6 +742,8 @@ export type JobState = 'deploying' | 'ready' | 'unknown';
383
742
  /** A Job as the API returns it. */
384
743
  export interface JobDetails extends Job {
385
744
  state: JobState;
745
+ /** Those of its `secrets` and `variables` that the platform's own variables override, as a Service's. */
746
+ overridden: string[];
386
747
  }
387
748
  /**
388
749
  * Read live from its Kubernetes Job: `pending` until its container runs
@@ -464,12 +825,12 @@ export interface LogQuery {
464
825
  /** A Secret's name is an environment variable name (the schema checks the same). */
465
826
  export declare const SECRET_NAME: RegExp;
466
827
  /**
467
- * At most this many bytes (UTF-8) per value, and all of a Project's values
468
- * together at most SECRETS_MAX_TOTAL_BYTES: they go into one Kubernetes
469
- * Secret (1 MiB at most) and into every container's environment.
828
+ * At most this many bytes (UTF-8) per value. The values one Service or Job
829
+ * names together are limited by ENVIRONMENT_LIMITS.maxNamedSecretsTotalBytes.
470
830
  */
471
831
  export declare const SECRET_VALUE_MAX_BYTES: number;
472
- export declare const SECRETS_MAX_TOTAL_BYTES: number;
832
+ /** At most this many Secrets per Project: what bounds a Project's Secrets, since no limit is on their size together. */
833
+ export declare const SECRETS_MAX_PER_PROJECT = 1000;
473
834
  /**
474
835
  * A Secret's value is write-only: the API accepts it and hands it to the
475
836
  * Project's Services and jobs as an environment variable, but never returns it.
@@ -481,11 +842,109 @@ export interface Secret {
481
842
  name: string;
482
843
  createdAt: Timestamp;
483
844
  updatedAt: Timestamp;
845
+ /** The Services and Jobs that name it: only their containers get it, and a change restarts those Services. Empty: unused. */
846
+ usedBy: {
847
+ kind: 'service' | 'job';
848
+ id: Id;
849
+ name: string;
850
+ }[];
484
851
  }
485
852
  export interface SecretInput {
486
853
  name: string;
487
854
  value: string;
488
855
  }
856
+ /** Limits of Keys (ARCHITECTURE.md, decision 167). */
857
+ export declare const KEY_LIMITS: {
858
+ /** Keys per Project, those pending deletion included. */
859
+ readonly maxPerProject: 20;
860
+ /** How long a deleted Key refuses every call and can still be restored, before it is erased. */
861
+ readonly deletionDays: 7;
862
+ /** Versions of one Key: every one is kept for the Key's life, so `rotate` is refused above this. */
863
+ readonly maxVersions: 1000;
864
+ };
865
+ /** Limits of one call of the key API (decision 167). */
866
+ export declare const KEY_CALL_LIMITS: {
867
+ /** A plaintext, decoded: larger data is encrypted with a key of the customer's own, which is encrypted with the Key. */
868
+ readonly maxPlaintextBytes: 4096;
869
+ readonly maxContextEntries: 16;
870
+ /** A context's names and values together, as UTF-8. */
871
+ readonly maxContextBytes: 1024;
872
+ /** A request's body. */
873
+ readonly maxBodyBytes: number;
874
+ /** How long a call's record is kept (decision 169). */
875
+ readonly retentionDays: 30;
876
+ /** Records one listing returns at most, and by default. */
877
+ readonly maxListed: 1000;
878
+ readonly defaultListed: 100;
879
+ };
880
+ /**
881
+ * One call of the key API as its record has it (decision 169): who used the
882
+ * Key, for what and how it ended. Never a plaintext or a ciphertext.
883
+ */
884
+ export interface KeyCall {
885
+ /** Grows with time; the `before` of the next page. */
886
+ id: string;
887
+ at: Timestamp;
888
+ holder: 'service' | 'job';
889
+ holderId: Id;
890
+ /** The Service's or Job's name when it called; null if it could not be read. */
891
+ holderName: string | null;
892
+ operation: 'encrypt' | 'decrypt';
893
+ /**
894
+ * `ok`; `forbidden` (no grant for the operation); `pending-deletion`;
895
+ * `invalid` (a body that is no such request); `cannot-decrypt` (another
896
+ * context, another Key or a changed ciphertext); `rate-limited` (calls
897
+ * above the limit, one record per minute with their number in `calls`).
898
+ */
899
+ outcome: 'ok' | 'forbidden' | 'pending-deletion' | 'invalid' | 'cannot-decrypt' | 'rate-limited';
900
+ /** The Key's version that encrypted or was asked to decrypt; null when the call did not get that far. */
901
+ version: number | null;
902
+ /** 1, or for `rate-limited` how many calls the record stands for. */
903
+ calls: number;
904
+ /** The context as sent, which is not secret and is stored; null when none could be read. */
905
+ context: Record<string, string> | null;
906
+ }
907
+ /** What a grant on a Key allows. Not ordered: `encrypt` does not include `decrypt`, nor the reverse. */
908
+ export declare const KEY_ACCESS: readonly ["encrypt", "decrypt", "both"];
909
+ export type KeyAccess = (typeof KEY_ACCESS)[number];
910
+ /** A Service's or a Job's grant on a Key (decision 168): its pods may call the key API for that Key. */
911
+ export interface KeyGrant {
912
+ holder: 'service' | 'job';
913
+ /** The Service's or Job's id. */
914
+ id: Id;
915
+ name: string;
916
+ access: KeyAccess;
917
+ createdAt: Timestamp;
918
+ }
919
+ export interface KeyGrantInput {
920
+ access: KeyAccess;
921
+ }
922
+ /** `active`, or `pending-deletion` from its delete until it is erased or restored. */
923
+ export type KeyState = 'active' | 'pending-deletion';
924
+ /**
925
+ * An encryption key of a Project that never leaves the platform
926
+ * (ARCHITECTURE.md, "Keys"): the API creates, rotates and deletes it and
927
+ * never returns its material.
928
+ */
929
+ export interface Key {
930
+ id: Id;
931
+ projectId: Id;
932
+ /** DNS label, unique within the Project, also while the Key is pending deletion. */
933
+ name: string;
934
+ /** The newest version, which encrypting uses; `rotate` adds one, and older ones keep decrypting. */
935
+ version: number;
936
+ state: KeyState;
937
+ /** When a Key pending deletion is erased, and what it encrypted becomes unreadable; null while it is active. */
938
+ deletesAt: Timestamp | null;
939
+ createdAt: Timestamp;
940
+ /** When the newest version was added: at creation, then at each rotation. */
941
+ rotatedAt: Timestamp;
942
+ /** The Services and Jobs of the Project that may use it, by name. */
943
+ grants: KeyGrant[];
944
+ }
945
+ export interface KeyInput {
946
+ name: string;
947
+ }
489
948
  /**
490
949
  * Where `oup login` signs in (`GET /v1/login`, no token needed): madAuth's
491
950
  * issuer and the CLI's client ID there, for the device authorization grant.