Combinations
How a campus stores an A-level combination of three principal subjects and the subsidiaries a student on it may take.
Prefix every path with /api/v1. The controller is combinations, bearer auth, and a permission on subject. There is no @RequireFeature on this controller. These handlers were not called. This is the campus catalogue of A-level combinations. It is not the student’s own subject rows.
Creating one
Prerequisites: create on subject. POST /combinations (createCombination, 201) takes campusId, code, name, an optional description, principalSubjectIds, and subsidiarySubjectIds.
CombinationService.validateSubjects refuses the list before any row is written. In the table, name stands for the subject name, and ids for the missing ids separated by commas.
| Situation | Error message |
|---|---|
| Not exactly three distinct principals | "A combination has exactly 3 distinct principal subjects" |
| No subsidiaries | "A combination allows at least one subsidiary subject" |
| A repeated subsidiary | "Subsidiary subjects must be distinct" |
| The same subject in both lists | "A subject cannot be both principal and subsidiary" |
| An id that is not a subject | "Subject not found: ids" (NotFoundException) |
| A subject on another campus | "Subject name belongs to a different campus" |
A principal that is not A-level and kind principal | "Subject name is not an A-level principal subject" |
A subsidiary whose kind is not subsidiary | "Subject name is not a subsidiary subject" |
Success writes the combination, then one combination_x_subject row per subject with role principal or subsidiary, and invalidates COMBINATION_CREATE for that campus.
Changing and deleting
GET /combinations (listCombinations) requires read on subject. It cursor-paginates that campus (query.campusId) and searches code and name. GET /combinations/:id (getCombination) throws "Combination not found". The decorator’s 404 adds a full stop.
PATCH /combinations/:id (updateCombination) requires update on subject. Only code, name, and description are copied onto the row. Unknown body keys are dropped. The comment says the global pipe does not whitelist, so a rest-spread would have written them. Sending either subject list replaces the rows. The list you omit is kept. Dropping a principal, or dropping a subsidiary an enrolment might already hold, first checks active and pending enrolments. One of those throws "Combination is in use by active or pending enrolments; its principal subjects and existing subsidiaries cannot change". The delete decorator does not mention this longer sentence. Adding a subsidiary without dropping one does not take that check. Success invalidates COMBINATION_UPDATE.
DELETE /combinations/:id (deleteCombination) requires delete on subject. An active or pending enrolment throws "Combination is in use by active or pending enrolments". That is a ConflictException. The decorator’s 409 is the same words with a full stop. Success soft-deletes the subject rows and the combination, invalidates COMBINATION_REMOVE, and the controller returns { "message": "Combination deleted successfully" }.
Those principal and subsidiary rows are created on Subjects. kind is stored on the subject. This module only checks it.
Sources
Naalya-API a5dff0c208d5193c274d3d1f87787b55344d5d30: combination.controller.ts, combination.service.ts (create, update, remove, validateSubjects, assertUnreferenced). No route was called.