mirror of
https://github.com/zadam/trilium.git
synced 2026-05-07 06:57:16 +02:00
fix(standalone): cyclic dependency breaking prod
This commit is contained in:
@@ -20,6 +20,7 @@ import BRevision from "./brevision.js";
|
||||
import { getLog } from "../../services/log.js";
|
||||
import { getSql } from "../../services/sql/index.js";
|
||||
import { formatDownloadTitle, isStringNote, normalize, randomString, replaceAll } from "../../services/utils/index.js";
|
||||
import scriptService from "../../services/script.js";
|
||||
|
||||
const LABEL = "label";
|
||||
const RELATION = "relation";
|
||||
@@ -322,9 +323,6 @@ class BNote extends AbstractBeccaEntity<BNote> {
|
||||
* @returns the return value of the executed script
|
||||
*/
|
||||
executeScript() {
|
||||
// Lazy require to avoid circular dependency (script.ts imports BNote as a type).
|
||||
// eslint-disable-next-line @typescript-eslint/no-require-imports
|
||||
const scriptService = require("../../services/script.js").default;
|
||||
return scriptService.executeNote(this, { originEntity: this });
|
||||
}
|
||||
|
||||
|
||||
@@ -26,7 +26,7 @@ async function exec(req: Request) {
|
||||
try {
|
||||
const body = req.body as ScriptBody;
|
||||
|
||||
const execute = (body: ScriptBody) => scriptService.executeScript(body.script, body.params, body.startNoteId, body.currentNoteId, body.originEntityName, body.originEntityId);
|
||||
const execute = (body: ScriptBody) => scriptService.executeScript(body.script, body.params, body.startNoteId, body.currentNoteId, body.originEntityName, body.originEntityId, becca);
|
||||
|
||||
const result = body.transactional ? getSql().transactional(() => execute(body)) : await execute(body);
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { ScriptParams } from "@triliumnext/commons";
|
||||
import { transform } from "sucrase";
|
||||
|
||||
import becca from "../becca/becca.js";
|
||||
import type Becca from "../becca/becca-interface.js";
|
||||
import type BNote from "../becca/entities/bnote.js";
|
||||
import type { ApiParams } from "./backend_script_api_interface.js";
|
||||
import { getLog } from "./log.js";
|
||||
@@ -76,7 +76,7 @@ ${bundle.script}\r
|
||||
* This method preserves frontend startNode - that's why we start execution from currentNote and override
|
||||
* bundle's startNote.
|
||||
*/
|
||||
function executeScript(script: string, params: ScriptParams, startNoteId: string, currentNoteId: string, originEntityName: string, originEntityId: string) {
|
||||
function executeScript(script: string, params: ScriptParams, startNoteId: string, currentNoteId: string, originEntityName: string, originEntityId: string, becca: Becca) {
|
||||
const startNote = becca.getNote(startNoteId);
|
||||
const currentNote = becca.getNote(currentNoteId);
|
||||
const originEntity = becca.getEntity(originEntityName, originEntityId);
|
||||
|
||||
Reference in New Issue
Block a user