| 1 | import { createZodDto } from '@yikart/common' |
| 2 | import { z } from 'zod' |
| 3 | import { createPlatformConfigSchema } from '../platforms.config' |
| 4 | import { PlatformStatus } from '../platforms.interface' |
| 5 | |
| 6 | const wechatOfficialAvailableConfigSchema = z.object({ |
| 7 | status: z.literal(PlatformStatus.Available), |
| 8 | appId: z.string(), |
| 9 | appSecret: z.string(), |
| 10 | hostUrl: z.string().default(''), |
| 11 | token: z.string().default(''), |
| 12 | encodingAESKey: z.string().default(''), |
| 13 | redirectUri: z.string().default(''), |
| 14 | logoUrl: z.url(), |
| 15 | scopes: z.array(z.string()).default([]), |
| 16 | }) |
| 17 | |
| 18 | const wechatChannelsAvailableConfigSchema = z.object({ |
| 19 | status: z.literal(PlatformStatus.Available), |
| 20 | appId: z.string(), |
| 21 | appSecret: z.string(), |
| 22 | token: z.string().default(''), |
| 23 | encodingAESKey: z.string().default(''), |
| 24 | redirectUri: z.string().default(''), |
| 25 | logoUrl: z.url(), |
| 26 | }) |
| 27 | |
| 28 | export const wechatOfficialConfigSchema = createPlatformConfigSchema(wechatOfficialAvailableConfigSchema) |
| 29 | export const wechatChannelsConfigSchema = createPlatformConfigSchema(wechatChannelsAvailableConfigSchema) |
| 30 | |
| 31 | export const wechatConfigSchema = z.object({ |
| 32 | official: wechatOfficialConfigSchema.default({ status: PlatformStatus.Hidden, logoUrl: '' } as never), |
| 33 | channels: wechatChannelsConfigSchema.default({ status: PlatformStatus.Hidden, logoUrl: '' } as never), |
| 34 | }) |
| 35 | |
| 36 | export class WechatOfficialConfig extends createZodDto(wechatOfficialAvailableConfigSchema) {} |
| 37 | export class WechatChannelsConfig extends createZodDto(wechatChannelsAvailableConfigSchema) {} |
| 38 | export class WechatConfig extends createZodDto(wechatConfigSchema) {} |
| 39 |