UNPKG

@launchmenu/applet-notes

Version:
116 lines 4.62 kB
import { FieldsFile, FileAutoReloader, FileAutoSaver, IField } from "@launchmenu/core"; import { DataCacher, IDataHook } from "model-react"; import { Note } from "./Note"; import { NoteCategory } from "./NoteCategory"; import { INoteCategoryMetadata } from "./_types/INoteCategoryMetadata"; import { INoteMetadata } from "./_types/INoteMetadata"; import { IDefaultAppearanceRetrievers } from "./_types/IDefaultAppearanceRetrievers"; declare type INotesFile = FieldsFile<{ /** The notes categories */ categories: IField<INoteCategoryMetadata[]>; /** The data for the notes themselves */ notes: IField<INoteMetadata[]>; }>; export declare class NotesSource { protected file: INotesFile; protected loader: FileAutoReloader; protected saver: FileAutoSaver; protected notesDir: string; /** The default appearance */ defaults: IDefaultAppearanceRetrievers; /** * Creates a new notes data source based on the specified file path * @param metadataFilePath The path to the metadata file of the notes * @param defaults The retrievers of the defaults of the notes **/ constructor(metadataFilePath: string, defaults: IDefaultAppearanceRetrievers); /** * Retrieves the path of this source * @returns The path of notes source */ getPath(): string; /** * Retrieves the notes file that the data is stored in * @returns The metadata file that all notes are stored in */ getFile(): INotesFile; /** * Retrieves the path to the directory notes are stored in * @returns The notes storage directory */ getNotesDir(): string; /** * Disposes this source fully */ destroy(): void; /** The notes data retriever that synchronizes with the note data on disk */ protected notes: DataCacher<Note[]>; /** * Updates the metadata of a given note * @param ID The note's ID * @param data The new data for the note (includes ID of the note) */ protected updateNote(ID: string, data?: INoteMetadata): void; /** * Retrieves all the registered notes * @param hook The hook to subscribe to changes * @returns The notes that are registered */ getAllNotes(hook?: IDataHook): Note[]; /** The categories data retriever that synchronizes with the note data on disk */ protected categories: DataCacher<NoteCategory[]>; /** * Updates the metadata of a given category * @param ID The ID of the category to update * @param data The new data for the category (includes ID of the note) */ protected updateCategory(ID: string, data?: INoteCategoryMetadata): void; /** * Retrieves all the note categories * @param hook The hook to subscribe to changes * @returns The note categories */ getAllCategories(hook?: IDataHook): NoteCategory[]; /** * Retrieves the category with a specified ID * @param ID The ID of the category * @param hook The hook to subscribes to changes * @returns The category if it exists */ getCategoryByID(ID: string, hook?: IDataHook): NoteCategory | null; /** * Adds a new note to the system * @param name The name of the note, ID will be based on this if specified * @param ID The ID of the note * @returns The created note */ addNote(name?: string, ID?: string): Promise<Note>; /** * Adds a note to the system, for which a file already exists * @param location The location of the note document * @param name The name of the note to import * @returns The imported note */ importNote(location: string, name?: string): Promise<Note>; /** * Creates a new note with the given information * @param noteData The note data * @returns The created note */ createNote(noteData: INoteMetadata): Promise<Note>; /** * Adds a new note category to the system * @param name The name of the category, ID will be based on this if specified * @param ID The ID of the note category * @returns The created note category */ addNoteCategory(name?: string, ID?: string): Promise<NoteCategory>; /** * Creates a new note category with the given information * @param noteCategoryData The note category data * @returns The created note category */ createNoteCategory(noteCategoryData: INoteCategoryMetadata): Promise<NoteCategory>; } export {}; //# sourceMappingURL=NotesSource.d.ts.map