@finos/legend-application-query 13.7.1 → 13.7.3

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 (47) hide show
  1. package/lib/application/LegendQueryApplicationConfig.d.ts +0 -1
  2. package/lib/application/LegendQueryApplicationConfig.d.ts.map +1 -1
  3. package/lib/application/LegendQueryApplicationConfig.js +0 -2
  4. package/lib/application/LegendQueryApplicationConfig.js.map +1 -1
  5. package/lib/components/Core_LegendQueryApplicationPlugin.d.ts +2 -3
  6. package/lib/components/Core_LegendQueryApplicationPlugin.d.ts.map +1 -1
  7. package/lib/components/Core_LegendQueryApplicationPlugin.js +4 -157
  8. package/lib/components/Core_LegendQueryApplicationPlugin.js.map +1 -1
  9. package/lib/components/QueryEditor.d.ts.map +1 -1
  10. package/lib/components/QueryEditor.js +2 -9
  11. package/lib/components/QueryEditor.js.map +1 -1
  12. package/lib/components/__test-utils__/QueryEditorComponentTestUtils.d.ts +2 -2
  13. package/lib/components/__test-utils__/QueryEditorComponentTestUtils.d.ts.map +1 -1
  14. package/lib/components/__test-utils__/QueryEditorComponentTestUtils.js +10 -38
  15. package/lib/components/__test-utils__/QueryEditorComponentTestUtils.js.map +1 -1
  16. package/lib/index.css +1 -1
  17. package/lib/package.json +1 -1
  18. package/lib/stores/LegendQueryApplicationPlugin.d.ts +3 -4
  19. package/lib/stores/LegendQueryApplicationPlugin.d.ts.map +1 -1
  20. package/lib/stores/LegendQueryApplicationPlugin.js +1 -0
  21. package/lib/stores/LegendQueryApplicationPlugin.js.map +1 -1
  22. package/lib/stores/QueryEditorStore.d.ts +2 -13
  23. package/lib/stores/QueryEditorStore.d.ts.map +1 -1
  24. package/lib/stores/QueryEditorStore.js +30 -135
  25. package/lib/stores/QueryEditorStore.js.map +1 -1
  26. package/lib/stores/data-space/DataSpaceQueryCreatorStore.d.ts +1 -2
  27. package/lib/stores/data-space/DataSpaceQueryCreatorStore.d.ts.map +1 -1
  28. package/lib/stores/data-space/DataSpaceQueryCreatorStore.js +12 -8
  29. package/lib/stores/data-space/DataSpaceQueryCreatorStore.js.map +1 -1
  30. package/lib/stores/data-space/DataSpaceQuerySetupState.d.ts +0 -1
  31. package/lib/stores/data-space/DataSpaceQuerySetupState.d.ts.map +1 -1
  32. package/lib/stores/data-space/DataSpaceQuerySetupState.js +0 -1
  33. package/lib/stores/data-space/DataSpaceQuerySetupState.js.map +1 -1
  34. package/lib/stores/data-space/DataSpaceTemplateQueryCreatorStore.d.ts +1 -3
  35. package/lib/stores/data-space/DataSpaceTemplateQueryCreatorStore.d.ts.map +1 -1
  36. package/lib/stores/data-space/DataSpaceTemplateQueryCreatorStore.js +24 -41
  37. package/lib/stores/data-space/DataSpaceTemplateQueryCreatorStore.js.map +1 -1
  38. package/package.json +9 -9
  39. package/src/application/LegendQueryApplicationConfig.ts +0 -3
  40. package/src/components/Core_LegendQueryApplicationPlugin.tsx +7 -281
  41. package/src/components/QueryEditor.tsx +1 -25
  42. package/src/components/__test-utils__/QueryEditorComponentTestUtils.tsx +24 -62
  43. package/src/stores/LegendQueryApplicationPlugin.tsx +5 -6
  44. package/src/stores/QueryEditorStore.ts +53 -254
  45. package/src/stores/data-space/DataSpaceQueryCreatorStore.ts +28 -17
  46. package/src/stores/data-space/DataSpaceQuerySetupState.ts +0 -1
  47. package/src/stores/data-space/DataSpaceTemplateQueryCreatorStore.ts +51 -73
@@ -21,12 +21,11 @@ import {
21
21
  QueryProjectCoordinates,
22
22
  extractElementNameFromPath,
23
23
  } from '@finos/legend-graph';
24
- import { type DepotServerClient } from '@finos/legend-server-depot';
25
24
  import {
26
- IllegalStateError,
27
- uuid,
28
- type GeneratorFn,
29
- } from '@finos/legend-shared';
25
+ type DepotServerClient,
26
+ StoreProjectData,
27
+ } from '@finos/legend-server-depot';
28
+ import { IllegalStateError, uuid } from '@finos/legend-shared';
30
29
  import {
31
30
  type QueryBuilderState,
32
31
  QueryBuilderDataBrowserWorkflow,
@@ -36,16 +35,18 @@ import {
36
35
  parseGACoordinates,
37
36
  } from '@finos/legend-storage';
38
37
  import {
39
- type QueryPersistConfiguration,
40
38
  QueryBuilderActionConfig_QueryApplication,
41
39
  QueryEditorStore,
40
+ type QueryPersistConfiguration,
42
41
  } from '../QueryEditorStore.js';
43
42
  import type { LegendQueryApplicationStore } from '../LegendQueryBaseStore.js';
44
43
  import {
45
- DataSpacePackageableElementExecutable,
44
+ DSL_DataSpace_getGraphManagerExtension,
46
45
  getDataSpace,
46
+ retrieveAnalyticsResultCache,
47
47
  getExecutionContextFromDataspaceExecutable,
48
48
  getQueryFromDataspaceExecutable,
49
+ DataSpacePackageableElementExecutable,
49
50
  } from '@finos/legend-extension-dsl-data-space/graph';
50
51
  import {
51
52
  type DataSpaceInfo,
@@ -89,84 +90,62 @@ export class DataSpaceTemplateQueryCreatorStore extends QueryEditorStore {
89
90
  };
90
91
  }
91
92
 
92
- override *buildGraph(): GeneratorFn<void> {
93
- // do nothing
94
- }
95
-
96
93
  async initializeQueryBuilderState(): Promise<QueryBuilderState> {
97
- const { dataSpaceAnalysisResult, isLightGraphEnabled } =
98
- await this.buildGraphAndDataspaceAnalyticsResult(
99
- this.groupId,
100
- this.artifactId,
101
- this.versionId,
102
- undefined,
103
- this.dataSpacePath,
104
- this.templateQueryId,
105
- );
106
94
  const dataSpace = getDataSpace(
107
95
  this.dataSpacePath,
108
96
  this.graphManagerState.graph,
109
97
  );
110
- let query;
111
- let executionContext;
112
- if (dataSpace.executables && dataSpace.executables.length > 0) {
113
- let template = dataSpace.executables.find(
114
- (ex) => ex.id === this.templateQueryId,
98
+ let template = dataSpace.executables?.find(
99
+ (executable) => executable.id === this.templateQueryId,
100
+ );
101
+ if (!template) {
102
+ template = dataSpace.executables?.find(
103
+ (executable) =>
104
+ executable instanceof DataSpacePackageableElementExecutable &&
105
+ executable.executable.value.path === this.templateQueryId,
115
106
  );
116
- if (!template) {
117
- template = dataSpace.executables.find(
118
- (executable) =>
119
- executable instanceof DataSpacePackageableElementExecutable &&
120
- executable.executable.value.path === this.templateQueryId,
121
- );
122
- }
123
- if (!template) {
124
- throw new IllegalStateError(
125
- `Can't find template query with id '${this.templateQueryId}'`,
126
- );
127
- }
128
- executionContext = getExecutionContextFromDataspaceExecutable(
129
- dataSpace,
130
- template,
107
+ }
108
+ if (!template) {
109
+ throw new IllegalStateError(
110
+ `Can't find template query with id '${this.templateQueryId}'`,
131
111
  );
132
- query = getQueryFromDataspaceExecutable(template, this.graphManagerState);
133
- this.templateQueryTitle = template.title;
134
- } else {
135
- let template = dataSpaceAnalysisResult?.executables.find(
136
- (executable) => executable.info?.id === this.templateQueryId,
112
+ }
113
+ const executionContext = getExecutionContextFromDataspaceExecutable(
114
+ dataSpace,
115
+ template,
116
+ );
117
+ if (!executionContext) {
118
+ throw new IllegalStateError(
119
+ `Can't find a correpsonding execution context`,
137
120
  );
138
- if (!template) {
139
- template = dataSpaceAnalysisResult?.executables.find(
140
- (executable) => executable.executable === this.templateQueryId,
141
- );
142
- }
143
- if (!template) {
144
- throw new IllegalStateError(
145
- `Can't find template query with id '${this.templateQueryId}'`,
146
- );
147
- }
148
- executionContext =
149
- template.info?.executionContextKey === undefined
150
- ? dataSpace.defaultExecutionContext
151
- : dataSpace.executionContexts.find(
152
- (ex) => ex.name === template.info?.executionContextKey,
153
- );
154
- if (template.info) {
155
- query = await this.graphManagerState.graphManager.pureCodeToLambda(
156
- template.info.query,
157
- );
158
- }
159
- this.templateQueryTitle = template.title;
160
121
  }
122
+ const query = getQueryFromDataspaceExecutable(
123
+ template,
124
+ this.graphManagerState,
125
+ );
161
126
  if (!query) {
162
127
  throw new IllegalStateError(
163
128
  `Can't fetch query from dataspace executable`,
164
129
  );
165
130
  }
166
- if (!executionContext) {
167
- throw new IllegalStateError(
168
- `Can't find a correpsonding execution context`,
131
+ this.templateQueryTitle = template.title;
132
+ let dataSpaceAnalysisResult;
133
+ try {
134
+ const project = StoreProjectData.serialization.fromJson(
135
+ await this.depotServerClient.getProject(this.groupId, this.artifactId),
136
+ );
137
+ dataSpaceAnalysisResult = await DSL_DataSpace_getGraphManagerExtension(
138
+ this.graphManagerState.graphManager,
139
+ ).retrieveDataSpaceAnalysisFromCache(() =>
140
+ retrieveAnalyticsResultCache(
141
+ project,
142
+ this.versionId,
143
+ dataSpace.path,
144
+ this.depotServerClient,
145
+ ),
169
146
  );
147
+ } catch {
148
+ // do nothing
170
149
  }
171
150
  const sourceInfo = {
172
151
  groupId: this.groupId,
@@ -181,7 +160,6 @@ export class DataSpaceTemplateQueryCreatorStore extends QueryEditorStore {
181
160
  new QueryBuilderActionConfig_QueryApplication(this),
182
161
  dataSpace,
183
162
  executionContext,
184
- isLightGraphEnabled,
185
163
  createDataSpaceDepoRepo(
186
164
  this,
187
165
  this.groupId,
@@ -189,7 +167,7 @@ export class DataSpaceTemplateQueryCreatorStore extends QueryEditorStore {
189
167
  this.versionId,
190
168
  undefined,
191
169
  ),
192
- async (dataSpaceInfo: DataSpaceInfo) => {
170
+ (dataSpaceInfo: DataSpaceInfo) => {
193
171
  this.applicationStore.notificationService.notifyWarning(
194
172
  `Can't switch data space to visit current template query`,
195
173
  );
@@ -202,7 +180,7 @@ export class DataSpaceTemplateQueryCreatorStore extends QueryEditorStore {
202
180
  sourceInfo,
203
181
  );
204
182
  queryBuilderState.setExecutionContext(executionContext);
205
- await queryBuilderState.propagateExecutionContextChange(true);
183
+ queryBuilderState.propagateExecutionContextChange(executionContext);
206
184
  queryBuilderState.initializeWithQuery(query);
207
185
  return queryBuilderState;
208
186
  }