From 17ef3231df08102cacd10f9319fd149de553fa62 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=89=8B=E7=93=9C=E4=B8=80=E5=8D=81=E9=9B=AA?= Date: Thu, 17 Apr 2025 09:38:38 +0800 Subject: [PATCH 1/5] =?UTF-8?q?fix:=20zod=20boolean=E5=BC=BA=E5=88=B6?= =?UTF-8?q?=E8=BD=AC=E6=8D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/core/helper/config.ts | 15 +-- .../extends/ClickInlineKeyboardButton.ts | 11 +- src/onebot/action/extends/CreateCollection.ts | 6 +- src/onebot/action/extends/FetchCustomFace.ts | 4 +- src/onebot/action/extends/FetchEmojiLike.ts | 10 +- src/onebot/action/extends/GetAiCharacters.ts | 6 +- .../action/extends/GetCollectionList.ts | 6 +- src/onebot/action/extends/GetGroupInfoEx.ts | 3 +- src/onebot/action/extends/GetMiniAppArk.ts | 46 ++++---- src/onebot/action/extends/GetProfileLike.ts | 8 +- src/onebot/action/extends/GetUserStatus.ts | 4 +- src/onebot/action/extends/MoveGroupFile.ts | 10 +- src/onebot/action/extends/OCRImage.ts | 4 +- src/onebot/action/extends/RenameGroupFile.ts | 10 +- src/onebot/action/extends/SendPacket.ts | 7 +- .../action/extends/SetDiyOnlineStatus.ts | 8 +- src/onebot/action/extends/SetGroupRemark.ts | 6 +- src/onebot/action/extends/SetGroupSign.ts | 4 +- src/onebot/action/extends/SetInputStatus.ts | 6 +- src/onebot/action/extends/SetLongNick.ts | 4 +- src/onebot/action/extends/SetOnlineStatus.ts | 8 +- src/onebot/action/extends/SetQQAvatar.ts | 4 +- src/onebot/action/extends/SetSpecialTitle.ts | 8 +- src/onebot/action/extends/ShareContact.ts | 10 +- src/onebot/action/extends/TransGroupFile.ts | 6 +- .../action/extends/TranslateEnWordToZn.ts | 4 +- src/onebot/action/file/GetFile.ts | 6 +- src/onebot/action/file/GetGroupFileUrl.ts | 6 +- src/onebot/action/file/GetPrivateFileUrl.ts | 4 +- .../action/go-cqhttp/CreateGroupFileFolder.ts | 6 +- .../action/go-cqhttp/DeleteGroupFile.ts | 6 +- .../action/go-cqhttp/DeleteGroupFileFolder.ts | 8 +- src/onebot/action/go-cqhttp/DownloadFile.ts | 10 +- src/onebot/action/go-cqhttp/GetForwardMsg.ts | 6 +- .../action/go-cqhttp/GetFriendMsgHistory.ts | 9 +- .../action/go-cqhttp/GetGroupAtAllRemain.ts | 4 +- .../go-cqhttp/GetGroupFileSystemInfo.ts | 4 +- .../action/go-cqhttp/GetGroupFilesByFolder.ts | 10 +- .../action/go-cqhttp/GetGroupHonorInfo.ts | 4 +- .../action/go-cqhttp/GetGroupMsgHistory.ts | 9 +- .../action/go-cqhttp/GetGroupRootFiles.ts | 6 +- .../action/go-cqhttp/GetStrangerInfo.ts | 5 +- .../go-cqhttp/GoCQHTTPCheckUrlSafely.ts | 4 +- .../action/go-cqhttp/GoCQHTTPDeleteFriend.ts | 9 +- .../action/go-cqhttp/GoCQHTTPGetModelShow.ts | 4 +- .../action/go-cqhttp/SendGroupNotice.ts | 18 +-- .../action/go-cqhttp/SetGroupPortrait.ts | 5 +- src/onebot/action/go-cqhttp/SetQQProfile.ts | 8 +- .../action/go-cqhttp/UploadGroupFile.ts | 12 +- .../action/go-cqhttp/UploadPrivateFile.ts | 8 +- src/onebot/action/group/DelEssenceMsg.ts | 4 +- src/onebot/action/group/DelGroupNotice.ts | 6 +- src/onebot/action/group/GetAiRecord.ts | 8 +- src/onebot/action/group/GetGroupEssence.ts | 4 +- src/onebot/action/group/GetGroupInfo.ts | 4 +- src/onebot/action/group/GetGroupList.ts | 3 +- src/onebot/action/group/GetGroupMemberInfo.ts | 7 +- src/onebot/action/group/GetGroupMemberList.ts | 5 +- src/onebot/action/group/GetGroupNotice.ts | 3 +- src/onebot/action/group/GetGroupShutList.ts | 4 +- src/onebot/action/group/GroupPoke.ts | 6 +- src/onebot/action/group/SendGroupAiRecord.ts | 8 +- src/onebot/action/group/SetEssenceMsg.ts | 4 +- src/onebot/action/group/SetGroupAddRequest.ts | 7 +- src/onebot/action/group/SetGroupAdmin.ts | 7 +- src/onebot/action/group/SetGroupBan.ts | 8 +- src/onebot/action/group/SetGroupCard.ts | 8 +- src/onebot/action/group/SetGroupKick.ts | 7 +- src/onebot/action/group/SetGroupLeave.ts | 5 +- src/onebot/action/group/SetGroupName.ts | 6 +- src/onebot/action/group/SetGroupWholeBan.ts | 5 +- src/onebot/action/msg/DeleteMsg.ts | 3 +- src/onebot/action/msg/ForwardSingleMsg.ts | 8 +- src/onebot/action/msg/GetMsg.ts | 4 +- src/onebot/action/msg/MarkMsgAsRead.ts | 8 +- src/onebot/action/msg/SetMsgEmojiLike.ts | 7 +- src/onebot/action/packet/SendPoke.ts | 5 +- src/onebot/action/system/GetCredentials.ts | 3 +- src/onebot/action/type.ts | 15 +++ src/onebot/action/user/FriendPoke.ts | 3 +- src/onebot/action/user/GetCookies.ts | 3 +- src/onebot/action/user/GetFriendList.ts | 3 +- src/onebot/action/user/GetRecentContact.ts | 3 +- src/onebot/action/user/SendLike.ts | 5 +- src/onebot/action/user/SetFriendAddRequest.ts | 7 +- src/onebot/config/config.ts | 107 +++++++++--------- src/webui/src/helper/config.ts | 11 +- src/webui/src/types/theme.ts | 5 +- 88 files changed, 377 insertions(+), 331 deletions(-) create mode 100644 src/onebot/action/type.ts diff --git a/src/core/helper/config.ts b/src/core/helper/config.ts index 94cfbeb5d..1b11467a0 100644 --- a/src/core/helper/config.ts +++ b/src/core/helper/config.ts @@ -1,15 +1,16 @@ import { ConfigBase } from '@/common/config-base'; import { NapCatCore } from '@/core'; +import { actionType } from '@/onebot/action/type'; import { z } from 'zod'; export const NapcatConfigSchema = z.object({ - fileLog: z.coerce.boolean().default(false), - consoleLog: z.coerce.boolean().default(true), - fileLogLevel: z.coerce.string().default('debug'), - consoleLogLevel: z.coerce.string().default('info'), - packetBackend: z.coerce.string().default('auto'), - packetServer: z.coerce.string().default(''), - o3HookMode: z.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 c06947cfd..aaca0481a 100644 --- a/src/onebot/action/extends/ClickInlineKeyboardButton.ts +++ b/src/onebot/action/extends/ClickInlineKeyboardButton.ts @@ -1,13 +1,14 @@ import { ActionName } from '@/onebot/action/router'; import { OneBotAction } from '../OneBotAction'; import { z } from 'zod'; +import { actionType } from '../type'; const SchemaData = z.object({ - group_id: z.coerce.string(), - bot_appid: z.coerce.string(), - button_id: z.coerce.string().default(''), - callback_data: z.coerce.string().default(''), - msg_seq: z.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 e1c5903ba..8451664ee 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 { actionType } from '../type'; const SchemaData = z.object({ - rawData: z.coerce.string(), - brief: z.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 cd7d76458..8e068060f 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 { actionType } from '../type'; const SchemaData = z.object({ - count: z.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 11505d9af..263311ad3 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 { actionType } from '../type'; const SchemaData = z.object({ - message_id: z.coerce.string(), - emojiId: z.coerce.string(), - emojiType: z.coerce.string(), - count: z.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 e2f2045a5..5706cfecd 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 { actionType } from '../type'; const SchemaData = z.object({ - group_id: z.coerce.string(), - chat_type: z.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 4399c3493..d1593a025 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 { actionType } from '../type'; const SchemaData = z.object({ - category: z.coerce.number(), - count: z.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 4dcd05ee5..ec3f685dc 100644 --- a/src/onebot/action/extends/GetGroupInfoEx.ts +++ b/src/onebot/action/extends/GetGroupInfoEx.ts @@ -1,8 +1,9 @@ import { OneBotAction } from '@/onebot/action/OneBotAction'; import { ActionName } from '@/onebot/action/router'; import { z } from 'zod'; +import { actionType } from '../type'; const SchemaData = z.object({ - group_id: z.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 699d66614..50e1629db 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 { actionType } from '../type'; const SchemaData = z.union([ z.object({ type: z.union([z.literal('bili'), z.literal('weibo')]), - title: z.coerce.string(), - desc: z.coerce.string(), - picUrl: z.coerce.string(), - jumpUrl: z.coerce.string(), - webUrl: z.coerce.string().optional(), - rawArkData: z.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: z.coerce.string(), - desc: z.coerce.string(), - picUrl: z.coerce.string(), - jumpUrl: z.coerce.string(), - iconUrl: z.coerce.string(), - webUrl: z.coerce.string().optional(), - appId: z.coerce.string(), - scene: z.union([z.coerce.number(), z.coerce.string()]), - templateType: z.union([z.coerce.number(), z.coerce.string()]), - businessType: z.union([z.coerce.number(), z.coerce.string()]), - verType: z.union([z.coerce.number(), z.coerce.string()]), - shareType: z.union([z.coerce.number(), z.coerce.string()]), - versionId: z.coerce.string(), - sdkId: z.coerce.string(), - withShareTicket: z.union([z.coerce.number(), z.coerce.string()]), - rawArkData: z.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 7e727a7a6..3e06b75b6 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 { actionType } from '../type'; const SchemaData = z.object({ - user_id: z.coerce.string().optional(), - start: z.coerce.number().default(0), - count: z.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 7fe274e8f..3256b6fed 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 { actionType } from '../type'; const SchemaData = z.object({ - user_id: z.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 05c92220b..cdad09878 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 { actionType } from '../type'; const SchemaData = z.object({ - group_id: z.coerce.string(), - file_id: z.coerce.string(), - current_parent_directory: z.coerce.string(), - target_parent_directory: z.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 d3dd45a8b..6e4baf619 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 { actionType } from '../type'; const SchemaData = z.object({ - image: z.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 06bb1f485..fe0fd2d7d 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 { actionType } from '../type'; const SchemaData = z.object({ - group_id: z.coerce.string(), - file_id: z.coerce.string(), - current_parent_directory: z.coerce.string(), - new_name: z.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 ac23b9c4a..b472109ae 100644 --- a/src/onebot/action/extends/SendPacket.ts +++ b/src/onebot/action/extends/SendPacket.ts @@ -2,11 +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 { actionType } from '../type'; const SchemaData = z.object({ - cmd: z.coerce.string(), - data: z.coerce.string(), - rsp: z.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 df36e0be0..7c1d609a7 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 { actionType } from '../type'; const SchemaData = z.object({ - face_id: z.coerce.string(),// 参考 face_config.json 的 QSid - face_type: z.coerce.string().default('1'), - wording: z.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 a6e5edaf2..c30fb31ce 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 { actionType } from '../type'; const SchemaData = z.object({ - group_id: z.coerce.string(), - remark: z.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 3d22da228..bb66c12fb 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 { actionType } from '../type'; const SchemaData = z.object({ - group_id: z.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 763249017..2dd00a44b 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 { actionType } from '../type'; const SchemaData = z.object({ - user_id: z.coerce.string(), - event_type: z.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 be68fea28..d84344e36 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 { actionType } from '../type'; const SchemaData = z.object({ - longNick: z.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 10101b9ab..d9d760195 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 { actionType } from '../type'; const SchemaData = z.object({ - status: z.coerce.number(), - ext_status: z.coerce.number(), - battery_status: z.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 eee209c85..9a84a5a0f 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 { actionType } from '../type'; const SchemaData = z.object({ - file: z.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 2665a373c..dcb0dff48 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 { actionType } from '../type'; const SchemaData = z.object({ - group_id: z.coerce.string(), - user_id: z.coerce.string(), - special_title: z.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 d14196830..732ac9906 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 { actionType } from '../type'; const SchemaData = z.object({ - user_id: z.coerce.string().optional(), - group_id: z.coerce.string().optional(), - phoneNumber: z.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 2c1da8c94..c802d1605 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 { actionType } from '../type'; const SchemaData = z.object({ - group_id: z.coerce.string(), - file_id: z.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 bc4977b25..77ce0647d 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 { actionType } from '../type'; const SchemaData = z.object({ - words: z.array(z.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 8d373676b..4116f4c47 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 { actionType } from '../type'; export interface GetFileResponse { file?: string; // path url?: string; @@ -14,8 +14,8 @@ export interface GetFileResponse { } const GetFileBase_PayloadSchema = z.object({ - file: z.coerce.string().optional(), - file_id: z.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 ea475659f..e454ea9f1 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 { actionType } from '../type'; const SchemaData = z.object({ - group_id: z.coerce.string(), - file_id: z.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 f2ea65e3f..2dbb615d4 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 { actionType } from '../type'; const SchemaData = z.object({ - file_id: z.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 f1f4c8ff8..2b1e3a18b 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 { actionType } from '../type'; const SchemaData = z.object({ - group_id: z.coerce.string(), - folder_name: z.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 54b5ff6f3..5a4895fe2 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 { actionType } from '../type'; const SchemaData = z.object({ - group_id: z.coerce.string(), - file_id: z.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 44c7767ee..170bb7031 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 { actionType } from '../type'; const SchemaData = z.object({ - group_id: z.coerce.string(), - folder_id: z.coerce.string().optional(), - folder: z.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 a5fb72221..3b5b79656 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 { actionType } from '../type'; interface FileResponse { file: string; } const SchemaData = z.object({ - url: z.coerce.string().optional(), - base64: z.coerce.string().optional(), - name: z.coerce.string().optional(), - headers: z.union([z.coerce.string(), z.array(z.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 e85546fed..62cbd4380 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 { actionType } from '../type'; const SchemaData = z.object({ - message_id: z.coerce.string().optional(), - id: z.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 08500dee9..be7a52d04 100644 --- a/src/onebot/action/go-cqhttp/GetFriendMsgHistory.ts +++ b/src/onebot/action/go-cqhttp/GetFriendMsgHistory.ts @@ -5,15 +5,16 @@ import { ChatType } from '@/core/types'; import { MessageUnique } from '@/common/message-unique'; import { z } from 'zod'; import { NetworkAdapterConfig } from '@/onebot/config/config'; +import { actionType } from '../type'; interface Response { messages: OB11Message[]; } const SchemaData = z.object({ - user_id: z.coerce.string(), - message_seq: z.coerce.string().optional(), - count: z.coerce.number().default(20), - reverseOrder: z.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 c5ff5d3c8..67d2eb8dd 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 { actionType } from '../type'; const SchemaData = z.object({ - group_id: z.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 7f9cc99f7..9d161641e 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 { actionType } from '../type'; const SchemaData = z.object({ - group_id: z.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 f04319631..fb993dba7 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 { actionType } from '../type'; const SchemaData = z.object({ - group_id: z.coerce.string(), - folder_id: z.coerce.string().optional(), - folder: z.coerce.string().optional(), - file_count: z.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 9f30542aa..a6c666a33 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 { actionType } from '../type'; const SchemaData = z.object({ - group_id: z.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 f9328d7f0..0952bb86d 100644 --- a/src/onebot/action/go-cqhttp/GetGroupMsgHistory.ts +++ b/src/onebot/action/go-cqhttp/GetGroupMsgHistory.ts @@ -5,16 +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 { actionType } from '../type'; interface Response { messages: OB11Message[]; } const SchemaData = z.object({ - group_id: z.coerce.string(), - message_seq: z.coerce.string().optional(), - count: z.coerce.number().default(20), - reverseOrder: z.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 9604e804e..d3a8efbc6 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 { actionType } from '../type'; const SchemaData = z.object({ - group_id: z.coerce.string(), - file_count: z.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 480daa8d6..6052c1b77 100644 --- a/src/onebot/action/go-cqhttp/GetStrangerInfo.ts +++ b/src/onebot/action/go-cqhttp/GetStrangerInfo.ts @@ -4,10 +4,11 @@ import { OB11Construct } from '@/onebot/helper/data'; import { ActionName } from '@/onebot/action/router'; import { calcQQLevel } from '@/common/helper'; import { z } from 'zod'; +import { actionType } from '../type'; const SchemaData = z.object({ - user_id: z.coerce.string(), - no_cache: z.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 0f4d4424e..180131474 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 { actionType } from '../type'; const SchemaData = z.object({ - url: z.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 f828306ab..278318529 100644 --- a/src/onebot/action/go-cqhttp/GoCQHTTPDeleteFriend.ts +++ b/src/onebot/action/go-cqhttp/GoCQHTTPDeleteFriend.ts @@ -1,12 +1,13 @@ import { OneBotAction } from '@/onebot/action/OneBotAction'; import { ActionName } from '@/onebot/action/router'; import { z } from 'zod'; +import { actionType } from '../type'; const SchemaData = z.object({ - friend_id: z.coerce.string().optional(), - user_id: z.coerce.string().optional(), - temp_block: z.coerce.boolean().optional(), - temp_both_del: z.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 ea791d3e9..962cf1370 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 { actionType } from '../type'; const SchemaData = z.object({ - model: z.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 e51c23558..b3b6a7959 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 { actionType } from '../type'; const SchemaData = z.object({ - group_id: z.coerce.string(), - content: z.coerce.string(), - image: z.coerce.string().optional(), - pinned: z.coerce.number().default(0), - type: z.coerce.number().default(1), - confirm_required: z.coerce.number().default(1), - is_show_edit_card: z.coerce.number().default(0), - tip_window_type: z.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 5c9e7091f..b009f2671 100644 --- a/src/onebot/action/go-cqhttp/SetGroupPortrait.ts +++ b/src/onebot/action/go-cqhttp/SetGroupPortrait.ts @@ -4,9 +4,10 @@ import { checkFileExistV2, uriToLocalFile } from '@/common/file'; import { z } from 'zod'; import fs from 'node:fs/promises'; import { GeneralCallResult } from '@/core'; +import { actionType } from '../type'; const SchemaData = z.object({ - file: z.coerce.string(), - group_id: z.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 e7832fbc9..f61872e97 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 { actionType } from '../type'; const SchemaData = z.object({ - nickname: z.coerce.string(), - personal_note: z.coerce.string().optional(), - sex: z.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 32f630654..3381f1981 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 { actionType } from '../type'; const SchemaData = z.object({ - group_id: z.coerce.string(), - file: z.coerce.string(), - name: z.coerce.string(), - folder: z.coerce.string().optional(), - folder_id: z.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 833799166..6d53fda64 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 { actionType } from '../type'; const SchemaData = z.object({ - user_id: z.coerce.string(), - file: z.coerce.string(), - name: z.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 5f6490cc2..1d108bec0 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 { actionType } from '../type'; const SchemaData = z.object({ - message_id: z.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 11d232342..7ec4de9c1 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 { actionType } from '../type'; const SchemaData = z.object({ - group_id: z.coerce.string(), - notice_id: z.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 8837551fa..58d40b1d6 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 { actionType } from '../type'; const SchemaData = z.object({ - character: z.coerce.string(), - group_id: z.coerce.string(), - text: z.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 9b46eb408..0176994ed 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 { actionType } from '../type'; const SchemaData = z.object({ - group_id: z.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 d96950612..9a24c3c05 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 { actionType } from '../type'; const SchemaData = z.object({ - group_id: z.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 0b219646f..98f7d407e 100644 --- a/src/onebot/action/group/GetGroupList.ts +++ b/src/onebot/action/group/GetGroupList.ts @@ -3,9 +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 { actionType } from '../type'; const SchemaData = z.object({ - no_cache: z.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 79f9c4e72..0aa72dde8 100644 --- a/src/onebot/action/group/GetGroupMemberInfo.ts +++ b/src/onebot/action/group/GetGroupMemberInfo.ts @@ -3,11 +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 { actionType } from '../type'; const SchemaData = z.object({ - group_id: z.coerce.string(), - user_id: z.coerce.string(), - no_cache: z.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 6e0aac63f..746efbaa6 100644 --- a/src/onebot/action/group/GetGroupMemberList.ts +++ b/src/onebot/action/group/GetGroupMemberList.ts @@ -4,10 +4,11 @@ import { OneBotAction } from '@/onebot/action/OneBotAction'; import { ActionName } from '@/onebot/action/router'; import { z } from 'zod'; import { GroupMember } from '@/core'; +import { actionType } from '../type'; const SchemaData = z.object({ - group_id: z.coerce.string(), - no_cache: z.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 50dd50b56..89f30a32c 100644 --- a/src/onebot/action/group/GetGroupNotice.ts +++ b/src/onebot/action/group/GetGroupNotice.ts @@ -2,6 +2,7 @@ import { WebApiGroupNoticeFeed } from '@/core'; import { OneBotAction } from '@/onebot/action/OneBotAction'; import { ActionName } from '@/onebot/action/router'; import { z } from 'zod'; +import { actionType } from '../type'; interface GroupNotice { sender_id: number; publish_time: number; @@ -17,7 +18,7 @@ interface GroupNotice { } const SchemaData = z.object({ - group_id: z.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 ba24fea1e..3133b412d 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 { actionType } from '../type'; const SchemaData = z.object({ - group_id: z.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 a0efd74f7..09d958e52 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 { actionType } from '../type'; const SchemaData = z.object({ - group_id: z.coerce.string(), - user_id: z.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 d845e793d..bb1c85fd7 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 { actionType } from '../type'; const SchemaData = z.object({ - character: z.coerce.string(), - group_id: z.coerce.string(), - text: z.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 80b7df566..de3c7f436 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 { actionType } from '../type'; const SchemaData = z.object({ - message_id: z.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 a2fcb6626..f0ced956d 100644 --- a/src/onebot/action/group/SetGroupAddRequest.ts +++ b/src/onebot/action/group/SetGroupAddRequest.ts @@ -2,11 +2,12 @@ import { OneBotAction } from '@/onebot/action/OneBotAction'; import { NTGroupRequestOperateTypes } from '@/core/types'; import { ActionName } from '@/onebot/action/router'; import { z } from 'zod'; +import { actionType } from '../type'; const SchemaData = z.object({ - flag: z.coerce.string(), - approve: z.coerce.boolean().default(true), - reason: z.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 d9e91397b..4067b4fff 100644 --- a/src/onebot/action/group/SetGroupAdmin.ts +++ b/src/onebot/action/group/SetGroupAdmin.ts @@ -2,11 +2,12 @@ import { OneBotAction } from '@/onebot/action/OneBotAction'; import { NTGroupMemberRole } from '@/core/types'; import { ActionName } from '@/onebot/action/router'; import { z } from 'zod'; +import { actionType } from '../type'; const SchemaData = z.object({ - group_id: z.coerce.string(), - user_id: z.coerce.string(), - enable: z.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 cb146e9dd..e4fe3c03d 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 { actionType } from '../type'; const SchemaData = z.object({ - group_id: z.coerce.string(), - user_id: z.coerce.string(), - duration: z.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 a3a61ee51..870af15ff 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 { actionType } from '../type'; const SchemaData = z.object({ - group_id: z.coerce.string(), - user_id: z.coerce.string(), - card: z.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 9aa313418..a394b9c88 100644 --- a/src/onebot/action/group/SetGroupKick.ts +++ b/src/onebot/action/group/SetGroupKick.ts @@ -1,11 +1,12 @@ import { OneBotAction } from '@/onebot/action/OneBotAction'; import { ActionName } from '@/onebot/action/router'; import { z } from 'zod'; +import { actionType } from '../type'; const SchemaData = z.object({ - group_id: z.coerce.string(), - user_id: z.coerce.string(), - reject_add_request: z.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 a830ad785..a21c890ed 100644 --- a/src/onebot/action/group/SetGroupLeave.ts +++ b/src/onebot/action/group/SetGroupLeave.ts @@ -1,10 +1,11 @@ import { OneBotAction } from '@/onebot/action/OneBotAction'; import { ActionName } from '@/onebot/action/router'; import { z } from 'zod'; +import { actionType } from '../type'; const SchemaData = z.object({ - group_id: z.coerce.string(), - is_dismiss: z.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 4b70af1a3..b1949b45e 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 { actionType } from '../type'; const SchemaData = z.object({ - group_id: z.coerce.string(), - group_name: z.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 06b16a272..e35b85b86 100644 --- a/src/onebot/action/group/SetGroupWholeBan.ts +++ b/src/onebot/action/group/SetGroupWholeBan.ts @@ -1,10 +1,11 @@ import { OneBotAction } from '@/onebot/action/OneBotAction'; import { ActionName } from '@/onebot/action/router'; import { z } from 'zod'; +import { actionType } from '../type'; const SchemaData = z.object({ - group_id: z.coerce.string(), - enable: z.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 87f387439..3d88c5a89 100644 --- a/src/onebot/action/msg/DeleteMsg.ts +++ b/src/onebot/action/msg/DeleteMsg.ts @@ -2,9 +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 { actionType } from '../type'; const SchemaData = z.object({ - message_id: z.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 a737b8abf..3497a40c6 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 { actionType } from '../type'; const SchemaData = z.object({ - message_id: z.coerce.string(), - group_id: z.coerce.string().optional(), - user_id: z.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 83095c896..347b1502c 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 { actionType } from '../type'; export type ReturnDataType = OB11Message const SchemaData = z.object({ - message_id: z.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 7bb6f9eb3..fcb8e2711 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 { actionType } from '../type'; const SchemaData = z.object({ - user_id: z.coerce.string().optional(), - group_id: z.coerce.string().optional(), - message_id: z.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 9d2c5bb03..b71983efb 100644 --- a/src/onebot/action/msg/SetMsgEmojiLike.ts +++ b/src/onebot/action/msg/SetMsgEmojiLike.ts @@ -2,11 +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 { actionType } from '../type'; const SchemaData = z.object({ - message_id: z.coerce.string(), - emoji_id: z.coerce.string(), - set: z.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 02e06c90f..dcd9da64f 100644 --- a/src/onebot/action/packet/SendPoke.ts +++ b/src/onebot/action/packet/SendPoke.ts @@ -1,10 +1,11 @@ import { ActionName } from '@/onebot/action/router'; import { GetPacketStatusDepends } from '@/onebot/action/packet/GetPacketStatus'; import { z } from 'zod'; +import { actionType } from '../type'; const SchemaData = z.object({ - group_id: z.coerce.string().optional(), - user_id: z.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 0d6a72fb1..072281280 100644 --- a/src/onebot/action/system/GetCredentials.ts +++ b/src/onebot/action/system/GetCredentials.ts @@ -1,6 +1,7 @@ import { OneBotAction } from '@/onebot/action/OneBotAction'; import { ActionName } from '@/onebot/action/router'; import { z } from 'zod'; +import { actionType } from '../type'; interface Response { cookies: string, @@ -8,7 +9,7 @@ interface Response { } const SchemaData = z.object({ - domain: z.coerce.string() + domain: actionType.string() }); type Payload = z.infer; diff --git a/src/onebot/action/type.ts b/src/onebot/action/type.ts new file mode 100644 index 000000000..f480fda08 --- /dev/null +++ b/src/onebot/action/type.ts @@ -0,0 +1,15 @@ +import { z } from "zod"; + +const boolean = () => z.preprocess( + val => typeof val === 'string' && val.toLowerCase() === 'false' ? false : Boolean(val), + z.boolean() +); +const number = () => z.preprocess( + val => typeof val !== 'number' ? Number(val) : val, + z.number() +); +const string = () => z.preprocess( + val => typeof val !== 'string' ? String(val) : val, + z.string() +); +export const actionType = { boolean, number, string }; \ No newline at end of file diff --git a/src/onebot/action/user/FriendPoke.ts b/src/onebot/action/user/FriendPoke.ts index 3eccae07e..68493c94a 100644 --- a/src/onebot/action/user/FriendPoke.ts +++ b/src/onebot/action/user/FriendPoke.ts @@ -1,9 +1,10 @@ import { ActionName } from '@/onebot/action/router'; import { GetPacketStatusDepends } from '@/onebot/action/packet/GetPacketStatus'; import { z } from 'zod'; +import { actionType } from '../type'; const SchemaData = z.object({ - user_id: z.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 82df5bccb..60c344240 100644 --- a/src/onebot/action/user/GetCookies.ts +++ b/src/onebot/action/user/GetCookies.ts @@ -1,13 +1,14 @@ import { OneBotAction } from '@/onebot/action/OneBotAction'; import { ActionName } from '@/onebot/action/router'; import { z } from 'zod'; +import { actionType } from '../type'; interface Response { cookies: string, bkn: string } const SchemaData = z.object({ - domain: z.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 e804bf1c1..74cc6815b 100644 --- a/src/onebot/action/user/GetFriendList.ts +++ b/src/onebot/action/user/GetFriendList.ts @@ -3,9 +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 { actionType } from '../type'; const SchemaData = z.object({ - no_cache: z.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 b79d7aec5..8a551b540 100644 --- a/src/onebot/action/user/GetRecentContact.ts +++ b/src/onebot/action/user/GetRecentContact.ts @@ -3,9 +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 { actionType } from '../type'; const SchemaData = z.object({ - count: z.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 4804184b4..5ac5078e7 100644 --- a/src/onebot/action/user/SendLike.ts +++ b/src/onebot/action/user/SendLike.ts @@ -1,10 +1,11 @@ import { OneBotAction } from '@/onebot/action/OneBotAction'; import { ActionName } from '@/onebot/action/router'; import { z } from 'zod'; +import { actionType } from '../type'; const SchemaData = z.object({ - times: z.coerce.number().default(1), - user_id: z.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 ef1fa7fbc..3fb71e18b 100644 --- a/src/onebot/action/user/SetFriendAddRequest.ts +++ b/src/onebot/action/user/SetFriendAddRequest.ts @@ -1,11 +1,12 @@ import { OneBotAction } from '@/onebot/action/OneBotAction'; import { ActionName } from '@/onebot/action/router'; import { z } from 'zod'; +import { actionType } from '../type'; const SchemaData = z.object({ - flag: z.coerce.string(), - approve: z.coerce.boolean().default(true), - remark: z.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 9a9b8a00f..7ee9d3b70 100644 --- a/src/onebot/config/config.ts +++ b/src/onebot/config/config.ts @@ -1,71 +1,72 @@ import { z } from 'zod'; +import { actionType } from '../action/type'; const HttpServerConfigSchema = z.object({ - name: z.coerce.string().default('http-server'), - enable: z.coerce.boolean().default(false), - port: z.coerce.number().default(3000), - host: z.coerce.string().default('0.0.0.0'), - enableCors: z.coerce.boolean().default(true), - enableWebsocket: z.coerce.boolean().default(true), - messagePostFormat: z.coerce.string().default('array'), - token: z.coerce.string().default(''), - debug: z.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: z.coerce.string().default('http-sse-server'), - enable: z.coerce.boolean().default(false), - port: z.coerce.number().default(3000), - host: z.coerce.string().default('0.0.0.0'), - enableCors: z.coerce.boolean().default(true), - enableWebsocket: z.coerce.boolean().default(true), - messagePostFormat: z.coerce.string().default('array'), - token: z.coerce.string().default(''), - debug: z.coerce.boolean().default(false), - reportSelfMessage: z.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: z.coerce.string().default('http-client'), - enable: z.coerce.boolean().default(false), - url: z.coerce.string().default('http://localhost:8080'), - messagePostFormat: z.coerce.string().default('array'), - reportSelfMessage: z.coerce.boolean().default(false), - token: z.coerce.string().default(''), - debug: z.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: z.coerce.string().default('websocket-server'), - enable: z.coerce.boolean().default(false), - host: z.coerce.string().default('0.0.0.0'), - port: z.coerce.number().default(3001), - messagePostFormat: z.coerce.string().default('array'), - reportSelfMessage: z.coerce.boolean().default(false), - token: z.coerce.string().default(''), - enableForcePushEvent: z.coerce.boolean().default(true), - debug: z.coerce.boolean().default(false), - heartInterval: z.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: z.coerce.string().default('websocket-client'), - enable: z.coerce.boolean().default(false), - url: z.coerce.string().default('ws://localhost:8082'), - messagePostFormat: z.coerce.string().default('array'), - reportSelfMessage: z.coerce.boolean().default(false), - reconnectInterval: z.coerce.number().default(5000), - token: z.coerce.string().default(''), - debug: z.coerce.boolean().default(false), - heartInterval: z.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: z.coerce.string().default('plugin'), - enable: z.coerce.boolean().default(false), - messagePostFormat: z.coerce.string().default('array'), - reportSelfMessage: z.coerce.boolean().default(false), - debug: z.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({ @@ -79,9 +80,9 @@ const NetworkConfigSchema = z.object({ export const OneBotConfigSchema = z.object({ network: NetworkConfigSchema, - musicSignUrl: z.coerce.string().default(''), - enableLocalFile2Url: z.coerce.boolean().default(false), - parseMultMsg: z.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 065628594..ffaf6df1b 100644 --- a/src/webui/src/helper/config.ts +++ b/src/webui/src/helper/config.ts @@ -4,13 +4,14 @@ import { resolve } from 'node:path'; import { deepMerge } from '../utils/object'; import { themeType } from '../types/theme'; import { z } from 'zod'; +import { actionType } from '@/onebot/action/type'; // 定义配置的类型 const WebUiConfigSchema = z.object({ - host: z.coerce.string().default('0.0.0.0'), - port: z.coerce.number().default(6099), - token: z.coerce.string().default('napcat'), - loginRate: z.coerce.number().default(10), - autoLoginAccount: z.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 dcbe3a47a..d62d08213 100644 --- a/src/webui/src/types/theme.ts +++ b/src/webui/src/types/theme.ts @@ -1,9 +1,10 @@ +import { actionType } from '@/onebot/action/type'; import { z } from 'zod'; export const themeType = z.object( { - dark: z.record(z.coerce.string(), z.coerce.string()), - light: z.record(z.coerce.string(), z.coerce.string()), + dark: z.record(actionType.string(), actionType.string()), + light: z.record(actionType.string(), actionType.string()), } ).default({ dark: { From 3f6249f39cfbbce1b214dd8c32d4d9756890268e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=89=8B=E7=93=9C=E4=B8=80=E5=8D=81=E9=9B=AA?= Date: Thu, 17 Apr 2025 09:48:59 +0800 Subject: [PATCH 2/5] fix --- src/onebot/action/type.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/onebot/action/type.ts b/src/onebot/action/type.ts index f480fda08..76b11d5c8 100644 --- a/src/onebot/action/type.ts +++ b/src/onebot/action/type.ts @@ -1,7 +1,7 @@ import { z } from "zod"; const boolean = () => z.preprocess( - val => typeof val === 'string' && val.toLowerCase() === 'false' ? false : Boolean(val), + val => typeof val === 'string' && (val.toLowerCase() === 'false' || val === '0') ? false : Boolean(val), z.boolean() ); const number = () => z.preprocess( From 54e6d5c3f2b0793ca0ced35e85b83177732e8171 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=89=8B=E7=93=9C=E4=B8=80=E5=8D=81=E9=9B=AA?= Date: Thu, 17 Apr 2025 09:52:03 +0800 Subject: [PATCH 3/5] fix --- src/{onebot/action/type.ts => common/coerce.ts} | 1 - src/core/helper/config.ts | 2 +- src/onebot/action/extends/ClickInlineKeyboardButton.ts | 2 +- src/onebot/action/extends/CreateCollection.ts | 2 +- src/onebot/action/extends/FetchCustomFace.ts | 2 +- src/onebot/action/extends/FetchEmojiLike.ts | 2 +- src/onebot/action/extends/GetAiCharacters.ts | 2 +- src/onebot/action/extends/GetCollectionList.ts | 2 +- src/onebot/action/extends/GetGroupInfoEx.ts | 2 +- src/onebot/action/extends/GetMiniAppArk.ts | 2 +- src/onebot/action/extends/GetProfileLike.ts | 2 +- src/onebot/action/extends/GetUserStatus.ts | 2 +- src/onebot/action/extends/MoveGroupFile.ts | 2 +- src/onebot/action/extends/OCRImage.ts | 2 +- src/onebot/action/extends/RenameGroupFile.ts | 2 +- src/onebot/action/extends/SendPacket.ts | 2 +- src/onebot/action/extends/SetDiyOnlineStatus.ts | 2 +- src/onebot/action/extends/SetGroupRemark.ts | 2 +- src/onebot/action/extends/SetGroupSign.ts | 2 +- src/onebot/action/extends/SetInputStatus.ts | 2 +- src/onebot/action/extends/SetLongNick.ts | 2 +- src/onebot/action/extends/SetOnlineStatus.ts | 2 +- src/onebot/action/extends/SetQQAvatar.ts | 2 +- src/onebot/action/extends/SetSpecialTitle.ts | 2 +- src/onebot/action/extends/ShareContact.ts | 2 +- src/onebot/action/extends/TransGroupFile.ts | 2 +- src/onebot/action/extends/TranslateEnWordToZn.ts | 2 +- src/onebot/action/file/GetFile.ts | 2 +- src/onebot/action/file/GetGroupFileUrl.ts | 2 +- src/onebot/action/file/GetPrivateFileUrl.ts | 2 +- src/onebot/action/go-cqhttp/CreateGroupFileFolder.ts | 2 +- src/onebot/action/go-cqhttp/DeleteGroupFile.ts | 2 +- src/onebot/action/go-cqhttp/DeleteGroupFileFolder.ts | 2 +- src/onebot/action/go-cqhttp/DownloadFile.ts | 2 +- src/onebot/action/go-cqhttp/GetForwardMsg.ts | 2 +- src/onebot/action/go-cqhttp/GetFriendMsgHistory.ts | 2 +- src/onebot/action/go-cqhttp/GetGroupAtAllRemain.ts | 2 +- src/onebot/action/go-cqhttp/GetGroupFileSystemInfo.ts | 2 +- src/onebot/action/go-cqhttp/GetGroupFilesByFolder.ts | 2 +- src/onebot/action/go-cqhttp/GetGroupHonorInfo.ts | 2 +- src/onebot/action/go-cqhttp/GetGroupMsgHistory.ts | 2 +- src/onebot/action/go-cqhttp/GetGroupRootFiles.ts | 2 +- src/onebot/action/go-cqhttp/GetStrangerInfo.ts | 2 +- src/onebot/action/go-cqhttp/GoCQHTTPCheckUrlSafely.ts | 2 +- src/onebot/action/go-cqhttp/GoCQHTTPDeleteFriend.ts | 2 +- src/onebot/action/go-cqhttp/GoCQHTTPGetModelShow.ts | 2 +- src/onebot/action/go-cqhttp/SendGroupNotice.ts | 2 +- src/onebot/action/go-cqhttp/SetGroupPortrait.ts | 2 +- src/onebot/action/go-cqhttp/SetQQProfile.ts | 2 +- src/onebot/action/go-cqhttp/UploadGroupFile.ts | 2 +- src/onebot/action/go-cqhttp/UploadPrivateFile.ts | 2 +- src/onebot/action/group/DelEssenceMsg.ts | 2 +- src/onebot/action/group/DelGroupNotice.ts | 2 +- src/onebot/action/group/GetAiRecord.ts | 2 +- src/onebot/action/group/GetGroupEssence.ts | 2 +- src/onebot/action/group/GetGroupInfo.ts | 2 +- src/onebot/action/group/GetGroupList.ts | 2 +- src/onebot/action/group/GetGroupMemberInfo.ts | 2 +- src/onebot/action/group/GetGroupMemberList.ts | 2 +- src/onebot/action/group/GetGroupNotice.ts | 2 +- src/onebot/action/group/GetGroupShutList.ts | 2 +- src/onebot/action/group/GroupPoke.ts | 2 +- src/onebot/action/group/SendGroupAiRecord.ts | 2 +- src/onebot/action/group/SetEssenceMsg.ts | 2 +- src/onebot/action/group/SetGroupAddRequest.ts | 2 +- src/onebot/action/group/SetGroupAdmin.ts | 2 +- src/onebot/action/group/SetGroupBan.ts | 2 +- src/onebot/action/group/SetGroupCard.ts | 2 +- src/onebot/action/group/SetGroupKick.ts | 2 +- src/onebot/action/group/SetGroupLeave.ts | 2 +- src/onebot/action/group/SetGroupName.ts | 2 +- src/onebot/action/group/SetGroupWholeBan.ts | 2 +- src/onebot/action/msg/DeleteMsg.ts | 2 +- src/onebot/action/msg/ForwardSingleMsg.ts | 2 +- src/onebot/action/msg/GetMsg.ts | 2 +- src/onebot/action/msg/MarkMsgAsRead.ts | 2 +- src/onebot/action/msg/SetMsgEmojiLike.ts | 2 +- src/onebot/action/packet/SendPoke.ts | 2 +- src/onebot/action/system/GetCredentials.ts | 2 +- src/onebot/action/user/FriendPoke.ts | 2 +- src/onebot/action/user/GetCookies.ts | 2 +- src/onebot/action/user/GetFriendList.ts | 2 +- src/onebot/action/user/GetRecentContact.ts | 2 +- src/onebot/action/user/SendLike.ts | 2 +- src/onebot/action/user/SetFriendAddRequest.ts | 2 +- src/onebot/config/config.ts | 2 +- src/webui/src/helper/config.ts | 2 +- src/webui/src/types/theme.ts | 2 +- 88 files changed, 87 insertions(+), 88 deletions(-) rename src/{onebot/action/type.ts => common/coerce.ts} (99%) diff --git a/src/onebot/action/type.ts b/src/common/coerce.ts similarity index 99% rename from src/onebot/action/type.ts rename to src/common/coerce.ts index 76b11d5c8..46eb174db 100644 --- a/src/onebot/action/type.ts +++ b/src/common/coerce.ts @@ -1,5 +1,4 @@ import { z } from "zod"; - const boolean = () => z.preprocess( val => typeof val === 'string' && (val.toLowerCase() === 'false' || val === '0') ? false : Boolean(val), z.boolean() diff --git a/src/core/helper/config.ts b/src/core/helper/config.ts index 1b11467a0..ca3d22686 100644 --- a/src/core/helper/config.ts +++ b/src/core/helper/config.ts @@ -1,6 +1,6 @@ import { ConfigBase } from '@/common/config-base'; import { NapCatCore } from '@/core'; -import { actionType } from '@/onebot/action/type'; +import { actionType } from '@/common/coerce'; import { z } from 'zod'; export const NapcatConfigSchema = z.object({ diff --git a/src/onebot/action/extends/ClickInlineKeyboardButton.ts b/src/onebot/action/extends/ClickInlineKeyboardButton.ts index aaca0481a..fba1830cd 100644 --- a/src/onebot/action/extends/ClickInlineKeyboardButton.ts +++ b/src/onebot/action/extends/ClickInlineKeyboardButton.ts @@ -1,7 +1,7 @@ import { ActionName } from '@/onebot/action/router'; import { OneBotAction } from '../OneBotAction'; import { z } from 'zod'; -import { actionType } from '../type'; +import { actionType } from '@/common/coerce'; const SchemaData = z.object({ group_id: actionType.string(), diff --git a/src/onebot/action/extends/CreateCollection.ts b/src/onebot/action/extends/CreateCollection.ts index 8451664ee..0faf8b4ec 100644 --- a/src/onebot/action/extends/CreateCollection.ts +++ b/src/onebot/action/extends/CreateCollection.ts @@ -1,7 +1,7 @@ import { OneBotAction } from '@/onebot/action/OneBotAction'; import { ActionName } from '@/onebot/action/router'; import { z } from 'zod'; -import { actionType } from '../type'; +import { actionType } from '@/common/coerce'; const SchemaData = z.object({ rawData: actionType.string(), brief: actionType.string(), diff --git a/src/onebot/action/extends/FetchCustomFace.ts b/src/onebot/action/extends/FetchCustomFace.ts index 8e068060f..ee6a535ca 100644 --- a/src/onebot/action/extends/FetchCustomFace.ts +++ b/src/onebot/action/extends/FetchCustomFace.ts @@ -1,7 +1,7 @@ import { z } from 'zod'; import { OneBotAction } from '@/onebot/action/OneBotAction'; import { ActionName } from '@/onebot/action/router'; -import { actionType } from '../type'; +import { actionType } from '@/common/coerce'; const SchemaData = z.object({ count: actionType.number().default(48), }); diff --git a/src/onebot/action/extends/FetchEmojiLike.ts b/src/onebot/action/extends/FetchEmojiLike.ts index 263311ad3..c55ce0c4d 100644 --- a/src/onebot/action/extends/FetchEmojiLike.ts +++ b/src/onebot/action/extends/FetchEmojiLike.ts @@ -3,7 +3,7 @@ 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 { actionType } from '../type'; +import { actionType } from '@/common/coerce'; const SchemaData = z.object({ message_id: actionType.string(), emojiId: actionType.string(), diff --git a/src/onebot/action/extends/GetAiCharacters.ts b/src/onebot/action/extends/GetAiCharacters.ts index 5706cfecd..7e2210bd4 100644 --- a/src/onebot/action/extends/GetAiCharacters.ts +++ b/src/onebot/action/extends/GetAiCharacters.ts @@ -2,7 +2,7 @@ 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 { actionType } from '../type'; +import { actionType } from '@/common/coerce'; const SchemaData = z.object({ group_id: actionType.string(), chat_type: actionType.number().default(1), diff --git a/src/onebot/action/extends/GetCollectionList.ts b/src/onebot/action/extends/GetCollectionList.ts index d1593a025..1cb629617 100644 --- a/src/onebot/action/extends/GetCollectionList.ts +++ b/src/onebot/action/extends/GetCollectionList.ts @@ -2,7 +2,7 @@ import { type NTQQCollectionApi } from '@/core/apis/collection'; import { OneBotAction } from '@/onebot/action/OneBotAction'; import { ActionName } from '@/onebot/action/router'; import { z } from 'zod'; -import { actionType } from '../type'; +import { actionType } from '@/common/coerce'; const SchemaData = z.object({ category: actionType.number(), count: actionType.number().default(1), diff --git a/src/onebot/action/extends/GetGroupInfoEx.ts b/src/onebot/action/extends/GetGroupInfoEx.ts index ec3f685dc..9ed398bcb 100644 --- a/src/onebot/action/extends/GetGroupInfoEx.ts +++ b/src/onebot/action/extends/GetGroupInfoEx.ts @@ -1,7 +1,7 @@ import { OneBotAction } from '@/onebot/action/OneBotAction'; import { ActionName } from '@/onebot/action/router'; import { z } from 'zod'; -import { actionType } from '../type'; +import { actionType } from '@/common/coerce'; const SchemaData = z.object({ group_id: actionType.string(), }); diff --git a/src/onebot/action/extends/GetMiniAppArk.ts b/src/onebot/action/extends/GetMiniAppArk.ts index 50e1629db..2bd60b0af 100644 --- a/src/onebot/action/extends/GetMiniAppArk.ts +++ b/src/onebot/action/extends/GetMiniAppArk.ts @@ -3,7 +3,7 @@ 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 { actionType } from '../type'; +import { actionType } from '@/common/coerce'; const SchemaData = z.union([ z.object({ type: z.union([z.literal('bili'), z.literal('weibo')]), diff --git a/src/onebot/action/extends/GetProfileLike.ts b/src/onebot/action/extends/GetProfileLike.ts index 3e06b75b6..cefd9e555 100644 --- a/src/onebot/action/extends/GetProfileLike.ts +++ b/src/onebot/action/extends/GetProfileLike.ts @@ -2,7 +2,7 @@ import { NTVoteInfo } from '@/core'; import { OneBotAction } from '@/onebot/action/OneBotAction'; import { ActionName } from '@/onebot/action/router'; import { z } from 'zod'; -import { actionType } from '../type'; +import { actionType } from '@/common/coerce'; const SchemaData = z.object({ user_id: actionType.string().optional(), start: actionType.number().default(0), diff --git a/src/onebot/action/extends/GetUserStatus.ts b/src/onebot/action/extends/GetUserStatus.ts index 3256b6fed..38ac00079 100644 --- a/src/onebot/action/extends/GetUserStatus.ts +++ b/src/onebot/action/extends/GetUserStatus.ts @@ -1,7 +1,7 @@ import { ActionName } from '@/onebot/action/router'; import { GetPacketStatusDepends } from '@/onebot/action/packet/GetPacketStatus'; import { z } from 'zod'; -import { actionType } from '../type'; +import { actionType } from '@/common/coerce'; const SchemaData = z.object({ user_id: actionType.number(), }); diff --git a/src/onebot/action/extends/MoveGroupFile.ts b/src/onebot/action/extends/MoveGroupFile.ts index cdad09878..7e2e6eb45 100644 --- a/src/onebot/action/extends/MoveGroupFile.ts +++ b/src/onebot/action/extends/MoveGroupFile.ts @@ -2,7 +2,7 @@ import { ActionName } from '@/onebot/action/router'; import { FileNapCatOneBotUUID } from '@/common/file-uuid'; import { GetPacketStatusDepends } from '@/onebot/action/packet/GetPacketStatus'; import { z } from 'zod'; -import { actionType } from '../type'; +import { actionType } from '@/common/coerce'; const SchemaData = z.object({ group_id: actionType.string(), file_id: actionType.string(), diff --git a/src/onebot/action/extends/OCRImage.ts b/src/onebot/action/extends/OCRImage.ts index 6e4baf619..c08a12b50 100644 --- a/src/onebot/action/extends/OCRImage.ts +++ b/src/onebot/action/extends/OCRImage.ts @@ -4,7 +4,7 @@ import { checkFileExist, uriToLocalFile } from '@/common/file'; import fs from 'fs'; import { z } from 'zod'; import { GeneralCallResultStatus } from '@/core'; -import { actionType } from '../type'; +import { actionType } from '@/common/coerce'; const SchemaData = z.object({ image: actionType.string(), }); diff --git a/src/onebot/action/extends/RenameGroupFile.ts b/src/onebot/action/extends/RenameGroupFile.ts index fe0fd2d7d..ff40a66be 100644 --- a/src/onebot/action/extends/RenameGroupFile.ts +++ b/src/onebot/action/extends/RenameGroupFile.ts @@ -2,7 +2,7 @@ import { ActionName } from '@/onebot/action/router'; import { FileNapCatOneBotUUID } from '@/common/file-uuid'; import { GetPacketStatusDepends } from '@/onebot/action/packet/GetPacketStatus'; import { z } from 'zod'; -import { actionType } from '../type'; +import { actionType } from '@/common/coerce'; const SchemaData = z.object({ group_id: actionType.string(), file_id: actionType.string(), diff --git a/src/onebot/action/extends/SendPacket.ts b/src/onebot/action/extends/SendPacket.ts index b472109ae..27c133ad1 100644 --- a/src/onebot/action/extends/SendPacket.ts +++ b/src/onebot/action/extends/SendPacket.ts @@ -2,7 +2,7 @@ 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 { actionType } from '../type'; +import { actionType } from '@/common/coerce'; const SchemaData = z.object({ cmd: actionType.string(), diff --git a/src/onebot/action/extends/SetDiyOnlineStatus.ts b/src/onebot/action/extends/SetDiyOnlineStatus.ts index 7c1d609a7..43bffa639 100644 --- a/src/onebot/action/extends/SetDiyOnlineStatus.ts +++ b/src/onebot/action/extends/SetDiyOnlineStatus.ts @@ -1,7 +1,7 @@ import { OneBotAction } from '@/onebot/action/OneBotAction'; import { ActionName } from '@/onebot/action/router'; import { z } from 'zod'; -import { actionType } from '../type'; +import { actionType } from '@/common/coerce'; const SchemaData = z.object({ face_id: actionType.string(),// 参考 face_config.json 的 QSid face_type: actionType.string().default('1'), diff --git a/src/onebot/action/extends/SetGroupRemark.ts b/src/onebot/action/extends/SetGroupRemark.ts index c30fb31ce..d5b7b6a0e 100644 --- a/src/onebot/action/extends/SetGroupRemark.ts +++ b/src/onebot/action/extends/SetGroupRemark.ts @@ -1,7 +1,7 @@ import { OneBotAction } from '@/onebot/action/OneBotAction'; import { ActionName } from '@/onebot/action/router'; import { z } from 'zod'; -import { actionType } from '../type'; +import { actionType } from '@/common/coerce'; const SchemaData = z.object({ group_id: actionType.string(), remark: actionType.string(), diff --git a/src/onebot/action/extends/SetGroupSign.ts b/src/onebot/action/extends/SetGroupSign.ts index bb66c12fb..56fdf5348 100644 --- a/src/onebot/action/extends/SetGroupSign.ts +++ b/src/onebot/action/extends/SetGroupSign.ts @@ -1,7 +1,7 @@ import { GetPacketStatusDepends } from '@/onebot/action/packet/GetPacketStatus'; import { ActionName } from '@/onebot/action/router'; import { z } from 'zod'; -import { actionType } from '../type'; +import { actionType } from '@/common/coerce'; const SchemaData = z.object({ group_id: actionType.string(), }); diff --git a/src/onebot/action/extends/SetInputStatus.ts b/src/onebot/action/extends/SetInputStatus.ts index 2dd00a44b..98f28a94c 100644 --- a/src/onebot/action/extends/SetInputStatus.ts +++ b/src/onebot/action/extends/SetInputStatus.ts @@ -2,7 +2,7 @@ import { OneBotAction } from '@/onebot/action/OneBotAction'; import { ActionName } from '@/onebot/action/router'; import { ChatType } from '@/core'; import { z } from 'zod'; -import { actionType } from '../type'; +import { actionType } from '@/common/coerce'; const SchemaData = z.object({ user_id: actionType.string(), event_type: actionType.number(), diff --git a/src/onebot/action/extends/SetLongNick.ts b/src/onebot/action/extends/SetLongNick.ts index d84344e36..4b05825b4 100644 --- a/src/onebot/action/extends/SetLongNick.ts +++ b/src/onebot/action/extends/SetLongNick.ts @@ -1,7 +1,7 @@ import { OneBotAction } from '@/onebot/action/OneBotAction'; import { ActionName } from '@/onebot/action/router'; import { z } from 'zod'; -import { actionType } from '../type'; +import { actionType } from '@/common/coerce'; const SchemaData = z.object({ longNick: actionType.string(), }); diff --git a/src/onebot/action/extends/SetOnlineStatus.ts b/src/onebot/action/extends/SetOnlineStatus.ts index d9d760195..e863b4aef 100644 --- a/src/onebot/action/extends/SetOnlineStatus.ts +++ b/src/onebot/action/extends/SetOnlineStatus.ts @@ -1,7 +1,7 @@ import { OneBotAction } from '@/onebot/action/OneBotAction'; import { ActionName } from '@/onebot/action/router'; import { z } from 'zod'; -import { actionType } from '../type'; +import { actionType } from '@/common/coerce'; const SchemaData = z.object({ status: actionType.number(), ext_status: actionType.number(), diff --git a/src/onebot/action/extends/SetQQAvatar.ts b/src/onebot/action/extends/SetQQAvatar.ts index 9a84a5a0f..767a5c3b4 100644 --- a/src/onebot/action/extends/SetQQAvatar.ts +++ b/src/onebot/action/extends/SetQQAvatar.ts @@ -3,7 +3,7 @@ import { ActionName } from '@/onebot/action/router'; import fs from 'node:fs/promises'; import { checkFileExist, uriToLocalFile } from '@/common/file'; import { z } from 'zod'; -import { actionType } from '../type'; +import { actionType } from '@/common/coerce'; const SchemaData = z.object({ file: actionType.string(), }); diff --git a/src/onebot/action/extends/SetSpecialTitle.ts b/src/onebot/action/extends/SetSpecialTitle.ts index dcb0dff48..efa4000ba 100644 --- a/src/onebot/action/extends/SetSpecialTitle.ts +++ b/src/onebot/action/extends/SetSpecialTitle.ts @@ -1,7 +1,7 @@ import { ActionName } from '@/onebot/action/router'; import { GetPacketStatusDepends } from '@/onebot/action/packet/GetPacketStatus'; import { z } from 'zod'; -import { actionType } from '../type'; +import { actionType } from '@/common/coerce'; const SchemaData = z.object({ group_id: actionType.string(), user_id: actionType.string(), diff --git a/src/onebot/action/extends/ShareContact.ts b/src/onebot/action/extends/ShareContact.ts index 732ac9906..571bbdb7a 100644 --- a/src/onebot/action/extends/ShareContact.ts +++ b/src/onebot/action/extends/ShareContact.ts @@ -2,7 +2,7 @@ import { GeneralCallResult } from '@/core'; import { OneBotAction } from '@/onebot/action/OneBotAction'; import { ActionName } from '@/onebot/action/router'; import { z } from 'zod'; -import { actionType } from '../type'; +import { actionType } from '@/common/coerce'; const SchemaData = z.object({ user_id: actionType.string().optional(), group_id: actionType.string().optional(), diff --git a/src/onebot/action/extends/TransGroupFile.ts b/src/onebot/action/extends/TransGroupFile.ts index c802d1605..bd5045a05 100644 --- a/src/onebot/action/extends/TransGroupFile.ts +++ b/src/onebot/action/extends/TransGroupFile.ts @@ -2,7 +2,7 @@ import { ActionName } from '@/onebot/action/router'; import { FileNapCatOneBotUUID } from '@/common/file-uuid'; import { GetPacketStatusDepends } from '@/onebot/action/packet/GetPacketStatus'; import { z } from 'zod'; -import { actionType } from '../type'; +import { actionType } from '@/common/coerce'; const SchemaData = z.object({ group_id: actionType.string(), file_id: actionType.string(), diff --git a/src/onebot/action/extends/TranslateEnWordToZn.ts b/src/onebot/action/extends/TranslateEnWordToZn.ts index 77ce0647d..ff27a83ff 100644 --- a/src/onebot/action/extends/TranslateEnWordToZn.ts +++ b/src/onebot/action/extends/TranslateEnWordToZn.ts @@ -1,7 +1,7 @@ import { OneBotAction } from '@/onebot/action/OneBotAction'; import { ActionName } from '@/onebot/action/router'; import { z } from 'zod'; -import { actionType } from '../type'; +import { actionType } from '@/common/coerce'; const SchemaData = z.object({ words: z.array(actionType.string()), }); diff --git a/src/onebot/action/file/GetFile.ts b/src/onebot/action/file/GetFile.ts index 4116f4c47..55725be90 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 { actionType } from '../type'; +import { actionType } from '@/common/coerce'; export interface GetFileResponse { file?: string; // path url?: string; diff --git a/src/onebot/action/file/GetGroupFileUrl.ts b/src/onebot/action/file/GetGroupFileUrl.ts index e454ea9f1..c90103e59 100644 --- a/src/onebot/action/file/GetGroupFileUrl.ts +++ b/src/onebot/action/file/GetGroupFileUrl.ts @@ -2,7 +2,7 @@ import { ActionName } from '@/onebot/action/router'; import { FileNapCatOneBotUUID } from '@/common/file-uuid'; import { GetPacketStatusDepends } from '@/onebot/action/packet/GetPacketStatus'; import { z } from 'zod'; -import { actionType } from '../type'; +import { actionType } from '@/common/coerce'; const SchemaData = z.object({ group_id: actionType.string(), file_id: actionType.string(), diff --git a/src/onebot/action/file/GetPrivateFileUrl.ts b/src/onebot/action/file/GetPrivateFileUrl.ts index 2dbb615d4..04b9bf1a0 100644 --- a/src/onebot/action/file/GetPrivateFileUrl.ts +++ b/src/onebot/action/file/GetPrivateFileUrl.ts @@ -2,7 +2,7 @@ import { ActionName } from '@/onebot/action/router'; import { FileNapCatOneBotUUID } from '@/common/file-uuid'; import { GetPacketStatusDepends } from '@/onebot/action/packet/GetPacketStatus'; import { z } from 'zod'; -import { actionType } from '../type'; +import { actionType } from '@/common/coerce'; const SchemaData = z.object({ file_id: actionType.string(), }); diff --git a/src/onebot/action/go-cqhttp/CreateGroupFileFolder.ts b/src/onebot/action/go-cqhttp/CreateGroupFileFolder.ts index 2b1e3a18b..91e3e5225 100644 --- a/src/onebot/action/go-cqhttp/CreateGroupFileFolder.ts +++ b/src/onebot/action/go-cqhttp/CreateGroupFileFolder.ts @@ -1,7 +1,7 @@ import { OneBotAction } from '@/onebot/action/OneBotAction'; import { ActionName } from '@/onebot/action/router'; import { z } from 'zod'; -import { actionType } from '../type'; +import { actionType } from '@/common/coerce'; const SchemaData = z.object({ group_id: actionType.string(), folder_name: actionType.string(), diff --git a/src/onebot/action/go-cqhttp/DeleteGroupFile.ts b/src/onebot/action/go-cqhttp/DeleteGroupFile.ts index 5a4895fe2..addee6b97 100644 --- a/src/onebot/action/go-cqhttp/DeleteGroupFile.ts +++ b/src/onebot/action/go-cqhttp/DeleteGroupFile.ts @@ -4,7 +4,7 @@ import { ActionName } from '@/onebot/action/router'; import { FileNapCatOneBotUUID } from '@/common/file-uuid'; import { z } from 'zod'; import { NTQQGroupApi } from '@/core/apis'; -import { actionType } from '../type'; +import { actionType } from '@/common/coerce'; const SchemaData = z.object({ group_id: actionType.string(), file_id: actionType.string(), diff --git a/src/onebot/action/go-cqhttp/DeleteGroupFileFolder.ts b/src/onebot/action/go-cqhttp/DeleteGroupFileFolder.ts index 170bb7031..be39f4762 100644 --- a/src/onebot/action/go-cqhttp/DeleteGroupFileFolder.ts +++ b/src/onebot/action/go-cqhttp/DeleteGroupFileFolder.ts @@ -2,7 +2,7 @@ import { ActionName } from '@/onebot/action/router'; import { OneBotAction } from '@/onebot/action/OneBotAction'; import { z } from 'zod'; import { NTQQGroupApi } from '@/core/apis'; -import { actionType } from '../type'; +import { actionType } from '@/common/coerce'; const SchemaData = z.object({ group_id: actionType.string(), folder_id: actionType.string().optional(), diff --git a/src/onebot/action/go-cqhttp/DownloadFile.ts b/src/onebot/action/go-cqhttp/DownloadFile.ts index 3b5b79656..d6288661c 100644 --- a/src/onebot/action/go-cqhttp/DownloadFile.ts +++ b/src/onebot/action/go-cqhttp/DownloadFile.ts @@ -5,7 +5,7 @@ import { join as joinPath } from 'node:path'; import { calculateFileMD5, uriToLocalFile } from '@/common/file'; import { randomUUID } from 'crypto'; import { z } from 'zod'; -import { actionType } from '../type'; +import { actionType } from '@/common/coerce'; interface FileResponse { file: string; } diff --git a/src/onebot/action/go-cqhttp/GetForwardMsg.ts b/src/onebot/action/go-cqhttp/GetForwardMsg.ts index 62cbd4380..d49baefd6 100644 --- a/src/onebot/action/go-cqhttp/GetForwardMsg.ts +++ b/src/onebot/action/go-cqhttp/GetForwardMsg.ts @@ -5,7 +5,7 @@ import { MessageUnique } from '@/common/message-unique'; import { ChatType, ElementType, MsgSourceType, NTMsgType, RawMessage } from '@/core'; import { z } from 'zod'; import { isNumeric } from '@/common/helper'; -import { actionType } from '../type'; +import { actionType } from '@/common/coerce'; const SchemaData = z.object({ message_id: actionType.string().optional(), id: actionType.string().optional(), diff --git a/src/onebot/action/go-cqhttp/GetFriendMsgHistory.ts b/src/onebot/action/go-cqhttp/GetFriendMsgHistory.ts index be7a52d04..2c0d4ecc1 100644 --- a/src/onebot/action/go-cqhttp/GetFriendMsgHistory.ts +++ b/src/onebot/action/go-cqhttp/GetFriendMsgHistory.ts @@ -5,7 +5,7 @@ import { ChatType } from '@/core/types'; import { MessageUnique } from '@/common/message-unique'; import { z } from 'zod'; import { NetworkAdapterConfig } from '@/onebot/config/config'; -import { actionType } from '../type'; +import { actionType } from '@/common/coerce'; interface Response { messages: OB11Message[]; diff --git a/src/onebot/action/go-cqhttp/GetGroupAtAllRemain.ts b/src/onebot/action/go-cqhttp/GetGroupAtAllRemain.ts index 67d2eb8dd..6149aa51c 100644 --- a/src/onebot/action/go-cqhttp/GetGroupAtAllRemain.ts +++ b/src/onebot/action/go-cqhttp/GetGroupAtAllRemain.ts @@ -1,7 +1,7 @@ import { OneBotAction } from '@/onebot/action/OneBotAction'; import { ActionName } from '@/onebot/action/router'; import { z } from 'zod'; -import { actionType } from '../type'; +import { actionType } from '@/common/coerce'; const SchemaData = z.object({ group_id: actionType.string() }); diff --git a/src/onebot/action/go-cqhttp/GetGroupFileSystemInfo.ts b/src/onebot/action/go-cqhttp/GetGroupFileSystemInfo.ts index 9d161641e..69c1edf45 100644 --- a/src/onebot/action/go-cqhttp/GetGroupFileSystemInfo.ts +++ b/src/onebot/action/go-cqhttp/GetGroupFileSystemInfo.ts @@ -1,7 +1,7 @@ import { OneBotAction } from '@/onebot/action/OneBotAction'; import { ActionName } from '@/onebot/action/router'; import { z } from 'zod'; -import { actionType } from '../type'; +import { actionType } from '@/common/coerce'; const SchemaData = z.object({ group_id: actionType.string() }); diff --git a/src/onebot/action/go-cqhttp/GetGroupFilesByFolder.ts b/src/onebot/action/go-cqhttp/GetGroupFilesByFolder.ts index fb993dba7..93d700739 100644 --- a/src/onebot/action/go-cqhttp/GetGroupFilesByFolder.ts +++ b/src/onebot/action/go-cqhttp/GetGroupFilesByFolder.ts @@ -3,7 +3,7 @@ import { OneBotAction } from '@/onebot/action/OneBotAction'; import { ActionName } from '@/onebot/action/router'; import { OB11Construct } from '@/onebot/helper/data'; import { z } from 'zod'; -import { actionType } from '../type'; +import { actionType } from '@/common/coerce'; const SchemaData = z.object({ group_id: actionType.string(), folder_id: actionType.string().optional(), diff --git a/src/onebot/action/go-cqhttp/GetGroupHonorInfo.ts b/src/onebot/action/go-cqhttp/GetGroupHonorInfo.ts index a6c666a33..b22c77b84 100644 --- a/src/onebot/action/go-cqhttp/GetGroupHonorInfo.ts +++ b/src/onebot/action/go-cqhttp/GetGroupHonorInfo.ts @@ -2,7 +2,7 @@ import { WebHonorType } from '@/core'; import { OneBotAction } from '@/onebot/action/OneBotAction'; import { ActionName } from '@/onebot/action/router'; import { z } from 'zod'; -import { actionType } from '../type'; +import { actionType } from '@/common/coerce'; const SchemaData = z.object({ 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 0952bb86d..bde27c1a4 100644 --- a/src/onebot/action/go-cqhttp/GetGroupMsgHistory.ts +++ b/src/onebot/action/go-cqhttp/GetGroupMsgHistory.ts @@ -5,7 +5,7 @@ import { ChatType, Peer } from '@/core/types'; import { MessageUnique } from '@/common/message-unique'; import { z } from 'zod'; import { NetworkAdapterConfig } from '@/onebot/config/config'; -import { actionType } from '../type'; +import { actionType } from '@/common/coerce'; interface Response { messages: OB11Message[]; diff --git a/src/onebot/action/go-cqhttp/GetGroupRootFiles.ts b/src/onebot/action/go-cqhttp/GetGroupRootFiles.ts index d3a8efbc6..613bac174 100644 --- a/src/onebot/action/go-cqhttp/GetGroupRootFiles.ts +++ b/src/onebot/action/go-cqhttp/GetGroupRootFiles.ts @@ -4,7 +4,7 @@ import { ActionName } from '@/onebot/action/router'; import { OB11GroupFile, OB11GroupFileFolder } from '@/onebot'; import { OB11Construct } from '@/onebot/helper/data'; import { z } from 'zod'; -import { actionType } from '../type'; +import { actionType } from '@/common/coerce'; const SchemaData = z.object({ group_id: actionType.string(), file_count: actionType.number().default(50), diff --git a/src/onebot/action/go-cqhttp/GetStrangerInfo.ts b/src/onebot/action/go-cqhttp/GetStrangerInfo.ts index 6052c1b77..aa6282837 100644 --- a/src/onebot/action/go-cqhttp/GetStrangerInfo.ts +++ b/src/onebot/action/go-cqhttp/GetStrangerInfo.ts @@ -4,7 +4,7 @@ import { OB11Construct } from '@/onebot/helper/data'; import { ActionName } from '@/onebot/action/router'; import { calcQQLevel } from '@/common/helper'; import { z } from 'zod'; -import { actionType } from '../type'; +import { actionType } from '@/common/coerce'; const SchemaData = z.object({ user_id: actionType.string(), diff --git a/src/onebot/action/go-cqhttp/GoCQHTTPCheckUrlSafely.ts b/src/onebot/action/go-cqhttp/GoCQHTTPCheckUrlSafely.ts index 180131474..997a16308 100644 --- a/src/onebot/action/go-cqhttp/GoCQHTTPCheckUrlSafely.ts +++ b/src/onebot/action/go-cqhttp/GoCQHTTPCheckUrlSafely.ts @@ -1,7 +1,7 @@ import { OneBotAction } from '@/onebot/action/OneBotAction'; import { ActionName } from '@/onebot/action/router'; import { z } from 'zod'; -import { actionType } from '../type'; +import { actionType } from '@/common/coerce'; const SchemaData = z.object({ url: actionType.string(), }); diff --git a/src/onebot/action/go-cqhttp/GoCQHTTPDeleteFriend.ts b/src/onebot/action/go-cqhttp/GoCQHTTPDeleteFriend.ts index 278318529..079f681f5 100644 --- a/src/onebot/action/go-cqhttp/GoCQHTTPDeleteFriend.ts +++ b/src/onebot/action/go-cqhttp/GoCQHTTPDeleteFriend.ts @@ -1,7 +1,7 @@ import { OneBotAction } from '@/onebot/action/OneBotAction'; import { ActionName } from '@/onebot/action/router'; import { z } from 'zod'; -import { actionType } from '../type'; +import { actionType } from '@/common/coerce'; const SchemaData = z.object({ friend_id: actionType.string().optional(), diff --git a/src/onebot/action/go-cqhttp/GoCQHTTPGetModelShow.ts b/src/onebot/action/go-cqhttp/GoCQHTTPGetModelShow.ts index 962cf1370..bbcce797e 100644 --- a/src/onebot/action/go-cqhttp/GoCQHTTPGetModelShow.ts +++ b/src/onebot/action/go-cqhttp/GoCQHTTPGetModelShow.ts @@ -1,7 +1,7 @@ import { OneBotAction } from '@/onebot/action/OneBotAction'; import { ActionName } from '@/onebot/action/router'; import { z } from 'zod'; -import { actionType } from '../type'; +import { actionType } from '@/common/coerce'; const SchemaData = z.object({ model: actionType.string(), }); diff --git a/src/onebot/action/go-cqhttp/SendGroupNotice.ts b/src/onebot/action/go-cqhttp/SendGroupNotice.ts index b3b6a7959..e309397c3 100644 --- a/src/onebot/action/go-cqhttp/SendGroupNotice.ts +++ b/src/onebot/action/go-cqhttp/SendGroupNotice.ts @@ -3,7 +3,7 @@ import { OneBotAction } from '@/onebot/action/OneBotAction'; import { ActionName } from '@/onebot/action/router'; import { unlink } from 'node:fs/promises'; import { z } from 'zod'; -import { actionType } from '../type'; +import { actionType } from '@/common/coerce'; const SchemaData = z.object({ group_id: actionType.string(), content: actionType.string(), diff --git a/src/onebot/action/go-cqhttp/SetGroupPortrait.ts b/src/onebot/action/go-cqhttp/SetGroupPortrait.ts index b009f2671..af178e9b2 100644 --- a/src/onebot/action/go-cqhttp/SetGroupPortrait.ts +++ b/src/onebot/action/go-cqhttp/SetGroupPortrait.ts @@ -4,7 +4,7 @@ import { checkFileExistV2, uriToLocalFile } from '@/common/file'; import { z } from 'zod'; import fs from 'node:fs/promises'; import { GeneralCallResult } from '@/core'; -import { actionType } from '../type'; +import { actionType } from '@/common/coerce'; const SchemaData = z.object({ file: actionType.string(), group_id: actionType.string() diff --git a/src/onebot/action/go-cqhttp/SetQQProfile.ts b/src/onebot/action/go-cqhttp/SetQQProfile.ts index f61872e97..28bffd6ae 100644 --- a/src/onebot/action/go-cqhttp/SetQQProfile.ts +++ b/src/onebot/action/go-cqhttp/SetQQProfile.ts @@ -2,7 +2,7 @@ import { NTQQUserApi } from '@/core/apis'; import { OneBotAction } from '@/onebot/action/OneBotAction'; import { ActionName } from '@/onebot/action/router'; import { z } from 'zod'; -import { actionType } from '../type'; +import { actionType } from '@/common/coerce'; const SchemaData = z.object({ nickname: actionType.string(), personal_note: actionType.string().optional(), diff --git a/src/onebot/action/go-cqhttp/UploadGroupFile.ts b/src/onebot/action/go-cqhttp/UploadGroupFile.ts index 3381f1981..195df4b95 100644 --- a/src/onebot/action/go-cqhttp/UploadGroupFile.ts +++ b/src/onebot/action/go-cqhttp/UploadGroupFile.ts @@ -5,7 +5,7 @@ import fs from 'fs'; import { uriToLocalFile } from '@/common/file'; import { SendMessageContext } from '@/onebot/api'; import { z } from 'zod'; -import { actionType } from '../type'; +import { actionType } from '@/common/coerce'; const SchemaData = z.object({ group_id: actionType.string(), file: actionType.string(), diff --git a/src/onebot/action/go-cqhttp/UploadPrivateFile.ts b/src/onebot/action/go-cqhttp/UploadPrivateFile.ts index 6d53fda64..7de401880 100644 --- a/src/onebot/action/go-cqhttp/UploadPrivateFile.ts +++ b/src/onebot/action/go-cqhttp/UploadPrivateFile.ts @@ -6,7 +6,7 @@ import { uriToLocalFile } from '@/common/file'; import { SendMessageContext } from '@/onebot/api'; import { ContextMode, createContext } from '@/onebot/action/msg/SendMsg'; import { z } from 'zod'; -import { actionType } from '../type'; +import { actionType } from '@/common/coerce'; const SchemaData = z.object({ user_id: actionType.string(), file: actionType.string(), diff --git a/src/onebot/action/group/DelEssenceMsg.ts b/src/onebot/action/group/DelEssenceMsg.ts index 1d108bec0..846aced13 100644 --- a/src/onebot/action/group/DelEssenceMsg.ts +++ b/src/onebot/action/group/DelEssenceMsg.ts @@ -2,7 +2,7 @@ import { OneBotAction } from '@/onebot/action/OneBotAction'; import { ActionName } from '@/onebot/action/router'; import { MessageUnique } from '@/common/message-unique'; import { z } from 'zod'; -import { actionType } from '../type'; +import { actionType } from '@/common/coerce'; const SchemaData = z.object({ message_id: actionType.string(), }); diff --git a/src/onebot/action/group/DelGroupNotice.ts b/src/onebot/action/group/DelGroupNotice.ts index 7ec4de9c1..b012f87db 100644 --- a/src/onebot/action/group/DelGroupNotice.ts +++ b/src/onebot/action/group/DelGroupNotice.ts @@ -1,7 +1,7 @@ import { OneBotAction } from '@/onebot/action/OneBotAction'; import { ActionName } from '@/onebot/action/router'; import { z } from 'zod'; -import { actionType } from '../type'; +import { actionType } from '@/common/coerce'; const SchemaData = z.object({ group_id: actionType.string(), notice_id: actionType.string() diff --git a/src/onebot/action/group/GetAiRecord.ts b/src/onebot/action/group/GetAiRecord.ts index 58d40b1d6..7e0d002c8 100644 --- a/src/onebot/action/group/GetAiRecord.ts +++ b/src/onebot/action/group/GetAiRecord.ts @@ -2,7 +2,7 @@ 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 { actionType } from '../type'; +import { actionType } from '@/common/coerce'; const SchemaData = z.object({ character: actionType.string(), group_id: actionType.string(), diff --git a/src/onebot/action/group/GetGroupEssence.ts b/src/onebot/action/group/GetGroupEssence.ts index 0176994ed..500d7dba3 100644 --- a/src/onebot/action/group/GetGroupEssence.ts +++ b/src/onebot/action/group/GetGroupEssence.ts @@ -5,7 +5,7 @@ import { MessageUnique } from '@/common/message-unique'; import crypto from 'crypto'; import { z } from 'zod'; import { NetworkAdapterConfig } from '@/onebot/config/config'; -import { actionType } from '../type'; +import { actionType } from '@/common/coerce'; const SchemaData = z.object({ group_id: actionType.string(), }); diff --git a/src/onebot/action/group/GetGroupInfo.ts b/src/onebot/action/group/GetGroupInfo.ts index 9a24c3c05..f427c2244 100644 --- a/src/onebot/action/group/GetGroupInfo.ts +++ b/src/onebot/action/group/GetGroupInfo.ts @@ -3,7 +3,7 @@ import { OB11Construct } from '@/onebot/helper/data'; import { OneBotAction } from '@/onebot/action/OneBotAction'; import { ActionName } from '@/onebot/action/router'; import { z } from 'zod'; -import { actionType } from '../type'; +import { actionType } from '@/common/coerce'; const SchemaData = z.object({ group_id: actionType.string(), }); diff --git a/src/onebot/action/group/GetGroupList.ts b/src/onebot/action/group/GetGroupList.ts index 98f7d407e..648d6cdcf 100644 --- a/src/onebot/action/group/GetGroupList.ts +++ b/src/onebot/action/group/GetGroupList.ts @@ -3,7 +3,7 @@ import { OB11Construct } from '@/onebot/helper/data'; import { OneBotAction } from '@/onebot/action/OneBotAction'; import { ActionName } from '@/onebot/action/router'; import { z } from 'zod'; -import { actionType } from '../type'; +import { actionType } from '@/common/coerce'; const SchemaData = z.object({ no_cache: actionType.boolean().default(false), diff --git a/src/onebot/action/group/GetGroupMemberInfo.ts b/src/onebot/action/group/GetGroupMemberInfo.ts index 0aa72dde8..b1925fd6a 100644 --- a/src/onebot/action/group/GetGroupMemberInfo.ts +++ b/src/onebot/action/group/GetGroupMemberInfo.ts @@ -3,7 +3,7 @@ import { OB11Construct } from '@/onebot/helper/data'; import { OneBotAction } from '@/onebot/action/OneBotAction'; import { ActionName } from '@/onebot/action/router'; import { z } from 'zod'; -import { actionType } from '../type'; +import { actionType } from '@/common/coerce'; const SchemaData = z.object({ group_id: actionType.string(), diff --git a/src/onebot/action/group/GetGroupMemberList.ts b/src/onebot/action/group/GetGroupMemberList.ts index 746efbaa6..909392bad 100644 --- a/src/onebot/action/group/GetGroupMemberList.ts +++ b/src/onebot/action/group/GetGroupMemberList.ts @@ -4,7 +4,7 @@ import { OneBotAction } from '@/onebot/action/OneBotAction'; import { ActionName } from '@/onebot/action/router'; import { z } from 'zod'; import { GroupMember } from '@/core'; -import { actionType } from '../type'; +import { actionType } from '@/common/coerce'; const SchemaData = z.object({ group_id: actionType.string(), diff --git a/src/onebot/action/group/GetGroupNotice.ts b/src/onebot/action/group/GetGroupNotice.ts index 89f30a32c..86ef5b0c0 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 { actionType } from '../type'; +import { actionType } from '@/common/coerce'; interface GroupNotice { sender_id: number; publish_time: number; diff --git a/src/onebot/action/group/GetGroupShutList.ts b/src/onebot/action/group/GetGroupShutList.ts index 3133b412d..b65bacad2 100644 --- a/src/onebot/action/group/GetGroupShutList.ts +++ b/src/onebot/action/group/GetGroupShutList.ts @@ -2,7 +2,7 @@ import { ShutUpGroupMember } from '@/core'; import { OneBotAction } from '@/onebot/action/OneBotAction'; import { ActionName } from '@/onebot/action/router'; import { z } from 'zod'; -import { actionType } from '../type'; +import { actionType } from '@/common/coerce'; const SchemaData = z.object({ group_id: actionType.string(), }); diff --git a/src/onebot/action/group/GroupPoke.ts b/src/onebot/action/group/GroupPoke.ts index 09d958e52..00c6fff8a 100644 --- a/src/onebot/action/group/GroupPoke.ts +++ b/src/onebot/action/group/GroupPoke.ts @@ -1,7 +1,7 @@ import { ActionName } from '@/onebot/action/router'; import { GetPacketStatusDepends } from '@/onebot/action/packet/GetPacketStatus'; import { z } from 'zod'; -import { actionType } from '../type'; +import { actionType } from '@/common/coerce'; const SchemaData = z.object({ group_id: actionType.string(), user_id: actionType.string(), diff --git a/src/onebot/action/group/SendGroupAiRecord.ts b/src/onebot/action/group/SendGroupAiRecord.ts index bb1c85fd7..454f77bef 100644 --- a/src/onebot/action/group/SendGroupAiRecord.ts +++ b/src/onebot/action/group/SendGroupAiRecord.ts @@ -2,7 +2,7 @@ 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 { actionType } from '../type'; +import { actionType } from '@/common/coerce'; const SchemaData = z.object({ character: actionType.string(), group_id: actionType.string(), diff --git a/src/onebot/action/group/SetEssenceMsg.ts b/src/onebot/action/group/SetEssenceMsg.ts index de3c7f436..04026cd05 100644 --- a/src/onebot/action/group/SetEssenceMsg.ts +++ b/src/onebot/action/group/SetEssenceMsg.ts @@ -2,7 +2,7 @@ import { OneBotAction } from '@/onebot/action/OneBotAction'; import { ActionName } from '@/onebot/action/router'; import { MessageUnique } from '@/common/message-unique'; import { z } from 'zod'; -import { actionType } from '../type'; +import { actionType } from '@/common/coerce'; const SchemaData = z.object({ message_id: actionType.string(), }); diff --git a/src/onebot/action/group/SetGroupAddRequest.ts b/src/onebot/action/group/SetGroupAddRequest.ts index f0ced956d..cabe123e0 100644 --- a/src/onebot/action/group/SetGroupAddRequest.ts +++ b/src/onebot/action/group/SetGroupAddRequest.ts @@ -2,7 +2,7 @@ import { OneBotAction } from '@/onebot/action/OneBotAction'; import { NTGroupRequestOperateTypes } from '@/core/types'; import { ActionName } from '@/onebot/action/router'; import { z } from 'zod'; -import { actionType } from '../type'; +import { actionType } from '@/common/coerce'; const SchemaData = z.object({ flag: actionType.string(), diff --git a/src/onebot/action/group/SetGroupAdmin.ts b/src/onebot/action/group/SetGroupAdmin.ts index 4067b4fff..f690ba9fd 100644 --- a/src/onebot/action/group/SetGroupAdmin.ts +++ b/src/onebot/action/group/SetGroupAdmin.ts @@ -2,7 +2,7 @@ import { OneBotAction } from '@/onebot/action/OneBotAction'; import { NTGroupMemberRole } from '@/core/types'; import { ActionName } from '@/onebot/action/router'; import { z } from 'zod'; -import { actionType } from '../type'; +import { actionType } from '@/common/coerce'; const SchemaData = z.object({ group_id: actionType.string(), diff --git a/src/onebot/action/group/SetGroupBan.ts b/src/onebot/action/group/SetGroupBan.ts index e4fe3c03d..c65d461cb 100644 --- a/src/onebot/action/group/SetGroupBan.ts +++ b/src/onebot/action/group/SetGroupBan.ts @@ -1,7 +1,7 @@ import { OneBotAction } from '@/onebot/action/OneBotAction'; import { ActionName } from '@/onebot/action/router'; import { z } from 'zod'; -import { actionType } from '../type'; +import { actionType } from '@/common/coerce'; const SchemaData = z.object({ group_id: actionType.string(), user_id: actionType.string(), diff --git a/src/onebot/action/group/SetGroupCard.ts b/src/onebot/action/group/SetGroupCard.ts index 870af15ff..f0e0b53b9 100644 --- a/src/onebot/action/group/SetGroupCard.ts +++ b/src/onebot/action/group/SetGroupCard.ts @@ -1,7 +1,7 @@ import { OneBotAction } from '@/onebot/action/OneBotAction'; import { ActionName } from '@/onebot/action/router'; import { z } from 'zod'; -import { actionType } from '../type'; +import { actionType } from '@/common/coerce'; const SchemaData = z.object({ group_id: actionType.string(), user_id: actionType.string(), diff --git a/src/onebot/action/group/SetGroupKick.ts b/src/onebot/action/group/SetGroupKick.ts index a394b9c88..08f6ec50a 100644 --- a/src/onebot/action/group/SetGroupKick.ts +++ b/src/onebot/action/group/SetGroupKick.ts @@ -1,7 +1,7 @@ import { OneBotAction } from '@/onebot/action/OneBotAction'; import { ActionName } from '@/onebot/action/router'; import { z } from 'zod'; -import { actionType } from '../type'; +import { actionType } from '@/common/coerce'; const SchemaData = z.object({ group_id: actionType.string(), diff --git a/src/onebot/action/group/SetGroupLeave.ts b/src/onebot/action/group/SetGroupLeave.ts index a21c890ed..4823c6bb8 100644 --- a/src/onebot/action/group/SetGroupLeave.ts +++ b/src/onebot/action/group/SetGroupLeave.ts @@ -1,7 +1,7 @@ import { OneBotAction } from '@/onebot/action/OneBotAction'; import { ActionName } from '@/onebot/action/router'; import { z } from 'zod'; -import { actionType } from '../type'; +import { actionType } from '@/common/coerce'; const SchemaData = z.object({ group_id: actionType.string(), diff --git a/src/onebot/action/group/SetGroupName.ts b/src/onebot/action/group/SetGroupName.ts index b1949b45e..bd6440493 100644 --- a/src/onebot/action/group/SetGroupName.ts +++ b/src/onebot/action/group/SetGroupName.ts @@ -2,7 +2,7 @@ import { OneBotAction } from '@/onebot/action/OneBotAction'; import { ActionName } from '@/onebot/action/router'; import { z } from 'zod'; -import { actionType } from '../type'; +import { actionType } from '@/common/coerce'; const SchemaData = z.object({ group_id: actionType.string(), group_name: actionType.string(), diff --git a/src/onebot/action/group/SetGroupWholeBan.ts b/src/onebot/action/group/SetGroupWholeBan.ts index e35b85b86..0e6c120ce 100644 --- a/src/onebot/action/group/SetGroupWholeBan.ts +++ b/src/onebot/action/group/SetGroupWholeBan.ts @@ -1,7 +1,7 @@ import { OneBotAction } from '@/onebot/action/OneBotAction'; import { ActionName } from '@/onebot/action/router'; import { z } from 'zod'; -import { actionType } from '../type'; +import { actionType } from '@/common/coerce'; const SchemaData = z.object({ group_id: actionType.string(), diff --git a/src/onebot/action/msg/DeleteMsg.ts b/src/onebot/action/msg/DeleteMsg.ts index 3d88c5a89..b1305dcca 100644 --- a/src/onebot/action/msg/DeleteMsg.ts +++ b/src/onebot/action/msg/DeleteMsg.ts @@ -2,7 +2,7 @@ import { ActionName } from '@/onebot/action/router'; import { OneBotAction } from '@/onebot/action/OneBotAction'; import { MessageUnique } from '@/common/message-unique'; import { z } from 'zod'; -import { actionType } from '../type'; +import { actionType } from '@/common/coerce'; const SchemaData = z.object({ message_id: actionType.string(), diff --git a/src/onebot/action/msg/ForwardSingleMsg.ts b/src/onebot/action/msg/ForwardSingleMsg.ts index 3497a40c6..c7e2c2455 100644 --- a/src/onebot/action/msg/ForwardSingleMsg.ts +++ b/src/onebot/action/msg/ForwardSingleMsg.ts @@ -3,7 +3,7 @@ import { ChatType, Peer } from '@/core/types'; import { ActionName } from '@/onebot/action/router'; import { MessageUnique } from '@/common/message-unique'; import { z } from 'zod'; -import { actionType } from '../type'; +import { actionType } from '@/common/coerce'; const SchemaData = z.object({ message_id: actionType.string(), group_id: actionType.string().optional(), diff --git a/src/onebot/action/msg/GetMsg.ts b/src/onebot/action/msg/GetMsg.ts index 347b1502c..ce287a5e5 100644 --- a/src/onebot/action/msg/GetMsg.ts +++ b/src/onebot/action/msg/GetMsg.ts @@ -5,7 +5,7 @@ import { MessageUnique } from '@/common/message-unique'; import { RawMessage } from '@/core'; import { z } from 'zod'; import { NetworkAdapterConfig } from '@/onebot/config/config'; -import { actionType } from '../type'; +import { actionType } from '@/common/coerce'; export type ReturnDataType = OB11Message const SchemaData = z.object({ diff --git a/src/onebot/action/msg/MarkMsgAsRead.ts b/src/onebot/action/msg/MarkMsgAsRead.ts index fcb8e2711..52ee09e10 100644 --- a/src/onebot/action/msg/MarkMsgAsRead.ts +++ b/src/onebot/action/msg/MarkMsgAsRead.ts @@ -3,7 +3,7 @@ import { OneBotAction } from '@/onebot/action/OneBotAction'; import { ActionName } from '@/onebot/action/router'; import { MessageUnique } from '@/common/message-unique'; import { z } from 'zod'; -import { actionType } from '../type'; +import { actionType } from '@/common/coerce'; const SchemaData = z.object({ user_id: actionType.string().optional(), group_id: actionType.string().optional(), diff --git a/src/onebot/action/msg/SetMsgEmojiLike.ts b/src/onebot/action/msg/SetMsgEmojiLike.ts index b71983efb..1eb9eed82 100644 --- a/src/onebot/action/msg/SetMsgEmojiLike.ts +++ b/src/onebot/action/msg/SetMsgEmojiLike.ts @@ -2,7 +2,7 @@ import { ActionName } from '@/onebot/action/router'; import { OneBotAction } from '@/onebot/action/OneBotAction'; import { MessageUnique } from '@/common/message-unique'; import { z } from 'zod'; -import { actionType } from '../type'; +import { actionType } from '@/common/coerce'; const SchemaData = z.object({ message_id: actionType.string(), diff --git a/src/onebot/action/packet/SendPoke.ts b/src/onebot/action/packet/SendPoke.ts index dcd9da64f..438f802f0 100644 --- a/src/onebot/action/packet/SendPoke.ts +++ b/src/onebot/action/packet/SendPoke.ts @@ -1,7 +1,7 @@ import { ActionName } from '@/onebot/action/router'; import { GetPacketStatusDepends } from '@/onebot/action/packet/GetPacketStatus'; import { z } from 'zod'; -import { actionType } from '../type'; +import { actionType } from '@/common/coerce'; const SchemaData = z.object({ group_id: actionType.string().optional(), diff --git a/src/onebot/action/system/GetCredentials.ts b/src/onebot/action/system/GetCredentials.ts index 072281280..cb49f0ccf 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 { actionType } from '../type'; +import { actionType } from '@/common/coerce'; interface Response { cookies: string, diff --git a/src/onebot/action/user/FriendPoke.ts b/src/onebot/action/user/FriendPoke.ts index 68493c94a..5b8ba4254 100644 --- a/src/onebot/action/user/FriendPoke.ts +++ b/src/onebot/action/user/FriendPoke.ts @@ -1,7 +1,7 @@ import { ActionName } from '@/onebot/action/router'; import { GetPacketStatusDepends } from '@/onebot/action/packet/GetPacketStatus'; import { z } from 'zod'; -import { actionType } from '../type'; +import { actionType } from '@/common/coerce'; const SchemaData = z.object({ user_id: actionType.string() diff --git a/src/onebot/action/user/GetCookies.ts b/src/onebot/action/user/GetCookies.ts index 60c344240..da021c339 100644 --- a/src/onebot/action/user/GetCookies.ts +++ b/src/onebot/action/user/GetCookies.ts @@ -1,7 +1,7 @@ import { OneBotAction } from '@/onebot/action/OneBotAction'; import { ActionName } from '@/onebot/action/router'; import { z } from 'zod'; -import { actionType } from '../type'; +import { actionType } from '@/common/coerce'; interface Response { cookies: string, bkn: string diff --git a/src/onebot/action/user/GetFriendList.ts b/src/onebot/action/user/GetFriendList.ts index 74cc6815b..ef85df428 100644 --- a/src/onebot/action/user/GetFriendList.ts +++ b/src/onebot/action/user/GetFriendList.ts @@ -3,7 +3,7 @@ import { OB11Construct } from '@/onebot/helper/data'; import { OneBotAction } from '@/onebot/action/OneBotAction'; import { ActionName } from '@/onebot/action/router'; import { z } from 'zod'; -import { actionType } from '../type'; +import { actionType } from '@/common/coerce'; const SchemaData = z.object({ no_cache: actionType.boolean().optional(), diff --git a/src/onebot/action/user/GetRecentContact.ts b/src/onebot/action/user/GetRecentContact.ts index 8a551b540..4c817eb3d 100644 --- a/src/onebot/action/user/GetRecentContact.ts +++ b/src/onebot/action/user/GetRecentContact.ts @@ -3,7 +3,7 @@ import { OneBotAction } from '@/onebot/action/OneBotAction'; import { ActionName } from '@/onebot/action/router'; import { NetworkAdapterConfig } from '@/onebot/config/config'; import { z } from 'zod'; -import { actionType } from '../type'; +import { actionType } from '@/common/coerce'; const SchemaData = z.object({ count: actionType.number().default(10), diff --git a/src/onebot/action/user/SendLike.ts b/src/onebot/action/user/SendLike.ts index 5ac5078e7..7630161ac 100644 --- a/src/onebot/action/user/SendLike.ts +++ b/src/onebot/action/user/SendLike.ts @@ -1,7 +1,7 @@ import { OneBotAction } from '@/onebot/action/OneBotAction'; import { ActionName } from '@/onebot/action/router'; import { z } from 'zod'; -import { actionType } from '../type'; +import { actionType } from '@/common/coerce'; const SchemaData = z.object({ times: actionType.number().default(1), diff --git a/src/onebot/action/user/SetFriendAddRequest.ts b/src/onebot/action/user/SetFriendAddRequest.ts index 3fb71e18b..f35318d46 100644 --- a/src/onebot/action/user/SetFriendAddRequest.ts +++ b/src/onebot/action/user/SetFriendAddRequest.ts @@ -1,7 +1,7 @@ import { OneBotAction } from '@/onebot/action/OneBotAction'; import { ActionName } from '@/onebot/action/router'; import { z } from 'zod'; -import { actionType } from '../type'; +import { actionType } from '@/common/coerce'; const SchemaData = z.object({ flag: actionType.string(), diff --git a/src/onebot/config/config.ts b/src/onebot/config/config.ts index 7ee9d3b70..266106b62 100644 --- a/src/onebot/config/config.ts +++ b/src/onebot/config/config.ts @@ -1,5 +1,5 @@ import { z } from 'zod'; -import { actionType } from '../action/type'; +import { actionType } from '../../common/coerce'; const HttpServerConfigSchema = z.object({ name: actionType.string().default('http-server'), diff --git a/src/webui/src/helper/config.ts b/src/webui/src/helper/config.ts index ffaf6df1b..af8e9c5c6 100644 --- a/src/webui/src/helper/config.ts +++ b/src/webui/src/helper/config.ts @@ -4,7 +4,7 @@ import { resolve } from 'node:path'; import { deepMerge } from '../utils/object'; import { themeType } from '../types/theme'; import { z } from 'zod'; -import { actionType } from '@/onebot/action/type'; +import { actionType } from '@/common/coerce'; // 定义配置的类型 const WebUiConfigSchema = z.object({ host: actionType.string().default('0.0.0.0'), diff --git a/src/webui/src/types/theme.ts b/src/webui/src/types/theme.ts index d62d08213..02be0c38d 100644 --- a/src/webui/src/types/theme.ts +++ b/src/webui/src/types/theme.ts @@ -1,4 +1,4 @@ -import { actionType } from '@/onebot/action/type'; +import { actionType } from '@/common/coerce'; import { z } from 'zod'; export const themeType = z.object( From 41dccd98a9e150671391c9089e6e1bfbe47393df Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=89=8B=E7=93=9C=E4=B8=80=E5=8D=81=E9=9B=AA?= Date: Thu, 17 Apr 2025 09:54:12 +0800 Subject: [PATCH 4/5] fix --- src/common/coerce.ts | 2 +- src/core/helper/config.ts | 16 +-- .../extends/ClickInlineKeyboardButton.ts | 12 +- src/onebot/action/extends/CreateCollection.ts | 6 +- src/onebot/action/extends/FetchCustomFace.ts | 4 +- src/onebot/action/extends/FetchEmojiLike.ts | 10 +- src/onebot/action/extends/GetAiCharacters.ts | 6 +- .../action/extends/GetCollectionList.ts | 6 +- src/onebot/action/extends/GetGroupInfoEx.ts | 4 +- src/onebot/action/extends/GetMiniAppArk.ts | 46 ++++---- src/onebot/action/extends/GetProfileLike.ts | 8 +- src/onebot/action/extends/GetUserStatus.ts | 4 +- src/onebot/action/extends/MoveGroupFile.ts | 10 +- src/onebot/action/extends/OCRImage.ts | 4 +- src/onebot/action/extends/RenameGroupFile.ts | 10 +- src/onebot/action/extends/SendPacket.ts | 8 +- .../action/extends/SetDiyOnlineStatus.ts | 8 +- src/onebot/action/extends/SetGroupRemark.ts | 6 +- src/onebot/action/extends/SetGroupSign.ts | 4 +- src/onebot/action/extends/SetInputStatus.ts | 6 +- src/onebot/action/extends/SetLongNick.ts | 4 +- src/onebot/action/extends/SetOnlineStatus.ts | 8 +- src/onebot/action/extends/SetQQAvatar.ts | 4 +- src/onebot/action/extends/SetSpecialTitle.ts | 8 +- src/onebot/action/extends/ShareContact.ts | 10 +- src/onebot/action/extends/TransGroupFile.ts | 6 +- .../action/extends/TranslateEnWordToZn.ts | 4 +- src/onebot/action/file/GetFile.ts | 6 +- src/onebot/action/file/GetGroupFileUrl.ts | 6 +- src/onebot/action/file/GetPrivateFileUrl.ts | 4 +- .../action/go-cqhttp/CreateGroupFileFolder.ts | 6 +- .../action/go-cqhttp/DeleteGroupFile.ts | 6 +- .../action/go-cqhttp/DeleteGroupFileFolder.ts | 8 +- src/onebot/action/go-cqhttp/DownloadFile.ts | 10 +- src/onebot/action/go-cqhttp/GetForwardMsg.ts | 6 +- .../action/go-cqhttp/GetFriendMsgHistory.ts | 10 +- .../action/go-cqhttp/GetGroupAtAllRemain.ts | 4 +- .../go-cqhttp/GetGroupFileSystemInfo.ts | 4 +- .../action/go-cqhttp/GetGroupFilesByFolder.ts | 10 +- .../action/go-cqhttp/GetGroupHonorInfo.ts | 4 +- .../action/go-cqhttp/GetGroupMsgHistory.ts | 10 +- .../action/go-cqhttp/GetGroupRootFiles.ts | 6 +- .../action/go-cqhttp/GetStrangerInfo.ts | 6 +- .../go-cqhttp/GoCQHTTPCheckUrlSafely.ts | 4 +- .../action/go-cqhttp/GoCQHTTPDeleteFriend.ts | 10 +- .../action/go-cqhttp/GoCQHTTPGetModelShow.ts | 4 +- .../action/go-cqhttp/SendGroupNotice.ts | 18 +-- .../action/go-cqhttp/SetGroupPortrait.ts | 6 +- src/onebot/action/go-cqhttp/SetQQProfile.ts | 8 +- .../action/go-cqhttp/UploadGroupFile.ts | 12 +- .../action/go-cqhttp/UploadPrivateFile.ts | 8 +- src/onebot/action/group/DelEssenceMsg.ts | 4 +- src/onebot/action/group/DelGroupNotice.ts | 6 +- src/onebot/action/group/GetAiRecord.ts | 8 +- src/onebot/action/group/GetGroupEssence.ts | 4 +- src/onebot/action/group/GetGroupInfo.ts | 4 +- src/onebot/action/group/GetGroupList.ts | 4 +- src/onebot/action/group/GetGroupMemberInfo.ts | 8 +- src/onebot/action/group/GetGroupMemberList.ts | 6 +- src/onebot/action/group/GetGroupNotice.ts | 4 +- src/onebot/action/group/GetGroupShutList.ts | 4 +- src/onebot/action/group/GroupPoke.ts | 6 +- src/onebot/action/group/SendGroupAiRecord.ts | 8 +- src/onebot/action/group/SetEssenceMsg.ts | 4 +- src/onebot/action/group/SetGroupAddRequest.ts | 8 +- src/onebot/action/group/SetGroupAdmin.ts | 8 +- src/onebot/action/group/SetGroupBan.ts | 8 +- src/onebot/action/group/SetGroupCard.ts | 8 +- src/onebot/action/group/SetGroupKick.ts | 8 +- src/onebot/action/group/SetGroupLeave.ts | 6 +- src/onebot/action/group/SetGroupName.ts | 6 +- src/onebot/action/group/SetGroupWholeBan.ts | 6 +- src/onebot/action/msg/DeleteMsg.ts | 4 +- src/onebot/action/msg/ForwardSingleMsg.ts | 8 +- src/onebot/action/msg/GetMsg.ts | 4 +- src/onebot/action/msg/MarkMsgAsRead.ts | 8 +- src/onebot/action/msg/SetMsgEmojiLike.ts | 8 +- src/onebot/action/packet/SendPoke.ts | 6 +- src/onebot/action/system/GetCredentials.ts | 4 +- src/onebot/action/user/FriendPoke.ts | 4 +- src/onebot/action/user/GetCookies.ts | 4 +- src/onebot/action/user/GetFriendList.ts | 4 +- src/onebot/action/user/GetRecentContact.ts | 4 +- src/onebot/action/user/SendLike.ts | 6 +- src/onebot/action/user/SetFriendAddRequest.ts | 8 +- src/onebot/config/config.ts | 108 +++++++++--------- src/webui/src/helper/config.ts | 12 +- src/webui/src/types/theme.ts | 6 +- 88 files changed, 363 insertions(+), 363 deletions(-) diff --git a/src/common/coerce.ts b/src/common/coerce.ts index 46eb174db..6aabd5382 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 actionType = { boolean, number, string }; \ No newline at end of file +export const coerce = { boolean, number, string }; \ No newline at end of file diff --git a/src/core/helper/config.ts b/src/core/helper/config.ts index ca3d22686..667212520 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 { actionType } from '@/common/coerce'; +import { coerce } from '@/common/coerce'; import { z } from 'zod'; export const NapcatConfigSchema = z.object({ - 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), + 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), }); export type NapcatConfig = z.infer; diff --git a/src/onebot/action/extends/ClickInlineKeyboardButton.ts b/src/onebot/action/extends/ClickInlineKeyboardButton.ts index fba1830cd..e7279c51c 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 { actionType } from '@/common/coerce'; +import { coerce } from '@/common/coerce'; const SchemaData = z.object({ - group_id: actionType.string(), - bot_appid: actionType.string(), - button_id: actionType.string().default(''), - callback_data: actionType.string().default(''), - msg_seq: actionType.string().default('10086'), + group_id: coerce.string(), + bot_appid: coerce.string(), + button_id: coerce.string().default(''), + callback_data: coerce.string().default(''), + msg_seq: coerce.string().default('10086'), }); type Payload = z.infer; diff --git a/src/onebot/action/extends/CreateCollection.ts b/src/onebot/action/extends/CreateCollection.ts index 0faf8b4ec..dd641d1b6 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 { actionType } from '@/common/coerce'; +import { coerce } from '@/common/coerce'; const SchemaData = z.object({ - rawData: actionType.string(), - brief: actionType.string(), + rawData: coerce.string(), + brief: coerce.string(), }); type Payload = z.infer; diff --git a/src/onebot/action/extends/FetchCustomFace.ts b/src/onebot/action/extends/FetchCustomFace.ts index ee6a535ca..b14d2afa2 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 { actionType } from '@/common/coerce'; +import { coerce } from '@/common/coerce'; const SchemaData = z.object({ - count: actionType.number().default(48), + count: coerce.number().default(48), }); type Payload = z.infer; diff --git a/src/onebot/action/extends/FetchEmojiLike.ts b/src/onebot/action/extends/FetchEmojiLike.ts index c55ce0c4d..ee383046b 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 { actionType } from '@/common/coerce'; +import { coerce } from '@/common/coerce'; const SchemaData = z.object({ - message_id: actionType.string(), - emojiId: actionType.string(), - emojiType: actionType.string(), - count: actionType.number().default(20), + message_id: coerce.string(), + emojiId: coerce.string(), + emojiType: coerce.string(), + count: coerce.number().default(20), }); type Payload = z.infer; diff --git a/src/onebot/action/extends/GetAiCharacters.ts b/src/onebot/action/extends/GetAiCharacters.ts index 7e2210bd4..5eb7fc5ba 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 { actionType } from '@/common/coerce'; +import { coerce } from '@/common/coerce'; const SchemaData = z.object({ - group_id: actionType.string(), - chat_type: actionType.number().default(1), + group_id: coerce.string(), + chat_type: coerce.number().default(1), }); type Payload = z.infer; diff --git a/src/onebot/action/extends/GetCollectionList.ts b/src/onebot/action/extends/GetCollectionList.ts index 1cb629617..4c170cffe 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 { actionType } from '@/common/coerce'; +import { coerce } from '@/common/coerce'; const SchemaData = z.object({ - category: actionType.number(), - count: actionType.number().default(1), + category: coerce.number(), + count: coerce.number().default(1), }); type Payload = z.infer; diff --git a/src/onebot/action/extends/GetGroupInfoEx.ts b/src/onebot/action/extends/GetGroupInfoEx.ts index 9ed398bcb..f0078a41d 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 { actionType } from '@/common/coerce'; +import { coerce } from '@/common/coerce'; const SchemaData = z.object({ - group_id: actionType.string(), + group_id: coerce.string(), }); type Payload = z.infer; diff --git a/src/onebot/action/extends/GetMiniAppArk.ts b/src/onebot/action/extends/GetMiniAppArk.ts index 2bd60b0af..d9ea14492 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 { actionType } from '@/common/coerce'; +import { coerce } from '@/common/coerce'; const SchemaData = z.union([ z.object({ type: z.union([z.literal('bili'), z.literal('weibo')]), - title: actionType.string(), - desc: actionType.string(), - picUrl: actionType.string(), - jumpUrl: actionType.string(), - webUrl: actionType.string().optional(), - rawArkData: actionType.string().optional() + title: coerce.string(), + desc: coerce.string(), + picUrl: coerce.string(), + jumpUrl: coerce.string(), + webUrl: coerce.string().optional(), + rawArkData: coerce.string().optional() }), z.object({ - 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() + 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() }) ]); type Payload = z.infer; diff --git a/src/onebot/action/extends/GetProfileLike.ts b/src/onebot/action/extends/GetProfileLike.ts index cefd9e555..f4cf7400f 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 { actionType } from '@/common/coerce'; +import { coerce } from '@/common/coerce'; const SchemaData = z.object({ - user_id: actionType.string().optional(), - start: actionType.number().default(0), - count: actionType.number().default(10), + user_id: coerce.string().optional(), + start: coerce.number().default(0), + count: coerce.number().default(10), }); type Payload = z.infer; diff --git a/src/onebot/action/extends/GetUserStatus.ts b/src/onebot/action/extends/GetUserStatus.ts index 38ac00079..66aeb609c 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 { actionType } from '@/common/coerce'; +import { coerce } from '@/common/coerce'; const SchemaData = z.object({ - user_id: actionType.number(), + user_id: coerce.number(), }); type Payload = z.infer; diff --git a/src/onebot/action/extends/MoveGroupFile.ts b/src/onebot/action/extends/MoveGroupFile.ts index 7e2e6eb45..bf5c1c488 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 { actionType } from '@/common/coerce'; +import { coerce } from '@/common/coerce'; const SchemaData = z.object({ - group_id: actionType.string(), - file_id: actionType.string(), - current_parent_directory: actionType.string(), - target_parent_directory: actionType.string(), + group_id: coerce.string(), + file_id: coerce.string(), + current_parent_directory: coerce.string(), + target_parent_directory: coerce.string(), }); type Payload = z.infer; diff --git a/src/onebot/action/extends/OCRImage.ts b/src/onebot/action/extends/OCRImage.ts index c08a12b50..c280a3ccb 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 { actionType } from '@/common/coerce'; +import { coerce } from '@/common/coerce'; const SchemaData = z.object({ - image: actionType.string(), + image: coerce.string(), }); type Payload = z.infer; diff --git a/src/onebot/action/extends/RenameGroupFile.ts b/src/onebot/action/extends/RenameGroupFile.ts index ff40a66be..8c6e79641 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 { actionType } from '@/common/coerce'; +import { coerce } from '@/common/coerce'; const SchemaData = z.object({ - group_id: actionType.string(), - file_id: actionType.string(), - current_parent_directory: actionType.string(), - new_name: actionType.string(), + group_id: coerce.string(), + file_id: coerce.string(), + current_parent_directory: coerce.string(), + new_name: coerce.string(), }); type Payload = z.infer; diff --git a/src/onebot/action/extends/SendPacket.ts b/src/onebot/action/extends/SendPacket.ts index 27c133ad1..feeb4d342 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 { actionType } from '@/common/coerce'; +import { coerce } from '@/common/coerce'; const SchemaData = z.object({ - cmd: actionType.string(), - data: actionType.string(), - rsp: actionType.boolean().default(true), + cmd: coerce.string(), + data: coerce.string(), + rsp: coerce.boolean().default(true), }); type Payload = z.infer; diff --git a/src/onebot/action/extends/SetDiyOnlineStatus.ts b/src/onebot/action/extends/SetDiyOnlineStatus.ts index 43bffa639..d63895c8d 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 { actionType } from '@/common/coerce'; +import { coerce } from '@/common/coerce'; const SchemaData = z.object({ - face_id: actionType.string(),// 参考 face_config.json 的 QSid - face_type: actionType.string().default('1'), - wording: actionType.string().default(' '), + face_id: coerce.string(),// 参考 face_config.json 的 QSid + face_type: coerce.string().default('1'), + wording: coerce.string().default(' '), }); type Payload = z.infer; diff --git a/src/onebot/action/extends/SetGroupRemark.ts b/src/onebot/action/extends/SetGroupRemark.ts index d5b7b6a0e..ab6367ea9 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 { actionType } from '@/common/coerce'; +import { coerce } from '@/common/coerce'; const SchemaData = z.object({ - group_id: actionType.string(), - remark: actionType.string(), + group_id: coerce.string(), + remark: coerce.string(), }); type Payload = z.infer; diff --git a/src/onebot/action/extends/SetGroupSign.ts b/src/onebot/action/extends/SetGroupSign.ts index 56fdf5348..82c62fd55 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 { actionType } from '@/common/coerce'; +import { coerce } from '@/common/coerce'; const SchemaData = z.object({ - group_id: actionType.string(), + group_id: coerce.string(), }); type Payload = z.infer; diff --git a/src/onebot/action/extends/SetInputStatus.ts b/src/onebot/action/extends/SetInputStatus.ts index 98f28a94c..affc88dfb 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 { actionType } from '@/common/coerce'; +import { coerce } from '@/common/coerce'; const SchemaData = z.object({ - user_id: actionType.string(), - event_type: actionType.number(), + user_id: coerce.string(), + event_type: coerce.number(), }); type Payload = z.infer; diff --git a/src/onebot/action/extends/SetLongNick.ts b/src/onebot/action/extends/SetLongNick.ts index 4b05825b4..090f0fb47 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 { actionType } from '@/common/coerce'; +import { coerce } from '@/common/coerce'; const SchemaData = z.object({ - longNick: actionType.string(), + longNick: coerce.string(), }); type Payload = z.infer; diff --git a/src/onebot/action/extends/SetOnlineStatus.ts b/src/onebot/action/extends/SetOnlineStatus.ts index e863b4aef..414c16eed 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 { actionType } from '@/common/coerce'; +import { coerce } from '@/common/coerce'; const SchemaData = z.object({ - status: actionType.number(), - ext_status: actionType.number(), - battery_status: actionType.number(), + status: coerce.number(), + ext_status: coerce.number(), + battery_status: coerce.number(), }); type Payload = z.infer; diff --git a/src/onebot/action/extends/SetQQAvatar.ts b/src/onebot/action/extends/SetQQAvatar.ts index 767a5c3b4..17832c4c8 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 { actionType } from '@/common/coerce'; +import { coerce } from '@/common/coerce'; const SchemaData = z.object({ - file: actionType.string(), + file: coerce.string(), }); type Payload = z.infer; diff --git a/src/onebot/action/extends/SetSpecialTitle.ts b/src/onebot/action/extends/SetSpecialTitle.ts index efa4000ba..6dca5fd76 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 { actionType } from '@/common/coerce'; +import { coerce } from '@/common/coerce'; const SchemaData = z.object({ - group_id: actionType.string(), - user_id: actionType.string(), - special_title: actionType.string().default(''), + group_id: coerce.string(), + user_id: coerce.string(), + special_title: coerce.string().default(''), }); type Payload = z.infer; diff --git a/src/onebot/action/extends/ShareContact.ts b/src/onebot/action/extends/ShareContact.ts index 571bbdb7a..3a61fdf0d 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 { actionType } from '@/common/coerce'; +import { coerce } from '@/common/coerce'; const SchemaData = z.object({ - user_id: actionType.string().optional(), - group_id: actionType.string().optional(), - phoneNumber: actionType.string().default(''), + user_id: coerce.string().optional(), + group_id: coerce.string().optional(), + phoneNumber: coerce.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 bd5045a05..2c801334c 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 { actionType } from '@/common/coerce'; +import { coerce } from '@/common/coerce'; const SchemaData = z.object({ - group_id: actionType.string(), - file_id: actionType.string(), + group_id: coerce.string(), + file_id: coerce.string(), }); type Payload = z.infer; diff --git a/src/onebot/action/extends/TranslateEnWordToZn.ts b/src/onebot/action/extends/TranslateEnWordToZn.ts index ff27a83ff..9c2e064ec 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 { actionType } from '@/common/coerce'; +import { coerce } from '@/common/coerce'; const SchemaData = z.object({ - words: z.array(actionType.string()), + words: z.array(coerce.string()), }); type Payload = z.infer; diff --git a/src/onebot/action/file/GetFile.ts b/src/onebot/action/file/GetFile.ts index 55725be90..9a6dbe8df 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 { actionType } from '@/common/coerce'; +import { coerce } from '@/common/coerce'; export interface GetFileResponse { file?: string; // path url?: string; @@ -14,8 +14,8 @@ export interface GetFileResponse { } const GetFileBase_PayloadSchema = z.object({ - file: actionType.string().optional(), - file_id: actionType.string().optional(), + file: coerce.string().optional(), + file_id: coerce.string().optional(), }); diff --git a/src/onebot/action/file/GetGroupFileUrl.ts b/src/onebot/action/file/GetGroupFileUrl.ts index c90103e59..df0e66d47 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 { actionType } from '@/common/coerce'; +import { coerce } from '@/common/coerce'; const SchemaData = z.object({ - group_id: actionType.string(), - file_id: actionType.string(), + group_id: coerce.string(), + file_id: coerce.string(), }); type Payload = z.infer; diff --git a/src/onebot/action/file/GetPrivateFileUrl.ts b/src/onebot/action/file/GetPrivateFileUrl.ts index 04b9bf1a0..c830397f6 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 { actionType } from '@/common/coerce'; +import { coerce } from '@/common/coerce'; const SchemaData = z.object({ - file_id: actionType.string(), + file_id: coerce.string(), }); type Payload = z.infer; diff --git a/src/onebot/action/go-cqhttp/CreateGroupFileFolder.ts b/src/onebot/action/go-cqhttp/CreateGroupFileFolder.ts index 91e3e5225..0c9d53c64 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 { actionType } from '@/common/coerce'; +import { coerce } from '@/common/coerce'; const SchemaData = z.object({ - group_id: actionType.string(), - folder_name: actionType.string(), + group_id: coerce.string(), + folder_name: coerce.string(), }); type Payload = z.infer; diff --git a/src/onebot/action/go-cqhttp/DeleteGroupFile.ts b/src/onebot/action/go-cqhttp/DeleteGroupFile.ts index addee6b97..5e21d1a83 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 { actionType } from '@/common/coerce'; +import { coerce } from '@/common/coerce'; const SchemaData = z.object({ - group_id: actionType.string(), - file_id: actionType.string(), + group_id: coerce.string(), + file_id: coerce.string(), }); type Payload = z.infer; diff --git a/src/onebot/action/go-cqhttp/DeleteGroupFileFolder.ts b/src/onebot/action/go-cqhttp/DeleteGroupFileFolder.ts index be39f4762..b7f6cf1f0 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 { actionType } from '@/common/coerce'; +import { coerce } from '@/common/coerce'; const SchemaData = z.object({ - group_id: actionType.string(), - folder_id: actionType.string().optional(), - folder: actionType.string().optional(), + group_id: coerce.string(), + folder_id: coerce.string().optional(), + folder: coerce.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 d6288661c..4b0e0b741 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 { actionType } from '@/common/coerce'; +import { coerce } from '@/common/coerce'; interface FileResponse { file: string; } const SchemaData = z.object({ - url: actionType.string().optional(), - base64: actionType.string().optional(), - name: actionType.string().optional(), - headers: z.union([actionType.string(), z.array(actionType.string())]).optional(), + url: coerce.string().optional(), + base64: coerce.string().optional(), + name: coerce.string().optional(), + headers: z.union([coerce.string(), z.array(coerce.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 d49baefd6..95eb9eae9 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 { actionType } from '@/common/coerce'; +import { coerce } from '@/common/coerce'; const SchemaData = z.object({ - message_id: actionType.string().optional(), - id: actionType.string().optional(), + message_id: coerce.string().optional(), + id: coerce.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 2c0d4ecc1..84e1437e5 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 { actionType } from '@/common/coerce'; +import { coerce } from '@/common/coerce'; interface Response { messages: OB11Message[]; } const SchemaData = z.object({ - user_id: actionType.string(), - message_seq: actionType.string().optional(), - count: actionType.number().default(20), - reverseOrder: actionType.boolean().default(false) + user_id: coerce.string(), + message_seq: coerce.string().optional(), + count: coerce.number().default(20), + reverseOrder: coerce.boolean().default(false) }); diff --git a/src/onebot/action/go-cqhttp/GetGroupAtAllRemain.ts b/src/onebot/action/go-cqhttp/GetGroupAtAllRemain.ts index 6149aa51c..8846266b3 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 { actionType } from '@/common/coerce'; +import { coerce } from '@/common/coerce'; const SchemaData = z.object({ - group_id: actionType.string() + group_id: coerce.string() }); type Payload = z.infer; diff --git a/src/onebot/action/go-cqhttp/GetGroupFileSystemInfo.ts b/src/onebot/action/go-cqhttp/GetGroupFileSystemInfo.ts index 69c1edf45..ac4761009 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 { actionType } from '@/common/coerce'; +import { coerce } from '@/common/coerce'; const SchemaData = z.object({ - group_id: actionType.string() + group_id: coerce.string() }); type Payload = z.infer; diff --git a/src/onebot/action/go-cqhttp/GetGroupFilesByFolder.ts b/src/onebot/action/go-cqhttp/GetGroupFilesByFolder.ts index 93d700739..f68540747 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 { actionType } from '@/common/coerce'; +import { coerce } from '@/common/coerce'; const SchemaData = z.object({ - group_id: actionType.string(), - folder_id: actionType.string().optional(), - folder: actionType.string().optional(), - file_count: actionType.number().default(50), + group_id: coerce.string(), + folder_id: coerce.string().optional(), + folder: coerce.string().optional(), + file_count: coerce.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 b22c77b84..0a4c172b4 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 { actionType } from '@/common/coerce'; +import { coerce } from '@/common/coerce'; const SchemaData = z.object({ - group_id: actionType.string(), + group_id: coerce.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 bde27c1a4..d0203f844 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 { actionType } from '@/common/coerce'; +import { coerce } from '@/common/coerce'; interface Response { messages: OB11Message[]; } const SchemaData = z.object({ - group_id: actionType.string(), - message_seq: actionType.string().optional(), - count: actionType.number().default(20), - reverseOrder: actionType.boolean().default(false) + group_id: coerce.string(), + message_seq: coerce.string().optional(), + count: coerce.number().default(20), + reverseOrder: coerce.boolean().default(false) }); diff --git a/src/onebot/action/go-cqhttp/GetGroupRootFiles.ts b/src/onebot/action/go-cqhttp/GetGroupRootFiles.ts index 613bac174..3e8b46985 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 { actionType } from '@/common/coerce'; +import { coerce } from '@/common/coerce'; const SchemaData = z.object({ - group_id: actionType.string(), - file_count: actionType.number().default(50), + group_id: coerce.string(), + file_count: coerce.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 aa6282837..b0c0c96eb 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 { actionType } from '@/common/coerce'; +import { coerce } from '@/common/coerce'; const SchemaData = z.object({ - user_id: actionType.string(), - no_cache: actionType.boolean().default(false), + user_id: coerce.string(), + no_cache: coerce.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 997a16308..29811f4c9 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 { actionType } from '@/common/coerce'; +import { coerce } from '@/common/coerce'; const SchemaData = z.object({ - url: actionType.string(), + url: coerce.string(), }); type Payload = z.infer; diff --git a/src/onebot/action/go-cqhttp/GoCQHTTPDeleteFriend.ts b/src/onebot/action/go-cqhttp/GoCQHTTPDeleteFriend.ts index 079f681f5..427734dc9 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 { actionType } from '@/common/coerce'; +import { coerce } from '@/common/coerce'; const SchemaData = z.object({ - friend_id: actionType.string().optional(), - user_id: actionType.string().optional(), - temp_block: actionType.boolean().optional(), - temp_both_del: actionType.boolean().optional(), + friend_id: coerce.string().optional(), + user_id: coerce.string().optional(), + temp_block: coerce.boolean().optional(), + temp_both_del: coerce.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 bbcce797e..15c4069e6 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 { actionType } from '@/common/coerce'; +import { coerce } from '@/common/coerce'; const SchemaData = z.object({ - model: actionType.string(), + model: coerce.string(), }); type Payload = z.infer; diff --git a/src/onebot/action/go-cqhttp/SendGroupNotice.ts b/src/onebot/action/go-cqhttp/SendGroupNotice.ts index e309397c3..be63a1aea 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 { actionType } from '@/common/coerce'; +import { coerce } from '@/common/coerce'; const SchemaData = z.object({ - 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), + 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), }); type Payload = z.infer; diff --git a/src/onebot/action/go-cqhttp/SetGroupPortrait.ts b/src/onebot/action/go-cqhttp/SetGroupPortrait.ts index af178e9b2..3d83921eb 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 { actionType } from '@/common/coerce'; +import { coerce } from '@/common/coerce'; const SchemaData = z.object({ - file: actionType.string(), - group_id: actionType.string() + file: coerce.string(), + group_id: coerce.string() }); type Payload = z.infer; diff --git a/src/onebot/action/go-cqhttp/SetQQProfile.ts b/src/onebot/action/go-cqhttp/SetQQProfile.ts index 28bffd6ae..ae458c729 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 { actionType } from '@/common/coerce'; +import { coerce } from '@/common/coerce'; const SchemaData = z.object({ - nickname: actionType.string(), - personal_note: actionType.string().optional(), - sex: actionType.string().optional(), // 传Sex值?建议传0 + nickname: coerce.string(), + personal_note: coerce.string().optional(), + sex: coerce.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 195df4b95..e253bd09f 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 { actionType } from '@/common/coerce'; +import { coerce } from '@/common/coerce'; const SchemaData = z.object({ - group_id: actionType.string(), - file: actionType.string(), - name: actionType.string(), - folder: actionType.string().optional(), - folder_id: actionType.string().optional(),//临时扩展 + group_id: coerce.string(), + file: coerce.string(), + name: coerce.string(), + folder: coerce.string().optional(), + folder_id: coerce.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 7de401880..6d1d240f4 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 { actionType } from '@/common/coerce'; +import { coerce } from '@/common/coerce'; const SchemaData = z.object({ - user_id: actionType.string(), - file: actionType.string(), - name: actionType.string(), + user_id: coerce.string(), + file: coerce.string(), + name: coerce.string(), }); type Payload = z.infer; diff --git a/src/onebot/action/group/DelEssenceMsg.ts b/src/onebot/action/group/DelEssenceMsg.ts index 846aced13..2cc5957f8 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 { actionType } from '@/common/coerce'; +import { coerce } from '@/common/coerce'; const SchemaData = z.object({ - message_id: actionType.string(), + message_id: coerce.string(), }); type Payload = z.infer; diff --git a/src/onebot/action/group/DelGroupNotice.ts b/src/onebot/action/group/DelGroupNotice.ts index b012f87db..2737003fa 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 { actionType } from '@/common/coerce'; +import { coerce } from '@/common/coerce'; const SchemaData = z.object({ - group_id: actionType.string(), - notice_id: actionType.string() + group_id: coerce.string(), + notice_id: coerce.string() }); type Payload = z.infer; diff --git a/src/onebot/action/group/GetAiRecord.ts b/src/onebot/action/group/GetAiRecord.ts index 7e0d002c8..a02a6ddc8 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 { actionType } from '@/common/coerce'; +import { coerce } from '@/common/coerce'; const SchemaData = z.object({ - character: actionType.string(), - group_id: actionType.string(), - text: actionType.string(), + character: coerce.string(), + group_id: coerce.string(), + text: coerce.string(), }); type Payload = z.infer; diff --git a/src/onebot/action/group/GetGroupEssence.ts b/src/onebot/action/group/GetGroupEssence.ts index 500d7dba3..4719ea2a6 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 { actionType } from '@/common/coerce'; +import { coerce } from '@/common/coerce'; const SchemaData = z.object({ - group_id: actionType.string(), + group_id: coerce.string(), }); type Payload = z.infer; diff --git a/src/onebot/action/group/GetGroupInfo.ts b/src/onebot/action/group/GetGroupInfo.ts index f427c2244..7325c35ff 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 { actionType } from '@/common/coerce'; +import { coerce } from '@/common/coerce'; const SchemaData = z.object({ - group_id: actionType.string(), + group_id: coerce.string(), }); type Payload = z.infer; diff --git a/src/onebot/action/group/GetGroupList.ts b/src/onebot/action/group/GetGroupList.ts index 648d6cdcf..4710f6d26 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 { actionType } from '@/common/coerce'; +import { coerce } from '@/common/coerce'; const SchemaData = z.object({ - no_cache: actionType.boolean().default(false), + no_cache: coerce.boolean().default(false), }); type Payload = z.infer; diff --git a/src/onebot/action/group/GetGroupMemberInfo.ts b/src/onebot/action/group/GetGroupMemberInfo.ts index b1925fd6a..dc8cc5c1b 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 { actionType } from '@/common/coerce'; +import { coerce } from '@/common/coerce'; const SchemaData = z.object({ - group_id: actionType.string(), - user_id: actionType.string(), - no_cache: actionType.boolean().default(false), + group_id: coerce.string(), + user_id: coerce.string(), + no_cache: coerce.boolean().default(false), }); type Payload = z.infer; diff --git a/src/onebot/action/group/GetGroupMemberList.ts b/src/onebot/action/group/GetGroupMemberList.ts index 909392bad..54fd3fbb5 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 { actionType } from '@/common/coerce'; +import { coerce } from '@/common/coerce'; const SchemaData = z.object({ - group_id: actionType.string(), - no_cache: actionType.boolean().default(false) + group_id: coerce.string(), + no_cache: coerce.boolean().default(false) }); type Payload = z.infer; diff --git a/src/onebot/action/group/GetGroupNotice.ts b/src/onebot/action/group/GetGroupNotice.ts index 86ef5b0c0..d290e65d3 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 { actionType } from '@/common/coerce'; +import { coerce } from '@/common/coerce'; interface GroupNotice { sender_id: number; publish_time: number; @@ -18,7 +18,7 @@ interface GroupNotice { } const SchemaData = z.object({ - group_id: actionType.string(), + group_id: coerce.string(), }); type Payload = z.infer; diff --git a/src/onebot/action/group/GetGroupShutList.ts b/src/onebot/action/group/GetGroupShutList.ts index b65bacad2..de927f934 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 { actionType } from '@/common/coerce'; +import { coerce } from '@/common/coerce'; const SchemaData = z.object({ - group_id: actionType.string(), + group_id: coerce.string(), }); type Payload = z.infer; diff --git a/src/onebot/action/group/GroupPoke.ts b/src/onebot/action/group/GroupPoke.ts index 00c6fff8a..8a7ad66f7 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 { actionType } from '@/common/coerce'; +import { coerce } from '@/common/coerce'; const SchemaData = z.object({ - group_id: actionType.string(), - user_id: actionType.string(), + group_id: coerce.string(), + user_id: coerce.string(), }); type Payload = z.infer; diff --git a/src/onebot/action/group/SendGroupAiRecord.ts b/src/onebot/action/group/SendGroupAiRecord.ts index 454f77bef..c0355a035 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 { actionType } from '@/common/coerce'; +import { coerce } from '@/common/coerce'; const SchemaData = z.object({ - character: actionType.string(), - group_id: actionType.string(), - text: actionType.string(), + character: coerce.string(), + group_id: coerce.string(), + text: coerce.string(), }); type Payload = z.infer; diff --git a/src/onebot/action/group/SetEssenceMsg.ts b/src/onebot/action/group/SetEssenceMsg.ts index 04026cd05..6200a5519 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 { actionType } from '@/common/coerce'; +import { coerce } from '@/common/coerce'; const SchemaData = z.object({ - message_id: actionType.string(), + message_id: coerce.string(), }); type Payload = z.infer; diff --git a/src/onebot/action/group/SetGroupAddRequest.ts b/src/onebot/action/group/SetGroupAddRequest.ts index cabe123e0..747ed0a93 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 { actionType } from '@/common/coerce'; +import { coerce } from '@/common/coerce'; const SchemaData = z.object({ - flag: actionType.string(), - approve: actionType.boolean().default(true), - reason: actionType.string().nullable().default(' '), + flag: coerce.string(), + approve: coerce.boolean().default(true), + reason: coerce.string().nullable().default(' '), }); type Payload = z.infer; diff --git a/src/onebot/action/group/SetGroupAdmin.ts b/src/onebot/action/group/SetGroupAdmin.ts index f690ba9fd..dbc7e1cc3 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 { actionType } from '@/common/coerce'; +import { coerce } from '@/common/coerce'; const SchemaData = z.object({ - group_id: actionType.string(), - user_id: actionType.string(), - enable: actionType.boolean().default(false), + group_id: coerce.string(), + user_id: coerce.string(), + enable: coerce.boolean().default(false), }); type Payload = z.infer; diff --git a/src/onebot/action/group/SetGroupBan.ts b/src/onebot/action/group/SetGroupBan.ts index c65d461cb..0ac711424 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 { actionType } from '@/common/coerce'; +import { coerce } from '@/common/coerce'; const SchemaData = z.object({ - group_id: actionType.string(), - user_id: actionType.string(), - duration: actionType.number().default(0), + group_id: coerce.string(), + user_id: coerce.string(), + duration: coerce.number().default(0), }); type Payload = z.infer; diff --git a/src/onebot/action/group/SetGroupCard.ts b/src/onebot/action/group/SetGroupCard.ts index f0e0b53b9..467e27766 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 { actionType } from '@/common/coerce'; +import { coerce } from '@/common/coerce'; const SchemaData = z.object({ - group_id: actionType.string(), - user_id: actionType.string(), - card: actionType.string().optional(), + group_id: coerce.string(), + user_id: coerce.string(), + card: coerce.string().optional(), }); type Payload = z.infer; diff --git a/src/onebot/action/group/SetGroupKick.ts b/src/onebot/action/group/SetGroupKick.ts index 08f6ec50a..66b9cf33e 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 { actionType } from '@/common/coerce'; +import { coerce } from '@/common/coerce'; const SchemaData = z.object({ - group_id: actionType.string(), - user_id: actionType.string(), - reject_add_request: actionType.boolean().optional(), + group_id: coerce.string(), + user_id: coerce.string(), + reject_add_request: coerce.boolean().optional(), }); type Payload = z.infer; diff --git a/src/onebot/action/group/SetGroupLeave.ts b/src/onebot/action/group/SetGroupLeave.ts index 4823c6bb8..1f6ce77d2 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 { actionType } from '@/common/coerce'; +import { coerce } from '@/common/coerce'; const SchemaData = z.object({ - group_id: actionType.string(), - is_dismiss: actionType.boolean().optional(), + group_id: coerce.string(), + is_dismiss: coerce.boolean().optional(), }); type Payload = z.infer; diff --git a/src/onebot/action/group/SetGroupName.ts b/src/onebot/action/group/SetGroupName.ts index bd6440493..54f620f75 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 { actionType } from '@/common/coerce'; +import { coerce } from '@/common/coerce'; const SchemaData = z.object({ - group_id: actionType.string(), - group_name: actionType.string(), + group_id: coerce.string(), + group_name: coerce.string(), }); type Payload = z.infer; diff --git a/src/onebot/action/group/SetGroupWholeBan.ts b/src/onebot/action/group/SetGroupWholeBan.ts index 0e6c120ce..1d3f5d72d 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 { actionType } from '@/common/coerce'; +import { coerce } from '@/common/coerce'; const SchemaData = z.object({ - group_id: actionType.string(), - enable: actionType.boolean().optional(), + group_id: coerce.string(), + enable: coerce.boolean().optional(), }); type Payload = z.infer; diff --git a/src/onebot/action/msg/DeleteMsg.ts b/src/onebot/action/msg/DeleteMsg.ts index b1305dcca..92456e9e8 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 { actionType } from '@/common/coerce'; +import { coerce } from '@/common/coerce'; const SchemaData = z.object({ - message_id: actionType.string(), + message_id: coerce.string(), }); type Payload = z.infer; diff --git a/src/onebot/action/msg/ForwardSingleMsg.ts b/src/onebot/action/msg/ForwardSingleMsg.ts index c7e2c2455..4c4a0ae9c 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 { actionType } from '@/common/coerce'; +import { coerce } from '@/common/coerce'; const SchemaData = z.object({ - message_id: actionType.string(), - group_id: actionType.string().optional(), - user_id: actionType.string().optional(), + message_id: coerce.string(), + group_id: coerce.string().optional(), + user_id: coerce.string().optional(), }); type Payload = z.infer; diff --git a/src/onebot/action/msg/GetMsg.ts b/src/onebot/action/msg/GetMsg.ts index ce287a5e5..ece7efe85 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 { actionType } from '@/common/coerce'; +import { coerce } from '@/common/coerce'; export type ReturnDataType = OB11Message const SchemaData = z.object({ - message_id: actionType.string(), + message_id: coerce.string(), }); type Payload = z.infer; diff --git a/src/onebot/action/msg/MarkMsgAsRead.ts b/src/onebot/action/msg/MarkMsgAsRead.ts index 52ee09e10..cde1d2fe1 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 { actionType } from '@/common/coerce'; +import { coerce } from '@/common/coerce'; const SchemaData = z.object({ - user_id: actionType.string().optional(), - group_id: actionType.string().optional(), - message_id: actionType.string().optional(), + user_id: coerce.string().optional(), + group_id: coerce.string().optional(), + message_id: coerce.string().optional(), }); type PlayloadType = z.infer; diff --git a/src/onebot/action/msg/SetMsgEmojiLike.ts b/src/onebot/action/msg/SetMsgEmojiLike.ts index 1eb9eed82..42016090c 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 { actionType } from '@/common/coerce'; +import { coerce } from '@/common/coerce'; const SchemaData = z.object({ - message_id: actionType.string(), - emoji_id: actionType.string(), - set: actionType.boolean().optional(), + message_id: coerce.string(), + emoji_id: coerce.string(), + set: coerce.boolean().optional(), }); type Payload = z.infer; diff --git a/src/onebot/action/packet/SendPoke.ts b/src/onebot/action/packet/SendPoke.ts index 438f802f0..598654c05 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 { actionType } from '@/common/coerce'; +import { coerce } from '@/common/coerce'; const SchemaData = z.object({ - group_id: actionType.string().optional(), - user_id: actionType.string(), + group_id: coerce.string().optional(), + user_id: coerce.string(), }); type Payload = z.infer; diff --git a/src/onebot/action/system/GetCredentials.ts b/src/onebot/action/system/GetCredentials.ts index cb49f0ccf..c27a7b4c9 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 { actionType } from '@/common/coerce'; +import { coerce } from '@/common/coerce'; interface Response { cookies: string, @@ -9,7 +9,7 @@ interface Response { } const SchemaData = z.object({ - domain: actionType.string() + domain: coerce.string() }); type Payload = z.infer; diff --git a/src/onebot/action/user/FriendPoke.ts b/src/onebot/action/user/FriendPoke.ts index 5b8ba4254..78a1b7963 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 { actionType } from '@/common/coerce'; +import { coerce } from '@/common/coerce'; const SchemaData = z.object({ - user_id: actionType.string() + user_id: coerce.string() }); type Payload = z.infer; diff --git a/src/onebot/action/user/GetCookies.ts b/src/onebot/action/user/GetCookies.ts index da021c339..9ff0e3bc4 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 { actionType } from '@/common/coerce'; +import { coerce } from '@/common/coerce'; interface Response { cookies: string, bkn: string } const SchemaData = z.object({ - domain: actionType.string() + domain: coerce.string() }); type Payload = z.infer; diff --git a/src/onebot/action/user/GetFriendList.ts b/src/onebot/action/user/GetFriendList.ts index ef85df428..16cf57b05 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 { actionType } from '@/common/coerce'; +import { coerce } from '@/common/coerce'; const SchemaData = z.object({ - no_cache: actionType.boolean().optional(), + no_cache: coerce.boolean().optional(), }); type Payload = z.infer; diff --git a/src/onebot/action/user/GetRecentContact.ts b/src/onebot/action/user/GetRecentContact.ts index 4c817eb3d..8ec364e7f 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 { actionType } from '@/common/coerce'; +import { coerce } from '@/common/coerce'; const SchemaData = z.object({ - count: actionType.number().default(10), + count: coerce.number().default(10), }); type Payload = z.infer; diff --git a/src/onebot/action/user/SendLike.ts b/src/onebot/action/user/SendLike.ts index 7630161ac..66912a9c8 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 { actionType } from '@/common/coerce'; +import { coerce } from '@/common/coerce'; const SchemaData = z.object({ - times: actionType.number().default(1), - user_id: actionType.string() + times: coerce.number().default(1), + user_id: coerce.string() }); type Payload = z.infer; diff --git a/src/onebot/action/user/SetFriendAddRequest.ts b/src/onebot/action/user/SetFriendAddRequest.ts index f35318d46..3a44ae8e5 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 { actionType } from '@/common/coerce'; +import { coerce } from '@/common/coerce'; const SchemaData = z.object({ - flag: actionType.string(), - approve: actionType.boolean().default(true), - remark: actionType.string().nullable().optional() + flag: coerce.string(), + approve: coerce.boolean().default(true), + remark: coerce.string().nullable().optional() }); type Payload = z.infer; diff --git a/src/onebot/config/config.ts b/src/onebot/config/config.ts index 266106b62..489ce61c5 100644 --- a/src/onebot/config/config.ts +++ b/src/onebot/config/config.ts @@ -1,72 +1,72 @@ import { z } from 'zod'; -import { actionType } from '../../common/coerce'; +import { coerce } from '../../common/coerce'; const HttpServerConfigSchema = z.object({ - 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) + 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) }); const HttpSseServerConfigSchema = z.object({ - 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) + 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) }); const HttpClientConfigSchema = z.object({ - 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) + 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) }); const WebsocketServerConfigSchema = z.object({ - 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) + 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) }); const WebsocketClientConfigSchema = z.object({ - 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) + 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) }); const PluginConfigSchema = z.object({ - 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), + 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), }); const NetworkConfigSchema = z.object({ @@ -80,9 +80,9 @@ const NetworkConfigSchema = z.object({ export const OneBotConfigSchema = z.object({ network: NetworkConfigSchema, - musicSignUrl: actionType.string().default(''), - enableLocalFile2Url: actionType.boolean().default(false), - parseMultMsg: actionType.boolean().default(false) + musicSignUrl: coerce.string().default(''), + enableLocalFile2Url: coerce.boolean().default(false), + parseMultMsg: coerce.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 af8e9c5c6..dbbdf13af 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 { actionType } from '@/common/coerce'; +import { coerce } from '@/common/coerce'; // 定义配置的类型 const WebUiConfigSchema = z.object({ - 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(''), + 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(''), theme: themeType, }); diff --git a/src/webui/src/types/theme.ts b/src/webui/src/types/theme.ts index 02be0c38d..5f32c1073 100644 --- a/src/webui/src/types/theme.ts +++ b/src/webui/src/types/theme.ts @@ -1,10 +1,10 @@ -import { actionType } from '@/common/coerce'; +import { coerce } from '@/common/coerce'; import { z } from 'zod'; export const themeType = z.object( { - dark: z.record(actionType.string(), actionType.string()), - light: z.record(actionType.string(), actionType.string()), + dark: z.record(coerce.string(), coerce.string()), + light: z.record(coerce.string(), coerce.string()), } ).default({ dark: { From bd3e06520f4ad340de85e65690d4e9bd3de5b72c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=89=8B=E7=93=9C=E4=B8=80=E5=8D=81=E9=9B=AA?= Date: Thu, 17 Apr 2025 09:56:12 +0800 Subject: [PATCH 5/5] fix --- src/common/coerce.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/common/coerce.ts b/src/common/coerce.ts index 6aabd5382..e9c6cd35f 100644 --- a/src/common/coerce.ts +++ b/src/common/coerce.ts @@ -1,4 +1,4 @@ -import { z } from "zod"; +import { z } from 'zod'; const boolean = () => z.preprocess( val => typeof val === 'string' && (val.toLowerCase() === 'false' || val === '0') ? false : Boolean(val), z.boolean()