import { Projects , ReadModel } from '@boostercloud/framework-core' ; import { UserWithEmail } from '../roles' ; import { ProjectionResult , ReadModelAction , UUID } from '@boostercloud/framework-types' ; import { Product } from '../entities/product' ; import { SKU } from '../common/sku' ; import { Money } from '../common/money' ; @ ReadModel ( { authorize : [ UserWithEmail ] , } ) export class ProductReadModel { public constructor ( readonly id , readonly sku , readonly displayName , readonly description , readonly availability , public deleted , readonly price ? ) { } @ Projects ( Product , 'id' ) public static updateWithProduct ( product ) { if ( product . deleted ) { return ReadModelAction . Delete ; } else { return new ProductReadModel ( product . id , product . sku , product . displayName , product . description , product . availability , product . deleted , product . price ) ; } } }