import Either from '@hexadrop/either'; import DomainError from '@hexadrop/error'; import { Class } from '@hexadrop/types/class'; import Command from './command.js'; import '@hexadrop/types/primitives'; /** * @callback CommandBusCallback * @param {CommandType} command - The command to be executed. * @returns {Either | Promise>} - The result of the command execution. * @template CommandType - The type of the command. */ type CommandBusCallback = (command: CommandType) => Either | Promise>; /** * @interface CommandHandler * @property {CommandBusCallback} run - The method to run the command. * @template CommandType - The type of the command. */ interface CommandHandler { run: CommandBusCallback; } type CommandHandlerClass = Class>; /** * @abstract * @class CommandBus * @description Abstract class representing a command bus. */ declare abstract class CommandBus { /** * @abstract * @method dispatch * @param {Command} command - The command to be dispatched. * @returns {Either | Promise>} - The result of the command dispatch. */ abstract dispatch(command: Command): Either | Promise>; } export { type CommandBusCallback, type CommandHandler, type CommandHandlerClass, CommandBus as default };