Events API
Abstract base classes for strongly-typed event payloads in event-driven architecture.
What It Does
The Events API provides foundational abstract base classes for defining strongly-typed event payloads in a microservices architecture. It serves as the base layer for the Foundation’s event-driven system, enabling type-safe event handling for create, update, and delete operations.
Note: This package is marked as DEPRECATED but still widely used across the Foundation ecosystem at version 5.6.0.
Key Capabilities
| Capability | Description |
|---|---|
| Typed Event Payloads | Generic abstract classes for create, update, and delete events |
| Type Safety | TypeScript support with generics for payload types |
| Consistency | Ensures uniform event structure across microservices |
| Extensibility | Allows services to extend with domain-specific event types |
| Integration | Foundation for event publishing and validation services |
Base Event Classes
BaseCreatedEvent<T>
Represents entity creation events:
- Contains
payloadof typeEvent<T> - Used when new entities are created
- Triggers onCreate Cloud Functions
BaseUpdatedEvent<T>
Represents entity update events:
- Contains
payloadof typeUpdatedEvent<T> - Includes before/after values
- Triggers onUpdate Cloud Functions
BaseDeletedEvent<T>
Represents entity deletion events:
- Contains
payloadof typeEvent<T> - Used when entities are deleted
- Triggers onDelete Cloud Functions
Event Structure
Events follow this structure:
{
kind: 'event',
item: any, // Actual payload data
timestamp: string, // ISO timestamp
senderId: string // Triggering entity ID
}Common Use Cases
- Event-driven microservices: Base classes for domain events
- Firestore triggers: Cloud Function event handling
- Pub/Sub messaging: Type-safe event publishing
- Event validation: Schema-based event validation
- Audit trails: Track entity lifecycle events
What Customers Don’t Have to Build
- Abstract event base classes
- Event type definitions
- Generic payload typing
- Event structure consistency
- Type-safe event inheritance
Last updated on