@finos/legend-query-builder 4.19.15 → 4.19.17

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 (27) hide show
  1. package/lib/components/QueryBuilderSideBar.d.ts +3 -3
  2. package/lib/components/QueryBuilderSideBar.d.ts.map +1 -1
  3. package/lib/components/QueryBuilderSideBar.js +5 -3
  4. package/lib/components/QueryBuilderSideBar.js.map +1 -1
  5. package/lib/data-access-overview.css +1 -1
  6. package/lib/index.css +1 -1
  7. package/lib/index.d.ts +1 -1
  8. package/lib/index.d.ts.map +1 -1
  9. package/lib/index.js +1 -1
  10. package/lib/index.js.map +1 -1
  11. package/lib/package.json +1 -1
  12. package/lib/stores/__test-utils__/TEST_DATA__QueryBuilder_Accessors.d.ts +82 -0
  13. package/lib/stores/__test-utils__/TEST_DATA__QueryBuilder_Accessors.d.ts.map +1 -1
  14. package/lib/stores/__test-utils__/TEST_DATA__QueryBuilder_Accessors.js +97 -0
  15. package/lib/stores/__test-utils__/TEST_DATA__QueryBuilder_Accessors.js.map +1 -1
  16. package/lib/stores/workflows/accessor/AccessorQueryBuilderHelper.js +3 -3
  17. package/lib/stores/workflows/accessor/AccessorQueryBuilderHelper.js.map +1 -1
  18. package/lib/stores/workflows/dataProduct/DataProductQueryBuilderState.d.ts +7 -30
  19. package/lib/stores/workflows/dataProduct/DataProductQueryBuilderState.d.ts.map +1 -1
  20. package/lib/stores/workflows/dataProduct/DataProductQueryBuilderState.js +35 -117
  21. package/lib/stores/workflows/dataProduct/DataProductQueryBuilderState.js.map +1 -1
  22. package/package.json +11 -11
  23. package/src/components/QueryBuilderSideBar.tsx +9 -4
  24. package/src/index.ts +0 -2
  25. package/src/stores/__test-utils__/TEST_DATA__QueryBuilder_Accessors.ts +99 -0
  26. package/src/stores/workflows/accessor/AccessorQueryBuilderHelper.ts +3 -3
  27. package/src/stores/workflows/dataProduct/DataProductQueryBuilderState.ts +44 -174
@@ -21,13 +21,12 @@ import {
21
21
  type V1_DataProductArtifact,
22
22
  type V1_DataProductInfo,
23
23
  ModelAccessPointGroup,
24
- NativeModelExecutionContext,
25
24
  CORE_PURE_PATH,
26
- type NativeModelAccess,
27
25
  type Mapping,
28
26
  type DataProductElementScope,
29
27
  PackageableRuntime,
30
28
  resolveUsableDataProductClasses,
29
+ LakehouseBaseRuntime,
31
30
  LakehouseRuntime,
32
31
  type LambdaFunction,
33
32
  attachRuntimeFromQuery,
@@ -37,7 +36,6 @@ import {
37
36
  resolveDataProductExecutionState,
38
37
  RuntimePointer,
39
38
  type QueryExecutionContext,
40
- QueryDataProductNativeExecutionContext,
41
39
  QueryDataProductModelAccessExecutionContext,
42
40
  QueryDataProductLakehouseExecutionContext,
43
41
  LakehouseAccessPoint,
@@ -68,7 +66,6 @@ import {
68
66
  ActionState,
69
67
  assertErrorThrown,
70
68
  filterByType,
71
- guaranteeNonNullable,
72
69
  type GeneratorFn,
73
70
  } from '@finos/legend-shared';
74
71
  import { action, computed, flow, makeObservable, observable } from 'mobx';
@@ -152,18 +149,6 @@ export const buildDataProductOption = (
152
149
  value,
153
150
  });
154
151
 
155
- export const buildExecOptions = (
156
- val: NativeModelExecutionContext,
157
- ): {
158
- label: string;
159
- value: NativeModelExecutionContext;
160
- } => {
161
- return {
162
- label: val.key,
163
- value: val,
164
- };
165
- };
166
-
167
152
  export type ModelAccessPointGroupOption = {
168
153
  label: string;
169
154
  value: ModelAccessPointGroup;
@@ -185,10 +170,7 @@ export type ExecutionIdOption = {
185
170
  * across different groups.
186
171
  */
187
172
  groupId?: string | undefined;
188
- value:
189
- | NativeModelExecutionContext
190
- | ModelAccessPointGroup
191
- | LakehouseAccessPoint;
173
+ value: ModelAccessPointGroup | LakehouseAccessPoint;
192
174
  };
193
175
 
194
176
  export abstract class DataProductExecutionState<T> {
@@ -221,30 +203,6 @@ export abstract class DataProductExecutionState<T> {
221
203
  }
222
204
  }
223
205
 
224
- export class NativeModelDataProductExecutionState extends DataProductExecutionState<NativeModelExecutionContext> {
225
- nativeModelAccess: NativeModelAccess;
226
-
227
- constructor(
228
- executionState: NativeModelExecutionContext,
229
- queryBuilderState: DataProductQueryBuilderState,
230
- ) {
231
- super(executionState, queryBuilderState);
232
- this.nativeModelAccess = executionState.__owner;
233
- }
234
-
235
- override get label(): string {
236
- return this.exectionValue.key;
237
- }
238
-
239
- get mapping(): Mapping {
240
- return this.exectionValue.mapping.value;
241
- }
242
-
243
- get featuredElements(): DataProductElementScope[] | undefined {
244
- return this.nativeModelAccess.featuredElements;
245
- }
246
- }
247
-
248
206
  export class ModelAccessPointDataProductExecutionState extends DataProductExecutionState<ModelAccessPointGroup> {
249
207
  selectedRuntime: PackageableRuntime | undefined;
250
208
  adhocRuntime = false;
@@ -295,7 +253,7 @@ export class ModelAccessPointDataProductExecutionState extends DataProductExecut
295
253
 
296
254
  get compatibleRuntimes(): PackageableRuntime[] {
297
255
  return this.queryBuilderState.graphManagerState.usableRuntimes.filter(
298
- (runtime) => runtime.runtimeValue instanceof LakehouseRuntime,
256
+ (runtime) => runtime.runtimeValue instanceof LakehouseBaseRuntime,
299
257
  );
300
258
  }
301
259
  }
@@ -344,7 +302,7 @@ export class LakehouseDataProductExecutionState extends DataProductExecutionStat
344
302
 
345
303
  get compatibleRuntimes(): PackageableRuntime[] {
346
304
  return this.queryBuilderState.graphManagerState.usableRuntimes.filter(
347
- (runtime) => runtime.runtimeValue instanceof LakehouseRuntime,
305
+ (runtime) => runtime.runtimeValue instanceof LakehouseBaseRuntime,
348
306
  );
349
307
  }
350
308
 
@@ -361,7 +319,7 @@ export class DataProductQueryBuilderState extends QueryBuilderState {
361
319
  dataProduct: DataProduct;
362
320
  dataProductArtifact: V1_DataProductArtifact | undefined;
363
321
  executionState: DataProductExecutionState<
364
- NativeModelExecutionContext | ModelAccessPointGroup | LakehouseAccessPoint
322
+ ModelAccessPointGroup | LakehouseAccessPoint
365
323
  >;
366
324
  entities: DepotEntityWithOrigin[] | undefined;
367
325
  mappingToMappingCoverageResult?: Map<
@@ -381,10 +339,7 @@ export class DataProductQueryBuilderState extends QueryBuilderState {
381
339
  dataProduct: DataProduct,
382
340
  artifact: V1_DataProductArtifact | undefined,
383
341
  actionConfig: QueryBuilderActionConfig,
384
- executionState:
385
- | NativeModelExecutionContext
386
- | ModelAccessPointGroup
387
- | LakehouseAccessPoint,
342
+ executionState: ModelAccessPointGroup | LakehouseAccessPoint,
388
343
  prioritizeEntityFunc: ((val: DepotEntityWithOrigin) => boolean) | undefined,
389
344
  onDataProductChange: (val: DepotEntityWithOrigin) => Promise<void>,
390
345
  onClassChange?: ((val: Class) => void) | undefined,
@@ -400,20 +355,15 @@ export class DataProductQueryBuilderState extends QueryBuilderState {
400
355
  setExecutionState: action,
401
356
  selectedDataProductOption: computed,
402
357
  isProductLinkable: computed,
403
- isNativeMode: computed,
404
358
  isModelAccessPointGroupMode: computed,
405
359
  isLakehouseMode: computed,
406
- showExecutionContextOptions: computed,
407
360
  showModelAccessPointGroupSelector: computed,
408
361
  showExecutionIdSelector: computed,
409
362
  executionIdOptions: computed,
410
363
  selectedExecutionIdOption: computed,
411
- hasNativeModelAccess: computed,
412
- hasBothAccessModes: computed,
413
364
  showContextSelector: computed,
414
365
  allContextOptions: computed,
415
366
  selectedContextOption: computed,
416
- selectedExecOption: computed,
417
367
  selectedModelAccessPointGroupOption: computed,
418
368
  usableClasses: computed,
419
369
  modelAccessPointGroups: computed,
@@ -432,11 +382,9 @@ export class DataProductQueryBuilderState extends QueryBuilderState {
432
382
  this.dataProduct = dataProduct;
433
383
  this.dataProductArtifact = artifact;
434
384
  this.executionState =
435
- executionState instanceof NativeModelExecutionContext
436
- ? new NativeModelDataProductExecutionState(executionState, this)
437
- : executionState instanceof LakehouseAccessPoint
438
- ? new LakehouseDataProductExecutionState(executionState, this)
439
- : new ModelAccessPointDataProductExecutionState(executionState, this);
385
+ executionState instanceof LakehouseAccessPoint
386
+ ? new LakehouseDataProductExecutionState(executionState, this)
387
+ : new ModelAccessPointDataProductExecutionState(executionState, this);
440
388
  this.prioritizeEntityFunc = prioritizeEntityFunc;
441
389
  this.onDataProductChange = onDataProductChange;
442
390
  this.onClassChange = onClassChange;
@@ -446,12 +394,7 @@ export class DataProductQueryBuilderState extends QueryBuilderState {
446
394
  }
447
395
 
448
396
  async prepareAccessForExecution(): Promise<void> {
449
- if (this.executionState instanceof NativeModelDataProductExecutionState) {
450
- const runtime = this.executionState.exectionValue.runtime;
451
- if (runtime) {
452
- this.changeRuntime(new RuntimePointer(runtime));
453
- }
454
- } else if (
397
+ if (
455
398
  this.executionState instanceof
456
399
  ModelAccessPointDataProductExecutionState &&
457
400
  this.executionState.selectedRuntime
@@ -481,10 +424,6 @@ export class DataProductQueryBuilderState extends QueryBuilderState {
481
424
  return false;
482
425
  }
483
426
 
484
- get isNativeMode(): boolean {
485
- return this.executionState instanceof NativeModelDataProductExecutionState;
486
- }
487
-
488
427
  get isModelAccessPointGroupMode(): boolean {
489
428
  return (
490
429
  this.executionState instanceof ModelAccessPointDataProductExecutionState
@@ -495,23 +434,12 @@ export class DataProductQueryBuilderState extends QueryBuilderState {
495
434
  return this.executionState instanceof LakehouseDataProductExecutionState;
496
435
  }
497
436
 
498
- get showExecutionContextOptions(): boolean {
499
- return this.isNativeMode && this.execOptions.length > 1;
500
- }
501
-
502
437
  get showModelAccessPointGroupSelector(): boolean {
503
438
  return (
504
439
  this.isModelAccessPointGroupMode &&
505
440
  this.modelAccessPointGroupOptions.length > 1
506
441
  );
507
442
  }
508
- get hasNativeModelAccess(): boolean {
509
- return this.dataProduct.nativeModelAccess !== undefined;
510
- }
511
-
512
- get hasBothAccessModes(): boolean {
513
- return this.hasModelAccessPointGroups && this.hasNativeModelAccess;
514
- }
515
443
 
516
444
  // showContextSelector / allContextOptions / selectedContextOption are aliases
517
445
  // over the upstream ExecutionIdOption API so existing UI code keeps working.
@@ -528,13 +456,6 @@ export class DataProductQueryBuilderState extends QueryBuilderState {
528
456
  }
529
457
 
530
458
  get executionIdOptions(): ExecutionIdOption[] {
531
- const nativeOptions: ExecutionIdOption[] = (
532
- this.dataProduct.nativeModelAccess?.nativeModelExecutionContexts ?? []
533
- ).map((ctx) => ({
534
- label: ctx.key,
535
- tag: 'NATIVE',
536
- value: ctx,
537
- }));
538
459
  const modelOptions: ExecutionIdOption[] = this.modelAccessPointGroups.map(
539
460
  (group) => ({
540
461
  label: group.title ?? group.id,
@@ -552,20 +473,12 @@ export class DataProductQueryBuilderState extends QueryBuilderState {
552
473
  groupId: ap.__owner.id,
553
474
  value: ap,
554
475
  }));
555
- return [...modelOptions, ...lakehouseOptions, ...nativeOptions].sort(
556
- compareLabelFn,
557
- );
476
+ return [...modelOptions, ...lakehouseOptions].sort(compareLabelFn);
558
477
  }
559
478
 
560
479
  get selectedExecutionIdOption(): ExecutionIdOption | undefined {
561
480
  const state = this.executionState;
562
- if (state instanceof NativeModelDataProductExecutionState) {
563
- return {
564
- label: state.exectionValue.key,
565
- tag: 'NATIVE',
566
- value: state.exectionValue,
567
- };
568
- } else if (state instanceof ModelAccessPointDataProductExecutionState) {
481
+ if (state instanceof ModelAccessPointDataProductExecutionState) {
569
482
  return {
570
483
  label: state.exectionValue.title ?? state.exectionValue.id,
571
484
  tag: 'MODEL',
@@ -591,30 +504,10 @@ export class DataProductQueryBuilderState extends QueryBuilderState {
591
504
  if (val === this.executionState.exectionValue) {
592
505
  return;
593
506
  }
594
- const switchingToModel = val instanceof ModelAccessPointGroup;
595
- const switchingToNative = val instanceof NativeModelExecutionContext;
596
- const wasModeSwitch =
597
- (switchingToModel && this.isNativeMode) ||
598
- (switchingToNative && this.isModelAccessPointGroupMode);
599
-
600
- if (wasModeSwitch) {
601
- this.changeHistoryState.querySnapshotBuffer = [];
602
- this.changeHistoryState.pointer = -1;
603
- this.changeHistoryState.setCurrentQuery(undefined);
604
- }
605
-
606
507
  await this.changeExecutionState(val);
607
508
  await this.propagateExecutionContextChange();
608
509
  }
609
510
 
610
- get selectedExecOption():
611
- | { label: string; value: NativeModelExecutionContext }
612
- | undefined {
613
- return this.executionState instanceof NativeModelDataProductExecutionState
614
- ? buildExecOptions(this.executionState.exectionValue)
615
- : undefined;
616
- }
617
-
618
511
  override get requiresMappingForExecution(): boolean {
619
512
  if (this.executionState instanceof LakehouseDataProductExecutionState) {
620
513
  return false;
@@ -652,12 +545,7 @@ export class DataProductQueryBuilderState extends QueryBuilderState {
652
545
  }
653
546
 
654
547
  override getQueryExecutionContext(): QueryExecutionContext {
655
- if (this.executionState instanceof NativeModelDataProductExecutionState) {
656
- const execContext = new QueryDataProductNativeExecutionContext();
657
- execContext.dataProductPath = this.dataProduct.path;
658
- execContext.executionKey = this.executionState.exectionValue.key;
659
- return execContext;
660
- } else if (
548
+ if (
661
549
  this.executionState instanceof ModelAccessPointDataProductExecutionState
662
550
  ) {
663
551
  const execContext = new QueryDataProductModelAccessExecutionContext();
@@ -714,27 +602,26 @@ export class DataProductQueryBuilderState extends QueryBuilderState {
714
602
  initWithDataProduct(
715
603
  dataProduct: DataProduct,
716
604
  accessor: Accessor | undefined,
717
- preResolvedState?:
718
- | NativeModelExecutionContext
719
- | ModelAccessPointGroup
720
- | LakehouseAccessPoint,
605
+ preResolvedState?: ModelAccessPointGroup | LakehouseAccessPoint,
721
606
  ): void {
722
607
  try {
723
608
  const execValue =
724
609
  preResolvedState ?? resolveDataProductExecutionState(dataProduct);
610
+ if (
611
+ !(execValue instanceof ModelAccessPointGroup) &&
612
+ !(execValue instanceof LakehouseAccessPoint)
613
+ ) {
614
+ throw new Error(
615
+ `Data product '${dataProduct.path}' is not supported for querying`,
616
+ );
617
+ }
725
618
  this.dataProduct = dataProduct;
726
619
  this.setExecutionState(execValue);
727
620
  const mapping = this.executionState.mapping;
728
621
  if (mapping) {
729
622
  this.changeMapping(mapping);
730
623
  }
731
- if (this.executionState instanceof NativeModelDataProductExecutionState) {
732
- const runtime = guaranteeNonNullable(
733
- this.executionState.exectionValue.runtime,
734
- 'runtime unable to be resolved',
735
- );
736
- this.changeRuntime(new RuntimePointer(runtime));
737
- } else if (
624
+ if (
738
625
  this.executionState instanceof
739
626
  ModelAccessPointDataProductExecutionState &&
740
627
  this.executionState.selectedRuntime instanceof PackageableRuntime
@@ -801,25 +688,15 @@ export class DataProductQueryBuilderState extends QueryBuilderState {
801
688
  return DataProduct;
802
689
  }
803
690
 
804
- setExecutionState(
805
- val:
806
- | NativeModelExecutionContext
807
- | ModelAccessPointGroup
808
- | LakehouseAccessPoint,
809
- ): void {
691
+ setExecutionState(val: ModelAccessPointGroup | LakehouseAccessPoint): void {
810
692
  this.executionState =
811
- val instanceof NativeModelExecutionContext
812
- ? new NativeModelDataProductExecutionState(val, this)
813
- : val instanceof LakehouseAccessPoint
814
- ? new LakehouseDataProductExecutionState(val, this)
815
- : new ModelAccessPointDataProductExecutionState(val, this);
693
+ val instanceof LakehouseAccessPoint
694
+ ? new LakehouseDataProductExecutionState(val, this)
695
+ : new ModelAccessPointDataProductExecutionState(val, this);
816
696
  }
817
697
 
818
698
  async changeExecutionState(
819
- val:
820
- | NativeModelExecutionContext
821
- | ModelAccessPointGroup
822
- | LakehouseAccessPoint,
699
+ val: ModelAccessPointGroup | LakehouseAccessPoint,
823
700
  ): Promise<void> {
824
701
  // preserve runtime selection when switching between Lakehouse access points
825
702
  // (or between Model access point groups) so users don't lose their chosen
@@ -921,9 +798,13 @@ export class DataProductQueryBuilderState extends QueryBuilderState {
921
798
  ? this.executionState.selectedRuntime
922
799
  : undefined;
923
800
  const lakehouseRuntime =
924
- selectedRuntime?.runtimeValue instanceof LakehouseRuntime
801
+ selectedRuntime?.runtimeValue instanceof LakehouseBaseRuntime
925
802
  ? selectedRuntime.runtimeValue
926
803
  : undefined;
804
+ const snowflakeRuntime =
805
+ lakehouseRuntime instanceof LakehouseRuntime
806
+ ? lakehouseRuntime
807
+ : undefined;
927
808
  // NOTE: `dataProduct` is declared with definite assignment, but is genuinely unset
928
809
  // on an artifact which was constructed rather than deserialized
929
810
  const artifactInfo: V1_DataProductInfo | undefined =
@@ -938,7 +819,7 @@ export class DataProductQueryBuilderState extends QueryBuilderState {
938
819
  : undefined,
939
820
  deploymentId: artifactInfo?.deploymentId,
940
821
  environment: lakehouseRuntime?.environment,
941
- warehouse: lakehouseRuntime?.warehouse,
822
+ warehouse: snowflakeRuntime?.warehouse,
942
823
  supportEmails: (this.dataProduct.supportInfo?.emails ?? []).map(
943
824
  (email) => email.address,
944
825
  ),
@@ -1016,7 +897,6 @@ export class DataProductQueryBuilderState extends QueryBuilderState {
1016
897
 
1017
898
  get isSupported(): boolean {
1018
899
  return (
1019
- this.dataProduct.nativeModelAccess !== undefined ||
1020
900
  // contains model access point group
1021
901
  this.dataProduct.accessPointGroups.filter(
1022
902
  filterByType(ModelAccessPointGroup),
@@ -1028,15 +908,6 @@ export class DataProductQueryBuilderState extends QueryBuilderState {
1028
908
  );
1029
909
  }
1030
910
 
1031
- // includes model access point group if more than one group
1032
- get execOptions(): { label: string; value: NativeModelExecutionContext }[] {
1033
- return (
1034
- this.dataProduct.nativeModelAccess?.nativeModelExecutionContexts.map(
1035
- buildExecOptions,
1036
- ) ?? []
1037
- ).sort(compareLabelFn);
1038
- }
1039
-
1040
911
  override async propagateExecutionContextChange(
1041
912
  requireReBuildingGraph?: boolean | undefined,
1042
913
  ): Promise<void> {
@@ -1050,7 +921,7 @@ export class DataProductQueryBuilderState extends QueryBuilderState {
1050
921
  newMapping.path,
1051
922
  );
1052
923
 
1053
- if (coverageResult && this.dataProductArtifact) {
924
+ if (this.dataProductArtifact) {
1054
925
  const origin = this.graphManagerState.graph.origin;
1055
926
  if (origin instanceof LegendSDLC) {
1056
927
  const newGraph = this.graphManagerState.createNewGraph();
@@ -1061,14 +932,7 @@ export class DataProductQueryBuilderState extends QueryBuilderState {
1061
932
  };
1062
933
  let accessPointId: string;
1063
934
  let dataProductAccessType: DataProductAccessType;
1064
- if (
1065
- this.executionState instanceof NativeModelDataProductExecutionState
1066
- ) {
1067
- accessPointId = this.executionState.exectionValue.key;
1068
- dataProductAccessType = DataProductAccessType.NATIVE;
1069
- } else if (
1070
- this.executionState instanceof LakehouseDataProductExecutionState
1071
- ) {
935
+ if (this.executionState instanceof LakehouseDataProductExecutionState) {
1072
936
  accessPointId = this.executionState.exectionValue.id;
1073
937
  dataProductAccessType = DataProductAccessType.LAKEHOUSE;
1074
938
  } else {
@@ -1089,7 +953,13 @@ export class DataProductQueryBuilderState extends QueryBuilderState {
1089
953
  this.graphManagerState.graph = newGraph;
1090
954
 
1091
955
  this.dataProduct = newGraph.getDataProduct(this.dataProduct.path);
1092
- this.setExecutionState(analysisResult.targetExecState);
956
+ const targetExecState = analysisResult.targetExecState;
957
+ if (
958
+ targetExecState instanceof ModelAccessPointGroup ||
959
+ targetExecState instanceof LakehouseAccessPoint
960
+ ) {
961
+ this.setExecutionState(targetExecState);
962
+ }
1093
963
  if (analysisResult.dataProductAnalysis.mappingToMappingCoverageResult) {
1094
964
  this.mappingToMappingCoverageResult =
1095
965
  analysisResult.dataProductAnalysis.mappingToMappingCoverageResult;
@@ -1101,7 +971,7 @@ export class DataProductQueryBuilderState extends QueryBuilderState {
1101
971
  this.explorerState.mappingModelCoverageAnalysisResult =
1102
972
  newCoverageResult;
1103
973
  }
1104
- } else {
974
+ } else if (coverageResult) {
1105
975
  this.explorerState.mappingModelCoverageAnalysisResult = coverageResult;
1106
976
  }
1107
977
  } else if (coverageResult) {