@finos/legend-application-query 12.0.9 → 13.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 (65) hide show
  1. package/lib/__lib__/LegendQueryEvent.d.ts +1 -0
  2. package/lib/__lib__/LegendQueryEvent.d.ts.map +1 -1
  3. package/lib/__lib__/LegendQueryEvent.js +1 -0
  4. package/lib/__lib__/LegendQueryEvent.js.map +1 -1
  5. package/lib/__lib__/LegendQueryTelemetryHelper.d.ts +7 -6
  6. package/lib/__lib__/LegendQueryTelemetryHelper.d.ts.map +1 -1
  7. package/lib/__lib__/LegendQueryTelemetryHelper.js +15 -12
  8. package/lib/__lib__/LegendQueryTelemetryHelper.js.map +1 -1
  9. package/lib/__lib__/LegendQueryUserDataHelper.d.ts +27 -0
  10. package/lib/__lib__/LegendQueryUserDataHelper.d.ts.map +1 -0
  11. package/lib/__lib__/LegendQueryUserDataHelper.js +63 -0
  12. package/lib/__lib__/LegendQueryUserDataHelper.js.map +1 -0
  13. package/lib/components/EditExistingQuerySetup.d.ts.map +1 -1
  14. package/lib/components/EditExistingQuerySetup.js +7 -71
  15. package/lib/components/EditExistingQuerySetup.js.map +1 -1
  16. package/lib/components/QueryEditor.d.ts.map +1 -1
  17. package/lib/components/QueryEditor.js +47 -97
  18. package/lib/components/QueryEditor.js.map +1 -1
  19. package/lib/components/QueryProductionizerSetup.d.ts.map +1 -1
  20. package/lib/components/QueryProductionizerSetup.js +6 -47
  21. package/lib/components/QueryProductionizerSetup.js.map +1 -1
  22. package/lib/components/QuerySetup.d.ts +3 -3
  23. package/lib/components/QuerySetup.d.ts.map +1 -1
  24. package/lib/components/QuerySetup.js +1 -1
  25. package/lib/components/QuerySetup.js.map +1 -1
  26. package/lib/index.css +2 -2
  27. package/lib/index.css.map +1 -1
  28. package/lib/index.d.ts +1 -1
  29. package/lib/index.d.ts.map +1 -1
  30. package/lib/index.js +1 -1
  31. package/lib/index.js.map +1 -1
  32. package/lib/package.json +1 -1
  33. package/lib/stores/EditExistingQuerySetupStore.d.ts +3 -12
  34. package/lib/stores/EditExistingQuerySetupStore.d.ts.map +1 -1
  35. package/lib/stores/EditExistingQuerySetupStore.js +27 -64
  36. package/lib/stores/EditExistingQuerySetupStore.js.map +1 -1
  37. package/lib/stores/LegendQueryApplicationPlugin.d.ts +4 -3
  38. package/lib/stores/LegendQueryApplicationPlugin.d.ts.map +1 -1
  39. package/lib/stores/LegendQueryApplicationPlugin.js.map +1 -1
  40. package/lib/stores/QueryEditorStore.d.ts +25 -39
  41. package/lib/stores/QueryEditorStore.d.ts.map +1 -1
  42. package/lib/stores/QueryEditorStore.js +44 -81
  43. package/lib/stores/QueryEditorStore.js.map +1 -1
  44. package/lib/stores/QueryProductionizerSetupStore.d.ts +4 -10
  45. package/lib/stores/QueryProductionizerSetupStore.d.ts.map +1 -1
  46. package/lib/stores/QueryProductionizerSetupStore.js +29 -62
  47. package/lib/stores/QueryProductionizerSetupStore.js.map +1 -1
  48. package/lib/stores/QuerySetupStore.d.ts.map +1 -1
  49. package/lib/stores/QuerySetupStore.js +4 -1
  50. package/lib/stores/QuerySetupStore.js.map +1 -1
  51. package/package.json +10 -10
  52. package/src/__lib__/LegendQueryEvent.ts +1 -0
  53. package/src/__lib__/LegendQueryTelemetryHelper.ts +19 -26
  54. package/src/__lib__/LegendQueryUserDataHelper.ts +92 -0
  55. package/src/components/EditExistingQuerySetup.tsx +10 -204
  56. package/src/components/QueryEditor.tsx +87 -291
  57. package/src/components/QueryProductionizerSetup.tsx +9 -124
  58. package/src/components/QuerySetup.tsx +1 -1
  59. package/src/index.ts +4 -1
  60. package/src/stores/EditExistingQuerySetupStore.ts +54 -87
  61. package/src/stores/LegendQueryApplicationPlugin.ts +4 -3
  62. package/src/stores/QueryEditorStore.ts +91 -107
  63. package/src/stores/QueryProductionizerSetupStore.ts +55 -84
  64. package/src/stores/QuerySetupStore.ts +10 -1
  65. package/tsconfig.json +1 -0
@@ -14,20 +14,10 @@
14
14
  * limitations under the License.
15
15
  */
16
16
 
17
- import {
18
- ArrowLeftIcon,
19
- ArrowRightIcon,
20
- BlankPanelContent,
21
- clsx,
22
- CustomSelectorInput,
23
- PanelLoadingIndicator,
24
- SearchIcon,
25
- type SelectComponent,
26
- } from '@finos/legend-art';
27
- import { debounce, guaranteeType } from '@finos/legend-shared';
28
- import { flowResult } from 'mobx';
17
+ import { ArrowLeftIcon } from '@finos/legend-art';
18
+ import { guaranteeType } from '@finos/legend-shared';
29
19
  import { observer, useLocalObservable } from 'mobx-react-lite';
30
- import { useContext, useEffect, useMemo, useRef, useState } from 'react';
20
+ import { useContext } from 'react';
31
21
  import { useApplicationStore } from '@finos/legend-application';
32
22
  import {
33
23
  useLegendQueryApplicationStore,
@@ -35,15 +25,8 @@ import {
35
25
  } from './LegendQueryFrameworkProvider.js';
36
26
  import { QueryProductionizerSetupStore } from '../stores/QueryProductionizerSetupStore.js';
37
27
  import { BaseQuerySetup, BaseQuerySetupStoreContext } from './QuerySetup.js';
38
- import {
39
- buildQueryOption,
40
- type QueryOption,
41
- } from '@finos/legend-query-builder';
42
28
  import { generateQuerySetupRoute } from '../__lib__/LegendQueryNavigation.js';
43
- import {
44
- CODE_EDITOR_LANGUAGE,
45
- CodeEditor,
46
- } from '@finos/legend-lego/code-editor';
29
+ import { QueryLoader } from '@finos/legend-query-builder';
47
30
 
48
31
  const QueryProductionizerSetupStoreProvider: React.FC<{
49
32
  children: React.ReactNode;
@@ -74,8 +57,6 @@ const useQueryProductionizerSetupStore = (): QueryProductionizerSetupStore =>
74
57
  const QueryProductionizerSetupContent = observer(() => {
75
58
  const applicationStore = useApplicationStore();
76
59
  const setupStore = useQueryProductionizerSetupStore();
77
- const querySearchRef = useRef<SelectComponent>(null);
78
- const [searchText, setSearchText] = useState('');
79
60
 
80
61
  // actions
81
62
  const back = (): void => {
@@ -83,53 +64,6 @@ const QueryProductionizerSetupContent = observer(() => {
83
64
  generateQuerySetupRoute(),
84
65
  );
85
66
  };
86
- const next = (): void => {
87
- if (setupStore.currentQuery) {
88
- setupStore
89
- .loadQueryProductionizer()
90
- .catch(applicationStore.alertUnhandledError);
91
- }
92
- };
93
- const canProceed = setupStore.currentQuery;
94
-
95
- // query
96
- const queryOptions = setupStore.queries.map(buildQueryOption);
97
- const selectedQueryOption = setupStore.currentQuery
98
- ? buildQueryOption(setupStore.currentQuery)
99
- : null;
100
- const onQueryOptionChange = (option: QueryOption | null): void => {
101
- if (option?.value !== setupStore.currentQuery) {
102
- setupStore.setCurrentQuery(option?.value.id);
103
- }
104
- };
105
-
106
- // search text
107
- const debouncedLoadQueries = useMemo(
108
- () =>
109
- debounce((input: string): void => {
110
- flowResult(setupStore.loadQueries(input)).catch(
111
- applicationStore.alertUnhandledError,
112
- );
113
- }, 500),
114
- [applicationStore, setupStore],
115
- );
116
- const onSearchTextChange = (value: string): void => {
117
- if (value !== searchText) {
118
- setSearchText(value);
119
- debouncedLoadQueries.cancel();
120
- debouncedLoadQueries(value);
121
- }
122
- };
123
-
124
- useEffect(() => {
125
- flowResult(setupStore.loadQueries('')).catch(
126
- applicationStore.alertUnhandledError,
127
- );
128
- }, [setupStore, applicationStore]);
129
-
130
- useEffect(() => {
131
- querySearchRef.current?.focus();
132
- }, []);
133
67
 
134
68
  return (
135
69
  <div className="query-setup__wizard query-setup__productionize-query">
@@ -144,61 +78,12 @@ const QueryProductionizerSetupContent = observer(() => {
144
78
  <div className="query-setup__wizard__header__title">
145
79
  Productionizing an existing query...
146
80
  </div>
147
- <button
148
- className={clsx('query-setup__wizard__header__btn', {
149
- 'query-setup__wizard__header__btn--ready': canProceed,
150
- })}
151
- onClick={next}
152
- disabled={!canProceed}
153
- title="Productionize query"
154
- >
155
- <ArrowRightIcon />
156
- </button>
157
81
  </div>
158
- <div className="query-setup__wizard__content">
159
- <div className="query-setup__wizard__group query-setup__wizard__group--inline">
160
- <div className="query-setup__wizard__group__title">
161
- <SearchIcon />
162
- </div>
163
- <CustomSelectorInput
164
- ref={querySearchRef}
165
- className="query-setup__wizard__selector"
166
- options={queryOptions}
167
- isLoading={setupStore.loadQueriesState.isInProgress}
168
- onInputChange={onSearchTextChange}
169
- inputValue={searchText}
170
- onChange={onQueryOptionChange}
171
- value={selectedQueryOption}
172
- placeholder="Search for query by name..."
173
- isClearable={true}
174
- escapeClearsValue={true}
175
- darkMode={true}
176
- />
177
- </div>
178
- <div className="query-setup__productionize-query__preview">
179
- <PanelLoadingIndicator
180
- isLoading={setupStore.loadQueryState.isInProgress}
181
- />
182
- {setupStore.currentQuery && (
183
- <>
184
- {!setupStore.currentQueryInfo && (
185
- <BlankPanelContent>{`Can't preview query`}</BlankPanelContent>
186
- )}
187
- {setupStore.currentQueryInfo && (
188
- <CodeEditor
189
- inputValue={setupStore.currentQueryInfo.content}
190
- isReadOnly={true}
191
- language={CODE_EDITOR_LANGUAGE.PURE}
192
- showMiniMap={false}
193
- hideGutter={true}
194
- />
195
- )}
196
- </>
197
- )}
198
- {!setupStore.currentQuery && (
199
- <BlankPanelContent>No query to preview</BlankPanelContent>
200
- )}
201
- </div>
82
+ <div className="query-setup__productionize-query__content">
83
+ <QueryLoader
84
+ queryLoaderState={setupStore.queryLoaderState}
85
+ loadActionLabel="productionize query"
86
+ />
202
87
  </div>
203
88
  </div>
204
89
  );
@@ -34,7 +34,7 @@ import {
34
34
  } from '@finos/legend-art';
35
35
  import { guaranteeNonNullable } from '@finos/legend-shared';
36
36
  import { observer, useLocalObservable } from 'mobx-react-lite';
37
- import React, { createContext, useContext, useEffect } from 'react';
37
+ import { createContext, useContext, useEffect } from 'react';
38
38
  import { LEGEND_QUERY_SETUP_QUERY_PARAM_TOKEN } from '../__lib__/LegendQueryNavigation.js';
39
39
  import {
40
40
  QuerySetupLandingPageStore,
package/src/index.ts CHANGED
@@ -21,7 +21,10 @@ export * from './application/LegendQueryPluginManager.js';
21
21
 
22
22
  export * from './__lib__/LegendQueryEvent.js';
23
23
  export * from './__lib__/LegendQueryEventHelper.js';
24
- export { generateExistingQueryEditorRoute } from './__lib__/LegendQueryNavigation.js';
24
+ export {
25
+ generateExistingQueryEditorRoute,
26
+ generateServiceQueryCreatorRoute,
27
+ } from './__lib__/LegendQueryNavigation.js';
25
28
 
26
29
  export {
27
30
  useLegendQueryApplicationStore,
@@ -14,33 +14,18 @@
14
14
  * limitations under the License.
15
15
  */
16
16
 
17
- import {
18
- DEFAULT_TYPEAHEAD_SEARCH_LIMIT,
19
- DEFAULT_TYPEAHEAD_SEARCH_MINIMUM_SEARCH_LENGTH,
20
- } from '@finos/legend-application';
21
- import {
22
- QuerySearchSpecification,
23
- type LightQuery,
24
- type QueryInfo,
25
- } from '@finos/legend-graph';
17
+ import { QueryLoaderState } from '@finos/legend-query-builder';
18
+ import { BaseQuerySetupStore } from './QuerySetupStore.js';
26
19
  import type { DepotServerClient } from '@finos/legend-server-depot';
27
- import {
28
- ActionState,
29
- assertErrorThrown,
30
- type GeneratorFn,
31
- } from '@finos/legend-shared';
32
- import { action, flow, makeObservable, observable } from 'mobx';
20
+ import { quantifyList } from '@finos/legend-shared';
21
+ import { LegendQueryUserDataHelper } from '../__lib__/LegendQueryUserDataHelper.js';
33
22
  import type { LegendQueryApplicationStore } from './LegendQueryBaseStore.js';
34
- import { BaseQuerySetupStore } from './QuerySetupStore.js';
23
+ import type { LightQuery } from '@finos/legend-graph';
24
+ import { generateExistingQueryEditorRoute } from '../__lib__/LegendQueryNavigation.js';
25
+ import { LegendQueryTelemetryHelper } from '../__lib__/LegendQueryTelemetryHelper.js';
35
26
 
36
27
  export class EditExistingQuerySetupStore extends BaseQuerySetupStore {
37
- readonly loadQueriesState = ActionState.create();
38
- readonly loadQueryState = ActionState.create();
39
-
40
- queries: LightQuery[] = [];
41
- currentQuery?: LightQuery | undefined;
42
- currentQueryInfo?: QueryInfo | undefined;
43
- showCurrentUserQueriesOnly = false;
28
+ readonly queryLoaderState: QueryLoaderState;
44
29
 
45
30
  constructor(
46
31
  applicationStore: LegendQueryApplicationStore,
@@ -48,69 +33,51 @@ export class EditExistingQuerySetupStore extends BaseQuerySetupStore {
48
33
  ) {
49
34
  super(applicationStore, depotServerClient);
50
35
 
51
- makeObservable(this, {
52
- queries: observable,
53
- currentQuery: observable,
54
- currentQueryInfo: observable,
55
- showCurrentUserQueriesOnly: observable,
56
- setShowCurrentUserQueriesOnly: action,
57
- setCurrentQuery: flow,
58
- loadQueries: flow,
59
- });
60
- }
61
-
62
- setShowCurrentUserQueriesOnly(val: boolean): void {
63
- this.showCurrentUserQueriesOnly = val;
64
- }
65
-
66
- *setCurrentQuery(queryId: string | undefined): GeneratorFn<void> {
67
- if (queryId) {
68
- try {
69
- this.loadQueryState.inProgress();
70
- this.currentQuery =
71
- (yield this.graphManagerState.graphManager.getLightQuery(
72
- queryId,
73
- )) as LightQuery;
74
- const queryInfo =
75
- (yield this.graphManagerState.graphManager.getQueryInfo(
76
- queryId,
77
- )) as QueryInfo;
78
- queryInfo.content =
79
- (yield this.graphManagerState.graphManager.prettyLambdaContent(
80
- queryInfo.content,
81
- )) as string;
82
- this.currentQueryInfo = queryInfo;
83
- } catch (error) {
84
- assertErrorThrown(error);
85
- this.applicationStore.notificationService.notifyError(error);
86
- } finally {
87
- this.loadQueryState.reset();
88
- }
89
- } else {
90
- this.currentQuery = undefined;
91
- }
92
- }
93
-
94
- *loadQueries(searchText: string): GeneratorFn<void> {
95
- const isValidSearchString =
96
- searchText.length >= DEFAULT_TYPEAHEAD_SEARCH_MINIMUM_SEARCH_LENGTH;
97
- this.loadQueriesState.inProgress();
98
- try {
99
- const searchSpecification = new QuerySearchSpecification();
100
- searchSpecification.searchTerm = isValidSearchString
101
- ? searchText
102
- : undefined;
103
- searchSpecification.limit = DEFAULT_TYPEAHEAD_SEARCH_LIMIT;
104
- searchSpecification.showCurrentUserQueriesOnly =
105
- this.showCurrentUserQueriesOnly;
106
- this.queries = (yield this.graphManagerState.graphManager.searchQueries(
107
- searchSpecification,
108
- )) as LightQuery[];
109
- this.loadQueriesState.pass();
110
- } catch (error) {
111
- assertErrorThrown(error);
112
- this.applicationStore.notificationService.notifyError(error);
113
- this.loadQueriesState.fail();
114
- }
36
+ this.queryLoaderState = new QueryLoaderState(
37
+ applicationStore,
38
+ this.graphManagerState,
39
+ {
40
+ loadQuery: (query: LightQuery): void => {
41
+ this.queryLoaderState.setQueryLoaderDialogOpen(false);
42
+ this.applicationStore.navigationService.navigator.goToLocation(
43
+ generateExistingQueryEditorRoute(query.id),
44
+ { ignoreBlocking: true },
45
+ );
46
+ },
47
+ fetchDefaultQueries: () =>
48
+ this.graphManagerState.graphManager.getQueries(
49
+ LegendQueryUserDataHelper.getRecentlyViewedQueries(
50
+ this.applicationStore.userDataService,
51
+ ),
52
+ ),
53
+ generateDefaultQueriesSummaryText: (queries) =>
54
+ queries.length
55
+ ? `Showing ${quantifyList(
56
+ queries,
57
+ 'recently viewed query',
58
+ 'recently viewed queries',
59
+ )}`
60
+ : `No recently viewed queries`,
61
+ onQueryDeleted: (query): void =>
62
+ LegendQueryUserDataHelper.removeRecentlyViewedQuery(
63
+ this.applicationStore.userDataService,
64
+ query.id,
65
+ ),
66
+ onQueryRenamed: (query): void => {
67
+ LegendQueryTelemetryHelper.logEvent_RenameQuerySucceeded(
68
+ applicationStore.telemetryService,
69
+ {
70
+ query: {
71
+ id: query.id,
72
+ name: query.name,
73
+ groupId: query.groupId,
74
+ artifactId: query.artifactId,
75
+ versionId: query.versionId,
76
+ },
77
+ },
78
+ );
79
+ },
80
+ },
81
+ );
115
82
  }
116
83
  }
@@ -64,7 +64,8 @@ export type QueryEditorActionConfiguration = {
64
64
  ) => React.ReactNode | undefined;
65
65
  };
66
66
 
67
- export type QueryEditorHelpMenuEntry = {
67
+ export type QueryEditorHelpMenuActionConfiguration = {
68
+ key: string;
68
69
  title?: string;
69
70
  label: string;
70
71
  onClick: () => void;
@@ -88,9 +89,9 @@ export abstract class LegendQueryApplicationPlugin extends LegendApplicationPlug
88
89
  getExtraQuerySetupActionConfigurations?(): QuerySetupActionConfiguration[];
89
90
 
90
91
  /**
91
- * Get the list of help items for query.
92
+ * Get the list of query editor help menu action configurations.
92
93
  */
93
- getExtraQueryEditorHelpMenuEntries?(): QueryEditorHelpMenuEntry[];
94
+ getExtraQueryEditorHelpMenuActionConfigurations?(): QueryEditorHelpMenuActionConfiguration[];
94
95
 
95
96
  /**
96
97
  * Get the list of existing query editor state builders.