import { assertIsFromEnum , assertIsNonEmptyString } from "./utils" ; export enum FindingSeverity { Unknown , Info , Low , Medium , High , Critical } export enum FindingType { Unknown , Exploit , Suspicious , Degraded , Info } export class Finding { private constructor ( readonly name , readonly description , readonly alertId , readonly protocol , readonly severity , readonly type , readonly everestId , readonly metadata ) { } toString ( ) { return JSON . stringify ( { ... this , severity : FindingSeverity [ this . severity ] , type : FindingType [ this . type ] } , null , 2 ) ; } static fromObject ( { name , description , alertId , protocol = 'ethereum' , severity , type , everestId , metadata = { } } ) { assertIsNonEmptyString ( name , 'name' ) ; assertIsNonEmptyString ( description , 'description' ) ; assertIsNonEmptyString ( alertId , 'alertId' ) ; assertIsNonEmptyString ( protocol , 'protocol' ) ; assertIsFromEnum ( severity , FindingSeverity , 'severity' ) ; assertIsFromEnum ( type , FindingType , 'type' ) ; return new Finding ( name , description , alertId , protocol , severity , type , everestId , metadata ) ; } }