Realtime
Realtime protocol schemas
Transport Protocol Enum
Defines the communication protocol for realtime data synchronization
Source: packages/spec/src/api/realtime.zod.ts
import { RealtimeConfig, RealtimeEvent, RealtimeEventType, RealtimePresence, Subscription, SubscriptionEvent, TransportProtocol } from '@objectstack/spec/api';
import type { RealtimeConfig, RealtimeEvent, RealtimeEventType, RealtimePresence, Subscription, SubscriptionEvent, TransportProtocol } from '@objectstack/spec/api';
// Validate data
const result = RealtimeConfig.parse(data);
| Property | Type | Required | Description |
|---|
| enabled | boolean | ✅ | Enable realtime synchronization |
| transport | Enum<'websocket' | 'sse' | 'polling'> | ✅ | Transport protocol |
| subscriptions | Object[] | optional | Default subscriptions |
| Property | Type | Required | Description |
|---|
| id | string | ✅ | Unique event identifier |
| type | string | ✅ | Event type (e.g., record.created, record.updated) |
| object | string | optional | Object name the event relates to |
| action | Enum<'created' | 'updated' | 'deleted'> | optional | Action performed |
| payload | Record<string, any> | ✅ | Event payload data |
| timestamp | string | ✅ | ISO 8601 datetime when event occurred |
| userId | string | optional | User who triggered the event |
| sessionId | string | optional | Session identifier |
record.created
record.updated
record.deleted
field.changed
| Property | Type | Required | Description |
|---|
| userId | string | ✅ | User identifier |
| status | Enum<'online' | 'away' | 'busy' | 'offline'> | ✅ | Current presence status |
| lastSeen | string | ✅ | ISO 8601 datetime of last activity |
| metadata | Record<string, any> | optional | Custom presence data (e.g., current page, custom status) |
| Property | Type | Required | Description |
|---|
| id | string | ✅ | Unique subscription identifier |
| events | Object[] | ✅ | Array of events to subscribe to |
| transport | Enum<'websocket' | 'sse' | 'polling'> | ✅ | Transport protocol to use |
| channel | string | optional | Optional channel name for grouping subscriptions |
| Property | Type | Required | Description |
|---|
| type | Enum<'record.created' | 'record.updated' | 'record.deleted' | 'field.changed'> | ✅ | Type of event to subscribe to |
| object | string | optional | Object name to subscribe to |
| filters | any | optional | Filter conditions |