export class Entry { constructor ( public id , public title , public content , public date , public link , public read ) { } } export class Abstract { constructor ( public readonly id , public title , public date , public link , public read , public feed , public starred = false , public custom_data ? ) { } static fromEntry ( entry , feed ) { return new Abstract ( entry . id , entry . title , entry . date , entry . link , entry . read , feed ) ; } } export class Summary { constructor ( public link , public title , public catelog = [ ] , public ok = true , public custom_data ? ) { } } export class Storage { private constructor ( private feed , private link , private title , private abstracts , private ok = true , private custom_data ? ) { } static fromSummary ( feed , summary , get ) { return new Storage ( feed , summary . link , summary . title , summary . catelog . map ( get ) , summary . ok , summary . custom_data ) ; } static fromJSON ( json ) { const obj = JSON . parse ( json ) ; return new Storage ( obj . feed , obj . link , obj . title , obj . abstracts , obj . ok , obj . custom_data ) ; } toSummary ( set ) { const summary = new Summary ( this . link , this . title , this . abstracts . map ( abs => abs . id ) , this . ok , this . custom_data ) ; for ( const abstract of this . abstracts ) { set ( abstract . id , abstract ) ; } return [ this . feed , summary ] ; } toJSON ( ) { return JSON . stringify ( { feed : this . feed , link : this . link , title : this . title , abstracts : this . abstracts , ok : this . ok , custom_data : this . custom_data , } ) ; } }