@finos/legend-application-repl 1.0.7 → 1.0.9
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/LegendREPLApplication.d.ts.map +1 -1
- package/lib/components/LegendREPLApplication.js +29 -15
- package/lib/components/LegendREPLApplication.js.map +1 -1
- package/lib/index.css +1 -1
- package/lib/package.json +3 -2
- package/lib/stores/LegendREPLDataCubeEngine.d.ts +37 -18
- package/lib/stores/LegendREPLDataCubeEngine.d.ts.map +1 -1
- package/lib/stores/LegendREPLDataCubeEngine.js +96 -47
- package/lib/stores/LegendREPLDataCubeEngine.js.map +1 -1
- package/lib/stores/LegendREPLDataCubeSource.d.ts +22 -0
- package/lib/stores/LegendREPLDataCubeSource.d.ts.map +1 -0
- package/lib/stores/LegendREPLDataCubeSource.js +22 -0
- package/lib/stores/LegendREPLDataCubeSource.js.map +1 -0
- package/lib/stores/LegendREPLServerClient.d.ts +34 -19
- package/lib/stores/LegendREPLServerClient.d.ts.map +1 -1
- package/lib/stores/LegendREPLServerClient.js +27 -5
- package/lib/stores/LegendREPLServerClient.js.map +1 -1
- package/package.json +7 -6
- package/src/components/LegendREPLApplication.tsx +55 -27
- package/src/stores/LegendREPLDataCubeEngine.ts +173 -87
- package/src/stores/LegendREPLDataCubeSource.ts +23 -0
- package/src/stores/LegendREPLServerClient.ts +65 -26
- package/tsconfig.json +1 -1
- package/lib/stores/LegendREPLDataCubeApplicationEngine.d.ts +0 -43
- package/lib/stores/LegendREPLDataCubeApplicationEngine.d.ts.map +0 -1
- package/lib/stores/LegendREPLDataCubeApplicationEngine.js +0 -86
- package/lib/stores/LegendREPLDataCubeApplicationEngine.js.map +0 -1
- package/src/stores/LegendREPLDataCubeApplicationEngine.ts +0 -137
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.9",
|
|
4
4
|
"description": "Legend REPL Grid client application core",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"legend",
|
|
@@ -43,17 +43,18 @@
|
|
|
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": "31.10.
|
|
46
|
+
"@finos/legend-application": "16.0.4",
|
|
47
|
+
"@finos/legend-art": "7.1.63",
|
|
48
|
+
"@finos/legend-data-cube": "0.0.11",
|
|
49
|
+
"@finos/legend-graph": "31.10.40",
|
|
50
50
|
"@finos/legend-shared": "10.0.57",
|
|
51
51
|
"@types/react": "18.3.11",
|
|
52
52
|
"@types/react-dom": "18.3.0",
|
|
53
53
|
"mobx": "6.13.3",
|
|
54
54
|
"mobx-react-lite": "4.0.7",
|
|
55
55
|
"react": "18.3.1",
|
|
56
|
-
"react-dom": "18.3.1"
|
|
56
|
+
"react-dom": "18.3.1",
|
|
57
|
+
"serializr": "3.0.2"
|
|
57
58
|
},
|
|
58
59
|
"devDependencies": {
|
|
59
60
|
"@finos/legend-dev-utils": "2.1.25",
|
|
@@ -22,14 +22,14 @@ import {
|
|
|
22
22
|
import { observer } from 'mobx-react-lite';
|
|
23
23
|
import { useEffect, useMemo } from 'react';
|
|
24
24
|
import {
|
|
25
|
+
formatDate,
|
|
25
26
|
guaranteeNonNullable,
|
|
26
27
|
LogEvent,
|
|
27
28
|
NetworkClient,
|
|
28
29
|
} from '@finos/legend-shared';
|
|
29
30
|
import { LegendREPLServerClient } from '../stores/LegendREPLServerClient.js';
|
|
30
|
-
import { LegendREPLDataCubeApplicationEngine } from '../stores/LegendREPLDataCubeApplicationEngine.js';
|
|
31
31
|
import { LegendREPLDataCubeEngine } from '../stores/LegendREPLDataCubeEngine.js';
|
|
32
|
-
import { DataCube,
|
|
32
|
+
import { DataCube, DataCubeSettingKey } from '@finos/legend-data-cube';
|
|
33
33
|
import {
|
|
34
34
|
APPLICATION_EVENT,
|
|
35
35
|
ApplicationFrameworkProvider,
|
|
@@ -38,53 +38,81 @@ import {
|
|
|
38
38
|
type LegendApplicationPluginManager,
|
|
39
39
|
} from '@finos/legend-application';
|
|
40
40
|
import type { LegendREPLApplicationConfig } from '../application/LegendREPLApplicationConfig.js';
|
|
41
|
+
import { LegendREPLDataCubeSource } from '../stores/LegendREPLDataCubeSource.js';
|
|
41
42
|
|
|
42
43
|
const LegendREPLDataCube = observer(() => {
|
|
43
|
-
const
|
|
44
|
+
const application = useApplicationStore<
|
|
44
45
|
LegendREPLApplicationConfig,
|
|
45
46
|
LegendApplicationPluginManager<LegendApplicationPlugin>
|
|
46
47
|
>();
|
|
47
|
-
const
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
}),
|
|
63
|
-
),
|
|
48
|
+
const config = application.config;
|
|
49
|
+
const engine = useMemo(
|
|
50
|
+
() =>
|
|
51
|
+
new LegendREPLDataCubeEngine(
|
|
52
|
+
application,
|
|
53
|
+
new LegendREPLServerClient(
|
|
54
|
+
new NetworkClient({
|
|
55
|
+
baseUrl: config.useDynamicREPLServer
|
|
56
|
+
? window.location.origin +
|
|
57
|
+
guaranteeNonNullable(config.baseAddress).replace('/repl/', '')
|
|
58
|
+
: config.replUrl,
|
|
59
|
+
}),
|
|
60
|
+
),
|
|
61
|
+
),
|
|
62
|
+
[application, config],
|
|
64
63
|
);
|
|
65
64
|
|
|
66
65
|
useEffect(() => {
|
|
67
|
-
|
|
66
|
+
engine.blockNavigation(
|
|
68
67
|
// Only block navigation in production
|
|
69
68
|
// eslint-disable-next-line no-process-env
|
|
70
69
|
[() => process.env.NODE_ENV === 'production'],
|
|
71
70
|
undefined,
|
|
72
71
|
() => {
|
|
73
|
-
|
|
72
|
+
engine.logWarning(
|
|
74
73
|
LogEvent.create(APPLICATION_EVENT.NAVIGATION_BLOCKED),
|
|
75
74
|
`Navigation from the application is blocked`,
|
|
76
75
|
);
|
|
77
76
|
},
|
|
78
77
|
);
|
|
79
78
|
return (): void => {
|
|
80
|
-
|
|
79
|
+
engine.unblockNavigation();
|
|
81
80
|
};
|
|
82
|
-
}, [
|
|
81
|
+
}, [engine]);
|
|
83
82
|
|
|
84
83
|
return (
|
|
85
|
-
<
|
|
86
|
-
|
|
87
|
-
|
|
84
|
+
<DataCube
|
|
85
|
+
engine={engine}
|
|
86
|
+
options={{
|
|
87
|
+
onNameChanged(name, source) {
|
|
88
|
+
const timestamp =
|
|
89
|
+
source instanceof LegendREPLDataCubeSource
|
|
90
|
+
? source.timestamp
|
|
91
|
+
: undefined;
|
|
92
|
+
application.layoutService.setWindowTitle(
|
|
93
|
+
`\u229E ${name}${timestamp ? ` - ${formatDate(new Date(timestamp), 'HH:mm:ss EEE MMM dd yyyy')}` : ''}`,
|
|
94
|
+
);
|
|
95
|
+
},
|
|
96
|
+
onSettingChanged(key, value) {
|
|
97
|
+
engine.persistSettingValue(key, value);
|
|
98
|
+
},
|
|
99
|
+
|
|
100
|
+
enableDebugMode: application.settingService.getBooleanValue(
|
|
101
|
+
DataCubeSettingKey.ENABLE_DEBUG_MODE,
|
|
102
|
+
),
|
|
103
|
+
gridClientRowBuffer: application.settingService.getNumericValue(
|
|
104
|
+
DataCubeSettingKey.GRID_CLIENT_ROW_BUFFER,
|
|
105
|
+
),
|
|
106
|
+
gridClientPurgeClosedRowNodes:
|
|
107
|
+
application.settingService.getBooleanValue(
|
|
108
|
+
DataCubeSettingKey.GRID_CLIENT_PURGE_CLOSED_ROW_NODES,
|
|
109
|
+
),
|
|
110
|
+
gridClientSuppressLargeDatasetWarning:
|
|
111
|
+
application.settingService.getBooleanValue(
|
|
112
|
+
DataCubeSettingKey.GRID_CLIENT_SUPPRESS_LARGE_DATASET_WARNING,
|
|
113
|
+
),
|
|
114
|
+
}}
|
|
115
|
+
/>
|
|
88
116
|
);
|
|
89
117
|
});
|
|
90
118
|
|
|
@@ -14,20 +14,22 @@
|
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
16
|
|
|
17
|
-
import type { LegendREPLServerClient } from './LegendREPLServerClient.js';
|
|
18
17
|
import {
|
|
18
|
+
GetBaseQueryResult,
|
|
19
|
+
type LegendREPLServerClient,
|
|
20
|
+
} from './LegendREPLServerClient.js';
|
|
21
|
+
import {
|
|
22
|
+
_elementPtr,
|
|
23
|
+
_function,
|
|
24
|
+
_lambda,
|
|
19
25
|
DataCubeEngine,
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
DEFAULT_GRID_CLIENT_ROW_BUFFER,
|
|
24
|
-
DEFAULT_GRID_CLIENT_SUPPRESS_LARGE_DATASET_WARNING,
|
|
25
|
-
type CompletionItem,
|
|
26
|
-
type DataCubeInfrastructureInfo,
|
|
27
|
-
type RelationType,
|
|
26
|
+
DataCubeFunction,
|
|
27
|
+
type DataCubeAPI,
|
|
28
|
+
type DataCubeSource,
|
|
28
29
|
} from '@finos/legend-data-cube';
|
|
29
30
|
import {
|
|
30
31
|
TDSExecutionResult,
|
|
32
|
+
type V1_AppliedFunction,
|
|
31
33
|
V1_buildExecutionResult,
|
|
32
34
|
V1_deserializeValueSpecification,
|
|
33
35
|
V1_serializeExecutionResult,
|
|
@@ -35,116 +37,123 @@ import {
|
|
|
35
37
|
type V1_Lambda,
|
|
36
38
|
type V1_ValueSpecification,
|
|
37
39
|
} from '@finos/legend-graph';
|
|
38
|
-
import {
|
|
39
|
-
|
|
40
|
-
|
|
40
|
+
import {
|
|
41
|
+
type DocumentationEntry,
|
|
42
|
+
guaranteeType,
|
|
43
|
+
isNonNullable,
|
|
44
|
+
LogEvent,
|
|
45
|
+
type PlainObject,
|
|
46
|
+
} from '@finos/legend-shared';
|
|
47
|
+
import { LegendREPLDataCubeSource } from './LegendREPLDataCubeSource.js';
|
|
48
|
+
import type { LegendREPLApplicationStore } from '../application/LegendREPLApplicationStore.js';
|
|
49
|
+
import {
|
|
50
|
+
APPLICATION_EVENT,
|
|
51
|
+
shouldDisplayVirtualAssistantDocumentationEntry,
|
|
52
|
+
} from '@finos/legend-application';
|
|
41
53
|
|
|
42
54
|
export class LegendREPLDataCubeEngine extends DataCubeEngine {
|
|
43
|
-
readonly application:
|
|
55
|
+
readonly application: LegendREPLApplicationStore;
|
|
44
56
|
readonly client: LegendREPLServerClient;
|
|
45
57
|
|
|
46
58
|
constructor(
|
|
47
|
-
application:
|
|
59
|
+
application: LegendREPLApplicationStore,
|
|
48
60
|
client: LegendREPLServerClient,
|
|
49
61
|
) {
|
|
50
62
|
super();
|
|
51
63
|
|
|
52
64
|
this.application = application;
|
|
53
65
|
this.client = client;
|
|
54
|
-
|
|
55
|
-
this.enableDebugMode =
|
|
56
|
-
this.application.getPersistedBooleanValue(
|
|
57
|
-
LEGEND_REPL_SETTING_KEY.ENABLE_DEBUG_MODE,
|
|
58
|
-
) ?? DEFAULT_ENABLE_DEBUG_MODE;
|
|
59
|
-
this.gridClientRowBuffer =
|
|
60
|
-
this.application.getPersistedNumericValue(
|
|
61
|
-
LEGEND_REPL_SETTING_KEY.GRID_CLIENT_ROW_BUFFER,
|
|
62
|
-
) ?? DEFAULT_GRID_CLIENT_ROW_BUFFER;
|
|
63
|
-
this.gridClientPurgeClosedRowNodes =
|
|
64
|
-
this.application.getPersistedBooleanValue(
|
|
65
|
-
LEGEND_REPL_SETTING_KEY.GRID_CLIENT_PURGE_CLOSED_ROW_NODES,
|
|
66
|
-
) ?? DEFAULT_GRID_CLIENT_PURGE_CLOSED_ROW_NODES;
|
|
67
|
-
this.gridClientSuppressLargeDatasetWarning =
|
|
68
|
-
this.application.getPersistedBooleanValue(
|
|
69
|
-
LEGEND_REPL_SETTING_KEY.GRID_CLIENT_SUPPRESS_LARGE_DATASET_WARNING,
|
|
70
|
-
) ?? DEFAULT_GRID_CLIENT_SUPPRESS_LARGE_DATASET_WARNING;
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
override setEnableDebugMode(value: boolean) {
|
|
74
|
-
super.setEnableDebugMode(value);
|
|
75
|
-
this.application.persistValue(
|
|
76
|
-
LEGEND_REPL_SETTING_KEY.ENABLE_DEBUG_MODE,
|
|
77
|
-
value,
|
|
78
|
-
);
|
|
79
66
|
}
|
|
80
67
|
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
68
|
+
blockNavigation(
|
|
69
|
+
blockCheckers: (() => boolean)[],
|
|
70
|
+
onBlock?: ((onProceed: () => void) => void) | undefined,
|
|
71
|
+
onNativePlatformNavigationBlock?: (() => void) | undefined,
|
|
72
|
+
) {
|
|
73
|
+
this.application.navigationService.navigator.blockNavigation(
|
|
74
|
+
blockCheckers,
|
|
75
|
+
onBlock,
|
|
76
|
+
onNativePlatformNavigationBlock,
|
|
86
77
|
);
|
|
87
78
|
}
|
|
88
79
|
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
this.application.persistValue(
|
|
92
|
-
LEGEND_REPL_SETTING_KEY.GRID_CLIENT_PURGE_CLOSED_ROW_NODES,
|
|
93
|
-
value,
|
|
94
|
-
);
|
|
80
|
+
unblockNavigation() {
|
|
81
|
+
this.application.navigationService.navigator.unblockNavigation();
|
|
95
82
|
}
|
|
96
83
|
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
);
|
|
84
|
+
persistSettingValue(
|
|
85
|
+
key: string,
|
|
86
|
+
value: string | number | boolean | object | undefined,
|
|
87
|
+
): void {
|
|
88
|
+
this.application.settingService.persistValue(key, value);
|
|
103
89
|
}
|
|
104
90
|
|
|
105
|
-
|
|
106
|
-
|
|
91
|
+
// ---------------------------------- IMPLEMENTATION ----------------------------------
|
|
92
|
+
|
|
93
|
+
override async fetchConfiguration() {
|
|
94
|
+
const info = await this.client.getInfrastructureInfo();
|
|
95
|
+
return {
|
|
96
|
+
gridClientLicense: info.gridClientLicense,
|
|
97
|
+
};
|
|
107
98
|
}
|
|
108
99
|
|
|
109
|
-
async
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
100
|
+
override async getInitialInput() {
|
|
101
|
+
const baseQuery = GetBaseQueryResult.serialization.fromJson(
|
|
102
|
+
await this.client.getBaseQuery(),
|
|
103
|
+
);
|
|
104
|
+
const source = new LegendREPLDataCubeSource();
|
|
105
|
+
source.mapping = baseQuery.source.mapping;
|
|
106
|
+
source.query = await this.parseValueSpecification(
|
|
107
|
+
baseQuery.source.query,
|
|
108
|
+
false,
|
|
109
|
+
);
|
|
110
|
+
source.runtime = baseQuery.source.runtime;
|
|
111
|
+
source.timestamp = baseQuery.source.timestamp;
|
|
112
|
+
source.sourceColumns = (
|
|
113
|
+
await this.getQueryRelationType(_lambda([], [source.query]), source)
|
|
114
|
+
).columns;
|
|
115
|
+
|
|
116
|
+
return {
|
|
117
|
+
query: baseQuery.query,
|
|
118
|
+
source,
|
|
119
|
+
};
|
|
117
120
|
}
|
|
118
121
|
|
|
119
|
-
async
|
|
122
|
+
async parseValueSpecification(
|
|
120
123
|
code: string,
|
|
121
124
|
returnSourceInformation?: boolean,
|
|
122
125
|
): Promise<V1_ValueSpecification> {
|
|
123
126
|
return V1_deserializeValueSpecification(
|
|
124
|
-
await this.client.
|
|
127
|
+
await this.client.parseValueSpecification({
|
|
128
|
+
code,
|
|
129
|
+
returnSourceInformation,
|
|
130
|
+
}),
|
|
125
131
|
[],
|
|
126
132
|
);
|
|
127
133
|
}
|
|
128
134
|
|
|
129
|
-
override
|
|
130
|
-
|
|
135
|
+
override getValueSpecificationCode(
|
|
136
|
+
value: V1_ValueSpecification,
|
|
131
137
|
pretty?: boolean,
|
|
132
|
-
)
|
|
133
|
-
return this.client.
|
|
134
|
-
|
|
138
|
+
) {
|
|
139
|
+
return this.client.getValueSpecificationCode({
|
|
140
|
+
value: V1_serializeValueSpecification(value, []),
|
|
135
141
|
pretty,
|
|
136
142
|
});
|
|
137
143
|
}
|
|
138
144
|
|
|
139
|
-
async
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
145
|
+
async getQueryTypeahead(
|
|
146
|
+
code: string,
|
|
147
|
+
baseQuery: V1_Lambda,
|
|
148
|
+
source: DataCubeSource,
|
|
149
|
+
) {
|
|
150
|
+
return this.client.getQueryTypeahead({
|
|
151
|
+
code,
|
|
152
|
+
baseQuery: V1_serializeValueSpecification(baseQuery, []),
|
|
153
|
+
});
|
|
143
154
|
}
|
|
144
155
|
|
|
145
|
-
async getQueryRelationType(
|
|
146
|
-
query: V1_ValueSpecification,
|
|
147
|
-
): Promise<RelationType> {
|
|
156
|
+
async getQueryRelationType(query: V1_Lambda, source: DataCubeSource) {
|
|
148
157
|
return this.client.getQueryRelationReturnType({
|
|
149
158
|
query: V1_serializeValueSpecification(query, []),
|
|
150
159
|
});
|
|
@@ -153,21 +162,22 @@ export class LegendREPLDataCubeEngine extends DataCubeEngine {
|
|
|
153
162
|
async getQueryCodeRelationReturnType(
|
|
154
163
|
code: string,
|
|
155
164
|
baseQuery: V1_ValueSpecification,
|
|
156
|
-
|
|
165
|
+
source: DataCubeSource,
|
|
166
|
+
) {
|
|
157
167
|
return this.client.getQueryCodeRelationReturnType({
|
|
158
168
|
code,
|
|
159
169
|
baseQuery: V1_serializeValueSpecification(baseQuery, []),
|
|
160
170
|
});
|
|
161
171
|
}
|
|
162
172
|
|
|
163
|
-
async executeQuery(
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
173
|
+
async executeQuery(
|
|
174
|
+
query: V1_Lambda,
|
|
175
|
+
source: DataCubeSource,
|
|
176
|
+
api: DataCubeAPI,
|
|
177
|
+
) {
|
|
168
178
|
const result = await this.client.executeQuery({
|
|
169
179
|
query: V1_serializeValueSpecification(query, []),
|
|
170
|
-
debug:
|
|
180
|
+
debug: api.getSettings().enableDebugMode,
|
|
171
181
|
});
|
|
172
182
|
return {
|
|
173
183
|
result: guaranteeType(
|
|
@@ -180,4 +190,80 @@ export class LegendREPLDataCubeEngine extends DataCubeEngine {
|
|
|
180
190
|
executedSQL: result.executedSQL,
|
|
181
191
|
};
|
|
182
192
|
}
|
|
193
|
+
|
|
194
|
+
override buildExecutionContext(
|
|
195
|
+
source: DataCubeSource,
|
|
196
|
+
): V1_AppliedFunction | undefined {
|
|
197
|
+
if (source instanceof LegendREPLDataCubeSource) {
|
|
198
|
+
return _function(
|
|
199
|
+
DataCubeFunction.FROM,
|
|
200
|
+
[
|
|
201
|
+
source.mapping ? _elementPtr(source.mapping) : undefined,
|
|
202
|
+
_elementPtr(source.runtime),
|
|
203
|
+
].filter(isNonNullable),
|
|
204
|
+
);
|
|
205
|
+
}
|
|
206
|
+
return undefined;
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
override getDocumentationURL(): string | undefined {
|
|
210
|
+
return this.application.documentationService.url;
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
override getDocumentationEntry(key: string) {
|
|
214
|
+
return this.application.documentationService.getDocEntry(key);
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
override shouldDisplayDocumentationEntry(entry: DocumentationEntry) {
|
|
218
|
+
return shouldDisplayVirtualAssistantDocumentationEntry(entry);
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
override openLink(url: string) {
|
|
222
|
+
this.application.navigationService.navigator.visitAddress(url);
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
override sendTelemetry(event: string, data: PlainObject) {
|
|
226
|
+
this.application.telemetryService.logEvent(event, data);
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
override logDebug(message: string, ...data: unknown[]) {
|
|
230
|
+
this.application.logService.debug(
|
|
231
|
+
LogEvent.create(APPLICATION_EVENT.DEBUG),
|
|
232
|
+
message,
|
|
233
|
+
...data,
|
|
234
|
+
);
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
override debugProcess(processName: string, ...data: [string, unknown][]) {
|
|
238
|
+
this.application.logService.debug(
|
|
239
|
+
LogEvent.create(APPLICATION_EVENT.DEBUG),
|
|
240
|
+
`\n------ START DEBUG PROCESS: ${processName} ------`,
|
|
241
|
+
...data.flatMap(([key, value]) => [`\n[${key.toUpperCase()}]:`, value]),
|
|
242
|
+
`\n------- END DEBUG PROCESS: ${processName} -------\n\n`,
|
|
243
|
+
);
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
override logInfo(event: LogEvent, ...data: unknown[]) {
|
|
247
|
+
this.application.logService.info(event, ...data);
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
override logWarning(event: LogEvent, ...data: unknown[]) {
|
|
251
|
+
this.application.logService.warn(event, ...data);
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
override logError(event: LogEvent, ...data: unknown[]) {
|
|
255
|
+
this.application.logService.error(event, ...data);
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
override logUnhandledError(error: Error) {
|
|
259
|
+
this.application.logUnhandledError(error);
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
override logIllegalStateError(message: string, error?: Error) {
|
|
263
|
+
this.logError(
|
|
264
|
+
LogEvent.create(APPLICATION_EVENT.ILLEGAL_APPLICATION_STATE_OCCURRED),
|
|
265
|
+
message,
|
|
266
|
+
error,
|
|
267
|
+
);
|
|
268
|
+
}
|
|
183
269
|
}
|
|
@@ -0,0 +1,23 @@
|
|
|
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 { DataCubeSource } from '@finos/legend-data-cube';
|
|
18
|
+
|
|
19
|
+
export class LegendREPLDataCubeSource extends DataCubeSource {
|
|
20
|
+
runtime!: string;
|
|
21
|
+
mapping?: string | undefined;
|
|
22
|
+
timestamp!: number;
|
|
23
|
+
}
|
|
@@ -18,52 +18,86 @@ import {
|
|
|
18
18
|
ContentType,
|
|
19
19
|
guaranteeNonNullable,
|
|
20
20
|
HttpHeader,
|
|
21
|
+
SerializationFactory,
|
|
22
|
+
usingModelSchema,
|
|
21
23
|
type NetworkClient,
|
|
22
24
|
type PlainObject,
|
|
23
25
|
} from '@finos/legend-shared';
|
|
24
|
-
import
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
DataCubeInfrastructureInfo,
|
|
26
|
+
import {
|
|
27
|
+
DataCubeQuery,
|
|
28
|
+
type CompletionItem,
|
|
29
|
+
type RelationType,
|
|
29
30
|
} from '@finos/legend-data-cube';
|
|
30
31
|
import type { V1_Lambda, V1_ValueSpecification } from '@finos/legend-graph';
|
|
32
|
+
import { createModelSchema, optional, primitive } from 'serializr';
|
|
31
33
|
|
|
32
|
-
type
|
|
33
|
-
|
|
34
|
+
type GetValueSpecificationCodeInput = {
|
|
35
|
+
value: PlainObject<V1_ValueSpecification>;
|
|
34
36
|
pretty?: boolean | undefined;
|
|
35
37
|
};
|
|
36
38
|
|
|
37
|
-
type
|
|
39
|
+
type ParseValueSpecificationInput = {
|
|
38
40
|
code: string;
|
|
39
41
|
returnSourceInformation?: boolean | undefined;
|
|
40
42
|
};
|
|
41
43
|
|
|
42
|
-
type
|
|
44
|
+
type QueryTypeaheadInput = {
|
|
43
45
|
code: string;
|
|
44
|
-
baseQuery?: PlainObject<
|
|
46
|
+
baseQuery?: PlainObject<V1_Lambda>;
|
|
45
47
|
};
|
|
46
48
|
|
|
47
|
-
type
|
|
49
|
+
type GetQueryRelationReturnTypeInput = {
|
|
48
50
|
query: PlainObject<V1_Lambda>;
|
|
49
51
|
};
|
|
50
52
|
|
|
51
|
-
type
|
|
53
|
+
type GetQueryCodeRelationReturnTypeInput = {
|
|
52
54
|
code: string;
|
|
53
55
|
baseQuery?: PlainObject<V1_ValueSpecification>;
|
|
54
56
|
};
|
|
55
57
|
|
|
56
|
-
type
|
|
58
|
+
type ExecutionInput = {
|
|
57
59
|
query: PlainObject<V1_Lambda>;
|
|
58
60
|
debug?: boolean | undefined;
|
|
59
61
|
};
|
|
60
62
|
|
|
61
|
-
type
|
|
63
|
+
type ExecutionResult = {
|
|
62
64
|
result: string;
|
|
63
65
|
executedQuery: string;
|
|
64
66
|
executedSQL: string;
|
|
65
67
|
};
|
|
66
68
|
|
|
69
|
+
type InfrastructureInfo = {
|
|
70
|
+
gridClientLicense?: string | undefined;
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
class QuerySource {
|
|
74
|
+
runtime!: string;
|
|
75
|
+
mapping?: string | undefined;
|
|
76
|
+
query!: string;
|
|
77
|
+
timestamp!: number;
|
|
78
|
+
|
|
79
|
+
static readonly serialization = new SerializationFactory(
|
|
80
|
+
createModelSchema(QuerySource, {
|
|
81
|
+
mapping: optional(primitive()),
|
|
82
|
+
query: primitive(),
|
|
83
|
+
runtime: primitive(),
|
|
84
|
+
timestamp: primitive(),
|
|
85
|
+
}),
|
|
86
|
+
);
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
export class GetBaseQueryResult {
|
|
90
|
+
query!: DataCubeQuery;
|
|
91
|
+
source!: QuerySource;
|
|
92
|
+
|
|
93
|
+
static readonly serialization = new SerializationFactory(
|
|
94
|
+
createModelSchema(GetBaseQueryResult, {
|
|
95
|
+
query: usingModelSchema(DataCubeQuery.serialization.schema),
|
|
96
|
+
source: usingModelSchema(QuerySource.serialization.schema),
|
|
97
|
+
}),
|
|
98
|
+
);
|
|
99
|
+
}
|
|
100
|
+
|
|
67
101
|
export class LegendREPLServerClient {
|
|
68
102
|
private readonly networkClient: NetworkClient;
|
|
69
103
|
|
|
@@ -82,37 +116,42 @@ export class LegendREPLServerClient {
|
|
|
82
116
|
return `${this.baseUrl}/api/dataCube`;
|
|
83
117
|
}
|
|
84
118
|
|
|
85
|
-
async getInfrastructureInfo(): Promise<
|
|
119
|
+
async getInfrastructureInfo(): Promise<InfrastructureInfo> {
|
|
86
120
|
return this.networkClient.get(`${this.dataCube}/infrastructureInfo`);
|
|
87
121
|
}
|
|
88
122
|
|
|
89
123
|
async getQueryTypeahead(
|
|
90
|
-
input:
|
|
124
|
+
input: QueryTypeaheadInput,
|
|
91
125
|
): Promise<CompletionItem[]> {
|
|
92
126
|
return this.networkClient.post(`${this.dataCube}/typeahead`, input);
|
|
93
127
|
}
|
|
94
128
|
|
|
95
|
-
async
|
|
96
|
-
input:
|
|
129
|
+
async parseValueSpecification(
|
|
130
|
+
input: ParseValueSpecificationInput,
|
|
97
131
|
): Promise<PlainObject<V1_ValueSpecification>> {
|
|
98
|
-
return this.networkClient.post(
|
|
132
|
+
return this.networkClient.post(
|
|
133
|
+
`${this.dataCube}/parseValueSpecification`,
|
|
134
|
+
input,
|
|
135
|
+
);
|
|
99
136
|
}
|
|
100
137
|
|
|
101
|
-
async
|
|
138
|
+
async getValueSpecificationCode(
|
|
139
|
+
input: GetValueSpecificationCodeInput,
|
|
140
|
+
): Promise<string> {
|
|
102
141
|
return this.networkClient.post(
|
|
103
|
-
`${this.dataCube}/
|
|
142
|
+
`${this.dataCube}/getValueSpecificationCode`,
|
|
104
143
|
input,
|
|
105
144
|
{},
|
|
106
145
|
{ [HttpHeader.ACCEPT]: ContentType.TEXT_PLAIN },
|
|
107
146
|
);
|
|
108
147
|
}
|
|
109
148
|
|
|
110
|
-
async getBaseQuery(): Promise<PlainObject<
|
|
149
|
+
async getBaseQuery(): Promise<PlainObject<GetBaseQueryResult>> {
|
|
111
150
|
return this.networkClient.get(`${this.dataCube}/getBaseQuery`);
|
|
112
151
|
}
|
|
113
152
|
|
|
114
153
|
async getQueryRelationReturnType(
|
|
115
|
-
input:
|
|
154
|
+
input: GetQueryRelationReturnTypeInput,
|
|
116
155
|
): Promise<RelationType> {
|
|
117
156
|
return this.networkClient.post(
|
|
118
157
|
`${this.dataCube}/getRelationReturnType`,
|
|
@@ -121,7 +160,7 @@ export class LegendREPLServerClient {
|
|
|
121
160
|
}
|
|
122
161
|
|
|
123
162
|
async getQueryCodeRelationReturnType(
|
|
124
|
-
input:
|
|
163
|
+
input: GetQueryCodeRelationReturnTypeInput,
|
|
125
164
|
): Promise<RelationType> {
|
|
126
165
|
return this.networkClient.post(
|
|
127
166
|
`${this.dataCube}/getRelationReturnType/code`,
|
|
@@ -130,8 +169,8 @@ export class LegendREPLServerClient {
|
|
|
130
169
|
}
|
|
131
170
|
|
|
132
171
|
async executeQuery(
|
|
133
|
-
input: PlainObject<
|
|
134
|
-
): Promise<
|
|
172
|
+
input: PlainObject<ExecutionInput>,
|
|
173
|
+
): Promise<ExecutionResult> {
|
|
135
174
|
return this.networkClient.post(`${this.dataCube}/executeQuery`, input);
|
|
136
175
|
}
|
|
137
176
|
}
|