@finos/legend-application 3.0.2 → 4.0.1

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 (178) hide show
  1. package/lib/application/LegendApplication.d.ts +2 -2
  2. package/lib/application/LegendApplication.d.ts.map +1 -1
  3. package/lib/application/LegendApplication.js +4 -4
  4. package/lib/application/LegendApplication.js.map +1 -1
  5. package/lib/application/LegendApplicationPluginManager.d.ts +3 -3
  6. package/lib/application/LegendApplicationPluginManager.d.ts.map +1 -1
  7. package/lib/components/ActionAlert.d.ts +1 -1
  8. package/lib/components/ActionAlert.js +3 -3
  9. package/lib/components/ActionAlert.js.map +1 -1
  10. package/lib/components/ApplicationStoreProvider.d.ts +3 -3
  11. package/lib/components/ApplicationStoreProvider.d.ts.map +1 -1
  12. package/lib/components/ApplicationStoreProvider.js +2 -2
  13. package/lib/components/ApplicationStoreProvider.js.map +1 -1
  14. package/lib/components/ApplicationStoreProviderTestUtils.d.ts +5 -5
  15. package/lib/components/ApplicationStoreProviderTestUtils.d.ts.map +1 -1
  16. package/lib/components/ApplicationStoreProviderTestUtils.js +5 -4
  17. package/lib/components/ApplicationStoreProviderTestUtils.js.map +1 -1
  18. package/lib/components/ApplicationTestID.js +1 -1
  19. package/lib/components/ApplicationTestID.js.map +1 -1
  20. package/lib/components/BasicValueSpecificationEditor.d.ts +44 -0
  21. package/lib/components/BasicValueSpecificationEditor.d.ts.map +1 -0
  22. package/lib/components/BasicValueSpecificationEditor.js +276 -0
  23. package/lib/components/BasicValueSpecificationEditor.js.map +1 -0
  24. package/lib/components/BlockingAlert.d.ts +1 -1
  25. package/lib/components/BlockingAlert.js +1 -1
  26. package/lib/components/BlockingAlert.js.map +1 -1
  27. package/lib/components/CustomDatePicker.d.ts +38 -0
  28. package/lib/components/CustomDatePicker.d.ts.map +1 -0
  29. package/lib/components/CustomDatePicker.js +592 -0
  30. package/lib/components/CustomDatePicker.js.map +1 -0
  31. package/lib/components/DocumentationLink.d.ts +1 -1
  32. package/lib/components/DocumentationLink.js +2 -2
  33. package/lib/components/DocumentationLink.js.map +1 -1
  34. package/lib/components/LambdaEditor.d.ts +2 -2
  35. package/lib/components/LambdaEditor.d.ts.map +1 -1
  36. package/lib/components/LambdaEditor.js +3 -3
  37. package/lib/components/LambdaEditor.js.map +1 -1
  38. package/lib/components/LambdaParameterValuesEditor.d.ts +25 -0
  39. package/lib/components/LambdaParameterValuesEditor.d.ts.map +1 -0
  40. package/lib/components/LambdaParameterValuesEditor.js +52 -0
  41. package/lib/components/LambdaParameterValuesEditor.js.map +1 -0
  42. package/lib/components/LegendApplicationComponentFrameworkProvider.d.ts +1 -1
  43. package/lib/components/LegendApplicationComponentFrameworkProvider.js +3 -3
  44. package/lib/components/LegendApplicationComponentFrameworkProvider.js.map +1 -1
  45. package/lib/components/LegendApplicationNavigationContextServiceUtils.d.ts +32 -0
  46. package/lib/components/LegendApplicationNavigationContextServiceUtils.d.ts.map +1 -0
  47. package/lib/components/LegendApplicationNavigationContextServiceUtils.js +57 -0
  48. package/lib/components/LegendApplicationNavigationContextServiceUtils.js.map +1 -0
  49. package/lib/components/NotificationManager.d.ts +1 -1
  50. package/lib/components/NotificationManager.js +2 -2
  51. package/lib/components/NotificationManager.js.map +1 -1
  52. package/lib/components/TextInputEditor.d.ts +2 -2
  53. package/lib/components/TextInputEditor.d.ts.map +1 -1
  54. package/lib/components/TextInputEditor.js +2 -2
  55. package/lib/components/TextInputEditor.js.map +1 -1
  56. package/lib/components/{AppHeader.d.ts → VirtualAssistant.d.ts} +5 -5
  57. package/lib/components/VirtualAssistant.d.ts.map +1 -0
  58. package/lib/components/VirtualAssistant.js +171 -0
  59. package/lib/components/VirtualAssistant.js.map +1 -0
  60. package/lib/components/WebApplicationNavigatorProvider.d.ts +2 -2
  61. package/lib/components/WebApplicationNavigatorProvider.d.ts.map +1 -1
  62. package/lib/components/WebApplicationNavigatorProvider.js +1 -1
  63. package/lib/components/WebApplicationNavigatorProvider.js.map +1 -1
  64. package/lib/components/WebApplicationNavigatorProviderTestUtils.d.ts +2 -2
  65. package/lib/components/WebApplicationNavigatorProviderTestUtils.d.ts.map +1 -1
  66. package/lib/components/WebApplicationNavigatorProviderTestUtils.js +3 -2
  67. package/lib/components/WebApplicationNavigatorProviderTestUtils.js.map +1 -1
  68. package/lib/const.js +2 -2
  69. package/lib/const.js.map +1 -1
  70. package/lib/index.css +2 -2
  71. package/lib/index.css.map +1 -1
  72. package/lib/index.d.ts +30 -22
  73. package/lib/index.d.ts.map +1 -1
  74. package/lib/index.js +32 -22
  75. package/lib/index.js.map +1 -1
  76. package/lib/stores/ApplicationEvent.d.ts +9 -7
  77. package/lib/stores/ApplicationEvent.d.ts.map +1 -1
  78. package/lib/stores/ApplicationEvent.js +10 -8
  79. package/lib/stores/ApplicationEvent.js.map +1 -1
  80. package/lib/stores/ApplicationStore.d.ts +16 -10
  81. package/lib/stores/ApplicationStore.d.ts.map +1 -1
  82. package/lib/stores/ApplicationStore.js +28 -23
  83. package/lib/stores/ApplicationStore.js.map +1 -1
  84. package/lib/stores/ApplicationStoreTestUtils.d.ts +3 -3
  85. package/lib/stores/ApplicationStoreTestUtils.d.ts.map +1 -1
  86. package/lib/stores/ApplicationStoreTestUtils.js +2 -2
  87. package/lib/stores/ApplicationStoreTestUtils.js.map +1 -1
  88. package/lib/stores/ApplicationTelemetry.d.ts +1 -1
  89. package/lib/stores/ApplicationTelemetry.d.ts.map +1 -1
  90. package/lib/stores/ApplicationTelemetry.js +2 -2
  91. package/lib/stores/ApplicationTelemetry.js.map +1 -1
  92. package/lib/stores/CJS__Fuse.cjs +35 -0
  93. package/lib/stores/CJS__Fuse.cjs.map +1 -0
  94. package/lib/stores/CJS__Fuse.d.cts +28 -0
  95. package/lib/stores/CJS__Fuse.d.cts.map +1 -0
  96. package/lib/stores/LambdaEditorState.d.ts +1 -1
  97. package/lib/stores/LambdaEditorState.d.ts.map +1 -1
  98. package/lib/stores/LambdaEditorState.js +2 -2
  99. package/lib/stores/LambdaEditorState.js.map +1 -1
  100. package/lib/stores/LambdaParameterState.d.ts +59 -0
  101. package/lib/stores/LambdaParameterState.d.ts.map +1 -0
  102. package/lib/stores/LambdaParameterState.js +184 -0
  103. package/lib/stores/LambdaParameterState.js.map +1 -0
  104. package/lib/stores/LegendApplicationAssistantService.d.ts +63 -0
  105. package/lib/stores/LegendApplicationAssistantService.d.ts.map +1 -0
  106. package/lib/stores/LegendApplicationAssistantService.js +167 -0
  107. package/lib/stores/LegendApplicationAssistantService.js.map +1 -0
  108. package/lib/stores/LegendApplicationConfig.d.ts +5 -4
  109. package/lib/stores/LegendApplicationConfig.d.ts.map +1 -1
  110. package/lib/stores/LegendApplicationConfig.js +8 -3
  111. package/lib/stores/LegendApplicationConfig.js.map +1 -1
  112. package/lib/stores/LegendApplicationDocumentationService.d.ts +70 -0
  113. package/lib/stores/LegendApplicationDocumentationService.d.ts.map +1 -0
  114. package/lib/stores/LegendApplicationDocumentationService.js +152 -0
  115. package/lib/stores/LegendApplicationDocumentationService.js.map +1 -0
  116. package/lib/stores/LegendApplicationEventService.d.ts +22 -0
  117. package/lib/stores/LegendApplicationEventService.d.ts.map +1 -0
  118. package/lib/stores/LegendApplicationEventService.js +25 -0
  119. package/lib/stores/LegendApplicationEventService.js.map +1 -0
  120. package/lib/stores/LegendApplicationNavigationContextService.d.ts +74 -0
  121. package/lib/stores/LegendApplicationNavigationContextService.d.ts.map +1 -0
  122. package/lib/stores/LegendApplicationNavigationContextService.js +118 -0
  123. package/lib/stores/LegendApplicationNavigationContextService.js.map +1 -0
  124. package/lib/stores/LegendApplicationPlugin.d.ts +6 -2
  125. package/lib/stores/LegendApplicationPlugin.d.ts.map +1 -1
  126. package/lib/stores/LegendApplicationPlugin.js.map +1 -1
  127. package/lib/stores/PureLanguageSupport.d.ts.map +1 -1
  128. package/lib/stores/PureLanguageSupport.js +8 -2
  129. package/lib/stores/PureLanguageSupport.js.map +1 -1
  130. package/lib/stores/ValueSpecificationModifierHelper.d.ts +27 -0
  131. package/lib/stores/ValueSpecificationModifierHelper.d.ts.map +1 -0
  132. package/lib/stores/ValueSpecificationModifierHelper.js +49 -0
  133. package/lib/stores/ValueSpecificationModifierHelper.js.map +1 -0
  134. package/package.json +26 -20
  135. package/src/application/LegendApplication.tsx +6 -6
  136. package/src/application/LegendApplicationPluginManager.tsx +3 -3
  137. package/src/components/ActionAlert.tsx +3 -3
  138. package/src/components/ApplicationStoreProvider.tsx +4 -4
  139. package/src/components/ApplicationStoreProviderTestUtils.tsx +7 -6
  140. package/src/components/BasicValueSpecificationEditor.tsx +703 -0
  141. package/src/components/BlockingAlert.tsx +1 -1
  142. package/src/components/CustomDatePicker.tsx +1235 -0
  143. package/src/components/DocumentationLink.tsx +2 -2
  144. package/src/components/LambdaEditor.tsx +4 -4
  145. package/src/components/LambdaParameterValuesEditor.tsx +114 -0
  146. package/src/components/LegendApplicationComponentFrameworkProvider.tsx +3 -3
  147. package/src/components/LegendApplicationNavigationContextServiceUtils.tsx +63 -0
  148. package/src/components/NotificationManager.tsx +2 -2
  149. package/src/components/TextInputEditor.tsx +2 -2
  150. package/src/components/VirtualAssistant.tsx +600 -0
  151. package/src/components/WebApplicationNavigatorProvider.tsx +1 -1
  152. package/src/components/WebApplicationNavigatorProviderTestUtils.tsx +3 -2
  153. package/src/index.ts +39 -28
  154. package/src/stores/ApplicationEvent.ts +11 -7
  155. package/src/stores/ApplicationStore.ts +31 -29
  156. package/src/stores/ApplicationStoreTestUtils.ts +4 -4
  157. package/src/stores/ApplicationTelemetry.ts +2 -2
  158. package/src/stores/CJS__Fuse.cts +28 -0
  159. package/src/stores/LambdaEditorState.ts +5 -5
  160. package/src/stores/LambdaParameterState.ts +314 -0
  161. package/src/stores/LegendApplicationAssistantService.ts +218 -0
  162. package/src/stores/LegendApplicationConfig.ts +20 -6
  163. package/src/stores/LegendApplicationDocumentationService.ts +276 -0
  164. package/src/stores/LegendApplicationEventService.ts +32 -0
  165. package/src/stores/LegendApplicationNavigationContextService.ts +131 -0
  166. package/src/stores/LegendApplicationPlugin.ts +10 -2
  167. package/src/stores/PureLanguageSupport.ts +8 -2
  168. package/src/stores/ValueSpecificationModifierHelper.ts +104 -0
  169. package/tsconfig.json +18 -12
  170. package/lib/components/AppHeader.d.ts.map +0 -1
  171. package/lib/components/AppHeader.js +0 -26
  172. package/lib/components/AppHeader.js.map +0 -1
  173. package/lib/stores/LegendApplicationDocumentationRegistry.d.ts +0 -36
  174. package/lib/stores/LegendApplicationDocumentationRegistry.d.ts.map +0 -1
  175. package/lib/stores/LegendApplicationDocumentationRegistry.js +0 -47
  176. package/lib/stores/LegendApplicationDocumentationRegistry.js.map +0 -1
  177. package/src/components/AppHeader.tsx +0 -49
  178. package/src/stores/LegendApplicationDocumentationRegistry.ts +0 -81
package/src/index.ts CHANGED
@@ -14,31 +14,42 @@
14
14
  * limitations under the License.
15
15
  */
16
16
 
17
- export * from './const';
18
-
19
- export * from './application/LegendApplicationPluginManager';
20
- export * from './application/LegendApplication';
21
-
22
- export * from './components/ApplicationStoreProvider';
23
- export * from './components/WebApplicationNavigatorProvider';
24
- export * from './components/LegendApplicationComponentFrameworkProvider';
25
-
26
- export * from './components/ApplicationStoreProviderTestUtils';
27
- export * from './components/WebApplicationNavigatorProviderTestUtils';
28
-
29
- export { AppHeader } from './components/AppHeader';
30
- export { DocumentationLink } from './components/DocumentationLink';
31
- export * from './components/TextInputEditor';
32
- export * from './components/LambdaEditor';
33
-
34
- export * from './stores/ApplicationStore';
35
- export * from './stores/ApplicationTelemetry';
36
- export * from './stores/ApplicationEvent';
37
- export * from './stores/LegendApplicationConfig';
38
- export { WebApplicationNavigator } from './stores/WebApplicationNavigator';
39
- export { LambdaEditorState } from './stores/LambdaEditorState';
40
- export * from './stores/PackageableElementOption';
41
- export * from './stores/LegendApplicationDocumentationRegistry';
42
- export * from './stores/LegendApplicationPlugin';
43
-
44
- export * from './stores/ApplicationStoreTestUtils';
17
+ export * from './const.js';
18
+
19
+ export * from './application/LegendApplicationPluginManager.js';
20
+ export * from './application/LegendApplication.js';
21
+
22
+ export * from './components/ApplicationStoreProvider.js';
23
+ export * from './components/WebApplicationNavigatorProvider.js';
24
+ export * from './components/LegendApplicationComponentFrameworkProvider.js';
25
+ export * from './components/LegendApplicationNavigationContextServiceUtils.js';
26
+
27
+ export * from './components/ApplicationStoreProviderTestUtils.js';
28
+ export * from './components/WebApplicationNavigatorProviderTestUtils.js';
29
+
30
+ // TODO: consider moving this to `LegendApplicationComponentFrameworkProvider`
31
+ // once we think we can add virtual assistant support for all apps
32
+ export * from './components/VirtualAssistant.js';
33
+
34
+ export * from './components/DocumentationLink.js';
35
+ export * from './components/TextInputEditor.js';
36
+ export * from './components/LambdaEditor.js';
37
+ export * from './components/BasicValueSpecificationEditor.js';
38
+ export * from './components/LambdaParameterValuesEditor.js';
39
+
40
+ export * from './stores/ApplicationStore.js';
41
+ export * from './stores/ApplicationTelemetry.js';
42
+ export * from './stores/ApplicationEvent.js';
43
+ export * from './stores/LegendApplicationConfig.js';
44
+ export { WebApplicationNavigator } from './stores/WebApplicationNavigator.js';
45
+ export { LambdaEditorState } from './stores/LambdaEditorState.js';
46
+ export * from './stores/PackageableElementOption.js';
47
+ export * from './stores/LegendApplicationDocumentationService.js';
48
+ export * from './stores/LegendApplicationEventService.js';
49
+ export * from './stores/LegendApplicationAssistantService.js';
50
+ export * from './stores/LegendApplicationNavigationContextService.js';
51
+ export * from './stores/LegendApplicationPlugin.js';
52
+
53
+ export * from './stores/ApplicationStoreTestUtils.js';
54
+ export * from './stores/ValueSpecificationModifierHelper.js';
55
+ export * from './stores/LambdaParameterState.js';
@@ -15,13 +15,17 @@
15
15
  */
16
16
 
17
17
  export enum APPLICATION_EVENT {
18
- TEXT_EDITOR_FONT_LOADED = 'TEXT_EDITOR_FONT_LOADED',
19
- APPLICATION_SETUP_FAILURE = 'APPLICATION_SETUP_FAILURE',
18
+ TEXT_EDITOR_FONT_LOADED = 'application.load.font.success',
19
+ APPLICATION_SETUP_FAILURE = 'application.setup.failure',
20
20
 
21
- APPLICATION_FAILURE = 'APPLICATION_FAILURE',
22
- APPLICATION_CONFIGURATION_FAILURE = 'APPLICATION_CONFIGURATION_FAILURE',
23
- ILLEGAL_APPLICATION_STATE_OCCURRED = 'ILLEGAL_APPLICATION_STATE_OCCURRED',
24
- APPLICATION_LOADED = 'APPLICATION_LOADED',
21
+ ILLEGAL_APPLICATION_STATE_OCCURRED = 'application.error.illegal-state',
22
+ APPLICATION_CONFIGURATION_FAILURE = 'application.configuration.failure',
25
23
 
26
- DEVELOPMENT_ISSUE = 'DEVELOPMENT_ISSUE',
24
+ APPLICATION_DOCUMTENTION_LOAD_SKIPPED = 'application.load.documentation.skipped',
25
+ APPLICATION_CONTEXTUAL_DOCUMTENTION_LOAD_SKIPPED = 'application.load.contextual-documentation.skipped',
26
+
27
+ APPLICATION_LOADED = 'application.load.success',
28
+ APPLICATION_LOAD_FAILURE = 'application.load.failure',
29
+
30
+ DEVELOPMENT_ISSUE = 'development.issue',
27
31
  }
@@ -16,7 +16,6 @@
16
16
 
17
17
  import {
18
18
  type SuperGenericFunction,
19
- EventNotifierService,
20
19
  TracerService,
21
20
  TelemetryService,
22
21
  assertTrue,
@@ -27,11 +26,14 @@ import {
27
26
  ApplicationError,
28
27
  } from '@finos/legend-shared';
29
28
  import { makeAutoObservable, action } from 'mobx';
30
- import { APPLICATION_EVENT } from './ApplicationEvent';
31
- import type { LegendApplicationConfig } from './LegendApplicationConfig';
32
- import type { WebApplicationNavigator } from './WebApplicationNavigator';
33
- import type { LegendApplicationPluginManager } from '../application/LegendApplicationPluginManager';
34
- import { LegendApplicationDocumentationRegistry } from './LegendApplicationDocumentationRegistry';
29
+ import { APPLICATION_EVENT } from './ApplicationEvent.js';
30
+ import type { LegendApplicationConfig } from './LegendApplicationConfig.js';
31
+ import type { WebApplicationNavigator } from './WebApplicationNavigator.js';
32
+ import type { LegendApplicationPluginManager } from '../application/LegendApplicationPluginManager.js';
33
+ import { LegendApplicationDocumentationService } from './LegendApplicationDocumentationService.js';
34
+ import { LegendApplicationAssistantService } from './LegendApplicationAssistantService.js';
35
+ import { LegendApplicationEventService } from './LegendApplicationEventService.js';
36
+ import { LegendApplicationNavigationContextService } from './LegendApplicationNavigationContextService.js';
35
37
 
36
38
  export enum ActionAlertType {
37
39
  STANDARD = 'STANDARD',
@@ -101,17 +103,29 @@ export class Notification {
101
103
  }
102
104
 
103
105
  export class ApplicationStore<T extends LegendApplicationConfig> {
106
+ pluginManager: LegendApplicationPluginManager;
107
+ config: T;
108
+
109
+ // navigation
104
110
  navigator: WebApplicationNavigator;
111
+ navigationContextService: LegendApplicationNavigationContextService;
112
+
113
+ // TODO: refactor this to `NotificationService` including notifications and alerts
105
114
  notification?: Notification | undefined;
106
115
  blockingAlertInfo?: BlockingAlertInfo | undefined;
107
116
  actionAlertInfo?: ActionAlertInfo | undefined;
108
- config: T;
109
- docRegistry: LegendApplicationDocumentationRegistry;
110
117
 
118
+ // TODO: consider renaming this to `LogService`
111
119
  log: Log = new Log();
120
+
121
+ // documentation & help
122
+ documentationService: LegendApplicationDocumentationService;
123
+ assistantService: LegendApplicationAssistantService;
124
+
125
+ // communication
126
+ eventService = new LegendApplicationEventService();
112
127
  telemetryService = new TelemetryService();
113
128
  tracerService = new TracerService();
114
- eventNotifierService = new EventNotifierService();
115
129
 
116
130
  constructor(
117
131
  config: T,
@@ -121,7 +135,7 @@ export class ApplicationStore<T extends LegendApplicationConfig> {
121
135
  makeAutoObservable(this, {
122
136
  navigator: false,
123
137
  setBlockingAlert: action,
124
- setActionAltertInfo: action,
138
+ setActionAlertInfo: action,
125
139
  setNotification: action,
126
140
  notify: action,
127
141
  notifySuccess: action,
@@ -132,29 +146,17 @@ export class ApplicationStore<T extends LegendApplicationConfig> {
132
146
 
133
147
  this.config = config;
134
148
  this.navigator = navigator;
135
-
136
- // Documentation
137
- this.docRegistry = new LegendApplicationDocumentationRegistry();
138
- [
139
- ...pluginManager
140
- .getApplicationPlugins()
141
- .flatMap(
142
- (plugin) => plugin.getExtraKeyedDocumentationEntries?.() ?? [],
143
- ),
144
- // entries from config will override entries specified natively
145
- ...config.documentationKeyedEntries,
146
- ].forEach((entry) =>
147
- this.docRegistry.registerEntry(entry.key, entry.content),
148
- );
149
- this.docRegistry.url = this.config.documentationUrl;
150
-
151
- // Register plugins
149
+ this.pluginManager = pluginManager;
150
+ this.navigationContextService =
151
+ new LegendApplicationNavigationContextService();
152
+ this.documentationService = new LegendApplicationDocumentationService(this);
153
+ this.assistantService = new LegendApplicationAssistantService(this);
152
154
  this.log.registerPlugins(pluginManager.getLoggerPlugins());
153
155
  this.telemetryService.registerPlugins(
154
156
  pluginManager.getTelemetryServicePlugins(),
155
157
  );
156
158
  this.tracerService.registerPlugins(pluginManager.getTracerServicePlugins());
157
- this.eventNotifierService.registerPlugins(
159
+ this.eventService.registerEventNotifierPlugins(
158
160
  pluginManager.getEventNotifierPlugins(),
159
161
  );
160
162
  }
@@ -163,7 +165,7 @@ export class ApplicationStore<T extends LegendApplicationConfig> {
163
165
  this.blockingAlertInfo = alertInfo;
164
166
  }
165
167
 
166
- setActionAltertInfo(alertInfo: ActionAlertInfo | undefined): void {
168
+ setActionAlertInfo(alertInfo: ActionAlertInfo | undefined): void {
167
169
  if (this.actionAlertInfo && alertInfo) {
168
170
  this.notifyIllegalState(
169
171
  'Action alert is stacked: new alert is invoked while another one is being displayed',
@@ -14,11 +14,11 @@
14
14
  * limitations under the License.
15
15
  */
16
16
 
17
- import { ApplicationStore } from './ApplicationStore';
17
+ import { ApplicationStore } from './ApplicationStore.js';
18
18
  import { createBrowserHistory } from 'history';
19
- import { WebApplicationNavigator } from './WebApplicationNavigator';
20
- import type { LegendApplicationConfig } from './LegendApplicationConfig';
21
- import type { LegendApplicationPluginManager } from '../application/LegendApplicationPluginManager';
19
+ import { WebApplicationNavigator } from './WebApplicationNavigator.js';
20
+ import type { LegendApplicationConfig } from './LegendApplicationConfig.js';
21
+ import type { LegendApplicationPluginManager } from '../application/LegendApplicationPluginManager.js';
22
22
 
23
23
  export const TEST_DATA__applicationVersion = {
24
24
  buildTime: '2001-01-01T00:00:00-0000',
@@ -15,7 +15,7 @@
15
15
  */
16
16
 
17
17
  import type { TelemetryService } from '@finos/legend-shared';
18
- import { APPLICATION_EVENT } from './ApplicationEvent';
18
+ import { APPLICATION_EVENT } from './ApplicationEvent.js';
19
19
 
20
20
  type ApplicationLoaded_TelemetryData = {
21
21
  browser: {
@@ -28,7 +28,7 @@ type ApplicationLoaded_TelemetryData = {
28
28
  };
29
29
 
30
30
  export class ApplicationTelemetry {
31
- static logEvent_GraphInitialized(
31
+ static logEvent_AppInitialized(
32
32
  telemetryService: TelemetryService,
33
33
  data: ApplicationLoaded_TelemetryData,
34
34
  ): void {
@@ -0,0 +1,28 @@
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
+ /**
18
+ * Previously, these exports rely on ES module interop to expose `default` export
19
+ * properly. But since we use `ESM` for Typescript resolution now, we lose this
20
+ * so we have to workaround by importing these and re-export them from CJS
21
+ *
22
+ * TODO: remove these when the package properly work with Typescript's nodenext
23
+ * module resolution
24
+ *
25
+ * @workaround ESM
26
+ * See https://github.com/microsoft/TypeScript/issues/49298
27
+ */
28
+ export { default as Fuse } from 'fuse.js';
@@ -27,7 +27,7 @@ import {
27
27
  * editing _something_ but allows user to edit via text.
28
28
  */
29
29
  export abstract class LambdaEditorState {
30
- uuid = uuid();
30
+ readonly uuid = uuid();
31
31
  lambdaPrefix: string;
32
32
  lambdaString: string; // value shown in lambda editor which can be edited
33
33
  parserError?: ParserError | undefined;
@@ -71,8 +71,8 @@ export abstract class LambdaEditorState {
71
71
  setCompilationError(compilationError: CompilationError | undefined): void {
72
72
  // account for the lambda prefix offset in source information
73
73
  if (compilationError?.sourceInformation) {
74
- compilationError.setSourceInformation(
75
- this.processSourceInformation(compilationError.sourceInformation),
74
+ compilationError.sourceInformation = this.processSourceInformation(
75
+ compilationError.sourceInformation,
76
76
  );
77
77
  }
78
78
  this.compilationError = compilationError;
@@ -81,8 +81,8 @@ export abstract class LambdaEditorState {
81
81
  setParserError(parserError: ParserError | undefined): void {
82
82
  // account for the lambda prefix offset in source information
83
83
  if (parserError?.sourceInformation) {
84
- parserError.setSourceInformation(
85
- this.processSourceInformation(parserError.sourceInformation),
84
+ parserError.sourceInformation = this.processSourceInformation(
85
+ parserError.sourceInformation,
86
86
  );
87
87
  }
88
88
  this.parserError = parserError;
@@ -0,0 +1,314 @@
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 InstanceValue,
19
+ type Multiplicity,
20
+ type ObserverContext,
21
+ type Type,
22
+ type ValueSpecification,
23
+ type PureModel,
24
+ CollectionInstanceValue,
25
+ Enumeration,
26
+ EnumValueExplicitReference,
27
+ EnumValueInstanceValue,
28
+ GenericType,
29
+ GenericTypeExplicitReference,
30
+ getEnumValue,
31
+ observe_ValueSpecification,
32
+ observe_VariableExpression,
33
+ PrimitiveInstanceValue,
34
+ PrimitiveType,
35
+ PRIMITIVE_TYPE,
36
+ VariableExpression,
37
+ LambdaFunction,
38
+ TYPICAL_MULTIPLICITY_TYPE,
39
+ CORE_PURE_PATH,
40
+ FunctionType,
41
+ SimpleFunctionExpression,
42
+ SUPPORTED_FUNCTIONS,
43
+ extractElementNameFromPath,
44
+ } from '@finos/legend-graph';
45
+ import {
46
+ addUniqueEntry,
47
+ deleteEntry,
48
+ IllegalStateError,
49
+ isNonNullable,
50
+ Randomizer,
51
+ uuid,
52
+ } from '@finos/legend-shared';
53
+ import { makeObservable, observable, action } from 'mobx';
54
+ import {
55
+ genericType_setRawType,
56
+ multiplicity_setLowerBound,
57
+ multiplicity_setUpperBound,
58
+ } from './ValueSpecificationModifierHelper.js';
59
+ import { format, addDays } from 'date-fns';
60
+ import { DATE_FORMAT, DATE_TIME_FORMAT } from '../const.js';
61
+
62
+ export enum PARAMETER_SUBMIT_ACTION {
63
+ EXECUTE = 'EXECUTE',
64
+ EXPORT = 'EXPORT',
65
+ }
66
+
67
+ export const createMockEnumerationProperty = (
68
+ enumeration: Enumeration,
69
+ ): string =>
70
+ new Randomizer().getRandomItemInCollection(enumeration.values)?.name ?? '';
71
+
72
+ const createMockPrimitiveProperty = (
73
+ primitiveType: PrimitiveType,
74
+ propertyName: string,
75
+ ): string | number | boolean => {
76
+ const randomizer = new Randomizer();
77
+ switch (primitiveType.name) {
78
+ case PRIMITIVE_TYPE.BOOLEAN:
79
+ return randomizer.getRandomItemInCollection([true, false]) ?? true;
80
+ case PRIMITIVE_TYPE.FLOAT:
81
+ return randomizer.getRandomFloat();
82
+ case PRIMITIVE_TYPE.DECIMAL:
83
+ return randomizer.getRandomDouble();
84
+ case PRIMITIVE_TYPE.NUMBER:
85
+ case PRIMITIVE_TYPE.INTEGER:
86
+ return randomizer.getRandomWholeNumber(100);
87
+ // NOTE that `Date` is the umbrella type that comprises `StrictDate` and `DateTime`, but for simplicity, we will generate `Date` as `StrictDate`
88
+ case PRIMITIVE_TYPE.DATE:
89
+ case PRIMITIVE_TYPE.STRICTDATE:
90
+ return format(
91
+ randomizer.getRandomDate(
92
+ new Date(Date.now()),
93
+ addDays(Date.now(), 100),
94
+ ),
95
+ DATE_FORMAT,
96
+ );
97
+ case PRIMITIVE_TYPE.DATETIME:
98
+ return format(
99
+ randomizer.getRandomDate(
100
+ new Date(Date.now()),
101
+ addDays(Date.now(), 100),
102
+ ),
103
+ DATE_TIME_FORMAT,
104
+ );
105
+ case PRIMITIVE_TYPE.STRING:
106
+ default:
107
+ return `${propertyName} ${randomizer.getRandomWholeNumber(100)}`;
108
+ }
109
+ };
110
+
111
+ export const buildParametersLetLambdaFunc = (
112
+ graph: PureModel,
113
+ lambdaParametersStates: LambdaParameterState[],
114
+ ): LambdaFunction => {
115
+ const multiplicityOne = graph.getTypicalMultiplicity(
116
+ TYPICAL_MULTIPLICITY_TYPE.ONE,
117
+ );
118
+ const typeString = graph.getPrimitiveType(PRIMITIVE_TYPE.STRING);
119
+ const typeAny = graph.getType(CORE_PURE_PATH.ANY);
120
+ const letlambdaFunction = new LambdaFunction(
121
+ new FunctionType(typeAny, multiplicityOne),
122
+ );
123
+ letlambdaFunction.expressionSequence = lambdaParametersStates
124
+ .map((queryParamState) => {
125
+ if (queryParamState.value) {
126
+ const letFunc = new SimpleFunctionExpression(
127
+ extractElementNameFromPath(SUPPORTED_FUNCTIONS.LET),
128
+ multiplicityOne,
129
+ );
130
+ const letVar = new PrimitiveInstanceValue(
131
+ GenericTypeExplicitReference.create(new GenericType(typeString)),
132
+ multiplicityOne,
133
+ );
134
+ letVar.values = [queryParamState.variableName];
135
+ letFunc.parametersValues.push(letVar);
136
+ letFunc.parametersValues.push(queryParamState.value);
137
+ return letFunc;
138
+ }
139
+ return undefined;
140
+ })
141
+ .filter(isNonNullable);
142
+ return letlambdaFunction;
143
+ };
144
+
145
+ export class LambdaParameterState {
146
+ readonly uuid = uuid();
147
+ readonly parameter: VariableExpression;
148
+ observableContext: ObserverContext;
149
+ value: ValueSpecification | undefined;
150
+
151
+ constructor(
152
+ variableExpression: VariableExpression,
153
+ observableContext: ObserverContext,
154
+ ) {
155
+ makeObservable(this, {
156
+ value: observable,
157
+ setValue: action,
158
+ mockParameterValue: action,
159
+ });
160
+ this.observableContext = observableContext;
161
+ this.parameter = observe_VariableExpression(variableExpression);
162
+ }
163
+
164
+ mockParameterValue(): void {
165
+ this.setValue(
166
+ this.generateMockValues(
167
+ this.parameter.genericType?.value.rawType,
168
+ this.parameter.multiplicity,
169
+ ),
170
+ );
171
+ }
172
+
173
+ private generateMockValues(
174
+ varType: Type | undefined,
175
+ multiplicity: Multiplicity,
176
+ ): InstanceValue | undefined {
177
+ if ((!multiplicity.upperBound || multiplicity.upperBound > 1) && varType) {
178
+ return new CollectionInstanceValue(
179
+ multiplicity,
180
+ GenericTypeExplicitReference.create(new GenericType(varType)),
181
+ );
182
+ }
183
+ if (varType instanceof PrimitiveType) {
184
+ const primitiveInst = new PrimitiveInstanceValue(
185
+ GenericTypeExplicitReference.create(new GenericType(varType)),
186
+ multiplicity,
187
+ );
188
+ primitiveInst.values = [
189
+ createMockPrimitiveProperty(
190
+ varType,
191
+ this.parameter.name === '' ? 'myVar' : this.parameter.name,
192
+ ),
193
+ ];
194
+ return primitiveInst;
195
+ } else if (varType instanceof Enumeration) {
196
+ const enumValueInstance = new EnumValueInstanceValue(
197
+ GenericTypeExplicitReference.create(new GenericType(varType)),
198
+ multiplicity,
199
+ );
200
+ const mock = createMockEnumerationProperty(varType);
201
+ if (mock !== '') {
202
+ enumValueInstance.values = [
203
+ EnumValueExplicitReference.create(getEnumValue(varType, mock)),
204
+ ];
205
+ }
206
+ return enumValueInstance;
207
+ }
208
+ return undefined;
209
+ }
210
+
211
+ setValue(value: ValueSpecification | undefined): void {
212
+ if (value instanceof VariableExpression) {
213
+ throw new IllegalStateError(
214
+ 'Can not assign a parameter to another parameter',
215
+ );
216
+ }
217
+ this.value = value
218
+ ? observe_ValueSpecification(value, this.observableContext)
219
+ : undefined;
220
+ }
221
+
222
+ changeVariableType(type: Type): void {
223
+ if (type !== this.variableType) {
224
+ const genricType = this.parameter.genericType?.value;
225
+ if (genricType) {
226
+ genericType_setRawType(genricType, type);
227
+ }
228
+ this.mockParameterValue();
229
+ }
230
+ }
231
+
232
+ changeMultiplicity(
233
+ lowerBound: number,
234
+ uppderBound: number | undefined,
235
+ ): void {
236
+ const current = this.parameter.multiplicity;
237
+ if (
238
+ current.lowerBound !== lowerBound ||
239
+ current.upperBound !== uppderBound
240
+ ) {
241
+ multiplicity_setLowerBound(current, lowerBound);
242
+ multiplicity_setUpperBound(current, uppderBound);
243
+ this.mockParameterValue();
244
+ }
245
+ }
246
+
247
+ get variableName(): string {
248
+ return this.parameter.name;
249
+ }
250
+
251
+ get variableType(): Type | undefined {
252
+ return this.parameter.genericType?.value.rawType;
253
+ }
254
+ }
255
+
256
+ export class ParameterInstanceValuesEditorState {
257
+ showModal = false;
258
+ submitAction:
259
+ | {
260
+ handler: () => Promise<void>;
261
+ label: string;
262
+ }
263
+ | undefined;
264
+
265
+ constructor() {
266
+ makeObservable(this, {
267
+ showModal: observable,
268
+ submitAction: observable,
269
+ setShowModal: action,
270
+ open: action,
271
+ setSubmitAction: action,
272
+ });
273
+ }
274
+
275
+ setShowModal(val: boolean): void {
276
+ this.showModal = val;
277
+ }
278
+
279
+ setSubmitAction(
280
+ val:
281
+ | {
282
+ handler: () => Promise<void>;
283
+ label: string;
284
+ }
285
+ | undefined,
286
+ ): void {
287
+ this.submitAction = val;
288
+ }
289
+
290
+ open(handler: () => Promise<void>, label: string): void {
291
+ this.setSubmitAction({ handler, label });
292
+ this.setShowModal(true);
293
+ }
294
+
295
+ close(): void {
296
+ this.setSubmitAction(undefined);
297
+ this.setShowModal(false);
298
+ }
299
+ }
300
+ export class LambdaParametersState {
301
+ parameterStates: LambdaParameterState[] = [];
302
+ parameterValuesEditorState = new ParameterInstanceValuesEditorState();
303
+
304
+ addParameter(val: LambdaParameterState): void {
305
+ addUniqueEntry(this.parameterStates, val);
306
+ }
307
+
308
+ removeParameter(val: LambdaParameterState): void {
309
+ deleteEntry(this.parameterStates, val);
310
+ }
311
+ setParameters(val: LambdaParameterState[]): void {
312
+ this.parameterStates = val;
313
+ }
314
+ }