ObjectStackObjectStack

Events Bus

Events Bus protocol schemas

Source: packages/spec/src/kernel/events/bus.zod.ts

TypeScript Usage

import { EventBusConfigSchema } from '@objectstack/spec/kernel';
import type { EventBusConfig } from '@objectstack/spec/kernel';

// Validate data
const result = EventBusConfigSchema.parse(data);

EventBusConfig

Properties

PropertyTypeRequiredDescription
persistence{ enabled: boolean; retentionDays: integer; filter?: any; storage: Enum<'database' | 'file' | 's3' | 'custom'> }optionalEvent persistence configuration
queue{ name: string; concurrency: integer; retryPolicy?: object; deadLetterQueue?: string; … }optionalEvent queue configuration
eventSourcing{ enabled: boolean; snapshotInterval: integer; snapshotRetention: integer; retentionDays: integer; … }optionalEvent sourcing configuration
replay{ enabled: boolean }optionalEvent replay configuration
webhooks{ id?: string; eventPattern: string; url: string; method: Enum<'GET' | 'POST' | 'PUT' | 'PATCH'>; … }[]optionalWebhook configurations
messageQueue{ provider: Enum<'kafka' | 'rabbitmq' | 'aws-sqs' | 'redis-pubsub' | 'google-pubsub' | 'azure-service-bus'>; topic: string; eventPattern: string; partitionKey?: string; … }optionalMessage queue integration
realtime{ enabled: boolean; protocol: Enum<'websocket' | 'sse' | 'long-polling'>; eventPattern: string; userFilter: boolean; … }optionalReal-time notification configuration
eventTypes{ name: string; version: string; schema?: any; description?: string; … }[]optionalEvent type definitions
handlers{ id?: string; eventName: string; handler: any; priority: integer; … }[]optionalGlobal event handlers

Nested Shape: EventBusConfig.persistence

PropertyTypeRequiredDescription
enabledbooleanoptional (default: false)Enable event persistence
retentionDaysintegerDays 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

Nested Shape: EventBusConfig.queue

PropertyTypeRequiredDescription
namestringoptional (default: "events")Event queue name
concurrencyintegeroptional (default: 10)Max concurrent event handlers
retryPolicy{ maxRetries: integer; backoffStrategy: Enum<'fixed' | 'linear' | 'exponential'>; initialDelayMs: integer; maxDelayMs: integer }optionalDefault retry policy for events
deadLetterQueuestringoptionalDead letter queue name for failed events
priorityEnabledbooleanoptional (default: true)Process events based on priority

Nested Shape: EventBusConfig.eventSourcing

PropertyTypeRequiredDescription
enabledbooleanoptional (default: false)Enable event sourcing
snapshotIntervalintegeroptional (default: 100)Create snapshot every N events
snapshotRetentionintegeroptional (default: 10)Number of snapshots to retain
retentionDaysintegeroptional (default: 365)Days to retain events
retentionneveroptional[REMOVED] EventSourcingConfig.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. The neighbouring snapshotRetention is a COUNT of snapshots, not a duration, so it keeps its name.
aggregateTypesstring[]optionalAggregate types to enable event sourcing for
storage{ type: Enum<'database' | 'file' | 's3' | 'eventstore'>; options?: Record<string, any> }optionalEvent store configuration

Nested Shape: EventBusConfig.replay

PropertyTypeRequiredDescription
enabledbooleanoptional (default: true)Enable event replay capability

Nested Shape: EventBusConfig.webhooks[number]

PropertyTypeRequiredDescription
idstringoptionalUnique webhook identifier
eventPatternstringEvent name pattern (supports wildcards)
urlstringWebhook endpoint URL
methodEnum<'GET' | 'POST' | 'PUT' | 'PATCH'>optional (default: "POST")HTTP method
headersRecord<string, string>optionalHTTP headers
authentication{ type: Enum<'none' | 'bearer' | 'basic' | 'api-key'>; credentials?: Record<string, string> }optionalAuthentication configuration
retryPolicy{ maxRetries: integer; backoffStrategy: Enum<'fixed' | 'linear' | 'exponential'>; initialDelayMs: integer; maxDelayMs: integer }optionalRetry policy
timeoutMsintegeroptional (default: 30000)Request timeout in milliseconds
transformanyoptionalTransform event before sending
enabledbooleanoptional (default: true)Whether webhook is enabled

Nested Shape: EventBusConfig.messageQueue

PropertyTypeRequiredDescription
providerEnum<'kafka' | 'rabbitmq' | 'aws-sqs' | 'redis-pubsub' | 'google-pubsub' | 'azure-service-bus'>Message queue provider
topicstringTopic or queue name
eventPatternstringoptional (default: "*")Event name pattern to publish (supports wildcards)
partitionKeystringoptionalJSON path for partition key (e.g., "metadata.tenantId")
formatEnum<'json' | 'avro' | 'protobuf'>optional (default: "json")Message serialization format
includeMetadatabooleanoptional (default: true)Include event metadata in message
compressionEnum<'none' | 'gzip' | 'snappy' | 'lz4'>optional (default: "none")Message compression
batchSizeintegeroptional (default: 1)Batch size for publishing
flushIntervalMsintegeroptional (default: 1000)Flush interval for batching

Nested Shape: EventBusConfig.realtime

PropertyTypeRequiredDescription
enabledbooleanoptional (default: true)Enable real-time notifications
protocolEnum<'websocket' | 'sse' | 'long-polling'>optional (default: "websocket")Real-time protocol
eventPatternstringoptional (default: "*")Event pattern to broadcast
userFilterbooleanoptional (default: true)Filter events by user
tenantFilterbooleanoptional (default: true)Filter events by tenant
channels{ name: string; eventPattern: string; filter?: any }[]optionalNamed channels for event broadcasting
rateLimit{ maxEventsPerSecond: integer; windowMs: integer }optionalRate limiting configuration

Nested Shape: EventBusConfig.eventTypes[number]

PropertyTypeRequiredDescription
namestringEvent type name (dot notation by convention, e.g. order.created; the platform-checked event vocabulary is the closed DataEventType / BulkDataEventType enums)
versionstringoptional (default: "1.0.0")Event schema version
schemaanyoptionalJSON Schema for event payload validation
descriptionstringoptionalEvent type description
deprecatedbooleanoptional (default: false)Whether this event type is deprecated
tagsstring[]optionalEvent type tags

Nested Shape: EventBusConfig.handlers[number]

PropertyTypeRequiredDescription
idstringoptionalUnique handler identifier
eventNamestringName of event to handle (supports wildcards like user.*)
handleranyHandler 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

On this page