@finos/legend-application-data-cube 0.1.6 → 0.1.8
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/__lib__/LegendDataCubeNavigation.d.ts +5 -5
- package/lib/__lib__/LegendDataCubeNavigation.d.ts.map +1 -1
- package/lib/__lib__/LegendDataCubeNavigation.js +5 -5
- package/lib/__lib__/LegendDataCubeNavigation.js.map +1 -1
- package/lib/{stores/source/CubeInputSource.js → __lib__/LegendDataCubeSetting.d.ts} +6 -14
- package/lib/__lib__/LegendDataCubeSetting.d.ts.map +1 -0
- package/lib/__lib__/LegendDataCubeSetting.js +25 -0
- package/lib/__lib__/LegendDataCubeSetting.js.map +1 -0
- package/lib/{stores/model/DataCubeQueryContent.js → __lib__/LegendDataCubeUserData.d.ts} +4 -5
- package/lib/__lib__/LegendDataCubeUserData.d.ts.map +1 -0
- package/lib/__lib__/LegendDataCubeUserData.js +21 -0
- package/lib/__lib__/LegendDataCubeUserData.js.map +1 -0
- package/lib/application/LegendDataCube.d.ts.map +1 -1
- package/lib/application/LegendDataCube.js.map +1 -1
- package/lib/application/LegendDataCubeApplicationConfig.d.ts +1 -1
- package/lib/application/LegendDataCubeApplicationConfig.d.ts.map +1 -1
- package/lib/application/LegendDataCubeApplicationConfig.js +3 -1
- package/lib/application/LegendDataCubeApplicationConfig.js.map +1 -1
- package/lib/application/LegendDataCubePluginManager.d.ts.map +1 -1
- package/lib/application/LegendDataCubePluginManager.js.map +1 -1
- package/lib/components/LegendDataCubeFrameworkProvider.d.ts +2 -2
- package/lib/components/LegendDataCubeFrameworkProvider.d.ts.map +1 -1
- package/lib/components/LegendDataCubeFrameworkProvider.js +5 -5
- package/lib/components/LegendDataCubeFrameworkProvider.js.map +1 -1
- package/lib/components/LegendDataCubeWebApplication.d.ts.map +1 -1
- package/lib/components/LegendDataCubeWebApplication.js +25 -6
- package/lib/components/LegendDataCubeWebApplication.js.map +1 -1
- package/lib/{stores/model/DataCubeGenericSource.d.ts → components/query-builder/LegendDataCubeNewQueryBuilder.d.ts} +4 -3
- package/lib/components/query-builder/LegendDataCubeNewQueryBuilder.d.ts.map +1 -0
- package/lib/components/query-builder/LegendDataCubeNewQueryBuilder.js +46 -0
- package/lib/components/query-builder/LegendDataCubeNewQueryBuilder.js.map +1 -0
- package/{src/stores/model/DataCubeGenericSource.ts → lib/components/query-builder/LegendDataCubeQueryBuilder.d.ts} +2 -2
- package/lib/components/query-builder/LegendDataCubeQueryBuilder.d.ts.map +1 -0
- package/lib/components/query-builder/LegendDataCubeQueryBuilder.js +79 -0
- package/lib/components/query-builder/LegendDataCubeQueryBuilder.js.map +1 -0
- package/lib/components/query-builder/LegendDataCubeQueryBuilderStoreProvider.d.ts +19 -0
- package/lib/components/query-builder/LegendDataCubeQueryBuilderStoreProvider.d.ts.map +1 -0
- package/lib/components/query-builder/LegendDataCubeQueryBuilderStoreProvider.js +33 -0
- package/lib/components/query-builder/LegendDataCubeQueryBuilderStoreProvider.js.map +1 -0
- package/lib/components/{source/ExistingDataCubeQuery.d.ts → query-builder/LegendDataCubeQueryLoader.d.ts} +2 -2
- package/lib/components/query-builder/LegendDataCubeQueryLoader.d.ts.map +1 -0
- package/lib/components/query-builder/LegendDataCubeQueryLoader.js +97 -0
- package/lib/components/query-builder/LegendDataCubeQueryLoader.js.map +1 -0
- package/lib/components/{DataCubeEditor.d.ts → query-builder/LegendDataCubeQuerySaver.d.ts} +2 -2
- package/lib/components/query-builder/LegendDataCubeQuerySaver.d.ts.map +1 -0
- package/lib/components/query-builder/LegendDataCubeQuerySaver.js +49 -0
- package/lib/components/query-builder/LegendDataCubeQuerySaver.js.map +1 -0
- package/lib/components/{source/DataCubeSourceEditor.d.ts → query-builder/source-builder/AdhocQueryDataCubeSourceBuilder.d.ts} +4 -4
- package/lib/components/query-builder/source-builder/AdhocQueryDataCubeSourceBuilder.d.ts.map +1 -0
- package/lib/components/query-builder/source-builder/AdhocQueryDataCubeSourceBuilder.js +22 -0
- package/lib/components/query-builder/source-builder/AdhocQueryDataCubeSourceBuilder.js.map +1 -0
- package/lib/components/{source/SavedQuerySourceEditor.d.ts → query-builder/source-builder/LegendQueryDataCubeSourceBuilder.d.ts} +4 -4
- package/lib/components/query-builder/source-builder/LegendQueryDataCubeSourceBuilder.d.ts.map +1 -0
- package/lib/components/query-builder/source-builder/LegendQueryDataCubeSourceBuilder.js +97 -0
- package/lib/components/query-builder/source-builder/LegendQueryDataCubeSourceBuilder.js.map +1 -0
- package/lib/index.css +2 -2
- package/lib/index.css.map +1 -1
- package/lib/package.json +2 -2
- package/lib/stores/LegendDataCubeBaseStore.d.ts +43 -0
- package/lib/stores/LegendDataCubeBaseStore.d.ts.map +1 -0
- package/lib/stores/LegendDataCubeBaseStore.js +130 -0
- package/lib/stores/LegendDataCubeBaseStore.js.map +1 -0
- package/lib/stores/LegendDataCubeDataCubeEngine.d.ts +57 -0
- package/lib/stores/LegendDataCubeDataCubeEngine.d.ts.map +1 -0
- package/lib/stores/LegendDataCubeDataCubeEngine.js +250 -0
- package/lib/stores/LegendDataCubeDataCubeEngine.js.map +1 -0
- package/lib/stores/model/LegendQueryDataCubeSource.d.ts +32 -0
- package/lib/stores/model/LegendQueryDataCubeSource.d.ts.map +1 -0
- package/lib/stores/model/LegendQueryDataCubeSource.js +35 -0
- package/lib/stores/model/LegendQueryDataCubeSource.js.map +1 -0
- package/lib/stores/query-builder/LegendDataCubeNewQueryState.d.ts +33 -0
- package/lib/stores/query-builder/LegendDataCubeNewQueryState.d.ts.map +1 -0
- package/lib/stores/query-builder/LegendDataCubeNewQueryState.js +94 -0
- package/lib/stores/query-builder/LegendDataCubeNewQueryState.js.map +1 -0
- package/lib/stores/query-builder/LegendDataCubeQueryBuilderStore.d.ts +59 -0
- package/lib/stores/query-builder/LegendDataCubeQueryBuilderStore.d.ts.map +1 -0
- package/lib/stores/query-builder/LegendDataCubeQueryBuilderStore.js +219 -0
- package/lib/stores/query-builder/LegendDataCubeQueryBuilderStore.js.map +1 -0
- package/lib/stores/query-builder/LegendDataCubeQueryLoaderState.d.ts +53 -0
- package/lib/stores/query-builder/LegendDataCubeQueryLoaderState.d.ts.map +1 -0
- package/lib/stores/query-builder/LegendDataCubeQueryLoaderState.js +198 -0
- package/lib/stores/query-builder/LegendDataCubeQueryLoaderState.js.map +1 -0
- package/lib/stores/{model/DataCubeQueryContent.d.ts → query-builder/source-builder/AdhocQueryDataCubeSourceBuilderState.d.ts} +7 -7
- package/lib/stores/query-builder/source-builder/AdhocQueryDataCubeSourceBuilderState.d.ts.map +1 -0
- package/lib/stores/{model/LegendSavedQuerySource.js → query-builder/source-builder/AdhocQueryDataCubeSourceBuilderState.js} +12 -7
- package/lib/stores/query-builder/source-builder/AdhocQueryDataCubeSourceBuilderState.js.map +1 -0
- package/lib/stores/query-builder/source-builder/LegendDataCubeSourceBuilderState.d.ts +32 -0
- package/lib/stores/query-builder/source-builder/LegendDataCubeSourceBuilderState.d.ts.map +1 -0
- package/lib/stores/query-builder/source-builder/LegendDataCubeSourceBuilderState.js +31 -0
- package/lib/stores/query-builder/source-builder/LegendDataCubeSourceBuilderState.js.map +1 -0
- package/lib/stores/query-builder/source-builder/LegendQueryDataCubeSourceBuilderState.d.ts +36 -0
- package/lib/stores/query-builder/source-builder/LegendQueryDataCubeSourceBuilderState.d.ts.map +1 -0
- package/lib/stores/query-builder/source-builder/LegendQueryDataCubeSourceBuilderState.js +90 -0
- package/lib/stores/query-builder/source-builder/LegendQueryDataCubeSourceBuilderState.js.map +1 -0
- package/package.json +11 -11
- package/src/__lib__/LegendDataCubeNavigation.ts +7 -7
- package/src/{stores/model/DataCubeQueryContent.ts → __lib__/LegendDataCubeSetting.ts} +6 -6
- package/{lib/stores/model/DataCubeGenericSource.js → src/__lib__/LegendDataCubeUserData.ts} +5 -2
- package/src/application/LegendDataCube.tsx +1 -0
- package/src/application/LegendDataCubeApplicationConfig.ts +6 -4
- package/src/application/LegendDataCubePluginManager.ts +1 -0
- package/src/components/LegendDataCubeFrameworkProvider.tsx +7 -7
- package/src/components/LegendDataCubeWebApplication.tsx +48 -12
- package/src/components/query-builder/LegendDataCubeNewQueryBuilder.tsx +112 -0
- package/src/components/query-builder/LegendDataCubeQueryBuilder.tsx +148 -0
- package/src/components/query-builder/LegendDataCubeQueryBuilderStoreProvider.tsx +56 -0
- package/src/components/query-builder/LegendDataCubeQueryLoader.tsx +309 -0
- package/src/components/query-builder/LegendDataCubeQuerySaver.tsx +112 -0
- package/src/{stores/source/CubeInputSource.ts → components/query-builder/source-builder/AdhocQueryDataCubeSourceBuilder.tsx} +14 -19
- package/src/components/query-builder/source-builder/LegendQueryDataCubeSourceBuilder.tsx +315 -0
- package/src/stores/LegendDataCubeBaseStore.ts +217 -0
- package/src/stores/LegendDataCubeDataCubeEngine.ts +489 -0
- package/src/stores/model/LegendQueryDataCubeSource.ts +46 -0
- package/src/stores/query-builder/LegendDataCubeNewQueryState.tsx +153 -0
- package/src/stores/query-builder/LegendDataCubeQueryBuilderStore.tsx +307 -0
- package/src/stores/query-builder/LegendDataCubeQueryLoaderState.tsx +260 -0
- package/src/stores/{source/LegendCubeViewer.ts → query-builder/source-builder/AdhocQueryDataCubeSourceBuilderState.ts} +15 -8
- package/src/stores/query-builder/source-builder/LegendDataCubeSourceBuilderState.ts +43 -0
- package/src/stores/query-builder/source-builder/LegendQueryDataCubeSourceBuilderState.ts +143 -0
- package/tsconfig.json +18 -15
- package/lib/components/DataCubeEditor.d.ts.map +0 -1
- package/lib/components/DataCubeEditor.js +0 -59
- package/lib/components/DataCubeEditor.js.map +0 -1
- package/lib/components/source/DataCubeSourceEditor.d.ts.map +0 -1
- package/lib/components/source/DataCubeSourceEditor.js +0 -43
- package/lib/components/source/DataCubeSourceEditor.js.map +0 -1
- package/lib/components/source/ExistingDataCubeQuery.d.ts.map +0 -1
- package/lib/components/source/ExistingDataCubeQuery.js +0 -36
- package/lib/components/source/ExistingDataCubeQuery.js.map +0 -1
- package/lib/components/source/SavedQuerySourceEditor.d.ts.map +0 -1
- package/lib/components/source/SavedQuerySourceEditor.js +0 -25
- package/lib/components/source/SavedQuerySourceEditor.js.map +0 -1
- package/lib/stores/LegendDataCubeEditorStore.d.ts +0 -50
- package/lib/stores/LegendDataCubeEditorStore.d.ts.map +0 -1
- package/lib/stores/LegendDataCubeEditorStore.js +0 -153
- package/lib/stores/LegendDataCubeEditorStore.js.map +0 -1
- package/lib/stores/engine/LegendExecutionDataCubeEngine.d.ts +0 -52
- package/lib/stores/engine/LegendExecutionDataCubeEngine.d.ts.map +0 -1
- package/lib/stores/engine/LegendExecutionDataCubeEngine.js +0 -149
- package/lib/stores/engine/LegendExecutionDataCubeEngine.js.map +0 -1
- package/lib/stores/model/DataCubeGenericSource.d.ts.map +0 -1
- package/lib/stores/model/DataCubeGenericSource.js.map +0 -1
- package/lib/stores/model/DataCubeGenericSourceHelper.d.ts +0 -24
- package/lib/stores/model/DataCubeGenericSourceHelper.d.ts.map +0 -1
- package/lib/stores/model/DataCubeGenericSourceHelper.js +0 -58
- package/lib/stores/model/DataCubeGenericSourceHelper.js.map +0 -1
- package/lib/stores/model/DataCubeQueryContent.d.ts.map +0 -1
- package/lib/stores/model/DataCubeQueryContent.js.map +0 -1
- package/lib/stores/model/LegendSavedQuerySource.d.ts +0 -21
- package/lib/stores/model/LegendSavedQuerySource.d.ts.map +0 -1
- package/lib/stores/model/LegendSavedQuerySource.js.map +0 -1
- package/lib/stores/source/CubeInputSource.d.ts +0 -32
- package/lib/stores/source/CubeInputSource.d.ts.map +0 -1
- package/lib/stores/source/CubeInputSource.js.map +0 -1
- package/lib/stores/source/CubeInputSourceLoader.d.ts +0 -37
- package/lib/stores/source/CubeInputSourceLoader.d.ts.map +0 -1
- package/lib/stores/source/CubeInputSourceLoader.js +0 -39
- package/lib/stores/source/CubeInputSourceLoader.js.map +0 -1
- package/lib/stores/source/LegendCubeViewer.d.ts +0 -23
- package/lib/stores/source/LegendCubeViewer.d.ts.map +0 -1
- package/lib/stores/source/LegendCubeViewer.js +0 -24
- package/lib/stores/source/LegendCubeViewer.js.map +0 -1
- package/lib/stores/source/LegendDataCubeSourceBuilder.d.ts +0 -34
- package/lib/stores/source/LegendDataCubeSourceBuilder.d.ts.map +0 -1
- package/lib/stores/source/LegendDataCubeSourceBuilder.js +0 -70
- package/lib/stores/source/LegendDataCubeSourceBuilder.js.map +0 -1
- package/lib/stores/source/SavedQueryInputSourceState.d.ts +0 -35
- package/lib/stores/source/SavedQueryInputSourceState.d.ts.map +0 -1
- package/lib/stores/source/SavedQueryInputSourceState.js +0 -81
- package/lib/stores/source/SavedQueryInputSourceState.js.map +0 -1
- package/src/components/DataCubeEditor.tsx +0 -190
- package/src/components/source/DataCubeSourceEditor.tsx +0 -133
- package/src/components/source/ExistingDataCubeQuery.tsx +0 -101
- package/src/components/source/SavedQuerySourceEditor.tsx +0 -62
- package/src/stores/LegendDataCubeEditorStore.ts +0 -237
- package/src/stores/engine/LegendExecutionDataCubeEngine.ts +0 -267
- package/src/stores/model/DataCubeGenericSourceHelper.ts +0 -97
- package/src/stores/model/LegendSavedQuerySource.ts +0 -26
- package/src/stores/source/CubeInputSourceLoader.ts +0 -56
- package/src/stores/source/LegendDataCubeSourceBuilder.ts +0 -98
- package/src/stores/source/SavedQueryInputSourceState.ts +0 -142
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
/**
|
|
3
|
+
* Copyright (c) 2020-present, Goldman Sachs
|
|
4
|
+
*
|
|
5
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
* you may not use this file except in compliance with the License.
|
|
7
|
+
* You may obtain a copy of the License at
|
|
8
|
+
*
|
|
9
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
*
|
|
11
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
* See the License for the specific language governing permissions and
|
|
15
|
+
* limitations under the License.
|
|
16
|
+
*/
|
|
17
|
+
import { action, makeObservable, observable } from 'mobx';
|
|
18
|
+
import { ActionState, assertErrorThrown, IllegalStateError, UnsupportedOperationError, } from '@finos/legend-shared';
|
|
19
|
+
import { LegendQueryDataCubeSourceBuilderState } from './source-builder/LegendQueryDataCubeSourceBuilderState.js';
|
|
20
|
+
import { LegendDataCubeSourceBuilderType, } from './source-builder/LegendDataCubeSourceBuilderState.js';
|
|
21
|
+
import { _selectFunction, DataCubeQuery, DEFAULT_TOOL_PANEL_WINDOW_CONFIG, } from '@finos/legend-data-cube';
|
|
22
|
+
import { LegendDataCubeNewQueryBuilder } from '../../components/query-builder/LegendDataCubeNewQueryBuilder.js';
|
|
23
|
+
import { AdhocQueryDataCubeSourceBuilderState } from './source-builder/AdhocQueryDataCubeSourceBuilderState.js';
|
|
24
|
+
import { LegendDataCubeQueryBuilderState, } from './LegendDataCubeQueryBuilderStore.js';
|
|
25
|
+
import { generateQueryBuilderRoute } from '../../__lib__/LegendDataCubeNavigation.js';
|
|
26
|
+
export class LegendDataCubeNewQueryState {
|
|
27
|
+
_application;
|
|
28
|
+
_store;
|
|
29
|
+
_engine;
|
|
30
|
+
_alertService;
|
|
31
|
+
finalizeState = ActionState.create();
|
|
32
|
+
display;
|
|
33
|
+
sourceBuilder;
|
|
34
|
+
constructor(store) {
|
|
35
|
+
makeObservable(this, {
|
|
36
|
+
sourceBuilder: observable,
|
|
37
|
+
changeSourceBuilder: action,
|
|
38
|
+
});
|
|
39
|
+
this._application = store.application;
|
|
40
|
+
this._store = store;
|
|
41
|
+
this._engine = store.engine;
|
|
42
|
+
this._alertService = store.alertService;
|
|
43
|
+
this.display = store.layoutService.newDisplay('New Query', () => _jsx(LegendDataCubeNewQueryBuilder, {}), {
|
|
44
|
+
...DEFAULT_TOOL_PANEL_WINDOW_CONFIG,
|
|
45
|
+
width: 500,
|
|
46
|
+
minWidth: 500,
|
|
47
|
+
});
|
|
48
|
+
this.sourceBuilder = this.createSourceBuilder(LegendDataCubeSourceBuilderType.LEGEND_QUERY);
|
|
49
|
+
}
|
|
50
|
+
changeSourceBuilder(type, skipCheck) {
|
|
51
|
+
if (this.sourceBuilder.label !== type || skipCheck) {
|
|
52
|
+
this.sourceBuilder = this.createSourceBuilder(type);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
createSourceBuilder(type) {
|
|
56
|
+
switch (type) {
|
|
57
|
+
case LegendDataCubeSourceBuilderType.LEGEND_QUERY:
|
|
58
|
+
return new LegendQueryDataCubeSourceBuilderState(this._application, this._engine, this._store.engineServerClient, this._store.graphManager, this._alertService);
|
|
59
|
+
case LegendDataCubeSourceBuilderType.ADHOC_QUERY:
|
|
60
|
+
return new AdhocQueryDataCubeSourceBuilderState(this._application, this._engine);
|
|
61
|
+
default:
|
|
62
|
+
throw new UnsupportedOperationError(`Can't create source builder for unsupported type '${type}'`);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
async finalize() {
|
|
66
|
+
if (!this.sourceBuilder.isValid) {
|
|
67
|
+
throw new IllegalStateError(`Can't generate query: source is not valid`);
|
|
68
|
+
}
|
|
69
|
+
this.finalizeState.inProgress();
|
|
70
|
+
try {
|
|
71
|
+
const source = await this.sourceBuilder.build();
|
|
72
|
+
const query = new DataCubeQuery();
|
|
73
|
+
const processedSource = await this._engine.processQuerySource(source);
|
|
74
|
+
query.source = source;
|
|
75
|
+
query.query = await this._engine.getValueSpecificationCode(_selectFunction(processedSource.columns));
|
|
76
|
+
this._store.setBuilder(new LegendDataCubeQueryBuilderState(query));
|
|
77
|
+
// only update the route instead of reloading in case we are creating
|
|
78
|
+
// a new query when we are editing another query
|
|
79
|
+
this._application.navigationService.navigator.updateCurrentLocation(generateQueryBuilderRoute(null));
|
|
80
|
+
// reset
|
|
81
|
+
this.changeSourceBuilder(LegendDataCubeSourceBuilderType.LEGEND_QUERY, true);
|
|
82
|
+
this.display.close();
|
|
83
|
+
this.finalizeState.pass();
|
|
84
|
+
}
|
|
85
|
+
catch (error) {
|
|
86
|
+
assertErrorThrown(error);
|
|
87
|
+
this._alertService.alertError(error, {
|
|
88
|
+
message: `Query Creation Failure: ${error.message}`,
|
|
89
|
+
});
|
|
90
|
+
this.finalizeState.fail();
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
//# sourceMappingURL=LegendDataCubeNewQueryState.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"LegendDataCubeNewQueryState.js","sourceRoot":"","sources":["../../../src/stores/query-builder/LegendDataCubeNewQueryState.tsx"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAAE,MAAM,EAAE,cAAc,EAAE,UAAU,EAAE,MAAM,MAAM,CAAC;AAC1D,OAAO,EACL,WAAW,EACX,iBAAiB,EACjB,iBAAiB,EACjB,yBAAyB,GAC1B,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,qCAAqC,EAAE,MAAM,2DAA2D,CAAC;AAElH,OAAO,EACL,+BAA+B,GAEhC,MAAM,sDAAsD,CAAC;AAC9D,OAAO,EACL,eAAe,EAEf,aAAa,EACb,gCAAgC,GAEjC,MAAM,yBAAyB,CAAC;AAEjC,OAAO,EAAE,6BAA6B,EAAE,MAAM,iEAAiE,CAAC;AAChH,OAAO,EAAE,oCAAoC,EAAE,MAAM,0DAA0D,CAAC;AAChH,OAAO,EACL,+BAA+B,GAEhC,MAAM,sCAAsC,CAAC;AAC9C,OAAO,EAAE,yBAAyB,EAAE,MAAM,2CAA2C,CAAC;AAEtF,MAAM,OAAO,2BAA2B;IACrB,YAAY,CAAiC;IAC7C,MAAM,CAAkC;IACxC,OAAO,CAA+B;IACtC,aAAa,CAAuB;IAE5C,aAAa,GAAG,WAAW,CAAC,MAAM,EAAE,CAAC;IACrC,OAAO,CAAe;IAE/B,aAAa,CAAmC;IAEhD,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EAAE;gBACnC,OAAO,EAAE,2BAA2B,KAAK,CAAC,OAAO,EAAE;aACpD,CAAC,CAAC;YACH,IAAI,CAAC,aAAa,CAAC,IAAI,EAAE,CAAC;QAC5B,CAAC;IACH,CAAC;CACF"}
|
|
@@ -0,0 +1,59 @@
|
|
|
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
|
+
import type { LegendDataCubeApplicationStore, LegendDataCubeBaseStore } from '../LegendDataCubeBaseStore.js';
|
|
17
|
+
import { type DataCubeAlertService, type DataCubeAPI, type DataCubeLayoutService, type DataCubeTaskService, DataCubeQuery, type DisplayState } from '@finos/legend-data-cube';
|
|
18
|
+
import { LegendDataCubeNewQueryState } from './LegendDataCubeNewQueryState.js';
|
|
19
|
+
import { PersistentDataCubeQuery, type V1_EngineServerClient, type V1_PureGraphManager } from '@finos/legend-graph';
|
|
20
|
+
import { ActionState } from '@finos/legend-shared';
|
|
21
|
+
import type { LegendDataCubeDataCubeEngine } from '../LegendDataCubeDataCubeEngine.js';
|
|
22
|
+
import { LegendDataCubeQueryLoaderState } from './LegendDataCubeQueryLoaderState.js';
|
|
23
|
+
import type { DepotServerClient } from '@finos/legend-server-depot';
|
|
24
|
+
export declare class LegendDataCubeQueryBuilderState {
|
|
25
|
+
uuid: string;
|
|
26
|
+
startTime: number;
|
|
27
|
+
query: DataCubeQuery;
|
|
28
|
+
persistentQuery?: PersistentDataCubeQuery | undefined;
|
|
29
|
+
dataCube?: DataCubeAPI | undefined;
|
|
30
|
+
constructor(query: DataCubeQuery, persistentQuery?: PersistentDataCubeQuery | undefined);
|
|
31
|
+
setDataCube(val: DataCubeAPI | undefined): void;
|
|
32
|
+
setPersistentQuery(val: PersistentDataCubeQuery): void;
|
|
33
|
+
}
|
|
34
|
+
export declare class LegendDataCubeQueryBuilderStore {
|
|
35
|
+
readonly application: LegendDataCubeApplicationStore;
|
|
36
|
+
readonly baseStore: LegendDataCubeBaseStore;
|
|
37
|
+
readonly engine: LegendDataCubeDataCubeEngine;
|
|
38
|
+
readonly depotServerClient: DepotServerClient;
|
|
39
|
+
readonly engineServerClient: V1_EngineServerClient;
|
|
40
|
+
readonly graphManager: V1_PureGraphManager;
|
|
41
|
+
readonly taskService: DataCubeTaskService;
|
|
42
|
+
readonly layoutService: DataCubeLayoutService;
|
|
43
|
+
readonly alertService: DataCubeAlertService;
|
|
44
|
+
readonly newQueryState: LegendDataCubeNewQueryState;
|
|
45
|
+
readonly saveQueryState: ActionState;
|
|
46
|
+
readonly saverDisplay: DisplayState;
|
|
47
|
+
readonly loadQueryState: ActionState;
|
|
48
|
+
loader: LegendDataCubeQueryLoaderState;
|
|
49
|
+
builder?: LegendDataCubeQueryBuilderState | undefined;
|
|
50
|
+
constructor(baseStore: LegendDataCubeBaseStore);
|
|
51
|
+
setBuilder(val: LegendDataCubeQueryBuilderState | undefined): void;
|
|
52
|
+
private updateWindowTitle;
|
|
53
|
+
getRecentlyViewedQueries(): string[];
|
|
54
|
+
loadQuery(queryId: string | undefined): Promise<void>;
|
|
55
|
+
private generatePersistentQuery;
|
|
56
|
+
createQuery(name: string): Promise<void>;
|
|
57
|
+
saveQuery(name: string, saveAsNewQuery: boolean): Promise<void>;
|
|
58
|
+
}
|
|
59
|
+
//# sourceMappingURL=LegendDataCubeQueryBuilderStore.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"LegendDataCubeQueryBuilderStore.d.ts","sourceRoot":"","sources":["../../../src/stores/query-builder/LegendDataCubeQueryBuilderStore.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAGH,OAAO,KAAK,EACV,8BAA8B,EAC9B,uBAAuB,EACxB,MAAM,+BAA+B,CAAC;AACvC,OAAO,EACL,KAAK,oBAAoB,EACzB,KAAK,WAAW,EAChB,KAAK,qBAAqB,EAC1B,KAAK,mBAAmB,EACxB,aAAa,EAEb,KAAK,YAAY,EAClB,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAAE,2BAA2B,EAAE,MAAM,kCAAkC,CAAC;AAC/E,OAAO,EACL,uBAAuB,EACvB,KAAK,qBAAqB,EAC1B,KAAK,mBAAmB,EACzB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EACL,WAAW,EAKZ,MAAM,sBAAsB,CAAC;AAC9B,OAAO,KAAK,EAAE,4BAA4B,EAAE,MAAM,oCAAoC,CAAC;AAGvF,OAAO,EAAE,8BAA8B,EAAE,MAAM,qCAAqC,CAAC;AAKrF,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,4BAA4B,CAAC;AAEpE,qBAAa,+BAA+B;IAC1C,IAAI,SAAU;IACd,SAAS,SAAc;IACvB,KAAK,EAAG,aAAa,CAAC;IACtB,eAAe,CAAC,EAAE,uBAAuB,GAAG,SAAS,CAAC;IACtD,QAAQ,CAAC,EAAE,WAAW,GAAG,SAAS,CAAC;gBAGjC,KAAK,EAAE,aAAa,EACpB,eAAe,CAAC,EAAE,uBAAuB,GAAG,SAAS;IAevD,WAAW,CAAC,GAAG,EAAE,WAAW,GAAG,SAAS;IAIxC,kBAAkB,CAAC,GAAG,EAAE,uBAAuB;CAKhD;AAED,qBAAa,+BAA+B;IAC1C,QAAQ,CAAC,WAAW,EAAE,8BAA8B,CAAC;IACrD,QAAQ,CAAC,SAAS,EAAE,uBAAuB,CAAC;IAC5C,QAAQ,CAAC,MAAM,EAAE,4BAA4B,CAAC;IAC9C,QAAQ,CAAC,iBAAiB,EAAE,iBAAiB,CAAC;IAC9C,QAAQ,CAAC,kBAAkB,EAAE,qBAAqB,CAAC;IACnD,QAAQ,CAAC,YAAY,EAAE,mBAAmB,CAAC;IAC3C,QAAQ,CAAC,WAAW,EAAE,mBAAmB,CAAC;IAC1C,QAAQ,CAAC,aAAa,EAAE,qBAAqB,CAAC;IAC9C,QAAQ,CAAC,YAAY,EAAE,oBAAoB,CAAC;IAE5C,QAAQ,CAAC,aAAa,EAAE,2BAA2B,CAAC;IAEpD,QAAQ,CAAC,cAAc,cAAwB;IAC/C,QAAQ,CAAC,YAAY,EAAE,YAAY,CAAC;IAEpC,QAAQ,CAAC,cAAc,cAAwB;IAC/C,MAAM,EAAE,8BAA8B,CAAC;IACvC,OAAO,CAAC,EAAE,+BAA+B,GAAG,SAAS,CAAC;gBAE1C,SAAS,EAAE,uBAAuB;IA4B9C,UAAU,CAAC,GAAG,EAAE,+BAA+B,GAAG,SAAS;IAI3D,OAAO,CAAC,iBAAiB;IAMzB,wBAAwB;IASlB,SAAS,CAAC,OAAO,EAAE,MAAM,GAAG,SAAS;YAgD7B,uBAAuB;IAkB/B,WAAW,CAAC,IAAI,EAAE,MAAM;IAuCxB,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,cAAc,EAAE,OAAO;CA8CtD"}
|
|
@@ -0,0 +1,219 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
/**
|
|
3
|
+
* Copyright (c) 2020-present, Goldman Sachs
|
|
4
|
+
*
|
|
5
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
* you may not use this file except in compliance with the License.
|
|
7
|
+
* You may obtain a copy of the License at
|
|
8
|
+
*
|
|
9
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
*
|
|
11
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
* See the License for the specific language governing permissions and
|
|
15
|
+
* limitations under the License.
|
|
16
|
+
*/
|
|
17
|
+
import { action, makeObservable, observable } from 'mobx';
|
|
18
|
+
import { DataCubeQuery, DEFAULT_ALERT_WINDOW_CONFIG, } from '@finos/legend-data-cube';
|
|
19
|
+
import { LegendDataCubeNewQueryState } from './LegendDataCubeNewQueryState.js';
|
|
20
|
+
import { PersistentDataCubeQuery, } from '@finos/legend-graph';
|
|
21
|
+
import { ActionState, assertErrorThrown, formatDate, isString, uuid, } from '@finos/legend-shared';
|
|
22
|
+
import { LegendDataCubeQuerySaver } from '../../components/query-builder/LegendDataCubeQuerySaver.js';
|
|
23
|
+
import { generateQueryBuilderRoute } from '../../__lib__/LegendDataCubeNavigation.js';
|
|
24
|
+
import { LegendDataCubeQueryLoaderState } from './LegendDataCubeQueryLoaderState.js';
|
|
25
|
+
import { LegendDataCubeUserDataKey, RECENTLY_VIEWED_QUERIES_LIMIT, } from '../../__lib__/LegendDataCubeUserData.js';
|
|
26
|
+
export class LegendDataCubeQueryBuilderState {
|
|
27
|
+
uuid = uuid();
|
|
28
|
+
startTime = Date.now();
|
|
29
|
+
query;
|
|
30
|
+
persistentQuery;
|
|
31
|
+
dataCube;
|
|
32
|
+
constructor(query, persistentQuery) {
|
|
33
|
+
makeObservable(this, {
|
|
34
|
+
dataCube: observable,
|
|
35
|
+
setDataCube: action,
|
|
36
|
+
query: observable,
|
|
37
|
+
persistentQuery: observable,
|
|
38
|
+
setPersistentQuery: action,
|
|
39
|
+
});
|
|
40
|
+
this.query = query;
|
|
41
|
+
this.persistentQuery = persistentQuery;
|
|
42
|
+
}
|
|
43
|
+
setDataCube(val) {
|
|
44
|
+
this.dataCube = val;
|
|
45
|
+
}
|
|
46
|
+
setPersistentQuery(val) {
|
|
47
|
+
this.persistentQuery = val;
|
|
48
|
+
this.query = DataCubeQuery.serialization.fromJson(val.content);
|
|
49
|
+
this.startTime = Date.now();
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
export class LegendDataCubeQueryBuilderStore {
|
|
53
|
+
application;
|
|
54
|
+
baseStore;
|
|
55
|
+
engine;
|
|
56
|
+
depotServerClient;
|
|
57
|
+
engineServerClient;
|
|
58
|
+
graphManager;
|
|
59
|
+
taskService;
|
|
60
|
+
layoutService;
|
|
61
|
+
alertService;
|
|
62
|
+
newQueryState;
|
|
63
|
+
saveQueryState = ActionState.create();
|
|
64
|
+
saverDisplay;
|
|
65
|
+
loadQueryState = ActionState.create();
|
|
66
|
+
loader;
|
|
67
|
+
builder;
|
|
68
|
+
constructor(baseStore) {
|
|
69
|
+
makeObservable(this, {
|
|
70
|
+
builder: observable,
|
|
71
|
+
setBuilder: action,
|
|
72
|
+
});
|
|
73
|
+
this.application = baseStore.application;
|
|
74
|
+
this.baseStore = baseStore;
|
|
75
|
+
this.engine = baseStore.engine;
|
|
76
|
+
this.depotServerClient = baseStore.depotServerClient;
|
|
77
|
+
this.engineServerClient = baseStore.engineServerClient;
|
|
78
|
+
this.graphManager = baseStore.graphManager;
|
|
79
|
+
this.taskService = baseStore.taskService;
|
|
80
|
+
this.alertService = baseStore.alertService;
|
|
81
|
+
this.layoutService = baseStore.layoutService;
|
|
82
|
+
this.newQueryState = new LegendDataCubeNewQueryState(this);
|
|
83
|
+
this.loader = new LegendDataCubeQueryLoaderState(this);
|
|
84
|
+
this.saverDisplay = this.layoutService.newDisplay('Save Query', () => _jsx(LegendDataCubeQuerySaver, {}), {
|
|
85
|
+
...DEFAULT_ALERT_WINDOW_CONFIG,
|
|
86
|
+
height: 140,
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
setBuilder(val) {
|
|
90
|
+
this.builder = val;
|
|
91
|
+
}
|
|
92
|
+
updateWindowTitle(persistentQuery) {
|
|
93
|
+
this.application.layoutService.setWindowTitle(`\u229E ${persistentQuery.name}${this.builder ? ` - ${formatDate(new Date(this.builder.startTime), 'HH:mm:ss EEE MMM dd yyyy')}` : ''}`);
|
|
94
|
+
}
|
|
95
|
+
getRecentlyViewedQueries() {
|
|
96
|
+
const data = this.application.userDataService.getObjectValue(LegendDataCubeUserDataKey.RECENTLY_VIEWED_QUERIES);
|
|
97
|
+
return data && Array.isArray(data) && data.every((id) => isString(id))
|
|
98
|
+
? data
|
|
99
|
+
: [];
|
|
100
|
+
}
|
|
101
|
+
async loadQuery(queryId) {
|
|
102
|
+
if (queryId !== this.builder?.persistentQuery?.id) {
|
|
103
|
+
if (!queryId) {
|
|
104
|
+
this.setBuilder(undefined);
|
|
105
|
+
return;
|
|
106
|
+
}
|
|
107
|
+
this.loadQueryState.inProgress();
|
|
108
|
+
try {
|
|
109
|
+
const persistentQuery = await this.baseStore.graphManager.getDataCubeQuery(queryId);
|
|
110
|
+
const query = DataCubeQuery.serialization.fromJson(persistentQuery.content);
|
|
111
|
+
this.setBuilder(new LegendDataCubeQueryBuilderState(query, persistentQuery));
|
|
112
|
+
this.updateWindowTitle(persistentQuery);
|
|
113
|
+
// update the list of stack of recently viewed queries
|
|
114
|
+
const recentlyViewedQueries = this.getRecentlyViewedQueries();
|
|
115
|
+
const idx = recentlyViewedQueries.findIndex((data) => data === queryId);
|
|
116
|
+
if (idx === -1) {
|
|
117
|
+
if (recentlyViewedQueries.length >= RECENTLY_VIEWED_QUERIES_LIMIT) {
|
|
118
|
+
recentlyViewedQueries.pop();
|
|
119
|
+
}
|
|
120
|
+
recentlyViewedQueries.unshift(queryId);
|
|
121
|
+
}
|
|
122
|
+
else {
|
|
123
|
+
recentlyViewedQueries.splice(idx, 1);
|
|
124
|
+
recentlyViewedQueries.unshift(queryId);
|
|
125
|
+
}
|
|
126
|
+
this.application.userDataService.persistValue(LegendDataCubeUserDataKey.RECENTLY_VIEWED_QUERIES, recentlyViewedQueries);
|
|
127
|
+
this.loadQueryState.pass();
|
|
128
|
+
}
|
|
129
|
+
catch (error) {
|
|
130
|
+
assertErrorThrown(error);
|
|
131
|
+
this.alertService.alertError(error, {
|
|
132
|
+
message: `Query Load Failure: ${error.message}`,
|
|
133
|
+
});
|
|
134
|
+
this.loadQueryState.fail();
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
async generatePersistentQuery(api, name, existingPersistentQuery) {
|
|
139
|
+
const query = await api.generateDataCubeQuery();
|
|
140
|
+
let persistentQuery;
|
|
141
|
+
if (existingPersistentQuery) {
|
|
142
|
+
persistentQuery = existingPersistentQuery.clone();
|
|
143
|
+
}
|
|
144
|
+
else {
|
|
145
|
+
persistentQuery = new PersistentDataCubeQuery();
|
|
146
|
+
persistentQuery.id = uuid();
|
|
147
|
+
}
|
|
148
|
+
persistentQuery.name = name;
|
|
149
|
+
persistentQuery.content = DataCubeQuery.serialization.toJson(query);
|
|
150
|
+
return persistentQuery;
|
|
151
|
+
}
|
|
152
|
+
async createQuery(name) {
|
|
153
|
+
if (!this.builder?.dataCube || this.saveQueryState.isInProgress) {
|
|
154
|
+
return;
|
|
155
|
+
}
|
|
156
|
+
this.saveQueryState.inProgress();
|
|
157
|
+
try {
|
|
158
|
+
const persistentQuery = await this.generatePersistentQuery(this.builder.dataCube, name);
|
|
159
|
+
const newQuery = await this.baseStore.graphManager.createDataCubeQuery(persistentQuery);
|
|
160
|
+
// NOTE: reload is the cleanest, least bug-prone handling here
|
|
161
|
+
// but we can opt for just updating the URL to reflect the new query
|
|
162
|
+
// as an optimization. Also, it helps preserve the edition history
|
|
163
|
+
// on the existing data-cube.
|
|
164
|
+
//
|
|
165
|
+
// Another way to avoid reloading the whole app it to force update
|
|
166
|
+
// the <DataCube/> component using the key prop that ties to an ID
|
|
167
|
+
// of the builder.
|
|
168
|
+
this.application.navigationService.navigator.updateCurrentLocation(generateQueryBuilderRoute(newQuery.id));
|
|
169
|
+
this.builder.setPersistentQuery(persistentQuery);
|
|
170
|
+
this.updateWindowTitle(persistentQuery);
|
|
171
|
+
this.saverDisplay.close();
|
|
172
|
+
this.saveQueryState.pass();
|
|
173
|
+
}
|
|
174
|
+
catch (error) {
|
|
175
|
+
assertErrorThrown(error);
|
|
176
|
+
this.alertService.alertError(error, {
|
|
177
|
+
message: `Query Creation Failure: ${error.message}`,
|
|
178
|
+
});
|
|
179
|
+
this.saveQueryState.fail();
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
async saveQuery(name, saveAsNewQuery) {
|
|
183
|
+
if (!this.builder?.dataCube || this.saveQueryState.isInProgress) {
|
|
184
|
+
return;
|
|
185
|
+
}
|
|
186
|
+
this.saveQueryState.inProgress();
|
|
187
|
+
try {
|
|
188
|
+
const persistentQuery = await this.generatePersistentQuery(this.builder.dataCube, name, this.builder.persistentQuery);
|
|
189
|
+
if (saveAsNewQuery) {
|
|
190
|
+
persistentQuery.id = uuid();
|
|
191
|
+
const newQuery = await this.baseStore.graphManager.createDataCubeQuery(persistentQuery);
|
|
192
|
+
// NOTE: reload is the cleanest, least bug-prone handling here
|
|
193
|
+
// but we can opt for just updating the URL to reflect the new query
|
|
194
|
+
// as an optimization. Also, it helps preserve the edition history
|
|
195
|
+
// on the existing data-cube.
|
|
196
|
+
//
|
|
197
|
+
// Another way to avoid reloading the whole app it to force update
|
|
198
|
+
// the <DataCube/> component using the key prop that ties to an ID
|
|
199
|
+
// of the builder.
|
|
200
|
+
this.application.navigationService.navigator.updateCurrentLocation(generateQueryBuilderRoute(newQuery.id));
|
|
201
|
+
}
|
|
202
|
+
else {
|
|
203
|
+
await this.baseStore.graphManager.updateDataCubeQuery(persistentQuery);
|
|
204
|
+
}
|
|
205
|
+
this.builder.setPersistentQuery(persistentQuery);
|
|
206
|
+
this.updateWindowTitle(persistentQuery);
|
|
207
|
+
this.saverDisplay.close();
|
|
208
|
+
this.saveQueryState.pass();
|
|
209
|
+
}
|
|
210
|
+
catch (error) {
|
|
211
|
+
assertErrorThrown(error);
|
|
212
|
+
this.alertService.alertError(error, {
|
|
213
|
+
message: `Query Update Failure: ${error.message}`,
|
|
214
|
+
});
|
|
215
|
+
this.saveQueryState.fail();
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
//# sourceMappingURL=LegendDataCubeQueryBuilderStore.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"LegendDataCubeQueryBuilderStore.js","sourceRoot":"","sources":["../../../src/stores/query-builder/LegendDataCubeQueryBuilderStore.tsx"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAAE,MAAM,EAAE,cAAc,EAAE,UAAU,EAAE,MAAM,MAAM,CAAC;AAK1D,OAAO,EAKL,aAAa,EACb,2BAA2B,GAE5B,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAAE,2BAA2B,EAAE,MAAM,kCAAkC,CAAC;AAC/E,OAAO,EACL,uBAAuB,GAGxB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EACL,WAAW,EACX,iBAAiB,EACjB,UAAU,EACV,QAAQ,EACR,IAAI,GACL,MAAM,sBAAsB,CAAC;AAE9B,OAAO,EAAE,wBAAwB,EAAE,MAAM,4DAA4D,CAAC;AACtG,OAAO,EAAE,yBAAyB,EAAE,MAAM,2CAA2C,CAAC;AACtF,OAAO,EAAE,8BAA8B,EAAE,MAAM,qCAAqC,CAAC;AACrF,OAAO,EACL,yBAAyB,EACzB,6BAA6B,GAC9B,MAAM,yCAAyC,CAAC;AAGjD,MAAM,OAAO,+BAA+B;IAC1C,IAAI,GAAG,IAAI,EAAE,CAAC;IACd,SAAS,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;IACvB,KAAK,CAAiB;IACtB,eAAe,CAAuC;IACtD,QAAQ,CAA2B;IAEnC,YACE,KAAoB,EACpB,eAAqD;QAErD,cAAc,CAAC,IAAI,EAAE;YACnB,QAAQ,EAAE,UAAU;YACpB,WAAW,EAAE,MAAM;YAEnB,KAAK,EAAE,UAAU;YACjB,eAAe,EAAE,U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+
* 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
|
+
import { type LightPersistentDataCubeQuery } from '@finos/legend-graph';
|
|
17
|
+
import { ActionState } from '@finos/legend-shared';
|
|
18
|
+
import type { LegendDataCubeQueryBuilderStore } from './LegendDataCubeQueryBuilderStore.js';
|
|
19
|
+
import { type DisplayState } from '@finos/legend-data-cube';
|
|
20
|
+
export declare const DATA_CUBE_QUERY_LOADER_TYPEAHEAD_SEARCH_LIMIT = 50;
|
|
21
|
+
export declare const DATA_CUBE_QUERY_LOADER_DEFAULT_QUERY_SEARCH_LIMIT = 10;
|
|
22
|
+
export declare enum DataCubeQuerySortByType {
|
|
23
|
+
LAST_CREATED = "Last Created",
|
|
24
|
+
LAST_VIEWED = "Last Viewed",
|
|
25
|
+
LAST_UPDATED = "Last Updated"
|
|
26
|
+
}
|
|
27
|
+
export declare class LegendDataCubeQueryLoaderState {
|
|
28
|
+
private readonly _application;
|
|
29
|
+
private readonly _store;
|
|
30
|
+
private readonly _graphManager;
|
|
31
|
+
private readonly _alertService;
|
|
32
|
+
readonly display: DisplayState;
|
|
33
|
+
readonly searchState: ActionState;
|
|
34
|
+
readonly finalizeState: ActionState;
|
|
35
|
+
queries: LightPersistentDataCubeQuery[];
|
|
36
|
+
selectedQuery?: LightPersistentDataCubeQuery | undefined;
|
|
37
|
+
searchText: string;
|
|
38
|
+
showCurrentUserQueriesOnly: boolean;
|
|
39
|
+
showingDefaultQueries: boolean;
|
|
40
|
+
sortBy: DataCubeQuerySortByType;
|
|
41
|
+
constructor(store: LegendDataCubeQueryBuilderStore);
|
|
42
|
+
setSearchText(val: string): void;
|
|
43
|
+
setQueries(val: LightPersistentDataCubeQuery[]): void;
|
|
44
|
+
setShowingDefaultQueries(val: boolean): void;
|
|
45
|
+
setShowCurrentUserQueriesOnly(val: boolean): void;
|
|
46
|
+
setSortBy(val: DataCubeQuerySortByType): void;
|
|
47
|
+
private getQuerySearchSortBy;
|
|
48
|
+
setSelectedQuery(query: LightPersistentDataCubeQuery | undefined): void;
|
|
49
|
+
canPerformAdvancedSearch(searchText: string): boolean;
|
|
50
|
+
searchQueries(searchText: string): Promise<void>;
|
|
51
|
+
finalize(): Promise<void>;
|
|
52
|
+
}
|
|
53
|
+
//# sourceMappingURL=LegendDataCubeQueryLoaderState.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"LegendDataCubeQueryLoaderState.d.ts","sourceRoot":"","sources":["../../../src/stores/query-builder/LegendDataCubeQueryLoaderState.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAOH,OAAO,EACL,KAAK,4BAA4B,EAIlC,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,WAAW,EAA+B,MAAM,sBAAsB,CAAC;AAEhF,OAAO,KAAK,EAAE,+BAA+B,EAAE,MAAM,sCAAsC,CAAC;AAE5F,OAAO,EAGL,KAAK,YAAY,EAClB,MAAM,yBAAyB,CAAC;AAIjC,eAAO,MAAM,6CAA6C,KAAK,CAAC;AAChE,eAAO,MAAM,iDAAiD,KAAK,CAAC;AAEpE,oBAAY,uBAAuB;IACjC,YAAY,iBAAiB;IAC7B,WAAW,gBAAgB;IAC3B,YAAY,iBAAiB;CAC9B;AAED,qBAAa,8BAA8B;IACzC,OAAO,CAAC,QAAQ,CAAC,YAAY,CAAgC;IAC7D,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAkC;IACzD,OAAO,CAAC,QAAQ,CAAC,aAAa,CAAsB;IACpD,OAAO,CAAC,QAAQ,CAAC,aAAa,CAAuB;IAErD,QAAQ,CAAC,OAAO,EAAE,YAAY,CAAC;IAC/B,QAAQ,CAAC,WAAW,cAAwB;IAC5C,QAAQ,CAAC,aAAa,cAAwB;IAE9C,OAAO,EAAE,4BAA4B,EAAE,CAAM;IAC7C,aAAa,CAAC,EAAE,4BAA4B,GAAG,SAAS,CAAC;IAEzD,UAAU,SAAM;IAChB,0BAA0B,UAAS;IACnC,qBAAqB,UAAQ;IAC7B,MAAM,0BAAuC;gBAEjC,KAAK,EAAE,+BAA+B;IAqClD,aAAa,CAAC,GAAG,EAAE,MAAM;IAIzB,UAAU,CAAC,GAAG,EAAE,4BAA4B,EAAE;IAI9C,wBAAwB,CAAC,GAAG,EAAE,OAAO;IAIrC,6BAA6B,CAAC,GAAG,EAAE,OAAO,GAAG,IAAI;IAIjD,SAAS,CAAC,GAAG,EAAE,uBAAuB;IAItC,OAAO,CAAC,oBAAoB;IAa5B,gBAAgB,CAAC,KAAK,EAAE,4BAA4B,GAAG,SAAS;IAIhE,wBAAwB,CAAC,UAAU,EAAE,MAAM;IAOrC,aAAa,CAAC,UAAU,EAAE,MAAM;IAuFhC,QAAQ;CAyBf"}
|
|
@@ -0,0 +1,198 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
/**
|
|
3
|
+
* Copyright (c) 2020-present, Goldman Sachs
|
|
4
|
+
*
|
|
5
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
* you may not use this file except in compliance with the License.
|
|
7
|
+
* You may obtain a copy of the License at
|
|
8
|
+
*
|
|
9
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
*
|
|
11
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
* See the License for the specific language governing permissions and
|
|
15
|
+
* limitations under the License.
|
|
16
|
+
*/
|
|
17
|
+
import { APPLICATION_EVENT, DEFAULT_TYPEAHEAD_SEARCH_MINIMUM_SEARCH_LENGTH, } from '@finos/legend-application';
|
|
18
|
+
import { QuerySearchSpecification, QuerySearchSortBy, } from '@finos/legend-graph';
|
|
19
|
+
import { ActionState, assertErrorThrown, LogEvent } from '@finos/legend-shared';
|
|
20
|
+
import { makeObservable, observable, action } from 'mobx';
|
|
21
|
+
import { LegendDataCubeUserDataKey } from '../../__lib__/LegendDataCubeUserData.js';
|
|
22
|
+
import { DEFAULT_TOOL_PANEL_WINDOW_CONFIG, } from '@finos/legend-data-cube';
|
|
23
|
+
import { LegendDataCubeQueryLoader } from '../../components/query-builder/LegendDataCubeQueryLoader.js';
|
|
24
|
+
import { generateQueryBuilderRoute } from '../../__lib__/LegendDataCubeNavigation.js';
|
|
25
|
+
export const DATA_CUBE_QUERY_LOADER_TYPEAHEAD_SEARCH_LIMIT = 50;
|
|
26
|
+
export const DATA_CUBE_QUERY_LOADER_DEFAULT_QUERY_SEARCH_LIMIT = 10;
|
|
27
|
+
export var DataCubeQuerySortByType;
|
|
28
|
+
(function (DataCubeQuerySortByType) {
|
|
29
|
+
DataCubeQuerySortByType["LAST_CREATED"] = "Last Created";
|
|
30
|
+
DataCubeQuerySortByType["LAST_VIEWED"] = "Last Viewed";
|
|
31
|
+
DataCubeQuerySortByType["LAST_UPDATED"] = "Last Updated";
|
|
32
|
+
})(DataCubeQuerySortByType || (DataCubeQuerySortByType = {}));
|
|
33
|
+
export class LegendDataCubeQueryLoaderState {
|
|
34
|
+
_application;
|
|
35
|
+
_store;
|
|
36
|
+
_graphManager;
|
|
37
|
+
_alertService;
|
|
38
|
+
display;
|
|
39
|
+
searchState = ActionState.create();
|
|
40
|
+
finalizeState = ActionState.create();
|
|
41
|
+
queries = [];
|
|
42
|
+
selectedQuery;
|
|
43
|
+
searchText = '';
|
|
44
|
+
showCurrentUserQueriesOnly = false;
|
|
45
|
+
showingDefaultQueries = true;
|
|
46
|
+
sortBy = DataCubeQuerySortByType.LAST_VIEWED;
|
|
47
|
+
constructor(store) {
|
|
48
|
+
makeObservable(this, {
|
|
49
|
+
showingDefaultQueries: observable,
|
|
50
|
+
setShowingDefaultQueries: action,
|
|
51
|
+
searchText: observable,
|
|
52
|
+
setSearchText: action,
|
|
53
|
+
queries: observable,
|
|
54
|
+
setQueries: action,
|
|
55
|
+
showCurrentUserQueriesOnly: observable,
|
|
56
|
+
setShowCurrentUserQueriesOnly: action,
|
|
57
|
+
sortBy: observable,
|
|
58
|
+
setSortBy: action,
|
|
59
|
+
selectedQuery: observable,
|
|
60
|
+
setSelectedQuery: action,
|
|
61
|
+
});
|
|
62
|
+
this._application = store.application;
|
|
63
|
+
this._store = store;
|
|
64
|
+
this._graphManager = store.graphManager;
|
|
65
|
+
this._alertService = store.alertService;
|
|
66
|
+
this.display = store.layoutService.newDisplay('Load Query', () => _jsx(LegendDataCubeQueryLoader, {}), {
|
|
67
|
+
...DEFAULT_TOOL_PANEL_WINDOW_CONFIG,
|
|
68
|
+
width: 500,
|
|
69
|
+
minWidth: 500,
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
setSearchText(val) {
|
|
73
|
+
this.searchText = val;
|
|
74
|
+
}
|
|
75
|
+
setQueries(val) {
|
|
76
|
+
this.queries = val;
|
|
77
|
+
}
|
|
78
|
+
setShowingDefaultQueries(val) {
|
|
79
|
+
this.showingDefaultQueries = val;
|
|
80
|
+
}
|
|
81
|
+
setShowCurrentUserQueriesOnly(val) {
|
|
82
|
+
this.showCurrentUserQueriesOnly = val;
|
|
83
|
+
}
|
|
84
|
+
setSortBy(val) {
|
|
85
|
+
this.sortBy = val;
|
|
86
|
+
}
|
|
87
|
+
getQuerySearchSortBy(sortByValue) {
|
|
88
|
+
switch (sortByValue) {
|
|
89
|
+
case DataCubeQuerySortByType.LAST_CREATED:
|
|
90
|
+
return QuerySearchSortBy.SORT_BY_CREATE;
|
|
91
|
+
case DataCubeQuerySortByType.LAST_UPDATED:
|
|
92
|
+
return QuerySearchSortBy.SORT_BY_UPDATE;
|
|
93
|
+
case DataCubeQuerySortByType.LAST_VIEWED:
|
|
94
|
+
return QuerySearchSortBy.SORT_BY_VIEW;
|
|
95
|
+
default:
|
|
96
|
+
return undefined;
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
setSelectedQuery(query) {
|
|
100
|
+
this.selectedQuery = query;
|
|
101
|
+
}
|
|
102
|
+
canPerformAdvancedSearch(searchText) {
|
|
103
|
+
return !(searchText.length < DEFAULT_TYPEAHEAD_SEARCH_MINIMUM_SEARCH_LENGTH &&
|
|
104
|
+
!this.showCurrentUserQueriesOnly);
|
|
105
|
+
}
|
|
106
|
+
async searchQueries(searchText) {
|
|
107
|
+
// for the initial search, i.e. no search config is specified, fetch the default queries if possible
|
|
108
|
+
if (!this.canPerformAdvancedSearch(searchText)) {
|
|
109
|
+
if (!searchText) {
|
|
110
|
+
this.setShowingDefaultQueries(true);
|
|
111
|
+
this.searchState.inProgress();
|
|
112
|
+
this.setQueries([]);
|
|
113
|
+
let defaultQueries = [];
|
|
114
|
+
try {
|
|
115
|
+
// first, try to fetch recently viewed queries
|
|
116
|
+
try {
|
|
117
|
+
const recentlyViewedQueryIDs = this._store.getRecentlyViewedQueries();
|
|
118
|
+
if (recentlyViewedQueryIDs.length) {
|
|
119
|
+
defaultQueries = await this._graphManager.getDataCubeQueries(recentlyViewedQueryIDs);
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
catch (error) {
|
|
123
|
+
assertErrorThrown(error);
|
|
124
|
+
// if there's an error fetching recently viewed queries, most likely because
|
|
125
|
+
// some queries have been removed, just remove them all from the cached user data
|
|
126
|
+
this._application.userDataService.persistValue(LegendDataCubeUserDataKey.RECENTLY_VIEWED_QUERIES, undefined);
|
|
127
|
+
}
|
|
128
|
+
// if there's no recently viewed queries, just fetch queries of the current user
|
|
129
|
+
if (!defaultQueries.length) {
|
|
130
|
+
const searchSpecification = new QuerySearchSpecification();
|
|
131
|
+
searchSpecification.limit =
|
|
132
|
+
DATA_CUBE_QUERY_LOADER_DEFAULT_QUERY_SEARCH_LIMIT;
|
|
133
|
+
searchSpecification.showCurrentUserQueriesOnly = true;
|
|
134
|
+
defaultQueries =
|
|
135
|
+
await this._graphManager.searchDataCubeQueries(searchSpecification);
|
|
136
|
+
}
|
|
137
|
+
this.setQueries(defaultQueries);
|
|
138
|
+
this.searchState.pass();
|
|
139
|
+
}
|
|
140
|
+
catch (error) {
|
|
141
|
+
assertErrorThrown(error);
|
|
142
|
+
this._application.logService.error(LogEvent.create(APPLICATION_EVENT.GENERIC_FAILURE), error);
|
|
143
|
+
this.searchState.fail();
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
return;
|
|
147
|
+
}
|
|
148
|
+
this.setShowingDefaultQueries(false);
|
|
149
|
+
this.searchState.inProgress();
|
|
150
|
+
try {
|
|
151
|
+
const searchSpecification = QuerySearchSpecification.createDefault(searchText);
|
|
152
|
+
searchSpecification.limit =
|
|
153
|
+
DATA_CUBE_QUERY_LOADER_TYPEAHEAD_SEARCH_LIMIT + 1;
|
|
154
|
+
searchSpecification.showCurrentUserQueriesOnly =
|
|
155
|
+
this.showCurrentUserQueriesOnly;
|
|
156
|
+
const querySearchSortBy = this.getQuerySearchSortBy(this.sortBy);
|
|
157
|
+
if (querySearchSortBy) {
|
|
158
|
+
searchSpecification.sortByOption = querySearchSortBy;
|
|
159
|
+
}
|
|
160
|
+
this.setQueries(await this._graphManager.searchDataCubeQueries(searchSpecification));
|
|
161
|
+
// if sorting is not configured, sort by name
|
|
162
|
+
if (!querySearchSortBy) {
|
|
163
|
+
this.setQueries(this.queries.toSorted((a, b) => a.name.localeCompare(b.name)));
|
|
164
|
+
}
|
|
165
|
+
this.searchState.pass();
|
|
166
|
+
}
|
|
167
|
+
catch (error) {
|
|
168
|
+
assertErrorThrown(error);
|
|
169
|
+
this._alertService.alertError(error, {
|
|
170
|
+
message: `Query Search Failure: ${error.message}`,
|
|
171
|
+
});
|
|
172
|
+
this.searchState.fail();
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
async finalize() {
|
|
176
|
+
if (!this.selectedQuery) {
|
|
177
|
+
return;
|
|
178
|
+
}
|
|
179
|
+
this.finalizeState.inProgress();
|
|
180
|
+
try {
|
|
181
|
+
// just simply change the route here and the new query ID will get picked up
|
|
182
|
+
// and handled by the query builder to load the new query.
|
|
183
|
+
this._application.navigationService.navigator.updateCurrentLocation(generateQueryBuilderRoute(this.selectedQuery.id));
|
|
184
|
+
// reset
|
|
185
|
+
this.setSelectedQuery(undefined);
|
|
186
|
+
this.display.close();
|
|
187
|
+
this.finalizeState.pass();
|
|
188
|
+
}
|
|
189
|
+
catch (error) {
|
|
190
|
+
assertErrorThrown(error);
|
|
191
|
+
this._alertService.alertError(error, {
|
|
192
|
+
message: `Query Load Failure: ${error.message}`,
|
|
193
|
+
});
|
|
194
|
+
this.finalizeState.fail();
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
//# sourceMappingURL=LegendDataCubeQueryLoaderState.js.map
|