s-private API Documentation - v3.8.1
    Preparing search index...
    imageEntity: { create: (args: CreateImageArgs) => ImageWithEvent } = ...

    Factory object for Image domain entity operations.

    This is the Aggregate Root for the Images bounded context.

    Type Declaration

    • create: (args: CreateImageArgs) => ImageWithEvent

      Creates a new unexported image entity with its domain event.

      When validation of any field fails

      For unexpected errors during creation

    As the aggregate root, Image is the only entry point for creating and managing image entities. All image-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 image with its domain event
    const [image, event] = imageEntity.create({
    userId: makeUserId("user-123"),
    path: makePath("image.jpg", true),
    contentType: makeContentType("image/jpeg"),
    fileSize: makeFileSize(1024),
    caller: "addImage",
    });

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