@brite-future-schools-contracts/contracts 2.0.32 → 2.0.36

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.
@@ -207,6 +207,7 @@ declare const createStaffContract: _orpc_contract.ContractProcedureBuilderWithIn
207
207
  nationalId: z.ZodString;
208
208
  roleName: z.ZodString;
209
209
  isPrimaryRole: z.ZodDefault<z.ZodBoolean>;
210
+ branchId: z.ZodOptional<z.ZodUUID>;
210
211
  departmentId: z.ZodOptional<z.ZodUUID>;
211
212
  designation: z.ZodString;
212
213
  employmentType: z.ZodEnum<{
@@ -339,6 +340,7 @@ declare const hrContract: {
339
340
  nationalId: z.ZodString;
340
341
  roleName: z.ZodString;
341
342
  isPrimaryRole: z.ZodDefault<z.ZodBoolean>;
343
+ branchId: z.ZodOptional<z.ZodUUID>;
342
344
  departmentId: z.ZodOptional<z.ZodUUID>;
343
345
  designation: z.ZodString;
344
346
  employmentType: z.ZodEnum<{
@@ -78,8 +78,8 @@ import {
78
78
  updateBankAccountContract,
79
79
  updateCategoryContract,
80
80
  updateStaffStatusContract
81
- } from "../chunk-2B5AQI2I.js";
82
- import "../chunk-7AJ4LRST.js";
81
+ } from "../chunk-RV423CEB.js";
82
+ import "../chunk-E3VLQFEY.js";
83
83
  export {
84
84
  acknowledgeContract,
85
85
  acknowledgeDiaryEntryContract,
package/dist/index.cjs CHANGED
@@ -407,6 +407,10 @@ var CreateStaffInputSchema = z3.object({
407
407
  description: "Role code from the roles table \u2014 e.g. TEACHER, HEAD_TEACHER"
408
408
  }),
409
409
  isPrimaryRole: z3.boolean().default(true),
410
+ // Oversight-only override — Proprietor/Director/System Admin can
411
+ // target a branch other than their own active one. Ignored server-side
412
+ // for non-oversight callers, who are always scoped to their own branch.
413
+ branchId: UuidSchema.optional(),
410
414
  // Employment details
411
415
  departmentId: UuidSchema.optional(),
412
416
  designation: z3.string().min(1).max(100).meta({
@@ -1335,7 +1339,15 @@ var blocksContract = {
1335
1339
  };
1336
1340
 
1337
1341
  // src/roles/helpers.ts
1342
+ var ORG_SCOPED_ROLES = /* @__PURE__ */ new Set([
1343
+ "PROPRIETOR",
1344
+ "DIRECTOR",
1345
+ "SYSTEM_ADMIN"
1346
+ ]);
1338
1347
  function hasRole(user, role) {
1348
+ if (ORG_SCOPED_ROLES.has(role)) {
1349
+ return user.roles.some((r) => r.name === role);
1350
+ }
1339
1351
  return user.roles.some(
1340
1352
  (r) => r.name === role && (!user.activeBranchId || r.branchId === user.activeBranchId)
1341
1353
  );