| 1 | import { AccountType, createZodDto } from '@yikart/common' |
| 2 | import { z } from 'zod' |
| 3 | import { ChannelWorkDataSnapshotVoSchema, ChannelWorkMetricsSnapshotVoSchema, ChannelWorkSnapshotVoSchema } from '../analytics/analytics.vo' |
| 4 | import { ChannelPaginationResultVoSchema } from '../platforms/platform-pagination.vo' |
| 5 | import { PublishContentMode } from '../platforms/platforms.interface' |
| 6 | |
| 7 | export const ChannelWorkDataVoSchema = z.object({ |
| 8 | platform: z.enum(AccountType).describe('平台'), |
| 9 | work: ChannelWorkSnapshotVoSchema.optional().describe('作品资料'), |
| 10 | snapshots: z.array(ChannelWorkDataSnapshotVoSchema).default([]).describe('本次保存的作品数据快照'), |
| 11 | extra: z.record(z.string(), z.unknown()).optional().describe('平台特殊字段'), |
| 12 | snapshotId: z.string().optional().describe('本次主快照 ID'), |
| 13 | fetchedAt: z.coerce.date().optional().describe('平台数据获取时间'), |
| 14 | message: z.string().optional().describe('提示信息'), |
| 15 | }) |
| 16 | |
| 17 | export class ChannelWorkDataVo extends createZodDto( |
| 18 | ChannelWorkDataVoSchema, |
| 19 | 'ChannelWorkDataVo', |
| 20 | ) {} |
| 21 | |
| 22 | export const ChannelWorkOwnershipVoSchema = z.object({ |
| 23 | platform: z.enum(AccountType).describe('平台'), |
| 24 | owned: z.boolean().describe('作品是否归属该账号'), |
| 25 | message: z.string().optional().describe('提示信息'), |
| 26 | }) |
| 27 | |
| 28 | export class ChannelWorkOwnershipVo extends createZodDto( |
| 29 | ChannelWorkOwnershipVoSchema, |
| 30 | 'ChannelWorkOwnershipVo', |
| 31 | ) {} |
| 32 | |
| 33 | export const ChannelWorkListItemVoSchema = z.object({ |
| 34 | platformWorkId: z.string().describe('平台作品 ID'), |
| 35 | contentMode: z.enum(PublishContentMode).describe('作品内容类型'), |
| 36 | title: z.string().optional().describe('作品标题'), |
| 37 | description: z.string().optional().describe('作品描述'), |
| 38 | url: z.string().optional().describe('作品链接'), |
| 39 | coverUrl: z.string().optional().describe('封面 URL'), |
| 40 | publishedAt: z.coerce.date().optional().describe('发布时间'), |
| 41 | authorName: z.string().optional().describe('作者名称'), |
| 42 | authorPlatformUid: z.string().optional().describe('作者平台 UID'), |
| 43 | status: z.string().optional().describe('作品状态'), |
| 44 | metrics: ChannelWorkMetricsSnapshotVoSchema.optional().describe('作品指标'), |
| 45 | }) |
| 46 | |
| 47 | export const ChannelWorkListVoSchema = z.object({ |
| 48 | platform: z.enum(AccountType).describe('平台'), |
| 49 | items: z.array(ChannelWorkListItemVoSchema).describe('作品列表'), |
| 50 | pagination: ChannelPaginationResultVoSchema.describe('分页结果'), |
| 51 | }) |
| 52 | |
| 53 | export class ChannelWorkListVo extends createZodDto( |
| 54 | ChannelWorkListVoSchema, |
| 55 | 'ChannelWorkListVo', |
| 56 | ) {} |
| 57 |