@brite-future-schools-contracts/contracts 2.0.2 → 2.0.4
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-3OMU2YSE.js +478 -0
- package/dist/chunk-3OMU2YSE.js.map +1 -0
- package/dist/chunk-R4XE3SFR.js +1 -0
- package/dist/chunk-S3BK5YEH.js +131 -0
- package/dist/chunk-S3BK5YEH.js.map +1 -0
- package/dist/contracts/index.cjs +415 -2
- package/dist/contracts/index.cjs.map +1 -1
- package/dist/contracts/index.d.cts +941 -1
- package/dist/contracts/index.d.ts +941 -1
- package/dist/contracts/index.js +32 -4
- package/dist/index.cjs +683 -4
- 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 +265 -5
- package/dist/index.js.map +1 -1
- package/dist/schemas/index.cjs +373 -0
- package/dist/schemas/index.cjs.map +1 -1
- package/dist/schemas/index.d.cts +564 -1
- package/dist/schemas/index.d.ts +564 -1
- package/dist/schemas/index.js +46 -2
- package/package.json +1 -1
- package/dist/chunk-AEZO7MJD.js +0 -127
- package/dist/chunk-AEZO7MJD.js.map +0 -1
- package/dist/chunk-IR6JUP6L.js +0 -48
- package/dist/chunk-IR6JUP6L.js.map +0 -1
- package/dist/chunk-PCHAGP5X.js +0 -1
- /package/dist/{chunk-PCHAGP5X.js.map → chunk-R4XE3SFR.js.map} +0 -0
package/dist/index.js
CHANGED
|
@@ -1,19 +1,49 @@
|
|
|
1
|
-
import "./chunk-
|
|
1
|
+
import "./chunk-R4XE3SFR.js";
|
|
2
2
|
import {
|
|
3
3
|
authContract,
|
|
4
|
+
bulkUploadStudentsContract,
|
|
4
5
|
changePasswordContract,
|
|
6
|
+
createDepartmentContract,
|
|
7
|
+
createStaffContract,
|
|
8
|
+
createStudentContract,
|
|
5
9
|
getMeContract,
|
|
10
|
+
getStaffByIdContract,
|
|
11
|
+
getStudentByIdContract,
|
|
12
|
+
hrContract,
|
|
13
|
+
linkGuardianContract,
|
|
14
|
+
listClassesContract,
|
|
15
|
+
listDepartmentsContract,
|
|
16
|
+
listStaffContract,
|
|
17
|
+
listStudentsContract,
|
|
6
18
|
loginContract,
|
|
7
19
|
logoutContract,
|
|
8
20
|
refreshTokenContract,
|
|
9
21
|
requestPasswordResetContract,
|
|
10
22
|
resetPasswordContract,
|
|
11
|
-
|
|
12
|
-
|
|
23
|
+
studentsContract,
|
|
24
|
+
switchBranchContract,
|
|
25
|
+
updateStaffStatusContract
|
|
26
|
+
} from "./chunk-S3BK5YEH.js";
|
|
13
27
|
import {
|
|
14
28
|
BranchRefSchema,
|
|
29
|
+
BulkUploadStudentRowSchema,
|
|
30
|
+
BulkUploadStudentsInputSchema,
|
|
31
|
+
BulkUploadStudentsOutputSchema,
|
|
15
32
|
ChangePasswordInputSchema,
|
|
33
|
+
ClassSummarySchema,
|
|
34
|
+
CreateDepartmentInputSchema,
|
|
35
|
+
CreateStaffInputSchema,
|
|
36
|
+
CreateStaffOutputSchema,
|
|
37
|
+
CreateStudentInputSchema,
|
|
38
|
+
CreateStudentOutputSchema,
|
|
16
39
|
CuidSchema,
|
|
40
|
+
DepartmentSchema,
|
|
41
|
+
EmploymentTypeSchema,
|
|
42
|
+
GenderSchema,
|
|
43
|
+
GradeLevelSchema,
|
|
44
|
+
LinkGuardianInputSchema,
|
|
45
|
+
ListStaffInputSchema,
|
|
46
|
+
ListStudentsInputSchema,
|
|
17
47
|
LoginInputSchema,
|
|
18
48
|
LoginOutputSchema,
|
|
19
49
|
LogoutInputSchema,
|
|
@@ -22,19 +52,191 @@ import {
|
|
|
22
52
|
RefreshTokenOutputSchema,
|
|
23
53
|
RequestPasswordResetInputSchema,
|
|
24
54
|
ResetPasswordInputSchema,
|
|
55
|
+
RoleNameSchema,
|
|
25
56
|
SessionUserOutputSchema,
|
|
26
57
|
SessionUserRoleSchema,
|
|
27
58
|
SessionUserSubRoleSchema,
|
|
28
59
|
SoftDeleteSchema,
|
|
60
|
+
StaffListItemSchema,
|
|
61
|
+
StaffProfileSchema,
|
|
62
|
+
StudentListItemSchema,
|
|
63
|
+
StudentProfileSchema,
|
|
64
|
+
StudentStatusSchema,
|
|
29
65
|
SwitchBranchInputSchema,
|
|
30
66
|
TimestampsSchema,
|
|
31
67
|
UuidSchema,
|
|
32
68
|
paginatedOutputSchema
|
|
33
|
-
} from "./chunk-
|
|
69
|
+
} from "./chunk-3OMU2YSE.js";
|
|
70
|
+
|
|
71
|
+
// src/roles/helpers.ts
|
|
72
|
+
function hasRole(user, role) {
|
|
73
|
+
return user.roles.some(
|
|
74
|
+
(r) => r.name === role && r.branchId === user.activeBranchId
|
|
75
|
+
);
|
|
76
|
+
}
|
|
77
|
+
function isProprietor(user) {
|
|
78
|
+
return hasRole(user, "PROPRIETOR");
|
|
79
|
+
}
|
|
80
|
+
function isDirector(user) {
|
|
81
|
+
return hasRole(user, "DIRECTOR");
|
|
82
|
+
}
|
|
83
|
+
function isSystemAdmin(user) {
|
|
84
|
+
return hasRole(user, "SYSTEM_ADMIN");
|
|
85
|
+
}
|
|
86
|
+
function isPrincipal(user) {
|
|
87
|
+
return hasRole(user, "PRINCIPAL");
|
|
88
|
+
}
|
|
89
|
+
function isDeputyPrincipal(user) {
|
|
90
|
+
return hasRole(user, "DEPUTY_PRINCIPAL");
|
|
91
|
+
}
|
|
92
|
+
function isSeniorLeadership(user) {
|
|
93
|
+
return isProprietor(user) || isDirector(user) || isPrincipal(user) || isDeputyPrincipal(user);
|
|
94
|
+
}
|
|
95
|
+
function isHOD(user) {
|
|
96
|
+
return hasRole(user, "HOD");
|
|
97
|
+
}
|
|
98
|
+
function isClassTeacher(user) {
|
|
99
|
+
return hasRole(user, "CLASS_TEACHER");
|
|
100
|
+
}
|
|
101
|
+
function isSubjectTeacher(user) {
|
|
102
|
+
return hasRole(user, "SUBJECT_TEACHER");
|
|
103
|
+
}
|
|
104
|
+
function isSchoolNurse(user) {
|
|
105
|
+
return hasRole(user, "SCHOOL_NURSE");
|
|
106
|
+
}
|
|
107
|
+
function isLibrarian(user) {
|
|
108
|
+
return hasRole(user, "LIBRARIAN");
|
|
109
|
+
}
|
|
110
|
+
function isLabTechnician(user) {
|
|
111
|
+
return hasRole(user, "LAB_TECHNICIAN");
|
|
112
|
+
}
|
|
113
|
+
function isSportsCoach(user) {
|
|
114
|
+
return hasRole(user, "SPORTS_COACH");
|
|
115
|
+
}
|
|
116
|
+
function isCounsellor(user) {
|
|
117
|
+
return hasRole(user, "COUNSELLOR");
|
|
118
|
+
}
|
|
119
|
+
function isCaretaker(user) {
|
|
120
|
+
return hasRole(user, "CARETAKER");
|
|
121
|
+
}
|
|
122
|
+
function isSecurity(user) {
|
|
123
|
+
return hasRole(user, "SECURITY");
|
|
124
|
+
}
|
|
125
|
+
function isBoardingMaster(user) {
|
|
126
|
+
return hasRole(user, "BOARDING_MASTER");
|
|
127
|
+
}
|
|
128
|
+
function isBursar(user) {
|
|
129
|
+
return hasRole(user, "BURSAR");
|
|
130
|
+
}
|
|
131
|
+
function isHrAdmin(user) {
|
|
132
|
+
return hasRole(user, "HR_ADMIN");
|
|
133
|
+
}
|
|
134
|
+
function isDriver(user) {
|
|
135
|
+
return hasRole(user, "DRIVER");
|
|
136
|
+
}
|
|
137
|
+
function isKitchenStaff(user) {
|
|
138
|
+
return hasRole(user, "KITCHEN_STAFF");
|
|
139
|
+
}
|
|
140
|
+
function isKitchenManager(user) {
|
|
141
|
+
return hasRole(user, "KITCHEN_MANAGER");
|
|
142
|
+
}
|
|
143
|
+
function isItAdmin(user) {
|
|
144
|
+
return hasRole(user, "IT_ADMIN");
|
|
145
|
+
}
|
|
146
|
+
function isPrefect(user) {
|
|
147
|
+
return hasRole(user, "PREFECT");
|
|
148
|
+
}
|
|
149
|
+
function isStudent(user) {
|
|
150
|
+
return hasRole(user, "STUDENT");
|
|
151
|
+
}
|
|
152
|
+
function isParent(user) {
|
|
153
|
+
return hasRole(user, "PARENT");
|
|
154
|
+
}
|
|
155
|
+
function isOrgSponsor(user) {
|
|
156
|
+
return hasRole(user, "ORG_SPONSOR");
|
|
157
|
+
}
|
|
158
|
+
function isIndividualSponsor(user) {
|
|
159
|
+
return hasRole(user, "INDIVIDUAL_SPONSOR");
|
|
160
|
+
}
|
|
161
|
+
function isStaff(user) {
|
|
162
|
+
const staffRoles = [
|
|
163
|
+
"PROPRIETOR",
|
|
164
|
+
"DIRECTOR",
|
|
165
|
+
"SYSTEM_ADMIN",
|
|
166
|
+
"PRINCIPAL",
|
|
167
|
+
"DEPUTY_PRINCIPAL",
|
|
168
|
+
"HOD",
|
|
169
|
+
"CLASS_TEACHER",
|
|
170
|
+
"SUBJECT_TEACHER",
|
|
171
|
+
"BURSAR",
|
|
172
|
+
"HR_ADMIN",
|
|
173
|
+
"SCHOOL_NURSE",
|
|
174
|
+
"LIBRARIAN",
|
|
175
|
+
"LAB_TECHNICIAN",
|
|
176
|
+
"SPORTS_COACH",
|
|
177
|
+
"COUNSELLOR",
|
|
178
|
+
"CARETAKER",
|
|
179
|
+
"SECURITY",
|
|
180
|
+
"KITCHEN_STAFF",
|
|
181
|
+
"KITCHEN_MANAGER",
|
|
182
|
+
"DRIVER",
|
|
183
|
+
"IT_ADMIN",
|
|
184
|
+
"BOARDING_MASTER",
|
|
185
|
+
"PREFECT"
|
|
186
|
+
];
|
|
187
|
+
return user.roles.some(
|
|
188
|
+
(r) => staffRoles.includes(r.name) && r.branchId === user.activeBranchId
|
|
189
|
+
);
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
// src/permissions/index.ts
|
|
193
|
+
function canMarkClassAttendance(user) {
|
|
194
|
+
return isClassTeacher(user) || isHOD(user) || isPrincipal(user) || isDeputyPrincipal(user) || isSystemAdmin(user);
|
|
195
|
+
}
|
|
196
|
+
function canViewClassAttendance(user) {
|
|
197
|
+
return canMarkClassAttendance(user) || isDirector(user) || isProprietor(user);
|
|
198
|
+
}
|
|
199
|
+
function canMarkStaffAttendance(user) {
|
|
200
|
+
return isHrAdmin(user) || isPrincipal(user) || isDeputyPrincipal(user) || isSystemAdmin(user);
|
|
201
|
+
}
|
|
202
|
+
function canViewStaffAttendance(user) {
|
|
203
|
+
return canMarkStaffAttendance(user) || isDirector(user) || isProprietor(user);
|
|
204
|
+
}
|
|
205
|
+
function canViewStaffList(user) {
|
|
206
|
+
return isHrAdmin(user) || isPrincipal(user) || isDeputyPrincipal(user) || isSystemAdmin(user) || isDirector(user) || isProprietor(user);
|
|
207
|
+
}
|
|
208
|
+
function canManageStaff(user) {
|
|
209
|
+
return isHrAdmin(user) || isPrincipal(user) || isSystemAdmin(user) || isDirector(user) || isProprietor(user);
|
|
210
|
+
}
|
|
211
|
+
function canViewStudentList(user) {
|
|
212
|
+
return isClassTeacher(user) || isHOD(user) || isPrincipal(user) || isDeputyPrincipal(user) || isHrAdmin(user) || isSystemAdmin(user) || isDirector(user) || isProprietor(user);
|
|
213
|
+
}
|
|
214
|
+
function canManageStudents(user) {
|
|
215
|
+
return isPrincipal(user) || isDeputyPrincipal(user) || isHrAdmin(user) || isSystemAdmin(user) || isDirector(user) || isProprietor(user);
|
|
216
|
+
}
|
|
217
|
+
function canAccessAdminDashboard(user) {
|
|
218
|
+
return !isStudent(user) && !isParent(user) && !isPrefect(user) && !isOrgSponsor(user) && !isIndividualSponsor(user);
|
|
219
|
+
}
|
|
34
220
|
export {
|
|
35
221
|
BranchRefSchema,
|
|
222
|
+
BulkUploadStudentRowSchema,
|
|
223
|
+
BulkUploadStudentsInputSchema,
|
|
224
|
+
BulkUploadStudentsOutputSchema,
|
|
36
225
|
ChangePasswordInputSchema,
|
|
226
|
+
ClassSummarySchema,
|
|
227
|
+
CreateDepartmentInputSchema,
|
|
228
|
+
CreateStaffInputSchema,
|
|
229
|
+
CreateStaffOutputSchema,
|
|
230
|
+
CreateStudentInputSchema,
|
|
231
|
+
CreateStudentOutputSchema,
|
|
37
232
|
CuidSchema,
|
|
233
|
+
DepartmentSchema,
|
|
234
|
+
EmploymentTypeSchema,
|
|
235
|
+
GenderSchema,
|
|
236
|
+
GradeLevelSchema,
|
|
237
|
+
LinkGuardianInputSchema,
|
|
238
|
+
ListStaffInputSchema,
|
|
239
|
+
ListStudentsInputSchema,
|
|
38
240
|
LoginInputSchema,
|
|
39
241
|
LoginOutputSchema,
|
|
40
242
|
LogoutInputSchema,
|
|
@@ -43,22 +245,80 @@ export {
|
|
|
43
245
|
RefreshTokenOutputSchema,
|
|
44
246
|
RequestPasswordResetInputSchema,
|
|
45
247
|
ResetPasswordInputSchema,
|
|
248
|
+
RoleNameSchema,
|
|
46
249
|
SessionUserOutputSchema,
|
|
47
250
|
SessionUserRoleSchema,
|
|
48
251
|
SessionUserSubRoleSchema,
|
|
49
252
|
SoftDeleteSchema,
|
|
253
|
+
StaffListItemSchema,
|
|
254
|
+
StaffProfileSchema,
|
|
255
|
+
StudentListItemSchema,
|
|
256
|
+
StudentProfileSchema,
|
|
257
|
+
StudentStatusSchema,
|
|
50
258
|
SwitchBranchInputSchema,
|
|
51
259
|
TimestampsSchema,
|
|
52
260
|
UuidSchema,
|
|
53
261
|
authContract,
|
|
262
|
+
bulkUploadStudentsContract,
|
|
263
|
+
canAccessAdminDashboard,
|
|
264
|
+
canManageStaff,
|
|
265
|
+
canManageStudents,
|
|
266
|
+
canMarkClassAttendance,
|
|
267
|
+
canMarkStaffAttendance,
|
|
268
|
+
canViewClassAttendance,
|
|
269
|
+
canViewStaffAttendance,
|
|
270
|
+
canViewStaffList,
|
|
271
|
+
canViewStudentList,
|
|
54
272
|
changePasswordContract,
|
|
273
|
+
createDepartmentContract,
|
|
274
|
+
createStaffContract,
|
|
275
|
+
createStudentContract,
|
|
55
276
|
getMeContract,
|
|
277
|
+
getStaffByIdContract,
|
|
278
|
+
getStudentByIdContract,
|
|
279
|
+
hrContract,
|
|
280
|
+
isBoardingMaster,
|
|
281
|
+
isBursar,
|
|
282
|
+
isCaretaker,
|
|
283
|
+
isClassTeacher,
|
|
284
|
+
isCounsellor,
|
|
285
|
+
isDeputyPrincipal,
|
|
286
|
+
isDirector,
|
|
287
|
+
isDriver,
|
|
288
|
+
isHOD,
|
|
289
|
+
isHrAdmin,
|
|
290
|
+
isIndividualSponsor,
|
|
291
|
+
isItAdmin,
|
|
292
|
+
isKitchenManager,
|
|
293
|
+
isKitchenStaff,
|
|
294
|
+
isLabTechnician,
|
|
295
|
+
isLibrarian,
|
|
296
|
+
isOrgSponsor,
|
|
297
|
+
isParent,
|
|
298
|
+
isPrefect,
|
|
299
|
+
isPrincipal,
|
|
300
|
+
isProprietor,
|
|
301
|
+
isSchoolNurse,
|
|
302
|
+
isSecurity,
|
|
303
|
+
isSeniorLeadership,
|
|
304
|
+
isSportsCoach,
|
|
305
|
+
isStaff,
|
|
306
|
+
isStudent,
|
|
307
|
+
isSubjectTeacher,
|
|
308
|
+
isSystemAdmin,
|
|
309
|
+
linkGuardianContract,
|
|
310
|
+
listClassesContract,
|
|
311
|
+
listDepartmentsContract,
|
|
312
|
+
listStaffContract,
|
|
313
|
+
listStudentsContract,
|
|
56
314
|
loginContract,
|
|
57
315
|
logoutContract,
|
|
58
316
|
paginatedOutputSchema,
|
|
59
317
|
refreshTokenContract,
|
|
60
318
|
requestPasswordResetContract,
|
|
61
319
|
resetPasswordContract,
|
|
62
|
-
|
|
320
|
+
studentsContract,
|
|
321
|
+
switchBranchContract,
|
|
322
|
+
updateStaffStatusContract
|
|
63
323
|
};
|
|
64
324
|
//# sourceMappingURL=index.js.map
|
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) &&\n !isOrgSponsor(user) &&\n !isIndividualSponsor(user)\n )\n}"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA2BA,SA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