@finos/legend-query-builder 4.9.4 → 4.10.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (118) hide show
  1. package/lib/__lib__/QueryBuilderTesting.d.ts +4 -1
  2. package/lib/__lib__/QueryBuilderTesting.d.ts.map +1 -1
  3. package/lib/__lib__/QueryBuilderTesting.js +5 -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 +80 -90
  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 +1 -1
  18. package/lib/components/fetch-structure/QueryBuilderTDSPanel.js.map +1 -1
  19. package/lib/components/filter/QueryBuilderFilterPanel.d.ts +3 -2
  20. package/lib/components/filter/QueryBuilderFilterPanel.d.ts.map +1 -1
  21. package/lib/components/filter/QueryBuilderFilterPanel.js +145 -8
  22. package/lib/components/filter/QueryBuilderFilterPanel.js.map +1 -1
  23. package/lib/index.css +16 -0
  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/QueryBuilderResultState.d.ts +3 -0
  30. package/lib/stores/QueryBuilderResultState.d.ts.map +1 -1
  31. package/lib/stores/QueryBuilderResultState.js +31 -2
  32. package/lib/stores/QueryBuilderResultState.js.map +1 -1
  33. package/lib/stores/QueryBuilderStateHashUtils.d.ts +2 -0
  34. package/lib/stores/QueryBuilderStateHashUtils.d.ts.map +1 -1
  35. package/lib/stores/QueryBuilderStateHashUtils.js +2 -0
  36. package/lib/stores/QueryBuilderStateHashUtils.js.map +1 -1
  37. package/lib/stores/QueryBuilderValueSpecificationBuilder.d.ts.map +1 -1
  38. package/lib/stores/QueryBuilderValueSpecificationBuilder.js +3 -23
  39. package/lib/stores/QueryBuilderValueSpecificationBuilder.js.map +1 -1
  40. package/lib/stores/fetch-structure/tds/post-filter/QueryBuilderPostFilterOperator.js +1 -1
  41. package/lib/stores/fetch-structure/tds/post-filter/QueryBuilderPostFilterOperator.js.map +1 -1
  42. package/lib/stores/fetch-structure/tds/post-filter/QueryBuilderPostFilterState.d.ts +31 -5
  43. package/lib/stores/fetch-structure/tds/post-filter/QueryBuilderPostFilterState.d.ts.map +1 -1
  44. package/lib/stores/fetch-structure/tds/post-filter/QueryBuilderPostFilterState.js +125 -30
  45. package/lib/stores/fetch-structure/tds/post-filter/QueryBuilderPostFilterState.js.map +1 -1
  46. package/lib/stores/fetch-structure/tds/post-filter/QueryBuilderPostFilterStateBuilder.d.ts.map +1 -1
  47. package/lib/stores/fetch-structure/tds/post-filter/QueryBuilderPostFilterStateBuilder.js +21 -8
  48. package/lib/stores/fetch-structure/tds/post-filter/QueryBuilderPostFilterStateBuilder.js.map +1 -1
  49. package/lib/stores/fetch-structure/tds/post-filter/operators/QueryBuilderPostFilterOperatorValueSpecificationBuilder.d.ts +3 -1
  50. package/lib/stores/fetch-structure/tds/post-filter/operators/QueryBuilderPostFilterOperatorValueSpecificationBuilder.d.ts.map +1 -1
  51. package/lib/stores/fetch-structure/tds/post-filter/operators/QueryBuilderPostFilterOperatorValueSpecificationBuilder.js +20 -17
  52. package/lib/stores/fetch-structure/tds/post-filter/operators/QueryBuilderPostFilterOperatorValueSpecificationBuilder.js.map +1 -1
  53. package/lib/stores/fetch-structure/tds/post-filter/operators/QueryBuilderPostFilterOperator_Contain.d.ts.map +1 -1
  54. package/lib/stores/fetch-structure/tds/post-filter/operators/QueryBuilderPostFilterOperator_Contain.js +4 -6
  55. package/lib/stores/fetch-structure/tds/post-filter/operators/QueryBuilderPostFilterOperator_Contain.js.map +1 -1
  56. package/lib/stores/fetch-structure/tds/post-filter/operators/QueryBuilderPostFilterOperator_EndWith.d.ts.map +1 -1
  57. package/lib/stores/fetch-structure/tds/post-filter/operators/QueryBuilderPostFilterOperator_EndWith.js +4 -6
  58. package/lib/stores/fetch-structure/tds/post-filter/operators/QueryBuilderPostFilterOperator_EndWith.js.map +1 -1
  59. package/lib/stores/fetch-structure/tds/post-filter/operators/QueryBuilderPostFilterOperator_Equal.d.ts +1 -1
  60. package/lib/stores/fetch-structure/tds/post-filter/operators/QueryBuilderPostFilterOperator_Equal.d.ts.map +1 -1
  61. package/lib/stores/fetch-structure/tds/post-filter/operators/QueryBuilderPostFilterOperator_Equal.js +10 -10
  62. package/lib/stores/fetch-structure/tds/post-filter/operators/QueryBuilderPostFilterOperator_Equal.js.map +1 -1
  63. package/lib/stores/fetch-structure/tds/post-filter/operators/QueryBuilderPostFilterOperator_GreaterThan.d.ts.map +1 -1
  64. package/lib/stores/fetch-structure/tds/post-filter/operators/QueryBuilderPostFilterOperator_GreaterThan.js +10 -10
  65. package/lib/stores/fetch-structure/tds/post-filter/operators/QueryBuilderPostFilterOperator_GreaterThan.js.map +1 -1
  66. package/lib/stores/fetch-structure/tds/post-filter/operators/QueryBuilderPostFilterOperator_GreaterThanEqual.d.ts.map +1 -1
  67. package/lib/stores/fetch-structure/tds/post-filter/operators/QueryBuilderPostFilterOperator_GreaterThanEqual.js +5 -5
  68. package/lib/stores/fetch-structure/tds/post-filter/operators/QueryBuilderPostFilterOperator_GreaterThanEqual.js.map +1 -1
  69. package/lib/stores/fetch-structure/tds/post-filter/operators/QueryBuilderPostFilterOperator_In.d.ts +1 -1
  70. package/lib/stores/fetch-structure/tds/post-filter/operators/QueryBuilderPostFilterOperator_In.d.ts.map +1 -1
  71. package/lib/stores/fetch-structure/tds/post-filter/operators/QueryBuilderPostFilterOperator_In.js +32 -27
  72. package/lib/stores/fetch-structure/tds/post-filter/operators/QueryBuilderPostFilterOperator_In.js.map +1 -1
  73. package/lib/stores/fetch-structure/tds/post-filter/operators/QueryBuilderPostFilterOperator_IsEmpty.d.ts.map +1 -1
  74. package/lib/stores/fetch-structure/tds/post-filter/operators/QueryBuilderPostFilterOperator_IsEmpty.js +10 -5
  75. package/lib/stores/fetch-structure/tds/post-filter/operators/QueryBuilderPostFilterOperator_IsEmpty.js.map +1 -1
  76. package/lib/stores/fetch-structure/tds/post-filter/operators/QueryBuilderPostFilterOperator_LessThan.d.ts.map +1 -1
  77. package/lib/stores/fetch-structure/tds/post-filter/operators/QueryBuilderPostFilterOperator_LessThan.js +10 -10
  78. package/lib/stores/fetch-structure/tds/post-filter/operators/QueryBuilderPostFilterOperator_LessThan.js.map +1 -1
  79. package/lib/stores/fetch-structure/tds/post-filter/operators/QueryBuilderPostFilterOperator_LessThanEqual.d.ts.map +1 -1
  80. package/lib/stores/fetch-structure/tds/post-filter/operators/QueryBuilderPostFilterOperator_LessThanEqual.js +5 -5
  81. package/lib/stores/fetch-structure/tds/post-filter/operators/QueryBuilderPostFilterOperator_LessThanEqual.js.map +1 -1
  82. package/lib/stores/fetch-structure/tds/post-filter/operators/QueryBuilderPostFilterOperator_StartWith.d.ts.map +1 -1
  83. package/lib/stores/fetch-structure/tds/post-filter/operators/QueryBuilderPostFilterOperator_StartWith.js +4 -6
  84. package/lib/stores/fetch-structure/tds/post-filter/operators/QueryBuilderPostFilterOperator_StartWith.js.map +1 -1
  85. package/lib/stores/fetch-structure/tds/projection/QueryBuilderProjectionColumnState.d.ts.map +1 -1
  86. package/lib/stores/fetch-structure/tds/projection/QueryBuilderProjectionColumnState.js +17 -3
  87. package/lib/stores/fetch-structure/tds/projection/QueryBuilderProjectionColumnState.js.map +1 -1
  88. package/lib/stores/filter/QueryBuilderFilterState.d.ts +7 -1
  89. package/lib/stores/filter/QueryBuilderFilterState.d.ts.map +1 -1
  90. package/lib/stores/filter/QueryBuilderFilterState.js +27 -0
  91. package/lib/stores/filter/QueryBuilderFilterState.js.map +1 -1
  92. package/package.json +5 -5
  93. package/src/__lib__/QueryBuilderTesting.ts +5 -1
  94. package/src/components/QueryBuilderResultPanel.tsx +127 -135
  95. package/src/components/__test-utils__/QueryBuilderComponentTestUtils.tsx +25 -1
  96. package/src/components/fetch-structure/QueryBuilderPostFilterPanel.tsx +102 -49
  97. package/src/components/fetch-structure/QueryBuilderTDSPanel.tsx +6 -2
  98. package/src/components/filter/QueryBuilderFilterPanel.tsx +239 -21
  99. package/src/stores/QueryBuilderConstantsState.ts +30 -0
  100. package/src/stores/QueryBuilderResultState.ts +36 -1
  101. package/src/stores/QueryBuilderStateHashUtils.ts +2 -0
  102. package/src/stores/QueryBuilderValueSpecificationBuilder.ts +4 -50
  103. package/src/stores/fetch-structure/tds/post-filter/QueryBuilderPostFilterOperator.ts +1 -1
  104. package/src/stores/fetch-structure/tds/post-filter/QueryBuilderPostFilterState.ts +180 -34
  105. package/src/stores/fetch-structure/tds/post-filter/QueryBuilderPostFilterStateBuilder.ts +38 -9
  106. package/src/stores/fetch-structure/tds/post-filter/operators/QueryBuilderPostFilterOperatorValueSpecificationBuilder.ts +36 -20
  107. package/src/stores/fetch-structure/tds/post-filter/operators/QueryBuilderPostFilterOperator_Contain.ts +5 -6
  108. package/src/stores/fetch-structure/tds/post-filter/operators/QueryBuilderPostFilterOperator_EndWith.ts +6 -6
  109. package/src/stores/fetch-structure/tds/post-filter/operators/QueryBuilderPostFilterOperator_Equal.ts +12 -13
  110. package/src/stores/fetch-structure/tds/post-filter/operators/QueryBuilderPostFilterOperator_GreaterThan.ts +10 -9
  111. package/src/stores/fetch-structure/tds/post-filter/operators/QueryBuilderPostFilterOperator_GreaterThanEqual.ts +5 -4
  112. package/src/stores/fetch-structure/tds/post-filter/operators/QueryBuilderPostFilterOperator_In.ts +48 -43
  113. package/src/stores/fetch-structure/tds/post-filter/operators/QueryBuilderPostFilterOperator_IsEmpty.ts +12 -4
  114. package/src/stores/fetch-structure/tds/post-filter/operators/QueryBuilderPostFilterOperator_LessThan.ts +10 -9
  115. package/src/stores/fetch-structure/tds/post-filter/operators/QueryBuilderPostFilterOperator_LessThanEqual.ts +5 -4
  116. package/src/stores/fetch-structure/tds/post-filter/operators/QueryBuilderPostFilterOperator_StartWith.ts +6 -6
  117. package/src/stores/fetch-structure/tds/projection/QueryBuilderProjectionColumnState.ts +26 -4
  118. package/src/stores/filter/QueryBuilderFilterState.ts +40 -1
@@ -27,6 +27,7 @@ import {
27
27
  PropertyExplicitReference,
28
28
  Multiplicity,
29
29
  PrimitiveType,
30
+ type PureModel,
30
31
  } from '@finos/legend-graph';
31
32
  import { guaranteeNonNullable } from '@finos/legend-shared';
32
33
  import type { QueryBuilderPostFilterOperator } from '../QueryBuilderPostFilterOperator.js';
@@ -36,27 +37,19 @@ import {
36
37
  getTDSColumnDerivedProperyFromType,
37
38
  } from '../QueryBuilderPostFilterState.js';
38
39
  import { QUERY_BUILDER_PURE_PATH } from '../../../../../graph/QueryBuilderMetaModelConst.js';
40
+ import type { QueryBuilderTDSColumnState } from '../../QueryBuilderTDSColumnState.js';
39
41
 
40
- export const buildPostFilterConditionExpression = (
42
+ export const buildtdsPropertyExpressionFromColState = (
41
43
  filterConditionState: PostFilterConditionState,
42
- operator: QueryBuilderPostFilterOperator,
43
- /**
44
- * If provided, this will be used to construct the simple
45
- * function expression for the function with the specified
46
- * name. If not provided, we will fall back to use the TDS column getter function expression.
47
- * This is the case because with TDS, we are provided some filter-like operators, e.g. IS_NULL, IS_NOT_NULL, etc.
48
- */
49
- operatorFunctionFullPath: string | undefined,
50
- ): FunctionExpression => {
51
- // primitives
52
- const graph =
53
- filterConditionState.postFilterState.tdsState.queryBuilderState
54
- .graphManagerState.graph;
55
- // property expression
56
- const colState = filterConditionState.columnState;
44
+ colState: QueryBuilderTDSColumnState,
45
+ graph: PureModel,
46
+ operator: QueryBuilderPostFilterOperator | undefined,
47
+ ): AbstractPropertyExpression => {
57
48
  const tdsPropertyExpression = new AbstractPropertyExpression('');
58
49
  let tdsDerivedPropertyName: TDS_COLUMN_GETTER;
59
- const correspondingTDSDerivedProperty = operator.getTDSColumnGetter();
50
+ const correspondingTDSDerivedProperty = operator
51
+ ? operator.getTDSColumnGetter()
52
+ : undefined;
60
53
  if (correspondingTDSDerivedProperty) {
61
54
  tdsDerivedPropertyName = correspondingTDSDerivedProperty;
62
55
  } else {
@@ -79,15 +72,38 @@ export const buildPostFilterConditionExpression = (
79
72
  );
80
73
  colInstanceValue.values = [colState.columnName];
81
74
  tdsPropertyExpression.parametersValues = [variableName, colInstanceValue];
75
+ return tdsPropertyExpression;
76
+ };
77
+
78
+ export const buildPostFilterConditionExpression = (
79
+ filterConditionState: PostFilterConditionState,
80
+ operator: QueryBuilderPostFilterOperator,
81
+ /**
82
+ * If provided, this will be used to construct the simple
83
+ * function expression for the function with the specified
84
+ * name. If not provided, we will fall back to use the TDS column getter function expression.
85
+ * This is the case because with TDS, we are provided some filter-like operators, e.g. IS_NULL, IS_NOT_NULL, etc.
86
+ */
87
+ operatorFunctionFullPath: string | undefined,
88
+ ): FunctionExpression => {
89
+ // primitives
90
+ const graph =
91
+ filterConditionState.postFilterState.tdsState.queryBuilderState
92
+ .graphManagerState.graph;
93
+ // property expression
94
+ const tdsPropertyExpression = buildtdsPropertyExpressionFromColState(
95
+ filterConditionState,
96
+ filterConditionState.leftConditionValue,
97
+ graph,
98
+ operator,
99
+ );
82
100
 
83
101
  if (operatorFunctionFullPath) {
84
102
  const expression = new SimpleFunctionExpression(
85
103
  extractElementNameFromPath(operatorFunctionFullPath),
86
104
  );
87
105
  expression.parametersValues.push(tdsPropertyExpression);
88
- if (filterConditionState.value) {
89
- expression.parametersValues.push(filterConditionState.value);
90
- }
106
+ filterConditionState.rightConditionValue.appendConditionValue(expression);
91
107
  return expression;
92
108
  } else {
93
109
  return tdsPropertyExpression;
@@ -37,7 +37,6 @@ import type {
37
37
  import {
38
38
  buildNotExpression,
39
39
  generateDefaultValueForPrimitiveType,
40
- getNonCollectionValueSpecificationType,
41
40
  unwrapNotExpression,
42
41
  } from '../../../../QueryBuilderValueSpecificationHelper.js';
43
42
  import { buildPostFilterConditionExpression } from './QueryBuilderPostFilterOperatorValueSpecificationBuilder.js';
@@ -60,17 +59,17 @@ export class QueryBuilderPostFilterOperator_Contain
60
59
  isCompatibleWithConditionValue(
61
60
  postFilterConditionState: PostFilterConditionState,
62
61
  ): boolean {
63
- const type = postFilterConditionState.value
64
- ? getNonCollectionValueSpecificationType(postFilterConditionState.value)
65
- : undefined;
66
- return PrimitiveType.STRING === type;
62
+ return (
63
+ !postFilterConditionState.rightConditionValue.isCollection &&
64
+ PrimitiveType.STRING === postFilterConditionState.rightConditionValue.type
65
+ );
67
66
  }
68
67
 
69
68
  getDefaultFilterConditionValue(
70
69
  postFilterConditionState: PostFilterConditionState,
71
70
  ): ValueSpecification {
72
71
  const propertyType = guaranteeNonNullable(
73
- postFilterConditionState.columnState.getColumnType(),
72
+ postFilterConditionState.leftConditionValue.getColumnType(),
74
73
  );
75
74
  switch (propertyType.path) {
76
75
  case PRIMITIVE_TYPE.STRING: {
@@ -35,7 +35,6 @@ import type {
35
35
  import {
36
36
  buildNotExpression,
37
37
  generateDefaultValueForPrimitiveType,
38
- getNonCollectionValueSpecificationType,
39
38
  unwrapNotExpression,
40
39
  } from '../../../../QueryBuilderValueSpecificationHelper.js';
41
40
  import { buildPostFilterConditionExpression } from './QueryBuilderPostFilterOperatorValueSpecificationBuilder.js';
@@ -58,16 +57,17 @@ export class QueryBuilderPostFilterOperator_EndWith
58
57
  isCompatibleWithConditionValue(
59
58
  postFilterConditionState: PostFilterConditionState,
60
59
  ): boolean {
61
- const type = postFilterConditionState.value
62
- ? getNonCollectionValueSpecificationType(postFilterConditionState.value)
63
- : undefined;
64
- return PrimitiveType.STRING === type;
60
+ return (
61
+ !postFilterConditionState.rightConditionValue.isCollection &&
62
+ PrimitiveType.STRING === postFilterConditionState.rightConditionValue.type
63
+ );
65
64
  }
66
65
 
67
66
  getDefaultFilterConditionValue(
68
67
  postFilterConditionState: PostFilterConditionState,
69
68
  ): ValueSpecification {
70
- const propertyType = postFilterConditionState.columnState.getColumnType();
69
+ const propertyType =
70
+ postFilterConditionState.leftConditionValue.getColumnType();
71
71
  switch (propertyType?.path) {
72
72
  case PRIMITIVE_TYPE.STRING: {
73
73
  return buildPrimitiveInstanceValue(
@@ -27,6 +27,7 @@ import {
27
27
  GenericType,
28
28
  GenericTypeExplicitReference,
29
29
  PRIMITIVE_TYPE,
30
+ PrimitiveType,
30
31
  } from '@finos/legend-graph';
31
32
  import {
32
33
  guaranteeNonNullable,
@@ -36,14 +37,13 @@ import {
36
37
  } from '@finos/legend-shared';
37
38
  import { QueryBuilderPostFilterOperator } from '../QueryBuilderPostFilterOperator.js';
38
39
  import { buildPostFilterConditionState } from '../QueryBuilderPostFilterStateBuilder.js';
39
- import type {
40
- PostFilterConditionState,
41
- QueryBuilderPostFilterState,
40
+ import {
41
+ type PostFilterConditionState,
42
+ type QueryBuilderPostFilterState,
42
43
  } from '../QueryBuilderPostFilterState.js';
43
44
  import {
44
45
  buildNotExpression,
45
46
  generateDefaultValueForPrimitiveType,
46
- getNonCollectionValueSpecificationType,
47
47
  isTypeCompatibleForAssignment,
48
48
  unwrapNotExpression,
49
49
  } from '../../../../QueryBuilderValueSpecificationHelper.js';
@@ -84,12 +84,11 @@ export class QueryBuilderPostFilterOperator_Equal
84
84
  isCompatibleWithConditionValue(
85
85
  postFilterConditionState: PostFilterConditionState,
86
86
  ): boolean {
87
- const valueSpecification = postFilterConditionState.value;
88
- if (valueSpecification) {
87
+ if (!postFilterConditionState.rightConditionValue.isCollection) {
89
88
  return isTypeCompatibleForAssignment(
90
- getNonCollectionValueSpecificationType(valueSpecification),
89
+ postFilterConditionState.rightConditionValue.type,
91
90
  guaranteeNonNullable(
92
- postFilterConditionState.columnState.getColumnType(),
91
+ postFilterConditionState.leftConditionValue.getColumnType(),
93
92
  ),
94
93
  );
95
94
  }
@@ -100,7 +99,7 @@ export class QueryBuilderPostFilterOperator_Equal
100
99
  postFilterConditionState: PostFilterConditionState,
101
100
  ): ValueSpecification {
102
101
  const propertyType = guaranteeNonNullable(
103
- postFilterConditionState.columnState.getColumnType(),
102
+ postFilterConditionState.leftConditionValue.getColumnType(),
104
103
  );
105
104
  switch (propertyType.path) {
106
105
  case PRIMITIVE_TYPE.STRING:
@@ -170,10 +169,10 @@ export class QueryBuilderPostFilterOperator_Equal
170
169
  return buildPostFilterConditionExpression(
171
170
  postFilterConditionState,
172
171
  this,
173
- postFilterConditionState.columnState.getColumnType()?.path ===
174
- PRIMITIVE_TYPE.DATETIME &&
175
- postFilterConditionState.value?.genericType?.value.rawType.path !==
176
- PRIMITIVE_TYPE.DATETIME
172
+ postFilterConditionState.leftConditionValue.getColumnType() ===
173
+ PrimitiveType.DATETIME &&
174
+ postFilterConditionState.rightConditionValue.type !==
175
+ PrimitiveType.DATETIME
177
176
  ? QUERY_BUILDER_SUPPORTED_FUNCTIONS.IS_ON_DAY
178
177
  : QUERY_BUILDER_SUPPORTED_FUNCTIONS.EQUAL,
179
178
  );
@@ -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
  }