@finos/legend-query-builder 4.13.9 → 4.13.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (56) hide show
  1. package/lib/__lib__/QueryBuilderTesting.d.ts +1 -0
  2. package/lib/__lib__/QueryBuilderTesting.d.ts.map +1 -1
  3. package/lib/__lib__/QueryBuilderTesting.js +1 -0
  4. package/lib/__lib__/QueryBuilderTesting.js.map +1 -1
  5. package/lib/components/explorer/QueryBuilderExplorerPanel.d.ts.map +1 -1
  6. package/lib/components/explorer/QueryBuilderExplorerPanel.js +2 -2
  7. package/lib/components/explorer/QueryBuilderExplorerPanel.js.map +1 -1
  8. package/lib/components/filter/QueryBuilderFilterPanel.d.ts.map +1 -1
  9. package/lib/components/filter/QueryBuilderFilterPanel.js +1 -1
  10. package/lib/components/filter/QueryBuilderFilterPanel.js.map +1 -1
  11. package/lib/components/result/QueryBuilderResultPanel.d.ts.map +1 -1
  12. package/lib/components/result/QueryBuilderResultPanel.js +3 -3
  13. package/lib/components/result/QueryBuilderResultPanel.js.map +1 -1
  14. package/lib/components/result/tds/QueryBuilderTDSResultShared.d.ts +1 -1
  15. package/lib/components/result/tds/QueryBuilderTDSResultShared.d.ts.map +1 -1
  16. package/lib/components/result/tds/QueryBuilderTDSResultShared.js +3 -2
  17. package/lib/components/result/tds/QueryBuilderTDSResultShared.js.map +1 -1
  18. package/lib/components/shared/BasicValueSpecificationEditor.d.ts.map +1 -1
  19. package/lib/components/shared/BasicValueSpecificationEditor.js +7 -1
  20. package/lib/components/shared/BasicValueSpecificationEditor.js.map +1 -1
  21. package/lib/components/shared/CustomDatePicker.js +14 -14
  22. package/lib/components/shared/CustomDatePicker.js.map +1 -1
  23. package/lib/components/shared/QueryBuilderPropertyInfoTooltip.d.ts +4 -1
  24. package/lib/components/shared/QueryBuilderPropertyInfoTooltip.d.ts.map +1 -1
  25. package/lib/components/shared/QueryBuilderPropertyInfoTooltip.js +24 -7
  26. package/lib/components/shared/QueryBuilderPropertyInfoTooltip.js.map +1 -1
  27. package/lib/components/shared/QueryBuilderRootClassInfoTooltip.d.ts.map +1 -1
  28. package/lib/components/shared/QueryBuilderRootClassInfoTooltip.js +3 -7
  29. package/lib/components/shared/QueryBuilderRootClassInfoTooltip.js.map +1 -1
  30. package/lib/graph/QueryBuilderMetaModelConst.d.ts +4 -2
  31. package/lib/graph/QueryBuilderMetaModelConst.d.ts.map +1 -1
  32. package/lib/graph/QueryBuilderMetaModelConst.js +4 -2
  33. package/lib/graph/QueryBuilderMetaModelConst.js.map +1 -1
  34. package/lib/graph-manager/protocol/pure/QueryBuilder_PureProtocolProcessorPlugin.d.ts.map +1 -1
  35. package/lib/graph-manager/protocol/pure/QueryBuilder_PureProtocolProcessorPlugin.js +2 -0
  36. package/lib/graph-manager/protocol/pure/QueryBuilder_PureProtocolProcessorPlugin.js.map +1 -1
  37. package/lib/index.css +2 -2
  38. package/lib/index.css.map +1 -1
  39. package/lib/package.json +1 -1
  40. package/lib/stores/QueryBuilderStateBuilder.d.ts +2 -1
  41. package/lib/stores/QueryBuilderStateBuilder.d.ts.map +1 -1
  42. package/lib/stores/QueryBuilderStateBuilder.js +28 -1
  43. package/lib/stores/QueryBuilderStateBuilder.js.map +1 -1
  44. package/package.json +8 -8
  45. package/src/__lib__/QueryBuilderTesting.ts +1 -0
  46. package/src/components/explorer/QueryBuilderExplorerPanel.tsx +7 -1
  47. package/src/components/filter/QueryBuilderFilterPanel.tsx +3 -0
  48. package/src/components/result/QueryBuilderResultPanel.tsx +3 -6
  49. package/src/components/result/tds/QueryBuilderTDSResultShared.tsx +3 -1
  50. package/src/components/shared/BasicValueSpecificationEditor.tsx +16 -11
  51. package/src/components/shared/CustomDatePicker.tsx +15 -15
  52. package/src/components/shared/QueryBuilderPropertyInfoTooltip.tsx +91 -20
  53. package/src/components/shared/QueryBuilderRootClassInfoTooltip.tsx +5 -20
  54. package/src/graph/QueryBuilderMetaModelConst.ts +4 -2
  55. package/src/graph-manager/protocol/pure/QueryBuilder_PureProtocolProcessorPlugin.ts +2 -0
  56. package/src/stores/QueryBuilderStateBuilder.ts +54 -12
@@ -17,12 +17,99 @@
17
17
  import { type TooltipPlacement, Tooltip } from '@finos/legend-art';
18
18
  import {
19
19
  type AbstractProperty,
20
+ type Type,
21
+ type TaggedValue,
20
22
  DerivedProperty,
21
23
  getMultiplicityDescription,
22
24
  CORE_PURE_PATH,
23
25
  PURE_DOC_TAG,
24
- type Type,
25
26
  } from '@finos/legend-graph';
27
+ import { useState } from 'react';
28
+
29
+ export const QueryBuilderTaggedValueInfoTooltip: React.FC<{
30
+ taggedValues: TaggedValue[];
31
+ }> = (props) => {
32
+ const { taggedValues } = props;
33
+ const [showMore, setShowMore] = useState(false);
34
+ const toggleShowMoreButton: React.MouseEventHandler = (event) => {
35
+ event.stopPropagation();
36
+ setShowMore(!showMore);
37
+ };
38
+ const isDocTaggedValue = (val: TaggedValue): boolean =>
39
+ val.tag.ownerReference.value.path === CORE_PURE_PATH.PROFILE_DOC &&
40
+ val.tag.value.value === PURE_DOC_TAG;
41
+ const documentation = taggedValues
42
+ .filter((taggedValue) => isDocTaggedValue(taggedValue))
43
+ .map((taggedValue) => taggedValue.value);
44
+ const tagValuesExceptDoc = taggedValues.filter(
45
+ (taggedValue) => !isDocTaggedValue(taggedValue),
46
+ );
47
+
48
+ const taggedValueCellRender = (taggedValue: TaggedValue): React.ReactNode => (
49
+ <div
50
+ className="query-builder__tooltip__item"
51
+ key={`${taggedValue.tag.ownerReference.value.name}.${taggedValue.value}`}
52
+ >
53
+ <div className="query-builder__tooltip__item__label">
54
+ {`${taggedValue.tag.ownerReference.value.name}.${taggedValue.tag.value.value}`}
55
+ </div>
56
+ <div className="query-builder__tooltip__item__value">
57
+ {taggedValue.value}
58
+ </div>
59
+ </div>
60
+ );
61
+
62
+ return (
63
+ <div>
64
+ {tagValuesExceptDoc.length > 0 ? (
65
+ <div className="query-builder__tooltip__item">
66
+ <div className="query-builder__tooltip__item__label">
67
+ Tagged Values
68
+ </div>
69
+ <div className="query-builder__tooltip__taggedValues">
70
+ {taggedValues.slice(0, 1).map((taggedValue) => (
71
+ <div
72
+ className="query-builder__tooltip__combo"
73
+ key={`${taggedValue.tag.ownerReference.value.name}.${taggedValue.value}`}
74
+ >
75
+ {taggedValueCellRender(taggedValue)}
76
+ {taggedValues.length > 3 && (
77
+ <button
78
+ className="btn btn--dark query-builder__tooltip__taggedValues__show-btn"
79
+ onClick={toggleShowMoreButton}
80
+ title="Toggle button to show more/less"
81
+ >
82
+ {showMore ? 'Show Less' : 'Show More'}
83
+ </button>
84
+ )}
85
+ </div>
86
+ ))}
87
+ {taggedValues
88
+ .slice(1, 3)
89
+ .map((taggedValue) => taggedValueCellRender(taggedValue))}
90
+ {showMore &&
91
+ taggedValues
92
+ .slice(3)
93
+ .map((taggedValue) => taggedValueCellRender(taggedValue))}
94
+ </div>
95
+ </div>
96
+ ) : (
97
+ <>
98
+ {Boolean(documentation.length) && (
99
+ <div className="query-builder__tooltip__item">
100
+ <div className="query-builder__tooltip__item__label">
101
+ Documentation
102
+ </div>
103
+ <div className="query-builder__tooltip__item__value">
104
+ {documentation.join('\n\n')}
105
+ </div>
106
+ </div>
107
+ )}
108
+ </>
109
+ )}
110
+ </div>
111
+ );
112
+ };
26
113
 
27
114
  export const QueryBuilderPropertyInfoTooltip: React.FC<{
28
115
  property: AbstractProperty;
@@ -33,14 +120,6 @@ export const QueryBuilderPropertyInfoTooltip: React.FC<{
33
120
  type?: Type | undefined;
34
121
  }> = (props) => {
35
122
  const { property, path, isMapped, children, placement, type } = props;
36
- const documentation = property.taggedValues
37
- .filter(
38
- (taggedValue) =>
39
- taggedValue.tag.ownerReference.value.path ===
40
- CORE_PURE_PATH.PROFILE_DOC &&
41
- taggedValue.tag.value.value === PURE_DOC_TAG,
42
- )
43
- .map((taggedValue) => taggedValue.value);
44
123
 
45
124
  return (
46
125
  <Tooltip
@@ -91,17 +170,9 @@ export const QueryBuilderPropertyInfoTooltip: React.FC<{
91
170
  {isMapped ? 'Yes' : 'No'}
92
171
  </div>
93
172
  </div>
94
-
95
- {Boolean(documentation.length) && (
96
- <div className="query-builder__tooltip__item">
97
- <div className="query-builder__tooltip__item__label">
98
- Documentation
99
- </div>
100
- <div className="query-builder__tooltip__item__value">
101
- {documentation.join('\n\n')}
102
- </div>
103
- </div>
104
- )}
173
+ <QueryBuilderTaggedValueInfoTooltip
174
+ taggedValues={property.taggedValues}
175
+ />
105
176
  </div>
106
177
  }
107
178
  >
@@ -15,7 +15,8 @@
15
15
  */
16
16
 
17
17
  import { type TooltipPlacement, Tooltip } from '@finos/legend-art';
18
- import { CORE_PURE_PATH, PURE_DOC_TAG, type Class } from '@finos/legend-graph';
18
+ import { type Class } from '@finos/legend-graph';
19
+ import { QueryBuilderTaggedValueInfoTooltip } from './QueryBuilderPropertyInfoTooltip.js';
19
20
 
20
21
  export const QueryBuilderRootClassInfoTooltip: React.FC<{
21
22
  _class: Class;
@@ -23,14 +24,6 @@ export const QueryBuilderRootClassInfoTooltip: React.FC<{
23
24
  placement?: TooltipPlacement | undefined;
24
25
  }> = (props) => {
25
26
  const { _class, children, placement } = props;
26
- const documentation = _class.taggedValues
27
- .filter(
28
- (taggedValue) =>
29
- taggedValue.tag.ownerReference.value.path ===
30
- CORE_PURE_PATH.PROFILE_DOC &&
31
- taggedValue.tag.value.value === PURE_DOC_TAG,
32
- )
33
- .map((taggedValue) => taggedValue.value);
34
27
 
35
28
  return (
36
29
  <Tooltip
@@ -59,17 +52,9 @@ export const QueryBuilderRootClassInfoTooltip: React.FC<{
59
52
  {_class.path}
60
53
  </div>
61
54
  </div>
62
-
63
- {Boolean(documentation.length) && (
64
- <div className="query-builder__tooltip__item">
65
- <div className="query-builder__tooltip__item__label">
66
- Documentation
67
- </div>
68
- <div className="query-builder__tooltip__item__value">
69
- {documentation.join('\n\n')}
70
- </div>
71
- </div>
72
- )}
55
+ <QueryBuilderTaggedValueInfoTooltip
56
+ taggedValues={_class.taggedValues}
57
+ />
73
58
  </div>
74
59
  }
75
60
  >
@@ -83,9 +83,11 @@ export enum QUERY_BUILDER_SUPPORTED_FUNCTIONS {
83
83
  TODAY = 'meta::pure::functions::date::today',
84
84
  NOW = 'meta::pure::functions::date::now',
85
85
  FIRST_DAY_OF_WEEK = 'meta::pure::functions::date::firstDayOfThisWeek',
86
- FIRST_DAY_OF_MONTH = 'meta::pure::functions::date::firstDayOfThisMonth',
86
+ FIRST_DAY_OF_THIS_MONTH = 'meta::pure::functions::date::firstDayOfThisMonth',
87
+ FIRST_DAY_OF_MONTH = 'meta::pure::functions::date::firstDayOfMonth',
87
88
  FIRST_DAY_OF_QUARTER = 'meta::pure::functions::date::firstDayOfThisQuarter',
88
- FIRST_DAY_OF_YEAR = 'meta::pure::functions::date::firstDayOfThisYear',
89
+ FIRST_DAY_OF_THIS_YEAR = 'meta::pure::functions::date::firstDayOfThisYear',
90
+ FIRST_DAY_OF_YEAR = 'meta::pure::functions::date::firstDayOfYear',
89
91
  PREVIOUS_DAY_OF_WEEK = 'meta::pure::functions::date::previousDayOfWeek',
90
92
  IS_ON_DAY = 'meta::pure::functions::date::isOnDay',
91
93
  IS_ON_OR_AFTER_DAY = 'meta::pure::functions::date::isOnOrAfterDay',
@@ -217,7 +217,9 @@ export class QueryBuilder_PureProtocolProcessorPlugin extends PureProtocolProces
217
217
  return expression;
218
218
  } else if (
219
219
  matchFunctionName(functionName, [
220
+ QUERY_BUILDER_SUPPORTED_FUNCTIONS.FIRST_DAY_OF_THIS_YEAR,
220
221
  QUERY_BUILDER_SUPPORTED_FUNCTIONS.FIRST_DAY_OF_YEAR,
222
+ QUERY_BUILDER_SUPPORTED_FUNCTIONS.FIRST_DAY_OF_THIS_MONTH,
221
223
  QUERY_BUILDER_SUPPORTED_FUNCTIONS.FIRST_DAY_OF_MONTH,
222
224
  QUERY_BUILDER_SUPPORTED_FUNCTIONS.FIRST_DAY_OF_WEEK,
223
225
  QUERY_BUILDER_SUPPORTED_FUNCTIONS.PREVIOUS_DAY_OF_WEEK,
@@ -26,25 +26,25 @@ import {
26
26
  } from '@finos/legend-shared';
27
27
  import type { QueryBuilderState } from './QueryBuilderState.js';
28
28
  import {
29
+ type AbstractPropertyExpression,
29
30
  type EnumValueInstanceValue,
30
31
  type FunctionExpression,
31
32
  type GraphFetchTreeInstanceValue,
32
33
  type ValueSpecificationVisitor,
33
- InstanceValue,
34
- INTERNAL__UnknownValueSpecification,
35
34
  type LambdaFunction,
36
35
  type KeyExpressionInstanceValue,
37
- matchFunctionName,
38
- Class,
36
+ type INTERNAL__PropagatedValue,
37
+ type ValueSpecification,
39
38
  type CollectionInstanceValue,
40
39
  type LambdaFunctionInstanceValue,
40
+ InstanceValue,
41
+ INTERNAL__UnknownValueSpecification,
42
+ matchFunctionName,
43
+ Class,
41
44
  PrimitiveInstanceValue,
42
45
  SimpleFunctionExpression,
43
46
  VariableExpression,
44
- type AbstractPropertyExpression,
45
47
  getMilestoneTemporalStereotype,
46
- type INTERNAL__PropagatedValue,
47
- type ValueSpecification,
48
48
  SUPPORTED_FUNCTIONS,
49
49
  isSuperType,
50
50
  PackageableElementReference,
@@ -206,6 +206,33 @@ const processGetAllVersionsInRangeExpression = (
206
206
  );
207
207
  };
208
208
 
209
+ // a recursive function to check if there are some date functions
210
+ // unsupported in the custom date picker dropdown.
211
+ // For now, it's just QUERY_BUILDER_SUPPORTED_FUNCTIONS.FIRST_DAY_OF_YEAR and QUERY_BUILDER_SUPPORTED_FUNCTIONS.FIRST_DAY_OF_MONTH.
212
+ export const isUsedDateFunctionSupportedInFormMode = (
213
+ valueSpec: ValueSpecification,
214
+ ): boolean => {
215
+ if (valueSpec instanceof SimpleFunctionExpression) {
216
+ if (
217
+ matchFunctionName(
218
+ valueSpec.functionName,
219
+ QUERY_BUILDER_SUPPORTED_FUNCTIONS.FIRST_DAY_OF_YEAR,
220
+ ) ||
221
+ matchFunctionName(
222
+ valueSpec.functionName,
223
+ QUERY_BUILDER_SUPPORTED_FUNCTIONS.FIRST_DAY_OF_MONTH,
224
+ )
225
+ ) {
226
+ return false;
227
+ }
228
+ return !valueSpec.parametersValues
229
+ .map((value) => isUsedDateFunctionSupportedInFormMode(value))
230
+ .includes(false);
231
+ } else {
232
+ return true;
233
+ }
234
+ };
235
+
209
236
  const processLetExpression = (
210
237
  expression: SimpleFunctionExpression,
211
238
  queryBuilderState: QueryBuilderState,
@@ -239,11 +266,26 @@ const processLetExpression = (
239
266
  rightSide.content,
240
267
  );
241
268
  } else {
242
- constantExpression = new QueryBuilderSimpleConstantExpressionState(
243
- queryBuilderState,
244
- varExp,
245
- rightSide,
246
- );
269
+ // Even if a valueSpecification is successfully built, it might contain some date functions
270
+ // unsupported in the custom date picker dropdown, e.g., QUERY_BUILDER_SUPPORTED_FUNCTIONS.FIRST_DAY_OF_YEAR
271
+ // or QUERY_BUILDER_SUPPORTED_FUNCTIONS.FIRST_DAY_OF_MONTH.
272
+ // If it doesn't contain any unsupported date functions, a QueryBuilderSimpleConstantExpressionState should be created.
273
+ // Otherwise, a QueryBuilderCalculatedConstantExpressionState should be created.
274
+ if (isUsedDateFunctionSupportedInFormMode(rightSide)) {
275
+ constantExpression = new QueryBuilderSimpleConstantExpressionState(
276
+ queryBuilderState,
277
+ varExp,
278
+ rightSide,
279
+ );
280
+ } else {
281
+ constantExpression = new QueryBuilderCalculatedConstantExpressionState(
282
+ queryBuilderState,
283
+ varExp,
284
+ queryBuilderState.graphManagerState.graphManager.serializeValueSpecification(
285
+ rightSide,
286
+ ),
287
+ );
288
+ }
247
289
  }
248
290
  queryBuilderState.constantState.setShowConstantPanel(true);
249
291
  queryBuilderState.constantState.addConstant(constantExpression);