| title |
Realtime |
| description |
Realtime protocol schemas |
**Source:** `packages/spec/src/api/realtime.zod.ts`
import { PresenceSchema, PresenceStatusSchema, RealtimeActionSchema, RealtimeConfigSchema, RealtimeEventSchema, RealtimeEventTypeSchema, SubscriptionSchema, SubscriptionEventSchema, TransportProtocolSchema } from '@objectstack/spec/api';
import type { Presence, PresenceStatus, RealtimeAction, RealtimeConfig, RealtimeEvent, RealtimeEventType, Subscription, SubscriptionEvent, TransportProtocol } from '@objectstack/spec/api';
// Validate data
const result = PresenceSchema.parse(data);
| Property |
Type |
Required |
Description |
| userId |
string |
✅ |
User identifier |
| status |
Enum<'online' | 'away' | '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 |
| enabled |
boolean |
optional |
Enable realtime synchronization |
| transport |
Enum<'websocket' | 'sse' | 'polling'> |
optional |
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 |
any |
optional |
Event payload data |
| timestamp |
string |
✅ |
ISO 8601 datetime when event occurred |
| userId |
string |
optional |
User who triggered the event |
record.created
record.updated
record.deleted
field.changed
| 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 |