import { z } from 'zod'; const targetPlatformEnum = z.enum(['default', 'intl', 'private']); // 产品类型(模型引用外部选项集,未给出完整选项列表;已与用户确认的全量枚举值) const productTypeEnum = z.enum(['scf', 'tcbr', 'lighthouse']); // featureList.separatorType:给 detail 添加符号的分割类型 const separatorTypeEnum = z.enum(['split', 'tick', 'unordered']); // serviceList.type:跳转操作类型 const serviceTypeEnum = z.enum(['create', 'delete', 'update', 'read']); // 产品特征列表条目(模型 required:[],全部字段均可选) const featureItemSchema = z .object({ name: z.string().optional(), title: z.string().optional(), // 支持 cloudId / http / base64(data: URI)等格式,按资源引用约定原样保留 icon: z.string().optional(), separatorType: separatorTypeEnum.optional(), // 若是 ["a","b","c"] 这种 JSON 数组字符串,前端会自动分割展示,否则整串展示;不 strip detail: z.string().optional(), }) .strict(); // 产品跳转列表条目(模型 required:[],全部字段均可选) const serviceItemSchema = z .object({ type: serviceTypeEnum.optional(), path: z.string().optional(), title: z.string().optional(), }) .strict(); // 最佳实践列表条目(模型 required: ["title","url"]) const guideItemSchema = z .object({ title: z.string(), url: z.string(), }) .strict(); const row = z .object({ lang: z.enum(['zh', 'en']), productType: productTypeEnum, title: z.string(), description: z.string().optional(), docUrl: z.string().max(256).optional(), featureList: z.array(featureItemSchema).optional(), serviceList: z.array(serviceItemSchema).optional(), guideList: z.array(guideItemSchema).optional(), order: z.number().int().optional(), // cloudID 存储类型,图标字段暂原样保留 cloud:// 协议地址,待业务方后续清理 titleIcon: z.string().optional(), targetPlatform: z.array(targetPlatformEnum).min(1), // —— 旧 cms 平台系统字段,保留以保证使用处兼容性 —— _id: z.string(), _openid: z.string().optional(), _mainDep: z.string().optional(), // xlsx 导出为字符串日期格式,非数字时间戳,按实际数据形态定 createdAt: z.string(), updatedAt: z.string(), owner: z.string().optional(), createBy: z.string().optional(), updateBy: z.string().optional(), }) .strict(); export default z.array(row);