@allurereport/aql 3.1.0
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/README.md +482 -0
- package/dist/errors/index.d.ts +105 -0
- package/dist/errors/index.js +165 -0
- package/dist/errors/index.js.map +1 -0
- package/dist/filter/index.d.ts +43 -0
- package/dist/filter/index.js +335 -0
- package/dist/filter/index.js.map +1 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.js +6 -0
- package/dist/index.js.map +1 -0
- package/dist/model.d.ts +192 -0
- package/dist/model.js +45 -0
- package/dist/model.js.map +1 -0
- package/dist/parser/index.d.ts +120 -0
- package/dist/parser/index.js +497 -0
- package/dist/parser/index.js.map +1 -0
- package/dist/tokenizer/index.d.ts +89 -0
- package/dist/tokenizer/index.js +416 -0
- package/dist/tokenizer/index.js.map +1 -0
- package/dist/utils/index.d.ts +56 -0
- package/dist/utils/index.js +139 -0
- package/dist/utils/index.js.map +1 -0
- package/package.json +50 -0
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
/* eslint-disable max-len */
|
|
2
|
+
/**
|
|
3
|
+
* AQL error types and classes
|
|
4
|
+
*/
|
|
5
|
+
export var AqlErrorCode;
|
|
6
|
+
(function (AqlErrorCode) {
|
|
7
|
+
/** Tokenizer errors */
|
|
8
|
+
AqlErrorCode["UNEXPECTED_CHARACTER"] = "UNEXPECTED_CHARACTER";
|
|
9
|
+
AqlErrorCode["UNTERMINATED_STRING"] = "UNTERMINATED_STRING";
|
|
10
|
+
AqlErrorCode["INVALID_UNICODE_ESCAPE"] = "INVALID_UNICODE_ESCAPE";
|
|
11
|
+
/** Parser errors */
|
|
12
|
+
AqlErrorCode["EXPECTED_TOKEN"] = "EXPECTED_TOKEN";
|
|
13
|
+
AqlErrorCode["EXPECTED_OPERATION"] = "EXPECTED_OPERATION";
|
|
14
|
+
AqlErrorCode["EXPECTED_VALUE"] = "EXPECTED_VALUE";
|
|
15
|
+
AqlErrorCode["EXPECTED_ACCESSOR"] = "EXPECTED_ACCESSOR";
|
|
16
|
+
AqlErrorCode["INVALID_SYNTAX"] = "INVALID_SYNTAX";
|
|
17
|
+
AqlErrorCode["INVALID_INPUT"] = "INVALID_INPUT";
|
|
18
|
+
AqlErrorCode["INVALID_IDENTIFIER"] = "INVALID_IDENTIFIER";
|
|
19
|
+
/** Configuration errors */
|
|
20
|
+
AqlErrorCode["FORBIDDEN_LOGICAL_OPERATOR"] = "FORBIDDEN_LOGICAL_OPERATOR";
|
|
21
|
+
AqlErrorCode["FORBIDDEN_OPERATION"] = "FORBIDDEN_OPERATION";
|
|
22
|
+
AqlErrorCode["FORBIDDEN_ARRAY_OPERATION"] = "FORBIDDEN_ARRAY_OPERATION";
|
|
23
|
+
AqlErrorCode["FORBIDDEN_IDENTIFIER"] = "FORBIDDEN_IDENTIFIER";
|
|
24
|
+
AqlErrorCode["FORBIDDEN_VALUE_TYPE"] = "FORBIDDEN_VALUE_TYPE";
|
|
25
|
+
AqlErrorCode["FORBIDDEN_PARENTHESES"] = "FORBIDDEN_PARENTHESES";
|
|
26
|
+
AqlErrorCode["FORBIDDEN_BRACKET_ACCESS"] = "FORBIDDEN_BRACKET_ACCESS";
|
|
27
|
+
})(AqlErrorCode || (AqlErrorCode = {}));
|
|
28
|
+
/**
|
|
29
|
+
* Base error class for AQL errors
|
|
30
|
+
*/
|
|
31
|
+
export class AqlError extends Error {
|
|
32
|
+
constructor(code, message, details = {}) {
|
|
33
|
+
super(message);
|
|
34
|
+
this.name = "AqlError";
|
|
35
|
+
this.code = code;
|
|
36
|
+
this.details = details;
|
|
37
|
+
/**
|
|
38
|
+
* Maintains proper stack trace for where our error was thrown (only available on V8)
|
|
39
|
+
*/
|
|
40
|
+
if (Error.captureStackTrace) {
|
|
41
|
+
Error.captureStackTrace(this, this.constructor);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Gets error details for translation/localization
|
|
46
|
+
* Includes error code and all context information
|
|
47
|
+
*/
|
|
48
|
+
get fullDetails() {
|
|
49
|
+
return { ...this.details, code: this.code };
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Gets error code for translation key generation
|
|
53
|
+
*/
|
|
54
|
+
get translationKey() {
|
|
55
|
+
return `aql.errors.${this.code}`;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Tokenizer error
|
|
60
|
+
*/
|
|
61
|
+
export class AqlTokenizerError extends AqlError {
|
|
62
|
+
constructor(code, message, details = {}) {
|
|
63
|
+
super(code, message, details);
|
|
64
|
+
this.name = "AqlTokenizerError";
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Parser error
|
|
69
|
+
*/
|
|
70
|
+
export class AqlParserError extends AqlError {
|
|
71
|
+
constructor(code, message, details = {}) {
|
|
72
|
+
super(code, message, details);
|
|
73
|
+
this.name = "AqlParserError";
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Helper functions to create specific errors
|
|
78
|
+
*/
|
|
79
|
+
export const AqlErrors = {
|
|
80
|
+
unexpectedCharacter: (character, position) => {
|
|
81
|
+
return new AqlTokenizerError(AqlErrorCode.UNEXPECTED_CHARACTER, `Unexpected character: ${character} at position ${position}`, { character, position });
|
|
82
|
+
},
|
|
83
|
+
unterminatedString: (position) => {
|
|
84
|
+
return new AqlTokenizerError(AqlErrorCode.UNTERMINATED_STRING, `Unterminated string at position ${position}`, {
|
|
85
|
+
position,
|
|
86
|
+
});
|
|
87
|
+
},
|
|
88
|
+
invalidUnicodeEscape: (position) => {
|
|
89
|
+
return new AqlTokenizerError(AqlErrorCode.INVALID_UNICODE_ESCAPE, `Invalid Unicode escape sequence at position ${position}`, { position });
|
|
90
|
+
},
|
|
91
|
+
expectedToken: (expected, got, position, context) => {
|
|
92
|
+
const message = context
|
|
93
|
+
? `Expected ${expected}, got ${got} at position ${position}. Context: ${context}`
|
|
94
|
+
: `Expected ${expected}, got ${got} at position ${position}`;
|
|
95
|
+
return new AqlParserError(AqlErrorCode.EXPECTED_TOKEN, message, {
|
|
96
|
+
expected,
|
|
97
|
+
got,
|
|
98
|
+
position,
|
|
99
|
+
context,
|
|
100
|
+
});
|
|
101
|
+
},
|
|
102
|
+
expectedOperation: (position) => {
|
|
103
|
+
return new AqlParserError(AqlErrorCode.EXPECTED_OPERATION, `Expected operation at position ${position}`, {
|
|
104
|
+
position,
|
|
105
|
+
});
|
|
106
|
+
},
|
|
107
|
+
expectedValue: (position) => {
|
|
108
|
+
return new AqlParserError(AqlErrorCode.EXPECTED_VALUE, `Expected value at position ${position}`, { position });
|
|
109
|
+
},
|
|
110
|
+
expectedAccessor: (position, expected) => {
|
|
111
|
+
const message = expected
|
|
112
|
+
? `Expected ${expected} in accessor at position ${position}`
|
|
113
|
+
: `Expected STRING or NUMBER in accessor at position ${position}`;
|
|
114
|
+
return new AqlParserError(AqlErrorCode.EXPECTED_ACCESSOR, message, {
|
|
115
|
+
position,
|
|
116
|
+
expected,
|
|
117
|
+
});
|
|
118
|
+
},
|
|
119
|
+
invalidInput: (reason) => {
|
|
120
|
+
return new AqlParserError(AqlErrorCode.INVALID_INPUT, reason, { reason });
|
|
121
|
+
},
|
|
122
|
+
invalidIdentifier: (identifier, position) => {
|
|
123
|
+
return new AqlParserError(AqlErrorCode.INVALID_IDENTIFIER, `Invalid identifier '${identifier}' at position ${position}. Identifier must contain only Latin letters (a-z, A-Z) and underscores (_)`, { identifier, position });
|
|
124
|
+
},
|
|
125
|
+
forbiddenLogicalOperator: (operator, position) => {
|
|
126
|
+
return new AqlParserError(AqlErrorCode.FORBIDDEN_LOGICAL_OPERATOR, `Logical operator '${operator}' is not allowed at position ${position}`, { operator, position });
|
|
127
|
+
},
|
|
128
|
+
forbiddenOperation: (operation, position) => {
|
|
129
|
+
return new AqlParserError(AqlErrorCode.FORBIDDEN_OPERATION, `Operation '${operation}' is not allowed at position ${position}`, { operation, position });
|
|
130
|
+
},
|
|
131
|
+
forbiddenArrayOperation: (operation, position) => {
|
|
132
|
+
return new AqlParserError(AqlErrorCode.FORBIDDEN_ARRAY_OPERATION, `Array operation '${operation}' is not allowed at position ${position}`, { operation, position });
|
|
133
|
+
},
|
|
134
|
+
forbiddenIdentifier: (identifier, position) => {
|
|
135
|
+
return new AqlParserError(AqlErrorCode.FORBIDDEN_IDENTIFIER, `Identifier '${identifier}' is not allowed at position ${position}`, { identifier, position });
|
|
136
|
+
},
|
|
137
|
+
forbiddenValueType: (valueType, position) => {
|
|
138
|
+
return new AqlParserError(AqlErrorCode.FORBIDDEN_VALUE_TYPE, `Value type '${valueType}' is not allowed at position ${position}`, { valueType, position });
|
|
139
|
+
},
|
|
140
|
+
forbiddenParentheses: (position) => {
|
|
141
|
+
return new AqlParserError(AqlErrorCode.FORBIDDEN_PARENTHESES, `Parentheses are not allowed at position ${position}`, { position });
|
|
142
|
+
},
|
|
143
|
+
forbiddenBracketAccess: (position) => {
|
|
144
|
+
return new AqlParserError(AqlErrorCode.FORBIDDEN_BRACKET_ACCESS, `Bracket access is not allowed at position ${position}`, { position });
|
|
145
|
+
},
|
|
146
|
+
};
|
|
147
|
+
/**
|
|
148
|
+
* Type guard to check if error is AqlError
|
|
149
|
+
*/
|
|
150
|
+
export function isAqlError(error) {
|
|
151
|
+
return error instanceof AqlError;
|
|
152
|
+
}
|
|
153
|
+
/**
|
|
154
|
+
* Type guard to check if error is AqlTokenizerError
|
|
155
|
+
*/
|
|
156
|
+
export function isAqlTokenizerError(error) {
|
|
157
|
+
return error instanceof AqlTokenizerError;
|
|
158
|
+
}
|
|
159
|
+
/**
|
|
160
|
+
* Type guard to check if error is AqlParserError
|
|
161
|
+
*/
|
|
162
|
+
export function isAqlParserError(error) {
|
|
163
|
+
return error instanceof AqlParserError;
|
|
164
|
+
}
|
|
165
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../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J,CAAC;IAED,sBAAsB,EAAE,CAAC,QAAgB,EAAkB,EAAE;QAC3D,OAAO,IAAI,cAAc,CACvB,YAAY,CAAC,wBAAwB,EACrC,6CAA6C,QAAQ,EAAE,EACvD,EAAE,QAAQ,EAAE,CACb,CAAC;IACJ,CAAC;CACF,CAAC;AAEF;;GAEG;AACH,MAAM,UAAU,UAAU,CAAC,KAAc;IACvC,OAAO,KAAK,YAAY,QAAQ,CAAC;AACnC,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,mBAAmB,CAAC,KAAc;IAChD,OAAO,KAAK,YAAY,iBAAiB,CAAC;AAC5C,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,gBAAgB,CAAC,KAAc;IAC7C,OAAO,KAAK,YAAY,cAAc,CAAC;AACzC,CAAC"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import type { AqlExpression, AqlParserConfig } from "../model.js";
|
|
2
|
+
type FilterContext = Map<string, any> | Record<string, any>;
|
|
3
|
+
/**
|
|
4
|
+
* Filters an array of objects based on an AQL expression string.
|
|
5
|
+
*
|
|
6
|
+
* @param items - Array of objects to filter
|
|
7
|
+
* @param aql - AQL string expression
|
|
8
|
+
* @param context - Optional context map or object for function values
|
|
9
|
+
* @param config - Optional parser configuration to restrict available features
|
|
10
|
+
* @returns Filtered array of objects
|
|
11
|
+
* @throws {AqlParserError} If the AQL string is invalid or uses forbidden features
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* ```typescript
|
|
15
|
+
* const items = [{ status: "passed" }, { status: "failed" }];
|
|
16
|
+
* const filtered = filterByAql(items, 'status = "passed"');
|
|
17
|
+
* // Returns [{ status: "passed" }]
|
|
18
|
+
* ```
|
|
19
|
+
*/
|
|
20
|
+
export declare function filterByAql<T extends Record<string, any>>(items: T[], aql: string, context?: FilterContext, config?: AqlParserConfig): T[];
|
|
21
|
+
/**
|
|
22
|
+
* Filters an array of objects based on a parsed AQL expression.
|
|
23
|
+
*
|
|
24
|
+
* @param items - Array of objects to filter
|
|
25
|
+
* @param expression - Pre-parsed AQL expression
|
|
26
|
+
* @returns Filtered array of objects
|
|
27
|
+
*
|
|
28
|
+
* @example
|
|
29
|
+
* ```typescript
|
|
30
|
+
* const expr = parseAql('status = "passed"').expression;
|
|
31
|
+
* const filtered = filterByAql(items, expr);
|
|
32
|
+
* ```
|
|
33
|
+
*/
|
|
34
|
+
export declare function filterByAql<T extends Record<string, any>>(items: T[], expression: AqlExpression): T[];
|
|
35
|
+
/**
|
|
36
|
+
* Creates a predicate function from an AQL expression.
|
|
37
|
+
*
|
|
38
|
+
* @param expression - The AQL expression to convert to a predicate
|
|
39
|
+
* @returns A predicate function that takes an item and returns a boolean
|
|
40
|
+
* @private
|
|
41
|
+
*/
|
|
42
|
+
export declare function createAqlPredicate(expression: AqlExpression): (item: any) => boolean;
|
|
43
|
+
export {};
|
|
@@ -0,0 +1,335 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* AQL filter implementation for filtering objects
|
|
3
|
+
*/
|
|
4
|
+
import { AqlLogicalOperator, AqlOperation, AqlOperationAliases } from "../model.js";
|
|
5
|
+
import { parseAql } from "../parser/index.js";
|
|
6
|
+
export function filterByAql(items, aqlOrExpression, context, config) {
|
|
7
|
+
let expression = null;
|
|
8
|
+
if (typeof aqlOrExpression === "string") {
|
|
9
|
+
const aql = aqlOrExpression;
|
|
10
|
+
if (!aql || aql.trim() === "") {
|
|
11
|
+
return items;
|
|
12
|
+
}
|
|
13
|
+
const parseResult = parseAql(aql, context, config);
|
|
14
|
+
if (!parseResult.expression) {
|
|
15
|
+
return items;
|
|
16
|
+
}
|
|
17
|
+
expression = parseResult.expression;
|
|
18
|
+
}
|
|
19
|
+
else {
|
|
20
|
+
expression = aqlOrExpression;
|
|
21
|
+
}
|
|
22
|
+
if (!expression) {
|
|
23
|
+
return items;
|
|
24
|
+
}
|
|
25
|
+
const predicate = createAqlPredicate(expression);
|
|
26
|
+
return items.filter(predicate);
|
|
27
|
+
}
|
|
28
|
+
const alwaysTruePredicate = () => true;
|
|
29
|
+
/**
|
|
30
|
+
* Creates a predicate function from an AQL expression.
|
|
31
|
+
*
|
|
32
|
+
* @param expression - The AQL expression to convert to a predicate
|
|
33
|
+
* @returns A predicate function that takes an item and returns a boolean
|
|
34
|
+
* @private
|
|
35
|
+
*/
|
|
36
|
+
export function createAqlPredicate(expression) {
|
|
37
|
+
switch (expression.type) {
|
|
38
|
+
case "condition":
|
|
39
|
+
return createConditionPredicate(expression);
|
|
40
|
+
case "arrayCondition":
|
|
41
|
+
return createArrayConditionPredicate(expression);
|
|
42
|
+
case "binary":
|
|
43
|
+
return createBinaryPredicate(expression);
|
|
44
|
+
case "not":
|
|
45
|
+
return createNotPredicate(expression);
|
|
46
|
+
case "paren":
|
|
47
|
+
return createParenPredicate(expression);
|
|
48
|
+
case "boolean":
|
|
49
|
+
return createBooleanPredicate(expression);
|
|
50
|
+
default:
|
|
51
|
+
return alwaysTruePredicate;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Creates a predicate for a condition expression.
|
|
56
|
+
*
|
|
57
|
+
* @param expression - The condition expression
|
|
58
|
+
* @returns A predicate function that evaluates the condition
|
|
59
|
+
* @private
|
|
60
|
+
*/
|
|
61
|
+
function createConditionPredicate(expression) {
|
|
62
|
+
const { left, operator, right } = expression;
|
|
63
|
+
return (item) => {
|
|
64
|
+
const leftValue = getAccessorValue(item, left);
|
|
65
|
+
const rightValue = getValue(right);
|
|
66
|
+
return compareValues(leftValue, operator, rightValue);
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Creates a predicate for an array condition expression (e.g., IN).
|
|
71
|
+
*
|
|
72
|
+
* @param expression - The array condition expression
|
|
73
|
+
* @returns A predicate function that evaluates the array condition
|
|
74
|
+
* @private
|
|
75
|
+
*/
|
|
76
|
+
function createArrayConditionPredicate(expression) {
|
|
77
|
+
const { left, operator, right } = expression;
|
|
78
|
+
if (operator === AqlOperation.IN) {
|
|
79
|
+
return (item) => {
|
|
80
|
+
const leftValue = getAccessorValue(item, left);
|
|
81
|
+
const rightValues = right.map(getValue);
|
|
82
|
+
if (leftValue === null || leftValue === undefined) {
|
|
83
|
+
return false;
|
|
84
|
+
}
|
|
85
|
+
return rightValues.some((rightValue) => {
|
|
86
|
+
if (rightValue === null || rightValue === undefined) {
|
|
87
|
+
return leftValue === null || leftValue === undefined;
|
|
88
|
+
}
|
|
89
|
+
return equals(leftValue, rightValue);
|
|
90
|
+
});
|
|
91
|
+
};
|
|
92
|
+
}
|
|
93
|
+
return () => false;
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* Creates a predicate for a binary expression (AND, OR).
|
|
97
|
+
*
|
|
98
|
+
* @param expression - The binary expression
|
|
99
|
+
* @returns A predicate function that evaluates the binary expression
|
|
100
|
+
* @private
|
|
101
|
+
*/
|
|
102
|
+
function createBinaryPredicate(expression) {
|
|
103
|
+
const leftPredicate = createAqlPredicate(expression.left);
|
|
104
|
+
const rightPredicate = createAqlPredicate(expression.right);
|
|
105
|
+
if (expression.operator === AqlLogicalOperator.AND) {
|
|
106
|
+
return (item) => leftPredicate(item) && rightPredicate(item);
|
|
107
|
+
}
|
|
108
|
+
if (expression.operator === AqlLogicalOperator.OR) {
|
|
109
|
+
return (item) => leftPredicate(item) || rightPredicate(item);
|
|
110
|
+
}
|
|
111
|
+
return () => false;
|
|
112
|
+
}
|
|
113
|
+
/**
|
|
114
|
+
* Creates a predicate for a NOT expression.
|
|
115
|
+
*
|
|
116
|
+
* @param expression - The NOT expression
|
|
117
|
+
* @returns A predicate function that negates the inner expression
|
|
118
|
+
* @private
|
|
119
|
+
*/
|
|
120
|
+
function createNotPredicate(expression) {
|
|
121
|
+
const predicate = createAqlPredicate(expression.expression);
|
|
122
|
+
return (item) => !predicate(item);
|
|
123
|
+
}
|
|
124
|
+
/**
|
|
125
|
+
* Creates a predicate for a parenthesized expression.
|
|
126
|
+
*
|
|
127
|
+
* @param expression - The parenthesized expression
|
|
128
|
+
* @returns A predicate function that evaluates the inner expression
|
|
129
|
+
* @private
|
|
130
|
+
*/
|
|
131
|
+
function createParenPredicate(expression) {
|
|
132
|
+
return createAqlPredicate(expression.expression);
|
|
133
|
+
}
|
|
134
|
+
/**
|
|
135
|
+
* Creates a predicate for a boolean expression.
|
|
136
|
+
*
|
|
137
|
+
* @param expression - The boolean expression
|
|
138
|
+
* @returns A predicate function that always returns the boolean value
|
|
139
|
+
* @private
|
|
140
|
+
*/
|
|
141
|
+
function createBooleanPredicate(expression) {
|
|
142
|
+
return () => expression.value;
|
|
143
|
+
}
|
|
144
|
+
/**
|
|
145
|
+
* Gets a value from an object using an accessor.
|
|
146
|
+
* Supports nested access via bracket notation (e.g., `identifier[key]`).
|
|
147
|
+
*
|
|
148
|
+
* @param item - The object to access
|
|
149
|
+
* @param accessor - The accessor specifying the identifier and optional index/key
|
|
150
|
+
* @returns The accessed value or undefined if not found
|
|
151
|
+
* @private
|
|
152
|
+
*/
|
|
153
|
+
function getAccessorValue(item, accessor) {
|
|
154
|
+
let value = item[accessor.identifier];
|
|
155
|
+
if (accessor.param) {
|
|
156
|
+
if (Array.isArray(value) || (typeof value === "object" && value !== null)) {
|
|
157
|
+
value = value[accessor.param.value];
|
|
158
|
+
}
|
|
159
|
+
else {
|
|
160
|
+
return undefined;
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
return value;
|
|
164
|
+
}
|
|
165
|
+
/**
|
|
166
|
+
* Converts an AqlValue to its JavaScript representation.
|
|
167
|
+
*
|
|
168
|
+
* @param aqlValue - The AQL value to convert
|
|
169
|
+
* @returns The JavaScript value (null, boolean, number, or string)
|
|
170
|
+
* @private
|
|
171
|
+
*/
|
|
172
|
+
function getValue(aqlValue) {
|
|
173
|
+
switch (aqlValue.type) {
|
|
174
|
+
case "NULL":
|
|
175
|
+
return null;
|
|
176
|
+
case "BOOLEAN":
|
|
177
|
+
return aqlValue.value.toLowerCase() === "true";
|
|
178
|
+
case "NUMBER": {
|
|
179
|
+
const num = parseFloat(aqlValue.value);
|
|
180
|
+
/**
|
|
181
|
+
* Check for invalid numbers
|
|
182
|
+
*/
|
|
183
|
+
if (Number.isNaN(num)) {
|
|
184
|
+
return 0;
|
|
185
|
+
}
|
|
186
|
+
/**
|
|
187
|
+
* Return integer if it's a whole number, otherwise return float
|
|
188
|
+
*/
|
|
189
|
+
return Number.isInteger(num) ? parseInt(aqlValue.value, 10) : num;
|
|
190
|
+
}
|
|
191
|
+
case "STRING":
|
|
192
|
+
return aqlValue.value;
|
|
193
|
+
default:
|
|
194
|
+
return aqlValue.value;
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
/**
|
|
198
|
+
* Compares two values based on an operator.
|
|
199
|
+
*
|
|
200
|
+
* @param left - The left operand value
|
|
201
|
+
* @param operator - The comparison operator (GT, GE, LT, LE, EQ, NEQ, CONTAINS or their string aliases: =, !=, >, >=, <, <=, ~=)
|
|
202
|
+
* @param right - The right operand value
|
|
203
|
+
* @returns `true` if the comparison is true, `false` otherwise
|
|
204
|
+
* @private
|
|
205
|
+
*/
|
|
206
|
+
function compareValues(left, operator, right) {
|
|
207
|
+
/**
|
|
208
|
+
* Handle null comparisons
|
|
209
|
+
*/
|
|
210
|
+
if (right === null || right === undefined) {
|
|
211
|
+
if (operator === AqlOperation.EQ || operator === AqlOperationAliases.EQ) {
|
|
212
|
+
return left === null || left === undefined;
|
|
213
|
+
}
|
|
214
|
+
if (operator === AqlOperation.NEQ || operator === AqlOperationAliases.NEQ) {
|
|
215
|
+
return left !== null && left !== undefined;
|
|
216
|
+
}
|
|
217
|
+
return false;
|
|
218
|
+
}
|
|
219
|
+
if (left === null || left === undefined) {
|
|
220
|
+
return false;
|
|
221
|
+
}
|
|
222
|
+
switch (operator) {
|
|
223
|
+
case AqlOperation.EQ:
|
|
224
|
+
case AqlOperationAliases.EQ:
|
|
225
|
+
return equals(left, right);
|
|
226
|
+
case AqlOperation.NEQ:
|
|
227
|
+
case AqlOperationAliases.NEQ:
|
|
228
|
+
return !equals(left, right);
|
|
229
|
+
case AqlOperation.GT:
|
|
230
|
+
case AqlOperationAliases.GT:
|
|
231
|
+
return compareNumbers(left, right) > 0;
|
|
232
|
+
case AqlOperation.GE:
|
|
233
|
+
case AqlOperationAliases.GE:
|
|
234
|
+
return compareNumbers(left, right) >= 0;
|
|
235
|
+
case AqlOperation.LT:
|
|
236
|
+
case AqlOperationAliases.LT:
|
|
237
|
+
return compareNumbers(left, right) < 0;
|
|
238
|
+
case AqlOperation.LE:
|
|
239
|
+
case AqlOperationAliases.LE:
|
|
240
|
+
return compareNumbers(left, right) <= 0;
|
|
241
|
+
case AqlOperation.CONTAINS:
|
|
242
|
+
case AqlOperationAliases.CONTAINS:
|
|
243
|
+
return contains(left, right);
|
|
244
|
+
default:
|
|
245
|
+
return false;
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
/**
|
|
249
|
+
* Checks if two values are equal.
|
|
250
|
+
* Performs case-insensitive comparison for strings.
|
|
251
|
+
*
|
|
252
|
+
* @param left - The left value to compare
|
|
253
|
+
* @param right - The right value to compare
|
|
254
|
+
* @returns `true` if values are equal, `false` otherwise
|
|
255
|
+
* @private
|
|
256
|
+
*/
|
|
257
|
+
function equals(left, right) {
|
|
258
|
+
if (left === right) {
|
|
259
|
+
return true;
|
|
260
|
+
}
|
|
261
|
+
/**
|
|
262
|
+
* String comparison (case-insensitive for strings)
|
|
263
|
+
*/
|
|
264
|
+
if (typeof left === "string" && typeof right === "string") {
|
|
265
|
+
return left.toLocaleLowerCase() === right.toLocaleLowerCase();
|
|
266
|
+
}
|
|
267
|
+
/**
|
|
268
|
+
* Number comparison
|
|
269
|
+
*/
|
|
270
|
+
if (typeof left === "number" && typeof right === "number") {
|
|
271
|
+
return left === right;
|
|
272
|
+
}
|
|
273
|
+
/**
|
|
274
|
+
* Boolean comparison
|
|
275
|
+
*/
|
|
276
|
+
if (typeof left === "boolean" && typeof right === "boolean") {
|
|
277
|
+
return left === right;
|
|
278
|
+
}
|
|
279
|
+
/**
|
|
280
|
+
* Array comparison
|
|
281
|
+
*/
|
|
282
|
+
if (Array.isArray(left) && Array.isArray(right)) {
|
|
283
|
+
if (left.length !== right.length) {
|
|
284
|
+
return false;
|
|
285
|
+
}
|
|
286
|
+
return left.every((item, index) => equals(item, right[index]));
|
|
287
|
+
}
|
|
288
|
+
return false;
|
|
289
|
+
}
|
|
290
|
+
/**
|
|
291
|
+
* Compares two values as numbers.
|
|
292
|
+
* Converts values to numbers if needed. null/undefined is considered less than any number.
|
|
293
|
+
*
|
|
294
|
+
* @param left - The left value to compare
|
|
295
|
+
* @param right - The right value to compare
|
|
296
|
+
* @returns Negative number if left < right, positive if left > right, 0 if equal
|
|
297
|
+
* @private
|
|
298
|
+
*/
|
|
299
|
+
function compareNumbers(left, right) {
|
|
300
|
+
/**
|
|
301
|
+
* Handle null/undefined
|
|
302
|
+
*/
|
|
303
|
+
if (left === null || left === undefined) {
|
|
304
|
+
return -1; // null/undefined is considered less than any number
|
|
305
|
+
}
|
|
306
|
+
/**
|
|
307
|
+
* Optimize: avoid parsing if both are already numbers
|
|
308
|
+
*/
|
|
309
|
+
const leftNum = typeof left === "number" ? left : typeof left === "string" ? parseFloat(left) : Number(left);
|
|
310
|
+
const rightNum = typeof right === "number" ? right : typeof right === "string" ? parseFloat(right) : Number(right);
|
|
311
|
+
if (Number.isNaN(leftNum) || Number.isNaN(rightNum)) {
|
|
312
|
+
return 0;
|
|
313
|
+
}
|
|
314
|
+
return leftNum - rightNum;
|
|
315
|
+
}
|
|
316
|
+
/**
|
|
317
|
+
* Checks if left value contains right value (case-insensitive string comparison).
|
|
318
|
+
*
|
|
319
|
+
* @param left - The value to search in
|
|
320
|
+
* @param right - The value to search for
|
|
321
|
+
* @returns `true` if left contains right, `false` otherwise
|
|
322
|
+
* @private
|
|
323
|
+
*/
|
|
324
|
+
function contains(left, right) {
|
|
325
|
+
if (left === null || left === undefined) {
|
|
326
|
+
return false;
|
|
327
|
+
}
|
|
328
|
+
if (left === right) {
|
|
329
|
+
return true;
|
|
330
|
+
}
|
|
331
|
+
const leftStr = String(left).toLocaleLowerCase();
|
|
332
|
+
const rightStr = String(right).toLocaleLowerCase();
|
|
333
|
+
return leftStr.includes(rightStr);
|
|
334
|
+
}
|
|
335
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/filter/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,EAAE,kBAAkB,EAAE,YAAY,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAcpF,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AA2C9C,MAAM,UAAU,WAAW,CACzB,KAAU,EACV,eAAuC,EACvC,OAAuB,EACvB,MAAwB;IAExB,IAAI,UAAU,GAAyB,IAAI,CAAC;IAE5C,IAAI,OAAO,eAAe,KAAK,QAAQ,EAAE,CAAC;QACxC,MAAM,GAAG,GAAG,eAAe,CAAC;QAC5B,IAAI,CAAC,GAAG,IAAI,GAAG,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE,CAAC;YAC9B,OAAO,KAAK,CAAC;QACf,CAAC;QAED,MAAM,WAAW,GAAG,QAAQ,CAAC,GAAG,EAAE,OAAO,EAAE,MAAM,CAAC,CAAC;QACnD,IAAI,CAAC,WAAW,CAAC,UAAU,EAAE,CAAC;YAC5B,OAAO,KAAK,CAAC;QACf,CAAC;QACD,UAAU,GAAG,WAAW,CAAC,UAAU,CAAC;IACtC,CAAC;SAAM,CAAC;QACN,UAAU,GAAG,eAAe,CAAC;IAC/B,CAAC;IAED,IAAI,CAAC,UAAU,EAAE,CAAC;QAChB,OAAO,KAAK,CAAC;IACf,CAAC;IAED,MAAM,SAAS,GAAG,kBAAkB,CAAC,UAAU,CAAC,CAAC;IACjD,OAAO,KAAK,CAAC,MAAM,CAAC,SAAS,CAAC,CA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C,KAAK,CAAC,QAAQ,CAAC,EAAE,CAAC;QACpD,OAAO,CAAC,CAAC;IACX,CAAC;IAED,OAAO,OAAO,GAAG,QAAQ,CAAC;AAC5B,CAAC;AAED;;;;;;;GAOG;AACH,SAAS,QAAQ,CAAC,IAAS,EAAE,KAAU;IACrC,IAAI,IAAI,KAAK,IAAI,IAAI,IAAI,KAAK,SAAS,EAAE,CAAC;QACxC,OAAO,KAAK,CAAC;IACf,CAAC;IAED,IAAI,IAAI,KAAK,KAAK,EAAE,CAAC;QACnB,OAAO,IAAI,CAAC;IACd,CAAC;IAED,MAAM,OAAO,GAAG,MAAM,CAAC,IAAI,CAAC,CAAC,iBAAiB,EAAE,CAAC;IACjD,MAAM,QAAQ,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC,iBAAiB,EAAE,CAAC;IAEnD,OAAO,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;AACpC,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export { parseAql, AqlParser } from "./parser/index.js";
|
|
2
|
+
export { filterByAql, createAqlPredicate } from "./filter/index.js";
|
|
3
|
+
export { includesAll, aqlExpression, aqlConditionExpression, aqlArrayConditionExpression, aqlBinaryExpression, aqlNotExpression, aqlParenExpression, aqlParserConfig, } from "./utils/index.js";
|
|
4
|
+
export { isAqlError, AqlError, AqlErrors } from "./errors/index.js";
|
|
5
|
+
export type { AqlParseResult, AqlExpression, AqlNotExpression, AqlParenExpression, AqlBinaryExpression, AqlBooleanExpression, AqlConditionExpression, AqlArrayConditionExpression, } from "./model.js";
|
|
6
|
+
export { AqlLogicalOperator, AqlOperation, AqlOperationAliases } from "./model.js";
|
|
7
|
+
export type { AqlParserConfig } from "./model.js";
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export { parseAql, AqlParser } from "./parser/index.js";
|
|
2
|
+
export { filterByAql, createAqlPredicate } from "./filter/index.js";
|
|
3
|
+
export { includesAll, aqlExpression, aqlConditionExpression, aqlArrayConditionExpression, aqlBinaryExpression, aqlNotExpression, aqlParenExpression, aqlParserConfig, } from "./utils/index.js";
|
|
4
|
+
export { isAqlError, AqlError, AqlErrors } from "./errors/index.js";
|
|
5
|
+
export { AqlLogicalOperator, AqlOperation, AqlOperationAliases } from "./model.js";
|
|
6
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AACxD,OAAO,EAAE,WAAW,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AACpE,OAAO,EACL,WAAW,EACX,aAAa,EACb,sBAAsB,EACtB,2BAA2B,EAC3B,mBAAmB,EACnB,gBAAgB,EAChB,kBAAkB,EAClB,eAAe,GAChB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAWpE,OAAO,EAAE,kBAAkB,EAAE,YAAY,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC"}
|