diff --git a/src/becca/entities/battribute.ts b/src/becca/entities/battribute.ts index ebd9e74cf..6ad1965ed 100644 --- a/src/becca/entities/battribute.ts +++ b/src/becca/entities/battribute.ts @@ -125,9 +125,6 @@ class BAttribute extends AbstractBeccaEntity { } } - /** - * @returns {BNote|null} - */ getNote() { const note = this.becca.getNote(this.noteId); @@ -138,9 +135,6 @@ class BAttribute extends AbstractBeccaEntity { return note; } - /** - * @returns {BNote|null} - */ getTargetNote() { if (this.type !== 'relation') { throw new Error(`Attribute '${this.attributeId}' is not a relation.`); @@ -153,9 +147,6 @@ class BAttribute extends AbstractBeccaEntity { return this.becca.getNote(this.value); } - /** - * @returns {boolean} - */ isDefinition() { return this.type === 'label' && (this.name.startsWith('label:') || this.name.startsWith('relation:')); } diff --git a/src/becca/entities/bbranch.ts b/src/becca/entities/bbranch.ts index 2b6dc8657..0f904de92 100644 --- a/src/becca/entities/bbranch.ts +++ b/src/becca/entities/bbranch.ts @@ -127,8 +127,6 @@ class BBranch extends AbstractBeccaEntity { * An example is shared or bookmarked clones - they are created automatically and exist for technical reasons, * not as user-intended actions. From user perspective, they don't count as real clones and for the purpose * of deletion should not act as a clone. - * - * @returns {boolean} */ get isWeak() { return ['_share', '_lbBookmarks'].includes(this.parentNoteId); diff --git a/src/becca/entities/bnote.ts b/src/becca/entities/bnote.ts index 1b681d546..a007f5278 100644 --- a/src/becca/entities/bnote.ts +++ b/src/becca/entities/bnote.ts @@ -167,39 +167,32 @@ class BNote extends AbstractBeccaEntity { return this.isContentAvailable() ? this.title : '[protected]'; } - /** @returns {BBranch[]} */ getParentBranches() { return this.parentBranches; } /** * Returns strong (as opposed to weak) parent branches. See isWeak for details. - * - * @returns {BBranch[]} */ getStrongParentBranches() { return this.getParentBranches().filter(branch => !branch.isWeak); } /** - * @returns {BBranch[]} * @deprecated use getParentBranches() instead */ getBranches() { return this.parentBranches; } - /** @returns {BNote[]} */ getParentNotes() { return this.parents; } - /** @returns {BNote[]} */ getChildNotes() { return this.children; } - /** @returns {boolean} */ hasChildren() { return this.children && this.children.length > 0; } @@ -270,17 +263,17 @@ class BNote extends AbstractBeccaEntity { return this.utcDateModified === null ? null : dayjs.utc(this.utcDateModified); } - /** @returns {boolean} true if this note is the root of the note tree. Root note has "root" noteId */ + /** @returns true if this note is the root of the note tree. Root note has "root" noteId */ isRoot() { return this.noteId === 'root'; } - /** @returns {boolean} true if this note is of application/json content type */ + /** @returns true if this note is of application/json content type */ isJson() { return this.mime === "application/json"; } - /** @returns {boolean} true if this note is JavaScript (code or attachment) */ + /** @returns true if this note is JavaScript (code or attachment) */ isJavaScript() { return (this.type === "code" || this.type === "file" || this.type === 'launcher') && (this.mime.startsWith("application/javascript") @@ -288,13 +281,13 @@ class BNote extends AbstractBeccaEntity { || this.mime === "text/javascript"); } - /** @returns {boolean} true if this note is HTML */ + /** @returns true if this note is HTML */ isHtml() { return ["code", "file", "render"].includes(this.type) && this.mime === "text/html"; } - /** @returns {boolean} true if this note is an image */ + /** @returns true if this note is an image */ isImage() { return this.type === 'image' || (this.type === 'file' && this.mime?.startsWith('image/')); @@ -305,12 +298,12 @@ class BNote extends AbstractBeccaEntity { return this.hasStringContent(); } - /** @returns {boolean} true if the note has string content (not binary) */ + /** @returns true if the note has string content (not binary) */ hasStringContent() { return utils.isStringNote(this.type, this.mime); } - /** @returns {string|null} JS script environment - either "frontend" or "backend" */ + /** @returns JS script environment - either "frontend" or "backend" */ getScriptEnv() { if (this.isHtml() || (this.isJavaScript() && this.mime.endsWith('env=frontend'))) { return "frontend"; @@ -519,8 +512,8 @@ class BNote extends AbstractBeccaEntity { } /** - * @param {string} name - label name - * @returns {BAttribute|null} label if it exists, null otherwise + * @param name - label name + * @returns label if it exists, null otherwise */ getLabel(name: string): BAttribute | null { return this.getAttribute(LABEL, name); @@ -681,7 +674,7 @@ class BNote extends AbstractBeccaEntity { * @param type - (optional) attribute type to filter * @param name - (optional) attribute name to filter * @param value - (optional) attribute value to filter - * @returns {BAttribute[]} note's "owned" attributes - excluding inherited ones + * @returns note's "owned" attributes - excluding inherited ones */ getOwnedAttributes(type: string | null = null, name: string | null = null, value: string | null = null) { this.__validateTypeName(type, name); @@ -704,7 +697,7 @@ class BNote extends AbstractBeccaEntity { } /** - * @returns {BAttribute} attribute belonging to this specific note (excludes inherited attributes) + * @returns attribute belonging to this specific note (excludes inherited attributes) * * This method can be significantly faster than the getAttribute() */ @@ -781,7 +774,7 @@ class BNote extends AbstractBeccaEntity { * - fast searching * - note similarity evaluation * - * @returns {string} - returns flattened textual representation of note, prefixes and attributes + * @returns - returns flattened textual representation of note, prefixes and attributes */ getFlatText() { if (!this.__flatTextCache) { @@ -972,7 +965,7 @@ class BNote extends AbstractBeccaEntity { }; } - /** @returns {string[]} - includes the subtree root note as well */ + /** @returns includes the subtree root note as well */ getSubtreeNoteIds({includeArchived = true, includeHidden = false, resolveSearch = false} = {}) { return this.getSubtree({includeArchived, includeHidden, resolveSearch}) .notes @@ -1032,7 +1025,6 @@ class BNote extends AbstractBeccaEntity { return this.getOwnedAttributes().length; } - /** @returns {BNote[]} */ getAncestors() { if (!this.__ancestorCache) { const noteIds = new Set(); @@ -1076,7 +1068,6 @@ class BNote extends AbstractBeccaEntity { return this.noteId === '_hidden' || this.hasAncestor('_hidden'); } - /** @returns {BAttribute[]} */ getTargetRelations() { return this.targetRelations; } @@ -1118,7 +1109,6 @@ class BNote extends AbstractBeccaEntity { .map(row => new BRevision(row)); } - /** @returns {BAttachment[]} */ getAttachments(opts: AttachmentOpts = {}) { opts.includeContentLength = !!opts.includeContentLength; // from testing, it looks like calculating length does not make a difference in performance even on large-ish DB @@ -1136,7 +1126,6 @@ class BNote extends AbstractBeccaEntity { .map(row => new BAttachment(row)); } - /** @returns {BAttachment|null} */ getAttachmentById(attachmentId: string, opts: AttachmentOpts = {}) { opts.includeContentLength = !!opts.includeContentLength; @@ -1583,10 +1572,7 @@ class BNote extends AbstractBeccaEntity { return !(this.noteId in this.becca.notes) || this.isBeingDeleted; } - /** - * @returns {BRevision|null} - */ - saveRevision() { + saveRevision(): BRevision { return sql.transactional(() => { let noteContent = this.getContent(); @@ -1633,9 +1619,8 @@ class BNote extends AbstractBeccaEntity { } /** - * @param {string} matchBy - choose by which property we detect if to update an existing attachment. - * Supported values are either 'attachmentId' (default) or 'title' - * @returns {BAttachment} + * @param matchBy - choose by which property we detect if to update an existing attachment. + * Supported values are either 'attachmentId' (default) or 'title' */ saveAttachment({attachmentId, role, mime, title, content, position}: AttachmentRow, matchBy = 'attachmentId') { if (!['attachmentId', 'title'].includes(matchBy)) { diff --git a/src/services/backend_script_api.ts b/src/services/backend_script_api.ts index 34767ae75..4a6e89d83 100644 --- a/src/services/backend_script_api.ts +++ b/src/services/backend_script_api.ts @@ -122,17 +122,14 @@ 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; /** * 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[]; diff --git a/src/services/consistency_checks.ts b/src/services/consistency_checks.ts index 36fdeef78..b4f615f53 100644 --- a/src/services/consistency_checks.ts +++ b/src/services/consistency_checks.ts @@ -69,7 +69,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; diff --git a/src/services/events.ts b/src/services/events.ts index 327443a95..0eda326b9 100644 --- a/src/services/events.ts +++ b/src/services/events.ts @@ -17,8 +17,7 @@ type EventListener = (data: any) => void; const eventListeners: Record = {}; /** - * @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)) { diff --git a/src/services/sql.ts b/src/services/sql.ts index 18d72912f..cb4a75df5 100644 --- a/src/services/sql.ts +++ b/src/services/sql.ts @@ -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, diff --git a/src/share/shaca/entities/snote.ts b/src/share/shaca/entities/snote.ts index 89b6562b4..37e0fb477 100644 --- a/src/share/shaca/entities/snote.ts +++ b/src/share/shaca/entities/snote.ts @@ -69,35 +69,29 @@ class SNote extends AbstractShacaEntity { return this.children.map(childNote => this.shaca.getBranchFromChildAndParent(childNote.noteId, this.noteId)); } - /** @returns {SBranch[]} */ getVisibleChildBranches() { return this.getChildBranches() .filter(branch => !branch.isHidden && !branch.getNote().isLabelTruthy('shareHiddenFromTree')); } - /** @returns {SNote[]} */ getParentNotes() { return this.parents; } - /** @returns {SNote[]} */ getChildNotes() { return this.children; } - /** @returns {SNote[]} */ getVisibleChildNotes() { return this.getVisibleChildBranches() .map(branch => branch.getNote()); } - /** @returns {boolean} */ hasChildren() { return this.children && this.children.length > 0; } - /** @returns {boolean} */ hasVisibleChildren() { return this.getVisibleChildNotes().length > 0; } @@ -250,7 +244,6 @@ class SNote extends AbstractShacaEntity { return !!this.getAttributes().find(attr => attr.type === type && attr.name === name); } - /** @returns {SNote|null} */ getRelationTarget(name: string) { const relation = this.getAttributes().find(attr => attr.type === 'relation' && attr.name === name); @@ -265,7 +258,7 @@ class SNote extends AbstractShacaEntity { /** * @param name - label name - * @returns {boolean} true if label exists (including inherited) and does not have "false" value. + * @returns true if label exists (including inherited) and does not have "false" value. */ isLabelTruthy(name: string) { const label = this.getLabel(name); @@ -321,25 +314,25 @@ class SNote extends AbstractShacaEntity { /** * @param name - label name - * @returns {string|null} label value if label exists, null otherwise + * @returns label value if label exists, null otherwise */ getLabelValue(name: string) { return this.getAttributeValue(LABEL, name); } /** * @param name - label name - * @returns {string|null} label value if label exists, null otherwise + * @returns label value if label exists, null otherwise */ getOwnedLabelValue(name: string) { return this.getOwnedAttributeValue(LABEL, name); } /** * @param name - relation name - * @returns {string|null} relation value if relation exists, null otherwise + * @returns relation value if relation exists, null otherwise */ getRelationValue(name: string) { return this.getAttributeValue(RELATION, name); } /** * @param name - relation name - * @returns {string|null} relation value if relation exists, null otherwise + * @returns relation value if relation exists, null otherwise */ getOwnedRelationValue(name: string) { return this.getOwnedAttributeValue(RELATION, name); } @@ -367,7 +360,7 @@ class SNote extends AbstractShacaEntity { /** * @param type - attribute type (label, relation, etc.) * @param name - attribute name - * @returns {string|null} attribute value of the given type and name or null if no such attribute exists. + * @returns attribute value of the given type and name or null if no such attribute exists. */ getAttributeValue(type: string, name: string) { const attr = this.getAttribute(type, name); @@ -412,7 +405,7 @@ class SNote extends AbstractShacaEntity { /** * @param name - label name to filter - * @returns {string[]} all note's label values, excluding inherited ones + * @returns all note's label values, excluding inherited ones */ getOwnedLabelValues(name: string) { return this.getOwnedAttributes(LABEL, name).map(l => l.value);