@finos/legend-query-builder 4.9.3 → 4.10.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (125) hide show
  1. package/lib/__lib__/QueryBuilderTesting.d.ts +3 -1
  2. package/lib/__lib__/QueryBuilderTesting.d.ts.map +1 -1
  3. package/lib/__lib__/QueryBuilderTesting.js +4 -1
  4. package/lib/__lib__/QueryBuilderTesting.js.map +1 -1
  5. package/lib/components/QueryBuilderResultPanel.d.ts.map +1 -1
  6. package/lib/components/QueryBuilderResultPanel.js +36 -33
  7. package/lib/components/QueryBuilderResultPanel.js.map +1 -1
  8. package/lib/components/__test-utils__/QueryBuilderComponentTestUtils.d.ts +1 -0
  9. package/lib/components/__test-utils__/QueryBuilderComponentTestUtils.d.ts.map +1 -1
  10. package/lib/components/__test-utils__/QueryBuilderComponentTestUtils.js +13 -1
  11. package/lib/components/__test-utils__/QueryBuilderComponentTestUtils.js.map +1 -1
  12. package/lib/components/fetch-structure/QueryBuilderPostFilterPanel.d.ts +2 -2
  13. package/lib/components/fetch-structure/QueryBuilderPostFilterPanel.d.ts.map +1 -1
  14. package/lib/components/fetch-structure/QueryBuilderPostFilterPanel.js +42 -24
  15. package/lib/components/fetch-structure/QueryBuilderPostFilterPanel.js.map +1 -1
  16. package/lib/components/fetch-structure/QueryBuilderTDSPanel.d.ts.map +1 -1
  17. package/lib/components/fetch-structure/QueryBuilderTDSPanel.js +5 -6
  18. package/lib/components/fetch-structure/QueryBuilderTDSPanel.js.map +1 -1
  19. package/lib/graph-manager/protocol/pure/v1/V1_QueryValueSpecificationBuilderHelper.d.ts +1 -1
  20. package/lib/graph-manager/protocol/pure/v1/V1_QueryValueSpecificationBuilderHelper.d.ts.map +1 -1
  21. package/lib/graph-manager/protocol/pure/v1/V1_QueryValueSpecificationBuilderHelper.js +2 -2
  22. package/lib/graph-manager/protocol/pure/v1/V1_QueryValueSpecificationBuilderHelper.js.map +1 -1
  23. package/lib/index.css +1 -1
  24. package/lib/package.json +1 -1
  25. package/lib/stores/QueryBuilderConstantsState.d.ts +5 -1
  26. package/lib/stores/QueryBuilderConstantsState.d.ts.map +1 -1
  27. package/lib/stores/QueryBuilderConstantsState.js +14 -1
  28. package/lib/stores/QueryBuilderConstantsState.js.map +1 -1
  29. package/lib/stores/QueryBuilderStateHashUtils.d.ts +2 -0
  30. package/lib/stores/QueryBuilderStateHashUtils.d.ts.map +1 -1
  31. package/lib/stores/QueryBuilderStateHashUtils.js +2 -0
  32. package/lib/stores/QueryBuilderStateHashUtils.js.map +1 -1
  33. package/lib/stores/QueryBuilderValueSpecificationBuilder.d.ts.map +1 -1
  34. package/lib/stores/QueryBuilderValueSpecificationBuilder.js +3 -23
  35. package/lib/stores/QueryBuilderValueSpecificationBuilder.js.map +1 -1
  36. package/lib/stores/explorer/QueryBuilderExplorerState.d.ts.map +1 -1
  37. package/lib/stores/explorer/QueryBuilderExplorerState.js +26 -8
  38. package/lib/stores/explorer/QueryBuilderExplorerState.js.map +1 -1
  39. package/lib/stores/fetch-structure/graph-fetch/QueryBuilderGraphFetchTreeUtil.d.ts.map +1 -1
  40. package/lib/stores/fetch-structure/graph-fetch/QueryBuilderGraphFetchTreeUtil.js +6 -0
  41. package/lib/stores/fetch-structure/graph-fetch/QueryBuilderGraphFetchTreeUtil.js.map +1 -1
  42. package/lib/stores/fetch-structure/tds/aggregation/QueryBuilderAggregateCalendarFunction.d.ts +3 -3
  43. package/lib/stores/fetch-structure/tds/aggregation/QueryBuilderAggregateCalendarFunction.d.ts.map +1 -1
  44. package/lib/stores/fetch-structure/tds/aggregation/QueryBuilderAggregateCalendarFunction.js.map +1 -1
  45. package/lib/stores/fetch-structure/tds/aggregation/calendarFunctions/QueryBuilderAggregateCalendarFunctionValueSpecificationBuilder.d.ts +2 -2
  46. package/lib/stores/fetch-structure/tds/aggregation/calendarFunctions/QueryBuilderAggregateCalendarFunctionValueSpecificationBuilder.d.ts.map +1 -1
  47. package/lib/stores/fetch-structure/tds/aggregation/calendarFunctions/QueryBuilderAggregateCalendarFunctionValueSpecificationBuilder.js +5 -4
  48. package/lib/stores/fetch-structure/tds/aggregation/calendarFunctions/QueryBuilderAggregateCalendarFunctionValueSpecificationBuilder.js.map +1 -1
  49. package/lib/stores/fetch-structure/tds/post-filter/QueryBuilderPostFilterOperator.js +1 -1
  50. package/lib/stores/fetch-structure/tds/post-filter/QueryBuilderPostFilterOperator.js.map +1 -1
  51. package/lib/stores/fetch-structure/tds/post-filter/QueryBuilderPostFilterState.d.ts +31 -5
  52. package/lib/stores/fetch-structure/tds/post-filter/QueryBuilderPostFilterState.d.ts.map +1 -1
  53. package/lib/stores/fetch-structure/tds/post-filter/QueryBuilderPostFilterState.js +125 -30
  54. package/lib/stores/fetch-structure/tds/post-filter/QueryBuilderPostFilterState.js.map +1 -1
  55. package/lib/stores/fetch-structure/tds/post-filter/QueryBuilderPostFilterStateBuilder.d.ts.map +1 -1
  56. package/lib/stores/fetch-structure/tds/post-filter/QueryBuilderPostFilterStateBuilder.js +21 -8
  57. package/lib/stores/fetch-structure/tds/post-filter/QueryBuilderPostFilterStateBuilder.js.map +1 -1
  58. package/lib/stores/fetch-structure/tds/post-filter/operators/QueryBuilderPostFilterOperatorValueSpecificationBuilder.d.ts +3 -1
  59. package/lib/stores/fetch-structure/tds/post-filter/operators/QueryBuilderPostFilterOperatorValueSpecificationBuilder.d.ts.map +1 -1
  60. package/lib/stores/fetch-structure/tds/post-filter/operators/QueryBuilderPostFilterOperatorValueSpecificationBuilder.js +20 -17
  61. package/lib/stores/fetch-structure/tds/post-filter/operators/QueryBuilderPostFilterOperatorValueSpecificationBuilder.js.map +1 -1
  62. package/lib/stores/fetch-structure/tds/post-filter/operators/QueryBuilderPostFilterOperator_Contain.d.ts.map +1 -1
  63. package/lib/stores/fetch-structure/tds/post-filter/operators/QueryBuilderPostFilterOperator_Contain.js +4 -6
  64. package/lib/stores/fetch-structure/tds/post-filter/operators/QueryBuilderPostFilterOperator_Contain.js.map +1 -1
  65. package/lib/stores/fetch-structure/tds/post-filter/operators/QueryBuilderPostFilterOperator_EndWith.d.ts.map +1 -1
  66. package/lib/stores/fetch-structure/tds/post-filter/operators/QueryBuilderPostFilterOperator_EndWith.js +4 -6
  67. package/lib/stores/fetch-structure/tds/post-filter/operators/QueryBuilderPostFilterOperator_EndWith.js.map +1 -1
  68. package/lib/stores/fetch-structure/tds/post-filter/operators/QueryBuilderPostFilterOperator_Equal.d.ts +1 -1
  69. package/lib/stores/fetch-structure/tds/post-filter/operators/QueryBuilderPostFilterOperator_Equal.d.ts.map +1 -1
  70. package/lib/stores/fetch-structure/tds/post-filter/operators/QueryBuilderPostFilterOperator_Equal.js +10 -10
  71. package/lib/stores/fetch-structure/tds/post-filter/operators/QueryBuilderPostFilterOperator_Equal.js.map +1 -1
  72. package/lib/stores/fetch-structure/tds/post-filter/operators/QueryBuilderPostFilterOperator_GreaterThan.d.ts.map +1 -1
  73. package/lib/stores/fetch-structure/tds/post-filter/operators/QueryBuilderPostFilterOperator_GreaterThan.js +10 -10
  74. package/lib/stores/fetch-structure/tds/post-filter/operators/QueryBuilderPostFilterOperator_GreaterThan.js.map +1 -1
  75. package/lib/stores/fetch-structure/tds/post-filter/operators/QueryBuilderPostFilterOperator_GreaterThanEqual.d.ts.map +1 -1
  76. package/lib/stores/fetch-structure/tds/post-filter/operators/QueryBuilderPostFilterOperator_GreaterThanEqual.js +5 -5
  77. package/lib/stores/fetch-structure/tds/post-filter/operators/QueryBuilderPostFilterOperator_GreaterThanEqual.js.map +1 -1
  78. package/lib/stores/fetch-structure/tds/post-filter/operators/QueryBuilderPostFilterOperator_In.d.ts +1 -1
  79. package/lib/stores/fetch-structure/tds/post-filter/operators/QueryBuilderPostFilterOperator_In.d.ts.map +1 -1
  80. package/lib/stores/fetch-structure/tds/post-filter/operators/QueryBuilderPostFilterOperator_In.js +32 -27
  81. package/lib/stores/fetch-structure/tds/post-filter/operators/QueryBuilderPostFilterOperator_In.js.map +1 -1
  82. package/lib/stores/fetch-structure/tds/post-filter/operators/QueryBuilderPostFilterOperator_IsEmpty.d.ts.map +1 -1
  83. package/lib/stores/fetch-structure/tds/post-filter/operators/QueryBuilderPostFilterOperator_IsEmpty.js +10 -5
  84. package/lib/stores/fetch-structure/tds/post-filter/operators/QueryBuilderPostFilterOperator_IsEmpty.js.map +1 -1
  85. package/lib/stores/fetch-structure/tds/post-filter/operators/QueryBuilderPostFilterOperator_LessThan.d.ts.map +1 -1
  86. package/lib/stores/fetch-structure/tds/post-filter/operators/QueryBuilderPostFilterOperator_LessThan.js +10 -10
  87. package/lib/stores/fetch-structure/tds/post-filter/operators/QueryBuilderPostFilterOperator_LessThan.js.map +1 -1
  88. package/lib/stores/fetch-structure/tds/post-filter/operators/QueryBuilderPostFilterOperator_LessThanEqual.d.ts.map +1 -1
  89. package/lib/stores/fetch-structure/tds/post-filter/operators/QueryBuilderPostFilterOperator_LessThanEqual.js +5 -5
  90. package/lib/stores/fetch-structure/tds/post-filter/operators/QueryBuilderPostFilterOperator_LessThanEqual.js.map +1 -1
  91. package/lib/stores/fetch-structure/tds/post-filter/operators/QueryBuilderPostFilterOperator_StartWith.d.ts.map +1 -1
  92. package/lib/stores/fetch-structure/tds/post-filter/operators/QueryBuilderPostFilterOperator_StartWith.js +4 -6
  93. package/lib/stores/fetch-structure/tds/post-filter/operators/QueryBuilderPostFilterOperator_StartWith.js.map +1 -1
  94. package/lib/stores/fetch-structure/tds/projection/QueryBuilderProjectionColumnState.d.ts.map +1 -1
  95. package/lib/stores/fetch-structure/tds/projection/QueryBuilderProjectionColumnState.js +17 -3
  96. package/lib/stores/fetch-structure/tds/projection/QueryBuilderProjectionColumnState.js.map +1 -1
  97. package/package.json +5 -5
  98. package/src/__lib__/QueryBuilderTesting.ts +4 -1
  99. package/src/components/QueryBuilderResultPanel.tsx +64 -59
  100. package/src/components/__test-utils__/QueryBuilderComponentTestUtils.tsx +25 -1
  101. package/src/components/fetch-structure/QueryBuilderPostFilterPanel.tsx +102 -49
  102. package/src/components/fetch-structure/QueryBuilderTDSPanel.tsx +24 -17
  103. package/src/graph-manager/protocol/pure/v1/V1_QueryValueSpecificationBuilderHelper.ts +3 -4
  104. package/src/stores/QueryBuilderConstantsState.ts +30 -0
  105. package/src/stores/QueryBuilderStateHashUtils.ts +2 -0
  106. package/src/stores/QueryBuilderValueSpecificationBuilder.ts +4 -50
  107. package/src/stores/explorer/QueryBuilderExplorerState.ts +43 -13
  108. package/src/stores/fetch-structure/graph-fetch/QueryBuilderGraphFetchTreeUtil.ts +10 -0
  109. package/src/stores/fetch-structure/tds/aggregation/QueryBuilderAggregateCalendarFunction.ts +2 -3
  110. package/src/stores/fetch-structure/tds/aggregation/calendarFunctions/QueryBuilderAggregateCalendarFunctionValueSpecificationBuilder.ts +7 -6
  111. package/src/stores/fetch-structure/tds/post-filter/QueryBuilderPostFilterOperator.ts +1 -1
  112. package/src/stores/fetch-structure/tds/post-filter/QueryBuilderPostFilterState.ts +180 -34
  113. package/src/stores/fetch-structure/tds/post-filter/QueryBuilderPostFilterStateBuilder.ts +38 -9
  114. package/src/stores/fetch-structure/tds/post-filter/operators/QueryBuilderPostFilterOperatorValueSpecificationBuilder.ts +36 -20
  115. package/src/stores/fetch-structure/tds/post-filter/operators/QueryBuilderPostFilterOperator_Contain.ts +5 -6
  116. package/src/stores/fetch-structure/tds/post-filter/operators/QueryBuilderPostFilterOperator_EndWith.ts +6 -6
  117. package/src/stores/fetch-structure/tds/post-filter/operators/QueryBuilderPostFilterOperator_Equal.ts +12 -13
  118. package/src/stores/fetch-structure/tds/post-filter/operators/QueryBuilderPostFilterOperator_GreaterThan.ts +10 -9
  119. package/src/stores/fetch-structure/tds/post-filter/operators/QueryBuilderPostFilterOperator_GreaterThanEqual.ts +5 -4
  120. package/src/stores/fetch-structure/tds/post-filter/operators/QueryBuilderPostFilterOperator_In.ts +48 -43
  121. package/src/stores/fetch-structure/tds/post-filter/operators/QueryBuilderPostFilterOperator_IsEmpty.ts +12 -4
  122. package/src/stores/fetch-structure/tds/post-filter/operators/QueryBuilderPostFilterOperator_LessThan.ts +10 -9
  123. package/src/stores/fetch-structure/tds/post-filter/operators/QueryBuilderPostFilterOperator_LessThanEqual.ts +5 -4
  124. package/src/stores/fetch-structure/tds/post-filter/operators/QueryBuilderPostFilterOperator_StartWith.ts +6 -6
  125. package/src/stores/fetch-structure/tds/projection/QueryBuilderProjectionColumnState.ts +26 -4
@@ -20,6 +20,7 @@ import {
20
20
  type FunctionExpression,
21
21
  AbstractPropertyExpression,
22
22
  PRIMITIVE_TYPE,
23
+ PrimitiveType,
23
24
  } from '@finos/legend-graph';
24
25
  import {
25
26
  guaranteeNonNullable,
@@ -35,7 +36,6 @@ import type {
35
36
  } from '../QueryBuilderPostFilterState.js';
36
37
  import {
37
38
  generateDefaultValueForPrimitiveType,
38
- getNonCollectionValueSpecificationType,
39
39
  isTypeCompatibleForAssignment,
40
40
  } from '../../../../QueryBuilderValueSpecificationHelper.js';
41
41
  import { buildPostFilterConditionExpression } from './QueryBuilderPostFilterOperatorValueSpecificationBuilder.js';
@@ -69,11 +69,11 @@ export class QueryBuilderPostFilterOperator_GreaterThan
69
69
  postFilterConditionState: PostFilterConditionState,
70
70
  ): boolean {
71
71
  return isTypeCompatibleForAssignment(
72
- postFilterConditionState.value
73
- ? getNonCollectionValueSpecificationType(postFilterConditionState.value)
72
+ !postFilterConditionState.rightConditionValue.isCollection
73
+ ? postFilterConditionState.rightConditionValue.type
74
74
  : undefined,
75
75
  guaranteeNonNullable(
76
- postFilterConditionState.columnState.getColumnType(),
76
+ postFilterConditionState.leftConditionValue.getColumnType(),
77
77
  ),
78
78
  );
79
79
  }
@@ -81,7 +81,8 @@ export class QueryBuilderPostFilterOperator_GreaterThan
81
81
  getDefaultFilterConditionValue(
82
82
  postFilterConditionState: PostFilterConditionState,
83
83
  ): ValueSpecification {
84
- const propertyType = postFilterConditionState.columnState.getColumnType();
84
+ const propertyType =
85
+ postFilterConditionState.leftConditionValue.getColumnType();
85
86
  switch (propertyType?.path) {
86
87
  case PRIMITIVE_TYPE.NUMBER:
87
88
  case PRIMITIVE_TYPE.DECIMAL:
@@ -121,10 +122,10 @@ export class QueryBuilderPostFilterOperator_GreaterThan
121
122
  return buildPostFilterConditionExpression(
122
123
  postFilterConditionState,
123
124
  this,
124
- postFilterConditionState.columnState.getColumnType()?.path ===
125
- PRIMITIVE_TYPE.DATETIME &&
126
- postFilterConditionState.value?.genericType?.value.rawType.path !==
127
- PRIMITIVE_TYPE.DATETIME
125
+ postFilterConditionState.leftConditionValue.getColumnType() ===
126
+ PrimitiveType.DATETIME &&
127
+ postFilterConditionState.rightConditionValue.type !==
128
+ PrimitiveType.DATETIME
128
129
  ? QUERY_BUILDER_SUPPORTED_FUNCTIONS.IS_AFTER_DAY
129
130
  : QUERY_BUILDER_SUPPORTED_FUNCTIONS.GREATER_THAN,
130
131
  );
@@ -19,6 +19,7 @@ import {
19
19
  type ValueSpecification,
20
20
  AbstractPropertyExpression,
21
21
  PRIMITIVE_TYPE,
22
+ PrimitiveType,
22
23
  } from '@finos/legend-graph';
23
24
  import { buildPostFilterConditionState } from '../QueryBuilderPostFilterStateBuilder.js';
24
25
  import type {
@@ -42,10 +43,10 @@ export class QueryBuilderPostFilterOperator_GreaterThanEqual extends QueryBuilde
42
43
  return buildPostFilterConditionExpression(
43
44
  postFilterConditionState,
44
45
  this,
45
- postFilterConditionState.columnState.getColumnType()?.path ===
46
- PRIMITIVE_TYPE.DATETIME &&
47
- postFilterConditionState.value?.genericType?.value.rawType.path !==
48
- PRIMITIVE_TYPE.DATETIME
46
+ postFilterConditionState.leftConditionValue.getColumnType() ===
47
+ PrimitiveType.DATETIME &&
48
+ postFilterConditionState.rightConditionValue.type !==
49
+ PrimitiveType.DATETIME
49
50
  ? QUERY_BUILDER_SUPPORTED_FUNCTIONS.IS_ON_OR_AFTER_DAY
50
51
  : QUERY_BUILDER_SUPPORTED_FUNCTIONS.GREATER_THAN_EQUAL,
51
52
  );
@@ -34,9 +34,10 @@ import {
34
34
  } from '@finos/legend-shared';
35
35
  import { QueryBuilderPostFilterOperator } from '../QueryBuilderPostFilterOperator.js';
36
36
  import { buildPostFilterConditionState } from '../QueryBuilderPostFilterStateBuilder.js';
37
- import type {
38
- PostFilterConditionState,
39
- QueryBuilderPostFilterState,
37
+ import {
38
+ PostFilterValueSpecConditionValueState,
39
+ type PostFilterConditionState,
40
+ type QueryBuilderPostFilterState,
40
41
  } from '../QueryBuilderPostFilterState.js';
41
42
  import { buildPostFilterConditionExpression } from './QueryBuilderPostFilterOperatorValueSpecificationBuilder.js';
42
43
  import {
@@ -75,47 +76,51 @@ export class QueryBuilderPostFilterOperator_In
75
76
  postFilterConditionState: PostFilterConditionState,
76
77
  ): boolean {
77
78
  const propertyType = guaranteeNonNullable(
78
- postFilterConditionState.columnState.getColumnType(),
79
+ postFilterConditionState.leftConditionValue.getColumnType(),
79
80
  );
80
- const valueSpec = postFilterConditionState.value;
81
- if (valueSpec instanceof CollectionInstanceValue) {
82
- if (valueSpec.values.length === 0) {
83
- return true;
84
- }
85
- const collectionType = getCollectionValueSpecificationType(
86
- postFilterConditionState.postFilterState.tdsState.queryBuilderState
87
- .graphManagerState.graph,
88
- valueSpec.values,
89
- );
90
- if (!collectionType) {
91
- return false;
92
- }
93
- if (
94
- (
95
- [
96
- PRIMITIVE_TYPE.NUMBER,
97
- PRIMITIVE_TYPE.INTEGER,
98
- PRIMITIVE_TYPE.DECIMAL,
99
- PRIMITIVE_TYPE.FLOAT,
100
- ] as string[]
101
- ).includes(propertyType.path)
102
- ) {
103
- return (
104
- [
105
- PRIMITIVE_TYPE.NUMBER,
106
- PRIMITIVE_TYPE.INTEGER,
107
- PRIMITIVE_TYPE.DECIMAL,
108
- PRIMITIVE_TYPE.FLOAT,
109
- ] as string[]
110
- ).includes(collectionType.path);
111
- }
112
- return collectionType === propertyType;
113
- } else if (valueSpec instanceof VariableExpression) {
114
- // check if not a single value
115
- if (valueSpec.multiplicity.upperBound === 1) {
116
- return false;
81
+ const rightSide = postFilterConditionState.rightConditionValue;
82
+ // `in`/`not in` doest not support right hand value being column state as the multipliticy for columns are [0..1]
83
+ if (rightSide instanceof PostFilterValueSpecConditionValueState) {
84
+ const valueSpec = rightSide.value;
85
+ if (valueSpec instanceof CollectionInstanceValue) {
86
+ if (valueSpec.values.length === 0) {
87
+ return true;
88
+ }
89
+ const collectionType = getCollectionValueSpecificationType(
90
+ postFilterConditionState.postFilterState.tdsState.queryBuilderState
91
+ .graphManagerState.graph,
92
+ valueSpec.values,
93
+ );
94
+ if (!collectionType) {
95
+ return false;
96
+ }
97
+ if (
98
+ (
99
+ [
100
+ PRIMITIVE_TYPE.NUMBER,
101
+ PRIMITIVE_TYPE.INTEGER,
102
+ PRIMITIVE_TYPE.DECIMAL,
103
+ PRIMITIVE_TYPE.FLOAT,
104
+ ] as string[]
105
+ ).includes(propertyType.path)
106
+ ) {
107
+ return (
108
+ [
109
+ PRIMITIVE_TYPE.NUMBER,
110
+ PRIMITIVE_TYPE.INTEGER,
111
+ PRIMITIVE_TYPE.DECIMAL,
112
+ PRIMITIVE_TYPE.FLOAT,
113
+ ] as string[]
114
+ ).includes(collectionType.path);
115
+ }
116
+ return collectionType === propertyType;
117
+ } else if (valueSpec instanceof VariableExpression) {
118
+ // check if not a single value
119
+ if (valueSpec.multiplicity.upperBound === 1) {
120
+ return false;
121
+ }
122
+ return propertyType === valueSpec.genericType?.value.rawType;
117
123
  }
118
- return propertyType === valueSpec.genericType?.value.rawType;
119
124
  }
120
125
  return false;
121
126
  }
@@ -124,7 +129,7 @@ export class QueryBuilderPostFilterOperator_In
124
129
  postFilterConditionState: PostFilterConditionState,
125
130
  ): ValueSpecification {
126
131
  const propertyType = guaranteeNonNullable(
127
- postFilterConditionState.columnState.getColumnType(),
132
+ postFilterConditionState.leftConditionValue.getColumnType(),
128
133
  );
129
134
  return new CollectionInstanceValue(
130
135
  Multiplicity.ONE,
@@ -27,6 +27,7 @@ import {
27
27
  type PostFilterConditionState,
28
28
  type QueryBuilderPostFilterState,
29
29
  TDS_COLUMN_GETTER,
30
+ PostFilterValueSpecConditionValueState,
30
31
  } from '../QueryBuilderPostFilterState.js';
31
32
  import { QueryBuilderSimpleProjectionColumnState } from '../../projection/QueryBuilderProjectionColumnState.js';
32
33
  import { buildPostFilterConditionExpression } from './QueryBuilderPostFilterOperatorValueSpecificationBuilder.js';
@@ -53,20 +54,27 @@ export class QueryBuilderPostFilterOperator_IsEmpty
53
54
  isCompatibleWithConditionValue(
54
55
  postFilterConditionState: PostFilterConditionState,
55
56
  ): boolean {
56
- return postFilterConditionState.value === undefined;
57
+ if (
58
+ postFilterConditionState.rightConditionValue instanceof
59
+ PostFilterValueSpecConditionValueState &&
60
+ postFilterConditionState.rightConditionValue.value === undefined
61
+ ) {
62
+ return true;
63
+ }
64
+ return false;
57
65
  }
58
66
 
59
67
  override isCompatibleWithPostFilterColumn(
60
68
  postFilterState: PostFilterConditionState,
61
69
  ): boolean {
62
- const columnType = postFilterState.columnState.getColumnType();
70
+ const columnType = postFilterState.leftConditionValue.getColumnType();
63
71
  if (columnType && this.isCompatibleWithType(columnType)) {
64
72
  if (
65
- postFilterState.columnState instanceof
73
+ postFilterState.leftConditionValue instanceof
66
74
  QueryBuilderSimpleProjectionColumnState
67
75
  ) {
68
76
  return isPropertyExpressionChainOptional(
69
- postFilterState.columnState.propertyExpressionState
77
+ postFilterState.leftConditionValue.propertyExpressionState
70
78
  .propertyExpression,
71
79
  );
72
80
  }
@@ -20,6 +20,7 @@ import {
20
20
  AbstractPropertyExpression,
21
21
  type FunctionExpression,
22
22
  PRIMITIVE_TYPE,
23
+ PrimitiveType,
23
24
  } from '@finos/legend-graph';
24
25
  import {
25
26
  guaranteeNonNullable,
@@ -35,7 +36,6 @@ import type {
35
36
  } from '../QueryBuilderPostFilterState.js';
36
37
  import {
37
38
  generateDefaultValueForPrimitiveType,
38
- getNonCollectionValueSpecificationType,
39
39
  isTypeCompatibleForAssignment,
40
40
  } from '../../../../QueryBuilderValueSpecificationHelper.js';
41
41
  import { buildPostFilterConditionExpression } from './QueryBuilderPostFilterOperatorValueSpecificationBuilder.js';
@@ -69,11 +69,11 @@ export class QueryBuilderPostFilterOperator_LessThan
69
69
  postFilterConditionState: PostFilterConditionState,
70
70
  ): boolean {
71
71
  return isTypeCompatibleForAssignment(
72
- postFilterConditionState.value
73
- ? getNonCollectionValueSpecificationType(postFilterConditionState.value)
72
+ !postFilterConditionState.rightConditionValue.isCollection
73
+ ? postFilterConditionState.rightConditionValue.type
74
74
  : undefined,
75
75
  guaranteeNonNullable(
76
- postFilterConditionState.columnState.getColumnType(),
76
+ postFilterConditionState.leftConditionValue.getColumnType(),
77
77
  ),
78
78
  );
79
79
  }
@@ -81,7 +81,8 @@ export class QueryBuilderPostFilterOperator_LessThan
81
81
  getDefaultFilterConditionValue(
82
82
  postFilterConditionState: PostFilterConditionState,
83
83
  ): ValueSpecification {
84
- const propertyType = postFilterConditionState.columnState.getColumnType();
84
+ const propertyType =
85
+ postFilterConditionState.leftConditionValue.getColumnType();
85
86
  switch (propertyType?.path) {
86
87
  case PRIMITIVE_TYPE.NUMBER:
87
88
  case PRIMITIVE_TYPE.DECIMAL:
@@ -121,10 +122,10 @@ export class QueryBuilderPostFilterOperator_LessThan
121
122
  return buildPostFilterConditionExpression(
122
123
  postFilterConditionState,
123
124
  this,
124
- postFilterConditionState.columnState.getColumnType()?.path ===
125
- PRIMITIVE_TYPE.DATETIME &&
126
- postFilterConditionState.value?.genericType?.value.rawType.path !==
127
- PRIMITIVE_TYPE.DATETIME
125
+ postFilterConditionState.leftConditionValue.getColumnType() ===
126
+ PrimitiveType.DATETIME &&
127
+ postFilterConditionState.rightConditionValue.type !==
128
+ PrimitiveType.DATETIME
128
129
  ? QUERY_BUILDER_SUPPORTED_FUNCTIONS.IS_BEFORE_DAY
129
130
  : QUERY_BUILDER_SUPPORTED_FUNCTIONS.LESS_THAN,
130
131
  );
@@ -19,6 +19,7 @@ import {
19
19
  type ValueSpecification,
20
20
  AbstractPropertyExpression,
21
21
  PRIMITIVE_TYPE,
22
+ PrimitiveType,
22
23
  } from '@finos/legend-graph';
23
24
  import { buildPostFilterConditionState } from '../QueryBuilderPostFilterStateBuilder.js';
24
25
  import type {
@@ -45,10 +46,10 @@ export class QueryBuilderPostFilterOperator_LessThanEqual
45
46
  return buildPostFilterConditionExpression(
46
47
  postFilterConditionState,
47
48
  this,
48
- postFilterConditionState.columnState.getColumnType()?.path ===
49
- PRIMITIVE_TYPE.DATETIME &&
50
- postFilterConditionState.value?.genericType?.value.rawType.path !==
51
- PRIMITIVE_TYPE.DATETIME
49
+ postFilterConditionState.leftConditionValue.getColumnType() ===
50
+ PrimitiveType.DATETIME &&
51
+ postFilterConditionState.rightConditionValue.type !==
52
+ PrimitiveType.DATETIME
52
53
  ? QUERY_BUILDER_SUPPORTED_FUNCTIONS.IS_ON_OR_BEFORE_DAY
53
54
  : QUERY_BUILDER_SUPPORTED_FUNCTIONS.LESS_THAN_EQUAL,
54
55
  );
@@ -36,7 +36,6 @@ import type {
36
36
  import {
37
37
  buildNotExpression,
38
38
  generateDefaultValueForPrimitiveType,
39
- getNonCollectionValueSpecificationType,
40
39
  unwrapNotExpression,
41
40
  } from '../../../../QueryBuilderValueSpecificationHelper.js';
42
41
  import { buildPostFilterConditionExpression } from './QueryBuilderPostFilterOperatorValueSpecificationBuilder.js';
@@ -59,16 +58,17 @@ export class QueryBuilderPostFilterOperator_StartWith
59
58
  isCompatibleWithConditionValue(
60
59
  postFilterConditionState: PostFilterConditionState,
61
60
  ): boolean {
62
- const type = postFilterConditionState.value
63
- ? getNonCollectionValueSpecificationType(postFilterConditionState.value)
64
- : undefined;
65
- return PrimitiveType.STRING === type;
61
+ return (
62
+ !postFilterConditionState.rightConditionValue.isCollection &&
63
+ PrimitiveType.STRING === postFilterConditionState.rightConditionValue.type
64
+ );
66
65
  }
67
66
 
68
67
  getDefaultFilterConditionValue(
69
68
  postFilterConditionState: PostFilterConditionState,
70
69
  ): ValueSpecification {
71
- const propertyType = postFilterConditionState.columnState.getColumnType();
70
+ const propertyType =
71
+ postFilterConditionState.leftConditionValue.getColumnType();
72
72
  switch (propertyType?.path) {
73
73
  case PRIMITIVE_TYPE.STRING: {
74
74
  return buildPrimitiveInstanceValue(
@@ -372,20 +372,42 @@ export class QueryBuilderDerivationProjectionColumnState
372
372
  const variable = projectionParameter[0] as VariableExpression;
373
373
  assertNonEmptyString(variable.name);
374
374
  // assign variable to query class
375
+ const queryBuilderState = this.tdsState.queryBuilderState;
375
376
  const rawVariableExpression = new RawVariableExpression(
376
377
  variable.name,
377
378
  Multiplicity.ONE,
378
379
  PackageableElementExplicitReference.create(
379
- guaranteeNonNullable(this.tdsState.queryBuilderState.class),
380
+ guaranteeNonNullable(queryBuilderState.class),
380
381
  ),
381
382
  );
382
383
  const _rawVariableExpression =
383
- this.tdsState.queryBuilderState.graphManagerState.graphManager.serializeRawValueSpecification(
384
+ queryBuilderState.graphManagerState.graphManager.serializeRawValueSpecification(
384
385
  rawVariableExpression,
385
386
  );
387
+ const parameters = queryBuilderState.parametersState.parameterStates.map(
388
+ (_param) =>
389
+ queryBuilderState.graphManagerState.graphManager.serializeValueSpecification(
390
+ _param.parameter,
391
+ ),
392
+ );
393
+ const letExpressions = queryBuilderState.constantState.constants
394
+ .map((_const) => _const.buildLetExpression())
395
+ .map((expres) =>
396
+ queryBuilderState.graphManagerState.graphManager.serializeValueSpecification(
397
+ expres,
398
+ ),
399
+ );
400
+ let lambdaBody = this.lambda.body;
401
+ if (letExpressions.length) {
402
+ if (Array.isArray(this.lambda.body)) {
403
+ lambdaBody = [...letExpressions, ...(this.lambda.body as object[])];
404
+ } else {
405
+ lambdaBody = [...letExpressions, this.lambda.body];
406
+ }
407
+ }
386
408
  const isolatedLambda = new RawLambda(
387
- [_rawVariableExpression],
388
- this.lambda.body,
409
+ [_rawVariableExpression, ...parameters],
410
+ lambdaBody,
389
411
  );
390
412
  return isolatedLambda;
391
413
  }