@finos/legend-application-query 13.8.8 → 13.8.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 (66) hide show
  1. package/lib/__lib__/LegendQueryNavigation.d.ts +16 -2
  2. package/lib/__lib__/LegendQueryNavigation.d.ts.map +1 -1
  3. package/lib/__lib__/LegendQueryNavigation.js +21 -2
  4. package/lib/__lib__/LegendQueryNavigation.js.map +1 -1
  5. package/lib/components/Core_LegendQueryApplicationPlugin.d.ts +2 -1
  6. package/lib/components/Core_LegendQueryApplicationPlugin.d.ts.map +1 -1
  7. package/lib/components/Core_LegendQueryApplicationPlugin.js +13 -0
  8. package/lib/components/Core_LegendQueryApplicationPlugin.js.map +1 -1
  9. package/lib/components/LegendQueryWebApplication.d.ts.map +1 -1
  10. package/lib/components/LegendQueryWebApplication.js +2 -1
  11. package/lib/components/LegendQueryWebApplication.js.map +1 -1
  12. package/lib/components/__test-utils__/QueryEditorComponentTestUtils.d.ts +14 -2
  13. package/lib/components/__test-utils__/QueryEditorComponentTestUtils.d.ts.map +1 -1
  14. package/lib/components/__test-utils__/QueryEditorComponentTestUtils.js +91 -5
  15. package/lib/components/__test-utils__/QueryEditorComponentTestUtils.js.map +1 -1
  16. package/lib/components/data-product/DataProductSampleQueryCreator.d.ts +19 -0
  17. package/lib/components/data-product/DataProductSampleQueryCreator.d.ts.map +1 -0
  18. package/lib/components/data-product/DataProductSampleQueryCreator.js +53 -0
  19. package/lib/components/data-product/DataProductSampleQueryCreator.js.map +1 -0
  20. package/lib/components/data-product/DataProductSampleQueryPanel.d.ts +23 -0
  21. package/lib/components/data-product/DataProductSampleQueryPanel.d.ts.map +1 -0
  22. package/lib/components/data-product/DataProductSampleQueryPanel.js +95 -0
  23. package/lib/components/data-product/DataProductSampleQueryPanel.js.map +1 -0
  24. package/lib/index.css +1 -1
  25. package/lib/light-mode.css +1 -1
  26. package/lib/package.json +1 -1
  27. package/lib/stores/BaseTemplateQueryCreatorStore.d.ts +68 -0
  28. package/lib/stores/BaseTemplateQueryCreatorStore.d.ts.map +1 -0
  29. package/lib/stores/BaseTemplateQueryCreatorStore.js +120 -0
  30. package/lib/stores/BaseTemplateQueryCreatorStore.js.map +1 -0
  31. package/lib/stores/QueryEditorStore.d.ts +2 -2
  32. package/lib/stores/QueryEditorStore.d.ts.map +1 -1
  33. package/lib/stores/QueryEditorStore.js +64 -30
  34. package/lib/stores/QueryEditorStore.js.map +1 -1
  35. package/lib/stores/data-product/DataProductSampleQueryCreatorStore.d.ts +37 -0
  36. package/lib/stores/data-product/DataProductSampleQueryCreatorStore.d.ts.map +1 -0
  37. package/lib/stores/data-product/DataProductSampleQueryCreatorStore.js +60 -0
  38. package/lib/stores/data-product/DataProductSampleQueryCreatorStore.js.map +1 -0
  39. package/lib/stores/data-product/query-builder/DataProductArtifactHelper.d.ts.map +1 -1
  40. package/lib/stores/data-product/query-builder/DataProductArtifactHelper.js +9 -0
  41. package/lib/stores/data-product/query-builder/DataProductArtifactHelper.js.map +1 -1
  42. package/lib/stores/data-product/query-builder/LegendQueryDataProductQueryBuilderState.d.ts +12 -2
  43. package/lib/stores/data-product/query-builder/LegendQueryDataProductQueryBuilderState.d.ts.map +1 -1
  44. package/lib/stores/data-product/query-builder/LegendQueryDataProductQueryBuilderState.js +40 -6
  45. package/lib/stores/data-product/query-builder/LegendQueryDataProductQueryBuilderState.js.map +1 -1
  46. package/lib/stores/data-space/DataProductQueryCreatorStore.js +1 -1
  47. package/lib/stores/data-space/DataProductQueryCreatorStore.js.map +1 -1
  48. package/lib/stores/data-space/DataSpaceTemplateQueryCreatorStore.d.ts +14 -18
  49. package/lib/stores/data-space/DataSpaceTemplateQueryCreatorStore.d.ts.map +1 -1
  50. package/lib/stores/data-space/DataSpaceTemplateQueryCreatorStore.js +15 -80
  51. package/lib/stores/data-space/DataSpaceTemplateQueryCreatorStore.js.map +1 -1
  52. package/package.json +13 -13
  53. package/src/__lib__/LegendQueryNavigation.ts +43 -5
  54. package/src/components/Core_LegendQueryApplicationPlugin.tsx +17 -0
  55. package/src/components/LegendQueryWebApplication.tsx +5 -0
  56. package/src/components/__test-utils__/QueryEditorComponentTestUtils.tsx +227 -3
  57. package/src/components/data-product/DataProductSampleQueryCreator.tsx +114 -0
  58. package/src/components/data-product/DataProductSampleQueryPanel.tsx +219 -0
  59. package/src/stores/BaseTemplateQueryCreatorStore.ts +203 -0
  60. package/src/stores/QueryEditorStore.ts +105 -51
  61. package/src/stores/data-product/DataProductSampleQueryCreatorStore.ts +135 -0
  62. package/src/stores/data-product/query-builder/DataProductArtifactHelper.ts +13 -0
  63. package/src/stores/data-product/query-builder/LegendQueryDataProductQueryBuilderState.ts +70 -7
  64. package/src/stores/data-space/DataProductQueryCreatorStore.ts +1 -1
  65. package/src/stores/data-space/DataSpaceTemplateQueryCreatorStore.ts +31 -126
  66. package/tsconfig.json +4 -0
@@ -22,6 +22,7 @@ import {
22
22
  type QueryBuilderActionConfig,
23
23
  type QueryBuilderConfig,
24
24
  type QueryBuilderWorkflowState,
25
+ LakehouseDataProductExecutionState,
25
26
  } from '@finos/legend-query-builder';
26
27
  import { renderLegendDataProductQueryBuilderSetupPanelContent } from '../../../components/data-product/LegendQueryDataProductQueryBuilder.js';
27
28
  import type { LegendQueryApplicationStore } from '../../LegendQueryBaseStore.js';
@@ -36,6 +37,7 @@ import type {
36
37
  } from '@finos/legend-storage';
37
38
  import {
38
39
  LegendSDLC,
40
+ type PackageableRuntime,
39
41
  type Class,
40
42
  type DataProduct,
41
43
  type GraphManagerState,
@@ -43,10 +45,12 @@ import {
43
45
  type NativeModelExecutionContext,
44
46
  type PackageableElement,
45
47
  type V1_DataProductArtifact,
48
+ type LakehouseAccessPoint,
46
49
  } from '@finos/legend-graph';
47
50
  import {
48
51
  generateDataProductNativeRoute,
49
52
  generateDataProductModelRoute,
53
+ generateDataProductLakehouseRoute,
50
54
  } from '../../../__lib__/LegendQueryNavigation.js';
51
55
  import { compareLabelFn } from '@finos/legend-art';
52
56
  import type { DataProductSelectorState } from '../../data-space/DataProductSelectorState.js';
@@ -62,6 +66,10 @@ export class LegendQueryDataProductQueryBuilderState extends DataProductQueryBui
62
66
  | ((val: ResolvedDataSpaceEntityWithOrigin) => void)
63
67
  | undefined;
64
68
  productSelectorState: DataProductSelectorState;
69
+ createLakehousePackageableRuntime: (
70
+ dataProductPath: string,
71
+ gav: { groupId: string; artifactId: string; versionId: string },
72
+ ) => Promise<PackageableRuntime>;
65
73
 
66
74
  constructor(
67
75
  applicationStore: LegendQueryApplicationStore,
@@ -70,17 +78,21 @@ export class LegendQueryDataProductQueryBuilderState extends DataProductQueryBui
70
78
  actionConfig: QueryBuilderActionConfig,
71
79
  dataProduct: DataProduct,
72
80
  artifact: V1_DataProductArtifact | undefined,
73
- executionState: NativeModelExecutionContext | ModelAccessPointGroup,
81
+ executionState:
82
+ | NativeModelExecutionContext
83
+ | ModelAccessPointGroup
84
+ | LakehouseAccessPoint,
74
85
  depotServerClient: DepotServerClient,
75
86
  project: ProjectGAVCoordinates,
76
87
  onDataProductChange: (val: DepotEntityWithOrigin) => Promise<void>,
88
+ createLakehousePackageableRuntime: (
89
+ dataProductPath: string,
90
+ gav: { groupId: string; artifactId: string; versionId: string },
91
+ ) => Promise<PackageableRuntime>,
77
92
  productSelectorState: DataProductSelectorState,
78
93
  onLegacyDataSpaceChange?:
79
94
  | ((val: ResolvedDataSpaceEntityWithOrigin) => void)
80
95
  | undefined,
81
- onExecutionContextChange?:
82
- | ((val: NativeModelExecutionContext) => void)
83
- | undefined,
84
96
  onClassChange?: ((val: Class) => void) | undefined,
85
97
  config?: QueryBuilderConfig | undefined,
86
98
  sourceInfo?: QueryableSourceInfo | undefined,
@@ -95,7 +107,6 @@ export class LegendQueryDataProductQueryBuilderState extends DataProductQueryBui
95
107
  executionState,
96
108
  undefined,
97
109
  onDataProductChange,
98
- onExecutionContextChange,
99
110
  onClassChange,
100
111
  config,
101
112
  sourceInfo,
@@ -104,6 +115,7 @@ export class LegendQueryDataProductQueryBuilderState extends DataProductQueryBui
104
115
  this.depotServerClient = depotServerClient;
105
116
  this.productSelectorState = productSelectorState;
106
117
  this.onLegacyDataSpaceChange = onLegacyDataSpaceChange;
118
+ this.createLakehousePackageableRuntime = createLakehousePackageableRuntime;
107
119
  }
108
120
 
109
121
  override handleDataProductChange(val: DepotEntityWithOrigin): void {
@@ -117,6 +129,46 @@ export class LegendQueryDataProductQueryBuilderState extends DataProductQueryBui
117
129
  }
118
130
  }
119
131
 
132
+ override async prepareAccessForExecution(): Promise<void> {
133
+ const origin = this.graphManagerState.graph.origin;
134
+ if (
135
+ this.executionState instanceof
136
+ ModelAccessPointDataProductExecutionState &&
137
+ origin instanceof LegendSDLC
138
+ ) {
139
+ const packageableRuntime = await this.createLakehousePackageableRuntime(
140
+ this.dataProduct.path,
141
+ {
142
+ groupId: origin.groupId,
143
+ artifactId: origin.artifactId,
144
+ versionId: origin.versionId,
145
+ },
146
+ );
147
+ this.graphManagerState.graph.addElement(packageableRuntime, '_internal_');
148
+
149
+ if (!this.executionState.adhocRuntime) {
150
+ this.executionState.withAdhocRuntime();
151
+ }
152
+
153
+ this.executionState.changeSelectedRuntime(packageableRuntime);
154
+ } else if (
155
+ this.executionState instanceof LakehouseDataProductExecutionState &&
156
+ origin instanceof LegendSDLC
157
+ ) {
158
+ const packageableRuntime = await this.createLakehousePackageableRuntime(
159
+ this.dataProduct.path,
160
+ {
161
+ groupId: origin.groupId,
162
+ artifactId: origin.artifactId,
163
+ versionId: origin.versionId,
164
+ },
165
+ );
166
+ this.graphManagerState.graph.addElement(packageableRuntime, '_internal_');
167
+ this.executionState.changeSelectedRuntime(packageableRuntime);
168
+ }
169
+ await super.prepareAccessForExecution();
170
+ }
171
+
120
172
  override get dataProductOptions(): DataProductOption[] {
121
173
  const graphOptions = super.dataProductOptions;
122
174
  const depotOptions: DataProductOption[] = [
@@ -154,8 +206,9 @@ export class LegendQueryDataProductQueryBuilderState extends DataProductQueryBui
154
206
 
155
207
  override get floatingExecutionElements(): PackageableElement[] | undefined {
156
208
  if (
157
- this.executionState instanceof
158
- ModelAccessPointDataProductExecutionState &&
209
+ (this.executionState instanceof
210
+ ModelAccessPointDataProductExecutionState ||
211
+ this.executionState instanceof LakehouseDataProductExecutionState) &&
159
212
  this.executionState.adhocRuntime &&
160
213
  this.graphManagerState.graph.origin !== undefined &&
161
214
  this.executionState.selectedRuntime !== undefined
@@ -189,6 +242,16 @@ export class LegendQueryDataProductQueryBuilderState extends DataProductQueryBui
189
242
  execState.exectionValue.id,
190
243
  ),
191
244
  );
245
+ } else if (execState instanceof LakehouseDataProductExecutionState) {
246
+ route = this.applicationStore.navigationService.navigator.generateAddress(
247
+ generateDataProductLakehouseRoute(
248
+ this.project.groupId,
249
+ this.project.artifactId,
250
+ this.project.versionId,
251
+ dataProduct.path,
252
+ execState.exectionValue.id,
253
+ ),
254
+ );
192
255
  } else {
193
256
  this.applicationStore.notificationService.notifyError(
194
257
  'Data Product link is not available for this execution type.',
@@ -155,7 +155,7 @@ export class QueryableDataProduct extends LegendQueryableElement {
155
155
  ) {
156
156
  super(groupId, artifactId, versionId);
157
157
  this.dataProductPath = dataProductPath;
158
- this.dataProductType = dataProductType;
158
+ this.dataProductType = dataProductType.toLowerCase();
159
159
  this.id = id;
160
160
  }
161
161
 
@@ -14,36 +14,14 @@
14
14
  * limitations under the License.
15
15
  */
16
16
 
17
- import {
18
- type Query,
19
- type QuerySearchSpecification,
20
- type RawLambda,
21
- type ValueSpecification,
22
- QueryProjectCoordinates,
23
- extractElementNameFromPath,
24
- } from '@finos/legend-graph';
25
- import { type DepotServerClient } from '@finos/legend-server-depot';
26
- import {
27
- assertErrorThrown,
28
- IllegalStateError,
29
- LogEvent,
30
- uuid,
31
- type GeneratorFn,
32
- } from '@finos/legend-shared';
17
+ import { IllegalStateError } from '@finos/legend-shared';
33
18
  import {
34
19
  type QueryBuilderState,
35
20
  QueryBuilderDataBrowserWorkflow,
36
21
  } from '@finos/legend-query-builder';
37
- import {
38
- type ProjectGAVCoordinates,
39
- parseGACoordinates,
40
- } from '@finos/legend-storage';
41
- import {
42
- type QueryPersistConfiguration,
43
- QueryBuilderActionConfig_QueryApplication,
44
- QueryEditorStore,
45
- } from '../QueryEditorStore.js';
22
+ import { QueryBuilderActionConfig_QueryApplication } from '../QueryEditorStore.js';
46
23
  import type { LegendQueryApplicationStore } from '../LegendQueryBaseStore.js';
24
+ import type { DepotServerClient } from '@finos/legend-server-depot';
47
25
  import { generateDataSpaceTemplateQueryCreatorRoute } from '../../__lib__/DSL_DataSpace_LegendQueryNavigation.js';
48
26
  import {
49
27
  DataSpacePackageableElementExecutable,
@@ -53,22 +31,14 @@ import {
53
31
  } from '@finos/legend-extension-dsl-data-space/graph';
54
32
  import {
55
33
  type ResolvedDataSpaceEntityWithOrigin,
56
- createQueryClassTaggedValue,
57
34
  createQueryDataSpaceTaggedValue,
58
35
  } from '@finos/legend-extension-dsl-data-space/application';
59
36
  import { LegendQueryDataSpaceQueryBuilderState } from './query-builder/LegendQueryDataSpaceQueryBuilderState.js';
60
37
  import { DataProductSelectorState } from './DataProductSelectorState.js';
61
- import { processQueryParameters } from '../../components/utils/QueryParameterUtils.js';
62
- import { LEGEND_QUERY_APP_EVENT } from '../../__lib__/LegendQueryEvent.js';
38
+ import { BaseTemplateQueryCreatorStore } from '../BaseTemplateQueryCreatorStore.js';
63
39
 
64
- export class DataSpaceTemplateQueryCreatorStore extends QueryEditorStore {
65
- readonly groupId: string;
66
- readonly artifactId: string;
67
- readonly versionId: string;
40
+ export class DataSpaceTemplateQueryCreatorStore extends BaseTemplateQueryCreatorStore {
68
41
  readonly dataSpacePath: string;
69
- readonly templateQueryId: string;
70
- templateQueryTitle?: string;
71
- urlQueryParamValues: Record<string, string> | undefined;
72
42
 
73
43
  constructor(
74
44
  applicationStore: LegendQueryApplicationStore,
@@ -80,22 +50,16 @@ export class DataSpaceTemplateQueryCreatorStore extends QueryEditorStore {
80
50
  templateQueryId: string,
81
51
  urlQueryParamValues: Record<string, string> | undefined,
82
52
  ) {
83
- super(applicationStore, depotServerClient);
84
-
85
- this.groupId = groupId;
86
- this.artifactId = artifactId;
87
- this.versionId = versionId;
53
+ super(
54
+ applicationStore,
55
+ depotServerClient,
56
+ groupId,
57
+ artifactId,
58
+ versionId,
59
+ templateQueryId,
60
+ urlQueryParamValues,
61
+ );
88
62
  this.dataSpacePath = dataSpacePath;
89
- this.templateQueryId = templateQueryId;
90
- this.urlQueryParamValues = urlQueryParamValues;
91
- }
92
-
93
- getProjectInfo(): ProjectGAVCoordinates {
94
- return {
95
- groupId: this.groupId,
96
- artifactId: this.artifactId,
97
- versionId: this.versionId,
98
- };
99
63
  }
100
64
 
101
65
  override getEditorRoute(): string {
@@ -108,8 +72,22 @@ export class DataSpaceTemplateQueryCreatorStore extends QueryEditorStore {
108
72
  );
109
73
  }
110
74
 
111
- override *buildGraph(): GeneratorFn<void> {
112
- // do nothing
75
+ override getEntityPath(): string {
76
+ return this.dataSpacePath;
77
+ }
78
+
79
+ override getSearchTaggedValues(): {
80
+ profile: string;
81
+ tag: string;
82
+ value: string;
83
+ }[] {
84
+ return [createQueryDataSpaceTaggedValue(this.dataSpacePath)];
85
+ }
86
+
87
+ override getQueryDecoratorTaggedValues():
88
+ | { profile: string; tag: string; value: string }[]
89
+ | undefined {
90
+ return undefined;
113
91
  }
114
92
 
115
93
  async initializeQueryBuilderState(): Promise<QueryBuilderState> {
@@ -232,81 +210,8 @@ export class DataSpaceTemplateQueryCreatorStore extends QueryEditorStore {
232
210
  queryBuilderState.setExecutionContext(executionContext);
233
211
  await queryBuilderState.propagateExecutionContextChange(true);
234
212
 
235
- let defaultParameters: Map<string, ValueSpecification> | undefined =
236
- undefined;
237
- const processedQueryParamValues = processQueryParameters(
238
- query,
239
- undefined,
240
- this.urlQueryParamValues,
241
- this.graphManagerState,
242
- );
243
- if (processedQueryParamValues?.size) {
244
- try {
245
- defaultParameters =
246
- await this.graphManagerState.graphManager.pureCodeToValueSpecifications(
247
- processedQueryParamValues,
248
- this.graphManagerState.graph,
249
- );
250
- } catch (error) {
251
- assertErrorThrown(error);
252
- this.applicationStore.logService.error(
253
- LogEvent.create(LEGEND_QUERY_APP_EVENT.GENERIC_FAILURE),
254
- `Error resolving preset query param values: ${error.message}`,
255
- );
256
- }
257
- }
213
+ const defaultParameters = await this.resolveDefaultParameters(query);
258
214
  queryBuilderState.initializeWithQuery(query, defaultParameters);
259
215
  return queryBuilderState;
260
216
  }
261
-
262
- getPersistConfiguration(
263
- lambda: RawLambda,
264
- options?: { update?: boolean | undefined },
265
- ): QueryPersistConfiguration {
266
- return {
267
- defaultName: options?.update
268
- ? `${extractElementNameFromPath(this.dataSpacePath)}`
269
- : `New Query for ${extractElementNameFromPath(this.dataSpacePath)}[${
270
- this.templateQueryId
271
- }]`,
272
- decorator: (query: Query): void => {
273
- query.id = uuid();
274
- query.groupId = this.groupId;
275
- query.artifactId = this.artifactId;
276
- query.versionId = this.versionId;
277
- if (this.queryBuilderState?.sourceClass) {
278
- query.taggedValues = [
279
- createQueryClassTaggedValue(
280
- this.queryBuilderState.sourceClass.path,
281
- ),
282
- ];
283
- }
284
- },
285
- };
286
- }
287
-
288
- override decorateSearchSpecification(
289
- val: QuerySearchSpecification,
290
- ): QuerySearchSpecification {
291
- const currentProjectCoordinates = new QueryProjectCoordinates();
292
- currentProjectCoordinates.groupId = this.groupId;
293
- currentProjectCoordinates.artifactId = this.artifactId;
294
- val.projectCoordinates = [
295
- // either get queries for the current project
296
- currentProjectCoordinates,
297
- // or any of its dependencies
298
- ...Array.from(
299
- this.graphManagerState.graph.dependencyManager.projectDependencyModelsIndex.keys(),
300
- ).map((dependencyKey) => {
301
- const { groupId, artifactId } = parseGACoordinates(dependencyKey);
302
- const coordinates = new QueryProjectCoordinates();
303
- coordinates.groupId = groupId;
304
- coordinates.artifactId = artifactId;
305
- return coordinates;
306
- }),
307
- ];
308
- val.taggedValues = [createQueryDataSpaceTaggedValue(this.dataSpacePath)];
309
- val.combineTaggedValuesCondition = true;
310
- return val;
311
- }
312
217
  }
package/tsconfig.json CHANGED
@@ -67,6 +67,7 @@
67
67
  "./src/components/data-product/QueryDataProductUtil.ts",
68
68
  "./src/components/data-space/QueryDataSpaceUtil.ts",
69
69
  "./src/components/utils/QueryParameterUtils.ts",
70
+ "./src/stores/BaseTemplateQueryCreatorStore.ts",
70
71
  "./src/stores/CloneServiceQuerySetupStore.ts",
71
72
  "./src/stores/CreateMappingQuerySetupStore.ts",
72
73
  "./src/stores/EditExistingQuerySetupStore.ts",
@@ -78,6 +79,7 @@
78
79
  "./src/stores/UpdateExistingServiceQuerySetupStore.ts",
79
80
  "./src/stores/__test-utils__/LegendQueryApplicationTestUtils.ts",
80
81
  "./src/stores/data-cube/ExistingQueryDataCubeViewer.ts",
82
+ "./src/stores/data-product/DataProductSampleQueryCreatorStore.ts",
81
83
  "./src/stores/data-product/query-builder/DataProductArtifactHelper.ts",
82
84
  "./src/stores/data-product/query-builder/LegendQueryDataProductQueryBuilderState.ts",
83
85
  "./src/stores/data-space/DataProductQueryCreatorStore.ts",
@@ -105,6 +107,8 @@
105
107
  "./src/components/data-cube/ExistingQueryDataCubeViewer.tsx",
106
108
  "./src/components/data-cube/ExistingQueryEditorStoreProviderProvider.tsx",
107
109
  "./src/components/data-product/DataProductInfo.tsx",
110
+ "./src/components/data-product/DataProductSampleQueryCreator.tsx",
111
+ "./src/components/data-product/DataProductSampleQueryPanel.tsx",
108
112
  "./src/components/data-product/LegendQueryDataProductQueryBuilder.tsx",
109
113
  "./src/components/data-space/DataProductQueryCreator.tsx",
110
114
  "./src/components/data-space/DataSpaceInfo.tsx",