Base classes and ts declarations for using the domain model pattern with DDD in js
MIT License
A set of base classes used to implement DDD style domain model pattern in JavaScript.
Below outlines the classes provided in this package and the functionality encapsulated in each.
Objects that matter only as the combination of their attributes. Two value objects with the same values for all their attributes are considered equal.
Provides a createdOn date which is can either be set via the constructor or defaults to Moment utc.
Objects that have a distinct identity that runs through time and different representations.
Extends ValueObject
but provides an id to distinguishes the objects identity throughout time. Defaulted to a v4 GUID when not provided.
Cluster of domain objects that can be treated as a single unit and the basic element of transfer of data storage.
Extends Entity
with the additional responsibility of tracking and queuing Events
.
Within these classes the Aggregate takes responsibility for eventing for any entity it manages. Events are stored within the class and made accessible vis the enqueuedEvents
method. The advantages of this approach are;
Captures the memory of something interesting which affects the domain
Used to provide a consistent interface for events from the domain expecting a type
and data
properties via the constructor. The following common event properties are default unless provided;
Intended to be extended by specific event classes that include data validation.
#Example Usage
All classes are exposed at root level.
const { ValueObject } = require('@reynolds/domain');
class Example extends ValueObject {
As are typescript declarations
const { ICreatedOn } = require('@reynolds/domain');
class Example implements ICreatedOn {}