primitive-admin 1.1.0-alpha.86 → 1.1.0-alpha.87

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 (40) hide show
  1. package/assets/skill/skills/primitive-platform/SKILL.md +29 -1
  2. package/dist/src/commands/analytics.js +4 -4
  3. package/dist/src/commands/analytics.js.map +1 -1
  4. package/dist/src/commands/auth-sessions.d.ts +7 -0
  5. package/dist/src/commands/auth-sessions.js +144 -0
  6. package/dist/src/commands/auth-sessions.js.map +1 -0
  7. package/dist/src/commands/auth.js +47 -8
  8. package/dist/src/commands/auth.js.map +1 -1
  9. package/dist/src/commands/sync.d.ts +10 -0
  10. package/dist/src/commands/sync.js +26 -1
  11. package/dist/src/commands/sync.js.map +1 -1
  12. package/dist/src/lib/api-client.d.ts +18 -0
  13. package/dist/src/lib/api-client.js +20 -1
  14. package/dist/src/lib/api-client.js.map +1 -1
  15. package/dist/src/lib/app-settings-descriptor.d.ts +1 -1
  16. package/dist/src/lib/app-settings-descriptor.js +0 -1
  17. package/dist/src/lib/app-settings-descriptor.js.map +1 -1
  18. package/dist/src/lib/env-resolver-core.js +10 -3
  19. package/dist/src/lib/env-resolver-core.js.map +1 -1
  20. package/dist/src/lib/function-document-types.d.ts +13 -2
  21. package/dist/src/lib/function-document-types.js +79 -30
  22. package/dist/src/lib/function-document-types.js.map +1 -1
  23. package/dist/src/lib/generated-config-surfaces.js +1 -18
  24. package/dist/src/lib/generated-config-surfaces.js.map +1 -1
  25. package/dist/src/lib/generated-sdk-types.d.ts +1 -1
  26. package/dist/src/lib/generated-sdk-types.js +1 -1
  27. package/dist/src/lib/generated-sdk-types.js.map +1 -1
  28. package/dist/src/lib/logout-admin-session.d.ts +33 -0
  29. package/dist/src/lib/logout-admin-session.js +70 -0
  30. package/dist/src/lib/logout-admin-session.js.map +1 -0
  31. package/dist/src/lib/refresh-admin-credentials.d.ts +9 -1
  32. package/dist/src/lib/refresh-admin-credentials.js +22 -2
  33. package/dist/src/lib/refresh-admin-credentials.js.map +1 -1
  34. package/dist/src/lib/storage-pending-retry.d.ts +26 -0
  35. package/dist/src/lib/storage-pending-retry.js +42 -0
  36. package/dist/src/lib/storage-pending-retry.js.map +1 -0
  37. package/dist/src/lib/workflow-usage.d.ts +11 -13
  38. package/dist/src/lib/workflow-usage.js +12 -14
  39. package/dist/src/lib/workflow-usage.js.map +1 -1
  40. package/package.json +2 -2
@@ -9,5 +9,5 @@
9
9
  * Regenerate with:
10
10
  * node cli/scripts/gen-sdk-types.mjs
11
11
  */
12
- export const SDK_TYPES_SOURCE = "// GENERATED by scripts/generate-function-profile.mjs from openapi.json.\n// DO NOT EDIT. Run `pnpm functions:profile` and commit the result; the\n// freshness guard in tests/api/spec/function-profile.test.ts fails when this\n// file and a fresh generation diverge.\n\n/**\n * Type surface of `primitive-functions` — what a server function's author writes\n * against (#3180). The published package's RUNTIME is a stub that throws from\n * every export on purpose: the platform substitutes its own copy at invoke\n * time, and reaching the stub means it did not.\n */\n\n/**\n * The signed-in user who invoked the function over HTTP.\n *\n * Attribution, never authority (#3279): function code acts as the system\n * whoever called it, so this says WHO asked, and the rows the function writes\n * are attributed to them. A trigger fire has no caller and `ctx.user` is\n * null.\n */\nexport interface FunctionUser {\n userId: string;\n email: string | null;\n}\n\n/**\n * What started this invocation. Narrow on `kind`.\n *\n * The same union the runtime builds (`src/server-functions/trigger-descriptor.ts`),\n * held identical by `tests/api/spec/function-trigger-declarations-3281.test.ts`:\n * a field the fire path sets is declared here, and nothing is declared here\n * that the fire path does not set.\n */\nexport type FunctionTrigger =\n /**\n * An HTTP invocation: the caller is `ctx.user`.\n *\n * `runKey` is the key a `start` was coalesced by (#3562) — what you\n * passed as `runKey` to make the run a singleton — and null when the\n * start named none, or when the call was an `invoke`, which coalesces\n * nothing.\n */\n | { kind: \"http\"; runKey: string | null }\n /** A verified webhook delivery to the function's own key. */\n | {\n kind: \"webhook\";\n /** The webhook key, which is the function key. */\n webhookKey: string;\n /** The platform's webhook row the delivery log lives under. */\n webhookId: string;\n /** The provider's event id (`X-Webhook-Event-Id`), when it sent one. */\n externalEventId: string | null;\n }\n /** A cron entry firing, scheduled or from the `cron-triggers test` diagnostic. */\n | {\n kind: \"cron\";\n /** The `[[function.triggers.cron]]` entry's `name`. */\n name: string;\n /** The platform's cron row. */\n triggerId: string;\n /** ISO 8601. The instant the fire was scheduled for; a diagnostic fire's is \"now\". */\n scheduledFor: string;\n /** Present, and true, only on the diagnostic fire: nothing was scheduled. */\n manual?: true;\n }\n /**\n * A DSL workflow's `workflow.call` step reached this function (#3288).\n *\n * TRANSITIONAL: the bridge exists so a workflow tree can migrate leaf-first\n * during the transition, and it retires with the workflow engine in phase 7,\n * taking this variant with it. `workflowKey` names the PARENT workflow, and\n * `runId`/`stepId` locate the step inside its run.\n */\n | { kind: \"workflow\"; workflowKey: string; runId: string; stepId: string }\n /**\n * Another function started this one with `ctx.functions.start` (#3280).\n *\n * `functionKey` names the PARENT, and `runId` its run — null when the\n * parent was a request invocation over HTTP, which writes no run row.\n * `runKey` is the key the parent's start named, or null (#3562).\n */\n | {\n kind: \"function\";\n functionKey: string;\n runId: string | null;\n runKey: string | null;\n }\n /**\n * An admin ran this function as the SYSTEM, from outside any trigger\n * (#3448) — `primitive functions invoke --as system`.\n *\n * `ctx.user` is null and the code runs with the app's system authority, as\n * it does for a cron or webhook fire. `userId` names the admin who asked:\n * attribution, never the principal the code runs as. `runKey` is the key\n * the admin's start named, or null (#3562).\n */\n | { kind: \"manual\"; userId: string; runKey: string | null };\n\n/** The result shape of an operation that answers in response headers. */\nexport interface HeaderResult {\n status: number;\n headers: Record<string, string>;\n}\n\n/**\n * A platform call that was refused. `errorCode` carries the gateway's own\n * codes (`FUNCTION_ROUTE_NOT_ALLOWED`, `FUNCTION_EGRESS_DENIED`, …) as well\n * as the route's.\n */\nexport interface PrimitivePlatformError extends Error {\n status: number;\n errorCode: string | null;\n}\n\n/**\n * The typed HTTP profile, generated from the platform's OpenAPI document. Its\n * namespaces mirror the operation ids: analytics, blobBuckets, channels, collections, configVars, connections, databaseTypeConfigs, databases, documents, email, functions, gemini, groups, integrations, llm, locks, notifications, prompts, resourceMetadata, secrets, users.\n * Methods take one options object carrying the operation's path parameters,\n * query parameters, request headers (under their wire names) and `body`.\n *\n * Generated from the same operations as the runtime profile, so a method that\n * type-checks is a method the platform publishes — and a missing path\n * parameter or a missing required header is a compile error rather than a\n * `TypeError` at invoke time. Every call runs with the app's own SYSTEM\n * authority (#3279): the invocation gate was the authorization. The two\n * namespaces the gateway does not admit are still declared: they exist, they\n * answer the gateway's structured denial, and hiding them would make a route's\n * availability look like a typo. Those are `databaseTypeConfigs` whole, and\n * `functions` except for `functions.start` — the nested-start door #3280\n * admits by name, which `ctx.functions.start` calls. `functions.invoke`\n * stays refused: same-run composition is an import.\n */\nexport interface FunctionApi {\n \"analytics\": {\n /** `analytics.cohortRetention` — GET /analytics/cohort-retention. Cohort retention metrics */\n \"cohortRetention\"(args?: {\n \"current_timestamp\"?: string | number | boolean;\n \"_bust\"?: string | number | boolean;\n }): Promise<any>;\n /** `analytics.dailyActive` — GET /analytics/daily-active. Daily active user time series */\n \"dailyActive\"(args?: {\n \"windowDays\"?: string | number | boolean;\n \"current_timestamp\"?: string | number | boolean;\n \"_bust\"?: string | number | boolean;\n }): Promise<any>;\n /** `analytics.errorGroups` — GET /analytics/errors/groups. Group failure events by fingerprint with per-day count buckets */\n \"errorGroups\"(args?: {\n \"windowDays\"?: string | number | boolean;\n \"limit\"?: string | number | boolean;\n \"current_timestamp\"?: string | number | boolean;\n \"_bust\"?: string | number | boolean;\n \"filter\"?: Record<string, Record<string, string | number | boolean | Array<string | number | boolean>>>;\n }): Promise<any>;\n /** `analytics.integrationUsage` — GET /analytics/integrations. Integration usage metrics */\n \"integrationUsage\"(args?: {\n \"windowDays\"?: string | number | boolean;\n \"current_timestamp\"?: string | number | boolean;\n \"_bust\"?: string | number | boolean;\n }): Promise<any>;\n /** `analytics.listEvents` — GET /analytics/events. List analytics events */\n \"listEvents\"(args?: {\n \"windowDays\"?: string | number | boolean;\n \"page\"?: string | number | boolean;\n \"current_timestamp\"?: string | number | boolean;\n \"_bust\"?: string | number | boolean;\n \"filter\"?: Record<string, Record<string, string | number | boolean | Array<string | number | boolean>>>;\n }): Promise<any>;\n /** `analytics.listEventsGrouped` — GET /analytics/events/grouped. List analytics events grouped by dimension */\n \"listEventsGrouped\"(args?: {\n \"windowDays\"?: string | number | boolean;\n \"groupBy\"?: string | number | boolean;\n \"current_timestamp\"?: string | number | boolean;\n \"_bust\"?: string | number | boolean;\n \"filter\"?: Record<string, Record<string, string | number | boolean | Array<string | number | boolean>>>;\n }): Promise<any>;\n /** `analytics.overviewDau` — GET /analytics/overview/dau. Daily active users overview */\n \"overviewDau\"(args?: {\n \"current_timestamp\"?: string | number | boolean;\n \"_bust\"?: string | number | boolean;\n }): Promise<any>;\n /** `analytics.overviewGrowth` — GET /analytics/overview/growth. User growth overview */\n \"overviewGrowth\"(args?: {\n \"windowDays\"?: string | number | boolean;\n \"current_timestamp\"?: string | number | boolean;\n \"_bust\"?: string | number | boolean;\n }): Promise<any>;\n /** `analytics.overviewMau` — GET /analytics/overview/mau. Monthly active users overview */\n \"overviewMau\"(args?: {\n \"current_timestamp\"?: string | number | boolean;\n \"_bust\"?: string | number | boolean;\n }): Promise<any>;\n /** `analytics.overviewWau` — GET /analytics/overview/wau. Weekly active users overview */\n \"overviewWau\"(args?: {\n \"current_timestamp\"?: string | number | boolean;\n \"_bust\"?: string | number | boolean;\n }): Promise<any>;\n /** `analytics.rollingActive` — GET /analytics/rolling-active. Rolling active user time series */\n \"rollingActive\"(args?: {\n \"windowDays\"?: string | number | boolean;\n \"current_timestamp\"?: string | number | boolean;\n \"_bust\"?: string | number | boolean;\n }): Promise<any>;\n /** `analytics.searchUsers` — GET /analytics/users/search. Search app users for analytics */\n \"searchUsers\"(args?: {\n \"q\"?: string | number | boolean;\n \"limit\"?: string | number | boolean;\n \"signupDay\"?: string | number | boolean;\n \"signupStartDay\"?: string | number | boolean;\n \"signupEndDay\"?: string | number | boolean;\n \"offset\"?: string | number | boolean;\n \"current_timestamp\"?: string | number | boolean;\n \"_bust\"?: string | number | boolean;\n }): Promise<any>;\n /** `analytics.topPrompts` — GET /analytics/prompts/top. List the most-executed prompts */\n \"topPrompts\"(args?: {\n \"windowDays\"?: string | number | boolean;\n \"limit\"?: string | number | boolean;\n \"current_timestamp\"?: string | number | boolean;\n \"_bust\"?: string | number | boolean;\n }): Promise<any>;\n /** `analytics.topUsers` — GET /analytics/users/top. List the most active users */\n \"topUsers\"(args?: {\n \"windowDays\"?: string | number | boolean;\n \"limit\"?: string | number | boolean;\n \"current_timestamp\"?: string | number | boolean;\n \"_bust\"?: string | number | boolean;\n }): Promise<any>;\n /** `analytics.topWorkflows` — GET /analytics/workflows/top. List the most-run workflows */\n \"topWorkflows\"(args?: {\n \"windowDays\"?: string | number | boolean;\n \"limit\"?: string | number | boolean;\n \"current_timestamp\"?: string | number | boolean;\n \"_bust\"?: string | number | boolean;\n }): Promise<any>;\n /** `analytics.userDetail` — GET /analytics/users/{userUlid}/detail. Detailed analytics for a single user */\n \"userDetail\"(args: {\n \"userUlid\": string | number;\n \"current_timestamp\"?: string | number | boolean;\n \"_bust\"?: string | number | boolean;\n }): Promise<any>;\n /** `analytics.userSnapshot` — GET /analytics/users/{userUlid}/snapshot. Activity snapshot for a single user */\n \"userSnapshot\"(args: {\n \"userUlid\": string | number;\n \"current_timestamp\"?: string | number | boolean;\n \"_bust\"?: string | number | boolean;\n }): Promise<any>;\n /** `analytics.writeForUser` — POST /analytics/write-for-user. Write an analytics event for a subject user under a grant */\n \"writeForUser\"(args: {\n body: unknown;\n }): Promise<any>;\n };\n \"blobBuckets\": {\n /** `blobBuckets.createBucket` — POST /blob-buckets. Create a blob bucket */\n \"createBucket\"(args: {\n body: unknown;\n }): Promise<any>;\n /** `blobBuckets.delete` — DELETE /blob-buckets/{bucketId}/blobs/{blobId}. Delete a blob */\n \"delete\"(args: {\n \"bucketId\": string | number;\n \"blobId\": string | number;\n }): Promise<any>;\n /** `blobBuckets.deleteBatch` — POST /blob-buckets/{bucketId}/blobs/delete. Batch delete blobs from a bucket */\n \"deleteBatch\"(args: {\n \"bucketId\": string | number;\n body: unknown;\n }): Promise<any>;\n /** `blobBuckets.deleteBucket` — DELETE /blob-buckets/{bucketId}. Delete a blob bucket */\n \"deleteBucket\"(args: {\n \"bucketId\": string | number;\n }): Promise<any>;\n /** `blobBuckets.download` — GET /blob-buckets/{bucketId}/blobs/{blobId}. Download a blob (anonymous allowed for public buckets) */\n \"download\"(args: {\n \"bucketId\": string | number;\n \"blobId\": string | number;\n \"disposition\"?: string | number | boolean;\n }): Promise<Uint8Array>;\n /** `blobBuckets.downloadSigned` — GET /blob-buckets/{bucketId}/blobs/{blobId}/signed. Download a blob via a signed URL token */\n \"downloadSigned\"(args: {\n \"bucketId\": string | number;\n \"blobId\": string | number;\n \"token\"?: string | number | boolean;\n }): Promise<Uint8Array>;\n /** `blobBuckets.getBucket` — GET /blob-buckets/{bucketId}. Get a blob bucket by id */\n \"getBucket\"(args: {\n \"bucketId\": string | number;\n }): Promise<any>;\n /** `blobBuckets.getMetadata` — GET /blob-buckets/{bucketId}/blobs/{blobId}/metadata. Get blob metadata (anonymous allowed for public buckets) */\n \"getMetadata\"(args: {\n \"bucketId\": string | number;\n \"blobId\": string | number;\n }): Promise<any>;\n /** `blobBuckets.getSignedUrl` — POST /blob-buckets/{bucketId}/blobs/{blobId}/signed-url. Create a signed download URL for a blob */\n \"getSignedUrl\"(args: {\n \"bucketId\": string | number;\n \"blobId\": string | number;\n body?: unknown;\n }): Promise<any>;\n /** `blobBuckets.list` — GET /blob-buckets/{bucketId}/blobs. List blobs in a bucket (anonymous allowed for public buckets) */\n \"list\"(args: {\n \"bucketId\": string | number;\n \"limit\"?: string | number | boolean;\n \"cursor\"?: string | number | boolean;\n }): Promise<any>;\n /** `blobBuckets.listBuckets` — GET /blob-buckets. List blob buckets */\n \"listBuckets\"(args?: Record<string, never>): Promise<any>;\n /** `blobBuckets.updateBucket` — PATCH /blob-buckets/{bucketId}. Update a blob bucket */\n \"updateBucket\"(args: {\n \"bucketId\": string | number;\n body: unknown;\n }): Promise<any>;\n /** `blobBuckets.upload` — POST /blob-buckets/{bucketId}/blobs. Upload a blob to a bucket */\n \"upload\"(args: {\n \"bucketId\": string | number;\n \"X-Blob-Filename\": string | number;\n \"X-Blob-Tags\"?: string | number;\n \"Content-Type\"?: string | number;\n body: ArrayBuffer | Uint8Array | string;\n }): Promise<any>;\n };\n \"channels\": {\n /** `channels.authorize` — POST /channels/{channel}/grants. Issue a channel grant under a server function's grant */\n \"authorize\"(args: {\n \"channel\": string | number;\n body: unknown;\n }): Promise<any>;\n /** `channels.publish` — POST /channels/{channel}/publish. Publish a message to a channel under a server function's grant */\n \"publish\"(args: {\n \"channel\": string | number;\n body: unknown;\n }): Promise<any>;\n };\n \"collections\": {\n /** `collections.addDocument` — POST /collections/{collectionId}/documents. Add a document to a collection */\n \"addDocument\"(args: {\n \"collectionId\": string | number;\n body: unknown;\n }): Promise<any>;\n /** `collections.addMember` — POST /collections/{collectionId}/members. Add a member to a collection */\n \"addMember\"(args: {\n \"collectionId\": string | number;\n body: unknown;\n }): Promise<any>;\n /** `collections.create` — POST /collections. Create a collection */\n \"create\"(args: {\n body: unknown;\n }): Promise<any>;\n /** `collections.delete` — DELETE /collections/{collectionId}. Delete a collection */\n \"delete\"(args: {\n \"collectionId\": string | number;\n }): Promise<any>;\n /** `collections.get` — GET /collections/{collectionId}. Get a collection by id */\n \"get\"(args: {\n \"collectionId\": string | number;\n }): Promise<any>;\n /** `collections.getAccess` — GET /collections/{collectionId}/access. Get a collection's access summary */\n \"getAccess\"(args: {\n \"collectionId\": string | number;\n }): Promise<any>;\n /** `collections.grantGroupPermission` — POST /collections/{collectionId}/group-permissions. Grant a group permission on a collection */\n \"grantGroupPermission\"(args: {\n \"collectionId\": string | number;\n body: unknown;\n }): Promise<any>;\n /** `collections.list` — GET /collections. List collections */\n \"list\"(args?: {\n \"limit\"?: string | number | boolean;\n \"cursor\"?: string | number | boolean;\n }): Promise<any>;\n /** `collections.listCollectionsForDocument` — GET /documents/{documentId}/collections. List collections a document belongs to (reverse lookup) */\n \"listCollectionsForDocument\"(args: {\n \"documentId\": string | number;\n \"limit\"?: string | number | boolean;\n \"cursor\"?: string | number | boolean;\n }): Promise<any>;\n /** `collections.listDocuments` — GET /collections/{collectionId}/documents. List documents in a collection */\n \"listDocuments\"(args: {\n \"collectionId\": string | number;\n \"limit\"?: string | number | boolean;\n \"cursor\"?: string | number | boolean;\n }): Promise<any>;\n /** `collections.listPendingInvitations` — GET /collections/{collectionId}/pending-invitations. List a collection's pending invitations */\n \"listPendingInvitations\"(args: {\n \"collectionId\": string | number;\n }): Promise<any>;\n /** `collections.removeDocument` — DELETE /collections/{collectionId}/documents/{documentId}. Remove a document from a collection */\n \"removeDocument\"(args: {\n \"collectionId\": string | number;\n \"documentId\": string | number;\n }): Promise<any>;\n /** `collections.removeMember` — DELETE /collections/{collectionId}/members/{userId}. Remove a member from a collection */\n \"removeMember\"(args: {\n \"collectionId\": string | number;\n \"userId\": string | number;\n }): Promise<any>;\n /** `collections.revokeGroupPermission` — DELETE /collections/{collectionId}/group-permissions/{groupType}/{groupId}. Revoke a group permission on a collection */\n \"revokeGroupPermission\"(args: {\n \"collectionId\": string | number;\n \"groupType\": string | number;\n \"groupId\": string | number;\n }): Promise<any>;\n /** `collections.update` — PATCH /collections/{collectionId}. Update a collection */\n \"update\"(args: {\n \"collectionId\": string | number;\n body: unknown;\n }): Promise<any>;\n };\n \"configVars\": {\n /** `configVars.get` — GET /config-vars/{name}. Read an app config var under a server function's grants */\n \"get\"(args: {\n \"name\": string | number;\n }): Promise<any>;\n };\n \"connections\": {\n /** `connections.send` — POST /connections/{connectionId}/send. Send a realtime message to one connection of this app */\n \"send\"(args: {\n \"connectionId\": string | number;\n body: unknown;\n }): Promise<any>;\n };\n \"databaseTypeConfigs\": {\n /** `databaseTypeConfigs.create` — POST /databases/types. Create a database type */\n \"create\"(args: {\n \"dryRun\"?: string | number | boolean;\n body: unknown;\n }): Promise<any>;\n /** `databaseTypeConfigs.createOperation` — POST /databases/types/{databaseType}/operations. Create an operation for a database type */\n \"createOperation\"(args: {\n \"databaseType\": string | number;\n \"dryRun\"?: string | number | boolean;\n body: unknown;\n }): Promise<any>;\n /** `databaseTypeConfigs.delete` — DELETE /databases/types/{databaseType}. Delete a database type */\n \"delete\"(args: {\n \"databaseType\": string | number;\n }): Promise<any>;\n /** `databaseTypeConfigs.deleteOperation` — DELETE /databases/types/{databaseType}/operations/{name}. Delete an operation for a database type */\n \"deleteOperation\"(args: {\n \"databaseType\": string | number;\n \"name\": string | number;\n }): Promise<any>;\n /** `databaseTypeConfigs.get` — GET /databases/types/{databaseType}. Get a database type */\n \"get\"(args: {\n \"databaseType\": string | number;\n }): Promise<any>;\n /** `databaseTypeConfigs.getOperation` — GET /databases/types/{databaseType}/operations/{name}. Get an operation for a database type */\n \"getOperation\"(args: {\n \"databaseType\": string | number;\n \"name\": string | number;\n }): Promise<any>;\n /** `databaseTypeConfigs.getReindexStatus` — GET /databases/types/{databaseType}/reindex-status. Status of the index back-provision fan-out for a type */\n \"getReindexStatus\"(args: {\n \"databaseType\": string | number;\n \"runId\"?: string | number | boolean;\n }): Promise<any>;\n /** `databaseTypeConfigs.list` — GET /databases/types. List database types */\n \"list\"(args?: Record<string, never>): Promise<any>;\n /** `databaseTypeConfigs.listOperations` — GET /databases/types/{databaseType}/operations. List operations for a database type */\n \"listOperations\"(args: {\n \"databaseType\": string | number;\n }): Promise<any>;\n /** `databaseTypeConfigs.scaffoldSchema` — POST /databases/types/{databaseType}/schema:scaffold. Scaffold a starter schema for a database type */\n \"scaffoldSchema\"(args: {\n \"databaseType\": string | number;\n }): Promise<any>;\n \"subscriptions\": {\n /** `databaseTypeConfigs.subscriptions.create` — POST /databases/types/{databaseType}/subscriptions. Create a subscription for a database type */\n \"create\"(args: {\n \"databaseType\": string | number;\n body: unknown;\n }): Promise<any>;\n /** `databaseTypeConfigs.subscriptions.delete` — DELETE /databases/types/{databaseType}/subscriptions/{subscriptionKey}. Delete a database type subscription */\n \"delete\"(args: {\n \"databaseType\": string | number;\n \"subscriptionKey\": string | number;\n }): Promise<any>;\n /** `databaseTypeConfigs.subscriptions.get` — GET /databases/types/{databaseType}/subscriptions/{subscriptionKey}. Get a database type subscription */\n \"get\"(args: {\n \"databaseType\": string | number;\n \"subscriptionKey\": string | number;\n }): Promise<any>;\n /** `databaseTypeConfigs.subscriptions.list` — GET /databases/types/{databaseType}/subscriptions. List subscriptions for a database type */\n \"list\"(args: {\n \"databaseType\": string | number;\n }): Promise<any>;\n /** `databaseTypeConfigs.subscriptions.update` — PUT /databases/types/{databaseType}/subscriptions/{subscriptionKey}. Update a database type subscription */\n \"update\"(args: {\n \"databaseType\": string | number;\n \"subscriptionKey\": string | number;\n body: unknown;\n }): Promise<any>;\n };\n /** `databaseTypeConfigs.update` — PATCH /databases/types/{databaseType}. Update a database type */\n \"update\"(args: {\n \"databaseType\": string | number;\n \"dryRun\"?: string | number | boolean;\n body: unknown;\n }): Promise<any>;\n /** `databaseTypeConfigs.updateOperation` — PATCH /databases/types/{databaseType}/operations/{name}. Update an operation for a database type */\n \"updateOperation\"(args: {\n \"databaseType\": string | number;\n \"name\": string | number;\n \"dryRun\"?: string | number | boolean;\n body: unknown;\n }): Promise<any>;\n };\n \"databases\": {\n /** `databases.addManager` — PUT /databases/{databaseId}/permissions. Set a user's database permission */\n \"addManager\"(args: {\n \"databaseId\": string | number;\n body: unknown;\n }): Promise<any>;\n \"adminData\": {\n /**\n * `databases.adminData.batch` — POST /databases/{databaseId}/admin-data/batch. DEPRECATED — direct database batch; use databases/{databaseId}/records/batch\n * @deprecated Use databases/{databaseId}/records/batch\n */\n \"batch\"(args: {\n \"databaseId\": string | number;\n body: unknown;\n }): Promise<any>;\n /**\n * `databases.adminData.count` — POST /databases/{databaseId}/admin-data/count. DEPRECATED — direct database count; use databases/{databaseId}/records/count\n * @deprecated Use databases/{databaseId}/records/count\n */\n \"count\"(args: {\n \"databaseId\": string | number;\n body: unknown;\n }): Promise<any>;\n /**\n * `databases.adminData.delete` — POST /databases/{databaseId}/admin-data/delete. DEPRECATED — direct database delete; use databases/{databaseId}/records/delete\n * @deprecated Use databases/{databaseId}/records/delete\n */\n \"delete\"(args: {\n \"databaseId\": string | number;\n body: unknown;\n }): Promise<any>;\n /**\n * `databases.adminData.patch` — POST /databases/{databaseId}/admin-data/patch. DEPRECATED — direct database patch; use databases/{databaseId}/records/patch\n * @deprecated Use databases/{databaseId}/records/patch\n */\n \"patch\"(args: {\n \"databaseId\": string | number;\n body: unknown;\n }): Promise<any>;\n /**\n * `databases.adminData.query` — POST /databases/{databaseId}/admin-data/query. DEPRECATED — direct database query; use databases/{databaseId}/records/query\n * @deprecated Use databases/{databaseId}/records/query\n */\n \"query\"(args: {\n \"databaseId\": string | number;\n body: unknown;\n }): Promise<any>;\n /**\n * `databases.adminData.save` — POST /databases/{databaseId}/admin-data/save. DEPRECATED — direct database save; use databases/{databaseId}/records/save\n * @deprecated Use databases/{databaseId}/records/save\n */\n \"save\"(args: {\n \"databaseId\": string | number;\n body: unknown;\n }): Promise<any>;\n };\n /** `databases.create` — POST /databases. Create a database */\n \"create\"(args: {\n body: unknown;\n }): Promise<any>;\n /** `databases.delete` — DELETE /databases/{databaseId}. Delete a database */\n \"delete\"(args: {\n \"databaseId\": string | number;\n }): Promise<any>;\n /** `databases.executeBatch` — POST /databases/{databaseId}/operations/{name}/batch. Execute a database operation in batch */\n \"executeBatch\"(args: {\n \"databaseId\": string | number;\n \"name\": string | number;\n body: unknown;\n }): Promise<any>;\n /** `databases.executeOperation` — POST /databases/{databaseId}/operations/{name}/execute. Execute a database operation */\n \"executeOperation\"(args: {\n \"databaseId\": string | number;\n \"name\": string | number;\n \"dryRun\"?: string | number | boolean;\n body?: unknown;\n }): Promise<any>;\n /** `databases.get` — GET /databases/{databaseId}. Get a database by id */\n \"get\"(args: {\n \"databaseId\": string | number;\n }): Promise<any>;\n /**\n * `databases.getMetadata` — GET /databases/{databaseId}/metadata. DEPRECATED — get database metadata; use resource metadata categories (resources/database/:databaseId/metadata/:category)\n * @deprecated Use resource metadata categories (resources/database/:databaseId/metadata/:category)\n */\n \"getMetadata\"(args: {\n \"databaseId\": string | number;\n }): Promise<any>;\n /** `databases.grantGroupPermission` — POST /databases/{databaseId}/group-permissions. Grant a group permission on a database */\n \"grantGroupPermission\"(args: {\n \"databaseId\": string | number;\n body: unknown;\n }): Promise<any>;\n /** `databases.importBulk` — POST /databases/{databaseId}/operations/{name}/import-bulk. Bulk-import records via a database operation */\n \"importBulk\"(args: {\n \"databaseId\": string | number;\n \"name\": string | number;\n body: unknown;\n }): Promise<any>;\n /** `databases.list` — GET /databases. List databases */\n \"list\"(args?: Record<string, never>): Promise<any>;\n /** `databases.listGroupPermissions` — GET /databases/{databaseId}/group-permissions. List a database's group permissions */\n \"listGroupPermissions\"(args: {\n \"databaseId\": string | number;\n }): Promise<any>;\n /** `databases.listOperations` — GET /databases/{databaseId}/operations. List operations runnable on a database */\n \"listOperations\"(args: {\n \"databaseId\": string | number;\n }): Promise<any>;\n /** `databases.listPermissions` — GET /databases/{databaseId}/permissions. List a database's user permissions */\n \"listPermissions\"(args: {\n \"databaseId\": string | number;\n }): Promise<any>;\n \"records\": {\n /** `databases.records.addToSet` — POST /databases/{databaseId}/records/stringset/add. Database records: stringset/add (requires manager-or-higher on the database, or an app-admin/owner role) */\n \"addToSet\"(args: {\n \"databaseId\": string | number;\n body: unknown;\n }): Promise<any>;\n /** `databases.records.aggregate` — POST /databases/{databaseId}/records/aggregate. Database records: aggregate (requires manager-or-higher on the database, or an app-admin/owner role) */\n \"aggregate\"(args: {\n \"databaseId\": string | number;\n body: unknown;\n }): Promise<any>;\n /** `databases.records.batch` — POST /databases/{databaseId}/records/batch. Database records: batch (requires manager-or-higher on the database, or an app-admin/owner role) */\n \"batch\"(args: {\n \"databaseId\": string | number;\n body: unknown;\n }): Promise<any>;\n /** `databases.records.count` — POST /databases/{databaseId}/records/count. Database records: count (requires manager-or-higher on the database, or an app-admin/owner role) */\n \"count\"(args: {\n \"databaseId\": string | number;\n body: unknown;\n }): Promise<any>;\n /** `databases.records.delete` — POST /databases/{databaseId}/records/delete. Database records: delete (requires manager-or-higher on the database, or an app-admin/owner role) */\n \"delete\"(args: {\n \"databaseId\": string | number;\n body: unknown;\n }): Promise<any>;\n /** `databases.records.describe` — GET /databases/{databaseId}/records/describe. Database records: describe (requires manager-or-higher on the database, or an app-admin/owner role) */\n \"describe\"(args: {\n \"databaseId\": string | number;\n \"modelName\"?: string | number | boolean;\n }): Promise<any>;\n /** `databases.records.dropIndex` — POST /databases/{databaseId}/records/index/drop. Database records: index/drop (requires manager-or-higher on the database, or an app-admin/owner role) */\n \"dropIndex\"(args: {\n \"databaseId\": string | number;\n body: unknown;\n }): Promise<any>;\n /** `databases.records.dropUniqueConstraint` — POST /databases/{databaseId}/records/unique-constraint/drop. Database records: unique-constraint/drop (requires manager-or-higher on the database, or an app-admin/owner role) */\n \"dropUniqueConstraint\"(args: {\n \"databaseId\": string | number;\n body: unknown;\n }): Promise<any>;\n /** `databases.records.increment` — POST /databases/{databaseId}/records/increment. Database records: increment (requires manager-or-higher on the database, or an app-admin/owner role) */\n \"increment\"(args: {\n \"databaseId\": string | number;\n body: unknown;\n }): Promise<any>;\n /** `databases.records.listIndexes` — GET /databases/{databaseId}/records/indexes. Database records: indexes (requires manager-or-higher on the database, or an app-admin/owner role) */\n \"listIndexes\"(args: {\n \"databaseId\": string | number;\n \"modelName\"?: string | number | boolean;\n }): Promise<any>;\n /** `databases.records.listUniqueConstraints` — GET /databases/{databaseId}/records/unique-constraints. Database records: unique-constraints (requires manager-or-higher on the database, or an app-admin/owner role) */\n \"listUniqueConstraints\"(args: {\n \"databaseId\": string | number;\n \"modelName\"?: string | number | boolean;\n }): Promise<any>;\n /** `databases.records.models` — GET /databases/{databaseId}/records/models. Database records: models (requires manager-or-higher on the database, or an app-admin/owner role) */\n \"models\"(args: {\n \"databaseId\": string | number;\n \"modelName\"?: string | number | boolean;\n }): Promise<any>;\n /** `databases.records.patch` — POST /databases/{databaseId}/records/patch. Database records: patch (requires manager-or-higher on the database, or an app-admin/owner role) */\n \"patch\"(args: {\n \"databaseId\": string | number;\n body: unknown;\n }): Promise<any>;\n /** `databases.records.query` — POST /databases/{databaseId}/records/query. Database records: query (requires manager-or-higher on the database, or an app-admin/owner role) */\n \"query\"(args: {\n \"databaseId\": string | number;\n body: unknown;\n }): Promise<{ items: any[]; hasMore: boolean; nextCursor?: string; prevCursor?: string }>;\n /** `databases.records.registerIndex` — POST /databases/{databaseId}/records/index/register. Database records: index/register (requires manager-or-higher on the database, or an app-admin/owner role) */\n \"registerIndex\"(args: {\n \"databaseId\": string | number;\n body: unknown;\n }): Promise<any>;\n /** `databases.records.registerUniqueConstraint` — POST /databases/{databaseId}/records/unique-constraint/register. Database records: unique-constraint/register (requires manager-or-higher on the database, or an app-admin/owner role) */\n \"registerUniqueConstraint\"(args: {\n \"databaseId\": string | number;\n body: unknown;\n }): Promise<any>;\n /** `databases.records.removeFromSet` — POST /databases/{databaseId}/records/stringset/remove. Database records: stringset/remove (requires manager-or-higher on the database, or an app-admin/owner role) */\n \"removeFromSet\"(args: {\n \"databaseId\": string | number;\n body: unknown;\n }): Promise<any>;\n /** `databases.records.save` — POST /databases/{databaseId}/records/save. Database records: save (requires manager-or-higher on the database, or an app-admin/owner role) */\n \"save\"(args: {\n \"databaseId\": string | number;\n body: unknown;\n }): Promise<any>;\n /** `databases.records.syncIndexes` — POST /databases/{databaseId}/records/indexes/sync. Database records: indexes/sync (requires manager-or-higher on the database, or an app-admin/owner role) */\n \"syncIndexes\"(args: {\n \"databaseId\": string | number;\n body: unknown;\n }): Promise<any>;\n };\n /** `databases.reindex` — POST /databases/{databaseId}/reindex. Reindex a database */\n \"reindex\"(args: {\n \"databaseId\": string | number;\n }): Promise<any>;\n /** `databases.revokeGroupPermission` — DELETE /databases/{databaseId}/group-permissions/{groupType}/{groupId}. Revoke a group permission on a database */\n \"revokeGroupPermission\"(args: {\n \"databaseId\": string | number;\n \"groupType\": string | number;\n \"groupId\": string | number;\n }): Promise<any>;\n /** `databases.revokePermission` — DELETE /databases/{databaseId}/permissions/{userId}. Remove a user's database permission */\n \"revokePermission\"(args: {\n \"databaseId\": string | number;\n \"userId\": string | number;\n }): Promise<any>;\n /** `databases.runOperation` — POST /databases/{databaseId}/operations/{name}/run. Run a database operation under a server function's grants */\n \"runOperation\"(args: {\n \"databaseId\": string | number;\n \"name\": string | number;\n body?: unknown;\n }): Promise<any>;\n /** `databases.transferOwnership` — POST /databases/{databaseId}/permissions/transfer. Transfer database ownership */\n \"transferOwnership\"(args: {\n \"databaseId\": string | number;\n body: unknown;\n }): Promise<any>;\n /** `databases.update` — PATCH /databases/{databaseId}. Update a database */\n \"update\"(args: {\n \"databaseId\": string | number;\n body: unknown;\n }): Promise<any>;\n /**\n * `databases.updateMetadata` — PATCH /databases/{databaseId}/metadata. DEPRECATED — update database metadata; use resource metadata categories (resources/database/:databaseId/metadata/:category)\n * @deprecated Use resource metadata categories (resources/database/:databaseId/metadata/:category)\n */\n \"updateMetadata\"(args: {\n \"databaseId\": string | number;\n body: unknown;\n }): Promise<any>;\n };\n \"documents\": {\n /** `documents.abortIngest` — POST /documents/{documentId}/ingest/{sessionId}/abort. Abort a bulk-load session before its swap */\n \"abortIngest\"(args: {\n \"documentId\": string | number;\n \"sessionId\": string | number;\n body: unknown;\n }): Promise<any>;\n /** `documents.addTag` — POST /documents/{documentId}/tags. Add a tag to a document */\n \"addTag\"(args: {\n \"documentId\": string | number;\n body: unknown;\n }): Promise<any>;\n \"aliases\": {\n /** `documents.aliases.delete` — DELETE /document-aliases/{scope}/{aliasKey}. Delete a (scope, aliasKey) document alias binding */\n \"delete\"(args: {\n \"scope\": string | number;\n \"aliasKey\": string | number;\n }): Promise<any>;\n /** `documents.aliases.listForDocument` — GET /documents/{documentId}/aliases. List aliases bound to a document */\n \"listForDocument\"(args: {\n \"documentId\": string | number;\n }): Promise<any>;\n /** `documents.aliases.resolve` — GET /document-aliases/{scope}/{aliasKey}. Resolve the document bound to a (scope, aliasKey) alias */\n \"resolve\"(args: {\n \"scope\": string | number;\n \"aliasKey\": string | number;\n }): Promise<any>;\n /** `documents.aliases.set` — PUT /document-aliases/{scope}/{aliasKey}. Bind a (scope, aliasKey) alias to a document */\n \"set\"(args: {\n \"scope\": string | number;\n \"aliasKey\": string | number;\n body: unknown;\n }): Promise<any>;\n };\n /** `documents.approveAccessRequest` — POST /documents/{documentId}/access-requests/{requestId}/approve. Approve a document access request */\n \"approveAccessRequest\"(args: {\n \"documentId\": string | number;\n \"requestId\": string | number;\n body?: unknown;\n }): Promise<any>;\n \"blobs\": {\n /** `documents.blobs.delete` — DELETE /documents/{documentId}/blobs/{blobId}. Delete a document blob */\n \"delete\"(args: {\n \"documentId\": string | number;\n \"blobId\": string | number;\n }): Promise<any>;\n /** `documents.blobs.downloadHeaders` — HEAD /documents/{documentId}/blobs/{blobId}/download. Get document blob download headers (ETag/304 support) */\n \"downloadHeaders\"(args: {\n \"documentId\": string | number;\n \"blobId\": string | number;\n }): Promise<HeaderResult>;\n /** `documents.blobs.downloadUrl` — GET /documents/{documentId}/blobs/{blobId}/download. Download a document blob's bytes */\n \"downloadUrl\"(args: {\n \"documentId\": string | number;\n \"blobId\": string | number;\n \"disposition\"?: string | number | boolean;\n }): Promise<Uint8Array>;\n /** `documents.blobs.get` — GET /documents/{documentId}/blobs/{blobId}. Get a document blob's metadata */\n \"get\"(args: {\n \"documentId\": string | number;\n \"blobId\": string | number;\n }): Promise<any>;\n /** `documents.blobs.list` — GET /documents/{documentId}/blobs. List blobs attached to a document */\n \"list\"(args: {\n \"documentId\": string | number;\n }): Promise<any>;\n /** `documents.blobs.upload` — PUT /documents/{documentId}/blobs/{blobId}. Upload a document blob with a client-specified id (immutable + idempotent) */\n \"upload\"(args: {\n \"documentId\": string | number;\n \"blobId\": string | number;\n \"X-Blob-Filename\": string | number;\n \"X-Blob-Size\": string | number;\n \"X-Blob-Sha256\": string | number;\n body: ArrayBuffer | Uint8Array | string;\n }): Promise<any>;\n /**\n * `documents.blobs.uploadWithoutId` — PUT /documents/{documentId}/blobs. Deprecated: upload a document blob without a client-specified id\n * @deprecated Deprecated in the app API spec; see its description.\n */\n \"uploadWithoutId\"(args: {\n \"documentId\": string | number;\n }): Promise<any>;\n };\n /** `documents.clearLinkAccess` — DELETE /documents/{documentId}/link-access. Turn off the document's link access */\n \"clearLinkAccess\"(args: {\n \"documentId\": string | number;\n }): Promise<any>;\n /** `documents.commitIngest` — POST /documents/{documentId}/ingest/{sessionId}/commit. Commit a bulk-load session: freeze its manifest and apply it */\n \"commitIngest\"(args: {\n \"documentId\": string | number;\n \"sessionId\": string | number;\n body: unknown;\n }): Promise<any>;\n /** `documents.create` — POST /documents. Create a new document */\n \"create\"(args: {\n body: unknown;\n }): Promise<any>;\n /** `documents.createIngest` — POST /documents/{documentId}/ingest. Open a bulk-load session on a large document */\n \"createIngest\"(args: {\n \"documentId\": string | number;\n body: unknown;\n }): Promise<any>;\n /** `documents.createWithAlias` — POST /documents/create-with-alias. Create a document and bind it to an alias */\n \"createWithAlias\"(args: {\n body: unknown;\n }): Promise<any>;\n /** `documents.debugDumpUpdates` — POST /documents/{documentId}/debug/dump-updates. Dump a document's raw CRDT update log (debug) */\n \"debugDumpUpdates\"(args: {\n \"documentId\": string | number;\n \"limit\"?: string | number | boolean;\n \"offset\"?: string | number | boolean;\n \"includeData\"?: string | number | boolean;\n \"includeR2Data\"?: string | number | boolean;\n body?: unknown;\n }): Promise<any>;\n /** `documents.debugMerge` — POST /documents/{documentId}/debug/merge. Force-merge a document's pending updates (debug) */\n \"debugMerge\"(args: {\n \"documentId\": string | number;\n body?: unknown;\n }): Promise<any>;\n /** `documents.debugMergeBlock` — POST /documents/{documentId}/debug/merge-block. Merge a specific update block of a document (debug) */\n \"debugMergeBlock\"(args: {\n \"documentId\": string | number;\n body?: unknown;\n }): Promise<any>;\n /** `documents.debugRestore` — POST /documents/debug/restore. Restore a document from a prior state snapshot (debug) */\n \"debugRestore\"(args: {\n body: unknown;\n }): Promise<any>;\n /** `documents.debugStats` — GET /documents/{documentId}/debug/stats. Get document storage/update stats (debug) */\n \"debugStats\"(args: {\n \"documentId\": string | number;\n }): Promise<any>;\n /** `documents.delete` — DELETE /documents/{documentId}. Delete a document */\n \"delete\"(args: {\n \"documentId\": string | number;\n }): Promise<any>;\n /** `documents.denyAccessRequest` — POST /documents/{documentId}/access-requests/{requestId}/deny. Deny a document access request */\n \"denyAccessRequest\"(args: {\n \"documentId\": string | number;\n \"requestId\": string | number;\n body?: unknown;\n }): Promise<any>;\n /** `documents.exportChain` — GET /documents/{documentId}/export/chain. Export chain of a large document (snapshot + sealed overlays + open epoch) */\n \"exportChain\"(args: {\n \"documentId\": string | number;\n }): Promise<any>;\n /** `documents.exportState` — GET /documents/{documentId}/export/state. Export a document's encoded CRDT state */\n \"exportState\"(args: {\n \"documentId\": string | number;\n }): Promise<any>;\n /** `documents.get` — GET /documents/{documentId}. Get a single document by id */\n \"get\"(args: {\n \"documentId\": string | number;\n }): Promise<any>;\n /** `documents.getImportChainStatus` — GET /documents/{documentId}/import/chain. How far a large document's chain import has got */\n \"getImportChainStatus\"(args: {\n \"documentId\": string | number;\n }): Promise<any>;\n /** `documents.getIngest` — GET /documents/{documentId}/ingest/{sessionId}. One bulk-load session's status */\n \"getIngest\"(args: {\n \"documentId\": string | number;\n \"sessionId\": string | number;\n }): Promise<any>;\n /** `documents.getLinkAccess` — GET /documents/{documentId}/link-access. Get the document's \"anyone with the link\" access level */\n \"getLinkAccess\"(args: {\n \"documentId\": string | number;\n }): Promise<any>;\n /** `documents.getOrCreateWithAlias` — POST /documents/get-or-create-with-alias. Get the document bound to an alias, creating it if absent (idempotent) */\n \"getOrCreateWithAlias\"(args: {\n body: unknown;\n }): Promise<any>;\n /** `documents.getPermissions` — GET /documents/{documentId}/permissions. List a document's user permissions */\n \"getPermissions\"(args: {\n \"documentId\": string | number;\n }): Promise<any>;\n /** `documents.getSchema` — GET /documents/{documentId}/schema. Introspect a document's model schema */\n \"getSchema\"(args: {\n \"documentId\": string | number;\n }): Promise<any>;\n /** `documents.getSnapshot` — GET /documents/{documentId}/snapshots/{buildId}. One snapshot build with its verification result */\n \"getSnapshot\"(args: {\n \"documentId\": string | number;\n \"buildId\": string | number;\n }): Promise<any>;\n /** `documents.getStats` — GET /documents/{documentId}/stats. Document statistics (record/model/blob counts, approximate size) */\n \"getStats\"(args: {\n \"documentId\": string | number;\n }): Promise<any>;\n /** `documents.grantGroupPermission` — POST /documents/{documentId}/group-permissions. Grant a group permission on a document */\n \"grantGroupPermission\"(args: {\n \"documentId\": string | number;\n body: unknown;\n }): Promise<any>;\n /** `documents.importChain` — POST /documents/{documentId}/import/chain. Install an uploaded chain into a large document */\n \"importChain\"(args: {\n \"documentId\": string | number;\n body: unknown;\n }): Promise<any>;\n /** `documents.importChainArtifact` — POST /documents/{documentId}/import/chain/artifact. Upload one artifact of a large document's import chain */\n \"importChainArtifact\"(args: {\n \"documentId\": string | number;\n \"kind\"?: string | number | boolean;\n \"epoch\"?: string | number | boolean;\n \"buildId\"?: string | number | boolean;\n \"model\"?: string | number | boolean;\n \"index\"?: string | number | boolean;\n body: ArrayBuffer | Uint8Array | string;\n }): Promise<any>;\n /** `documents.importState` — POST /documents/{documentId}/import/state. Import encoded CRDT state into a document */\n \"importState\"(args: {\n \"documentId\": string | number;\n body: unknown;\n }): Promise<any>;\n /** `documents.listAccessRequests` — GET /documents/{documentId}/access-requests. List access requests for a document */\n \"listAccessRequests\"(args: {\n \"documentId\": string | number;\n }): Promise<any>;\n /** `documents.listGroupPermissions` — GET /documents/{documentId}/group-permissions. List a document's group permissions */\n \"listGroupPermissions\"(args: {\n \"documentId\": string | number;\n }): Promise<any>;\n /** `documents.listIngests` — GET /documents/{documentId}/ingest. List a large document's bulk-load sessions, newest first */\n \"listIngests\"(args: {\n \"documentId\": string | number;\n \"limit\"?: string | number | boolean;\n \"cursor\"?: string | number | boolean;\n }): Promise<any>;\n /** `documents.listPendingInvitations` — GET /documents/{documentId}/pending-invitations. List a document's pending (deferred) invitations */\n \"listPendingInvitations\"(args: {\n \"documentId\": string | number;\n }): Promise<any>;\n /** `documents.listSnapshots` — GET /documents/{documentId}/snapshots. List a large document's snapshot builds, newest first */\n \"listSnapshots\"(args: {\n \"documentId\": string | number;\n \"limit\"?: string | number | boolean;\n \"cursor\"?: string | number | boolean;\n }): Promise<any>;\n /** `documents.open` — POST /documents/open. Open a document for collaboration (resolves access + alias) */\n \"open\"(args: {\n body: unknown;\n }): Promise<any>;\n \"records\": {\n /** `documents.records.aggregate` — POST /documents/{documentId}/records/{model}/aggregate. Aggregate records in a document model (count/sum/avg/min/max, optional grouping) */\n \"aggregate\"(args: {\n \"documentId\": string | number;\n \"model\": string | number;\n \"documentFormat\"?: string | number | boolean;\n body: unknown;\n }): Promise<any>;\n /** `documents.records.bulk` — POST /documents/{documentId}/records/bulk. Apply an atomic multi-model record blob to a document (create/patch/delete) */\n \"bulk\"(args: {\n \"documentId\": string | number;\n \"documentFormat\"?: string | number | boolean;\n body: unknown;\n }): Promise<any>;\n /** `documents.records.count` — GET /documents/{documentId}/records/{model}/count. Count records in a document model */\n \"count\"(args: {\n \"documentId\": string | number;\n \"model\": string | number;\n \"documentFormat\"?: string | number | boolean;\n \"filter\"?: Record<string, unknown> | string;\n }): Promise<any>;\n /** `documents.records.delete` — DELETE /documents/{documentId}/records/{model}/{recordId}. Delete a record from a document model */\n \"delete\"(args: {\n \"documentId\": string | number;\n \"model\": string | number;\n \"recordId\": string | number;\n \"documentFormat\"?: string | number | boolean;\n }): Promise<any>;\n /** `documents.records.patch` — PATCH /documents/{documentId}/records/{model}/{recordId}. Merge fields into an existing record in a document model */\n \"patch\"(args: {\n \"documentId\": string | number;\n \"model\": string | number;\n \"recordId\": string | number;\n \"documentFormat\"?: string | number | boolean;\n body: unknown;\n }): Promise<any>;\n /** `documents.records.query` — GET /documents/{documentId}/records/{model}. Query records in a document model */\n \"query\"(args: {\n \"documentId\": string | number;\n \"model\": string | number;\n \"documentFormat\"?: string | number | boolean;\n \"limit\"?: string | number | boolean;\n \"cursor\"?: string | number | boolean;\n \"filter\"?: Record<string, unknown> | string;\n }): Promise<any>;\n /** `documents.records.save` — POST /documents/{documentId}/records/{model}. Create or replace a record in a document model */\n \"save\"(args: {\n \"documentId\": string | number;\n \"model\": string | number;\n \"documentFormat\"?: string | number | boolean;\n body: unknown;\n }): Promise<any>;\n };\n /** `documents.removePermissionByEmail` — DELETE /documents/{documentId}/permissions. Revoke a user's permission on a document by email (?email=) */\n \"removePermissionByEmail\"(args: {\n \"documentId\": string | number;\n \"email\"?: string | number | boolean;\n }): Promise<any>;\n /** `documents.removePermissionByUserId` — DELETE /documents/{documentId}/permissions/{userId}. Revoke a user's permission on a document by user id */\n \"removePermissionByUserId\"(args: {\n \"documentId\": string | number;\n \"userId\": string | number;\n }): Promise<any>;\n /** `documents.removeTag` — DELETE /documents/{documentId}/tags/{tag}. Remove a tag from a document */\n \"removeTag\"(args: {\n \"documentId\": string | number;\n \"tag\": string | number;\n }): Promise<any>;\n /** `documents.requestAccess` — POST /documents/{documentId}/access-requests. Request access to a document */\n \"requestAccess\"(args: {\n \"documentId\": string | number;\n body: unknown;\n }): Promise<any>;\n /** `documents.requestSnapshot` — POST /documents/{documentId}/snapshots. Snapshot a large document now: seal the open epoch and build a base */\n \"requestSnapshot\"(args: {\n \"documentId\": string | number;\n body: unknown;\n }): Promise<any>;\n /** `documents.revokeGroupPermission` — DELETE /documents/{documentId}/group-permissions/{groupType}/{groupId}. Revoke a group permission on a document */\n \"revokeGroupPermission\"(args: {\n \"documentId\": string | number;\n \"groupType\": string | number;\n \"groupId\": string | number;\n }): Promise<any>;\n /** `documents.setLinkAccess` — PUT /documents/{documentId}/link-access. Set the document's \"anyone with the link\" access level */\n \"setLinkAccess\"(args: {\n \"documentId\": string | number;\n body: unknown;\n }): Promise<any>;\n /** `documents.transferOwnership` — POST /documents/{documentId}/permissions/transfer. Transfer ownership of a document to another user */\n \"transferOwnership\"(args: {\n \"documentId\": string | number;\n body: unknown;\n }): Promise<any>;\n /** `documents.update` — PUT /documents/{documentId}. Update a document's metadata */\n \"update\"(args: {\n \"documentId\": string | number;\n body: unknown;\n }): Promise<any>;\n /** `documents.updatePermissions` — PUT /documents/{documentId}/permissions. Grant or update a user's permission on a document */\n \"updatePermissions\"(args: {\n \"documentId\": string | number;\n body: unknown;\n }): Promise<any>;\n /** `documents.uploadIngestChunk` — POST /documents/{documentId}/ingest/{sessionId}/chunks. Upload one chunk of a bulk-load session's artifact */\n \"uploadIngestChunk\"(args: {\n \"documentId\": string | number;\n \"sessionId\": string | number;\n body: FormData | ArrayBuffer | Uint8Array | string;\n }): Promise<any>;\n /** `documents.validateAccess` — POST /documents/{documentId}/validate-access. Resolve effective access to a document, for the caller or a named user */\n \"validateAccess\"(args: {\n \"documentId\": string | number;\n body?: unknown;\n }): Promise<any>;\n };\n \"email\": {\n /** `email.send` — POST /emails/send. Send an application email under a server function's grant */\n \"send\"(args: {\n body: unknown;\n }): Promise<any>;\n };\n \"functions\": {\n /** `functions.invoke` — POST /functions/{functionKey}. Invoke a server function: a request function returns its result, a task function starts a run */\n \"invoke\"(args: {\n \"functionKey\": string | number;\n body?: unknown;\n }): Promise<any>;\n /** `functions.invokeAsSystem` — POST /functions/{functionKey}/invoke-as-system. Invoke a server function as the system, with no caller */\n \"invokeAsSystem\"(args: {\n \"functionKey\": string | number;\n body?: unknown;\n }): Promise<any>;\n /** `functions.logs` — GET /functions/{functionKey}/logs. List a server function's invocation logs, newest first */\n \"logs\"(args: {\n \"functionKey\": string | number;\n \"limit\"?: string | number | boolean;\n \"cursor\"?: string | number | boolean;\n \"runId\"?: string | number | boolean;\n }): Promise<any>;\n /** `functions.start` — POST /functions/{functionKey}/start. Start a server function as a task run */\n \"start\"(args: {\n \"functionKey\": string | number;\n body?: unknown;\n }): Promise<any>;\n };\n \"gemini\": {\n /**\n * `gemini.countTokens` — POST /gemini/count-tokens. Count tokens for a Gemini request\n * @deprecated These direct proxy routes will be removed in the next major release of the platform server. Run a managed prompt from a server function instead: `ctx.prompts.run` (see the Server Functions guide).\n */\n \"countTokens\"(args: {\n body: unknown;\n }): Promise<any>;\n /**\n * `gemini.generate` — POST /gemini/generate. Generate content with Gemini\n * @deprecated These direct proxy routes will be removed in the next major release of the platform server. Run a managed prompt from a server function instead: `ctx.prompts.run` (see the Server Functions guide).\n */\n \"generate\"(args: {\n body: unknown;\n }): Promise<any>;\n /**\n * `gemini.generateRaw` — POST /gemini/generate-raw. Generate content with Gemini (raw passthrough)\n * @deprecated These direct proxy routes will be removed in the next major release of the platform server. Run a managed prompt from a server function instead: `ctx.prompts.run` (see the Server Functions guide).\n */\n \"generateRaw\"(args: {\n \"model\"?: string | number | boolean;\n body: unknown;\n }): Promise<any>;\n /**\n * `gemini.models` — GET /gemini/models. List available Gemini models\n * @deprecated These direct proxy routes will be removed in the next major release of the platform server. Run a managed prompt from a server function instead: `ctx.prompts.run` (see the Server Functions guide).\n */\n \"models\"(args?: Record<string, never>): Promise<any>;\n };\n \"groups\": {\n /** `groups.addMember` — POST /groups/{groupType}/{groupId}/members. Add a member to a group */\n \"addMember\"(args: {\n \"groupType\": string | number;\n \"groupId\": string | number;\n body: unknown;\n }): Promise<any>;\n /** `groups.create` — POST /groups. Create a group */\n \"create\"(args: {\n body: unknown;\n }): Promise<any>;\n /** `groups.delete` — DELETE /groups/{groupType}/{groupId}. Delete a group */\n \"delete\"(args: {\n \"groupType\": string | number;\n \"groupId\": string | number;\n }): Promise<any>;\n /** `groups.get` — GET /groups/{groupType}/{groupId}. Get a group by type and id */\n \"get\"(args: {\n \"groupType\": string | number;\n \"groupId\": string | number;\n }): Promise<any>;\n /** `groups.list` — GET /groups. List groups */\n \"list\"(args?: {\n \"type\"?: string | number | boolean;\n \"includeSystem\"?: string | number | boolean;\n \"limit\"?: string | number | boolean;\n \"cursor\"?: string | number | boolean;\n }): Promise<any>;\n /** `groups.listDatabases` — GET /groups/{groupType}/{groupId}/databases. List databases shared with a group */\n \"listDatabases\"(args: {\n \"groupType\": string | number;\n \"groupId\": string | number;\n }): Promise<any>;\n /** `groups.listDocuments` — GET /groups/{groupType}/{groupId}/documents. List documents shared with a group */\n \"listDocuments\"(args: {\n \"groupType\": string | number;\n \"groupId\": string | number;\n }): Promise<any>;\n /** `groups.listMembers` — GET /groups/{groupType}/{groupId}/members. List a group's members */\n \"listMembers\"(args: {\n \"groupType\": string | number;\n \"groupId\": string | number;\n \"limit\"?: string | number | boolean;\n \"cursor\"?: string | number | boolean;\n \"include\"?: string | number | boolean;\n }): Promise<any>;\n /** `groups.listPendingInvitations` — GET /groups/{groupType}/{groupId}/pending-invitations. List a group's pending invitations */\n \"listPendingInvitations\"(args: {\n \"groupType\": string | number;\n \"groupId\": string | number;\n }): Promise<any>;\n /** `groups.listUserMemberships` — GET /users/{userId}/memberships. List a user's group memberships */\n \"listUserMemberships\"(args: {\n \"userId\": string | number;\n \"includeSystem\"?: string | number | boolean;\n \"type\"?: string | number | boolean;\n }): Promise<any>;\n /** `groups.removeMember` — DELETE /groups/{groupType}/{groupId}/members/{userId}. Remove a specific member from a group */\n \"removeMember\"(args: {\n \"groupType\": string | number;\n \"groupId\": string | number;\n \"userId\": string | number;\n }): Promise<any>;\n /** `groups.removeMemberByEmail` — DELETE /groups/{groupType}/{groupId}/members. Remove a group member or pending invitation by email */\n \"removeMemberByEmail\"(args: {\n \"groupType\": string | number;\n \"groupId\": string | number;\n \"email\"?: string | number | boolean;\n }): Promise<any>;\n /** `groups.update` — PATCH /groups/{groupType}/{groupId}. Update a group */\n \"update\"(args: {\n \"groupType\": string | number;\n \"groupId\": string | number;\n body: unknown;\n }): Promise<any>;\n };\n \"integrations\": {\n /** `integrations.call` — POST /integrations/{integrationKey}/call. Call an integration under a server function's grants */\n \"call\"(args: {\n \"integrationKey\": string | number;\n body?: unknown;\n }): Promise<any>;\n /** `integrations.list` — GET /integrations. List integrations configured for the app */\n \"list\"(args?: Record<string, never>): Promise<any>;\n /** `integrations.proxy` — POST /integrations/{integrationKey}/proxy. Proxy a request through a configured integration */\n \"proxy\"(args: {\n \"integrationKey\": string | number;\n }): Promise<any>;\n };\n \"llm\": {\n /**\n * `llm.chat` — POST /llm/chat. Run an LLM chat completion\n * @deprecated These direct proxy routes will be removed in the next major release of the platform server. Run a managed prompt from a server function instead: `ctx.prompts.run` (see the Server Functions guide).\n */\n \"chat\"(args: {\n body: unknown;\n }): Promise<any>;\n /**\n * `llm.models` — GET /llm/models. List available LLM models\n * @deprecated These direct proxy routes will be removed in the next major release of the platform server. Run a managed prompt from a server function instead: `ctx.prompts.run` (see the Server Functions guide).\n */\n \"models\"(args?: Record<string, never>): Promise<any>;\n };\n \"locks\": {\n /** `locks.list` — GET /locks. List all currently-held named locks in the app */\n \"list\"(args?: Record<string, never>): Promise<any>;\n /** `locks.release` — POST /locks/release. Release a held named lock (requires the acquire handle) */\n \"release\"(args: {\n body: unknown;\n }): Promise<any>;\n /** `locks.renew` — POST /locks/renew. Extend the lease on a held named lock */\n \"renew\"(args: {\n body: unknown;\n }): Promise<any>;\n /** `locks.status` — POST /locks/status. Report the current holder of a named lock */\n \"status\"(args: {\n body: unknown;\n }): Promise<any>;\n /** `locks.tryAcquire` — POST /locks/acquire. Attempt to acquire a named lock (single non-blocking attempt) */\n \"tryAcquire\"(args: {\n body: unknown;\n }): Promise<any>;\n };\n \"notifications\": {\n /** `notifications.list` — GET /notifications. List the caller's in-app notification inbox (newest first) */\n \"list\"(args?: {\n \"limit\"?: string | number | boolean;\n \"cursor\"?: string | number | boolean;\n }): Promise<any>;\n /** `notifications.listDevices` — GET /me/push-tokens. List the caller's registered push devices */\n \"listDevices\"(args?: Record<string, never>): Promise<any>;\n /** `notifications.markAllRead` — POST /notifications/read-all. Mark all of the caller's notifications as read */\n \"markAllRead\"(args?: Record<string, never>): Promise<any>;\n /** `notifications.markRead` — PATCH /notifications/{notificationId}/read. Mark one of the caller's notifications as read */\n \"markRead\"(args: {\n \"notificationId\": string | number;\n }): Promise<any>;\n /** `notifications.registerDevice` — POST /me/push-tokens. Register (upsert) the caller's device push token */\n \"registerDevice\"(args: {\n body: unknown;\n }): Promise<any>;\n /** `notifications.send` — POST /notifications/send. Send a notification to an app user (durable in-app inbox row + live WS frame) */\n \"send\"(args: {\n body: unknown;\n }): Promise<any>;\n /** `notifications.unreadCount` — GET /notifications/unread-count. Count the caller's unread notifications */\n \"unreadCount\"(args?: Record<string, never>): Promise<any>;\n /** `notifications.unregisterDevice` — DELETE /me/push-tokens/{token}. Unregister one of the caller's device push tokens */\n \"unregisterDevice\"(args: {\n \"token\": string | number;\n }): Promise<any>;\n };\n \"prompts\": {\n /** `prompts.execute` — POST /prompts/{promptKey}/execute. Execute a saved prompt */\n \"execute\"(args: {\n \"promptKey\": string | number;\n }): Promise<any>;\n /** `prompts.run` — POST /prompts/{promptKey}/run. Run a prompt under a server function's grants */\n \"run\"(args: {\n \"promptKey\": string | number;\n body?: unknown;\n }): Promise<any>;\n };\n \"resourceMetadata\": {\n /** `resourceMetadata.delete` — DELETE /resources/{resourceType}/{resourceId}/metadata/{category}. Delete a resource's metadata for a category (idempotent) */\n \"delete\"(args: {\n \"resourceType\": string | number;\n \"resourceId\": string | number;\n \"category\": string | number;\n }): Promise<any>;\n /** `resourceMetadata.get` — GET /resources/{resourceType}/{resourceId}/metadata/{category}. Read a resource's metadata for a category */\n \"get\"(args: {\n \"resourceType\": string | number;\n \"resourceId\": string | number;\n \"category\": string | number;\n }): Promise<any>;\n /** `resourceMetadata.getBatch` — POST /resources/metadata/batch. Batch-read resource metadata (partial success) */\n \"getBatch\"(args: {\n \"debug\"?: string | number | boolean;\n body: unknown;\n }): Promise<any>;\n /** `resourceMetadata.list` — GET /resources/{resourceType}/{resourceId}/metadata. List all metadata categories on a resource */\n \"list\"(args: {\n \"resourceType\": string | number;\n \"resourceId\": string | number;\n }): Promise<any>;\n /** `resourceMetadata.resolve` — POST /metadata/resolve. Resolve a resource by a category's unique metadata value */\n \"resolve\"(args: {\n body: unknown;\n }): Promise<any>;\n /** `resourceMetadata.set` — PUT /resources/{resourceType}/{resourceId}/metadata/{category}. Write a resource's metadata for a category */\n \"set\"(args: {\n \"resourceType\": string | number;\n \"resourceId\": string | number;\n \"category\": string | number;\n body: unknown;\n }): Promise<any>;\n };\n \"secrets\": {\n /** `secrets.get` — GET /secrets/{name}. Read an app secret under a server function's grants */\n \"get\"(args: {\n \"name\": string | number;\n }): Promise<any>;\n };\n \"users\": {\n /** `users.getBasic` — GET /users/{userId}/basic. Get a user's basic public profile */\n \"getBasic\"(args: {\n \"userId\": string | number;\n }): Promise<any>;\n /** `users.getProfiles` — POST /users/profiles. Look up user profiles in bulk */\n \"getProfiles\"(args: {\n body: unknown;\n }): Promise<any>;\n /** `users.list` — GET /users. List app users */\n \"list\"(args?: {\n \"email\"?: string | number | boolean;\n \"userId\"?: string | number | boolean;\n \"name\"?: string | number | boolean;\n \"limit\"?: string | number | boolean;\n \"cursor\"?: string | number | boolean;\n }): Promise<any>;\n /** `users.lookup` — GET /users/lookup. Look up a user by identifier */\n \"lookup\"(args?: {\n \"email\"?: string | number | boolean;\n }): Promise<any>;\n /**\n * `users.remove` — DELETE /users/{userId}. DEPRECATED — remove a user from the app; use the admin API's PUT apps/:appId/users/:userId/disable (`primitive users disable`)\n * @deprecated Use the admin API's PUT apps/:appId/users/:userId/disable (`primitive users disable`)\n */\n \"remove\"(args: {\n \"userId\": string | number;\n }): Promise<any>;\n /** `users.send` — POST /users/{userId}/send. Send a realtime message to a member of this app */\n \"send\"(args: {\n \"userId\": string | number;\n body: unknown;\n }): Promise<any>;\n /** `users.setRole` — PUT /users/{userId}/role. Set a user's app role */\n \"setRole\"(args: {\n \"userId\": string | number;\n body: unknown;\n }): Promise<any>;\n };\n}\n\n/**\n * The app's database types, model by model — EMPTY here and filled by the\n * declaration `primitive config push` writes into the config tree's\n * `functions/` directory (#3182). A tree that has pushed once therefore types\n * `ctx.db` against its own schemas; one that has not gets the open form and\n * still compiles.\n */\nexport interface DatabaseSchemas {}\n\n/**\n * The type keys `ctx.db` accepts.\n *\n * Every key the augmentation declares, and NOTHING else, once a tree has\n * pushed: naming a type the app does not have is a compile error. Before that\n * — an unaugmented tree, a function written before the first push —\n * `DatabaseSchemas` is empty and `keyof` it is `never`, which would make the\n * argument unwritable rather than open. So the empty case widens to `string`\n * and the handle is untyped instead of unusable.\n */\nexport type DatabaseTypeKeys = [keyof DatabaseSchemas] extends [never]\n ? string\n : keyof DatabaseSchemas & string;\n\n/** A model's row shape, or an open record for a type with no schema. */\nexport type DatabaseModels<K extends string> = K extends keyof DatabaseSchemas\n ? DatabaseSchemas[K]\n : Record<string, Record<string, unknown>>;\n\n/**\n * The app's functions, key by key — EMPTY here and filled by the declaration\n * `primitive config push` writes into the config tree's `functions/`\n * directory (`primitive-function-types.d.ts`): each key's declared input and\n * output types, from its `inputSchema` and `outputSchema`. It is what types\n * `defineFunction(\"<key>\", handler)`.\n */\nexport interface FunctionSchemas {}\n\n/**\n * The keys `defineFunction(key, handler)` accepts: every key the augmentation\n * declares once a tree has pushed, so a key the tree does not declare is a\n * compile error — and `string` before that, the `DatabaseTypeKeys` rule, so an\n * unaugmented tree keeps compiling.\n */\nexport type FunctionKeys = [keyof FunctionSchemas] extends [never]\n ? string\n : keyof FunctionSchemas & string;\n\n/** A declared function's input type, or `any` when nothing is declared. */\nexport type FunctionInput<K extends string> = K extends keyof FunctionSchemas\n ? FunctionSchemas[K] extends { input: infer I }\n ? I\n : any\n : any;\n\n/** A declared function's output type, or `any` when nothing is declared. */\nexport type FunctionOutput<K extends string> = K extends keyof FunctionSchemas\n ? FunctionSchemas[K] extends { output: infer O }\n ? O\n : any\n : any;\n\n/**\n * The model names one database type addresses — its own, or any name at all\n * for a type that declares no schema (the DO is schemaless, so a grant on such\n * a type is legal and there is simply nothing to narrow to).\n */\nexport type DatabaseModelNames<TModels> = [keyof TModels] extends [never]\n ? string\n : keyof TModels & string;\n\n/**\n * A row as the platform HANDS IT BACK: whatever the schema declared, plus the\n * record identity the platform owns (#3450).\n *\n * Every stored record has an `id`. A save that arrives without one is given a\n * ULID, a projection always keeps it, and `delete` and `patch` take nothing\n * else — so a function that queries a model and then moves one of its rows\n * needs the id of the row it just read. A schema is free to say nothing about\n * that field, and most do; the identity is the platform's, not the schema's,\n * so it is added here rather than rendered into each declaration.\n *\n * A declared `id` is REPLACED, never intersected: one declared optional would\n * stay optional on a read row it is always present on, and one declared with\n * some other type would intersect to `never` and be unusable. The platform\n * stamps a string whatever the schema says.\n *\n * An `any` row stays `any` — `DatabaseHandle<any>` is `defineQuery`'s default\n * handle, and turning its rows into an object with one known member would\n * narrow code that was deliberately left open.\n *\n * Writes are untouched: every one of them takes `Partial<TRow>`, so a row a\n * function BUILDS still needs no id.\n */\nexport type PlatformRow<TRow> = 0 extends 1 & TRow\n ? TRow\n : Omit<TRow, \"id\"> & { id: string };\n\n/** One model's row shape, open when the type declares no schema. */\nexport type DatabaseModelRow<TModels, M extends string> =\n M extends keyof TModels\n ? PlatformRow<TModels[M]>\n : Record<string, unknown> & { id: string };\n\n/**\n * One model of one database, scoped: the `modelName` every records call needs\n * is bound once, so a call names an operation and its own arguments.\n *\n * Filters and options are ordinary objects. Inline filter typing arrives with\n * unified schemas — the intent's decision, not an omission — so what is typed\n * today is the model name and the row shape a read hands back.\n */\nexport type ModelScopedBody<TBody = Record<string, unknown>> = TBody & {\n /**\n * Bound by the handle. Reserved so a body cannot look like a second way to\n * choose a model: the runtime assigns the handle's own model last, and a row\n * type that said otherwise would be a lie about what came back.\n */\n modelName?: never;\n};\n\n/**\n * One write inside a model-scoped batch. Every batch verb is a write, so a\n * batch on a model needs that model's write grant whatever the ops are.\n */\nexport type ModelBatchOperation<TRow> = {\n op: \"save\" | \"patch\" | \"delete\" | \"increment\" | \"addToSet\" | \"removeFromSet\";\n id?: string;\n data?: Partial<TRow>;\n /** Bound by the handle, for the same reason every other call's is. */\n modelName?: never;\n [key: string]: unknown;\n};\n\nexport interface DatabaseModelHandle<TRow> {\n /**\n * One page of this model's rows, in the decided envelope — `{ items,\n * hasMore, nextCursor? }` (#3287), the same shape `ctx.doc(...)`,\n * `ctx.users.list` and the client library answer. The route's own wire\n * shape is unchanged; the SDK is where the one name lives, so shared paging\n * code can be written once.\n */\n query(body?: ModelScopedBody): Promise<{ items: TRow[]; hasMore: boolean; nextCursor?: string }>;\n count(body?: ModelScopedBody): Promise<any>;\n aggregate(body: ModelScopedBody): Promise<any>;\n save(body: ModelScopedBody<{ id?: string; data: Partial<TRow>; [key: string]: unknown }>): Promise<any>;\n /**\n * Change some fields of ONE row — `databases.records.patch`, with this\n * handle's model bound (#3450).\n *\n * The record id is positional and the body may not carry another, for the\n * same reason it may not name another model: the runtime assigns both LAST,\n * so a body that appeared to choose either would be a lie about which row\n * moved. `condition`, `stringSets` and the rest of the operation's own keys\n * pass through untouched.\n */\n patch(\n recordId: string,\n body: ModelScopedBody<{ data: Partial<TRow>; id?: never; [key: string]: unknown }>\n ): Promise<any>;\n /**\n * Remove ONE row by the id a read handed back — `databases.records.delete`,\n * with this handle's model bound (#3450). An optional `condition` makes it\n * conditional, and travels untouched.\n */\n delete(\n recordId: string,\n body?: ModelScopedBody<{ condition?: Record<string, unknown>; id?: never }>\n ): Promise<any>;\n /** Several writes to THIS model in one request; the binding is per item. */\n batch(body: {\n operations: Array<ModelBatchOperation<TRow>>;\n atomic?: boolean;\n }): Promise<any>;\n}\n\n/** One database, typed by the database TYPE key its grant names. */\nexport interface DatabaseHandle<TModels> {\n /** The database this handle addresses — part of every query cache key. */\n databaseId: string;\n /** The type key this handle was opened with. */\n databaseType: string;\n model<M extends DatabaseModelNames<TModels>>(\n modelName: M\n ): DatabaseModelHandle<DatabaseModelRow<TModels, M>>;\n /**\n * A batch may also SPAN models, and then it names each one itself — the\n * model-scoped form above is the typed way to write the common case.\n */\n batch(body: {\n operations: Array<Record<string, unknown>>;\n atomic?: boolean;\n }): Promise<any>;\n /** Run one of the database type's prepared operations under this function's grants. */\n runOperation(name: string, params?: Record<string, unknown>): Promise<any>;\n}\n\n/**\n * The app's DOCUMENT models — EMPTY here and filled by the declaration\n * `primitive config push` writes into the config tree's `functions/` directory\n * (`primitive-document-types.d.ts`, from the project's `models/models.toml`).\n * A project with no document schema gets the open form and still compiles.\n */\nexport interface DocumentSchemas {}\n\n/** The model names `ctx.doc(id).model()` accepts — every declared one, or `string` before a push. */\nexport type DocumentModelNames = [keyof DocumentSchemas] extends [never]\n ? string\n : keyof DocumentSchemas & string;\n\n/**\n * A document model's row shape, or an open record for an undeclared schema —\n * carrying the platform's record identity either way (#3450), by the same rule\n * and for the same reason as a database row: the records DO is one\n * implementation, and `patch` and `delete` here take an id too.\n */\nexport type DocumentModelRow<M extends string> = M extends keyof DocumentSchemas\n ? PlatformRow<DocumentSchemas[M]>\n : Record<string, unknown> & { id: string };\n\n/** The options a document model read takes: a filter object (or its JSON), a page size, a cursor. */\nexport interface DocumentQueryOptions {\n filter?: Record<string, unknown> | string;\n limit?: number;\n cursor?: string;\n /**\n * The document format you expect (#3764). When it disagrees with the format\n * the platform resolved, the call is refused with a 409\n * DOCUMENT_FORMAT_MISMATCH rather than answered out of the wrong tables.\n * Usually stated once on the handle, as ctx.doc(id, { documentFormat: 2 }),\n * rather than per read.\n */\n documentFormat?: 1 | 2;\n}\n\n/**\n * One document model, bound to its document and its model name — a thin\n * binding over `ctx.api.documents.records.*` with the route's own shapes.\n */\n/**\n * One op of a document `batch` — the `documents.records.bulk` blob's shape,\n * typed to this handle's model (#3455).\n *\n * `model` is NOT a member: the handle already names it and assigns it last, so\n * a multi-model blob stays on the raw `ctx.api.documents.records.bulk`\n * operation rather than becoming a second way to say the same thing.\n */\nexport type DocumentBatchOp<TRow> =\n | { action: \"create\" | \"patch\"; id: string; data: Partial<TRow>; precondition?: Record<string, unknown> }\n | { action: \"delete\"; id: string; precondition?: Record<string, unknown> };\n\n/** What `documents.records.bulk` answers: the blob's aggregate effect. */\nexport interface DocumentBulkResult {\n applied: number;\n added: Array<{ model: string; id: string }>;\n updated: Array<{ model: string; id: string }>;\n deleted: number;\n}\n\nexport interface DocumentModelHandle<TRow> {\n query(options?: DocumentQueryOptions): Promise<{ items: TRow[]; hasMore: boolean; nextCursor?: string }>;\n count(options?: { filter?: Record<string, unknown> | string }): Promise<{ count: number }>;\n aggregate(body: Record<string, unknown>): Promise<any>;\n save(body: { id: string; data: Partial<TRow>; options?: Record<string, unknown> }): Promise<{ record: TRow }>;\n patch(recordId: string, body: { data: Partial<TRow>; options?: Record<string, unknown> }): Promise<{ record: TRow }>;\n delete(recordId: string): Promise<{ deleted: boolean }>;\n /**\n * Apply an ordered blob of this model's ops in ONE transaction — all of it\n * commits or none of it does, and connected clients see one update.\n *\n * One model's ops, by construction: every op's `model` is this handle's.\n * A blob that spans models is the raw `ctx.api.documents.records.bulk`\n * operation's job.\n */\n batch(ops: Array<DocumentBatchOp<TRow>>): Promise<DocumentBulkResult>;\n}\n\n/** A document, addressed once; its models are typed from `DocumentSchemas`. */\nexport interface DocumentHandle {\n documentId: string;\n model<M extends DocumentModelNames>(modelName: M): DocumentModelHandle<DocumentModelRow<M>>;\n}\n\n/**\n * One call through a granted integration — #3183.\n *\n * `path` is RELATIVE to the integration's `baseUrl`, and the host is the\n * integration's: the platform resolves and normalizes the path before checking\n * it against `allowedPaths`, so a protocol-relative path or a `..` segment is\n * refused rather than silently sending the request somewhere else.\n */\nexport interface IntegrationCallRequest {\n /** Must be in the integration's `allowedMethods`. Defaults to its own default. */\n method?: string;\n /** Relative to the integration's `baseUrl`. */\n path?: string;\n query?: Record<string, unknown>;\n headers?: Record<string, string>;\n body?: unknown;\n /** form-urlencoded body; not combinable with `body`. */\n form?: Record<string, unknown>;\n bodyMode?: \"json\" | \"raw\" | \"multipart\";\n}\n\n/** What the upstream answered, as the platform saw it. */\nexport interface IntegrationCallResult {\n status: number;\n headers: Record<string, string>;\n body: unknown;\n durationMs: number;\n traceId: string;\n /** Set when the platform or the upstream refused; absent on success. */\n errorCode?: string;\n}\n\n/** What a prompt run is given — the member execute route's own body. */\nexport interface PromptRunArgs {\n /**\n * The prompt's variables. A `kind = \"decisions\"` prompt takes\n * `{ state, criteria? }`: `state` is the value its questions are asked\n * about, and `criteria.<question>` supplies this run's options for each\n * choice question declared `criteriaSource = \"dynamic\"` — a table of option\n * key = description (a string or a JSON object), at least two entries (#3813).\n */\n variables?: Record<string, unknown>;\n /** Run against a different model for this call only. */\n modelOverride?: string;\n /** Pin a specific config OF THIS PROMPT; defaults to its active one. */\n configId?: string;\n}\n\n/**\n * The app's PROMPTS — EMPTY here and filled by the declaration\n * `primitive config push` writes into the config tree's `functions/` directory\n * (`primitive-prompt-types.d.ts`, from the tree's `prompts/*.toml`). A prompt\n * that declares an `outputSchema` carries `{ output: <Key>PromptOutput }`; one\n * that declares none carries `{}`, so reading `parsed.field` on it is a\n * compile error rather than a runtime `undefined`.\n */\nexport interface PromptSchemas {}\n\n/**\n * The keys whose declaration is an AGENT (`kind = \"agent\"`, #3798): entries\n * carrying `{ agent: … }` instead of an output. An agent runs turn by turn in\n * a session and never single-shot, so these are the keys `PromptKeys` leaves\n * out.\n */\nexport type AgentKeys = {\n [K in keyof PromptSchemas]: PromptSchemas[K] extends { agent: unknown } ? K : never;\n}[keyof PromptSchemas] &\n string;\n\n/**\n * The keys `ctx.prompts.run` accepts — every declared one that is not an\n * agent, or `string` before a push.\n */\nexport type PromptKeys = [keyof PromptSchemas] extends [never]\n ? string\n : Exclude<keyof PromptSchemas & string, AgentKeys>;\n\n/** One agent's session variables, typed from its `inputSchema` (#3798). */\nexport type AgentVariables<K extends AgentKeys> = PromptSchemas[K] extends {\n agent: { variables: infer V };\n}\n ? V\n : never;\n\n/** One agent's client tools, by name: each one's `input` and `output` (#3798). */\nexport type AgentClientTools<K extends AgentKeys> = PromptSchemas[K] extends {\n agent: { clientTools: infer T };\n}\n ? T\n : never;\n\n/** One agent's event kinds, by name: each one's payload (#3798). */\nexport type AgentEvents<K extends AgentKeys> = PromptSchemas[K] extends {\n agent: { events: infer E };\n}\n ? E\n : never;\n\n/** One prompt's declared output type, or `unknown` where none is declared. */\nexport type PromptOutput<K extends string> = K extends keyof PromptSchemas\n ? PromptSchemas[K] extends { output: infer O }\n ? O\n : unknown\n : unknown;\n\n/**\n * Why a prompt's own answer was refused — #3330. Never set on a PROVIDER\n * failure, which is what makes \"the model returned the wrong shape\"\n * distinguishable from \"the model failed\".\n */\nexport type PromptOutputErrorCode =\n | \"PROMPT_OUTPUT_NOT_JSON\"\n | \"PROMPT_OUTPUT_SCHEMA_VIOLATION\";\n\n/**\n * Every code the envelope's `errorCode` can carry — #3663, #3813.\n *\n * `PROMPT_UPSTREAM_TIMEOUT` is the one that is NOT about the prompt's own\n * answer: the provider ran out of time, so there was no answer to refuse. It\n * is the only provider failure that sets `errorCode` at all, which is what\n * leaves \"the model returned the wrong shape\" distinguishable from \"the model\n * failed\" while still letting a caller retry the one failure worth retrying.\n *\n * `PROMPT_CRITERIA_INVALID` is the run that never reached a provider: a\n * decisions run's `variables.criteria` was refused before the call, so\n * nothing was billed (#3813).\n *\n * `PROMPT_STRICT_OUTPUT_SCHEMA_MISSING` never reached one either: the config\n * sets `strictOutput = true` and the prompt has no usable `outputSchema` to\n * send as the strict `json_schema` (#3801).\n */\nexport type PromptRunErrorCode =\n | PromptOutputErrorCode\n | \"PROMPT_UPSTREAM_TIMEOUT\"\n | \"PROMPT_CRITERIA_INVALID\"\n | \"PROMPT_STRICT_OUTPUT_SCHEMA_MISSING\";\n\n/** A prompt that declares an output shape, when the answer matched it. */\nexport interface PromptRunSuccess<TParsed> {\n success: true;\n output: string;\n /** The parsed, validated answer — no caller-side `JSON.parse` (#3330). */\n parsed: TParsed;\n error?: null;\n errorCode?: null;\n metrics?: Record<string, unknown>;\n configId: string;\n}\n\n/**\n * The failure arm, whichever failed. `errorCode` is set for a SHAPE failure,\n * for a refused run (`PROMPT_CRITERIA_INVALID`, #3813), and for a provider\n * one only when the upstream TIMED OUT (#3663); `output` carries the text\n * either way, which is where the model's own value lives — a validation\n * `error` names paths and schema constraints only.\n */\nexport interface PromptRunFailure {\n success: false;\n output: string;\n error: string | null;\n errorCode?: PromptRunErrorCode | null;\n parsed?: undefined;\n metrics?: Record<string, unknown>;\n configId: string;\n /**\n * The upstream provider's HTTP status, when the call reached a provider and\n * it answered — #3663. This is what a retry decision is made on: a 504 or a\n * 503 is worth another attempt, a 400 on a refused payload is not.\n *\n * It does not depend on which provider the config named: Gemini and\n * OpenRouter report it identically. It is absent when no provider answer was\n * observed — an unset key, an oversized payload, a completion that came back\n * empty — so a number here is always the provider's own.\n */\n upstreamStatus?: number;\n}\n\n/** The envelope for a key whose declaration says nothing about its output. */\nexport interface PromptRunOpenResult {\n success: boolean;\n output: string;\n /**\n * Present when the config that ran declares `outputFormat = \"json\"` and the\n * text parsed. Untyped: nothing declared its shape.\n */\n parsed?: unknown;\n error?: string | null;\n errorCode?: PromptRunErrorCode | null;\n metrics?: Record<string, unknown>;\n configId: string;\n /** The upstream provider's HTTP status on a provider failure — #3663. */\n upstreamStatus?: number;\n}\n\n/**\n * The member execute envelope, plus what the prompt's own declaration adds.\n *\n * For a key whose `prompts/<key>.toml` declares an `outputSchema`, this is a\n * discriminated union: narrow on `success` and `parsed` is the declared type,\n * required. For every other key — and in a tree that has not pushed — it is\n * the open shape, with `parsed` optional and `unknown`.\n */\nexport type PromptRunResult<K extends string = string> = K extends keyof PromptSchemas\n ? PromptSchemas[K] extends { output: infer O }\n ? PromptRunSuccess<O> | PromptRunFailure\n : PromptRunOpenResult\n : PromptRunOpenResult;\n\n/** What a send delivered to. */\nexport interface SendResult {\n /** Unique live connections the frame was sent to. Zero is a success. */\n connections: number;\n /** True when the per-user connection ceiling stopped the fanout. */\n truncated: boolean;\n}\n\n/** Who a channel grant is for, and for how long — #3184. */\nexport interface ChannelAuthorizeOptions {\n /**\n * The member the grant names. Caller mode defaults to the invoking caller;\n * system mode has no caller and must say.\n */\n userId?: string;\n /** Default 300 s, clamped to the platform ceiling of 900 s. */\n ttlSeconds?: number;\n}\n\n/** The credential a client presents on the WebSocket it already has. */\nexport interface ChannelGrantResult {\n channel: string;\n /** The signed grant. Hand it to the client; it is not readable here. */\n grant: string;\n /** Epoch milliseconds. Expiry is the only revocation a channel has. */\n expiresAt: number;\n}\n\n/** Where to start and how big a page to take — #3280. */\nexport interface UserPageOptions {\n /** Page size. Capped by the route at 100. */\n limit?: number;\n /** The `nextCursor` of the page before this one. */\n cursor?: string;\n}\n\n/** One user on the roster, as the platform's own users route reports them. */\nexport interface UserPageItem {\n userId: string;\n email: string | null;\n name: string | null;\n avatarUrl: string | null;\n role: string;\n addedAt: string | null;\n status: string;\n disabledAt: string | null;\n [key: string]: unknown;\n}\n\n/** The decided paged envelope, the same shape every paged read answers. */\nexport interface UserPage {\n items: UserPageItem[];\n hasMore: boolean;\n /** Absent on the last page. */\n nextCursor?: string;\n}\n\n/** How a nested start is keyed and labelled — #3280. */\nexport interface FunctionStartOptions {\n /**\n * Idempotency key, scoped to the tree's root initiator and the resolved\n * context document: a repeat replays the run that already exists rather than\n * starting a second. At most 100 characters.\n */\n runKey?: string;\n /**\n * The document the child's run is keyed under. Defaults through the\n * inheritance rule: the parent run's context, else the root caller's root\n * document, else `fn:<the root function's id>`. At most 100 characters.\n */\n contextDocId?: string;\n /** Caller metadata, at most 1 KB encoded. */\n meta?: Record<string, unknown>;\n}\n\n/** The start envelope, the same one a workflow start answers with — #3280. */\nexport interface FunctionStartResult {\n /** Poll this on the platform's run-status route. */\n runId: string;\n runKey: string;\n instanceId: string;\n status: string;\n /**\n * True when `runKey` already named a run in this tree, which this envelope\n * describes. That is what makes a run key a singleton.\n */\n existing?: boolean;\n}\n\nexport interface FunctionContext {\n /** The HTTP caller, or null for a webhook or cron fire. */\n user: FunctionUser | null;\n trigger: FunctionTrigger;\n /**\n * Which RUNTIME is hosting this code — #3482.\n *\n * Beside `trigger`, which says which DOOR fired, and they are different\n * questions: an HTTP call is whichever runtime the caller chose\n * (`invoke` or `start`), a cron fire is always a task and a webhook\n * delivery is always a request.\n *\n * To REFUSE a runtime rather than branch on it, call\n * `assertRuntime(\"task\")` — at module scope to refuse it outright, or in\n * the handler to refuse one call.\n */\n runtime: \"request\" | \"task\";\n /**\n * The RUN this invocation belongs to, or null — #3562.\n *\n * Set under the task runtime (every slice of the run, the first and every\n * resume) and for a webhook-fired request run, which writes a row. Null for\n * an HTTP `invoke`, which writes no run row at all.\n *\n * It is the deterministic OWNER a task run presents to re-take its own\n * lease: `ctx.api.locks.tryAcquire({ body: { key, ttlMs, owner: ctx.runId } })`\n * succeeds for the run that already holds the key, with a fresh handle.\n */\n runId: string | null;\n /**\n * The SLICE of the run this code is running in, or null — #3562.\n *\n * The same identifier `primitive functions runs` and the run-status\n * route's `slice.sliceId` report. A task run is a sequence of slices: it\n * changes when the run hibernates and wakes, which is how a handler can tell\n * a resume from a first pass.\n *\n * Null under the request runtime: a request invocation is not a slice.\n */\n sliceId: string | null;\n api: FunctionApi;\n /**\n * A typed handle over one database. The second argument is the database TYPE\n * key — the same key a `database:<type>/<model>:read|write` grant names —\n * and it is what selects the models this handle knows (#3182).\n */\n db<K extends DatabaseTypeKeys>(\n databaseId: string,\n databaseType: K\n ): DatabaseHandle<DatabaseModels<K>>;\n /**\n * A typed handle over one document's record models, typed from the\n * project's `models/models.toml` — `ctx.db`'s shape for documents. It\n * confers nothing: every call is a `documents.records.*` operation on the\n * same authority.\n */\n doc(documentId: string, options?: { documentFormat?: 1 | 2 }): DocumentHandle;\n /**\n * Outbound HTTP, through a granted integration and nowhere else (#3183).\n *\n * A function has no raw network access: every `fetch` to a host that is not\n * the platform answers `FUNCTION_EGRESS_DENIED`, grant or no grant. What an\n * `integration:<key>` grant buys is this call, which the MAIN WORKER makes on\n * the function's behalf — which is why the integration's `{{secrets.*}}`\n * credentials can be injected into the request without ever being visible to\n * the code that asked for it.\n */\n integrations: {\n call(\n integrationKey: string,\n request?: IntegrationCallRequest\n ): Promise<IntegrationCallResult>;\n };\n /**\n * Start a TASK function from inside this one — #3280.\n *\n * The one nested door, and it is a START. A request function is code and\n * code composes by being IMPORTED, so there is no synchronous nested\n * invocation to reach for; a request-mode callee answers\n * `FUNCTION_MODE_MISMATCH`.\n *\n * The callee's `access` gate is not consulted — this function's own gate was\n * the authorization — and every run in the tree is keyed by whoever started\n * it, so the member who invoked the root polls and terminates them all.\n * Nesting is bounded at four levels.\n */\n functions: {\n start(\n functionKey: string,\n input?: unknown,\n options?: FunctionStartOptions\n ): Promise<FunctionStartResult>;\n };\n /**\n * Run one of the app's prompts, with nothing to declare (#3183, #3279).\n *\n * The prompt's `accessRule` is not consulted — it states which MEMBERS may\n * execute the prompt from a client, and the invocation gate is what\n * authorized this call. The provider request is bounded by the invocation's\n * own deadline.\n *\n * TYPED BY KEY (#3330). Where `prompts/<key>.toml` declares an\n * `outputSchema`, the platform parses the answer, validates it against that\n * schema and hands it back as `parsed`, typed — so the shape is written once\n * in TOML instead of restated as a `JSON.parse` at every call site. Where\n * only the config that ran declares `outputFormat = \"json\"`, `parsed` is\n * present but `unknown`. Where neither is declared the envelope is exactly\n * what it has always been.\n *\n * A shape the declaration refuses is `success: false` with an `errorCode`\n * (`PROMPT_OUTPUT_NOT_JSON` or `PROMPT_OUTPUT_SCHEMA_VIOLATION`) and the\n * text still in `output`; a PROVIDER failure has `error` and no\n * `errorCode`, so the two are told apart without guessing.\n *\n * Once a tree has pushed, a key it does not declare is a compile error.\n */\n prompts: {\n run<K extends PromptKeys>(\n promptKey: K,\n args?: PromptRunArgs\n ): Promise<PromptRunResult<K>>;\n };\n /**\n * The value of one app secret, under a `secret:<NAME>` grant (#3183).\n *\n * Prefer `ctx.integrations.call` when the secret is a credential FOR an\n * integration: there the value is injected by the platform and never enters\n * the sandbox at all. This is for the cases an integration cannot express.\n *\n * Rejects with `FUNCTION_SECRET_NOT_FOUND` when the grant names a value\n * this environment has not been given — secrets are provisioned per\n * environment, out of band from the push.\n */\n secret(name: string): Promise<string>;\n /** The value of one app config var, under a `var:<NAME>` grant (#3183). */\n configVar(name: string): Promise<string>;\n /**\n * Realtime messages to this app's clients, under a `users:send` grant\n * (#3183).\n *\n * The recipient's client receives a `direct.message` frame carrying this\n * payload and the sending function's key. Presence is not guaranteed: a\n * member with no live socket answers `{ connections: 0 }` rather than an\n * error.\n */\n users: {\n /**\n * One page of the app's users — #3280.\n *\n * On the APP's system authority, whoever invoked the function: a member\n * who passes this function's gate reads whatever roster it chooses to\n * expose, so say who may in the function's own `access` expression.\n * `limit` is capped by the route at 100.\n */\n list(options?: UserPageOptions): Promise<UserPage>;\n /**\n * Every page of the app's users, in order — #3280.\n *\n * FOR A REQUEST FUNCTION AND A SINGLE-SLICE LOOP. A durable loop must take\n * its pages inside `step.do` with an EXPLICIT cursor: a memoized step does\n * not advance an iterator on resume, so an iteration across a sleep would\n * replay pages it had already taken.\n */\n iterate(options?: UserPageOptions): AsyncIterable<UserPage>;\n send(userId: string, payload: unknown): Promise<SendResult>;\n };\n /** The same frame to ONE connection, under a `connections:send` grant. */\n connections: {\n send(connectionId: string, payload: unknown): Promise<SendResult>;\n };\n /**\n * Realtime channels, under a `channel:<namespace>` grant that COVERS the\n * channel — #3184.\n *\n * `authorize` hands back a short-lived grant for ONE member to present on\n * the socket it already has; `publish` delivers a `channel.message` frame to\n * every connection that has joined and whose grant has not expired. Expiry is\n * the only revocation, so `expiresAt` comes back for the client to renew\n * ahead of — a renewal is another authorize and another subscribe.\n */\n channels: {\n authorize(\n channel: string,\n options?: ChannelAuthorizeOptions\n ): Promise<ChannelGrantResult>;\n publish(channel: string, payload: unknown): Promise<SendResult>;\n };\n}\n\n/** How the wait between one step's retries grows. */\nexport type StepBackoff = \"constant\" | \"linear\" | \"exponential\";\n\n/**\n * The retry and timeout policy for ONE `step.do` — Cloudflare Workflows' own\n * step config.\n *\n * Under the TASK runner the platform forwards this object to Workflows\n * untouched, so these are its fields and its spellings: a duration is either a\n * number of milliseconds or a string Workflows parses (`\"10 seconds\"`,\n * `\"5 minutes\"`). Under the REQUEST runner `step.do` accepts a config and\n * ignores it — the body runs inline, and there is nothing to retry into.\n *\n * `stepPolicy.<family>` IS a `StepConfig`, so the platform's own defaults\n * hand straight to `step.do` (#3657). The shape is closed on purpose: a key\n * outside it — `retry` for `retries`, `timeoutMs` for `timeout` — is a\n * refusal at `config push` rather than an option the engine silently drops.\n */\nexport interface StepConfig {\n retries?: { limit: number; delay: string | number; backoff?: StepBackoff };\n timeout?: string | number;\n}\n\n/**\n * The step handle. `step` is the third argument under BOTH runners, so the\n * same body runs either way — which is what `mode = \"any\"` is for (#3454).\n *\n * Under the TASK runner it is Cloudflare Workflows' `WorkflowStep`, forwarded\n * untouched: `step.do` results are memoized and replayed, and `step.sleep`\n * hibernates.\n *\n * Under the REQUEST runner it is the platform's own, bounded by the request's\n * clock: `do` executes the body inline (there is no engine to memoize into,\n * and nothing is replayed); `sleep` and `sleepUntil` REALLY wait when the\n * remaining request budget covers the duration, and otherwise fail the\n * invocation with `errorCode: \"FUNCTION_RUNTIME_REFUSED\"` saying to start the\n * function as a task; `waitForEvent` fails the same way, because nothing can\n * deliver an event to an invocation that has to return now. The thrown error's\n * `name` is `STEP_NOT_AVAILABLE` in every case, so a body that catches it\n * keeps catching it.\n */\nexport interface FunctionStep {\n do<T>(name: string, body: () => T | Promise<T>): Promise<T>;\n do<T>(\n name: string,\n config: StepConfig,\n body: () => T | Promise<T>\n ): Promise<T>;\n sleep(name: string, duration: number | string): Promise<void>;\n sleepUntil(name: string, timestamp: Date | number): Promise<void>;\n waitForEvent<T = unknown>(\n name: string,\n options: Record<string, unknown>\n ): Promise<T>;\n}\n\nexport declare const SDK_STUB_VERSION: string;\n\n/**\n * Thrown by `assertRuntime` when this function is running under the other\n * runtime — #3482.\n *\n * The platform settles it as `status: \"failed\"` with\n * `errorCode: \"FUNCTION_RUNTIME_REFUSED\"`, on a request invocation's\n * envelope and on a task run's row and record alike.\n */\nexport declare class FunctionRuntimeError extends Error {\n name: \"FUNCTION_RUNTIME_REFUSED\";\n /** The runtime this invocation is actually running under. */\n runtime: \"request\" | \"task\";\n /** The runtime the function asked for. */\n required: \"request\" | \"task\";\n}\n\n/**\n * Refuse the runtime this function was not written for — #3482.\n *\n * A function is a function and the caller picks the runtime at each call, so\n * nothing in config says which one a function may run under. This is the lock,\n * and it lives in the one place that can always be right about the code:\n *\n * ```ts\n * import { assertRuntime } from \"primitive-functions\";\n *\n * // At module scope: this function is never runnable inside a request.\n * assertRuntime(\"task\");\n *\n * export default async function (input, ctx, step) {\n * await step.sleep(\"cool-off\", \"1 hour\");\n * return { ok: true };\n * }\n * ```\n *\n * Returns when the runtimes match; otherwise throws\n * {@link FunctionRuntimeError}, which the platform settles as\n * `status: \"failed\"` with `errorCode: \"FUNCTION_RUNTIME_REFUSED\"` and a\n * message naming both runtimes and the verb that takes the one required.\n */\nexport declare function assertRuntime(required: \"request\" | \"task\"): void;\n\n/**\n * The handler a function exports, typed for one declared key.\n *\n * `step` is the third argument under BOTH runners (#3186, #3454). A task run\n * gets the engine's live `WorkflowStep`; a request invocation gets the\n * platform's own, where `do` runs the body inline and a wait the request\n * budget cannot cover fails the invocation naming the task runner — so a\n * task-authored body can be exercised as a request, and the one place the two\n * genuinely differ says so rather than pretending.\n */\nexport type FunctionHandler<TInput, TOutput> = (\n input: TInput,\n ctx: FunctionContext,\n step: FunctionStep\n) => Promise<TOutput>;\n\n/**\n * Declare a server function's handler, typed from its declaration.\n *\n * The KEYED form, `defineFunction(\"<key>\", handler)`, is typed from the\n * `FunctionSchemas` augmentation `primitive config push` writes beside the\n * sources: `input` is the key's declared input, the return is checked against\n * its declared output, and a key the tree does not declare is a compile error.\n * `config push` also refuses an entry whose key names another file's. In a\n * tree that has not pushed yet the key is any string and both types are `any`.\n *\n * The UNKEYED form is what it always was: author-declared generics. Both\n * styles reach the platform bootstrap identically — a plain default export\n * taking `(input, ctx, step)` runs exactly as a wrapped one does — so this is\n * a typing and intent marker, not a different calling convention.\n */\nexport declare function defineFunction<K extends FunctionKeys>(\n key: K,\n handler: (\n input: FunctionInput<K>,\n ctx: FunctionContext,\n step: FunctionStep\n ) => FunctionOutput<K> | Promise<FunctionOutput<K>>\n): FunctionHandler<FunctionInput<K>, FunctionOutput<K>> & { functionKey: K };\nexport declare function defineFunction<TInput = unknown, TOutput = unknown>(\n handler: (\n input: TInput,\n ctx: FunctionContext,\n step: FunctionStep\n ) => TOutput | Promise<TOutput>\n): FunctionHandler<TInput, TOutput>;\n\n/**\n * One declared parameter of a registered query.\n *\n * `caller: true` (or `type: \"$caller\"`) is the intent's IMMUTABLE binding:\n * the platform injects the invocation's user and refuses a call that supplies\n * the parameter itself.\n */\n/** The scalar parameter types, and an array parameter's element types. */\nexport type QueryScalarParamType = \"string\" | \"number\" | \"boolean\" | \"any\";\n\nexport interface QueryParamSpec {\n type?: QueryScalarParamType | \"$caller\" | \"array\";\n /** For `type: \"array\"` — the element type; absent means any element. */\n items?: { type: QueryScalarParamType };\n caller?: boolean;\n optional?: boolean;\n default?: unknown;\n}\n\n/** A scalar parameter type's TypeScript type. */\nexport type QueryScalarValue<T> = T extends \"string\"\n ? string\n : T extends \"number\"\n ? number\n : T extends \"boolean\"\n ? boolean\n : T extends \"$caller\"\n ? string\n : any;\n\n/** The value `run` receives for one declared parameter. */\nexport type QueryParamValue<S> = S extends { caller: true }\n ? string\n : S extends { type: \"array\"; items: { type: infer I } }\n ? QueryScalarValue<I>[]\n : S extends { type: \"array\" }\n ? unknown[]\n : S extends { type: infer T }\n ? QueryScalarValue<T>\n : any;\n\ntype QueryOptionalKeys<P> = {\n [K in keyof P]: P[K] extends { optional: true } ? K : never;\n}[keyof P];\n\n/**\n * `run`'s `params`, typed from the declaration: scalars as their scalar,\n * `$caller` as a string, an array as `T[]`, an `optional: true` parameter\n * as an optional key (a parameter with a default is always present). An\n * undeclared name is a compile error.\n */\nexport type QueryParams<P> = {\n [K in Exclude<keyof P, QueryOptionalKeys<P>>]: QueryParamValue<P[K]>;\n} & {\n [K in QueryOptionalKeys<P>]?: QueryParamValue<P[K]>;\n};\n\n/** A registration's definition with its parameters DECLARED, so `run` is typed from them. */\nexport interface TypedQueryDefinition<TDb, TSpec extends Record<string, QueryParamSpec>, TResult> {\n models: string[];\n params?: TSpec;\n cache?: { ttlMs: number };\n run: (db: TDb, params: QueryParams<TSpec>) => TResult | Promise<TResult>;\n}\n\nexport interface QueryDefinition<TDb, TParams, TResult> {\n /** The models this query touches. Caching is off unless the run matches. */\n models: string[];\n params?: Record<string, QueryParamSpec>;\n /**\n * Cache the answer for `ttlMs` — capped by the platform, and applied ONLY\n * when the run is verified: every model the body touched was declared, and\n * no prepared operation was used. A write through the handle drops the\n * entries that read the written model.\n */\n cache?: { ttlMs: number };\n run: (db: TDb, params: TParams) => TResult | Promise<TResult>;\n}\n\n/**\n * Register a named query over a database handle (#3187).\n *\n * A registration helper, not a language: `run` is ordinary code over the same\n * typed handle, and what registration adds is a name, declared parameters\n * (validated, coerced and defaulted), the `$caller` binding, and a cache the\n * platform may use when it can verify what the run touched.\n *\n * Register at MODULE scope: a registration made inside the handler still works\n * for direct calls but is invisible to `config push`'s manifest.\n *\n * `run`'s `params` are TYPED from the declaration (the first overload,\n * inferred with a `const` type parameter): a scalar as its scalar, `$caller`\n * as a string, `{ type: \"array\", items: { type: \"string\" } }` as `string[]`,\n * an `optional: true` parameter as an optional key; an undeclared name inside\n * `run` is a compile error. A declared default is coerced to the declared\n * type at registration, so `run` receives what the declaration promises. The\n * second overload keeps an explicit `TParams`.\n */\nexport declare function defineQuery<\n const TSpec extends Record<string, QueryParamSpec>,\n TDb = DatabaseHandle<any>,\n TResult = any\n>(\n name: string,\n definition: TypedQueryDefinition<TDb, TSpec, TResult>\n): (db: TDb, params?: Record<string, unknown>) => Promise<TResult>;\nexport declare function defineQuery<\n TDb = DatabaseHandle<any>,\n TParams = Record<string, any>,\n TResult = any\n>(\n name: string,\n definition: QueryDefinition<TDb, TParams, TResult>\n): (db: TDb, params?: Record<string, unknown>) => Promise<TResult>;\n\n/** The same, for a registration that writes. A mutation is never cached. */\nexport declare function defineMutation<\n const TSpec extends Record<string, QueryParamSpec>,\n TDb = DatabaseHandle<any>,\n TResult = any\n>(\n name: string,\n definition: TypedQueryDefinition<TDb, TSpec, TResult>\n): (db: TDb, params?: Record<string, unknown>) => Promise<TResult>;\nexport declare function defineMutation<\n TDb = DatabaseHandle<any>,\n TParams = Record<string, any>,\n TResult = any\n>(\n name: string,\n definition: QueryDefinition<TDb, TParams, TResult>\n): (db: TDb, params?: Record<string, unknown>) => Promise<TResult>;\n\n/** The platform's cap on a registered query's cache TTL, in milliseconds. */\nexport declare const MAX_QUERY_CACHE_TTL_MS: number;\n\n/**\n * Map over items with BOUNDED concurrency (#3187). Results come back in the\n * input's order; the first rejection wins and nothing new is started after it.\n *\n * The bound matters inside a sandbox: an unbounded fan-out over a page of rows\n * spends the whole subrequest ceiling in one line.\n */\nexport declare function pMap<T, R>(\n items: Iterable<T>,\n mapper: (item: T, index: number) => R | Promise<R>,\n options?: { concurrency?: number }\n): Promise<R[]>;\n\n/** The default concurrency `pMap` applies when none is given. */\nexport declare const PMAP_DEFAULT_CONCURRENCY: number;\n\n/**\n * A time-ordered ULID.\n *\n * GENERATE IT INSIDE `step.do`. A durable run re-executes its handler on\n * every resume and memoizes only what a step returned, so an id minted at the\n * top of a handler is a different id after a sleep — and whatever it was\n * written into is orphaned.\n */\nexport declare function ulid(): string;\n\n/** One family's durable `step.do` configuration — a `StepConfig` with every field decided. */\nexport interface StepPolicy extends StepConfig {\n retries: { limit: number; delay: string; backoff: StepBackoff };\n timeout: string;\n}\n\n/**\n * The per-family step policies the DSL runners use, generated from their own\n * timeout module (#3187):\n *\n * await step.do(\"send-receipt\", stepPolicy.email, () =>\n * ctx.api.email.send({ body: { to, subject, htmlBody } }));\n *\n * `retries: 0` on email and the AI families is deliberate — a retried timeout\n * would send the same email twice or bill the same generation twice.\n */\nexport declare const stepPolicy: {\n email: StepPolicy;\n llm: StepPolicy;\n gemini: StepPolicy;\n database: StepPolicy;\n};\n\n// Every member the three runtime copies put on their own default export — the\n// platform's `sdk-core.ts`, the published stub and the CLI's collect stub —\n// and nothing else. A helper the module hands a default import but does not\n// declare here is one an author cannot call without the compiler refusing it\n// (#3482 CR3482-002); `tests/api/spec/function-profile.test.ts` holds the four\n// lists equal and compiles a default import against them.\ndeclare const _default: {\n SDK_STUB_VERSION: string;\n defineFunction: typeof defineFunction;\n defineQuery: typeof defineQuery;\n defineMutation: typeof defineMutation;\n pMap: typeof pMap;\n ulid: typeof ulid;\n assertRuntime: typeof assertRuntime;\n FunctionRuntimeError: typeof FunctionRuntimeError;\n};\nexport default _default;\n";
12
+ export const SDK_TYPES_SOURCE = "// GENERATED by scripts/generate-function-profile.mjs from openapi.json.\n// DO NOT EDIT. Run `pnpm functions:profile` and commit the result; the\n// freshness guard in tests/api/spec/function-profile.test.ts fails when this\n// file and a fresh generation diverge.\n\n/**\n * Type surface of `primitive-functions` — what a server function's author writes\n * against (#3180). The published package's RUNTIME is a stub that throws from\n * every export on purpose: the platform substitutes its own copy at invoke\n * time, and reaching the stub means it did not.\n */\n\n/**\n * The signed-in user who invoked the function over HTTP.\n *\n * Attribution, never authority (#3279): function code acts as the system\n * whoever called it, so this says WHO asked, and the rows the function writes\n * are attributed to them. A trigger fire has no caller and `ctx.user` is\n * null.\n */\nexport interface FunctionUser {\n userId: string;\n email: string | null;\n}\n\n/**\n * What started this invocation. Narrow on `kind`.\n *\n * The same union the runtime builds (`src/server-functions/trigger-descriptor.ts`),\n * held identical by `tests/api/spec/function-trigger-declarations-3281.test.ts`:\n * a field the fire path sets is declared here, and nothing is declared here\n * that the fire path does not set.\n */\nexport type FunctionTrigger =\n /**\n * An HTTP invocation: the caller is `ctx.user`.\n *\n * `runKey` is the key a `start` was coalesced by (#3562) — what you\n * passed as `runKey` to make the run a singleton — and null when the\n * start named none, or when the call was an `invoke`, which coalesces\n * nothing.\n */\n | { kind: \"http\"; runKey: string | null }\n /** A verified webhook delivery to the function's own key. */\n | {\n kind: \"webhook\";\n /** The webhook key, which is the function key. */\n webhookKey: string;\n /** The platform's webhook row the delivery log lives under. */\n webhookId: string;\n /** The provider's event id (`X-Webhook-Event-Id`), when it sent one. */\n externalEventId: string | null;\n }\n /** A cron entry firing, scheduled or from the `cron-triggers test` diagnostic. */\n | {\n kind: \"cron\";\n /** The `[[function.triggers.cron]]` entry's `name`. */\n name: string;\n /** The platform's cron row. */\n triggerId: string;\n /** ISO 8601. The instant the fire was scheduled for; a diagnostic fire's is \"now\". */\n scheduledFor: string;\n /** Present, and true, only on the diagnostic fire: nothing was scheduled. */\n manual?: true;\n }\n /**\n * A DSL workflow's `workflow.call` step reached this function (#3288).\n *\n * TRANSITIONAL: the bridge exists so a workflow tree can migrate leaf-first\n * during the transition, and it retires with the workflow engine in phase 7,\n * taking this variant with it. `workflowKey` names the PARENT workflow, and\n * `runId`/`stepId` locate the step inside its run.\n */\n | { kind: \"workflow\"; workflowKey: string; runId: string; stepId: string }\n /**\n * Another function started this one with `ctx.functions.start` (#3280).\n *\n * `functionKey` names the PARENT, and `runId` its run — null when the\n * parent was a request invocation over HTTP, which writes no run row.\n * `runKey` is the key the parent's start named, or null (#3562).\n */\n | {\n kind: \"function\";\n functionKey: string;\n runId: string | null;\n runKey: string | null;\n }\n /**\n * An admin ran this function as the SYSTEM, from outside any trigger\n * (#3448) — `primitive functions invoke --as system`.\n *\n * `ctx.user` is null and the code runs with the app's system authority, as\n * it does for a cron or webhook fire. `userId` names the admin who asked:\n * attribution, never the principal the code runs as. `runKey` is the key\n * the admin's start named, or null (#3562).\n */\n | { kind: \"manual\"; userId: string; runKey: string | null };\n\n/** The result shape of an operation that answers in response headers. */\nexport interface HeaderResult {\n status: number;\n headers: Record<string, string>;\n}\n\n/**\n * A platform call that was refused. `errorCode` carries the gateway's own\n * codes (`FUNCTION_ROUTE_NOT_ALLOWED`, `FUNCTION_EGRESS_DENIED`, …) as well\n * as the route's.\n */\nexport interface PrimitivePlatformError extends Error {\n status: number;\n errorCode: string | null;\n}\n\n/**\n * The typed HTTP profile, generated from the platform's OpenAPI document. Its\n * namespaces mirror the operation ids: analytics, blobBuckets, channels, collections, configVars, connections, databaseTypeConfigs, databases, documents, email, functions, groups, integrations, locks, notifications, prompts, resourceMetadata, secrets, users.\n * Methods take one options object carrying the operation's path parameters,\n * query parameters, request headers (under their wire names) and `body`.\n *\n * Generated from the same operations as the runtime profile, so a method that\n * type-checks is a method the platform publishes — and a missing path\n * parameter or a missing required header is a compile error rather than a\n * `TypeError` at invoke time. Every call runs with the app's own SYSTEM\n * authority (#3279): the invocation gate was the authorization. The two\n * namespaces the gateway does not admit are still declared: they exist, they\n * answer the gateway's structured denial, and hiding them would make a route's\n * availability look like a typo. Those are `databaseTypeConfigs` whole, and\n * `functions` except for `functions.start` — the nested-start door #3280\n * admits by name, which `ctx.functions.start` calls. `functions.invoke`\n * stays refused: same-run composition is an import.\n */\nexport interface FunctionApi {\n \"analytics\": {\n /** `analytics.cohortRetention` — GET /analytics/cohort-retention. Cohort retention metrics */\n \"cohortRetention\"(args?: {\n \"current_timestamp\"?: string | number | boolean;\n \"_bust\"?: string | number | boolean;\n }): Promise<any>;\n /** `analytics.dailyActive` — GET /analytics/daily-active. Daily active user time series */\n \"dailyActive\"(args?: {\n \"windowDays\"?: string | number | boolean;\n \"current_timestamp\"?: string | number | boolean;\n \"_bust\"?: string | number | boolean;\n }): Promise<any>;\n /** `analytics.errorGroups` — GET /analytics/errors/groups. Group failure events by fingerprint with per-day count buckets */\n \"errorGroups\"(args?: {\n \"windowDays\"?: string | number | boolean;\n \"limit\"?: string | number | boolean;\n \"current_timestamp\"?: string | number | boolean;\n \"_bust\"?: string | number | boolean;\n \"filter\"?: Record<string, Record<string, string | number | boolean | Array<string | number | boolean>>>;\n }): Promise<any>;\n /** `analytics.integrationUsage` — GET /analytics/integrations. Integration usage metrics */\n \"integrationUsage\"(args?: {\n \"windowDays\"?: string | number | boolean;\n \"current_timestamp\"?: string | number | boolean;\n \"_bust\"?: string | number | boolean;\n }): Promise<any>;\n /** `analytics.listEvents` — GET /analytics/events. List analytics events */\n \"listEvents\"(args?: {\n \"windowDays\"?: string | number | boolean;\n \"page\"?: string | number | boolean;\n \"current_timestamp\"?: string | number | boolean;\n \"_bust\"?: string | number | boolean;\n \"filter\"?: Record<string, Record<string, string | number | boolean | Array<string | number | boolean>>>;\n }): Promise<any>;\n /** `analytics.listEventsGrouped` — GET /analytics/events/grouped. List analytics events grouped by dimension */\n \"listEventsGrouped\"(args?: {\n \"windowDays\"?: string | number | boolean;\n \"groupBy\"?: string | number | boolean;\n \"current_timestamp\"?: string | number | boolean;\n \"_bust\"?: string | number | boolean;\n \"filter\"?: Record<string, Record<string, string | number | boolean | Array<string | number | boolean>>>;\n }): Promise<any>;\n /** `analytics.overviewDau` — GET /analytics/overview/dau. Daily active users overview */\n \"overviewDau\"(args?: {\n \"current_timestamp\"?: string | number | boolean;\n \"_bust\"?: string | number | boolean;\n }): Promise<any>;\n /** `analytics.overviewGrowth` — GET /analytics/overview/growth. User growth overview */\n \"overviewGrowth\"(args?: {\n \"windowDays\"?: string | number | boolean;\n \"current_timestamp\"?: string | number | boolean;\n \"_bust\"?: string | number | boolean;\n }): Promise<any>;\n /** `analytics.overviewMau` — GET /analytics/overview/mau. Monthly active users overview */\n \"overviewMau\"(args?: {\n \"current_timestamp\"?: string | number | boolean;\n \"_bust\"?: string | number | boolean;\n }): Promise<any>;\n /** `analytics.overviewWau` — GET /analytics/overview/wau. Weekly active users overview */\n \"overviewWau\"(args?: {\n \"current_timestamp\"?: string | number | boolean;\n \"_bust\"?: string | number | boolean;\n }): Promise<any>;\n /** `analytics.rollingActive` — GET /analytics/rolling-active. Rolling active user time series */\n \"rollingActive\"(args?: {\n \"windowDays\"?: string | number | boolean;\n \"current_timestamp\"?: string | number | boolean;\n \"_bust\"?: string | number | boolean;\n }): Promise<any>;\n /** `analytics.searchUsers` — GET /analytics/users/search. Search app users for analytics */\n \"searchUsers\"(args?: {\n \"q\"?: string | number | boolean;\n \"limit\"?: string | number | boolean;\n \"signupDay\"?: string | number | boolean;\n \"signupStartDay\"?: string | number | boolean;\n \"signupEndDay\"?: string | number | boolean;\n \"offset\"?: string | number | boolean;\n \"current_timestamp\"?: string | number | boolean;\n \"_bust\"?: string | number | boolean;\n }): Promise<any>;\n /** `analytics.topPrompts` — GET /analytics/prompts/top. List the most-executed prompts */\n \"topPrompts\"(args?: {\n \"windowDays\"?: string | number | boolean;\n \"limit\"?: string | number | boolean;\n \"current_timestamp\"?: string | number | boolean;\n \"_bust\"?: string | number | boolean;\n }): Promise<any>;\n /** `analytics.topUsers` — GET /analytics/users/top. List the most active users */\n \"topUsers\"(args?: {\n \"windowDays\"?: string | number | boolean;\n \"limit\"?: string | number | boolean;\n \"current_timestamp\"?: string | number | boolean;\n \"_bust\"?: string | number | boolean;\n }): Promise<any>;\n /** `analytics.topWorkflows` — GET /analytics/workflows/top. List the most-run workflows */\n \"topWorkflows\"(args?: {\n \"windowDays\"?: string | number | boolean;\n \"limit\"?: string | number | boolean;\n \"current_timestamp\"?: string | number | boolean;\n \"_bust\"?: string | number | boolean;\n }): Promise<any>;\n /** `analytics.userDetail` — GET /analytics/users/{userUlid}/detail. Detailed analytics for a single user */\n \"userDetail\"(args: {\n \"userUlid\": string | number;\n \"current_timestamp\"?: string | number | boolean;\n \"_bust\"?: string | number | boolean;\n }): Promise<any>;\n /** `analytics.userSnapshot` — GET /analytics/users/{userUlid}/snapshot. Activity snapshot for a single user */\n \"userSnapshot\"(args: {\n \"userUlid\": string | number;\n \"current_timestamp\"?: string | number | boolean;\n \"_bust\"?: string | number | boolean;\n }): Promise<any>;\n /** `analytics.writeForUser` — POST /analytics/write-for-user. Write an analytics event for a subject user under a grant */\n \"writeForUser\"(args: {\n body: unknown;\n }): Promise<any>;\n };\n \"blobBuckets\": {\n /** `blobBuckets.createBucket` — POST /blob-buckets. Create a blob bucket */\n \"createBucket\"(args: {\n body: unknown;\n }): Promise<any>;\n /** `blobBuckets.delete` — DELETE /blob-buckets/{bucketId}/blobs/{blobId}. Delete a blob */\n \"delete\"(args: {\n \"bucketId\": string | number;\n \"blobId\": string | number;\n }): Promise<any>;\n /** `blobBuckets.deleteBatch` — POST /blob-buckets/{bucketId}/blobs/delete. Batch delete blobs from a bucket */\n \"deleteBatch\"(args: {\n \"bucketId\": string | number;\n body: unknown;\n }): Promise<any>;\n /** `blobBuckets.deleteBucket` — DELETE /blob-buckets/{bucketId}. Delete a blob bucket */\n \"deleteBucket\"(args: {\n \"bucketId\": string | number;\n }): Promise<any>;\n /** `blobBuckets.download` — GET /blob-buckets/{bucketId}/blobs/{blobId}. Download a blob (anonymous allowed for public buckets) */\n \"download\"(args: {\n \"bucketId\": string | number;\n \"blobId\": string | number;\n \"disposition\"?: string | number | boolean;\n }): Promise<Uint8Array>;\n /** `blobBuckets.downloadSigned` — GET /blob-buckets/{bucketId}/blobs/{blobId}/signed. Download a blob via a signed URL token */\n \"downloadSigned\"(args: {\n \"bucketId\": string | number;\n \"blobId\": string | number;\n \"token\"?: string | number | boolean;\n }): Promise<Uint8Array>;\n /** `blobBuckets.getBucket` — GET /blob-buckets/{bucketId}. Get a blob bucket by id */\n \"getBucket\"(args: {\n \"bucketId\": string | number;\n }): Promise<any>;\n /** `blobBuckets.getMetadata` — GET /blob-buckets/{bucketId}/blobs/{blobId}/metadata. Get blob metadata (anonymous allowed for public buckets) */\n \"getMetadata\"(args: {\n \"bucketId\": string | number;\n \"blobId\": string | number;\n }): Promise<any>;\n /** `blobBuckets.getSignedUrl` — POST /blob-buckets/{bucketId}/blobs/{blobId}/signed-url. Create a signed download URL for a blob */\n \"getSignedUrl\"(args: {\n \"bucketId\": string | number;\n \"blobId\": string | number;\n body?: unknown;\n }): Promise<any>;\n /** `blobBuckets.list` — GET /blob-buckets/{bucketId}/blobs. List blobs in a bucket (anonymous allowed for public buckets) */\n \"list\"(args: {\n \"bucketId\": string | number;\n \"limit\"?: string | number | boolean;\n \"cursor\"?: string | number | boolean;\n }): Promise<any>;\n /** `blobBuckets.listBuckets` — GET /blob-buckets. List blob buckets */\n \"listBuckets\"(args?: Record<string, never>): Promise<any>;\n /** `blobBuckets.updateBucket` — PATCH /blob-buckets/{bucketId}. Update a blob bucket */\n \"updateBucket\"(args: {\n \"bucketId\": string | number;\n body: unknown;\n }): Promise<any>;\n /** `blobBuckets.upload` — POST /blob-buckets/{bucketId}/blobs. Upload a blob to a bucket */\n \"upload\"(args: {\n \"bucketId\": string | number;\n \"X-Blob-Filename\": string | number;\n \"X-Blob-Tags\"?: string | number;\n \"Content-Type\"?: string | number;\n body: ArrayBuffer | Uint8Array | string;\n }): Promise<any>;\n };\n \"channels\": {\n /** `channels.authorize` — POST /channels/{channel}/grants. Issue a channel grant under a server function's grant */\n \"authorize\"(args: {\n \"channel\": string | number;\n body: unknown;\n }): Promise<any>;\n /** `channels.publish` — POST /channels/{channel}/publish. Publish a message to a channel under a server function's grant */\n \"publish\"(args: {\n \"channel\": string | number;\n body: unknown;\n }): Promise<any>;\n };\n \"collections\": {\n /** `collections.addDocument` — POST /collections/{collectionId}/documents. Add a document to a collection */\n \"addDocument\"(args: {\n \"collectionId\": string | number;\n body: unknown;\n }): Promise<any>;\n /** `collections.addMember` — POST /collections/{collectionId}/members. Add a member to a collection */\n \"addMember\"(args: {\n \"collectionId\": string | number;\n body: unknown;\n }): Promise<any>;\n /** `collections.create` — POST /collections. Create a collection */\n \"create\"(args: {\n body: unknown;\n }): Promise<any>;\n /** `collections.delete` — DELETE /collections/{collectionId}. Delete a collection */\n \"delete\"(args: {\n \"collectionId\": string | number;\n }): Promise<any>;\n /** `collections.get` — GET /collections/{collectionId}. Get a collection by id */\n \"get\"(args: {\n \"collectionId\": string | number;\n }): Promise<any>;\n /** `collections.getAccess` — GET /collections/{collectionId}/access. Get a collection's access summary */\n \"getAccess\"(args: {\n \"collectionId\": string | number;\n }): Promise<any>;\n /** `collections.grantGroupPermission` — POST /collections/{collectionId}/group-permissions. Grant a group permission on a collection */\n \"grantGroupPermission\"(args: {\n \"collectionId\": string | number;\n body: unknown;\n }): Promise<any>;\n /** `collections.list` — GET /collections. List collections */\n \"list\"(args?: {\n \"limit\"?: string | number | boolean;\n \"cursor\"?: string | number | boolean;\n }): Promise<any>;\n /** `collections.listCollectionsForDocument` — GET /documents/{documentId}/collections. List collections a document belongs to (reverse lookup) */\n \"listCollectionsForDocument\"(args: {\n \"documentId\": string | number;\n \"limit\"?: string | number | boolean;\n \"cursor\"?: string | number | boolean;\n }): Promise<any>;\n /** `collections.listDocuments` — GET /collections/{collectionId}/documents. List documents in a collection */\n \"listDocuments\"(args: {\n \"collectionId\": string | number;\n \"limit\"?: string | number | boolean;\n \"cursor\"?: string | number | boolean;\n }): Promise<any>;\n /** `collections.listPendingInvitations` — GET /collections/{collectionId}/pending-invitations. List a collection's pending invitations */\n \"listPendingInvitations\"(args: {\n \"collectionId\": string | number;\n }): Promise<any>;\n /** `collections.removeDocument` — DELETE /collections/{collectionId}/documents/{documentId}. Remove a document from a collection */\n \"removeDocument\"(args: {\n \"collectionId\": string | number;\n \"documentId\": string | number;\n }): Promise<any>;\n /** `collections.removeMember` — DELETE /collections/{collectionId}/members/{userId}. Remove a member from a collection */\n \"removeMember\"(args: {\n \"collectionId\": string | number;\n \"userId\": string | number;\n }): Promise<any>;\n /** `collections.revokeGroupPermission` — DELETE /collections/{collectionId}/group-permissions/{groupType}/{groupId}. Revoke a group permission on a collection */\n \"revokeGroupPermission\"(args: {\n \"collectionId\": string | number;\n \"groupType\": string | number;\n \"groupId\": string | number;\n }): Promise<any>;\n /** `collections.update` — PATCH /collections/{collectionId}. Update a collection */\n \"update\"(args: {\n \"collectionId\": string | number;\n body: unknown;\n }): Promise<any>;\n };\n \"configVars\": {\n /** `configVars.get` — GET /config-vars/{name}. Read an app config var under a server function's grants */\n \"get\"(args: {\n \"name\": string | number;\n }): Promise<any>;\n };\n \"connections\": {\n /** `connections.send` — POST /connections/{connectionId}/send. Send a realtime message to one connection of this app */\n \"send\"(args: {\n \"connectionId\": string | number;\n body: unknown;\n }): Promise<any>;\n };\n \"databaseTypeConfigs\": {\n /** `databaseTypeConfigs.create` — POST /databases/types. Create a database type */\n \"create\"(args: {\n \"dryRun\"?: string | number | boolean;\n body: unknown;\n }): Promise<any>;\n /** `databaseTypeConfigs.createOperation` — POST /databases/types/{databaseType}/operations. Create an operation for a database type */\n \"createOperation\"(args: {\n \"databaseType\": string | number;\n \"dryRun\"?: string | number | boolean;\n body: unknown;\n }): Promise<any>;\n /** `databaseTypeConfigs.delete` — DELETE /databases/types/{databaseType}. Delete a database type */\n \"delete\"(args: {\n \"databaseType\": string | number;\n }): Promise<any>;\n /** `databaseTypeConfigs.deleteOperation` — DELETE /databases/types/{databaseType}/operations/{name}. Delete an operation for a database type */\n \"deleteOperation\"(args: {\n \"databaseType\": string | number;\n \"name\": string | number;\n }): Promise<any>;\n /** `databaseTypeConfigs.get` — GET /databases/types/{databaseType}. Get a database type */\n \"get\"(args: {\n \"databaseType\": string | number;\n }): Promise<any>;\n /** `databaseTypeConfigs.getOperation` — GET /databases/types/{databaseType}/operations/{name}. Get an operation for a database type */\n \"getOperation\"(args: {\n \"databaseType\": string | number;\n \"name\": string | number;\n }): Promise<any>;\n /** `databaseTypeConfigs.getReindexStatus` — GET /databases/types/{databaseType}/reindex-status. Status of the index back-provision fan-out for a type */\n \"getReindexStatus\"(args: {\n \"databaseType\": string | number;\n \"runId\"?: string | number | boolean;\n }): Promise<any>;\n /** `databaseTypeConfigs.list` — GET /databases/types. List database types */\n \"list\"(args?: Record<string, never>): Promise<any>;\n /** `databaseTypeConfigs.listOperations` — GET /databases/types/{databaseType}/operations. List operations for a database type */\n \"listOperations\"(args: {\n \"databaseType\": string | number;\n }): Promise<any>;\n /** `databaseTypeConfigs.scaffoldSchema` — POST /databases/types/{databaseType}/schema:scaffold. Scaffold a starter schema for a database type */\n \"scaffoldSchema\"(args: {\n \"databaseType\": string | number;\n }): Promise<any>;\n \"subscriptions\": {\n /** `databaseTypeConfigs.subscriptions.create` — POST /databases/types/{databaseType}/subscriptions. Create a subscription for a database type */\n \"create\"(args: {\n \"databaseType\": string | number;\n body: unknown;\n }): Promise<any>;\n /** `databaseTypeConfigs.subscriptions.delete` — DELETE /databases/types/{databaseType}/subscriptions/{subscriptionKey}. Delete a database type subscription */\n \"delete\"(args: {\n \"databaseType\": string | number;\n \"subscriptionKey\": string | number;\n }): Promise<any>;\n /** `databaseTypeConfigs.subscriptions.get` — GET /databases/types/{databaseType}/subscriptions/{subscriptionKey}. Get a database type subscription */\n \"get\"(args: {\n \"databaseType\": string | number;\n \"subscriptionKey\": string | number;\n }): Promise<any>;\n /** `databaseTypeConfigs.subscriptions.list` — GET /databases/types/{databaseType}/subscriptions. List subscriptions for a database type */\n \"list\"(args: {\n \"databaseType\": string | number;\n }): Promise<any>;\n /** `databaseTypeConfigs.subscriptions.update` — PUT /databases/types/{databaseType}/subscriptions/{subscriptionKey}. Update a database type subscription */\n \"update\"(args: {\n \"databaseType\": string | number;\n \"subscriptionKey\": string | number;\n body: unknown;\n }): Promise<any>;\n };\n /** `databaseTypeConfigs.update` — PATCH /databases/types/{databaseType}. Update a database type */\n \"update\"(args: {\n \"databaseType\": string | number;\n \"dryRun\"?: string | number | boolean;\n body: unknown;\n }): Promise<any>;\n /** `databaseTypeConfigs.updateOperation` — PATCH /databases/types/{databaseType}/operations/{name}. Update an operation for a database type */\n \"updateOperation\"(args: {\n \"databaseType\": string | number;\n \"name\": string | number;\n \"dryRun\"?: string | number | boolean;\n body: unknown;\n }): Promise<any>;\n };\n \"databases\": {\n /** `databases.addManager` — PUT /databases/{databaseId}/permissions. Set a user's database permission */\n \"addManager\"(args: {\n \"databaseId\": string | number;\n body: unknown;\n }): Promise<any>;\n \"adminData\": {\n /**\n * `databases.adminData.batch` — POST /databases/{databaseId}/admin-data/batch. DEPRECATED — direct database batch; use databases/{databaseId}/records/batch\n * @deprecated Use databases/{databaseId}/records/batch\n */\n \"batch\"(args: {\n \"databaseId\": string | number;\n body: unknown;\n }): Promise<any>;\n /**\n * `databases.adminData.count` — POST /databases/{databaseId}/admin-data/count. DEPRECATED — direct database count; use databases/{databaseId}/records/count\n * @deprecated Use databases/{databaseId}/records/count\n */\n \"count\"(args: {\n \"databaseId\": string | number;\n body: unknown;\n }): Promise<any>;\n /**\n * `databases.adminData.delete` — POST /databases/{databaseId}/admin-data/delete. DEPRECATED — direct database delete; use databases/{databaseId}/records/delete\n * @deprecated Use databases/{databaseId}/records/delete\n */\n \"delete\"(args: {\n \"databaseId\": string | number;\n body: unknown;\n }): Promise<any>;\n /**\n * `databases.adminData.patch` — POST /databases/{databaseId}/admin-data/patch. DEPRECATED — direct database patch; use databases/{databaseId}/records/patch\n * @deprecated Use databases/{databaseId}/records/patch\n */\n \"patch\"(args: {\n \"databaseId\": string | number;\n body: unknown;\n }): Promise<any>;\n /**\n * `databases.adminData.query` — POST /databases/{databaseId}/admin-data/query. DEPRECATED — direct database query; use databases/{databaseId}/records/query\n * @deprecated Use databases/{databaseId}/records/query\n */\n \"query\"(args: {\n \"databaseId\": string | number;\n body: unknown;\n }): Promise<any>;\n /**\n * `databases.adminData.save` — POST /databases/{databaseId}/admin-data/save. DEPRECATED — direct database save; use databases/{databaseId}/records/save\n * @deprecated Use databases/{databaseId}/records/save\n */\n \"save\"(args: {\n \"databaseId\": string | number;\n body: unknown;\n }): Promise<any>;\n };\n /** `databases.create` — POST /databases. Create a database */\n \"create\"(args: {\n body: unknown;\n }): Promise<any>;\n /** `databases.delete` — DELETE /databases/{databaseId}. Delete a database */\n \"delete\"(args: {\n \"databaseId\": string | number;\n }): Promise<any>;\n /** `databases.executeBatch` — POST /databases/{databaseId}/operations/{name}/batch. Execute a database operation in batch */\n \"executeBatch\"(args: {\n \"databaseId\": string | number;\n \"name\": string | number;\n body: unknown;\n }): Promise<any>;\n /** `databases.executeOperation` — POST /databases/{databaseId}/operations/{name}/execute. Execute a database operation */\n \"executeOperation\"(args: {\n \"databaseId\": string | number;\n \"name\": string | number;\n \"dryRun\"?: string | number | boolean;\n body?: unknown;\n }): Promise<any>;\n /** `databases.get` — GET /databases/{databaseId}. Get a database by id */\n \"get\"(args: {\n \"databaseId\": string | number;\n }): Promise<any>;\n /**\n * `databases.getMetadata` — GET /databases/{databaseId}/metadata. DEPRECATED — get database metadata; use resource metadata categories (resources/database/:databaseId/metadata/:category)\n * @deprecated Use resource metadata categories (resources/database/:databaseId/metadata/:category)\n */\n \"getMetadata\"(args: {\n \"databaseId\": string | number;\n }): Promise<any>;\n /** `databases.grantGroupPermission` — POST /databases/{databaseId}/group-permissions. Grant a group permission on a database */\n \"grantGroupPermission\"(args: {\n \"databaseId\": string | number;\n body: unknown;\n }): Promise<any>;\n /** `databases.importBulk` — POST /databases/{databaseId}/operations/{name}/import-bulk. Bulk-import records via a database operation */\n \"importBulk\"(args: {\n \"databaseId\": string | number;\n \"name\": string | number;\n body: unknown;\n }): Promise<any>;\n /** `databases.list` — GET /databases. List databases */\n \"list\"(args?: Record<string, never>): Promise<any>;\n /** `databases.listGroupPermissions` — GET /databases/{databaseId}/group-permissions. List a database's group permissions */\n \"listGroupPermissions\"(args: {\n \"databaseId\": string | number;\n }): Promise<any>;\n /** `databases.listOperations` — GET /databases/{databaseId}/operations. List operations runnable on a database */\n \"listOperations\"(args: {\n \"databaseId\": string | number;\n }): Promise<any>;\n /** `databases.listPermissions` — GET /databases/{databaseId}/permissions. List a database's user permissions */\n \"listPermissions\"(args: {\n \"databaseId\": string | number;\n }): Promise<any>;\n \"records\": {\n /** `databases.records.addToSet` — POST /databases/{databaseId}/records/stringset/add. Database records: stringset/add (requires manager-or-higher on the database, or an app-admin/owner role) */\n \"addToSet\"(args: {\n \"databaseId\": string | number;\n body: unknown;\n }): Promise<any>;\n /** `databases.records.aggregate` — POST /databases/{databaseId}/records/aggregate. Database records: aggregate (requires manager-or-higher on the database, or an app-admin/owner role) */\n \"aggregate\"(args: {\n \"databaseId\": string | number;\n body: unknown;\n }): Promise<any>;\n /** `databases.records.batch` — POST /databases/{databaseId}/records/batch. Database records: batch (requires manager-or-higher on the database, or an app-admin/owner role) */\n \"batch\"(args: {\n \"databaseId\": string | number;\n body: unknown;\n }): Promise<any>;\n /** `databases.records.count` — POST /databases/{databaseId}/records/count. Database records: count (requires manager-or-higher on the database, or an app-admin/owner role) */\n \"count\"(args: {\n \"databaseId\": string | number;\n body: unknown;\n }): Promise<any>;\n /** `databases.records.delete` — POST /databases/{databaseId}/records/delete. Database records: delete (requires manager-or-higher on the database, or an app-admin/owner role) */\n \"delete\"(args: {\n \"databaseId\": string | number;\n body: unknown;\n }): Promise<any>;\n /** `databases.records.describe` — GET /databases/{databaseId}/records/describe. Database records: describe (requires manager-or-higher on the database, or an app-admin/owner role) */\n \"describe\"(args: {\n \"databaseId\": string | number;\n \"modelName\"?: string | number | boolean;\n }): Promise<any>;\n /** `databases.records.dropIndex` — POST /databases/{databaseId}/records/index/drop. Database records: index/drop (requires manager-or-higher on the database, or an app-admin/owner role) */\n \"dropIndex\"(args: {\n \"databaseId\": string | number;\n body: unknown;\n }): Promise<any>;\n /** `databases.records.dropUniqueConstraint` — POST /databases/{databaseId}/records/unique-constraint/drop. Database records: unique-constraint/drop (requires manager-or-higher on the database, or an app-admin/owner role) */\n \"dropUniqueConstraint\"(args: {\n \"databaseId\": string | number;\n body: unknown;\n }): Promise<any>;\n /** `databases.records.increment` — POST /databases/{databaseId}/records/increment. Database records: increment (requires manager-or-higher on the database, or an app-admin/owner role) */\n \"increment\"(args: {\n \"databaseId\": string | number;\n body: unknown;\n }): Promise<any>;\n /** `databases.records.listIndexes` — GET /databases/{databaseId}/records/indexes. Database records: indexes (requires manager-or-higher on the database, or an app-admin/owner role) */\n \"listIndexes\"(args: {\n \"databaseId\": string | number;\n \"modelName\"?: string | number | boolean;\n }): Promise<any>;\n /** `databases.records.listUniqueConstraints` — GET /databases/{databaseId}/records/unique-constraints. Database records: unique-constraints (requires manager-or-higher on the database, or an app-admin/owner role) */\n \"listUniqueConstraints\"(args: {\n \"databaseId\": string | number;\n \"modelName\"?: string | number | boolean;\n }): Promise<any>;\n /** `databases.records.models` — GET /databases/{databaseId}/records/models. Database records: models (requires manager-or-higher on the database, or an app-admin/owner role) */\n \"models\"(args: {\n \"databaseId\": string | number;\n \"modelName\"?: string | number | boolean;\n }): Promise<any>;\n /** `databases.records.patch` — POST /databases/{databaseId}/records/patch. Database records: patch (requires manager-or-higher on the database, or an app-admin/owner role) */\n \"patch\"(args: {\n \"databaseId\": string | number;\n body: unknown;\n }): Promise<any>;\n /** `databases.records.query` — POST /databases/{databaseId}/records/query. Database records: query (requires manager-or-higher on the database, or an app-admin/owner role) */\n \"query\"(args: {\n \"databaseId\": string | number;\n body: unknown;\n }): Promise<{ items: any[]; hasMore: boolean; nextCursor?: string; prevCursor?: string }>;\n /** `databases.records.registerIndex` — POST /databases/{databaseId}/records/index/register. Database records: index/register (requires manager-or-higher on the database, or an app-admin/owner role) */\n \"registerIndex\"(args: {\n \"databaseId\": string | number;\n body: unknown;\n }): Promise<any>;\n /** `databases.records.registerUniqueConstraint` — POST /databases/{databaseId}/records/unique-constraint/register. Database records: unique-constraint/register (requires manager-or-higher on the database, or an app-admin/owner role) */\n \"registerUniqueConstraint\"(args: {\n \"databaseId\": string | number;\n body: unknown;\n }): Promise<any>;\n /** `databases.records.removeFromSet` — POST /databases/{databaseId}/records/stringset/remove. Database records: stringset/remove (requires manager-or-higher on the database, or an app-admin/owner role) */\n \"removeFromSet\"(args: {\n \"databaseId\": string | number;\n body: unknown;\n }): Promise<any>;\n /** `databases.records.save` — POST /databases/{databaseId}/records/save. Database records: save (requires manager-or-higher on the database, or an app-admin/owner role) */\n \"save\"(args: {\n \"databaseId\": string | number;\n body: unknown;\n }): Promise<any>;\n /** `databases.records.syncIndexes` — POST /databases/{databaseId}/records/indexes/sync. Database records: indexes/sync (requires manager-or-higher on the database, or an app-admin/owner role) */\n \"syncIndexes\"(args: {\n \"databaseId\": string | number;\n body: unknown;\n }): Promise<any>;\n };\n /** `databases.reindex` — POST /databases/{databaseId}/reindex. Reindex a database */\n \"reindex\"(args: {\n \"databaseId\": string | number;\n }): Promise<any>;\n /** `databases.revokeGroupPermission` — DELETE /databases/{databaseId}/group-permissions/{groupType}/{groupId}. Revoke a group permission on a database */\n \"revokeGroupPermission\"(args: {\n \"databaseId\": string | number;\n \"groupType\": string | number;\n \"groupId\": string | number;\n }): Promise<any>;\n /** `databases.revokePermission` — DELETE /databases/{databaseId}/permissions/{userId}. Remove a user's database permission */\n \"revokePermission\"(args: {\n \"databaseId\": string | number;\n \"userId\": string | number;\n }): Promise<any>;\n /** `databases.runOperation` — POST /databases/{databaseId}/operations/{name}/run. Run a database operation under a server function's grants */\n \"runOperation\"(args: {\n \"databaseId\": string | number;\n \"name\": string | number;\n body?: unknown;\n }): Promise<any>;\n /** `databases.transferOwnership` — POST /databases/{databaseId}/permissions/transfer. Transfer database ownership */\n \"transferOwnership\"(args: {\n \"databaseId\": string | number;\n body: unknown;\n }): Promise<any>;\n /** `databases.update` — PATCH /databases/{databaseId}. Update a database */\n \"update\"(args: {\n \"databaseId\": string | number;\n body: unknown;\n }): Promise<any>;\n /**\n * `databases.updateMetadata` — PATCH /databases/{databaseId}/metadata. DEPRECATED — update database metadata; use resource metadata categories (resources/database/:databaseId/metadata/:category)\n * @deprecated Use resource metadata categories (resources/database/:databaseId/metadata/:category)\n */\n \"updateMetadata\"(args: {\n \"databaseId\": string | number;\n body: unknown;\n }): Promise<any>;\n };\n \"documents\": {\n /** `documents.abortIngest` — POST /documents/{documentId}/ingest/{sessionId}/abort. Abort a bulk-load session before its swap */\n \"abortIngest\"(args: {\n \"documentId\": string | number;\n \"sessionId\": string | number;\n body: unknown;\n }): Promise<any>;\n /** `documents.addTag` — POST /documents/{documentId}/tags. Add a tag to a document */\n \"addTag\"(args: {\n \"documentId\": string | number;\n body: unknown;\n }): Promise<any>;\n \"aliases\": {\n /** `documents.aliases.delete` — DELETE /document-aliases/{scope}/{aliasKey}. Delete a (scope, aliasKey) document alias binding */\n \"delete\"(args: {\n \"scope\": string | number;\n \"aliasKey\": string | number;\n \"userId\"?: string | number | boolean;\n }): Promise<any>;\n /** `documents.aliases.listForDocument` — GET /documents/{documentId}/aliases. List aliases bound to a document */\n \"listForDocument\"(args: {\n \"documentId\": string | number;\n }): Promise<any>;\n /** `documents.aliases.resolve` — GET /document-aliases/{scope}/{aliasKey}. Resolve the document bound to a (scope, aliasKey) alias */\n \"resolve\"(args: {\n \"scope\": string | number;\n \"aliasKey\": string | number;\n \"userId\"?: string | number | boolean;\n }): Promise<any>;\n /** `documents.aliases.set` — PUT /document-aliases/{scope}/{aliasKey}. Bind a (scope, aliasKey) alias to a document */\n \"set\"(args: {\n \"scope\": string | number;\n \"aliasKey\": string | number;\n body: unknown;\n }): Promise<any>;\n };\n /** `documents.approveAccessRequest` — POST /documents/{documentId}/access-requests/{requestId}/approve. Approve a document access request */\n \"approveAccessRequest\"(args: {\n \"documentId\": string | number;\n \"requestId\": string | number;\n body?: unknown;\n }): Promise<any>;\n \"blobs\": {\n /** `documents.blobs.delete` — DELETE /documents/{documentId}/blobs/{blobId}. Delete a document blob */\n \"delete\"(args: {\n \"documentId\": string | number;\n \"blobId\": string | number;\n }): Promise<any>;\n /** `documents.blobs.downloadHeaders` — HEAD /documents/{documentId}/blobs/{blobId}/download. Get document blob download headers (ETag/304 support) */\n \"downloadHeaders\"(args: {\n \"documentId\": string | number;\n \"blobId\": string | number;\n }): Promise<HeaderResult>;\n /** `documents.blobs.downloadUrl` — GET /documents/{documentId}/blobs/{blobId}/download. Download a document blob's bytes */\n \"downloadUrl\"(args: {\n \"documentId\": string | number;\n \"blobId\": string | number;\n \"disposition\"?: string | number | boolean;\n }): Promise<Uint8Array>;\n /** `documents.blobs.get` — GET /documents/{documentId}/blobs/{blobId}. Get a document blob's metadata */\n \"get\"(args: {\n \"documentId\": string | number;\n \"blobId\": string | number;\n }): Promise<any>;\n /** `documents.blobs.list` — GET /documents/{documentId}/blobs. List blobs attached to a document */\n \"list\"(args: {\n \"documentId\": string | number;\n }): Promise<any>;\n /** `documents.blobs.upload` — PUT /documents/{documentId}/blobs/{blobId}. Upload a document blob with a client-specified id (immutable + idempotent) */\n \"upload\"(args: {\n \"documentId\": string | number;\n \"blobId\": string | number;\n \"X-Blob-Filename\": string | number;\n \"X-Blob-Size\": string | number;\n \"X-Blob-Sha256\": string | number;\n body: ArrayBuffer | Uint8Array | string;\n }): Promise<any>;\n /**\n * `documents.blobs.uploadWithoutId` — PUT /documents/{documentId}/blobs. Deprecated: upload a document blob without a client-specified id\n * @deprecated Deprecated in the app API spec; see its description.\n */\n \"uploadWithoutId\"(args: {\n \"documentId\": string | number;\n }): Promise<any>;\n };\n /** `documents.clearLinkAccess` — DELETE /documents/{documentId}/link-access. Turn off the document's link access */\n \"clearLinkAccess\"(args: {\n \"documentId\": string | number;\n }): Promise<any>;\n /** `documents.commitIngest` — POST /documents/{documentId}/ingest/{sessionId}/commit. Commit a bulk-load session: freeze its manifest and apply it */\n \"commitIngest\"(args: {\n \"documentId\": string | number;\n \"sessionId\": string | number;\n body: unknown;\n }): Promise<any>;\n /** `documents.create` — POST /documents. Create a new document */\n \"create\"(args: {\n body: unknown;\n }): Promise<any>;\n /** `documents.createIngest` — POST /documents/{documentId}/ingest. Open a bulk-load session on a large document */\n \"createIngest\"(args: {\n \"documentId\": string | number;\n body: unknown;\n }): Promise<any>;\n /** `documents.createWithAlias` — POST /documents/create-with-alias. Create a document and bind it to an alias */\n \"createWithAlias\"(args: {\n body: unknown;\n }): Promise<any>;\n /** `documents.debugDumpUpdates` — POST /documents/{documentId}/debug/dump-updates. Dump a document's raw CRDT update log (debug) */\n \"debugDumpUpdates\"(args: {\n \"documentId\": string | number;\n \"limit\"?: string | number | boolean;\n \"offset\"?: string | number | boolean;\n \"includeData\"?: string | number | boolean;\n \"includeR2Data\"?: string | number | boolean;\n body?: unknown;\n }): Promise<any>;\n /** `documents.debugMerge` — POST /documents/{documentId}/debug/merge. Force-merge a document's pending updates (debug) */\n \"debugMerge\"(args: {\n \"documentId\": string | number;\n body?: unknown;\n }): Promise<any>;\n /** `documents.debugMergeBlock` — POST /documents/{documentId}/debug/merge-block. Merge a specific update block of a document (debug) */\n \"debugMergeBlock\"(args: {\n \"documentId\": string | number;\n body?: unknown;\n }): Promise<any>;\n /** `documents.debugRestore` — POST /documents/debug/restore. Restore a document from a prior state snapshot (debug) */\n \"debugRestore\"(args: {\n body: unknown;\n }): Promise<any>;\n /** `documents.debugStats` — GET /documents/{documentId}/debug/stats. Get document storage/update stats (debug) */\n \"debugStats\"(args: {\n \"documentId\": string | number;\n }): Promise<any>;\n /** `documents.delete` — DELETE /documents/{documentId}. Delete a document */\n \"delete\"(args: {\n \"documentId\": string | number;\n }): Promise<any>;\n /** `documents.denyAccessRequest` — POST /documents/{documentId}/access-requests/{requestId}/deny. Deny a document access request */\n \"denyAccessRequest\"(args: {\n \"documentId\": string | number;\n \"requestId\": string | number;\n body?: unknown;\n }): Promise<any>;\n /** `documents.exportChain` — GET /documents/{documentId}/export/chain. Export chain of a large document (snapshot + sealed overlays + open epoch) */\n \"exportChain\"(args: {\n \"documentId\": string | number;\n }): Promise<any>;\n /** `documents.exportState` — GET /documents/{documentId}/export/state. Export a document's encoded CRDT state */\n \"exportState\"(args: {\n \"documentId\": string | number;\n }): Promise<any>;\n /** `documents.get` — GET /documents/{documentId}. Get a single document by id */\n \"get\"(args: {\n \"documentId\": string | number;\n }): Promise<any>;\n /** `documents.getImportChainStatus` — GET /documents/{documentId}/import/chain. How far a large document's chain import has got */\n \"getImportChainStatus\"(args: {\n \"documentId\": string | number;\n }): Promise<any>;\n /** `documents.getIngest` — GET /documents/{documentId}/ingest/{sessionId}. One bulk-load session's status */\n \"getIngest\"(args: {\n \"documentId\": string | number;\n \"sessionId\": string | number;\n }): Promise<any>;\n /** `documents.getLinkAccess` — GET /documents/{documentId}/link-access. Get the document's \"anyone with the link\" access level */\n \"getLinkAccess\"(args: {\n \"documentId\": string | number;\n }): Promise<any>;\n /** `documents.getOrCreateWithAlias` — POST /documents/get-or-create-with-alias. Get the document bound to an alias, creating it if absent (idempotent) */\n \"getOrCreateWithAlias\"(args: {\n body: unknown;\n }): Promise<any>;\n /** `documents.getPermissions` — GET /documents/{documentId}/permissions. List a document's user permissions */\n \"getPermissions\"(args: {\n \"documentId\": string | number;\n }): Promise<any>;\n /** `documents.getSchema` — GET /documents/{documentId}/schema. Introspect a document's model schema */\n \"getSchema\"(args: {\n \"documentId\": string | number;\n }): Promise<any>;\n /** `documents.getSnapshot` — GET /documents/{documentId}/snapshots/{buildId}. One snapshot build with its verification result */\n \"getSnapshot\"(args: {\n \"documentId\": string | number;\n \"buildId\": string | number;\n }): Promise<any>;\n /** `documents.getStats` — GET /documents/{documentId}/stats. Document statistics (record/model/blob counts, approximate size) */\n \"getStats\"(args: {\n \"documentId\": string | number;\n }): Promise<any>;\n /** `documents.grantGroupPermission` — POST /documents/{documentId}/group-permissions. Grant a group permission on a document */\n \"grantGroupPermission\"(args: {\n \"documentId\": string | number;\n body: unknown;\n }): Promise<any>;\n /** `documents.importChain` — POST /documents/{documentId}/import/chain. Install an uploaded chain into a large document */\n \"importChain\"(args: {\n \"documentId\": string | number;\n body: unknown;\n }): Promise<any>;\n /** `documents.importChainArtifact` — POST /documents/{documentId}/import/chain/artifact. Upload one artifact of a large document's import chain */\n \"importChainArtifact\"(args: {\n \"documentId\": string | number;\n \"kind\"?: string | number | boolean;\n \"epoch\"?: string | number | boolean;\n \"buildId\"?: string | number | boolean;\n \"model\"?: string | number | boolean;\n \"index\"?: string | number | boolean;\n body: ArrayBuffer | Uint8Array | string;\n }): Promise<any>;\n /** `documents.importState` — POST /documents/{documentId}/import/state. Import encoded CRDT state into a document */\n \"importState\"(args: {\n \"documentId\": string | number;\n body: unknown;\n }): Promise<any>;\n /** `documents.listAccessRequests` — GET /documents/{documentId}/access-requests. List access requests for a document */\n \"listAccessRequests\"(args: {\n \"documentId\": string | number;\n }): Promise<any>;\n /** `documents.listGroupPermissions` — GET /documents/{documentId}/group-permissions. List a document's group permissions */\n \"listGroupPermissions\"(args: {\n \"documentId\": string | number;\n }): Promise<any>;\n /** `documents.listIngests` — GET /documents/{documentId}/ingest. List a large document's bulk-load sessions, newest first */\n \"listIngests\"(args: {\n \"documentId\": string | number;\n \"limit\"?: string | number | boolean;\n \"cursor\"?: string | number | boolean;\n }): Promise<any>;\n /** `documents.listPendingInvitations` — GET /documents/{documentId}/pending-invitations. List a document's pending (deferred) invitations */\n \"listPendingInvitations\"(args: {\n \"documentId\": string | number;\n }): Promise<any>;\n /** `documents.listSnapshots` — GET /documents/{documentId}/snapshots. List a large document's snapshot builds, newest first */\n \"listSnapshots\"(args: {\n \"documentId\": string | number;\n \"limit\"?: string | number | boolean;\n \"cursor\"?: string | number | boolean;\n }): Promise<any>;\n /** `documents.open` — POST /documents/open. Open a document for collaboration (resolves access + alias) */\n \"open\"(args: {\n body: unknown;\n }): Promise<any>;\n \"records\": {\n /** `documents.records.aggregate` — POST /documents/{documentId}/records/{model}/aggregate. Aggregate records in a document model (count/sum/avg/min/max, optional grouping) */\n \"aggregate\"(args: {\n \"documentId\": string | number;\n \"model\": string | number;\n \"documentFormat\"?: string | number | boolean;\n body: unknown;\n }): Promise<any>;\n /** `documents.records.bulk` — POST /documents/{documentId}/records/bulk. Apply an atomic multi-model record blob to a document (create/patch/delete) */\n \"bulk\"(args: {\n \"documentId\": string | number;\n \"documentFormat\"?: string | number | boolean;\n body: unknown;\n }): Promise<any>;\n /** `documents.records.count` — GET /documents/{documentId}/records/{model}/count. Count records in a document model */\n \"count\"(args: {\n \"documentId\": string | number;\n \"model\": string | number;\n \"documentFormat\"?: string | number | boolean;\n \"filter\"?: Record<string, unknown> | string;\n }): Promise<any>;\n /** `documents.records.delete` — DELETE /documents/{documentId}/records/{model}/{recordId}. Delete a record from a document model */\n \"delete\"(args: {\n \"documentId\": string | number;\n \"model\": string | number;\n \"recordId\": string | number;\n \"documentFormat\"?: string | number | boolean;\n }): Promise<any>;\n /** `documents.records.patch` — PATCH /documents/{documentId}/records/{model}/{recordId}. Merge fields into an existing record in a document model */\n \"patch\"(args: {\n \"documentId\": string | number;\n \"model\": string | number;\n \"recordId\": string | number;\n \"documentFormat\"?: string | number | boolean;\n body: unknown;\n }): Promise<any>;\n /** `documents.records.query` — GET /documents/{documentId}/records/{model}. Query records in a document model */\n \"query\"(args: {\n \"documentId\": string | number;\n \"model\": string | number;\n \"documentFormat\"?: string | number | boolean;\n \"limit\"?: string | number | boolean;\n \"cursor\"?: string | number | boolean;\n \"filter\"?: Record<string, unknown> | string;\n }): Promise<any>;\n /** `documents.records.save` — POST /documents/{documentId}/records/{model}. Create or replace a record in a document model */\n \"save\"(args: {\n \"documentId\": string | number;\n \"model\": string | number;\n \"documentFormat\"?: string | number | boolean;\n body: unknown;\n }): Promise<any>;\n };\n /** `documents.removePermissionByEmail` — DELETE /documents/{documentId}/permissions. Revoke a user's permission on a document by email (?email=) */\n \"removePermissionByEmail\"(args: {\n \"documentId\": string | number;\n \"email\"?: string | number | boolean;\n }): Promise<any>;\n /** `documents.removePermissionByUserId` — DELETE /documents/{documentId}/permissions/{userId}. Revoke a user's permission on a document by user id */\n \"removePermissionByUserId\"(args: {\n \"documentId\": string | number;\n \"userId\": string | number;\n }): Promise<any>;\n /** `documents.removeTag` — DELETE /documents/{documentId}/tags/{tag}. Remove a tag from a document */\n \"removeTag\"(args: {\n \"documentId\": string | number;\n \"tag\": string | number;\n }): Promise<any>;\n /** `documents.requestAccess` — POST /documents/{documentId}/access-requests. Request access to a document */\n \"requestAccess\"(args: {\n \"documentId\": string | number;\n body: unknown;\n }): Promise<any>;\n /** `documents.requestSnapshot` — POST /documents/{documentId}/snapshots. Snapshot a large document now: seal the open epoch and build a base */\n \"requestSnapshot\"(args: {\n \"documentId\": string | number;\n body: unknown;\n }): Promise<any>;\n /** `documents.revokeGroupPermission` — DELETE /documents/{documentId}/group-permissions/{groupType}/{groupId}. Revoke a group permission on a document */\n \"revokeGroupPermission\"(args: {\n \"documentId\": string | number;\n \"groupType\": string | number;\n \"groupId\": string | number;\n }): Promise<any>;\n /** `documents.setLinkAccess` — PUT /documents/{documentId}/link-access. Set the document's \"anyone with the link\" access level */\n \"setLinkAccess\"(args: {\n \"documentId\": string | number;\n body: unknown;\n }): Promise<any>;\n /** `documents.transferOwnership` — POST /documents/{documentId}/permissions/transfer. Transfer ownership of a document to another user */\n \"transferOwnership\"(args: {\n \"documentId\": string | number;\n body: unknown;\n }): Promise<any>;\n /** `documents.update` — PUT /documents/{documentId}. Update a document's metadata */\n \"update\"(args: {\n \"documentId\": string | number;\n body: unknown;\n }): Promise<any>;\n /** `documents.updatePermissions` — PUT /documents/{documentId}/permissions. Grant or update a user's permission on a document */\n \"updatePermissions\"(args: {\n \"documentId\": string | number;\n body: unknown;\n }): Promise<any>;\n /** `documents.uploadIngestChunk` — POST /documents/{documentId}/ingest/{sessionId}/chunks. Upload one chunk of a bulk-load session's artifact */\n \"uploadIngestChunk\"(args: {\n \"documentId\": string | number;\n \"sessionId\": string | number;\n body: FormData | ArrayBuffer | Uint8Array | string;\n }): Promise<any>;\n /** `documents.validateAccess` — POST /documents/{documentId}/validate-access. Resolve effective access to a document, for the caller or a named user */\n \"validateAccess\"(args: {\n \"documentId\": string | number;\n body?: unknown;\n }): Promise<any>;\n };\n \"email\": {\n /** `email.send` — POST /emails/send. Send an application email under a server function's grant */\n \"send\"(args: {\n body: unknown;\n }): Promise<any>;\n };\n \"functions\": {\n /** `functions.invoke` — POST /functions/{functionKey}. Invoke a server function: a request function returns its result, a task function starts a run */\n \"invoke\"(args: {\n \"functionKey\": string | number;\n body?: unknown;\n }): Promise<any>;\n /** `functions.invokeAsSystem` — POST /functions/{functionKey}/invoke-as-system. Invoke a server function as the system, with no caller */\n \"invokeAsSystem\"(args: {\n \"functionKey\": string | number;\n body?: unknown;\n }): Promise<any>;\n /** `functions.logs` — GET /functions/{functionKey}/logs. List a server function's invocation logs, newest first */\n \"logs\"(args: {\n \"functionKey\": string | number;\n \"limit\"?: string | number | boolean;\n \"cursor\"?: string | number | boolean;\n \"runId\"?: string | number | boolean;\n }): Promise<any>;\n /** `functions.start` — POST /functions/{functionKey}/start. Start a server function as a task run */\n \"start\"(args: {\n \"functionKey\": string | number;\n body?: unknown;\n }): Promise<any>;\n };\n \"groups\": {\n /** `groups.addMember` — POST /groups/{groupType}/{groupId}/members. Add a member to a group */\n \"addMember\"(args: {\n \"groupType\": string | number;\n \"groupId\": string | number;\n body: unknown;\n }): Promise<any>;\n /** `groups.create` — POST /groups. Create a group */\n \"create\"(args: {\n body: unknown;\n }): Promise<any>;\n /** `groups.delete` — DELETE /groups/{groupType}/{groupId}. Delete a group */\n \"delete\"(args: {\n \"groupType\": string | number;\n \"groupId\": string | number;\n }): Promise<any>;\n /** `groups.get` — GET /groups/{groupType}/{groupId}. Get a group by type and id */\n \"get\"(args: {\n \"groupType\": string | number;\n \"groupId\": string | number;\n }): Promise<any>;\n /** `groups.list` — GET /groups. List groups */\n \"list\"(args?: {\n \"type\"?: string | number | boolean;\n \"includeSystem\"?: string | number | boolean;\n \"limit\"?: string | number | boolean;\n \"cursor\"?: string | number | boolean;\n }): Promise<any>;\n /** `groups.listDatabases` — GET /groups/{groupType}/{groupId}/databases. List databases shared with a group */\n \"listDatabases\"(args: {\n \"groupType\": string | number;\n \"groupId\": string | number;\n }): Promise<any>;\n /** `groups.listDocuments` — GET /groups/{groupType}/{groupId}/documents. List documents shared with a group */\n \"listDocuments\"(args: {\n \"groupType\": string | number;\n \"groupId\": string | number;\n }): Promise<any>;\n /** `groups.listMembers` — GET /groups/{groupType}/{groupId}/members. List a group's members */\n \"listMembers\"(args: {\n \"groupType\": string | number;\n \"groupId\": string | number;\n \"limit\"?: string | number | boolean;\n \"cursor\"?: string | number | boolean;\n \"include\"?: string | number | boolean;\n }): Promise<any>;\n /** `groups.listPendingInvitations` — GET /groups/{groupType}/{groupId}/pending-invitations. List a group's pending invitations */\n \"listPendingInvitations\"(args: {\n \"groupType\": string | number;\n \"groupId\": string | number;\n }): Promise<any>;\n /** `groups.listUserMemberships` — GET /users/{userId}/memberships. List a user's group memberships */\n \"listUserMemberships\"(args: {\n \"userId\": string | number;\n \"includeSystem\"?: string | number | boolean;\n \"type\"?: string | number | boolean;\n }): Promise<any>;\n /** `groups.removeMember` — DELETE /groups/{groupType}/{groupId}/members/{userId}. Remove a specific member from a group */\n \"removeMember\"(args: {\n \"groupType\": string | number;\n \"groupId\": string | number;\n \"userId\": string | number;\n }): Promise<any>;\n /** `groups.removeMemberByEmail` — DELETE /groups/{groupType}/{groupId}/members. Remove a group member or pending invitation by email */\n \"removeMemberByEmail\"(args: {\n \"groupType\": string | number;\n \"groupId\": string | number;\n \"email\"?: string | number | boolean;\n }): Promise<any>;\n /** `groups.update` — PATCH /groups/{groupType}/{groupId}. Update a group */\n \"update\"(args: {\n \"groupType\": string | number;\n \"groupId\": string | number;\n body: unknown;\n }): Promise<any>;\n };\n \"integrations\": {\n /** `integrations.call` — POST /integrations/{integrationKey}/call. Call an integration under a server function's grants */\n \"call\"(args: {\n \"integrationKey\": string | number;\n body?: unknown;\n }): Promise<any>;\n /** `integrations.list` — GET /integrations. List integrations configured for the app */\n \"list\"(args?: Record<string, never>): Promise<any>;\n /** `integrations.proxy` — POST /integrations/{integrationKey}/proxy. Proxy a request through a configured integration */\n \"proxy\"(args: {\n \"integrationKey\": string | number;\n }): Promise<any>;\n };\n \"locks\": {\n /** `locks.list` — GET /locks. List all currently-held named locks in the app */\n \"list\"(args?: Record<string, never>): Promise<any>;\n /** `locks.release` — POST /locks/release. Release a held named lock (requires the acquire handle) */\n \"release\"(args: {\n body: unknown;\n }): Promise<any>;\n /** `locks.renew` — POST /locks/renew. Extend the lease on a held named lock */\n \"renew\"(args: {\n body: unknown;\n }): Promise<any>;\n /** `locks.status` — POST /locks/status. Report the current holder of a named lock */\n \"status\"(args: {\n body: unknown;\n }): Promise<any>;\n /** `locks.tryAcquire` — POST /locks/acquire. Attempt to acquire a named lock (single non-blocking attempt) */\n \"tryAcquire\"(args: {\n body: unknown;\n }): Promise<any>;\n };\n \"notifications\": {\n /** `notifications.list` — GET /notifications. List the caller's in-app notification inbox (newest first) */\n \"list\"(args?: {\n \"limit\"?: string | number | boolean;\n \"cursor\"?: string | number | boolean;\n }): Promise<any>;\n /** `notifications.listDevices` — GET /me/push-tokens. List the caller's registered push devices */\n \"listDevices\"(args?: Record<string, never>): Promise<any>;\n /** `notifications.markAllRead` — POST /notifications/read-all. Mark all of the caller's notifications as read */\n \"markAllRead\"(args?: Record<string, never>): Promise<any>;\n /** `notifications.markRead` — PATCH /notifications/{notificationId}/read. Mark one of the caller's notifications as read */\n \"markRead\"(args: {\n \"notificationId\": string | number;\n }): Promise<any>;\n /** `notifications.registerDevice` — POST /me/push-tokens. Register (upsert) the caller's device push token */\n \"registerDevice\"(args: {\n body: unknown;\n }): Promise<any>;\n /** `notifications.send` — POST /notifications/send. Send a notification to an app user (durable in-app inbox row + live WS frame) */\n \"send\"(args: {\n body: unknown;\n }): Promise<any>;\n /** `notifications.unreadCount` — GET /notifications/unread-count. Count the caller's unread notifications */\n \"unreadCount\"(args?: Record<string, never>): Promise<any>;\n /** `notifications.unregisterDevice` — DELETE /me/push-tokens/{token}. Unregister one of the caller's device push tokens */\n \"unregisterDevice\"(args: {\n \"token\": string | number;\n }): Promise<any>;\n };\n \"prompts\": {\n /** `prompts.execute` — POST /prompts/{promptKey}/execute. Execute a saved prompt */\n \"execute\"(args: {\n \"promptKey\": string | number;\n }): Promise<any>;\n /** `prompts.run` — POST /prompts/{promptKey}/run. Run a prompt under a server function's grants */\n \"run\"(args: {\n \"promptKey\": string | number;\n body?: unknown;\n }): Promise<any>;\n };\n \"resourceMetadata\": {\n /** `resourceMetadata.delete` — DELETE /resources/{resourceType}/{resourceId}/metadata/{category}. Delete a resource's metadata for a category (idempotent) */\n \"delete\"(args: {\n \"resourceType\": string | number;\n \"resourceId\": string | number;\n \"category\": string | number;\n }): Promise<any>;\n /** `resourceMetadata.get` — GET /resources/{resourceType}/{resourceId}/metadata/{category}. Read a resource's metadata for a category */\n \"get\"(args: {\n \"resourceType\": string | number;\n \"resourceId\": string | number;\n \"category\": string | number;\n }): Promise<any>;\n /** `resourceMetadata.getBatch` — POST /resources/metadata/batch. Batch-read resource metadata (partial success) */\n \"getBatch\"(args: {\n \"debug\"?: string | number | boolean;\n body: unknown;\n }): Promise<any>;\n /** `resourceMetadata.list` — GET /resources/{resourceType}/{resourceId}/metadata. List all metadata categories on a resource */\n \"list\"(args: {\n \"resourceType\": string | number;\n \"resourceId\": string | number;\n }): Promise<any>;\n /** `resourceMetadata.resolve` — POST /metadata/resolve. Resolve a resource by a category's unique metadata value */\n \"resolve\"(args: {\n body: unknown;\n }): Promise<any>;\n /** `resourceMetadata.set` — PUT /resources/{resourceType}/{resourceId}/metadata/{category}. Write a resource's metadata for a category */\n \"set\"(args: {\n \"resourceType\": string | number;\n \"resourceId\": string | number;\n \"category\": string | number;\n body: unknown;\n }): Promise<any>;\n };\n \"secrets\": {\n /** `secrets.get` — GET /secrets/{name}. Read an app secret under a server function's grants */\n \"get\"(args: {\n \"name\": string | number;\n }): Promise<any>;\n };\n \"users\": {\n /** `users.getBasic` — GET /users/{userId}/basic. Get a user's basic public profile */\n \"getBasic\"(args: {\n \"userId\": string | number;\n }): Promise<any>;\n /** `users.getProfiles` — POST /users/profiles. Look up user profiles in bulk */\n \"getProfiles\"(args: {\n body: unknown;\n }): Promise<any>;\n /** `users.getRootDocument` — GET /users/{userId}/root-document. Get an app user's root document id */\n \"getRootDocument\"(args: {\n \"userId\": string | number;\n }): Promise<any>;\n /** `users.list` — GET /users. List app users */\n \"list\"(args?: {\n \"email\"?: string | number | boolean;\n \"userId\"?: string | number | boolean;\n \"name\"?: string | number | boolean;\n \"limit\"?: string | number | boolean;\n \"cursor\"?: string | number | boolean;\n }): Promise<any>;\n /** `users.lookup` — GET /users/lookup. Look up a user by identifier */\n \"lookup\"(args?: {\n \"email\"?: string | number | boolean;\n }): Promise<any>;\n /**\n * `users.remove` — DELETE /users/{userId}. DEPRECATED — remove a user from the app; use the admin API's PUT apps/:appId/users/:userId/disable (`primitive users disable`)\n * @deprecated Use the admin API's PUT apps/:appId/users/:userId/disable (`primitive users disable`)\n */\n \"remove\"(args: {\n \"userId\": string | number;\n }): Promise<any>;\n /** `users.send` — POST /users/{userId}/send. Send a realtime message to a member of this app */\n \"send\"(args: {\n \"userId\": string | number;\n body: unknown;\n }): Promise<any>;\n /** `users.setRole` — PUT /users/{userId}/role. Set a user's app role */\n \"setRole\"(args: {\n \"userId\": string | number;\n body: unknown;\n }): Promise<any>;\n };\n}\n\n/**\n * The app's database types, model by model — EMPTY here and filled by the\n * declaration `primitive config push` writes into the config tree's\n * `functions/` directory (#3182). A tree that has pushed once therefore types\n * `ctx.db` against its own schemas; one that has not gets the open form and\n * still compiles.\n */\nexport interface DatabaseSchemas {}\n\n/**\n * The type keys `ctx.db` accepts.\n *\n * Every key the augmentation declares, and NOTHING else, once a tree has\n * pushed: naming a type the app does not have is a compile error. Before that\n * — an unaugmented tree, a function written before the first push —\n * `DatabaseSchemas` is empty and `keyof` it is `never`, which would make the\n * argument unwritable rather than open. So the empty case widens to `string`\n * and the handle is untyped instead of unusable.\n */\nexport type DatabaseTypeKeys = [keyof DatabaseSchemas] extends [never]\n ? string\n : keyof DatabaseSchemas & string;\n\n/** A model's row shape, or an open record for a type with no schema. */\nexport type DatabaseModels<K extends string> = K extends keyof DatabaseSchemas\n ? DatabaseSchemas[K]\n : Record<string, Record<string, unknown>>;\n\n/**\n * The app's functions, key by key — EMPTY here and filled by the declaration\n * `primitive config push` writes into the config tree's `functions/`\n * directory (`primitive-function-types.d.ts`): each key's declared input and\n * output types, from its `inputSchema` and `outputSchema`. It is what types\n * `defineFunction(\"<key>\", handler)`.\n */\nexport interface FunctionSchemas {}\n\n/**\n * The keys `defineFunction(key, handler)` accepts: every key the augmentation\n * declares once a tree has pushed, so a key the tree does not declare is a\n * compile error — and `string` before that, the `DatabaseTypeKeys` rule, so an\n * unaugmented tree keeps compiling.\n */\nexport type FunctionKeys = [keyof FunctionSchemas] extends [never]\n ? string\n : keyof FunctionSchemas & string;\n\n/** A declared function's input type, or `any` when nothing is declared. */\nexport type FunctionInput<K extends string> = K extends keyof FunctionSchemas\n ? FunctionSchemas[K] extends { input: infer I }\n ? I\n : any\n : any;\n\n/** A declared function's output type, or `any` when nothing is declared. */\nexport type FunctionOutput<K extends string> = K extends keyof FunctionSchemas\n ? FunctionSchemas[K] extends { output: infer O }\n ? O\n : any\n : any;\n\n/**\n * The model names one database type addresses — its own, or any name at all\n * for a type that declares no schema (the DO is schemaless, so a grant on such\n * a type is legal and there is simply nothing to narrow to).\n */\nexport type DatabaseModelNames<TModels> = [keyof TModels] extends [never]\n ? string\n : keyof TModels & string;\n\n/**\n * A row as the platform HANDS IT BACK: whatever the schema declared, plus the\n * record identity the platform owns (#3450).\n *\n * Every stored record has an `id`. A save that arrives without one is given a\n * ULID, a projection always keeps it, and `delete` and `patch` take nothing\n * else — so a function that queries a model and then moves one of its rows\n * needs the id of the row it just read. A schema is free to say nothing about\n * that field, and most do; the identity is the platform's, not the schema's,\n * so it is added here rather than rendered into each declaration.\n *\n * A declared `id` is REPLACED, never intersected: one declared optional would\n * stay optional on a read row it is always present on, and one declared with\n * some other type would intersect to `never` and be unusable. The platform\n * stamps a string whatever the schema says.\n *\n * An `any` row stays `any` — `DatabaseHandle<any>` is `defineQuery`'s default\n * handle, and turning its rows into an object with one known member would\n * narrow code that was deliberately left open.\n *\n * Writes are untouched: every one of them takes `Partial<TRow>`, so a row a\n * function BUILDS still needs no id.\n */\nexport type PlatformRow<TRow> = 0 extends 1 & TRow\n ? TRow\n : Omit<TRow, \"id\"> & { id: string };\n\n/** One model's row shape, open when the type declares no schema. */\nexport type DatabaseModelRow<TModels, M extends string> =\n M extends keyof TModels\n ? PlatformRow<TModels[M]>\n : Record<string, unknown> & { id: string };\n\n/**\n * One model of one database, scoped: the `modelName` every records call needs\n * is bound once, so a call names an operation and its own arguments.\n *\n * Filters and options are ordinary objects. Inline filter typing arrives with\n * unified schemas — the intent's decision, not an omission — so what is typed\n * today is the model name and the row shape a read hands back.\n */\nexport type ModelScopedBody<TBody = Record<string, unknown>> = TBody & {\n /**\n * Bound by the handle. Reserved so a body cannot look like a second way to\n * choose a model: the runtime assigns the handle's own model last, and a row\n * type that said otherwise would be a lie about what came back.\n */\n modelName?: never;\n};\n\n/**\n * One write inside a model-scoped batch. Every batch verb is a write, so a\n * batch on a model needs that model's write grant whatever the ops are.\n */\nexport type ModelBatchOperation<TRow> = {\n op: \"save\" | \"patch\" | \"delete\" | \"increment\" | \"addToSet\" | \"removeFromSet\";\n id?: string;\n data?: Partial<TRow>;\n /** Bound by the handle, for the same reason every other call's is. */\n modelName?: never;\n [key: string]: unknown;\n};\n\nexport interface DatabaseModelHandle<TRow> {\n /**\n * One page of this model's rows, in the decided envelope — `{ items,\n * hasMore, nextCursor? }` (#3287), the same shape `ctx.doc(...)`,\n * `ctx.users.list` and the client library answer. The route's own wire\n * shape is unchanged; the SDK is where the one name lives, so shared paging\n * code can be written once.\n */\n query(body?: ModelScopedBody): Promise<{ items: TRow[]; hasMore: boolean; nextCursor?: string }>;\n count(body?: ModelScopedBody): Promise<any>;\n aggregate(body: ModelScopedBody): Promise<any>;\n save(body: ModelScopedBody<{ id?: string; data: Partial<TRow>; [key: string]: unknown }>): Promise<any>;\n /**\n * Change some fields of ONE row — `databases.records.patch`, with this\n * handle's model bound (#3450).\n *\n * The record id is positional and the body may not carry another, for the\n * same reason it may not name another model: the runtime assigns both LAST,\n * so a body that appeared to choose either would be a lie about which row\n * moved. `condition`, `stringSets` and the rest of the operation's own keys\n * pass through untouched.\n */\n patch(\n recordId: string,\n body: ModelScopedBody<{ data: Partial<TRow>; id?: never; [key: string]: unknown }>\n ): Promise<any>;\n /**\n * Remove ONE row by the id a read handed back — `databases.records.delete`,\n * with this handle's model bound (#3450). An optional `condition` makes it\n * conditional, and travels untouched.\n */\n delete(\n recordId: string,\n body?: ModelScopedBody<{ condition?: Record<string, unknown>; id?: never }>\n ): Promise<any>;\n /** Several writes to THIS model in one request; the binding is per item. */\n batch(body: {\n operations: Array<ModelBatchOperation<TRow>>;\n atomic?: boolean;\n }): Promise<any>;\n}\n\n/** One database, typed by the database TYPE key its grant names. */\nexport interface DatabaseHandle<TModels> {\n /** The database this handle addresses — part of every query cache key. */\n databaseId: string;\n /** The type key this handle was opened with. */\n databaseType: string;\n model<M extends DatabaseModelNames<TModels>>(\n modelName: M\n ): DatabaseModelHandle<DatabaseModelRow<TModels, M>>;\n /**\n * A batch may also SPAN models, and then it names each one itself — the\n * model-scoped form above is the typed way to write the common case.\n */\n batch(body: {\n operations: Array<Record<string, unknown>>;\n atomic?: boolean;\n }): Promise<any>;\n /** Run one of the database type's prepared operations under this function's grants. */\n runOperation(name: string, params?: Record<string, unknown>): Promise<any>;\n}\n\n/**\n * The app's DOCUMENT models — EMPTY here and filled by the declaration\n * `primitive config push` writes into the config tree's `functions/` directory\n * (`primitive-document-types.d.ts`, from the project's `models/models.toml`).\n * A project with no document schema gets the open form and still compiles.\n */\nexport interface DocumentSchemas {}\n\n/** The model names `ctx.doc(id).model()` accepts — every declared one, or `string` before a push. */\nexport type DocumentModelNames = [keyof DocumentSchemas] extends [never]\n ? string\n : keyof DocumentSchemas & string;\n\n/**\n * A document model's row shape, or an open record for an undeclared schema —\n * carrying the platform's record identity either way (#3450), by the same rule\n * and for the same reason as a database row: the records DO is one\n * implementation, and `patch` and `delete` here take an id too.\n */\nexport type DocumentModelRow<M extends string> = M extends keyof DocumentSchemas\n ? PlatformRow<DocumentSchemas[M]>\n : Record<string, unknown> & { id: string };\n\n/** The options a document model read takes: a filter object (or its JSON), a page size, a cursor. */\nexport interface DocumentQueryOptions {\n filter?: Record<string, unknown> | string;\n limit?: number;\n cursor?: string;\n /**\n * The document format you expect (#3764). When it disagrees with the format\n * the platform resolved, the call is refused with a 409\n * DOCUMENT_FORMAT_MISMATCH rather than answered out of the wrong tables.\n * Usually stated once on the handle, as ctx.doc(id, { documentFormat: 2 }),\n * rather than per read.\n */\n documentFormat?: 1 | 2;\n}\n\n/**\n * One document model, bound to its document and its model name — a thin\n * binding over `ctx.api.documents.records.*` with the route's own shapes.\n */\n/**\n * One op of a document `batch` — the `documents.records.bulk` blob's shape,\n * typed to this handle's model (#3455).\n *\n * `model` is NOT a member: the handle already names it and assigns it last, so\n * a multi-model blob stays on the raw `ctx.api.documents.records.bulk`\n * operation rather than becoming a second way to say the same thing.\n */\nexport type DocumentBatchOp<TRow> =\n | { action: \"create\" | \"patch\"; id: string; data: Partial<TRow>; precondition?: Record<string, unknown> }\n | { action: \"delete\"; id: string; precondition?: Record<string, unknown> };\n\n/** What `documents.records.bulk` answers: the blob's aggregate effect. */\nexport interface DocumentBulkResult {\n applied: number;\n added: Array<{ model: string; id: string }>;\n updated: Array<{ model: string; id: string }>;\n deleted: number;\n}\n\nexport interface DocumentModelHandle<TRow> {\n query(options?: DocumentQueryOptions): Promise<{ items: TRow[]; hasMore: boolean; nextCursor?: string }>;\n count(options?: { filter?: Record<string, unknown> | string }): Promise<{ count: number }>;\n aggregate(body: Record<string, unknown>): Promise<any>;\n save(body: { id: string; data: Partial<TRow>; options?: Record<string, unknown> }): Promise<{ record: TRow }>;\n patch(recordId: string, body: { data: Partial<TRow>; options?: Record<string, unknown> }): Promise<{ record: TRow }>;\n delete(recordId: string): Promise<{ deleted: boolean }>;\n /**\n * Apply an ordered blob of this model's ops in ONE transaction — all of it\n * commits or none of it does, and connected clients see one update.\n *\n * One model's ops, by construction: every op's `model` is this handle's.\n * A blob that spans models is the raw `ctx.api.documents.records.bulk`\n * operation's job.\n */\n batch(ops: Array<DocumentBatchOp<TRow>>): Promise<DocumentBulkResult>;\n}\n\n/** A document, addressed once; its models are typed from `DocumentSchemas`. */\nexport interface DocumentHandle {\n documentId: string;\n model<M extends DocumentModelNames>(modelName: M): DocumentModelHandle<DocumentModelRow<M>>;\n}\n\n/**\n * One call through a granted integration — #3183.\n *\n * `path` is RELATIVE to the integration's `baseUrl`, and the host is the\n * integration's: the platform resolves and normalizes the path before checking\n * it against `allowedPaths`, so a protocol-relative path or a `..` segment is\n * refused rather than silently sending the request somewhere else.\n */\nexport interface IntegrationCallRequest {\n /** Must be in the integration's `allowedMethods`. Defaults to its own default. */\n method?: string;\n /** Relative to the integration's `baseUrl`. */\n path?: string;\n query?: Record<string, unknown>;\n headers?: Record<string, string>;\n body?: unknown;\n /** form-urlencoded body; not combinable with `body`. */\n form?: Record<string, unknown>;\n bodyMode?: \"json\" | \"raw\" | \"multipart\";\n}\n\n/** What the upstream answered, as the platform saw it. */\nexport interface IntegrationCallResult {\n status: number;\n headers: Record<string, string>;\n body: unknown;\n durationMs: number;\n traceId: string;\n /** Set when the platform or the upstream refused; absent on success. */\n errorCode?: string;\n}\n\n/** What a prompt run is given — the member execute route's own body. */\nexport interface PromptRunArgs {\n /**\n * The prompt's variables. A `kind = \"decisions\"` prompt takes\n * `{ state, criteria? }`: `state` is the value its questions are asked\n * about, and `criteria.<question>` supplies this run's options for each\n * choice question declared `criteriaSource = \"dynamic\"` — a table of option\n * key = description (a string or a JSON object), at least two entries (#3813).\n */\n variables?: Record<string, unknown>;\n /** Run against a different model for this call only. */\n modelOverride?: string;\n /** Pin a specific config OF THIS PROMPT; defaults to its active one. */\n configId?: string;\n}\n\n/**\n * The app's PROMPTS — EMPTY here and filled by the declaration\n * `primitive config push` writes into the config tree's `functions/` directory\n * (`primitive-prompt-types.d.ts`, from the tree's `prompts/*.toml`). A prompt\n * that declares an `outputSchema` carries `{ output: <Key>PromptOutput }`; one\n * that declares none carries `{}`, so reading `parsed.field` on it is a\n * compile error rather than a runtime `undefined`.\n */\nexport interface PromptSchemas {}\n\n/**\n * The keys whose declaration is an AGENT (`kind = \"agent\"`, #3798): entries\n * carrying `{ agent: … }` instead of an output. An agent runs turn by turn in\n * a session and never single-shot, so these are the keys `PromptKeys` leaves\n * out.\n */\nexport type AgentKeys = {\n [K in keyof PromptSchemas]: PromptSchemas[K] extends { agent: unknown } ? K : never;\n}[keyof PromptSchemas] &\n string;\n\n/**\n * The keys `ctx.prompts.run` accepts — every declared one that is not an\n * agent, or `string` before a push.\n */\nexport type PromptKeys = [keyof PromptSchemas] extends [never]\n ? string\n : Exclude<keyof PromptSchemas & string, AgentKeys>;\n\n/** One agent's session variables, typed from its `inputSchema` (#3798). */\nexport type AgentVariables<K extends AgentKeys> = PromptSchemas[K] extends {\n agent: { variables: infer V };\n}\n ? V\n : never;\n\n/** One agent's client tools, by name: each one's `input` and `output` (#3798). */\nexport type AgentClientTools<K extends AgentKeys> = PromptSchemas[K] extends {\n agent: { clientTools: infer T };\n}\n ? T\n : never;\n\n/** One agent's event kinds, by name: each one's payload (#3798). */\nexport type AgentEvents<K extends AgentKeys> = PromptSchemas[K] extends {\n agent: { events: infer E };\n}\n ? E\n : never;\n\n/** One prompt's declared output type, or `unknown` where none is declared. */\nexport type PromptOutput<K extends string> = K extends keyof PromptSchemas\n ? PromptSchemas[K] extends { output: infer O }\n ? O\n : unknown\n : unknown;\n\n/**\n * Why a prompt's own answer was refused — #3330. Never set on a PROVIDER\n * failure, which is what makes \"the model returned the wrong shape\"\n * distinguishable from \"the model failed\".\n */\nexport type PromptOutputErrorCode =\n | \"PROMPT_OUTPUT_NOT_JSON\"\n | \"PROMPT_OUTPUT_SCHEMA_VIOLATION\";\n\n/**\n * Every code the envelope's `errorCode` can carry — #3663, #3813.\n *\n * `PROMPT_UPSTREAM_TIMEOUT` is the one that is NOT about the prompt's own\n * answer: the provider ran out of time, so there was no answer to refuse. It\n * is the only provider failure that sets `errorCode` at all, which is what\n * leaves \"the model returned the wrong shape\" distinguishable from \"the model\n * failed\" while still letting a caller retry the one failure worth retrying.\n *\n * `PROMPT_CRITERIA_INVALID` is the run that never reached a provider: a\n * decisions run's `variables.criteria` was refused before the call, so\n * nothing was billed (#3813).\n *\n * `PROMPT_STRICT_OUTPUT_SCHEMA_MISSING` never reached one either: the config\n * sets `strictOutput = true` and the prompt has no usable `outputSchema` to\n * send as the strict `json_schema` (#3801).\n */\nexport type PromptRunErrorCode =\n | PromptOutputErrorCode\n | \"PROMPT_UPSTREAM_TIMEOUT\"\n | \"PROMPT_CRITERIA_INVALID\"\n | \"PROMPT_STRICT_OUTPUT_SCHEMA_MISSING\";\n\n/** A prompt that declares an output shape, when the answer matched it. */\nexport interface PromptRunSuccess<TParsed> {\n success: true;\n output: string;\n /** The parsed, validated answer — no caller-side `JSON.parse` (#3330). */\n parsed: TParsed;\n error?: null;\n errorCode?: null;\n metrics?: Record<string, unknown>;\n configId: string;\n}\n\n/**\n * The failure arm, whichever failed. `errorCode` is set for a SHAPE failure,\n * for a refused run (`PROMPT_CRITERIA_INVALID`, #3813), and for a provider\n * one only when the upstream TIMED OUT (#3663); `output` carries the text\n * either way, which is where the model's own value lives — a validation\n * `error` names paths and schema constraints only.\n */\nexport interface PromptRunFailure {\n success: false;\n output: string;\n error: string | null;\n errorCode?: PromptRunErrorCode | null;\n parsed?: undefined;\n metrics?: Record<string, unknown>;\n configId: string;\n /**\n * The upstream provider's HTTP status, when the call reached a provider and\n * it answered — #3663. This is what a retry decision is made on: a 504 or a\n * 503 is worth another attempt, a 400 on a refused payload is not.\n *\n * It does not depend on which provider the config named: Gemini and\n * OpenRouter report it identically. It is absent when no provider answer was\n * observed — an unset key, an oversized payload, a completion that came back\n * empty — so a number here is always the provider's own.\n */\n upstreamStatus?: number;\n}\n\n/** The envelope for a key whose declaration says nothing about its output. */\nexport interface PromptRunOpenResult {\n success: boolean;\n output: string;\n /**\n * Present when the config that ran declares `outputFormat = \"json\"` and the\n * text parsed. Untyped: nothing declared its shape.\n */\n parsed?: unknown;\n error?: string | null;\n errorCode?: PromptRunErrorCode | null;\n metrics?: Record<string, unknown>;\n configId: string;\n /** The upstream provider's HTTP status on a provider failure — #3663. */\n upstreamStatus?: number;\n}\n\n/**\n * The member execute envelope, plus what the prompt's own declaration adds.\n *\n * For a key whose `prompts/<key>.toml` declares an `outputSchema`, this is a\n * discriminated union: narrow on `success` and `parsed` is the declared type,\n * required. For every other key — and in a tree that has not pushed — it is\n * the open shape, with `parsed` optional and `unknown`.\n */\nexport type PromptRunResult<K extends string = string> = K extends keyof PromptSchemas\n ? PromptSchemas[K] extends { output: infer O }\n ? PromptRunSuccess<O> | PromptRunFailure\n : PromptRunOpenResult\n : PromptRunOpenResult;\n\n/** What a send delivered to. */\nexport interface SendResult {\n /** Unique live connections the frame was sent to. Zero is a success. */\n connections: number;\n /** True when the per-user connection ceiling stopped the fanout. */\n truncated: boolean;\n}\n\n/** Who a channel grant is for, and for how long — #3184. */\nexport interface ChannelAuthorizeOptions {\n /**\n * The member the grant names. Caller mode defaults to the invoking caller;\n * system mode has no caller and must say.\n */\n userId?: string;\n /** Default 300 s, clamped to the platform ceiling of 900 s. */\n ttlSeconds?: number;\n}\n\n/** The credential a client presents on the WebSocket it already has. */\nexport interface ChannelGrantResult {\n channel: string;\n /** The signed grant. Hand it to the client; it is not readable here. */\n grant: string;\n /** Epoch milliseconds. Expiry is the only revocation a channel has. */\n expiresAt: number;\n}\n\n/** Where to start and how big a page to take — #3280. */\nexport interface UserPageOptions {\n /** Page size. Capped by the route at 100. */\n limit?: number;\n /** The `nextCursor` of the page before this one. */\n cursor?: string;\n}\n\n/** One user on the roster, as the platform's own users route reports them. */\nexport interface UserPageItem {\n userId: string;\n email: string | null;\n name: string | null;\n avatarUrl: string | null;\n role: string;\n addedAt: string | null;\n status: string;\n disabledAt: string | null;\n [key: string]: unknown;\n}\n\n/** The decided paged envelope, the same shape every paged read answers. */\nexport interface UserPage {\n items: UserPageItem[];\n hasMore: boolean;\n /** Absent on the last page. */\n nextCursor?: string;\n}\n\n/** How a nested start is keyed and labelled — #3280. */\nexport interface FunctionStartOptions {\n /**\n * Idempotency key, scoped to the tree's root initiator and the resolved\n * context document: a repeat replays the run that already exists rather than\n * starting a second. At most 100 characters.\n */\n runKey?: string;\n /**\n * The document the child's run is keyed under. Defaults through the\n * inheritance rule: the parent run's context, else the root caller's root\n * document, else `fn:<the root function's id>`. At most 100 characters.\n */\n contextDocId?: string;\n /** Caller metadata, at most 1 KB encoded. */\n meta?: Record<string, unknown>;\n}\n\n/** The start envelope, the same one a workflow start answers with — #3280. */\nexport interface FunctionStartResult {\n /** Poll this on the platform's run-status route. */\n runId: string;\n runKey: string;\n instanceId: string;\n status: string;\n /**\n * True when `runKey` already named a run in this tree, which this envelope\n * describes. That is what makes a run key a singleton.\n */\n existing?: boolean;\n}\n\nexport interface FunctionContext {\n /** The HTTP caller, or null for a webhook or cron fire. */\n user: FunctionUser | null;\n trigger: FunctionTrigger;\n /**\n * Which RUNTIME is hosting this code — #3482.\n *\n * Beside `trigger`, which says which DOOR fired, and they are different\n * questions: an HTTP call is whichever runtime the caller chose\n * (`invoke` or `start`), a cron fire is always a task and a webhook\n * delivery is always a request.\n *\n * To REFUSE a runtime rather than branch on it, call\n * `assertRuntime(\"task\")` — at module scope to refuse it outright, or in\n * the handler to refuse one call.\n */\n runtime: \"request\" | \"task\";\n /**\n * The RUN this invocation belongs to, or null — #3562.\n *\n * Set under the task runtime (every slice of the run, the first and every\n * resume) and for a webhook-fired request run, which writes a row. Null for\n * an HTTP `invoke`, which writes no run row at all.\n *\n * It is the deterministic OWNER a task run presents to re-take its own\n * lease: `ctx.api.locks.tryAcquire({ body: { key, ttlMs, owner: ctx.runId } })`\n * succeeds for the run that already holds the key, with a fresh handle.\n */\n runId: string | null;\n /**\n * The SLICE of the run this code is running in, or null — #3562.\n *\n * The same identifier `primitive functions runs` and the run-status\n * route's `slice.sliceId` report. A task run is a sequence of slices: it\n * changes when the run hibernates and wakes, which is how a handler can tell\n * a resume from a first pass.\n *\n * Null under the request runtime: a request invocation is not a slice.\n */\n sliceId: string | null;\n api: FunctionApi;\n /**\n * A typed handle over one database. The second argument is the database TYPE\n * key — the same key a `database:<type>/<model>:read|write` grant names —\n * and it is what selects the models this handle knows (#3182).\n */\n db<K extends DatabaseTypeKeys>(\n databaseId: string,\n databaseType: K\n ): DatabaseHandle<DatabaseModels<K>>;\n /**\n * A typed handle over one document's record models, typed from the\n * project's `models/models.toml` — `ctx.db`'s shape for documents. It\n * confers nothing: every call is a `documents.records.*` operation on the\n * same authority.\n */\n doc(documentId: string, options?: { documentFormat?: 1 | 2 }): DocumentHandle;\n /**\n * Outbound HTTP, through a granted integration and nowhere else (#3183).\n *\n * A function has no raw network access: every `fetch` to a host that is not\n * the platform answers `FUNCTION_EGRESS_DENIED`, grant or no grant. What an\n * `integration:<key>` grant buys is this call, which the MAIN WORKER makes on\n * the function's behalf — which is why the integration's `{{secrets.*}}`\n * credentials can be injected into the request without ever being visible to\n * the code that asked for it.\n */\n integrations: {\n call(\n integrationKey: string,\n request?: IntegrationCallRequest\n ): Promise<IntegrationCallResult>;\n };\n /**\n * Start a TASK function from inside this one — #3280.\n *\n * The one nested door, and it is a START. A request function is code and\n * code composes by being IMPORTED, so there is no synchronous nested\n * invocation to reach for; a request-mode callee answers\n * `FUNCTION_MODE_MISMATCH`.\n *\n * The callee's `access` gate is not consulted — this function's own gate was\n * the authorization — and every run in the tree is keyed by whoever started\n * it, so the member who invoked the root polls and terminates them all.\n * Nesting is bounded at four levels.\n */\n functions: {\n start(\n functionKey: string,\n input?: unknown,\n options?: FunctionStartOptions\n ): Promise<FunctionStartResult>;\n };\n /**\n * Run one of the app's prompts, with nothing to declare (#3183, #3279).\n *\n * The prompt's `accessRule` is not consulted — it states which MEMBERS may\n * execute the prompt from a client, and the invocation gate is what\n * authorized this call. The provider request is bounded by the invocation's\n * own deadline.\n *\n * TYPED BY KEY (#3330). Where `prompts/<key>.toml` declares an\n * `outputSchema`, the platform parses the answer, validates it against that\n * schema and hands it back as `parsed`, typed — so the shape is written once\n * in TOML instead of restated as a `JSON.parse` at every call site. Where\n * only the config that ran declares `outputFormat = \"json\"`, `parsed` is\n * present but `unknown`. Where neither is declared the envelope is exactly\n * what it has always been.\n *\n * A shape the declaration refuses is `success: false` with an `errorCode`\n * (`PROMPT_OUTPUT_NOT_JSON` or `PROMPT_OUTPUT_SCHEMA_VIOLATION`) and the\n * text still in `output`; a PROVIDER failure has `error` and no\n * `errorCode`, so the two are told apart without guessing.\n *\n * Once a tree has pushed, a key it does not declare is a compile error.\n */\n prompts: {\n run<K extends PromptKeys>(\n promptKey: K,\n args?: PromptRunArgs\n ): Promise<PromptRunResult<K>>;\n };\n /**\n * The value of one app secret, under a `secret:<NAME>` grant (#3183).\n *\n * Prefer `ctx.integrations.call` when the secret is a credential FOR an\n * integration: there the value is injected by the platform and never enters\n * the sandbox at all. This is for the cases an integration cannot express.\n *\n * Rejects with `FUNCTION_SECRET_NOT_FOUND` when the grant names a value\n * this environment has not been given — secrets are provisioned per\n * environment, out of band from the push.\n */\n secret(name: string): Promise<string>;\n /** The value of one app config var, under a `var:<NAME>` grant (#3183). */\n configVar(name: string): Promise<string>;\n /**\n * Realtime messages to this app's clients, under a `users:send` grant\n * (#3183).\n *\n * The recipient's client receives a `direct.message` frame carrying this\n * payload and the sending function's key. Presence is not guaranteed: a\n * member with no live socket answers `{ connections: 0 }` rather than an\n * error.\n */\n users: {\n /**\n * One page of the app's users — #3280.\n *\n * On the APP's system authority, whoever invoked the function: a member\n * who passes this function's gate reads whatever roster it chooses to\n * expose, so say who may in the function's own `access` expression.\n * `limit` is capped by the route at 100.\n */\n list(options?: UserPageOptions): Promise<UserPage>;\n /**\n * Every page of the app's users, in order — #3280.\n *\n * FOR A REQUEST FUNCTION AND A SINGLE-SLICE LOOP. A durable loop must take\n * its pages inside `step.do` with an EXPLICIT cursor: a memoized step does\n * not advance an iterator on resume, so an iteration across a sleep would\n * replay pages it had already taken.\n */\n iterate(options?: UserPageOptions): AsyncIterable<UserPage>;\n send(userId: string, payload: unknown): Promise<SendResult>;\n };\n /** The same frame to ONE connection, under a `connections:send` grant. */\n connections: {\n send(connectionId: string, payload: unknown): Promise<SendResult>;\n };\n /**\n * Realtime channels, under a `channel:<namespace>` grant that COVERS the\n * channel — #3184.\n *\n * `authorize` hands back a short-lived grant for ONE member to present on\n * the socket it already has; `publish` delivers a `channel.message` frame to\n * every connection that has joined and whose grant has not expired. Expiry is\n * the only revocation, so `expiresAt` comes back for the client to renew\n * ahead of — a renewal is another authorize and another subscribe.\n */\n channels: {\n authorize(\n channel: string,\n options?: ChannelAuthorizeOptions\n ): Promise<ChannelGrantResult>;\n publish(channel: string, payload: unknown): Promise<SendResult>;\n };\n}\n\n/** How the wait between one step's retries grows. */\nexport type StepBackoff = \"constant\" | \"linear\" | \"exponential\";\n\n/**\n * The retry and timeout policy for ONE `step.do` — Cloudflare Workflows' own\n * step config.\n *\n * Under the TASK runner the platform forwards this object to Workflows\n * untouched, so these are its fields and its spellings: a duration is either a\n * number of milliseconds or a string Workflows parses (`\"10 seconds\"`,\n * `\"5 minutes\"`). Under the REQUEST runner `step.do` accepts a config and\n * ignores it — the body runs inline, and there is nothing to retry into.\n *\n * `stepPolicy.<family>` IS a `StepConfig`, so the platform's own defaults\n * hand straight to `step.do` (#3657). The shape is closed on purpose: a key\n * outside it — `retry` for `retries`, `timeoutMs` for `timeout` — is a\n * refusal at `config push` rather than an option the engine silently drops.\n */\nexport interface StepConfig {\n retries?: { limit: number; delay: string | number; backoff?: StepBackoff };\n timeout?: string | number;\n}\n\n/**\n * The step handle. `step` is the third argument under BOTH runners, so the\n * same body runs either way — which is what `mode = \"any\"` is for (#3454).\n *\n * Under the TASK runner it is Cloudflare Workflows' `WorkflowStep`, forwarded\n * untouched: `step.do` results are memoized and replayed, and `step.sleep`\n * hibernates.\n *\n * Under the REQUEST runner it is the platform's own, bounded by the request's\n * clock: `do` executes the body inline (there is no engine to memoize into,\n * and nothing is replayed); `sleep` and `sleepUntil` REALLY wait when the\n * remaining request budget covers the duration, and otherwise fail the\n * invocation with `errorCode: \"FUNCTION_RUNTIME_REFUSED\"` saying to start the\n * function as a task; `waitForEvent` fails the same way, because nothing can\n * deliver an event to an invocation that has to return now. The thrown error's\n * `name` is `STEP_NOT_AVAILABLE` in every case, so a body that catches it\n * keeps catching it.\n */\nexport interface FunctionStep {\n do<T>(name: string, body: () => T | Promise<T>): Promise<T>;\n do<T>(\n name: string,\n config: StepConfig,\n body: () => T | Promise<T>\n ): Promise<T>;\n sleep(name: string, duration: number | string): Promise<void>;\n sleepUntil(name: string, timestamp: Date | number): Promise<void>;\n waitForEvent<T = unknown>(\n name: string,\n options: Record<string, unknown>\n ): Promise<T>;\n}\n\nexport declare const SDK_STUB_VERSION: string;\n\n/**\n * Thrown by `assertRuntime` when this function is running under the other\n * runtime — #3482.\n *\n * The platform settles it as `status: \"failed\"` with\n * `errorCode: \"FUNCTION_RUNTIME_REFUSED\"`, on a request invocation's\n * envelope and on a task run's row and record alike.\n */\nexport declare class FunctionRuntimeError extends Error {\n name: \"FUNCTION_RUNTIME_REFUSED\";\n /** The runtime this invocation is actually running under. */\n runtime: \"request\" | \"task\";\n /** The runtime the function asked for. */\n required: \"request\" | \"task\";\n}\n\n/**\n * Refuse the runtime this function was not written for — #3482.\n *\n * A function is a function and the caller picks the runtime at each call, so\n * nothing in config says which one a function may run under. This is the lock,\n * and it lives in the one place that can always be right about the code:\n *\n * ```ts\n * import { assertRuntime } from \"primitive-functions\";\n *\n * // At module scope: this function is never runnable inside a request.\n * assertRuntime(\"task\");\n *\n * export default async function (input, ctx, step) {\n * await step.sleep(\"cool-off\", \"1 hour\");\n * return { ok: true };\n * }\n * ```\n *\n * Returns when the runtimes match; otherwise throws\n * {@link FunctionRuntimeError}, which the platform settles as\n * `status: \"failed\"` with `errorCode: \"FUNCTION_RUNTIME_REFUSED\"` and a\n * message naming both runtimes and the verb that takes the one required.\n */\nexport declare function assertRuntime(required: \"request\" | \"task\"): void;\n\n/**\n * The handler a function exports, typed for one declared key.\n *\n * `step` is the third argument under BOTH runners (#3186, #3454). A task run\n * gets the engine's live `WorkflowStep`; a request invocation gets the\n * platform's own, where `do` runs the body inline and a wait the request\n * budget cannot cover fails the invocation naming the task runner — so a\n * task-authored body can be exercised as a request, and the one place the two\n * genuinely differ says so rather than pretending.\n */\nexport type FunctionHandler<TInput, TOutput> = (\n input: TInput,\n ctx: FunctionContext,\n step: FunctionStep\n) => Promise<TOutput>;\n\n/**\n * Declare a server function's handler, typed from its declaration.\n *\n * The KEYED form, `defineFunction(\"<key>\", handler)`, is typed from the\n * `FunctionSchemas` augmentation `primitive config push` writes beside the\n * sources: `input` is the key's declared input, the return is checked against\n * its declared output, and a key the tree does not declare is a compile error.\n * `config push` also refuses an entry whose key names another file's. In a\n * tree that has not pushed yet the key is any string and both types are `any`.\n *\n * The UNKEYED form is what it always was: author-declared generics. Both\n * styles reach the platform bootstrap identically — a plain default export\n * taking `(input, ctx, step)` runs exactly as a wrapped one does — so this is\n * a typing and intent marker, not a different calling convention.\n */\nexport declare function defineFunction<K extends FunctionKeys>(\n key: K,\n handler: (\n input: FunctionInput<K>,\n ctx: FunctionContext,\n step: FunctionStep\n ) => FunctionOutput<K> | Promise<FunctionOutput<K>>\n): FunctionHandler<FunctionInput<K>, FunctionOutput<K>> & { functionKey: K };\nexport declare function defineFunction<TInput = unknown, TOutput = unknown>(\n handler: (\n input: TInput,\n ctx: FunctionContext,\n step: FunctionStep\n ) => TOutput | Promise<TOutput>\n): FunctionHandler<TInput, TOutput>;\n\n/**\n * One declared parameter of a registered query.\n *\n * `caller: true` (or `type: \"$caller\"`) is the intent's IMMUTABLE binding:\n * the platform injects the invocation's user and refuses a call that supplies\n * the parameter itself.\n */\n/** The scalar parameter types, and an array parameter's element types. */\nexport type QueryScalarParamType = \"string\" | \"number\" | \"boolean\" | \"any\";\n\nexport interface QueryParamSpec {\n type?: QueryScalarParamType | \"$caller\" | \"array\";\n /** For `type: \"array\"` — the element type; absent means any element. */\n items?: { type: QueryScalarParamType };\n caller?: boolean;\n optional?: boolean;\n default?: unknown;\n}\n\n/** A scalar parameter type's TypeScript type. */\nexport type QueryScalarValue<T> = T extends \"string\"\n ? string\n : T extends \"number\"\n ? number\n : T extends \"boolean\"\n ? boolean\n : T extends \"$caller\"\n ? string\n : any;\n\n/** The value `run` receives for one declared parameter. */\nexport type QueryParamValue<S> = S extends { caller: true }\n ? string\n : S extends { type: \"array\"; items: { type: infer I } }\n ? QueryScalarValue<I>[]\n : S extends { type: \"array\" }\n ? unknown[]\n : S extends { type: infer T }\n ? QueryScalarValue<T>\n : any;\n\ntype QueryOptionalKeys<P> = {\n [K in keyof P]: P[K] extends { optional: true } ? K : never;\n}[keyof P];\n\n/**\n * `run`'s `params`, typed from the declaration: scalars as their scalar,\n * `$caller` as a string, an array as `T[]`, an `optional: true` parameter\n * as an optional key (a parameter with a default is always present). An\n * undeclared name is a compile error.\n */\nexport type QueryParams<P> = {\n [K in Exclude<keyof P, QueryOptionalKeys<P>>]: QueryParamValue<P[K]>;\n} & {\n [K in QueryOptionalKeys<P>]?: QueryParamValue<P[K]>;\n};\n\n/** A registration's definition with its parameters DECLARED, so `run` is typed from them. */\nexport interface TypedQueryDefinition<TDb, TSpec extends Record<string, QueryParamSpec>, TResult> {\n models: string[];\n params?: TSpec;\n cache?: { ttlMs: number };\n run: (db: TDb, params: QueryParams<TSpec>) => TResult | Promise<TResult>;\n}\n\nexport interface QueryDefinition<TDb, TParams, TResult> {\n /** The models this query touches. Caching is off unless the run matches. */\n models: string[];\n params?: Record<string, QueryParamSpec>;\n /**\n * Cache the answer for `ttlMs` — capped by the platform, and applied ONLY\n * when the run is verified: every model the body touched was declared, and\n * no prepared operation was used. A write through the handle drops the\n * entries that read the written model.\n */\n cache?: { ttlMs: number };\n run: (db: TDb, params: TParams) => TResult | Promise<TResult>;\n}\n\n/**\n * Register a named query over a database handle (#3187).\n *\n * A registration helper, not a language: `run` is ordinary code over the same\n * typed handle, and what registration adds is a name, declared parameters\n * (validated, coerced and defaulted), the `$caller` binding, and a cache the\n * platform may use when it can verify what the run touched.\n *\n * Register at MODULE scope: a registration made inside the handler still works\n * for direct calls but is invisible to `config push`'s manifest.\n *\n * `run`'s `params` are TYPED from the declaration (the first overload,\n * inferred with a `const` type parameter): a scalar as its scalar, `$caller`\n * as a string, `{ type: \"array\", items: { type: \"string\" } }` as `string[]`,\n * an `optional: true` parameter as an optional key; an undeclared name inside\n * `run` is a compile error. A declared default is coerced to the declared\n * type at registration, so `run` receives what the declaration promises. The\n * second overload keeps an explicit `TParams`.\n */\nexport declare function defineQuery<\n const TSpec extends Record<string, QueryParamSpec>,\n TDb = DatabaseHandle<any>,\n TResult = any\n>(\n name: string,\n definition: TypedQueryDefinition<TDb, TSpec, TResult>\n): (db: TDb, params?: Record<string, unknown>) => Promise<TResult>;\nexport declare function defineQuery<\n TDb = DatabaseHandle<any>,\n TParams = Record<string, any>,\n TResult = any\n>(\n name: string,\n definition: QueryDefinition<TDb, TParams, TResult>\n): (db: TDb, params?: Record<string, unknown>) => Promise<TResult>;\n\n/** The same, for a registration that writes. A mutation is never cached. */\nexport declare function defineMutation<\n const TSpec extends Record<string, QueryParamSpec>,\n TDb = DatabaseHandle<any>,\n TResult = any\n>(\n name: string,\n definition: TypedQueryDefinition<TDb, TSpec, TResult>\n): (db: TDb, params?: Record<string, unknown>) => Promise<TResult>;\nexport declare function defineMutation<\n TDb = DatabaseHandle<any>,\n TParams = Record<string, any>,\n TResult = any\n>(\n name: string,\n definition: QueryDefinition<TDb, TParams, TResult>\n): (db: TDb, params?: Record<string, unknown>) => Promise<TResult>;\n\n/** The platform's cap on a registered query's cache TTL, in milliseconds. */\nexport declare const MAX_QUERY_CACHE_TTL_MS: number;\n\n/**\n * Map over items with BOUNDED concurrency (#3187). Results come back in the\n * input's order; the first rejection wins and nothing new is started after it.\n *\n * The bound matters inside a sandbox: an unbounded fan-out over a page of rows\n * spends the whole subrequest ceiling in one line.\n */\nexport declare function pMap<T, R>(\n items: Iterable<T>,\n mapper: (item: T, index: number) => R | Promise<R>,\n options?: { concurrency?: number }\n): Promise<R[]>;\n\n/** The default concurrency `pMap` applies when none is given. */\nexport declare const PMAP_DEFAULT_CONCURRENCY: number;\n\n/**\n * A time-ordered ULID.\n *\n * GENERATE IT INSIDE `step.do`. A durable run re-executes its handler on\n * every resume and memoizes only what a step returned, so an id minted at the\n * top of a handler is a different id after a sleep — and whatever it was\n * written into is orphaned.\n */\nexport declare function ulid(): string;\n\n/** One family's durable `step.do` configuration — a `StepConfig` with every field decided. */\nexport interface StepPolicy extends StepConfig {\n retries: { limit: number; delay: string; backoff: StepBackoff };\n timeout: string;\n}\n\n/**\n * The per-family step policies the DSL runners use, generated from their own\n * timeout module (#3187):\n *\n * await step.do(\"send-receipt\", stepPolicy.email, () =>\n * ctx.api.email.send({ body: { to, subject, htmlBody } }));\n *\n * `retries: 0` on email and the AI families is deliberate — a retried timeout\n * would send the same email twice or bill the same generation twice.\n */\nexport declare const stepPolicy: {\n email: StepPolicy;\n llm: StepPolicy;\n gemini: StepPolicy;\n database: StepPolicy;\n};\n\n// Every member the three runtime copies put on their own default export — the\n// platform's `sdk-core.ts`, the published stub and the CLI's collect stub —\n// and nothing else. A helper the module hands a default import but does not\n// declare here is one an author cannot call without the compiler refusing it\n// (#3482 CR3482-002); `tests/api/spec/function-profile.test.ts` holds the four\n// lists equal and compiles a default import against them.\ndeclare const _default: {\n SDK_STUB_VERSION: string;\n defineFunction: typeof defineFunction;\n defineQuery: typeof defineQuery;\n defineMutation: typeof defineMutation;\n pMap: typeof pMap;\n ulid: typeof ulid;\n assertRuntime: typeof assertRuntime;\n FunctionRuntimeError: typeof FunctionRuntimeError;\n};\nexport default _default;\n";
13
13
  //# sourceMappingURL=generated-sdk-types.js.map