feat: enforce ticket ownership during work sessions

This commit is contained in:
Esdras Renan 2025-10-20 19:46:20 -03:00
parent 81657e52d8
commit 3972f66c92
6 changed files with 397 additions and 43 deletions

View file

@ -53,11 +53,22 @@ export const ticketSubcategorySummarySchema = z.object({
categoryId: z.string().optional(),
})
export type TicketSubcategorySummary = z.infer<typeof ticketSubcategorySummarySchema>
export const ticketCommentSchema = z.object({
id: z.string(),
author: userSummarySchema,
visibility: commentVisibilitySchema,
export const ticketAgentWorkTotalSchema = z.object({
agentId: z.string(),
agentName: z.string().nullable().optional(),
agentEmail: z.string().nullable().optional(),
avatarUrl: z.string().nullable().optional(),
totalWorkedMs: z.number(),
internalWorkedMs: z.number().optional().default(0),
externalWorkedMs: z.number().optional().default(0),
})
export type TicketAgentWorkTotal = z.infer<typeof ticketAgentWorkTotalSchema>
export const ticketCommentSchema = z.object({
id: z.string(),
author: userSummarySchema,
visibility: commentVisibilitySchema,
body: z.string(),
attachments: z
.array(
@ -144,11 +155,12 @@ export const ticketSchema = z.object({
workType: z.string().optional(),
})
.nullable(),
perAgentTotals: z.array(ticketAgentWorkTotalSchema).optional(),
})
.nullable()
.optional(),
})
export type Ticket = z.infer<typeof ticketSchema>
})
export type Ticket = z.infer<typeof ticketSchema>
export const ticketWithDetailsSchema = ticketSchema.extend({
description: z.string().optional(),