refactor(db,persistence): unify EventStore and WorkflowAlertStore onto core/db SQLite

This commit is contained in:
gitea committed 2026-09-30 00:26:49 +08:00
1 parent 5a0c277993
commit 3864f0ffd0
7 files changed
+228 -34

No files matched your search

+3 -2
View File
@@ -25,10 +25,11 @@ export async function handleServiceCommand(
const corpId = corp.corpId || corp.id;
const client = await createSessionClient(corp);
const limit = numberOption(parsed.options, ["limit", "count", "n"], 50) || 50;
const store = new EventStore(join(SERVICE_STATE_DIR, `events-${corpId}.json`));
const stateFile = stringOption(parsed.options, ["state-file", "stateFile"]);
const store = new EventStore(stateFile || `corp:${corpId}`);
const result = await pollEvents(client, corpId, store, limit);
if (runtime.jsonMode) return { stdout: printJson(result, runtime.outputOptions), stderr: "", exitCode: 0 };
return { stdout: `====== 事件轮询 (企业: ${corp.name}) ======\n${printKeyValue({ "待办扫描": result.scanned.todo, "未读消息扫描": result.scanned.messages, "新增事件": result.newEvents.length, "重复事件": result.duplicateCount, "事件状态文件": join(SERVICE_STATE_DIR, `events-${corpId}.json`) })}\n`, stderr: "", exitCode: 0 };
return { stdout: `====== 事件轮询 (企业: ${corp.name}) ======\n${printKeyValue({ "待办扫描": result.scanned.todo, "未读消息扫描": result.scanned.messages, "新增事件": result.newEvents.length, "重复事件": result.duplicateCount, "存储后端": stateFile || "SQLite (observed_events)" })}\n`, stderr: "", exitCode: 0 };
}
const config: ServiceConfig = {