import { AbstractDatastore , BinaryFileData , Datastore , DatastoreID , DatastoreOverview , DocMetaSnapshotEventListener , DocMetaSnapshotOpts , DocMetaSnapshotResult , InitResult , PrefsProvider , SnapshotResult } from './Datastore' ; import { DeleteResult } from './Datastore' ; import { WriteFileOpts } from './Datastore' ; import { DatastoreCapabilities } from './Datastore' ; import { Directories } from './Directories' ; import { DocMetaFileRef , DocMetaRef } from './DocMetaRef' ; import { Preconditions } from 'polar-shared/src/Preconditions' ; import { Backend } from 'polar-shared/src/datastore/Backend' ; import { DocFileMeta } from 'polar-shared/src/datastore/DocFileMeta' ; import { Optional } from 'polar-shared/src/util/ts/Optional' ; import { IDocInfo } from 'polar-shared/src/metadata/IDocInfo' ; import { WriteOpts } from './Datastore' ; import { DatastoreMutation } from './DatastoreMutation' ; import { FileRef } from "polar-shared/src/datastore/FileRef" ; import { GetFileOpts } from "polar-shared/src/datastore/IDatastore" ; /**
 * A datastore that just forwards events to the given delegate.
 */ export class DelegatedDatastore extends AbstractDatastore implements Datastore { public readonly id : DatastoreID ; public readonly directories : Directories ; public readonly filesDir : string ; protected readonly delegate : Datastore ; constructor ( delegate ) { super ( ) ; Preconditions . assertPresent ( delegate , 'delegate' ) ; this . id = 'delegated:' + delegate . id ; this . delegate = delegate ; this . directories = new Directories ( ) ; this . filesDir = this . directories . filesDir ; } public contains ( fingerprint ) { return this . delegate . contains ( fingerprint ) ; } public delete ( docMetaFileRef , datastoreMutation ? ) { return this . delegate . delete ( docMetaFileRef , datastoreMutation ) ; } public writeFile ( backend , ref , data , opts ? ) { return this . delegate . writeFile ( backend , ref , data , opts ) ; } public containsFile ( backend , ref ) { return this . delegate . containsFile ( backend , ref ) ; } public getFile ( backend , ref , opts ? ) { return this . delegate . getFile ( backend , ref , opts ) ; } public deleteFile ( backend , ref ) { return this . delegate . deleteFile ( backend , ref ) ; } public getDocMeta ( fingerprint ) { return this . delegate . getDocMeta ( fingerprint ) ; } public async getDocMetaSnapshot ( opts ) { return this . delegate . getDocMetaSnapshot ( opts ) ; } public getDocMetaRefs ( ) { return this . delegate . getDocMetaRefs ( ) ; } public async snapshot ( listener ) { return this . delegate . snapshot ( listener ) ; } public async createBackup ( ) { return this . delegate . createBackup ( ) ; } public init ( ) { return this . delegate . init ( ) ; } public stop ( ) { return this . delegate . stop ( ) ; } public write ( fingerprint , data , docInfo , opts ? ) { return this . delegate . write ( fingerprint , data , docInfo , opts ) ; } public async synchronizeDocs ( ... docMetaRefs ) { return this . delegate . synchronizeDocs ( ... docMetaRefs ) ; } public addDocMetaSnapshotEventListener ( docMetaSnapshotEventListener ) { this . delegate . addDocMetaSnapshotEventListener ( docMetaSnapshotEventListener ) ; } public async overview ( ) { return await this . delegate . overview ( ) ; } public capabilities ( ) { return this . delegate . capabilities ( ) ; } }