mirror of
				https://github.com/zadam/trilium.git
				synced 2025-10-31 02:16:05 +01:00 
			
		
		
		
	server-ts: Remove unnecessary type comments
This commit is contained in:
		| @@ -125,9 +125,6 @@ class BAttribute extends AbstractBeccaEntity<BAttribute> { | ||||
|         } | ||||
|     } | ||||
|  | ||||
|     /** | ||||
|      * @returns {BNote|null} | ||||
|      */ | ||||
|     getNote() { | ||||
|         const note = this.becca.getNote(this.noteId); | ||||
|  | ||||
| @@ -138,9 +135,6 @@ class BAttribute extends AbstractBeccaEntity<BAttribute> { | ||||
|         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<BAttribute> { | ||||
|         return this.becca.getNote(this.value); | ||||
|     } | ||||
|  | ||||
|     /** | ||||
|      * @returns {boolean} | ||||
|      */ | ||||
|     isDefinition() { | ||||
|         return this.type === 'label' && (this.name.startsWith('label:') || this.name.startsWith('relation:')); | ||||
|     } | ||||
|   | ||||
| @@ -127,8 +127,6 @@ class BBranch extends AbstractBeccaEntity<BBranch> { | ||||
|      * 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); | ||||
|   | ||||
| @@ -167,39 +167,32 @@ class BNote extends AbstractBeccaEntity<BNote> { | ||||
|         return this.isContentAvailable() ? this.title : '[protected]'; | ||||
|     } | ||||
|  | ||||
|     /** @returns {BBranch[]} */ | ||||
|     getParentBranches() { | ||||
|         return this.parentBranches; | ||||
|     } | ||||
|  | ||||
|     /** | ||||
|      * Returns <i>strong</i> (as opposed to <i>weak</i>) 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<BNote> { | ||||
|         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<BNote> { | ||||
|                 || 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<BNote> { | ||||
|         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<BNote> { | ||||
|     } | ||||
|  | ||||
|     /** | ||||
|      * @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<BNote> { | ||||
|      * @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<BNote> { | ||||
|     } | ||||
|  | ||||
|     /** | ||||
|      * @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<BNote> { | ||||
|      * - 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<BNote> { | ||||
|         }; | ||||
|     } | ||||
|  | ||||
|     /** @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<BNote> { | ||||
|         return this.getOwnedAttributes().length; | ||||
|     } | ||||
|  | ||||
|     /** @returns {BNote[]} */ | ||||
|     getAncestors() { | ||||
|         if (!this.__ancestorCache) { | ||||
|             const noteIds = new Set(); | ||||
| @@ -1076,7 +1068,6 @@ class BNote extends AbstractBeccaEntity<BNote> { | ||||
|         return this.noteId === '_hidden' || this.hasAncestor('_hidden'); | ||||
|     } | ||||
|  | ||||
|     /** @returns {BAttribute[]} */ | ||||
|     getTargetRelations() { | ||||
|         return this.targetRelations; | ||||
|     } | ||||
| @@ -1118,7 +1109,6 @@ class BNote extends AbstractBeccaEntity<BNote> { | ||||
|             .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<BNote> { | ||||
|             .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<BNote> { | ||||
|         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<BNote> { | ||||
|     } | ||||
|  | ||||
|     /** | ||||
|      * @param {string} matchBy - choose by which property we detect if to update an existing attachment. | ||||
|      * @param matchBy - choose by which property we detect if to update an existing attachment. | ||||
|  *                      Supported values are either 'attachmentId' (default) or 'title' | ||||
|      * @returns {BAttachment} | ||||
|      */ | ||||
|     saveAttachment({attachmentId, role, mime, title, content, position}: AttachmentRow, matchBy = 'attachmentId') { | ||||
|         if (!['attachmentId', 'title'].includes(matchBy)) { | ||||
|   | ||||
| @@ -122,9 +122,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; | ||||
|      | ||||
|   | ||||
| @@ -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; | ||||
|   | ||||
| @@ -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)) { | ||||
|   | ||||
| @@ -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, | ||||
|   | ||||
| @@ -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); | ||||
|   | ||||
		Reference in New Issue
	
	Block a user