@finos/legend-query-builder 4.3.9 → 4.5.0

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 (139) hide show
  1. package/lib/components/QueryBuilder.d.ts.map +1 -1
  2. package/lib/components/QueryBuilder.js +2 -2
  3. package/lib/components/QueryBuilder.js.map +1 -1
  4. package/lib/components/QueryBuilderResultPanel.d.ts.map +1 -1
  5. package/lib/components/QueryBuilderResultPanel.js +8 -2
  6. package/lib/components/QueryBuilderResultPanel.js.map +1 -1
  7. package/lib/components/__test-utils__/QueryBuilderComponentTestUtils.d.ts.map +1 -1
  8. package/lib/components/__test-utils__/QueryBuilderComponentTestUtils.js +1 -1
  9. package/lib/components/__test-utils__/QueryBuilderComponentTestUtils.js.map +1 -1
  10. package/lib/components/execution-plan/AllocationExecutionNodeViewer.js +1 -1
  11. package/lib/components/execution-plan/AllocationExecutionNodeViewer.js.map +1 -1
  12. package/lib/components/execution-plan/ExecutionPlanViewer.d.ts +7 -0
  13. package/lib/components/execution-plan/ExecutionPlanViewer.d.ts.map +1 -1
  14. package/lib/components/execution-plan/ExecutionPlanViewer.js +109 -27
  15. package/lib/components/execution-plan/ExecutionPlanViewer.js.map +1 -1
  16. package/lib/components/execution-plan/FunctionParametersValidationNodeViewer.d.ts.map +1 -1
  17. package/lib/components/execution-plan/FunctionParametersValidationNodeViewer.js.map +1 -1
  18. package/lib/components/execution-plan/ImplementationViewer.d.ts +23 -0
  19. package/lib/components/execution-plan/ImplementationViewer.d.ts.map +1 -0
  20. package/lib/components/execution-plan/ImplementationViewer.js +35 -0
  21. package/lib/components/execution-plan/ImplementationViewer.js.map +1 -0
  22. package/lib/components/execution-plan/PartialClassResultViewer.d.ts +21 -0
  23. package/lib/components/execution-plan/PartialClassResultViewer.d.ts.map +1 -0
  24. package/lib/components/execution-plan/PartialClassResultViewer.js +24 -0
  25. package/lib/components/execution-plan/PartialClassResultViewer.js.map +1 -0
  26. package/lib/components/execution-plan/RelationalClassQueryTempTableGraphFetchExecutionNodeViewer.d.ts +23 -0
  27. package/lib/components/execution-plan/RelationalClassQueryTempTableGraphFetchExecutionNodeViewer.d.ts.map +1 -0
  28. package/lib/components/execution-plan/RelationalClassQueryTempTableGraphFetchExecutionNodeViewer.js +43 -0
  29. package/lib/components/execution-plan/RelationalClassQueryTempTableGraphFetchExecutionNodeViewer.js.map +1 -0
  30. package/lib/components/execution-plan/RelationalCrossRootQueryTempTableGraphFetchExecutionNodeViewer.d.ts +23 -0
  31. package/lib/components/execution-plan/RelationalCrossRootQueryTempTableGraphFetchExecutionNodeViewer.d.ts.map +1 -0
  32. package/lib/components/execution-plan/RelationalCrossRootQueryTempTableGraphFetchExecutionNodeViewer.js +47 -0
  33. package/lib/components/execution-plan/RelationalCrossRootQueryTempTableGraphFetchExecutionNodeViewer.js.map +1 -0
  34. package/lib/components/execution-plan/RelationalRootQueryTempTableGraphFetchExecutionNodeViewer.d.ts +23 -0
  35. package/lib/components/execution-plan/RelationalRootQueryTempTableGraphFetchExecutionNodeViewer.d.ts.map +1 -0
  36. package/lib/components/execution-plan/RelationalRootQueryTempTableGraphFetchExecutionNodeViewer.js +43 -0
  37. package/lib/components/execution-plan/RelationalRootQueryTempTableGraphFetchExecutionNodeViewer.js.map +1 -0
  38. package/lib/components/execution-plan/ResultTypeViewer.d.ts.map +1 -1
  39. package/lib/components/execution-plan/ResultTypeViewer.js +5 -1
  40. package/lib/components/execution-plan/ResultTypeViewer.js.map +1 -1
  41. package/lib/components/execution-plan/SQLExecutionNodeViewer.d.ts +1 -1
  42. package/lib/components/execution-plan/SQLExecutionNodeViewer.d.ts.map +1 -1
  43. package/lib/components/execution-plan/SQLExecutionNodeViewer.js +16 -3
  44. package/lib/components/execution-plan/SQLExecutionNodeViewer.js.map +1 -1
  45. package/lib/components/execution-plan/SequenceExecutionNodeViewer.d.ts +6 -0
  46. package/lib/components/execution-plan/SequenceExecutionNodeViewer.d.ts.map +1 -1
  47. package/lib/components/execution-plan/SequenceExecutionNodeViewer.js +34 -12
  48. package/lib/components/execution-plan/SequenceExecutionNodeViewer.js.map +1 -1
  49. package/lib/components/execution-plan/StoreMappingGlobalGraphFetchExecutionNodeViewer.d.ts +23 -0
  50. package/lib/components/execution-plan/StoreMappingGlobalGraphFetchExecutionNodeViewer.d.ts.map +1 -0
  51. package/lib/components/execution-plan/StoreMappingGlobalGraphFetchExecutionNodeViewer.js +57 -0
  52. package/lib/components/execution-plan/StoreMappingGlobalGraphFetchExecutionNodeViewer.js.map +1 -0
  53. package/lib/components/execution-plan/TempTableStrategyViewer.d.ts +28 -0
  54. package/lib/components/execution-plan/TempTableStrategyViewer.d.ts.map +1 -0
  55. package/lib/components/execution-plan/TempTableStrategyViewer.js +42 -0
  56. package/lib/components/execution-plan/TempTableStrategyViewer.js.map +1 -0
  57. package/lib/components/fetch-structure/QueryBuilderGraphFetchTreePanel.d.ts +7 -1
  58. package/lib/components/fetch-structure/QueryBuilderGraphFetchTreePanel.d.ts.map +1 -1
  59. package/lib/components/fetch-structure/QueryBuilderGraphFetchTreePanel.js +16 -10
  60. package/lib/components/fetch-structure/QueryBuilderGraphFetchTreePanel.js.map +1 -1
  61. package/lib/components/shared/CustomDatePicker.d.ts +2 -1
  62. package/lib/components/shared/CustomDatePicker.d.ts.map +1 -1
  63. package/lib/components/shared/CustomDatePicker.js +31 -19
  64. package/lib/components/shared/CustomDatePicker.js.map +1 -1
  65. package/lib/components/shared/QueryBuilderVariableSelector.d.ts.map +1 -1
  66. package/lib/components/shared/QueryBuilderVariableSelector.js +1 -1
  67. package/lib/components/shared/QueryBuilderVariableSelector.js.map +1 -1
  68. package/lib/graph-manager/QueryBuilderConfig.d.ts +24 -0
  69. package/lib/graph-manager/QueryBuilderConfig.d.ts.map +1 -0
  70. package/lib/graph-manager/QueryBuilderConfig.js +27 -0
  71. package/lib/graph-manager/QueryBuilderConfig.js.map +1 -0
  72. package/lib/index.css +2 -2
  73. package/lib/index.css.map +1 -1
  74. package/lib/index.d.ts +1 -0
  75. package/lib/index.d.ts.map +1 -1
  76. package/lib/index.js +1 -0
  77. package/lib/index.js.map +1 -1
  78. package/lib/package.json +9 -9
  79. package/lib/stores/QueryBuilderState.d.ts +3 -1
  80. package/lib/stores/QueryBuilderState.d.ts.map +1 -1
  81. package/lib/stores/QueryBuilderState.js +4 -2
  82. package/lib/stores/QueryBuilderState.js.map +1 -1
  83. package/lib/stores/__test-utils__/QueryBuilderStateTestUtils.d.ts.map +1 -1
  84. package/lib/stores/__test-utils__/QueryBuilderStateTestUtils.js +1 -1
  85. package/lib/stores/__test-utils__/QueryBuilderStateTestUtils.js.map +1 -1
  86. package/lib/stores/execution-plan/ExecutionPlanState.d.ts +15 -1
  87. package/lib/stores/execution-plan/ExecutionPlanState.d.ts.map +1 -1
  88. package/lib/stores/execution-plan/ExecutionPlanState.js +50 -3
  89. package/lib/stores/execution-plan/ExecutionPlanState.js.map +1 -1
  90. package/lib/stores/fetch-structure/graph-fetch/QueryBuilderGraphFetchTreeState.d.ts.map +1 -1
  91. package/lib/stores/fetch-structure/graph-fetch/QueryBuilderGraphFetchTreeState.js +16 -4
  92. package/lib/stores/fetch-structure/graph-fetch/QueryBuilderGraphFetchTreeState.js.map +1 -1
  93. package/lib/stores/fetch-structure/graph-fetch/QueryBuilderGraphFetchTreeUtil.d.ts +6 -4
  94. package/lib/stores/fetch-structure/graph-fetch/QueryBuilderGraphFetchTreeUtil.d.ts.map +1 -1
  95. package/lib/stores/fetch-structure/graph-fetch/QueryBuilderGraphFetchTreeUtil.js +43 -9
  96. package/lib/stores/fetch-structure/graph-fetch/QueryBuilderGraphFetchTreeUtil.js.map +1 -1
  97. package/lib/stores/workflows/FunctionQueryBuilderState.d.ts +2 -1
  98. package/lib/stores/workflows/FunctionQueryBuilderState.d.ts.map +1 -1
  99. package/lib/stores/workflows/FunctionQueryBuilderState.js +2 -2
  100. package/lib/stores/workflows/FunctionQueryBuilderState.js.map +1 -1
  101. package/lib/stores/workflows/MappingQueryBuilderState.d.ts +2 -1
  102. package/lib/stores/workflows/MappingQueryBuilderState.d.ts.map +1 -1
  103. package/lib/stores/workflows/MappingQueryBuilderState.js +2 -2
  104. package/lib/stores/workflows/MappingQueryBuilderState.js.map +1 -1
  105. package/lib/stores/workflows/ServiceQueryBuilderState.d.ts +2 -1
  106. package/lib/stores/workflows/ServiceQueryBuilderState.d.ts.map +1 -1
  107. package/lib/stores/workflows/ServiceQueryBuilderState.js +2 -2
  108. package/lib/stores/workflows/ServiceQueryBuilderState.js.map +1 -1
  109. package/package.json +17 -17
  110. package/src/components/QueryBuilder.tsx +16 -14
  111. package/src/components/QueryBuilderResultPanel.tsx +7 -2
  112. package/src/components/__test-utils__/QueryBuilderComponentTestUtils.tsx +1 -0
  113. package/src/components/execution-plan/AllocationExecutionNodeViewer.tsx +1 -1
  114. package/src/components/execution-plan/ExecutionPlanViewer.tsx +233 -57
  115. package/src/components/execution-plan/FunctionParametersValidationNodeViewer.tsx +1 -0
  116. package/src/components/execution-plan/ImplementationViewer.tsx +76 -0
  117. package/src/components/execution-plan/PartialClassResultViewer.tsx +55 -0
  118. package/src/components/execution-plan/RelationalClassQueryTempTableGraphFetchExecutionNodeViewer.tsx +190 -0
  119. package/src/components/execution-plan/RelationalCrossRootQueryTempTableGraphFetchExecutionNodeViewer.tsx +219 -0
  120. package/src/components/execution-plan/RelationalRootQueryTempTableGraphFetchExecutionNodeViewer.tsx +204 -0
  121. package/src/components/execution-plan/ResultTypeViewer.tsx +4 -0
  122. package/src/components/execution-plan/SQLExecutionNodeViewer.tsx +66 -44
  123. package/src/components/execution-plan/SequenceExecutionNodeViewer.tsx +79 -15
  124. package/src/components/execution-plan/StoreMappingGlobalGraphFetchExecutionNodeViewer.tsx +264 -0
  125. package/src/components/execution-plan/TempTableStrategyViewer.tsx +97 -0
  126. package/src/components/fetch-structure/QueryBuilderGraphFetchTreePanel.tsx +23 -9
  127. package/src/components/shared/CustomDatePicker.tsx +65 -27
  128. package/src/components/shared/QueryBuilderVariableSelector.tsx +4 -1
  129. package/src/graph-manager/QueryBuilderConfig.ts +31 -0
  130. package/src/index.ts +1 -1
  131. package/src/stores/QueryBuilderState.ts +5 -0
  132. package/src/stores/__test-utils__/QueryBuilderStateTestUtils.ts +1 -0
  133. package/src/stores/execution-plan/ExecutionPlanState.ts +64 -1
  134. package/src/stores/fetch-structure/graph-fetch/QueryBuilderGraphFetchTreeState.ts +17 -7
  135. package/src/stores/fetch-structure/graph-fetch/QueryBuilderGraphFetchTreeUtil.ts +73 -9
  136. package/src/stores/workflows/FunctionQueryBuilderState.ts +3 -1
  137. package/src/stores/workflows/MappingQueryBuilderState.ts +3 -1
  138. package/src/stores/workflows/ServiceQueryBuilderState.ts +3 -1
  139. package/tsconfig.json +8 -0
@@ -52,7 +52,7 @@ export const SQLExecutionNodeViewerHelper: React.FC<{
52
52
  resultType: ResultType;
53
53
  executionPlanState: ExecutionPlanState;
54
54
  }> = observer((props) => {
55
- const { query, resultColumns, resultType, executionPlanState } = props;
55
+ const { query, resultColumns, executionPlanState } = props;
56
56
  const applicationStore = executionPlanState.applicationStore;
57
57
  const copyExpression = (value: string): void => {
58
58
  applicationStore.clipboardService
@@ -66,7 +66,6 @@ export const SQLExecutionNodeViewerHelper: React.FC<{
66
66
  )
67
67
  .catch(applicationStore.alertUnhandledError);
68
68
  };
69
-
70
69
  return (
71
70
  <>
72
71
  <div className="query-builder__sql__container">
@@ -89,46 +88,60 @@ export const SQLExecutionNodeViewerHelper: React.FC<{
89
88
  </PanelListItem>
90
89
  </div>
91
90
  <div className="query-builder__sql__container__code-editor">
91
+ {/* Replace special characters to fix SQL-formatter bug*/}
92
92
  <CodeEditor
93
- inputValue={tryToFormatSql(query)}
93
+ inputValue={tryToFormatSql(
94
+ query
95
+ .replaceAll('$', 'changeDollar')
96
+ .replaceAll('?', 'changeQuestion')
97
+ .replaceAll('{', 'changeOpenCurlyBracket')
98
+ .replaceAll('}', 'changeCloseCurlyBracket')
99
+ .replaceAll("'", 'changeSingleQuote'),
100
+ )
101
+ .replaceAll('changeDollar', '$')
102
+ .replaceAll('changeQuestion', '?')
103
+ .replaceAll('changeOpenCurlyBracket', '{')
104
+ .replaceAll('changeCloseCurlyBracket', '}')
105
+ .replaceAll('changeSingleQuote', "'")}
94
106
  language={CODE_EDITOR_LANGUAGE.SQL}
95
107
  />
96
108
  </div>
97
109
  <PanelDivider />
98
110
  </div>
99
111
  </div>
100
- <div className="query-builder__sql__container">
101
- <div>
102
- <PanelListItem className="query-builder__sql__container__item__label">
103
- Result Columns
104
- </PanelListItem>
105
- <PanelDivider />
106
- <table className="table query-builder__sql__container__table">
107
- <thead>
108
- <tr>
109
- <th className="table__cell--left">Label</th>
110
- <th className="table__cell--left">Data Type</th>
111
- </tr>
112
- </thead>
113
- <tbody>
114
- {resultColumns.map((column) => (
115
- <tr key={column.label}>
116
- <td className="table__cell--left">
117
- {column.label.replaceAll(`"`, '')}
118
- </td>
119
-
120
- {column.dataType && (
112
+ {resultColumns.length > 0 && (
113
+ <div className="query-builder__sql__container">
114
+ <div>
115
+ <PanelListItem className="query-builder__sql__container__item__label">
116
+ Result Columns
117
+ </PanelListItem>
118
+ <PanelDivider />
119
+ <table className="table query-builder__sql__container__table">
120
+ <thead>
121
+ <tr>
122
+ <th className="table__cell--left">Label</th>
123
+ <th className="table__cell--left">Data Type</th>
124
+ </tr>
125
+ </thead>
126
+ <tbody>
127
+ {resultColumns.map((column) => (
128
+ <tr key={column.label}>
121
129
  <td className="table__cell--left">
122
- {stringifyDataType(column.dataType)}
130
+ {column.label.replaceAll(`"`, '')}
123
131
  </td>
124
- )}
125
- </tr>
126
- ))}
127
- </tbody>
128
- </table>
132
+
133
+ {column.dataType && (
134
+ <td className="table__cell--left">
135
+ {stringifyDataType(column.dataType)}
136
+ </td>
137
+ )}
138
+ </tr>
139
+ ))}
140
+ </tbody>
141
+ </table>
142
+ </div>
129
143
  </div>
130
- </div>
131
- <ResultTypeViewer resultType={resultType} />
144
+ )}
132
145
  </>
133
146
  );
134
147
  });
@@ -138,12 +151,22 @@ export const SQLExecutionNodeViewer: React.FC<{
138
151
  resultColumns: SQLResultColumn[];
139
152
  resultType: ResultType;
140
153
  executionPlanState: ExecutionPlanState;
141
- viewJson: boolean;
154
+ viewJson?: boolean | undefined;
142
155
  }> = observer((props) => {
143
156
  const { query, resultColumns, resultType, executionPlanState, viewJson } =
144
157
  props;
145
158
  const applicationStore = executionPlanState.applicationStore;
146
159
 
160
+ if (viewJson === false) {
161
+ return (
162
+ <SQLExecutionNodeViewerHelper
163
+ query={query}
164
+ resultColumns={resultColumns}
165
+ resultType={resultType}
166
+ executionPlanState={executionPlanState}
167
+ />
168
+ );
169
+ }
147
170
  return (
148
171
  <PanelContent
149
172
  darkMode={
@@ -156,17 +179,16 @@ export const SQLExecutionNodeViewer: React.FC<{
156
179
  resultType={resultType}
157
180
  executionPlanState={executionPlanState}
158
181
  />
159
- {viewJson && (
160
- <div className="query-builder__sql__container">
161
- <Button
162
- className="btn--dark execution-node-viewer__unsupported-view__to-text-mode__btn"
163
- onClick={(): void =>
164
- executionPlanState.setViewMode(EXECUTION_PLAN_VIEW_MODE.JSON)
165
- }
166
- text="View JSON"
167
- />
168
- </div>
169
- )}
182
+ <ResultTypeViewer resultType={resultType} />
183
+ <div className="query-builder__sql__container">
184
+ <Button
185
+ className="btn--dark execution-node-viewer__unsupported-view__to-text-mode__btn"
186
+ onClick={(): void =>
187
+ executionPlanState.setViewMode(EXECUTION_PLAN_VIEW_MODE.JSON)
188
+ }
189
+ text="View JSON"
190
+ />
191
+ </div>
170
192
  <PanelDivider />
171
193
  </PanelContent>
172
194
  );
@@ -15,7 +15,10 @@
15
15
  */
16
16
 
17
17
  import { observer } from 'mobx-react-lite';
18
- import { generateExecutionNodeLabel } from './ExecutionPlanViewer.js';
18
+ import {
19
+ ExecutionNodeViewer,
20
+ generateExecutionNodeLabel,
21
+ } from './ExecutionPlanViewer.js';
19
22
  import {
20
23
  type ExecutionPlanState,
21
24
  EXECUTION_PLAN_VIEW_MODE,
@@ -28,33 +31,55 @@ import {
28
31
  PanelDivider,
29
32
  Button,
30
33
  PanelContent,
34
+ ChevronDownIcon,
35
+ ChevronRightIcon,
31
36
  } from '@finos/legend-art';
32
37
  import type { ExecutionNode, SequenceExecutionNode } from '@finos/legend-graph';
33
38
  import { ResultTypeViewer } from './ResultTypeViewer.js';
39
+ import { useState } from 'react';
34
40
 
35
- export const SequenceExecutionNodeViewer: React.FC<{
41
+ export const SequenceExecutionNodeViewerHelper: React.FC<{
36
42
  node: SequenceExecutionNode;
37
43
  executionPlanState: ExecutionPlanState;
44
+ viewJson?: boolean | undefined;
38
45
  }> = observer((props) => {
39
- const { node, executionPlanState } = props;
46
+ const { node, executionPlanState, viewJson } = props;
40
47
  const resultType = node.resultType;
41
- const applicationStore = executionPlanState.applicationStore;
48
+ const [executionNode, setExecutionNode] = useState<ExecutionNode | undefined>(
49
+ undefined,
50
+ );
51
+ const nodeExpandIcon = viewJson ? (
52
+ <div />
53
+ ) : executionNode ? (
54
+ <ChevronDownIcon />
55
+ ) : (
56
+ <ChevronRightIcon />
57
+ );
42
58
  const openExecutionNode = (child: ExecutionNode): void => {
43
59
  const newNode = executionPlanState.treeData?.nodes.get(child._UUID);
44
- if (newNode instanceof ExecutionPlanViewTreeNodeData) {
45
- executionPlanState.transformMetadataToProtocolJson(newNode.executionPlan);
46
- } else if (newNode instanceof ExecutionNodeTreeNodeData) {
47
- executionPlanState.transformMetadataToProtocolJson(newNode.executionNode);
60
+ if (viewJson === false) {
61
+ if (executionNode) {
62
+ setExecutionNode(undefined);
63
+ } else {
64
+ setExecutionNode(child);
65
+ }
66
+ } else {
67
+ if (newNode instanceof ExecutionPlanViewTreeNodeData) {
68
+ executionPlanState.transformMetadataToProtocolJson(
69
+ newNode.executionPlan,
70
+ );
71
+ } else if (newNode instanceof ExecutionNodeTreeNodeData) {
72
+ executionPlanState.transformMetadataToProtocolJson(
73
+ newNode.executionNode,
74
+ );
75
+ }
76
+ if (newNode) {
77
+ executionPlanState.setSelectedNode(newNode);
78
+ }
48
79
  }
49
- executionPlanState.setSelectedNode(newNode);
50
80
  };
51
-
52
81
  return (
53
- <PanelContent
54
- darkMode={
55
- !applicationStore.layoutService.TEMPORARY__isLightColorThemeEnabled
56
- }
57
- >
82
+ <>
58
83
  <div className="query-builder__sequence__container">
59
84
  <div>
60
85
  <PanelListItem className="query-builder__sequence__container__item__label">
@@ -72,6 +97,7 @@ export const SequenceExecutionNodeViewer: React.FC<{
72
97
  tabIndex={-1}
73
98
  title={`Go to ${generateExecutionNodeLabel(child)}`}
74
99
  >
100
+ {!viewJson && nodeExpandIcon}
75
101
  {`${index + 1}: ${generateExecutionNodeLabel(child)}`}
76
102
  </button>
77
103
  </div>
@@ -80,6 +106,44 @@ export const SequenceExecutionNodeViewer: React.FC<{
80
106
  </div>
81
107
  <PanelDivider />
82
108
  <ResultTypeViewer resultType={resultType} />
109
+ {viewJson === false && executionNode && (
110
+ <ExecutionNodeViewer
111
+ executionNode={executionNode}
112
+ executionPlanState={executionPlanState}
113
+ viewJson={false}
114
+ />
115
+ )}
116
+ </>
117
+ );
118
+ });
119
+
120
+ export const SequenceExecutionNodeViewer: React.FC<{
121
+ node: SequenceExecutionNode;
122
+ executionPlanState: ExecutionPlanState;
123
+ viewJson?: boolean | undefined;
124
+ }> = observer((props) => {
125
+ const { node, executionPlanState, viewJson } = props;
126
+ const applicationStore = executionPlanState.applicationStore;
127
+ if (viewJson === false) {
128
+ return (
129
+ <SequenceExecutionNodeViewerHelper
130
+ node={node}
131
+ executionPlanState={executionPlanState}
132
+ viewJson={viewJson}
133
+ />
134
+ );
135
+ }
136
+ return (
137
+ <PanelContent
138
+ darkMode={
139
+ !applicationStore.layoutService.TEMPORARY__isLightColorThemeEnabled
140
+ }
141
+ >
142
+ <SequenceExecutionNodeViewerHelper
143
+ node={node}
144
+ executionPlanState={executionPlanState}
145
+ viewJson={viewJson}
146
+ />
83
147
  <div className="query-builder__execution__container">
84
148
  <Button
85
149
  className="btn--dark execution-node-viewer__unsupported-view__to-text-mode__btn"
@@ -0,0 +1,264 @@
1
+ /**
2
+ * Copyright (c) 2020-present, Goldman Sachs
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+
17
+ import { observer } from 'mobx-react-lite';
18
+ import {
19
+ type ExecutionPlanState,
20
+ EXECUTION_PLAN_VIEW_MODE,
21
+ } from '../../stores/execution-plan/ExecutionPlanState.js';
22
+ import {
23
+ PartialClassResultType,
24
+ PropertyGraphFetchTree,
25
+ RootGraphFetchTree,
26
+ type StoreMappingGlobalGraphFetchExecutionNode,
27
+ } from '@finos/legend-graph';
28
+ import {
29
+ PanelListItem,
30
+ PanelDivider,
31
+ Button,
32
+ PanelContent,
33
+ TreeView,
34
+ } from '@finos/legend-art';
35
+ import { guaranteeType, isNonNullable } from '@finos/legend-shared';
36
+ import {
37
+ buildGraphFetchTreeData,
38
+ buildPropertyGraphFetchTreeData,
39
+ type QueryBuilderGraphFetchTreeData,
40
+ type QueryBuilderGraphFetchTreeNodeData,
41
+ } from '../../stores/fetch-structure/graph-fetch/QueryBuilderGraphFetchTreeUtil.js';
42
+ import { QueryBuilderGraphFetchTreeNodeContainer } from '../fetch-structure/QueryBuilderGraphFetchTreePanel.js';
43
+ import { PartialClassResultTypeViewer } from './PartialClassResultViewer.js';
44
+
45
+ export const StoreMappingGlobalGraphFetchExecutionNodeViewer: React.FC<{
46
+ storeMappingNode: StoreMappingGlobalGraphFetchExecutionNode;
47
+ executionPlanState: ExecutionPlanState;
48
+ }> = observer((props) => {
49
+ const { storeMappingNode, executionPlanState } = props;
50
+
51
+ let treeData: QueryBuilderGraphFetchTreeData | undefined = undefined;
52
+ try {
53
+ if (storeMappingNode.graphFetchTree instanceof RootGraphFetchTree) {
54
+ treeData = buildGraphFetchTreeData(
55
+ guaranteeType(storeMappingNode.graphFetchTree, RootGraphFetchTree),
56
+ true,
57
+ );
58
+ } else if (
59
+ storeMappingNode.graphFetchTree instanceof PropertyGraphFetchTree
60
+ ) {
61
+ treeData = buildPropertyGraphFetchTreeData(
62
+ storeMappingNode.graphFetchTree,
63
+ );
64
+ }
65
+ } catch {
66
+ //do nothing
67
+ }
68
+
69
+ const getChildNodes = (
70
+ node: QueryBuilderGraphFetchTreeNodeData,
71
+ ): QueryBuilderGraphFetchTreeNodeData[] =>
72
+ node.childrenIds
73
+ .map((id) => {
74
+ if (treeData) {
75
+ return treeData.nodes.get(id);
76
+ }
77
+ return null;
78
+ })
79
+ .filter(isNonNullable);
80
+
81
+ const isReadOnly = true;
82
+ const applicationStore = executionPlanState.applicationStore;
83
+
84
+ return (
85
+ <PanelContent
86
+ darkMode={
87
+ !applicationStore.layoutService.TEMPORARY__isLightColorThemeEnabled
88
+ }
89
+ >
90
+ <div className="query-builder__store-mapping-global-graph-fetch__container">
91
+ <PanelListItem className="query-builder__store-mapping-global-graph-fetch__container__label">
92
+ Store Mapping Global Graph Fetch Execution Node Details
93
+ </PanelListItem>
94
+ <PanelDivider />
95
+ <table className="table query-builder__store-mapping-global-graph-fetch__container__table">
96
+ <thead>
97
+ <tr>
98
+ <th className="table__cell--left">Property</th>
99
+ <th className="table__cell--left">Details</th>
100
+ </tr>
101
+ </thead>
102
+ <tbody>
103
+ {storeMappingNode.parentIndex !== undefined && (
104
+ <tr>
105
+ <td className="table__cell--left"> ParentIndex</td>
106
+ <td className="table__cell--left">
107
+ {storeMappingNode.parentIndex}
108
+ </td>
109
+ </tr>
110
+ )}
111
+ {storeMappingNode.enableConstraints !== undefined && (
112
+ <tr>
113
+ <td className="table__cell--left">EnableConstraints</td>
114
+ <td className="table__cell--left">
115
+ {storeMappingNode.enableConstraints.toString()}
116
+ </td>
117
+ </tr>
118
+ )}
119
+ {storeMappingNode.checked !== undefined && (
120
+ <tr>
121
+ <td className="table__cell--left">Checked</td>
122
+ <td className="table__cell--left">
123
+ {storeMappingNode.checked.toString()}
124
+ </td>
125
+ </tr>
126
+ )}
127
+ {storeMappingNode.authDependent !== undefined && (
128
+ <tr>
129
+ <td className="table__cell--left">AuthDependent</td>
130
+ <td className="table__cell--left">
131
+ {storeMappingNode.authDependent.toString()}
132
+ </td>
133
+ </tr>
134
+ )}
135
+ {storeMappingNode.store && (
136
+ <tr>
137
+ <td className="table__cell--left">Store</td>
138
+ <td className="table__cell--left">{storeMappingNode.store}</td>
139
+ </tr>
140
+ )}
141
+ <tr>
142
+ <td className="table__cell--left">LocalTreeIndices</td>
143
+ <td className="table__cell--left">{`[${storeMappingNode.localTreeIndices.toString()}]`}</td>
144
+ </tr>
145
+ <tr>
146
+ <td className="table__cell--left">DependencyIndices</td>
147
+ <td className="table__cell--left">{`[${storeMappingNode.dependencyIndices.toString()}]`}</td>
148
+ </tr>
149
+ </tbody>
150
+ </table>
151
+ <PanelDivider />
152
+ {treeData && (
153
+ <>
154
+ <PanelListItem className="query-builder__store-mapping-global-graph-fetch__container__label2">
155
+ Graph Fetch Tree
156
+ </PanelListItem>
157
+ <div className="query-builder__store-mapping-global-graph-fetch__container__config-group__content">
158
+ <div className="query-builder__store-mapping-global-graph-fetch__container__config-group__item">
159
+ <TreeView
160
+ components={{
161
+ TreeNodeContainer: QueryBuilderGraphFetchTreeNodeContainer,
162
+ }}
163
+ className="query-builder-graph-fetch-tree__container__tree"
164
+ treeData={treeData}
165
+ getChildNodes={getChildNodes}
166
+ innerProps={{
167
+ isReadOnly,
168
+ }}
169
+ />
170
+ </div>
171
+ </div>
172
+ <PanelDivider />
173
+ </>
174
+ )}
175
+ {storeMappingNode.xStorePropertyFetchDetails && (
176
+ <>
177
+ <PanelListItem className="query-builder__store-mapping-global-graph-fetch__container__xstore">
178
+ xStorePropertyFetchDetails
179
+ </PanelListItem>
180
+ <PanelDivider />
181
+ <table className="table query-builder__store-mapping-global-graph-fetch__container__table">
182
+ <thead>
183
+ <tr>
184
+ <th className="table__cell--left">Property</th>
185
+ <th className="table__cell--left">Details</th>
186
+ </tr>
187
+ </thead>
188
+ <tbody>
189
+ <tr>
190
+ <td className="table__cell--left"> propertyPath </td>
191
+ <td className="table__cell--left">
192
+ {storeMappingNode.xStorePropertyFetchDetails.propertyPath}
193
+ </td>
194
+ </tr>
195
+ <tr>
196
+ <td className="table__cell--left"> sourceMappingId </td>
197
+ <td className="table__cell--left">
198
+ {
199
+ storeMappingNode.xStorePropertyFetchDetails
200
+ .sourceMappingId
201
+ }
202
+ </td>
203
+ </tr>
204
+ <tr>
205
+ <td className="table__cell--left"> sourceSetId </td>
206
+ <td className="table__cell--left">
207
+ {storeMappingNode.xStorePropertyFetchDetails.sourceSetId}
208
+ </td>
209
+ </tr>
210
+ <tr>
211
+ <td className="table__cell--left"> subTree </td>
212
+ <td className="table__cell--left">
213
+ {storeMappingNode.xStorePropertyFetchDetails.subTree}
214
+ </td>
215
+ </tr>
216
+ <tr>
217
+ <td className="table__cell--left"> supportsCaching </td>
218
+ <td className="table__cell--left">
219
+ {storeMappingNode.xStorePropertyFetchDetails.supportsCaching.toString()}
220
+ </td>
221
+ </tr>
222
+ <tr>
223
+ <td className="table__cell--left"> targetMappingId </td>
224
+ <td className="table__cell--left">
225
+ {
226
+ storeMappingNode.xStorePropertyFetchDetails
227
+ .targetMappingId
228
+ }
229
+ </td>
230
+ </tr>
231
+ <tr>
232
+ <td className="table__cell--left"> targetSetId</td>
233
+ <td className="table__cell--left">
234
+ {storeMappingNode.xStorePropertyFetchDetails.targetSetId}
235
+ </td>
236
+ </tr>
237
+ <tr>
238
+ <td className="table__cell--left">targetPropertiesOrdered</td>
239
+ <td className="table__cell--left">{`[${storeMappingNode.xStorePropertyFetchDetails.targetPropertiesOrdered.toString()}]`}</td>
240
+ </tr>
241
+ </tbody>
242
+ </table>
243
+ </>
244
+ )}
245
+ {storeMappingNode.resultType instanceof PartialClassResultType && (
246
+ <PartialClassResultTypeViewer
247
+ resultType={storeMappingNode.resultType}
248
+ />
249
+ )}
250
+ <PanelDivider />
251
+ <div className="query-builder__store-mapping-global-graph-fetch__container__btn">
252
+ <Button
253
+ className="btn--dark execution-node-viewer__unsupported-view__to-text-mode__btn"
254
+ onClick={(): void =>
255
+ executionPlanState.setViewMode(EXECUTION_PLAN_VIEW_MODE.JSON)
256
+ }
257
+ text="View JSON"
258
+ />
259
+ </div>
260
+ <PanelDivider />
261
+ </div>
262
+ </PanelContent>
263
+ );
264
+ });
@@ -0,0 +1,97 @@
1
+ /**
2
+ * Copyright (c) 2020-present, Goldman Sachs
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+
17
+ import { PanelDivider, PanelListItem } from '@finos/legend-art';
18
+ import {
19
+ LoadFromResultSetAsValueTuplesTempTableStrategy,
20
+ LoadFromSubQueryTempTableStrategy,
21
+ LoadFromTempFileTempTableStrategy,
22
+ type TempTableStrategy,
23
+ } from '@finos/legend-graph';
24
+ import { observer } from 'mobx-react-lite';
25
+ import {
26
+ ExecutionNodeViewer,
27
+ generateExecutionNodeLabel,
28
+ } from './ExecutionPlanViewer.js';
29
+ import { type ExecutionPlanState } from '../../stores/execution-plan/ExecutionPlanState.js';
30
+
31
+ export enum TEMP_TABLE_STRATEGY_TYPES {
32
+ RESULT_SET = 'resultSet',
33
+ TEMP_FILE = 'tempFile',
34
+ SUB_QUERY = 'subQuery',
35
+ }
36
+
37
+ export const TempTableStrategyViewer: React.FC<{
38
+ tempTableStrategy: TempTableStrategy;
39
+ executionPlanState: ExecutionPlanState;
40
+ }> = observer((props) => {
41
+ const { tempTableStrategy, executionPlanState } = props;
42
+ let _type = '';
43
+ if (
44
+ tempTableStrategy instanceof LoadFromResultSetAsValueTuplesTempTableStrategy
45
+ ) {
46
+ _type = TEMP_TABLE_STRATEGY_TYPES.RESULT_SET;
47
+ } else if (tempTableStrategy instanceof LoadFromTempFileTempTableStrategy) {
48
+ _type = TEMP_TABLE_STRATEGY_TYPES.TEMP_FILE;
49
+ }
50
+ if (tempTableStrategy instanceof LoadFromSubQueryTempTableStrategy) {
51
+ _type = TEMP_TABLE_STRATEGY_TYPES.SUB_QUERY;
52
+ }
53
+ return (
54
+ <div className="query-builder__temp-table-strategy__container">
55
+ {_type && (
56
+ <PanelListItem className="query-builder__temp-table-strategy__container__item">
57
+ Type: {_type}
58
+ </PanelListItem>
59
+ )}
60
+ <PanelListItem className="query-builder__temp-table-strategy__container__header">
61
+ {`Create Temp Table (${generateExecutionNodeLabel(
62
+ tempTableStrategy.createTempTableNode,
63
+ )})`}
64
+ </PanelListItem>
65
+ <ExecutionNodeViewer
66
+ executionNode={tempTableStrategy.createTempTableNode}
67
+ executionPlanState={executionPlanState}
68
+ viewJson={false}
69
+ />
70
+ <PanelDivider />
71
+
72
+ <PanelListItem className="query-builder__temp-table-strategy__container__header">
73
+ {`Load Temp Table (${generateExecutionNodeLabel(
74
+ tempTableStrategy.loadTempTableNode,
75
+ )})`}
76
+ </PanelListItem>
77
+ <ExecutionNodeViewer
78
+ executionNode={tempTableStrategy.loadTempTableNode}
79
+ executionPlanState={executionPlanState}
80
+ viewJson={false}
81
+ />
82
+ <PanelDivider />
83
+
84
+ <PanelListItem className="query-builder__temp-table-strategy__container__header">
85
+ {`Drop Temp Table (${generateExecutionNodeLabel(
86
+ tempTableStrategy.dropTempTableNode,
87
+ )})`}
88
+ </PanelListItem>
89
+ <ExecutionNodeViewer
90
+ executionNode={tempTableStrategy.dropTempTableNode}
91
+ executionPlanState={executionPlanState}
92
+ viewJson={false}
93
+ />
94
+ <PanelDivider />
95
+ </div>
96
+ );
97
+ });