@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
@@ -32,6 +32,7 @@ import {
32
32
  FilledWindowMaximizeIcon,
33
33
  BasePopover,
34
34
  PanelFormSection,
35
+ CalculateIcon,
35
36
  } from '@finos/legend-art';
36
37
  import {
37
38
  type Enum,
@@ -53,6 +54,8 @@ import {
53
54
  getEnumValue,
54
55
  getMultiplicityDescription,
55
56
  type ObserverContext,
57
+ matchFunctionName,
58
+ isSubType,
56
59
  } from '@finos/legend-graph';
57
60
  import {
58
61
  type DebouncedFunc,
@@ -62,6 +65,7 @@ import {
62
65
  returnUndefOnError,
63
66
  uniq,
64
67
  parseCSVString,
68
+ guaranteeIsNumber,
65
69
  } from '@finos/legend-shared';
66
70
  import { flowResult } from 'mobx';
67
71
  import { observer } from 'mobx-react-lite';
@@ -72,6 +76,9 @@ import {
72
76
  instanceValue_setValues,
73
77
  } from '../../stores/shared/ValueSpecificationModifierHelper.js';
74
78
  import { CustomDatePicker } from './CustomDatePicker.js';
79
+ import { QUERY_BUILDER_SUPPORTED_FUNCTIONS } from '../../graphManager/QueryBuilderSupportedFunctions.js';
80
+ import { simplifyValueExpression } from '../../stores/QueryBuilderValueSpecificationHelper.js';
81
+ import { evaluate } from 'mathjs';
75
82
 
76
83
  type TypeCheckOption = {
77
84
  expectedType: Type;
@@ -210,6 +217,7 @@ const StringPrimitiveInstanceValueEditor = observer(
210
217
  cleanUpReloadValues?: () => void;
211
218
  }
212
219
  | undefined;
220
+ obseverContext: ObserverContext;
213
221
  }) => {
214
222
  const {
215
223
  valueSpecification,
@@ -217,12 +225,13 @@ const StringPrimitiveInstanceValueEditor = observer(
217
225
  resetValue,
218
226
  setValueSpecification,
219
227
  selectorConfig,
228
+ obseverContext,
220
229
  } = props;
221
230
  const useSelector = Boolean(selectorConfig);
222
231
  const applicationStore = useApplicationStore();
223
232
  const value = valueSpecification.values[0] as string;
224
233
  const updateValueSpec = (val: string): void => {
225
- instanceValue_setValue(valueSpecification, val, 0);
234
+ instanceValue_setValue(valueSpecification, val, 0, obseverContext);
226
235
  setValueSpecification(valueSpecification);
227
236
  };
228
237
  const changeInputValue: React.ChangeEventHandler<HTMLInputElement> = (
@@ -316,12 +325,18 @@ const BooleanPrimitiveInstanceValueEditor = observer(
316
325
  className?: string | undefined;
317
326
  resetValue: () => void;
318
327
  setValueSpecification: (val: ValueSpecification) => void;
328
+ obseverContext: ObserverContext;
319
329
  }) => {
320
- const { valueSpecification, className, resetValue, setValueSpecification } =
321
- props;
330
+ const {
331
+ valueSpecification,
332
+ className,
333
+ resetValue,
334
+ setValueSpecification,
335
+ obseverContext,
336
+ } = props;
322
337
  const value = valueSpecification.values[0] as boolean;
323
338
  const toggleValue = (): void => {
324
- instanceValue_setValue(valueSpecification, !value, 0);
339
+ instanceValue_setValue(valueSpecification, !value, 0, obseverContext);
325
340
  setValueSpecification(valueSpecification);
326
341
  };
327
342
 
@@ -354,6 +369,7 @@ const NumberPrimitiveInstanceValueEditor = observer(
354
369
  className?: string | undefined;
355
370
  resetValue: () => void;
356
371
  setValueSpecification: (val: ValueSpecification) => void;
372
+ obseverContext: ObserverContext;
357
373
  }) => {
358
374
  const {
359
375
  valueSpecification,
@@ -361,26 +377,95 @@ const NumberPrimitiveInstanceValueEditor = observer(
361
377
  className,
362
378
  resetValue,
363
379
  setValueSpecification,
380
+ obseverContext,
364
381
  } = props;
365
- const value = valueSpecification.values[0] as number;
382
+ const [value, setValue] = useState(
383
+ (valueSpecification.values[0] as number).toString(),
384
+ );
385
+ const inputRef = useRef<HTMLInputElement>(null);
386
+ const numericValue = isInteger
387
+ ? Number.parseInt(Number(value).toString(), 10)
388
+ : Number(value);
389
+
366
390
  const changeValue: React.ChangeEventHandler<HTMLInputElement> = (event) => {
367
- let inputVal = isInteger
368
- ? parseInt(event.target.value, 10)
369
- : parseFloat(event.target.value);
370
- inputVal = isNaN(inputVal) ? 0 : inputVal;
371
- instanceValue_setValue(valueSpecification, inputVal, 0);
372
- setValueSpecification(valueSpecification);
391
+ setValue(event.target.value);
373
392
  };
374
393
 
394
+ // Support expression evaluation
395
+ const calculateExpression = (): void => {
396
+ if (isNaN(numericValue)) {
397
+ try {
398
+ const calculatedValue = guaranteeIsNumber(evaluate(value));
399
+ setValue(
400
+ isInteger
401
+ ? Number.parseInt(calculatedValue.toString(), 10).toString()
402
+ : Number(calculatedValue).toString(),
403
+ );
404
+ } catch {
405
+ setValue((valueSpecification.values[0] as number).toString());
406
+ }
407
+ } else {
408
+ setValue(numericValue.toString());
409
+ }
410
+ };
411
+
412
+ const onKeyDown: React.KeyboardEventHandler<HTMLInputElement> = (event) => {
413
+ if (event.code === 'Enter') {
414
+ calculateExpression();
415
+ inputRef.current?.focus();
416
+ } else if (event.code === 'Escape') {
417
+ inputRef.current?.select();
418
+ }
419
+ };
420
+
421
+ useEffect(() => {
422
+ setValue((valueSpecification.values[0] as number).toString());
423
+ }, [valueSpecification]);
424
+
425
+ useEffect(() => {
426
+ if (
427
+ !isNaN(numericValue) &&
428
+ numericValue !== valueSpecification.values[0]
429
+ ) {
430
+ instanceValue_setValue(
431
+ valueSpecification,
432
+ numericValue,
433
+ 0,
434
+ obseverContext,
435
+ );
436
+ setValueSpecification(valueSpecification);
437
+ }
438
+ }, [
439
+ numericValue,
440
+ valueSpecification,
441
+ setValueSpecification,
442
+ obseverContext,
443
+ ]);
444
+
375
445
  return (
376
446
  <div className={clsx('value-spec-editor', className)}>
377
- <input
378
- className="panel__content__form__section__input value-spec-editor__input"
379
- spellCheck={false}
380
- type="number"
381
- value={value}
382
- onChange={changeValue}
383
- />
447
+ <div className="value-spec-editor__number__input-container">
448
+ <input
449
+ ref={inputRef}
450
+ className="panel__content__form__section__input value-spec-editor__input value-spec-editor__number__input"
451
+ spellCheck={false}
452
+ type="text" // NOTE: we leave this as text so that we can support expression evaluation
453
+ inputMode="numeric"
454
+ value={value}
455
+ onChange={changeValue}
456
+ onBlur={calculateExpression}
457
+ onKeyDown={onKeyDown}
458
+ />
459
+ <div className="value-spec-editor__number__actions">
460
+ <button
461
+ className="value-spec-editor__number__action"
462
+ title="Evaluate Expression (Enter)"
463
+ onClick={calculateExpression}
464
+ >
465
+ <CalculateIcon />
466
+ </button>
467
+ </div>
468
+ </div>
384
469
  <button
385
470
  className="value-spec-editor__reset-btn"
386
471
  title="Reset"
@@ -399,9 +484,15 @@ const EnumValueInstanceValueEditor = observer(
399
484
  className?: string | undefined;
400
485
  setValueSpecification: (val: ValueSpecification) => void;
401
486
  resetValue: () => void;
487
+ obseverContext: ObserverContext;
402
488
  }) => {
403
- const { valueSpecification, className, resetValue, setValueSpecification } =
404
- props;
489
+ const {
490
+ valueSpecification,
491
+ className,
492
+ resetValue,
493
+ setValueSpecification,
494
+ obseverContext,
495
+ } = props;
405
496
  const enumValueRef = guaranteeNonNullable(valueSpecification.values[0]);
406
497
  const enumValue = enumValueRef.value;
407
498
  const options = enumValue._OWNER.values.map((value) => ({
@@ -413,6 +504,7 @@ const EnumValueInstanceValueEditor = observer(
413
504
  valueSpecification,
414
505
  EnumValueExplicitReference.create(val.value),
415
506
  0,
507
+ obseverContext,
416
508
  );
417
509
  setValueSpecification(valueSpecification);
418
510
  };
@@ -466,9 +558,10 @@ const setCollectionValue = (
466
558
  valueSpecification: CollectionInstanceValue,
467
559
  expectedType: Type,
468
560
  value: string,
561
+ obseverContext: ObserverContext,
469
562
  ): void => {
470
563
  if (value.trim().length === 0) {
471
- instanceValue_setValues(valueSpecification, []);
564
+ instanceValue_setValues(valueSpecification, [], obseverContext);
472
565
  return;
473
566
  }
474
567
  let result: unknown[] = [];
@@ -489,7 +582,11 @@ const setCollectionValue = (
489
582
  new GenericType(expectedType),
490
583
  ),
491
584
  );
492
- instanceValue_setValues(primitiveInstanceValue, [item.toString()]);
585
+ instanceValue_setValues(
586
+ primitiveInstanceValue,
587
+ [item.toString()],
588
+ obseverContext,
589
+ );
493
590
  return primitiveInstanceValue;
494
591
  })
495
592
  .filter(isNonNullable);
@@ -510,7 +607,11 @@ const setCollectionValue = (
510
607
  new GenericType(expectedType),
511
608
  ),
512
609
  );
513
- instanceValue_setValues(primitiveInstanceValue, [item]);
610
+ instanceValue_setValues(
611
+ primitiveInstanceValue,
612
+ [item],
613
+ obseverContext,
614
+ );
514
615
  return primitiveInstanceValue;
515
616
  })
516
617
  .filter(isNonNullable);
@@ -532,14 +633,16 @@ const setCollectionValue = (
532
633
  const enumValueInstanceValue = new EnumValueInstanceValue(
533
634
  GenericTypeExplicitReference.create(new GenericType(expectedType)),
534
635
  );
535
- instanceValue_setValues(enumValueInstanceValue, [
536
- EnumValueExplicitReference.create(_enum),
537
- ]);
636
+ instanceValue_setValues(
637
+ enumValueInstanceValue,
638
+ [EnumValueExplicitReference.create(_enum)],
639
+ obseverContext,
640
+ );
538
641
  return enumValueInstanceValue;
539
642
  })
540
643
  .filter(isNonNullable);
541
644
  }
542
- instanceValue_setValues(valueSpecification, result);
645
+ instanceValue_setValues(valueSpecification, result, obseverContext);
543
646
  };
544
647
 
545
648
  const COLLECTION_PREVIEW_CHAR_LIMIT = 50;
@@ -552,6 +655,7 @@ const CollectionValueInstanceValueEditor = observer(
552
655
  className?: string | undefined;
553
656
  resetValue: () => void;
554
657
  setValueSpecification: (val: ValueSpecification) => void;
658
+ obseverContext: ObserverContext;
555
659
  }) => {
556
660
  const {
557
661
  valueSpecification,
@@ -559,6 +663,7 @@ const CollectionValueInstanceValueEditor = observer(
559
663
  className,
560
664
  resetValue,
561
665
  setValueSpecification,
666
+ obseverContext,
562
667
  } = props;
563
668
  const inputRef = useRef<HTMLInputElement>(null);
564
669
  const [text, setText] = useState(stringifyValue(valueSpecification.values));
@@ -583,7 +688,12 @@ const CollectionValueInstanceValueEditor = observer(
583
688
  const saveEdit = (): void => {
584
689
  setEditable(false);
585
690
  setShowAdvancedEditorPopover(false);
586
- setCollectionValue(valueSpecification, expectedType, text);
691
+ setCollectionValue(
692
+ valueSpecification,
693
+ expectedType,
694
+ text,
695
+ obseverContext,
696
+ );
587
697
  setText(stringifyValue(valueSpecification.values));
588
698
  setValueSpecification(valueSpecification);
589
699
  };
@@ -779,6 +889,7 @@ export const BasicValueSpecificationEditor: React.FC<{
779
889
  className={className}
780
890
  resetValue={resetValue}
781
891
  selectorConfig={selectorConfig}
892
+ obseverContext={obseverContext}
782
893
  />
783
894
  );
784
895
  case PRIMITIVE_TYPE.BOOLEAN:
@@ -788,6 +899,7 @@ export const BasicValueSpecificationEditor: React.FC<{
788
899
  setValueSpecification={setValueSpecification}
789
900
  className={className}
790
901
  resetValue={resetValue}
902
+ obseverContext={obseverContext}
791
903
  />
792
904
  );
793
905
  case PRIMITIVE_TYPE.NUMBER:
@@ -802,6 +914,7 @@ export const BasicValueSpecificationEditor: React.FC<{
802
914
  setValueSpecification={setValueSpecification}
803
915
  className={className}
804
916
  resetValue={resetValue}
917
+ obseverContext={obseverContext}
805
918
  />
806
919
  );
807
920
  case PRIMITIVE_TYPE.DATE:
@@ -829,6 +942,7 @@ export const BasicValueSpecificationEditor: React.FC<{
829
942
  className={className}
830
943
  resetValue={resetValue}
831
944
  setValueSpecification={setValueSpecification}
945
+ obseverContext={obseverContext}
832
946
  />
833
947
  );
834
948
  } else if (
@@ -846,6 +960,7 @@ export const BasicValueSpecificationEditor: React.FC<{
846
960
  className={className}
847
961
  resetValue={resetValue}
848
962
  setValueSpecification={setValueSpecification}
963
+ obseverContext={obseverContext}
849
964
  />
850
965
  );
851
966
  }
@@ -870,26 +985,55 @@ export const BasicValueSpecificationEditor: React.FC<{
870
985
  resetValue={resetValue}
871
986
  />
872
987
  );
873
- } else if (
874
- valueSpecification instanceof SimpleFunctionExpression &&
875
- [
876
- PRIMITIVE_TYPE.DATE.toString(),
877
- PRIMITIVE_TYPE.STRICTDATE.toString(),
878
- PRIMITIVE_TYPE.DATETIME.toString(),
879
- PRIMITIVE_TYPE.LATESTDATE.toString(),
880
- ].includes(typeCheckOption.expectedType.path)
881
- ) {
882
- return (
883
- <DateInstanceValueEditor
884
- valueSpecification={valueSpecification}
885
- graph={graph}
886
- obseverContext={obseverContext}
887
- typeCheckOption={typeCheckOption}
888
- className={className}
889
- setValueSpecification={setValueSpecification}
890
- resetValue={resetValue}
891
- />
892
- );
988
+ } else if (valueSpecification instanceof SimpleFunctionExpression) {
989
+ if (isSubType(typeCheckOption.expectedType, PrimitiveType.DATE)) {
990
+ return (
991
+ <DateInstanceValueEditor
992
+ valueSpecification={valueSpecification}
993
+ graph={graph}
994
+ obseverContext={obseverContext}
995
+ typeCheckOption={typeCheckOption}
996
+ className={className}
997
+ setValueSpecification={setValueSpecification}
998
+ resetValue={resetValue}
999
+ />
1000
+ );
1001
+ } else if (
1002
+ // TODO: think of other ways we could make use of this code path where we can simplify
1003
+ // an expression value to simple value, not just handling minus() function only
1004
+ isSubType(typeCheckOption.expectedType, PrimitiveType.NUMBER) &&
1005
+ matchFunctionName(
1006
+ valueSpecification.functionName,
1007
+ QUERY_BUILDER_SUPPORTED_FUNCTIONS.MINUS,
1008
+ )
1009
+ ) {
1010
+ const simplifiedValue = simplifyValueExpression(
1011
+ valueSpecification,
1012
+ obseverContext,
1013
+ );
1014
+ if (
1015
+ simplifiedValue instanceof PrimitiveInstanceValue &&
1016
+ isSubType(
1017
+ simplifiedValue.genericType.value.rawType,
1018
+ PrimitiveType.NUMBER,
1019
+ )
1020
+ ) {
1021
+ return (
1022
+ <NumberPrimitiveInstanceValueEditor
1023
+ valueSpecification={simplifiedValue}
1024
+ isInteger={
1025
+ simplifiedValue.genericType.value.rawType ===
1026
+ PrimitiveType.INTEGER
1027
+ }
1028
+ setValueSpecification={setValueSpecification}
1029
+ className={className}
1030
+ resetValue={resetValue}
1031
+ obseverContext={obseverContext}
1032
+ />
1033
+ );
1034
+ }
1035
+ }
893
1036
  }
1037
+
894
1038
  return <UnsupportedValueSpecificationEditor />;
895
1039
  };
@@ -258,16 +258,20 @@ const buildPureDateFunctionExpression = (
258
258
  new GenericType(graph.getType(DAY_OF_WEEK)),
259
259
  ),
260
260
  );
261
- instanceValue_setValues(dayOfWeekEnumIntanceValue, [
262
- ...dayOfWeekEnumIntanceValue.values,
263
- EnumValueExplicitReference.create(
264
- guaranteeNonNullable(
265
- graph
266
- .getEnumeration(DAY_OF_WEEK)
267
- .values.filter((e) => e.name === datePickerOption.day)[0],
261
+ instanceValue_setValues(
262
+ dayOfWeekEnumIntanceValue,
263
+ [
264
+ ...dayOfWeekEnumIntanceValue.values,
265
+ EnumValueExplicitReference.create(
266
+ guaranteeNonNullable(
267
+ graph
268
+ .getEnumeration(DAY_OF_WEEK)
269
+ .values.filter((e) => e.name === datePickerOption.day)[0],
270
+ ),
268
271
  ),
269
- ),
270
- ]);
272
+ ],
273
+ observerContext,
274
+ );
271
275
  functionExpression_addParameterValue(
272
276
  previousFridaySFE,
273
277
  dayOfWeekEnumIntanceValue,
@@ -454,6 +458,7 @@ const buildPureAdjustDateFunction = (
454
458
  graph,
455
459
  PRIMITIVE_TYPE.INTEGER,
456
460
  customDateOption.duration,
461
+ observerContext,
457
462
  ),
458
463
  observerContext,
459
464
  );
@@ -463,14 +468,14 @@ const buildPureAdjustDateFunction = (
463
468
  observerContext,
464
469
  );
465
470
  } else {
466
- const adjustmentInstanceValue = buildPrimitiveInstanceValue(
467
- graph,
468
- PRIMITIVE_TYPE.INTEGER,
469
- customDateOption.duration,
470
- );
471
471
  functionExpression_addParameterValue(
472
472
  dateAdjustSimpleFunctionExpression,
473
- adjustmentInstanceValue,
473
+ buildPrimitiveInstanceValue(
474
+ graph,
475
+ PRIMITIVE_TYPE.INTEGER,
476
+ customDateOption.duration,
477
+ observerContext,
478
+ ),
474
479
  observerContext,
475
480
  );
476
481
  }
@@ -479,17 +484,21 @@ const buildPureAdjustDateFunction = (
479
484
  new GenericType(graph.getType(DURATION_UNIT)),
480
485
  ),
481
486
  );
482
- instanceValue_setValues(durationUnitEnumIntanceValue, [
483
- ...durationUnitEnumIntanceValue.values,
484
- EnumValueExplicitReference.create(
485
- guaranteeNonNullable(
486
- buildPureDurationEnumValue(
487
- guaranteeNonNullable(customDateOption.unit),
488
- graph,
487
+ instanceValue_setValues(
488
+ durationUnitEnumIntanceValue,
489
+ [
490
+ ...durationUnitEnumIntanceValue.values,
491
+ EnumValueExplicitReference.create(
492
+ guaranteeNonNullable(
493
+ buildPureDurationEnumValue(
494
+ guaranteeNonNullable(customDateOption.unit),
495
+ graph,
496
+ ),
489
497
  ),
490
498
  ),
491
- ),
492
- ]);
499
+ ],
500
+ observerContext,
501
+ );
493
502
  functionExpression_addParameterValue(
494
503
  dateAdjustSimpleFunctionExpression,
495
504
  durationUnitEnumIntanceValue,
@@ -699,12 +708,14 @@ const AbsoluteDateValueSpecificationEditor: React.FC<{
699
708
  graph: PureModel;
700
709
  setValueSpecification: (val: ValueSpecification) => void;
701
710
  setDatePickerOption: (datePickerOption: DatePickerOption) => void;
711
+ observerContext: ObserverContext;
702
712
  }> = (props) => {
703
713
  const {
704
714
  valueSpecification,
705
715
  graph,
706
716
  setValueSpecification,
707
717
  setDatePickerOption,
718
+ observerContext,
708
719
  } = props;
709
720
  const inputRef = useRef<HTMLInputElement>(null);
710
721
  const absoluteDateValue =
@@ -720,10 +731,16 @@ const AbsoluteDateValueSpecificationEditor: React.FC<{
720
731
  graph,
721
732
  PRIMITIVE_TYPE.STRICTDATE,
722
733
  event.target.value,
734
+ observerContext,
723
735
  ),
724
736
  );
725
737
  } else if (valueSpecification instanceof InstanceValue) {
726
- instanceValue_setValue(valueSpecification, event.target.value, 0);
738
+ instanceValue_setValue(
739
+ valueSpecification,
740
+ event.target.value,
741
+ 0,
742
+ observerContext,
743
+ );
727
744
  if (
728
745
  valueSpecification.genericType.value.rawType.path !==
729
746
  PRIMITIVE_TYPE.STRICTDATE
@@ -768,12 +785,14 @@ const AbsoluteTimeValueSpecificationEditor: React.FC<{
768
785
  graph: PureModel;
769
786
  setValueSpecification: (val: ValueSpecification) => void;
770
787
  setDatePickerOption: (datePickerOption: DatePickerOption) => void;
788
+ observerContext: ObserverContext;
771
789
  }> = (props) => {
772
790
  const {
773
791
  valueSpecification,
774
792
  graph,
775
793
  setValueSpecification,
776
794
  setDatePickerOption,
795
+ observerContext,
777
796
  } = props;
778
797
  const inputRef = useRef<HTMLInputElement>(null);
779
798
  const absoluteTimeValue =
@@ -789,10 +808,16 @@ const AbsoluteTimeValueSpecificationEditor: React.FC<{
789
808
  graph,
790
809
  PRIMITIVE_TYPE.DATETIME,
791
810
  event.target.value,
811
+ observerContext,
792
812
  ),
793
813
  );
794
814
  } else {
795
- instanceValue_setValue(valueSpecification, event.target.value, 0);
815
+ instanceValue_setValue(
816
+ valueSpecification,
817
+ event.target.value,
818
+ 0,
819
+ observerContext,
820
+ );
796
821
  if (
797
822
  valueSpecification.genericType.value.rawType.path !==
798
823
  PRIMITIVE_TYPE.DATETIME
@@ -1213,6 +1238,7 @@ export const CustomDatePicker: React.FC<{
1213
1238
  graph,
1214
1239
  PRIMITIVE_TYPE.LATESTDATE,
1215
1240
  event.target.value,
1241
+ observerContext,
1216
1242
  ),
1217
1243
  );
1218
1244
  } else if (
@@ -1255,6 +1281,7 @@ export const CustomDatePicker: React.FC<{
1255
1281
  valueSpecification={valueSpecification}
1256
1282
  setValueSpecification={setValueSpecification}
1257
1283
  setDatePickerOption={setDatePickerOption}
1284
+ observerContext={observerContext}
1258
1285
  />
1259
1286
  );
1260
1287
  case CUSTOM_DATE_PICKER_OPTION.ABSOLUTE_TIME:
@@ -1264,6 +1291,7 @@ export const CustomDatePicker: React.FC<{
1264
1291
  valueSpecification={valueSpecification}
1265
1292
  setValueSpecification={setValueSpecification}
1266
1293
  setDatePickerOption={setDatePickerOption}
1294
+ observerContext={observerContext}
1267
1295
  />
1268
1296
  );
1269
1297
  case CUSTOM_DATE_PICKER_OPTION.CUSTOM_DATE:
@@ -584,7 +584,6 @@ const LambdaEditorPopUp = observer(
584
584
  >
585
585
  <Modal
586
586
  darkMode={true}
587
- data-testid={QUERY_BUILDER_TEST_ID.LAMBDA_EDITOR__EDITOR_INPUT}
588
587
  className={clsx(
589
588
  'editor-modal lambda-editor__popup__modal',
590
589
  {
@@ -106,9 +106,7 @@ const WatermarkValueEditor = observer(
106
106
  watermarkState.setValue(val);
107
107
  }}
108
108
  graph={graph}
109
- obseverContext={
110
- watermarkState.queryBuilderState.observableContext
111
- }
109
+ obseverContext={watermarkState.queryBuilderState.observerContext}
112
110
  typeCheckOption={{
113
111
  expectedType: PrimitiveType.STRING,
114
112
  }}
@@ -24,6 +24,7 @@ export enum QUERY_BUILDER_SUPPORTED_FUNCTIONS {
24
24
  OR = 'meta::pure::functions::boolean::or',
25
25
  TAKE = 'meta::pure::functions::collection::take',
26
26
  SUBTYPE = 'meta::pure::functions::lang::subType',
27
+ MINUS = 'meta::pure::functions::math::minus',
27
28
 
28
29
  // graph-fetch
29
30
  GRAPH_FETCH = 'meta::pure::graphFetch::execution::graphFetch',
@@ -53,6 +54,7 @@ export enum QUERY_BUILDER_SUPPORTED_FUNCTIONS {
53
54
  LESS_THAN = 'meta::pure::functions::lang::tests::lessThan',
54
55
  LESS_THAN_EQUAL = 'meta::pure::functions::lang::tests::lessThanEqual',
55
56
  STARTS_WITH = 'meta::pure::functions::string::startsWith',
57
+
56
58
  // aggregation
57
59
  AVERAGE = 'meta::pure::functions::math::average',
58
60
  COUNT = 'meta::pure::functions::collection::count',
@@ -66,8 +68,10 @@ export enum QUERY_BUILDER_SUPPORTED_FUNCTIONS {
66
68
  STD_DEV_SAMPLE = 'meta::pure::functions::math::stdDevSample',
67
69
  SUM = 'meta::pure::functions::math::sum',
68
70
  UNIQUE_VALUE_ONLY = 'meta::pure::functions::collection::uniqueValueOnly',
71
+
69
72
  // watermark
70
73
  WATERMARK = 'meta::datalake::functions::forWatermark',
74
+
71
75
  // OLAP
72
76
  OLAP_GROUPBY = 'meta::pure::tds::olapGroupBy',
73
77
  OLAP_RANK = 'meta::pure::functions::math::olap::rank',
@@ -57,7 +57,7 @@ export class QueryBuilder_PureProtocolProcessorPlugin extends PureProtocolProces
57
57
  openVariables: string[],
58
58
  compileContext: V1_GraphBuilderContext,
59
59
  processingContext: V1_ProcessingContext,
60
- ): [SimpleFunctionExpression, ValueSpecification[]] | undefined => {
60
+ ): SimpleFunctionExpression | undefined => {
61
61
  if (
62
62
  matchFunctionName(
63
63
  functionName,