metis-desk/modules/companies/src/common/dto/shared/people.dto.ts

64 lines
1.6 KiB
TypeScript
Raw Normal View History

import { z } from "zod/v4";
import { PersonPhotoVersionSchema } from "../../person-photo";
const OptionalText = z.string().max(100).nullable();
2026-10-10 10:01:58 +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(),
});
export type PersonDTO = z.infer<typeof PersonSchema>;
2026-10-10 10:01:58 +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
export const DepartmentSchema = DepartmentFieldsSchema.extend({
id: z.uuid(),
companyId: z.uuid(),
});
2026-10-10 10:01:58 +00:00
export type DepartmentDTO = z.infer<typeof DepartmentSchema>;
2026-10-10 10:01:58 +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
export const AssignmentRevisionSchema = AssignmentFieldsSchema.extend({
id: z.uuid(),
recordedAt: z.iso.datetime(),
});
2026-10-10 10:01:58 +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
export type DepartmentAssignmentDTO = z.infer<typeof DepartmentAssignmentSchema>;