@finos/legend-extension-dsl-service 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.
- package/LICENSE +201 -0
- package/README.md +3 -0
- package/lib/components/studio/DSL_Service_LegendStudioApplicationPlugin.d.ts +22 -0
- package/lib/components/studio/DSL_Service_LegendStudioApplicationPlugin.d.ts.map +1 -0
- package/lib/components/studio/DSL_Service_LegendStudioApplicationPlugin.js +59 -0
- package/lib/components/studio/DSL_Service_LegendStudioApplicationPlugin.js.map +1 -0
- package/lib/components/studio/ServiceQueryEditor.d.ts +25 -0
- package/lib/components/studio/ServiceQueryEditor.d.ts.map +1 -0
- package/lib/components/studio/ServiceQueryEditor.js +190 -0
- package/lib/components/studio/ServiceQueryEditor.js.map +1 -0
- package/lib/components/studio/ServiceQueryEditorReviewAction.d.ts +19 -0
- package/lib/components/studio/ServiceQueryEditorReviewAction.d.ts.map +1 -0
- package/lib/components/studio/ServiceQueryEditorReviewAction.js +71 -0
- package/lib/components/studio/ServiceQueryEditorReviewAction.js.map +1 -0
- package/lib/components/studio/ServiceQueryEditorStoreProvider.d.ts +31 -0
- package/lib/components/studio/ServiceQueryEditorStoreProvider.d.ts.map +1 -0
- package/lib/components/studio/ServiceQueryEditorStoreProvider.js +40 -0
- package/lib/components/studio/ServiceQueryEditorStoreProvider.js.map +1 -0
- package/lib/components/studio/ServiceQueryEditorWorkspaceStatus.d.ts +19 -0
- package/lib/components/studio/ServiceQueryEditorWorkspaceStatus.d.ts.map +1 -0
- package/lib/components/studio/ServiceQueryEditorWorkspaceStatus.js +69 -0
- package/lib/components/studio/ServiceQueryEditorWorkspaceStatus.js.map +1 -0
- package/lib/components/studio/UpdateProjectServiceQuerySetup.d.ts +18 -0
- package/lib/components/studio/UpdateProjectServiceQuerySetup.d.ts.map +1 -0
- package/lib/components/studio/UpdateProjectServiceQuerySetup.js +182 -0
- package/lib/components/studio/UpdateProjectServiceQuerySetup.js.map +1 -0
- package/lib/components/studio/UpdateServiceQuerySetup.d.ts +18 -0
- package/lib/components/studio/UpdateServiceQuerySetup.d.ts.map +1 -0
- package/lib/components/studio/UpdateServiceQuerySetup.js +172 -0
- package/lib/components/studio/UpdateServiceQuerySetup.js.map +1 -0
- package/lib/index.css +17 -0
- package/lib/index.css.map +1 -0
- package/lib/index.d.ts +17 -0
- package/lib/index.d.ts.map +1 -0
- package/lib/index.js +17 -0
- package/lib/index.js.map +1 -0
- package/lib/package.json +84 -0
- package/lib/stores/studio/DSL_Service_LegendStudioRouter.d.ts +53 -0
- package/lib/stores/studio/DSL_Service_LegendStudioRouter.d.ts.map +1 -0
- package/lib/stores/studio/DSL_Service_LegendStudioRouter.js +62 -0
- package/lib/stores/studio/DSL_Service_LegendStudioRouter.js.map +1 -0
- package/lib/stores/studio/ServiceQueryEditorStore.d.ts +64 -0
- package/lib/stores/studio/ServiceQueryEditorStore.d.ts.map +1 -0
- package/lib/stores/studio/ServiceQueryEditorStore.js +260 -0
- package/lib/stores/studio/ServiceQueryEditorStore.js.map +1 -0
- package/lib/stores/studio/UpdateProjectServiceQuerySetupStore.d.ts +46 -0
- package/lib/stores/studio/UpdateProjectServiceQuerySetupStore.d.ts.map +1 -0
- package/lib/stores/studio/UpdateProjectServiceQuerySetupStore.js +184 -0
- package/lib/stores/studio/UpdateProjectServiceQuerySetupStore.js.map +1 -0
- package/lib/stores/studio/UpdateServiceQuerySetupStore.d.ts +48 -0
- package/lib/stores/studio/UpdateServiceQuerySetupStore.d.ts.map +1 -0
- package/lib/stores/studio/UpdateServiceQuerySetupStore.js +184 -0
- package/lib/stores/studio/UpdateServiceQuerySetupStore.js.map +1 -0
- package/package.json +84 -0
- package/src/components/studio/DSL_Service_LegendStudioApplicationPlugin.tsx +71 -0
- package/src/components/studio/ServiceQueryEditor.tsx +551 -0
- package/src/components/studio/ServiceQueryEditorReviewAction.tsx +172 -0
- package/src/components/studio/ServiceQueryEditorStoreProvider.tsx +89 -0
- package/src/components/studio/ServiceQueryEditorWorkspaceStatus.tsx +121 -0
- package/src/components/studio/UpdateProjectServiceQuerySetup.tsx +479 -0
- package/src/components/studio/UpdateServiceQuerySetup.tsx +476 -0
- package/src/index.ts +17 -0
- package/src/stores/studio/DSL_Service_LegendStudioRouter.ts +159 -0
- package/src/stores/studio/ServiceQueryEditorStore.ts +487 -0
- package/src/stores/studio/UpdateProjectServiceQuerySetupStore.ts +281 -0
- package/src/stores/studio/UpdateServiceQuerySetupStore.ts +314 -0
- package/tsconfig.json +58 -0
- package/tsconfig.package.json +38 -0
|
@@ -0,0 +1,281 @@
|
|
|
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 { observable, makeObservable, flowResult, flow, action } from 'mobx';
|
|
18
|
+
import {
|
|
19
|
+
type GeneratorFn,
|
|
20
|
+
type PlainObject,
|
|
21
|
+
ActionState,
|
|
22
|
+
assertErrorThrown,
|
|
23
|
+
guaranteeNonNullable,
|
|
24
|
+
LogEvent,
|
|
25
|
+
} from '@finos/legend-shared';
|
|
26
|
+
import {
|
|
27
|
+
type SDLCServerClient,
|
|
28
|
+
Workspace,
|
|
29
|
+
WorkspaceType,
|
|
30
|
+
Project,
|
|
31
|
+
} from '@finos/legend-server-sdlc';
|
|
32
|
+
import {
|
|
33
|
+
type LegendStudioApplicationStore,
|
|
34
|
+
LEGEND_STUDIO_APP_EVENT,
|
|
35
|
+
} from '@finos/legend-application-studio';
|
|
36
|
+
import { generateProjectServiceQueryUpdaterSetupRoute } from './DSL_Service_LegendStudioRouter.js';
|
|
37
|
+
import { CORE_PURE_PATH } from '@finos/legend-graph';
|
|
38
|
+
import type { Entity } from '@finos/legend-storage';
|
|
39
|
+
|
|
40
|
+
const MINIMUM_PROJECT_LOADER_SEARCH_LENGTH = 3;
|
|
41
|
+
const DEFAULT_PROJECT_LOADER_LIMIT = 10;
|
|
42
|
+
|
|
43
|
+
export class UpdateProjectServiceQuerySetupStore {
|
|
44
|
+
applicationStore: LegendStudioApplicationStore;
|
|
45
|
+
sdlcServerClient: SDLCServerClient;
|
|
46
|
+
|
|
47
|
+
initState = ActionState.create();
|
|
48
|
+
loadProjectsState = ActionState.create();
|
|
49
|
+
projects: Project[] = [];
|
|
50
|
+
currentProject?: Project | undefined;
|
|
51
|
+
|
|
52
|
+
loadWorkspacesState = ActionState.create();
|
|
53
|
+
createWorkspaceState = ActionState.create();
|
|
54
|
+
groupWorkspaces: Workspace[] = [];
|
|
55
|
+
currentGroupWorkspace?: Workspace | undefined;
|
|
56
|
+
showCreateWorkspaceModal = false;
|
|
57
|
+
|
|
58
|
+
services: Entity[] = [];
|
|
59
|
+
currentService?: Entity | undefined;
|
|
60
|
+
|
|
61
|
+
constructor(
|
|
62
|
+
applicationStore: LegendStudioApplicationStore,
|
|
63
|
+
sdlcServerClient: SDLCServerClient,
|
|
64
|
+
) {
|
|
65
|
+
makeObservable(this, {
|
|
66
|
+
projects: observable,
|
|
67
|
+
currentProject: observable,
|
|
68
|
+
groupWorkspaces: observable,
|
|
69
|
+
currentGroupWorkspace: observable,
|
|
70
|
+
showCreateWorkspaceModal: observable,
|
|
71
|
+
services: observable,
|
|
72
|
+
currentService: observable,
|
|
73
|
+
setShowCreateWorkspaceModal: action,
|
|
74
|
+
resetCurrentProject: action,
|
|
75
|
+
resetCurrentGroupWorkspace: action,
|
|
76
|
+
resetCurrentService: action,
|
|
77
|
+
changeService: action,
|
|
78
|
+
initialize: flow,
|
|
79
|
+
loadProjects: flow,
|
|
80
|
+
changeProject: flow,
|
|
81
|
+
changeWorkspace: flow,
|
|
82
|
+
createWorkspace: flow,
|
|
83
|
+
});
|
|
84
|
+
|
|
85
|
+
this.applicationStore = applicationStore;
|
|
86
|
+
this.sdlcServerClient = sdlcServerClient;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
setShowCreateWorkspaceModal(val: boolean): void {
|
|
90
|
+
this.showCreateWorkspaceModal = val;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
resetCurrentProject(): void {
|
|
94
|
+
this.currentProject = undefined;
|
|
95
|
+
this.groupWorkspaces = [];
|
|
96
|
+
this.resetCurrentGroupWorkspace();
|
|
97
|
+
this.applicationStore.navigator.goTo(
|
|
98
|
+
generateProjectServiceQueryUpdaterSetupRoute(undefined),
|
|
99
|
+
);
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
resetCurrentGroupWorkspace(): void {
|
|
103
|
+
this.currentGroupWorkspace = undefined;
|
|
104
|
+
this.services = [];
|
|
105
|
+
this.resetCurrentService();
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
resetCurrentService(): void {
|
|
109
|
+
this.currentService = undefined;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
*initialize(projectId: string | undefined): GeneratorFn<void> {
|
|
113
|
+
if (!this.initState.isInInitialState) {
|
|
114
|
+
return;
|
|
115
|
+
}
|
|
116
|
+
this.initState.inProgress();
|
|
117
|
+
|
|
118
|
+
try {
|
|
119
|
+
if (projectId) {
|
|
120
|
+
let project: Project;
|
|
121
|
+
try {
|
|
122
|
+
project = Project.serialization.fromJson(
|
|
123
|
+
(yield this.sdlcServerClient.getProject(
|
|
124
|
+
projectId,
|
|
125
|
+
)) as PlainObject<Project>,
|
|
126
|
+
);
|
|
127
|
+
} catch {
|
|
128
|
+
this.applicationStore.navigator.goTo(
|
|
129
|
+
generateProjectServiceQueryUpdaterSetupRoute(undefined),
|
|
130
|
+
);
|
|
131
|
+
this.initState.pass();
|
|
132
|
+
return;
|
|
133
|
+
}
|
|
134
|
+
yield flowResult(this.changeProject(project));
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
this.initState.pass();
|
|
138
|
+
} catch (error) {
|
|
139
|
+
assertErrorThrown(error);
|
|
140
|
+
this.applicationStore.log.error(
|
|
141
|
+
LogEvent.create(LEGEND_STUDIO_APP_EVENT.SDLC_MANAGER_FAILURE),
|
|
142
|
+
error,
|
|
143
|
+
);
|
|
144
|
+
this.applicationStore.notifyError(error);
|
|
145
|
+
this.initState.fail();
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
*loadProjects(searchText: string): GeneratorFn<void> {
|
|
150
|
+
const isValidSearchString =
|
|
151
|
+
searchText.length >= MINIMUM_PROJECT_LOADER_SEARCH_LENGTH;
|
|
152
|
+
this.loadProjectsState.inProgress();
|
|
153
|
+
try {
|
|
154
|
+
this.projects = (
|
|
155
|
+
(yield this.sdlcServerClient.getProjects(
|
|
156
|
+
undefined,
|
|
157
|
+
isValidSearchString ? searchText : undefined,
|
|
158
|
+
undefined,
|
|
159
|
+
DEFAULT_PROJECT_LOADER_LIMIT,
|
|
160
|
+
)) as PlainObject<Project>[]
|
|
161
|
+
).map((v) => Project.serialization.fromJson(v));
|
|
162
|
+
this.loadProjectsState.pass();
|
|
163
|
+
} catch (error) {
|
|
164
|
+
assertErrorThrown(error);
|
|
165
|
+
this.applicationStore.notifyError(error);
|
|
166
|
+
this.loadProjectsState.fail();
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
*changeProject(project: Project): GeneratorFn<void> {
|
|
171
|
+
this.currentProject = project;
|
|
172
|
+
this.applicationStore.navigator.goTo(
|
|
173
|
+
generateProjectServiceQueryUpdaterSetupRoute(project.projectId),
|
|
174
|
+
);
|
|
175
|
+
|
|
176
|
+
this.loadWorkspacesState.inProgress();
|
|
177
|
+
try {
|
|
178
|
+
const workspacesInConflictResolutionIds = (
|
|
179
|
+
(yield this.sdlcServerClient.getWorkspacesInConflictResolutionMode(
|
|
180
|
+
project.projectId,
|
|
181
|
+
)) as Workspace[]
|
|
182
|
+
).map((workspace) => workspace.workspaceId);
|
|
183
|
+
|
|
184
|
+
this.groupWorkspaces = (
|
|
185
|
+
(yield this.sdlcServerClient.getGroupWorkspaces(
|
|
186
|
+
project.projectId,
|
|
187
|
+
)) as PlainObject<Workspace>[]
|
|
188
|
+
)
|
|
189
|
+
.map((v) => Workspace.serialization.fromJson(v))
|
|
190
|
+
.filter(
|
|
191
|
+
(workspace) =>
|
|
192
|
+
// NOTE we don't handle workspaces that only have conflict resolution but no standard workspace
|
|
193
|
+
// since that indicates bad state of the SDLC server
|
|
194
|
+
!workspacesInConflictResolutionIds.includes(
|
|
195
|
+
workspace.workspaceId,
|
|
196
|
+
) && workspace.workspaceType === WorkspaceType.GROUP,
|
|
197
|
+
);
|
|
198
|
+
|
|
199
|
+
if (this.groupWorkspaces.length) {
|
|
200
|
+
yield flowResult(
|
|
201
|
+
this.changeWorkspace(guaranteeNonNullable(this.groupWorkspaces[0])),
|
|
202
|
+
);
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
this.loadWorkspacesState.pass();
|
|
206
|
+
} catch (error) {
|
|
207
|
+
assertErrorThrown(error);
|
|
208
|
+
this.applicationStore.log.error(
|
|
209
|
+
LogEvent.create(LEGEND_STUDIO_APP_EVENT.SDLC_MANAGER_FAILURE),
|
|
210
|
+
error,
|
|
211
|
+
);
|
|
212
|
+
this.applicationStore.notifyError(error);
|
|
213
|
+
this.loadWorkspacesState.fail();
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
*changeWorkspace(workspace: Workspace): GeneratorFn<void> {
|
|
218
|
+
this.currentGroupWorkspace = workspace;
|
|
219
|
+
|
|
220
|
+
try {
|
|
221
|
+
const entities = (yield flowResult(
|
|
222
|
+
this.sdlcServerClient.getEntities(workspace.projectId, workspace),
|
|
223
|
+
)) as Entity[];
|
|
224
|
+
this.services = entities.filter(
|
|
225
|
+
(entity) => entity.classifierPath === CORE_PURE_PATH.SERVICE,
|
|
226
|
+
);
|
|
227
|
+
|
|
228
|
+
if (this.services.length) {
|
|
229
|
+
this.changeService(guaranteeNonNullable(this.services[0]));
|
|
230
|
+
}
|
|
231
|
+
} catch {
|
|
232
|
+
this.services = [];
|
|
233
|
+
this.resetCurrentService();
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
changeService(service: Entity): void {
|
|
238
|
+
this.currentService = service;
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
*createWorkspace(projectId: string, workspaceId: string): GeneratorFn<void> {
|
|
242
|
+
this.createWorkspaceState.inProgress();
|
|
243
|
+
try {
|
|
244
|
+
const newGroupWorkspace = Workspace.serialization.fromJson(
|
|
245
|
+
(yield this.sdlcServerClient.createWorkspace(
|
|
246
|
+
projectId,
|
|
247
|
+
workspaceId,
|
|
248
|
+
WorkspaceType.GROUP,
|
|
249
|
+
)) as PlainObject<Workspace>,
|
|
250
|
+
);
|
|
251
|
+
|
|
252
|
+
this.applicationStore.notifySuccess(
|
|
253
|
+
`Workspace '${newGroupWorkspace.workspaceId}' is succesfully created`,
|
|
254
|
+
);
|
|
255
|
+
|
|
256
|
+
const matchingGroupWorkspace = this.groupWorkspaces.find(
|
|
257
|
+
(workspace) => workspace.workspaceId === newGroupWorkspace.workspaceId,
|
|
258
|
+
);
|
|
259
|
+
const groupWorkspaceToSelect =
|
|
260
|
+
matchingGroupWorkspace ?? newGroupWorkspace;
|
|
261
|
+
|
|
262
|
+
yield flowResult(this.changeWorkspace(groupWorkspaceToSelect));
|
|
263
|
+
this.setShowCreateWorkspaceModal(false);
|
|
264
|
+
|
|
265
|
+
// NOTE: do this after closing the modal to not interfere
|
|
266
|
+
// with validation of existing workspaces in create workspace modal
|
|
267
|
+
if (!matchingGroupWorkspace) {
|
|
268
|
+
this.groupWorkspaces.push(newGroupWorkspace);
|
|
269
|
+
}
|
|
270
|
+
} catch (error) {
|
|
271
|
+
assertErrorThrown(error);
|
|
272
|
+
this.applicationStore.log.error(
|
|
273
|
+
LogEvent.create(LEGEND_STUDIO_APP_EVENT.WORKSPACE_SETUP_FAILURE),
|
|
274
|
+
error,
|
|
275
|
+
);
|
|
276
|
+
this.applicationStore.notifyError(error);
|
|
277
|
+
} finally {
|
|
278
|
+
this.createWorkspaceState.reset();
|
|
279
|
+
}
|
|
280
|
+
}
|
|
281
|
+
}
|
|
@@ -0,0 +1,314 @@
|
|
|
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 { observable, makeObservable, flowResult, flow, action } from 'mobx';
|
|
18
|
+
import {
|
|
19
|
+
type GeneratorFn,
|
|
20
|
+
type PlainObject,
|
|
21
|
+
ActionState,
|
|
22
|
+
assertErrorThrown,
|
|
23
|
+
guaranteeNonNullable,
|
|
24
|
+
LogEvent,
|
|
25
|
+
} from '@finos/legend-shared';
|
|
26
|
+
import {
|
|
27
|
+
type DepotServerClient,
|
|
28
|
+
type StoredEntity,
|
|
29
|
+
DepotScope,
|
|
30
|
+
ProjectData,
|
|
31
|
+
MASTER_SNAPSHOT_ALIAS,
|
|
32
|
+
} from '@finos/legend-server-depot';
|
|
33
|
+
import {
|
|
34
|
+
extractServiceInfo,
|
|
35
|
+
type ServiceInfo,
|
|
36
|
+
} from '@finos/legend-query-builder';
|
|
37
|
+
import {
|
|
38
|
+
type SDLCServerClient,
|
|
39
|
+
Workspace,
|
|
40
|
+
WorkspaceType,
|
|
41
|
+
} from '@finos/legend-server-sdlc';
|
|
42
|
+
import {
|
|
43
|
+
type LegendStudioApplicationStore,
|
|
44
|
+
LEGEND_STUDIO_APP_EVENT,
|
|
45
|
+
} from '@finos/legend-application-studio';
|
|
46
|
+
import {
|
|
47
|
+
generateServiceQueryUpdaterSetupRoute,
|
|
48
|
+
parseServiceCoordinates,
|
|
49
|
+
} from './DSL_Service_LegendStudioRouter.js';
|
|
50
|
+
import { CORE_PURE_PATH } from '@finos/legend-graph';
|
|
51
|
+
import type { Entity } from '@finos/legend-storage';
|
|
52
|
+
|
|
53
|
+
const MINIMUM_SERVICE_LOADER_SEARCH_LENGTH = 3;
|
|
54
|
+
const DEFAULT_SERVICE_LOADER_LIMIT = 10;
|
|
55
|
+
|
|
56
|
+
export class UpdateServiceQuerySetupStore {
|
|
57
|
+
applicationStore: LegendStudioApplicationStore;
|
|
58
|
+
sdlcServerClient: SDLCServerClient;
|
|
59
|
+
depotServerClient: DepotServerClient;
|
|
60
|
+
|
|
61
|
+
initState = ActionState.create();
|
|
62
|
+
loadServicesState = ActionState.create();
|
|
63
|
+
services: ServiceInfo[] = [];
|
|
64
|
+
currentProject?: ProjectData | undefined;
|
|
65
|
+
currentSnapshotService?: ServiceInfo | undefined;
|
|
66
|
+
|
|
67
|
+
loadWorkspacesState = ActionState.create();
|
|
68
|
+
createWorkspaceState = ActionState.create();
|
|
69
|
+
groupWorkspaces: Workspace[] = [];
|
|
70
|
+
currentGroupWorkspace?: Workspace | undefined;
|
|
71
|
+
currentWorkspaceService?: Entity | undefined;
|
|
72
|
+
checkWorkspaceCompatibilityState = ActionState.create();
|
|
73
|
+
showCreateWorkspaceModal = false;
|
|
74
|
+
|
|
75
|
+
constructor(
|
|
76
|
+
applicationStore: LegendStudioApplicationStore,
|
|
77
|
+
sdlcServerClient: SDLCServerClient,
|
|
78
|
+
depotServerClient: DepotServerClient,
|
|
79
|
+
) {
|
|
80
|
+
makeObservable(this, {
|
|
81
|
+
services: observable,
|
|
82
|
+
currentProject: observable,
|
|
83
|
+
currentSnapshotService: observable,
|
|
84
|
+
groupWorkspaces: observable,
|
|
85
|
+
currentGroupWorkspace: observable,
|
|
86
|
+
currentWorkspaceService: observable,
|
|
87
|
+
showCreateWorkspaceModal: observable,
|
|
88
|
+
setShowCreateWorkspaceModal: action,
|
|
89
|
+
resetCurrentService: action,
|
|
90
|
+
resetCurrentGroupWorkspace: action,
|
|
91
|
+
initialize: flow,
|
|
92
|
+
loadServices: flow,
|
|
93
|
+
changeService: flow,
|
|
94
|
+
changeWorkspace: flow,
|
|
95
|
+
createWorkspace: flow,
|
|
96
|
+
});
|
|
97
|
+
|
|
98
|
+
this.applicationStore = applicationStore;
|
|
99
|
+
this.sdlcServerClient = sdlcServerClient;
|
|
100
|
+
this.depotServerClient = depotServerClient;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
setShowCreateWorkspaceModal(val: boolean): void {
|
|
104
|
+
this.showCreateWorkspaceModal = val;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
resetCurrentService(): void {
|
|
108
|
+
this.currentProject = undefined;
|
|
109
|
+
this.currentSnapshotService = undefined;
|
|
110
|
+
this.groupWorkspaces = [];
|
|
111
|
+
this.resetCurrentGroupWorkspace();
|
|
112
|
+
this.applicationStore.navigator.goTo(
|
|
113
|
+
generateServiceQueryUpdaterSetupRoute(undefined, undefined, undefined),
|
|
114
|
+
);
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
resetCurrentGroupWorkspace(): void {
|
|
118
|
+
this.currentGroupWorkspace = undefined;
|
|
119
|
+
this.currentWorkspaceService = undefined;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
*initialize(serviceCoordinates: string | undefined): GeneratorFn<void> {
|
|
123
|
+
if (!this.initState.isInInitialState) {
|
|
124
|
+
return;
|
|
125
|
+
}
|
|
126
|
+
this.initState.inProgress();
|
|
127
|
+
|
|
128
|
+
try {
|
|
129
|
+
if (serviceCoordinates) {
|
|
130
|
+
const { groupId, artifactId, servicePath } =
|
|
131
|
+
parseServiceCoordinates(serviceCoordinates);
|
|
132
|
+
yield flowResult(this.changeService(groupId, artifactId, servicePath));
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
this.initState.pass();
|
|
136
|
+
} catch (error) {
|
|
137
|
+
assertErrorThrown(error);
|
|
138
|
+
this.applicationStore.log.error(
|
|
139
|
+
LogEvent.create(LEGEND_STUDIO_APP_EVENT.DEPOT_MANAGER_FAILURE),
|
|
140
|
+
error,
|
|
141
|
+
);
|
|
142
|
+
this.applicationStore.notifyError(error);
|
|
143
|
+
this.initState.fail();
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
*loadServices(searchText: string): GeneratorFn<void> {
|
|
148
|
+
const isValidSearchString =
|
|
149
|
+
searchText.length >= MINIMUM_SERVICE_LOADER_SEARCH_LENGTH;
|
|
150
|
+
this.loadServicesState.inProgress();
|
|
151
|
+
try {
|
|
152
|
+
this.services = (
|
|
153
|
+
(yield this.depotServerClient.getEntitiesByClassifierPath(
|
|
154
|
+
CORE_PURE_PATH.SERVICE,
|
|
155
|
+
{
|
|
156
|
+
search: isValidSearchString ? searchText : undefined,
|
|
157
|
+
// NOTE: since this mode is meant for contribution, we want to load services
|
|
158
|
+
// on the snapshot version (i.e. merged to the default branch on the projects)
|
|
159
|
+
scope: DepotScope.SNAPSHOT,
|
|
160
|
+
limit: DEFAULT_SERVICE_LOADER_LIMIT,
|
|
161
|
+
},
|
|
162
|
+
)) as StoredEntity[]
|
|
163
|
+
).map((storedEntity) => extractServiceInfo(storedEntity));
|
|
164
|
+
this.loadServicesState.pass();
|
|
165
|
+
} catch (error) {
|
|
166
|
+
assertErrorThrown(error);
|
|
167
|
+
this.applicationStore.notifyError(error);
|
|
168
|
+
this.loadServicesState.fail();
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
*changeService(
|
|
173
|
+
groupId: string,
|
|
174
|
+
artifactId: string,
|
|
175
|
+
servicePath: string,
|
|
176
|
+
): GeneratorFn<void> {
|
|
177
|
+
this.loadWorkspacesState.inProgress();
|
|
178
|
+
|
|
179
|
+
try {
|
|
180
|
+
const project = ProjectData.serialization.fromJson(
|
|
181
|
+
(yield this.depotServerClient.getProject(
|
|
182
|
+
groupId,
|
|
183
|
+
artifactId,
|
|
184
|
+
)) as PlainObject<ProjectData>,
|
|
185
|
+
);
|
|
186
|
+
|
|
187
|
+
this.currentProject = project;
|
|
188
|
+
|
|
189
|
+
const serviceEntity = (yield this.depotServerClient.getEntity(
|
|
190
|
+
project,
|
|
191
|
+
MASTER_SNAPSHOT_ALIAS,
|
|
192
|
+
servicePath,
|
|
193
|
+
)) as Entity;
|
|
194
|
+
this.currentSnapshotService = extractServiceInfo({
|
|
195
|
+
groupId: groupId,
|
|
196
|
+
artifactId: artifactId,
|
|
197
|
+
versionId: MASTER_SNAPSHOT_ALIAS,
|
|
198
|
+
entity: serviceEntity,
|
|
199
|
+
});
|
|
200
|
+
|
|
201
|
+
this.applicationStore.navigator.goTo(
|
|
202
|
+
generateServiceQueryUpdaterSetupRoute(
|
|
203
|
+
project.groupId,
|
|
204
|
+
project.artifactId,
|
|
205
|
+
servicePath,
|
|
206
|
+
),
|
|
207
|
+
);
|
|
208
|
+
|
|
209
|
+
const workspacesInConflictResolutionIds = (
|
|
210
|
+
(yield this.sdlcServerClient.getWorkspacesInConflictResolutionMode(
|
|
211
|
+
project.projectId,
|
|
212
|
+
)) as Workspace[]
|
|
213
|
+
).map((workspace) => workspace.workspaceId);
|
|
214
|
+
|
|
215
|
+
this.groupWorkspaces = (
|
|
216
|
+
(yield this.sdlcServerClient.getGroupWorkspaces(
|
|
217
|
+
project.projectId,
|
|
218
|
+
)) as PlainObject<Workspace>[]
|
|
219
|
+
)
|
|
220
|
+
.map((v) => Workspace.serialization.fromJson(v))
|
|
221
|
+
.filter(
|
|
222
|
+
(workspace) =>
|
|
223
|
+
// NOTE we don't handle workspaces that only have conflict resolution but no standard workspace
|
|
224
|
+
// since that indicates bad state of the SDLC server
|
|
225
|
+
!workspacesInConflictResolutionIds.includes(
|
|
226
|
+
workspace.workspaceId,
|
|
227
|
+
) && workspace.workspaceType === WorkspaceType.GROUP,
|
|
228
|
+
);
|
|
229
|
+
|
|
230
|
+
if (this.groupWorkspaces.length) {
|
|
231
|
+
yield flowResult(
|
|
232
|
+
this.changeWorkspace(
|
|
233
|
+
guaranteeNonNullable(this.groupWorkspaces[0]),
|
|
234
|
+
servicePath,
|
|
235
|
+
),
|
|
236
|
+
);
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
this.loadWorkspacesState.pass();
|
|
240
|
+
} catch (error) {
|
|
241
|
+
assertErrorThrown(error);
|
|
242
|
+
this.applicationStore.log.error(
|
|
243
|
+
LogEvent.create(LEGEND_STUDIO_APP_EVENT.DEPOT_MANAGER_FAILURE),
|
|
244
|
+
error,
|
|
245
|
+
);
|
|
246
|
+
this.applicationStore.notifyError(error);
|
|
247
|
+
this.loadWorkspacesState.fail();
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
*changeWorkspace(
|
|
252
|
+
workspace: Workspace,
|
|
253
|
+
servicePath: string,
|
|
254
|
+
): GeneratorFn<void> {
|
|
255
|
+
this.currentGroupWorkspace = workspace;
|
|
256
|
+
|
|
257
|
+
this.checkWorkspaceCompatibilityState.inProgress();
|
|
258
|
+
try {
|
|
259
|
+
this.currentWorkspaceService = (yield flowResult(
|
|
260
|
+
this.sdlcServerClient.getWorkspaceEntity(workspace, servicePath),
|
|
261
|
+
)) as Entity;
|
|
262
|
+
} catch {
|
|
263
|
+
this.currentWorkspaceService = undefined;
|
|
264
|
+
}
|
|
265
|
+
this.checkWorkspaceCompatibilityState.reset();
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
*createWorkspace(
|
|
269
|
+
projectId: string,
|
|
270
|
+
workspaceId: string,
|
|
271
|
+
servicePath: string,
|
|
272
|
+
): GeneratorFn<void> {
|
|
273
|
+
this.createWorkspaceState.inProgress();
|
|
274
|
+
try {
|
|
275
|
+
const newGroupWorkspace = Workspace.serialization.fromJson(
|
|
276
|
+
(yield this.sdlcServerClient.createWorkspace(
|
|
277
|
+
projectId,
|
|
278
|
+
workspaceId,
|
|
279
|
+
WorkspaceType.GROUP,
|
|
280
|
+
)) as PlainObject<Workspace>,
|
|
281
|
+
);
|
|
282
|
+
|
|
283
|
+
this.applicationStore.notifySuccess(
|
|
284
|
+
`Workspace '${newGroupWorkspace.workspaceId}' is succesfully created`,
|
|
285
|
+
);
|
|
286
|
+
|
|
287
|
+
const matchingGroupWorkspace = this.groupWorkspaces.find(
|
|
288
|
+
(workspace) => workspace.workspaceId === newGroupWorkspace.workspaceId,
|
|
289
|
+
);
|
|
290
|
+
const groupWorkspaceToSelect =
|
|
291
|
+
matchingGroupWorkspace ?? newGroupWorkspace;
|
|
292
|
+
|
|
293
|
+
yield flowResult(
|
|
294
|
+
this.changeWorkspace(groupWorkspaceToSelect, servicePath),
|
|
295
|
+
);
|
|
296
|
+
this.setShowCreateWorkspaceModal(false);
|
|
297
|
+
|
|
298
|
+
// NOTE: do this after closing the modal to not interfere
|
|
299
|
+
// with validation of existing workspaces in create workspace modal
|
|
300
|
+
if (!matchingGroupWorkspace) {
|
|
301
|
+
this.groupWorkspaces.push(newGroupWorkspace);
|
|
302
|
+
}
|
|
303
|
+
} catch (error) {
|
|
304
|
+
assertErrorThrown(error);
|
|
305
|
+
this.applicationStore.log.error(
|
|
306
|
+
LogEvent.create(LEGEND_STUDIO_APP_EVENT.WORKSPACE_SETUP_FAILURE),
|
|
307
|
+
error,
|
|
308
|
+
);
|
|
309
|
+
this.applicationStore.notifyError(error);
|
|
310
|
+
} finally {
|
|
311
|
+
this.createWorkspaceState.reset();
|
|
312
|
+
}
|
|
313
|
+
}
|
|
314
|
+
}
|
package/tsconfig.json
ADDED
|
@@ -0,0 +1,58 @@
|
|
|
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
|
+
"isolatedModules": true,
|
|
19
|
+
"importsNotUsedAsValues": "error",
|
|
20
|
+
"strict": true,
|
|
21
|
+
"noImplicitOverride": true,
|
|
22
|
+
"noUncheckedIndexedAccess": true,
|
|
23
|
+
"exactOptionalPropertyTypes": true,
|
|
24
|
+
"forceConsistentCasingInFileNames": true,
|
|
25
|
+
"outDir": "./lib",
|
|
26
|
+
"tsBuildInfoFile": "./build/prod.tsbuildinfo",
|
|
27
|
+
"rootDir": "./src",
|
|
28
|
+
"jsx": "react-jsx"
|
|
29
|
+
},
|
|
30
|
+
"references": [
|
|
31
|
+
{
|
|
32
|
+
"path": "./tsconfig.package.json"
|
|
33
|
+
}
|
|
34
|
+
],
|
|
35
|
+
"files": [
|
|
36
|
+
"./src/index.ts",
|
|
37
|
+
"./src/stores/studio/DSL_Service_LegendStudioRouter.ts",
|
|
38
|
+
"./src/stores/studio/ServiceQueryEditorStore.ts",
|
|
39
|
+
"./src/stores/studio/UpdateProjectServiceQuerySetupStore.ts",
|
|
40
|
+
"./src/stores/studio/UpdateServiceQuerySetupStore.ts",
|
|
41
|
+
"./src/components/studio/DSL_Service_LegendStudioApplicationPlugin.tsx",
|
|
42
|
+
"./src/components/studio/ServiceQueryEditor.tsx",
|
|
43
|
+
"./src/components/studio/ServiceQueryEditorReviewAction.tsx",
|
|
44
|
+
"./src/components/studio/ServiceQueryEditorStoreProvider.tsx",
|
|
45
|
+
"./src/components/studio/ServiceQueryEditorWorkspaceStatus.tsx",
|
|
46
|
+
"./src/components/studio/UpdateProjectServiceQuerySetup.tsx",
|
|
47
|
+
"./src/components/studio/UpdateServiceQuerySetup.tsx"
|
|
48
|
+
],
|
|
49
|
+
"include": [
|
|
50
|
+
"src/**/*.ts",
|
|
51
|
+
"src/**/*.tsx",
|
|
52
|
+
"src/**/*.json"
|
|
53
|
+
],
|
|
54
|
+
"exclude": [
|
|
55
|
+
"src/**/__tests__/**/*.*",
|
|
56
|
+
"src/**/__mocks__/**/*.*"
|
|
57
|
+
]
|
|
58
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
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
|
+
"isolatedModules": true,
|
|
19
|
+
"importsNotUsedAsValues": "error",
|
|
20
|
+
"strict": true,
|
|
21
|
+
"noImplicitOverride": true,
|
|
22
|
+
"noUncheckedIndexedAccess": true,
|
|
23
|
+
"exactOptionalPropertyTypes": true,
|
|
24
|
+
"forceConsistentCasingInFileNames": true,
|
|
25
|
+
"outDir": "./lib",
|
|
26
|
+
"tsBuildInfoFile": "./build/package.tsbuildinfo",
|
|
27
|
+
"rootDir": "./"
|
|
28
|
+
},
|
|
29
|
+
"files": [
|
|
30
|
+
"./package.json"
|
|
31
|
+
],
|
|
32
|
+
"include": [
|
|
33
|
+
"package.json"
|
|
34
|
+
],
|
|
35
|
+
"exclude": [
|
|
36
|
+
"lib"
|
|
37
|
+
]
|
|
38
|
+
}
|