| 1 | import type { AccountType } from '@yikart/common' |
| 2 | import type { PublishContentInput, PublishContentOverride } from '../schemas/publish-content.schema' |
| 3 | import { createZodDto, PaginationDtoSchema } from '@yikart/common' |
| 4 | import { PublishRecordSource } from '@yikart/mongodb' |
| 5 | import { z } from 'zod' |
| 6 | import { createPlatformPublishOptionItemSchema } from '../../platforms/publish.schema' |
| 7 | import { PublishContentInputSchema, PublishContentOverrideSchema } from '../schemas/publish-content.schema' |
| 8 | |
| 9 | const PublishFlowItemSchema = createPlatformPublishOptionItemSchema({ |
| 10 | accountId: z.string().describe('账号 ID'), |
| 11 | overrides: PublishContentOverrideSchema.optional().describe('平台覆盖内容'), |
| 12 | }) |
| 13 | |
| 14 | export const PublishFlowContextSchema = z.object({ |
| 15 | taskId: z.string().optional().describe('外部任务 ID'), |
| 16 | materialGroupId: z.string().optional().describe('素材组 ID'), |
| 17 | materialId: z.string().optional().describe('素材 ID'), |
| 18 | source: z.enum(PublishRecordSource).optional().describe('发布来源'), |
| 19 | }) |
| 20 | |
| 21 | export const CreatePublishFlowSchema = z.object({ |
| 22 | flowId: z.string().optional().describe('外部流水 ID'), |
| 23 | content: PublishContentInputSchema.describe('跨平台共享内容'), |
| 24 | publishAt: z.coerce.date().describe('目标发布时间'), |
| 25 | context: PublishFlowContextSchema.optional().describe('外部业务关联'), |
| 26 | items: z.array(PublishFlowItemSchema).min(1).describe('平台发布项'), |
| 27 | }) |
| 28 | |
| 29 | export class CreatePublishFlowDto extends createZodDto(CreatePublishFlowSchema) {} |
| 30 | |
| 31 | export interface CreatePublishFlowCommand { |
| 32 | flowId?: string |
| 33 | content: PublishContentInput |
| 34 | publishAt: Date |
| 35 | context?: z.infer<typeof PublishFlowContextSchema> |
| 36 | items: Array<{ |
| 37 | accountId: string |
| 38 | platform: AccountType |
| 39 | option?: Record<string, unknown> |
| 40 | overrides?: PublishContentOverride |
| 41 | }> |
| 42 | } |
| 43 | |
| 44 | export const PublishFlowQuerySchema = PaginationDtoSchema.extend({ |
| 45 | userId: z.string().optional().describe('用户 ID'), |
| 46 | status: z.string().optional().describe('状态筛选'), |
| 47 | }) |
| 48 | |
| 49 | export class PublishFlowQueryDto extends createZodDto(PublishFlowQuerySchema) {} |
| 50 |