返回 AiToEarn
channels-mcp.schema.ts
根目录 / project / aitoearn-backend / apps / aitoearn-server / src / core / channels / mcp / channels-mcp.schema.ts
1 import { AccountType } from '@yikart/common'
2 import { PublishRecordSource, PublishStatus, PublishType } from '@yikart/mongodb'
3 import { z } from 'zod'
4 import { ChannelPaginationInputWithDefaultSchema } from '../platforms/platform-pagination.dto'
5 import { ChannelEngagementFunctionName } from '../platforms/platforms.interface'
6 import { CreatePublishFlowSchema, PublishFlowContextSchema } from '../publish/flows/publish-flow.dto'
7 import { PublishUpdateDataSchema } from '../publish/tasks/publish-update.schema'
8
9 export const CreateChannelPublishFlowSchema = CreatePublishFlowSchema.extend({
10 context: PublishFlowContextSchema.omit({ source: true }).optional().describe('外部业务关联,source 固定为 MCP'),
11 })
12 export type CreateChannelPublishFlowParams = z.infer<typeof CreateChannelPublishFlowSchema>
13
14 const PublishTimeRangeSchema = z
15 .array(z.coerce.date())
16 .length(2)
17 .transform(value => value as [Date, Date])
18 .describe('发布时间范围')
19
20 export const ListChannelPublishRecordsSchema = z.object({
21 accountId: z.string().optional().describe('账号 ID'),
22 accountType: z.enum(AccountType).optional().describe('账号平台'),
23 flowId: z.string().optional().describe('发布 flow ID'),
24 source: z.enum(PublishRecordSource).optional().describe('发布来源'),
25 status: z.coerce.number().pipe(z.enum(PublishStatus)).optional().describe('发布状态'),
26 type: z.enum(PublishType).optional().describe('发布类型'),
27 time: PublishTimeRangeSchema.optional(),
28 uid: z.string().optional().describe('平台账号 UID'),
29 })
30 export type ListChannelPublishRecordsParams = z.infer<typeof ListChannelPublishRecordsSchema>
31
32 export const GetChannelPublishRecordByRecordIdSchema = z.object({
33 recordId: z.string().min(1).describe('发布记录 ID'),
34 })
35 export type GetChannelPublishRecordByRecordIdParams = z.infer<typeof GetChannelPublishRecordByRecordIdSchema>
36
37 export const GetChannelPublishRecordByTaskIdSchema = z.object({
38 taskId: z.string().min(1).describe('发布任务 ID'),
39 })
40 export type GetChannelPublishRecordByTaskIdParams = z.infer<typeof GetChannelPublishRecordByTaskIdSchema>
41
42 export const GetChannelPublishRecordByFlowIdSchema = z.object({
43 flowId: z.string().min(1).describe('发布 flow ID'),
44 })
45 export type GetChannelPublishRecordByFlowIdParams = z.infer<typeof GetChannelPublishRecordByFlowIdSchema>
46
47 export const ChannelPublishTaskSchema = z.object({
48 taskId: z.string().min(1).describe('发布任务 ID'),
49 })
50 export type ChannelPublishTaskParams = z.infer<typeof ChannelPublishTaskSchema>
51
52 export const UpdateChannelPublishAtSchema = ChannelPublishTaskSchema.extend({
53 publishAt: z.coerce.date().describe('目标发布时间'),
54 })
55 export type UpdateChannelPublishAtParams = z.infer<typeof UpdateChannelPublishAtSchema>
56
57 export const RequestChannelPublishUpdateSchema = ChannelPublishTaskSchema.extend({
58 data: PublishUpdateDataSchema.describe('新版发布更新数据'),
59 })
60 export type RequestChannelPublishUpdateParams = z.infer<typeof RequestChannelPublishUpdateSchema>
61
62 export const ChannelPlatformSchema = z.object({
63 platform: z.enum(AccountType).describe('平台'),
64 })
65 export type ChannelPlatformParams = z.infer<typeof ChannelPlatformSchema>
66
67 export const ListBilibiliChannelPlatformCategoriesSchema = z.object({
68 accountId: z.string().min(1).describe('Bilibili 账号 ID'),
69 })
70 export type ListBilibiliChannelPlatformCategoriesParams = z.infer<typeof ListBilibiliChannelPlatformCategoriesSchema>
71
72 export const ListYoutubeChannelPlatformCategoriesSchema = z.object({
73 accountId: z.string().min(1).describe('YouTube 账号 ID'),
74 id: z.string().optional().describe('YouTube 分类 ID'),
75 regionCode: z.string().default('US').describe('YouTube 地区代码'),
76 })
77 export type ListYoutubeChannelPlatformCategoriesParams = z.infer<typeof ListYoutubeChannelPlatformCategoriesSchema>
78
79 export const ChannelWorkAccountSchema = z.object({
80 accountId: z.string().min(1).optional().describe('账号 ID'),
81 platform: z.enum(AccountType).describe('平台'),
82 })
83 export type ChannelWorkAccountParams = z.infer<typeof ChannelWorkAccountSchema>
84
85 export const GetChannelWorkLinkInfoSchema = ChannelWorkAccountSchema.extend({
86 link: z.string().min(1).describe('作品链接'),
87 })
88 export type GetChannelWorkLinkInfoParams = z.infer<typeof GetChannelWorkLinkInfoSchema>
89
90 export const ChannelWorkSchema = ChannelWorkAccountSchema.extend({
91 platformWorkId: z.string().min(1).describe('平台作品 ID'),
92 })
93 export type ChannelWorkParams = z.infer<typeof ChannelWorkSchema>
94
95 export const ListChannelWorksSchema = z.object({
96 accountId: z.string().min(1).describe('账号 ID'),
97 platform: z.enum(AccountType).describe('平台'),
98 pagination: ChannelPaginationInputWithDefaultSchema.describe('分页参数'),
99 })
100 export type ListChannelWorksParams = z.infer<typeof ListChannelWorksSchema>
101
102 export const GetChannelAccountAnalyticsSchema = z.object({
103 accountId: z.string().min(1).describe('账号 ID'),
104 since: z.coerce.date().optional().describe('开始时间'),
105 until: z.coerce.date().optional().describe('结束时间'),
106 })
107 export type GetChannelAccountAnalyticsParams = z.infer<typeof GetChannelAccountAnalyticsSchema>
108
109 export const VerifyChannelWorkOwnershipSchema = z.object({
110 platform: z.enum(AccountType).describe('平台'),
111 platformWorkId: z.string().min(1).describe('平台作品 ID'),
112 candidateAccountId: z.string().min(1).describe('候选账号 ID'),
113 })
114 export type VerifyChannelWorkOwnershipParams = z.infer<typeof VerifyChannelWorkOwnershipSchema>
115
116 export const ListChannelEngagementCommentsSchema = z.object({
117 accountId: z.string().min(1).describe('账号 ID'),
118 platform: z.enum(AccountType).describe('平台'),
119 platformWorkId: z.string().min(1).describe('平台作品 ID'),
120 pagination: ChannelPaginationInputWithDefaultSchema.describe('分页参数'),
121 })
122 export type ListChannelEngagementCommentsParams = z.infer<typeof ListChannelEngagementCommentsSchema>
123
124 export const SubmitChannelEngagementCommentSchema = z.object({
125 accountId: z.string().min(1).describe('账号 ID'),
126 platform: z.enum(AccountType).describe('平台'),
127 platformWorkId: z.string().min(1).describe('平台作品 ID'),
128 content: z.string().min(1).describe('评论内容'),
129 parentCommentId: z.string().optional().describe('父评论 ID'),
130 })
131 export type SubmitChannelEngagementCommentParams = z.infer<typeof SubmitChannelEngagementCommentSchema>
132
133 export const CallChannelEngagementFunctionSchema = z.object({
134 accountId: z.string().min(1).describe('动作执行账号 ID'),
135 platform: z.enum(AccountType).describe('平台'),
136 name: z.enum(ChannelEngagementFunctionName).describe('互动函数名称'),
137 data: z.record(z.string(), z.unknown()).describe('函数参数:delete_comment/hide_reply/unhide_reply 传 commentId;work 动作传 platformWorkId;quote 额外传 content;follow/unfollow 传 targetPlatformUid'),
138 })
139 export type CallChannelEngagementFunctionParams = z.infer<typeof CallChannelEngagementFunctionSchema>
140
140 lines TYPESCRIPT