@finos/legend-query-builder 4.14.36 → 4.14.38

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 (77) hide show
  1. package/lib/__lib__/QueryBuilderDocumentation.d.ts +2 -1
  2. package/lib/__lib__/QueryBuilderDocumentation.d.ts.map +1 -1
  3. package/lib/__lib__/QueryBuilderDocumentation.js +1 -0
  4. package/lib/__lib__/QueryBuilderDocumentation.js.map +1 -1
  5. package/lib/components/QueryBuilder.d.ts.map +1 -1
  6. package/lib/components/QueryBuilder.js +26 -9
  7. package/lib/components/QueryBuilder.js.map +1 -1
  8. package/lib/components/QueryBuilderSideBar.d.ts.map +1 -1
  9. package/lib/components/QueryBuilderSideBar.js +3 -3
  10. package/lib/components/QueryBuilderSideBar.js.map +1 -1
  11. package/lib/components/QueryBuilderTextEditor.d.ts.map +1 -1
  12. package/lib/components/QueryBuilderTextEditor.js +17 -3
  13. package/lib/components/QueryBuilderTextEditor.js.map +1 -1
  14. package/lib/components/explorer/QueryBuilderMilestoningEditor.d.ts +5 -0
  15. package/lib/components/explorer/QueryBuilderMilestoningEditor.d.ts.map +1 -1
  16. package/lib/components/explorer/QueryBuilderMilestoningEditor.js +10 -5
  17. package/lib/components/explorer/QueryBuilderMilestoningEditor.js.map +1 -1
  18. package/lib/components/fetch-structure/QueryBuilderResultModifierPanel.d.ts.map +1 -1
  19. package/lib/components/fetch-structure/QueryBuilderResultModifierPanel.js +35 -3
  20. package/lib/components/fetch-structure/QueryBuilderResultModifierPanel.js.map +1 -1
  21. package/lib/components/fetch-structure/QueryBuilderTDSPanel.d.ts.map +1 -1
  22. package/lib/components/fetch-structure/QueryBuilderTDSPanel.js +11 -1
  23. package/lib/components/fetch-structure/QueryBuilderTDSPanel.js.map +1 -1
  24. package/lib/components/result/QueryBuilderResultPanel.d.ts.map +1 -1
  25. package/lib/components/result/QueryBuilderResultPanel.js +21 -8
  26. package/lib/components/result/QueryBuilderResultPanel.js.map +1 -1
  27. package/lib/components/workflows/ClassQueryBuilder.d.ts.map +1 -1
  28. package/lib/components/workflows/ClassQueryBuilder.js +3 -3
  29. package/lib/components/workflows/ClassQueryBuilder.js.map +1 -1
  30. package/lib/components/workflows/MappingQueryBuilder.d.ts.map +1 -1
  31. package/lib/components/workflows/MappingQueryBuilder.js +3 -3
  32. package/lib/components/workflows/MappingQueryBuilder.js.map +1 -1
  33. package/lib/components/workflows/ServiceQueryBuilder.d.ts.map +1 -1
  34. package/lib/components/workflows/ServiceQueryBuilder.js +3 -3
  35. package/lib/components/workflows/ServiceQueryBuilder.js.map +1 -1
  36. package/lib/index.css +2 -2
  37. package/lib/index.css.map +1 -1
  38. package/lib/package.json +1 -1
  39. package/lib/stores/QueryBuilderTextEditorState.d.ts +4 -1
  40. package/lib/stores/QueryBuilderTextEditorState.d.ts.map +1 -1
  41. package/lib/stores/QueryBuilderTextEditorState.js +19 -2
  42. package/lib/stores/QueryBuilderTextEditorState.js.map +1 -1
  43. package/lib/stores/QueryBuilder_LegendApplicationPlugin_Extension.d.ts +16 -0
  44. package/lib/stores/QueryBuilder_LegendApplicationPlugin_Extension.d.ts.map +1 -1
  45. package/lib/stores/QueryLoaderState.d.ts +2 -2
  46. package/lib/stores/QueryLoaderState.d.ts.map +1 -1
  47. package/lib/stores/QueryLoaderState.js +3 -3
  48. package/lib/stores/QueryLoaderState.js.map +1 -1
  49. package/lib/stores/explorer/QueryFunctionsExplorerState.d.ts +1 -1
  50. package/lib/stores/explorer/QueryFunctionsExplorerState.d.ts.map +1 -1
  51. package/lib/stores/explorer/QueryFunctionsExplorerState.js +2 -1
  52. package/lib/stores/explorer/QueryFunctionsExplorerState.js.map +1 -1
  53. package/lib/stores/fetch-structure/tds/QueryBuilderTDSState.d.ts +1 -0
  54. package/lib/stores/fetch-structure/tds/QueryBuilderTDSState.d.ts.map +1 -1
  55. package/lib/stores/fetch-structure/tds/QueryBuilderTDSState.js +8 -0
  56. package/lib/stores/fetch-structure/tds/QueryBuilderTDSState.js.map +1 -1
  57. package/lib/stores/milestoning/QueryBuilderMilestoningState.d.ts.map +1 -1
  58. package/lib/stores/milestoning/QueryBuilderMilestoningState.js +9 -3
  59. package/lib/stores/milestoning/QueryBuilderMilestoningState.js.map +1 -1
  60. package/package.json +5 -5
  61. package/src/__lib__/QueryBuilderDocumentation.ts +1 -0
  62. package/src/components/QueryBuilder.tsx +100 -17
  63. package/src/components/QueryBuilderSideBar.tsx +3 -2
  64. package/src/components/QueryBuilderTextEditor.tsx +46 -11
  65. package/src/components/explorer/QueryBuilderMilestoningEditor.tsx +60 -46
  66. package/src/components/fetch-structure/QueryBuilderResultModifierPanel.tsx +53 -3
  67. package/src/components/fetch-structure/QueryBuilderTDSPanel.tsx +116 -19
  68. package/src/components/result/QueryBuilderResultPanel.tsx +84 -29
  69. package/src/components/workflows/ClassQueryBuilder.tsx +3 -2
  70. package/src/components/workflows/MappingQueryBuilder.tsx +3 -2
  71. package/src/components/workflows/ServiceQueryBuilder.tsx +7 -3
  72. package/src/stores/QueryBuilderTextEditorState.ts +20 -2
  73. package/src/stores/QueryBuilder_LegendApplicationPlugin_Extension.ts +21 -0
  74. package/src/stores/QueryLoaderState.ts +5 -7
  75. package/src/stores/explorer/QueryFunctionsExplorerState.ts +6 -2
  76. package/src/stores/fetch-structure/tds/QueryBuilderTDSState.ts +11 -0
  77. package/src/stores/milestoning/QueryBuilderMilestoningState.ts +11 -7
@@ -17,6 +17,7 @@
17
17
  import {
18
18
  CustomSelectorInput,
19
19
  PanelHeader,
20
+ compareLabelFn,
20
21
  createFilter,
21
22
  } from '@finos/legend-art';
22
23
  import { observer } from 'mobx-react-lite';
@@ -59,7 +60,7 @@ const MappingQueryBuilderSetupPanelContent = observer(
59
60
  // mapping
60
61
  const mappingOptions = queryBuilderState.graphManagerState.usableMappings
61
62
  .map(buildElementOption)
62
- .sort((a, b) => a.label.localeCompare(b.label));
63
+ .sort(compareLabelFn);
63
64
  const selectedMappingOption = queryBuilderState.executionContextState
64
65
  .mapping
65
66
  ? buildElementOption(queryBuilderState.executionContextState.mapping)
@@ -93,7 +94,7 @@ const MappingQueryBuilderSetupPanelContent = observer(
93
94
  new RuntimePointer(PackageableElementExplicitReference.create(rt)),
94
95
  )
95
96
  .map(buildRuntimeValueOption)
96
- .sort((a, b) => a.label.localeCompare(b.label));
97
+ .sort(compareLabelFn);
97
98
  const selectedRuntimeOption = queryBuilderState.executionContextState
98
99
  .runtimeValue
99
100
  ? buildRuntimeValueOption(
@@ -14,7 +14,11 @@
14
14
  * limitations under the License.
15
15
  */
16
16
 
17
- import { CustomSelectorInput, PanelHeader } from '@finos/legend-art';
17
+ import {
18
+ CustomSelectorInput,
19
+ PanelHeader,
20
+ compareLabelFn,
21
+ } from '@finos/legend-art';
18
22
  import { observer } from 'mobx-react-lite';
19
23
  import { getMappingCompatibleClasses, type Service } from '@finos/legend-graph';
20
24
  import { useApplicationStore } from '@finos/legend-application';
@@ -57,7 +61,7 @@ const ServiceQueryBuilderSetupPanelContent = observer(
57
61
  const serviceOptions =
58
62
  queryBuilderState.usableServices
59
63
  ?.map(buildElementOption)
60
- .sort((a, b) => a.label.localeCompare(b.label)) ?? [];
64
+ .sort(compareLabelFn) ?? [];
61
65
  const selectedServiceOption = buildElementOption(queryBuilderState.service);
62
66
  const onServiceOptionChange = (
63
67
  option: PackageableElementOption<Service>,
@@ -71,7 +75,7 @@ const ServiceQueryBuilderSetupPanelContent = observer(
71
75
  // execution context
72
76
  const executionContextOptions = queryBuilderState.executionContexts
73
77
  .map(buildExecutionContextOption)
74
- .sort((a, b) => a.label.localeCompare(b.label));
78
+ .sort(compareLabelFn);
75
79
  const selectedExecutionContextOption =
76
80
  queryBuilderState.selectedExecutionContext
77
81
  ? buildExecutionContextOption(
@@ -67,6 +67,7 @@ export class QueryBuilderTextEditorState extends LambdaEditorState {
67
67
  * TODO: consider moving this to another state if we need to simplify the logic of text-mode
68
68
  */
69
69
  readOnlylambdaJson = '';
70
+ isReadOnly: boolean | undefined;
70
71
 
71
72
  constructor(queryBuilderState: QueryBuilderState) {
72
73
  super('', '');
@@ -75,7 +76,9 @@ export class QueryBuilderTextEditorState extends LambdaEditorState {
75
76
  rawLambdaState: observable,
76
77
  isConvertingLambdaToString: observable,
77
78
  mode: observable,
79
+ isReadOnly: observable,
78
80
  setQueryRawLambdaState: action,
81
+ setIsReadOnly: action,
79
82
  setMode: action,
80
83
  openModal: action,
81
84
  closeModal: flow,
@@ -89,10 +92,23 @@ export class QueryBuilderTextEditorState extends LambdaEditorState {
89
92
  return buildSourceInformationSourceId(['query-builder']);
90
93
  }
91
94
 
95
+ get text(): string | undefined {
96
+ if (this.mode === QueryBuilderTextEditorMode.TEXT) {
97
+ return this.fullLambdaString;
98
+ } else if (this.mode === QueryBuilderTextEditorMode.JSON) {
99
+ return this.readOnlylambdaJson;
100
+ }
101
+ return undefined;
102
+ }
103
+
92
104
  setQueryRawLambdaState(rawLambdaState: QueryBuilderRawLambdaState): void {
93
105
  this.rawLambdaState = rawLambdaState;
94
106
  }
95
107
 
108
+ setIsReadOnly(val: boolean | undefined): void {
109
+ this.isReadOnly = val;
110
+ }
111
+
96
112
  setMode(openModal: QueryBuilderTextEditorMode | undefined): void {
97
113
  this.mode = openModal;
98
114
  }
@@ -170,7 +186,7 @@ export class QueryBuilderTextEditorState extends LambdaEditorState {
170
186
  }
171
187
  }
172
188
 
173
- openModal(mode: QueryBuilderTextEditorMode): void {
189
+ openModal(mode: QueryBuilderTextEditorMode, isReadOnly?: boolean): void {
174
190
  try {
175
191
  const rawLambda = this.queryBuilderState.buildQuery();
176
192
  if (mode === QueryBuilderTextEditorMode.TEXT) {
@@ -190,6 +206,7 @@ export class QueryBuilderTextEditorState extends LambdaEditorState {
190
206
  );
191
207
  }
192
208
  this.setMode(mode);
209
+ this.setIsReadOnly(isReadOnly);
193
210
  } catch (error) {
194
211
  assertErrorThrown(error);
195
212
  this.queryBuilderState.applicationStore.notificationService.notifyError(
@@ -200,7 +217,7 @@ export class QueryBuilderTextEditorState extends LambdaEditorState {
200
217
 
201
218
  *closeModal(): GeneratorFn<void> {
202
219
  this.closingQueryState.inProgress();
203
- if (this.mode === QueryBuilderTextEditorMode.TEXT) {
220
+ if (this.mode === QueryBuilderTextEditorMode.TEXT && !this.isReadOnly) {
204
221
  yield flowResult(this.convertLambdaGrammarStringToObject());
205
222
  if (this.parserError) {
206
223
  this.queryBuilderState.applicationStore.notificationService.notifyError(
@@ -215,6 +232,7 @@ export class QueryBuilderTextEditorState extends LambdaEditorState {
215
232
  }
216
233
  return;
217
234
  }
235
+ this.setIsReadOnly(undefined);
218
236
  this.closingQueryState.complete();
219
237
 
220
238
  this.setMode(undefined);
@@ -83,6 +83,17 @@ export type QueryBuilderHeaderActionConfiguration = {
83
83
  ) => React.ReactNode | undefined;
84
84
  };
85
85
 
86
+ export type QueryBuilderMenuActionConfiguration = {
87
+ key: string;
88
+ title?: string;
89
+ label: string;
90
+ onClick: (queryBuilderState: QueryBuilderState) => void;
91
+ icon?: React.ReactNode;
92
+ renderExtraComponent?: (
93
+ queryBuilderState: QueryBuilderState,
94
+ ) => React.ReactNode;
95
+ };
96
+
86
97
  export interface QueryBuilder_LegendApplicationPlugin_Extension
87
98
  extends LegendApplicationPlugin {
88
99
  /**
@@ -136,4 +147,14 @@ export interface QueryBuilder_LegendApplicationPlugin_Extension
136
147
  * Get the list of action configurations
137
148
  */
138
149
  getExtraQueryBuilderHeaderTitleConfigurations?(): QueryBuilderHeaderActionConfiguration[];
150
+
151
+ /**
152
+ * Get the list of help menu action configurations
153
+ */
154
+ getExtraQueryBuilderHelpMenuActionConfigurations?(): QueryBuilderMenuActionConfiguration[];
155
+
156
+ /**
157
+ * Get the list of export menu action configurations
158
+ */
159
+ getExtraQueryBuilderExportMenuActionConfigurations?(): QueryBuilderMenuActionConfiguration[];
139
160
  }
@@ -65,7 +65,7 @@ export class QueryLoaderState {
65
65
 
66
66
  readonly isReadOnly?: boolean | undefined;
67
67
  readonly onQueryRenamed?: ((query: LightQuery) => void) | undefined;
68
- readonly onQueryDeleted?: ((query: LightQuery) => void) | undefined;
68
+ readonly onQueryDeleted?: ((query: string) => void) | undefined;
69
69
  readonly handleFetchDefaultQueriesFailure?: (() => void) | undefined;
70
70
 
71
71
  queryBuilderState?: QueryBuilderState | undefined;
@@ -100,7 +100,7 @@ export class QueryLoaderState {
100
100
 
101
101
  isReadOnly?: boolean | undefined;
102
102
  onQueryRenamed?: ((query: LightQuery) => void) | undefined;
103
- onQueryDeleted?: ((query: LightQuery) => void) | undefined;
103
+ onQueryDeleted?: ((query: string) => void) | undefined;
104
104
  handleFetchDefaultQueriesFailure?: (() => void) | undefined;
105
105
  },
106
106
  ) {
@@ -304,11 +304,9 @@ export class QueryLoaderState {
304
304
  *deleteQuery(queryId: string): GeneratorFn<void> {
305
305
  this.deleteQueryState.inProgress();
306
306
  try {
307
- const query = (yield this.graphManagerState.graphManager.deleteQuery(
308
- queryId,
309
- )) as Query;
310
- this.onQueryDeleted?.(query);
311
- this.applicationStore.notificationService.notify(
307
+ yield this.graphManagerState.graphManager.deleteQuery(queryId);
308
+ this.onQueryDeleted?.(queryId);
309
+ this.applicationStore.notificationService.notifySuccess(
312
310
  'Deleted query successfully',
313
311
  );
314
312
  this.deleteQueryState.pass();
@@ -30,7 +30,11 @@ import {
30
30
  } from '@finos/legend-shared';
31
31
  import { action, makeObservable, observable } from 'mobx';
32
32
  import type { QueryBuilderState } from '../QueryBuilderState.js';
33
- import type { TreeNodeData, TreeData } from '@finos/legend-art';
33
+ import {
34
+ type TreeNodeData,
35
+ type TreeData,
36
+ compareLabelFn,
37
+ } from '@finos/legend-art';
34
38
 
35
39
  export const QUERY_BUILDER_FUNCTION_DND_TYPE = 'QUERY_BUILDER_FUNCTION';
36
40
 
@@ -206,7 +210,7 @@ export const getFunctionsExplorerTreeNodeChildren = (
206
210
  return node.childrenIds
207
211
  .map((id) => data.nodes.get(id))
208
212
  .filter(isNonNullable)
209
- .sort((a, b) => a.label.localeCompare(b.label))
213
+ .sort(compareLabelFn)
210
214
  .sort(
211
215
  (a, b) =>
212
216
  (b.packageableElement instanceof Package ? 1 : 0) -
@@ -146,6 +146,7 @@ export class QueryBuilderTDSState
146
146
  TEMPORARY__showPostFetchStructurePanel: computed,
147
147
  derivations: computed,
148
148
  hasParserError: computed,
149
+ isQueryOptionsSet: computed,
149
150
  addColumn: action,
150
151
  moveColumn: action,
151
152
  removeAllColumns: action,
@@ -356,6 +357,16 @@ export class QueryBuilderTDSState
356
357
  return fetchStructureValidationIssues;
357
358
  }
358
359
 
360
+ get isQueryOptionsSet(): boolean {
361
+ return (
362
+ this.resultSetModifierState.limit !== undefined ||
363
+ this.queryBuilderState.milestoningState.isMilestonedQuery ||
364
+ this.resultSetModifierState.slice !== undefined ||
365
+ this.resultSetModifierState.sortColumns.length > 0 ||
366
+ this.resultSetModifierState.distinct
367
+ );
368
+ }
369
+
359
370
  get tdsColumns(): QueryBuilderTDSColumnState[] {
360
371
  const aggregationStateCols = this.aggregationState.columns.map(
361
372
  (c) => c.projectionColumnState,
@@ -75,7 +75,7 @@ export class QueryBuilderMilestoningState implements Hashable {
75
75
  startDate: observable,
76
76
  endDate: observable,
77
77
  showMilestoningEditor: observable,
78
- isMilestonedQuery: computed,
78
+
79
79
  setProcessingDate: action,
80
80
  setBusinessDate: action,
81
81
  setStartDate: action,
@@ -87,6 +87,10 @@ export class QueryBuilderMilestoningState implements Hashable {
87
87
  initializeAllVersionsInRangeParameters: action,
88
88
  clearAllVersionsInRangeParameters: action,
89
89
  clearGetAllParameters: action,
90
+
91
+ isAllVersionsEnabled: computed,
92
+ isAllVersionsInRangeEnabled: computed,
93
+ isMilestonedQuery: computed,
90
94
  hashCode: computed,
91
95
  });
92
96
 
@@ -380,9 +384,9 @@ export class QueryBuilderMilestoningState implements Hashable {
380
384
  this.queryBuilderState.parametersState.parameterStates.find(
381
385
  (p) => p.parameter === this.startDate,
382
386
  );
383
- this.queryBuilderState.parametersState.removeParameter(
384
- guaranteeNonNullable(paramState),
385
- );
387
+ if (paramState) {
388
+ this.queryBuilderState.parametersState.removeParameter(paramState);
389
+ }
386
390
  }
387
391
  if (
388
392
  this.endDate instanceof VariableExpression &&
@@ -394,9 +398,9 @@ export class QueryBuilderMilestoningState implements Hashable {
394
398
  this.queryBuilderState.parametersState.parameterStates.find(
395
399
  (p) => p.parameter === this.endDate,
396
400
  );
397
- this.queryBuilderState.parametersState.removeParameter(
398
- guaranteeNonNullable(paramState),
399
- );
401
+ if (paramState) {
402
+ this.queryBuilderState.parametersState.removeParameter(paramState);
403
+ }
400
404
  }
401
405
  this.setStartDate(undefined);
402
406
  this.setEndDate(undefined);