@finos/legend-application-repl 1.0.8 → 1.0.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (28) hide show
  1. package/lib/components/LegendREPLApplication.d.ts.map +1 -1
  2. package/lib/components/LegendREPLApplication.js +29 -15
  3. package/lib/components/LegendREPLApplication.js.map +1 -1
  4. package/lib/index.css +1 -1
  5. package/lib/package.json +6 -5
  6. package/lib/stores/LegendREPLDataCubeEngine.d.ts +37 -18
  7. package/lib/stores/LegendREPLDataCubeEngine.d.ts.map +1 -1
  8. package/lib/stores/LegendREPLDataCubeEngine.js +96 -47
  9. package/lib/stores/LegendREPLDataCubeEngine.js.map +1 -1
  10. package/lib/stores/LegendREPLDataCubeSource.d.ts +22 -0
  11. package/lib/stores/LegendREPLDataCubeSource.d.ts.map +1 -0
  12. package/lib/stores/LegendREPLDataCubeSource.js +22 -0
  13. package/lib/stores/LegendREPLDataCubeSource.js.map +1 -0
  14. package/lib/stores/LegendREPLServerClient.d.ts +34 -19
  15. package/lib/stores/LegendREPLServerClient.d.ts.map +1 -1
  16. package/lib/stores/LegendREPLServerClient.js +27 -5
  17. package/lib/stores/LegendREPLServerClient.js.map +1 -1
  18. package/package.json +12 -11
  19. package/src/components/LegendREPLApplication.tsx +55 -27
  20. package/src/stores/LegendREPLDataCubeEngine.ts +173 -87
  21. package/src/stores/LegendREPLDataCubeSource.ts +23 -0
  22. package/src/stores/LegendREPLServerClient.ts +65 -26
  23. package/tsconfig.json +1 -1
  24. package/lib/stores/LegendREPLDataCubeApplicationEngine.d.ts +0 -43
  25. package/lib/stores/LegendREPLDataCubeApplicationEngine.d.ts.map +0 -1
  26. package/lib/stores/LegendREPLDataCubeApplicationEngine.js +0 -86
  27. package/lib/stores/LegendREPLDataCubeApplicationEngine.js.map +0 -1
  28. package/src/stores/LegendREPLDataCubeApplicationEngine.ts +0 -137
@@ -1 +1 @@
1
- {"version":3,"file":"LegendREPLServerClient.js","source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C,UAAU,EAAE,CAChD,CAAC;IACJ,CAAC;IAED,KAAK,CAAC,YAAY;QAChB,OAAO,IAAI,CAAC,aAAa,CAAC,GAAG,CAAC,GAAG,IAAI,CAAC,QAAQ,eAAe,CAAC,CAAC;IACjE,CAAC;IAED,KAAK,CAAC,0BAA0B,CAC9B,KAAsC;QAEtC,OAAO,IAAI,CAAC,aAAa,CAAC,IAAI,CAC5B,GAAG,IAAI,CAAC,QAAQ,wBAAwB,EACxC,KAAK,CACN,CAAC;IACJ,CAAC;IAED,KAAK,CAAC,8BAA8B,CAClC,KAA0C;QAE1C,OAAO,IAAI,CAAC,aAAa,CAAC,IAAI,CAC5B,GAAG,IAAI,CAAC,QAAQ,6BAA6B,EAC7C,KAAK,CACN,CAAC;IACJ,CAAC;IAED,KAAK,CAAC,YAAY,CAChB,KAAkC;QAElC,OAAO,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC,QAAQ,eAAe,EAAE,KAAK,CAAC,CAAC;IACzE,CAAC;CACF"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@finos/legend-application-repl",
3
- "version": "1.0.8",
3
+ "version": "1.0.10",
4
4
  "description": "Legend REPL Grid client application core",
5
5
  "keywords": [
6
6
  "legend",
@@ -43,27 +43,28 @@
43
43
  "test:watch": "jest --watch"
44
44
  },
45
45
  "dependencies": {
46
- "@finos/legend-application": "16.0.3",
47
- "@finos/legend-art": "7.1.62",
48
- "@finos/legend-data-cube": "0.0.10",
49
- "@finos/legend-graph": "31.10.39",
50
- "@finos/legend-shared": "10.0.57",
46
+ "@finos/legend-application": "16.0.5",
47
+ "@finos/legend-art": "7.1.64",
48
+ "@finos/legend-data-cube": "0.0.12",
49
+ "@finos/legend-graph": "31.10.41",
50
+ "@finos/legend-shared": "10.0.58",
51
51
  "@types/react": "18.3.11",
52
- "@types/react-dom": "18.3.0",
53
- "mobx": "6.13.3",
52
+ "@types/react-dom": "18.3.1",
53
+ "mobx": "6.13.5",
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.3"
57
58
  },
58
59
  "devDependencies": {
59
- "@finos/legend-dev-utils": "2.1.25",
60
+ "@finos/legend-dev-utils": "2.1.26",
60
61
  "@jest/globals": "29.7.0",
61
62
  "cross-env": "7.0.3",
62
63
  "eslint": "9.12.0",
63
64
  "jest": "29.7.0",
64
65
  "npm-run-all": "4.1.5",
65
66
  "rimraf": "6.0.1",
66
- "sass": "1.79.4",
67
+ "sass": "1.80.2",
67
68
  "typescript": "5.6.3"
68
69
  },
69
70
  "peerDependencies": {
@@ -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, DataCubeProvider } from '@finos/legend-data-cube';
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 applicationStore = useApplicationStore<
44
+ const application = useApplicationStore<
44
45
  LegendREPLApplicationConfig,
45
46
  LegendApplicationPluginManager<LegendApplicationPlugin>
46
47
  >();
47
- const application = useMemo(
48
- () => new LegendREPLDataCubeApplicationEngine(applicationStore),
49
- [applicationStore],
50
- );
51
- const engine = new LegendREPLDataCubeEngine(
52
- application,
53
- new LegendREPLServerClient(
54
- new NetworkClient({
55
- baseUrl: applicationStore.config.useDynamicREPLServer
56
- ? window.location.origin +
57
- guaranteeNonNullable(applicationStore.config.baseAddress).replace(
58
- '/repl/',
59
- '',
60
- )
61
- : applicationStore.config.replUrl,
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
- application.blockNavigation(
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
- application.logWarning(
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
- application.unblockNavigation();
79
+ engine.unblockNavigation();
81
80
  };
82
- }, [application]);
81
+ }, [engine]);
83
82
 
84
83
  return (
85
- <DataCubeProvider application={application} engine={engine}>
86
- <DataCube />
87
- </DataCubeProvider>
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
- DataCubeGetBaseQueryResult,
21
- DEFAULT_ENABLE_DEBUG_MODE,
22
- DEFAULT_GRID_CLIENT_PURGE_CLOSED_ROW_NODES,
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 { guaranteeType } from '@finos/legend-shared';
39
- import type { LegendREPLDataCubeApplicationEngine } from './LegendREPLDataCubeApplicationEngine.js';
40
- import { LEGEND_REPL_SETTING_KEY } from '../__lib__/LegendREPLSetting.js';
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: LegendREPLDataCubeApplicationEngine;
55
+ readonly application: LegendREPLApplicationStore;
44
56
  readonly client: LegendREPLServerClient;
45
57
 
46
58
  constructor(
47
- application: LegendREPLDataCubeApplicationEngine,
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
- override setGridClientRowBuffer(value: number) {
82
- super.setGridClientRowBuffer(value);
83
- this.application.persistValue(
84
- LEGEND_REPL_SETTING_KEY.GRID_CLIENT_ROW_BUFFER,
85
- value,
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
- override setGridClientPurgeClosedRowNodes(value: boolean) {
90
- super.setGridClientPurgeClosedRowNodes(value);
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
- override setGridClientSuppressLargeDatasetWarning(value: boolean) {
98
- super.setGridClientSuppressLargeDatasetWarning(value);
99
- this.application.persistValue(
100
- LEGEND_REPL_SETTING_KEY.GRID_CLIENT_SUPPRESS_LARGE_DATASET_WARNING,
101
- value,
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
- async getInfrastructureInfo(): Promise<DataCubeInfrastructureInfo> {
106
- return this.client.getInfrastructureInfo();
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 getQueryTypeahead(
110
- code: string,
111
- query: V1_ValueSpecification,
112
- ): Promise<CompletionItem[]> {
113
- return this.client.getQueryTypeahead({
114
- code,
115
- baseQuery: V1_serializeValueSpecification(query, []),
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 parseQuery(
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.parseQuery({ code, returnSourceInformation }),
127
+ await this.client.parseValueSpecification({
128
+ code,
129
+ returnSourceInformation,
130
+ }),
125
131
  [],
126
132
  );
127
133
  }
128
134
 
129
- override getQueryCode(
130
- query: V1_ValueSpecification,
135
+ override getValueSpecificationCode(
136
+ value: V1_ValueSpecification,
131
137
  pretty?: boolean,
132
- ): Promise<string> {
133
- return this.client.getQueryCode({
134
- query: V1_serializeValueSpecification(query, []),
138
+ ) {
139
+ return this.client.getValueSpecificationCode({
140
+ value: V1_serializeValueSpecification(value, []),
135
141
  pretty,
136
142
  });
137
143
  }
138
144
 
139
- async getBaseQuery(): Promise<DataCubeGetBaseQueryResult> {
140
- return DataCubeGetBaseQueryResult.serialization.fromJson(
141
- await this.client.getBaseQuery(),
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
- ): Promise<RelationType> {
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(query: V1_Lambda): Promise<{
164
- result: TDSExecutionResult;
165
- executedQuery: string;
166
- executedSQL: string;
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: this.enableDebugMode,
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
+ }