@finos/legend-extension-dsl-data-space 0.0.1

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 (78) hide show
  1. package/CHANGELOG.md +9 -0
  2. package/LICENSE +201 -0
  3. package/README.md +3 -0
  4. package/lib/DSLDataSpace_Extension.d.ts +27 -0
  5. package/lib/DSLDataSpace_Extension.d.ts.map +1 -0
  6. package/lib/DSLDataSpace_Extension.js +43 -0
  7. package/lib/DSLDataSpace_Extension.js.map +1 -0
  8. package/lib/components/studio/DSLDataSpace_StudioPlugin.d.ts +30 -0
  9. package/lib/components/studio/DSLDataSpace_StudioPlugin.d.ts.map +1 -0
  10. package/lib/components/studio/DSLDataSpace_StudioPlugin.js +107 -0
  11. package/lib/components/studio/DSLDataSpace_StudioPlugin.js.map +1 -0
  12. package/lib/components/studio/DataSpaceEditor.d.ts +19 -0
  13. package/lib/components/studio/DataSpaceEditor.d.ts.map +1 -0
  14. package/lib/components/studio/DataSpaceEditor.js +100 -0
  15. package/lib/components/studio/DataSpaceEditor.js.map +1 -0
  16. package/lib/graph/DSLDataSpace_PureGraphPlugin.d.ts +24 -0
  17. package/lib/graph/DSLDataSpace_PureGraphPlugin.d.ts.map +1 -0
  18. package/lib/graph/DSLDataSpace_PureGraphPlugin.js +30 -0
  19. package/lib/graph/DSLDataSpace_PureGraphPlugin.js.map +1 -0
  20. package/lib/graphManager/DSLDataSpace_GraphManagerHelper.d.ts +19 -0
  21. package/lib/graphManager/DSLDataSpace_GraphManagerHelper.d.ts.map +1 -0
  22. package/lib/graphManager/DSLDataSpace_GraphManagerHelper.js +18 -0
  23. package/lib/graphManager/DSLDataSpace_GraphManagerHelper.js.map +1 -0
  24. package/lib/graphManager/DSLDataSpace_PureGraphManagerPlugin.d.ts +25 -0
  25. package/lib/graphManager/DSLDataSpace_PureGraphManagerPlugin.d.ts.map +1 -0
  26. package/lib/graphManager/DSLDataSpace_PureGraphManagerPlugin.js +45 -0
  27. package/lib/graphManager/DSLDataSpace_PureGraphManagerPlugin.js.map +1 -0
  28. package/lib/index.css +17 -0
  29. package/lib/index.css.map +1 -0
  30. package/lib/index.d.ts +17 -0
  31. package/lib/index.d.ts.map +1 -0
  32. package/lib/index.js +17 -0
  33. package/lib/index.js.map +1 -0
  34. package/lib/models/DSLDataSpace_ModelUtils.d.ts +19 -0
  35. package/lib/models/DSLDataSpace_ModelUtils.d.ts.map +1 -0
  36. package/lib/models/DSLDataSpace_ModelUtils.js +20 -0
  37. package/lib/models/DSLDataSpace_ModelUtils.js.map +1 -0
  38. package/lib/models/metamodels/pure/model/packageableElements/dataSpace/DataSpace.d.ts +34 -0
  39. package/lib/models/metamodels/pure/model/packageableElements/dataSpace/DataSpace.d.ts.map +1 -0
  40. package/lib/models/metamodels/pure/model/packageableElements/dataSpace/DataSpace.js +58 -0
  41. package/lib/models/metamodels/pure/model/packageableElements/dataSpace/DataSpace.js.map +1 -0
  42. package/lib/models/protocols/pure/DSLDataSpace_PureProtocolProcessorPlugin.d.ts +27 -0
  43. package/lib/models/protocols/pure/DSLDataSpace_PureProtocolProcessorPlugin.d.ts.map +1 -0
  44. package/lib/models/protocols/pure/DSLDataSpace_PureProtocolProcessorPlugin.js +119 -0
  45. package/lib/models/protocols/pure/DSLDataSpace_PureProtocolProcessorPlugin.js.map +1 -0
  46. package/lib/models/protocols/pure/v1/model/packageableElements/dataSpace/V1_DataSpace.d.ts +33 -0
  47. package/lib/models/protocols/pure/v1/model/packageableElements/dataSpace/V1_DataSpace.d.ts.map +1 -0
  48. package/lib/models/protocols/pure/v1/model/packageableElements/dataSpace/V1_DataSpace.js +49 -0
  49. package/lib/models/protocols/pure/v1/model/packageableElements/dataSpace/V1_DataSpace.js.map +1 -0
  50. package/lib/models/protocols/pure/v1/transformation/pureGraph/V1_DSLDataSpace_GraphBuilderHelper.d.ts +19 -0
  51. package/lib/models/protocols/pure/v1/transformation/pureGraph/V1_DSLDataSpace_GraphBuilderHelper.d.ts.map +1 -0
  52. package/lib/models/protocols/pure/v1/transformation/pureGraph/V1_DSLDataSpace_GraphBuilderHelper.js +18 -0
  53. package/lib/models/protocols/pure/v1/transformation/pureGraph/V1_DSLDataSpace_GraphBuilderHelper.js.map +1 -0
  54. package/lib/models/protocols/pure/v1/transformation/pureProtocol/V1_DSLDataSpace_ProtocolHelper.d.ts +19 -0
  55. package/lib/models/protocols/pure/v1/transformation/pureProtocol/V1_DSLDataSpace_ProtocolHelper.d.ts.map +1 -0
  56. package/lib/models/protocols/pure/v1/transformation/pureProtocol/V1_DSLDataSpace_ProtocolHelper.js +36 -0
  57. package/lib/models/protocols/pure/v1/transformation/pureProtocol/V1_DSLDataSpace_ProtocolHelper.js.map +1 -0
  58. package/lib/stores/studio/DataSpaceEditorState.d.ts +42 -0
  59. package/lib/stores/studio/DataSpaceEditorState.d.ts.map +1 -0
  60. package/lib/stores/studio/DataSpaceEditorState.js +76 -0
  61. package/lib/stores/studio/DataSpaceEditorState.js.map +1 -0
  62. package/package.json +80 -0
  63. package/src/DSLDataSpace_Extension.ts +49 -0
  64. package/src/components/studio/DSLDataSpace_StudioPlugin.tsx +146 -0
  65. package/src/components/studio/DataSpaceEditor.tsx +275 -0
  66. package/src/graph/DSLDataSpace_PureGraphPlugin.ts +38 -0
  67. package/src/graphManager/DSLDataSpace_GraphManagerHelper.ts +21 -0
  68. package/src/graphManager/DSLDataSpace_PureGraphManagerPlugin.ts +56 -0
  69. package/src/index.ts +17 -0
  70. package/src/models/DSLDataSpace_ModelUtils.ts +19 -0
  71. package/src/models/metamodels/pure/model/packageableElements/dataSpace/DataSpace.ts +73 -0
  72. package/src/models/protocols/pure/DSLDataSpace_PureProtocolProcessorPlugin.ts +180 -0
  73. package/src/models/protocols/pure/v1/model/packageableElements/dataSpace/V1_DataSpace.ts +60 -0
  74. package/src/models/protocols/pure/v1/transformation/pureGraph/V1_DSLDataSpace_GraphBuilderHelper.ts +30 -0
  75. package/src/models/protocols/pure/v1/transformation/pureProtocol/V1_DSLDataSpace_ProtocolHelper.ts +82 -0
  76. package/src/stores/studio/DataSpaceEditorState.ts +108 -0
  77. package/tsconfig.json +64 -0
  78. package/tsconfig.package.json +40 -0
@@ -0,0 +1,275 @@
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 { useRef, useEffect } from 'react';
18
+ import { observer } from 'mobx-react-lite';
19
+ import { useEditorStore } from '@finos/legend-studio';
20
+ import { useResizeDetector } from 'react-resize-detector';
21
+ import {
22
+ BlankPanelContent,
23
+ ShapesIcon,
24
+ PlayIcon,
25
+ UserIcon,
26
+ QuestionCircleIcon,
27
+ clsx,
28
+ EnvelopIcon,
29
+ MappingIcon,
30
+ RuntimeIcon,
31
+ CustomSelectorInput,
32
+ } from '@finos/legend-art';
33
+ import {
34
+ DataSpaceEditorState,
35
+ DATA_SPACE_VIEWER_ACTIVITY_MODE,
36
+ } from '../../stores/studio/DataSpaceEditorState';
37
+ import type { Diagram } from '@finos/legend-extension-dsl-diagram';
38
+ import { DiagramRenderer } from '@finos/legend-extension-dsl-diagram';
39
+
40
+ interface DataSpaceViewerActivityConfig {
41
+ mode: DATA_SPACE_VIEWER_ACTIVITY_MODE;
42
+ title: string;
43
+ icon: React.ReactElement;
44
+ }
45
+
46
+ const DataSpaceDiagramCanvas = observer(
47
+ (
48
+ props: {
49
+ dataSpaceEditorState: DataSpaceEditorState;
50
+ diagram: Diagram;
51
+ },
52
+ ref: React.Ref<HTMLDivElement>,
53
+ ) => {
54
+ const { dataSpaceEditorState, diagram } = props;
55
+ const diagramCanvasRef =
56
+ ref as React.MutableRefObject<HTMLDivElement | null>;
57
+
58
+ const { width, height } = useResizeDetector<HTMLDivElement>({
59
+ refreshMode: 'debounce',
60
+ refreshRate: 50,
61
+ targetRef: diagramCanvasRef,
62
+ });
63
+
64
+ useEffect(() => {
65
+ if (diagramCanvasRef.current) {
66
+ const renderer = new DiagramRenderer(diagramCanvasRef.current, diagram);
67
+ dataSpaceEditorState.setRenderer(renderer);
68
+ renderer.render();
69
+ renderer.autoRecenter();
70
+ }
71
+ }, [diagramCanvasRef, dataSpaceEditorState, diagram]);
72
+
73
+ useEffect(() => {
74
+ if (dataSpaceEditorState.isDiagramRendererInitialized) {
75
+ dataSpaceEditorState.renderer.refresh();
76
+ }
77
+ }, [dataSpaceEditorState, width, height]);
78
+
79
+ return (
80
+ <div
81
+ ref={diagramCanvasRef}
82
+ className="diagram-canvas"
83
+ tabIndex={0}
84
+ onContextMenu={(event): void => event.preventDefault()}
85
+ />
86
+ );
87
+ },
88
+ { forwardRef: true },
89
+ );
90
+
91
+ type DiagramOption = { label: string; value: Diagram };
92
+ const buildDiagramOption = (diagram: Diagram): DiagramOption => ({
93
+ label: diagram.name,
94
+ value: diagram,
95
+ });
96
+
97
+ const DataSpaceModelsOverview = observer(
98
+ (props: { dataSpaceEditorState: DataSpaceEditorState }) => {
99
+ const { dataSpaceEditorState } = props;
100
+ const diagramCanvasRef = useRef<HTMLDivElement>(null);
101
+ const diagramOptions =
102
+ dataSpaceEditorState.diagrams.map(buildDiagramOption);
103
+ const selectedDiagramOption = dataSpaceEditorState.currentDiagram
104
+ ? buildDiagramOption(dataSpaceEditorState.currentDiagram)
105
+ : null;
106
+ const onDiagramOptionChange = (option: DiagramOption): void => {
107
+ if (option.value !== dataSpaceEditorState.currentDiagram) {
108
+ dataSpaceEditorState.setCurrentDiagram(option.value);
109
+ }
110
+ };
111
+
112
+ return (
113
+ <>
114
+ {dataSpaceEditorState.diagrams.length !== 0 && (
115
+ <div className="data-space-viewer__main-panel__content data-space-viewer__overview-panel">
116
+ <div className="data-space-viewer__overview-panel__header">
117
+ <CustomSelectorInput
118
+ className="data-space-viewer__overview-panel__diagram-selector"
119
+ options={diagramOptions}
120
+ onChange={onDiagramOptionChange}
121
+ value={selectedDiagramOption}
122
+ placeholder="Search for a diagram"
123
+ darkMode={true}
124
+ />
125
+ </div>
126
+ <div className="data-space-viewer__overview-panel__content">
127
+ {dataSpaceEditorState.currentDiagram && (
128
+ <DataSpaceDiagramCanvas
129
+ dataSpaceEditorState={dataSpaceEditorState}
130
+ diagram={dataSpaceEditorState.currentDiagram}
131
+ ref={diagramCanvasRef}
132
+ />
133
+ )}
134
+ </div>
135
+ </div>
136
+ )}
137
+ {dataSpaceEditorState.diagrams.length === 0 && (
138
+ <BlankPanelContent>No diagrams available</BlankPanelContent>
139
+ )}
140
+ </>
141
+ );
142
+ },
143
+ );
144
+
145
+ export const DataSpaceViewer = observer(() => {
146
+ const editorStore = useEditorStore();
147
+ const dataSpaceEditorState =
148
+ editorStore.getCurrentEditorState(DataSpaceEditorState);
149
+ const dataSpace = dataSpaceEditorState.dataSpace;
150
+ const changeActivity =
151
+ (activity: DATA_SPACE_VIEWER_ACTIVITY_MODE): (() => void) =>
152
+ (): void =>
153
+ dataSpaceEditorState.setCurrentActivity(activity);
154
+
155
+ const activities: DataSpaceViewerActivityConfig[] = [
156
+ {
157
+ mode: DATA_SPACE_VIEWER_ACTIVITY_MODE.MODELS,
158
+ title: 'Models Overview',
159
+ icon: <ShapesIcon />,
160
+ },
161
+ {
162
+ mode: DATA_SPACE_VIEWER_ACTIVITY_MODE.EXECUTION,
163
+ title: 'Execution Context',
164
+ icon: <PlayIcon />,
165
+ },
166
+ {
167
+ mode: DATA_SPACE_VIEWER_ACTIVITY_MODE.ENTITLEMENT,
168
+ title: 'Entitlement',
169
+ icon: <UserIcon />,
170
+ },
171
+ {
172
+ mode: DATA_SPACE_VIEWER_ACTIVITY_MODE.SUPPORT,
173
+ title: 'Support',
174
+ icon: <QuestionCircleIcon />,
175
+ },
176
+ ];
177
+
178
+ return (
179
+ <div className="data-space-viewer">
180
+ <div className="data-space-viewer__header">
181
+ <div className="data-space-viewer__path">{dataSpace.path}</div>
182
+ <div className="data-space-viewer__gav">
183
+ <div className="data-space-viewer__gav__group-id">
184
+ {dataSpace.groupId}
185
+ </div>
186
+ <div className="data-space-viewer__gav__separator">:</div>
187
+ <div className="data-space-viewer__gav__artifact-id">
188
+ {dataSpace.artifactId}
189
+ </div>
190
+ <div className="data-space-viewer__gav__separator">:</div>
191
+ <div className="data-space-viewer__gav__version-id">
192
+ {dataSpace.versionId}
193
+ </div>
194
+ </div>
195
+ <div className="data-space-viewer__description">
196
+ {dataSpace.description ? (
197
+ dataSpace.description
198
+ ) : (
199
+ <div className="data-space-viewer__description--empty">
200
+ No description
201
+ </div>
202
+ )}
203
+ </div>
204
+ </div>
205
+ <div className="data-space-viewer__content">
206
+ <div className="data-space-viewer__body">
207
+ <div className="data-space-viewer__activity-bar">
208
+ <div className="data-space-viewer__activity-bar__items">
209
+ {activities.map((activity) => (
210
+ <button
211
+ key={activity.mode}
212
+ className={clsx('data-space-viewer__activity-bar__item', {
213
+ 'data-space-viewer__activity-bar__item--active':
214
+ dataSpaceEditorState.currentActivity === activity.mode,
215
+ })}
216
+ onClick={changeActivity(activity.mode)}
217
+ tabIndex={-1}
218
+ title={activity.title}
219
+ >
220
+ {activity.icon}
221
+ </button>
222
+ ))}
223
+ </div>
224
+ </div>
225
+ <div className="data-space-viewer__main-panel">
226
+ {dataSpaceEditorState.currentActivity ===
227
+ DATA_SPACE_VIEWER_ACTIVITY_MODE.MODELS && (
228
+ <DataSpaceModelsOverview
229
+ dataSpaceEditorState={dataSpaceEditorState}
230
+ />
231
+ )}
232
+ {dataSpaceEditorState.currentActivity ===
233
+ DATA_SPACE_VIEWER_ACTIVITY_MODE.EXECUTION && (
234
+ <div className="data-space-viewer__main-panel__content data-space-viewer__execution-panel">
235
+ <div className="data-space-viewer__panel__info-entry">
236
+ <div className="data-space-viewer__panel__info-entry__icon">
237
+ <MappingIcon />
238
+ </div>
239
+ <div className="data-space-viewer__panel__info-entry__content">
240
+ {dataSpace.mapping}
241
+ </div>
242
+ </div>
243
+ <div className="data-space-viewer__panel__info-entry">
244
+ <div className="data-space-viewer__panel__info-entry__icon">
245
+ <RuntimeIcon />
246
+ </div>
247
+ <div className="data-space-viewer__panel__info-entry__content">
248
+ {dataSpace.runtime}
249
+ </div>
250
+ </div>
251
+ </div>
252
+ )}
253
+ {dataSpaceEditorState.currentActivity ===
254
+ DATA_SPACE_VIEWER_ACTIVITY_MODE.ENTITLEMENT && (
255
+ <BlankPanelContent>(WIP)</BlankPanelContent>
256
+ )}
257
+ {dataSpaceEditorState.currentActivity ===
258
+ DATA_SPACE_VIEWER_ACTIVITY_MODE.SUPPORT && (
259
+ <div className="data-space-viewer__main-panel__content data-space-viewer__support-panel">
260
+ <div className="data-space-viewer__panel__info-entry">
261
+ <div className="data-space-viewer__panel__info-entry__icon">
262
+ <EnvelopIcon />
263
+ </div>
264
+ <div className="data-space-viewer__panel__info-entry__content">
265
+ {dataSpace.supportEmail ?? '(no support contact available)'}
266
+ </div>
267
+ </div>
268
+ </div>
269
+ )}
270
+ </div>
271
+ </div>
272
+ </div>
273
+ </div>
274
+ );
275
+ });
@@ -0,0 +1,38 @@
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 packageJson from '../../package.json';
18
+ import { DataSpace } from '../models/metamodels/pure/model/packageableElements/dataSpace/DataSpace';
19
+ import type { Clazz } from '@finos/legend-shared';
20
+ import type {
21
+ GraphPluginManager,
22
+ PackageableElement,
23
+ } from '@finos/legend-graph';
24
+ import { PureGraphPlugin } from '@finos/legend-graph';
25
+
26
+ export class DSLDataSpace_PureGraphPlugin extends PureGraphPlugin {
27
+ constructor() {
28
+ super(packageJson.extensions.pureGraphPlugin, packageJson.version);
29
+ }
30
+
31
+ install(pluginManager: GraphPluginManager): void {
32
+ pluginManager.registerPureGraphPlugins(this);
33
+ }
34
+
35
+ override getExtraPureGraphExtensionClasses(): Clazz<PackageableElement>[] {
36
+ return [DataSpace];
37
+ }
38
+ }
@@ -0,0 +1,21 @@
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 { PureModel } from '@finos/legend-graph';
18
+ import { DataSpace } from '../models/metamodels/pure/model/packageableElements/dataSpace/DataSpace';
19
+
20
+ export const getDataSpace = (path: string, graph: PureModel): DataSpace =>
21
+ graph.getExtensionElement(path, DataSpace, `Can't find data space '${path}'`);
@@ -0,0 +1,56 @@
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 packageJson from '../../package.json';
18
+ import { DataSpace } from '../models/metamodels/pure/model/packageableElements/dataSpace/DataSpace';
19
+ import type {
20
+ GraphPluginManager,
21
+ PackageableElement,
22
+ PureGrammarElementLabeler,
23
+ } from '@finos/legend-graph';
24
+ import { PureGraphManagerPlugin } from '@finos/legend-graph';
25
+
26
+ const PURE_GRAMMAR_DATA_SPACE_PARSER_NAME = 'DataSpace';
27
+ const PURE_GRAMMAR_DATA_SPACE_ELEMENT_TYPE_LABEL = 'DataSpace';
28
+
29
+ export class DSLDataSpace_PureGraphManagerPlugin extends PureGraphManagerPlugin {
30
+ constructor() {
31
+ super(packageJson.extensions.pureGraphManagerPlugin, packageJson.version);
32
+ }
33
+
34
+ install(pluginManager: GraphPluginManager): void {
35
+ pluginManager.registerPureGraphManagerPlugin(this);
36
+ }
37
+
38
+ override getExtraPureGrammarParserNames(): string[] {
39
+ return [PURE_GRAMMAR_DATA_SPACE_PARSER_NAME];
40
+ }
41
+
42
+ override getExtraPureGrammarKeywords(): string[] {
43
+ return [PURE_GRAMMAR_DATA_SPACE_ELEMENT_TYPE_LABEL];
44
+ }
45
+
46
+ override getExtraPureGrammarElementLabelers(): PureGrammarElementLabeler[] {
47
+ return [
48
+ (element: PackageableElement): string | undefined => {
49
+ if (element instanceof DataSpace) {
50
+ return PURE_GRAMMAR_DATA_SPACE_ELEMENT_TYPE_LABEL;
51
+ }
52
+ return undefined;
53
+ },
54
+ ];
55
+ }
56
+ }
package/src/index.ts ADDED
@@ -0,0 +1,17 @@
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 * from './DSLDataSpace_Extension';
@@ -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 DATA_SPACE_HASH_STRUCTURE {
18
+ DATA_SPACE = 'DATA_SPACE',
19
+ }
@@ -0,0 +1,73 @@
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 { makeObservable, override } from 'mobx';
18
+ import { hashArray } from '@finos/legend-shared';
19
+ import type { Hashable } from '@finos/legend-shared';
20
+ import type {
21
+ PackageableElementVisitor,
22
+ StereotypeReference,
23
+ TaggedValue,
24
+ } from '@finos/legend-graph';
25
+ import { PackageableElement } from '@finos/legend-graph';
26
+ import { DATA_SPACE_HASH_STRUCTURE } from '../../../../../DSLDataSpace_ModelUtils';
27
+
28
+ export class DataSpace extends PackageableElement implements Hashable {
29
+ stereotypes: StereotypeReference[] = [];
30
+ taggedValues: TaggedValue[] = [];
31
+ groupId!: string;
32
+ artifactId!: string;
33
+ versionId!: string;
34
+ mapping!: string;
35
+ runtime!: string;
36
+ diagrams: string[] = [];
37
+ description?: string | undefined;
38
+ // NOTE: we're not too sure about this attribute. We feel that this would be needed but maybe
39
+ // we can think of a more generic strategy for this type of metadata
40
+ supportEmail?: string | undefined;
41
+
42
+ constructor(name: string) {
43
+ super(name);
44
+
45
+ makeObservable<DataSpace, '_elementHashCode'>(this, {
46
+ _elementHashCode: override,
47
+ });
48
+ }
49
+
50
+ protected override get _elementHashCode(): string {
51
+ return hashArray([
52
+ DATA_SPACE_HASH_STRUCTURE.DATA_SPACE,
53
+ hashArray(
54
+ this.stereotypes.map((stereotype) => stereotype.pointerHashCode),
55
+ ),
56
+ hashArray(this.taggedValues),
57
+ this.groupId,
58
+ this.artifactId,
59
+ this.versionId,
60
+ this.mapping,
61
+ this.runtime,
62
+ hashArray(this.diagrams),
63
+ this.description ?? '',
64
+ this.supportEmail ?? '',
65
+ ]);
66
+ }
67
+
68
+ accept_PackageableElementVisitor<T>(
69
+ visitor: PackageableElementVisitor<T>,
70
+ ): T {
71
+ return visitor.visit_PackageableElement(this);
72
+ }
73
+ }
@@ -0,0 +1,180 @@
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 packageJson from '../../../../package.json';
18
+ import { V1_DataSpace } from './v1/model/packageableElements/dataSpace/V1_DataSpace';
19
+ import type { PlainObject } from '@finos/legend-shared';
20
+ import { isNonNullable, assertType } from '@finos/legend-shared';
21
+ import { deserialize, serialize } from 'serializr';
22
+ import {
23
+ V1_dataSpaceModelSchema,
24
+ V1_DATA_SPACE_ELEMENT_PROTOCOL_TYPE,
25
+ } from './v1/transformation/pureProtocol/V1_DSLDataSpace_ProtocolHelper';
26
+ import { getDataSpace } from '../../../graphManager/DSLDataSpace_GraphManagerHelper';
27
+ import { DataSpace } from '../../metamodels/pure/model/packageableElements/dataSpace/DataSpace';
28
+ import type {
29
+ GraphPluginManager,
30
+ PackageableElement,
31
+ V1_ElementProtocolClassifierPathGetter,
32
+ V1_ElementProtocolDeserializer,
33
+ V1_ElementProtocolSerializer,
34
+ V1_ElementTransformer,
35
+ V1_GraphBuilderContext,
36
+ V1_GraphTransformerContext,
37
+ V1_PackageableElement,
38
+ } from '@finos/legend-graph';
39
+ import {
40
+ V1_buildTaggedValue,
41
+ V1_transformStereotype,
42
+ V1_transformTaggedValue,
43
+ PureProtocolProcessorPlugin,
44
+ V1_ElementBuilder,
45
+ V1_initPackageableElement,
46
+ } from '@finos/legend-graph';
47
+
48
+ const DATA_SPACE_ELEMENT_CLASSIFIER_PATH =
49
+ 'meta::pure::metamodel::dataSpace::DataSpace';
50
+
51
+ export class DSLDataSpace_PureProtocolProcessorPlugin extends PureProtocolProcessorPlugin {
52
+ constructor() {
53
+ super(
54
+ packageJson.extensions.pureProtocolProcessorPlugin,
55
+ packageJson.version,
56
+ );
57
+ }
58
+
59
+ install(pluginManager: GraphPluginManager): void {
60
+ pluginManager.registerPureProtocolProcessorPlugin(this);
61
+ }
62
+
63
+ override V1_getExtraElementBuilders(): V1_ElementBuilder<V1_PackageableElement>[] {
64
+ return [
65
+ new V1_ElementBuilder<V1_DataSpace>({
66
+ elementClassName: 'DataSpace',
67
+ _class: V1_DataSpace,
68
+ firstPass: (
69
+ elementProtocol: V1_PackageableElement,
70
+ context: V1_GraphBuilderContext,
71
+ ): PackageableElement => {
72
+ assertType(elementProtocol, V1_DataSpace);
73
+ const element = new DataSpace(elementProtocol.name);
74
+ const path = context.currentSubGraph.buildPath(
75
+ elementProtocol.package,
76
+ elementProtocol.name,
77
+ );
78
+ context.currentSubGraph.setOwnElementInExtension(
79
+ path,
80
+ element,
81
+ DataSpace,
82
+ );
83
+ return element;
84
+ },
85
+ secondPass: (
86
+ elementProtocol: V1_PackageableElement,
87
+ context: V1_GraphBuilderContext,
88
+ ): void => {
89
+ assertType(elementProtocol, V1_DataSpace);
90
+ const path = context.graph.buildPath(
91
+ elementProtocol.package,
92
+ elementProtocol.name,
93
+ );
94
+ const element = getDataSpace(path, context.graph);
95
+ element.stereotypes = elementProtocol.stereotypes
96
+ .map((stereotype) => context.resolveStereotype(stereotype))
97
+ .filter(isNonNullable);
98
+ element.taggedValues = elementProtocol.taggedValues
99
+ .map((taggedValue) => V1_buildTaggedValue(taggedValue, context))
100
+ .filter(isNonNullable);
101
+ element.groupId = elementProtocol.groupId;
102
+ element.artifactId = elementProtocol.artifactId;
103
+ element.versionId = elementProtocol.versionId;
104
+ element.mapping = elementProtocol.mapping;
105
+ element.runtime = elementProtocol.runtime;
106
+ element.description = elementProtocol.description;
107
+ element.supportEmail = elementProtocol.supportEmail;
108
+ element.diagrams = elementProtocol.diagrams ?? [];
109
+ },
110
+ }),
111
+ ];
112
+ }
113
+
114
+ override V1_getExtraElementClassifierPathGetters(): V1_ElementProtocolClassifierPathGetter[] {
115
+ return [
116
+ (elementProtocol: V1_PackageableElement): string | undefined => {
117
+ if (elementProtocol instanceof V1_DataSpace) {
118
+ return DATA_SPACE_ELEMENT_CLASSIFIER_PATH;
119
+ }
120
+ return undefined;
121
+ },
122
+ ];
123
+ }
124
+
125
+ override V1_getExtraElementProtocolSerializers(): V1_ElementProtocolSerializer[] {
126
+ return [
127
+ (
128
+ elementProtocol: V1_PackageableElement,
129
+ ): PlainObject<V1_PackageableElement> | undefined => {
130
+ if (elementProtocol instanceof V1_DataSpace) {
131
+ return serialize(V1_dataSpaceModelSchema, elementProtocol);
132
+ }
133
+ return undefined;
134
+ },
135
+ ];
136
+ }
137
+
138
+ override V1_getExtraElementProtocolDeserializers(): V1_ElementProtocolDeserializer[] {
139
+ return [
140
+ (
141
+ json: PlainObject<V1_PackageableElement>,
142
+ ): V1_PackageableElement | undefined => {
143
+ if (json._type === V1_DATA_SPACE_ELEMENT_PROTOCOL_TYPE) {
144
+ return deserialize(V1_dataSpaceModelSchema, json);
145
+ }
146
+ return undefined;
147
+ },
148
+ ];
149
+ }
150
+
151
+ override V1_getExtraElementTransformers(): V1_ElementTransformer[] {
152
+ return [
153
+ (
154
+ metamodel: PackageableElement,
155
+ context: V1_GraphTransformerContext,
156
+ ): V1_PackageableElement | undefined => {
157
+ if (metamodel instanceof DataSpace) {
158
+ const protocol = new V1_DataSpace();
159
+ V1_initPackageableElement(protocol, metamodel);
160
+ protocol.stereotypes = metamodel.stereotypes.map(
161
+ V1_transformStereotype,
162
+ );
163
+ protocol.taggedValues = metamodel.taggedValues.map(
164
+ V1_transformTaggedValue,
165
+ );
166
+ protocol.groupId = metamodel.groupId;
167
+ protocol.artifactId = metamodel.artifactId;
168
+ protocol.versionId = metamodel.versionId;
169
+ protocol.mapping = metamodel.mapping;
170
+ protocol.runtime = metamodel.runtime;
171
+ protocol.description = metamodel.description;
172
+ protocol.supportEmail = metamodel.supportEmail;
173
+ protocol.diagrams = metamodel.diagrams;
174
+ return protocol;
175
+ }
176
+ return undefined;
177
+ },
178
+ ];
179
+ }
180
+ }