| 1 | import { z } from 'zod' |
| 2 | |
| 3 | import { |
| 4 | MaterialStatus, |
| 5 | MaterialType, |
| 6 | MediaType, |
| 7 | PubStatus, |
| 8 | PubType, |
| 9 | } from '../enums' |
| 10 | |
| 11 | // --------------------------------------------------------------------------- |
| 12 | // PubRecord |
| 13 | // --------------------------------------------------------------------------- |
| 14 | |
| 15 | export const PubRecordSchema = z.object({ |
| 16 | id: z.string().describe('记录 ID'), |
| 17 | userId: z.string().describe('用户 ID'), |
| 18 | accountId: z.string().describe('账号 ID'), |
| 19 | commonCoverPath: z.string().optional().describe('通用封面路径'), |
| 20 | coverPath: z.string().optional().describe('封面路径'), |
| 21 | desc: z.string().describe('描述'), |
| 22 | publishTime: z.coerce.date().optional().describe('发布时间'), |
| 23 | status: z.enum(PubStatus).describe('发布状态'), |
| 24 | timingTime: z.coerce.date().optional().describe('定时时间'), |
| 25 | title: z.string().describe('标题'), |
| 26 | type: z.enum(PubType).describe('发布类型'), |
| 27 | videoPath: z.string().optional().describe('视频路径'), |
| 28 | }) |
| 29 | export interface PubRecord extends z.infer<typeof PubRecordSchema> {} |
| 30 | |
| 31 | // --------------------------------------------------------------------------- |
| 32 | // MaterialMedia |
| 33 | // --------------------------------------------------------------------------- |
| 34 | |
| 35 | export const MaterialMediaSchema = z.object({ |
| 36 | url: z.string().describe('媒体 URL'), |
| 37 | type: z.enum(MediaType).describe('媒体类型'), |
| 38 | thumbUrl: z.string().optional().describe('缩略图 URL'), |
| 39 | content: z.string().optional().describe('内容'), |
| 40 | }) |
| 41 | export interface MaterialMedia extends z.infer<typeof MaterialMediaSchema> {} |
| 42 | |
| 43 | // --------------------------------------------------------------------------- |
| 44 | // Material |
| 45 | // --------------------------------------------------------------------------- |
| 46 | |
| 47 | export const MaterialSchema = z.object({ |
| 48 | id: z.string().describe('素材 ID'), |
| 49 | userId: z.string().describe('用户 ID'), |
| 50 | groupId: z.string().optional().describe('分组 ID'), |
| 51 | type: z.enum(MaterialType).describe('素材类型'), |
| 52 | coverUrl: z.string().optional().describe('封面 URL'), |
| 53 | mediaList: z.array(MaterialMediaSchema).describe('媒体列表'), |
| 54 | title: z.string().describe('标题'), |
| 55 | desc: z.string().describe('描述'), |
| 56 | status: z.enum(MaterialStatus).describe('素材状态'), |
| 57 | option: z.record(z.string(), z.any()).describe('额外选项'), |
| 58 | useCount: z.number().optional().describe('使用次数'), |
| 59 | model: z.string().optional().describe('AI 生成模型'), |
| 60 | generationParams: z.record(z.string(), z.any()).optional().describe('AI 生成参数(prompt、aspectRatio、duration 等)'), |
| 61 | createAt: z.coerce.date().describe('创建时间'), |
| 62 | updatedAt: z.coerce.date().describe('更新时间'), |
| 63 | }) |
| 64 | export interface Material extends z.infer<typeof MaterialSchema> {} |
| 65 | |
| 66 | // --------------------------------------------------------------------------- |
| 67 | // NewMaterial |
| 68 | // --------------------------------------------------------------------------- |
| 69 | |
| 70 | export const NewMaterialSchema = z.object({ |
| 71 | groupId: z.string().describe('分组 ID'), |
| 72 | coverUrl: z.string().optional().describe('封面 URL'), |
| 73 | mediaList: z.array(MaterialMediaSchema).describe('媒体列表'), |
| 74 | title: z.string().describe('标题'), |
| 75 | desc: z.string().optional().describe('描述'), |
| 76 | location: z.array(z.number()).optional().describe('位置坐标'), |
| 77 | option: z.record(z.string(), z.any()).optional().describe('额外选项'), |
| 78 | }) |
| 79 | export interface NewMaterial extends z.infer<typeof NewMaterialSchema> {} |
| 80 | |
| 81 | // --------------------------------------------------------------------------- |
| 82 | // UpMaterial |
| 83 | // --------------------------------------------------------------------------- |
| 84 | |
| 85 | export const UpMaterialSchema = z.object({ |
| 86 | title: z.string().optional().describe('标题'), |
| 87 | desc: z.string().optional().describe('描述'), |
| 88 | option: z.record(z.string(), z.any()).optional().describe('额外选项'), |
| 89 | }) |
| 90 | export interface UpMaterial extends z.infer<typeof UpMaterialSchema> {} |
| 91 | |
| 92 | // --------------------------------------------------------------------------- |
| 93 | // MaterialFilter |
| 94 | // --------------------------------------------------------------------------- |
| 95 | |
| 96 | export const MaterialFilterSchema = z.object({ |
| 97 | userId: z.string().describe('用户 ID'), |
| 98 | title: z.string().optional().describe('标题筛选'), |
| 99 | groupId: z.string().optional().describe('分组 ID 筛选'), |
| 100 | }) |
| 101 | export interface MaterialFilter extends z.infer<typeof MaterialFilterSchema> {} |
| 102 | |
| 103 | // --------------------------------------------------------------------------- |
| 104 | // MaterialGroup |
| 105 | // --------------------------------------------------------------------------- |
| 106 | |
| 107 | export const MaterialGroupSchema = z.object({ |
| 108 | id: z.string().describe('分组 ID'), |
| 109 | userId: z.string().describe('用户 ID'), |
| 110 | userType: z.string().optional().describe('用户类型'), |
| 111 | title: z.string().describe('标题'), |
| 112 | desc: z.string().optional().describe('描述'), |
| 113 | platform: z.string().optional().describe('平台'), |
| 114 | createAt: z.coerce.date().describe('创建时间'), |
| 115 | updatedAt: z.coerce.date().describe('更新时间'), |
| 116 | }) |
| 117 | export interface MaterialGroup extends z.infer<typeof MaterialGroupSchema> {} |
| 118 | |
| 119 | // --------------------------------------------------------------------------- |
| 120 | // Media |
| 121 | // --------------------------------------------------------------------------- |
| 122 | |
| 123 | export const MediaSchema = z.object({ |
| 124 | id: z.string().describe('媒体 ID'), |
| 125 | userId: z.string().describe('用户 ID'), |
| 126 | userType: z.string().optional().describe('用户类型'), |
| 127 | groupId: z.string().optional().describe('分组 ID'), |
| 128 | materialId: z.string().optional().describe('素材 ID'), |
| 129 | type: z.enum(MaterialType).describe('素材类型'), |
| 130 | url: z.string().describe('URL'), |
| 131 | title: z.string().optional().describe('标题'), |
| 132 | desc: z.string().optional().describe('描述'), |
| 133 | createAt: z.coerce.date().describe('创建时间'), |
| 134 | updatedAt: z.coerce.date().describe('更新时间'), |
| 135 | }) |
| 136 | export interface Media extends z.infer<typeof MediaSchema> {} |
| 137 | |
| 138 | // --------------------------------------------------------------------------- |
| 139 | // NewMedia |
| 140 | // --------------------------------------------------------------------------- |
| 141 | |
| 142 | export const NewMediaSchema = z.object({ |
| 143 | userId: z.string().describe('用户 ID'), |
| 144 | userType: z.string().optional().describe('用户类型'), |
| 145 | groupId: z.string().optional().describe('分组 ID'), |
| 146 | materialId: z.string().optional().describe('素材 ID'), |
| 147 | type: z.enum(MediaType).describe('媒体类型'), |
| 148 | url: z.string().describe('URL'), |
| 149 | thumbUrl: z.string().optional().describe('缩略图 URL'), |
| 150 | title: z.string().optional().describe('标题'), |
| 151 | desc: z.string().optional().describe('描述'), |
| 152 | }) |
| 153 | export interface NewMedia extends z.infer<typeof NewMediaSchema> {} |
| 154 | |
| 155 | // --------------------------------------------------------------------------- |
| 156 | // MediaGroup |
| 157 | // --------------------------------------------------------------------------- |
| 158 | |
| 159 | export const MediaGroupSchema = z.object({ |
| 160 | _id: z.string().describe('MongoDB _id'), |
| 161 | id: z.string().describe('分组 ID'), |
| 162 | userId: z.string().describe('用户 ID'), |
| 163 | title: z.string().describe('标题'), |
| 164 | desc: z.string().optional().describe('描述'), |
| 165 | createAt: z.coerce.date().describe('创建时间'), |
| 166 | updatedAt: z.coerce.date().describe('更新时间'), |
| 167 | mediaList: z |
| 168 | .object({ |
| 169 | list: z.array(MediaSchema).describe('媒体列表'), |
| 170 | total: z.number().describe('总数'), |
| 171 | }) |
| 172 | .optional() |
| 173 | .describe('媒体列表信息'), |
| 174 | }) |
| 175 | export interface MediaGroup extends z.infer<typeof MediaGroupSchema> {} |
| 176 | |
| 177 | // --------------------------------------------------------------------------- |
| 178 | // NewMaterialGroup |
| 179 | // --------------------------------------------------------------------------- |
| 180 | |
| 181 | export const NewMaterialGroupSchema = z.object({ |
| 182 | type: z.enum(MaterialType).describe('素材类型'), |
| 183 | userId: z.string().describe('用户 ID'), |
| 184 | userType: z.string().optional().describe('用户类型'), |
| 185 | name: z.string().describe('分组名称'), |
| 186 | desc: z.string().optional().describe('描述'), |
| 187 | platform: z.string().optional().describe('平台'), |
| 188 | }) |
| 189 | export interface NewMaterialGroup extends z.infer<typeof NewMaterialGroupSchema> {} |
| 190 | |
| 191 | // --------------------------------------------------------------------------- |
| 192 | // UpdateMaterialGroup |
| 193 | // --------------------------------------------------------------------------- |
| 194 | |
| 195 | export const UpdateMaterialGroupSchema = z.object({ |
| 196 | name: z.string().describe('分组名称'), |
| 197 | desc: z.string().optional().describe('描述'), |
| 198 | platform: z.string().nullable().optional().describe('平台'), |
| 199 | }) |
| 200 | export interface UpdateMaterialGroup extends z.infer<typeof UpdateMaterialGroupSchema> {} |
| 201 |