@finos/legend-query-builder 4.14.50 → 4.14.52

Sign up to get free protection for your applications and to get access to all the features.
Files changed (196) hide show
  1. package/lib/components/QueryBuilderConstantExpressionPanel.js +1 -1
  2. package/lib/components/QueryBuilderConstantExpressionPanel.js.map +1 -1
  3. package/lib/components/QueryBuilderParametersPanel.js +1 -1
  4. package/lib/components/QueryBuilderParametersPanel.js.map +1 -1
  5. package/lib/components/QueryBuilderPropertyExpressionEditor.js +1 -1
  6. package/lib/components/QueryBuilderPropertyExpressionEditor.js.map +1 -1
  7. package/lib/components/QueryBuilderSideBar.d.ts.map +1 -1
  8. package/lib/components/QueryBuilderSideBar.js +1 -1
  9. package/lib/components/QueryBuilderSideBar.js.map +1 -1
  10. package/lib/components/QueryBuilder_LegendApplicationPlugin.d.ts +0 -1
  11. package/lib/components/QueryBuilder_LegendApplicationPlugin.d.ts.map +1 -1
  12. package/lib/components/ServiceQuerySetupUtils.d.ts.map +1 -1
  13. package/lib/components/__test-utils__/QueryBuilderComponentTestUtils.d.ts +1 -1
  14. package/lib/components/__test-utils__/QueryBuilderComponentTestUtils.d.ts.map +1 -1
  15. package/lib/components/__test-utils__/QueryBuilderComponentTestUtils.js +4 -2
  16. package/lib/components/__test-utils__/QueryBuilderComponentTestUtils.js.map +1 -1
  17. package/lib/components/execution-plan/AllocationExecutionNodeViewer.d.ts +0 -1
  18. package/lib/components/execution-plan/AllocationExecutionNodeViewer.d.ts.map +1 -1
  19. package/lib/components/execution-plan/ConstantExecutionNodeViewer.d.ts +0 -1
  20. package/lib/components/execution-plan/ConstantExecutionNodeViewer.d.ts.map +1 -1
  21. package/lib/components/execution-plan/DataTypeResultTypeViewer.d.ts +0 -1
  22. package/lib/components/execution-plan/DataTypeResultTypeViewer.d.ts.map +1 -1
  23. package/lib/components/execution-plan/ExecutionPlanViewer.d.ts +0 -1
  24. package/lib/components/execution-plan/ExecutionPlanViewer.d.ts.map +1 -1
  25. package/lib/components/execution-plan/FunctionParametersValidationNodeViewer.js +1 -1
  26. package/lib/components/execution-plan/ImplementationViewer.d.ts +0 -1
  27. package/lib/components/execution-plan/ImplementationViewer.d.ts.map +1 -1
  28. package/lib/components/execution-plan/PartialClassResultViewer.d.ts +0 -1
  29. package/lib/components/execution-plan/PartialClassResultViewer.d.ts.map +1 -1
  30. package/lib/components/execution-plan/PartialClassResultViewer.js +1 -1
  31. package/lib/components/execution-plan/RelationalClassQueryTempTableGraphFetchExecutionNodeViewer.d.ts +0 -1
  32. package/lib/components/execution-plan/RelationalClassQueryTempTableGraphFetchExecutionNodeViewer.d.ts.map +1 -1
  33. package/lib/components/execution-plan/RelationalClassQueryTempTableGraphFetchExecutionNodeViewer.js +1 -1
  34. package/lib/components/execution-plan/RelationalCrossRootQueryTempTableGraphFetchExecutionNodeViewer.d.ts +0 -1
  35. package/lib/components/execution-plan/RelationalCrossRootQueryTempTableGraphFetchExecutionNodeViewer.d.ts.map +1 -1
  36. package/lib/components/execution-plan/RelationalCrossRootQueryTempTableGraphFetchExecutionNodeViewer.js +1 -1
  37. package/lib/components/execution-plan/RelationalRootQueryTempTableGraphFetchExecutionNodeViewer.d.ts +0 -1
  38. package/lib/components/execution-plan/RelationalRootQueryTempTableGraphFetchExecutionNodeViewer.d.ts.map +1 -1
  39. package/lib/components/execution-plan/RelationalRootQueryTempTableGraphFetchExecutionNodeViewer.js +1 -1
  40. package/lib/components/execution-plan/RelationalTDSInstantiationExecutionNodeViewer.d.ts +0 -1
  41. package/lib/components/execution-plan/RelationalTDSInstantiationExecutionNodeViewer.d.ts.map +1 -1
  42. package/lib/components/execution-plan/ResultTypeViewer.d.ts +0 -1
  43. package/lib/components/execution-plan/ResultTypeViewer.d.ts.map +1 -1
  44. package/lib/components/execution-plan/SQLExecutionNodeViewer.d.ts +0 -1
  45. package/lib/components/execution-plan/SQLExecutionNodeViewer.d.ts.map +1 -1
  46. package/lib/components/execution-plan/SQLExecutionNodeViewer.js +1 -1
  47. package/lib/components/execution-plan/SequenceExecutionNodeViewer.d.ts +0 -1
  48. package/lib/components/execution-plan/SequenceExecutionNodeViewer.d.ts.map +1 -1
  49. package/lib/components/execution-plan/StoreMappingGlobalGraphFetchExecutionNodeViewer.d.ts +0 -1
  50. package/lib/components/execution-plan/StoreMappingGlobalGraphFetchExecutionNodeViewer.d.ts.map +1 -1
  51. package/lib/components/execution-plan/StoreMappingGlobalGraphFetchExecutionNodeViewer.js +2 -2
  52. package/lib/components/execution-plan/TDSResultTypeViewer.d.ts +0 -1
  53. package/lib/components/execution-plan/TDSResultTypeViewer.d.ts.map +1 -1
  54. package/lib/components/execution-plan/TDSResultTypeViewer.js +1 -1
  55. package/lib/components/execution-plan/TempTableStrategyViewer.d.ts +0 -1
  56. package/lib/components/execution-plan/TempTableStrategyViewer.d.ts.map +1 -1
  57. package/lib/components/explorer/QueryBuilderExplorerPanel.d.ts +0 -1
  58. package/lib/components/explorer/QueryBuilderExplorerPanel.d.ts.map +1 -1
  59. package/lib/components/explorer/QueryBuilderMilestoningParameterEditor.js +1 -1
  60. package/lib/components/explorer/QueryBuilderMilestoningParameterEditor.js.map +1 -1
  61. package/lib/components/fetch-structure/QueryBuilderGraphFetchTreePanel.d.ts +0 -1
  62. package/lib/components/fetch-structure/QueryBuilderGraphFetchTreePanel.d.ts.map +1 -1
  63. package/lib/components/fetch-structure/QueryBuilderPostFilterPanel.d.ts.map +1 -1
  64. package/lib/components/fetch-structure/QueryBuilderPostFilterPanel.js +1 -1
  65. package/lib/components/fetch-structure/QueryBuilderPostFilterPanel.js.map +1 -1
  66. package/lib/components/fetch-structure/QueryBuilderResultModifierPanel.js +1 -1
  67. package/lib/components/fetch-structure/QueryBuilderResultModifierPanel.js.map +1 -1
  68. package/lib/components/fetch-structure/QueryBuilderTDSComponentHelper.d.ts +0 -1
  69. package/lib/components/fetch-structure/QueryBuilderTDSComponentHelper.d.ts.map +1 -1
  70. package/lib/components/fetch-structure/QueryBuilderTDSPanel.js +1 -1
  71. package/lib/components/fetch-structure/QueryBuilderTDSPanel.js.map +1 -1
  72. package/lib/components/filter/QueryBuilderFilterPanel.d.ts.map +1 -1
  73. package/lib/components/filter/QueryBuilderFilterPanel.js +9 -4
  74. package/lib/components/filter/QueryBuilderFilterPanel.js.map +1 -1
  75. package/lib/components/result/QueryBuilderResultPanel.d.ts.map +1 -1
  76. package/lib/components/result/QueryBuilderResultPanel.js +1 -1
  77. package/lib/components/result/QueryBuilderResultPanel.js.map +1 -1
  78. package/lib/components/result/tds/QueryBuilderTDSGridResult.d.ts.map +1 -1
  79. package/lib/components/result/tds/QueryBuilderTDSGridResult.js +10 -8
  80. package/lib/components/result/tds/QueryBuilderTDSGridResult.js.map +1 -1
  81. package/lib/components/result/tds/QueryBuilderTDSResultShared.d.ts +0 -1
  82. package/lib/components/result/tds/QueryBuilderTDSResultShared.d.ts.map +1 -1
  83. package/lib/components/result/tds/QueryBuilderTDSResultShared.js.map +1 -1
  84. package/lib/components/result/tds/QueryBuilderTDSSimpleGridResult.js +2 -2
  85. package/lib/components/result/tds/QueryBuilderTDSSimpleGridResult.js.map +1 -1
  86. package/lib/components/shared/BasicValueSpecificationEditor.d.ts +19 -4
  87. package/lib/components/shared/BasicValueSpecificationEditor.d.ts.map +1 -1
  88. package/lib/components/shared/BasicValueSpecificationEditor.js +97 -36
  89. package/lib/components/shared/BasicValueSpecificationEditor.js.map +1 -1
  90. package/lib/components/shared/CustomDatePicker.d.ts +2 -1
  91. package/lib/components/shared/CustomDatePicker.d.ts.map +1 -1
  92. package/lib/components/shared/CustomDatePicker.js +8 -5
  93. package/lib/components/shared/CustomDatePicker.js.map +1 -1
  94. package/lib/components/shared/LambdaParameterValuesEditor.js +1 -1
  95. package/lib/components/shared/LambdaParameterValuesEditor.js.map +1 -1
  96. package/lib/components/shared/QueryBuilderPanelIssueCountBadge.d.ts +0 -1
  97. package/lib/components/shared/QueryBuilderPanelIssueCountBadge.d.ts.map +1 -1
  98. package/lib/components/shared/QueryBuilderPropertyInfoTooltip.d.ts +0 -1
  99. package/lib/components/shared/QueryBuilderPropertyInfoTooltip.d.ts.map +1 -1
  100. package/lib/components/shared/QueryBuilderRootClassInfoTooltip.d.ts +0 -1
  101. package/lib/components/shared/QueryBuilderRootClassInfoTooltip.d.ts.map +1 -1
  102. package/lib/components/shared/QueryBuilderVariableSelector.d.ts.map +1 -1
  103. package/lib/components/shared/QueryBuilderVariableSelector.js +1 -1
  104. package/lib/components/shared/QueryBuilderVariableSelector.js.map +1 -1
  105. package/lib/components/workflows/ClassQueryBuilder.d.ts.map +1 -1
  106. package/lib/components/workflows/MappingQueryBuilder.d.ts.map +1 -1
  107. package/lib/components/workflows/ServiceQueryBuilder.d.ts.map +1 -1
  108. package/lib/graph/QueryBuilderMetaModelConst.d.ts +1 -0
  109. package/lib/graph/QueryBuilderMetaModelConst.d.ts.map +1 -1
  110. package/lib/graph/QueryBuilderMetaModelConst.js +1 -0
  111. package/lib/graph/QueryBuilderMetaModelConst.js.map +1 -1
  112. package/lib/graph-manager/protocol/pure/QueryBuilder_PureGraphManagerExtension.d.ts.map +1 -1
  113. package/lib/graph-manager/protocol/pure/QueryBuilder_PureGraphManagerExtension.js.map +1 -1
  114. package/lib/graph-manager/protocol/pure/v1/V1_QueryValueSpecificationBuilderHelper.d.ts +1 -2
  115. package/lib/graph-manager/protocol/pure/v1/V1_QueryValueSpecificationBuilderHelper.d.ts.map +1 -1
  116. package/lib/graph-manager/protocol/pure/v1/V1_QueryValueSpecificationBuilderHelper.js +68 -8
  117. package/lib/graph-manager/protocol/pure/v1/V1_QueryValueSpecificationBuilderHelper.js.map +1 -1
  118. package/lib/index.css +2 -2
  119. package/lib/index.css.map +1 -1
  120. package/lib/package.json +7 -7
  121. package/lib/stores/QueryBuilderState.d.ts +0 -1
  122. package/lib/stores/QueryBuilderState.d.ts.map +1 -1
  123. package/lib/stores/QueryBuilderStateBuilder.d.ts.map +1 -1
  124. package/lib/stores/QueryBuilderStateBuilder.js +5 -1
  125. package/lib/stores/QueryBuilderStateBuilder.js.map +1 -1
  126. package/lib/stores/QueryBuilderValueSpecificationHelper.js.map +1 -1
  127. package/lib/stores/QueryBuilder_LegendApplicationPlugin_Extension.d.ts +0 -1
  128. package/lib/stores/QueryBuilder_LegendApplicationPlugin_Extension.d.ts.map +1 -1
  129. package/lib/stores/__test-utils__/QueryBuilderStateTestUtils.d.ts.map +1 -1
  130. package/lib/stores/execution-plan/ExecutionPlanState.d.ts.map +1 -1
  131. package/lib/stores/explorer/QueryBuilderExplorerState.d.ts +0 -1
  132. package/lib/stores/explorer/QueryBuilderExplorerState.d.ts.map +1 -1
  133. package/lib/stores/explorer/QueryFunctionsExplorerState.d.ts.map +1 -1
  134. package/lib/stores/fetch-structure/graph-fetch/QueryBuilderGraphFetchTreeUtil.d.ts.map +1 -1
  135. package/lib/stores/fetch-structure/graph-fetch/QueryBuilderGraphFetchTreeValueSpecificationBuilder.d.ts.map +1 -1
  136. package/lib/stores/fetch-structure/tds/QueryBuilderTDSState.d.ts +2 -0
  137. package/lib/stores/fetch-structure/tds/QueryBuilderTDSState.d.ts.map +1 -1
  138. package/lib/stores/fetch-structure/tds/QueryBuilderTDSState.js +6 -0
  139. package/lib/stores/fetch-structure/tds/QueryBuilderTDSState.js.map +1 -1
  140. package/lib/stores/fetch-structure/tds/projection/QueryBuilderProjectionStateBuilder.d.ts +11 -0
  141. package/lib/stores/fetch-structure/tds/projection/QueryBuilderProjectionStateBuilder.d.ts.map +1 -1
  142. package/lib/stores/fetch-structure/tds/projection/QueryBuilderProjectionStateBuilder.js +76 -20
  143. package/lib/stores/fetch-structure/tds/projection/QueryBuilderProjectionStateBuilder.js.map +1 -1
  144. package/lib/stores/fetch-structure/tds/projection/QueryBuilderProjectionValueSpecificationBuilder.d.ts.map +1 -1
  145. package/lib/stores/fetch-structure/tds/projection/QueryBuilderProjectionValueSpecificationBuilder.js +70 -34
  146. package/lib/stores/fetch-structure/tds/projection/QueryBuilderProjectionValueSpecificationBuilder.js.map +1 -1
  147. package/lib/stores/filter/QueryBuilderFilterState.d.ts +2 -0
  148. package/lib/stores/filter/QueryBuilderFilterState.d.ts.map +1 -1
  149. package/lib/stores/filter/QueryBuilderFilterState.js +7 -0
  150. package/lib/stores/filter/QueryBuilderFilterState.js.map +1 -1
  151. package/lib/stores/shared/ValueSpecificationEditorHelper.d.ts +5 -2
  152. package/lib/stores/shared/ValueSpecificationEditorHelper.d.ts.map +1 -1
  153. package/lib/stores/shared/ValueSpecificationEditorHelper.js +20 -9
  154. package/lib/stores/shared/ValueSpecificationEditorHelper.js.map +1 -1
  155. package/lib/stores/shared/ValueSpecificationModifierHelper.d.ts.map +1 -1
  156. package/lib/stores/workflows/ClassQueryBuilderState.d.ts.map +1 -1
  157. package/lib/stores/workflows/MappingQueryBuilderState.d.ts.map +1 -1
  158. package/lib/stores/workflows/ServiceQueryBuilderState.d.ts.map +1 -1
  159. package/package.json +15 -15
  160. package/src/components/QueryBuilderConstantExpressionPanel.tsx +1 -1
  161. package/src/components/QueryBuilderParametersPanel.tsx +1 -1
  162. package/src/components/QueryBuilderPropertyExpressionEditor.tsx +1 -1
  163. package/src/components/QueryBuilderSideBar.tsx +1 -1
  164. package/src/components/__test-utils__/QueryBuilderComponentTestUtils.tsx +4 -1
  165. package/src/components/execution-plan/FunctionParametersValidationNodeViewer.tsx +1 -1
  166. package/src/components/execution-plan/PartialClassResultViewer.tsx +1 -1
  167. package/src/components/execution-plan/RelationalClassQueryTempTableGraphFetchExecutionNodeViewer.tsx +1 -1
  168. package/src/components/execution-plan/RelationalCrossRootQueryTempTableGraphFetchExecutionNodeViewer.tsx +1 -1
  169. package/src/components/execution-plan/RelationalRootQueryTempTableGraphFetchExecutionNodeViewer.tsx +1 -1
  170. package/src/components/execution-plan/SQLExecutionNodeViewer.tsx +1 -1
  171. package/src/components/execution-plan/StoreMappingGlobalGraphFetchExecutionNodeViewer.tsx +2 -2
  172. package/src/components/execution-plan/TDSResultTypeViewer.tsx +1 -1
  173. package/src/components/explorer/QueryBuilderMilestoningParameterEditor.tsx +1 -1
  174. package/src/components/fetch-structure/QueryBuilderPostFilterPanel.tsx +1 -1
  175. package/src/components/fetch-structure/QueryBuilderResultModifierPanel.tsx +1 -1
  176. package/src/components/fetch-structure/QueryBuilderTDSPanel.tsx +1 -1
  177. package/src/components/filter/QueryBuilderFilterPanel.tsx +18 -4
  178. package/src/components/result/QueryBuilderResultPanel.tsx +1 -0
  179. package/src/components/result/tds/QueryBuilderTDSGridResult.tsx +12 -13
  180. package/src/components/result/tds/QueryBuilderTDSResultShared.tsx +1 -1
  181. package/src/components/result/tds/QueryBuilderTDSSimpleGridResult.tsx +2 -2
  182. package/src/components/shared/BasicValueSpecificationEditor.tsx +257 -55
  183. package/src/components/shared/CustomDatePicker.tsx +36 -11
  184. package/src/components/shared/LambdaParameterValuesEditor.tsx +1 -1
  185. package/src/components/shared/QueryBuilderVariableSelector.tsx +4 -1
  186. package/src/graph/QueryBuilderMetaModelConst.ts +1 -0
  187. package/src/graph-manager/protocol/pure/QueryBuilder_PureGraphManagerExtension.ts +1 -1
  188. package/src/graph-manager/protocol/pure/v1/V1_QueryValueSpecificationBuilderHelper.ts +189 -18
  189. package/src/stores/QueryBuilderStateBuilder.ts +6 -1
  190. package/src/stores/QueryBuilderValueSpecificationHelper.ts +2 -2
  191. package/src/stores/fetch-structure/tds/QueryBuilderTDSState.ts +7 -0
  192. package/src/stores/fetch-structure/tds/projection/QueryBuilderProjectionStateBuilder.ts +167 -43
  193. package/src/stores/fetch-structure/tds/projection/QueryBuilderProjectionValueSpecificationBuilder.ts +145 -69
  194. package/src/stores/filter/QueryBuilderFilterState.ts +8 -0
  195. package/src/stores/shared/ValueSpecificationEditorHelper.ts +47 -7
  196. package/tsconfig.package.json +1 -1
@@ -1244,7 +1244,9 @@ export const CustomDatePicker: React.FC<{
1244
1244
  */
1245
1245
  match?: boolean;
1246
1246
  };
1247
+ displayAsEditableValue?: boolean | undefined;
1247
1248
  setValueSpecification: (val: ValueSpecification) => void;
1249
+ handleBlur?: (() => void) | undefined;
1248
1250
  }> = (props) => {
1249
1251
  const {
1250
1252
  valueSpecification,
@@ -1253,6 +1255,8 @@ export const CustomDatePicker: React.FC<{
1253
1255
  observerContext,
1254
1256
  hasError,
1255
1257
  typeCheckOption,
1258
+ displayAsEditableValue,
1259
+ handleBlur,
1256
1260
  } = props;
1257
1261
  const applicationStore = useApplicationStore();
1258
1262
  // For some cases where types need to be matched strictly.
@@ -1283,6 +1287,7 @@ export const CustomDatePicker: React.FC<{
1283
1287
  buildDatePickerOption(valueSpecification, applicationStore),
1284
1288
  );
1285
1289
  setAnchorEl(null);
1290
+ handleBlur?.();
1286
1291
  };
1287
1292
  const handleDatePickerOptionChange = (
1288
1293
  event: React.ChangeEvent<HTMLInputElement>,
@@ -1408,15 +1413,35 @@ export const CustomDatePicker: React.FC<{
1408
1413
 
1409
1414
  return (
1410
1415
  <>
1411
- <button
1412
- className={clsx('value-spec-editor__date-picker__trigger', {
1413
- 'value-spec-editor__date-picker__trigger--error': hasError,
1414
- })}
1415
- title="Click to edit and pick from more date options"
1416
- onClick={openCustomDatePickerPopover}
1417
- >
1418
- {datePickerOption.label || 'Select value'}
1419
- </button>
1416
+ {displayAsEditableValue ? (
1417
+ <span
1418
+ className={clsx(
1419
+ 'value-spec-editor__date-picker__editable__display--content editable-value',
1420
+ {
1421
+ 'value-spec-editor__date-picker__editable__display--content--error':
1422
+ hasError,
1423
+ },
1424
+ )}
1425
+ title="Click to edit and pick from more date options"
1426
+ onClick={openCustomDatePickerPopover}
1427
+ >
1428
+ {datePickerOption.label ? (
1429
+ `"${datePickerOption.label}"`
1430
+ ) : (
1431
+ <>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</>
1432
+ )}
1433
+ </span>
1434
+ ) : (
1435
+ <button
1436
+ className={clsx('value-spec-editor__date-picker__trigger', {
1437
+ 'value-spec-editor__date-picker__trigger--error': hasError,
1438
+ })}
1439
+ title="Click to edit and pick from more date options"
1440
+ onClick={openCustomDatePickerPopover}
1441
+ >
1442
+ {datePickerOption.label || 'Select value'}
1443
+ </button>
1444
+ )}
1420
1445
  <BasePopover
1421
1446
  open={Boolean(anchorEl)}
1422
1447
  TransitionProps={{
@@ -1425,8 +1450,8 @@ export const CustomDatePicker: React.FC<{
1425
1450
  anchorEl={anchorEl}
1426
1451
  onClose={closeCustomDatePickerPopover}
1427
1452
  anchorOrigin={{
1428
- vertical: 'bottom',
1429
- horizontal: 'center',
1453
+ vertical: displayAsEditableValue ? 20 : 'bottom',
1454
+ horizontal: displayAsEditableValue ? 50 : 'center',
1430
1455
  }}
1431
1456
  transformOrigin={{
1432
1457
  vertical: 'top',
@@ -103,7 +103,7 @@ export const LambdaParameterValuesEditor = observer(
103
103
  paramState.setValue(val);
104
104
  }}
105
105
  graph={graph}
106
- obseverContext={observerContext}
106
+ observerContext={observerContext}
107
107
  typeCheckOption={{
108
108
  expectedType: variableType,
109
109
  match: variableType === PrimitiveType.DATETIME,
@@ -61,7 +61,10 @@ export const getNameOfValueSpecification = (
61
61
  return possibleDateLabel;
62
62
  }
63
63
  }
64
- return getValueSpecificationStringValue(value);
64
+ return getValueSpecificationStringValue(
65
+ value,
66
+ queryBuilderState.applicationStore,
67
+ );
65
68
  };
66
69
 
67
70
  const QueryBuilderVariableContextMenu = observer(
@@ -116,6 +116,7 @@ export enum QUERY_BUILDER_SUPPORTED_FUNCTIONS {
116
116
  TDS_TAKE = 'meta::pure::tds::take',
117
117
  TDS_RESTRICT = 'meta::pure::tds::restrict',
118
118
  TDS_FUNC = 'meta::pure::tds::func',
119
+ TDS_COL = 'meta::pure::tds::col',
119
120
 
120
121
  // Relation
121
122
  RELATION_PROJECT = 'meta::pure::functions::relation::project',
@@ -44,4 +44,4 @@ export const getQueryBuilderGraphManagerExtension = (
44
44
  extension instanceof QueryBuilder_PureGraphManagerExtension,
45
45
  ),
46
46
  `Can't find query builder Pure graph manager extension`,
47
- ) as QueryBuilder_PureGraphManagerExtension;
47
+ );
@@ -27,10 +27,10 @@ import {
27
27
  import {
28
28
  type V1_GraphBuilderContext,
29
29
  type V1_ProcessingContext,
30
- V1_ValueSpecification,
31
30
  type ValueSpecification,
32
- type SimpleFunctionExpression,
33
31
  type Type,
32
+ type SimpleFunctionExpression,
33
+ V1_ValueSpecification,
34
34
  V1_buildBaseSimpleFunctionExpression,
35
35
  V1_buildGenericFunctionExpression,
36
36
  extractElementNameFromPath,
@@ -580,7 +580,7 @@ export const V1_buildFilterFunctionExpression = (
580
580
  return expression;
581
581
  };
582
582
 
583
- export const V1_buildTypedProjectFunctionExpression = (
583
+ const V1_buildTypedProjectFunctionExpression = (
584
584
  functionName: string,
585
585
  parameters: V1_ValueSpecification[],
586
586
  openVariables: string[],
@@ -684,23 +684,184 @@ export const V1_buildTypedProjectFunctionExpression = (
684
684
  return expression;
685
685
  };
686
686
 
687
- export const V1_buildProjectFunctionExpression = (
687
+ const V1_buildColFunctionExpression = (
688
+ valueSpecification: V1_ValueSpecification,
689
+ precedingExperession: ValueSpecification,
690
+ openVariables: string[],
691
+ compileContext: V1_GraphBuilderContext,
692
+ processingContext: V1_ProcessingContext,
693
+ ): SimpleFunctionExpression => {
694
+ const appliedFunc = guaranteeType(
695
+ valueSpecification,
696
+ V1_AppliedFunction,
697
+ `Can't build tds col func: only support applied function`,
698
+ );
699
+ assertTrue(
700
+ matchFunctionName(
701
+ appliedFunc.function,
702
+ QUERY_BUILDER_SUPPORTED_FUNCTIONS.TDS_COL,
703
+ ),
704
+ `Can't build tds col func: unsupported func name ${appliedFunc.function}`,
705
+ );
706
+ assertTrue(
707
+ appliedFunc.parameters.length === 2,
708
+ `Can't build tds col func: only support col function with 2 parameters`,
709
+ );
710
+ const colLambda = guaranteeType(
711
+ appliedFunc.parameters[0],
712
+ V1_Lambda,
713
+ `Can't build tds col func: only support first parameter of col function as Lambda`,
714
+ );
715
+ let lambda: ValueSpecification;
716
+ try {
717
+ colLambda.parameters.forEach((variable): void => {
718
+ if (variable.name && !variable.class) {
719
+ const variableExpression = new VariableExpression(
720
+ variable.name,
721
+ Multiplicity.ONE,
722
+ );
723
+ variableExpression.genericType = precedingExperession.genericType;
724
+ processingContext.addInferredVariables(
725
+ variable.name,
726
+ variableExpression,
727
+ );
728
+ }
729
+ });
730
+ lambda = buildProjectionColumnLambda(
731
+ colLambda,
732
+ openVariables,
733
+ compileContext,
734
+ processingContext,
735
+ );
736
+ } catch {
737
+ lambda = new INTERNAL__UnknownValueSpecification(
738
+ V1_serializeValueSpecification(
739
+ colLambda,
740
+ compileContext.extensions.plugins,
741
+ ),
742
+ );
743
+ }
744
+ guaranteeType(
745
+ appliedFunc.parameters[1],
746
+ V1_CString,
747
+ `Can't build tds col func: only support second parameter of col function as String`,
748
+ );
749
+ const colNameValueSpec = guaranteeNonNullable(
750
+ appliedFunc.parameters[1],
751
+ ).accept_ValueSpecificationVisitor(
752
+ new V1_ValueSpecificationBuilder(
753
+ compileContext,
754
+ processingContext,
755
+ openVariables,
756
+ ),
757
+ );
758
+ const colFunctionExpression = V1_buildBaseSimpleFunctionExpression(
759
+ [lambda, colNameValueSpec],
760
+ appliedFunc.function,
761
+ compileContext,
762
+ );
763
+ return colFunctionExpression;
764
+ };
765
+
766
+ const V1_buildTDSProjectWithColFunctionExpression = (
688
767
  functionName: string,
689
768
  parameters: V1_ValueSpecification[],
690
769
  openVariables: string[],
691
770
  compileContext: V1_GraphBuilderContext,
692
771
  processingContext: V1_ProcessingContext,
693
772
  ): SimpleFunctionExpression => {
694
- if (parameters.length === 2) {
695
- return V1_buildTypedProjectFunctionExpression(
696
- functionName,
697
- parameters,
773
+ assertTrue(
774
+ parameters.length === 2,
775
+ `Can't build tds project() expression: project() expects 2 arguments`,
776
+ );
777
+ const precedingExperession = (
778
+ parameters[0] as V1_ValueSpecification
779
+ ).accept_ValueSpecificationVisitor(
780
+ new V1_ValueSpecificationBuilder(
781
+ compileContext,
782
+ processingContext,
783
+ openVariables,
784
+ ),
785
+ );
786
+ assertNonNullable(
787
+ precedingExperession.genericType,
788
+ `Can't build tds project() expression: preceding expression return type is missing`,
789
+ );
790
+ const colFuncExpress = guaranteeNonNullable(
791
+ parameters[1],
792
+ `Can't build tds project() expression: second parameter is missing`,
793
+ );
794
+ let secondProcessedParameter: ValueSpecification;
795
+ if (colFuncExpress instanceof V1_Collection) {
796
+ const processedColExpressions = new CollectionInstanceValue(
797
+ compileContext.graph.getMultiplicity(
798
+ colFuncExpress.multiplicity.lowerBound,
799
+ colFuncExpress.multiplicity.upperBound,
800
+ ),
801
+ );
802
+ processedColExpressions.values = colFuncExpress.values.map((value) =>
803
+ V1_buildColFunctionExpression(
804
+ value,
805
+ precedingExperession,
806
+ openVariables,
807
+ compileContext,
808
+ processingContext,
809
+ ),
810
+ );
811
+ secondProcessedParameter = processedColExpressions;
812
+ } else {
813
+ assertType(
814
+ colFuncExpress,
815
+ V1_AppliedFunction,
816
+ `Can't build project() expression: project() expects argument #2 to be a function`,
817
+ );
818
+ secondProcessedParameter = V1_buildColFunctionExpression(
819
+ colFuncExpress,
820
+ precedingExperession,
698
821
  openVariables,
699
822
  compileContext,
700
823
  processingContext,
701
824
  );
702
825
  }
826
+ const expression = V1_buildBaseSimpleFunctionExpression(
827
+ [precedingExperession, secondProcessedParameter],
828
+ functionName,
829
+ compileContext,
830
+ );
831
+ expression.genericType = GenericTypeExplicitReference.create(
832
+ new GenericType(
833
+ compileContext.resolveType(QUERY_BUILDER_PURE_PATH.TDS_ROW).value,
834
+ ),
835
+ );
836
+ return expression;
837
+ };
703
838
 
839
+ export const V1_buildProjectFunctionExpression = (
840
+ functionName: string,
841
+ parameters: V1_ValueSpecification[],
842
+ openVariables: string[],
843
+ compileContext: V1_GraphBuilderContext,
844
+ processingContext: V1_ProcessingContext,
845
+ ): SimpleFunctionExpression => {
846
+ if (parameters.length === 2) {
847
+ try {
848
+ return V1_buildTDSProjectWithColFunctionExpression(
849
+ functionName,
850
+ parameters,
851
+ openVariables,
852
+ compileContext,
853
+ processingContext,
854
+ );
855
+ } catch {
856
+ return V1_buildTypedProjectFunctionExpression(
857
+ functionName,
858
+ parameters,
859
+ openVariables,
860
+ compileContext,
861
+ processingContext,
862
+ );
863
+ }
864
+ }
704
865
  const length = parameters.length;
705
866
  assertTrue(
706
867
  length === 3 || length === 2,
@@ -723,15 +884,19 @@ export const V1_buildProjectFunctionExpression = (
723
884
  );
724
885
 
725
886
  const columnExpressions = parameters[1];
726
- assertType(
727
- columnExpressions,
728
- V1_Collection,
729
- `Can't build project() expression: project() expects argument #1 to be a collection`,
730
- );
731
- topLevelLambdaParameters = columnExpressions.values
732
- .filter(filterByType(V1_Lambda))
733
- .map((lambda) => lambda.parameters)
734
- .flat();
887
+ if (columnExpressions instanceof V1_Lambda) {
888
+ topLevelLambdaParameters = columnExpressions.parameters;
889
+ } else {
890
+ assertType(
891
+ columnExpressions,
892
+ V1_Collection,
893
+ `Can't build project() expression: project() expects argument #1 to be a collection`,
894
+ );
895
+ topLevelLambdaParameters = columnExpressions.values
896
+ .filter(filterByType(V1_Lambda))
897
+ .map((lambda) => lambda.parameters)
898
+ .flat();
899
+ }
735
900
 
736
901
  const variables = new Set<string>();
737
902
  // Make sure top-level lambdas have their lambda parameter types set properly
@@ -753,7 +918,13 @@ export const V1_buildProjectFunctionExpression = (
753
918
  columnExpressions.multiplicity.upperBound,
754
919
  ),
755
920
  );
756
- processedColumnExpressions.values = columnExpressions.values.map((value) => {
921
+ let colExpressionValues: V1_ValueSpecification[] = [];
922
+ if (columnExpressions instanceof V1_Lambda) {
923
+ colExpressionValues = [columnExpressions];
924
+ } else {
925
+ colExpressionValues = columnExpressions.values;
926
+ }
927
+ processedColumnExpressions.values = colExpressionValues.map((value) => {
757
928
  try {
758
929
  return buildProjectionColumnLambda(
759
930
  value,
@@ -68,6 +68,7 @@ import {
68
68
  processInternalizeExpression,
69
69
  } from './fetch-structure/graph-fetch/QueryBuilderGraphFetchTreeStateBuilder.js';
70
70
  import {
71
+ processTDSColExpression,
71
72
  processTDSDistinctExpression,
72
73
  processTDSProjectExpression,
73
74
  processTDSProjectionColumnPropertyExpression,
@@ -661,7 +662,11 @@ export class QueryBuilderValueSpecificationProcessor
661
662
  this.parentLambda,
662
663
  );
663
664
  }
664
-
665
+ return;
666
+ } else if (
667
+ matchFunctionName(functionName, QUERY_BUILDER_SUPPORTED_FUNCTIONS.TDS_COL)
668
+ ) {
669
+ processTDSColExpression(valueSpecification, this.queryBuilderState);
665
670
  return;
666
671
  } else if (
667
672
  matchFunctionName(
@@ -86,7 +86,7 @@ export const getCollectionValueSpecificationType = (
86
86
  ): Type | undefined => {
87
87
  if (values.every((val) => val instanceof PrimitiveInstanceValue)) {
88
88
  const valuePrimitiveTypes: (PrimitiveType | undefined)[] = [];
89
- (values as PrimitiveInstanceValue[]).forEach((val) => {
89
+ values.forEach((val) => {
90
90
  const primitiveType = val.genericType.value.rawType;
91
91
  switch (primitiveType.path) {
92
92
  case PRIMITIVE_TYPE.STRING:
@@ -118,7 +118,7 @@ export const getCollectionValueSpecificationType = (
118
118
  return valuePrimitiveTypes[0] as PrimitiveType;
119
119
  } else if (values.every((val) => val instanceof EnumValueInstanceValue)) {
120
120
  const valueEnumerationTypes: Enumeration[] = [];
121
- (values as EnumValueInstanceValue[]).forEach((val) => {
121
+ values.forEach((val) => {
122
122
  addUniqueEntry(
123
123
  valueEnumerationTypes,
124
124
  guaranteeNonNullable(val.values[0]).value._OWNER,
@@ -122,6 +122,7 @@ export class QueryBuilderTDSState
122
122
  isConvertDerivationProjectionObjects = false;
123
123
  showPostFilterPanel: boolean;
124
124
  showWindowFuncPanel = false;
125
+ useColFunc = false;
125
126
 
126
127
  postFilterOperators: QueryBuilderPostFilterOperator[] =
127
128
  getQueryBuilderCorePostFilterOperators();
@@ -144,6 +145,7 @@ export class QueryBuilderTDSState
144
145
  isConvertDerivationProjectionObjects: observable,
145
146
  showPostFilterPanel: observable,
146
147
  showWindowFuncPanel: observable,
148
+ useColFunc: observable,
147
149
  TEMPORARY__showPostFetchStructurePanel: computed,
148
150
  derivations: computed,
149
151
  hasParserError: computed,
@@ -157,6 +159,7 @@ export class QueryBuilderTDSState
157
159
  initializeWithQuery: action,
158
160
  setShowPostFilterPanel: action,
159
161
  setShowWindowFuncPanel: action,
162
+ setUseColFunc: action,
160
163
  checkBeforeChangingImplementation: action,
161
164
  convertDerivationProjectionObjects: flow,
162
165
  fetchDerivedReturnTypes: flow,
@@ -459,6 +462,10 @@ export class QueryBuilderTDSState
459
462
  this.showWindowFuncPanel = val;
460
463
  }
461
464
 
465
+ setUseColFunc(val: boolean): void {
466
+ this.useColFunc = val;
467
+ }
468
+
462
469
  *convertDerivationProjectionObjects(): GeneratorFn<void> {
463
470
  const lambdas = new Map<string, RawLambda>();
464
471
  const derivationProjectionColumnStateMap = new Map<