@finos/legend-query-builder 4.7.3 → 4.8.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/lib/components/QueryBuilderConstantExpressionPanel.d.ts.map +1 -1
- package/lib/components/QueryBuilderConstantExpressionPanel.js +24 -8
- package/lib/components/QueryBuilderConstantExpressionPanel.js.map +1 -1
- package/lib/components/fetch-structure/QueryBuilderPostFilterPanel.d.ts.map +1 -1
- package/lib/components/fetch-structure/QueryBuilderPostFilterPanel.js +5 -3
- package/lib/components/fetch-structure/QueryBuilderPostFilterPanel.js.map +1 -1
- package/lib/components/fetch-structure/QueryBuilderTDSPanel.d.ts.map +1 -1
- package/lib/components/fetch-structure/QueryBuilderTDSPanel.js +8 -1
- package/lib/components/fetch-structure/QueryBuilderTDSPanel.js.map +1 -1
- package/lib/components/shared/LambdaEditor.d.ts +1 -11
- package/lib/components/shared/LambdaEditor.d.ts.map +1 -1
- package/lib/components/shared/LambdaEditor.js +11 -4
- package/lib/components/shared/LambdaEditor.js.map +1 -1
- package/lib/index.css +2 -2
- package/lib/index.css.map +1 -1
- package/lib/package.json +2 -2
- package/lib/stores/QueryBuilderConstantsState.d.ts +2 -1
- package/lib/stores/QueryBuilderConstantsState.d.ts.map +1 -1
- package/lib/stores/QueryBuilderConstantsState.js +9 -1
- package/lib/stores/QueryBuilderConstantsState.js.map +1 -1
- package/lib/stores/QueryBuilderState.d.ts.map +1 -1
- package/lib/stores/QueryBuilderState.js +1 -0
- package/lib/stores/QueryBuilderState.js.map +1 -1
- package/lib/stores/QueryBuilderTypeaheadHelper.d.ts +1 -1
- package/lib/stores/QueryBuilderTypeaheadHelper.d.ts.map +1 -1
- package/lib/stores/QueryBuilderTypeaheadHelper.js +190 -30
- package/lib/stores/QueryBuilderTypeaheadHelper.js.map +1 -1
- package/lib/stores/fetch-structure/QueryBuilderFetchStructureImplementationState.d.ts +1 -0
- package/lib/stores/fetch-structure/QueryBuilderFetchStructureImplementationState.d.ts.map +1 -1
- package/lib/stores/fetch-structure/QueryBuilderFetchStructureImplementationState.js.map +1 -1
- package/lib/stores/fetch-structure/QueryBuilderFetchStructureState.d.ts +1 -0
- package/lib/stores/fetch-structure/QueryBuilderFetchStructureState.d.ts.map +1 -1
- package/lib/stores/fetch-structure/QueryBuilderFetchStructureState.js +4 -0
- package/lib/stores/fetch-structure/QueryBuilderFetchStructureState.js.map +1 -1
- package/lib/stores/fetch-structure/graph-fetch/QueryBuilderGraphFetchTreeState.d.ts +1 -0
- package/lib/stores/fetch-structure/graph-fetch/QueryBuilderGraphFetchTreeState.d.ts.map +1 -1
- package/lib/stores/fetch-structure/graph-fetch/QueryBuilderGraphFetchTreeState.js +3 -0
- package/lib/stores/fetch-structure/graph-fetch/QueryBuilderGraphFetchTreeState.js.map +1 -1
- package/lib/stores/fetch-structure/tds/QueryBuilderTDSState.d.ts +2 -0
- package/lib/stores/fetch-structure/tds/QueryBuilderTDSState.d.ts.map +1 -1
- package/lib/stores/fetch-structure/tds/QueryBuilderTDSState.js +25 -1
- package/lib/stores/fetch-structure/tds/QueryBuilderTDSState.js.map +1 -1
- package/lib/stores/fetch-structure/tds/post-filter/QueryBuilderPostFilterState.d.ts +3 -1
- package/lib/stores/fetch-structure/tds/post-filter/QueryBuilderPostFilterState.d.ts.map +1 -1
- package/lib/stores/fetch-structure/tds/post-filter/QueryBuilderPostFilterState.js +6 -0
- package/lib/stores/fetch-structure/tds/post-filter/QueryBuilderPostFilterState.js.map +1 -1
- package/lib/stores/fetch-structure/tds/projection/QueryBuilderProjectionColumnState.d.ts +9 -2
- package/lib/stores/fetch-structure/tds/projection/QueryBuilderProjectionColumnState.d.ts.map +1 -1
- package/lib/stores/fetch-structure/tds/projection/QueryBuilderProjectionColumnState.js +40 -6
- package/lib/stores/fetch-structure/tds/projection/QueryBuilderProjectionColumnState.js.map +1 -1
- package/lib/stores/milestoning/QueryBuilderBitemporalMilestoningImplementation.d.ts +1 -0
- package/lib/stores/milestoning/QueryBuilderBitemporalMilestoningImplementation.d.ts.map +1 -1
- package/lib/stores/milestoning/QueryBuilderBitemporalMilestoningImplementation.js +8 -1
- package/lib/stores/milestoning/QueryBuilderBitemporalMilestoningImplementation.js.map +1 -1
- package/lib/stores/milestoning/QueryBuilderBusinessTemporalMilestoningImplementation.d.ts +1 -0
- package/lib/stores/milestoning/QueryBuilderBusinessTemporalMilestoningImplementation.d.ts.map +1 -1
- package/lib/stores/milestoning/QueryBuilderBusinessTemporalMilestoningImplementation.js +7 -1
- package/lib/stores/milestoning/QueryBuilderBusinessTemporalMilestoningImplementation.js.map +1 -1
- package/lib/stores/milestoning/QueryBuilderMilestoningImplementation.d.ts +4 -0
- package/lib/stores/milestoning/QueryBuilderMilestoningImplementation.d.ts.map +1 -1
- package/lib/stores/milestoning/QueryBuilderMilestoningImplementation.js.map +1 -1
- package/lib/stores/milestoning/QueryBuilderProcessingTemporalMilestoningImplementation.d.ts +1 -0
- package/lib/stores/milestoning/QueryBuilderProcessingTemporalMilestoningImplementation.d.ts.map +1 -1
- package/lib/stores/milestoning/QueryBuilderProcessingTemporalMilestoningImplementation.js +7 -1
- package/lib/stores/milestoning/QueryBuilderProcessingTemporalMilestoningImplementation.js.map +1 -1
- package/package.json +6 -6
- package/src/components/QueryBuilderConstantExpressionPanel.tsx +81 -24
- package/src/components/fetch-structure/QueryBuilderPostFilterPanel.tsx +11 -1
- package/src/components/fetch-structure/QueryBuilderTDSPanel.tsx +12 -1
- package/src/components/shared/LambdaEditor.tsx +15 -2
- package/src/stores/QueryBuilderConstantsState.ts +12 -0
- package/src/stores/QueryBuilderState.ts +1 -0
- package/src/stores/QueryBuilderTypeaheadHelper.ts +382 -54
- package/src/stores/fetch-structure/QueryBuilderFetchStructureImplementationState.ts +1 -0
- package/src/stores/fetch-structure/QueryBuilderFetchStructureState.ts +5 -0
- package/src/stores/fetch-structure/graph-fetch/QueryBuilderGraphFetchTreeState.ts +4 -0
- package/src/stores/fetch-structure/tds/QueryBuilderTDSState.ts +43 -1
- package/src/stores/fetch-structure/tds/post-filter/QueryBuilderPostFilterState.ts +11 -0
- package/src/stores/fetch-structure/tds/projection/QueryBuilderProjectionColumnState.ts +66 -9
- package/src/stores/milestoning/QueryBuilderBitemporalMilestoningImplementation.ts +14 -0
- package/src/stores/milestoning/QueryBuilderBusinessTemporalMilestoningImplementation.ts +13 -0
- package/src/stores/milestoning/QueryBuilderMilestoningImplementation.ts +7 -0
- package/src/stores/milestoning/QueryBuilderProcessingTemporalMilestoningImplementation.ts +13 -0
|
@@ -15,77 +15,356 @@
|
|
|
15
15
|
*/
|
|
16
16
|
|
|
17
17
|
import {
|
|
18
|
-
|
|
18
|
+
AbstractPropertyExpression,
|
|
19
19
|
type ExecutionResult,
|
|
20
20
|
type ValueSpecification,
|
|
21
21
|
PrimitiveInstanceValue,
|
|
22
22
|
PRIMITIVE_TYPE,
|
|
23
23
|
TDSExecutionResult,
|
|
24
24
|
type RawLambda,
|
|
25
|
+
DerivedProperty,
|
|
26
|
+
Class,
|
|
27
|
+
SimpleFunctionExpression,
|
|
28
|
+
matchFunctionName,
|
|
29
|
+
PrimitiveType,
|
|
30
|
+
type ObserverContext,
|
|
31
|
+
Multiplicity,
|
|
32
|
+
getMilestoneTemporalStereotype,
|
|
33
|
+
extractElementNameFromPath,
|
|
34
|
+
CollectionInstanceValue,
|
|
35
|
+
GenericTypeExplicitReference,
|
|
36
|
+
GenericType,
|
|
37
|
+
CORE_PURE_PATH,
|
|
38
|
+
FunctionType,
|
|
39
|
+
LambdaFunction,
|
|
40
|
+
PackageableElementExplicitReference,
|
|
41
|
+
PropertyExplicitReference,
|
|
42
|
+
getAllClassDerivedProperties,
|
|
43
|
+
VariableExpression,
|
|
44
|
+
buildRawLambdaFromLambdaFunction,
|
|
45
|
+
type Type,
|
|
46
|
+
INTERNAL__UnknownValueSpecification,
|
|
47
|
+
V1_transformRawLambda,
|
|
48
|
+
V1_GraphTransformerContextBuilder,
|
|
49
|
+
V1_serializeRawValueSpecification,
|
|
25
50
|
} from '@finos/legend-graph';
|
|
26
|
-
import {
|
|
51
|
+
import {
|
|
52
|
+
getNullableFirstEntry,
|
|
53
|
+
guaranteeNonNullable,
|
|
54
|
+
guaranteeType,
|
|
55
|
+
isNonNullable,
|
|
56
|
+
isString,
|
|
57
|
+
UnsupportedOperationError,
|
|
58
|
+
} from '@finos/legend-shared';
|
|
27
59
|
import { QueryBuilderPostFilterOperator_StartWith } from './fetch-structure/tds/post-filter/operators/QueryBuilderPostFilterOperator_StartWith.js';
|
|
28
60
|
import type { QueryBuilderAggregateColumnState } from './fetch-structure/tds/aggregation/QueryBuilderAggregationState.js';
|
|
29
61
|
import {
|
|
30
|
-
|
|
31
|
-
|
|
62
|
+
getTDSColumnDerivedProperyFromType,
|
|
63
|
+
type TDS_COLUMN_GETTER,
|
|
32
64
|
} from './fetch-structure/tds/post-filter/QueryBuilderPostFilterState.js';
|
|
33
65
|
import {
|
|
66
|
+
QueryBuilderDerivationProjectionColumnState,
|
|
34
67
|
QueryBuilderProjectionColumnState,
|
|
35
68
|
QueryBuilderSimpleProjectionColumnState,
|
|
36
69
|
} from './fetch-structure/tds/projection/QueryBuilderProjectionColumnState.js';
|
|
37
70
|
import type { QueryBuilderState } from './QueryBuilderState.js';
|
|
38
|
-
import { QueryBuilderTDSState } from './fetch-structure/tds/QueryBuilderTDSState.js';
|
|
39
71
|
import {
|
|
40
72
|
DEFAULT_TYPEAHEAD_SEARCH_LIMIT,
|
|
41
73
|
DEFAULT_TYPEAHEAD_SEARCH_MINIMUM_SEARCH_LENGTH,
|
|
42
74
|
} from '@finos/legend-application';
|
|
75
|
+
import {
|
|
76
|
+
QUERY_BUILDER_PURE_PATH,
|
|
77
|
+
QUERY_BUILDER_SUPPORTED_FUNCTIONS,
|
|
78
|
+
} from '../graph/QueryBuilderMetaModelConst.js';
|
|
79
|
+
import {
|
|
80
|
+
functionExpression_setParametersValues,
|
|
81
|
+
variableExpression_setName,
|
|
82
|
+
} from './shared/ValueSpecificationModifierHelper.js';
|
|
83
|
+
import { createSupportedFunctionExpression } from './shared/ValueSpecificationEditorHelper.js';
|
|
84
|
+
import { buildGetAllFunction } from './QueryBuilderValueSpecificationBuilder.js';
|
|
85
|
+
import { getPropertyChainName } from './QueryBuilderPropertyEditorState.js';
|
|
86
|
+
import { buildGenericLambdaFunctionInstanceValue } from './QueryBuilderValueSpecificationHelper.js';
|
|
87
|
+
import {
|
|
88
|
+
DEFAULT_LAMBDA_VARIABLE_NAME,
|
|
89
|
+
DEFAULT_POST_FILTER_LAMBDA_VARIABLE_NAME,
|
|
90
|
+
} from './QueryBuilderConfig.js';
|
|
91
|
+
import type { QueryBuilderAggregateOperator } from './fetch-structure/tds/aggregation/QueryBuilderAggregateOperator.js';
|
|
43
92
|
|
|
44
|
-
const
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
93
|
+
const buildPropertyExpressionChainWithDefaultMilestoningDates = (
|
|
94
|
+
propertyExpression: AbstractPropertyExpression,
|
|
95
|
+
lambdaParameterName: string,
|
|
96
|
+
observerContext: ObserverContext,
|
|
97
|
+
): AbstractPropertyExpression => {
|
|
98
|
+
const newPropertyExpression = new AbstractPropertyExpression('');
|
|
99
|
+
newPropertyExpression.func = propertyExpression.func;
|
|
100
|
+
newPropertyExpression.parametersValues = [
|
|
101
|
+
...propertyExpression.parametersValues,
|
|
102
|
+
];
|
|
103
|
+
|
|
104
|
+
let nextExpression: ValueSpecification | undefined;
|
|
105
|
+
let currentExpression: ValueSpecification | undefined = newPropertyExpression;
|
|
106
|
+
while (currentExpression instanceof AbstractPropertyExpression) {
|
|
107
|
+
nextExpression = getNullableFirstEntry(currentExpression.parametersValues);
|
|
108
|
+
if (nextExpression instanceof AbstractPropertyExpression) {
|
|
109
|
+
const parameterValue = new AbstractPropertyExpression('');
|
|
110
|
+
parameterValue.func = nextExpression.func;
|
|
111
|
+
parameterValue.parametersValues = [...nextExpression.parametersValues];
|
|
112
|
+
nextExpression = parameterValue;
|
|
113
|
+
currentExpression.parametersValues[0] = parameterValue;
|
|
114
|
+
}
|
|
115
|
+
if (
|
|
116
|
+
currentExpression instanceof AbstractPropertyExpression &&
|
|
117
|
+
currentExpression.func.value.genericType.value.rawType instanceof Class &&
|
|
118
|
+
currentExpression.func.value._OWNER._generatedMilestonedProperties
|
|
119
|
+
.length !== 0 &&
|
|
120
|
+
currentExpression.func.value instanceof DerivedProperty &&
|
|
121
|
+
!currentExpression.func.value._OWNER.derivedProperties.includes(
|
|
122
|
+
currentExpression.func.value,
|
|
123
|
+
)
|
|
124
|
+
) {
|
|
125
|
+
const parameterValue = createSupportedFunctionExpression(
|
|
126
|
+
QUERY_BUILDER_SUPPORTED_FUNCTIONS.NOW,
|
|
127
|
+
PrimitiveType.DATETIME,
|
|
128
|
+
);
|
|
129
|
+
const parameterValues =
|
|
130
|
+
currentExpression.parametersValues.length === 2
|
|
131
|
+
? [parameterValue]
|
|
132
|
+
: [parameterValue, parameterValue];
|
|
133
|
+
functionExpression_setParametersValues(
|
|
134
|
+
currentExpression,
|
|
135
|
+
[
|
|
136
|
+
guaranteeNonNullable(currentExpression.parametersValues[0]),
|
|
137
|
+
...parameterValues,
|
|
138
|
+
],
|
|
139
|
+
observerContext,
|
|
140
|
+
);
|
|
141
|
+
}
|
|
142
|
+
currentExpression = nextExpression;
|
|
143
|
+
// Take care of chains of subtype (a pattern that is not useful, but we want to support and rectify)
|
|
144
|
+
// $x.employees->subType(@Person)->subType(@Staff)
|
|
145
|
+
while (
|
|
146
|
+
currentExpression instanceof SimpleFunctionExpression &&
|
|
147
|
+
matchFunctionName(
|
|
148
|
+
currentExpression.functionName,
|
|
149
|
+
QUERY_BUILDER_SUPPORTED_FUNCTIONS.SUBTYPE,
|
|
150
|
+
)
|
|
151
|
+
) {
|
|
152
|
+
currentExpression = getNullableFirstEntry(
|
|
153
|
+
currentExpression.parametersValues,
|
|
154
|
+
);
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
// Update the root lambda name based on the parent's lambda parameter name.
|
|
159
|
+
if (currentExpression instanceof VariableExpression) {
|
|
160
|
+
variableExpression_setName(currentExpression, lambdaParameterName);
|
|
161
|
+
}
|
|
162
|
+
return newPropertyExpression;
|
|
55
163
|
};
|
|
56
164
|
|
|
57
|
-
const
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
165
|
+
const buildRawLambda = (
|
|
166
|
+
queryBuilderState: QueryBuilderState,
|
|
167
|
+
propertyExpression?: AbstractPropertyExpression | undefined,
|
|
168
|
+
aggregationOperator?: QueryBuilderAggregateOperator | undefined,
|
|
169
|
+
colLambda?: ValueSpecification | undefined,
|
|
170
|
+
colType?: Type | undefined,
|
|
171
|
+
colName?: string | undefined,
|
|
172
|
+
value?: ValueSpecification | undefined,
|
|
63
173
|
): RawLambda => {
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
174
|
+
if (!propertyExpression && !(colLambda && colType && colName)) {
|
|
175
|
+
throw new UnsupportedOperationError(`Can't build typeahead query`);
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
const lambdaFunction = new LambdaFunction(
|
|
179
|
+
new FunctionType(
|
|
180
|
+
PackageableElementExplicitReference.create(
|
|
181
|
+
queryBuilderState.graphManagerState.graph.getType(CORE_PURE_PATH.ANY),
|
|
182
|
+
),
|
|
183
|
+
Multiplicity.ONE,
|
|
184
|
+
),
|
|
67
185
|
);
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
186
|
+
|
|
187
|
+
// build getAll function
|
|
188
|
+
const _class = guaranteeNonNullable(queryBuilderState.class);
|
|
189
|
+
const getAllFn = buildGetAllFunction(
|
|
190
|
+
guaranteeNonNullable(queryBuilderState.class),
|
|
191
|
+
Multiplicity.ONE,
|
|
192
|
+
);
|
|
193
|
+
const milestoningStereotype = getMilestoneTemporalStereotype(
|
|
194
|
+
_class,
|
|
195
|
+
queryBuilderState.graphManagerState.graph,
|
|
196
|
+
);
|
|
197
|
+
if (milestoningStereotype) {
|
|
198
|
+
// build milestoning parameter(s) for getAll()
|
|
199
|
+
queryBuilderState.milestoningState
|
|
200
|
+
.getMilestoningImplementation(milestoningStereotype)
|
|
201
|
+
.buildGetAllWithDefaultParameters(getAllFn);
|
|
202
|
+
}
|
|
203
|
+
lambdaFunction.expressionSequence[0] = getAllFn;
|
|
204
|
+
|
|
205
|
+
// projection
|
|
206
|
+
const columnName = propertyExpression
|
|
207
|
+
? getPropertyChainName(propertyExpression, false)
|
|
208
|
+
: colName;
|
|
209
|
+
if (aggregationOperator) {
|
|
210
|
+
const groupByFunction = new SimpleFunctionExpression(
|
|
211
|
+
extractElementNameFromPath(
|
|
212
|
+
QUERY_BUILDER_SUPPORTED_FUNCTIONS.TDS_GROUP_BY,
|
|
213
|
+
),
|
|
214
|
+
);
|
|
215
|
+
|
|
216
|
+
const colLambdas = new CollectionInstanceValue(Multiplicity.ZERO);
|
|
217
|
+
const aggregateLambdas = new CollectionInstanceValue(Multiplicity.ONE);
|
|
218
|
+
const colAliases = new CollectionInstanceValue(Multiplicity.ONE);
|
|
219
|
+
const colAlias = new PrimitiveInstanceValue(
|
|
220
|
+
GenericTypeExplicitReference.create(
|
|
221
|
+
new GenericType(PrimitiveType.STRING),
|
|
222
|
+
),
|
|
223
|
+
);
|
|
224
|
+
colAlias.values.push(columnName);
|
|
225
|
+
colAliases.values.push(colAlias);
|
|
226
|
+
const columnLambda = propertyExpression
|
|
227
|
+
? buildGenericLambdaFunctionInstanceValue(
|
|
228
|
+
DEFAULT_LAMBDA_VARIABLE_NAME,
|
|
229
|
+
[propertyExpression],
|
|
230
|
+
queryBuilderState.graphManagerState.graph,
|
|
231
|
+
)
|
|
232
|
+
: colLambda;
|
|
233
|
+
const aggregateFunctionExpression = new SimpleFunctionExpression(
|
|
234
|
+
extractElementNameFromPath(QUERY_BUILDER_SUPPORTED_FUNCTIONS.TDS_AGG),
|
|
235
|
+
);
|
|
236
|
+
const aggregateLambda = buildGenericLambdaFunctionInstanceValue(
|
|
237
|
+
DEFAULT_LAMBDA_VARIABLE_NAME,
|
|
238
|
+
[
|
|
239
|
+
aggregationOperator.buildAggregateExpression(
|
|
240
|
+
propertyExpression,
|
|
241
|
+
DEFAULT_LAMBDA_VARIABLE_NAME,
|
|
242
|
+
queryBuilderState.graphManagerState.graph,
|
|
243
|
+
),
|
|
244
|
+
],
|
|
245
|
+
queryBuilderState.graphManagerState.graph,
|
|
246
|
+
);
|
|
247
|
+
aggregateFunctionExpression.parametersValues = [
|
|
248
|
+
guaranteeNonNullable(columnLambda),
|
|
249
|
+
aggregateLambda,
|
|
250
|
+
];
|
|
251
|
+
aggregateLambdas.values.push(aggregateFunctionExpression);
|
|
252
|
+
groupByFunction.parametersValues = [
|
|
253
|
+
lambdaFunction.expressionSequence[0],
|
|
254
|
+
colLambdas,
|
|
255
|
+
aggregateLambdas,
|
|
256
|
+
colAliases,
|
|
257
|
+
];
|
|
258
|
+
lambdaFunction.expressionSequence[0] = groupByFunction;
|
|
71
259
|
} else {
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
260
|
+
const projectFunction = new SimpleFunctionExpression(
|
|
261
|
+
extractElementNameFromPath(QUERY_BUILDER_SUPPORTED_FUNCTIONS.TDS_PROJECT),
|
|
262
|
+
);
|
|
263
|
+
const colLambdas = new CollectionInstanceValue(Multiplicity.ONE);
|
|
264
|
+
const colAliases = new CollectionInstanceValue(Multiplicity.ONE);
|
|
265
|
+
// column alias
|
|
266
|
+
const colAlias = new PrimitiveInstanceValue(
|
|
267
|
+
GenericTypeExplicitReference.create(
|
|
268
|
+
new GenericType(PrimitiveType.STRING),
|
|
269
|
+
),
|
|
270
|
+
);
|
|
271
|
+
colAlias.values.push(columnName);
|
|
272
|
+
colAliases.values.push(colAlias);
|
|
273
|
+
const columnLambda = propertyExpression
|
|
274
|
+
? buildGenericLambdaFunctionInstanceValue(
|
|
275
|
+
DEFAULT_LAMBDA_VARIABLE_NAME,
|
|
276
|
+
[propertyExpression],
|
|
277
|
+
queryBuilderState.graphManagerState.graph,
|
|
278
|
+
)
|
|
279
|
+
: colLambda;
|
|
280
|
+
colLambdas.values.push(guaranteeNonNullable(columnLambda));
|
|
281
|
+
projectFunction.parametersValues = [
|
|
282
|
+
lambdaFunction.expressionSequence[0],
|
|
283
|
+
colLambdas,
|
|
284
|
+
colAliases,
|
|
285
|
+
];
|
|
286
|
+
lambdaFunction.expressionSequence[0] = projectFunction;
|
|
75
287
|
}
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
288
|
+
|
|
289
|
+
// append post filter
|
|
290
|
+
const operator = new QueryBuilderPostFilterOperator_StartWith();
|
|
291
|
+
const tdsPropertyExpression = new AbstractPropertyExpression('');
|
|
292
|
+
let tdsDerivedPropertyName: TDS_COLUMN_GETTER;
|
|
293
|
+
const correspondingTDSDerivedProperty = operator.getTDSColumnGetter();
|
|
294
|
+
if (correspondingTDSDerivedProperty) {
|
|
295
|
+
tdsDerivedPropertyName = correspondingTDSDerivedProperty;
|
|
296
|
+
} else {
|
|
297
|
+
const type =
|
|
298
|
+
propertyExpression?.func.value.genericType.value.rawType ?? colType;
|
|
299
|
+
tdsDerivedPropertyName = getTDSColumnDerivedProperyFromType(
|
|
300
|
+
guaranteeNonNullable(type),
|
|
301
|
+
);
|
|
302
|
+
}
|
|
303
|
+
tdsPropertyExpression.func = PropertyExplicitReference.create(
|
|
304
|
+
guaranteeNonNullable(
|
|
305
|
+
getAllClassDerivedProperties(
|
|
306
|
+
queryBuilderState.graphManagerState.graph.getClass(
|
|
307
|
+
QUERY_BUILDER_PURE_PATH.TDS_ROW,
|
|
308
|
+
),
|
|
309
|
+
).find((p) => p.name === tdsDerivedPropertyName),
|
|
310
|
+
),
|
|
82
311
|
);
|
|
83
|
-
const
|
|
84
|
-
|
|
85
|
-
|
|
312
|
+
const variableName = new VariableExpression(
|
|
313
|
+
DEFAULT_POST_FILTER_LAMBDA_VARIABLE_NAME,
|
|
314
|
+
Multiplicity.ONE,
|
|
315
|
+
);
|
|
316
|
+
const colInstanceValue = new PrimitiveInstanceValue(
|
|
317
|
+
GenericTypeExplicitReference.create(new GenericType(PrimitiveType.STRING)),
|
|
318
|
+
);
|
|
319
|
+
colInstanceValue.values = [columnName];
|
|
320
|
+
tdsPropertyExpression.parametersValues = [variableName, colInstanceValue];
|
|
321
|
+
|
|
322
|
+
const postFilterExpression = new SimpleFunctionExpression(
|
|
323
|
+
extractElementNameFromPath(QUERY_BUILDER_SUPPORTED_FUNCTIONS.STARTS_WITH),
|
|
324
|
+
);
|
|
325
|
+
postFilterExpression.parametersValues.push(tdsPropertyExpression);
|
|
326
|
+
if (value) {
|
|
327
|
+
postFilterExpression.parametersValues.push(value);
|
|
328
|
+
}
|
|
329
|
+
const filterLambda = buildGenericLambdaFunctionInstanceValue(
|
|
330
|
+
DEFAULT_POST_FILTER_LAMBDA_VARIABLE_NAME,
|
|
331
|
+
[postFilterExpression],
|
|
332
|
+
queryBuilderState.graphManagerState.graph,
|
|
333
|
+
);
|
|
334
|
+
|
|
335
|
+
// build post-filter expression
|
|
336
|
+
const filterExpression = new SimpleFunctionExpression(
|
|
337
|
+
extractElementNameFromPath(QUERY_BUILDER_SUPPORTED_FUNCTIONS.TDS_FILTER),
|
|
338
|
+
);
|
|
339
|
+
const projectExpression = guaranteeNonNullable(
|
|
340
|
+
lambdaFunction.expressionSequence[0],
|
|
341
|
+
);
|
|
342
|
+
filterExpression.parametersValues = [projectExpression, filterLambda];
|
|
343
|
+
lambdaFunction.expressionSequence[0] = filterExpression;
|
|
344
|
+
|
|
345
|
+
// append distinct and take
|
|
346
|
+
const postFilterExp = lambdaFunction.expressionSequence[0];
|
|
347
|
+
let currentExpression = postFilterExp;
|
|
348
|
+
const distinctFunction = new SimpleFunctionExpression(
|
|
349
|
+
extractElementNameFromPath(QUERY_BUILDER_SUPPORTED_FUNCTIONS.TDS_DISTINCT),
|
|
350
|
+
);
|
|
351
|
+
distinctFunction.parametersValues[0] = currentExpression;
|
|
352
|
+
currentExpression = distinctFunction;
|
|
353
|
+
const limit = new PrimitiveInstanceValue(
|
|
354
|
+
GenericTypeExplicitReference.create(new GenericType(PrimitiveType.INTEGER)),
|
|
355
|
+
);
|
|
356
|
+
limit.values = [DEFAULT_TYPEAHEAD_SEARCH_LIMIT];
|
|
357
|
+
const takeFunction = new SimpleFunctionExpression(
|
|
358
|
+
extractElementNameFromPath(QUERY_BUILDER_SUPPORTED_FUNCTIONS.TDS_TAKE),
|
|
359
|
+
);
|
|
360
|
+
takeFunction.parametersValues[0] = currentExpression;
|
|
361
|
+
takeFunction.parametersValues[1] = limit;
|
|
362
|
+
currentExpression = takeFunction;
|
|
363
|
+
lambdaFunction.expressionSequence[0] = currentExpression;
|
|
364
|
+
return buildRawLambdaFromLambdaFunction(
|
|
365
|
+
lambdaFunction,
|
|
366
|
+
queryBuilderState.graphManagerState,
|
|
86
367
|
);
|
|
87
|
-
tdsState.postFilterState.addNodeFromNode(postFilterNode, undefined);
|
|
88
|
-
return builderState.resultState.buildExecutionRawLambda();
|
|
89
368
|
};
|
|
90
369
|
|
|
91
370
|
export const buildPropertyTypeaheadQuery = (
|
|
@@ -93,17 +372,22 @@ export const buildPropertyTypeaheadQuery = (
|
|
|
93
372
|
propertyExpression: AbstractPropertyExpression,
|
|
94
373
|
value: ValueSpecification | undefined,
|
|
95
374
|
): RawLambda => {
|
|
96
|
-
const
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
375
|
+
const newPropertyExpression =
|
|
376
|
+
buildPropertyExpressionChainWithDefaultMilestoningDates(
|
|
377
|
+
propertyExpression,
|
|
378
|
+
DEFAULT_LAMBDA_VARIABLE_NAME,
|
|
379
|
+
queryBuilderState.observerContext,
|
|
380
|
+
);
|
|
381
|
+
|
|
382
|
+
return buildRawLambda(
|
|
383
|
+
queryBuilderState,
|
|
384
|
+
newPropertyExpression,
|
|
385
|
+
undefined,
|
|
386
|
+
undefined,
|
|
387
|
+
undefined,
|
|
388
|
+
undefined,
|
|
389
|
+
value,
|
|
105
390
|
);
|
|
106
|
-
return buildColumnTypeaheadQuery(builderState, columnState, value);
|
|
107
391
|
};
|
|
108
392
|
|
|
109
393
|
export const buildProjectionColumnTypeaheadQuery = (
|
|
@@ -113,8 +397,52 @@ export const buildProjectionColumnTypeaheadQuery = (
|
|
|
113
397
|
| QueryBuilderAggregateColumnState,
|
|
114
398
|
value: ValueSpecification | undefined,
|
|
115
399
|
): RawLambda => {
|
|
116
|
-
|
|
117
|
-
|
|
400
|
+
let propertyExpression: AbstractPropertyExpression | undefined = undefined;
|
|
401
|
+
let aggregationOperator: QueryBuilderAggregateOperator | undefined =
|
|
402
|
+
undefined;
|
|
403
|
+
let columnLambda: ValueSpecification | undefined = undefined;
|
|
404
|
+
let columnName: string | undefined = undefined;
|
|
405
|
+
let columnType: Type | undefined = undefined;
|
|
406
|
+
let column: QueryBuilderProjectionColumnState;
|
|
407
|
+
if (columnState instanceof QueryBuilderProjectionColumnState) {
|
|
408
|
+
column = columnState;
|
|
409
|
+
} else {
|
|
410
|
+
column = columnState.projectionColumnState;
|
|
411
|
+
aggregationOperator = columnState.operator;
|
|
412
|
+
}
|
|
413
|
+
if (column instanceof QueryBuilderDerivationProjectionColumnState) {
|
|
414
|
+
columnLambda = new INTERNAL__UnknownValueSpecification(
|
|
415
|
+
V1_serializeRawValueSpecification(
|
|
416
|
+
V1_transformRawLambda(
|
|
417
|
+
column.lambda,
|
|
418
|
+
new V1_GraphTransformerContextBuilder(
|
|
419
|
+
// TODO?: do we need to include the plugins here?
|
|
420
|
+
[],
|
|
421
|
+
).build(),
|
|
422
|
+
),
|
|
423
|
+
),
|
|
424
|
+
);
|
|
425
|
+
columnName = column.columnName;
|
|
426
|
+
columnType = column.returnType;
|
|
427
|
+
} else {
|
|
428
|
+
propertyExpression =
|
|
429
|
+
buildPropertyExpressionChainWithDefaultMilestoningDates(
|
|
430
|
+
guaranteeType(column, QueryBuilderSimpleProjectionColumnState)
|
|
431
|
+
.propertyExpressionState.propertyExpression,
|
|
432
|
+
DEFAULT_LAMBDA_VARIABLE_NAME,
|
|
433
|
+
queryBuilderState.observerContext,
|
|
434
|
+
);
|
|
435
|
+
}
|
|
436
|
+
|
|
437
|
+
return buildRawLambda(
|
|
438
|
+
queryBuilderState,
|
|
439
|
+
propertyExpression,
|
|
440
|
+
aggregationOperator,
|
|
441
|
+
columnLambda,
|
|
442
|
+
columnType,
|
|
443
|
+
columnName,
|
|
444
|
+
value,
|
|
445
|
+
);
|
|
118
446
|
};
|
|
119
447
|
|
|
120
448
|
export const buildTypeaheadOptions = (result: ExecutionResult): string[] => {
|
|
@@ -73,6 +73,7 @@ export abstract class QueryBuilderFetchStructureImplementationState
|
|
|
73
73
|
options?: LambdaFunctionBuilderOption,
|
|
74
74
|
): void;
|
|
75
75
|
abstract initialize(): void;
|
|
76
|
+
abstract initializeWithQuery(): void;
|
|
76
77
|
abstract get hashCode(): string;
|
|
77
78
|
|
|
78
79
|
get TEMPORARY__showPostFetchStructurePanel(): boolean {
|
|
@@ -37,6 +37,7 @@ export class QueryBuilderFetchStructureState {
|
|
|
37
37
|
makeObservable(this, {
|
|
38
38
|
implementation: observable,
|
|
39
39
|
changeImplementation: action,
|
|
40
|
+
initializeWithQuery: action,
|
|
40
41
|
});
|
|
41
42
|
|
|
42
43
|
this.queryBuilderState = queryBuilderState;
|
|
@@ -77,6 +78,10 @@ export class QueryBuilderFetchStructureState {
|
|
|
77
78
|
this.implementation.initialize();
|
|
78
79
|
}
|
|
79
80
|
|
|
81
|
+
initializeWithQuery(): void {
|
|
82
|
+
this.implementation.initializeWithQuery();
|
|
83
|
+
}
|
|
84
|
+
|
|
80
85
|
fetchProperty(node: QueryBuilderExplorerTreeNodeData): void {
|
|
81
86
|
if (
|
|
82
87
|
node instanceof QueryBuilderExplorerTreePropertyNodeData &&
|
|
@@ -44,6 +44,7 @@ import {
|
|
|
44
44
|
type LambdaFunction,
|
|
45
45
|
type ValueSpecification,
|
|
46
46
|
type VariableExpression,
|
|
47
|
+
type EngineError,
|
|
47
48
|
GRAPH_MANAGER_EVENT,
|
|
48
49
|
extractSourceInformationCoordinates,
|
|
49
50
|
LAMBDA_PIPE,
|
|
@@ -150,9 +151,11 @@ export class QueryBuilderTDSState
|
|
|
150
151
|
removeAllColumns: action,
|
|
151
152
|
replaceColumn: action,
|
|
152
153
|
initialize: action,
|
|
154
|
+
initializeWithQuery: action,
|
|
153
155
|
setShowPostFilterPanel: action,
|
|
154
156
|
setShowWindowFuncPanel: action,
|
|
155
157
|
convertDerivationProjectionObjects: flow,
|
|
158
|
+
fetchDerivedReturnTypes: flow,
|
|
156
159
|
});
|
|
157
160
|
|
|
158
161
|
this.resultSetModifierState = new QueryResultSetModifierState(this);
|
|
@@ -358,6 +361,12 @@ export class QueryBuilderTDSState
|
|
|
358
361
|
this.setShowWindowFuncPanel(false);
|
|
359
362
|
}
|
|
360
363
|
|
|
364
|
+
override initializeWithQuery(): void {
|
|
365
|
+
flowResult(this.fetchDerivedReturnTypes()).catch(
|
|
366
|
+
this.queryBuilderState.applicationStore.alertUnhandledError,
|
|
367
|
+
);
|
|
368
|
+
}
|
|
369
|
+
|
|
361
370
|
isColumnInUse(tdsCol: QueryBuilderTDSColumnState): boolean {
|
|
362
371
|
return Boolean(
|
|
363
372
|
[
|
|
@@ -741,7 +750,7 @@ export class QueryBuilderTDSState
|
|
|
741
750
|
filterByType(QueryBuilderDerivationProjectionColumnState),
|
|
742
751
|
);
|
|
743
752
|
if (derivationColumns.length) {
|
|
744
|
-
// we will return false if any derivation cols are present as we can't verify is the variable is
|
|
753
|
+
// we will return false if any derivation cols are present as we can't verify is the variable is used
|
|
745
754
|
return false;
|
|
746
755
|
}
|
|
747
756
|
const usedInProjection = columns
|
|
@@ -760,4 +769,37 @@ export class QueryBuilderTDSState
|
|
|
760
769
|
this.resultSetModifierState,
|
|
761
770
|
]);
|
|
762
771
|
}
|
|
772
|
+
|
|
773
|
+
*fetchDerivedReturnTypes(): GeneratorFn<void> {
|
|
774
|
+
try {
|
|
775
|
+
const input = new Map<string, RawLambda>();
|
|
776
|
+
const graph = this.queryBuilderState.graphManagerState.graph;
|
|
777
|
+
const derivedCols = this.projectionColumns.filter(
|
|
778
|
+
filterByType(QueryBuilderDerivationProjectionColumnState),
|
|
779
|
+
);
|
|
780
|
+
derivedCols.forEach((col) =>
|
|
781
|
+
input.set(col.columnName, col.getIsolatedRawLambda()),
|
|
782
|
+
);
|
|
783
|
+
const result =
|
|
784
|
+
(yield this.queryBuilderState.graphManagerState.graphManager.getLambdasReturnType(
|
|
785
|
+
input,
|
|
786
|
+
graph,
|
|
787
|
+
)) as {
|
|
788
|
+
results: Map<string, string>;
|
|
789
|
+
errors: Map<string, EngineError>;
|
|
790
|
+
};
|
|
791
|
+
Array.from(result.results.entries()).forEach((res) => {
|
|
792
|
+
const col = derivedCols.find((d) => d.columnName === res[0]);
|
|
793
|
+
if (col) {
|
|
794
|
+
col.setLambdaReturnType(res[1]);
|
|
795
|
+
}
|
|
796
|
+
});
|
|
797
|
+
} catch (error) {
|
|
798
|
+
assertErrorThrown(error);
|
|
799
|
+
this.queryBuilderState.applicationStore.logService.info(
|
|
800
|
+
LogEvent.create('Unable to fetch derived return types'),
|
|
801
|
+
error,
|
|
802
|
+
);
|
|
803
|
+
}
|
|
804
|
+
}
|
|
763
805
|
}
|
|
@@ -480,6 +480,9 @@ export class QueryBuilderPostFilterState
|
|
|
480
480
|
operators: QueryBuilderPostFilterOperator[] = [];
|
|
481
481
|
rootIds: string[] = [];
|
|
482
482
|
nodes = new Map<string, QueryBuilderPostFilterTreeNodeData>();
|
|
483
|
+
derivedColumnBeingDropped:
|
|
484
|
+
| QueryBuilderDerivationProjectionColumnState
|
|
485
|
+
| undefined;
|
|
483
486
|
|
|
484
487
|
constructor(
|
|
485
488
|
tdsState: QueryBuilderTDSState,
|
|
@@ -492,6 +495,7 @@ export class QueryBuilderPostFilterState
|
|
|
492
495
|
rootIds: observable,
|
|
493
496
|
nodes: observable,
|
|
494
497
|
lambdaParameterName: observable,
|
|
498
|
+
derivedColumnBeingDropped: observable,
|
|
495
499
|
setLambdaParameterName: action,
|
|
496
500
|
setSelectedNode: action,
|
|
497
501
|
addNodeFromNode: action,
|
|
@@ -504,6 +508,7 @@ export class QueryBuilderPostFilterState
|
|
|
504
508
|
expandTree: action,
|
|
505
509
|
replaceBlankNodeWithNode: action,
|
|
506
510
|
setRearrangingConditions: action,
|
|
511
|
+
setDerivedColumnBeingDropped: action,
|
|
507
512
|
hashCode: computed,
|
|
508
513
|
});
|
|
509
514
|
|
|
@@ -526,6 +531,12 @@ export class QueryBuilderPostFilterState
|
|
|
526
531
|
);
|
|
527
532
|
}
|
|
528
533
|
|
|
534
|
+
setDerivedColumnBeingDropped(
|
|
535
|
+
val: QueryBuilderDerivationProjectionColumnState | undefined,
|
|
536
|
+
): void {
|
|
537
|
+
this.derivedColumnBeingDropped = val;
|
|
538
|
+
}
|
|
539
|
+
|
|
529
540
|
get isEmpty(): boolean {
|
|
530
541
|
return !this.nodes.size && !this.rootIds.length;
|
|
531
542
|
}
|