UNPKG

@hiki9/rich-domain

Version:

Rich Domain is a library that provides a set of tools to help you build complex business logic in NodeJS using Domain Driven Design principles.

24 lines 1.27 kB
import { DomainEventReplaceOptions, EntityConfig, EntityProps, EventPublisher, IAggregate, IDomainEvent, WithDate } from "../interface/types"; import { DomainEvent } from "./domain-event"; import { Entity } from "./entity"; import { EntityHook } from "./hooks"; import { Id } from "./ids"; declare const DOMAIN_EVENTS: unique symbol; export declare abstract class Aggregate<Props extends EntityProps, Input extends Partial<Props> = Partial<Props>> extends Entity<Props, Input> implements IAggregate<Props> { isAggregate: boolean; private [DOMAIN_EVENTS]; protected static hooks: EntityHook<any, any>; constructor(input: Input, options?: EntityConfig); constructor(input: Props, options?: EntityConfig); constructor(input: WithDate<Props>, options?: EntityConfig); hashCode(): Id; addEvent(domainEvent: DomainEvent<any>, replace?: DomainEventReplaceOptions): void; clearEvents(): void; removeEvent(eventName: string): void; getEvents<T = IDomainEvent<any>>(eventName?: string): T[]; hasEvent(eventName: string): boolean; dispatch(eventName: string, eventPublisher: EventPublisher<any>): Promise<void>; dispatchAll(eventPublisher: EventPublisher<any>): Promise<void>; } export {}; //# sourceMappingURL=aggregate.d.ts.map