@finos/legend-application-data-cube 0.1.7 → 0.1.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.
Files changed (62) hide show
  1. package/lib/components/LegendDataCubeWebApplication.js +1 -1
  2. package/lib/components/LegendDataCubeWebApplication.js.map +1 -1
  3. package/lib/components/query-builder/LegendDataCubeNewQueryBuilder.d.ts +1 -4
  4. package/lib/components/query-builder/LegendDataCubeNewQueryBuilder.d.ts.map +1 -1
  5. package/lib/components/query-builder/LegendDataCubeNewQueryBuilder.js +5 -4
  6. package/lib/components/query-builder/LegendDataCubeNewQueryBuilder.js.map +1 -1
  7. package/lib/components/query-builder/LegendDataCubeQueryBuilder.d.ts.map +1 -1
  8. package/lib/components/query-builder/LegendDataCubeQueryBuilder.js +27 -33
  9. package/lib/components/query-builder/LegendDataCubeQueryBuilder.js.map +1 -1
  10. package/lib/components/query-builder/LegendDataCubeQueryLoader.d.ts.map +1 -1
  11. package/lib/components/query-builder/LegendDataCubeQueryLoader.js +5 -7
  12. package/lib/components/query-builder/LegendDataCubeQueryLoader.js.map +1 -1
  13. package/lib/components/query-builder/LegendDataCubeQuerySaver.d.ts.map +1 -1
  14. package/lib/components/query-builder/LegendDataCubeQuerySaver.js +4 -4
  15. package/lib/components/query-builder/LegendDataCubeQuerySaver.js.map +1 -1
  16. package/lib/components/query-builder/source-builder/LegendQueryDataCubeSourceBuilder.d.ts.map +1 -1
  17. package/lib/components/query-builder/source-builder/LegendQueryDataCubeSourceBuilder.js +7 -7
  18. package/lib/components/query-builder/source-builder/LegendQueryDataCubeSourceBuilder.js.map +1 -1
  19. package/lib/index.css +1 -1
  20. package/lib/package.json +3 -3
  21. package/lib/stores/LegendDataCubeBaseStore.d.ts +5 -3
  22. package/lib/stores/LegendDataCubeBaseStore.d.ts.map +1 -1
  23. package/lib/stores/LegendDataCubeBaseStore.js +16 -9
  24. package/lib/stores/LegendDataCubeBaseStore.js.map +1 -1
  25. package/lib/stores/LegendDataCubeDataCubeEngine.d.ts +10 -18
  26. package/lib/stores/LegendDataCubeDataCubeEngine.d.ts.map +1 -1
  27. package/lib/stores/LegendDataCubeDataCubeEngine.js +57 -56
  28. package/lib/stores/LegendDataCubeDataCubeEngine.js.map +1 -1
  29. package/lib/stores/query-builder/LegendDataCubeNewQueryState.d.ts +5 -6
  30. package/lib/stores/query-builder/LegendDataCubeNewQueryState.d.ts.map +1 -1
  31. package/lib/stores/query-builder/LegendDataCubeNewQueryState.js +17 -15
  32. package/lib/stores/query-builder/LegendDataCubeNewQueryState.js.map +1 -1
  33. package/lib/stores/query-builder/LegendDataCubeQueryBuilderStore.d.ts +11 -4
  34. package/lib/stores/query-builder/LegendDataCubeQueryBuilderStore.d.ts.map +1 -1
  35. package/lib/stores/query-builder/LegendDataCubeQueryBuilderStore.js +21 -13
  36. package/lib/stores/query-builder/LegendDataCubeQueryBuilderStore.js.map +1 -1
  37. package/lib/stores/query-builder/LegendDataCubeQueryLoaderState.d.ts +4 -5
  38. package/lib/stores/query-builder/LegendDataCubeQueryLoaderState.d.ts.map +1 -1
  39. package/lib/stores/query-builder/LegendDataCubeQueryLoaderState.js +18 -17
  40. package/lib/stores/query-builder/LegendDataCubeQueryLoaderState.js.map +1 -1
  41. package/lib/stores/query-builder/source-builder/LegendDataCubeSourceBuilderState.d.ts +3 -4
  42. package/lib/stores/query-builder/source-builder/LegendDataCubeSourceBuilderState.d.ts.map +1 -1
  43. package/lib/stores/query-builder/source-builder/LegendDataCubeSourceBuilderState.js +5 -5
  44. package/lib/stores/query-builder/source-builder/LegendDataCubeSourceBuilderState.js.map +1 -1
  45. package/lib/stores/query-builder/source-builder/LegendQueryDataCubeSourceBuilderState.d.ts +9 -4
  46. package/lib/stores/query-builder/source-builder/LegendQueryDataCubeSourceBuilderState.d.ts.map +1 -1
  47. package/lib/stores/query-builder/source-builder/LegendQueryDataCubeSourceBuilderState.js +15 -9
  48. package/lib/stores/query-builder/source-builder/LegendQueryDataCubeSourceBuilderState.js.map +1 -1
  49. package/package.json +12 -12
  50. package/src/components/LegendDataCubeWebApplication.tsx +1 -1
  51. package/src/components/query-builder/LegendDataCubeNewQueryBuilder.tsx +77 -80
  52. package/src/components/query-builder/LegendDataCubeQueryBuilder.tsx +65 -130
  53. package/src/components/query-builder/LegendDataCubeQueryLoader.tsx +6 -7
  54. package/src/components/query-builder/LegendDataCubeQuerySaver.tsx +10 -4
  55. package/src/components/query-builder/source-builder/LegendQueryDataCubeSourceBuilder.tsx +10 -8
  56. package/src/stores/LegendDataCubeBaseStore.ts +32 -13
  57. package/src/stores/LegendDataCubeDataCubeEngine.ts +80 -85
  58. package/src/stores/query-builder/LegendDataCubeNewQueryState.tsx +30 -16
  59. package/src/stores/query-builder/LegendDataCubeQueryBuilderStore.tsx +32 -21
  60. package/src/stores/query-builder/LegendDataCubeQueryLoaderState.tsx +25 -23
  61. package/src/stores/query-builder/source-builder/LegendDataCubeSourceBuilderState.ts +9 -6
  62. package/src/stores/query-builder/source-builder/LegendQueryDataCubeSourceBuilderState.ts +31 -13
@@ -62,21 +62,14 @@ import {
62
62
  LogEvent,
63
63
  UnsupportedOperationError,
64
64
  type PlainObject,
65
- type DocumentationEntry,
66
65
  assertErrorThrown,
67
66
  NetworkClientError,
68
67
  HttpStatus,
69
68
  getNonNullableEntry,
70
69
  assertType,
71
70
  } from '@finos/legend-shared';
72
- import type {
73
- LegendDataCubeApplicationStore,
74
- LegendDataCubeBaseStore,
75
- } from './LegendDataCubeBaseStore.js';
76
- import {
77
- APPLICATION_EVENT,
78
- shouldDisplayVirtualAssistantDocumentationEntry,
79
- } from '@finos/legend-application';
71
+ import type { LegendDataCubeApplicationStore } from './LegendDataCubeBaseStore.js';
72
+ import { APPLICATION_EVENT } from '@finos/legend-application';
80
73
  import {
81
74
  LEGEND_QUERY_DATA_CUBE_SOURCE_TYPE,
82
75
  LegendQueryDataCubeSource,
@@ -89,18 +82,23 @@ import {
89
82
  } from '@finos/legend-server-depot';
90
83
 
91
84
  export class LegendDataCubeDataCubeEngine extends DataCubeEngine {
92
- readonly application: LegendDataCubeApplicationStore;
93
- readonly graphManager: V1_PureGraphManager;
94
- readonly depotServerClient: DepotServerClient;
95
- readonly engineServerClient: V1_EngineServerClient;
85
+ private readonly _application: LegendDataCubeApplicationStore;
86
+ private readonly _depotServerClient: DepotServerClient;
87
+ private readonly _engineServerClient: V1_EngineServerClient;
88
+ private readonly _graphManager: V1_PureGraphManager;
96
89
 
97
- constructor(baseStore: LegendDataCubeBaseStore) {
90
+ constructor(
91
+ application: LegendDataCubeApplicationStore,
92
+ depotServerClient: DepotServerClient,
93
+ engineServerClient: V1_EngineServerClient,
94
+ graphManager: V1_PureGraphManager,
95
+ ) {
98
96
  super();
99
97
 
100
- this.application = baseStore.application;
101
- this.graphManager = baseStore.graphManager;
102
- this.depotServerClient = baseStore.depotServerClient;
103
- this.engineServerClient = baseStore.engineServerClient;
98
+ this._application = application;
99
+ this._depotServerClient = depotServerClient;
100
+ this._engineServerClient = engineServerClient;
101
+ this._graphManager = graphManager;
104
102
  }
105
103
 
106
104
  // ---------------------------------- IMPLEMENTATION ----------------------------------
@@ -119,31 +117,41 @@ export class LegendDataCubeDataCubeEngine extends DataCubeEngine {
119
117
  rawSource.query,
120
118
  false,
121
119
  );
122
- source.columns = (
123
- await this.getQueryRelationType(_lambda([], [source.query]), source)
124
- ).columns;
120
+ try {
121
+ source.columns = (
122
+ await this._getLambdaRelationType(
123
+ _serializeValueSpecification(_lambda([], [source.query])),
124
+ source.model,
125
+ )
126
+ ).columns;
127
+ } catch (error) {
128
+ assertErrorThrown(error);
129
+ throw new Error(
130
+ `Can't get query result columns. Make sure the source query return a relation (i.e. typed TDS). Error: ${error.message}`,
131
+ );
132
+ }
125
133
  return source;
126
134
  }
127
135
  case LEGEND_QUERY_DATA_CUBE_SOURCE_TYPE: {
128
136
  const rawSource =
129
137
  RawLegendQueryDataCubeSource.serialization.fromJson(value);
130
- const queryInfo = await this.graphManager.getQueryInfo(
138
+ const queryInfo = await this._graphManager.getQueryInfo(
131
139
  rawSource.queryId,
132
140
  );
133
141
  const executionContext =
134
- await this.graphManager.resolveQueryInfoExecutionContext(
142
+ await this._graphManager.resolveQueryInfoExecutionContext(
135
143
  queryInfo,
136
144
  () =>
137
- this.depotServerClient.getVersionEntities(
145
+ this._depotServerClient.getVersionEntities(
138
146
  queryInfo.groupId,
139
147
  queryInfo.artifactId,
140
148
  queryInfo.versionId,
141
149
  ),
142
150
  );
143
- const query = new LegendQueryDataCubeSource();
144
- query.info = queryInfo;
145
- query.lambda = _deserializeLambda(
146
- await this.engineServerClient.grammarToJSON_lambda(
151
+ const source = new LegendQueryDataCubeSource();
152
+ source.info = queryInfo;
153
+ source.lambda = _deserializeLambda(
154
+ await this._engineServerClient.grammarToJSON_lambda(
147
155
  queryInfo.content,
148
156
  '',
149
157
  undefined,
@@ -151,9 +159,9 @@ export class LegendDataCubeDataCubeEngine extends DataCubeEngine {
151
159
  false,
152
160
  ),
153
161
  );
154
- query.mapping = executionContext.mapping;
155
- query.runtime = executionContext.runtime;
156
- query.model = V1_serializePureModelContext(
162
+ source.mapping = executionContext.mapping;
163
+ source.runtime = executionContext.runtime;
164
+ source.model = V1_serializePureModelContext(
157
165
  new V1_PureModelContextPointer(
158
166
  undefined,
159
167
  new V1_LegendSDLC(
@@ -163,15 +171,22 @@ export class LegendDataCubeDataCubeEngine extends DataCubeEngine {
163
171
  ),
164
172
  ),
165
173
  );
166
- query.columns = (
167
- await this._getLambdaRelationType(
168
- _serializeValueSpecification(query.lambda),
169
- query.model,
170
- )
171
- ).columns;
172
- query.query = getNonNullableEntry(query.lambda.body, 0);
174
+ source.query = getNonNullableEntry(source.lambda.body, 0);
173
175
  // TODO: handle parameter values
174
- return query;
176
+ try {
177
+ source.columns = (
178
+ await this._getLambdaRelationType(
179
+ _serializeValueSpecification(source.lambda),
180
+ source.model,
181
+ )
182
+ ).columns;
183
+ } catch (error) {
184
+ assertErrorThrown(error);
185
+ throw new Error(
186
+ `Can't get query result columns. Make sure the saved query return a relation (i.e. typed TDS). Error: ${error.message}`,
187
+ );
188
+ }
189
+ return source;
175
190
  }
176
191
  default:
177
192
  throw new UnsupportedOperationError(
@@ -194,14 +209,14 @@ export class LegendDataCubeDataCubeEngine extends DataCubeEngine {
194
209
  : codeBlock;
195
210
  if (source instanceof AdhocQueryDataCubeSource) {
196
211
  return (
197
- await this.engineServerClient.completeCode({
212
+ await this._engineServerClient.completeCode({
198
213
  codeBlock,
199
214
  model: source.model,
200
215
  })
201
216
  ).completions as CompletionItem[];
202
217
  } else if (source instanceof LegendQueryDataCubeSource) {
203
218
  return (
204
- await this.engineServerClient.completeCode({
219
+ await this._engineServerClient.completeCode({
205
220
  codeBlock,
206
221
  model: source.model,
207
222
  })
@@ -218,7 +233,7 @@ export class LegendDataCubeDataCubeEngine extends DataCubeEngine {
218
233
  ) {
219
234
  try {
220
235
  return _deserializeValueSpecification(
221
- await this.engineServerClient.grammarToJSON_valueSpecification(
236
+ await this._engineServerClient.grammarToJSON_valueSpecification(
222
237
  code,
223
238
  '',
224
239
  undefined,
@@ -246,24 +261,12 @@ export class LegendDataCubeDataCubeEngine extends DataCubeEngine {
246
261
  value: V1_ValueSpecification,
247
262
  pretty?: boolean | undefined,
248
263
  ) {
249
- return this.graphManager.valueSpecificationToPureCode(
264
+ return this._graphManager.valueSpecificationToPureCode(
250
265
  _serializeValueSpecification(value),
251
266
  pretty,
252
267
  );
253
268
  }
254
269
 
255
- // TODO: we could optimize this by synthesizing the base query from the source columns
256
- // instead of having to send the entire graph model
257
- override async getQueryRelationType(
258
- query: V1_Lambda,
259
- source: DataCubeSource,
260
- ) {
261
- return this._getQueryRelationType(
262
- _serializeValueSpecification(query),
263
- source,
264
- );
265
- }
266
-
267
270
  // TODO: we could optimize this by synthesizing the base query from the source columns
268
271
  // instead of having to send the entire graph model
269
272
  override async getQueryCodeRelationReturnType(
@@ -274,7 +277,7 @@ export class LegendDataCubeDataCubeEngine extends DataCubeEngine {
274
277
  const baseQueryCode = await this.getValueSpecificationCode(baseQuery);
275
278
  const columnOffset = baseQueryCode.length;
276
279
  try {
277
- const lambda = await this.engineServerClient.grammarToJSON_lambda(
280
+ const lambda = await this._engineServerClient.grammarToJSON_lambda(
278
281
  baseQueryCode + code,
279
282
  '',
280
283
  undefined,
@@ -379,7 +382,7 @@ export class LegendDataCubeDataCubeEngine extends DataCubeEngine {
379
382
  ) {
380
383
  const relationType = deserialize(
381
384
  V1_relationTypeModelSchema,
382
- await this.engineServerClient.lambdaRelationType({
385
+ await this._engineServerClient.lambdaRelationType({
383
386
  lambda,
384
387
  model,
385
388
  }),
@@ -399,7 +402,7 @@ export class LegendDataCubeDataCubeEngine extends DataCubeEngine {
399
402
  ): Promise<ExecutionResult> {
400
403
  return V1_buildExecutionResult(
401
404
  V1_deserializeExecutionResult(
402
- (await this.engineServerClient.runQuery({
405
+ (await this._engineServerClient.runQuery({
403
406
  clientVersion:
404
407
  // eslint-disable-next-line no-process-env
405
408
  process.env.NODE_ENV === 'development'
@@ -421,28 +424,8 @@ export class LegendDataCubeDataCubeEngine extends DataCubeEngine {
421
424
 
422
425
  // ---------------------------------- APPLICATION ----------------------------------
423
426
 
424
- override getDocumentationURL(): string | undefined {
425
- return this.application.documentationService.url;
426
- }
427
-
428
- override getDocumentationEntry(key: string) {
429
- return this.application.documentationService.getDocEntry(key);
430
- }
431
-
432
- override shouldDisplayDocumentationEntry(entry: DocumentationEntry) {
433
- return shouldDisplayVirtualAssistantDocumentationEntry(entry);
434
- }
435
-
436
- override openLink(url: string) {
437
- this.application.navigationService.navigator.visitAddress(url);
438
- }
439
-
440
- override sendTelemetry(event: string, data: PlainObject) {
441
- this.application.telemetryService.logEvent(event, data);
442
- }
443
-
444
427
  override logDebug(message: string, ...data: unknown[]) {
445
- this.application.logService.debug(
428
+ this._application.logService.debug(
446
429
  LogEvent.create(APPLICATION_EVENT.DEBUG),
447
430
  message,
448
431
  ...data,
@@ -452,14 +435,14 @@ export class LegendDataCubeDataCubeEngine extends DataCubeEngine {
452
435
  override debugProcess(processName: string, ...data: [string, unknown][]) {
453
436
  // eslint-disable-next-line no-process-env
454
437
  if (process.env.NODE_ENV === 'development') {
455
- this.application.logService.info(
438
+ this._application.logService.info(
456
439
  LogEvent.create(APPLICATION_EVENT.DEBUG),
457
440
  `\n------ START DEBUG PROCESS: ${processName} ------`,
458
441
  ...data.flatMap(([key, value]) => [`\n[${key.toUpperCase()}]:`, value]),
459
442
  `\n------- END DEBUG PROCESS: ${processName} -------\n\n`,
460
443
  );
461
444
  } else {
462
- this.application.logService.debug(
445
+ this._application.logService.debug(
463
446
  LogEvent.create(APPLICATION_EVENT.DEBUG),
464
447
  `\n------ START DEBUG PROCESS: ${processName} ------`,
465
448
  ...data.flatMap(([key, value]) => [`\n[${key.toUpperCase()}]:`, value]),
@@ -469,19 +452,19 @@ export class LegendDataCubeDataCubeEngine extends DataCubeEngine {
469
452
  }
470
453
 
471
454
  override logInfo(event: LogEvent, ...data: unknown[]) {
472
- this.application.logService.info(event, ...data);
455
+ this._application.logService.info(event, ...data);
473
456
  }
474
457
 
475
458
  override logWarning(event: LogEvent, ...data: unknown[]) {
476
- this.application.logService.warn(event, ...data);
459
+ this._application.logService.warn(event, ...data);
477
460
  }
478
461
 
479
462
  override logError(event: LogEvent, ...data: unknown[]) {
480
- this.application.logService.error(event, ...data);
463
+ this._application.logService.error(event, ...data);
481
464
  }
482
465
 
483
466
  override logUnhandledError(error: Error) {
484
- this.application.logUnhandledError(error);
467
+ this._application.logUnhandledError(error);
485
468
  }
486
469
 
487
470
  override logIllegalStateError(message: string, error?: Error) {
@@ -491,4 +474,16 @@ export class LegendDataCubeDataCubeEngine extends DataCubeEngine {
491
474
  error,
492
475
  );
493
476
  }
477
+
478
+ override getDocumentationEntry(key: string) {
479
+ return this._application.documentationService.getDocEntry(key);
480
+ }
481
+
482
+ override openLink(url: string) {
483
+ this._application.navigationService.navigator.visitAddress(url);
484
+ }
485
+
486
+ override sendTelemetry(event: string, data: PlainObject) {
487
+ this._application.telemetryService.logEvent(event, data);
488
+ }
494
489
  }
@@ -29,6 +29,7 @@ import {
29
29
  } from './source-builder/LegendDataCubeSourceBuilderState.js';
30
30
  import {
31
31
  _selectFunction,
32
+ type DataCubeAlertService,
32
33
  DataCubeQuery,
33
34
  DEFAULT_TOOL_PANEL_WINDOW_CONFIG,
34
35
  type DisplayState,
@@ -43,12 +44,14 @@ import {
43
44
  import { generateQueryBuilderRoute } from '../../__lib__/LegendDataCubeNavigation.js';
44
45
 
45
46
  export class LegendDataCubeNewQueryState {
46
- readonly application: LegendDataCubeApplicationStore;
47
- readonly store: LegendDataCubeQueryBuilderStore;
48
- readonly engine: LegendDataCubeDataCubeEngine;
49
- readonly display: DisplayState;
47
+ private readonly _application: LegendDataCubeApplicationStore;
48
+ private readonly _store: LegendDataCubeQueryBuilderStore;
49
+ private readonly _engine: LegendDataCubeDataCubeEngine;
50
+ private readonly _alertService: DataCubeAlertService;
50
51
 
51
52
  readonly finalizeState = ActionState.create();
53
+ readonly display: DisplayState;
54
+
52
55
  sourceBuilder: LegendDataCubeSourceBuilderState;
53
56
 
54
57
  constructor(store: LegendDataCubeQueryBuilderStore) {
@@ -57,12 +60,14 @@ export class LegendDataCubeNewQueryState {
57
60
  changeSourceBuilder: action,
58
61
  });
59
62
 
60
- this.application = store.application;
61
- this.store = store;
62
- this.engine = store.engine;
63
- this.display = this.engine.layout.newDisplay(
63
+ this._application = store.application;
64
+ this._store = store;
65
+ this._engine = store.engine;
66
+ this._alertService = store.alertService;
67
+
68
+ this.display = store.layoutService.newDisplay(
64
69
  'New Query',
65
- () => <LegendDataCubeNewQueryBuilder state={this} />,
70
+ () => <LegendDataCubeNewQueryBuilder />,
66
71
  {
67
72
  ...DEFAULT_TOOL_PANEL_WINDOW_CONFIG,
68
73
  width: 500,
@@ -89,9 +94,18 @@ export class LegendDataCubeNewQueryState {
89
94
  ): LegendDataCubeSourceBuilderState {
90
95
  switch (type) {
91
96
  case LegendDataCubeSourceBuilderType.LEGEND_QUERY:
92
- return new LegendQueryDataCubeSourceBuilderState(this);
97
+ return new LegendQueryDataCubeSourceBuilderState(
98
+ this._application,
99
+ this._engine,
100
+ this._store.engineServerClient,
101
+ this._store.graphManager,
102
+ this._alertService,
103
+ );
93
104
  case LegendDataCubeSourceBuilderType.ADHOC_QUERY:
94
- return new AdhocQueryDataCubeSourceBuilderState(this);
105
+ return new AdhocQueryDataCubeSourceBuilderState(
106
+ this._application,
107
+ this._engine,
108
+ );
95
109
  default:
96
110
  throw new UnsupportedOperationError(
97
111
  `Can't create source builder for unsupported type '${type}'`,
@@ -108,16 +122,16 @@ export class LegendDataCubeNewQueryState {
108
122
  try {
109
123
  const source = await this.sourceBuilder.build();
110
124
  const query = new DataCubeQuery();
111
- const processedSource = await this.engine.processQuerySource(source);
125
+ const processedSource = await this._engine.processQuerySource(source);
112
126
  query.source = source;
113
- query.query = await this.engine.getValueSpecificationCode(
127
+ query.query = await this._engine.getValueSpecificationCode(
114
128
  _selectFunction(processedSource.columns),
115
129
  );
116
130
 
117
- this.store.setBuilder(new LegendDataCubeQueryBuilderState(query));
131
+ this._store.setBuilder(new LegendDataCubeQueryBuilderState(query));
118
132
  // only update the route instead of reloading in case we are creating
119
133
  // a new query when we are editing another query
120
- this.application.navigationService.navigator.updateCurrentLocation(
134
+ this._application.navigationService.navigator.updateCurrentLocation(
121
135
  generateQueryBuilderRoute(null),
122
136
  );
123
137
 
@@ -130,7 +144,7 @@ export class LegendDataCubeNewQueryState {
130
144
  this.finalizeState.pass();
131
145
  } catch (error) {
132
146
  assertErrorThrown(error);
133
- this.engine.alertError(error, {
147
+ this._alertService.alertError(error, {
134
148
  message: `Query Creation Failure: ${error.message}`,
135
149
  });
136
150
  this.finalizeState.fail();
@@ -20,14 +20,20 @@ import type {
20
20
  LegendDataCubeBaseStore,
21
21
  } from '../LegendDataCubeBaseStore.js';
22
22
  import {
23
- DataCubeConfiguration,
23
+ type DataCubeAlertService,
24
+ type DataCubeAPI,
25
+ type DataCubeLayoutService,
26
+ type DataCubeTaskService,
24
27
  DataCubeQuery,
25
- DEFAULT_SMALL_ALERT_WINDOW_CONFIG,
26
- type DataCubeState,
28
+ DEFAULT_ALERT_WINDOW_CONFIG,
27
29
  type DisplayState,
28
30
  } from '@finos/legend-data-cube';
29
31
  import { LegendDataCubeNewQueryState } from './LegendDataCubeNewQueryState.js';
30
- import { PersistentDataCubeQuery } from '@finos/legend-graph';
32
+ import {
33
+ PersistentDataCubeQuery,
34
+ type V1_EngineServerClient,
35
+ type V1_PureGraphManager,
36
+ } from '@finos/legend-graph';
31
37
  import {
32
38
  ActionState,
33
39
  assertErrorThrown,
@@ -43,13 +49,14 @@ import {
43
49
  LegendDataCubeUserDataKey,
44
50
  RECENTLY_VIEWED_QUERIES_LIMIT,
45
51
  } from '../../__lib__/LegendDataCubeUserData.js';
52
+ import type { DepotServerClient } from '@finos/legend-server-depot';
46
53
 
47
54
  export class LegendDataCubeQueryBuilderState {
48
55
  uuid = uuid();
49
56
  startTime = Date.now();
50
57
  query!: DataCubeQuery;
51
58
  persistentQuery?: PersistentDataCubeQuery | undefined;
52
- dataCube?: DataCubeState | undefined;
59
+ dataCube?: DataCubeAPI | undefined;
53
60
 
54
61
  constructor(
55
62
  query: DataCubeQuery,
@@ -68,7 +75,7 @@ export class LegendDataCubeQueryBuilderState {
68
75
  this.persistentQuery = persistentQuery;
69
76
  }
70
77
 
71
- setDataCube(val: DataCubeState | undefined) {
78
+ setDataCube(val: DataCubeAPI | undefined) {
72
79
  this.dataCube = val;
73
80
  }
74
81
 
@@ -83,6 +90,12 @@ export class LegendDataCubeQueryBuilderStore {
83
90
  readonly application: LegendDataCubeApplicationStore;
84
91
  readonly baseStore: LegendDataCubeBaseStore;
85
92
  readonly engine: LegendDataCubeDataCubeEngine;
93
+ readonly depotServerClient: DepotServerClient;
94
+ readonly engineServerClient: V1_EngineServerClient;
95
+ readonly graphManager: V1_PureGraphManager;
96
+ readonly taskService: DataCubeTaskService;
97
+ readonly layoutService: DataCubeLayoutService;
98
+ readonly alertService: DataCubeAlertService;
86
99
 
87
100
  readonly newQueryState: LegendDataCubeNewQueryState;
88
101
 
@@ -102,14 +115,20 @@ export class LegendDataCubeQueryBuilderStore {
102
115
  this.application = baseStore.application;
103
116
  this.baseStore = baseStore;
104
117
  this.engine = baseStore.engine;
118
+ this.depotServerClient = baseStore.depotServerClient;
119
+ this.engineServerClient = baseStore.engineServerClient;
120
+ this.graphManager = baseStore.graphManager;
121
+ this.taskService = baseStore.taskService;
122
+ this.alertService = baseStore.alertService;
123
+ this.layoutService = baseStore.layoutService;
105
124
 
106
125
  this.newQueryState = new LegendDataCubeNewQueryState(this);
107
126
  this.loader = new LegendDataCubeQueryLoaderState(this);
108
- this.saverDisplay = this.engine.layout.newDisplay(
127
+ this.saverDisplay = this.layoutService.newDisplay(
109
128
  'Save Query',
110
129
  () => <LegendDataCubeQuerySaver />,
111
130
  {
112
- ...DEFAULT_SMALL_ALERT_WINDOW_CONFIG,
131
+ ...DEFAULT_ALERT_WINDOW_CONFIG,
113
132
  height: 140,
114
133
  },
115
134
  );
@@ -174,7 +193,7 @@ export class LegendDataCubeQueryBuilderStore {
174
193
  this.loadQueryState.pass();
175
194
  } catch (error) {
176
195
  assertErrorThrown(error);
177
- this.engine.alertError(error, {
196
+ this.alertService.alertError(error, {
178
197
  message: `Query Load Failure: ${error.message}`,
179
198
  });
180
199
  this.loadQueryState.fail();
@@ -183,19 +202,11 @@ export class LegendDataCubeQueryBuilderStore {
183
202
  }
184
203
 
185
204
  private async generatePersistentQuery(
186
- dataCube: DataCubeState,
205
+ api: DataCubeAPI,
187
206
  name: string,
188
207
  existingPersistentQuery?: PersistentDataCubeQuery | undefined,
189
208
  ) {
190
- const currentSnapshot = dataCube.view.snapshotManager.currentSnapshot;
191
-
192
- const query = new DataCubeQuery();
193
- query.source = dataCube.query.source;
194
- query.configuration = DataCubeConfiguration.serialization.fromJson(
195
- currentSnapshot.data.configuration,
196
- );
197
- query.query = await this.engine.getPartialQueryCode(currentSnapshot);
198
-
209
+ const query = await api.generateDataCubeQuery();
199
210
  let persistentQuery: PersistentDataCubeQuery;
200
211
  if (existingPersistentQuery) {
201
212
  persistentQuery = existingPersistentQuery.clone();
@@ -240,7 +251,7 @@ export class LegendDataCubeQueryBuilderStore {
240
251
  this.saveQueryState.pass();
241
252
  } catch (error) {
242
253
  assertErrorThrown(error);
243
- this.engine.alertError(error, {
254
+ this.alertService.alertError(error, {
244
255
  message: `Query Creation Failure: ${error.message}`,
245
256
  });
246
257
  this.saveQueryState.fail();
@@ -287,7 +298,7 @@ export class LegendDataCubeQueryBuilderStore {
287
298
  this.saveQueryState.pass();
288
299
  } catch (error) {
289
300
  assertErrorThrown(error);
290
- this.engine.alertError(error, {
301
+ this.alertService.alertError(error, {
291
302
  message: `Query Update Failure: ${error.message}`,
292
303
  });
293
304
  this.saveQueryState.fail();
@@ -23,13 +23,14 @@ import {
23
23
  type LightPersistentDataCubeQuery,
24
24
  QuerySearchSpecification,
25
25
  QuerySearchSortBy,
26
+ type V1_PureGraphManager,
26
27
  } from '@finos/legend-graph';
27
28
  import { ActionState, assertErrorThrown, LogEvent } from '@finos/legend-shared';
28
29
  import { makeObservable, observable, action } from 'mobx';
29
- import type { LegendDataCubeDataCubeEngine } from '../LegendDataCubeDataCubeEngine.js';
30
30
  import type { LegendDataCubeQueryBuilderStore } from './LegendDataCubeQueryBuilderStore.js';
31
31
  import { LegendDataCubeUserDataKey } from '../../__lib__/LegendDataCubeUserData.js';
32
32
  import {
33
+ type DataCubeAlertService,
33
34
  DEFAULT_TOOL_PANEL_WINDOW_CONFIG,
34
35
  type DisplayState,
35
36
  } from '@finos/legend-data-cube';
@@ -46,13 +47,15 @@ export enum DataCubeQuerySortByType {
46
47
  }
47
48
 
48
49
  export class LegendDataCubeQueryLoaderState {
49
- readonly application: GenericLegendApplicationStore;
50
- readonly store: LegendDataCubeQueryBuilderStore;
51
- readonly engine: LegendDataCubeDataCubeEngine;
52
- readonly display: DisplayState;
50
+ private readonly _application: GenericLegendApplicationStore;
51
+ private readonly _store: LegendDataCubeQueryBuilderStore;
52
+ private readonly _graphManager: V1_PureGraphManager;
53
+ private readonly _alertService: DataCubeAlertService;
53
54
 
55
+ readonly display: DisplayState;
54
56
  readonly searchState = ActionState.create();
55
57
  readonly finalizeState = ActionState.create();
58
+
56
59
  queries: LightPersistentDataCubeQuery[] = [];
57
60
  selectedQuery?: LightPersistentDataCubeQuery | undefined;
58
61
 
@@ -82,10 +85,12 @@ export class LegendDataCubeQueryLoaderState {
82
85
  setSelectedQuery: action,
83
86
  });
84
87
 
85
- this.application = store.application;
86
- this.store = store;
87
- this.engine = store.engine;
88
- this.display = this.engine.layout.newDisplay(
88
+ this._application = store.application;
89
+ this._store = store;
90
+ this._graphManager = store.graphManager;
91
+ this._alertService = store.alertService;
92
+
93
+ this.display = store.layoutService.newDisplay(
89
94
  'Load Query',
90
95
  () => <LegendDataCubeQueryLoader />,
91
96
  {
@@ -152,18 +157,17 @@ export class LegendDataCubeQueryLoaderState {
152
157
  // first, try to fetch recently viewed queries
153
158
  try {
154
159
  const recentlyViewedQueryIDs =
155
- this.store.getRecentlyViewedQueries();
160
+ this._store.getRecentlyViewedQueries();
156
161
  if (recentlyViewedQueryIDs.length) {
157
- defaultQueries =
158
- await this.engine.graphManager.getDataCubeQueries(
159
- recentlyViewedQueryIDs,
160
- );
162
+ defaultQueries = await this._graphManager.getDataCubeQueries(
163
+ recentlyViewedQueryIDs,
164
+ );
161
165
  }
162
166
  } catch (error) {
163
167
  assertErrorThrown(error);
164
168
  // if there's an error fetching recently viewed queries, most likely because
165
169
  // some queries have been removed, just remove them all from the cached user data
166
- this.application.userDataService.persistValue(
170
+ this._application.userDataService.persistValue(
167
171
  LegendDataCubeUserDataKey.RECENTLY_VIEWED_QUERIES,
168
172
  undefined,
169
173
  );
@@ -175,7 +179,7 @@ export class LegendDataCubeQueryLoaderState {
175
179
  DATA_CUBE_QUERY_LOADER_DEFAULT_QUERY_SEARCH_LIMIT;
176
180
  searchSpecification.showCurrentUserQueriesOnly = true;
177
181
  defaultQueries =
178
- await this.engine.graphManager.searchDataCubeQueries(
182
+ await this._graphManager.searchDataCubeQueries(
179
183
  searchSpecification,
180
184
  );
181
185
  }
@@ -183,7 +187,7 @@ export class LegendDataCubeQueryLoaderState {
183
187
  this.searchState.pass();
184
188
  } catch (error) {
185
189
  assertErrorThrown(error);
186
- this.engine.logError(
190
+ this._application.logService.error(
187
191
  LogEvent.create(APPLICATION_EVENT.GENERIC_FAILURE),
188
192
  error,
189
193
  );
@@ -208,9 +212,7 @@ export class LegendDataCubeQueryLoaderState {
208
212
  searchSpecification.sortByOption = querySearchSortBy;
209
213
  }
210
214
  this.setQueries(
211
- await this.engine.graphManager.searchDataCubeQueries(
212
- searchSpecification,
213
- ),
215
+ await this._graphManager.searchDataCubeQueries(searchSpecification),
214
216
  );
215
217
 
216
218
  // if sorting is not configured, sort by name
@@ -223,7 +225,7 @@ export class LegendDataCubeQueryLoaderState {
223
225
  this.searchState.pass();
224
226
  } catch (error) {
225
227
  assertErrorThrown(error);
226
- this.engine.alertError(error, {
228
+ this._alertService.alertError(error, {
227
229
  message: `Query Search Failure: ${error.message}`,
228
230
  });
229
231
  this.searchState.fail();
@@ -239,7 +241,7 @@ export class LegendDataCubeQueryLoaderState {
239
241
  try {
240
242
  // just simply change the route here and the new query ID will get picked up
241
243
  // and handled by the query builder to load the new query.
242
- this.application.navigationService.navigator.updateCurrentLocation(
244
+ this._application.navigationService.navigator.updateCurrentLocation(
243
245
  generateQueryBuilderRoute(this.selectedQuery.id),
244
246
  );
245
247
 
@@ -249,7 +251,7 @@ export class LegendDataCubeQueryLoaderState {
249
251
  this.finalizeState.pass();
250
252
  } catch (error) {
251
253
  assertErrorThrown(error);
252
- this.engine.alertError(error, {
254
+ this._alertService.alertError(error, {
253
255
  message: `Query Load Failure: ${error.message}`,
254
256
  });
255
257
  this.finalizeState.fail();