@finos/legend-extension-dsl-data-space-studio 0.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 (53) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +3 -0
  3. package/lib/__lib__/DSL_DataSpace_LegendStudioCodeSnippet.d.ts +17 -0
  4. package/lib/__lib__/DSL_DataSpace_LegendStudioCodeSnippet.d.ts.map +1 -0
  5. package/lib/__lib__/DSL_DataSpace_LegendStudioCodeSnippet.js +54 -0
  6. package/lib/__lib__/DSL_DataSpace_LegendStudioCodeSnippet.js.map +1 -0
  7. package/lib/__lib__/DSL_DataSpace_LegendStudioDocumentation.d.ts +21 -0
  8. package/lib/__lib__/DSL_DataSpace_LegendStudioDocumentation.d.ts.map +1 -0
  9. package/lib/__lib__/DSL_DataSpace_LegendStudioDocumentation.js +22 -0
  10. package/lib/__lib__/DSL_DataSpace_LegendStudioDocumentation.js.map +1 -0
  11. package/lib/components/DSL_DataSpace_LegendStudioApplicationPlugin.d.ts +39 -0
  12. package/lib/components/DSL_DataSpace_LegendStudioApplicationPlugin.d.ts.map +1 -0
  13. package/lib/components/DSL_DataSpace_LegendStudioApplicationPlugin.js +206 -0
  14. package/lib/components/DSL_DataSpace_LegendStudioApplicationPlugin.js.map +1 -0
  15. package/lib/components/DataSpacePreviewAction.d.ts +25 -0
  16. package/lib/components/DataSpacePreviewAction.d.ts.map +1 -0
  17. package/lib/components/DataSpacePreviewAction.js +53 -0
  18. package/lib/components/DataSpacePreviewAction.js.map +1 -0
  19. package/lib/components/DataSpaceQueryAction.d.ts +24 -0
  20. package/lib/components/DataSpaceQueryAction.d.ts.map +1 -0
  21. package/lib/components/DataSpaceQueryAction.js +52 -0
  22. package/lib/components/DataSpaceQueryAction.js.map +1 -0
  23. package/lib/components/DataSpaceTemplateQueryPromoteReview.d.ts +19 -0
  24. package/lib/components/DataSpaceTemplateQueryPromoteReview.d.ts.map +1 -0
  25. package/lib/components/DataSpaceTemplateQueryPromoteReview.js +81 -0
  26. package/lib/components/DataSpaceTemplateQueryPromoteReview.js.map +1 -0
  27. package/lib/index.css +17 -0
  28. package/lib/index.css.map +1 -0
  29. package/lib/index.d.ts +17 -0
  30. package/lib/index.d.ts.map +1 -0
  31. package/lib/index.js +17 -0
  32. package/lib/index.js.map +1 -0
  33. package/lib/package.json +75 -0
  34. package/lib/stores/DataSpacePreviewState.d.ts +33 -0
  35. package/lib/stores/DataSpacePreviewState.d.ts.map +1 -0
  36. package/lib/stores/DataSpacePreviewState.js +116 -0
  37. package/lib/stores/DataSpacePreviewState.js.map +1 -0
  38. package/lib/stores/DataSpaceTemplateQueryPromotionReviewerStore.d.ts +61 -0
  39. package/lib/stores/DataSpaceTemplateQueryPromotionReviewerStore.d.ts.map +1 -0
  40. package/lib/stores/DataSpaceTemplateQueryPromotionReviewerStore.js +406 -0
  41. package/lib/stores/DataSpaceTemplateQueryPromotionReviewerStore.js.map +1 -0
  42. package/package.json +75 -0
  43. package/src/__lib__/DSL_DataSpace_LegendStudioCodeSnippet.ts +54 -0
  44. package/src/__lib__/DSL_DataSpace_LegendStudioDocumentation.ts +21 -0
  45. package/src/components/DSL_DataSpace_LegendStudioApplicationPlugin.tsx +299 -0
  46. package/src/components/DataSpacePreviewAction.tsx +136 -0
  47. package/src/components/DataSpaceQueryAction.tsx +100 -0
  48. package/src/components/DataSpaceTemplateQueryPromoteReview.tsx +292 -0
  49. package/src/index.ts +17 -0
  50. package/src/stores/DataSpacePreviewState.ts +199 -0
  51. package/src/stores/DataSpaceTemplateQueryPromotionReviewerStore.ts +636 -0
  52. package/tsconfig.json +54 -0
  53. package/tsconfig.package.json +37 -0
@@ -0,0 +1,636 @@
1
+ /**
2
+ * Copyright (c) 2020-present, Goldman Sachs
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+
17
+ import {
18
+ type LightQuery,
19
+ type QueryInfo,
20
+ type RawLambda,
21
+ GraphManagerState,
22
+ } from '@finos/legend-graph';
23
+ import {
24
+ type DepotServerClient,
25
+ StoreProjectData,
26
+ ProjectDependencyCoordinates,
27
+ ProjectVersionEntities,
28
+ } from '@finos/legend-server-depot';
29
+ import {
30
+ ActionState,
31
+ assertErrorThrown,
32
+ guaranteeNonNullable,
33
+ LogEvent,
34
+ type GeneratorFn,
35
+ type PlainObject,
36
+ } from '@finos/legend-shared';
37
+ import { type Entity } from '@finos/legend-storage';
38
+ import {
39
+ type ProjectConfigurationStatus,
40
+ fetchProjectConfigurationStatus,
41
+ generateEditorRoute,
42
+ LEGEND_STUDIO_APP_EVENT,
43
+ type LegendStudioApplicationStore,
44
+ EditorStore,
45
+ generateReviewRoute,
46
+ } from '@finos/legend-application-studio';
47
+ import {
48
+ DEFAULT_TAB_SIZE,
49
+ ActionAlertType,
50
+ ActionAlertActionType,
51
+ } from '@finos/legend-application';
52
+ import {
53
+ makeObservable,
54
+ observable,
55
+ computed,
56
+ action,
57
+ flow,
58
+ flowResult,
59
+ } from 'mobx';
60
+ import {
61
+ type SDLCServerClient,
62
+ type ProjectDependency,
63
+ Project,
64
+ WorkspaceType,
65
+ Workspace,
66
+ ProjectConfiguration,
67
+ EntityChangeType,
68
+ } from '@finos/legend-server-sdlc';
69
+ import {
70
+ DATA_SPACE_ELEMENT_CLASSIFIER_PATH,
71
+ DSL_DataSpace_getGraphManagerExtension,
72
+ type DSL_DataSpace_PureGraphManagerExtension,
73
+ } from '@finos/legend-extension-dsl-data-space/graph';
74
+ import {
75
+ generateDataSpaceQuerySetupRoute,
76
+ generateDataSpaceTemplateQueryPromotionRoute,
77
+ } from '@finos/legend-extension-dsl-data-space/application';
78
+
79
+ const projectDependencyToProjectCoordinates = (
80
+ projectDependency: ProjectDependency,
81
+ ): ProjectDependencyCoordinates =>
82
+ new ProjectDependencyCoordinates(
83
+ guaranteeNonNullable(projectDependency.groupId),
84
+ guaranteeNonNullable(projectDependency.artifactId),
85
+ projectDependency.versionId,
86
+ );
87
+
88
+ const DEFAULT_WORKSPACE_NAME_PREFIX = 'promote-as-template-query';
89
+
90
+ export class DataSpaceTemplateQueryPromotionReviewerStore {
91
+ readonly applicationStore: LegendStudioApplicationStore;
92
+ readonly sdlcServerClient: SDLCServerClient;
93
+ readonly depotServerClient: DepotServerClient;
94
+ readonly graphManagerState: GraphManagerState;
95
+ readonly initState = ActionState.create();
96
+ readonly promoteState = ActionState.create();
97
+ readonly loadQueryState = ActionState.create();
98
+ readonly loadWorkspacesState = ActionState.create();
99
+ editorStore: EditorStore;
100
+ graphManagerExtension: DSL_DataSpace_PureGraphManagerExtension;
101
+ currentQuery?: LightQuery | undefined;
102
+ currentQueryInfo?: QueryInfo | undefined;
103
+ currentQueryProject?: StoreProjectData | undefined;
104
+ currentProject?: Project | undefined;
105
+ currentProjectConfiguration?: ProjectConfiguration;
106
+ currentProjectConfigurationStatus?: ProjectConfigurationStatus | undefined;
107
+ currentProjectEntities: Entity[] = [];
108
+ dependencyEntities: Entity[] = [];
109
+ groupWorkspaces: Workspace[] = [];
110
+ workspaceName = '';
111
+ dataSpacePath!: string;
112
+ dataSpaceEntity: Entity | undefined;
113
+ templateQueryId = 'template_id';
114
+ templateQueryTitle = 'template_title';
115
+ templateQueryDescription = '';
116
+
117
+ constructor(
118
+ applicationStore: LegendStudioApplicationStore,
119
+ sdlcServerClient: SDLCServerClient,
120
+ depotServerClient: DepotServerClient,
121
+ ) {
122
+ makeObservable(this, {
123
+ editorStore: observable,
124
+ graphManagerExtension: observable,
125
+ currentQuery: observable,
126
+ currentQueryInfo: observable,
127
+ currentQueryProject: observable,
128
+ currentProject: observable,
129
+ currentProjectConfiguration: observable,
130
+ currentProjectConfigurationStatus: observable,
131
+ currentProjectEntities: observable,
132
+ dataSpaceEntity: observable,
133
+ groupWorkspaces: observable,
134
+ workspaceName: observable,
135
+ templateQueryId: observable,
136
+ templateQueryTitle: observable,
137
+ templateQueryDescription: observable,
138
+ isWorkspaceNameValid: computed,
139
+ isTemplateQueryIdValid: computed,
140
+ setWorkspaceName: action,
141
+ setTemplateQueryId: action,
142
+ setTemplateQueryTitle: action,
143
+ setTemplateQueryDescription: action,
144
+ initialize: flow,
145
+ loadQuery: flow,
146
+ loadProject: flow,
147
+ promoteAsTemplateQuery: flow,
148
+ });
149
+
150
+ this.applicationStore = applicationStore;
151
+ this.sdlcServerClient = sdlcServerClient;
152
+ this.depotServerClient = depotServerClient;
153
+ this.graphManagerState = new GraphManagerState(
154
+ applicationStore.pluginManager,
155
+ applicationStore.logService,
156
+ );
157
+ this.editorStore = new EditorStore(
158
+ applicationStore,
159
+ sdlcServerClient,
160
+ depotServerClient,
161
+ );
162
+ this.graphManagerExtension = DSL_DataSpace_getGraphManagerExtension(
163
+ this.editorStore.graphManagerState.graphManager,
164
+ );
165
+ }
166
+
167
+ setWorkspaceName(val: string): void {
168
+ this.workspaceName = val;
169
+ }
170
+
171
+ setTemplateQueryId(val: string): void {
172
+ this.templateQueryId = val;
173
+ }
174
+
175
+ setTemplateQueryTitle(val: string): void {
176
+ this.templateQueryTitle = val;
177
+ }
178
+
179
+ setTemplateQueryDescription(val: string): void {
180
+ this.templateQueryDescription = val;
181
+ }
182
+
183
+ get isWorkspaceNameValid(): boolean {
184
+ return !this.groupWorkspaces.some(
185
+ (ws) => ws.workspaceId === this.workspaceName,
186
+ );
187
+ }
188
+
189
+ get isTemplateQueryIdValid(): boolean {
190
+ if (this.dataSpaceEntity) {
191
+ return this.graphManagerExtension.IsTemplateQueryIdValid(
192
+ this.dataSpaceEntity,
193
+ this.templateQueryId,
194
+ );
195
+ }
196
+ return false;
197
+ }
198
+
199
+ *initialize(
200
+ queryId: string | undefined,
201
+ dataSpacePath: string,
202
+ ): GeneratorFn<void> {
203
+ if (!this.initState.isInInitialState) {
204
+ return;
205
+ }
206
+ try {
207
+ this.initState.inProgress();
208
+ yield this.graphManagerState.graphManager.initialize(
209
+ {
210
+ env: this.applicationStore.config.env,
211
+ tabSize: DEFAULT_TAB_SIZE,
212
+ clientConfig: {
213
+ baseUrl: this.applicationStore.config.engineServerUrl,
214
+ queryBaseUrl: this.applicationStore.config.engineQueryServerUrl,
215
+ enableCompression: true,
216
+ },
217
+ },
218
+ {
219
+ tracerService: this.applicationStore.tracerService,
220
+ },
221
+ );
222
+ this.dataSpacePath = dataSpacePath;
223
+ if (queryId) {
224
+ let query: LightQuery | undefined;
225
+ try {
226
+ query = (yield this.graphManagerState.graphManager.getLightQuery(
227
+ queryId,
228
+ )) as LightQuery;
229
+ } catch {
230
+ query = undefined;
231
+ }
232
+ if (query) {
233
+ yield flowResult(this.loadQuery(query));
234
+ } else {
235
+ this.applicationStore.navigationService.navigator.updateCurrentLocation(
236
+ generateDataSpaceQuerySetupRoute(),
237
+ );
238
+ }
239
+ }
240
+ if (this.currentQuery) {
241
+ this.currentQueryProject = StoreProjectData.serialization.fromJson(
242
+ (yield this.depotServerClient.getProject(
243
+ this.currentQuery.groupId,
244
+ this.currentQuery.artifactId,
245
+ )) as PlainObject<StoreProjectData>,
246
+ );
247
+ const projectData = (yield Promise.all([
248
+ this.depotServerClient.getVersionEntities(
249
+ this.currentQuery.groupId,
250
+ this.currentQuery.artifactId,
251
+ this.currentQuery.versionId,
252
+ ),
253
+ this.sdlcServerClient.getConfiguration(
254
+ this.currentQueryProject.projectId,
255
+ undefined,
256
+ ),
257
+ ])) as [Entity[], PlainObject<ProjectConfiguration>];
258
+
259
+ const [currentProjectEntities, currentProjectConfiguration] = [
260
+ projectData[0],
261
+ ProjectConfiguration.serialization.fromJson(projectData[1]),
262
+ ];
263
+ this.currentProjectConfiguration = currentProjectConfiguration;
264
+ const dependencyEntities = (
265
+ (yield this.depotServerClient.collectDependencyEntities(
266
+ (
267
+ [
268
+ ...currentProjectConfiguration.projectDependencies,
269
+ ] as ProjectDependency[]
270
+ )
271
+ .map(projectDependencyToProjectCoordinates)
272
+ .map((p) => ProjectDependencyCoordinates.serialization.toJson(p)),
273
+ true,
274
+ true,
275
+ )) as PlainObject<ProjectVersionEntities>[]
276
+ )
277
+ .map((p) => ProjectVersionEntities.serialization.fromJson(p))
278
+ .flatMap((info) => info.entities);
279
+ this.dependencyEntities = dependencyEntities;
280
+ this.currentProjectEntities = currentProjectEntities;
281
+ this.dataSpaceEntity = guaranteeNonNullable(
282
+ currentProjectEntities.filter(
283
+ (entity: Entity) =>
284
+ entity.path === dataSpacePath &&
285
+ entity.classifierPath === DATA_SPACE_ELEMENT_CLASSIFIER_PATH,
286
+ )[0],
287
+ `Can't find dataSpace entity with path ${this.dataSpaceEntity}`,
288
+ );
289
+ this.initState.pass();
290
+ }
291
+ } catch (error) {
292
+ assertErrorThrown(error);
293
+ this.applicationStore.logService.error(
294
+ LogEvent.create(LEGEND_STUDIO_APP_EVENT.GENERIC_FAILURE),
295
+ error,
296
+ );
297
+ this.applicationStore.alertService.setBlockingAlert({
298
+ message: `Can't initialize template query promotion reviewer store`,
299
+ });
300
+ this.initState.fail();
301
+ }
302
+ }
303
+
304
+ *loadQuery(query: LightQuery): GeneratorFn<void> {
305
+ this.currentQuery = query;
306
+ this.templateQueryTitle = query.name;
307
+
308
+ try {
309
+ this.loadQueryState.inProgress();
310
+ this.currentQueryInfo =
311
+ (yield this.graphManagerState.graphManager.getQueryInfo(
312
+ query.id,
313
+ )) as QueryInfo;
314
+ this.currentQueryProject = StoreProjectData.serialization.fromJson(
315
+ (yield this.depotServerClient.getProject(
316
+ this.currentQuery.groupId,
317
+ this.currentQuery.artifactId,
318
+ )) as PlainObject<StoreProjectData>,
319
+ );
320
+ this.setWorkspaceName(`${DEFAULT_WORKSPACE_NAME_PREFIX}-${query.name}`);
321
+ this.applicationStore.navigationService.navigator.updateCurrentLocation(
322
+ generateDataSpaceTemplateQueryPromotionRoute(
323
+ this.currentQuery.groupId,
324
+ this.currentQuery.artifactId,
325
+ this.currentQuery.versionId,
326
+ this.dataSpacePath,
327
+ query.id,
328
+ ),
329
+ );
330
+ const currentProject = Project.serialization.fromJson(
331
+ (yield this.sdlcServerClient.getProject(
332
+ this.currentQueryProject.projectId,
333
+ )) as PlainObject<Project>,
334
+ );
335
+ yield flowResult(this.loadProject(currentProject));
336
+ } catch (error) {
337
+ assertErrorThrown(error);
338
+ this.applicationStore.notificationService.notifyError(error);
339
+ } finally {
340
+ this.loadQueryState.complete();
341
+ }
342
+ }
343
+
344
+ *loadProject(project: Project): GeneratorFn<void> {
345
+ this.currentProject = project;
346
+ this.currentProjectConfigurationStatus = undefined;
347
+ this.loadWorkspacesState.inProgress();
348
+ try {
349
+ this.currentProjectConfigurationStatus =
350
+ (yield fetchProjectConfigurationStatus(
351
+ project.projectId,
352
+ undefined,
353
+ this.applicationStore,
354
+ this.sdlcServerClient,
355
+ )) as ProjectConfigurationStatus;
356
+ this.groupWorkspaces = (
357
+ (yield this.sdlcServerClient.getGroupWorkspaces(
358
+ project.projectId,
359
+ )) as PlainObject<Workspace>[]
360
+ )
361
+ .map((v) => Workspace.serialization.fromJson(v))
362
+ .filter((workspace) => workspace.workspaceType === WorkspaceType.GROUP);
363
+ this.loadWorkspacesState.pass();
364
+ } catch (error) {
365
+ assertErrorThrown(error);
366
+ this.applicationStore.logService.error(
367
+ LogEvent.create(LEGEND_STUDIO_APP_EVENT.SDLC_MANAGER_FAILURE),
368
+ error,
369
+ );
370
+ this.applicationStore.notificationService.notifyError(error);
371
+ this.loadWorkspacesState.fail();
372
+ }
373
+ }
374
+
375
+ *promoteAsTemplateQuery(): GeneratorFn<void> {
376
+ const query = this.currentQuery;
377
+ const project = this.currentProject;
378
+ if (
379
+ this.promoteState.isInProgress ||
380
+ !query ||
381
+ !this.currentQueryInfo ||
382
+ !this.currentProjectConfiguration ||
383
+ !project ||
384
+ !this.workspaceName ||
385
+ !this.templateQueryTitle ||
386
+ !this.dataSpaceEntity ||
387
+ !this.isWorkspaceNameValid ||
388
+ !this.isTemplateQueryIdValid
389
+ ) {
390
+ return;
391
+ }
392
+
393
+ try {
394
+ this.promoteState.inProgress();
395
+ // 1. prepare project entities
396
+ this.applicationStore.alertService.setBlockingAlert({
397
+ message: `Fetching and updating project...`,
398
+ prompt: 'Please do not close the application',
399
+ showLoading: true,
400
+ });
401
+
402
+ // update datasapce entity
403
+ const updatedDataSpaceEntity =
404
+ (yield this.graphManagerExtension.addNewExecutableToDataSpaceEntity(
405
+ this.dataSpaceEntity,
406
+ {
407
+ id: this.templateQueryId,
408
+ title: this.templateQueryTitle,
409
+ mapping: guaranteeNonNullable(this.currentQueryInfo).mapping,
410
+ runtime: guaranteeNonNullable(this.currentQueryInfo).runtime,
411
+ query: (yield this.graphManagerState.graphManager.pureCodeToLambda(
412
+ this.currentQueryInfo.content,
413
+ )) as RawLambda,
414
+ description: this.templateQueryDescription,
415
+ },
416
+ )) as Entity;
417
+ guaranteeNonNullable(
418
+ this.currentProjectEntities.filter(
419
+ (entity: Entity) =>
420
+ entity.path === this.dataSpacePath &&
421
+ entity.classifierPath === DATA_SPACE_ELEMENT_CLASSIFIER_PATH,
422
+ )[0],
423
+ ).content = updatedDataSpaceEntity.content;
424
+
425
+ // 2. check if the graph compiles properly
426
+ this.applicationStore.alertService.setBlockingAlert({
427
+ message: `Checking workspace compilation status...`,
428
+ prompt: 'Please do not close the application',
429
+ showLoading: true,
430
+ });
431
+ let compilationFailed = false;
432
+ try {
433
+ yield this.graphManagerState.graphManager.compileEntities([
434
+ ...this.dependencyEntities,
435
+ ...this.currentProjectEntities,
436
+ ]);
437
+ } catch {
438
+ compilationFailed = true;
439
+ }
440
+
441
+ // 3. proceed to setup the workspace
442
+ const setupWorkspace = async (): Promise<void> => {
443
+ let workspace: Workspace | undefined;
444
+ try {
445
+ this.applicationStore.alertService.setBlockingAlert({
446
+ message: `Creating workspace...`,
447
+ prompt: 'Please do not close the application',
448
+ showLoading: true,
449
+ });
450
+
451
+ // i. create workspace
452
+ workspace = Workspace.serialization.fromJson(
453
+ await this.sdlcServerClient.createWorkspace(
454
+ project.projectId,
455
+ undefined,
456
+ this.workspaceName,
457
+ WorkspaceType.GROUP,
458
+ ),
459
+ );
460
+
461
+ // ii. update dataspace
462
+ this.applicationStore.alertService.setBlockingAlert({
463
+ message: `Generating code commit...`,
464
+ prompt: 'Please do not close the application',
465
+ showLoading: true,
466
+ });
467
+ await this.sdlcServerClient.performEntityChanges(
468
+ project.projectId,
469
+ workspace,
470
+ {
471
+ message:
472
+ 'promote-as-template-query: promote query as a template query to dataspace',
473
+ entityChanges: [
474
+ {
475
+ classifierPath: updatedDataSpaceEntity.classifierPath,
476
+ entityPath: updatedDataSpaceEntity.path,
477
+ content: updatedDataSpaceEntity.content,
478
+ type: EntityChangeType.MODIFY,
479
+ },
480
+ ],
481
+ },
482
+ );
483
+
484
+ // iii create review
485
+ this.applicationStore.alertService.setBlockingAlert({
486
+ message: `Generating code review...`,
487
+ prompt: 'Please do not close the application',
488
+ showLoading: true,
489
+ });
490
+ await flowResult(
491
+ this.editorStore.initialize(
492
+ project.projectId,
493
+ undefined,
494
+ workspace.workspaceId,
495
+ workspace.workspaceType,
496
+ ),
497
+ );
498
+ const workspaceReviewState = this.editorStore.workspaceReviewState;
499
+ const workspaceContainsSnapshotDependencies =
500
+ this.editorStore.projectConfigurationEditorState
501
+ .containsSnapshotDependencies;
502
+ const isCreateReviewDisabled =
503
+ Boolean(workspaceReviewState.workspaceReview) ||
504
+ workspaceContainsSnapshotDependencies ||
505
+ !workspaceReviewState.canCreateReview ||
506
+ workspaceReviewState.sdlcState.isActiveProjectSandbox;
507
+ workspaceReviewState.reviewTitle =
508
+ 'code review - promote query as a template query to dataspace';
509
+ if (!isCreateReviewDisabled) {
510
+ await flowResult(
511
+ workspaceReviewState.createWorkspaceReview(
512
+ workspaceReviewState.reviewTitle,
513
+ ),
514
+ );
515
+ } else {
516
+ this.applicationStore.notificationService.notifyError(
517
+ `Can't create code review`,
518
+ );
519
+ }
520
+
521
+ // iv. complete, redirect user to the service query editor screen
522
+ this.applicationStore.alertService.setBlockingAlert(undefined);
523
+ this.promoteState.pass();
524
+ this.applicationStore.alertService.setActionAlertInfo({
525
+ message: `Successfully promoted query into dataspace '${this.dataSpacePath}'. Now your template query can be found in workspace '${this.workspaceName}' of project '${project.name}' (${project.projectId})`,
526
+ prompt: compilationFailed
527
+ ? `The workspace might not compile at the moment, please make sure to fix the issue and submit a review to make the dataspace part of the project to complete template query promotion`
528
+ : `Please make sure to get the generated code-review reviewed and approved`,
529
+ type: ActionAlertType.STANDARD,
530
+ actions: compilationFailed
531
+ ? [
532
+ {
533
+ label: 'Open Workspace',
534
+ type: ActionAlertActionType.PROCEED,
535
+ handler: (): void => {
536
+ this.applicationStore.navigationService.navigator.goToLocation(
537
+ generateEditorRoute(
538
+ project.projectId,
539
+ undefined,
540
+ this.workspaceName,
541
+ WorkspaceType.GROUP,
542
+ ),
543
+ );
544
+ },
545
+ default: true,
546
+ },
547
+ ]
548
+ : [
549
+ {
550
+ label: 'Open Code Review',
551
+ type: ActionAlertActionType.PROCEED,
552
+ handler: (): void => {
553
+ if (workspaceReviewState.workspaceReview) {
554
+ this.applicationStore.navigationService.navigator.visitAddress(
555
+ this.applicationStore.navigationService.navigator.generateAddress(
556
+ generateReviewRoute(
557
+ workspaceReviewState.workspaceReview.projectId,
558
+ workspaceReviewState.workspaceReview.id,
559
+ ),
560
+ ),
561
+ );
562
+ }
563
+ },
564
+ default: true,
565
+ },
566
+ {
567
+ label: 'Open Workspace',
568
+ type: ActionAlertActionType.PROCEED,
569
+ handler: (): void => {
570
+ this.applicationStore.navigationService.navigator.goToLocation(
571
+ generateEditorRoute(
572
+ project.projectId,
573
+ undefined,
574
+ this.workspaceName,
575
+ WorkspaceType.GROUP,
576
+ ),
577
+ );
578
+ },
579
+ },
580
+ ],
581
+ });
582
+ } catch (error) {
583
+ assertErrorThrown(error);
584
+ this.applicationStore.alertService.setBlockingAlert(undefined);
585
+ this.applicationStore.notificationService.notifyError(
586
+ `Can't set up workspace: ${error.message}`,
587
+ );
588
+ if (workspace) {
589
+ await this.sdlcServerClient.deleteWorkspace(
590
+ project.projectId,
591
+ workspace,
592
+ );
593
+ }
594
+ this.promoteState.fail();
595
+ }
596
+ };
597
+
598
+ this.applicationStore.alertService.setBlockingAlert(undefined);
599
+ if (compilationFailed) {
600
+ this.applicationStore.alertService.setActionAlertInfo({
601
+ message: `We have found compilation issues with the workspace. Your query can still be promoted, but you would need to fix compilation issues afterwards`,
602
+ prompt: `Do you still want to proceed to promote the query as a template query?`,
603
+ type: ActionAlertType.STANDARD,
604
+ actions: [
605
+ {
606
+ label: `Proceed`,
607
+ type: ActionAlertActionType.PROCEED_WITH_CAUTION,
608
+ handler: (): void => {
609
+ setupWorkspace().catch(
610
+ this.applicationStore.alertUnhandledError,
611
+ );
612
+ },
613
+ },
614
+ {
615
+ label: 'Abort',
616
+ type: ActionAlertActionType.PROCEED,
617
+ handler: (): void => {
618
+ this.promoteState.fail();
619
+ },
620
+ default: true,
621
+ },
622
+ ],
623
+ });
624
+ } else {
625
+ yield setupWorkspace();
626
+ }
627
+
628
+ this.promoteState.pass();
629
+ } catch (error) {
630
+ assertErrorThrown(error);
631
+ this.applicationStore.alertService.setBlockingAlert(undefined);
632
+ this.applicationStore.notificationService.notifyError(error);
633
+ this.promoteState.fail();
634
+ }
635
+ }
636
+ }
package/tsconfig.json ADDED
@@ -0,0 +1,54 @@
1
+ {
2
+ "compilerOptions": {
3
+ "lib": [
4
+ "dom",
5
+ "dom.iterable",
6
+ "esnext",
7
+ "webworker",
8
+ "scripthost"
9
+ ],
10
+ "composite": true,
11
+ "declaration": true,
12
+ "declarationMap": true,
13
+ "sourceMap": true,
14
+ "target": "esnext",
15
+ "module": "nodenext",
16
+ "skipLibCheck": true,
17
+ "resolveJsonModule": true,
18
+ "verbatimModuleSyntax": true,
19
+ "strict": true,
20
+ "noImplicitOverride": true,
21
+ "noUncheckedIndexedAccess": true,
22
+ "exactOptionalPropertyTypes": true,
23
+ "forceConsistentCasingInFileNames": true,
24
+ "outDir": "./lib",
25
+ "tsBuildInfoFile": "./build/prod.tsbuildinfo",
26
+ "rootDir": "./src",
27
+ "jsx": "react-jsx"
28
+ },
29
+ "references": [
30
+ {
31
+ "path": "./tsconfig.package.json"
32
+ }
33
+ ],
34
+ "files": [
35
+ "./src/index.ts",
36
+ "./src/__lib__/DSL_DataSpace_LegendStudioCodeSnippet.ts",
37
+ "./src/__lib__/DSL_DataSpace_LegendStudioDocumentation.ts",
38
+ "./src/stores/DataSpacePreviewState.ts",
39
+ "./src/stores/DataSpaceTemplateQueryPromotionReviewerStore.ts",
40
+ "./src/components/DSL_DataSpace_LegendStudioApplicationPlugin.tsx",
41
+ "./src/components/DataSpacePreviewAction.tsx",
42
+ "./src/components/DataSpaceQueryAction.tsx",
43
+ "./src/components/DataSpaceTemplateQueryPromoteReview.tsx"
44
+ ],
45
+ "include": [
46
+ "src/**/*.ts",
47
+ "src/**/*.tsx",
48
+ "src/**/*.json"
49
+ ],
50
+ "exclude": [
51
+ "src/**/__tests__/**/*.*",
52
+ "src/**/__mocks__/**/*.*"
53
+ ]
54
+ }