ConstCreates a new unexported note entity with its domain event.
As the aggregate root, Note is the only entry point for creating and managing note entities. All note-related operations must go through this factory to ensure domain invariants are maintained.
Provides immutable entity creation following DDD patterns. All returned entities are frozen using Object.freeze(). Returns a tuple of [entity, event] for domain event dispatching.
// Create a new unexported note with its domain event
const [note, event] = noteEntity.create({
userId: makeUserId("user-123"),
title: makeNoteTitle("Meeting Notes"),
markdown: makeMarkdown("# Content"),
caller: "addNote",
});
// Persist and dispatch event
await repository.create(note);
await eventDispatcher.dispatch(event);
NotesDomainService for invariant validation (duplicate title check)
Factory object for Note domain entity operations.
This is the Aggregate Root for the Notes bounded context.