@finos/legend-query-builder 4.2.4 → 4.3.1
Sign up to get free protection for your applications and to get access to all the features.
- package/lib/components/QueryBuilder.d.ts.map +1 -1
- package/lib/components/QueryBuilder.js +3 -1
- package/lib/components/QueryBuilder.js.map +1 -1
- package/lib/components/QueryBuilderResultPanel.d.ts.map +1 -1
- package/lib/components/QueryBuilderResultPanel.js +11 -2
- package/lib/components/QueryBuilderResultPanel.js.map +1 -1
- package/lib/components/QueryBuilderSideBar.d.ts +16 -0
- package/lib/components/QueryBuilderSideBar.d.ts.map +1 -1
- package/lib/components/QueryBuilderSideBar.js +85 -7
- package/lib/components/QueryBuilderSideBar.js.map +1 -1
- package/lib/components/QueryChat.d.ts.map +1 -1
- package/lib/components/QueryChat.js +1 -1
- package/lib/components/QueryChat.js.map +1 -1
- package/lib/components/__test-utils__/QueryBuilderComponentTestUtils.js +2 -2
- package/lib/components/__test-utils__/QueryBuilderComponentTestUtils.js.map +1 -1
- package/lib/components/explorer/QueryBuilderExplorerPanel.d.ts.map +1 -1
- package/lib/components/explorer/QueryBuilderExplorerPanel.js +5 -1
- package/lib/components/explorer/QueryBuilderExplorerPanel.js.map +1 -1
- package/lib/components/workflows/ClassQueryBuilder.d.ts.map +1 -1
- package/lib/components/workflows/ClassQueryBuilder.js +13 -9
- package/lib/components/workflows/ClassQueryBuilder.js.map +1 -1
- package/lib/components/workflows/MappingQueryBuilder.d.ts.map +1 -1
- package/lib/components/workflows/MappingQueryBuilder.js +13 -11
- package/lib/components/workflows/MappingQueryBuilder.js.map +1 -1
- package/lib/components/workflows/ServiceQueryBuilder.d.ts.map +1 -1
- package/lib/components/workflows/ServiceQueryBuilder.js +3 -2
- package/lib/components/workflows/ServiceQueryBuilder.js.map +1 -1
- package/lib/index.css +1 -1
- package/lib/index.d.ts +1 -0
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +1 -0
- package/lib/index.js.map +1 -1
- package/lib/package.json +1 -1
- package/lib/stores/QueryBuilderExecutionContextState.d.ts +34 -0
- package/lib/stores/QueryBuilderExecutionContextState.d.ts.map +1 -0
- package/lib/stores/QueryBuilderExecutionContextState.js +59 -0
- package/lib/stores/QueryBuilderExecutionContextState.js.map +1 -0
- package/lib/stores/QueryBuilderInternalizeState.d.ts +24 -0
- package/lib/stores/QueryBuilderInternalizeState.d.ts.map +1 -0
- package/lib/stores/QueryBuilderInternalizeState.js +26 -0
- package/lib/stores/QueryBuilderInternalizeState.js.map +1 -0
- package/lib/stores/QueryBuilderResultState.js +5 -5
- package/lib/stores/QueryBuilderResultState.js.map +1 -1
- package/lib/stores/QueryBuilderState.d.ts +7 -5
- package/lib/stores/QueryBuilderState.d.ts.map +1 -1
- package/lib/stores/QueryBuilderState.js +19 -17
- package/lib/stores/QueryBuilderState.js.map +1 -1
- package/lib/stores/QueryBuilderStateBuilder.d.ts +1 -1
- package/lib/stores/QueryBuilderStateBuilder.d.ts.map +1 -1
- package/lib/stores/QueryBuilderStateBuilder.js +27 -2
- package/lib/stores/QueryBuilderStateBuilder.js.map +1 -1
- package/lib/stores/QueryBuilderValueSpecificationBuilder.d.ts.map +1 -1
- package/lib/stores/QueryBuilderValueSpecificationBuilder.js +28 -2
- package/lib/stores/QueryBuilderValueSpecificationBuilder.js.map +1 -1
- package/lib/stores/__test-utils__/QueryBuilderStateTestUtils.d.ts.map +1 -1
- package/lib/stores/__test-utils__/QueryBuilderStateTestUtils.js +2 -2
- package/lib/stores/__test-utils__/QueryBuilderStateTestUtils.js.map +1 -1
- package/lib/stores/entitlements/QueryBuilderCheckEntitlementsState.d.ts.map +1 -1
- package/lib/stores/entitlements/QueryBuilderCheckEntitlementsState.js +6 -4
- package/lib/stores/entitlements/QueryBuilderCheckEntitlementsState.js.map +1 -1
- package/lib/stores/explorer/QueryBuilderExplorerState.js +9 -9
- package/lib/stores/explorer/QueryBuilderExplorerState.js.map +1 -1
- package/lib/stores/fetch-structure/graph-fetch/QueryBuilderGraphFetchTreeStateBuilder.d.ts +2 -1
- package/lib/stores/fetch-structure/graph-fetch/QueryBuilderGraphFetchTreeStateBuilder.d.ts.map +1 -1
- package/lib/stores/fetch-structure/graph-fetch/QueryBuilderGraphFetchTreeStateBuilder.js +25 -2
- package/lib/stores/fetch-structure/graph-fetch/QueryBuilderGraphFetchTreeStateBuilder.js.map +1 -1
- package/lib/stores/fetch-structure/tds/QueryBuilderTDSState.js +1 -1
- package/lib/stores/fetch-structure/tds/QueryBuilderTDSState.js.map +1 -1
- package/lib/stores/fetch-structure/tds/post-filter/QueryBuilderPostFilterState.d.ts.map +1 -1
- package/lib/stores/fetch-structure/tds/post-filter/QueryBuilderPostFilterState.js +3 -1
- package/lib/stores/fetch-structure/tds/post-filter/QueryBuilderPostFilterState.js.map +1 -1
- package/lib/stores/filter/QueryBuilderFilterState.d.ts.map +1 -1
- package/lib/stores/filter/QueryBuilderFilterState.js +2 -1
- package/lib/stores/filter/QueryBuilderFilterState.js.map +1 -1
- package/lib/stores/workflows/ClassQueryBuilderState.d.ts.map +1 -1
- package/lib/stores/workflows/ClassQueryBuilderState.js +2 -1
- package/lib/stores/workflows/ClassQueryBuilderState.js.map +1 -1
- package/lib/stores/workflows/FunctionQueryBuilderState.d.ts +23 -0
- package/lib/stores/workflows/FunctionQueryBuilderState.d.ts.map +1 -0
- package/lib/stores/workflows/FunctionQueryBuilderState.js +27 -0
- package/lib/stores/workflows/FunctionQueryBuilderState.js.map +1 -0
- package/lib/stores/workflows/ServiceQueryBuilderState.d.ts.map +1 -1
- package/lib/stores/workflows/ServiceQueryBuilderState.js +7 -7
- package/lib/stores/workflows/ServiceQueryBuilderState.js.map +1 -1
- package/package.json +4 -4
- package/src/components/QueryBuilder.tsx +5 -1
- package/src/components/QueryBuilderResultPanel.tsx +13 -3
- package/src/components/QueryBuilderSideBar.tsx +211 -7
- package/src/components/QueryChat.tsx +2 -1
- package/src/components/__test-utils__/QueryBuilderComponentTestUtils.tsx +2 -2
- package/src/components/explorer/QueryBuilderExplorerPanel.tsx +5 -1
- package/src/components/workflows/ClassQueryBuilder.tsx +17 -9
- package/src/components/workflows/MappingQueryBuilder.tsx +15 -11
- package/src/components/workflows/ServiceQueryBuilder.tsx +3 -2
- package/src/index.ts +1 -0
- package/src/stores/QueryBuilderExecutionContextState.ts +69 -0
- package/src/stores/QueryBuilderInternalizeState.ts +34 -0
- package/src/stores/QueryBuilderResultState.ts +6 -6
- package/src/stores/QueryBuilderState.ts +28 -21
- package/src/stores/QueryBuilderStateBuilder.ts +79 -1
- package/src/stores/QueryBuilderValueSpecificationBuilder.ts +50 -1
- package/src/stores/__test-utils__/QueryBuilderStateTestUtils.ts +4 -2
- package/src/stores/entitlements/QueryBuilderCheckEntitlementsState.ts +6 -4
- package/src/stores/explorer/QueryBuilderExplorerState.ts +9 -9
- package/src/stores/fetch-structure/graph-fetch/QueryBuilderGraphFetchTreeStateBuilder.ts +64 -2
- package/src/stores/fetch-structure/tds/QueryBuilderTDSState.ts +1 -1
- package/src/stores/fetch-structure/tds/post-filter/QueryBuilderPostFilterState.ts +4 -2
- package/src/stores/filter/QueryBuilderFilterState.ts +5 -2
- package/src/stores/workflows/ClassQueryBuilderState.ts +2 -1
- package/src/stores/workflows/FunctionQueryBuilderState.ts +38 -0
- package/src/stores/workflows/ServiceQueryBuilderState.ts +7 -11
- package/tsconfig.json +3 -0
@@ -71,11 +71,15 @@ const ClassQueryBuilderSetupPanelContent = observer(
|
|
71
71
|
)
|
72
72
|
: []
|
73
73
|
).map(buildElementOption);
|
74
|
-
const selectedMappingOption = queryBuilderState.
|
75
|
-
|
74
|
+
const selectedMappingOption = queryBuilderState.executionContextState
|
75
|
+
.mapping
|
76
|
+
? buildElementOption(queryBuilderState.executionContextState.mapping)
|
76
77
|
: null;
|
77
78
|
const changeMapping = (val: PackageableElementOption<Mapping>): void => {
|
78
|
-
if (
|
79
|
+
if (
|
80
|
+
!queryBuilderState.class ||
|
81
|
+
val.value === queryBuilderState.executionContextState.mapping
|
82
|
+
) {
|
79
83
|
return;
|
80
84
|
}
|
81
85
|
queryBuilderState.changeMapping(val.value);
|
@@ -90,9 +94,9 @@ const ClassQueryBuilderSetupPanelContent = observer(
|
|
90
94
|
|
91
95
|
// runtime
|
92
96
|
const runtimeOptions = (
|
93
|
-
queryBuilderState.mapping
|
97
|
+
queryBuilderState.executionContextState.mapping
|
94
98
|
? getMappingCompatibleRuntimes(
|
95
|
-
queryBuilderState.mapping,
|
99
|
+
queryBuilderState.executionContextState.mapping,
|
96
100
|
queryBuilderState.graphManagerState.usableRuntimes,
|
97
101
|
)
|
98
102
|
: []
|
@@ -102,11 +106,14 @@ const ClassQueryBuilderSetupPanelContent = observer(
|
|
102
106
|
new RuntimePointer(PackageableElementExplicitReference.create(rt)),
|
103
107
|
)
|
104
108
|
.map(buildRuntimeValueOption);
|
105
|
-
const selectedRuntimeOption = queryBuilderState.
|
106
|
-
|
109
|
+
const selectedRuntimeOption = queryBuilderState.executionContextState
|
110
|
+
.runtimeValue
|
111
|
+
? buildRuntimeValueOption(
|
112
|
+
queryBuilderState.executionContextState.runtimeValue,
|
113
|
+
)
|
107
114
|
: null;
|
108
115
|
const changeRuntime = (val: { value: Runtime }): void => {
|
109
|
-
if (val.value === queryBuilderState.runtimeValue) {
|
116
|
+
if (val.value === queryBuilderState.executionContextState.runtimeValue) {
|
110
117
|
return;
|
111
118
|
}
|
112
119
|
queryBuilderState.changeRuntime(val.value);
|
@@ -177,7 +184,8 @@ const ClassQueryBuilderSetupPanelContent = observer(
|
|
177
184
|
placeholder="Choose a runtime..."
|
178
185
|
noMatchMessage="No compatible runtime found for specified mapping"
|
179
186
|
disabled={
|
180
|
-
!queryBuilderState.class ||
|
187
|
+
!queryBuilderState.class ||
|
188
|
+
!queryBuilderState.executionContextState.mapping
|
181
189
|
}
|
182
190
|
options={runtimeOptions}
|
183
191
|
onChange={changeRuntime}
|
@@ -62,11 +62,12 @@ const MappingQueryBuilderSetupPanelContent = observer(
|
|
62
62
|
queryBuilderState.graphManagerState.usableMappings.map(
|
63
63
|
buildElementOption,
|
64
64
|
);
|
65
|
-
const selectedMappingOption = queryBuilderState.
|
66
|
-
|
65
|
+
const selectedMappingOption = queryBuilderState.executionContextState
|
66
|
+
.mapping
|
67
|
+
? buildElementOption(queryBuilderState.executionContextState.mapping)
|
67
68
|
: null;
|
68
69
|
const changeMapping = (val: PackageableElementOption<Mapping>): void => {
|
69
|
-
if (val.value === queryBuilderState.mapping) {
|
70
|
+
if (val.value === queryBuilderState.executionContextState.mapping) {
|
70
71
|
return;
|
71
72
|
}
|
72
73
|
queryBuilderState.changeMapping(val.value);
|
@@ -82,9 +83,9 @@ const MappingQueryBuilderSetupPanelContent = observer(
|
|
82
83
|
|
83
84
|
// runtime
|
84
85
|
const runtimeOptions = (
|
85
|
-
queryBuilderState.mapping
|
86
|
+
queryBuilderState.executionContextState.mapping
|
86
87
|
? getMappingCompatibleRuntimes(
|
87
|
-
queryBuilderState.mapping,
|
88
|
+
queryBuilderState.executionContextState.mapping,
|
88
89
|
queryBuilderState.graphManagerState.usableRuntimes,
|
89
90
|
)
|
90
91
|
: []
|
@@ -94,11 +95,14 @@ const MappingQueryBuilderSetupPanelContent = observer(
|
|
94
95
|
new RuntimePointer(PackageableElementExplicitReference.create(rt)),
|
95
96
|
)
|
96
97
|
.map(buildRuntimeValueOption);
|
97
|
-
const selectedRuntimeOption = queryBuilderState.
|
98
|
-
|
98
|
+
const selectedRuntimeOption = queryBuilderState.executionContextState
|
99
|
+
.runtimeValue
|
100
|
+
? buildRuntimeValueOption(
|
101
|
+
queryBuilderState.executionContextState.runtimeValue,
|
102
|
+
)
|
99
103
|
: null;
|
100
104
|
const changeRuntime = (val: { value: Runtime }): void => {
|
101
|
-
if (val.value === queryBuilderState.runtimeValue) {
|
105
|
+
if (val.value === queryBuilderState.executionContextState.runtimeValue) {
|
102
106
|
return;
|
103
107
|
}
|
104
108
|
queryBuilderState.changeRuntime(val.value);
|
@@ -113,9 +117,9 @@ const MappingQueryBuilderSetupPanelContent = observer(
|
|
113
117
|
});
|
114
118
|
|
115
119
|
// class
|
116
|
-
const classes = queryBuilderState.mapping
|
120
|
+
const classes = queryBuilderState.executionContextState.mapping
|
117
121
|
? getMappingCompatibleClasses(
|
118
|
-
queryBuilderState.mapping,
|
122
|
+
queryBuilderState.executionContextState.mapping,
|
119
123
|
queryBuilderState.graphManagerState.usableClasses,
|
120
124
|
)
|
121
125
|
: [];
|
@@ -170,7 +174,7 @@ const MappingQueryBuilderSetupPanelContent = observer(
|
|
170
174
|
className="panel__content__form__section__dropdown query-builder__setup__config-group__item__selector"
|
171
175
|
placeholder="Choose a runtime..."
|
172
176
|
noMatchMessage="No compatible runtime found for specified mapping"
|
173
|
-
disabled={!queryBuilderState.mapping}
|
177
|
+
disabled={!queryBuilderState.executionContextState.mapping}
|
174
178
|
options={runtimeOptions}
|
175
179
|
onChange={changeRuntime}
|
176
180
|
value={selectedRuntimeOption}
|
@@ -47,6 +47,7 @@ const buildExecutionContextOption = (
|
|
47
47
|
*
|
48
48
|
* See details on propagation/cascading in {@link ServiceQueryBuilderState}
|
49
49
|
*/
|
50
|
+
// TODO: add mapping/runtime for `from` queries
|
50
51
|
const ServiceQueryBuilderSetupPanelContent = observer(
|
51
52
|
(props: { queryBuilderState: ServiceQueryBuilderState }) => {
|
52
53
|
const { queryBuilderState } = props;
|
@@ -87,9 +88,9 @@ const ServiceQueryBuilderSetupPanelContent = observer(
|
|
87
88
|
};
|
88
89
|
|
89
90
|
// class
|
90
|
-
const classes = queryBuilderState.mapping
|
91
|
+
const classes = queryBuilderState.executionContextState.mapping
|
91
92
|
? getMappingCompatibleClasses(
|
92
|
-
queryBuilderState.mapping,
|
93
|
+
queryBuilderState.executionContextState.mapping,
|
93
94
|
queryBuilderState.graphManagerState.usableClasses,
|
94
95
|
)
|
95
96
|
: [];
|
package/src/index.ts
CHANGED
@@ -37,6 +37,7 @@ export {
|
|
37
37
|
getRuntimeOptionFormatter,
|
38
38
|
} from './components/QueryBuilderSideBar.js';
|
39
39
|
export { ClassQueryBuilderState } from './stores/workflows/ClassQueryBuilderState.js';
|
40
|
+
export { FunctionQueryBuilderState } from './stores/workflows/FunctionQueryBuilderState.js';
|
40
41
|
export { MappingQueryBuilderState } from './stores/workflows/MappingQueryBuilderState.js';
|
41
42
|
export {
|
42
43
|
type ServiceExecutionContext,
|
@@ -0,0 +1,69 @@
|
|
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 type { Mapping, Runtime } from '@finos/legend-graph';
|
18
|
+
import type { QueryBuilderState } from './QueryBuilderState.js';
|
19
|
+
import { action, makeObservable, observable } from 'mobx';
|
20
|
+
|
21
|
+
export abstract class QueryBuilderExecutionContextState {
|
22
|
+
readonly queryBuilderState: QueryBuilderState;
|
23
|
+
mapping: Mapping | undefined;
|
24
|
+
runtimeValue: Runtime | undefined;
|
25
|
+
|
26
|
+
constructor(queryBuilderState: QueryBuilderState) {
|
27
|
+
this.queryBuilderState = queryBuilderState;
|
28
|
+
}
|
29
|
+
|
30
|
+
setMapping(val: Mapping | undefined): void {
|
31
|
+
this.mapping = val;
|
32
|
+
}
|
33
|
+
|
34
|
+
setRuntimeValue(val: Runtime | undefined): void {
|
35
|
+
this.runtimeValue = val;
|
36
|
+
}
|
37
|
+
|
38
|
+
get specifiedInQuery(): boolean {
|
39
|
+
return true;
|
40
|
+
}
|
41
|
+
}
|
42
|
+
|
43
|
+
export class QueryBuilderEmbeddedFromExecutionContextState extends QueryBuilderExecutionContextState {
|
44
|
+
constructor(queryBuilderState: QueryBuilderState) {
|
45
|
+
super(queryBuilderState);
|
46
|
+
makeObservable(this, {
|
47
|
+
mapping: observable,
|
48
|
+
runtimeValue: observable,
|
49
|
+
setMapping: action,
|
50
|
+
setRuntimeValue: action,
|
51
|
+
});
|
52
|
+
}
|
53
|
+
}
|
54
|
+
|
55
|
+
export class QueryBuilderExternalExecutionContextState extends QueryBuilderExecutionContextState {
|
56
|
+
constructor(queryBuilderState: QueryBuilderState) {
|
57
|
+
super(queryBuilderState);
|
58
|
+
makeObservable(this, {
|
59
|
+
mapping: observable,
|
60
|
+
runtimeValue: observable,
|
61
|
+
setMapping: action,
|
62
|
+
setRuntimeValue: action,
|
63
|
+
});
|
64
|
+
}
|
65
|
+
|
66
|
+
override get specifiedInQuery(): boolean {
|
67
|
+
return false;
|
68
|
+
}
|
69
|
+
}
|
@@ -0,0 +1,34 @@
|
|
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 type { QueryBuilderState } from './QueryBuilderState.js';
|
18
|
+
import type { Binding, VariableExpression } from '@finos/legend-graph';
|
19
|
+
|
20
|
+
export class QueryBuilderInternalizeState {
|
21
|
+
readonly queryBuilderState: QueryBuilderState;
|
22
|
+
binding: Binding;
|
23
|
+
inputData: VariableExpression;
|
24
|
+
|
25
|
+
constructor(
|
26
|
+
binding: Binding,
|
27
|
+
inputData: VariableExpression,
|
28
|
+
queryBuilderState: QueryBuilderState,
|
29
|
+
) {
|
30
|
+
this.queryBuilderState = queryBuilderState;
|
31
|
+
this.binding = binding;
|
32
|
+
this.inputData = inputData;
|
33
|
+
}
|
34
|
+
}
|
@@ -217,8 +217,8 @@ export class QueryBuilderResultState {
|
|
217
217
|
const result =
|
218
218
|
(yield this.queryBuilderState.graphManagerState.graphManager.runQuery(
|
219
219
|
query,
|
220
|
-
this.queryBuilderState.mapping,
|
221
|
-
this.queryBuilderState.runtimeValue,
|
220
|
+
this.queryBuilderState.executionContextState.mapping,
|
221
|
+
this.queryBuilderState.executionContextState.runtimeValue,
|
222
222
|
this.queryBuilderState.graphManagerState.graph,
|
223
223
|
{
|
224
224
|
serializationFormat,
|
@@ -260,11 +260,11 @@ export class QueryBuilderResultState {
|
|
260
260
|
this.setIsRunningQuery(true);
|
261
261
|
const currentHashCode = this.queryBuilderState.hashCode;
|
262
262
|
const mapping = guaranteeNonNullable(
|
263
|
-
this.queryBuilderState.mapping,
|
263
|
+
this.queryBuilderState.executionContextState.mapping,
|
264
264
|
'Mapping is required to execute query',
|
265
265
|
);
|
266
266
|
const runtime = guaranteeNonNullable(
|
267
|
-
this.queryBuilderState.runtimeValue,
|
267
|
+
this.queryBuilderState.executionContextState.runtimeValue,
|
268
268
|
`Runtime is required to execute query`,
|
269
269
|
);
|
270
270
|
const query = this.buildExecutionRawLambda();
|
@@ -350,11 +350,11 @@ export class QueryBuilderResultState {
|
|
350
350
|
try {
|
351
351
|
this.isGeneratingPlan = true;
|
352
352
|
const mapping = guaranteeNonNullable(
|
353
|
-
this.queryBuilderState.mapping,
|
353
|
+
this.queryBuilderState.executionContextState.mapping,
|
354
354
|
'Mapping is required to execute query',
|
355
355
|
);
|
356
356
|
const runtime = guaranteeNonNullable(
|
357
|
-
this.queryBuilderState.runtimeValue,
|
357
|
+
this.queryBuilderState.executionContextState.runtimeValue,
|
358
358
|
`Runtime is required to execute query`,
|
359
359
|
);
|
360
360
|
const query = this.queryBuilderState.buildQuery();
|
@@ -51,6 +51,8 @@ import {
|
|
51
51
|
type Mapping,
|
52
52
|
type Runtime,
|
53
53
|
type GraphManagerState,
|
54
|
+
type ValueSpecification,
|
55
|
+
type Type,
|
54
56
|
GRAPH_MANAGER_EVENT,
|
55
57
|
CompilationError,
|
56
58
|
extractSourceInformationCoordinates,
|
@@ -62,9 +64,7 @@ import {
|
|
62
64
|
isStubbed_RawLambda,
|
63
65
|
buildLambdaVariableExpressions,
|
64
66
|
buildRawLambdaFromLambdaFunction,
|
65
|
-
type ValueSpecification,
|
66
67
|
PrimitiveType,
|
67
|
-
type Type,
|
68
68
|
SimpleFunctionExpression,
|
69
69
|
extractElementNameFromPath,
|
70
70
|
SUPPORTED_FUNCTIONS,
|
@@ -94,6 +94,11 @@ import { QueryBuilderConstantsState } from './QueryBuilderConstantsState.js';
|
|
94
94
|
import { QueryBuilderCheckEntitlementsState } from './entitlements/QueryBuilderCheckEntitlementsState.js';
|
95
95
|
import { QueryBuilderTDSState } from './fetch-structure/tds/QueryBuilderTDSState.js';
|
96
96
|
import { QUERY_BUILDER_PURE_PATH } from '../graph/QueryBuilderMetaModelConst.js';
|
97
|
+
import type { QueryBuilderInternalizeState } from './QueryBuilderInternalizeState.js';
|
98
|
+
import {
|
99
|
+
QueryBuilderExternalExecutionContextState,
|
100
|
+
type QueryBuilderExecutionContextState,
|
101
|
+
} from './QueryBuilderExecutionContextState.js';
|
97
102
|
|
98
103
|
export abstract class QueryBuilderState implements CommandRegistrar {
|
99
104
|
readonly applicationStore: GenericLegendApplicationStore;
|
@@ -125,8 +130,8 @@ export abstract class QueryBuilderState implements CommandRegistrar {
|
|
125
130
|
isQueryChatOpened = false;
|
126
131
|
|
127
132
|
class?: Class | undefined;
|
128
|
-
|
129
|
-
|
133
|
+
executionContextState: QueryBuilderExecutionContextState;
|
134
|
+
internalizeState?: QueryBuilderInternalizeState | undefined;
|
130
135
|
|
131
136
|
// NOTE: this makes it so that we need to import components in stores code,
|
132
137
|
// we probably want to refactor to an extension mechanism
|
@@ -154,9 +159,8 @@ export abstract class QueryBuilderState implements CommandRegistrar {
|
|
154
159
|
isCheckingEntitlments: observable,
|
155
160
|
isCalendarEnabled: observable,
|
156
161
|
changeDetectionState: observable,
|
162
|
+
executionContextState: observable,
|
157
163
|
class: observable,
|
158
|
-
mapping: observable,
|
159
|
-
runtimeValue: observable,
|
160
164
|
isQueryChatOpened: observable,
|
161
165
|
|
162
166
|
sideBarClassName: computed,
|
@@ -169,14 +173,13 @@ export abstract class QueryBuilderState implements CommandRegistrar {
|
|
169
173
|
setIsCalendarEnabled: action,
|
170
174
|
setIsCheckingEntitlments: action,
|
171
175
|
setClass: action,
|
172
|
-
setMapping: action,
|
173
|
-
setRuntimeValue: action,
|
174
176
|
setIsQueryChatOpened: action,
|
175
177
|
|
176
178
|
resetQueryResult: action,
|
177
179
|
resetQueryContent: action,
|
178
180
|
changeClass: action,
|
179
181
|
changeMapping: action,
|
182
|
+
setExecutionContextState: action,
|
180
183
|
|
181
184
|
rebuildWithQuery: action,
|
182
185
|
compileQuery: flow,
|
@@ -185,7 +188,9 @@ export abstract class QueryBuilderState implements CommandRegistrar {
|
|
185
188
|
|
186
189
|
this.applicationStore = applicationStore;
|
187
190
|
this.graphManagerState = graphManagerState;
|
188
|
-
|
191
|
+
this.executionContextState = new QueryBuilderExternalExecutionContextState(
|
192
|
+
this,
|
193
|
+
);
|
189
194
|
this.milestoningState = new QueryBuilderMilestoningState(this);
|
190
195
|
this.explorerState = new QueryBuilderExplorerState(this);
|
191
196
|
this.parametersState = new QueryBuilderParametersState(this);
|
@@ -250,6 +255,10 @@ export abstract class QueryBuilderState implements CommandRegistrar {
|
|
250
255
|
this.isQueryChatOpened = val;
|
251
256
|
}
|
252
257
|
|
258
|
+
setInternalize(val: QueryBuilderInternalizeState | undefined): void {
|
259
|
+
this.internalizeState = val;
|
260
|
+
}
|
261
|
+
|
253
262
|
setShowFunctionsExplorerPanel(val: boolean): void {
|
254
263
|
this.showFunctionsExplorerPanel = val;
|
255
264
|
}
|
@@ -274,12 +283,8 @@ export abstract class QueryBuilderState implements CommandRegistrar {
|
|
274
283
|
this.class = val;
|
275
284
|
}
|
276
285
|
|
277
|
-
|
278
|
-
this.
|
279
|
-
}
|
280
|
-
|
281
|
-
setRuntimeValue(val: Runtime | undefined): void {
|
282
|
-
this.runtimeValue = val;
|
286
|
+
setExecutionContextState(val: QueryBuilderExecutionContextState): void {
|
287
|
+
this.executionContextState = val;
|
283
288
|
}
|
284
289
|
|
285
290
|
get isQuerySupported(): boolean {
|
@@ -373,12 +378,12 @@ export abstract class QueryBuilderState implements CommandRegistrar {
|
|
373
378
|
this.resetQueryContent();
|
374
379
|
this.milestoningState.updateMilestoningConfiguration();
|
375
380
|
}
|
376
|
-
this.setMapping(val);
|
381
|
+
this.executionContextState.setMapping(val);
|
377
382
|
}
|
378
383
|
|
379
384
|
changeRuntime(val: Runtime): void {
|
380
385
|
this.resetQueryResult();
|
381
|
-
this.setRuntimeValue(val);
|
386
|
+
this.executionContextState.setRuntimeValue(val);
|
382
387
|
}
|
383
388
|
|
384
389
|
getCurrentParameterValues(): Map<string, ValueSpecification> | undefined {
|
@@ -421,11 +426,11 @@ export abstract class QueryBuilderState implements CommandRegistrar {
|
|
421
426
|
'Query must be supported to build from function',
|
422
427
|
);
|
423
428
|
const mapping = guaranteeNonNullable(
|
424
|
-
this.mapping,
|
429
|
+
this.executionContextState.mapping,
|
425
430
|
'Mapping required to build from() function',
|
426
431
|
);
|
427
432
|
const runtime = guaranteeNonNullable(
|
428
|
-
this.runtimeValue,
|
433
|
+
this.executionContextState.runtimeValue,
|
429
434
|
'Runtime required to build from query',
|
430
435
|
);
|
431
436
|
const runtimePointer = guaranteeType(
|
@@ -666,8 +671,10 @@ export abstract class QueryBuilderState implements CommandRegistrar {
|
|
666
671
|
this.graphManagerState,
|
667
672
|
);
|
668
673
|
basicState.class = this.class;
|
669
|
-
basicState.mapping =
|
670
|
-
|
674
|
+
basicState.executionContextState.mapping =
|
675
|
+
this.executionContextState.mapping;
|
676
|
+
basicState.executionContextState.runtimeValue =
|
677
|
+
this.executionContextState.runtimeValue;
|
671
678
|
return basicState;
|
672
679
|
}
|
673
680
|
|
@@ -30,7 +30,7 @@ import {
|
|
30
30
|
type FunctionExpression,
|
31
31
|
type GraphFetchTreeInstanceValue,
|
32
32
|
type ValueSpecificationVisitor,
|
33
|
-
|
33
|
+
InstanceValue,
|
34
34
|
type INTERNAL__UnknownValueSpecification,
|
35
35
|
type LambdaFunction,
|
36
36
|
type KeyExpressionInstanceValue,
|
@@ -47,6 +47,11 @@ import {
|
|
47
47
|
type ValueSpecification,
|
48
48
|
SUPPORTED_FUNCTIONS,
|
49
49
|
isSuperType,
|
50
|
+
PackageableElementReference,
|
51
|
+
Mapping,
|
52
|
+
PackageableRuntime,
|
53
|
+
RuntimePointer,
|
54
|
+
PackageableElementExplicitReference,
|
50
55
|
} from '@finos/legend-graph';
|
51
56
|
import { processTDSPostFilterExpression } from './fetch-structure/tds/post-filter/QueryBuilderPostFilterStateBuilder.js';
|
52
57
|
import { processFilterExpression } from './filter/QueryBuilderFilterStateBuilder.js';
|
@@ -58,6 +63,7 @@ import {
|
|
58
63
|
processGraphFetchExpression,
|
59
64
|
processGraphFetchExternalizeExpression,
|
60
65
|
processGraphFetchSerializeExpression,
|
66
|
+
processInternalizeExpression,
|
61
67
|
} from './fetch-structure/graph-fetch/QueryBuilderGraphFetchTreeStateBuilder.js';
|
62
68
|
import {
|
63
69
|
processTDSDistinctExpression,
|
@@ -78,6 +84,7 @@ import { processWatermarkExpression } from './watermark/QueryBuilderWatermarkSta
|
|
78
84
|
import { QueryBuilderConstantExpressionState } from './QueryBuilderConstantsState.js';
|
79
85
|
import { checkIfEquivalent } from './milestoning/QueryBuilderMilestoningHelper.js';
|
80
86
|
import type { QueryBuilderParameterValue } from './QueryBuilderParametersState.js';
|
87
|
+
import { QueryBuilderEmbeddedFromExecutionContextState } from './QueryBuilderExecutionContextState.js';
|
81
88
|
|
82
89
|
const processGetAllExpression = (
|
83
90
|
expression: SimpleFunctionExpression,
|
@@ -146,6 +153,51 @@ const processLetExpression = (
|
|
146
153
|
queryBuilderState.constantState.addConstant(constantExpression);
|
147
154
|
};
|
148
155
|
|
156
|
+
const processFromFunction = (
|
157
|
+
expression: SimpleFunctionExpression,
|
158
|
+
queryBuilderState: QueryBuilderState,
|
159
|
+
): void => {
|
160
|
+
// mapping
|
161
|
+
const mappingInstanceExpression = guaranteeType(
|
162
|
+
expression.parametersValues[1],
|
163
|
+
InstanceValue,
|
164
|
+
`Can't process from() expression: only support from() with 1st parameter as instance value`,
|
165
|
+
);
|
166
|
+
const mapping = guaranteeType(
|
167
|
+
guaranteeType(
|
168
|
+
mappingInstanceExpression.values[0],
|
169
|
+
PackageableElementReference,
|
170
|
+
`Can't process from() expression: only support from() with 1st parameter as packagableElement value`,
|
171
|
+
).value,
|
172
|
+
Mapping,
|
173
|
+
`Can't process from() expression: only support from() with 1st parameter as mapping value`,
|
174
|
+
);
|
175
|
+
// runtime
|
176
|
+
const runtimeInstanceExpression = guaranteeType(
|
177
|
+
expression.parametersValues[2],
|
178
|
+
InstanceValue,
|
179
|
+
`Can't process from() expression: only support from() with 2nd parameter as instance value`,
|
180
|
+
);
|
181
|
+
const runtimeVal = guaranteeType(
|
182
|
+
guaranteeType(
|
183
|
+
runtimeInstanceExpression.values[0],
|
184
|
+
PackageableElementReference,
|
185
|
+
`Can't process from() expression: only support from() with 2nd parameter as packagableElement value`,
|
186
|
+
).value,
|
187
|
+
PackageableRuntime,
|
188
|
+
`Can't process from() expression: only support from() with 2nd parameter as runtime value`,
|
189
|
+
);
|
190
|
+
const fromContext = new QueryBuilderEmbeddedFromExecutionContextState(
|
191
|
+
queryBuilderState,
|
192
|
+
);
|
193
|
+
fromContext.setMapping(mapping);
|
194
|
+
fromContext.setRuntimeValue(
|
195
|
+
new RuntimePointer(PackageableElementExplicitReference.create(runtimeVal)),
|
196
|
+
);
|
197
|
+
queryBuilderState.setExecutionContextState(fromContext);
|
198
|
+
return;
|
199
|
+
};
|
200
|
+
|
149
201
|
/**
|
150
202
|
* This is the value specification processor (a.k.a state builder) for query builder.
|
151
203
|
*
|
@@ -321,6 +373,18 @@ export class QueryBuilderValueSpecificationProcessor
|
|
321
373
|
) {
|
322
374
|
processGetAllExpression(valueSpecification, this.queryBuilderState);
|
323
375
|
return;
|
376
|
+
} else if (
|
377
|
+
matchFunctionName(
|
378
|
+
functionName,
|
379
|
+
QUERY_BUILDER_SUPPORTED_FUNCTIONS.INTERNALIZE,
|
380
|
+
)
|
381
|
+
) {
|
382
|
+
processInternalizeExpression(
|
383
|
+
valueSpecification,
|
384
|
+
this.queryBuilderState,
|
385
|
+
this.parentLambda,
|
386
|
+
);
|
387
|
+
return;
|
324
388
|
} else if (
|
325
389
|
matchFunctionName(functionName, [
|
326
390
|
QUERY_BUILDER_SUPPORTED_FUNCTIONS.FILTER,
|
@@ -545,6 +609,20 @@ export class QueryBuilderValueSpecificationProcessor
|
|
545
609
|
this.parentLambda,
|
546
610
|
);
|
547
611
|
return;
|
612
|
+
} else if (matchFunctionName(functionName, [SUPPORTED_FUNCTIONS.FROM])) {
|
613
|
+
const parameters = valueSpecification.parametersValues;
|
614
|
+
assertTrue(
|
615
|
+
parameters.length === 3,
|
616
|
+
'From function expects 2 parameters (mapping and runtime)',
|
617
|
+
);
|
618
|
+
processFromFunction(valueSpecification, this.queryBuilderState);
|
619
|
+
QueryBuilderValueSpecificationProcessor.processChild(
|
620
|
+
guaranteeNonNullable(parameters[0]),
|
621
|
+
valueSpecification,
|
622
|
+
this.parentLambda,
|
623
|
+
this.queryBuilderState,
|
624
|
+
);
|
625
|
+
return;
|
548
626
|
} else if (
|
549
627
|
matchFunctionName(
|
550
628
|
functionName,
|
@@ -14,7 +14,7 @@
|
|
14
14
|
* limitations under the License.
|
15
15
|
*/
|
16
16
|
|
17
|
-
import { guaranteeNonNullable } from '@finos/legend-shared';
|
17
|
+
import { guaranteeNonNullable, guaranteeType } from '@finos/legend-shared';
|
18
18
|
import {
|
19
19
|
type Class,
|
20
20
|
Multiplicity,
|
@@ -31,6 +31,7 @@ import {
|
|
31
31
|
PrimitiveInstanceValue,
|
32
32
|
PrimitiveType,
|
33
33
|
SUPPORTED_FUNCTIONS,
|
34
|
+
RuntimePointer,
|
34
35
|
} from '@finos/legend-graph';
|
35
36
|
import type { QueryBuilderState } from './QueryBuilderState.js';
|
36
37
|
import { buildFilterExpression } from './filter/QueryBuilderFilterValueSpecificationBuilder.js';
|
@@ -40,6 +41,10 @@ import { QUERY_BUILDER_SUPPORTED_FUNCTIONS } from '../graph/QueryBuilderMetaMode
|
|
40
41
|
import { buildWatermarkExpression } from './watermark/QueryBuilderWatermarkValueSpecificationBuilder.js';
|
41
42
|
import { buildExecutionQueryFromLambdaFunction } from './shared/LambdaParameterState.js';
|
42
43
|
import type { QueryBuilderConstantExpressionState } from './QueryBuilderConstantsState.js';
|
44
|
+
import {
|
45
|
+
QueryBuilderEmbeddedFromExecutionContextState,
|
46
|
+
type QueryBuilderExecutionContextState,
|
47
|
+
} from './QueryBuilderExecutionContextState.js';
|
43
48
|
|
44
49
|
export const buildGetAllFunction = (
|
45
50
|
_class: Class,
|
@@ -91,6 +96,45 @@ const buildLetExpression = (
|
|
91
96
|
return letFunc;
|
92
97
|
};
|
93
98
|
|
99
|
+
const buildExecutionContextState = (
|
100
|
+
executionState: QueryBuilderExecutionContextState,
|
101
|
+
lambdaFunction: LambdaFunction,
|
102
|
+
): LambdaFunction => {
|
103
|
+
if (executionState instanceof QueryBuilderEmbeddedFromExecutionContextState) {
|
104
|
+
const precedingExpression = guaranteeNonNullable(
|
105
|
+
lambdaFunction.expressionSequence[0],
|
106
|
+
`Can't build from() expression: preceding expression is not defined`,
|
107
|
+
);
|
108
|
+
const fromFunc = new SimpleFunctionExpression(
|
109
|
+
extractElementNameFromPath(SUPPORTED_FUNCTIONS.FROM),
|
110
|
+
);
|
111
|
+
// 1st param
|
112
|
+
const mapping = guaranteeNonNullable(
|
113
|
+
executionState.mapping,
|
114
|
+
'Mapping required for building from() expression',
|
115
|
+
);
|
116
|
+
const mappingInstance = new InstanceValue(Multiplicity.ONE, undefined);
|
117
|
+
mappingInstance.values = [
|
118
|
+
PackageableElementExplicitReference.create(mapping),
|
119
|
+
];
|
120
|
+
// 2nd parameter
|
121
|
+
const runtime = guaranteeType(
|
122
|
+
executionState.runtimeValue,
|
123
|
+
RuntimePointer,
|
124
|
+
'Runtime Pointer required for building from() expression',
|
125
|
+
);
|
126
|
+
const runtimeInstance = new InstanceValue(Multiplicity.ONE, undefined);
|
127
|
+
runtimeInstance.values = [runtime.packageableRuntime];
|
128
|
+
fromFunc.parametersValues = [
|
129
|
+
precedingExpression,
|
130
|
+
mappingInstance,
|
131
|
+
runtimeInstance,
|
132
|
+
];
|
133
|
+
lambdaFunction.expressionSequence[0] = fromFunc;
|
134
|
+
}
|
135
|
+
return lambdaFunction;
|
136
|
+
};
|
137
|
+
|
94
138
|
const buildFetchStructure = (
|
95
139
|
fetchStructureState: QueryBuilderFetchStructureState,
|
96
140
|
lambdaFunction: LambdaFunction,
|
@@ -157,6 +201,11 @@ export const buildLambdaFunction = (
|
|
157
201
|
lambdaFunction,
|
158
202
|
options,
|
159
203
|
);
|
204
|
+
// build execution-state
|
205
|
+
buildExecutionContextState(
|
206
|
+
queryBuilderState.executionContextState,
|
207
|
+
lambdaFunction,
|
208
|
+
);
|
160
209
|
|
161
210
|
// build variable expressions
|
162
211
|
if (queryBuilderState.constantState.constants.length) {
|
@@ -138,9 +138,11 @@ export const TEST__setUpQueryBuilderState = async (
|
|
138
138
|
if (executionContext) {
|
139
139
|
const graph = queryBuilderState.graphManagerState.graph;
|
140
140
|
queryBuilderState.class = graph.getClass(executionContext._class);
|
141
|
-
queryBuilderState.mapping = graph.getMapping(
|
141
|
+
queryBuilderState.executionContextState.mapping = graph.getMapping(
|
142
|
+
executionContext.mapping,
|
143
|
+
);
|
142
144
|
if (executionContext.runtime) {
|
143
|
-
queryBuilderState.runtimeValue = graph.getRuntime(
|
145
|
+
queryBuilderState.executionContextState.runtimeValue = graph.getRuntime(
|
144
146
|
executionContext.runtime,
|
145
147
|
);
|
146
148
|
}
|