@finos/legend-query-builder 4.15.2 → 4.15.4
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.
- package/lib/__lib__/QueryBuilderTesting.d.ts +1 -0
- package/lib/__lib__/QueryBuilderTesting.d.ts.map +1 -1
- package/lib/__lib__/QueryBuilderTesting.js +2 -0
- package/lib/__lib__/QueryBuilderTesting.js.map +1 -1
- package/lib/components/data-cube/QueryBuilderDataCube.d.ts.map +1 -1
- package/lib/components/data-cube/QueryBuilderDataCube.js +6 -7
- package/lib/components/data-cube/QueryBuilderDataCube.js.map +1 -1
- package/lib/components/explorer/QueryBuilderFunctionsExplorerPanel.d.ts.map +1 -1
- package/lib/components/explorer/QueryBuilderFunctionsExplorerPanel.js +38 -33
- package/lib/components/explorer/QueryBuilderFunctionsExplorerPanel.js.map +1 -1
- package/lib/components/fetch-structure/QueryBuilderTDSPanel.d.ts.map +1 -1
- package/lib/components/fetch-structure/QueryBuilderTDSPanel.js +12 -5
- package/lib/components/fetch-structure/QueryBuilderTDSPanel.js.map +1 -1
- package/lib/components/filter/QueryBuilderFilterPanel.js +2 -2
- package/lib/components/filter/QueryBuilderFilterPanel.js.map +1 -1
- package/lib/components/result/tds/QueryBuilderTDSGridResult.d.ts.map +1 -1
- package/lib/components/result/tds/QueryBuilderTDSGridResult.js +4 -3
- package/lib/components/result/tds/QueryBuilderTDSGridResult.js.map +1 -1
- package/lib/components/result/tds/QueryBuilderTDSResultShared.d.ts +2 -2
- package/lib/components/result/tds/QueryBuilderTDSResultShared.d.ts.map +1 -1
- package/lib/components/result/tds/QueryBuilderTDSResultShared.js +157 -19
- package/lib/components/result/tds/QueryBuilderTDSResultShared.js.map +1 -1
- package/lib/index.css +2 -2
- package/lib/index.css.map +1 -1
- package/lib/index.d.ts +1 -1
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js.map +1 -1
- package/lib/package.json +1 -1
- package/lib/stores/QueryBuilderState.d.ts +6 -1
- package/lib/stores/QueryBuilderState.d.ts.map +1 -1
- package/lib/stores/QueryBuilderState.js +3 -0
- package/lib/stores/QueryBuilderState.js.map +1 -1
- package/lib/stores/explorer/QueryFunctionsExplorerState.d.ts +17 -6
- package/lib/stores/explorer/QueryFunctionsExplorerState.d.ts.map +1 -1
- package/lib/stores/explorer/QueryFunctionsExplorerState.js +142 -59
- package/lib/stores/explorer/QueryFunctionsExplorerState.js.map +1 -1
- package/lib/stores/filter/QueryBuilderFilterOperator.d.ts +1 -1
- package/lib/stores/filter/QueryBuilderFilterOperator.d.ts.map +1 -1
- package/lib/stores/filter/QueryBuilderFilterState.d.ts +1 -1
- package/lib/stores/filter/QueryBuilderFilterState.d.ts.map +1 -1
- package/lib/stores/filter/QueryBuilderFilterState.js +8 -3
- package/lib/stores/filter/QueryBuilderFilterState.js.map +1 -1
- package/lib/stores/filter/QueryBuilderFilterStateBuilder.js +1 -1
- package/lib/stores/filter/QueryBuilderFilterStateBuilder.js.map +1 -1
- package/lib/stores/filter/operators/QueryBuilderFilterOperator_Contain.d.ts +2 -2
- package/lib/stores/filter/operators/QueryBuilderFilterOperator_Contain.d.ts.map +1 -1
- package/lib/stores/filter/operators/QueryBuilderFilterOperator_Contain.js +3 -3
- package/lib/stores/filter/operators/QueryBuilderFilterOperator_Contain.js.map +1 -1
- package/lib/stores/filter/operators/QueryBuilderFilterOperator_EndWith.d.ts +2 -2
- package/lib/stores/filter/operators/QueryBuilderFilterOperator_EndWith.d.ts.map +1 -1
- package/lib/stores/filter/operators/QueryBuilderFilterOperator_EndWith.js +3 -3
- package/lib/stores/filter/operators/QueryBuilderFilterOperator_EndWith.js.map +1 -1
- package/lib/stores/filter/operators/QueryBuilderFilterOperator_Equal.d.ts +2 -2
- package/lib/stores/filter/operators/QueryBuilderFilterOperator_Equal.d.ts.map +1 -1
- package/lib/stores/filter/operators/QueryBuilderFilterOperator_Equal.js +2 -2
- package/lib/stores/filter/operators/QueryBuilderFilterOperator_Equal.js.map +1 -1
- package/lib/stores/filter/operators/QueryBuilderFilterOperator_GreaterThan.d.ts +1 -1
- package/lib/stores/filter/operators/QueryBuilderFilterOperator_GreaterThan.d.ts.map +1 -1
- package/lib/stores/filter/operators/QueryBuilderFilterOperator_GreaterThan.js +2 -2
- package/lib/stores/filter/operators/QueryBuilderFilterOperator_GreaterThan.js.map +1 -1
- package/lib/stores/filter/operators/QueryBuilderFilterOperator_GreaterThanEqual.d.ts +1 -1
- package/lib/stores/filter/operators/QueryBuilderFilterOperator_GreaterThanEqual.d.ts.map +1 -1
- package/lib/stores/filter/operators/QueryBuilderFilterOperator_GreaterThanEqual.js +2 -2
- package/lib/stores/filter/operators/QueryBuilderFilterOperator_GreaterThanEqual.js.map +1 -1
- package/lib/stores/filter/operators/QueryBuilderFilterOperator_In.d.ts +2 -2
- package/lib/stores/filter/operators/QueryBuilderFilterOperator_In.d.ts.map +1 -1
- package/lib/stores/filter/operators/QueryBuilderFilterOperator_In.js +2 -2
- package/lib/stores/filter/operators/QueryBuilderFilterOperator_In.js.map +1 -1
- package/lib/stores/filter/operators/QueryBuilderFilterOperator_IsEmpty.d.ts +2 -2
- package/lib/stores/filter/operators/QueryBuilderFilterOperator_IsEmpty.d.ts.map +1 -1
- package/lib/stores/filter/operators/QueryBuilderFilterOperator_IsEmpty.js +2 -2
- package/lib/stores/filter/operators/QueryBuilderFilterOperator_IsEmpty.js.map +1 -1
- package/lib/stores/filter/operators/QueryBuilderFilterOperator_LessThan.d.ts +1 -1
- package/lib/stores/filter/operators/QueryBuilderFilterOperator_LessThan.d.ts.map +1 -1
- package/lib/stores/filter/operators/QueryBuilderFilterOperator_LessThan.js +2 -2
- package/lib/stores/filter/operators/QueryBuilderFilterOperator_LessThan.js.map +1 -1
- package/lib/stores/filter/operators/QueryBuilderFilterOperator_LessThanEqual.d.ts +1 -1
- package/lib/stores/filter/operators/QueryBuilderFilterOperator_LessThanEqual.d.ts.map +1 -1
- package/lib/stores/filter/operators/QueryBuilderFilterOperator_LessThanEqual.js +2 -2
- package/lib/stores/filter/operators/QueryBuilderFilterOperator_LessThanEqual.js.map +1 -1
- package/lib/stores/filter/operators/QueryBuilderFilterOperator_StartWith.d.ts +2 -2
- package/lib/stores/filter/operators/QueryBuilderFilterOperator_StartWith.d.ts.map +1 -1
- package/lib/stores/filter/operators/QueryBuilderFilterOperator_StartWith.js +3 -3
- package/lib/stores/filter/operators/QueryBuilderFilterOperator_StartWith.js.map +1 -1
- package/package.json +6 -6
- package/src/__lib__/QueryBuilderTesting.ts +2 -0
- package/src/components/data-cube/QueryBuilderDataCube.tsx +15 -25
- package/src/components/explorer/QueryBuilderFunctionsExplorerPanel.tsx +63 -70
- package/src/components/fetch-structure/QueryBuilderTDSPanel.tsx +23 -11
- package/src/components/filter/QueryBuilderFilterPanel.tsx +2 -2
- package/src/components/result/tds/QueryBuilderTDSGridResult.tsx +7 -3
- package/src/components/result/tds/QueryBuilderTDSResultShared.tsx +334 -26
- package/src/index.ts +1 -0
- package/src/stores/QueryBuilderState.ts +12 -0
- package/src/stores/explorer/QueryFunctionsExplorerState.ts +227 -94
- package/src/stores/filter/QueryBuilderFilterOperator.ts +1 -1
- package/src/stores/filter/QueryBuilderFilterState.ts +10 -5
- package/src/stores/filter/QueryBuilderFilterStateBuilder.ts +1 -1
- package/src/stores/filter/operators/QueryBuilderFilterOperator_Contain.ts +3 -5
- package/src/stores/filter/operators/QueryBuilderFilterOperator_EndWith.ts +3 -5
- package/src/stores/filter/operators/QueryBuilderFilterOperator_Equal.ts +2 -2
- package/src/stores/filter/operators/QueryBuilderFilterOperator_GreaterThan.ts +2 -4
- package/src/stores/filter/operators/QueryBuilderFilterOperator_GreaterThanEqual.ts +2 -4
- package/src/stores/filter/operators/QueryBuilderFilterOperator_In.ts +2 -2
- package/src/stores/filter/operators/QueryBuilderFilterOperator_IsEmpty.ts +2 -2
- package/src/stores/filter/operators/QueryBuilderFilterOperator_LessThan.ts +2 -4
- package/src/stores/filter/operators/QueryBuilderFilterOperator_LessThanEqual.ts +2 -4
- package/src/stores/filter/operators/QueryBuilderFilterOperator_StartWith.ts +3 -5
|
@@ -16,12 +16,16 @@
|
|
|
16
16
|
|
|
17
17
|
import {
|
|
18
18
|
type PackageableElement,
|
|
19
|
-
|
|
19
|
+
type FunctionAnalysisInfo,
|
|
20
|
+
type PureModel,
|
|
20
21
|
Package,
|
|
21
22
|
Unit,
|
|
22
23
|
ROOT_PACKAGE_NAME,
|
|
24
|
+
buildFunctionAnalysisInfoFromConcreteFunctionDefinition,
|
|
25
|
+
getOrCreateGraphPackage,
|
|
23
26
|
} from '@finos/legend-graph';
|
|
24
27
|
import {
|
|
28
|
+
ActionState,
|
|
25
29
|
addUniqueEntry,
|
|
26
30
|
guaranteeNonNullable,
|
|
27
31
|
isNonNullable,
|
|
@@ -47,16 +51,12 @@ export class QueryBuilderFunctionsExplorerTreeNodeData implements TreeNodeData {
|
|
|
47
51
|
label: string;
|
|
48
52
|
childrenIds: string[] = [];
|
|
49
53
|
isOpen?: boolean | undefined;
|
|
50
|
-
|
|
54
|
+
package?: PackageableElement;
|
|
55
|
+
functionAnalysisInfo?: FunctionAnalysisInfo | undefined;
|
|
51
56
|
|
|
52
|
-
constructor(
|
|
53
|
-
id: string,
|
|
54
|
-
label: string,
|
|
55
|
-
packageableElement: PackageableElement,
|
|
56
|
-
) {
|
|
57
|
+
constructor(id: string, label: string) {
|
|
57
58
|
this.id = id;
|
|
58
59
|
this.label = label;
|
|
59
|
-
this.packageableElement = packageableElement;
|
|
60
60
|
}
|
|
61
61
|
}
|
|
62
62
|
|
|
@@ -73,29 +73,38 @@ const getValidDisplayablePackageSet = (
|
|
|
73
73
|
}
|
|
74
74
|
};
|
|
75
75
|
|
|
76
|
-
|
|
76
|
+
const generateFunctionsExplorerTreeNodeDataFromPackage = (
|
|
77
77
|
queryBuilderState: QueryBuilderState,
|
|
78
|
-
element:
|
|
78
|
+
element: Package,
|
|
79
79
|
rootPackageName: ROOT_PACKAGE_NAME,
|
|
80
80
|
): QueryBuilderFunctionsExplorerTreeNodeData => ({
|
|
81
81
|
id: element.path,
|
|
82
82
|
label: element.name,
|
|
83
|
-
childrenIds:
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
83
|
+
childrenIds: element.children
|
|
84
|
+
.filter((child) => !(child instanceof Unit))
|
|
85
|
+
.filter(
|
|
86
|
+
(child) =>
|
|
87
|
+
child instanceof Package &&
|
|
88
|
+
getValidDisplayablePackageSet(queryBuilderState, rootPackageName).has(
|
|
89
|
+
child,
|
|
90
|
+
),
|
|
91
|
+
)
|
|
92
|
+
.map((child) => child.path)
|
|
93
|
+
.concat(
|
|
94
|
+
queryBuilderState.functionsExplorerState.packagePathToFunctionInfoMap
|
|
95
|
+
?.get(element.path)
|
|
96
|
+
?.map((info) => info.functionPath) ?? [],
|
|
97
|
+
),
|
|
98
|
+
package: element,
|
|
99
|
+
});
|
|
100
|
+
|
|
101
|
+
export const generateFunctionsExplorerTreeNodeDataFromFunctionAnalysisInfo = (
|
|
102
|
+
functionAnalysisInfo: FunctionAnalysisInfo,
|
|
103
|
+
): QueryBuilderFunctionsExplorerTreeNodeData => ({
|
|
104
|
+
id: functionAnalysisInfo.functionPath,
|
|
105
|
+
label: functionAnalysisInfo.name,
|
|
106
|
+
childrenIds: [],
|
|
107
|
+
functionAnalysisInfo: functionAnalysisInfo,
|
|
99
108
|
});
|
|
100
109
|
|
|
101
110
|
const generateFunctionsExplorerTreeNodeChilrdren = (
|
|
@@ -104,34 +113,48 @@ const generateFunctionsExplorerTreeNodeChilrdren = (
|
|
|
104
113
|
data: TreeData<QueryBuilderFunctionsExplorerTreeNodeData>,
|
|
105
114
|
rootPackageName = ROOT_PACKAGE_NAME.MAIN,
|
|
106
115
|
): void => {
|
|
116
|
+
const functionInfoMap =
|
|
117
|
+
rootPackageName === ROOT_PACKAGE_NAME.MAIN
|
|
118
|
+
? queryBuilderState.functionsExplorerState.functionInfoMap
|
|
119
|
+
: queryBuilderState.functionsExplorerState.dependencyFunctionInfoMap;
|
|
107
120
|
const validDisplayablePackageSet = getValidDisplayablePackageSet(
|
|
108
121
|
queryBuilderState,
|
|
109
122
|
rootPackageName,
|
|
110
123
|
);
|
|
111
|
-
|
|
112
|
-
.
|
|
113
|
-
|
|
114
|
-
(
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
child instanceof ConcreteFunctionDefinition,
|
|
118
|
-
)
|
|
119
|
-
.map((child) => child.path);
|
|
120
|
-
(node.packageableElement as Package).children
|
|
121
|
-
.filter((child) => !(child instanceof Unit))
|
|
124
|
+
const qualifiedExtraFunctionPaths =
|
|
125
|
+
queryBuilderState.functionsExplorerState.packagePathToFunctionInfoMap
|
|
126
|
+
?.get(node.id)
|
|
127
|
+
?.map((info) => info.functionPath);
|
|
128
|
+
|
|
129
|
+
const childrenPackages = (node.package as Package).children
|
|
122
130
|
.filter(
|
|
123
131
|
(child) =>
|
|
124
132
|
// avoid displaying empty packages
|
|
125
|
-
|
|
126
|
-
child instanceof ConcreteFunctionDefinition,
|
|
127
|
-
)
|
|
128
|
-
.map((child) =>
|
|
129
|
-
generateFunctionsExplorerTreeNodeData(
|
|
130
|
-
queryBuilderState,
|
|
131
|
-
child,
|
|
132
|
-
rootPackageName,
|
|
133
|
-
),
|
|
133
|
+
child instanceof Package && validDisplayablePackageSet.has(child),
|
|
134
134
|
)
|
|
135
|
+
.map((child) => child as Package);
|
|
136
|
+
|
|
137
|
+
node.childrenIds = childrenPackages
|
|
138
|
+
.map((child) => child.path)
|
|
139
|
+
.concat(qualifiedExtraFunctionPaths ?? []);
|
|
140
|
+
|
|
141
|
+
const childNodesFromPackage = childrenPackages.map((child) =>
|
|
142
|
+
generateFunctionsExplorerTreeNodeDataFromPackage(
|
|
143
|
+
queryBuilderState,
|
|
144
|
+
child,
|
|
145
|
+
rootPackageName,
|
|
146
|
+
),
|
|
147
|
+
);
|
|
148
|
+
|
|
149
|
+
const childNodesFromFunction = qualifiedExtraFunctionPaths
|
|
150
|
+
?.map((path) => functionInfoMap?.get(path))
|
|
151
|
+
.filter(isNonNullable)
|
|
152
|
+
.map((info) =>
|
|
153
|
+
generateFunctionsExplorerTreeNodeDataFromFunctionAnalysisInfo(info),
|
|
154
|
+
);
|
|
155
|
+
|
|
156
|
+
childNodesFromPackage
|
|
157
|
+
.concat(childNodesFromFunction ?? [])
|
|
135
158
|
.forEach((childNode) => {
|
|
136
159
|
const currentNode = data.nodes.get(childNode.id);
|
|
137
160
|
if (currentNode) {
|
|
@@ -157,14 +180,20 @@ export const getFunctionsExplorerTreeData = (
|
|
|
157
180
|
switch (rootPackageName) {
|
|
158
181
|
case ROOT_PACKAGE_NAME.PROJECT_DEPENDENCY_ROOT:
|
|
159
182
|
if (
|
|
160
|
-
queryBuilderState.
|
|
161
|
-
|
|
183
|
+
!queryBuilderState.functionsExplorerState.dependencyFunctionInfoMap ||
|
|
184
|
+
Array.from(
|
|
185
|
+
queryBuilderState.functionsExplorerState.dependencyFunctionInfoMap,
|
|
186
|
+
).length === 0
|
|
162
187
|
) {
|
|
163
188
|
return { rootIds, nodes };
|
|
164
189
|
}
|
|
165
190
|
break;
|
|
166
191
|
default:
|
|
167
|
-
if (
|
|
192
|
+
if (
|
|
193
|
+
!queryBuilderState.functionsExplorerState.functionInfoMap ||
|
|
194
|
+
Array.from(queryBuilderState.functionsExplorerState.functionInfoMap)
|
|
195
|
+
.length === 0
|
|
196
|
+
) {
|
|
168
197
|
return { rootIds, nodes };
|
|
169
198
|
}
|
|
170
199
|
}
|
|
@@ -172,22 +201,19 @@ export const getFunctionsExplorerTreeData = (
|
|
|
172
201
|
roots.forEach((root) => {
|
|
173
202
|
root.children
|
|
174
203
|
.slice()
|
|
175
|
-
.filter((child) => !(child instanceof Unit))
|
|
176
204
|
.filter(
|
|
177
205
|
(child) =>
|
|
178
206
|
child instanceof Package && validDisplayablePackageSet.has(child),
|
|
179
207
|
)
|
|
208
|
+
.map((child) => child as Package)
|
|
180
209
|
.sort((a, b) => a.name.localeCompare(b.name))
|
|
181
|
-
.sort(
|
|
182
|
-
(a, b) =>
|
|
183
|
-
(b instanceof Package ? 1 : 0) - (a instanceof Package ? 1 : 0),
|
|
184
|
-
)
|
|
185
210
|
.forEach((childPackage) => {
|
|
186
|
-
const childTreeNodeData =
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
211
|
+
const childTreeNodeData =
|
|
212
|
+
generateFunctionsExplorerTreeNodeDataFromPackage(
|
|
213
|
+
queryBuilderState,
|
|
214
|
+
childPackage,
|
|
215
|
+
rootPackageName,
|
|
216
|
+
);
|
|
191
217
|
addUniqueEntry(rootIds, childTreeNodeData.id);
|
|
192
218
|
nodes.set(childTreeNodeData.id, childTreeNodeData);
|
|
193
219
|
});
|
|
@@ -211,16 +237,14 @@ export const getFunctionsExplorerTreeNodeChildren = (
|
|
|
211
237
|
.map((id) => data.nodes.get(id))
|
|
212
238
|
.filter(isNonNullable)
|
|
213
239
|
.sort(compareLabelFn)
|
|
214
|
-
.sort(
|
|
215
|
-
(a, b) =>
|
|
216
|
-
(b.packageableElement instanceof Package ? 1 : 0) -
|
|
217
|
-
(a.packageableElement instanceof Package ? 1 : 0),
|
|
218
|
-
);
|
|
240
|
+
.sort((a, b) => (b.package ? 1 : 0) - (a.package ? 1 : 0));
|
|
219
241
|
};
|
|
220
242
|
|
|
221
243
|
const getAllPackagesFromElement = (element: PackageableElement): Package[] => {
|
|
222
244
|
if (element.package) {
|
|
223
|
-
return [element
|
|
245
|
+
return (element instanceof Package ? [element] : []).concat(
|
|
246
|
+
[element.package].concat(getAllPackagesFromElement(element.package)),
|
|
247
|
+
);
|
|
224
248
|
}
|
|
225
249
|
return [];
|
|
226
250
|
};
|
|
@@ -228,30 +252,36 @@ const getAllPackagesFromElement = (element: PackageableElement): Package[] => {
|
|
|
228
252
|
export class QueryFunctionExplorerState {
|
|
229
253
|
readonly uuid = uuid();
|
|
230
254
|
queryFunctionsState: QueryFunctionsExplorerState;
|
|
231
|
-
|
|
255
|
+
functionAnalysisInfo: FunctionAnalysisInfo;
|
|
232
256
|
|
|
233
257
|
constructor(
|
|
234
258
|
queryFunctionsState: QueryFunctionsExplorerState,
|
|
235
|
-
|
|
259
|
+
functionAnalysisInfo: FunctionAnalysisInfo,
|
|
236
260
|
) {
|
|
237
261
|
makeObservable(this, {
|
|
238
|
-
|
|
262
|
+
functionAnalysisInfo: observable,
|
|
239
263
|
});
|
|
240
264
|
this.queryFunctionsState = queryFunctionsState;
|
|
241
|
-
this.
|
|
265
|
+
this.functionAnalysisInfo = functionAnalysisInfo;
|
|
242
266
|
}
|
|
243
267
|
}
|
|
244
268
|
|
|
245
269
|
export class QueryFunctionsExplorerState {
|
|
270
|
+
readonly initState = ActionState.create();
|
|
271
|
+
|
|
246
272
|
queryBuilderState: QueryBuilderState;
|
|
247
273
|
treeData?: TreeData<QueryBuilderFunctionsExplorerTreeNodeData> | undefined;
|
|
248
274
|
dependencyTreeData?:
|
|
249
275
|
| TreeData<QueryBuilderFunctionsExplorerTreeNodeData>
|
|
250
276
|
| undefined;
|
|
277
|
+
_functionGraph: PureModel;
|
|
251
278
|
functionExplorerStates: QueryFunctionExplorerState[] = [];
|
|
252
279
|
dependencyFunctionExplorerStates: QueryFunctionExplorerState[] = [];
|
|
253
280
|
displayablePackagesSet: Set<Package> = new Set<Package>();
|
|
254
281
|
dependencyDisplayablePackagesSet: Set<Package> = new Set<Package>();
|
|
282
|
+
functionInfoMap?: Map<string, FunctionAnalysisInfo>;
|
|
283
|
+
dependencyFunctionInfoMap?: Map<string, FunctionAnalysisInfo>;
|
|
284
|
+
packagePathToFunctionInfoMap?: Map<string, FunctionAnalysisInfo[]>;
|
|
255
285
|
|
|
256
286
|
constructor(queryBuilderState: QueryBuilderState) {
|
|
257
287
|
makeObservable(this, {
|
|
@@ -259,13 +289,22 @@ export class QueryFunctionsExplorerState {
|
|
|
259
289
|
dependencyFunctionExplorerStates: observable.ref,
|
|
260
290
|
treeData: observable.ref,
|
|
261
291
|
dependencyTreeData: observable.ref,
|
|
292
|
+
_functionGraph: observable,
|
|
293
|
+
functionInfoMap: observable,
|
|
294
|
+
dependencyFunctionInfoMap: observable,
|
|
295
|
+
packagePathToFunctionInfoMap: observable,
|
|
296
|
+
setFunctionInfoMap: action,
|
|
297
|
+
setDependencyFunctionInfoMap: action,
|
|
262
298
|
setTreeData: action,
|
|
299
|
+
setPackagePathToFunctionInfoMap: action,
|
|
263
300
|
setDependencyTreeData: action,
|
|
264
301
|
refreshTree: action,
|
|
265
302
|
onTreeNodeSelect: action,
|
|
303
|
+
initializeTreeData: action,
|
|
266
304
|
});
|
|
267
305
|
this.queryBuilderState = queryBuilderState;
|
|
268
|
-
this.
|
|
306
|
+
this._functionGraph =
|
|
307
|
+
this.queryBuilderState.graphManagerState.createNewGraph();
|
|
269
308
|
}
|
|
270
309
|
|
|
271
310
|
getTreeData(
|
|
@@ -279,18 +318,48 @@ export class QueryFunctionsExplorerState {
|
|
|
279
318
|
}
|
|
280
319
|
}
|
|
281
320
|
|
|
321
|
+
setFunctionInfoMap(info: Map<string, FunctionAnalysisInfo>) {
|
|
322
|
+
this.functionInfoMap = info;
|
|
323
|
+
}
|
|
324
|
+
|
|
325
|
+
setDependencyFunctionInfoMap(info: Map<string, FunctionAnalysisInfo>) {
|
|
326
|
+
this.dependencyFunctionInfoMap = info;
|
|
327
|
+
}
|
|
328
|
+
|
|
329
|
+
setPackagePathToFunctionInfoMap(map: Map<string, FunctionAnalysisInfo[]>) {
|
|
330
|
+
this.packagePathToFunctionInfoMap = map;
|
|
331
|
+
}
|
|
332
|
+
|
|
282
333
|
async initializeDisplayablePackagesSet(): Promise<void> {
|
|
283
|
-
this.
|
|
284
|
-
.
|
|
285
|
-
|
|
286
|
-
|
|
334
|
+
if (this.functionInfoMap) {
|
|
335
|
+
Array.from(this.functionInfoMap.values())
|
|
336
|
+
.map((info) =>
|
|
337
|
+
getOrCreateGraphPackage(
|
|
338
|
+
this._functionGraph,
|
|
339
|
+
info.packagePath,
|
|
340
|
+
undefined,
|
|
341
|
+
),
|
|
342
|
+
)
|
|
343
|
+
.map((f) => getAllPackagesFromElement(f))
|
|
344
|
+
.flat()
|
|
345
|
+
.forEach((pkg) => this.displayablePackagesSet.add(pkg));
|
|
346
|
+
}
|
|
287
347
|
}
|
|
288
348
|
|
|
289
349
|
async initializeDependencyDisplayablePackagesSet(): Promise<void> {
|
|
290
|
-
this.
|
|
291
|
-
.
|
|
292
|
-
|
|
293
|
-
|
|
350
|
+
if (this.dependencyFunctionInfoMap) {
|
|
351
|
+
Array.from(this.dependencyFunctionInfoMap.values())
|
|
352
|
+
.map((info) =>
|
|
353
|
+
getOrCreateGraphPackage(
|
|
354
|
+
this._functionGraph,
|
|
355
|
+
info.packagePath,
|
|
356
|
+
undefined,
|
|
357
|
+
),
|
|
358
|
+
)
|
|
359
|
+
.map((f) => getAllPackagesFromElement(f))
|
|
360
|
+
.flat()
|
|
361
|
+
.forEach((pkg) => this.dependencyDisplayablePackagesSet.add(pkg));
|
|
362
|
+
}
|
|
294
363
|
}
|
|
295
364
|
|
|
296
365
|
setTreeData(
|
|
@@ -327,7 +396,7 @@ export class QueryFunctionsExplorerState {
|
|
|
327
396
|
data: TreeData<QueryBuilderFunctionsExplorerTreeNodeData>,
|
|
328
397
|
rootPackageName = ROOT_PACKAGE_NAME.MAIN,
|
|
329
398
|
): void => {
|
|
330
|
-
if (node.
|
|
399
|
+
if (node.package) {
|
|
331
400
|
if (node.childrenIds.length) {
|
|
332
401
|
node.isOpen = !node.isOpen;
|
|
333
402
|
generateFunctionsExplorerTreeNodeChilrdren(
|
|
@@ -347,41 +416,105 @@ export class QueryFunctionsExplorerState {
|
|
|
347
416
|
}
|
|
348
417
|
};
|
|
349
418
|
|
|
419
|
+
initializeFunctionInfoMap(): void {
|
|
420
|
+
const functionInfoMap = new Map<string, FunctionAnalysisInfo>();
|
|
421
|
+
const dependencyFunctionInfoMap = new Map<string, FunctionAnalysisInfo>();
|
|
422
|
+
const functionInfos =
|
|
423
|
+
buildFunctionAnalysisInfoFromConcreteFunctionDefinition(
|
|
424
|
+
this.queryBuilderState.graphManagerState.graph.ownFunctions,
|
|
425
|
+
this._functionGraph,
|
|
426
|
+
);
|
|
427
|
+
functionInfos.forEach((info) =>
|
|
428
|
+
functionInfoMap.set(info.functionPath, info),
|
|
429
|
+
);
|
|
430
|
+
if (
|
|
431
|
+
this.queryBuilderState.graphManagerState.graph.dependencyManager
|
|
432
|
+
.hasDependencies
|
|
433
|
+
) {
|
|
434
|
+
const dependencyFunctions =
|
|
435
|
+
this.queryBuilderState.graphManagerState.graph.dependencyManager
|
|
436
|
+
.functions;
|
|
437
|
+
const dependencyFunctionInfos =
|
|
438
|
+
buildFunctionAnalysisInfoFromConcreteFunctionDefinition(
|
|
439
|
+
dependencyFunctions,
|
|
440
|
+
this._functionGraph,
|
|
441
|
+
);
|
|
442
|
+
dependencyFunctionInfos.forEach((info) =>
|
|
443
|
+
dependencyFunctionInfoMap.set(info.functionPath, info),
|
|
444
|
+
);
|
|
445
|
+
}
|
|
446
|
+
const queryBuilderFunctionAnalysisInfo =
|
|
447
|
+
this.queryBuilderState.buildFunctionAnalysisInfo();
|
|
448
|
+
if (queryBuilderFunctionAnalysisInfo) {
|
|
449
|
+
Array.from(
|
|
450
|
+
queryBuilderFunctionAnalysisInfo.functionInfoMap.entries(),
|
|
451
|
+
).forEach(([path, info]) => functionInfoMap.set(path, info));
|
|
452
|
+
Array.from(
|
|
453
|
+
queryBuilderFunctionAnalysisInfo.dependencyFunctionInfoMap.entries(),
|
|
454
|
+
).forEach(([path, info]) => {
|
|
455
|
+
dependencyFunctionInfoMap.set(path, info);
|
|
456
|
+
});
|
|
457
|
+
}
|
|
458
|
+
const packagePathToFunctionInfoMap = new Map<
|
|
459
|
+
string,
|
|
460
|
+
FunctionAnalysisInfo[]
|
|
461
|
+
>();
|
|
462
|
+
Array.from(functionInfoMap.values())
|
|
463
|
+
.concat(Array.from(dependencyFunctionInfoMap.values()))
|
|
464
|
+
.forEach((info) => {
|
|
465
|
+
const curr = packagePathToFunctionInfoMap.get(info.packagePath);
|
|
466
|
+
if (curr) {
|
|
467
|
+
packagePathToFunctionInfoMap.set(info.packagePath, [...curr, info]);
|
|
468
|
+
} else {
|
|
469
|
+
packagePathToFunctionInfoMap.set(info.packagePath, [info]);
|
|
470
|
+
}
|
|
471
|
+
});
|
|
472
|
+
this.setPackagePathToFunctionInfoMap(packagePathToFunctionInfoMap);
|
|
473
|
+
this.setFunctionInfoMap(functionInfoMap);
|
|
474
|
+
this.setDependencyFunctionInfoMap(dependencyFunctionInfoMap);
|
|
475
|
+
}
|
|
476
|
+
|
|
350
477
|
initializeTreeData(): void {
|
|
478
|
+
if (!this.initState.isInInitialState) {
|
|
479
|
+
return;
|
|
480
|
+
}
|
|
481
|
+
|
|
482
|
+
this.initState.inProgress();
|
|
483
|
+
this.initializeFunctionInfoMap();
|
|
351
484
|
this.initializeDisplayablePackagesSet()
|
|
352
485
|
.catch(noop())
|
|
353
486
|
.finally(() => {
|
|
354
487
|
this.setTreeData(
|
|
355
488
|
getFunctionsExplorerTreeData(
|
|
356
|
-
[this.
|
|
489
|
+
[this._functionGraph.root],
|
|
357
490
|
this.queryBuilderState,
|
|
491
|
+
ROOT_PACKAGE_NAME.MAIN,
|
|
358
492
|
),
|
|
359
493
|
);
|
|
360
|
-
this.functionExplorerStates =
|
|
361
|
-
this.
|
|
362
|
-
|
|
363
|
-
|
|
494
|
+
this.functionExplorerStates = this.functionInfoMap
|
|
495
|
+
? Array.from(this.functionInfoMap.values()).map(
|
|
496
|
+
(info) => new QueryFunctionExplorerState(this, info),
|
|
497
|
+
)
|
|
498
|
+
: [];
|
|
364
499
|
});
|
|
365
|
-
if (
|
|
366
|
-
this.queryBuilderState.graphManagerState.graph.dependencyManager
|
|
367
|
-
.hasDependencies
|
|
368
|
-
) {
|
|
500
|
+
if (this.dependencyFunctionInfoMap) {
|
|
369
501
|
this.initializeDependencyDisplayablePackagesSet()
|
|
370
502
|
.catch(noop())
|
|
371
503
|
.finally(() => {
|
|
372
504
|
this.setDependencyTreeData(
|
|
373
505
|
getFunctionsExplorerTreeData(
|
|
374
|
-
this.
|
|
375
|
-
.roots,
|
|
506
|
+
[this._functionGraph.root],
|
|
376
507
|
this.queryBuilderState,
|
|
377
508
|
ROOT_PACKAGE_NAME.PROJECT_DEPENDENCY_ROOT,
|
|
378
509
|
),
|
|
379
510
|
);
|
|
380
|
-
this.dependencyFunctionExplorerStates =
|
|
381
|
-
this.
|
|
382
|
-
|
|
383
|
-
|
|
511
|
+
this.dependencyFunctionExplorerStates = this.dependencyFunctionInfoMap
|
|
512
|
+
? Array.from(this.dependencyFunctionInfoMap.values()).map(
|
|
513
|
+
(info) => new QueryFunctionExplorerState(this, info),
|
|
514
|
+
)
|
|
515
|
+
: [];
|
|
384
516
|
});
|
|
385
517
|
}
|
|
518
|
+
this.initState.pass();
|
|
386
519
|
}
|
|
387
520
|
}
|
|
@@ -27,7 +27,7 @@ import type {
|
|
|
27
27
|
export abstract class QueryBuilderFilterOperator implements Hashable {
|
|
28
28
|
readonly uuid = uuid();
|
|
29
29
|
|
|
30
|
-
abstract getLabel(
|
|
30
|
+
abstract getLabel(): string;
|
|
31
31
|
|
|
32
32
|
abstract isCompatibleWithFilterConditionProperty(
|
|
33
33
|
filterConditionState: FilterConditionState,
|
|
@@ -246,6 +246,7 @@ export class FilterConditionState implements Hashable {
|
|
|
246
246
|
constructor(
|
|
247
247
|
filterState: QueryBuilderFilterState,
|
|
248
248
|
propertyExpression: AbstractPropertyExpression,
|
|
249
|
+
operator?: QueryBuilderFilterOperator,
|
|
249
250
|
) {
|
|
250
251
|
makeObservable(this, {
|
|
251
252
|
propertyExpressionState: observable,
|
|
@@ -271,11 +272,15 @@ export class FilterConditionState implements Hashable {
|
|
|
271
272
|
);
|
|
272
273
|
|
|
273
274
|
// operator
|
|
274
|
-
|
|
275
|
-
this.
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
275
|
+
if (operator) {
|
|
276
|
+
this.operator = operator;
|
|
277
|
+
} else {
|
|
278
|
+
assertTrue(
|
|
279
|
+
this.operators.length !== 0,
|
|
280
|
+
`Can't find an operator for property '${this.propertyExpressionState.path}': no operators registered`,
|
|
281
|
+
);
|
|
282
|
+
this.operator = this.operators[0] as QueryBuilderFilterOperator;
|
|
283
|
+
}
|
|
279
284
|
this.buildRightConditionValueFromValueSpec(
|
|
280
285
|
this.operator.getDefaultFilterConditionValue(this),
|
|
281
286
|
);
|
|
@@ -332,7 +332,7 @@ const processFilterTree = (
|
|
|
332
332
|
assertTrue(
|
|
333
333
|
parentLambdaVariableName === variableName,
|
|
334
334
|
`Can't process ${extractElementNameFromPath(
|
|
335
|
-
filterConditionState.operator.getLabel(
|
|
335
|
+
filterConditionState.operator.getLabel(),
|
|
336
336
|
)}() expression: expects variable used in lambda body '${variableName}' to match lambda parameter '${parentLambdaVariableName}'`,
|
|
337
337
|
);
|
|
338
338
|
filterState.addNodeFromNode(
|
|
@@ -46,7 +46,7 @@ export class QueryBuilderFilterOperator_Contain
|
|
|
46
46
|
extends QueryBuilderFilterOperator
|
|
47
47
|
implements Hashable
|
|
48
48
|
{
|
|
49
|
-
getLabel(
|
|
49
|
+
getLabel(): string {
|
|
50
50
|
return 'contains';
|
|
51
51
|
}
|
|
52
52
|
|
|
@@ -90,9 +90,7 @@ export class QueryBuilderFilterOperator_Contain
|
|
|
90
90
|
}
|
|
91
91
|
default:
|
|
92
92
|
throw new UnsupportedOperationError(
|
|
93
|
-
`Can't get default value for filter operator '${this.getLabel(
|
|
94
|
-
filterConditionState,
|
|
95
|
-
)}' when the LHS property is of type '${propertyType.path}'`,
|
|
93
|
+
`Can't get default value for filter operator '${this.getLabel()}' when the LHS property is of type '${propertyType.path}'`,
|
|
96
94
|
);
|
|
97
95
|
}
|
|
98
96
|
}
|
|
@@ -128,7 +126,7 @@ export class QueryBuilderFilterOperator_Contain
|
|
|
128
126
|
}
|
|
129
127
|
|
|
130
128
|
export class QueryBuilderFilterOperator_NotContain extends QueryBuilderFilterOperator_Contain {
|
|
131
|
-
override getLabel(
|
|
129
|
+
override getLabel(): string {
|
|
132
130
|
return `doesn't contain`;
|
|
133
131
|
}
|
|
134
132
|
|
|
@@ -46,7 +46,7 @@ export class QueryBuilderFilterOperator_EndWith
|
|
|
46
46
|
extends QueryBuilderFilterOperator
|
|
47
47
|
implements Hashable
|
|
48
48
|
{
|
|
49
|
-
getLabel(
|
|
49
|
+
getLabel(): string {
|
|
50
50
|
return 'ends with';
|
|
51
51
|
}
|
|
52
52
|
|
|
@@ -90,9 +90,7 @@ export class QueryBuilderFilterOperator_EndWith
|
|
|
90
90
|
}
|
|
91
91
|
default:
|
|
92
92
|
throw new UnsupportedOperationError(
|
|
93
|
-
`Can't get default value for filter operator '${this.getLabel(
|
|
94
|
-
filterConditionState,
|
|
95
|
-
)}' when the LHS property is of type '${propertyType.path}'`,
|
|
93
|
+
`Can't get default value for filter operator '${this.getLabel()}' when the LHS property is of type '${propertyType.path}'`,
|
|
96
94
|
);
|
|
97
95
|
}
|
|
98
96
|
}
|
|
@@ -128,7 +126,7 @@ export class QueryBuilderFilterOperator_EndWith
|
|
|
128
126
|
}
|
|
129
127
|
|
|
130
128
|
export class QueryBuilderFilterOperator_NotEndWith extends QueryBuilderFilterOperator_EndWith {
|
|
131
|
-
override getLabel(
|
|
129
|
+
override getLabel(): string {
|
|
132
130
|
return `doesn't end with`;
|
|
133
131
|
}
|
|
134
132
|
|
|
@@ -44,7 +44,7 @@ export class QueryBuilderFilterOperator_Equal
|
|
|
44
44
|
extends QueryBuilderFilterOperator
|
|
45
45
|
implements Hashable
|
|
46
46
|
{
|
|
47
|
-
getLabel(
|
|
47
|
+
getLabel(): string {
|
|
48
48
|
return 'is';
|
|
49
49
|
}
|
|
50
50
|
|
|
@@ -143,7 +143,7 @@ export class QueryBuilderFilterOperator_Equal
|
|
|
143
143
|
}
|
|
144
144
|
|
|
145
145
|
export class QueryBuilderFilterOperator_NotEqual extends QueryBuilderFilterOperator_Equal {
|
|
146
|
-
override getLabel(
|
|
146
|
+
override getLabel(): string {
|
|
147
147
|
return `is not`;
|
|
148
148
|
}
|
|
149
149
|
|
|
@@ -43,7 +43,7 @@ export class QueryBuilderFilterOperator_GreaterThan
|
|
|
43
43
|
extends QueryBuilderFilterOperator
|
|
44
44
|
implements Hashable
|
|
45
45
|
{
|
|
46
|
-
getLabel(
|
|
46
|
+
getLabel(): string {
|
|
47
47
|
return '>';
|
|
48
48
|
}
|
|
49
49
|
|
|
@@ -104,9 +104,7 @@ export class QueryBuilderFilterOperator_GreaterThan
|
|
|
104
104
|
}
|
|
105
105
|
default:
|
|
106
106
|
throw new UnsupportedOperationError(
|
|
107
|
-
`Can't get default value for filter operator '${this.getLabel(
|
|
108
|
-
filterConditionState,
|
|
109
|
-
)}' when the LHS property is of type '${propertyType.path}'`,
|
|
107
|
+
`Can't get default value for filter operator '${this.getLabel()}' when the LHS property is of type '${propertyType.path}'`,
|
|
110
108
|
);
|
|
111
109
|
}
|
|
112
110
|
}
|
|
@@ -43,7 +43,7 @@ export class QueryBuilderFilterOperator_GreaterThanEqual
|
|
|
43
43
|
extends QueryBuilderFilterOperator
|
|
44
44
|
implements Hashable
|
|
45
45
|
{
|
|
46
|
-
getLabel(
|
|
46
|
+
getLabel(): string {
|
|
47
47
|
return '>=';
|
|
48
48
|
}
|
|
49
49
|
|
|
@@ -104,9 +104,7 @@ export class QueryBuilderFilterOperator_GreaterThanEqual
|
|
|
104
104
|
}
|
|
105
105
|
default:
|
|
106
106
|
throw new UnsupportedOperationError(
|
|
107
|
-
`Can't get default value for filter operator '${this.getLabel(
|
|
108
|
-
filterConditionState,
|
|
109
|
-
)}' when the LHS property is of type '${propertyType.path}'`,
|
|
107
|
+
`Can't get default value for filter operator '${this.getLabel()}' when the LHS property is of type '${propertyType.path}'`,
|
|
110
108
|
);
|
|
111
109
|
}
|
|
112
110
|
}
|
|
@@ -48,7 +48,7 @@ export class QueryBuilderFilterOperator_In
|
|
|
48
48
|
extends QueryBuilderFilterOperator
|
|
49
49
|
implements Hashable
|
|
50
50
|
{
|
|
51
|
-
getLabel(
|
|
51
|
+
getLabel(): string {
|
|
52
52
|
return 'is in list of';
|
|
53
53
|
}
|
|
54
54
|
|
|
@@ -176,7 +176,7 @@ export class QueryBuilderFilterOperator_In
|
|
|
176
176
|
}
|
|
177
177
|
|
|
178
178
|
export class QueryBuilderFilterOperator_NotIn extends QueryBuilderFilterOperator_In {
|
|
179
|
-
override getLabel(
|
|
179
|
+
override getLabel(): string {
|
|
180
180
|
return `is not in list of`;
|
|
181
181
|
}
|
|
182
182
|
|