add log for endpoints

This commit is contained in:
Peter Maquiran
2024-06-17 17:04:42 +01:00
parent 58eee3ff93
commit 157ecdd10b
10 changed files with 123 additions and 42 deletions
@@ -1,4 +1,5 @@
import { z } from 'zod';
import { EAttendeeType, EEventCategory, EEventOwnerType, EEventStatus, EEventType } from './enums';
export const AttachmentInputDTOSchema = z.object({
id: z.string().nullable(),
@@ -7,7 +8,7 @@ export const AttachmentInputDTOSchema = z.object({
description: z.string().nullable(),
applicationId: z.number().int(),
}).strict();
const EAttendeeTypeDTO = z.enum(["Required", "Acknowledgment", "Optional"]);
const EAttendeeTypeDTO = z.nativeEnum(EAttendeeType);
const CommentSchema = z.object({
@@ -18,7 +19,7 @@ const CommentSchema = z.object({
const AttendeeSchema = z.object({
id: z.string(),
name: z.string(),
attendeeType: z.enum(["Required", "Acknowledgment", "Optional"]), // ["Required", "Acknowledgment", "Optional"] = [1,2,3]
attendeeType: z.nativeEnum(EAttendeeType), // ["Required", "Acknowledgment", "Optional"] = [1,2,3]
emailAddress: z.string(),
wxUserId: z.number(),
});
@@ -47,27 +48,32 @@ const EventRecurrenceSchema = z.object({
until: z.string()
});
export const EventOutputDTOSchema = z.object({
id: z.string(),
owner: OwnerSchema,
ownerType: z.number(), // ["PR", "MD", "Other"] = [1,2,3],
subject: z.string(),
body: z.string(),
location: z.string(),
startDate: z.string(),
endDate: z.string(),
type: z.string(),
category: z.number(), // ['Oficial', 'Pessoal'] = [1, 2]
attendees: z.array(AttendeeSchema),
isRecurring: z.boolean(),
eventRecurrence: EventRecurrenceSchema,
hasAttachments: z.boolean(),
attachments: z.array(AttachmentInputDTOSchema),
comments: z.array(CommentSchema),
isPrivate: z.boolean(),
isAllDayEvent: z.boolean(),
organizer: OrganizerSchema,
status: z.number(), // ['Pending', 'Revision', 'Approved', 'Declined', 'Communicated', 'ToCommunicate'] = [1, 2, 3, 4, 5, 6]
});
success: z.boolean(),
message: z.string(),
data: z.object({
id: z.string(),
owner: OwnerSchema,
ownerType: z.nativeEnum(EEventOwnerType), // ["PR", "MD", "Other"] = [1,2,3],
subject: z.string(),
body: z.string(),
location: z.string(),
startDate: z.string(),
endDate: z.string(),
type: z.nativeEnum(EEventType),
category: z.nativeEnum(EEventCategory), // ['Oficial', 'Pessoal'] = [1, 2]
attendees: z.array(AttendeeSchema),
isRecurring: z.boolean(),
eventRecurrence: EventRecurrenceSchema,
hasAttachments: z.boolean(),
attachments: z.array(AttachmentInputDTOSchema),
comments: z.array(CommentSchema),
isPrivate: z.boolean(),
isAllDayEvent: z.boolean(),
organizer: OrganizerSchema,
status: z.nativeEnum(EEventStatus), // ['Pending', 'Revision', 'Approved', 'Declined', 'Communicated', 'ToCommunicate'] = [1, 2, 3, 4, 5, 6]
}),
}).nullable();
export type EventOutputDTO = z.infer<typeof EventOutputDTOSchema>
@@ -1,15 +1,24 @@
import { z } from "zod";
import { EEventOwnerType, EEventType, EEventCategory, EEventStatus } from "./enums";
const OwnerSchema = z.object({
wxUserId: z.number(),
wxFullName: z.string(),
wxeMail: z.string(),
userPhoto: z.string(),
});
const EventToApproveList = z.array(z.object({
id: z.string().uuid(),
owner: z.string().nullable(),
owner: OwnerSchema,
ownerType: z.nativeEnum(EEventOwnerType),
subject: z.string(),
body: z.string(),
location: z.string().nullable(),
startDate: z.string().datetime(),
endDate: z.string().datetime(),
startDate: z.string().datetime({ offset: true }),
endDate: z.string().datetime({ offset: true }),
type: z.nativeEnum(EEventType),
category: z.nativeEnum(EEventCategory),
isRecurring: z.boolean(),