2026-10-03 11:13:15 +00:00
|
|
|
import { z } from "zod/v4";
|
2026-10-09 21:00:34 +00:00
|
|
|
import { PersonPhotoVersionSchema } from "../../person-photo";
|
2026-10-03 11:13:15 +00:00
|
|
|
|
|
|
|
|
const OptionalText = z.string().max(100).nullable();
|
2026-10-10 10:01:58 +00:00
|
|
|
|
2026-10-03 11:13:15 +00:00
|
|
|
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(),
|
|
|
|
|
});
|
2026-10-10 10:01:58 +00:00
|
|
|
|
|
|
|
|
export const PersonSchema = PersonFieldsSchema.extend({
|
|
|
|
|
id: z.uuid(),
|
|
|
|
|
companyId: z.uuid(),
|
|
|
|
|
photoVersion: PersonPhotoVersionSchema.nullable().optional(),
|
|
|
|
|
});
|
|
|
|
|
|
2026-10-03 11:13:15 +00:00
|
|
|
export type PersonDTO = z.infer<typeof PersonSchema>;
|
2026-10-10 10:01:58 +00:00
|
|
|
|
2026-10-03 11:13:15 +00:00
|
|
|
export const DepartmentFieldsSchema = z.strictObject({
|
|
|
|
|
name: z
|
|
|
|
|
.string()
|
|
|
|
|
.min(1)
|
|
|
|
|
.max(100)
|
|
|
|
|
.refine((value) => value.trim().length > 0),
|
|
|
|
|
active: z.boolean(),
|
|
|
|
|
});
|
2026-10-10 10:01:58 +00:00
|
|
|
|
2026-10-03 11:13:15 +00:00
|
|
|
export const DepartmentSchema = DepartmentFieldsSchema.extend({
|
|
|
|
|
id: z.uuid(),
|
|
|
|
|
companyId: z.uuid(),
|
|
|
|
|
});
|
2026-10-10 10:01:58 +00:00
|
|
|
|
2026-10-03 11:13:15 +00:00
|
|
|
export type DepartmentDTO = z.infer<typeof DepartmentSchema>;
|
2026-10-10 10:01:58 +00:00
|
|
|
|
2026-10-03 11:13:15 +00:00
|
|
|
export const AssignmentFieldsSchema = z.strictObject({
|
|
|
|
|
position: OptionalText,
|
|
|
|
|
startDate: z.iso.date(),
|
|
|
|
|
endDate: z.iso.date().nullable(),
|
|
|
|
|
isPrimary: z.boolean(),
|
|
|
|
|
});
|
2026-10-10 10:01:58 +00:00
|
|
|
|
2026-10-03 11:13:15 +00:00
|
|
|
export const AssignmentRevisionSchema = AssignmentFieldsSchema.extend({
|
|
|
|
|
id: z.uuid(),
|
|
|
|
|
recordedAt: z.iso.datetime(),
|
|
|
|
|
});
|
2026-10-10 10:01:58 +00:00
|
|
|
|
2026-10-03 11:13:15 +00:00
|
|
|
export const DepartmentAssignmentSchema = AssignmentFieldsSchema.extend({
|
|
|
|
|
id: z.uuid(),
|
|
|
|
|
companyId: z.uuid(),
|
|
|
|
|
personId: z.uuid(),
|
|
|
|
|
departmentId: z.uuid(),
|
|
|
|
|
history: z.array(AssignmentRevisionSchema),
|
|
|
|
|
});
|
2026-10-10 10:01:58 +00:00
|
|
|
|
2026-10-03 11:13:15 +00:00
|
|
|
export type DepartmentAssignmentDTO = z.infer<typeof DepartmentAssignmentSchema>;
|