@finos/legend-query-builder 4.14.51 → 4.14.52
Sign up to get free protection for your applications and to get access to all the features.
- package/lib/components/QueryBuilderConstantExpressionPanel.js +1 -1
- package/lib/components/QueryBuilderConstantExpressionPanel.js.map +1 -1
- package/lib/components/QueryBuilderParametersPanel.js +1 -1
- package/lib/components/QueryBuilderParametersPanel.js.map +1 -1
- package/lib/components/QueryBuilderPropertyExpressionEditor.js +1 -1
- package/lib/components/QueryBuilderPropertyExpressionEditor.js.map +1 -1
- package/lib/components/QueryBuilderSideBar.d.ts.map +1 -1
- package/lib/components/QueryBuilderSideBar.js +1 -1
- package/lib/components/QueryBuilderSideBar.js.map +1 -1
- package/lib/components/QueryBuilder_LegendApplicationPlugin.d.ts +0 -1
- package/lib/components/QueryBuilder_LegendApplicationPlugin.d.ts.map +1 -1
- package/lib/components/ServiceQuerySetupUtils.d.ts.map +1 -1
- package/lib/components/__test-utils__/QueryBuilderComponentTestUtils.d.ts +1 -1
- package/lib/components/__test-utils__/QueryBuilderComponentTestUtils.d.ts.map +1 -1
- package/lib/components/__test-utils__/QueryBuilderComponentTestUtils.js +4 -2
- package/lib/components/__test-utils__/QueryBuilderComponentTestUtils.js.map +1 -1
- package/lib/components/execution-plan/AllocationExecutionNodeViewer.d.ts +0 -1
- package/lib/components/execution-plan/AllocationExecutionNodeViewer.d.ts.map +1 -1
- package/lib/components/execution-plan/ConstantExecutionNodeViewer.d.ts +0 -1
- package/lib/components/execution-plan/ConstantExecutionNodeViewer.d.ts.map +1 -1
- package/lib/components/execution-plan/DataTypeResultTypeViewer.d.ts +0 -1
- package/lib/components/execution-plan/DataTypeResultTypeViewer.d.ts.map +1 -1
- package/lib/components/execution-plan/ExecutionPlanViewer.d.ts +0 -1
- package/lib/components/execution-plan/ExecutionPlanViewer.d.ts.map +1 -1
- package/lib/components/execution-plan/FunctionParametersValidationNodeViewer.js +1 -1
- package/lib/components/execution-plan/ImplementationViewer.d.ts +0 -1
- package/lib/components/execution-plan/ImplementationViewer.d.ts.map +1 -1
- package/lib/components/execution-plan/PartialClassResultViewer.d.ts +0 -1
- package/lib/components/execution-plan/PartialClassResultViewer.d.ts.map +1 -1
- package/lib/components/execution-plan/PartialClassResultViewer.js +1 -1
- package/lib/components/execution-plan/RelationalClassQueryTempTableGraphFetchExecutionNodeViewer.d.ts +0 -1
- package/lib/components/execution-plan/RelationalClassQueryTempTableGraphFetchExecutionNodeViewer.d.ts.map +1 -1
- package/lib/components/execution-plan/RelationalClassQueryTempTableGraphFetchExecutionNodeViewer.js +1 -1
- package/lib/components/execution-plan/RelationalCrossRootQueryTempTableGraphFetchExecutionNodeViewer.d.ts +0 -1
- package/lib/components/execution-plan/RelationalCrossRootQueryTempTableGraphFetchExecutionNodeViewer.d.ts.map +1 -1
- package/lib/components/execution-plan/RelationalCrossRootQueryTempTableGraphFetchExecutionNodeViewer.js +1 -1
- package/lib/components/execution-plan/RelationalRootQueryTempTableGraphFetchExecutionNodeViewer.d.ts +0 -1
- package/lib/components/execution-plan/RelationalRootQueryTempTableGraphFetchExecutionNodeViewer.d.ts.map +1 -1
- package/lib/components/execution-plan/RelationalRootQueryTempTableGraphFetchExecutionNodeViewer.js +1 -1
- package/lib/components/execution-plan/RelationalTDSInstantiationExecutionNodeViewer.d.ts +0 -1
- package/lib/components/execution-plan/RelationalTDSInstantiationExecutionNodeViewer.d.ts.map +1 -1
- package/lib/components/execution-plan/ResultTypeViewer.d.ts +0 -1
- package/lib/components/execution-plan/ResultTypeViewer.d.ts.map +1 -1
- package/lib/components/execution-plan/SQLExecutionNodeViewer.d.ts +0 -1
- package/lib/components/execution-plan/SQLExecutionNodeViewer.d.ts.map +1 -1
- package/lib/components/execution-plan/SQLExecutionNodeViewer.js +1 -1
- package/lib/components/execution-plan/SequenceExecutionNodeViewer.d.ts +0 -1
- package/lib/components/execution-plan/SequenceExecutionNodeViewer.d.ts.map +1 -1
- package/lib/components/execution-plan/StoreMappingGlobalGraphFetchExecutionNodeViewer.d.ts +0 -1
- package/lib/components/execution-plan/StoreMappingGlobalGraphFetchExecutionNodeViewer.d.ts.map +1 -1
- package/lib/components/execution-plan/StoreMappingGlobalGraphFetchExecutionNodeViewer.js +2 -2
- package/lib/components/execution-plan/TDSResultTypeViewer.d.ts +0 -1
- package/lib/components/execution-plan/TDSResultTypeViewer.d.ts.map +1 -1
- package/lib/components/execution-plan/TDSResultTypeViewer.js +1 -1
- package/lib/components/execution-plan/TempTableStrategyViewer.d.ts +0 -1
- package/lib/components/execution-plan/TempTableStrategyViewer.d.ts.map +1 -1
- package/lib/components/explorer/QueryBuilderExplorerPanel.d.ts +0 -1
- package/lib/components/explorer/QueryBuilderExplorerPanel.d.ts.map +1 -1
- package/lib/components/explorer/QueryBuilderMilestoningParameterEditor.js +1 -1
- package/lib/components/explorer/QueryBuilderMilestoningParameterEditor.js.map +1 -1
- package/lib/components/fetch-structure/QueryBuilderGraphFetchTreePanel.d.ts +0 -1
- package/lib/components/fetch-structure/QueryBuilderGraphFetchTreePanel.d.ts.map +1 -1
- package/lib/components/fetch-structure/QueryBuilderPostFilterPanel.d.ts.map +1 -1
- package/lib/components/fetch-structure/QueryBuilderPostFilterPanel.js +1 -1
- package/lib/components/fetch-structure/QueryBuilderPostFilterPanel.js.map +1 -1
- package/lib/components/fetch-structure/QueryBuilderResultModifierPanel.js +1 -1
- package/lib/components/fetch-structure/QueryBuilderResultModifierPanel.js.map +1 -1
- package/lib/components/fetch-structure/QueryBuilderTDSComponentHelper.d.ts +0 -1
- package/lib/components/fetch-structure/QueryBuilderTDSComponentHelper.d.ts.map +1 -1
- package/lib/components/fetch-structure/QueryBuilderTDSPanel.js +1 -1
- package/lib/components/fetch-structure/QueryBuilderTDSPanel.js.map +1 -1
- package/lib/components/filter/QueryBuilderFilterPanel.d.ts.map +1 -1
- package/lib/components/filter/QueryBuilderFilterPanel.js +9 -4
- package/lib/components/filter/QueryBuilderFilterPanel.js.map +1 -1
- package/lib/components/result/QueryBuilderResultPanel.d.ts.map +1 -1
- package/lib/components/result/QueryBuilderResultPanel.js +1 -1
- package/lib/components/result/QueryBuilderResultPanel.js.map +1 -1
- package/lib/components/result/tds/QueryBuilderTDSGridResult.d.ts.map +1 -1
- package/lib/components/result/tds/QueryBuilderTDSGridResult.js +10 -8
- package/lib/components/result/tds/QueryBuilderTDSGridResult.js.map +1 -1
- package/lib/components/result/tds/QueryBuilderTDSResultShared.d.ts +0 -1
- package/lib/components/result/tds/QueryBuilderTDSResultShared.d.ts.map +1 -1
- package/lib/components/result/tds/QueryBuilderTDSResultShared.js.map +1 -1
- package/lib/components/result/tds/QueryBuilderTDSSimpleGridResult.js +2 -2
- package/lib/components/result/tds/QueryBuilderTDSSimpleGridResult.js.map +1 -1
- package/lib/components/shared/BasicValueSpecificationEditor.d.ts +19 -4
- package/lib/components/shared/BasicValueSpecificationEditor.d.ts.map +1 -1
- package/lib/components/shared/BasicValueSpecificationEditor.js +97 -36
- package/lib/components/shared/BasicValueSpecificationEditor.js.map +1 -1
- package/lib/components/shared/CustomDatePicker.d.ts +2 -1
- package/lib/components/shared/CustomDatePicker.d.ts.map +1 -1
- package/lib/components/shared/CustomDatePicker.js +8 -5
- package/lib/components/shared/CustomDatePicker.js.map +1 -1
- package/lib/components/shared/LambdaParameterValuesEditor.js +1 -1
- package/lib/components/shared/LambdaParameterValuesEditor.js.map +1 -1
- package/lib/components/shared/QueryBuilderPanelIssueCountBadge.d.ts +0 -1
- package/lib/components/shared/QueryBuilderPanelIssueCountBadge.d.ts.map +1 -1
- package/lib/components/shared/QueryBuilderPropertyInfoTooltip.d.ts +0 -1
- package/lib/components/shared/QueryBuilderPropertyInfoTooltip.d.ts.map +1 -1
- package/lib/components/shared/QueryBuilderRootClassInfoTooltip.d.ts +0 -1
- package/lib/components/shared/QueryBuilderRootClassInfoTooltip.d.ts.map +1 -1
- package/lib/components/shared/QueryBuilderVariableSelector.d.ts.map +1 -1
- package/lib/components/shared/QueryBuilderVariableSelector.js +1 -1
- package/lib/components/shared/QueryBuilderVariableSelector.js.map +1 -1
- package/lib/components/workflows/ClassQueryBuilder.d.ts.map +1 -1
- package/lib/components/workflows/MappingQueryBuilder.d.ts.map +1 -1
- package/lib/components/workflows/ServiceQueryBuilder.d.ts.map +1 -1
- package/lib/graph/QueryBuilderMetaModelConst.d.ts +1 -0
- package/lib/graph/QueryBuilderMetaModelConst.d.ts.map +1 -1
- package/lib/graph/QueryBuilderMetaModelConst.js +1 -0
- package/lib/graph/QueryBuilderMetaModelConst.js.map +1 -1
- package/lib/graph-manager/protocol/pure/QueryBuilder_PureGraphManagerExtension.d.ts.map +1 -1
- package/lib/graph-manager/protocol/pure/QueryBuilder_PureGraphManagerExtension.js.map +1 -1
- package/lib/graph-manager/protocol/pure/v1/V1_QueryValueSpecificationBuilderHelper.d.ts +1 -2
- package/lib/graph-manager/protocol/pure/v1/V1_QueryValueSpecificationBuilderHelper.d.ts.map +1 -1
- package/lib/graph-manager/protocol/pure/v1/V1_QueryValueSpecificationBuilderHelper.js +68 -8
- package/lib/graph-manager/protocol/pure/v1/V1_QueryValueSpecificationBuilderHelper.js.map +1 -1
- package/lib/index.css +2 -2
- package/lib/index.css.map +1 -1
- package/lib/package.json +7 -7
- package/lib/stores/QueryBuilderState.d.ts +0 -1
- package/lib/stores/QueryBuilderState.d.ts.map +1 -1
- package/lib/stores/QueryBuilderStateBuilder.d.ts.map +1 -1
- package/lib/stores/QueryBuilderStateBuilder.js +5 -1
- package/lib/stores/QueryBuilderStateBuilder.js.map +1 -1
- package/lib/stores/QueryBuilderValueSpecificationHelper.js.map +1 -1
- package/lib/stores/QueryBuilder_LegendApplicationPlugin_Extension.d.ts +0 -1
- package/lib/stores/QueryBuilder_LegendApplicationPlugin_Extension.d.ts.map +1 -1
- package/lib/stores/__test-utils__/QueryBuilderStateTestUtils.d.ts.map +1 -1
- package/lib/stores/execution-plan/ExecutionPlanState.d.ts.map +1 -1
- package/lib/stores/explorer/QueryBuilderExplorerState.d.ts +0 -1
- package/lib/stores/explorer/QueryBuilderExplorerState.d.ts.map +1 -1
- package/lib/stores/explorer/QueryFunctionsExplorerState.d.ts.map +1 -1
- package/lib/stores/fetch-structure/graph-fetch/QueryBuilderGraphFetchTreeUtil.d.ts.map +1 -1
- package/lib/stores/fetch-structure/graph-fetch/QueryBuilderGraphFetchTreeValueSpecificationBuilder.d.ts.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 +6 -0
- package/lib/stores/fetch-structure/tds/QueryBuilderTDSState.js.map +1 -1
- package/lib/stores/fetch-structure/tds/projection/QueryBuilderProjectionStateBuilder.d.ts +11 -0
- package/lib/stores/fetch-structure/tds/projection/QueryBuilderProjectionStateBuilder.d.ts.map +1 -1
- package/lib/stores/fetch-structure/tds/projection/QueryBuilderProjectionStateBuilder.js +76 -20
- package/lib/stores/fetch-structure/tds/projection/QueryBuilderProjectionStateBuilder.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 +70 -34
- package/lib/stores/fetch-structure/tds/projection/QueryBuilderProjectionValueSpecificationBuilder.js.map +1 -1
- package/lib/stores/filter/QueryBuilderFilterState.d.ts +2 -0
- package/lib/stores/filter/QueryBuilderFilterState.d.ts.map +1 -1
- package/lib/stores/filter/QueryBuilderFilterState.js +7 -0
- package/lib/stores/filter/QueryBuilderFilterState.js.map +1 -1
- package/lib/stores/shared/ValueSpecificationEditorHelper.d.ts +5 -2
- package/lib/stores/shared/ValueSpecificationEditorHelper.d.ts.map +1 -1
- package/lib/stores/shared/ValueSpecificationEditorHelper.js +20 -9
- package/lib/stores/shared/ValueSpecificationEditorHelper.js.map +1 -1
- package/lib/stores/shared/ValueSpecificationModifierHelper.d.ts.map +1 -1
- package/lib/stores/workflows/ClassQueryBuilderState.d.ts.map +1 -1
- package/lib/stores/workflows/MappingQueryBuilderState.d.ts.map +1 -1
- package/lib/stores/workflows/ServiceQueryBuilderState.d.ts.map +1 -1
- package/package.json +15 -15
- package/src/components/QueryBuilderConstantExpressionPanel.tsx +1 -1
- package/src/components/QueryBuilderParametersPanel.tsx +1 -1
- package/src/components/QueryBuilderPropertyExpressionEditor.tsx +1 -1
- package/src/components/QueryBuilderSideBar.tsx +1 -1
- package/src/components/__test-utils__/QueryBuilderComponentTestUtils.tsx +4 -1
- package/src/components/execution-plan/FunctionParametersValidationNodeViewer.tsx +1 -1
- package/src/components/execution-plan/PartialClassResultViewer.tsx +1 -1
- package/src/components/execution-plan/RelationalClassQueryTempTableGraphFetchExecutionNodeViewer.tsx +1 -1
- package/src/components/execution-plan/RelationalCrossRootQueryTempTableGraphFetchExecutionNodeViewer.tsx +1 -1
- package/src/components/execution-plan/RelationalRootQueryTempTableGraphFetchExecutionNodeViewer.tsx +1 -1
- package/src/components/execution-plan/SQLExecutionNodeViewer.tsx +1 -1
- package/src/components/execution-plan/StoreMappingGlobalGraphFetchExecutionNodeViewer.tsx +2 -2
- package/src/components/execution-plan/TDSResultTypeViewer.tsx +1 -1
- package/src/components/explorer/QueryBuilderMilestoningParameterEditor.tsx +1 -1
- package/src/components/fetch-structure/QueryBuilderPostFilterPanel.tsx +1 -1
- package/src/components/fetch-structure/QueryBuilderResultModifierPanel.tsx +1 -1
- package/src/components/fetch-structure/QueryBuilderTDSPanel.tsx +1 -1
- package/src/components/filter/QueryBuilderFilterPanel.tsx +18 -4
- package/src/components/result/QueryBuilderResultPanel.tsx +1 -0
- package/src/components/result/tds/QueryBuilderTDSGridResult.tsx +12 -13
- package/src/components/result/tds/QueryBuilderTDSResultShared.tsx +1 -1
- package/src/components/result/tds/QueryBuilderTDSSimpleGridResult.tsx +2 -2
- package/src/components/shared/BasicValueSpecificationEditor.tsx +257 -55
- package/src/components/shared/CustomDatePicker.tsx +36 -11
- package/src/components/shared/LambdaParameterValuesEditor.tsx +1 -1
- package/src/components/shared/QueryBuilderVariableSelector.tsx +4 -1
- package/src/graph/QueryBuilderMetaModelConst.ts +1 -0
- package/src/graph-manager/protocol/pure/QueryBuilder_PureGraphManagerExtension.ts +1 -1
- package/src/graph-manager/protocol/pure/v1/V1_QueryValueSpecificationBuilderHelper.ts +189 -18
- package/src/stores/QueryBuilderStateBuilder.ts +6 -1
- package/src/stores/QueryBuilderValueSpecificationHelper.ts +2 -2
- package/src/stores/fetch-structure/tds/QueryBuilderTDSState.ts +7 -0
- package/src/stores/fetch-structure/tds/projection/QueryBuilderProjectionStateBuilder.ts +167 -43
- package/src/stores/fetch-structure/tds/projection/QueryBuilderProjectionValueSpecificationBuilder.ts +145 -69
- package/src/stores/filter/QueryBuilderFilterState.ts +8 -0
- package/src/stores/shared/ValueSpecificationEditorHelper.ts +47 -7
- package/tsconfig.package.json +1 -1
@@ -28,6 +28,7 @@ import {
|
|
28
28
|
V1_RawLambda,
|
29
29
|
VariableExpression,
|
30
30
|
PrimitiveInstanceValue,
|
31
|
+
LambdaFunctionInstanceValue,
|
31
32
|
} from '@finos/legend-graph';
|
32
33
|
import {
|
33
34
|
assertNonNullable,
|
@@ -59,22 +60,11 @@ import {
|
|
59
60
|
import { QueryBuilderTDSState } from '../QueryBuilderTDSState.js';
|
60
61
|
import { SortColumnState } from '../QueryResultSetModifierState.js';
|
61
62
|
|
62
|
-
|
63
|
+
const validateTDSProjectPrecedingExpression = (
|
63
64
|
expression: SimpleFunctionExpression,
|
64
65
|
queryBuilderState: QueryBuilderState,
|
65
66
|
parentLambda: LambdaFunction,
|
66
67
|
): void => {
|
67
|
-
// update fetch-structure
|
68
|
-
queryBuilderState.fetchStructureState.changeImplementation(
|
69
|
-
FETCH_STRUCTURE_IMPLEMENTATION.TABULAR_DATA_STRUCTURE,
|
70
|
-
);
|
71
|
-
|
72
|
-
// check parameters
|
73
|
-
assertTrue(
|
74
|
-
expression.parametersValues.length === 3,
|
75
|
-
`Can't process project() expression: project() expects 2 arguments`,
|
76
|
-
);
|
77
|
-
|
78
68
|
// check preceding expression
|
79
69
|
const precedingExpression = guaranteeType(
|
80
70
|
expression.parametersValues[0],
|
@@ -96,47 +86,143 @@ export const processTDSProjectExpression = (
|
|
96
86
|
parentLambda,
|
97
87
|
queryBuilderState,
|
98
88
|
);
|
89
|
+
};
|
90
|
+
|
91
|
+
// process project() that uses col()
|
92
|
+
const processTDSProjectColExpression = (
|
93
|
+
expression: SimpleFunctionExpression,
|
94
|
+
queryBuilderState: QueryBuilderState,
|
95
|
+
parentLambda: LambdaFunction,
|
96
|
+
): void => {
|
97
|
+
// update fetch-structure
|
98
|
+
queryBuilderState.fetchStructureState.changeImplementation(
|
99
|
+
FETCH_STRUCTURE_IMPLEMENTATION.TABULAR_DATA_STRUCTURE,
|
100
|
+
);
|
101
|
+
// check parameters
|
102
|
+
assertTrue(
|
103
|
+
expression.parametersValues.length === 2,
|
104
|
+
`Can't process project() expression: project() expects 2 arguments`,
|
105
|
+
);
|
106
|
+
|
107
|
+
validateTDSProjectPrecedingExpression(
|
108
|
+
expression,
|
109
|
+
queryBuilderState,
|
110
|
+
parentLambda,
|
111
|
+
);
|
99
112
|
|
100
113
|
// check columns
|
101
114
|
const columnLambdas = expression.parametersValues[1];
|
102
|
-
|
103
|
-
columnLambdas
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
115
|
+
if (columnLambdas instanceof CollectionInstanceValue) {
|
116
|
+
columnLambdas.values.map((value) =>
|
117
|
+
QueryBuilderValueSpecificationProcessor.processChild(
|
118
|
+
value,
|
119
|
+
expression,
|
120
|
+
parentLambda,
|
121
|
+
queryBuilderState,
|
122
|
+
),
|
123
|
+
);
|
124
|
+
} else {
|
125
|
+
assertType(
|
126
|
+
columnLambdas,
|
127
|
+
SimpleFunctionExpression,
|
128
|
+
`Can't process project() expression: project() expects argument #1 to be a function expression`,
|
129
|
+
);
|
108
130
|
QueryBuilderValueSpecificationProcessor.processChild(
|
109
|
-
|
131
|
+
columnLambdas,
|
110
132
|
expression,
|
111
133
|
parentLambda,
|
112
134
|
queryBuilderState,
|
113
|
-
)
|
114
|
-
|
135
|
+
);
|
136
|
+
}
|
137
|
+
};
|
115
138
|
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
)
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
139
|
+
/**
|
140
|
+
* process project()
|
141
|
+
* variants could be:
|
142
|
+
* Person.all()->project([x|x.firmID], ['Id'])
|
143
|
+
* Person.all()->project(x|x.firmID, ['Id'])
|
144
|
+
* Person.all()->project([x|x.firmID], 'Id')
|
145
|
+
* Person.all()->project(x|x.firmID, 'Id')
|
146
|
+
* Person.all()->project(col({p:my::Person[1]|$p.firmID}, 'Id'))
|
147
|
+
* Person.all()->project([ col({p:my::Person[1]|$p.firmID}, 'Id') ])
|
148
|
+
*/
|
149
|
+
export const processTDSProjectExpression = (
|
150
|
+
expression: SimpleFunctionExpression,
|
151
|
+
queryBuilderState: QueryBuilderState,
|
152
|
+
parentLambda: LambdaFunction,
|
153
|
+
): void => {
|
154
|
+
if (expression.parametersValues.length === 2) {
|
155
|
+
processTDSProjectColExpression(expression, queryBuilderState, parentLambda);
|
156
|
+
} else {
|
157
|
+
// update fetch-structure
|
158
|
+
queryBuilderState.fetchStructureState.changeImplementation(
|
159
|
+
FETCH_STRUCTURE_IMPLEMENTATION.TABULAR_DATA_STRUCTURE,
|
160
|
+
);
|
130
161
|
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
162
|
+
// check parameters
|
163
|
+
assertTrue(
|
164
|
+
expression.parametersValues.length === 3,
|
165
|
+
`Can't process project() expression: project() expects 3 arguments`,
|
166
|
+
);
|
167
|
+
|
168
|
+
// check preceding expression
|
169
|
+
validateTDSProjectPrecedingExpression(
|
170
|
+
expression,
|
171
|
+
queryBuilderState,
|
172
|
+
parentLambda,
|
173
|
+
);
|
174
|
+
|
175
|
+
// check columns
|
176
|
+
const columnLambdas = expression.parametersValues[1];
|
177
|
+
assertType(
|
178
|
+
columnLambdas,
|
179
|
+
CollectionInstanceValue,
|
180
|
+
`Can't process project() expression: project() expects argument #1 to be a collection`,
|
181
|
+
);
|
182
|
+
columnLambdas.values.map((value) =>
|
183
|
+
QueryBuilderValueSpecificationProcessor.processChild(
|
184
|
+
value,
|
185
|
+
expression,
|
186
|
+
parentLambda,
|
187
|
+
queryBuilderState,
|
188
|
+
),
|
189
|
+
);
|
190
|
+
|
191
|
+
// check column aliases
|
192
|
+
const columnAliases = expression.parametersValues[2];
|
193
|
+
let aliases: string[] = [];
|
194
|
+
if (columnAliases instanceof CollectionInstanceValue) {
|
195
|
+
assertType(
|
196
|
+
columnAliases,
|
197
|
+
CollectionInstanceValue,
|
198
|
+
`Can't process project() expression: project() expects argument #2 to be a collection or a string`,
|
199
|
+
);
|
200
|
+
aliases = columnAliases.values
|
201
|
+
.map(extractNullableStringFromInstanceValue)
|
202
|
+
.filter(isNonNullable);
|
203
|
+
} else {
|
204
|
+
assertType(
|
205
|
+
columnAliases,
|
206
|
+
PrimitiveInstanceValue,
|
207
|
+
`Can't process project() expression: project() expects argument #2 to be a collection or string`,
|
208
|
+
);
|
209
|
+
aliases = [columnAliases.values[0] as string];
|
210
|
+
}
|
211
|
+
assertTrue(
|
212
|
+
columnLambdas.values.length === aliases.length,
|
213
|
+
`Can't process project() expression: number of aliases does not match the number of columns`,
|
139
214
|
);
|
215
|
+
|
216
|
+
// build state
|
217
|
+
if (
|
218
|
+
queryBuilderState.fetchStructureState.implementation instanceof
|
219
|
+
QueryBuilderTDSState
|
220
|
+
) {
|
221
|
+
const tdsState = queryBuilderState.fetchStructureState.implementation;
|
222
|
+
tdsState.projectionColumns.forEach((column, idx) =>
|
223
|
+
column.setColumnName(aliases[idx] as string),
|
224
|
+
);
|
225
|
+
}
|
140
226
|
}
|
141
227
|
};
|
142
228
|
|
@@ -247,6 +333,44 @@ export const processTDSProjectionDerivationExpression = (
|
|
247
333
|
}
|
248
334
|
};
|
249
335
|
|
336
|
+
export const processTDSColExpression = (
|
337
|
+
expression: SimpleFunctionExpression,
|
338
|
+
queryBuilderState: QueryBuilderState,
|
339
|
+
): void => {
|
340
|
+
// check parameters
|
341
|
+
assertTrue(
|
342
|
+
expression.parametersValues.length === 2,
|
343
|
+
`Can't process col() func expression: col() expects 2 argument`,
|
344
|
+
);
|
345
|
+
// check preceding expression
|
346
|
+
const lambdaFunc = guaranteeType(
|
347
|
+
expression.parametersValues[0],
|
348
|
+
LambdaFunctionInstanceValue,
|
349
|
+
`Can't process col() func expressionn: only support col() immediately following an lambda function`,
|
350
|
+
);
|
351
|
+
const colNameInstance = guaranteeType(
|
352
|
+
expression.parametersValues[1],
|
353
|
+
PrimitiveInstanceValue,
|
354
|
+
`Can't process col() func expression: the #2 argument of col() should be a string`,
|
355
|
+
);
|
356
|
+
processTDSProjectionColumnPropertyExpression(
|
357
|
+
guaranteeType(
|
358
|
+
lambdaFunc.values[0]?.expressionSequence[0],
|
359
|
+
AbstractPropertyExpression,
|
360
|
+
`Can't process col() func expression: lambda function of col() should contain AbstractPropertyExpression`,
|
361
|
+
),
|
362
|
+
colNameInstance.values[0] as string,
|
363
|
+
queryBuilderState,
|
364
|
+
);
|
365
|
+
if (
|
366
|
+
queryBuilderState.fetchStructureState.implementation instanceof
|
367
|
+
QueryBuilderTDSState
|
368
|
+
) {
|
369
|
+
const tdsState = queryBuilderState.fetchStructureState.implementation;
|
370
|
+
tdsState.setUseColFunc(true);
|
371
|
+
}
|
372
|
+
};
|
373
|
+
|
250
374
|
export const processTDSTakeExpression = (
|
251
375
|
expression: SimpleFunctionExpression,
|
252
376
|
queryBuilderState: QueryBuilderState,
|
package/src/stores/fetch-structure/tds/projection/QueryBuilderProjectionValueSpecificationBuilder.ts
CHANGED
@@ -16,13 +16,13 @@
|
|
16
16
|
|
17
17
|
import {
|
18
18
|
type LambdaFunction,
|
19
|
+
type ValueSpecification,
|
19
20
|
CollectionInstanceValue,
|
20
21
|
extractElementNameFromPath,
|
21
22
|
GenericType,
|
22
23
|
GenericTypeExplicitReference,
|
23
24
|
PrimitiveInstanceValue,
|
24
25
|
SimpleFunctionExpression,
|
25
|
-
type ValueSpecification,
|
26
26
|
INTERNAL__UnknownValueSpecification,
|
27
27
|
V1_serializeRawValueSpecification,
|
28
28
|
V1_transformRawLambda,
|
@@ -35,6 +35,7 @@ import {
|
|
35
35
|
UnsupportedOperationError,
|
36
36
|
} from '@finos/legend-shared';
|
37
37
|
import {
|
38
|
+
type QueryBuilderProjectionColumnState,
|
38
39
|
QueryBuilderDerivationProjectionColumnState,
|
39
40
|
QueryBuilderSimpleProjectionColumnState,
|
40
41
|
} from './QueryBuilderProjectionColumnState.js';
|
@@ -175,6 +176,62 @@ const appendResultSetModifier = (
|
|
175
176
|
return lambdaFunction;
|
176
177
|
};
|
177
178
|
|
179
|
+
const buildProjectColFunc = (
|
180
|
+
tdsState: QueryBuilderTDSState,
|
181
|
+
projectionColumnState: QueryBuilderProjectionColumnState,
|
182
|
+
options?: LambdaFunctionBuilderOption,
|
183
|
+
): SimpleFunctionExpression => {
|
184
|
+
const colFunc = new SimpleFunctionExpression(
|
185
|
+
extractElementNameFromPath(QUERY_BUILDER_SUPPORTED_FUNCTIONS.TDS_COL),
|
186
|
+
);
|
187
|
+
let columnLambda: ValueSpecification;
|
188
|
+
if (
|
189
|
+
projectionColumnState instanceof QueryBuilderSimpleProjectionColumnState
|
190
|
+
) {
|
191
|
+
columnLambda = buildGenericLambdaFunctionInstanceValue(
|
192
|
+
projectionColumnState.lambdaParameterName,
|
193
|
+
[
|
194
|
+
buildPropertyExpressionChain(
|
195
|
+
projectionColumnState.propertyExpressionState.propertyExpression,
|
196
|
+
projectionColumnState.propertyExpressionState.queryBuilderState,
|
197
|
+
projectionColumnState.lambdaParameterName,
|
198
|
+
options,
|
199
|
+
),
|
200
|
+
],
|
201
|
+
tdsState.queryBuilderState.graphManagerState.graph,
|
202
|
+
);
|
203
|
+
} else if (
|
204
|
+
projectionColumnState instanceof QueryBuilderDerivationProjectionColumnState
|
205
|
+
) {
|
206
|
+
columnLambda = new INTERNAL__UnknownValueSpecification(
|
207
|
+
V1_serializeRawValueSpecification(
|
208
|
+
V1_transformRawLambda(
|
209
|
+
projectionColumnState.lambda,
|
210
|
+
new V1_GraphTransformerContextBuilder(
|
211
|
+
// TODO?: do we need to include the plugins here?
|
212
|
+
[],
|
213
|
+
)
|
214
|
+
.withKeepSourceInformationFlag(
|
215
|
+
Boolean(options?.keepSourceInformation),
|
216
|
+
)
|
217
|
+
.build(),
|
218
|
+
),
|
219
|
+
),
|
220
|
+
);
|
221
|
+
} else {
|
222
|
+
throw new UnsupportedOperationError(
|
223
|
+
`Can't build project() column expression: unsupported projection column state`,
|
224
|
+
projectionColumnState,
|
225
|
+
);
|
226
|
+
}
|
227
|
+
const colAlias = new PrimitiveInstanceValue(
|
228
|
+
GenericTypeExplicitReference.create(new GenericType(PrimitiveType.STRING)),
|
229
|
+
);
|
230
|
+
colAlias.values.push(projectionColumnState.columnName);
|
231
|
+
colFunc.parametersValues = [columnLambda, colAlias];
|
232
|
+
return colFunc;
|
233
|
+
};
|
234
|
+
|
178
235
|
export const appendProjection = (
|
179
236
|
tdsState: QueryBuilderTDSState,
|
180
237
|
lambdaFunction: LambdaFunction,
|
@@ -330,79 +387,98 @@ export const appendProjection = (
|
|
330
387
|
QUERY_BUILDER_SUPPORTED_FUNCTIONS.TDS_PROJECT,
|
331
388
|
),
|
332
389
|
);
|
333
|
-
|
334
|
-
|
335
|
-
|
336
|
-
|
337
|
-
|
338
|
-
);
|
339
|
-
const colAliases = new CollectionInstanceValue(
|
340
|
-
queryBuilderState.graphManagerState.graph.getMultiplicity(
|
341
|
-
tdsState.projectionColumns.length,
|
342
|
-
tdsState.projectionColumns.length,
|
343
|
-
),
|
344
|
-
);
|
345
|
-
tdsState.projectionColumns.forEach((projectionColumnState) => {
|
346
|
-
// column alias
|
347
|
-
const colAlias = new PrimitiveInstanceValue(
|
348
|
-
GenericTypeExplicitReference.create(
|
349
|
-
new GenericType(PrimitiveType.STRING),
|
390
|
+
if (tdsState.useColFunc) {
|
391
|
+
const colFuncCollection = new CollectionInstanceValue(
|
392
|
+
queryBuilderState.graphManagerState.graph.getMultiplicity(
|
393
|
+
tdsState.projectionColumns.length,
|
394
|
+
tdsState.projectionColumns.length,
|
350
395
|
),
|
351
396
|
);
|
352
|
-
|
353
|
-
|
354
|
-
|
355
|
-
// column projection
|
356
|
-
let columnLambda: ValueSpecification;
|
357
|
-
if (
|
358
|
-
projectionColumnState instanceof
|
359
|
-
QueryBuilderSimpleProjectionColumnState
|
360
|
-
) {
|
361
|
-
columnLambda = buildGenericLambdaFunctionInstanceValue(
|
362
|
-
projectionColumnState.lambdaParameterName,
|
363
|
-
[
|
364
|
-
buildPropertyExpressionChain(
|
365
|
-
projectionColumnState.propertyExpressionState
|
366
|
-
.propertyExpression,
|
367
|
-
projectionColumnState.propertyExpressionState.queryBuilderState,
|
368
|
-
projectionColumnState.lambdaParameterName,
|
369
|
-
options,
|
370
|
-
),
|
371
|
-
],
|
372
|
-
queryBuilderState.graphManagerState.graph,
|
397
|
+
tdsState.projectionColumns.forEach((projectionColumnState) => {
|
398
|
+
colFuncCollection.values.push(
|
399
|
+
buildProjectColFunc(tdsState, projectionColumnState, options),
|
373
400
|
);
|
374
|
-
}
|
375
|
-
|
376
|
-
|
377
|
-
|
378
|
-
|
379
|
-
|
380
|
-
|
381
|
-
|
382
|
-
|
383
|
-
|
384
|
-
|
385
|
-
|
386
|
-
|
387
|
-
|
388
|
-
|
389
|
-
|
390
|
-
|
401
|
+
});
|
402
|
+
projectFunction.parametersValues = [
|
403
|
+
precedingExpression,
|
404
|
+
colFuncCollection,
|
405
|
+
];
|
406
|
+
} else {
|
407
|
+
const colLambdas = new CollectionInstanceValue(
|
408
|
+
queryBuilderState.graphManagerState.graph.getMultiplicity(
|
409
|
+
tdsState.projectionColumns.length,
|
410
|
+
tdsState.projectionColumns.length,
|
411
|
+
),
|
412
|
+
);
|
413
|
+
const colAliases = new CollectionInstanceValue(
|
414
|
+
queryBuilderState.graphManagerState.graph.getMultiplicity(
|
415
|
+
tdsState.projectionColumns.length,
|
416
|
+
tdsState.projectionColumns.length,
|
417
|
+
),
|
418
|
+
);
|
419
|
+
tdsState.projectionColumns.forEach((projectionColumnState) => {
|
420
|
+
// column alias
|
421
|
+
const colAlias = new PrimitiveInstanceValue(
|
422
|
+
GenericTypeExplicitReference.create(
|
423
|
+
new GenericType(PrimitiveType.STRING),
|
391
424
|
),
|
392
425
|
);
|
393
|
-
|
394
|
-
|
395
|
-
|
396
|
-
|
397
|
-
|
398
|
-
|
399
|
-
|
400
|
-
|
401
|
-
|
402
|
-
|
403
|
-
|
404
|
-
|
405
|
-
|
426
|
+
colAlias.values.push(projectionColumnState.columnName);
|
427
|
+
colAliases.values.push(colAlias);
|
428
|
+
|
429
|
+
// column projection
|
430
|
+
let columnLambda: ValueSpecification;
|
431
|
+
if (
|
432
|
+
projectionColumnState instanceof
|
433
|
+
QueryBuilderSimpleProjectionColumnState
|
434
|
+
) {
|
435
|
+
columnLambda = buildGenericLambdaFunctionInstanceValue(
|
436
|
+
projectionColumnState.lambdaParameterName,
|
437
|
+
[
|
438
|
+
buildPropertyExpressionChain(
|
439
|
+
projectionColumnState.propertyExpressionState
|
440
|
+
.propertyExpression,
|
441
|
+
projectionColumnState.propertyExpressionState
|
442
|
+
.queryBuilderState,
|
443
|
+
projectionColumnState.lambdaParameterName,
|
444
|
+
options,
|
445
|
+
),
|
446
|
+
],
|
447
|
+
queryBuilderState.graphManagerState.graph,
|
448
|
+
);
|
449
|
+
} else if (
|
450
|
+
projectionColumnState instanceof
|
451
|
+
QueryBuilderDerivationProjectionColumnState
|
452
|
+
) {
|
453
|
+
columnLambda = new INTERNAL__UnknownValueSpecification(
|
454
|
+
V1_serializeRawValueSpecification(
|
455
|
+
V1_transformRawLambda(
|
456
|
+
projectionColumnState.lambda,
|
457
|
+
new V1_GraphTransformerContextBuilder(
|
458
|
+
// TODO?: do we need to include the plugins here?
|
459
|
+
[],
|
460
|
+
)
|
461
|
+
.withKeepSourceInformationFlag(
|
462
|
+
Boolean(options?.keepSourceInformation),
|
463
|
+
)
|
464
|
+
.build(),
|
465
|
+
),
|
466
|
+
),
|
467
|
+
);
|
468
|
+
} else {
|
469
|
+
throw new UnsupportedOperationError(
|
470
|
+
`Can't build project() column expression: unsupported projection column state`,
|
471
|
+
projectionColumnState,
|
472
|
+
);
|
473
|
+
}
|
474
|
+
colLambdas.values.push(columnLambda);
|
475
|
+
});
|
476
|
+
projectFunction.parametersValues = [
|
477
|
+
precedingExpression,
|
478
|
+
colLambdas,
|
479
|
+
colAliases,
|
480
|
+
];
|
481
|
+
}
|
406
482
|
lambdaFunction.expressionSequence[0] = projectFunction;
|
407
483
|
} else {
|
408
484
|
const projectFunction = buildRelationProjection(
|
@@ -415,18 +415,26 @@ export class QueryBuilderFilterTreeConditionNodeData
|
|
415
415
|
implements Hashable
|
416
416
|
{
|
417
417
|
condition: FilterConditionState;
|
418
|
+
isNewlyAdded: boolean;
|
418
419
|
|
419
420
|
constructor(parentId: string | undefined, condition: FilterConditionState) {
|
420
421
|
super(parentId);
|
421
422
|
|
422
423
|
makeObservable(this, {
|
423
424
|
condition: observable,
|
425
|
+
isNewlyAdded: observable,
|
426
|
+
setIsNewlyAdded: action,
|
424
427
|
dragPreviewLabel: computed,
|
425
428
|
});
|
426
429
|
|
430
|
+
this.isNewlyAdded = false;
|
427
431
|
this.condition = condition;
|
428
432
|
}
|
429
433
|
|
434
|
+
setIsNewlyAdded(val: boolean): void {
|
435
|
+
this.isNewlyAdded = val;
|
436
|
+
}
|
437
|
+
|
430
438
|
get dragPreviewLabel(): string {
|
431
439
|
return this.condition.propertyExpressionState.title;
|
432
440
|
}
|
@@ -42,6 +42,7 @@ import {
|
|
42
42
|
CORE_PURE_PATH,
|
43
43
|
buildRawLambdaFromLambdaFunction,
|
44
44
|
getValueSpecificationReturnType,
|
45
|
+
isSubType,
|
45
46
|
} from '@finos/legend-graph';
|
46
47
|
import {
|
47
48
|
Randomizer,
|
@@ -58,6 +59,13 @@ import {
|
|
58
59
|
QUERY_BUILDER_PURE_PATH,
|
59
60
|
QUERY_BUILDER_SUPPORTED_FUNCTIONS,
|
60
61
|
} from '../../graph/QueryBuilderMetaModelConst.js';
|
62
|
+
import { buildDatePickerOption } from '../../components/shared/CustomDatePicker.js';
|
63
|
+
import type {
|
64
|
+
ApplicationStore,
|
65
|
+
LegendApplicationConfig,
|
66
|
+
LegendApplicationPlugin,
|
67
|
+
LegendApplicationPluginManager,
|
68
|
+
} from '@finos/legend-application';
|
61
69
|
|
62
70
|
export const createSupportedFunctionExpression = (
|
63
71
|
supportedFuncName: string,
|
@@ -293,21 +301,53 @@ export const generateVariableExpressionMockValue = (
|
|
293
301
|
|
294
302
|
export const getValueSpecificationStringValue = (
|
295
303
|
valueSpecification: ValueSpecification,
|
304
|
+
applicationStore: ApplicationStore<
|
305
|
+
LegendApplicationConfig,
|
306
|
+
LegendApplicationPluginManager<LegendApplicationPlugin>
|
307
|
+
>,
|
308
|
+
options?: {
|
309
|
+
omitEnumOwnerName?: boolean;
|
310
|
+
},
|
296
311
|
): string | undefined => {
|
297
312
|
if (valueSpecification instanceof PrimitiveInstanceValue) {
|
313
|
+
if (
|
314
|
+
isSubType(
|
315
|
+
valueSpecification.genericType.value.rawType,
|
316
|
+
PrimitiveType.DATE,
|
317
|
+
)
|
318
|
+
) {
|
319
|
+
return buildDatePickerOption(valueSpecification, applicationStore).label;
|
320
|
+
}
|
298
321
|
return valueSpecification.values[0]?.toString();
|
299
322
|
} else if (valueSpecification instanceof EnumValueInstanceValue) {
|
300
323
|
const _enum = valueSpecification.values[0];
|
324
|
+
if (options?.omitEnumOwnerName) {
|
325
|
+
return _enum?.value.name;
|
326
|
+
}
|
301
327
|
return `${_enum?.ownerReference.value.name}.${_enum?.value.name}`;
|
302
328
|
} else if (valueSpecification instanceof VariableExpression) {
|
303
329
|
return valueSpecification.name;
|
304
330
|
} else if (valueSpecification instanceof INTERNAL__PropagatedValue) {
|
305
|
-
return getValueSpecificationStringValue(
|
331
|
+
return getValueSpecificationStringValue(
|
332
|
+
valueSpecification.getValue(),
|
333
|
+
applicationStore,
|
334
|
+
);
|
306
335
|
} else if (valueSpecification instanceof SimpleFunctionExpression) {
|
336
|
+
if (
|
337
|
+
valueSpecification.genericType?.value.rawType !== undefined &&
|
338
|
+
isSubType(
|
339
|
+
valueSpecification.genericType.value.rawType,
|
340
|
+
PrimitiveType.DATE,
|
341
|
+
)
|
342
|
+
) {
|
343
|
+
return buildDatePickerOption(valueSpecification, applicationStore).label;
|
344
|
+
}
|
307
345
|
return valueSpecification.functionName;
|
308
346
|
} else if (valueSpecification instanceof CollectionInstanceValue) {
|
309
347
|
return valueSpecification.values
|
310
|
-
.map(
|
348
|
+
.map((valueSpec) =>
|
349
|
+
getValueSpecificationStringValue(valueSpec, applicationStore),
|
350
|
+
)
|
311
351
|
.join(',');
|
312
352
|
}
|
313
353
|
return undefined;
|
@@ -336,7 +376,7 @@ export const valueSpecReturnTDS = (
|
|
336
376
|
export const convertTextToPrimitiveInstanceValue = (
|
337
377
|
expectedType: Type,
|
338
378
|
value: string,
|
339
|
-
|
379
|
+
observerContext: ObserverContext,
|
340
380
|
): PrimitiveInstanceValue | null => {
|
341
381
|
let result = null;
|
342
382
|
if (expectedType instanceof PrimitiveType) {
|
@@ -345,7 +385,7 @@ export const convertTextToPrimitiveInstanceValue = (
|
|
345
385
|
result = new PrimitiveInstanceValue(
|
346
386
|
GenericTypeExplicitReference.create(new GenericType(expectedType)),
|
347
387
|
);
|
348
|
-
instanceValue_setValues(result, [value.toString()],
|
388
|
+
instanceValue_setValues(result, [value.toString()], observerContext);
|
349
389
|
break;
|
350
390
|
}
|
351
391
|
case PRIMITIVE_TYPE.NUMBER:
|
@@ -358,7 +398,7 @@ export const convertTextToPrimitiveInstanceValue = (
|
|
358
398
|
result = new PrimitiveInstanceValue(
|
359
399
|
GenericTypeExplicitReference.create(new GenericType(expectedType)),
|
360
400
|
);
|
361
|
-
instanceValue_setValues(result, [Number(value)],
|
401
|
+
instanceValue_setValues(result, [Number(value)], observerContext);
|
362
402
|
break;
|
363
403
|
}
|
364
404
|
case PRIMITIVE_TYPE.DATE:
|
@@ -369,7 +409,7 @@ export const convertTextToPrimitiveInstanceValue = (
|
|
369
409
|
result = new PrimitiveInstanceValue(
|
370
410
|
GenericTypeExplicitReference.create(new GenericType(expectedType)),
|
371
411
|
);
|
372
|
-
instanceValue_setValues(result, [value],
|
412
|
+
instanceValue_setValues(result, [value], observerContext);
|
373
413
|
break;
|
374
414
|
}
|
375
415
|
case PRIMITIVE_TYPE.DATETIME: {
|
@@ -385,7 +425,7 @@ export const convertTextToPrimitiveInstanceValue = (
|
|
385
425
|
result = new PrimitiveInstanceValue(
|
386
426
|
GenericTypeExplicitReference.create(new GenericType(expectedType)),
|
387
427
|
);
|
388
|
-
instanceValue_setValues(result, [value],
|
428
|
+
instanceValue_setValues(result, [value], observerContext);
|
389
429
|
break;
|
390
430
|
}
|
391
431
|
default:
|