mirror of
https://github.com/NapNeko/NapCatQQ.git
synced 2026-02-05 15:11:15 +00:00
Introduced explicit payloadSchema and returnSchema definitions for all OneBotAction classes using @sinclair/typebox. This improves type safety, API documentation, and validation for action payloads and return values. Also refactored method signatures and types for consistency across the codebase.
26 lines
879 B
TypeScript
26 lines
879 B
TypeScript
import { OneBotAction } from '@/napcat-onebot/action/OneBotAction';
|
|
import { ActionName } from '@/napcat-onebot/action/router';
|
|
import { napCatVersion } from 'napcat-common/src/version';
|
|
import { Type, Static } from '@sinclair/typebox';
|
|
|
|
const ReturnSchema = Type.Object({
|
|
app_name: Type.String({ description: '应用名称' }),
|
|
protocol_version: Type.String({ description: '协议版本' }),
|
|
app_version: Type.String({ description: '应用版本' }),
|
|
}, { description: '版本信息' });
|
|
|
|
type ReturnType = Static<typeof ReturnSchema>;
|
|
|
|
export default class GetVersionInfo extends OneBotAction<void, ReturnType> {
|
|
override actionName = ActionName.GetVersionInfo;
|
|
override returnSchema = ReturnSchema;
|
|
|
|
async _handle (): Promise<ReturnType> {
|
|
return {
|
|
app_name: 'NapCat.Onebot',
|
|
protocol_version: 'v11',
|
|
app_version: napCatVersion,
|
|
};
|
|
}
|
|
}
|