Events Handlers Events Handlers protocol schemas
Source: packages/spec/src/kernel/events/handlers.zod.ts
import { EventHandlerSchema, EventPersistenceSchema, EventRouteSchema } from '@objectstack/spec/kernel' ;
import type { EventHandler, EventPersistence, EventRoute } from '@objectstack/spec/kernel' ;
// Validate data
const result = EventHandlerSchema. parse (data);
Property Type Required Description id stringoptional Unique handler identifier eventName string✅ Name of event to handle (supports wildcards like user.*) handler any✅ Handler function priority integeroptional (default: 0) Execution priority (lower numbers execute first) async booleanoptional (default: true) Execute in background (true) or block (false) retry { maxRetries: integer; backoffMs: integer; backoffMultiplier: number }optional Retry policy for failed handlers timeoutMs integeroptional Handler timeout in milliseconds filter anyoptional Optional filter to determine if handler should execute
Property Type Required Description maxRetries integeroptional (default: 3) Maximum retry attempts backoffMs integeroptional (default: 1000) Initial backoff delay backoffMultiplier numberoptional (default: 2) Backoff multiplier
Property Type Required Description enabled booleanoptional (default: false) Enable event persistence retentionDays integer✅ Days to retain persisted events retention neveroptional [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 anyoptional Optional filter function to select which events to persist storage Enum<'database' | 'file' | 's3' | 'custom'>optional (default: "database") Storage backend for persisted events
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 anyoptional Optional function to transform payload