import { SerializableQuery } from './SerializableQuery'; import { QueryAction, QueryResponseAction } from './QueryAction'; import { EntityName } from '../ValueObject/EntityName'; import { QueryConstructor } from 'ts-eventsourcing/QueryHandling/Query'; /** * Return action for sending the query. * * The action will be picked up by the middleware {@see queryMiddleware} */ export declare const QUERY_TRANSMITTING: (entity: string, query: object | QueryConstructor) => string; /** * The query is transmitted successfully. * * This will **not** say the query is handled successfully!. */ export declare const QUERY_TRANSMITTED_SUCCESSFULLY: (entity: string, query: object | QueryConstructor) => string; /** * The query transmission failed. */ export declare const QUERY_TRANSMISSION_FAILED: (entity: string, query: object | QueryConstructor) => string; /** * The handling of the query failed. */ export declare const QUERY_HANDLING_FAILED: (entity: string, query: object | QueryConstructor) => string; /** * The query failed by any means. */ export declare const QUERY_FAILED: (entity: string, query: object | QueryConstructor) => string; /** * The query succeeded. */ export declare const QUERY_SUCCEEDED: (entity: string, query: object | QueryConstructor) => string; /** * Send a query. * * Will be picked up by the {@see queryMiddleware} * * @example * * sendQuery(new ByeProduct(...), 'BUY PRODUCT') */ export declare function sendQuery(query: SerializableQuery, entity: string, metadata?: { [key: string]: any; }): QueryAction; /** * Will send a query, and return queryHandler status. * * @see listenToQueryHandler * @see sendQuery */ export declare function sendQueryAndListenToHandler(query: SerializableQuery, entity: string, metadata?: { [key: string]: any; }): Promise; /** * Listen to query 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 requestAccount(name: string, password: string) { * return listenToQuery(sendQuery( * new UserRegisterQuery(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 queryHandlerResponseMiddleware} */ export declare function listenToQueryHandler(query: QueryAction): Promise; export declare function queryTransmittedSuccessfully(query: SerializableQuery, entity: string, metadata?: { [key: string]: any; }): QueryAction; export declare function queryTransmissionFailed(query: SerializableQuery, entity: string, error: unknown, metadata?: { [key: string]: any; }): QueryAction; export declare function queryHandledSuccessfully(query: SerializableQuery, entity: string, response: T, metadata?: { [key: string]: any; }): QueryResponseAction; export declare function queryHandledFailed(query: SerializableQuery, entity: string, error: unknown, metadata?: { [key: string]: any; }): QueryAction; export declare function queryFailed(query: SerializableQuery, entity: string, metadata?: { [key: string]: any; }): QueryAction; /** * Convenience function to get query action types. */ export declare function queryHandelingActionTypes(entity: EntityName, query: QueryConstructor): { transmitting: string; transmittingSuccessfully: string; transmittingFailed: string; queryHandlingFailed: string; queryFailed: string; querySucceeded: string; };