import { OrbitStore } from "@withorbit/store-shared" ; import { AttachmentID , AttachmentMIMEType , Event , EventID , } from "@withorbit/core" ; import { SyncAdapter } from "./syncAdapter" ; export class OrbitStoreSyncAdapter implements SyncAdapter { id : string ; private readonly _orbitStore : OrbitStore ; constructor ( orbitStore , syncID ) { this . id = syncID ; this . _orbitStore = orbitStore ; } async putEvents ( events ) { await this . _orbitStore . database . putEvents ( events ) ; } async listEvents ( afterEventID , limit ) { return await this . _orbitStore . database . listEvents ( { afterID : afterEventID ?? undefined , limit , } ) ; } async putAttachment ( contents , id , type ) { await this . _orbitStore . attachmentStore . storeAttachment ( contents , id , type ) ; } async getAttachmentContents ( id ) { return ( await this . _orbitStore . attachmentStore . getAttachment ( id ) ) . contents ; } }