@finos/legend-query-builder 4.2.3 → 4.3.0
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/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/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
@@ -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
|
}
|
@@ -53,16 +53,18 @@ export class QueryBuilderCheckEntitlementsState implements Hashable {
|
|
53
53
|
|
54
54
|
this.dataAccessState = undefined;
|
55
55
|
if (
|
56
|
-
this.queryBuilderState.mapping &&
|
57
|
-
this.queryBuilderState.runtimeValue instanceof
|
56
|
+
this.queryBuilderState.executionContextState.mapping &&
|
57
|
+
this.queryBuilderState.executionContextState.runtimeValue instanceof
|
58
|
+
RuntimePointer
|
58
59
|
) {
|
59
60
|
this.dataAccessState = new DataAccessState(
|
60
61
|
this.queryBuilderState.applicationStore,
|
61
62
|
this.queryBuilderState.graphManagerState,
|
62
63
|
{
|
63
|
-
mapping: this.queryBuilderState.mapping.path,
|
64
|
+
mapping: this.queryBuilderState.executionContextState.mapping.path,
|
64
65
|
runtime:
|
65
|
-
this.queryBuilderState.runtimeValue
|
66
|
+
this.queryBuilderState.executionContextState.runtimeValue
|
67
|
+
.packageableRuntime.value.path,
|
66
68
|
getQuery: async () =>
|
67
69
|
this.createExecutableQuery(
|
68
70
|
this.queryBuilderState.buildQuery(),
|
@@ -660,7 +660,7 @@ export class QueryBuilderExplorerState {
|
|
660
660
|
|
661
661
|
refreshTreeData(): void {
|
662
662
|
const _class = this.queryBuilderState.class;
|
663
|
-
const _mapping = this.queryBuilderState.mapping;
|
663
|
+
const _mapping = this.queryBuilderState.executionContextState.mapping;
|
664
664
|
this.setTreeData(
|
665
665
|
_class && _mapping && this.mappingModelCoverageAnalysisResult
|
666
666
|
? getQueryBuilderTreeData(
|
@@ -675,9 +675,9 @@ export class QueryBuilderExplorerState {
|
|
675
675
|
// We will only refetch if the analysis result's mapping has changed.
|
676
676
|
// This makes the assumption that the mapping has not been edited, which is a valid assumption since query is not for editing mappings
|
677
677
|
if (
|
678
|
-
this.queryBuilderState.mapping &&
|
679
|
-
this.queryBuilderState.mapping
|
680
|
-
this.mappingModelCoverageAnalysisResult?.mapping
|
678
|
+
this.queryBuilderState.executionContextState.mapping &&
|
679
|
+
this.queryBuilderState.executionContextState.mapping !==
|
680
|
+
this.mappingModelCoverageAnalysisResult?.mapping
|
681
681
|
) {
|
682
682
|
this.mappingModelCoverageAnalysisState.inProgress();
|
683
683
|
QueryBuilderTelemetryHelper.logEvent_QueryMappingModelCoverageAnalysisLaunched(
|
@@ -692,7 +692,7 @@ export class QueryBuilderExplorerState {
|
|
692
692
|
try {
|
693
693
|
this.mappingModelCoverageAnalysisResult = (yield flowResult(
|
694
694
|
this.queryBuilderState.graphManagerState.graphManager.analyzeMappingModelCoverage(
|
695
|
-
this.queryBuilderState.mapping,
|
695
|
+
this.queryBuilderState.executionContextState.mapping,
|
696
696
|
this.queryBuilderState.graphManagerState.graph,
|
697
697
|
),
|
698
698
|
)) as MappingModelCoverageAnalysisResult;
|
@@ -720,7 +720,7 @@ export class QueryBuilderExplorerState {
|
|
720
720
|
*previewData(
|
721
721
|
node: QueryBuilderExplorerTreePropertyNodeData,
|
722
722
|
): GeneratorFn<void> {
|
723
|
-
const runtime = this.queryBuilderState.runtimeValue;
|
723
|
+
const runtime = this.queryBuilderState.executionContextState.runtimeValue;
|
724
724
|
if (!runtime) {
|
725
725
|
this.queryBuilderState.applicationStore.notificationService.notifyWarning(
|
726
726
|
`Can't preview data for property '${node.property.name}': runtime is not specified`,
|
@@ -730,7 +730,7 @@ export class QueryBuilderExplorerState {
|
|
730
730
|
if (
|
731
731
|
!node.mappingData.mapped ||
|
732
732
|
!this.queryBuilderState.class ||
|
733
|
-
!this.queryBuilderState.mapping
|
733
|
+
!this.queryBuilderState.executionContextState.mapping
|
734
734
|
) {
|
735
735
|
return;
|
736
736
|
}
|
@@ -759,7 +759,7 @@ export class QueryBuilderExplorerState {
|
|
759
759
|
this.queryBuilderState,
|
760
760
|
propertyExpression,
|
761
761
|
),
|
762
|
-
this.queryBuilderState.mapping,
|
762
|
+
this.queryBuilderState.executionContextState.mapping,
|
763
763
|
runtime,
|
764
764
|
this.queryBuilderState.graphManagerState.graph,
|
765
765
|
)) as ExecutionResult;
|
@@ -796,7 +796,7 @@ export class QueryBuilderExplorerState {
|
|
796
796
|
this.queryBuilderState,
|
797
797
|
propertyExpression,
|
798
798
|
),
|
799
|
-
this.queryBuilderState.mapping,
|
799
|
+
this.queryBuilderState.executionContextState.mapping,
|
800
800
|
runtime,
|
801
801
|
this.queryBuilderState.graphManagerState.graph,
|
802
802
|
)) as ExecutionResult;
|
@@ -32,11 +32,13 @@ import {
|
|
32
32
|
CollectionInstanceValue,
|
33
33
|
getClassProperty,
|
34
34
|
PrimitiveType,
|
35
|
+
VariableExpression,
|
35
36
|
} from '@finos/legend-graph';
|
36
37
|
import {
|
37
38
|
assertIsBoolean,
|
38
39
|
assertIsString,
|
39
40
|
assertTrue,
|
41
|
+
assertType,
|
40
42
|
guaranteeIsString,
|
41
43
|
guaranteeNonNullable,
|
42
44
|
guaranteeType,
|
@@ -45,7 +47,7 @@ import {
|
|
45
47
|
QUERY_BUILDER_PURE_PATH,
|
46
48
|
QUERY_BUILDER_SUPPORTED_FUNCTIONS,
|
47
49
|
} from '../../../graph/QueryBuilderMetaModelConst.js';
|
48
|
-
import type
|
50
|
+
import { type QueryBuilderState } from '../../QueryBuilderState.js';
|
49
51
|
import { QueryBuilderValueSpecificationProcessor } from '../../QueryBuilderStateBuilder.js';
|
50
52
|
import { FETCH_STRUCTURE_IMPLEMENTATION } from '../QueryBuilderFetchStructureImplementationState.js';
|
51
53
|
import {
|
@@ -56,6 +58,7 @@ import {
|
|
56
58
|
} from './QueryBuilderGraphFetchTreeState.js';
|
57
59
|
import { buildGraphFetchTreeData } from './QueryBuilderGraphFetchTreeUtil.js';
|
58
60
|
import {} from 'mobx';
|
61
|
+
import { QueryBuilderInternalizeState } from '../../QueryBuilderInternalizeState.js';
|
59
62
|
|
60
63
|
export const processGraphFetchExpression = (
|
61
64
|
expression: SimpleFunctionExpression,
|
@@ -105,6 +108,65 @@ export const processGraphFetchExpression = (
|
|
105
108
|
}
|
106
109
|
};
|
107
110
|
|
111
|
+
export const processInternalizeExpression = (
|
112
|
+
expression: SimpleFunctionExpression,
|
113
|
+
queryBuilderState: QueryBuilderState,
|
114
|
+
parentLambda: LambdaFunction,
|
115
|
+
): void => {
|
116
|
+
// update fetch-structure
|
117
|
+
queryBuilderState.fetchStructureState.changeImplementation(
|
118
|
+
FETCH_STRUCTURE_IMPLEMENTATION.GRAPH_FETCH,
|
119
|
+
);
|
120
|
+
const functionName = expression.functionName;
|
121
|
+
// check parameters
|
122
|
+
assertTrue(
|
123
|
+
expression.parametersValues.length === 3,
|
124
|
+
`Can't process ${functionName}() expression: ${functionName}() expects 2 argument`,
|
125
|
+
);
|
126
|
+
|
127
|
+
// first param classs
|
128
|
+
const classVal = expression.parametersValues[0];
|
129
|
+
const _class = classVal?.genericType?.value.rawType;
|
130
|
+
assertType(
|
131
|
+
_class,
|
132
|
+
Class,
|
133
|
+
`Can't process internalize() expression: internalize() return type is missing`,
|
134
|
+
);
|
135
|
+
|
136
|
+
queryBuilderState.setClass(_class);
|
137
|
+
queryBuilderState.milestoningState.clearMilestoningDates();
|
138
|
+
queryBuilderState.explorerState.refreshTreeData();
|
139
|
+
|
140
|
+
// binding
|
141
|
+
const instanceExpression = guaranteeType(
|
142
|
+
expression.parametersValues[1],
|
143
|
+
InstanceValue,
|
144
|
+
`Can't process internalize() expression: only support internalize() with 1st parameter as instance value`,
|
145
|
+
);
|
146
|
+
const binding = guaranteeType(
|
147
|
+
guaranteeType(
|
148
|
+
instanceExpression.values[0],
|
149
|
+
PackageableElementReference,
|
150
|
+
`Can't process internalize() expression: only support internalize() with 1st parameter as packagableElement value`,
|
151
|
+
).value,
|
152
|
+
Binding,
|
153
|
+
`Can't process internalize() expression: only support internalize() with 1st parameter as binding value`,
|
154
|
+
);
|
155
|
+
|
156
|
+
const variableExpression = guaranteeType(
|
157
|
+
expression.parametersValues[2],
|
158
|
+
VariableExpression,
|
159
|
+
);
|
160
|
+
|
161
|
+
const inernalize = new QueryBuilderInternalizeState(
|
162
|
+
binding,
|
163
|
+
variableExpression,
|
164
|
+
queryBuilderState,
|
165
|
+
);
|
166
|
+
|
167
|
+
queryBuilderState.setInternalize(inernalize);
|
168
|
+
};
|
169
|
+
|
108
170
|
type PropertyValue = object | string | number | boolean;
|
109
171
|
|
110
172
|
// Dynamically sets key values of config
|
@@ -327,6 +389,7 @@ export const processGraphFetchExternalizeExpression = (
|
|
327
389
|
matchFunctionName(precedingExpression.functionName, [
|
328
390
|
QUERY_BUILDER_SUPPORTED_FUNCTIONS.GRAPH_FETCH,
|
329
391
|
QUERY_BUILDER_SUPPORTED_FUNCTIONS.GRAPH_FETCH_CHECKED,
|
392
|
+
QUERY_BUILDER_SUPPORTED_FUNCTIONS.INTERNALIZE,
|
330
393
|
]),
|
331
394
|
`Can't process externalize() expression: only support externalize() in graph-fetch expression`,
|
332
395
|
);
|
@@ -373,7 +436,6 @@ export const processGraphFetchExternalizeExpression = (
|
|
373
436
|
Binding,
|
374
437
|
`Can't process externalize() expression: only support externalize() with 1st parameter as binding value`,
|
375
438
|
);
|
376
|
-
|
377
439
|
const externalizeState = new GraphFetchExternalFormatSerializationState(
|
378
440
|
graphFetchTreeState,
|
379
441
|
binding,
|
@@ -452,7 +452,7 @@ export class QueryBuilderTDSState
|
|
452
452
|
new QueryBuilderDerivationProjectionColumnState(
|
453
453
|
this,
|
454
454
|
guaranteeType(
|
455
|
-
this.queryBuilderState.graphManagerState.graphManager.
|
455
|
+
this.queryBuilderState.graphManagerState.graphManager.transformValueSpecToRawValueSpec(
|
456
456
|
columnColumnLambda,
|
457
457
|
this.queryBuilderState.graphManagerState.graph,
|
458
458
|
),
|
@@ -380,10 +380,12 @@ export class PostFilterConditionState implements Hashable {
|
|
380
380
|
this.value,
|
381
381
|
),
|
382
382
|
guaranteeNonNullable(
|
383
|
-
this.postFilterState.tdsState.queryBuilderState
|
383
|
+
this.postFilterState.tdsState.queryBuilderState
|
384
|
+
.executionContextState.mapping,
|
384
385
|
),
|
385
386
|
guaranteeNonNullable(
|
386
|
-
this.postFilterState.tdsState.queryBuilderState
|
387
|
+
this.postFilterState.tdsState.queryBuilderState
|
388
|
+
.executionContextState.runtimeValue,
|
387
389
|
),
|
388
390
|
this.postFilterState.tdsState.queryBuilderState.graphManagerState
|
389
391
|
.graph,
|
@@ -134,9 +134,12 @@ export class FilterConditionState implements Hashable {
|
|
134
134
|
this.propertyExpressionState.propertyExpression,
|
135
135
|
this.value,
|
136
136
|
),
|
137
|
-
guaranteeNonNullable(this.filterState.queryBuilderState.mapping),
|
138
137
|
guaranteeNonNullable(
|
139
|
-
this.filterState.queryBuilderState.
|
138
|
+
this.filterState.queryBuilderState.executionContextState.mapping,
|
139
|
+
),
|
140
|
+
guaranteeNonNullable(
|
141
|
+
this.filterState.queryBuilderState.executionContextState
|
142
|
+
.runtimeValue,
|
140
143
|
),
|
141
144
|
this.filterState.queryBuilderState.graphManagerState.graph,
|
142
145
|
)) as ExecutionResult;
|
@@ -44,7 +44,8 @@ export class ClassQueryBuilderState extends QueryBuilderState {
|
|
44
44
|
);
|
45
45
|
// cascading
|
46
46
|
const isCurrentMappingCompatible =
|
47
|
-
this.mapping &&
|
47
|
+
this.executionContextState.mapping &&
|
48
|
+
compatibleMappings.includes(this.executionContextState.mapping);
|
48
49
|
if (this.isMappingReadOnly || isCurrentMappingCompatible) {
|
49
50
|
return;
|
50
51
|
}
|
@@ -0,0 +1,38 @@
|
|
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 { GenericLegendApplicationStore } from '@finos/legend-application';
|
18
|
+
import type {
|
19
|
+
ConcreteFunctionDefinition,
|
20
|
+
GraphManagerState,
|
21
|
+
} from '@finos/legend-graph';
|
22
|
+
import { ClassQueryBuilderState } from './ClassQueryBuilderState.js';
|
23
|
+
|
24
|
+
// Note: We may want to move it to extend QueryBuilderState directly
|
25
|
+
// but for now we will use the same setup as class as class, mapping, runtime are editable
|
26
|
+
export class FunctionQueryBuilderState extends ClassQueryBuilderState {
|
27
|
+
readonly functionElement: ConcreteFunctionDefinition;
|
28
|
+
|
29
|
+
constructor(
|
30
|
+
applicationStore: GenericLegendApplicationStore,
|
31
|
+
graphManagerState: GraphManagerState,
|
32
|
+
functionElemenet: ConcreteFunctionDefinition,
|
33
|
+
) {
|
34
|
+
super(applicationStore, graphManagerState);
|
35
|
+
this.functionElement = functionElemenet;
|
36
|
+
this.showParametersPanel = true;
|
37
|
+
}
|
38
|
+
}
|