@finos/legend-query-builder 0.6.22 → 0.6.23
Sign up to get free protection for your applications and to get access to all the features.
- package/lib/components/QueryBuilderParametersPanel.d.ts.map +1 -1
- package/lib/components/QueryBuilderParametersPanel.js +2 -2
- package/lib/components/QueryBuilderParametersPanel.js.map +1 -1
- package/lib/components/QueryBuilderResultPanel.d.ts.map +1 -1
- package/lib/components/QueryBuilderResultPanel.js +8 -3
- package/lib/components/QueryBuilderResultPanel.js.map +1 -1
- package/lib/components/QueryBuilderTextEditor.d.ts.map +1 -1
- package/lib/components/QueryBuilderTextEditor.js +4 -3
- package/lib/components/QueryBuilderTextEditor.js.map +1 -1
- package/lib/components/explorer/QueryBuilderExplorerPanel.d.ts.map +1 -1
- package/lib/components/explorer/QueryBuilderExplorerPanel.js +8 -7
- package/lib/components/explorer/QueryBuilderExplorerPanel.js.map +1 -1
- package/lib/components/shared/LambdaParameterValuesEditor.d.ts.map +1 -1
- package/lib/components/shared/LambdaParameterValuesEditor.js +10 -4
- package/lib/components/shared/LambdaParameterValuesEditor.js.map +1 -1
- package/lib/components/shared/QueryBuilderVariableSelector.js +1 -1
- package/lib/components/shared/QueryBuilderVariableSelector.js.map +1 -1
- package/lib/graphManager/QueryBuilderSupportedFunctions.d.ts +1 -0
- package/lib/graphManager/QueryBuilderSupportedFunctions.d.ts.map +1 -1
- package/lib/graphManager/QueryBuilderSupportedFunctions.js +1 -0
- package/lib/graphManager/QueryBuilderSupportedFunctions.js.map +1 -1
- package/lib/index.css +2 -2
- package/lib/index.css.map +1 -1
- package/lib/package.json +1 -1
- package/lib/stores/QueryBuilderPreviewDataHelper.d.ts.map +1 -1
- package/lib/stores/QueryBuilderPreviewDataHelper.js +6 -2
- package/lib/stores/QueryBuilderPreviewDataHelper.js.map +1 -1
- package/lib/stores/QueryBuilderResultState.d.ts +3 -1
- package/lib/stores/QueryBuilderResultState.d.ts.map +1 -1
- package/lib/stores/QueryBuilderResultState.js +4 -1
- package/lib/stores/QueryBuilderResultState.js.map +1 -1
- package/lib/stores/QueryBuilderValueSpecificationBuilder.d.ts.map +1 -1
- package/lib/stores/QueryBuilderValueSpecificationBuilder.js +24 -8
- package/lib/stores/QueryBuilderValueSpecificationBuilder.js.map +1 -1
- package/lib/stores/QueryBuilderValueSpecificationBuilderHelper.d.ts +7 -1
- package/lib/stores/QueryBuilderValueSpecificationBuilderHelper.d.ts.map +1 -1
- package/lib/stores/QueryBuilderValueSpecificationBuilderHelper.js +49 -32
- package/lib/stores/QueryBuilderValueSpecificationBuilderHelper.js.map +1 -1
- package/lib/stores/fetch-structure/tds/projection/QueryBuilderProjectionValueSpecificationBuilder.d.ts.map +1 -1
- package/lib/stores/fetch-structure/tds/projection/QueryBuilderProjectionValueSpecificationBuilder.js +2 -2
- package/lib/stores/fetch-structure/tds/projection/QueryBuilderProjectionValueSpecificationBuilder.js.map +1 -1
- package/lib/stores/shared/LambdaParameterState.d.ts +1 -1
- package/lib/stores/shared/LambdaParameterState.d.ts.map +1 -1
- package/lib/stores/shared/LambdaParameterState.js +1 -1
- package/lib/stores/shared/LambdaParameterState.js.map +1 -1
- package/package.json +4 -4
- package/src/components/QueryBuilderParametersPanel.tsx +2 -3
- package/src/components/QueryBuilderResultPanel.tsx +17 -3
- package/src/components/QueryBuilderTextEditor.tsx +10 -2
- package/src/components/explorer/QueryBuilderExplorerPanel.tsx +12 -1
- package/src/components/shared/LambdaParameterValuesEditor.tsx +24 -11
- package/src/components/shared/QueryBuilderVariableSelector.tsx +1 -1
- package/src/graphManager/QueryBuilderSupportedFunctions.ts +1 -0
- package/src/stores/QueryBuilderPreviewDataHelper.ts +6 -2
- package/src/stores/QueryBuilderResultState.ts +7 -1
- package/src/stores/QueryBuilderValueSpecificationBuilder.ts +39 -9
- package/src/stores/QueryBuilderValueSpecificationBuilderHelper.ts +77 -34
- package/src/stores/fetch-structure/tds/projection/QueryBuilderProjectionValueSpecificationBuilder.ts +2 -0
- package/src/stores/shared/LambdaParameterState.ts +1 -1
@@ -133,7 +133,7 @@ export const VariableViewer = observer(
|
|
133
133
|
<TimesIcon />
|
134
134
|
</button>
|
135
135
|
<VariableInfoTooltip variable={variable}>
|
136
|
-
<div className="value-spec-editor__variable__info">
|
136
|
+
<div className="query-builder__variables__variable__action value-spec-editor__variable__info">
|
137
137
|
<InfoCircleIcon />
|
138
138
|
</div>
|
139
139
|
</VariableInfoTooltip>
|
@@ -19,6 +19,7 @@ export enum QUERY_BUILDER_SUPPORTED_FUNCTIONS {
|
|
19
19
|
EXISTS = 'meta::pure::functions::collection::exists',
|
20
20
|
FILTER = 'meta::pure::functions::collection::filter',
|
21
21
|
GET_ALL = 'meta::pure::functions::collection::getAll',
|
22
|
+
GET_ALL_VERSIONS = 'meta::pure::functions::collection::getAllVersions',
|
22
23
|
NOT = 'meta::pure::functions::boolean::not',
|
23
24
|
OR = 'meta::pure::functions::boolean::or',
|
24
25
|
TAKE = 'meta::pure::functions::collection::take',
|
@@ -141,7 +141,9 @@ export const buildNumericPreviewDataQuery = (
|
|
141
141
|
aggregationState.changeColumnAggregateOperator(valAggOp, colState);
|
142
142
|
});
|
143
143
|
|
144
|
-
return builderState.resultState.buildExecutionRawLambda(
|
144
|
+
return builderState.resultState.buildExecutionRawLambda({
|
145
|
+
useAllVersionsForMilestoning: true,
|
146
|
+
});
|
145
147
|
};
|
146
148
|
|
147
149
|
export const buildNonNumericPreviewDataQuery = (
|
@@ -198,5 +200,7 @@ export const buildNonNumericPreviewDataQuery = (
|
|
198
200
|
sortValueCount,
|
199
201
|
new SortColumnState(valueProjectionColState),
|
200
202
|
];
|
201
|
-
return builderState.resultState.buildExecutionRawLambda(
|
203
|
+
return builderState.resultState.buildExecutionRawLambda({
|
204
|
+
useAllVersionsForMilestoning: true,
|
205
|
+
});
|
202
206
|
};
|
@@ -42,6 +42,7 @@ import {
|
|
42
42
|
buildExecutionParameterValues,
|
43
43
|
getExecutionQueryFromRawLambda,
|
44
44
|
} from './shared/LambdaParameterState.js';
|
45
|
+
import type { LambdaFunctionBuilderOption } from './QueryBuilderValueSpecificationBuilderHelper.js';
|
45
46
|
|
46
47
|
const DEFAULT_LIMIT = 1000;
|
47
48
|
|
@@ -51,6 +52,7 @@ export class QueryBuilderResultState {
|
|
51
52
|
readonly executionPlanState: ExecutionPlanState;
|
52
53
|
|
53
54
|
previewLimit = DEFAULT_LIMIT;
|
55
|
+
pressedRunQuery = ActionState.create();
|
54
56
|
isRunningQuery = false;
|
55
57
|
isGeneratingPlan = false;
|
56
58
|
executionResult?: ExecutionResult | undefined;
|
@@ -113,11 +115,14 @@ export class QueryBuilderResultState {
|
|
113
115
|
return false;
|
114
116
|
}
|
115
117
|
|
116
|
-
buildExecutionRawLambda(
|
118
|
+
buildExecutionRawLambda(
|
119
|
+
executionOptions?: LambdaFunctionBuilderOption,
|
120
|
+
): RawLambda {
|
117
121
|
let query: RawLambda;
|
118
122
|
if (this.queryBuilderState.isQuerySupported) {
|
119
123
|
const lambdaFunction = buildLambdaFunction(this.queryBuilderState, {
|
120
124
|
isBuildingExecutionQuery: true,
|
125
|
+
...executionOptions,
|
121
126
|
});
|
122
127
|
query = buildRawLambdaFromLambdaFunction(
|
123
128
|
lambdaFunction,
|
@@ -241,6 +246,7 @@ export class QueryBuilderResultState {
|
|
241
246
|
this.queryBuilderState.applicationStore.notifyError(error);
|
242
247
|
} finally {
|
243
248
|
this.setIsRunningQuery(false);
|
249
|
+
this.pressedRunQuery.complete();
|
244
250
|
}
|
245
251
|
}
|
246
252
|
|
@@ -57,6 +57,24 @@ const buildGetAllFunction = (
|
|
57
57
|
return _func;
|
58
58
|
};
|
59
59
|
|
60
|
+
const buildGetAllVersionsFunction = (
|
61
|
+
_class: Class,
|
62
|
+
multiplicity: Multiplicity,
|
63
|
+
): SimpleFunctionExpression => {
|
64
|
+
const _func = new SimpleFunctionExpression(
|
65
|
+
extractElementNameFromPath(
|
66
|
+
QUERY_BUILDER_SUPPORTED_FUNCTIONS.GET_ALL_VERSIONS,
|
67
|
+
),
|
68
|
+
);
|
69
|
+
const classInstance = new InstanceValue(
|
70
|
+
multiplicity,
|
71
|
+
GenericTypeExplicitReference.create(new GenericType(_class)),
|
72
|
+
);
|
73
|
+
classInstance.values[0] = PackageableElementExplicitReference.create(_class);
|
74
|
+
_func.parametersValues.push(classInstance);
|
75
|
+
return _func;
|
76
|
+
};
|
77
|
+
|
60
78
|
const buildLetExpression = (
|
61
79
|
constantExpressionState: QueryBuilderConstantExpressionState,
|
62
80
|
): SimpleFunctionExpression => {
|
@@ -101,20 +119,32 @@ export const buildLambdaFunction = (
|
|
101
119
|
),
|
102
120
|
);
|
103
121
|
|
104
|
-
// build getAll()
|
105
|
-
const getAllFunction = buildGetAllFunction(_class, Multiplicity.ONE);
|
106
|
-
|
107
|
-
// build milestoning parameter(s) for getAll()
|
108
122
|
const milestoningStereotype = getMilestoneTemporalStereotype(
|
109
123
|
_class,
|
110
124
|
queryBuilderState.graphManagerState.graph,
|
111
125
|
);
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
126
|
+
|
127
|
+
if (milestoningStereotype && options?.useAllVersionsForMilestoning) {
|
128
|
+
// build getAllVersions() when we preview data for milestoned classes
|
129
|
+
// because if we use getAll() we need to pass in data to execute the query
|
130
|
+
// but we don't give user that option in this flow.
|
131
|
+
const getAllVersionsFunction = buildGetAllVersionsFunction(
|
132
|
+
_class,
|
133
|
+
Multiplicity.ONE,
|
134
|
+
);
|
135
|
+
|
136
|
+
lambdaFunction.expressionSequence[0] = getAllVersionsFunction;
|
137
|
+
} else {
|
138
|
+
// build getAll()
|
139
|
+
const getAllFunction = buildGetAllFunction(_class, Multiplicity.ONE);
|
140
|
+
if (milestoningStereotype) {
|
141
|
+
// build milestoning parameter(s) for getAll()
|
142
|
+
queryBuilderState.milestoningState
|
143
|
+
.getMilestoningImplementation(milestoningStereotype)
|
144
|
+
.buildGetAllParameters(getAllFunction);
|
145
|
+
}
|
146
|
+
lambdaFunction.expressionSequence[0] = getAllFunction;
|
116
147
|
}
|
117
|
-
lambdaFunction.expressionSequence[0] = getAllFunction;
|
118
148
|
|
119
149
|
// build watermark
|
120
150
|
buildWatermarkExpression(queryBuilderState.watermarkState, lambdaFunction);
|
@@ -16,9 +16,12 @@
|
|
16
16
|
|
17
17
|
import {
|
18
18
|
AbstractPropertyExpression,
|
19
|
+
Class,
|
19
20
|
DerivedProperty,
|
20
21
|
INTERNAL__PropagatedValue,
|
21
22
|
matchFunctionName,
|
23
|
+
MILESTONING_VERSION_PROPERTY_SUFFIX,
|
24
|
+
PropertyExplicitReference,
|
22
25
|
SimpleFunctionExpression,
|
23
26
|
VariableExpression,
|
24
27
|
type ValueSpecification,
|
@@ -30,7 +33,11 @@ import {
|
|
30
33
|
} from '@finos/legend-shared';
|
31
34
|
import { QUERY_BUILDER_SUPPORTED_FUNCTIONS } from '../graphManager/QueryBuilderSupportedFunctions.js';
|
32
35
|
import type { QueryBuilderState } from './QueryBuilderState.js';
|
33
|
-
import {
|
36
|
+
import {
|
37
|
+
functionExpression_setParametersValues,
|
38
|
+
propertyExpression_setFunc,
|
39
|
+
variableExpression_setName,
|
40
|
+
} from './shared/ValueSpecificationModifierHelper.js';
|
34
41
|
|
35
42
|
/**
|
36
43
|
* Gets the value of ValueSpecification given INTERNAL__PropagatedValue is pointing to.
|
@@ -50,6 +57,7 @@ export const buildPropertyExpressionChain = (
|
|
50
57
|
propertyExpression: AbstractPropertyExpression,
|
51
58
|
queryBuilderState: QueryBuilderState,
|
52
59
|
lambdaParameterName: string,
|
60
|
+
options?: LambdaFunctionBuilderOption,
|
53
61
|
/**
|
54
62
|
* As of now, we don't support date propagation for aggregation-class functions
|
55
63
|
* so we have this temporary flag to disable date propagation, there could be other
|
@@ -81,45 +89,73 @@ export const buildPropertyExpressionChain = (
|
|
81
89
|
currentExpression instanceof AbstractPropertyExpression &&
|
82
90
|
currentExpression.func.value instanceof DerivedProperty
|
83
91
|
) {
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
92
|
+
// check if we are building the expression chain to view preview data and if the
|
93
|
+
// the property is milestoned. If that is the case we need to replace the
|
94
|
+
// `property` with `propertyAllVersions`
|
95
|
+
if (
|
96
|
+
options?.useAllVersionsForMilestoning &&
|
97
|
+
currentExpression.func.value.genericType.value.rawType instanceof
|
98
|
+
Class &&
|
99
|
+
currentExpression.func.value._OWNER._generatedMilestonedProperties
|
100
|
+
.length !== 0
|
101
|
+
) {
|
102
|
+
const name = currentExpression.func.value.name;
|
103
|
+
const property =
|
104
|
+
currentExpression.func.value._OWNER._generatedMilestonedProperties.find(
|
105
|
+
(e) => e.name === `${name}${MILESTONING_VERSION_PROPERTY_SUFFIX}`,
|
106
|
+
);
|
107
|
+
if (property) {
|
108
|
+
propertyExpression_setFunc(
|
109
|
+
currentExpression,
|
110
|
+
PropertyExplicitReference.create(property),
|
111
|
+
);
|
112
|
+
functionExpression_setParametersValues(
|
113
|
+
currentExpression,
|
114
|
+
[guaranteeNonNullable(currentExpression.parametersValues[0])],
|
115
|
+
queryBuilderState.observableContext,
|
116
|
+
);
|
117
|
+
}
|
118
|
+
} else {
|
119
|
+
const currentPropertyExpression = currentExpression;
|
120
|
+
const parameterValues = currentExpression.parametersValues.slice(1);
|
121
|
+
parameterValues.forEach((parameterValue, index) => {
|
122
|
+
if (parameterValue instanceof INTERNAL__PropagatedValue) {
|
123
|
+
// Replace with argumentless derived property expression only when default date propagation is supported
|
95
124
|
if (
|
96
|
-
|
97
|
-
|
98
|
-
(index === 0 &&
|
99
|
-
currentPropertyExpression.parametersValues.length === 3 &&
|
100
|
-
!(
|
101
|
-
currentPropertyExpression.parametersValues[2] instanceof
|
102
|
-
INTERNAL__PropagatedValue &&
|
103
|
-
currentPropertyExpression.parametersValues[2]
|
104
|
-
.isPropagatedValue === true
|
105
|
-
))
|
125
|
+
!TEMPORARY__disableDatePropagation &&
|
126
|
+
parameterValue.isPropagatedValue
|
106
127
|
) {
|
128
|
+
// NOTE: For `bitemporal` property check if the property expression has parameters which are not instance of
|
129
|
+
// `INTERNAL_PropagatedValue` then pass the parameters as user explicitly changed values of either of the parameters.
|
130
|
+
if (
|
131
|
+
(index === 1 &&
|
132
|
+
currentPropertyExpression.parametersValues.length === 3) ||
|
133
|
+
(index === 0 &&
|
134
|
+
currentPropertyExpression.parametersValues.length === 3 &&
|
135
|
+
!(
|
136
|
+
currentPropertyExpression.parametersValues[2] instanceof
|
137
|
+
INTERNAL__PropagatedValue &&
|
138
|
+
currentPropertyExpression.parametersValues[2]
|
139
|
+
.isPropagatedValue === true
|
140
|
+
))
|
141
|
+
) {
|
142
|
+
currentPropertyExpression.parametersValues[index + 1] =
|
143
|
+
getValueOfInternalPropagatedValue(parameterValue);
|
144
|
+
} else {
|
145
|
+
currentPropertyExpression.parametersValues = [
|
146
|
+
guaranteeNonNullable(
|
147
|
+
guaranteeType(currentExpression, AbstractPropertyExpression)
|
148
|
+
.parametersValues[0],
|
149
|
+
),
|
150
|
+
];
|
151
|
+
}
|
152
|
+
} else {
|
107
153
|
currentPropertyExpression.parametersValues[index + 1] =
|
108
154
|
getValueOfInternalPropagatedValue(parameterValue);
|
109
|
-
} else {
|
110
|
-
currentPropertyExpression.parametersValues = [
|
111
|
-
guaranteeNonNullable(
|
112
|
-
guaranteeType(currentExpression, AbstractPropertyExpression)
|
113
|
-
.parametersValues[0],
|
114
|
-
),
|
115
|
-
];
|
116
155
|
}
|
117
|
-
} else {
|
118
|
-
currentPropertyExpression.parametersValues[index + 1] =
|
119
|
-
getValueOfInternalPropagatedValue(parameterValue);
|
120
156
|
}
|
121
|
-
}
|
122
|
-
}
|
157
|
+
});
|
158
|
+
}
|
123
159
|
}
|
124
160
|
currentExpression = nextExpression;
|
125
161
|
// Take care of chains of subtype (a pattern that is not useful, but we want to support and rectify)
|
@@ -150,5 +186,12 @@ export type LambdaFunctionBuilderOption = {
|
|
150
186
|
* queryBuilderState will make the lambda function building process overrides several query values, such as the row limit.
|
151
187
|
*/
|
152
188
|
isBuildingExecutionQuery?: boolean | undefined;
|
189
|
+
|
190
|
+
/**
|
191
|
+
* Set this to `true` when we construct query for execution within the app to view preview data.
|
192
|
+
* queryBuilderState will make the lambda function building process overrides `.all()` to `.allVersions()` if the Class
|
193
|
+
* is milestoned and `property` to `propertyAllVersions` if a property is milestoned.
|
194
|
+
*/
|
195
|
+
useAllVersionsForMilestoning?: boolean | undefined;
|
153
196
|
keepSourceInformation?: boolean | undefined;
|
154
197
|
};
|
package/src/stores/fetch-structure/tds/projection/QueryBuilderProjectionValueSpecificationBuilder.ts
CHANGED
@@ -227,6 +227,7 @@ export const appendProjection = (
|
|
227
227
|
projectionColumnState.propertyExpressionState.propertyExpression,
|
228
228
|
projectionColumnState.propertyExpressionState.queryBuilderState,
|
229
229
|
projectionColumnState.lambdaParameterName,
|
230
|
+
options,
|
230
231
|
true,
|
231
232
|
),
|
232
233
|
],
|
@@ -328,6 +329,7 @@ export const appendProjection = (
|
|
328
329
|
projectionColumnState.propertyExpressionState.propertyExpression,
|
329
330
|
projectionColumnState.propertyExpressionState.queryBuilderState,
|
330
331
|
projectionColumnState.lambdaParameterName,
|
332
|
+
options,
|
331
333
|
),
|
332
334
|
],
|
333
335
|
queryBuilderState.graphManagerState.graph,
|