@hexadrop/query
Version:
Hexagonal architecture utils library
32 lines (29 loc) • 1.43 kB
TypeScript
import { QueryBusCallback } from './bus.js';
import Query, { QueryClass } from './query.js';
import '@hexadrop/either';
import '@hexadrop/error';
import '@hexadrop/types/class';
import '@hexadrop/types/primitives';
/**
* This is an abstract class named QueryHandlers.
* It provides a structure for handling queries in the application.
*
* @abstract
*/
declare abstract class QueryHandlers {
/**
* This is an abstract method named 'search'.
* It is expected to be implemented by subclasses of QueryHandlers.
* The method takes a query of type 'QueryType' or 'QueryClass<ResponseType, QueryType>' as an argument.
* 'ResponseType' and 'QueryType' are generic parameters where 'QueryType' extends 'Query<ResponseType>'.
* The method should return a 'QueryBusCallback<ResponseType, QueryType>'.
*
* @abstract
* @param {QueryType | QueryClass<ResponseType, QueryType>} query - The query to be searched.
* @returns {QueryBusCallback<ResponseType, QueryType>} - The callback function to be executed when the query is found.
* @template QueryType - The type of the query to be searched.
* @template ResponseType - The type of the response to be returned.
*/
abstract search<ResponseType, QueryType extends Query<ResponseType>>(query: QueryClass<ResponseType, QueryType> | QueryType): QueryBusCallback<ResponseType, QueryType>;
}
export { QueryHandlers as default };