import { Requester } from "../requester" ; import { WithError , NullableError } from "../error" ; export type Bookmark = { title : string ; url ? : string ; id : string ; parentId ? : string ; isParent ? : boolean ; } ; export class BookmarkRepository { constructor ( protected readonly requester ) { } public async getTree ( id ) { const [ bookmarks , error ] = await this . requester . execute < Bookmark [ ] > ( { method : "bookmark/getTree" , params : { id : id } , } ) ; if ( bookmarks === null ) { return [ [ ] , error ] ; } return [ bookmarks , error ] ; } public async open ( id ) { return this . requester . executeAsync ( { method : "bookmark/open" , params : { id : id } , } ) ; } public async tabOpen ( ids ) { return this . requester . batchNotify ( ids . map ( id => { return { method : "bookmark/tabOpen" , params : { id : id } } ; } ) ) ; } public async remove ( ids ) { return this . requester . batchNotify ( ids . map ( id => { return { method : "bookmark/remove" , params : { id : id } } ; } ) ) ; } }