import { ReadModel , Projects } from '@boostercloud/framework-core' ; import { Admin } from '../roles' ; import { ProjectionResult , UUID } from '@boostercloud/framework-types' ; import { Product } from '../entities/product' ; @ ReadModel ( { authorize : [ Admin ] , } ) export class ProductUpdatesReadModel { public constructor ( readonly id , readonly availability , readonly lastUpdate , readonly previousUpdate ? ) { } @ Projects ( Product , 'id' ) public static updateWithProduct ( product , previous ? ) { return new ProductUpdatesReadModel ( product . id , product . availability , new Date ( ) , previous ?. lastUpdate ) ; } }