Merge pull request #47 from TriliumNext/feature/typescript_backend_10

Convert backend to TypeScript (84% -> 89%)
This commit is contained in:
Elian Doran
2024-04-20 09:36:08 +03:00
committed by GitHub
25 changed files with 458 additions and 415 deletions

View File

@@ -127,8 +127,8 @@ interface Api {
/**
* Retrieves notes with given label name & value
*
* @param name - attribute name
* @param value - attribute value
* @param name - attribute name
* @param value - attribute value
*/
getNotesWithLabel(name: string, value?: string): BNote[];

View File

@@ -68,7 +68,7 @@ class ConsistencyChecks {
childToParents[childNoteId].push(parentNoteId);
}
/** @returns {boolean} true if cycle was found and we should try again */
/** @returns true if cycle was found and we should try again */
const checkTreeCycle = (noteId: string, path: string[]) => {
if (noteId === 'root') {
return false;

View File

@@ -17,8 +17,7 @@ type EventListener = (data: any) => void;
const eventListeners: Record<string, EventListener[]> = {};
/**
* @param {string|string[]}eventTypes - can be either single event or an array of events
* @param listener
* @param eventTypes - can be either single event or an array of events
*/
function subscribe(eventTypes: EventType, listener: EventListener) {
if (!Array.isArray(eventTypes)) {

View File

@@ -323,9 +323,9 @@ export = {
* Get single value from the given query - first column from first returned row.
*
* @method
* @param {string} query - SQL query with ? used as parameter placeholder
* @param {object[]} [params] - array of params if needed
* @returns [object] - single value
* @param query - SQL query with ? used as parameter placeholder
* @param params - array of params if needed
* @returns single value
*/
getValue,
@@ -333,9 +333,9 @@ export = {
* Get first returned row.
*
* @method
* @param {string} query - SQL query with ? used as parameter placeholder
* @param {object[]} [params] - array of params if needed
* @returns {object} - map of column name to column value
* @param query - SQL query with ? used as parameter placeholder
* @param params - array of params if needed
* @returns - map of column name to column value
*/
getRow,
getRowOrNull,
@@ -344,9 +344,9 @@ export = {
* Get all returned rows.
*
* @method
* @param {string} query - SQL query with ? used as parameter placeholder
* @param {object[]} [params] - array of params if needed
* @returns {object[]} - array of all rows, each row is a map of column name to column value
* @param query - SQL query with ? used as parameter placeholder
* @param params - array of params if needed
* @returns - array of all rows, each row is a map of column name to column value
*/
getRows,
getRawRows,
@@ -357,9 +357,9 @@ export = {
* Get a map of first column mapping to second column.
*
* @method
* @param {string} query - SQL query with ? used as parameter placeholder
* @param {object[]} [params] - array of params if needed
* @returns {object} - map of first column to second column
* @param query - SQL query with ? used as parameter placeholder
* @param params - array of params if needed
* @returns - map of first column to second column
*/
getMap,
@@ -367,9 +367,9 @@ export = {
* Get a first column in an array.
*
* @method
* @param {string} query - SQL query with ? used as parameter placeholder
* @param {object[]} [params] - array of params if needed
* @returns {object[]} - array of first column of all returned rows
* @param query - SQL query with ? used as parameter placeholder
* @param params - array of params if needed
* @returns array of first column of all returned rows
*/
getColumn,
@@ -377,8 +377,8 @@ export = {
* Execute SQL
*
* @method
* @param {string} query - SQL query with ? used as parameter placeholder
* @param {object[]} [params] - array of params if needed
* @param query - SQL query with ? used as parameter placeholder
* @param params - array of params if needed
*/
execute,
executeMany,

View File

@@ -156,9 +156,9 @@ const STRING_MIME_TYPES = [
"image/svg+xml"
];
function isStringNote(type: string, mime: string) {
function isStringNote(type: string | null, mime: string) {
// render and book are string note in the sense that they are expected to contain empty string
return ["text", "code", "relationMap", "search", "render", "book", "mermaid", "canvas"].includes(type)
return (type && ["text", "code", "relationMap", "search", "render", "book", "mermaid", "canvas"].includes(type))
|| mime.startsWith('text/')
|| STRING_MIME_TYPES.includes(mime);
}