mirror of
https://github.com/shumaiOne/shumai.git
synced 2026-12-02 14:04:50 +00:00
feat(audit): add audit log support for APIs and WebUI dashboard
This commit is contained in:
@@ -0,0 +1,43 @@
|
||||
import { z } from 'zod'
|
||||
import { AuditAction } from '@shumai/db'
|
||||
|
||||
export { AuditAction }
|
||||
|
||||
export const auditLogSchema = z.object({
|
||||
id: z.string(),
|
||||
action: z.nativeEnum(AuditAction),
|
||||
teamId: z.string(),
|
||||
userId: z.string().nullable().optional(),
|
||||
projectId: z.string().nullable().optional(),
|
||||
itemId: z.string().nullable().optional(),
|
||||
createdAt: z.string(),
|
||||
})
|
||||
|
||||
export type AuditLog = z.infer<typeof auditLogSchema>
|
||||
|
||||
export const listAuditLogsQuerySchema = z.object({
|
||||
first: z.coerce.number().optional(),
|
||||
after: z.string().optional(),
|
||||
actions: z
|
||||
.union([z.nativeEnum(AuditAction), z.array(z.nativeEnum(AuditAction))])
|
||||
.transform((val) => (Array.isArray(val) ? val : [val]))
|
||||
.optional(),
|
||||
userIds: z
|
||||
.union([z.string(), z.array(z.string())])
|
||||
.transform((val) => (Array.isArray(val) ? val : [val]))
|
||||
.optional(),
|
||||
itemId: z.string().optional(),
|
||||
})
|
||||
|
||||
export type ListAuditLogsQuery = z.infer<typeof listAuditLogsQuerySchema>
|
||||
|
||||
export const listAuditLogsResponseSchema = z.object({
|
||||
nodes: z.array(auditLogSchema),
|
||||
pageInfo: z.object({
|
||||
hasNextPage: z.boolean(),
|
||||
endCursor: z.string().nullable(),
|
||||
}),
|
||||
total: z.number(),
|
||||
})
|
||||
|
||||
export type ListAuditLogsResponse = z.infer<typeof listAuditLogsResponseSchema>
|
||||
@@ -19,3 +19,4 @@ export * from './upload'
|
||||
export * from './user-metadata'
|
||||
export * from './versionStack'
|
||||
export * from './chat'
|
||||
export * from './auditLog'
|
||||
|
||||
Reference in New Issue
Block a user