@finos/legend-application-data-cube 0.1.5 → 0.1.7

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 (181) hide show
  1. package/lib/__lib__/LegendDataCubeNavigation.d.ts +5 -5
  2. package/lib/__lib__/LegendDataCubeNavigation.d.ts.map +1 -1
  3. package/lib/__lib__/LegendDataCubeNavigation.js +5 -5
  4. package/lib/__lib__/LegendDataCubeNavigation.js.map +1 -1
  5. package/lib/{stores/source/CubeInputSource.js → __lib__/LegendDataCubeSetting.d.ts} +6 -14
  6. package/lib/__lib__/LegendDataCubeSetting.d.ts.map +1 -0
  7. package/lib/__lib__/LegendDataCubeSetting.js +25 -0
  8. package/lib/__lib__/LegendDataCubeSetting.js.map +1 -0
  9. package/lib/{stores/model/DataCubeQueryContent.js → __lib__/LegendDataCubeUserData.d.ts} +4 -5
  10. package/lib/__lib__/LegendDataCubeUserData.d.ts.map +1 -0
  11. package/lib/{stores/model/DataCubeGenericSource.d.ts → __lib__/LegendDataCubeUserData.js} +6 -3
  12. package/lib/__lib__/LegendDataCubeUserData.js.map +1 -0
  13. package/lib/application/LegendDataCube.d.ts.map +1 -1
  14. package/lib/application/LegendDataCube.js.map +1 -1
  15. package/lib/application/LegendDataCubeApplicationConfig.d.ts +1 -1
  16. package/lib/application/LegendDataCubeApplicationConfig.d.ts.map +1 -1
  17. package/lib/application/LegendDataCubeApplicationConfig.js +3 -1
  18. package/lib/application/LegendDataCubeApplicationConfig.js.map +1 -1
  19. package/lib/application/LegendDataCubePluginManager.d.ts.map +1 -1
  20. package/lib/application/LegendDataCubePluginManager.js.map +1 -1
  21. package/lib/components/LegendDataCubeFrameworkProvider.d.ts +2 -2
  22. package/lib/components/LegendDataCubeFrameworkProvider.d.ts.map +1 -1
  23. package/lib/components/LegendDataCubeFrameworkProvider.js +5 -5
  24. package/lib/components/LegendDataCubeFrameworkProvider.js.map +1 -1
  25. package/lib/components/LegendDataCubeWebApplication.d.ts.map +1 -1
  26. package/lib/components/LegendDataCubeWebApplication.js +25 -6
  27. package/lib/components/LegendDataCubeWebApplication.js.map +1 -1
  28. package/lib/components/{source/DataCubeSourceEditor.d.ts → query-builder/LegendDataCubeNewQueryBuilder.d.ts} +4 -4
  29. package/lib/components/query-builder/LegendDataCubeNewQueryBuilder.d.ts.map +1 -0
  30. package/lib/components/query-builder/LegendDataCubeNewQueryBuilder.js +45 -0
  31. package/lib/components/query-builder/LegendDataCubeNewQueryBuilder.js.map +1 -0
  32. package/{src/stores/model/DataCubeGenericSource.ts → lib/components/query-builder/LegendDataCubeQueryBuilder.d.ts} +2 -2
  33. package/lib/components/query-builder/LegendDataCubeQueryBuilder.d.ts.map +1 -0
  34. package/lib/components/query-builder/LegendDataCubeQueryBuilder.js +85 -0
  35. package/lib/components/query-builder/LegendDataCubeQueryBuilder.js.map +1 -0
  36. package/lib/components/query-builder/LegendDataCubeQueryBuilderStoreProvider.d.ts +19 -0
  37. package/lib/components/query-builder/LegendDataCubeQueryBuilderStoreProvider.d.ts.map +1 -0
  38. package/lib/components/query-builder/LegendDataCubeQueryBuilderStoreProvider.js +33 -0
  39. package/lib/components/query-builder/LegendDataCubeQueryBuilderStoreProvider.js.map +1 -0
  40. package/lib/components/{source/ExistingDataCubeQuery.d.ts → query-builder/LegendDataCubeQueryLoader.d.ts} +2 -2
  41. package/lib/components/query-builder/LegendDataCubeQueryLoader.d.ts.map +1 -0
  42. package/lib/components/query-builder/LegendDataCubeQueryLoader.js +99 -0
  43. package/lib/components/query-builder/LegendDataCubeQueryLoader.js.map +1 -0
  44. package/lib/components/{DataCubeEditor.d.ts → query-builder/LegendDataCubeQuerySaver.d.ts} +2 -2
  45. package/lib/components/query-builder/LegendDataCubeQuerySaver.d.ts.map +1 -0
  46. package/lib/components/query-builder/LegendDataCubeQuerySaver.js +49 -0
  47. package/lib/components/query-builder/LegendDataCubeQuerySaver.js.map +1 -0
  48. package/lib/components/{source/SavedQuerySourceEditor.d.ts → query-builder/source-builder/AdhocQueryDataCubeSourceBuilder.d.ts} +4 -4
  49. package/lib/components/query-builder/source-builder/AdhocQueryDataCubeSourceBuilder.d.ts.map +1 -0
  50. package/lib/components/query-builder/source-builder/AdhocQueryDataCubeSourceBuilder.js +22 -0
  51. package/lib/components/query-builder/source-builder/AdhocQueryDataCubeSourceBuilder.js.map +1 -0
  52. package/lib/components/query-builder/source-builder/LegendQueryDataCubeSourceBuilder.d.ts +22 -0
  53. package/lib/components/query-builder/source-builder/LegendQueryDataCubeSourceBuilder.d.ts.map +1 -0
  54. package/lib/components/query-builder/source-builder/LegendQueryDataCubeSourceBuilder.js +97 -0
  55. package/lib/components/query-builder/source-builder/LegendQueryDataCubeSourceBuilder.js.map +1 -0
  56. package/lib/index.css +2 -2
  57. package/lib/index.css.map +1 -1
  58. package/lib/package.json +2 -2
  59. package/lib/stores/LegendDataCubeBaseStore.d.ts +41 -0
  60. package/lib/stores/LegendDataCubeBaseStore.d.ts.map +1 -0
  61. package/lib/stores/LegendDataCubeBaseStore.js +123 -0
  62. package/lib/stores/LegendDataCubeBaseStore.js.map +1 -0
  63. package/lib/stores/LegendDataCubeDataCubeEngine.d.ts +65 -0
  64. package/lib/stores/LegendDataCubeDataCubeEngine.d.ts.map +1 -0
  65. package/lib/stores/LegendDataCubeDataCubeEngine.js +249 -0
  66. package/lib/stores/LegendDataCubeDataCubeEngine.js.map +1 -0
  67. package/lib/stores/model/LegendQueryDataCubeSource.d.ts +32 -0
  68. package/lib/stores/model/LegendQueryDataCubeSource.d.ts.map +1 -0
  69. package/lib/stores/model/LegendQueryDataCubeSource.js +35 -0
  70. package/lib/stores/model/LegendQueryDataCubeSource.js.map +1 -0
  71. package/lib/stores/query-builder/LegendDataCubeNewQueryState.d.ts +34 -0
  72. package/lib/stores/query-builder/LegendDataCubeNewQueryState.d.ts.map +1 -0
  73. package/lib/stores/query-builder/LegendDataCubeNewQueryState.js +92 -0
  74. package/lib/stores/query-builder/LegendDataCubeNewQueryState.js.map +1 -0
  75. package/lib/stores/query-builder/LegendDataCubeQueryBuilderStore.d.ts +52 -0
  76. package/lib/stores/query-builder/LegendDataCubeQueryBuilderStore.d.ts.map +1 -0
  77. package/lib/stores/query-builder/LegendDataCubeQueryBuilderStore.js +211 -0
  78. package/lib/stores/query-builder/LegendDataCubeQueryBuilderStore.js.map +1 -0
  79. package/lib/stores/query-builder/LegendDataCubeQueryLoaderState.d.ts +54 -0
  80. package/lib/stores/query-builder/LegendDataCubeQueryLoaderState.d.ts.map +1 -0
  81. package/lib/stores/query-builder/LegendDataCubeQueryLoaderState.js +197 -0
  82. package/lib/stores/query-builder/LegendDataCubeQueryLoaderState.js.map +1 -0
  83. package/lib/stores/{model/DataCubeQueryContent.d.ts → query-builder/source-builder/AdhocQueryDataCubeSourceBuilderState.d.ts} +7 -7
  84. package/lib/stores/query-builder/source-builder/AdhocQueryDataCubeSourceBuilderState.d.ts.map +1 -0
  85. package/lib/stores/{model/LegendSavedQuerySource.js → query-builder/source-builder/AdhocQueryDataCubeSourceBuilderState.js} +12 -7
  86. package/lib/stores/query-builder/source-builder/AdhocQueryDataCubeSourceBuilderState.js.map +1 -0
  87. package/lib/stores/query-builder/source-builder/LegendDataCubeSourceBuilderState.d.ts +33 -0
  88. package/lib/stores/query-builder/source-builder/LegendDataCubeSourceBuilderState.d.ts.map +1 -0
  89. package/lib/stores/query-builder/source-builder/LegendDataCubeSourceBuilderState.js +31 -0
  90. package/lib/stores/query-builder/source-builder/LegendDataCubeSourceBuilderState.js.map +1 -0
  91. package/lib/stores/query-builder/source-builder/LegendQueryDataCubeSourceBuilderState.d.ts +31 -0
  92. package/lib/stores/query-builder/source-builder/LegendQueryDataCubeSourceBuilderState.d.ts.map +1 -0
  93. package/lib/stores/query-builder/source-builder/LegendQueryDataCubeSourceBuilderState.js +84 -0
  94. package/lib/stores/query-builder/source-builder/LegendQueryDataCubeSourceBuilderState.js.map +1 -0
  95. package/package.json +11 -11
  96. package/src/__lib__/LegendDataCubeNavigation.ts +7 -7
  97. package/src/{stores/model/DataCubeQueryContent.ts → __lib__/LegendDataCubeSetting.ts} +6 -6
  98. package/{lib/stores/model/DataCubeGenericSource.js → src/__lib__/LegendDataCubeUserData.ts} +5 -2
  99. package/src/application/LegendDataCube.tsx +1 -0
  100. package/src/application/LegendDataCubeApplicationConfig.ts +6 -4
  101. package/src/application/LegendDataCubePluginManager.ts +1 -0
  102. package/src/components/LegendDataCubeFrameworkProvider.tsx +7 -7
  103. package/src/components/LegendDataCubeWebApplication.tsx +48 -12
  104. package/src/components/query-builder/LegendDataCubeNewQueryBuilder.tsx +115 -0
  105. package/src/components/query-builder/LegendDataCubeQueryBuilder.tsx +213 -0
  106. package/src/components/query-builder/LegendDataCubeQueryBuilderStoreProvider.tsx +56 -0
  107. package/src/components/query-builder/LegendDataCubeQueryLoader.tsx +310 -0
  108. package/src/components/query-builder/LegendDataCubeQuerySaver.tsx +106 -0
  109. package/src/{stores/source/CubeInputSource.ts → components/query-builder/source-builder/AdhocQueryDataCubeSourceBuilder.tsx} +14 -19
  110. package/src/components/query-builder/source-builder/LegendQueryDataCubeSourceBuilder.tsx +313 -0
  111. package/src/stores/LegendDataCubeBaseStore.ts +198 -0
  112. package/src/stores/LegendDataCubeDataCubeEngine.ts +494 -0
  113. package/src/stores/model/LegendQueryDataCubeSource.ts +46 -0
  114. package/src/stores/query-builder/LegendDataCubeNewQueryState.tsx +139 -0
  115. package/src/stores/query-builder/LegendDataCubeQueryBuilderStore.tsx +296 -0
  116. package/src/stores/query-builder/LegendDataCubeQueryLoaderState.tsx +258 -0
  117. package/src/stores/{source/LegendCubeViewer.ts → query-builder/source-builder/AdhocQueryDataCubeSourceBuilderState.ts} +15 -8
  118. package/src/stores/query-builder/source-builder/LegendDataCubeSourceBuilderState.ts +40 -0
  119. package/src/stores/query-builder/source-builder/LegendQueryDataCubeSourceBuilderState.ts +125 -0
  120. package/tsconfig.json +18 -15
  121. package/lib/components/DataCubeEditor.d.ts.map +0 -1
  122. package/lib/components/DataCubeEditor.js +0 -59
  123. package/lib/components/DataCubeEditor.js.map +0 -1
  124. package/lib/components/source/DataCubeSourceEditor.d.ts.map +0 -1
  125. package/lib/components/source/DataCubeSourceEditor.js +0 -43
  126. package/lib/components/source/DataCubeSourceEditor.js.map +0 -1
  127. package/lib/components/source/ExistingDataCubeQuery.d.ts.map +0 -1
  128. package/lib/components/source/ExistingDataCubeQuery.js +0 -36
  129. package/lib/components/source/ExistingDataCubeQuery.js.map +0 -1
  130. package/lib/components/source/SavedQuerySourceEditor.d.ts.map +0 -1
  131. package/lib/components/source/SavedQuerySourceEditor.js +0 -25
  132. package/lib/components/source/SavedQuerySourceEditor.js.map +0 -1
  133. package/lib/stores/LegendDataCubeEditorStore.d.ts +0 -50
  134. package/lib/stores/LegendDataCubeEditorStore.d.ts.map +0 -1
  135. package/lib/stores/LegendDataCubeEditorStore.js +0 -153
  136. package/lib/stores/LegendDataCubeEditorStore.js.map +0 -1
  137. package/lib/stores/engine/LegendExecutionDataCubeEngine.d.ts +0 -52
  138. package/lib/stores/engine/LegendExecutionDataCubeEngine.d.ts.map +0 -1
  139. package/lib/stores/engine/LegendExecutionDataCubeEngine.js +0 -149
  140. package/lib/stores/engine/LegendExecutionDataCubeEngine.js.map +0 -1
  141. package/lib/stores/model/DataCubeGenericSource.d.ts.map +0 -1
  142. package/lib/stores/model/DataCubeGenericSource.js.map +0 -1
  143. package/lib/stores/model/DataCubeGenericSourceHelper.d.ts +0 -24
  144. package/lib/stores/model/DataCubeGenericSourceHelper.d.ts.map +0 -1
  145. package/lib/stores/model/DataCubeGenericSourceHelper.js +0 -58
  146. package/lib/stores/model/DataCubeGenericSourceHelper.js.map +0 -1
  147. package/lib/stores/model/DataCubeQueryContent.d.ts.map +0 -1
  148. package/lib/stores/model/DataCubeQueryContent.js.map +0 -1
  149. package/lib/stores/model/LegendSavedQuerySource.d.ts +0 -21
  150. package/lib/stores/model/LegendSavedQuerySource.d.ts.map +0 -1
  151. package/lib/stores/model/LegendSavedQuerySource.js.map +0 -1
  152. package/lib/stores/source/CubeInputSource.d.ts +0 -32
  153. package/lib/stores/source/CubeInputSource.d.ts.map +0 -1
  154. package/lib/stores/source/CubeInputSource.js.map +0 -1
  155. package/lib/stores/source/CubeInputSourceLoader.d.ts +0 -37
  156. package/lib/stores/source/CubeInputSourceLoader.d.ts.map +0 -1
  157. package/lib/stores/source/CubeInputSourceLoader.js +0 -39
  158. package/lib/stores/source/CubeInputSourceLoader.js.map +0 -1
  159. package/lib/stores/source/LegendCubeViewer.d.ts +0 -23
  160. package/lib/stores/source/LegendCubeViewer.d.ts.map +0 -1
  161. package/lib/stores/source/LegendCubeViewer.js +0 -24
  162. package/lib/stores/source/LegendCubeViewer.js.map +0 -1
  163. package/lib/stores/source/LegendDataCubeSourceBuilder.d.ts +0 -34
  164. package/lib/stores/source/LegendDataCubeSourceBuilder.d.ts.map +0 -1
  165. package/lib/stores/source/LegendDataCubeSourceBuilder.js +0 -70
  166. package/lib/stores/source/LegendDataCubeSourceBuilder.js.map +0 -1
  167. package/lib/stores/source/SavedQueryInputSourceState.d.ts +0 -35
  168. package/lib/stores/source/SavedQueryInputSourceState.d.ts.map +0 -1
  169. package/lib/stores/source/SavedQueryInputSourceState.js +0 -81
  170. package/lib/stores/source/SavedQueryInputSourceState.js.map +0 -1
  171. package/src/components/DataCubeEditor.tsx +0 -190
  172. package/src/components/source/DataCubeSourceEditor.tsx +0 -133
  173. package/src/components/source/ExistingDataCubeQuery.tsx +0 -101
  174. package/src/components/source/SavedQuerySourceEditor.tsx +0 -62
  175. package/src/stores/LegendDataCubeEditorStore.ts +0 -237
  176. package/src/stores/engine/LegendExecutionDataCubeEngine.ts +0 -267
  177. package/src/stores/model/DataCubeGenericSourceHelper.ts +0 -97
  178. package/src/stores/model/LegendSavedQuerySource.ts +0 -26
  179. package/src/stores/source/CubeInputSourceLoader.ts +0 -56
  180. package/src/stores/source/LegendDataCubeSourceBuilder.ts +0 -98
  181. package/src/stores/source/SavedQueryInputSourceState.ts +0 -142
@@ -14,23 +14,18 @@
14
14
  * limitations under the License.
15
15
  */
16
16
 
17
- import type { VersionedProjectData } from '@finos/legend-server-depot';
17
+ import { observer } from 'mobx-react-lite';
18
+ import type { AdhocQueryDataCubeSourceBuilderState } from '../../../stores/query-builder/source-builder/AdhocQueryDataCubeSourceBuilderState.js';
19
+ import { FormBadge_WIP } from '@finos/legend-data-cube';
18
20
 
19
- export abstract class LegendDepotSavedSource {
20
- project!: VersionedProjectData;
21
- }
22
-
23
- export class LegendDepotService extends LegendDepotSavedSource {
24
- service!: string;
25
- }
26
-
27
- export class LegendDepotFunction extends LegendDepotSavedSource {
28
- _function!: string;
29
- }
30
-
31
- export class LegendDepotTable extends LegendDepotSavedSource {
32
- database!: string;
33
- schema!: string;
34
- table!: string;
35
- runtime!: string;
36
- }
21
+ export const AdhocQueryDataCubeSourceBuilder = observer(
22
+ (props: { sourceBuilder: AdhocQueryDataCubeSourceBuilderState }) => {
23
+ return (
24
+ <div className="flex h-full w-full">
25
+ <div className="flex h-6 items-center text-neutral-500">
26
+ This is a work-in-progress. <FormBadge_WIP />
27
+ </div>
28
+ </div>
29
+ );
30
+ },
31
+ );
@@ -0,0 +1,313 @@
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 { observer } from 'mobx-react-lite';
18
+ import {
19
+ QUERY_LOADER_TYPEAHEAD_SEARCH_LIMIT,
20
+ SORT_BY_OPTIONS,
21
+ type QueryLoaderState,
22
+ } from '@finos/legend-query-builder';
23
+ import type { LegendQueryDataCubeSourceBuilderState } from '../../../stores/query-builder/source-builder/LegendQueryDataCubeSourceBuilderState.js';
24
+ import { generateGAVCoordinates } from '@finos/legend-storage';
25
+ import { useApplicationStore } from '@finos/legend-application';
26
+ import { cn, DataCubeIcon, useDropdownMenu } from '@finos/legend-art';
27
+ import {
28
+ debounce,
29
+ formatDistanceToNow,
30
+ quantifyList,
31
+ } from '@finos/legend-shared';
32
+ import { flowResult } from 'mobx';
33
+ import { useRef, useState, useMemo, useEffect } from 'react';
34
+ import {
35
+ FormButton,
36
+ FormCheckbox,
37
+ FormCodeEditor,
38
+ FormDropdownMenu,
39
+ FormDropdownMenuItem,
40
+ FormDropdownMenuTrigger,
41
+ FormTextInput,
42
+ } from '@finos/legend-data-cube';
43
+ import { CODE_EDITOR_LANGUAGE } from '@finos/legend-code-editor';
44
+
45
+ const LegendQuerySearcher = observer((props: { state: QueryLoaderState }) => {
46
+ const { state } = props;
47
+ const application = useApplicationStore();
48
+ const searchInputRef = useRef<HTMLInputElement>(null);
49
+ const searchResults = state.queries;
50
+
51
+ useEffect(() => {
52
+ searchInputRef.current?.focus();
53
+ }, [state]);
54
+
55
+ // search text
56
+ const debouncedLoadQueries = useMemo(
57
+ () =>
58
+ debounce((input: string) => {
59
+ flowResult(state.searchQueries(input)).catch(
60
+ application.alertUnhandledError,
61
+ );
62
+ }, 500),
63
+ [application.alertUnhandledError, state],
64
+ );
65
+ const onSearchTextChange: React.ChangeEventHandler<HTMLInputElement> = (
66
+ event,
67
+ ) => {
68
+ if (event.target.value !== state.searchText) {
69
+ state.setSearchText(event.target.value);
70
+ debouncedLoadQueries.cancel();
71
+ debouncedLoadQueries(event.target.value);
72
+ }
73
+ };
74
+ const clearSearches = () => {
75
+ state.setSearchText('');
76
+ debouncedLoadQueries.cancel();
77
+ debouncedLoadQueries('');
78
+ };
79
+
80
+ // filter and sort
81
+ const [isMineOnly, setIsMineOnly] = useState(false);
82
+ const toggleShowCurrentUserQueriesOnly = () => {
83
+ state.setShowCurrentUserQueriesOnly(!state.showCurrentUserQueriesOnly);
84
+ setIsMineOnly(!isMineOnly);
85
+ debouncedLoadQueries.cancel();
86
+ debouncedLoadQueries(state.searchText);
87
+ };
88
+
89
+ const [
90
+ openSortDropdown,
91
+ closeSortDropdown,
92
+ sortDropdownProps,
93
+ sortDropdownPropsOpen,
94
+ ] = useDropdownMenu();
95
+ const applySort = (value: SORT_BY_OPTIONS) => {
96
+ state.setSortBy(value);
97
+ debouncedLoadQueries.cancel();
98
+ debouncedLoadQueries(state.searchText);
99
+ };
100
+
101
+ useEffect(() => {
102
+ flowResult(state.searchQueries('')).catch(application.alertUnhandledError);
103
+ }, [application, state]);
104
+
105
+ return (
106
+ <div className="h-full">
107
+ <div className="p-1.5">
108
+ <div className="relative flex h-6 w-full items-center justify-between">
109
+ <FormTextInput
110
+ ref={searchInputRef}
111
+ className={cn('h-6 w-full pl-6 pr-1', {
112
+ 'pr-6': Boolean(state.searchText),
113
+ })}
114
+ onChange={onSearchTextChange}
115
+ value={state.searchText}
116
+ placeholder="Search for queries by name or ID"
117
+ />
118
+ <div className="absolute flex aspect-square h-full items-center justify-center">
119
+ <DataCubeIcon.Search className="text-lg text-neutral-600" />
120
+ </div>
121
+ {Boolean(state.searchText) && (
122
+ <>
123
+ <button
124
+ className="absolute right-0 flex aspect-square h-full items-center justify-center"
125
+ tabIndex={-1}
126
+ onClick={clearSearches}
127
+ title="Clear"
128
+ >
129
+ <DataCubeIcon.X />
130
+ </button>
131
+ </>
132
+ )}
133
+ </div>
134
+ <div className="mt-1 flex h-6 w-full items-center">
135
+ <div className="flex w-[calc(100%_-_128px)] items-center">
136
+ <div className="w-10 text-sm">Filters:</div>
137
+ <div className="flex h-6 w-[calc(100%_-_40px)] overflow-x-auto">
138
+ <FormCheckbox
139
+ label="Mine Only"
140
+ checked={isMineOnly}
141
+ onChange={toggleShowCurrentUserQueriesOnly}
142
+ />
143
+ </div>
144
+ {/* TODO?: support extra filters */}
145
+ </div>
146
+
147
+ <div>
148
+ <FormDropdownMenuTrigger
149
+ className="w-32"
150
+ onClick={openSortDropdown}
151
+ open={sortDropdownPropsOpen}
152
+ disabled={!state.canPerformAdvancedSearch(state.searchText)}
153
+ >
154
+ Sort by: {state.sortBy}
155
+ </FormDropdownMenuTrigger>
156
+ <FormDropdownMenu className="w-32" {...sortDropdownProps}>
157
+ {Object.values(SORT_BY_OPTIONS).map((option) => (
158
+ <FormDropdownMenuItem
159
+ key={option}
160
+ onClick={() => {
161
+ applySort(option);
162
+ closeSortDropdown();
163
+ }}
164
+ autoFocus={option === state.sortBy}
165
+ >
166
+ {option}
167
+ </FormDropdownMenuItem>
168
+ ))}
169
+ </FormDropdownMenu>
170
+ </div>
171
+ </div>
172
+ </div>
173
+ <div className="mx-1.5 mb-1 h-[1px] bg-neutral-200" />
174
+ <div className="h-[calc(100%_-_71px)]">
175
+ <div className="h-full overflow-y-auto">
176
+ {state.searchQueriesState.hasCompleted && (
177
+ <>
178
+ <div className="mb-1 flex h-5 w-full items-center px-1.5 text-sm text-neutral-600">
179
+ {state.showingDefaultQueries ? (
180
+ (state.generateDefaultQueriesSummaryText?.(searchResults) ??
181
+ `Refine your search to get better matches`)
182
+ ) : searchResults.length >=
183
+ QUERY_LOADER_TYPEAHEAD_SEARCH_LIMIT ? (
184
+ <>
185
+ {`Found ${QUERY_LOADER_TYPEAHEAD_SEARCH_LIMIT}+ matches`}{' '}
186
+ <DataCubeIcon.AlertInfo
187
+ className="ml-1 text-lg"
188
+ title="Some queries are not listed, refine your search to get better matches"
189
+ />
190
+ </>
191
+ ) : (
192
+ `Found ${quantifyList(searchResults, 'match', 'matches')}`
193
+ )}
194
+ </div>
195
+ {searchResults
196
+ .slice(0, QUERY_LOADER_TYPEAHEAD_SEARCH_LIMIT)
197
+ .map((query, idx) => (
198
+ <div
199
+ className="mx-1.5 mb-0.5 flex h-[42px] w-[calc(100%_-_12px)] cursor-pointer border border-neutral-200 bg-neutral-100 hover:bg-neutral-200"
200
+ key={query.id}
201
+ title="Click to choose query"
202
+ onClick={() => state.loadQuery(query)}
203
+ >
204
+ <div className="w-[calc(100%_-_16px)]">
205
+ <div className="h-6 w-4/5 overflow-hidden text-ellipsis whitespace-nowrap px-1.5 leading-6">
206
+ {query.name}
207
+ </div>
208
+ <div className="flex h-[18px] items-start justify-between px-1.5">
209
+ <div className="flex">
210
+ <DataCubeIcon.ClockEdit className="text-sm text-neutral-500" />
211
+ <div className="ml-1 text-sm text-neutral-500">
212
+ {query.lastUpdatedAt
213
+ ? formatDistanceToNow(
214
+ new Date(query.lastUpdatedAt),
215
+ {
216
+ includeSeconds: true,
217
+ addSuffix: true,
218
+ },
219
+ )
220
+ : '(unknown)'}
221
+ </div>
222
+ </div>
223
+ <div className="flex">
224
+ <DataCubeIcon.User className="text-sm text-neutral-500" />
225
+ <div className="ml-1 text-sm text-neutral-500">
226
+ {query.owner}
227
+ </div>
228
+ </div>
229
+ </div>
230
+ </div>
231
+ <div className="flex h-full w-4 items-center justify-center">
232
+ <DataCubeIcon.ChevronRight className="text-neutral-600" />
233
+ </div>
234
+ </div>
235
+ ))}
236
+ </>
237
+ )}
238
+ {!state.searchQueriesState.hasCompleted && (
239
+ <div className="mb-1 flex h-5 w-full items-center px-1.5 text-sm text-neutral-600">
240
+ <DataCubeIcon.Loader className="animate-spin stroke-2 text-lg" />
241
+ <span className="ml-1">Searching...</span>
242
+ </div>
243
+ )}
244
+ </div>
245
+ </div>
246
+ </div>
247
+ );
248
+ });
249
+
250
+ export const LegendQueryDataCubeSourceBuilder = observer(
251
+ (props: { sourceBuilder: LegendQueryDataCubeSourceBuilderState }) => {
252
+ const { sourceBuilder } = props;
253
+ const query = sourceBuilder.query;
254
+
255
+ if (!query) {
256
+ return <LegendQuerySearcher state={sourceBuilder.queryLoaderState} />;
257
+ }
258
+ return (
259
+ <div className="h-full">
260
+ <div className="mb-0.5 flex h-[60px] w-full border border-neutral-200 bg-neutral-100">
261
+ <div className="w-full">
262
+ <div className="h-6 w-4/5 overflow-hidden text-ellipsis whitespace-nowrap px-1.5 leading-6">
263
+ {query.name}
264
+ </div>
265
+ <div className="flex h-[18px] items-start justify-between px-1.5 text-sm text-neutral-500">
266
+ {`[ ${generateGAVCoordinates(
267
+ query.groupId,
268
+ query.artifactId,
269
+ query.versionId,
270
+ )} ]`}
271
+ </div>
272
+ <div className="flex h-[18px] items-start justify-between px-1.5">
273
+ <div className="flex">
274
+ <DataCubeIcon.ClockEdit className="text-sm text-neutral-500" />
275
+ <div className="ml-1 text-sm text-neutral-500">
276
+ {query.lastUpdatedAt
277
+ ? formatDistanceToNow(new Date(query.lastUpdatedAt), {
278
+ includeSeconds: true,
279
+ addSuffix: true,
280
+ })
281
+ : '(unknown)'}
282
+ </div>
283
+ </div>
284
+ <div className="flex">
285
+ <DataCubeIcon.User className="text-sm text-neutral-500" />
286
+ <div className="ml-1 text-sm text-neutral-500">
287
+ {query.owner}
288
+ </div>
289
+ </div>
290
+ </div>
291
+ </div>
292
+ </div>
293
+ {sourceBuilder.queryCode !== undefined && (
294
+ <div className="mt-1.5 h-40 w-full">
295
+ <FormCodeEditor
296
+ value={sourceBuilder.queryCode}
297
+ title="Query Code"
298
+ isReadOnly={true}
299
+ language={CODE_EDITOR_LANGUAGE.PURE}
300
+ hidePadding={true}
301
+ />
302
+ </div>
303
+ )}
304
+ <FormButton
305
+ className="mt-1.5"
306
+ onClick={() => sourceBuilder.unsetQuery()}
307
+ >
308
+ Select Another Query
309
+ </FormButton>
310
+ </div>
311
+ );
312
+ },
313
+ );
@@ -0,0 +1,198 @@
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 {
18
+ APPLICATION_EVENT,
19
+ DEFAULT_TAB_SIZE,
20
+ type ApplicationStore,
21
+ } from '@finos/legend-application';
22
+ import type { LegendDataCubePluginManager } from '../application/LegendDataCubePluginManager.js';
23
+ import { DepotServerClient } from '@finos/legend-server-depot';
24
+ import type { LegendDataCubeApplicationConfig } from '../application/LegendDataCubeApplicationConfig.js';
25
+ import {
26
+ V1_EngineServerClient,
27
+ V1_PureGraphManager,
28
+ } from '@finos/legend-graph';
29
+ import {
30
+ ActionState,
31
+ LogEvent,
32
+ assertErrorThrown,
33
+ guaranteeIsBoolean,
34
+ guaranteeIsString,
35
+ } from '@finos/legend-shared';
36
+ import { LegendDataCubeDataCubeEngine } from './LegendDataCubeDataCubeEngine.js';
37
+ import {
38
+ DataCubeSettingGroup,
39
+ DataCubeSettingType,
40
+ LayoutManagerState,
41
+ type DataCubeSetting,
42
+ type DataCubeSettingValues,
43
+ } from '@finos/legend-data-cube';
44
+ import {
45
+ LegendDataCubeSettingKey,
46
+ LegendDataCubeSettingStorageKey,
47
+ } from '../__lib__/LegendDataCubeSetting.js';
48
+
49
+ export type LegendDataCubeApplicationStore = ApplicationStore<
50
+ LegendDataCubeApplicationConfig,
51
+ LegendDataCubePluginManager
52
+ >;
53
+
54
+ declare const AG_GRID_LICENSE: string | undefined;
55
+
56
+ export class LegendDataCubeBaseStore {
57
+ readonly application: LegendDataCubeApplicationStore;
58
+ readonly pluginManager: LegendDataCubePluginManager;
59
+ readonly layout = new LayoutManagerState();
60
+
61
+ readonly depotServerClient: DepotServerClient;
62
+ readonly graphManager: V1_PureGraphManager;
63
+ readonly engineServerClient: V1_EngineServerClient;
64
+ readonly engine: LegendDataCubeDataCubeEngine;
65
+ readonly initializeState = ActionState.create();
66
+
67
+ readonly dataCubeSettings: DataCubeSetting[];
68
+
69
+ gridClientLicense?: string | undefined;
70
+
71
+ constructor(application: LegendDataCubeApplicationStore) {
72
+ this.application = application;
73
+ this.pluginManager = application.pluginManager;
74
+ this.depotServerClient = new DepotServerClient({
75
+ serverUrl: this.application.config.depotServerUrl,
76
+ });
77
+ this.depotServerClient.setTracerService(application.tracerService);
78
+ this.graphManager = new V1_PureGraphManager(
79
+ this.application.pluginManager,
80
+ this.application.logService,
81
+ );
82
+
83
+ this.dataCubeSettings = [
84
+ {
85
+ key: LegendDataCubeSettingKey.DEBUGGER__ENGINE_SERVER_CLIENT__ENABLE_COMPRESSION,
86
+ title: `Engine Client Request Payload Compression: Enabled`,
87
+ description: `Specifies if request payload should be compressed for better performance.`,
88
+ group: DataCubeSettingGroup.DEBUG,
89
+ type: DataCubeSettingType.BOOLEAN,
90
+ defaultValue: true,
91
+ action: (newValue) => {
92
+ this.engineServerClient.setCompression(newValue);
93
+ this.graphManager
94
+ .TEMPORARY__getEngineConfig()
95
+ .setUseClientRequestPayloadCompression(newValue);
96
+ },
97
+ } satisfies DataCubeSetting<boolean>,
98
+ {
99
+ key: LegendDataCubeSettingKey.DEBUGGER__ENGINE_SERVER_CLIENT__BASE_URL,
100
+ title: `Engine Server Base URL`,
101
+ description: `Specifies another base URL to be used for engine server.`,
102
+ group: DataCubeSettingGroup.DEBUG,
103
+ type: DataCubeSettingType.STRING,
104
+ defaultValue: application.config.engineServerUrl,
105
+ action: (newValue) => {
106
+ this.engineServerClient.setBaseUrl(newValue);
107
+ this.graphManager.TEMPORARY__getEngineConfig().setBaseUrl(newValue);
108
+ },
109
+ } satisfies DataCubeSetting<string>,
110
+ ];
111
+
112
+ this.engineServerClient = new V1_EngineServerClient({
113
+ baseUrl: this.getEngineServerBaseUrlSettingValue(),
114
+ queryBaseUrl: this.application.config.engineQueryServerUrl,
115
+ enableCompression: this.getEngineEnableCompressionSettingValue(),
116
+ });
117
+ this.engineServerClient.setTracerService(application.tracerService);
118
+ this.engine = new LegendDataCubeDataCubeEngine(this);
119
+ }
120
+
121
+ private getEngineEnableCompressionSettingValue() {
122
+ const persistedValues = this.application.settingService.getObjectValue(
123
+ LegendDataCubeSettingStorageKey.DATA_CUBE,
124
+ ) as DataCubeSettingValues | undefined;
125
+ return guaranteeIsBoolean(
126
+ persistedValues?.[
127
+ LegendDataCubeSettingKey
128
+ .DEBUGGER__ENGINE_SERVER_CLIENT__ENABLE_COMPRESSION
129
+ ] ??
130
+ this.dataCubeSettings.find(
131
+ (configuration) =>
132
+ configuration.key ===
133
+ LegendDataCubeSettingKey.DEBUGGER__ENGINE_SERVER_CLIENT__ENABLE_COMPRESSION,
134
+ )?.defaultValue,
135
+ );
136
+ }
137
+
138
+ private getEngineServerBaseUrlSettingValue() {
139
+ const persistedValues = this.application.settingService.getObjectValue(
140
+ LegendDataCubeSettingStorageKey.DATA_CUBE,
141
+ ) as DataCubeSettingValues | undefined;
142
+ return guaranteeIsString(
143
+ persistedValues?.[
144
+ LegendDataCubeSettingKey.DEBUGGER__ENGINE_SERVER_CLIENT__BASE_URL
145
+ ] ??
146
+ this.dataCubeSettings.find(
147
+ (configuration) =>
148
+ configuration.key ===
149
+ LegendDataCubeSettingKey.DEBUGGER__ENGINE_SERVER_CLIENT__BASE_URL,
150
+ )?.defaultValue,
151
+ );
152
+ }
153
+
154
+ async initialize() {
155
+ this.initializeState.inProgress();
156
+
157
+ try {
158
+ this.application.identityService.setCurrentUser(
159
+ await this.engineServerClient.getCurrentUserId(),
160
+ );
161
+ this.application.telemetryService.setup();
162
+ } catch (error) {
163
+ assertErrorThrown(error);
164
+ this.application.logService.error(
165
+ LogEvent.create(APPLICATION_EVENT.IDENTITY_AUTO_FETCH__FAILURE),
166
+ error,
167
+ );
168
+ }
169
+
170
+ try {
171
+ this.gridClientLicense = AG_GRID_LICENSE;
172
+
173
+ await this.graphManager.initialize(
174
+ {
175
+ env: this.application.config.env,
176
+ tabSize: DEFAULT_TAB_SIZE,
177
+ clientConfig: {
178
+ baseUrl: this.getEngineServerBaseUrlSettingValue(),
179
+ queryBaseUrl: this.application.config.engineQueryServerUrl,
180
+ enableCompression: this.getEngineEnableCompressionSettingValue(),
181
+ },
182
+ },
183
+ {
184
+ tracerService: this.application.tracerService,
185
+ },
186
+ );
187
+ this.initializeState.pass();
188
+ } catch (error) {
189
+ assertErrorThrown(error);
190
+ this.application.logService.error(
191
+ LogEvent.create(APPLICATION_EVENT.APPLICATION_LOAD__FAILURE),
192
+ `Can't initialize Legend DataCube`,
193
+ error,
194
+ );
195
+ this.initializeState.fail();
196
+ }
197
+ }
198
+ }