mirror of
https://github.com/zadam/trilium.git
synced 2026-05-07 09:46:56 +02:00
chore(core): fix various type errors
This commit is contained in:
@@ -1,13 +1,14 @@
|
||||
import type { Router, Request, Response, NextFunction } from "express";
|
||||
import eu from "./etapi_utils.js";
|
||||
import sql from "../services/sql.js";
|
||||
import type { NextFunction,Request, Response, Router } from "express";
|
||||
|
||||
import appInfo from "../services/app_info.js";
|
||||
import sql from "../services/sql.js";
|
||||
import eu from "./etapi_utils.js";
|
||||
|
||||
interface MetricsData {
|
||||
version: {
|
||||
app: string;
|
||||
db: number;
|
||||
node: string;
|
||||
node?: string;
|
||||
sync: number;
|
||||
buildDate: string;
|
||||
buildRevision: string;
|
||||
@@ -45,7 +46,7 @@ function formatPrometheusMetrics(data: MetricsData): string {
|
||||
const lines: string[] = [];
|
||||
|
||||
// Helper function to add a metric
|
||||
const addMetric = (name: string, value: number | null, help: string, type: string = 'gauge', labels: Record<string, string> = {}) => {
|
||||
const addMetric = (name: string, value: number | null, help: string, type: string = 'gauge', labels: Record<string, string | undefined> = {}) => {
|
||||
if (value === null) return;
|
||||
|
||||
lines.push(`# HELP ${name} ${help}`);
|
||||
@@ -233,8 +234,8 @@ function register(router: Router): void {
|
||||
} else if (format === 'prometheus') {
|
||||
const prometheusText = formatPrometheusMetrics(metrics);
|
||||
res.status(200)
|
||||
.set('Content-Type', 'text/plain; version=0.0.4; charset=utf-8')
|
||||
.send(prometheusText);
|
||||
.set('Content-Type', 'text/plain; version=0.0.4; charset=utf-8')
|
||||
.send(prometheusText);
|
||||
} else {
|
||||
throw new eu.EtapiError(400, "INVALID_FORMAT", "Supported formats: 'prometheus' (default), 'json'");
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { BackupDatabaseNowResponse, DatabaseCheckIntegrityResponse } from "@triliumnext/commons";
|
||||
import { becca_loader, ValidationError } from "@triliumnext/core";
|
||||
import { becca_loader, rebuildIntegrationTestDatabase as rebuildIntegrationTestDatabaseCore,ValidationError } from "@triliumnext/core";
|
||||
import type { Request } from "express";
|
||||
|
||||
import anonymizationService from "../../services/anonymization.js";
|
||||
@@ -30,7 +30,7 @@ function findAndFixConsistencyIssues() {
|
||||
}
|
||||
|
||||
async function rebuildIntegrationTestDatabase() {
|
||||
sql.rebuildIntegrationTestDatabase();
|
||||
rebuildIntegrationTestDatabaseCore();
|
||||
sql_init.initializeDb();
|
||||
becca_loader.load();
|
||||
}
|
||||
|
||||
@@ -1,12 +1,11 @@
|
||||
import { deferred, LOCALES } from "@triliumnext/commons";
|
||||
import { becca_loader, i18n } from "@triliumnext/core";
|
||||
import { beforeAll, describe, expect, it } from "vitest";
|
||||
|
||||
import becca from "../becca/becca.js";
|
||||
import becca_loader from "../becca/becca_loader.js";
|
||||
import branches from "./branches.js";
|
||||
import cls from "./cls.js";
|
||||
import hiddenSubtreeService from "./hidden_subtree.js";
|
||||
import { changeLanguage } from "./i18n.js";
|
||||
import notes from "./notes.js";
|
||||
import sql_init from "./sql_init.js";
|
||||
|
||||
@@ -141,7 +140,7 @@ describe("Hidden Subtree", () => {
|
||||
}
|
||||
|
||||
try {
|
||||
await changeLanguage(locale.id);
|
||||
await i18n.changeLanguage(locale.id);
|
||||
} catch (error) {
|
||||
done.reject(error);
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { describe, expect, it, beforeEach } from "vitest";
|
||||
import * as cls from "../services/context.js";
|
||||
import { getSql } from "../services/sql/index.js";
|
||||
import { getSql, rebuildIntegrationTestDatabase } from "../services/sql/index.js";
|
||||
import becca from "../becca/becca.js";
|
||||
import becca_loader from "../becca/becca_loader.js";
|
||||
import migration from "./0233__migrate_geo_map_to_collection.js";
|
||||
@@ -23,7 +23,7 @@ describe("Migration 0233: Migrate geoMap to collection", () => {
|
||||
|
||||
beforeEach(async () => {
|
||||
// Set up a clean in-memory database for each test
|
||||
sql.rebuildIntegrationTestDatabase();
|
||||
rebuildIntegrationTestDatabase();
|
||||
|
||||
await new Promise<void>((resolve) => {
|
||||
cls.getContext().init(() => {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
export default {
|
||||
backupNow() {
|
||||
backupNow(name: string) {
|
||||
console.warn("Backup not yet available.");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,5 +2,10 @@
|
||||
export default {
|
||||
General: {
|
||||
readOnly: false
|
||||
},
|
||||
Sync: {
|
||||
syncServerHost: "",
|
||||
syncServerTimeout: "120000",
|
||||
syncProxy: ""
|
||||
}
|
||||
};
|
||||
|
||||
@@ -4,6 +4,7 @@ export default {
|
||||
|
||||
return {
|
||||
attachmentId: null,
|
||||
title: ""
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import type BNote from "../becca/entities/bnote";
|
||||
|
||||
export function executeNoteNoException(script: unknown) {
|
||||
export function executeNoteNoException(script: unknown, { originEntity: unknown }) {
|
||||
console.warn("Skipped script execution");
|
||||
}
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@ import searchService from "./search.js";
|
||||
import BNote from "../../../becca/entities/bnote.js";
|
||||
import BBranch from "../../../becca/entities/bbranch.js";
|
||||
import SearchContext from "../search_context.js";
|
||||
import dateUtils from "../../date_utils.js";
|
||||
import dateUtils from "../../utils/date.js";
|
||||
import becca from "../../../becca/becca.js";
|
||||
import { findNoteByTitle, note, NoteBuilder } from "../../../test/becca_mocking.js";
|
||||
|
||||
|
||||
@@ -14,6 +14,6 @@ export function getSql(): SqlService {
|
||||
return sql;
|
||||
}
|
||||
|
||||
export function rebuildIntegrationTestDatabase(path: string) {
|
||||
export function rebuildIntegrationTestDatabase(path?: string) {
|
||||
throw new Error("Not implemented");
|
||||
}
|
||||
|
||||
@@ -4,8 +4,8 @@ import becca from "../becca/becca.js";
|
||||
import BBranch from "../becca/entities/bbranch.js";
|
||||
import BNote from "../becca/entities/bnote.js";
|
||||
import tree from "./tree.js";
|
||||
import cls from "./cls.js";
|
||||
import {buildNote} from "../test/becca_easy_mocking.js";
|
||||
import { getContext } from "./context.js";
|
||||
|
||||
describe("Tree", () => {
|
||||
let rootNote!: NoteBuilder;
|
||||
@@ -58,7 +58,7 @@ describe("Tree", () => {
|
||||
],
|
||||
"#sorted": "",
|
||||
});
|
||||
cls.init(() => {
|
||||
getContext().init(() => {
|
||||
tree.sortNotesIfNeeded(note.noteId);
|
||||
});
|
||||
const orderedTitles = note.children.map((child) => child.title);
|
||||
@@ -85,7 +85,7 @@ describe("Tree", () => {
|
||||
|
||||
// Sort a few times to ensure that the resulting order is the same.
|
||||
for (let i = 0; i < 5; i++) {
|
||||
cls.init(() => {
|
||||
getContext().init(() => {
|
||||
tree.sortNotesIfNeeded(rootNote.note.noteId);
|
||||
});
|
||||
|
||||
@@ -106,7 +106,7 @@ describe("Tree", () => {
|
||||
],
|
||||
"#sorted": ""
|
||||
});
|
||||
cls.init(() => {
|
||||
getContext().init(() => {
|
||||
tree.sortNotesIfNeeded(note.noteId);
|
||||
});
|
||||
const orderedTitles = note.children.map((child) => child.title);
|
||||
@@ -126,7 +126,7 @@ describe("Tree", () => {
|
||||
"#sorted": "",
|
||||
"#sortDirection": "desc"
|
||||
});
|
||||
cls.init(() => {
|
||||
getContext().init(() => {
|
||||
tree.sortNotesIfNeeded(note.noteId);
|
||||
});
|
||||
const orderedTitles = note.children.map((child) => child.title);
|
||||
@@ -148,7 +148,7 @@ describe("Tree", () => {
|
||||
"#sorted": "",
|
||||
"#sortFoldersFirst": ""
|
||||
});
|
||||
cls.init(() => {
|
||||
getContext().init(() => {
|
||||
tree.sortNotesIfNeeded(note.noteId);
|
||||
});
|
||||
const orderedTitles = note.children.map((child) => child.title);
|
||||
@@ -169,7 +169,7 @@ describe("Tree", () => {
|
||||
"#sorted": "",
|
||||
"#sortNatural": ""
|
||||
});
|
||||
cls.init(() => {
|
||||
getContext().init(() => {
|
||||
tree.sortNotesIfNeeded(note.noteId);
|
||||
});
|
||||
const orderedTitles = note.children.map((child) => child.title);
|
||||
|
||||
@@ -5,6 +5,7 @@ import mimeTypes from "mime-types";
|
||||
import escape from "escape-html";
|
||||
import unescape from "unescape";
|
||||
import path from "path";
|
||||
import { NoteMeta } from "../../meta";
|
||||
|
||||
// TODO: Implement platform detection.
|
||||
export const isElectron = false;
|
||||
|
||||
@@ -20,7 +20,8 @@
|
||||
"src/**/*.spec.js",
|
||||
"src/**/*.test.jsx",
|
||||
"src/**/*.spec.jsx",
|
||||
"src/**/*.d.ts"
|
||||
"src/**/*.d.ts",
|
||||
"src/**/*.json"
|
||||
],
|
||||
"references": [
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user