search-input-query-parser 0.4.1 → 0.5.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/index.js +48 -0
- package/dist/cjs/parser.js +4 -4
- package/dist/esm/index.js +22 -0
- package/dist/esm/parser.js +3 -2
- package/dist/types/index.d.ts +16 -0
- package/dist/types/parser.d.ts +16 -16
- package/package.json +6 -1
- package/src/index.ts +62 -0
- package/src/parser.ts +18 -28
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
exports.searchStringToParadeDbSql = exports.searchQueryToParadeDbSql = exports.searchStringToIlikeSql = exports.searchQueryToIlikeSql = exports.searchStringToTsVectorSql = exports.searchQueryToTsVectorSql = exports.searchStringToSql = exports.searchQueryToSql = exports.parseExpression = void 0;
|
|
18
|
+
// Re-export everything from parser.ts
|
|
19
|
+
__exportStar(require("./parser"), exports);
|
|
20
|
+
// Re-export everything from validator.ts
|
|
21
|
+
__exportStar(require("./validator"), exports);
|
|
22
|
+
// Re-export everything from lexer.ts
|
|
23
|
+
__exportStar(require("./lexer"), exports);
|
|
24
|
+
// Re-export everything from first-pass-parser.ts with renamed types to avoid conflicts
|
|
25
|
+
var first_pass_parser_1 = require("./first-pass-parser");
|
|
26
|
+
Object.defineProperty(exports, "parseExpression", { enumerable: true, get: function () { return first_pass_parser_1.parseExpression; } });
|
|
27
|
+
// Re-export SQL-related files with renamed types to avoid conflicts
|
|
28
|
+
var search_query_to_sql_1 = require("./search-query-to-sql");
|
|
29
|
+
Object.defineProperty(exports, "searchQueryToSql", { enumerable: true, get: function () { return search_query_to_sql_1.searchQueryToSql; } });
|
|
30
|
+
Object.defineProperty(exports, "searchStringToSql", { enumerable: true, get: function () { return search_query_to_sql_1.searchStringToSql; } });
|
|
31
|
+
var search_query_to_tsvector_sql_1 = require("./search-query-to-tsvector-sql");
|
|
32
|
+
Object.defineProperty(exports, "searchQueryToTsVectorSql", { enumerable: true, get: function () { return search_query_to_tsvector_sql_1.searchQueryToTsVectorSql; } });
|
|
33
|
+
Object.defineProperty(exports, "searchStringToTsVectorSql", { enumerable: true, get: function () { return search_query_to_tsvector_sql_1.searchStringToTsVectorSql; } });
|
|
34
|
+
var search_query_to_ilike_sql_1 = require("./search-query-to-ilike-sql");
|
|
35
|
+
Object.defineProperty(exports, "searchQueryToIlikeSql", { enumerable: true, get: function () { return search_query_to_ilike_sql_1.searchQueryToIlikeSql; } });
|
|
36
|
+
Object.defineProperty(exports, "searchStringToIlikeSql", { enumerable: true, get: function () { return search_query_to_ilike_sql_1.searchStringToIlikeSql; } });
|
|
37
|
+
var search_query_to_paradedb_sql_1 = require("./search-query-to-paradedb-sql");
|
|
38
|
+
Object.defineProperty(exports, "searchQueryToParadeDbSql", { enumerable: true, get: function () { return search_query_to_paradedb_sql_1.searchQueryToParadeDbSql; } });
|
|
39
|
+
Object.defineProperty(exports, "searchStringToParadeDbSql", { enumerable: true, get: function () { return search_query_to_paradedb_sql_1.searchStringToParadeDbSql; } });
|
|
40
|
+
// Re-export utility functions
|
|
41
|
+
__exportStar(require("./validate-expression-fields"), exports);
|
|
42
|
+
__exportStar(require("./validate-string"), exports);
|
|
43
|
+
__exportStar(require("./validate-wildcard"), exports);
|
|
44
|
+
__exportStar(require("./validate-in-expression"), exports);
|
|
45
|
+
__exportStar(require("./parse-in-values"), exports);
|
|
46
|
+
__exportStar(require("./parse-primary"), exports);
|
|
47
|
+
__exportStar(require("./parse-range-expression"), exports);
|
|
48
|
+
__exportStar(require("./transform-to-expression"), exports);
|
package/dist/cjs/parser.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.parseSearchInputQuery = exports.stringify = exports.SearchQueryErrorCode = void 0;
|
|
4
4
|
const lexer_1 = require("./lexer");
|
|
5
5
|
const first_pass_parser_1 = require("./first-pass-parser");
|
|
6
6
|
const validator_1 = require("./validator");
|
|
@@ -23,11 +23,11 @@ const stringify = (expr) => {
|
|
|
23
23
|
}
|
|
24
24
|
return `${expr.field.value}:${expr.operator}${expr.value.value}`;
|
|
25
25
|
case "NOT":
|
|
26
|
-
return `NOT (${stringify(expr.expression)})`;
|
|
26
|
+
return `NOT (${(0, exports.stringify)(expr.expression)})`;
|
|
27
27
|
case "AND":
|
|
28
|
-
return `(${stringify(expr.left)} AND ${stringify(expr.right)})`;
|
|
28
|
+
return `(${(0, exports.stringify)(expr.left)} AND ${(0, exports.stringify)(expr.right)})`;
|
|
29
29
|
case "OR":
|
|
30
|
-
return `(${stringify(expr.left)} OR ${stringify(expr.right)})`;
|
|
30
|
+
return `(${(0, exports.stringify)(expr.left)} OR ${(0, exports.stringify)(expr.right)})`;
|
|
31
31
|
case "IN": {
|
|
32
32
|
const values = expr.values.map((v) => v.value).join(",");
|
|
33
33
|
return `${expr.field.value}:IN(${values})`;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
// Re-export everything from parser.ts
|
|
2
|
+
export * from "./parser";
|
|
3
|
+
// Re-export everything from validator.ts
|
|
4
|
+
export * from "./validator";
|
|
5
|
+
// Re-export everything from lexer.ts
|
|
6
|
+
export * from "./lexer";
|
|
7
|
+
// Re-export everything from first-pass-parser.ts with renamed types to avoid conflicts
|
|
8
|
+
export { parseExpression, } from "./first-pass-parser";
|
|
9
|
+
// Re-export SQL-related files with renamed types to avoid conflicts
|
|
10
|
+
export { searchQueryToSql, searchStringToSql, } from "./search-query-to-sql";
|
|
11
|
+
export { searchQueryToTsVectorSql, searchStringToTsVectorSql, } from "./search-query-to-tsvector-sql";
|
|
12
|
+
export { searchQueryToIlikeSql, searchStringToIlikeSql, } from "./search-query-to-ilike-sql";
|
|
13
|
+
export { searchQueryToParadeDbSql, searchStringToParadeDbSql, } from "./search-query-to-paradedb-sql";
|
|
14
|
+
// Re-export utility functions
|
|
15
|
+
export * from "./validate-expression-fields";
|
|
16
|
+
export * from "./validate-string";
|
|
17
|
+
export * from "./validate-wildcard";
|
|
18
|
+
export * from "./validate-in-expression";
|
|
19
|
+
export * from "./parse-in-values";
|
|
20
|
+
export * from "./parse-primary";
|
|
21
|
+
export * from "./parse-range-expression";
|
|
22
|
+
export * from "./transform-to-expression";
|
package/dist/esm/parser.js
CHANGED
|
@@ -3,8 +3,10 @@ import { parseExpression, } from "./first-pass-parser";
|
|
|
3
3
|
import { validateSearchQuery, SearchQueryErrorCode, } from "./validator";
|
|
4
4
|
import { validateExpressionFields } from "./validate-expression-fields";
|
|
5
5
|
import { transformToExpression } from "./transform-to-expression";
|
|
6
|
+
// Re-export these types from validator for backward compatibility
|
|
7
|
+
export { SearchQueryErrorCode };
|
|
6
8
|
// Helper function to stringify expressions
|
|
7
|
-
const stringify = (expr) => {
|
|
9
|
+
export const stringify = (expr) => {
|
|
8
10
|
var _a;
|
|
9
11
|
switch (expr.type) {
|
|
10
12
|
case "SEARCH_TERM":
|
|
@@ -79,4 +81,3 @@ export const parseSearchInputQuery = (input, fieldSchemas = []) => {
|
|
|
79
81
|
};
|
|
80
82
|
}
|
|
81
83
|
};
|
|
82
|
-
export { SearchQueryErrorCode, stringify, };
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export * from "./parser";
|
|
2
|
+
export * from "./validator";
|
|
3
|
+
export * from "./lexer";
|
|
4
|
+
export { parseExpression, type PositionLength, type StringLiteral, type WildcardPattern as FirstPassWildcardPattern, type AndExpression, type OrExpression, type NotExpression, type InExpression as FirstPassInExpression, type FirstPassExpression, type ParseResult, } from "./first-pass-parser";
|
|
5
|
+
export { searchQueryToSql, searchStringToSql, type SqlQueryResult as SqlQueryResultBase, type SearchType, type SearchQueryOptions as SearchQueryOptionsBase, } from "./search-query-to-sql";
|
|
6
|
+
export { searchQueryToTsVectorSql, searchStringToTsVectorSql, type SqlQueryResult as TsVectorSqlQueryResult, type SearchQueryOptions as TsVectorSearchQueryOptions, } from "./search-query-to-tsvector-sql";
|
|
7
|
+
export { searchQueryToIlikeSql, searchStringToIlikeSql, type SqlQueryResult as IlikeSqlQueryResult, type SearchQueryOptions as IlikeSearchQueryOptions, } from "./search-query-to-ilike-sql";
|
|
8
|
+
export { searchQueryToParadeDbSql, searchStringToParadeDbSql, type SqlQueryResult as ParadeDbSqlQueryResult, type SearchQueryOptions as ParadeDbSearchQueryOptions, } from "./search-query-to-paradedb-sql";
|
|
9
|
+
export * from "./validate-expression-fields";
|
|
10
|
+
export * from "./validate-string";
|
|
11
|
+
export * from "./validate-wildcard";
|
|
12
|
+
export * from "./validate-in-expression";
|
|
13
|
+
export * from "./parse-in-values";
|
|
14
|
+
export * from "./parse-primary";
|
|
15
|
+
export * from "./parse-range-expression";
|
|
16
|
+
export * from "./transform-to-expression";
|
package/dist/types/parser.d.ts
CHANGED
|
@@ -1,28 +1,29 @@
|
|
|
1
1
|
import { PositionLength } from "./first-pass-parser";
|
|
2
2
|
import { ValidationError, SearchQueryErrorCode } from "./validator";
|
|
3
|
-
|
|
3
|
+
export { ValidationError, SearchQueryErrorCode };
|
|
4
|
+
export interface FieldSchema {
|
|
4
5
|
name: string;
|
|
5
6
|
type: "string" | "number" | "date" | "boolean";
|
|
6
7
|
}
|
|
7
|
-
type SearchTerm = {
|
|
8
|
+
export type SearchTerm = {
|
|
8
9
|
readonly type: "SEARCH_TERM";
|
|
9
10
|
readonly value: string;
|
|
10
11
|
} & PositionLength;
|
|
11
|
-
type WildcardPattern = {
|
|
12
|
+
export type WildcardPattern = {
|
|
12
13
|
readonly type: "WILDCARD";
|
|
13
14
|
readonly prefix: string;
|
|
14
15
|
readonly quoted: boolean;
|
|
15
16
|
} & PositionLength;
|
|
16
|
-
type Field = {
|
|
17
|
+
export type Field = {
|
|
17
18
|
readonly type: "FIELD";
|
|
18
19
|
readonly value: string;
|
|
19
20
|
} & PositionLength;
|
|
20
|
-
type Value = {
|
|
21
|
+
export type Value = {
|
|
21
22
|
readonly type: "VALUE";
|
|
22
23
|
readonly value: string;
|
|
23
24
|
} & PositionLength;
|
|
24
|
-
type RangeOperator = ">=" | ">" | "<=" | "<" | "BETWEEN";
|
|
25
|
-
type RangeExpression = {
|
|
25
|
+
export type RangeOperator = ">=" | ">" | "<=" | "<" | "BETWEEN";
|
|
26
|
+
export type RangeExpression = {
|
|
26
27
|
readonly type: "RANGE";
|
|
27
28
|
readonly field: Field;
|
|
28
29
|
readonly operator: RangeOperator;
|
|
@@ -34,35 +35,34 @@ export type FieldValue = {
|
|
|
34
35
|
readonly field: Field;
|
|
35
36
|
readonly value: Value;
|
|
36
37
|
};
|
|
37
|
-
type And = {
|
|
38
|
+
export type And = {
|
|
38
39
|
readonly type: "AND";
|
|
39
40
|
readonly left: Expression;
|
|
40
41
|
readonly right: Expression;
|
|
41
42
|
} & PositionLength;
|
|
42
|
-
type Or = {
|
|
43
|
+
export type Or = {
|
|
43
44
|
readonly type: "OR";
|
|
44
45
|
readonly left: Expression;
|
|
45
46
|
readonly right: Expression;
|
|
46
47
|
} & PositionLength;
|
|
47
|
-
type Not = {
|
|
48
|
+
export type Not = {
|
|
48
49
|
readonly type: "NOT";
|
|
49
50
|
readonly expression: Expression;
|
|
50
51
|
} & PositionLength;
|
|
51
|
-
type InExpression = {
|
|
52
|
+
export type InExpression = {
|
|
52
53
|
readonly type: "IN";
|
|
53
54
|
readonly field: Field;
|
|
54
55
|
readonly values: Value[];
|
|
55
56
|
} & PositionLength;
|
|
56
|
-
type Expression = SearchTerm | WildcardPattern | FieldValue | RangeExpression | And | Or | Not | InExpression;
|
|
57
|
-
type SearchQuery = {
|
|
57
|
+
export type Expression = SearchTerm | WildcardPattern | FieldValue | RangeExpression | And | Or | Not | InExpression;
|
|
58
|
+
export type SearchQuery = {
|
|
58
59
|
readonly type: "SEARCH_QUERY";
|
|
59
60
|
readonly expression: Expression | null;
|
|
60
61
|
};
|
|
61
|
-
type SearchQueryError = {
|
|
62
|
+
export type SearchQueryError = {
|
|
62
63
|
readonly type: "SEARCH_QUERY_ERROR";
|
|
63
64
|
readonly expression: null;
|
|
64
65
|
readonly errors: ValidationError[];
|
|
65
66
|
};
|
|
66
|
-
declare const stringify: (expr: Expression) => string;
|
|
67
|
+
export declare const stringify: (expr: Expression) => string;
|
|
67
68
|
export declare const parseSearchInputQuery: (input: string, fieldSchemas?: FieldSchema[]) => SearchQuery | SearchQueryError;
|
|
68
|
-
export { type SearchQuery, type SearchQueryError, type Expression, type ValidationError, SearchQueryErrorCode, type FieldSchema, type RangeOperator, type RangeExpression, type WildcardPattern, type Value, stringify, };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "search-input-query-parser",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.5.1",
|
|
4
4
|
"description": "A parser for advanced search query syntax with field:value support",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"search",
|
|
@@ -19,6 +19,11 @@
|
|
|
19
19
|
],
|
|
20
20
|
"exports": {
|
|
21
21
|
".": {
|
|
22
|
+
"types": "./dist/types/index.d.ts",
|
|
23
|
+
"import": "./dist/esm/index.js",
|
|
24
|
+
"require": "./dist/cjs/index.js"
|
|
25
|
+
},
|
|
26
|
+
"./parser": {
|
|
22
27
|
"types": "./dist/types/parser.d.ts",
|
|
23
28
|
"import": "./dist/esm/parser.js",
|
|
24
29
|
"require": "./dist/cjs/parser.js"
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
// Re-export everything from parser.ts
|
|
2
|
+
export * from "./parser";
|
|
3
|
+
|
|
4
|
+
// Re-export everything from validator.ts
|
|
5
|
+
export * from "./validator";
|
|
6
|
+
|
|
7
|
+
// Re-export everything from lexer.ts
|
|
8
|
+
export * from "./lexer";
|
|
9
|
+
|
|
10
|
+
// Re-export everything from first-pass-parser.ts with renamed types to avoid conflicts
|
|
11
|
+
export {
|
|
12
|
+
parseExpression,
|
|
13
|
+
type PositionLength,
|
|
14
|
+
type StringLiteral,
|
|
15
|
+
type WildcardPattern as FirstPassWildcardPattern,
|
|
16
|
+
type AndExpression,
|
|
17
|
+
type OrExpression,
|
|
18
|
+
type NotExpression,
|
|
19
|
+
type InExpression as FirstPassInExpression,
|
|
20
|
+
type FirstPassExpression,
|
|
21
|
+
type ParseResult,
|
|
22
|
+
} from "./first-pass-parser";
|
|
23
|
+
|
|
24
|
+
// Re-export SQL-related files with renamed types to avoid conflicts
|
|
25
|
+
export {
|
|
26
|
+
searchQueryToSql,
|
|
27
|
+
searchStringToSql,
|
|
28
|
+
type SqlQueryResult as SqlQueryResultBase,
|
|
29
|
+
type SearchType,
|
|
30
|
+
type SearchQueryOptions as SearchQueryOptionsBase,
|
|
31
|
+
} from "./search-query-to-sql";
|
|
32
|
+
|
|
33
|
+
export {
|
|
34
|
+
searchQueryToTsVectorSql,
|
|
35
|
+
searchStringToTsVectorSql,
|
|
36
|
+
type SqlQueryResult as TsVectorSqlQueryResult,
|
|
37
|
+
type SearchQueryOptions as TsVectorSearchQueryOptions,
|
|
38
|
+
} from "./search-query-to-tsvector-sql";
|
|
39
|
+
|
|
40
|
+
export {
|
|
41
|
+
searchQueryToIlikeSql,
|
|
42
|
+
searchStringToIlikeSql,
|
|
43
|
+
type SqlQueryResult as IlikeSqlQueryResult,
|
|
44
|
+
type SearchQueryOptions as IlikeSearchQueryOptions,
|
|
45
|
+
} from "./search-query-to-ilike-sql";
|
|
46
|
+
|
|
47
|
+
export {
|
|
48
|
+
searchQueryToParadeDbSql,
|
|
49
|
+
searchStringToParadeDbSql,
|
|
50
|
+
type SqlQueryResult as ParadeDbSqlQueryResult,
|
|
51
|
+
type SearchQueryOptions as ParadeDbSearchQueryOptions,
|
|
52
|
+
} from "./search-query-to-paradedb-sql";
|
|
53
|
+
|
|
54
|
+
// Re-export utility functions
|
|
55
|
+
export * from "./validate-expression-fields";
|
|
56
|
+
export * from "./validate-string";
|
|
57
|
+
export * from "./validate-wildcard";
|
|
58
|
+
export * from "./validate-in-expression";
|
|
59
|
+
export * from "./parse-in-values";
|
|
60
|
+
export * from "./parse-primary";
|
|
61
|
+
export * from "./parse-range-expression";
|
|
62
|
+
export * from "./transform-to-expression";
|
package/src/parser.ts
CHANGED
|
@@ -12,37 +12,40 @@ import {
|
|
|
12
12
|
import { validateExpressionFields } from "./validate-expression-fields";
|
|
13
13
|
import { transformToExpression } from "./transform-to-expression";
|
|
14
14
|
|
|
15
|
+
// Re-export these types from validator for backward compatibility
|
|
16
|
+
export { ValidationError, SearchQueryErrorCode };
|
|
17
|
+
|
|
15
18
|
// Schema types for range queries
|
|
16
|
-
interface FieldSchema {
|
|
19
|
+
export interface FieldSchema {
|
|
17
20
|
name: string;
|
|
18
21
|
type: "string" | "number" | "date" | "boolean";
|
|
19
22
|
}
|
|
20
23
|
|
|
21
24
|
// Second Pass AST types (semantic analysis)
|
|
22
|
-
type SearchTerm = {
|
|
25
|
+
export type SearchTerm = {
|
|
23
26
|
readonly type: "SEARCH_TERM";
|
|
24
27
|
readonly value: string;
|
|
25
28
|
} & PositionLength;
|
|
26
29
|
|
|
27
|
-
type WildcardPattern = {
|
|
30
|
+
export type WildcardPattern = {
|
|
28
31
|
readonly type: "WILDCARD";
|
|
29
32
|
readonly prefix: string;
|
|
30
33
|
readonly quoted: boolean;
|
|
31
34
|
} & PositionLength;
|
|
32
35
|
|
|
33
|
-
type Field = {
|
|
36
|
+
export type Field = {
|
|
34
37
|
readonly type: "FIELD";
|
|
35
38
|
readonly value: string;
|
|
36
39
|
} & PositionLength;
|
|
37
40
|
|
|
38
|
-
type Value = {
|
|
41
|
+
export type Value = {
|
|
39
42
|
readonly type: "VALUE";
|
|
40
43
|
readonly value: string;
|
|
41
44
|
} & PositionLength;
|
|
42
45
|
|
|
43
|
-
type RangeOperator = ">=" | ">" | "<=" | "<" | "BETWEEN";
|
|
46
|
+
export type RangeOperator = ">=" | ">" | "<=" | "<" | "BETWEEN";
|
|
44
47
|
|
|
45
|
-
type RangeExpression = {
|
|
48
|
+
export type RangeExpression = {
|
|
46
49
|
readonly type: "RANGE";
|
|
47
50
|
readonly field: Field;
|
|
48
51
|
readonly operator: RangeOperator;
|
|
@@ -56,30 +59,30 @@ export type FieldValue = {
|
|
|
56
59
|
readonly value: Value;
|
|
57
60
|
};
|
|
58
61
|
|
|
59
|
-
type And = {
|
|
62
|
+
export type And = {
|
|
60
63
|
readonly type: "AND";
|
|
61
64
|
readonly left: Expression;
|
|
62
65
|
readonly right: Expression;
|
|
63
66
|
} & PositionLength;
|
|
64
67
|
|
|
65
|
-
type Or = {
|
|
68
|
+
export type Or = {
|
|
66
69
|
readonly type: "OR";
|
|
67
70
|
readonly left: Expression;
|
|
68
71
|
readonly right: Expression;
|
|
69
72
|
} & PositionLength;
|
|
70
73
|
|
|
71
|
-
type Not = {
|
|
74
|
+
export type Not = {
|
|
72
75
|
readonly type: "NOT";
|
|
73
76
|
readonly expression: Expression;
|
|
74
77
|
} & PositionLength;
|
|
75
78
|
|
|
76
|
-
type InExpression = {
|
|
79
|
+
export type InExpression = {
|
|
77
80
|
readonly type: "IN";
|
|
78
81
|
readonly field: Field;
|
|
79
82
|
readonly values: Value[];
|
|
80
83
|
} & PositionLength;
|
|
81
84
|
|
|
82
|
-
type Expression =
|
|
85
|
+
export type Expression =
|
|
83
86
|
| SearchTerm
|
|
84
87
|
| WildcardPattern
|
|
85
88
|
| FieldValue
|
|
@@ -89,19 +92,19 @@ type Expression =
|
|
|
89
92
|
| Not
|
|
90
93
|
| InExpression;
|
|
91
94
|
|
|
92
|
-
type SearchQuery = {
|
|
95
|
+
export type SearchQuery = {
|
|
93
96
|
readonly type: "SEARCH_QUERY";
|
|
94
97
|
readonly expression: Expression | null;
|
|
95
98
|
};
|
|
96
99
|
|
|
97
|
-
type SearchQueryError = {
|
|
100
|
+
export type SearchQueryError = {
|
|
98
101
|
readonly type: "SEARCH_QUERY_ERROR";
|
|
99
102
|
readonly expression: null;
|
|
100
103
|
readonly errors: ValidationError[];
|
|
101
104
|
};
|
|
102
105
|
|
|
103
106
|
// Helper function to stringify expressions
|
|
104
|
-
const stringify = (expr: Expression): string => {
|
|
107
|
+
export const stringify = (expr: Expression): string => {
|
|
105
108
|
switch (expr.type) {
|
|
106
109
|
case "SEARCH_TERM":
|
|
107
110
|
return expr.value;
|
|
@@ -210,16 +213,3 @@ export const parseSearchInputQuery = (
|
|
|
210
213
|
}
|
|
211
214
|
};
|
|
212
215
|
|
|
213
|
-
export {
|
|
214
|
-
type SearchQuery,
|
|
215
|
-
type SearchQueryError,
|
|
216
|
-
type Expression,
|
|
217
|
-
type ValidationError,
|
|
218
|
-
SearchQueryErrorCode,
|
|
219
|
-
type FieldSchema,
|
|
220
|
-
type RangeOperator,
|
|
221
|
-
type RangeExpression,
|
|
222
|
-
type WildcardPattern,
|
|
223
|
-
type Value,
|
|
224
|
-
stringify,
|
|
225
|
-
};
|