import OrbitAPIClient from "@withorbit/api-client" ; import { AttachmentID , AttachmentMIMEType , Event , EventID , } from "@withorbit/core" ; import { SyncAdapter } from "./syncAdapter" ; export class APISyncAdapter implements SyncAdapter { id : string ; private readonly _apiClient : OrbitAPIClient ; constructor ( apiClient , syncID ) { this . id = syncID ; this . _apiClient = apiClient ; } async listEvents ( afterEventID , limit ) { const response = await this . _apiClient . listEvents2 ( { afterID : afterEventID ?? undefined , limit : limit , } ) ; return response . items ; } async putEvents ( events ) { await this . _apiClient . putEvents2 ( events ) ; } async putAttachment ( contents , id , type ) { await this . _apiClient . putAttachment2 ( id , type , contents ) ; } async getAttachmentContents ( id ) { const { contents } = await this . _apiClient . getAttachment2 ( id ) ; return contents ; } }