Events Handlers — Kernel Protocol reference
Events Handlers schemas of the ObjectStack Kernel Protocol: EventHandler and 2 more — each property with its type, default and a TypeScript example.
Source: packages/spec/src/kernel/events/handlers.zod.ts
TypeScript Usage
import { EventHandlerSchema, EventPersistenceSchema, EventRouteSchema } from '@objectstack/spec/kernel';
import type { EventHandler, EventPersistence, EventRoute } from '@objectstack/spec/kernel';
// Validate data
const result = EventHandlerSchema.parse(data);EventHandler
Properties
| Property | Type | Required | Description |
|---|---|---|---|
| id | string | optional | Unique handler identifier |
| eventName | string | ✅ | Name of event to handle (supports wildcards like user.*) |
| handler | any | ✅ | Handler function |
| priority | integer | optional (default: 0) | Execution priority (lower numbers execute first) |
| async | boolean | optional (default: true) | Execute in background (true) or block (false) |
| retry | { maxRetries?: integer; backoffMs?: integer; backoffMultiplier?: number } | optional | Retry policy for failed handlers |
| timeoutMs | integer | optional | Handler timeout in milliseconds |
| filter | any | optional | Optional filter to determine if handler should execute |
Nested Shape: EventHandler.retry
| Property | Type | Required | Description |
|---|---|---|---|
| maxRetries | integer | optional (default: 3) | Maximum retry attempts |
| backoffMs | integer | optional (default: 1000) | Initial backoff delay |
| backoffMultiplier | number | optional (default: 2) | Backoff multiplier |
EventPersistence
Properties
| Property | Type | Required | Description |
|---|---|---|---|
| enabled | boolean | optional (default: false) | Enable event persistence |
| retentionDays | integer | ✅ | Days to retain persisted events |
| retention | never | optional | [REMOVED] EventPersistence.retention was renamed to retentionDays in @objectstack/spec 17 — the unit of a duration-shaped number lives in the key name, not only in the describe prose. Rename the key to retentionDays; the value (days) is unchanged. |
| filter | any | optional | Optional filter function to select which events to persist |
| storage | Enum<'database' | 'file' | 's3' | 'custom'> | optional (default: "database") | Storage backend for persisted events |
EventRoute
Properties
| Property | Type | Required | Description |
|---|---|---|---|
| from | string | ✅ | Source event pattern (supports wildcards, e.g., user.* or *.created) |
| to | string[] | ✅ | Target event names to route to |
| transform | any | optional | Optional function to transform payload |
Events Dlq
Events Dlq schemas of the ObjectStack Kernel Protocol: DeadLetterQueueEntry, EventLogEntry — each property with its type, default and a TypeScript example.
Events Integrations
Events Integrations schemas of the ObjectStack Kernel Protocol — each property with its type, default and a TypeScript example.