49 lines
1.5 KiB
TypeScript
49 lines
1.5 KiB
TypeScript
|
|
import { z } from "zod/v4";
|
||
|
|
|
||
|
|
const OptionalText = z.string().max(100).nullable();
|
||
|
|
export const PersonFieldsSchema = z.strictObject({
|
||
|
|
name: z
|
||
|
|
.string()
|
||
|
|
.min(1)
|
||
|
|
.max(100)
|
||
|
|
.refine((value) => value.trim().length > 0),
|
||
|
|
position: OptionalText,
|
||
|
|
email: z.email().max(254).nullable(),
|
||
|
|
phone: z.string().min(3).max(50).nullable(),
|
||
|
|
active: z.boolean(),
|
||
|
|
isContact: z.boolean(),
|
||
|
|
});
|
||
|
|
export const PersonSchema = PersonFieldsSchema.extend({ id: z.uuid(), companyId: z.uuid() });
|
||
|
|
export type PersonDTO = z.infer<typeof PersonSchema>;
|
||
|
|
export const DepartmentFieldsSchema = z.strictObject({
|
||
|
|
name: z
|
||
|
|
.string()
|
||
|
|
.min(1)
|
||
|
|
.max(100)
|
||
|
|
.refine((value) => value.trim().length > 0),
|
||
|
|
active: z.boolean(),
|
||
|
|
});
|
||
|
|
export const DepartmentSchema = DepartmentFieldsSchema.extend({
|
||
|
|
id: z.uuid(),
|
||
|
|
companyId: z.uuid(),
|
||
|
|
});
|
||
|
|
export type DepartmentDTO = z.infer<typeof DepartmentSchema>;
|
||
|
|
export const AssignmentFieldsSchema = z.strictObject({
|
||
|
|
position: OptionalText,
|
||
|
|
startDate: z.iso.date(),
|
||
|
|
endDate: z.iso.date().nullable(),
|
||
|
|
isPrimary: z.boolean(),
|
||
|
|
});
|
||
|
|
export const AssignmentRevisionSchema = AssignmentFieldsSchema.extend({
|
||
|
|
id: z.uuid(),
|
||
|
|
recordedAt: z.iso.datetime(),
|
||
|
|
});
|
||
|
|
export const DepartmentAssignmentSchema = AssignmentFieldsSchema.extend({
|
||
|
|
id: z.uuid(),
|
||
|
|
companyId: z.uuid(),
|
||
|
|
personId: z.uuid(),
|
||
|
|
departmentId: z.uuid(),
|
||
|
|
history: z.array(AssignmentRevisionSchema),
|
||
|
|
});
|
||
|
|
export type DepartmentAssignmentDTO = z.infer<typeof DepartmentAssignmentSchema>;
|