s-private API Documentation - v3.8.1
    Preparing search index...
    noteEntity: { create: (args: CreateNoteArgs) => NoteWithEvent } = ...

    Factory object for Note domain entity operations.

    This is the Aggregate Root for the Notes bounded context.

    Type Declaration

    • create: (args: CreateNoteArgs) => NoteWithEvent

      Creates a new unexported note entity with its domain event.

      When validation of any field fails

      For unexpected errors during creation

    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);
    • CreateNoteArgs for creation parameters
    • NoteWithEvent for return type
    • NotesDomainService for invariant validation (duplicate title check)