@brite-future-schools-contracts/contracts 1.0.8 → 2.0.3
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 +592 -0
- package/dist/contracts/index.cjs.map +1 -0
- package/dist/contracts/index.d.cts +1141 -0
- package/dist/contracts/index.d.ts +1069 -9648
- package/dist/contracts/index.js +48 -1412
- package/dist/contracts/index.js.map +1 -1
- package/dist/index.cjs +675 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +4 -0
- package/dist/index.d.ts +2 -2
- package/dist/index.js +132 -1536
- package/dist/index.js.map +1 -1
- package/dist/schemas/index.cjs +554 -0
- package/dist/schemas/index.cjs.map +1 -0
- package/dist/schemas/index.d.cts +708 -0
- package/dist/schemas/index.d.ts +664 -995
- package/dist/schemas/index.js +86 -640
- package/dist/schemas/index.js.map +1 -1
- package/package.json +32 -59
- package/dist/chunk-M6LF6JUL.mjs +0 -557
- package/dist/chunk-M6LF6JUL.mjs.map +0 -1
- package/dist/chunk-VC6SCJVW.mjs +0 -935
- package/dist/chunk-VC6SCJVW.mjs.map +0 -1
- package/dist/contracts/index.d.mts +0 -9720
- package/dist/contracts/index.mjs +0 -36
- package/dist/index.d.mts +0 -4
- package/dist/index.mjs +0 -161
- package/dist/index.mjs.map +0 -1
- package/dist/schemas/index.d.mts +0 -1039
- package/dist/schemas/index.mjs +0 -129
- package/dist/schemas/index.mjs.map +0 -1
- package/src/contracts/index.ts +0 -1209
- package/src/index.ts +0 -2
- package/src/schemas/index.ts +0 -586
- /package/dist/{contracts/index.mjs.map → chunk-R4XE3SFR.js.map} +0 -0
|
@@ -0,0 +1,592 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
|
|
30
|
+
// src/contracts/index.ts
|
|
31
|
+
var contracts_exports = {};
|
|
32
|
+
__export(contracts_exports, {
|
|
33
|
+
authContract: () => authContract,
|
|
34
|
+
bulkUploadStudentsContract: () => bulkUploadStudentsContract,
|
|
35
|
+
changePasswordContract: () => changePasswordContract,
|
|
36
|
+
createDepartmentContract: () => createDepartmentContract,
|
|
37
|
+
createStaffContract: () => createStaffContract,
|
|
38
|
+
createStudentContract: () => createStudentContract,
|
|
39
|
+
getMeContract: () => getMeContract,
|
|
40
|
+
getStaffByIdContract: () => getStaffByIdContract,
|
|
41
|
+
getStudentByIdContract: () => getStudentByIdContract,
|
|
42
|
+
hrContract: () => hrContract,
|
|
43
|
+
linkGuardianContract: () => linkGuardianContract,
|
|
44
|
+
listClassesContract: () => listClassesContract,
|
|
45
|
+
listDepartmentsContract: () => listDepartmentsContract,
|
|
46
|
+
listStaffContract: () => listStaffContract,
|
|
47
|
+
listStudentsContract: () => listStudentsContract,
|
|
48
|
+
loginContract: () => loginContract,
|
|
49
|
+
logoutContract: () => logoutContract,
|
|
50
|
+
refreshTokenContract: () => refreshTokenContract,
|
|
51
|
+
requestPasswordResetContract: () => requestPasswordResetContract,
|
|
52
|
+
resetPasswordContract: () => resetPasswordContract,
|
|
53
|
+
studentsContract: () => studentsContract,
|
|
54
|
+
switchBranchContract: () => switchBranchContract,
|
|
55
|
+
updateStaffStatusContract: () => updateStaffStatusContract
|
|
56
|
+
});
|
|
57
|
+
module.exports = __toCommonJS(contracts_exports);
|
|
58
|
+
|
|
59
|
+
// src/contracts/auth.ts
|
|
60
|
+
var import_contract = require("@orpc/contract");
|
|
61
|
+
var z3 = __toESM(require("zod"), 1);
|
|
62
|
+
|
|
63
|
+
// src/schemas/auth.ts
|
|
64
|
+
var z2 = __toESM(require("zod"), 1);
|
|
65
|
+
|
|
66
|
+
// src/schemas/base.ts
|
|
67
|
+
var z = __toESM(require("zod"), 1);
|
|
68
|
+
var CuidSchema = z.string().regex(/^[a-z][a-z0-9]{24}$/, "Invalid cuid2 identifier").meta({ description: "cuid2 \u2014 prefixed, collision-resistant identifier" });
|
|
69
|
+
var UuidSchema = z.uuidv4().meta({ description: "RFC-4122 UUID v4" });
|
|
70
|
+
var IsoDatetime = z.iso.datetime();
|
|
71
|
+
var TimestampsSchema = z.object({
|
|
72
|
+
createdAt: IsoDatetime.meta({ description: "ISO-8601 creation time (UTC)" }),
|
|
73
|
+
updatedAt: IsoDatetime.meta({ description: "ISO-8601 last update time (UTC)" })
|
|
74
|
+
});
|
|
75
|
+
var SoftDeleteSchema = z.object({
|
|
76
|
+
deletedAt: IsoDatetime.nullable().meta({
|
|
77
|
+
description: "Set when the record is soft-deleted; null if active"
|
|
78
|
+
})
|
|
79
|
+
});
|
|
80
|
+
var PaginationInputSchema = z.object({
|
|
81
|
+
cursor: CuidSchema.optional().meta({
|
|
82
|
+
description: "Opaque cursor from the previous page response"
|
|
83
|
+
}),
|
|
84
|
+
limit: z.int().min(1).max(100).default(20).meta({ description: "Number of items to return (1\u2013100, default 20)" })
|
|
85
|
+
});
|
|
86
|
+
var BranchRefSchema = z.object({
|
|
87
|
+
branchId: CuidSchema.meta({ description: "The branch this record belongs to" })
|
|
88
|
+
});
|
|
89
|
+
|
|
90
|
+
// src/schemas/auth.ts
|
|
91
|
+
var SessionUserRoleSchema = z2.object({
|
|
92
|
+
id: CuidSchema,
|
|
93
|
+
name: z2.string().meta({ description: "Role name, e.g. PRINCIPAL" }),
|
|
94
|
+
branchId: CuidSchema,
|
|
95
|
+
isPrimary: z2.boolean()
|
|
96
|
+
});
|
|
97
|
+
var SessionUserSubRoleSchema = z2.object({
|
|
98
|
+
id: CuidSchema,
|
|
99
|
+
name: z2.string().meta({ description: "Sub-role name, e.g. HEAD_PREFECT" }),
|
|
100
|
+
branchId: CuidSchema
|
|
101
|
+
});
|
|
102
|
+
var SessionUserOutputSchema = z2.object({
|
|
103
|
+
id: CuidSchema,
|
|
104
|
+
email: z2.email(),
|
|
105
|
+
firstName: z2.string(),
|
|
106
|
+
lastName: z2.string(),
|
|
107
|
+
activeBranchId: CuidSchema,
|
|
108
|
+
roles: z2.array(SessionUserRoleSchema),
|
|
109
|
+
subRoles: z2.array(SessionUserSubRoleSchema),
|
|
110
|
+
isActive: z2.boolean(),
|
|
111
|
+
mustChangePassword: z2.boolean()
|
|
112
|
+
});
|
|
113
|
+
var LoginInputSchema = z2.object({
|
|
114
|
+
email: z2.email().meta({ description: "User email address" }),
|
|
115
|
+
password: z2.string().min(1).meta({ description: "Plain-text password (sent over TLS)" }),
|
|
116
|
+
branchId: CuidSchema.optional().meta({
|
|
117
|
+
description: "Branch to activate on login; defaults to user primary branch"
|
|
118
|
+
})
|
|
119
|
+
});
|
|
120
|
+
var LoginOutputSchema = z2.object({
|
|
121
|
+
accessToken: z2.string().meta({ description: "Short-lived JWT (15 min)" }),
|
|
122
|
+
refreshToken: z2.string().meta({ description: "Long-lived opaque refresh token (7 days)" }),
|
|
123
|
+
expiresIn: z2.int().positive().meta({ description: "Access token TTL in seconds" }),
|
|
124
|
+
user: SessionUserOutputSchema
|
|
125
|
+
});
|
|
126
|
+
var RefreshTokenInputSchema = z2.object({
|
|
127
|
+
refreshToken: z2.string().min(1)
|
|
128
|
+
});
|
|
129
|
+
var RefreshTokenOutputSchema = z2.object({
|
|
130
|
+
accessToken: z2.string(),
|
|
131
|
+
expiresIn: z2.int().positive()
|
|
132
|
+
});
|
|
133
|
+
var LogoutInputSchema = z2.object({
|
|
134
|
+
refreshToken: z2.string().min(1).meta({
|
|
135
|
+
description: "The refresh token to revoke; also invalidated server-side"
|
|
136
|
+
})
|
|
137
|
+
});
|
|
138
|
+
var ChangePasswordInputSchema = z2.object({
|
|
139
|
+
currentPassword: z2.string().min(1),
|
|
140
|
+
newPassword: z2.string().min(8, { error: "Password must be at least 8 characters" }),
|
|
141
|
+
confirmPassword: z2.string().min(1)
|
|
142
|
+
}).refine((v) => v.newPassword === v.confirmPassword, {
|
|
143
|
+
error: "Passwords do not match",
|
|
144
|
+
path: ["confirmPassword"]
|
|
145
|
+
});
|
|
146
|
+
var RequestPasswordResetInputSchema = z2.object({
|
|
147
|
+
email: z2.email()
|
|
148
|
+
});
|
|
149
|
+
var ResetPasswordInputSchema = z2.object({
|
|
150
|
+
token: z2.string().min(1).meta({ description: "One-time reset token from email link" }),
|
|
151
|
+
newPassword: z2.string().min(8, { error: "Password must be at least 8 characters" }),
|
|
152
|
+
confirmPassword: z2.string().min(1)
|
|
153
|
+
}).refine((v) => v.newPassword === v.confirmPassword, {
|
|
154
|
+
error: "Passwords do not match",
|
|
155
|
+
path: ["confirmPassword"]
|
|
156
|
+
});
|
|
157
|
+
var SwitchBranchInputSchema = z2.object({
|
|
158
|
+
branchId: CuidSchema.meta({ description: "Branch to switch the active session to" })
|
|
159
|
+
});
|
|
160
|
+
|
|
161
|
+
// src/contracts/auth.ts
|
|
162
|
+
var EmptyOutputSchema = z3.object({}).meta({ description: "Empty success response" });
|
|
163
|
+
var loginContract = import_contract.oc.route({ method: "POST", path: "/auth/login" }).input(LoginInputSchema).output(LoginOutputSchema);
|
|
164
|
+
var refreshTokenContract = import_contract.oc.route({ method: "POST", path: "/auth/refresh" }).input(RefreshTokenInputSchema).output(RefreshTokenOutputSchema);
|
|
165
|
+
var logoutContract = import_contract.oc.route({ method: "POST", path: "/auth/logout" }).input(LogoutInputSchema).output(EmptyOutputSchema);
|
|
166
|
+
var getMeContract = import_contract.oc.route({ method: "GET", path: "/auth/me" }).output(SessionUserOutputSchema);
|
|
167
|
+
var changePasswordContract = import_contract.oc.route({ method: "POST", path: "/auth/change-password" }).input(ChangePasswordInputSchema).output(EmptyOutputSchema);
|
|
168
|
+
var requestPasswordResetContract = import_contract.oc.route({ method: "POST", path: "/auth/request-password-reset" }).input(RequestPasswordResetInputSchema).output(EmptyOutputSchema);
|
|
169
|
+
var resetPasswordContract = import_contract.oc.route({ method: "POST", path: "/auth/reset-password" }).input(ResetPasswordInputSchema).output(EmptyOutputSchema);
|
|
170
|
+
var switchBranchContract = import_contract.oc.route({ method: "POST", path: "/auth/switch-branch" }).input(SwitchBranchInputSchema).output(SessionUserOutputSchema);
|
|
171
|
+
var authContract = {
|
|
172
|
+
login: loginContract,
|
|
173
|
+
refreshToken: refreshTokenContract,
|
|
174
|
+
logout: logoutContract,
|
|
175
|
+
me: getMeContract,
|
|
176
|
+
changePassword: changePasswordContract,
|
|
177
|
+
requestPasswordReset: requestPasswordResetContract,
|
|
178
|
+
resetPassword: resetPasswordContract,
|
|
179
|
+
switchBranch: switchBranchContract
|
|
180
|
+
};
|
|
181
|
+
|
|
182
|
+
// src/contracts/hr.ts
|
|
183
|
+
var import_contract2 = require("@orpc/contract");
|
|
184
|
+
var z5 = __toESM(require("zod"), 1);
|
|
185
|
+
|
|
186
|
+
// src/schemas/hr.ts
|
|
187
|
+
var z4 = __toESM(require("zod"), 1);
|
|
188
|
+
var EmploymentTypeSchema = z4.enum([
|
|
189
|
+
"permanent",
|
|
190
|
+
"contract",
|
|
191
|
+
"temporary",
|
|
192
|
+
"intern"
|
|
193
|
+
]);
|
|
194
|
+
var RoleNameSchema = z4.enum([
|
|
195
|
+
"PROPRIETOR",
|
|
196
|
+
"DIRECTOR",
|
|
197
|
+
"SYSTEM_ADMIN",
|
|
198
|
+
"PRINCIPAL",
|
|
199
|
+
"DEPUTY_PRINCIPAL",
|
|
200
|
+
"HOD",
|
|
201
|
+
"CLASS_TEACHER",
|
|
202
|
+
"SUBJECT_TEACHER",
|
|
203
|
+
"BURSAR",
|
|
204
|
+
"HR_ADMIN",
|
|
205
|
+
"SCHOOL_NURSE",
|
|
206
|
+
"LIBRARIAN",
|
|
207
|
+
"LAB_TECHNICIAN",
|
|
208
|
+
"SPORTS_COACH",
|
|
209
|
+
"COUNSELLOR",
|
|
210
|
+
"CARETAKER",
|
|
211
|
+
"SECURITY",
|
|
212
|
+
"KITCHEN_STAFF",
|
|
213
|
+
"KITCHEN_MANAGER",
|
|
214
|
+
"DRIVER",
|
|
215
|
+
"IT_ADMIN",
|
|
216
|
+
"BOARDING_MASTER",
|
|
217
|
+
"PREFECT",
|
|
218
|
+
"STUDENT",
|
|
219
|
+
"PARENT",
|
|
220
|
+
"ORG_SPONSOR",
|
|
221
|
+
"INDIVIDUAL_SPONSOR"
|
|
222
|
+
]);
|
|
223
|
+
var CreateStaffInputSchema = z4.object({
|
|
224
|
+
// Personal details
|
|
225
|
+
firstName: z4.string().min(1).max(100),
|
|
226
|
+
middleName: z4.string().max(100).optional(),
|
|
227
|
+
lastName: z4.string().min(1).max(100),
|
|
228
|
+
email: z4.email(),
|
|
229
|
+
phone: z4.string().min(9).max(30),
|
|
230
|
+
nationalId: z4.string().min(1).max(20),
|
|
231
|
+
// Role assignment
|
|
232
|
+
roleName: RoleNameSchema.meta({
|
|
233
|
+
description: "System role to assign \u2014 determines dashboard access and permissions"
|
|
234
|
+
}),
|
|
235
|
+
isPrimaryRole: z4.boolean().default(true),
|
|
236
|
+
// Employment details
|
|
237
|
+
departmentId: UuidSchema.optional(),
|
|
238
|
+
designation: z4.string().min(1).max(100).meta({
|
|
239
|
+
description: 'Job title, e.g. "Mathematics Teacher", "Head of Finance"'
|
|
240
|
+
}),
|
|
241
|
+
employmentType: EmploymentTypeSchema,
|
|
242
|
+
contractStart: z4.iso.date().meta({ description: "ISO date, e.g. 2026-01-15" }),
|
|
243
|
+
contractEnd: z4.iso.date().optional(),
|
|
244
|
+
// Payroll
|
|
245
|
+
basicSalary: z4.number().positive(),
|
|
246
|
+
houseAllowance: z4.number().nonnegative().default(0),
|
|
247
|
+
transportAllowance: z4.number().nonnegative().default(0),
|
|
248
|
+
helbDeduction: z4.number().nonnegative().default(0),
|
|
249
|
+
saccoDeduction: z4.number().nonnegative().default(0),
|
|
250
|
+
// Banking
|
|
251
|
+
bankName: z4.string().max(100).optional(),
|
|
252
|
+
bankAccount: z4.string().max(30).optional(),
|
|
253
|
+
bankBranch: z4.string().max(100).optional(),
|
|
254
|
+
// Statutory
|
|
255
|
+
tscNumber: z4.string().max(30).optional(),
|
|
256
|
+
kraPin: z4.string().max(20).optional(),
|
|
257
|
+
nhifNo: z4.string().max(20).optional(),
|
|
258
|
+
nssfNo: z4.string().max(20).optional()
|
|
259
|
+
});
|
|
260
|
+
var StaffProfileSchema = z4.object({
|
|
261
|
+
// Staff record
|
|
262
|
+
id: UuidSchema,
|
|
263
|
+
userId: UuidSchema,
|
|
264
|
+
branchId: UuidSchema,
|
|
265
|
+
firstName: z4.string(),
|
|
266
|
+
middleName: z4.string().nullable(),
|
|
267
|
+
lastName: z4.string(),
|
|
268
|
+
phone: z4.string(),
|
|
269
|
+
nationalId: z4.string(),
|
|
270
|
+
tscNumber: z4.string().nullable(),
|
|
271
|
+
kraPin: z4.string().nullable(),
|
|
272
|
+
nhifNo: z4.string().nullable(),
|
|
273
|
+
nssfNo: z4.string().nullable(),
|
|
274
|
+
designation: z4.string(),
|
|
275
|
+
employmentType: EmploymentTypeSchema,
|
|
276
|
+
contractStart: z4.string(),
|
|
277
|
+
contractEnd: z4.string().nullable(),
|
|
278
|
+
basicSalary: z4.string(),
|
|
279
|
+
houseAllowance: z4.string(),
|
|
280
|
+
transportAllowance: z4.string(),
|
|
281
|
+
helbDeduction: z4.string().nullable(),
|
|
282
|
+
saccoDeduction: z4.string().nullable(),
|
|
283
|
+
bankName: z4.string().nullable(),
|
|
284
|
+
bankAccount: z4.string().nullable(),
|
|
285
|
+
bankBranch: z4.string().nullable(),
|
|
286
|
+
status: z4.string(),
|
|
287
|
+
createdAt: z4.string(),
|
|
288
|
+
// From users join
|
|
289
|
+
email: z4.string(),
|
|
290
|
+
mustChangePassword: z4.boolean(),
|
|
291
|
+
// Department (nullable — not all staff are in a department)
|
|
292
|
+
departmentId: UuidSchema.nullable(),
|
|
293
|
+
departmentName: z4.string().nullable(),
|
|
294
|
+
// Primary role
|
|
295
|
+
roleName: RoleNameSchema.nullable(),
|
|
296
|
+
roleId: UuidSchema.nullable()
|
|
297
|
+
});
|
|
298
|
+
var StaffListItemSchema = z4.object({
|
|
299
|
+
id: UuidSchema,
|
|
300
|
+
userId: UuidSchema,
|
|
301
|
+
firstName: z4.string(),
|
|
302
|
+
middleName: z4.string().nullable(),
|
|
303
|
+
lastName: z4.string(),
|
|
304
|
+
email: z4.string(),
|
|
305
|
+
phone: z4.string(),
|
|
306
|
+
designation: z4.string(),
|
|
307
|
+
employmentType: EmploymentTypeSchema,
|
|
308
|
+
status: z4.string(),
|
|
309
|
+
departmentName: z4.string().nullable(),
|
|
310
|
+
roleName: RoleNameSchema.nullable(),
|
|
311
|
+
createdAt: z4.string()
|
|
312
|
+
});
|
|
313
|
+
var ListStaffInputSchema = PaginationInputSchema.extend({
|
|
314
|
+
search: z4.string().optional().meta({
|
|
315
|
+
description: "Search by name or email"
|
|
316
|
+
}),
|
|
317
|
+
departmentId: UuidSchema.optional(),
|
|
318
|
+
roleName: RoleNameSchema.optional(),
|
|
319
|
+
status: z4.enum(["active", "inactive"]).optional()
|
|
320
|
+
});
|
|
321
|
+
var CreateStaffOutputSchema = z4.object({
|
|
322
|
+
staffId: UuidSchema,
|
|
323
|
+
userId: UuidSchema,
|
|
324
|
+
email: z4.string(),
|
|
325
|
+
/** Temp password was emailed — not returned in response for security */
|
|
326
|
+
emailSent: z4.boolean()
|
|
327
|
+
});
|
|
328
|
+
var DepartmentSchema = z4.object({
|
|
329
|
+
id: UuidSchema,
|
|
330
|
+
branchId: UuidSchema,
|
|
331
|
+
name: z4.string(),
|
|
332
|
+
hodId: UuidSchema.nullable()
|
|
333
|
+
});
|
|
334
|
+
var CreateDepartmentInputSchema = z4.object({
|
|
335
|
+
name: z4.string().min(1).max(100),
|
|
336
|
+
hodId: UuidSchema.optional()
|
|
337
|
+
});
|
|
338
|
+
|
|
339
|
+
// src/contracts/hr.ts
|
|
340
|
+
var EmptyOutput = z5.object({});
|
|
341
|
+
var createStaffContract = import_contract2.oc.route({ method: "POST", path: "/hr/staff" }).input(CreateStaffInputSchema).output(CreateStaffOutputSchema);
|
|
342
|
+
var listStaffContract = import_contract2.oc.route({ method: "GET", path: "/hr/staff" }).input(ListStaffInputSchema).output(z5.object({
|
|
343
|
+
items: z5.array(StaffListItemSchema),
|
|
344
|
+
total: z5.number(),
|
|
345
|
+
nextCursor: UuidSchema.nullable()
|
|
346
|
+
}));
|
|
347
|
+
var getStaffByIdContract = import_contract2.oc.route({ method: "GET", path: "/hr/staff/{id}" }).input(z5.object({ id: UuidSchema })).output(StaffProfileSchema);
|
|
348
|
+
var updateStaffStatusContract = import_contract2.oc.route({ method: "PATCH", path: "/hr/staff/{id}/status" }).input(z5.object({
|
|
349
|
+
id: UuidSchema,
|
|
350
|
+
status: z5.enum(["active", "inactive", "suspended"])
|
|
351
|
+
})).output(EmptyOutput);
|
|
352
|
+
var listDepartmentsContract = import_contract2.oc.route({ method: "GET", path: "/hr/departments" }).input(z5.object({ branchId: UuidSchema.optional() })).output(z5.array(DepartmentSchema));
|
|
353
|
+
var createDepartmentContract = import_contract2.oc.route({ method: "POST", path: "/hr/departments" }).input(CreateDepartmentInputSchema).output(DepartmentSchema);
|
|
354
|
+
var hrContract = {
|
|
355
|
+
createStaff: createStaffContract,
|
|
356
|
+
listStaff: listStaffContract,
|
|
357
|
+
getStaffById: getStaffByIdContract,
|
|
358
|
+
updateStaffStatus: updateStaffStatusContract,
|
|
359
|
+
listDepartments: listDepartmentsContract,
|
|
360
|
+
createDepartment: createDepartmentContract
|
|
361
|
+
};
|
|
362
|
+
|
|
363
|
+
// src/contracts/students.ts
|
|
364
|
+
var import_contract3 = require("@orpc/contract");
|
|
365
|
+
var z7 = __toESM(require("zod"), 1);
|
|
366
|
+
|
|
367
|
+
// src/schemas/students.ts
|
|
368
|
+
var z6 = __toESM(require("zod"), 1);
|
|
369
|
+
var GenderSchema = z6.enum(["male", "female"]);
|
|
370
|
+
var StudentStatusSchema = z6.enum([
|
|
371
|
+
"active",
|
|
372
|
+
"transferred",
|
|
373
|
+
"graduated",
|
|
374
|
+
"suspended",
|
|
375
|
+
"withdrawn"
|
|
376
|
+
]);
|
|
377
|
+
var GradeLevelSchema = z6.enum([
|
|
378
|
+
"PP1",
|
|
379
|
+
"PP2",
|
|
380
|
+
"G1",
|
|
381
|
+
"G2",
|
|
382
|
+
"G3",
|
|
383
|
+
"G4",
|
|
384
|
+
"G5",
|
|
385
|
+
"G6",
|
|
386
|
+
"G7",
|
|
387
|
+
"G8",
|
|
388
|
+
"G9"
|
|
389
|
+
]);
|
|
390
|
+
var CreateStudentInputSchema = z6.object({
|
|
391
|
+
// Identity
|
|
392
|
+
firstName: z6.string().min(1).max(100),
|
|
393
|
+
middleName: z6.string().max(100).optional(),
|
|
394
|
+
lastName: z6.string().min(1).max(100),
|
|
395
|
+
dateOfBirth: z6.iso.date().meta({ description: "ISO date, e.g. 2015-03-22" }),
|
|
396
|
+
gender: GenderSchema,
|
|
397
|
+
admissionNo: z6.string().min(1).max(50).meta({
|
|
398
|
+
description: "School-assigned admission number \u2014 must be unique per branch"
|
|
399
|
+
}),
|
|
400
|
+
nemisNo: z6.string().max(50).optional(),
|
|
401
|
+
admissionDate: z6.iso.date(),
|
|
402
|
+
bloodGroup: z6.string().max(10).optional(),
|
|
403
|
+
medicalNotes: z6.string().optional(),
|
|
404
|
+
// Class placement (optional at creation — can be enrolled later)
|
|
405
|
+
classId: UuidSchema.optional().meta({
|
|
406
|
+
description: "Class to enrol student in for the current term"
|
|
407
|
+
}),
|
|
408
|
+
termId: UuidSchema.optional().meta({
|
|
409
|
+
description: "Term for class enrolment \u2014 required if classId is provided"
|
|
410
|
+
}),
|
|
411
|
+
// Guardian (optional at creation — can be linked later)
|
|
412
|
+
guardian: z6.object({
|
|
413
|
+
firstName: z6.string().min(1).max(100),
|
|
414
|
+
middleName: z6.string().max(100).optional(),
|
|
415
|
+
lastName: z6.string().min(1).max(100),
|
|
416
|
+
relationship: z6.string().min(1).max(50).meta({
|
|
417
|
+
description: "e.g. mother, father, uncle, guardian"
|
|
418
|
+
}),
|
|
419
|
+
phone: z6.string().min(9).max(30),
|
|
420
|
+
email: z6.email().optional(),
|
|
421
|
+
nationalId: z6.string().max(20).optional(),
|
|
422
|
+
occupation: z6.string().max(100).optional()
|
|
423
|
+
}).optional()
|
|
424
|
+
});
|
|
425
|
+
var StudentProfileSchema = z6.object({
|
|
426
|
+
id: UuidSchema,
|
|
427
|
+
branchId: UuidSchema,
|
|
428
|
+
admissionNo: z6.string(),
|
|
429
|
+
nemisNo: z6.string().nullable(),
|
|
430
|
+
firstName: z6.string(),
|
|
431
|
+
middleName: z6.string().nullable(),
|
|
432
|
+
lastName: z6.string(),
|
|
433
|
+
dateOfBirth: z6.string(),
|
|
434
|
+
gender: GenderSchema,
|
|
435
|
+
photoUrl: z6.string().nullable(),
|
|
436
|
+
bloodGroup: z6.string().nullable(),
|
|
437
|
+
medicalNotes: z6.string().nullable(),
|
|
438
|
+
admissionDate: z6.string(),
|
|
439
|
+
status: StudentStatusSchema,
|
|
440
|
+
createdAt: z6.string(),
|
|
441
|
+
// Current class (from latest enrollment)
|
|
442
|
+
currentClass: z6.object({
|
|
443
|
+
classId: UuidSchema,
|
|
444
|
+
className: z6.string(),
|
|
445
|
+
gradeLevel: GradeLevelSchema,
|
|
446
|
+
termId: UuidSchema,
|
|
447
|
+
termName: z6.string()
|
|
448
|
+
}).nullable(),
|
|
449
|
+
// Guardians
|
|
450
|
+
guardians: z6.array(z6.object({
|
|
451
|
+
id: UuidSchema,
|
|
452
|
+
firstName: z6.string(),
|
|
453
|
+
middleName: z6.string().nullable(),
|
|
454
|
+
lastName: z6.string(),
|
|
455
|
+
relationship: z6.string(),
|
|
456
|
+
phone: z6.string(),
|
|
457
|
+
email: z6.string().nullable(),
|
|
458
|
+
isPrimary: z6.boolean()
|
|
459
|
+
}))
|
|
460
|
+
});
|
|
461
|
+
var StudentListItemSchema = z6.object({
|
|
462
|
+
id: UuidSchema,
|
|
463
|
+
admissionNo: z6.string(),
|
|
464
|
+
firstName: z6.string(),
|
|
465
|
+
middleName: z6.string().nullable(),
|
|
466
|
+
lastName: z6.string(),
|
|
467
|
+
gender: GenderSchema,
|
|
468
|
+
status: StudentStatusSchema,
|
|
469
|
+
className: z6.string().nullable(),
|
|
470
|
+
gradeLevel: GradeLevelSchema.nullable(),
|
|
471
|
+
primaryGuardianName: z6.string().nullable(),
|
|
472
|
+
primaryGuardianPhone: z6.string().nullable(),
|
|
473
|
+
createdAt: z6.string()
|
|
474
|
+
});
|
|
475
|
+
var ListStudentsInputSchema = PaginationInputSchema.extend({
|
|
476
|
+
search: z6.string().optional().meta({
|
|
477
|
+
description: "Search by name or admission number"
|
|
478
|
+
}),
|
|
479
|
+
classId: UuidSchema.optional(),
|
|
480
|
+
gradeLevel: GradeLevelSchema.optional(),
|
|
481
|
+
status: StudentStatusSchema.optional(),
|
|
482
|
+
termId: UuidSchema.optional()
|
|
483
|
+
});
|
|
484
|
+
var BulkUploadStudentRowSchema = z6.object({
|
|
485
|
+
firstName: z6.string().min(1),
|
|
486
|
+
middleName: z6.string().optional(),
|
|
487
|
+
lastName: z6.string().min(1),
|
|
488
|
+
dateOfBirth: z6.string().min(1).meta({ description: "Any parseable date string" }),
|
|
489
|
+
gender: z6.string().min(1).meta({ description: "male | female (case-insensitive)" }),
|
|
490
|
+
admissionNo: z6.string().min(1),
|
|
491
|
+
nemisNo: z6.string().optional(),
|
|
492
|
+
admissionDate: z6.string().optional(),
|
|
493
|
+
bloodGroup: z6.string().optional(),
|
|
494
|
+
// Guardian columns (all optional in CSV)
|
|
495
|
+
guardianFirstName: z6.string().optional(),
|
|
496
|
+
guardianLastName: z6.string().optional(),
|
|
497
|
+
guardianRelationship: z6.string().optional(),
|
|
498
|
+
guardianPhone: z6.string().optional(),
|
|
499
|
+
guardianEmail: z6.string().optional()
|
|
500
|
+
});
|
|
501
|
+
var BulkUploadStudentsInputSchema = z6.object({
|
|
502
|
+
classId: UuidSchema.meta({
|
|
503
|
+
description: "Class to enrol all uploaded students into"
|
|
504
|
+
}),
|
|
505
|
+
termId: UuidSchema,
|
|
506
|
+
rows: z6.array(BulkUploadStudentRowSchema).min(1).max(500)
|
|
507
|
+
});
|
|
508
|
+
var BulkUploadStudentsOutputSchema = z6.object({
|
|
509
|
+
created: z6.int().nonnegative(),
|
|
510
|
+
skipped: z6.int().nonnegative(),
|
|
511
|
+
errors: z6.array(z6.object({
|
|
512
|
+
row: z6.int().positive(),
|
|
513
|
+
admissionNo: z6.string().optional(),
|
|
514
|
+
reason: z6.string()
|
|
515
|
+
}))
|
|
516
|
+
});
|
|
517
|
+
var CreateStudentOutputSchema = z6.object({
|
|
518
|
+
studentId: UuidSchema,
|
|
519
|
+
admissionNo: z6.string()
|
|
520
|
+
});
|
|
521
|
+
var LinkGuardianInputSchema = z6.object({
|
|
522
|
+
studentId: UuidSchema,
|
|
523
|
+
firstName: z6.string().min(1).max(100),
|
|
524
|
+
middleName: z6.string().max(100).optional(),
|
|
525
|
+
lastName: z6.string().min(1).max(100),
|
|
526
|
+
relationship: z6.string().min(1).max(50),
|
|
527
|
+
phone: z6.string().min(9).max(30),
|
|
528
|
+
email: z6.email().optional(),
|
|
529
|
+
nationalId: z6.string().max(20).optional(),
|
|
530
|
+
occupation: z6.string().max(100).optional(),
|
|
531
|
+
isPrimary: z6.boolean().default(false)
|
|
532
|
+
});
|
|
533
|
+
var ClassSummarySchema = z6.object({
|
|
534
|
+
id: UuidSchema,
|
|
535
|
+
name: z6.string(),
|
|
536
|
+
gradeLevel: GradeLevelSchema,
|
|
537
|
+
gradeName: z6.string(),
|
|
538
|
+
capacity: z6.number().nullable(),
|
|
539
|
+
enrolledCount: z6.number(),
|
|
540
|
+
classTeacherId: UuidSchema.nullable()
|
|
541
|
+
});
|
|
542
|
+
|
|
543
|
+
// src/contracts/students.ts
|
|
544
|
+
var EmptyOutput2 = z7.object({});
|
|
545
|
+
var createStudentContract = import_contract3.oc.route({ method: "POST", path: "/students" }).input(CreateStudentInputSchema).output(CreateStudentOutputSchema);
|
|
546
|
+
var bulkUploadStudentsContract = import_contract3.oc.route({ method: "POST", path: "/students/bulk" }).input(BulkUploadStudentsInputSchema).output(BulkUploadStudentsOutputSchema);
|
|
547
|
+
var listStudentsContract = import_contract3.oc.route({ method: "GET", path: "/students" }).input(ListStudentsInputSchema).output(z7.object({
|
|
548
|
+
items: z7.array(StudentListItemSchema),
|
|
549
|
+
total: z7.number(),
|
|
550
|
+
nextCursor: UuidSchema.nullable()
|
|
551
|
+
}));
|
|
552
|
+
var getStudentByIdContract = import_contract3.oc.route({ method: "GET", path: "/students/{id}" }).input(z7.object({ id: UuidSchema })).output(StudentProfileSchema);
|
|
553
|
+
var linkGuardianContract = import_contract3.oc.route({ method: "POST", path: "/students/guardians" }).input(LinkGuardianInputSchema).output(z7.object({ guardianId: UuidSchema }));
|
|
554
|
+
var listClassesContract = import_contract3.oc.route({ method: "GET", path: "/students/classes" }).input(z7.object({
|
|
555
|
+
termId: UuidSchema.optional(),
|
|
556
|
+
gradeLevel: z7.string().optional()
|
|
557
|
+
})).output(z7.array(ClassSummarySchema));
|
|
558
|
+
var studentsContract = {
|
|
559
|
+
create: createStudentContract,
|
|
560
|
+
bulkUpload: bulkUploadStudentsContract,
|
|
561
|
+
list: listStudentsContract,
|
|
562
|
+
getById: getStudentByIdContract,
|
|
563
|
+
linkGuardian: linkGuardianContract,
|
|
564
|
+
listClasses: listClassesContract
|
|
565
|
+
};
|
|
566
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
567
|
+
0 && (module.exports = {
|
|
568
|
+
authContract,
|
|
569
|
+
bulkUploadStudentsContract,
|
|
570
|
+
changePasswordContract,
|
|
571
|
+
createDepartmentContract,
|
|
572
|
+
createStaffContract,
|
|
573
|
+
createStudentContract,
|
|
574
|
+
getMeContract,
|
|
575
|
+
getStaffByIdContract,
|
|
576
|
+
getStudentByIdContract,
|
|
577
|
+
hrContract,
|
|
578
|
+
linkGuardianContract,
|
|
579
|
+
listClassesContract,
|
|
580
|
+
listDepartmentsContract,
|
|
581
|
+
listStaffContract,
|
|
582
|
+
listStudentsContract,
|
|
583
|
+
loginContract,
|
|
584
|
+
logoutContract,
|
|
585
|
+
refreshTokenContract,
|
|
586
|
+
requestPasswordResetContract,
|
|
587
|
+
resetPasswordContract,
|
|
588
|
+
studentsContract,
|
|
589
|
+
switchBranchContract,
|
|
590
|
+
updateStaffStatusContract
|
|
591
|
+
});
|
|
592
|
+
//# sourceMappingURL=index.cjs.map
|