From 8b0d1866252ff621a7cc922f742cfeec31c89fd6 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: Fri, 6 Mar 2026 10:32:48 +0800 Subject: [PATCH] Remove napcat-onebot test_schema.ts MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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. --- packages/napcat-onebot/test_schema.ts | 61 --------------------------- 1 file changed, 61 deletions(-) delete mode 100644 packages/napcat-onebot/test_schema.ts diff --git a/packages/napcat-onebot/test_schema.ts b/packages/napcat-onebot/test_schema.ts deleted file mode 100644 index b5994a9fd..000000000 --- a/packages/napcat-onebot/test_schema.ts +++ /dev/null @@ -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); -}