Skip to content

Build your personal knowledge base with Trilium Notes

refactor(server): remove bbranch wrapper

Elian Dorancc1a14285dfd
diff --git a/apps/script-deployer/package.json b/apps/script-deployer/package.json
index 049fb1bfea..e8ebafa94f 100644
--- a/apps/script-deployer/package.json
+++ b/apps/script-deployer/package.json
@@ -7,5 +7,8 @@
"dev": "tsx watch --clear-screen=false --ignore '../client/node_modules/.vite-temp' src/dev.ts",
"test": "vitest run",
"clean": "rm -rf data"
+ },
+ "devDependencies": {
+ "@triliumnext/core": "workspace:*"
}
}
diff --git a/apps/script-deployer/src/deploy.spec.ts b/apps/script-deployer/src/deploy.spec.ts
index 77403f124a..f12d1ad1c9 100644
--- a/apps/script-deployer/src/deploy.spec.ts
+++ b/apps/script-deployer/src/deploy.spec.ts
@@ -1,9 +1,9 @@
-import becca from "@triliumnext/server/src/becca/becca";
-import BBranch from "@triliumnext/server/src/becca/entities/bbranch";
+import { BBranch, becca, becca_easy_mocking } from "@triliumnext/core";
import cls from "@triliumnext/server/src/services/cls";
-import { buildNote } from "@triliumnext/server/src/test/becca_easy_mocking";
import { beforeEach, describe, expect, it, vi } from "vitest";
+const { buildNote } = becca_easy_mocking;
+
import {
codeNoteId,
deployScript,
diff --git a/apps/script-deployer/src/dev.ts b/apps/script-deployer/src/dev.ts
index 4816637b7c..17e6b86946 100644
--- a/apps/script-deployer/src/dev.ts
+++ b/apps/script-deployer/src/dev.ts
@@ -74,7 +74,7 @@ async function ensureScriptsFolder() {
if (becca.notes[SCRIPTS_NOTE_ID]) return;
const cls = (await import("@triliumnext/server/src/services/cls.js")).default;
- const notesService = (await import("@triliumnext/server/src/services/notes.js")).default;
+ const { note_service: notesService } = await import("@triliumnext/core");
cls.init(() => {
notesService.createNewNote({
@@ -98,7 +98,7 @@ async function deployScripts() {
const becca = (await import("@triliumnext/server/src/becca/becca.js")).default;
const cls = (await import("@triliumnext/server/src/services/cls.js")).default;
- const notesService = (await import("@triliumnext/server/src/services/notes.js")).default;
+ const { note_service: notesService } = await import("@triliumnext/core");
console.log(`Deploying ${files.length} script(s)…`);
@@ -160,7 +160,7 @@ function watchScripts() {
// For render scripts, trigger a refresh of all contexts viewing
// the render note by injecting a client-side script via websocket.
if (meta.type === "render") {
- const ws = (await import("@triliumnext/server/src/services/ws.js")).default;
+ const { ws } = await import("@triliumnext/core");
const renderId = renderNoteId(meta.id);
ws.sendMessageToAllClients({
type: "execute-script",
diff --git a/apps/server/src/becca/entities/bbranch.ts b/apps/server/src/becca/entities/bbranch.ts
deleted file mode 100644
index 0c687237b1..0000000000
--- a/apps/server/src/becca/entities/bbranch.ts
+++ /dev/null
@@ -1,2 +0,0 @@
-import { BBranch } from "@triliumnext/core";
-export default BBranch;
diff --git a/apps/server/src/etapi/branches.ts b/apps/server/src/etapi/branches.ts
index a97cb51ae0..554659d9c9 100644
--- a/apps/server/src/etapi/branches.ts
+++ b/apps/server/src/etapi/branches.ts
@@ -1,10 +1,9 @@
import type { BranchRow } from "@triliumnext/commons";
import type { Router } from "express";
-import { entity_changes as entityChangesService } from "@triliumnext/core";
+import { BBranch, entity_changes as entityChangesService } from "@triliumnext/core";
import becca from "../becca/becca.js";
-import BBranch from "../becca/entities/bbranch.js";
import eu from "./etapi_utils.js";
import mappers from "./mappers.js";
import v from "./validators.js";
diff --git a/apps/server/src/etapi/mappers.ts b/apps/server/src/etapi/mappers.ts
index d00a9798db..c6c9c15b0f 100644
--- a/apps/server/src/etapi/mappers.ts
+++ b/apps/server/src/etapi/mappers.ts
@@ -1,6 +1,4 @@
-import type { BAttachment, BAttribute, BNote, BRevision } from "@triliumnext/core";
-
-import type BBranch from "../becca/entities/bbranch.js";
+import type { BAttachment, BAttribute, BBranch, BNote, BRevision } from "@triliumnext/core";
function mapNoteToPojo(note: BNote) {
return {
diff --git a/apps/server/src/services/branches.ts b/apps/server/src/services/branches.ts
index b41036d93a..39a340465f 100644
--- a/apps/server/src/services/branches.ts
+++ b/apps/server/src/services/branches.ts
@@ -1,6 +1,5 @@
-import { tree as treeService } from "@triliumnext/core";
+import { type BBranch, tree as treeService } from "@triliumnext/core";
-import type BBranch from "../becca/entities/bbranch.js";
import sql from "./sql.js";
function moveBranchToNote(branchToMove: BBranch, targetParentNoteId: string) {
diff --git a/apps/server/src/services/export/zip/share_theme.ts b/apps/server/src/services/export/zip/share_theme.ts
index 181829a1c2..ef42c6ad05 100644
--- a/apps/server/src/services/export/zip/share_theme.ts
+++ b/apps/server/src/services/export/zip/share_theme.ts
@@ -1,4 +1,4 @@
-import { type BNote, ExportFormat, icon_packs as iconPackService, ZipExportProvider } from "@triliumnext/core";
+import { type BBranch, type BNote, ExportFormat, icon_packs as iconPackService, ZipExportProvider } from "@triliumnext/core";
import ejs from "ejs";
import fs, { readdirSync, readFileSync } from "fs";
import { convert as convertToText } from "html-to-text";
@@ -6,7 +6,6 @@ import { t } from "i18next";
import { join } from "path";
import becca from "../../../becca/becca";
-import type BBranch from "../../../becca/entities/bbranch.js";
import { getClientDir, getShareThemeAssetDir } from "../../../routes/assets";
import { getDefaultTemplatePath, readTemplate, renderNoteForExport } from "../../../share/content_renderer";
import log from "../../log";
diff --git a/apps/server/src/services/search/services/search_benchmark.spec.ts b/apps/server/src/services/search/services/search_benchmark.spec.ts
index b7a460d4d2..6f03329148 100644
--- a/apps/server/src/services/search/services/search_benchmark.spec.ts
+++ b/apps/server/src/services/search/services/search_benchmark.spec.ts
@@ -12,9 +12,8 @@
*
* All times are in-memory (monkeypatched getContent, no real SQL).
*/
-import { becca_mocking, BNote, search as searchService, SearchContext } from "@triliumnext/core";
+import { BBranch, becca_mocking, BNote, search as searchService, SearchContext } from "@triliumnext/core";
import { describe, it, expect, afterEach } from "vitest";
-import BBranch from "../../../becca/entities/bbranch.js";
import becca from "../../../becca/becca.js";
const { NoteBuilder, note } = becca_mocking;
diff --git a/apps/server/src/share/content_renderer.ts b/apps/server/src/share/content_renderer.ts
index b2ef8786d2..6849f38310 100644
--- a/apps/server/src/share/content_renderer.ts
+++ b/apps/server/src/share/content_renderer.ts
@@ -1,5 +1,5 @@
import { extractYouTubeVideoId, renderSpreadsheetToHtml, renderToHtml as renderMarkdownToHtml } from "@triliumnext/commons";
-import { type BAttachment, BNote, icon_packs as iconPackService, options, sanitize, task_states, utils } from "@triliumnext/core";
+import { type BAttachment, type BBranch, BNote, icon_packs as iconPackService, options, sanitize, task_states, utils } from "@triliumnext/core";
import { highlightAuto } from "@triliumnext/highlightjs";
import ejs from "ejs";
import escapeHtml from "escape-html";
@@ -9,7 +9,6 @@ import { HTMLElement, Options, parse, TextNode } from "node-html-parser";
import { join } from "path";
import becca from "../becca/becca.js";
-import type BBranch from "../becca/entities/bbranch.js";
import assetPath, { assetUrlFragment } from "../services/asset_path.js";
import log from "../services/log.js";
import { getResourceDir, isDev } from "../services/utils.js";
diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml
index 1f123c63cc..4f19eda818 100644
--- a/pnpm-lock.yaml
+++ b/pnpm-lock.yaml
@@ -403,7 +403,7 @@ importers:
version: 6.3.3
copy-webpack-plugin:
specifier: 14.0.0
happy-dom:
specifier: 20.9.0
version: 20.9.0
@@ -586,7 +586,11 @@ importers:
specifier: 8.3.4
version: 8.3.4
- apps/script-deployer: {}
+ apps/script-deployer:
+ devDependencies:
+ '@triliumnext/core':
+ specifier: workspace:*
+ version: link:../../packages/trilium-core
apps/server:
dependencies:
@@ -21575,14 +21579,14 @@ snapshots:
dependencies:
glob-parent: 6.0.2
normalize-path: 3.0.0
schema-utils: 4.3.3
serialize-javascript: 7.0.5
tinyglobby: 0.2.16
dependencies:
@@ -27663,17 +27667,16 @@ snapshots:
rimraf: 2.6.3
optional: true
dependencies:
'@jridgewell/trace-mapping': 0.3.31
jest-worker: 27.5.1
schema-utils: 4.3.3
terser: 5.47.1
optionalDependencies:
esbuild: 0.28.0
lightningcss: 1.32.0
- postcss: 8.5.15
dependencies:
@@ -28512,7 +28515,7 @@ snapshots:
- postcss
- uglify-js
dependencies:
'@types/eslint-scope': 3.7.7
'@types/estree': 1.0.9
@@ -28535,7 +28538,7 @@ snapshots:
neo-async: 2.6.2
schema-utils: 4.3.3
tapable: 2.3.3
watchpack: 2.5.1
webpack-sources: 3.4.1
transitivePeerDependencies: