@finos/legend-application 7.2.0 → 8.0.0

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 (66) hide show
  1. package/lib/components/ActionAlert.js +2 -1
  2. package/lib/components/ActionAlert.js.map +1 -1
  3. package/lib/components/ApplicationStoreProvider.d.ts +3 -3
  4. package/lib/components/ApplicationStoreProvider.d.ts.map +1 -1
  5. package/lib/components/ApplicationStoreProviderTestUtils.d.ts +1 -1
  6. package/lib/components/ApplicationStoreProviderTestUtils.js.map +1 -1
  7. package/lib/components/VirtualAssistant.d.ts.map +1 -1
  8. package/lib/components/VirtualAssistant.js +21 -12
  9. package/lib/components/VirtualAssistant.js.map +1 -1
  10. package/lib/components/shared/CustomDatePicker.d.ts.map +1 -1
  11. package/lib/components/shared/CustomDatePicker.js +31 -9
  12. package/lib/components/shared/CustomDatePicker.js.map +1 -1
  13. package/lib/components/shared/TextSearchAdvancedConfigMenu.d.ts +22 -0
  14. package/lib/components/shared/TextSearchAdvancedConfigMenu.d.ts.map +1 -0
  15. package/lib/components/shared/TextSearchAdvancedConfigMenu.js +37 -0
  16. package/lib/components/shared/TextSearchAdvancedConfigMenu.js.map +1 -0
  17. package/lib/index.css +2 -2
  18. package/lib/index.css.map +1 -1
  19. package/lib/index.d.ts +2 -0
  20. package/lib/index.d.ts.map +1 -1
  21. package/lib/index.js +2 -0
  22. package/lib/index.js.map +1 -1
  23. package/lib/stores/ApplicationStore.d.ts +4 -4
  24. package/lib/stores/ApplicationStore.d.ts.map +1 -1
  25. package/lib/stores/ApplicationStore.js +7 -4
  26. package/lib/stores/ApplicationStore.js.map +1 -1
  27. package/lib/stores/ApplicationStoreTestUtils.d.ts +1 -1
  28. package/lib/stores/ApplicationStoreTestUtils.js.map +1 -1
  29. package/lib/stores/ApplicationTelemetry.d.ts +5 -0
  30. package/lib/stores/ApplicationTelemetry.d.ts.map +1 -1
  31. package/lib/stores/ApplicationTelemetry.js.map +1 -1
  32. package/lib/stores/AssistantService.d.ts +10 -2
  33. package/lib/stores/AssistantService.d.ts.map +1 -1
  34. package/lib/stores/AssistantService.js +55 -4
  35. package/lib/stores/AssistantService.js.map +1 -1
  36. package/lib/stores/LegendApplicationDocumentation.d.ts +19 -0
  37. package/lib/stores/LegendApplicationDocumentation.d.ts.map +1 -0
  38. package/lib/stores/LegendApplicationDocumentation.js +20 -0
  39. package/lib/stores/LegendApplicationDocumentation.js.map +1 -0
  40. package/lib/stores/PureLanguageSupport.js +3 -3
  41. package/lib/stores/PureLanguageSupport.js.map +1 -1
  42. package/lib/stores/shared/LambdaParameterState.d.ts +6 -2
  43. package/lib/stores/shared/LambdaParameterState.d.ts.map +1 -1
  44. package/lib/stores/shared/LambdaParameterState.js +26 -2
  45. package/lib/stores/shared/LambdaParameterState.js.map +1 -1
  46. package/lib/stores/shared/TextSearchAdvancedConfigState.d.ts +30 -0
  47. package/lib/stores/shared/TextSearchAdvancedConfigState.d.ts.map +1 -0
  48. package/lib/stores/shared/TextSearchAdvancedConfigState.js +59 -0
  49. package/lib/stores/shared/TextSearchAdvancedConfigState.js.map +1 -0
  50. package/package.json +9 -9
  51. package/src/components/ActionAlert.tsx +1 -1
  52. package/src/components/ApplicationStoreProvider.tsx +3 -3
  53. package/src/components/ApplicationStoreProviderTestUtils.tsx +2 -2
  54. package/src/components/VirtualAssistant.tsx +127 -76
  55. package/src/components/shared/CustomDatePicker.tsx +40 -2
  56. package/src/components/shared/TextSearchAdvancedConfigMenu.tsx +73 -0
  57. package/src/index.ts +3 -0
  58. package/src/stores/ApplicationStore.ts +10 -11
  59. package/src/stores/ApplicationStoreTestUtils.ts +2 -2
  60. package/src/stores/ApplicationTelemetry.ts +5 -0
  61. package/src/stores/AssistantService.ts +69 -4
  62. package/src/stores/LegendApplicationDocumentation.ts +19 -0
  63. package/src/stores/PureLanguageSupport.ts +3 -3
  64. package/src/stores/shared/LambdaParameterState.ts +33 -3
  65. package/src/stores/shared/TextSearchAdvancedConfigState.ts +65 -0
  66. package/tsconfig.json +3 -0
@@ -25,12 +25,15 @@ import {
25
25
  isNonNullable,
26
26
  ActionState,
27
27
  } from '@finos/legend-shared';
28
+ import { TextSearchAdvancedConfigState } from './shared/TextSearchAdvancedConfigState.js';
28
29
 
29
30
  export enum VIRTUAL_ASSISTANT_TAB {
30
31
  SEARCH = 'SEARCH',
31
32
  CONTEXTUAL_SUPPORT = 'CONTEXTUAL_SUPPORT',
32
33
  }
33
34
 
35
+ export const DOCUMENTATION_SEARCH_RESULTS_LIMIT = 100;
36
+
34
37
  export class VirtualAssistantDocumentationEntry {
35
38
  uuid = uuid();
36
39
  documentationKey: string;
@@ -79,7 +82,6 @@ export class VirtualAssistantContextualDocumentationEntry {
79
82
 
80
83
  export class AssistantService {
81
84
  readonly applicationStore: GenericLegendApplicationStore;
82
- private readonly searchEngine: Fuse<DocumentationEntry>;
83
85
  /**
84
86
  * This key is used to allow programmatic re-rendering of the assistant panel
85
87
  */
@@ -87,19 +89,28 @@ export class AssistantService {
87
89
  isHidden = false;
88
90
  isOpen = false;
89
91
  selectedTab = VIRTUAL_ASSISTANT_TAB.SEARCH;
92
+ currentDocumentationEntry: VirtualAssistantDocumentationEntry | undefined;
90
93
 
91
- searchResults: VirtualAssistantDocumentationEntry[] = [];
92
- searchState = ActionState.create().pass();
94
+ // search text
95
+ private readonly searchEngine: Fuse<DocumentationEntry>;
96
+ searchConfigurationState: TextSearchAdvancedConfigState;
97
+ searchState = ActionState.create();
93
98
  searchText = '';
99
+ searchResults: VirtualAssistantDocumentationEntry[] = [];
100
+ showSearchConfigurationMenu = false;
101
+ isOverSearchLimit = false;
94
102
 
95
103
  constructor(applicationStore: GenericLegendApplicationStore) {
96
104
  makeObservable(this, {
97
105
  isHidden: observable,
98
106
  isOpen: observable,
99
107
  panelRenderingKey: observable,
108
+ isOverSearchLimit: observable,
100
109
  selectedTab: observable,
101
110
  searchText: observable,
102
111
  searchResults: observable,
112
+ currentDocumentationEntry: observable,
113
+ showSearchConfigurationMenu: observable,
103
114
  currentContextualDocumentationEntry: computed,
104
115
  setIsHidden: action,
105
116
  setIsOpen: action,
@@ -107,7 +118,9 @@ export class AssistantService {
107
118
  setSearchText: action,
108
119
  resetSearch: action,
109
120
  search: action,
121
+ openDocumentationEntry: action,
110
122
  refreshPanelRendering: action,
123
+ setShowSearchConfigurationMenu: action,
111
124
  });
112
125
 
113
126
  this.applicationStore = applicationStore;
@@ -143,8 +156,14 @@ export class AssistantService {
143
156
  weight: 1,
144
157
  },
145
158
  ],
159
+ // extended search allows for exact word match through single quote
160
+ // See https://fusejs.io/examples.html#extended-search
161
+ useExtendedSearch: true,
146
162
  },
147
163
  );
164
+ this.searchConfigurationState = new TextSearchAdvancedConfigState(() => {
165
+ this.search();
166
+ });
148
167
  }
149
168
 
150
169
  get currentContextualDocumentationEntry():
@@ -159,6 +178,7 @@ export class AssistantService {
159
178
  this.applicationStore.documentationService.getContextualDocEntry(
160
179
  currentContext,
161
180
  );
181
+
162
182
  return currentContextualDocumentationEntry
163
183
  ? new VirtualAssistantContextualDocumentationEntry(
164
184
  currentContext,
@@ -181,6 +201,22 @@ export class AssistantService {
181
201
  : undefined;
182
202
  }
183
203
 
204
+ openDocumentationEntry(docKey: string): void {
205
+ const matchingDocEntry = this.applicationStore.documentationService
206
+ .getAllDocEntries()
207
+ .find((entry) => entry._documentationKey === docKey);
208
+
209
+ if (matchingDocEntry) {
210
+ this.setIsOpen(true);
211
+ this.setIsHidden(false);
212
+ this.currentDocumentationEntry = new VirtualAssistantDocumentationEntry(
213
+ matchingDocEntry,
214
+ );
215
+ this.currentDocumentationEntry.setIsOpen(true);
216
+ this.resetSearch();
217
+ }
218
+ }
219
+
184
220
  setIsHidden(val: boolean): void {
185
221
  this.isHidden = val;
186
222
  }
@@ -222,10 +258,39 @@ export class AssistantService {
222
258
  }
223
259
 
224
260
  search(): void {
261
+ if (!this.searchText) {
262
+ this.searchResults = [];
263
+ return;
264
+ }
265
+ this.currentDocumentationEntry = undefined;
225
266
  this.searchState.inProgress();
226
267
  this.searchResults = Array.from(
227
- this.searchEngine.search(this.searchText).values(),
268
+ this.searchEngine
269
+ .search(
270
+ this.searchConfigurationState.generateSearchText(this.searchText),
271
+ {
272
+ // NOTE: search for limit + 1 item so we can know if there are more search results
273
+ limit: DOCUMENTATION_SEARCH_RESULTS_LIMIT + 1,
274
+ },
275
+ )
276
+ .values(),
228
277
  ).map((result) => new VirtualAssistantDocumentationEntry(result.item));
278
+
279
+ // check if the search results exceed the limit
280
+ if (this.searchResults.length > DOCUMENTATION_SEARCH_RESULTS_LIMIT) {
281
+ this.isOverSearchLimit = true;
282
+ this.searchResults = this.searchResults.slice(
283
+ 0,
284
+ DOCUMENTATION_SEARCH_RESULTS_LIMIT,
285
+ );
286
+ } else {
287
+ this.isOverSearchLimit = false;
288
+ }
289
+
229
290
  this.searchState.complete();
230
291
  }
292
+
293
+ setShowSearchConfigurationMenu(val: boolean): void {
294
+ this.showSearchConfigurationMenu = val;
295
+ }
231
296
  }
@@ -0,0 +1,19 @@
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
+ export enum LEGEND_APPLICATION_DOCUMENTATION_KEY {
18
+ QUESTION_HOW_TO_USE_ADVANCED_SEARCH_SYNTAX = 'question.how-to-use-advanced-search-syntax',
19
+ }
@@ -124,10 +124,7 @@ const generateLanguageMonarch = (
124
124
  PURE_ELEMENT_NAME.MEASURE,
125
125
  PURE_ELEMENT_NAME.PROFILE,
126
126
  PURE_ELEMENT_NAME.FUNCTION,
127
- PURE_ELEMENT_NAME.FLAT_DATA,
128
- PURE_ELEMENT_NAME.DATABASE,
129
127
  PURE_ELEMENT_NAME.MAPPING,
130
- PURE_ELEMENT_NAME.SERVICE,
131
128
  PURE_ELEMENT_NAME.RUNTIME,
132
129
  PURE_ELEMENT_NAME.CONNECTION,
133
130
  PURE_ELEMENT_NAME.FILE_GENERATION,
@@ -148,6 +145,9 @@ const generateLanguageMonarch = (
148
145
  * @modularize
149
146
  * See https://github.com/finos/legend-studio/issues/65
150
147
  */
148
+ PURE_ELEMENT_NAME.SERVICE,
149
+ PURE_ELEMENT_NAME.FLAT_DATA,
150
+ PURE_ELEMENT_NAME.DATABASE,
151
151
  PURE_CONNECTION_NAME.FLAT_DATA_CONNECTION,
152
152
  PURE_CONNECTION_NAME.RELATIONAL_DATABASE_CONNECTION,
153
153
  'Relational',
@@ -38,11 +38,13 @@ import {
38
38
  import {
39
39
  addUniqueEntry,
40
40
  deleteEntry,
41
+ type Hashable,
42
+ hashArray,
41
43
  IllegalStateError,
42
44
  isNonNullable,
43
45
  uuid,
44
46
  } from '@finos/legend-shared';
45
- import { makeObservable, observable, action } from 'mobx';
47
+ import { makeObservable, observable, action, computed } from 'mobx';
46
48
  import {
47
49
  genericType_setRawType,
48
50
  multiplicity_setLowerBound,
@@ -54,6 +56,11 @@ export enum PARAMETER_SUBMIT_ACTION {
54
56
  EXPORT = 'EXPORT',
55
57
  }
56
58
 
59
+ enum LAMABA_PARAMETER_HASH_STRUCTURE {
60
+ LAMBDA_PARAMETER_STATE = 'LAMBDA_PARAMETER_STATE',
61
+ LAMBDA_PARAMETERS_STATE = 'LAMBDA_PARAMETERS_STATE',
62
+ }
63
+
57
64
  export const buildParametersLetLambdaFunc = (
58
65
  graph: PureModel,
59
66
  lambdaParametersStates: LambdaParameterState[],
@@ -87,7 +94,7 @@ export const buildParametersLetLambdaFunc = (
87
94
  .filter(isNonNullable);
88
95
  return letlambdaFunction;
89
96
  };
90
- export class LambdaParameterState {
97
+ export class LambdaParameterState implements Hashable {
91
98
  readonly uuid = uuid();
92
99
  readonly parameter: VariableExpression;
93
100
  readonly graph: PureModel;
@@ -103,12 +110,21 @@ export class LambdaParameterState {
103
110
  value: observable,
104
111
  setValue: action,
105
112
  mockParameterValue: action,
113
+ hashCode: computed,
106
114
  });
107
115
  this.observableContext = observableContext;
108
116
  this.parameter = observe_VariableExpression(variableExpression);
109
117
  this.graph = graph;
110
118
  }
111
119
 
120
+ get hashCode(): string {
121
+ return hashArray([
122
+ LAMABA_PARAMETER_HASH_STRUCTURE.LAMBDA_PARAMETER_STATE,
123
+ this.value ?? '',
124
+ this.parameter.name,
125
+ ]);
126
+ }
127
+
112
128
  mockParameterValue(): void {
113
129
  this.setValue(
114
130
  generateVariableExpressionMockValue(this.parameter, this.graph),
@@ -204,10 +220,24 @@ export class ParameterInstanceValuesEditorState {
204
220
  this.setShowModal(false);
205
221
  }
206
222
  }
207
- export class LambdaParametersState {
223
+
224
+ export class LambdaParametersState implements Hashable {
208
225
  parameterStates: LambdaParameterState[] = [];
209
226
  parameterValuesEditorState = new ParameterInstanceValuesEditorState();
210
227
 
228
+ constructor() {
229
+ makeObservable(this, {
230
+ hashCode: computed,
231
+ });
232
+ }
233
+
234
+ get hashCode(): string {
235
+ return hashArray([
236
+ LAMABA_PARAMETER_HASH_STRUCTURE.LAMBDA_PARAMETERS_STATE,
237
+ hashArray(this.parameterStates),
238
+ ]);
239
+ }
240
+
211
241
  addParameter(val: LambdaParameterState): void {
212
242
  addUniqueEntry(this.parameterStates, val);
213
243
  }
@@ -0,0 +1,65 @@
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 { action, computed, makeObservable, observable } from 'mobx';
18
+
19
+ export enum ADVANCED_TEXT_SEARCH_MODE {
20
+ STANDARD = 'standard',
21
+ INCLUDE = 'include match',
22
+ EXACT = 'exact match',
23
+ INVERSE = 'excludes exact match',
24
+ }
25
+
26
+ export class TextSearchAdvancedConfigState {
27
+ currentMode = ADVANCED_TEXT_SEARCH_MODE.STANDARD;
28
+ onSearchModeChange: () => void;
29
+
30
+ constructor(onSearchModeChange: () => void) {
31
+ makeObservable(this, {
32
+ currentMode: observable,
33
+ isAdvancedSearchActive: computed,
34
+ setCurrentMode: action,
35
+ });
36
+
37
+ this.onSearchModeChange = onSearchModeChange;
38
+ }
39
+
40
+ get isAdvancedSearchActive(): boolean {
41
+ return this.currentMode !== ADVANCED_TEXT_SEARCH_MODE.STANDARD;
42
+ }
43
+
44
+ generateSearchText(val: string): string {
45
+ switch (this.currentMode) {
46
+ case ADVANCED_TEXT_SEARCH_MODE.INCLUDE: {
47
+ return `'"${val}"`;
48
+ }
49
+ case ADVANCED_TEXT_SEARCH_MODE.EXACT: {
50
+ return `="${val}"`;
51
+ }
52
+ case ADVANCED_TEXT_SEARCH_MODE.INVERSE: {
53
+ return `!"${val}"`;
54
+ }
55
+ default: {
56
+ return val;
57
+ }
58
+ }
59
+ }
60
+
61
+ setCurrentMode(val: ADVANCED_TEXT_SEARCH_MODE): void {
62
+ this.currentMode = val;
63
+ this.onSearchModeChange();
64
+ }
65
+ }
package/tsconfig.json CHANGED
@@ -40,6 +40,7 @@
40
40
  "./src/stores/AssistantService.ts",
41
41
  "./src/stores/DocumentationService.ts",
42
42
  "./src/stores/EventService.ts",
43
+ "./src/stores/LegendApplicationDocumentation.ts",
43
44
  "./src/stores/LegendApplicationPlugin.ts",
44
45
  "./src/stores/PureLanguageSupport.ts",
45
46
  "./src/stores/WebApplicationNavigator.ts",
@@ -47,6 +48,7 @@
47
48
  "./src/stores/shared/LambdaEditorState.ts",
48
49
  "./src/stores/shared/LambdaParameterState.ts",
49
50
  "./src/stores/shared/PackageableElementOption.ts",
51
+ "./src/stores/shared/TextSearchAdvancedConfigState.ts",
50
52
  "./src/stores/shared/ValueSpecificationModifierHelper.ts",
51
53
  "./src/application/LegendApplication.tsx",
52
54
  "./src/application/LegendApplicationPluginManager.tsx",
@@ -67,6 +69,7 @@
67
69
  "./src/components/shared/LambdaParameterValuesEditor.tsx",
68
70
  "./src/components/shared/PackageableElementOptionRenderer.tsx",
69
71
  "./src/components/shared/TextInputEditor.tsx",
72
+ "./src/components/shared/TextSearchAdvancedConfigMenu.tsx",
70
73
  "./src/components/shared/execution-plan-viewer/ExecutionPlanViewer.tsx",
71
74
  "./src/components/shared/execution-plan-viewer/SQLExecutionNodeViewer.tsx",
72
75
  "./src/stores/CJS__Fuse.cts"