import Storage, { Collection } from '../core/storage' import Engine from './Engine' export default class RemoteStorage implements Storage { private readonly engine: Engine> constructor( private ownerId: string, private baseUrl: string, private collectionId: string, ) { this.engine = new Engine(baseUrl) } async deleteItem(item: T) { return this.engine.removeItem(this.collectionId, item) } async queryItems() { const response = await this.engine.getCollection(this.collectionId) as Collection; return response.items; } async saveItem(newItem: T) { return this.engine.setItem(this.collectionId, newItem) } }