Build your personal knowledge base with Trilium Notes
TypeScript electronelectron-appknowledge-baseknowledge-graphknowledge-managementknowledge-management-graphlocal-firstnote-managmentnote-takernote-takingnotebooknotesnotes-apppersonal-knowledge-basepersonal-wikiscriptableself-hostedself-hostingwiki
chore(core): port relation map route
Elian Doran7d30771f0528
diff --git a/apps/server/src/routes/routes.ts b/apps/server/src/routes/routes.tsindex 69a3edc123..ed180fdc23 100644--- a/apps/server/src/routes/routes.ts+++ b/apps/server/src/routes/routes.ts@@ -40,7 +40,6 @@ import otherRoute from "./api/other.js";import passwordApiRoute from "./api/password.js";import recentChangesApiRoute from "./api/recent_changes.js";import recoveryCodes from './api/recovery_codes.js';-import relationMapApiRoute from "./api/relation-map.js";import scriptRoute from "./api/script.js";import searchRoute from "./api/search.js";import senderRoute from "./api/sender.js";@@ -257,7 +256,6 @@ function register(app: express.Application) {asyncRoute(PST, "/api/sender/image", [auth.checkEtapiToken, uploadMiddlewareWithErrorHandling], senderRoute.uploadImage, apiResultHandler);asyncRoute(PST, "/api/sender/note", [auth.checkEtapiToken], senderRoute.saveNote, apiResultHandler);- apiRoute(PST, "/api/relation-map", relationMapApiRoute.getRelationMap);asyncApiRoute(GET, "/api/similar-notes/:noteId", similarNotesRoute.getSimilarNotes);asyncApiRoute(GET, "/api/backend-log", backendLogRoute.getBackendLog);route(GET, "/api/fonts", [auth.checkApiAuthOrElectron], fontsRoute.getFontCss);diff --git a/apps/server/src/routes/api/relation-map.ts b/packages/trilium-core/src/routes/api/relation-map.tssimilarity index 92%rename from apps/server/src/routes/api/relation-map.tsrename to packages/trilium-core/src/routes/api/relation-map.tsindex bc1c877aa6..b57750ab27 100644--- a/apps/server/src/routes/api/relation-map.ts+++ b/packages/trilium-core/src/routes/api/relation-map.ts@@ -1,7 +1,7 @@import type { Request } from "express";import becca from "../../becca/becca.js";-import sql from "../../services/sql.js";import { RelationMapPostResponse } from "@triliumnext/commons";+import { getSql } from "../../services/sql/index.js";function getRelationMap(req: Request) {const { relationMapNoteId, noteIds } = req.body;@@ -30,7 +30,7 @@ function getRelationMap(req: Request) {const hideRelationsVal = relationMapNote.getLabelValue("hideRelations");const hideRelations = !hideRelationsVal ? [] : hideRelationsVal.split(",").map((token) => token.trim());- const foundNoteIds = sql.getColumn<string>(/*sql*/`SELECT noteId FROM notes WHERE isDeleted = 0 AND noteId IN (${questionMarks})`, noteIds);+ const foundNoteIds = getSql().getColumn<string>(/*sql*/`SELECT noteId FROM notes WHERE isDeleted = 0 AND noteId IN (${questionMarks})`, noteIds);const notes = becca.getNotes(foundNoteIds);for (const note of notes) {diff --git a/packages/trilium-core/src/routes/index.ts b/packages/trilium-core/src/routes/index.tsindex 5233437861..9be361452a 100644--- a/packages/trilium-core/src/routes/index.ts+++ b/packages/trilium-core/src/routes/index.ts@@ -14,6 +14,7 @@ import cloningApiRoute from "./api/cloning";import sqlRoute from "./api/sql";import attributesRoute from "./api/attributes";import revisionsApiRoute from "./api/revisions";+import relationMapApiRoute from "./api/relation-map";// TODO: Deduplicate with routes.tsconst GET = "get",@@ -109,6 +110,7 @@ export function buildSharedApiRoutes(apiRoute: any) {apiRoute(GET, "/api/app-info", appInfoRoute.getAppInfo);apiRoute(GET, "/api/other/icon-usage", otherRoute.getIconUsage);+ apiRoute(PST, "/api/relation-map", relationMapApiRoute.getRelationMap);}/** Handling common patterns. If entity is not caught, serialization to JSON will fail */