| title | Hook Body |
|---|---|
| description | Hook Body protocol schemas |
{/*
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);L1 expression body — pure formula, no IO
| Property | Type | Required | Description |
|---|---|---|---|
| language | 'expression' |
✅ | |
| source | string |
✅ | Formula expression source |
Hook/Action body — expression (L1) or sandboxed JS (L2)
This schema accepts one of the following structures:
L1 expression body — pure formula, no IO
| Property | Type | Required | Description |
|---|---|---|---|
| language | 'expression' |
✅ | |
| source | string |
✅ | Formula expression source |
L2 sandboxed JS body — runs inside an isolated VM with declared capabilities
| 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) |
api.readapi.writeapi.transactioncrypto.uuidlog
L2 sandboxed JS body — runs inside an isolated VM with declared capabilities
| 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) |