hezarfen_frontend
Clone
https://git.tahinli.com/archive/hezarfen_frontend.git
0 watching0 forksTypeScript5.5 MiB5fcd955Burak Boduroğlu2 months ago730 commits
| 1 | import type { NoteFile, Page, PageParams, RagOutput } from "@/api/client"; |
| 2 | import { deleteCourseNoteFileById, deleteCourseNoteRagOutput, getCourseNoteFileBlob, getCourseNoteFileUrl, getCourseNoteFiles, getCourseNoteRag, postCourseNoteFile, postCourseNoteRagReindex } from "@/api/course-notes"; |
| 3 | import { 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 | */ |
| 11 | export 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 | |
| 25 | export const personalNoteFiles: NoteFileSource = { |
| 26 | maxFiles: 10, |
| 27 | listFiles: getNoteFiles, |
| 28 | uploadFile: postNoteFile, |
| 29 | deleteFile: deleteNoteFileById, |
| 30 | fileUrl: getNoteFileUrl, |
| 31 | fileBlob: getNoteFileBlob, |
| 32 | }; |
| 33 | |
| 34 | export 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 | }; |