refactor(dtos): use @shumai/db/enums across DTO definitions

This commit is contained in:
yiling
2026-08-01 10:47:41 +08:00
parent 11fc76e56b
commit 7dfb2c7f2f
5 changed files with 18 additions and 8 deletions
+3 -2
View File
@@ -1,7 +1,8 @@
import { z } from 'zod'
import { AgentType } from '@shumai/db/enums'
export const agentTypeSchema = z.enum(['chat', 'autofill', 'embedding'])
export type AgentType = z.infer<typeof agentTypeSchema>
export { AgentType }
export const agentTypeSchema = z.nativeEnum(AgentType)
export const thinkingLevelSchema = z.enum(['off', 'minimal', 'low', 'medium', 'high', 'xhigh'])
export type ThinkingLevel = z.infer<typeof thinkingLevelSchema>
+6 -3
View File
@@ -1,8 +1,11 @@
import { z } from 'zod'
import { InviteRole } from '@shumai/db/enums'
export { InviteRole }
export const inviteInfoSchema = z.object({
code: z.string(),
role: z.enum(['editor', 'reviewer', 'owner']),
role: z.string(),
teamId: z.string(),
teamName: z.string(),
projectId: z.string().optional(),
@@ -14,13 +17,13 @@ export const inviteInfoSchema = z.object({
export type InviteInfo = z.infer<typeof inviteInfoSchema>
export const createTeamInviteRequestSchema = z.object({
role: z.enum(['editor', 'reviewer']),
role: z.nativeEnum(InviteRole),
})
export type CreateTeamInviteRequest = z.infer<typeof createTeamInviteRequestSchema>
export const createProjectInviteRequestSchema = z.object({
role: z.enum(['editor', 'reviewer']),
role: z.nativeEnum(InviteRole),
})
export type CreateProjectInviteRequest = z.infer<typeof createProjectInviteRequestSchema>
+3
View File
@@ -1,4 +1,7 @@
import { z } from 'zod'
import { MetadataFieldScope } from '@shumai/db/enums'
export { MetadataFieldScope }
export const FieldType = {
text: 'text',
+1 -1
View File
@@ -1,5 +1,5 @@
import { z } from 'zod'
import type { NotificationType } from '@shumai/db'
import type { NotificationType } from '@shumai/db/enums'
export const teamUserInfoSchema = z.object({
id: z.string().optional(),
+5 -2
View File
@@ -1,6 +1,9 @@
import { z } from 'zod'
import { UserType, TeamMemberScope } from '@shumai/db/enums'
import { paginationPageInfoSchema, paginationParamsSchema } from './pagination'
export { UserType, TeamMemberScope }
export const createTeamRequestSchema = z.object({
name: z.string(),
})
@@ -50,9 +53,9 @@ export const userInfoSchema = z.object({
name: z.string(),
role: z.enum(['owner', 'editor', 'reviewer', 'bot', 'unknown']),
email: z.string().optional(),
type: z.enum(['human', 'agent']).optional(),
type: z.nativeEnum(UserType).optional(),
image: z.string().optional(),
scope: z.enum(['team', 'project']).optional(),
scope: z.nativeEnum(TeamMemberScope).optional(),
})
export type UserInfo = z.infer<typeof userInfoSchema>