| 1 | import { createZodDto, PaginationDtoSchema, UserType } from '@yikart/common' |
| 2 | import { z } from 'zod' |
| 3 | |
| 4 | const volcengineToolSchema = z.object({ |
| 5 | type: z.literal('web_search'), |
| 6 | }) |
| 7 | |
| 8 | // 通用视频生成请求 |
| 9 | const videoGenerationRequestSchema = z.object({ |
| 10 | model: z.string().min(1).describe('模型名称'), |
| 11 | prompt: z.string().min(1).max(4000).describe('提示词'), |
| 12 | groupId: z.string().optional().describe('素材组 ID,传入后生成成功时保存到该素材组'), |
| 13 | image: z.string().or(z.string().array()).optional().describe('图片URL或base64'), |
| 14 | image_tail: z.string().optional().describe('尾帧图片URL或base64'), |
| 15 | video_url: z.string().optional().describe('视频URL(用于视频编辑模式)'), |
| 16 | images: z.string().array().optional().describe('参考图片URL或base64列表'), |
| 17 | videos: z.string().array().optional().describe('参考视频URL列表'), |
| 18 | audios: z.string().array().optional().describe('参考音频URL或base64列表'), |
| 19 | mode: z.string().optional().describe('生成模式'), |
| 20 | size: z.string().optional().describe('尺寸'), |
| 21 | resolution: z.string().optional().describe('分辨率'), |
| 22 | ratio: z.string().optional().describe('宽高比'), |
| 23 | duration: z.number().optional().describe('时长'), |
| 24 | seed: z.number().int().optional().describe('随机种子'), |
| 25 | watermark: z.boolean().optional().describe('是否带水印'), |
| 26 | tools: z.array(volcengineToolSchema).optional().describe('供应商工具配置'), |
| 27 | metadata: z.record(z.string(), z.unknown()).optional().describe('其他参数'), |
| 28 | }) |
| 29 | |
| 30 | export class VideoGenerationRequestDto extends createZodDto(videoGenerationRequestSchema) {} |
| 31 | |
| 32 | // 通用视频任务状态查询 |
| 33 | const videoTaskQuerySchema = z.object({ |
| 34 | taskId: z.string().min(1).describe('任务ID'), |
| 35 | }) |
| 36 | |
| 37 | export class VideoTaskQueryDto extends createZodDto(videoTaskQuerySchema) {} |
| 38 | |
| 39 | // 通用视频生成请求(内部使用) |
| 40 | const userVideoGenerationRequestSchema = z.object({ |
| 41 | userId: z.string(), |
| 42 | userType: z.enum(UserType), |
| 43 | ...videoGenerationRequestSchema.shape, |
| 44 | }) |
| 45 | |
| 46 | export class UserVideoGenerationRequestDto extends createZodDto(userVideoGenerationRequestSchema) {} |
| 47 | |
| 48 | // 通用视频任务状态查询(内部使用) |
| 49 | const userVideoTaskQuerySchema = z.object({ |
| 50 | userId: z.string(), |
| 51 | userType: z.enum(UserType), |
| 52 | ...videoTaskQuerySchema.shape, |
| 53 | }) |
| 54 | |
| 55 | export class UserVideoTaskQueryDto extends createZodDto(userVideoTaskQuerySchema) {} |
| 56 | |
| 57 | // 视频任务列表查询 |
| 58 | const listVideoTasksQuerySchema = z.object({ |
| 59 | ...PaginationDtoSchema.shape, |
| 60 | }) |
| 61 | |
| 62 | export class ListVideoTasksQueryDto extends createZodDto(listVideoTasksQuerySchema) {} |
| 63 | |
| 64 | // 视频任务列表查询(内部使用) |
| 65 | const userListVideoTasksQuerySchema = z.object({ |
| 66 | userId: z.string(), |
| 67 | userType: z.enum(UserType), |
| 68 | ...listVideoTasksQuerySchema.shape, |
| 69 | }) |
| 70 | |
| 71 | export class UserListVideoTasksQueryDto extends createZodDto(userListVideoTasksQuerySchema) {} |
| 72 | |
| 73 | // 视频生成模型查询DTO |
| 74 | const videoGenerationModelsQuerySchema = z.object({ |
| 75 | userId: z.string().optional().describe('用户ID'), |
| 76 | userType: z.enum(UserType).optional().describe('用户类型'), |
| 77 | }) |
| 78 | |
| 79 | export class VideoGenerationModelsQueryDto extends createZodDto(videoGenerationModelsQuerySchema) {} |
| 80 |