@finos/legend-application-query 13.8.56 → 13.8.57
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/__lib__/LegendQueryNavigation.d.ts +0 -13
- package/lib/__lib__/LegendQueryNavigation.d.ts.map +1 -1
- package/lib/__lib__/LegendQueryNavigation.js +0 -13
- package/lib/__lib__/LegendQueryNavigation.js.map +1 -1
- package/lib/components/Core_LegendQueryApplicationPlugin.d.ts +1 -2
- package/lib/components/Core_LegendQueryApplicationPlugin.d.ts.map +1 -1
- package/lib/components/Core_LegendQueryApplicationPlugin.js +0 -13
- package/lib/components/Core_LegendQueryApplicationPlugin.js.map +1 -1
- package/lib/components/LegendQueryWebApplication.d.ts.map +1 -1
- package/lib/components/LegendQueryWebApplication.js +1 -2
- package/lib/components/LegendQueryWebApplication.js.map +1 -1
- package/lib/components/__test-utils__/QueryEditorComponentTestUtils.d.ts +1 -17
- package/lib/components/__test-utils__/QueryEditorComponentTestUtils.d.ts.map +1 -1
- package/lib/components/__test-utils__/QueryEditorComponentTestUtils.js +2 -175
- package/lib/components/__test-utils__/QueryEditorComponentTestUtils.js.map +1 -1
- package/lib/index.css +1 -1
- package/lib/index.d.ts +1 -1
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +1 -1
- package/lib/index.js.map +1 -1
- package/lib/light-mode.css +1 -1
- package/lib/package.json +1 -1
- package/lib/stores/QueryEditorStore.d.ts +4 -4
- package/lib/stores/QueryEditorStore.d.ts.map +1 -1
- package/lib/stores/QueryEditorStore.js +9 -53
- package/lib/stores/QueryEditorStore.js.map +1 -1
- package/lib/stores/data-product/query-builder/DataProductArtifactHelper.d.ts.map +1 -1
- package/lib/stores/data-product/query-builder/DataProductArtifactHelper.js +1 -10
- package/lib/stores/data-product/query-builder/DataProductArtifactHelper.js.map +1 -1
- package/lib/stores/data-product/query-builder/LegendQueryDataProductQueryBuilderState.d.ts +3 -2
- package/lib/stores/data-product/query-builder/LegendQueryDataProductQueryBuilderState.d.ts.map +1 -1
- package/lib/stores/data-product/query-builder/LegendQueryDataProductQueryBuilderState.js +21 -19
- package/lib/stores/data-product/query-builder/LegendQueryDataProductQueryBuilderState.js.map +1 -1
- package/package.json +8 -8
- package/src/__lib__/LegendQueryNavigation.ts +0 -45
- package/src/components/Core_LegendQueryApplicationPlugin.tsx +0 -17
- package/src/components/LegendQueryWebApplication.tsx +0 -5
- package/src/components/__test-utils__/QueryEditorComponentTestUtils.tsx +0 -430
- package/src/index.ts +0 -1
- package/src/stores/QueryEditorStore.ts +10 -68
- package/src/stores/data-product/query-builder/DataProductArtifactHelper.ts +1 -13
- package/src/stores/data-product/query-builder/LegendQueryDataProductQueryBuilderState.ts +33 -43
- package/tsconfig.json +0 -3
- package/lib/components/data-product/DataProductSampleQueryCreator.d.ts +0 -19
- package/lib/components/data-product/DataProductSampleQueryCreator.d.ts.map +0 -1
- package/lib/components/data-product/DataProductSampleQueryCreator.js +0 -53
- package/lib/components/data-product/DataProductSampleQueryCreator.js.map +0 -1
- package/lib/components/data-product/DataProductSampleQueryPanel.d.ts +0 -23
- package/lib/components/data-product/DataProductSampleQueryPanel.d.ts.map +0 -1
- package/lib/components/data-product/DataProductSampleQueryPanel.js +0 -95
- package/lib/components/data-product/DataProductSampleQueryPanel.js.map +0 -1
- package/lib/stores/data-product/DataProductSampleQueryCreatorStore.d.ts +0 -39
- package/lib/stores/data-product/DataProductSampleQueryCreatorStore.d.ts.map +0 -1
- package/lib/stores/data-product/DataProductSampleQueryCreatorStore.js +0 -71
- package/lib/stores/data-product/DataProductSampleQueryCreatorStore.js.map +0 -1
- package/src/components/data-product/DataProductSampleQueryCreator.tsx +0 -114
- package/src/components/data-product/DataProductSampleQueryPanel.tsx +0 -219
- package/src/stores/data-product/DataProductSampleQueryCreatorStore.ts +0 -152
|
@@ -41,7 +41,6 @@ import { flowResult } from 'mobx';
|
|
|
41
41
|
import { LEGACY_DATA_SPACE_QUERY_ROUTE_PATTERN } from '../__lib__/DSL_DataSpace_LegendQueryNavigation.js';
|
|
42
42
|
import { DataSpaceTemplateQueryCreator } from './data-space/DataSpaceTemplateQueryCreator.js';
|
|
43
43
|
import { QueryCreator } from './data-space/DataProductQueryCreator.js';
|
|
44
|
-
import { DataProductSampleQueryCreator } from './data-product/DataProductSampleQueryCreator.js';
|
|
45
44
|
import { IngestQueryCreator } from './ingest/IngestQueryCreator.js';
|
|
46
45
|
import { ExistingQueryDataCubeViewer } from './data-cube/ExistingQueryDataCubeViewer.js';
|
|
47
46
|
import { DataSpaceArtifactInspector } from './DataSpaceArtifactInspector.js';
|
|
@@ -106,10 +105,6 @@ const LegendQueryWebApplicationRouter = observer(() => {
|
|
|
106
105
|
path={LEGEND_QUERY_ROUTE_PATTERN.DATA_CUBE_EXISTING_QUERY}
|
|
107
106
|
element={<ExistingQueryDataCubeViewer />}
|
|
108
107
|
/>
|
|
109
|
-
<Route
|
|
110
|
-
path={LEGEND_QUERY_ROUTE_PATTERN.DATA_PRODUCT_SAMPLE_QUERY}
|
|
111
|
-
element={<DataProductSampleQueryCreator />}
|
|
112
|
-
/>
|
|
113
108
|
<Route
|
|
114
109
|
path={LEGEND_QUERY_ROUTE_PATTERN.DATA_PRODUCT}
|
|
115
110
|
element={<QueryCreator />}
|
|
@@ -34,15 +34,12 @@ import {
|
|
|
34
34
|
QueryExplicitExecutionContext,
|
|
35
35
|
QueryDataSpaceExecutionContext,
|
|
36
36
|
QueryDataProductModelAccessExecutionContext,
|
|
37
|
-
QueryDataProductNativeExecutionContext,
|
|
38
37
|
PackageableElementExplicitReference,
|
|
39
38
|
QueryDataSpaceExecutionContextInfo,
|
|
40
39
|
QueryExplicitExecutionContextInfo,
|
|
41
40
|
QueryDataProductModelAccessExecutionContextInfo,
|
|
42
|
-
QueryDataProductNativeExecutionContextInfo,
|
|
43
41
|
ModelAccessPointGroup,
|
|
44
42
|
V1_PureGraphManager,
|
|
45
|
-
type V1_DataProductArtifact,
|
|
46
43
|
} from '@finos/legend-graph';
|
|
47
44
|
import { DepotServerClient } from '@finos/legend-server-depot';
|
|
48
45
|
import {
|
|
@@ -77,7 +74,6 @@ import {
|
|
|
77
74
|
} from '@finos/legend-application/browser';
|
|
78
75
|
import {
|
|
79
76
|
generateExistingQueryEditorRoute,
|
|
80
|
-
generateDataProductSampleQueryRoute,
|
|
81
77
|
LEGEND_QUERY_ROUTE_PATTERN,
|
|
82
78
|
} from '../../__lib__/LegendQueryNavigation.js';
|
|
83
79
|
import {
|
|
@@ -92,8 +88,6 @@ import {
|
|
|
92
88
|
import { LegendQueryDataProductQueryBuilderState } from '../../stores/data-product/query-builder/LegendQueryDataProductQueryBuilderState.js';
|
|
93
89
|
import { DataProductSelectorState } from '../../stores/data-space/DataProductSelectorState.js';
|
|
94
90
|
import { DataSpaceTemplateQueryCreatorStore } from '../../stores/data-space/DataSpaceTemplateQueryCreatorStore.js';
|
|
95
|
-
import { DataProductSampleQueryCreatorStore } from '../../stores/data-product/DataProductSampleQueryCreatorStore.js';
|
|
96
|
-
import { DataProductSampleQueryCreator } from '../data-product/DataProductSampleQueryCreator.js';
|
|
97
91
|
|
|
98
92
|
const TEST_QUERY_ID = 'test-query-id';
|
|
99
93
|
const TEST_GROUP_ID = 'test-group';
|
|
@@ -101,8 +95,6 @@ const TEST_ARTIFACT_ID = 'test-artifact';
|
|
|
101
95
|
const TEST_VERSION_ID = 'test-version';
|
|
102
96
|
const TEST_TEMPLATE_QUERY_ID = 'templateQuery';
|
|
103
97
|
const TEST_DATA_SPACE_PATH = 'domain::COVIDDatapace';
|
|
104
|
-
const TEST_SAMPLE_QUERY_ID = 'sampleQuery';
|
|
105
|
-
const TEST_DATA_PRODUCT_PATH = 'test::MyDataProduct';
|
|
106
98
|
export const TEST_QUERY_NAME = 'MyTestQuery';
|
|
107
99
|
|
|
108
100
|
export const TEST__provideMockedQueryEditorStore = (customization?: {
|
|
@@ -846,425 +838,3 @@ export const TEST__setUpDataProductExistingQueryEditor = async (
|
|
|
846
838
|
),
|
|
847
839
|
};
|
|
848
840
|
};
|
|
849
|
-
|
|
850
|
-
export const TEST__setUpDataProductNativeExistingQueryEditor = async (
|
|
851
|
-
MOCK__editorStore: ExistingQueryEditorStore,
|
|
852
|
-
dataProductPath: string,
|
|
853
|
-
executionKey: string,
|
|
854
|
-
lambda: RawLambda,
|
|
855
|
-
entities: PlainObject<Entity>[],
|
|
856
|
-
artifact?: V1_DataProductArtifact | undefined,
|
|
857
|
-
): Promise<{
|
|
858
|
-
renderResult: RenderResult;
|
|
859
|
-
queryBuilderState: QueryBuilderState;
|
|
860
|
-
}> => {
|
|
861
|
-
const projectData = {
|
|
862
|
-
id: 'test-id',
|
|
863
|
-
groupId: 'test.group',
|
|
864
|
-
artifactId: 'test-artifact',
|
|
865
|
-
projectId: 'test-project-id',
|
|
866
|
-
versions: ['0.0.0'],
|
|
867
|
-
latestVersion: '0.0.0',
|
|
868
|
-
};
|
|
869
|
-
|
|
870
|
-
const lightQuery = new LightQuery();
|
|
871
|
-
lightQuery.name = TEST_QUERY_NAME;
|
|
872
|
-
lightQuery.id = TEST_QUERY_ID;
|
|
873
|
-
lightQuery.versionId = '0.0.0';
|
|
874
|
-
lightQuery.groupId = 'test.group';
|
|
875
|
-
lightQuery.artifactId = 'test-artifact';
|
|
876
|
-
lightQuery.owner = 'test-artifact';
|
|
877
|
-
lightQuery.isCurrentUserQuery = true;
|
|
878
|
-
|
|
879
|
-
const graphManagerState = MOCK__editorStore.graphManagerState;
|
|
880
|
-
|
|
881
|
-
await graphManagerState.graphManager.initialize({
|
|
882
|
-
env: 'test',
|
|
883
|
-
tabSize: 2,
|
|
884
|
-
clientConfig: {},
|
|
885
|
-
});
|
|
886
|
-
|
|
887
|
-
await graphManagerState.initializeSystem();
|
|
888
|
-
await graphManagerState.graphManager.buildGraph(
|
|
889
|
-
graphManagerState.graph,
|
|
890
|
-
entities as unknown as Entity[],
|
|
891
|
-
graphManagerState.graphBuildState,
|
|
892
|
-
);
|
|
893
|
-
|
|
894
|
-
const query = new Query();
|
|
895
|
-
query.name = lightQuery.name;
|
|
896
|
-
query.id = lightQuery.id;
|
|
897
|
-
query.versionId = lightQuery.versionId;
|
|
898
|
-
query.groupId = lightQuery.groupId;
|
|
899
|
-
query.artifactId = lightQuery.artifactId;
|
|
900
|
-
query.owner = lightQuery.owner;
|
|
901
|
-
query.isCurrentUserQuery = lightQuery.isCurrentUserQuery;
|
|
902
|
-
const execContext = new QueryDataProductNativeExecutionContext();
|
|
903
|
-
execContext.dataProductPath = dataProductPath;
|
|
904
|
-
execContext.executionKey = executionKey;
|
|
905
|
-
query.executionContext = execContext;
|
|
906
|
-
query.content = 'some content';
|
|
907
|
-
|
|
908
|
-
const execContextInfo = new QueryDataProductNativeExecutionContextInfo();
|
|
909
|
-
execContextInfo.dataProductPath = dataProductPath;
|
|
910
|
-
execContextInfo.executionKey = executionKey;
|
|
911
|
-
|
|
912
|
-
const queryInfo: QueryInfo = {
|
|
913
|
-
name: TEST_QUERY_NAME,
|
|
914
|
-
id: TEST_QUERY_ID,
|
|
915
|
-
versionId: '0.0.0',
|
|
916
|
-
groupId: 'test.group',
|
|
917
|
-
artifactId: 'test-artifact',
|
|
918
|
-
executionContext: execContextInfo,
|
|
919
|
-
content: 'some content',
|
|
920
|
-
isCurrentUserQuery: true,
|
|
921
|
-
};
|
|
922
|
-
|
|
923
|
-
// Resolve the data product and execution state from the built graph
|
|
924
|
-
const dataProduct = graphManagerState.graph.getDataProduct(dataProductPath);
|
|
925
|
-
const nativeAccess = guaranteeNonNullable(
|
|
926
|
-
dataProduct.nativeModelAccess,
|
|
927
|
-
`Data product '${dataProductPath}' has no native model access`,
|
|
928
|
-
);
|
|
929
|
-
const executionState = guaranteeNonNullable(
|
|
930
|
-
nativeAccess.nativeModelExecutionContexts.find(
|
|
931
|
-
(ctx) => ctx.key === executionKey,
|
|
932
|
-
),
|
|
933
|
-
`Can't find native execution context '${executionKey}'`,
|
|
934
|
-
);
|
|
935
|
-
|
|
936
|
-
createSpy(
|
|
937
|
-
MOCK__editorStore.depotServerClient,
|
|
938
|
-
'getProject',
|
|
939
|
-
).mockResolvedValue(projectData);
|
|
940
|
-
createSpy(
|
|
941
|
-
MOCK__editorStore.depotServerClient,
|
|
942
|
-
'getEntities',
|
|
943
|
-
).mockResolvedValue(entities);
|
|
944
|
-
createSpy(
|
|
945
|
-
MOCK__editorStore.depotServerClient,
|
|
946
|
-
'getEntitiesByClassifier',
|
|
947
|
-
).mockResolvedValue([]);
|
|
948
|
-
createSpy(
|
|
949
|
-
MOCK__editorStore.depotServerClient,
|
|
950
|
-
'getEntitiesSummaryByClassifier',
|
|
951
|
-
).mockResolvedValue([]);
|
|
952
|
-
createSpy(
|
|
953
|
-
MOCK__editorStore.depotServerClient,
|
|
954
|
-
'getVersions',
|
|
955
|
-
).mockResolvedValue([projectData.latestVersion]);
|
|
956
|
-
createSpy(graphManagerState.graphManager, 'getLightQuery').mockResolvedValue(
|
|
957
|
-
lightQuery,
|
|
958
|
-
);
|
|
959
|
-
createSpy(graphManagerState.graphManager, 'getQueryInfo').mockResolvedValue(
|
|
960
|
-
queryInfo,
|
|
961
|
-
);
|
|
962
|
-
createSpy(
|
|
963
|
-
graphManagerState.graphManager,
|
|
964
|
-
'pureCodeToLambda',
|
|
965
|
-
).mockResolvedValue(new RawLambda(lambda.parameters, lambda.body));
|
|
966
|
-
createSpy(graphManagerState.graphManager, 'getQuery').mockResolvedValue(
|
|
967
|
-
query,
|
|
968
|
-
);
|
|
969
|
-
createSpy(
|
|
970
|
-
graphManagerState.graphManager,
|
|
971
|
-
'analyzeMappingModelCoverage',
|
|
972
|
-
).mockResolvedValue(
|
|
973
|
-
graphManagerState.graphManager.buildMappingModelCoverageAnalysisResult(
|
|
974
|
-
{ mappedEntities: [] },
|
|
975
|
-
executionState.mapping.value,
|
|
976
|
-
),
|
|
977
|
-
);
|
|
978
|
-
|
|
979
|
-
// Build the query builder state that buildDataProductQueryBuilderState would return
|
|
980
|
-
const mockQueryBuilderState = new LegendQueryDataProductQueryBuilderState(
|
|
981
|
-
MOCK__editorStore.applicationStore,
|
|
982
|
-
graphManagerState,
|
|
983
|
-
QueryBuilderDataBrowserWorkflow.INSTANCE,
|
|
984
|
-
new QueryBuilderActionConfig_QueryApplication(MOCK__editorStore),
|
|
985
|
-
dataProduct,
|
|
986
|
-
artifact,
|
|
987
|
-
executionState,
|
|
988
|
-
MOCK__editorStore.depotServerClient,
|
|
989
|
-
{ groupId: 'test.group', artifactId: 'test-artifact', versionId: '0.0.0' },
|
|
990
|
-
async () => {
|
|
991
|
-
/* no-op for tests */
|
|
992
|
-
},
|
|
993
|
-
async () => {
|
|
994
|
-
throw new Error('Not implemented in tests');
|
|
995
|
-
},
|
|
996
|
-
new DataProductSelectorState(
|
|
997
|
-
MOCK__editorStore.depotServerClient,
|
|
998
|
-
MOCK__editorStore.applicationStore,
|
|
999
|
-
),
|
|
1000
|
-
undefined,
|
|
1001
|
-
undefined,
|
|
1002
|
-
MOCK__editorStore.applicationStore.config.options.queryBuilderConfig,
|
|
1003
|
-
{
|
|
1004
|
-
groupId: 'test.group',
|
|
1005
|
-
artifactId: 'test-artifact',
|
|
1006
|
-
versionId: '0.0.0',
|
|
1007
|
-
dataProduct: dataProductPath,
|
|
1008
|
-
},
|
|
1009
|
-
);
|
|
1010
|
-
mockQueryBuilderState.initWithDataProduct(
|
|
1011
|
-
dataProduct,
|
|
1012
|
-
undefined,
|
|
1013
|
-
executionState,
|
|
1014
|
-
);
|
|
1015
|
-
|
|
1016
|
-
MOCK__editorStore.buildGraph = createMock();
|
|
1017
|
-
MOCK__editorStore.buildFullGraph = createMock();
|
|
1018
|
-
MOCK__editorStore.fetchDataProductArtifact = createMock();
|
|
1019
|
-
(
|
|
1020
|
-
MOCK__editorStore.fetchDataProductArtifact as ReturnType<typeof createMock>
|
|
1021
|
-
).mockResolvedValue({});
|
|
1022
|
-
MOCK__editorStore.buildDataProductQueryBuilderState = createMock();
|
|
1023
|
-
(
|
|
1024
|
-
MOCK__editorStore.buildDataProductQueryBuilderState as ReturnType<
|
|
1025
|
-
typeof createMock
|
|
1026
|
-
>
|
|
1027
|
-
).mockResolvedValue(mockQueryBuilderState);
|
|
1028
|
-
graphManagerState.graphManager.initialize = createMock();
|
|
1029
|
-
|
|
1030
|
-
const renderResult = render(
|
|
1031
|
-
<ApplicationStoreProvider store={MOCK__editorStore.applicationStore}>
|
|
1032
|
-
<TEST__BrowserEnvironmentProvider
|
|
1033
|
-
initialEntries={[generateExistingQueryEditorRoute(lightQuery.id)]}
|
|
1034
|
-
>
|
|
1035
|
-
<LegendQueryFrameworkProvider>
|
|
1036
|
-
<Routes>
|
|
1037
|
-
<Route
|
|
1038
|
-
path={LEGEND_QUERY_ROUTE_PATTERN.EDIT_EXISTING_QUERY}
|
|
1039
|
-
element={<ExistingQueryEditor />}
|
|
1040
|
-
/>
|
|
1041
|
-
</Routes>
|
|
1042
|
-
</LegendQueryFrameworkProvider>
|
|
1043
|
-
</TEST__BrowserEnvironmentProvider>
|
|
1044
|
-
</ApplicationStoreProvider>,
|
|
1045
|
-
);
|
|
1046
|
-
await waitFor(() =>
|
|
1047
|
-
renderResult.getByTestId(QUERY_BUILDER_TEST_ID.QUERY_BUILDER),
|
|
1048
|
-
);
|
|
1049
|
-
|
|
1050
|
-
return {
|
|
1051
|
-
renderResult,
|
|
1052
|
-
queryBuilderState: guaranteeNonNullable(
|
|
1053
|
-
MOCK__editorStore.queryBuilderState,
|
|
1054
|
-
`Query builder state should have been initialized`,
|
|
1055
|
-
),
|
|
1056
|
-
};
|
|
1057
|
-
};
|
|
1058
|
-
|
|
1059
|
-
export const TEST__provideMockedDataProductSampleQueryCreatorStore =
|
|
1060
|
-
(customization?: {
|
|
1061
|
-
mock?: DataProductSampleQueryCreatorStore;
|
|
1062
|
-
applicationStore?: LegendQueryApplicationStore;
|
|
1063
|
-
pluginManager?: LegendQueryPluginManager;
|
|
1064
|
-
extraPlugins?: AbstractPlugin[];
|
|
1065
|
-
extraPresets?: AbstractPreset[];
|
|
1066
|
-
}): DataProductSampleQueryCreatorStore => {
|
|
1067
|
-
const pluginManager =
|
|
1068
|
-
customization?.pluginManager ?? LegendQueryPluginManager.create();
|
|
1069
|
-
pluginManager
|
|
1070
|
-
.usePlugins([
|
|
1071
|
-
new Core_LegendQueryApplicationPlugin(),
|
|
1072
|
-
...(customization?.extraPlugins ?? []),
|
|
1073
|
-
])
|
|
1074
|
-
.usePresets([...(customization?.extraPresets ?? [])])
|
|
1075
|
-
.install();
|
|
1076
|
-
const applicationStore =
|
|
1077
|
-
customization?.applicationStore ??
|
|
1078
|
-
new ApplicationStore(
|
|
1079
|
-
TEST__getTestLegendQueryApplicationConfig(),
|
|
1080
|
-
pluginManager,
|
|
1081
|
-
);
|
|
1082
|
-
const depotServerClient = new DepotServerClient({
|
|
1083
|
-
serverUrl: applicationStore.config.depotServerUrl,
|
|
1084
|
-
});
|
|
1085
|
-
depotServerClient.setTracerService(applicationStore.tracerService);
|
|
1086
|
-
const value =
|
|
1087
|
-
customization?.mock ??
|
|
1088
|
-
new DataProductSampleQueryCreatorStore(
|
|
1089
|
-
applicationStore,
|
|
1090
|
-
depotServerClient,
|
|
1091
|
-
TEST_GROUP_ID,
|
|
1092
|
-
TEST_ARTIFACT_ID,
|
|
1093
|
-
TEST_VERSION_ID,
|
|
1094
|
-
TEST_DATA_PRODUCT_PATH,
|
|
1095
|
-
TEST_SAMPLE_QUERY_ID,
|
|
1096
|
-
{ fips: 'value' },
|
|
1097
|
-
);
|
|
1098
|
-
const MOCK__QueryEditorStoreProvider = require('../QueryEditorStoreProvider.js'); // eslint-disable-line @typescript-eslint/no-require-imports,@typescript-eslint/no-unsafe-assignment
|
|
1099
|
-
MOCK__QueryEditorStoreProvider.useQueryEditorStore = createMock();
|
|
1100
|
-
MOCK__QueryEditorStoreProvider.useQueryEditorStore.mockReturnValue(value);
|
|
1101
|
-
return value;
|
|
1102
|
-
};
|
|
1103
|
-
|
|
1104
|
-
export const TEST__setUpDataProductSampleQueryEditor = async (
|
|
1105
|
-
MOCK__editorStore: DataProductSampleQueryCreatorStore,
|
|
1106
|
-
dataProductPath: string,
|
|
1107
|
-
executionKey: string,
|
|
1108
|
-
lambda: RawLambda,
|
|
1109
|
-
entities: PlainObject<Entity>[],
|
|
1110
|
-
artifact: V1_DataProductArtifact,
|
|
1111
|
-
): Promise<{
|
|
1112
|
-
renderResult: RenderResult;
|
|
1113
|
-
queryBuilderState: QueryBuilderState;
|
|
1114
|
-
}> => {
|
|
1115
|
-
const projectData = {
|
|
1116
|
-
id: 'test-id',
|
|
1117
|
-
groupId: MOCK__editorStore.groupId,
|
|
1118
|
-
artifactId: MOCK__editorStore.artifactId,
|
|
1119
|
-
projectId: 'test-project-id',
|
|
1120
|
-
versions: [MOCK__editorStore.versionId],
|
|
1121
|
-
latestVersion: MOCK__editorStore.versionId,
|
|
1122
|
-
};
|
|
1123
|
-
|
|
1124
|
-
const graphManagerState = MOCK__editorStore.graphManagerState;
|
|
1125
|
-
|
|
1126
|
-
await graphManagerState.graphManager.initialize({
|
|
1127
|
-
env: 'test',
|
|
1128
|
-
tabSize: 2,
|
|
1129
|
-
clientConfig: {},
|
|
1130
|
-
});
|
|
1131
|
-
await graphManagerState.initializeSystem();
|
|
1132
|
-
await graphManagerState.graphManager.buildGraph(
|
|
1133
|
-
graphManagerState.graph,
|
|
1134
|
-
entities as unknown as Entity[],
|
|
1135
|
-
graphManagerState.graphBuildState,
|
|
1136
|
-
);
|
|
1137
|
-
|
|
1138
|
-
const dataProduct = graphManagerState.graph.getDataProduct(dataProductPath);
|
|
1139
|
-
const nativeAccess = guaranteeNonNullable(
|
|
1140
|
-
dataProduct.nativeModelAccess,
|
|
1141
|
-
`Data product '${dataProductPath}' has no native model access`,
|
|
1142
|
-
);
|
|
1143
|
-
const executionState = guaranteeNonNullable(
|
|
1144
|
-
nativeAccess.nativeModelExecutionContexts.find(
|
|
1145
|
-
(ctx) => ctx.key === executionKey,
|
|
1146
|
-
),
|
|
1147
|
-
`Can't find native execution context '${executionKey}'`,
|
|
1148
|
-
);
|
|
1149
|
-
|
|
1150
|
-
createSpy(
|
|
1151
|
-
MOCK__editorStore.depotServerClient,
|
|
1152
|
-
'getProject',
|
|
1153
|
-
).mockResolvedValue(projectData);
|
|
1154
|
-
createSpy(
|
|
1155
|
-
MOCK__editorStore.depotServerClient,
|
|
1156
|
-
'getEntities',
|
|
1157
|
-
).mockResolvedValue(entities);
|
|
1158
|
-
createSpy(
|
|
1159
|
-
MOCK__editorStore.depotServerClient,
|
|
1160
|
-
'getEntitiesByClassifier',
|
|
1161
|
-
).mockResolvedValue([]);
|
|
1162
|
-
createSpy(
|
|
1163
|
-
MOCK__editorStore.depotServerClient,
|
|
1164
|
-
'getEntitiesSummaryByClassifier',
|
|
1165
|
-
).mockResolvedValue([]);
|
|
1166
|
-
createSpy(
|
|
1167
|
-
MOCK__editorStore.depotServerClient,
|
|
1168
|
-
'getVersions',
|
|
1169
|
-
).mockResolvedValue([projectData.latestVersion]);
|
|
1170
|
-
createSpy(
|
|
1171
|
-
graphManagerState.graphManager,
|
|
1172
|
-
'pureCodeToLambda',
|
|
1173
|
-
).mockResolvedValue(new RawLambda(lambda.parameters, lambda.body));
|
|
1174
|
-
createSpy(
|
|
1175
|
-
graphManagerState.graphManager,
|
|
1176
|
-
'analyzeMappingModelCoverage',
|
|
1177
|
-
).mockResolvedValue(
|
|
1178
|
-
graphManagerState.graphManager.buildMappingModelCoverageAnalysisResult(
|
|
1179
|
-
{ mappedEntities: [] },
|
|
1180
|
-
executionState.mapping.value,
|
|
1181
|
-
),
|
|
1182
|
-
);
|
|
1183
|
-
|
|
1184
|
-
const mockQueryBuilderState = new LegendQueryDataProductQueryBuilderState(
|
|
1185
|
-
MOCK__editorStore.applicationStore,
|
|
1186
|
-
graphManagerState,
|
|
1187
|
-
QueryBuilderDataBrowserWorkflow.INSTANCE,
|
|
1188
|
-
new QueryBuilderActionConfig_QueryApplication(MOCK__editorStore),
|
|
1189
|
-
dataProduct,
|
|
1190
|
-
artifact,
|
|
1191
|
-
executionState,
|
|
1192
|
-
MOCK__editorStore.depotServerClient,
|
|
1193
|
-
{
|
|
1194
|
-
groupId: MOCK__editorStore.groupId,
|
|
1195
|
-
artifactId: MOCK__editorStore.artifactId,
|
|
1196
|
-
versionId: MOCK__editorStore.versionId,
|
|
1197
|
-
},
|
|
1198
|
-
async () => {
|
|
1199
|
-
/* no-op for tests */
|
|
1200
|
-
},
|
|
1201
|
-
async () => {
|
|
1202
|
-
throw new Error('Not implemented in tests');
|
|
1203
|
-
},
|
|
1204
|
-
new DataProductSelectorState(
|
|
1205
|
-
MOCK__editorStore.depotServerClient,
|
|
1206
|
-
MOCK__editorStore.applicationStore,
|
|
1207
|
-
),
|
|
1208
|
-
undefined,
|
|
1209
|
-
undefined,
|
|
1210
|
-
MOCK__editorStore.applicationStore.config.options.queryBuilderConfig,
|
|
1211
|
-
{
|
|
1212
|
-
groupId: MOCK__editorStore.groupId,
|
|
1213
|
-
artifactId: MOCK__editorStore.artifactId,
|
|
1214
|
-
versionId: MOCK__editorStore.versionId,
|
|
1215
|
-
dataProduct: dataProductPath,
|
|
1216
|
-
},
|
|
1217
|
-
);
|
|
1218
|
-
mockQueryBuilderState.initWithDataProduct(
|
|
1219
|
-
dataProduct,
|
|
1220
|
-
undefined,
|
|
1221
|
-
executionState,
|
|
1222
|
-
);
|
|
1223
|
-
|
|
1224
|
-
MOCK__editorStore.buildGraph = createMock();
|
|
1225
|
-
MOCK__editorStore.fetchDataProductArtifact = createMock();
|
|
1226
|
-
(
|
|
1227
|
-
MOCK__editorStore.fetchDataProductArtifact as ReturnType<typeof createMock>
|
|
1228
|
-
).mockResolvedValue(artifact);
|
|
1229
|
-
MOCK__editorStore.buildDataProductQueryBuilderState = createMock();
|
|
1230
|
-
(
|
|
1231
|
-
MOCK__editorStore.buildDataProductQueryBuilderState as ReturnType<
|
|
1232
|
-
typeof createMock
|
|
1233
|
-
>
|
|
1234
|
-
).mockResolvedValue(mockQueryBuilderState);
|
|
1235
|
-
graphManagerState.graphManager.initialize = createMock();
|
|
1236
|
-
|
|
1237
|
-
const sampleQueryRoute = generateDataProductSampleQueryRoute(
|
|
1238
|
-
MOCK__editorStore.groupId,
|
|
1239
|
-
MOCK__editorStore.artifactId,
|
|
1240
|
-
MOCK__editorStore.versionId,
|
|
1241
|
-
dataProductPath,
|
|
1242
|
-
MOCK__editorStore.templateQueryId,
|
|
1243
|
-
);
|
|
1244
|
-
|
|
1245
|
-
const renderResult = render(
|
|
1246
|
-
<ApplicationStoreProvider store={MOCK__editorStore.applicationStore}>
|
|
1247
|
-
<TEST__BrowserEnvironmentProvider initialEntries={[sampleQueryRoute]}>
|
|
1248
|
-
<LegendQueryFrameworkProvider>
|
|
1249
|
-
<Routes>
|
|
1250
|
-
<Route
|
|
1251
|
-
path={LEGEND_QUERY_ROUTE_PATTERN.DATA_PRODUCT_SAMPLE_QUERY}
|
|
1252
|
-
element={<DataProductSampleQueryCreator />}
|
|
1253
|
-
/>
|
|
1254
|
-
</Routes>
|
|
1255
|
-
</LegendQueryFrameworkProvider>
|
|
1256
|
-
</TEST__BrowserEnvironmentProvider>
|
|
1257
|
-
</ApplicationStoreProvider>,
|
|
1258
|
-
);
|
|
1259
|
-
await waitFor(() =>
|
|
1260
|
-
renderResult.getByTestId(QUERY_BUILDER_TEST_ID.QUERY_BUILDER),
|
|
1261
|
-
);
|
|
1262
|
-
|
|
1263
|
-
return {
|
|
1264
|
-
renderResult,
|
|
1265
|
-
queryBuilderState: guaranteeNonNullable(
|
|
1266
|
-
MOCK__editorStore.queryBuilderState,
|
|
1267
|
-
`Query builder state should have been initialized`,
|
|
1268
|
-
),
|
|
1269
|
-
};
|
|
1270
|
-
};
|
package/src/index.ts
CHANGED
|
@@ -43,7 +43,6 @@ import {
|
|
|
43
43
|
} from '@finos/legend-shared';
|
|
44
44
|
import {
|
|
45
45
|
type LightQuery,
|
|
46
|
-
type NativeModelExecutionContext,
|
|
47
46
|
type RawLambda,
|
|
48
47
|
type Runtime,
|
|
49
48
|
type Service,
|
|
@@ -76,7 +75,6 @@ import {
|
|
|
76
75
|
QUERY_PROFILE_PATH,
|
|
77
76
|
QueryDataSpaceExecutionContextInfo,
|
|
78
77
|
QueryExplicitExecutionContextInfo,
|
|
79
|
-
QueryDataProductNativeExecutionContextInfo,
|
|
80
78
|
QueryDataProductModelAccessExecutionContextInfo,
|
|
81
79
|
QueryDataProductLakehouseExecutionContextInfo,
|
|
82
80
|
QueryIngestExecutionContextInfo,
|
|
@@ -1068,31 +1066,6 @@ export abstract class QueryEditorStore {
|
|
|
1068
1066
|
artifact: V1_DataProductArtifact,
|
|
1069
1067
|
executionContextId: string | undefined,
|
|
1070
1068
|
): string {
|
|
1071
|
-
// Try native execution contexts first
|
|
1072
|
-
if (artifact.nativeModelAccess) {
|
|
1073
|
-
const native = artifact.nativeModelAccess;
|
|
1074
|
-
if (executionContextId) {
|
|
1075
|
-
const matchingContext = native.nativeModelExecutionContexts.find(
|
|
1076
|
-
(ctx) => ctx.key === executionContextId,
|
|
1077
|
-
);
|
|
1078
|
-
if (matchingContext) {
|
|
1079
|
-
return matchingContext.mapping;
|
|
1080
|
-
}
|
|
1081
|
-
}
|
|
1082
|
-
// Fall back to default execution context
|
|
1083
|
-
const defaultContext = native.nativeModelExecutionContexts.find(
|
|
1084
|
-
(ctx) => ctx.key === native.defaultExecutionContext,
|
|
1085
|
-
);
|
|
1086
|
-
if (defaultContext) {
|
|
1087
|
-
return defaultContext.mapping;
|
|
1088
|
-
}
|
|
1089
|
-
// Fall back to first context
|
|
1090
|
-
const firstContext = native.nativeModelExecutionContexts[0];
|
|
1091
|
-
if (firstContext) {
|
|
1092
|
-
return firstContext.mapping;
|
|
1093
|
-
}
|
|
1094
|
-
}
|
|
1095
|
-
|
|
1096
1069
|
// Try model access point groups
|
|
1097
1070
|
const modelGroups = artifact.accessPointGroups.filter(
|
|
1098
1071
|
(g): g is V1_ModelAccessPointGroupInfo =>
|
|
@@ -1197,48 +1170,25 @@ export abstract class QueryEditorStore {
|
|
|
1197
1170
|
|
|
1198
1171
|
/**
|
|
1199
1172
|
* Resolves the execution state for a data product by looking up `accessId`
|
|
1200
|
-
* in both model access point groups (by `id`) and
|
|
1201
|
-
* (by `
|
|
1173
|
+
* in both model access point groups (by `id`) and lakehouse access points
|
|
1174
|
+
* (by `id`). Throws if no matching state is found.
|
|
1202
1175
|
*/
|
|
1203
1176
|
resolveDataProductExecutionState(
|
|
1204
1177
|
dataProduct: DataProduct,
|
|
1205
1178
|
accessId: string | undefined,
|
|
1206
|
-
):
|
|
1207
|
-
| NativeModelExecutionContext
|
|
1208
|
-
| ModelAccessPointGroup
|
|
1209
|
-
| LakehouseAccessPoint {
|
|
1210
|
-
// Search model access point groups
|
|
1179
|
+
): ModelAccessPointGroup | LakehouseAccessPoint {
|
|
1211
1180
|
const modelGroups = dataProduct.accessPointGroups.filter(
|
|
1212
1181
|
filterByType(ModelAccessPointGroup),
|
|
1213
1182
|
);
|
|
1183
|
+
const lakehouseAccessPoints = dataProduct.accessPointGroups
|
|
1184
|
+
.flatMap((group) => group.accessPoints)
|
|
1185
|
+
.filter(filterByType(LakehouseAccessPoint));
|
|
1186
|
+
|
|
1214
1187
|
if (accessId) {
|
|
1215
1188
|
const matchingGroup = modelGroups.find((g) => g.id === accessId);
|
|
1216
1189
|
if (matchingGroup) {
|
|
1217
1190
|
return matchingGroup;
|
|
1218
1191
|
}
|
|
1219
|
-
}
|
|
1220
|
-
// Search native model execution contexts
|
|
1221
|
-
const nativeAccess = dataProduct.nativeModelAccess;
|
|
1222
|
-
if (nativeAccess && accessId) {
|
|
1223
|
-
const matchingContext = nativeAccess.nativeModelExecutionContexts.find(
|
|
1224
|
-
(ctx) => ctx.key === accessId,
|
|
1225
|
-
);
|
|
1226
|
-
if (matchingContext) {
|
|
1227
|
-
return matchingContext;
|
|
1228
|
-
}
|
|
1229
|
-
}
|
|
1230
|
-
|
|
1231
|
-
// Fall back: prioritize first model access point group over native default
|
|
1232
|
-
const firstGroup = modelGroups[0];
|
|
1233
|
-
if (firstGroup) {
|
|
1234
|
-
return firstGroup;
|
|
1235
|
-
}
|
|
1236
|
-
|
|
1237
|
-
// Search lakehouse access points
|
|
1238
|
-
const lakehouseAccessPoints = dataProduct.accessPointGroups
|
|
1239
|
-
.flatMap((group) => group.accessPoints)
|
|
1240
|
-
.filter(filterByType(LakehouseAccessPoint));
|
|
1241
|
-
if (accessId) {
|
|
1242
1192
|
const matchingLakehouseAP = lakehouseAccessPoints.find(
|
|
1243
1193
|
(ap) => ap.id === accessId,
|
|
1244
1194
|
);
|
|
@@ -1248,8 +1198,8 @@ export abstract class QueryEditorStore {
|
|
|
1248
1198
|
}
|
|
1249
1199
|
|
|
1250
1200
|
return guaranteeNonNullable(
|
|
1251
|
-
modelGroups[0] ??
|
|
1252
|
-
`Can't resolve execution state for data product '${dataProduct.path}'${accessId ? ` with access ID '${accessId}'` : ''}. Data product must have model access point groups or
|
|
1201
|
+
modelGroups[0] ?? lakehouseAccessPoints[0],
|
|
1202
|
+
`Can't resolve execution state for data product '${dataProduct.path}'${accessId ? ` with access ID '${accessId}'` : ''}. Data product must have model access point groups or lakehouse access points.`,
|
|
1253
1203
|
);
|
|
1254
1204
|
}
|
|
1255
1205
|
|
|
@@ -2195,8 +2145,6 @@ export class ExistingQueryEditorStore extends QueryEditorStore {
|
|
|
2195
2145
|
dataSpaceTaggedValue !== undefined ||
|
|
2196
2146
|
queryInfo?.executionContext instanceof
|
|
2197
2147
|
QueryDataSpaceExecutionContextInfo ||
|
|
2198
|
-
queryInfo?.executionContext instanceof
|
|
2199
|
-
QueryDataProductNativeExecutionContextInfo ||
|
|
2200
2148
|
queryInfo?.executionContext instanceof
|
|
2201
2149
|
QueryDataProductModelAccessExecutionContextInfo ||
|
|
2202
2150
|
queryInfo?.executionContext instanceof
|
|
@@ -2505,18 +2453,12 @@ export class ExistingQueryEditorStore extends QueryEditorStore {
|
|
|
2505
2453
|
);
|
|
2506
2454
|
return classQueryBuilderState;
|
|
2507
2455
|
} else if (
|
|
2508
|
-
exec instanceof QueryDataProductNativeExecutionContextInfo ||
|
|
2509
2456
|
exec instanceof QueryDataProductModelAccessExecutionContextInfo ||
|
|
2510
2457
|
exec instanceof QueryDataProductLakehouseExecutionContextInfo
|
|
2511
2458
|
) {
|
|
2512
2459
|
let executionContextId: string;
|
|
2513
2460
|
let accessType: DataProductAccessType;
|
|
2514
|
-
if (exec instanceof
|
|
2515
|
-
executionContextId = exec.executionKey;
|
|
2516
|
-
accessType = DataProductAccessType.NATIVE;
|
|
2517
|
-
} else if (
|
|
2518
|
-
exec instanceof QueryDataProductModelAccessExecutionContextInfo
|
|
2519
|
-
) {
|
|
2461
|
+
if (exec instanceof QueryDataProductModelAccessExecutionContextInfo) {
|
|
2520
2462
|
executionContextId = exec.accessPointGroupId;
|
|
2521
2463
|
accessType = DataProductAccessType.MODEL;
|
|
2522
2464
|
} else {
|
|
@@ -34,19 +34,7 @@ export const resolveDefaultDataProductAccessType = (
|
|
|
34
34
|
};
|
|
35
35
|
}
|
|
36
36
|
|
|
37
|
-
// start on ModelAPG if it exists, then fallback to native access
|
|
38
|
-
const nativeAccess = dataProductArtifact.nativeModelAccess;
|
|
39
|
-
if (nativeAccess) {
|
|
40
|
-
const defaultKey = nativeAccess.defaultExecutionContext;
|
|
41
|
-
const native =
|
|
42
|
-
nativeAccess.nativeModelExecutionContexts.find(
|
|
43
|
-
(ctx) => ctx.key === defaultKey,
|
|
44
|
-
) ?? nativeAccess.nativeModelExecutionContexts[0];
|
|
45
|
-
if (native) {
|
|
46
|
-
return { type: DataProductAccessType.NATIVE, id: native.key };
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
37
|
throw new Error(
|
|
50
|
-
`Data Product not supported for querying on legend query ${dataProductArtifact.dataProduct.path}. Must contain a model access point
|
|
38
|
+
`Data Product not supported for querying on legend query ${dataProductArtifact.dataProduct.path}. Must contain a model access point.`,
|
|
51
39
|
);
|
|
52
40
|
};
|