@finos/legend-extension-dsl-data-space 0.0.6 → 1.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 (70) hide show
  1. package/CHANGELOG.md +32 -0
  2. package/lib/DSLDataSpace_Extension.d.ts +0 -5
  3. package/lib/DSLDataSpace_Extension.d.ts.map +1 -1
  4. package/lib/DSLDataSpace_Extension.js +0 -12
  5. package/lib/DSLDataSpace_Extension.js.map +1 -1
  6. package/lib/components/{studio/DataSpaceEditor.d.ts → DataSpaceViewer.d.ts} +5 -2
  7. package/lib/components/DataSpaceViewer.d.ts.map +1 -0
  8. package/lib/components/DataSpaceViewer.js +186 -0
  9. package/lib/components/DataSpaceViewer.js.map +1 -0
  10. package/lib/components/query/DSLDataSpace_LegendQueryPlugin.d.ts +24 -0
  11. package/lib/components/query/DSLDataSpace_LegendQueryPlugin.d.ts.map +1 -0
  12. package/lib/components/query/DSLDataSpace_LegendQueryPlugin.js +51 -0
  13. package/lib/components/query/DSLDataSpace_LegendQueryPlugin.js.map +1 -0
  14. package/lib/components/query/DataSpaceQuerySetup.d.ts +22 -0
  15. package/lib/components/query/DataSpaceQuerySetup.d.ts.map +1 -0
  16. package/lib/components/query/DataSpaceQuerySetup.js +95 -0
  17. package/lib/components/query/DataSpaceQuerySetup.js.map +1 -0
  18. package/lib/components/studio/{DSLDataSpace_StudioPlugin.d.ts → DSLDataSpace_LegendStudioPlugin.d.ts} +5 -6
  19. package/lib/components/studio/DSLDataSpace_LegendStudioPlugin.d.ts.map +1 -0
  20. package/lib/components/studio/{DSLDataSpace_StudioPlugin.js → DSLDataSpace_LegendStudioPlugin.js} +7 -18
  21. package/lib/components/studio/DSLDataSpace_LegendStudioPlugin.js.map +1 -0
  22. package/lib/graph/DSLDataSpace_PureGraphPlugin.js +1 -1
  23. package/lib/graph/DSLDataSpace_PureGraphPlugin.js.map +1 -1
  24. package/lib/index.css +2 -2
  25. package/lib/index.css.map +1 -1
  26. package/lib/index.d.ts +5 -0
  27. package/lib/index.d.ts.map +1 -1
  28. package/lib/index.js +5 -0
  29. package/lib/index.js.map +1 -1
  30. package/lib/models/protocols/pure/DSLDataSpace_PureProtocolProcessorPlugin.d.ts +39 -1
  31. package/lib/models/protocols/pure/DSLDataSpace_PureProtocolProcessorPlugin.d.ts.map +1 -1
  32. package/lib/models/protocols/pure/DSLDataSpace_PureProtocolProcessorPlugin.js +110 -8
  33. package/lib/models/protocols/pure/DSLDataSpace_PureProtocolProcessorPlugin.js.map +1 -1
  34. package/lib/models/protocols/pure/v1/transformation/pureProtocol/V1_DSLDataSpace_ProtocolHelper.d.ts +1 -0
  35. package/lib/models/protocols/pure/v1/transformation/pureProtocol/V1_DSLDataSpace_ProtocolHelper.d.ts.map +1 -1
  36. package/lib/models/protocols/pure/v1/transformation/pureProtocol/V1_DSLDataSpace_ProtocolHelper.js +1 -1
  37. package/lib/models/protocols/pure/v1/transformation/pureProtocol/V1_DSLDataSpace_ProtocolHelper.js.map +1 -1
  38. package/lib/stores/DataSpaceViewerState.d.ts +59 -0
  39. package/lib/stores/DataSpaceViewerState.d.ts.map +1 -0
  40. package/lib/stores/DataSpaceViewerState.js +137 -0
  41. package/lib/stores/DataSpaceViewerState.js.map +1 -0
  42. package/lib/stores/query/DataSpaceQuerySetupState.d.ts +49 -0
  43. package/lib/stores/query/DataSpaceQuerySetupState.d.ts.map +1 -0
  44. package/lib/stores/query/DataSpaceQuerySetupState.js +129 -0
  45. package/lib/stores/query/DataSpaceQuerySetupState.js.map +1 -0
  46. package/package.json +26 -21
  47. package/src/DSLDataSpace_Extension.ts +0 -15
  48. package/src/components/DataSpaceViewer.tsx +598 -0
  49. package/src/components/query/DSLDataSpace_LegendQueryPlugin.tsx +76 -0
  50. package/src/components/query/DataSpaceQuerySetup.tsx +234 -0
  51. package/src/components/studio/{DSLDataSpace_StudioPlugin.tsx → DSLDataSpace_LegendStudioPlugin.tsx} +17 -27
  52. package/src/graph/DSLDataSpace_PureGraphPlugin.ts +1 -1
  53. package/src/index.ts +12 -0
  54. package/src/models/protocols/pure/DSLDataSpace_PureProtocolProcessorPlugin.ts +192 -6
  55. package/src/models/protocols/pure/v1/transformation/pureProtocol/V1_DSLDataSpace_ProtocolHelper.ts +1 -1
  56. package/src/stores/DataSpaceViewerState.ts +202 -0
  57. package/src/stores/query/DataSpaceQuerySetupState.ts +235 -0
  58. package/tsconfig.json +7 -3
  59. package/tsconfig.package.json +1 -0
  60. package/lib/components/studio/DSLDataSpace_StudioPlugin.d.ts.map +0 -1
  61. package/lib/components/studio/DSLDataSpace_StudioPlugin.js.map +0 -1
  62. package/lib/components/studio/DataSpaceEditor.d.ts.map +0 -1
  63. package/lib/components/studio/DataSpaceEditor.js +0 -98
  64. package/lib/components/studio/DataSpaceEditor.js.map +0 -1
  65. package/lib/stores/studio/DataSpaceEditorState.d.ts +0 -42
  66. package/lib/stores/studio/DataSpaceEditorState.d.ts.map +0 -1
  67. package/lib/stores/studio/DataSpaceEditorState.js +0 -76
  68. package/lib/stores/studio/DataSpaceEditorState.js.map +0 -1
  69. package/src/components/studio/DataSpaceEditor.tsx +0 -272
  70. package/src/stores/studio/DataSpaceEditorState.ts +0 -108
@@ -0,0 +1,234 @@
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 { useApplicationStore } from '@finos/legend-application';
18
+ import type { SelectComponent } from '@finos/legend-art';
19
+ import {
20
+ BoltIcon,
21
+ ArrowRightIcon,
22
+ clsx,
23
+ BlankPanelContent,
24
+ TimesCircleIcon,
25
+ PanelLoadingIndicator,
26
+ ArrowLeftIcon,
27
+ CustomSelectorInput,
28
+ SearchIcon,
29
+ } from '@finos/legend-art';
30
+ import { useQuerySetupStore, useLegendQueryStore } from '@finos/legend-query';
31
+ import { generateGAVCoordinates } from '@finos/legend-server-depot';
32
+ import { debounce } from '@finos/legend-shared';
33
+ import { flowResult } from 'mobx';
34
+ import { observer } from 'mobx-react-lite';
35
+ import { useEffect, useMemo, useRef, useState } from 'react';
36
+ import type {
37
+ DataSpaceQuerySetupState,
38
+ LightDataSpace,
39
+ } from '../../stores/query/DataSpaceQuerySetupState';
40
+ import { DataSpaceViewer } from '../DataSpaceViewer';
41
+
42
+ type DataSpaceOption = { label: string; value: LightDataSpace };
43
+ const buildDataSpaceOption = (dataSpace: LightDataSpace): DataSpaceOption => ({
44
+ label: dataSpace.path,
45
+ value: dataSpace,
46
+ });
47
+
48
+ export const DataspaceQuerySetup = observer(
49
+ (props: { querySetupState: DataSpaceQuerySetupState }) => {
50
+ const { querySetupState } = props;
51
+ const applicationStore = useApplicationStore();
52
+ const setupStore = useQuerySetupStore();
53
+ const queryStore = useLegendQueryStore();
54
+ const dataSpaceSearchRef = useRef<SelectComponent>(null);
55
+ const [searchText, setSearchText] = useState('');
56
+
57
+ const toggleGetSnapshot = (): void => {
58
+ querySetupState.setToGetSnapShot(!querySetupState.toGetSnapShot);
59
+ flowResult(querySetupState.loadDataSpaces(searchText)).catch(
60
+ applicationStore.alertIllegalUnhandledError,
61
+ );
62
+ };
63
+
64
+ const next = (): void => {
65
+ if (querySetupState.dataSpaceViewerState) {
66
+ flowResult(querySetupState.proceedToCreateQuery()).catch(
67
+ applicationStore.alertIllegalUnhandledError,
68
+ );
69
+ }
70
+ };
71
+ const canProceed = querySetupState.dataSpaceViewerState;
72
+
73
+ const back = (): void => {
74
+ setupStore.setSetupState(undefined);
75
+ querySetupState.setCurrentDataSpace(undefined);
76
+ queryStore.graphManagerState.resetGraph();
77
+ };
78
+
79
+ // query
80
+ const dataSpaceOptions =
81
+ querySetupState.dataSpaces.map(buildDataSpaceOption);
82
+ const selectedDataSpaceOption = querySetupState.currentDataSpace
83
+ ? buildDataSpaceOption(querySetupState.currentDataSpace)
84
+ : null;
85
+ const onDataSpaceOptionChange = (option: DataSpaceOption | null): void => {
86
+ if (option?.value !== querySetupState.currentDataSpace) {
87
+ queryStore.graphManagerState.resetGraph();
88
+ querySetupState.setCurrentDataSpace(option?.value);
89
+ querySetupState.setDataSpaceViewerState(undefined);
90
+ }
91
+ };
92
+ const formatQueryOptionLabel = (
93
+ option: DataSpaceOption,
94
+ ): React.ReactNode => (
95
+ <div className="query-setup__data-space__option">
96
+ <div className="query-setup__data-space__option__label">
97
+ {option.label}
98
+ </div>
99
+ <div className="query-setup__data-space__option__gav">
100
+ {generateGAVCoordinates(
101
+ option.value.groupId,
102
+ option.value.artifactId,
103
+ option.value.versionId,
104
+ )}
105
+ </div>
106
+ </div>
107
+ );
108
+
109
+ // search text
110
+ const debouncedLoadDataSpaces = useMemo(
111
+ () =>
112
+ debounce((input: string): void => {
113
+ flowResult(querySetupState.loadDataSpaces(input)).catch(
114
+ applicationStore.alertIllegalUnhandledError,
115
+ );
116
+ }, 500),
117
+ [applicationStore, querySetupState],
118
+ );
119
+ const onSearchTextChange = (value: string): void => {
120
+ if (value !== searchText) {
121
+ setSearchText(value);
122
+ debouncedLoadDataSpaces.cancel();
123
+ debouncedLoadDataSpaces(value);
124
+ }
125
+ };
126
+
127
+ useEffect(() => {
128
+ flowResult(querySetupState.loadDataSpaces('')).catch(
129
+ applicationStore.alertIllegalUnhandledError,
130
+ );
131
+ }, [querySetupState, applicationStore]);
132
+
133
+ useEffect(() => {
134
+ if (querySetupState.currentDataSpace) {
135
+ flowResult(
136
+ querySetupState.setUpDataSpace(querySetupState.currentDataSpace),
137
+ ).catch(applicationStore.alertIllegalUnhandledError);
138
+ }
139
+ }, [querySetupState, applicationStore, querySetupState.currentDataSpace]);
140
+
141
+ useEffect(() => {
142
+ dataSpaceSearchRef.current?.focus();
143
+ }, []);
144
+
145
+ return (
146
+ <div className="query-setup__wizard query-setup__data-space">
147
+ <div className="query-setup__wizard__header query-setup__data-space__header">
148
+ <button
149
+ className="query-setup__wizard__header__btn"
150
+ onClick={back}
151
+ title="Back to Main Menu"
152
+ >
153
+ <ArrowLeftIcon />
154
+ </button>
155
+ <div className="query-setup__wizard__header__title">
156
+ Creating query from data space...
157
+ </div>
158
+ <button
159
+ className={clsx('query-setup__wizard__header__btn', {
160
+ 'query-setup__wizard__header__btn--ready': canProceed,
161
+ })}
162
+ onClick={next}
163
+ disabled={!canProceed}
164
+ title="Proceed"
165
+ >
166
+ <ArrowRightIcon />
167
+ </button>
168
+ </div>
169
+ <div className="query-setup__wizard__content">
170
+ <div className="query-setup__wizard__group query-setup__wizard__group--inline query-setup__data-space__input-group">
171
+ <div className="query-setup__wizard__group__title">
172
+ <SearchIcon />
173
+ </div>
174
+ <CustomSelectorInput
175
+ ref={dataSpaceSearchRef}
176
+ className="query-setup__wizard__selector"
177
+ options={dataSpaceOptions}
178
+ isLoading={querySetupState.loadDataSpacesState.isInProgress}
179
+ onInputChange={onSearchTextChange}
180
+ inputValue={searchText}
181
+ onChange={onDataSpaceOptionChange}
182
+ value={selectedDataSpaceOption}
183
+ placeholder="Search for data space by name..."
184
+ isClearable={true}
185
+ escapeClearsValue={true}
186
+ darkMode={true}
187
+ formatOptionLabel={formatQueryOptionLabel}
188
+ />
189
+ <button
190
+ className={clsx('query-setup__data-space__use-snapshot-btn', {
191
+ 'query-setup__data-space__use-snapshot-btn--active':
192
+ querySetupState.toGetSnapShot,
193
+ })}
194
+ tabIndex={-1}
195
+ title={`[${
196
+ querySetupState.toGetSnapShot ? 'on' : 'off'
197
+ }] Toggle show data spaces from snapshot releases instead of latest releases`}
198
+ onClick={toggleGetSnapshot}
199
+ >
200
+ <BoltIcon />
201
+ </button>
202
+ </div>
203
+ <div className="query-setup__data-space__view">
204
+ <PanelLoadingIndicator
205
+ isLoading={querySetupState.setUpDataSpaceState.isInProgress}
206
+ />
207
+ {querySetupState.dataSpaceViewerState && (
208
+ <DataSpaceViewer
209
+ dataSpaceViewerState={querySetupState.dataSpaceViewerState}
210
+ />
211
+ )}
212
+ {!querySetupState.dataSpaceViewerState &&
213
+ querySetupState.setUpDataSpaceState.isInProgress && (
214
+ <BlankPanelContent>Setting up data space...</BlankPanelContent>
215
+ )}
216
+ {!querySetupState.dataSpaceViewerState &&
217
+ querySetupState.setUpDataSpaceState.hasFailed && (
218
+ <BlankPanelContent>
219
+ <div className="query-setup__data-space__view--failed">
220
+ <div className="query-setup__data-space__view--failed__icon">
221
+ <TimesCircleIcon />
222
+ </div>
223
+ <div className="query-setup__data-space__view--failed__text">
224
+ Can&apos;t load data space
225
+ </div>
226
+ </div>
227
+ </BlankPanelContent>
228
+ )}
229
+ </div>
230
+ </div>
231
+ </div>
232
+ );
233
+ },
234
+ );
@@ -16,41 +16,42 @@
16
16
 
17
17
  import packageJson from '../../../package.json';
18
18
  import type {
19
- StudioPluginManager,
19
+ LegendStudioPluginManager,
20
20
  NewElementFromStateCreator,
21
- EditorStore,
22
- ElementEditorState,
23
- ElementEditorStateCreator,
24
21
  ElementTypeGetter,
25
22
  ElementProjectExplorerDnDTypeGetter,
26
23
  ElementIconGetter,
27
- DSL_StudioPlugin_Extension,
24
+ DSL_LegendStudioPlugin_Extension,
28
25
  NewElementState,
29
- ElementEditorRenderer,
26
+ ElementEditorStateCreator,
27
+ EditorStore,
28
+ ElementEditorState,
29
+ } from '@finos/legend-studio';
30
+ import {
31
+ UnsupportedElementEditorState,
32
+ LegendStudioPlugin,
30
33
  } from '@finos/legend-studio';
31
- import { StudioPlugin } from '@finos/legend-studio';
32
34
  import { SquareIcon } from '@finos/legend-art';
33
35
  import type { PackageableElement } from '@finos/legend-graph';
34
36
  import {
35
37
  DataSpace,
36
38
  DataSpaceExecutionContext,
37
39
  } from '../../models/metamodels/pure/model/packageableElements/dataSpace/DataSpace';
38
- import { DataSpaceEditorState } from '../../stores/studio/DataSpaceEditorState';
39
- import { DataSpaceViewer } from './DataSpaceEditor';
40
+ import { LATEST_VERSION_ALIAS } from '@finos/legend-server-depot';
40
41
 
41
42
  const DATA_SPACE_ELEMENT_TYPE = 'DATA SPACE';
42
43
  const DATA_SPACE_ELEMENT_PROJECT_EXPLORER_DND_TYPE =
43
44
  'PROJECT_EXPLORER_DATA_SPACE';
44
45
 
45
- export class DSLDataSpace_StudioPlugin
46
- extends StudioPlugin
47
- implements DSL_StudioPlugin_Extension
46
+ export class DSLDataSpace_LegendStudioPlugin
47
+ extends LegendStudioPlugin
48
+ implements DSL_LegendStudioPlugin_Extension
48
49
  {
49
50
  constructor() {
50
51
  super(packageJson.extensions.studioPlugin, packageJson.version);
51
52
  }
52
53
 
53
- install(pluginManager: StudioPluginManager): void {
54
+ install(pluginManager: LegendStudioPluginManager): void {
54
55
  pluginManager.registerStudioPlugin(this);
55
56
  }
56
57
 
@@ -74,7 +75,7 @@ export class DSLDataSpace_StudioPlugin
74
75
  (type: string): React.ReactNode | undefined => {
75
76
  if (type === DATA_SPACE_ELEMENT_TYPE) {
76
77
  return (
77
- <div className="icon icon--text-element">
78
+ <div className="icon icon--data-space">
78
79
  <SquareIcon />
79
80
  </div>
80
81
  );
@@ -84,17 +85,6 @@ export class DSLDataSpace_StudioPlugin
84
85
  ];
85
86
  }
86
87
 
87
- getExtraElementEditorRenderers(): ElementEditorRenderer[] {
88
- return [
89
- (elementEditorState: ElementEditorState): React.ReactNode | undefined => {
90
- if (elementEditorState instanceof DataSpaceEditorState) {
91
- return <DataSpaceViewer key={elementEditorState.uuid} />;
92
- }
93
- return undefined;
94
- },
95
- ];
96
- }
97
-
98
88
  getExtraNewElementFromStateCreators(): NewElementFromStateCreator[] {
99
89
  return [
100
90
  (
@@ -108,7 +98,7 @@ export class DSLDataSpace_StudioPlugin
108
98
  state.editorStore.projectConfigurationEditorState.currentProjectConfiguration.groupId;
109
99
  dataSpace.artifactId =
110
100
  state.editorStore.projectConfigurationEditorState.currentProjectConfiguration.artifactId;
111
- dataSpace.versionId = 'latest';
101
+ dataSpace.versionId = LATEST_VERSION_ALIAS;
112
102
  const dataSpaceExecutionContext = new DataSpaceExecutionContext();
113
103
  dataSpaceExecutionContext.name = 'dummyContext';
114
104
  dataSpaceExecutionContext.mapping = 'dummyMapping';
@@ -129,7 +119,7 @@ export class DSLDataSpace_StudioPlugin
129
119
  element: PackageableElement,
130
120
  ): ElementEditorState | undefined => {
131
121
  if (element instanceof DataSpace) {
132
- return new DataSpaceEditorState(editorStore, element);
122
+ return new UnsupportedElementEditorState(editorStore, element);
133
123
  }
134
124
  return undefined;
135
125
  },
@@ -29,7 +29,7 @@ export class DSLDataSpace_PureGraphPlugin extends PureGraphPlugin {
29
29
  }
30
30
 
31
31
  install(pluginManager: GraphPluginManager): void {
32
- pluginManager.registerPureGraphPlugins(this);
32
+ pluginManager.registerPureGraphPlugin(this);
33
33
  }
34
34
 
35
35
  override getExtraPureGraphExtensionClasses(): Clazz<PackageableElement>[] {
package/src/index.ts CHANGED
@@ -15,3 +15,15 @@
15
15
  */
16
16
 
17
17
  export * from './DSLDataSpace_Extension';
18
+ export { DSLDataSpace_LegendStudioPlugin } from './components/studio/DSLDataSpace_LegendStudioPlugin';
19
+ export { DSLDataSpace_LegendQueryPlugin } from './components/query/DSLDataSpace_LegendQueryPlugin';
20
+
21
+ export { DataSpaceViewer } from './components/DataSpaceViewer';
22
+
23
+ export {
24
+ DATA_SPACE_ELEMENT_CLASSIFIER_PATH,
25
+ extractDataSpaceTaxonomyNodes,
26
+ getResolvedDataSpace,
27
+ } from './models/protocols/pure/DSLDataSpace_PureProtocolProcessorPlugin';
28
+
29
+ export { DataSpaceViewerState } from './stores/DataSpaceViewerState';
@@ -23,6 +23,7 @@ import {
23
23
  } from './v1/model/packageableElements/dataSpace/V1_DataSpace';
24
24
  import type { PlainObject } from '@finos/legend-shared';
25
25
  import {
26
+ uuid,
26
27
  guaranteeNonEmptyString,
27
28
  guaranteeNonNullable,
28
29
  UnsupportedOperationError,
@@ -35,6 +36,7 @@ import {
35
36
  V1_DATA_SPACE_ELEMENT_PROTOCOL_TYPE,
36
37
  } from './v1/transformation/pureProtocol/V1_DSLDataSpace_ProtocolHelper';
37
38
  import { getDataSpace } from '../../../graphManager/DSLDataSpace_GraphManagerHelper';
39
+ import type { DataSpaceSupportInfo } from '../../metamodels/pure/model/packageableElements/dataSpace/DataSpace';
38
40
  import {
39
41
  DataSpace,
40
42
  DataSpaceExecutionContext,
@@ -42,7 +44,11 @@ import {
42
44
  } from '../../metamodels/pure/model/packageableElements/dataSpace/DataSpace';
43
45
  import type {
44
46
  GraphPluginManager,
47
+ Mapping,
45
48
  PackageableElement,
49
+ PackageableElementReference,
50
+ PackageableRuntime,
51
+ PureModel,
46
52
  V1_ElementProtocolClassifierPathGetter,
47
53
  V1_ElementProtocolDeserializer,
48
54
  V1_ElementProtocolSerializer,
@@ -51,8 +57,11 @@ import type {
51
57
  V1_GraphTransformerContext,
52
58
  V1_PackageableElement,
53
59
  V1_PureModelContextData,
60
+ V1_TaggedValue,
54
61
  } from '@finos/legend-graph';
55
62
  import {
63
+ V1_taggedValueSchema,
64
+ PackageableElementExplicitReference,
56
65
  V1_PackageableElementPointer,
57
66
  V1_PackageableElementPointerType,
58
67
  V1_buildTaggedValue,
@@ -61,10 +70,14 @@ import {
61
70
  PureProtocolProcessorPlugin,
62
71
  V1_ElementBuilder,
63
72
  V1_initPackageableElement,
73
+ V1_StereotypePtr,
64
74
  } from '@finos/legend-graph';
65
- import { V1_DSLDiagram_PackageableElementPointerType } from '@finos/legend-extension-dsl-diagram';
75
+ import {
76
+ Diagram,
77
+ V1_DSLDiagram_PackageableElementPointerType,
78
+ } from '@finos/legend-extension-dsl-diagram';
66
79
 
67
- const DATA_SPACE_ELEMENT_CLASSIFIER_PATH =
80
+ export const DATA_SPACE_ELEMENT_CLASSIFIER_PATH =
68
81
  'meta::pure::metamodel::dataSpace::DataSpace';
69
82
 
70
83
  export class DSLDataSpace_PureProtocolProcessorPlugin extends PureProtocolProcessorPlugin {
@@ -161,15 +174,20 @@ export class DSLDataSpace_PureProtocolProcessorPlugin extends PureProtocolProces
161
174
  `Can't find default execution context '${elementProtocol.defaultExecutionContext}'`,
162
175
  );
163
176
  element.description = elementProtocol.description;
164
- element.featuredDiagrams = (
165
- elementProtocol.featuredDiagrams ?? []
166
- ).map((pointer) => pointer.path);
177
+ if (elementProtocol.featuredDiagrams) {
178
+ element.featuredDiagrams = elementProtocol.featuredDiagrams.map(
179
+ (pointer) => pointer.path,
180
+ );
181
+ }
167
182
  if (elementProtocol.supportInfo) {
168
183
  if (
169
184
  elementProtocol.supportInfo instanceof V1_DataSpaceSupportEmail
170
185
  ) {
171
186
  const supportEmail = new DataSpaceSupportEmail();
172
- supportEmail.address = elementProtocol.supportInfo.address;
187
+ supportEmail.address = guaranteeNonEmptyString(
188
+ elementProtocol.supportInfo.address,
189
+ `Data space support email 'address' field is missing or empty`,
190
+ );
173
191
  element.supportInfo = supportEmail;
174
192
  } else {
175
193
  throw new UnsupportedOperationError(
@@ -202,6 +220,7 @@ export class DSLDataSpace_PureProtocolProcessorPlugin extends PureProtocolProces
202
220
  return [
203
221
  (
204
222
  elementProtocol: V1_PackageableElement,
223
+ plugins: PureProtocolProcessorPlugin[],
205
224
  ): PlainObject<V1_PackageableElement> | undefined => {
206
225
  if (elementProtocol instanceof V1_DataSpace) {
207
226
  return serialize(V1_dataSpaceModelSchema, elementProtocol);
@@ -215,6 +234,7 @@ export class DSLDataSpace_PureProtocolProcessorPlugin extends PureProtocolProces
215
234
  return [
216
235
  (
217
236
  json: PlainObject<V1_PackageableElement>,
237
+ plugins: PureProtocolProcessorPlugin[],
218
238
  ): V1_PackageableElement | undefined => {
219
239
  if (json._type === V1_DATA_SPACE_ELEMENT_PROTOCOL_TYPE) {
220
240
  return deserialize(V1_dataSpaceModelSchema, json);
@@ -288,3 +308,169 @@ export class DSLDataSpace_PureProtocolProcessorPlugin extends PureProtocolProces
288
308
  ];
289
309
  }
290
310
  }
311
+
312
+ export class ResolvedDataSpaceExecutionContext {
313
+ name!: string;
314
+ description?: string | undefined;
315
+ mapping!: PackageableElementReference<Mapping>;
316
+ defaultRuntime!: PackageableElementReference<PackageableRuntime>;
317
+ }
318
+
319
+ /**
320
+ * When we actually need to use the data space, we want to resolve all of its
321
+ * element pointers to actual reference, hence this model.
322
+ */
323
+ export class ResolvedDataSpace {
324
+ taggedValues: {
325
+ uuid: string;
326
+ profile: string;
327
+ tag: string;
328
+ value: string;
329
+ }[] = [];
330
+ stereotypes: { uuid: string; profile: string; stereotype: string }[] = [];
331
+ path!: string;
332
+ groupId!: string;
333
+ artifactId!: string;
334
+ versionId!: string;
335
+ executionContexts: ResolvedDataSpaceExecutionContext[] = [];
336
+ defaultExecutionContext!: ResolvedDataSpaceExecutionContext;
337
+ featuredDiagrams: PackageableElementReference<Diagram>[] = [];
338
+ description?: string | undefined;
339
+ supportInfo?: DataSpaceSupportInfo | undefined;
340
+ }
341
+
342
+ export const getResolvedDataSpace = (
343
+ json: PlainObject<V1_DataSpace>,
344
+ graph: PureModel,
345
+ ): ResolvedDataSpace => {
346
+ const dataSpace = new ResolvedDataSpace();
347
+ if (json._type === V1_DATA_SPACE_ELEMENT_PROTOCOL_TYPE) {
348
+ const protocol = deserialize(V1_dataSpaceModelSchema, json);
349
+ dataSpace.path = protocol.path;
350
+ if (Array.isArray(json.taggedValues)) {
351
+ dataSpace.taggedValues = (
352
+ json.taggedValues as PlainObject<V1_TaggedValue>[]
353
+ )
354
+ .map((taggedValueJson) =>
355
+ deserialize(V1_taggedValueSchema, taggedValueJson),
356
+ )
357
+ .map((taggedValue) => ({
358
+ uuid: uuid(),
359
+ profile: taggedValue.tag.profile,
360
+ tag: taggedValue.tag.value,
361
+ value: taggedValue.value,
362
+ }));
363
+ }
364
+ if (Array.isArray(json.stereotypes)) {
365
+ dataSpace.stereotypes = (
366
+ json.stereotypes as PlainObject<V1_StereotypePtr>[]
367
+ )
368
+ .map((stereotypePtrJson) =>
369
+ deserialize(V1_StereotypePtr, stereotypePtrJson),
370
+ )
371
+ .map((stereotypePtr) => ({
372
+ uuid: uuid(),
373
+ profile: stereotypePtr.profile,
374
+ stereotype: stereotypePtr.value,
375
+ }));
376
+ }
377
+ dataSpace.groupId = guaranteeNonEmptyString(
378
+ protocol.groupId,
379
+ `Data space 'groupId' field is missing or empty`,
380
+ );
381
+ dataSpace.artifactId = guaranteeNonEmptyString(
382
+ protocol.artifactId,
383
+ `Data space 'artifactId' field is missing or empty`,
384
+ );
385
+ dataSpace.versionId = guaranteeNonEmptyString(
386
+ protocol.versionId,
387
+ `Data space 'versionId' field is missing or empty`,
388
+ );
389
+ dataSpace.executionContexts = protocol.executionContexts.map(
390
+ (contextProtocol) => {
391
+ const context = new ResolvedDataSpaceExecutionContext();
392
+ context.name = guaranteeNonEmptyString(
393
+ contextProtocol.name,
394
+ `Data space execution context 'name' field is missing or empty`,
395
+ );
396
+ context.description = contextProtocol.description;
397
+ context.mapping = PackageableElementExplicitReference.create(
398
+ graph.getMapping(contextProtocol.mapping.path),
399
+ );
400
+ context.defaultRuntime = PackageableElementExplicitReference.create(
401
+ graph.getRuntime(contextProtocol.defaultRuntime.path),
402
+ );
403
+ return context;
404
+ },
405
+ );
406
+ dataSpace.defaultExecutionContext = guaranteeNonNullable(
407
+ dataSpace.executionContexts.find(
408
+ (context) =>
409
+ context.name ===
410
+ guaranteeNonEmptyString(
411
+ protocol.defaultExecutionContext,
412
+ `Data space 'defaultExecutionContext' field is missing or empty`,
413
+ ),
414
+ ),
415
+ `Can't find default execution context '${protocol.defaultExecutionContext}'`,
416
+ );
417
+ dataSpace.description = protocol.description;
418
+ if (protocol.featuredDiagrams) {
419
+ dataSpace.featuredDiagrams = protocol.featuredDiagrams.map((pointer) =>
420
+ PackageableElementExplicitReference.create(
421
+ graph.getExtensionElement(pointer.path, Diagram),
422
+ ),
423
+ );
424
+ }
425
+ if (protocol.supportInfo) {
426
+ if (protocol.supportInfo instanceof V1_DataSpaceSupportEmail) {
427
+ const supportEmail = new DataSpaceSupportEmail();
428
+ supportEmail.address = guaranteeNonEmptyString(
429
+ protocol.supportInfo.address,
430
+ `Data space support email 'address' field is missing or empty`,
431
+ );
432
+ dataSpace.supportInfo = supportEmail;
433
+ } else {
434
+ throw new UnsupportedOperationError(
435
+ `Can't build data space support info`,
436
+ protocol.supportInfo,
437
+ );
438
+ }
439
+ }
440
+ return dataSpace;
441
+ }
442
+ throw new UnsupportedOperationError(`Can't resolve data space`, json);
443
+ };
444
+
445
+ export const extractDataSpaceTaxonomyNodes = (
446
+ json: PlainObject<V1_DataSpace>,
447
+ ): string[] => {
448
+ const ENTERPRISE_PROFILE_PATH = `meta::pure::profiles::enterprise`;
449
+ const TAXONOMY_NODES_TAG = `taxonomyNodes`;
450
+ const TAXONOMY_NODES_TAG_VALUE_DELIMITER = `,`;
451
+
452
+ const taxonomyNodes = new Set<string>();
453
+ if (json._type === V1_DATA_SPACE_ELEMENT_PROTOCOL_TYPE) {
454
+ if (Array.isArray(json.taggedValues)) {
455
+ const taggedValues = (
456
+ json.taggedValues as PlainObject<V1_TaggedValue>[]
457
+ ).map((taggedValueJson) =>
458
+ deserialize(V1_taggedValueSchema, taggedValueJson),
459
+ );
460
+ taggedValues
461
+ .filter(
462
+ (taggedValue) =>
463
+ taggedValue.tag.profile === ENTERPRISE_PROFILE_PATH &&
464
+ taggedValue.tag.value === TAXONOMY_NODES_TAG,
465
+ )
466
+ .forEach((taggedValue) => {
467
+ taggedValue.value
468
+ .split(TAXONOMY_NODES_TAG_VALUE_DELIMITER)
469
+ .map((value) => value.trim())
470
+ .filter((value) => Boolean(value))
471
+ .forEach((value) => taxonomyNodes.add(value));
472
+ });
473
+ }
474
+ }
475
+ return Array.from(taxonomyNodes.values());
476
+ };
@@ -47,7 +47,7 @@ import {
47
47
  } from '../../model/packageableElements/dataSpace/V1_DataSpace';
48
48
 
49
49
  export const V1_DATA_SPACE_ELEMENT_PROTOCOL_TYPE = 'dataSpace';
50
- const V1_DATA_SPACE_SUPPORT_EMAIL_TYPE = 'email';
50
+ export const V1_DATA_SPACE_SUPPORT_EMAIL_TYPE = 'email';
51
51
 
52
52
  const V1_dataSpaceExecutionContextModelSchema = createModelSchema(
53
53
  V1_DataSpaceExecutionContext,