返回 AiToEarn
channel.types.ts
根目录 / project / aitoearn-web / src / api / channels / channel.types.ts
1 import type { ChannelPublishStatus, PlatformStatus, PublishContentMode } from './channel.constants'
2 import type { PlatType } from '@/app/config/platConfig'
3 import type { PubType } from '@/app/config/publishConfig'
4
5 // Source: types/channelAuth.type.ts
6
7 /**
8 * ChannelAuthSessionStatus 类型。
9 */
10 export type ChannelAuthSessionStatus = 'pending' | 'completed' | 'failed'
11
12 /**
13 * StartChannelAccountAuthParams 请求参数。
14 */
15 export interface StartChannelAccountAuthParams {
16 callbackUrl?: string
17 redirectUri?: string
18 groupId?: string
19 }
20
21 /**
22 * StartChannelOAuthLoginParams 请求参数。
23 */
24 export interface StartChannelOAuthLoginParams {
25 redirectUri?: string
26 inviteCode?: string
27 }
28
29 /**
30 * ChannelAccountAuthStart 类型。
31 */
32 export interface ChannelAccountAuthStart {
33 url: string
34 sessionId: string
35 expiresAt?: string
36 }
37
38 /**
39 * ChannelOAuthLoginStart 类型。
40 */
41 export interface ChannelOAuthLoginStart {
42 url: string
43 sessionId: string
44 expiresAt?: string
45 authInstructions?: Record<string, string>
46 }
47
48 /**
49 * ChannelAuthConnectedAccount 类型。
50 */
51 export interface ChannelAuthConnectedAccount {
52 accountId: string
53 platform: PlatType
54 platformUid: string
55 displayName: string
56 avatarUrl?: string
57 }
58
59 /**
60 * ChannelAuthSelectableAccount 类型。
61 */
62 export interface ChannelAuthSelectableAccount {
63 platform: PlatType
64 platformUid: string
65 displayName: string
66 avatarUrl?: string
67 parentPlatformUid?: string
68 }
69
70 /**
71 * ChannelAccountAuthStatus 类型。
72 */
73 export interface ChannelAccountAuthStatus {
74 sessionId: string
75 status: ChannelAuthSessionStatus
76 requiresSelection: boolean
77 expiresAt?: string
78 accountId?: string
79 accountIds?: string[]
80 accounts?: ChannelAuthConnectedAccount[]
81 selectableAccounts?: ChannelAuthSelectableAccount[]
82 }
83
84 // Source: types/channelPlatform.ts
85
86 /**
87 * PlatformAuthType 类型。
88 */
89 export type PlatformAuthType = 'oauth2' | 'oauth1' | 'api_key' | 'browser' | 'plugin' | 'qrcode' | 'mobile_handoff'
90
91 /**
92 * PlatformEditorType 类型。
93 */
94 export type PlatformEditorType = 'none' | 'text' | 'normal' | 'markdown' | 'html'
95
96 /**
97 * PlatformContentMode 类型。
98 */
99 export type PlatformContentMode = PublishContentMode | PubType
100
101 /**
102 * PublishOptionValueType 类型。
103 */
104 export type PublishOptionValueType = 'list' | 'tree'
105
106 /**
107 * PublishOptionValueItem 数据结构。
108 */
109 export interface PublishOptionValueItem {
110 value: string
111 label: string
112 description?: string
113 disabled?: boolean
114 children?: PublishOptionValueItem[]
115 extra?: Record<string, unknown>
116 }
117
118 /**
119 * PublishOptionValuesVo 响应数据。
120 */
121 export interface PublishOptionValuesVo {
122 field: string
123 valueType: PublishOptionValueType
124 items: PublishOptionValueItem[]
125 }
126
127 /**
128 * PublishOptionCreatedValueVo 响应数据。
129 */
130 export interface PublishOptionCreatedValueVo {
131 field: string
132 valueType: PublishOptionValueType
133 item: PublishOptionValueItem
134 }
135
136 /**
137 * PlatformDisplayName 类型。
138 */
139 export interface PlatformDisplayName {
140 'en-US'?: string
141 'zh-CN'?: string
142 [locale: string]: string | undefined
143 }
144
145 /**
146 * PlatformContentLimits 类型。
147 */
148 export interface PlatformContentLimits {
149 modes?: PlatformContentMode[]
150 maxTitleLength?: number
151 maxBodyLength?: number
152 maxTotalTextLength?: number
153 maxMediaCount?: number
154 maxImages?: number
155 maxVideos?: number
156 }
157
158 /**
159 * PlatformMediaRules 类型。
160 */
161 export type PlatformMediaRules = Record<string, unknown>
162
163 /**
164 * PlatformTopicRules 类型。
165 */
166 export interface PlatformTopicRules {
167 supported: boolean
168 nativeField?: boolean
169 maxCount?: number
170 maxTotalLength?: number
171 }
172
173 /**
174 * PlatformCapabilities 类型。
175 */
176 export interface PlatformCapabilities {
177 auth: Record<string, boolean>
178 publish: Record<string, boolean | string | undefined>
179 analytics: Record<string, boolean>
180 engagement: Record<string, boolean>
181 work: Record<string, boolean>
182 browse: Record<string, boolean>
183 webhook: Record<string, boolean>
184 }
185
186 /**
187 * PlatformMetadataVo 响应数据。
188 */
189 export interface PlatformMetadataVo {
190 platform: PlatType
191 status: PlatformStatus
192 displayName: PlatformDisplayName
193 logoUrl: string
194 authType: PlatformAuthType
195 authInstructions?: PlatformDisplayName
196 editor: PlatformEditorType
197 contentLimits: PlatformContentLimits
198 mediaRules: PlatformMediaRules
199 topic: PlatformTopicRules
200 capabilities: PlatformCapabilities
201 optionSchema: Record<string, unknown>
202 defaultOption?: Record<string, unknown>
203 }
204
205 /**
206 * PlatformPubParamsConfig 数据结构。
207 */
208 export interface PlatformPubParamsConfig {
209 titleMax?: number
210 topicMax?: number
211 topicMaxTotalLength?: number
212 desMax: number
213 imagesMax?: number
214 }
215
216 /**
217 * PlatformInfo 数据结构。
218 */
219 export interface PlatformInfo {
220 type: PlatType
221 platform: PlatType
222 status: PlatformStatus
223 name: string
224 icon: string
225 logoUrl: string
226 authType: PlatformAuthType
227 authInstruction?: string
228 editor: PlatformEditorType
229 capabilities: PlatformCapabilities
230 contentLimits: PlatformContentLimits
231 mediaRules: PlatformMediaRules
232 topic: PlatformTopicRules
233 optionSchema: Record<string, unknown>
234 defaultOption?: Record<string, unknown>
235 commonPubParamsConfig: PlatformPubParamsConfig
236 pubTypes: Set<PubType>
237 themeColor?: string
238 }
239
240 /**
241 * PlatformInfoTuple 类型。
242 */
243 export type PlatformInfoTuple = [PlatType, PlatformInfo]
244
245 // Source: types/channelPublish.type.ts
246
247 /**
248 * ChannelPublishSource 类型。
249 */
250 export type ChannelPublishSource
251 = | 'publish' | 'web' | 'api' | 'internal' | 'mcp'
252
253 /**
254 * ChannelPublishRecordEngagement 类型。
255 */
256 export interface ChannelPublishRecordEngagement {
257 viewCount: number
258 commentCount: number
259 likeCount: number
260 shareCount: number
261 clickCount: number
262 impressionCount: number
263 favoriteCount: number
264 }
265
266 /**
267 * ChannelPublishRecordOption 数据结构。
268 */
269 export interface ChannelPublishRecordOption {
270 facebook?: {
271 content_category?: string
272 }
273 [key: string]: unknown
274 }
275
276 /**
277 * ChannelPublishMediaInput 数据结构。
278 */
279 export interface ChannelPublishMediaInput {
280 url: string
281 metadata?: Record<string, unknown>
282 }
283
284 /**
285 * ChannelPublishCoverInput 数据结构。
286 */
287 export interface ChannelPublishCoverInput {
288 url: string
289 metadata?: Record<string, unknown>
290 }
291
292 /**
293 * ChannelPublishContentInput 数据结构。
294 */
295 export interface ChannelPublishContentInput {
296 title?: string
297 body?: string
298 media: ChannelPublishMediaInput[]
299 cover?: ChannelPublishCoverInput
300 }
301
302 /**
303 * ChannelPublishContentOverride 类型。
304 */
305 export interface ChannelPublishContentOverride {
306 title?: string
307 body?: string
308 media?: ChannelPublishMediaInput[]
309 cover?: ChannelPublishCoverInput | null
310 }
311
312 /**
313 * ChannelPublishFlowContext 类型。
314 */
315 export interface ChannelPublishFlowContext {
316 type?: PubType.VIDEO | PubType.ImageText
317 taskId?: string
318 userTaskId?: string
319 materialGroupId?: string
320 materialId?: string
321 source?: ChannelPublishSource
322 videoUrl?: string
323 imgUrlList?: string[]
324 }
325
326 /**
327 * ChannelCreatePublishFlowItem 数据结构。
328 */
329 export interface ChannelCreatePublishFlowItem {
330 accountId: string
331 platform: PlatType
332 option?: Record<string, unknown>
333 overrides?: ChannelPublishContentOverride
334 }
335
336 /**
337 * ChannelCreatePublishFlowParams 请求参数。
338 */
339 export interface ChannelCreatePublishFlowParams {
340 flowId?: string
341 content: ChannelPublishContentInput
342 publishAt: string
343 context?: ChannelPublishFlowContext
344 items: ChannelCreatePublishFlowItem[]
345 }
346
347 /**
348 * ChannelPublishFlowTaskVo 响应数据。
349 */
350 export interface ChannelPublishFlowTaskVo {
351 id: string
352 accountId: string
353 platform: PlatType
354 status?: ChannelPublishStatus
355 publishTime?: string
356 platformWorkId?: string
357 workLink?: string
358 errorMsg?: string
359 }
360
361 /**
362 * ChannelPublishFlowVo 响应数据。
363 */
364 export interface ChannelPublishFlowVo {
365 flowId: string
366 tasks: ChannelPublishFlowTaskVo[]
367 }
368
369 /**
370 * ChannelPublishRecordItem 数据结构。
371 */
372 export interface ChannelPublishRecordItem {
373 id: string
374 flowId?: string
375 taskId?: string
376 userTaskId?: string
377 userId?: string
378 accountId?: string
379 accountType: PlatType
380 type: PubType.VIDEO | PubType.ImageText
381 status: ChannelPublishStatus
382 title?: string
383 desc?: string
384 publishTime: string | Date
385 platformWorkId?: string
386 workLink?: string
387 videoUrl?: string
388 coverUrl?: string
389 imgUrlList?: string[]
390 topics?: string[]
391 source?: ChannelPublishSource
392 errorMsg?: string
393 createdAt?: string
394 updatedAt?: string
395 option?: ChannelPublishRecordOption
396 dataOption?: Record<string, unknown>
397 dataId?: string
398 uid?: string
399 taskMaterialId?: string
400 inQueue?: boolean
401 linkStatus?: 'pending' | 'ready' | 'failed'
402 linkError?: string
403 linkMeta?: Record<string, unknown>
404 engagement?: ChannelPublishRecordEngagement
405 }
406
407 /**
408 * ChannelPublicPublishRecordItem 数据结构。
409 */
410 export type ChannelPublicPublishRecordItem
411 = Partial<ChannelPublishRecordItem>
412 & Pick<ChannelPublishRecordItem, 'id' | 'accountType' | 'type' | 'status' | 'publishTime'>
413
414 /**
415 * ChannelPublishRecordListVo 响应数据。
416 */
417 export type ChannelPublishRecordListVo
418 = | ChannelPublishRecordItem[]
419 | {
420 records?: ChannelPublishRecordItem[]
421 list?: ChannelPublishRecordItem[]
422 items?: ChannelPublishRecordItem[]
423 rows?: ChannelPublishRecordItem[]
424 }
425
426
427 /**
428 * ChannelPublishUserActionVo 响应数据。
429 */
430 export interface ChannelPublishUserActionVo {
431 recordId: string
432 platform: PlatType.Douyin
433 shareId: string
434 schemeUrl: string
435 shortLink: string
436 expiresAt?: string | Date
437 }
438
439 /**
440 * ChannelPublishRecordQueryParams 请求参数。
441 */
442 export interface ChannelPublishRecordQueryParams {
443 accountId?: string
444 accountType?: PlatType
445 status?: ChannelPublishStatus
446 time?: [string, string]
447 }
448
449 /**
450 * ChannelWorkQueryParams 请求参数。
451 */
452 export interface ChannelWorkQueryParams {
453 platform: PlatType
454 accountId?: string
455 }
456
457 /**
458 * ChannelWorkAnalyticsVo 响应数据。
459 */
460 export interface ChannelWorkAnalyticsVo {
461 platform: PlatType
462 accountId?: string
463 platformWorkId: string
464 metrics?: ChannelWorkMetricsSnapshot
465 fetchedAt?: string
466 message?: string
467 [key: string]: unknown
468 }
469
470 /**
471 * ChannelWorkMetricsSnapshot 数据结构。
472 */
473 export interface ChannelWorkMetricsSnapshot {
474 viewCount?: number
475 playCount?: number
476 impressionCount?: number
477 reachCount?: number
478 likeCount?: number
479 collectCount?: number
480 commentCount?: number
481 shareCount?: number
482 saveCount?: number
483 clickCount?: number
484 engagementCount?: number
485 watchTimeSeconds?: number
486 }
487 /**
488 * Channel platform metadata list options.
489 */
490 export interface ChannelPlatformListOptions {
491 fresh?: boolean
492 }
493
494 /**
495 * Channel publish task action response.
496 */
497 export interface ChannelPublishTaskActionVo {
498 taskId: string
499 }
500
500 lines TYPESCRIPT