迁移类型校验到zod

This commit is contained in:
手瓜一十雪
2025-04-13 20:05:11 +08:00
parent d4ab191f34
commit 2147c4ffee
101 changed files with 951 additions and 945 deletions

View File

@@ -8,7 +8,7 @@ export class GetRkeyEx extends GetPacketStatusDepends<void, unknown> {
let rkeys = await this.core.apis.PacketApi.pkt.operation.FetchRkey();
return rkeys.map(rkey => {
return {
type: rkey.type === 10 ? "private" : "group",
type: rkey.type === 10 ? 'private' : 'group',
rkey: rkey.rkey,
created_at: rkey.time,
ttl: rkey.ttl,

View File

@@ -30,7 +30,7 @@ export class GetRkeyServer extends GetPacketStatusDepends<void, { private_rkey?:
private_rkey: privateRkeyItem ? privateRkeyItem.rkey : undefined,
group_rkey: groupRkeyItem ? groupRkeyItem.rkey : undefined,
expired_time: this.expiryTime,
name: "NapCat 4"
name: 'NapCat 4'
};
return this.rkeyCache;

View File

@@ -1,13 +1,13 @@
import { ActionName } from '@/onebot/action/router';
import { GetPacketStatusDepends } from '@/onebot/action/packet/GetPacketStatus';
import { Static, Type } from '@sinclair/typebox';
import { z } from 'zod';
const SchemaData = Type.Object({
group_id: Type.Optional(Type.Union([Type.Number(), Type.String()])),
user_id: Type.Union([Type.Number(), Type.String()]),
const SchemaData = z.object({
group_id: z.union([z.number(), z.string()]).optional(),
user_id: z.union([z.number(), z.string()]),
});
type Payload = Static<typeof SchemaData>;
type Payload = z.infer<typeof SchemaData>;
export class SendPoke extends GetPacketStatusDepends<Payload, void> {
override actionName = ActionName.SendPoke;