mirror of
https://github.com/zadam/trilium.git
synced 2025-03-01 14:22:32 +01:00
server-esm: Remove dynamic imports due to past circular issues
This commit is contained in:
parent
efdae79c10
commit
ad93fe4b75
@ -155,9 +155,7 @@ export default class Becca {
|
|||||||
}
|
}
|
||||||
|
|
||||||
getRevision(revisionId: string): BRevision | null {
|
getRevision(revisionId: string): BRevision | null {
|
||||||
const row = sql.getRow("SELECT * FROM revisions WHERE revisionId = ?", [revisionId]);
|
const row = sql.getRow<RevisionRow | null>("SELECT * FROM revisions WHERE revisionId = ?", [revisionId]);
|
||||||
|
|
||||||
const BRevision = require('./entities/brevision'); // avoiding circular dependency problems
|
|
||||||
return row ? new BRevision(row) : null;
|
return row ? new BRevision(row) : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -179,9 +177,7 @@ export default class Becca {
|
|||||||
WHERE attachmentId = ? AND isDeleted = 0`
|
WHERE attachmentId = ? AND isDeleted = 0`
|
||||||
: `SELECT * FROM attachments WHERE attachmentId = ? AND isDeleted = 0`;
|
: `SELECT * FROM attachments WHERE attachmentId = ? AND isDeleted = 0`;
|
||||||
|
|
||||||
const BAttachment = require('./entities/battachment'); // avoiding circular dependency problems
|
return sql.getRows<AttachmentRow>(query, [attachmentId])
|
||||||
|
|
||||||
return sql.getRows(query, [attachmentId])
|
|
||||||
.map(row => new BAttachment(row))[0];
|
.map(row => new BAttachment(row))[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -194,7 +190,6 @@ export default class Becca {
|
|||||||
}
|
}
|
||||||
|
|
||||||
getAttachments(attachmentIds: string[]): BAttachment[] {
|
getAttachments(attachmentIds: string[]): BAttachment[] {
|
||||||
const BAttachment = require('./entities/battachment'); // avoiding circular dependency problems
|
|
||||||
return sql.getManyRows<AttachmentRow>("SELECT * FROM attachments WHERE attachmentId IN (???) AND isDeleted = 0", attachmentIds)
|
return sql.getManyRows<AttachmentRow>("SELECT * FROM attachments WHERE attachmentId IN (???) AND isDeleted = 0", attachmentIds)
|
||||||
.map(row => new BAttachment(row));
|
.map(row => new BAttachment(row));
|
||||||
}
|
}
|
||||||
@ -204,9 +199,7 @@ export default class Becca {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
const row = sql.getRow("SELECT *, LENGTH(content) AS contentLength FROM blobs WHERE blobId = ?", [entity.blobId]);
|
const row = sql.getRow<BBlob | null>("SELECT *, LENGTH(content) AS contentLength FROM blobs WHERE blobId = ?", [entity.blobId]);
|
||||||
|
|
||||||
const BBlob = require('./entities/bblob'); // avoiding circular dependency problems
|
|
||||||
return row ? new BBlob(row) : null;
|
return row ? new BBlob(row) : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -248,16 +241,12 @@ export default class Becca {
|
|||||||
}
|
}
|
||||||
|
|
||||||
getRecentNotesFromQuery(query: string, params: string[] = []): BRecentNote[] {
|
getRecentNotesFromQuery(query: string, params: string[] = []): BRecentNote[] {
|
||||||
const rows = sql.getRows(query, params);
|
const rows = sql.getRows<BRecentNote>(query, params);
|
||||||
|
|
||||||
const BRecentNote = require('./entities/brecent_note'); // avoiding circular dependency problems
|
|
||||||
return rows.map(row => new BRecentNote(row));
|
return rows.map(row => new BRecentNote(row));
|
||||||
}
|
}
|
||||||
|
|
||||||
getRevisionsFromQuery(query: string, params: string[] = []): BRevision[] {
|
getRevisionsFromQuery(query: string, params: string[] = []): BRevision[] {
|
||||||
const rows = sql.getRows<RevisionRow>(query, params);
|
const rows = sql.getRows<RevisionRow>(query, params);
|
||||||
|
|
||||||
const BRevision = require('./entities/brevision'); // avoiding circular dependency problems
|
|
||||||
return rows.map(row => new BRevision(row));
|
return rows.map(row => new BRevision(row));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -42,7 +42,7 @@ export interface OptionRow {
|
|||||||
name: string;
|
name: string;
|
||||||
value: string;
|
value: string;
|
||||||
isSynced: boolean;
|
isSynced: boolean;
|
||||||
utcDateModified: string;
|
utcDateModified?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface EtapiTokenRow {
|
export interface EtapiTokenRow {
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
import becca from "../becca/becca.js";
|
import becca from "../becca/becca.js";
|
||||||
|
import BOption from "../becca/entities/boption.js";
|
||||||
import { OptionRow } from '../becca/entities/rows';
|
import { OptionRow } from '../becca/entities/rows';
|
||||||
import sql from "./sql.js";
|
import sql from "./sql.js";
|
||||||
|
|
||||||
@ -68,10 +69,7 @@ function setOption(name: string, value: string | number | boolean) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function createOption(name: string, value: string | number, isSynced: boolean) {
|
function createOption(name: string, value: string, isSynced: boolean) {
|
||||||
// to avoid circular dependency, need to find a better solution
|
|
||||||
const BOption = require('../becca/entities/boption');
|
|
||||||
|
|
||||||
new BOption({
|
new BOption({
|
||||||
name: name,
|
name: name,
|
||||||
value: value,
|
value: value,
|
||||||
|
@ -16,6 +16,7 @@ import BAttribute from "../../../becca/entities/battribute.js";
|
|||||||
import { SearchParams, TokenStructure } from "./types";
|
import { SearchParams, TokenStructure } from "./types";
|
||||||
import Expression from "../expressions/expression.js";
|
import Expression from "../expressions/expression.js";
|
||||||
import sql from "../../sql.js";
|
import sql from "../../sql.js";
|
||||||
|
import scriptService from "../../script.js";
|
||||||
|
|
||||||
function searchFromNote(note: BNote) {
|
function searchFromNote(note: BNote) {
|
||||||
let searchResultNoteIds;
|
let searchResultNoteIds;
|
||||||
@ -78,7 +79,6 @@ function searchFromRelation(note: BNote, relationName: string) {
|
|||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
|
|
||||||
const scriptService = require('../../script'); // TODO: to avoid circular dependency
|
|
||||||
const result = scriptService.executeNote(scriptNote, {originEntity: note});
|
const result = scriptService.executeNote(scriptNote, {originEntity: note});
|
||||||
|
|
||||||
if (!Array.isArray(result)) {
|
if (!Array.isArray(result)) {
|
||||||
|
@ -19,6 +19,7 @@ import entityConstructor from "../becca/entity_constructor.js";
|
|||||||
import becca from "../becca/becca.js";
|
import becca from "../becca/becca.js";
|
||||||
import { EntityChange, EntityChangeRecord, EntityRow } from './entity_changes_interface';
|
import { EntityChange, EntityChangeRecord, EntityRow } from './entity_changes_interface';
|
||||||
import { CookieJar, ExecOpts } from './request_interface';
|
import { CookieJar, ExecOpts } from './request_interface';
|
||||||
|
import setupService from "./setup.js";
|
||||||
|
|
||||||
let proxyToggle = true;
|
let proxyToggle = true;
|
||||||
|
|
||||||
@ -107,8 +108,6 @@ async function sync() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async function login() {
|
async function login() {
|
||||||
const setupService = require('./setup'); // circular dependency issue
|
|
||||||
|
|
||||||
if (!await setupService.hasSyncServerSchemaAndSeed()) {
|
if (!await setupService.hasSyncServerSchemaAndSeed()) {
|
||||||
await setupService.sendSeedToSyncServer();
|
await setupService.sendSeedToSyncServer();
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user