types.ts52 lines · main
| 1 | /** |
| 2 | * Shared types between the runtime host, its executors, and the apps/api |
| 3 | * control plane that drives it. |
| 4 | */ |
| 5 | |
| 6 | import type { RuntimeErrorCode } from './isolate-runtime/types.js'; |
| 7 | |
| 8 | export interface InvokeRequest { |
| 9 | readonly projectId: string; |
| 10 | readonly functionName: string; |
| 11 | readonly args: unknown; |
| 12 | readonly deploymentId: string; |
| 13 | readonly requestId: string; |
| 14 | readonly auth: InvokeAuth | null; |
| 15 | readonly env?: Readonly<Record<string, string>>; |
| 16 | } |
| 17 | |
| 18 | export interface InvokeAuth { |
| 19 | readonly userId: string; |
| 20 | readonly tokenType: 'session' | 'api_key'; |
| 21 | } |
| 22 | |
| 23 | export type InvokeResult = |
| 24 | | { |
| 25 | ok: true; |
| 26 | value: unknown; |
| 27 | durationMs: number; |
| 28 | // Tables the executor observed `ctx.db('<table>')` on. The realtime |
| 29 | // service uses these to decide which LISTEN channels to subscribe |
| 30 | // to for re-invocation push. |
| 31 | touchedTables: readonly string[]; |
| 32 | } |
| 33 | | { |
| 34 | ok: false; |
| 35 | code: RuntimeErrorCode; |
| 36 | message: string; |
| 37 | durationMs: number; |
| 38 | touchedTables?: readonly string[]; |
| 39 | }; |
| 40 | |
| 41 | /** |
| 42 | * A deployed bundle. For Phase 1 the runtime reads plain `.ts` files from |
| 43 | * disk and executes them via `inline`. Phase 2 introduces signed, content- |
| 44 | * addressed bundles plus the Deno executor that enforces the permission |
| 45 | * model from CLAUDE.md §7.3. |
| 46 | */ |
| 47 | export interface Bundle { |
| 48 | readonly projectId: string; |
| 49 | readonly deploymentId: string; |
| 50 | readonly functionNames: readonly string[]; |
| 51 | readonly directory: string; |
| 52 | } |