import { ReadModelBeforeFunction , CommandBeforeFunction , CommandInput , UserEnvelope , ReadModelRequestEnvelope , ReadModelInterface , } from '@boostercloud/framework-types' ; export const applyReadModelRequestBeforeFunctions = ( readModelRequestEnvelope , beforeHooks ) : ReadModelRequestEnvelope < ReadModelInterface > => { return beforeHooks . reduce ( ( currentReadModelRequestEnvelope , beforeFunction ) => beforeFunction ( currentReadModelRequestEnvelope ) , readModelRequestEnvelope ) ; } ; export const applyBeforeFunctions = ( commandInput , beforeHooks , currentUser ? ) : CommandInput => { return beforeHooks . reduce ( ( currentInput , before ) => before ( currentInput , currentUser ) , commandInput ) ; } ;