@finos/legend-query-builder 1.0.2 → 1.0.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (197) hide show
  1. package/lib/components/QueryBuilderConstantExpressionPanel.d.ts.map +1 -1
  2. package/lib/components/QueryBuilderConstantExpressionPanel.js +4 -4
  3. package/lib/components/QueryBuilderConstantExpressionPanel.js.map +1 -1
  4. package/lib/components/QueryBuilderParametersPanel.js +2 -2
  5. package/lib/components/QueryBuilderParametersPanel.js.map +1 -1
  6. package/lib/components/QueryBuilderPropertyExpressionEditor.js +5 -6
  7. package/lib/components/QueryBuilderPropertyExpressionEditor.js.map +1 -1
  8. package/lib/components/QueryBuilderResultPanel.d.ts.map +1 -1
  9. package/lib/components/QueryBuilderResultPanel.js +8 -13
  10. package/lib/components/QueryBuilderResultPanel.js.map +1 -1
  11. package/lib/components/explorer/QueryBuilderExplorerPanel.d.ts.map +1 -1
  12. package/lib/components/explorer/QueryBuilderExplorerPanel.js +6 -6
  13. package/lib/components/explorer/QueryBuilderExplorerPanel.js.map +1 -1
  14. package/lib/components/explorer/QueryBuilderMilestoningEditor.d.ts.map +1 -1
  15. package/lib/components/explorer/QueryBuilderMilestoningEditor.js +3 -5
  16. package/lib/components/explorer/QueryBuilderMilestoningEditor.js.map +1 -1
  17. package/lib/components/explorer/QueryBuilderPropertySearchPanel.d.ts.map +1 -1
  18. package/lib/components/explorer/QueryBuilderPropertySearchPanel.js +5 -6
  19. package/lib/components/explorer/QueryBuilderPropertySearchPanel.js.map +1 -1
  20. package/lib/components/fetch-structure/QueryBuilderPostFilterPanel.js +1 -1
  21. package/lib/components/fetch-structure/QueryBuilderPostFilterPanel.js.map +1 -1
  22. package/lib/components/filter/QueryBuilderFilterPanel.js +1 -1
  23. package/lib/components/filter/QueryBuilderFilterPanel.js.map +1 -1
  24. package/lib/components/shared/BasicValueSpecificationEditor.d.ts.map +1 -1
  25. package/lib/components/shared/BasicValueSpecificationEditor.js +91 -41
  26. package/lib/components/shared/BasicValueSpecificationEditor.js.map +1 -1
  27. package/lib/components/shared/CustomDatePicker.d.ts.map +1 -1
  28. package/lib/components/shared/CustomDatePicker.js +13 -14
  29. package/lib/components/shared/CustomDatePicker.js.map +1 -1
  30. package/lib/components/shared/LambdaEditor.d.ts.map +1 -1
  31. package/lib/components/shared/LambdaEditor.js +1 -1
  32. package/lib/components/shared/LambdaEditor.js.map +1 -1
  33. package/lib/components/watermark/QueryBuilderWatermark.d.ts.map +1 -1
  34. package/lib/components/watermark/QueryBuilderWatermark.js +1 -1
  35. package/lib/components/watermark/QueryBuilderWatermark.js.map +1 -1
  36. package/lib/graphManager/QueryBuilderSupportedFunctions.d.ts +1 -0
  37. package/lib/graphManager/QueryBuilderSupportedFunctions.d.ts.map +1 -1
  38. package/lib/graphManager/QueryBuilderSupportedFunctions.js +1 -0
  39. package/lib/graphManager/QueryBuilderSupportedFunctions.js.map +1 -1
  40. package/lib/graphManager/protocol/pure/QueryBuilder_PureProtocolProcessorPlugin.js.map +1 -1
  41. package/lib/graphManager/protocol/pure/v1/V1_QueryValueSpecificationBuilderHelper.d.ts +8 -8
  42. package/lib/graphManager/protocol/pure/v1/V1_QueryValueSpecificationBuilderHelper.d.ts.map +1 -1
  43. package/lib/graphManager/protocol/pure/v1/V1_QueryValueSpecificationBuilderHelper.js +17 -26
  44. package/lib/graphManager/protocol/pure/v1/V1_QueryValueSpecificationBuilderHelper.js.map +1 -1
  45. package/lib/index.css +2 -2
  46. package/lib/index.css.map +1 -1
  47. package/lib/package.json +11 -10
  48. package/lib/stores/QueryBuilderChangeDetectionState.d.ts +4 -4
  49. package/lib/stores/QueryBuilderChangeDetectionState.d.ts.map +1 -1
  50. package/lib/stores/QueryBuilderChangeDetectionState.js +9 -9
  51. package/lib/stores/QueryBuilderChangeDetectionState.js.map +1 -1
  52. package/lib/stores/QueryBuilderConstantsState.d.ts.map +1 -1
  53. package/lib/stores/QueryBuilderConstantsState.js +4 -4
  54. package/lib/stores/QueryBuilderConstantsState.js.map +1 -1
  55. package/lib/stores/QueryBuilderPropertyEditorState.d.ts +2 -3
  56. package/lib/stores/QueryBuilderPropertyEditorState.d.ts.map +1 -1
  57. package/lib/stores/QueryBuilderPropertyEditorState.js +9 -12
  58. package/lib/stores/QueryBuilderPropertyEditorState.js.map +1 -1
  59. package/lib/stores/QueryBuilderState.d.ts +8 -5
  60. package/lib/stores/QueryBuilderState.d.ts.map +1 -1
  61. package/lib/stores/QueryBuilderState.js +25 -21
  62. package/lib/stores/QueryBuilderState.js.map +1 -1
  63. package/lib/stores/QueryBuilderStateBuilder.d.ts +2 -2
  64. package/lib/stores/QueryBuilderStateBuilder.d.ts.map +1 -1
  65. package/lib/stores/QueryBuilderStateBuilder.js +16 -12
  66. package/lib/stores/QueryBuilderStateBuilder.js.map +1 -1
  67. package/lib/stores/QueryBuilderTextEditorState.d.ts.map +1 -1
  68. package/lib/stores/QueryBuilderTextEditorState.js +4 -1
  69. package/lib/stores/QueryBuilderTextEditorState.js.map +1 -1
  70. package/lib/stores/QueryBuilderValueSpecificationBuilderHelper.js +1 -1
  71. package/lib/stores/QueryBuilderValueSpecificationBuilderHelper.js.map +1 -1
  72. package/lib/stores/QueryBuilderValueSpecificationHelper.d.ts +9 -1
  73. package/lib/stores/QueryBuilderValueSpecificationHelper.d.ts.map +1 -1
  74. package/lib/stores/QueryBuilderValueSpecificationHelper.js +22 -1
  75. package/lib/stores/QueryBuilderValueSpecificationHelper.js.map +1 -1
  76. package/lib/stores/fetch-structure/graph-fetch/QueryBuilderGraphFetchTreeUtil.d.ts.map +1 -1
  77. package/lib/stores/fetch-structure/graph-fetch/QueryBuilderGraphFetchTreeUtil.js +2 -2
  78. package/lib/stores/fetch-structure/graph-fetch/QueryBuilderGraphFetchTreeUtil.js.map +1 -1
  79. package/lib/stores/fetch-structure/tds/post-filter/QueryBuilderPostFilterState.js +1 -1
  80. package/lib/stores/fetch-structure/tds/post-filter/QueryBuilderPostFilterState.js.map +1 -1
  81. package/lib/stores/fetch-structure/tds/post-filter/QueryBuilderPostFilterStateBuilder.d.ts.map +1 -1
  82. package/lib/stores/fetch-structure/tds/post-filter/QueryBuilderPostFilterStateBuilder.js +21 -1
  83. package/lib/stores/fetch-structure/tds/post-filter/QueryBuilderPostFilterStateBuilder.js.map +1 -1
  84. package/lib/stores/fetch-structure/tds/post-filter/operators/QueryBuilderPostFilterOperator_Contain.d.ts.map +1 -1
  85. package/lib/stores/fetch-structure/tds/post-filter/operators/QueryBuilderPostFilterOperator_Contain.js +2 -1
  86. package/lib/stores/fetch-structure/tds/post-filter/operators/QueryBuilderPostFilterOperator_Contain.js.map +1 -1
  87. package/lib/stores/fetch-structure/tds/post-filter/operators/QueryBuilderPostFilterOperator_EndWith.d.ts.map +1 -1
  88. package/lib/stores/fetch-structure/tds/post-filter/operators/QueryBuilderPostFilterOperator_EndWith.js +2 -1
  89. package/lib/stores/fetch-structure/tds/post-filter/operators/QueryBuilderPostFilterOperator_EndWith.js.map +1 -1
  90. package/lib/stores/fetch-structure/tds/post-filter/operators/QueryBuilderPostFilterOperator_Equal.d.ts.map +1 -1
  91. package/lib/stores/fetch-structure/tds/post-filter/operators/QueryBuilderPostFilterOperator_Equal.js +6 -3
  92. package/lib/stores/fetch-structure/tds/post-filter/operators/QueryBuilderPostFilterOperator_Equal.js.map +1 -1
  93. package/lib/stores/fetch-structure/tds/post-filter/operators/QueryBuilderPostFilterOperator_GreaterThan.d.ts.map +1 -1
  94. package/lib/stores/fetch-structure/tds/post-filter/operators/QueryBuilderPostFilterOperator_GreaterThan.js +4 -2
  95. package/lib/stores/fetch-structure/tds/post-filter/operators/QueryBuilderPostFilterOperator_GreaterThan.js.map +1 -1
  96. package/lib/stores/fetch-structure/tds/post-filter/operators/QueryBuilderPostFilterOperator_LessThan.d.ts.map +1 -1
  97. package/lib/stores/fetch-structure/tds/post-filter/operators/QueryBuilderPostFilterOperator_LessThan.js +4 -2
  98. package/lib/stores/fetch-structure/tds/post-filter/operators/QueryBuilderPostFilterOperator_LessThan.js.map +1 -1
  99. package/lib/stores/fetch-structure/tds/post-filter/operators/QueryBuilderPostFilterOperator_StartWith.d.ts.map +1 -1
  100. package/lib/stores/fetch-structure/tds/post-filter/operators/QueryBuilderPostFilterOperator_StartWith.js +2 -1
  101. package/lib/stores/fetch-structure/tds/post-filter/operators/QueryBuilderPostFilterOperator_StartWith.js.map +1 -1
  102. package/lib/stores/filter/QueryBuilderFilterState.js +2 -2
  103. package/lib/stores/filter/QueryBuilderFilterState.js.map +1 -1
  104. package/lib/stores/filter/operators/QueryBuilderFilterOperatorValueSpecificationBuilder.d.ts.map +1 -1
  105. package/lib/stores/filter/operators/QueryBuilderFilterOperatorValueSpecificationBuilder.js +9 -2
  106. package/lib/stores/filter/operators/QueryBuilderFilterOperatorValueSpecificationBuilder.js.map +1 -1
  107. package/lib/stores/filter/operators/QueryBuilderFilterOperator_Contain.d.ts.map +1 -1
  108. package/lib/stores/filter/operators/QueryBuilderFilterOperator_Contain.js +1 -1
  109. package/lib/stores/filter/operators/QueryBuilderFilterOperator_Contain.js.map +1 -1
  110. package/lib/stores/filter/operators/QueryBuilderFilterOperator_EndWith.d.ts.map +1 -1
  111. package/lib/stores/filter/operators/QueryBuilderFilterOperator_EndWith.js +1 -1
  112. package/lib/stores/filter/operators/QueryBuilderFilterOperator_EndWith.js.map +1 -1
  113. package/lib/stores/filter/operators/QueryBuilderFilterOperator_Equal.d.ts.map +1 -1
  114. package/lib/stores/filter/operators/QueryBuilderFilterOperator_Equal.js +4 -3
  115. package/lib/stores/filter/operators/QueryBuilderFilterOperator_Equal.js.map +1 -1
  116. package/lib/stores/filter/operators/QueryBuilderFilterOperator_GreaterThan.d.ts.map +1 -1
  117. package/lib/stores/filter/operators/QueryBuilderFilterOperator_GreaterThan.js +2 -2
  118. package/lib/stores/filter/operators/QueryBuilderFilterOperator_GreaterThan.js.map +1 -1
  119. package/lib/stores/filter/operators/QueryBuilderFilterOperator_GreaterThanEqual.d.ts.map +1 -1
  120. package/lib/stores/filter/operators/QueryBuilderFilterOperator_GreaterThanEqual.js +2 -2
  121. package/lib/stores/filter/operators/QueryBuilderFilterOperator_GreaterThanEqual.js.map +1 -1
  122. package/lib/stores/filter/operators/QueryBuilderFilterOperator_LessThan.d.ts.map +1 -1
  123. package/lib/stores/filter/operators/QueryBuilderFilterOperator_LessThan.js +2 -2
  124. package/lib/stores/filter/operators/QueryBuilderFilterOperator_LessThan.js.map +1 -1
  125. package/lib/stores/filter/operators/QueryBuilderFilterOperator_LessThanEqual.d.ts.map +1 -1
  126. package/lib/stores/filter/operators/QueryBuilderFilterOperator_LessThanEqual.js +2 -2
  127. package/lib/stores/filter/operators/QueryBuilderFilterOperator_LessThanEqual.js.map +1 -1
  128. package/lib/stores/filter/operators/QueryBuilderFilterOperator_StartWith.d.ts.map +1 -1
  129. package/lib/stores/filter/operators/QueryBuilderFilterOperator_StartWith.js +1 -1
  130. package/lib/stores/filter/operators/QueryBuilderFilterOperator_StartWith.js.map +1 -1
  131. package/lib/stores/milestoning/QueryBuilderMilestoningState.d.ts.map +1 -1
  132. package/lib/stores/milestoning/QueryBuilderMilestoningState.js +3 -3
  133. package/lib/stores/milestoning/QueryBuilderMilestoningState.js.map +1 -1
  134. package/lib/stores/shared/LambdaParameterState.d.ts +2 -2
  135. package/lib/stores/shared/LambdaParameterState.d.ts.map +1 -1
  136. package/lib/stores/shared/LambdaParameterState.js +5 -5
  137. package/lib/stores/shared/LambdaParameterState.js.map +1 -1
  138. package/lib/stores/shared/ValueSpecificationEditorHelper.d.ts +4 -4
  139. package/lib/stores/shared/ValueSpecificationEditorHelper.d.ts.map +1 -1
  140. package/lib/stores/shared/ValueSpecificationEditorHelper.js +11 -15
  141. package/lib/stores/shared/ValueSpecificationEditorHelper.js.map +1 -1
  142. package/lib/stores/shared/ValueSpecificationModifierHelper.d.ts +8 -8
  143. package/lib/stores/shared/ValueSpecificationModifierHelper.d.ts.map +1 -1
  144. package/lib/stores/shared/ValueSpecificationModifierHelper.js +20 -17
  145. package/lib/stores/shared/ValueSpecificationModifierHelper.js.map +1 -1
  146. package/lib/stores/watermark/QueryBuilderWatermarkState.d.ts.map +1 -1
  147. package/lib/stores/watermark/QueryBuilderWatermarkState.js +1 -1
  148. package/lib/stores/watermark/QueryBuilderWatermarkState.js.map +1 -1
  149. package/package.json +18 -17
  150. package/src/components/QueryBuilderConstantExpressionPanel.tsx +4 -2
  151. package/src/components/QueryBuilderParametersPanel.tsx +2 -2
  152. package/src/components/QueryBuilderPropertyExpressionEditor.tsx +6 -6
  153. package/src/components/QueryBuilderResultPanel.tsx +19 -15
  154. package/src/components/explorer/QueryBuilderExplorerPanel.tsx +10 -11
  155. package/src/components/explorer/QueryBuilderMilestoningEditor.tsx +7 -5
  156. package/src/components/explorer/QueryBuilderPropertySearchPanel.tsx +9 -6
  157. package/src/components/fetch-structure/QueryBuilderPostFilterPanel.tsx +1 -1
  158. package/src/components/filter/QueryBuilderFilterPanel.tsx +1 -1
  159. package/src/components/shared/BasicValueSpecificationEditor.tsx +192 -48
  160. package/src/components/shared/CustomDatePicker.tsx +54 -26
  161. package/src/components/shared/LambdaEditor.tsx +0 -1
  162. package/src/components/watermark/QueryBuilderWatermark.tsx +1 -3
  163. package/src/graphManager/QueryBuilderSupportedFunctions.ts +4 -0
  164. package/src/graphManager/protocol/pure/QueryBuilder_PureProtocolProcessorPlugin.ts +1 -1
  165. package/src/graphManager/protocol/pure/v1/V1_QueryValueSpecificationBuilderHelper.ts +67 -68
  166. package/src/stores/QueryBuilderChangeDetectionState.ts +13 -11
  167. package/src/stores/QueryBuilderConstantsState.ts +4 -3
  168. package/src/stores/QueryBuilderPropertyEditorState.ts +17 -13
  169. package/src/stores/QueryBuilderState.ts +35 -24
  170. package/src/stores/QueryBuilderStateBuilder.ts +20 -18
  171. package/src/stores/QueryBuilderTextEditorState.ts +4 -1
  172. package/src/stores/QueryBuilderValueSpecificationBuilderHelper.ts +1 -1
  173. package/src/stores/QueryBuilderValueSpecificationHelper.ts +36 -0
  174. package/src/stores/fetch-structure/graph-fetch/QueryBuilderGraphFetchTreeUtil.ts +10 -2
  175. package/src/stores/fetch-structure/tds/post-filter/QueryBuilderPostFilterState.ts +1 -1
  176. package/src/stores/fetch-structure/tds/post-filter/QueryBuilderPostFilterStateBuilder.ts +26 -1
  177. package/src/stores/fetch-structure/tds/post-filter/operators/QueryBuilderPostFilterOperator_Contain.ts +2 -0
  178. package/src/stores/fetch-structure/tds/post-filter/operators/QueryBuilderPostFilterOperator_EndWith.ts +2 -0
  179. package/src/stores/fetch-structure/tds/post-filter/operators/QueryBuilderPostFilterOperator_Equal.ts +14 -3
  180. package/src/stores/fetch-structure/tds/post-filter/operators/QueryBuilderPostFilterOperator_GreaterThan.ts +4 -0
  181. package/src/stores/fetch-structure/tds/post-filter/operators/QueryBuilderPostFilterOperator_LessThan.ts +4 -0
  182. package/src/stores/fetch-structure/tds/post-filter/operators/QueryBuilderPostFilterOperator_StartWith.ts +2 -0
  183. package/src/stores/filter/QueryBuilderFilterState.ts +2 -2
  184. package/src/stores/filter/operators/QueryBuilderFilterOperatorValueSpecificationBuilder.ts +17 -4
  185. package/src/stores/filter/operators/QueryBuilderFilterOperator_Contain.ts +1 -0
  186. package/src/stores/filter/operators/QueryBuilderFilterOperator_EndWith.ts +1 -0
  187. package/src/stores/filter/operators/QueryBuilderFilterOperator_Equal.ts +12 -3
  188. package/src/stores/filter/operators/QueryBuilderFilterOperator_GreaterThan.ts +2 -0
  189. package/src/stores/filter/operators/QueryBuilderFilterOperator_GreaterThanEqual.ts +2 -0
  190. package/src/stores/filter/operators/QueryBuilderFilterOperator_LessThan.ts +2 -0
  191. package/src/stores/filter/operators/QueryBuilderFilterOperator_LessThanEqual.ts +2 -0
  192. package/src/stores/filter/operators/QueryBuilderFilterOperator_StartWith.ts +1 -0
  193. package/src/stores/milestoning/QueryBuilderMilestoningState.ts +3 -9
  194. package/src/stores/shared/LambdaParameterState.ts +9 -5
  195. package/src/stores/shared/ValueSpecificationEditorHelper.ts +24 -9
  196. package/src/stores/shared/ValueSpecificationModifierHelper.ts +42 -20
  197. package/src/stores/watermark/QueryBuilderWatermarkState.ts +1 -4
@@ -198,7 +198,10 @@ export class QueryBuilderTextEditorState extends LambdaEditorState {
198
198
  `Can't parse query. Please fix error before closing: ${this.parserError.message}`,
199
199
  );
200
200
  } else {
201
- this.queryBuilderState.rebuildWithQuery(this.rawLambdaState.lambda);
201
+ this.queryBuilderState.rebuildWithQuery(this.rawLambdaState.lambda, {
202
+ preserveParameterValues: true,
203
+ preserveResult: true,
204
+ });
202
205
  this.setMode(undefined);
203
206
  }
204
207
  return;
@@ -114,7 +114,7 @@ export const buildPropertyExpressionChain = (
114
114
  functionExpression_setParametersValues(
115
115
  currentExpression,
116
116
  [guaranteeNonNullable(currentExpression.parametersValues[0])],
117
- queryBuilderState.observableContext,
117
+ queryBuilderState.observerContext,
118
118
  );
119
119
  }
120
120
  } else {
@@ -44,6 +44,8 @@ import {
44
44
  GenericTypeExplicitReference,
45
45
  GenericType,
46
46
  INTERNAL__PropagatedValue,
47
+ isSubType,
48
+ type ObserverContext,
47
49
  } from '@finos/legend-graph';
48
50
  import {
49
51
  addUniqueEntry,
@@ -59,6 +61,7 @@ import {
59
61
  getDerivedPropertyMilestoningSteoreotype,
60
62
  validateMilestoningPropertyExpressionChain,
61
63
  } from './milestoning/QueryBuilderMilestoningHelper.js';
64
+ import { instanceValue_setValues } from './shared/ValueSpecificationModifierHelper.js';
62
65
 
63
66
  export const getNonCollectionValueSpecificationType = (
64
67
  valueSpecification: ValueSpecification,
@@ -355,3 +358,36 @@ export const isValueExpressionReferencedInValue = (
355
358
  }
356
359
  return false;
357
360
  };
361
+
362
+ /**
363
+ * Some expression which represents a value and can be simplified to make
364
+ * editing experience easier
365
+ *
366
+ * e.g. -5 is often represented as minus(5), which is a function expression
367
+ * but we want to simplify it to a primitive instance value with value -5
368
+ */
369
+ export const simplifyValueExpression = (
370
+ value: ValueSpecification,
371
+ observerContext: ObserverContext,
372
+ ): ValueSpecification => {
373
+ if (
374
+ value instanceof SimpleFunctionExpression &&
375
+ matchFunctionName(
376
+ value.functionName,
377
+ QUERY_BUILDER_SUPPORTED_FUNCTIONS.MINUS,
378
+ ) &&
379
+ value.parametersValues.length === 1 &&
380
+ value.parametersValues[0] instanceof PrimitiveInstanceValue
381
+ ) {
382
+ const val = value.parametersValues[0];
383
+ if (isSubType(val.genericType.value.rawType, PrimitiveType.NUMBER)) {
384
+ instanceValue_setValues(
385
+ val,
386
+ [(val.values[0] as number) * -1],
387
+ observerContext,
388
+ );
389
+ }
390
+ return val;
391
+ }
392
+ return value;
393
+ };
@@ -298,10 +298,18 @@ export const addQueryBuilderPropertyNode = (
298
298
  treeData.nodes.set(childNode.id, childNode);
299
299
  if (parentNode) {
300
300
  addUniqueEntry(parentNode.childrenIds, childNode.id);
301
- graphFetchTree_addSubTree(parentNode.tree, childNode.tree);
301
+ graphFetchTree_addSubTree(
302
+ parentNode.tree,
303
+ childNode.tree,
304
+ queryBuilderState.observerContext,
305
+ );
302
306
  } else {
303
307
  addUniqueEntry(treeData.rootIds, childNode.id);
304
- graphFetchTree_addSubTree(treeData.tree, childNode.tree);
308
+ graphFetchTree_addSubTree(
309
+ treeData.tree,
310
+ childNode.tree,
311
+ queryBuilderState.observerContext,
312
+ );
305
313
  }
306
314
  }
307
315
  };
@@ -410,7 +410,7 @@ export class PostFilterConditionState implements Hashable {
410
410
  this.value = val
411
411
  ? observe_ValueSpecification(
412
412
  val,
413
- this.postFilterState.tdsState.queryBuilderState.observableContext,
413
+ this.postFilterState.tdsState.queryBuilderState.observerContext,
414
414
  )
415
415
  : undefined;
416
416
  }
@@ -49,6 +49,7 @@ import { QUERY_BUILDER_SUPPORTED_FUNCTIONS } from '../../../../graphManager/Quer
49
49
  import type { QueryBuilderState } from '../../../QueryBuilderState.js';
50
50
  import { QueryBuilderTDSState } from '../QueryBuilderTDSState.js';
51
51
  import { toGroupOperation } from '../../../QueryBuilderGroupOperationHelper.js';
52
+ import { simplifyValueExpression } from '../../../QueryBuilderValueSpecificationHelper.js';
52
53
 
53
54
  const findProjectionColumnState = (
54
55
  propertyExpression: AbstractPropertyExpression,
@@ -150,11 +151,17 @@ export const buildPostFilterConditionState = (
150
151
 
151
152
  // get operation value specification
152
153
  const value = expression.parametersValues[1];
154
+
153
155
  // create state
154
156
  postConditionState = new PostFilterConditionState(
155
157
  postFilterState,
156
158
  columnState,
157
- value,
159
+ value
160
+ ? simplifyValueExpression(
161
+ value,
162
+ postFilterState.tdsState.queryBuilderState.observerContext,
163
+ )
164
+ : undefined,
158
165
  operator,
159
166
  );
160
167
 
@@ -178,6 +185,24 @@ const processPostFilterTree = (
178
185
  postFilterState: QueryBuilderPostFilterState,
179
186
  parentPostFilterNodeId: string | undefined,
180
187
  ): void => {
188
+ // // NOTE: This checks if the expression is a simple function expression of Minus
189
+ // // since negative numbers are returned as a SimpleFunctionExpression of minus(number)
190
+ // // rather than a PrimitiveInstanceValue of -number, so here
191
+ // // we replace the parameter value of the expression directly with a PrimitiveInstanceValue
192
+ // if (
193
+ // expression.parametersValues[1] instanceof SimpleFunctionExpression &&
194
+ // expression.parametersValues[1].functionName === MINUS_STRING &&
195
+ // expression.parametersValues[1].parametersValues[0] instanceof
196
+ // PrimitiveInstanceValue
197
+ // ) {
198
+ // expression.parametersValues[1].parametersValues[0].values[0] =
199
+ // parseFloat(
200
+ // expression.parametersValues[1].parametersValues[0].values[0] as string,
201
+ // ) * -1;
202
+ // expression.parametersValues[1] =
203
+ // expression.parametersValues[1].parametersValues[0];
204
+ // }
205
+
181
206
  const parentNode = parentPostFilterNodeId
182
207
  ? postFilterState.getNode(parentPostFilterNodeId)
183
208
  : undefined;
@@ -79,6 +79,8 @@ export class QueryBuilderPostFilterOperator_Contain
79
79
  .graphManagerState.graph,
80
80
  propertyType.path,
81
81
  generateDefaultValueForPrimitiveType(propertyType.path),
82
+ postFilterConditionState.postFilterState.tdsState.queryBuilderState
83
+ .observerContext,
82
84
  );
83
85
  }
84
86
  default:
@@ -75,6 +75,8 @@ export class QueryBuilderPostFilterOperator_EndWith
75
75
  .graphManagerState.graph,
76
76
  propertyType.path,
77
77
  generateDefaultValueForPrimitiveType(propertyType.path),
78
+ postFilterConditionState.postFilterState.tdsState.queryBuilderState
79
+ .observerContext,
78
80
  );
79
81
  }
80
82
  default:
@@ -117,6 +117,8 @@ export class QueryBuilderPostFilterOperator_Equal
117
117
  .graphManagerState.graph,
118
118
  propertyType.path,
119
119
  generateDefaultValueForPrimitiveType(propertyType.path),
120
+ postFilterConditionState.postFilterState.tdsState.queryBuilderState
121
+ .observerContext,
120
122
  );
121
123
  }
122
124
  case PRIMITIVE_TYPE.DATE: {
@@ -125,6 +127,8 @@ export class QueryBuilderPostFilterOperator_Equal
125
127
  .graphManagerState.graph,
126
128
  PRIMITIVE_TYPE.STRICTDATE,
127
129
  generateDefaultValueForPrimitiveType(propertyType.path),
130
+ postFilterConditionState.postFilterState.tdsState.queryBuilderState
131
+ .observerContext,
128
132
  );
129
133
  }
130
134
  default:
@@ -135,9 +139,16 @@ export class QueryBuilderPostFilterOperator_Equal
135
139
  new GenericType(propertyType),
136
140
  ),
137
141
  );
138
- instanceValue_setValues(enumValueInstanceValue, [
139
- EnumValueExplicitReference.create(propertyType.values[0] as Enum),
140
- ]);
142
+ instanceValue_setValues(
143
+ enumValueInstanceValue,
144
+ [
145
+ EnumValueExplicitReference.create(
146
+ propertyType.values[0] as Enum,
147
+ ),
148
+ ],
149
+ postFilterConditionState.postFilterState.tdsState
150
+ .queryBuilderState.observerContext,
151
+ );
141
152
  return enumValueInstanceValue;
142
153
  }
143
154
  throw new UnsupportedOperationError(
@@ -95,6 +95,8 @@ export class QueryBuilderPostFilterOperator_GreaterThan
95
95
  .graphManagerState.graph,
96
96
  propertyType.path,
97
97
  generateDefaultValueForPrimitiveType(propertyType.path),
98
+ postFilterConditionState.postFilterState.tdsState.queryBuilderState
99
+ .observerContext,
98
100
  );
99
101
  }
100
102
  case PRIMITIVE_TYPE.DATE: {
@@ -103,6 +105,8 @@ export class QueryBuilderPostFilterOperator_GreaterThan
103
105
  .graphManagerState.graph,
104
106
  PRIMITIVE_TYPE.STRICTDATE,
105
107
  generateDefaultValueForPrimitiveType(propertyType.path),
108
+ postFilterConditionState.postFilterState.tdsState.queryBuilderState
109
+ .observerContext,
106
110
  );
107
111
  }
108
112
  default:
@@ -95,6 +95,8 @@ export class QueryBuilderPostFilterOperator_LessThan
95
95
  .graphManagerState.graph,
96
96
  propertyType.path,
97
97
  generateDefaultValueForPrimitiveType(propertyType.path),
98
+ postFilterConditionState.postFilterState.tdsState.queryBuilderState
99
+ .observerContext,
98
100
  );
99
101
  }
100
102
  case PRIMITIVE_TYPE.DATE: {
@@ -103,6 +105,8 @@ export class QueryBuilderPostFilterOperator_LessThan
103
105
  .graphManagerState.graph,
104
106
  PRIMITIVE_TYPE.STRICTDATE,
105
107
  generateDefaultValueForPrimitiveType(propertyType.path),
108
+ postFilterConditionState.postFilterState.tdsState.queryBuilderState
109
+ .observerContext,
106
110
  );
107
111
  }
108
112
  default:
@@ -76,6 +76,8 @@ export class QueryBuilderPostFilterOperator_StartWith
76
76
  .graphManagerState.graph,
77
77
  propertyType.path,
78
78
  generateDefaultValueForPrimitiveType(propertyType.path),
79
+ postFilterConditionState.postFilterState.tdsState.queryBuilderState
80
+ .observerContext,
79
81
  );
80
82
  }
81
83
  default:
@@ -167,7 +167,7 @@ export class FilterConditionState implements Hashable {
167
167
  // observe the property expression
168
168
  observe_ValueSpecification(
169
169
  propertyExpression,
170
- this.filterState.queryBuilderState.observableContext,
170
+ this.filterState.queryBuilderState.observerContext,
171
171
  );
172
172
 
173
173
  this.propertyExpressionState = new QueryBuilderPropertyExpressionState(
@@ -204,7 +204,7 @@ export class FilterConditionState implements Hashable {
204
204
  this.value = val
205
205
  ? observe_ValueSpecification(
206
206
  val,
207
- this.filterState.queryBuilderState.observableContext,
207
+ this.filterState.queryBuilderState.observerContext,
208
208
  )
209
209
  : undefined;
210
210
  }
@@ -35,7 +35,10 @@ import {
35
35
  type QueryBuilderFilterState,
36
36
  } from '../QueryBuilderFilterState.js';
37
37
  import { QUERY_BUILDER_SUPPORTED_FUNCTIONS } from '../../../graphManager/QueryBuilderSupportedFunctions.js';
38
- import { buildGenericLambdaFunctionInstanceValue } from '../../QueryBuilderValueSpecificationHelper.js';
38
+ import {
39
+ buildGenericLambdaFunctionInstanceValue,
40
+ simplifyValueExpression,
41
+ } from '../../QueryBuilderValueSpecificationHelper.js';
39
42
  import type { QueryBuilderFilterOperator } from '../QueryBuilderFilterOperator.js';
40
43
  import { buildPropertyExpressionChain } from '../../QueryBuilderValueSpecificationBuilderHelper.js';
41
44
 
@@ -488,9 +491,19 @@ export const buildFilterConditionState = (
488
491
  )}() expression: property is not compatible with operator`,
489
492
  );
490
493
  filterConditionState.setOperator(operator);
491
- filterConditionState.setValue(
492
- hasNoValue ? undefined : mainExpressionWithOperator.parametersValues[1],
493
- );
494
+
495
+ // value
496
+ const value = mainExpressionWithOperator.parametersValues[1];
497
+ if (hasNoValue || !value) {
498
+ filterConditionState.setValue(undefined);
499
+ } else {
500
+ filterConditionState.setValue(
501
+ simplifyValueExpression(
502
+ value,
503
+ filterConditionState.filterState.queryBuilderState.observerContext,
504
+ ),
505
+ );
506
+ }
494
507
  if (!operator.isCompatibleWithFilterConditionValue(filterConditionState)) {
495
508
  filterConditionState.setValue(
496
509
  operator.getDefaultFilterConditionValue(filterConditionState),
@@ -84,6 +84,7 @@ export class QueryBuilderFilterOperator_Contain
84
84
  .graph,
85
85
  propertyType.path,
86
86
  generateDefaultValueForPrimitiveType(propertyType.path),
87
+ filterConditionState.filterState.queryBuilderState.observerContext,
87
88
  );
88
89
  }
89
90
  default:
@@ -84,6 +84,7 @@ export class QueryBuilderFilterOperator_EndWith
84
84
  .graph,
85
85
  propertyType.path,
86
86
  generateDefaultValueForPrimitiveType(propertyType.path),
87
+ filterConditionState.filterState.queryBuilderState.observerContext,
87
88
  );
88
89
  }
89
90
  default:
@@ -118,6 +118,7 @@ export class QueryBuilderFilterOperator_Equal
118
118
  .graph,
119
119
  propertyType.path,
120
120
  generateDefaultValueForPrimitiveType(propertyType.path),
121
+ filterConditionState.filterState.queryBuilderState.observerContext,
121
122
  );
122
123
  }
123
124
  case PRIMITIVE_TYPE.DATE: {
@@ -126,6 +127,7 @@ export class QueryBuilderFilterOperator_Equal
126
127
  .graph,
127
128
  PRIMITIVE_TYPE.STRICTDATE,
128
129
  generateDefaultValueForPrimitiveType(propertyType.path),
130
+ filterConditionState.filterState.queryBuilderState.observerContext,
129
131
  );
130
132
  }
131
133
  default:
@@ -136,9 +138,16 @@ export class QueryBuilderFilterOperator_Equal
136
138
  new GenericType(propertyType),
137
139
  ),
138
140
  );
139
- instanceValue_setValues(enumValueInstanceValue, [
140
- EnumValueExplicitReference.create(propertyType.values[0] as Enum),
141
- ]);
141
+ instanceValue_setValues(
142
+ enumValueInstanceValue,
143
+ [
144
+ EnumValueExplicitReference.create(
145
+ propertyType.values[0] as Enum,
146
+ ),
147
+ ],
148
+ filterConditionState.filterState.queryBuilderState
149
+ .observerContext,
150
+ );
142
151
  return enumValueInstanceValue;
143
152
  }
144
153
  throw new UnsupportedOperationError(
@@ -101,6 +101,7 @@ export class QueryBuilderFilterOperator_GreaterThan
101
101
  .graph,
102
102
  propertyType.path,
103
103
  generateDefaultValueForPrimitiveType(propertyType.path),
104
+ filterConditionState.filterState.queryBuilderState.observerContext,
104
105
  );
105
106
  }
106
107
  case PRIMITIVE_TYPE.DATE: {
@@ -109,6 +110,7 @@ export class QueryBuilderFilterOperator_GreaterThan
109
110
  .graph,
110
111
  PRIMITIVE_TYPE.STRICTDATE,
111
112
  generateDefaultValueForPrimitiveType(propertyType.path),
113
+ filterConditionState.filterState.queryBuilderState.observerContext,
112
114
  );
113
115
  }
114
116
  default:
@@ -101,6 +101,7 @@ export class QueryBuilderFilterOperator_GreaterThanEqual
101
101
  .graph,
102
102
  propertyType.path,
103
103
  generateDefaultValueForPrimitiveType(propertyType.path),
104
+ filterConditionState.filterState.queryBuilderState.observerContext,
104
105
  );
105
106
  }
106
107
  case PRIMITIVE_TYPE.DATE: {
@@ -109,6 +110,7 @@ export class QueryBuilderFilterOperator_GreaterThanEqual
109
110
  .graph,
110
111
  PRIMITIVE_TYPE.STRICTDATE,
111
112
  generateDefaultValueForPrimitiveType(propertyType.path),
113
+ filterConditionState.filterState.queryBuilderState.observerContext,
112
114
  );
113
115
  }
114
116
  default:
@@ -101,6 +101,7 @@ export class QueryBuilderFilterOperator_LessThan
101
101
  .graph,
102
102
  propertyType.path,
103
103
  generateDefaultValueForPrimitiveType(propertyType.path),
104
+ filterConditionState.filterState.queryBuilderState.observerContext,
104
105
  );
105
106
  }
106
107
  case PRIMITIVE_TYPE.DATE: {
@@ -109,6 +110,7 @@ export class QueryBuilderFilterOperator_LessThan
109
110
  .graph,
110
111
  PRIMITIVE_TYPE.STRICTDATE,
111
112
  generateDefaultValueForPrimitiveType(propertyType.path),
113
+ filterConditionState.filterState.queryBuilderState.observerContext,
112
114
  );
113
115
  }
114
116
  default:
@@ -101,6 +101,7 @@ export class QueryBuilderFilterOperator_LessThanEqual
101
101
  .graph,
102
102
  propertyType.path,
103
103
  generateDefaultValueForPrimitiveType(propertyType.path),
104
+ filterConditionState.filterState.queryBuilderState.observerContext,
104
105
  );
105
106
  }
106
107
  case PRIMITIVE_TYPE.DATE: {
@@ -109,6 +110,7 @@ export class QueryBuilderFilterOperator_LessThanEqual
109
110
  .graph,
110
111
  PRIMITIVE_TYPE.STRICTDATE,
111
112
  generateDefaultValueForPrimitiveType(propertyType.path),
113
+ filterConditionState.filterState.queryBuilderState.observerContext,
112
114
  );
113
115
  }
114
116
  default:
@@ -84,6 +84,7 @@ export class QueryBuilderFilterOperator_StartWith
84
84
  .graph,
85
85
  propertyType.path,
86
86
  generateDefaultValueForPrimitiveType(propertyType.path),
87
+ filterConditionState.filterState.queryBuilderState.observerContext,
87
88
  );
88
89
  }
89
90
  default:
@@ -114,19 +114,13 @@ export class QueryBuilderMilestoningState implements Hashable {
114
114
 
115
115
  setProcessingDate(val: ValueSpecification | undefined): void {
116
116
  this.processingDate = val
117
- ? observe_ValueSpecification(
118
- val,
119
- this.queryBuilderState.observableContext,
120
- )
117
+ ? observe_ValueSpecification(val, this.queryBuilderState.observerContext)
121
118
  : val;
122
119
  }
123
120
 
124
121
  setBusinessDate(val: ValueSpecification | undefined): void {
125
122
  this.businessDate = val
126
- ? observe_ValueSpecification(
127
- val,
128
- this.queryBuilderState.observableContext,
129
- )
123
+ ? observe_ValueSpecification(val, this.queryBuilderState.observerContext)
130
124
  : val;
131
125
  }
132
126
 
@@ -165,7 +159,7 @@ export class QueryBuilderMilestoningState implements Hashable {
165
159
  ) {
166
160
  const variableState = new LambdaParameterState(
167
161
  milestoningParameter,
168
- this.queryBuilderState.observableContext,
162
+ this.queryBuilderState.observerContext,
169
163
  this.queryBuilderState.graphManagerState.graph,
170
164
  );
171
165
  variableState.mockParameterValue();
@@ -201,13 +201,13 @@ export class LambdaParameterState implements Hashable {
201
201
  readonly uuid = uuid();
202
202
  readonly parameter: VariableExpression;
203
203
  readonly graph: PureModel;
204
- readonly observableContext: ObserverContext;
204
+ readonly observerContext: ObserverContext;
205
205
 
206
206
  value: ValueSpecification | undefined;
207
207
 
208
208
  constructor(
209
209
  variableExpression: VariableExpression,
210
- observableContext: ObserverContext,
210
+ observerContext: ObserverContext,
211
211
  graph: PureModel,
212
212
  ) {
213
213
  makeObservable(this, {
@@ -217,7 +217,7 @@ export class LambdaParameterState implements Hashable {
217
217
  hashCode: computed,
218
218
  });
219
219
 
220
- this.observableContext = observableContext;
220
+ this.observerContext = observerContext;
221
221
  this.parameter = observe_VariableExpression(variableExpression);
222
222
  this.graph = graph;
223
223
  }
@@ -231,7 +231,11 @@ export class LambdaParameterState implements Hashable {
231
231
 
232
232
  mockParameterValue(): void {
233
233
  this.setValue(
234
- generateVariableExpressionMockValue(this.parameter, this.graph),
234
+ generateVariableExpressionMockValue(
235
+ this.parameter,
236
+ this.graph,
237
+ this.observerContext,
238
+ ),
235
239
  );
236
240
  }
237
241
 
@@ -242,7 +246,7 @@ export class LambdaParameterState implements Hashable {
242
246
  );
243
247
  }
244
248
  this.value = value
245
- ? observe_ValueSpecification(value, this.observableContext)
249
+ ? observe_ValueSpecification(value, this.observerContext)
246
250
  : undefined;
247
251
  }
248
252
 
@@ -33,6 +33,7 @@ import {
33
33
  INTERNAL__PropagatedValue,
34
34
  SimpleFunctionExpression,
35
35
  SUPPORTED_FUNCTIONS,
36
+ type ObserverContext,
36
37
  } from '@finos/legend-graph';
37
38
  import { Randomizer, UnsupportedOperationError } from '@finos/legend-shared';
38
39
  import { generateDefaultValueForPrimitiveType } from '../QueryBuilderValueSpecificationHelper.js';
@@ -58,6 +59,7 @@ export const createSupportedFunctionExpression = (
58
59
  const createMockPrimitiveValueSpecification = (
59
60
  primitiveType: PrimitiveType,
60
61
  propertyName: string,
62
+ observerContext: ObserverContext,
61
63
  ): ValueSpecification => {
62
64
  const primitiveTypeName = primitiveType.name;
63
65
  if (
@@ -97,7 +99,7 @@ const createMockPrimitiveValueSpecification = (
97
99
  default:
98
100
  value = `${propertyName} ${randomizer.getRandomWholeNumber(100)}`;
99
101
  }
100
- instanceValue_setValues(primitiveInstanceValue, [value]);
102
+ instanceValue_setValues(primitiveInstanceValue, [value], observerContext);
101
103
  return primitiveInstanceValue;
102
104
  };
103
105
 
@@ -110,19 +112,21 @@ export const buildPrimitiveInstanceValue = (
110
112
  graph: PureModel,
111
113
  type: PRIMITIVE_TYPE,
112
114
  value: unknown,
115
+ observerContext: ObserverContext,
113
116
  ): PrimitiveInstanceValue => {
114
117
  const instance = new PrimitiveInstanceValue(
115
118
  GenericTypeExplicitReference.create(
116
119
  new GenericType(graph.getPrimitiveType(type)),
117
120
  ),
118
121
  );
119
- instanceValue_setValues(instance, [value]);
122
+ instanceValue_setValues(instance, [value], observerContext);
120
123
  return instance;
121
124
  };
122
125
 
123
126
  export const buildDefaultInstanceValue = (
124
127
  graph: PureModel,
125
128
  type: Type,
129
+ observerContext: ObserverContext,
126
130
  ): ValueSpecification => {
127
131
  const path = type.path;
128
132
  switch (path) {
@@ -139,6 +143,7 @@ export const buildDefaultInstanceValue = (
139
143
  graph,
140
144
  path,
141
145
  generateDefaultValueForPrimitiveType(path),
146
+ observerContext,
142
147
  );
143
148
  }
144
149
  case PRIMITIVE_TYPE.DATE: {
@@ -146,6 +151,7 @@ export const buildDefaultInstanceValue = (
146
151
  graph,
147
152
  PRIMITIVE_TYPE.STRICTDATE,
148
153
  generateDefaultValueForPrimitiveType(path),
154
+ observerContext,
149
155
  );
150
156
  }
151
157
  default:
@@ -154,9 +160,11 @@ export const buildDefaultInstanceValue = (
154
160
  const enumValueInstanceValue = new EnumValueInstanceValue(
155
161
  GenericTypeExplicitReference.create(new GenericType(type)),
156
162
  );
157
- instanceValue_setValues(enumValueInstanceValue, [
158
- EnumValueExplicitReference.create(type.values[0] as Enum),
159
- ]);
163
+ instanceValue_setValues(
164
+ enumValueInstanceValue,
165
+ [EnumValueExplicitReference.create(type.values[0] as Enum)],
166
+ observerContext,
167
+ );
160
168
  return enumValueInstanceValue;
161
169
  }
162
170
  throw new UnsupportedOperationError(
@@ -172,6 +180,7 @@ export const buildDefaultInstanceValue = (
172
180
  export const generateVariableExpressionMockValue = (
173
181
  parameter: VariableExpression,
174
182
  graph: PureModel,
183
+ observerContext: ObserverContext,
175
184
  ): ValueSpecification | undefined => {
176
185
  const varType = parameter.genericType?.value.rawType;
177
186
  const multiplicity = parameter.multiplicity;
@@ -182,16 +191,22 @@ export const generateVariableExpressionMockValue = (
182
191
  );
183
192
  }
184
193
  if (varType instanceof PrimitiveType) {
185
- return createMockPrimitiveValueSpecification(varType, VAR_DEFAULT_NAME);
194
+ return createMockPrimitiveValueSpecification(
195
+ varType,
196
+ VAR_DEFAULT_NAME,
197
+ observerContext,
198
+ );
186
199
  } else if (varType instanceof Enumeration) {
187
200
  const enumValueInstance = new EnumValueInstanceValue(
188
201
  GenericTypeExplicitReference.create(new GenericType(varType)),
189
202
  );
190
203
  const mock = createMockEnumerationProperty(varType);
191
204
  if (mock !== '') {
192
- instanceValue_setValues(enumValueInstance, [
193
- EnumValueExplicitReference.create(getEnumValue(varType, mock)),
194
- ]);
205
+ instanceValue_setValues(
206
+ enumValueInstance,
207
+ [EnumValueExplicitReference.create(getEnumValue(varType, mock))],
208
+ observerContext,
209
+ );
195
210
  }
196
211
  return enumValueInstance;
197
212
  }