2026-10-03 10:36:03 +00:00
|
|
|
import { z } from "zod/v4";
|
|
|
|
|
|
2026-10-08 16:31:46 +00:00
|
|
|
import { CompanyLogoVersionSchema } from "../../company-logo";
|
|
|
|
|
|
2026-10-03 11:13:15 +00:00
|
|
|
import {
|
|
|
|
|
DepartmentAssignmentSchema,
|
|
|
|
|
DepartmentSchema,
|
|
|
|
|
PersonFieldsSchema,
|
|
|
|
|
PersonSchema,
|
|
|
|
|
} from "./people.dto";
|
|
|
|
|
|
2026-10-03 10:36:03 +00:00
|
|
|
const RequiredTextSchema = z
|
|
|
|
|
.string()
|
|
|
|
|
.min(1)
|
|
|
|
|
.max(100)
|
|
|
|
|
.refine((value) => value.trim().length > 0);
|
2026-10-10 10:01:58 +00:00
|
|
|
|
2026-10-03 10:36:03 +00:00
|
|
|
export const CompanyFieldsSchema = z.strictObject({
|
|
|
|
|
name: RequiredTextSchema,
|
|
|
|
|
active: z.boolean(),
|
|
|
|
|
});
|
2026-10-10 10:01:58 +00:00
|
|
|
|
2026-10-03 11:13:15 +00:00
|
|
|
export const ContactFieldsSchema = PersonFieldsSchema.omit({ isContact: true });
|
2026-10-10 10:01:58 +00:00
|
|
|
|
2026-10-03 10:36:03 +00:00
|
|
|
export const SiteFieldsSchema = z.strictObject({
|
|
|
|
|
name: RequiredTextSchema,
|
|
|
|
|
address: z.string().max(10000).nullable(),
|
2026-10-10 20:22:28 +00:00
|
|
|
phone: z.string().max(50).nullable(),
|
2026-10-03 10:36:03 +00:00
|
|
|
});
|
2026-10-10 10:01:58 +00:00
|
|
|
|
2026-10-08 16:31:46 +00:00
|
|
|
export const CompanySummarySchema = CompanyFieldsSchema.extend({
|
|
|
|
|
id: z.uuid(),
|
|
|
|
|
logoVersion: CompanyLogoVersionSchema.nullable().optional(),
|
|
|
|
|
});
|
2026-10-10 10:01:58 +00:00
|
|
|
|
2026-10-03 10:36:03 +00:00
|
|
|
export type CompanySummaryDTO = z.infer<typeof CompanySummarySchema>;
|
2026-10-10 10:01:58 +00:00
|
|
|
|
2026-10-03 11:13:15 +00:00
|
|
|
export const ContactSchema = PersonSchema;
|
2026-10-10 10:01:58 +00:00
|
|
|
|
2026-10-03 10:36:03 +00:00
|
|
|
export type ContactDTO = z.infer<typeof ContactSchema>;
|
2026-10-10 10:01:58 +00:00
|
|
|
|
2026-10-03 10:36:03 +00:00
|
|
|
export const SiteSchema = SiteFieldsSchema.extend({ id: z.uuid(), companyId: z.uuid() });
|
2026-10-10 10:01:58 +00:00
|
|
|
|
2026-10-03 10:36:03 +00:00
|
|
|
export type SiteDTO = z.infer<typeof SiteSchema>;
|
2026-10-10 10:01:58 +00:00
|
|
|
|
2026-10-03 10:36:03 +00:00
|
|
|
export const CompanySchema = CompanySummarySchema.extend({
|
|
|
|
|
contacts: z.array(ContactSchema),
|
|
|
|
|
sites: z.array(SiteSchema),
|
2026-10-03 11:13:15 +00:00
|
|
|
people: z.array(PersonSchema),
|
|
|
|
|
departments: z.array(DepartmentSchema),
|
|
|
|
|
assignments: z.array(DepartmentAssignmentSchema),
|
2026-10-03 10:36:03 +00:00
|
|
|
});
|
2026-10-10 10:01:58 +00:00
|
|
|
|
2026-10-03 10:36:03 +00:00
|
|
|
export type CompanyDTO = z.infer<typeof CompanySchema>;
|