🔌 align three api shapes with the refactored backend
Browse files at this commitaba07ef0257d574fafc8892161df1145c002acf2Parent: 790b1c0- fix
- 🔌 align three api shapes with the refactored backend
5 changed files +635 -630
- src/api/__tests__/auth/auth.test.ts +4 -4
- src/api/__tests__/parents/parents.test.ts +1 -1
- src/api/auth/postRegister.ts +9 -3
- src/api/client/types.ts +620 -621
- src/api/parents/postParentStudent.ts +1 -1
src/api/__tests__/auth/auth.test.tsmodified+4 -4
| @@ -33,12 +33,12 @@ describe("auth API", () => { | ||
| 33 | 33 | }); |
| 34 | 34 | |
| 35 | 35 | it("postRegister calls /auth/register with data", async () => { |
| 36 | - const mockUser = { id: "u2", username: "newuser" }; | |
| 37 | - mockFetchSuccess(mockUser); | |
| 36 | + const mockResponse = { username: "newuser", role: "student" }; | |
| 37 | + mockFetchSuccess(mockResponse); | |
| 38 | 38 | |
| 39 | - const data = { school: "demo", username: "newuser", password: "password", email: "test@test.com" }; | |
| 39 | + const data = { school: "demo", username: "newuser", password: "password" }; | |
| 40 | 40 | const result = await postRegister(data); |
| 41 | - expect(result).toEqual(mockUser); | |
| 41 | + expect(result).toEqual(mockResponse); | |
| 42 | 42 | |
| 43 | 43 | const [url, init] = lastFetchCall(); |
| 44 | 44 | expect(url).toBe("/api/auth/register"); |
src/api/__tests__/parents/parents.test.tsmodified+1 -1
| @@ -32,7 +32,7 @@ describe("parents API", () => { | ||
| 32 | 32 | const [url, init] = lastFetchCall(); |
| 33 | 33 | expect(url).toBe("/api/users/u1/students"); |
| 34 | 34 | expect(init?.method).toBe("POST"); |
| 35 | - expect(init?.body).toBe(JSON.stringify(JSON.stringify({ user_id: "s1" }))); // client.ts stringifies the string again? wait no, if it expects double stringify, we do it. Let's just use the exact string. Actually, let's just use init?.body | |
| 35 | + expect(init?.body).toBe(JSON.stringify({ user_id: "s1" })); | |
| 36 | 36 | }); |
| 37 | 37 | |
| 38 | 38 | it("deleteParentStudent calls /users/:id/students/:studentId", async () => { |
src/api/auth/postRegister.tsmodified+9 -3
| @@ -1,5 +1,5 @@ | ||
| 1 | 1 | import { client } from "../client"; |
| 2 | -import type { User } from "../client"; | |
| 2 | +import type { Role } from "../client"; | |
| 3 | 3 | |
| 4 | 4 | export type RegisterBody = { |
| 5 | 5 | school: string; |
| @@ -7,6 +7,12 @@ export type RegisterBody = { | ||
| 7 | 7 | password: string; |
| 8 | 8 | }; |
| 9 | 9 | |
| 10 | -export function postRegister(body: RegisterBody): Promise<User> { | |
| 11 | - return client<User>("/auth/register", { method: "POST", body }); | |
| 10 | +/** Backend answers 201 {username, role} only — anti-enumeration, no id. */ | |
| 11 | +export type RegisterResponse = { | |
| 12 | + username: string; | |
| 13 | + role: Role; | |
| 14 | +}; | |
| 15 | + | |
| 16 | +export function postRegister(body: RegisterBody): Promise<RegisterResponse> { | |
| 17 | + return client<RegisterResponse>("/auth/register", { method: "POST", body }); | |
| 12 | 18 | } |
src/api/client/types.tsmodified+620 -621
| @@ -13,44 +13,44 @@ export type QuestionKind = "choice" | "text"; | ||
| 13 | 13 | export type AttemptStatus = "in_progress" | "submitted" | "expired"; |
| 14 | 14 | |
| 15 | 15 | export type User = { |
| 16 | - id: string; | |
| 17 | - username: string; | |
| 18 | - role: Role; | |
| 19 | - name: string | null; | |
| 20 | - surname: string | null; | |
| 21 | - email: string | null; | |
| 22 | - phone: string | null; | |
| 23 | - birth_date: string | null; | |
| 24 | - theme: UserTheme | null; | |
| 25 | - language: UserLanguage | null; | |
| 26 | - palette_color: string | null; | |
| 16 | + id: string; | |
| 17 | + username: string; | |
| 18 | + role: Role; | |
| 19 | + name: string | null; | |
| 20 | + surname: string | null; | |
| 21 | + email: string | null; | |
| 22 | + phone: string | null; | |
| 23 | + birth_date: string | null; | |
| 24 | + theme: UserTheme | null; | |
| 25 | + language: UserLanguage | null; | |
| 26 | + palette_color: string | null; | |
| 27 | 27 | }; |
| 28 | 28 | |
| 29 | 29 | // PATCH /users/me and PATCH /users/{id}/profile take the same body: an omitted |
| 30 | 30 | // (or null) field is left alone, an empty string clears it. |
| 31 | 31 | export type ProfileUpdate = { |
| 32 | - name?: string | null; | |
| 33 | - surname?: string | null; | |
| 34 | - email?: string | null; | |
| 35 | - phone?: string | null; | |
| 36 | - birth_date?: string | null; | |
| 37 | - display_name?: string | null; | |
| 38 | - bio?: string | null; | |
| 32 | + name?: string | null; | |
| 33 | + surname?: string | null; | |
| 34 | + email?: string | null; | |
| 35 | + phone?: string | null; | |
| 36 | + birth_date?: string | null; | |
| 37 | + display_name?: string | null; | |
| 38 | + bio?: string | null; | |
| 39 | 39 | }; |
| 40 | 40 | |
| 41 | 41 | export type PersonRef = { |
| 42 | - id: string; | |
| 43 | - username: string; | |
| 44 | - display_name: string | null; | |
| 42 | + id: string; | |
| 43 | + username: string; | |
| 44 | + display_name: string | null; | |
| 45 | 45 | }; |
| 46 | 46 | |
| 47 | 47 | // The lifetime counter a badge reads. Badges sharing a stat form a ladder. |
| 48 | 48 | export type BadgeStat = |
| 49 | - | "homework_submitted" | |
| 50 | - | "homework_on_time" | |
| 51 | - | "exam_sat" | |
| 52 | - | "pomodoro_finished" | |
| 53 | - | "pomodoro_focus_ms"; | |
| 49 | + | "homework_submitted" | |
| 50 | + | "homework_on_time" | |
| 51 | + | "exam_sat" | |
| 52 | + | "pomodoro_finished" | |
| 53 | + | "pomodoro_focus_ms"; | |
| 54 | 54 | |
| 55 | 55 | // One entry of the badge catalogue, served by GET /limits. The label and icon |
| 56 | 56 | // behind an id live in the client, exactly as they do for a role. |
| @@ -69,254 +69,254 @@ export type ProfileCourseRef = { id: string; title: string; kind: CourseKind }; | ||
| 69 | 69 | // Lifetime counters behind the badge ladders, plus the two live totals the |
| 70 | 70 | // capped `classes`/`courses` lists would otherwise hide. |
| 71 | 71 | export type ProfileStats = { |
| 72 | - pomodoro_sessions: number; | |
| 73 | - pomodoro_focus_ms: number; | |
| 74 | - courses: number; | |
| 75 | - classes: number; | |
| 76 | - homework_submitted_total: number; | |
| 77 | - homework_on_time_total: number; | |
| 78 | - exam_sat_total: number; | |
| 79 | - pomodoro_finished_total: number; | |
| 80 | - pomodoro_focus_ms_total: number; | |
| 72 | + pomodoro_sessions: number; | |
| 73 | + pomodoro_focus_ms: number; | |
| 74 | + courses: number; | |
| 75 | + classes: number; | |
| 76 | + homework_submitted_total: number; | |
| 77 | + homework_on_time_total: number; | |
| 78 | + exam_sat_total: number; | |
| 79 | + pomodoro_finished_total: number; | |
| 80 | + pomodoro_focus_ms_total: number; | |
| 81 | 81 | }; |
| 82 | 82 | |
| 83 | 83 | // A person's public profile. Readable by any authenticated account except a |
| 84 | 84 | // parent, who only reaches their own and their linked students'. Never carries |
| 85 | 85 | // email, phone or birth date at any role — those stay on GET /users/{id}. |
| 86 | 86 | export type Profile = { |
| 87 | - id: string; | |
| 88 | - username: string; | |
| 89 | - display_name: string | null; | |
| 90 | - role: Role; | |
| 91 | - bio: string | null; | |
| 92 | - avatar: AvatarMeta | null; | |
| 93 | - // Capped at limits.user.max_profile_classes; stats.classes holds the true total. | |
| 94 | - classes: ProfileClassRef[]; | |
| 95 | - // Capped at limits.user.max_profile_courses, and filtered to what the reader | |
| 96 | - // may see; stats.courses holds the owner's true, unfiltered total. | |
| 97 | - courses: ProfileCourseRef[]; | |
| 98 | - badges: EarnedBadge[]; | |
| 99 | - stats: ProfileStats; | |
| 87 | + id: string; | |
| 88 | + username: string; | |
| 89 | + display_name: string | null; | |
| 90 | + role: Role; | |
| 91 | + bio: string | null; | |
| 92 | + avatar: AvatarMeta | null; | |
| 93 | + // Capped at limits.user.max_profile_classes; stats.classes holds the true total. | |
| 94 | + classes: ProfileClassRef[]; | |
| 95 | + // Capped at limits.user.max_profile_courses, and filtered to what the reader | |
| 96 | + // may see; stats.courses holds the owner's true, unfiltered total. | |
| 97 | + courses: ProfileCourseRef[]; | |
| 98 | + badges: EarnedBadge[]; | |
| 99 | + stats: ProfileStats; | |
| 100 | 100 | }; |
| 101 | 101 | |
| 102 | 102 | export type Note = { |
| 103 | - id: string; | |
| 104 | - title: string; | |
| 105 | - content: string; | |
| 103 | + id: string; | |
| 104 | + title: string; | |
| 105 | + content: string; | |
| 106 | 106 | }; |
| 107 | 107 | |
| 108 | 108 | /** A note attached to a course; files reuse the personal note's `NoteFile` shape. */ |
| 109 | 109 | export type CourseNote = { |
| 110 | - id: string; | |
| 111 | - course: string; | |
| 112 | - title: string; | |
| 113 | - content: string; | |
| 110 | + id: string; | |
| 111 | + course: string; | |
| 112 | + title: string; | |
| 113 | + content: string; | |
| 114 | 114 | }; |
| 115 | 115 | |
| 116 | 116 | /** One AI service output stored against a course note. `payload` is the |
| 117 | 117 | * service's own shape — stored and served unread, rendered as JSON. */ |
| 118 | 118 | export type RagOutput = { |
| 119 | - id: string; | |
| 120 | - course_note: string; | |
| 121 | - course: string; | |
| 122 | - /** The note's file attachments the output was built from. */ | |
| 123 | - sources: string[]; | |
| 124 | - payload: unknown; | |
| 125 | - /** When the backend stored it, epoch milliseconds. */ | |
| 126 | - generated_at: number; | |
| 119 | + id: string; | |
| 120 | + course_note: string; | |
| 121 | + course: string; | |
| 122 | + /** The note's file attachments the output was built from. */ | |
| 123 | + sources: string[]; | |
| 124 | + payload: unknown; | |
| 125 | + /** When the backend stored it, epoch milliseconds. */ | |
| 126 | + generated_at: number; | |
| 127 | 127 | }; |
| 128 | 128 | |
| 129 | 129 | export type NoteFile = { |
| 130 | - id: string; | |
| 131 | - name: string; | |
| 132 | - content_type: string; | |
| 133 | - size: number; | |
| 130 | + id: string; | |
| 131 | + name: string; | |
| 132 | + content_type: string; | |
| 133 | + size: number; | |
| 134 | 134 | }; |
| 135 | 135 | |
| 136 | 136 | /** The caller's school entitlements: every switched-on module, sorted by name. */ |
| 137 | 137 | export type EnabledModules = { |
| 138 | - enabled: string[]; | |
| 138 | + enabled: string[]; | |
| 139 | 139 | }; |
| 140 | 140 | |
| 141 | 141 | export type ModuleCatalogEntry = { |
| 142 | - module: string; | |
| 143 | - package: string; | |
| 144 | - /** Modules that must be enabled alongside this one. */ | |
| 145 | - requires: string[]; | |
| 142 | + module: string; | |
| 143 | + package: string; | |
| 144 | + /** Modules that must be enabled alongside this one. */ | |
| 145 | + requires: string[]; | |
| 146 | 146 | }; |
| 147 | 147 | |
| 148 | 148 | export type ModuleCatalogPackage = { |
| 149 | - package: string; | |
| 150 | - modules: string[]; | |
| 149 | + package: string; | |
| 150 | + modules: string[]; | |
| 151 | 151 | }; |
| 152 | 152 | |
| 153 | 153 | /** The deployment's whole module catalog — identical for every school. */ |
| 154 | 154 | export type ModuleCatalog = { |
| 155 | - modules: ModuleCatalogEntry[]; | |
| 156 | - packages: ModuleCatalogPackage[]; | |
| 155 | + modules: ModuleCatalogEntry[]; | |
| 156 | + packages: ModuleCatalogPackage[]; | |
| 157 | 157 | }; |
| 158 | 158 | |
| 159 | 159 | export type EventAudience = |
| 160 | - | { kind: "school" } | |
| 161 | - | { kind: "role"; role: Role } | |
| 162 | - | { kind: "course"; course: string } | |
| 163 | - | { kind: "registration"; capacity?: number | null }; | |
| 160 | + | { kind: "school" } | |
| 161 | + | { kind: "role"; role: Role } | |
| 162 | + | { kind: "course"; course: string } | |
| 163 | + | { kind: "registration"; capacity?: number | null }; | |
| 164 | 164 | |
| 165 | 165 | export type Event = { |
| 166 | - id: string; | |
| 167 | - creator: string; | |
| 168 | - title: string; | |
| 169 | - description: string; | |
| 170 | - audience: EventAudience; | |
| 171 | - starts_at: number | null; | |
| 172 | - ends_at: number | null; | |
| 166 | + id: string; | |
| 167 | + creator: string; | |
| 168 | + title: string; | |
| 169 | + description: string; | |
| 170 | + audience: EventAudience; | |
| 171 | + starts_at: number | null; | |
| 172 | + ends_at: number | null; | |
| 173 | 173 | }; |
| 174 | 174 | |
| 175 | 175 | export type Attendance = { |
| 176 | - id: string; | |
| 177 | - event: string; | |
| 178 | - user: PersonRef; | |
| 179 | - status: AttendanceStatus; | |
| 180 | - marked_by: PersonRef; | |
| 176 | + id: string; | |
| 177 | + event: string; | |
| 178 | + user: PersonRef; | |
| 179 | + status: AttendanceStatus; | |
| 180 | + marked_by: PersonRef; | |
| 181 | 181 | }; |
| 182 | 182 | |
| 183 | 183 | export type EventRosterEntry = { |
| 184 | - user: PersonRef; | |
| 185 | - status: AttendanceStatus | null; | |
| 186 | - marked_by: PersonRef | null; | |
| 184 | + user: PersonRef; | |
| 185 | + status: AttendanceStatus | null; | |
| 186 | + marked_by: PersonRef | null; | |
| 187 | 187 | }; |
| 188 | 188 | |
| 189 | 189 | export type EventRegistration = { |
| 190 | - event: string; | |
| 191 | - user: PersonRef; | |
| 192 | - registered_by: PersonRef; | |
| 190 | + event: string; | |
| 191 | + user: PersonRef; | |
| 192 | + registered_by: PersonRef; | |
| 193 | 193 | }; |
| 194 | 194 | |
| 195 | 195 | export type AppointmentStatus = "pending" | "approved" | "rejected" | "cancelled"; |
| 196 | 196 | |
| 197 | 197 | export type AppointmentSlot = { |
| 198 | - id: string; | |
| 199 | - teacher: PersonRef; | |
| 200 | - starts_at: number; // unix ms UTC | |
| 201 | - ends_at: number; // unix ms UTC, half-open | |
| 202 | - note: string | null; | |
| 203 | - series: string | null; // null = one-off; shared id across a weekly series | |
| 204 | - created_at: number; | |
| 198 | + id: string; | |
| 199 | + teacher: PersonRef; | |
| 200 | + starts_at: number; // unix ms UTC | |
| 201 | + ends_at: number; // unix ms UTC, half-open | |
| 202 | + note: string | null; | |
| 203 | + series: string | null; // null = one-off; shared id across a weekly series | |
| 204 | + created_at: number; | |
| 205 | 205 | }; |
| 206 | 206 | |
| 207 | 207 | export type Appointment = { |
| 208 | - id: string; | |
| 209 | - slot: string; | |
| 210 | - teacher: PersonRef | null; // null only if slot vanished | |
| 211 | - requester: PersonRef; | |
| 212 | - status: AppointmentStatus; | |
| 213 | - reason: string; | |
| 214 | - starts_at: number | null; // effective window: the proposal whenever one is on the | |
| 215 | - // row (accepted or not), else the slot's own time | |
| 216 | - ends_at: number | null; | |
| 217 | - proposed_starts_at: number | null; | |
| 218 | - proposed_ends_at: number | null; | |
| 219 | - proposed_by: PersonRef | null; | |
| 220 | - decided_by: PersonRef | null; // null while pending | |
| 221 | - cancelled_by: PersonRef | null; // set only when status === "cancelled" | |
| 222 | - cancel_reason: string | null; // optional reason, null when none given | |
| 223 | - reject_reason: string | null; // optional reason when status === "rejected" (rejecter is decided_by) | |
| 224 | - created_at: number; | |
| 208 | + id: string; | |
| 209 | + slot: string; | |
| 210 | + teacher: PersonRef | null; // null only if slot vanished | |
| 211 | + requester: PersonRef; | |
| 212 | + status: AppointmentStatus; | |
| 213 | + reason: string; | |
| 214 | + starts_at: number | null; // effective window: the proposal whenever one is on the | |
| 215 | + // row (accepted or not), else the slot's own time | |
| 216 | + ends_at: number | null; | |
| 217 | + proposed_starts_at: number | null; | |
| 218 | + proposed_ends_at: number | null; | |
| 219 | + proposed_by: PersonRef | null; | |
| 220 | + decided_by: PersonRef | null; // null while pending | |
| 221 | + cancelled_by: PersonRef | null; // set only when status === "cancelled" | |
| 222 | + cancel_reason: string | null; // optional reason, null when none given | |
| 223 | + reject_reason: string | null; // optional reason when status === "rejected" (rejecter is decided_by) | |
| 224 | + created_at: number; | |
| 225 | 225 | }; |
| 226 | 226 | |
| 227 | 227 | export const APPOINTMENT_LIMITS = { |
| 228 | - noteMaxLen: 500, // MAX_APPOINTMENT_NOTE_LEN, empty allowed | |
| 229 | - reasonMaxLen: 1000, // MAX_APPOINTMENT_REASON_LEN, non-blank required | |
| 230 | - maxSlotOccurrences: 52, // MAX_SLOT_OCCURRENCES for repeat_weekly | |
| 228 | + noteMaxLen: 500, // MAX_APPOINTMENT_NOTE_LEN, empty allowed | |
| 229 | + reasonMaxLen: 1000, // MAX_APPOINTMENT_REASON_LEN, non-blank required | |
| 230 | + maxSlotOccurrences: 52, // MAX_SLOT_OCCURRENCES for repeat_weekly | |
| 231 | 231 | } as const; |
| 232 | 232 | |
| 233 | 233 | export const BANK_QUESTION_LIMITS = { |
| 234 | - textMaxLen: 2000, // MAX_QUESTION_TEXT_LEN | |
| 235 | - choiceTextMaxLen: 500, // MAX_CHOICE_TEXT_LEN | |
| 236 | - minPoints: 1, // MIN_QUESTION_POINTS | |
| 237 | - maxPoints: 100, // MAX_QUESTION_POINTS | |
| 238 | - minChoices: 2, // MIN_QUESTION_CHOICES | |
| 239 | - maxChoices: 10, // MAX_QUESTION_CHOICES | |
| 234 | + textMaxLen: 2000, // MAX_QUESTION_TEXT_LEN | |
| 235 | + choiceTextMaxLen: 500, // MAX_CHOICE_TEXT_LEN | |
| 236 | + minPoints: 1, // MIN_QUESTION_POINTS | |
| 237 | + maxPoints: 100, // MAX_QUESTION_POINTS | |
| 238 | + minChoices: 2, // MIN_QUESTION_CHOICES | |
| 239 | + maxChoices: 10, // MAX_QUESTION_CHOICES | |
| 240 | 240 | } as const; |
| 241 | 241 | |
| 242 | 242 | export type Course = { |
| 243 | - id: string; | |
| 244 | - creator: PersonRef; | |
| 245 | - teachers?: PersonRef[]; | |
| 246 | - title: string; | |
| 247 | - description: string; | |
| 248 | - kind: CourseKind; | |
| 249 | - term: string | null; | |
| 250 | - capacity: number | null; | |
| 243 | + id: string; | |
| 244 | + creator: PersonRef; | |
| 245 | + teachers?: PersonRef[]; | |
| 246 | + title: string; | |
| 247 | + description: string; | |
| 248 | + kind: CourseKind; | |
| 249 | + term: string | null; | |
| 250 | + capacity: number | null; | |
| 251 | 251 | }; |
| 252 | 252 | |
| 253 | 253 | export type Term = { |
| 254 | - id: string; | |
| 255 | - name: string; | |
| 256 | - starts_at: number; | |
| 257 | - ends_at: number; | |
| 258 | - /** Archived at, UTC unix-millis; null while the term is open. */ | |
| 259 | - archived_at: number | null; | |
| 254 | + id: string; | |
| 255 | + name: string; | |
| 256 | + starts_at: number; | |
| 257 | + ends_at: number; | |
| 258 | + /** Archived at, UTC unix-millis; null while the term is open. */ | |
| 259 | + archived_at: number | null; | |
| 260 | 260 | }; |
| 261 | 261 | |
| 262 | 262 | export type Enrollment = { |
| 263 | - id: string; | |
| 264 | - course: string; | |
| 265 | - user: PersonRef; | |
| 266 | - enrolled_by: PersonRef; | |
| 267 | - // The class (ClassGroup id) that pumped this enrollment, or null for a | |
| 268 | - // hand-placed row. A row with a source is swept when that class drops the | |
| 269 | - // student or detaches the course; a null row is permanent. | |
| 270 | - source: string | null; | |
| 263 | + id: string; | |
| 264 | + course: string; | |
| 265 | + user: PersonRef; | |
| 266 | + enrolled_by: PersonRef; | |
| 267 | + // The class (ClassGroup id) that pumped this enrollment, or null for a | |
| 268 | + // hand-placed row. A row with a source is swept when that class drops the | |
| 269 | + // student or detaches the course; a null row is permanent. | |
| 270 | + source: string | null; | |
| 271 | 271 | }; |
| 272 | 272 | |
| 273 | 273 | // A class (şube): a named group of students, optionally tied to a term, that |
| 274 | 274 | // pumps the Cartesian product of its members × attached courses into real |
| 275 | 275 | // enrollment rows. See src/api/classes. |
| 276 | 276 | export type ClassGroup = { |
| 277 | - id: string; | |
| 278 | - // null for a caller below teacher+ — the office's account names are not | |
| 279 | - // theirs to learn (a student's own GET /classes/me, a parent's | |
| 280 | - // GET /classes/user/{user}). | |
| 281 | - creator: PersonRef | null; | |
| 282 | - name: string; | |
| 283 | - grade: string | null; | |
| 284 | - term: string | null; | |
| 285 | - // The class's homeroom teacher (sınıf öğretmeni); null when none is assigned. | |
| 286 | - teacher: PersonRef | null; | |
| 277 | + id: string; | |
| 278 | + // null for a caller below teacher+ — the office's account names are not | |
| 279 | + // theirs to learn (a student's own GET /classes/me, a parent's | |
| 280 | + // GET /classes/user/{user}). | |
| 281 | + creator: PersonRef | null; | |
| 282 | + name: string; | |
| 283 | + grade: string | null; | |
| 284 | + term: string | null; | |
| 285 | + // The class's homeroom teacher (sınıf öğretmeni); null when none is assigned. | |
| 286 | + teacher: PersonRef | null; | |
| 287 | 287 | }; |
| 288 | 288 | |
| 289 | 289 | export type ClassMember = { |
| 290 | - id: string; | |
| 291 | - class: string; | |
| 292 | - user: PersonRef; | |
| 293 | - added_by: PersonRef; | |
| 290 | + id: string; | |
| 291 | + class: string; | |
| 292 | + user: PersonRef; | |
| 293 | + added_by: PersonRef; | |
| 294 | 294 | }; |
| 295 | 295 | |
| 296 | 296 | export type ClassCourse = { |
| 297 | - id: string; | |
| 298 | - class: string; | |
| 299 | - course: string; | |
| 300 | - attached_by: PersonRef; | |
| 297 | + id: string; | |
| 298 | + class: string; | |
| 299 | + course: string; | |
| 300 | + attached_by: PersonRef; | |
| 301 | 301 | }; |
| 302 | 302 | |
| 303 | 303 | // A grade blueprint: the set of courses every class at one grade takes. The |
| 304 | 304 | // grade label is the record's key, so there is at most one per grade. Creating |
| 305 | 305 | // or editing one applies it to every existing class at that grade right away. |
| 306 | 306 | export type ClassBlueprint = { |
| 307 | - grade: string; | |
| 308 | - courses: string[]; | |
| 309 | - creator: PersonRef; | |
| 307 | + grade: string; | |
| 308 | + courses: string[]; | |
| 309 | + creator: PersonRef; | |
| 310 | 310 | }; |
| 311 | 311 | |
| 312 | 312 | // One (class, course) pair a blueprint could not attach. Applying is |
| 313 | 313 | // best-effort: a pair that cannot land is reported here and the rest still go |
| 314 | 314 | // through. `reason` is backend English — localize it, never render it raw. |
| 315 | 315 | export type BlueprintSkip = { |
| 316 | - class: string; | |
| 317 | - class_name: string; | |
| 318 | - course: string; | |
| 319 | - reason: string; | |
| 316 | + class: string; | |
| 317 | + class_name: string; | |
| 318 | + course: string; | |
| 319 | + reason: string; | |
| 320 | 320 | }; |
| 321 | 321 | |
| 322 | 322 | export type BlueprintResult = { blueprint: ClassBlueprint; skipped: BlueprintSkip[] }; |
| @@ -325,85 +325,85 @@ export type BlueprintApplyResult = { skipped: BlueprintSkip[] }; | ||
| 325 | 325 | |
| 326 | 326 | /** One section measured against its grade's blueprint. */ |
| 327 | 327 | export type BlueprintSectionStatus = { |
| 328 | - class: string; | |
| 329 | - class_name: string; | |
| 330 | - /** Template courses the section does not carry; empty when in sync. */ | |
| 331 | - missing: string[]; | |
| 328 | + class: string; | |
| 329 | + class_name: string; | |
| 330 | + /** Template courses the section does not carry; empty when in sync. */ | |
| 331 | + missing: string[]; | |
| 332 | 332 | }; |
| 333 | 333 | |
| 334 | 334 | /** Every section at a grade with the template courses it is missing. */ |
| 335 | 335 | export type BlueprintStatus = { |
| 336 | - grade: string; | |
| 337 | - /** The template every section below is measured against. */ | |
| 338 | - courses: string[]; | |
| 339 | - matched: number; | |
| 340 | - sections: BlueprintSectionStatus[]; | |
| 336 | + grade: string; | |
| 337 | + /** The template every section below is measured against. */ | |
| 338 | + courses: string[]; | |
| 339 | + matched: number; | |
| 340 | + sections: BlueprintSectionStatus[]; | |
| 341 | 341 | }; |
| 342 | 342 | |
| 343 | 343 | export type CourseSession = { |
| 344 | - id: string; | |
| 345 | - course: string; | |
| 346 | - teacher: PersonRef; | |
| 347 | - topic: string; | |
| 348 | - starts_at: number; | |
| 349 | - ends_at: number | null; | |
| 344 | + id: string; | |
| 345 | + course: string; | |
| 346 | + teacher: PersonRef; | |
| 347 | + topic: string; | |
| 348 | + starts_at: number; | |
| 349 | + ends_at: number | null; | |
| 350 | 350 | }; |
| 351 | 351 | |
| 352 | 352 | export type SessionAttendance = { |
| 353 | - id: string; | |
| 354 | - session: string; | |
| 355 | - course: string; | |
| 356 | - user: PersonRef; | |
| 357 | - status: AttendanceStatus; | |
| 358 | - marked_by: PersonRef; | |
| 353 | + id: string; | |
| 354 | + session: string; | |
| 355 | + course: string; | |
| 356 | + user: PersonRef; | |
| 357 | + status: AttendanceStatus; | |
| 358 | + marked_by: PersonRef; | |
| 359 | 359 | }; |
| 360 | 360 | |
| 361 | 361 | export type Exam = { |
| 362 | - id: string; | |
| 363 | - creator: string; | |
| 364 | - course: string; | |
| 365 | - title: string; | |
| 366 | - description: string; | |
| 367 | - kind: ExamKind | string; | |
| 368 | - mode: ExamMode | string | null; | |
| 369 | - starts_at: number | null; | |
| 370 | - ends_at: number | null; | |
| 371 | - duration_ms: number | null; | |
| 372 | - max_attempts: number; | |
| 373 | - allow_rejoin: boolean; | |
| 374 | - allow_review: boolean; | |
| 375 | - draft: boolean; | |
| 362 | + id: string; | |
| 363 | + creator: string; | |
| 364 | + course: string; | |
| 365 | + title: string; | |
| 366 | + description: string; | |
| 367 | + kind: ExamKind | string; | |
| 368 | + mode: ExamMode | string | null; | |
| 369 | + starts_at: number | null; | |
| 370 | + ends_at: number | null; | |
| 371 | + duration_ms: number | null; | |
| 372 | + max_attempts: number; | |
| 373 | + allow_rejoin: boolean; | |
| 374 | + allow_review: boolean; | |
| 375 | + draft: boolean; | |
| 376 | 376 | }; |
| 377 | 377 | |
| 378 | 378 | export type ImageMeta = { |
| 379 | - content_type: string; | |
| 380 | - size: number; | |
| 379 | + content_type: string; | |
| 380 | + size: number; | |
| 381 | 381 | }; |
| 382 | 382 | |
| 383 | 383 | export type ExamResult = { |
| 384 | - id: string; | |
| 385 | - exam: string; | |
| 386 | - user: PersonRef; | |
| 387 | - mark: number; | |
| 388 | - graded_by: PersonRef; | |
| 384 | + id: string; | |
| 385 | + exam: string; | |
| 386 | + user: PersonRef; | |
| 387 | + mark: number; | |
| 388 | + graded_by: PersonRef; | |
| 389 | 389 | }; |
| 390 | 390 | |
| 391 | 391 | /** One option of a choice question. `id` is stable across edits, so its image survives. */ |
| 392 | 392 | export type Choice = { id: string; text: string }; |
| 393 | 393 | |
| 394 | 394 | export type ExamQuestion = { |
| 395 | - id: string; | |
| 396 | - exam: string; | |
| 397 | - subject: string; | |
| 398 | - text: string; | |
| 399 | - kind: QuestionKind; | |
| 400 | - points: number; | |
| 401 | - choices: Choice[] | null; | |
| 402 | - correct: string | null; | |
| 403 | - image?: ImageMeta | null; | |
| 404 | - choice_images?: (ImageMeta | null)[] | null; | |
| 405 | - from_bank?: string | null; // bank template this question was added from, if any | |
| 406 | - banked_as?: string | null; // bank template last created by saving this question, if any | |
| 395 | + id: string; | |
| 396 | + exam: string; | |
| 397 | + subject: string; | |
| 398 | + text: string; | |
| 399 | + kind: QuestionKind; | |
| 400 | + points: number; | |
| 401 | + choices: Choice[] | null; | |
| 402 | + correct: string | null; | |
| 403 | + image?: ImageMeta | null; | |
| 404 | + choice_images?: (ImageMeta | null)[] | null; | |
| 405 | + from_bank?: string | null; // bank template this question was added from, if any | |
| 406 | + banked_as?: string | null; // bank template last created by saving this question, if any | |
| 407 | 407 | }; |
| 408 | 408 | |
| 409 | 409 | /** `private`: owner + admins only. `school`: every teacher can see it and its answer key. */ |
| @@ -411,372 +411,371 @@ export type BankVisibility = "private" | "school"; | ||
| 411 | 411 | |
| 412 | 412 | /** Reusable question stored in the school-wide question bank, outside any exam. */ |
| 413 | 413 | export type BankQuestion = { |
| 414 | - id: string; | |
| 415 | - owner: string; // user id | |
| 416 | - owner_name: string; | |
| 417 | - subject: string | null; // subject id (origin metadata); null once that subject is deleted | |
| 418 | - subject_name: string; | |
| 419 | - text: string; | |
| 420 | - kind: QuestionKind; | |
| 421 | - points: number; | |
| 422 | - choices: Choice[] | null; | |
| 423 | - correct: string | null; | |
| 424 | - image?: ImageMeta | null; | |
| 425 | - choice_images?: (ImageMeta | null)[] | null; | |
| 426 | - source_exam?: string | null; | |
| 427 | - visibility: BankVisibility; // new templates start "private" | |
| 428 | - created_at: number; // UTC unix ms | |
| 429 | - /** | |
| 430 | - * How many exam questions were copied out of this template. Each copy is | |
| 431 | - * detached, so editing the template never reaches them — this is the | |
| 432 | - * divergence surface. List-only, exactly like `subject_name`/`owner_name`: | |
| 433 | - * the single-template endpoints return 0. | |
| 434 | - */ | |
| 435 | - used_count: number; | |
| 414 | + id: string; | |
| 415 | + owner: string; // user id | |
| 416 | + owner_name: string; | |
| 417 | + subject: string | null; // subject id (origin metadata); null once that subject is deleted | |
| 418 | + subject_name: string; | |
| 419 | + text: string; | |
| 420 | + kind: QuestionKind; | |
| 421 | + points: number; | |
| 422 | + choices: Choice[] | null; | |
| 423 | + correct: string | null; | |
| 424 | + image?: ImageMeta | null; | |
| 425 | + choice_images?: (ImageMeta | null)[] | null; | |
| 426 | + source_exam?: string | null; | |
| 427 | + visibility: BankVisibility; // new templates start "private" | |
| 428 | + created_at: number; // UTC unix ms | |
| 429 | + /** | |
| 430 | + * How many exam questions were copied out of this template. Each copy is | |
| 431 | + * detached, so editing the template never reaches them — this is the | |
| 432 | + * divergence surface. List-only, exactly like `subject_name`/`owner_name`: | |
| 433 | + * the single-template endpoints return 0. | |
| 434 | + */ | |
| 435 | + used_count: number; | |
| 436 | 436 | }; |
| 437 | 437 | |
| 438 | 438 | export type ExamAttempt = { |
| 439 | - id: string; | |
| 440 | - exam: string; | |
| 441 | - user: PersonRef; | |
| 442 | - status: AttemptStatus; | |
| 443 | - attempt: number; | |
| 444 | - attempts_used: number; | |
| 445 | - max_attempts: number; | |
| 446 | - started_at: number; | |
| 447 | - finished_at: number | null; | |
| 448 | - deadline: number | null; | |
| 449 | - remaining_ms: number | null; | |
| 450 | - left_at: number | null; | |
| 451 | - mark: number | null; | |
| 452 | - answered: number; | |
| 453 | - question_count: number; | |
| 454 | - now: number; | |
| 439 | + id: string; | |
| 440 | + exam: string; | |
| 441 | + user: PersonRef; | |
| 442 | + status: AttemptStatus; | |
| 443 | + attempt: number; | |
| 444 | + attempts_used: number; | |
| 445 | + max_attempts: number; | |
| 446 | + started_at: number; | |
| 447 | + finished_at: number | null; | |
| 448 | + deadline: number | null; | |
| 449 | + remaining_ms: number | null; | |
| 450 | + left_at: number | null; | |
| 451 | + mark: number | null; | |
| 452 | + answered: number; | |
| 453 | + question_count: number; | |
| 454 | + now: number; | |
| 455 | 455 | }; |
| 456 | 456 | |
| 457 | 457 | export type AttemptAnswer = { |
| 458 | - selected?: string | null; | |
| 459 | - text?: string | null; | |
| 460 | - updated_at?: number; | |
| 461 | - answer_image?: ImageMeta | null; | |
| 458 | + selected?: string | null; | |
| 459 | + text?: string | null; | |
| 460 | + updated_at?: number; | |
| 461 | + answer_image?: ImageMeta | null; | |
| 462 | 462 | }; |
| 463 | 463 | |
| 464 | 464 | export type AttemptQuestionResponse = { |
| 465 | - id: string; | |
| 466 | - subject: string; | |
| 467 | - text: string; | |
| 468 | - kind: QuestionKind; | |
| 469 | - points: number; | |
| 470 | - choices: Choice[] | null; | |
| 471 | - image?: ImageMeta | null; | |
| 472 | - choice_images?: (ImageMeta | null)[] | null; | |
| 473 | - answer: AttemptAnswer | null; | |
| 465 | + id: string; | |
| 466 | + subject: string; | |
| 467 | + text: string; | |
| 468 | + kind: QuestionKind; | |
| 469 | + points: number; | |
| 470 | + choices: Choice[] | null; | |
| 471 | + image?: ImageMeta | null; | |
| 472 | + choice_images?: (ImageMeta | null)[] | null; | |
| 473 | + answer: AttemptAnswer | null; | |
| 474 | 474 | }; |
| 475 | 475 | |
| 476 | 476 | export type AttemptQuestion = AttemptQuestionResponse & { exam: string }; |
| 477 | 477 | |
| 478 | 478 | export type PomodoroSession = { |
| 479 | - id: string; | |
| 480 | - user: string; | |
| 481 | - started_at: number; | |
| 482 | - finished_at: number | null; | |
| 483 | - duration_ms: number | null; | |
| 479 | + id: string; | |
| 480 | + user: string; | |
| 481 | + started_at: number; | |
| 482 | + finished_at: number | null; | |
| 483 | + duration_ms: number | null; | |
| 484 | 484 | }; |
| 485 | 485 | |
| 486 | 486 | export type PomodoroLog = { |
| 487 | - items: PomodoroSession[]; | |
| 488 | - total: number; | |
| 489 | - limit: number | null; | |
| 490 | - offset: number; | |
| 491 | - total_focus_ms: number; | |
| 487 | + items: PomodoroSession[]; | |
| 488 | + total: number; | |
| 489 | + limit: number | null; | |
| 490 | + offset: number; | |
| 491 | + total_focus_ms: number; | |
| 492 | 492 | }; |
| 493 | 493 | |
| 494 | 494 | export type Subject = { |
| 495 | - id: string; | |
| 496 | - course: string; | |
| 497 | - name: string; | |
| 498 | - description: string; | |
| 495 | + id: string; | |
| 496 | + course: string; | |
| 497 | + name: string; | |
| 498 | + description: string; | |
| 499 | 499 | }; |
| 500 | 500 | |
| 501 | 501 | export type MarkEntry = { |
| 502 | - exam: string; | |
| 503 | - title: string; | |
| 504 | - kind: string; | |
| 505 | - weight: number; | |
| 506 | - mark: number; | |
| 507 | - grade?: string | null; | |
| 508 | - graded_by: string; | |
| 502 | + exam: string; | |
| 503 | + title: string; | |
| 504 | + kind: string; | |
| 505 | + weight: number; | |
| 506 | + mark: number; | |
| 507 | + grade?: string | null; | |
| 508 | + graded_by: string; | |
| 509 | 509 | }; |
| 510 | 510 | |
| 511 | 511 | export type CourseMarks = { |
| 512 | - course: Course; | |
| 513 | - results: MarkEntry[]; | |
| 514 | - average: number | null; | |
| 515 | - average_grade?: string | null; | |
| 512 | + course: Course; | |
| 513 | + results: MarkEntry[]; | |
| 514 | + average: number | null; | |
| 515 | + average_grade?: string | null; | |
| 516 | 516 | }; |
| 517 | 517 | |
| 518 | 518 | export type AttendanceCounts = { |
| 519 | - present: number; | |
| 520 | - absent: number; | |
| 521 | - late: number; | |
| 522 | - excused: number; | |
| 523 | - custom: Record<string, number>; | |
| 524 | - total: number; | |
| 525 | - rate: number | null; | |
| 519 | + present: number; | |
| 520 | + absent: number; | |
| 521 | + late: number; | |
| 522 | + excused: number; | |
| 523 | + custom: Record<string, number>; | |
| 524 | + total: number; | |
| 525 | + rate: number | null; | |
| 526 | 526 | }; |
| 527 | 527 | |
| 528 | 528 | export type CourseAttendance = { |
| 529 | - course: Course; | |
| 530 | - counts: AttendanceCounts; | |
| 529 | + course: Course; | |
| 530 | + counts: AttendanceCounts; | |
| 531 | 531 | }; |
| 532 | 532 | |
| 533 | 533 | export type AttendanceReport = { |
| 534 | - user: string; | |
| 535 | - events: AttendanceCounts; | |
| 536 | - sessions: AttendanceCounts; | |
| 537 | - courses: CourseAttendance[]; | |
| 534 | + user: string; | |
| 535 | + events: AttendanceCounts; | |
| 536 | + sessions: AttendanceCounts; | |
| 537 | + courses: CourseAttendance[]; | |
| 538 | 538 | }; |
| 539 | 539 | |
| 540 | 540 | export type WorkEntry = { |
| 541 | - id: string; | |
| 542 | - user: string; | |
| 543 | - check_in: number; | |
| 544 | - check_out: number | null; | |
| 545 | - duration_ms: number | null; | |
| 541 | + id: string; | |
| 542 | + user: string; | |
| 543 | + check_in: number; | |
| 544 | + check_out: number | null; | |
| 545 | + duration_ms: number | null; | |
| 546 | 546 | }; |
| 547 | 547 | |
| 548 | 548 | export type MarksReport = { |
| 549 | - user: string; | |
| 550 | - courses: CourseMarks[]; | |
| 551 | - overall_average: number | null; | |
| 552 | - overall_grade?: string | null; | |
| 549 | + user: string; | |
| 550 | + courses: CourseMarks[]; | |
| 551 | + overall_average: number | null; | |
| 552 | + overall_grade?: string | null; | |
| 553 | 553 | }; |
| 554 | 554 | |
| 555 | 555 | export type ExamStatistics = { |
| 556 | - exam: string; | |
| 557 | - graded: number; | |
| 558 | - average: number | null; | |
| 559 | - min: number | null; | |
| 560 | - max: number | null; | |
| 556 | + exam: string; | |
| 557 | + graded: number; | |
| 558 | + average: number | null; | |
| 559 | + min: number | null; | |
| 560 | + max: number | null; | |
| 561 | 561 | }; |
| 562 | 562 | |
| 563 | 563 | export type StudentAnswer = { |
| 564 | - question: string; | |
| 565 | - selected: string | null; | |
| 566 | - text: string | null; | |
| 567 | - updated_at: number; | |
| 568 | - is_correct: boolean | null; | |
| 569 | - answer_image?: ImageMeta | null; | |
| 564 | + question: string; | |
| 565 | + selected: string | null; | |
| 566 | + text: string | null; | |
| 567 | + updated_at: number; | |
| 568 | + is_correct: boolean | null; | |
| 569 | + answer_image?: ImageMeta | null; | |
| 570 | 570 | }; |
| 571 | 571 | |
| 572 | 572 | export type StudentAnswerSheet = { |
| 573 | - exam: string; | |
| 574 | - user: PersonRef; | |
| 575 | - answers: StudentAnswer[]; | |
| 576 | - auto_score: { earned: number; possible: number }; | |
| 573 | + exam: string; | |
| 574 | + user: PersonRef; | |
| 575 | + answers: StudentAnswer[]; | |
| 576 | + auto_score: { earned: number; possible: number }; | |
| 577 | 577 | }; |
| 578 | 578 | |
| 579 | 579 | export type LiveRosterEntry = { |
| 580 | - user: PersonRef; | |
| 581 | - status: AttemptStatus | "not_started" | "absent"; | |
| 582 | - attempt: number | null; | |
| 583 | - attempts_used: number; | |
| 584 | - deadline: number | null; | |
| 585 | - remaining_ms: number | null; | |
| 586 | - left_at: number | null; | |
| 587 | - mark: number | null; | |
| 588 | - answered: number; | |
| 589 | - started_at: number | null; | |
| 590 | - finished_at: number | null; | |
| 591 | - last_activity: number | null; | |
| 580 | + user: PersonRef; | |
| 581 | + status: AttemptStatus | "not_started" | "absent"; | |
| 582 | + attempt: number | null; | |
| 583 | + attempts_used: number; | |
| 584 | + deadline: number | null; | |
| 585 | + remaining_ms: number | null; | |
| 586 | + left_at: number | null; | |
| 587 | + mark: number | null; | |
| 588 | + answered: number; | |
| 589 | + started_at: number | null; | |
| 590 | + finished_at: number | null; | |
| 591 | + last_activity: number | null; | |
| 592 | 592 | }; |
| 593 | 593 | |
| 594 | 594 | export type LiveMonitor = { |
| 595 | - exam: Exam; | |
| 596 | - now: number; | |
| 597 | - question_count: number; | |
| 598 | - students: LiveRosterEntry[]; | |
| 599 | - counts: { | |
| 600 | - enrolled: number; | |
| 601 | - not_started: number; | |
| 602 | - absent: number; | |
| 603 | - in_progress: number; | |
| 604 | - submitted: number; | |
| 605 | - expired: number; | |
| 606 | - graded: number; | |
| 607 | - }; | |
| 595 | + exam: Exam; | |
| 596 | + now: number; | |
| 597 | + question_count: number; | |
| 598 | + students: LiveRosterEntry[]; | |
| 599 | + counts: { | |
| 600 | + enrolled: number; | |
| 601 | + not_started: number; | |
| 602 | + absent: number; | |
| 603 | + in_progress: number; | |
| 604 | + submitted: number; | |
| 605 | + expired: number; | |
| 606 | + graded: number; | |
| 607 | + }; | |
| 608 | 608 | }; |
| 609 | 609 | |
| 610 | 610 | export type ExamKindSetting = { |
| 611 | - name: string; | |
| 612 | - weight: number; | |
| 611 | + name: string; | |
| 612 | + weight: number; | |
| 613 | 613 | }; |
| 614 | 614 | |
| 615 | 615 | export type GradeBand = { |
| 616 | - min: number; | |
| 617 | - label: string; | |
| 616 | + min: number; | |
| 617 | + label: string; | |
| 618 | 618 | }; |
| 619 | 619 | |
| 620 | 620 | export type MealSlot = { |
| 621 | - name: string; | |
| 622 | - serving_minute: number | null; | |
| 621 | + name: string; | |
| 622 | + serving_minute: number | null; | |
| 623 | 623 | }; |
| 624 | 624 | |
| 625 | 625 | export type SchoolSettings = { |
| 626 | - exam_kinds: ExamKindSetting[]; | |
| 627 | - attendance_statuses: string[]; | |
| 628 | - grade_bands: GradeBand[]; | |
| 629 | - max_file_bytes: number; | |
| 630 | - chatbot_history_turns: number; | |
| 631 | - max_chatbot_threads: number; | |
| 632 | - max_chatbot_message_len: number; | |
| 633 | - meal_slots: MealSlot[]; | |
| 634 | - dietary_tags: string[]; | |
| 635 | - meal_cancel_cutoff_minutes: number | null; | |
| 626 | + exam_kinds: ExamKindSetting[]; | |
| 627 | + attendance_statuses: string[]; | |
| 628 | + grade_bands: GradeBand[]; | |
| 629 | + max_file_bytes: number; | |
| 630 | + chatbot_history_turns: number; | |
| 631 | + max_chatbot_threads: number; | |
| 632 | + max_chatbot_message_len: number; | |
| 633 | + meal_slots: MealSlot[]; | |
| 634 | + dietary_tags: string[]; | |
| 635 | + meal_cancel_cutoff_minutes: number | null; | |
| 636 | 636 | }; |
| 637 | 637 | |
| 638 | 638 | export type Limits = { |
| 639 | - user: { | |
| 640 | - min_username_len: number; | |
| 641 | - max_username_len: number; | |
| 642 | - username_separators: string[]; | |
| 643 | - reserved_usernames: string[]; | |
| 644 | - min_password_len: number; | |
| 645 | - max_password_len: number; | |
| 646 | - max_name_len: number; | |
| 647 | - max_display_name_len: number; | |
| 648 | - max_bio_len: number; | |
| 649 | - // Caps on what a profile read embeds, not on membership: the full lists | |
| 650 | - // stay at /courses/me and /classes/me. | |
| 651 | - max_profile_courses: number; | |
| 652 | - max_profile_classes: number; | |
| 653 | - max_email_len: number; | |
| 654 | - min_phone_digits: number; | |
| 655 | - max_phone_digits: number; | |
| 656 | - roles: Role[]; | |
| 657 | - themes: UserTheme[]; | |
| 658 | - languages: UserLanguage[]; | |
| 659 | - session_duration_days: number; | |
| 660 | - }; | |
| 661 | - badges: { catalog: BadgeCatalogEntry[] }; | |
| 662 | - note: { max_title_len: number; max_content_len: number; max_files: number }; | |
| 663 | - file: { | |
| 664 | - max_name_len: number; | |
| 665 | - max_content_type_len: number; | |
| 666 | - min_max_file_bytes: number; | |
| 667 | - max_max_file_bytes: number; | |
| 668 | - default_max_file_bytes: number; | |
| 669 | - image_content_types: string[]; | |
| 670 | - }; | |
| 671 | - message: { max_subject_len: number; max_body_len: number; max_label_len: number }; | |
| 672 | - event: { max_title_len: number; max_description_len: number }; | |
| 673 | - course: { | |
| 674 | - max_title_len: number; | |
| 675 | - max_description_len: number; | |
| 676 | - kinds: CourseKind[]; | |
| 677 | - max_subject_name_len: number; | |
| 678 | - max_subject_description_len: number; | |
| 679 | - max_session_topic_len: number; | |
| 680 | - max_term_name_len: number; | |
| 681 | - max_class_name_len: number; | |
| 682 | - max_class_grade_len: number; | |
| 683 | - max_class_members: number; | |
| 684 | - max_class_courses: number; | |
| 685 | - max_class_bytes: number; | |
| 686 | - }; | |
| 687 | - exam: { | |
| 688 | - max_title_len: number; | |
| 689 | - max_description_len: number; | |
| 690 | - modes: ExamMode[]; | |
| 691 | - min_duration_ms: number; | |
| 692 | - max_duration_ms: number; | |
| 693 | - max_attempts: number; | |
| 694 | - unlimited_attempts: number; | |
| 695 | - question_kinds: QuestionKind[]; | |
| 696 | - max_question_text_len: number; | |
| 697 | - min_question_points: number; | |
| 698 | - max_question_points: number; | |
| 699 | - min_question_choices: number; | |
| 700 | - max_question_choices: number; | |
| 701 | - max_choice_text_len: number; | |
| 702 | - max_answer_text_len: number; | |
| 703 | - min_mark: number; | |
| 704 | - max_mark: number; | |
| 705 | - ws_tick_secs: number; | |
| 706 | - ws_max_question_id_len: number; | |
| 707 | - }; | |
| 708 | - homework: { | |
| 709 | - max_title_len: number; | |
| 710 | - max_description_len: number; | |
| 711 | - max_text_len: number; | |
| 712 | - max_files_per_submission: number; | |
| 713 | - max_assigned: number; | |
| 714 | - statuses: string[]; | |
| 715 | - }; | |
| 716 | - question_pool: { max_title_len: number; max_body_len: number; max_solution_body_len: number }; | |
| 717 | - appointment: { max_note_len: number; max_reason_len: number; max_slot_occurrences: number }; | |
| 718 | - meal: { | |
| 719 | - max_dish_name_len: number; | |
| 720 | - max_dish_description_len: number; | |
| 721 | - max_dishes_per_menu: number; | |
| 722 | - max_dish_tags: number; | |
| 723 | - max_menu_capacity: number; | |
| 724 | - max_dietary_tags: number; | |
| 725 | - max_dietary_note_len: number; | |
| 726 | - max_dish_price_minor: number; | |
| 727 | - max_ledger_amount_minor: number; | |
| 728 | - max_ledger_method_len: number; | |
| 729 | - max_ledger_note_len: number; | |
| 730 | - max_cancel_cutoff_minutes: number; | |
| 731 | - max_serving_minute: number; | |
| 732 | - booking_statuses: string[]; | |
| 733 | - attendance_statuses: string[]; | |
| 734 | - ledger_kinds: string[]; | |
| 735 | - }; | |
| 736 | - payment: { | |
| 737 | - max_plan_name_len: number; | |
| 738 | - max_plan_installments: number; | |
| 739 | - max_assign_students: number; | |
| 740 | - max_request_key_len: number; | |
| 741 | - ledger_kinds: string[]; | |
| 742 | - }; | |
| 743 | - chatbot: { | |
| 744 | - max_message_len: number; | |
| 745 | - max_thread_title_len: number; | |
| 746 | - min_max_message_len: number; | |
| 747 | - max_max_message_len: number; | |
| 748 | - default_max_message_len: number; | |
| 749 | - min_history_turns: number; | |
| 750 | - max_history_turns: number; | |
| 751 | - default_history_turns: number; | |
| 752 | - min_max_threads: number; | |
| 753 | - max_max_threads: number; | |
| 754 | - default_max_threads: number; | |
| 755 | - }; | |
| 756 | - board: { | |
| 757 | - max_title_len: number; | |
| 758 | - // People the creator may name onto one board. Every participant draws, so | |
| 759 | - // this also bounds a room's writer count. | |
| 760 | - max_participants: number; | |
| 761 | - max_stroke_payload_len: number; | |
| 762 | - max_epoch_strokes: number; | |
| 763 | - max_board_strokes: number; | |
| 764 | - max_boards_per_creator: number; | |
| 765 | - stroke_kinds: string[]; | |
| 766 | - ws_tick_secs: number; | |
| 767 | - ws_max_board_id_len: number; | |
| 768 | - }; | |
| 769 | - settings: { | |
| 770 | - max_list_len: number; | |
| 771 | - max_item_len: number; | |
| 772 | - min_exam_kind_weight: number; | |
| 773 | - max_exam_kind_weight: number; | |
| 774 | - max_grade_bands: number; | |
| 775 | - max_grade_label_len: number; | |
| 776 | - required_attendance_statuses: string[]; | |
| 777 | - }; | |
| 778 | - request: { max_page_limit: number; schedule_past_grace_ms: number; request_timeout_secs: number }; | |
| 779 | - rate: { window_secs: number; auth_per_minute: number; api_per_minute: number; chatbot_per_minute: number }; | |
| 639 | + user: { | |
| 640 | + min_username_len: number; | |
| 641 | + max_username_len: number; | |
| 642 | + username_separators: string[]; | |
| 643 | + reserved_usernames: string[]; | |
| 644 | + min_password_len: number; | |
| 645 | + max_password_len: number; | |
| 646 | + max_name_len: number; | |
| 647 | + max_display_name_len: number; | |
| 648 | + max_bio_len: number; | |
| 649 | + // Caps on what a profile read embeds, not on membership: the full lists | |
| 650 | + // stay at /courses/me and /classes/me. | |
| 651 | + max_profile_courses: number; | |
| 652 | + max_profile_classes: number; | |
| 653 | + max_email_len: number; | |
| 654 | + min_phone_digits: number; | |
| 655 | + max_phone_digits: number; | |
| 656 | + roles: Role[]; | |
| 657 | + themes: UserTheme[]; | |
| 658 | + languages: UserLanguage[]; | |
| 659 | + session_duration_days: number; | |
| 660 | + }; | |
| 661 | + badges: { catalog: BadgeCatalogEntry[] }; | |
| 662 | + note: { max_title_len: number; max_content_len: number; max_files: number }; | |
| 663 | + file: { | |
| 664 | + max_name_len: number; | |
| 665 | + max_content_type_len: number; | |
| 666 | + min_max_file_bytes: number; | |
| 667 | + max_max_file_bytes: number; | |
| 668 | + default_max_file_bytes: number; | |
| 669 | + image_content_types: string[]; | |
| 670 | + }; | |
| 671 | + message: { max_subject_len: number; max_body_len: number; max_label_len: number }; | |
| 672 | + event: { max_title_len: number; max_description_len: number }; | |
| 673 | + course: { | |
| 674 | + max_title_len: number; | |
| 675 | + max_description_len: number; | |
| 676 | + kinds: CourseKind[]; | |
| 677 | + max_subject_name_len: number; | |
| 678 | + max_subject_description_len: number; | |
| 679 | + max_session_topic_len: number; | |
| 680 | + max_term_name_len: number; | |
| 681 | + max_class_name_len: number; | |
| 682 | + max_class_grade_len: number; | |
| 683 | + max_class_members: number; | |
| 684 | + max_class_courses: number; | |
| 685 | + }; | |
| 686 | + exam: { | |
| 687 | + max_title_len: number; | |
| 688 | + max_description_len: number; | |
| 689 | + modes: ExamMode[]; | |
| 690 | + min_duration_ms: number; | |
| 691 | + max_duration_ms: number; | |
| 692 | + max_attempts: number; | |
| 693 | + unlimited_attempts: number; | |
| 694 | + question_kinds: QuestionKind[]; | |
| 695 | + max_question_text_len: number; | |
| 696 | + min_question_points: number; | |
| 697 | + max_question_points: number; | |
| 698 | + min_question_choices: number; | |
| 699 | + max_question_choices: number; | |
| 700 | + max_choice_text_len: number; | |
| 701 | + max_answer_text_len: number; | |
| 702 | + min_mark: number; | |
| 703 | + max_mark: number; | |
| 704 | + ws_tick_secs: number; | |
| 705 | + ws_max_question_id_len: number; | |
| 706 | + }; | |
| 707 | + homework: { | |
| 708 | + max_title_len: number; | |
| 709 | + max_description_len: number; | |
| 710 | + max_text_len: number; | |
| 711 | + max_files_per_submission: number; | |
| 712 | + max_assigned: number; | |
| 713 | + statuses: string[]; | |
| 714 | + }; | |
| 715 | + question_pool: { max_title_len: number; max_body_len: number; max_solution_body_len: number }; | |
| 716 | + appointment: { max_note_len: number; max_reason_len: number; max_slot_occurrences: number }; | |
| 717 | + meal: { | |
| 718 | + max_dish_name_len: number; | |
| 719 | + max_dish_description_len: number; | |
| 720 | + max_dishes_per_menu: number; | |
| 721 | + max_dish_tags: number; | |
| 722 | + max_menu_capacity: number; | |
| 723 | + max_dietary_tags: number; | |
| 724 | + max_dietary_note_len: number; | |
| 725 | + max_dish_price_minor: number; | |
| 726 | + max_ledger_amount_minor: number; | |
| 727 | + max_ledger_method_len: number; | |
| 728 | + max_ledger_note_len: number; | |
| 729 | + max_cancel_cutoff_minutes: number; | |
| 730 | + max_serving_minute: number; | |
| 731 | + booking_statuses: string[]; | |
| 732 | + attendance_statuses: string[]; | |
| 733 | + ledger_kinds: string[]; | |
| 734 | + }; | |
| 735 | + payment: { | |
| 736 | + max_plan_name_len: number; | |
| 737 | + max_plan_installments: number; | |
| 738 | + max_assign_students: number; | |
| 739 | + max_request_key_len: number; | |
| 740 | + ledger_kinds: string[]; | |
| 741 | + }; | |
| 742 | + chatbot: { | |
| 743 | + max_message_len: number; | |
| 744 | + max_thread_title_len: number; | |
| 745 | + min_max_message_len: number; | |
| 746 | + max_max_message_len: number; | |
| 747 | + default_max_message_len: number; | |
| 748 | + min_history_turns: number; | |
| 749 | + max_history_turns: number; | |
| 750 | + default_history_turns: number; | |
| 751 | + min_max_threads: number; | |
| 752 | + max_max_threads: number; | |
| 753 | + default_max_threads: number; | |
| 754 | + }; | |
| 755 | + board: { | |
| 756 | + max_title_len: number; | |
| 757 | + // People the creator may name onto one board. Every participant draws, so | |
| 758 | + // this also bounds a room's writer count. | |
| 759 | + max_participants: number; | |
| 760 | + max_stroke_payload_len: number; | |
| 761 | + max_epoch_strokes: number; | |
| 762 | + max_board_strokes: number; | |
| 763 | + max_boards_per_creator: number; | |
| 764 | + stroke_kinds: string[]; | |
| 765 | + ws_tick_secs: number; | |
| 766 | + ws_max_board_id_len: number; | |
| 767 | + }; | |
| 768 | + settings: { | |
| 769 | + max_list_len: number; | |
| 770 | + max_item_len: number; | |
| 771 | + min_exam_kind_weight: number; | |
| 772 | + max_exam_kind_weight: number; | |
| 773 | + max_grade_bands: number; | |
| 774 | + max_grade_label_len: number; | |
| 775 | + required_attendance_statuses: string[]; | |
| 776 | + }; | |
| 777 | + request: { max_page_limit: number; schedule_past_grace_ms: number; request_timeout_secs: number }; | |
| 778 | + rate: { window_secs: number; auth_per_minute: number; api_per_minute: number; chatbot_per_minute: number }; | |
| 780 | 779 | }; |
| 781 | 780 | |
| 782 | 781 | // Fallbacks keep forms usable when the unauthenticated metadata request fails. |
| @@ -787,141 +786,141 @@ export const QUESTION_KINDS: QuestionKind[] = ["choice", "text"]; | ||
| 787 | 786 | export type MessageFolder = "inbox" | "sent" | "archive" | "trash"; |
| 788 | 787 | |
| 789 | 788 | export type Message = { |
| 790 | - id: string; | |
| 791 | - sender: PersonRef; | |
| 792 | - sender_role: Role | null; | |
| 793 | - recipient: PersonRef; | |
| 794 | - recipient_role: Role | null; | |
| 795 | - subject: string; | |
| 796 | - body: string; | |
| 797 | - sent_at: number; | |
| 798 | - read: boolean; | |
| 799 | - folder: MessageFolder; | |
| 800 | - previous_folder?: MessageFolder | string | null; | |
| 801 | - label: string | null; | |
| 789 | + id: string; | |
| 790 | + sender: PersonRef; | |
| 791 | + sender_role: Role | null; | |
| 792 | + recipient: PersonRef; | |
| 793 | + recipient_role: Role | null; | |
| 794 | + subject: string; | |
| 795 | + body: string; | |
| 796 | + sent_at: number; | |
| 797 | + read: boolean; | |
| 798 | + folder: MessageFolder; | |
| 799 | + previous_folder?: MessageFolder | string | null; | |
| 800 | + label: string | null; | |
| 802 | 801 | }; |
| 803 | 802 | |
| 804 | 803 | export type Homework = { |
| 805 | - id: string; | |
| 806 | - course: string; | |
| 807 | - subject: string; | |
| 808 | - title: string; | |
| 809 | - description: string | null; | |
| 810 | - due_at: number; | |
| 811 | - assigned: string[] | null; | |
| 812 | - created_by: string; | |
| 813 | - created_at: number; | |
| 804 | + id: string; | |
| 805 | + course: string; | |
| 806 | + subject: string; | |
| 807 | + title: string; | |
| 808 | + description: string | null; | |
| 809 | + due_at: number; | |
| 810 | + assigned: string[] | null; | |
| 811 | + created_by: string; | |
| 812 | + created_at: number; | |
| 814 | 813 | }; |
| 815 | 814 | |
| 816 | 815 | export type HomeworkFile = { |
| 817 | - id: string; | |
| 818 | - name: string; | |
| 819 | - content_type: string; | |
| 820 | - size: number; | |
| 816 | + id: string; | |
| 817 | + name: string; | |
| 818 | + content_type: string; | |
| 819 | + size: number; | |
| 821 | 820 | }; |
| 822 | 821 | |
| 823 | 822 | export type HomeworkResultStatus = "done" | "incomplete" | "missing" | string; |
| 824 | 823 | |
| 825 | 824 | export type HomeworkResult = { |
| 826 | - status: HomeworkResultStatus; | |
| 827 | - mark: number | null; | |
| 828 | - graded_by: string; | |
| 829 | - created_at: number; | |
| 825 | + status: HomeworkResultStatus; | |
| 826 | + mark: number | null; | |
| 827 | + graded_by: string; | |
| 828 | + created_at: number; | |
| 830 | 829 | }; |
| 831 | 830 | |
| 832 | 831 | export type HomeworkSubmission = { |
| 833 | - user: string; | |
| 834 | - homework: string; | |
| 835 | - text: string | null; | |
| 836 | - submitted_at: number; | |
| 837 | - updated_at: number; | |
| 838 | - late: boolean; | |
| 839 | - files: HomeworkFile[]; | |
| 840 | - result: HomeworkResult | null; | |
| 832 | + user: string; | |
| 833 | + homework: string; | |
| 834 | + text: string | null; | |
| 835 | + submitted_at: number; | |
| 836 | + updated_at: number; | |
| 837 | + late: boolean; | |
| 838 | + files: HomeworkFile[]; | |
| 839 | + result: HomeworkResult | null; | |
| 841 | 840 | }; |
| 842 | 841 | |
| 843 | 842 | export type HomeworkRosterSubmission = Omit<HomeworkSubmission, "user" | "homework" | "result">; |
| 844 | 843 | |
| 845 | 844 | export type HomeworkRosterEntry = { |
| 846 | - user: string; | |
| 847 | - submission: HomeworkRosterSubmission | null; | |
| 848 | - result: HomeworkResult | null; | |
| 849 | - missing: boolean; | |
| 850 | - unenrolled: boolean; | |
| 845 | + user: string; | |
| 846 | + submission: HomeworkRosterSubmission | null; | |
| 847 | + result: HomeworkResult | null; | |
| 848 | + missing: boolean; | |
| 849 | + unenrolled: boolean; | |
| 851 | 850 | }; |
| 852 | 851 | |
| 853 | 852 | export type HomeworkReportEntry = { |
| 854 | - course: string; | |
| 855 | - homework: string; | |
| 856 | - title: string; | |
| 857 | - subject: string; | |
| 858 | - due_at: number; | |
| 859 | - submitted: boolean; | |
| 860 | - late: boolean; | |
| 861 | - missing: boolean; | |
| 862 | - result: HomeworkResult | null; | |
| 853 | + course: string; | |
| 854 | + homework: string; | |
| 855 | + title: string; | |
| 856 | + subject: string; | |
| 857 | + due_at: number; | |
| 858 | + submitted: boolean; | |
| 859 | + late: boolean; | |
| 860 | + missing: boolean; | |
| 861 | + result: HomeworkResult | null; | |
| 863 | 862 | }; |
| 864 | 863 | |
| 865 | 864 | export type MealDish = { |
| 866 | - id: string; | |
| 867 | - name: string; | |
| 868 | - description: string | null; | |
| 869 | - price_minor: number; | |
| 870 | - tags: string[]; | |
| 871 | - conflicts: string[]; | |
| 872 | - created_at: number; | |
| 865 | + id: string; | |
| 866 | + name: string; | |
| 867 | + description: string | null; | |
| 868 | + price_minor: number; | |
| 869 | + tags: string[]; | |
| 870 | + conflicts: string[]; | |
| 871 | + created_at: number; | |
| 873 | 872 | }; |
| 874 | 873 | |
| 875 | 874 | export type MealMenu = { |
| 876 | - id: string; | |
| 877 | - date: string; | |
| 878 | - slot: string; | |
| 879 | - capacity: number | null; | |
| 880 | - dishes: MealDish[]; | |
| 881 | - created_by: PersonRef; | |
| 882 | - created_at: number; | |
| 875 | + id: string; | |
| 876 | + date: string; | |
| 877 | + slot: string; | |
| 878 | + capacity: number | null; | |
| 879 | + dishes: MealDish[]; | |
| 880 | + created_by: PersonRef; | |
| 881 | + created_at: number; | |
| 883 | 882 | }; |
| 884 | 883 | |
| 885 | 884 | export type MealBooking = { |
| 886 | - id: string; | |
| 887 | - menu_id: string; | |
| 888 | - student: PersonRef; | |
| 889 | - booked_by: PersonRef; | |
| 890 | - status: string; | |
| 891 | - cancelled_at: number | null; | |
| 892 | - created_at: number; | |
| 885 | + id: string; | |
| 886 | + menu_id: string; | |
| 887 | + student: PersonRef; | |
| 888 | + booked_by: PersonRef; | |
| 889 | + status: string; | |
| 890 | + cancelled_at: number | null; | |
| 891 | + created_at: number; | |
| 893 | 892 | }; |
| 894 | 893 | |
| 895 | 894 | export type MealAttendance = { |
| 896 | - id: string; | |
| 897 | - menu_id: string; | |
| 898 | - student: PersonRef; | |
| 899 | - status: string; | |
| 900 | - marked_by: PersonRef; | |
| 901 | - marked_at: number; | |
| 895 | + id: string; | |
| 896 | + menu_id: string; | |
| 897 | + student: PersonRef; | |
| 898 | + status: string; | |
| 899 | + marked_by: PersonRef; | |
| 900 | + marked_at: number; | |
| 902 | 901 | }; |
| 903 | 902 | |
| 904 | 903 | export type DietaryProfile = { |
| 905 | - student: PersonRef; | |
| 906 | - tags: string[]; | |
| 907 | - note: string | null; | |
| 908 | - updated_by: PersonRef | null; | |
| 909 | - updated_at: number | null; | |
| 904 | + student: PersonRef; | |
| 905 | + tags: string[]; | |
| 906 | + note: string | null; | |
| 907 | + updated_by: PersonRef | null; | |
| 908 | + updated_at: number | null; | |
| 910 | 909 | }; |
| 911 | 910 | |
| 912 | 911 | export type MealBalance = { |
| 913 | - student: PersonRef; | |
| 914 | - balance_minor: number; | |
| 912 | + student: PersonRef; | |
| 913 | + balance_minor: number; | |
| 915 | 914 | }; |
| 916 | 915 | |
| 917 | 916 | export type MealLedgerEntry = { |
| 918 | - id: string; | |
| 919 | - student: PersonRef; | |
| 920 | - kind: string; | |
| 921 | - amount_minor: number; | |
| 922 | - source: string | null; | |
| 923 | - method: string | null; | |
| 924 | - note: string | null; | |
| 925 | - recorded_by: PersonRef; | |
| 926 | - created_at: number; | |
| 917 | + id: string; | |
| 918 | + student: PersonRef; | |
| 919 | + kind: string; | |
| 920 | + amount_minor: number; | |
| 921 | + source: string | null; | |
| 922 | + method: string | null; | |
| 923 | + note: string | null; | |
| 924 | + recorded_by: PersonRef; | |
| 925 | + created_at: number; | |
| 927 | 926 | }; |
src/api/parents/postParentStudent.tsmodified+1 -1
| @@ -10,6 +10,6 @@ export interface ParentLinkResponse { | ||
| 10 | 10 | export async function postParentStudent(id: string, user_id: string): Promise<ParentLinkResponse> { |
| 11 | 11 | return client(`/users/${id}/students`, { |
| 12 | 12 | method: "POST", |
| 13 | - body: JSON.stringify({ user_id }), | |
| 13 | + body: { user_id }, | |
| 14 | 14 | }); |
| 15 | 15 | } |