From 0df488667ecab3a70502192706badadf8099da96 Mon Sep 17 00:00:00 2001 From: Elian Doran Date: Sun, 18 Feb 2024 00:45:21 +0200 Subject: [PATCH] server-ts: Port services/search/expressions/attribute_exists --- ...ttribute_exists.js => attribute_exists.ts} | 20 +++++++++++++------ src/services/search/services/parse.js | 2 +- 2 files changed, 15 insertions(+), 7 deletions(-) rename src/services/search/expressions/{attribute_exists.js => attribute_exists.ts} (69%) diff --git a/src/services/search/expressions/attribute_exists.js b/src/services/search/expressions/attribute_exists.ts similarity index 69% rename from src/services/search/expressions/attribute_exists.js rename to src/services/search/expressions/attribute_exists.ts index 6d2e92d64..7a17897bf 100644 --- a/src/services/search/expressions/attribute_exists.js +++ b/src/services/search/expressions/attribute_exists.ts @@ -1,11 +1,19 @@ "use strict"; -const NoteSet = require('../note_set'); -const becca = require('../../../becca/becca'); -const Expression = require('./expression'); +import NoteSet = require("../note_set"); +import SearchContext = require("../search_context"); + +import becca = require('../../../becca/becca'); +import Expression = require('./expression'); class AttributeExistsExp extends Expression { - constructor(attributeType, attributeName, prefixMatch) { + + private attributeType: string; + private attributeName: string; + private isTemplateLabel: boolean; + private prefixMatch: string; + + constructor(attributeType: string, attributeName: string, prefixMatch: string) { super(); this.attributeType = attributeType; @@ -15,7 +23,7 @@ class AttributeExistsExp extends Expression { this.prefixMatch = prefixMatch; } - execute(inputNoteSet, executionContext, searchContext) { + execute(inputNoteSet: NoteSet, executionContext: {}, searchContext: SearchContext) { const attrs = this.prefixMatch ? becca.findAttributesWithPrefix(this.attributeType, this.attributeName) : becca.findAttributes(this.attributeType, this.attributeName); @@ -40,4 +48,4 @@ class AttributeExistsExp extends Expression { } } -module.exports = AttributeExistsExp; +export = AttributeExistsExp; diff --git a/src/services/search/services/parse.js b/src/services/search/services/parse.js index 94b5fdd7e..3f67e8bc8 100644 --- a/src/services/search/services/parse.js +++ b/src/services/search/services/parse.js @@ -9,7 +9,7 @@ const DescendantOfExp = require('../expressions/descendant_of.js'); const ParentOfExp = require('../expressions/parent_of.js'); const RelationWhereExp = require('../expressions/relation_where.js'); const PropertyComparisonExp = require('../expressions/property_comparison.js'); -const AttributeExistsExp = require('../expressions/attribute_exists.js'); +const AttributeExistsExp = require('../expressions/attribute_exists'); const LabelComparisonExp = require('../expressions/label_comparison.js'); const NoteFlatTextExp = require('../expressions/note_flat_text.js'); const NoteContentFulltextExp = require('../expressions/note_content_fulltext.js');