-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathtraining.zod.ts
More file actions
217 lines (187 loc) · 6.36 KB
/
Copy pathtraining.zod.ts
File metadata and controls
217 lines (187 loc) · 6.36 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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
// Copyright (c) 2025 ObjectStack. Licensed under the Apache-2.0 license.
import { z } from 'zod';
/**
* Information Security Training Protocol — ISO 27001:2022 (A.6.3)
*
* Defines schemas for security awareness and training management including
* course definitions, completion tracking, and organizational training plans.
*
* @see https://www.iso.org/standard/27001
* @category Security
*/
/**
* Training Category Schema
*
* Classification of training content by domain.
*/
import { lazySchema } from '../shared/lazy-schema';
export const TrainingCategorySchema = lazySchema(() => z.enum([
'security_awareness', // General security awareness
'data_protection', // Data handling and privacy
'incident_response', // Incident reporting and response
'access_control', // Access management best practices
'phishing_awareness', // Phishing and social engineering
'compliance', // Regulatory compliance (GDPR, HIPAA, etc.)
'secure_development', // Secure coding and development practices
'physical_security', // Physical security awareness
'business_continuity', // Business continuity and disaster recovery
'other', // Other training categories
]));
/**
* Training Completion Status Schema
*/
export const TrainingCompletionStatusSchema = lazySchema(() => z.enum([
'not_started', // Training not yet begun
'in_progress', // Training currently underway
'completed', // Training completed successfully
'failed', // Training assessment not passed
'expired', // Training certification has expired
]));
/**
* Training Course Schema
*
* Definition of a security training course or module.
*
* @example
* ```json
* {
* "id": "COURSE-SEC-001",
* "title": "Information Security Fundamentals",
* "description": "Annual security awareness training for all employees",
* "category": "security_awareness",
* "durationMinutes": 60,
* "mandatory": true,
* "targetRoles": ["all_employees"],
* "validityDays": 365,
* "passingScore": 80
* }
* ```
*/
export const TrainingCourseSchema = lazySchema(() => z.object({
/**
* Unique course identifier
*/
id: z.string().describe('Unique course identifier'),
/**
* Course title
*/
title: z.string().describe('Course title'),
/**
* Course description and objectives
*/
description: z.string().describe('Course description and learning objectives'),
/**
* Training category
*/
category: TrainingCategorySchema.describe('Training category'),
/**
* Estimated duration in minutes
*/
durationMinutes: z.number().min(1).describe('Estimated course duration in minutes'),
/**
* Whether this training is mandatory
*/
mandatory: z.boolean().default(false).describe('Whether training is mandatory'),
/**
* Target roles or groups for this training
*/
targetRoles: z.array(z.string()).describe('Target roles or groups'),
/**
* Validity period in days before recertification is needed
*/
validityDays: z.number().optional().describe('Certification validity period in days'),
/**
* Minimum passing score (percentage) for assessment
*/
passingScore: z.number().min(0).max(100).optional()
.describe('Minimum passing score percentage'),
/**
* Course version for tracking content updates
*/
version: z.string().optional().describe('Course content version'),
}).describe('Security training course definition'));
/**
* Training Record Schema
*
* Individual employee training completion record.
*/
export const TrainingRecordSchema = lazySchema(() => z.object({
/**
* Reference to the course ID
*/
courseId: z.string().describe('Training course identifier'),
/**
* User who completed (or is assigned) the training
*/
userId: z.string().describe('User identifier'),
/**
* Completion status
*/
status: TrainingCompletionStatusSchema.describe('Training completion status'),
/**
* Training assignment date (Unix milliseconds)
*/
assignedAt: z.number().describe('Assignment timestamp'),
/**
* Training completion date (Unix milliseconds)
*/
completedAt: z.number().optional().describe('Completion timestamp'),
/**
* Assessment score (percentage)
*/
score: z.number().min(0).max(100).optional().describe('Assessment score percentage'),
/**
* Certification expiry date (Unix milliseconds)
*/
expiresAt: z.number().optional().describe('Certification expiry timestamp'),
/**
* Notes or comments from instructor or system
*/
notes: z.string().optional().describe('Training notes or comments'),
}).describe('Individual training completion record'));
/**
* Training Plan Schema
*
* Organizational training plan defining schedule and requirements (A.6.3).
*/
export const TrainingPlanSchema = lazySchema(() => z.object({
/**
* Whether training management is enabled
*/
enabled: z.boolean().default(true).describe('Enable training management'),
/**
* Training courses in the plan
*/
courses: z.array(TrainingCourseSchema).describe('Training courses'),
/**
* Default recertification interval in days
*/
recertificationIntervalDays: z.number().default(365)
.describe('Default recertification interval in days'),
/**
* Whether to track training completion for compliance reporting
*/
trackCompletion: z.boolean().default(true)
.describe('Track training completion for compliance'),
/**
* Grace period in days after expiry before non-compliance escalation
*/
gracePeriodDays: z.number().default(30)
.describe('Grace period in days after certification expiry'),
/**
* Whether to send reminders for upcoming training deadlines
*/
sendReminders: z.boolean().default(true)
.describe('Send reminders for upcoming training deadlines'),
/**
* Days before deadline to send first reminder
*/
reminderDaysBefore: z.number().default(14)
.describe('Days before deadline to send first reminder'),
}).describe('Organizational training plan per ISO 27001:2022 A.6.3'));
// Type exports
export type TrainingCategory = z.infer<typeof TrainingCategorySchema>;
export type TrainingCompletionStatus = z.infer<typeof TrainingCompletionStatusSchema>;
export type TrainingCourse = z.infer<typeof TrainingCourseSchema>;
export type TrainingRecord = z.infer<typeof TrainingRecordSchema>;
export type TrainingPlan = z.infer<typeof TrainingPlanSchema>;