import type { BlockedSite } from "./types" import type { ExtensionDatabase } from "./database" export interface BlockedSitesRepo { getAll(): Promise getOne(id: string): Promise insert(input: BlockedSite): Promise update(input: BlockedSite): Promise delete(input: BlockedSite): Promise } export function createBlockedSitesRepo(_db: Promise): BlockedSitesRepo { return { async getAll() { const db = await _db; return await db.getAll("blocked_sites"); }, async getOne(id) { const db = await _db; return await db.get("blocked_sites", id); }, async insert(input) { const db = await _db; await db.add("blocked_sites", input) }, async update(input) { const db = await _db; await db.put("blocked_sites", input) }, async delete(input) { const db = await _db; await db.delete("blocked_sites", input.id) } } }