forge
Explore
Log in

Don't you dare go Hollow

hezarfen_frontend

Clone
★ 0

0 watching0 forksTypeScript5.5 MiB4e0a329Burak Boduroğlu2 months ago537 commits

note-source.ts42 lines, 1.9 KiBHistoryRawDownload
1import type { NoteFile, Page, PageParams, RagOutput } from "@/api/client";
2import { deleteCourseNoteFileById, deleteCourseNoteRagOutput, getCourseNoteFileBlob, getCourseNoteFileUrl, getCourseNoteFiles, getCourseNoteRag, postCourseNoteFile } 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};
23
24export const personalNoteFiles: NoteFileSource = {
25 maxFiles: 10,
26 listFiles: getNoteFiles,
27 uploadFile: postNoteFile,
28 deleteFile: deleteNoteFileById,
29 fileUrl: getNoteFileUrl,
30 fileBlob: getNoteFileBlob,
31};
32
33export const courseNoteFiles: NoteFileSource = {
34 maxFiles: 10,
35 listFiles: getCourseNoteFiles,
36 uploadFile: postCourseNoteFile,
37 deleteFile: deleteCourseNoteFileById,
38 fileUrl: getCourseNoteFileUrl,
39 fileBlob: getCourseNoteFileBlob,
40 listRagOutputs: getCourseNoteRag,
41 deleteRagOutput: deleteCourseNoteRagOutput,
42};