forge
Explore
Log in

Don't you dare go Hollow

🔌 align three api shapes with the refactored backend

Browse files at this commit

aba07ef0257d574fafc8892161df1145c002acf2Ahmet Kaan GümüşParent: 790b1c0
  • fix
    • 🔌 align three api shapes with the refactored backend
Show full message
fix: 🔌 align three api shapes with the refactored backend
- postParentStudent sent a pre-stringified body that client() encoded
  again, so the backend got a quoted string and 400'd every link; pass
  the plain object
- postRegister declared Promise<User> but the backend's
  anti-enumeration 201 carries only {username, role}; retype to
  RegisterResponse
- drop Limits.course.max_class_bytes: invented by a past alignment
  commit, never published or enforced by the backend in any revision
- update the auth and parents tests, which pinned both wrong shapes
src/api/__tests__/auth/auth.test.tsmodified+4 -4
@@ -33,12 +33,12 @@ describe("auth API", () => {
3333 });
3434
3535 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);
3838
39- const data = { school: "demo", username: "newuser", password: "password", email: "test@test.com" };
39+ const data = { school: "demo", username: "newuser", password: "password" };
4040 const result = await postRegister(data);
41- expect(result).toEqual(mockUser);
41+ expect(result).toEqual(mockResponse);
4242
4343 const [url, init] = lastFetchCall();
4444 expect(url).toBe("/api/auth/register");
src/api/__tests__/parents/parents.test.tsmodified+1 -1
@@ -32,7 +32,7 @@ describe("parents API", () => {
3232 const [url, init] = lastFetchCall();
3333 expect(url).toBe("/api/users/u1/students");
3434 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" }));
3636 });
3737
3838 it("deleteParentStudent calls /users/:id/students/:studentId", async () => {
src/api/auth/postRegister.tsmodified+9 -3
@@ -1,5 +1,5 @@
11 import { client } from "../client";
2-import type { User } from "../client";
2+import type { Role } from "../client";
33
44 export type RegisterBody = {
55 school: string;
@@ -7,6 +7,12 @@ export type RegisterBody = {
77 password: string;
88 };
99
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 });
1218 }
src/api/client/types.tsmodified+620 -621
@@ -13,44 +13,44 @@ export type QuestionKind = "choice" | "text";
1313 export type AttemptStatus = "in_progress" | "submitted" | "expired";
1414
1515 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;
2727 };
2828
2929 // PATCH /users/me and PATCH /users/{id}/profile take the same body: an omitted
3030 // (or null) field is left alone, an empty string clears it.
3131 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;
3939 };
4040
4141 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;
4545 };
4646
4747 // The lifetime counter a badge reads. Badges sharing a stat form a ladder.
4848 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";
5454
5555 // One entry of the badge catalogue, served by GET /limits. The label and icon
5656 // 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 };
6969 // Lifetime counters behind the badge ladders, plus the two live totals the
7070 // capped `classes`/`courses` lists would otherwise hide.
7171 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;
8181 };
8282
8383 // A person's public profile. Readable by any authenticated account except a
8484 // parent, who only reaches their own and their linked students'. Never carries
8585 // email, phone or birth date at any role — those stay on GET /users/{id}.
8686 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;
100100 };
101101
102102 export type Note = {
103- id: string;
104- title: string;
105- content: string;
103+ id: string;
104+ title: string;
105+ content: string;
106106 };
107107
108108 /** A note attached to a course; files reuse the personal note's `NoteFile` shape. */
109109 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;
114114 };
115115
116116 /** One AI service output stored against a course note. `payload` is the
117117 * service's own shape — stored and served unread, rendered as JSON. */
118118 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;
127127 };
128128
129129 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;
134134 };
135135
136136 /** The caller's school entitlements: every switched-on module, sorted by name. */
137137 export type EnabledModules = {
138- enabled: string[];
138+ enabled: string[];
139139 };
140140
141141 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[];
146146 };
147147
148148 export type ModuleCatalogPackage = {
149- package: string;
150- modules: string[];
149+ package: string;
150+ modules: string[];
151151 };
152152
153153 /** The deployment's whole module catalog — identical for every school. */
154154 export type ModuleCatalog = {
155- modules: ModuleCatalogEntry[];
156- packages: ModuleCatalogPackage[];
155+ modules: ModuleCatalogEntry[];
156+ packages: ModuleCatalogPackage[];
157157 };
158158
159159 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 };
164164
165165 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;
173173 };
174174
175175 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;
181181 };
182182
183183 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;
187187 };
188188
189189 export type EventRegistration = {
190- event: string;
191- user: PersonRef;
192- registered_by: PersonRef;
190+ event: string;
191+ user: PersonRef;
192+ registered_by: PersonRef;
193193 };
194194
195195 export type AppointmentStatus = "pending" | "approved" | "rejected" | "cancelled";
196196
197197 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;
205205 };
206206
207207 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;
225225 };
226226
227227 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
231231 } as const;
232232
233233 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
240240 } as const;
241241
242242 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;
251251 };
252252
253253 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;
260260 };
261261
262262 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;
271271 };
272272
273273 // A class (şube): a named group of students, optionally tied to a term, that
274274 // pumps the Cartesian product of its members × attached courses into real
275275 // enrollment rows. See src/api/classes.
276276 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;
287287 };
288288
289289 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;
294294 };
295295
296296 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;
301301 };
302302
303303 // A grade blueprint: the set of courses every class at one grade takes. The
304304 // grade label is the record's key, so there is at most one per grade. Creating
305305 // or editing one applies it to every existing class at that grade right away.
306306 export type ClassBlueprint = {
307- grade: string;
308- courses: string[];
309- creator: PersonRef;
307+ grade: string;
308+ courses: string[];
309+ creator: PersonRef;
310310 };
311311
312312 // One (class, course) pair a blueprint could not attach. Applying is
313313 // best-effort: a pair that cannot land is reported here and the rest still go
314314 // through. `reason` is backend English — localize it, never render it raw.
315315 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;
320320 };
321321
322322 export type BlueprintResult = { blueprint: ClassBlueprint; skipped: BlueprintSkip[] };
@@ -325,85 +325,85 @@ export type BlueprintApplyResult = { skipped: BlueprintSkip[] };
325325
326326 /** One section measured against its grade's blueprint. */
327327 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[];
332332 };
333333
334334 /** Every section at a grade with the template courses it is missing. */
335335 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[];
341341 };
342342
343343 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;
350350 };
351351
352352 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;
359359 };
360360
361361 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;
376376 };
377377
378378 export type ImageMeta = {
379- content_type: string;
380- size: number;
379+ content_type: string;
380+ size: number;
381381 };
382382
383383 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;
389389 };
390390
391391 /** One option of a choice question. `id` is stable across edits, so its image survives. */
392392 export type Choice = { id: string; text: string };
393393
394394 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
407407 };
408408
409409 /** `private`: owner + admins only. `school`: every teacher can see it and its answer key. */
@@ -411,372 +411,371 @@ export type BankVisibility = "private" | "school";
411411
412412 /** Reusable question stored in the school-wide question bank, outside any exam. */
413413 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;
436436 };
437437
438438 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;
455455 };
456456
457457 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;
462462 };
463463
464464 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;
474474 };
475475
476476 export type AttemptQuestion = AttemptQuestionResponse & { exam: string };
477477
478478 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;
484484 };
485485
486486 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;
492492 };
493493
494494 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;
499499 };
500500
501501 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;
509509 };
510510
511511 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;
516516 };
517517
518518 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;
526526 };
527527
528528 export type CourseAttendance = {
529- course: Course;
530- counts: AttendanceCounts;
529+ course: Course;
530+ counts: AttendanceCounts;
531531 };
532532
533533 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[];
538538 };
539539
540540 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;
546546 };
547547
548548 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;
553553 };
554554
555555 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;
561561 };
562562
563563 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;
570570 };
571571
572572 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 };
577577 };
578578
579579 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;
592592 };
593593
594594 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+ };
608608 };
609609
610610 export type ExamKindSetting = {
611- name: string;
612- weight: number;
611+ name: string;
612+ weight: number;
613613 };
614614
615615 export type GradeBand = {
616- min: number;
617- label: string;
616+ min: number;
617+ label: string;
618618 };
619619
620620 export type MealSlot = {
621- name: string;
622- serving_minute: number | null;
621+ name: string;
622+ serving_minute: number | null;
623623 };
624624
625625 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;
636636 };
637637
638638 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 };
780779 };
781780
782781 // Fallbacks keep forms usable when the unauthenticated metadata request fails.
@@ -787,141 +786,141 @@ export const QUESTION_KINDS: QuestionKind[] = ["choice", "text"];
787786 export type MessageFolder = "inbox" | "sent" | "archive" | "trash";
788787
789788 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;
802801 };
803802
804803 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;
814813 };
815814
816815 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;
821820 };
822821
823822 export type HomeworkResultStatus = "done" | "incomplete" | "missing" | string;
824823
825824 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;
830829 };
831830
832831 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;
841840 };
842841
843842 export type HomeworkRosterSubmission = Omit<HomeworkSubmission, "user" | "homework" | "result">;
844843
845844 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;
851850 };
852851
853852 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;
863862 };
864863
865864 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;
873872 };
874873
875874 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;
883882 };
884883
885884 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;
893892 };
894893
895894 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;
902901 };
903902
904903 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;
910909 };
911910
912911 export type MealBalance = {
913- student: PersonRef;
914- balance_minor: number;
912+ student: PersonRef;
913+ balance_minor: number;
915914 };
916915
917916 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;
927926 };
src/api/parents/postParentStudent.tsmodified+1 -1
@@ -10,6 +10,6 @@ export interface ParentLinkResponse {
1010 export async function postParentStudent(id: string, user_id: string): Promise<ParentLinkResponse> {
1111 return client(`/users/${id}/students`, {
1212 method: "POST",
13- body: JSON.stringify({ user_id }),
13+ body: { user_id },
1414 });
1515 }