/** * Base Entity interface with generic ID type support. */ export interface Entity { readonly id: Id; equals(object?: Entity): boolean; } /** * Configuration options for creating an Entity. */ export type EntityConfig = { /** * Custom function to generate IDs for new entities. * If not provided, defaults to UUID v7 (requires Id to be string). */ generateId?: () => Id; }; /** * Base type for entity data props. */ export type TEntity = { [key: string]: unknown; id?: Id; }; /** * An object whose definition is based on `identity` over just its attributes. * * Also known as `Reference Objects`. * * @typeParam T - The shape of the entity's data properties * @typeParam Id - The type of the entity's identifier (defaults to string) */ export declare abstract class AbstractEntity, Id = string> implements Entity { private readonly _id; protected readonly _data: Omit; /** * Creates a new Entity instance. * * @param data - The entity data, optionally including an id for reconstitution * @param config - Configuration options including custom generateId function * * @example * // Using default UUID string IDs * class UserEntity extends AbstractEntity<{ name: string }> {} * * @example * // Using custom numeric IDs * class ProductEntity extends AbstractEntity<{ title: string }, number> { * constructor(data: { title: string; id?: number }) { * super(data, { generateId: () => Math.floor(Math.random() * 1000000) }); * } * } */ constructor(data: T, config?: EntityConfig); get id(): Id; equals(object?: AbstractEntity): boolean; } /** * Create the public interface of the resulting Entity. * * This allows you to depend on an abstraction over a concretion. */ export type BuildEntityInterface = Entity & Exclude; //# sourceMappingURL=entity.d.ts.map