@openupstream/sdk 0.16.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/internal.js CHANGED
@@ -1,4 +1,4 @@
1
- import { DEFAULT_CPU_BURST } from './model.js';
1
+ import { DEFAULT_CPU_BURST, DEFAULT_SERVICE_ROLLOUT } from './model.js';
2
2
  /**
3
3
  * Kubernetes names, by id (ARCHITECTURE.md, decision 42): the operators
4
4
  * create these objects, the control plane reads and deletes them.
@@ -69,9 +69,10 @@ export const databaseReadConnection = (database) => ({
69
69
  ...databaseConnection(database),
70
70
  host: `${readPoolerName(database)}.${projectNamespace(database.projectId)}.svc.cluster.local`,
71
71
  });
72
- /** The Kubernetes Secret with the values of the Secrets a Service's or a Job's definition names (decision 170); it exists only while the definition names one. */
72
+ /** The Kubernetes Secret with the values of the Secrets a Service's, Job's or Function's definition names (decision 170); it exists only while the definition names one. */
73
73
  export const serviceEnvSecret = (service) => `svc-${service.id}-env`;
74
74
  export const jobEnvSecret = (job) => `job-${job.id}-env`;
75
+ export const functionEnvSecret = (fn) => `fn-${fn.id}-env`;
75
76
  /** `DATABASE_URL_<NAME>`'s suffix: the Database's name upper-cased, `-` as `_`. */
76
77
  export const databaseEnvSuffix = (database) => database.name.toUpperCase().replaceAll('-', '_');
77
78
  /**
@@ -107,6 +108,17 @@ export const JOB_ID_LABEL = 'openupstream.io/job-id';
107
108
  export const RUN_TRIGGER_LABEL = 'openupstream.io/trigger';
108
109
  /** The folder under the backup bucket that holds one Database's base backups and WAL. */
109
110
  export const backupPrefix = (projectId, databaseId) => `${projectNamespace(projectId)}/${clusterName({ id: databaseId })}/`;
111
+ /**
112
+ * The server name its backups of `version` are archived under in its
113
+ * ObjectStore (Barman's `serverName`, decision 220): the Cluster's name for
114
+ * the major it was created with (`archiveVersion`), `<cluster>-pg<major>`
115
+ * for each major it was upgraded to. `pg_upgrade` makes a new system with
116
+ * timeline 1, whose WAL would mix with, and could overwrite, the old
117
+ * major's in one folder.
118
+ */
119
+ export const archiveServerName = (server, version, archiveVersion) => version === archiveVersion ? clusterName(server) : `${clusterName(server)}-pg${version}`;
120
+ /** The folder under the backup bucket of one server's archive under `serverName` (archiveServerName). */
121
+ export const archivePrefix = (projectId, serverName) => `${projectNamespace(projectId)}/${serverName}/`;
110
122
  /** Ids are lowercase UUIDs, as Postgres prints them; usable in DNS names. */
111
123
  export const UUID = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/;
112
124
  /** Project and Database names, and label values: a DNS label (the schema checks the same). */
@@ -128,6 +140,8 @@ export const INTERNAL_ROUTES_PATH = '/internal/v1/routes';
128
140
  export const INTERNAL_SERVICES_PATH = '/internal/v1/services';
129
141
  /** `GET` lists every Job with its Project, for the Jobs operator. */
130
142
  export const INTERNAL_JOBS_PATH = '/internal/v1/jobs';
143
+ /** `GET` lists every Function of a live Project, for the Functions operator (FunctionRow). */
144
+ export const INTERNAL_FUNCTIONS_PATH = '/internal/v1/functions';
131
145
  /**
132
146
  * For the madAuth sidecar, which passes on madAuth's events (decision 143):
133
147
  * `DELETE <path>/<user id>` removes a user madAuth deleted from every
@@ -140,15 +154,54 @@ export const INTERNAL_USERS_PATH = '/internal/v1/users';
140
154
  export const MADAUTH_ID = /^[A-Za-z0-9_-]{1,128}$/;
141
155
  export const internalUserPath = (subject) => `${INTERNAL_USERS_PATH}/${subject}`;
142
156
  export const internalApiKeyPath = (subject, apiKeyId) => `${INTERNAL_USERS_PATH}/${subject}/api-keys/${apiKeyId}`;
157
+ /**
158
+ * Whether an address has a pending invitation (decision 142), which lets it
159
+ * sign up while sign-up is closed: madAuth's sidecar asks before a new user
160
+ * is created. The address goes as the hex SHA-256 of its lowercased form,
161
+ * so no address is in a URL.
162
+ */
163
+ export const INTERNAL_INVITED_PATH = '/internal/v1/invited';
164
+ export const internalInvitedPath = (emailSha256Hex) => `${INTERNAL_INVITED_PATH}/${emailSha256Hex}`;
143
165
  /** An Account's usage of one month: `${INTERNAL_ACCOUNTS_PATH}/{id}/usage?month=YYYY-MM`, for the billing service. */
144
166
  export const internalUsagePath = (accountId, month) => `${INTERNAL_ACCOUNTS_PATH}/${accountId}/usage?month=${month}`;
167
+ /** The short form of each kind of Resource a Route targets in Kubernetes names. */
168
+ const ROUTED_KIND_LABEL = { bucket: 'bucket', service: 'svc', function: 'fn' };
145
169
  /**
146
170
  * The Traefik IngressRoute that serves one Resource under one Domain, in its
147
- * Project's namespace (decision 114): `domain-<id>-bucket-<id>` or
148
- * `domain-<id>-svc-<id>`. Traefik names each rule's metrics after it, so
149
- * metering reads the Resource from them.
171
+ * Project's namespace (decision 114): `domain-<id>-bucket-<id>`,
172
+ * `domain-<id>-svc-<id>` or `domain-<id>-fn-<id>`. Traefik names each
173
+ * rule's metrics after it, so metering reads the Resource from them.
174
+ */
175
+ export const ingressRouteName = (domainId, resource) => `domain-${domainId}-${ROUTED_KIND_LABEL[resource.kind]}-${resource.id}`;
176
+ const isRecord = (value) => typeof value === 'object' && value !== null && !Array.isArray(value);
177
+ const isFunctionRowOrigin = (value) => isRecord(value) &&
178
+ typeof value['name'] === 'string' &&
179
+ ((value['kind'] === 'bucket' && typeof value['bucketId'] === 'string' && typeof value['bucketName'] === 'string') ||
180
+ (value['kind'] === 'service' && typeof value['serviceId'] === 'string' && typeof value['port'] === 'number'));
181
+ /** Only the shape a Functions operator relies on; the control plane checked the values when it stored them. */
182
+ export const isFunctionRow = (value) => isRecord(value) &&
183
+ typeof value['id'] === 'string' &&
184
+ typeof value['projectId'] === 'string' &&
185
+ typeof value['componentDigest'] === 'string' &&
186
+ typeof value['memoryMb'] === 'number' &&
187
+ typeof value['cpuMs'] === 'number' &&
188
+ typeof value['timeoutMs'] === 'number' &&
189
+ Array.isArray(value['secrets']) &&
190
+ value['secrets'].every((name) => typeof name === 'string') &&
191
+ isRecord(value['variables']) &&
192
+ Object.values(value['variables']).every((text) => typeof text === 'string') &&
193
+ typeof value['envVersion'] === 'string' &&
194
+ Array.isArray(value['origins']) &&
195
+ value['origins'].every(isFunctionRowOrigin);
196
+ /** Whether a body of `INTERNAL_FUNCTIONS_PATH` has the shape of its rows. */
197
+ export const isFunctionRows = (body) => Array.isArray(body) && body.every(isFunctionRow);
198
+ /**
199
+ * The control plane's port that serves Functions' components to the runner
200
+ * (`GET componentPath(…)`, `application/wasm`): no authentication, so only
201
+ * the runner's namespace may reach it (control-plane/deploy).
150
202
  */
151
- export const ingressRouteName = (domainId, resource) => `domain-${domainId}-${resource.kind === 'bucket' ? 'bucket' : 'svc'}-${resource.id}`;
203
+ export const COMPONENTS_PORT = 8085;
204
+ export const componentPath = (projectId, digest) => `/components/${projectId}/${digest}`;
152
205
  /** The audience of the token a pod presents to the key API (decision 168); the Kubernetes API accepts no such token. */
153
206
  export const KEYS_AUDIENCE = 'openupstream-keys';
154
207
  /** The key API's port on the control plane's pods and its Kubernetes Service. */
@@ -227,6 +280,8 @@ export const serviceSpecVersion = (row) => [
227
280
  ...(row.memoryRequestMb === undefined ? [] : [`request:${row.memoryRequestMb}`]),
228
281
  // Only when not the default, so a Service that bursts 2× keeps the version it had.
229
282
  ...(row.service.cpuBurst === DEFAULT_CPU_BURST ? [] : [`burst:${row.service.cpuBurst}`]),
283
+ // Only when not the default, so a Service that overlaps keeps the version it had.
284
+ ...(row.service.rollout === undefined || row.service.rollout === DEFAULT_SERVICE_ROLLOUT ? [] : [`rollout:${row.service.rollout}`]),
230
285
  ].join('|');
231
286
  /**
232
287
  * Everything of a Job's row that its CronJob is rendered from. The Jobs
@@ -282,6 +337,8 @@ export const PLATFORM = {
282
337
  autoGrow: true,
283
338
  maxStorageGb: null,
284
339
  tier: 'production',
340
+ // The platform's own servers stay on the major they were made with; upgrading one is a runbook's step.
341
+ postgresVersion: 17,
285
342
  createdAt: '2026-10-17T00:00:00Z',
286
343
  },
287
344
  authDatabase: {
@@ -294,6 +351,7 @@ export const PLATFORM = {
294
351
  autoGrow: true,
295
352
  maxStorageGb: null,
296
353
  tier: 'production',
354
+ postgresVersion: 17,
297
355
  createdAt: '2026-10-17T00:00:00Z',
298
356
  },
299
357
  /** The billing service's state; seeded only where a billing service runs (BILLING_CALLERS). */
@@ -307,6 +365,7 @@ export const PLATFORM = {
307
365
  autoGrow: true,
308
366
  maxStorageGb: null,
309
367
  tier: 'production',
368
+ postgresVersion: 17,
310
369
  createdAt: '2026-10-20T00:00:00Z',
311
370
  },
312
371
  };
@@ -1 +1 @@
1
- {"version":3,"file":"internal.js","sourceRoot":"","sources":["../src/internal.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAE/C;;;GAGG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,SAAa,EAAU,EAAE,CAAC,WAAW,SAAS,EAAE,CAAC;AAElF,qGAAqG;AACrG,MAAM,CAAC,MAAM,WAAW,GAAG,CAAC,QAA8B,EAAU,EAAE,CAAC,MAAM,QAAQ,CAAC,EAAE,EAAE,CAAC;AAE3F,kGAAkG;AAClG,MAAM,CAAC,MAAM,UAAU,GAAG,CAAC,QAA8B,EAAU,EAAE,CAAC,GAAG,WAAW,CAAC,QAAQ,CAAC,SAAS,CAAC;AAExG;;;GAGG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,QAA8B,EAAU,EAAE,CAAC,GAAG,UAAU,CAAC,QAAQ,CAAC,KAAK,CAAC;AAEvG;;;;GAIG;AACH,MAAM,CAAC,MAAM,2BAA2B,GAAG,GAAG,CAAC;AAE/C,MAAM,CAAC,MAAM,qBAAqB,GAAG,CAAC,QAAgB,EAAU,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,QAAQ,GAAG,2BAA2B,CAAC,GAAG,IAAI,CAAC,CAAC;AAE9H,2EAA2E;AAC3E,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAAC,QAA8B,EAAU,EAAE,CAAC,GAAG,WAAW,CAAC,QAAQ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I;QAClB,IAAI,EAAE,YAAY;QAClB,eAAe,EAAE,EAAE;QACnB,SAAS,EAAE,sBAAsB;KACpC;CAOJ,CAAC;AAEF,kHAAkH;AAClH,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,QAAc,EAAiB,EAAE,CAAC;IAC3D,EAAE,OAAO,EAAE,QAAQ,CAAC,OAAO,EAAE,QAAQ,EAAE,EAAE,GAAG,QAAQ,CAAC,QAAQ,EAAE,QAAQ,EAAE,EAAE;IAC3E,EAAE,OAAO,EAAE,QAAQ,CAAC,OAAO,EAAE,QAAQ,EAAE,EAAE,GAAG,QAAQ,CAAC,YAAY,EAAE,QAAQ,EAAE,EAAE;CAClF,CAAC"}
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
- /** Renames an Account token or changes its role; a lost role drops its Postgres roles its grants do not allow. */
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 {
@@ -394,6 +472,23 @@ export declare const DATABASE_MIN_MEMORY_MB = 256;
394
472
  export declare const POSTGRES_TIERS: readonly ["production", "development"];
395
473
  export type PostgresTier = (typeof POSTGRES_TIERS)[number];
396
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;
397
492
  export interface Database {
398
493
  id: Id;
399
494
  projectId: Id;
@@ -412,6 +507,8 @@ export interface Database {
412
507
  maxStorageGb: number | null;
413
508
  /** Its server's tier (decision 201). */
414
509
  tier: PostgresTier;
510
+ /** Its server's Postgres major version (decision 220). */
511
+ postgresVersion: number;
415
512
  createdAt: Timestamp;
416
513
  /** Set when the Database started as a copy of another one. */
417
514
  restoredFrom?: DatabaseRestore;
@@ -445,6 +542,19 @@ export interface PostgresServer {
445
542
  maxStorageGb: number | null;
446
543
  /** Production or development (decision 201). */
447
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
+ };
448
558
  createdAt: Timestamp;
449
559
  /** Its live Databases, oldest first. */
450
560
  databases: {
@@ -526,6 +636,12 @@ export interface DatabaseInput {
526
636
  restoreFrom?: DatabaseRestore;
527
637
  /** Its server's tier (decision 201); default `production`. */
528
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;
529
645
  /**
530
646
  * The name of the Postgres server created with it (decision 189);
531
647
  * default: the Database's name.
@@ -559,16 +675,25 @@ export interface DatabasePatch {
559
675
  * standby and stops backups, keeping the existing ones.
560
676
  */
561
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;
562
686
  }
563
687
  /**
564
688
  * - `provisioning`: being created, or not yet seen by the operator
565
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
566
691
  * - `ready`: both instances healthy
567
692
  * - `degraded`: running, but not every instance is healthy (e.g. during a
568
693
  * failover)
569
694
  * - `unknown`: the platform could not check just now
570
695
  */
571
- export type DatabaseState = 'provisioning' | 'resizing' | 'ready' | 'degraded' | 'unknown';
696
+ export type DatabaseState = 'provisioning' | 'resizing' | 'upgrading' | 'ready' | 'degraded' | 'unknown';
572
697
  /**
573
698
  * Where the Project's Services and Jobs reach the Database: through its
574
699
  * PgBouncer (transaction pooling), inside the cluster only. The password is
@@ -694,6 +819,16 @@ export declare const SERVICE_LIMITS: {
694
819
  export declare const CPU_BURSTS: readonly [1, 2, 4];
695
820
  export type CpuBurst = (typeof CPU_BURSTS)[number];
696
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;
697
832
  /**
698
833
  * A container, always on, 1..N replicas (ARCHITECTURE.md, "Containers"):
699
834
  * an HTTP server, or a worker without a port. Its image is pinned to a
@@ -715,6 +850,8 @@ export interface Service {
715
850
  cpuMillicores: number;
716
851
  /** How far it may use idle CPU beyond `cpuMillicores` (CPU_BURSTS). */
717
852
  cpuBurst: CpuBurst;
853
+ /** How its pods are replaced on a rollout (SERVICE_ROLLOUTS). */
854
+ rollout: ServiceRollout;
718
855
  /**
719
856
  * The HTTP port the container listens on; null: a worker, which no Route
720
857
  * can serve, gets no in-cluster address and counts as ready once it runs
@@ -790,6 +927,8 @@ export interface ServiceInput {
790
927
  cpuMillicores: number;
791
928
  /** Default DEFAULT_CPU_BURST. */
792
929
  cpuBurst?: CpuBurst;
930
+ /** Default DEFAULT_SERVICE_ROLLOUT. */
931
+ rollout?: ServiceRollout;
793
932
  homeSite?: Site;
794
933
  registryAuth?: RegistryAuth;
795
934
  /** Names of Secrets of the Project; default none. An unknown name is refused. */
@@ -817,6 +956,7 @@ export interface ServicePatch {
817
956
  memoryMb?: number;
818
957
  cpuMillicores?: number;
819
958
  cpuBurst?: CpuBurst;
959
+ rollout?: ServiceRollout;
820
960
  homeSite?: Site | null;
821
961
  registryAuth?: RegistryAuth | null;
822
962
  /** Replaces the whole list. */
@@ -873,6 +1013,93 @@ export interface ServiceDetails extends Service {
873
1013
  */
874
1014
  overridden: string[];
875
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'>>;
876
1103
  /** Limits of a Job, checked by the API; memory and CPU as for a Service. */
877
1104
  export declare const JOB_LIMITS: {
878
1105
  readonly minMemoryMb: 64;
@@ -1088,9 +1315,9 @@ export interface Secret {
1088
1315
  name: string;
1089
1316
  createdAt: Timestamp;
1090
1317
  updatedAt: Timestamp;
1091
- /** The Services and Jobs that name it: only their containers get it, and a change restarts those Services. Empty: unused. */
1318
+ /** The Services, Jobs and Functions that name it: only they get it, and a change restarts those Services. Empty: unused. */
1092
1319
  usedBy: {
1093
- kind: 'service' | 'job';
1320
+ kind: 'service' | 'job' | 'function';
1094
1321
  id: Id;
1095
1322
  name: string;
1096
1323
  }[];
@@ -1258,10 +1485,13 @@ export type RouteTarget = {
1258
1485
  } | {
1259
1486
  kind: 'service';
1260
1487
  serviceId: Id;
1488
+ } | {
1489
+ kind: 'function';
1490
+ functionId: Id;
1261
1491
  };
1262
1492
  /**
1263
- * One entry under a Domain: everything below `pathPrefix` goes to a Bucket or
1264
- * 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.
1265
1495
  */
1266
1496
  export interface Route {
1267
1497
  id: Id;
@@ -1276,7 +1506,7 @@ export interface Route {
1276
1506
  * Bucket the prefix is stripped: `/docs/a.html` on the Route `/docs` serves
1277
1507
  * the object `a.html`. With `spaFallback`, a path with no object serves
1278
1508
  * `index.html` with status 200; every Route to one Bucket has the same
1279
- * `spaFallback`. A Service gets the path unchanged.
1509
+ * `spaFallback`. A Service and a Function get the path unchanged.
1280
1510
  */
1281
1511
  export type RouteInput = {
1282
1512
  pathPrefix: string;
@@ -1286,9 +1516,13 @@ export type RouteInput = {
1286
1516
  pathPrefix: string;
1287
1517
  /** The Service gets the request with its path as it came, prefix included. */
1288
1518
  serviceId: Id;
1519
+ } | {
1520
+ pathPrefix: string;
1521
+ /** The Function gets the request with its path as it came, prefix included. */
1522
+ functionId: Id;
1289
1523
  };
1290
- /** `database` for usage before decision 189; a Postgres server's since. */
1291
- export declare const RESOURCE_KINDS: readonly ["database", "postgres_server", "bucket", "service", "job"];
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"];
1292
1526
  export type ResourceKind = (typeof RESOURCE_KINDS)[number];
1293
1527
  /**
1294
1528
  * One running copy of a Resource: an instance or a PgBouncer of a Database,
@@ -1325,6 +1559,18 @@ export interface Measured {
1325
1559
  used: number | null;
1326
1560
  allocated: number | null;
1327
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
+ }
1328
1574
  /**
1329
1575
  * A Resource's current use (ARCHITECTURE.md, decision 124): the sum over
1330
1576
  * its instances for CPU and memory (a Database's memory: its Postgres
@@ -1341,6 +1587,25 @@ export interface ResourceUsage {
1341
1587
  memoryBytes: Measured;
1342
1588
  storageBytes: Measured;
1343
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;
1344
1609
  }
1345
1610
  export interface ProjectUsage {
1346
1611
  measuredAt: Timestamp;
@@ -1418,9 +1683,12 @@ export interface ProjectAlerts {
1418
1683
  * `postgres_dev_memory_gb_hours` and `postgres_dev_storage_gb_hours`
1419
1684
  * (development, decision 201), and were `memory_gb_hours` and
1420
1685
  * `storage_gb_hours` before. Events are never rewritten, so the older
1421
- * units stay for the events from before.
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.
1422
1690
  */
1423
- 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"];
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"];
1424
1692
  export type UsageUnit = (typeof USAGE_UNITS)[number];
1425
1693
  /** A Resource consumed `quantity` of `unit` between `intervalStart` and `intervalEnd`. */
1426
1694
  export interface UsageEvent {