@finos/legend-application-studio 26.0.2 → 26.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (182) hide show
  1. package/lib/application/LegendStudioApplicationConfig.d.ts +10 -13
  2. package/lib/application/LegendStudioApplicationConfig.d.ts.map +1 -1
  3. package/lib/application/LegendStudioApplicationConfig.js +11 -10
  4. package/lib/application/LegendStudioApplicationConfig.js.map +1 -1
  5. package/lib/components/ElementIconUtils.d.ts +1 -1
  6. package/lib/components/ElementIconUtils.d.ts.map +1 -1
  7. package/lib/components/ElementIconUtils.js +11 -5
  8. package/lib/components/ElementIconUtils.js.map +1 -1
  9. package/lib/components/editor/__test-utils__/EditorComponentTestUtils.d.ts.map +1 -1
  10. package/lib/components/editor/__test-utils__/EditorComponentTestUtils.js +2 -0
  11. package/lib/components/editor/__test-utils__/EditorComponentTestUtils.js.map +1 -1
  12. package/lib/components/editor/editor-group/EditorGroup.d.ts.map +1 -1
  13. package/lib/components/editor/editor-group/EditorGroup.js +7 -1
  14. package/lib/components/editor/editor-group/EditorGroup.js.map +1 -1
  15. package/lib/components/editor/editor-group/FunctionEditor.d.ts +0 -16
  16. package/lib/components/editor/editor-group/FunctionEditor.d.ts.map +1 -1
  17. package/lib/components/editor/editor-group/FunctionEditor.js +79 -26
  18. package/lib/components/editor/editor-group/FunctionEditor.js.map +1 -1
  19. package/lib/components/editor/editor-group/{service-editor/TEMPORARY__SnowflakeServiceDeployer.d.ts → INTERNAL__UnknownFunctionActivatorEdtior.d.ts} +2 -2
  20. package/lib/components/editor/editor-group/INTERNAL__UnknownFunctionActivatorEdtior.d.ts.map +1 -0
  21. package/lib/components/editor/editor-group/INTERNAL__UnknownFunctionActivatorEdtior.js +49 -0
  22. package/lib/components/editor/editor-group/INTERNAL__UnknownFunctionActivatorEdtior.js.map +1 -0
  23. package/lib/components/editor/editor-group/ModelImporter.js +1 -1
  24. package/lib/components/editor/editor-group/ModelImporter.js.map +1 -1
  25. package/lib/components/editor/editor-group/ProtocolValueBuilder.d.ts +22 -0
  26. package/lib/components/editor/editor-group/ProtocolValueBuilder.d.ts.map +1 -0
  27. package/lib/components/editor/editor-group/ProtocolValueBuilder.js +88 -0
  28. package/lib/components/editor/editor-group/ProtocolValueBuilder.js.map +1 -0
  29. package/lib/components/editor/editor-group/connection-editor/RelationalDatabaseConnectionEditor.d.ts.map +1 -1
  30. package/lib/components/editor/editor-group/connection-editor/RelationalDatabaseConnectionEditor.js +5 -1
  31. package/lib/components/editor/editor-group/connection-editor/RelationalDatabaseConnectionEditor.js.map +1 -1
  32. package/lib/components/editor/editor-group/connection-editor/post-processor-editor/MapperPostProcessorEditor.js +1 -1
  33. package/lib/components/editor/editor-group/element-generation-editor/FileGenerationEditor.d.ts +1 -1
  34. package/lib/components/editor/editor-group/element-generation-editor/FileGenerationEditor.d.ts.map +1 -1
  35. package/lib/components/editor/editor-group/element-generation-editor/FileGenerationEditor.js.map +1 -1
  36. package/lib/components/editor/editor-group/mapping-editor/EnumerationMappingEditor.js +1 -1
  37. package/lib/components/editor/editor-group/mapping-editor/FlatDataPropertyMappingEditor.js +3 -3
  38. package/lib/components/editor/editor-group/mapping-editor/FlatDataPropertyMappingEditor.js.map +1 -1
  39. package/lib/components/editor/editor-group/mapping-editor/InstanceSetImplementationEditor.d.ts.map +1 -1
  40. package/lib/components/editor/editor-group/mapping-editor/InstanceSetImplementationEditor.js +3 -3
  41. package/lib/components/editor/editor-group/mapping-editor/InstanceSetImplementationEditor.js.map +1 -1
  42. package/lib/components/editor/editor-group/mapping-editor/InstanceSetImplementationSourceSelectorModal.js +1 -1
  43. package/lib/components/editor/editor-group/mapping-editor/InstanceSetImplementationSourceSelectorModal.js.map +1 -1
  44. package/lib/components/editor/editor-group/mapping-editor/MappingEditor.js +1 -1
  45. package/lib/components/editor/editor-group/mapping-editor/MappingEditor.js.map +1 -1
  46. package/lib/components/editor/{edit-panel/mapping-editor/testable → editor-group/mapping-editor}/MappingTestableEditor.d.ts +1 -1
  47. package/lib/components/editor/editor-group/mapping-editor/MappingTestableEditor.d.ts.map +1 -0
  48. package/lib/components/editor/{edit-panel/mapping-editor/testable → editor-group/mapping-editor}/MappingTestableEditor.js +11 -11
  49. package/lib/components/editor/editor-group/mapping-editor/MappingTestableEditor.js.map +1 -0
  50. package/lib/components/editor/editor-group/mapping-editor/PurePropertyMappingEditor.js +4 -4
  51. package/lib/components/editor/editor-group/mapping-editor/PurePropertyMappingEditor.js.map +1 -1
  52. package/lib/components/editor/editor-group/mapping-editor/relational/RelationalPropertyMappingEditor.js +4 -4
  53. package/lib/components/editor/editor-group/mapping-editor/relational/RelationalPropertyMappingEditor.js.map +1 -1
  54. package/lib/components/editor/editor-group/service-editor/ServiceEditor.d.ts.map +1 -1
  55. package/lib/components/editor/editor-group/service-editor/ServiceEditor.js +0 -7
  56. package/lib/components/editor/editor-group/service-editor/ServiceEditor.js.map +1 -1
  57. package/lib/components/editor/editor-group/service-editor/ServicePostValidationEditor.js +3 -3
  58. package/lib/components/editor/editor-group/service-editor/ServicePostValidationEditor.js.map +1 -1
  59. package/lib/components/editor/editor-group/uml-editor/ClassEditor.js +3 -3
  60. package/lib/components/editor/editor-group/uml-editor/ClassEditor.js.map +1 -1
  61. package/lib/components/editor/editor-group/uml-editor/StereotypeSelector.d.ts.map +1 -1
  62. package/lib/components/editor/editor-group/uml-editor/StereotypeSelector.js +6 -2
  63. package/lib/components/editor/editor-group/uml-editor/StereotypeSelector.js.map +1 -1
  64. package/lib/components/editor/editor-group/uml-editor/TaggedValueEditor.d.ts.map +1 -1
  65. package/lib/components/editor/editor-group/uml-editor/TaggedValueEditor.js +10 -2
  66. package/lib/components/editor/editor-group/uml-editor/TaggedValueEditor.js.map +1 -1
  67. package/lib/components/workspace-setup/WorkspaceSetup.js +1 -1
  68. package/lib/components/workspace-setup/WorkspaceSetup.js.map +1 -1
  69. package/lib/index.css +2 -2
  70. package/lib/index.css.map +1 -1
  71. package/lib/package.json +2 -2
  72. package/lib/stores/LegendStudioApplicationPlugin.d.ts +1 -1
  73. package/lib/stores/LegendStudioApplicationPlugin.d.ts.map +1 -1
  74. package/lib/stores/editor/EditorGraphState.d.ts +3 -1
  75. package/lib/stores/editor/EditorGraphState.d.ts.map +1 -1
  76. package/lib/stores/editor/EditorGraphState.js +14 -0
  77. package/lib/stores/editor/EditorGraphState.js.map +1 -1
  78. package/lib/stores/editor/EditorStore.d.ts +5 -5
  79. package/lib/stores/editor/EditorStore.d.ts.map +1 -1
  80. package/lib/stores/editor/EditorStore.js +12 -7
  81. package/lib/stores/editor/EditorStore.js.map +1 -1
  82. package/lib/stores/editor/EditorTabManagerState.d.ts.map +1 -1
  83. package/lib/stores/editor/EditorTabManagerState.js +5 -1
  84. package/lib/stores/editor/EditorTabManagerState.js.map +1 -1
  85. package/lib/stores/editor/editor-state/ExternalFormatState.d.ts +3 -3
  86. package/lib/stores/editor/editor-state/ExternalFormatState.d.ts.map +1 -1
  87. package/lib/stores/editor/editor-state/ExternalFormatState.js +14 -14
  88. package/lib/stores/editor/editor-state/ExternalFormatState.js.map +1 -1
  89. package/lib/stores/editor/editor-state/GraphGenerationState.d.ts +2 -2
  90. package/lib/stores/editor/editor-state/GraphGenerationState.d.ts.map +1 -1
  91. package/lib/stores/editor/editor-state/GraphGenerationState.js +1 -1
  92. package/lib/stores/editor/editor-state/GraphGenerationState.js.map +1 -1
  93. package/lib/stores/editor/editor-state/element-editor-state/FunctionActivatorBuilderState.d.ts +34 -0
  94. package/lib/stores/editor/editor-state/element-editor-state/FunctionActivatorBuilderState.d.ts.map +1 -0
  95. package/lib/stores/editor/editor-state/element-editor-state/FunctionActivatorBuilderState.js +118 -0
  96. package/lib/stores/editor/editor-state/element-editor-state/FunctionActivatorBuilderState.js.map +1 -0
  97. package/lib/stores/editor/editor-state/element-editor-state/FunctionEditorState.d.ts +10 -8
  98. package/lib/stores/editor/editor-state/element-editor-state/FunctionEditorState.d.ts.map +1 -1
  99. package/lib/stores/editor/editor-state/element-editor-state/FunctionEditorState.js +16 -13
  100. package/lib/stores/editor/editor-state/element-editor-state/FunctionEditorState.js.map +1 -1
  101. package/lib/stores/editor/editor-state/element-editor-state/INTERNAL__UnknownFunctionActivatorEditorState.d.ts +31 -0
  102. package/lib/stores/editor/editor-state/element-editor-state/INTERNAL__UnknownFunctionActivatorEditorState.d.ts.map +1 -0
  103. package/lib/stores/editor/editor-state/element-editor-state/INTERNAL__UnknownFunctionActivatorEditorState.js +91 -0
  104. package/lib/stores/editor/editor-state/element-editor-state/INTERNAL__UnknownFunctionActivatorEditorState.js.map +1 -0
  105. package/lib/stores/editor/editor-state/element-editor-state/ProtocolValueBuilderState.d.ts +69 -0
  106. package/lib/stores/editor/editor-state/element-editor-state/ProtocolValueBuilderState.d.ts.map +1 -0
  107. package/lib/stores/editor/editor-state/element-editor-state/ProtocolValueBuilderState.js +243 -0
  108. package/lib/stores/editor/editor-state/element-editor-state/ProtocolValueBuilderState.js.map +1 -0
  109. package/lib/stores/editor/editor-state/element-editor-state/connection/ConnectionEditorState.d.ts +2 -0
  110. package/lib/stores/editor/editor-state/element-editor-state/connection/ConnectionEditorState.d.ts.map +1 -1
  111. package/lib/stores/editor/editor-state/element-editor-state/connection/ConnectionEditorState.js +8 -1
  112. package/lib/stores/editor/editor-state/element-editor-state/connection/ConnectionEditorState.js.map +1 -1
  113. package/lib/stores/editor/editor-state/element-editor-state/service/ServiceEditorState.d.ts +2 -13
  114. package/lib/stores/editor/editor-state/element-editor-state/service/ServiceEditorState.d.ts.map +1 -1
  115. package/lib/stores/editor/editor-state/element-editor-state/service/ServiceEditorState.js +1 -39
  116. package/lib/stores/editor/editor-state/element-editor-state/service/ServiceEditorState.js.map +1 -1
  117. package/lib/stores/editor/utils/MockDataUtils.d.ts +0 -1
  118. package/lib/stores/editor/utils/MockDataUtils.d.ts.map +1 -1
  119. package/lib/stores/editor/utils/MockDataUtils.js +7 -20
  120. package/lib/stores/editor/utils/MockDataUtils.js.map +1 -1
  121. package/lib/stores/editor/utils/PackageTreeUtils.js +1 -1
  122. package/lib/stores/editor/utils/PackageTreeUtils.js.map +1 -1
  123. package/lib/stores/graph-modifier/DomainGraphModifierHelper.d.ts +3 -1
  124. package/lib/stores/graph-modifier/DomainGraphModifierHelper.d.ts.map +1 -1
  125. package/lib/stores/graph-modifier/DomainGraphModifierHelper.js +4 -1
  126. package/lib/stores/graph-modifier/DomainGraphModifierHelper.js.map +1 -1
  127. package/lib/stores/graph-modifier/STO_Relational_GraphModifierHelper.d.ts +1 -0
  128. package/lib/stores/graph-modifier/STO_Relational_GraphModifierHelper.d.ts.map +1 -1
  129. package/lib/stores/graph-modifier/STO_Relational_GraphModifierHelper.js +3 -0
  130. package/lib/stores/graph-modifier/STO_Relational_GraphModifierHelper.js.map +1 -1
  131. package/lib/stores/project-view/ProjectViewerStore.js +7 -3
  132. package/lib/stores/project-view/ProjectViewerStore.js.map +1 -1
  133. package/package.json +12 -12
  134. package/src/application/LegendStudioApplicationConfig.ts +14 -20
  135. package/src/components/ElementIconUtils.tsx +14 -2
  136. package/src/components/editor/__test-utils__/EditorComponentTestUtils.tsx +2 -0
  137. package/src/components/editor/editor-group/EditorGroup.tsx +12 -1
  138. package/src/components/editor/editor-group/FunctionEditor.tsx +331 -85
  139. package/src/components/editor/editor-group/INTERNAL__UnknownFunctionActivatorEdtior.tsx +129 -0
  140. package/src/components/editor/editor-group/ModelImporter.tsx +1 -1
  141. package/src/components/editor/editor-group/ProtocolValueBuilder.tsx +225 -0
  142. package/src/components/editor/editor-group/connection-editor/RelationalDatabaseConnectionEditor.tsx +26 -1
  143. package/src/components/editor/editor-group/connection-editor/post-processor-editor/MapperPostProcessorEditor.tsx +1 -1
  144. package/src/components/editor/editor-group/element-generation-editor/FileGenerationEditor.tsx +7 -28
  145. package/src/components/editor/editor-group/mapping-editor/EnumerationMappingEditor.tsx +1 -1
  146. package/src/components/editor/editor-group/mapping-editor/FlatDataPropertyMappingEditor.tsx +4 -4
  147. package/src/components/editor/editor-group/mapping-editor/InstanceSetImplementationEditor.tsx +2 -3
  148. package/src/components/editor/editor-group/mapping-editor/InstanceSetImplementationSourceSelectorModal.tsx +1 -1
  149. package/src/components/editor/editor-group/mapping-editor/MappingEditor.tsx +1 -1
  150. package/src/components/editor/{edit-panel/mapping-editor/testable → editor-group/mapping-editor}/MappingTestableEditor.tsx +13 -13
  151. package/src/components/editor/editor-group/mapping-editor/PurePropertyMappingEditor.tsx +5 -5
  152. package/src/components/editor/editor-group/mapping-editor/relational/RelationalPropertyMappingEditor.tsx +5 -5
  153. package/src/components/editor/editor-group/service-editor/ServiceEditor.tsx +0 -10
  154. package/src/components/editor/editor-group/service-editor/ServicePostValidationEditor.tsx +3 -3
  155. package/src/components/editor/editor-group/uml-editor/ClassEditor.tsx +3 -3
  156. package/src/components/editor/editor-group/uml-editor/StereotypeSelector.tsx +12 -11
  157. package/src/components/editor/editor-group/uml-editor/TaggedValueEditor.tsx +18 -20
  158. package/src/components/workspace-setup/WorkspaceSetup.tsx +1 -1
  159. package/src/stores/LegendStudioApplicationPlugin.ts +14 -5
  160. package/src/stores/editor/EditorGraphState.ts +24 -0
  161. package/src/stores/editor/EditorStore.ts +16 -7
  162. package/src/stores/editor/EditorTabManagerState.ts +7 -0
  163. package/src/stores/editor/editor-state/ExternalFormatState.ts +14 -16
  164. package/src/stores/editor/editor-state/GraphGenerationState.ts +3 -2
  165. package/src/stores/editor/editor-state/element-editor-state/FunctionActivatorBuilderState.ts +178 -0
  166. package/src/stores/editor/editor-state/element-editor-state/FunctionEditorState.ts +21 -13
  167. package/src/stores/editor/editor-state/element-editor-state/INTERNAL__UnknownFunctionActivatorEditorState.ts +136 -0
  168. package/src/stores/editor/editor-state/element-editor-state/ProtocolValueBuilderState.ts +364 -0
  169. package/src/stores/editor/editor-state/element-editor-state/connection/ConnectionEditorState.ts +12 -0
  170. package/src/stores/editor/editor-state/element-editor-state/service/ServiceEditorState.ts +0 -53
  171. package/src/stores/editor/utils/MockDataUtils.ts +7 -28
  172. package/src/stores/editor/utils/PackageTreeUtils.ts +1 -1
  173. package/src/stores/graph-modifier/DomainGraphModifierHelper.ts +9 -1
  174. package/src/stores/graph-modifier/STO_Relational_GraphModifierHelper.ts +6 -0
  175. package/src/stores/project-view/ProjectViewerStore.ts +6 -6
  176. package/tsconfig.json +6 -2
  177. package/lib/components/editor/edit-panel/mapping-editor/testable/MappingTestableEditor.d.ts.map +0 -1
  178. package/lib/components/editor/edit-panel/mapping-editor/testable/MappingTestableEditor.js.map +0 -1
  179. package/lib/components/editor/editor-group/service-editor/TEMPORARY__SnowflakeServiceDeployer.d.ts.map +0 -1
  180. package/lib/components/editor/editor-group/service-editor/TEMPORARY__SnowflakeServiceDeployer.js +0 -39
  181. package/lib/components/editor/editor-group/service-editor/TEMPORARY__SnowflakeServiceDeployer.js.map +0 -1
  182. 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 FUNCTION_SPEC_TAB {
41
- GENERAL = 'GENERAL',
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 FunctionBodyEditorState extends LambdaEditorState {
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
- selectedTab: FUNCTION_SPEC_TAB;
157
- functionBodyEditorState: FunctionBodyEditorState;
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 = FUNCTION_SPEC_TAB.GENERAL;
175
- this.functionBodyEditorState = new FunctionBodyEditorState(
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
- setSelectedTab(tab: FUNCTION_SPEC_TAB): void {
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(FUNCTION_SPEC_TAB.GENERAL);
197
- this.functionBodyEditorState.setCompilationError(compilationError);
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.functionBodyEditorState.setCompilationError(undefined);
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
+ }