mirror of
https://github.com/shumaiOne/shumai.git
synced 2026-11-25 11:48:43 +00:00
refactor(dtos): define AuditAction enum in dtos package to decouple from db
This commit is contained in:
@@ -9,10 +9,11 @@ import {
|
||||
paginationParamsSchema,
|
||||
AgentInfo,
|
||||
AgentType,
|
||||
AuditAction,
|
||||
} from '@shumai/dtos'
|
||||
|
||||
import type { Prisma } from '@shumai/db'
|
||||
import { prisma, AuditAction } from '@shumai/db'
|
||||
import { prisma } from '@shumai/db'
|
||||
import { auditLogService } from '@shumai/core/src/auditLog/auditLog'
|
||||
|
||||
type User = Prisma.UserGetPayload<Record<string, never>>
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
import { Hono } from 'hono'
|
||||
import { zValidator } from '@hono/zod-validator'
|
||||
import { postAttachmentRequestSchema } from '@shumai/dtos'
|
||||
import { postAttachmentRequestSchema, AuditAction } from '@shumai/dtos'
|
||||
import { assetService } from '@shumai/core/src/asset/asset'
|
||||
import { s3Service } from '@shumai/core/src/s3/s3'
|
||||
import { auditLogService } from '@shumai/core/src/auditLog/auditLog'
|
||||
import { AssetType, AuditAction, prisma } from '@shumai/db'
|
||||
import { AssetType, prisma } from '@shumai/db'
|
||||
import { ulid } from 'ulid'
|
||||
import { authzService, Permission, ResourceType } from '@shumai/core/src/authz/authz'
|
||||
import type { Prisma } from '@shumai/db'
|
||||
|
||||
@@ -5,7 +5,7 @@ import { metadataService } from '@shumai/core/src/metadata/metadata'
|
||||
import { notificationService } from '@shumai/core/src/notification/notification'
|
||||
import { s3Service } from '@shumai/core/src/s3/s3'
|
||||
import type { Prisma } from '@shumai/db'
|
||||
import { prisma, AuditAction } from '@shumai/db'
|
||||
import { prisma } from '@shumai/db'
|
||||
import { auditLogService } from '@shumai/core/src/auditLog/auditLog'
|
||||
import {
|
||||
createCommentRequestSchema,
|
||||
@@ -18,6 +18,7 @@ import {
|
||||
uploadFileRequestSchema,
|
||||
getDownloadLinksRequestSchema,
|
||||
completeCommentRequestSchema,
|
||||
AuditAction,
|
||||
} from '@shumai/dtos'
|
||||
import { transcodeService } from '@shumai/core'
|
||||
import fs from 'fs'
|
||||
|
||||
@@ -9,10 +9,9 @@ import {
|
||||
deleteFoldersRequestSchema,
|
||||
restoreFoldersRequestSchema,
|
||||
} from '@shumai/dtos'
|
||||
import { listChildrenRequestSchema, updateAssetOrderRequestSchema } from '@shumai/dtos'
|
||||
import { listChildrenRequestSchema, updateAssetOrderRequestSchema, AuditAction } from '@shumai/dtos'
|
||||
import { searchRequestSchema } from '@shumai/dtos'
|
||||
import type { Prisma } from '@shumai/db'
|
||||
import { AuditAction } from '@shumai/db'
|
||||
import { auditLogService } from '@shumai/core/src/auditLog/auditLog'
|
||||
|
||||
type User = Prisma.UserGetPayload<Record<string, never>>
|
||||
|
||||
@@ -5,11 +5,12 @@ import {
|
||||
createTeamInviteRequestSchema,
|
||||
joinRequestSchema,
|
||||
InviteInfo,
|
||||
AuditAction,
|
||||
} from '@shumai/dtos'
|
||||
import { authzService, Permission, ResourceType } from '@shumai/core/src/authz/authz'
|
||||
import { inviteService } from '@shumai/core/src/invite/invite'
|
||||
import { notificationService } from '@shumai/core/src/notification/notification'
|
||||
import { NotificationType, AuditAction } from '@shumai/db'
|
||||
import { NotificationType } from '@shumai/db'
|
||||
import type { Prisma } from '@shumai/db'
|
||||
import { auditLogService } from '@shumai/core/src/auditLog/auditLog'
|
||||
|
||||
|
||||
@@ -7,9 +7,10 @@ import {
|
||||
updateFieldRequestSchema,
|
||||
updateProjectFieldsOrderRequestSchema,
|
||||
FieldInfo,
|
||||
AuditAction,
|
||||
} from '@shumai/dtos'
|
||||
import type { Prisma } from '@shumai/db'
|
||||
import { prisma, AuditAction } from '@shumai/db'
|
||||
import { prisma } from '@shumai/db'
|
||||
import { auditLogService } from '@shumai/core/src/auditLog/auditLog'
|
||||
|
||||
type User = Prisma.UserGetPayload<Record<string, never>>
|
||||
|
||||
@@ -12,9 +12,9 @@ import {
|
||||
updateProjectMemberRoleRequestSchema,
|
||||
addProjectMemberRequestSchema,
|
||||
} from '@shumai/dtos'
|
||||
import { listMembersQuerySchema, paginationParamsSchema } from '@shumai/dtos'
|
||||
import { listMembersQuerySchema, paginationParamsSchema, AuditAction } from '@shumai/dtos'
|
||||
import type { Prisma } from '@shumai/db'
|
||||
import { prisma, AuditAction } from '@shumai/db'
|
||||
import { prisma } from '@shumai/db'
|
||||
import { auditLogService } from '@shumai/core/src/auditLog/auditLog'
|
||||
|
||||
type User = Prisma.UserGetPayload<Record<string, never>>
|
||||
|
||||
@@ -2,8 +2,7 @@ import { zValidator } from '@hono/zod-validator'
|
||||
import { Hono } from 'hono'
|
||||
import { authzService, Permission, ResourceType } from '@shumai/core/src/authz/authz'
|
||||
import { providerService } from '@shumai/core/src/provider/provider'
|
||||
import { createProviderRequestSchema, updateProviderRequestSchema } from '@shumai/dtos'
|
||||
import { AuditAction } from '@shumai/db'
|
||||
import { createProviderRequestSchema, updateProviderRequestSchema, AuditAction } from '@shumai/dtos'
|
||||
import type { Prisma } from '@shumai/db'
|
||||
import { auditLogService } from '@shumai/core/src/auditLog/auditLog'
|
||||
|
||||
|
||||
@@ -7,9 +7,10 @@ import {
|
||||
updateShareLinkRequestSchema,
|
||||
listShareLinksRequestSchema,
|
||||
addAssetToShareRequestSchema,
|
||||
AuditAction,
|
||||
} from '@shumai/dtos'
|
||||
import type { Prisma } from '@shumai/db'
|
||||
import { prisma, AuditAction } from '@shumai/db'
|
||||
import { prisma } from '@shumai/db'
|
||||
import { auditLogService } from '@shumai/core/src/auditLog/auditLog'
|
||||
|
||||
type User = Prisma.UserGetPayload<Record<string, never>>
|
||||
|
||||
@@ -6,9 +6,10 @@ import {
|
||||
upsertSkillRequestSchema,
|
||||
updateSkillConfigRequestSchema,
|
||||
updateSkillPermissionRequestSchema,
|
||||
AuditAction,
|
||||
} from '@shumai/dtos'
|
||||
import type { Prisma } from '@shumai/db'
|
||||
import { prisma, AuditAction } from '@shumai/db'
|
||||
import { prisma } from '@shumai/db'
|
||||
import { auditLogService } from '@shumai/core/src/auditLog/auditLog'
|
||||
|
||||
type User = Prisma.UserGetPayload<Record<string, never>>
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { describe, expect, it, vi, beforeEach, afterEach } from 'vitest'
|
||||
import { Hono } from 'hono'
|
||||
import { AuditAction } from '@shumai/db'
|
||||
import { AuditAction } from '@shumai/dtos'
|
||||
import teamRoute from './team'
|
||||
import { authMiddleware } from './middleware/auth'
|
||||
import { teamService } from '@shumai/core/src/team/team'
|
||||
|
||||
@@ -15,11 +15,15 @@ import {
|
||||
createApiTokenRequestSchema,
|
||||
listAuditLogsQuerySchema,
|
||||
} from '@shumai/dtos'
|
||||
import { updateUserMetadataRequestSchema, getTeamAiUsageQuerySchema } from '@shumai/dtos'
|
||||
import {
|
||||
updateUserMetadataRequestSchema,
|
||||
getTeamAiUsageQuerySchema,
|
||||
AuditAction,
|
||||
} from '@shumai/dtos'
|
||||
import { apiTokenService } from '@shumai/core/src/user/api-token'
|
||||
import { aiUsageService } from '@shumai/core/src/ai-usage/ai-usage'
|
||||
import { auditLogService } from '@shumai/core/src/auditLog/auditLog'
|
||||
import { NotificationType, AuditAction } from '@shumai/db'
|
||||
import { NotificationType } from '@shumai/db'
|
||||
import type { Prisma } from '@shumai/db'
|
||||
|
||||
type User = Prisma.UserGetPayload<Record<string, never>>
|
||||
|
||||
@@ -6,12 +6,12 @@ import {
|
||||
createUploadTaskRequestSchema,
|
||||
localUploadQuerySchema,
|
||||
} from '@shumai/dtos'
|
||||
import { paginationParamsSchema } from '@shumai/dtos'
|
||||
import { paginationParamsSchema, AuditAction } from '@shumai/dtos'
|
||||
import { authzService, Permission, ResourceType } from '@shumai/core/src/authz/authz'
|
||||
import { notificationService } from '@shumai/core/src/notification/notification'
|
||||
import { auditLogService } from '@shumai/core/src/auditLog/auditLog'
|
||||
import { assetService } from '@shumai/core/src/asset/asset'
|
||||
import { NotificationType, AuditAction } from '@shumai/db'
|
||||
import { NotificationType } from '@shumai/db'
|
||||
import { s3Service, verifyLocalUrlSignature } from '@shumai/core/src/s3/s3'
|
||||
import type { Prisma } from '@shumai/db'
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import { describe, it, expect } from 'vitest'
|
||||
import { prisma, AuditAction } from '@shumai/db'
|
||||
import { prisma } from '@shumai/db'
|
||||
import { AuditAction } from '@shumai/dtos'
|
||||
import { setupTestDbHooks } from '@shumai/db/test'
|
||||
import { auditLogService } from './auditLog'
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import { prisma } from '@shumai/db'
|
||||
import type { Prisma, AuditAction } from '@shumai/db'
|
||||
import type { Prisma } from '@shumai/db'
|
||||
import type { AuditAction } from '@shumai/dtos'
|
||||
import { paginateQuery } from '@shumai/core/src/pagination'
|
||||
|
||||
export interface LogActionParams {
|
||||
|
||||
@@ -1,47 +0,0 @@
|
||||
/* eslint-disable @typescript-eslint/naming-convention */
|
||||
export const AuditAction = {
|
||||
team_create: 'team_create',
|
||||
team_update: 'team_update',
|
||||
team_delete: 'team_delete',
|
||||
team_member_add: 'team_member_add',
|
||||
team_member_update: 'team_member_update',
|
||||
team_member_remove: 'team_member_remove',
|
||||
project_create: 'project_create',
|
||||
project_update: 'project_update',
|
||||
project_delete: 'project_delete',
|
||||
project_empty_trash: 'project_empty_trash',
|
||||
project_member_add: 'project_member_add',
|
||||
project_member_update: 'project_member_update',
|
||||
project_member_remove: 'project_member_remove',
|
||||
file_create: 'file_create',
|
||||
file_update: 'file_update',
|
||||
file_delete: 'file_delete',
|
||||
folder_create: 'folder_create',
|
||||
folder_update: 'folder_update',
|
||||
folder_delete: 'folder_delete',
|
||||
asset_reparent: 'asset_reparent',
|
||||
asset_copy: 'asset_copy',
|
||||
share_create: 'share_create',
|
||||
share_update: 'share_update',
|
||||
share_delete: 'share_delete',
|
||||
agent_create: 'agent_create',
|
||||
agent_update: 'agent_update',
|
||||
agent_delete: 'agent_delete',
|
||||
skill_create: 'skill_create',
|
||||
skill_update: 'skill_update',
|
||||
skill_delete: 'skill_delete',
|
||||
provider_create: 'provider_create',
|
||||
provider_update: 'provider_update',
|
||||
provider_delete: 'provider_delete',
|
||||
invite_create: 'invite_create',
|
||||
invite_revoke: 'invite_revoke',
|
||||
metadata_field_create: 'metadata_field_create',
|
||||
metadata_field_update: 'metadata_field_update',
|
||||
metadata_field_delete: 'metadata_field_delete',
|
||||
comment_create: 'comment_create',
|
||||
comment_update: 'comment_update',
|
||||
comment_delete: 'comment_delete',
|
||||
comment_complete: 'comment_complete',
|
||||
} as const
|
||||
|
||||
export type AuditAction = (typeof AuditAction)[keyof typeof AuditAction]
|
||||
@@ -111,4 +111,3 @@ export function getPrismaTestingHelper() {
|
||||
|
||||
export * from './generated/prisma/client'
|
||||
export * from './utils/ngram'
|
||||
export * from './audit'
|
||||
|
||||
@@ -1,7 +1,49 @@
|
||||
import { z } from 'zod'
|
||||
import { AuditAction } from '@shumai/db'
|
||||
|
||||
export { AuditAction }
|
||||
export enum AuditAction {
|
||||
team_create = 'team_create',
|
||||
team_update = 'team_update',
|
||||
team_delete = 'team_delete',
|
||||
team_member_add = 'team_member_add',
|
||||
team_member_update = 'team_member_update',
|
||||
team_member_remove = 'team_member_remove',
|
||||
project_create = 'project_create',
|
||||
project_update = 'project_update',
|
||||
project_delete = 'project_delete',
|
||||
project_empty_trash = 'project_empty_trash',
|
||||
project_member_add = 'project_member_add',
|
||||
project_member_update = 'project_member_update',
|
||||
project_member_remove = 'project_member_remove',
|
||||
file_create = 'file_create',
|
||||
file_update = 'file_update',
|
||||
file_delete = 'file_delete',
|
||||
folder_create = 'folder_create',
|
||||
folder_update = 'folder_update',
|
||||
folder_delete = 'folder_delete',
|
||||
asset_reparent = 'asset_reparent',
|
||||
asset_copy = 'asset_copy',
|
||||
share_create = 'share_create',
|
||||
share_update = 'share_update',
|
||||
share_delete = 'share_delete',
|
||||
agent_create = 'agent_create',
|
||||
agent_update = 'agent_update',
|
||||
agent_delete = 'agent_delete',
|
||||
skill_create = 'skill_create',
|
||||
skill_update = 'skill_update',
|
||||
skill_delete = 'skill_delete',
|
||||
provider_create = 'provider_create',
|
||||
provider_update = 'provider_update',
|
||||
provider_delete = 'provider_delete',
|
||||
invite_create = 'invite_create',
|
||||
invite_revoke = 'invite_revoke',
|
||||
metadata_field_create = 'metadata_field_create',
|
||||
metadata_field_update = 'metadata_field_update',
|
||||
metadata_field_delete = 'metadata_field_delete',
|
||||
comment_create = 'comment_create',
|
||||
comment_update = 'comment_update',
|
||||
comment_delete = 'comment_delete',
|
||||
comment_complete = 'comment_complete',
|
||||
}
|
||||
|
||||
export const auditLogSchema = z.object({
|
||||
id: z.string(),
|
||||
|
||||
Reference in New Issue
Block a user