forge
Explore
Log in

Don't you dare go Hollow

hezarfen_frontend

Clone
★ 0

0 watching0 forksTypeScript5.5 MiB5fcd955Burak Boduroğlu2 months ago730 commits

note-source.ts44 lines, 2.0 KiBHistoryRawDownload
1import type { NoteFile, Page, PageParams, RagOutput } from "@/api/client";
2import { deleteCourseNoteFileById, deleteCourseNoteRagOutput, getCourseNoteFileBlob, getCourseNoteFileUrl, getCourseNoteFiles, getCourseNoteRag, postCourseNoteFile, postCourseNoteRagReindex } from "@/api/course-notes";
3import { deleteNoteFileById, getNoteFileBlob, getNoteFileUrl, getNoteFiles, postNoteFile } from "@/api/notes";
4
5/**
6 * The file routes behind a note. `/notes` (personal) and `/course-notes` (a
7 * course's notes) expose the same five operations over the same `NoteFile`
8 * shape, so the note components take one of these instead of importing a
9 * single domain's API directly.
10 */
11export type NoteFileSource = {
12 /** Backend cap per note: MAX_NOTE_FILES / MAX_COURSE_NOTE_FILES, both 10. */
13 maxFiles: number;
14 listFiles: (noteId: string, params?: PageParams, signal?: AbortSignal) => Promise<Page<NoteFile>>;
15 uploadFile: (noteId: string, file: File, signal?: AbortSignal) => Promise<NoteFile>;
16 deleteFile: (noteId: string, fileId: string) => Promise<void>;
17 fileUrl: (noteId: string, fileId: string) => string;
18 fileBlob: (noteId: string, fileId: string, signal?: AbortSignal) => Promise<Blob>;
19 /** AI outputs hanging off the note — only course notes have them. */
20 listRagOutputs?: (noteId: string, params?: PageParams, signal?: AbortSignal) => Promise<Page<RagOutput>>;
21 deleteRagOutput?: (noteId: string, outputId: string) => Promise<void>;
22 reindexRag?: (noteId: string) => Promise<void>;
23};
24
25export const personalNoteFiles: NoteFileSource = {
26 maxFiles: 10,
27 listFiles: getNoteFiles,
28 uploadFile: postNoteFile,
29 deleteFile: deleteNoteFileById,
30 fileUrl: getNoteFileUrl,
31 fileBlob: getNoteFileBlob,
32};
33
34export const courseNoteFiles: NoteFileSource = {
35 maxFiles: 10,
36 listFiles: getCourseNoteFiles,
37 uploadFile: postCourseNoteFile,
38 deleteFile: deleteCourseNoteFileById,
39 fileUrl: getCourseNoteFileUrl,
40 fileBlob: getCourseNoteFileBlob,
41 listRagOutputs: getCourseNoteRag,
42 deleteRagOutput: deleteCourseNoteRagOutput,
43 reindexRag: postCourseNoteRagReindex,
44};