@finos/legend-query-builder 4.14.18 → 4.14.20

Sign up to get free protection for your applications and to get access to all the features.
Files changed (133) hide show
  1. package/lib/components/QueryBuilder.d.ts.map +1 -1
  2. package/lib/components/QueryBuilder.js +5 -3
  3. package/lib/components/QueryBuilder.js.map +1 -1
  4. package/lib/components/QueryBuilderConstantExpressionPanel.d.ts.map +1 -1
  5. package/lib/components/QueryBuilderConstantExpressionPanel.js +71 -45
  6. package/lib/components/QueryBuilderConstantExpressionPanel.js.map +1 -1
  7. package/lib/components/QueryBuilderDiffPanel.d.ts.map +1 -1
  8. package/lib/components/QueryBuilderDiffPanel.js +2 -1
  9. package/lib/components/QueryBuilderDiffPanel.js.map +1 -1
  10. package/lib/components/QueryBuilderParametersPanel.d.ts.map +1 -1
  11. package/lib/components/QueryBuilderParametersPanel.js +25 -26
  12. package/lib/components/QueryBuilderParametersPanel.js.map +1 -1
  13. package/lib/components/QueryBuilderPropertyExpressionEditor.d.ts +11 -2
  14. package/lib/components/QueryBuilderPropertyExpressionEditor.d.ts.map +1 -1
  15. package/lib/components/QueryBuilderPropertyExpressionEditor.js +35 -10
  16. package/lib/components/QueryBuilderPropertyExpressionEditor.js.map +1 -1
  17. package/lib/components/QueryBuilderSideBar.d.ts.map +1 -1
  18. package/lib/components/QueryBuilderSideBar.js +6 -1
  19. package/lib/components/QueryBuilderSideBar.js.map +1 -1
  20. package/lib/components/QueryBuilderTextEditor.d.ts.map +1 -1
  21. package/lib/components/QueryBuilderTextEditor.js +3 -3
  22. package/lib/components/QueryBuilderTextEditor.js.map +1 -1
  23. package/lib/components/QueryLoader.d.ts.map +1 -1
  24. package/lib/components/QueryLoader.js +90 -39
  25. package/lib/components/QueryLoader.js.map +1 -1
  26. package/lib/components/QueryUsageViewer.d.ts.map +1 -1
  27. package/lib/components/QueryUsageViewer.js +2 -2
  28. package/lib/components/QueryUsageViewer.js.map +1 -1
  29. package/lib/components/__test-utils__/QueryBuilderComponentTestUtils.d.ts +2 -0
  30. package/lib/components/__test-utils__/QueryBuilderComponentTestUtils.d.ts.map +1 -1
  31. package/lib/components/__test-utils__/QueryBuilderComponentTestUtils.js +19 -2
  32. package/lib/components/__test-utils__/QueryBuilderComponentTestUtils.js.map +1 -1
  33. package/lib/components/data-access/DataAccessOverview.d.ts.map +1 -1
  34. package/lib/components/data-access/DataAccessOverview.js +6 -1
  35. package/lib/components/data-access/DataAccessOverview.js.map +1 -1
  36. package/lib/components/execution-plan/ExecutionPlanViewer.d.ts.map +1 -1
  37. package/lib/components/execution-plan/ExecutionPlanViewer.js +6 -6
  38. package/lib/components/execution-plan/ExecutionPlanViewer.js.map +1 -1
  39. package/lib/components/explorer/QueryBuilderExplorerPanel.d.ts.map +1 -1
  40. package/lib/components/explorer/QueryBuilderExplorerPanel.js +3 -2
  41. package/lib/components/explorer/QueryBuilderExplorerPanel.js.map +1 -1
  42. package/lib/components/explorer/QueryBuilderMilestoningEditor.d.ts.map +1 -1
  43. package/lib/components/explorer/QueryBuilderMilestoningEditor.js +3 -2
  44. package/lib/components/explorer/QueryBuilderMilestoningEditor.js.map +1 -1
  45. package/lib/components/fetch-structure/QueryBuilderGraphFetchTreePanel.d.ts.map +1 -1
  46. package/lib/components/fetch-structure/QueryBuilderGraphFetchTreePanel.js +6 -3
  47. package/lib/components/fetch-structure/QueryBuilderGraphFetchTreePanel.js.map +1 -1
  48. package/lib/components/fetch-structure/QueryBuilderResultModifierPanel.d.ts.map +1 -1
  49. package/lib/components/fetch-structure/QueryBuilderResultModifierPanel.js +4 -3
  50. package/lib/components/fetch-structure/QueryBuilderResultModifierPanel.js.map +1 -1
  51. package/lib/components/fetch-structure/QueryBuilderTDSPanel.d.ts.map +1 -1
  52. package/lib/components/fetch-structure/QueryBuilderTDSPanel.js +11 -22
  53. package/lib/components/fetch-structure/QueryBuilderTDSPanel.js.map +1 -1
  54. package/lib/components/fetch-structure/QueryBuilderTDSWindowPanel.d.ts.map +1 -1
  55. package/lib/components/fetch-structure/QueryBuilderTDSWindowPanel.js +2 -2
  56. package/lib/components/fetch-structure/QueryBuilderTDSWindowPanel.js.map +1 -1
  57. package/lib/components/result/QueryBuilderResultPanel.d.ts.map +1 -1
  58. package/lib/components/result/QueryBuilderResultPanel.js +2 -1
  59. package/lib/components/result/QueryBuilderResultPanel.js.map +1 -1
  60. package/lib/components/result/tds/QueryBuilderTDSGridResult.d.ts.map +1 -1
  61. package/lib/components/result/tds/QueryBuilderTDSGridResult.js +5 -1
  62. package/lib/components/result/tds/QueryBuilderTDSGridResult.js.map +1 -1
  63. package/lib/components/result/tds/QueryBuilderTDSSimpleGridResult.d.ts.map +1 -1
  64. package/lib/components/result/tds/QueryBuilderTDSSimpleGridResult.js +11 -2
  65. package/lib/components/result/tds/QueryBuilderTDSSimpleGridResult.js.map +1 -1
  66. package/lib/components/shared/BasicValueSpecificationEditor.d.ts.map +1 -1
  67. package/lib/components/shared/BasicValueSpecificationEditor.js +25 -22
  68. package/lib/components/shared/BasicValueSpecificationEditor.js.map +1 -1
  69. package/lib/components/shared/CustomDatePicker.d.ts.map +1 -1
  70. package/lib/components/shared/CustomDatePicker.js +8 -5
  71. package/lib/components/shared/CustomDatePicker.js.map +1 -1
  72. package/lib/components/shared/LambdaEditor.d.ts.map +1 -1
  73. package/lib/components/shared/LambdaEditor.js +17 -3
  74. package/lib/components/shared/LambdaEditor.js.map +1 -1
  75. package/lib/components/shared/LambdaParameterValuesEditor.d.ts.map +1 -1
  76. package/lib/components/shared/LambdaParameterValuesEditor.js +2 -2
  77. package/lib/components/shared/LambdaParameterValuesEditor.js.map +1 -1
  78. package/lib/components/shared/QueryBuilderPropertyInfoTooltip.d.ts +6 -0
  79. package/lib/components/shared/QueryBuilderPropertyInfoTooltip.d.ts.map +1 -1
  80. package/lib/components/shared/QueryBuilderPropertyInfoTooltip.js +40 -3
  81. package/lib/components/shared/QueryBuilderPropertyInfoTooltip.js.map +1 -1
  82. package/lib/components/watermark/QueryBuilderWatermark.d.ts.map +1 -1
  83. package/lib/components/watermark/QueryBuilderWatermark.js +28 -12
  84. package/lib/components/watermark/QueryBuilderWatermark.js.map +1 -1
  85. package/lib/index.css +17 -1
  86. package/lib/index.css.map +1 -1
  87. package/lib/package.json +1 -1
  88. package/lib/stores/QueryBuilderConstantsState.d.ts +1 -0
  89. package/lib/stores/QueryBuilderConstantsState.d.ts.map +1 -1
  90. package/lib/stores/QueryBuilderConstantsState.js +7 -1
  91. package/lib/stores/QueryBuilderConstantsState.js.map +1 -1
  92. package/lib/stores/QueryBuilder_LegendApplicationPlugin_Extension.d.ts +24 -1
  93. package/lib/stores/QueryBuilder_LegendApplicationPlugin_Extension.d.ts.map +1 -1
  94. package/lib/stores/QueryLoaderState.d.ts +14 -4
  95. package/lib/stores/QueryLoaderState.d.ts.map +1 -1
  96. package/lib/stores/QueryLoaderState.js +35 -5
  97. package/lib/stores/QueryLoaderState.js.map +1 -1
  98. package/lib/stores/watermark/QueryBuilderWatermarkState.d.ts +1 -2
  99. package/lib/stores/watermark/QueryBuilderWatermarkState.d.ts.map +1 -1
  100. package/lib/stores/watermark/QueryBuilderWatermarkState.js +2 -12
  101. package/lib/stores/watermark/QueryBuilderWatermarkState.js.map +1 -1
  102. package/package.json +8 -8
  103. package/src/components/QueryBuilder.tsx +14 -2
  104. package/src/components/QueryBuilderConstantExpressionPanel.tsx +145 -69
  105. package/src/components/QueryBuilderDiffPanel.tsx +10 -2
  106. package/src/components/QueryBuilderParametersPanel.tsx +42 -37
  107. package/src/components/QueryBuilderPropertyExpressionEditor.tsx +87 -24
  108. package/src/components/QueryBuilderSideBar.tsx +20 -0
  109. package/src/components/QueryBuilderTextEditor.tsx +6 -4
  110. package/src/components/QueryLoader.tsx +291 -130
  111. package/src/components/QueryUsageViewer.tsx +7 -1
  112. package/src/components/__test-utils__/QueryBuilderComponentTestUtils.tsx +40 -4
  113. package/src/components/data-access/DataAccessOverview.tsx +9 -1
  114. package/src/components/execution-plan/ExecutionPlanViewer.tsx +11 -8
  115. package/src/components/explorer/QueryBuilderExplorerPanel.tsx +5 -2
  116. package/src/components/explorer/QueryBuilderMilestoningEditor.tsx +5 -2
  117. package/src/components/fetch-structure/QueryBuilderGraphFetchTreePanel.tsx +12 -5
  118. package/src/components/fetch-structure/QueryBuilderResultModifierPanel.tsx +8 -4
  119. package/src/components/fetch-structure/QueryBuilderTDSPanel.tsx +56 -72
  120. package/src/components/fetch-structure/QueryBuilderTDSWindowPanel.tsx +8 -2
  121. package/src/components/result/QueryBuilderResultPanel.tsx +8 -1
  122. package/src/components/result/tds/QueryBuilderTDSGridResult.tsx +6 -3
  123. package/src/components/result/tds/QueryBuilderTDSSimpleGridResult.tsx +14 -4
  124. package/src/components/shared/BasicValueSpecificationEditor.tsx +39 -25
  125. package/src/components/shared/CustomDatePicker.tsx +18 -5
  126. package/src/components/shared/LambdaEditor.tsx +27 -11
  127. package/src/components/shared/LambdaParameterValuesEditor.tsx +4 -1
  128. package/src/components/shared/QueryBuilderPropertyInfoTooltip.tsx +115 -64
  129. package/src/components/watermark/QueryBuilderWatermark.tsx +60 -19
  130. package/src/stores/QueryBuilderConstantsState.ts +12 -0
  131. package/src/stores/QueryBuilder_LegendApplicationPlugin_Extension.ts +39 -1
  132. package/src/stores/QueryLoaderState.ts +64 -12
  133. package/src/stores/watermark/QueryBuilderWatermarkState.ts +2 -12
@@ -45,6 +45,7 @@ import {
45
45
  changeEntry,
46
46
  assertTrue,
47
47
  ActionState,
48
+ deepClone,
48
49
  } from '@finos/legend-shared';
49
50
  import { action, makeObservable, observable } from 'mobx';
50
51
  import { QUERY_BUILDER_STATE_HASH_STRUCTURE } from './QueryBuilderStateHashUtils.js';
@@ -386,3 +387,14 @@ export class QueryBuilderConstantsState implements Hashable {
386
387
  ]);
387
388
  }
388
389
  }
390
+
391
+ export const cloneQueryBuilderConstantLambdaEditorState = (
392
+ state: QueryBuilderConstantLambdaEditorState,
393
+ ): QueryBuilderConstantLambdaEditorState => {
394
+ const clonedState = new QueryBuilderConstantLambdaEditorState(
395
+ deepClone(state.calculatedState),
396
+ );
397
+ clonedState.lambdaString = state.lambdaString;
398
+ clonedState.parserError = deepClone(state.parserError);
399
+ return clonedState;
400
+ };
@@ -16,12 +16,29 @@
16
16
 
17
17
  import type { LegendApplicationPlugin } from '@finos/legend-application';
18
18
  import type { QueryBuilderState } from './QueryBuilderState.js';
19
- import type { QuerySearchSpecification } from '@finos/legend-graph';
19
+ import type { QuerySearchSpecification, RawLambda } from '@finos/legend-graph';
20
20
  import type {
21
21
  DataAccessState,
22
22
  DatasetAccessInfo,
23
23
  } from './data-access/DataAccessState.js';
24
24
 
25
+ export type CuratedTemplateQuery = {
26
+ title: string;
27
+ description: string | undefined;
28
+ query: RawLambda;
29
+ executionContextKey: string;
30
+ };
31
+
32
+ export type CuratedTemplateQuerySpecification = {
33
+ getCuratedTemplateQueries(
34
+ queryBuilderState: QueryBuilderState,
35
+ ): CuratedTemplateQuery[];
36
+ loadCuratedTemplateQuery(
37
+ templateQuery: CuratedTemplateQuery,
38
+ queryBuilderState: QueryBuilderState,
39
+ ): void;
40
+ };
41
+
25
42
  export type LoadQueryFilterOption = {
26
43
  key: string;
27
44
  label: (queryBuilderState: QueryBuilderState) => string | undefined;
@@ -53,13 +70,29 @@ export type QueryChatRenderer = (
53
70
  queryBuilderState: QueryBuilderState,
54
71
  ) => React.ReactNode;
55
72
 
73
+ export type TemplateQueryPanelContentRenderer = (
74
+ queryBuilderState: QueryBuilderState,
75
+ ) => React.ReactNode;
76
+
56
77
  export interface QueryBuilder_LegendApplicationPlugin_Extension
57
78
  extends LegendApplicationPlugin {
79
+ /**
80
+ * Get the list of template query specifications
81
+ */
82
+ getCuratedTemplateQuerySpecifications?(): CuratedTemplateQuerySpecification[];
83
+
58
84
  /**
59
85
  * Get the list of filter options for query loader.
60
86
  */
61
87
  getExtraLoadQueryFilterOptions?(): LoadQueryFilterOption[];
62
88
 
89
+ /**
90
+ * Get the list of filter options related to template query
91
+ */
92
+ getQueryFilterOptionsRelatedToTemplateQuery?(): (
93
+ queryBuilderState: QueryBuilderState,
94
+ ) => string[];
95
+
63
96
  /**
64
97
  * Get the list of warehouse entitlement configurations
65
98
  */
@@ -79,4 +112,9 @@ export interface QueryBuilder_LegendApplicationPlugin_Extension
79
112
  * Get the list of query chat configurations
80
113
  */
81
114
  getExtraQueryChatRenderers?(): QueryChatRenderer[];
115
+
116
+ /**
117
+ * Get the list of template query panel content render
118
+ */
119
+ getExtraTemplateQueryPanelContentRenderer?(): TemplateQueryPanelContentRenderer[];
82
120
  }
@@ -19,12 +19,13 @@ import {
19
19
  type GenericLegendApplicationStore,
20
20
  } from '@finos/legend-application';
21
21
  import {
22
- type LightQuery,
23
22
  QuerySearchSpecification,
23
+ GRAPH_MANAGER_EVENT,
24
24
  type QueryInfo,
25
+ type LightQuery,
25
26
  type BasicGraphManagerState,
26
27
  type Query,
27
- GRAPH_MANAGER_EVENT,
28
+ type RawLambda,
28
29
  } from '@finos/legend-graph';
29
30
  import {
30
31
  ActionState,
@@ -36,6 +37,7 @@ import {
36
37
  import { makeObservable, observable, action, flow } from 'mobx';
37
38
  import type { QueryBuilderState } from './QueryBuilderState.js';
38
39
  import type {
40
+ CuratedTemplateQuerySpecification,
39
41
  LoadQueryFilterOption,
40
42
  QueryBuilder_LegendApplicationPlugin_Extension,
41
43
  } from './QueryBuilder_LegendApplicationPlugin_Extension.js';
@@ -72,12 +74,15 @@ export class QueryLoaderState {
72
74
  showCurrentUserQueriesOnly = false; // TODO: if we start having more native filters, we should make them part of `extraFilters`
73
75
  extraFilters = new Map<string, boolean>();
74
76
  extraFilterOptions: LoadQueryFilterOption[] = [];
77
+ extraQueryFilterOptionsRelatedToTemplateQuery: string[] = [];
75
78
  queries: LightQuery[] = [];
79
+ curatedTemplateQuerySepcifications: CuratedTemplateQuerySpecification[] = [];
76
80
 
77
81
  isQueryLoaderDialogOpen = false;
82
+ isCuratedTemplateToggled = false;
78
83
  showingDefaultQueries = true;
79
84
  showPreviewViewer = false;
80
- queryPreviewContent?: QueryInfo;
85
+ queryPreviewContent?: QueryInfo | { name: string; content: string };
81
86
 
82
87
  constructor(
83
88
  applicationStore: GenericLegendApplicationStore,
@@ -107,11 +112,14 @@ export class QueryLoaderState {
107
112
  showCurrentUserQueriesOnly: observable,
108
113
  showPreviewViewer: observable,
109
114
  searchText: observable,
115
+ isCuratedTemplateToggled: observable,
116
+ curatedTemplateQuerySepcifications: observable,
110
117
  setSearchText: action,
111
118
  setQueryLoaderDialogOpen: action,
112
119
  setQueries: action,
113
120
  setShowCurrentUserQueriesOnly: action,
114
121
  setShowPreviewViewer: action,
122
+ setIsCuratedTemplateToggled: action,
115
123
  searchQueries: flow,
116
124
  getPreviewQueryContent: flow,
117
125
  deleteQuery: flow,
@@ -134,6 +142,10 @@ export class QueryLoaderState {
134
142
  options.handleFetchDefaultQueriesFailure;
135
143
  }
136
144
 
145
+ setIsCuratedTemplateToggled(val: boolean): void {
146
+ this.isCuratedTemplateToggled = val;
147
+ }
148
+
137
149
  setSearchText(val: string): void {
138
150
  this.searchText = val;
139
151
  }
@@ -156,6 +168,7 @@ export class QueryLoaderState {
156
168
 
157
169
  reset(): void {
158
170
  this.setShowCurrentUserQueriesOnly(false);
171
+ this.setIsCuratedTemplateToggled(false);
159
172
  }
160
173
 
161
174
  *initialize(queryBuilderState: QueryBuilderState): GeneratorFn<void> {
@@ -168,12 +181,32 @@ export class QueryLoaderState {
168
181
  plugin as QueryBuilder_LegendApplicationPlugin_Extension
169
182
  ).getExtraLoadQueryFilterOptions?.() ?? [],
170
183
  );
184
+ this.extraQueryFilterOptionsRelatedToTemplateQuery =
185
+ this.applicationStore.pluginManager
186
+ .getApplicationPlugins()
187
+ .flatMap(
188
+ (plugin) =>
189
+ (plugin as QueryBuilder_LegendApplicationPlugin_Extension)
190
+ .getQueryFilterOptionsRelatedToTemplateQuery?.()(
191
+ guaranteeNonNullable(this.queryBuilderState),
192
+ )
193
+ .flat() ?? [],
194
+ );
171
195
  const extraFilters = this.extraFilterOptions.map((filterOption) =>
172
196
  filterOption.label(guaranteeNonNullable(this.queryBuilderState)),
173
197
  );
174
198
  extraFilters.forEach(
175
199
  (filter) => filter && this.extraFilters.set(filter, false),
176
200
  );
201
+ this.curatedTemplateQuerySepcifications =
202
+ this.applicationStore.pluginManager
203
+ .getApplicationPlugins()
204
+ .flatMap(
205
+ (plugin) =>
206
+ (
207
+ plugin as QueryBuilder_LegendApplicationPlugin_Extension
208
+ ).getCuratedTemplateQuerySpecifications?.() ?? [],
209
+ );
177
210
  }
178
211
 
179
212
  *searchQueries(searchText: string): GeneratorFn<void> {
@@ -287,17 +320,36 @@ export class QueryLoaderState {
287
320
  }
288
321
  }
289
322
 
290
- *getPreviewQueryContent(queryId: string): GeneratorFn<void> {
323
+ *getPreviewQueryContent(
324
+ queryId: string | undefined,
325
+ template?: {
326
+ queryName: string;
327
+ queryContent: RawLambda;
328
+ },
329
+ ): GeneratorFn<void> {
291
330
  this.previewQueryState.inProgress();
292
331
  try {
293
- const queryInfo = (yield this.graphManagerState.graphManager.getQueryInfo(
294
- queryId,
295
- )) as QueryInfo;
296
- this.queryPreviewContent = queryInfo;
297
- this.queryPreviewContent.content =
298
- (yield this.graphManagerState.graphManager.prettyLambdaContent(
299
- queryInfo.content,
300
- )) as string;
332
+ if (queryId) {
333
+ const queryInfo =
334
+ (yield this.graphManagerState.graphManager.getQueryInfo(
335
+ queryId,
336
+ )) as QueryInfo;
337
+ this.queryPreviewContent = queryInfo;
338
+ this.queryPreviewContent.content =
339
+ (yield this.graphManagerState.graphManager.prettyLambdaContent(
340
+ queryInfo.content,
341
+ )) as string;
342
+ } else if (template) {
343
+ this.queryPreviewContent = {
344
+ name: template.queryName,
345
+ content: '',
346
+ } as QueryInfo;
347
+ this.queryPreviewContent.content =
348
+ (yield this.graphManagerState.graphManager.lambdaToPureCode(
349
+ template.queryContent,
350
+ true,
351
+ )) as string;
352
+ }
301
353
  this.previewQueryState.pass();
302
354
  } catch (error) {
303
355
  assertErrorThrown(error);
@@ -39,8 +39,6 @@ export class QueryBuilderWatermarkState implements Hashable {
39
39
  value: observable,
40
40
  isEditingWatermark: observable,
41
41
  setValue: action,
42
- resetValue: action,
43
- enableWatermark: action,
44
42
  setIsEditingWatermark: action,
45
43
  hashCode: computed,
46
44
  });
@@ -48,7 +46,7 @@ export class QueryBuilderWatermarkState implements Hashable {
48
46
  this.queryBuilderState = queryBuilderState;
49
47
  }
50
48
 
51
- resetValue(): void {
49
+ getDefaultValue(): ValueSpecification {
52
50
  const watermarkConstant = new PrimitiveInstanceValue(
53
51
  GenericTypeExplicitReference.create(
54
52
  new GenericType(PrimitiveType.STRING),
@@ -56,21 +54,13 @@ export class QueryBuilderWatermarkState implements Hashable {
56
54
  );
57
55
 
58
56
  watermarkConstant.values = ['watermarkValue'];
59
- this.setValue(watermarkConstant);
57
+ return watermarkConstant;
60
58
  }
61
59
 
62
60
  setIsEditingWatermark(val: boolean): void {
63
61
  this.isEditingWatermark = val;
64
62
  }
65
63
 
66
- enableWatermark(): void {
67
- if (this.value) {
68
- this.setValue(undefined);
69
- } else {
70
- this.resetValue();
71
- }
72
- }
73
-
74
64
  setValue(val: ValueSpecification | undefined): void {
75
65
  this.value = val
76
66
  ? observe_ValueSpecification(val, this.queryBuilderState.observerContext)