UNPKG

domain-objects

Version:

A simple, convenient way to represent domain objects, leverage domain knowledge, and add runtime validation in your code base.

36 lines 1.8 kB
"use strict"; var _a; Object.defineProperty(exports, "__esModule", { value: true }); exports.DomainEntity = exports.MARK_AS_DOMAIN_ENTITY = void 0; const DomainObject_1 = require("./DomainObject"); const markers_1 = require("./markers"); const version_1 = require("./version"); var markers_2 = require("./markers"); Object.defineProperty(exports, "MARK_AS_DOMAIN_ENTITY", { enumerable: true, get: function () { return markers_2.MARK_AS_DOMAIN_ENTITY; } }); /** * In Domain Driven Design, an Entity is a type of Domain Object for which: * - properties change over time * - e.g., it has a lifecycle * - identity matters * - i.e., it represents a distinct existence * - e.g., two entities could have the same properties, differing only by id, and are still considered different entities * - e.g., you can update properties on an entity and it is still considered the same entity * * The purpose of a Domain Entity is to represent objects which have distinct identities, lifecycles, and existence important in the domain. * * For example, * - A `User { uuid, name, address, profilePicture }` is an entity. Properties like `name`, `address`, and `profilePicture` can change over time. * - A `Task { uuid, requestId, status }` is an entity. We expect `status` to change over time as the task goes from, for example, `QUEUED` to `FULFILLED`. */ class DomainEntity extends DomainObject_1.DomainObject { } exports.DomainEntity = DomainEntity; _a = markers_1.MARK_AS_DOMAIN_ENTITY; /** * DomainEntity marker symbol for cross-version compatibility. * * Uses Symbol.for() to create a global symbol that works across different versions * of the domain-objects library. The value is the version string. */ DomainEntity[_a] = version_1.VERSION; //# sourceMappingURL=DomainEntity.js.map