@finos/legend-extension-dsl-data-space-studio 0.1.337 → 0.1.339
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/lib/__lib__/DSL_DataSpace_LegendStudioDocumentation.d.ts +0 -3
- package/lib/__lib__/DSL_DataSpace_LegendStudioDocumentation.d.ts.map +1 -1
- package/lib/__lib__/DSL_DataSpace_LegendStudioDocumentation.js +0 -4
- package/lib/__lib__/DSL_DataSpace_LegendStudioDocumentation.js.map +1 -1
- package/lib/components/DataSpaceEditor.d.ts.map +1 -1
- package/lib/components/DataSpaceEditor.js +4 -51
- package/lib/components/DataSpaceEditor.js.map +1 -1
- package/lib/components/DataSpaceGeneralEditor/DataSpaceGeneralEditor.d.ts.map +1 -1
- package/lib/components/DataSpaceGeneralEditor/DataSpaceGeneralEditor.js +63 -3
- package/lib/components/DataSpaceGeneralEditor/DataSpaceGeneralEditor.js.map +1 -1
- package/lib/index.css +2 -2
- package/lib/index.css.map +1 -1
- package/lib/package.json +1 -1
- package/lib/stores/DataSpaceEditorState.d.ts +1 -3
- package/lib/stores/DataSpaceEditorState.d.ts.map +1 -1
- package/lib/stores/DataSpaceEditorState.js +4 -55
- package/lib/stores/DataSpaceEditorState.js.map +1 -1
- package/package.json +8 -8
- package/src/__lib__/DSL_DataSpace_LegendStudioDocumentation.ts +0 -4
- package/src/components/DataSpaceEditor.tsx +3 -158
- package/src/components/DataSpaceGeneralEditor/DataSpaceGeneralEditor.tsx +163 -8
- package/src/stores/DataSpaceEditorState.ts +2 -117
- package/tsconfig.json +0 -1
- package/lib/stores/DataSpaceToDataProductConverter.d.ts +0 -29
- package/lib/stores/DataSpaceToDataProductConverter.d.ts.map +0 -1
- package/lib/stores/DataSpaceToDataProductConverter.js +0 -153
- package/lib/stores/DataSpaceToDataProductConverter.js.map +0 -1
- package/src/stores/DataSpaceToDataProductConverter.ts +0 -239
|
@@ -14,35 +14,14 @@
|
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
16
|
|
|
17
|
-
import { useState } from 'react';
|
|
18
17
|
import { observer } from 'mobx-react-lite';
|
|
19
18
|
import { useEditorStore } from '@finos/legend-application-studio';
|
|
20
|
-
import {
|
|
21
|
-
|
|
22
|
-
WandIcon,
|
|
23
|
-
Panel,
|
|
24
|
-
PanelContent,
|
|
25
|
-
PanelHeader,
|
|
26
|
-
Dialog,
|
|
27
|
-
Modal,
|
|
28
|
-
ModalHeader,
|
|
29
|
-
ModalBody,
|
|
30
|
-
ModalFooter,
|
|
31
|
-
ModalFooterButton,
|
|
32
|
-
CustomSelectorInput,
|
|
33
|
-
} from '@finos/legend-art';
|
|
34
|
-
import {
|
|
35
|
-
DataSpaceEditorState,
|
|
36
|
-
onConvertDataSpaceToDataProduct,
|
|
37
|
-
onMergeDataSpaceToDataProduct,
|
|
38
|
-
} from '../stores/DataSpaceEditorState.js';
|
|
19
|
+
import { EyeIcon, Panel, PanelContent, PanelHeader } from '@finos/legend-art';
|
|
20
|
+
import { DataSpaceEditorState } from '../stores/DataSpaceEditorState.js';
|
|
39
21
|
import { DataSpaceGeneralEditor } from './DataSpaceGeneralEditor/DataSpaceGeneralEditor.js';
|
|
40
22
|
import { DataSpacePreviewState } from '../stores/DataSpacePreviewState.js';
|
|
41
23
|
import { flowResult } from 'mobx';
|
|
42
|
-
import {
|
|
43
|
-
isStubbed_PackageableElement,
|
|
44
|
-
type DataProduct,
|
|
45
|
-
} from '@finos/legend-graph';
|
|
24
|
+
import { isStubbed_PackageableElement } from '@finos/legend-graph';
|
|
46
25
|
import { DSL_DATA_SPACE_LEGEND_STUDIO_APPLICATION_NAVIGATION_CONTEXT_KEY } from '../__lib__/DSL_DataSpace_LegendStudioDocumentation.js';
|
|
47
26
|
import { useApplicationNavigationContext } from '@finos/legend-application';
|
|
48
27
|
|
|
@@ -78,71 +57,6 @@ export const DataSpaceEditor = observer(() => {
|
|
|
78
57
|
).catch(editorStore.applicationStore.alertUnhandledError);
|
|
79
58
|
};
|
|
80
59
|
|
|
81
|
-
const convertDataSpace = (): void => {
|
|
82
|
-
flowResult(
|
|
83
|
-
onConvertDataSpaceToDataProduct(dataSpace, editorStore, dataSpaceState),
|
|
84
|
-
).catch(editorStore.applicationStore.alertUnhandledError);
|
|
85
|
-
};
|
|
86
|
-
|
|
87
|
-
const eligibleMergeTargets =
|
|
88
|
-
editorStore.graphManagerState.graph.ownDataProducts.filter(
|
|
89
|
-
(dp) => dp.nativeModelAccess === undefined,
|
|
90
|
-
);
|
|
91
|
-
|
|
92
|
-
const mergeDataSpace = (targetDataProduct: DataProduct): void => {
|
|
93
|
-
flowResult(
|
|
94
|
-
onMergeDataSpaceToDataProduct(
|
|
95
|
-
dataSpace,
|
|
96
|
-
targetDataProduct,
|
|
97
|
-
editorStore,
|
|
98
|
-
dataSpaceState,
|
|
99
|
-
),
|
|
100
|
-
).catch(editorStore.applicationStore.alertUnhandledError);
|
|
101
|
-
};
|
|
102
|
-
|
|
103
|
-
const [showConvertModal, setShowConvertModal] = useState(false);
|
|
104
|
-
|
|
105
|
-
const modeOptions: { label: string; value: string }[] = [
|
|
106
|
-
{ label: 'Merge', value: 'merge' },
|
|
107
|
-
{ label: 'Create', value: 'create' },
|
|
108
|
-
];
|
|
109
|
-
|
|
110
|
-
const [selectedMode, setSelectedMode] = useState<{
|
|
111
|
-
label: string;
|
|
112
|
-
value: string;
|
|
113
|
-
} | null>(modeOptions[0] ?? null);
|
|
114
|
-
|
|
115
|
-
const mergeTargetOptions = eligibleMergeTargets.map((dp) => ({
|
|
116
|
-
label: dp.path,
|
|
117
|
-
value: dp,
|
|
118
|
-
}));
|
|
119
|
-
|
|
120
|
-
const [selectedMergeTarget, setSelectedMergeTarget] = useState<{
|
|
121
|
-
label: string;
|
|
122
|
-
value: DataProduct;
|
|
123
|
-
} | null>(mergeTargetOptions[0] ?? null);
|
|
124
|
-
|
|
125
|
-
const onConvertButtonClick = (): void => {
|
|
126
|
-
if (eligibleMergeTargets.length === 0) {
|
|
127
|
-
convertDataSpace();
|
|
128
|
-
return;
|
|
129
|
-
}
|
|
130
|
-
setSelectedMode(modeOptions[0] ?? null);
|
|
131
|
-
setSelectedMergeTarget(mergeTargetOptions[0] ?? null);
|
|
132
|
-
setShowConvertModal(true);
|
|
133
|
-
};
|
|
134
|
-
|
|
135
|
-
const closeConvertModal = (): void => setShowConvertModal(false);
|
|
136
|
-
|
|
137
|
-
const handleConvertConfirm = (): void => {
|
|
138
|
-
closeConvertModal();
|
|
139
|
-
if (selectedMode?.value === 'merge' && selectedMergeTarget) {
|
|
140
|
-
mergeDataSpace(selectedMergeTarget.value);
|
|
141
|
-
} else {
|
|
142
|
-
convertDataSpace();
|
|
143
|
-
}
|
|
144
|
-
};
|
|
145
|
-
|
|
146
60
|
useApplicationNavigationContext(
|
|
147
61
|
DSL_DATA_SPACE_LEGEND_STUDIO_APPLICATION_NAVIGATION_CONTEXT_KEY.DATA_SPACE_EDITOR,
|
|
148
62
|
);
|
|
@@ -157,20 +71,6 @@ export const DataSpaceEditor = observer(() => {
|
|
|
157
71
|
/>
|
|
158
72
|
<PanelHeader title="General" darkMode={true}>
|
|
159
73
|
<div className="panel__header__actions">
|
|
160
|
-
<div className="btn__dropdown-combo btn__dropdown-combo--primary">
|
|
161
|
-
<button
|
|
162
|
-
className="btn__dropdown-combo__label"
|
|
163
|
-
onClick={onConvertButtonClick}
|
|
164
|
-
title="Convert to Data Product"
|
|
165
|
-
tabIndex={-1}
|
|
166
|
-
style={{ width: 'auto', whiteSpace: 'nowrap' }}
|
|
167
|
-
>
|
|
168
|
-
<WandIcon className="btn__dropdown-combo__label__icon" />
|
|
169
|
-
<div className="btn__dropdown-combo__label__title">
|
|
170
|
-
Convert to DataProduct
|
|
171
|
-
</div>
|
|
172
|
-
</button>
|
|
173
|
-
</div>
|
|
174
74
|
<div className="btn__dropdown-combo btn__dropdown-combo--primary">
|
|
175
75
|
<button
|
|
176
76
|
className="btn__dropdown-combo__label"
|
|
@@ -186,61 +86,6 @@ export const DataSpaceEditor = observer(() => {
|
|
|
186
86
|
</div>
|
|
187
87
|
</PanelHeader>
|
|
188
88
|
|
|
189
|
-
<Dialog open={showConvertModal} onClose={closeConvertModal}>
|
|
190
|
-
<Modal darkMode={true}>
|
|
191
|
-
<ModalHeader title="Convert to Data Product" />
|
|
192
|
-
<ModalBody>
|
|
193
|
-
<div className="panel__content__form__section">
|
|
194
|
-
<div className="panel__content__form__section__header__label">
|
|
195
|
-
Mode
|
|
196
|
-
</div>
|
|
197
|
-
<CustomSelectorInput
|
|
198
|
-
options={modeOptions}
|
|
199
|
-
onChange={(val: { label: string; value: string } | null) => {
|
|
200
|
-
if (val) {
|
|
201
|
-
setSelectedMode(val);
|
|
202
|
-
if (val.value === 'merge') {
|
|
203
|
-
setSelectedMergeTarget(mergeTargetOptions[0] ?? null);
|
|
204
|
-
}
|
|
205
|
-
}
|
|
206
|
-
}}
|
|
207
|
-
value={selectedMode}
|
|
208
|
-
darkMode={true}
|
|
209
|
-
/>
|
|
210
|
-
</div>
|
|
211
|
-
{selectedMode?.value === 'merge' && (
|
|
212
|
-
<div className="panel__content__form__section">
|
|
213
|
-
<div className="panel__content__form__section__header__label">
|
|
214
|
-
Target Data Product
|
|
215
|
-
</div>
|
|
216
|
-
<CustomSelectorInput
|
|
217
|
-
options={mergeTargetOptions}
|
|
218
|
-
onChange={(
|
|
219
|
-
val: { label: string; value: DataProduct } | null,
|
|
220
|
-
) => {
|
|
221
|
-
setSelectedMergeTarget(val);
|
|
222
|
-
}}
|
|
223
|
-
value={selectedMergeTarget}
|
|
224
|
-
darkMode={true}
|
|
225
|
-
/>
|
|
226
|
-
</div>
|
|
227
|
-
)}
|
|
228
|
-
</ModalBody>
|
|
229
|
-
<ModalFooter>
|
|
230
|
-
<ModalFooterButton
|
|
231
|
-
text="Cancel"
|
|
232
|
-
onClick={closeConvertModal}
|
|
233
|
-
type="secondary"
|
|
234
|
-
/>
|
|
235
|
-
<ModalFooterButton
|
|
236
|
-
text={selectedMode?.value === 'merge' ? 'Merge' : 'Create'}
|
|
237
|
-
onClick={handleConvertConfirm}
|
|
238
|
-
disabled={selectedMode?.value === 'merge' && !selectedMergeTarget}
|
|
239
|
-
/>
|
|
240
|
-
</ModalFooter>
|
|
241
|
-
</Modal>
|
|
242
|
-
</Dialog>
|
|
243
|
-
|
|
244
89
|
<PanelContent>
|
|
245
90
|
<DataSpaceGeneralEditor />
|
|
246
91
|
</PanelContent>
|
|
@@ -14,13 +14,27 @@
|
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
16
|
|
|
17
|
-
import { useEditorStore } from '@finos/legend-application-studio';
|
|
18
17
|
import {
|
|
18
|
+
useEditorStore,
|
|
19
|
+
LEGEND_STUDIO_DOCUMENTATION_KEY,
|
|
20
|
+
LegendStudioTelemetryHelper,
|
|
21
|
+
type DSL_DataSpace_LegendStudioApplicationPlugin_Extension,
|
|
22
|
+
} from '@finos/legend-application-studio';
|
|
23
|
+
import {
|
|
24
|
+
clsx,
|
|
19
25
|
PanelContentLists,
|
|
20
26
|
PanelForm,
|
|
21
27
|
PanelFormTextField,
|
|
28
|
+
PanelLoadingIndicator,
|
|
29
|
+
SparkleIcon,
|
|
22
30
|
} from '@finos/legend-art';
|
|
23
31
|
import { observer } from 'mobx-react-lite';
|
|
32
|
+
import { useState } from 'react';
|
|
33
|
+
import {
|
|
34
|
+
assertErrorThrown,
|
|
35
|
+
HttpStatus,
|
|
36
|
+
NetworkClientError,
|
|
37
|
+
} from '@finos/legend-shared';
|
|
24
38
|
import { DataSpaceEditorState } from '../../stores/DataSpaceEditorState.js';
|
|
25
39
|
import {
|
|
26
40
|
dataSpace_setDescription,
|
|
@@ -38,6 +52,7 @@ export const DataSpaceGeneralEditor = observer(() => {
|
|
|
38
52
|
const dataSpaceState =
|
|
39
53
|
editorStore.tabManagerState.getCurrentEditorState(DataSpaceEditorState);
|
|
40
54
|
const dataSpace = dataSpaceState.dataSpace;
|
|
55
|
+
const isReadOnly = dataSpaceState.isReadOnly;
|
|
41
56
|
|
|
42
57
|
// Basic properties handlers
|
|
43
58
|
const handleTitleChange = (value: string | undefined): void => {
|
|
@@ -48,6 +63,86 @@ export const DataSpaceGeneralEditor = observer(() => {
|
|
|
48
63
|
dataSpace_setDescription(dataSpace, value);
|
|
49
64
|
};
|
|
50
65
|
|
|
66
|
+
// AI documentation suggestion
|
|
67
|
+
const legendAIUrl = editorStore.applicationStore.config.legendAIUrl;
|
|
68
|
+
const aiDocSuggester = legendAIUrl
|
|
69
|
+
? editorStore.pluginManager
|
|
70
|
+
.getApplicationPlugins()
|
|
71
|
+
.map((p) =>
|
|
72
|
+
(
|
|
73
|
+
p as DSL_DataSpace_LegendStudioApplicationPlugin_Extension
|
|
74
|
+
).getExtraDataSpaceDocumentationAISuggester?.bind(p),
|
|
75
|
+
)
|
|
76
|
+
.find(Boolean)
|
|
77
|
+
: undefined;
|
|
78
|
+
const [isSuggestingWithAI, setIsSuggestingWithAI] = useState(false);
|
|
79
|
+
const [aiDocSuggestion, setAIDocSuggestion] = useState<string | undefined>(
|
|
80
|
+
undefined,
|
|
81
|
+
);
|
|
82
|
+
const suggestDocumentationWithAI = async (): Promise<void> => {
|
|
83
|
+
if (!aiDocSuggester || !legendAIUrl) {
|
|
84
|
+
return;
|
|
85
|
+
}
|
|
86
|
+
LegendStudioTelemetryHelper.logEvent_DataSpaceLegendAISuggestLaunched(
|
|
87
|
+
editorStore.applicationStore.telemetryService,
|
|
88
|
+
dataSpace.path,
|
|
89
|
+
);
|
|
90
|
+
setIsSuggestingWithAI(true);
|
|
91
|
+
setAIDocSuggestion(undefined);
|
|
92
|
+
try {
|
|
93
|
+
const definitions =
|
|
94
|
+
await editorStore.graphManagerState.graphManager.graphToPureCode(
|
|
95
|
+
editorStore.graphManagerState.graph,
|
|
96
|
+
);
|
|
97
|
+
const suggestion = await aiDocSuggester(
|
|
98
|
+
{ definitions, data_space_name: dataSpace.path },
|
|
99
|
+
legendAIUrl,
|
|
100
|
+
);
|
|
101
|
+
setAIDocSuggestion(suggestion.description);
|
|
102
|
+
} catch (error) {
|
|
103
|
+
assertErrorThrown(error);
|
|
104
|
+
LegendStudioTelemetryHelper.logEvent_DataSpaceLegendAISuggestFailure(
|
|
105
|
+
editorStore.applicationStore.telemetryService,
|
|
106
|
+
dataSpace.path,
|
|
107
|
+
error.message,
|
|
108
|
+
);
|
|
109
|
+
if (
|
|
110
|
+
error instanceof NetworkClientError &&
|
|
111
|
+
(error.response.status === HttpStatus.UNAUTHORIZED ||
|
|
112
|
+
error.response.status === HttpStatus.FORBIDDEN)
|
|
113
|
+
) {
|
|
114
|
+
const docEntry =
|
|
115
|
+
editorStore.applicationStore.documentationService.getDocEntry(
|
|
116
|
+
LEGEND_STUDIO_DOCUMENTATION_KEY.LEGENDAI_HOW_TO_GET_ENTITLEMENTS,
|
|
117
|
+
);
|
|
118
|
+
if (docEntry?.url) {
|
|
119
|
+
error.message = `${error.message}. Please check how to get entitlements: ${docEntry.url}`;
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
throw error;
|
|
123
|
+
} finally {
|
|
124
|
+
setIsSuggestingWithAI(false);
|
|
125
|
+
}
|
|
126
|
+
};
|
|
127
|
+
const applyAIDocSuggestion = (): void => {
|
|
128
|
+
if (!aiDocSuggestion) {
|
|
129
|
+
return;
|
|
130
|
+
}
|
|
131
|
+
LegendStudioTelemetryHelper.logEvent_DataSpaceLegendAISuggestApplied(
|
|
132
|
+
editorStore.applicationStore.telemetryService,
|
|
133
|
+
dataSpace.path,
|
|
134
|
+
);
|
|
135
|
+
dataSpace_setDescription(dataSpace, aiDocSuggestion);
|
|
136
|
+
setAIDocSuggestion(undefined);
|
|
137
|
+
};
|
|
138
|
+
const discardAIDocSuggestion = (): void => {
|
|
139
|
+
LegendStudioTelemetryHelper.logEvent_DataSpaceLegendAISuggestDiscarded(
|
|
140
|
+
editorStore.applicationStore.telemetryService,
|
|
141
|
+
dataSpace.path,
|
|
142
|
+
);
|
|
143
|
+
setAIDocSuggestion(undefined);
|
|
144
|
+
};
|
|
145
|
+
|
|
51
146
|
return (
|
|
52
147
|
<PanelContentLists className="dataSpace-editor__general">
|
|
53
148
|
<PanelForm>
|
|
@@ -58,13 +153,73 @@ export const DataSpaceGeneralEditor = observer(() => {
|
|
|
58
153
|
update={handleTitleChange}
|
|
59
154
|
placeholder="Enter title"
|
|
60
155
|
/>
|
|
61
|
-
<
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
156
|
+
<div className="panel__content__form__section">
|
|
157
|
+
<div className="panel__content__form__section__header__label">
|
|
158
|
+
Description
|
|
159
|
+
{aiDocSuggestion && (
|
|
160
|
+
<span
|
|
161
|
+
className="dataSpace-editor__ai-suggestion-badge"
|
|
162
|
+
style={{ marginLeft: '0.8rem' }}
|
|
163
|
+
>
|
|
164
|
+
<SparkleIcon />
|
|
165
|
+
AI Suggestion
|
|
166
|
+
</span>
|
|
167
|
+
)}
|
|
168
|
+
{aiDocSuggester && !aiDocSuggestion && (
|
|
169
|
+
<button
|
|
170
|
+
className="dataSpace-editor__ai-suggest-btn"
|
|
171
|
+
style={{ marginLeft: '0.8rem' }}
|
|
172
|
+
onClick={(): void => {
|
|
173
|
+
suggestDocumentationWithAI().catch(
|
|
174
|
+
editorStore.applicationStore.alertUnhandledError,
|
|
175
|
+
);
|
|
176
|
+
}}
|
|
177
|
+
disabled={isSuggestingWithAI || isReadOnly}
|
|
178
|
+
title="Use AI to suggest a description for this data product"
|
|
179
|
+
>
|
|
180
|
+
<SparkleIcon />
|
|
181
|
+
<span>
|
|
182
|
+
{isSuggestingWithAI ? 'Suggesting...' : 'Suggest with AI'}
|
|
183
|
+
</span>
|
|
184
|
+
</button>
|
|
185
|
+
)}
|
|
186
|
+
</div>
|
|
187
|
+
<div className="panel__content__form__section__header__prompt">
|
|
188
|
+
Provide a description for this Data Product.
|
|
189
|
+
</div>
|
|
190
|
+
<PanelLoadingIndicator isLoading={isSuggestingWithAI} />
|
|
191
|
+
<textarea
|
|
192
|
+
className={clsx('panel__content__form__section__textarea', {
|
|
193
|
+
'textarea--ai-suggested': Boolean(aiDocSuggestion),
|
|
194
|
+
})}
|
|
195
|
+
spellCheck={false}
|
|
196
|
+
disabled={isReadOnly}
|
|
197
|
+
readOnly={Boolean(aiDocSuggestion)}
|
|
198
|
+
value={aiDocSuggestion ?? dataSpace.description ?? ''}
|
|
199
|
+
onChange={(event) => {
|
|
200
|
+
handleDescriptionChange(event.target.value);
|
|
201
|
+
}}
|
|
202
|
+
placeholder="Enter description"
|
|
203
|
+
/>
|
|
204
|
+
{aiDocSuggestion && (
|
|
205
|
+
<div className="dataSpace-editor__ai-suggestion__actions">
|
|
206
|
+
<button
|
|
207
|
+
className="btn btn--dark dataSpace-editor__ai-suggestion__apply-btn"
|
|
208
|
+
onClick={applyAIDocSuggestion}
|
|
209
|
+
title="Apply AI suggestion to description"
|
|
210
|
+
>
|
|
211
|
+
Apply Suggestion
|
|
212
|
+
</button>
|
|
213
|
+
<button
|
|
214
|
+
className="btn dataSpace-editor__ai-suggestion__dismiss-btn"
|
|
215
|
+
onClick={discardAIDocSuggestion}
|
|
216
|
+
title="Dismiss AI suggestion"
|
|
217
|
+
>
|
|
218
|
+
Dismiss
|
|
219
|
+
</button>
|
|
220
|
+
</div>
|
|
221
|
+
)}
|
|
222
|
+
</div>
|
|
68
223
|
<DataSpaceDefaultExecutionContextSection />
|
|
69
224
|
<DataSpaceDiagramsSection />
|
|
70
225
|
<DataSpaceElementsSection />
|
|
@@ -14,21 +14,12 @@
|
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
16
|
|
|
17
|
-
import {
|
|
18
|
-
action,
|
|
19
|
-
computed,
|
|
20
|
-
flow,
|
|
21
|
-
flowResult,
|
|
22
|
-
makeObservable,
|
|
23
|
-
observable,
|
|
24
|
-
} from 'mobx';
|
|
17
|
+
import { action, computed, makeObservable, observable } from 'mobx';
|
|
25
18
|
import {
|
|
26
19
|
type EditorStore,
|
|
27
|
-
DataProductEditorState,
|
|
28
20
|
ElementEditorState,
|
|
29
21
|
} from '@finos/legend-application-studio';
|
|
30
22
|
import {
|
|
31
|
-
type DataProduct,
|
|
32
23
|
type PackageableElement,
|
|
33
24
|
Package,
|
|
34
25
|
Class,
|
|
@@ -36,7 +27,6 @@ import {
|
|
|
36
27
|
Association,
|
|
37
28
|
Service,
|
|
38
29
|
ConcreteFunctionDefinition,
|
|
39
|
-
observe_DataProduct,
|
|
40
30
|
} from '@finos/legend-graph';
|
|
41
31
|
import { Diagram } from '@finos/legend-extension-dsl-diagram/graph';
|
|
42
32
|
import {
|
|
@@ -44,113 +34,8 @@ import {
|
|
|
44
34
|
DataSpacePackageableElementExecutable,
|
|
45
35
|
type DataSpaceElement,
|
|
46
36
|
} from '@finos/legend-extension-dsl-data-space/graph';
|
|
47
|
-
import {
|
|
48
|
-
assertErrorThrown,
|
|
49
|
-
guaranteeType,
|
|
50
|
-
type GeneratorFn,
|
|
51
|
-
} from '@finos/legend-shared';
|
|
37
|
+
import { guaranteeType } from '@finos/legend-shared';
|
|
52
38
|
import { DataSpaceExecutionContextState } from './DataSpaceExecutionContextState.js';
|
|
53
|
-
import {
|
|
54
|
-
convertDataSpaceToDataProduct,
|
|
55
|
-
convertDataSpaceToNativeModelAccess,
|
|
56
|
-
} from '../stores/DataSpaceToDataProductConverter.js';
|
|
57
|
-
import { DSL_DATA_SPACE_LEGEND_STUDIO_APPLICATION_LOGGING_CONTEXT_KEY } from '../__lib__/DSL_DataSpace_LegendStudioDocumentation.js';
|
|
58
|
-
|
|
59
|
-
export const onMergeDataSpaceToDataProduct = flow(function* (
|
|
60
|
-
dataSpace: DataSpace,
|
|
61
|
-
targetDataProduct: DataProduct,
|
|
62
|
-
editorStore: EditorStore,
|
|
63
|
-
dataSpaceEditorState: DataSpaceEditorState,
|
|
64
|
-
): GeneratorFn<void> {
|
|
65
|
-
try {
|
|
66
|
-
targetDataProduct.nativeModelAccess =
|
|
67
|
-
convertDataSpaceToNativeModelAccess(dataSpace);
|
|
68
|
-
|
|
69
|
-
editorStore.graphManagerState.graph.deleteElement(dataSpace);
|
|
70
|
-
|
|
71
|
-
const dataSpacePackage = dataSpace.package;
|
|
72
|
-
if (dataSpacePackage && dataSpacePackage.children.length === 0) {
|
|
73
|
-
editorStore.graphManagerState.graph.deleteElement(dataSpacePackage);
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
const dataProductEditorState = new DataProductEditorState(
|
|
77
|
-
editorStore,
|
|
78
|
-
targetDataProduct,
|
|
79
|
-
);
|
|
80
|
-
|
|
81
|
-
editorStore.tabManagerState.closeTab(dataSpaceEditorState);
|
|
82
|
-
editorStore.tabManagerState.openTab(dataProductEditorState);
|
|
83
|
-
yield flowResult(editorStore.explorerTreeState.build());
|
|
84
|
-
|
|
85
|
-
editorStore.applicationStore.notificationService.notifySuccess(
|
|
86
|
-
`Successfully merged DataSpace ${dataSpace.name} into Data Product ${targetDataProduct.path}`,
|
|
87
|
-
);
|
|
88
|
-
} catch (error) {
|
|
89
|
-
assertErrorThrown(error);
|
|
90
|
-
editorStore.applicationStore.notificationService.notifyError(
|
|
91
|
-
`Failed to merge DataSpace into Data Product: ${error.message}`,
|
|
92
|
-
);
|
|
93
|
-
}
|
|
94
|
-
});
|
|
95
|
-
|
|
96
|
-
export const onConvertDataSpaceToDataProduct = flow(function* (
|
|
97
|
-
dataSpace: DataSpace,
|
|
98
|
-
editorStore: EditorStore,
|
|
99
|
-
dataSpaceEditorState: DataSpaceEditorState,
|
|
100
|
-
): GeneratorFn<void> {
|
|
101
|
-
try {
|
|
102
|
-
const dataProduct = convertDataSpaceToDataProduct(
|
|
103
|
-
dataSpace,
|
|
104
|
-
editorStore.changeDetectionState.observerContext,
|
|
105
|
-
);
|
|
106
|
-
|
|
107
|
-
editorStore.graphManagerState.graph.deleteElement(dataSpace);
|
|
108
|
-
|
|
109
|
-
editorStore.graphManagerState.graph.addElement(
|
|
110
|
-
dataProduct,
|
|
111
|
-
dataSpace.package?.path.replace(/dataspace/, 'dataProduct'),
|
|
112
|
-
);
|
|
113
|
-
|
|
114
|
-
const dataSpacePackage = dataSpace.package;
|
|
115
|
-
if (dataSpacePackage && dataSpacePackage.children.length === 0) {
|
|
116
|
-
editorStore.graphManagerState.graph.deleteElement(dataSpacePackage);
|
|
117
|
-
}
|
|
118
|
-
const addedElement = editorStore.graphManagerState.graph.getNullableElement(
|
|
119
|
-
dataProduct.path,
|
|
120
|
-
);
|
|
121
|
-
if (addedElement) {
|
|
122
|
-
observe_DataProduct(
|
|
123
|
-
addedElement as DataProduct,
|
|
124
|
-
editorStore.changeDetectionState.observerContext,
|
|
125
|
-
);
|
|
126
|
-
}
|
|
127
|
-
const dataProductEditorState = new DataProductEditorState(
|
|
128
|
-
editorStore,
|
|
129
|
-
addedElement as DataProduct,
|
|
130
|
-
);
|
|
131
|
-
|
|
132
|
-
editorStore.tabManagerState.closeTab(dataSpaceEditorState);
|
|
133
|
-
editorStore.tabManagerState.openTab(dataProductEditorState);
|
|
134
|
-
yield flowResult(editorStore.explorerTreeState.build());
|
|
135
|
-
editorStore.applicationStore.telemetryService.logEvent(
|
|
136
|
-
DSL_DATA_SPACE_LEGEND_STUDIO_APPLICATION_LOGGING_CONTEXT_KEY.CONVERT_DATA_SPACE_TO_DATA_PRODUCT,
|
|
137
|
-
{
|
|
138
|
-
sourceInfo: editorStore.editorMode.getSourceInfo(),
|
|
139
|
-
dataSpacePath: dataSpace.path,
|
|
140
|
-
dataProductPath: dataProduct.path,
|
|
141
|
-
},
|
|
142
|
-
);
|
|
143
|
-
|
|
144
|
-
editorStore.applicationStore.notificationService.notifySuccess(
|
|
145
|
-
`Successfully converted DataSpace ${dataSpace.name} to Data Product`,
|
|
146
|
-
);
|
|
147
|
-
} catch (error) {
|
|
148
|
-
assertErrorThrown(error);
|
|
149
|
-
editorStore.applicationStore.notificationService.notifyError(
|
|
150
|
-
`Failed to convert DataSpace to Data Product: ${error.message}`,
|
|
151
|
-
);
|
|
152
|
-
}
|
|
153
|
-
});
|
|
154
39
|
|
|
155
40
|
export class DataSpaceEditorState extends ElementEditorState {
|
|
156
41
|
executionContextState: DataSpaceExecutionContextState;
|
package/tsconfig.json
CHANGED
|
@@ -58,7 +58,6 @@
|
|
|
58
58
|
"./src/stores/DataSpaceExecutionContextState.ts",
|
|
59
59
|
"./src/stores/DataSpacePreviewState.ts",
|
|
60
60
|
"./src/stores/DataSpaceTemplateQueryPromotionReviewerStore.ts",
|
|
61
|
-
"./src/stores/DataSpaceToDataProductConverter.ts",
|
|
62
61
|
"./src/stores/studio/DSL_DataSpace_GraphModifierHelper.ts",
|
|
63
62
|
"./src/components/DSL_DataProduct_ElementDriver.tsx",
|
|
64
63
|
"./src/components/DSL_DataSpace_LegendStudioApplicationPlugin.tsx",
|
|
@@ -1,29 +0,0 @@
|
|
|
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
|
-
import { type DataSpace } from '@finos/legend-extension-dsl-data-space/graph';
|
|
17
|
-
import { DataProduct, NativeModelAccess, ObserverContext } from '@finos/legend-graph';
|
|
18
|
-
export declare enum DATA_PRODUCT_SUPPORT_TYPE {
|
|
19
|
-
DOCUMENTATION = "Documentation",
|
|
20
|
-
SUPPORT = "Support",
|
|
21
|
-
WEBSITE = "Website",
|
|
22
|
-
FAQ = "FAQ"
|
|
23
|
-
}
|
|
24
|
-
export declare const DATA_PRODUCT_DEFAULT_TITLE = "DataProduct Auto Generated title: Please update";
|
|
25
|
-
export declare const DATA_PRODUCT_DEFAULT_DESCRIPTION_PREFIX = "Migrated using studio converter from dataspace: ";
|
|
26
|
-
export declare const DATA_PRODUCT_NATIVE_MODEL_ACCESS_SAMPLE_QUERY_ID_PREFIX = "DATA_PRODUCT_NATIVE_MODEL_ACCESS_SAMPLE_QUERY_ID";
|
|
27
|
-
export declare const convertDataSpaceToNativeModelAccess: (dataSpace: DataSpace) => NativeModelAccess;
|
|
28
|
-
export declare const convertDataSpaceToDataProduct: (dataSpace: DataSpace, observerContext?: ObserverContext) => DataProduct;
|
|
29
|
-
//# sourceMappingURL=DataSpaceToDataProductConverter.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"DataSpaceToDataProductConverter.d.ts","sourceRoot":"","sources":["../../src/stores/DataSpaceToDataProductConverter.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EACL,KAAK,SAAS,EAKf,MAAM,8CAA8C,CAAC;AACtD,OAAO,EACL,WAAW,EAUX,iBAAiB,EAGjB,eAAe,EAChB,MAAM,qBAAqB,CAAC;AAM7B,oBAAY,yBAAyB;IACnC,aAAa,kBAAkB;IAC/B,OAAO,YAAY;IACnB,OAAO,YAAY;IACnB,GAAG,QAAQ;CACZ;AAED,eAAO,MAAM,0BAA0B,oDACY,CAAC;AACpD,eAAO,MAAM,uCAAuC,qDACA,CAAC;AACrD,eAAO,MAAM,uDAAuD,qDAChB,CAAC;AA2IrD,eAAO,MAAM,mCAAmC,GAC9C,WAAW,SAAS,KACnB,iBAoBF,CAAC;AAEF,eAAO,MAAM,6BAA6B,GACxC,WAAW,SAAS,EACpB,kBAAiB,eAAyC,KACzD,WAgBF,CAAC"}
|