Skip to main content

Type Alias: DomainEvent

type DomainEvent: NonNullable<operations["getEventSchema"]["responses"][200]["content"]["application/json"]>;

Real-time domain event model.

Every type here is derived from the OpenAPI spec (components["schemas"] and the documentation-only GET /api/events/schema operation) — there are NO hand-written event shapes, so the model can never drift from the backend. Regenerate with npm run generate:types whenever the spec changes.

Events are delivered as JSON on the SSE streams:

  • GET /api/events/stream (tenant-wide)
  • GET /api/projects/{projectId}/events/stream (project-scoped)

Each event's data (the SSE data: line) is a DomainEvent. Narrow on the type discriminator to get a fully-typed payload.data:

function handle(event: DomainEvent) {
if (event.type === "gathering.member.joined") {
event.payload.data.member; // GatheringMember
} else if (event.type === "message.created") {
event.payload.data.content; // string
}
}

Defined in

4Players/cortex-typescript-sdk/src/realtime/events.ts:28