metis-desk/modules/companies/src/common/dto/shared/company.dto.ts
David 18324f92bd feat: add person and department management features
- Implemented Person entity with validation and update methods.
- Created CalendarDate value object for date validation.
- Developed migration script to transition company_contacts to person and department structures.
- Established Sequelize models for departments and assignments.
- Introduced request DTOs for person and department management.
- Added shared DTO schemas for validation.
- Built assignment and department forms with validation and submission handling.
- Created people section to manage and display company personnel.
- Implemented person form for adding and editing personnel details.
2026-10-03 13:13:15 +02:00

38 lines
1.2 KiB
TypeScript

import { z } from "zod/v4";
import {
DepartmentAssignmentSchema,
DepartmentSchema,
PersonFieldsSchema,
PersonSchema,
} from "./people.dto";
const RequiredTextSchema = z
.string()
.min(1)
.max(100)
.refine((value) => value.trim().length > 0);
export const CompanyFieldsSchema = z.strictObject({
name: RequiredTextSchema,
active: z.boolean(),
});
export const ContactFieldsSchema = PersonFieldsSchema.omit({ isContact: true });
export const SiteFieldsSchema = z.strictObject({
name: RequiredTextSchema,
address: z.string().max(10000).nullable(),
});
export const CompanySummarySchema = CompanyFieldsSchema.extend({ id: z.uuid() });
export type CompanySummaryDTO = z.infer<typeof CompanySummarySchema>;
export const ContactSchema = PersonSchema;
export type ContactDTO = z.infer<typeof ContactSchema>;
export const SiteSchema = SiteFieldsSchema.extend({ id: z.uuid(), companyId: z.uuid() });
export type SiteDTO = z.infer<typeof SiteSchema>;
export const CompanySchema = CompanySummarySchema.extend({
contacts: z.array(ContactSchema),
sites: z.array(SiteSchema),
people: z.array(PersonSchema),
departments: z.array(DepartmentSchema),
assignments: z.array(DepartmentAssignmentSchema),
});
export type CompanyDTO = z.infer<typeof CompanySchema>;