import { DocInfo } from './DocInfo' ; import { SerializedObject } from './SerializedObject' ; import { Preconditions } from 'polar-shared/src/Preconditions' ; import { AnnotationInfos } from './AnnotationInfos' ; import { Attachment } from './Attachment' ; import { IPageMeta } from "polar-shared/src/metadata/IPageMeta" ; import { IDocInfo } from "polar-shared/src/metadata/IDocInfo" ; import { IDocMeta } from "polar-shared/src/metadata/IDocMeta" ; /**
 * Root metadata for a document including page metadata, and metadata for
 * the specific document.
 */ export class DocMeta extends SerializedObject implements IDocMeta { public docInfo : IDocInfo ; public pageMetas : { [ id ] : IPageMeta ; } ; public annotationInfo = AnnotationInfos . create ( ) ; public version = 2 ; public attachments : { [ id ] : Attachment ; } = { } ; constructor ( docInfo , pageMetas ) { super ( ) ; this . docInfo = docInfo ; this . pageMetas = pageMetas ; } public getPageMeta ( num ) { num = Preconditions . assertPresent ( num , "num" ) ; const pageMeta = this . pageMetas [ num ] ; if ( ! pageMeta ) { throw new Error ( "No pageMeta for page: " + num ) ; } return pageMeta ; } public validate ( ) { Preconditions . assertInstanceOf ( this . docInfo , DocInfo , "docInfo" ) ; Preconditions . assertPresent ( this . pageMetas , "pageMetas" ) ; Preconditions . assertNumber ( this . version , "version" ) ; } }