metis-desk/modules/companies/src/common/tickets.ts
2026-10-07 11:41:56 +02:00

55 lines
1.7 KiB
TypeScript

import { z } from "zod/v4";
import {
TicketChannelSchema,
TicketInputSchema,
TicketPrioritySchema,
TicketStateSchema,
} from "../api/domain/ticket-values";
export type { TicketInput, TicketTargetInput } from "../api/domain/ticket-values";
export { TicketChannelSchema, TicketInputSchema, TicketPrioritySchema, TicketStateSchema };
export const SaveTicketSchema = z.strictObject({
values: TicketInputSchema,
requestKey: z.uuid(),
expectedRevisionId: z.uuid().nullable(),
});
export type SaveTicketInput = z.infer<typeof SaveTicketSchema>;
export const TicketSchema = z.strictObject({
id: z.uuid(),
companyId: z.uuid(),
companyName: z.string(),
reference: z.string(),
values: TicketInputSchema,
requesterName: z.string().nullable(),
assigneeName: z.string().nullable(),
history: z
.array(
z.strictObject({
id: z.uuid(),
values: TicketInputSchema,
actorId: z.uuid(),
actorName: z.string(),
recordedAt: z.iso.datetime(),
})
)
.min(1),
});
const OptionSchema = z.strictObject({ id: z.uuid(), name: z.string(), active: z.boolean() });
export const TicketListSchema = z.strictObject({
tickets: z.array(TicketSchema),
companies: z.array(OptionSchema),
technicians: z.array(OptionSchema),
});
export const TicketResponseSchema = z.strictObject({ ticket: TicketSchema });
export const TicketLookupsSchema = z.strictObject({
people: z.array(OptionSchema),
assets: z.array(OptionSchema),
resources: z.array(OptionSchema),
workstations: z.array(OptionSchema),
});
export type TicketDTO = z.infer<typeof TicketSchema>;
export type TicketListDTO = z.infer<typeof TicketListSchema>;
export type TicketLookupsDTO = z.infer<typeof TicketLookupsSchema>;