feat(audit): add audit log support for APIs and WebUI dashboard

This commit is contained in:
yiling
2026-08-01 10:39:31 +08:00
parent 7a83f7d406
commit 118107ebc9
58 changed files with 4298 additions and 23 deletions
+43
View File
@@ -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>
+1
View File
@@ -19,3 +19,4 @@ export * from './upload'
export * from './user-metadata'
export * from './versionStack'
export * from './chat'
export * from './auditLog'