@finos/legend-application-query 13.4.16 → 13.4.18

Sign up to get free protection for your applications and to get access to all the features.
Files changed (51) hide show
  1. package/lib/__lib__/LegendQueryEvent.d.ts +2 -1
  2. package/lib/__lib__/LegendQueryEvent.d.ts.map +1 -1
  3. package/lib/__lib__/LegendQueryEvent.js +1 -0
  4. package/lib/__lib__/LegendQueryEvent.js.map +1 -1
  5. package/lib/__lib__/LegendQueryUserDataHelper.d.ts +23 -3
  6. package/lib/__lib__/LegendQueryUserDataHelper.d.ts.map +1 -1
  7. package/lib/__lib__/LegendQueryUserDataHelper.js +94 -14
  8. package/lib/__lib__/LegendQueryUserDataHelper.js.map +1 -1
  9. package/lib/__lib__/LegendQueryUserDataSpaceHelper.d.ts +31 -0
  10. package/lib/__lib__/LegendQueryUserDataSpaceHelper.d.ts.map +1 -0
  11. package/lib/__lib__/LegendQueryUserDataSpaceHelper.js +54 -0
  12. package/lib/__lib__/LegendQueryUserDataSpaceHelper.js.map +1 -0
  13. package/lib/components/Core_LegendQueryApplicationPlugin.d.ts.map +1 -1
  14. package/lib/components/Core_LegendQueryApplicationPlugin.js +29 -11
  15. package/lib/components/Core_LegendQueryApplicationPlugin.js.map +1 -1
  16. package/lib/components/LegendQueryAppInfo.d.ts +21 -0
  17. package/lib/components/LegendQueryAppInfo.d.ts.map +1 -0
  18. package/lib/components/LegendQueryAppInfo.js +46 -0
  19. package/lib/components/LegendQueryAppInfo.js.map +1 -0
  20. package/lib/components/QueryEditor.d.ts.map +1 -1
  21. package/lib/components/QueryEditor.js +8 -7
  22. package/lib/components/QueryEditor.js.map +1 -1
  23. package/lib/components/data-space/DataSpaceQuerySetup.js +1 -1
  24. package/lib/components/data-space/DataSpaceQuerySetup.js.map +1 -1
  25. package/lib/index.css +2 -2
  26. package/lib/index.css.map +1 -1
  27. package/lib/package.json +3 -3
  28. package/lib/stores/QueryEditorStore.d.ts +3 -0
  29. package/lib/stores/QueryEditorStore.d.ts.map +1 -1
  30. package/lib/stores/QueryEditorStore.js +13 -1
  31. package/lib/stores/QueryEditorStore.js.map +1 -1
  32. package/lib/stores/data-space/DataSpaceQueryCreatorStore.d.ts +2 -0
  33. package/lib/stores/data-space/DataSpaceQueryCreatorStore.d.ts.map +1 -1
  34. package/lib/stores/data-space/DataSpaceQueryCreatorStore.js +21 -2
  35. package/lib/stores/data-space/DataSpaceQueryCreatorStore.js.map +1 -1
  36. package/lib/stores/data-space/DataSpaceQuerySetupState.d.ts +10 -2
  37. package/lib/stores/data-space/DataSpaceQuerySetupState.d.ts.map +1 -1
  38. package/lib/stores/data-space/DataSpaceQuerySetupState.js +53 -3
  39. package/lib/stores/data-space/DataSpaceQuerySetupState.js.map +1 -1
  40. package/package.json +13 -13
  41. package/src/__lib__/LegendQueryEvent.ts +2 -0
  42. package/src/__lib__/LegendQueryUserDataHelper.ts +192 -18
  43. package/src/__lib__/LegendQueryUserDataSpaceHelper.ts +98 -0
  44. package/src/components/Core_LegendQueryApplicationPlugin.tsx +35 -20
  45. package/src/components/LegendQueryAppInfo.tsx +153 -0
  46. package/src/components/QueryEditor.tsx +18 -9
  47. package/src/components/data-space/DataSpaceQuerySetup.tsx +1 -1
  48. package/src/stores/QueryEditorStore.ts +19 -0
  49. package/src/stores/data-space/DataSpaceQueryCreatorStore.ts +59 -0
  50. package/src/stores/data-space/DataSpaceQuerySetupState.ts +92 -4
  51. package/tsconfig.json +2 -0
@@ -22,13 +22,13 @@ import {
22
22
  } from '@finos/legend-server-depot';
23
23
  import type { GraphManagerState, RawLambda } from '@finos/legend-graph';
24
24
  import { type GenericLegendApplicationStore } from '@finos/legend-application';
25
- import { action, flow, makeObservable, observable } from 'mobx';
25
+ import { action, flow, flowResult, makeObservable, observable } from 'mobx';
26
26
  import {
27
27
  type QueryBuilderConfig,
28
28
  QueryBuilderState,
29
29
  QueryBuilderDataBrowserWorkflow,
30
30
  } from '@finos/legend-query-builder';
31
- import type { ProjectGAVCoordinates } from '@finos/legend-storage';
31
+ import type { Entity, ProjectGAVCoordinates } from '@finos/legend-storage';
32
32
  import {
33
33
  ActionState,
34
34
  assertErrorThrown,
@@ -51,7 +51,13 @@ import {
51
51
  import { generateDataSpaceQueryCreatorRoute } from '../../__lib__/DSL_DataSpace_LegendQueryNavigation.js';
52
52
  import { renderDataSpaceQuerySetupSetupPanelContent } from '../../components/data-space/DataSpaceQuerySetup.js';
53
53
  import { DataSpaceAdvancedSearchState } from '@finos/legend-extension-dsl-data-space/application-query';
54
+ import type { VisitedDataspace } from '../../__lib__/LegendQueryUserDataSpaceHelper.js';
55
+ import { LegendQueryUserDataHelper } from '../../__lib__/LegendQueryUserDataHelper.js';
54
56
 
57
+ type DataSpaceVisitedEntity = {
58
+ visited: VisitedDataspace;
59
+ entity: Entity;
60
+ };
55
61
  export class DataSpaceQuerySetupState extends QueryBuilderState {
56
62
  editorStore: QueryEditorStore;
57
63
  readonly depotServerClient: DepotServerClient;
@@ -107,7 +113,9 @@ export class DataSpaceQuerySetupState extends QueryBuilderState {
107
113
  advancedSearchState: observable,
108
114
  showAdvancedSearchPanel: action,
109
115
  hideAdvancedSearchPanel: action,
110
- loadDataSpaces: flow,
116
+ initializeDataSpaceSetup: flow,
117
+ redirectIfPossible: flow,
118
+ hyrdateVisitedDataSpace: flow,
111
119
  });
112
120
 
113
121
  this.editorStore = editorStore;
@@ -144,9 +152,29 @@ export class DataSpaceQuerySetupState extends QueryBuilderState {
144
152
  this.advancedSearchState = undefined;
145
153
  }
146
154
 
147
- *loadDataSpaces(): GeneratorFn<void> {
155
+ *initializeDataSpaceSetup(): GeneratorFn<void> {
148
156
  this.loadDataSpacesState.inProgress();
149
157
  try {
158
+ const hydrated = (yield flowResult(this.redirectIfPossible())) as
159
+ | DataSpaceVisitedEntity
160
+ | undefined;
161
+ if (hydrated) {
162
+ this.applicationStore.navigationService.navigator.goToLocation(
163
+ generateDataSpaceQueryCreatorRoute(
164
+ guaranteeNonNullable(hydrated.visited.groupId),
165
+ guaranteeNonNullable(hydrated.visited.artifactId),
166
+ hydrated.visited.versionId ?? LATEST_VERSION_ALIAS,
167
+ hydrated.visited.path,
168
+ hydrated.visited.execContext ??
169
+ (hydrated.entity.content.defaultExecutionContext as string),
170
+ undefined,
171
+ undefined,
172
+ ),
173
+ );
174
+ this.loadDataSpacesState.complete();
175
+ return;
176
+ }
177
+
150
178
  this.dataSpaces = (
151
179
  (yield this.depotServerClient.getEntitiesByClassifier(
152
180
  DATA_SPACE_ELEMENT_CLASSIFIER_PATH,
@@ -162,6 +190,66 @@ export class DataSpaceQuerySetupState extends QueryBuilderState {
162
190
  this.applicationStore.notificationService.notifyError(error);
163
191
  }
164
192
  }
193
+
194
+ *redirectIfPossible(): GeneratorFn<DataSpaceVisitedEntity | undefined> {
195
+ const visitedQueries =
196
+ LegendQueryUserDataHelper.getRecentlyVisitedDataSpaces(
197
+ this.applicationStore.userDataService,
198
+ );
199
+ let redirect: DataSpaceVisitedEntity | undefined = undefined;
200
+ for (let i = 0; i < visitedQueries.length; i++) {
201
+ const visited = visitedQueries[i];
202
+ if (visited) {
203
+ const hydrated = (yield flowResult(
204
+ this.hyrdateVisitedDataSpace(visited),
205
+ )) as DataSpaceVisitedEntity | undefined;
206
+ if (hydrated) {
207
+ redirect = hydrated;
208
+ break;
209
+ }
210
+ }
211
+ }
212
+ return redirect;
213
+ }
214
+
215
+ *hyrdateVisitedDataSpace(
216
+ visited: VisitedDataspace,
217
+ ): GeneratorFn<DataSpaceVisitedEntity | undefined> {
218
+ try {
219
+ const entity = (yield this.depotServerClient.getVersionEntity(
220
+ visited.groupId,
221
+ visited.artifactId,
222
+ visited.versionId ?? LATEST_VERSION_ALIAS,
223
+ visited.path,
224
+ )) as Entity;
225
+ const content = entity.content as {
226
+ executionContexts: { name: string }[];
227
+ };
228
+ if (visited.execContext) {
229
+ const found = content.executionContexts.find(
230
+ (e) => e.name === visited.execContext,
231
+ );
232
+ if (!found) {
233
+ visited.execContext = undefined;
234
+ return {
235
+ visited,
236
+ entity,
237
+ };
238
+ }
239
+ }
240
+ return {
241
+ visited,
242
+ entity,
243
+ };
244
+ } catch (error) {
245
+ assertErrorThrown(error);
246
+ LegendQueryUserDataHelper.removeRecentlyViewedDataSpace(
247
+ this.applicationStore.userDataService,
248
+ visited.id,
249
+ );
250
+ }
251
+ return undefined;
252
+ }
165
253
  }
166
254
 
167
255
  export class DataSpaceQuerySetupStore extends QueryEditorStore {
package/tsconfig.json CHANGED
@@ -57,6 +57,7 @@
57
57
  "./src/__lib__/LegendQueryNavigation.ts",
58
58
  "./src/__lib__/LegendQueryTelemetryHelper.ts",
59
59
  "./src/__lib__/LegendQueryUserDataHelper.ts",
60
+ "./src/__lib__/LegendQueryUserDataSpaceHelper.ts",
60
61
  "./src/application/Core_LegendQuery_LegendApplicationPlugin.ts",
61
62
  "./src/application/LegendQueryApplicationConfig.ts",
62
63
  "./src/application/LegendQueryPluginManager.ts",
@@ -79,6 +80,7 @@
79
80
  "./src/components/Core_LegendQueryApplicationPlugin.tsx",
80
81
  "./src/components/CreateMappingQuerySetup.tsx",
81
82
  "./src/components/EditExistingQuerySetup.tsx",
83
+ "./src/components/LegendQueryAppInfo.tsx",
82
84
  "./src/components/LegendQueryFrameworkProvider.tsx",
83
85
  "./src/components/LegendQueryWebApplication.tsx",
84
86
  "./src/components/LoadProjectServiceQuerySetup.tsx",