chore(server): various references to core

This commit is contained in:
Elian Doran 2026-01-06 12:05:52 +02:00
parent e19e9b3830
commit b7ad76827a
No known key found for this signature in database
7 changed files with 19 additions and 22 deletions

View File

@ -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 {

View File

@ -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 {

View File

@ -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";

View File

@ -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[]) {

View File

@ -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]);
}

View File

@ -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";

View File

@ -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";