import { NOTES_FILES_CAPABILITY_ID } from "../../../capabilities"; import { backendRequest } from "./backend-rpc"; export interface QuickNoteEntry { id: string; title: string; updatedAt?: number; } export class NotesFiles { constructor(private readonly dataDir: string) {} private invoke(operationId: string, payload: Record = {}): Promise { return backendRequest("capability.invoke", { capabilityId: NOTES_FILES_CAPABILITY_ID, operationId, payload: { dataDir: this.dataDir, ...payload, }, }); } async load(symbol: string): Promise { return this.invoke("load", { symbol, }); } async save(symbol: string, notes: string): Promise { await this.invoke("save", { symbol, notes, }); } async delete(symbol: string): Promise { await this.invoke("delete", { symbol, }); } async loadQuickNotesIndex(): Promise { return this.invoke("loadQuickNotesIndex"); } async saveQuickNotesIndex(entries: QuickNoteEntry[]): Promise { await this.invoke("saveQuickNotesIndex", { entries, }); } quickNoteKey(id: string): string { return `__note-${id}__`; } }