UNPKG

@fluster.io/dev

Version:

563 lines (562 loc) 21.7 kB
import { WebviewWindow as ___WebviewWindow__ } from '@tauri-apps/api/webviewWindow'; /** user-defined commands **/ export declare const commands: { getOperatingSystem(): Promise<Result<SupportedOperatingSystem, FlusterError>>; pathExists(filePath: string): Promise<boolean>; /** * Appends the path to the base_path if it is not already contained within the fs_path. * If the base_path is empty, it will always return the fs_path. */ normalizePath(fsPath: string, basePath: string): Promise<string>; getDashboardData(): Promise<DashboardData>; getQrCodeSvg(content: string): Promise<Result<string, FlusterError>>; getEnvironmentVariable(key: string): Promise<Result<string, FlusterError>>; getTextSimilarity(a: string, b: string): Promise<number>; getUniqueId(): Promise<string>; getTagSearchResults(tagValues: string[]): Promise<Result<TraditionalSearchResults, FlusterError>>; getTopicSearchResults(tagValues: string[]): Promise<Result<TraditionalSearchResults, FlusterError>>; getSubjectSearchResults(tagValues: string[]): Promise<Result<TraditionalSearchResults, FlusterError>>; semanticSearch(query: string, pagination: PaginationProps): Promise<Result<SemanticSearchResults, FlusterError>>; getAllTags(): Promise<Result<SharedTaggableModel[], FlusterError>>; getAllSubjects(): Promise<Result<SharedTaggableModel[], FlusterError>>; getAllTopics(): Promise<Result<SharedTaggableModel[], FlusterError>>; getNotesByBibEntryId(bibEntryId: string): Promise<Result<TraditionalSearchResults, FlusterError>>; /** * Accepts the user defined equation_id field, not the auto-generated id. */ getNotesByEquationId(equationId: string): Promise<Result<TraditionalSearchResults, FlusterError>>; getNoteByDictEntryLabel(dictEntryLabel: string): Promise<Result<TraditionalSearchResults, FlusterError>>; getExistingTaggables(): Promise<AllTaggableData>; /** * This wraps a series of functions handled by the fluster_native_interface package, conditionally * based on user settings and app state. */ syncLocalDatabase(opts: SyncFilesystemDirectoryOptions): Promise<Result<null, FlusterError>>; saveUtf8File(fsPath: string, fileContent: string): Promise<Result<null, FlusterError>>; readUtf8File(fsPath: string): Promise<Result<string, FlusterError>>; readFileToBytes(fsPath: string): Promise<Result<number[], FlusterError>>; writeFile(filePath: string, content: string): Promise<Result<null, FlusterError>>; /** * Make sure to enforce the root directory as a base for globs on the front end, otherwise the * entire computer will be searched. */ fsGlob(globString: string, basePath: string): Promise<string[]>; /** * This a file extension, without a leading '.'. For regular globs use fs_glob. * The n_threads field is a stringified integer representing the number of threads. */ fsFileExtensionGlob(fileExtension: string, basePath: string, nThreads: string): Promise<Result<string[], FlusterError>>; initializeDatabase(): Promise<Result<null, FlusterError>>; initializeDesktop(): Promise<Result<null, FlusterError>>; wipeDatabase(): Promise<Result<null, FlusterError>>; getEmbeddedDoc(id: InternalEmbeddedDocsId): Promise<string>; getDesktopHealthReport(): Promise<DesktopHealthReport>; getEmbeddedDocByRelativePath(fp: string): Promise<Result<string, FlusterError>>; addBookmark(noteFilePath: string): Promise<Result<null, FlusterError>>; removeBookmark(noteFilePath: string): Promise<Result<null, FlusterError>>; getBookmarkedNotes(): Promise<Result<MdxBookmarkData[], FlusterError>>; filePathIsBookmarked(noteFilePath: string): Promise<Result<boolean, FlusterError>>; getDictionaryEntries(): Promise<Result<DictionaryEntryModel[], FlusterError>>; /** * This method is used when the search param fsPath is set. This is similar to the way the app * worked in the previous rendtion when 'prefer fs' was enabled by the user. */ readMdxFromFs(fsPath: string): Promise<Result<MdxNoteGroup, FlusterError>>; readMdxFile(filePath: string): Promise<Result<MdxNoteGroup, FlusterError>>; parseMdxString(mdxContent: string, filePath: string | null): Promise<Result<MdxNoteGroup, FlusterError>>; setLastReadByFilePath(filePath: string): Promise<Result<null, FlusterError>>; removeFrontMatter(mdxContent: string): Promise<string>; getNoteSummaries(pagination: PaginationProps): Promise<Result<NoteSummary[], FlusterError>>; getTocFromMarkdown(markdownContent: string): Promise<Result<TocEntry[], FlusterError>>; getTocFromFsPath(fsPath: string): Promise<Result<TocEntry[], FlusterError>>; mdxNoteFullTextSearch(query: string, pagination: PaginationProps): Promise<Result<MdxNoteGroup[], FlusterError>>; getNoteCount(predicate: string | null): Promise<Result<string, FlusterError>>; getNoteGroupByFilePath(filePath: string): Promise<Result<MdxNoteGroup, FlusterError>>; getNoteByUserProvidedId(userProvidedId: string): Promise<Result<MdxNoteGroup, FlusterError>>; deleteSettingState(settingsId: string): Promise<Result<null, FlusterError>>; saveSettingState(jsonString: string, settingsId: string): Promise<Result<null, FlusterError>>; getSettingState(): Promise<Result<string, FlusterError>>; /** * Returns the string which points the location of mathjax that needs to be passed to the front * end. This is the location that mathjax is copied *to*, not from. */ getMathjaxPath(): Promise<MathjaxData>; getEquations(): Promise<Result<EquationModel[], FlusterError>>; saveEquations(data: EquationModel[]): Promise<Result<null, FlusterError>>; getEquationById(id: string): Promise<Result<EquationModel, FlusterError>>; deleteEquationById(id: string): Promise<Result<null, FlusterError>>; getEquationByUserProvidedId(id: string[]): Promise<Result<EquationModel[], FlusterError>>; grid2d(x: AxisGeneratorProps, y: AxisGeneratorProps): Promise<number[][][]>; logspace(base: number, a: number, b: number, n: string): Promise<number[]>; arange(from: number, to: number, step: number): Promise<number[]>; linspace(from: number, to: number, nItems: string): Promise<number[]>; axisGrid(axis: AxisGeneratorProps): Promise<number[][]>; /** * Note that the values are all in array's and that tags is a 2d array. This is so that for each * index in the snippets array, there is an array at that index in the tags array with the tags * the snippet at that index contains. * While it's weird to think about a database's data in this way, this very similar to how pandas and * polars handle their data. */ saveSnippets(items: SnippetModel[], tags: string[][]): Promise<Result<null, FlusterError>>; getSnippets(opts: GetSnippetsParams): Promise<Result<SnippetModel[], FlusterError>>; deleteSnippetById(id: string): Promise<Result<null, FlusterError>>; getSnippetById(id: string): Promise<Result<[SnippetModel, SharedTaggableModel[]], FlusterError>>; getBibEntries(predicate: string | null, pagination: PaginationProps): Promise<Result<BibEntryModel[], FlusterError>>; getBibEntryCount(predicate: string | null): Promise<Result<string, FlusterError>>; syncBib(entries: BibEntryModel[]): Promise<Result<null, FlusterError>>; saveBibEntries(entries: BibEntryModel[]): Promise<Result<null, FlusterError>>; getBibEntryById(id: string): Promise<Result<BibEntryModel, FlusterError>>; bibEntriesFullTextSearch(query: string, pagination: PaginationProps): Promise<Result<BibEntryModel[], FlusterError>>; getAiChatById(chatId: string): Promise<Result<AiChatData, FlusterError>>; createNewAiChat(label: string): Promise<Result<null, FlusterError>>; getAllAiChats(): Promise<Result<AiChatModel[], FlusterError>>; deleteChatById(chatId: string): Promise<Result<null, FlusterError>>; addAiChatRequest(chatId: string, chatInput: string): Promise<Result<AiChatResponseMessageModel, FlusterError>>; beginEmbeddingModelDownload(): Promise<void>; beginLanguageModelDownload(): Promise<void>; createTask(task: TaskModel, tags: TaskTagModel[]): Promise<Result<null, FlusterError>>; createTaskList(taskList: TaskListModel): Promise<Result<null, FlusterError>>; deleteTaskById(id: string): Promise<Result<null, FlusterError>>; deleteTaskListById(id: string): Promise<Result<null, FlusterError>>; getTaskById(id: string): Promise<Result<TaskModel, FlusterError>>; getTaskListData(listId: string): Promise<Result<TaskListData, FlusterError>>; countTasksInList(id: string): Promise<Result<string, FlusterError>>; getAllTaskLists(): Promise<Result<TaskListModel[], FlusterError>>; getTaskListCount(predicate: string | null): Promise<Result<string, FlusterError>>; getTaskCount(predicate: string | null): Promise<Result<string, FlusterError>>; getIncompleteTasksWithDueDate(): Promise<Result<TaskModel[], FlusterError>>; createNewKanbanBoard(item: KanbanBoardModel): Promise<Result<null, FlusterError>>; deleteKanbanBoardById(id: string): Promise<Result<null, FlusterError>>; deleteKanbanBoardCardById(id: string): Promise<Result<null, FlusterError>>; createNewKanbanBoardCard(item: KanbanCardModel): Promise<Result<null, FlusterError>>; getKanbanBoardById(id: string): Promise<Result<KanbanBoardData, FlusterError>>; getKanbanBoardList(predicate: string | null, pagination: PaginationProps | null): Promise<Result<KanbanBoardListData, FlusterError>>; generateNewToken(length: string): Promise<string>; getPlotlyTheme(themeId: PlotlyTheme): Promise<string>; }; /** user-defined events **/ export declare const events: { setDbConnectionUri: __EventObj__<SetDbConnectionUri> & ((handle: __WebviewWindow__) => __EventObj__<SetDbConnectionUri>); showToast: __EventObj__<ShowToast> & ((handle: __WebviewWindow__) => __EventObj__<ShowToast>); }; /** user-defined constants **/ /** user-defined types **/ /** * A utility struct that combines the ChatModel, AiChatMessageResponse, and AiChatMessageRequest * entities into a single struct. */ export type AiChatData = { chat: AiChatModel; outgoing: AiChatRequestMessageModel[]; incoming: AiChatResponseMessageModel[]; }; /** * The database entity representing a specific chat historys */ export type AiChatModel = { id: string; label: string; ctime: string; }; export type AiChatRequestMessageModel = { id: string; /** * The id of the accompanying AiChatModel row. */ chat_id: string; /** * The user's input as the request body. */ body: string; /** * The stringified unix timestamp of the time the message was sent. */ sent_at: string; }; export type AiChatResponseMessageModel = { id: string; /** * The id of the accompanying AiChatModel row. */ chat_id: string; /** * The user's input as the request body. */ body: string; /** * The stringified unix timestamp of the time the message was received. */ received_at: string; }; export type AllTaggableData = { tags: SharedTaggableModel[]; topics: SharedTaggableModel[]; subjects: SharedTaggableModel[]; }; export type AxisGeneratorProps = { min: number; max: number; count: string; label: string | null; }; export type BibEntryModel = { id: string; user_provided_id: string | null; /** * The json string representing this item's data. */ data: string; ctime: string; html_citation: string; pdf_path: string | null; }; export type DashboardData = Record<string, never>; export type DesktopHealthReport = { database_tables_exist: boolean; /** * This boolean describes the overall health of the desktop app. If any inidividual field * that warrents re-initializing is false, this field will be false. */ healthy: boolean; }; export type DictionaryEntryModel = { /** * Primary Key */ label: string; body: string; /** * The source string for the mdx source that produces this dictionary entry. This is just * a file path for local notes. */ mdx_source: string; ctime: string; }; export type DictionaryEntryModelWithoutSource = { /** * Primary Key */ label: string; body: string; ctime: string; }; export type DownloadingStatus = { /** * The proportion of the app downloaded, between 0 and 1. */ portion: string; /** * The elapsed time in seconds. */ elapsedTime: number; }; export type EquationModel = { /** * This is the traditional id field, generated by uuid. */ id: string; /** * The equation_id field is the 'id' field as provided from the user. This is used to * reference equations throughout their notes in a way that makes sense to the user as * opposed to an arbitrary string. */ equation_id: string | null; /** * The title or label for the equation. */ label: string; /** * The equation latex string. */ body: string; desc: string; /** * Time snippet is initially created. */ ctime: string; /** * Time snippet is last updated. */ utime: string; }; export type FlusterError = "OperatingSystemNotSupported" | "FailToLoadDocs" | { FailToLoadEnvironmentVariable: string; } | "FailToParseDate" | "FailToWriteChatSession" | "FailToReadChatSession" | "NoAiProvidersConfigured" | "FailToGenerateChatResponse" | "FailToLoadModel" | "FailToCreateEmbeddingVector" | "FailToGetSemanticResults" | "FailToCreateQrCode" | "FailToCount" | "NotImplemented" | "FailToCopyFiles" | "FailToWriteFile" | "FailToSaveSettings" | "FailToReadSettings" | "FailToParseBibFile" | "SettingsBibPathNotFound" | "CannotParseBibfile" | "FailToFindDataDirectory" | "FailToCreateIndex" | "FailToSerialize" | "NotFoundById" | "DuplicateId" | "FailToDelete" | "FailToClean" | "FailToCreateTable" | "FailToOpenTable" | "FailToConnect" | "FailToStartDb" | "FailToStopDb" | "FailToCreateEntity" | "FailToCreateSnippet" | "FailToFind" | "FailToFindById" | "FailToCreatePath" | "FailToCreateTag" | "FailToCreateSubject" | { DataDirNotFound: []; } | { FailToClearDirectory: string; } | "FailToCreateTopic" | "FailToLocateStorageDir" | { FailToReadFileSystemPath: string; } | "FailToReadMathjaxFont" | { FailToSaveFile: string; } | { MdxParsingError: string; } | { NoTitleError: string; } | "FailToGatherMdxGroups" | { AttemptedToParseFileWasntFound: string; } | { FailToSaveMdxNote: string; } | /** * Taggables * */ "FailToUpsertTags" | "FailToExecutePython"; /** * This is the model as it exists in the database. All related external tables can be combined to form a * `FrontMatterModel` struct, which more closely represents the front matter as it appears in a * user's notes. */ export type FrontMatterBaseModel = { id: string; mdx_note_file_path: string; /** * The user_provided_id is the id field as it appears in the user's note. The id field in * this struct is generated by Surreal. */ user_provided_id: string | null; title: string; summary: string | null; list_id: string | null; list_index: string | null; subject: string | null; topic: string | null; }; /** * This model mirrors the structure of the front matter as it appears in a user's note, where the * nested entities represent the data as it is stored in the database. This model should handle * all parsing and saving of all nested models. */ export type FrontMatterModel = { id: string; mdx_note_file_path: string; /** * The user_provided_id is the id field as it appears in the user's note. The id field in * this struct is generated by Surreal. */ user_provided_id: string | null; title: string; summary: string | null; list_id: string | null; list_index: string | null; tags: SharedTaggableModel[]; subject: SharedTaggableModel | null; topic: SharedTaggableModel | null; }; export type GetSnippetsParams = { langs: string[] | null; }; export type InternalEmbeddedDocsId = /** * This is the super general public version of the model, designed to peak interest, not * prove the model. */ "ModelIntro" | /** * This is the somewhat academic version of the model. Not fully peer-review worthy, but * who gives a shit. It's right. */ "ModelFull" | /** * How to contribute */ "HowToContribute" | "GettingStarted" | "ColorProps" | "IntroToJsx" | "JupyterSetup" | "QuickReference" | "Mermaid"; export type KanbanBoardData = { board: KanbanBoardModel; }; export type KanbanBoardListData = { boards: KanbanBoardModel[]; }; export type KanbanBoardModel = { id: string; label: string; desc: string | null; }; export type KanbanCardModel = { id: string; label: string; desc: string | null; body: string | null; /** * The id field of the KanbanBoardListModel that contains this entry. */ list_id: string; }; export type MathjaxData = { root: string; main_path: string; font_path: string; }; export type MdxBookmarkData = { note: MdxNoteModel; front_matter: FrontMatterBaseModel; }; export type MdxNoteGroup = { mdx: MdxNoteModel; front_matter: FrontMatterModel; tags: SharedTaggableModel[]; equations: EquationModel[]; dictionary_entries: DictionaryEntryModel[]; citations: BibEntryModel[]; note_links: MdxNoteLinkModel[]; }; export type MdxNoteLinkModel = { mdx_note_file_path_from: string; mdx_user_provided_id_to: string; }; export type MdxNoteModel = { /** * create a new model. This file_path becomes essentially the primary key. */ file_path: string; raw_body: string; ctime: string; /** * This field is updated each time a note is accessed in milliseconds. */ last_read: string; vec: number[]; }; export type NoteSummary = { title: string; file_path: string; }; export type PaginationProps = { per_page: string; page_number: string; }; export type PlotlyTheme = "ggplot2" | "seaborn" | "simple_white" | "plotly" | "plotly_white" | "plotly_dark" | "presentation" | "xgridoff" | "ygridoff" | "gridon" | "none"; export type SearchOrder = "Created"; export type SearchParams = { order: SearchOrder | null; per_page: number | null; page: number | null; }; export type SemanticSearchResults = { notes: MdxNoteGroup[]; }; export type SetDbConnectionUri = { uri: string; }; export type SharedTaggableModel = { value: string; ctime: string; }; export type ShowToast = { title: string; body: string; duration: number; variant: ToastVariant; /** * id is required to allow items to be removed reliably. It just needs to be unique. */ id: string; }; /** * The SnippetModel is the snippet representation that is passed back and forth across language * boundries to get around serialization issues with the SnippetEntity methods. */ export type SnippetModel = { id: string | null; /** * A title or label for the snippet. */ label: string; /** * The code the snippet contains. */ body: string; /** * An optional short description. */ desc: string | null; /** * THe language of the snippet. */ lang: string; /** * The time the snippet was created. */ ctime: string; /** * The time the snippet was last updated. */ utime: string; }; export type SupportedOperatingSystem = "Windows" | "Mac" | "Linux" | "Ios" | "Android" | "NotSupported"; export type SyncFilesystemDirectoryOptions = { dir_path: string; bib_path: string | null; /** * The stringified integer representing the number of threads. */ n_threads: string; use_git_ignore: boolean; /** * defaults to true */ with_ai: boolean; existing_taggables: AllTaggableData; }; export type TaskListData = { list: TaskListModel; items: TaskModel[]; }; export type TaskListModel = { id: string; label: string; desc: string | null; ctime: string; }; export type TaskModel = { id: string; /** * The id of the parent task list. */ task_list_id: string; label: string; /** * notes can be any mdx string. */ notes: string; /** * The optional due date for the task. */ due_at: string | null; /** * Time the task was created. */ ctime: string; complete: boolean; }; export type TaskTagModel = { task_id: string; tag_value: string; }; export type ToastVariant = "Success" | "Info" | "Error"; export type TocEntry = { depth: number; body: string; }; /** * The search results returned froma taggable input or via a traditional text based query. */ export type TraditionalSearchResults = { notes: MdxNoteGroup[]; }; import * as TAURI_API_EVENT from "@tauri-apps/api/event"; type __EventObj__<T> = { listen: (cb: TAURI_API_EVENT.EventCallback<T>) => ReturnType<typeof TAURI_API_EVENT.listen<T>>; once: (cb: TAURI_API_EVENT.EventCallback<T>) => ReturnType<typeof TAURI_API_EVENT.once<T>>; emit: null extends T ? (payload?: T) => ReturnType<typeof TAURI_API_EVENT.emit> : (payload: T) => ReturnType<typeof TAURI_API_EVENT.emit>; }; export type Result<T, E> = { status: "ok"; data: T; } | { status: "error"; error: E; }; export {};