Hook Body
Hook Body protocol schemas
Source: packages/spec/src/data/hook-body.zod.ts
TypeScript Usage
import { ExpressionBodySchema, HookBodySchema, HookBodyCapability, ScriptBodySchema } from '@objectstack/spec/data';
import type { ExpressionBody, HookBody, HookBodyCapability, ScriptBody } from '@objectstack/spec/data';
// Validate data
const result = ExpressionBodySchema.parse(data);ExpressionBody
L1 expression body — pure formula, no IO
Properties
| Property | Type | Required | Description |
|---|---|---|---|
| language | 'expression' | ✅ | |
| source | string | ✅ | Formula expression source |
HookBody
Hook/Action body — expression (L1) or sandboxed JS (L2)
Union Options
This schema accepts one of the following structures:
Option 1
L1 expression body — pure formula, no IO
Properties
| Property | Type | Required | Description |
|---|---|---|---|
| language | 'expression' | ✅ | |
| source | string | ✅ | Formula expression source |
Option 2
L2 sandboxed JS body — runs inside an isolated VM with declared capabilities
Properties
| Property | Type | Required | Description |
|---|---|---|---|
| language | 'js' | ✅ | |
| source | string | ✅ | Function body source |
| capabilities | Enum<'api.read' | 'api.write' | 'api.transaction' | 'crypto.uuid' | 'log'>[] | ✅ | Granted capability tokens |
| timeoutMs | integer | optional | Per-invocation timeout (ms) |
| memoryMb | integer | optional | Per-invocation memory cap (MB) |
HookBodyCapability
Allowed Values
api.readapi.writeapi.transactioncrypto.uuidlog
ScriptBody
L2 sandboxed JS body — runs inside an isolated VM with declared capabilities
Properties
| Property | Type | Required | Description |
|---|---|---|---|
| language | 'js' | ✅ | |
| source | string | ✅ | Function body source |
| capabilities | Enum<'api.read' | 'api.write' | 'api.transaction' | 'crypto.uuid' | 'log'>[] | ✅ | Granted capability tokens |
| timeoutMs | integer | optional | Per-invocation timeout (ms) |
| memoryMb | integer | optional | Per-invocation memory cap (MB) |