@finos/legend-application-repl 1.0.35 → 1.0.37
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/components/LegendREPLDataCubeHeader.d.ts +2 -4
- package/lib/components/LegendREPLDataCubeHeader.d.ts.map +1 -1
- package/lib/components/LegendREPLDataCubeHeader.js +8 -8
- package/lib/components/LegendREPLDataCubeHeader.js.map +1 -1
- package/lib/components/LegendREPLWebApplication.d.ts.map +1 -1
- package/lib/components/LegendREPLWebApplication.js +19 -9
- package/lib/components/LegendREPLWebApplication.js.map +1 -1
- package/lib/index.css +1 -1
- package/lib/package.json +3 -3
- package/lib/stores/LegendREPLBaseStore.d.ts +8 -6
- package/lib/stores/LegendREPLBaseStore.d.ts.map +1 -1
- package/lib/stores/LegendREPLBaseStore.js +40 -30
- package/lib/stores/LegendREPLBaseStore.js.map +1 -1
- package/lib/stores/LegendREPLDataCubeEngine.d.ts +8 -17
- package/lib/stores/LegendREPLDataCubeEngine.d.ts.map +1 -1
- package/lib/stores/LegendREPLDataCubeEngine.js +63 -61
- package/lib/stores/LegendREPLDataCubeEngine.js.map +1 -1
- package/package.json +8 -8
- package/src/components/LegendREPLDataCubeHeader.tsx +12 -9
- package/src/components/LegendREPLWebApplication.tsx +35 -10
- package/src/stores/LegendREPLBaseStore.tsx +60 -36
- package/src/stores/LegendREPLDataCubeEngine.ts +82 -80
|
@@ -16,70 +16,66 @@
|
|
|
16
16
|
import {} from './LegendREPLServerClient.js';
|
|
17
17
|
import { _elementPtr, _function, _lambda, DataCubeEngine, DataCubeFunction, _deserializeValueSpecification, _serializeValueSpecification, } from '@finos/legend-data-cube';
|
|
18
18
|
import { TDSExecutionResult, V1_buildExecutionResult, V1_deserializeExecutionResult, V1_buildEngineError, V1_EngineError, V1_getGenericTypeFullPath, V1_relationTypeModelSchema, } from '@finos/legend-graph';
|
|
19
|
-
import { assertErrorThrown, guaranteeType, HttpStatus, isNonNullable, LogEvent, NetworkClientError, } from '@finos/legend-shared';
|
|
19
|
+
import { assertErrorThrown, guaranteeType, HttpStatus, isNonNullable, LogEvent, NetworkClientError, UnsupportedOperationError, } from '@finos/legend-shared';
|
|
20
20
|
import { LegendREPLDataCubeSource, RawLegendREPLDataCubeSource, REPL_DATA_CUBE_SOURCE_TYPE, } from './LegendREPLDataCubeSource.js';
|
|
21
|
-
import { APPLICATION_EVENT
|
|
21
|
+
import { APPLICATION_EVENT } from '@finos/legend-application';
|
|
22
22
|
import { deserialize } from 'serializr';
|
|
23
23
|
export class LegendREPLDataCubeEngine extends DataCubeEngine {
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
client
|
|
27
|
-
constructor(baseStore) {
|
|
24
|
+
_application;
|
|
25
|
+
_client;
|
|
26
|
+
constructor(application, client) {
|
|
28
27
|
super();
|
|
29
|
-
this.
|
|
30
|
-
this.
|
|
31
|
-
this.client = baseStore.client;
|
|
28
|
+
this._application = application;
|
|
29
|
+
this._client = client;
|
|
32
30
|
}
|
|
33
31
|
// ---------------------------------- IMPLEMENTATION ----------------------------------
|
|
34
32
|
async processQuerySource(value) {
|
|
35
|
-
|
|
36
|
-
|
|
33
|
+
switch (value._type) {
|
|
34
|
+
case REPL_DATA_CUBE_SOURCE_TYPE: {
|
|
35
|
+
const rawSource = RawLegendREPLDataCubeSource.serialization.fromJson(value);
|
|
36
|
+
const source = new LegendREPLDataCubeSource();
|
|
37
|
+
source.query = await this.parseValueSpecification(rawSource.query, false);
|
|
38
|
+
try {
|
|
39
|
+
source.columns = (await this._getQueryRelationType(_lambda([], [source.query]))).columns;
|
|
40
|
+
}
|
|
41
|
+
catch (error) {
|
|
42
|
+
assertErrorThrown(error);
|
|
43
|
+
throw new Error(`Can't get query result columns. Make sure the source query return a relation (i.e. typed TDS). Error: ${error.message}`);
|
|
44
|
+
}
|
|
45
|
+
source.runtime = rawSource.runtime;
|
|
46
|
+
source.mapping = rawSource.mapping;
|
|
47
|
+
source.timestamp = rawSource.timestamp;
|
|
48
|
+
source.model = rawSource.model;
|
|
49
|
+
source.isLocal = rawSource.isLocal;
|
|
50
|
+
source.isPersistenceSupported = rawSource.isPersistenceSupported;
|
|
51
|
+
return source;
|
|
52
|
+
}
|
|
53
|
+
default: {
|
|
54
|
+
throw new UnsupportedOperationError(`Can't process query source of type '${value._type}'.`);
|
|
55
|
+
}
|
|
37
56
|
}
|
|
38
|
-
const rawSource = RawLegendREPLDataCubeSource.serialization.fromJson(value);
|
|
39
|
-
this.baseStore.sourceQuery = rawSource.query;
|
|
40
|
-
const source = new LegendREPLDataCubeSource();
|
|
41
|
-
source.query = await this.parseValueSpecification(rawSource.query, false);
|
|
42
|
-
source.columns = (await this.getQueryRelationType(_lambda([], [source.query]), source)).columns;
|
|
43
|
-
source.runtime = rawSource.runtime;
|
|
44
|
-
source.mapping = rawSource.mapping;
|
|
45
|
-
source.timestamp = rawSource.timestamp;
|
|
46
|
-
source.model = rawSource.model;
|
|
47
|
-
source.isLocal = rawSource.isLocal;
|
|
48
|
-
source.isPersistenceSupported = rawSource.isPersistenceSupported;
|
|
49
|
-
return source;
|
|
50
57
|
}
|
|
51
58
|
async parseValueSpecification(code, returnSourceInformation) {
|
|
52
|
-
return _deserializeValueSpecification(await this.
|
|
59
|
+
return _deserializeValueSpecification(await this._client.parseValueSpecification({
|
|
53
60
|
code,
|
|
54
61
|
returnSourceInformation,
|
|
55
62
|
}));
|
|
56
63
|
}
|
|
57
64
|
async getValueSpecificationCode(value, pretty) {
|
|
58
|
-
return this.
|
|
65
|
+
return this._client.getValueSpecificationCode({
|
|
59
66
|
value: _serializeValueSpecification(value),
|
|
60
67
|
pretty,
|
|
61
68
|
});
|
|
62
69
|
}
|
|
63
70
|
async getQueryTypeahead(code, baseQuery, source) {
|
|
64
|
-
return this.
|
|
71
|
+
return this._client.getQueryTypeahead({
|
|
65
72
|
code,
|
|
66
73
|
baseQuery: _serializeValueSpecification(baseQuery),
|
|
67
74
|
});
|
|
68
75
|
}
|
|
69
|
-
async getQueryRelationType(query, source) {
|
|
70
|
-
const relationType = deserialize(V1_relationTypeModelSchema, await this.client.getQueryRelationReturnType({
|
|
71
|
-
query: _serializeValueSpecification(query),
|
|
72
|
-
}));
|
|
73
|
-
return {
|
|
74
|
-
columns: relationType.columns.map((column) => ({
|
|
75
|
-
name: column.name,
|
|
76
|
-
type: V1_getGenericTypeFullPath(column.genericType),
|
|
77
|
-
})),
|
|
78
|
-
};
|
|
79
|
-
}
|
|
80
76
|
async getQueryCodeRelationReturnType(code, baseQuery, source) {
|
|
81
77
|
try {
|
|
82
|
-
const relationType = deserialize(V1_relationTypeModelSchema, await this.
|
|
78
|
+
const relationType = deserialize(V1_relationTypeModelSchema, await this._client.getQueryCodeRelationReturnType({
|
|
83
79
|
code,
|
|
84
80
|
baseQuery: _serializeValueSpecification(baseQuery),
|
|
85
81
|
}));
|
|
@@ -100,7 +96,7 @@ export class LegendREPLDataCubeEngine extends DataCubeEngine {
|
|
|
100
96
|
}
|
|
101
97
|
}
|
|
102
98
|
async executeQuery(query, source, options) {
|
|
103
|
-
const result = await this.
|
|
99
|
+
const result = await this._client.executeQuery({
|
|
104
100
|
query: _serializeValueSpecification(query),
|
|
105
101
|
debug: options?.debug,
|
|
106
102
|
});
|
|
@@ -119,48 +115,54 @@ export class LegendREPLDataCubeEngine extends DataCubeEngine {
|
|
|
119
115
|
}
|
|
120
116
|
return undefined;
|
|
121
117
|
}
|
|
122
|
-
// ----------------------------------
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
return
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
this.application.navigationService.navigator.visitAddress(url);
|
|
134
|
-
}
|
|
135
|
-
sendTelemetry(event, data) {
|
|
136
|
-
this.application.telemetryService.logEvent(event, data);
|
|
118
|
+
// ---------------------------------- UTILITIES ----------------------------------
|
|
119
|
+
async _getQueryRelationType(query) {
|
|
120
|
+
const relationType = deserialize(V1_relationTypeModelSchema, await this._client.getQueryRelationReturnType({
|
|
121
|
+
query: _serializeValueSpecification(query),
|
|
122
|
+
}));
|
|
123
|
+
return {
|
|
124
|
+
columns: relationType.columns.map((column) => ({
|
|
125
|
+
name: column.name,
|
|
126
|
+
type: V1_getGenericTypeFullPath(column.genericType),
|
|
127
|
+
})),
|
|
128
|
+
};
|
|
137
129
|
}
|
|
130
|
+
// ---------------------------------- APPLICATION ----------------------------------
|
|
138
131
|
logDebug(message, ...data) {
|
|
139
|
-
this.
|
|
132
|
+
this._application.logService.debug(LogEvent.create(APPLICATION_EVENT.DEBUG), message, ...data);
|
|
140
133
|
}
|
|
141
134
|
debugProcess(processName, ...data) {
|
|
142
135
|
// eslint-disable-next-line no-process-env
|
|
143
136
|
if (process.env.NODE_ENV === 'development') {
|
|
144
|
-
this.
|
|
137
|
+
this._application.logService.info(LogEvent.create(APPLICATION_EVENT.DEBUG), `\n------ START DEBUG PROCESS: ${processName} ------`, ...data.flatMap(([key, value]) => [`\n[${key.toUpperCase()}]:`, value]), `\n------- END DEBUG PROCESS: ${processName} -------\n\n`);
|
|
145
138
|
}
|
|
146
139
|
else {
|
|
147
|
-
this.
|
|
140
|
+
this._application.logService.debug(LogEvent.create(APPLICATION_EVENT.DEBUG), `\n------ START DEBUG PROCESS: ${processName} ------`, ...data.flatMap(([key, value]) => [`\n[${key.toUpperCase()}]:`, value]), `\n------- END DEBUG PROCESS: ${processName} -------\n\n`);
|
|
148
141
|
}
|
|
149
142
|
}
|
|
150
143
|
logInfo(event, ...data) {
|
|
151
|
-
this.
|
|
144
|
+
this._application.logService.info(event, ...data);
|
|
152
145
|
}
|
|
153
146
|
logWarning(event, ...data) {
|
|
154
|
-
this.
|
|
147
|
+
this._application.logService.warn(event, ...data);
|
|
155
148
|
}
|
|
156
149
|
logError(event, ...data) {
|
|
157
|
-
this.
|
|
150
|
+
this._application.logService.error(event, ...data);
|
|
158
151
|
}
|
|
159
152
|
logUnhandledError(error) {
|
|
160
|
-
this.
|
|
153
|
+
this._application.logUnhandledError(error);
|
|
161
154
|
}
|
|
162
155
|
logIllegalStateError(message, error) {
|
|
163
156
|
this.logError(LogEvent.create(APPLICATION_EVENT.ILLEGAL_APPLICATION_STATE_OCCURRED), message, error);
|
|
164
157
|
}
|
|
158
|
+
getDocumentationEntry(key) {
|
|
159
|
+
return this._application.documentationService.getDocEntry(key);
|
|
160
|
+
}
|
|
161
|
+
openLink(url) {
|
|
162
|
+
this._application.navigationService.navigator.visitAddress(url);
|
|
163
|
+
}
|
|
164
|
+
sendTelemetry(event, data) {
|
|
165
|
+
this._application.telemetryService.logEvent(event, data);
|
|
166
|
+
}
|
|
165
167
|
}
|
|
166
168
|
//# sourceMappingURL=LegendREPLDataCubeEngine.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LegendREPLDataCubeEngine.js","sourceRoot":"","sources":["../../src/stores/LegendREPLDataCubeEngine.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAA+B,MAAM,6BAA6B,CAAC;AAC1E,OAAO,EACL,WAAW,EACX,SAAS,EACT,OAAO,EACP,cAAc,EACd,gBAAgB,EAGhB,8BAA8B,EAC9B,4BAA4B,GAC7B,MAAM,yBAAyB,CAAC;AACjC,OAAO,EACL,kBAAkB,EAElB,uBAAuB,EACvB,6BAA6B,EAG7B,mBAAmB,EACnB,cAAc,EACd,yBAAyB,EACzB,0BAA0B,GAC3B,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EACL,iBAAiB,
|
|
1
|
+
{"version":3,"file":"LegendREPLDataCubeEngine.js","sourceRoot":"","sources":["../../src/stores/LegendREPLDataCubeEngine.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAA+B,MAAM,6BAA6B,CAAC;AAC1E,OAAO,EACL,WAAW,EACX,SAAS,EACT,OAAO,EACP,cAAc,EACd,gBAAgB,EAGhB,8BAA8B,EAC9B,4BAA4B,G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AC;IAEQ,iBAAiB,CAAC,KAAY;QACrC,IAAI,CAAC,YAAY,CAAC,iBAAiB,CAAC,KAAK,CAAC,CAAC;IAC7C,CAAC;IAEQ,oBAAoB,CAAC,OAAe,EAAE,KAAa;QAC1D,IAAI,CAAC,QAAQ,CACX,QAAQ,CAAC,MAAM,CAAC,iBAAiB,CAAC,kCAAkC,CAAC,EACrE,OAAO,EACP,KAAK,CACN,CAAC;IACJ,CAAC;IAEQ,qBAAqB,CAAC,GAAW;QACxC,OAAO,IAAI,CAAC,YAAY,CAAC,oBAAoB,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC;IACjE,CAAC;IAEQ,QAAQ,CAAC,GAAW;QAC3B,IAAI,CAAC,YAAY,CAAC,iBAAiB,CAAC,SAAS,CAAC,YAAY,CAAC,GAAG,CAAC,CAAC;IAClE,CAAC;IAEQ,aAAa,CAAC,KAAa,EAAE,IAAiB;QACrD,IAAI,CAAC,YAAY,CAAC,gBAAgB,CAAC,QAAQ,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC;IAC3D,CAAC;CACF"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@finos/legend-application-repl",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.37",
|
|
4
4
|
"description": "Legend REPL Grid client application core",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"legend",
|
|
@@ -43,12 +43,12 @@
|
|
|
43
43
|
"test:watch": "jest --watch"
|
|
44
44
|
},
|
|
45
45
|
"dependencies": {
|
|
46
|
-
"@finos/legend-application": "16.0.
|
|
47
|
-
"@finos/legend-art": "7.1.
|
|
48
|
-
"@finos/legend-data-cube": "0.0.
|
|
49
|
-
"@finos/legend-graph": "32.0.
|
|
50
|
-
"@finos/legend-shared": "10.0.
|
|
51
|
-
"@types/react": "19.0.
|
|
46
|
+
"@finos/legend-application": "16.0.17",
|
|
47
|
+
"@finos/legend-art": "7.1.74",
|
|
48
|
+
"@finos/legend-data-cube": "0.0.39",
|
|
49
|
+
"@finos/legend-graph": "32.0.1",
|
|
50
|
+
"@finos/legend-shared": "10.0.66",
|
|
51
|
+
"@types/react": "19.0.3",
|
|
52
52
|
"@types/react-dom": "19.0.2",
|
|
53
53
|
"mobx": "6.13.5",
|
|
54
54
|
"mobx-react-lite": "4.1.0",
|
|
@@ -64,7 +64,7 @@
|
|
|
64
64
|
"jest": "29.7.0",
|
|
65
65
|
"npm-run-all": "4.1.5",
|
|
66
66
|
"rimraf": "6.0.1",
|
|
67
|
-
"sass": "1.83.
|
|
67
|
+
"sass": "1.83.1",
|
|
68
68
|
"typescript": "5.7.2"
|
|
69
69
|
},
|
|
70
70
|
"peerDependencies": {
|
|
@@ -14,25 +14,28 @@
|
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
16
|
|
|
17
|
-
import {
|
|
17
|
+
import {
|
|
18
|
+
FormButton,
|
|
19
|
+
type DataCubeInnerHeaderComponentParams,
|
|
20
|
+
} from '@finos/legend-data-cube';
|
|
18
21
|
import { observer } from 'mobx-react-lite';
|
|
19
22
|
import { LegendREPLDataCubeSource } from '../stores/LegendREPLDataCubeSource.js';
|
|
20
23
|
import { useLegendREPLBaseStore } from './LegendREPLFramworkProvider.js';
|
|
21
24
|
|
|
22
25
|
export const LegendREPLDataCubeHeader = observer(
|
|
23
|
-
(props:
|
|
24
|
-
const {
|
|
26
|
+
(props: DataCubeInnerHeaderComponentParams) => {
|
|
27
|
+
const { api } = props;
|
|
25
28
|
const store = useLegendREPLBaseStore();
|
|
26
29
|
|
|
27
|
-
if (!
|
|
30
|
+
if (!store.source || !store.queryServerBaseUrl) {
|
|
28
31
|
return null;
|
|
29
32
|
}
|
|
30
33
|
|
|
31
34
|
const isPublishAllowed =
|
|
32
|
-
|
|
33
|
-
|
|
35
|
+
store.source instanceof LegendREPLDataCubeSource &&
|
|
36
|
+
store.source.isPersistenceSupported &&
|
|
34
37
|
// eslint-disable-next-line no-process-env
|
|
35
|
-
(process.env.NODE_ENV === 'development' || !
|
|
38
|
+
(process.env.NODE_ENV === 'development' || !store.source.isLocal);
|
|
36
39
|
|
|
37
40
|
return (
|
|
38
41
|
<div className="flex h-full items-center">
|
|
@@ -41,8 +44,8 @@ export const LegendREPLDataCubeHeader = observer(
|
|
|
41
44
|
disabled={!isPublishAllowed || store.publishState.isInProgress}
|
|
42
45
|
onClick={() => {
|
|
43
46
|
store
|
|
44
|
-
.publishDataCube(
|
|
45
|
-
.catch((error) =>
|
|
47
|
+
.publishDataCube(api)
|
|
48
|
+
.catch((error) => store.alertService.alertUnhandledError(error));
|
|
46
49
|
}}
|
|
47
50
|
>
|
|
48
51
|
Publish
|
|
@@ -24,6 +24,9 @@ import { useEffect } from 'react';
|
|
|
24
24
|
import { formatDate, LogEvent } from '@finos/legend-shared';
|
|
25
25
|
import {
|
|
26
26
|
DataCube,
|
|
27
|
+
DataCubePlaceholder,
|
|
28
|
+
DataCubePlaceholderErrorDisplay,
|
|
29
|
+
DEFAULT_REPORT_NAME,
|
|
27
30
|
type DataCubeQuery,
|
|
28
31
|
type DataCubeSettingValues,
|
|
29
32
|
} from '@finos/legend-data-cube';
|
|
@@ -64,29 +67,36 @@ const LegendREPLDataCube = observer((props: { query: DataCubeQuery }) => {
|
|
|
64
67
|
query={query}
|
|
65
68
|
engine={store.engine}
|
|
66
69
|
options={{
|
|
67
|
-
|
|
70
|
+
gridClientLicense: store.gridClientLicense,
|
|
71
|
+
layoutManager: store.layoutService.manager,
|
|
72
|
+
taskManager: store.taskService.manager,
|
|
73
|
+
onNameChanged(event) {
|
|
68
74
|
const timestamp =
|
|
69
|
-
source instanceof LegendREPLDataCubeSource
|
|
70
|
-
? source.timestamp
|
|
75
|
+
event.source instanceof LegendREPLDataCubeSource
|
|
76
|
+
? event.source.timestamp
|
|
71
77
|
: undefined;
|
|
72
78
|
application.layoutService.setWindowTitle(
|
|
73
79
|
`\u229E ${name}${timestamp ? ` - ${formatDate(new Date(timestamp), 'HH:mm:ss EEE MMM dd yyyy')}` : ''}`,
|
|
74
80
|
);
|
|
75
81
|
},
|
|
76
|
-
|
|
77
|
-
|
|
82
|
+
onViewInitialized(event) {
|
|
83
|
+
store.setSource(event.source);
|
|
84
|
+
},
|
|
85
|
+
innerHeaderRenderer: (params) => (
|
|
86
|
+
<LegendREPLDataCubeHeader api={params.api} />
|
|
78
87
|
),
|
|
79
|
-
|
|
80
|
-
|
|
88
|
+
settingsData: {
|
|
89
|
+
values: application.settingService.getObjectValue(
|
|
81
90
|
LegendREPLSettingStorageKey.DATA_CUBE,
|
|
82
|
-
) as DataCubeSettingValues | undefined
|
|
91
|
+
) as DataCubeSettingValues | undefined,
|
|
83
92
|
},
|
|
84
|
-
|
|
93
|
+
onSettingsChanged(values) {
|
|
85
94
|
application.settingService.persistValue(
|
|
86
95
|
LegendREPLSettingStorageKey.DATA_CUBE,
|
|
87
96
|
values,
|
|
88
97
|
);
|
|
89
98
|
},
|
|
99
|
+
documentationUrl: application.documentationService.url,
|
|
90
100
|
}}
|
|
91
101
|
/>
|
|
92
102
|
);
|
|
@@ -105,9 +115,24 @@ export const LegendREPLRouter = observer(() => {
|
|
|
105
115
|
.catch((error) => store.application.alertUnhandledError(error));
|
|
106
116
|
}, [store]);
|
|
107
117
|
|
|
118
|
+
if (!store.initializeState.hasSucceeded) {
|
|
119
|
+
return (
|
|
120
|
+
<DataCubePlaceholder
|
|
121
|
+
title={DEFAULT_REPORT_NAME}
|
|
122
|
+
layoutManager={store.layoutService.manager}
|
|
123
|
+
>
|
|
124
|
+
{store.initializeState.hasFailed && (
|
|
125
|
+
<DataCubePlaceholderErrorDisplay
|
|
126
|
+
message="Initialization Failure"
|
|
127
|
+
prompt="Resolve the issue and reload."
|
|
128
|
+
/>
|
|
129
|
+
)}
|
|
130
|
+
</DataCubePlaceholder>
|
|
131
|
+
);
|
|
132
|
+
}
|
|
108
133
|
return (
|
|
109
134
|
<div className="h-full">
|
|
110
|
-
{store.
|
|
135
|
+
{store.query && (
|
|
111
136
|
<Routes>
|
|
112
137
|
<Route
|
|
113
138
|
path={LEGEND_REPL_GRID_CLIENT_ROUTE_PATTERN.DATA_CUBE}
|
|
@@ -25,14 +25,22 @@ import {
|
|
|
25
25
|
import type { LegendREPLApplicationStore } from '../application/LegendREPLApplicationStore.js';
|
|
26
26
|
import { LegendREPLServerClient } from './LegendREPLServerClient.js';
|
|
27
27
|
import {
|
|
28
|
-
DataCubeConfiguration,
|
|
29
28
|
DataCubeQuery,
|
|
29
|
+
type DataCubeSource,
|
|
30
30
|
LayoutConfiguration,
|
|
31
31
|
RawAdhocQueryDataCubeSource,
|
|
32
32
|
WindowState,
|
|
33
|
-
type
|
|
33
|
+
type DataCubeAPI,
|
|
34
|
+
DEFAULT_REPORT_NAME,
|
|
35
|
+
DataCubeLayoutService,
|
|
36
|
+
DataCubeAlertService,
|
|
37
|
+
DataCubeLogService,
|
|
38
|
+
DataCubeTaskService,
|
|
34
39
|
} from '@finos/legend-data-cube';
|
|
35
|
-
import {
|
|
40
|
+
import {
|
|
41
|
+
LegendREPLDataCubeSource,
|
|
42
|
+
RawLegendREPLDataCubeSource,
|
|
43
|
+
} from './LegendREPLDataCubeSource.js';
|
|
36
44
|
import { PersistentDataCubeQuery } from '@finos/legend-graph';
|
|
37
45
|
import { LegendREPLPublishDataCubeAlert } from '../components/LegendREPLPublishDataCubeAlert.js';
|
|
38
46
|
import { APPLICATION_EVENT } from '@finos/legend-application';
|
|
@@ -40,14 +48,17 @@ import { action, makeObservable, observable } from 'mobx';
|
|
|
40
48
|
import { LegendREPLDataCubeEngine } from './LegendREPLDataCubeEngine.js';
|
|
41
49
|
|
|
42
50
|
export class LegendREPLBaseStore {
|
|
51
|
+
private readonly _client: LegendREPLServerClient;
|
|
43
52
|
readonly application: LegendREPLApplicationStore;
|
|
44
|
-
readonly client: LegendREPLServerClient;
|
|
45
53
|
readonly engine: LegendREPLDataCubeEngine;
|
|
54
|
+
readonly taskService: DataCubeTaskService;
|
|
55
|
+
readonly layoutService: DataCubeLayoutService;
|
|
56
|
+
readonly alertService: DataCubeAlertService;
|
|
57
|
+
|
|
46
58
|
readonly initializeState = ActionState.create();
|
|
47
59
|
readonly publishState = ActionState.create();
|
|
48
60
|
|
|
49
|
-
|
|
50
|
-
currentUser?: string | undefined;
|
|
61
|
+
source?: DataCubeSource | undefined;
|
|
51
62
|
gridClientLicense?: string | undefined;
|
|
52
63
|
queryServerBaseUrl?: string | undefined;
|
|
53
64
|
hostedApplicationBaseUrl?: string | undefined;
|
|
@@ -56,11 +67,13 @@ export class LegendREPLBaseStore {
|
|
|
56
67
|
constructor(application: LegendREPLApplicationStore) {
|
|
57
68
|
makeObservable(this, {
|
|
58
69
|
query: observable,
|
|
59
|
-
|
|
60
70
|
setQuery: action,
|
|
71
|
+
|
|
72
|
+
source: observable,
|
|
73
|
+
setSource: action,
|
|
61
74
|
});
|
|
62
75
|
this.application = application;
|
|
63
|
-
this.
|
|
76
|
+
this._client = new LegendREPLServerClient(
|
|
64
77
|
new NetworkClient({
|
|
65
78
|
baseUrl: application.config.useDynamicREPLServer
|
|
66
79
|
? window.location.origin +
|
|
@@ -71,18 +84,27 @@ export class LegendREPLBaseStore {
|
|
|
71
84
|
: application.config.replUrl,
|
|
72
85
|
}),
|
|
73
86
|
);
|
|
74
|
-
this.engine = new LegendREPLDataCubeEngine(this);
|
|
87
|
+
this.engine = new LegendREPLDataCubeEngine(this.application, this._client);
|
|
88
|
+
this.taskService = new DataCubeTaskService();
|
|
89
|
+
this.layoutService = new DataCubeLayoutService();
|
|
90
|
+
this.alertService = new DataCubeAlertService(
|
|
91
|
+
new DataCubeLogService(this.engine),
|
|
92
|
+
this.layoutService,
|
|
93
|
+
);
|
|
75
94
|
}
|
|
76
95
|
|
|
77
|
-
setQuery(query: DataCubeQuery | undefined)
|
|
96
|
+
setQuery(query: DataCubeQuery | undefined) {
|
|
78
97
|
this.query = query;
|
|
79
98
|
}
|
|
80
99
|
|
|
100
|
+
setSource(source: DataCubeSource | undefined) {
|
|
101
|
+
this.source = source;
|
|
102
|
+
}
|
|
103
|
+
|
|
81
104
|
async initialize() {
|
|
82
105
|
this.initializeState.inProgress();
|
|
83
106
|
try {
|
|
84
|
-
const info = await this.
|
|
85
|
-
this.currentUser = info.currentUser;
|
|
107
|
+
const info = await this._client.getInfrastructureInfo();
|
|
86
108
|
if (info.currentUser) {
|
|
87
109
|
this.application.identityService.setCurrentUser(info.currentUser);
|
|
88
110
|
}
|
|
@@ -92,7 +114,7 @@ export class LegendREPLBaseStore {
|
|
|
92
114
|
this.hostedApplicationBaseUrl = info.hostedApplicationBaseUrl;
|
|
93
115
|
this.gridClientLicense = info.gridClientLicense;
|
|
94
116
|
this.setQuery(
|
|
95
|
-
DataCubeQuery.serialization.fromJson(await this.
|
|
117
|
+
DataCubeQuery.serialization.fromJson(await this._client.getBaseQuery()),
|
|
96
118
|
);
|
|
97
119
|
|
|
98
120
|
this.initializeState.pass();
|
|
@@ -103,46 +125,48 @@ export class LegendREPLBaseStore {
|
|
|
103
125
|
`Can't initialize REPL`,
|
|
104
126
|
error,
|
|
105
127
|
);
|
|
128
|
+
this.alertService.alertError(error, {
|
|
129
|
+
message: `Initialization Failure: ${error.message}`,
|
|
130
|
+
text: `Resolve the issue and reload the engine.`,
|
|
131
|
+
});
|
|
106
132
|
this.initializeState.fail();
|
|
107
133
|
}
|
|
108
134
|
}
|
|
109
135
|
|
|
110
|
-
async publishDataCube(
|
|
136
|
+
async publishDataCube(api: DataCubeAPI) {
|
|
111
137
|
if (
|
|
112
|
-
!this.sourceQuery ||
|
|
113
|
-
!dataCube.view.isSourceProcessed ||
|
|
114
138
|
!this.queryServerBaseUrl ||
|
|
115
|
-
!(
|
|
116
|
-
!
|
|
117
|
-
!
|
|
139
|
+
!(this.source instanceof LegendREPLDataCubeSource) ||
|
|
140
|
+
!this.source.isPersistenceSupported ||
|
|
141
|
+
!this.source.model ||
|
|
118
142
|
// eslint-disable-next-line no-process-env
|
|
119
|
-
!(process.env.NODE_ENV === 'development' || !
|
|
143
|
+
!(process.env.NODE_ENV === 'development' || !this.source.isLocal)
|
|
120
144
|
) {
|
|
121
145
|
return;
|
|
122
146
|
}
|
|
123
147
|
|
|
124
148
|
this.publishState.inProgress();
|
|
125
|
-
const task =
|
|
149
|
+
const task = this.taskService.newTask('Publish query');
|
|
126
150
|
|
|
127
151
|
try {
|
|
128
|
-
const query =
|
|
129
|
-
|
|
130
|
-
dataCube.view.snapshotManager.currentSnapshot,
|
|
131
|
-
);
|
|
152
|
+
const query = await api.generateDataCubeQuery();
|
|
153
|
+
|
|
132
154
|
const source = new RawAdhocQueryDataCubeSource();
|
|
133
|
-
source.query =
|
|
134
|
-
|
|
135
|
-
|
|
155
|
+
source.query = RawLegendREPLDataCubeSource.serialization.fromJson(
|
|
156
|
+
query.source,
|
|
157
|
+
).query;
|
|
158
|
+
source.runtime = this.source.runtime;
|
|
159
|
+
source.model = this.source.model;
|
|
136
160
|
query.source = RawAdhocQueryDataCubeSource.serialization.toJson(source);
|
|
161
|
+
|
|
137
162
|
const newQuery = new PersistentDataCubeQuery();
|
|
138
163
|
newQuery.id = uuid();
|
|
139
|
-
newQuery.name =
|
|
140
|
-
dataCube.view.snapshotManager.currentSnapshot.data.configuration,
|
|
141
|
-
).name;
|
|
164
|
+
newQuery.name = query.configuration?.name ?? DEFAULT_REPORT_NAME;
|
|
142
165
|
newQuery.content = DataCubeQuery.serialization.toJson(query);
|
|
143
|
-
newQuery.owner = this.currentUser;
|
|
166
|
+
newQuery.owner = this.application.identityService.currentUser;
|
|
167
|
+
|
|
144
168
|
const publishedQuery = PersistentDataCubeQuery.serialization.fromJson(
|
|
145
|
-
await this.
|
|
169
|
+
await this._client.publishQuery(
|
|
146
170
|
PersistentDataCubeQuery.serialization.toJson(newQuery),
|
|
147
171
|
this.queryServerBaseUrl,
|
|
148
172
|
),
|
|
@@ -160,15 +184,15 @@ export class LegendREPLBaseStore {
|
|
|
160
184
|
minHeight: 100,
|
|
161
185
|
center: true,
|
|
162
186
|
};
|
|
163
|
-
|
|
187
|
+
this.layoutService.newWindow(window);
|
|
164
188
|
} catch (error) {
|
|
165
189
|
assertErrorThrown(error);
|
|
166
|
-
|
|
190
|
+
this.alertService.alertError(error, {
|
|
167
191
|
message: `Persistence Failure: Can't publish query.`,
|
|
168
192
|
text: `Error: ${error.message}`,
|
|
169
193
|
});
|
|
170
194
|
} finally {
|
|
171
|
-
|
|
195
|
+
this.taskService.endTask(task);
|
|
172
196
|
this.publishState.complete();
|
|
173
197
|
}
|
|
174
198
|
}
|