refactor(onebot): collapse action registration into a single barrel
加一个 action 文件原本要同步改三处手写清单:ApiHandler 的 12 个 register import + 12 行构造调用、各文件的 register footer、action-docs 的 13 import + GROUPS。现收敛 成一个 actions/index.ts barrel 作为「文件→动作 + 分类」的单一真相。 - action-kit:抽 RegisteredActionSpec(describe+register),ActionSpec/ StreamActionSpec extends 它,registerActions 参数放宽到 RegisteredActionSpec[] (它只调 .register),于是 stream 动作也能并入统一注册。 - 新增 actions/index.ts:ACTION_GROUPS(11 组含分类,stream 合并)+ ALL_ACTIONS。 - api-handler:12 import+12 调用 → registerActions(this, context, ALL_ACTIONS); .handle_quick_operation(唯一非 ActionSpec 的裸 handler,需要 h 本身)从 extended 搬进构造器一处显式注册。 - action-docs:改用 barrel 的 ACTION_GROUPS,删本地 GROUPS + 13 import。 - 删 12 个 register footer + 清理因此变 unused 的 ApiHandler/ApiActionContext import。 行为严格不变:注册的动作集合、.handle_quick_operation、文档分类/计数均一致。 onebot 516 全绿、全仓 12 包 typecheck Done;对抗性 Agent 逐条对比 HEAD 确认等价。
This commit is contained in:
16 files changed
+98
-139
No files matched your search
@@ -23,7 +23,7 @@ import fs from 'fs';
|
||||
import { createHash } from 'crypto';
|
||||
import { createLogger } from '@snowluma/common/logger';
|
||||
import { defineAction, defineStreamAction, f } from '../action-kit';
|
||||
import type { ApiActionContext, ApiHandler } from '../api-handler';
|
||||
import type { ApiActionContext } from '../api-handler';
|
||||
import { okResponse, type ApiResponse } from '../types';
|
||||
import { StreamStatus } from '../streaming';
|
||||
|
||||
@@ -361,9 +361,5 @@ const cleanStreamTempFile = defineAction({
|
||||
|
||||
export const actions = [uploadFileStream, cleanStreamTempFile];
|
||||
|
||||
export function register(h: ApiHandler, ctx: ApiActionContext): void {
|
||||
for (const a of actions) a.register(h, ctx);
|
||||
}
|
||||
|
||||
// Exposed for tests.
|
||||
export const __test = { uploads, handleUpload, cleanDir, validateStreamId, STREAM_UPLOAD_DIR, MAX_CONCURRENT_STREAMS, MAX_CHUNKS };
|
||||
Reference in new issue
Block a user