ObjectStackObjectStack

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

PropertyTypeRequiredDescription
idstringoptionalUnique handler identifier
eventNamestring✅Name of event to handle (supports wildcards like user.*)
handlerany✅Handler function
priorityintegeroptional (default: 0)Execution priority (lower numbers execute first)
asyncbooleanoptional (default: true)Execute in background (true) or block (false)
retry{ maxRetries?: integer; backoffMs?: integer; backoffMultiplier?: number }optionalRetry policy for failed handlers
timeoutMsintegeroptionalHandler timeout in milliseconds
filteranyoptionalOptional filter to determine if handler should execute

Nested Shape: EventHandler.retry

PropertyTypeRequiredDescription
maxRetriesintegeroptional (default: 3)Maximum retry attempts
backoffMsintegeroptional (default: 1000)Initial backoff delay
backoffMultipliernumberoptional (default: 2)Backoff multiplier

EventPersistence

Properties

PropertyTypeRequiredDescription
enabledbooleanoptional (default: false)Enable event persistence
retentionDaysinteger✅Days to retain persisted events
retentionneveroptional[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.
filteranyoptionalOptional filter function to select which events to persist
storageEnum<'database' | 'file' | 's3' | 'custom'>optional (default: "database")Storage backend for persisted events

EventRoute

Properties

PropertyTypeRequiredDescription
fromstring✅Source event pattern (supports wildcards, e.g., user.* or *.created)
tostring[]✅Target event names to route to
transformanyoptionalOptional function to transform payload

On this page