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
+105 -2
View File
@@ -417,7 +417,8 @@ export const ModelName = {
Provider: 'Provider',
Collection: 'Collection',
ApiToken: 'ApiToken',
AiUsage: 'AiUsage'
AiUsage: 'AiUsage',
AuditLog: 'AuditLog'
} as const
export type ModelName = (typeof ModelName)[keyof typeof ModelName]
@@ -433,7 +434,7 @@ export type TypeMap<ExtArgs extends runtime.Types.Extensions.InternalArgs = runt
omit: GlobalOmitOptions
}
meta: {
modelProps: "user" | "session" | "account" | "verification" | "authToken" | "team" | "sandbox" | "skill" | "teamMember" | "project" | "projectMember" | "shareLink" | "asset" | "storageKey" | "assetMetadataValue" | "assetComment" | "assetCommentAttachment" | "assetEmbedding" | "invite" | "metadataField" | "notification" | "systemSettings" | "task" | "workflowTask" | "agent" | "agentSkill" | "agentSession" | "agentSessionEntry" | "userMetadata" | "model" | "provider" | "collection" | "apiToken" | "aiUsage"
modelProps: "user" | "session" | "account" | "verification" | "authToken" | "team" | "sandbox" | "skill" | "teamMember" | "project" | "projectMember" | "shareLink" | "asset" | "storageKey" | "assetMetadataValue" | "assetComment" | "assetCommentAttachment" | "assetEmbedding" | "invite" | "metadataField" | "notification" | "systemSettings" | "task" | "workflowTask" | "agent" | "agentSkill" | "agentSession" | "agentSessionEntry" | "userMetadata" | "model" | "provider" | "collection" | "apiToken" | "aiUsage" | "auditLog"
txIsolationLevel: TransactionIsolationLevel
}
model: {
@@ -2953,6 +2954,80 @@ export type TypeMap<ExtArgs extends runtime.Types.Extensions.InternalArgs = runt
}
}
}
AuditLog: {
payload: Prisma.$AuditLogPayload<ExtArgs>
fields: Prisma.AuditLogFieldRefs
operations: {
findUnique: {
args: Prisma.AuditLogFindUniqueArgs<ExtArgs>
result: runtime.Types.Utils.PayloadToResult<Prisma.$AuditLogPayload> | null
}
findUniqueOrThrow: {
args: Prisma.AuditLogFindUniqueOrThrowArgs<ExtArgs>
result: runtime.Types.Utils.PayloadToResult<Prisma.$AuditLogPayload>
}
findFirst: {
args: Prisma.AuditLogFindFirstArgs<ExtArgs>
result: runtime.Types.Utils.PayloadToResult<Prisma.$AuditLogPayload> | null
}
findFirstOrThrow: {
args: Prisma.AuditLogFindFirstOrThrowArgs<ExtArgs>
result: runtime.Types.Utils.PayloadToResult<Prisma.$AuditLogPayload>
}
findMany: {
args: Prisma.AuditLogFindManyArgs<ExtArgs>
result: runtime.Types.Utils.PayloadToResult<Prisma.$AuditLogPayload>[]
}
create: {
args: Prisma.AuditLogCreateArgs<ExtArgs>
result: runtime.Types.Utils.PayloadToResult<Prisma.$AuditLogPayload>
}
createMany: {
args: Prisma.AuditLogCreateManyArgs<ExtArgs>
result: BatchPayload
}
createManyAndReturn: {
args: Prisma.AuditLogCreateManyAndReturnArgs<ExtArgs>
result: runtime.Types.Utils.PayloadToResult<Prisma.$AuditLogPayload>[]
}
delete: {
args: Prisma.AuditLogDeleteArgs<ExtArgs>
result: runtime.Types.Utils.PayloadToResult<Prisma.$AuditLogPayload>
}
update: {
args: Prisma.AuditLogUpdateArgs<ExtArgs>
result: runtime.Types.Utils.PayloadToResult<Prisma.$AuditLogPayload>
}
deleteMany: {
args: Prisma.AuditLogDeleteManyArgs<ExtArgs>
result: BatchPayload
}
updateMany: {
args: Prisma.AuditLogUpdateManyArgs<ExtArgs>
result: BatchPayload
}
updateManyAndReturn: {
args: Prisma.AuditLogUpdateManyAndReturnArgs<ExtArgs>
result: runtime.Types.Utils.PayloadToResult<Prisma.$AuditLogPayload>[]
}
upsert: {
args: Prisma.AuditLogUpsertArgs<ExtArgs>
result: runtime.Types.Utils.PayloadToResult<Prisma.$AuditLogPayload>
}
aggregate: {
args: Prisma.AuditLogAggregateArgs<ExtArgs>
result: runtime.Types.Utils.Optional<Prisma.AggregateAuditLog>
}
groupBy: {
args: Prisma.AuditLogGroupByArgs<ExtArgs>
result: runtime.Types.Utils.Optional<Prisma.AuditLogGroupByOutputType>[]
}
count: {
args: Prisma.AuditLogCountArgs<ExtArgs>
result: runtime.Types.Utils.Optional<Prisma.AuditLogCountAggregateOutputType> | number
}
}
}
}
} & {
other: {
@@ -3488,6 +3563,19 @@ export const AiUsageScalarFieldEnum = {
export type AiUsageScalarFieldEnum = (typeof AiUsageScalarFieldEnum)[keyof typeof AiUsageScalarFieldEnum]
export const AuditLogScalarFieldEnum = {
id: 'id',
action: 'action',
teamId: 'teamId',
userId: 'userId',
projectId: 'projectId',
itemId: 'itemId',
createdAt: 'createdAt'
} as const
export type AuditLogScalarFieldEnum = (typeof AuditLogScalarFieldEnum)[keyof typeof AuditLogScalarFieldEnum]
export const SortOrder = {
asc: 'asc',
desc: 'desc'
@@ -3856,6 +3944,20 @@ export type EnumAgentSessionTypeFieldRefInput<$PrismaModel> = FieldRefInputType<
export type ListEnumAgentSessionTypeFieldRefInput<$PrismaModel> = FieldRefInputType<$PrismaModel, 'AgentSessionType[]'>
/**
* Reference to a field of type 'AuditAction'
*/
export type EnumAuditActionFieldRefInput<$PrismaModel> = FieldRefInputType<$PrismaModel, 'AuditAction'>
/**
* Reference to a field of type 'AuditAction[]'
*/
export type ListEnumAuditActionFieldRefInput<$PrismaModel> = FieldRefInputType<$PrismaModel, 'AuditAction[]'>
/**
* Batch Payload for updateMany & deleteMany & createMany
*/
@@ -4000,6 +4102,7 @@ export type GlobalOmitConfig = {
collection?: Prisma.CollectionOmit
apiToken?: Prisma.ApiTokenOmit
aiUsage?: Prisma.AiUsageOmit
auditLog?: Prisma.AuditLogOmit
}
/* Types for Logging */