ObjectStackObjectStack

Realtime Shared — API Protocol reference

Realtime Shared Protocol — Shared schemas and types for real-time communication protocols.

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 also: realtime.zod.ts for transport-layer configuration

See also: websocket.zod.ts for collaborative editing protocol

Source: packages/spec/src/api/realtime-shared.zod.ts

TypeScript Usage

import { BasePresenceSchema, PresenceStatus, RealtimeRecordAction } from '@objectstack/spec/api';
import type { BasePresence, PresenceStatus, RealtimeRecordAction } from '@objectstack/spec/api';

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

BasePresence

Properties

PropertyTypeRequiredDescription
userIdstring✅User identifier
statusEnum<'online' | 'away' | 'busy' | 'offline'>✅Current presence status
lastSeenstring✅ISO 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