From 2be1bd16129cf6bbc5ea858690e7585f3019adc3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=9B=B7=E7=94=B5=E8=8A=BD=E8=A1=A3?= Date: Thu, 16 Apr 2026 22:32:25 -0400 Subject: [PATCH] refactor(api-server): move misc SQL into db.knowledge domain method Replace the inline knowledge_base queryAll in routes-misc.ts with db.listKnowledgeEntries (added in the previous commit). Routes-misc now holds no raw SQL. --- src/main/api-server/routes-misc.ts | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) diff --git a/src/main/api-server/routes-misc.ts b/src/main/api-server/routes-misc.ts index 9368b0d5..5955f29c 100644 --- a/src/main/api-server/routes-misc.ts +++ b/src/main/api-server/routes-misc.ts @@ -1,13 +1,6 @@ import { z } from "zod"; import { requireParam, type AgentApiServer } from "./server-core"; -type KnowledgeRow = { - id: string; companyId: string; category: string; topic: string; - content: string; authorAgentId: string; importance: string; - tagsJson: string; referencedEntityType: string | null; - referencedEntityId: string | null; createdAt: string; updatedAt: string; -}; - const socialDraftSchema = z.object({ socialAccountId: z.string().uuid(), platform: z.string(), @@ -226,10 +219,7 @@ export function registerMiscRoutes(server: AgentApiServer) { server.json(res, 403, { error: "Company mismatch" }); return; } - const entries = db.queryAll( - "select id, company_id as companyId, category, topic, content, author_agent_id as authorAgentId, importance, tags_json as tagsJson, referenced_entity_type as referencedEntityType, referenced_entity_id as referencedEntityId, created_at as createdAt, updated_at as updatedAt from knowledge_base where company_id = ? order by updated_at desc", - token.companyId, - ); + const entries = db.listKnowledgeEntries(token.companyId); server.json(res, 200, entries); });