@finos/legend-extension-dsl-data-space 4.0.3 → 5.0.0

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.
Files changed (97) hide show
  1. package/lib/DSLDataSpace_Const.d.ts +18 -0
  2. package/lib/DSLDataSpace_Const.d.ts.map +1 -0
  3. package/lib/DSLDataSpace_Const.js +20 -0
  4. package/lib/DSLDataSpace_Const.js.map +1 -0
  5. package/lib/components/DataSpaceViewer.d.ts.map +1 -1
  6. package/lib/components/DataSpaceViewer.js +30 -27
  7. package/lib/components/DataSpaceViewer.js.map +1 -1
  8. package/lib/components/query/{DSLDataSpace_LegendQueryPlugin.d.ts → DSLDataSpace_LegendQueryApplicationPlugin.d.ts} +6 -3
  9. package/lib/components/query/DSLDataSpace_LegendQueryApplicationPlugin.d.ts.map +1 -0
  10. package/lib/components/query/{DSLDataSpace_LegendQueryPlugin.js → DSLDataSpace_LegendQueryApplicationPlugin.js} +27 -3
  11. package/lib/components/query/DSLDataSpace_LegendQueryApplicationPlugin.js.map +1 -0
  12. package/lib/components/query/DataSpaceQueryEditor.d.ts +20 -0
  13. package/lib/components/query/DataSpaceQueryEditor.d.ts.map +1 -0
  14. package/lib/components/query/DataSpaceQueryEditor.js +43 -0
  15. package/lib/components/query/DataSpaceQueryEditor.js.map +1 -0
  16. package/lib/components/query/DataSpaceQuerySetup.d.ts.map +1 -1
  17. package/lib/components/query/DataSpaceQuerySetup.js +4 -17
  18. package/lib/components/query/DataSpaceQuerySetup.js.map +1 -1
  19. package/lib/components/studio/{DSLDataSpace_LegendStudioPlugin.d.ts → DSLDataSpace_LegendStudioApplicationPlugin.d.ts} +3 -3
  20. package/lib/components/studio/DSLDataSpace_LegendStudioApplicationPlugin.d.ts.map +1 -0
  21. package/lib/components/studio/{DSLDataSpace_LegendStudioPlugin.js → DSLDataSpace_LegendStudioApplicationPlugin.js} +3 -3
  22. package/lib/components/studio/DSLDataSpace_LegendStudioApplicationPlugin.js.map +1 -0
  23. package/lib/graphManager/DSLDataSpace_PureGraphManagerPlugin.d.ts +2 -1
  24. package/lib/graphManager/DSLDataSpace_PureGraphManagerPlugin.d.ts.map +1 -1
  25. package/lib/graphManager/DSLDataSpace_PureGraphManagerPlugin.js +4 -0
  26. package/lib/graphManager/DSLDataSpace_PureGraphManagerPlugin.js.map +1 -1
  27. package/lib/graphManager/action/analytics/DataSpaceAnalysis.d.ts +50 -0
  28. package/lib/graphManager/action/analytics/DataSpaceAnalysis.d.ts.map +1 -0
  29. package/lib/graphManager/action/analytics/DataSpaceAnalysis.js +48 -0
  30. package/lib/graphManager/action/analytics/DataSpaceAnalysis.js.map +1 -0
  31. package/lib/graphManager/protocol/DSLDataSpace_PureGraphManagerExtension.d.ts +23 -0
  32. package/lib/graphManager/protocol/DSLDataSpace_PureGraphManagerExtension.d.ts.map +1 -0
  33. package/lib/graphManager/protocol/DSLDataSpace_PureGraphManagerExtension.js +21 -0
  34. package/lib/graphManager/protocol/DSLDataSpace_PureGraphManagerExtension.js.map +1 -0
  35. package/lib/graphManager/protocol/DSLDataSpace_PureGraphManagerExtensionBuilder.d.ts +18 -0
  36. package/lib/graphManager/protocol/DSLDataSpace_PureGraphManagerExtensionBuilder.d.ts.map +1 -0
  37. package/lib/graphManager/protocol/DSLDataSpace_PureGraphManagerExtensionBuilder.js +20 -0
  38. package/lib/graphManager/protocol/DSLDataSpace_PureGraphManagerExtensionBuilder.js.map +1 -0
  39. package/lib/graphManager/protocol/v1/V1_DSLDataSpace_PureGraphManagerExtension.d.ts +26 -0
  40. package/lib/graphManager/protocol/v1/V1_DSLDataSpace_PureGraphManagerExtension.d.ts.map +1 -0
  41. package/lib/graphManager/protocol/v1/V1_DSLDataSpace_PureGraphManagerExtension.js +131 -0
  42. package/lib/graphManager/protocol/v1/V1_DSLDataSpace_PureGraphManagerExtension.js.map +1 -0
  43. package/lib/graphManager/protocol/v1/engine/analytics/V1_DataSpaceAnalysis.d.ts +53 -0
  44. package/lib/graphManager/protocol/v1/engine/analytics/V1_DataSpaceAnalysis.d.ts.map +1 -0
  45. package/lib/graphManager/protocol/v1/engine/analytics/V1_DataSpaceAnalysis.js +78 -0
  46. package/lib/graphManager/protocol/v1/engine/analytics/V1_DataSpaceAnalysis.js.map +1 -0
  47. package/lib/index.css +2 -2
  48. package/lib/index.css.map +1 -1
  49. package/lib/index.d.ts +4 -2
  50. package/lib/index.d.ts.map +1 -1
  51. package/lib/index.js +4 -2
  52. package/lib/index.js.map +1 -1
  53. package/lib/models/protocols/pure/v1/transformation/pureProtocol/V1_DSLDataSpace_ProtocolHelper.d.ts +3 -1
  54. package/lib/models/protocols/pure/v1/transformation/pureProtocol/V1_DSLDataSpace_ProtocolHelper.d.ts.map +1 -1
  55. package/lib/models/protocols/pure/v1/transformation/pureProtocol/V1_DSLDataSpace_ProtocolHelper.js +1 -1
  56. package/lib/models/protocols/pure/v1/transformation/pureProtocol/V1_DSLDataSpace_ProtocolHelper.js.map +1 -1
  57. package/lib/package.json +6 -5
  58. package/lib/stores/DataSpaceViewerState.d.ts +7 -11
  59. package/lib/stores/DataSpaceViewerState.d.ts.map +1 -1
  60. package/lib/stores/DataSpaceViewerState.js +10 -32
  61. package/lib/stores/DataSpaceViewerState.js.map +1 -1
  62. package/lib/stores/query/DSLDataSpace_LegendQueryRouter.d.ts +32 -0
  63. package/lib/stores/query/DSLDataSpace_LegendQueryRouter.d.ts.map +1 -0
  64. package/lib/stores/query/DSLDataSpace_LegendQueryRouter.js +34 -0
  65. package/lib/stores/query/DSLDataSpace_LegendQueryRouter.js.map +1 -0
  66. package/lib/stores/query/DataSpaceQueryEditorStore.d.ts +31 -0
  67. package/lib/stores/query/DataSpaceQueryEditorStore.d.ts.map +1 -0
  68. package/lib/stores/query/DataSpaceQueryEditorStore.js +87 -0
  69. package/lib/stores/query/DataSpaceQueryEditorStore.js.map +1 -0
  70. package/lib/stores/query/DataSpaceQuerySetupState.d.ts +3 -4
  71. package/lib/stores/query/DataSpaceQuerySetupState.d.ts.map +1 -1
  72. package/lib/stores/query/DataSpaceQuerySetupState.js +34 -44
  73. package/lib/stores/query/DataSpaceQuerySetupState.js.map +1 -1
  74. package/package.json +16 -15
  75. package/src/DSLDataSpace_Const.ts +20 -0
  76. package/src/components/DataSpaceViewer.tsx +56 -66
  77. package/src/components/query/{DSLDataSpace_LegendQueryPlugin.tsx → DSLDataSpace_LegendQueryApplicationPlugin.tsx} +39 -2
  78. package/src/components/query/DataSpaceQueryEditor.tsx +106 -0
  79. package/src/components/query/DataSpaceQuerySetup.tsx +23 -32
  80. package/src/components/studio/{DSLDataSpace_LegendStudioPlugin.tsx → DSLDataSpace_LegendStudioApplicationPlugin.tsx} +8 -8
  81. package/src/graphManager/DSLDataSpace_PureGraphManagerPlugin.ts +6 -0
  82. package/src/graphManager/action/analytics/DataSpaceAnalysis.ts +64 -0
  83. package/src/graphManager/protocol/DSLDataSpace_PureGraphManagerExtension.ts +42 -0
  84. package/src/graphManager/protocol/DSLDataSpace_PureGraphManagerExtensionBuilder.ts +27 -0
  85. package/src/graphManager/protocol/v1/V1_DSLDataSpace_PureGraphManagerExtension.ts +228 -0
  86. package/src/graphManager/protocol/v1/engine/analytics/V1_DataSpaceAnalysis.ts +117 -0
  87. package/src/index.ts +4 -2
  88. package/src/models/protocols/pure/v1/transformation/pureProtocol/V1_DSLDataSpace_ProtocolHelper.ts +1 -1
  89. package/src/stores/DataSpaceViewerState.ts +23 -54
  90. package/src/stores/query/DSLDataSpace_LegendQueryRouter.ts +69 -0
  91. package/src/stores/query/DataSpaceQueryEditorStore.ts +141 -0
  92. package/src/stores/query/DataSpaceQuerySetupState.ts +65 -73
  93. package/tsconfig.json +11 -2
  94. package/lib/components/query/DSLDataSpace_LegendQueryPlugin.d.ts.map +0 -1
  95. package/lib/components/query/DSLDataSpace_LegendQueryPlugin.js.map +0 -1
  96. package/lib/components/studio/DSLDataSpace_LegendStudioPlugin.d.ts.map +0 -1
  97. package/lib/components/studio/DSLDataSpace_LegendStudioPlugin.js.map +0 -1
@@ -0,0 +1,106 @@
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 { observer, useLocalObservable } from 'mobx-react-lite';
18
+ import { getQueryParameters } from '@finos/legend-shared';
19
+ import { useApplicationStore } from '@finos/legend-application';
20
+ import {
21
+ parseGAVCoordinates,
22
+ useDepotServerClient,
23
+ } from '@finos/legend-server-depot';
24
+ import {
25
+ LEGEND_QUERY_PATH_PARAM_TOKEN,
26
+ LEGEND_QUERY_QUERY_PARAM_TOKEN,
27
+ QueryEditor,
28
+ QueryEditorStoreContext,
29
+ useLegendQueryApplicationStore,
30
+ useLegendQueryBaseStore,
31
+ } from '@finos/legend-query';
32
+ import { useParams } from 'react-router';
33
+ import { DataSpaceQueryEditorStore } from '../../stores/query/DataSpaceQueryEditorStore.js';
34
+ import {
35
+ type DataSpaceQueryEditorPathParams,
36
+ type DataSpaceQueryEditorQueryParams,
37
+ DATA_SPACE_QUERY_EDITOR_PATH_PARAM_TOKEN,
38
+ } from '../../stores/query/DSLDataSpace_LegendQueryRouter.js';
39
+
40
+ const DataSpaceQueryEditorStoreProvider: React.FC<{
41
+ children: React.ReactNode;
42
+ gav: string;
43
+ dataSpacePath: string;
44
+ executionContext: string;
45
+ runtimePath: string | undefined;
46
+ classPath: string | undefined;
47
+ }> = ({
48
+ children,
49
+ gav,
50
+ dataSpacePath,
51
+ executionContext,
52
+ runtimePath,
53
+ classPath,
54
+ }) => {
55
+ const { groupId, artifactId, versionId } = parseGAVCoordinates(gav);
56
+ const applicationStore = useLegendQueryApplicationStore();
57
+ const depotServerClient = useDepotServerClient();
58
+ const baseStore = useLegendQueryBaseStore();
59
+ const store = useLocalObservable(
60
+ () =>
61
+ new DataSpaceQueryEditorStore(
62
+ applicationStore,
63
+ depotServerClient,
64
+ baseStore.pluginManager,
65
+ groupId,
66
+ artifactId,
67
+ versionId,
68
+ dataSpacePath,
69
+ executionContext,
70
+ runtimePath,
71
+ classPath,
72
+ ),
73
+ );
74
+ return (
75
+ <QueryEditorStoreContext.Provider value={store}>
76
+ {children}
77
+ </QueryEditorStoreContext.Provider>
78
+ );
79
+ };
80
+
81
+ export const DataSpaceQueryEditor = observer(() => {
82
+ const applicationStore = useApplicationStore();
83
+ const params = useParams<DataSpaceQueryEditorPathParams>();
84
+ const gav = params[LEGEND_QUERY_PATH_PARAM_TOKEN.GAV];
85
+ const dataSpacePath =
86
+ params[DATA_SPACE_QUERY_EDITOR_PATH_PARAM_TOKEN.DATA_SPACE_PATH];
87
+ const executionContext =
88
+ params[DATA_SPACE_QUERY_EDITOR_PATH_PARAM_TOKEN.EXECUTION_CONTEXT];
89
+ const runtimePath = params[LEGEND_QUERY_PATH_PARAM_TOKEN.RUNTIME_PATH];
90
+ const classPath = getQueryParameters<DataSpaceQueryEditorQueryParams>(
91
+ applicationStore.navigator.getCurrentLocation(),
92
+ true,
93
+ )[LEGEND_QUERY_QUERY_PARAM_TOKEN.CLASS_PATH];
94
+
95
+ return (
96
+ <DataSpaceQueryEditorStoreProvider
97
+ gav={gav}
98
+ dataSpacePath={dataSpacePath}
99
+ executionContext={executionContext}
100
+ runtimePath={runtimePath}
101
+ classPath={classPath}
102
+ >
103
+ <QueryEditor />
104
+ </DataSpaceQueryEditorStoreProvider>
105
+ );
106
+ });
@@ -27,7 +27,7 @@ import {
27
27
  CustomSelectorInput,
28
28
  SearchIcon,
29
29
  } from '@finos/legend-art';
30
- import { useQuerySetupStore, useLegendQueryStore } from '@finos/legend-query';
30
+ import { useQuerySetupStore } from '@finos/legend-query';
31
31
  import { generateGAVCoordinates } from '@finos/legend-server-depot';
32
32
  import { debounce } from '@finos/legend-shared';
33
33
  import { flowResult } from 'mobx';
@@ -50,7 +50,6 @@ export const DataspaceQuerySetup = observer(
50
50
  const { querySetupState } = props;
51
51
  const applicationStore = useApplicationStore();
52
52
  const setupStore = useQuerySetupStore();
53
- const queryStore = useLegendQueryStore();
54
53
  const dataSpaceSearchRef = useRef<SelectComponent>(null);
55
54
  const [searchText, setSearchText] = useState('');
56
55
 
@@ -73,7 +72,6 @@ export const DataspaceQuerySetup = observer(
73
72
  const back = (): void => {
74
73
  setupStore.setSetupState(undefined);
75
74
  querySetupState.setCurrentDataSpace(undefined);
76
- queryStore.graphManagerState.resetGraph();
77
75
  };
78
76
 
79
77
  // query
@@ -84,7 +82,6 @@ export const DataspaceQuerySetup = observer(
84
82
  : null;
85
83
  const onDataSpaceOptionChange = (option: DataSpaceOption | null): void => {
86
84
  if (option?.value !== querySetupState.currentDataSpace) {
87
- queryStore.graphManagerState.resetGraph();
88
85
  querySetupState.setCurrentDataSpace(option?.value);
89
86
  querySetupState.setDataSpaceViewerState(undefined);
90
87
  }
@@ -133,7 +130,7 @@ export const DataspaceQuerySetup = observer(
133
130
  useEffect(() => {
134
131
  if (querySetupState.currentDataSpace) {
135
132
  flowResult(
136
- querySetupState.setUpDataSpace(querySetupState.currentDataSpace),
133
+ querySetupState.loadDataSpace(querySetupState.currentDataSpace),
137
134
  ).catch(applicationStore.alertUnhandledError);
138
135
  }
139
136
  }, [querySetupState, applicationStore, querySetupState.currentDataSpace]);
@@ -202,40 +199,34 @@ export const DataspaceQuerySetup = observer(
202
199
  </div>
203
200
  <div className="query-setup__data-space__view">
204
201
  <PanelLoadingIndicator
205
- isLoading={querySetupState.setUpDataSpaceState.isInProgress}
202
+ isLoading={querySetupState.loadDataSpaceState.isInProgress}
206
203
  />
207
204
  {querySetupState.dataSpaceViewerState && (
208
205
  <DataSpaceViewer
209
206
  dataSpaceViewerState={querySetupState.dataSpaceViewerState}
210
207
  />
211
208
  )}
212
- {!querySetupState.dataSpaceViewerState &&
213
- querySetupState.setUpDataSpaceState.isInProgress && (
214
- <BlankPanelContent>
215
- {querySetupState.queryStore.buildGraphState.message ??
216
- querySetupState.queryStore.graphManagerState
217
- .systemBuildState.message ??
218
- querySetupState.queryStore.graphManagerState
219
- .dependenciesBuildState.message ??
220
- querySetupState.queryStore.graphManagerState
221
- .generationsBuildState.message ??
222
- querySetupState.queryStore.graphManagerState.graphBuildState
223
- .message}
224
- </BlankPanelContent>
225
- )}
226
- {!querySetupState.dataSpaceViewerState &&
227
- querySetupState.setUpDataSpaceState.hasFailed && (
228
- <BlankPanelContent>
229
- <div className="query-setup__data-space__view--failed">
230
- <div className="query-setup__data-space__view--failed__icon">
231
- <TimesCircleIcon />
209
+ {!querySetupState.dataSpaceViewerState && (
210
+ <>
211
+ {querySetupState.loadDataSpaceState.isInProgress && (
212
+ <BlankPanelContent>
213
+ {querySetupState.loadDataSpaceState.message}
214
+ </BlankPanelContent>
215
+ )}
216
+ {querySetupState.loadDataSpaceState.hasFailed && (
217
+ <BlankPanelContent>
218
+ <div className="query-setup__data-space__view--failed">
219
+ <div className="query-setup__data-space__view--failed__icon">
220
+ <TimesCircleIcon />
221
+ </div>
222
+ <div className="query-setup__data-space__view--failed__text">
223
+ Can&apos;t load data space
224
+ </div>
232
225
  </div>
233
- <div className="query-setup__data-space__view--failed__text">
234
- Can&apos;t load data space
235
- </div>
236
- </div>
237
- </BlankPanelContent>
238
- )}
226
+ </BlankPanelContent>
227
+ )}
228
+ </>
229
+ )}
239
230
  </div>
240
231
  </div>
241
232
  </div>
@@ -20,7 +20,7 @@ import {
20
20
  type ElementTypeGetter,
21
21
  type ElementProjectExplorerDnDTypeGetter,
22
22
  type ElementIconGetter,
23
- type DSL_LegendStudioPlugin_Extension,
23
+ type DSL_LegendStudioApplicationPlugin_Extension,
24
24
  type NewElementState,
25
25
  type ElementEditorStateCreator,
26
26
  type EditorStore,
@@ -31,7 +31,7 @@ import {
31
31
  type PureGrammarTextSuggestion,
32
32
  type PureGrammarParserElementSnippetSuggestionsGetter,
33
33
  UnsupportedElementEditorState,
34
- LegendStudioPlugin,
34
+ LegendStudioApplicationPlugin,
35
35
  } from '@finos/legend-studio';
36
36
  import { SquareIcon } from '@finos/legend-art';
37
37
  import {
@@ -50,15 +50,15 @@ import {
50
50
  PURE_GRAMMAR_DATA_SPACE_PARSER_NAME,
51
51
  } from '../../graphManager/DSLDataSpace_PureGraphManagerPlugin.js';
52
52
  import { SIMPLE_DATA_SPACE_SNIPPET } from './DSLDataSpace_CodeSnippets.js';
53
- import type { LegendApplicationDocumentationEntry } from '@finos/legend-application';
53
+ import type { DocumentationEntry } from '@finos/legend-application';
54
54
 
55
55
  const DATA_SPACE_ELEMENT_TYPE = 'DATA SPACE';
56
56
  const DATA_SPACE_ELEMENT_PROJECT_EXPLORER_DND_TYPE =
57
57
  'PROJECT_EXPLORER_DATA_SPACE';
58
58
 
59
- export class DSLDataSpace_LegendStudioPlugin
60
- extends LegendStudioPlugin
61
- implements DSL_LegendStudioPlugin_Extension
59
+ export class DSLDataSpace_LegendStudioApplicationPlugin
60
+ extends LegendStudioApplicationPlugin
61
+ implements DSL_LegendStudioApplicationPlugin_Extension
62
62
  {
63
63
  constructor() {
64
64
  super(packageJson.extensions.studioPlugin, packageJson.version);
@@ -162,7 +162,7 @@ export class DSLDataSpace_LegendStudioPlugin
162
162
  editorStore: EditorStore,
163
163
  parserKeyword: string,
164
164
  elementKeyword: string,
165
- ): LegendApplicationDocumentationEntry | undefined => {
165
+ ): DocumentationEntry | undefined => {
166
166
  if (parserKeyword === PURE_GRAMMAR_DATA_SPACE_PARSER_NAME) {
167
167
  if (elementKeyword === PURE_GRAMMAR_DATA_SPACE_ELEMENT_TYPE_LABEL) {
168
168
  return editorStore.applicationStore.documentationService.getDocEntry(
@@ -180,7 +180,7 @@ export class DSLDataSpace_LegendStudioPlugin
180
180
  (
181
181
  editorStore: EditorStore,
182
182
  parserKeyword: string,
183
- ): LegendApplicationDocumentationEntry | undefined => {
183
+ ): DocumentationEntry | undefined => {
184
184
  if (parserKeyword === PURE_GRAMMAR_DATA_SPACE_PARSER_NAME) {
185
185
  return editorStore.applicationStore.documentationService.getDocEntry(
186
186
  DSL_DATA_SPACE_LEGEND_STUDIO_DOCUMENTATION_KEY.GRAMMAR_PARSER,
@@ -22,8 +22,10 @@ import {
22
22
  type ElementObserver,
23
23
  type PackageableElement,
24
24
  type PureGrammarElementLabeler,
25
+ type PureGraphManagerExtensionBuilder,
25
26
  } from '@finos/legend-graph';
26
27
  import { observe_DataSpace } from './action/changeDetection/DSLDataSpace_ObserverHelper.js';
28
+ import { DSLDataSpace_buildGraphManagerExtension } from './protocol/DSLDataSpace_PureGraphManagerExtensionBuilder.js';
27
29
 
28
30
  export const PURE_GRAMMAR_DATA_SPACE_PARSER_NAME = 'DataSpace';
29
31
  export const PURE_GRAMMAR_DATA_SPACE_ELEMENT_TYPE_LABEL = 'DataSpace';
@@ -33,6 +35,10 @@ export class DSLDataSpace_PureGraphManagerPlugin extends PureGraphManagerPlugin
33
35
  super(packageJson.extensions.pureGraphManagerPlugin, packageJson.version);
34
36
  }
35
37
 
38
+ override getExtraPureGraphManagerExtensionBuilders(): PureGraphManagerExtensionBuilder[] {
39
+ return [DSLDataSpace_buildGraphManagerExtension];
40
+ }
41
+
36
42
  override getExtraPureGrammarParserNames(): string[] {
37
43
  return [PURE_GRAMMAR_DATA_SPACE_PARSER_NAME];
38
44
  }
@@ -0,0 +1,64 @@
1
+ /**
2
+ * Copyright (c) 2020-present, Goldman Sachs
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+
17
+ import type { Diagram } from '@finos/legend-extension-dsl-diagram';
18
+ import type {
19
+ Mapping,
20
+ PackageableRuntime,
21
+ PureModel,
22
+ } from '@finos/legend-graph';
23
+ import { uuid } from '@finos/legend-shared';
24
+ import type { DataSpaceSupportInfo } from '../../../models/metamodels/pure/model/packageableElements/dataSpace/DSLDataSpace_DataSpace.js';
25
+
26
+ export class DataSpaceExecutionContextAnalysisResult {
27
+ name!: string;
28
+ description?: string | undefined;
29
+ mapping!: Mapping;
30
+ defaultRuntime!: PackageableRuntime;
31
+ compatibleRuntimes!: PackageableRuntime[];
32
+ }
33
+
34
+ export class DataSpaceTaggedValueInfo {
35
+ readonly _UUID = uuid();
36
+
37
+ profile!: string;
38
+ tag!: string;
39
+ value!: string;
40
+ }
41
+
42
+ export class DataSpaceStereotypeInfo {
43
+ readonly _UUID = uuid();
44
+
45
+ profile!: string;
46
+ value!: string;
47
+ }
48
+
49
+ export class DataSpaceAnalysisResult {
50
+ name!: string;
51
+ package!: string;
52
+ path!: string;
53
+ taggedValues: DataSpaceTaggedValueInfo[] = [];
54
+ stereotypes: DataSpaceStereotypeInfo[] = [];
55
+ description?: string | undefined;
56
+ supportInfo?: DataSpaceSupportInfo | undefined;
57
+
58
+ graph!: PureModel;
59
+
60
+ executionContextsIndex!: Map<string, DataSpaceExecutionContextAnalysisResult>;
61
+ defaultExecutionContext!: DataSpaceExecutionContextAnalysisResult;
62
+
63
+ featuredDiagrams: Diagram[] = [];
64
+ }
@@ -0,0 +1,42 @@
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
+ type AbstractPureGraphManager,
19
+ AbstractPureGraphManagerExtension,
20
+ } from '@finos/legend-graph';
21
+ import type { Entity } from '@finos/legend-model-storage';
22
+ import { guaranteeNonNullable } from '@finos/legend-shared';
23
+ import type { DataSpaceAnalysisResult } from '../action/analytics/DataSpaceAnalysis.js';
24
+
25
+ export abstract class DSLDataSpace_PureGraphManagerExtension extends AbstractPureGraphManagerExtension {
26
+ abstract analyzeDataSpace(
27
+ dataSpacePath: string,
28
+ entities: Entity[],
29
+ dependencyEntitiesIndex: Map<string, Entity[]>,
30
+ ): Promise<DataSpaceAnalysisResult>;
31
+ }
32
+
33
+ export const getDSLDataSpaceGraphManagerExtension = (
34
+ graphManager: AbstractPureGraphManager,
35
+ ): DSLDataSpace_PureGraphManagerExtension =>
36
+ guaranteeNonNullable(
37
+ graphManager.extensions.find(
38
+ (extension) =>
39
+ extension instanceof DSLDataSpace_PureGraphManagerExtension,
40
+ ),
41
+ `Can't find DSL Data Space Pure graph manager extension`,
42
+ ) as DSLDataSpace_PureGraphManagerExtension;
@@ -0,0 +1,27 @@
1
+ /**
2
+ * Copyright (c) 2020-present, Goldman Sachs
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+
17
+ import type {
18
+ AbstractPureGraphManager,
19
+ AbstractPureGraphManagerExtension,
20
+ } from '@finos/legend-graph';
21
+ import { V1_DSLDataSpace_PureGraphManagerExtension } from './v1/V1_DSLDataSpace_PureGraphManagerExtension.js';
22
+
23
+ export const DSLDataSpace_buildGraphManagerExtension = (
24
+ graphManager: AbstractPureGraphManager,
25
+ ): AbstractPureGraphManagerExtension =>
26
+ // NOTE: until we support more client versions, we always default to return V1
27
+ new V1_DSLDataSpace_PureGraphManagerExtension(graphManager);
@@ -0,0 +1,228 @@
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 { getDiagram } from '@finos/legend-extension-dsl-diagram';
18
+ import {
19
+ PureModel,
20
+ V1_PureGraphManager,
21
+ PureClientVersion,
22
+ type AbstractPureGraphManager,
23
+ CoreModel,
24
+ SystemModel,
25
+ V1_Mapping,
26
+ resolvePackagePathAndElementName,
27
+ V1_PureModelContextType,
28
+ V1_PackageableRuntime,
29
+ V1_EngineRuntime,
30
+ } from '@finos/legend-graph';
31
+ import type { Entity } from '@finos/legend-model-storage';
32
+ import {
33
+ ActionState,
34
+ guaranteeNonEmptyString,
35
+ guaranteeNonNullable,
36
+ guaranteeType,
37
+ uniq,
38
+ type PlainObject,
39
+ } from '@finos/legend-shared';
40
+ import { DataSpaceSupportEmail } from '../../../models/metamodels/pure/model/packageableElements/dataSpace/DSLDataSpace_DataSpace.js';
41
+ import { V1_DataSpaceSupportEmail } from '../../../models/protocols/pure/v1/model/packageableElements/dataSpace/V1_DSLDataSpace_DataSpace.js';
42
+ import {
43
+ DataSpaceAnalysisResult,
44
+ DataSpaceExecutionContextAnalysisResult,
45
+ DataSpaceStereotypeInfo,
46
+ DataSpaceTaggedValueInfo,
47
+ } from '../../action/analytics/DataSpaceAnalysis.js';
48
+ import { DSLDataSpace_PureGraphManagerExtension } from '../DSLDataSpace_PureGraphManagerExtension.js';
49
+ import { V1_DataSpaceAnalysisResult } from './engine/analytics/V1_DataSpaceAnalysis.js';
50
+
51
+ const ANALYZE_DATA_SPACE_TRACE = 'analyze data space';
52
+
53
+ export class V1_DSLDataSpace_PureGraphManagerExtension extends DSLDataSpace_PureGraphManagerExtension {
54
+ declare graphManager: V1_PureGraphManager;
55
+
56
+ constructor(graphManager: AbstractPureGraphManager) {
57
+ super(graphManager);
58
+ this.graphManager = guaranteeType(graphManager, V1_PureGraphManager);
59
+ }
60
+
61
+ getSupportedProtocolVersion(): string {
62
+ return PureClientVersion.V1_0_0;
63
+ }
64
+
65
+ async analyzeDataSpace(
66
+ dataSpacePath: string,
67
+ entities: Entity[],
68
+ dependencyEntitiesIndex: Map<string, Entity[]>,
69
+ ): Promise<DataSpaceAnalysisResult> {
70
+ // prepare graph data for analysis
71
+ // NOTE: we don't do serialization roundtrip here to save time
72
+ const graphDataForAnalysis = {
73
+ _type: V1_PureModelContextType.DATA,
74
+ elements: Array.from(dependencyEntitiesIndex.values())
75
+ .flat()
76
+ .concat(entities)
77
+ .map((entity) => entity.content),
78
+ };
79
+
80
+ const engineServerClient = this.graphManager.engine.getEngineServerClient();
81
+ const analysisResult = V1_DataSpaceAnalysisResult.serialization.fromJson(
82
+ await engineServerClient.postWithTracing<
83
+ PlainObject<V1_DataSpaceAnalysisResult>
84
+ >(
85
+ engineServerClient.getTraceData(ANALYZE_DATA_SPACE_TRACE),
86
+ `${engineServerClient._pure()}/analytics/dataSpace/render`,
87
+ {
88
+ clientVersion: V1_PureGraphManager.TARGET_PROTOCOL_VERSION,
89
+ dataSpace: dataSpacePath,
90
+ model: graphDataForAnalysis,
91
+ },
92
+ {},
93
+ undefined,
94
+ undefined,
95
+ { enableCompression: true },
96
+ ),
97
+ );
98
+
99
+ const result = new DataSpaceAnalysisResult();
100
+ result.name = analysisResult.name;
101
+ result.package = analysisResult.package;
102
+ result.path = analysisResult.path;
103
+ result.description = analysisResult.description;
104
+
105
+ result.taggedValues = analysisResult.taggedValues.map((taggedValue) => {
106
+ const info = new DataSpaceTaggedValueInfo();
107
+ info.profile = taggedValue.profile;
108
+ info.tag = taggedValue.value;
109
+ info.value = taggedValue.value;
110
+ return info;
111
+ });
112
+ result.stereotypes = analysisResult.stereotypes.map((stereotype) => {
113
+ const info = new DataSpaceStereotypeInfo();
114
+ info.profile = stereotype.profile;
115
+ info.value = stereotype.value;
116
+ return info;
117
+ });
118
+
119
+ if (analysisResult.supportInfo) {
120
+ if (analysisResult.supportInfo instanceof V1_DataSpaceSupportEmail) {
121
+ const supportEmail = new DataSpaceSupportEmail();
122
+ supportEmail.address = guaranteeNonEmptyString(
123
+ analysisResult.supportInfo.address,
124
+ `Data space support email 'address' field is missing or empty`,
125
+ );
126
+ result.supportInfo = supportEmail;
127
+ }
128
+ // NOTE: we will relax the check and not throw here for unknown support info type
129
+ }
130
+
131
+ // create an empty graph
132
+ const extensionElementClasses = this.graphManager.pluginManager
133
+ .getPureGraphPlugins()
134
+ .flatMap((plugin) => plugin.getExtraPureGraphExtensionClasses?.() ?? []);
135
+ const systemModel = new SystemModel(extensionElementClasses);
136
+ const coreModel = new CoreModel(extensionElementClasses);
137
+ await this.graphManager.buildSystem(
138
+ coreModel,
139
+ systemModel,
140
+ ActionState.create(),
141
+ {},
142
+ );
143
+ systemModel.initializeAutoImports();
144
+ const graph = new PureModel(
145
+ coreModel,
146
+ systemModel,
147
+ this.graphManager.pluginManager.getPureGraphPlugins(),
148
+ );
149
+
150
+ // Create dummy mappings and runtimes
151
+ // TODO?: these stubbed mappings and runtimes are not really useful that useful, so either we should
152
+ // simplify the model here or potentially refactor the backend analytics endpoint to return these as model
153
+ const mappingModels = uniq(
154
+ analysisResult.executionContexts.map((context) => context.mapping),
155
+ ).map((path) => {
156
+ const mapping = new V1_Mapping();
157
+ const [packagePath, name] = resolvePackagePathAndElementName(path);
158
+ mapping.package = packagePath;
159
+ mapping.name = name;
160
+ return mapping;
161
+ });
162
+ const runtimeModels = uniq(
163
+ analysisResult.executionContexts
164
+ .map((context) => context.defaultRuntime)
165
+ .concat(
166
+ analysisResult.executionContexts.flatMap(
167
+ (val) => val.compatibleRuntimes,
168
+ ),
169
+ ),
170
+ ).map((path) => {
171
+ const runtime = new V1_PackageableRuntime();
172
+ const [packagePath, name] = resolvePackagePathAndElementName(path);
173
+ runtime.package = packagePath;
174
+ runtime.name = name;
175
+ runtime.runtimeValue = new V1_EngineRuntime();
176
+ return runtime;
177
+ });
178
+
179
+ // prepare the model context data
180
+ // scan for models coming from system so we don't duplicate them when building the graph
181
+ const graphEntities = analysisResult.model.elements
182
+ .concat(mappingModels)
183
+ .concat(runtimeModels)
184
+ // NOTE: if an element could be found in the graph already it means it comes from system
185
+ // so we could rid of it
186
+ .filter((el) => !graph.getNullableElement(el.path, false))
187
+ .map((el) => this.graphManager.elementProtocolToEntity(el));
188
+
189
+ await this.graphManager.buildGraph(
190
+ graph,
191
+ graphEntities,
192
+ ActionState.create(),
193
+ );
194
+
195
+ // build execution context info
196
+ result.executionContextsIndex = new Map<
197
+ string,
198
+ DataSpaceExecutionContextAnalysisResult
199
+ >();
200
+ analysisResult.executionContexts.forEach((context) => {
201
+ const contextAnalysisResult =
202
+ new DataSpaceExecutionContextAnalysisResult();
203
+ contextAnalysisResult.name = context.name;
204
+ contextAnalysisResult.description = context.description;
205
+ contextAnalysisResult.mapping = graph.getMapping(context.mapping);
206
+ contextAnalysisResult.defaultRuntime = graph.getRuntime(
207
+ context.defaultRuntime,
208
+ );
209
+ contextAnalysisResult.compatibleRuntimes = context.compatibleRuntimes.map(
210
+ (runtime) => graph.getRuntime(runtime),
211
+ );
212
+ result.executionContextsIndex.set(
213
+ contextAnalysisResult.name,
214
+ contextAnalysisResult,
215
+ );
216
+ });
217
+ result.defaultExecutionContext = guaranteeNonNullable(
218
+ result.executionContextsIndex.get(analysisResult.defaultExecutionContext),
219
+ );
220
+
221
+ // find featured diagrams
222
+ result.featuredDiagrams = analysisResult.featuredDiagrams.map((path) =>
223
+ getDiagram(path, graph),
224
+ );
225
+
226
+ return result;
227
+ }
228
+ }