import { FlashcardType } from 'polar-shared/src/metadata/FlashcardType' ; import { VersionedObject } from './VersionedObject' ; import { Text } from 'polar-shared/src/metadata/Text' ; import { Preconditions } from 'polar-shared/src/Preconditions' ; import { ISODateTimeString } from 'polar-shared/src/metadata/ISODateTimeStrings' ; import { Ref } from 'polar-shared/src/metadata/Refs' ; import { IFlashcard } from "polar-shared/src/metadata/IFlashcard" ; export class Flashcard extends VersionedObject implements IFlashcard { public type : FlashcardType ; public fields : { [ key ] : Text ; } ; public archetype : string ; public constructor ( template ) { super ( template ) ; this . type = template . type ; this . fields = template . fields ; this . archetype = template . archetype ; this . guid = template . guid ; this . init ( template ) ; } public validate ( ) { super . validate ( ) ; Preconditions . assertPresent ( this . id , "id" ) ; Preconditions . assertPresent ( this . type , "type" ) ; Preconditions . assertPresent ( this . guid , "guid" ) ; Preconditions . assertPresent ( this . fields , "fields" ) ; Preconditions . assertPresent ( this . archetype , "archetype" ) ; } public static newInstance ( id , guid , created , lastUpdated , type , fields , archetype , ref ) { const result = new Flashcard ( < Flashcard > { id , guid , created , lastUpdated , type , fields , archetype , ref } ) ; return Object . freeze ( result ) ; } }