@openupstream/sdk 0.12.0 → 0.22.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/index.d.ts +57 -5
- package/dist/index.js +109 -6
- package/dist/index.js.map +1 -1
- package/dist/internal.d.ts +175 -12
- package/dist/internal.js +92 -7
- package/dist/internal.js.map +1 -1
- package/dist/model.d.ts +480 -10
- package/dist/model.js +111 -2
- package/dist/model.js.map +1 -1
- package/package.json +1 -1
package/dist/model.d.ts
CHANGED
|
@@ -304,6 +304,67 @@ export interface Grant {
|
|
|
304
304
|
export interface GrantInput {
|
|
305
305
|
access: DatabaseAccess;
|
|
306
306
|
}
|
|
307
|
+
/** How long an invitation can be accepted, from its sending (decision 142). */
|
|
308
|
+
export declare const INVITATION_DAYS = 7;
|
|
309
|
+
/** An Account sends at most this many invitation e-mails a day; an address gets at most one an hour. */
|
|
310
|
+
export declare const INVITATION_LIMITS: {
|
|
311
|
+
readonly mailsPerAccountPerDay: 20;
|
|
312
|
+
readonly mailsPerAddressPerHour: 1;
|
|
313
|
+
};
|
|
314
|
+
/** A Database an invitation grants access to, at a level (decision 142). */
|
|
315
|
+
export interface InvitationGrant {
|
|
316
|
+
databaseId: Id;
|
|
317
|
+
databaseName: string;
|
|
318
|
+
projectId: Id;
|
|
319
|
+
projectName: string;
|
|
320
|
+
access: DatabaseAccess;
|
|
321
|
+
}
|
|
322
|
+
/**
|
|
323
|
+
* A pending invitation into an Account (decision 142): the invited address
|
|
324
|
+
* becomes a Member with `role`, or with `grants` when it has none, once
|
|
325
|
+
* someone signed in with that address accepts it. Owners see and revoke
|
|
326
|
+
* the pending ones.
|
|
327
|
+
*/
|
|
328
|
+
export interface Invitation {
|
|
329
|
+
id: Id;
|
|
330
|
+
accountId: Id;
|
|
331
|
+
/** The invited address, as the owner typed it. */
|
|
332
|
+
email: string;
|
|
333
|
+
role: MemberRole | null;
|
|
334
|
+
/** What the Member gets without a role; a Database deleted before acceptance is left out. */
|
|
335
|
+
grants: InvitationGrant[];
|
|
336
|
+
/** The address of the owner who invited, as the e-mail names it. */
|
|
337
|
+
invitedBy: string;
|
|
338
|
+
createdAt: Timestamp;
|
|
339
|
+
/** When its link stops working; resending starts 7 new days. */
|
|
340
|
+
expiresAt: Timestamp;
|
|
341
|
+
}
|
|
342
|
+
/**
|
|
343
|
+
* Invites an address into the Account: owners only, with a session or `oup
|
|
344
|
+
* login`, never an API key. A role, or grants on Databases of the Account;
|
|
345
|
+
* inviting the address again replaces its pending invitation.
|
|
346
|
+
*/
|
|
347
|
+
export interface InvitationInput {
|
|
348
|
+
email: string;
|
|
349
|
+
role?: MemberRole | null;
|
|
350
|
+
grants?: {
|
|
351
|
+
databaseId: Id;
|
|
352
|
+
access: DatabaseAccess;
|
|
353
|
+
}[];
|
|
354
|
+
}
|
|
355
|
+
/** What the invitation's link shows before anyone signs in: whom it is for, from whom, into which Account. */
|
|
356
|
+
export interface InvitationView {
|
|
357
|
+
accountName: string;
|
|
358
|
+
invitedBy: string;
|
|
359
|
+
email: string;
|
|
360
|
+
role: MemberRole | null;
|
|
361
|
+
grants: Omit<InvitationGrant, 'databaseId' | 'projectId'>[];
|
|
362
|
+
expiresAt: Timestamp;
|
|
363
|
+
}
|
|
364
|
+
/** The token from an invitation's link (the part after `#`): sent in the body, so it reaches no server log. */
|
|
365
|
+
export interface InvitationToken {
|
|
366
|
+
token: string;
|
|
367
|
+
}
|
|
307
368
|
/**
|
|
308
369
|
* What an Account token may do in the whole Account (decision 144):
|
|
309
370
|
* `developer`, as a Member with that role; never `owner`, so a token
|
|
@@ -315,6 +376,10 @@ export type AccountTokenRole = (typeof ACCOUNT_TOKEN_ROLES)[number];
|
|
|
315
376
|
export declare const ACCOUNT_TOKEN_PREFIX = "oup_tok_";
|
|
316
377
|
/** An Account token expires at most this many days after it is created or rolled. */
|
|
317
378
|
export declare const ACCOUNT_TOKEN_MAX_DAYS = 365;
|
|
379
|
+
/** At most this many source ranges per Account token (decision 214). */
|
|
380
|
+
export declare const ACCOUNT_TOKEN_MAX_SOURCE_RANGES = 20;
|
|
381
|
+
/** The owners are e-mailed this many days before an Account token expires, once per expiry (decision 214). */
|
|
382
|
+
export declare const ACCOUNT_TOKEN_WARNING_DAYS = 14;
|
|
318
383
|
/**
|
|
319
384
|
* A named secret that belongs to the Account, not to a person, for CI, BI
|
|
320
385
|
* tools and scripts outside the platform (decision 144). It has the
|
|
@@ -333,6 +398,12 @@ export interface AccountToken {
|
|
|
333
398
|
expiresAt: Timestamp;
|
|
334
399
|
/** The last request made with it, to the minute; null if none yet. */
|
|
335
400
|
lastUsedAt: Timestamp | null;
|
|
401
|
+
/**
|
|
402
|
+
* The addresses it may be used from, as CIDR ranges (`203.0.113.0/24`,
|
|
403
|
+
* `2001:db8::/32`); empty: from anywhere. A request from elsewhere, the
|
|
404
|
+
* tunnel of `oup pg proxy` included, is refused (403).
|
|
405
|
+
*/
|
|
406
|
+
sourceRanges: string[];
|
|
336
407
|
createdAt: Timestamp;
|
|
337
408
|
}
|
|
338
409
|
/** A new Account token; owners only, with a session or `oup login`. */
|
|
@@ -342,11 +413,18 @@ export interface AccountTokenInput {
|
|
|
342
413
|
role?: AccountTokenRole | null;
|
|
343
414
|
/** In the future, at most ACCOUNT_TOKEN_MAX_DAYS away. */
|
|
344
415
|
expiresAt: Timestamp;
|
|
416
|
+
/** CIDR ranges or single addresses; default none: from anywhere. */
|
|
417
|
+
sourceRanges?: string[];
|
|
345
418
|
}
|
|
346
|
-
/**
|
|
419
|
+
/**
|
|
420
|
+
* Renames an Account token, changes its role or its source ranges; a lost
|
|
421
|
+
* role drops its Postgres roles its grants do not allow. `sourceRanges`
|
|
422
|
+
* replaces the whole list; empty allows every address.
|
|
423
|
+
*/
|
|
347
424
|
export interface AccountTokenPatch {
|
|
348
425
|
name?: string;
|
|
349
426
|
role?: AccountTokenRole | null;
|
|
427
|
+
sourceRanges?: string[];
|
|
350
428
|
}
|
|
351
429
|
/** A new secret for an Account token, with a new expiry; its name, rights and Postgres roles stay. */
|
|
352
430
|
export interface AccountTokenRoll {
|
|
@@ -383,6 +461,34 @@ export interface ProjectResources {
|
|
|
383
461
|
}
|
|
384
462
|
/** Postgres always runs with at least this much memory. */
|
|
385
463
|
export declare const DATABASE_MIN_MEMORY_MB = 256;
|
|
464
|
+
/**
|
|
465
|
+
* What a Postgres server is for (decision 201): `production` runs a
|
|
466
|
+
* primary and a standby in two Sites, a PgBouncer in each and continuous
|
|
467
|
+
* backups with point-in-time restore; `development` (tests, staging) runs
|
|
468
|
+
* one instance and one PgBouncer in its Home site and has no backups: it
|
|
469
|
+
* is down while its Site is, and its data is lost with its server. Each is
|
|
470
|
+
* billed in units of its own.
|
|
471
|
+
*/
|
|
472
|
+
export declare const POSTGRES_TIERS: readonly ["production", "development"];
|
|
473
|
+
export type PostgresTier = (typeof POSTGRES_TIERS)[number];
|
|
474
|
+
export declare const DEFAULT_POSTGRES_TIER: PostgresTier;
|
|
475
|
+
/**
|
|
476
|
+
* The Postgres major versions a new server can be created with, oldest
|
|
477
|
+
* first (decision 220). A server keeps its major until its customer
|
|
478
|
+
* upgrades it to a newer one; minor versions come with the platform's
|
|
479
|
+
* image. A major leaves this list before its end of life, and servers
|
|
480
|
+
* still on it are upgraded after notice (decision 162).
|
|
481
|
+
*/
|
|
482
|
+
export declare const POSTGRES_VERSIONS: readonly [17, 18, 19];
|
|
483
|
+
export type PostgresVersion = (typeof POSTGRES_VERSIONS)[number];
|
|
484
|
+
/**
|
|
485
|
+
* A new server's major when the request names none: the newest one that
|
|
486
|
+
* has had its first minor release (x.1), so not a major in its first
|
|
487
|
+
* weeks (decision 220).
|
|
488
|
+
*/
|
|
489
|
+
export declare const DEFAULT_POSTGRES_VERSION: PostgresVersion;
|
|
490
|
+
/** Whether `version` is one a new server can be created with or upgraded to. */
|
|
491
|
+
export declare const isPostgresVersion: (version: number) => version is PostgresVersion;
|
|
386
492
|
export interface Database {
|
|
387
493
|
id: Id;
|
|
388
494
|
projectId: Id;
|
|
@@ -399,10 +505,94 @@ export interface Database {
|
|
|
399
505
|
autoGrow: boolean;
|
|
400
506
|
/** How far auto-grow may take storageGb; null: no limit but the nodes' free space. */
|
|
401
507
|
maxStorageGb: number | null;
|
|
508
|
+
/** Its server's tier (decision 201). */
|
|
509
|
+
tier: PostgresTier;
|
|
510
|
+
/** Its server's Postgres major version (decision 220). */
|
|
511
|
+
postgresVersion: number;
|
|
402
512
|
createdAt: Timestamp;
|
|
403
513
|
/** Set when the Database started as a copy of another one. */
|
|
404
514
|
restoredFrom?: DatabaseRestore;
|
|
515
|
+
/**
|
|
516
|
+
* The Postgres database's name inside its server, and the stem of its
|
|
517
|
+
* owner and group roles (`oup_owner_<postgresName>`, decision 189): the
|
|
518
|
+
* Database's name with `-` as `_` when it was created, and its source's
|
|
519
|
+
* in a restore. Absent for a Database from before, whose database and
|
|
520
|
+
* owner are both `app`.
|
|
521
|
+
*/
|
|
522
|
+
postgresName?: string;
|
|
523
|
+
/** The Postgres server it is in (decision 189), which has its sizes, Home site and backups. */
|
|
524
|
+
serverId: Id;
|
|
405
525
|
}
|
|
526
|
+
/**
|
|
527
|
+
* The running Postgres of a Project (decision 189, ADR-0015): what is
|
|
528
|
+
* sized, placed, fails over, is backed up and billed. It holds one or more
|
|
529
|
+
* Databases, is created with its first and deleted with its last.
|
|
530
|
+
*/
|
|
531
|
+
export interface PostgresServer {
|
|
532
|
+
id: Id;
|
|
533
|
+
projectId: Id;
|
|
534
|
+
/** DNS label, unique within the Project; its first Database's name. */
|
|
535
|
+
name: string;
|
|
536
|
+
/** Where the primary runs when nothing has failed. */
|
|
537
|
+
homeSite: Site;
|
|
538
|
+
memoryMb: number;
|
|
539
|
+
storageGb: number;
|
|
540
|
+
/** Whether storage grows by itself (decision 111). */
|
|
541
|
+
autoGrow: boolean;
|
|
542
|
+
maxStorageGb: number | null;
|
|
543
|
+
/** Production or development (decision 201). */
|
|
544
|
+
tier: PostgresTier;
|
|
545
|
+
/**
|
|
546
|
+
* The Postgres major version it runs, or is being upgraded to (decision
|
|
547
|
+
* 220): one of POSTGRES_VERSIONS, or an older one it was created with.
|
|
548
|
+
*/
|
|
549
|
+
postgresVersion: number;
|
|
550
|
+
/**
|
|
551
|
+
* Its latest upgrade, when `pg_upgrade` failed: the server was given its
|
|
552
|
+
* previous major back, unchanged. Cleared by the next upgrade.
|
|
553
|
+
*/
|
|
554
|
+
failedUpgrade?: {
|
|
555
|
+
postgresVersion: number;
|
|
556
|
+
at: Timestamp;
|
|
557
|
+
};
|
|
558
|
+
createdAt: Timestamp;
|
|
559
|
+
/** Its live Databases, oldest first. */
|
|
560
|
+
databases: {
|
|
561
|
+
id: Id;
|
|
562
|
+
name: string;
|
|
563
|
+
}[];
|
|
564
|
+
}
|
|
565
|
+
/** A Postgres server with what its Cluster says now. */
|
|
566
|
+
export interface PostgresServerDetails extends PostgresServer {
|
|
567
|
+
state: DatabaseState;
|
|
568
|
+
}
|
|
569
|
+
/**
|
|
570
|
+
* A new Postgres server as a copy of another of the Project at a target
|
|
571
|
+
* time (or the latest point its archive reaches): with every Database the
|
|
572
|
+
* source held then, each named `<its name>-<name>` (decision 189). Sizes
|
|
573
|
+
* and Site default to the source's.
|
|
574
|
+
*/
|
|
575
|
+
export interface PostgresServerRestoreInput {
|
|
576
|
+
name: string;
|
|
577
|
+
restoreFrom: {
|
|
578
|
+
serverId: Id;
|
|
579
|
+
targetTime?: Timestamp;
|
|
580
|
+
};
|
|
581
|
+
homeSite?: Site;
|
|
582
|
+
memoryMb?: number;
|
|
583
|
+
storageGb?: number;
|
|
584
|
+
autoGrow?: boolean;
|
|
585
|
+
maxStorageGb?: number | null;
|
|
586
|
+
/** Default: the source's. */
|
|
587
|
+
tier?: PostgresTier;
|
|
588
|
+
}
|
|
589
|
+
/** A resize of a Postgres server: what DatabasePatch sets, now said of the server. */
|
|
590
|
+
export type PostgresServerPatch = DatabasePatch;
|
|
591
|
+
/**
|
|
592
|
+
* The longest name a new Database may have: its owner and group roles
|
|
593
|
+
* (`oup_connect_<name>`) must fit Postgres's 63 characters (decision 189).
|
|
594
|
+
*/
|
|
595
|
+
export declare const DATABASE_NAME_MAX_LENGTH = 51;
|
|
406
596
|
/**
|
|
407
597
|
* Where a restored Database's data comes from (decision 108): another
|
|
408
598
|
* Database of the same Project, live or deleted within the backup retention
|
|
@@ -444,6 +634,29 @@ export interface DatabaseInput {
|
|
|
444
634
|
/** Default null: no limit. At least storageGb. */
|
|
445
635
|
maxStorageGb?: number | null;
|
|
446
636
|
restoreFrom?: DatabaseRestore;
|
|
637
|
+
/** Its server's tier (decision 201); default `production`. */
|
|
638
|
+
tier?: PostgresTier;
|
|
639
|
+
/**
|
|
640
|
+
* Its server's Postgres major version (decision 220); default
|
|
641
|
+
* DEFAULT_POSTGRES_VERSION. A restore takes its source's and refuses
|
|
642
|
+
* another.
|
|
643
|
+
*/
|
|
644
|
+
postgresVersion?: PostgresVersion;
|
|
645
|
+
/**
|
|
646
|
+
* The name of the Postgres server created with it (decision 189);
|
|
647
|
+
* default: the Database's name.
|
|
648
|
+
*/
|
|
649
|
+
serverName?: string;
|
|
650
|
+
}
|
|
651
|
+
/**
|
|
652
|
+
* A new Database on an existing Postgres server of the Project (decision
|
|
653
|
+
* 189): it takes no sizes or Site, which are the server's. The server must
|
|
654
|
+
* have the per-Database layout (any created since decision 189).
|
|
655
|
+
*/
|
|
656
|
+
export interface DatabaseOnServerInput {
|
|
657
|
+
name: string;
|
|
658
|
+
/** The server's name. */
|
|
659
|
+
server: string;
|
|
447
660
|
}
|
|
448
661
|
/**
|
|
449
662
|
* Resizes a Database (decision 110). Storage only grows: a volume cannot
|
|
@@ -456,16 +669,31 @@ export interface DatabasePatch {
|
|
|
456
669
|
autoGrow?: boolean;
|
|
457
670
|
/** null removes the limit. */
|
|
458
671
|
maxStorageGb?: number | null;
|
|
672
|
+
/**
|
|
673
|
+
* A new tier (decision 201): to `production` adds a standby and starts
|
|
674
|
+
* backups (needs room in another Site); to `development` removes the
|
|
675
|
+
* standby and stops backups, keeping the existing ones.
|
|
676
|
+
*/
|
|
677
|
+
tier?: PostgresTier;
|
|
678
|
+
/**
|
|
679
|
+
* Upgrades the server to this newer major (decision 220), with
|
|
680
|
+
* CloudNativePG's offline `pg_upgrade`: every Database on it is down for
|
|
681
|
+
* minutes, the server reads `upgrading` meanwhile. No way back: a
|
|
682
|
+
* downgrade is refused. Point-in-time restore reaches back only to the
|
|
683
|
+
* upgrade. Not together with another change.
|
|
684
|
+
*/
|
|
685
|
+
postgresVersion?: PostgresVersion;
|
|
459
686
|
}
|
|
460
687
|
/**
|
|
461
688
|
* - `provisioning`: being created, or not yet seen by the operator
|
|
462
|
-
* - `resizing`: its Cluster does not have the size the Database asks for yet
|
|
689
|
+
* - `resizing`: its Cluster does not have the size or tier (decision 201) the Database asks for yet
|
|
690
|
+
* - `upgrading`: its server is being upgraded to a newer Postgres major (decision 220); down meanwhile
|
|
463
691
|
* - `ready`: both instances healthy
|
|
464
692
|
* - `degraded`: running, but not every instance is healthy (e.g. during a
|
|
465
693
|
* failover)
|
|
466
694
|
* - `unknown`: the platform could not check just now
|
|
467
695
|
*/
|
|
468
|
-
export type DatabaseState = 'provisioning' | 'resizing' | 'ready' | 'degraded' | 'unknown';
|
|
696
|
+
export type DatabaseState = 'provisioning' | 'resizing' | 'upgrading' | 'ready' | 'degraded' | 'unknown';
|
|
469
697
|
/**
|
|
470
698
|
* Where the Project's Services and Jobs reach the Database: through its
|
|
471
699
|
* PgBouncer (transaction pooling), inside the cluster only. The password is
|
|
@@ -516,6 +744,12 @@ export interface DatabaseProxy {
|
|
|
516
744
|
user: string;
|
|
517
745
|
password: string;
|
|
518
746
|
database: string;
|
|
747
|
+
/**
|
|
748
|
+
* At `owner`: the Database's owner, which the role acts as, so what it
|
|
749
|
+
* creates belongs to the owner (`app` in a Database from before,
|
|
750
|
+
* `oup_owner_<postgresName>` since decision 189).
|
|
751
|
+
*/
|
|
752
|
+
owner?: string;
|
|
519
753
|
tunnelUrl: string;
|
|
520
754
|
}
|
|
521
755
|
/**
|
|
@@ -575,6 +809,26 @@ export declare const SERVICE_LIMITS: {
|
|
|
575
809
|
readonly minCpuMillicores: 50;
|
|
576
810
|
readonly maxCpuMillicores: 8000;
|
|
577
811
|
};
|
|
812
|
+
/**
|
|
813
|
+
* How far a Service's or Job's containers may use idle CPU beyond their
|
|
814
|
+
* configured CPU (decision 198): 1, never; 2 or 4, up to that many times
|
|
815
|
+
* it. The configured CPU is guaranteed whatever the choice; the rest is
|
|
816
|
+
* used only while the node has idle cores. Each choice has its own price
|
|
817
|
+
* per core-hour (`cpu_hours_1x`, `cpu_hours_2x`, `cpu_hours_4x`).
|
|
818
|
+
*/
|
|
819
|
+
export declare const CPU_BURSTS: readonly [1, 2, 4];
|
|
820
|
+
export type CpuBurst = (typeof CPU_BURSTS)[number];
|
|
821
|
+
export declare const DEFAULT_CPU_BURST: CpuBurst;
|
|
822
|
+
/**
|
|
823
|
+
* How a Service replaces its pods on a rollout (decision 161): `overlap`
|
|
824
|
+
* starts a new pod before an old one stops, so a deploy costs no downtime;
|
|
825
|
+
* `stopFirst` stops every old pod before a new one starts, seconds of
|
|
826
|
+
* downtime per deploy, for an app that must never run twice at once, such
|
|
827
|
+
* as a bot polling one chat or a scheduler without a lock.
|
|
828
|
+
*/
|
|
829
|
+
export declare const SERVICE_ROLLOUTS: readonly ["overlap", "stopFirst"];
|
|
830
|
+
export type ServiceRollout = (typeof SERVICE_ROLLOUTS)[number];
|
|
831
|
+
export declare const DEFAULT_SERVICE_ROLLOUT: ServiceRollout;
|
|
578
832
|
/**
|
|
579
833
|
* A container, always on, 1..N replicas (ARCHITECTURE.md, "Containers"):
|
|
580
834
|
* an HTTP server, or a worker without a port. Its image is pinned to a
|
|
@@ -594,6 +848,10 @@ export interface Service {
|
|
|
594
848
|
replicas: number;
|
|
595
849
|
memoryMb: number;
|
|
596
850
|
cpuMillicores: number;
|
|
851
|
+
/** How far it may use idle CPU beyond `cpuMillicores` (CPU_BURSTS). */
|
|
852
|
+
cpuBurst: CpuBurst;
|
|
853
|
+
/** How its pods are replaced on a rollout (SERVICE_ROLLOUTS). */
|
|
854
|
+
rollout: ServiceRollout;
|
|
597
855
|
/**
|
|
598
856
|
* The HTTP port the container listens on; null: a worker, which no Route
|
|
599
857
|
* can serve, gets no in-cluster address and counts as ready once it runs
|
|
@@ -667,6 +925,10 @@ export interface ServiceInput {
|
|
|
667
925
|
replicas?: number;
|
|
668
926
|
memoryMb: number;
|
|
669
927
|
cpuMillicores: number;
|
|
928
|
+
/** Default DEFAULT_CPU_BURST. */
|
|
929
|
+
cpuBurst?: CpuBurst;
|
|
930
|
+
/** Default DEFAULT_SERVICE_ROLLOUT. */
|
|
931
|
+
rollout?: ServiceRollout;
|
|
670
932
|
homeSite?: Site;
|
|
671
933
|
registryAuth?: RegistryAuth;
|
|
672
934
|
/** Names of Secrets of the Project; default none. An unknown name is refused. */
|
|
@@ -693,6 +955,8 @@ export interface ServicePatch {
|
|
|
693
955
|
replicas?: number;
|
|
694
956
|
memoryMb?: number;
|
|
695
957
|
cpuMillicores?: number;
|
|
958
|
+
cpuBurst?: CpuBurst;
|
|
959
|
+
rollout?: ServiceRollout;
|
|
696
960
|
homeSite?: Site | null;
|
|
697
961
|
registryAuth?: RegistryAuth | null;
|
|
698
962
|
/** Replaces the whole list. */
|
|
@@ -749,6 +1013,93 @@ export interface ServiceDetails extends Service {
|
|
|
749
1013
|
*/
|
|
750
1014
|
overridden: string[];
|
|
751
1015
|
}
|
|
1016
|
+
/**
|
|
1017
|
+
* Limits of a Function (decisions 159, 211 and 216), the runner's
|
|
1018
|
+
* (`function-runner/src/config.rs`), and of its component: a
|
|
1019
|
+
* WebAssembly component of at most `maxComponentBytes`.
|
|
1020
|
+
*/
|
|
1021
|
+
export declare const FUNCTION_LIMITS: {
|
|
1022
|
+
readonly minMemoryMb: 1;
|
|
1023
|
+
readonly maxMemoryMb: 512;
|
|
1024
|
+
readonly defaultMemoryMb: 64;
|
|
1025
|
+
readonly minCpuMs: 1;
|
|
1026
|
+
readonly maxCpuMs: 60000;
|
|
1027
|
+
readonly defaultCpuMs: 50;
|
|
1028
|
+
readonly minTimeoutMs: 1;
|
|
1029
|
+
readonly maxTimeoutMs: 60000;
|
|
1030
|
+
readonly defaultTimeoutMs: 30000;
|
|
1031
|
+
readonly maxComponentBytes: number;
|
|
1032
|
+
readonly maxOrigins: 64;
|
|
1033
|
+
};
|
|
1034
|
+
/** A component's digest: `sha256:` and the hex SHA-256 of its bytes. */
|
|
1035
|
+
export declare const FUNCTION_COMPONENT_DIGEST: RegExp;
|
|
1036
|
+
/**
|
|
1037
|
+
* A component uploaded to a Project (`POST …/function-components`, the
|
|
1038
|
+
* raw bytes as `application/wasm`): what a Function names by its digest.
|
|
1039
|
+
* The same bytes uploaded again are the same component. One that no
|
|
1040
|
+
* Function names is deleted a day after its upload.
|
|
1041
|
+
*/
|
|
1042
|
+
export interface FunctionComponent {
|
|
1043
|
+
digest: string;
|
|
1044
|
+
sizeBytes: number;
|
|
1045
|
+
}
|
|
1046
|
+
/** A Bucket or Service of its Project that a Function reaches at `http://<name>/`. */
|
|
1047
|
+
export interface FunctionOrigin {
|
|
1048
|
+
/** The Bucket's or Service's name. */
|
|
1049
|
+
name: string;
|
|
1050
|
+
kind: 'bucket' | 'service';
|
|
1051
|
+
id: Id;
|
|
1052
|
+
}
|
|
1053
|
+
/**
|
|
1054
|
+
* A Function, which customers know as a Front Function (decisions 159 and
|
|
1055
|
+
* 212): a WebAssembly component of the `wasi:http/proxy` world that
|
|
1056
|
+
* answers the requests of the Routes that target it, run by the shared
|
|
1057
|
+
* runner with a fresh instance per request.
|
|
1058
|
+
*/
|
|
1059
|
+
export interface FunctionResource {
|
|
1060
|
+
id: Id;
|
|
1061
|
+
projectId: Id;
|
|
1062
|
+
/** DNS label, unique within the Project. */
|
|
1063
|
+
name: string;
|
|
1064
|
+
/** The digest of the component it runs. */
|
|
1065
|
+
component: string;
|
|
1066
|
+
/** That component's size in bytes. */
|
|
1067
|
+
sizeBytes: number;
|
|
1068
|
+
/** The memory one request's instance may use. */
|
|
1069
|
+
memoryMb: number;
|
|
1070
|
+
/** The CPU one request may use, in 1 ms ticks its guest runs through. */
|
|
1071
|
+
cpuMs: number;
|
|
1072
|
+
/** The deadline of one whole response. */
|
|
1073
|
+
timeoutMs: number;
|
|
1074
|
+
/** The Buckets and Services it reaches by name, by name. */
|
|
1075
|
+
origins: FunctionOrigin[];
|
|
1076
|
+
/** The Project's Secrets it reads, by name, each an environment variable (decision 170). */
|
|
1077
|
+
secrets: string[];
|
|
1078
|
+
/** Its plain settings, environment variables anyone who may read the Project can see. */
|
|
1079
|
+
variables: Record<string, string>;
|
|
1080
|
+
createdAt: Timestamp;
|
|
1081
|
+
updatedAt: Timestamp;
|
|
1082
|
+
}
|
|
1083
|
+
/** Creates a Function running a component uploaded to the Project before. */
|
|
1084
|
+
export interface FunctionInput {
|
|
1085
|
+
name: string;
|
|
1086
|
+
/** The digest `POST …/function-components` answered. */
|
|
1087
|
+
component: string;
|
|
1088
|
+
/** Default FUNCTION_LIMITS.defaultMemoryMb. */
|
|
1089
|
+
memoryMb?: number;
|
|
1090
|
+
/** Default FUNCTION_LIMITS.defaultCpuMs. */
|
|
1091
|
+
cpuMs?: number;
|
|
1092
|
+
/** Default FUNCTION_LIMITS.defaultTimeoutMs. */
|
|
1093
|
+
timeoutMs?: number;
|
|
1094
|
+
/** Names of the Project's Buckets and Services (one with a port); default none. */
|
|
1095
|
+
origins?: string[];
|
|
1096
|
+
/** Names of Secrets of the Project; default none. An unknown name is refused. */
|
|
1097
|
+
secrets?: string[];
|
|
1098
|
+
/** Default none. */
|
|
1099
|
+
variables?: Record<string, string>;
|
|
1100
|
+
}
|
|
1101
|
+
/** Changes a Function; its name stays. Each list or map replaces the whole one. */
|
|
1102
|
+
export type FunctionPatch = Partial<Omit<FunctionInput, 'name'>>;
|
|
752
1103
|
/** Limits of a Job, checked by the API; memory and CPU as for a Service. */
|
|
753
1104
|
export declare const JOB_LIMITS: {
|
|
754
1105
|
readonly minMemoryMb: 64;
|
|
@@ -784,6 +1135,8 @@ export interface Job {
|
|
|
784
1135
|
args: string[] | null;
|
|
785
1136
|
memoryMb: number;
|
|
786
1137
|
cpuMillicores: number;
|
|
1138
|
+
/** How far its runs may use idle CPU beyond `cpuMillicores`, as a Service's. */
|
|
1139
|
+
cpuBurst: CpuBurst;
|
|
787
1140
|
/** A run still going after this long is stopped and failed. */
|
|
788
1141
|
timeoutSeconds: number;
|
|
789
1142
|
/**
|
|
@@ -814,6 +1167,8 @@ export interface JobInput {
|
|
|
814
1167
|
args?: string[];
|
|
815
1168
|
memoryMb: number;
|
|
816
1169
|
cpuMillicores: number;
|
|
1170
|
+
/** Default DEFAULT_CPU_BURST. */
|
|
1171
|
+
cpuBurst?: CpuBurst;
|
|
817
1172
|
/** Default JOB_LIMITS.defaultTimeoutSeconds. */
|
|
818
1173
|
timeoutSeconds?: number;
|
|
819
1174
|
schedule?: string;
|
|
@@ -838,6 +1193,7 @@ export interface JobPatch {
|
|
|
838
1193
|
args?: string[] | null;
|
|
839
1194
|
memoryMb?: number;
|
|
840
1195
|
cpuMillicores?: number;
|
|
1196
|
+
cpuBurst?: CpuBurst;
|
|
841
1197
|
timeoutSeconds?: number;
|
|
842
1198
|
schedule?: string | null;
|
|
843
1199
|
timeZone?: string | null;
|
|
@@ -959,9 +1315,9 @@ export interface Secret {
|
|
|
959
1315
|
name: string;
|
|
960
1316
|
createdAt: Timestamp;
|
|
961
1317
|
updatedAt: Timestamp;
|
|
962
|
-
/** The Services and
|
|
1318
|
+
/** The Services, Jobs and Functions that name it: only they get it, and a change restarts those Services. Empty: unused. */
|
|
963
1319
|
usedBy: {
|
|
964
|
-
kind: 'service' | 'job';
|
|
1320
|
+
kind: 'service' | 'job' | 'function';
|
|
965
1321
|
id: Id;
|
|
966
1322
|
name: string;
|
|
967
1323
|
}[];
|
|
@@ -1129,10 +1485,13 @@ export type RouteTarget = {
|
|
|
1129
1485
|
} | {
|
|
1130
1486
|
kind: 'service';
|
|
1131
1487
|
serviceId: Id;
|
|
1488
|
+
} | {
|
|
1489
|
+
kind: 'function';
|
|
1490
|
+
functionId: Id;
|
|
1132
1491
|
};
|
|
1133
1492
|
/**
|
|
1134
|
-
* One entry under a Domain: everything below `pathPrefix` goes to a Bucket
|
|
1135
|
-
* a Service of the Domain's Project.
|
|
1493
|
+
* One entry under a Domain: everything below `pathPrefix` goes to a Bucket,
|
|
1494
|
+
* a Service or a Function of the Domain's Project.
|
|
1136
1495
|
*/
|
|
1137
1496
|
export interface Route {
|
|
1138
1497
|
id: Id;
|
|
@@ -1147,7 +1506,7 @@ export interface Route {
|
|
|
1147
1506
|
* Bucket the prefix is stripped: `/docs/a.html` on the Route `/docs` serves
|
|
1148
1507
|
* the object `a.html`. With `spaFallback`, a path with no object serves
|
|
1149
1508
|
* `index.html` with status 200; every Route to one Bucket has the same
|
|
1150
|
-
* `spaFallback`. A Service
|
|
1509
|
+
* `spaFallback`. A Service and a Function get the path unchanged.
|
|
1151
1510
|
*/
|
|
1152
1511
|
export type RouteInput = {
|
|
1153
1512
|
pathPrefix: string;
|
|
@@ -1157,8 +1516,13 @@ export type RouteInput = {
|
|
|
1157
1516
|
pathPrefix: string;
|
|
1158
1517
|
/** The Service gets the request with its path as it came, prefix included. */
|
|
1159
1518
|
serviceId: Id;
|
|
1519
|
+
} | {
|
|
1520
|
+
pathPrefix: string;
|
|
1521
|
+
/** The Function gets the request with its path as it came, prefix included. */
|
|
1522
|
+
functionId: Id;
|
|
1160
1523
|
};
|
|
1161
|
-
|
|
1524
|
+
/** `database` for usage before decision 189; a Postgres server's since. `function`: a Function (decision 216). */
|
|
1525
|
+
export declare const RESOURCE_KINDS: readonly ["database", "postgres_server", "bucket", "service", "job", "function"];
|
|
1162
1526
|
export type ResourceKind = (typeof RESOURCE_KINDS)[number];
|
|
1163
1527
|
/**
|
|
1164
1528
|
* One running copy of a Resource: an instance or a PgBouncer of a Database,
|
|
@@ -1195,6 +1559,18 @@ export interface Measured {
|
|
|
1195
1559
|
used: number | null;
|
|
1196
1560
|
allocated: number | null;
|
|
1197
1561
|
}
|
|
1562
|
+
/**
|
|
1563
|
+
* One Database's own data on its Postgres server (decision 206): its size
|
|
1564
|
+
* as Postgres counts it (`pg_database_size`), on the server's fullest
|
|
1565
|
+
* instance. The server's storage holds more than its Databases' sum: the
|
|
1566
|
+
* WAL, Postgres's own databases and free space.
|
|
1567
|
+
*/
|
|
1568
|
+
export interface DatabaseStorage {
|
|
1569
|
+
id: Id;
|
|
1570
|
+
name: string;
|
|
1571
|
+
/** null: not measured. */
|
|
1572
|
+
storageBytes: number | null;
|
|
1573
|
+
}
|
|
1198
1574
|
/**
|
|
1199
1575
|
* A Resource's current use (ARCHITECTURE.md, decision 124): the sum over
|
|
1200
1576
|
* its instances for CPU and memory (a Database's memory: its Postgres
|
|
@@ -1211,6 +1587,25 @@ export interface ResourceUsage {
|
|
|
1211
1587
|
memoryBytes: Measured;
|
|
1212
1588
|
storageBytes: Measured;
|
|
1213
1589
|
instances: Instance[];
|
|
1590
|
+
/** A Postgres server's Databases, oldest first, each with its own size (decision 206; SDK 0.17.0). Absent for other kinds. */
|
|
1591
|
+
databases?: DatabaseStorage[];
|
|
1592
|
+
/**
|
|
1593
|
+
* A Postgres server's write-ahead log (`pg_wal`) on its fullest
|
|
1594
|
+
* instance; null: not measured (decision 207; SDK 0.18.0). What is left
|
|
1595
|
+
* of its storage beyond its Databases and the WAL holds Postgres's own
|
|
1596
|
+
* databases, temporary files and the filesystem. Absent for other kinds.
|
|
1597
|
+
*/
|
|
1598
|
+
walBytes?: number | null;
|
|
1599
|
+
/**
|
|
1600
|
+
* A Function's requests (whatever their outcome) and the CPU
|
|
1601
|
+
* milliseconds they ran through over the last hour, what it is billed
|
|
1602
|
+
* by (decision 218); null: not measured. A Function has no instances,
|
|
1603
|
+
* CPU, memory or storage of its own here. Absent for other kinds.
|
|
1604
|
+
*/
|
|
1605
|
+
lastHour?: {
|
|
1606
|
+
requests: number;
|
|
1607
|
+
cpuMs: number;
|
|
1608
|
+
} | null;
|
|
1214
1609
|
}
|
|
1215
1610
|
export interface ProjectUsage {
|
|
1216
1611
|
measuredAt: Timestamp;
|
|
@@ -1218,7 +1613,82 @@ export interface ProjectUsage {
|
|
|
1218
1613
|
measured: boolean;
|
|
1219
1614
|
resources: ResourceUsage[];
|
|
1220
1615
|
}
|
|
1221
|
-
|
|
1616
|
+
/**
|
|
1617
|
+
* A customer alert (ARCHITECTURE.md, decision 199, ADR-0017): a condition on
|
|
1618
|
+
* one of the Project's Resources that only the customer can fix, firing now.
|
|
1619
|
+
* The set is fixed (`ServiceOutOfMemory`, `ServiceMemoryNearLimit`,
|
|
1620
|
+
* `ServiceRestarting`, `ServiceDiskNearLimit`, `JobRunOutOfMemory`,
|
|
1621
|
+
* `JobRunDiskNearLimit`, `PostgresServerStorageAtMaximum`);
|
|
1622
|
+
* a newer API may send others, so `name` is a string.
|
|
1623
|
+
*/
|
|
1624
|
+
export interface CustomerAlert {
|
|
1625
|
+
name: string;
|
|
1626
|
+
/** `name` null: the Resource is gone, the alert has not cleared yet. */
|
|
1627
|
+
resource: {
|
|
1628
|
+
kind: ResourceKind;
|
|
1629
|
+
id: Id;
|
|
1630
|
+
name: string | null;
|
|
1631
|
+
};
|
|
1632
|
+
/** The instance it fired on, as `Instance.name` in the usage; null: the whole Resource. */
|
|
1633
|
+
instance: string | null;
|
|
1634
|
+
severity: 'warning' | 'critical';
|
|
1635
|
+
/** What happened, in a sentence. */
|
|
1636
|
+
summary: string;
|
|
1637
|
+
/** What to change to fix it. */
|
|
1638
|
+
fix: string;
|
|
1639
|
+
/** Since when its condition holds. */
|
|
1640
|
+
since: Timestamp;
|
|
1641
|
+
}
|
|
1642
|
+
/**
|
|
1643
|
+
* What happened to a Service or a Job (decision 203, ADR-0019): a stop of
|
|
1644
|
+
* one of its containers or an eviction, kept 30 days.
|
|
1645
|
+
* - `out_of_memory`: stopped at its memory limit
|
|
1646
|
+
* - `crashed`: exited with a code other than 0 (a Service restarted, a run failed)
|
|
1647
|
+
* - `exited`: a Service's process exited with 0, and was restarted
|
|
1648
|
+
* - `evicted`: removed, e.g. above its 2 GiB of disk; `message` says why
|
|
1649
|
+
* A newer API may send other kinds, so `kind` is a string.
|
|
1650
|
+
*/
|
|
1651
|
+
export interface ResourceEvent {
|
|
1652
|
+
id: string;
|
|
1653
|
+
happenedAt: Timestamp;
|
|
1654
|
+
/** `name` null: the Resource is deleted. */
|
|
1655
|
+
resource: {
|
|
1656
|
+
kind: 'service' | 'job';
|
|
1657
|
+
id: Id;
|
|
1658
|
+
name: string | null;
|
|
1659
|
+
};
|
|
1660
|
+
/** The instance, as `Instance.name` in the usage: a replica, or a run. */
|
|
1661
|
+
instance: string;
|
|
1662
|
+
kind: string;
|
|
1663
|
+
exitCode: number | null;
|
|
1664
|
+
/** What happened, in a sentence. */
|
|
1665
|
+
summary: string;
|
|
1666
|
+
/** Kubernetes' own words, e.g. the kubelet's for an eviction; null when it gave none. */
|
|
1667
|
+
message: string | null;
|
|
1668
|
+
}
|
|
1669
|
+
export interface ProjectAlerts {
|
|
1670
|
+
checkedAt: Timestamp;
|
|
1671
|
+
/** false: the installation has no Prometheus, or it did not answer; then `alerts` is empty without meaning all is well. */
|
|
1672
|
+
available: boolean;
|
|
1673
|
+
alerts: CustomerAlert[];
|
|
1674
|
+
}
|
|
1675
|
+
/**
|
|
1676
|
+
* `cpu_seconds`: measured CPU, billed until decision 195; `cpu_hours`:
|
|
1677
|
+
* configured CPU × hours of pods that burst 2×, until decision 198;
|
|
1678
|
+
* `cpu_hours_1x`, `_2x`, `_4x`: configured CPU × hours since, one unit per
|
|
1679
|
+
* CPU burst, each with its own price. `memory_gb_hours` and
|
|
1680
|
+
* `storage_gb_hours` are Services', Jobs' and Buckets'; a Postgres server's
|
|
1681
|
+
* memory and storage are `postgres_memory_gb_hours` and
|
|
1682
|
+
* `postgres_storage_gb_hours` (production, decision 200) or
|
|
1683
|
+
* `postgres_dev_memory_gb_hours` and `postgres_dev_storage_gb_hours`
|
|
1684
|
+
* (development, decision 201), and were `memory_gb_hours` and
|
|
1685
|
+
* `storage_gb_hours` before. Events are never rewritten, so the older
|
|
1686
|
+
* units stay for the events from before. A Function's are
|
|
1687
|
+
* `function_requests` (requests, whatever their outcome) and
|
|
1688
|
+
* `function_cpu_ms` (the 1 ms ticks its instances ran through), decision
|
|
1689
|
+
* 211; its response bytes are `egress_gb` like any Route's.
|
|
1690
|
+
*/
|
|
1691
|
+
export declare const USAGE_UNITS: readonly ["cpu_seconds", "cpu_hours", "cpu_hours_1x", "cpu_hours_2x", "cpu_hours_4x", "memory_gb_hours", "storage_gb_hours", "postgres_memory_gb_hours", "postgres_storage_gb_hours", "postgres_dev_memory_gb_hours", "postgres_dev_storage_gb_hours", "egress_gb", "function_requests", "function_cpu_ms"];
|
|
1222
1692
|
export type UsageUnit = (typeof USAGE_UNITS)[number];
|
|
1223
1693
|
/** A Resource consumed `quantity` of `unit` between `intervalStart` and `intervalEnd`. */
|
|
1224
1694
|
export interface UsageEvent {
|