UNPKG

nestjs-event-sourcing-lib

Version:

A comprehensive Event Sourcing and CQRS library for NestJS applications

98 lines (76 loc) 3.4 kB
# Changelog All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). ## [1.0.0] - 2025-07-18 ### Added - Initial release of nest-event-sourcing - Core Event Sourcing abstractions: - `Event` base class with metadata and serialization - `Command` base class with validation support - `AggregateRoot` abstract class with event application and snapshot support - `Projection` base class for read models - `EventStore` interface with comprehensive functionality ### Features - **PostgreSQL Event Store**: Full implementation with TypeORM integration - Event persistence with optimistic concurrency control - Snapshot support for performance optimization - Transaction support for atomic operations - Comprehensive indexing for efficient queries - Connection pooling and health checks - **MongoDB Event Store**: Complete implementation with MongoDB driver - Document-based event storage - Aggregation pipeline support for complex queries - Automatic indexing for optimal performance - Built-in error handling and retry mechanisms - **Decorator System**: Rich metadata decoration system - `@AggregateRoot` for aggregate registration - `@CommandHandler` and `@Command` for CQRS integration - `@OnEvent` and `@Event` for event handling - `@Projection` for read model registration - **Service Layer**: Production-ready service implementations - `CommandHandler` service with transaction management - `EventBus` service with local event publishing - Comprehensive error handling and logging - Built-in retry policies and optimistic locking - **NestJS Integration**: Seamless framework integration - `EventSourcingModule` with `forRoot` and `forRootAsync` methods - Dependency injection support - Global module configuration - Feature module support with `forFeature` ### Technical Features - **TypeScript First**: Strict typing throughout the library - **Modular Architecture**: Support for multiple Event Store backends - **Error Handling**: Comprehensive error types and handling - **Performance**: Snapshot support and query optimization - **Testing**: Full test suite with unit and integration tests - **Documentation**: Comprehensive README with examples ### Dependencies - Core dependencies: `@nestjs/common`, `@nestjs/core`, `@nestjs/cqrs` - Validation: `class-validator`, `class-transformer` - Utilities: `uuid` for ID generation - Optional peer dependencies: - `typeorm` and `pg` for PostgreSQL support - `mongodb` for MongoDB support ### Breaking Changes - None (initial release) ### Migration Guide - None (initial release) ## [Unreleased] ### Planned Features - EventStoreDB integration - Kafka event bus integration - RabbitMQ event bus integration - Advanced projection capabilities - Event replay functionality - Saga pattern support - Event versioning and migration tools - Performance monitoring and metrics - Distributed event sourcing support ### Known Issues - None reported --- ## Contributing Please read [CONTRIBUTING.md](CONTRIBUTING.md) for details on our code of conduct and the process for submitting pull requests. ## License This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.