primitive-functions 0.3.0-alpha.16 → 0.3.0-alpha.17

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.
Files changed (4) hide show
  1. package/README.md +3 -3
  2. package/index.d.ts +764 -264
  3. package/index.js +32 -0
  4. package/package.json +1 -1
package/index.d.ts CHANGED
@@ -5,7 +5,7 @@
5
5
 
6
6
  /**
7
7
  * Type surface of `primitive-functions` — what a server function's author writes
8
- * against (#3180). The published package's RUNTIME is a stub that throws from
8
+ * against. The published package's RUNTIME is a stub that throws from
9
9
  * every export on purpose: the platform substitutes its own copy at invoke
10
10
  * time, and reaching the stub means it did not.
11
11
  *
@@ -32,7 +32,7 @@
32
32
  /**
33
33
  * The signed-in user who invoked the function over HTTP.
34
34
  *
35
- * Attribution, never authority (#3279): function code acts as the system
35
+ * Attribution, never authority: function code acts as the system
36
36
  * whoever called it, so this says WHO asked, and the rows the function writes
37
37
  * are attributed to them. A trigger fire has no caller and `ctx.user` is
38
38
  * null.
@@ -54,7 +54,7 @@ export type FunctionTrigger =
54
54
  /**
55
55
  * An HTTP invocation: the caller is `ctx.user`.
56
56
  *
57
- * `runKey` is the key a `start` was coalesced by (#3562) — what you
57
+ * `runKey` is the key a `start` was coalesced by — what you
58
58
  * passed as `runKey` to make the run a singleton — and null when the
59
59
  * start named none, or when the call was an `invoke`, which coalesces
60
60
  * nothing.
@@ -83,11 +83,11 @@ export type FunctionTrigger =
83
83
  manual?: true;
84
84
  }
85
85
  /**
86
- * Another function started this one with `ctx.functions.start` (#3280).
86
+ * Another function started this one with `ctx.functions.start`.
87
87
  *
88
88
  * `functionKey` names the PARENT, and `runId` its run — null when the
89
89
  * parent was a request invocation over HTTP, which writes no run row.
90
- * `runKey` is the key the parent's start named, or null (#3562).
90
+ * `runKey` is the key the parent's start named, or null.
91
91
  */
92
92
  | {
93
93
  kind: "function";
@@ -97,12 +97,12 @@ export type FunctionTrigger =
97
97
  }
98
98
  /**
99
99
  * An admin ran this function as the SYSTEM, from outside any trigger
100
- * (#3448) — `primitive functions invoke --as system`.
100
+ * — `primitive functions invoke --as system`.
101
101
  *
102
102
  * `ctx.user` is null and the code runs with the app's system authority, as
103
103
  * it does for a cron or webhook fire. `userId` names the admin who asked:
104
104
  * attribution, never the principal the code runs as. `runKey` is the key
105
- * the admin's start named, or null (#3562).
105
+ * the admin's start named, or null.
106
106
  */
107
107
  | { kind: "manual"; userId: string; runKey: string | null }
108
108
  /**
@@ -236,8 +236,8 @@ export interface PrimitivePlatformError extends Error {
236
236
  status: number;
237
237
  errorCode: string | null;
238
238
  /**
239
- * The route's structured `details`, or null when its refusal carries none
240
- * (#3803). `AGENT_SESSION_VARIABLES_INVALID` lists `errors` as
239
+ * The route's structured `details`, or null when its refusal carries none.
240
+ * `AGENT_SESSION_VARIABLES_INVALID` lists `errors` as
241
241
  * `{ path, message }`.
242
242
  */
243
243
  details: unknown;
@@ -291,11 +291,11 @@ export interface CollectionCreateBody {
291
291
  * type-checks is a method the platform publishes — and a missing path
292
292
  * parameter or a missing required header is a compile error rather than a
293
293
  * `TypeError` at invoke time. Every call runs with the app's own SYSTEM
294
- * authority (#3279): the invocation gate was the authorization. The two
294
+ * authority: the invocation gate was the authorization. The two
295
295
  * namespaces the gateway does not admit are still declared: they exist, they
296
296
  * answer the gateway's structured denial, and hiding them would make a route's
297
297
  * availability look like a typo. Those are `databaseTypeConfigs` whole, and
298
- * `functions` except for `functions.start` — the nested-start door #3280
298
+ * `functions` except for `functions.start` — the nested-start door
299
299
  * admits by name, which `ctx.functions.start` calls. `functions.invoke`
300
300
  * stays refused: same-run composition is an import.
301
301
  */
@@ -371,7 +371,7 @@ export interface FunctionApi {
371
371
  * `agentSessions.attachments.downloadUrl` — GET /agent-sessions/{sessionId}/attachments/{blobId}/download. Download an agent session attachment
372
372
  * @beta
373
373
  */
374
- "downloadUrl"(args: {
374
+ "download"(args: {
375
375
  "sessionId": string | number;
376
376
  "blobId": string | number;
377
377
  "disposition"?: string | number | boolean;
@@ -429,9 +429,9 @@ export interface FunctionApi {
429
429
  scope?: string;
430
430
  /** 1 to 255 characters; defaults to the agent's display name. */
431
431
  title?: string;
432
- /** Initial participants (they send, answer and upload): existing users of this app, distinct, not the caller. Together with `viewers` at most 50 (#3805). */
432
+ /** Initial participants (they send, answer and upload): existing users of this app, distinct, not the caller. Together with `viewers` at most 50. */
433
433
  participants?: string[];
434
- /** Initial viewers (they read the session's db3): existing users of this app, distinct, in neither list twice, not the caller (#3805). */
434
+ /** Initial viewers (they read the session's db3): existing users of this app, distinct, in neither list twice, not the caller. */
435
435
  viewers?: string[];
436
436
  /** Whose session: the member who owns it. Omitted means the caller. An app owner or admin, or a server function run with no caller or one an app owner or admin invoked, may name another member; a run with no caller must name one (`FUNCTION_SUBJECT_REQUIRED`). An ordinary member's run may name another member only when its function declares `users:readAny` (on a read) or `users:actAsAny` (on a call that acts as them), and a run an agent drives never may (`SUBJECT_USER_FORBIDDEN`). */
437
437
  userId?: string;
@@ -1223,6 +1223,31 @@ export interface FunctionApi {
1223
1223
  expiresAt: number;
1224
1224
  expiresInSeconds: number;
1225
1225
  }>;
1226
+ /**
1227
+ * `blobBuckets.getSignedUrls` — POST /blob-buckets/{bucketId}/blobs/signed-urls. Create signed download URLs for many blobs
1228
+ * @beta
1229
+ */
1230
+ "getSignedUrls"(args: {
1231
+ "bucketId": string | number;
1232
+ body: {
1233
+ /** The blobs to sign, 0 to 100 non-empty ids */
1234
+ blobIds: string[];
1235
+ /** How long every URL works, in seconds: 30 to 86,400; 300 when absent */
1236
+ expiresInSeconds?: number;
1237
+ };
1238
+ }): Promise<{
1239
+ items: {
1240
+ blobId: string;
1241
+ /** Downloads the blob with no credential until `expiresAt` */
1242
+ url: string;
1243
+ token: string;
1244
+ }[];
1245
+ /** Authorized ids with no object */
1246
+ missing: string[];
1247
+ /** When every URL stops working, in unix seconds */
1248
+ expiresAt: number;
1249
+ expiresInSeconds: number;
1250
+ }>;
1226
1251
  /** `blobBuckets.list` — GET /blob-buckets/{bucketId}/blobs. List blobs in a bucket (anonymous allowed for public buckets) */
1227
1252
  "list"(args: {
1228
1253
  "bucketId": string | number;
@@ -1354,7 +1379,7 @@ export interface FunctionApi {
1354
1379
  body: {
1355
1380
  userId: string;
1356
1381
  role?: "owner" | "manager" | "editor" | "contributor" | "viewer";
1357
- /** Deprecated (removal: #4718): send `role`. `reader` is viewer, `read-write` is editor. @deprecated */
1382
+ /** Deprecated: send `role`. `reader` is viewer, `read-write` is editor. @deprecated */
1358
1383
  permission?: "reader" | "read-write";
1359
1384
  sendEmail?: boolean;
1360
1385
  collectionUrl?: string;
@@ -1362,17 +1387,17 @@ export interface FunctionApi {
1362
1387
  } | {
1363
1388
  email: string;
1364
1389
  role?: "owner" | "manager" | "editor" | "contributor" | "viewer";
1365
- /** Deprecated (removal: #4718): send `role`. `reader` is viewer, `read-write` is editor. @deprecated */
1390
+ /** Deprecated: send `role`. `reader` is viewer, `read-write` is editor. @deprecated */
1366
1391
  permission?: "reader" | "read-write";
1367
1392
  sendEmail?: boolean;
1368
1393
  collectionUrl?: string;
1369
1394
  note?: string;
1370
1395
  } | {
1371
1396
  groupId: string;
1372
- /** Deprecated (removal: #4718): groups are addressed by `groupId` alone; a sent type is looked up first. @deprecated */
1397
+ /** Deprecated: groups are addressed by `groupId` alone; a sent type is looked up first. @deprecated */
1373
1398
  groupType?: string;
1374
1399
  role?: "manager" | "editor" | "contributor" | "viewer";
1375
- /** Deprecated (removal: #4718): send `role`. `reader` is viewer, `read-write` is editor. @deprecated */
1400
+ /** Deprecated: send `role`. `reader` is viewer, `read-write` is editor. @deprecated */
1376
1401
  permission?: "reader" | "read-write";
1377
1402
  };
1378
1403
  }): Promise<{
@@ -1380,13 +1405,13 @@ export interface FunctionApi {
1380
1405
  userId?: string;
1381
1406
  principal?: string;
1382
1407
  groupId?: string;
1383
- /** Deprecated (removal: #4718): groups are addressed by `groupId` alone. @deprecated */
1408
+ /** Deprecated: groups are addressed by `groupId` alone. @deprecated */
1384
1409
  groupType?: string;
1385
1410
  role?: "owner" | "manager" | "editor" | "contributor" | "viewer";
1386
- /** Deprecated (removal: #4718): read `role`. `reader` for viewer and contributor, `read-write` for editor, manager and owner. @deprecated */
1411
+ /** Deprecated: read `role`. `reader` for viewer and contributor, `read-write` for editor, manager and owner. @deprecated */
1387
1412
  permission?: string;
1388
1413
  addedAt?: string | null;
1389
- /** Deprecated (removal: #4718): kept for clients built before collection roles; read `role`. @deprecated */
1414
+ /** Deprecated: kept for clients built before collection roles; read `role`. @deprecated */
1390
1415
  addedBy?: string | null;
1391
1416
  userName?: string;
1392
1417
  userEmail?: string;
@@ -1406,7 +1431,7 @@ export interface FunctionApi {
1406
1431
  appId: string;
1407
1432
  name: string;
1408
1433
  description?: string | null;
1409
- /** Deprecated (removal: #4718): read `role` and `settings`. The stored type, or `default`, while the type's rule set still governs the collection; `default` once fixed roles do. @deprecated */
1434
+ /** Deprecated: read `role` and `settings`. The stored type, or `default`, while the type's rule set still governs the collection; `default` once fixed roles do. @deprecated */
1410
1435
  collectionType: string;
1411
1436
  documentCount?: number;
1412
1437
  /** Who created the collection: the caller, never the custodian it named. */
@@ -1434,7 +1459,7 @@ export interface FunctionApi {
1434
1459
  appId: string;
1435
1460
  name: string;
1436
1461
  description?: string | null;
1437
- /** Deprecated (removal: #4718): read `role` and `settings`. The stored type, or `default`, while the type's rule set still governs the collection; `default` once fixed roles do. @deprecated */
1462
+ /** Deprecated: read `role` and `settings`. The stored type, or `default`, while the type's rule set still governs the collection; `default` once fixed roles do. @deprecated */
1438
1463
  collectionType: string;
1439
1464
  documentCount?: number;
1440
1465
  /** Who created the collection: the caller, never the custodian it named. */
@@ -1449,18 +1474,18 @@ export interface FunctionApi {
1449
1474
  };
1450
1475
  }>;
1451
1476
  /**
1452
- * `collections.getAccess` — GET /collections/{collectionId}/access. DEPRECATED — Get a collection's access summary; use GET /collections/{collectionId}/members (removal: #4718)
1453
- * @deprecated Use GET /collections/{collectionId}/members (removal: #4718)
1477
+ * `collections.getAccess` — GET /collections/{collectionId}/access. DEPRECATED — Get a collection's access summary; use GET /collections/{collectionId}/members
1478
+ * @deprecated Use GET /collections/{collectionId}/members
1454
1479
  */
1455
1480
  "getAccess"(args: {
1456
1481
  "collectionId": string | number;
1457
1482
  }): Promise<{
1458
1483
  groups: {
1459
1484
  collectionId: string;
1460
- /** Deprecated (removal: #4718): groups are addressed by `groupId` alone. @deprecated */
1485
+ /** Deprecated: groups are addressed by `groupId` alone. @deprecated */
1461
1486
  groupType: string;
1462
1487
  groupId: string;
1463
- /** Deprecated (removal: #4718): read `role`. `reader` for viewer and contributor, `read-write` for editor, manager and owner. @deprecated */
1488
+ /** Deprecated: read `role`. `reader` for viewer and contributor, `read-write` for editor, manager and owner. @deprecated */
1464
1489
  permission: string;
1465
1490
  role?: "owner" | "manager" | "editor" | "contributor" | "viewer";
1466
1491
  grantedAt?: string | null;
@@ -1468,34 +1493,34 @@ export interface FunctionApi {
1468
1493
  }[];
1469
1494
  members: {
1470
1495
  userId: string;
1471
- /** Deprecated (removal: #4718): read `role`. `reader` for viewer and contributor, `read-write` for editor, manager and owner. @deprecated */
1496
+ /** Deprecated: read `role`. `reader` for viewer and contributor, `read-write` for editor, manager and owner. @deprecated */
1472
1497
  permission: string;
1473
1498
  role?: "owner" | "manager" | "editor" | "contributor" | "viewer";
1474
1499
  addedAt?: string | null;
1475
- /** Deprecated (removal: #4718): kept for clients built before collection roles; read `role`. @deprecated */
1500
+ /** Deprecated: kept for clients built before collection roles; read `role`. @deprecated */
1476
1501
  addedBy?: string | null;
1477
1502
  }[];
1478
1503
  }>;
1479
1504
  /**
1480
- * `collections.grantGroupPermission` — POST /collections/{collectionId}/group-permissions. DEPRECATED — Grant a group permission on a collection; use POST /collections/{collectionId}/members with groupId and role (removal: #4718)
1481
- * @deprecated Use POST /collections/{collectionId}/members with groupId and role (removal: #4718)
1505
+ * `collections.grantGroupPermission` — POST /collections/{collectionId}/group-permissions. DEPRECATED — Grant a group permission on a collection; use POST /collections/{collectionId}/members with groupId and role
1506
+ * @deprecated Use POST /collections/{collectionId}/members with groupId and role
1482
1507
  */
1483
1508
  "grantGroupPermission"(args: {
1484
1509
  "collectionId": string | number;
1485
1510
  body: {
1486
- /** Deprecated (removal: #4718): groups are addressed by `groupId` alone; a sent type is looked up first. @deprecated */
1511
+ /** Deprecated: groups are addressed by `groupId` alone; a sent type is looked up first. @deprecated */
1487
1512
  groupType?: string;
1488
1513
  groupId: string;
1489
1514
  role?: "manager" | "editor" | "contributor" | "viewer";
1490
- /** Deprecated (removal: #4718): send `role`. `reader` is viewer, `read-write` is editor. @deprecated */
1515
+ /** Deprecated: send `role`. `reader` is viewer, `read-write` is editor. @deprecated */
1491
1516
  permission?: "reader" | "read-write";
1492
1517
  };
1493
1518
  }): Promise<{
1494
1519
  collectionId: string;
1495
- /** Deprecated (removal: #4718): groups are addressed by `groupId` alone. @deprecated */
1520
+ /** Deprecated: groups are addressed by `groupId` alone. @deprecated */
1496
1521
  groupType: string;
1497
1522
  groupId: string;
1498
- /** Deprecated (removal: #4718): read `role`. `reader` for viewer and contributor, `read-write` for editor, manager and owner. @deprecated */
1523
+ /** Deprecated: read `role`. `reader` for viewer and contributor, `read-write` for editor, manager and owner. @deprecated */
1499
1524
  permission: string;
1500
1525
  role?: "owner" | "manager" | "editor" | "contributor" | "viewer";
1501
1526
  grantedAt?: string | null;
@@ -1512,7 +1537,7 @@ export interface FunctionApi {
1512
1537
  appId: string;
1513
1538
  name: string;
1514
1539
  description?: string | null;
1515
- /** Deprecated (removal: #4718): read `role` and `settings`. The stored type, or `default`, while the type's rule set still governs the collection; `default` once fixed roles do. @deprecated */
1540
+ /** Deprecated: read `role` and `settings`. The stored type, or `default`, while the type's rule set still governs the collection; `default` once fixed roles do. @deprecated */
1516
1541
  collectionType: string;
1517
1542
  documentCount?: number;
1518
1543
  createdBy?: string | null;
@@ -1525,7 +1550,7 @@ export interface FunctionApi {
1525
1550
  };
1526
1551
  /** The listed user's role on the collection, held directly. */
1527
1552
  role?: "owner" | "manager" | "editor" | "contributor" | "viewer";
1528
- /** Deprecated (removal: #4718): read `role`. `reader` for viewer and contributor, `read-write` for editor, manager and owner. @deprecated */
1553
+ /** Deprecated: read `role`. `reader` for viewer and contributor, `read-write` for editor, manager and owner. @deprecated */
1529
1554
  permission: "reader" | "read-write";
1530
1555
  }[];
1531
1556
  hasMore: boolean;
@@ -1546,7 +1571,7 @@ export interface FunctionApi {
1546
1571
  appId: string;
1547
1572
  name: string;
1548
1573
  description?: string | null;
1549
- /** Deprecated (removal: #4718): read `role` and `settings`. The stored type, or `default`, while the type's rule set still governs the collection; `default` once fixed roles do. @deprecated */
1574
+ /** Deprecated: read `role` and `settings`. The stored type, or `default`, while the type's rule set still governs the collection; `default` once fixed roles do. @deprecated */
1550
1575
  collectionType: string;
1551
1576
  documentCount?: number;
1552
1577
  /** Who created the collection: the caller, never the custodian it named. */
@@ -1652,7 +1677,7 @@ export interface FunctionApi {
1652
1677
  appId: string;
1653
1678
  name: string;
1654
1679
  description?: string | null;
1655
- /** Deprecated (removal: #4718): read `role` and `settings`. The stored type, or `default`, while the type's rule set still governs the collection; `default` once fixed roles do. @deprecated */
1680
+ /** Deprecated: read `role` and `settings`. The stored type, or `default`, while the type's rule set still governs the collection; `default` once fixed roles do. @deprecated */
1656
1681
  collectionType: string;
1657
1682
  documentCount?: number;
1658
1683
  createdBy?: string | null;
@@ -1665,7 +1690,7 @@ export interface FunctionApi {
1665
1690
  };
1666
1691
  /** The listed user's role on the collection, held directly. */
1667
1692
  role?: "owner" | "manager" | "editor" | "contributor" | "viewer";
1668
- /** Deprecated (removal: #4718): read `role`. `reader` for viewer and contributor, `read-write` for editor, manager and owner. @deprecated */
1693
+ /** Deprecated: read `role`. `reader` for viewer and contributor, `read-write` for editor, manager and owner. @deprecated */
1669
1694
  permission: "reader" | "read-write";
1670
1695
  }[];
1671
1696
  hasMore: boolean;
@@ -1683,13 +1708,13 @@ export interface FunctionApi {
1683
1708
  userId?: string;
1684
1709
  /** A group member's id. */
1685
1710
  groupId?: string;
1686
- /** Deprecated (removal: #4718): groups are addressed by `groupId` alone. @deprecated */
1711
+ /** Deprecated: groups are addressed by `groupId` alone. @deprecated */
1687
1712
  groupType?: string;
1688
1713
  role: "owner" | "manager" | "editor" | "contributor" | "viewer";
1689
- /** Deprecated (removal: #4718): read `role`. `reader` for viewer and contributor, `read-write` for editor, manager and owner. @deprecated */
1714
+ /** Deprecated: read `role`. `reader` for viewer and contributor, `read-write` for editor, manager and owner. @deprecated */
1690
1715
  permission: string;
1691
1716
  addedAt?: string | null;
1692
- /** Deprecated (removal: #4718): kept for clients built before collection roles; read `role`. @deprecated */
1717
+ /** Deprecated: kept for clients built before collection roles; read `role`. @deprecated */
1693
1718
  addedBy?: string | null;
1694
1719
  }[];
1695
1720
  /** Always false: the list is complete. */
@@ -1702,7 +1727,7 @@ export interface FunctionApi {
1702
1727
  items: {
1703
1728
  email: string;
1704
1729
  role?: "owner" | "manager" | "editor" | "contributor" | "viewer";
1705
- /** Deprecated (removal: #4718): read `role`. @deprecated */
1730
+ /** Deprecated: read `role`. @deprecated */
1706
1731
  permission: "reader" | "read-write";
1707
1732
  invitationId: string;
1708
1733
  createdAt?: string | null;
@@ -1736,8 +1761,8 @@ export interface FunctionApi {
1736
1761
  };
1737
1762
  }>;
1738
1763
  /**
1739
- * `collections.revokeGroupPermission` — DELETE /collections/{collectionId}/group-permissions/{groupType}/{groupId}. DEPRECATED — Revoke a group permission on a collection, by type; use DELETE /collections/{collectionId}/members/group:{groupId} (removal: #4718)
1740
- * @deprecated Use DELETE /collections/{collectionId}/members/group:{groupId} (removal: #4718)
1764
+ * `collections.revokeGroupPermission` — DELETE /collections/{collectionId}/group-permissions/{groupType}/{groupId}. DEPRECATED — Revoke a group permission on a collection, by type; use DELETE /collections/{collectionId}/members/group:{groupId}
1765
+ * @deprecated Use DELETE /collections/{collectionId}/members/group:{groupId}
1741
1766
  */
1742
1767
  "revokeGroupPermission"(args: {
1743
1768
  "collectionId": string | number;
@@ -1774,13 +1799,13 @@ export interface FunctionApi {
1774
1799
  userId?: string;
1775
1800
  /** A group member's id. */
1776
1801
  groupId?: string;
1777
- /** Deprecated (removal: #4718): groups are addressed by `groupId` alone. @deprecated */
1802
+ /** Deprecated: groups are addressed by `groupId` alone. @deprecated */
1778
1803
  groupType?: string;
1779
1804
  role: "owner" | "manager" | "editor" | "contributor" | "viewer";
1780
- /** Deprecated (removal: #4718): read `role`. `reader` for viewer and contributor, `read-write` for editor, manager and owner. @deprecated */
1805
+ /** Deprecated: read `role`. `reader` for viewer and contributor, `read-write` for editor, manager and owner. @deprecated */
1781
1806
  permission: string;
1782
1807
  addedAt?: string | null;
1783
- /** Deprecated (removal: #4718): kept for clients built before collection roles; read `role`. @deprecated */
1808
+ /** Deprecated: kept for clients built before collection roles; read `role`. @deprecated */
1784
1809
  addedBy?: string | null;
1785
1810
  }>;
1786
1811
  /** `collections.transfer` — POST /collections/{collectionId}/transfer. Transfer a collection to another user or to the app */
@@ -1795,7 +1820,7 @@ export interface FunctionApi {
1795
1820
  appId: string;
1796
1821
  name: string;
1797
1822
  description?: string | null;
1798
- /** Deprecated (removal: #4718): read `role` and `settings`. The stored type, or `default`, while the type's rule set still governs the collection; `default` once fixed roles do. @deprecated */
1823
+ /** Deprecated: read `role` and `settings`. The stored type, or `default`, while the type's rule set still governs the collection; `default` once fixed roles do. @deprecated */
1799
1824
  collectionType: string;
1800
1825
  documentCount?: number;
1801
1826
  /** Who created the collection: the caller, never the custodian it named. */
@@ -1825,7 +1850,7 @@ export interface FunctionApi {
1825
1850
  appId: string;
1826
1851
  name: string;
1827
1852
  description?: string | null;
1828
- /** Deprecated (removal: #4718): read `role` and `settings`. The stored type, or `default`, while the type's rule set still governs the collection; `default` once fixed roles do. @deprecated */
1853
+ /** Deprecated: read `role` and `settings`. The stored type, or `default`, while the type's rule set still governs the collection; `default` once fixed roles do. @deprecated */
1829
1854
  collectionType: string;
1830
1855
  documentCount?: number;
1831
1856
  /** Who created the collection: the caller, never the custodian it named. */
@@ -1885,6 +1910,10 @@ export interface FunctionApi {
1885
1910
  /** Raw TOML; clients parse it themselves (round-2 decision). */
1886
1911
  schema?: string | null;
1887
1912
  metadataManifest?: Record<string, unknown> | null;
1913
+ /** `true` on an archived db3 type, which takes no new db3s; absent otherwise. Set with `PUT db3-types/:name`. */
1914
+ archived?: boolean;
1915
+ /** `admins` on a db3 type only app admins and owners create db3s of; absent otherwise. Set with `PUT db3-types/:name`. */
1916
+ create?: "admins";
1888
1917
  createdAt?: string;
1889
1918
  modifiedAt?: string;
1890
1919
  createdBy?: string;
@@ -1913,6 +1942,8 @@ export interface FunctionApi {
1913
1942
  ok: boolean;
1914
1943
  dryRun: boolean;
1915
1944
  databaseType: string;
1945
+ /** Present when the type has fields marked `deprecated` and not `cleared`: each as `<model>.<field>` */
1946
+ deprecatedFields?: string[];
1916
1947
  }>;
1917
1948
  /**
1918
1949
  * `databaseTypeConfigs.delete` — DELETE /databases/types/{databaseType}. Delete a database type
@@ -1941,6 +1972,10 @@ export interface FunctionApi {
1941
1972
  /** Raw TOML; clients parse it themselves (round-2 decision). */
1942
1973
  schema?: string | null;
1943
1974
  metadataManifest?: Record<string, unknown> | null;
1975
+ /** `true` on an archived db3 type, which takes no new db3s; absent otherwise. Set with `PUT db3-types/:name`. */
1976
+ archived?: boolean;
1977
+ /** `admins` on a db3 type only app admins and owners create db3s of; absent otherwise. Set with `PUT db3-types/:name`. */
1978
+ create?: "admins";
1944
1979
  createdAt?: string;
1945
1980
  modifiedAt?: string;
1946
1981
  createdBy?: string;
@@ -2001,6 +2036,10 @@ export interface FunctionApi {
2001
2036
  /** Raw TOML; clients parse it themselves (round-2 decision). */
2002
2037
  schema?: string | null;
2003
2038
  metadataManifest?: Record<string, unknown> | null;
2039
+ /** `true` on an archived db3 type, which takes no new db3s; absent otherwise. Set with `PUT db3-types/:name`. */
2040
+ archived?: boolean;
2041
+ /** `admins` on a db3 type only app admins and owners create db3s of; absent otherwise. Set with `PUT db3-types/:name`. */
2042
+ create?: "admins";
2004
2043
  createdAt?: string;
2005
2044
  modifiedAt?: string;
2006
2045
  createdBy?: string;
@@ -2062,6 +2101,10 @@ export interface FunctionApi {
2062
2101
  /** Raw TOML; clients parse it themselves (round-2 decision). */
2063
2102
  schema?: string | null;
2064
2103
  metadataManifest?: Record<string, unknown> | null;
2104
+ /** `true` on an archived db3 type, which takes no new db3s; absent otherwise. Set with `PUT db3-types/:name`. */
2105
+ archived?: boolean;
2106
+ /** `admins` on a db3 type only app admins and owners create db3s of; absent otherwise. Set with `PUT db3-types/:name`. */
2107
+ create?: "admins";
2065
2108
  createdAt?: string;
2066
2109
  modifiedAt?: string;
2067
2110
  createdBy?: string;
@@ -2100,12 +2143,28 @@ export interface FunctionApi {
2100
2143
  reasons?: {
2101
2144
  /** `models.<model>` or `models.<model>.fields.<field>` */
2102
2145
  path: string;
2103
- /** `model-removed`, `field-removed`, `field-type-changed`, `enum-value-removed`, `field-made-required`, `required-field-added` or `vector-changed` */
2146
+ /** `model-removed`, `field-removed`, `field-type-changed`, `enum-value-removed`, `field-made-required`, `required-field-added`, `vector-changed` or `cleared-field-required`; and, with `always: true`, `cleared-field-in-use`, `field-tombstoned-without-clear`, `tombstoned-name-declared`, `tombstone-removed`, `field-name-collision` or `hook-name-not-compilable` */
2104
2147
  change: string;
2105
2148
  /** The change and what to do instead */
2106
2149
  reason: string;
2150
+ /** `true` on a field lifecycle reason (`cleared-field-in-use`, `field-tombstoned-without-clear`, `tombstoned-name-declared`, `tombstone-removed`, `field-name-collision`, `hook-name-not-compilable`), which holds on every type, with or without db3s, and under `allowFieldRemoval`; absent otherwise */
2151
+ always?: boolean;
2107
2152
  }[];
2108
2153
  };
2154
+ /** Present when the type has fields marked `deprecated` and not `cleared`: each as `<model>.<field>` */
2155
+ deprecatedFields?: string[];
2156
+ /** Present when the write took `cleared` off fields: each as `<model>.<field>`. Values a db3 already dropped stay unset, and each device re-downloads each db3 of the type */
2157
+ unclearedFields?: string[];
2158
+ /** Present when the write renamed fields: each field whose key changed while its `storedAs` kept the stored name, as `{ model, storedAs, from, to }` */
2159
+ renamedFields?: {
2160
+ model: string;
2161
+ /** The field's stored name, which records hold */
2162
+ storedAs: string;
2163
+ /** The field's current name before the write */
2164
+ from: string;
2165
+ /** The field's current name after the write */
2166
+ to: string;
2167
+ }[];
2109
2168
  }>;
2110
2169
  };
2111
2170
  "databases": {
@@ -2183,7 +2242,7 @@ export interface FunctionApi {
2183
2242
  "grantGroupPermission"(args: {
2184
2243
  "databaseId": string | number;
2185
2244
  body: {
2186
- /** Deprecated (removal: #4718): groups are named by `groupId` alone. Given, the group is looked up by type first. @deprecated */
2245
+ /** Deprecated: groups are named by `groupId` alone. Given, the group is looked up by type first. @deprecated */
2187
2246
  groupType?: string;
2188
2247
  groupId: string;
2189
2248
  permission: "manager" | "owner";
@@ -2311,7 +2370,7 @@ export interface FunctionApi {
2311
2370
  update?: string[];
2312
2371
  };
2313
2372
  }[];
2314
- /** All-or-nothing (#1478). Default false: each operation's outcome is recorded independently and successful siblings commit. */
2373
+ /** All-or-nothing. Default false: each operation's outcome is recorded independently and successful siblings commit. */
2315
2374
  atomic?: boolean;
2316
2375
  };
2317
2376
  }): Promise<{
@@ -2319,7 +2378,7 @@ export interface FunctionApi {
2319
2378
  success: boolean;
2320
2379
  id: string;
2321
2380
  error?: string;
2322
- /** The natural HTTP status of a failure (#1478). */
2381
+ /** The natural HTTP status of a failure. */
2323
2382
  status?: number;
2324
2383
  code?: "NOT_FOUND" | "HOOK_DENIED" | "CONDITION_NOT_MET" | "ALREADY_EXISTS" | "UNIQUE_VIOLATION" | "VALIDATION_ERROR";
2325
2384
  /** The post-increment values, for increment. */
@@ -2634,8 +2693,8 @@ export interface FunctionApi {
2634
2693
  success: boolean;
2635
2694
  }>;
2636
2695
  /**
2637
- * `databases.revokeGroupPermissionByType` — DELETE /databases/{databaseId}/group-permissions/{groupType}/{groupId}. DEPRECATED — Revoke a group permission on a database, by type; use DELETE /databases/{databaseId}/group-permissions/{groupId} (removal: #4718)
2638
- * @deprecated Use DELETE /databases/{databaseId}/group-permissions/{groupId} (removal: #4718)
2696
+ * `databases.revokeGroupPermissionByType` — DELETE /databases/{databaseId}/group-permissions/{groupType}/{groupId}. DEPRECATED — Revoke a group permission on a database, by type; use DELETE /databases/{databaseId}/group-permissions/{groupId}
2697
+ * @deprecated Use DELETE /databases/{databaseId}/group-permissions/{groupId}
2639
2698
  */
2640
2699
  "revokeGroupPermissionByType"(args: {
2641
2700
  "databaseId": string | number;
@@ -2964,11 +3023,28 @@ export interface FunctionApi {
2964
3023
  "db3Id": string | number;
2965
3024
  "blobId": string | number;
2966
3025
  }): Promise<HeaderResult>;
3026
+ /**
3027
+ * `db3.blobs.downloadPublic` — GET /public/db3/{db3Id}/blobs/{blobId}. Download a public db3's blob, signed out
3028
+ * @beta
3029
+ */
3030
+ "downloadPublic"(args: {
3031
+ "db3Id": string | number;
3032
+ "blobId": string | number;
3033
+ }): Promise<Uint8Array>;
3034
+ /**
3035
+ * `db3.blobs.downloadSigned` — GET /db3/{db3Id}/blobs/{blobId}/signed. Download a db3 blob through a signed URL
3036
+ * @beta
3037
+ */
3038
+ "downloadSigned"(args: {
3039
+ "db3Id": string | number;
3040
+ "blobId": string | number;
3041
+ "token"?: string | number | boolean;
3042
+ }): Promise<Uint8Array>;
2967
3043
  /**
2968
3044
  * `db3.blobs.downloadUrl` — GET /db3/{db3Id}/blobs/{blobId}/download. Download a db3 blob's bytes
2969
3045
  * @beta
2970
3046
  */
2971
- "downloadUrl"(args: {
3047
+ "download"(args: {
2972
3048
  "db3Id": string | number;
2973
3049
  "blobId": string | number;
2974
3050
  "disposition"?: string | number | boolean;
@@ -2991,6 +3067,31 @@ export interface FunctionApi {
2991
3067
  /** 0 on the idempotent 200; the stored length on a 201. */
2992
3068
  bytesTransferred?: number;
2993
3069
  }>;
3070
+ /**
3071
+ * `db3.blobs.getSignedUrls` — POST /db3/{db3Id}/blobs/signed-urls. Mint signed download URLs for a db3's blobs
3072
+ * @beta
3073
+ */
3074
+ "getSignedUrls"(args: {
3075
+ "db3Id": string | number;
3076
+ "userId"?: string | number;
3077
+ body: {
3078
+ /** The blobs to sign, 0 to 100 blob ids (ULIDs); one URL each, in this order */
3079
+ blobIds: string[];
3080
+ /** How long every URL works, in seconds: 30 to 86,400 (3,600 in a signed-out run); 300 when absent */
3081
+ expiresInSeconds?: number;
3082
+ };
3083
+ }): Promise<{
3084
+ items: {
3085
+ blobId: string;
3086
+ /** Downloads the blob with no credential until `expiresAt` */
3087
+ url: string;
3088
+ /** The URL's token, its only credential */
3089
+ token: string;
3090
+ }[];
3091
+ /** When every URL stops working, in unix seconds */
3092
+ expiresAt: number;
3093
+ expiresInSeconds: number;
3094
+ }>;
2994
3095
  /**
2995
3096
  * `db3.blobs.list` — GET /db3/{db3Id}/blobs. List blobs attached to a db3
2996
3097
  * @beta
@@ -3013,6 +3114,36 @@ export interface FunctionApi {
3013
3114
  nextCursor?: string;
3014
3115
  prevCursor?: string;
3015
3116
  }>;
3117
+ /**
3118
+ * `db3.blobs.signedUploadUrl` — POST /db3/{db3Id}/blobs/signed-upload-url. Mint a signed upload URL for an app-held db3
3119
+ * @beta
3120
+ */
3121
+ "signedUploadUrl"(args: {
3122
+ "db3Id": string | number;
3123
+ body: {
3124
+ /** The largest upload accepted, in bytes: 1 to 10,485,760 */
3125
+ maxBytes: number;
3126
+ /** The one media type the upload must send as its `Content-Type`, lowercase, with no parameters (for example `image/png`) */
3127
+ contentType: string;
3128
+ /** How long the URL accepts its upload, in seconds: 30 to 3,600; 300 when absent */
3129
+ expiresInSeconds?: number;
3130
+ /** The stored blob's filename: 1 to 255 characters with no control characters, `/` or `\`; `upload` when absent */
3131
+ filename?: string;
3132
+ };
3133
+ }): Promise<{
3134
+ /** Where to `PUT` the file's bytes, with no credential */
3135
+ url: string;
3136
+ /** The URL's token, the upload's only credential */
3137
+ token: string;
3138
+ /** The token's id: the upload's answer names it, and `primitive spent-tokens get` reads its use */
3139
+ tokenId: string;
3140
+ maxBytes: number;
3141
+ contentType: string;
3142
+ filename: string;
3143
+ /** When the URL stops accepting its upload, in unix seconds */
3144
+ expiresAt: number;
3145
+ expiresInSeconds: number;
3146
+ }>;
3016
3147
  /**
3017
3148
  * `db3.blobs.upload` — PUT /db3/{db3Id}/blobs/{blobId}. Upload a db3 blob with a client-specified id (immutable + idempotent)
3018
3149
  * @beta
@@ -3455,6 +3586,12 @@ export interface FunctionApi {
3455
3586
  /** How the caller holds it: `owner`, `grant` (a direct grant), `group`, `link`, `app` (the db3's app access), or `resource` (a member of the resource that holds the db3, such as an agent session) */
3456
3587
  accessSource?: string;
3457
3588
  grantedAt?: string;
3589
+ /** `reader` while the db3 is public; present only then, and only for a caller who manages its sharing (an app owner or admin, a function, the db3's owner or a read-write grantee) */
3590
+ publicAccess?: "reader";
3591
+ /** Who last changed the db3's public access: a user id, or `sys:<appId>` for a function */
3592
+ publicAccessUpdatedBy?: string | null;
3593
+ /** When the db3's public access last changed */
3594
+ publicAccessUpdatedAt?: string | null;
3458
3595
  }>;
3459
3596
  /**
3460
3597
  * `db3.getAppAccess` — GET /db3/{db3Id}/app-access. Read a db3's app access
@@ -3617,7 +3754,7 @@ export interface FunctionApi {
3617
3754
  */
3618
3755
  "getOrCreateWithAlias"(args: {
3619
3756
  body: {
3620
- /** The alias to bind. `scope` must be `user` — app-scoped aliases were removed (#1168) — and `userId` defaults to the caller, which only an app admin may override. */
3757
+ /** The alias to bind. `scope` must be `user` — app-scoped aliases were removed — and `userId` defaults to the caller, which only an app admin may override. */
3621
3758
  alias: {
3622
3759
  scope: "user";
3623
3760
  aliasKey: string;
@@ -3626,13 +3763,13 @@ export interface FunctionApi {
3626
3763
  title?: string;
3627
3764
  /** Applied only when the alias is created here. */
3628
3765
  tags?: string[];
3629
- /** Not read by the handler; use `alias.scope`. Sending it is refused with 400 `VALIDATION_FAILED` (#3757). */
3766
+ /** Not read by the handler; use `alias.scope`. Sending it is refused with 400 `VALIDATION_FAILED`. */
3630
3767
  scope?: string;
3631
- /** Not read by the handler; use `alias.aliasKey`. Sending it is refused with 400 `VALIDATION_FAILED` (#3757). */
3768
+ /** Not read by the handler; use `alias.aliasKey`. Sending it is refused with 400 `VALIDATION_FAILED`. */
3632
3769
  aliasKey?: string;
3633
- /** Not read by the handler. Sending it is refused with 400 `VALIDATION_FAILED` (#3757). */
3770
+ /** Not read by the handler. Sending it is refused with 400 `VALIDATION_FAILED`. */
3634
3771
  name?: string;
3635
- /** Caller-defined metadata blob applied only when the alias is created here (#3757). */
3772
+ /** Caller-defined metadata blob applied only when the alias is created here. */
3636
3773
  metadata?: Record<string, unknown>;
3637
3774
  /** A db3 type of this app. Creating, its current revision is installed before the db3 answers; on an alias that already names a db3, a db3 of another type (or of none) is refused `DB3_TYPE_MISMATCH`. */
3638
3775
  type?: string;
@@ -3851,7 +3988,7 @@ export interface FunctionApi {
3851
3988
  "grantGroupPermission"(args: {
3852
3989
  "db3Id": string | number;
3853
3990
  body: {
3854
- /** Deprecated (removal: #4718): groups are named by `groupId` alone. Given, the group is looked up by type first; the `_`-prefixed platform types are refused here. @deprecated */
3991
+ /** Deprecated: groups are named by `groupId` alone. Given, the group is looked up by type first; the `_`-prefixed platform types are refused here. @deprecated */
3855
3992
  groupType?: string;
3856
3993
  groupId: string;
3857
3994
  permission: "read-write" | "reader";
@@ -4602,6 +4739,7 @@ export interface FunctionApi {
4602
4739
  "db3Id": string | number;
4603
4740
  "model": string | number;
4604
4741
  "userId"?: string | number;
4742
+ "names"?: string | number | boolean;
4605
4743
  body: {
4606
4744
  options: {
4607
4745
  /** One or more aggregate operations. `count` takes no field; `sum`/`avg`/`min`/`max` each require one. */
@@ -4679,6 +4817,7 @@ export interface FunctionApi {
4679
4817
  "batch"(args: {
4680
4818
  "db3Id": string | number;
4681
4819
  "userId"?: string | number;
4820
+ "names"?: string | number | boolean;
4682
4821
  body: {
4683
4822
  /** Ordered ops, applied in one transaction (at most 100; all-or-nothing unless `atomic: false`). */
4684
4823
  operations: Array<{
@@ -4924,6 +5063,7 @@ export interface FunctionApi {
4924
5063
  "batchRead"(args: {
4925
5064
  "db3Id": string | number;
4926
5065
  "userId"?: string | number;
5066
+ "names"?: string | number | boolean;
4927
5067
  body: {
4928
5068
  /** The reads, answered in order (1 to 100). Any key a read does not take is refused. */
4929
5069
  operations: Array<{
@@ -5039,6 +5179,32 @@ export interface FunctionApi {
5039
5179
  };
5040
5180
  };
5041
5181
  }>;
5182
+ /**
5183
+ * `db3.records.clear` — POST /db3/{db3Id}/records/{model}/clear. Empty one model of a db3
5184
+ * @experimental
5185
+ */
5186
+ "clear"(args: {
5187
+ "db3Id": string | number;
5188
+ "model": string | number;
5189
+ body?: {
5190
+ /** Also remove the model itself from an untyped db3. Omitted or false: only its records go. */
5191
+ drop?: boolean;
5192
+ };
5193
+ }): Promise<{
5194
+ ok: boolean;
5195
+ /** The model emptied. */
5196
+ model: string;
5197
+ /** The live records removed. */
5198
+ rows: number;
5199
+ /** The clear's log number; null when nothing was written. */
5200
+ lsn: number | null;
5201
+ /** The clear's epoch; null when nothing was written. */
5202
+ epoch: number | null;
5203
+ /** Whether the model itself was removed. */
5204
+ dropped: boolean;
5205
+ /** The rows the clear read and wrote, { rowsRead, rowsWritten }. */
5206
+ cost?: Record<string, unknown>;
5207
+ }>;
5042
5208
  /**
5043
5209
  * `db3.records.count` — GET /db3/{db3Id}/records/{model}/count. Count records in a db3 model
5044
5210
  * @beta
@@ -5047,6 +5213,7 @@ export interface FunctionApi {
5047
5213
  "db3Id": string | number;
5048
5214
  "model": string | number;
5049
5215
  "userId"?: string | number;
5216
+ "names"?: string | number | boolean;
5050
5217
  "filter"?: Record<string, unknown> | string;
5051
5218
  }): Promise<{
5052
5219
  count: number;
@@ -5096,6 +5263,7 @@ export interface FunctionApi {
5096
5263
  "requestId"?: string | number | boolean;
5097
5264
  "condition"?: string | number | boolean;
5098
5265
  "userId"?: string | number;
5266
+ "names"?: string | number | boolean;
5099
5267
  }): Promise<{
5100
5268
  deleted: boolean;
5101
5269
  }>;
@@ -5205,6 +5373,7 @@ export interface FunctionApi {
5205
5373
  "model": string | number;
5206
5374
  "recordId": string | number;
5207
5375
  "userId"?: string | number;
5376
+ "names"?: string | number | boolean;
5208
5377
  body: {
5209
5378
  /** Each field's delta, a finite number; a missing or non-numeric field starts at 0. `id` and reserved names are refused. */
5210
5379
  fields: Record<string, number>;
@@ -5230,6 +5399,7 @@ export interface FunctionApi {
5230
5399
  "model": string | number;
5231
5400
  "recordId": string | number;
5232
5401
  "userId"?: string | number;
5402
+ "names"?: string | number | boolean;
5233
5403
  body: {
5234
5404
  /** The fields to merge into the record. */
5235
5405
  data: Record<string, unknown>;
@@ -5263,6 +5433,7 @@ export interface FunctionApi {
5263
5433
  "limit"?: string | number | boolean;
5264
5434
  "cursor"?: string | number | boolean;
5265
5435
  "userId"?: string | number;
5436
+ "names"?: string | number | boolean;
5266
5437
  "filter"?: Record<string, unknown> | string;
5267
5438
  "sort"?: Record<string, unknown> | string;
5268
5439
  "include"?: unknown[] | string;
@@ -5314,6 +5485,7 @@ export interface FunctionApi {
5314
5485
  "db3Id": string | number;
5315
5486
  "model": string | number;
5316
5487
  "userId"?: string | number;
5488
+ "names"?: string | number | boolean;
5317
5489
  body: {
5318
5490
  /** The record's id, minted by the server when omitted (a ULID). Must not contain the reserved key separator. */
5319
5491
  id?: string;
@@ -5507,6 +5679,8 @@ export interface FunctionApi {
5507
5679
  load?: Record<string, unknown> | null;
5508
5680
  /** The bulk loads the room still keeps, oldest first. */
5509
5681
  loads?: Record<string, unknown>[];
5682
+ /** The model clears the room still keeps (#5994), oldest first. */
5683
+ clears?: Record<string, unknown>[];
5510
5684
  /** The current segment, as `GET …/snapshots/{segmentId}` describes it, or null. */
5511
5685
  segment?: Record<string, unknown> | null;
5512
5686
  /** The segment export in progress, or null. */
@@ -5585,6 +5759,25 @@ export interface FunctionApi {
5585
5759
  ownerRow: boolean;
5586
5760
  changed: boolean;
5587
5761
  }>;
5762
+ /**
5763
+ * `db3.setPublicAccess` — PUT /db3/{db3Id}/public-access. Set a db3's public access
5764
+ * @beta
5765
+ */
5766
+ "setPublicAccess"(args: {
5767
+ "db3Id": string | number;
5768
+ body: {
5769
+ /** `reader` marks the db3 public; `null` clears it */
5770
+ level: "reader" | null;
5771
+ };
5772
+ }): Promise<{
5773
+ id: string;
5774
+ /** `reader` while the db3 is public, or null when it is not */
5775
+ level: "reader" | null;
5776
+ /** Whether the stored level moved; the level already stored is answered `false` */
5777
+ changed: boolean;
5778
+ /** The app's `signedOutAccess` setting: public access is honoured only while it is on */
5779
+ signedOutAccess: boolean;
5780
+ }>;
5588
5781
  /**
5589
5782
  * `db3.setSync` — PUT /db3/{db3Id}/sync. Turn a db3's sync on or off
5590
5783
  * @beta
@@ -6017,7 +6210,7 @@ export interface FunctionApi {
6017
6210
  * `documents.blobs.downloadUrl` — GET /documents/{documentId}/blobs/{blobId}/download. Download a document blob's bytes
6018
6211
  * @deprecated Deprecated in the app API spec; see its description.
6019
6212
  */
6020
- "downloadUrl"(args: {
6213
+ "download"(args: {
6021
6214
  "documentId": string | number;
6022
6215
  "blobId": string | number;
6023
6216
  "disposition"?: string | number | boolean;
@@ -6237,9 +6430,9 @@ export interface FunctionApi {
6237
6430
  */
6238
6431
  "create"(args: {
6239
6432
  body: {
6240
- /** Not read by the handler — send `title` instead. Sending it is refused with 400 `VALIDATION_FAILED` (#3757). */
6433
+ /** Not read by the handler — send `title` instead. Sending it is refused with 400 `VALIDATION_FAILED`. */
6241
6434
  name?: string;
6242
- /** Not read by the handler. Sending it is refused with 400 `VALIDATION_FAILED` (#3757). */
6435
+ /** Not read by the handler. Sending it is refused with 400 `VALIDATION_FAILED`. */
6243
6436
  parentId?: string;
6244
6437
  title?: string;
6245
6438
  /** Adopt a caller-chosen id instead of a generated one. */
@@ -6248,7 +6441,7 @@ export interface FunctionApi {
6248
6441
  /** Honored for an app admin only; ignored otherwise. */
6249
6442
  createdBy?: string;
6250
6443
  metadata?: Record<string, unknown>;
6251
- /** Large-document opt-in (#2816); chosen at creation, never migrated. */
6444
+ /** Large-document opt-in; chosen at creation, never migrated. */
6252
6445
  documentFormat?: number;
6253
6446
  /** Read in order to be refused: a Blob requires its document, so create the document first, upload the blob, then `PUT /documents/{documentId}`. Answers 400 `THUMBNAIL_REQUIRES_EXISTING_DOC`. */
6254
6447
  thumbnailBlobId?: string;
@@ -6262,7 +6455,7 @@ export interface FunctionApi {
6262
6455
  tags?: string[];
6263
6456
  /** Caller-defined metadata blob, when set. */
6264
6457
  metadata?: Record<string, unknown>;
6265
- /** Echoed only for a large document (#2816). */
6458
+ /** Echoed only for a large document. */
6266
6459
  documentFormat?: number;
6267
6460
  }>;
6268
6461
  /**
@@ -6409,24 +6602,24 @@ export interface FunctionApi {
6409
6602
  */
6410
6603
  "createWithAlias"(args: {
6411
6604
  body: {
6412
- /** The alias to bind. `scope` must be `user` — app-scoped aliases were removed (#1168) — and `userId` defaults to the caller, which only an app admin may override. */
6605
+ /** The alias to bind. `scope` must be `user` — app-scoped aliases were removed — and `userId` defaults to the caller, which only an app admin may override. */
6413
6606
  alias: {
6414
6607
  scope: "user";
6415
6608
  aliasKey: string;
6416
6609
  userId?: string;
6417
6610
  };
6418
6611
  title?: string;
6419
- /** Not read by the handler; use `alias.scope`. Sending it is refused with 400 `VALIDATION_FAILED` (#3757). */
6612
+ /** Not read by the handler; use `alias.scope`. Sending it is refused with 400 `VALIDATION_FAILED`. */
6420
6613
  scope?: string;
6421
- /** Not read by the handler; use `alias.aliasKey`. Sending it is refused with 400 `VALIDATION_FAILED` (#3757). */
6614
+ /** Not read by the handler; use `alias.aliasKey`. Sending it is refused with 400 `VALIDATION_FAILED`. */
6422
6615
  aliasKey?: string;
6423
- /** Not read by the handler. Sending it is refused with 400 `VALIDATION_FAILED` (#3757). */
6616
+ /** Not read by the handler. Sending it is refused with 400 `VALIDATION_FAILED`. */
6424
6617
  name?: string;
6425
- /** Applied at creation, under the same limits `POST /documents` applies (#3757). */
6618
+ /** Applied at creation, under the same limits `POST /documents` applies. */
6426
6619
  tags?: string[];
6427
- /** Caller-defined metadata blob applied at creation, under the same size limit `POST /documents` applies (#3757). */
6620
+ /** Caller-defined metadata blob applied at creation, under the same size limit `POST /documents` applies. */
6428
6621
  metadata?: Record<string, unknown>;
6429
- /** Large-document opt-in (#3654); chosen at creation, never migrated. Same rule as `POST /documents`. */
6622
+ /** Large-document opt-in; chosen at creation, never migrated. Same rule as `POST /documents`. */
6430
6623
  documentFormat?: number;
6431
6624
  };
6432
6625
  }): Promise<{
@@ -6435,11 +6628,11 @@ export interface FunctionApi {
6435
6628
  createdBy?: string;
6436
6629
  createdAt?: string;
6437
6630
  modifiedAt?: string;
6438
- /** Echoed when the call applied tags (#3757). */
6631
+ /** Echoed when the call applied tags. */
6439
6632
  tags?: string[];
6440
6633
  /** Caller-defined metadata blob, when set. */
6441
6634
  metadata?: Record<string, unknown>;
6442
- /** Echoed only for a large document (#3654). */
6635
+ /** Echoed only for a large document. */
6443
6636
  documentFormat?: number;
6444
6637
  alias: {
6445
6638
  scope: "app" | "user";
@@ -6673,7 +6866,7 @@ export interface FunctionApi {
6673
6866
  thumbnailBlobId?: string;
6674
6867
  /** Caller-defined metadata blob. */
6675
6868
  metadata?: Record<string, unknown>;
6676
- /** Present only for a large document (#2816). */
6869
+ /** Present only for a large document. */
6677
6870
  documentFormat?: number;
6678
6871
  invitationAccepted?: boolean;
6679
6872
  upgradedFromPermission?: string;
@@ -6849,7 +7042,7 @@ export interface FunctionApi {
6849
7042
  */
6850
7043
  "getOrCreateWithAlias"(args: {
6851
7044
  body: {
6852
- /** The alias to bind. `scope` must be `user` — app-scoped aliases were removed (#1168) — and `userId` defaults to the caller, which only an app admin may override. */
7045
+ /** The alias to bind. `scope` must be `user` — app-scoped aliases were removed — and `userId` defaults to the caller, which only an app admin may override. */
6853
7046
  alias: {
6854
7047
  scope: "user";
6855
7048
  aliasKey: string;
@@ -6858,15 +7051,15 @@ export interface FunctionApi {
6858
7051
  title?: string;
6859
7052
  /** Applied only when the alias is created here. */
6860
7053
  tags?: string[];
6861
- /** Not read by the handler; use `alias.scope`. Sending it is refused with 400 `VALIDATION_FAILED` (#3757). */
7054
+ /** Not read by the handler; use `alias.scope`. Sending it is refused with 400 `VALIDATION_FAILED`. */
6862
7055
  scope?: string;
6863
- /** Not read by the handler; use `alias.aliasKey`. Sending it is refused with 400 `VALIDATION_FAILED` (#3757). */
7056
+ /** Not read by the handler; use `alias.aliasKey`. Sending it is refused with 400 `VALIDATION_FAILED`. */
6864
7057
  aliasKey?: string;
6865
- /** Not read by the handler. Sending it is refused with 400 `VALIDATION_FAILED` (#3757). */
7058
+ /** Not read by the handler. Sending it is refused with 400 `VALIDATION_FAILED`. */
6866
7059
  name?: string;
6867
- /** Caller-defined metadata blob applied only when the alias is created here (#3757). */
7060
+ /** Caller-defined metadata blob applied only when the alias is created here. */
6868
7061
  metadata?: Record<string, unknown>;
6869
- /** Large-document opt-in (#3757); applied when this call creates the document, and otherwise read as an expectation about the document the alias already names — a stored format that differs answers 409, one that agrees is echoed. Chosen at creation, never migrated. */
7062
+ /** Large-document opt-in; applied when this call creates the document, and otherwise read as an expectation about the document the alias already names — a stored format that differs answers 409, one that agrees is echoed. Chosen at creation, never migrated. */
6870
7063
  documentFormat?: number;
6871
7064
  };
6872
7065
  }): Promise<{
@@ -6875,11 +7068,11 @@ export interface FunctionApi {
6875
7068
  createdBy?: string;
6876
7069
  createdAt?: string;
6877
7070
  modifiedAt?: string;
6878
- /** Echoed when the call applied tags (#3757). */
7071
+ /** Echoed when the call applied tags. */
6879
7072
  tags?: string[];
6880
7073
  /** Caller-defined metadata blob, when set. */
6881
7074
  metadata?: Record<string, unknown>;
6882
- /** Echoed only for a large document (#3654). */
7075
+ /** Echoed only for a large document. */
6883
7076
  documentFormat?: number;
6884
7077
  alias: {
6885
7078
  scope: "app" | "user";
@@ -7055,7 +7248,7 @@ export interface FunctionApi {
7055
7248
  "grantGroupPermission"(args: {
7056
7249
  "documentId": string | number;
7057
7250
  body: {
7058
- /** Deprecated (removal: #4718): groups are named by `groupId` alone. Given, the group is looked up by type first; the `_`-prefixed platform types are refused here. @deprecated */
7251
+ /** Deprecated: groups are named by `groupId` alone. Given, the group is looked up by type first; the `_`-prefixed platform types are refused here. @deprecated */
7059
7252
  groupType?: string;
7060
7253
  groupId: string;
7061
7254
  permission: "read-write" | "reader";
@@ -7315,7 +7508,7 @@ export interface FunctionApi {
7315
7508
  thumbnailBlobId?: string;
7316
7509
  /** Caller-defined metadata blob. */
7317
7510
  metadata?: Record<string, unknown>;
7318
- /** Present only for a large document (#2816). */
7511
+ /** Present only for a large document. */
7319
7512
  documentFormat?: number;
7320
7513
  invitationAccepted?: boolean;
7321
7514
  upgradedFromPermission?: string;
@@ -7375,7 +7568,7 @@ export interface FunctionApi {
7375
7568
  thumbnailBlobId?: string;
7376
7569
  /** Caller-defined metadata blob. */
7377
7570
  metadata?: Record<string, unknown>;
7378
- /** Present only for a large document (#2816). */
7571
+ /** Present only for a large document. */
7379
7572
  documentFormat?: number;
7380
7573
  invitationAccepted?: boolean;
7381
7574
  upgradedFromPermission?: string;
@@ -7534,7 +7727,7 @@ export interface FunctionApi {
7534
7727
  thumbnailBlobId?: string;
7535
7728
  /** Caller-defined metadata blob. */
7536
7729
  metadata?: Record<string, unknown>;
7537
- /** Present only for a large document (#2816). */
7730
+ /** Present only for a large document. */
7538
7731
  documentFormat?: number;
7539
7732
  invitationAccepted?: boolean;
7540
7733
  upgradedFromPermission?: string;
@@ -8130,8 +8323,8 @@ export interface FunctionApi {
8130
8323
  success: boolean;
8131
8324
  }>;
8132
8325
  /**
8133
- * `documents.revokeGroupPermissionByType` — DELETE /documents/{documentId}/group-permissions/{groupType}/{groupId}. DEPRECATED — Revoke a group permission on a document, by type; use DELETE /documents/{documentId}/group-permissions/{groupId} (removal: #4718)
8134
- * @deprecated Use DELETE /documents/{documentId}/group-permissions/{groupId} (removal: #4718)
8326
+ * `documents.revokeGroupPermissionByType` — DELETE /documents/{documentId}/group-permissions/{groupType}/{groupId}. DEPRECATED — Revoke a group permission on a document, by type; use DELETE /documents/{documentId}/group-permissions/{groupId}
8327
+ * @deprecated Use DELETE /documents/{documentId}/group-permissions/{groupId}
8135
8328
  */
8136
8329
  "revokeGroupPermissionByType"(args: {
8137
8330
  "documentId": string | number;
@@ -8204,6 +8397,8 @@ export interface FunctionApi {
8204
8397
  load?: Record<string, unknown> | null;
8205
8398
  /** The bulk loads the room still keeps, oldest first. */
8206
8399
  loads?: Record<string, unknown>[];
8400
+ /** The model clears the room still keeps (#5994), oldest first. */
8401
+ clears?: Record<string, unknown>[];
8207
8402
  /** The current segment, as `GET …/snapshots/{segmentId}` describes it, or null. */
8208
8403
  segment?: Record<string, unknown> | null;
8209
8404
  /** The segment export in progress, or null. */
@@ -8301,7 +8496,7 @@ export interface FunctionApi {
8301
8496
  thumbnailBlobId?: string;
8302
8497
  /** Caller-defined metadata blob. */
8303
8498
  metadata?: Record<string, unknown>;
8304
- /** Present only for a large document (#2816). */
8499
+ /** Present only for a large document. */
8305
8500
  documentFormat?: number;
8306
8501
  invitationAccepted?: boolean;
8307
8502
  upgradedFromPermission?: string;
@@ -8488,6 +8683,8 @@ export interface FunctionApi {
8488
8683
  meta?: Record<string, unknown>;
8489
8684
  /** Wall-clock budget for the invocation. Defaults to 5000 and clamps silently to the platform ceiling of 30000. */
8490
8685
  timeoutMs?: number;
8686
+ /** A Turnstile token, required on a signed-out call to a function whose `[function] public` table sets `turnstile = true`. It is verified and removed before the function runs; anywhere else it is ignored. */
8687
+ turnstileToken?: string;
8491
8688
  };
8492
8689
  }): Promise<{
8493
8690
  status?: string;
@@ -8495,7 +8692,7 @@ export interface FunctionApi {
8495
8692
  output?: Record<string, unknown>;
8496
8693
  error?: string;
8497
8694
  errorCode?: string;
8498
- /** The invocation-log record this answer belongs to (#3448), minted before the run so the record and the answer share it. Hand it to `functions logs --invocation`. Present exactly when the platform recorded the invocation; a gate refusal carries none. */
8695
+ /** The invocation-log record this answer belongs to (#3448), minted before the run so the record and the answer share it. Hand it to `functions logs --invocation`. Present exactly when the platform recorded the invocation; a gate refusal carries none, and neither does an answer served from the signed-out cache (`X-Function-Cache: hit`). */
8499
8696
  invocationId?: string;
8500
8697
  /** The resolved platform ceilings the sandbox ran under — `[function.limits]` clamped element-wise to the platform's own values. Present on every request outcome the sandbox produced (`completed`, and a `failed` the handler itself caused); absent from a refusal that never reached the sandbox, which has no run to describe. */
8501
8698
  limits?: {
@@ -8661,8 +8858,8 @@ export interface FunctionApi {
8661
8858
  inviteToken?: string | null;
8662
8859
  }>;
8663
8860
  /**
8664
- * `groups.addMemberByType` — POST /groups/{groupType}/{groupId}/members. DEPRECATED — Add a member to a group, by type; use POST /groups/{groupId}/members (removal: #4718)
8665
- * @deprecated Use POST /groups/{groupId}/members (removal: #4718)
8861
+ * `groups.addMemberByType` — POST /groups/{groupType}/{groupId}/members. DEPRECATED — Add a member to a group, by type; use POST /groups/{groupId}/members
8862
+ * @deprecated Use POST /groups/{groupId}/members
8666
8863
  */
8667
8864
  "addMemberByType"(args: {
8668
8865
  "groupType": string | number;
@@ -8694,7 +8891,7 @@ export interface FunctionApi {
8694
8891
  /** `groups.create` — POST /groups. Create a group */
8695
8892
  "create"(args: {
8696
8893
  body: {
8697
- /** Deprecated (removal: #4718): groups are addressed by `groupId` alone. Checked and ignored: a new group is stored as type `group`. @deprecated */
8894
+ /** Deprecated: groups are addressed by `groupId` alone. Checked and ignored: a new group is stored as type `group`. @deprecated */
8698
8895
  groupType?: string;
8699
8896
  name: string;
8700
8897
  description?: string;
@@ -8714,7 +8911,7 @@ export interface FunctionApi {
8714
8911
  };
8715
8912
  }): Promise<{
8716
8913
  appId: string;
8717
- /** Deprecated (removal: #4718): groups are addressed by `groupId` alone. */
8914
+ /** Deprecated: groups are addressed by `groupId` alone. */
8718
8915
  groupType: string;
8719
8916
  groupId: string;
8720
8917
  name: string;
@@ -8738,8 +8935,8 @@ export interface FunctionApi {
8738
8935
  success: boolean;
8739
8936
  }>;
8740
8937
  /**
8741
- * `groups.deleteByType` — DELETE /groups/{groupType}/{groupId}. DEPRECATED — Delete a group, by type; use DELETE /groups/{groupId} (removal: #4718)
8742
- * @deprecated Use DELETE /groups/{groupId} (removal: #4718)
8938
+ * `groups.deleteByType` — DELETE /groups/{groupType}/{groupId}. DEPRECATED — Delete a group, by type; use DELETE /groups/{groupId}
8939
+ * @deprecated Use DELETE /groups/{groupId}
8743
8940
  */
8744
8941
  "deleteByType"(args: {
8745
8942
  "groupType": string | number;
@@ -8753,7 +8950,7 @@ export interface FunctionApi {
8753
8950
  "groupType"?: string | number | boolean;
8754
8951
  }): Promise<{
8755
8952
  appId: string;
8756
- /** Deprecated (removal: #4718): groups are addressed by `groupId` alone. */
8953
+ /** Deprecated: groups are addressed by `groupId` alone. */
8757
8954
  groupType: string;
8758
8955
  groupId: string;
8759
8956
  name: string;
@@ -8770,15 +8967,15 @@ export interface FunctionApi {
8770
8967
  modifiedAt?: string | null;
8771
8968
  }>;
8772
8969
  /**
8773
- * `groups.getByType` — GET /groups/{groupType}/{groupId}. DEPRECATED — Get a group, by type; use GET /groups/{groupId} (removal: #4718)
8774
- * @deprecated Use GET /groups/{groupId} (removal: #4718)
8970
+ * `groups.getByType` — GET /groups/{groupType}/{groupId}. DEPRECATED — Get a group, by type; use GET /groups/{groupId}
8971
+ * @deprecated Use GET /groups/{groupId}
8775
8972
  */
8776
8973
  "getByType"(args: {
8777
8974
  "groupType": string | number;
8778
8975
  "groupId": string | number;
8779
8976
  }): Promise<{
8780
8977
  appId: string;
8781
- /** Deprecated (removal: #4718): groups are addressed by `groupId` alone. */
8978
+ /** Deprecated: groups are addressed by `groupId` alone. */
8782
8979
  groupType: string;
8783
8980
  groupId: string;
8784
8981
  name: string;
@@ -8803,7 +9000,7 @@ export interface FunctionApi {
8803
9000
  }): Promise<{
8804
9001
  items: {
8805
9002
  appId: string;
8806
- /** Deprecated (removal: #4718): groups are addressed by `groupId` alone. */
9003
+ /** Deprecated: groups are addressed by `groupId` alone. */
8807
9004
  groupType: string;
8808
9005
  groupId: string;
8809
9006
  name: string;
@@ -8834,7 +9031,7 @@ export interface FunctionApi {
8834
9031
  }): Promise<{
8835
9032
  items: {
8836
9033
  appId: string;
8837
- /** Deprecated (removal: #4718): groups are addressed by `groupId` alone. */
9034
+ /** Deprecated: groups are addressed by `groupId` alone. */
8838
9035
  groupType: string;
8839
9036
  groupId: string;
8840
9037
  name: string;
@@ -8869,8 +9066,8 @@ export interface FunctionApi {
8869
9066
  grantedAt?: string | null;
8870
9067
  }[]>;
8871
9068
  /**
8872
- * `groups.listDatabasesByType` — GET /groups/{groupType}/{groupId}/databases. DEPRECATED — List databases shared with a group, by type; use GET /groups/{groupId}/databases (removal: #4718)
8873
- * @deprecated Use GET /groups/{groupId}/databases (removal: #4718)
9069
+ * `groups.listDatabasesByType` — GET /groups/{groupType}/{groupId}/databases. DEPRECATED — List databases shared with a group, by type; use GET /groups/{groupId}/databases
9070
+ * @deprecated Use GET /groups/{groupId}/databases
8874
9071
  */
8875
9072
  "listDatabasesByType"(args: {
8876
9073
  "groupType": string | number;
@@ -8913,8 +9110,8 @@ export interface FunctionApi {
8913
9110
  nextCursor?: string;
8914
9111
  }>;
8915
9112
  /**
8916
- * `groups.listDb3ByType` — GET /groups/{groupType}/{groupId}/db3. DEPRECATED — List db3s shared with a group, by type; use GET /groups/{groupId}/db3 (removal: #4718)
8917
- * @deprecated Use GET /groups/{groupId}/db3 (removal: #4718)
9113
+ * `groups.listDb3ByType` — GET /groups/{groupType}/{groupId}/db3. DEPRECATED — List db3s shared with a group, by type; use GET /groups/{groupId}/db3
9114
+ * @deprecated Use GET /groups/{groupId}/db3
8918
9115
  */
8919
9116
  "listDb3ByType"(args: {
8920
9117
  "groupType": string | number;
@@ -8966,8 +9163,8 @@ export interface FunctionApi {
8966
9163
  addedBy?: string | null;
8967
9164
  }[]>;
8968
9165
  /**
8969
- * `groups.listDocumentsByType` — GET /groups/{groupType}/{groupId}/documents. DEPRECATED — List documents shared with a group, by type; use GET /groups/{groupId}/documents (removal: #4718)
8970
- * @deprecated Use GET /groups/{groupId}/documents (removal: #4718)
9166
+ * `groups.listDocumentsByType` — GET /groups/{groupType}/{groupId}/documents. DEPRECATED — List documents shared with a group, by type; use GET /groups/{groupId}/documents
9167
+ * @deprecated Use GET /groups/{groupId}/documents
8971
9168
  */
8972
9169
  "listDocumentsByType"(args: {
8973
9170
  "groupType": string | number;
@@ -9014,8 +9211,8 @@ export interface FunctionApi {
9014
9211
  prevCursor?: string;
9015
9212
  }>;
9016
9213
  /**
9017
- * `groups.listMembersByType` — GET /groups/{groupType}/{groupId}/members. DEPRECATED — List a group's members, by type; use GET /groups/{groupId}/members (removal: #4718)
9018
- * @deprecated Use GET /groups/{groupId}/members (removal: #4718)
9214
+ * `groups.listMembersByType` — GET /groups/{groupType}/{groupId}/members. DEPRECATED — List a group's members, by type; use GET /groups/{groupId}/members
9215
+ * @deprecated Use GET /groups/{groupId}/members
9019
9216
  */
9020
9217
  "listMembersByType"(args: {
9021
9218
  "groupType": string | number;
@@ -9054,8 +9251,8 @@ export interface FunctionApi {
9054
9251
  }[];
9055
9252
  }>;
9056
9253
  /**
9057
- * `groups.listPendingInvitationsByType` — GET /groups/{groupType}/{groupId}/pending-invitations. DEPRECATED — List a group's pending invitations, by type; use GET /groups/{groupId}/pending-invitations (removal: #4718)
9058
- * @deprecated Use GET /groups/{groupId}/pending-invitations (removal: #4718)
9254
+ * `groups.listPendingInvitationsByType` — GET /groups/{groupType}/{groupId}/pending-invitations. DEPRECATED — List a group's pending invitations, by type; use GET /groups/{groupId}/pending-invitations
9255
+ * @deprecated Use GET /groups/{groupId}/pending-invitations
9059
9256
  */
9060
9257
  "listPendingInvitationsByType"(args: {
9061
9258
  "groupType": string | number;
@@ -9106,8 +9303,8 @@ export interface FunctionApi {
9106
9303
  deferredCount?: number;
9107
9304
  }>;
9108
9305
  /**
9109
- * `groups.removeMemberByEmailByType` — DELETE /groups/{groupType}/{groupId}/members. DEPRECATED — Remove a group member or pending invitation by email, by type; use DELETE /groups/{groupId}/members (removal: #4718)
9110
- * @deprecated Use DELETE /groups/{groupId}/members (removal: #4718)
9306
+ * `groups.removeMemberByEmailByType` — DELETE /groups/{groupType}/{groupId}/members. DEPRECATED — Remove a group member or pending invitation by email, by type; use DELETE /groups/{groupId}/members
9307
+ * @deprecated Use DELETE /groups/{groupId}/members
9111
9308
  */
9112
9309
  "removeMemberByEmailByType"(args: {
9113
9310
  "groupType": string | number;
@@ -9120,8 +9317,8 @@ export interface FunctionApi {
9120
9317
  deferredCount?: number;
9121
9318
  }>;
9122
9319
  /**
9123
- * `groups.removeMemberByType` — DELETE /groups/{groupType}/{groupId}/members/{userId}. DEPRECATED — Remove a specific member from a group, by type; use DELETE /groups/{groupId}/members/{userId} (removal: #4718)
9124
- * @deprecated Use DELETE /groups/{groupId}/members/{userId} (removal: #4718)
9320
+ * `groups.removeMemberByType` — DELETE /groups/{groupType}/{groupId}/members/{userId}. DEPRECATED — Remove a specific member from a group, by type; use DELETE /groups/{groupId}/members/{userId}
9321
+ * @deprecated Use DELETE /groups/{groupId}/members/{userId}
9125
9322
  */
9126
9323
  "removeMemberByType"(args: {
9127
9324
  "groupType": string | number;
@@ -9146,8 +9343,8 @@ export interface FunctionApi {
9146
9343
  deferredCount: number;
9147
9344
  }>;
9148
9345
  /**
9149
- * `groups.revokePendingInvitationByType` — DELETE /groups/{groupType}/{groupId}/pending-invitations/{invitationId}. DEPRECATED — Revoke a pending invitation's grants on a group, by type; use DELETE /groups/{groupId}/pending-invitations/{invitationId} (removal: #4718)
9150
- * @deprecated Use DELETE /groups/{groupId}/pending-invitations/{invitationId} (removal: #4718)
9346
+ * `groups.revokePendingInvitationByType` — DELETE /groups/{groupType}/{groupId}/pending-invitations/{invitationId}. DEPRECATED — Revoke a pending invitation's grants on a group, by type; use DELETE /groups/{groupId}/pending-invitations/{invitationId}
9347
+ * @deprecated Use DELETE /groups/{groupId}/pending-invitations/{invitationId}
9151
9348
  */
9152
9349
  "revokePendingInvitationByType"(args: {
9153
9350
  "groupType": string | number;
@@ -9187,7 +9384,7 @@ export interface FunctionApi {
9187
9384
  };
9188
9385
  }): Promise<{
9189
9386
  appId: string;
9190
- /** Deprecated (removal: #4718): groups are addressed by `groupId` alone. */
9387
+ /** Deprecated: groups are addressed by `groupId` alone. */
9191
9388
  groupType: string;
9192
9389
  groupId: string;
9193
9390
  name: string;
@@ -9217,7 +9414,7 @@ export interface FunctionApi {
9217
9414
  };
9218
9415
  }): Promise<{
9219
9416
  appId: string;
9220
- /** Deprecated (removal: #4718): groups are addressed by `groupId` alone. */
9417
+ /** Deprecated: groups are addressed by `groupId` alone. */
9221
9418
  groupType: string;
9222
9419
  groupId: string;
9223
9420
  name: string;
@@ -9234,8 +9431,8 @@ export interface FunctionApi {
9234
9431
  modifiedAt?: string | null;
9235
9432
  }>;
9236
9433
  /**
9237
- * `groups.updateByType` — PATCH /groups/{groupType}/{groupId}. DEPRECATED — Update a group, by type; use PATCH /groups/{groupId} (removal: #4718)
9238
- * @deprecated Use PATCH /groups/{groupId} (removal: #4718)
9434
+ * `groups.updateByType` — PATCH /groups/{groupType}/{groupId}. DEPRECATED — Update a group, by type; use PATCH /groups/{groupId}
9435
+ * @deprecated Use PATCH /groups/{groupId}
9239
9436
  */
9240
9437
  "updateByType"(args: {
9241
9438
  "groupType": string | number;
@@ -9246,7 +9443,7 @@ export interface FunctionApi {
9246
9443
  };
9247
9444
  }): Promise<{
9248
9445
  appId: string;
9249
- /** Deprecated (removal: #4718): groups are addressed by `groupId` alone. */
9446
+ /** Deprecated: groups are addressed by `groupId` alone. */
9250
9447
  groupType: string;
9251
9448
  groupId: string;
9252
9449
  name: string;
@@ -9707,6 +9904,7 @@ export interface FunctionApi {
9707
9904
  /**
9708
9905
  * `resourceMetadata.delete` — DELETE /resources/{resourceType}/{resourceId}/metadata/{category}. Delete a resource's metadata for a category (idempotent)
9709
9906
  * @experimental
9907
+ * @deprecated Use user properties for per-user data, and a db3 database keyed by the group or collection id for group or collection data, instead.
9710
9908
  */
9711
9909
  "delete"(args: {
9712
9910
  "resourceType": string | number;
@@ -9723,6 +9921,7 @@ export interface FunctionApi {
9723
9921
  /**
9724
9922
  * `resourceMetadata.get` — GET /resources/{resourceType}/{resourceId}/metadata/{category}. Read a resource's metadata for a category
9725
9923
  * @experimental
9924
+ * @deprecated Use user properties for per-user data, and a db3 database keyed by the group or collection id for group or collection data, instead.
9726
9925
  */
9727
9926
  "get"(args: {
9728
9927
  "resourceType": string | number;
@@ -9740,6 +9939,7 @@ export interface FunctionApi {
9740
9939
  /**
9741
9940
  * `resourceMetadata.getBatch` — POST /resources/metadata/batch. Batch-read resource metadata (partial success)
9742
9941
  * @experimental
9942
+ * @deprecated Use user properties for per-user data, and a db3 database keyed by the group or collection id for group or collection data, instead.
9743
9943
  */
9744
9944
  "getBatch"(args: {
9745
9945
  "debug"?: string | number | boolean;
@@ -9768,6 +9968,7 @@ export interface FunctionApi {
9768
9968
  /**
9769
9969
  * `resourceMetadata.list` — GET /resources/{resourceType}/{resourceId}/metadata. List all metadata categories on a resource
9770
9970
  * @experimental
9971
+ * @deprecated Use user properties for per-user data, and a db3 database keyed by the group or collection id for group or collection data, instead.
9771
9972
  */
9772
9973
  "list"(args: {
9773
9974
  "resourceType": string | number;
@@ -9784,6 +9985,7 @@ export interface FunctionApi {
9784
9985
  /**
9785
9986
  * `resourceMetadata.resolve` — POST /metadata/resolve. Resolve a resource by a category's unique metadata value
9786
9987
  * @experimental
9988
+ * @deprecated Use user properties for per-user data, and a db3 database keyed by the group or collection id for group or collection data, instead.
9787
9989
  */
9788
9990
  "resolve"(args: {
9789
9991
  body: {
@@ -9800,6 +10002,7 @@ export interface FunctionApi {
9800
10002
  /**
9801
10003
  * `resourceMetadata.set` — PUT /resources/{resourceType}/{resourceId}/metadata/{category}. Write a resource's metadata for a category
9802
10004
  * @experimental
10005
+ * @deprecated Use user properties for per-user data, and a db3 database keyed by the group or collection id for group or collection data, instead.
9803
10006
  */
9804
10007
  "set"(args: {
9805
10008
  "resourceType": string | number;
@@ -10158,7 +10361,7 @@ export interface FunctionApi {
10158
10361
  addToSet?: Record<string, unknown>;
10159
10362
  /** Stringset property name → one string or an array of strings to remove. */
10160
10363
  removeFromSet?: Record<string, unknown>;
10161
- /** A records-query filter over properties.<name>, userId, email, name and avatarUrl; the write happens only if it holds. */
10364
+ /** A records-query filter over `properties.<name>`, userId, email, name and avatarUrl; the write happens only if it holds. */
10162
10365
  condition?: Record<string, unknown>;
10163
10366
  };
10164
10367
  }): Promise<{
@@ -10191,7 +10394,7 @@ export interface FunctionApi {
10191
10394
  /**
10192
10395
  * The app's database types, model by model — EMPTY here and filled by the
10193
10396
  * declaration `primitive config push` writes into the config tree's
10194
- * `functions/` directory (#3182). A tree that has pushed once therefore types
10397
+ * `functions/` directory. A tree that has pushed once therefore types
10195
10398
  * `ctx.db` against its own schemas; one that has not gets the open form and
10196
10399
  * still compiles.
10197
10400
  */
@@ -10260,7 +10463,7 @@ export type DatabaseModelNames<TModels> = [keyof TModels] extends [never]
10260
10463
 
10261
10464
  /**
10262
10465
  * A row as the platform HANDS IT BACK: whatever the schema declared, plus the
10263
- * record identity the platform owns (#3450).
10466
+ * record identity the platform owns.
10264
10467
  *
10265
10468
  * Every stored record has an `id`. A save that arrives without one is given a
10266
10469
  * ULID, a projection always keeps it, and `delete` and `patch` take nothing
@@ -10321,10 +10524,15 @@ export type ModelBatchOperation<TRow> = {
10321
10524
  [key: string]: unknown;
10322
10525
  };
10323
10526
 
10527
+ /**
10528
+ * One model on a {@link DatabaseHandle}, as `handle.model(name)` returns it —
10529
+ * the pre-db3 way to read and write a database's rows.
10530
+ * @deprecated Use a `ctx.db3` model handle.
10531
+ */
10324
10532
  export interface DatabaseModelHandle<TRow> {
10325
10533
  /**
10326
10534
  * One page of this model's rows, in the decided envelope — `{ items,
10327
- * hasMore, nextCursor? }` (#3287), the same shape `ctx.doc(...)`,
10535
+ * hasMore, nextCursor? }`, the same shape `ctx.doc(...)`,
10328
10536
  * `ctx.users.list` and the client library answer. The route's own wire
10329
10537
  * shape is unchanged; the SDK is where the one name lives, so shared paging
10330
10538
  * code can be written once.
@@ -10339,7 +10547,7 @@ export interface DatabaseModelHandle<TRow> {
10339
10547
  save(body: ModelScopedBody<{ id?: string; data: Partial<TRow>; [key: string]: unknown }>): Promise<any>;
10340
10548
  /**
10341
10549
  * Change some fields of ONE row — `databases.records.patch`, with this
10342
- * handle's model bound (#3450).
10550
+ * handle's model bound.
10343
10551
  *
10344
10552
  * The record id is positional and the body may not carry another, for the
10345
10553
  * same reason it may not name another model: the runtime assigns both LAST,
@@ -10354,7 +10562,7 @@ export interface DatabaseModelHandle<TRow> {
10354
10562
  ): Promise<any>;
10355
10563
  /**
10356
10564
  * Remove ONE row by the id a read handed back — `databases.records.delete`,
10357
- * with this handle's model bound (#3450). An optional `condition` makes it
10565
+ * with this handle's model bound. An optional `condition` makes it
10358
10566
  * conditional, and travels untouched.
10359
10567
  * @deprecated Use a `ctx.db3` model handle.
10360
10568
  */
@@ -10408,7 +10616,7 @@ export type DocumentModelNames = [keyof DocumentSchemas] extends [never]
10408
10616
 
10409
10617
  /**
10410
10618
  * A document model's row shape, or an open record for an undeclared schema —
10411
- * carrying the platform's record identity either way (#3450), by the same rule
10619
+ * carrying the platform's record identity either way, by the same rule
10412
10620
  * and for the same reason as a database row: the records DO is one
10413
10621
  * implementation, and `patch` and `delete` here take an id too.
10414
10622
  */
@@ -10417,7 +10625,7 @@ export type DocumentModelRow<M extends string> = M extends keyof DocumentSchemas
10417
10625
  : Record<string, unknown> & { id: string };
10418
10626
 
10419
10627
  /**
10420
- * One related-records spec of a document model read's `include` (#4692),
10628
+ * One related-records spec of a document model read's `include`,
10421
10629
  * answered on a db3 (a format-3 document) as `_related` on each record.
10422
10630
  */
10423
10631
  export interface DocumentIncludeSpec {
@@ -10469,7 +10677,7 @@ export interface DocumentQueryOptions {
10469
10677
  limit?: number;
10470
10678
  cursor?: string;
10471
10679
  /**
10472
- * The document format you expect (#3764). When it disagrees with the format
10680
+ * The document format you expect. When it disagrees with the format
10473
10681
  * the platform resolved, the call is refused with a 409
10474
10682
  * DOCUMENT_FORMAT_MISMATCH rather than answered out of the wrong tables.
10475
10683
  * Usually stated once on the handle, as ctx.doc(id, { documentFormat: 2 }),
@@ -10492,7 +10700,7 @@ export interface DocumentQueryOptions {
10492
10700
  */
10493
10701
  /**
10494
10702
  * One op of a document `batch` — the `documents.records.batch` blob's shape,
10495
- * typed to this handle's model (#3455).
10703
+ * typed to this handle's model.
10496
10704
  *
10497
10705
  * `model` is NOT a member: the handle already names it and assigns it last, so
10498
10706
  * a multi-model blob stays on the raw `ctx.api.documents.records.batch`
@@ -10521,6 +10729,11 @@ export interface DocumentBulkResult {
10521
10729
  upserted: Array<{ index: number; model: string; id: string; created: boolean }>;
10522
10730
  }
10523
10731
 
10732
+ /**
10733
+ * One model on a `ctx.doc(documentId)` handle, as its `model(name)` returns
10734
+ * it — the pre-db3 way to read and write a document model's records.
10735
+ * @deprecated Use a `ctx.db3` model handle.
10736
+ */
10524
10737
  export interface DocumentModelHandle<TRow> {
10525
10738
  /**
10526
10739
  * One page of the model's records: 100 by default, up to 10,000 with
@@ -10987,7 +11200,10 @@ export interface Db3ModelHandle<TRow, TQuery = DocumentQueryOptions, TCount = {
10987
11200
  * @beta
10988
11201
  */
10989
11202
  query(options?: TQuery): Promise<{ items: Array<TRow & { _related?: Record<string, any> }>; hasMore: boolean; nextCursor?: string }>;
10990
- /** @beta */
11203
+ /**
11204
+ * The number of records matching an optional filter.
11205
+ * @beta
11206
+ */
10991
11207
  count(options?: TCount): Promise<{ count: number }>;
10992
11208
  /**
10993
11209
  * Counts, sums, averages, minimums and maximums, resolved to the bare row array.
@@ -11059,7 +11275,10 @@ export interface Db3Handle<TModels, TQueries = {}> {
11059
11275
  db3Id: string;
11060
11276
  /** The type key this handle was opened with. */
11061
11277
  type: string;
11062
- /** @beta */
11278
+ /**
11279
+ * One model on this db3, typed from its schema.
11280
+ * @beta
11281
+ */
11063
11282
  model<M extends Db3ModelNames<TModels>>(modelName: M): Db3ModelHandle<Db3ModelRow<TModels, M>, Db3ModelQueryOptions<TQueries, M>, Db3ModelCountOptions<TQueries, M>, Db3ModelAggregateBody<TQueries, M>, Db3ModelUniqueOf<TQueries, M>>;
11064
11283
  /**
11065
11284
  * Writes and reads across models in one request (at most 100); each op names its `model`.
@@ -11077,7 +11296,7 @@ export interface Db3Handle<TModels, TQueries = {}> {
11077
11296
  }
11078
11297
 
11079
11298
  /**
11080
- * How a `ctx.db3` handle's calls are judged — #4806.
11299
+ * How a `ctx.db3` handle's calls are judged.
11081
11300
  *
11082
11301
  * `asUser` names the member every call is judged by: their grant on the
11083
11302
  * db3 and nothing else, with no app or function authority, and the room's
@@ -11100,7 +11319,7 @@ export interface Db3HandleOptions {
11100
11319
  export type Db3UntypedHandle = Omit<Db3Handle<Record<string, Record<string, unknown>>>, "type">;
11101
11320
 
11102
11321
  /**
11103
- * One call through a granted integration — #3183.
11322
+ * One call through a granted integration.
11104
11323
  *
11105
11324
  * `path` is RELATIVE to the integration's `baseUrl`, and the host is the
11106
11325
  * integration's: the platform resolves and normalizes the path before checking
@@ -11138,7 +11357,7 @@ export interface PromptRunArgs {
11138
11357
  * `{ state, criteria? }`: `state` is the value its questions are asked
11139
11358
  * about, and `criteria.<question>` supplies this run's options for each
11140
11359
  * choice question declared `criteriaSource = "dynamic"` — a table of option
11141
- * key = description (a string or a JSON object), at least two entries (#3813).
11360
+ * key = description (a string or a JSON object), at least two entries.
11142
11361
  */
11143
11362
  variables?: Record<string, unknown>;
11144
11363
  /** Run against a different model for this call only. */
@@ -11158,7 +11377,7 @@ export interface PromptRunArgs {
11158
11377
  export interface PromptSchemas {}
11159
11378
 
11160
11379
  /**
11161
- * The keys whose declaration is an AGENT (`kind = "agent"`, #3798): entries
11380
+ * The keys whose declaration is an AGENT (`kind = "agent"`): entries
11162
11381
  * carrying `{ agent: … }` instead of an output. An agent runs turn by turn in
11163
11382
  * a session and never single-shot, so these are the keys `PromptKeys` leaves
11164
11383
  * out.
@@ -11176,7 +11395,7 @@ export type PromptKeys = [keyof PromptSchemas] extends [never]
11176
11395
  ? string
11177
11396
  : Exclude<keyof PromptSchemas & string, AgentKeys>;
11178
11397
 
11179
- /** One agent's session variables, typed from its `inputSchema` (#3798). */
11398
+ /** One agent's session variables, typed from its `inputSchema`. */
11180
11399
  export type AgentVariables<K extends AgentKeys> = PromptSchemas[K] extends {
11181
11400
  agent: { variables: infer V };
11182
11401
  }
@@ -11184,7 +11403,7 @@ export type AgentVariables<K extends AgentKeys> = PromptSchemas[K] extends {
11184
11403
  : never;
11185
11404
 
11186
11405
  /**
11187
- * The keys `ctx.agents.createSession` accepts — #3803: every declared agent,
11406
+ * The keys `ctx.agents.createSession` accepts: every declared agent,
11188
11407
  * or `string` before the tree has pushed any prompt (the `PromptKeys`
11189
11408
  * rule).
11190
11409
  */
@@ -11193,7 +11412,7 @@ export type SessionAgentKeys = [keyof PromptSchemas] extends [never]
11193
11412
  : AgentKeys;
11194
11413
 
11195
11414
  /**
11196
- * What `ctx.agents.createSession` takes — #3803. Typed by the agent's key:
11415
+ * What `ctx.agents.createSession` takes. Typed by the agent's key:
11197
11416
  * `variables` is that agent's `inputSchema` (any object before a push),
11198
11417
  * and the platform validates it again against the schema as pushed.
11199
11418
  */
@@ -11208,12 +11427,12 @@ export interface AgentSessionCreateOptions<K extends SessionAgentKeys> {
11208
11427
  title?: string;
11209
11428
  /**
11210
11429
  * Initial participants, who send messages and hold a `read-write` grant
11211
- * on the session's document — #3805. Existing users of this app, not the
11430
+ * on the session's document. Existing users of this app, not the
11212
11431
  * caller; with `viewers`, at most 50.
11213
11432
  */
11214
11433
  participants?: string[];
11215
11434
  /**
11216
- * Initial viewers, who read the session and hold a `reader` grant — #3805.
11435
+ * Initial viewers, who read the session and hold a `reader` grant.
11217
11436
  * Existing users of this app, not the caller, in neither list twice.
11218
11437
  */
11219
11438
  viewers?: string[];
@@ -11225,13 +11444,13 @@ export interface AgentSessionCreateOptions<K extends SessionAgentKeys> {
11225
11444
  userId?: string;
11226
11445
  }
11227
11446
 
11228
- /** What `ctx.agents.createSession` answers — #3803. */
11447
+ /** What `ctx.agents.createSession` answers. */
11229
11448
  export interface AgentSessionCreateResult {
11230
- /** The session: what the app keeps and uses for everything (#4883: its db3 has the same id). */
11449
+ /** The session: what the app keeps and uses for everything (its db3 has the same id). */
11231
11450
  sessionId: string;
11232
11451
  }
11233
11452
 
11234
- /** What `ctx.agents.getSession` answers — #3805. Never the document's rows. */
11453
+ /** What `ctx.agents.getSession` answers. Never the document's rows. */
11235
11454
  export interface AgentSessionInfo {
11236
11455
  sessionId: string;
11237
11456
  agentKey: string;
@@ -11293,7 +11512,7 @@ export interface AgentSessionTurnSummary {
11293
11512
  pending: { kind: "answer" | "end" } | null;
11294
11513
  }
11295
11514
 
11296
- /** One session in `ctx.agents.listSessions` — #3805. */
11515
+ /** One session in `ctx.agents.listSessions`. */
11297
11516
  export interface AgentSessionListItem {
11298
11517
  sessionId: string;
11299
11518
  agentKey: string;
@@ -11317,7 +11536,7 @@ export interface AgentSessionListItem {
11317
11536
  status: AgentSessionStatus | null;
11318
11537
  }
11319
11538
 
11320
- /** What `ctx.agents.listSessions` takes — #3805. */
11539
+ /** What `ctx.agents.listSessions` takes. */
11321
11540
  export interface AgentSessionListOptions {
11322
11541
  /**
11323
11542
  * Whose sessions; omitted, the invoking user's. A run with no caller must
@@ -11344,14 +11563,14 @@ export interface AgentSessionSubjectOptions {
11344
11563
  userId?: string;
11345
11564
  }
11346
11565
 
11347
- /** A page of `ctx.agents.listSessions` — #3805. */
11566
+ /** A page of `ctx.agents.listSessions`. */
11348
11567
  export interface AgentSessionListPage {
11349
11568
  items: AgentSessionListItem[];
11350
11569
  hasMore: boolean;
11351
11570
  nextCursor?: string;
11352
11571
  }
11353
11572
 
11354
- /** What `ctx.agents.recordEvent` takes — #3807. */
11573
+ /** What `ctx.agents.recordEvent` takes. */
11355
11574
  export interface AgentSessionEvent {
11356
11575
  /** An event kind the session's agent declares. */
11357
11576
  kind: string;
@@ -11363,7 +11582,7 @@ export interface AgentSessionEvent {
11363
11582
  refersTo?: string;
11364
11583
  }
11365
11584
 
11366
- /** What `ctx.agents.recordEvent` answers — #3807. */
11585
+ /** What `ctx.agents.recordEvent` answers. */
11367
11586
  export interface AgentSessionEventResult {
11368
11587
  messageId: string;
11369
11588
  seq: number;
@@ -11414,14 +11633,14 @@ export interface UserUsage {
11414
11633
  storage: UserUsageStorage[];
11415
11634
  }
11416
11635
 
11417
- /** One agent's client tools, by name: each one's `input` and `output` (#3798). */
11636
+ /** One agent's client tools, by name: each one's `input` and `output`. */
11418
11637
  export type AgentClientTools<K extends AgentKeys> = PromptSchemas[K] extends {
11419
11638
  agent: { clientTools: infer T };
11420
11639
  }
11421
11640
  ? T
11422
11641
  : never;
11423
11642
 
11424
- /** One agent's event kinds, by name: each one's payload (#3798). */
11643
+ /** One agent's event kinds, by name: each one's payload. */
11425
11644
  export type AgentEvents<K extends AgentKeys> = PromptSchemas[K] extends {
11426
11645
  agent: { events: infer E };
11427
11646
  }
@@ -11436,7 +11655,7 @@ export type PromptOutput<K extends string> = K extends keyof PromptSchemas
11436
11655
  : unknown;
11437
11656
 
11438
11657
  /**
11439
- * Why a prompt's own answer was refused or incomplete — #3330, #4146. Never
11658
+ * Why a prompt's own answer was refused or incomplete. Never
11440
11659
  * set on a PROVIDER failure, which is what makes "the model returned the wrong
11441
11660
  * shape" distinguishable from "the model failed".
11442
11661
  *
@@ -11452,7 +11671,7 @@ export type PromptOutputErrorCode =
11452
11671
  | "PROMPT_OUTPUT_TRUNCATED";
11453
11672
 
11454
11673
  /**
11455
- * Every code the envelope's `errorCode` can carry — #3663, #3813.
11674
+ * Every code the envelope's `errorCode` can carry.
11456
11675
  *
11457
11676
  * `PROMPT_UPSTREAM_TIMEOUT` and `PROMPT_UPSTREAM_REJECTED` are NOT about the
11458
11677
  * prompt's own answer: the provider ran out of time, or refused the request as
@@ -11465,11 +11684,11 @@ export type PromptOutputErrorCode =
11465
11684
  *
11466
11685
  * `PROMPT_CRITERIA_INVALID` is the run that never reached a provider: a
11467
11686
  * decisions run's `variables.criteria` was refused before the call, so
11468
- * nothing was billed (#3813).
11687
+ * nothing was billed.
11469
11688
  *
11470
11689
  * `PROMPT_STRICT_OUTPUT_SCHEMA_MISSING` never reached one either: the config
11471
11690
  * sets `strictOutput = true` and the prompt has no usable `outputSchema` to
11472
- * send as the strict `json_schema` (#3801).
11691
+ * send as the strict `json_schema`.
11473
11692
  *
11474
11693
  * Nor did `PROMPT_SCHEMA_NOT_TRANSLATABLE`: the config runs on Gemini and the
11475
11694
  * prompt's stored `outputSchema` holds a keyword Gemini cannot be sent
@@ -11488,7 +11707,7 @@ export type PromptRunErrorCode =
11488
11707
  export interface PromptRunSuccess<TParsed> {
11489
11708
  success: true;
11490
11709
  output: string;
11491
- /** The parsed, validated answer — no caller-side `JSON.parse` (#3330). */
11710
+ /** The parsed, validated answer — no caller-side `JSON.parse`. */
11492
11711
  parsed: TParsed;
11493
11712
  error?: null;
11494
11713
  errorCode?: null;
@@ -11504,8 +11723,8 @@ export interface PromptRunSuccess<TParsed> {
11504
11723
 
11505
11724
  /**
11506
11725
  * The failure arm, whichever failed. `errorCode` is set for a SHAPE failure,
11507
- * for a refused run (`PROMPT_CRITERIA_INVALID`, #3813), and for a provider
11508
- * one only when the upstream TIMED OUT (#3663); `output` carries the text
11726
+ * for a refused run (`PROMPT_CRITERIA_INVALID`), and for a provider
11727
+ * one only when the upstream TIMED OUT; `output` carries the text
11509
11728
  * either way, which is where the model's own value lives — a validation
11510
11729
  * `error` names paths and schema constraints only.
11511
11730
  */
@@ -11519,7 +11738,7 @@ export interface PromptRunFailure {
11519
11738
  configId: string;
11520
11739
  /**
11521
11740
  * The upstream provider's HTTP status, when the call reached a provider and
11522
- * it answered — #3663. This is what a retry decision is made on: a 504 or a
11741
+ * it answered. This is what a retry decision is made on: a 504 or a
11523
11742
  * 503 is worth another attempt, a 400 on a refused payload is not.
11524
11743
  *
11525
11744
  * It does not depend on which provider the config named: Gemini and
@@ -11549,7 +11768,7 @@ export interface PromptRunOpenResult {
11549
11768
  errorCode?: PromptRunErrorCode | null;
11550
11769
  metrics?: Record<string, unknown>;
11551
11770
  configId: string;
11552
- /** The upstream provider's HTTP status on a provider failure — #3663. */
11771
+ /** The upstream provider's HTTP status on a provider failure. */
11553
11772
  upstreamStatus?: number;
11554
11773
  /**
11555
11774
  * `true` when the provider stopped at the output token limit
@@ -11581,7 +11800,7 @@ export interface SendResult {
11581
11800
  truncated: boolean;
11582
11801
  }
11583
11802
 
11584
- /** Who a channel grant is for, and for how long — #3184. */
11803
+ /** Who a channel grant is for, and for how long. */
11585
11804
  export interface ChannelAuthorizeOptions {
11586
11805
  /**
11587
11806
  * The member the grant names. Caller mode defaults to the invoking caller;
@@ -11601,7 +11820,7 @@ export interface ChannelGrantResult {
11601
11820
  expiresAt: number;
11602
11821
  }
11603
11822
 
11604
- /** Where to start and how big a page to take — #3280. */
11823
+ /** Where to start and how big a page to take. */
11605
11824
  export interface UserPageOptions {
11606
11825
  /** Page size. Capped by the route at 100. */
11607
11826
  limit?: number;
@@ -11854,7 +12073,7 @@ export interface UserWalkStart {
11854
12073
  existing: boolean;
11855
12074
  }
11856
12075
 
11857
- /** How a nested start is keyed and labelled — #3280. */
12076
+ /** How a nested start is keyed and labelled. */
11858
12077
  export interface FunctionStartOptions {
11859
12078
  /**
11860
12079
  * Idempotency key, scoped to the tree's root initiator and the resolved
@@ -11872,7 +12091,7 @@ export interface FunctionStartOptions {
11872
12091
  meta?: Record<string, unknown>;
11873
12092
  }
11874
12093
 
11875
- /** The start envelope, the same one a workflow start answers with — #3280. */
12094
+ /** The start envelope, the same one a workflow start answers with. */
11876
12095
  export interface FunctionStartResult {
11877
12096
  /** Poll this on the platform's run-status route. */
11878
12097
  runId: string;
@@ -11886,14 +12105,14 @@ export interface FunctionStartResult {
11886
12105
  existing?: boolean;
11887
12106
  }
11888
12107
 
11889
- /** A held named lock, as `ctx.locks.acquire` hands it back — #3930. */
12108
+ /** A held named lock, as `ctx.locks.acquire` hands it back. */
11890
12109
  export interface LockHandle {
11891
12110
  key: string;
11892
12111
  handleId: string;
11893
12112
  leaseExpiresAt: string;
11894
12113
  }
11895
12114
 
11896
- /** How long to hold, and how long to wait — #3930. */
12115
+ /** How long to hold, and how long to wait. */
11897
12116
  export interface LockAcquireOptions {
11898
12117
  /** The lease, in milliseconds (at most 24 h). Renew or release before it lapses. */
11899
12118
  ttlMs: number;
@@ -11911,7 +12130,7 @@ export interface LockAcquireOptions {
11911
12130
  }
11912
12131
 
11913
12132
  /**
11914
- * The answer to a blocking acquire — #3930. Never a throw for "not acquired":
12133
+ * The answer to a blocking acquire. Never a throw for "not acquired":
11915
12134
  * a refusal carries the last contention seen, and `rateLimited` says the
11916
12135
  * last attempt was refused by the acquire rate limit rather than by a holder.
11917
12136
  */
@@ -11932,6 +12151,12 @@ export type LockReleaseResult =
11932
12151
  | { released: true }
11933
12152
  | { released: false; reason: "not_holder" | "not_held" };
11934
12153
 
12154
+ /**
12155
+ * `ctx`, the second argument every function handler and `authorize` receives:
12156
+ * who and what triggered this run, and every platform capability a grant can
12157
+ * open — `ctx.api`, `ctx.db3`, `ctx.documents`, `ctx.locks`, `ctx.agents` and
12158
+ * the rest.
12159
+ */
11935
12160
  export interface FunctionContext {
11936
12161
  /** The HTTP caller, or null for a webhook or cron fire. */
11937
12162
  user: FunctionUser | null;
@@ -11947,7 +12172,7 @@ export interface FunctionContext {
11947
12172
  */
11948
12173
  tool?: FunctionToolContext;
11949
12174
  /**
11950
- * Which RUNTIME is hosting this code — #3482.
12175
+ * Which RUNTIME is hosting this code.
11951
12176
  *
11952
12177
  * Beside `trigger`, which says which DOOR fired, and they are different
11953
12178
  * questions: an HTTP call is whichever runtime the caller chose
@@ -11960,7 +12185,34 @@ export interface FunctionContext {
11960
12185
  */
11961
12186
  runtime: "request" | "task";
11962
12187
  /**
11963
- * The RUN this invocation belongs to, or null — #3562.
12188
+ * Signed links to a function of this app, admitted by its
12189
+ * `requireToken`. Signing needs `tokens:sign`.
12190
+ * @beta
12191
+ */
12192
+ actionTokens: {
12193
+ /**
12194
+ * Sign a token that admits its holder to the function `functionKey`
12195
+ * names, through that function's `requireToken`. Needs
12196
+ * `capabilities = ["tokens:sign"]` in this function's TOML (403
12197
+ * `FUNCTION_TOKENS_GRANT_MISSING` otherwise). Options out of range are
12198
+ * refused 400 `ACTION_TOKEN_OPTIONS_INVALID`, and a key this app has no
12199
+ * function for 404 `ACTION_TOKEN_FUNCTION_NOT_FOUND`. Nothing is stored,
12200
+ * and rotating `JWT_SECRET` voids every outstanding token.
12201
+ *
12202
+ * ```ts
12203
+ * const { token } = await ctx.actionTokens.sign({
12204
+ * functionKey: "confirm-email",
12205
+ * args: { email: input.email },
12206
+ * expiresIn: 24 * 3600,
12207
+ * singleUse: true,
12208
+ * });
12209
+ * ```
12210
+ * @beta
12211
+ */
12212
+ sign(options: ActionTokenSignOptions): Promise<ActionToken>;
12213
+ };
12214
+ /**
12215
+ * The RUN this invocation belongs to, or null.
11964
12216
  *
11965
12217
  * Set under the task runtime (every slice of the run, the first and every
11966
12218
  * resume) and for a webhook-fired request run, which writes a row. Null for
@@ -11972,7 +12224,7 @@ export interface FunctionContext {
11972
12224
  */
11973
12225
  runId: string | null;
11974
12226
  /**
11975
- * The SLICE of the run this code is running in, or null — #3562.
12227
+ * The SLICE of the run this code is running in, or null.
11976
12228
  *
11977
12229
  * The same identifier `primitive functions runs` and the run-status
11978
12230
  * route's `slice.sliceId` report. A task run is a sequence of slices: it
@@ -11986,7 +12238,7 @@ export interface FunctionContext {
11986
12238
  /**
11987
12239
  * A typed handle over one database. The second argument is the database TYPE
11988
12240
  * key — the same key a `database:<type>/<model>:read|write` grant names —
11989
- * and it is what selects the models this handle knows (#3182).
12241
+ * and it is what selects the models this handle knows.
11990
12242
  * @deprecated Use `ctx.db3`, the typed db3 handle.
11991
12243
  */
11992
12244
  db<K extends DatabaseTypeKeys>(
@@ -12043,7 +12295,7 @@ export interface FunctionContext {
12043
12295
  */
12044
12296
  doc(documentId: string, options?: { documentFormat?: 1 | 2 | 3 }): DocumentHandle;
12045
12297
  /**
12046
- * Outbound HTTP, through a granted integration and nowhere else (#3183).
12298
+ * Outbound HTTP, through a granted integration and nowhere else.
12047
12299
  *
12048
12300
  * A function has no raw network access: every `fetch` to a host that is not
12049
12301
  * the platform answers `FUNCTION_EGRESS_DENIED`, grant or no grant. What an
@@ -12060,7 +12312,7 @@ export interface FunctionContext {
12060
12312
  ): Promise<IntegrationCallResult>;
12061
12313
  };
12062
12314
  /**
12063
- * Start another function as a TASK run from inside this one — #3280.
12315
+ * Start another function as a TASK run from inside this one.
12064
12316
  *
12065
12317
  * The one nested door, and it is a START: code that wants a result composes
12066
12318
  * by IMPORTING the other function, so there is no synchronous nested
@@ -12080,14 +12332,14 @@ export interface FunctionContext {
12080
12332
  ): Promise<FunctionStartResult>;
12081
12333
  };
12082
12334
  /**
12083
- * Run one of the app's prompts, with nothing to declare (#3183, #3279).
12335
+ * Run one of the app's prompts, with nothing to declare.
12084
12336
  *
12085
12337
  * The calling function's `authorize` is the authorization: it decided who
12086
12338
  * may invoke the function, and so who may run the prompt, which carries no
12087
12339
  * rule of its own. The provider request is bounded by the invocation's own
12088
12340
  * deadline.
12089
12341
  *
12090
- * TYPED BY KEY (#3330). Where `prompts/<key>.toml` declares an
12342
+ * TYPED BY KEY. Where `prompts/<key>.toml` declares an
12091
12343
  * `outputSchema`, the platform parses the answer, validates it against that
12092
12344
  * schema and hands it back as `parsed`, typed — so the shape is written once
12093
12345
  * in TOML instead of restated as a `JSON.parse` at every call site. Where
@@ -12110,7 +12362,7 @@ export interface FunctionContext {
12110
12362
  ): Promise<PromptRunResult<K>>;
12111
12363
  };
12112
12364
  /**
12113
- * Agent sessions (#3803, project `agents`), on the header's subject rule:
12365
+ * Agent sessions (project `agents`), on the header's subject rule:
12114
12366
  * each call acts for `userId`, else the invoking user, and from any kind of
12115
12367
  * run — a run with no caller must name the member.
12116
12368
  *
@@ -12119,9 +12371,9 @@ export interface FunctionContext {
12119
12371
  * `inputSchema` reject with `AGENT_SESSION_VARIABLES_INVALID` and
12120
12372
  * `details.errors`. Once a tree has pushed, a key that is not an agent,
12121
12373
  * and variables the agent's schema refuses, are compile errors.
12122
- * `participants` and `viewers` name initial members (#3805).
12374
+ * `participants` and `viewers` name initial members.
12123
12375
  *
12124
- * `getSession` and `listSessions` (#3805) read the member's sessions —
12376
+ * `getSession` and `listSessions` read the member's sessions —
12125
12377
  * the ones they own or are a member of — as that member, with no admin arm
12126
12378
  * whoever invoked the function: a session they are not in answers
12127
12379
  * `AGENT_SESSION_NOT_FOUND`, and function code never sees a session's
@@ -12137,7 +12389,7 @@ export interface FunctionContext {
12137
12389
  * `SUBJECT_USER_INVALID`, never read as the invoking user. Renaming and
12138
12390
  * changing members are the owner's, from a client.
12139
12391
  *
12140
- * `recordEvent` (#3807) records an event as the member, who must be the
12392
+ * `recordEvent` records an event as the member, who must be the
12141
12393
  * session's owner or a participant (`AGENT_SESSION_PARTICIPANT_ONLY` for a
12142
12394
  * viewer); the row is authored `app`. The kind must be one the agent
12143
12395
  * declares (`AGENT_EVENT_KIND_UNKNOWN`) and the data must match its schema
@@ -12189,7 +12441,7 @@ export interface FunctionContext {
12189
12441
  forUser(userId: string, options?: UsageWindowOptions): Promise<UserUsage>;
12190
12442
  };
12191
12443
  /**
12192
- * The value of one app secret, under a `secret:<NAME>` grant (#3183).
12444
+ * The value of one app secret, under a `secret:<NAME>` grant.
12193
12445
  *
12194
12446
  * Prefer `ctx.integrations.call` when the secret is a credential FOR an
12195
12447
  * integration: there the value is injected by the platform and never enters
@@ -12202,13 +12454,12 @@ export interface FunctionContext {
12202
12454
  */
12203
12455
  secret(name: string): Promise<string>;
12204
12456
  /**
12205
- * The value of one app config var, under a `var:<NAME>` grant (#3183).
12457
+ * The value of one app config var, under a `var:<NAME>` grant.
12206
12458
  * @public
12207
12459
  */
12208
12460
  configVar(name: string): Promise<string>;
12209
12461
  /**
12210
- * Realtime messages to this app's clients, under a `users:send` grant
12211
- * (#3183).
12462
+ * Realtime messages to this app's clients, under a `users:send` grant.
12212
12463
  *
12213
12464
  * The recipient's client receives a `direct.message` frame carrying this
12214
12465
  * payload and the sending function's key. Presence is not guaranteed: a
@@ -12217,7 +12468,7 @@ export interface FunctionContext {
12217
12468
  */
12218
12469
  users: {
12219
12470
  /**
12220
- * One page of the app's users — #3280.
12471
+ * One page of the app's users.
12221
12472
  *
12222
12473
  * On the APP's system authority, whoever invoked the function: a member
12223
12474
  * who passes this function's gate reads whatever roster it chooses to
@@ -12229,7 +12480,7 @@ export interface FunctionContext {
12229
12480
  */
12230
12481
  list(options?: UserPageOptions): Promise<UserPage>;
12231
12482
  /**
12232
- * Every page of the app's users, in order — #3280.
12483
+ * Every page of the app's users, in order.
12233
12484
  *
12234
12485
  * FOR A REQUEST FUNCTION AND A SINGLE-SLICE LOOP. A durable loop must take
12235
12486
  * its pages inside `step.do` with an EXPLICIT cursor: a memoized step does
@@ -12335,7 +12586,7 @@ export interface FunctionContext {
12335
12586
  };
12336
12587
  /**
12337
12588
  * Realtime channels, under a `channel:<namespace>` grant that COVERS the
12338
- * channel — #3184.
12589
+ * channel.
12339
12590
  *
12340
12591
  * `authorize` hands back a short-lived grant for ONE member to present on
12341
12592
  * the socket it already has; `publish` delivers a `channel.message` frame to
@@ -12353,7 +12604,7 @@ export interface FunctionContext {
12353
12604
  publish(channel: string, payload: unknown): Promise<SendResult>;
12354
12605
  };
12355
12606
  /**
12356
- * Named locks that WAIT — #3930. `ctx.api.locks.tryAcquire` is one attempt;
12607
+ * Named locks that WAIT. `ctx.api.locks.tryAcquire` is one attempt;
12357
12608
  * these wait for the key, up to `timeoutMs` (at most one hour).
12358
12609
  *
12359
12610
  * The owner defaults to `ctx.runId`, so a run never waits on its own hold:
@@ -12425,17 +12676,18 @@ export type FunctionContextFor<K extends FunctionTriggerKind> = FunctionContext
12425
12676
  export type StepBackoff = "constant" | "linear" | "exponential";
12426
12677
 
12427
12678
  /**
12428
- * The retry and timeout policy for ONE `step.do` — Cloudflare Workflows' own
12429
- * step config.
12679
+ * The retry and timeout policy for ONE `step.do` — the TASK runner's
12680
+ * workflow engine's own step config.
12430
12681
  *
12431
- * Under the TASK runner the platform forwards this object to Workflows
12432
- * untouched, so these are its fields and its spellings: a duration is either a
12433
- * number of milliseconds or a string Workflows parses (`"10 seconds"`,
12434
- * `"5 minutes"`). Under the REQUEST runner `step.do` accepts a config and
12435
- * ignores it — the body runs inline, and there is nothing to retry into.
12682
+ * Under the TASK runner the platform forwards this object to the workflow
12683
+ * engine untouched, so these are its fields and its spellings: a duration is
12684
+ * either a number of milliseconds or a string the engine parses
12685
+ * (`"10 seconds"`, `"5 minutes"`). Under the REQUEST runner `step.do` accepts
12686
+ * a config and ignores it — the body runs inline, and there is nothing to
12687
+ * retry into.
12436
12688
  *
12437
12689
  * `stepPolicy.<family>` IS a `StepConfig`, so the platform's own defaults
12438
- * hand straight to `step.do` (#3657). The shape is closed on purpose: a key
12690
+ * hand straight to `step.do`. The shape is closed on purpose: a key
12439
12691
  * outside it — `retry` for `retries`, `timeoutMs` for `timeout` — is a
12440
12692
  * refusal at `config push` rather than an option the engine silently drops.
12441
12693
  */
@@ -12446,11 +12698,11 @@ export interface StepConfig {
12446
12698
 
12447
12699
  /**
12448
12700
  * The step handle. `step` is the third argument under BOTH runners, so the
12449
- * same body runs either way — which is what `mode = "any"` is for (#3454).
12701
+ * same body runs either way — which is what `mode = "any"` is for.
12450
12702
  *
12451
- * Under the TASK runner it is Cloudflare Workflows' `WorkflowStep`, forwarded
12452
- * untouched: `step.do` results are memoized and replayed, and `step.sleep`
12453
- * hibernates.
12703
+ * Under the TASK runner it is the workflow engine's own step handle,
12704
+ * forwarded untouched: `step.do` results are memoized and replayed, and
12705
+ * `step.sleep` hibernates.
12454
12706
  *
12455
12707
  * Under the REQUEST runner it is the platform's own, bounded by the request's
12456
12708
  * clock: `do` executes the body inline (there is no engine to memoize into,
@@ -12463,25 +12715,31 @@ export interface StepConfig {
12463
12715
  * keeps catching it.
12464
12716
  */
12465
12717
  export interface FunctionStep {
12718
+ /** Run `body` as one named, retryable unit; `config` overrides `stepPolicy.<family>`'s defaults. */
12466
12719
  do<T>(name: string, body: () => T | Promise<T>): Promise<T>;
12720
+ /** Run `body` as one named, retryable unit, under its own `config` rather than `stepPolicy.<family>`'s. */
12467
12721
  do<T>(
12468
12722
  name: string,
12469
12723
  config: StepConfig,
12470
12724
  body: () => T | Promise<T>
12471
12725
  ): Promise<T>;
12726
+ /** Pause this run for `duration` under this step's name. */
12472
12727
  sleep(name: string, duration: number | string): Promise<void>;
12728
+ /** Pause this run until `timestamp` under this step's name. */
12473
12729
  sleepUntil(name: string, timestamp: Date | number): Promise<void>;
12730
+ /** Pause this run until an external event under this step's name arrives, or forever if none does. */
12474
12731
  waitForEvent<T = unknown>(
12475
12732
  name: string,
12476
12733
  options: Record<string, unknown>
12477
12734
  ): Promise<T>;
12478
12735
  }
12479
12736
 
12737
+ /** The version of this type surface, for tooling that needs to tell SDK releases apart. */
12480
12738
  export declare const SDK_STUB_VERSION: string;
12481
12739
 
12482
12740
  /**
12483
12741
  * Thrown by `assertRuntime` when this function is running under the other
12484
- * runtime — #3482.
12742
+ * runtime.
12485
12743
  *
12486
12744
  * The platform settles it as `status: "failed"` with
12487
12745
  * `errorCode: "FUNCTION_RUNTIME_REFUSED"`, on a request invocation's
@@ -12496,7 +12754,7 @@ export declare class FunctionRuntimeError extends Error {
12496
12754
  }
12497
12755
 
12498
12756
  /**
12499
- * Refuse the runtime this function was not written for — #3482.
12757
+ * Refuse the runtime this function was not written for.
12500
12758
  *
12501
12759
  * A function is a function and the caller picks the runtime at each call, so
12502
12760
  * nothing in config says which one a function may run under. This is the lock,
@@ -12558,7 +12816,7 @@ export declare function assertTrigger<K extends FunctionTriggerKind>(
12558
12816
  /**
12559
12817
  * The handler a function exports, typed for one declared key.
12560
12818
  *
12561
- * `step` is the third argument under BOTH runners (#3186, #3454). A task run
12819
+ * `step` is the third argument under BOTH runners. A task run
12562
12820
  * gets the engine's live `WorkflowStep`; a request invocation gets the
12563
12821
  * platform's own, where `do` runs the body inline and a wait the request
12564
12822
  * budget cannot cover fails the invocation naming the task runner — so a
@@ -12676,13 +12934,22 @@ export interface AuthDb3ModelHandle<TRow, TQuery = DocumentQueryOptions> {
12676
12934
 
12677
12935
  /** One db3, typed by its type the way `ctx.db3` is, with reads only. */
12678
12936
  export interface AuthDb3Handle<TModels, TQueries = {}> {
12679
- /** @beta */
12937
+ /**
12938
+ * One model on this db3, typed from its schema.
12939
+ * @beta
12940
+ */
12680
12941
  model<M extends Db3ModelNames<TModels>>(modelName: M): AuthDb3ModelHandle<Db3ModelRow<TModels, M>, Db3ModelQueryOptions<TQueries, M>>;
12681
12942
  /**
12682
12943
  * The caller's level on the db3, or `null`: none, not a db3 of this app, or its sync is off. One read.
12683
12944
  * @beta
12684
12945
  */
12685
12946
  permissions(): Promise<DocumentPermission | null>;
12947
+ /**
12948
+ * `"reader"` when the db3 is public and the app's `signedOutAccess` is on, or `null`: not public,
12949
+ * not a db3 of this app, or the setting is off. The same for every caller, signed out included. One read.
12950
+ * @beta
12951
+ */
12952
+ publicAccess(): Promise<"reader" | null>;
12686
12953
  }
12687
12954
 
12688
12955
  /** One document, for reading inside `authorize`; its models are typed the way `ctx.doc`'s are. */
@@ -12933,6 +13200,136 @@ export declare function requireDocumentOwner<TInput = any>(
12933
13200
  documentIdOf: (input: TInput) => string
12934
13201
  ): AuthorizeHelper<TInput, { userId: string; documentId: string }>;
12935
13202
 
13203
+ /**
13204
+ * An `authorize` that admits any caller, signed out included, to the db3
13205
+ * `db3IdOf(input)` names while it is public and the app's
13206
+ * `signedOutAccess` is on, resolving `{ db3Id }`. Any other db3 (private,
13207
+ * unknown, another app's, or the setting off) answers 404 `NOT_FOUND`. An
13208
+ * input that names no db3 id is denied `INVALID`. One read. `type` types
13209
+ * the handle and is not checked against the db3.
13210
+ *
13211
+ * ```ts
13212
+ * import { defineFunction, requirePublicDb3 } from "primitive-functions";
13213
+ *
13214
+ * export default defineFunction({
13215
+ * authorize: requirePublicDb3((input: { db3Id: string }) => input.db3Id),
13216
+ * handler: async (input, ctx) => ctx.api.db3.get({ db3Id: ctx.auth.db3Id }),
13217
+ * });
13218
+ * ```
13219
+ * @beta
13220
+ */
13221
+ export declare function requirePublicDb3<TInput = any>(
13222
+ db3IdOf: (input: TInput) => string,
13223
+ type?: Db3TypeKeys
13224
+ ): AuthorizeHelper<TInput, { db3Id: string }>;
13225
+
13226
+ /** What `requireDb3Level` takes beside the level. */
13227
+ export interface Db3LevelOptions {
13228
+ /** Also admit anyone while the db3 is public. Needs `minLevel` `"reader"`. */
13229
+ orPublic?: boolean;
13230
+ }
13231
+
13232
+ /**
13233
+ * An `authorize` that admits a signed-in caller whose level on the db3
13234
+ * `db3IdOf(input)` names is `minLevel` or above, ranked owner >
13235
+ * read-write > reader, resolving `{ db3Id, via: "sharing", level }` with the
13236
+ * level they hold. With `{ orPublic: true }` it also admits anyone, signed
13237
+ * out included, while the db3 is public and the app's `signedOutAccess` is
13238
+ * on, resolving `{ db3Id, via: "public", level: "reader" }`. Every caller it
13239
+ * does not admit gets 404 `NOT_FOUND`; an input that names no db3 id is
13240
+ * denied `INVALID`. Sharing is read first, and skipped for a caller who is
13241
+ * not signed in.
13242
+ * @beta
13243
+ */
13244
+ export declare function requireDb3Level<TInput = any>(
13245
+ db3IdOf: (input: TInput) => string,
13246
+ type: Db3TypeKeys | undefined,
13247
+ minLevel: "reader",
13248
+ options: Db3LevelOptions & { orPublic: true }
13249
+ ): AuthorizeHelper<TInput, { db3Id: string; via: "sharing" | "public"; level: DocumentPermission }>;
13250
+ /**
13251
+ * Without `orPublic`, an `authorize` that admits only through sharing:
13252
+ * a signed-in caller whose level on the db3 is `minLevel` or above,
13253
+ * resolving `{ db3Id, via: "sharing", level }`.
13254
+ * @beta
13255
+ */
13256
+ export declare function requireDb3Level<TInput = any>(
13257
+ db3IdOf: (input: TInput) => string,
13258
+ type: Db3TypeKeys | undefined,
13259
+ minLevel: DocumentPermission,
13260
+ options?: Db3LevelOptions & { orPublic?: false }
13261
+ ): AuthorizeHelper<TInput, { db3Id: string; via: "sharing"; level: DocumentPermission }>;
13262
+
13263
+ /** One item an invitation shares, as {@link requireInvitation} resolves it. */
13264
+ export type InvitationSharedItem =
13265
+ | { kind: "db3"; id: string; title: string; level: "read-write" | "reader" }
13266
+ | { kind: "group"; id: string; groupType: string; title: string; level: "owner" | "manager" | "member" }
13267
+ | { kind: "collection"; id: string; title: string; level: string };
13268
+
13269
+ /** What {@link requireInvitation} resolves as `ctx.auth`. */
13270
+ export interface InvitationAuth {
13271
+ invitationId: string;
13272
+ /** Who created the invitation; `sys:<appId>` for a function run nobody started. */
13273
+ inviterId: string;
13274
+ /** The app role the invitation offers. */
13275
+ role: string;
13276
+ /** At most 20 items, oldest grant first; every `id` is of this app. */
13277
+ shared: InvitationSharedItem[];
13278
+ /** The invitation shares more than `shared` lists. */
13279
+ sharedTruncated: boolean;
13280
+ }
13281
+
13282
+ /**
13283
+ * An `authorize` that admits any caller, signed in or signed out, who
13284
+ * presents a token of this app's invitation that is unaccepted, unexpired and
13285
+ * still shares something, resolving the invitation as `ctx.auth`: its id,
13286
+ * the inviter's id, the offered role and what it shares (db3s, groups and
13287
+ * collections that still exist, each with its id). Every other token answers
13288
+ * 404 `NOT_FOUND`; an input that names no token is denied `INVALID`. One
13289
+ * read. An answer it admitted is never cached, so a version that uses it may
13290
+ * not declare `cacheSeconds`. A signed-out caller reaches it only through a
13291
+ * `public` function in an app with `signedOutAccess` on.
13292
+ *
13293
+ * ```ts
13294
+ * import { defineFunction, requireInvitation } from "primitive-functions";
13295
+ *
13296
+ * export default defineFunction({
13297
+ * authorize: requireInvitation((input: { inviteToken: string }) => input.inviteToken),
13298
+ * handler: async (input, ctx) => ({ shared: ctx.auth.shared.map((item) => item.title) }),
13299
+ * });
13300
+ * ```
13301
+ * @beta
13302
+ */
13303
+ export declare function requireInvitation<TInput = any>(
13304
+ tokenOf: (input: TInput) => string
13305
+ ): AuthorizeHelper<TInput, InvitationAuth>;
13306
+
13307
+ /**
13308
+ * An `authorize` that admits whoever presents an action token
13309
+ * `tokenOf(input)` selects, signed for this function with
13310
+ * `ctx.actionTokens.sign`, resolving `{ args, tokenId }` with the
13311
+ * arguments the token binds. Signed-out and signed-in callers are admitted
13312
+ * alike. A single-use token is spent before the handler runs, and stays spent
13313
+ * if the handler fails. A token that has expired, was altered, is for another
13314
+ * function, is of another app or was signed before `JWT_SECRET` rotated
13315
+ * answers 404 `NOT_FOUND` with a message saying why; an input that names no
13316
+ * token is denied `INVALID`. The answer is never cached, and
13317
+ * `ctx.reauthorize()` throws in a run a single-use token admitted. One read.
13318
+ *
13319
+ * ```ts
13320
+ * import { defineFunction, requireToken } from "primitive-functions";
13321
+ *
13322
+ * export default defineFunction({
13323
+ * authorize: requireToken((input: { token: string }) => input.token),
13324
+ * handler: async (input, ctx) => ({ orderId: ctx.auth.args.orderId }),
13325
+ * });
13326
+ * ```
13327
+ * @beta
13328
+ */
13329
+ export declare function requireToken<TInput = any, TArgs extends Record<string, unknown> = Record<string, any>>(
13330
+ tokenOf: (input: TInput) => string
13331
+ ): AuthorizeHelper<TInput, { args: TArgs; tokenId: string }>;
13332
+
12936
13333
  /**
12937
13334
  * Which doors {@link allowCallers} admits. `users` decides on `http` only.
12938
13335
  * The agent doors (`tool`, `context`, `history`) are admitted only
@@ -12981,6 +13378,32 @@ export declare function allowCallers<TInput = any, TAuth = never, TAgentAuth = n
12981
13378
  rules: CallerRules<TInput, TAuth, TAgentAuth>
12982
13379
  ): AuthorizeHelper<TInput, TAuth | TAgentAuth | null>;
12983
13380
 
13381
+ /** What `ctx.actionTokens.sign` takes. */
13382
+ export interface ActionTokenSignOptions {
13383
+ /** The key of the function of this app the token admits its holder to. */
13384
+ functionKey: string;
13385
+ /**
13386
+ * What the token binds, read by that function as `ctx.auth.args`: a JSON
13387
+ * object of at most 2,048 bytes. Signed, not encrypted: whoever holds the
13388
+ * link can read it.
13389
+ */
13390
+ args: Record<string, unknown>;
13391
+ /** Seconds until the token expires: an integer from 1 to 31,536,000 (365 days). */
13392
+ expiresIn: number;
13393
+ /** Admit once: the first use spends the token. Defaults to false. */
13394
+ singleUse?: boolean;
13395
+ }
13396
+
13397
+ /** A signed action token, as `ctx.actionTokens.sign` answers it. */
13398
+ export interface ActionToken {
13399
+ /** The token, `v1.<keyId>.<payload>.<sig>`: put it in the link. */
13400
+ token: string;
13401
+ /** The token's id; a single-use token's spent row is read by it. */
13402
+ tokenId: string;
13403
+ /** When it expires, ISO 8601. */
13404
+ expiresAt: string;
13405
+ }
13406
+
12984
13407
  /**
12985
13408
  * What the object form's handler reads beside `FunctionContext`: the value
12986
13409
  * `authorize` resolved when the invocation was admitted, and a way to ask
@@ -13028,11 +13451,15 @@ export type WriteAuthorizeBeforeHandler =
13028
13451
  | boolean
13029
13452
  | symbol;
13030
13453
 
13031
- // The object `WriteAuthorizeBeforeHandler` stands for: it has no field a
13032
- // handler could read as any type. The member only keeps the marker distinct;
13033
- // it is `unknown`, not `never`, so reading it proves nothing, and optional,
13034
- // so an `in` check that finds it absent does not narrow the object to `never`.
13035
- interface AuthorizeNotInferred {
13454
+ /**
13455
+ * @internal Exported only so TypeDoc can resolve {@link WriteAuthorizeBeforeHandler}'s
13456
+ * link to it; an author never names it. The object it stands for has no field
13457
+ * a handler could read as any type. The member only keeps the marker
13458
+ * distinct; it is `unknown`, not `never`, so reading it proves nothing, and
13459
+ * optional, so an `in` check that finds it absent does not narrow the object
13460
+ * to `never`.
13461
+ */
13462
+ export interface AuthorizeNotInferred {
13036
13463
  /** Never present: this type only names the fix in a compile error. */
13037
13464
  readonly writeAuthorizeBeforeHandler?: unknown;
13038
13465
  }
@@ -13067,34 +13494,48 @@ export type FunctionApprovedInput<TInput, I extends PropertyKey> = [I] extends [
13067
13494
  ? Pick<TInput, Extract<I, keyof TInput>>
13068
13495
  : never;
13069
13496
 
13070
- // Names a type where the compiler must not infer from it, so the `input`
13071
- // list is the only place the approved keys come from and the checks below
13072
- // only ever read what was inferred elsewhere. Not the intrinsic `NoInfer`,
13073
- // which would raise the TypeScript these declarations need to 5.4.
13074
- type ListedOnly<T> = [T][T extends any ? 0 : never];
13075
-
13076
- // The type an object form's `input` list is checked against, once the list
13077
- // `L` is inferred: `L` itself when every key it names is one of `TKey`,
13078
- // and the keys otherwise, so the refusal names the key. The list is a
13079
- // literal array (a tuple once inferred): a widened array, whose type does
13080
- // not say which keys it holds, is refused, so its type never approves a key
13081
- // the value may not name. The check sits here and not in a constraint on
13082
- // `L`: an `authorize` whose `auth` is not annotated supplies the unkeyed
13083
- // `TInput` only after the list is read, and a constraint over it would see
13084
- // no keys.
13085
- type ListedList<L extends readonly string[], TKey extends string> = [L[number]] extends [TKey]
13497
+ /**
13498
+ * @internal Exported only so `defineFunction`'s overloads can name it; an
13499
+ * author never writes it. Names a type where the compiler must not infer
13500
+ * from it, so the `input` list is the only place the approved keys come
13501
+ * from and the checks below only ever read what was inferred elsewhere.
13502
+ * Not the intrinsic `NoInfer`, which would raise the TypeScript these
13503
+ * declarations need to 5.4.
13504
+ */
13505
+ export type ListedOnly<T> = [T][T extends any ? 0 : never];
13506
+
13507
+ /**
13508
+ * @internal Exported only so `defineFunction`'s overloads can name it; an
13509
+ * author never writes it. The type an object form's `input` list is
13510
+ * checked against, once the list `L` is inferred: `L` itself when every
13511
+ * key it names is one of `TKey`, and the keys otherwise, so the refusal
13512
+ * names the key. The list is a literal array (a tuple once inferred): a
13513
+ * widened array, whose type does not say which keys it holds, is refused,
13514
+ * so its type never approves a key the value may not name. The check sits
13515
+ * here and not in a constraint on `L`: an `authorize` whose `auth` is not
13516
+ * annotated supplies the unkeyed `TInput` only after the list is read, and
13517
+ * a constraint over it would see no keys.
13518
+ */
13519
+ export type ListedList<L extends readonly string[], TKey extends string> = [L[number]] extends [TKey]
13086
13520
  ? number extends L["length"]
13087
13521
  ? readonly ["an input list is a literal array of the keys the handler reads"]
13088
13522
  : L
13089
13523
  : readonly TKey[];
13090
13524
 
13091
- // The unkeyed form's keys, over `keyof`: a mapped type here fixes `TInput`
13092
- // before an `authorize` whose `auth` is not annotated is read.
13093
- type ListedInputKey<TInput> = TInput extends unknown ? keyof TInput & string : never;
13525
+ /**
13526
+ * @internal Exported only so `defineFunction`'s overloads can name it; an
13527
+ * author never writes it. The unkeyed form's keys, over `keyof`: a mapped
13528
+ * type here fixes `TInput` before an `authorize` whose `auth` is not
13529
+ * annotated is read.
13530
+ */
13531
+ export type ListedInputKey<TInput> = TInput extends unknown ? keyof TInput & string : never;
13094
13532
 
13095
- // A list named in explicit type arguments is still written on the
13096
- // definition: the type arguments alone approve nothing.
13097
- type ListWritten<L> = [L] extends [never] ? {} : L extends readonly [] ? {} : { input: unknown };
13533
+ /**
13534
+ * @internal Exported only so `defineFunction`'s overloads can name it; an
13535
+ * author never writes it. A list named in explicit type arguments is still
13536
+ * written on the definition: the type arguments alone approve nothing.
13537
+ */
13538
+ export type ListWritten<L> = [L] extends [never] ? {} : L extends readonly [] ? {} : { input: unknown };
13098
13539
 
13099
13540
  // The keys a handler's own input type reads that the approved input `H`
13100
13541
  // does not have, member by member for a union on either side.
@@ -13102,12 +13543,16 @@ type UnlistedReads<P, H> = P extends unknown
13102
13543
  ? Exclude<keyof P, H extends unknown ? keyof H : never>
13103
13544
  : never;
13104
13545
 
13105
- // The handler's input type `P` is inferred from its own annotation (or is
13106
- // `H` when it has none), so an annotation never widens what it reads: one
13107
- // naming a key the list does not, even an optional one, is refused by name,
13108
- // and one the approved input is not assignable to is refused as before. An
13109
- // explicit `any` is the author's own way out and is left alone.
13110
- type ApprovedHandler<P, H> = 0 extends 1 & P
13546
+ /**
13547
+ * @internal Exported only so `defineFunction`'s overloads can name it; an
13548
+ * author never writes it. The handler's input type `P` is inferred from
13549
+ * its own annotation (or is `H` when it has none), so an annotation never
13550
+ * widens what it reads: one naming a key the list does not, even an
13551
+ * optional one, is refused by name, and one the approved input is not
13552
+ * assignable to is refused as before. An explicit `any` is the author's
13553
+ * own way out and is left alone.
13554
+ */
13555
+ export type ApprovedHandler<P, H> = 0 extends 1 & P
13111
13556
  ? {}
13112
13557
  : [UnlistedReads<P, H>] extends [never]
13113
13558
  ? [H] extends [P]
@@ -13143,16 +13588,19 @@ export interface FunctionDefinition<
13143
13588
  ) => TOutput | Promise<TOutput>;
13144
13589
  }
13145
13590
 
13146
- // What `defineFunction` holds `authorize` to. Uninferred, `TAuth` is
13147
- // `WriteAuthorizeBeforeHandler | null` and `authorize` is accepted as
13148
- // written, so the errors land on the `ctx.auth` read; the `null` keeps
13149
- // that read as null-safe as a bare `allow()` needs. `never` passes
13150
- // through first: it is what a helper such as `allowCallers(...)` sees for a
13151
- // `TAuth` not inferred yet, and turned into `unknown` it would be
13152
- // inferred as the helper's own value. The fallback is matched both ways: an
13153
- // explicit `null` is assignable to it and must still hold `authorize` to
13154
- // itself.
13155
- type DefinedAuthorize<TAuth> = [TAuth] extends [never]
13591
+ /**
13592
+ * @internal Exported only so `defineFunction`'s overloads can name it; an
13593
+ * author never writes it. What `defineFunction` holds `authorize` to.
13594
+ * Uninferred, `TAuth` is {@link WriteAuthorizeBeforeHandler} `| null` and
13595
+ * `authorize` is accepted as written, so the errors land on the `ctx.auth`
13596
+ * read; the `null` keeps that read as null-safe as a bare `allow()` needs.
13597
+ * `never` passes through first: it is what a helper such as
13598
+ * `allowCallers(...)` sees for a `TAuth` not inferred yet, and turned into
13599
+ * `unknown` it would be inferred as the helper's own value. The fallback is
13600
+ * matched both ways: an explicit `null` is assignable to it and must still
13601
+ * hold `authorize` to itself.
13602
+ */
13603
+ export type DefinedAuthorize<TAuth> = [TAuth] extends [never]
13156
13604
  ? TAuth
13157
13605
  : [TAuth] extends [WriteAuthorizeBeforeHandler | null]
13158
13606
  ? [WriteAuthorizeBeforeHandler | null] extends [TAuth]
@@ -13273,6 +13721,9 @@ export declare function defineFunction<TInput = unknown, TOutput = unknown>(
13273
13721
  ) => TOutput | Promise<TOutput>
13274
13722
  ): FunctionHandler<TInput, TOutput>;
13275
13723
 
13724
+ /** The scalar parameter types, and an array parameter's element types. */
13725
+ export type QueryScalarParamType = "string" | "number" | "boolean" | "any";
13726
+
13276
13727
  /**
13277
13728
  * One declared parameter of a registered query.
13278
13729
  *
@@ -13280,9 +13731,6 @@ export declare function defineFunction<TInput = unknown, TOutput = unknown>(
13280
13731
  * the platform injects the invocation's user and refuses a call that supplies
13281
13732
  * the parameter itself.
13282
13733
  */
13283
- /** The scalar parameter types, and an array parameter's element types. */
13284
- export type QueryScalarParamType = "string" | "number" | "boolean" | "any";
13285
-
13286
13734
  export interface QueryParamSpec {
13287
13735
  type?: QueryScalarParamType | "$caller" | "array";
13288
13736
  /** For `type: "array"` — the element type; absent means any element. */
@@ -13314,7 +13762,12 @@ export type QueryParamValue<S> = S extends { caller: true }
13314
13762
  ? QueryScalarValue<T>
13315
13763
  : any;
13316
13764
 
13317
- type QueryOptionalKeys<P> = {
13765
+ /**
13766
+ * @internal Exported only so {@link QueryParams} can name it; an author never
13767
+ * writes it. The keys of `P` declared `optional: true` — the ones
13768
+ * `QueryParams` keeps optional.
13769
+ */
13770
+ export type QueryOptionalKeys<P> = {
13318
13771
  [K in keyof P]: P[K] extends { optional: true } ? K : never;
13319
13772
  }[keyof P];
13320
13773
 
@@ -13338,6 +13791,12 @@ export interface TypedQueryDefinition<TDb, TSpec extends Record<string, QueryPar
13338
13791
  run: (db: TDb, params: QueryParams<TSpec>) => TResult | Promise<TResult>;
13339
13792
  }
13340
13793
 
13794
+ /**
13795
+ * A registration's definition with its parameters UNDECLARED: `run` reads
13796
+ * `params` loosely typed as `TParams`, the type argument the caller supplied.
13797
+ * Prefer declaring `params` (see {@link TypedQueryDefinition}), which types
13798
+ * `run`'s `params` from the declaration instead.
13799
+ */
13341
13800
  export interface QueryDefinition<TDb, TParams, TResult> {
13342
13801
  /** The models this query touches. Caching is off unless the run matches. */
13343
13802
  models: string[];
@@ -13353,7 +13812,7 @@ export interface QueryDefinition<TDb, TParams, TResult> {
13353
13812
  }
13354
13813
 
13355
13814
  /**
13356
- * Register a named query over a database handle (#3187).
13815
+ * Register a named query over a database handle.
13357
13816
  *
13358
13817
  * A registration helper, not a language: `run` is ordinary code over the same
13359
13818
  * typed handle, and what registration adds is a name, declared parameters
@@ -13410,7 +13869,7 @@ export declare function defineMutation<
13410
13869
  export declare const MAX_QUERY_CACHE_TTL_MS: number;
13411
13870
 
13412
13871
  /**
13413
- * Map over items with BOUNDED concurrency (#3187). Results come back in the
13872
+ * Map over items with BOUNDED concurrency. Results come back in the
13414
13873
  * input's order; the first rejection wins and nothing new is started after it.
13415
13874
  *
13416
13875
  * The bound matters inside a sandbox: an unbounded fan-out over a page of rows
@@ -13461,6 +13920,40 @@ export declare function decodeVector(base64: string, encoding: VectorEncoding):
13461
13920
  /** A db3 vector field's stored value as its raw bytes. Throws `DB3_VECTOR_INVALID` for text that is not canonical base64. */
13462
13921
  export declare function vectorBytes(base64: string): Uint8Array;
13463
13922
 
13923
+ /**
13924
+ * A db3 JSON field's stored value: a `schemas/` object def's value `T` as
13925
+ * canonical JSON text (RFC 8785). The generated declaration types such a
13926
+ * field `Db3Json<Schemas.<Name>>`; a plain `string` is not assignable to
13927
+ * it, so a function writes `encodeDb3Json(value)` and reads with
13928
+ * `decodeDb3Json`.
13929
+ *
13930
+ * @beta
13931
+ */
13932
+ export type Db3Json<T> = string & { readonly __db3Json: T };
13933
+
13934
+ /**
13935
+ * A value as a db3 JSON field's stored text: canonical JSON (RFC 8785), object
13936
+ * keys sorted, no whitespace. It does not check the value against the field's
13937
+ * def: the server stores any string, and only the web and Swift clients
13938
+ * validate.
13939
+ *
13940
+ * Throws an error with `code: "DB3_JSON_INVALID"` when the value is not an
13941
+ * object, or holds a value JSON cannot (a function, a `Date`, a non-finite
13942
+ * number, a number above 2^53 in magnitude, a lone surrogate).
13943
+ *
13944
+ * @beta
13945
+ */
13946
+ export declare function encodeDb3Json<T>(value: T): Db3Json<T>;
13947
+
13948
+ /**
13949
+ * A db3 JSON field's stored text as its value. It does not check the value
13950
+ * against the field's def. Throws an error with `code: "DB3_JSON_INVALID"`
13951
+ * when the text is not JSON of an object.
13952
+ *
13953
+ * @beta
13954
+ */
13955
+ export declare function decodeDb3Json<T>(text: Db3Json<T>): T;
13956
+
13464
13957
  /** One family's durable `step.do` configuration — a `StepConfig` with every field decided. */
13465
13958
  export interface StepPolicy extends StepConfig {
13466
13959
  retries: { limit: number; delay: string; backoff: StepBackoff };
@@ -13469,7 +13962,7 @@ export interface StepPolicy extends StepConfig {
13469
13962
 
13470
13963
  /**
13471
13964
  * The per-family step policies the DSL runners use, generated from their own
13472
- * timeout module (#3187):
13965
+ * timeout module:
13473
13966
  *
13474
13967
  * await step.do("send-receipt", stepPolicy.email, () =>
13475
13968
  * ctx.api.email.send({ body: { to, subject, htmlBody } }));
@@ -13487,9 +13980,10 @@ export declare const stepPolicy: {
13487
13980
  // Every member the three runtime copies put on their own default export — the
13488
13981
  // platform's `sdk-core.ts`, the published stub and the CLI's collect stub —
13489
13982
  // and nothing else. A helper the module hands a default import but does not
13490
- // declare here is one an author cannot call without the compiler refusing it
13491
- // (#3482 CR3482-002); `tests/api/spec/function-profile.test.ts` holds the four
13492
- // lists equal and compiles a default import against them.
13983
+ // declare here is one an author cannot call without the compiler refusing it;
13984
+ // `tests/api/spec/function-profile.test.ts` holds the four lists equal and
13985
+ // compiles a default import against them.
13986
+ /** Every named export, also reachable as one default import. */
13493
13987
  declare const _default: {
13494
13988
  SDK_STUB_VERSION: string;
13495
13989
  defineFunction: typeof defineFunction;
@@ -13503,6 +13997,10 @@ declare const _default: {
13503
13997
  requireMember: typeof requireMember;
13504
13998
  requireCollectionRole: typeof requireCollectionRole;
13505
13999
  requireDocumentOwner: typeof requireDocumentOwner;
14000
+ requirePublicDb3: typeof requirePublicDb3;
14001
+ requireDb3Level: typeof requireDb3Level;
14002
+ requireToken: typeof requireToken;
14003
+ requireInvitation: typeof requireInvitation;
13506
14004
  defineQuery: typeof defineQuery;
13507
14005
  defineMutation: typeof defineMutation;
13508
14006
  pMap: typeof pMap;
@@ -13510,6 +14008,8 @@ declare const _default: {
13510
14008
  encodeVector: typeof encodeVector;
13511
14009
  decodeVector: typeof decodeVector;
13512
14010
  vectorBytes: typeof vectorBytes;
14011
+ encodeDb3Json: typeof encodeDb3Json;
14012
+ decodeDb3Json: typeof decodeDb3Json;
13513
14013
  assertRuntime: typeof assertRuntime;
13514
14014
  assertTrigger: typeof assertTrigger;
13515
14015
  FunctionRuntimeError: typeof FunctionRuntimeError;