@finos/legend-application-query 13.4.1 → 13.4.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (70) hide show
  1. package/lib/__lib__/DSL_DataSpace_LegendQueryDocumentation.d.ts +19 -0
  2. package/lib/__lib__/DSL_DataSpace_LegendQueryDocumentation.d.ts.map +1 -0
  3. package/lib/__lib__/DSL_DataSpace_LegendQueryDocumentation.js +20 -0
  4. package/lib/__lib__/DSL_DataSpace_LegendQueryDocumentation.js.map +1 -0
  5. package/lib/__lib__/DSL_DataSpace_LegendQueryNavigation.d.ts +53 -0
  6. package/lib/__lib__/DSL_DataSpace_LegendQueryNavigation.d.ts.map +1 -0
  7. package/lib/__lib__/DSL_DataSpace_LegendQueryNavigation.js +59 -0
  8. package/lib/__lib__/DSL_DataSpace_LegendQueryNavigation.js.map +1 -0
  9. package/lib/components/Core_LegendQueryApplicationPlugin.d.ts.map +1 -1
  10. package/lib/components/Core_LegendQueryApplicationPlugin.js +14 -1
  11. package/lib/components/Core_LegendQueryApplicationPlugin.js.map +1 -1
  12. package/lib/components/LegendQueryWebApplication.d.ts.map +1 -1
  13. package/lib/components/LegendQueryWebApplication.js +18 -10
  14. package/lib/components/LegendQueryWebApplication.js.map +1 -1
  15. package/lib/components/QueryEditor.d.ts.map +1 -1
  16. package/lib/components/QueryEditor.js +47 -18
  17. package/lib/components/QueryEditor.js.map +1 -1
  18. package/lib/components/data-space/DataSpaceQueryCreator.d.ts +19 -0
  19. package/lib/components/data-space/DataSpaceQueryCreator.d.ts.map +1 -0
  20. package/lib/components/data-space/DataSpaceQueryCreator.js +43 -0
  21. package/lib/components/data-space/DataSpaceQueryCreator.js.map +1 -0
  22. package/lib/components/data-space/DataSpaceQuerySetup.d.ts +21 -0
  23. package/lib/components/data-space/DataSpaceQuerySetup.d.ts.map +1 -0
  24. package/lib/components/data-space/DataSpaceQuerySetup.js +64 -0
  25. package/lib/components/data-space/DataSpaceQuerySetup.js.map +1 -0
  26. package/lib/components/data-space/DataSpaceTemplateQueryCreator.d.ts +19 -0
  27. package/lib/components/data-space/DataSpaceTemplateQueryCreator.d.ts.map +1 -0
  28. package/lib/components/data-space/DataSpaceTemplateQueryCreator.js +39 -0
  29. package/lib/components/data-space/DataSpaceTemplateQueryCreator.js.map +1 -0
  30. package/lib/components/data-space/QueryDataSpaceUtil.d.ts +19 -0
  31. package/lib/components/data-space/QueryDataSpaceUtil.d.ts.map +1 -0
  32. package/lib/components/data-space/QueryDataSpaceUtil.js +25 -0
  33. package/lib/components/data-space/QueryDataSpaceUtil.js.map +1 -0
  34. package/lib/index.css +1 -1
  35. package/lib/package.json +2 -1
  36. package/lib/stores/LegendQueryApplicationPlugin.d.ts +0 -16
  37. package/lib/stores/LegendQueryApplicationPlugin.d.ts.map +1 -1
  38. package/lib/stores/LegendQueryApplicationPlugin.js.map +1 -1
  39. package/lib/stores/QueryEditorStore.d.ts +2 -0
  40. package/lib/stores/QueryEditorStore.d.ts.map +1 -1
  41. package/lib/stores/QueryEditorStore.js +96 -11
  42. package/lib/stores/QueryEditorStore.js.map +1 -1
  43. package/lib/stores/data-space/DataSpaceQueryCreatorStore.d.ts +37 -0
  44. package/lib/stores/data-space/DataSpaceQueryCreatorStore.d.ts.map +1 -0
  45. package/lib/stores/data-space/DataSpaceQueryCreatorStore.js +132 -0
  46. package/lib/stores/data-space/DataSpaceQueryCreatorStore.js.map +1 -0
  47. package/lib/stores/data-space/DataSpaceQuerySetupState.d.ts +51 -0
  48. package/lib/stores/data-space/DataSpaceQuerySetupState.d.ts.map +1 -0
  49. package/lib/stores/data-space/DataSpaceQuerySetupState.js +107 -0
  50. package/lib/stores/data-space/DataSpaceQuerySetupState.js.map +1 -0
  51. package/lib/stores/data-space/DataSpaceTemplateQueryCreatorStore.d.ts +36 -0
  52. package/lib/stores/data-space/DataSpaceTemplateQueryCreatorStore.d.ts.map +1 -0
  53. package/lib/stores/data-space/DataSpaceTemplateQueryCreatorStore.js +104 -0
  54. package/lib/stores/data-space/DataSpaceTemplateQueryCreatorStore.js.map +1 -0
  55. package/package.json +2 -1
  56. package/src/__lib__/DSL_DataSpace_LegendQueryDocumentation.ts +19 -0
  57. package/src/__lib__/DSL_DataSpace_LegendQueryNavigation.ts +123 -0
  58. package/src/components/Core_LegendQueryApplicationPlugin.tsx +18 -0
  59. package/src/components/LegendQueryWebApplication.tsx +48 -12
  60. package/src/components/QueryEditor.tsx +112 -24
  61. package/src/components/data-space/DataSpaceQueryCreator.tsx +99 -0
  62. package/src/components/data-space/DataSpaceQuerySetup.tsx +165 -0
  63. package/src/components/data-space/DataSpaceTemplateQueryCreator.tsx +82 -0
  64. package/src/components/data-space/QueryDataSpaceUtil.ts +34 -0
  65. package/src/stores/LegendQueryApplicationPlugin.ts +0 -22
  66. package/src/stores/QueryEditorStore.ts +187 -12
  67. package/src/stores/data-space/DataSpaceQueryCreatorStore.ts +286 -0
  68. package/src/stores/data-space/DataSpaceQuerySetupState.ts +208 -0
  69. package/src/stores/data-space/DataSpaceTemplateQueryCreatorStore.ts +204 -0
  70. package/tsconfig.json +10 -1
@@ -0,0 +1,104 @@
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
+ import { extractElementNameFromPath, } from '@finos/legend-graph';
17
+ import { StoreProjectData, } from '@finos/legend-server-depot';
18
+ import { filterByType, guaranteeNonNullable, uuid } from '@finos/legend-shared';
19
+ import { QueryEditorStore, createViewProjectHandler, createViewSDLCProjectHandler, } from '../QueryEditorStore.js';
20
+ import { DSL_DataSpace_getGraphManagerExtension, DataSpaceExecutableTemplate, getDataSpace, retrieveAnalyticsResultCache, } from '@finos/legend-extension-dsl-data-space/graph';
21
+ import { DataSpaceProjectInfo, DataSpaceQueryBuilderState, createQueryClassTaggedValue, createQueryDataSpaceTaggedValue, } from '@finos/legend-extension-dsl-data-space/application';
22
+ import { generateDataSpaceTemplateQueryCreatorRoute } from '../../__lib__/DSL_DataSpace_LegendQueryNavigation.js';
23
+ export class DataSpaceTemplateQueryCreatorStore extends QueryEditorStore {
24
+ groupId;
25
+ artifactId;
26
+ versionId;
27
+ dataSpacePath;
28
+ templateQueryId;
29
+ templateQueryTitle;
30
+ constructor(applicationStore, depotServerClient, groupId, artifactId, versionId, dataSpacePath, templateQueryId) {
31
+ super(applicationStore, depotServerClient);
32
+ this.groupId = groupId;
33
+ this.artifactId = artifactId;
34
+ this.versionId = versionId;
35
+ this.dataSpacePath = dataSpacePath;
36
+ this.templateQueryId = templateQueryId;
37
+ }
38
+ getProjectInfo() {
39
+ return {
40
+ groupId: this.groupId,
41
+ artifactId: this.artifactId,
42
+ versionId: this.versionId,
43
+ };
44
+ }
45
+ async initializeQueryBuilderState() {
46
+ const dataSpace = getDataSpace(this.dataSpacePath, this.graphManagerState.graph);
47
+ const dataSpaceExecutableTemplate = guaranteeNonNullable(dataSpace.executables
48
+ ?.filter(filterByType(DataSpaceExecutableTemplate))
49
+ .find((executable) => executable.id === this.templateQueryId), `Can't find template query with id '${this.templateQueryId}'`);
50
+ const executionContext = guaranteeNonNullable(dataSpaceExecutableTemplate.executionContextKey
51
+ ? dataSpace.executionContexts.filter((ec) => ec.name === dataSpaceExecutableTemplate.executionContextKey)[0]
52
+ : dataSpace.defaultExecutionContext, `Can't find execution context '${dataSpaceExecutableTemplate.executionContextKey}'`);
53
+ this.templateQueryTitle = dataSpaceExecutableTemplate.title;
54
+ let dataSpaceAnalysisResult;
55
+ try {
56
+ const project = StoreProjectData.serialization.fromJson(await this.depotServerClient.getProject(this.groupId, this.artifactId));
57
+ dataSpaceAnalysisResult = await DSL_DataSpace_getGraphManagerExtension(this.graphManagerState.graphManager).retrieveDataSpaceAnalysisFromCache(() => retrieveAnalyticsResultCache(project, this.versionId, dataSpace.path, this.depotServerClient));
58
+ }
59
+ catch {
60
+ // do nothing
61
+ }
62
+ const projectInfo = new DataSpaceProjectInfo(this.groupId, this.artifactId, this.versionId, createViewProjectHandler(this.applicationStore), createViewSDLCProjectHandler(this.applicationStore, this.depotServerClient));
63
+ const sourceInfo = {
64
+ groupId: projectInfo.groupId,
65
+ artifactId: projectInfo.artifactId,
66
+ versionId: projectInfo.versionId,
67
+ dataSpace: dataSpace.path,
68
+ };
69
+ const queryBuilderState = new DataSpaceQueryBuilderState(this.applicationStore, this.graphManagerState, this.depotServerClient, dataSpace, executionContext, (dataSpaceInfo) => {
70
+ this.applicationStore.notificationService.notifyWarning(`Can't switch data space to visit current template query`);
71
+ }, true, dataSpaceAnalysisResult, (ec) => {
72
+ this.applicationStore.navigationService.navigator.updateCurrentLocation(generateDataSpaceTemplateQueryCreatorRoute(this.groupId, this.artifactId, this.versionId, dataSpace.path, this.templateQueryId));
73
+ }, undefined, undefined, projectInfo, this.applicationStore.config.options.queryBuilderConfig, sourceInfo);
74
+ queryBuilderState.setExecutionContext(executionContext);
75
+ queryBuilderState.propagateExecutionContextChange(executionContext);
76
+ queryBuilderState.initializeWithQuery(dataSpaceExecutableTemplate.query);
77
+ return queryBuilderState;
78
+ }
79
+ getPersistConfiguration(lambda, options) {
80
+ return {
81
+ defaultName: options?.update
82
+ ? `${extractElementNameFromPath(this.dataSpacePath)}`
83
+ : `New Query for ${extractElementNameFromPath(this.dataSpacePath)}[${this.templateQueryId}]`,
84
+ decorator: (query) => {
85
+ query.id = uuid();
86
+ query.groupId = this.groupId;
87
+ query.artifactId = this.artifactId;
88
+ query.versionId = this.versionId;
89
+ if (this.queryBuilderState?.class) {
90
+ query.taggedValues = [
91
+ createQueryDataSpaceTaggedValue(this.dataSpacePath),
92
+ createQueryClassTaggedValue(this.queryBuilderState.class.path),
93
+ ];
94
+ }
95
+ else {
96
+ query.taggedValues = [
97
+ createQueryDataSpaceTaggedValue(this.dataSpacePath),
98
+ ];
99
+ }
100
+ },
101
+ };
102
+ }
103
+ }
104
+ //# sourceMappingURL=DataSpaceTemplateQueryCreatorStore.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"DataSpaceTemplateQueryCreatorStore.js","sourceRoot":"","sources":["../../../src/stores/data-space/DataSpaceTemplateQueryCreatorStore.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EACL,0BAA0B,GAG3B,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAEL,gBAAgB,GACjB,MAAM,4BAA4B,CAAC;AACpC,OAAO,EAAE,YAAY,EAAE,oBAAoB,EAAE,IAAI,EAAE,MAAM,sBAAsB,CAAC;AAGhF,OAAO,EACL,gBAAgB,EAChB,wBAAwB,EACxB,4BAA4B,GAE7B,MAAM,wBAAwB,CAAC;AAEhC,OAAO,EACL,sCAAsC,EACtC,2BAA2B,EAE3B,YAAY,EACZ,4BAA4B,GAC7B,MAAM,8CAA8C,CAAC;AACtD,OAAO,EACL,oBAAoB,EACpB,0BAA0B,EAC1B,2BAA2B,EAC3B,+BAA+B,GAEhC,MAAM,oDAAoD,CAAC;AAC5D,OAAO,EAAE,0CAA0C,EAAE,MAAM,sDAAsD,CAAC;AAElH,MAAM,OAAO,kCAAmC,SAAQ,gBAAgB;IAC7D,OAAO,CAAS;IAChB,UAAU,CAAS;IACnB,SAAS,CAAS;IAClB,aAAa,CAAS;IACtB,eAAe,CAAS;IACjC,kBAAkB,CAAU;IAE5B,YACE,gBAA6C,EAC7C,iBAAoC,EACpC,OAAe,EACf,UAAkB,EAClB,SAAiB,EACjB,aAAqB,EACrB,eAAuB;QAEvB,KAAK,CAAC,gBAAgB,EAAE,iBAAiB,CAAC,CAAC;QAE3C,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QACvB,IAAI,CAAC,UAAU,GAAG,UAAU,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AAC;SACF,CAAC;IACJ,CAAC;CACF"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@finos/legend-application-query",
3
- "version": "13.4.1",
3
+ "version": "13.4.2",
4
4
  "description": "Legend Query application core",
5
5
  "keywords": [
6
6
  "legend",
@@ -45,6 +45,7 @@
45
45
  "dependencies": {
46
46
  "@finos/legend-application": "15.0.74",
47
47
  "@finos/legend-art": "7.1.26",
48
+ "@finos/legend-extension-dsl-data-space": "10.3.1",
48
49
  "@finos/legend-graph": "31.9.11",
49
50
  "@finos/legend-lego": "1.2.24",
50
51
  "@finos/legend-query-builder": "4.14.25",
@@ -0,0 +1,19 @@
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
+ export enum DSL_DATA_SPACE_LEGEND_QUERY_DOCUMENTATION_KEY {
18
+ CURATED_TEMPLATE_QUERY = 'dsl-dataspace.curated-template-query',
19
+ }
@@ -0,0 +1,123 @@
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 {
18
+ generateExtensionUrlPattern,
19
+ generatePath,
20
+ } from '@finos/legend-application/browser';
21
+ import {
22
+ addQueryParametersToUrl,
23
+ stringifyQueryParams,
24
+ } from '@finos/legend-shared';
25
+ import { generateGAVCoordinates } from '@finos/legend-storage';
26
+
27
+ export enum DATA_SPACE_QUERY_CREATOR_ROUTE_PATTERN_TOKEN {
28
+ GAV = 'gav',
29
+ DATA_SPACE_PATH = 'dataSpacePath',
30
+ EXECUTION_CONTEXT = 'executionContext',
31
+ RUNTIME_PATH = 'runtimePath',
32
+ }
33
+
34
+ export enum DATA_SPACE_QUERY_CREATOR_QUERY_PARAM_TOKEN {
35
+ CLASS_PATH = 'class',
36
+ }
37
+
38
+ export enum DATA_SPACE_TEMPLATE_QUERY_CREATOR_ROUTE_PATTERN_TOKEN {
39
+ GAV = 'gav',
40
+ DATA_SPACE_PATH = 'dataSpacePath',
41
+ TEMPLATE = 'template',
42
+ TEMPLATE_QUERY_ID = 'templateQueryId',
43
+ }
44
+
45
+ export type DataSpaceQueryCreatorPathParams = {
46
+ [DATA_SPACE_QUERY_CREATOR_ROUTE_PATTERN_TOKEN.GAV]: string;
47
+ [DATA_SPACE_QUERY_CREATOR_ROUTE_PATTERN_TOKEN.DATA_SPACE_PATH]: string;
48
+ [DATA_SPACE_QUERY_CREATOR_ROUTE_PATTERN_TOKEN.EXECUTION_CONTEXT]: string;
49
+ [DATA_SPACE_QUERY_CREATOR_ROUTE_PATTERN_TOKEN.RUNTIME_PATH]?: string;
50
+ };
51
+
52
+ export type DataSpaceTemplateQueryCreatorPathParams = {
53
+ [DATA_SPACE_TEMPLATE_QUERY_CREATOR_ROUTE_PATTERN_TOKEN.GAV]: string;
54
+ [DATA_SPACE_TEMPLATE_QUERY_CREATOR_ROUTE_PATTERN_TOKEN.DATA_SPACE_PATH]: string;
55
+ [DATA_SPACE_TEMPLATE_QUERY_CREATOR_ROUTE_PATTERN_TOKEN.TEMPLATE_QUERY_ID]: string;
56
+ };
57
+
58
+ export type DataSpaceQueryEditorQueryParams = {
59
+ [DATA_SPACE_QUERY_CREATOR_QUERY_PARAM_TOKEN.CLASS_PATH]?: string | undefined;
60
+ };
61
+
62
+ export const DATA_SPACE_QUERY_ROUTE_PATTERN = Object.freeze({
63
+ SETUP: `/dataspace`,
64
+ CREATE: `/dataspace/:${DATA_SPACE_QUERY_CREATOR_ROUTE_PATTERN_TOKEN.GAV}/:${DATA_SPACE_QUERY_CREATOR_ROUTE_PATTERN_TOKEN.DATA_SPACE_PATH}/:${DATA_SPACE_QUERY_CREATOR_ROUTE_PATTERN_TOKEN.EXECUTION_CONTEXT}/:${DATA_SPACE_QUERY_CREATOR_ROUTE_PATTERN_TOKEN.RUNTIME_PATH}?`,
65
+ TEMPLATE_QUERY: `/dataspace/:${DATA_SPACE_TEMPLATE_QUERY_CREATOR_ROUTE_PATTERN_TOKEN.GAV}/:${DATA_SPACE_TEMPLATE_QUERY_CREATOR_ROUTE_PATTERN_TOKEN.DATA_SPACE_PATH}/:${DATA_SPACE_TEMPLATE_QUERY_CREATOR_ROUTE_PATTERN_TOKEN.TEMPLATE}/:${DATA_SPACE_TEMPLATE_QUERY_CREATOR_ROUTE_PATTERN_TOKEN.TEMPLATE_QUERY_ID}`,
66
+ });
67
+
68
+ export const generateDataSpaceQuerySetupRoute = (): string =>
69
+ generatePath(
70
+ generateExtensionUrlPattern(DATA_SPACE_QUERY_ROUTE_PATTERN.SETUP),
71
+ {},
72
+ );
73
+
74
+ export const generateDataSpaceQueryCreatorRoute = (
75
+ groupId: string,
76
+ artifactId: string,
77
+ versionId: string,
78
+ dataSpacePath: string,
79
+ executionContextKey: string,
80
+ runtimePath?: string | undefined,
81
+ classPath?: string | undefined,
82
+ ): string =>
83
+ addQueryParametersToUrl(
84
+ generatePath(
85
+ generateExtensionUrlPattern(DATA_SPACE_QUERY_ROUTE_PATTERN.CREATE),
86
+ {
87
+ [DATA_SPACE_QUERY_CREATOR_ROUTE_PATTERN_TOKEN.GAV]:
88
+ generateGAVCoordinates(groupId, artifactId, versionId),
89
+ [DATA_SPACE_QUERY_CREATOR_ROUTE_PATTERN_TOKEN.DATA_SPACE_PATH]:
90
+ dataSpacePath,
91
+ [DATA_SPACE_QUERY_CREATOR_ROUTE_PATTERN_TOKEN.EXECUTION_CONTEXT]:
92
+ executionContextKey,
93
+ [DATA_SPACE_QUERY_CREATOR_ROUTE_PATTERN_TOKEN.RUNTIME_PATH]:
94
+ runtimePath,
95
+ },
96
+ ),
97
+ stringifyQueryParams({
98
+ [DATA_SPACE_QUERY_CREATOR_QUERY_PARAM_TOKEN.CLASS_PATH]: classPath
99
+ ? encodeURIComponent(classPath)
100
+ : undefined,
101
+ }),
102
+ );
103
+
104
+ export const generateDataSpaceTemplateQueryCreatorRoute = (
105
+ groupId: string,
106
+ artifactId: string,
107
+ versionId: string,
108
+ dataSpacePath: string,
109
+ templateQueryId: string,
110
+ ): string =>
111
+ generatePath(
112
+ generateExtensionUrlPattern(DATA_SPACE_QUERY_ROUTE_PATTERN.TEMPLATE_QUERY),
113
+ {
114
+ [DATA_SPACE_TEMPLATE_QUERY_CREATOR_ROUTE_PATTERN_TOKEN.GAV]:
115
+ generateGAVCoordinates(groupId, artifactId, versionId),
116
+ [DATA_SPACE_TEMPLATE_QUERY_CREATOR_ROUTE_PATTERN_TOKEN.DATA_SPACE_PATH]:
117
+ dataSpacePath,
118
+ [DATA_SPACE_TEMPLATE_QUERY_CREATOR_ROUTE_PATTERN_TOKEN.TEMPLATE]:
119
+ DATA_SPACE_TEMPLATE_QUERY_CREATOR_ROUTE_PATTERN_TOKEN.TEMPLATE,
120
+ [DATA_SPACE_TEMPLATE_QUERY_CREATOR_ROUTE_PATTERN_TOKEN.TEMPLATE_QUERY_ID]:
121
+ templateQueryId,
122
+ },
123
+ );
@@ -27,6 +27,7 @@ import {
27
27
  ManageSearchIcon,
28
28
  PlusIcon,
29
29
  RobotIcon,
30
+ SquareIcon,
30
31
  } from '@finos/legend-art';
31
32
  import {
32
33
  generateCloneServiceQuerySetupRoute,
@@ -49,6 +50,7 @@ import {
49
50
  configureCodeEditorComponent,
50
51
  setupPureLanguageService,
51
52
  } from '@finos/legend-lego/code-editor';
53
+ import { generateDataSpaceQuerySetupRoute } from '../__lib__/DSL_DataSpace_LegendQueryNavigation.js';
52
54
 
53
55
  export class Core_LegendQueryApplicationPlugin extends LegendQueryApplicationPlugin {
54
56
  static NAME = packageJson.extensions.applicationQueryPlugin;
@@ -183,6 +185,22 @@ export class Core_LegendQueryApplicationPlugin extends LegendQueryApplicationPlu
183
185
  className: 'query-setup__landing-page__action--productionize-query',
184
186
  icon: <ArrowCircleUpIcon />,
185
187
  },
188
+ // data space
189
+ {
190
+ key: 'create-query-from-data-space',
191
+ isAdvanced: false,
192
+ isCreateAction: true,
193
+ action: async (setupStore) => {
194
+ setupStore.applicationStore.navigationService.navigator.goToLocation(
195
+ generateDataSpaceQuerySetupRoute(),
196
+ );
197
+ },
198
+ label: 'Create query from data space',
199
+ className: 'query-setup__landing-page__action--data-space',
200
+ icon: (
201
+ <SquareIcon className="query-setup__landing-page__icon--data-space" />
202
+ ),
203
+ },
186
204
  ];
187
205
  }
188
206
  }
@@ -39,7 +39,10 @@ import { EditExistingQuerySetup } from './EditExistingQuerySetup.js';
39
39
  import { CreateMappingQuerySetup } from './CreateMappingQuerySetup.js';
40
40
  import { useEffect } from 'react';
41
41
  import { flowResult } from 'mobx';
42
- import { guaranteeNonNullable, isNonNullable } from '@finos/legend-shared';
42
+ import { DATA_SPACE_QUERY_ROUTE_PATTERN } from '../__lib__/DSL_DataSpace_LegendQueryNavigation.js';
43
+ import { DataSpaceQuerySetup } from './data-space/DataSpaceQuerySetup.js';
44
+ import { DataSpaceTemplateQueryCreator } from './data-space/DataSpaceTemplateQueryCreator.js';
45
+ import { DataSpaceQueryCreator } from './data-space/DataSpaceQueryCreator.js';
43
46
 
44
47
  const LegendQueryWebApplicationRouter = observer(() => {
45
48
  const applicationStore = useLegendQueryApplicationStore();
@@ -49,16 +52,6 @@ const LegendQueryWebApplicationRouter = observer(() => {
49
52
  .getApplicationPlugins()
50
53
  .flatMap((plugin) => plugin.getExtraApplicationPageEntries?.() ?? []);
51
54
 
52
- const setupRoot = applicationStore.pluginManager
53
- .getApplicationPlugins()
54
- .flatMap((plugin) => plugin.getExtraRootAppRedirectPath?.())
55
- .filter(isNonNullable);
56
-
57
- const rootRedirect =
58
- setupRoot.length === 1
59
- ? generateExtensionUrlPattern(guaranteeNonNullable(setupRoot[0]))
60
- : LEGEND_QUERY_ROUTE_PATTERN.SETUP;
61
-
62
55
  useEffect(() => {
63
56
  flowResult(baseStore.initialize()).catch(
64
57
  applicationStore.alertUnhandledError,
@@ -117,6 +110,44 @@ const LegendQueryWebApplicationRouter = observer(() => {
117
110
  MappingQueryCreator as TEMPORARY__ReactRouterComponentType
118
111
  }
119
112
  />
113
+ {/* DATA SPACE */}
114
+ <Route
115
+ exact={true}
116
+ path={[
117
+ generateExtensionUrlPattern(DATA_SPACE_QUERY_ROUTE_PATTERN.SETUP),
118
+ ]}
119
+ component={
120
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
121
+ DataSpaceQuerySetup as TEMPORARY__ReactRouterComponentType
122
+ }
123
+ />
124
+
125
+ <Route
126
+ exact={true}
127
+ path={[
128
+ generateExtensionUrlPattern(
129
+ DATA_SPACE_QUERY_ROUTE_PATTERN.TEMPLATE_QUERY,
130
+ ),
131
+ ]}
132
+ component={
133
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
134
+ DataSpaceTemplateQueryCreator as TEMPORARY__ReactRouterComponentType
135
+ }
136
+ />
137
+
138
+ <Route
139
+ exact={true}
140
+ path={[
141
+ generateExtensionUrlPattern(
142
+ DATA_SPACE_QUERY_ROUTE_PATTERN.CREATE,
143
+ ),
144
+ ]}
145
+ component={
146
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
147
+ DataSpaceQueryCreator as TEMPORARY__ReactRouterComponentType
148
+ }
149
+ />
150
+
120
151
  {extraApplicationPageEntries.map((entry) => (
121
152
  <Route
122
153
  key={entry.key}
@@ -128,7 +159,12 @@ const LegendQueryWebApplicationRouter = observer(() => {
128
159
  }
129
160
  />
130
161
  ))}
131
- <Redirect to={rootRedirect} />
162
+ {/* Redirect to data space view */}
163
+ <Redirect
164
+ to={generateExtensionUrlPattern(
165
+ DATA_SPACE_QUERY_ROUTE_PATTERN.SETUP,
166
+ )}
167
+ />
132
168
  </Switch>
133
169
  )}
134
170
  </div>
@@ -47,6 +47,7 @@ import {
47
47
  Panel,
48
48
  PanelFullContent,
49
49
  CustomSelectorInput,
50
+ ArrowCircleUpIcon,
50
51
  } from '@finos/legend-art';
51
52
  import { observer } from 'mobx-react-lite';
52
53
  import { Fragment, useEffect, useMemo, useRef, useState } from 'react';
@@ -86,21 +87,28 @@ import {
86
87
  type QueryBuilderState,
87
88
  } from '@finos/legend-query-builder';
88
89
  import { QUERY_DOCUMENTATION_KEY } from '../application/LegendQueryDocumentation.js';
89
- import {
90
- debounce,
91
- guaranteeNonNullable,
92
- isNonNullable,
93
- } from '@finos/legend-shared';
90
+ import { buildUrl, debounce } from '@finos/legend-shared';
94
91
  import { LegendQueryTelemetryHelper } from '../__lib__/LegendQueryTelemetryHelper.js';
95
92
  import { QUERY_EDITOR_TEST_ID } from '../__lib__/LegendQueryTesting.js';
96
93
  import {
97
94
  compareSemVerVersions,
98
95
  generateGAVCoordinates,
96
+ parseProjectIdentifier,
99
97
  } from '@finos/legend-storage';
100
98
  import type { Query } from '@finos/legend-graph';
101
- import { LATEST_VERSION_ALIAS } from '@finos/legend-server-depot';
99
+ import {
100
+ LATEST_VERSION_ALIAS,
101
+ StoreProjectData,
102
+ } from '@finos/legend-server-depot';
102
103
  import { buildVersionOption, type VersionOption } from './QuerySetup.js';
103
104
  import { QueryEditorExistingQueryVersionRevertModal } from './QueryEdtiorExistingQueryVersionRevertModal.js';
105
+ import {
106
+ DataSpaceQueryBuilderState,
107
+ generateDataSpaceTemplateQueryPromotionRoute,
108
+ } from '@finos/legend-extension-dsl-data-space/application';
109
+ import { getDataSpaceQueryInfo } from './data-space/QueryDataSpaceUtil.js';
110
+ import { generateDataSpaceQueryCreatorRoute } from '../__lib__/DSL_DataSpace_LegendQueryNavigation.js';
111
+ import { DataSpaceTemplateQueryCreatorStore } from '../stores/data-space/DataSpaceTemplateQueryCreatorStore.js';
104
112
 
105
113
  const CreateQueryDialog = observer(() => {
106
114
  const editorStore = useQueryEditorStore();
@@ -602,16 +610,22 @@ const QueryEditorHeaderContent = observer(
602
610
  if (editorStore instanceof ExistingQueryEditorStore) {
603
611
  const query = editorStore.query;
604
612
  if (query) {
605
- const paths = applicationStore.pluginManager
606
- .getApplicationPlugins()
607
- .flatMap(
608
- (plugin) => plugin.getExtraNewQueryNavigationPaths?.() ?? [],
609
- )
610
- .map((callback) => callback(query, editorStore))
611
- .filter(isNonNullable);
612
- if (paths.length) {
613
+ const dataSpacePath = getDataSpaceQueryInfo(query);
614
+ if (
615
+ dataSpacePath &&
616
+ queryBuilderState instanceof DataSpaceQueryBuilderState
617
+ ) {
613
618
  editorStore.applicationStore.navigationService.navigator.goToLocation(
614
- guaranteeNonNullable(paths[0]),
619
+ generateDataSpaceQueryCreatorRoute(
620
+ query.groupId,
621
+ query.artifactId,
622
+ query.versionId,
623
+ dataSpacePath,
624
+ // TODO: fix execution key once that is fixed
625
+ queryBuilderState.executionContext.name,
626
+ undefined,
627
+ undefined,
628
+ ),
615
629
  );
616
630
  } else {
617
631
  editorStore.applicationStore.navigationService.navigator.goToLocation(
@@ -659,17 +673,21 @@ const QueryEditorHeaderContent = observer(
659
673
  existingEditorStore={editorStore}
660
674
  />
661
675
  );
676
+ } else if (editorStore instanceof DataSpaceTemplateQueryCreatorStore) {
677
+ return (
678
+ <div className="query-editor__dataspace__header">
679
+ <div className="query-editor__header__content__main query-editor__header__content__title__text query-editor__dataspace__header__title__text">
680
+ {editorStore.templateQueryTitle}
681
+ </div>
682
+ <div className="query-editor__dataspace__header__title__tag">
683
+ template
684
+ </div>
685
+ </div>
686
+ );
662
687
  }
663
- const extensionHeader = applicationStore.pluginManager
664
- .getApplicationPlugins()
665
- .flatMap((plugin) => plugin.getExtraQueryHeaders?.() ?? [])
666
- .map((renderFunc) => renderFunc(editorStore))
667
- .find((element) => element !== undefined);
668
688
 
669
689
  return (
670
- extensionHeader ?? (
671
- <div className="query-editor__header__content__main query-editor__header__content__title" />
672
- )
690
+ <div className="query-editor__header__content__main query-editor__header__content__title" />
673
691
  );
674
692
  };
675
693
 
@@ -690,6 +708,57 @@ const QueryEditorHeaderContent = observer(
690
708
  </MenuContentItem>
691
709
  ));
692
710
 
711
+ const proceedCuratedTemplateQueryPromotion = async (): Promise<void> => {
712
+ if (
713
+ !(
714
+ editorStore instanceof ExistingQueryEditorStore &&
715
+ queryBuilderState instanceof DataSpaceQueryBuilderState
716
+ )
717
+ ) {
718
+ return;
719
+ }
720
+ // fetch project data
721
+ const project = StoreProjectData.serialization.fromJson(
722
+ await editorStore.depotServerClient.getProject(
723
+ editorStore.lightQuery.groupId,
724
+ editorStore.lightQuery.artifactId,
725
+ ),
726
+ );
727
+
728
+ // find the matching SDLC instance
729
+ const projectIDPrefix = parseProjectIdentifier(project.projectId).prefix;
730
+ const matchingSDLCEntry =
731
+ editorStore.applicationStore.config.studioInstances.find(
732
+ (entry) => entry.sdlcProjectIDPrefix === projectIDPrefix,
733
+ );
734
+ if (matchingSDLCEntry) {
735
+ editorStore.applicationStore.navigationService.navigator.visitAddress(
736
+ buildUrl([
737
+ editorStore.applicationStore.config.studioApplicationUrl,
738
+ generateDataSpaceTemplateQueryPromotionRoute(
739
+ editorStore.lightQuery.groupId,
740
+ editorStore.lightQuery.artifactId,
741
+ editorStore.lightQuery.versionId,
742
+ queryBuilderState.dataSpace.path,
743
+ editorStore.lightQuery.id,
744
+ ),
745
+ ]),
746
+ );
747
+ } else {
748
+ editorStore.applicationStore.notificationService.notifyWarning(
749
+ `Can't find the corresponding SDLC instance to productionize the query`,
750
+ );
751
+ }
752
+ };
753
+
754
+ const proceedTemplate = (): void => {
755
+ queryBuilderState.changeDetectionState.alertUnsavedChanges(() => {
756
+ proceedCuratedTemplateQueryPromotion().catch(
757
+ editorStore.applicationStore.alertUnhandledError,
758
+ );
759
+ });
760
+ };
761
+
693
762
  return (
694
763
  <div
695
764
  className="query-editor__header__content"
@@ -710,7 +779,26 @@ const QueryEditorHeaderContent = observer(
710
779
  {actionConfig.renderer(editorStore, queryBuilderState)}
711
780
  </Fragment>
712
781
  ))}
713
-
782
+ <>
783
+ {editorStore instanceof ExistingQueryEditorStore &&
784
+ queryBuilderState instanceof DataSpaceQueryBuilderState && (
785
+ <button
786
+ className="query-editor__header__action btn--dark"
787
+ tabIndex={-1}
788
+ onClick={proceedTemplate}
789
+ title={
790
+ !(editorStore instanceof ExistingQueryEditorStore)
791
+ ? 'Please save your query first before promoting'
792
+ : 'Promote Curated Template query...'
793
+ }
794
+ >
795
+ <ArrowCircleUpIcon className="query-editor__header__action__icon--productionize" />
796
+ <div className="query-editor__header__action__label">
797
+ Promote as Template Query
798
+ </div>
799
+ </button>
800
+ )}
801
+ </>
714
802
  <Button
715
803
  className="query-editor__header__action btn--dark"
716
804
  disabled={editorStore.isPerformingBlockingAction}