diff --git a/src/services/search/expressions/ancestor.js b/src/services/search/expressions/ancestor.ts similarity index 75% rename from src/services/search/expressions/ancestor.js rename to src/services/search/expressions/ancestor.ts index f48e9e59f..6f169e33a 100644 --- a/src/services/search/expressions/ancestor.js +++ b/src/services/search/expressions/ancestor.ts @@ -1,12 +1,19 @@ "use strict"; -const Expression = require('./expression'); -const NoteSet = require('../note_set'); -const log = require('../../log'); -const becca = require('../../../becca/becca'); +import Expression = require('./expression'); +import NoteSet = require('../note_set'); +import log = require('../../log'); +import becca = require('../../../becca/becca'); +import SearchContext = require('../search_context'); class AncestorExp extends Expression { - constructor(ancestorNoteId, ancestorDepth) { + + private ancestorNoteId: string; + private ancestorDepthComparator; + + ancestorDepth: string; + + constructor(ancestorNoteId: string, ancestorDepth: string) { super(); this.ancestorNoteId = ancestorNoteId; @@ -14,7 +21,7 @@ class AncestorExp extends Expression { this.ancestorDepthComparator = this.getComparator(ancestorDepth); } - execute(inputNoteSet, executionContext, searchContext) { + execute(inputNoteSet: NoteSet, executionContext: {}, searchContext: SearchContext) { const ancestorNote = becca.notes[this.ancestorNoteId]; if (!ancestorNote) { @@ -44,7 +51,7 @@ class AncestorExp extends Expression { return depthConformingNoteSet; } - getComparator(depthCondition) { + getComparator(depthCondition: string): ((depth: number) => boolean) | null { if (!depthCondition) { return null; } diff --git a/src/services/search/expressions/expression.ts b/src/services/search/expressions/expression.ts index a83c139f2..c74341ba2 100644 --- a/src/services/search/expressions/expression.ts +++ b/src/services/search/expressions/expression.ts @@ -10,12 +10,6 @@ abstract class Expression { this.name = this.constructor.name; // for DEBUG mode to have expression name as part of dumped JSON } - /** - * @param {NoteSet} inputNoteSet - * @param {object} executionContext - * @param {SearchContext} searchContext - * @returns {NoteSet} - */ abstract execute(inputNoteSet: NoteSet, executionContext: {}, searchContext: SearchContext): NoteSet; } diff --git a/src/services/search/services/parse.js b/src/services/search/services/parse.js index 6b2e8fa84..17f0844ca 100644 --- a/src/services/search/services/parse.js +++ b/src/services/search/services/parse.js @@ -14,7 +14,7 @@ const LabelComparisonExp = require('../expressions/label_comparison.js'); const NoteFlatTextExp = require('../expressions/note_flat_text.js'); const NoteContentFulltextExp = require('../expressions/note_content_fulltext.js'); const OrderByAndLimitExp = require('../expressions/order_by_and_limit.js'); -const AncestorExp = require('../expressions/ancestor.js'); +const AncestorExp = require('../expressions/ancestor'); const buildComparator = require('./build_comparator.js'); const ValueExtractor = require('../value_extractor'); const utils = require('../../utils');