@finos/legend-application-studio 28.15.4 → 28.15.6

Sign up to get free protection for your applications and to get access to all the features.
Files changed (70) hide show
  1. package/lib/components/editor/editor-group/EditorGroup.d.ts.map +1 -1
  2. package/lib/components/editor/editor-group/EditorGroup.js +5 -0
  3. package/lib/components/editor/editor-group/EditorGroup.js.map +1 -1
  4. package/lib/components/editor/editor-group/UnsupportedElementEditor.d.ts +2 -0
  5. package/lib/components/editor/editor-group/UnsupportedElementEditor.d.ts.map +1 -1
  6. package/lib/components/editor/editor-group/UnsupportedElementEditor.js +12 -3
  7. package/lib/components/editor/editor-group/UnsupportedElementEditor.js.map +1 -1
  8. package/lib/components/editor/editor-group/function-activator/FunctionEditor.d.ts +1 -1
  9. package/lib/components/editor/editor-group/function-activator/FunctionEditor.d.ts.map +1 -1
  10. package/lib/components/editor/editor-group/function-activator/FunctionEditor.js +6 -4
  11. package/lib/components/editor/editor-group/function-activator/FunctionEditor.js.map +1 -1
  12. package/lib/components/editor/editor-group/function-activator/HostedServiceFunctionActivatorEditor.d.ts +19 -0
  13. package/lib/components/editor/editor-group/function-activator/HostedServiceFunctionActivatorEditor.d.ts.map +1 -0
  14. package/lib/components/editor/editor-group/function-activator/HostedServiceFunctionActivatorEditor.js +175 -0
  15. package/lib/components/editor/editor-group/function-activator/HostedServiceFunctionActivatorEditor.js.map +1 -0
  16. package/lib/components/editor/editor-group/function-activator/SnowflakeAppFunctionActivatorEditor.d.ts.map +1 -1
  17. package/lib/components/editor/editor-group/function-activator/SnowflakeAppFunctionActivatorEditor.js +18 -5
  18. package/lib/components/editor/editor-group/function-activator/SnowflakeAppFunctionActivatorEditor.js.map +1 -1
  19. package/lib/components/project-reviewer/ProjectReviewSideBar.js +1 -1
  20. package/lib/components/project-reviewer/ProjectReviewSideBar.js.map +1 -1
  21. package/lib/components/project-reviewer/ProjectReviewer.js +1 -1
  22. package/lib/components/project-reviewer/ProjectReviewer.js.map +1 -1
  23. package/lib/index.css +2 -2
  24. package/lib/index.css.map +1 -1
  25. package/lib/package.json +1 -1
  26. package/lib/stores/editor/EditorGraphState.d.ts.map +1 -1
  27. package/lib/stores/editor/EditorGraphState.js +4 -1
  28. package/lib/stores/editor/EditorGraphState.js.map +1 -1
  29. package/lib/stores/editor/EditorTabManagerState.d.ts.map +1 -1
  30. package/lib/stores/editor/EditorTabManagerState.js +5 -1
  31. package/lib/stores/editor/EditorTabManagerState.js.map +1 -1
  32. package/lib/stores/editor/editor-state/element-editor-state/ElementEditorState.d.ts.map +1 -1
  33. package/lib/stores/editor/editor-state/element-editor-state/ElementEditorState.js +10 -3
  34. package/lib/stores/editor/editor-state/element-editor-state/ElementEditorState.js.map +1 -1
  35. package/lib/stores/editor/editor-state/element-editor-state/FunctionActivatorState.d.ts.map +1 -1
  36. package/lib/stores/editor/editor-state/element-editor-state/FunctionActivatorState.js +17 -2
  37. package/lib/stores/editor/editor-state/element-editor-state/FunctionActivatorState.js.map +1 -1
  38. package/lib/stores/editor/editor-state/element-editor-state/function-activator/HostedServiceFunctionActivatorEditorState.d.ts +53 -0
  39. package/lib/stores/editor/editor-state/element-editor-state/function-activator/HostedServiceFunctionActivatorEditorState.d.ts.map +1 -0
  40. package/lib/stores/editor/editor-state/element-editor-state/function-activator/HostedServiceFunctionActivatorEditorState.js +150 -0
  41. package/lib/stores/editor/editor-state/element-editor-state/function-activator/HostedServiceFunctionActivatorEditorState.js.map +1 -0
  42. package/lib/stores/editor/utils/ModelClassifierUtils.d.ts +1 -0
  43. package/lib/stores/editor/utils/ModelClassifierUtils.d.ts.map +1 -1
  44. package/lib/stores/editor/utils/ModelClassifierUtils.js +1 -0
  45. package/lib/stores/editor/utils/ModelClassifierUtils.js.map +1 -1
  46. package/lib/stores/graph-modifier/DSL_FunctionActivator_GraphModifierHelper.d.ts +28 -0
  47. package/lib/stores/graph-modifier/DSL_FunctionActivator_GraphModifierHelper.d.ts.map +1 -0
  48. package/lib/stores/graph-modifier/DSL_FunctionActivator_GraphModifierHelper.js +55 -0
  49. package/lib/stores/graph-modifier/DSL_FunctionActivator_GraphModifierHelper.js.map +1 -0
  50. package/lib/stores/project-reviewer/ProjectReviewerStore.d.ts +9 -7
  51. package/lib/stores/project-reviewer/ProjectReviewerStore.d.ts.map +1 -1
  52. package/lib/stores/project-reviewer/ProjectReviewerStore.js +58 -36
  53. package/lib/stores/project-reviewer/ProjectReviewerStore.js.map +1 -1
  54. package/package.json +5 -5
  55. package/src/components/editor/editor-group/EditorGroup.tsx +10 -0
  56. package/src/components/editor/editor-group/UnsupportedElementEditor.tsx +38 -9
  57. package/src/components/editor/editor-group/function-activator/FunctionEditor.tsx +10 -6
  58. package/src/components/editor/editor-group/function-activator/HostedServiceFunctionActivatorEditor.tsx +631 -0
  59. package/src/components/editor/editor-group/function-activator/SnowflakeAppFunctionActivatorEditor.tsx +51 -3
  60. package/src/components/project-reviewer/ProjectReviewSideBar.tsx +1 -1
  61. package/src/components/project-reviewer/ProjectReviewer.tsx +1 -1
  62. package/src/stores/editor/EditorGraphState.ts +3 -0
  63. package/src/stores/editor/EditorTabManagerState.ts +7 -0
  64. package/src/stores/editor/editor-state/element-editor-state/ElementEditorState.ts +22 -5
  65. package/src/stores/editor/editor-state/element-editor-state/FunctionActivatorState.ts +17 -1
  66. package/src/stores/editor/editor-state/element-editor-state/function-activator/HostedServiceFunctionActivatorEditorState.ts +212 -0
  67. package/src/stores/editor/utils/ModelClassifierUtils.ts +1 -0
  68. package/src/stores/graph-modifier/DSL_FunctionActivator_GraphModifierHelper.ts +96 -0
  69. package/src/stores/project-reviewer/ProjectReviewerStore.ts +85 -60
  70. package/tsconfig.json +3 -0
@@ -33,17 +33,19 @@ import {
33
33
  generateFunctionPrettyName,
34
34
  RelationalDatabaseConnection,
35
35
  DatabaseType,
36
+ DeploymentOwner,
36
37
  } from '@finos/legend-graph';
37
38
  import { observer } from 'mobx-react-lite';
38
39
  import { useApplicationStore } from '@finos/legend-application';
39
40
  import { useEditorStore } from '../../EditorStoreProvider.js';
40
41
  import { SnowflakeAppFunctionActivatorEdtiorState } from '../../../../stores/editor/editor-state/element-editor-state/function-activator/SnowflakeAppFunctionActivatorEditorState.js';
41
42
  import { flowResult } from 'mobx';
42
- import { useRef } from 'react';
43
+ import { useRef, useState } from 'react';
43
44
  import {
44
45
  buildRelationalDatabaseConnectionOption,
45
46
  type RelationalDatabaseConnectionOption,
46
47
  } from '../connection-editor/RelationalDatabaseConnectionEditor.js';
48
+ import { activator_setDeploymentOwner } from '../../../../stores/graph-modifier/DSL_FunctionActivator_GraphModifierHelper.js';
47
49
 
48
50
  export const SnowflakeAppFunctionActivatorEditor = observer(() => {
49
51
  const editorStore = useEditorStore();
@@ -51,7 +53,9 @@ export const SnowflakeAppFunctionActivatorEditor = observer(() => {
51
53
  const editorState = editorStore.tabManagerState.getCurrentEditorState(
52
54
  SnowflakeAppFunctionActivatorEdtiorState,
53
55
  );
56
+ const isReadOnly = editorState.isReadOnly;
54
57
  const activator = editorState.activator;
58
+ const ownership = activator.ownership;
55
59
  const connectionSelectorRef = useRef<SelectComponent>(null);
56
60
  const connectionFilterOption = createFilter({
57
61
  ignoreCase: true,
@@ -86,7 +90,7 @@ export const SnowflakeAppFunctionActivatorEditor = observer(() => {
86
90
  : initializeActivationConnection(connectionOptions.at(0)?.value);
87
91
 
88
92
  const changeConnection = (val: RelationalDatabaseConnectionOption): void => {
89
- if (val.value === activationConnection) {
93
+ if (!isReadOnly && val.value === activationConnection) {
90
94
  return;
91
95
  }
92
96
  editorState.updateConnection(val.value);
@@ -94,7 +98,9 @@ export const SnowflakeAppFunctionActivatorEditor = observer(() => {
94
98
  const changeDescription: React.ChangeEventHandler<HTMLTextAreaElement> = (
95
99
  event,
96
100
  ) => {
97
- editorState.updateAppDescription(event.target.value);
101
+ if (!isReadOnly) {
102
+ editorState.updateAppDescription(event.target.value);
103
+ }
98
104
  };
99
105
  const visitFunction = (): void =>
100
106
  editorState.editorStore.graphEditorMode.openElement(
@@ -116,6 +122,17 @@ export const SnowflakeAppFunctionActivatorEditor = observer(() => {
116
122
  );
117
123
  };
118
124
 
125
+ //Ownership
126
+ const [ownerInputValue, setOwner] = useState<string>('');
127
+ const updateDeploymentIdentifier: React.ChangeEventHandler<
128
+ HTMLInputElement
129
+ > = (event) => {
130
+ if (!isReadOnly) {
131
+ setOwner(event.target.value);
132
+ activator_setDeploymentOwner(ownership, event.target.value);
133
+ }
134
+ };
135
+
119
136
  return (
120
137
  <div className="snowflake-app-function-activator-editor">
121
138
  <Panel>
@@ -225,6 +242,7 @@ export const SnowflakeAppFunctionActivatorEditor = observer(() => {
225
242
  <PanelForm>
226
243
  <PanelFormTextField
227
244
  value={activator.applicationName}
245
+ isReadOnly={isReadOnly}
228
246
  name="Activator Identifer"
229
247
  placeholder="Specify the name of the UDTF for this activator..."
230
248
  update={(value: string | undefined): void =>
@@ -241,11 +259,41 @@ export const SnowflakeAppFunctionActivatorEditor = observer(() => {
241
259
  <textarea
242
260
  className="panel__content__form__section__textarea service-editor__documentation__input"
243
261
  spellCheck={false}
262
+ disabled={isReadOnly}
244
263
  value={activator.description}
245
264
  onChange={changeDescription}
246
265
  />
247
266
  </div>
248
267
  </PanelForm>
268
+ <PanelForm>
269
+ <div>
270
+ <div className="panel__content__form__section">
271
+ <div className="panel__content__form__section__header__label">
272
+ Ownership
273
+ </div>
274
+ <div className="panel__content__form__section__header__prompt">
275
+ The ownership model you want to use to control your snowflake
276
+ app.
277
+ </div>
278
+ </div>
279
+ {ownership instanceof DeploymentOwner && (
280
+ <div className="panel__content__form__section">
281
+ <div>
282
+ <div className="panel__content__form__section__header__label">
283
+ Deployment Identifier :
284
+ </div>
285
+ <input
286
+ className="panel__content__form__section__input"
287
+ spellCheck={false}
288
+ disabled={isReadOnly}
289
+ value={ownerInputValue}
290
+ onChange={updateDeploymentIdentifier}
291
+ />
292
+ </div>
293
+ </div>
294
+ )}
295
+ </div>
296
+ </PanelForm>
249
297
  </PanelContent>
250
298
  </Panel>
251
299
  </div>
@@ -90,7 +90,7 @@ export const ProjectReviewerSideBar = observer(() => {
90
90
  }
91
91
  // Actions
92
92
  const isDispatchingAction =
93
- reviewStore.fetchComparisonState.isInProgress ||
93
+ reviewStore.buildReviewReportState.isInProgress ||
94
94
  reviewStore.approveState.isInProgress ||
95
95
  reviewStore.closeState.isInProgress ||
96
96
  reviewStore.commitState.isInProgress ||
@@ -65,7 +65,7 @@ const ProjectReviewerStatusBar = observer(() => {
65
65
  ? 'closing review...'
66
66
  : reviewStore.reOpenState.isInProgress
67
67
  ? 'reopening review...'
68
- : reviewStore.fetchComparisonState.isInProgress
68
+ : reviewStore.buildReviewReportState.isInProgress
69
69
  ? 'loading changes...'
70
70
  : undefined;
71
71
  const toggleAssistant = (): void =>
@@ -89,6 +89,7 @@ import {
89
89
  ExecutionEnvironmentInstance,
90
90
  SnowflakeApp,
91
91
  GraphEntities,
92
+ HostedService,
92
93
  } from '@finos/legend-graph';
93
94
  import { CONFIGURATION_EDITOR_TAB } from './editor-state/project-configuration-editor-state/ProjectConfigurationEditorState.js';
94
95
  import { PACKAGEABLE_ELEMENT_TYPE } from './utils/ModelClassifierUtils.js';
@@ -872,6 +873,8 @@ export class EditorGraphState {
872
873
  return PACKAGEABLE_ELEMENT_TYPE.EXECUTION_ENVIRONMENT;
873
874
  } else if (element instanceof SnowflakeApp) {
874
875
  return PACKAGEABLE_ELEMENT_TYPE.SNOWFLAKE_APP;
876
+ } else if (element instanceof HostedService) {
877
+ return PACKAGEABLE_ELEMENT_TYPE.HOSTED_SERVICE;
875
878
  }
876
879
  const extraElementTypeLabelGetters = this.editorStore.pluginManager
877
880
  .getApplicationPlugins()
@@ -34,6 +34,7 @@ import {
34
34
  Service,
35
35
  INTERNAL__UnknownFunctionActivator,
36
36
  SnowflakeApp,
37
+ HostedService,
37
38
  } from '@finos/legend-graph';
38
39
  import {
39
40
  type Clazz,
@@ -61,6 +62,7 @@ import type { DSL_LegendStudioApplicationPlugin_Extension } from '../LegendStudi
61
62
  import { TabManagerState } from '@finos/legend-lego/application';
62
63
  import { INTERNAL__UnknownFunctionActivatorEdtiorState } from './editor-state/element-editor-state/function-activator/INTERNAL__UnknownFunctionActivatorEditorState.js';
63
64
  import { SnowflakeAppFunctionActivatorEdtiorState } from './editor-state/element-editor-state/function-activator/SnowflakeAppFunctionActivatorEditorState.js';
65
+ import { HostedServiceFunctionActivatorEditorState } from './editor-state/element-editor-state/function-activator/HostedServiceFunctionActivatorEditorState.js';
64
66
 
65
67
  export class EditorTabManagerState extends TabManagerState {
66
68
  readonly editorStore: EditorStore;
@@ -133,6 +135,11 @@ export class EditorTabManagerState extends TabManagerState {
133
135
  this.editorStore,
134
136
  element,
135
137
  );
138
+ } else if (element instanceof HostedService) {
139
+ return new HostedServiceFunctionActivatorEditorState(
140
+ this.editorStore,
141
+ element,
142
+ );
136
143
  } else if (element instanceof INTERNAL__UnknownFunctionActivator) {
137
144
  return new INTERNAL__UnknownFunctionActivatorEdtiorState(
138
145
  this.editorStore,
@@ -23,12 +23,15 @@ import {
23
23
  LogEvent,
24
24
  assertErrorThrown,
25
25
  guaranteeNonNullable,
26
+ guaranteeType,
27
+ isType,
26
28
  } from '@finos/legend-shared';
27
29
  import {
28
30
  type CompilationError,
29
31
  type PackageableElement,
30
32
  GRAPH_MANAGER_EVENT,
31
33
  isElementReadOnly,
34
+ INTERNAL__UnknownPackageableElement,
32
35
  } from '@finos/legend-graph';
33
36
  import { DEFAULT_TAB_SIZE } from '@finos/legend-application';
34
37
  import type { ElementFileGenerationState } from './ElementFileGenerationState.js';
@@ -198,12 +201,26 @@ export abstract class ElementEditorState extends EditorState {
198
201
  );
199
202
  } catch (error) {
200
203
  assertErrorThrown(error);
201
- this.setTextContent(
202
- generateMultiLineCommentForError(
203
- `Can't generate protocol JSON for element`,
204
- error,
205
- ),
204
+ const isUnknownEntity = isType(
205
+ this.element,
206
+ INTERNAL__UnknownPackageableElement,
206
207
  );
208
+ if (isUnknownEntity) {
209
+ const unknownEntity = guaranteeType(
210
+ this.element,
211
+ INTERNAL__UnknownPackageableElement,
212
+ );
213
+ this.setTextContent(
214
+ JSON.stringify(unknownEntity.content, undefined, DEFAULT_TAB_SIZE),
215
+ );
216
+ } else {
217
+ this.setTextContent(
218
+ generateMultiLineCommentForError(
219
+ `Can't generate protocol JSON for element`,
220
+ error,
221
+ ),
222
+ );
223
+ }
207
224
  this.editorStore.applicationStore.logService.error(
208
225
  LogEvent.create(GRAPH_MANAGER_EVENT.PARSING_FAILURE),
209
226
  error,
@@ -25,8 +25,9 @@ import {
25
25
  extractPackagePathFromPath,
26
26
  SnowflakeAppDeploymentConfiguration,
27
27
  DeploymentOwner,
28
+ HostedService,
28
29
  } from '@finos/legend-graph';
29
- import { type GeneratorFn } from '@finos/legend-shared';
30
+ import { uuid, type GeneratorFn } from '@finos/legend-shared';
30
31
  import { FUNCTION_ACTIVATE_TYPE } from '../../../../components/editor/editor-group/function-activator/FunctionEditor.js';
31
32
 
32
33
  const BASE_ACTIVATOR_NAME = 'NewActivator';
@@ -100,6 +101,21 @@ export class FunctionActivatorState {
100
101
  new SnowflakeAppDeploymentConfiguration();
101
102
  return snowflakeApp;
102
103
  }
104
+ case FUNCTION_ACTIVATE_TYPE.HOSTED_SERVICE: {
105
+ const activatorName = this.activatorPath.includes('::')
106
+ ? extractElementNameFromPath(this.activatorPath)
107
+ : this.activatorPath;
108
+ const hostedService = new HostedService(activatorName);
109
+ hostedService.documentation = '';
110
+ hostedService.ownership = new DeploymentOwner('', hostedService);
111
+ hostedService.pattern = `/${uuid()}`;
112
+ hostedService.autoActivateUpdates = true;
113
+ hostedService.storeModel = false;
114
+ hostedService.generateLineage = false;
115
+ hostedService.function =
116
+ PackageableElementExplicitReference.create(functionElement);
117
+ return hostedService;
118
+ }
103
119
  default:
104
120
  return undefined;
105
121
  }
@@ -0,0 +1,212 @@
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
+ InMemoryGraphData,
19
+ HostedService,
20
+ observe_HostedService,
21
+ DeploymentOwner,
22
+ UserList,
23
+ } from '@finos/legend-graph';
24
+ import {
25
+ type GeneratorFn,
26
+ ActionState,
27
+ assertErrorThrown,
28
+ guaranteeType,
29
+ type PlainObject,
30
+ } from '@finos/legend-shared';
31
+ import { makeObservable, action, flow, computed } from 'mobx';
32
+ import type { EditorStore } from '../../../EditorStore.js';
33
+ import { ElementEditorState } from '../ElementEditorState.js';
34
+ import { activator_setOwnership } from '../../../../graph-modifier/DSL_FunctionActivator_GraphModifierHelper.js';
35
+ import { User } from '@finos/legend-server-sdlc';
36
+
37
+ //Ownership
38
+ enum HostedServiceOwnershipType {
39
+ DEPLOYMENT_OWNERSHIP = 'deploymentOwnership',
40
+ USERLIST_OWNERSHIP = 'userListOwnership',
41
+ }
42
+ export const MINIMUM_HOSTED_SERVICE_OWNERS = 2;
43
+ export const DeploymentOwnershipLabel = 'Deployment';
44
+ export const UserlistOwnershipLabel = 'User List';
45
+
46
+ export const OWNERSHIP_OPTIONS = [
47
+ {
48
+ label: DeploymentOwnershipLabel,
49
+ value: HostedServiceOwnershipType.DEPLOYMENT_OWNERSHIP,
50
+ },
51
+ {
52
+ label: UserlistOwnershipLabel,
53
+ value: HostedServiceOwnershipType.USERLIST_OWNERSHIP,
54
+ },
55
+ ];
56
+
57
+ export type HostedServiceOwnerOption = {
58
+ label: string;
59
+ value: string;
60
+ };
61
+
62
+ export class HostedServiceFunctionActivatorEditorState extends ElementEditorState {
63
+ readonly validateState = ActionState.create();
64
+ readonly deployState = ActionState.create();
65
+
66
+ constructor(editorStore: EditorStore, element: HostedService) {
67
+ super(editorStore, element);
68
+
69
+ makeObservable(this, {
70
+ activator: computed,
71
+ reprocess: action,
72
+ updateDocumentation: action,
73
+ updatePattern: action,
74
+ setSelectedOwnership: action,
75
+ selectedOwnership: computed,
76
+ storeModel: action,
77
+ generateLineage: action,
78
+ validate: flow,
79
+ deployToSandbox: flow,
80
+ searchUsers: flow,
81
+ });
82
+ }
83
+
84
+ get activator(): HostedService {
85
+ return observe_HostedService(
86
+ guaranteeType(
87
+ this.element,
88
+ HostedService,
89
+ 'Element inside hosted service state must be a HostedService',
90
+ ),
91
+ );
92
+ }
93
+
94
+ updateDocumentation(val: string): void {
95
+ this.activator.documentation = val;
96
+ }
97
+
98
+ updatePattern(val: string): void {
99
+ this.activator.pattern = val;
100
+ }
101
+
102
+ storeModel(val: boolean): void {
103
+ this.activator.storeModel = val;
104
+ }
105
+
106
+ generateLineage(val: boolean): void {
107
+ this.activator.generateLineage = val;
108
+ }
109
+
110
+ get selectedOwnership(): HostedServiceOwnerOption | undefined {
111
+ const ownership = this.activator.ownership;
112
+ if (ownership instanceof DeploymentOwner) {
113
+ return {
114
+ label: DeploymentOwnershipLabel,
115
+ value: HostedServiceOwnershipType.DEPLOYMENT_OWNERSHIP,
116
+ };
117
+ } else if (ownership instanceof UserList) {
118
+ return {
119
+ label: UserlistOwnershipLabel,
120
+ value: HostedServiceOwnershipType.USERLIST_OWNERSHIP,
121
+ };
122
+ }
123
+ return undefined;
124
+ }
125
+
126
+ setSelectedOwnership(o: HostedServiceOwnerOption): void {
127
+ switch (o.value) {
128
+ case HostedServiceOwnershipType.DEPLOYMENT_OWNERSHIP: {
129
+ activator_setOwnership(
130
+ this.activator,
131
+ new DeploymentOwner('', this.activator),
132
+ );
133
+ break;
134
+ }
135
+ case HostedServiceOwnershipType.USERLIST_OWNERSHIP: {
136
+ const currentUserId =
137
+ this.editorStore.graphManagerState.graphManager.TEMPORARY__getEngineConfig()
138
+ .currentUserId;
139
+ activator_setOwnership(
140
+ this.activator,
141
+ new UserList(currentUserId ? [currentUserId] : [], this.activator),
142
+ );
143
+ break;
144
+ }
145
+ default: {
146
+ this.editorStore.applicationStore.notificationService.notifyError(
147
+ 'Unsupported ownership type',
148
+ );
149
+ }
150
+ }
151
+ }
152
+
153
+ *validate(): GeneratorFn<void> {
154
+ this.validateState.inProgress();
155
+ try {
156
+ yield this.editorStore.graphManagerState.graphManager.validateFunctionActivator(
157
+ this.activator,
158
+ new InMemoryGraphData(this.editorStore.graphManagerState.graph),
159
+ );
160
+ this.editorStore.applicationStore.notificationService.notifySuccess(
161
+ `Hosted Service is valid`,
162
+ );
163
+ } catch (error) {
164
+ assertErrorThrown(error);
165
+ this.editorStore.applicationStore.notificationService.notifyError(error);
166
+ } finally {
167
+ this.validateState.complete();
168
+ }
169
+ }
170
+
171
+ *deployToSandbox(): GeneratorFn<void> {
172
+ this.deployState.inProgress();
173
+ try {
174
+ yield this.editorStore.graphManagerState.graphManager.publishFunctionActivatorToSandbox(
175
+ this.activator,
176
+ new InMemoryGraphData(this.editorStore.graphManagerState.graph),
177
+ );
178
+ this.editorStore.applicationStore.notificationService.notifySuccess(
179
+ 'Hosted Service Function Activator has been deployed successfully',
180
+ );
181
+ } catch (error) {
182
+ assertErrorThrown(error);
183
+ this.editorStore.applicationStore.notificationService.notifyError(error);
184
+ } finally {
185
+ this.deployState.complete();
186
+ }
187
+ }
188
+
189
+ *searchUsers(name: string): GeneratorFn<User[]> {
190
+ try {
191
+ return (
192
+ (yield this.editorStore.sdlcServerClient.getUsers(
193
+ name,
194
+ )) as PlainObject<User>[]
195
+ ).map((p) => User.serialization.fromJson(p));
196
+ } catch (error) {
197
+ assertErrorThrown(error);
198
+ this.editorStore.applicationStore.notificationService.notifyError(error);
199
+ return [];
200
+ }
201
+ }
202
+
203
+ reprocess(
204
+ newElement: HostedService,
205
+ editorStore: EditorStore,
206
+ ): HostedServiceFunctionActivatorEditorState {
207
+ return new HostedServiceFunctionActivatorEditorState(
208
+ editorStore,
209
+ newElement,
210
+ );
211
+ }
212
+ }
@@ -70,6 +70,7 @@ export enum PACKAGEABLE_ELEMENT_TYPE {
70
70
  SECTION_INDEX = 'SECTION_INDEX',
71
71
  DATA = 'DATA',
72
72
  SNOWFLAKE_APP = 'SNOWFLAKE_APP',
73
+ HOSTED_SERVICE = 'HOSTED_SERVICE',
73
74
 
74
75
  TEMPORARY__LOCAL_CONNECTION = 'LOCAL_CONNECTION',
75
76
  INTERNAL__UNKNOWN = 'UNKNOWN',
@@ -0,0 +1,96 @@
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
+ type HostedService,
19
+ DEFAULT_HOSTED_SERVICE_PATTERN,
20
+ type FunctionActivator,
21
+ type Ownership,
22
+ observe_FunctionActivatorOwnership,
23
+ type DeploymentOwner,
24
+ type UserList,
25
+ } from '@finos/legend-graph';
26
+ import { action } from 'mobx';
27
+
28
+ export const hostedService_setDocumentation = action(
29
+ (hostedService: HostedService, val: string): void => {
30
+ hostedService.documentation = val;
31
+ },
32
+ );
33
+
34
+ export const hostedService_setAutoActivateUpdates = action(
35
+ (hostedService: HostedService, val: boolean): void => {
36
+ hostedService.autoActivateUpdates = val;
37
+ },
38
+ );
39
+
40
+ export const hostedService_setPattern = action(
41
+ (hostedService: HostedService, val: string): void => {
42
+ hostedService.pattern = val;
43
+ },
44
+ );
45
+
46
+ export const hostedService_removePatternParameter = action(
47
+ (hostedService: HostedService, value: string): void => {
48
+ const newPattern = hostedService.pattern
49
+ .replace(new RegExp(`\\/\\{${value}\\}`, 'ug'), '')
50
+ .replace(/\/{2,}/gu, '/');
51
+ hostedService.pattern =
52
+ newPattern !== '' ? newPattern : DEFAULT_HOSTED_SERVICE_PATTERN;
53
+ },
54
+ );
55
+
56
+ export const hostedService_setStoreModel = action(
57
+ (hostedService: HostedService, val: boolean): void => {
58
+ hostedService.storeModel = val;
59
+ },
60
+ );
61
+
62
+ export const hostedService_setGenerateLineage = action(
63
+ (hostedService: HostedService, val: boolean): void => {
64
+ hostedService.generateLineage = val;
65
+ },
66
+ );
67
+
68
+ export const activator_setOwnership = action(
69
+ (activator: FunctionActivator, value: Ownership): void => {
70
+ activator.ownership = observe_FunctionActivatorOwnership(value);
71
+ },
72
+ );
73
+
74
+ export const activator_setDeploymentOwner = action(
75
+ (deploymentOwner: DeploymentOwner, value: string): void => {
76
+ deploymentOwner.id = value;
77
+ },
78
+ );
79
+
80
+ export const activator_addUserOwner = action(
81
+ (userList: UserList, value: string): void => {
82
+ userList.users.push(value);
83
+ },
84
+ );
85
+
86
+ export const activator_updateUserOwnership = action(
87
+ (userList: UserList, value: string, index: number): void => {
88
+ userList.users[index] = value;
89
+ },
90
+ );
91
+
92
+ export const activator_deleteValueFromUserOwnership = action(
93
+ (userList: UserList, index: number): void => {
94
+ userList.users.splice(index, 1);
95
+ },
96
+ );