s-private API Documentation - v3.8.1
    Preparing search index...
    articleEntity: { create: (args: CreateArticleArgs) => ArticleWithEvent } = ...

    Factory object for Article domain entity operations.

    This is the Aggregate Root for the Articles bounded context.

    Type Declaration

    • create: (args: CreateArticleArgs) => ArticleWithEvent

      Creates a new unexported article entity with its domain event.

      When validation of any field fails

      For unexpected errors during creation

    As the aggregate root, Article is the only entry point for creating and managing article entities. All article-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 article with its domain event
    const [article, event] = articleEntity.create({
    userId: makeUserId("user-123"),
    categoryName: makeCategoryName("Tech"),
    title: makeArticleTitle("Article Title"),
    url: makeUrl("https://example.com"),
    caller: "addArticle",
    });

    // Persist and dispatch event
    await repository.create(article);
    await eventDispatcher.dispatch(event);