domain-objects
Version:
A simple, convenient way to represent domain objects, leverage domain knowledge, and add runtime validation in your code base.
35 lines • 2.01 kB
JavaScript
;
var _a;
Object.defineProperty(exports, "__esModule", { value: true });
exports.DomainEvent = exports.MARK_AS_DOMAIN_EVENT = 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_EVENT", { enumerable: true, get: function () { return markers_2.MARK_AS_DOMAIN_EVENT; } });
/**
* In Domain Driven Design, an Event is a type of Domain Object for which:
* - properties are immutable (e.g., something happened)
* - identity does matter
* - i.e., it is uniquely identified by what happened and to what
* - i.e., if you change the uniquely identifying properties (when or to what) of an event, it will be considered a new event
* - i.e., not all properties on the event uniquely identify the event
*
* The purpose of a Domain Event is to represent interesting things that happen in the domain.
*
* For example,
* - An `ItemViewedEvent { itemUuid, customerUuid, occurredAt }` is an event. Changing when it `occurredAt` which `customerUuid` did it or which `itemUuid` it happened to would result in a new event.
* - A `PowerSupplyMeasuredEvent { batteryUuid, current, voltage, temperature, occurredAt }` is an event. Changing when it `occurredAt` or which `batteryUuid` it occurred to would result in a new event. Note: changing the `current`, `voltage`, or `temperature` would _not_ result in a new event though, since only one measurement can be made at a time for a `batteryUuid`
*/
class DomainEvent extends DomainObject_1.DomainObject {
}
exports.DomainEvent = DomainEvent;
_a = markers_1.MARK_AS_DOMAIN_EVENT;
/**
* DomainEvent 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.
*/
DomainEvent[_a] = version_1.VERSION;
//# sourceMappingURL=DomainEvent.js.map