ObjectStackObjectStack

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

PropertyTypeRequiredDescription
userIdstringUser identifier
statusEnum<'online' | 'away' | 'busy' | 'offline'>Current presence status
lastSeenstringISO 8601 datetime of last activity
metadataRecord<string, any>optionalCustom presence data (e.g., current page, custom status)

PresenceStatus

Allowed Values

  • online
  • away
  • busy
  • offline

RealtimeRecordAction

Allowed Values

  • created
  • updated
  • deleted

On this page