@finos/legend-query-builder 4.14.29 → 4.14.31
Sign up to get free protection for your applications and to get access to all the features.
- package/lib/components/QueryBuilder.d.ts +1 -1
- package/lib/components/QueryBuilder.d.ts.map +1 -1
- package/lib/components/QueryBuilder.js +64 -7
- package/lib/components/QueryBuilder.js.map +1 -1
- package/lib/components/__test-utils__/QueryBuilderComponentTestUtils.d.ts.map +1 -1
- package/lib/components/__test-utils__/QueryBuilderComponentTestUtils.js +2 -1
- package/lib/components/__test-utils__/QueryBuilderComponentTestUtils.js.map +1 -1
- package/lib/components/fetch-structure/QueryBuilderFetchStructurePanel.d.ts.map +1 -1
- package/lib/components/fetch-structure/QueryBuilderFetchStructurePanel.js +5 -10
- package/lib/components/fetch-structure/QueryBuilderFetchStructurePanel.js.map +1 -1
- package/lib/graph/QueryBuilderMetaModelConst.d.ts +3 -0
- package/lib/graph/QueryBuilderMetaModelConst.d.ts.map +1 -1
- package/lib/graph/QueryBuilderMetaModelConst.js +5 -0
- package/lib/graph/QueryBuilderMetaModelConst.js.map +1 -1
- package/lib/graph-manager/protocol/pure/QueryBuilder_PureProtocolProcessorPlugin.js +4 -1
- package/lib/graph-manager/protocol/pure/QueryBuilder_PureProtocolProcessorPlugin.js.map +1 -1
- package/lib/graph-manager/protocol/pure/v1/V1_QueryValueSpecificationBuilderHelper.d.ts +1 -0
- package/lib/graph-manager/protocol/pure/v1/V1_QueryValueSpecificationBuilderHelper.d.ts.map +1 -1
- package/lib/graph-manager/protocol/pure/v1/V1_QueryValueSpecificationBuilderHelper.js +51 -3
- package/lib/graph-manager/protocol/pure/v1/V1_QueryValueSpecificationBuilderHelper.js.map +1 -1
- package/lib/index.css +2 -2
- package/lib/index.css.map +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/QueryBuilderResultState.d.ts.map +1 -1
- package/lib/stores/QueryBuilderResultState.js +1 -0
- package/lib/stores/QueryBuilderResultState.js.map +1 -1
- package/lib/stores/QueryBuilderState.d.ts +10 -1
- package/lib/stores/QueryBuilderState.d.ts.map +1 -1
- package/lib/stores/QueryBuilderState.js +21 -2
- package/lib/stores/QueryBuilderState.js.map +1 -1
- package/lib/stores/QueryBuilderStateBuilder.d.ts +2 -1
- package/lib/stores/QueryBuilderStateBuilder.d.ts.map +1 -1
- package/lib/stores/QueryBuilderStateBuilder.js +33 -4
- package/lib/stores/QueryBuilderStateBuilder.js.map +1 -1
- package/lib/stores/QueryBuilderValueSpecificationBuilderHelper.d.ts +5 -0
- package/lib/stores/QueryBuilderValueSpecificationBuilderHelper.d.ts.map +1 -1
- package/lib/stores/__test-utils__/QueryBuilderStateTestUtils.d.ts.map +1 -1
- package/lib/stores/__test-utils__/QueryBuilderStateTestUtils.js +2 -1
- package/lib/stores/__test-utils__/QueryBuilderStateTestUtils.js.map +1 -1
- package/lib/stores/fetch-structure/QueryBuilderFetchStructureImplementationState.d.ts +1 -0
- package/lib/stores/fetch-structure/QueryBuilderFetchStructureImplementationState.d.ts.map +1 -1
- package/lib/stores/fetch-structure/QueryBuilderFetchStructureImplementationState.js.map +1 -1
- package/lib/stores/fetch-structure/QueryBuilderFetchStructureState.d.ts +2 -1
- package/lib/stores/fetch-structure/QueryBuilderFetchStructureState.d.ts.map +1 -1
- package/lib/stores/fetch-structure/QueryBuilderFetchStructureState.js +7 -0
- package/lib/stores/fetch-structure/QueryBuilderFetchStructureState.js.map +1 -1
- package/lib/stores/fetch-structure/graph-fetch/QueryBuilderGraphFetchTreeState.d.ts +1 -0
- package/lib/stores/fetch-structure/graph-fetch/QueryBuilderGraphFetchTreeState.d.ts.map +1 -1
- package/lib/stores/fetch-structure/graph-fetch/QueryBuilderGraphFetchTreeState.js +4 -0
- package/lib/stores/fetch-structure/graph-fetch/QueryBuilderGraphFetchTreeState.js.map +1 -1
- package/lib/stores/fetch-structure/tds/QueryBuilderAdvancedWorkflowState.d.ts +2 -0
- package/lib/stores/fetch-structure/tds/QueryBuilderAdvancedWorkflowState.d.ts.map +1 -0
- package/lib/stores/fetch-structure/tds/QueryBuilderAdvancedWorkflowState.js +2 -0
- package/lib/stores/fetch-structure/tds/QueryBuilderAdvancedWorkflowState.js.map +1 -0
- package/lib/stores/fetch-structure/tds/QueryBuilderTDSState.d.ts +1 -0
- package/lib/stores/fetch-structure/tds/QueryBuilderTDSState.d.ts.map +1 -1
- package/lib/stores/fetch-structure/tds/QueryBuilderTDSState.js +4 -0
- package/lib/stores/fetch-structure/tds/QueryBuilderTDSState.js.map +1 -1
- package/lib/stores/fetch-structure/tds/projection/QueryBuilderProjectionStateBuilder.d.ts +4 -3
- package/lib/stores/fetch-structure/tds/projection/QueryBuilderProjectionStateBuilder.d.ts.map +1 -1
- package/lib/stores/fetch-structure/tds/projection/QueryBuilderProjectionStateBuilder.js +35 -3
- package/lib/stores/fetch-structure/tds/projection/QueryBuilderProjectionStateBuilder.js.map +1 -1
- package/lib/stores/fetch-structure/tds/projection/QueryBuilderProjectionValueSpecificationBuilder.d.ts +2 -9
- package/lib/stores/fetch-structure/tds/projection/QueryBuilderProjectionValueSpecificationBuilder.d.ts.map +1 -1
- package/lib/stores/fetch-structure/tds/projection/QueryBuilderProjectionValueSpecificationBuilder.js +45 -36
- package/lib/stores/fetch-structure/tds/projection/QueryBuilderProjectionValueSpecificationBuilder.js.map +1 -1
- package/lib/stores/fetch-structure/tds/projection/QueryBuilderRelationProjectValueSpecBuidler.d.ts +20 -0
- package/lib/stores/fetch-structure/tds/projection/QueryBuilderRelationProjectValueSpecBuidler.d.ts.map +1 -0
- package/lib/stores/fetch-structure/tds/projection/QueryBuilderRelationProjectValueSpecBuidler.js +55 -0
- package/lib/stores/fetch-structure/tds/projection/QueryBuilderRelationProjectValueSpecBuidler.js.map +1 -0
- package/lib/stores/query-workflow/QueryBuilderWorkFlowState.d.ts +35 -0
- package/lib/stores/query-workflow/QueryBuilderWorkFlowState.d.ts.map +1 -0
- package/lib/stores/query-workflow/QueryBuilderWorkFlowState.js +42 -0
- package/lib/stores/query-workflow/QueryBuilderWorkFlowState.js.map +1 -0
- package/lib/stores/workflows/FunctionQueryBuilderState.d.ts +2 -1
- package/lib/stores/workflows/FunctionQueryBuilderState.d.ts.map +1 -1
- package/lib/stores/workflows/FunctionQueryBuilderState.js +2 -2
- package/lib/stores/workflows/FunctionQueryBuilderState.js.map +1 -1
- package/lib/stores/workflows/MappingQueryBuilderState.d.ts +2 -1
- package/lib/stores/workflows/MappingQueryBuilderState.d.ts.map +1 -1
- package/lib/stores/workflows/MappingQueryBuilderState.js +2 -2
- package/lib/stores/workflows/MappingQueryBuilderState.js.map +1 -1
- package/lib/stores/workflows/ServiceQueryBuilderState.d.ts +2 -1
- package/lib/stores/workflows/ServiceQueryBuilderState.d.ts.map +1 -1
- package/lib/stores/workflows/ServiceQueryBuilderState.js +2 -2
- package/lib/stores/workflows/ServiceQueryBuilderState.js.map +1 -1
- package/package.json +3 -3
- package/src/components/QueryBuilder.tsx +214 -2
- package/src/components/__test-utils__/QueryBuilderComponentTestUtils.tsx +2 -0
- package/src/components/fetch-structure/QueryBuilderFetchStructurePanel.tsx +29 -29
- package/src/graph/QueryBuilderMetaModelConst.ts +7 -0
- package/src/graph-manager/protocol/pure/QueryBuilder_PureProtocolProcessorPlugin.ts +3 -3
- package/src/graph-manager/protocol/pure/v1/V1_QueryValueSpecificationBuilderHelper.ts +122 -1
- package/src/index.ts +1 -0
- package/src/stores/QueryBuilderResultState.ts +1 -0
- package/src/stores/QueryBuilderState.ts +27 -0
- package/src/stores/QueryBuilderStateBuilder.ts +65 -5
- package/src/stores/QueryBuilderValueSpecificationBuilderHelper.ts +5 -0
- package/src/stores/__test-utils__/QueryBuilderStateTestUtils.ts +2 -0
- package/src/stores/fetch-structure/QueryBuilderFetchStructureImplementationState.ts +1 -0
- package/src/stores/fetch-structure/QueryBuilderFetchStructureState.ts +15 -0
- package/src/stores/fetch-structure/graph-fetch/QueryBuilderGraphFetchTreeState.ts +5 -0
- package/src/stores/fetch-structure/tds/QueryBuilderAdvancedWorkflowState.ts +0 -0
- package/src/stores/fetch-structure/tds/QueryBuilderTDSState.ts +5 -0
- package/src/stores/fetch-structure/tds/projection/QueryBuilderProjectionStateBuilder.ts +76 -2
- package/src/stores/fetch-structure/tds/projection/QueryBuilderProjectionValueSpecificationBuilder.ts +90 -81
- package/src/stores/fetch-structure/tds/projection/QueryBuilderRelationProjectValueSpecBuidler.ts +108 -0
- package/src/stores/query-workflow/QueryBuilderWorkFlowState.ts +64 -0
- package/src/stores/workflows/FunctionQueryBuilderState.ts +3 -1
- package/src/stores/workflows/MappingQueryBuilderState.ts +9 -1
- package/src/stores/workflows/ServiceQueryBuilderState.ts +9 -1
- package/tsconfig.json +3 -0
@@ -109,6 +109,7 @@ import {
|
|
109
109
|
import type { QueryBuilderConfig } from '../graph-manager/QueryBuilderConfig.js';
|
110
110
|
import { QUERY_BUILDER_EVENT } from '../__lib__/QueryBuilderEvent.js';
|
111
111
|
import { QueryBuilderChangeHistoryState } from './QueryBuilderChangeHistoryState.js';
|
112
|
+
import { type QueryBuilderWorkflowState } from './query-workflow/QueryBuilderWorkFlowState.js';
|
112
113
|
|
113
114
|
export interface QuerySDLC {}
|
114
115
|
|
@@ -118,6 +119,11 @@ export type QueryStateInfo = QuerySDLC & {
|
|
118
119
|
runtime: string;
|
119
120
|
};
|
120
121
|
|
122
|
+
export enum QUERY_BUILDER_LAMBDA_WRITER_MODE {
|
123
|
+
STANDARD = 'STANDARD',
|
124
|
+
TYPED_FETCH_STRUCTURE = 'TYPED_FETCH_STRUCTURE',
|
125
|
+
}
|
126
|
+
|
121
127
|
export abstract class QueryBuilderState implements CommandRegistrar {
|
122
128
|
readonly applicationStore: GenericLegendApplicationStore;
|
123
129
|
readonly graphManagerState: GraphManagerState;
|
@@ -126,6 +132,7 @@ export abstract class QueryBuilderState implements CommandRegistrar {
|
|
126
132
|
readonly queryCompileState = ActionState.create();
|
127
133
|
readonly observerContext: ObserverContext;
|
128
134
|
readonly config: QueryBuilderConfig | undefined;
|
135
|
+
readonly workflowState: QueryBuilderWorkflowState;
|
129
136
|
|
130
137
|
explorerState: QueryBuilderExplorerState;
|
131
138
|
functionsExplorerState: QueryFunctionsExplorerState;
|
@@ -150,6 +157,8 @@ export abstract class QueryBuilderState implements CommandRegistrar {
|
|
150
157
|
isQueryChatOpened = false;
|
151
158
|
isLocalModeEnabled = false;
|
152
159
|
|
160
|
+
lambdaWriteMode = QUERY_BUILDER_LAMBDA_WRITER_MODE.STANDARD;
|
161
|
+
|
153
162
|
class?: Class | undefined;
|
154
163
|
getAllFunction: QUERY_BUILDER_SUPPORTED_GET_ALL_FUNCTIONS =
|
155
164
|
QUERY_BUILDER_SUPPORTED_GET_ALL_FUNCTIONS.GET_ALL;
|
@@ -168,6 +177,7 @@ export abstract class QueryBuilderState implements CommandRegistrar {
|
|
168
177
|
constructor(
|
169
178
|
applicationStore: GenericLegendApplicationStore,
|
170
179
|
graphManagerState: GraphManagerState,
|
180
|
+
workflowState: QueryBuilderWorkflowState,
|
171
181
|
config: QueryBuilderConfig | undefined,
|
172
182
|
sourceInfo?: QuerySDLC | undefined,
|
173
183
|
) {
|
@@ -196,6 +206,7 @@ export abstract class QueryBuilderState implements CommandRegistrar {
|
|
196
206
|
isQueryChatOpened: observable,
|
197
207
|
isLocalModeEnabled: observable,
|
198
208
|
getAllFunction: observable,
|
209
|
+
lambdaWriteMode: observable,
|
199
210
|
|
200
211
|
sideBarClassName: computed,
|
201
212
|
isQuerySupported: computed,
|
@@ -210,6 +221,7 @@ export abstract class QueryBuilderState implements CommandRegistrar {
|
|
210
221
|
setIsQueryChatOpened: action,
|
211
222
|
setIsLocalModeEnabled: action,
|
212
223
|
setGetAllFunction: action,
|
224
|
+
setLambdaWriteMode: action,
|
213
225
|
|
214
226
|
resetQueryResult: action,
|
215
227
|
resetQueryContent: action,
|
@@ -245,6 +257,8 @@ export abstract class QueryBuilderState implements CommandRegistrar {
|
|
245
257
|
this.changeDetectionState = new QueryBuilderChangeDetectionState(this);
|
246
258
|
this.changeHistoryState = new QueryBuilderChangeHistoryState(this);
|
247
259
|
this.config = config;
|
260
|
+
|
261
|
+
this.workflowState = workflowState;
|
248
262
|
this.sourceInfo = sourceInfo;
|
249
263
|
}
|
250
264
|
|
@@ -290,6 +304,17 @@ export abstract class QueryBuilderState implements CommandRegistrar {
|
|
290
304
|
return this.allVariables.map((e) => e.name);
|
291
305
|
}
|
292
306
|
|
307
|
+
get isFetchStructureTyped(): boolean {
|
308
|
+
return (
|
309
|
+
this.lambdaWriteMode ===
|
310
|
+
QUERY_BUILDER_LAMBDA_WRITER_MODE.TYPED_FETCH_STRUCTURE
|
311
|
+
);
|
312
|
+
}
|
313
|
+
|
314
|
+
setLambdaWriteMode(val: QUERY_BUILDER_LAMBDA_WRITER_MODE): void {
|
315
|
+
this.lambdaWriteMode = val;
|
316
|
+
}
|
317
|
+
|
293
318
|
getQueryExecutionContext(): QueryExecutionContext {
|
294
319
|
const queryExeContext = new QueryExplicitExecutionContext();
|
295
320
|
const runtimeValue = guaranteeType(
|
@@ -528,6 +553,7 @@ export abstract class QueryBuilderState implements CommandRegistrar {
|
|
528
553
|
return buildRawLambdaFromLambdaFunction(
|
529
554
|
buildLambdaFunction(this, {
|
530
555
|
keepSourceInformation: Boolean(options?.keepSourceInformation),
|
556
|
+
useTypedRelationFunctions: this.isFetchStructureTyped,
|
531
557
|
}),
|
532
558
|
this.graphManagerState,
|
533
559
|
);
|
@@ -789,6 +815,7 @@ export abstract class QueryBuilderState implements CommandRegistrar {
|
|
789
815
|
const basicState = new INTERNAL__BasicQueryBuilderState(
|
790
816
|
this.applicationStore,
|
791
817
|
this.graphManagerState,
|
818
|
+
this.workflowState,
|
792
819
|
undefined,
|
793
820
|
);
|
794
821
|
basicState.class = this.class;
|
@@ -26,7 +26,7 @@ import {
|
|
26
26
|
} from '@finos/legend-shared';
|
27
27
|
import type { QueryBuilderState } from './QueryBuilderState.js';
|
28
28
|
import {
|
29
|
-
|
29
|
+
AbstractPropertyExpression,
|
30
30
|
type EnumValueInstanceValue,
|
31
31
|
type FunctionExpression,
|
32
32
|
type GraphFetchTreeInstanceValue,
|
@@ -36,7 +36,8 @@ import {
|
|
36
36
|
type INTERNAL__PropagatedValue,
|
37
37
|
type ValueSpecification,
|
38
38
|
type CollectionInstanceValue,
|
39
|
-
|
39
|
+
LambdaFunctionInstanceValue,
|
40
|
+
type ColSpecArrayInstance,
|
40
41
|
InstanceValue,
|
41
42
|
INTERNAL__UnknownValueSpecification,
|
42
43
|
matchFunctionName,
|
@@ -481,6 +482,7 @@ export class QueryBuilderValueSpecificationProcessor
|
|
481
482
|
) {
|
482
483
|
processTDSProjectionDerivationExpression(
|
483
484
|
valueSpecification,
|
485
|
+
undefined,
|
484
486
|
this.parentExpression,
|
485
487
|
this.queryBuilderState,
|
486
488
|
);
|
@@ -637,10 +639,10 @@ export class QueryBuilderValueSpecificationProcessor
|
|
637
639
|
);
|
638
640
|
return;
|
639
641
|
} else if (
|
640
|
-
matchFunctionName(
|
641
|
-
functionName,
|
642
|
+
matchFunctionName(functionName, [
|
642
643
|
QUERY_BUILDER_SUPPORTED_FUNCTIONS.TDS_PROJECT,
|
643
|
-
|
644
|
+
QUERY_BUILDER_SUPPORTED_FUNCTIONS.RELATION_PROJECT,
|
645
|
+
])
|
644
646
|
) {
|
645
647
|
processTDSProjectExpression(
|
646
648
|
valueSpecification,
|
@@ -835,6 +837,7 @@ export class QueryBuilderValueSpecificationProcessor
|
|
835
837
|
if (
|
836
838
|
matchFunctionName(this.parentExpression.functionName, [
|
837
839
|
QUERY_BUILDER_SUPPORTED_FUNCTIONS.TDS_PROJECT,
|
840
|
+
QUERY_BUILDER_SUPPORTED_FUNCTIONS.RELATION_PROJECT,
|
838
841
|
QUERY_BUILDER_SUPPORTED_FUNCTIONS.TDS_GROUP_BY,
|
839
842
|
QUERY_BUILDER_SUPPORTED_FUNCTIONS.TDS_AGG,
|
840
843
|
...Object.values(
|
@@ -844,6 +847,7 @@ export class QueryBuilderValueSpecificationProcessor
|
|
844
847
|
) {
|
845
848
|
processTDSProjectionColumnPropertyExpression(
|
846
849
|
valueSpecification,
|
850
|
+
undefined,
|
847
851
|
this.queryBuilderState,
|
848
852
|
);
|
849
853
|
return;
|
@@ -903,6 +907,62 @@ export class QueryBuilderValueSpecificationProcessor
|
|
903
907
|
): void {
|
904
908
|
throw new UnsupportedOperationError();
|
905
909
|
}
|
910
|
+
|
911
|
+
visit_ColSpecArrayInstance(valueSpecification: ColSpecArrayInstance): void {
|
912
|
+
assertNonNullable(
|
913
|
+
this.parentExpression,
|
914
|
+
`Can't process col spec aray instance: parent expression cannot be retrieved`,
|
915
|
+
);
|
916
|
+
|
917
|
+
if (
|
918
|
+
matchFunctionName(this.parentExpression.functionName, [
|
919
|
+
QUERY_BUILDER_SUPPORTED_FUNCTIONS.RELATION_PROJECT,
|
920
|
+
])
|
921
|
+
) {
|
922
|
+
const spec = valueSpecification.values;
|
923
|
+
assertTrue(
|
924
|
+
spec.length === 1,
|
925
|
+
`Can't process col spec array instance: value expected to be of size 1`,
|
926
|
+
);
|
927
|
+
guaranteeNonNullable(spec[0]).colSpecs.forEach((col) => {
|
928
|
+
const _function1 = guaranteeType(
|
929
|
+
col.function1,
|
930
|
+
LambdaFunctionInstanceValue,
|
931
|
+
`Can't process col spec: function1 not a lambda function instance value`,
|
932
|
+
);
|
933
|
+
assertTrue(_function1.values.length === 1);
|
934
|
+
const lambdaVal = guaranteeNonNullable(_function1.values[0]);
|
935
|
+
assertTrue(lambdaVal.expressionSequence.length === 1);
|
936
|
+
const expression = guaranteeNonNullable(
|
937
|
+
lambdaVal.expressionSequence[0],
|
938
|
+
);
|
939
|
+
|
940
|
+
if (expression instanceof AbstractPropertyExpression) {
|
941
|
+
processTDSProjectionColumnPropertyExpression(
|
942
|
+
expression,
|
943
|
+
col.name,
|
944
|
+
this.queryBuilderState,
|
945
|
+
);
|
946
|
+
} else if (expression instanceof INTERNAL__UnknownValueSpecification) {
|
947
|
+
assertNonNullable(
|
948
|
+
this.parentExpression,
|
949
|
+
`Can't process unknown value: parent expression cannot be retrieved`,
|
950
|
+
);
|
951
|
+
processTDSProjectionDerivationExpression(
|
952
|
+
expression,
|
953
|
+
col.name,
|
954
|
+
this.parentExpression,
|
955
|
+
this.queryBuilderState,
|
956
|
+
);
|
957
|
+
}
|
958
|
+
});
|
959
|
+
|
960
|
+
return;
|
961
|
+
}
|
962
|
+
throw new UnsupportedOperationError(
|
963
|
+
`Can't process col spec array expression with parent expression of function ${this.parentExpression.functionName}()`,
|
964
|
+
);
|
965
|
+
}
|
906
966
|
}
|
907
967
|
|
908
968
|
export const processParameters = (
|
@@ -205,4 +205,9 @@ export type LambdaFunctionBuilderOption = {
|
|
205
205
|
* limit for the query results if it exists so the exported results contain all the data
|
206
206
|
*/
|
207
207
|
isExportingResult?: boolean | undefined;
|
208
|
+
/**
|
209
|
+
* Set this flag to `true` when you want to write to typed TDS function using the `Relation`
|
210
|
+
* typed in engine. This is still an experimental feature, hence we should only enable this flag when user wants to enable this directly.
|
211
|
+
*/
|
212
|
+
useTypedRelationFunctions?: boolean | undefined;
|
208
213
|
};
|
@@ -41,6 +41,7 @@ import {
|
|
41
41
|
INTERNAL__BasicQueryBuilderState,
|
42
42
|
type QueryBuilderState,
|
43
43
|
} from '../QueryBuilderState.js';
|
44
|
+
import { QueryBuilderAdvancedWorkflowState } from '../query-workflow/QueryBuilderWorkFlowState.js';
|
44
45
|
|
45
46
|
export class TEST__LegendApplicationPluginManager
|
46
47
|
extends LegendApplicationPluginManager<LegendApplicationPlugin>
|
@@ -131,6 +132,7 @@ export const TEST__setUpQueryBuilderState = async (
|
|
131
132
|
const queryBuilderState = new INTERNAL__BasicQueryBuilderState(
|
132
133
|
applicationStore,
|
133
134
|
graphManagerState,
|
135
|
+
QueryBuilderAdvancedWorkflowState.INSTANCE,
|
134
136
|
undefined,
|
135
137
|
);
|
136
138
|
if (rawLambda) {
|
@@ -58,6 +58,7 @@ export abstract class QueryBuilderFetchStructureImplementationState
|
|
58
58
|
abstract get usedExplorerTreePropertyNodeIDs(): string[];
|
59
59
|
abstract get fetchStructureValidationIssues(): string[];
|
60
60
|
abstract get allValidationIssues(): string[];
|
61
|
+
abstract get fetchLabel(): string;
|
61
62
|
|
62
63
|
abstract onClassChange(_class: Class | undefined): void;
|
63
64
|
abstract revealCompilationError(compilationError: CompilationError): boolean;
|
@@ -29,6 +29,21 @@ import {
|
|
29
29
|
type QueryBuilderFetchStructureImplementationState,
|
30
30
|
} from './QueryBuilderFetchStructureImplementationState.js';
|
31
31
|
|
32
|
+
export const onChangeFetchStructureImplementation =
|
33
|
+
(
|
34
|
+
implementationType: FETCH_STRUCTURE_IMPLEMENTATION,
|
35
|
+
fetchStructureState: QueryBuilderFetchStructureState,
|
36
|
+
): (() => void) =>
|
37
|
+
(): void => {
|
38
|
+
if (fetchStructureState.implementation.type !== implementationType) {
|
39
|
+
fetchStructureState.implementation.checkBeforeChangingImplementation(
|
40
|
+
() => {
|
41
|
+
fetchStructureState.changeImplementation(implementationType);
|
42
|
+
},
|
43
|
+
);
|
44
|
+
}
|
45
|
+
};
|
46
|
+
|
32
47
|
export class QueryBuilderFetchStructureState {
|
33
48
|
readonly queryBuilderState: QueryBuilderState;
|
34
49
|
implementation: QueryBuilderFetchStructureImplementationState;
|
@@ -292,6 +292,7 @@ export class QueryBuilderGraphFetchTreeState
|
|
292
292
|
setSerializationState: action,
|
293
293
|
setChecked: action,
|
294
294
|
initialize: action,
|
295
|
+
checkBeforeChangingImplementation: action,
|
295
296
|
});
|
296
297
|
|
297
298
|
// try to initialize the graph-fetch tree data using the setup class
|
@@ -304,6 +305,10 @@ export class QueryBuilderGraphFetchTreeState
|
|
304
305
|
return FETCH_STRUCTURE_IMPLEMENTATION.GRAPH_FETCH;
|
305
306
|
}
|
306
307
|
|
308
|
+
override get fetchLabel(): string {
|
309
|
+
return 'Class Properties';
|
310
|
+
}
|
311
|
+
|
307
312
|
get usedExplorerTreePropertyNodeIDs(): string[] {
|
308
313
|
if (!this.treeData) {
|
309
314
|
return [];
|
File without changes
|
@@ -154,6 +154,7 @@ export class QueryBuilderTDSState
|
|
154
154
|
initializeWithQuery: action,
|
155
155
|
setShowPostFilterPanel: action,
|
156
156
|
setShowWindowFuncPanel: action,
|
157
|
+
checkBeforeChangingImplementation: action,
|
157
158
|
convertDerivationProjectionObjects: flow,
|
158
159
|
fetchDerivedReturnTypes: flow,
|
159
160
|
});
|
@@ -194,6 +195,10 @@ export class QueryBuilderTDSState
|
|
194
195
|
);
|
195
196
|
}
|
196
197
|
|
198
|
+
override get fetchLabel(): string {
|
199
|
+
return 'Columns';
|
200
|
+
}
|
201
|
+
|
197
202
|
override get TEMPORARY__showPostFetchStructurePanel(): boolean {
|
198
203
|
return (
|
199
204
|
this.queryBuilderState.filterState.showPanel ||
|
@@ -28,6 +28,7 @@ import {
|
|
28
28
|
V1_RawLambda,
|
29
29
|
VariableExpression,
|
30
30
|
PrimitiveInstanceValue,
|
31
|
+
ColSpecArrayInstance,
|
31
32
|
} from '@finos/legend-graph';
|
32
33
|
import {
|
33
34
|
assertNonNullable,
|
@@ -44,7 +45,10 @@ import {
|
|
44
45
|
QUERY_BUILDER_SUPPORTED_FUNCTIONS,
|
45
46
|
QUERY_BUILDER_SUPPORTED_GET_ALL_FUNCTIONS,
|
46
47
|
} from '../../../../graph/QueryBuilderMetaModelConst.js';
|
47
|
-
import
|
48
|
+
import {
|
49
|
+
QUERY_BUILDER_LAMBDA_WRITER_MODE,
|
50
|
+
type QueryBuilderState,
|
51
|
+
} from '../../../QueryBuilderState.js';
|
48
52
|
import { QueryBuilderValueSpecificationProcessor } from '../../../QueryBuilderStateBuilder.js';
|
49
53
|
import {
|
50
54
|
extractNullableNumberFromInstanceValue,
|
@@ -59,11 +63,74 @@ import {
|
|
59
63
|
import { QueryBuilderTDSState } from '../QueryBuilderTDSState.js';
|
60
64
|
import { SortColumnState } from '../QueryResultSetModifierState.js';
|
61
65
|
|
66
|
+
export const processTypedTDSProjectExpression = (
|
67
|
+
expression: SimpleFunctionExpression,
|
68
|
+
queryBuilderState: QueryBuilderState,
|
69
|
+
parentLambda: LambdaFunction,
|
70
|
+
): void => {
|
71
|
+
// check parameters
|
72
|
+
assertTrue(
|
73
|
+
expression.parametersValues.length === 2,
|
74
|
+
`Can't process project() expression: project() expects 2 arguments`,
|
75
|
+
);
|
76
|
+
// update fetch-structure
|
77
|
+
queryBuilderState.fetchStructureState.changeImplementation(
|
78
|
+
FETCH_STRUCTURE_IMPLEMENTATION.TABULAR_DATA_STRUCTURE,
|
79
|
+
);
|
80
|
+
|
81
|
+
// check preceding expression
|
82
|
+
const precedingExpression = guaranteeType(
|
83
|
+
expression.parametersValues[0],
|
84
|
+
SimpleFunctionExpression,
|
85
|
+
`Can't process project() expression: only support project() immediately following an expression`,
|
86
|
+
);
|
87
|
+
assertTrue(
|
88
|
+
matchFunctionName(precedingExpression.functionName, [
|
89
|
+
QUERY_BUILDER_SUPPORTED_GET_ALL_FUNCTIONS.GET_ALL,
|
90
|
+
QUERY_BUILDER_SUPPORTED_GET_ALL_FUNCTIONS.GET_ALL_VERSIONS,
|
91
|
+
QUERY_BUILDER_SUPPORTED_GET_ALL_FUNCTIONS.GET_ALL_VERSIONS_IN_RANGE,
|
92
|
+
QUERY_BUILDER_SUPPORTED_FUNCTIONS.FILTER,
|
93
|
+
QUERY_BUILDER_SUPPORTED_FUNCTIONS.WATERMARK,
|
94
|
+
]),
|
95
|
+
`Can't process project() expression: only support project() immediately following either getAll(), filter(), or forWatermark()`,
|
96
|
+
);
|
97
|
+
QueryBuilderValueSpecificationProcessor.process(
|
98
|
+
precedingExpression,
|
99
|
+
parentLambda,
|
100
|
+
queryBuilderState,
|
101
|
+
);
|
102
|
+
// check columns
|
103
|
+
const classInstance = expression.parametersValues[1];
|
104
|
+
assertType(
|
105
|
+
classInstance,
|
106
|
+
ColSpecArrayInstance,
|
107
|
+
`Can't process project() expression: project() expects argument #1 to be a ColSpecArrayInstance`,
|
108
|
+
);
|
109
|
+
queryBuilderState.setLambdaWriteMode(
|
110
|
+
QUERY_BUILDER_LAMBDA_WRITER_MODE.TYPED_FETCH_STRUCTURE,
|
111
|
+
);
|
112
|
+
QueryBuilderValueSpecificationProcessor.processChild(
|
113
|
+
classInstance,
|
114
|
+
expression,
|
115
|
+
parentLambda,
|
116
|
+
queryBuilderState,
|
117
|
+
);
|
118
|
+
};
|
119
|
+
|
62
120
|
export const processTDSProjectExpression = (
|
63
121
|
expression: SimpleFunctionExpression,
|
64
122
|
queryBuilderState: QueryBuilderState,
|
65
123
|
parentLambda: LambdaFunction,
|
66
124
|
): void => {
|
125
|
+
if (expression.parametersValues.length === 2) {
|
126
|
+
processTypedTDSProjectExpression(
|
127
|
+
expression,
|
128
|
+
queryBuilderState,
|
129
|
+
parentLambda,
|
130
|
+
);
|
131
|
+
|
132
|
+
return;
|
133
|
+
}
|
67
134
|
// update fetch-structure
|
68
135
|
queryBuilderState.fetchStructureState.changeImplementation(
|
69
136
|
FETCH_STRUCTURE_IMPLEMENTATION.TABULAR_DATA_STRUCTURE,
|
@@ -142,6 +209,7 @@ export const processTDSProjectExpression = (
|
|
142
209
|
|
143
210
|
export const processTDSProjectionColumnPropertyExpression = (
|
144
211
|
expression: AbstractPropertyExpression,
|
212
|
+
columnName: string | undefined,
|
145
213
|
queryBuilderState: QueryBuilderState,
|
146
214
|
): void => {
|
147
215
|
if (
|
@@ -200,7 +268,9 @@ export const processTDSProjectionColumnPropertyExpression = (
|
|
200
268
|
);
|
201
269
|
|
202
270
|
tdsState.addColumn(columnState, { skipSorting: true });
|
203
|
-
|
271
|
+
if (columnName) {
|
272
|
+
columnState.setColumnName(columnName);
|
273
|
+
}
|
204
274
|
// NOTE: technically we should set the lambda parameter name when we process
|
205
275
|
// the lambda, not when we process the lambda body like this, but that requires
|
206
276
|
// some setup, so it's easier to do it here. The validation of this should have
|
@@ -211,6 +281,7 @@ export const processTDSProjectionColumnPropertyExpression = (
|
|
211
281
|
|
212
282
|
export const processTDSProjectionDerivationExpression = (
|
213
283
|
value: INTERNAL__UnknownValueSpecification,
|
284
|
+
columnName: string | undefined,
|
214
285
|
parentExpression: SimpleFunctionExpression,
|
215
286
|
queryBuilderState: QueryBuilderState,
|
216
287
|
): void => {
|
@@ -236,6 +307,9 @@ export const processTDSProjectionDerivationExpression = (
|
|
236
307
|
new RawLambda(rawLambdaProtocol.parameters, rawLambdaProtocol.body),
|
237
308
|
);
|
238
309
|
projectionState.addColumn(columnState, { skipSorting: true });
|
310
|
+
if (columnName) {
|
311
|
+
columnState.setColumnName(columnName);
|
312
|
+
}
|
239
313
|
}
|
240
314
|
};
|
241
315
|
|
package/src/stores/fetch-structure/tds/projection/QueryBuilderProjectionValueSpecificationBuilder.ts
CHANGED
@@ -45,10 +45,14 @@ import {
|
|
45
45
|
} from '../QueryResultSetModifierState.js';
|
46
46
|
import { QUERY_BUILDER_SUPPORTED_FUNCTIONS } from '../../../../graph/QueryBuilderMetaModelConst.js';
|
47
47
|
import { buildGenericLambdaFunctionInstanceValue } from '../../../QueryBuilderValueSpecificationHelper.js';
|
48
|
-
import {
|
48
|
+
import {
|
49
|
+
buildPropertyExpressionChain,
|
50
|
+
type LambdaFunctionBuilderOption,
|
51
|
+
} from '../../../QueryBuilderValueSpecificationBuilderHelper.js';
|
49
52
|
import { appendOLAPGroupByState } from '../window/QueryBuilderWindowValueSpecificationBuilder.js';
|
50
53
|
import { appendPostFilter } from '../post-filter/QueryBuilderPostFilterValueSpecificationBuilder.js';
|
51
54
|
import { buildTDSSortTypeExpression } from '../QueryBuilderTDSHelper.js';
|
55
|
+
import { buildRelationProjection } from './QueryBuilderRelationProjectValueSpecBuidler.js';
|
52
56
|
|
53
57
|
const buildSortExpression = (
|
54
58
|
sortColumnState: SortColumnState,
|
@@ -174,15 +178,7 @@ const appendResultSetModifier = (
|
|
174
178
|
export const appendProjection = (
|
175
179
|
tdsState: QueryBuilderTDSState,
|
176
180
|
lambdaFunction: LambdaFunction,
|
177
|
-
options?:
|
178
|
-
/**
|
179
|
-
* Set queryBuilderState to `true` when we construct query for execution within the app.
|
180
|
-
* queryBuilderState will make the lambda function building process overrides several query values, such as the row limit.
|
181
|
-
*/
|
182
|
-
isBuildingExecutionQuery?: boolean | undefined;
|
183
|
-
keepSourceInformation?: boolean | undefined;
|
184
|
-
isExportingResult?: boolean | undefined;
|
185
|
-
},
|
181
|
+
options?: LambdaFunctionBuilderOption,
|
186
182
|
): void => {
|
187
183
|
const queryBuilderState = tdsState.queryBuilderState;
|
188
184
|
const precedingExpression = guaranteeNonNullable(
|
@@ -327,82 +323,95 @@ export const appendProjection = (
|
|
327
323
|
];
|
328
324
|
lambdaFunction.expressionSequence[0] = groupByFunction;
|
329
325
|
} else if (tdsState.projectionColumns.length) {
|
330
|
-
|
331
|
-
|
332
|
-
|
333
|
-
|
334
|
-
|
335
|
-
queryBuilderState.graphManagerState.graph.getMultiplicity(
|
336
|
-
tdsState.projectionColumns.length,
|
337
|
-
tdsState.projectionColumns.length,
|
338
|
-
),
|
339
|
-
);
|
340
|
-
const colAliases = new CollectionInstanceValue(
|
341
|
-
queryBuilderState.graphManagerState.graph.getMultiplicity(
|
342
|
-
tdsState.projectionColumns.length,
|
343
|
-
tdsState.projectionColumns.length,
|
344
|
-
),
|
345
|
-
);
|
346
|
-
tdsState.projectionColumns.forEach((projectionColumnState) => {
|
347
|
-
// column alias
|
348
|
-
const colAlias = new PrimitiveInstanceValue(
|
349
|
-
GenericTypeExplicitReference.create(
|
350
|
-
new GenericType(PrimitiveType.STRING),
|
326
|
+
if (!tdsState.queryBuilderState.isFetchStructureTyped) {
|
327
|
+
// projection
|
328
|
+
const projectFunction = new SimpleFunctionExpression(
|
329
|
+
extractElementNameFromPath(
|
330
|
+
QUERY_BUILDER_SUPPORTED_FUNCTIONS.TDS_PROJECT,
|
351
331
|
),
|
352
332
|
);
|
353
|
-
|
354
|
-
|
355
|
-
|
356
|
-
|
357
|
-
|
358
|
-
|
359
|
-
|
360
|
-
|
361
|
-
|
362
|
-
|
363
|
-
|
364
|
-
|
365
|
-
|
366
|
-
|
367
|
-
|
368
|
-
|
369
|
-
),
|
370
|
-
|
371
|
-
queryBuilderState.graphManagerState.graph,
|
333
|
+
const colLambdas = new CollectionInstanceValue(
|
334
|
+
queryBuilderState.graphManagerState.graph.getMultiplicity(
|
335
|
+
tdsState.projectionColumns.length,
|
336
|
+
tdsState.projectionColumns.length,
|
337
|
+
),
|
338
|
+
);
|
339
|
+
const colAliases = new CollectionInstanceValue(
|
340
|
+
queryBuilderState.graphManagerState.graph.getMultiplicity(
|
341
|
+
tdsState.projectionColumns.length,
|
342
|
+
tdsState.projectionColumns.length,
|
343
|
+
),
|
344
|
+
);
|
345
|
+
tdsState.projectionColumns.forEach((projectionColumnState) => {
|
346
|
+
// column alias
|
347
|
+
const colAlias = new PrimitiveInstanceValue(
|
348
|
+
GenericTypeExplicitReference.create(
|
349
|
+
new GenericType(PrimitiveType.STRING),
|
350
|
+
),
|
372
351
|
);
|
373
|
-
|
374
|
-
|
375
|
-
|
376
|
-
|
377
|
-
columnLambda
|
378
|
-
|
379
|
-
|
380
|
-
|
381
|
-
|
382
|
-
|
383
|
-
|
384
|
-
|
385
|
-
|
386
|
-
|
352
|
+
colAlias.values.push(projectionColumnState.columnName);
|
353
|
+
colAliases.values.push(colAlias);
|
354
|
+
|
355
|
+
// column projection
|
356
|
+
let columnLambda: ValueSpecification;
|
357
|
+
if (
|
358
|
+
projectionColumnState instanceof
|
359
|
+
QueryBuilderSimpleProjectionColumnState
|
360
|
+
) {
|
361
|
+
columnLambda = buildGenericLambdaFunctionInstanceValue(
|
362
|
+
projectionColumnState.lambdaParameterName,
|
363
|
+
[
|
364
|
+
buildPropertyExpressionChain(
|
365
|
+
projectionColumnState.propertyExpressionState
|
366
|
+
.propertyExpression,
|
367
|
+
projectionColumnState.propertyExpressionState.queryBuilderState,
|
368
|
+
projectionColumnState.lambdaParameterName,
|
369
|
+
options,
|
370
|
+
),
|
371
|
+
],
|
372
|
+
queryBuilderState.graphManagerState.graph,
|
373
|
+
);
|
374
|
+
} else if (
|
375
|
+
projectionColumnState instanceof
|
376
|
+
QueryBuilderDerivationProjectionColumnState
|
377
|
+
) {
|
378
|
+
columnLambda = new INTERNAL__UnknownValueSpecification(
|
379
|
+
V1_serializeRawValueSpecification(
|
380
|
+
V1_transformRawLambda(
|
381
|
+
projectionColumnState.lambda,
|
382
|
+
new V1_GraphTransformerContextBuilder(
|
383
|
+
// TODO?: do we need to include the plugins here?
|
384
|
+
[],
|
387
385
|
)
|
388
|
-
|
386
|
+
.withKeepSourceInformationFlag(
|
387
|
+
Boolean(options?.keepSourceInformation),
|
388
|
+
)
|
389
|
+
.build(),
|
390
|
+
),
|
389
391
|
),
|
390
|
-
)
|
391
|
-
|
392
|
-
|
393
|
-
|
394
|
-
|
395
|
-
|
396
|
-
|
397
|
-
|
398
|
-
|
399
|
-
|
400
|
-
|
401
|
-
|
402
|
-
|
403
|
-
|
404
|
-
|
405
|
-
|
392
|
+
);
|
393
|
+
} else {
|
394
|
+
throw new UnsupportedOperationError(
|
395
|
+
`Can't build project() column expression: unsupported projection column state`,
|
396
|
+
projectionColumnState,
|
397
|
+
);
|
398
|
+
}
|
399
|
+
colLambdas.values.push(columnLambda);
|
400
|
+
});
|
401
|
+
projectFunction.parametersValues = [
|
402
|
+
precedingExpression,
|
403
|
+
colLambdas,
|
404
|
+
colAliases,
|
405
|
+
];
|
406
|
+
lambdaFunction.expressionSequence[0] = projectFunction;
|
407
|
+
} else {
|
408
|
+
const projectFunction = buildRelationProjection(
|
409
|
+
precedingExpression,
|
410
|
+
tdsState,
|
411
|
+
options,
|
412
|
+
);
|
413
|
+
lambdaFunction.expressionSequence[0] = projectFunction;
|
414
|
+
}
|
406
415
|
}
|
407
416
|
|
408
417
|
// build olapGroupBy
|