@finos/legend-application-studio 26.0.2 → 26.0.3
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/application/LegendStudioApplicationConfig.d.ts +10 -13
- package/lib/application/LegendStudioApplicationConfig.d.ts.map +1 -1
- package/lib/application/LegendStudioApplicationConfig.js +11 -10
- package/lib/application/LegendStudioApplicationConfig.js.map +1 -1
- package/lib/components/ElementIconUtils.d.ts +1 -1
- package/lib/components/ElementIconUtils.d.ts.map +1 -1
- package/lib/components/ElementIconUtils.js +11 -5
- package/lib/components/ElementIconUtils.js.map +1 -1
- package/lib/components/editor/__test-utils__/EditorComponentTestUtils.d.ts.map +1 -1
- package/lib/components/editor/__test-utils__/EditorComponentTestUtils.js +2 -0
- package/lib/components/editor/__test-utils__/EditorComponentTestUtils.js.map +1 -1
- package/lib/components/editor/editor-group/EditorGroup.d.ts.map +1 -1
- package/lib/components/editor/editor-group/EditorGroup.js +7 -1
- package/lib/components/editor/editor-group/EditorGroup.js.map +1 -1
- package/lib/components/editor/editor-group/FunctionEditor.d.ts +0 -16
- package/lib/components/editor/editor-group/FunctionEditor.d.ts.map +1 -1
- package/lib/components/editor/editor-group/FunctionEditor.js +79 -26
- package/lib/components/editor/editor-group/FunctionEditor.js.map +1 -1
- package/lib/components/editor/editor-group/{service-editor/TEMPORARY__SnowflakeServiceDeployer.d.ts → INTERNAL__UnknownFunctionActivatorEdtior.d.ts} +2 -2
- package/lib/components/editor/editor-group/INTERNAL__UnknownFunctionActivatorEdtior.d.ts.map +1 -0
- package/lib/components/editor/editor-group/INTERNAL__UnknownFunctionActivatorEdtior.js +49 -0
- package/lib/components/editor/editor-group/INTERNAL__UnknownFunctionActivatorEdtior.js.map +1 -0
- package/lib/components/editor/editor-group/ModelImporter.js +1 -1
- package/lib/components/editor/editor-group/ModelImporter.js.map +1 -1
- package/lib/components/editor/editor-group/ProtocolValueBuilder.d.ts +22 -0
- package/lib/components/editor/editor-group/ProtocolValueBuilder.d.ts.map +1 -0
- package/lib/components/editor/editor-group/ProtocolValueBuilder.js +88 -0
- package/lib/components/editor/editor-group/ProtocolValueBuilder.js.map +1 -0
- package/lib/components/editor/editor-group/connection-editor/RelationalDatabaseConnectionEditor.d.ts.map +1 -1
- package/lib/components/editor/editor-group/connection-editor/RelationalDatabaseConnectionEditor.js +5 -1
- package/lib/components/editor/editor-group/connection-editor/RelationalDatabaseConnectionEditor.js.map +1 -1
- package/lib/components/editor/editor-group/connection-editor/post-processor-editor/MapperPostProcessorEditor.js +1 -1
- package/lib/components/editor/editor-group/element-generation-editor/FileGenerationEditor.d.ts +1 -1
- package/lib/components/editor/editor-group/element-generation-editor/FileGenerationEditor.d.ts.map +1 -1
- package/lib/components/editor/editor-group/element-generation-editor/FileGenerationEditor.js.map +1 -1
- package/lib/components/editor/editor-group/mapping-editor/EnumerationMappingEditor.js +1 -1
- package/lib/components/editor/editor-group/mapping-editor/FlatDataPropertyMappingEditor.js +3 -3
- package/lib/components/editor/editor-group/mapping-editor/FlatDataPropertyMappingEditor.js.map +1 -1
- package/lib/components/editor/editor-group/mapping-editor/InstanceSetImplementationEditor.d.ts.map +1 -1
- package/lib/components/editor/editor-group/mapping-editor/InstanceSetImplementationEditor.js +3 -3
- package/lib/components/editor/editor-group/mapping-editor/InstanceSetImplementationEditor.js.map +1 -1
- package/lib/components/editor/editor-group/mapping-editor/InstanceSetImplementationSourceSelectorModal.js +1 -1
- package/lib/components/editor/editor-group/mapping-editor/InstanceSetImplementationSourceSelectorModal.js.map +1 -1
- package/lib/components/editor/editor-group/mapping-editor/MappingEditor.js +1 -1
- package/lib/components/editor/editor-group/mapping-editor/MappingEditor.js.map +1 -1
- package/lib/components/editor/{edit-panel/mapping-editor/testable → editor-group/mapping-editor}/MappingTestableEditor.d.ts +1 -1
- package/lib/components/editor/editor-group/mapping-editor/MappingTestableEditor.d.ts.map +1 -0
- package/lib/components/editor/{edit-panel/mapping-editor/testable → editor-group/mapping-editor}/MappingTestableEditor.js +11 -11
- package/lib/components/editor/editor-group/mapping-editor/MappingTestableEditor.js.map +1 -0
- package/lib/components/editor/editor-group/mapping-editor/PurePropertyMappingEditor.js +4 -4
- package/lib/components/editor/editor-group/mapping-editor/PurePropertyMappingEditor.js.map +1 -1
- package/lib/components/editor/editor-group/mapping-editor/relational/RelationalPropertyMappingEditor.js +4 -4
- package/lib/components/editor/editor-group/mapping-editor/relational/RelationalPropertyMappingEditor.js.map +1 -1
- package/lib/components/editor/editor-group/service-editor/ServiceEditor.d.ts.map +1 -1
- package/lib/components/editor/editor-group/service-editor/ServiceEditor.js +0 -7
- package/lib/components/editor/editor-group/service-editor/ServiceEditor.js.map +1 -1
- package/lib/components/editor/editor-group/service-editor/ServicePostValidationEditor.js +3 -3
- package/lib/components/editor/editor-group/service-editor/ServicePostValidationEditor.js.map +1 -1
- package/lib/components/editor/editor-group/uml-editor/ClassEditor.js +3 -3
- package/lib/components/editor/editor-group/uml-editor/ClassEditor.js.map +1 -1
- package/lib/components/editor/editor-group/uml-editor/StereotypeSelector.d.ts.map +1 -1
- package/lib/components/editor/editor-group/uml-editor/StereotypeSelector.js +6 -2
- package/lib/components/editor/editor-group/uml-editor/StereotypeSelector.js.map +1 -1
- package/lib/components/editor/editor-group/uml-editor/TaggedValueEditor.d.ts.map +1 -1
- package/lib/components/editor/editor-group/uml-editor/TaggedValueEditor.js +10 -2
- package/lib/components/editor/editor-group/uml-editor/TaggedValueEditor.js.map +1 -1
- package/lib/components/workspace-setup/WorkspaceSetup.js +1 -1
- package/lib/components/workspace-setup/WorkspaceSetup.js.map +1 -1
- package/lib/index.css +2 -2
- package/lib/index.css.map +1 -1
- package/lib/package.json +2 -2
- package/lib/stores/LegendStudioApplicationPlugin.d.ts +1 -1
- package/lib/stores/LegendStudioApplicationPlugin.d.ts.map +1 -1
- package/lib/stores/editor/EditorGraphState.d.ts +3 -1
- package/lib/stores/editor/EditorGraphState.d.ts.map +1 -1
- package/lib/stores/editor/EditorGraphState.js +14 -0
- package/lib/stores/editor/EditorGraphState.js.map +1 -1
- package/lib/stores/editor/EditorStore.d.ts +5 -5
- package/lib/stores/editor/EditorStore.d.ts.map +1 -1
- package/lib/stores/editor/EditorStore.js +12 -7
- package/lib/stores/editor/EditorStore.js.map +1 -1
- package/lib/stores/editor/EditorTabManagerState.d.ts.map +1 -1
- package/lib/stores/editor/EditorTabManagerState.js +5 -1
- package/lib/stores/editor/EditorTabManagerState.js.map +1 -1
- package/lib/stores/editor/editor-state/ExternalFormatState.d.ts +3 -3
- package/lib/stores/editor/editor-state/ExternalFormatState.d.ts.map +1 -1
- package/lib/stores/editor/editor-state/ExternalFormatState.js +14 -14
- package/lib/stores/editor/editor-state/ExternalFormatState.js.map +1 -1
- package/lib/stores/editor/editor-state/GraphGenerationState.d.ts +2 -2
- package/lib/stores/editor/editor-state/GraphGenerationState.d.ts.map +1 -1
- package/lib/stores/editor/editor-state/GraphGenerationState.js +1 -1
- package/lib/stores/editor/editor-state/GraphGenerationState.js.map +1 -1
- package/lib/stores/editor/editor-state/element-editor-state/FunctionActivatorBuilderState.d.ts +34 -0
- package/lib/stores/editor/editor-state/element-editor-state/FunctionActivatorBuilderState.d.ts.map +1 -0
- package/lib/stores/editor/editor-state/element-editor-state/FunctionActivatorBuilderState.js +118 -0
- package/lib/stores/editor/editor-state/element-editor-state/FunctionActivatorBuilderState.js.map +1 -0
- package/lib/stores/editor/editor-state/element-editor-state/FunctionEditorState.d.ts +10 -8
- package/lib/stores/editor/editor-state/element-editor-state/FunctionEditorState.d.ts.map +1 -1
- package/lib/stores/editor/editor-state/element-editor-state/FunctionEditorState.js +16 -13
- package/lib/stores/editor/editor-state/element-editor-state/FunctionEditorState.js.map +1 -1
- package/lib/stores/editor/editor-state/element-editor-state/INTERNAL__UnknownFunctionActivatorEditorState.d.ts +31 -0
- package/lib/stores/editor/editor-state/element-editor-state/INTERNAL__UnknownFunctionActivatorEditorState.d.ts.map +1 -0
- package/lib/stores/editor/editor-state/element-editor-state/INTERNAL__UnknownFunctionActivatorEditorState.js +91 -0
- package/lib/stores/editor/editor-state/element-editor-state/INTERNAL__UnknownFunctionActivatorEditorState.js.map +1 -0
- package/lib/stores/editor/editor-state/element-editor-state/ProtocolValueBuilderState.d.ts +69 -0
- package/lib/stores/editor/editor-state/element-editor-state/ProtocolValueBuilderState.d.ts.map +1 -0
- package/lib/stores/editor/editor-state/element-editor-state/ProtocolValueBuilderState.js +243 -0
- package/lib/stores/editor/editor-state/element-editor-state/ProtocolValueBuilderState.js.map +1 -0
- package/lib/stores/editor/editor-state/element-editor-state/connection/ConnectionEditorState.d.ts +2 -0
- package/lib/stores/editor/editor-state/element-editor-state/connection/ConnectionEditorState.d.ts.map +1 -1
- package/lib/stores/editor/editor-state/element-editor-state/connection/ConnectionEditorState.js +8 -1
- package/lib/stores/editor/editor-state/element-editor-state/connection/ConnectionEditorState.js.map +1 -1
- package/lib/stores/editor/editor-state/element-editor-state/service/ServiceEditorState.d.ts +2 -13
- package/lib/stores/editor/editor-state/element-editor-state/service/ServiceEditorState.d.ts.map +1 -1
- package/lib/stores/editor/editor-state/element-editor-state/service/ServiceEditorState.js +1 -39
- package/lib/stores/editor/editor-state/element-editor-state/service/ServiceEditorState.js.map +1 -1
- package/lib/stores/editor/utils/MockDataUtils.d.ts +0 -1
- package/lib/stores/editor/utils/MockDataUtils.d.ts.map +1 -1
- package/lib/stores/editor/utils/MockDataUtils.js +7 -20
- package/lib/stores/editor/utils/MockDataUtils.js.map +1 -1
- package/lib/stores/editor/utils/PackageTreeUtils.js +1 -1
- package/lib/stores/editor/utils/PackageTreeUtils.js.map +1 -1
- package/lib/stores/graph-modifier/DomainGraphModifierHelper.d.ts +3 -1
- package/lib/stores/graph-modifier/DomainGraphModifierHelper.d.ts.map +1 -1
- package/lib/stores/graph-modifier/DomainGraphModifierHelper.js +4 -1
- package/lib/stores/graph-modifier/DomainGraphModifierHelper.js.map +1 -1
- package/lib/stores/graph-modifier/STO_Relational_GraphModifierHelper.d.ts +1 -0
- package/lib/stores/graph-modifier/STO_Relational_GraphModifierHelper.d.ts.map +1 -1
- package/lib/stores/graph-modifier/STO_Relational_GraphModifierHelper.js +3 -0
- package/lib/stores/graph-modifier/STO_Relational_GraphModifierHelper.js.map +1 -1
- package/lib/stores/project-view/ProjectViewerStore.js +7 -3
- package/lib/stores/project-view/ProjectViewerStore.js.map +1 -1
- package/package.json +12 -12
- package/src/application/LegendStudioApplicationConfig.ts +14 -20
- package/src/components/ElementIconUtils.tsx +14 -2
- package/src/components/editor/__test-utils__/EditorComponentTestUtils.tsx +2 -0
- package/src/components/editor/editor-group/EditorGroup.tsx +12 -1
- package/src/components/editor/editor-group/FunctionEditor.tsx +331 -85
- package/src/components/editor/editor-group/INTERNAL__UnknownFunctionActivatorEdtior.tsx +129 -0
- package/src/components/editor/editor-group/ModelImporter.tsx +1 -1
- package/src/components/editor/editor-group/ProtocolValueBuilder.tsx +225 -0
- package/src/components/editor/editor-group/connection-editor/RelationalDatabaseConnectionEditor.tsx +26 -1
- package/src/components/editor/editor-group/connection-editor/post-processor-editor/MapperPostProcessorEditor.tsx +1 -1
- package/src/components/editor/editor-group/element-generation-editor/FileGenerationEditor.tsx +7 -28
- package/src/components/editor/editor-group/mapping-editor/EnumerationMappingEditor.tsx +1 -1
- package/src/components/editor/editor-group/mapping-editor/FlatDataPropertyMappingEditor.tsx +4 -4
- package/src/components/editor/editor-group/mapping-editor/InstanceSetImplementationEditor.tsx +2 -3
- package/src/components/editor/editor-group/mapping-editor/InstanceSetImplementationSourceSelectorModal.tsx +1 -1
- package/src/components/editor/editor-group/mapping-editor/MappingEditor.tsx +1 -1
- package/src/components/editor/{edit-panel/mapping-editor/testable → editor-group/mapping-editor}/MappingTestableEditor.tsx +13 -13
- package/src/components/editor/editor-group/mapping-editor/PurePropertyMappingEditor.tsx +5 -5
- package/src/components/editor/editor-group/mapping-editor/relational/RelationalPropertyMappingEditor.tsx +5 -5
- package/src/components/editor/editor-group/service-editor/ServiceEditor.tsx +0 -10
- package/src/components/editor/editor-group/service-editor/ServicePostValidationEditor.tsx +3 -3
- package/src/components/editor/editor-group/uml-editor/ClassEditor.tsx +3 -3
- package/src/components/editor/editor-group/uml-editor/StereotypeSelector.tsx +12 -11
- package/src/components/editor/editor-group/uml-editor/TaggedValueEditor.tsx +18 -20
- package/src/components/workspace-setup/WorkspaceSetup.tsx +1 -1
- package/src/stores/LegendStudioApplicationPlugin.ts +14 -5
- package/src/stores/editor/EditorGraphState.ts +24 -0
- package/src/stores/editor/EditorStore.ts +16 -7
- package/src/stores/editor/EditorTabManagerState.ts +7 -0
- package/src/stores/editor/editor-state/ExternalFormatState.ts +14 -16
- package/src/stores/editor/editor-state/GraphGenerationState.ts +3 -2
- package/src/stores/editor/editor-state/element-editor-state/FunctionActivatorBuilderState.ts +178 -0
- package/src/stores/editor/editor-state/element-editor-state/FunctionEditorState.ts +21 -13
- package/src/stores/editor/editor-state/element-editor-state/INTERNAL__UnknownFunctionActivatorEditorState.ts +136 -0
- package/src/stores/editor/editor-state/element-editor-state/ProtocolValueBuilderState.ts +364 -0
- package/src/stores/editor/editor-state/element-editor-state/connection/ConnectionEditorState.ts +12 -0
- package/src/stores/editor/editor-state/element-editor-state/service/ServiceEditorState.ts +0 -53
- package/src/stores/editor/utils/MockDataUtils.ts +7 -28
- package/src/stores/editor/utils/PackageTreeUtils.ts +1 -1
- package/src/stores/graph-modifier/DomainGraphModifierHelper.ts +9 -1
- package/src/stores/graph-modifier/STO_Relational_GraphModifierHelper.ts +6 -0
- package/src/stores/project-view/ProjectViewerStore.ts +6 -6
- package/tsconfig.json +6 -2
- package/lib/components/editor/edit-panel/mapping-editor/testable/MappingTestableEditor.d.ts.map +0 -1
- package/lib/components/editor/edit-panel/mapping-editor/testable/MappingTestableEditor.js.map +0 -1
- package/lib/components/editor/editor-group/service-editor/TEMPORARY__SnowflakeServiceDeployer.d.ts.map +0 -1
- package/lib/components/editor/editor-group/service-editor/TEMPORARY__SnowflakeServiceDeployer.js +0 -39
- package/lib/components/editor/editor-group/service-editor/TEMPORARY__SnowflakeServiceDeployer.js.map +0 -1
- package/src/components/editor/editor-group/service-editor/TEMPORARY__SnowflakeServiceDeployer.tsx +0 -79
@@ -0,0 +1,178 @@
|
|
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
|
+
action,
|
19
|
+
computed,
|
20
|
+
flow,
|
21
|
+
flowResult,
|
22
|
+
makeObservable,
|
23
|
+
observable,
|
24
|
+
} from 'mobx';
|
25
|
+
import type { FunctionEditorState } from './FunctionEditorState.js';
|
26
|
+
import {
|
27
|
+
INTERNAL__UnknownFunctionActivator,
|
28
|
+
type FunctionActivatorConfiguration,
|
29
|
+
PackageableElementExplicitReference,
|
30
|
+
buildPath,
|
31
|
+
generateFunctionPrettyName,
|
32
|
+
} from '@finos/legend-graph';
|
33
|
+
import { ProtocolValueBuilderState } from './ProtocolValueBuilderState.js';
|
34
|
+
import {
|
35
|
+
generateEnumerableNameFromToken,
|
36
|
+
type GeneratorFn,
|
37
|
+
type PlainObject,
|
38
|
+
} from '@finos/legend-shared';
|
39
|
+
import { INTERNAL__UnknownFunctionActivator_setContent } from '../../../graph-modifier/DomainGraphModifierHelper.js';
|
40
|
+
|
41
|
+
const BASE_ACTIVATOR_NAME = 'NewActivator';
|
42
|
+
export const FUNCTION_ACTIVATOR_EXCLUDED_PATHS = [
|
43
|
+
'meta::protocols::pure::vX_X_X::metamodel::functionActivator::FunctionActivator.function',
|
44
|
+
'meta::protocols::pure::vX_X_X::metamodel::domain::AnnotatedElement.stereotypes',
|
45
|
+
'meta::protocols::pure::vX_X_X::metamodel::domain::AnnotatedElement.taggedValues',
|
46
|
+
'meta::protocols::pure::vX_X_X::metamodel::domain::AnnotatedElement.sourceInformation',
|
47
|
+
'meta::protocols::pure::vX_X_X::metamodel::PackageableElement.sourceInformation',
|
48
|
+
'meta::protocols::pure::vX_X_X::metamodel::PackageableElement.package',
|
49
|
+
'meta::protocols::pure::vX_X_X::metamodel::PackageableElement.name',
|
50
|
+
'meta::protocols::pure::vX_X_X::metamodel::PackageableElement._type',
|
51
|
+
];
|
52
|
+
|
53
|
+
export class FunctionActivatorBuilderState {
|
54
|
+
readonly functionEditorState: FunctionEditorState;
|
55
|
+
|
56
|
+
currentActivatorConfiguration?: FunctionActivatorConfiguration | undefined;
|
57
|
+
functionActivatorProtocolValueBuilderState?:
|
58
|
+
| ProtocolValueBuilderState
|
59
|
+
| undefined;
|
60
|
+
activatorName = BASE_ACTIVATOR_NAME;
|
61
|
+
functionActivator?: INTERNAL__UnknownFunctionActivator | undefined;
|
62
|
+
|
63
|
+
constructor(functionEditorState: FunctionEditorState) {
|
64
|
+
makeObservable(this, {
|
65
|
+
currentActivatorConfiguration: observable,
|
66
|
+
functionActivatorProtocolValueBuilderState: observable,
|
67
|
+
functionActivator: observable,
|
68
|
+
activatorName: observable,
|
69
|
+
isDuplicated: computed,
|
70
|
+
isValid: computed,
|
71
|
+
setActivatorName: action,
|
72
|
+
setCurrentActivatorConfiguration: action,
|
73
|
+
activate: flow,
|
74
|
+
});
|
75
|
+
|
76
|
+
this.functionEditorState = functionEditorState;
|
77
|
+
}
|
78
|
+
|
79
|
+
get isDuplicated(): boolean {
|
80
|
+
return Boolean(
|
81
|
+
this.functionEditorState.editorStore.graphManagerState.graph.getNullableElement(
|
82
|
+
buildPath(
|
83
|
+
this.functionEditorState.functionElement.package?.path,
|
84
|
+
this.activatorName,
|
85
|
+
),
|
86
|
+
),
|
87
|
+
);
|
88
|
+
}
|
89
|
+
|
90
|
+
get isValid(): boolean {
|
91
|
+
if (!this.functionActivator) {
|
92
|
+
return false;
|
93
|
+
}
|
94
|
+
return this.activatorName.length !== 0 && !this.isDuplicated;
|
95
|
+
}
|
96
|
+
|
97
|
+
setActivatorName(val: string): void {
|
98
|
+
this.activatorName = val;
|
99
|
+
if (this.functionActivator) {
|
100
|
+
this.functionActivator.name = val;
|
101
|
+
}
|
102
|
+
}
|
103
|
+
|
104
|
+
setCurrentActivatorConfiguration(
|
105
|
+
val: FunctionActivatorConfiguration | undefined,
|
106
|
+
): void {
|
107
|
+
this.currentActivatorConfiguration = val;
|
108
|
+
if (val) {
|
109
|
+
this.functionActivatorProtocolValueBuilderState =
|
110
|
+
new ProtocolValueBuilderState(val.configurationType, {
|
111
|
+
graph: val.graph,
|
112
|
+
initialValue: undefined,
|
113
|
+
excludedPaths: FUNCTION_ACTIVATOR_EXCLUDED_PATHS,
|
114
|
+
onValueChange: (value: PlainObject) => {
|
115
|
+
if (this.functionActivator) {
|
116
|
+
INTERNAL__UnknownFunctionActivator_setContent(
|
117
|
+
this.functionActivator,
|
118
|
+
value,
|
119
|
+
);
|
120
|
+
}
|
121
|
+
},
|
122
|
+
decorateValue: (value: PlainObject): PlainObject => {
|
123
|
+
value._type = val.packageableElementJSONType;
|
124
|
+
value.package =
|
125
|
+
this.functionEditorState.functionElement.package?.path;
|
126
|
+
value.name = this.activatorName;
|
127
|
+
value.function = generateFunctionPrettyName(
|
128
|
+
this.functionEditorState.functionElement,
|
129
|
+
{
|
130
|
+
fullPath: true,
|
131
|
+
spacing: false,
|
132
|
+
},
|
133
|
+
).replaceAll(' ', '');
|
134
|
+
return value;
|
135
|
+
},
|
136
|
+
});
|
137
|
+
this.activatorName = generateEnumerableNameFromToken(
|
138
|
+
this.functionEditorState.functionElement.package?.children.map(
|
139
|
+
(child) => child.name,
|
140
|
+
) ?? [],
|
141
|
+
BASE_ACTIVATOR_NAME,
|
142
|
+
);
|
143
|
+
this.functionActivator = new INTERNAL__UnknownFunctionActivator(
|
144
|
+
this.activatorName,
|
145
|
+
);
|
146
|
+
this.functionActivator.function =
|
147
|
+
PackageableElementExplicitReference.create(
|
148
|
+
this.functionEditorState.functionElement,
|
149
|
+
);
|
150
|
+
this.functionActivator.content =
|
151
|
+
this.functionActivatorProtocolValueBuilderState.getValue();
|
152
|
+
} else {
|
153
|
+
this.functionActivatorProtocolValueBuilderState = undefined;
|
154
|
+
}
|
155
|
+
}
|
156
|
+
|
157
|
+
*activate(): GeneratorFn<void> {
|
158
|
+
if (!this.isValid || !this.functionActivator) {
|
159
|
+
return;
|
160
|
+
}
|
161
|
+
|
162
|
+
try {
|
163
|
+
yield flowResult(
|
164
|
+
this.functionEditorState.editorStore.graphEditorMode.addElement(
|
165
|
+
this.functionActivator,
|
166
|
+
this.functionEditorState.functionElement.package?.path,
|
167
|
+
true,
|
168
|
+
),
|
169
|
+
);
|
170
|
+
} catch {
|
171
|
+
this.functionEditorState.editorStore.applicationStore.notificationService.notifyError(
|
172
|
+
`Can't activate function`,
|
173
|
+
);
|
174
|
+
} finally {
|
175
|
+
this.setCurrentActivatorConfiguration(undefined);
|
176
|
+
}
|
177
|
+
}
|
178
|
+
}
|
@@ -36,16 +36,18 @@ import {
|
|
36
36
|
isStubbed_PackageableElement,
|
37
37
|
} from '@finos/legend-graph';
|
38
38
|
import { LambdaEditorState } from '@finos/legend-query-builder';
|
39
|
+
import { FunctionActivatorBuilderState } from './FunctionActivatorBuilderState.js';
|
39
40
|
|
40
|
-
export enum
|
41
|
-
|
41
|
+
export enum FUNCTION_EDITOR_TAB {
|
42
|
+
DEFINITION = 'DEFINITION',
|
42
43
|
TAGGED_VALUES = 'TAGGED_VALUES',
|
43
44
|
STEREOTYPES = 'STEREOTYPES',
|
44
45
|
}
|
45
46
|
|
46
|
-
export class
|
47
|
-
editorStore: EditorStore;
|
48
|
-
functionElement: ConcreteFunctionDefinition;
|
47
|
+
export class FunctionDefinitionEditorState extends LambdaEditorState {
|
48
|
+
readonly editorStore: EditorStore;
|
49
|
+
readonly functionElement: ConcreteFunctionDefinition;
|
50
|
+
|
49
51
|
isConvertingFunctionBodyToString = false;
|
50
52
|
|
51
53
|
constructor(
|
@@ -153,8 +155,10 @@ export class FunctionBodyEditorState extends LambdaEditorState {
|
|
153
155
|
}
|
154
156
|
|
155
157
|
export class FunctionEditorState extends ElementEditorState {
|
156
|
-
|
157
|
-
|
158
|
+
readonly functionDefinitionEditorState: FunctionDefinitionEditorState;
|
159
|
+
readonly activatorBuilderState: FunctionActivatorBuilderState;
|
160
|
+
|
161
|
+
selectedTab: FUNCTION_EDITOR_TAB;
|
158
162
|
|
159
163
|
constructor(editorStore: EditorStore, element: PackageableElement) {
|
160
164
|
super(editorStore, element);
|
@@ -171,11 +175,12 @@ export class FunctionEditorState extends ElementEditorState {
|
|
171
175
|
ConcreteFunctionDefinition,
|
172
176
|
'Element inside function editor state must be a function',
|
173
177
|
);
|
174
|
-
this.selectedTab =
|
175
|
-
this.
|
178
|
+
this.selectedTab = FUNCTION_EDITOR_TAB.DEFINITION;
|
179
|
+
this.functionDefinitionEditorState = new FunctionDefinitionEditorState(
|
176
180
|
element,
|
177
181
|
this.editorStore,
|
178
182
|
);
|
183
|
+
this.activatorBuilderState = new FunctionActivatorBuilderState(this);
|
179
184
|
}
|
180
185
|
|
181
186
|
get functionElement(): ConcreteFunctionDefinition {
|
@@ -185,7 +190,8 @@ export class FunctionEditorState extends ElementEditorState {
|
|
185
190
|
'Element inside function editor state must be a function',
|
186
191
|
);
|
187
192
|
}
|
188
|
-
|
193
|
+
|
194
|
+
setSelectedTab(tab: FUNCTION_EDITOR_TAB): void {
|
189
195
|
this.selectedTab = tab;
|
190
196
|
}
|
191
197
|
|
@@ -193,8 +199,10 @@ export class FunctionEditorState extends ElementEditorState {
|
|
193
199
|
let revealed = false;
|
194
200
|
try {
|
195
201
|
if (compilationError.sourceInformation) {
|
196
|
-
this.setSelectedTab(
|
197
|
-
this.
|
202
|
+
this.setSelectedTab(FUNCTION_EDITOR_TAB.DEFINITION);
|
203
|
+
this.functionDefinitionEditorState.setCompilationError(
|
204
|
+
compilationError,
|
205
|
+
);
|
198
206
|
revealed = true;
|
199
207
|
}
|
200
208
|
} catch (error) {
|
@@ -209,7 +217,7 @@ export class FunctionEditorState extends ElementEditorState {
|
|
209
217
|
}
|
210
218
|
|
211
219
|
override clearCompilationError(): void {
|
212
|
-
this.
|
220
|
+
this.functionDefinitionEditorState.setCompilationError(undefined);
|
213
221
|
}
|
214
222
|
|
215
223
|
reprocess(
|
@@ -0,0 +1,136 @@
|
|
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
|
+
generateFunctionPrettyName,
|
19
|
+
InMemoryGraphData,
|
20
|
+
type INTERNAL__UnknownFunctionActivator,
|
21
|
+
} from '@finos/legend-graph';
|
22
|
+
import type { EditorStore } from '../../EditorStore.js';
|
23
|
+
import { ElementEditorState } from './ElementEditorState.js';
|
24
|
+
import { action, flow, makeObservable } from 'mobx';
|
25
|
+
import {
|
26
|
+
ActionState,
|
27
|
+
assertErrorThrown,
|
28
|
+
type GeneratorFn,
|
29
|
+
type PlainObject,
|
30
|
+
} from '@finos/legend-shared';
|
31
|
+
import { ProtocolValueBuilderState } from './ProtocolValueBuilderState.js';
|
32
|
+
import { INTERNAL__UnknownFunctionActivator_setContent } from '../../../graph-modifier/DomainGraphModifierHelper.js';
|
33
|
+
import { FUNCTION_ACTIVATOR_EXCLUDED_PATHS } from './FunctionActivatorBuilderState.js';
|
34
|
+
|
35
|
+
export class INTERNAL__UnknownFunctionActivatorEdtiorState extends ElementEditorState {
|
36
|
+
readonly activator: INTERNAL__UnknownFunctionActivator;
|
37
|
+
readonly validateState = ActionState.create();
|
38
|
+
readonly publishToSandboxState = ActionState.create();
|
39
|
+
protocolValueBuilderState?: ProtocolValueBuilderState | undefined;
|
40
|
+
|
41
|
+
constructor(
|
42
|
+
editorStore: EditorStore,
|
43
|
+
element: INTERNAL__UnknownFunctionActivator,
|
44
|
+
) {
|
45
|
+
super(editorStore, element);
|
46
|
+
|
47
|
+
makeObservable(this, {
|
48
|
+
reprocess: action,
|
49
|
+
validate: flow,
|
50
|
+
publishToSandbox: flow,
|
51
|
+
});
|
52
|
+
|
53
|
+
this.activator = element;
|
54
|
+
const matchingFunctionActivatorConfiguration =
|
55
|
+
this.editorStore.graphState.functionActivatorConfigurations.find(
|
56
|
+
(config) =>
|
57
|
+
config.packageableElementJSONType === this.activator.content._type,
|
58
|
+
);
|
59
|
+
this.protocolValueBuilderState = matchingFunctionActivatorConfiguration
|
60
|
+
? new ProtocolValueBuilderState(
|
61
|
+
matchingFunctionActivatorConfiguration.configurationType,
|
62
|
+
{
|
63
|
+
graph: matchingFunctionActivatorConfiguration.graph,
|
64
|
+
initialValue: this.activator.content,
|
65
|
+
excludedPaths: FUNCTION_ACTIVATOR_EXCLUDED_PATHS,
|
66
|
+
onValueChange: (value: PlainObject) => {
|
67
|
+
INTERNAL__UnknownFunctionActivator_setContent(
|
68
|
+
this.activator,
|
69
|
+
value,
|
70
|
+
);
|
71
|
+
},
|
72
|
+
decorateValue: (value: PlainObject): PlainObject => {
|
73
|
+
value._type =
|
74
|
+
matchingFunctionActivatorConfiguration.packageableElementJSONType;
|
75
|
+
value.package = this.activator.package?.path;
|
76
|
+
value.name = this.activator.name;
|
77
|
+
value.function = generateFunctionPrettyName(
|
78
|
+
this.activator.function.value,
|
79
|
+
{
|
80
|
+
fullPath: true,
|
81
|
+
spacing: false,
|
82
|
+
},
|
83
|
+
).replaceAll(' ', '');
|
84
|
+
return value;
|
85
|
+
},
|
86
|
+
},
|
87
|
+
)
|
88
|
+
: undefined;
|
89
|
+
}
|
90
|
+
|
91
|
+
*validate(): GeneratorFn<void> {
|
92
|
+
this.validateState.inProgress();
|
93
|
+
try {
|
94
|
+
yield this.editorStore.graphManagerState.graphManager.validateFunctionActivator(
|
95
|
+
this.activator,
|
96
|
+
new InMemoryGraphData(this.editorStore.graphManagerState.graph),
|
97
|
+
);
|
98
|
+
this.editorStore.applicationStore.notificationService.notifySuccess(
|
99
|
+
`Function activator is valid`,
|
100
|
+
);
|
101
|
+
} catch (error) {
|
102
|
+
assertErrorThrown(error);
|
103
|
+
this.editorStore.applicationStore.notificationService.notifyError(error);
|
104
|
+
} finally {
|
105
|
+
this.validateState.complete();
|
106
|
+
}
|
107
|
+
}
|
108
|
+
|
109
|
+
*publishToSandbox(): GeneratorFn<void> {
|
110
|
+
this.publishToSandboxState.inProgress();
|
111
|
+
try {
|
112
|
+
yield this.editorStore.graphManagerState.graphManager.publishFunctionActivatorToSandbox(
|
113
|
+
this.activator,
|
114
|
+
new InMemoryGraphData(this.editorStore.graphManagerState.graph),
|
115
|
+
);
|
116
|
+
this.editorStore.applicationStore.notificationService.notifySuccess(
|
117
|
+
`Function activator is published to sandbox`,
|
118
|
+
);
|
119
|
+
} catch (error) {
|
120
|
+
assertErrorThrown(error);
|
121
|
+
this.editorStore.applicationStore.notificationService.notifyError(error);
|
122
|
+
} finally {
|
123
|
+
this.publishToSandboxState.complete();
|
124
|
+
}
|
125
|
+
}
|
126
|
+
|
127
|
+
reprocess(
|
128
|
+
newElement: INTERNAL__UnknownFunctionActivator,
|
129
|
+
editorStore: EditorStore,
|
130
|
+
): INTERNAL__UnknownFunctionActivatorEdtiorState {
|
131
|
+
return new INTERNAL__UnknownFunctionActivatorEdtiorState(
|
132
|
+
editorStore,
|
133
|
+
newElement,
|
134
|
+
);
|
135
|
+
}
|
136
|
+
}
|