Realtime Shared
Realtime Shared protocol schemas
Realtime Shared Protocol
Shared schemas and types for real-time communication protocols.
This module consolidates overlapping definitions between the transport-level
realtime protocol (SSE/Polling/WebSocket) and the WebSocket collaboration protocol.
Architecture:
-
realtime-shared.zod.ts— Shared base schemas (Presence, Event types) -
realtime.zod.ts— Transport-layer protocol (Channel, Subscription, Transport selection) -
websocket.zod.ts— Collaboration protocol (Cursor, OT editing, Advanced presence)
@see realtime.zod.ts for transport-layer configuration
@see websocket.zod.ts for collaborative editing protocol
Source: packages/spec/src/api/realtime-shared.zod.ts
TypeScript Usage
import { BasePresence, PresenceStatus, RealtimeRecordAction } from '@objectstack/spec/api';
import type { BasePresence, PresenceStatus, RealtimeRecordAction } from '@objectstack/spec/api';
// Validate data
const result = BasePresence.parse(data);BasePresence
Properties
| 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) |
PresenceStatus
Allowed Values
onlineawaybusyoffline
RealtimeRecordAction
Allowed Values
createdupdateddeleted