metis-desk/modules/companies/src/common/intervention-templates.ts

42 lines
1.3 KiB
TypeScript
Raw Normal View History

2026-10-07 11:03:01 +00:00
import { z } from "zod/v4";
import { InterventionTemplateInputSchema } from "../api/domain/intervention-template-values";
export type {
InterventionStepInput,
InterventionTemplateInput,
} from "../api/domain/intervention-template-values";
export {
InterventionStepInputSchema,
InterventionTemplateInputSchema,
} from "../api/domain/intervention-template-values";
export const SaveInterventionTemplateSchema = z.strictObject({
values: InterventionTemplateInputSchema,
requestKey: z.uuid(),
expectedRevisionId: z.uuid().nullable(),
});
export const InterventionTemplateSchema = z.strictObject({
id: z.uuid(),
companyId: z.uuid().nullable(),
values: InterventionTemplateInputSchema,
history: z
.array(
z.strictObject({
id: z.uuid(),
values: InterventionTemplateInputSchema,
actorId: z.uuid().nullable(),
actorName: z.string().min(1),
recordedAt: z.iso.datetime(),
})
)
.min(1),
});
export const InterventionTemplatesSchema = z.strictObject({
templates: z.array(InterventionTemplateSchema),
});
export const InterventionTemplateResponseSchema = z.strictObject({
template: InterventionTemplateSchema,
});
export type InterventionTemplateDTO = z.infer<typeof InterventionTemplateSchema>;
export type SaveInterventionTemplateInput = z.infer<typeof SaveInterventionTemplateSchema>;