import { SerializableCommand } from './SerializableCommand'; import { CommandAction, CommandResponseAction } from './CommandAction'; import { CommandConstructor } from 'ts-eventsourcing/CommandHandling/Command'; import { EntityName } from '../ValueObject/EntityName'; /** * Return action for sending the command. * * The action will be picked up by the middleware {@see commandMiddleware} */ export declare const COMMAND_TRANSMITTING: (entity: string, command: object | CommandConstructor) => string; /** * The command is transmitted successfully. * * This will **not** say the command is handled successfully!. */ export declare const COMMAND_TRANSMITTED_SUCCESSFULLY: (entity: string, command: object | CommandConstructor) => string; /** * The command transmission failed. */ export declare const COMMAND_TRANSMISSION_FAILED: (entity: string, command: object | CommandConstructor) => string; /** * The command failed by any means. */ export declare const COMMAND_FAILED: (entity: string, command: object | CommandConstructor) => string; /** * The command handling failed. */ export declare const COMMAND_HANDLING_FAILED: (entity: string, command: object | CommandConstructor) => string; /** * The command succeeded. */ export declare const COMMAND_SUCCEEDED: (entity: string, command: object | CommandConstructor) => string; /** * Send a command. * * Will be picked up by the {@see commandMiddleware} * * @example * * sendCommand(new ByeProduct(...), 'BUY PRODUCT') */ export declare function sendCommand(command: SerializableCommand, entity: string, metadata?: { [key: string]: any; }): CommandAction; /** * Will send a command, and return commandHandler status. * * @see listenToCommandHandler * @see sendCommand */ export declare function sendCommandAndListenToHandler(command: SerializableCommand, entity: string, metadata?: { [key: string]: any; }): Promise; /** * Listen to command handler response or errors. * * The return type is actual not really a promise. The middleware returns the promise when you bind it tor Redux. * * @example * * function registerAccount(name: string, password: string) { * return listenToCommand(sendCommand( * new UserRegisterCommand(name, password), * 'register' * )); * } * * const RegisterForm = ({ register }: { register: (name: string, password: string) => Promise }) => ( * // The form * return
...
; * ); * * const mapDispatchToProps = { register: registerAccount }; * * export const ConnectedRegisterForm = connect( * null, * mapDispatchToProps, * )(RegisterForm); * * Requires {@see commandHandlerResponseMiddleware} */ export declare function listenToCommandHandler(command: CommandAction): Promise; export declare function commandTransmittedSuccessfully(command: SerializableCommand, entity: string, metadata?: { [key: string]: any; }): CommandAction; export declare function commandTransmissionFailed(command: SerializableCommand, entity: string, error: unknown, metadata?: { [key: string]: any; }): CommandAction; export declare function commandHandledSuccessfully(command: SerializableCommand, entity: string, response: T, metadata?: { [key: string]: any; }): CommandResponseAction; export declare function commandFailed(command: SerializableCommand, entity: string, metadata?: { [key: string]: any; }): CommandAction; export declare function commandHandledFailed(command: SerializableCommand, entity: string, error: unknown, metadata?: { [key: string]: any; }): CommandAction; /** * Convenience function to get command action types. */ export declare function commandHandelingActionTypes(entity: EntityName, command: CommandConstructor): { transmitting: string; transmittingSuccessfully: string; transmittingFailed: string; commandFailed: string; commandHandlingFailed: string; commandSucceeded: string; };