-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathrole.zod.ts
More file actions
42 lines (38 loc) · 1.3 KB
/
role.zod.ts
File metadata and controls
42 lines (38 loc) · 1.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
import { z } from 'zod';
import { SnakeCaseIdentifierSchema } from '../shared/identifiers.zod';
/**
* Role Schema (aka Business Unit / Org Unit)
* Defines the organizational hierarchy (Reporting Structure).
*
* COMPARISON:
* - Salesforce: "Role" (Hierarchy for visibility rollup)
* - Microsoft: "Business Unit" (Structural container for data)
* - Kubernetes/AWS: "Role" usually refers to Permissions (we use PermissionSet for that)
*
* ROLES IN OBJECTSTACK:
* Used primarily for "Reporting Structure" - Managers see subordinates' data.
*
* **NAMING CONVENTION:**
* Role names MUST be lowercase snake_case to prevent security issues.
*
* @example Good role names
* - 'sales_manager'
* - 'ceo'
* - 'region_east_vp'
* - 'engineering_lead'
*
* @example Bad role names (will be rejected)
* - 'SalesManager' (camelCase)
* - 'CEO' (uppercase)
* - 'Region East VP' (spaces and uppercase)
*/
export const RoleSchema = z.object({
/** Identity */
name: SnakeCaseIdentifierSchema.describe('Unique role name (lowercase snake_case)'),
label: z.string().describe('Display label (e.g. VP of Sales)'),
/** Hierarchy */
parent: z.string().optional().describe('Parent Role ID (Reports To)'),
/** Description */
description: z.string().optional(),
});
export type Role = z.infer<typeof RoleSchema>;