chore(server): fix references to abstract becca entity

This commit is contained in:
Elian Doran 2026-01-06 11:54:29 +02:00
parent 9391159413
commit 544c52931c
No known key found for this signature in database
6 changed files with 56 additions and 55 deletions

View File

@ -1,8 +1,7 @@
import { NotFoundError, ValidationError } from "@triliumnext/core"; import { AbstractBeccaEntity,NotFoundError, ValidationError } from "@triliumnext/core";
import express, { type RequestHandler } from "express"; import express, { type RequestHandler } from "express";
import multer from "multer"; import multer from "multer";
import AbstractBeccaEntity from "../becca/entities/abstract_becca_entity.js";
import { namespace } from "../cls_provider.js"; import { namespace } from "../cls_provider.js";
import auth from "../services/auth.js"; import auth from "../services/auth.js";
import cls from "../services/cls.js"; import cls from "../services/cls.js";

View File

@ -1,41 +1,42 @@
import log from "./log.js"; import type { AttributeRow } from "@triliumnext/commons";
import noteService from "./notes.js";
import sql from "./sql.js";
import { randomString, escapeHtml, unescapeHtml } from "./utils.js";
import attributeService from "./attributes.js";
import dateNoteService from "./date_notes.js";
import treeService from "./tree.js";
import config from "./config.js";
import axios from "axios";
import { dayjs } from "@triliumnext/commons"; import { dayjs } from "@triliumnext/commons";
import xml2js from "xml2js"; import { formatLogMessage } from "@triliumnext/commons";
import type { AbstractBeccaEntity } from "@triliumnext/core";
import axios from "axios";
import * as cheerio from "cheerio"; import * as cheerio from "cheerio";
import cloningService from "./cloning.js"; import xml2js from "xml2js";
import appInfo from "./app_info.js";
import searchService from "./search/services/search.js";
import SearchContext from "./search/search_context.js";
import becca from "../becca/becca.js"; import becca from "../becca/becca.js";
import ws from "./ws.js"; import type Becca from "../becca/becca-interface.js";
import type BAttachment from "../becca/entities/battachment.js";
import type BAttribute from "../becca/entities/battribute.js";
import type BBranch from "../becca/entities/bbranch.js";
import type BEtapiToken from "../becca/entities/betapi_token.js";
import type BNote from "../becca/entities/bnote.js";
import type BOption from "../becca/entities/boption.js";
import type BRevision from "../becca/entities/brevision.js";
import appInfo from "./app_info.js";
import attributeService from "./attributes.js";
import type { ApiParams } from "./backend_script_api_interface.js";
import backupService from "./backup.js";
import branchService from "./branches.js";
import cloningService from "./cloning.js";
import config from "./config.js";
import dateNoteService from "./date_notes.js";
import exportService from "./export/zip.js";
import log from "./log.js";
import type { NoteParams } from "./note-interface.js";
import noteService from "./notes.js";
import optionsService from "./options.js";
import SearchContext from "./search/search_context.js";
import searchService from "./search/services/search.js";
import SpacedUpdate from "./spaced_update.js"; import SpacedUpdate from "./spaced_update.js";
import specialNotesService from "./special_notes.js"; import specialNotesService from "./special_notes.js";
import branchService from "./branches.js"; import sql from "./sql.js";
import exportService from "./export/zip.js";
import syncMutex from "./sync_mutex.js"; import syncMutex from "./sync_mutex.js";
import backupService from "./backup.js"; import treeService from "./tree.js";
import optionsService from "./options.js"; import { escapeHtml, randomString, unescapeHtml } from "./utils.js";
import { formatLogMessage } from "@triliumnext/commons"; import ws from "./ws.js";
import type BNote from "../becca/entities/bnote.js";
import type AbstractBeccaEntity from "../becca/entities/abstract_becca_entity.js";
import type BBranch from "../becca/entities/bbranch.js";
import type BAttribute from "../becca/entities/battribute.js";
import type BAttachment from "../becca/entities/battachment.js";
import type BRevision from "../becca/entities/brevision.js";
import type BEtapiToken from "../becca/entities/betapi_token.js";
import type BOption from "../becca/entities/boption.js";
import type { AttributeRow } from "@triliumnext/commons";
import type Becca from "../becca/becca-interface.js";
import type { NoteParams } from "./note-interface.js";
import type { ApiParams } from "./backend_script_api_interface.js";
/** /**
* A whole number * A whole number
@ -506,7 +507,7 @@ function BackendScriptApi(this: Api, currentNote: BNote, apiParams: ApiParams) {
throw new Error(`Unable to find parent note with ID ${parentNote}.`); throw new Error(`Unable to find parent note with ID ${parentNote}.`);
} }
let extraOptions: NoteParams = { const extraOptions: NoteParams = {
..._extraOptions, ..._extraOptions,
content: "", content: "",
type: "text", type: "text",
@ -620,13 +621,13 @@ function BackendScriptApi(this: Api, currentNote: BNote, apiParams: ApiParams) {
} }
const parentNoteId = opts.isVisible ? "_lbVisibleLaunchers" : "_lbAvailableLaunchers"; const parentNoteId = opts.isVisible ? "_lbVisibleLaunchers" : "_lbAvailableLaunchers";
const noteId = "al_" + opts.id; const noteId = `al_${ opts.id}`;
const launcherNote = const launcherNote =
becca.getNote(noteId) || becca.getNote(noteId) ||
specialNotesService.createLauncher({ specialNotesService.createLauncher({
noteId: noteId, noteId,
parentNoteId: parentNoteId, parentNoteId,
launcherType: opts.type launcherType: opts.type
}).note; }).note;
@ -680,7 +681,7 @@ function BackendScriptApi(this: Api, currentNote: BNote, apiParams: ApiParams) {
ws.sendMessageToAllClients({ ws.sendMessageToAllClients({
type: "execute-script", type: "execute-script",
script: script, script,
params: prepareParams(params), params: prepareParams(params),
startNoteId: this.startNote?.noteId, startNoteId: this.startNote?.noteId,
currentNoteId: this.currentNote.noteId, currentNoteId: this.currentNote.noteId,
@ -696,9 +697,9 @@ function BackendScriptApi(this: Api, currentNote: BNote, apiParams: ApiParams) {
return params.map((p) => { return params.map((p) => {
if (typeof p === "function") { if (typeof p === "function") {
return `!@#Function: ${p.toString()}`; return `!@#Function: ${p.toString()}`;
} else {
return p;
} }
return p;
}); });
} }
}; };

View File

@ -1,5 +1,6 @@
import type { AbstractBeccaEntity } from "@triliumnext/core";
import type { Request, Response } from "express"; import type { Request, Response } from "express";
import type AbstractBeccaEntity from "../becca/entities/abstract_becca_entity.js";
import type BNote from "../becca/entities/bnote.js"; import type BNote from "../becca/entities/bnote.js";
export interface ApiParams { export interface ApiParams {

View File

@ -1,7 +1,6 @@
import { events as eventService } from "@triliumnext/core"; import { type AbstractBeccaEntity, events as eventService } from "@triliumnext/core";
import becca from "../becca/becca.js"; import becca from "../becca/becca.js";
import type AbstractBeccaEntity from "../becca/entities/abstract_becca_entity.js";
import BAttribute from "../becca/entities/battribute.js"; import BAttribute from "../becca/entities/battribute.js";
import type BNote from "../becca/entities/bnote.js"; import type BNote from "../becca/entities/bnote.js";
import hiddenSubtreeService from "./hidden_subtree.js"; import hiddenSubtreeService from "./hidden_subtree.js";

View File

@ -1,16 +1,16 @@
import { WebSocketServer as WebSocketServer, WebSocket } from "ws"; import { type EntityChange,WebSocketMessage } from "@triliumnext/commons";
import { isElectron, randomString } from "./utils.js"; import { AbstractBeccaEntity } from "@triliumnext/core";
import log from "./log.js"; import type { IncomingMessage, Server as HttpServer } from "http";
import sql from "./sql.js"; import { WebSocket,WebSocketServer } from "ws";
import becca from "../becca/becca.js";
import cls from "./cls.js"; import cls from "./cls.js";
import config from "./config.js"; import config from "./config.js";
import syncMutexService from "./sync_mutex.js"; import log from "./log.js";
import protectedSessionService from "./protected_session.js"; import protectedSessionService from "./protected_session.js";
import becca from "../becca/becca.js"; import sql from "./sql.js";
import AbstractBeccaEntity from "../becca/entities/abstract_becca_entity.js"; import syncMutexService from "./sync_mutex.js";
import { isElectron, randomString } from "./utils.js";
import type { IncomingMessage, Server as HttpServer } from "http";
import { WebSocketMessage, type EntityChange } from "@triliumnext/commons";
let webSocketServer!: WebSocketServer; let webSocketServer!: WebSocketServer;
let lastSyncedPush: number; let lastSyncedPush: number;
@ -80,7 +80,7 @@ function sendMessageToAllClients(message: WebSocketMessage) {
} }
let clientCount = 0; let clientCount = 0;
webSocketServer.clients.forEach(function each(client) { webSocketServer.clients.forEach((client) => {
if (client.readyState === WebSocket.OPEN) { if (client.readyState === WebSocket.OPEN) {
client.send(jsonStr); client.send(jsonStr);
clientCount++; clientCount++;

View File

@ -27,6 +27,7 @@ export { default as BNote } from "./becca/entities/bnote";
export { default as BOption } from "./becca/entities/boption"; export { default as BOption } from "./becca/entities/boption";
export { default as BRecentNote } from "./becca/entities/brecent_note"; export { default as BRecentNote } from "./becca/entities/brecent_note";
export { default as BRevision } from "./becca/entities/brevision"; export { default as BRevision } from "./becca/entities/brevision";
export { default as AbstractBeccaEntity } from "./becca/entities/abstract_becca_entity";
export function initializeCore({ dbConfig, executionContext, crypto }: { export function initializeCore({ dbConfig, executionContext, crypto }: {
dbConfig: SqlServiceParams, dbConfig: SqlServiceParams,