@finos/legend-application-data-cube 0.1.6 → 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
@@ -1,62 +0,0 @@
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 { QueryLoader } from '@finos/legend-query-builder';
19
- import type { SavedQueryInputSourceState } from '../../stores/source/SavedQueryInputSourceState.js';
20
- import { generateGAVCoordinates } from '@finos/legend-storage';
21
-
22
- export const SavedQuerySourceEditor = observer(
23
- (props: { savedQueryInputSourceState: SavedQueryInputSourceState }) => {
24
- const { savedQueryInputSourceState } = props;
25
- const savedQuery = savedQueryInputSourceState.query;
26
-
27
- return (
28
- <div>
29
- {savedQuery ? (
30
- <div className="p-3">
31
- <div className="text-l font-bold">Saved Query</div>
32
- <div>
33
- <div className="flex pt-px">
34
- <div className="font-bold">Name:</div>
35
- <div>{savedQuery.name}</div>
36
- </div>
37
- <div className="flex pt-px">
38
- <div className="font-bold">Project:</div>
39
- <div>
40
- {generateGAVCoordinates(
41
- savedQuery.groupId,
42
- savedQuery.artifactId,
43
- savedQuery.versionId,
44
- )}
45
- </div>
46
- </div>
47
- <div className="flex pt-px">
48
- <div className="font-bold">Owner:</div>
49
- <div>{savedQuery.owner}</div>
50
- </div>
51
- </div>
52
- </div>
53
- ) : (
54
- <QueryLoader
55
- queryLoaderState={savedQueryInputSourceState.queryLoaderState}
56
- loadActionLabel={'Open'}
57
- />
58
- )}
59
- </div>
60
- );
61
- },
62
- );
@@ -1,237 +0,0 @@
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
- DEFAULT_TAB_SIZE,
19
- type ApplicationStore,
20
- } from '@finos/legend-application';
21
- import type { LegendDataCubePluginManager } from '../application/LegendDataCubePluginManager.js';
22
- import { DepotServerClient, resolveVersion } from '@finos/legend-server-depot';
23
- import type { LegendDataCubeApplicationConfig } from '../application/LegendDataCubeApplicationConfig.js';
24
- import {
25
- GraphManagerState,
26
- LegendSDLC,
27
- PersistentDataCubeQuery,
28
- type QueryInfo,
29
- type RawLambda,
30
- } from '@finos/legend-graph';
31
- import { LegendDataCubeSourceBuilder } from './source/LegendDataCubeSourceBuilder.js';
32
- import {
33
- ActionState,
34
- UnsupportedOperationError,
35
- assertErrorThrown,
36
- guaranteeNonNullable,
37
- uuid,
38
- type GeneratorFn,
39
- } from '@finos/legend-shared';
40
- import { action, flow, flowResult, makeObservable, observable } from 'mobx';
41
- import { LegendCubeViewer } from './source/LegendCubeViewer.js';
42
- import type { DataCubeEngine } from '@finos/legend-data-cube';
43
- import type { DataCubeGenericSource } from './model/DataCubeGenericSource.js';
44
- import {
45
- createQueryBuilderContent,
46
- deserializeDataCubeQueryConent,
47
- serializeDataCubeQueryConent,
48
- } from './model/DataCubeGenericSourceHelper.js';
49
- import { LegendSavedQuerySource } from './model/LegendSavedQuerySource.js';
50
- import { LegendExecutionDataCubeEngine } from './engine/LegendExecutionDataCubeEngine.js';
51
- import { generatedSavedQueryUrl } from '../__lib__/LegendDataCubeNavigation.js';
52
-
53
- export type LegendDataCubeApplicationStore = ApplicationStore<
54
- LegendDataCubeApplicationConfig,
55
- LegendDataCubePluginManager
56
- >;
57
-
58
- export class LegendDataCubeStoreContext {
59
- readonly applicationStore: LegendDataCubeApplicationStore;
60
- readonly depotServerClient: DepotServerClient;
61
- readonly graphManagerState: GraphManagerState;
62
- initState = ActionState.create();
63
-
64
- constructor(applicationStore: LegendDataCubeApplicationStore) {
65
- makeObservable(this, {
66
- initialize: flow,
67
- initState: observable,
68
- });
69
- // server
70
- this.depotServerClient = new DepotServerClient({
71
- serverUrl: applicationStore.config.depotServerUrl,
72
- });
73
- this.depotServerClient.setTracerService(applicationStore.tracerService);
74
- this.graphManagerState = new GraphManagerState(
75
- applicationStore.pluginManager,
76
- applicationStore.logService,
77
- );
78
- this.applicationStore = applicationStore;
79
- }
80
-
81
- *initialize(): GeneratorFn<void> {
82
- if (!this.initState.isInInitialState) {
83
- return;
84
- }
85
-
86
- try {
87
- this.initState.inProgress();
88
- // TODO: when we genericize the way to initialize an application page
89
- this.applicationStore.assistantService.setIsHidden(true);
90
-
91
- // initialize the graph manager
92
- yield this.graphManagerState.graphManager.initialize(
93
- {
94
- env: this.applicationStore.config.env,
95
- tabSize: DEFAULT_TAB_SIZE,
96
- clientConfig: {
97
- baseUrl: this.applicationStore.config.engineServerUrl,
98
- queryBaseUrl: this.applicationStore.config.engineQueryServerUrl,
99
- enableCompression: true,
100
- },
101
- },
102
- {
103
- tracerService: this.applicationStore.tracerService,
104
- },
105
- );
106
- this.initState.pass();
107
- } catch (error) {
108
- assertErrorThrown(error);
109
- this.applicationStore.notificationService.notifyError(error);
110
- this.initState.fail();
111
- }
112
- }
113
- }
114
-
115
- export class LegendDataCubeStore {
116
- readonly applicationStore: LegendDataCubeApplicationStore;
117
- readonly context: LegendDataCubeStoreContext;
118
- readonly pluginManager: LegendDataCubePluginManager;
119
-
120
- sourceSelector: LegendDataCubeSourceBuilder;
121
- cubeViewer: LegendCubeViewer | undefined;
122
- saveModal = false;
123
- saveModalState = ActionState.create();
124
- savedQuery: PersistentDataCubeQuery | undefined;
125
-
126
- constructor(applicationStore: LegendDataCubeApplicationStore) {
127
- makeObservable(this, {
128
- cubeViewer: observable,
129
- sourceSelector: observable,
130
- saveModal: observable,
131
- setSaveModal: observable,
132
- saveModalState: observable,
133
- savedQuery: observable,
134
- initializeView: action,
135
- initialize: flow,
136
- saveQuery: flow,
137
- });
138
- this.applicationStore = applicationStore;
139
- this.pluginManager = applicationStore.pluginManager;
140
- this.context = new LegendDataCubeStoreContext(applicationStore);
141
- this.sourceSelector = new LegendDataCubeSourceBuilder(this.context);
142
- }
143
-
144
- setSaveModal(val: boolean): void {
145
- this.saveModal = val;
146
- }
147
-
148
- initializeView(source: DataCubeGenericSource, engine: DataCubeEngine): void {
149
- this.cubeViewer = new LegendCubeViewer(source, engine);
150
- }
151
-
152
- *initialize(id: string): GeneratorFn<void> {
153
- try {
154
- yield flowResult(this.context.initialize());
155
- const query =
156
- (yield this.context.graphManagerState.graphManager.getDataCubeQuery(
157
- id,
158
- )) as unknown as PersistentDataCubeQuery;
159
- this.savedQuery = query;
160
- const source = deserializeDataCubeQueryConent(query.content).source;
161
- if (source instanceof LegendSavedQuerySource) {
162
- const queryInfo =
163
- (yield this.context.graphManagerState.graphManager.getQueryInfo(
164
- source.id,
165
- )) as unknown as QueryInfo;
166
- const execConext =
167
- (yield this.context.graphManagerState.graphManager.resolveQueryInfoExecutionContext(
168
- queryInfo,
169
- () =>
170
- this.context.depotServerClient.getVersionEntities(
171
- queryInfo.groupId,
172
- queryInfo.artifactId,
173
- queryInfo.versionId,
174
- ),
175
- )) as { mapping: string | undefined; runtime: string };
176
- const lambda =
177
- (yield this.context.graphManagerState.graphManager.pureCodeToLambda(
178
- queryInfo.content,
179
- )) as unknown as RawLambda;
180
- this.context.graphManagerState.graph.setOrigin(
181
- new LegendSDLC(
182
- queryInfo.groupId,
183
- queryInfo.artifactId,
184
- resolveVersion(queryInfo.versionId),
185
- ),
186
- );
187
- // TODO: we should be able to call engine and convert lambda to relation if not one.
188
- const engine = new LegendExecutionDataCubeEngine(
189
- lambda,
190
- undefined,
191
- execConext.mapping,
192
- execConext.runtime,
193
- this.context.graphManagerState,
194
- );
195
- this.initializeView(source, engine);
196
- } else {
197
- throw new UnsupportedOperationError('not supported');
198
- }
199
- } catch (error) {
200
- assertErrorThrown(error);
201
- this.applicationStore.notificationService.notifyError(
202
- `Unable to initialie query with id '${id}'`,
203
- );
204
- }
205
- }
206
-
207
- *saveQuery(name: string): GeneratorFn<void> {
208
- try {
209
- this.saveModalState.inProgress();
210
- const view = guaranteeNonNullable(this.cubeViewer);
211
- const content = serializeDataCubeQueryConent(
212
- createQueryBuilderContent(view.source),
213
- );
214
- const cubeQuery = new PersistentDataCubeQuery();
215
- cubeQuery.content = content;
216
- cubeQuery.name = name;
217
- cubeQuery.id = uuid();
218
- const querySaved =
219
- (yield this.context.graphManagerState.graphManager.createQueryDataCube(
220
- cubeQuery,
221
- )) as unknown as PersistentDataCubeQuery;
222
- this.savedQuery = querySaved;
223
- // TODO: fix reload
224
- this.applicationStore.navigationService.navigator.goToLocation(
225
- generatedSavedQueryUrl(querySaved.id),
226
- );
227
- this.setSaveModal(false);
228
- this.saveModalState.complete();
229
- } catch (error) {
230
- assertErrorThrown(error);
231
- this.saveModalState.fail();
232
- this.applicationStore.notificationService.notifyError(
233
- `Unable to save query`,
234
- );
235
- }
236
- }
237
- }
@@ -1,267 +0,0 @@
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
- SUPPORTED_FUNCTIONS,
19
- V1_AppliedFunction,
20
- V1_Lambda,
21
- RawLambda,
22
- RelationalExecutionActivities,
23
- TDSExecutionResult,
24
- V1_deserializeRawValueSpecification,
25
- V1_deserializeValueSpecification,
26
- V1_RawLambda,
27
- V1_serializeValueSpecification,
28
- type GraphManagerState,
29
- type PureModel,
30
- type V1_ValueSpecification,
31
- type ParameterValue,
32
- } from '@finos/legend-graph';
33
- import {
34
- _elementPtr,
35
- _functionName,
36
- DataCubeEngine,
37
- DataCubeSource,
38
- type RelationType,
39
- DataCubeQuery,
40
- type CompletionItem,
41
- _function,
42
- DataCubeFunction,
43
- } from '@finos/legend-data-cube';
44
- import {
45
- guaranteeType,
46
- isNonNullable,
47
- LogService,
48
- type PlainObject,
49
- } from '@finos/legend-shared';
50
-
51
- class QueryBuilderDataCubeSource extends DataCubeSource {
52
- mapping?: string | undefined;
53
- runtime!: string;
54
- }
55
-
56
- export class LegendExecutionDataCubeEngine extends DataCubeEngine {
57
- readonly logService = new LogService();
58
- readonly graphState: GraphManagerState;
59
- readonly selectInitialQuery: RawLambda;
60
- readonly mappingPath: string | undefined;
61
- readonly parameterValues: ParameterValue[] | undefined;
62
- readonly runtimePath: string;
63
- _parameters: object | undefined;
64
-
65
- constructor(
66
- selectQuery: RawLambda,
67
- parameterValues: ParameterValue[] | undefined,
68
- mappingPath: string | undefined,
69
- runtimePath: string,
70
- graphManagerState: GraphManagerState,
71
- ) {
72
- super();
73
- this.graphState = graphManagerState;
74
- this.selectInitialQuery = selectQuery;
75
- this.mappingPath = mappingPath;
76
- this.runtimePath = runtimePath;
77
- this.parameterValues = parameterValues;
78
- }
79
-
80
- get sourceLabel(): string {
81
- return `Query Builder Report`;
82
- }
83
-
84
- get graph(): PureModel {
85
- return this.graphState.graph;
86
- }
87
-
88
- private getSourceFunctionExpression() {
89
- let srcFuncExp = V1_deserializeValueSpecification(
90
- this.graphState.graphManager.serializeRawValueSpecification(
91
- this.selectInitialQuery,
92
- ),
93
- [],
94
- );
95
- // We could do a further check here to ensure the experssion is an applied funciton
96
- // this is because data cube expects an expression to be able to built further upon the queery
97
- if (
98
- srcFuncExp instanceof V1_Lambda &&
99
- srcFuncExp.body.length === 1 &&
100
- srcFuncExp.body[0]
101
- ) {
102
- srcFuncExp = srcFuncExp.body[0];
103
- }
104
- return srcFuncExp;
105
- }
106
-
107
- async getBaseQuery() {
108
- const srcFuncExp = this.getSourceFunctionExpression();
109
- this._parameters = this.selectInitialQuery.parameters;
110
- const fromFuncExp = new V1_AppliedFunction();
111
- fromFuncExp.function = _functionName(SUPPORTED_FUNCTIONS.FROM);
112
- fromFuncExp.parameters = [srcFuncExp];
113
- if (this.mappingPath) {
114
- fromFuncExp.parameters.push(_elementPtr(this.mappingPath));
115
- }
116
- if (this.runtimePath) {
117
- fromFuncExp.parameters.push(_elementPtr(this.runtimePath));
118
- }
119
- const columns = (await this.getRelationalType(this.selectInitialQuery))
120
- .columns;
121
- const query = new DataCubeQuery();
122
- query.query = `~[${columns.map((e) => `'${e.name}'`)}]->select()`;
123
-
124
- return query;
125
- }
126
-
127
- async processQuerySource(value: PlainObject) {
128
- const srcFuncExp = this.getSourceFunctionExpression();
129
- const columns = (await this.getRelationalType(this.selectInitialQuery))
130
- .columns;
131
- const source = new QueryBuilderDataCubeSource();
132
- source.sourceColumns = columns;
133
- source.mapping = this.mappingPath;
134
- source.runtime = this.runtimePath;
135
- source.query = srcFuncExp;
136
- return source;
137
- }
138
-
139
- private buildRawLambdaFromValueSpec(query: V1_Lambda): RawLambda {
140
- const json = guaranteeType(
141
- V1_deserializeRawValueSpecification(
142
- V1_serializeValueSpecification(query, []),
143
- ),
144
- V1_RawLambda,
145
- );
146
- return new RawLambda(json.parameters, json.body);
147
- }
148
-
149
- async getQueryTypeahead(
150
- code: string,
151
- baseQuery: V1_Lambda,
152
- source: DataCubeSource,
153
- ) {
154
- const lambda = this.buildRawLambdaFromValueSpec(baseQuery);
155
- const queryString =
156
- await this.graphState.graphManager.lambdaToPureCode(lambda);
157
- let codeBlock = queryString + code;
158
- if (codeBlock[0] === '|') {
159
- codeBlock = codeBlock.substring(1);
160
- }
161
- const result = await this.graphState.graphManager.getCodeComplete(
162
- codeBlock,
163
- this.graph,
164
- undefined,
165
- );
166
- return result.completions as CompletionItem[];
167
- }
168
-
169
- async parseValueSpecification(
170
- code: string,
171
- returnSourceInformation?: boolean,
172
- ) {
173
- return V1_deserializeValueSpecification(
174
- await this.graphState.graphManager.pureCodeToValueSpecification(
175
- code,
176
- returnSourceInformation,
177
- ),
178
- [],
179
- );
180
- }
181
-
182
- async getValueSpecificationCode(
183
- value: V1_ValueSpecification,
184
- pretty?: boolean | undefined,
185
- ) {
186
- return this.graphState.graphManager.valueSpecificationToPureCode(
187
- V1_serializeValueSpecification(value, []),
188
- pretty,
189
- );
190
- }
191
-
192
- private async getRelationalType(query: RawLambda): Promise<RelationType> {
193
- const relationType =
194
- await this.graphState.graphManager.getLambdaRelationType(
195
- query,
196
- this.graph,
197
- );
198
- return relationType;
199
- }
200
-
201
- async getQueryRelationType(query: V1_Lambda, source: DataCubeSource) {
202
- const lambda = this.buildRawLambdaFromValueSpec(query);
203
- return this.getRelationalType(lambda);
204
- }
205
-
206
- async getQueryCodeRelationReturnType(
207
- code: string,
208
- baseQuery: V1_ValueSpecification,
209
- source: DataCubeSource,
210
- ) {
211
- const queryString =
212
- await this.graphState.graphManager.valueSpecificationToPureCode(
213
- V1_serializeValueSpecification(baseQuery, []),
214
- );
215
- const fullQuery = queryString + code;
216
- return this.getRelationalType(
217
- await this.graphState.graphManager.pureCodeToLambda(fullQuery),
218
- );
219
- }
220
-
221
- async executeQuery(query: V1_Lambda, source: DataCubeSource) {
222
- const lambda = this.buildRawLambdaFromValueSpec(query);
223
- lambda.parameters = this._parameters;
224
- const [executionWithMetadata, queryString] = await Promise.all([
225
- this.graphState.graphManager.runQuery(
226
- lambda,
227
- undefined,
228
- undefined,
229
- this.graph,
230
- {
231
- parameterValues: this.parameterValues ?? [],
232
- },
233
- ),
234
- this.graphState.graphManager.lambdaToPureCode(lambda),
235
- ]);
236
- const expectedTDS = guaranteeType(
237
- executionWithMetadata.executionResult,
238
- TDSExecutionResult,
239
- 'Query returned expected to be of tabular data set',
240
- );
241
- const sql = expectedTDS.activities?.[0];
242
- let sqlString = '### NO SQL FOUND';
243
- if (sql instanceof RelationalExecutionActivities) {
244
- sqlString = sql.sql;
245
- }
246
- return {
247
- result: expectedTDS,
248
- executedQuery: queryString,
249
- executedSQL: sqlString,
250
- };
251
- }
252
-
253
- buildExecutionContext(
254
- source: DataCubeSource,
255
- ): V1_AppliedFunction | undefined {
256
- if (source instanceof QueryBuilderDataCubeSource) {
257
- return _function(
258
- DataCubeFunction.FROM,
259
- [
260
- source.mapping ? _elementPtr(source.mapping) : undefined,
261
- _elementPtr(source.runtime),
262
- ].filter(isNonNullable),
263
- );
264
- }
265
- return undefined;
266
- }
267
- }
@@ -1,97 +0,0 @@
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
- UnsupportedOperationError,
19
- optionalCustom,
20
- usingConstantValueSchema,
21
- type PlainObject,
22
- } from '@finos/legend-shared';
23
- import type { DataCubeGenericSource } from './DataCubeGenericSource.js';
24
- import { LegendSavedQuerySource } from './LegendSavedQuerySource.js';
25
- import {
26
- createModelSchema,
27
- primitive,
28
- deserialize,
29
- serialize,
30
- optional,
31
- raw,
32
- } from 'serializr';
33
- import { DataCubeQueryConent } from './DataCubeQueryContent.js';
34
-
35
- enum SavedDataCubeQueryType {
36
- LEGEND_QUERY = 'LegendQuery',
37
- }
38
-
39
- export const legendSavedQuerySourceModelSchema = createModelSchema(
40
- LegendSavedQuerySource,
41
- {
42
- _type: usingConstantValueSchema(SavedDataCubeQueryType.LEGEND_QUERY),
43
- id: primitive(),
44
- },
45
- );
46
-
47
- const deserializeDataCubeGenericSource = (
48
- content: PlainObject<object>,
49
- ): DataCubeGenericSource => {
50
- switch (content._type) {
51
- case SavedDataCubeQueryType.LEGEND_QUERY:
52
- return deserialize(legendSavedQuerySourceModelSchema, content);
53
- default:
54
- }
55
- throw new UnsupportedOperationError(
56
- `Can't de serialize saved data cube`,
57
- content._type,
58
- );
59
- };
60
-
61
- const serializeDataCubeGenericSource = (
62
- genericSource: DataCubeGenericSource,
63
- ): PlainObject<DataCubeGenericSource> => {
64
- if (genericSource instanceof LegendSavedQuerySource) {
65
- return serialize(legendSavedQuerySourceModelSchema, genericSource);
66
- }
67
- throw new UnsupportedOperationError(`Can't serialize saved data cube`);
68
- };
69
-
70
- const dataCubeQueryConentModelSchema = createModelSchema(DataCubeQueryConent, {
71
- query: optional(primitive()),
72
- configuration: optional(raw()),
73
- source: optionalCustom(
74
- (val) => serializeDataCubeGenericSource(val),
75
- (val) => deserializeDataCubeGenericSource(val),
76
- ),
77
- });
78
-
79
- export const createQueryBuilderContent = (
80
- source: DataCubeGenericSource,
81
- ): DataCubeQueryConent => {
82
- const content = new DataCubeQueryConent();
83
- content.source = source;
84
- return content;
85
- };
86
-
87
- export const serializeDataCubeQueryConent = (
88
- content: DataCubeQueryConent,
89
- ): PlainObject<DataCubeQueryConent> => {
90
- return serialize(dataCubeQueryConentModelSchema, content);
91
- };
92
-
93
- export const deserializeDataCubeQueryConent = (
94
- content: PlainObject<DataCubeQueryConent>,
95
- ): DataCubeQueryConent => {
96
- return deserialize(dataCubeQueryConentModelSchema, content);
97
- };
@@ -1,26 +0,0 @@
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 { DataCubeGenericSource } from './DataCubeGenericSource.js';
18
-
19
- export class LegendSavedQuerySource extends DataCubeGenericSource {
20
- id: string;
21
-
22
- constructor(id: string) {
23
- super();
24
- this.id = id;
25
- }
26
- }