Remove napcat-onebot test_schema.ts

Delete packages/napcat-onebot/test_schema.ts — a standalone script that compiled and validated OB11 TypeBox schemas and performed a sample validation. This file appeared to be a local test/diagnostic harness and was removed as part of cleanup to avoid keeping ad-hoc test scripts in the package source.
This commit is contained in:
手瓜一十雪 committed 2026-03-06 10:32:48 +08:00
1 parent 3ba1bd9565
commit 8b0d186625
1 file changed
-61
-61
View File
@@ -1,61 +0,0 @@
import { TypeCompiler } from '@sinclair/typebox/compiler';
import { Value } from '@sinclair/typebox/value';
import { OB11MessageDataSchema, OB11MessageSchema, OB11PostSendMsgSchema } from './types/message';
import { OB11MessageSchema as OB11ActionMessageSchema } from './action/schemas';
try {
TypeCompiler.Compile(OB11MessageDataSchema);
console.log("Compile OB11MessageDataSchema OK");
} catch (e: any) {
console.error("Error in OB11MessageDataSchema:", e.message);
}
try {
TypeCompiler.Compile(OB11MessageSchema);
console.log("Compile OB11MessageSchema OK");
} catch (e: any) {
console.error("Error in OB11MessageSchema:", e.message);
}
try {
TypeCompiler.Compile(OB11ActionMessageSchema);
console.log("Compile OB11ActionMessageSchema OK");
} catch (e: any) {
console.error("Error in OB11ActionMessageSchema:", e.message);
}
import { Type } from '@sinclair/typebox';
try {
const QA = Type.Object({ message: OB11PostSendMsgSchema, quick_action: OB11ActionMessageSchema });
TypeCompiler.Compile(QA);
console.log("Compile Quick Action OK");
} catch (e: any) {
console.error("Error in Quick Action:", e.message);
}
// Test validation
const testObj = {
message_type: 'private',
user_id: 12345,
message: [
{ type: 'text', data: { text: 'hello' } }
]
};
try {
let data = structuredClone(testObj);
data = Value.Default(OB11PostSendMsgSchema, data) as any;
data = Value.Convert(OB11PostSendMsgSchema, data) as any;
const compiler = TypeCompiler.Compile(OB11PostSendMsgSchema);
const isValid = compiler.Check(data);
console.log("Validation result:", isValid);
if (!isValid) {
const errors = [...compiler.Errors(data)];
errors.forEach(e => console.error(e.path, e.message));
} else {
console.log("Data after Convert and Check:", JSON.stringify(data, null, 2));
}
} catch (e: any) {
console.error("Test validation error:", e.message);
}