interface Command

Defines a command handler in Eventicle’s CQRS architecture.

Commands encapsulate business operations that change system state and emit domain events. They provide the "C" in CQRS, handling write operations while maintaining strong consistency and business rule enforcement.

I - Input data type for the command  O - Output/response type from the command

Key Features: - *\*Business Logic\**: Encapsulates domain operations and invariants - \**Event Generation\**: Produces events representing state changes - \**Type Safety\**: Strongly-typed input/output contracts - \**Transactional\**: Atomic execution with event emission - \**Scalable\*\*: Can be distributed across multiple instances

Properties

execute

The command handler function. The data will be received from the CommandIntent

This may be called concurrently.

This should attempt to modify the system and then emit events to represent the change.

Signature
execute: (data: I) => Promise<CommandReturn<O>>;

streamToEmit

Target event stream for publishing generated events.

All events returned by the command execution will be published to this stream, making them available to event views, sagas, and other subscribers.

Signature
streamToEmit: string;

type

Unique command type identifier used for registration and dispatch.

Should be descriptive and follow consistent naming conventions (e.g., 'CreateUser', 'ProcessPayment', 'CancelOrder').

Signature
type: string;