import WebinyError from "@webiny/error" ; import { Plugin } from "@webiny/plugins" ; import { Sort } from "elastic-ts" ; export interface ModifySortParams { sort : Sort ; } export interface ModifySortCallable < T extends ModifySortParams > { ( params ) : void ; } export abstract class ElasticsearchSortModifierPlugin < T extends ModifySortParams = ModifySortParams > extends Plugin { private readonly callable ? : ModifySortCallable < T > ; public constructor ( callable ? ) { super ( ) ; this . callable = callable ; } public modifySort ( params ) { if ( typeof this . callable !== "function" ) { throw new WebinyError ( `Missing modification for the sort.` , "SORT_MODIFICATION_MISSING" , { params } ) ; } this . callable ( params ) ; } }