Skip to content

@saflib/notify


@saflib/notify

Classes

ClassDescription
InProcessChangeEmitterSingle-process ChangeEmitter with per-org subscribers and a small ring buffer for Last-Event-ID reconnect replay.

Interfaces

InterfaceDescription
ChangeEmitterTransport-agnostic change bus. In-process today; later Redis/NATS or HTTP. Never import product-specific types into implementations.
ChangeEventPublished in-process and on the SSE wire (JSON in the data: field). Coarse change hint only — no resource bodies.
ChangeEventWithIdChange event plus monotonic id for SSE id: / Last-Event-ID replay.
InProcessChangeEmitterOptions-
SseWritableMinimal writable surface (Express Response, Node streams, test buffers).
WriteSseEventOptions-

Type Aliases

Type AliasDescription
ChangeEventListener-

Variables

VariableDescription
RING_BUFFER_MAX_AGE_MSDefault max age for buffered events (~5 minutes).
RING_BUFFER_MAX_EVENTSDefault per-org ring buffer capacity (~50 events).
SSE_HEARTBEAT_INTERVAL_MSOptional SSE comment heartbeat interval (~30 seconds).
SSE_MAX_CONNECTION_MSServer closes SSE connections after this duration; client reconnects.

Functions

FunctionDescription
validateSseOriginCSRF-style check for cookie-authenticated long-lived GET (EventSource). Missing/empty Origin is allowed (non-browser clients). When Origin is present it must match an allowed app origin exactly.
writeSseCommentWrite an SSE comment line (useful as a keepalive heartbeat). Format: : <comment>\n\n
writeSseEventWrite one SSE event frame. Ends with a blank line per the SSE framing rules.