export type AggregateID = string; export interface BaseEntityProps { id: AggregateID; createdAt: Date; updatedAt: Date; deletedAt: Date; } export interface CreateEntityProps { id: AggregateID; props: T; createdAt?: Date; updatedAt?: Date; deletedAt?: Date; } export declare abstract class Entity { constructor({ id, createdAt, updatedAt, deletedAt, props, }: CreateEntityProps); protected readonly props: EntityProps; /** * ID is set in the concrete entity implementation to support * different ID types depending on your needs. * For example it could be a UUID for aggregate root, * and shortid / nanoid for child entities. */ protected abstract _id: AggregateID; private readonly _createdAt; private _updatedAt; private _deletedAt; get id(): AggregateID; private setId; get createdAt(): Date; get updatedAt(): Date; setUpdatedAt(updatedAt: Date): void; get deletedAt(): Date; static isEntity(entity: unknown): entity is Entity; /** * Checks if two entities are the same Entity by comparing ID field. * @param object Entity */ equals(object?: Entity): boolean; /** * Returns entity properties. * @return {*} {Props & EntityProps} * @memberof Entity */ getProps(): EntityProps & BaseEntityProps; /** * Convert an Entity and all sub-entities/Value Objects it * contains to a plain object with primitive types. Can be * useful when logging an entity during testing/debugging */ toObject(): unknown; /** * There are certain rules that always have to be true (invariants) * for each entity. Validate method is called every time before * saving an entity to the database to make sure those rules are respected. */ abstract validate(): void; private validateProps; } //# sourceMappingURL=entity.base.d.ts.map