diff --git a/src/common/coerce.ts b/src/common/coerce.ts index 6aabd538..46eb174d 100644 --- a/src/common/coerce.ts +++ b/src/common/coerce.ts @@ -11,4 +11,4 @@ const string = () => z.preprocess( val => typeof val !== 'string' ? String(val) : val, z.string() ); -export const coerce = { boolean, number, string }; \ No newline at end of file +export const actionType = { boolean, number, string }; \ No newline at end of file diff --git a/src/core/helper/config.ts b/src/core/helper/config.ts index 66721252..ca3d2268 100644 --- a/src/core/helper/config.ts +++ b/src/core/helper/config.ts @@ -1,16 +1,16 @@ import { ConfigBase } from '@/common/config-base'; import { NapCatCore } from '@/core'; -import { coerce } from '@/common/coerce'; +import { actionType } from '@/common/coerce'; import { z } from 'zod'; export const NapcatConfigSchema = z.object({ - fileLog: coerce.boolean().default(false), - consoleLog: coerce.boolean().default(true), - fileLogLevel: coerce.string().default('debug'), - consoleLogLevel: coerce.string().default('info'), - packetBackend: coerce.string().default('auto'), - packetServer: coerce.string().default(''), - o3HookMode: coerce.number().default(0), + fileLog: actionType.boolean().default(false), + consoleLog: actionType.boolean().default(true), + fileLogLevel: actionType.string().default('debug'), + consoleLogLevel: actionType.string().default('info'), + packetBackend: actionType.string().default('auto'), + packetServer: actionType.string().default(''), + o3HookMode: actionType.number().default(0), }); export type NapcatConfig = z.infer; diff --git a/src/onebot/action/extends/ClickInlineKeyboardButton.ts b/src/onebot/action/extends/ClickInlineKeyboardButton.ts index e7279c51..fba1830c 100644 --- a/src/onebot/action/extends/ClickInlineKeyboardButton.ts +++ b/src/onebot/action/extends/ClickInlineKeyboardButton.ts @@ -1,14 +1,14 @@ import { ActionName } from '@/onebot/action/router'; import { OneBotAction } from '../OneBotAction'; import { z } from 'zod'; -import { coerce } from '@/common/coerce'; +import { actionType } from '@/common/coerce'; const SchemaData = z.object({ - group_id: coerce.string(), - bot_appid: coerce.string(), - button_id: coerce.string().default(''), - callback_data: coerce.string().default(''), - msg_seq: coerce.string().default('10086'), + group_id: actionType.string(), + bot_appid: actionType.string(), + button_id: actionType.string().default(''), + callback_data: actionType.string().default(''), + msg_seq: actionType.string().default('10086'), }); type Payload = z.infer; diff --git a/src/onebot/action/extends/CreateCollection.ts b/src/onebot/action/extends/CreateCollection.ts index dd641d1b..0faf8b4e 100644 --- a/src/onebot/action/extends/CreateCollection.ts +++ b/src/onebot/action/extends/CreateCollection.ts @@ -1,10 +1,10 @@ import { OneBotAction } from '@/onebot/action/OneBotAction'; import { ActionName } from '@/onebot/action/router'; import { z } from 'zod'; -import { coerce } from '@/common/coerce'; +import { actionType } from '@/common/coerce'; const SchemaData = z.object({ - rawData: coerce.string(), - brief: coerce.string(), + rawData: actionType.string(), + brief: actionType.string(), }); type Payload = z.infer; diff --git a/src/onebot/action/extends/FetchCustomFace.ts b/src/onebot/action/extends/FetchCustomFace.ts index b14d2afa..ee6a535c 100644 --- a/src/onebot/action/extends/FetchCustomFace.ts +++ b/src/onebot/action/extends/FetchCustomFace.ts @@ -1,9 +1,9 @@ import { z } from 'zod'; import { OneBotAction } from '@/onebot/action/OneBotAction'; import { ActionName } from '@/onebot/action/router'; -import { coerce } from '@/common/coerce'; +import { actionType } from '@/common/coerce'; const SchemaData = z.object({ - count: coerce.number().default(48), + count: actionType.number().default(48), }); type Payload = z.infer; diff --git a/src/onebot/action/extends/FetchEmojiLike.ts b/src/onebot/action/extends/FetchEmojiLike.ts index ee383046..c55ce0c4 100644 --- a/src/onebot/action/extends/FetchEmojiLike.ts +++ b/src/onebot/action/extends/FetchEmojiLike.ts @@ -3,12 +3,12 @@ import { OneBotAction } from '@/onebot/action/OneBotAction'; import { ActionName } from '@/onebot/action/router'; import { MessageUnique } from '@/common/message-unique'; import { type NTQQMsgApi } from '@/core/apis'; -import { coerce } from '@/common/coerce'; +import { actionType } from '@/common/coerce'; const SchemaData = z.object({ - message_id: coerce.string(), - emojiId: coerce.string(), - emojiType: coerce.string(), - count: coerce.number().default(20), + message_id: actionType.string(), + emojiId: actionType.string(), + emojiType: actionType.string(), + count: actionType.number().default(20), }); type Payload = z.infer; diff --git a/src/onebot/action/extends/GetAiCharacters.ts b/src/onebot/action/extends/GetAiCharacters.ts index 5eb7fc5b..7e2210bd 100644 --- a/src/onebot/action/extends/GetAiCharacters.ts +++ b/src/onebot/action/extends/GetAiCharacters.ts @@ -2,10 +2,10 @@ import { ActionName } from '@/onebot/action/router'; import { GetPacketStatusDepends } from '@/onebot/action/packet/GetPacketStatus'; import { AIVoiceChatType } from '@/core/packet/entities/aiChat'; import { z } from 'zod'; -import { coerce } from '@/common/coerce'; +import { actionType } from '@/common/coerce'; const SchemaData = z.object({ - group_id: coerce.string(), - chat_type: coerce.number().default(1), + group_id: actionType.string(), + chat_type: actionType.number().default(1), }); type Payload = z.infer; diff --git a/src/onebot/action/extends/GetCollectionList.ts b/src/onebot/action/extends/GetCollectionList.ts index 4c170cff..1cb62961 100644 --- a/src/onebot/action/extends/GetCollectionList.ts +++ b/src/onebot/action/extends/GetCollectionList.ts @@ -2,10 +2,10 @@ import { type NTQQCollectionApi } from '@/core/apis/collection'; import { OneBotAction } from '@/onebot/action/OneBotAction'; import { ActionName } from '@/onebot/action/router'; import { z } from 'zod'; -import { coerce } from '@/common/coerce'; +import { actionType } from '@/common/coerce'; const SchemaData = z.object({ - category: coerce.number(), - count: coerce.number().default(1), + category: actionType.number(), + count: actionType.number().default(1), }); type Payload = z.infer; diff --git a/src/onebot/action/extends/GetGroupInfoEx.ts b/src/onebot/action/extends/GetGroupInfoEx.ts index f0078a41..9ed398bc 100644 --- a/src/onebot/action/extends/GetGroupInfoEx.ts +++ b/src/onebot/action/extends/GetGroupInfoEx.ts @@ -1,9 +1,9 @@ import { OneBotAction } from '@/onebot/action/OneBotAction'; import { ActionName } from '@/onebot/action/router'; import { z } from 'zod'; -import { coerce } from '@/common/coerce'; +import { actionType } from '@/common/coerce'; const SchemaData = z.object({ - group_id: coerce.string(), + group_id: actionType.string(), }); type Payload = z.infer; diff --git a/src/onebot/action/extends/GetMiniAppArk.ts b/src/onebot/action/extends/GetMiniAppArk.ts index d9ea1449..2bd60b0a 100644 --- a/src/onebot/action/extends/GetMiniAppArk.ts +++ b/src/onebot/action/extends/GetMiniAppArk.ts @@ -3,34 +3,34 @@ import { GetPacketStatusDepends } from '@/onebot/action/packet/GetPacketStatus'; import { MiniAppInfo, MiniAppInfoHelper } from '@/core/packet/utils/helper/miniAppHelper'; import { MiniAppData, MiniAppRawData, MiniAppReqCustomParams, MiniAppReqParams } from '@/core/packet/entities/miniApp'; import { z } from 'zod'; -import { coerce } from '@/common/coerce'; +import { actionType } from '@/common/coerce'; const SchemaData = z.union([ z.object({ type: z.union([z.literal('bili'), z.literal('weibo')]), - title: coerce.string(), - desc: coerce.string(), - picUrl: coerce.string(), - jumpUrl: coerce.string(), - webUrl: coerce.string().optional(), - rawArkData: coerce.string().optional() + title: actionType.string(), + desc: actionType.string(), + picUrl: actionType.string(), + jumpUrl: actionType.string(), + webUrl: actionType.string().optional(), + rawArkData: actionType.string().optional() }), z.object({ - title: coerce.string(), - desc: coerce.string(), - picUrl: coerce.string(), - jumpUrl: coerce.string(), - iconUrl: coerce.string(), - webUrl: coerce.string().optional(), - appId: coerce.string(), - scene: z.union([coerce.number(), coerce.string()]), - templateType: z.union([coerce.number(), coerce.string()]), - businessType: z.union([coerce.number(), coerce.string()]), - verType: z.union([coerce.number(), coerce.string()]), - shareType: z.union([coerce.number(), coerce.string()]), - versionId: coerce.string(), - sdkId: coerce.string(), - withShareTicket: z.union([coerce.number(), coerce.string()]), - rawArkData: coerce.string().optional() + title: actionType.string(), + desc: actionType.string(), + picUrl: actionType.string(), + jumpUrl: actionType.string(), + iconUrl: actionType.string(), + webUrl: actionType.string().optional(), + appId: actionType.string(), + scene: z.union([actionType.number(), actionType.string()]), + templateType: z.union([actionType.number(), actionType.string()]), + businessType: z.union([actionType.number(), actionType.string()]), + verType: z.union([actionType.number(), actionType.string()]), + shareType: z.union([actionType.number(), actionType.string()]), + versionId: actionType.string(), + sdkId: actionType.string(), + withShareTicket: z.union([actionType.number(), actionType.string()]), + rawArkData: actionType.string().optional() }) ]); type Payload = z.infer; diff --git a/src/onebot/action/extends/GetProfileLike.ts b/src/onebot/action/extends/GetProfileLike.ts index f4cf7400..cefd9e55 100644 --- a/src/onebot/action/extends/GetProfileLike.ts +++ b/src/onebot/action/extends/GetProfileLike.ts @@ -2,11 +2,11 @@ import { NTVoteInfo } from '@/core'; import { OneBotAction } from '@/onebot/action/OneBotAction'; import { ActionName } from '@/onebot/action/router'; import { z } from 'zod'; -import { coerce } from '@/common/coerce'; +import { actionType } from '@/common/coerce'; const SchemaData = z.object({ - user_id: coerce.string().optional(), - start: coerce.number().default(0), - count: coerce.number().default(10), + user_id: actionType.string().optional(), + start: actionType.number().default(0), + count: actionType.number().default(10), }); type Payload = z.infer; diff --git a/src/onebot/action/extends/GetUserStatus.ts b/src/onebot/action/extends/GetUserStatus.ts index 66aeb609..38ac0007 100644 --- a/src/onebot/action/extends/GetUserStatus.ts +++ b/src/onebot/action/extends/GetUserStatus.ts @@ -1,9 +1,9 @@ import { ActionName } from '@/onebot/action/router'; import { GetPacketStatusDepends } from '@/onebot/action/packet/GetPacketStatus'; import { z } from 'zod'; -import { coerce } from '@/common/coerce'; +import { actionType } from '@/common/coerce'; const SchemaData = z.object({ - user_id: coerce.number(), + user_id: actionType.number(), }); type Payload = z.infer; diff --git a/src/onebot/action/extends/MoveGroupFile.ts b/src/onebot/action/extends/MoveGroupFile.ts index bf5c1c48..7e2e6eb4 100644 --- a/src/onebot/action/extends/MoveGroupFile.ts +++ b/src/onebot/action/extends/MoveGroupFile.ts @@ -2,12 +2,12 @@ import { ActionName } from '@/onebot/action/router'; import { FileNapCatOneBotUUID } from '@/common/file-uuid'; import { GetPacketStatusDepends } from '@/onebot/action/packet/GetPacketStatus'; import { z } from 'zod'; -import { coerce } from '@/common/coerce'; +import { actionType } from '@/common/coerce'; const SchemaData = z.object({ - group_id: coerce.string(), - file_id: coerce.string(), - current_parent_directory: coerce.string(), - target_parent_directory: coerce.string(), + group_id: actionType.string(), + file_id: actionType.string(), + current_parent_directory: actionType.string(), + target_parent_directory: actionType.string(), }); type Payload = z.infer; diff --git a/src/onebot/action/extends/OCRImage.ts b/src/onebot/action/extends/OCRImage.ts index c280a3cc..c08a12b5 100644 --- a/src/onebot/action/extends/OCRImage.ts +++ b/src/onebot/action/extends/OCRImage.ts @@ -4,9 +4,9 @@ import { checkFileExist, uriToLocalFile } from '@/common/file'; import fs from 'fs'; import { z } from 'zod'; import { GeneralCallResultStatus } from '@/core'; -import { coerce } from '@/common/coerce'; +import { actionType } from '@/common/coerce'; const SchemaData = z.object({ - image: coerce.string(), + image: actionType.string(), }); type Payload = z.infer; diff --git a/src/onebot/action/extends/RenameGroupFile.ts b/src/onebot/action/extends/RenameGroupFile.ts index 8c6e7964..ff40a66b 100644 --- a/src/onebot/action/extends/RenameGroupFile.ts +++ b/src/onebot/action/extends/RenameGroupFile.ts @@ -2,12 +2,12 @@ import { ActionName } from '@/onebot/action/router'; import { FileNapCatOneBotUUID } from '@/common/file-uuid'; import { GetPacketStatusDepends } from '@/onebot/action/packet/GetPacketStatus'; import { z } from 'zod'; -import { coerce } from '@/common/coerce'; +import { actionType } from '@/common/coerce'; const SchemaData = z.object({ - group_id: coerce.string(), - file_id: coerce.string(), - current_parent_directory: coerce.string(), - new_name: coerce.string(), + group_id: actionType.string(), + file_id: actionType.string(), + current_parent_directory: actionType.string(), + new_name: actionType.string(), }); type Payload = z.infer; diff --git a/src/onebot/action/extends/SendPacket.ts b/src/onebot/action/extends/SendPacket.ts index feeb4d34..27c133ad 100644 --- a/src/onebot/action/extends/SendPacket.ts +++ b/src/onebot/action/extends/SendPacket.ts @@ -2,12 +2,12 @@ import { PacketHexStr } from '@/core/packet/transformer/base'; import { GetPacketStatusDepends } from '@/onebot/action/packet/GetPacketStatus'; import { ActionName } from '@/onebot/action/router'; import { z } from 'zod'; -import { coerce } from '@/common/coerce'; +import { actionType } from '@/common/coerce'; const SchemaData = z.object({ - cmd: coerce.string(), - data: coerce.string(), - rsp: coerce.boolean().default(true), + cmd: actionType.string(), + data: actionType.string(), + rsp: actionType.boolean().default(true), }); type Payload = z.infer; diff --git a/src/onebot/action/extends/SetDiyOnlineStatus.ts b/src/onebot/action/extends/SetDiyOnlineStatus.ts index d63895c8..43bffa63 100644 --- a/src/onebot/action/extends/SetDiyOnlineStatus.ts +++ b/src/onebot/action/extends/SetDiyOnlineStatus.ts @@ -1,11 +1,11 @@ import { OneBotAction } from '@/onebot/action/OneBotAction'; import { ActionName } from '@/onebot/action/router'; import { z } from 'zod'; -import { coerce } from '@/common/coerce'; +import { actionType } from '@/common/coerce'; const SchemaData = z.object({ - face_id: coerce.string(),// 参考 face_config.json 的 QSid - face_type: coerce.string().default('1'), - wording: coerce.string().default(' '), + face_id: actionType.string(),// 参考 face_config.json 的 QSid + face_type: actionType.string().default('1'), + wording: actionType.string().default(' '), }); type Payload = z.infer; diff --git a/src/onebot/action/extends/SetGroupRemark.ts b/src/onebot/action/extends/SetGroupRemark.ts index ab6367ea..d5b7b6a0 100644 --- a/src/onebot/action/extends/SetGroupRemark.ts +++ b/src/onebot/action/extends/SetGroupRemark.ts @@ -1,10 +1,10 @@ import { OneBotAction } from '@/onebot/action/OneBotAction'; import { ActionName } from '@/onebot/action/router'; import { z } from 'zod'; -import { coerce } from '@/common/coerce'; +import { actionType } from '@/common/coerce'; const SchemaData = z.object({ - group_id: coerce.string(), - remark: coerce.string(), + group_id: actionType.string(), + remark: actionType.string(), }); type Payload = z.infer; diff --git a/src/onebot/action/extends/SetGroupSign.ts b/src/onebot/action/extends/SetGroupSign.ts index 82c62fd5..56fdf534 100644 --- a/src/onebot/action/extends/SetGroupSign.ts +++ b/src/onebot/action/extends/SetGroupSign.ts @@ -1,9 +1,9 @@ import { GetPacketStatusDepends } from '@/onebot/action/packet/GetPacketStatus'; import { ActionName } from '@/onebot/action/router'; import { z } from 'zod'; -import { coerce } from '@/common/coerce'; +import { actionType } from '@/common/coerce'; const SchemaData = z.object({ - group_id: coerce.string(), + group_id: actionType.string(), }); type Payload = z.infer; diff --git a/src/onebot/action/extends/SetInputStatus.ts b/src/onebot/action/extends/SetInputStatus.ts index affc88df..98f28a94 100644 --- a/src/onebot/action/extends/SetInputStatus.ts +++ b/src/onebot/action/extends/SetInputStatus.ts @@ -2,10 +2,10 @@ import { OneBotAction } from '@/onebot/action/OneBotAction'; import { ActionName } from '@/onebot/action/router'; import { ChatType } from '@/core'; import { z } from 'zod'; -import { coerce } from '@/common/coerce'; +import { actionType } from '@/common/coerce'; const SchemaData = z.object({ - user_id: coerce.string(), - event_type: coerce.number(), + user_id: actionType.string(), + event_type: actionType.number(), }); type Payload = z.infer; diff --git a/src/onebot/action/extends/SetLongNick.ts b/src/onebot/action/extends/SetLongNick.ts index 090f0fb4..4b05825b 100644 --- a/src/onebot/action/extends/SetLongNick.ts +++ b/src/onebot/action/extends/SetLongNick.ts @@ -1,9 +1,9 @@ import { OneBotAction } from '@/onebot/action/OneBotAction'; import { ActionName } from '@/onebot/action/router'; import { z } from 'zod'; -import { coerce } from '@/common/coerce'; +import { actionType } from '@/common/coerce'; const SchemaData = z.object({ - longNick: coerce.string(), + longNick: actionType.string(), }); type Payload = z.infer; diff --git a/src/onebot/action/extends/SetOnlineStatus.ts b/src/onebot/action/extends/SetOnlineStatus.ts index 414c16ee..e863b4ae 100644 --- a/src/onebot/action/extends/SetOnlineStatus.ts +++ b/src/onebot/action/extends/SetOnlineStatus.ts @@ -1,11 +1,11 @@ import { OneBotAction } from '@/onebot/action/OneBotAction'; import { ActionName } from '@/onebot/action/router'; import { z } from 'zod'; -import { coerce } from '@/common/coerce'; +import { actionType } from '@/common/coerce'; const SchemaData = z.object({ - status: coerce.number(), - ext_status: coerce.number(), - battery_status: coerce.number(), + status: actionType.number(), + ext_status: actionType.number(), + battery_status: actionType.number(), }); type Payload = z.infer; diff --git a/src/onebot/action/extends/SetQQAvatar.ts b/src/onebot/action/extends/SetQQAvatar.ts index 17832c4c..767a5c3b 100644 --- a/src/onebot/action/extends/SetQQAvatar.ts +++ b/src/onebot/action/extends/SetQQAvatar.ts @@ -3,9 +3,9 @@ import { ActionName } from '@/onebot/action/router'; import fs from 'node:fs/promises'; import { checkFileExist, uriToLocalFile } from '@/common/file'; import { z } from 'zod'; -import { coerce } from '@/common/coerce'; +import { actionType } from '@/common/coerce'; const SchemaData = z.object({ - file: coerce.string(), + file: actionType.string(), }); type Payload = z.infer; diff --git a/src/onebot/action/extends/SetSpecialTitle.ts b/src/onebot/action/extends/SetSpecialTitle.ts index 6dca5fd7..efa4000b 100644 --- a/src/onebot/action/extends/SetSpecialTitle.ts +++ b/src/onebot/action/extends/SetSpecialTitle.ts @@ -1,11 +1,11 @@ import { ActionName } from '@/onebot/action/router'; import { GetPacketStatusDepends } from '@/onebot/action/packet/GetPacketStatus'; import { z } from 'zod'; -import { coerce } from '@/common/coerce'; +import { actionType } from '@/common/coerce'; const SchemaData = z.object({ - group_id: coerce.string(), - user_id: coerce.string(), - special_title: coerce.string().default(''), + group_id: actionType.string(), + user_id: actionType.string(), + special_title: actionType.string().default(''), }); type Payload = z.infer; diff --git a/src/onebot/action/extends/ShareContact.ts b/src/onebot/action/extends/ShareContact.ts index 3a61fdf0..571bbdb7 100644 --- a/src/onebot/action/extends/ShareContact.ts +++ b/src/onebot/action/extends/ShareContact.ts @@ -2,11 +2,11 @@ import { GeneralCallResult } from '@/core'; import { OneBotAction } from '@/onebot/action/OneBotAction'; import { ActionName } from '@/onebot/action/router'; import { z } from 'zod'; -import { coerce } from '@/common/coerce'; +import { actionType } from '@/common/coerce'; const SchemaData = z.object({ - user_id: coerce.string().optional(), - group_id: coerce.string().optional(), - phoneNumber: coerce.string().default(''), + user_id: actionType.string().optional(), + group_id: actionType.string().optional(), + phoneNumber: actionType.string().default(''), }); type Payload = z.infer; @@ -29,7 +29,7 @@ export class SharePeer extends OneBotAction; diff --git a/src/onebot/action/extends/TransGroupFile.ts b/src/onebot/action/extends/TransGroupFile.ts index 2c801334..bd5045a0 100644 --- a/src/onebot/action/extends/TransGroupFile.ts +++ b/src/onebot/action/extends/TransGroupFile.ts @@ -2,10 +2,10 @@ import { ActionName } from '@/onebot/action/router'; import { FileNapCatOneBotUUID } from '@/common/file-uuid'; import { GetPacketStatusDepends } from '@/onebot/action/packet/GetPacketStatus'; import { z } from 'zod'; -import { coerce } from '@/common/coerce'; +import { actionType } from '@/common/coerce'; const SchemaData = z.object({ - group_id: coerce.string(), - file_id: coerce.string(), + group_id: actionType.string(), + file_id: actionType.string(), }); type Payload = z.infer; diff --git a/src/onebot/action/extends/TranslateEnWordToZn.ts b/src/onebot/action/extends/TranslateEnWordToZn.ts index 9c2e064e..ff27a83f 100644 --- a/src/onebot/action/extends/TranslateEnWordToZn.ts +++ b/src/onebot/action/extends/TranslateEnWordToZn.ts @@ -1,9 +1,9 @@ import { OneBotAction } from '@/onebot/action/OneBotAction'; import { ActionName } from '@/onebot/action/router'; import { z } from 'zod'; -import { coerce } from '@/common/coerce'; +import { actionType } from '@/common/coerce'; const SchemaData = z.object({ - words: z.array(coerce.string()), + words: z.array(actionType.string()), }); type Payload = z.infer; diff --git a/src/onebot/action/file/GetFile.ts b/src/onebot/action/file/GetFile.ts index 9a6dbe8d..55725be9 100644 --- a/src/onebot/action/file/GetFile.ts +++ b/src/onebot/action/file/GetFile.ts @@ -4,7 +4,7 @@ import { FileNapCatOneBotUUID } from '@/common/file-uuid'; import { ActionName } from '@/onebot/action/router'; import { OB11MessageImage, OB11MessageVideo } from '@/onebot/types'; import { z } from 'zod'; -import { coerce } from '@/common/coerce'; +import { actionType } from '@/common/coerce'; export interface GetFileResponse { file?: string; // path url?: string; @@ -14,8 +14,8 @@ export interface GetFileResponse { } const GetFileBase_PayloadSchema = z.object({ - file: coerce.string().optional(), - file_id: coerce.string().optional(), + file: actionType.string().optional(), + file_id: actionType.string().optional(), }); diff --git a/src/onebot/action/file/GetGroupFileUrl.ts b/src/onebot/action/file/GetGroupFileUrl.ts index df0e66d4..c90103e5 100644 --- a/src/onebot/action/file/GetGroupFileUrl.ts +++ b/src/onebot/action/file/GetGroupFileUrl.ts @@ -2,10 +2,10 @@ import { ActionName } from '@/onebot/action/router'; import { FileNapCatOneBotUUID } from '@/common/file-uuid'; import { GetPacketStatusDepends } from '@/onebot/action/packet/GetPacketStatus'; import { z } from 'zod'; -import { coerce } from '@/common/coerce'; +import { actionType } from '@/common/coerce'; const SchemaData = z.object({ - group_id: coerce.string(), - file_id: coerce.string(), + group_id: actionType.string(), + file_id: actionType.string(), }); type Payload = z.infer; diff --git a/src/onebot/action/file/GetPrivateFileUrl.ts b/src/onebot/action/file/GetPrivateFileUrl.ts index c830397f..04b9bf1a 100644 --- a/src/onebot/action/file/GetPrivateFileUrl.ts +++ b/src/onebot/action/file/GetPrivateFileUrl.ts @@ -2,9 +2,9 @@ import { ActionName } from '@/onebot/action/router'; import { FileNapCatOneBotUUID } from '@/common/file-uuid'; import { GetPacketStatusDepends } from '@/onebot/action/packet/GetPacketStatus'; import { z } from 'zod'; -import { coerce } from '@/common/coerce'; +import { actionType } from '@/common/coerce'; const SchemaData = z.object({ - file_id: coerce.string(), + file_id: actionType.string(), }); type Payload = z.infer; diff --git a/src/onebot/action/go-cqhttp/CreateGroupFileFolder.ts b/src/onebot/action/go-cqhttp/CreateGroupFileFolder.ts index 0c9d53c6..91e3e522 100644 --- a/src/onebot/action/go-cqhttp/CreateGroupFileFolder.ts +++ b/src/onebot/action/go-cqhttp/CreateGroupFileFolder.ts @@ -1,10 +1,10 @@ import { OneBotAction } from '@/onebot/action/OneBotAction'; import { ActionName } from '@/onebot/action/router'; import { z } from 'zod'; -import { coerce } from '@/common/coerce'; +import { actionType } from '@/common/coerce'; const SchemaData = z.object({ - group_id: coerce.string(), - folder_name: coerce.string(), + group_id: actionType.string(), + folder_name: actionType.string(), }); type Payload = z.infer; diff --git a/src/onebot/action/go-cqhttp/DeleteGroupFile.ts b/src/onebot/action/go-cqhttp/DeleteGroupFile.ts index 5e21d1a8..addee6b9 100644 --- a/src/onebot/action/go-cqhttp/DeleteGroupFile.ts +++ b/src/onebot/action/go-cqhttp/DeleteGroupFile.ts @@ -4,10 +4,10 @@ import { ActionName } from '@/onebot/action/router'; import { FileNapCatOneBotUUID } from '@/common/file-uuid'; import { z } from 'zod'; import { NTQQGroupApi } from '@/core/apis'; -import { coerce } from '@/common/coerce'; +import { actionType } from '@/common/coerce'; const SchemaData = z.object({ - group_id: coerce.string(), - file_id: coerce.string(), + group_id: actionType.string(), + file_id: actionType.string(), }); type Payload = z.infer; diff --git a/src/onebot/action/go-cqhttp/DeleteGroupFileFolder.ts b/src/onebot/action/go-cqhttp/DeleteGroupFileFolder.ts index b7f6cf1f..be39f476 100644 --- a/src/onebot/action/go-cqhttp/DeleteGroupFileFolder.ts +++ b/src/onebot/action/go-cqhttp/DeleteGroupFileFolder.ts @@ -2,11 +2,11 @@ import { ActionName } from '@/onebot/action/router'; import { OneBotAction } from '@/onebot/action/OneBotAction'; import { z } from 'zod'; import { NTQQGroupApi } from '@/core/apis'; -import { coerce } from '@/common/coerce'; +import { actionType } from '@/common/coerce'; const SchemaData = z.object({ - group_id: coerce.string(), - folder_id: coerce.string().optional(), - folder: coerce.string().optional(), + group_id: actionType.string(), + folder_id: actionType.string().optional(), + folder: actionType.string().optional(), }); type Payload = z.infer; diff --git a/src/onebot/action/go-cqhttp/DownloadFile.ts b/src/onebot/action/go-cqhttp/DownloadFile.ts index 4b0e0b74..d6288661 100644 --- a/src/onebot/action/go-cqhttp/DownloadFile.ts +++ b/src/onebot/action/go-cqhttp/DownloadFile.ts @@ -5,16 +5,16 @@ import { join as joinPath } from 'node:path'; import { calculateFileMD5, uriToLocalFile } from '@/common/file'; import { randomUUID } from 'crypto'; import { z } from 'zod'; -import { coerce } from '@/common/coerce'; +import { actionType } from '@/common/coerce'; interface FileResponse { file: string; } const SchemaData = z.object({ - url: coerce.string().optional(), - base64: coerce.string().optional(), - name: coerce.string().optional(), - headers: z.union([coerce.string(), z.array(coerce.string())]).optional(), + url: actionType.string().optional(), + base64: actionType.string().optional(), + name: actionType.string().optional(), + headers: z.union([actionType.string(), z.array(actionType.string())]).optional(), }); type Payload = z.infer; diff --git a/src/onebot/action/go-cqhttp/GetForwardMsg.ts b/src/onebot/action/go-cqhttp/GetForwardMsg.ts index 95eb9eae..d49baefd 100644 --- a/src/onebot/action/go-cqhttp/GetForwardMsg.ts +++ b/src/onebot/action/go-cqhttp/GetForwardMsg.ts @@ -5,10 +5,10 @@ import { MessageUnique } from '@/common/message-unique'; import { ChatType, ElementType, MsgSourceType, NTMsgType, RawMessage } from '@/core'; import { z } from 'zod'; import { isNumeric } from '@/common/helper'; -import { coerce } from '@/common/coerce'; +import { actionType } from '@/common/coerce'; const SchemaData = z.object({ - message_id: coerce.string().optional(), - id: coerce.string().optional(), + message_id: actionType.string().optional(), + id: actionType.string().optional(), }); type Payload = z.infer; diff --git a/src/onebot/action/go-cqhttp/GetFriendMsgHistory.ts b/src/onebot/action/go-cqhttp/GetFriendMsgHistory.ts index 84e1437e..2c0d4ecc 100644 --- a/src/onebot/action/go-cqhttp/GetFriendMsgHistory.ts +++ b/src/onebot/action/go-cqhttp/GetFriendMsgHistory.ts @@ -5,16 +5,16 @@ import { ChatType } from '@/core/types'; import { MessageUnique } from '@/common/message-unique'; import { z } from 'zod'; import { NetworkAdapterConfig } from '@/onebot/config/config'; -import { coerce } from '@/common/coerce'; +import { actionType } from '@/common/coerce'; interface Response { messages: OB11Message[]; } const SchemaData = z.object({ - user_id: coerce.string(), - message_seq: coerce.string().optional(), - count: coerce.number().default(20), - reverseOrder: coerce.boolean().default(false) + user_id: actionType.string(), + message_seq: actionType.string().optional(), + count: actionType.number().default(20), + reverseOrder: actionType.boolean().default(false) }); diff --git a/src/onebot/action/go-cqhttp/GetGroupAtAllRemain.ts b/src/onebot/action/go-cqhttp/GetGroupAtAllRemain.ts index 8846266b..6149aa51 100644 --- a/src/onebot/action/go-cqhttp/GetGroupAtAllRemain.ts +++ b/src/onebot/action/go-cqhttp/GetGroupAtAllRemain.ts @@ -1,9 +1,9 @@ import { OneBotAction } from '@/onebot/action/OneBotAction'; import { ActionName } from '@/onebot/action/router'; import { z } from 'zod'; -import { coerce } from '@/common/coerce'; +import { actionType } from '@/common/coerce'; const SchemaData = z.object({ - group_id: coerce.string() + group_id: actionType.string() }); type Payload = z.infer; diff --git a/src/onebot/action/go-cqhttp/GetGroupFileSystemInfo.ts b/src/onebot/action/go-cqhttp/GetGroupFileSystemInfo.ts index ac476100..69c1edf4 100644 --- a/src/onebot/action/go-cqhttp/GetGroupFileSystemInfo.ts +++ b/src/onebot/action/go-cqhttp/GetGroupFileSystemInfo.ts @@ -1,9 +1,9 @@ import { OneBotAction } from '@/onebot/action/OneBotAction'; import { ActionName } from '@/onebot/action/router'; import { z } from 'zod'; -import { coerce } from '@/common/coerce'; +import { actionType } from '@/common/coerce'; const SchemaData = z.object({ - group_id: coerce.string() + group_id: actionType.string() }); type Payload = z.infer; diff --git a/src/onebot/action/go-cqhttp/GetGroupFilesByFolder.ts b/src/onebot/action/go-cqhttp/GetGroupFilesByFolder.ts index f6854074..93d70073 100644 --- a/src/onebot/action/go-cqhttp/GetGroupFilesByFolder.ts +++ b/src/onebot/action/go-cqhttp/GetGroupFilesByFolder.ts @@ -3,12 +3,12 @@ import { OneBotAction } from '@/onebot/action/OneBotAction'; import { ActionName } from '@/onebot/action/router'; import { OB11Construct } from '@/onebot/helper/data'; import { z } from 'zod'; -import { coerce } from '@/common/coerce'; +import { actionType } from '@/common/coerce'; const SchemaData = z.object({ - group_id: coerce.string(), - folder_id: coerce.string().optional(), - folder: coerce.string().optional(), - file_count: coerce.number().default(50), + group_id: actionType.string(), + folder_id: actionType.string().optional(), + folder: actionType.string().optional(), + file_count: actionType.number().default(50), }); type Payload = z.infer; diff --git a/src/onebot/action/go-cqhttp/GetGroupHonorInfo.ts b/src/onebot/action/go-cqhttp/GetGroupHonorInfo.ts index 0a4c172b..b22c77b8 100644 --- a/src/onebot/action/go-cqhttp/GetGroupHonorInfo.ts +++ b/src/onebot/action/go-cqhttp/GetGroupHonorInfo.ts @@ -2,9 +2,9 @@ import { WebHonorType } from '@/core'; import { OneBotAction } from '@/onebot/action/OneBotAction'; import { ActionName } from '@/onebot/action/router'; import { z } from 'zod'; -import { coerce } from '@/common/coerce'; +import { actionType } from '@/common/coerce'; const SchemaData = z.object({ - group_id: coerce.string(), + group_id: actionType.string(), type: z.nativeEnum(WebHonorType).optional() }); diff --git a/src/onebot/action/go-cqhttp/GetGroupMsgHistory.ts b/src/onebot/action/go-cqhttp/GetGroupMsgHistory.ts index d0203f84..bde27c1a 100644 --- a/src/onebot/action/go-cqhttp/GetGroupMsgHistory.ts +++ b/src/onebot/action/go-cqhttp/GetGroupMsgHistory.ts @@ -5,17 +5,17 @@ import { ChatType, Peer } from '@/core/types'; import { MessageUnique } from '@/common/message-unique'; import { z } from 'zod'; import { NetworkAdapterConfig } from '@/onebot/config/config'; -import { coerce } from '@/common/coerce'; +import { actionType } from '@/common/coerce'; interface Response { messages: OB11Message[]; } const SchemaData = z.object({ - group_id: coerce.string(), - message_seq: coerce.string().optional(), - count: coerce.number().default(20), - reverseOrder: coerce.boolean().default(false) + group_id: actionType.string(), + message_seq: actionType.string().optional(), + count: actionType.number().default(20), + reverseOrder: actionType.boolean().default(false) }); diff --git a/src/onebot/action/go-cqhttp/GetGroupRootFiles.ts b/src/onebot/action/go-cqhttp/GetGroupRootFiles.ts index 3e8b4698..613bac17 100644 --- a/src/onebot/action/go-cqhttp/GetGroupRootFiles.ts +++ b/src/onebot/action/go-cqhttp/GetGroupRootFiles.ts @@ -4,10 +4,10 @@ import { ActionName } from '@/onebot/action/router'; import { OB11GroupFile, OB11GroupFileFolder } from '@/onebot'; import { OB11Construct } from '@/onebot/helper/data'; import { z } from 'zod'; -import { coerce } from '@/common/coerce'; +import { actionType } from '@/common/coerce'; const SchemaData = z.object({ - group_id: coerce.string(), - file_count: coerce.number().default(50), + group_id: actionType.string(), + file_count: actionType.number().default(50), }); type Payload = z.infer; diff --git a/src/onebot/action/go-cqhttp/GetStrangerInfo.ts b/src/onebot/action/go-cqhttp/GetStrangerInfo.ts index b0c0c96e..aa628283 100644 --- a/src/onebot/action/go-cqhttp/GetStrangerInfo.ts +++ b/src/onebot/action/go-cqhttp/GetStrangerInfo.ts @@ -4,11 +4,11 @@ import { OB11Construct } from '@/onebot/helper/data'; import { ActionName } from '@/onebot/action/router'; import { calcQQLevel } from '@/common/helper'; import { z } from 'zod'; -import { coerce } from '@/common/coerce'; +import { actionType } from '@/common/coerce'; const SchemaData = z.object({ - user_id: coerce.string(), - no_cache: coerce.boolean().default(false), + user_id: actionType.string(), + no_cache: actionType.boolean().default(false), }); type Payload = z.infer; diff --git a/src/onebot/action/go-cqhttp/GoCQHTTPCheckUrlSafely.ts b/src/onebot/action/go-cqhttp/GoCQHTTPCheckUrlSafely.ts index 29811f4c..997a1630 100644 --- a/src/onebot/action/go-cqhttp/GoCQHTTPCheckUrlSafely.ts +++ b/src/onebot/action/go-cqhttp/GoCQHTTPCheckUrlSafely.ts @@ -1,9 +1,9 @@ import { OneBotAction } from '@/onebot/action/OneBotAction'; import { ActionName } from '@/onebot/action/router'; import { z } from 'zod'; -import { coerce } from '@/common/coerce'; +import { actionType } from '@/common/coerce'; const SchemaData = z.object({ - url: coerce.string(), + url: actionType.string(), }); type Payload = z.infer; diff --git a/src/onebot/action/go-cqhttp/GoCQHTTPDeleteFriend.ts b/src/onebot/action/go-cqhttp/GoCQHTTPDeleteFriend.ts index 427734dc..079f681f 100644 --- a/src/onebot/action/go-cqhttp/GoCQHTTPDeleteFriend.ts +++ b/src/onebot/action/go-cqhttp/GoCQHTTPDeleteFriend.ts @@ -1,13 +1,13 @@ import { OneBotAction } from '@/onebot/action/OneBotAction'; import { ActionName } from '@/onebot/action/router'; import { z } from 'zod'; -import { coerce } from '@/common/coerce'; +import { actionType } from '@/common/coerce'; const SchemaData = z.object({ - friend_id: coerce.string().optional(), - user_id: coerce.string().optional(), - temp_block: coerce.boolean().optional(), - temp_both_del: coerce.boolean().optional(), + friend_id: actionType.string().optional(), + user_id: actionType.string().optional(), + temp_block: actionType.boolean().optional(), + temp_both_del: actionType.boolean().optional(), }); type Payload = z.infer; diff --git a/src/onebot/action/go-cqhttp/GoCQHTTPGetModelShow.ts b/src/onebot/action/go-cqhttp/GoCQHTTPGetModelShow.ts index 15c4069e..bbcce797 100644 --- a/src/onebot/action/go-cqhttp/GoCQHTTPGetModelShow.ts +++ b/src/onebot/action/go-cqhttp/GoCQHTTPGetModelShow.ts @@ -1,9 +1,9 @@ import { OneBotAction } from '@/onebot/action/OneBotAction'; import { ActionName } from '@/onebot/action/router'; import { z } from 'zod'; -import { coerce } from '@/common/coerce'; +import { actionType } from '@/common/coerce'; const SchemaData = z.object({ - model: coerce.string(), + model: actionType.string(), }); type Payload = z.infer; diff --git a/src/onebot/action/go-cqhttp/SendGroupNotice.ts b/src/onebot/action/go-cqhttp/SendGroupNotice.ts index be63a1ae..e309397c 100644 --- a/src/onebot/action/go-cqhttp/SendGroupNotice.ts +++ b/src/onebot/action/go-cqhttp/SendGroupNotice.ts @@ -3,16 +3,16 @@ import { OneBotAction } from '@/onebot/action/OneBotAction'; import { ActionName } from '@/onebot/action/router'; import { unlink } from 'node:fs/promises'; import { z } from 'zod'; -import { coerce } from '@/common/coerce'; +import { actionType } from '@/common/coerce'; const SchemaData = z.object({ - group_id: coerce.string(), - content: coerce.string(), - image: coerce.string().optional(), - pinned: coerce.number().default(0), - type: coerce.number().default(1), - confirm_required: coerce.number().default(1), - is_show_edit_card: coerce.number().default(0), - tip_window_type: coerce.number().default(0), + group_id: actionType.string(), + content: actionType.string(), + image: actionType.string().optional(), + pinned: actionType.number().default(0), + type: actionType.number().default(1), + confirm_required: actionType.number().default(1), + is_show_edit_card: actionType.number().default(0), + tip_window_type: actionType.number().default(0), }); type Payload = z.infer; diff --git a/src/onebot/action/go-cqhttp/SetGroupPortrait.ts b/src/onebot/action/go-cqhttp/SetGroupPortrait.ts index 3d83921e..af178e9b 100644 --- a/src/onebot/action/go-cqhttp/SetGroupPortrait.ts +++ b/src/onebot/action/go-cqhttp/SetGroupPortrait.ts @@ -4,10 +4,10 @@ import { checkFileExistV2, uriToLocalFile } from '@/common/file'; import { z } from 'zod'; import fs from 'node:fs/promises'; import { GeneralCallResult } from '@/core'; -import { coerce } from '@/common/coerce'; +import { actionType } from '@/common/coerce'; const SchemaData = z.object({ - file: coerce.string(), - group_id: coerce.string() + file: actionType.string(), + group_id: actionType.string() }); type Payload = z.infer; diff --git a/src/onebot/action/go-cqhttp/SetQQProfile.ts b/src/onebot/action/go-cqhttp/SetQQProfile.ts index ae458c72..28bffd6a 100644 --- a/src/onebot/action/go-cqhttp/SetQQProfile.ts +++ b/src/onebot/action/go-cqhttp/SetQQProfile.ts @@ -2,11 +2,11 @@ import { NTQQUserApi } from '@/core/apis'; import { OneBotAction } from '@/onebot/action/OneBotAction'; import { ActionName } from '@/onebot/action/router'; import { z } from 'zod'; -import { coerce } from '@/common/coerce'; +import { actionType } from '@/common/coerce'; const SchemaData = z.object({ - nickname: coerce.string(), - personal_note: coerce.string().optional(), - sex: coerce.string().optional(), // 传Sex值?建议传0 + nickname: actionType.string(), + personal_note: actionType.string().optional(), + sex: actionType.string().optional(), // 传Sex值?建议传0 }); type Payload = z.infer; diff --git a/src/onebot/action/go-cqhttp/UploadGroupFile.ts b/src/onebot/action/go-cqhttp/UploadGroupFile.ts index e253bd09..195df4b9 100644 --- a/src/onebot/action/go-cqhttp/UploadGroupFile.ts +++ b/src/onebot/action/go-cqhttp/UploadGroupFile.ts @@ -5,13 +5,13 @@ import fs from 'fs'; import { uriToLocalFile } from '@/common/file'; import { SendMessageContext } from '@/onebot/api'; import { z } from 'zod'; -import { coerce } from '@/common/coerce'; +import { actionType } from '@/common/coerce'; const SchemaData = z.object({ - group_id: coerce.string(), - file: coerce.string(), - name: coerce.string(), - folder: coerce.string().optional(), - folder_id: coerce.string().optional(),//临时扩展 + group_id: actionType.string(), + file: actionType.string(), + name: actionType.string(), + folder: actionType.string().optional(), + folder_id: actionType.string().optional(),//临时扩展 }); type Payload = z.infer; diff --git a/src/onebot/action/go-cqhttp/UploadPrivateFile.ts b/src/onebot/action/go-cqhttp/UploadPrivateFile.ts index 6d1d240f..7de40188 100644 --- a/src/onebot/action/go-cqhttp/UploadPrivateFile.ts +++ b/src/onebot/action/go-cqhttp/UploadPrivateFile.ts @@ -6,11 +6,11 @@ import { uriToLocalFile } from '@/common/file'; import { SendMessageContext } from '@/onebot/api'; import { ContextMode, createContext } from '@/onebot/action/msg/SendMsg'; import { z } from 'zod'; -import { coerce } from '@/common/coerce'; +import { actionType } from '@/common/coerce'; const SchemaData = z.object({ - user_id: coerce.string(), - file: coerce.string(), - name: coerce.string(), + user_id: actionType.string(), + file: actionType.string(), + name: actionType.string(), }); type Payload = z.infer; diff --git a/src/onebot/action/group/DelEssenceMsg.ts b/src/onebot/action/group/DelEssenceMsg.ts index 2cc5957f..846aced1 100644 --- a/src/onebot/action/group/DelEssenceMsg.ts +++ b/src/onebot/action/group/DelEssenceMsg.ts @@ -2,9 +2,9 @@ import { OneBotAction } from '@/onebot/action/OneBotAction'; import { ActionName } from '@/onebot/action/router'; import { MessageUnique } from '@/common/message-unique'; import { z } from 'zod'; -import { coerce } from '@/common/coerce'; +import { actionType } from '@/common/coerce'; const SchemaData = z.object({ - message_id: coerce.string(), + message_id: actionType.string(), }); type Payload = z.infer; diff --git a/src/onebot/action/group/DelGroupNotice.ts b/src/onebot/action/group/DelGroupNotice.ts index 2737003f..b012f87d 100644 --- a/src/onebot/action/group/DelGroupNotice.ts +++ b/src/onebot/action/group/DelGroupNotice.ts @@ -1,10 +1,10 @@ import { OneBotAction } from '@/onebot/action/OneBotAction'; import { ActionName } from '@/onebot/action/router'; import { z } from 'zod'; -import { coerce } from '@/common/coerce'; +import { actionType } from '@/common/coerce'; const SchemaData = z.object({ - group_id: coerce.string(), - notice_id: coerce.string() + group_id: actionType.string(), + notice_id: actionType.string() }); type Payload = z.infer; diff --git a/src/onebot/action/group/GetAiRecord.ts b/src/onebot/action/group/GetAiRecord.ts index a02a6ddc..7e0d002c 100644 --- a/src/onebot/action/group/GetAiRecord.ts +++ b/src/onebot/action/group/GetAiRecord.ts @@ -2,11 +2,11 @@ import { ActionName } from '@/onebot/action/router'; import { GetPacketStatusDepends } from '@/onebot/action/packet/GetPacketStatus'; import { AIVoiceChatType } from '@/core/packet/entities/aiChat'; import { z } from 'zod'; -import { coerce } from '@/common/coerce'; +import { actionType } from '@/common/coerce'; const SchemaData = z.object({ - character: coerce.string(), - group_id: coerce.string(), - text: coerce.string(), + character: actionType.string(), + group_id: actionType.string(), + text: actionType.string(), }); type Payload = z.infer; diff --git a/src/onebot/action/group/GetGroupEssence.ts b/src/onebot/action/group/GetGroupEssence.ts index 4719ea2a..500d7dba 100644 --- a/src/onebot/action/group/GetGroupEssence.ts +++ b/src/onebot/action/group/GetGroupEssence.ts @@ -5,9 +5,9 @@ import { MessageUnique } from '@/common/message-unique'; import crypto from 'crypto'; import { z } from 'zod'; import { NetworkAdapterConfig } from '@/onebot/config/config'; -import { coerce } from '@/common/coerce'; +import { actionType } from '@/common/coerce'; const SchemaData = z.object({ - group_id: coerce.string(), + group_id: actionType.string(), }); type Payload = z.infer; diff --git a/src/onebot/action/group/GetGroupInfo.ts b/src/onebot/action/group/GetGroupInfo.ts index 7325c35f..f427c224 100644 --- a/src/onebot/action/group/GetGroupInfo.ts +++ b/src/onebot/action/group/GetGroupInfo.ts @@ -3,9 +3,9 @@ import { OB11Construct } from '@/onebot/helper/data'; import { OneBotAction } from '@/onebot/action/OneBotAction'; import { ActionName } from '@/onebot/action/router'; import { z } from 'zod'; -import { coerce } from '@/common/coerce'; +import { actionType } from '@/common/coerce'; const SchemaData = z.object({ - group_id: coerce.string(), + group_id: actionType.string(), }); type Payload = z.infer; diff --git a/src/onebot/action/group/GetGroupList.ts b/src/onebot/action/group/GetGroupList.ts index 4710f6d2..648d6cdc 100644 --- a/src/onebot/action/group/GetGroupList.ts +++ b/src/onebot/action/group/GetGroupList.ts @@ -3,10 +3,10 @@ import { OB11Construct } from '@/onebot/helper/data'; import { OneBotAction } from '@/onebot/action/OneBotAction'; import { ActionName } from '@/onebot/action/router'; import { z } from 'zod'; -import { coerce } from '@/common/coerce'; +import { actionType } from '@/common/coerce'; const SchemaData = z.object({ - no_cache: coerce.boolean().default(false), + no_cache: actionType.boolean().default(false), }); type Payload = z.infer; diff --git a/src/onebot/action/group/GetGroupMemberInfo.ts b/src/onebot/action/group/GetGroupMemberInfo.ts index dc8cc5c1..b1925fd6 100644 --- a/src/onebot/action/group/GetGroupMemberInfo.ts +++ b/src/onebot/action/group/GetGroupMemberInfo.ts @@ -3,12 +3,12 @@ import { OB11Construct } from '@/onebot/helper/data'; import { OneBotAction } from '@/onebot/action/OneBotAction'; import { ActionName } from '@/onebot/action/router'; import { z } from 'zod'; -import { coerce } from '@/common/coerce'; +import { actionType } from '@/common/coerce'; const SchemaData = z.object({ - group_id: coerce.string(), - user_id: coerce.string(), - no_cache: coerce.boolean().default(false), + group_id: actionType.string(), + user_id: actionType.string(), + no_cache: actionType.boolean().default(false), }); type Payload = z.infer; diff --git a/src/onebot/action/group/GetGroupMemberList.ts b/src/onebot/action/group/GetGroupMemberList.ts index 54fd3fbb..909392ba 100644 --- a/src/onebot/action/group/GetGroupMemberList.ts +++ b/src/onebot/action/group/GetGroupMemberList.ts @@ -4,11 +4,11 @@ import { OneBotAction } from '@/onebot/action/OneBotAction'; import { ActionName } from '@/onebot/action/router'; import { z } from 'zod'; import { GroupMember } from '@/core'; -import { coerce } from '@/common/coerce'; +import { actionType } from '@/common/coerce'; const SchemaData = z.object({ - group_id: coerce.string(), - no_cache: coerce.boolean().default(false) + group_id: actionType.string(), + no_cache: actionType.boolean().default(false) }); type Payload = z.infer; diff --git a/src/onebot/action/group/GetGroupNotice.ts b/src/onebot/action/group/GetGroupNotice.ts index d290e65d..86ef5b0c 100644 --- a/src/onebot/action/group/GetGroupNotice.ts +++ b/src/onebot/action/group/GetGroupNotice.ts @@ -2,7 +2,7 @@ import { WebApiGroupNoticeFeed } from '@/core'; import { OneBotAction } from '@/onebot/action/OneBotAction'; import { ActionName } from '@/onebot/action/router'; import { z } from 'zod'; -import { coerce } from '@/common/coerce'; +import { actionType } from '@/common/coerce'; interface GroupNotice { sender_id: number; publish_time: number; @@ -18,7 +18,7 @@ interface GroupNotice { } const SchemaData = z.object({ - group_id: coerce.string(), + group_id: actionType.string(), }); type Payload = z.infer; diff --git a/src/onebot/action/group/GetGroupShutList.ts b/src/onebot/action/group/GetGroupShutList.ts index de927f93..b65bacad 100644 --- a/src/onebot/action/group/GetGroupShutList.ts +++ b/src/onebot/action/group/GetGroupShutList.ts @@ -2,9 +2,9 @@ import { ShutUpGroupMember } from '@/core'; import { OneBotAction } from '@/onebot/action/OneBotAction'; import { ActionName } from '@/onebot/action/router'; import { z } from 'zod'; -import { coerce } from '@/common/coerce'; +import { actionType } from '@/common/coerce'; const SchemaData = z.object({ - group_id: coerce.string(), + group_id: actionType.string(), }); type Payload = z.infer; diff --git a/src/onebot/action/group/GroupPoke.ts b/src/onebot/action/group/GroupPoke.ts index 8a7ad66f..00c6fff8 100644 --- a/src/onebot/action/group/GroupPoke.ts +++ b/src/onebot/action/group/GroupPoke.ts @@ -1,10 +1,10 @@ import { ActionName } from '@/onebot/action/router'; import { GetPacketStatusDepends } from '@/onebot/action/packet/GetPacketStatus'; import { z } from 'zod'; -import { coerce } from '@/common/coerce'; +import { actionType } from '@/common/coerce'; const SchemaData = z.object({ - group_id: coerce.string(), - user_id: coerce.string(), + group_id: actionType.string(), + user_id: actionType.string(), }); type Payload = z.infer; diff --git a/src/onebot/action/group/SendGroupAiRecord.ts b/src/onebot/action/group/SendGroupAiRecord.ts index c0355a03..454f77be 100644 --- a/src/onebot/action/group/SendGroupAiRecord.ts +++ b/src/onebot/action/group/SendGroupAiRecord.ts @@ -2,11 +2,11 @@ import { ActionName } from '@/onebot/action/router'; import { GetPacketStatusDepends } from '@/onebot/action/packet/GetPacketStatus'; import { AIVoiceChatType } from '@/core/packet/entities/aiChat'; import { z } from 'zod'; -import { coerce } from '@/common/coerce'; +import { actionType } from '@/common/coerce'; const SchemaData = z.object({ - character: coerce.string(), - group_id: coerce.string(), - text: coerce.string(), + character: actionType.string(), + group_id: actionType.string(), + text: actionType.string(), }); type Payload = z.infer; diff --git a/src/onebot/action/group/SetEssenceMsg.ts b/src/onebot/action/group/SetEssenceMsg.ts index 6200a551..04026cd0 100644 --- a/src/onebot/action/group/SetEssenceMsg.ts +++ b/src/onebot/action/group/SetEssenceMsg.ts @@ -2,9 +2,9 @@ import { OneBotAction } from '@/onebot/action/OneBotAction'; import { ActionName } from '@/onebot/action/router'; import { MessageUnique } from '@/common/message-unique'; import { z } from 'zod'; -import { coerce } from '@/common/coerce'; +import { actionType } from '@/common/coerce'; const SchemaData = z.object({ - message_id: coerce.string(), + message_id: actionType.string(), }); type Payload = z.infer; diff --git a/src/onebot/action/group/SetGroupAddRequest.ts b/src/onebot/action/group/SetGroupAddRequest.ts index 747ed0a9..cabe123e 100644 --- a/src/onebot/action/group/SetGroupAddRequest.ts +++ b/src/onebot/action/group/SetGroupAddRequest.ts @@ -2,12 +2,12 @@ import { OneBotAction } from '@/onebot/action/OneBotAction'; import { NTGroupRequestOperateTypes } from '@/core/types'; import { ActionName } from '@/onebot/action/router'; import { z } from 'zod'; -import { coerce } from '@/common/coerce'; +import { actionType } from '@/common/coerce'; const SchemaData = z.object({ - flag: coerce.string(), - approve: coerce.boolean().default(true), - reason: coerce.string().nullable().default(' '), + flag: actionType.string(), + approve: actionType.boolean().default(true), + reason: actionType.string().nullable().default(' '), }); type Payload = z.infer; diff --git a/src/onebot/action/group/SetGroupAdmin.ts b/src/onebot/action/group/SetGroupAdmin.ts index dbc7e1cc..f690ba9f 100644 --- a/src/onebot/action/group/SetGroupAdmin.ts +++ b/src/onebot/action/group/SetGroupAdmin.ts @@ -2,12 +2,12 @@ import { OneBotAction } from '@/onebot/action/OneBotAction'; import { NTGroupMemberRole } from '@/core/types'; import { ActionName } from '@/onebot/action/router'; import { z } from 'zod'; -import { coerce } from '@/common/coerce'; +import { actionType } from '@/common/coerce'; const SchemaData = z.object({ - group_id: coerce.string(), - user_id: coerce.string(), - enable: coerce.boolean().default(false), + group_id: actionType.string(), + user_id: actionType.string(), + enable: actionType.boolean().default(false), }); type Payload = z.infer; diff --git a/src/onebot/action/group/SetGroupBan.ts b/src/onebot/action/group/SetGroupBan.ts index 0ac71142..c65d461c 100644 --- a/src/onebot/action/group/SetGroupBan.ts +++ b/src/onebot/action/group/SetGroupBan.ts @@ -1,11 +1,11 @@ import { OneBotAction } from '@/onebot/action/OneBotAction'; import { ActionName } from '@/onebot/action/router'; import { z } from 'zod'; -import { coerce } from '@/common/coerce'; +import { actionType } from '@/common/coerce'; const SchemaData = z.object({ - group_id: coerce.string(), - user_id: coerce.string(), - duration: coerce.number().default(0), + group_id: actionType.string(), + user_id: actionType.string(), + duration: actionType.number().default(0), }); type Payload = z.infer; diff --git a/src/onebot/action/group/SetGroupCard.ts b/src/onebot/action/group/SetGroupCard.ts index 467e2776..f0e0b53b 100644 --- a/src/onebot/action/group/SetGroupCard.ts +++ b/src/onebot/action/group/SetGroupCard.ts @@ -1,11 +1,11 @@ import { OneBotAction } from '@/onebot/action/OneBotAction'; import { ActionName } from '@/onebot/action/router'; import { z } from 'zod'; -import { coerce } from '@/common/coerce'; +import { actionType } from '@/common/coerce'; const SchemaData = z.object({ - group_id: coerce.string(), - user_id: coerce.string(), - card: coerce.string().optional(), + group_id: actionType.string(), + user_id: actionType.string(), + card: actionType.string().optional(), }); type Payload = z.infer; diff --git a/src/onebot/action/group/SetGroupKick.ts b/src/onebot/action/group/SetGroupKick.ts index 66b9cf33..08f6ec50 100644 --- a/src/onebot/action/group/SetGroupKick.ts +++ b/src/onebot/action/group/SetGroupKick.ts @@ -1,12 +1,12 @@ import { OneBotAction } from '@/onebot/action/OneBotAction'; import { ActionName } from '@/onebot/action/router'; import { z } from 'zod'; -import { coerce } from '@/common/coerce'; +import { actionType } from '@/common/coerce'; const SchemaData = z.object({ - group_id: coerce.string(), - user_id: coerce.string(), - reject_add_request: coerce.boolean().optional(), + group_id: actionType.string(), + user_id: actionType.string(), + reject_add_request: actionType.boolean().optional(), }); type Payload = z.infer; diff --git a/src/onebot/action/group/SetGroupLeave.ts b/src/onebot/action/group/SetGroupLeave.ts index 1f6ce77d..4823c6bb 100644 --- a/src/onebot/action/group/SetGroupLeave.ts +++ b/src/onebot/action/group/SetGroupLeave.ts @@ -1,11 +1,11 @@ import { OneBotAction } from '@/onebot/action/OneBotAction'; import { ActionName } from '@/onebot/action/router'; import { z } from 'zod'; -import { coerce } from '@/common/coerce'; +import { actionType } from '@/common/coerce'; const SchemaData = z.object({ - group_id: coerce.string(), - is_dismiss: coerce.boolean().optional(), + group_id: actionType.string(), + is_dismiss: actionType.boolean().optional(), }); type Payload = z.infer; diff --git a/src/onebot/action/group/SetGroupName.ts b/src/onebot/action/group/SetGroupName.ts index 54f620f7..bd644049 100644 --- a/src/onebot/action/group/SetGroupName.ts +++ b/src/onebot/action/group/SetGroupName.ts @@ -2,10 +2,10 @@ import { OneBotAction } from '@/onebot/action/OneBotAction'; import { ActionName } from '@/onebot/action/router'; import { z } from 'zod'; -import { coerce } from '@/common/coerce'; +import { actionType } from '@/common/coerce'; const SchemaData = z.object({ - group_id: coerce.string(), - group_name: coerce.string(), + group_id: actionType.string(), + group_name: actionType.string(), }); type Payload = z.infer; diff --git a/src/onebot/action/group/SetGroupWholeBan.ts b/src/onebot/action/group/SetGroupWholeBan.ts index 1d3f5d72..0e6c120c 100644 --- a/src/onebot/action/group/SetGroupWholeBan.ts +++ b/src/onebot/action/group/SetGroupWholeBan.ts @@ -1,11 +1,11 @@ import { OneBotAction } from '@/onebot/action/OneBotAction'; import { ActionName } from '@/onebot/action/router'; import { z } from 'zod'; -import { coerce } from '@/common/coerce'; +import { actionType } from '@/common/coerce'; const SchemaData = z.object({ - group_id: coerce.string(), - enable: coerce.boolean().optional(), + group_id: actionType.string(), + enable: actionType.boolean().optional(), }); type Payload = z.infer; diff --git a/src/onebot/action/msg/DeleteMsg.ts b/src/onebot/action/msg/DeleteMsg.ts index 92456e9e..b1305dcc 100644 --- a/src/onebot/action/msg/DeleteMsg.ts +++ b/src/onebot/action/msg/DeleteMsg.ts @@ -2,10 +2,10 @@ import { ActionName } from '@/onebot/action/router'; import { OneBotAction } from '@/onebot/action/OneBotAction'; import { MessageUnique } from '@/common/message-unique'; import { z } from 'zod'; -import { coerce } from '@/common/coerce'; +import { actionType } from '@/common/coerce'; const SchemaData = z.object({ - message_id: coerce.string(), + message_id: actionType.string(), }); type Payload = z.infer; diff --git a/src/onebot/action/msg/ForwardSingleMsg.ts b/src/onebot/action/msg/ForwardSingleMsg.ts index 4c4a0ae9..c7e2c245 100644 --- a/src/onebot/action/msg/ForwardSingleMsg.ts +++ b/src/onebot/action/msg/ForwardSingleMsg.ts @@ -3,11 +3,11 @@ import { ChatType, Peer } from '@/core/types'; import { ActionName } from '@/onebot/action/router'; import { MessageUnique } from '@/common/message-unique'; import { z } from 'zod'; -import { coerce } from '@/common/coerce'; +import { actionType } from '@/common/coerce'; const SchemaData = z.object({ - message_id: coerce.string(), - group_id: coerce.string().optional(), - user_id: coerce.string().optional(), + message_id: actionType.string(), + group_id: actionType.string().optional(), + user_id: actionType.string().optional(), }); type Payload = z.infer; diff --git a/src/onebot/action/msg/GetMsg.ts b/src/onebot/action/msg/GetMsg.ts index ece7efe8..ce287a5e 100644 --- a/src/onebot/action/msg/GetMsg.ts +++ b/src/onebot/action/msg/GetMsg.ts @@ -5,11 +5,11 @@ import { MessageUnique } from '@/common/message-unique'; import { RawMessage } from '@/core'; import { z } from 'zod'; import { NetworkAdapterConfig } from '@/onebot/config/config'; -import { coerce } from '@/common/coerce'; +import { actionType } from '@/common/coerce'; export type ReturnDataType = OB11Message const SchemaData = z.object({ - message_id: coerce.string(), + message_id: actionType.string(), }); type Payload = z.infer; diff --git a/src/onebot/action/msg/MarkMsgAsRead.ts b/src/onebot/action/msg/MarkMsgAsRead.ts index cde1d2fe..52ee09e1 100644 --- a/src/onebot/action/msg/MarkMsgAsRead.ts +++ b/src/onebot/action/msg/MarkMsgAsRead.ts @@ -3,11 +3,11 @@ import { OneBotAction } from '@/onebot/action/OneBotAction'; import { ActionName } from '@/onebot/action/router'; import { MessageUnique } from '@/common/message-unique'; import { z } from 'zod'; -import { coerce } from '@/common/coerce'; +import { actionType } from '@/common/coerce'; const SchemaData = z.object({ - user_id: coerce.string().optional(), - group_id: coerce.string().optional(), - message_id: coerce.string().optional(), + user_id: actionType.string().optional(), + group_id: actionType.string().optional(), + message_id: actionType.string().optional(), }); type PlayloadType = z.infer; diff --git a/src/onebot/action/msg/SetMsgEmojiLike.ts b/src/onebot/action/msg/SetMsgEmojiLike.ts index 42016090..1eb9eed8 100644 --- a/src/onebot/action/msg/SetMsgEmojiLike.ts +++ b/src/onebot/action/msg/SetMsgEmojiLike.ts @@ -2,12 +2,12 @@ import { ActionName } from '@/onebot/action/router'; import { OneBotAction } from '@/onebot/action/OneBotAction'; import { MessageUnique } from '@/common/message-unique'; import { z } from 'zod'; -import { coerce } from '@/common/coerce'; +import { actionType } from '@/common/coerce'; const SchemaData = z.object({ - message_id: coerce.string(), - emoji_id: coerce.string(), - set: coerce.boolean().optional(), + message_id: actionType.string(), + emoji_id: actionType.string(), + set: actionType.boolean().optional(), }); type Payload = z.infer; diff --git a/src/onebot/action/packet/SendPoke.ts b/src/onebot/action/packet/SendPoke.ts index 598654c0..438f802f 100644 --- a/src/onebot/action/packet/SendPoke.ts +++ b/src/onebot/action/packet/SendPoke.ts @@ -1,11 +1,11 @@ import { ActionName } from '@/onebot/action/router'; import { GetPacketStatusDepends } from '@/onebot/action/packet/GetPacketStatus'; import { z } from 'zod'; -import { coerce } from '@/common/coerce'; +import { actionType } from '@/common/coerce'; const SchemaData = z.object({ - group_id: coerce.string().optional(), - user_id: coerce.string(), + group_id: actionType.string().optional(), + user_id: actionType.string(), }); type Payload = z.infer; diff --git a/src/onebot/action/system/GetCredentials.ts b/src/onebot/action/system/GetCredentials.ts index c27a7b4c..cb49f0cc 100644 --- a/src/onebot/action/system/GetCredentials.ts +++ b/src/onebot/action/system/GetCredentials.ts @@ -1,7 +1,7 @@ import { OneBotAction } from '@/onebot/action/OneBotAction'; import { ActionName } from '@/onebot/action/router'; import { z } from 'zod'; -import { coerce } from '@/common/coerce'; +import { actionType } from '@/common/coerce'; interface Response { cookies: string, @@ -9,7 +9,7 @@ interface Response { } const SchemaData = z.object({ - domain: coerce.string() + domain: actionType.string() }); type Payload = z.infer; diff --git a/src/onebot/action/user/FriendPoke.ts b/src/onebot/action/user/FriendPoke.ts index 78a1b796..5b8ba425 100644 --- a/src/onebot/action/user/FriendPoke.ts +++ b/src/onebot/action/user/FriendPoke.ts @@ -1,10 +1,10 @@ import { ActionName } from '@/onebot/action/router'; import { GetPacketStatusDepends } from '@/onebot/action/packet/GetPacketStatus'; import { z } from 'zod'; -import { coerce } from '@/common/coerce'; +import { actionType } from '@/common/coerce'; const SchemaData = z.object({ - user_id: coerce.string() + user_id: actionType.string() }); type Payload = z.infer; diff --git a/src/onebot/action/user/GetCookies.ts b/src/onebot/action/user/GetCookies.ts index 9ff0e3bc..da021c33 100644 --- a/src/onebot/action/user/GetCookies.ts +++ b/src/onebot/action/user/GetCookies.ts @@ -1,14 +1,14 @@ import { OneBotAction } from '@/onebot/action/OneBotAction'; import { ActionName } from '@/onebot/action/router'; import { z } from 'zod'; -import { coerce } from '@/common/coerce'; +import { actionType } from '@/common/coerce'; interface Response { cookies: string, bkn: string } const SchemaData = z.object({ - domain: coerce.string() + domain: actionType.string() }); type Payload = z.infer; diff --git a/src/onebot/action/user/GetFriendList.ts b/src/onebot/action/user/GetFriendList.ts index 16cf57b0..ef85df42 100644 --- a/src/onebot/action/user/GetFriendList.ts +++ b/src/onebot/action/user/GetFriendList.ts @@ -3,10 +3,10 @@ import { OB11Construct } from '@/onebot/helper/data'; import { OneBotAction } from '@/onebot/action/OneBotAction'; import { ActionName } from '@/onebot/action/router'; import { z } from 'zod'; -import { coerce } from '@/common/coerce'; +import { actionType } from '@/common/coerce'; const SchemaData = z.object({ - no_cache: coerce.boolean().optional(), + no_cache: actionType.boolean().optional(), }); type Payload = z.infer; diff --git a/src/onebot/action/user/GetRecentContact.ts b/src/onebot/action/user/GetRecentContact.ts index 8ec364e7..4c817eb3 100644 --- a/src/onebot/action/user/GetRecentContact.ts +++ b/src/onebot/action/user/GetRecentContact.ts @@ -3,10 +3,10 @@ import { OneBotAction } from '@/onebot/action/OneBotAction'; import { ActionName } from '@/onebot/action/router'; import { NetworkAdapterConfig } from '@/onebot/config/config'; import { z } from 'zod'; -import { coerce } from '@/common/coerce'; +import { actionType } from '@/common/coerce'; const SchemaData = z.object({ - count: coerce.number().default(10), + count: actionType.number().default(10), }); type Payload = z.infer; diff --git a/src/onebot/action/user/SendLike.ts b/src/onebot/action/user/SendLike.ts index 66912a9c..7630161a 100644 --- a/src/onebot/action/user/SendLike.ts +++ b/src/onebot/action/user/SendLike.ts @@ -1,11 +1,11 @@ import { OneBotAction } from '@/onebot/action/OneBotAction'; import { ActionName } from '@/onebot/action/router'; import { z } from 'zod'; -import { coerce } from '@/common/coerce'; +import { actionType } from '@/common/coerce'; const SchemaData = z.object({ - times: coerce.number().default(1), - user_id: coerce.string() + times: actionType.number().default(1), + user_id: actionType.string() }); type Payload = z.infer; diff --git a/src/onebot/action/user/SetFriendAddRequest.ts b/src/onebot/action/user/SetFriendAddRequest.ts index 3a44ae8e..f35318d4 100644 --- a/src/onebot/action/user/SetFriendAddRequest.ts +++ b/src/onebot/action/user/SetFriendAddRequest.ts @@ -1,12 +1,12 @@ import { OneBotAction } from '@/onebot/action/OneBotAction'; import { ActionName } from '@/onebot/action/router'; import { z } from 'zod'; -import { coerce } from '@/common/coerce'; +import { actionType } from '@/common/coerce'; const SchemaData = z.object({ - flag: coerce.string(), - approve: coerce.boolean().default(true), - remark: coerce.string().nullable().optional() + flag: actionType.string(), + approve: actionType.boolean().default(true), + remark: actionType.string().nullable().optional() }); type Payload = z.infer; diff --git a/src/onebot/config/config.ts b/src/onebot/config/config.ts index 489ce61c..266106b6 100644 --- a/src/onebot/config/config.ts +++ b/src/onebot/config/config.ts @@ -1,72 +1,72 @@ import { z } from 'zod'; -import { coerce } from '../../common/coerce'; +import { actionType } from '../../common/coerce'; const HttpServerConfigSchema = z.object({ - name: coerce.string().default('http-server'), - enable: coerce.boolean().default(false), - port: coerce.number().default(3000), - host: coerce.string().default('0.0.0.0'), - enableCors: coerce.boolean().default(true), - enableWebsocket: coerce.boolean().default(true), - messagePostFormat: coerce.string().default('array'), - token: coerce.string().default(''), - debug: coerce.boolean().default(false) + name: actionType.string().default('http-server'), + enable: actionType.boolean().default(false), + port: actionType.number().default(3000), + host: actionType.string().default('0.0.0.0'), + enableCors: actionType.boolean().default(true), + enableWebsocket: actionType.boolean().default(true), + messagePostFormat: actionType.string().default('array'), + token: actionType.string().default(''), + debug: actionType.boolean().default(false) }); const HttpSseServerConfigSchema = z.object({ - name: coerce.string().default('http-sse-server'), - enable: coerce.boolean().default(false), - port: coerce.number().default(3000), - host: coerce.string().default('0.0.0.0'), - enableCors: coerce.boolean().default(true), - enableWebsocket: coerce.boolean().default(true), - messagePostFormat: coerce.string().default('array'), - token: coerce.string().default(''), - debug: coerce.boolean().default(false), - reportSelfMessage: coerce.boolean().default(false) + name: actionType.string().default('http-sse-server'), + enable: actionType.boolean().default(false), + port: actionType.number().default(3000), + host: actionType.string().default('0.0.0.0'), + enableCors: actionType.boolean().default(true), + enableWebsocket: actionType.boolean().default(true), + messagePostFormat: actionType.string().default('array'), + token: actionType.string().default(''), + debug: actionType.boolean().default(false), + reportSelfMessage: actionType.boolean().default(false) }); const HttpClientConfigSchema = z.object({ - name: coerce.string().default('http-client'), - enable: coerce.boolean().default(false), - url: coerce.string().default('http://localhost:8080'), - messagePostFormat: coerce.string().default('array'), - reportSelfMessage: coerce.boolean().default(false), - token: coerce.string().default(''), - debug: coerce.boolean().default(false) + name: actionType.string().default('http-client'), + enable: actionType.boolean().default(false), + url: actionType.string().default('http://localhost:8080'), + messagePostFormat: actionType.string().default('array'), + reportSelfMessage: actionType.boolean().default(false), + token: actionType.string().default(''), + debug: actionType.boolean().default(false) }); const WebsocketServerConfigSchema = z.object({ - name: coerce.string().default('websocket-server'), - enable: coerce.boolean().default(false), - host: coerce.string().default('0.0.0.0'), - port: coerce.number().default(3001), - messagePostFormat: coerce.string().default('array'), - reportSelfMessage: coerce.boolean().default(false), - token: coerce.string().default(''), - enableForcePushEvent: coerce.boolean().default(true), - debug: coerce.boolean().default(false), - heartInterval: coerce.number().default(30000) + name: actionType.string().default('websocket-server'), + enable: actionType.boolean().default(false), + host: actionType.string().default('0.0.0.0'), + port: actionType.number().default(3001), + messagePostFormat: actionType.string().default('array'), + reportSelfMessage: actionType.boolean().default(false), + token: actionType.string().default(''), + enableForcePushEvent: actionType.boolean().default(true), + debug: actionType.boolean().default(false), + heartInterval: actionType.number().default(30000) }); const WebsocketClientConfigSchema = z.object({ - name: coerce.string().default('websocket-client'), - enable: coerce.boolean().default(false), - url: coerce.string().default('ws://localhost:8082'), - messagePostFormat: coerce.string().default('array'), - reportSelfMessage: coerce.boolean().default(false), - reconnectInterval: coerce.number().default(5000), - token: coerce.string().default(''), - debug: coerce.boolean().default(false), - heartInterval: coerce.number().default(30000) + name: actionType.string().default('websocket-client'), + enable: actionType.boolean().default(false), + url: actionType.string().default('ws://localhost:8082'), + messagePostFormat: actionType.string().default('array'), + reportSelfMessage: actionType.boolean().default(false), + reconnectInterval: actionType.number().default(5000), + token: actionType.string().default(''), + debug: actionType.boolean().default(false), + heartInterval: actionType.number().default(30000) }); const PluginConfigSchema = z.object({ - name: coerce.string().default('plugin'), - enable: coerce.boolean().default(false), - messagePostFormat: coerce.string().default('array'), - reportSelfMessage: coerce.boolean().default(false), - debug: coerce.boolean().default(false), + name: actionType.string().default('plugin'), + enable: actionType.boolean().default(false), + messagePostFormat: actionType.string().default('array'), + reportSelfMessage: actionType.boolean().default(false), + debug: actionType.boolean().default(false), }); const NetworkConfigSchema = z.object({ @@ -80,9 +80,9 @@ const NetworkConfigSchema = z.object({ export const OneBotConfigSchema = z.object({ network: NetworkConfigSchema, - musicSignUrl: coerce.string().default(''), - enableLocalFile2Url: coerce.boolean().default(false), - parseMultMsg: coerce.boolean().default(false) + musicSignUrl: actionType.string().default(''), + enableLocalFile2Url: actionType.boolean().default(false), + parseMultMsg: actionType.boolean().default(false) }); export type OneBotConfig = z.infer; diff --git a/src/webui/src/helper/config.ts b/src/webui/src/helper/config.ts index dbbdf13a..af8e9c5c 100644 --- a/src/webui/src/helper/config.ts +++ b/src/webui/src/helper/config.ts @@ -4,14 +4,14 @@ import { resolve } from 'node:path'; import { deepMerge } from '../utils/object'; import { themeType } from '../types/theme'; import { z } from 'zod'; -import { coerce } from '@/common/coerce'; +import { actionType } from '@/common/coerce'; // 定义配置的类型 const WebUiConfigSchema = z.object({ - host: coerce.string().default('0.0.0.0'), - port: coerce.number().default(6099), - token: coerce.string().default('napcat'), - loginRate: coerce.number().default(10), - autoLoginAccount: coerce.string().default(''), + host: actionType.string().default('0.0.0.0'), + port: actionType.number().default(6099), + token: actionType.string().default('napcat'), + loginRate: actionType.number().default(10), + autoLoginAccount: actionType.string().default(''), theme: themeType, }); diff --git a/src/webui/src/types/theme.ts b/src/webui/src/types/theme.ts index 5f32c107..02be0c38 100644 --- a/src/webui/src/types/theme.ts +++ b/src/webui/src/types/theme.ts @@ -1,10 +1,10 @@ -import { coerce } from '@/common/coerce'; +import { actionType } from '@/common/coerce'; import { z } from 'zod'; export const themeType = z.object( { - dark: z.record(coerce.string(), coerce.string()), - light: z.record(coerce.string(), coerce.string()), + dark: z.record(actionType.string(), actionType.string()), + light: z.record(actionType.string(), actionType.string()), } ).default({ dark: {