@finos/legend-query-builder 4.14.19 → 4.14.20
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.
- package/lib/components/QueryLoader.d.ts.map +1 -1
- package/lib/components/QueryLoader.js +85 -36
- package/lib/components/QueryLoader.js.map +1 -1
- package/lib/index.css +2 -2
- package/lib/index.css.map +1 -1
- package/lib/package.json +1 -1
- package/lib/stores/QueryBuilder_LegendApplicationPlugin_Extension.d.ts +19 -1
- package/lib/stores/QueryBuilder_LegendApplicationPlugin_Extension.d.ts.map +1 -1
- package/lib/stores/QueryLoaderState.d.ts +14 -4
- package/lib/stores/QueryLoaderState.d.ts.map +1 -1
- package/lib/stores/QueryLoaderState.js +35 -5
- package/lib/stores/QueryLoaderState.js.map +1 -1
- package/package.json +1 -1
- package/src/components/QueryLoader.tsx +279 -127
- package/src/stores/QueryBuilder_LegendApplicationPlugin_Extension.ts +30 -1
- package/src/stores/QueryLoaderState.ts +64 -12
@@ -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
|
-
|
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(
|
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
|
-
|
294
|
-
|
295
|
-
|
296
|
-
|
297
|
-
|
298
|
-
|
299
|
-
|
300
|
-
|
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);
|