fix:coerce

This commit is contained in:
手瓜一十雪
2025-04-15 12:25:37 +08:00
parent 9257a6cfde
commit dd895d7c17
88 changed files with 277 additions and 276 deletions

View File

@@ -3,8 +3,8 @@ import { ActionName } from '@/onebot/action/router';
import { z } from 'zod';
const SchemaData = z.object({
group_id: z.union([z.number(), z.string()]),
folder_name: z.string(),
group_id: z.union([z.coerce.number(), z.coerce.string()]),
folder_name: z.coerce.string(),
});
type Payload = z.infer<typeof SchemaData>;

View File

@@ -6,8 +6,8 @@ import { z } from 'zod';
import { NTQQGroupApi } from '@/core/apis';
const SchemaData = z.object({
group_id: z.union([z.number(), z.string()]),
file_id: z.string(),
group_id: z.union([z.coerce.number(), z.coerce.string()]),
file_id: z.coerce.string(),
});
type Payload = z.infer<typeof SchemaData>;

View File

@@ -4,9 +4,9 @@ import { z } from 'zod';
import { NTQQGroupApi } from '@/core/apis';
const SchemaData = z.object({
group_id: z.union([z.number(), z.string()]),
folder_id: z.string().optional(),
folder: z.string().optional(),
group_id: z.union([z.coerce.number(), z.coerce.string()]),
folder_id: z.coerce.string().optional(),
folder: z.coerce.string().optional(),
});
type Payload = z.infer<typeof SchemaData>;

View File

@@ -11,10 +11,10 @@ interface FileResponse {
}
const SchemaData = z.object({
url: z.string().optional(),
base64: z.string().optional(),
name: z.string().optional(),
headers: z.union([z.string(), z.array(z.string())]).optional(),
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(),
});
type Payload = z.infer<typeof SchemaData>;

View File

@@ -7,8 +7,8 @@ import { z } from 'zod';
import { isNumeric } from '@/common/helper';
const SchemaData = z.object({
message_id: z.string().optional(),
id: z.string().optional(),
message_id: z.coerce.string().optional(),
id: z.coerce.string().optional(),
});
type Payload = z.infer<typeof SchemaData>;

View File

@@ -10,10 +10,10 @@ interface Response {
messages: OB11Message[];
}
const SchemaData = z.object({
user_id: z.union([z.number(), z.string()]),
message_seq: z.union([z.number(), z.string()]).optional(),
count: z.union([z.number(), z.string()]).default(20),
reverseOrder: z.boolean().default(false)
user_id: z.union([z.coerce.number(), z.coerce.string()]),
message_seq: z.union([z.coerce.number(), z.coerce.string()]).optional(),
count: z.union([z.coerce.number(), z.coerce.string()]).default(20),
reverseOrder: z.coerce.boolean().default(false)
});

View File

@@ -3,7 +3,7 @@ import { ActionName } from '@/onebot/action/router';
import { z } from 'zod';
const SchemaData = z.object({
group_id: z.union([z.number(), z.string()])
group_id: z.union([z.coerce.number(), z.coerce.string()])
});
type Payload = z.infer<typeof SchemaData>;

View File

@@ -3,7 +3,7 @@ import { ActionName } from '@/onebot/action/router';
import { z } from 'zod';
const SchemaData = z.object({
group_id: z.union([z.number(), z.string()])
group_id: z.union([z.coerce.number(), z.coerce.string()])
});
type Payload = z.infer<typeof SchemaData>;

View File

@@ -5,10 +5,10 @@ import { OB11Construct } from '@/onebot/helper/data';
import { z } from 'zod';
const SchemaData = z.object({
group_id: z.union([z.number(), z.string()]),
folder_id: z.string().optional(),
folder: z.string().optional(),
file_count: z.union([z.number(), z.string()]).default(50),
group_id: z.union([z.coerce.number(), z.coerce.string()]),
folder_id: z.coerce.string().optional(),
folder: z.coerce.string().optional(),
file_count: z.union([z.coerce.number(), z.coerce.string()]).default(50),
});
type Payload = z.infer<typeof SchemaData>;

View File

@@ -4,7 +4,7 @@ import { ActionName } from '@/onebot/action/router';
import { z } from 'zod';
const SchemaData = z.object({
group_id: z.union([z.number(), z.string()]),
group_id: z.union([z.coerce.number(), z.coerce.string()]),
type: z.nativeEnum(WebHonorType).optional()
});

View File

@@ -11,10 +11,10 @@ interface Response {
}
const SchemaData = z.object({
group_id: z.union([z.number(), z.string()]),
message_seq: z.union([z.number(), z.string()]).optional(),
count: z.union([z.number(), z.string()]).default(20),
reverseOrder: z.boolean().default(false)
group_id: z.union([z.coerce.number(), z.coerce.string()]),
message_seq: z.union([z.coerce.number(), z.coerce.string()]).optional(),
count: z.union([z.coerce.number(), z.coerce.string()]).default(20),
reverseOrder: z.coerce.boolean().default(false)
});

View File

@@ -6,8 +6,8 @@ import { OB11Construct } from '@/onebot/helper/data';
import { z } from 'zod';
const SchemaData = z.object({
group_id: z.union([z.number(), z.string()]),
file_count: z.union([z.number(), z.string()]).default(50),
group_id: z.union([z.coerce.number(), z.coerce.string()]),
file_count: z.union([z.coerce.number(), z.coerce.string()]).default(50),
});
type Payload = z.infer<typeof SchemaData>;

View File

@@ -6,8 +6,8 @@ import { calcQQLevel } from '@/common/helper';
import { z } from 'zod';
const SchemaData = z.object({
user_id: z.union([z.number(), z.string()]),
no_cache: z.boolean().default(false),
user_id: z.union([z.coerce.number(), z.coerce.string()]),
no_cache: z.coerce.boolean().default(false),
});
type Payload = z.infer<typeof SchemaData>;

View File

@@ -3,7 +3,7 @@ import { ActionName } from '@/onebot/action/router';
import { z } from 'zod';
const SchemaData = z.object({
url: z.string(),
url: z.coerce.string(),
});
type Payload = z.infer<typeof SchemaData>;

View File

@@ -3,10 +3,10 @@ import { ActionName } from '@/onebot/action/router';
import { z } from 'zod';
const SchemaData = z.object({
friend_id: z.union([z.string(), z.number()]).optional(),
user_id: z.union([z.string(), z.number()]).optional(),
temp_block: z.boolean().optional(),
temp_both_del: z.boolean().optional(),
friend_id: z.union([z.coerce.string(), z.coerce.number()]).optional(),
user_id: z.union([z.coerce.string(), z.coerce.number()]).optional(),
temp_block: z.coerce.boolean().optional(),
temp_both_del: z.coerce.boolean().optional(),
});
type Payload = z.infer<typeof SchemaData>;

View File

@@ -3,7 +3,7 @@ import { ActionName } from '@/onebot/action/router';
import { z } from 'zod';
const SchemaData = z.object({
model: z.string(),
model: z.coerce.string(),
});
type Payload = z.infer<typeof SchemaData>;

View File

@@ -5,14 +5,14 @@ import { unlink } from 'node:fs/promises';
import { z } from 'zod';
const SchemaData = z.object({
group_id: z.union([z.number(), z.string()]),
content: z.string(),
image: z.string().optional(),
pinned: z.union([z.number(), z.string()]).default(0),
type: z.union([z.number(), z.string()]).default(1),
confirm_required: z.union([z.number(), z.string()]).default(1),
is_show_edit_card: z.union([z.number(), z.string()]).default(0),
tip_window_type: z.union([z.number(), z.string()]).default(0),
group_id: z.union([z.coerce.number(), z.coerce.string()]),
content: z.coerce.string(),
image: z.coerce.string().optional(),
pinned: z.union([z.coerce.number(), z.coerce.string()]).default(0),
type: z.union([z.coerce.number(), z.coerce.string()]).default(1),
confirm_required: z.union([z.coerce.number(), z.coerce.string()]).default(1),
is_show_edit_card: z.union([z.coerce.number(), z.coerce.string()]).default(0),
tip_window_type: z.union([z.coerce.number(), z.coerce.string()]).default(0),
});
type Payload = z.infer<typeof SchemaData>;

View File

@@ -5,8 +5,8 @@ import { z } from 'zod';
import fs from 'node:fs/promises';
import { GeneralCallResult } from '@/core';
const SchemaData = z.object({
file: z.string(),
group_id: z.union([z.number(), z.string()])
file: z.coerce.string(),
group_id: z.union([z.coerce.number(), z.coerce.string()])
});
type Payload = z.infer<typeof SchemaData>;

View File

@@ -4,9 +4,9 @@ import { ActionName } from '@/onebot/action/router';
import { z } from 'zod';
const SchemaData = z.object({
nickname: z.string(),
personal_note: z.string().optional(),
sex: z.union([z.number(), z.string()]).optional(), // 传Sex值建议传0
nickname: z.coerce.string(),
personal_note: z.coerce.string().optional(),
sex: z.union([z.coerce.number(), z.coerce.string()]).optional(), // 传Sex值建议传0
});
type Payload = z.infer<typeof SchemaData>;

View File

@@ -7,11 +7,11 @@ import { SendMessageContext } from '@/onebot/api';
import { z } from 'zod';
const SchemaData = z.object({
group_id: z.union([z.number(), z.string()]),
file: z.string(),
name: z.string(),
folder: z.string().optional(),
folder_id: z.string().optional(),//临时扩展
group_id: z.union([z.coerce.number(), z.coerce.string()]),
file: z.coerce.string(),
name: z.coerce.string(),
folder: z.coerce.string().optional(),
folder_id: z.coerce.string().optional(),//临时扩展
});
type Payload = z.infer<typeof SchemaData>;

View File

@@ -8,9 +8,9 @@ import { ContextMode, createContext } from '@/onebot/action/msg/SendMsg';
import { z } from 'zod';
const SchemaData = z.object({
user_id: z.union([z.number(), z.string()]),
file: z.string(),
name: z.string(),
user_id: z.union([z.coerce.number(), z.coerce.string()]),
file: z.coerce.string(),
name: z.coerce.string(),
});
type Payload = z.infer<typeof SchemaData>;