@finos/legend-query-builder 4.1.14 → 4.2.0
Sign up to get free protection for your applications and to get access to all the features.
- package/lib/components/filter/QueryBuilderFilterPanel.d.ts +6 -1
- package/lib/components/filter/QueryBuilderFilterPanel.d.ts.map +1 -1
- package/lib/components/filter/QueryBuilderFilterPanel.js +189 -13
- package/lib/components/filter/QueryBuilderFilterPanel.js.map +1 -1
- package/lib/index.css +17 -1
- package/lib/index.css.map +1 -1
- package/lib/package.json +6 -6
- package/lib/stores/QueryBuilderStateHashUtils.d.ts +1 -0
- package/lib/stores/QueryBuilderStateHashUtils.d.ts.map +1 -1
- package/lib/stores/QueryBuilderStateHashUtils.js +1 -0
- package/lib/stores/QueryBuilderStateHashUtils.js.map +1 -1
- package/lib/stores/filter/QueryBuilderFilterOperator.d.ts +1 -1
- package/lib/stores/filter/QueryBuilderFilterOperator.d.ts.map +1 -1
- package/lib/stores/filter/QueryBuilderFilterOperator.js.map +1 -1
- package/lib/stores/filter/QueryBuilderFilterState.d.ts +16 -5
- package/lib/stores/filter/QueryBuilderFilterState.d.ts.map +1 -1
- package/lib/stores/filter/QueryBuilderFilterState.js +78 -18
- package/lib/stores/filter/QueryBuilderFilterState.js.map +1 -1
- package/lib/stores/filter/QueryBuilderFilterStateBuilder.d.ts.map +1 -1
- package/lib/stores/filter/QueryBuilderFilterStateBuilder.js +125 -2
- package/lib/stores/filter/QueryBuilderFilterStateBuilder.js.map +1 -1
- package/lib/stores/filter/QueryBuilderFilterValueSpecificationBuilder.d.ts.map +1 -1
- package/lib/stores/filter/QueryBuilderFilterValueSpecificationBuilder.js +62 -3
- package/lib/stores/filter/QueryBuilderFilterValueSpecificationBuilder.js.map +1 -1
- package/lib/stores/filter/operators/QueryBuilderFilterOperatorValueSpecificationBuilder.d.ts +1 -1
- package/lib/stores/filter/operators/QueryBuilderFilterOperatorValueSpecificationBuilder.d.ts.map +1 -1
- package/lib/stores/filter/operators/QueryBuilderFilterOperatorValueSpecificationBuilder.js +12 -192
- package/lib/stores/filter/operators/QueryBuilderFilterOperatorValueSpecificationBuilder.js.map +1 -1
- package/lib/stores/filter/operators/QueryBuilderFilterOperator_Contain.d.ts +2 -2
- package/lib/stores/filter/operators/QueryBuilderFilterOperator_Contain.d.ts.map +1 -1
- package/lib/stores/filter/operators/QueryBuilderFilterOperator_Contain.js +4 -4
- package/lib/stores/filter/operators/QueryBuilderFilterOperator_Contain.js.map +1 -1
- package/lib/stores/filter/operators/QueryBuilderFilterOperator_EndWith.d.ts +2 -2
- package/lib/stores/filter/operators/QueryBuilderFilterOperator_EndWith.d.ts.map +1 -1
- package/lib/stores/filter/operators/QueryBuilderFilterOperator_EndWith.js +4 -4
- package/lib/stores/filter/operators/QueryBuilderFilterOperator_EndWith.js.map +1 -1
- package/lib/stores/filter/operators/QueryBuilderFilterOperator_Equal.d.ts +2 -2
- package/lib/stores/filter/operators/QueryBuilderFilterOperator_Equal.d.ts.map +1 -1
- package/lib/stores/filter/operators/QueryBuilderFilterOperator_Equal.js +4 -4
- package/lib/stores/filter/operators/QueryBuilderFilterOperator_Equal.js.map +1 -1
- package/lib/stores/filter/operators/QueryBuilderFilterOperator_GreaterThan.d.ts +1 -1
- package/lib/stores/filter/operators/QueryBuilderFilterOperator_GreaterThan.d.ts.map +1 -1
- package/lib/stores/filter/operators/QueryBuilderFilterOperator_GreaterThan.js +2 -2
- package/lib/stores/filter/operators/QueryBuilderFilterOperator_GreaterThan.js.map +1 -1
- package/lib/stores/filter/operators/QueryBuilderFilterOperator_GreaterThanEqual.d.ts +1 -1
- package/lib/stores/filter/operators/QueryBuilderFilterOperator_GreaterThanEqual.d.ts.map +1 -1
- package/lib/stores/filter/operators/QueryBuilderFilterOperator_GreaterThanEqual.js +2 -2
- package/lib/stores/filter/operators/QueryBuilderFilterOperator_GreaterThanEqual.js.map +1 -1
- package/lib/stores/filter/operators/QueryBuilderFilterOperator_In.d.ts +2 -2
- package/lib/stores/filter/operators/QueryBuilderFilterOperator_In.d.ts.map +1 -1
- package/lib/stores/filter/operators/QueryBuilderFilterOperator_In.js +4 -4
- package/lib/stores/filter/operators/QueryBuilderFilterOperator_In.js.map +1 -1
- package/lib/stores/filter/operators/QueryBuilderFilterOperator_IsEmpty.d.ts +2 -2
- package/lib/stores/filter/operators/QueryBuilderFilterOperator_IsEmpty.d.ts.map +1 -1
- package/lib/stores/filter/operators/QueryBuilderFilterOperator_IsEmpty.js +4 -4
- package/lib/stores/filter/operators/QueryBuilderFilterOperator_IsEmpty.js.map +1 -1
- package/lib/stores/filter/operators/QueryBuilderFilterOperator_LessThan.d.ts +1 -1
- package/lib/stores/filter/operators/QueryBuilderFilterOperator_LessThan.d.ts.map +1 -1
- package/lib/stores/filter/operators/QueryBuilderFilterOperator_LessThan.js +2 -2
- package/lib/stores/filter/operators/QueryBuilderFilterOperator_LessThan.js.map +1 -1
- package/lib/stores/filter/operators/QueryBuilderFilterOperator_LessThanEqual.d.ts +1 -1
- package/lib/stores/filter/operators/QueryBuilderFilterOperator_LessThanEqual.d.ts.map +1 -1
- package/lib/stores/filter/operators/QueryBuilderFilterOperator_LessThanEqual.js +2 -2
- package/lib/stores/filter/operators/QueryBuilderFilterOperator_LessThanEqual.js.map +1 -1
- package/lib/stores/filter/operators/QueryBuilderFilterOperator_StartWith.d.ts +2 -2
- package/lib/stores/filter/operators/QueryBuilderFilterOperator_StartWith.d.ts.map +1 -1
- package/lib/stores/filter/operators/QueryBuilderFilterOperator_StartWith.js +4 -4
- package/lib/stores/filter/operators/QueryBuilderFilterOperator_StartWith.js.map +1 -1
- package/package.json +14 -14
- package/src/components/filter/QueryBuilderFilterPanel.tsx +355 -24
- package/src/stores/QueryBuilderStateHashUtils.ts +1 -0
- package/src/stores/filter/QueryBuilderFilterOperator.ts +1 -0
- package/src/stores/filter/QueryBuilderFilterState.ts +115 -27
- package/src/stores/filter/QueryBuilderFilterStateBuilder.ts +244 -0
- package/src/stores/filter/QueryBuilderFilterValueSpecificationBuilder.ts +94 -1
- package/src/stores/filter/operators/QueryBuilderFilterOperatorValueSpecificationBuilder.ts +37 -377
- package/src/stores/filter/operators/QueryBuilderFilterOperator_Contain.ts +7 -1
- package/src/stores/filter/operators/QueryBuilderFilterOperator_EndWith.ts +7 -1
- package/src/stores/filter/operators/QueryBuilderFilterOperator_Equal.ts +7 -1
- package/src/stores/filter/operators/QueryBuilderFilterOperator_GreaterThan.ts +2 -0
- package/src/stores/filter/operators/QueryBuilderFilterOperator_GreaterThanEqual.ts +2 -0
- package/src/stores/filter/operators/QueryBuilderFilterOperator_In.ts +7 -1
- package/src/stores/filter/operators/QueryBuilderFilterOperator_IsEmpty.ts +7 -1
- package/src/stores/filter/operators/QueryBuilderFilterOperator_LessThan.ts +2 -0
- package/src/stores/filter/operators/QueryBuilderFilterOperator_LessThanEqual.ts +2 -0
- package/src/stores/filter/operators/QueryBuilderFilterOperator_StartWith.ts +7 -1
@@ -13,12 +13,25 @@
|
|
13
13
|
* See the License for the specific language governing permissions and
|
14
14
|
* limitations under the License.
|
15
15
|
*/
|
16
|
-
import { AbstractPropertyExpression, LambdaFunctionInstanceValue, matchFunctionName, SimpleFunctionExpression, VariableExpression, } from '@finos/legend-graph';
|
16
|
+
import { AbstractPropertyExpression, extractElementNameFromPath, LambdaFunction, LambdaFunctionInstanceValue, matchFunctionName, SimpleFunctionExpression, VariableExpression, } from '@finos/legend-graph';
|
17
17
|
import { assertTrue, assertType, guaranteeNonNullable, guaranteeType, returnUndefOnError, UnsupportedOperationError, } from '@finos/legend-shared';
|
18
18
|
import { QUERY_BUILDER_SUPPORTED_FUNCTIONS } from '../../graph/QueryBuilderMetaModelConst.js';
|
19
19
|
import { toGroupOperation } from '../QueryBuilderGroupOperationHelper.js';
|
20
20
|
import { validatePropertyExpressionChain } from '../QueryBuilderValueSpecificationHelper.js';
|
21
|
-
import { QueryBuilderFilterTreeConditionNodeData, QueryBuilderFilterTreeGroupNodeData, } from './QueryBuilderFilterState.js';
|
21
|
+
import { QueryBuilderFilterTreeConditionNodeData, QueryBuilderFilterTreeGroupNodeData, QueryBuilderFilterTreeExistsNodeData, QueryBuilderFilterTreeOperationNodeData, } from './QueryBuilderFilterState.js';
|
22
|
+
const getPropertyExpressionChainVariable = (propertyExpression) => {
|
23
|
+
let currentExpression = propertyExpression;
|
24
|
+
while (currentExpression instanceof AbstractPropertyExpression) {
|
25
|
+
currentExpression = guaranteeNonNullable(currentExpression.parametersValues[0]);
|
26
|
+
// Take care of chains of subtype (a pattern that is not useful, but we want to support and rectify)
|
27
|
+
// $x.employees->subType(@Person)->subType(@Staff)
|
28
|
+
while (currentExpression instanceof SimpleFunctionExpression &&
|
29
|
+
matchFunctionName(currentExpression.functionName, QUERY_BUILDER_SUPPORTED_FUNCTIONS.SUBTYPE)) {
|
30
|
+
currentExpression = guaranteeNonNullable(currentExpression.parametersValues[0]);
|
31
|
+
}
|
32
|
+
}
|
33
|
+
return guaranteeType(currentExpression, VariableExpression);
|
34
|
+
};
|
22
35
|
const processFilterTree = (expression, filterState, parentFilterNodeId) => {
|
23
36
|
const parentNode = parentFilterNodeId
|
24
37
|
? filterState.getNode(parentFilterNodeId)
|
@@ -29,9 +42,113 @@ const processFilterTree = (expression, filterState, parentFilterNodeId) => {
|
|
29
42
|
])) {
|
30
43
|
const groupNode = new QueryBuilderFilterTreeGroupNodeData(parentFilterNodeId, toGroupOperation(expression.functionName));
|
31
44
|
filterState.nodes.set(groupNode.id, groupNode);
|
45
|
+
if (parentNode) {
|
46
|
+
groupNode.lambdaParameterName = guaranteeType(parentNode, QueryBuilderFilterTreeOperationNodeData).lambdaParameterName;
|
47
|
+
}
|
32
48
|
expression.parametersValues.forEach((filterExpression) => processFilterTree(guaranteeType(filterExpression, SimpleFunctionExpression, `Can't process filter group expression: each child expression must be a function expression`), filterState, groupNode.id));
|
33
49
|
filterState.addNodeFromNode(groupNode, parentNode);
|
34
50
|
}
|
51
|
+
else if (matchFunctionName(expression.functionName, [
|
52
|
+
QUERY_BUILDER_SUPPORTED_FUNCTIONS.EXISTS,
|
53
|
+
])) {
|
54
|
+
const propertyExpression = guaranteeType(expression.parametersValues[0], AbstractPropertyExpression);
|
55
|
+
if (propertyExpression.func.value.multiplicity.upperBound === undefined ||
|
56
|
+
propertyExpression.func.value.multiplicity.upperBound > 1) {
|
57
|
+
const existsNode = new QueryBuilderFilterTreeExistsNodeData(parentFilterNodeId);
|
58
|
+
const lambdaFunctionInstance = guaranteeType(expression.parametersValues[1], LambdaFunctionInstanceValue, `Can't process filter expression: only supports exists with second paramter as LambdaFunctionInstanceValue`);
|
59
|
+
const lambdaFunction = guaranteeType(lambdaFunctionInstance.values[0], LambdaFunction);
|
60
|
+
const filterExpression = guaranteeType(lambdaFunction.expressionSequence[0], SimpleFunctionExpression);
|
61
|
+
existsNode.setPropertyExpression(propertyExpression);
|
62
|
+
existsNode.lambdaParameterName =
|
63
|
+
lambdaFunction.functionType.parameters[0]?.name;
|
64
|
+
filterState.nodes.set(existsNode.id, existsNode);
|
65
|
+
processFilterTree(filterExpression, filterState, existsNode.id);
|
66
|
+
filterState.addNodeFromNode(existsNode, parentNode);
|
67
|
+
}
|
68
|
+
else {
|
69
|
+
// Build property chain if we have exists filter() and the multiplicity of the property
|
70
|
+
// is of multiplicity less than or equal to one. This will auto-fix the exists into the
|
71
|
+
// desired filter expression
|
72
|
+
// 1. Decompose the exists() lambda chain into property expression chains
|
73
|
+
const existsLambdaParameterNames = [];
|
74
|
+
const existsLambdaExpressions = [];
|
75
|
+
let mainFilterExpression = expression;
|
76
|
+
while (matchFunctionName(mainFilterExpression.functionName, QUERY_BUILDER_SUPPORTED_FUNCTIONS.EXISTS)) {
|
77
|
+
const existsLambda = guaranteeNonNullable(guaranteeType(mainFilterExpression.parametersValues[1], LambdaFunctionInstanceValue).values[0], `Can't process exists() expression: exists() lambda is missing`);
|
78
|
+
assertTrue(existsLambda.expressionSequence.length === 1, `Can't process exists() expression: exists() lambda body should hold an expression`);
|
79
|
+
mainFilterExpression = guaranteeType(existsLambda.expressionSequence[0], SimpleFunctionExpression, `Can't process exists() expression: exists() lambda body should hold an expression`);
|
80
|
+
// record the lambda parameter name
|
81
|
+
assertTrue(existsLambda.functionType.parameters.length === 1, `Can't process exists() expression: exists() lambda should have 1 parameter`);
|
82
|
+
existsLambdaParameterNames.push(guaranteeType(existsLambda.functionType.parameters[0], VariableExpression, `Can't process exists() expression: exists() lambda should have 1 parameter`).name);
|
83
|
+
// record the lambda property expression
|
84
|
+
if (mainFilterExpression.parametersValues[0] instanceof
|
85
|
+
AbstractPropertyExpression &&
|
86
|
+
!(mainFilterExpression.parametersValues[0].func.value.multiplicity
|
87
|
+
.upperBound === undefined ||
|
88
|
+
mainFilterExpression.parametersValues[0].func.value.multiplicity
|
89
|
+
.upperBound > 1)) {
|
90
|
+
existsLambdaExpressions.push(mainFilterExpression.parametersValues[0]);
|
91
|
+
}
|
92
|
+
else {
|
93
|
+
break;
|
94
|
+
}
|
95
|
+
}
|
96
|
+
// 2. Build the property expression
|
97
|
+
const initialPropertyExpression = guaranteeType(expression.parametersValues[0], AbstractPropertyExpression);
|
98
|
+
let flattenedPropertyExpressionChain = new AbstractPropertyExpression('');
|
99
|
+
flattenedPropertyExpressionChain.func = initialPropertyExpression.func;
|
100
|
+
flattenedPropertyExpressionChain.parametersValues = [
|
101
|
+
...initialPropertyExpression.parametersValues,
|
102
|
+
];
|
103
|
+
for (const exp of existsLambdaExpressions) {
|
104
|
+
// when rebuilding the property expression chain, disregard the initial variable that starts the chain
|
105
|
+
const expressions = [];
|
106
|
+
let currentExpression = exp;
|
107
|
+
while (currentExpression instanceof AbstractPropertyExpression ||
|
108
|
+
(currentExpression instanceof SimpleFunctionExpression &&
|
109
|
+
matchFunctionName(currentExpression.functionName, QUERY_BUILDER_SUPPORTED_FUNCTIONS.SUBTYPE))) {
|
110
|
+
if (currentExpression instanceof SimpleFunctionExpression) {
|
111
|
+
const functionExpression = new SimpleFunctionExpression(extractElementNameFromPath(QUERY_BUILDER_SUPPORTED_FUNCTIONS.SUBTYPE));
|
112
|
+
functionExpression.parametersValues.unshift(guaranteeNonNullable(currentExpression.parametersValues[1]));
|
113
|
+
expressions.push(functionExpression);
|
114
|
+
}
|
115
|
+
else if (currentExpression instanceof AbstractPropertyExpression) {
|
116
|
+
const propertyExp = new AbstractPropertyExpression('');
|
117
|
+
propertyExp.func = currentExpression.func;
|
118
|
+
// NOTE: we must retain the rest of the parameters as those are derived property parameters
|
119
|
+
propertyExp.parametersValues =
|
120
|
+
currentExpression.parametersValues.length > 1
|
121
|
+
? currentExpression.parametersValues.slice(1)
|
122
|
+
: [];
|
123
|
+
expressions.push(propertyExp);
|
124
|
+
}
|
125
|
+
currentExpression = guaranteeNonNullable(currentExpression.parametersValues[0]);
|
126
|
+
}
|
127
|
+
assertTrue(expressions.length > 0, `Can't process exists() expression: exists() usage with non-chain property expression is not supported`);
|
128
|
+
for (let i = 0; i < expressions.length - 1; ++i) {
|
129
|
+
expressions[i].parametersValues.unshift(expressions[i + 1]);
|
130
|
+
}
|
131
|
+
expressions[expressions.length - 1].parametersValues.unshift(flattenedPropertyExpressionChain);
|
132
|
+
flattenedPropertyExpressionChain = guaranteeType(expressions[0], AbstractPropertyExpression, `Can't process exists() expression: can't flatten to a property expression`);
|
133
|
+
}
|
134
|
+
mainFilterExpression.parametersValues =
|
135
|
+
mainFilterExpression.parametersValues.map((p) => {
|
136
|
+
if (p instanceof SimpleFunctionExpression &&
|
137
|
+
p.parametersValues[0] instanceof AbstractPropertyExpression) {
|
138
|
+
p.parametersValues[0].parametersValues[0] =
|
139
|
+
flattenedPropertyExpressionChain;
|
140
|
+
}
|
141
|
+
else if (p instanceof AbstractPropertyExpression) {
|
142
|
+
p.parametersValues[0] = guaranteeNonNullable(flattenedPropertyExpressionChain.parametersValues[0]);
|
143
|
+
}
|
144
|
+
else if (p instanceof VariableExpression) {
|
145
|
+
return flattenedPropertyExpressionChain;
|
146
|
+
}
|
147
|
+
return p;
|
148
|
+
});
|
149
|
+
processFilterTree(mainFilterExpression, filterState, parentFilterNodeId);
|
150
|
+
}
|
151
|
+
}
|
35
152
|
else {
|
36
153
|
const propertyExpression = expression.parametersValues[0];
|
37
154
|
if (propertyExpression instanceof AbstractPropertyExpression) {
|
@@ -46,6 +163,12 @@ const processFilterTree = (expression, filterState, parentFilterNodeId) => {
|
|
46
163
|
// considered as not supporting the lambda.
|
47
164
|
const filterConditionState = returnUndefOnError(() => operator.buildFilterConditionState(filterState, expression));
|
48
165
|
if (filterConditionState) {
|
166
|
+
const variableName = getPropertyExpressionChainVariable(filterConditionState.propertyExpressionState.propertyExpression).name;
|
167
|
+
const parentLambdaVariableName = parentNode instanceof QueryBuilderFilterTreeOperationNodeData &&
|
168
|
+
parentNode.lambdaParameterName
|
169
|
+
? parentNode.lambdaParameterName
|
170
|
+
: filterState.lambdaParameterName;
|
171
|
+
assertTrue(parentLambdaVariableName === variableName, `Can't process ${extractElementNameFromPath(filterConditionState.operator.getLabel(filterConditionState))}() expression: expects variable used in lambda body '${variableName}' to match lambda parameter '${parentLambdaVariableName}'`);
|
49
172
|
filterState.addNodeFromNode(new QueryBuilderFilterTreeConditionNodeData(undefined, filterConditionState), parentNode);
|
50
173
|
return;
|
51
174
|
}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"QueryBuilderFilterStateBuilder.js","sourceRoot":"","sources":["../../../src/stores/filter/QueryBuilderFilterStateBuilder.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EACL,0BAA0B,EAC1B,2BAA2B,EAC3B,iBAAiB,EACjB,wBAAwB,
|
1
|
+
{"version":3,"file":"QueryBuilderFilterStateBuilder.js","sourceRoot":"","sources":["../../../src/stores/filter/QueryBuilderFilterStateBuilder.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EACL,0BAA0B,EAC1B,0BAA0B,EAC1B,cAAc,EACd,2BAA2B,EAC3B,iBAAiB,EACjB,wBAAwB,EAExB,kBAAkB,GACnB,MAAM,qBAAqB,CAAC;AAC7B,OAA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AAG,aAAa,CAClC,UAAU,CAAC,kBAAkB,CAAC,CAAC,CAAC,EAChC,wBAAwB,EACxB,oFAAoF,CACrF,CAAC;IAEF,UAAU,CACR,UAAU,CAAC,YAAY,CAAC,UAAU,CAAC,MAAM,KAAK,CAAC,EAC/C,8EAA8E,CAC/E,CAAC;IACF,WAAW,CAAC,sBAAsB,CAChC,aAAa,CACX,UAAU,CAAC,YAAY,CAAC,UAAU,CAAC,CAAC,CAAC,EACrC,kBAAkB,EAClB,8EAA8E,CAC/E,CAAC,IAAI,CACP,CAAC;IAEF,iBAAiB,CAAC,cAAc,EAAE,WAAW,EAAE,SAAS,CAAC,CAAC;IAE1D;;;;;OAKG;IACH,WAAW,CAAC,YAAY,EAAE,CAAC;AAC7B,CAAC,CAAC"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"QueryBuilderFilterValueSpecificationBuilder.d.ts","sourceRoot":"","sources":["../../../src/stores/filter/QueryBuilderFilterValueSpecificationBuilder.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;
|
1
|
+
{"version":3,"file":"QueryBuilderFilterValueSpecificationBuilder.d.ts","sourceRoot":"","sources":["../../../src/stores/filter/QueryBuilderFilterValueSpecificationBuilder.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAOH,OAAO,EAEL,KAAK,cAAc,EAGpB,MAAM,qBAAqB,CAAC;AAG7B,OAAO,EACL,KAAK,uBAAuB,EAM7B,MAAM,8BAA8B,CAAC;AA0ItC,eAAO,MAAM,qBAAqB,gBACnB,uBAAuB,kBACpB,cAAc,KAC7B,IA4BF,CAAC"}
|
@@ -13,15 +13,19 @@
|
|
13
13
|
* See the License for the specific language governing permissions and
|
14
14
|
* limitations under the License.
|
15
15
|
*/
|
16
|
-
import { isNonNullable, guaranteeNonNullable } from '@finos/legend-shared';
|
16
|
+
import { isNonNullable, guaranteeNonNullable, guaranteeType, } from '@finos/legend-shared';
|
17
17
|
import { extractElementNameFromPath, SimpleFunctionExpression, } from '@finos/legend-graph';
|
18
18
|
import { buildGenericLambdaFunctionInstanceValue } from '../QueryBuilderValueSpecificationHelper.js';
|
19
19
|
import { fromGroupOperation } from '../QueryBuilderGroupOperationHelper.js';
|
20
|
-
import { QueryBuilderFilterTreeConditionNodeData, QueryBuilderFilterTreeGroupNodeData, } from './QueryBuilderFilterState.js';
|
20
|
+
import { QueryBuilderFilterTreeConditionNodeData, QueryBuilderFilterTreeGroupNodeData, QueryBuilderFilterTreeExistsNodeData, QueryBuilderFilterTreeOperationNodeData, } from './QueryBuilderFilterState.js';
|
21
21
|
import { QUERY_BUILDER_SUPPORTED_FUNCTIONS } from '../../graph/QueryBuilderMetaModelConst.js';
|
22
|
+
import { DEFAULT_LAMBDA_VARIABLE_NAME } from '../QueryBuilderConfig.js';
|
22
23
|
const buildFilterConditionExpression = (filterState, node) => {
|
23
24
|
if (node instanceof QueryBuilderFilterTreeConditionNodeData) {
|
24
|
-
|
25
|
+
const parentNode = node.parentId
|
26
|
+
? guaranteeType(filterState.nodes.get(node.parentId), QueryBuilderFilterTreeOperationNodeData)
|
27
|
+
: undefined;
|
28
|
+
return node.condition.operator.buildFilterConditionExpression(node.condition, parentNode?.lambdaParameterName);
|
25
29
|
}
|
26
30
|
else if (node instanceof QueryBuilderFilterTreeGroupNodeData) {
|
27
31
|
const func = new SimpleFunctionExpression(extractElementNameFromPath(fromGroupOperation(node.groupOperation)));
|
@@ -55,6 +59,61 @@ const buildFilterConditionExpression = (filterState, node) => {
|
|
55
59
|
}
|
56
60
|
return func.parametersValues.length ? func : undefined;
|
57
61
|
}
|
62
|
+
else if (node instanceof QueryBuilderFilterTreeExistsNodeData) {
|
63
|
+
const func = new SimpleFunctionExpression(extractElementNameFromPath(QUERY_BUILDER_SUPPORTED_FUNCTIONS.EXISTS));
|
64
|
+
let parentNode = node.parentId
|
65
|
+
? guaranteeType(filterState.nodes.get(guaranteeNonNullable(node.parentId)), QueryBuilderFilterTreeOperationNodeData)
|
66
|
+
: undefined;
|
67
|
+
while (parentNode &&
|
68
|
+
!(parentNode instanceof QueryBuilderFilterTreeGroupNodeData)) {
|
69
|
+
parentNode = parentNode.parentId
|
70
|
+
? guaranteeType(filterState.nodes.get(guaranteeNonNullable(parentNode.parentId)), QueryBuilderFilterTreeOperationNodeData)
|
71
|
+
: undefined;
|
72
|
+
}
|
73
|
+
const propertyExpression = guaranteeNonNullable(node.propertyExpression);
|
74
|
+
const clauses = node.childrenIds
|
75
|
+
.map((e) => filterState.nodes.get(e))
|
76
|
+
.filter(isNonNullable)
|
77
|
+
.map((e) => buildFilterConditionExpression(filterState, e))
|
78
|
+
.filter(isNonNullable);
|
79
|
+
/**
|
80
|
+
* NOTE: Due to a limitation (or perhaps design decision) in the engine, group operations
|
81
|
+
* like and/or do not take more than 2 parameters, as such, if we have more than 2, we need
|
82
|
+
* to create a chain of this operation to accomondate.
|
83
|
+
*
|
84
|
+
* This means that in the read direction, we might need to flatten the chains down to group with
|
85
|
+
* multiple clauses. This means user's intended grouping will not be kept.
|
86
|
+
*/
|
87
|
+
let parametersValues;
|
88
|
+
if (clauses.length > 2) {
|
89
|
+
const firstClause = clauses[0];
|
90
|
+
let currentClause = clauses[clauses.length - 1];
|
91
|
+
for (let i = clauses.length - 2; i > 0; --i) {
|
92
|
+
const clause1 = clauses[i];
|
93
|
+
const clause2 = currentClause;
|
94
|
+
const groupClause = new SimpleFunctionExpression(guaranteeNonNullable(parentNode).groupOperation);
|
95
|
+
groupClause.parametersValues = [clause1, clause2];
|
96
|
+
currentClause = groupClause;
|
97
|
+
}
|
98
|
+
parametersValues = [firstClause, currentClause];
|
99
|
+
}
|
100
|
+
else if (clauses.length === 1) {
|
101
|
+
const lambdaFunctionInstanceValue = buildGenericLambdaFunctionInstanceValue(node.lambdaParameterName ?? DEFAULT_LAMBDA_VARIABLE_NAME, clauses, filterState.queryBuilderState.graphManagerState.graph);
|
102
|
+
func.parametersValues = [propertyExpression, lambdaFunctionInstanceValue];
|
103
|
+
return func;
|
104
|
+
}
|
105
|
+
else {
|
106
|
+
parametersValues = clauses;
|
107
|
+
}
|
108
|
+
if (!parametersValues.length) {
|
109
|
+
return undefined;
|
110
|
+
}
|
111
|
+
const simp = new SimpleFunctionExpression(extractElementNameFromPath(fromGroupOperation(guaranteeNonNullable(parentNode).groupOperation)));
|
112
|
+
simp.parametersValues = parametersValues;
|
113
|
+
const lambdaFunctionInstanceValue = buildGenericLambdaFunctionInstanceValue(node.lambdaParameterName ?? DEFAULT_LAMBDA_VARIABLE_NAME, [simp], filterState.queryBuilderState.graphManagerState.graph);
|
114
|
+
func.parametersValues = [propertyExpression, lambdaFunctionInstanceValue];
|
115
|
+
return func;
|
116
|
+
}
|
58
117
|
return undefined;
|
59
118
|
};
|
60
119
|
export const buildFilterExpression = (filterState, lambdaFunction) => {
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"QueryBuilderFilterValueSpecificationBuilder.js","sourceRoot":"","sources":["../../../src/stores/filter/QueryBuilderFilterValueSpecificationBuilder.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,
|
1
|
+
{"version":3,"file":"QueryBuilderFilterValueSpecificationBuilder.js","sourceRoot":"","sources":["../../../src/stores/filter/QueryBuilderFilterValueSpecificationBuilder.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EACL,aAAa,EACb,oBAAoB,EACpB,aAAa,GACd,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAGL,0BAA0B,EAC1B,wBAAwB,GACzB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,uCAAuC,EAAE,MAAM,4CAA4C,CAAC;AACrG,OAAO,EAAE,kBAAkB,EAAE,MAAM,wCAAwC,CAAC;AAC5E,OAAO,EAEL,uCAAuC,EACvC,mCAAmC,EAEnC,oCAAoC,EACpC,uCAAuC,GACxC,MAAM,8BAA8B,CAAC;AACtC,OAAO,EAAE,iCAAiC,EAAE,MAA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C,MAAM,CAAC,CACrE,CAAC;IACF,MAAM,iBAAiB,GAAG,oBAAoB,CAC5C,cAAc,CAAC,kBAAkB,CAAC,CAAC,CAAC,CACrC,CAAC;IACF,YAAY;IACZ,gBAAgB,CAAC,gBAAgB,CAAC,IAAI,CAAC,iBAAiB,CAAC,CAAC;IAC1D,YAAY;IACZ,gBAAgB,CAAC,gBAAgB,CAAC,IAAI,CACpC,uCAAuC,CACrC,WAAW,CAAC,mBAAmB,EAC/B,0BAA0B,EAC1B,WAAW,CAAC,iBAAiB,CAAC,iBAAiB,CAAC,KAAK,CACtD,CACF,CAAC;IACF,sCAAsC;IACtC,cAAc,CAAC,kBAAkB,CAAC,CAAC,CAAC,GAAG,gBAAgB,CAAC;AAC1D,CAAC,CAAC"}
|
package/lib/stores/filter/operators/QueryBuilderFilterOperatorValueSpecificationBuilder.d.ts
CHANGED
@@ -16,6 +16,6 @@
|
|
16
16
|
import { type ValueSpecification, SimpleFunctionExpression } from '@finos/legend-graph';
|
17
17
|
import { FilterConditionState, type QueryBuilderFilterState } from '../QueryBuilderFilterState.js';
|
18
18
|
import type { QueryBuilderFilterOperator } from '../QueryBuilderFilterOperator.js';
|
19
|
-
export declare const buildFilterConditionExpression: (filterConditionState: FilterConditionState, operatorFunctionFullPath: string) => ValueSpecification;
|
19
|
+
export declare const buildFilterConditionExpression: (filterConditionState: FilterConditionState, operatorFunctionFullPath: string, lambdaParameterName?: string | undefined) => ValueSpecification;
|
20
20
|
export declare const buildFilterConditionState: (filterState: QueryBuilderFilterState, expression: SimpleFunctionExpression, operatorFunctionFullPath: string, operator: QueryBuilderFilterOperator, hasNoValue?: boolean) => FilterConditionState | undefined;
|
21
21
|
//# sourceMappingURL=QueryBuilderFilterOperatorValueSpecificationBuilder.d.ts.map
|
package/lib/stores/filter/operators/QueryBuilderFilterOperatorValueSpecificationBuilder.d.ts.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"QueryBuilderFilterOperatorValueSpecificationBuilder.d.ts","sourceRoot":"","sources":["../../../../src/stores/filter/operators/QueryBuilderFilterOperatorValueSpecificationBuilder.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EACL,KAAK,kBAAkB,
|
1
|
+
{"version":3,"file":"QueryBuilderFilterOperatorValueSpecificationBuilder.d.ts","sourceRoot":"","sources":["../../../../src/stores/filter/operators/QueryBuilderFilterOperatorValueSpecificationBuilder.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EACL,KAAK,kBAAkB,EAKvB,wBAAwB,EAEzB,MAAM,qBAAqB,CAAC;AAM7B,OAAO,EACL,oBAAoB,EACpB,KAAK,uBAAuB,EAC7B,MAAM,+BAA+B,CAAC;AAGvC,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,kCAAkC,CAAC;AAGnF,eAAO,MAAM,8BAA8B,yBACnB,oBAAoB,4BAChB,MAAM,wBACV,MAAM,GAAG,SAAS,KACvC,kBAeF,CAAC;AAEF,eAAO,MAAM,yBAAyB,gBACvB,uBAAuB,cACxB,wBAAwB,4BACV,MAAM,YACtB,0BAA0B,2BAOnC,oBAAoB,GAAG,SAuGzB,CAAC"}
|
@@ -13,114 +13,15 @@
|
|
13
13
|
* See the License for the specific language governing permissions and
|
14
14
|
* limitations under the License.
|
15
15
|
*/
|
16
|
-
import { extractElementNameFromPath, matchFunctionName, LambdaFunctionInstanceValue,
|
17
|
-
import { guaranteeType, guaranteeNonNullable, assertTrue,
|
16
|
+
import { extractElementNameFromPath, matchFunctionName, LambdaFunctionInstanceValue, AbstractPropertyExpression, SimpleFunctionExpression, LambdaFunction, } from '@finos/legend-graph';
|
17
|
+
import { guaranteeType, guaranteeNonNullable, assertTrue, } from '@finos/legend-shared';
|
18
18
|
import { FilterConditionState, } from '../QueryBuilderFilterState.js';
|
19
19
|
import { QUERY_BUILDER_SUPPORTED_FUNCTIONS } from '../../../graph/QueryBuilderMetaModelConst.js';
|
20
|
-
import {
|
20
|
+
import { simplifyValueExpression } from '../../QueryBuilderValueSpecificationHelper.js';
|
21
21
|
import { buildPropertyExpressionChain } from '../../QueryBuilderValueSpecificationBuilderHelper.js';
|
22
|
-
const
|
23
|
-
let currentExpression = propertyExpression;
|
24
|
-
while (currentExpression instanceof AbstractPropertyExpression) {
|
25
|
-
currentExpression = guaranteeNonNullable(currentExpression.parametersValues[0]);
|
26
|
-
// Take care of chains of subtype (a pattern that is not useful, but we want to support and rectify)
|
27
|
-
// $x.employees->subType(@Person)->subType(@Staff)
|
28
|
-
while (currentExpression instanceof SimpleFunctionExpression &&
|
29
|
-
matchFunctionName(currentExpression.functionName, QUERY_BUILDER_SUPPORTED_FUNCTIONS.SUBTYPE)) {
|
30
|
-
currentExpression = guaranteeNonNullable(currentExpression.parametersValues[0]);
|
31
|
-
}
|
32
|
-
}
|
33
|
-
return guaranteeType(currentExpression, VariableExpression);
|
34
|
-
};
|
35
|
-
const buildFilterConditionExpressionWithExists = (filterConditionState, operatorFunctionFullPath) => {
|
36
|
-
assertTrue(filterConditionState.propertyExpressionState.requiresExistsHandling);
|
37
|
-
// 1. Decompose property expression
|
38
|
-
const expressions = [];
|
39
|
-
let currentPropertyExpression = buildPropertyExpressionChain(filterConditionState.propertyExpressionState.propertyExpression, filterConditionState.propertyExpressionState.queryBuilderState, filterConditionState.filterState.lambdaParameterName);
|
40
|
-
while (currentPropertyExpression instanceof AbstractPropertyExpression ||
|
41
|
-
(currentPropertyExpression instanceof SimpleFunctionExpression &&
|
42
|
-
matchFunctionName(currentPropertyExpression.functionName, QUERY_BUILDER_SUPPORTED_FUNCTIONS.SUBTYPE))) {
|
43
|
-
let exp;
|
44
|
-
if (currentPropertyExpression instanceof SimpleFunctionExpression) {
|
45
|
-
exp = new SimpleFunctionExpression(extractElementNameFromPath(QUERY_BUILDER_SUPPORTED_FUNCTIONS.SUBTYPE));
|
46
|
-
}
|
47
|
-
else {
|
48
|
-
exp = new AbstractPropertyExpression('');
|
49
|
-
exp.func = currentPropertyExpression.func;
|
50
|
-
}
|
51
|
-
// NOTE: we must retain the rest of the parameters as those are derived property parameters
|
52
|
-
exp.parametersValues =
|
53
|
-
currentPropertyExpression.parametersValues.length > 1
|
54
|
-
? currentPropertyExpression.parametersValues.slice(1)
|
55
|
-
: [];
|
56
|
-
expressions.push(exp);
|
57
|
-
currentPropertyExpression = guaranteeNonNullable(currentPropertyExpression.parametersValues[0]);
|
58
|
-
}
|
59
|
-
const rootVariable = guaranteeType(currentPropertyExpression, VariableExpression);
|
60
|
-
// 2. Traverse the list of decomposed property expression backward, every time we encounter a property of
|
61
|
-
// multiplicity many, create a new property expression and keep track of it to later form the lambda chain
|
62
|
-
const existsLambdaParamNames = [
|
63
|
-
...filterConditionState.existsLambdaParamNames,
|
64
|
-
];
|
65
|
-
const existsLambdaPropertyChains = [rootVariable];
|
66
|
-
let currentParamNameIndex = 0;
|
67
|
-
for (let i = expressions.length - 1; i >= 0; --i) {
|
68
|
-
const exp = expressions[i];
|
69
|
-
// just keep adding to the property chain
|
70
|
-
exp.parametersValues.unshift(existsLambdaPropertyChains[existsLambdaPropertyChains.length - 1]);
|
71
|
-
existsLambdaPropertyChains[existsLambdaPropertyChains.length - 1] = exp;
|
72
|
-
// ... but if the property is of multiplicity multiple, start a new property chain
|
73
|
-
if (exp instanceof AbstractPropertyExpression &&
|
74
|
-
(exp.func.value.multiplicity.upperBound === undefined ||
|
75
|
-
exp.func.value.multiplicity.upperBound > 1)) {
|
76
|
-
// NOTE: we need to find/generate the property chain variable name
|
77
|
-
// here, by doing this, we try our best to respect original/user-input variable name
|
78
|
-
if (currentParamNameIndex > existsLambdaParamNames.length - 1) {
|
79
|
-
existsLambdaParamNames.push(generateEnumerableNameFromToken(existsLambdaParamNames, filterConditionState.filterState.lambdaParameterName));
|
80
|
-
assertTrue(currentParamNameIndex === existsLambdaParamNames.length - 1);
|
81
|
-
}
|
82
|
-
existsLambdaPropertyChains.push(new VariableExpression(existsLambdaParamNames[currentParamNameIndex], Multiplicity.ONE));
|
83
|
-
currentParamNameIndex++;
|
84
|
-
}
|
85
|
-
}
|
86
|
-
// 3. Build each property chain into an exists() simple function expression
|
87
|
-
const simpleFunctionExpressions = [];
|
88
|
-
for (let i = 0; i < existsLambdaPropertyChains.length - 1; ++i) {
|
89
|
-
const simpleFunctionExpression = new SimpleFunctionExpression(extractElementNameFromPath(QUERY_BUILDER_SUPPORTED_FUNCTIONS.EXISTS));
|
90
|
-
simpleFunctionExpression.parametersValues.push(existsLambdaPropertyChains[i]);
|
91
|
-
simpleFunctionExpressions.push(simpleFunctionExpression);
|
92
|
-
}
|
93
|
-
// build the leaf simple function expression which uses the operator
|
94
|
-
const operatorEpression = new SimpleFunctionExpression(extractElementNameFromPath(operatorFunctionFullPath));
|
95
|
-
operatorEpression.parametersValues.push(existsLambdaPropertyChains[existsLambdaPropertyChains.length - 1]);
|
96
|
-
// NOTE: there are simple operators which do not require any params (e.g. isEmpty)
|
97
|
-
if (filterConditionState.value) {
|
98
|
-
operatorEpression.parametersValues.push(filterConditionState.value);
|
99
|
-
}
|
100
|
-
simpleFunctionExpressions.push(operatorEpression);
|
101
|
-
// 4. Build the exists() lambda chain
|
102
|
-
assertTrue(simpleFunctionExpressions.length >= 2);
|
103
|
-
for (let i = simpleFunctionExpressions.length - 2; i >= 0; --i) {
|
104
|
-
const currentSFE = simpleFunctionExpressions[i];
|
105
|
-
const childSFE = simpleFunctionExpressions[i + 1];
|
106
|
-
// build child SFE lambda
|
107
|
-
const _existsLambdaVariable = childSFE.parametersValues[0];
|
108
|
-
const existsLambdaVariable = _existsLambdaVariable instanceof AbstractPropertyExpression
|
109
|
-
? getPropertyExpressionChainVariable(_existsLambdaVariable)
|
110
|
-
: guaranteeType(_existsLambdaVariable, VariableExpression);
|
111
|
-
const existsLambda = buildGenericLambdaFunctionInstanceValue(existsLambdaVariable.name, [childSFE], filterConditionState.filterState.queryBuilderState.graphManagerState
|
112
|
-
.graph);
|
113
|
-
// add the child SFE lambda to the current SFE parameters
|
114
|
-
currentSFE.parametersValues.push(existsLambda);
|
115
|
-
}
|
116
|
-
return simpleFunctionExpressions[0];
|
117
|
-
};
|
118
|
-
export const buildFilterConditionExpression = (filterConditionState, operatorFunctionFullPath) => {
|
119
|
-
if (filterConditionState.propertyExpressionState.requiresExistsHandling) {
|
120
|
-
return buildFilterConditionExpressionWithExists(filterConditionState, operatorFunctionFullPath);
|
121
|
-
}
|
22
|
+
export const buildFilterConditionExpression = (filterConditionState, operatorFunctionFullPath, lambdaParameterName) => {
|
122
23
|
const expression = new SimpleFunctionExpression(extractElementNameFromPath(operatorFunctionFullPath));
|
123
|
-
const propertyExpression = buildPropertyExpressionChain(filterConditionState.propertyExpressionState.propertyExpression, filterConditionState.propertyExpressionState.queryBuilderState, filterConditionState.filterState.lambdaParameterName);
|
24
|
+
const propertyExpression = buildPropertyExpressionChain(filterConditionState.propertyExpressionState.propertyExpression, filterConditionState.propertyExpressionState.queryBuilderState, lambdaParameterName ?? filterConditionState.filterState.lambdaParameterName);
|
124
25
|
expression.parametersValues.push(guaranteeNonNullable(propertyExpression));
|
125
26
|
// NOTE: there are simple operators which do not require any params (e.g. isEmpty)
|
126
27
|
if (filterConditionState.value) {
|
@@ -128,90 +29,6 @@ export const buildFilterConditionExpression = (filterConditionState, operatorFun
|
|
128
29
|
}
|
129
30
|
return expression;
|
130
31
|
};
|
131
|
-
/**
|
132
|
-
* Handling exists() lambda found in the filter condition expression.
|
133
|
-
* The general approach for handling exists() is we will flat out the chain
|
134
|
-
* of exists() expressions into a normal filter condition state.
|
135
|
-
*
|
136
|
-
* When we build the condition function expression from the filter condition state,
|
137
|
-
* we walk the property expression chain, find property with multiplitiy upper bound
|
138
|
-
* other than 1 and create an exists() lambda there
|
139
|
-
*
|
140
|
-
* NOTE: to ensure we respect user's choice of variable name, as we build the state
|
141
|
-
* we record the lambda parameter names, so we can use those while re-building the function
|
142
|
-
* If for some reason, this list is stale, we can start adding our own parameter names
|
143
|
-
*/
|
144
|
-
const buildFilterConditionStateWithExists = (filterState, parentExpression, operatorFunctionFullPath) => {
|
145
|
-
if (matchFunctionName(parentExpression.functionName, QUERY_BUILDER_SUPPORTED_FUNCTIONS.EXISTS)) {
|
146
|
-
// 1. Decompose the exists() lambda chain into property expression chains
|
147
|
-
const existsLambdaParameterNames = [];
|
148
|
-
// `existsLambdaExpressions` should be a list of `AbstractPropertyExpression`
|
149
|
-
// e.g. |Firm.all()->filter(x|$x.employees->exists(x_1|$x_1->subType(@Develper).id->exists(x_2|$x_2 == 1))
|
150
|
-
// In the first exists() lambda, `$x_1->subType(@Develper).id` is an `AbstractPropertyExpression`.
|
151
|
-
const existsLambdaExpressions = [];
|
152
|
-
let mainFilterExpression = parentExpression;
|
153
|
-
while (matchFunctionName(mainFilterExpression.functionName, QUERY_BUILDER_SUPPORTED_FUNCTIONS.EXISTS)) {
|
154
|
-
const existsLambda = guaranteeNonNullable(guaranteeType(mainFilterExpression.parametersValues[1], LambdaFunctionInstanceValue).values[0], `Can't process exists() expression: exists() lambda is missing`);
|
155
|
-
assertTrue(existsLambda.expressionSequence.length === 1, `Can't process exists() expression: exists() lambda body should hold an expression`);
|
156
|
-
mainFilterExpression = guaranteeType(existsLambda.expressionSequence[0], SimpleFunctionExpression, `Can't process exists() expression: exists() lambda body should hold an expression`);
|
157
|
-
// record the lambda parameter name
|
158
|
-
assertTrue(existsLambda.functionType.parameters.length === 1, `Can't process exists() expression: exists() lambda should have 1 parameter`);
|
159
|
-
existsLambdaParameterNames.push(guaranteeType(existsLambda.functionType.parameters[0], VariableExpression, `Can't process exists() expression: exists() lambda should have 1 parameter`).name);
|
160
|
-
// record the lambda property expression
|
161
|
-
if (mainFilterExpression.parametersValues[0] instanceof
|
162
|
-
AbstractPropertyExpression) {
|
163
|
-
existsLambdaExpressions.push(mainFilterExpression.parametersValues[0]);
|
164
|
-
}
|
165
|
-
}
|
166
|
-
// NOTE: make sure that the inner most function expression is the one we support
|
167
|
-
if (!matchFunctionName(mainFilterExpression.functionName, operatorFunctionFullPath)) {
|
168
|
-
return [undefined, undefined];
|
169
|
-
}
|
170
|
-
// 2. Build the property expression
|
171
|
-
const initialPropertyExpression = guaranteeType(parentExpression.parametersValues[0], AbstractPropertyExpression);
|
172
|
-
let flattenedPropertyExpressionChain = new AbstractPropertyExpression('');
|
173
|
-
flattenedPropertyExpressionChain.func = initialPropertyExpression.func;
|
174
|
-
flattenedPropertyExpressionChain.parametersValues = [
|
175
|
-
...initialPropertyExpression.parametersValues,
|
176
|
-
];
|
177
|
-
for (const expression of existsLambdaExpressions) {
|
178
|
-
// when rebuilding the property expression chain, disregard the initial variable that starts the chain
|
179
|
-
const expressions = [];
|
180
|
-
let currentExpression = expression;
|
181
|
-
while (currentExpression instanceof AbstractPropertyExpression ||
|
182
|
-
(currentExpression instanceof SimpleFunctionExpression &&
|
183
|
-
matchFunctionName(currentExpression.functionName, QUERY_BUILDER_SUPPORTED_FUNCTIONS.SUBTYPE))) {
|
184
|
-
if (currentExpression instanceof SimpleFunctionExpression) {
|
185
|
-
const functionExpression = new SimpleFunctionExpression(extractElementNameFromPath(QUERY_BUILDER_SUPPORTED_FUNCTIONS.SUBTYPE));
|
186
|
-
functionExpression.parametersValues.unshift(guaranteeNonNullable(currentExpression.parametersValues[1]));
|
187
|
-
expressions.push(functionExpression);
|
188
|
-
}
|
189
|
-
else if (currentExpression instanceof AbstractPropertyExpression) {
|
190
|
-
const propertyExpression = new AbstractPropertyExpression('');
|
191
|
-
propertyExpression.func = currentExpression.func;
|
192
|
-
// NOTE: we must retain the rest of the parameters as those are derived property parameters
|
193
|
-
propertyExpression.parametersValues =
|
194
|
-
currentExpression.parametersValues.length > 1
|
195
|
-
? currentExpression.parametersValues.slice(1)
|
196
|
-
: [];
|
197
|
-
expressions.push(propertyExpression);
|
198
|
-
}
|
199
|
-
currentExpression = guaranteeNonNullable(currentExpression.parametersValues[0]);
|
200
|
-
}
|
201
|
-
assertTrue(expressions.length > 0, `Can't process exists() expression: exists() usage with non-chain property expression is not supported`);
|
202
|
-
for (let i = 0; i < expressions.length - 1; ++i) {
|
203
|
-
expressions[i].parametersValues.unshift(expressions[i + 1]);
|
204
|
-
}
|
205
|
-
expressions[expressions.length - 1].parametersValues.unshift(flattenedPropertyExpressionChain);
|
206
|
-
flattenedPropertyExpressionChain = guaranteeType(expressions[0], AbstractPropertyExpression, `Can't process exists() expression: can't flatten to a property expression`);
|
207
|
-
}
|
208
|
-
// 3. Build the filter condition state with the simplified property expression
|
209
|
-
const filterConditionState = new FilterConditionState(filterState, flattenedPropertyExpressionChain);
|
210
|
-
existsLambdaParameterNames.forEach((paramName) => filterConditionState.addExistsLambdaParamNames(paramName));
|
211
|
-
return [filterConditionState, mainFilterExpression];
|
212
|
-
}
|
213
|
-
return [undefined, undefined];
|
214
|
-
};
|
215
32
|
export const buildFilterConditionState = (filterState, expression, operatorFunctionFullPath, operator,
|
216
33
|
/**
|
217
34
|
* Use this flag for operator that does not require any param (e.g. isEmpty)
|
@@ -227,14 +44,17 @@ hasNoValue = false) => {
|
|
227
44
|
if (matchFunctionName(expression.functionName, operatorFunctionFullPath)) {
|
228
45
|
assertTrue(expression.parametersValues.length === (hasNoValue ? 1 : 2), `Can't process ${extractElementNameFromPath(operatorFunctionFullPath)}() expression: ${extractElementNameFromPath(operatorFunctionFullPath)}() expects ${hasNoValue ? 'no argument' : '1 argument'}`);
|
229
46
|
const propertyExpression = guaranteeType(expression.parametersValues[0], AbstractPropertyExpression, `Can't process ${extractElementNameFromPath(operatorFunctionFullPath)}() expression: expects property expression in lambda body`);
|
230
|
-
const variableName = getPropertyExpressionChainVariable(propertyExpression).name;
|
231
|
-
assertTrue(filterState.lambdaParameterName === variableName, `Can't process ${extractElementNameFromPath(operatorFunctionFullPath)}() expression: expects variable used in lambda body '${variableName}' to match lambda parameter '${filterState.lambdaParameterName}'`);
|
232
47
|
filterConditionState = new FilterConditionState(filterState, propertyExpression);
|
233
48
|
mainExpressionWithOperator = expression;
|
234
49
|
}
|
235
50
|
else if (matchFunctionName(expression.functionName, QUERY_BUILDER_SUPPORTED_FUNCTIONS.EXISTS)) {
|
236
|
-
[
|
237
|
-
|
51
|
+
const lambdaFunctionInstance = guaranteeType(expression.parametersValues[1], LambdaFunctionInstanceValue);
|
52
|
+
const lambdaFunction = guaranteeType(lambdaFunctionInstance.values[0], LambdaFunction);
|
53
|
+
const filterExpression = guaranteeType(lambdaFunction.expressionSequence[0], SimpleFunctionExpression);
|
54
|
+
assertTrue(filterExpression.parametersValues.length === (hasNoValue ? 1 : 2), `Can't process ${extractElementNameFromPath(operatorFunctionFullPath)}() expression: ${extractElementNameFromPath(operatorFunctionFullPath)}() expects ${hasNoValue ? 'no argument' : '1 argument'}`);
|
55
|
+
const propertyExpression = guaranteeType(filterExpression.parametersValues[0], AbstractPropertyExpression, `Can't process ${extractElementNameFromPath(operatorFunctionFullPath)}() expression: expects property expression in lambda body`);
|
56
|
+
filterConditionState = new FilterConditionState(filterState, propertyExpression);
|
57
|
+
mainExpressionWithOperator = filterExpression;
|
238
58
|
}
|
239
59
|
// Post-build check: make sure the simple filter condition LHS, RHS, and operator are compatible
|
240
60
|
// and set the value of the condition in the state accordingly.
|
package/lib/stores/filter/operators/QueryBuilderFilterOperatorValueSpecificationBuilder.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"QueryBuilderFilterOperatorValueSpecificationBuilder.js","sourceRoot":"","sources":["../../../../src/stores/filter/operators/QueryBuilderFilterOperatorValueSpecificationBuilder.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAEL,0BAA0B,EAC1B,iBAAiB,EACjB,2BAA2B,EAC3B,kBAAkB,EAClB,0BAA0B,EAC1B,wBAAwB,EACxB,YAAY,GACb,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EACL,aAAa,EACb,oBAAoB,EACpB,UAAU,EACV,+BAA+B,GAChC,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EACL,oBAAoB,G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AK,EACL,oBAAoB,CAAC,WAAW,CAAC,iBAAiB,CAAC,eAAe,CACnE,CACF,CAAC;SACH;QACD,IAAI,CAAC,QAAQ,CAAC,oCAAoC,CAAC,oBAAoB,CAAC,EAAE;YACxE,oBAAoB,CAAC,QAAQ,CAC3B,QAAQ,CAAC,8BAA8B,CAAC,oBAAoB,CAAC,CAC9D,CAAC;SACH;QACD,OAAO,oBAAoB,CAAC;KAC7B;IACD,OAAO,SAAS,CAAC;AACnB,CAAC,CAAC"}
|
1
|
+
{"version":3,"file":"QueryBuilderFilterOperatorValueSpecificationBuilder.js","sourceRoot":"","sources":["../../../../src/stores/filter/operators/QueryBuilderFilterOperatorValueSpecificationBuilder.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAEL,0BAA0B,EAC1B,iBAAiB,EACjB,2BAA2B,EAC3B,0BAA0B,EAC1B,wBAAwB,EACxB,cAAc,GACf,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EACL,aAAa,EACb,oBAAoB,EACpB,UAAU,GACX,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EACL,oBAAoB,GAErB,MAAM,+BAA+B,CAAC;AACvC,OAAO,EAAE,iCAAiC,EAAE,MAAM,8CAA8C,CAAC;AACjG,OAAO,EAAE,uBAAuB,EAAE,MAAM,+CAA+C,CAAC;AAExF,OAAO,EAAE,4BAA4B,EAAE,MAAM,sDAAsD,CAAC;AAEpG,MAAM,CAAC,MAAM,8BAA8B,GAAG,CAC5C,oBAA0C,EAC1C,wBAAgC,EAChC,mBAAwC,EACpB,EAAE;IACtB,MAAM,UAAU,GAAG,IAAI,wBAAwB,CAC7C,0BAA0B,CAAC,wBAAwB,CAAC,CACrD,CAAC;IACF,MAAM,kBAAkB,GAAG,4BAA4B,CACrD,oBAAoB,CAAC,uBAAuB,CAAC,kBAAkB,EAC/D,oBAAoB,CAAC,uBAAuB,CAAC,iBAAiB,EAC9D,mBAAmB,IAAI,oBAAoB,CAAC,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C,KAAK,EAAE;YACxB,oBAAoB,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAC;SAC1C;aAAM;YACL,oBAAoB,CAAC,QAAQ,CAC3B,uBAAuB,CACrB,KAAK,EACL,oBAAoB,CAAC,WAAW,CAAC,iBAAiB,CAAC,eAAe,CACnE,CACF,CAAC;SACH;QACD,IAAI,CAAC,QAAQ,CAAC,oCAAoC,CAAC,oBAAoB,CAAC,EAAE;YACxE,oBAAoB,CAAC,QAAQ,CAC3B,QAAQ,CAAC,8BAA8B,CAAC,oBAAoB,CAAC,CAC9D,CAAC;SACH;QACD,OAAO,oBAAoB,CAAC;KAC7B;IACD,OAAO,SAAS,CAAC;AACnB,CAAC,CAAC"}
|
@@ -22,13 +22,13 @@ export declare class QueryBuilderFilterOperator_Contain extends QueryBuilderFilt
|
|
22
22
|
isCompatibleWithFilterConditionProperty(filterConditionState: FilterConditionState): boolean;
|
23
23
|
isCompatibleWithFilterConditionValue(filterConditionState: FilterConditionState): boolean;
|
24
24
|
getDefaultFilterConditionValue(filterConditionState: FilterConditionState): ValueSpecification | undefined;
|
25
|
-
buildFilterConditionExpression(filterConditionState: FilterConditionState): ValueSpecification;
|
25
|
+
buildFilterConditionExpression(filterConditionState: FilterConditionState, lambdaParameterName?: string | undefined): ValueSpecification;
|
26
26
|
buildFilterConditionState(filterState: QueryBuilderFilterState, expression: SimpleFunctionExpression): FilterConditionState | undefined;
|
27
27
|
get hashCode(): string;
|
28
28
|
}
|
29
29
|
export declare class QueryBuilderFilterOperator_NotContain extends QueryBuilderFilterOperator_Contain {
|
30
30
|
getLabel(filterConditionState: FilterConditionState): string;
|
31
|
-
buildFilterConditionExpression(filterConditionState: FilterConditionState): ValueSpecification;
|
31
|
+
buildFilterConditionExpression(filterConditionState: FilterConditionState, lambdaParameterName?: string | undefined): ValueSpecification;
|
32
32
|
buildFilterConditionState(filterState: QueryBuilderFilterState, expression: SimpleFunctionExpression): FilterConditionState | undefined;
|
33
33
|
get hashCode(): string;
|
34
34
|
}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"QueryBuilderFilterOperator_Contain.d.ts","sourceRoot":"","sources":["../../../../src/stores/filter/operators/QueryBuilderFilterOperator_Contain.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,KAAK,EACV,uBAAuB,EACvB,oBAAoB,EACrB,MAAM,+BAA+B,CAAC;AACvC,OAAO,EAAE,0BAA0B,EAAE,MAAM,kCAAkC,CAAC;AAC9E,OAAO,EAEL,KAAK,kBAAkB,EACvB,KAAK,wBAAwB,EAE9B,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EACL,KAAK,QAAQ,EAGd,MAAM,sBAAsB,CAAC;AAe9B,qBAAa,kCACX,SAAQ,0BACR,YAAW,QAAQ;IAEnB,QAAQ,CAAC,oBAAoB,EAAE,oBAAoB,GAAG,MAAM;IAI5D,uCAAuC,CACrC,oBAAoB,EAAE,oBAAoB,GACzC,OAAO;IAQV,oCAAoC,CAClC,oBAAoB,EAAE,oBAAoB,GACzC,OAAO;IAOV,8BAA8B,CAC5B,oBAAoB,EAAE,oBAAoB,GACzC,kBAAkB,GAAG,SAAS;IAuBjC,8BAA8B,CAC5B,oBAAoB,EAAE,oBAAoB,
|
1
|
+
{"version":3,"file":"QueryBuilderFilterOperator_Contain.d.ts","sourceRoot":"","sources":["../../../../src/stores/filter/operators/QueryBuilderFilterOperator_Contain.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,KAAK,EACV,uBAAuB,EACvB,oBAAoB,EACrB,MAAM,+BAA+B,CAAC;AACvC,OAAO,EAAE,0BAA0B,EAAE,MAAM,kCAAkC,CAAC;AAC9E,OAAO,EAEL,KAAK,kBAAkB,EACvB,KAAK,wBAAwB,EAE9B,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EACL,KAAK,QAAQ,EAGd,MAAM,sBAAsB,CAAC;AAe9B,qBAAa,kCACX,SAAQ,0BACR,YAAW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