@saflib/notify
@saflib/notify
Classes
| Class | Description |
|---|---|
| InProcessChangeEmitter | Single-process ChangeEmitter with per-org subscribers and a small ring buffer for Last-Event-ID reconnect replay. |
Interfaces
| Interface | Description |
|---|---|
| ChangeEmitter | Transport-agnostic change bus. In-process today; later Redis/NATS or HTTP. Never import product-specific types into implementations. |
| ChangeEvent | Published in-process and on the SSE wire (JSON in the data: field). Coarse change hint only — no resource bodies. |
| ChangeEventWithId | Change event plus monotonic id for SSE id: / Last-Event-ID replay. |
| InProcessChangeEmitterOptions | - |
| SseWritable | Minimal writable surface (Express Response, Node streams, test buffers). |
| WriteSseEventOptions | - |
Type Aliases
| Type Alias | Description |
|---|---|
| ChangeEventListener | - |
Variables
| Variable | Description |
|---|---|
| RING_BUFFER_MAX_AGE_MS | Default max age for buffered events (~5 minutes). |
| RING_BUFFER_MAX_EVENTS | Default per-org ring buffer capacity (~50 events). |
| SSE_HEARTBEAT_INTERVAL_MS | Optional SSE comment heartbeat interval (~30 seconds). |
| SSE_MAX_CONNECTION_MS | Server closes SSE connections after this duration; client reconnects. |
Functions
| Function | Description |
|---|---|
| validateSseOrigin | CSRF-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. |
| writeSseComment | Write an SSE comment line (useful as a keepalive heartbeat). Format: : <comment>\n\n |
| writeSseEvent | Write one SSE event frame. Ends with a blank line per the SSE framing rules. |