@finos/legend-application-studio 28.18.124 → 28.18.126
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__/LegendStudioNavigation.d.ts +7 -0
- package/lib/__lib__/LegendStudioNavigation.d.ts.map +1 -1
- package/lib/__lib__/LegendStudioNavigation.js +5 -0
- package/lib/__lib__/LegendStudioNavigation.js.map +1 -1
- package/lib/application/LegendIngestionConfiguration.d.ts +40 -0
- package/lib/application/LegendIngestionConfiguration.d.ts.map +1 -0
- package/lib/application/LegendIngestionConfiguration.js +57 -0
- package/lib/application/LegendIngestionConfiguration.js.map +1 -0
- package/lib/application/LegendStudioApplicationConfig.d.ts +2 -0
- package/lib/application/LegendStudioApplicationConfig.d.ts.map +1 -1
- package/lib/application/LegendStudioApplicationConfig.js +6 -0
- package/lib/application/LegendStudioApplicationConfig.js.map +1 -1
- package/lib/components/ElementIconUtils.d.ts.map +1 -1
- package/lib/components/ElementIconUtils.js +3 -1
- package/lib/components/ElementIconUtils.js.map +1 -1
- package/lib/components/LegendStudioWebApplication.d.ts.map +1 -1
- package/lib/components/LegendStudioWebApplication.js +16 -0
- package/lib/components/LegendStudioWebApplication.js.map +1 -1
- package/lib/components/editor/Editor.d.ts.map +1 -1
- package/lib/components/editor/Editor.js +3 -2
- package/lib/components/editor/Editor.js.map +1 -1
- package/lib/components/editor/editor-group/EditorGroup.d.ts.map +1 -1
- package/lib/components/editor/editor-group/EditorGroup.js +5 -0
- package/lib/components/editor/editor-group/EditorGroup.js.map +1 -1
- package/lib/components/editor/editor-group/function-activator/SnowflakeAppFunctionActivatorEditor.d.ts.map +1 -1
- package/lib/components/editor/editor-group/function-activator/SnowflakeAppFunctionActivatorEditor.js +1 -1
- package/lib/components/editor/editor-group/function-activator/SnowflakeAppFunctionActivatorEditor.js.map +1 -1
- package/lib/components/editor/editor-group/ingest-editor/IngestDefinitionEditor.d.ts +19 -0
- package/lib/components/editor/editor-group/ingest-editor/IngestDefinitionEditor.d.ts.map +1 -0
- package/lib/components/editor/editor-group/ingest-editor/IngestDefinitionEditor.js +85 -0
- package/lib/components/editor/editor-group/ingest-editor/IngestDefinitionEditor.js.map +1 -0
- package/lib/components/lazy-text-editor/LazyTextEditor.js +1 -1
- package/lib/components/lazy-text-editor/LazyTextEditor.js.map +1 -1
- package/lib/index.css +1 -1
- package/lib/package.json +3 -1
- package/lib/stores/editor/EditorGraphState.d.ts.map +1 -1
- package/lib/stores/editor/EditorGraphState.js +4 -1
- package/lib/stores/editor/EditorGraphState.js.map +1 -1
- package/lib/stores/editor/EditorStore.d.ts +6 -2
- package/lib/stores/editor/EditorStore.d.ts.map +1 -1
- package/lib/stores/editor/EditorStore.js +21 -4
- package/lib/stores/editor/EditorStore.js.map +1 -1
- package/lib/stores/editor/EditorTabManagerState.d.ts +2 -1
- package/lib/stores/editor/EditorTabManagerState.d.ts.map +1 -1
- package/lib/stores/editor/EditorTabManagerState.js +6 -2
- package/lib/stores/editor/EditorTabManagerState.js.map +1 -1
- package/lib/stores/editor/GraphEditFormModeState.d.ts +2 -1
- package/lib/stores/editor/GraphEditFormModeState.d.ts.map +1 -1
- package/lib/stores/editor/GraphEditFormModeState.js +2 -2
- package/lib/stores/editor/GraphEditFormModeState.js.map +1 -1
- package/lib/stores/editor/GraphEditorMode.d.ts +2 -1
- package/lib/stores/editor/GraphEditorMode.d.ts.map +1 -1
- package/lib/stores/editor/GraphEditorMode.js.map +1 -1
- package/lib/stores/editor/editor-state/element-editor-state/ElementEditorInitialConfiguration.d.ts +30 -0
- package/lib/stores/editor/editor-state/element-editor-state/ElementEditorInitialConfiguration.d.ts.map +1 -0
- package/lib/stores/editor/editor-state/element-editor-state/ElementEditorInitialConfiguration.js +50 -0
- package/lib/stores/editor/editor-state/element-editor-state/ElementEditorInitialConfiguration.js.map +1 -0
- package/lib/stores/editor/editor-state/element-editor-state/ElementEditorState.d.ts +2 -1
- package/lib/stores/editor/editor-state/element-editor-state/ElementEditorState.d.ts.map +1 -1
- package/lib/stores/editor/editor-state/element-editor-state/ElementEditorState.js +1 -1
- package/lib/stores/editor/editor-state/element-editor-state/ElementEditorState.js.map +1 -1
- package/lib/stores/editor/editor-state/element-editor-state/function-activator/SnowflakeAppFunctionActivatorEditorState.d.ts +1 -0
- package/lib/stores/editor/editor-state/element-editor-state/function-activator/SnowflakeAppFunctionActivatorEditorState.d.ts.map +1 -1
- package/lib/stores/editor/editor-state/element-editor-state/function-activator/SnowflakeAppFunctionActivatorEditorState.js +4 -0
- package/lib/stores/editor/editor-state/element-editor-state/function-activator/SnowflakeAppFunctionActivatorEditorState.js.map +1 -1
- package/lib/stores/editor/editor-state/element-editor-state/ingest/IngestDefinitionEditorState.d.ts +40 -0
- package/lib/stores/editor/editor-state/element-editor-state/ingest/IngestDefinitionEditorState.d.ts.map +1 -0
- package/lib/stores/editor/editor-state/element-editor-state/ingest/IngestDefinitionEditorState.js +119 -0
- package/lib/stores/editor/editor-state/element-editor-state/ingest/IngestDefinitionEditorState.js.map +1 -0
- package/lib/stores/editor/utils/ModelClassifierUtils.d.ts +2 -1
- package/lib/stores/editor/utils/ModelClassifierUtils.d.ts.map +1 -1
- package/lib/stores/editor/utils/ModelClassifierUtils.js +1 -0
- package/lib/stores/editor/utils/ModelClassifierUtils.js.map +1 -1
- package/lib/stores/ingestion/IngestDeploymentServerClient.d.ts +29 -0
- package/lib/stores/ingestion/IngestDeploymentServerClient.d.ts.map +1 -0
- package/lib/stores/ingestion/IngestDeploymentServerClient.js +49 -0
- package/lib/stores/ingestion/IngestDeploymentServerClient.js.map +1 -0
- package/lib/stores/ingestion/IngestDiscoveryServerClient.d.ts +26 -0
- package/lib/stores/ingestion/IngestDiscoveryServerClient.d.ts.map +1 -0
- package/lib/stores/ingestion/IngestDiscoveryServerClient.js +35 -0
- package/lib/stores/ingestion/IngestDiscoveryServerClient.js.map +1 -0
- package/lib/stores/ingestion/IngestionDeploymentResponse.d.ts +40 -0
- package/lib/stores/ingestion/IngestionDeploymentResponse.d.ts.map +1 -0
- package/lib/stores/ingestion/IngestionDeploymentResponse.js +55 -0
- package/lib/stores/ingestion/IngestionDeploymentResponse.js.map +1 -0
- package/lib/stores/ingestion/IngestionManager.d.ts +35 -0
- package/lib/stores/ingestion/IngestionManager.d.ts.map +1 -0
- package/lib/stores/ingestion/IngestionManager.js +83 -0
- package/lib/stores/ingestion/IngestionManager.js.map +1 -0
- package/package.json +10 -8
- package/src/__lib__/LegendStudioNavigation.ts +14 -0
- package/src/application/LegendIngestionConfiguration.ts +94 -0
- package/src/application/LegendStudioApplicationConfig.ts +15 -0
- package/src/components/ElementIconUtils.tsx +3 -0
- package/src/components/LegendStudioWebApplication.tsx +29 -0
- package/src/components/editor/Editor.tsx +8 -3
- package/src/components/editor/editor-group/EditorGroup.tsx +4 -1
- package/src/components/editor/editor-group/function-activator/SnowflakeAppFunctionActivatorEditor.tsx +11 -0
- package/src/components/editor/editor-group/ingest-editor/IngestDefinitionEditor.tsx +214 -0
- package/src/components/lazy-text-editor/LazyTextEditor.tsx +1 -1
- package/src/stores/editor/EditorGraphState.ts +3 -0
- package/src/stores/editor/EditorStore.ts +39 -1
- package/src/stores/editor/EditorTabManagerState.ts +6 -0
- package/src/stores/editor/GraphEditFormModeState.ts +9 -2
- package/src/stores/editor/GraphEditorMode.ts +5 -1
- package/src/stores/editor/editor-state/element-editor-state/ElementEditorInitialConfiguration.ts +97 -0
- package/src/stores/editor/editor-state/element-editor-state/ElementEditorState.ts +6 -1
- package/src/stores/editor/editor-state/element-editor-state/function-activator/SnowflakeAppFunctionActivatorEditorState.ts +5 -0
- package/src/stores/editor/editor-state/element-editor-state/ingest/IngestDefinitionEditorState.ts +184 -0
- package/src/stores/editor/utils/ModelClassifierUtils.ts +1 -0
- package/src/stores/ingestion/IngestDeploymentServerClient.ts +83 -0
- package/src/stores/ingestion/IngestDiscoveryServerClient.ts +52 -0
- package/src/stores/ingestion/IngestionDeploymentResponse.ts +73 -0
- package/src/stores/ingestion/IngestionManager.ts +163 -0
- package/tsconfig.json +8 -0
@@ -56,6 +56,7 @@ import {
|
|
56
56
|
AssertionError,
|
57
57
|
guaranteeType,
|
58
58
|
type Clazz,
|
59
|
+
returnUndefOnError,
|
59
60
|
} from '@finos/legend-shared';
|
60
61
|
import { EditorSDLCState } from './EditorSDLCState.js';
|
61
62
|
import { ModelImporterState } from './editor-state/ModelImporterState.js';
|
@@ -69,6 +70,8 @@ import {
|
|
69
70
|
generateEditorRoute,
|
70
71
|
generateSetupRoute,
|
71
72
|
generateViewProjectRoute,
|
73
|
+
LEGEND_STUDIO_QUERY_PARAMS,
|
74
|
+
type StudioQueryParams,
|
72
75
|
type WorkspaceEditorPathParams,
|
73
76
|
} from '../../__lib__/LegendStudioNavigation.js';
|
74
77
|
import { PanelDisplayState } from '@finos/legend-art';
|
@@ -118,6 +121,8 @@ import {
|
|
118
121
|
LazyTextEditorStore,
|
119
122
|
} from '../lazy-text-editor/LazyTextEditorStore.js';
|
120
123
|
import type { QueryBuilderDataCubeViewerState } from '@finos/legend-query-builder';
|
124
|
+
import { IngestionManager } from '../ingestion/IngestionManager.js';
|
125
|
+
import { EditorInitialConfiguration } from './editor-state/element-editor-state/ElementEditorInitialConfiguration.js';
|
121
126
|
|
122
127
|
export abstract class EditorExtensionState {
|
123
128
|
/**
|
@@ -133,6 +138,7 @@ export class EditorStore implements CommandRegistrar {
|
|
133
138
|
readonly applicationStore: LegendStudioApplicationStore;
|
134
139
|
readonly sdlcServerClient: SDLCServerClient;
|
135
140
|
readonly depotServerClient: DepotServerClient;
|
141
|
+
readonly ingestionManager: IngestionManager | undefined;
|
136
142
|
readonly pluginManager: LegendStudioPluginManager;
|
137
143
|
|
138
144
|
/**
|
@@ -145,6 +151,7 @@ export class EditorStore implements CommandRegistrar {
|
|
145
151
|
readonly initState = ActionState.create();
|
146
152
|
|
147
153
|
initialEntityPath?: string | undefined;
|
154
|
+
editorConfig: EditorInitialConfiguration | undefined;
|
148
155
|
editorMode: EditorMode;
|
149
156
|
// NOTE: once we clear up the editor store to make modes more separated
|
150
157
|
// we should remove these sets of functions. They are basically hacks to
|
@@ -303,6 +310,16 @@ export class EditorStore implements CommandRegistrar {
|
|
303
310
|
this,
|
304
311
|
this.sdlcState,
|
305
312
|
);
|
313
|
+
// ingestion
|
314
|
+
const ingestionConifg =
|
315
|
+
applicationStore.config.options.ingestDeploymentConfig;
|
316
|
+
if (ingestionConifg) {
|
317
|
+
this.ingestionManager = new IngestionManager(
|
318
|
+
ingestionConifg,
|
319
|
+
this.applicationStore,
|
320
|
+
);
|
321
|
+
}
|
322
|
+
|
306
323
|
// extensions
|
307
324
|
this.extensionStates = this.pluginManager
|
308
325
|
.getApplicationPlugins()
|
@@ -549,17 +566,35 @@ export class EditorStore implements CommandRegistrar {
|
|
549
566
|
this.explorerTreeState = new ExplorerTreeState(this);
|
550
567
|
}
|
551
568
|
|
552
|
-
internalizeEntityPath(
|
569
|
+
internalizeEntityPath(
|
570
|
+
params: Partial<WorkspaceEditorPathParams>,
|
571
|
+
studioParams: Partial<StudioQueryParams> | undefined,
|
572
|
+
): void {
|
553
573
|
const { projectId, entityPath } = params;
|
554
574
|
const workspaceType = params.groupWorkspaceId
|
555
575
|
? WorkspaceType.GROUP
|
556
576
|
: WorkspaceType.USER;
|
577
|
+
const editorConfig =
|
578
|
+
studioParams?.[LEGEND_STUDIO_QUERY_PARAMS.EDITOR_CONFIG];
|
557
579
|
const workspaceId = guaranteeNonNullable(
|
558
580
|
params.groupWorkspaceId ?? params.workspaceId,
|
559
581
|
`Workspace/group workspace ID is not provided`,
|
560
582
|
);
|
561
583
|
if (entityPath) {
|
562
584
|
this.initialEntityPath = entityPath;
|
585
|
+
if (editorConfig) {
|
586
|
+
const _config = returnUndefOnError(() =>
|
587
|
+
EditorInitialConfiguration.serialization.fromJson(
|
588
|
+
JSON.parse(atob(editorConfig)),
|
589
|
+
),
|
590
|
+
);
|
591
|
+
const config = guaranteeNonNullable(
|
592
|
+
_config,
|
593
|
+
`error reading and serializing config ${editorConfig}`,
|
594
|
+
);
|
595
|
+
|
596
|
+
this.editorConfig = config;
|
597
|
+
}
|
563
598
|
this.applicationStore.navigationService.navigator.updateCurrentLocation(
|
564
599
|
generateEditorRoute(
|
565
600
|
guaranteeNonNullable(projectId),
|
@@ -1031,7 +1066,10 @@ export class EditorStore implements CommandRegistrar {
|
|
1031
1066
|
try {
|
1032
1067
|
this.graphEditorMode.openElement(
|
1033
1068
|
this.graphManagerState.graph.getElement(this.initialEntityPath),
|
1069
|
+
this.editorConfig,
|
1034
1070
|
);
|
1071
|
+
// we may not want to set as undefined if using it for other things
|
1072
|
+
this.editorConfig = undefined;
|
1035
1073
|
} catch {
|
1036
1074
|
const elementPath = this.initialEntityPath;
|
1037
1075
|
this.initialEntityPath = undefined;
|
@@ -36,6 +36,7 @@ import {
|
|
36
36
|
SnowflakeApp,
|
37
37
|
HostedService,
|
38
38
|
DataProduct,
|
39
|
+
IngestDefinition,
|
39
40
|
} from '@finos/legend-graph';
|
40
41
|
import {
|
41
42
|
type Clazz,
|
@@ -66,6 +67,8 @@ import { SnowflakeAppFunctionActivatorEdtiorState } from './editor-state/element
|
|
66
67
|
import { HostedServiceFunctionActivatorEditorState } from './editor-state/element-editor-state/function-activator/HostedServiceFunctionActivatorEditorState.js';
|
67
68
|
import { ArtifactGenerationViewerState } from './editor-state/ArtifactGenerationViewerState.js';
|
68
69
|
import { DataProductEditorState } from './editor-state/element-editor-state/dataProduct/DataProductEditorState.js';
|
70
|
+
import { IngestDefinitionEditorState } from './editor-state/element-editor-state/ingest/IngestDefinitionEditorState.js';
|
71
|
+
import type { EditorInitialConfiguration } from './editor-state/element-editor-state/ElementEditorInitialConfiguration.js';
|
69
72
|
|
70
73
|
export class EditorTabManagerState extends TabManagerState {
|
71
74
|
readonly editorStore: EditorStore;
|
@@ -146,6 +149,7 @@ export class EditorTabManagerState extends TabManagerState {
|
|
146
149
|
|
147
150
|
createElementEditorState(
|
148
151
|
element: PackageableElement,
|
152
|
+
config?: EditorInitialConfiguration,
|
149
153
|
): ElementEditorState | undefined {
|
150
154
|
if (element instanceof PrimitiveType) {
|
151
155
|
throw new UnsupportedOperationError(
|
@@ -173,6 +177,8 @@ export class EditorTabManagerState extends TabManagerState {
|
|
173
177
|
return new PackageableConnectionEditorState(this.editorStore, element);
|
174
178
|
} else if (element instanceof Mapping) {
|
175
179
|
return new MappingEditorState(this.editorStore, element);
|
180
|
+
} else if (element instanceof IngestDefinition) {
|
181
|
+
return new IngestDefinitionEditorState(this.editorStore, element, config);
|
176
182
|
} else if (element instanceof Service) {
|
177
183
|
return new ServiceEditorState(this.editorStore, element);
|
178
184
|
} else if (element instanceof DataProduct) {
|
@@ -55,6 +55,7 @@ import { ElementEditorState } from './editor-state/element-editor-state/ElementE
|
|
55
55
|
import { LegendStudioTelemetryHelper } from '../../__lib__/LegendStudioTelemetryHelper.js';
|
56
56
|
import { GraphEditorMode } from './GraphEditorMode.js';
|
57
57
|
import { GlobalBulkServiceRegistrationState } from './sidebar-state/BulkServiceRegistrationState.js';
|
58
|
+
import type { EditorInitialConfiguration } from './editor-state/element-editor-state/ElementEditorInitialConfiguration.js';
|
58
59
|
|
59
60
|
export class GraphEditFormModeState extends GraphEditorMode {
|
60
61
|
*initialize(): GeneratorFn<void> {
|
@@ -567,7 +568,10 @@ export class GraphEditFormModeState extends GraphEditorMode {
|
|
567
568
|
return;
|
568
569
|
}
|
569
570
|
|
570
|
-
openElement(
|
571
|
+
openElement(
|
572
|
+
element: PackageableElement,
|
573
|
+
config?: EditorInitialConfiguration | undefined,
|
574
|
+
): void {
|
571
575
|
if (!(element instanceof Package)) {
|
572
576
|
const existingElementState = this.editorStore.tabManagerState.tabs.find(
|
573
577
|
(state) =>
|
@@ -575,7 +579,10 @@ export class GraphEditFormModeState extends GraphEditorMode {
|
|
575
579
|
);
|
576
580
|
const newTab =
|
577
581
|
existingElementState ??
|
578
|
-
this.editorStore.tabManagerState.createElementEditorState(
|
582
|
+
this.editorStore.tabManagerState.createElementEditorState(
|
583
|
+
element,
|
584
|
+
config,
|
585
|
+
);
|
579
586
|
if (newTab) {
|
580
587
|
this.editorStore.tabManagerState.openTab(newTab);
|
581
588
|
} else {
|
@@ -22,6 +22,7 @@ import type { EditorStore } from './EditorStore.js';
|
|
22
22
|
|
23
23
|
import type { GRAPH_EDITOR_MODE } from './EditorConfig.js';
|
24
24
|
import type { Problem } from './EditorGraphState.js';
|
25
|
+
import type { EditorInitialConfiguration } from './editor-state/element-editor-state/ElementEditorInitialConfiguration.js';
|
25
26
|
|
26
27
|
export abstract class GraphEditorMode {
|
27
28
|
readonly editorStore: EditorStore;
|
@@ -81,5 +82,8 @@ export abstract class GraphEditorMode {
|
|
81
82
|
isGraphBuildFailure?: boolean;
|
82
83
|
}): GeneratorFn<void>;
|
83
84
|
abstract handleCleanupFailure(error: unknown): GeneratorFn<void>;
|
84
|
-
abstract openElement(
|
85
|
+
abstract openElement(
|
86
|
+
element: PackageableElement,
|
87
|
+
config?: EditorInitialConfiguration | undefined,
|
88
|
+
): void;
|
85
89
|
}
|
package/src/stores/editor/editor-state/element-editor-state/ElementEditorInitialConfiguration.ts
ADDED
@@ -0,0 +1,97 @@
|
|
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
|
+
SerializationFactory,
|
19
|
+
UnsupportedOperationError,
|
20
|
+
usingConstantValueSchema,
|
21
|
+
type PlainObject,
|
22
|
+
} from '@finos/legend-shared';
|
23
|
+
import { PACKAGEABLE_ELEMENT_TYPE } from '../../utils/ModelClassifierUtils.js';
|
24
|
+
import {
|
25
|
+
createModelSchema,
|
26
|
+
custom,
|
27
|
+
deserialize,
|
28
|
+
optional,
|
29
|
+
primitive,
|
30
|
+
serialize,
|
31
|
+
} from 'serializr';
|
32
|
+
|
33
|
+
export abstract class ElementEditorInitialConfiguration {
|
34
|
+
abstract type: PACKAGEABLE_ELEMENT_TYPE;
|
35
|
+
}
|
36
|
+
|
37
|
+
export class IngestElementEditorInitialConfiguration extends ElementEditorInitialConfiguration {
|
38
|
+
deployOnOpen?: boolean;
|
39
|
+
type = PACKAGEABLE_ELEMENT_TYPE.INGEST_DEFINITION;
|
40
|
+
|
41
|
+
static readonly serialization = new SerializationFactory(
|
42
|
+
createModelSchema(IngestElementEditorInitialConfiguration, {
|
43
|
+
_type: usingConstantValueSchema(
|
44
|
+
PACKAGEABLE_ELEMENT_TYPE.INGEST_DEFINITION,
|
45
|
+
),
|
46
|
+
deployOnOpen: optional(primitive()),
|
47
|
+
}),
|
48
|
+
);
|
49
|
+
}
|
50
|
+
|
51
|
+
const serializeElementEditorInitialConfiguration = (
|
52
|
+
protocol: ElementEditorInitialConfiguration,
|
53
|
+
): PlainObject<ElementEditorInitialConfiguration> => {
|
54
|
+
if (protocol instanceof IngestElementEditorInitialConfiguration) {
|
55
|
+
return serialize(
|
56
|
+
IngestElementEditorInitialConfiguration.serialization.schema,
|
57
|
+
protocol,
|
58
|
+
);
|
59
|
+
}
|
60
|
+
throw new UnsupportedOperationError(
|
61
|
+
`Can't serialize element config`,
|
62
|
+
protocol,
|
63
|
+
);
|
64
|
+
};
|
65
|
+
|
66
|
+
const deseralizeElementEditorInitialConfiguration = (
|
67
|
+
json: PlainObject<ElementEditorInitialConfiguration>,
|
68
|
+
): ElementEditorInitialConfiguration => {
|
69
|
+
switch (json._type) {
|
70
|
+
case PACKAGEABLE_ELEMENT_TYPE.INGEST_DEFINITION:
|
71
|
+
return deserialize(
|
72
|
+
IngestElementEditorInitialConfiguration.serialization.schema,
|
73
|
+
json,
|
74
|
+
);
|
75
|
+
default: {
|
76
|
+
throw new UnsupportedOperationError(
|
77
|
+
`Can't deserialize element config`,
|
78
|
+
json,
|
79
|
+
);
|
80
|
+
}
|
81
|
+
}
|
82
|
+
};
|
83
|
+
|
84
|
+
export class EditorInitialConfiguration {
|
85
|
+
elementEditorConfiguration?: ElementEditorInitialConfiguration;
|
86
|
+
|
87
|
+
static readonly serialization = new SerializationFactory(
|
88
|
+
createModelSchema(EditorInitialConfiguration, {
|
89
|
+
elementEditorConfiguration: optional(
|
90
|
+
custom(
|
91
|
+
serializeElementEditorInitialConfiguration,
|
92
|
+
deseralizeElementEditorInitialConfiguration,
|
93
|
+
),
|
94
|
+
),
|
95
|
+
}),
|
96
|
+
);
|
97
|
+
}
|
@@ -36,6 +36,7 @@ import {
|
|
36
36
|
import { DEFAULT_TAB_SIZE } from '@finos/legend-application';
|
37
37
|
import type { ElementFileGenerationState } from './ElementFileGenerationState.js';
|
38
38
|
import type { ElementXTSchemaGenerationState } from './ElementExternalFormatGenerationState.js';
|
39
|
+
import type { EditorInitialConfiguration } from './ElementEditorInitialConfiguration.js';
|
39
40
|
|
40
41
|
const generateMultiLineCommentForError = (
|
41
42
|
message: string,
|
@@ -104,7 +105,11 @@ export abstract class ElementEditorState extends EditorState {
|
|
104
105
|
textContent = '';
|
105
106
|
isReadOnly = false;
|
106
107
|
|
107
|
-
constructor(
|
108
|
+
constructor(
|
109
|
+
editorStore: EditorStore,
|
110
|
+
element: PackageableElement,
|
111
|
+
config?: EditorInitialConfiguration | undefined,
|
112
|
+
) {
|
108
113
|
super(editorStore);
|
109
114
|
|
110
115
|
makeObservable(this, {
|
@@ -48,6 +48,7 @@ export class SnowflakeAppFunctionActivatorEdtiorState extends ElementEditorState
|
|
48
48
|
reprocess: action,
|
49
49
|
updateOwnership: action,
|
50
50
|
updateUsageRole: action,
|
51
|
+
updateDeploymentSchema: action,
|
51
52
|
updatePermissionScopte: action,
|
52
53
|
updateAppDescription: action,
|
53
54
|
updateApplicationName: action,
|
@@ -88,6 +89,10 @@ export class SnowflakeAppFunctionActivatorEdtiorState extends ElementEditorState
|
|
88
89
|
this.activator.usageRole = val;
|
89
90
|
}
|
90
91
|
|
92
|
+
updateDeploymentSchema(val: string | undefined): void {
|
93
|
+
this.activator.deploymentSchema = val;
|
94
|
+
}
|
95
|
+
|
91
96
|
updatePermissionScopte(val: SnowflakePermissionScheme): void {
|
92
97
|
this.activator.permissionScheme = val;
|
93
98
|
}
|
package/src/stores/editor/editor-state/element-editor-state/ingest/IngestDefinitionEditorState.ts
ADDED
@@ -0,0 +1,184 @@
|
|
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 { IngestDefinition, type PackageableElement } from '@finos/legend-graph';
|
18
|
+
import { ElementEditorState } from '../ElementEditorState.js';
|
19
|
+
import type { EditorStore } from '../../../EditorStore.js';
|
20
|
+
import {
|
21
|
+
ActionState,
|
22
|
+
assertErrorThrown,
|
23
|
+
assertTrue,
|
24
|
+
guaranteeNonNullable,
|
25
|
+
guaranteeType,
|
26
|
+
type GeneratorFn,
|
27
|
+
} from '@finos/legend-shared';
|
28
|
+
import type { IngestionManager } from '../../../../ingestion/IngestionManager.js';
|
29
|
+
import { action, flow, flowResult, makeObservable, observable } from 'mobx';
|
30
|
+
import type {
|
31
|
+
IngestDefinitionValidationResponse,
|
32
|
+
ValidateAndDeploymentResponse,
|
33
|
+
} from '../../../../ingestion/IngestionDeploymentResponse.js';
|
34
|
+
import {
|
35
|
+
EditorInitialConfiguration,
|
36
|
+
IngestElementEditorInitialConfiguration,
|
37
|
+
} from '../ElementEditorInitialConfiguration.js';
|
38
|
+
import type { AuthContextProps } from 'react-oidc-context';
|
39
|
+
import { EXTERNAL_APPLICATION_NAVIGATION__generateUrlWithEditorConfig } from '../../../../../__lib__/LegendStudioNavigation.js';
|
40
|
+
|
41
|
+
const createEditorInitialConfiguration = (): EditorInitialConfiguration => {
|
42
|
+
const config = new EditorInitialConfiguration();
|
43
|
+
const ingest = new IngestElementEditorInitialConfiguration();
|
44
|
+
ingest.deployOnOpen = true;
|
45
|
+
config.elementEditorConfiguration = ingest;
|
46
|
+
return config;
|
47
|
+
};
|
48
|
+
|
49
|
+
const editorInitialConfigToBase64 = (val: EditorInitialConfiguration): string =>
|
50
|
+
btoa(JSON.stringify(EditorInitialConfiguration.serialization.toJson(val)));
|
51
|
+
|
52
|
+
export const generateUrlToDeployOnOpen = (
|
53
|
+
val: IngestDefinitionEditorState,
|
54
|
+
): string => {
|
55
|
+
return val.editorStore.applicationStore.navigationService.navigator.generateAddress(
|
56
|
+
EXTERNAL_APPLICATION_NAVIGATION__generateUrlWithEditorConfig(
|
57
|
+
val.editorStore.editorMode.generateElementLink(val.ingest.path),
|
58
|
+
editorInitialConfigToBase64(createEditorInitialConfiguration()),
|
59
|
+
),
|
60
|
+
);
|
61
|
+
};
|
62
|
+
export class IngestDefinitionEditorState extends ElementEditorState {
|
63
|
+
validationError: IngestDefinitionValidationResponse | undefined;
|
64
|
+
deploymentState = ActionState.create();
|
65
|
+
deployOnOpen = false;
|
66
|
+
|
67
|
+
constructor(
|
68
|
+
editorStore: EditorStore,
|
69
|
+
element: PackageableElement,
|
70
|
+
config?: EditorInitialConfiguration,
|
71
|
+
) {
|
72
|
+
super(editorStore, element);
|
73
|
+
|
74
|
+
makeObservable(this, {
|
75
|
+
deploymentState: observable,
|
76
|
+
deployOnOpen: observable,
|
77
|
+
setDeployOnOpen: observable,
|
78
|
+
validationError: observable,
|
79
|
+
setValError: action,
|
80
|
+
init_with_deploy: flow,
|
81
|
+
deploy: flow,
|
82
|
+
});
|
83
|
+
const elementConfig = config?.elementEditorConfiguration;
|
84
|
+
if (elementConfig instanceof IngestElementEditorInitialConfiguration) {
|
85
|
+
this.deployOnOpen = elementConfig.deployOnOpen ?? false;
|
86
|
+
}
|
87
|
+
}
|
88
|
+
|
89
|
+
get ingestionManager(): IngestionManager | undefined {
|
90
|
+
return this.editorStore.ingestionManager;
|
91
|
+
}
|
92
|
+
|
93
|
+
setValError(val: IngestDefinitionValidationResponse | undefined): void {
|
94
|
+
this.validationError = val;
|
95
|
+
}
|
96
|
+
|
97
|
+
setDeployOnOpen(value: boolean): void {
|
98
|
+
this.deployOnOpen = value;
|
99
|
+
}
|
100
|
+
|
101
|
+
*init_with_deploy(auth: AuthContextProps): GeneratorFn<void> {
|
102
|
+
this.setDeployOnOpen(false);
|
103
|
+
if (!auth.isAuthenticated) {
|
104
|
+
auth
|
105
|
+
.signinRedirect({
|
106
|
+
state: generateUrlToDeployOnOpen(this),
|
107
|
+
})
|
108
|
+
.catch(this.editorStore.applicationStore.alertUnhandledError);
|
109
|
+
return;
|
110
|
+
}
|
111
|
+
const token = auth.user?.access_token;
|
112
|
+
yield flowResult(this.generateElementGrammar()).catch(
|
113
|
+
this.editorStore.applicationStore.alertUnhandledError,
|
114
|
+
);
|
115
|
+
flowResult(this.deploy(token)).catch(
|
116
|
+
this.editorStore.applicationStore.alertUnhandledError,
|
117
|
+
);
|
118
|
+
}
|
119
|
+
|
120
|
+
*deploy(token: string | undefined): GeneratorFn<void> {
|
121
|
+
try {
|
122
|
+
assertTrue(
|
123
|
+
this.validForDeployment,
|
124
|
+
'Ingest definition is not valid for deployment',
|
125
|
+
);
|
126
|
+
this.deploymentState.inProgress();
|
127
|
+
const response = (yield guaranteeNonNullable(
|
128
|
+
this.ingestionManager,
|
129
|
+
).deploy(
|
130
|
+
guaranteeNonNullable(this.textContent),
|
131
|
+
guaranteeNonNullable(this.ingest.appDirDeployment),
|
132
|
+
this.deploymentState,
|
133
|
+
token,
|
134
|
+
)) as unknown as ValidateAndDeploymentResponse;
|
135
|
+
const deploymentResponse = response.deploymentResponse;
|
136
|
+
if (deploymentResponse) {
|
137
|
+
this.editorStore.applicationStore.notificationService.notifySuccess(
|
138
|
+
`Ingest definition successfully deployed on ${deploymentResponse.ingestDefinitionUrn}`,
|
139
|
+
);
|
140
|
+
} else {
|
141
|
+
this.setValError(response.validationResponse);
|
142
|
+
}
|
143
|
+
} catch (error) {
|
144
|
+
assertErrorThrown(error);
|
145
|
+
this.editorStore.applicationStore.notificationService.notifyError(
|
146
|
+
`Ingest definition failed to deploy: ${error.message}`,
|
147
|
+
);
|
148
|
+
} finally {
|
149
|
+
this.deploymentState.complete();
|
150
|
+
}
|
151
|
+
}
|
152
|
+
|
153
|
+
reprocess(
|
154
|
+
newElement: PackageableElement,
|
155
|
+
editorStore: EditorStore,
|
156
|
+
): ElementEditorState {
|
157
|
+
return new IngestDefinitionEditorState(editorStore, newElement);
|
158
|
+
}
|
159
|
+
|
160
|
+
get validForDeployment(): boolean {
|
161
|
+
return Boolean(
|
162
|
+
this.ingest.appDirDeployment && this.textContent && this.ingestionManager,
|
163
|
+
);
|
164
|
+
}
|
165
|
+
|
166
|
+
get validationMessage(): string {
|
167
|
+
if (!this.ingest.appDirDeployment) {
|
168
|
+
return 'No app dir deployment found';
|
169
|
+
} else if (!this.textContent) {
|
170
|
+
return 'No ingest definition found';
|
171
|
+
} else if (!this.ingestionManager) {
|
172
|
+
return 'No ingestion manager found';
|
173
|
+
}
|
174
|
+
return 'Deploy';
|
175
|
+
}
|
176
|
+
|
177
|
+
get ingest(): IngestDefinition {
|
178
|
+
return guaranteeType(
|
179
|
+
this.element,
|
180
|
+
IngestDefinition,
|
181
|
+
'Element inside ingest editor state must be a IngestDefinition',
|
182
|
+
);
|
183
|
+
}
|
184
|
+
}
|
@@ -0,0 +1,83 @@
|
|
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
|
+
AbstractServerClient,
|
19
|
+
ContentType,
|
20
|
+
HttpHeader,
|
21
|
+
type PlainObject,
|
22
|
+
} from '@finos/legend-shared';
|
23
|
+
import { makeObservable, observable } from 'mobx';
|
24
|
+
import type {
|
25
|
+
IngestDefinitionDeploymentResponse,
|
26
|
+
IngestDefinitionValidationResponse,
|
27
|
+
} from './IngestionDeploymentResponse.js';
|
28
|
+
import type { IngestDeploymentServerConfig } from '../../application/LegendIngestionConfiguration.js';
|
29
|
+
|
30
|
+
export class IngestDeploymentServerClient extends AbstractServerClient {
|
31
|
+
environmentClassification: string;
|
32
|
+
constructor(config: IngestDeploymentServerConfig) {
|
33
|
+
super({
|
34
|
+
baseUrl: config.ingestServerUrl,
|
35
|
+
});
|
36
|
+
this.environmentClassification = config.environmentClassification;
|
37
|
+
makeObservable(this, {
|
38
|
+
environmentClassification: observable,
|
39
|
+
baseUrl: observable,
|
40
|
+
});
|
41
|
+
}
|
42
|
+
|
43
|
+
private _token = (token?: string) => ({
|
44
|
+
Authorization: `Bearer ${token}`,
|
45
|
+
});
|
46
|
+
|
47
|
+
private _tokenWithTextPlain = (token?: string) => ({
|
48
|
+
[HttpHeader.CONTENT_TYPE]: ContentType.TEXT_PLAIN,
|
49
|
+
Authorization: `Bearer ${token}`,
|
50
|
+
});
|
51
|
+
|
52
|
+
private _ingest = (): string =>
|
53
|
+
`${this.baseUrl}/ingest/sdlc/deploy/definitions`;
|
54
|
+
|
55
|
+
changeServer(serverConfig: IngestDeploymentServerConfig): void {
|
56
|
+
this.baseUrl = serverConfig.ingestServerUrl;
|
57
|
+
this.environmentClassification = serverConfig.environmentClassification;
|
58
|
+
}
|
59
|
+
|
60
|
+
validate(
|
61
|
+
validateGrammar: string,
|
62
|
+
token: string | undefined,
|
63
|
+
): Promise<PlainObject<IngestDefinitionValidationResponse>> {
|
64
|
+
return this.post(
|
65
|
+
`${this._ingest()}/validate`,
|
66
|
+
validateGrammar,
|
67
|
+
undefined,
|
68
|
+
this._tokenWithTextPlain(token),
|
69
|
+
);
|
70
|
+
}
|
71
|
+
|
72
|
+
deploy(
|
73
|
+
deployGrammar: string,
|
74
|
+
token: string | undefined,
|
75
|
+
): Promise<IngestDefinitionDeploymentResponse> {
|
76
|
+
return this.post(
|
77
|
+
`${this._ingest()}`,
|
78
|
+
deployGrammar,
|
79
|
+
undefined,
|
80
|
+
this._tokenWithTextPlain(token),
|
81
|
+
);
|
82
|
+
}
|
83
|
+
}
|
@@ -0,0 +1,52 @@
|
|
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 { AbstractServerClient, type PlainObject } from '@finos/legend-shared';
|
18
|
+
import type { IngestDeploymentServerConfig } from '../../application/LegendIngestionConfiguration.js';
|
19
|
+
|
20
|
+
export class IngestDiscoveryServerClient extends AbstractServerClient {
|
21
|
+
constructor(url: string) {
|
22
|
+
super({
|
23
|
+
baseUrl: url,
|
24
|
+
});
|
25
|
+
}
|
26
|
+
private _ingest = (): string =>
|
27
|
+
`${this.baseUrl}/ingest/discovery/environments/producers`;
|
28
|
+
|
29
|
+
private _env = (): string => `${this.baseUrl}/ingest/discovery/environments`;
|
30
|
+
|
31
|
+
private _token = (token?: string) => ({
|
32
|
+
Authorization: `Bearer ${token}`,
|
33
|
+
});
|
34
|
+
|
35
|
+
discover(
|
36
|
+
token?: string | undefined,
|
37
|
+
): Promise<PlainObject<IngestDeploymentServerConfig[]>> {
|
38
|
+
return this.get(`${this._env()}`, {}, this._token(token));
|
39
|
+
}
|
40
|
+
|
41
|
+
findProducerServer(
|
42
|
+
id: number,
|
43
|
+
level: string,
|
44
|
+
token?: string | undefined,
|
45
|
+
): Promise<PlainObject<IngestDeploymentServerConfig>> {
|
46
|
+
return this.get(
|
47
|
+
`${this._ingest()}/${id}/${level}/search`,
|
48
|
+
{},
|
49
|
+
this._token(token),
|
50
|
+
);
|
51
|
+
}
|
52
|
+
}
|