Skip to content

Build your personal knowledge base with Trilium Notes

chore(test): fix typing errors in parser

Elian Doranf026706e2535
diff --git a/spec/search/parser.spec.ts b/spec/search/parser.spec.ts
index 7774a8d1e3..09c7ce06b7 100644
--- a/spec/search/parser.spec.ts
+++ b/spec/search/parser.spec.ts
@@ -1,49 +1,28 @@
-// @ts-nocheck
-// There are many issues with the types of the parser e.g. "parse" function returns "Expression"
-// but we access properties like "subExpressions" which is not defined in the "Expression" class.
-
+import AndExp from "../../src/services/search/expressions/and.js";
+import AttributeExistsExp from "../../src/services/search/expressions/attribute_exists.js";
import Expression from "../../src/services/search/expressions/expression.js";
+import LabelComparisonExp from "../../src/services/search/expressions/label_comparison.js";
+import NotExp from "../../src/services/search/expressions/not.js";
+import NoteContentFulltextExp from "../../src/services/search/expressions/note_content_fulltext.js";
+import NoteFlatTextExp from "../../src/services/search/expressions/note_flat_text.js";
+import OrExp from "../../src/services/search/expressions/or.js";
import OrderByAndLimitExp from "../../src/services/search/expressions/order_by_and_limit.js";
+import PropertyComparisonExp from "../../src/services/search/expressions/property_comparison.js";
import SearchContext from "../../src/services/search/search_context.js";
-import parse from "../../src/services/search/services/parse.js";
-
-function tokens(toks: Array<string>, cur = 0): Array<any> {
- return toks.map((arg) => {
- if (Array.isArray(arg)) {
- return tokens(arg, cur);
- } else {
- cur += arg.length;
-
- return {
- token: arg,
- inQuotes: false,
- startIndex: cur - arg.length,
- endIndex: cur - 1
- };
- }
- });
-}
-
-function assertIsArchived(exp: Expression) {
- expect(exp.constructor.name).toEqual("PropertyComparisonExp");
- expect(exp.propertyName).toEqual("isArchived");
- expect(exp.operator).toEqual("=");
- expect(exp.comparedValue).toEqual("false");
-}
+import { default as parseInternal, type ParseOpts } from "../../src/services/search/services/parse.js";
describe("Parser", () => {
it("fulltext parser without content", () => {
const rootExp = parse({
fulltextTokens: tokens(["hello", "hi"]),
expressionTokens: [],
- searchContext: new SearchContext({ excludeArchived: true })
- });
+ searchContext: new SearchContext()
+ }, AndExp);
- expect(rootExp.constructor.name).toEqual("AndExp");
- expect(rootExp.subExpressions[0].constructor.name).toEqual("PropertyComparisonExp");
- expect(rootExp.subExpressions[2].constructor.name).toEqual("OrExp");
- expect(rootExp.subExpressions[2].subExpressions[0].constructor.name).toEqual("NoteFlatTextExp");
- expect(rootExp.subExpressions[2].subExpressions[0].tokens).toEqual(["hello", "hi"]);
+ expectExpression(rootExp.subExpressions[0], PropertyComparisonExp);
+ const orExp = expectExpression(rootExp.subExpressions[2], OrExp);
+ const flatTextExp = expectExpression(orExp.subExpressions[0], NoteFlatTextExp);
+ expect(flatTextExp.tokens).toEqual(["hello", "hi"]);
});
it("fulltext parser with content", () => {
@@ -51,20 +30,17 @@ describe("Parser", () => {
fulltextTokens: tokens(["hello", "hi"]),
expressionTokens: [],
searchContext: new SearchContext()
- });
+ }, AndExp);
- expect(rootExp.constructor.name).toEqual("AndExp");
assertIsArchived(rootExp.subExpressions[0]);
- expect(rootExp.subExpressions[2].constructor.name).toEqual("OrExp");
-
- const subs = rootExp.subExpressions[2].subExpressions;
+ const orExp = expectExpression(rootExp.subExpressions[2], OrExp);
- expect(subs[0].constructor.name).toEqual("NoteFlatTextExp");
- expect(subs[0].tokens).toEqual(["hello", "hi"]);
+ const firstSub = expectExpression(orExp.subExpressions[0], NoteFlatTextExp);
+ expect(firstSub.tokens).toEqual(["hello", "hi"]);
- expect(subs[1].constructor.name).toEqual("NoteContentFulltextExp");
- expect(subs[1].tokens).toEqual(["hello", "hi"]);
+ const secondSub = expectExpression(orExp.subExpressions[1], NoteContentFulltextExp);
+ expect(secondSub.tokens).toEqual(["hello", "hi"]);
});
it("simple label comparison", () => {
@@ -72,14 +48,13 @@ describe("Parser", () => {
fulltextTokens: [],
expressionTokens: tokens(["#mylabel", "=", "text"]),
searchContext: new SearchContext()
- });
+ }, AndExp);
- expect(rootExp.constructor.name).toEqual("AndExp");
assertIsArchived(rootExp.subExpressions[0]);
- expect(rootExp.subExpressions[2].constructor.name).toEqual("LabelComparisonExp");
- expect(rootExp.subExpressions[2].attributeType).toEqual("label");
- expect(rootExp.subExpressions[2].attributeName).toEqual("mylabel");
- expect(rootExp.subExpressions[2].comparator).toBeTruthy();
+ const labelComparisonExp = expectExpression(rootExp.subExpressions[2], LabelComparisonExp);
+ expect(labelComparisonExp.attributeType).toEqual("label");
+ expect(labelComparisonExp.attributeName).toEqual("mylabel");
+ expect(labelComparisonExp.comparator).toBeTruthy();
});
it("simple attribute negation", () => {
@@ -87,46 +62,40 @@ describe("Parser", () => {
fulltextTokens: [],
expressionTokens: tokens(["#!mylabel"]),
searchContext: new SearchContext()
- });
+ }, AndExp);
- expect(rootExp.constructor.name).toEqual("AndExp");
assertIsArchived(rootExp.subExpressions[0]);
- expect(rootExp.subExpressions[2].constructor.name).toEqual("NotExp");
- expect(rootExp.subExpressions[2].subExpression.constructor.name).toEqual("AttributeExistsExp");
- expect(rootExp.subExpressions[2].subExpression.attributeType).toEqual("label");
- expect(rootExp.subExpressions[2].subExpression.attributeName).toEqual("mylabel");
+ let notExp = expectExpression(rootExp.subExpressions[2], NotExp);
+ let attributeExistsExp = expectExpression(notExp.subExpression, AttributeExistsExp);
+ expect(attributeExistsExp.attributeType).toEqual("label");
+ expect(attributeExistsExp.attributeName).toEqual("mylabel");
rootExp = parse({
fulltextTokens: [],
expressionTokens: tokens(["~!myrelation"]),
searchContext: new SearchContext()
- });
+ }, AndExp);
- expect(rootExp.constructor.name).toEqual("AndExp");
assertIsArchived(rootExp.subExpressions[0]);
- expect(rootExp.subExpressions[2].constructor.name).toEqual("NotExp");
- expect(rootExp.subExpressions[2].subExpression.constructor.name).toEqual("AttributeExistsExp");
- expect(rootExp.subExpressions[2].subExpression.attributeType).toEqual("relation");
- expect(rootExp.subExpressions[2].subExpression.attributeName).toEqual("myrelation");
+ notExp = expectExpression(rootExp.subExpressions[2], NotExp);
+ attributeExistsExp = expectExpression(notExp.subExpression, AttributeExistsExp);
+ expect(attributeExistsExp.attributeType).toEqual("relation");
+ expect(attributeExistsExp.attributeName).toEqual("myrelation");
});
it("simple label AND", () => {
const rootExp = parse({
fulltextTokens: [],
expressionTokens: tokens(["#first", "=", "text", "and", "#second", "=", "text"]),
- searchContext: new SearchContext(true)
- });
+ searchContext: new SearchContext()
+ }, AndExp);
- expect(rootExp.constructor.name).toEqual("AndExp");
assertIsArchived(rootExp.subExpressions[0]);
- expect(rootExp.subExpressions[2].constructor.name).toEqual("AndExp");
- const [firstSub, secondSub] = rootExp.subExpressions[2].subExpressions;
+ const andExp = expectExpression(rootExp.subExpressions[2], AndExp);
+ const [firstSub, secondSub] = expectSubexpressions(andExp, LabelComparisonExp, LabelComparisonExp);
- expect(firstSub.constructor.name).toEqual("LabelComparisonExp");
expect(firstSub.attributeName).toEqual("first");
-
- expect(secondSub.constructor.name).toEqual("LabelComparisonExp");
expect(secondSub.attributeName).toEqual("second");
});
@@ -135,18 +104,14 @@ describe("Parser", () => {
fulltextTokens: [],
expressionTokens: tokens(["#first", "=", "text", "#second", "=", "text"]),
searchContext: new SearchContext()
- });
+ }, AndExp);
- expect(rootExp.constructor.name).toEqual("AndExp");
assertIsArchived(rootExp.subExpressions[0]);
- expect(rootExp.subExpressions[2].constructor.name).toEqual("AndExp");
- const [firstSub, secondSub] = rootExp.subExpressions[2].subExpressions;
+ const andExp = expectExpression(rootExp.subExpressions[2], AndExp);
+ const [firstSub, secondSub] = expectSubexpressions(andExp, LabelComparisonExp, LabelComparisonExp);
- expect(firstSub.constructor.name).toEqual("LabelComparisonExp");
expect(firstSub.attributeName).toEqual("first");
-
- expect(secondSub.constructor.name).toEqual("LabelComparisonExp");
expect(secondSub.attributeName).toEqual("second");
});
@@ -155,18 +120,13 @@ describe("Parser", () => {
fulltextTokens: [],
expressionTokens: tokens(["#first", "=", "text", "or", "#second", "=", "text"]),
searchContext: new SearchContext()
- });
+ }, AndExp);
- expect(rootExp.constructor.name).toEqual("AndExp");
assertIsArchived(rootExp.subExpressions[0]);
- expect(rootExp.subExpressions[2].constructor.name).toEqual("OrExp");
- const [firstSub, secondSub] = rootExp.subExpressions[2].subExpressions;
-
- expect(firstSub.constructor.name).toEqual("LabelComparisonExp");
+ const orExp = expectExpression(rootExp.subExpressions[2], OrExp);
+ const [firstSub, secondSub] = expectSubexpressions(orExp, LabelComparisonExp, LabelComparisonExp);
expect(firstSub.attributeName).toEqual("first");
-
- expect(secondSub.constructor.name).toEqual("LabelComparisonExp");
expect(secondSub.attributeName).toEqual("second");
});
@@ -174,20 +134,16 @@ describe("Parser", () => {
const rootExp = parse({
fulltextTokens: tokens(["hello"]),
expressionTokens: tokens(["#mylabel", "=", "text"]),
- searchContext: new SearchContext({ excludeArchived: true })
- });
+ searchContext: new SearchContext()
+ }, AndExp);
- expect(rootExp.constructor.name).toEqual("AndExp");
- const [firstSub, secondSub, thirdSub, fourth] = rootExp.subExpressions;
+ const [firstSub, _, thirdSub, fourth] = expectSubexpressions(rootExp, PropertyComparisonExp, undefined, OrExp, LabelComparisonExp);
- expect(firstSub.constructor.name).toEqual("PropertyComparisonExp");
expect(firstSub.propertyName).toEqual("isArchived");
- expect(thirdSub.constructor.name).toEqual("OrExp");
- expect(thirdSub.subExpressions[0].constructor.name).toEqual("NoteFlatTextExp");
- expect(thirdSub.subExpressions[0].tokens).toEqual(["hello"]);
+ const noteFlatTextExp = expectExpression(thirdSub.subExpressions[0], NoteFlatTextExp);
+ expect(noteFlatTextExp.tokens).toEqual(["hello"]);
- expect(fourth.constructor.name).toEqual("LabelComparisonExp");
expect(fourth.attributeName).toEqual("mylabel");
});
@@ -196,24 +152,17 @@ describe("Parser", () => {
fulltextTokens: [],
expressionTokens: tokens(["#first", "=", "text", "or", ["#second", "=", "text", "and", "#third", "=", "text"]]),
searchContext: new SearchContext()
- });
+ }, AndExp);
- expect(rootExp.constructor.name).toEqual("AndExp");
assertIsArchived(rootExp.subExpressions[0]);
- expect(rootExp.subExpressions[2].constructor.name).toEqual("OrExp");
- const [firstSub, secondSub] = rootExp.subExpressions[2].subExpressions;
+ const orExp = expectExpression(rootExp.subExpressions[2], OrExp);
+ const [firstSub, secondSub] = expectSubexpressions(orExp, LabelComparisonExp, AndExp);
- expect(firstSub.constructor.name).toEqual("LabelComparisonExp");
expect(firstSub.attributeName).toEqual("first");
- expect(secondSub.constructor.name).toEqual("AndExp");
- const [firstSubSub, secondSubSub] = secondSub.subExpressions;
-
- expect(firstSubSub.constructor.name).toEqual("LabelComparisonExp");
+ const [firstSubSub, secondSubSub] = expectSubexpressions(secondSub, LabelComparisonExp, LabelComparisonExp);
expect(firstSubSub.attributeName).toEqual("second");
-
- expect(secondSubSub.constructor.name).toEqual("LabelComparisonExp");
expect(secondSubSub.attributeName).toEqual("third");
});
@@ -222,27 +171,19 @@ describe("Parser", () => {
fulltextTokens: [],
expressionTokens: tokens(["#first", ["#second", "or", "#third"], "#fourth"]),
searchContext: new SearchContext()
- });
+ }, AndExp);
- expect(rootExp.constructor.name).toEqual("AndExp");
assertIsArchived(rootExp.subExpressions[0]);
- expect(rootExp.subExpressions[2].constructor.name).toEqual("AndExp");
- const [firstSub, secondSub, thirdSub] = rootExp.subExpressions[2].subExpressions;
+ const andExp = expectExpression(rootExp.subExpressions[2], AndExp);
+ const [firstSub, secondSub, thirdSub] = expectSubexpressions(andExp, AttributeExistsExp, OrExp, AttributeExistsExp);
- expect(firstSub.constructor.name).toEqual("AttributeExistsExp");
expect(firstSub.attributeName).toEqual("first");
- expect(secondSub.constructor.name).toEqual("OrExp");
- const [firstSubSub, secondSubSub] = secondSub.subExpressions;
-
- expect(firstSubSub.constructor.name).toEqual("AttributeExistsExp");
+ const [firstSubSub, secondSubSub] = expectSubexpressions(secondSub, AttributeExistsExp, AttributeExistsExp);
expect(firstSubSub.attributeName).toEqual("second");
-
- expect(secondSubSub.constructor.name).toEqual("AttributeExistsExp");
expect(secondSubSub.attributeName).toEqual("third");
- expect(thirdSub.constructor.name).toEqual("AttributeExistsExp");
expect(thirdSub.attributeName).toEqual("fourth");
});
@@ -250,13 +191,9 @@ describe("Parser", () => {
const rootExp = parse({
fulltextTokens: tokens(["hello", "hi"]),
expressionTokens: [],
- searchContext: new SearchContext({
- excludeArchived: true,
- limit: 2
- })
- });
+ searchContext: new SearchContext({ limit: 2 })
+ }, OrderByAndLimitExp);
- expect(rootExp).toBeInstanceOf(OrderByAndLimitExp);
expect(rootExp.limit).toBe(2);
expect(rootExp.subExpression).toBeInstanceOf(AndExp);
});
@@ -266,7 +203,7 @@ describe("Invalid expressions", () => {
it("incomplete comparison", () => {
const searchContext = new SearchContext();
- parse({
+ parseInternal({
fulltextTokens: [],
expressionTokens: tokens(["#first", "="]),
searchContext
@@ -279,7 +216,7 @@ describe("Invalid expressions", () => {
let searchContext = new SearchContext();
searchContext.originalQuery = "#first = #second";
- parse({
+ parseInternal({
fulltextTokens: [],
expressionTokens: tokens(["#first", "=", "#second"]),
searchContext
@@ -290,7 +227,7 @@ describe("Invalid expressions", () => {
searchContext = new SearchContext();
searchContext.originalQuery = "#first = note.relations.second";
- parse({
+ parseInternal({
fulltextTokens: [],
expressionTokens: tokens(["#first", "=", "note", ".", "relations", "second"]),
searchContext
@@ -306,21 +243,20 @@ describe("Invalid expressions", () => {
{ token: "#second", inQuotes: true }
],
searchContext: new SearchContext()
- });
+ }, AndExp);
- expect(rootExp.constructor.name).toEqual("AndExp");
assertIsArchived(rootExp.subExpressions[0]);
- expect(rootExp.subExpressions[2].constructor.name).toEqual("LabelComparisonExp");
- expect(rootExp.subExpressions[2].attributeType).toEqual("label");
- expect(rootExp.subExpressions[2].attributeName).toEqual("first");
- expect(rootExp.subExpressions[2].comparator).toBeTruthy();
+ const labelComparisonExp = expectExpression(rootExp.subExpressions[2], LabelComparisonExp);
+ expect(labelComparisonExp.attributeType).toEqual("label");
+ expect(labelComparisonExp.attributeName).toEqual("first");
+ expect(labelComparisonExp.comparator).toBeTruthy();
});
it("searching by relation without note property", () => {
const searchContext = new SearchContext();
- parse({
+ parseInternal({
fulltextTokens: [],
expressionTokens: tokens(["~first", "=", "text", "-", "abc"]),
searchContext
@@ -329,3 +265,91 @@ describe("Invalid expressions", () => {
expect(searchContext.error).toEqual('Relation can be compared only with property, e.g. ~relation.title=hello in ""');
});
});
+
+type ClassType<T extends Expression> = new (...args: any[]) => T;
+
+function tokens(toks: (string | string[])[], cur = 0): Array<any> {
+ return toks.map((arg) => {
+ if (Array.isArray(arg)) {
+ return tokens(arg, cur);
+ } else {
+ cur += arg.length;
+
+ return {
+ token: arg,
+ inQuotes: false,
+ startIndex: cur - arg.length,
+ endIndex: cur - 1
+ };
+ }
+ });
+}
+
+function assertIsArchived(_exp: Expression) {
+ const exp = expectExpression(_exp, PropertyComparisonExp);
+ expect(exp.propertyName).toEqual("isArchived");
+ expect(exp.operator).toEqual("=");
+ expect(exp.comparedValue).toEqual("false");
+}
+
+/**
+ * Parses the corresponding {@link Expression} from plain text, while also expecting the resulting expression to be of the given type.
+ *
+ * @param opts the options for parsing.
+ * @param type the expected type of the expression.
+ * @returns the expression typecasted to the expected type.
+ */
+function parse<T extends Expression>(opts: ParseOpts, type: ClassType<T>) {
+ return expectExpression(parseInternal(opts), type);
+}
+
+/**
+ * Expects the given {@link Expression} to be of the given type.
+ *
+ * @param exp an instance of an {@link Expression}.
+ * @param type a type class such as {@link AndExp}, {@link OrExp}, etc.
+ * @returns the same expression typecasted to the expected type.
+ */
+function expectExpression<T extends Expression>(exp: Expression, type: ClassType<T>) {
+ expect(exp).toBeInstanceOf(type);
+ return exp as T;
+}
+
+/**
+ * For an {@link AndExp}, it goes through all its subexpressions (up to fourth) and checks their type and returns them as a typecasted array.
+ * Each subexpression can have their own type.
+ *
+ * @param exp the expression containing one or more subexpressions.
+ * @param firstType the type of the first subexpression.
+ * @param secondType the type of the second subexpression.
+ * @param thirdType the type of the third subexpression.
+ * @param fourthType the type of the fourth subexpression.
+ * @returns an array of all the subexpressions (in order) typecasted to their expected type.
+ */
+function expectSubexpressions<FirstT extends Expression,
+ SecondT extends Expression,
+ ThirdT extends Expression,
+ FourthT extends Expression>(
+ exp: AndExp,
+ firstType: ClassType<FirstT>,
+ secondType?: ClassType<SecondT>,
+ thirdType?: ClassType<ThirdT>,
+ fourthType?: ClassType<FourthT>): [ FirstT, SecondT, ThirdT, FourthT ]
+{
+ expectExpression(exp.subExpressions[0], firstType);
+ if (secondType) {
+ expectExpression(exp.subExpressions[1], secondType);
+ }
+ if (thirdType) {
+ expectExpression(exp.subExpressions[2], thirdType);
+ }
+ if (fourthType) {
+ expectExpression(exp.subExpressions[3], fourthType);
+ }
+ return [
+ exp.subExpressions[0] as FirstT,
+ exp.subExpressions[1] as SecondT,
+ exp.subExpressions[2] as ThirdT,
+ exp.subExpressions[3] as FourthT
+ ]
+}
diff --git a/src/services/search/expressions/and.ts b/src/services/search/expressions/and.ts
index 2a6e078773..72918a74f0 100644
--- a/src/services/search/expressions/and.ts
+++ b/src/services/search/expressions/and.ts
@@ -6,7 +6,7 @@ import Expression from "./expression.js";
import TrueExp from "./true.js";
class AndExp extends Expression {
- private subExpressions: Expression[];
+ subExpressions: Expression[];
static of(_subExpressions: (Expression | null | undefined)[]) {
const subExpressions = _subExpressions.filter((exp) => !!exp) as Expression[];
diff --git a/src/services/search/expressions/attribute_exists.ts b/src/services/search/expressions/attribute_exists.ts
index 1b0dc397b6..52c8660012 100644
--- a/src/services/search/expressions/attribute_exists.ts
+++ b/src/services/search/expressions/attribute_exists.ts
@@ -7,8 +7,8 @@ import becca from "../../../becca/becca.js";
import Expression from "./expression.js";
class AttributeExistsExp extends Expression {
- private attributeType: string;
- private attributeName: string;
+ attributeType: string;
+ attributeName: string;
private isTemplateLabel: boolean;
private prefixMatch: boolean;
diff --git a/src/services/search/expressions/label_comparison.ts b/src/services/search/expressions/label_comparison.ts
index ade1fed6cf..c162aa0a22 100644
--- a/src/services/search/expressions/label_comparison.ts
+++ b/src/services/search/expressions/label_comparison.ts
@@ -8,9 +8,9 @@ import SearchContext from "../search_context.js";
type Comparator = (value: string) => boolean;
class LabelComparisonExp extends Expression {
- private attributeType: string;
- private attributeName: string;
- private comparator: Comparator;
+ attributeType: string;
+ attributeName: string;
+ comparator: Comparator;
constructor(attributeType: string, attributeName: string, comparator: Comparator) {
super();
diff --git a/src/services/search/expressions/not.ts b/src/services/search/expressions/not.ts
index 25f61f6db8..80f2adfe33 100644
--- a/src/services/search/expressions/not.ts
+++ b/src/services/search/expressions/not.ts
@@ -5,7 +5,7 @@ import SearchContext from "../search_context.js";
import Expression from "./expression.js";
class NotExp extends Expression {
- private subExpression: Expression;
+ subExpression: Expression;
constructor(subExpression: Expression) {
super();
diff --git a/src/services/search/expressions/note_content_fulltext.ts b/src/services/search/expressions/note_content_fulltext.ts
index 741a54a033..cd92e5178f 100644
--- a/src/services/search/expressions/note_content_fulltext.ts
+++ b/src/services/search/expressions/note_content_fulltext.ts
@@ -34,7 +34,7 @@ type SearchRow = Pick<NoteRow, "noteId" | "type" | "mime" | "content" | "isProte
class NoteContentFulltextExp extends Expression {
private operator: string;
- private tokens: string[];
+ tokens: string[];
private raw: boolean;
private flatText: boolean;
diff --git a/src/services/search/expressions/note_flat_text.ts b/src/services/search/expressions/note_flat_text.ts
index 5e5e41f35f..9d39e4397c 100644
--- a/src/services/search/expressions/note_flat_text.ts
+++ b/src/services/search/expressions/note_flat_text.ts
@@ -10,7 +10,7 @@ import { normalize } from "../../utils.js";
import beccaService from "../../../becca/becca_service.js";
class NoteFlatTextExp extends Expression {
- private tokens: string[];
+ tokens: string[];
constructor(tokens: string[]) {
super();
diff --git a/src/services/search/expressions/or.ts b/src/services/search/expressions/or.ts
index 10dd5dc033..1e41abff50 100644
--- a/src/services/search/expressions/or.ts
+++ b/src/services/search/expressions/or.ts
@@ -6,7 +6,7 @@ import TrueExp from "./true.js";
import SearchContext from "../search_context.js";
class OrExp extends Expression {
- private subExpressions: Expression[];
+ subExpressions: Expression[];
static of(subExpressions: Expression[]) {
subExpressions = subExpressions.filter((exp) => !!exp);
diff --git a/src/services/search/expressions/order_by_and_limit.ts b/src/services/search/expressions/order_by_and_limit.ts
index c0cb676a70..3bbc53a678 100644
--- a/src/services/search/expressions/order_by_and_limit.ts
+++ b/src/services/search/expressions/order_by_and_limit.ts
@@ -18,7 +18,7 @@ interface OrderDefinition {
class OrderByAndLimitExp extends Expression {
private orderDefinitions: OrderDefinition[];
- private limit: number;
+ limit: number;
subExpression: Expression | null;
constructor(orderDefinitions: Pick<OrderDefinition, "direction" | "valueExtractor">[], limit?: number) {
diff --git a/src/services/search/expressions/property_comparison.ts b/src/services/search/expressions/property_comparison.ts
index a29661c478..02906f9956 100644
--- a/src/services/search/expressions/property_comparison.ts
+++ b/src/services/search/expressions/property_comparison.ts
@@ -41,9 +41,9 @@ interface SearchContext {
}
class PropertyComparisonExp extends Expression {
- private propertyName: string;
- private operator: string;
- private comparedValue: string;
+ propertyName: string;
+ operator: string;
+ comparedValue: string;
private comparator;
static isProperty(name: string) {
diff --git a/src/services/search/search_context.ts b/src/services/search/search_context.ts
index 5efc890a84..29fb7dbda5 100644
--- a/src/services/search/search_context.ts
+++ b/src/services/search/search_context.ts
@@ -22,7 +22,7 @@ class SearchContext {
originalQuery: string;
fulltextQuery: string;
dbLoadNeeded: boolean;
- private error: string | null;
+ error: string | null;
constructor(params: SearchParams = {}) {
this.fastSearch = !!params.fastSearch;
diff --git a/src/services/search/services/parse.ts b/src/services/search/services/parse.ts
index 1a0fcce237..34acbc7ad4 100644
--- a/src/services/search/services/parse.ts
+++ b/src/services/search/services/parse.ts
@@ -423,7 +423,14 @@ function getExpression(tokens: TokenData[], searchContext: SearchContext, level
return getAggregateExpression();
}
-function parse({ fulltextTokens, expressionTokens, searchContext }: { fulltextTokens: TokenData[]; expressionTokens: TokenStructure; searchContext: SearchContext; originalQuery: string }) {
+export interface ParseOpts {
+ fulltextTokens: TokenData[];
+ expressionTokens: TokenStructure;
+ searchContext: SearchContext;
+ originalQuery?: string
+}
+
+function parse({ fulltextTokens, expressionTokens, searchContext }: ParseOpts) {
let expression: Expression | undefined | null;
try {