mirror of
https://github.com/zadam/trilium.git
synced 2025-11-17 02:30:42 +01:00
Merge pull request #42 from TriliumNext/feature/typescript_backend_6
Convert backend to TypeScript (67% -> 71%)
This commit is contained in:
@@ -80,7 +80,6 @@ interface Api {
|
||||
|
||||
/**
|
||||
* Axios library for HTTP requests. See {@link https://axios-http.com} for documentation
|
||||
* @type {axios}
|
||||
* @deprecated use native (browser compatible) fetch() instead
|
||||
*/
|
||||
axios: typeof axios;
|
||||
@@ -122,9 +121,6 @@ interface Api {
|
||||
/**
|
||||
* This is a powerful search method - you can search by attributes and their values, e.g.:
|
||||
* "#dateModified =* MONTH AND #log". See {@link https://github.com/zadam/trilium/wiki/Search} for full documentation for all options
|
||||
*
|
||||
* @param {string} query
|
||||
* @param {Object} [searchParams]
|
||||
*/
|
||||
searchForNote(query: string, searchParams: SearchParams): BNote | null;
|
||||
|
||||
|
||||
@@ -4,7 +4,8 @@ import protectedSessionService = require('./protected_session');
|
||||
import utils = require('./utils');
|
||||
import type { Blob } from "./blob-interface";
|
||||
|
||||
function getBlobPojo(entityName: string, entityId: string) {
|
||||
function getBlobPojo(entityName: string, entityId: string, opts?: { preview: boolean }) {
|
||||
// TODO: Unused opts.
|
||||
const entity = becca.getEntity(entityName, entityId);
|
||||
if (!entity) {
|
||||
throw new NotFoundError(`Entity ${entityName} '${entityId}' was not found.`);
|
||||
|
||||
@@ -27,7 +27,8 @@ function moveBranchToNote(branchToMove: BBranch, targetParentNoteId: string) {
|
||||
};
|
||||
}
|
||||
|
||||
function moveBranchToBranch(branchToMove: BBranch, targetParentBranch: BBranch) {
|
||||
function moveBranchToBranch(branchToMove: BBranch, targetParentBranch: BBranch, branchId: string) {
|
||||
// TODO: Unused branch ID argument.
|
||||
const res = moveBranchToNote(branchToMove, targetParentBranch.noteId);
|
||||
|
||||
if (!("success" in res) || !res.success) {
|
||||
|
||||
@@ -150,7 +150,7 @@ function getActions(note: BNote) {
|
||||
.filter(a => !!a);
|
||||
}
|
||||
|
||||
function executeActions(note: BNote, searchResultNoteIds: string[]) {
|
||||
function executeActions(note: BNote, searchResultNoteIds: string[] | Set<string>) {
|
||||
const actions = getActions(note);
|
||||
|
||||
for (const resultNoteId of searchResultNoteIds) {
|
||||
|
||||
@@ -58,7 +58,7 @@ function cloneNoteToBranch(noteId: string, parentBranchId: string, prefix: strin
|
||||
return ret;
|
||||
}
|
||||
|
||||
function ensureNoteIsPresentInParent(noteId: string, parentNoteId: string, prefix: string) {
|
||||
function ensureNoteIsPresentInParent(noteId: string, parentNoteId: string, prefix?: string) {
|
||||
if (!(noteId in becca.notes)) {
|
||||
return { branch: null, success: false, message: `Note '${noteId}' is deleted.` };
|
||||
} else if (!(parentNoteId in becca.notes)) {
|
||||
@@ -109,7 +109,7 @@ function ensureNoteIsAbsentFromParent(noteId: string, parentNoteId: string) {
|
||||
}
|
||||
}
|
||||
|
||||
function toggleNoteInParent(present: boolean, noteId: string, parentNoteId: string, prefix: string) {
|
||||
function toggleNoteInParent(present: boolean, noteId: string, parentNoteId: string, prefix?: string) {
|
||||
if (present) {
|
||||
return ensureNoteIsPresentInParent(noteId, parentNoteId, prefix);
|
||||
}
|
||||
|
||||
@@ -913,7 +913,7 @@ sqlInit.dbReady.then(() => {
|
||||
setTimeout(cls.wrap(runPeriodicChecks), 4 * 1000);
|
||||
});
|
||||
|
||||
module.exports = {
|
||||
export = {
|
||||
runOnDemandChecks,
|
||||
runEntityChangesChecks
|
||||
};
|
||||
|
||||
@@ -49,8 +49,12 @@ interface Message {
|
||||
messages?: string[];
|
||||
startNoteId?: string;
|
||||
currentNoteId?: string;
|
||||
entityType?: string;
|
||||
entityId?: string;
|
||||
originEntityName?: "notes";
|
||||
originEntityId?: string | null;
|
||||
lastModifiedMs?: number;
|
||||
filePath?: string;
|
||||
}
|
||||
|
||||
type SessionParser = (req: IncomingMessage, params: {}, cb: () => void) => void;
|
||||
|
||||
Reference in New Issue
Block a user