@finos/legend-query-builder 4.14.51 → 4.14.53

Sign up to get free protection for your applications and to get access to all the features.
Files changed (219) hide show
  1. package/lib/components/QueryBuilder.d.ts.map +1 -1
  2. package/lib/components/QueryBuilder.js +1 -0
  3. package/lib/components/QueryBuilder.js.map +1 -1
  4. package/lib/components/QueryBuilderConstantExpressionPanel.js +1 -1
  5. package/lib/components/QueryBuilderConstantExpressionPanel.js.map +1 -1
  6. package/lib/components/QueryBuilderParametersPanel.js +1 -1
  7. package/lib/components/QueryBuilderParametersPanel.js.map +1 -1
  8. package/lib/components/QueryBuilderPropertyExpressionEditor.js +1 -1
  9. package/lib/components/QueryBuilderPropertyExpressionEditor.js.map +1 -1
  10. package/lib/components/QueryBuilderSideBar.d.ts.map +1 -1
  11. package/lib/components/QueryBuilderSideBar.js +1 -1
  12. package/lib/components/QueryBuilderSideBar.js.map +1 -1
  13. package/lib/components/QueryBuilder_LegendApplicationPlugin.d.ts +0 -1
  14. package/lib/components/QueryBuilder_LegendApplicationPlugin.d.ts.map +1 -1
  15. package/lib/components/ServiceQuerySetupUtils.d.ts.map +1 -1
  16. package/lib/components/__test-utils__/QueryBuilderComponentTestUtils.d.ts +1 -1
  17. package/lib/components/__test-utils__/QueryBuilderComponentTestUtils.d.ts.map +1 -1
  18. package/lib/components/__test-utils__/QueryBuilderComponentTestUtils.js +4 -2
  19. package/lib/components/__test-utils__/QueryBuilderComponentTestUtils.js.map +1 -1
  20. package/lib/components/execution-plan/AllocationExecutionNodeViewer.d.ts +0 -1
  21. package/lib/components/execution-plan/AllocationExecutionNodeViewer.d.ts.map +1 -1
  22. package/lib/components/execution-plan/ConstantExecutionNodeViewer.d.ts +0 -1
  23. package/lib/components/execution-plan/ConstantExecutionNodeViewer.d.ts.map +1 -1
  24. package/lib/components/execution-plan/DataTypeResultTypeViewer.d.ts +0 -1
  25. package/lib/components/execution-plan/DataTypeResultTypeViewer.d.ts.map +1 -1
  26. package/lib/components/execution-plan/ExecutionPlanViewer.d.ts +0 -1
  27. package/lib/components/execution-plan/ExecutionPlanViewer.d.ts.map +1 -1
  28. package/lib/components/execution-plan/FunctionParametersValidationNodeViewer.js +1 -1
  29. package/lib/components/execution-plan/ImplementationViewer.d.ts +0 -1
  30. package/lib/components/execution-plan/ImplementationViewer.d.ts.map +1 -1
  31. package/lib/components/execution-plan/PartialClassResultViewer.d.ts +0 -1
  32. package/lib/components/execution-plan/PartialClassResultViewer.d.ts.map +1 -1
  33. package/lib/components/execution-plan/PartialClassResultViewer.js +1 -1
  34. package/lib/components/execution-plan/RelationalClassQueryTempTableGraphFetchExecutionNodeViewer.d.ts +0 -1
  35. package/lib/components/execution-plan/RelationalClassQueryTempTableGraphFetchExecutionNodeViewer.d.ts.map +1 -1
  36. package/lib/components/execution-plan/RelationalClassQueryTempTableGraphFetchExecutionNodeViewer.js +1 -1
  37. package/lib/components/execution-plan/RelationalCrossRootQueryTempTableGraphFetchExecutionNodeViewer.d.ts +0 -1
  38. package/lib/components/execution-plan/RelationalCrossRootQueryTempTableGraphFetchExecutionNodeViewer.d.ts.map +1 -1
  39. package/lib/components/execution-plan/RelationalCrossRootQueryTempTableGraphFetchExecutionNodeViewer.js +1 -1
  40. package/lib/components/execution-plan/RelationalRootQueryTempTableGraphFetchExecutionNodeViewer.d.ts +0 -1
  41. package/lib/components/execution-plan/RelationalRootQueryTempTableGraphFetchExecutionNodeViewer.d.ts.map +1 -1
  42. package/lib/components/execution-plan/RelationalRootQueryTempTableGraphFetchExecutionNodeViewer.js +1 -1
  43. package/lib/components/execution-plan/RelationalTDSInstantiationExecutionNodeViewer.d.ts +0 -1
  44. package/lib/components/execution-plan/RelationalTDSInstantiationExecutionNodeViewer.d.ts.map +1 -1
  45. package/lib/components/execution-plan/ResultTypeViewer.d.ts +0 -1
  46. package/lib/components/execution-plan/ResultTypeViewer.d.ts.map +1 -1
  47. package/lib/components/execution-plan/SQLExecutionNodeViewer.d.ts +0 -1
  48. package/lib/components/execution-plan/SQLExecutionNodeViewer.d.ts.map +1 -1
  49. package/lib/components/execution-plan/SQLExecutionNodeViewer.js +1 -1
  50. package/lib/components/execution-plan/SequenceExecutionNodeViewer.d.ts +0 -1
  51. package/lib/components/execution-plan/SequenceExecutionNodeViewer.d.ts.map +1 -1
  52. package/lib/components/execution-plan/StoreMappingGlobalGraphFetchExecutionNodeViewer.d.ts +0 -1
  53. package/lib/components/execution-plan/StoreMappingGlobalGraphFetchExecutionNodeViewer.d.ts.map +1 -1
  54. package/lib/components/execution-plan/StoreMappingGlobalGraphFetchExecutionNodeViewer.js +2 -2
  55. package/lib/components/execution-plan/TDSResultTypeViewer.d.ts +0 -1
  56. package/lib/components/execution-plan/TDSResultTypeViewer.d.ts.map +1 -1
  57. package/lib/components/execution-plan/TDSResultTypeViewer.js +1 -1
  58. package/lib/components/execution-plan/TempTableStrategyViewer.d.ts +0 -1
  59. package/lib/components/execution-plan/TempTableStrategyViewer.d.ts.map +1 -1
  60. package/lib/components/explorer/QueryBuilderExplorerPanel.d.ts +0 -1
  61. package/lib/components/explorer/QueryBuilderExplorerPanel.d.ts.map +1 -1
  62. package/lib/components/explorer/QueryBuilderMilestoningParameterEditor.d.ts +2 -0
  63. package/lib/components/explorer/QueryBuilderMilestoningParameterEditor.d.ts.map +1 -1
  64. package/lib/components/explorer/QueryBuilderMilestoningParameterEditor.js +14 -7
  65. package/lib/components/explorer/QueryBuilderMilestoningParameterEditor.js.map +1 -1
  66. package/lib/components/fetch-structure/QueryBuilderGraphFetchTreePanel.d.ts +0 -1
  67. package/lib/components/fetch-structure/QueryBuilderGraphFetchTreePanel.d.ts.map +1 -1
  68. package/lib/components/fetch-structure/QueryBuilderPostFilterPanel.d.ts.map +1 -1
  69. package/lib/components/fetch-structure/QueryBuilderPostFilterPanel.js +1 -1
  70. package/lib/components/fetch-structure/QueryBuilderPostFilterPanel.js.map +1 -1
  71. package/lib/components/fetch-structure/QueryBuilderResultModifierPanel.d.ts.map +1 -1
  72. package/lib/components/fetch-structure/QueryBuilderResultModifierPanel.js +36 -11
  73. package/lib/components/fetch-structure/QueryBuilderResultModifierPanel.js.map +1 -1
  74. package/lib/components/fetch-structure/QueryBuilderTDSComponentHelper.d.ts +0 -1
  75. package/lib/components/fetch-structure/QueryBuilderTDSComponentHelper.d.ts.map +1 -1
  76. package/lib/components/fetch-structure/QueryBuilderTDSPanel.d.ts.map +1 -1
  77. package/lib/components/fetch-structure/QueryBuilderTDSPanel.js +5 -2
  78. package/lib/components/fetch-structure/QueryBuilderTDSPanel.js.map +1 -1
  79. package/lib/components/filter/QueryBuilderFilterPanel.d.ts.map +1 -1
  80. package/lib/components/filter/QueryBuilderFilterPanel.js +9 -4
  81. package/lib/components/filter/QueryBuilderFilterPanel.js.map +1 -1
  82. package/lib/components/result/QueryBuilderResultPanel.d.ts.map +1 -1
  83. package/lib/components/result/QueryBuilderResultPanel.js +1 -1
  84. package/lib/components/result/QueryBuilderResultPanel.js.map +1 -1
  85. package/lib/components/result/tds/QueryBuilderTDSGridResult.d.ts.map +1 -1
  86. package/lib/components/result/tds/QueryBuilderTDSGridResult.js +10 -8
  87. package/lib/components/result/tds/QueryBuilderTDSGridResult.js.map +1 -1
  88. package/lib/components/result/tds/QueryBuilderTDSResultShared.d.ts +0 -1
  89. package/lib/components/result/tds/QueryBuilderTDSResultShared.d.ts.map +1 -1
  90. package/lib/components/result/tds/QueryBuilderTDSResultShared.js.map +1 -1
  91. package/lib/components/result/tds/QueryBuilderTDSSimpleGridResult.js +2 -2
  92. package/lib/components/result/tds/QueryBuilderTDSSimpleGridResult.js.map +1 -1
  93. package/lib/components/shared/BasicValueSpecificationEditor.d.ts +19 -4
  94. package/lib/components/shared/BasicValueSpecificationEditor.d.ts.map +1 -1
  95. package/lib/components/shared/BasicValueSpecificationEditor.js +97 -36
  96. package/lib/components/shared/BasicValueSpecificationEditor.js.map +1 -1
  97. package/lib/components/shared/CustomDatePicker.d.ts +2 -1
  98. package/lib/components/shared/CustomDatePicker.d.ts.map +1 -1
  99. package/lib/components/shared/CustomDatePicker.js +8 -5
  100. package/lib/components/shared/CustomDatePicker.js.map +1 -1
  101. package/lib/components/shared/LambdaParameterValuesEditor.js +1 -1
  102. package/lib/components/shared/LambdaParameterValuesEditor.js.map +1 -1
  103. package/lib/components/shared/QueryBuilderPanelIssueCountBadge.d.ts +0 -1
  104. package/lib/components/shared/QueryBuilderPanelIssueCountBadge.d.ts.map +1 -1
  105. package/lib/components/shared/QueryBuilderPropertyInfoTooltip.d.ts +0 -1
  106. package/lib/components/shared/QueryBuilderPropertyInfoTooltip.d.ts.map +1 -1
  107. package/lib/components/shared/QueryBuilderRootClassInfoTooltip.d.ts +0 -1
  108. package/lib/components/shared/QueryBuilderRootClassInfoTooltip.d.ts.map +1 -1
  109. package/lib/components/shared/QueryBuilderVariableSelector.d.ts +3 -0
  110. package/lib/components/shared/QueryBuilderVariableSelector.d.ts.map +1 -1
  111. package/lib/components/shared/QueryBuilderVariableSelector.js +3 -3
  112. package/lib/components/shared/QueryBuilderVariableSelector.js.map +1 -1
  113. package/lib/components/workflows/ClassQueryBuilder.d.ts.map +1 -1
  114. package/lib/components/workflows/MappingQueryBuilder.d.ts.map +1 -1
  115. package/lib/components/workflows/ServiceQueryBuilder.d.ts.map +1 -1
  116. package/lib/graph/QueryBuilderMetaModelConst.d.ts +1 -0
  117. package/lib/graph/QueryBuilderMetaModelConst.d.ts.map +1 -1
  118. package/lib/graph/QueryBuilderMetaModelConst.js +1 -0
  119. package/lib/graph/QueryBuilderMetaModelConst.js.map +1 -1
  120. package/lib/graph-manager/protocol/pure/QueryBuilder_PureGraphManagerExtension.d.ts.map +1 -1
  121. package/lib/graph-manager/protocol/pure/QueryBuilder_PureGraphManagerExtension.js.map +1 -1
  122. package/lib/graph-manager/protocol/pure/v1/V1_QueryValueSpecificationBuilderHelper.d.ts +1 -2
  123. package/lib/graph-manager/protocol/pure/v1/V1_QueryValueSpecificationBuilderHelper.d.ts.map +1 -1
  124. package/lib/graph-manager/protocol/pure/v1/V1_QueryValueSpecificationBuilderHelper.js +68 -8
  125. package/lib/graph-manager/protocol/pure/v1/V1_QueryValueSpecificationBuilderHelper.js.map +1 -1
  126. package/lib/index.css +2 -2
  127. package/lib/index.css.map +1 -1
  128. package/lib/index.d.ts +1 -1
  129. package/lib/index.d.ts.map +1 -1
  130. package/lib/index.js +1 -1
  131. package/lib/index.js.map +1 -1
  132. package/lib/package.json +7 -7
  133. package/lib/stores/QueryBuilderState.d.ts +0 -1
  134. package/lib/stores/QueryBuilderState.d.ts.map +1 -1
  135. package/lib/stores/QueryBuilderState.js +1 -0
  136. package/lib/stores/QueryBuilderState.js.map +1 -1
  137. package/lib/stores/QueryBuilderStateBuilder.d.ts.map +1 -1
  138. package/lib/stores/QueryBuilderStateBuilder.js +5 -1
  139. package/lib/stores/QueryBuilderStateBuilder.js.map +1 -1
  140. package/lib/stores/QueryBuilderValueSpecificationHelper.js.map +1 -1
  141. package/lib/stores/QueryBuilder_LegendApplicationPlugin_Extension.d.ts +1 -2
  142. package/lib/stores/QueryBuilder_LegendApplicationPlugin_Extension.d.ts.map +1 -1
  143. package/lib/stores/__test-utils__/QueryBuilderStateTestUtils.d.ts.map +1 -1
  144. package/lib/stores/execution-plan/ExecutionPlanState.d.ts.map +1 -1
  145. package/lib/stores/explorer/QueryBuilderExplorerState.d.ts +0 -1
  146. package/lib/stores/explorer/QueryBuilderExplorerState.d.ts.map +1 -1
  147. package/lib/stores/explorer/QueryFunctionsExplorerState.d.ts.map +1 -1
  148. package/lib/stores/fetch-structure/graph-fetch/QueryBuilderGraphFetchTreeUtil.d.ts.map +1 -1
  149. package/lib/stores/fetch-structure/graph-fetch/QueryBuilderGraphFetchTreeValueSpecificationBuilder.d.ts.map +1 -1
  150. package/lib/stores/fetch-structure/tds/QueryBuilderTDSState.d.ts +2 -0
  151. package/lib/stores/fetch-structure/tds/QueryBuilderTDSState.d.ts.map +1 -1
  152. package/lib/stores/fetch-structure/tds/QueryBuilderTDSState.js +6 -0
  153. package/lib/stores/fetch-structure/tds/QueryBuilderTDSState.js.map +1 -1
  154. package/lib/stores/fetch-structure/tds/projection/QueryBuilderProjectionStateBuilder.d.ts +11 -0
  155. package/lib/stores/fetch-structure/tds/projection/QueryBuilderProjectionStateBuilder.d.ts.map +1 -1
  156. package/lib/stores/fetch-structure/tds/projection/QueryBuilderProjectionStateBuilder.js +76 -20
  157. package/lib/stores/fetch-structure/tds/projection/QueryBuilderProjectionStateBuilder.js.map +1 -1
  158. package/lib/stores/fetch-structure/tds/projection/QueryBuilderProjectionValueSpecificationBuilder.d.ts.map +1 -1
  159. package/lib/stores/fetch-structure/tds/projection/QueryBuilderProjectionValueSpecificationBuilder.js +70 -34
  160. package/lib/stores/fetch-structure/tds/projection/QueryBuilderProjectionValueSpecificationBuilder.js.map +1 -1
  161. package/lib/stores/filter/QueryBuilderFilterState.d.ts +2 -0
  162. package/lib/stores/filter/QueryBuilderFilterState.d.ts.map +1 -1
  163. package/lib/stores/filter/QueryBuilderFilterState.js +7 -0
  164. package/lib/stores/filter/QueryBuilderFilterState.js.map +1 -1
  165. package/lib/stores/milestoning/QueryBuilderMilestoningState.d.ts +2 -2
  166. package/lib/stores/milestoning/QueryBuilderMilestoningState.d.ts.map +1 -1
  167. package/lib/stores/milestoning/QueryBuilderMilestoningState.js +15 -4
  168. package/lib/stores/milestoning/QueryBuilderMilestoningState.js.map +1 -1
  169. package/lib/stores/shared/ValueSpecificationEditorHelper.d.ts +5 -2
  170. package/lib/stores/shared/ValueSpecificationEditorHelper.d.ts.map +1 -1
  171. package/lib/stores/shared/ValueSpecificationEditorHelper.js +20 -9
  172. package/lib/stores/shared/ValueSpecificationEditorHelper.js.map +1 -1
  173. package/lib/stores/shared/ValueSpecificationModifierHelper.d.ts.map +1 -1
  174. package/lib/stores/workflows/ClassQueryBuilderState.d.ts.map +1 -1
  175. package/lib/stores/workflows/MappingQueryBuilderState.d.ts.map +1 -1
  176. package/lib/stores/workflows/ServiceQueryBuilderState.d.ts.map +1 -1
  177. package/package.json +15 -15
  178. package/src/components/QueryBuilder.tsx +1 -0
  179. package/src/components/QueryBuilderConstantExpressionPanel.tsx +1 -1
  180. package/src/components/QueryBuilderParametersPanel.tsx +1 -1
  181. package/src/components/QueryBuilderPropertyExpressionEditor.tsx +1 -1
  182. package/src/components/QueryBuilderSideBar.tsx +1 -1
  183. package/src/components/__test-utils__/QueryBuilderComponentTestUtils.tsx +4 -1
  184. package/src/components/execution-plan/FunctionParametersValidationNodeViewer.tsx +1 -1
  185. package/src/components/execution-plan/PartialClassResultViewer.tsx +1 -1
  186. package/src/components/execution-plan/RelationalClassQueryTempTableGraphFetchExecutionNodeViewer.tsx +1 -1
  187. package/src/components/execution-plan/RelationalCrossRootQueryTempTableGraphFetchExecutionNodeViewer.tsx +1 -1
  188. package/src/components/execution-plan/RelationalRootQueryTempTableGraphFetchExecutionNodeViewer.tsx +1 -1
  189. package/src/components/execution-plan/SQLExecutionNodeViewer.tsx +1 -1
  190. package/src/components/execution-plan/StoreMappingGlobalGraphFetchExecutionNodeViewer.tsx +2 -2
  191. package/src/components/execution-plan/TDSResultTypeViewer.tsx +1 -1
  192. package/src/components/explorer/QueryBuilderMilestoningParameterEditor.tsx +60 -22
  193. package/src/components/fetch-structure/QueryBuilderPostFilterPanel.tsx +1 -1
  194. package/src/components/fetch-structure/QueryBuilderResultModifierPanel.tsx +156 -60
  195. package/src/components/fetch-structure/QueryBuilderTDSPanel.tsx +12 -2
  196. package/src/components/filter/QueryBuilderFilterPanel.tsx +18 -4
  197. package/src/components/result/QueryBuilderResultPanel.tsx +1 -0
  198. package/src/components/result/tds/QueryBuilderTDSGridResult.tsx +12 -13
  199. package/src/components/result/tds/QueryBuilderTDSResultShared.tsx +1 -1
  200. package/src/components/result/tds/QueryBuilderTDSSimpleGridResult.tsx +2 -2
  201. package/src/components/shared/BasicValueSpecificationEditor.tsx +257 -55
  202. package/src/components/shared/CustomDatePicker.tsx +36 -11
  203. package/src/components/shared/LambdaParameterValuesEditor.tsx +1 -1
  204. package/src/components/shared/QueryBuilderVariableSelector.tsx +13 -4
  205. package/src/graph/QueryBuilderMetaModelConst.ts +1 -0
  206. package/src/graph-manager/protocol/pure/QueryBuilder_PureGraphManagerExtension.ts +1 -1
  207. package/src/graph-manager/protocol/pure/v1/V1_QueryValueSpecificationBuilderHelper.ts +189 -18
  208. package/src/index.ts +1 -0
  209. package/src/stores/QueryBuilderState.ts +1 -0
  210. package/src/stores/QueryBuilderStateBuilder.ts +6 -1
  211. package/src/stores/QueryBuilderValueSpecificationHelper.ts +2 -2
  212. package/src/stores/QueryBuilder_LegendApplicationPlugin_Extension.ts +1 -1
  213. package/src/stores/fetch-structure/tds/QueryBuilderTDSState.ts +7 -0
  214. package/src/stores/fetch-structure/tds/projection/QueryBuilderProjectionStateBuilder.ts +167 -43
  215. package/src/stores/fetch-structure/tds/projection/QueryBuilderProjectionValueSpecificationBuilder.ts +145 -69
  216. package/src/stores/filter/QueryBuilderFilterState.ts +8 -0
  217. package/src/stores/milestoning/QueryBuilderMilestoningState.ts +22 -9
  218. package/src/stores/shared/ValueSpecificationEditorHelper.ts +47 -7
  219. 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
- export const processTDSProjectExpression = (
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
- assertType(
103
- columnLambdas,
104
- CollectionInstanceValue,
105
- `Can't process project() expression: project() expects argument #1 to be a collection`,
106
- );
107
- columnLambdas.values.map((value) =>
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
- value,
131
+ columnLambdas,
110
132
  expression,
111
133
  parentLambda,
112
134
  queryBuilderState,
113
- ),
114
- );
135
+ );
136
+ }
137
+ };
115
138
 
116
- // check column aliases
117
- const columnAliases = expression.parametersValues[2];
118
- assertType(
119
- columnAliases,
120
- CollectionInstanceValue,
121
- `Can't process project() expression: project() expects argument #2 to be a collection`,
122
- );
123
- assertTrue(
124
- columnLambdas.values.length === columnAliases.values.length,
125
- `Can't process project() expression: number of aliases does not match the number of columns`,
126
- );
127
- const aliases = columnAliases.values
128
- .map(extractNullableStringFromInstanceValue)
129
- .filter(isNonNullable);
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
- // build state
132
- if (
133
- queryBuilderState.fetchStructureState.implementation instanceof
134
- QueryBuilderTDSState
135
- ) {
136
- const tdsState = queryBuilderState.fetchStructureState.implementation;
137
- tdsState.projectionColumns.forEach((column, idx) =>
138
- column.setColumnName(aliases[idx] as string),
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,
@@ -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
- const colLambdas = new CollectionInstanceValue(
334
- queryBuilderState.graphManagerState.graph.getMultiplicity(
335
- tdsState.projectionColumns.length,
336
- tdsState.projectionColumns.length,
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
- colAlias.values.push(projectionColumnState.columnName);
353
- colAliases.values.push(colAlias);
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
- } else if (
375
- projectionColumnState instanceof
376
- QueryBuilderDerivationProjectionColumnState
377
- ) {
378
- columnLambda = new INTERNAL__UnknownValueSpecification(
379
- V1_serializeRawValueSpecification(
380
- V1_transformRawLambda(
381
- projectionColumnState.lambda,
382
- new V1_GraphTransformerContextBuilder(
383
- // TODO?: do we need to include the plugins here?
384
- [],
385
- )
386
- .withKeepSourceInformationFlag(
387
- Boolean(options?.keepSourceInformation),
388
- )
389
- .build(),
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
- } else {
394
- throw new UnsupportedOperationError(
395
- `Can't build project() column expression: unsupported projection column state`,
396
- projectionColumnState,
397
- );
398
- }
399
- colLambdas.values.push(columnLambda);
400
- });
401
- projectFunction.parametersValues = [
402
- precedingExpression,
403
- colLambdas,
404
- colAliases,
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
  }
@@ -482,20 +482,22 @@ export class QueryBuilderMilestoningState implements Hashable {
482
482
  }
483
483
 
484
484
  updateMilestoningParameterValue(
485
- parameter: VariableExpression,
485
+ parameter: ValueSpecification | undefined,
486
486
  value: ValueSpecification | undefined,
487
487
  ): void {
488
- const variableState =
489
- this.queryBuilderState.parametersState.parameterStates.find(
490
- (param) => param.parameter.name === parameter.name,
491
- );
492
- if (variableState) {
493
- variableState.setValue(value);
488
+ if (parameter instanceof VariableExpression) {
489
+ const variableState =
490
+ this.queryBuilderState.parametersState.parameterStates.find(
491
+ (param) => param.parameter.name === parameter.name,
492
+ );
493
+ if (variableState) {
494
+ variableState.setValue(value);
495
+ }
494
496
  }
495
497
  }
496
498
 
497
499
  getMilestoningParameterValue(
498
- milestoningParameter: ValueSpecification,
500
+ milestoningParameter: ValueSpecification | undefined,
499
501
  ): ValueSpecification | undefined {
500
502
  let value: ValueSpecification | undefined = milestoningParameter;
501
503
  if (milestoningParameter instanceof VariableExpression) {
@@ -515,7 +517,18 @@ export class QueryBuilderMilestoningState implements Hashable {
515
517
  const usedInProcessingDate = this.processingDate
516
518
  ? isValueExpressionReferencedInValue(variable, this.processingDate)
517
519
  : false;
518
- return usedInBusiness || usedInProcessingDate;
520
+ const usedInStartDate = this.startDate
521
+ ? isValueExpressionReferencedInValue(variable, this.startDate)
522
+ : false;
523
+ const usedInEndState = this.endDate
524
+ ? isValueExpressionReferencedInValue(variable, this.endDate)
525
+ : false;
526
+ return (
527
+ usedInBusiness ||
528
+ usedInProcessingDate ||
529
+ usedInStartDate ||
530
+ usedInEndState
531
+ );
519
532
  }
520
533
 
521
534
  isMilestoningParameter(parameter: VariableExpression): boolean {