From aba07ef0257d574fafc8892161df1145c002acf2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ahmet=20Kaan=20G=C3=BCm=C3=BC=C5=9F?= Date: Sun, 13 Sep 2026 05:38:03 +0300 Subject: [PATCH] =?UTF-8?q?fix:=20=F0=9F=94=8C=20align=20three=20api=20sha?= =?UTF-8?q?pes=20with=20the=20refactored=20backend=20-=20postParentStudent?= =?UTF-8?q?=20sent=20a=20pre-stringified=20body=20that=20client()=20encode?= =?UTF-8?q?d=20=20=20again,=20so=20the=20backend=20got=20a=20quoted=20stri?= =?UTF-8?q?ng=20and=20400'd=20every=20link;=20pass=20=20=20the=20plain=20o?= =?UTF-8?q?bject=20-=20postRegister=20declared=20Promise=20but=20the?= =?UTF-8?q?=20backend's=20=20=20anti-enumeration=20201=20carries=20only=20?= =?UTF-8?q?{username,=20role};=20retype=20to=20=20=20RegisterResponse=20-?= =?UTF-8?q?=20drop=20Limits.course.max=5Fclass=5Fbytes:=20invented=20by=20?= =?UTF-8?q?a=20past=20alignment=20=20=20commit,=20never=20published=20or?= =?UTF-8?q?=20enforced=20by=20the=20backend=20in=20any=20revision=20-=20up?= =?UTF-8?q?date=20the=20auth=20and=20parents=20tests,=20which=20pinned=20b?= =?UTF-8?q?oth=20wrong=20shapes?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api/__tests__/auth/auth.test.ts | 8 +- src/api/__tests__/parents/parents.test.ts | 2 +- src/api/auth/postRegister.ts | 12 +- src/api/client/types.ts | 1241 ++++++++++----------- src/api/parents/postParentStudent.ts | 2 +- 5 files changed, 635 insertions(+), 630 deletions(-) diff --git a/src/api/__tests__/auth/auth.test.ts b/src/api/__tests__/auth/auth.test.ts index 4a71d0e..47ea78f 100644 --- a/src/api/__tests__/auth/auth.test.ts +++ b/src/api/__tests__/auth/auth.test.ts @@ -33,12 +33,12 @@ describe("auth API", () => { }); it("postRegister calls /auth/register with data", async () => { - const mockUser = { id: "u2", username: "newuser" }; - mockFetchSuccess(mockUser); + const mockResponse = { username: "newuser", role: "student" }; + mockFetchSuccess(mockResponse); - const data = { school: "demo", username: "newuser", password: "password", email: "test@test.com" }; + const data = { school: "demo", username: "newuser", password: "password" }; const result = await postRegister(data); - expect(result).toEqual(mockUser); + expect(result).toEqual(mockResponse); const [url, init] = lastFetchCall(); expect(url).toBe("/api/auth/register"); diff --git a/src/api/__tests__/parents/parents.test.ts b/src/api/__tests__/parents/parents.test.ts index 7984246..da610eb 100644 --- a/src/api/__tests__/parents/parents.test.ts +++ b/src/api/__tests__/parents/parents.test.ts @@ -32,7 +32,7 @@ describe("parents API", () => { const [url, init] = lastFetchCall(); expect(url).toBe("/api/users/u1/students"); expect(init?.method).toBe("POST"); - 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 + expect(init?.body).toBe(JSON.stringify({ user_id: "s1" })); }); it("deleteParentStudent calls /users/:id/students/:studentId", async () => { diff --git a/src/api/auth/postRegister.ts b/src/api/auth/postRegister.ts index 8ad8368..78fdcc7 100644 --- a/src/api/auth/postRegister.ts +++ b/src/api/auth/postRegister.ts @@ -1,5 +1,5 @@ import { client } from "../client"; -import type { User } from "../client"; +import type { Role } from "../client"; export type RegisterBody = { school: string; @@ -7,6 +7,12 @@ export type RegisterBody = { password: string; }; -export function postRegister(body: RegisterBody): Promise { - return client("/auth/register", { method: "POST", body }); +/** Backend answers 201 {username, role} only — anti-enumeration, no id. */ +export type RegisterResponse = { + username: string; + role: Role; +}; + +export function postRegister(body: RegisterBody): Promise { + return client("/auth/register", { method: "POST", body }); } diff --git a/src/api/client/types.ts b/src/api/client/types.ts index ae6f331..db03db5 100644 --- a/src/api/client/types.ts +++ b/src/api/client/types.ts @@ -13,44 +13,44 @@ export type QuestionKind = "choice" | "text"; export type AttemptStatus = "in_progress" | "submitted" | "expired"; export type User = { - id: string; - username: string; - role: Role; - name: string | null; - surname: string | null; - email: string | null; - phone: string | null; - birth_date: string | null; - theme: UserTheme | null; - language: UserLanguage | null; - palette_color: string | null; + id: string; + username: string; + role: Role; + name: string | null; + surname: string | null; + email: string | null; + phone: string | null; + birth_date: string | null; + theme: UserTheme | null; + language: UserLanguage | null; + palette_color: string | null; }; // PATCH /users/me and PATCH /users/{id}/profile take the same body: an omitted // (or null) field is left alone, an empty string clears it. export type ProfileUpdate = { - name?: string | null; - surname?: string | null; - email?: string | null; - phone?: string | null; - birth_date?: string | null; - display_name?: string | null; - bio?: string | null; + name?: string | null; + surname?: string | null; + email?: string | null; + phone?: string | null; + birth_date?: string | null; + display_name?: string | null; + bio?: string | null; }; export type PersonRef = { - id: string; - username: string; - display_name: string | null; + id: string; + username: string; + display_name: string | null; }; // The lifetime counter a badge reads. Badges sharing a stat form a ladder. export type BadgeStat = - | "homework_submitted" - | "homework_on_time" - | "exam_sat" - | "pomodoro_finished" - | "pomodoro_focus_ms"; + | "homework_submitted" + | "homework_on_time" + | "exam_sat" + | "pomodoro_finished" + | "pomodoro_focus_ms"; // One entry of the badge catalogue, served by GET /limits. The label and icon // 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 }; // Lifetime counters behind the badge ladders, plus the two live totals the // capped `classes`/`courses` lists would otherwise hide. export type ProfileStats = { - pomodoro_sessions: number; - pomodoro_focus_ms: number; - courses: number; - classes: number; - homework_submitted_total: number; - homework_on_time_total: number; - exam_sat_total: number; - pomodoro_finished_total: number; - pomodoro_focus_ms_total: number; + pomodoro_sessions: number; + pomodoro_focus_ms: number; + courses: number; + classes: number; + homework_submitted_total: number; + homework_on_time_total: number; + exam_sat_total: number; + pomodoro_finished_total: number; + pomodoro_focus_ms_total: number; }; // A person's public profile. Readable by any authenticated account except a // parent, who only reaches their own and their linked students'. Never carries // email, phone or birth date at any role — those stay on GET /users/{id}. export type Profile = { - id: string; - username: string; - display_name: string | null; - role: Role; - bio: string | null; - avatar: AvatarMeta | null; - // Capped at limits.user.max_profile_classes; stats.classes holds the true total. - classes: ProfileClassRef[]; - // Capped at limits.user.max_profile_courses, and filtered to what the reader - // may see; stats.courses holds the owner's true, unfiltered total. - courses: ProfileCourseRef[]; - badges: EarnedBadge[]; - stats: ProfileStats; + id: string; + username: string; + display_name: string | null; + role: Role; + bio: string | null; + avatar: AvatarMeta | null; + // Capped at limits.user.max_profile_classes; stats.classes holds the true total. + classes: ProfileClassRef[]; + // Capped at limits.user.max_profile_courses, and filtered to what the reader + // may see; stats.courses holds the owner's true, unfiltered total. + courses: ProfileCourseRef[]; + badges: EarnedBadge[]; + stats: ProfileStats; }; export type Note = { - id: string; - title: string; - content: string; + id: string; + title: string; + content: string; }; /** A note attached to a course; files reuse the personal note's `NoteFile` shape. */ export type CourseNote = { - id: string; - course: string; - title: string; - content: string; + id: string; + course: string; + title: string; + content: string; }; /** One AI service output stored against a course note. `payload` is the * service's own shape — stored and served unread, rendered as JSON. */ export type RagOutput = { - id: string; - course_note: string; - course: string; - /** The note's file attachments the output was built from. */ - sources: string[]; - payload: unknown; - /** When the backend stored it, epoch milliseconds. */ - generated_at: number; + id: string; + course_note: string; + course: string; + /** The note's file attachments the output was built from. */ + sources: string[]; + payload: unknown; + /** When the backend stored it, epoch milliseconds. */ + generated_at: number; }; export type NoteFile = { - id: string; - name: string; - content_type: string; - size: number; + id: string; + name: string; + content_type: string; + size: number; }; /** The caller's school entitlements: every switched-on module, sorted by name. */ export type EnabledModules = { - enabled: string[]; + enabled: string[]; }; export type ModuleCatalogEntry = { - module: string; - package: string; - /** Modules that must be enabled alongside this one. */ - requires: string[]; + module: string; + package: string; + /** Modules that must be enabled alongside this one. */ + requires: string[]; }; export type ModuleCatalogPackage = { - package: string; - modules: string[]; + package: string; + modules: string[]; }; /** The deployment's whole module catalog — identical for every school. */ export type ModuleCatalog = { - modules: ModuleCatalogEntry[]; - packages: ModuleCatalogPackage[]; + modules: ModuleCatalogEntry[]; + packages: ModuleCatalogPackage[]; }; export type EventAudience = - | { kind: "school" } - | { kind: "role"; role: Role } - | { kind: "course"; course: string } - | { kind: "registration"; capacity?: number | null }; + | { kind: "school" } + | { kind: "role"; role: Role } + | { kind: "course"; course: string } + | { kind: "registration"; capacity?: number | null }; export type Event = { - id: string; - creator: string; - title: string; - description: string; - audience: EventAudience; - starts_at: number | null; - ends_at: number | null; + id: string; + creator: string; + title: string; + description: string; + audience: EventAudience; + starts_at: number | null; + ends_at: number | null; }; export type Attendance = { - id: string; - event: string; - user: PersonRef; - status: AttendanceStatus; - marked_by: PersonRef; + id: string; + event: string; + user: PersonRef; + status: AttendanceStatus; + marked_by: PersonRef; }; export type EventRosterEntry = { - user: PersonRef; - status: AttendanceStatus | null; - marked_by: PersonRef | null; + user: PersonRef; + status: AttendanceStatus | null; + marked_by: PersonRef | null; }; export type EventRegistration = { - event: string; - user: PersonRef; - registered_by: PersonRef; + event: string; + user: PersonRef; + registered_by: PersonRef; }; export type AppointmentStatus = "pending" | "approved" | "rejected" | "cancelled"; export type AppointmentSlot = { - id: string; - teacher: PersonRef; - starts_at: number; // unix ms UTC - ends_at: number; // unix ms UTC, half-open - note: string | null; - series: string | null; // null = one-off; shared id across a weekly series - created_at: number; + id: string; + teacher: PersonRef; + starts_at: number; // unix ms UTC + ends_at: number; // unix ms UTC, half-open + note: string | null; + series: string | null; // null = one-off; shared id across a weekly series + created_at: number; }; export type Appointment = { - id: string; - slot: string; - teacher: PersonRef | null; // null only if slot vanished - requester: PersonRef; - status: AppointmentStatus; - reason: string; - starts_at: number | null; // effective window: the proposal whenever one is on the - // row (accepted or not), else the slot's own time - ends_at: number | null; - proposed_starts_at: number | null; - proposed_ends_at: number | null; - proposed_by: PersonRef | null; - decided_by: PersonRef | null; // null while pending - cancelled_by: PersonRef | null; // set only when status === "cancelled" - cancel_reason: string | null; // optional reason, null when none given - reject_reason: string | null; // optional reason when status === "rejected" (rejecter is decided_by) - created_at: number; + id: string; + slot: string; + teacher: PersonRef | null; // null only if slot vanished + requester: PersonRef; + status: AppointmentStatus; + reason: string; + starts_at: number | null; // effective window: the proposal whenever one is on the + // row (accepted or not), else the slot's own time + ends_at: number | null; + proposed_starts_at: number | null; + proposed_ends_at: number | null; + proposed_by: PersonRef | null; + decided_by: PersonRef | null; // null while pending + cancelled_by: PersonRef | null; // set only when status === "cancelled" + cancel_reason: string | null; // optional reason, null when none given + reject_reason: string | null; // optional reason when status === "rejected" (rejecter is decided_by) + created_at: number; }; export const APPOINTMENT_LIMITS = { - noteMaxLen: 500, // MAX_APPOINTMENT_NOTE_LEN, empty allowed - reasonMaxLen: 1000, // MAX_APPOINTMENT_REASON_LEN, non-blank required - maxSlotOccurrences: 52, // MAX_SLOT_OCCURRENCES for repeat_weekly + noteMaxLen: 500, // MAX_APPOINTMENT_NOTE_LEN, empty allowed + reasonMaxLen: 1000, // MAX_APPOINTMENT_REASON_LEN, non-blank required + maxSlotOccurrences: 52, // MAX_SLOT_OCCURRENCES for repeat_weekly } as const; export const BANK_QUESTION_LIMITS = { - textMaxLen: 2000, // MAX_QUESTION_TEXT_LEN - choiceTextMaxLen: 500, // MAX_CHOICE_TEXT_LEN - minPoints: 1, // MIN_QUESTION_POINTS - maxPoints: 100, // MAX_QUESTION_POINTS - minChoices: 2, // MIN_QUESTION_CHOICES - maxChoices: 10, // MAX_QUESTION_CHOICES + textMaxLen: 2000, // MAX_QUESTION_TEXT_LEN + choiceTextMaxLen: 500, // MAX_CHOICE_TEXT_LEN + minPoints: 1, // MIN_QUESTION_POINTS + maxPoints: 100, // MAX_QUESTION_POINTS + minChoices: 2, // MIN_QUESTION_CHOICES + maxChoices: 10, // MAX_QUESTION_CHOICES } as const; export type Course = { - id: string; - creator: PersonRef; - teachers?: PersonRef[]; - title: string; - description: string; - kind: CourseKind; - term: string | null; - capacity: number | null; + id: string; + creator: PersonRef; + teachers?: PersonRef[]; + title: string; + description: string; + kind: CourseKind; + term: string | null; + capacity: number | null; }; export type Term = { - id: string; - name: string; - starts_at: number; - ends_at: number; - /** Archived at, UTC unix-millis; null while the term is open. */ - archived_at: number | null; + id: string; + name: string; + starts_at: number; + ends_at: number; + /** Archived at, UTC unix-millis; null while the term is open. */ + archived_at: number | null; }; export type Enrollment = { - id: string; - course: string; - user: PersonRef; - enrolled_by: PersonRef; - // The class (ClassGroup id) that pumped this enrollment, or null for a - // hand-placed row. A row with a source is swept when that class drops the - // student or detaches the course; a null row is permanent. - source: string | null; + id: string; + course: string; + user: PersonRef; + enrolled_by: PersonRef; + // The class (ClassGroup id) that pumped this enrollment, or null for a + // hand-placed row. A row with a source is swept when that class drops the + // student or detaches the course; a null row is permanent. + source: string | null; }; // A class (şube): a named group of students, optionally tied to a term, that // pumps the Cartesian product of its members × attached courses into real // enrollment rows. See src/api/classes. export type ClassGroup = { - id: string; - // null for a caller below teacher+ — the office's account names are not - // theirs to learn (a student's own GET /classes/me, a parent's - // GET /classes/user/{user}). - creator: PersonRef | null; - name: string; - grade: string | null; - term: string | null; - // The class's homeroom teacher (sınıf öğretmeni); null when none is assigned. - teacher: PersonRef | null; + id: string; + // null for a caller below teacher+ — the office's account names are not + // theirs to learn (a student's own GET /classes/me, a parent's + // GET /classes/user/{user}). + creator: PersonRef | null; + name: string; + grade: string | null; + term: string | null; + // The class's homeroom teacher (sınıf öğretmeni); null when none is assigned. + teacher: PersonRef | null; }; export type ClassMember = { - id: string; - class: string; - user: PersonRef; - added_by: PersonRef; + id: string; + class: string; + user: PersonRef; + added_by: PersonRef; }; export type ClassCourse = { - id: string; - class: string; - course: string; - attached_by: PersonRef; + id: string; + class: string; + course: string; + attached_by: PersonRef; }; // A grade blueprint: the set of courses every class at one grade takes. The // grade label is the record's key, so there is at most one per grade. Creating // or editing one applies it to every existing class at that grade right away. export type ClassBlueprint = { - grade: string; - courses: string[]; - creator: PersonRef; + grade: string; + courses: string[]; + creator: PersonRef; }; // One (class, course) pair a blueprint could not attach. Applying is // best-effort: a pair that cannot land is reported here and the rest still go // through. `reason` is backend English — localize it, never render it raw. export type BlueprintSkip = { - class: string; - class_name: string; - course: string; - reason: string; + class: string; + class_name: string; + course: string; + reason: string; }; export type BlueprintResult = { blueprint: ClassBlueprint; skipped: BlueprintSkip[] }; @@ -325,85 +325,85 @@ export type BlueprintApplyResult = { skipped: BlueprintSkip[] }; /** One section measured against its grade's blueprint. */ export type BlueprintSectionStatus = { - class: string; - class_name: string; - /** Template courses the section does not carry; empty when in sync. */ - missing: string[]; + class: string; + class_name: string; + /** Template courses the section does not carry; empty when in sync. */ + missing: string[]; }; /** Every section at a grade with the template courses it is missing. */ export type BlueprintStatus = { - grade: string; - /** The template every section below is measured against. */ - courses: string[]; - matched: number; - sections: BlueprintSectionStatus[]; + grade: string; + /** The template every section below is measured against. */ + courses: string[]; + matched: number; + sections: BlueprintSectionStatus[]; }; export type CourseSession = { - id: string; - course: string; - teacher: PersonRef; - topic: string; - starts_at: number; - ends_at: number | null; + id: string; + course: string; + teacher: PersonRef; + topic: string; + starts_at: number; + ends_at: number | null; }; export type SessionAttendance = { - id: string; - session: string; - course: string; - user: PersonRef; - status: AttendanceStatus; - marked_by: PersonRef; + id: string; + session: string; + course: string; + user: PersonRef; + status: AttendanceStatus; + marked_by: PersonRef; }; export type Exam = { - id: string; - creator: string; - course: string; - title: string; - description: string; - kind: ExamKind | string; - mode: ExamMode | string | null; - starts_at: number | null; - ends_at: number | null; - duration_ms: number | null; - max_attempts: number; - allow_rejoin: boolean; - allow_review: boolean; - draft: boolean; + id: string; + creator: string; + course: string; + title: string; + description: string; + kind: ExamKind | string; + mode: ExamMode | string | null; + starts_at: number | null; + ends_at: number | null; + duration_ms: number | null; + max_attempts: number; + allow_rejoin: boolean; + allow_review: boolean; + draft: boolean; }; export type ImageMeta = { - content_type: string; - size: number; + content_type: string; + size: number; }; export type ExamResult = { - id: string; - exam: string; - user: PersonRef; - mark: number; - graded_by: PersonRef; + id: string; + exam: string; + user: PersonRef; + mark: number; + graded_by: PersonRef; }; /** One option of a choice question. `id` is stable across edits, so its image survives. */ export type Choice = { id: string; text: string }; export type ExamQuestion = { - id: string; - exam: string; - subject: string; - text: string; - kind: QuestionKind; - points: number; - choices: Choice[] | null; - correct: string | null; - image?: ImageMeta | null; - choice_images?: (ImageMeta | null)[] | null; - from_bank?: string | null; // bank template this question was added from, if any - banked_as?: string | null; // bank template last created by saving this question, if any + id: string; + exam: string; + subject: string; + text: string; + kind: QuestionKind; + points: number; + choices: Choice[] | null; + correct: string | null; + image?: ImageMeta | null; + choice_images?: (ImageMeta | null)[] | null; + from_bank?: string | null; // bank template this question was added from, if any + banked_as?: string | null; // bank template last created by saving this question, if any }; /** `private`: owner + admins only. `school`: every teacher can see it and its answer key. */ @@ -411,372 +411,371 @@ export type BankVisibility = "private" | "school"; /** Reusable question stored in the school-wide question bank, outside any exam. */ export type BankQuestion = { - id: string; - owner: string; // user id - owner_name: string; - subject: string | null; // subject id (origin metadata); null once that subject is deleted - subject_name: string; - text: string; - kind: QuestionKind; - points: number; - choices: Choice[] | null; - correct: string | null; - image?: ImageMeta | null; - choice_images?: (ImageMeta | null)[] | null; - source_exam?: string | null; - visibility: BankVisibility; // new templates start "private" - created_at: number; // UTC unix ms - /** - * How many exam questions were copied out of this template. Each copy is - * detached, so editing the template never reaches them — this is the - * divergence surface. List-only, exactly like `subject_name`/`owner_name`: - * the single-template endpoints return 0. - */ - used_count: number; + id: string; + owner: string; // user id + owner_name: string; + subject: string | null; // subject id (origin metadata); null once that subject is deleted + subject_name: string; + text: string; + kind: QuestionKind; + points: number; + choices: Choice[] | null; + correct: string | null; + image?: ImageMeta | null; + choice_images?: (ImageMeta | null)[] | null; + source_exam?: string | null; + visibility: BankVisibility; // new templates start "private" + created_at: number; // UTC unix ms + /** + * How many exam questions were copied out of this template. Each copy is + * detached, so editing the template never reaches them — this is the + * divergence surface. List-only, exactly like `subject_name`/`owner_name`: + * the single-template endpoints return 0. + */ + used_count: number; }; export type ExamAttempt = { - id: string; - exam: string; - user: PersonRef; - status: AttemptStatus; - attempt: number; - attempts_used: number; - max_attempts: number; - started_at: number; - finished_at: number | null; - deadline: number | null; - remaining_ms: number | null; - left_at: number | null; - mark: number | null; - answered: number; - question_count: number; - now: number; + id: string; + exam: string; + user: PersonRef; + status: AttemptStatus; + attempt: number; + attempts_used: number; + max_attempts: number; + started_at: number; + finished_at: number | null; + deadline: number | null; + remaining_ms: number | null; + left_at: number | null; + mark: number | null; + answered: number; + question_count: number; + now: number; }; export type AttemptAnswer = { - selected?: string | null; - text?: string | null; - updated_at?: number; - answer_image?: ImageMeta | null; + selected?: string | null; + text?: string | null; + updated_at?: number; + answer_image?: ImageMeta | null; }; export type AttemptQuestionResponse = { - id: string; - subject: string; - text: string; - kind: QuestionKind; - points: number; - choices: Choice[] | null; - image?: ImageMeta | null; - choice_images?: (ImageMeta | null)[] | null; - answer: AttemptAnswer | null; + id: string; + subject: string; + text: string; + kind: QuestionKind; + points: number; + choices: Choice[] | null; + image?: ImageMeta | null; + choice_images?: (ImageMeta | null)[] | null; + answer: AttemptAnswer | null; }; export type AttemptQuestion = AttemptQuestionResponse & { exam: string }; export type PomodoroSession = { - id: string; - user: string; - started_at: number; - finished_at: number | null; - duration_ms: number | null; + id: string; + user: string; + started_at: number; + finished_at: number | null; + duration_ms: number | null; }; export type PomodoroLog = { - items: PomodoroSession[]; - total: number; - limit: number | null; - offset: number; - total_focus_ms: number; + items: PomodoroSession[]; + total: number; + limit: number | null; + offset: number; + total_focus_ms: number; }; export type Subject = { - id: string; - course: string; - name: string; - description: string; + id: string; + course: string; + name: string; + description: string; }; export type MarkEntry = { - exam: string; - title: string; - kind: string; - weight: number; - mark: number; - grade?: string | null; - graded_by: string; + exam: string; + title: string; + kind: string; + weight: number; + mark: number; + grade?: string | null; + graded_by: string; }; export type CourseMarks = { - course: Course; - results: MarkEntry[]; - average: number | null; - average_grade?: string | null; + course: Course; + results: MarkEntry[]; + average: number | null; + average_grade?: string | null; }; export type AttendanceCounts = { - present: number; - absent: number; - late: number; - excused: number; - custom: Record; - total: number; - rate: number | null; + present: number; + absent: number; + late: number; + excused: number; + custom: Record; + total: number; + rate: number | null; }; export type CourseAttendance = { - course: Course; - counts: AttendanceCounts; + course: Course; + counts: AttendanceCounts; }; export type AttendanceReport = { - user: string; - events: AttendanceCounts; - sessions: AttendanceCounts; - courses: CourseAttendance[]; + user: string; + events: AttendanceCounts; + sessions: AttendanceCounts; + courses: CourseAttendance[]; }; export type WorkEntry = { - id: string; - user: string; - check_in: number; - check_out: number | null; - duration_ms: number | null; + id: string; + user: string; + check_in: number; + check_out: number | null; + duration_ms: number | null; }; export type MarksReport = { - user: string; - courses: CourseMarks[]; - overall_average: number | null; - overall_grade?: string | null; + user: string; + courses: CourseMarks[]; + overall_average: number | null; + overall_grade?: string | null; }; export type ExamStatistics = { - exam: string; - graded: number; - average: number | null; - min: number | null; - max: number | null; + exam: string; + graded: number; + average: number | null; + min: number | null; + max: number | null; }; export type StudentAnswer = { - question: string; - selected: string | null; - text: string | null; - updated_at: number; - is_correct: boolean | null; - answer_image?: ImageMeta | null; + question: string; + selected: string | null; + text: string | null; + updated_at: number; + is_correct: boolean | null; + answer_image?: ImageMeta | null; }; export type StudentAnswerSheet = { - exam: string; - user: PersonRef; - answers: StudentAnswer[]; - auto_score: { earned: number; possible: number }; + exam: string; + user: PersonRef; + answers: StudentAnswer[]; + auto_score: { earned: number; possible: number }; }; export type LiveRosterEntry = { - user: PersonRef; - status: AttemptStatus | "not_started" | "absent"; - attempt: number | null; - attempts_used: number; - deadline: number | null; - remaining_ms: number | null; - left_at: number | null; - mark: number | null; - answered: number; - started_at: number | null; - finished_at: number | null; - last_activity: number | null; + user: PersonRef; + status: AttemptStatus | "not_started" | "absent"; + attempt: number | null; + attempts_used: number; + deadline: number | null; + remaining_ms: number | null; + left_at: number | null; + mark: number | null; + answered: number; + started_at: number | null; + finished_at: number | null; + last_activity: number | null; }; export type LiveMonitor = { - exam: Exam; - now: number; - question_count: number; - students: LiveRosterEntry[]; - counts: { - enrolled: number; - not_started: number; - absent: number; - in_progress: number; - submitted: number; - expired: number; - graded: number; - }; + exam: Exam; + now: number; + question_count: number; + students: LiveRosterEntry[]; + counts: { + enrolled: number; + not_started: number; + absent: number; + in_progress: number; + submitted: number; + expired: number; + graded: number; + }; }; export type ExamKindSetting = { - name: string; - weight: number; + name: string; + weight: number; }; export type GradeBand = { - min: number; - label: string; + min: number; + label: string; }; export type MealSlot = { - name: string; - serving_minute: number | null; + name: string; + serving_minute: number | null; }; export type SchoolSettings = { - exam_kinds: ExamKindSetting[]; - attendance_statuses: string[]; - grade_bands: GradeBand[]; - max_file_bytes: number; - chatbot_history_turns: number; - max_chatbot_threads: number; - max_chatbot_message_len: number; - meal_slots: MealSlot[]; - dietary_tags: string[]; - meal_cancel_cutoff_minutes: number | null; + exam_kinds: ExamKindSetting[]; + attendance_statuses: string[]; + grade_bands: GradeBand[]; + max_file_bytes: number; + chatbot_history_turns: number; + max_chatbot_threads: number; + max_chatbot_message_len: number; + meal_slots: MealSlot[]; + dietary_tags: string[]; + meal_cancel_cutoff_minutes: number | null; }; export type Limits = { - user: { - min_username_len: number; - max_username_len: number; - username_separators: string[]; - reserved_usernames: string[]; - min_password_len: number; - max_password_len: number; - max_name_len: number; - max_display_name_len: number; - max_bio_len: number; - // Caps on what a profile read embeds, not on membership: the full lists - // stay at /courses/me and /classes/me. - max_profile_courses: number; - max_profile_classes: number; - max_email_len: number; - min_phone_digits: number; - max_phone_digits: number; - roles: Role[]; - themes: UserTheme[]; - languages: UserLanguage[]; - session_duration_days: number; - }; - badges: { catalog: BadgeCatalogEntry[] }; - note: { max_title_len: number; max_content_len: number; max_files: number }; - file: { - max_name_len: number; - max_content_type_len: number; - min_max_file_bytes: number; - max_max_file_bytes: number; - default_max_file_bytes: number; - image_content_types: string[]; - }; - message: { max_subject_len: number; max_body_len: number; max_label_len: number }; - event: { max_title_len: number; max_description_len: number }; - course: { - max_title_len: number; - max_description_len: number; - kinds: CourseKind[]; - max_subject_name_len: number; - max_subject_description_len: number; - max_session_topic_len: number; - max_term_name_len: number; - max_class_name_len: number; - max_class_grade_len: number; - max_class_members: number; - max_class_courses: number; - max_class_bytes: number; - }; - exam: { - max_title_len: number; - max_description_len: number; - modes: ExamMode[]; - min_duration_ms: number; - max_duration_ms: number; - max_attempts: number; - unlimited_attempts: number; - question_kinds: QuestionKind[]; - max_question_text_len: number; - min_question_points: number; - max_question_points: number; - min_question_choices: number; - max_question_choices: number; - max_choice_text_len: number; - max_answer_text_len: number; - min_mark: number; - max_mark: number; - ws_tick_secs: number; - ws_max_question_id_len: number; - }; - homework: { - max_title_len: number; - max_description_len: number; - max_text_len: number; - max_files_per_submission: number; - max_assigned: number; - statuses: string[]; - }; - question_pool: { max_title_len: number; max_body_len: number; max_solution_body_len: number }; - appointment: { max_note_len: number; max_reason_len: number; max_slot_occurrences: number }; - meal: { - max_dish_name_len: number; - max_dish_description_len: number; - max_dishes_per_menu: number; - max_dish_tags: number; - max_menu_capacity: number; - max_dietary_tags: number; - max_dietary_note_len: number; - max_dish_price_minor: number; - max_ledger_amount_minor: number; - max_ledger_method_len: number; - max_ledger_note_len: number; - max_cancel_cutoff_minutes: number; - max_serving_minute: number; - booking_statuses: string[]; - attendance_statuses: string[]; - ledger_kinds: string[]; - }; - payment: { - max_plan_name_len: number; - max_plan_installments: number; - max_assign_students: number; - max_request_key_len: number; - ledger_kinds: string[]; - }; - chatbot: { - max_message_len: number; - max_thread_title_len: number; - min_max_message_len: number; - max_max_message_len: number; - default_max_message_len: number; - min_history_turns: number; - max_history_turns: number; - default_history_turns: number; - min_max_threads: number; - max_max_threads: number; - default_max_threads: number; - }; - board: { - max_title_len: number; - // People the creator may name onto one board. Every participant draws, so - // this also bounds a room's writer count. - max_participants: number; - max_stroke_payload_len: number; - max_epoch_strokes: number; - max_board_strokes: number; - max_boards_per_creator: number; - stroke_kinds: string[]; - ws_tick_secs: number; - ws_max_board_id_len: number; - }; - settings: { - max_list_len: number; - max_item_len: number; - min_exam_kind_weight: number; - max_exam_kind_weight: number; - max_grade_bands: number; - max_grade_label_len: number; - required_attendance_statuses: string[]; - }; - request: { max_page_limit: number; schedule_past_grace_ms: number; request_timeout_secs: number }; - rate: { window_secs: number; auth_per_minute: number; api_per_minute: number; chatbot_per_minute: number }; + user: { + min_username_len: number; + max_username_len: number; + username_separators: string[]; + reserved_usernames: string[]; + min_password_len: number; + max_password_len: number; + max_name_len: number; + max_display_name_len: number; + max_bio_len: number; + // Caps on what a profile read embeds, not on membership: the full lists + // stay at /courses/me and /classes/me. + max_profile_courses: number; + max_profile_classes: number; + max_email_len: number; + min_phone_digits: number; + max_phone_digits: number; + roles: Role[]; + themes: UserTheme[]; + languages: UserLanguage[]; + session_duration_days: number; + }; + badges: { catalog: BadgeCatalogEntry[] }; + note: { max_title_len: number; max_content_len: number; max_files: number }; + file: { + max_name_len: number; + max_content_type_len: number; + min_max_file_bytes: number; + max_max_file_bytes: number; + default_max_file_bytes: number; + image_content_types: string[]; + }; + message: { max_subject_len: number; max_body_len: number; max_label_len: number }; + event: { max_title_len: number; max_description_len: number }; + course: { + max_title_len: number; + max_description_len: number; + kinds: CourseKind[]; + max_subject_name_len: number; + max_subject_description_len: number; + max_session_topic_len: number; + max_term_name_len: number; + max_class_name_len: number; + max_class_grade_len: number; + max_class_members: number; + max_class_courses: number; + }; + exam: { + max_title_len: number; + max_description_len: number; + modes: ExamMode[]; + min_duration_ms: number; + max_duration_ms: number; + max_attempts: number; + unlimited_attempts: number; + question_kinds: QuestionKind[]; + max_question_text_len: number; + min_question_points: number; + max_question_points: number; + min_question_choices: number; + max_question_choices: number; + max_choice_text_len: number; + max_answer_text_len: number; + min_mark: number; + max_mark: number; + ws_tick_secs: number; + ws_max_question_id_len: number; + }; + homework: { + max_title_len: number; + max_description_len: number; + max_text_len: number; + max_files_per_submission: number; + max_assigned: number; + statuses: string[]; + }; + question_pool: { max_title_len: number; max_body_len: number; max_solution_body_len: number }; + appointment: { max_note_len: number; max_reason_len: number; max_slot_occurrences: number }; + meal: { + max_dish_name_len: number; + max_dish_description_len: number; + max_dishes_per_menu: number; + max_dish_tags: number; + max_menu_capacity: number; + max_dietary_tags: number; + max_dietary_note_len: number; + max_dish_price_minor: number; + max_ledger_amount_minor: number; + max_ledger_method_len: number; + max_ledger_note_len: number; + max_cancel_cutoff_minutes: number; + max_serving_minute: number; + booking_statuses: string[]; + attendance_statuses: string[]; + ledger_kinds: string[]; + }; + payment: { + max_plan_name_len: number; + max_plan_installments: number; + max_assign_students: number; + max_request_key_len: number; + ledger_kinds: string[]; + }; + chatbot: { + max_message_len: number; + max_thread_title_len: number; + min_max_message_len: number; + max_max_message_len: number; + default_max_message_len: number; + min_history_turns: number; + max_history_turns: number; + default_history_turns: number; + min_max_threads: number; + max_max_threads: number; + default_max_threads: number; + }; + board: { + max_title_len: number; + // People the creator may name onto one board. Every participant draws, so + // this also bounds a room's writer count. + max_participants: number; + max_stroke_payload_len: number; + max_epoch_strokes: number; + max_board_strokes: number; + max_boards_per_creator: number; + stroke_kinds: string[]; + ws_tick_secs: number; + ws_max_board_id_len: number; + }; + settings: { + max_list_len: number; + max_item_len: number; + min_exam_kind_weight: number; + max_exam_kind_weight: number; + max_grade_bands: number; + max_grade_label_len: number; + required_attendance_statuses: string[]; + }; + request: { max_page_limit: number; schedule_past_grace_ms: number; request_timeout_secs: number }; + rate: { window_secs: number; auth_per_minute: number; api_per_minute: number; chatbot_per_minute: number }; }; // Fallbacks keep forms usable when the unauthenticated metadata request fails. @@ -787,141 +786,141 @@ export const QUESTION_KINDS: QuestionKind[] = ["choice", "text"]; export type MessageFolder = "inbox" | "sent" | "archive" | "trash"; export type Message = { - id: string; - sender: PersonRef; - sender_role: Role | null; - recipient: PersonRef; - recipient_role: Role | null; - subject: string; - body: string; - sent_at: number; - read: boolean; - folder: MessageFolder; - previous_folder?: MessageFolder | string | null; - label: string | null; + id: string; + sender: PersonRef; + sender_role: Role | null; + recipient: PersonRef; + recipient_role: Role | null; + subject: string; + body: string; + sent_at: number; + read: boolean; + folder: MessageFolder; + previous_folder?: MessageFolder | string | null; + label: string | null; }; export type Homework = { - id: string; - course: string; - subject: string; - title: string; - description: string | null; - due_at: number; - assigned: string[] | null; - created_by: string; - created_at: number; + id: string; + course: string; + subject: string; + title: string; + description: string | null; + due_at: number; + assigned: string[] | null; + created_by: string; + created_at: number; }; export type HomeworkFile = { - id: string; - name: string; - content_type: string; - size: number; + id: string; + name: string; + content_type: string; + size: number; }; export type HomeworkResultStatus = "done" | "incomplete" | "missing" | string; export type HomeworkResult = { - status: HomeworkResultStatus; - mark: number | null; - graded_by: string; - created_at: number; + status: HomeworkResultStatus; + mark: number | null; + graded_by: string; + created_at: number; }; export type HomeworkSubmission = { - user: string; - homework: string; - text: string | null; - submitted_at: number; - updated_at: number; - late: boolean; - files: HomeworkFile[]; - result: HomeworkResult | null; + user: string; + homework: string; + text: string | null; + submitted_at: number; + updated_at: number; + late: boolean; + files: HomeworkFile[]; + result: HomeworkResult | null; }; export type HomeworkRosterSubmission = Omit; export type HomeworkRosterEntry = { - user: string; - submission: HomeworkRosterSubmission | null; - result: HomeworkResult | null; - missing: boolean; - unenrolled: boolean; + user: string; + submission: HomeworkRosterSubmission | null; + result: HomeworkResult | null; + missing: boolean; + unenrolled: boolean; }; export type HomeworkReportEntry = { - course: string; - homework: string; - title: string; - subject: string; - due_at: number; - submitted: boolean; - late: boolean; - missing: boolean; - result: HomeworkResult | null; + course: string; + homework: string; + title: string; + subject: string; + due_at: number; + submitted: boolean; + late: boolean; + missing: boolean; + result: HomeworkResult | null; }; export type MealDish = { - id: string; - name: string; - description: string | null; - price_minor: number; - tags: string[]; - conflicts: string[]; - created_at: number; + id: string; + name: string; + description: string | null; + price_minor: number; + tags: string[]; + conflicts: string[]; + created_at: number; }; export type MealMenu = { - id: string; - date: string; - slot: string; - capacity: number | null; - dishes: MealDish[]; - created_by: PersonRef; - created_at: number; + id: string; + date: string; + slot: string; + capacity: number | null; + dishes: MealDish[]; + created_by: PersonRef; + created_at: number; }; export type MealBooking = { - id: string; - menu_id: string; - student: PersonRef; - booked_by: PersonRef; - status: string; - cancelled_at: number | null; - created_at: number; + id: string; + menu_id: string; + student: PersonRef; + booked_by: PersonRef; + status: string; + cancelled_at: number | null; + created_at: number; }; export type MealAttendance = { - id: string; - menu_id: string; - student: PersonRef; - status: string; - marked_by: PersonRef; - marked_at: number; + id: string; + menu_id: string; + student: PersonRef; + status: string; + marked_by: PersonRef; + marked_at: number; }; export type DietaryProfile = { - student: PersonRef; - tags: string[]; - note: string | null; - updated_by: PersonRef | null; - updated_at: number | null; + student: PersonRef; + tags: string[]; + note: string | null; + updated_by: PersonRef | null; + updated_at: number | null; }; export type MealBalance = { - student: PersonRef; - balance_minor: number; + student: PersonRef; + balance_minor: number; }; export type MealLedgerEntry = { - id: string; - student: PersonRef; - kind: string; - amount_minor: number; - source: string | null; - method: string | null; - note: string | null; - recorded_by: PersonRef; - created_at: number; + id: string; + student: PersonRef; + kind: string; + amount_minor: number; + source: string | null; + method: string | null; + note: string | null; + recorded_by: PersonRef; + created_at: number; }; diff --git a/src/api/parents/postParentStudent.ts b/src/api/parents/postParentStudent.ts index bbb3419..5353c2c 100644 --- a/src/api/parents/postParentStudent.ts +++ b/src/api/parents/postParentStudent.ts @@ -10,6 +10,6 @@ export interface ParentLinkResponse { export async function postParentStudent(id: string, user_id: string): Promise { return client(`/users/${id}/students`, { method: "POST", - body: JSON.stringify({ user_id }), + body: { user_id }, }); }