import { Booster } from '../booster' ; import { Class , EntityInterface , ProjectionMetadata , ProjectionResult } from '@boostercloud/framework-types' ; param originEntity export function Projects < TEntity extends EntityInterface > ( originEntity , joinKey ) { return ( readModelClass , methodName ) => { registerProjection ( originEntity . name , { joinKey : joinKey , class : readModelClass , methodName : methodName , } ) ; } ; } function registerProjection ( originName , projectionMetadata ) { Booster . configureCurrentEnv ( ( config ) : void => { const entityProjections = config . projections [ originName ] || [ ] ; if ( entityProjections . indexOf ( projectionMetadata ) < 0 ) { entityProjections . push ( projectionMetadata ) ; config . projections [ originName ] = entityProjections ; } } ) ; } type ProjectionMethod < TEntity , TReadModel > = TypedPropertyDescriptor < ( _ : TEntity , readModel ? : TReadModel ) => ProjectionResult < TReadModel > > ;