* fix: refactor to accommodate authentication, transaction and pagination together into ctx.state * feat: allow passing response type to APIContext * feat: preliminary work for initial review * fix: use unknown for base types * fix: api/attachments * fix: api/documents * fix: jsdoc comment for input * fix: replace at() with index access for compatibility * fix: validation err message * fix: error handling * fix: remove unnecessary extend
36 lines
1009 B
TypeScript
36 lines
1009 B
TypeScript
import { z } from "zod";
|
|
import BaseSchema from "@server/routes/api/BaseSchema";
|
|
|
|
export const EventsListSchema = BaseSchema.extend({
|
|
body: z.object({
|
|
/** Id of the user who performed the action */
|
|
actorId: z.string().uuid().optional(),
|
|
|
|
/** Id of the document to filter the events for */
|
|
documentId: z.string().uuid().optional(),
|
|
|
|
/** Id of the collection to filter the events for */
|
|
collectionId: z.string().uuid().optional(),
|
|
|
|
/** Whether to include audit events */
|
|
auditLog: z.boolean().default(false),
|
|
|
|
/** Name of the event to retrieve */
|
|
name: z.string().optional(),
|
|
|
|
/** The attribute to sort the events by */
|
|
sort: z
|
|
.string()
|
|
.refine((val) => ["name", "createdAt"].includes(val))
|
|
.default("createdAt"),
|
|
|
|
/** The direction to sort the events */
|
|
direction: z
|
|
.string()
|
|
.optional()
|
|
.transform((val) => (val !== "ASC" ? "DESC" : val)),
|
|
}),
|
|
});
|
|
|
|
export type EventsListReq = z.infer<typeof EventsListSchema>;
|