feat(api): complete domain event publishing with aggregate root pattern
- Add getUncommittedEvents() and commit() to AggregateRoot base class - Create 6 new domain events: SubscriptionExpired, SubscriptionRenewed, ListingStatusChanged, UserKycUpdated, UserDeactivated, PaymentRefunded - Wire events into entity state changes: SubscriptionEntity (markExpired, renewPeriod), ListingEntity (all transitions), UserEntity (KYC, deactivate), PaymentEntity (markRefunded) - Add 7 new event listeners across notifications, admin, and search modules (25 total @OnEvent handlers) - Fix ReviewDeletedListener to handle LISTING target type - Restore watcher notifications in ListingSoldListener - Update barrel exports and module registrations Resolves: TEC-1564 Co-Authored-By: Paperclip <noreply@paperclip.ing>
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
import { type UserRole, type KYCStatus } from '@prisma/client';
|
||||
import { AggregateRoot } from '@modules/shared';
|
||||
import { UserDeactivatedEvent } from '../events/user-deactivated.event';
|
||||
import { UserKycUpdatedEvent } from '../events/user-kyc-updated.event';
|
||||
import { UserRegisteredEvent } from '../events/user-registered.event';
|
||||
import { type Email } from '../value-objects/email.vo';
|
||||
import { type HashedPassword } from '../value-objects/hashed-password.vo';
|
||||
@@ -76,14 +78,19 @@ export class UserEntity extends AggregateRoot<string> {
|
||||
}
|
||||
|
||||
updateKycStatus(status: KYCStatus, kycData?: unknown): void {
|
||||
const previousStatus = this._kycStatus;
|
||||
this._kycStatus = status;
|
||||
if (kycData !== undefined) this._kycData = kycData;
|
||||
this.updatedAt = new Date();
|
||||
|
||||
this.addDomainEvent(new UserKycUpdatedEvent(this.id, status, previousStatus));
|
||||
}
|
||||
|
||||
deactivate(): void {
|
||||
this._isActive = false;
|
||||
this.updatedAt = new Date();
|
||||
|
||||
this.addDomainEvent(new UserDeactivatedEvent(this.id));
|
||||
}
|
||||
|
||||
activate(): void {
|
||||
|
||||
Reference in New Issue
Block a user