|
| 1 | +--- |
| 2 | +title: Hook Body Doors — Data Protocol reference |
| 3 | +navTitle: Hook Body Doors |
| 4 | +description: "The two platform doors a sandboxed script body (a hook, action or job body) reaches for records it may not write itself: mail goes through the mail service." |
| 5 | +--- |
| 6 | + |
| 7 | +{/* ⚠️ AUTO-GENERATED — DO NOT EDIT. Run build-docs.ts to regenerate. Hand-written docs live in the module folders under content/docs/. */} |
| 8 | + |
| 9 | +The two platform doors a sandboxed script body (a hook, action or job body) |
| 10 | +reaches for records it may not write itself: mail goes through the mail |
| 11 | +service, and a timeline entry goes through the activity door. A body asks for |
| 12 | +each with its own capability token (`email.send`, `activity.append`, |
| 13 | +`HookBodyCapability`), and calls it as `ctx.email.send(input)` / |
| 14 | +`ctx.activity.append(input)`. |
| 15 | + |
| 16 | +Each input below is what the BODY may say. What the platform says about the |
| 17 | +message or the entry is stamped by the door and is not an input: the sender, |
| 18 | +the user the mail is sent by, the organization it belongs to, the actor of a |
| 19 | +timeline entry and the origin naming the body that wrote it. A key outside |
| 20 | +the shape is refused, never dropped, so a body that names one of those is |
| 21 | +told at the call. |
| 22 | + |
| 23 | +<Callout type="info"> |
| 24 | +**Source:** `packages/spec/src/data/hook-body-doors.zod.ts` |
| 25 | +</Callout> |
| 26 | + |
| 27 | +## TypeScript Usage |
| 28 | + |
| 29 | +```typescript |
| 30 | +import { BodyActivityAppendInputSchema, BodyDoorRecordRefSchema, BodyMailSendInputSchema } from '@objectstack/spec/data'; |
| 31 | +import type { BodyActivityAppendInput, BodyDoorRecordRef, BodyMailSendInput } from '@objectstack/spec/data'; |
| 32 | + |
| 33 | +// Validate data |
| 34 | +const result = BodyActivityAppendInputSchema.parse(data); |
| 35 | +``` |
| 36 | + |
| 37 | +--- |
| 38 | + |
| 39 | +## BodyActivityAppendInput |
| 40 | + |
| 41 | +ctx.activity.append input: one entry a script body adds to a record timeline |
| 42 | + |
| 43 | +### Properties |
| 44 | + |
| 45 | +| Property | Type | Required | Description | |
| 46 | +| :--- | :--- | :--- | :--- | |
| 47 | +| **object** | `string` | ✅ | Object name of the record the entry is about | |
| 48 | +| **recordId** | `string` | ✅ | Id of the record the entry is about | |
| 49 | +| **type** | `string` | ✅ | Activity kind, from the open vocabulary less the platform-only values | |
| 50 | +| **summary** | `string` | ✅ | One-line summary | |
| 51 | +| **recordLabel** | `string` | optional | Display label of the record, as of the entry | |
| 52 | +| **source** | `{ object: string; id: string }` | optional | The record the entry points at for its detail | |
| 53 | +| **metadata** | `Record<string, any>` | optional | Display hints stored beside the entry | |
| 54 | + |
| 55 | +### Nested Shape: `BodyActivityAppendInput.source` |
| 56 | + |
| 57 | +| Property | Type | Required | Description | |
| 58 | +| :--- | :--- | :--- | :--- | |
| 59 | +| **object** | `string` | ✅ | Object name of the record | |
| 60 | +| **id** | `string` | ✅ | Record id | |
| 61 | + |
| 62 | + |
| 63 | +--- |
| 64 | + |
| 65 | +## BodyDoorRecordRef |
| 66 | + |
| 67 | +A record the door reads in the caller's scope before it acts |
| 68 | + |
| 69 | +### Properties |
| 70 | + |
| 71 | +| Property | Type | Required | Description | |
| 72 | +| :--- | :--- | :--- | :--- | |
| 73 | +| **object** | `string` | ✅ | Object name of the record | |
| 74 | +| **id** | `string` | ✅ | Record id | |
| 75 | + |
| 76 | + |
| 77 | +--- |
| 78 | + |
| 79 | +## BodyMailSendInput |
| 80 | + |
| 81 | +ctx.email.send input: a message a script body hands to the mail service |
| 82 | + |
| 83 | +### Properties |
| 84 | + |
| 85 | +| Property | Type | Required | Description | |
| 86 | +| :--- | :--- | :--- | :--- | |
| 87 | +| **to** | `string \| { name?: string; address: string } \| (string \| { name?: string; address: string })[]` | ✅ | Recipient address, or a list of them | |
| 88 | +| **cc** | `string \| { name?: string; address: string } \| (string \| { name?: string; address: string })[]` | optional | Carbon-copy recipients | |
| 89 | +| **bcc** | `string \| { name?: string; address: string } \| (string \| { name?: string; address: string })[]` | optional | Blind carbon-copy recipients | |
| 90 | +| **replyTo** | `string \| { name?: string; address: string }` | optional | Reply-To address; the sender itself is the configured one | |
| 91 | +| **subject** | `string` | ✅ | Subject line | |
| 92 | +| **text** | `string` | optional | Plain-text body | |
| 93 | +| **html** | `string` | optional | HTML body | |
| 94 | +| **related** | `{ object: string; id: string }` | optional | The record the message is about | |
| 95 | + |
| 96 | +### Nested Shape: `BodyMailSendInput.related` |
| 97 | + |
| 98 | +| Property | Type | Required | Description | |
| 99 | +| :--- | :--- | :--- | :--- | |
| 100 | +| **object** | `string` | ✅ | Object name of the record | |
| 101 | +| **id** | `string` | ✅ | Record id | |
| 102 | + |
| 103 | + |
| 104 | +--- |
| 105 | + |
0 commit comments