@brite-future-schools-contracts/contracts 2.0.3 → 2.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{chunk-S3BK5YEH.js → chunk-3IZCDZ2P.js} +29 -3
- package/dist/chunk-3IZCDZ2P.js.map +1 -0
- package/dist/{chunk-3OMU2YSE.js → chunk-7Q4RWA5S.js} +73 -2
- package/dist/chunk-7Q4RWA5S.js.map +1 -0
- package/dist/chunk-PDCM3NIB.js +1 -0
- package/dist/contracts/index.cjs +88 -0
- package/dist/contracts/index.cjs.map +1 -1
- package/dist/contracts/index.d.cts +132 -1
- package/dist/contracts/index.d.ts +132 -1
- package/dist/contracts/index.js +12 -2
- package/dist/index.cjs +351 -21
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +134 -2
- package/dist/index.d.ts +134 -2
- package/dist/index.js +219 -3
- package/dist/index.js.map +1 -1
- package/dist/schemas/index.cjs +80 -0
- package/dist/schemas/index.cjs.map +1 -1
- package/dist/schemas/index.d.cts +105 -1
- package/dist/schemas/index.d.ts +105 -1
- package/dist/schemas/index.js +20 -2
- package/package.json +1 -1
- package/dist/chunk-3OMU2YSE.js.map +0 -1
- package/dist/chunk-R4XE3SFR.js +0 -1
- package/dist/chunk-S3BK5YEH.js.map +0 -1
- /package/dist/{chunk-R4XE3SFR.js.map → chunk-PDCM3NIB.js.map} +0 -0
package/dist/index.js
CHANGED
|
@@ -1,11 +1,14 @@
|
|
|
1
|
-
import "./chunk-
|
|
1
|
+
import "./chunk-PDCM3NIB.js";
|
|
2
2
|
import {
|
|
3
|
+
attendanceContract,
|
|
3
4
|
authContract,
|
|
4
5
|
bulkUploadStudentsContract,
|
|
5
6
|
changePasswordContract,
|
|
6
7
|
createDepartmentContract,
|
|
7
8
|
createStaffContract,
|
|
8
9
|
createStudentContract,
|
|
10
|
+
getByClassContract,
|
|
11
|
+
getByStudentContract,
|
|
9
12
|
getMeContract,
|
|
10
13
|
getStaffByIdContract,
|
|
11
14
|
getStudentByIdContract,
|
|
@@ -15,21 +18,26 @@ import {
|
|
|
15
18
|
listDepartmentsContract,
|
|
16
19
|
listStaffContract,
|
|
17
20
|
listStudentsContract,
|
|
21
|
+
listTermsContract,
|
|
18
22
|
loginContract,
|
|
19
23
|
logoutContract,
|
|
24
|
+
markAttendanceContract,
|
|
20
25
|
refreshTokenContract,
|
|
21
26
|
requestPasswordResetContract,
|
|
22
27
|
resetPasswordContract,
|
|
23
28
|
studentsContract,
|
|
24
29
|
switchBranchContract,
|
|
25
30
|
updateStaffStatusContract
|
|
26
|
-
} from "./chunk-
|
|
31
|
+
} from "./chunk-3IZCDZ2P.js";
|
|
27
32
|
import {
|
|
33
|
+
AttendanceRecordInputSchema,
|
|
34
|
+
AttendanceStatusSchema,
|
|
28
35
|
BranchRefSchema,
|
|
29
36
|
BulkUploadStudentRowSchema,
|
|
30
37
|
BulkUploadStudentsInputSchema,
|
|
31
38
|
BulkUploadStudentsOutputSchema,
|
|
32
39
|
ChangePasswordInputSchema,
|
|
40
|
+
ClassAttendanceRowSchema,
|
|
33
41
|
ClassSummarySchema,
|
|
34
42
|
CreateDepartmentInputSchema,
|
|
35
43
|
CreateStaffInputSchema,
|
|
@@ -40,6 +48,8 @@ import {
|
|
|
40
48
|
DepartmentSchema,
|
|
41
49
|
EmploymentTypeSchema,
|
|
42
50
|
GenderSchema,
|
|
51
|
+
GetByClassInputSchema,
|
|
52
|
+
GetByStudentInputSchema,
|
|
43
53
|
GradeLevelSchema,
|
|
44
54
|
LinkGuardianInputSchema,
|
|
45
55
|
ListStaffInputSchema,
|
|
@@ -47,6 +57,8 @@ import {
|
|
|
47
57
|
LoginInputSchema,
|
|
48
58
|
LoginOutputSchema,
|
|
49
59
|
LogoutInputSchema,
|
|
60
|
+
MarkAttendanceInputSchema,
|
|
61
|
+
MarkAttendanceOutputSchema,
|
|
50
62
|
PaginationInputSchema,
|
|
51
63
|
RefreshTokenInputSchema,
|
|
52
64
|
RefreshTokenOutputSchema,
|
|
@@ -59,20 +71,175 @@ import {
|
|
|
59
71
|
SoftDeleteSchema,
|
|
60
72
|
StaffListItemSchema,
|
|
61
73
|
StaffProfileSchema,
|
|
74
|
+
StudentAttendanceRowSchema,
|
|
62
75
|
StudentListItemSchema,
|
|
63
76
|
StudentProfileSchema,
|
|
64
77
|
StudentStatusSchema,
|
|
65
78
|
SwitchBranchInputSchema,
|
|
79
|
+
TermSchema,
|
|
66
80
|
TimestampsSchema,
|
|
67
81
|
UuidSchema,
|
|
68
82
|
paginatedOutputSchema
|
|
69
|
-
} from "./chunk-
|
|
83
|
+
} from "./chunk-7Q4RWA5S.js";
|
|
84
|
+
|
|
85
|
+
// src/roles/helpers.ts
|
|
86
|
+
function hasRole(user, role) {
|
|
87
|
+
return user.roles.some(
|
|
88
|
+
(r) => r.name === role && r.branchId === user.activeBranchId
|
|
89
|
+
);
|
|
90
|
+
}
|
|
91
|
+
function isProprietor(user) {
|
|
92
|
+
return hasRole(user, "PROPRIETOR");
|
|
93
|
+
}
|
|
94
|
+
function isDirector(user) {
|
|
95
|
+
return hasRole(user, "DIRECTOR");
|
|
96
|
+
}
|
|
97
|
+
function isSystemAdmin(user) {
|
|
98
|
+
return hasRole(user, "SYSTEM_ADMIN");
|
|
99
|
+
}
|
|
100
|
+
function isPrincipal(user) {
|
|
101
|
+
return hasRole(user, "PRINCIPAL");
|
|
102
|
+
}
|
|
103
|
+
function isDeputyPrincipal(user) {
|
|
104
|
+
return hasRole(user, "DEPUTY_PRINCIPAL");
|
|
105
|
+
}
|
|
106
|
+
function isSeniorLeadership(user) {
|
|
107
|
+
return isProprietor(user) || isDirector(user) || isPrincipal(user) || isDeputyPrincipal(user);
|
|
108
|
+
}
|
|
109
|
+
function isHOD(user) {
|
|
110
|
+
return hasRole(user, "HOD");
|
|
111
|
+
}
|
|
112
|
+
function isClassTeacher(user) {
|
|
113
|
+
return hasRole(user, "CLASS_TEACHER");
|
|
114
|
+
}
|
|
115
|
+
function isSubjectTeacher(user) {
|
|
116
|
+
return hasRole(user, "SUBJECT_TEACHER");
|
|
117
|
+
}
|
|
118
|
+
function isSchoolNurse(user) {
|
|
119
|
+
return hasRole(user, "SCHOOL_NURSE");
|
|
120
|
+
}
|
|
121
|
+
function isLibrarian(user) {
|
|
122
|
+
return hasRole(user, "LIBRARIAN");
|
|
123
|
+
}
|
|
124
|
+
function isLabTechnician(user) {
|
|
125
|
+
return hasRole(user, "LAB_TECHNICIAN");
|
|
126
|
+
}
|
|
127
|
+
function isSportsCoach(user) {
|
|
128
|
+
return hasRole(user, "SPORTS_COACH");
|
|
129
|
+
}
|
|
130
|
+
function isCounsellor(user) {
|
|
131
|
+
return hasRole(user, "COUNSELLOR");
|
|
132
|
+
}
|
|
133
|
+
function isCaretaker(user) {
|
|
134
|
+
return hasRole(user, "CARETAKER");
|
|
135
|
+
}
|
|
136
|
+
function isSecurity(user) {
|
|
137
|
+
return hasRole(user, "SECURITY");
|
|
138
|
+
}
|
|
139
|
+
function isBoardingMaster(user) {
|
|
140
|
+
return hasRole(user, "BOARDING_MASTER");
|
|
141
|
+
}
|
|
142
|
+
function isBursar(user) {
|
|
143
|
+
return hasRole(user, "BURSAR");
|
|
144
|
+
}
|
|
145
|
+
function isHrAdmin(user) {
|
|
146
|
+
return hasRole(user, "HR_ADMIN");
|
|
147
|
+
}
|
|
148
|
+
function isDriver(user) {
|
|
149
|
+
return hasRole(user, "DRIVER");
|
|
150
|
+
}
|
|
151
|
+
function isKitchenStaff(user) {
|
|
152
|
+
return hasRole(user, "KITCHEN_STAFF");
|
|
153
|
+
}
|
|
154
|
+
function isKitchenManager(user) {
|
|
155
|
+
return hasRole(user, "KITCHEN_MANAGER");
|
|
156
|
+
}
|
|
157
|
+
function isItAdmin(user) {
|
|
158
|
+
return hasRole(user, "IT_ADMIN");
|
|
159
|
+
}
|
|
160
|
+
function isPrefect(user) {
|
|
161
|
+
return hasRole(user, "PREFECT");
|
|
162
|
+
}
|
|
163
|
+
function isStudent(user) {
|
|
164
|
+
return hasRole(user, "STUDENT");
|
|
165
|
+
}
|
|
166
|
+
function isParent(user) {
|
|
167
|
+
return hasRole(user, "PARENT");
|
|
168
|
+
}
|
|
169
|
+
function isOrgSponsor(user) {
|
|
170
|
+
return hasRole(user, "ORG_SPONSOR");
|
|
171
|
+
}
|
|
172
|
+
function isIndividualSponsor(user) {
|
|
173
|
+
return hasRole(user, "INDIVIDUAL_SPONSOR");
|
|
174
|
+
}
|
|
175
|
+
function isStaff(user) {
|
|
176
|
+
const staffRoles = [
|
|
177
|
+
"PROPRIETOR",
|
|
178
|
+
"DIRECTOR",
|
|
179
|
+
"SYSTEM_ADMIN",
|
|
180
|
+
"PRINCIPAL",
|
|
181
|
+
"DEPUTY_PRINCIPAL",
|
|
182
|
+
"HOD",
|
|
183
|
+
"CLASS_TEACHER",
|
|
184
|
+
"SUBJECT_TEACHER",
|
|
185
|
+
"BURSAR",
|
|
186
|
+
"HR_ADMIN",
|
|
187
|
+
"SCHOOL_NURSE",
|
|
188
|
+
"LIBRARIAN",
|
|
189
|
+
"LAB_TECHNICIAN",
|
|
190
|
+
"SPORTS_COACH",
|
|
191
|
+
"COUNSELLOR",
|
|
192
|
+
"CARETAKER",
|
|
193
|
+
"SECURITY",
|
|
194
|
+
"KITCHEN_STAFF",
|
|
195
|
+
"KITCHEN_MANAGER",
|
|
196
|
+
"DRIVER",
|
|
197
|
+
"IT_ADMIN",
|
|
198
|
+
"BOARDING_MASTER",
|
|
199
|
+
"PREFECT"
|
|
200
|
+
];
|
|
201
|
+
return user.roles.some(
|
|
202
|
+
(r) => staffRoles.includes(r.name) && r.branchId === user.activeBranchId
|
|
203
|
+
);
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
// src/permissions/index.ts
|
|
207
|
+
function canMarkClassAttendance(user) {
|
|
208
|
+
return isClassTeacher(user) || isHOD(user) || isPrincipal(user) || isDeputyPrincipal(user) || isSystemAdmin(user);
|
|
209
|
+
}
|
|
210
|
+
function canViewClassAttendance(user) {
|
|
211
|
+
return canMarkClassAttendance(user) || isDirector(user) || isProprietor(user);
|
|
212
|
+
}
|
|
213
|
+
function canMarkStaffAttendance(user) {
|
|
214
|
+
return isHrAdmin(user) || isPrincipal(user) || isDeputyPrincipal(user) || isSystemAdmin(user);
|
|
215
|
+
}
|
|
216
|
+
function canViewStaffAttendance(user) {
|
|
217
|
+
return canMarkStaffAttendance(user) || isDirector(user) || isProprietor(user);
|
|
218
|
+
}
|
|
219
|
+
function canViewStaffList(user) {
|
|
220
|
+
return isHrAdmin(user) || isPrincipal(user) || isDeputyPrincipal(user) || isSystemAdmin(user) || isDirector(user) || isProprietor(user);
|
|
221
|
+
}
|
|
222
|
+
function canManageStaff(user) {
|
|
223
|
+
return isHrAdmin(user) || isPrincipal(user) || isSystemAdmin(user) || isDirector(user) || isProprietor(user);
|
|
224
|
+
}
|
|
225
|
+
function canViewStudentList(user) {
|
|
226
|
+
return isClassTeacher(user) || isHOD(user) || isPrincipal(user) || isDeputyPrincipal(user) || isHrAdmin(user) || isSystemAdmin(user) || isDirector(user) || isProprietor(user);
|
|
227
|
+
}
|
|
228
|
+
function canManageStudents(user) {
|
|
229
|
+
return isPrincipal(user) || isDeputyPrincipal(user) || isHrAdmin(user) || isSystemAdmin(user) || isDirector(user) || isProprietor(user);
|
|
230
|
+
}
|
|
231
|
+
function canAccessAdminDashboard(user) {
|
|
232
|
+
return !isStudent(user) && !isParent(user) && !isPrefect(user) && !isOrgSponsor(user) && !isIndividualSponsor(user);
|
|
233
|
+
}
|
|
70
234
|
export {
|
|
235
|
+
AttendanceRecordInputSchema,
|
|
236
|
+
AttendanceStatusSchema,
|
|
71
237
|
BranchRefSchema,
|
|
72
238
|
BulkUploadStudentRowSchema,
|
|
73
239
|
BulkUploadStudentsInputSchema,
|
|
74
240
|
BulkUploadStudentsOutputSchema,
|
|
75
241
|
ChangePasswordInputSchema,
|
|
242
|
+
ClassAttendanceRowSchema,
|
|
76
243
|
ClassSummarySchema,
|
|
77
244
|
CreateDepartmentInputSchema,
|
|
78
245
|
CreateStaffInputSchema,
|
|
@@ -83,6 +250,8 @@ export {
|
|
|
83
250
|
DepartmentSchema,
|
|
84
251
|
EmploymentTypeSchema,
|
|
85
252
|
GenderSchema,
|
|
253
|
+
GetByClassInputSchema,
|
|
254
|
+
GetByStudentInputSchema,
|
|
86
255
|
GradeLevelSchema,
|
|
87
256
|
LinkGuardianInputSchema,
|
|
88
257
|
ListStaffInputSchema,
|
|
@@ -90,6 +259,8 @@ export {
|
|
|
90
259
|
LoginInputSchema,
|
|
91
260
|
LoginOutputSchema,
|
|
92
261
|
LogoutInputSchema,
|
|
262
|
+
MarkAttendanceInputSchema,
|
|
263
|
+
MarkAttendanceOutputSchema,
|
|
93
264
|
PaginationInputSchema,
|
|
94
265
|
RefreshTokenInputSchema,
|
|
95
266
|
RefreshTokenOutputSchema,
|
|
@@ -102,29 +273,74 @@ export {
|
|
|
102
273
|
SoftDeleteSchema,
|
|
103
274
|
StaffListItemSchema,
|
|
104
275
|
StaffProfileSchema,
|
|
276
|
+
StudentAttendanceRowSchema,
|
|
105
277
|
StudentListItemSchema,
|
|
106
278
|
StudentProfileSchema,
|
|
107
279
|
StudentStatusSchema,
|
|
108
280
|
SwitchBranchInputSchema,
|
|
281
|
+
TermSchema,
|
|
109
282
|
TimestampsSchema,
|
|
110
283
|
UuidSchema,
|
|
284
|
+
attendanceContract,
|
|
111
285
|
authContract,
|
|
112
286
|
bulkUploadStudentsContract,
|
|
287
|
+
canAccessAdminDashboard,
|
|
288
|
+
canManageStaff,
|
|
289
|
+
canManageStudents,
|
|
290
|
+
canMarkClassAttendance,
|
|
291
|
+
canMarkStaffAttendance,
|
|
292
|
+
canViewClassAttendance,
|
|
293
|
+
canViewStaffAttendance,
|
|
294
|
+
canViewStaffList,
|
|
295
|
+
canViewStudentList,
|
|
113
296
|
changePasswordContract,
|
|
114
297
|
createDepartmentContract,
|
|
115
298
|
createStaffContract,
|
|
116
299
|
createStudentContract,
|
|
300
|
+
getByClassContract,
|
|
301
|
+
getByStudentContract,
|
|
117
302
|
getMeContract,
|
|
118
303
|
getStaffByIdContract,
|
|
119
304
|
getStudentByIdContract,
|
|
120
305
|
hrContract,
|
|
306
|
+
isBoardingMaster,
|
|
307
|
+
isBursar,
|
|
308
|
+
isCaretaker,
|
|
309
|
+
isClassTeacher,
|
|
310
|
+
isCounsellor,
|
|
311
|
+
isDeputyPrincipal,
|
|
312
|
+
isDirector,
|
|
313
|
+
isDriver,
|
|
314
|
+
isHOD,
|
|
315
|
+
isHrAdmin,
|
|
316
|
+
isIndividualSponsor,
|
|
317
|
+
isItAdmin,
|
|
318
|
+
isKitchenManager,
|
|
319
|
+
isKitchenStaff,
|
|
320
|
+
isLabTechnician,
|
|
321
|
+
isLibrarian,
|
|
322
|
+
isOrgSponsor,
|
|
323
|
+
isParent,
|
|
324
|
+
isPrefect,
|
|
325
|
+
isPrincipal,
|
|
326
|
+
isProprietor,
|
|
327
|
+
isSchoolNurse,
|
|
328
|
+
isSecurity,
|
|
329
|
+
isSeniorLeadership,
|
|
330
|
+
isSportsCoach,
|
|
331
|
+
isStaff,
|
|
332
|
+
isStudent,
|
|
333
|
+
isSubjectTeacher,
|
|
334
|
+
isSystemAdmin,
|
|
121
335
|
linkGuardianContract,
|
|
122
336
|
listClassesContract,
|
|
123
337
|
listDepartmentsContract,
|
|
124
338
|
listStaffContract,
|
|
125
339
|
listStudentsContract,
|
|
340
|
+
listTermsContract,
|
|
126
341
|
loginContract,
|
|
127
342
|
logoutContract,
|
|
343
|
+
markAttendanceContract,
|
|
128
344
|
paginatedOutputSchema,
|
|
129
345
|
refreshTokenContract,
|
|
130
346
|
requestPasswordResetContract,
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
|
1
|
+
{"version":3,"sources":["../src/roles/helpers.ts","../src/permissions/index.ts"],"sourcesContent":["/**\n * Brite Future Schools — bfs-contracts\n * Role helper functions.\n *\n * Every helper takes a SessionUser and returns a boolean.\n * Use these instead of hardcoded role string comparisons everywhere.\n *\n * Usage:\n * import { isProprietor, isPrincipal } from '@brite-future-schools-contracts/contracts'\n * if (isProprietor(user)) { ... }\n *\n * Phase History:\n * Phase 0.1 (2026-06-05): Initial creation\n * Phase 0.2 (2026-06-06): Roles reconciled against schema — added\n * SCHOOL_NURSE, LAB_TECHNICIAN, SPORTS_COACH,\n * CARETAKER, SECURITY, KITCHEN_STAFF, IT_ADMIN,\n * ORG_SPONSOR, INDIVIDUAL_SPONSOR, KITCHEN_MANAGER,\n * BOARDING_MASTER, PREFECT\n *\n * @module src/roles/helpers\n * @since Phase 0.1\n */\n\nimport type { RoleName, SessionUser } from './types.js'\n\n// ── Private helper ─────────────────────────────────────────────────────────────\n\nfunction hasRole(user: SessionUser, role: RoleName): boolean {\n return user.roles.some(\n (r) => r.name === role && r.branchId === user.activeBranchId,\n )\n}\n\n// ── Senior leadership ──────────────────────────────────────────────────────────\n\nexport function isProprietor(user: SessionUser): boolean {\n return hasRole(user, 'PROPRIETOR')\n}\n\nexport function isDirector(user: SessionUser): boolean {\n return hasRole(user, 'DIRECTOR')\n}\n\nexport function isSystemAdmin(user: SessionUser): boolean {\n return hasRole(user, 'SYSTEM_ADMIN')\n}\n\nexport function isPrincipal(user: SessionUser): boolean {\n return hasRole(user, 'PRINCIPAL')\n}\n\nexport function isDeputyPrincipal(user: SessionUser): boolean {\n return hasRole(user, 'DEPUTY_PRINCIPAL')\n}\n\nexport function isSeniorLeadership(user: SessionUser): boolean {\n return (\n isProprietor(user) ||\n isDirector(user) ||\n isPrincipal(user) ||\n isDeputyPrincipal(user)\n )\n}\n\n// ── Academic staff ─────────────────────────────────────────────────────────────\n\nexport function isHOD(user: SessionUser): boolean {\n return hasRole(user, 'HOD')\n}\n\nexport function isClassTeacher(user: SessionUser): boolean {\n return hasRole(user, 'CLASS_TEACHER')\n}\n\nexport function isSubjectTeacher(user: SessionUser): boolean {\n return hasRole(user, 'SUBJECT_TEACHER')\n}\n\n// ── Support staff ──────────────────────────────────────────────────────────────\n\nexport function isSchoolNurse(user: SessionUser): boolean {\n return hasRole(user, 'SCHOOL_NURSE')\n}\n\nexport function isLibrarian(user: SessionUser): boolean {\n return hasRole(user, 'LIBRARIAN')\n}\n\nexport function isLabTechnician(user: SessionUser): boolean {\n return hasRole(user, 'LAB_TECHNICIAN')\n}\n\nexport function isSportsCoach(user: SessionUser): boolean {\n return hasRole(user, 'SPORTS_COACH')\n}\n\nexport function isCounsellor(user: SessionUser): boolean {\n return hasRole(user, 'COUNSELLOR')\n}\n\nexport function isCaretaker(user: SessionUser): boolean {\n return hasRole(user, 'CARETAKER')\n}\n\nexport function isSecurity(user: SessionUser): boolean {\n return hasRole(user, 'SECURITY')\n}\n\nexport function isBoardingMaster(user: SessionUser): boolean {\n return hasRole(user, 'BOARDING_MASTER')\n}\n\n// ── Operations ─────────────────────────────────────────────────────────────────\n\nexport function isBursar(user: SessionUser): boolean {\n return hasRole(user, 'BURSAR')\n}\n\nexport function isHrAdmin(user: SessionUser): boolean {\n return hasRole(user, 'HR_ADMIN')\n}\n\nexport function isDriver(user: SessionUser): boolean {\n return hasRole(user, 'DRIVER')\n}\n\nexport function isKitchenStaff(user: SessionUser): boolean {\n return hasRole(user, 'KITCHEN_STAFF')\n}\n\nexport function isKitchenManager(user: SessionUser): boolean {\n return hasRole(user, 'KITCHEN_MANAGER')\n}\n\nexport function isItAdmin(user: SessionUser): boolean {\n return hasRole(user, 'IT_ADMIN')\n}\n\n// ── Students and parents ───────────────────────────────────────────────────────\n\nexport function isPrefect(user: SessionUser): boolean {\n return hasRole(user, 'PREFECT')\n}\n\nexport function isStudent(user: SessionUser): boolean {\n return hasRole(user, 'STUDENT')\n}\n\nexport function isParent(user: SessionUser): boolean {\n return hasRole(user, 'PARENT')\n}\n\n// ── Sponsors ───────────────────────────────────────────────────────────────────\n\nexport function isOrgSponsor(user: SessionUser): boolean {\n return hasRole(user, 'ORG_SPONSOR')\n}\n\nexport function isIndividualSponsor(user: SessionUser): boolean {\n return hasRole(user, 'INDIVIDUAL_SPONSOR')\n}\n\n// ── Broad groupings ────────────────────────────────────────────────────────────\n\nexport function isStaff(user: SessionUser): boolean {\n const staffRoles: RoleName[] = [\n 'PROPRIETOR',\n 'DIRECTOR',\n 'SYSTEM_ADMIN',\n 'PRINCIPAL',\n 'DEPUTY_PRINCIPAL',\n 'HOD',\n 'CLASS_TEACHER',\n 'SUBJECT_TEACHER',\n 'BURSAR',\n 'HR_ADMIN',\n 'SCHOOL_NURSE',\n 'LIBRARIAN',\n 'LAB_TECHNICIAN',\n 'SPORTS_COACH',\n 'COUNSELLOR',\n 'CARETAKER',\n 'SECURITY',\n 'KITCHEN_STAFF',\n 'KITCHEN_MANAGER',\n 'DRIVER',\n 'IT_ADMIN',\n 'BOARDING_MASTER',\n 'PREFECT',\n ]\n return user.roles.some(\n (r) =>\n staffRoles.includes(r.name) && r.branchId === user.activeBranchId,\n )\n}","/**\n * Brite Future Schools — bfs-contracts\n * Permission helper functions.\n *\n * Answer \"can this user do X?\" — not \"is this user role Y?\".\n * Every UI gate and API guard must use these instead of raw role checks.\n *\n * Phase History:\n * Phase 2 (2026-06-08): Initial creation — attendance, staff, students,\n * dashboard permissions\n *\n * @module src/permissions/index\n * @since Phase 2\n */\n\nimport type { SessionUser } from '../roles/types.js'\nimport {\n isProprietor,\n isDirector,\n isSystemAdmin,\n isPrincipal,\n isDeputyPrincipal,\n isHOD,\n isClassTeacher,\n isHrAdmin,\n isStudent,\n isParent,\n isOrgSponsor,\n isIndividualSponsor,\n isPrefect,\n} from '../roles/helpers.js'\n\n// ── Attendance ─────────────────────────────────────────────────────────────────\n\n/** Class teacher marks roll for their own class; senior staff can mark any. */\nexport function canMarkClassAttendance(user: SessionUser): boolean {\n return (\n isClassTeacher(user) ||\n isHOD(user) ||\n isPrincipal(user) ||\n isDeputyPrincipal(user) ||\n isSystemAdmin(user)\n )\n}\n\n/** Who can read class attendance records. */\nexport function canViewClassAttendance(user: SessionUser): boolean {\n return (\n canMarkClassAttendance(user) ||\n isDirector(user) ||\n isProprietor(user)\n )\n}\n\n/** Who can record staff attendance. */\nexport function canMarkStaffAttendance(user: SessionUser): boolean {\n return (\n isHrAdmin(user) ||\n isPrincipal(user) ||\n isDeputyPrincipal(user) ||\n isSystemAdmin(user)\n )\n}\n\n/** Who can view staff attendance records. */\nexport function canViewStaffAttendance(user: SessionUser): boolean {\n return (\n canMarkStaffAttendance(user) ||\n isDirector(user) ||\n isProprietor(user)\n )\n}\n\n// ── Staff ──────────────────────────────────────────────────────────────────────\n\n/** Who can view the staff list. */\nexport function canViewStaffList(user: SessionUser): boolean {\n return (\n isHrAdmin(user) ||\n isPrincipal(user) ||\n isDeputyPrincipal(user) ||\n isSystemAdmin(user) ||\n isDirector(user) ||\n isProprietor(user)\n )\n}\n\n/** Who can create or edit staff records. */\nexport function canManageStaff(user: SessionUser): boolean {\n return (\n isHrAdmin(user) ||\n isPrincipal(user) ||\n isSystemAdmin(user) ||\n isDirector(user) ||\n isProprietor(user)\n )\n}\n\n// ── Students ───────────────────────────────────────────────────────────────────\n\n/** Who can view the student list. */\nexport function canViewStudentList(user: SessionUser): boolean {\n return (\n isClassTeacher(user) ||\n isHOD(user) ||\n isPrincipal(user) ||\n isDeputyPrincipal(user) ||\n isHrAdmin(user) ||\n isSystemAdmin(user) ||\n isDirector(user) ||\n isProprietor(user)\n )\n}\n\n/** Who can enrol or edit student records. */\nexport function canManageStudents(user: SessionUser): boolean {\n return (\n isPrincipal(user) ||\n isDeputyPrincipal(user) ||\n isHrAdmin(user) ||\n isSystemAdmin(user) ||\n isDirector(user) ||\n isProprietor(user)\n )\n}\n\n// ── Dashboard ──────────────────────────────────────────────────────────────────\n\n/** Anyone with a staff-level or above role can access the admin dashboard. */\nexport function canAccessAdminDashboard(user: SessionUser): boolean {\n return (\n !isStudent(user) &&\n !isParent(user) &&\n !isPrefect(user) &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d,CAAC,UAAU,IAAI,KACf,CAAC,aAAa,IAAI,KAClB,CAAC,oBAAoB,IAAI;AAEjC;","names":[]}
|
package/dist/schemas/index.cjs
CHANGED
|
@@ -30,11 +30,14 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
30
30
|
// src/schemas/index.ts
|
|
31
31
|
var schemas_exports = {};
|
|
32
32
|
__export(schemas_exports, {
|
|
33
|
+
AttendanceRecordInputSchema: () => AttendanceRecordInputSchema,
|
|
34
|
+
AttendanceStatusSchema: () => AttendanceStatusSchema,
|
|
33
35
|
BranchRefSchema: () => BranchRefSchema,
|
|
34
36
|
BulkUploadStudentRowSchema: () => BulkUploadStudentRowSchema,
|
|
35
37
|
BulkUploadStudentsInputSchema: () => BulkUploadStudentsInputSchema,
|
|
36
38
|
BulkUploadStudentsOutputSchema: () => BulkUploadStudentsOutputSchema,
|
|
37
39
|
ChangePasswordInputSchema: () => ChangePasswordInputSchema,
|
|
40
|
+
ClassAttendanceRowSchema: () => ClassAttendanceRowSchema,
|
|
38
41
|
ClassSummarySchema: () => ClassSummarySchema,
|
|
39
42
|
CreateDepartmentInputSchema: () => CreateDepartmentInputSchema,
|
|
40
43
|
CreateStaffInputSchema: () => CreateStaffInputSchema,
|
|
@@ -45,6 +48,8 @@ __export(schemas_exports, {
|
|
|
45
48
|
DepartmentSchema: () => DepartmentSchema,
|
|
46
49
|
EmploymentTypeSchema: () => EmploymentTypeSchema,
|
|
47
50
|
GenderSchema: () => GenderSchema,
|
|
51
|
+
GetByClassInputSchema: () => GetByClassInputSchema,
|
|
52
|
+
GetByStudentInputSchema: () => GetByStudentInputSchema,
|
|
48
53
|
GradeLevelSchema: () => GradeLevelSchema,
|
|
49
54
|
LinkGuardianInputSchema: () => LinkGuardianInputSchema,
|
|
50
55
|
ListStaffInputSchema: () => ListStaffInputSchema,
|
|
@@ -52,6 +57,8 @@ __export(schemas_exports, {
|
|
|
52
57
|
LoginInputSchema: () => LoginInputSchema,
|
|
53
58
|
LoginOutputSchema: () => LoginOutputSchema,
|
|
54
59
|
LogoutInputSchema: () => LogoutInputSchema,
|
|
60
|
+
MarkAttendanceInputSchema: () => MarkAttendanceInputSchema,
|
|
61
|
+
MarkAttendanceOutputSchema: () => MarkAttendanceOutputSchema,
|
|
55
62
|
PaginationInputSchema: () => PaginationInputSchema,
|
|
56
63
|
RefreshTokenInputSchema: () => RefreshTokenInputSchema,
|
|
57
64
|
RefreshTokenOutputSchema: () => RefreshTokenOutputSchema,
|
|
@@ -64,10 +71,12 @@ __export(schemas_exports, {
|
|
|
64
71
|
SoftDeleteSchema: () => SoftDeleteSchema,
|
|
65
72
|
StaffListItemSchema: () => StaffListItemSchema,
|
|
66
73
|
StaffProfileSchema: () => StaffProfileSchema,
|
|
74
|
+
StudentAttendanceRowSchema: () => StudentAttendanceRowSchema,
|
|
67
75
|
StudentListItemSchema: () => StudentListItemSchema,
|
|
68
76
|
StudentProfileSchema: () => StudentProfileSchema,
|
|
69
77
|
StudentStatusSchema: () => StudentStatusSchema,
|
|
70
78
|
SwitchBranchInputSchema: () => SwitchBranchInputSchema,
|
|
79
|
+
TermSchema: () => TermSchema,
|
|
71
80
|
TimestampsSchema: () => TimestampsSchema,
|
|
72
81
|
UuidSchema: () => UuidSchema,
|
|
73
82
|
paginatedOutputSchema: () => paginatedOutputSchema
|
|
@@ -507,13 +516,78 @@ var ClassSummarySchema = z4.object({
|
|
|
507
516
|
enrolledCount: z4.number(),
|
|
508
517
|
classTeacherId: UuidSchema.nullable()
|
|
509
518
|
});
|
|
519
|
+
|
|
520
|
+
// src/schemas/attendance.ts
|
|
521
|
+
var z5 = __toESM(require("zod"), 1);
|
|
522
|
+
var AttendanceStatusSchema = z5.enum([
|
|
523
|
+
"present",
|
|
524
|
+
"absent",
|
|
525
|
+
"late",
|
|
526
|
+
"excused"
|
|
527
|
+
]);
|
|
528
|
+
var TermSchema = z5.object({
|
|
529
|
+
id: UuidSchema,
|
|
530
|
+
branchId: UuidSchema,
|
|
531
|
+
academicYearId: UuidSchema,
|
|
532
|
+
name: z5.string(),
|
|
533
|
+
startDate: z5.string(),
|
|
534
|
+
endDate: z5.string(),
|
|
535
|
+
isCurrent: z5.boolean()
|
|
536
|
+
});
|
|
537
|
+
var AttendanceRecordInputSchema = z5.object({
|
|
538
|
+
studentId: UuidSchema,
|
|
539
|
+
status: AttendanceStatusSchema,
|
|
540
|
+
notes: z5.string().max(500).optional()
|
|
541
|
+
});
|
|
542
|
+
var MarkAttendanceInputSchema = z5.object({
|
|
543
|
+
classId: UuidSchema,
|
|
544
|
+
termId: UuidSchema,
|
|
545
|
+
date: z5.iso.date(),
|
|
546
|
+
records: z5.array(AttendanceRecordInputSchema).min(1)
|
|
547
|
+
});
|
|
548
|
+
var MarkAttendanceOutputSchema = z5.object({
|
|
549
|
+
count: z5.number(),
|
|
550
|
+
date: z5.string(),
|
|
551
|
+
classId: UuidSchema
|
|
552
|
+
});
|
|
553
|
+
var GetByClassInputSchema = z5.object({
|
|
554
|
+
classId: UuidSchema,
|
|
555
|
+
date: z5.iso.date()
|
|
556
|
+
});
|
|
557
|
+
var ClassAttendanceRowSchema = z5.object({
|
|
558
|
+
id: UuidSchema,
|
|
559
|
+
studentId: UuidSchema,
|
|
560
|
+
firstName: z5.string(),
|
|
561
|
+
middleName: z5.string().nullable(),
|
|
562
|
+
lastName: z5.string(),
|
|
563
|
+
admissionNo: z5.string(),
|
|
564
|
+
status: AttendanceStatusSchema,
|
|
565
|
+
notes: z5.string().nullable(),
|
|
566
|
+
markedBy: UuidSchema,
|
|
567
|
+
updatedAt: z5.string()
|
|
568
|
+
});
|
|
569
|
+
var GetByStudentInputSchema = z5.object({
|
|
570
|
+
studentId: UuidSchema,
|
|
571
|
+
termId: UuidSchema
|
|
572
|
+
});
|
|
573
|
+
var StudentAttendanceRowSchema = z5.object({
|
|
574
|
+
id: UuidSchema,
|
|
575
|
+
date: z5.string(),
|
|
576
|
+
status: AttendanceStatusSchema,
|
|
577
|
+
notes: z5.string().nullable(),
|
|
578
|
+
classId: UuidSchema,
|
|
579
|
+
className: z5.string()
|
|
580
|
+
});
|
|
510
581
|
// Annotate the CommonJS export names for ESM import in node:
|
|
511
582
|
0 && (module.exports = {
|
|
583
|
+
AttendanceRecordInputSchema,
|
|
584
|
+
AttendanceStatusSchema,
|
|
512
585
|
BranchRefSchema,
|
|
513
586
|
BulkUploadStudentRowSchema,
|
|
514
587
|
BulkUploadStudentsInputSchema,
|
|
515
588
|
BulkUploadStudentsOutputSchema,
|
|
516
589
|
ChangePasswordInputSchema,
|
|
590
|
+
ClassAttendanceRowSchema,
|
|
517
591
|
ClassSummarySchema,
|
|
518
592
|
CreateDepartmentInputSchema,
|
|
519
593
|
CreateStaffInputSchema,
|
|
@@ -524,6 +598,8 @@ var ClassSummarySchema = z4.object({
|
|
|
524
598
|
DepartmentSchema,
|
|
525
599
|
EmploymentTypeSchema,
|
|
526
600
|
GenderSchema,
|
|
601
|
+
GetByClassInputSchema,
|
|
602
|
+
GetByStudentInputSchema,
|
|
527
603
|
GradeLevelSchema,
|
|
528
604
|
LinkGuardianInputSchema,
|
|
529
605
|
ListStaffInputSchema,
|
|
@@ -531,6 +607,8 @@ var ClassSummarySchema = z4.object({
|
|
|
531
607
|
LoginInputSchema,
|
|
532
608
|
LoginOutputSchema,
|
|
533
609
|
LogoutInputSchema,
|
|
610
|
+
MarkAttendanceInputSchema,
|
|
611
|
+
MarkAttendanceOutputSchema,
|
|
534
612
|
PaginationInputSchema,
|
|
535
613
|
RefreshTokenInputSchema,
|
|
536
614
|
RefreshTokenOutputSchema,
|
|
@@ -543,10 +621,12 @@ var ClassSummarySchema = z4.object({
|
|
|
543
621
|
SoftDeleteSchema,
|
|
544
622
|
StaffListItemSchema,
|
|
545
623
|
StaffProfileSchema,
|
|
624
|
+
StudentAttendanceRowSchema,
|
|
546
625
|
StudentListItemSchema,
|
|
547
626
|
StudentProfileSchema,
|
|
548
627
|
StudentStatusSchema,
|
|
549
628
|
SwitchBranchInputSchema,
|
|
629
|
+
TermSchema,
|
|
550
630
|
TimestampsSchema,
|
|
551
631
|
UuidSchema,
|
|
552
632
|
paginatedOutputSchema
|