@finos/legend-query-builder 4.4.0 → 4.5.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (114) hide show
  1. package/lib/components/QueryBuilderResultPanel.d.ts.map +1 -1
  2. package/lib/components/QueryBuilderResultPanel.js +8 -2
  3. package/lib/components/QueryBuilderResultPanel.js.map +1 -1
  4. package/lib/components/execution-plan/AllocationExecutionNodeViewer.js +1 -1
  5. package/lib/components/execution-plan/AllocationExecutionNodeViewer.js.map +1 -1
  6. package/lib/components/execution-plan/ExecutionPlanViewer.d.ts +7 -0
  7. package/lib/components/execution-plan/ExecutionPlanViewer.d.ts.map +1 -1
  8. package/lib/components/execution-plan/ExecutionPlanViewer.js +109 -27
  9. package/lib/components/execution-plan/ExecutionPlanViewer.js.map +1 -1
  10. package/lib/components/execution-plan/FunctionParametersValidationNodeViewer.d.ts.map +1 -1
  11. package/lib/components/execution-plan/FunctionParametersValidationNodeViewer.js.map +1 -1
  12. package/lib/components/execution-plan/ImplementationViewer.d.ts +23 -0
  13. package/lib/components/execution-plan/ImplementationViewer.d.ts.map +1 -0
  14. package/lib/components/execution-plan/ImplementationViewer.js +35 -0
  15. package/lib/components/execution-plan/ImplementationViewer.js.map +1 -0
  16. package/lib/components/execution-plan/PartialClassResultViewer.d.ts +21 -0
  17. package/lib/components/execution-plan/PartialClassResultViewer.d.ts.map +1 -0
  18. package/lib/components/execution-plan/PartialClassResultViewer.js +24 -0
  19. package/lib/components/execution-plan/PartialClassResultViewer.js.map +1 -0
  20. package/lib/components/execution-plan/RelationalClassQueryTempTableGraphFetchExecutionNodeViewer.d.ts +23 -0
  21. package/lib/components/execution-plan/RelationalClassQueryTempTableGraphFetchExecutionNodeViewer.d.ts.map +1 -0
  22. package/lib/components/execution-plan/RelationalClassQueryTempTableGraphFetchExecutionNodeViewer.js +43 -0
  23. package/lib/components/execution-plan/RelationalClassQueryTempTableGraphFetchExecutionNodeViewer.js.map +1 -0
  24. package/lib/components/execution-plan/RelationalCrossRootQueryTempTableGraphFetchExecutionNodeViewer.d.ts +23 -0
  25. package/lib/components/execution-plan/RelationalCrossRootQueryTempTableGraphFetchExecutionNodeViewer.d.ts.map +1 -0
  26. package/lib/components/execution-plan/RelationalCrossRootQueryTempTableGraphFetchExecutionNodeViewer.js +47 -0
  27. package/lib/components/execution-plan/RelationalCrossRootQueryTempTableGraphFetchExecutionNodeViewer.js.map +1 -0
  28. package/lib/components/execution-plan/RelationalRootQueryTempTableGraphFetchExecutionNodeViewer.d.ts +23 -0
  29. package/lib/components/execution-plan/RelationalRootQueryTempTableGraphFetchExecutionNodeViewer.d.ts.map +1 -0
  30. package/lib/components/execution-plan/RelationalRootQueryTempTableGraphFetchExecutionNodeViewer.js +43 -0
  31. package/lib/components/execution-plan/RelationalRootQueryTempTableGraphFetchExecutionNodeViewer.js.map +1 -0
  32. package/lib/components/execution-plan/ResultTypeViewer.d.ts.map +1 -1
  33. package/lib/components/execution-plan/ResultTypeViewer.js +5 -1
  34. package/lib/components/execution-plan/ResultTypeViewer.js.map +1 -1
  35. package/lib/components/execution-plan/SQLExecutionNodeViewer.d.ts +1 -1
  36. package/lib/components/execution-plan/SQLExecutionNodeViewer.d.ts.map +1 -1
  37. package/lib/components/execution-plan/SQLExecutionNodeViewer.js +16 -3
  38. package/lib/components/execution-plan/SQLExecutionNodeViewer.js.map +1 -1
  39. package/lib/components/execution-plan/SequenceExecutionNodeViewer.d.ts +6 -0
  40. package/lib/components/execution-plan/SequenceExecutionNodeViewer.d.ts.map +1 -1
  41. package/lib/components/execution-plan/SequenceExecutionNodeViewer.js +34 -12
  42. package/lib/components/execution-plan/SequenceExecutionNodeViewer.js.map +1 -1
  43. package/lib/components/execution-plan/StoreMappingGlobalGraphFetchExecutionNodeViewer.d.ts +23 -0
  44. package/lib/components/execution-plan/StoreMappingGlobalGraphFetchExecutionNodeViewer.d.ts.map +1 -0
  45. package/lib/components/execution-plan/StoreMappingGlobalGraphFetchExecutionNodeViewer.js +57 -0
  46. package/lib/components/execution-plan/StoreMappingGlobalGraphFetchExecutionNodeViewer.js.map +1 -0
  47. package/lib/components/execution-plan/TempTableStrategyViewer.d.ts +28 -0
  48. package/lib/components/execution-plan/TempTableStrategyViewer.d.ts.map +1 -0
  49. package/lib/components/execution-plan/TempTableStrategyViewer.js +42 -0
  50. package/lib/components/execution-plan/TempTableStrategyViewer.js.map +1 -0
  51. package/lib/components/fetch-structure/QueryBuilderGraphFetchTreePanel.d.ts +7 -1
  52. package/lib/components/fetch-structure/QueryBuilderGraphFetchTreePanel.d.ts.map +1 -1
  53. package/lib/components/fetch-structure/QueryBuilderGraphFetchTreePanel.js +16 -10
  54. package/lib/components/fetch-structure/QueryBuilderGraphFetchTreePanel.js.map +1 -1
  55. package/lib/components/filter/QueryBuilderFilterPanel.d.ts.map +1 -1
  56. package/lib/components/filter/QueryBuilderFilterPanel.js +21 -8
  57. package/lib/components/filter/QueryBuilderFilterPanel.js.map +1 -1
  58. package/lib/components/shared/CustomDatePicker.d.ts +2 -1
  59. package/lib/components/shared/CustomDatePicker.d.ts.map +1 -1
  60. package/lib/components/shared/CustomDatePicker.js +31 -19
  61. package/lib/components/shared/CustomDatePicker.js.map +1 -1
  62. package/lib/components/shared/QueryBuilderVariableSelector.d.ts.map +1 -1
  63. package/lib/components/shared/QueryBuilderVariableSelector.js +1 -1
  64. package/lib/components/shared/QueryBuilderVariableSelector.js.map +1 -1
  65. package/lib/index.css +2 -2
  66. package/lib/index.css.map +1 -1
  67. package/lib/package.json +1 -1
  68. package/lib/stores/execution-plan/ExecutionPlanState.d.ts +15 -1
  69. package/lib/stores/execution-plan/ExecutionPlanState.d.ts.map +1 -1
  70. package/lib/stores/execution-plan/ExecutionPlanState.js +50 -3
  71. package/lib/stores/execution-plan/ExecutionPlanState.js.map +1 -1
  72. package/lib/stores/fetch-structure/graph-fetch/QueryBuilderGraphFetchTreeState.d.ts.map +1 -1
  73. package/lib/stores/fetch-structure/graph-fetch/QueryBuilderGraphFetchTreeState.js +16 -4
  74. package/lib/stores/fetch-structure/graph-fetch/QueryBuilderGraphFetchTreeState.js.map +1 -1
  75. package/lib/stores/fetch-structure/graph-fetch/QueryBuilderGraphFetchTreeUtil.d.ts +6 -4
  76. package/lib/stores/fetch-structure/graph-fetch/QueryBuilderGraphFetchTreeUtil.d.ts.map +1 -1
  77. package/lib/stores/fetch-structure/graph-fetch/QueryBuilderGraphFetchTreeUtil.js +43 -9
  78. package/lib/stores/fetch-structure/graph-fetch/QueryBuilderGraphFetchTreeUtil.js.map +1 -1
  79. package/lib/stores/filter/QueryBuilderFilterState.d.ts +3 -2
  80. package/lib/stores/filter/QueryBuilderFilterState.d.ts.map +1 -1
  81. package/lib/stores/filter/QueryBuilderFilterState.js +7 -5
  82. package/lib/stores/filter/QueryBuilderFilterState.js.map +1 -1
  83. package/lib/stores/filter/QueryBuilderFilterStateBuilder.d.ts.map +1 -1
  84. package/lib/stores/filter/QueryBuilderFilterStateBuilder.js +1 -1
  85. package/lib/stores/filter/QueryBuilderFilterStateBuilder.js.map +1 -1
  86. package/lib/stores/filter/QueryBuilderFilterValueSpecificationBuilder.d.ts.map +1 -1
  87. package/lib/stores/filter/QueryBuilderFilterValueSpecificationBuilder.js +5 -1
  88. package/lib/stores/filter/QueryBuilderFilterValueSpecificationBuilder.js.map +1 -1
  89. package/package.json +5 -5
  90. package/src/components/QueryBuilderResultPanel.tsx +7 -2
  91. package/src/components/execution-plan/AllocationExecutionNodeViewer.tsx +1 -1
  92. package/src/components/execution-plan/ExecutionPlanViewer.tsx +233 -57
  93. package/src/components/execution-plan/FunctionParametersValidationNodeViewer.tsx +1 -0
  94. package/src/components/execution-plan/ImplementationViewer.tsx +76 -0
  95. package/src/components/execution-plan/PartialClassResultViewer.tsx +55 -0
  96. package/src/components/execution-plan/RelationalClassQueryTempTableGraphFetchExecutionNodeViewer.tsx +190 -0
  97. package/src/components/execution-plan/RelationalCrossRootQueryTempTableGraphFetchExecutionNodeViewer.tsx +219 -0
  98. package/src/components/execution-plan/RelationalRootQueryTempTableGraphFetchExecutionNodeViewer.tsx +204 -0
  99. package/src/components/execution-plan/ResultTypeViewer.tsx +4 -0
  100. package/src/components/execution-plan/SQLExecutionNodeViewer.tsx +66 -44
  101. package/src/components/execution-plan/SequenceExecutionNodeViewer.tsx +79 -15
  102. package/src/components/execution-plan/StoreMappingGlobalGraphFetchExecutionNodeViewer.tsx +264 -0
  103. package/src/components/execution-plan/TempTableStrategyViewer.tsx +97 -0
  104. package/src/components/fetch-structure/QueryBuilderGraphFetchTreePanel.tsx +23 -9
  105. package/src/components/filter/QueryBuilderFilterPanel.tsx +43 -7
  106. package/src/components/shared/CustomDatePicker.tsx +65 -27
  107. package/src/components/shared/QueryBuilderVariableSelector.tsx +4 -1
  108. package/src/stores/execution-plan/ExecutionPlanState.ts +64 -1
  109. package/src/stores/fetch-structure/graph-fetch/QueryBuilderGraphFetchTreeState.ts +17 -7
  110. package/src/stores/fetch-structure/graph-fetch/QueryBuilderGraphFetchTreeUtil.ts +73 -9
  111. package/src/stores/filter/QueryBuilderFilterState.ts +13 -5
  112. package/src/stores/filter/QueryBuilderFilterStateBuilder.ts +1 -0
  113. package/src/stores/filter/QueryBuilderFilterValueSpecificationBuilder.ts +14 -1
  114. package/tsconfig.json +7 -0
@@ -20,13 +20,14 @@ import {
20
20
  deleteEntry,
21
21
  hashArray,
22
22
  type Hashable,
23
+ UnsupportedOperationError,
23
24
  } from '@finos/legend-shared';
24
25
  import type { TreeNodeData, TreeData } from '@finos/legend-art';
25
26
  import {
26
27
  type AbstractProperty,
27
28
  type GraphFetchTree,
28
29
  type Type,
29
- type RootGraphFetchTree,
30
+ RootGraphFetchTree,
30
31
  PropertyExplicitReference,
31
32
  Class,
32
33
  PropertyGraphFetchTree,
@@ -51,7 +52,7 @@ export class QueryBuilderGraphFetchTreeNodeData
51
52
  {
52
53
  readonly id: string;
53
54
  readonly label: string;
54
- readonly tree: PropertyGraphFetchTree;
55
+ readonly tree: PropertyGraphFetchTree | RootGraphFetchTree;
55
56
  readonly parentId?: string | undefined;
56
57
  isSelected?: boolean | undefined;
57
58
  isOpen?: boolean | undefined;
@@ -61,7 +62,7 @@ export class QueryBuilderGraphFetchTreeNodeData
61
62
  id: string,
62
63
  label: string,
63
64
  parentId: string | undefined,
64
- graphFetchTreeNode: PropertyGraphFetchTree,
65
+ graphFetchTreeNode: PropertyGraphFetchTree | RootGraphFetchTree,
65
66
  ) {
66
67
  makeObservable(this, {
67
68
  hashCode: computed,
@@ -76,7 +77,16 @@ export class QueryBuilderGraphFetchTreeNodeData
76
77
  }
77
78
 
78
79
  get type(): Type {
79
- return this.tree.property.value.genericType.value.rawType;
80
+ if (this.tree instanceof PropertyGraphFetchTree) {
81
+ return this.tree.property.value.genericType.value.rawType;
82
+ }
83
+ if (this.tree instanceof RootGraphFetchTree) {
84
+ return this.tree.class.value;
85
+ }
86
+ throw new UnsupportedOperationError(
87
+ `Can't get type of Graph Fetch Tree`,
88
+ this.tree,
89
+ );
80
90
  }
81
91
 
82
92
  get hashCode(): string {
@@ -105,6 +115,14 @@ export const generateGraphFetchTreeNodeID = (
105
115
  subType ? `${TYPE_CAST_TOKEN}${subType.path}` : ''
106
116
  }`;
107
117
 
118
+ export const generateRootGraphFetchTreeNodeID = (
119
+ parentNodeId: string | undefined,
120
+ classValue: string | undefined,
121
+ ): string =>
122
+ `${parentNodeId ? `${parentNodeId}.` : ''}${
123
+ classValue ? `${TYPE_CAST_TOKEN}${classValue}` : ''
124
+ }`;
125
+
108
126
  const buildGraphFetchSubTree = (
109
127
  tree: GraphFetchTree,
110
128
  parentNode: QueryBuilderGraphFetchTreeNodeData | undefined,
@@ -132,19 +150,65 @@ const buildGraphFetchSubTree = (
132
150
  return node;
133
151
  };
134
152
 
153
+ const buildRootGraphFetchSubTree = (
154
+ tree: RootGraphFetchTree,
155
+ parentNode: QueryBuilderGraphFetchTreeNodeData | undefined,
156
+ nodes: Map<string, QueryBuilderGraphFetchTreeNodeData>,
157
+ ): QueryBuilderGraphFetchTreeNodeData => {
158
+ const parentNodeId = parentNode?.id;
159
+ const node = new QueryBuilderGraphFetchTreeNodeData(
160
+ generateRootGraphFetchTreeNodeID(
161
+ parentNodeId,
162
+ tree.class.valueForSerialization ?? '',
163
+ ),
164
+ tree.class.value.name,
165
+ parentNodeId,
166
+ tree,
167
+ );
168
+ tree.subTrees.forEach((subTree) => {
169
+ const subTreeNode = buildGraphFetchSubTree(subTree, node, nodes);
170
+ addUniqueEntry(node.childrenIds, subTreeNode.id);
171
+ nodes.set(subTreeNode.id, subTreeNode);
172
+ });
173
+ return node;
174
+ };
175
+
135
176
  /**
136
177
  * Build graph fetch tree data from an existing graph fetch tree root
137
178
  */
138
179
  export const buildGraphFetchTreeData = (
139
180
  tree: RootGraphFetchTree,
181
+ displayRoot: boolean = false,
140
182
  ): QueryBuilderGraphFetchTreeData => {
141
183
  const rootIds: string[] = [];
142
184
  const nodes = new Map<string, QueryBuilderGraphFetchTreeNodeData>();
143
- tree.subTrees.forEach((subTree) => {
144
- const subTreeNode = buildGraphFetchSubTree(subTree, undefined, nodes);
145
- addUniqueEntry(rootIds, subTreeNode.id);
146
- nodes.set(subTreeNode.id, subTreeNode);
147
- });
185
+ if (displayRoot) {
186
+ const rootNode = buildRootGraphFetchSubTree(tree, undefined, nodes);
187
+ addUniqueEntry(rootIds, rootNode.id);
188
+ nodes.set(rootNode.id, rootNode);
189
+ } else {
190
+ tree.subTrees.forEach((subTree) => {
191
+ const subTreeNode = buildGraphFetchSubTree(subTree, undefined, nodes);
192
+ addUniqueEntry(rootIds, subTreeNode.id);
193
+ nodes.set(subTreeNode.id, subTreeNode);
194
+ });
195
+ }
196
+
197
+ return { rootIds, nodes, tree };
198
+ };
199
+
200
+ export const buildPropertyGraphFetchTreeData = (
201
+ propertyTree: PropertyGraphFetchTree,
202
+ ): QueryBuilderGraphFetchTreeData => {
203
+ const rootIds: string[] = [];
204
+ const nodes = new Map<string, QueryBuilderGraphFetchTreeNodeData>();
205
+ const propertyNode = buildGraphFetchSubTree(propertyTree, undefined, nodes);
206
+ addUniqueEntry(rootIds, propertyNode.id);
207
+ nodes.set(propertyNode.id, propertyNode);
208
+ const tree = new RootGraphFetchTree(
209
+ PackageableElementExplicitReference.create(new Class('root')),
210
+ );
211
+ tree.subTrees.push(propertyTree);
148
212
  return { rootIds, nodes, tree };
149
213
  };
150
214
 
@@ -343,16 +343,21 @@ export class QueryBuilderFilterTreeExistsNodeData
343
343
  extends QueryBuilderFilterTreeOperationNodeData
344
344
  implements Hashable
345
345
  {
346
- propertyExpression!: AbstractPropertyExpression;
346
+ readonly filterState: QueryBuilderFilterState;
347
+ propertyExpressionState!: QueryBuilderPropertyExpressionState;
347
348
 
348
- constructor(parentId: string | undefined) {
349
+ constructor(
350
+ filterState: QueryBuilderFilterState,
351
+ parentId: string | undefined,
352
+ ) {
349
353
  super(parentId);
350
354
 
351
355
  makeObservable(this, {
352
- propertyExpression: observable,
356
+ propertyExpressionState: observable,
353
357
  setPropertyExpression: action,
354
358
  });
355
359
 
360
+ this.filterState = filterState;
356
361
  this.isOpen = true;
357
362
  }
358
363
 
@@ -361,7 +366,10 @@ export class QueryBuilderFilterTreeExistsNodeData
361
366
  }
362
367
 
363
368
  setPropertyExpression(val: AbstractPropertyExpression): void {
364
- this.propertyExpression = val;
369
+ this.propertyExpressionState = new QueryBuilderPropertyExpressionState(
370
+ this.filterState.queryBuilderState,
371
+ val,
372
+ );
365
373
  }
366
374
 
367
375
  get hashCode(): string {
@@ -369,7 +377,7 @@ export class QueryBuilderFilterTreeExistsNodeData
369
377
  QUERY_BUILDER_STATE_HASH_STRUCTURE.FILTER_TREE_EXISTS_NODE_DATA,
370
378
  this.parentId ?? '',
371
379
  hashArray(this.childrenIds),
372
- this.propertyExpression,
380
+ this.propertyExpressionState.propertyExpression,
373
381
  this.lambdaParameterName ?? '',
374
382
  ]);
375
383
  }
@@ -120,6 +120,7 @@ const processFilterTree = (
120
120
  propertyExpression.func.value.multiplicity.upperBound > 1
121
121
  ) {
122
122
  const existsNode = new QueryBuilderFilterTreeExistsNodeData(
123
+ filterState,
123
124
  parentFilterNodeId,
124
125
  );
125
126
  const lambdaFunctionInstance = guaranteeType(
@@ -37,6 +37,7 @@ import {
37
37
  } from './QueryBuilderFilterState.js';
38
38
  import { QUERY_BUILDER_SUPPORTED_FUNCTIONS } from '../../graph/QueryBuilderMetaModelConst.js';
39
39
  import { DEFAULT_LAMBDA_VARIABLE_NAME } from '../QueryBuilderConfig.js';
40
+ import { buildPropertyExpressionChain } from '../QueryBuilderValueSpecificationBuilderHelper.js';
40
41
 
41
42
  const buildFilterConditionExpression = (
42
43
  filterState: QueryBuilderFilterState,
@@ -110,7 +111,19 @@ const buildFilterConditionExpression = (
110
111
  )
111
112
  : undefined;
112
113
  }
113
- const propertyExpression = guaranteeNonNullable(node.propertyExpression);
114
+ const lambdaParameterName = node.parentId
115
+ ? guaranteeType(
116
+ filterState.nodes.get(guaranteeNonNullable(node.parentId)),
117
+ QueryBuilderFilterTreeOperationNodeData,
118
+ ).lambdaParameterName
119
+ : undefined;
120
+ const propertyExpression = guaranteeNonNullable(
121
+ buildPropertyExpressionChain(
122
+ node.propertyExpressionState.propertyExpression,
123
+ node.propertyExpressionState.queryBuilderState,
124
+ lambdaParameterName ?? filterState.lambdaParameterName,
125
+ ),
126
+ );
114
127
  const clauses = node.childrenIds
115
128
  .map((e) => filterState.nodes.get(e))
116
129
  .filter(isNonNullable)
package/tsconfig.json CHANGED
@@ -232,11 +232,18 @@
232
232
  "./src/components/execution-plan/DataTypeResultTypeViewer.tsx",
233
233
  "./src/components/execution-plan/ExecutionPlanViewer.tsx",
234
234
  "./src/components/execution-plan/FunctionParametersValidationNodeViewer.tsx",
235
+ "./src/components/execution-plan/ImplementationViewer.tsx",
236
+ "./src/components/execution-plan/PartialClassResultViewer.tsx",
237
+ "./src/components/execution-plan/RelationalClassQueryTempTableGraphFetchExecutionNodeViewer.tsx",
238
+ "./src/components/execution-plan/RelationalCrossRootQueryTempTableGraphFetchExecutionNodeViewer.tsx",
239
+ "./src/components/execution-plan/RelationalRootQueryTempTableGraphFetchExecutionNodeViewer.tsx",
235
240
  "./src/components/execution-plan/RelationalTDSInstantiationExecutionNodeViewer.tsx",
236
241
  "./src/components/execution-plan/ResultTypeViewer.tsx",
237
242
  "./src/components/execution-plan/SQLExecutionNodeViewer.tsx",
238
243
  "./src/components/execution-plan/SequenceExecutionNodeViewer.tsx",
244
+ "./src/components/execution-plan/StoreMappingGlobalGraphFetchExecutionNodeViewer.tsx",
239
245
  "./src/components/execution-plan/TDSResultTypeViewer.tsx",
246
+ "./src/components/execution-plan/TempTableStrategyViewer.tsx",
240
247
  "./src/components/explorer/QueryBuilderExplorerPanel.tsx",
241
248
  "./src/components/explorer/QueryBuilderFunctionsExplorerPanel.tsx",
242
249
  "./src/components/explorer/QueryBuilderMilestoningEditor.tsx",