@finos/legend-extension-dsl-data-space-studio 0.1.358 → 0.1.360

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 (35) hide show
  1. package/lib/components/DataSpaceEditor.d.ts.map +1 -1
  2. package/lib/components/DataSpaceEditor.js +4 -0
  3. package/lib/components/DataSpaceEditor.js.map +1 -1
  4. package/lib/components/DataSpaceGeneralEditor/DataSpaceGeneralEditor.d.ts.map +1 -1
  5. package/lib/components/DataSpaceGeneralEditor/DataSpaceGeneralEditor.js +3 -0
  6. package/lib/components/DataSpaceGeneralEditor/DataSpaceGeneralEditor.js.map +1 -1
  7. package/lib/components/DataSpaceGeneralEditor/DataSpaceInfoTab.d.ts +19 -0
  8. package/lib/components/DataSpaceGeneralEditor/DataSpaceInfoTab.d.ts.map +1 -0
  9. package/lib/components/DataSpaceGeneralEditor/DataSpaceInfoTab.js +28 -0
  10. package/lib/components/DataSpaceGeneralEditor/DataSpaceInfoTab.js.map +1 -0
  11. package/lib/components/DataSpaceGeneralEditor/DataSpaceRelatedDataSpacesSection.d.ts +19 -0
  12. package/lib/components/DataSpaceGeneralEditor/DataSpaceRelatedDataSpacesSection.d.ts.map +1 -0
  13. package/lib/components/DataSpaceGeneralEditor/DataSpaceRelatedDataSpacesSection.js +48 -0
  14. package/lib/components/DataSpaceGeneralEditor/DataSpaceRelatedDataSpacesSection.js.map +1 -0
  15. package/lib/components/DataSpaceGeneralEditor/DataSpaceSidebar.d.ts.map +1 -1
  16. package/lib/components/DataSpaceGeneralEditor/DataSpaceSidebar.js +2 -1
  17. package/lib/components/DataSpaceGeneralEditor/DataSpaceSidebar.js.map +1 -1
  18. package/lib/index.css +1 -1
  19. package/lib/package.json +1 -1
  20. package/lib/stores/DataSpaceEditorState.d.ts +36 -3
  21. package/lib/stores/DataSpaceEditorState.d.ts.map +1 -1
  22. package/lib/stores/DataSpaceEditorState.js +178 -5
  23. package/lib/stores/DataSpaceEditorState.js.map +1 -1
  24. package/lib/stores/DataSpacePreviewState.d.ts.map +1 -1
  25. package/lib/stores/DataSpacePreviewState.js +11 -2
  26. package/lib/stores/DataSpacePreviewState.js.map +1 -1
  27. package/package.json +12 -12
  28. package/src/components/DataSpaceEditor.tsx +7 -0
  29. package/src/components/DataSpaceGeneralEditor/DataSpaceGeneralEditor.tsx +3 -0
  30. package/src/components/DataSpaceGeneralEditor/DataSpaceInfoTab.tsx +67 -0
  31. package/src/components/DataSpaceGeneralEditor/DataSpaceRelatedDataSpacesSection.tsx +101 -0
  32. package/src/components/DataSpaceGeneralEditor/DataSpaceSidebar.tsx +8 -1
  33. package/src/stores/DataSpaceEditorState.ts +321 -2
  34. package/src/stores/DataSpacePreviewState.ts +19 -0
  35. package/tsconfig.json +2 -0
@@ -14,27 +14,64 @@
14
14
  * limitations under the License.
15
15
  */
16
16
 
17
- import { action, computed, makeObservable, observable } from 'mobx';
17
+ import { action, computed, flow, makeObservable, observable } from 'mobx';
18
18
  import {
19
19
  type EditorStore,
20
20
  ElementEditorState,
21
+ annotatedElement_addTaggedValue,
22
+ annotatedElement_deleteTaggedValue,
23
+ annotatedElement_addStereotype,
24
+ annotatedElement_deleteStereotype,
25
+ taggedValue_setValue,
21
26
  } from '@finos/legend-application-studio';
22
27
  import {
23
28
  type PackageableElement,
29
+ type StereotypeReference,
24
30
  Package,
25
31
  Class,
26
32
  Enumeration,
27
33
  Association,
28
34
  Service,
29
35
  ConcreteFunctionDefinition,
36
+ TaggedValue,
37
+ TagExplicitReference,
38
+ StereotypeExplicitReference,
39
+ getTag,
40
+ getStereotype,
30
41
  } from '@finos/legend-graph';
31
42
  import { Diagram } from '@finos/legend-extension-dsl-diagram/graph';
32
43
  import {
33
44
  DataSpace,
34
45
  DataSpacePackageableElementExecutable,
35
46
  type DataSpaceElement,
47
+ type ResolvedDataSpaceEntityWithOrigin,
48
+ extractDataSpaceInfoFromSummary,
49
+ DATA_SPACE_ELEMENT_CLASSIFIER_PATH,
50
+ PURE_DATA_SPACE_INFO_PROFILE_PATH,
51
+ PURE_DATA_SPACE_INFO_PROFILE_VERIFIED_STEREOTYPE,
52
+ PURE_DATA_SPACE_INFO_PROFILE_IN_DEVELOPMENT_STEREOTYPE,
53
+ PURE_DATA_SPACE_INFO_PROFILE_EXTERNAL_STEREOTYPE,
54
+ PURE_DATA_SPACE_INFO_PROFILE_RELATED_DATA_SPACES_TAG,
55
+ PURE_DATA_SPACE_INFO_PROFILE_DEPRECATION_NOTICE_TAG,
36
56
  } from '@finos/legend-extension-dsl-data-space/graph';
37
- import { guaranteeType } from '@finos/legend-shared';
57
+ import {
58
+ encodeRelatedDataSpaceGAV,
59
+ parseRelatedDataSpaceGAV,
60
+ parseRelatedDataSpaceGAVs,
61
+ splitRelatedDataSpaceEntries,
62
+ } from '@finos/legend-extension-dsl-data-space/application';
63
+ import {
64
+ DepotScope,
65
+ LATEST_VERSION_ALIAS,
66
+ type StoredSummaryEntity,
67
+ } from '@finos/legend-server-depot';
68
+ import {
69
+ ActionState,
70
+ assertErrorThrown,
71
+ guaranteeNonNullable,
72
+ guaranteeType,
73
+ type GeneratorFn,
74
+ } from '@finos/legend-shared';
38
75
  import { DataSpaceExecutionContextState } from './DataSpaceExecutionContextState.js';
39
76
  import { DataSpaceExecutableTemplateStateCache } from './DataSpaceExecutableTemplateState.js';
40
77
  import { DataSpaceExecutableSampleValuesStateCache } from './DataSpaceExecutableSampleValuesState.js';
@@ -43,13 +80,28 @@ export enum DATA_SPACE_TAB {
43
80
  HOME = 'Home',
44
81
  EXECUTION_CONTEXTS = 'Execution Contexts',
45
82
  EXECUTABLES = 'Executables',
83
+ INFO = 'Info',
84
+ }
85
+
86
+ export interface RelatedDataSpaceRow {
87
+ id: string;
88
+ label: string;
89
+ taggedValue: TaggedValue;
90
+ entryIndex: number;
91
+ isMultiEntry: boolean;
46
92
  }
47
93
 
48
94
  export class DataSpaceEditorState extends ElementEditorState {
49
95
  executionContextState: DataSpaceExecutionContextState;
50
96
  readonly executableTemplateStates: DataSpaceExecutableTemplateStateCache;
51
97
  readonly executableSampleValuesStates: DataSpaceExecutableSampleValuesStateCache;
98
+ readonly loadRelatedDataSpacesState = ActionState.create();
52
99
  selectedTab = DATA_SPACE_TAB.HOME;
100
+ availableRelatedDataSpaces: ResolvedDataSpaceEntityWithOrigin[] = [];
101
+
102
+ private static relatedDataSpacesCache:
103
+ | Promise<ResolvedDataSpaceEntityWithOrigin[]>
104
+ | undefined;
53
105
 
54
106
  constructor(editorStore: EditorStore, element: PackageableElement) {
55
107
  super(editorStore, element);
@@ -57,13 +109,29 @@ export class DataSpaceEditorState extends ElementEditorState {
57
109
  makeObservable(this, {
58
110
  executionContextState: observable,
59
111
  selectedTab: observable,
112
+ availableRelatedDataSpaces: observable,
60
113
  dataSpace: computed,
114
+ relatedDataSpaceTaggedValues: computed,
115
+ isVerified: computed,
116
+ isInDevelopment: computed,
117
+ isExternal: computed,
118
+ deprecationNotice: computed,
61
119
  reprocess: action,
62
120
  isValidDataSpaceElement: action,
63
121
  getDataSpaceElementOptions: action,
64
122
  getDiagramOptions: action,
65
123
  getDataSpaceExecutableOptions: action,
124
+ getRelatedDataSpaceOptions: action,
125
+ addRelatedDataSpace: action,
126
+ removeRelatedDataSpace: action,
127
+ removeRelatedDataSpaceRow: action,
128
+ toggleVerified: action,
129
+ toggleInDevelopment: action,
130
+ toggleExternal: action,
131
+ setDeprecationNotice: action,
132
+ relatedDataSpaceRows: computed,
66
133
  setSelectedTab: action,
134
+ loadRelatedDataSpaces: flow,
67
135
  });
68
136
 
69
137
  this.executionContextState = new DataSpaceExecutionContextState(this);
@@ -151,6 +219,257 @@ export class DataSpaceEditorState extends ElementEditorState {
151
219
  );
152
220
  }
153
221
 
222
+ private findInfoStereotype(
223
+ stereotypeValue: string,
224
+ ): StereotypeReference | undefined {
225
+ return this.dataSpace.stereotypes.find(
226
+ (stereotype) =>
227
+ stereotype.ownerReference.value.path ===
228
+ PURE_DATA_SPACE_INFO_PROFILE_PATH &&
229
+ stereotype.value.value === stereotypeValue,
230
+ );
231
+ }
232
+
233
+ private toggleInfoStereotype(stereotypeValue: string, value: boolean): void {
234
+ const existing = this.findInfoStereotype(stereotypeValue);
235
+ if (value) {
236
+ if (!existing) {
237
+ annotatedElement_addStereotype(
238
+ this.dataSpace,
239
+ StereotypeExplicitReference.create(
240
+ getStereotype(
241
+ this.editorStore.graphManagerState.graph.getProfile(
242
+ PURE_DATA_SPACE_INFO_PROFILE_PATH,
243
+ ),
244
+ stereotypeValue,
245
+ ),
246
+ ),
247
+ );
248
+ }
249
+ } else if (existing) {
250
+ annotatedElement_deleteStereotype(this.dataSpace, existing);
251
+ }
252
+ }
253
+
254
+ get isVerified(): boolean {
255
+ return Boolean(
256
+ this.findInfoStereotype(PURE_DATA_SPACE_INFO_PROFILE_VERIFIED_STEREOTYPE),
257
+ );
258
+ }
259
+
260
+ get isInDevelopment(): boolean {
261
+ return Boolean(
262
+ this.findInfoStereotype(
263
+ PURE_DATA_SPACE_INFO_PROFILE_IN_DEVELOPMENT_STEREOTYPE,
264
+ ),
265
+ );
266
+ }
267
+
268
+ toggleVerified(value: boolean): void {
269
+ this.toggleInfoStereotype(
270
+ PURE_DATA_SPACE_INFO_PROFILE_VERIFIED_STEREOTYPE,
271
+ value,
272
+ );
273
+ }
274
+
275
+ toggleInDevelopment(value: boolean): void {
276
+ this.toggleInfoStereotype(
277
+ PURE_DATA_SPACE_INFO_PROFILE_IN_DEVELOPMENT_STEREOTYPE,
278
+ value,
279
+ );
280
+ }
281
+
282
+ get isExternal(): boolean {
283
+ return Boolean(
284
+ this.findInfoStereotype(PURE_DATA_SPACE_INFO_PROFILE_EXTERNAL_STEREOTYPE),
285
+ );
286
+ }
287
+
288
+ toggleExternal(value: boolean): void {
289
+ this.toggleInfoStereotype(
290
+ PURE_DATA_SPACE_INFO_PROFILE_EXTERNAL_STEREOTYPE,
291
+ value,
292
+ );
293
+ }
294
+
295
+ private findDeprecationNoticeTaggedValue(): TaggedValue | undefined {
296
+ return this.dataSpace.taggedValues.find(
297
+ (taggedValue) =>
298
+ taggedValue.tag.ownerReference.value.path ===
299
+ PURE_DATA_SPACE_INFO_PROFILE_PATH &&
300
+ taggedValue.tag.value.value ===
301
+ PURE_DATA_SPACE_INFO_PROFILE_DEPRECATION_NOTICE_TAG,
302
+ );
303
+ }
304
+
305
+ get deprecationNotice(): string | undefined {
306
+ return this.findDeprecationNoticeTaggedValue()?.value;
307
+ }
308
+
309
+ setDeprecationNotice(value: string | undefined): void {
310
+ const existing = this.findDeprecationNoticeTaggedValue();
311
+ if (value !== undefined && value !== '') {
312
+ if (existing) {
313
+ taggedValue_setValue(existing, value);
314
+ } else {
315
+ const tag = getTag(
316
+ this.editorStore.graphManagerState.graph.getProfile(
317
+ PURE_DATA_SPACE_INFO_PROFILE_PATH,
318
+ ),
319
+ PURE_DATA_SPACE_INFO_PROFILE_DEPRECATION_NOTICE_TAG,
320
+ );
321
+ annotatedElement_addTaggedValue(
322
+ this.dataSpace,
323
+ new TaggedValue(TagExplicitReference.create(tag), value),
324
+ );
325
+ }
326
+ } else if (existing) {
327
+ annotatedElement_deleteTaggedValue(this.dataSpace, existing);
328
+ }
329
+ }
330
+
331
+ get relatedDataSpaceTaggedValues(): TaggedValue[] {
332
+ return this.dataSpace.taggedValues.filter(
333
+ (taggedValue) =>
334
+ taggedValue.tag.ownerReference.value.path ===
335
+ PURE_DATA_SPACE_INFO_PROFILE_PATH &&
336
+ taggedValue.tag.value.value ===
337
+ PURE_DATA_SPACE_INFO_PROFILE_RELATED_DATA_SPACES_TAG,
338
+ );
339
+ }
340
+
341
+ get relatedDataSpaceRows(): RelatedDataSpaceRow[] {
342
+ return this.relatedDataSpaceTaggedValues.flatMap((taggedValue) => {
343
+ const segments = splitRelatedDataSpaceEntries(taggedValue.value);
344
+ if (segments.length === 0) {
345
+ return [
346
+ {
347
+ id: taggedValue._UUID,
348
+ label: taggedValue.value,
349
+ taggedValue,
350
+ entryIndex: 0,
351
+ isMultiEntry: false,
352
+ },
353
+ ];
354
+ }
355
+ const isMultiEntry = segments.length > 1;
356
+ return segments.map((segment, index) => ({
357
+ id: isMultiEntry ? `${taggedValue._UUID}-${index}` : taggedValue._UUID,
358
+ label: parseRelatedDataSpaceGAV(segment)?.name ?? segment,
359
+ taggedValue,
360
+ entryIndex: index,
361
+ isMultiEntry,
362
+ }));
363
+ });
364
+ }
365
+
366
+ getRelatedDataSpaceOptions(): {
367
+ label: string;
368
+ value: ResolvedDataSpaceEntityWithOrigin;
369
+ }[] {
370
+ const selfPath = this.dataSpace.path;
371
+ const addedPaths = new Set(
372
+ this.relatedDataSpaceTaggedValues.flatMap((taggedValue) =>
373
+ parseRelatedDataSpaceGAVs(taggedValue.value).map((entry) => entry.path),
374
+ ),
375
+ );
376
+ return this.availableRelatedDataSpaces
377
+ .filter(
378
+ (entity) =>
379
+ entity.origin !== undefined &&
380
+ entity.path !== selfPath &&
381
+ !addedPaths.has(entity.path),
382
+ )
383
+ .map((entity) => ({
384
+ label: entity.path,
385
+ value: entity,
386
+ }));
387
+ }
388
+
389
+ addRelatedDataSpace(entity: ResolvedDataSpaceEntityWithOrigin): void {
390
+ try {
391
+ const origin = guaranteeNonNullable(
392
+ entity.origin,
393
+ 'Related Data Space must have GAV coordinates',
394
+ );
395
+ const encoded = encodeRelatedDataSpaceGAV({
396
+ groupId: origin.groupId,
397
+ artifactId: origin.artifactId,
398
+ versionId: LATEST_VERSION_ALIAS,
399
+ path: entity.path,
400
+ });
401
+ const tag = getTag(
402
+ this.editorStore.graphManagerState.graph.getProfile(
403
+ PURE_DATA_SPACE_INFO_PROFILE_PATH,
404
+ ),
405
+ PURE_DATA_SPACE_INFO_PROFILE_RELATED_DATA_SPACES_TAG,
406
+ );
407
+ annotatedElement_addTaggedValue(
408
+ this.dataSpace,
409
+ new TaggedValue(TagExplicitReference.create(tag), encoded),
410
+ );
411
+ } catch (error) {
412
+ assertErrorThrown(error);
413
+ this.editorStore.applicationStore.notificationService.notifyWarning(
414
+ `Can't add related Data Space: ${error.message}`,
415
+ );
416
+ }
417
+ }
418
+
419
+ removeRelatedDataSpace(taggedValue: TaggedValue): void {
420
+ annotatedElement_deleteTaggedValue(this.dataSpace, taggedValue);
421
+ }
422
+
423
+ removeRelatedDataSpaceRow(row: RelatedDataSpaceRow): void {
424
+ if (!row.isMultiEntry) {
425
+ this.removeRelatedDataSpace(row.taggedValue);
426
+ return;
427
+ }
428
+ const remaining = splitRelatedDataSpaceEntries(
429
+ row.taggedValue.value,
430
+ ).filter((_, index) => index !== row.entryIndex);
431
+ this.removeRelatedDataSpace(row.taggedValue);
432
+ const tag = getTag(
433
+ this.editorStore.graphManagerState.graph.getProfile(
434
+ PURE_DATA_SPACE_INFO_PROFILE_PATH,
435
+ ),
436
+ PURE_DATA_SPACE_INFO_PROFILE_RELATED_DATA_SPACES_TAG,
437
+ );
438
+ remaining.forEach((segment) => {
439
+ annotatedElement_addTaggedValue(
440
+ this.dataSpace,
441
+ new TaggedValue(TagExplicitReference.create(tag), segment),
442
+ );
443
+ });
444
+ }
445
+
446
+ *loadRelatedDataSpaces(): GeneratorFn<void> {
447
+ this.loadRelatedDataSpacesState.inProgress();
448
+ try {
449
+ DataSpaceEditorState.relatedDataSpacesCache ??= (async () =>
450
+ (
451
+ (await this.editorStore.depotServerClient.getEntitiesSummaryByClassifier(
452
+ DATA_SPACE_ELEMENT_CLASSIFIER_PATH,
453
+ {
454
+ scope: DepotScope.RELEASES,
455
+ summary: true,
456
+ latest: true,
457
+ },
458
+ )) as unknown as StoredSummaryEntity[]
459
+ ).map((storedEntity) =>
460
+ extractDataSpaceInfoFromSummary(storedEntity),
461
+ ))();
462
+ this.availableRelatedDataSpaces =
463
+ (yield DataSpaceEditorState.relatedDataSpacesCache) as ResolvedDataSpaceEntityWithOrigin[];
464
+ this.loadRelatedDataSpacesState.pass();
465
+ } catch (error) {
466
+ assertErrorThrown(error);
467
+ DataSpaceEditorState.relatedDataSpacesCache = undefined;
468
+ this.editorStore.applicationStore.notificationService.notifyError(error);
469
+ this.loadRelatedDataSpacesState.fail();
470
+ }
471
+ }
472
+
154
473
  override reprocess(
155
474
  newElement: PackageableElement,
156
475
  editorStore: EditorStore,
@@ -17,6 +17,7 @@
17
17
  import {
18
18
  EditorExtensionState,
19
19
  queryClass,
20
+ EXTERNAL_APPLICATION_NAVIGATION__generateMarketplaceDataSpaceViewUrl,
20
21
  type EditorStore,
21
22
  } from '@finos/legend-application-studio';
22
23
  import {
@@ -145,6 +146,7 @@ export class DataSpacePreviewState extends EditorExtensionState {
145
146
  artifactId,
146
147
  versionId,
147
148
  analysisResult,
149
+ this.editorStore.depotServerClient,
148
150
  {
149
151
  retrieveGraphData: () =>
150
152
  new InMemoryGraphData(this.editorStore.graphManagerState.graph),
@@ -163,6 +165,23 @@ export class DataSpacePreviewState extends EditorExtensionState {
163
165
  'This feature is not supported in preview mode',
164
166
  );
165
167
  },
168
+ viewDataSpace: (gavPath: string): void => {
169
+ if (
170
+ this.editorStore.applicationStore.config.marketplaceApplicationUrl
171
+ ) {
172
+ this.editorStore.applicationStore.navigationService.navigator.visitAddress(
173
+ EXTERNAL_APPLICATION_NAVIGATION__generateMarketplaceDataSpaceViewUrl(
174
+ this.editorStore.applicationStore.config
175
+ .marketplaceApplicationUrl,
176
+ gavPath,
177
+ ),
178
+ );
179
+ } else {
180
+ this.editorStore.applicationStore.notificationService.notifyWarning(
181
+ 'Marketplace application URL is not configured',
182
+ );
183
+ }
184
+ },
166
185
  queryClass: (_class: Class): void => {
167
186
  queryClass(_class, this.editorStore).catch(
168
187
  this.editorStore.applicationStore.alertUnhandledError,
package/tsconfig.json CHANGED
@@ -75,6 +75,8 @@
75
75
  "./src/components/DataSpaceGeneralEditor/DataSpaceExecutablesSection.tsx",
76
76
  "./src/components/DataSpaceGeneralEditor/DataSpaceGeneralEditor.tsx",
77
77
  "./src/components/DataSpaceGeneralEditor/DataSpaceHomeTab.tsx",
78
+ "./src/components/DataSpaceGeneralEditor/DataSpaceInfoTab.tsx",
79
+ "./src/components/DataSpaceGeneralEditor/DataSpaceRelatedDataSpacesSection.tsx",
78
80
  "./src/components/DataSpaceGeneralEditor/DataSpaceSidebar.tsx",
79
81
  "./src/components/DataSpaceGeneralEditor/DataSpaceSupportInfoSection.tsx",
80
82
  "./src/components/DataSpaceGeneralEditor/DataSpaceValidation.tsx"