Documentation Index
Fetch the complete documentation index at: https://grantmaster.dev/llms.txt
Use this file to discover all available pages before exploring further.
shared/events
The canonical EventBus emission and projection infrastructure. This module wraps the rawIEventBus.emit() with type-safe helpers, schema validation, status projections, and test coverage tooling.
Module Map
| File | Role |
|---|---|
canonicalEventEmitter.ts | Primary entry point — emitCanonicalSystemEvent(input) |
canonicalEventMap.ts | Maps SystemEventType → payload type at compile time |
canonicalEventSchema.ts | Zod schemas for every event payload |
canonicalConsumers.ts | Default consumer registrations (status projections, audit log) |
canonicalStatus.ts | Computes domain status from event history |
canonicalStatusSummary.ts | Aggregate status across multiple entities |
canonicalProjectionHealth.ts | Health checks for projection consistency |
canonicalEventVersion.ts | Version negotiation for event schema evolution |
index.ts | Re-exports emitCanonicalSystemEvent as shared/events default export |
Primary API
metadata.source, metadata.version: '1.0.0', metadata.correlationId, and timestamp.
Type Safety
canonicalEventMap.ts maps every SystemEventType to its payload interface, enforced at compile time:
emitCanonicalSystemEvent<E extends keyof EventPayloadMap> constrains the payload parameter to the correct type for the given type.
Schema Validation
canonicalEventSchema.ts provides Zod schemas for every event payload. Used during:
- SuperAdmin EventBus monitor (validates persisted events from Firestore)
- Integration tests in
canonicalEventSchema.test.ts
Status Projections
canonicalStatus.ts derives an entity’s current status by replaying its event history:
canonicalStatusSummary.ts aggregates statuses across a collection for dashboard cards.
Canonical Consumers
canonicalConsumers.ts registers the default subscriptions that run for every organization:
- Audit log writer — persists all events to
auditLogscollection - Status projection updater — updates cached status documents on lifecycle events
- Notification trigger — dispatches notifications for approval/rejection events
initCanonicalConsumers().
Related Docs
- event-catalog.md — full list of 100+ event types
- base-service-and-eventbus.md — EventBus patterns and rules