module organization
Nine files under src/. One public barrel.
Tree#
flowchart TB src[src/] src --> index.js src --> wrapper.js src --> attendance.js src --> registration.js src --> exam.js src --> exceptions.js src --> encryption.js src --> utils.js src --> feedback.js
Imports#
flowchart LR index.js --> wrapper.js index.js --> attendance.js index.js --> registration.js index.js --> exam.js index.js --> exceptions.js index.js --> encryption.js
flowchart LR wrapper.js --> exceptions.js wrapper.js --> registration.js wrapper.js --> attendance.js wrapper.js --> exam.js wrapper.js --> encryption.js
encryption.js imports generate_date_seq and get_random_char_seq from utils.js.
feedback.js has no importers.
Responsibility#
| File | Owns |
|---|---|
index.js |
re-exports |
wrapper.js |
API, DEFCAPTCHA, WebPortal, WebPortalSession, __hit, every portal method |
attendance.js |
AttendanceHeader, Semester, AttendanceMeta |
registration.js |
RegisteredSubject, Registrations |
exam.js |
ExamEvent |
exceptions.js |
six error classes |
encryption.js |
AES helpers, generate_local_name, serialize |
utils.js |
date seq, random charset |
feedback.js |
frozen rating strings |
Public vs internal#
flowchart TB pub[Named exports from index.js] pub --> WP[WebPortal WebPortalSession] pub --> C[API DEFCAPTCHA] pub --> M[models] pub --> E[errors] pub --> G[generate_local_name] priv[Not exported] priv --> hit[__hit] priv --> authFn[authenticated] priv --> encPriv[encrypt decrypt serialize_payload] priv --> util[utils] priv --> fb[FeedbackOptions]
You can still import internal files from src/ if you ship source. The CDN bundle only exposes what index.js exports.
Semester reuse#
flowchart TB Sem[Semester in attendance.js] Sem --> att[attendance meta] Sem --> reg[registered semesters] Sem --> exam[exam semesters] Sem --> marks[marks semesters] Sem --> grade[grade card semesters]
One class, several endpoints. Keep the instance with the endpoint family that created it.
Exceptions module#
flowchart TB exceptions.js --> APIError exceptions.js --> LoginError exceptions.js --> SessionError exceptions.js --> SessionExpired exceptions.js --> NotLoggedIn exceptions.js --> AccountAPIError
No extra types. No HTTP helper.
Adding a method#
Put the function on WebPortal, call __hit with API + ENDPOINT, add the name to authenticatedMethods if it needs a session, export nothing new unless you add a model. Rebuild with npm run build.
flowchart LR add[new WebPortal method] --> hit[__hit] add --> list[authenticatedMethods] model[new DTO] --> file[domain .js] file --> index[index.js export]