@finos/legend-extension-dsl-data-space 4.0.5 → 6.1.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 (154) 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/DSLDataSpace_Extension.d.ts +1 -1
  6. package/lib/DSLDataSpace_Extension.d.ts.map +1 -1
  7. package/lib/DSLDataSpace_Extension.js +3 -3
  8. package/lib/DSLDataSpace_Extension.js.map +1 -1
  9. package/lib/components/DataSpaceViewer.d.ts.map +1 -1
  10. package/lib/components/DataSpaceViewer.js +39 -33
  11. package/lib/components/DataSpaceViewer.js.map +1 -1
  12. package/lib/components/query/{DSLDataSpace_LegendQueryPlugin.d.ts → DSLDataSpace_LegendQueryApplicationPlugin.d.ts} +6 -3
  13. package/lib/components/query/DSLDataSpace_LegendQueryApplicationPlugin.d.ts.map +1 -0
  14. package/lib/components/query/{DSLDataSpace_LegendQueryPlugin.js → DSLDataSpace_LegendQueryApplicationPlugin.js} +28 -4
  15. package/lib/components/query/DSLDataSpace_LegendQueryApplicationPlugin.js.map +1 -0
  16. package/lib/components/query/DataSpaceQueryEditor.d.ts +20 -0
  17. package/lib/components/query/DataSpaceQueryEditor.d.ts.map +1 -0
  18. package/lib/components/query/DataSpaceQueryEditor.js +43 -0
  19. package/lib/components/query/DataSpaceQueryEditor.js.map +1 -0
  20. package/lib/components/query/DataSpaceQuerySetup.d.ts.map +1 -1
  21. package/lib/components/query/DataSpaceQuerySetup.js +13 -21
  22. package/lib/components/query/DataSpaceQuerySetup.js.map +1 -1
  23. package/lib/components/studio/{DSLDataSpace_LegendStudioPlugin.d.ts → DSLDataSpace_LegendStudioApplicationPlugin.d.ts} +3 -3
  24. package/lib/components/studio/DSLDataSpace_LegendStudioApplicationPlugin.d.ts.map +1 -0
  25. package/lib/components/studio/{DSLDataSpace_LegendStudioPlugin.js → DSLDataSpace_LegendStudioApplicationPlugin.js} +5 -5
  26. package/lib/components/studio/DSLDataSpace_LegendStudioApplicationPlugin.js.map +1 -0
  27. package/lib/{models/DSLDataSpace_ModelUtils.d.ts → graph/DSLDataSpace_HashUtils.d.ts} +1 -1
  28. package/lib/graph/DSLDataSpace_HashUtils.d.ts.map +1 -0
  29. package/lib/{models/DSLDataSpace_ModelUtils.js → graph/DSLDataSpace_HashUtils.js} +1 -1
  30. package/lib/graph/DSLDataSpace_HashUtils.js.map +1 -0
  31. package/lib/graph/DSLDataSpace_PureGraphPlugin.js +1 -1
  32. package/lib/graph/DSLDataSpace_PureGraphPlugin.js.map +1 -1
  33. package/lib/{models/metamodels → graph/metamodel}/pure/model/packageableElements/dataSpace/DSLDataSpace_DataSpace.d.ts +1 -0
  34. package/lib/graph/metamodel/pure/model/packageableElements/dataSpace/DSLDataSpace_DataSpace.d.ts.map +1 -0
  35. package/lib/{models/metamodels → graph/metamodel}/pure/model/packageableElements/dataSpace/DSLDataSpace_DataSpace.js +3 -1
  36. package/lib/graph/metamodel/pure/model/packageableElements/dataSpace/DSLDataSpace_DataSpace.js.map +1 -0
  37. package/lib/graphManager/DSLDataSpace_GraphManagerHelper.d.ts +1 -1
  38. package/lib/graphManager/DSLDataSpace_GraphManagerHelper.d.ts.map +1 -1
  39. package/lib/graphManager/DSLDataSpace_GraphManagerHelper.js +1 -1
  40. package/lib/graphManager/DSLDataSpace_GraphManagerHelper.js.map +1 -1
  41. package/lib/graphManager/DSLDataSpace_PureGraphManagerPlugin.d.ts +2 -1
  42. package/lib/graphManager/DSLDataSpace_PureGraphManagerPlugin.d.ts.map +1 -1
  43. package/lib/graphManager/DSLDataSpace_PureGraphManagerPlugin.js +5 -1
  44. package/lib/graphManager/DSLDataSpace_PureGraphManagerPlugin.js.map +1 -1
  45. package/lib/graphManager/action/analytics/DataSpaceAnalysis.d.ts +51 -0
  46. package/lib/graphManager/action/analytics/DataSpaceAnalysis.d.ts.map +1 -0
  47. package/lib/graphManager/action/analytics/DataSpaceAnalysis.js +49 -0
  48. package/lib/graphManager/action/analytics/DataSpaceAnalysis.js.map +1 -0
  49. package/lib/graphManager/action/changeDetection/DSLDataSpace_ObserverHelper.d.ts +1 -1
  50. package/lib/graphManager/action/changeDetection/DSLDataSpace_ObserverHelper.d.ts.map +1 -1
  51. package/lib/graphManager/action/changeDetection/DSLDataSpace_ObserverHelper.js +1 -0
  52. package/lib/graphManager/action/changeDetection/DSLDataSpace_ObserverHelper.js.map +1 -1
  53. package/lib/graphManager/protocol/pure/DSLDataSpace_PureGraphManagerExtension.d.ts +23 -0
  54. package/lib/graphManager/protocol/pure/DSLDataSpace_PureGraphManagerExtension.d.ts.map +1 -0
  55. package/lib/graphManager/protocol/pure/DSLDataSpace_PureGraphManagerExtension.js +21 -0
  56. package/lib/graphManager/protocol/pure/DSLDataSpace_PureGraphManagerExtension.js.map +1 -0
  57. package/lib/graphManager/protocol/pure/DSLDataSpace_PureGraphManagerExtensionBuilder.d.ts +18 -0
  58. package/lib/graphManager/protocol/pure/DSLDataSpace_PureGraphManagerExtensionBuilder.d.ts.map +1 -0
  59. package/lib/graphManager/protocol/pure/DSLDataSpace_PureGraphManagerExtensionBuilder.js +20 -0
  60. package/lib/graphManager/protocol/pure/DSLDataSpace_PureGraphManagerExtensionBuilder.js.map +1 -0
  61. package/lib/{models/protocols → graphManager/protocol}/pure/DSLDataSpace_PureProtocolProcessorPlugin.d.ts +0 -0
  62. package/lib/graphManager/protocol/pure/DSLDataSpace_PureProtocolProcessorPlugin.d.ts.map +1 -0
  63. package/lib/{models/protocols → graphManager/protocol}/pure/DSLDataSpace_PureProtocolProcessorPlugin.js +3 -1
  64. package/lib/graphManager/protocol/pure/DSLDataSpace_PureProtocolProcessorPlugin.js.map +1 -0
  65. package/lib/graphManager/protocol/pure/v1/V1_DSLDataSpace_PureGraphManagerExtension.d.ts +26 -0
  66. package/lib/graphManager/protocol/pure/v1/V1_DSLDataSpace_PureGraphManagerExtension.d.ts.map +1 -0
  67. package/lib/graphManager/protocol/pure/v1/V1_DSLDataSpace_PureGraphManagerExtension.js +159 -0
  68. package/lib/graphManager/protocol/pure/v1/V1_DSLDataSpace_PureGraphManagerExtension.js.map +1 -0
  69. package/lib/{models/protocols → graphManager/protocol}/pure/v1/V1_DSLDataSpace_SystemModels.json +0 -0
  70. package/lib/graphManager/protocol/pure/v1/engine/analytics/V1_DataSpaceAnalysis.d.ts +54 -0
  71. package/lib/graphManager/protocol/pure/v1/engine/analytics/V1_DataSpaceAnalysis.d.ts.map +1 -0
  72. package/lib/graphManager/protocol/pure/v1/engine/analytics/V1_DataSpaceAnalysis.js +80 -0
  73. package/lib/graphManager/protocol/pure/v1/engine/analytics/V1_DataSpaceAnalysis.js.map +1 -0
  74. package/lib/{models/protocols → graphManager/protocol}/pure/v1/model/packageableElements/dataSpace/V1_DSLDataSpace_DataSpace.d.ts +1 -0
  75. package/lib/graphManager/protocol/pure/v1/model/packageableElements/dataSpace/V1_DSLDataSpace_DataSpace.d.ts.map +1 -0
  76. package/lib/{models/protocols → graphManager/protocol}/pure/v1/model/packageableElements/dataSpace/V1_DSLDataSpace_DataSpace.js +3 -1
  77. package/lib/graphManager/protocol/pure/v1/model/packageableElements/dataSpace/V1_DSLDataSpace_DataSpace.js.map +1 -0
  78. package/lib/{models/protocols → graphManager/protocol}/pure/v1/transformation/pureGraph/V1_DSLDataSpace_GraphBuilderHelper.d.ts +1 -1
  79. package/lib/graphManager/protocol/pure/v1/transformation/pureGraph/V1_DSLDataSpace_GraphBuilderHelper.d.ts.map +1 -0
  80. package/lib/{models/protocols → graphManager/protocol}/pure/v1/transformation/pureGraph/V1_DSLDataSpace_GraphBuilderHelper.js +0 -0
  81. package/lib/graphManager/protocol/pure/v1/transformation/pureGraph/V1_DSLDataSpace_GraphBuilderHelper.js.map +1 -0
  82. package/lib/{models/protocols → graphManager/protocol}/pure/v1/transformation/pureProtocol/V1_DSLDataSpace_ProtocolHelper.d.ts +3 -1
  83. package/lib/graphManager/protocol/pure/v1/transformation/pureProtocol/V1_DSLDataSpace_ProtocolHelper.d.ts.map +1 -0
  84. package/lib/{models/protocols → graphManager/protocol}/pure/v1/transformation/pureProtocol/V1_DSLDataSpace_ProtocolHelper.js +2 -1
  85. package/lib/graphManager/protocol/pure/v1/transformation/pureProtocol/V1_DSLDataSpace_ProtocolHelper.js.map +1 -0
  86. package/lib/index.css +2 -2
  87. package/lib/index.css.map +1 -1
  88. package/lib/index.d.ts +5 -3
  89. package/lib/index.d.ts.map +1 -1
  90. package/lib/index.js +5 -3
  91. package/lib/index.js.map +1 -1
  92. package/lib/package.json +15 -14
  93. package/lib/stores/DataSpaceViewerState.d.ts +8 -12
  94. package/lib/stores/DataSpaceViewerState.d.ts.map +1 -1
  95. package/lib/stores/DataSpaceViewerState.js +11 -33
  96. package/lib/stores/DataSpaceViewerState.js.map +1 -1
  97. package/lib/stores/query/DSLDataSpace_LegendQueryRouter.d.ts +32 -0
  98. package/lib/stores/query/DSLDataSpace_LegendQueryRouter.d.ts.map +1 -0
  99. package/lib/stores/query/DSLDataSpace_LegendQueryRouter.js +34 -0
  100. package/lib/stores/query/DSLDataSpace_LegendQueryRouter.js.map +1 -0
  101. package/lib/stores/query/DataSpaceQueryEditorStore.d.ts +31 -0
  102. package/lib/stores/query/DataSpaceQueryEditorStore.d.ts.map +1 -0
  103. package/lib/stores/query/DataSpaceQueryEditorStore.js +88 -0
  104. package/lib/stores/query/DataSpaceQueryEditorStore.js.map +1 -0
  105. package/lib/stores/query/DataSpaceQuerySetupState.d.ts +6 -5
  106. package/lib/stores/query/DataSpaceQuerySetupState.d.ts.map +1 -1
  107. package/lib/stores/query/DataSpaceQuerySetupState.js +41 -46
  108. package/lib/stores/query/DataSpaceQuerySetupState.js.map +1 -1
  109. package/package.json +22 -21
  110. package/src/DSLDataSpace_Const.ts +20 -0
  111. package/src/DSLDataSpace_Extension.ts +3 -3
  112. package/src/components/DataSpaceViewer.tsx +142 -89
  113. package/src/components/query/{DSLDataSpace_LegendQueryPlugin.tsx → DSLDataSpace_LegendQueryApplicationPlugin.tsx} +41 -4
  114. package/src/components/query/DataSpaceQueryEditor.tsx +106 -0
  115. package/src/components/query/DataSpaceQuerySetup.tsx +45 -34
  116. package/src/components/studio/{DSLDataSpace_LegendStudioPlugin.tsx → DSLDataSpace_LegendStudioApplicationPlugin.tsx} +11 -11
  117. package/src/{models/DSLDataSpace_ModelUtils.ts → graph/DSLDataSpace_HashUtils.ts} +0 -0
  118. package/src/graph/DSLDataSpace_PureGraphPlugin.ts +1 -1
  119. package/src/{models/metamodels → graph/metamodel}/pure/model/packageableElements/dataSpace/DSLDataSpace_DataSpace.ts +3 -1
  120. package/src/graphManager/DSLDataSpace_GraphManagerHelper.ts +1 -1
  121. package/src/graphManager/DSLDataSpace_PureGraphManagerPlugin.ts +7 -1
  122. package/src/graphManager/action/analytics/DataSpaceAnalysis.ts +65 -0
  123. package/src/graphManager/action/changeDetection/DSLDataSpace_ObserverHelper.ts +2 -1
  124. package/src/graphManager/protocol/pure/DSLDataSpace_PureGraphManagerExtension.ts +42 -0
  125. package/src/graphManager/protocol/pure/DSLDataSpace_PureGraphManagerExtensionBuilder.ts +27 -0
  126. package/src/{models/protocols → graphManager/protocol}/pure/DSLDataSpace_PureProtocolProcessorPlugin.ts +3 -1
  127. package/src/graphManager/protocol/pure/v1/V1_DSLDataSpace_PureGraphManagerExtension.ts +265 -0
  128. package/src/{models/protocols → graphManager/protocol}/pure/v1/V1_DSLDataSpace_SystemModels.json +0 -0
  129. package/src/graphManager/protocol/pure/v1/engine/analytics/V1_DataSpaceAnalysis.ts +119 -0
  130. package/src/{models/protocols → graphManager/protocol}/pure/v1/model/packageableElements/dataSpace/V1_DSLDataSpace_DataSpace.ts +3 -1
  131. package/src/{models/protocols → graphManager/protocol}/pure/v1/transformation/pureGraph/V1_DSLDataSpace_GraphBuilderHelper.ts +1 -1
  132. package/src/{models/protocols → graphManager/protocol}/pure/v1/transformation/pureProtocol/V1_DSLDataSpace_ProtocolHelper.ts +2 -1
  133. package/src/index.ts +5 -3
  134. package/src/stores/DataSpaceViewerState.ts +24 -55
  135. package/src/stores/query/DSLDataSpace_LegendQueryRouter.ts +69 -0
  136. package/src/stores/query/DataSpaceQueryEditorStore.ts +143 -0
  137. package/src/stores/query/DataSpaceQuerySetupState.ts +74 -75
  138. package/tsconfig.json +18 -9
  139. package/lib/components/query/DSLDataSpace_LegendQueryPlugin.d.ts.map +0 -1
  140. package/lib/components/query/DSLDataSpace_LegendQueryPlugin.js.map +0 -1
  141. package/lib/components/studio/DSLDataSpace_LegendStudioPlugin.d.ts.map +0 -1
  142. package/lib/components/studio/DSLDataSpace_LegendStudioPlugin.js.map +0 -1
  143. package/lib/models/DSLDataSpace_ModelUtils.d.ts.map +0 -1
  144. package/lib/models/DSLDataSpace_ModelUtils.js.map +0 -1
  145. package/lib/models/metamodels/pure/model/packageableElements/dataSpace/DSLDataSpace_DataSpace.d.ts.map +0 -1
  146. package/lib/models/metamodels/pure/model/packageableElements/dataSpace/DSLDataSpace_DataSpace.js.map +0 -1
  147. package/lib/models/protocols/pure/DSLDataSpace_PureProtocolProcessorPlugin.d.ts.map +0 -1
  148. package/lib/models/protocols/pure/DSLDataSpace_PureProtocolProcessorPlugin.js.map +0 -1
  149. package/lib/models/protocols/pure/v1/model/packageableElements/dataSpace/V1_DSLDataSpace_DataSpace.d.ts.map +0 -1
  150. package/lib/models/protocols/pure/v1/model/packageableElements/dataSpace/V1_DSLDataSpace_DataSpace.js.map +0 -1
  151. package/lib/models/protocols/pure/v1/transformation/pureGraph/V1_DSLDataSpace_GraphBuilderHelper.d.ts.map +0 -1
  152. package/lib/models/protocols/pure/v1/transformation/pureGraph/V1_DSLDataSpace_GraphBuilderHelper.js.map +0 -1
  153. package/lib/models/protocols/pure/v1/transformation/pureProtocol/V1_DSLDataSpace_ProtocolHelper.d.ts.map +0 -1
  154. package/lib/models/protocols/pure/v1/transformation/pureProtocol/V1_DSLDataSpace_ProtocolHelper.js.map +0 -1
@@ -0,0 +1,265 @@
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
+ V1_Class,
31
+ } from '@finos/legend-graph';
32
+ import type { Entity } from '@finos/legend-storage';
33
+ import {
34
+ ActionState,
35
+ guaranteeNonEmptyString,
36
+ guaranteeNonNullable,
37
+ guaranteeType,
38
+ isNonNullable,
39
+ uniq,
40
+ type PlainObject,
41
+ } from '@finos/legend-shared';
42
+ import { DataSpaceSupportEmail } from '../../../../graph/metamodel/pure/model/packageableElements/dataSpace/DSLDataSpace_DataSpace.js';
43
+ import { V1_DataSpaceSupportEmail } from '../../../../graphManager/protocol/pure/v1/model/packageableElements/dataSpace/V1_DSLDataSpace_DataSpace.js';
44
+ import {
45
+ DataSpaceAnalysisResult,
46
+ DataSpaceExecutionContextAnalysisResult,
47
+ DataSpaceStereotypeInfo,
48
+ DataSpaceTaggedValueInfo,
49
+ } from '../../../action/analytics/DataSpaceAnalysis.js';
50
+ import { DSLDataSpace_PureGraphManagerExtension } from '../DSLDataSpace_PureGraphManagerExtension.js';
51
+ import { V1_DataSpaceAnalysisResult } from './engine/analytics/V1_DataSpaceAnalysis.js';
52
+
53
+ const ANALYZE_DATA_SPACE_TRACE = 'analyze data space';
54
+
55
+ export class V1_DSLDataSpace_PureGraphManagerExtension extends DSLDataSpace_PureGraphManagerExtension {
56
+ declare graphManager: V1_PureGraphManager;
57
+
58
+ constructor(graphManager: AbstractPureGraphManager) {
59
+ super(graphManager);
60
+ this.graphManager = guaranteeType(graphManager, V1_PureGraphManager);
61
+ }
62
+
63
+ getSupportedProtocolVersion(): string {
64
+ return PureClientVersion.V1_0_0;
65
+ }
66
+
67
+ async analyzeDataSpace(
68
+ dataSpacePath: string,
69
+ entities: Entity[],
70
+ dependencyEntitiesIndex: Map<string, Entity[]>,
71
+ ): Promise<DataSpaceAnalysisResult> {
72
+ // prepare graph data for analysis
73
+ // NOTE: we don't do serialization roundtrip here to save time
74
+ const graphDataForAnalysis = {
75
+ _type: V1_PureModelContextType.DATA,
76
+ elements: Array.from(dependencyEntitiesIndex.values())
77
+ .flat()
78
+ .concat(entities)
79
+ .map((entity) => entity.content),
80
+ };
81
+
82
+ const engineServerClient = this.graphManager.engine.getEngineServerClient();
83
+ const analysisResult = V1_DataSpaceAnalysisResult.serialization.fromJson(
84
+ await engineServerClient.postWithTracing<
85
+ PlainObject<V1_DataSpaceAnalysisResult>
86
+ >(
87
+ engineServerClient.getTraceData(ANALYZE_DATA_SPACE_TRACE),
88
+ `${engineServerClient._pure()}/analytics/dataSpace/render`,
89
+ {
90
+ clientVersion: V1_PureGraphManager.TARGET_PROTOCOL_VERSION,
91
+ dataSpace: dataSpacePath,
92
+ model: graphDataForAnalysis,
93
+ },
94
+ {},
95
+ undefined,
96
+ undefined,
97
+ { enableCompression: true },
98
+ ),
99
+ );
100
+
101
+ const result = new DataSpaceAnalysisResult();
102
+ result.name = analysisResult.name;
103
+ result.package = analysisResult.package;
104
+ result.path = analysisResult.path;
105
+ result.title = analysisResult.title;
106
+ result.description = analysisResult.description;
107
+
108
+ result.taggedValues = analysisResult.taggedValues.map((taggedValue) => {
109
+ const info = new DataSpaceTaggedValueInfo();
110
+ info.profile = taggedValue.profile;
111
+ info.tag = taggedValue.value;
112
+ info.value = taggedValue.value;
113
+ return info;
114
+ });
115
+ result.stereotypes = analysisResult.stereotypes.map((stereotype) => {
116
+ const info = new DataSpaceStereotypeInfo();
117
+ info.profile = stereotype.profile;
118
+ info.value = stereotype.value;
119
+ return info;
120
+ });
121
+
122
+ if (analysisResult.supportInfo) {
123
+ if (analysisResult.supportInfo instanceof V1_DataSpaceSupportEmail) {
124
+ const supportEmail = new DataSpaceSupportEmail();
125
+ supportEmail.address = guaranteeNonEmptyString(
126
+ analysisResult.supportInfo.address,
127
+ `Data space support email 'address' field is missing or empty`,
128
+ );
129
+ result.supportInfo = supportEmail;
130
+ }
131
+ // NOTE: we will relax the check and not throw here for unknown support info type
132
+ }
133
+
134
+ // create an empty graph
135
+ const extensionElementClasses = this.graphManager.pluginManager
136
+ .getPureGraphPlugins()
137
+ .flatMap((plugin) => plugin.getExtraPureGraphExtensionClasses?.() ?? []);
138
+ const systemModel = new SystemModel(extensionElementClasses);
139
+ const coreModel = new CoreModel(extensionElementClasses);
140
+ await this.graphManager.buildSystem(
141
+ coreModel,
142
+ systemModel,
143
+ ActionState.create(),
144
+ {},
145
+ );
146
+ systemModel.initializeAutoImports();
147
+ const graph = new PureModel(
148
+ coreModel,
149
+ systemModel,
150
+ this.graphManager.pluginManager.getPureGraphPlugins(),
151
+ );
152
+
153
+ // Create dummy mappings and runtimes
154
+ // TODO?: these stubbed mappings and runtimes are not really useful that useful, so either we should
155
+ // simplify the model here or potentially refactor the backend analytics endpoint to return these as model
156
+ const mappingModels = uniq(
157
+ analysisResult.executionContexts.map((context) => context.mapping),
158
+ ).map((path) => {
159
+ const mapping = new V1_Mapping();
160
+ const [packagePath, name] = resolvePackagePathAndElementName(path);
161
+ mapping.package = packagePath;
162
+ mapping.name = name;
163
+ return mapping;
164
+ });
165
+ const runtimeModels = uniq(
166
+ analysisResult.executionContexts
167
+ .map((context) => context.defaultRuntime)
168
+ .concat(
169
+ analysisResult.executionContexts.flatMap(
170
+ (val) => val.compatibleRuntimes,
171
+ ),
172
+ ),
173
+ ).map((path) => {
174
+ const runtime = new V1_PackageableRuntime();
175
+ const [packagePath, name] = resolvePackagePathAndElementName(path);
176
+ runtime.package = packagePath;
177
+ runtime.name = name;
178
+ runtime.runtimeValue = new V1_EngineRuntime();
179
+ return runtime;
180
+ });
181
+
182
+ // prepare the model context data
183
+ const graphEntities = analysisResult.model.elements
184
+ // NOTE: this is a temporary hack to fix a problem with data space analytics
185
+ // where the classes for properties are not properly surveyed
186
+ // We need to wait for the actual fix in backend to be merged and released
187
+ // See https://github.com/finos/legend-engine/pull/836
188
+ .concat(
189
+ uniq(
190
+ analysisResult.model.elements.flatMap((element) => {
191
+ if (element instanceof V1_Class) {
192
+ return element.derivedProperties
193
+ .map((prop) => prop.returnType)
194
+ .concat(element.properties.map((prop) => prop.type));
195
+ }
196
+ return [];
197
+ }),
198
+ )
199
+ // make sure to not include types already returned by the analysis
200
+ .filter(
201
+ (path) =>
202
+ !analysisResult.model.elements
203
+ .map((el) => el.path)
204
+ .includes(path),
205
+ )
206
+ .map((path) => {
207
+ const [pkgPath, name] = resolvePackagePathAndElementName(path);
208
+ if (!pkgPath) {
209
+ // exclude package-less elements (i.e. primitive types)
210
+ return undefined;
211
+ }
212
+ const _class = new V1_Class();
213
+ _class.name = name;
214
+ _class.package = pkgPath;
215
+ return _class;
216
+ })
217
+ .filter(isNonNullable),
218
+ )
219
+ .concat(mappingModels)
220
+ .concat(runtimeModels)
221
+ // NOTE: if an element could be found in the graph already it means it comes from system
222
+ // so we could rid of it
223
+ .filter((el) => !graph.getNullableElement(el.path, false))
224
+ .map((el) => this.graphManager.elementProtocolToEntity(el));
225
+
226
+ await this.graphManager.buildGraph(
227
+ graph,
228
+ graphEntities,
229
+ ActionState.create(),
230
+ );
231
+
232
+ // build execution context info
233
+ result.executionContextsIndex = new Map<
234
+ string,
235
+ DataSpaceExecutionContextAnalysisResult
236
+ >();
237
+ analysisResult.executionContexts.forEach((context) => {
238
+ const contextAnalysisResult =
239
+ new DataSpaceExecutionContextAnalysisResult();
240
+ contextAnalysisResult.name = context.name;
241
+ contextAnalysisResult.description = context.description;
242
+ contextAnalysisResult.mapping = graph.getMapping(context.mapping);
243
+ contextAnalysisResult.defaultRuntime = graph.getRuntime(
244
+ context.defaultRuntime,
245
+ );
246
+ contextAnalysisResult.compatibleRuntimes = context.compatibleRuntimes.map(
247
+ (runtime) => graph.getRuntime(runtime),
248
+ );
249
+ result.executionContextsIndex.set(
250
+ contextAnalysisResult.name,
251
+ contextAnalysisResult,
252
+ );
253
+ });
254
+ result.defaultExecutionContext = guaranteeNonNullable(
255
+ result.executionContextsIndex.get(analysisResult.defaultExecutionContext),
256
+ );
257
+
258
+ // find featured diagrams
259
+ result.featuredDiagrams = analysisResult.featuredDiagrams.map((path) =>
260
+ getDiagram(path, graph),
261
+ );
262
+
263
+ return result;
264
+ }
265
+ }
@@ -0,0 +1,119 @@
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 { V1_PureModelContextData } from '@finos/legend-graph';
18
+ import { SerializationFactory, optionalCustom } from '@finos/legend-shared';
19
+ import {
20
+ createModelSchema,
21
+ list,
22
+ object,
23
+ optional,
24
+ primitive,
25
+ SKIP,
26
+ } from 'serializr';
27
+ import type { V1_DataSpaceSupportInfo } from '../../../../../../graphManager/protocol/pure/v1/model/packageableElements/dataSpace/V1_DSLDataSpace_DataSpace.js';
28
+ import { V1_deserializeSupportInfo } from '../../../../../../graphManager/protocol/pure/v1/transformation/pureProtocol/V1_DSLDataSpace_ProtocolHelper.js';
29
+
30
+ class V1_DataSpaceTaggedValueInfo {
31
+ profile!: string;
32
+ tag!: string;
33
+ value!: string;
34
+
35
+ static readonly serialization = new SerializationFactory(
36
+ createModelSchema(V1_DataSpaceTaggedValueInfo, {
37
+ profile: primitive(),
38
+ tag: primitive(),
39
+ value: primitive(),
40
+ }),
41
+ );
42
+ }
43
+
44
+ class V1_DataSpaceStereotypeInfo {
45
+ profile!: string;
46
+ value!: string;
47
+
48
+ static readonly serialization = new SerializationFactory(
49
+ createModelSchema(V1_DataSpaceStereotypeInfo, {
50
+ profile: primitive(),
51
+ value: primitive(),
52
+ }),
53
+ );
54
+ }
55
+
56
+ class V1_DataSpaceExecutionContextAnalysisResult {
57
+ name!: string;
58
+ description?: string | undefined;
59
+ mapping!: string;
60
+ defaultRuntime!: string;
61
+ compatibleRuntimes!: string[];
62
+
63
+ static readonly serialization = new SerializationFactory(
64
+ createModelSchema(V1_DataSpaceExecutionContextAnalysisResult, {
65
+ name: primitive(),
66
+ description: optional(primitive()),
67
+ mapping: primitive(),
68
+ defaultRuntime: primitive(),
69
+ compatibleRuntimes: list(primitive()),
70
+ }),
71
+ );
72
+ }
73
+
74
+ export class V1_DataSpaceAnalysisResult {
75
+ name!: string;
76
+ package!: string;
77
+ path!: string;
78
+
79
+ taggedValues: V1_DataSpaceTaggedValueInfo[] = [];
80
+ stereotypes: V1_DataSpaceStereotypeInfo[] = [];
81
+
82
+ title?: string | undefined;
83
+ description?: string | undefined;
84
+ supportInfo?: V1_DataSpaceSupportInfo | undefined;
85
+
86
+ model!: V1_PureModelContextData;
87
+
88
+ executionContexts: V1_DataSpaceExecutionContextAnalysisResult[] = [];
89
+ defaultExecutionContext!: string;
90
+
91
+ featuredDiagrams: string[] = [];
92
+
93
+ static readonly serialization = new SerializationFactory(
94
+ createModelSchema(V1_DataSpaceAnalysisResult, {
95
+ name: primitive(),
96
+ package: primitive(),
97
+ path: primitive(),
98
+
99
+ taggedValues: list(object(V1_DataSpaceTaggedValueInfo)),
100
+ stereotypes: list(object(V1_DataSpaceStereotypeInfo)),
101
+
102
+ title: optional(primitive()),
103
+ description: optional(primitive()),
104
+ supportInfo: optionalCustom(
105
+ () => SKIP,
106
+ (val) => V1_deserializeSupportInfo(val),
107
+ ),
108
+
109
+ model: object(V1_PureModelContextData),
110
+
111
+ executionContexts: list(
112
+ object(V1_DataSpaceExecutionContextAnalysisResult),
113
+ ),
114
+ defaultExecutionContext: primitive(),
115
+
116
+ featuredDiagrams: list(primitive()),
117
+ }),
118
+ );
119
+ }
@@ -15,7 +15,7 @@
15
15
  */
16
16
 
17
17
  import { hashArray, type Hashable } from '@finos/legend-shared';
18
- import { DATA_SPACE_HASH_STRUCTURE } from '../../../../../../DSLDataSpace_ModelUtils.js';
18
+ import { DATA_SPACE_HASH_STRUCTURE } from '../../../../../../../graph/DSLDataSpace_HashUtils.js';
19
19
  import {
20
20
  V1_PackageableElement,
21
21
  type V1_PackageableElementPointer,
@@ -65,6 +65,7 @@ export class V1_DataSpace extends V1_PackageableElement implements Hashable {
65
65
  executionContexts!: V1_DataSpaceExecutionContext[];
66
66
  defaultExecutionContext!: string;
67
67
  featuredDiagrams?: V1_PackageableElementPointer[] | undefined;
68
+ title?: string | undefined;
68
69
  description?: string | undefined;
69
70
  supportInfo?: V1_DataSpaceSupportInfo | undefined;
70
71
 
@@ -76,6 +77,7 @@ export class V1_DataSpace extends V1_PackageableElement implements Hashable {
76
77
  hashArray(this.executionContexts),
77
78
  this.defaultExecutionContext,
78
79
  hashArray((this.featuredDiagrams ?? []).map((pointer) => pointer.path)),
80
+ this.title ?? '',
79
81
  this.description ?? '',
80
82
  this.supportInfo ?? '',
81
83
  ]);
@@ -15,7 +15,7 @@
15
15
  */
16
16
 
17
17
  import { getDataSpace } from '../../../../../../graphManager/DSLDataSpace_GraphManagerHelper.js';
18
- import type { DataSpace } from '../../../../../metamodels/pure/model/packageableElements/dataSpace/DSLDataSpace_DataSpace.js';
18
+ import type { DataSpace } from '../../../../../../graph/metamodel/pure/model/packageableElements/dataSpace/DSLDataSpace_DataSpace.js';
19
19
  import type {
20
20
  PackageableElementImplicitReference,
21
21
  V1_GraphBuilderContext,
@@ -78,7 +78,7 @@ const V1_serializeSupportInfo = (
78
78
  throw new UnsupportedOperationError(`Can't serialize support info`, protocol);
79
79
  };
80
80
 
81
- const V1_deserializeSupportInfo = (
81
+ export const V1_deserializeSupportInfo = (
82
82
  json: PlainObject<V1_DataSpaceSupportInfo> | undefined,
83
83
  ): V1_DataSpaceSupportInfo | undefined => {
84
84
  if (!json) {
@@ -157,4 +157,5 @@ export const V1_dataSpaceModelSchema = createModelSchema(V1_DataSpace, {
157
157
  skipIfEmpty: false,
158
158
  }),
159
159
  ),
160
+ title: optional(primitive()),
160
161
  });
package/src/index.ts CHANGED
@@ -15,16 +15,18 @@
15
15
  */
16
16
 
17
17
  export * from './DSLDataSpace_Extension.js';
18
- export { DSLDataSpace_LegendStudioPlugin } from './components/studio/DSLDataSpace_LegendStudioPlugin.js';
19
- export { DSLDataSpace_LegendQueryPlugin } from './components/query/DSLDataSpace_LegendQueryPlugin.js';
18
+ export { DSLDataSpace_LegendStudioApplicationPlugin } from './components/studio/DSLDataSpace_LegendStudioApplicationPlugin.js';
19
+ export { DSLDataSpace_LegendQueryApplicationPlugin } from './components/query/DSLDataSpace_LegendQueryApplicationPlugin.js';
20
20
 
21
21
  export { DataSpaceViewer } from './components/DataSpaceViewer.js';
22
22
 
23
23
  export {
24
24
  DATA_SPACE_ELEMENT_CLASSIFIER_PATH,
25
25
  extractDataSpaceTaxonomyNodes,
26
- } from './models/protocols/pure/DSLDataSpace_PureProtocolProcessorPlugin.js';
26
+ } from './graphManager/protocol/pure/DSLDataSpace_PureProtocolProcessorPlugin.js';
27
27
 
28
28
  export { DataSpaceViewerState } from './stores/DataSpaceViewerState.js';
29
29
 
30
30
  export * from './graphManager/DSLDataSpace_GraphManagerHelper.js';
31
+ export { getDSLDataSpaceGraphManagerExtension } from './graphManager/protocol/pure/DSLDataSpace_PureGraphManagerExtension.js';
32
+ export { DataSpaceAnalysisResult } from './graphManager/action/analytics/DataSpaceAnalysis.js';
@@ -17,20 +17,19 @@
17
17
  import {
18
18
  type ClassView,
19
19
  type DiagramRenderer,
20
- Diagram,
20
+ type Diagram,
21
21
  DIAGRAM_INTERACTION_MODE,
22
22
  } from '@finos/legend-extension-dsl-diagram';
23
- import type {
24
- GraphManagerState,
25
- PackageableElementReference,
26
- PackageableRuntime,
27
- } from '@finos/legend-graph';
28
- import { guaranteeNonNullable } from '@finos/legend-shared';
23
+ import type { PackageableRuntime } from '@finos/legend-graph';
24
+ import {
25
+ getNullableFirstElement,
26
+ guaranteeNonNullable,
27
+ } from '@finos/legend-shared';
29
28
  import { action, computed, makeObservable, observable } from 'mobx';
30
29
  import type {
31
- DataSpace,
32
- DataSpaceExecutionContext,
33
- } from '../models/metamodels/pure/model/packageableElements/dataSpace/DSLDataSpace_DataSpace.js';
30
+ DataSpaceAnalysisResult,
31
+ DataSpaceExecutionContextAnalysisResult,
32
+ } from '../graphManager/action/analytics/DataSpaceAnalysis.js';
34
33
 
35
34
  export enum DATA_SPACE_VIEWER_ACTIVITY_MODE {
36
35
  MODELS_OVERVIEW = 'MODELS_OVERVIEW',
@@ -38,20 +37,19 @@ export enum DATA_SPACE_VIEWER_ACTIVITY_MODE {
38
37
  ENTITLEMENT = 'ENTITLEMENT',
39
38
  TEST_DATA = 'TEST_DATA',
40
39
  TEST_COVERAGE = 'TEST_COVERAGE',
41
- TAGS = 'TAGS',
40
+ INFO = 'INFO',
42
41
  SUPPORT = 'SUPPORT',
43
42
  }
44
43
 
45
44
  export class DataSpaceViewerState {
46
- graphManagerState: GraphManagerState;
47
45
  groupId: string;
48
46
  artifactId: string;
49
47
  versionId: string;
50
- dataSpace: DataSpace;
48
+ dataSpaceAnalysisResult: DataSpaceAnalysisResult;
51
49
  _renderer?: DiagramRenderer | undefined;
52
50
  currentDiagram?: Diagram | undefined;
53
51
  currentActivity = DATA_SPACE_VIEWER_ACTIVITY_MODE.MODELS_OVERVIEW;
54
- currentExecutionContext: DataSpaceExecutionContext;
52
+ currentExecutionContext: DataSpaceExecutionContextAnalysisResult;
55
53
  currentRuntime: PackageableRuntime;
56
54
  viewProject?:
57
55
  | ((
@@ -64,11 +62,10 @@ export class DataSpaceViewerState {
64
62
  onDiagramClassDoubleClick?: ((classView: ClassView) => void) | undefined;
65
63
 
66
64
  constructor(
67
- graphManagerState: GraphManagerState,
68
65
  groupId: string,
69
66
  artifactId: string,
70
67
  versionId: string,
71
- dataSpace: DataSpace,
68
+ dataSpaceAnalysisResult: DataSpaceAnalysisResult,
72
69
  options?: {
73
70
  viewProject?: (
74
71
  groupId: string,
@@ -93,22 +90,16 @@ export class DataSpaceViewerState {
93
90
  setCurrentRuntime: action,
94
91
  });
95
92
 
96
- this.graphManagerState = graphManagerState;
97
- this.dataSpace = dataSpace;
93
+ this.dataSpaceAnalysisResult = dataSpaceAnalysisResult;
98
94
  this.groupId = groupId;
99
95
  this.artifactId = artifactId;
100
96
  this.versionId = versionId;
101
- this.currentExecutionContext = this.dataSpace.defaultExecutionContext;
102
- this.currentRuntime =
103
- this.dataSpace.defaultExecutionContext.defaultRuntime.value;
104
- this.currentDiagram = this.dataSpace.featuredDiagrams?.length
105
- ? (
106
- this.dataSpace
107
- .featuredDiagrams[0] as PackageableElementReference<Diagram>
108
- ).value
109
- : this.diagrams.length
110
- ? this.diagrams[0]
111
- : undefined;
97
+ this.currentExecutionContext =
98
+ dataSpaceAnalysisResult.defaultExecutionContext;
99
+ this.currentRuntime = this.currentExecutionContext.defaultRuntime;
100
+ this.currentDiagram = getNullableFirstElement(
101
+ this.dataSpaceAnalysisResult.featuredDiagrams,
102
+ );
112
103
  this.viewProject = options?.viewProject;
113
104
  this.onDiagramClassDoubleClick = options?.onDiagramClassDoubleClick;
114
105
  }
@@ -124,30 +115,6 @@ export class DataSpaceViewerState {
124
115
  return Boolean(this._renderer);
125
116
  }
126
117
 
127
- get featuredDiagrams(): Diagram[] {
128
- return this.dataSpace.featuredDiagrams?.map((ref) => ref.value) ?? [];
129
- }
130
-
131
- get diagrams(): Diagram[] {
132
- return this.graphManagerState.graph
133
- .getExtensionElements(Diagram)
134
- .concat(
135
- this.graphManagerState.graph.dependencyManager.getExtensionElements(
136
- Diagram,
137
- ),
138
- );
139
- }
140
-
141
- get runtimes(): PackageableRuntime[] {
142
- return this.graphManagerState.graph.ownRuntimes
143
- .concat(this.graphManagerState.graph.dependencyManager.runtimes)
144
- .filter((runtime) =>
145
- runtime.runtimeValue.mappings
146
- .map((mapping) => mapping.value)
147
- .includes(this.currentExecutionContext.mapping.value),
148
- );
149
- }
150
-
151
118
  // NOTE: we have tried to use React to control the cursor and
152
119
  // could not overcome the jank/lag problem, so we settle with CSS-based approach
153
120
  // See https://css-tricks.com/using-css-cursors/
@@ -183,9 +150,11 @@ export class DataSpaceViewerState {
183
150
  this.currentActivity = val;
184
151
  }
185
152
 
186
- setCurrentExecutionContext(val: DataSpaceExecutionContext): void {
153
+ setCurrentExecutionContext(
154
+ val: DataSpaceExecutionContextAnalysisResult,
155
+ ): void {
187
156
  this.currentExecutionContext = val;
188
- this.currentRuntime = val.defaultRuntime.value;
157
+ this.currentRuntime = val.defaultRuntime;
189
158
  }
190
159
 
191
160
  setCurrentRuntime(val: PackageableRuntime): void {
@@ -0,0 +1,69 @@
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 { generateExtensionUrlPattern } from '@finos/legend-application';
18
+ import {
19
+ LEGEND_QUERY_PATH_PARAM_TOKEN,
20
+ LEGEND_QUERY_QUERY_PARAM_TOKEN,
21
+ } from '@finos/legend-application-query';
22
+ import { generateGAVCoordinates } from '@finos/legend-server-depot';
23
+ import { generatePath } from 'react-router';
24
+
25
+ export enum DATA_SPACE_QUERY_EDITOR_PATH_PARAM_TOKEN {
26
+ DATA_SPACE_PATH = 'dataSpacePath',
27
+ EXECUTION_CONTEXT = 'executionContext',
28
+ }
29
+
30
+ export interface DataSpaceQueryEditorPathParams {
31
+ [LEGEND_QUERY_PATH_PARAM_TOKEN.GAV]: string;
32
+ [DATA_SPACE_QUERY_EDITOR_PATH_PARAM_TOKEN.DATA_SPACE_PATH]: string;
33
+ [DATA_SPACE_QUERY_EDITOR_PATH_PARAM_TOKEN.EXECUTION_CONTEXT]: string;
34
+ [LEGEND_QUERY_PATH_PARAM_TOKEN.RUNTIME_PATH]?: string;
35
+ }
36
+
37
+ export interface DataSpaceQueryEditorQueryParams {
38
+ [LEGEND_QUERY_QUERY_PARAM_TOKEN.CLASS_PATH]?: string;
39
+ }
40
+
41
+ export const DATA_SPACE_QUERY_EDITOR_ROUTE_PATTERN = `/dataspace/:${LEGEND_QUERY_PATH_PARAM_TOKEN.GAV}/:${DATA_SPACE_QUERY_EDITOR_PATH_PARAM_TOKEN.DATA_SPACE_PATH}/:${DATA_SPACE_QUERY_EDITOR_PATH_PARAM_TOKEN.EXECUTION_CONTEXT}/:${LEGEND_QUERY_PATH_PARAM_TOKEN.RUNTIME_PATH}?`;
42
+
43
+ export const generateDataSpaceQueryEditorRoute = (
44
+ groupId: string,
45
+ artifactId: string,
46
+ versionId: string,
47
+ dataSpacePath: string,
48
+ executionContextKey: string,
49
+ runtimePath?: string | undefined,
50
+ classPath?: string | undefined,
51
+ ): string =>
52
+ `${generatePath(
53
+ generateExtensionUrlPattern(DATA_SPACE_QUERY_EDITOR_ROUTE_PATTERN),
54
+ {
55
+ [LEGEND_QUERY_PATH_PARAM_TOKEN.GAV]: generateGAVCoordinates(
56
+ groupId,
57
+ artifactId,
58
+ versionId,
59
+ ),
60
+ [DATA_SPACE_QUERY_EDITOR_PATH_PARAM_TOKEN.DATA_SPACE_PATH]: dataSpacePath,
61
+ [DATA_SPACE_QUERY_EDITOR_PATH_PARAM_TOKEN.EXECUTION_CONTEXT]:
62
+ executionContextKey,
63
+ [LEGEND_QUERY_PATH_PARAM_TOKEN.RUNTIME_PATH]: runtimePath,
64
+ },
65
+ )}${
66
+ classPath
67
+ ? `?${LEGEND_QUERY_QUERY_PARAM_TOKEN.CLASS_PATH}=${classPath}`
68
+ : ''
69
+ }`;