From 1e91db865bfbd8da0de6789c858b17ad2b243d76 Mon Sep 17 00:00:00 2001 From: Elian Doran Date: Sat, 17 Feb 2024 18:55:41 +0200 Subject: [PATCH] server-ts: Implement review comments --- src/becca/becca-interface.ts | 4 ++-- src/services/backend_script_api.js | 2 +- src/services/encryption/data_encryption.ts | 2 +- src/services/search/note_set.ts | 5 +++-- src/services/sql.ts | 4 ++-- 5 files changed, 9 insertions(+), 8 deletions(-) diff --git a/src/becca/becca-interface.ts b/src/becca/becca-interface.ts index a18dc9432..4c8218797 100644 --- a/src/becca/becca-interface.ts +++ b/src/becca/becca-interface.ts @@ -68,7 +68,7 @@ class Becca { } findAttributesWithPrefix(type: string, name: string): BAttribute[] { - const resArr = []; + const resArr: BAttribute[][] = []; const key = `${type}-${name}`; for (const idx in this.attributeIndex) { @@ -105,7 +105,7 @@ class Becca { } getNotes(noteIds: string[], ignoreMissing: boolean = false): BNote[] { - const filteredNotes = []; + const filteredNotes: BNote[] = []; for (const noteId of noteIds) { const note = this.notes[noteId]; diff --git a/src/services/backend_script_api.js b/src/services/backend_script_api.js index 40e898659..fc8e80aef 100644 --- a/src/services/backend_script_api.js +++ b/src/services/backend_script_api.js @@ -678,7 +678,7 @@ function BackendScriptApi(currentNote, apiParams) { /** * This object contains "at your risk" and "no BC guarantees" objects for advanced use cases. * - * @property {Becca} becca - provides access to the backend in-memory object graph, see {@link https://github.com/zadam/trilium/blob/master/src/becca/becca} + * @property {Becca} becca - provides access to the backend in-memory object graph, see {@link https://github.com/zadam/trilium/blob/master/src/becca/becca.js} */ this.__private = { becca diff --git a/src/services/encryption/data_encryption.ts b/src/services/encryption/data_encryption.ts index c19008a5b..b82a0e8c6 100644 --- a/src/services/encryption/data_encryption.ts +++ b/src/services/encryption/data_encryption.ts @@ -3,7 +3,7 @@ import crypto = require('crypto'); import log = require('../log'); -function arraysIdentical(a: Buffer, b: Buffer) { +function arraysIdentical(a: any[] | Buffer, b: any[] | Buffer) { let i = a.length; if (i !== b.length) return false; while (i--) { diff --git a/src/services/search/note_set.ts b/src/services/search/note_set.ts index d53d00e4d..47c644c38 100644 --- a/src/services/search/note_set.ts +++ b/src/services/search/note_set.ts @@ -4,9 +4,10 @@ import BNote = require("../../becca/entities/bnote"); class NoteSet { - private notes: BNote[]; private noteIdSet: Set; - private sorted: boolean; + + notes: BNote[]; + sorted: boolean; constructor(notes: BNote[] = []) { this.notes = notes; diff --git a/src/services/sql.ts b/src/services/sql.ts index ffc15a99d..f0a9d7d29 100644 --- a/src/services/sql.ts +++ b/src/services/sql.ts @@ -157,10 +157,10 @@ function iterateRows(query: string, params: Params = []) { function getMap(query: string, params: Params = []) { const map: Record = {} as Record; - const results = getRawRows(query, params); + const results = getRawRows<[K, V]>(query, params); for (const row of results || []) { - map[row[0] as K] = row[1]; + map[row[0]] = row[1]; } return map;