dino-core
Version:
A dependency injection framework for NodeJS applications
24 lines (23 loc) • 1.09 kB
TypeScript
import { type Archetype, type Props } from './Archetype';
import { type Id } from './Id';
/**
* Define an entity in the common sense of DDD (Domain-Driven Design).
* The properties passed to the constructor will be set with the provided value
* and will only be accessible for reading and writing.
*/
export declare class Entity<T, P extends Props = Record<string, any>> implements Archetype {
private readonly id;
protected constructor(id: Id<T>, props?: P);
getId(): Id<T>;
/**
* Compare two entities for equality
* > if other object is not defined return false
* > if this object and other object are not of the same type then return false
* > if the id of this object properties is not same as the id of other object then return false
* > otherwise return true
* @param other the other archetype to compare
* @returns true if the two entities are same, false otherwise
*/
equals<T extends Archetype>(other: T): boolean;
static create<T, P extends Props = Record<string, any>>(id: Id<T>, props?: P): Entity<T, P>;
}