Skip to content

Build your personal knowledge base with Trilium Notes

chore(server): various references to core

Elian Doranb7ad76827ab7
diff --git a/apps/server/src/anonymize.ts b/apps/server/src/anonymize.ts
index e78fe00179..aea817831e 100644
--- a/apps/server/src/anonymize.ts
+++ b/apps/server/src/anonymize.ts
@@ -1,6 +1,6 @@
import anonymizationService from "./services/anonymization.js";
import sqlInit from "./services/sql_init.js";
-await import("./becca/entity_constructor.js");
+await import("@triliumnext/core");
sqlInit.dbReady.then(async () => {
try {
diff --git a/apps/server/src/routes/api/similar_notes.ts b/apps/server/src/routes/api/similar_notes.ts
index 6b9cbb9261..afa845b102 100644
--- a/apps/server/src/routes/api/similar_notes.ts
+++ b/apps/server/src/routes/api/similar_notes.ts
@@ -1,17 +1,15 @@
-"use strict";
-
+import { SimilarNoteResponse } from "@triliumnext/commons";
+import { similarity } from "@triliumnext/core";
import type { Request } from "express";
-import similarityService from "../../becca/similarity.js";
import becca from "../../becca/becca.js";
-import { SimilarNoteResponse } from "@triliumnext/commons";
async function getSimilarNotes(req: Request) {
const noteId = req.params.noteId;
const _note = becca.getNoteOrThrow(noteId);
- return (await similarityService.findSimilarNotes(noteId) satisfies SimilarNoteResponse);
+ return (await similarity.findSimilarNotes(noteId) satisfies SimilarNoteResponse);
}
export default {
diff --git a/apps/server/src/services/encryption/open_id_encryption.ts b/apps/server/src/services/encryption/open_id_encryption.ts
index a191b782b3..5126a0cf5c 100644
--- a/apps/server/src/services/encryption/open_id_encryption.ts
+++ b/apps/server/src/services/encryption/open_id_encryption.ts
@@ -1,6 +1,5 @@
-import { data_encryption } from "@triliumnext/core";
+import { data_encryption, OpenIdError } from "@triliumnext/core";
-import OpenIdError from "../../errors/open_id_error.js";
import sql from "../sql.js";
import sqlInit from "../sql_init.js";
import utils, { constantTimeCompare } from "../utils.js";
diff --git a/apps/server/src/services/sync.ts b/apps/server/src/services/sync.ts
index 1ded101a34..665e140e3e 100644
--- a/apps/server/src/services/sync.ts
+++ b/apps/server/src/services/sync.ts
@@ -1,10 +1,9 @@
import type { EntityChange, EntityChangeRecord, EntityRow } from "@triliumnext/commons";
-import { becca_loader } from "@triliumnext/core";
+import { becca_loader, entity_constructor } from "@triliumnext/core";
import becca from "../becca/becca.js";
-import entityConstructor from "../becca/entity_constructor.js";
import appInfo from "./app_info.js";
import cls from "./cls.js";
import consistency_checks from "./consistency_checks.js";
@@ -95,7 +94,7 @@ async function sync() {
success: false,
message: "No connection to sync server."
};
- }
+ }
log.info(`Sync failed: '${e.message}', stack: ${e.stack}`);
ws.syncFailed();
@@ -104,7 +103,7 @@ async function sync() {
success: false,
message: e.message
};
-
+
}
}
@@ -220,9 +219,9 @@ async function pushChanges(syncContext: SyncContext) {
lastSyncedPush = entityChange.id;
return false;
- }
+ }
return true;
-
+
});
if (filteredEntityChanges.length === 0 && lastSyncedPush) {
@@ -341,8 +340,8 @@ function getEntityChangeRow(entityChange: EntityChange) {
if (entityName === "note_reordering") {
return sql.getMap("SELECT branchId, notePosition FROM branches WHERE parentNoteId = ? AND isDeleted = 0", [entityId]);
- }
- const primaryKey = entityConstructor.getEntityFromEntityName(entityName).primaryKeyName;
+ }
+ const primaryKey = entity_constructor.getEntityFromEntityName(entityName).primaryKeyName;
if (!primaryKey) {
throw new Error(`Unknown entity for entity change ${JSON.stringify(entityChange)}`);
@@ -367,7 +366,7 @@ function getEntityChangeRow(entityChange: EntityChange) {
return entityRow;
-
+
}
function getEntityChangeRecords(entityChanges: EntityChange[]) {
diff --git a/apps/server/src/services/sync_update.ts b/apps/server/src/services/sync_update.ts
index 9e88e5796a..0e28f8b014 100644
--- a/apps/server/src/services/sync_update.ts
+++ b/apps/server/src/services/sync_update.ts
@@ -1,7 +1,6 @@
import type { EntityChange, EntityChangeRecord, EntityRow } from "@triliumnext/commons";
-import { events as eventService } from "@triliumnext/core";
+import { entity_constructor, events as eventService } from "@triliumnext/core";
-import entityConstructor from "../becca/entity_constructor.js";
import entityChangesService from "./entity_changes.js";
import log from "./log.js";
import sql from "./sql.js";
@@ -155,7 +154,7 @@ function eraseEntity(entityChange: EntityChange) {
return;
}
- const primaryKeyName = entityConstructor.getEntityFromEntityName(entityName).primaryKeyName;
+ const primaryKeyName = entity_constructor.getEntityFromEntityName(entityName).primaryKeyName;
sql.execute(/*sql*/`DELETE FROM ${entityName} WHERE ${primaryKeyName} = ?`, [entityId]);
}
diff --git a/apps/server/src/share/shaca/entities/snote.ts b/apps/server/src/share/shaca/entities/snote.ts
index da72cd419f..ecc1d31917 100644
--- a/apps/server/src/share/shaca/entities/snote.ts
+++ b/apps/server/src/share/shaca/entities/snote.ts
@@ -1,6 +1,6 @@
+import { NOTE_TYPE_ICONS } from "@triliumnext/core";
import escape from "escape-html";
-import { NOTE_TYPE_ICONS } from "../../../becca/entities/bnote.js";
import type { Blob } from "../../../services/blob-interface.js";
import utils from "../../../services/utils.js";
import sql from "../../sql.js";
diff --git a/packages/trilium-core/src/index.ts b/packages/trilium-core/src/index.ts
index 4a4ed3111d..e8f5e95f4b 100644
--- a/packages/trilium-core/src/index.ts
+++ b/packages/trilium-core/src/index.ts
@@ -19,12 +19,14 @@ export type { CryptoProvider } from "./services/encryption/crypto";
export { default as becca } from "./becca/becca";
export { default as becca_loader } from "./becca/becca_loader";
export { default as becca_service } from "./becca/becca_service";
+export { default as entity_constructor } from "./becca/entity_constructor";
+export { default as similarity } from "./becca/similarity";
export { default as BAttachment } from "./becca/entities/battachment";
export { default as BAttribute } from "./becca/entities/battribute";
export { default as BBlob } from "./becca/entities/bblob";
export { default as BBranch } from "./becca/entities/bbranch";
export { default as BEtapiToken } from "./becca/entities/betapi_token";
-export { default as BNote } from "./becca/entities/bnote";
+export { default as BNote, NOTE_TYPE_ICONS } from "./becca/entities/bnote";
export { default as BOption } from "./becca/entities/boption";
export { default as BRecentNote } from "./becca/entities/brecent_note";
export { default as BRevision } from "./becca/entities/brevision";