@finos/legend-application-query 13.7.204 → 13.8.0

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 (111) hide show
  1. package/lib/__lib__/LegendQueryNavigation.d.ts +16 -10
  2. package/lib/__lib__/LegendQueryNavigation.d.ts.map +1 -1
  3. package/lib/__lib__/LegendQueryNavigation.js +17 -12
  4. package/lib/__lib__/LegendQueryNavigation.js.map +1 -1
  5. package/lib/__lib__/LegendQueryUserDataHelper.d.ts +25 -7
  6. package/lib/__lib__/LegendQueryUserDataHelper.d.ts.map +1 -1
  7. package/lib/__lib__/LegendQueryUserDataHelper.js +81 -6
  8. package/lib/__lib__/LegendQueryUserDataHelper.js.map +1 -1
  9. package/lib/__lib__/LegendQueryUserDataSpaceHelper.d.ts +21 -4
  10. package/lib/__lib__/LegendQueryUserDataSpaceHelper.d.ts.map +1 -1
  11. package/lib/__lib__/LegendQueryUserDataSpaceHelper.js +17 -0
  12. package/lib/__lib__/LegendQueryUserDataSpaceHelper.js.map +1 -1
  13. package/lib/application/LegendQueryApplicationConfig.d.ts +10 -0
  14. package/lib/application/LegendQueryApplicationConfig.d.ts.map +1 -1
  15. package/lib/application/LegendQueryApplicationConfig.js +16 -0
  16. package/lib/application/LegendQueryApplicationConfig.js.map +1 -1
  17. package/lib/components/Core_LegendQueryApplicationPlugin.d.ts.map +1 -1
  18. package/lib/components/Core_LegendQueryApplicationPlugin.js +7 -3
  19. package/lib/components/Core_LegendQueryApplicationPlugin.js.map +1 -1
  20. package/lib/components/LegendQueryWebApplication.d.ts.map +1 -1
  21. package/lib/components/LegendQueryWebApplication.js +2 -2
  22. package/lib/components/LegendQueryWebApplication.js.map +1 -1
  23. package/lib/components/QueryEditor.d.ts.map +1 -1
  24. package/lib/components/QueryEditor.js +28 -12
  25. package/lib/components/QueryEditor.js.map +1 -1
  26. package/lib/components/__test-utils__/QueryEditorComponentTestUtils.d.ts +8 -0
  27. package/lib/components/__test-utils__/QueryEditorComponentTestUtils.d.ts.map +1 -1
  28. package/lib/components/__test-utils__/QueryEditorComponentTestUtils.js +190 -8
  29. package/lib/components/__test-utils__/QueryEditorComponentTestUtils.js.map +1 -1
  30. package/lib/components/data-product/DataProductInfo.d.ts +28 -0
  31. package/lib/components/data-product/DataProductInfo.d.ts.map +1 -0
  32. package/lib/components/data-product/DataProductInfo.js +89 -0
  33. package/lib/components/data-product/DataProductInfo.js.map +1 -0
  34. package/lib/components/{data-space/DataSpaceQueryCreator.d.ts → data-product/LegendQueryDataProductQueryBuilder.d.ts} +3 -4
  35. package/lib/components/data-product/LegendQueryDataProductQueryBuilder.d.ts.map +1 -0
  36. package/lib/components/data-product/LegendQueryDataProductQueryBuilder.js +98 -0
  37. package/lib/components/data-product/LegendQueryDataProductQueryBuilder.js.map +1 -0
  38. package/lib/components/data-space/DataProductQueryCreator.d.ts +36 -0
  39. package/lib/components/data-space/DataProductQueryCreator.d.ts.map +1 -0
  40. package/lib/components/data-space/DataProductQueryCreator.js +76 -0
  41. package/lib/components/data-space/DataProductQueryCreator.js.map +1 -0
  42. package/lib/index.css +1 -1
  43. package/lib/index.d.ts +1 -1
  44. package/lib/index.d.ts.map +1 -1
  45. package/lib/index.js +1 -1
  46. package/lib/index.js.map +1 -1
  47. package/lib/light-mode.css +1 -1
  48. package/lib/package.json +2 -1
  49. package/lib/stores/QueryEditorStore.d.ts +46 -2
  50. package/lib/stores/QueryEditorStore.d.ts.map +1 -1
  51. package/lib/stores/QueryEditorStore.js +251 -5
  52. package/lib/stores/QueryEditorStore.js.map +1 -1
  53. package/lib/stores/data-product/query-builder/DataProductArtifactHelper.d.ts +21 -0
  54. package/lib/stores/data-product/query-builder/DataProductArtifactHelper.d.ts.map +1 -0
  55. package/lib/stores/data-product/query-builder/DataProductArtifactHelper.js +35 -0
  56. package/lib/stores/data-product/query-builder/DataProductArtifactHelper.js.map +1 -0
  57. package/lib/stores/data-product/query-builder/LegendQueryDataProductQueryBuilderState.d.ts +11 -3
  58. package/lib/stores/data-product/query-builder/LegendQueryDataProductQueryBuilderState.d.ts.map +1 -1
  59. package/lib/stores/data-product/query-builder/LegendQueryDataProductQueryBuilderState.js +50 -8
  60. package/lib/stores/data-product/query-builder/LegendQueryDataProductQueryBuilderState.js.map +1 -1
  61. package/lib/stores/data-space/DataProductQueryCreatorStore.d.ts +94 -0
  62. package/lib/stores/data-space/DataProductQueryCreatorStore.d.ts.map +1 -0
  63. package/lib/stores/data-space/DataProductQueryCreatorStore.js +388 -0
  64. package/lib/stores/data-space/DataProductQueryCreatorStore.js.map +1 -0
  65. package/lib/stores/data-space/DataProductSelectorState.d.ts +44 -0
  66. package/lib/stores/data-space/DataProductSelectorState.d.ts.map +1 -0
  67. package/lib/stores/data-space/DataProductSelectorState.js +111 -0
  68. package/lib/stores/data-space/DataProductSelectorState.js.map +1 -0
  69. package/lib/stores/data-space/DataSpaceTemplateQueryCreatorStore.d.ts.map +1 -1
  70. package/lib/stores/data-space/DataSpaceTemplateQueryCreatorStore.js +3 -0
  71. package/lib/stores/data-space/DataSpaceTemplateQueryCreatorStore.js.map +1 -1
  72. package/lib/stores/data-space/LegendQueryBareQueryBuilderState.d.ts +1 -1
  73. package/lib/stores/data-space/LegendQueryBareQueryBuilderState.d.ts.map +1 -1
  74. package/lib/stores/data-space/LegendQueryBareQueryBuilderState.js +1 -1
  75. package/lib/stores/data-space/LegendQueryBareQueryBuilderState.js.map +1 -1
  76. package/lib/stores/data-space/query-builder/LegendQueryDataSpaceQueryBuilderState.d.ts +4 -3
  77. package/lib/stores/data-space/query-builder/LegendQueryDataSpaceQueryBuilderState.d.ts.map +1 -1
  78. package/lib/stores/data-space/query-builder/LegendQueryDataSpaceQueryBuilderState.js +24 -29
  79. package/lib/stores/data-space/query-builder/LegendQueryDataSpaceQueryBuilderState.js.map +1 -1
  80. package/package.json +9 -8
  81. package/src/__lib__/LegendQueryNavigation.ts +76 -18
  82. package/src/__lib__/LegendQueryUserDataHelper.ts +177 -12
  83. package/src/__lib__/LegendQueryUserDataSpaceHelper.ts +54 -4
  84. package/src/application/LegendQueryApplicationConfig.ts +31 -0
  85. package/src/components/Core_LegendQueryApplicationPlugin.tsx +8 -2
  86. package/src/components/LegendQueryWebApplication.tsx +8 -4
  87. package/src/components/QueryEditor.tsx +132 -42
  88. package/src/components/__test-utils__/QueryEditorComponentTestUtils.tsx +418 -5
  89. package/src/components/data-product/DataProductInfo.tsx +297 -0
  90. package/src/components/data-product/LegendQueryDataProductQueryBuilder.tsx +268 -0
  91. package/src/components/data-space/DataProductQueryCreator.tsx +167 -0
  92. package/src/components/data-space/DataSpaceQuerySetup.tsx +1 -1
  93. package/src/index.ts +6 -0
  94. package/src/stores/QueryEditorStore.ts +485 -2
  95. package/src/stores/data-product/query-builder/DataProductArtifactHelper.ts +48 -0
  96. package/src/stores/data-product/query-builder/LegendQueryDataProductQueryBuilderState.ts +77 -16
  97. package/src/stores/data-space/DataProductQueryCreatorStore.ts +765 -0
  98. package/src/stores/data-space/DataProductSelectorState.ts +164 -0
  99. package/src/stores/data-space/DataSpaceTemplateQueryCreatorStore.ts +10 -0
  100. package/src/stores/data-space/LegendQueryBareQueryBuilderState.ts +1 -1
  101. package/src/stores/data-space/query-builder/LegendQueryDataSpaceQueryBuilderState.ts +27 -54
  102. package/tsconfig.json +6 -2
  103. package/lib/components/data-space/DataSpaceQueryCreator.d.ts.map +0 -1
  104. package/lib/components/data-space/DataSpaceQueryCreator.js +0 -62
  105. package/lib/components/data-space/DataSpaceQueryCreator.js.map +0 -1
  106. package/lib/stores/data-space/DataSpaceQueryCreatorStore.d.ts +0 -92
  107. package/lib/stores/data-space/DataSpaceQueryCreatorStore.d.ts.map +0 -1
  108. package/lib/stores/data-space/DataSpaceQueryCreatorStore.js +0 -400
  109. package/lib/stores/data-space/DataSpaceQueryCreatorStore.js.map +0 -1
  110. package/src/components/data-space/DataSpaceQueryCreator.tsx +0 -119
  111. package/src/stores/data-space/DataSpaceQueryCreatorStore.ts +0 -697
@@ -19,6 +19,7 @@ import {
19
19
  type PlainObject,
20
20
  type AbstractPlugin,
21
21
  type AbstractPreset,
22
+ filterByType,
22
23
  guaranteeNonNullable,
23
24
  } from '@finos/legend-shared';
24
25
  import { createMock, createSpy } from '@finos/legend-shared/test';
@@ -31,9 +32,14 @@ import {
31
32
  RawLambda,
32
33
  QueryExplicitExecutionContext,
33
34
  QueryDataSpaceExecutionContext,
35
+ QueryDataProductModelAccessExecutionContext,
36
+ QueryDataProductNativeExecutionContext,
34
37
  PackageableElementExplicitReference,
35
38
  QueryDataSpaceExecutionContextInfo,
36
39
  QueryExplicitExecutionContextInfo,
40
+ QueryDataProductModelAccessExecutionContextInfo,
41
+ QueryDataProductNativeExecutionContextInfo,
42
+ ModelAccessPointGroup,
37
43
  } from '@finos/legend-graph';
38
44
  import { DepotServerClient } from '@finos/legend-server-depot';
39
45
  import {
@@ -48,11 +54,15 @@ import type {
48
54
  Entity,
49
55
  StoredFileGeneration,
50
56
  } from '@finos/legend-storage';
51
- import { ExistingQueryEditorStore } from '../../stores/QueryEditorStore.js';
57
+ import {
58
+ ExistingQueryEditorStore,
59
+ QueryBuilderActionConfig_QueryApplication,
60
+ } from '../../stores/QueryEditorStore.js';
52
61
  import type { LegendQueryApplicationStore } from '../../stores/LegendQueryBaseStore.js';
53
62
  import {
54
63
  type QueryBuilderState,
55
64
  QUERY_BUILDER_TEST_ID,
65
+ QueryBuilderDataBrowserWorkflow,
56
66
  } from '@finos/legend-query-builder';
57
67
  import { LegendQueryFrameworkProvider } from '../LegendQueryFrameworkProvider.js';
58
68
  import { TEST__BrowserEnvironmentProvider } from '@finos/legend-application/test';
@@ -66,6 +76,8 @@ import {
66
76
  type V1_DataSpaceAnalysisResult,
67
77
  DSL_DataSpace_getGraphManagerExtension,
68
78
  } from '@finos/legend-extension-dsl-data-space/graph';
79
+ import { LegendQueryDataProductQueryBuilderState } from '../../stores/data-product/query-builder/LegendQueryDataProductQueryBuilderState.js';
80
+ import { DataProductSelectorState } from '../../stores/data-space/DataProductSelectorState.js';
69
81
 
70
82
  const TEST_QUERY_ID = 'test-query-id';
71
83
  export const TEST_QUERY_NAME = 'MyTestQuery';
@@ -93,17 +105,19 @@ export const TEST__provideMockedQueryEditorStore = (customization?: {
93
105
  TEST__getTestLegendQueryApplicationConfig(),
94
106
  pluginManager,
95
107
  );
108
+ const depotServerClient = new DepotServerClient({
109
+ serverUrl: applicationStore.config.depotServerUrl,
110
+ });
111
+ depotServerClient.setTracerService(applicationStore.tracerService);
96
112
  const value =
97
113
  customization?.mock ??
98
114
  new ExistingQueryEditorStore(
99
115
  applicationStore,
100
- new DepotServerClient({
101
- serverUrl: applicationStore.config.depotServerUrl,
102
- }),
116
+ depotServerClient,
103
117
  TEST_QUERY_ID,
104
118
  undefined,
105
119
  );
106
- const MOCK__QueryEditorStoreProvider = require('../QueryEditorStoreProvider.js'); // eslint-disable-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-require-imports
120
+ const MOCK__QueryEditorStoreProvider = require('../QueryEditorStoreProvider.js'); // eslint-disable-line @typescript-eslint/no-require-imports,@typescript-eslint/no-unsafe-assignment
107
121
  MOCK__QueryEditorStoreProvider.useQueryEditorStore = createMock();
108
122
  MOCK__QueryEditorStoreProvider.useQueryEditorStore.mockReturnValue(value);
109
123
  return value;
@@ -417,3 +431,402 @@ export const TEST__setUpDataSpaceExistingQueryEditor = async (
417
431
  ),
418
432
  };
419
433
  };
434
+
435
+ export const TEST__setUpDataProductExistingQueryEditor = async (
436
+ MOCK__editorStore: ExistingQueryEditorStore,
437
+ dataProductPath: string,
438
+ accessPointGroupId: string,
439
+ lambda: RawLambda,
440
+ entities: PlainObject<Entity>[],
441
+ ): Promise<{
442
+ renderResult: RenderResult;
443
+ queryBuilderState: QueryBuilderState;
444
+ }> => {
445
+ const projectData = {
446
+ id: 'test-id',
447
+ groupId: 'test.group',
448
+ artifactId: 'test-artifact',
449
+ projectId: 'test-project-id',
450
+ versions: ['0.0.0'],
451
+ latestVersion: '0.0.0',
452
+ };
453
+
454
+ const lightQuery = new LightQuery();
455
+ lightQuery.name = TEST_QUERY_NAME;
456
+ lightQuery.id = TEST_QUERY_ID;
457
+ lightQuery.versionId = '0.0.0';
458
+ lightQuery.groupId = 'test.group';
459
+ lightQuery.artifactId = 'test-artifact';
460
+ lightQuery.owner = 'test-artifact';
461
+ lightQuery.isCurrentUserQuery = true;
462
+
463
+ const graphManagerState = MOCK__editorStore.graphManagerState;
464
+
465
+ await graphManagerState.graphManager.initialize({
466
+ env: 'test',
467
+ tabSize: 2,
468
+ clientConfig: {},
469
+ });
470
+
471
+ await graphManagerState.initializeSystem();
472
+ await graphManagerState.graphManager.buildGraph(
473
+ graphManagerState.graph,
474
+ entities as unknown as Entity[],
475
+ graphManagerState.graphBuildState,
476
+ );
477
+
478
+ const query = new Query();
479
+ query.name = lightQuery.name;
480
+ query.id = lightQuery.id;
481
+ query.versionId = lightQuery.versionId;
482
+ query.groupId = lightQuery.groupId;
483
+ query.artifactId = lightQuery.artifactId;
484
+ query.owner = lightQuery.owner;
485
+ query.isCurrentUserQuery = lightQuery.isCurrentUserQuery;
486
+ const execContext = new QueryDataProductModelAccessExecutionContext();
487
+ execContext.dataProductPath = dataProductPath;
488
+ execContext.accessPointGroupId = accessPointGroupId;
489
+ query.executionContext = execContext;
490
+ query.content = 'some content';
491
+
492
+ const execContextInfo = new QueryDataProductModelAccessExecutionContextInfo();
493
+ execContextInfo.dataProductPath = dataProductPath;
494
+ execContextInfo.accessPointGroupId = accessPointGroupId;
495
+
496
+ const queryInfo: QueryInfo = {
497
+ name: TEST_QUERY_NAME,
498
+ id: TEST_QUERY_ID,
499
+ versionId: '0.0.0',
500
+ groupId: 'test.group',
501
+ artifactId: 'test-artifact',
502
+ executionContext: execContextInfo,
503
+ content: 'some content',
504
+ isCurrentUserQuery: true,
505
+ };
506
+
507
+ // Resolve the data product and execution state from the built graph
508
+ const dataProduct = graphManagerState.graph.getDataProduct(dataProductPath);
509
+ const modelGroups = dataProduct.accessPointGroups.filter(
510
+ filterByType(ModelAccessPointGroup),
511
+ );
512
+ const executionState = guaranteeNonNullable(
513
+ modelGroups.find((g) => g.id === accessPointGroupId),
514
+ `Can't find access point group '${accessPointGroupId}'`,
515
+ );
516
+
517
+ createSpy(
518
+ MOCK__editorStore.depotServerClient,
519
+ 'getProject',
520
+ ).mockResolvedValue(projectData);
521
+ createSpy(
522
+ MOCK__editorStore.depotServerClient,
523
+ 'getEntities',
524
+ ).mockResolvedValue(entities);
525
+ createSpy(
526
+ MOCK__editorStore.depotServerClient,
527
+ 'getEntitiesByClassifier',
528
+ ).mockResolvedValue([]);
529
+ createSpy(
530
+ MOCK__editorStore.depotServerClient,
531
+ 'getEntitiesSummaryByClassifier',
532
+ ).mockResolvedValue([]);
533
+ createSpy(
534
+ MOCK__editorStore.depotServerClient,
535
+ 'getVersions',
536
+ ).mockResolvedValue([projectData.latestVersion]);
537
+ createSpy(graphManagerState.graphManager, 'getLightQuery').mockResolvedValue(
538
+ lightQuery,
539
+ );
540
+ createSpy(graphManagerState.graphManager, 'getQueryInfo').mockResolvedValue(
541
+ queryInfo,
542
+ );
543
+ createSpy(
544
+ graphManagerState.graphManager,
545
+ 'pureCodeToLambda',
546
+ ).mockResolvedValue(new RawLambda(lambda.parameters, lambda.body));
547
+ createSpy(graphManagerState.graphManager, 'getQuery').mockResolvedValue(
548
+ query,
549
+ );
550
+ createSpy(
551
+ graphManagerState.graphManager,
552
+ 'analyzeMappingModelCoverage',
553
+ ).mockResolvedValue(
554
+ graphManagerState.graphManager.buildMappingModelCoverageAnalysisResult(
555
+ { mappedEntities: [] },
556
+ executionState.mapping.value,
557
+ ),
558
+ );
559
+
560
+ // Build the query builder state that buildDataProductQueryBuilderState would return
561
+ const mockQueryBuilderState = new LegendQueryDataProductQueryBuilderState(
562
+ MOCK__editorStore.applicationStore,
563
+ graphManagerState,
564
+ QueryBuilderDataBrowserWorkflow.INSTANCE,
565
+ new QueryBuilderActionConfig_QueryApplication(MOCK__editorStore),
566
+ dataProduct,
567
+ undefined,
568
+ executionState,
569
+ MOCK__editorStore.depotServerClient,
570
+ { groupId: 'test.group', artifactId: 'test-artifact', versionId: '0.0.0' },
571
+ async () => {
572
+ /* no-op for tests */
573
+ },
574
+ new DataProductSelectorState(
575
+ MOCK__editorStore.depotServerClient,
576
+ MOCK__editorStore.applicationStore,
577
+ ),
578
+ undefined,
579
+ undefined,
580
+ MOCK__editorStore.applicationStore.config.options.queryBuilderConfig,
581
+ {
582
+ groupId: 'test.group',
583
+ artifactId: 'test-artifact',
584
+ versionId: '0.0.0',
585
+ dataProduct: dataProductPath,
586
+ },
587
+ );
588
+ mockQueryBuilderState.initWithDataProduct(dataProduct, executionState);
589
+
590
+ MOCK__editorStore.buildGraph = createMock();
591
+ MOCK__editorStore.buildFullGraph = createMock();
592
+ MOCK__editorStore.fetchDataProductArtifact = createMock();
593
+ (
594
+ MOCK__editorStore.fetchDataProductArtifact as ReturnType<typeof createMock>
595
+ ).mockResolvedValue({});
596
+ MOCK__editorStore.buildDataProductQueryBuilderState = createMock();
597
+ (
598
+ MOCK__editorStore.buildDataProductQueryBuilderState as ReturnType<
599
+ typeof createMock
600
+ >
601
+ ).mockResolvedValue(mockQueryBuilderState);
602
+ graphManagerState.graphManager.initialize = createMock();
603
+
604
+ const renderResult = render(
605
+ <ApplicationStoreProvider store={MOCK__editorStore.applicationStore}>
606
+ <TEST__BrowserEnvironmentProvider
607
+ initialEntries={[generateExistingQueryEditorRoute(lightQuery.id)]}
608
+ >
609
+ <LegendQueryFrameworkProvider>
610
+ <Routes>
611
+ <Route
612
+ path={LEGEND_QUERY_ROUTE_PATTERN.EDIT_EXISTING_QUERY}
613
+ element={<ExistingQueryEditor />}
614
+ />
615
+ </Routes>
616
+ </LegendQueryFrameworkProvider>
617
+ </TEST__BrowserEnvironmentProvider>
618
+ </ApplicationStoreProvider>,
619
+ );
620
+ await waitFor(() =>
621
+ renderResult.getByTestId(QUERY_BUILDER_TEST_ID.QUERY_BUILDER),
622
+ );
623
+
624
+ return {
625
+ renderResult,
626
+ queryBuilderState: guaranteeNonNullable(
627
+ MOCK__editorStore.queryBuilderState,
628
+ `Query builder state should have been initialized`,
629
+ ),
630
+ };
631
+ };
632
+
633
+ export const TEST__setUpDataProductNativeExistingQueryEditor = async (
634
+ MOCK__editorStore: ExistingQueryEditorStore,
635
+ dataProductPath: string,
636
+ executionKey: string,
637
+ lambda: RawLambda,
638
+ entities: PlainObject<Entity>[],
639
+ ): Promise<{
640
+ renderResult: RenderResult;
641
+ queryBuilderState: QueryBuilderState;
642
+ }> => {
643
+ const projectData = {
644
+ id: 'test-id',
645
+ groupId: 'test.group',
646
+ artifactId: 'test-artifact',
647
+ projectId: 'test-project-id',
648
+ versions: ['0.0.0'],
649
+ latestVersion: '0.0.0',
650
+ };
651
+
652
+ const lightQuery = new LightQuery();
653
+ lightQuery.name = TEST_QUERY_NAME;
654
+ lightQuery.id = TEST_QUERY_ID;
655
+ lightQuery.versionId = '0.0.0';
656
+ lightQuery.groupId = 'test.group';
657
+ lightQuery.artifactId = 'test-artifact';
658
+ lightQuery.owner = 'test-artifact';
659
+ lightQuery.isCurrentUserQuery = true;
660
+
661
+ const graphManagerState = MOCK__editorStore.graphManagerState;
662
+
663
+ await graphManagerState.graphManager.initialize({
664
+ env: 'test',
665
+ tabSize: 2,
666
+ clientConfig: {},
667
+ });
668
+
669
+ await graphManagerState.initializeSystem();
670
+ await graphManagerState.graphManager.buildGraph(
671
+ graphManagerState.graph,
672
+ entities as unknown as Entity[],
673
+ graphManagerState.graphBuildState,
674
+ );
675
+
676
+ const query = new Query();
677
+ query.name = lightQuery.name;
678
+ query.id = lightQuery.id;
679
+ query.versionId = lightQuery.versionId;
680
+ query.groupId = lightQuery.groupId;
681
+ query.artifactId = lightQuery.artifactId;
682
+ query.owner = lightQuery.owner;
683
+ query.isCurrentUserQuery = lightQuery.isCurrentUserQuery;
684
+ const execContext = new QueryDataProductNativeExecutionContext();
685
+ execContext.dataProductPath = dataProductPath;
686
+ execContext.executionKey = executionKey;
687
+ query.executionContext = execContext;
688
+ query.content = 'some content';
689
+
690
+ const execContextInfo = new QueryDataProductNativeExecutionContextInfo();
691
+ execContextInfo.dataProductPath = dataProductPath;
692
+ execContextInfo.executionKey = executionKey;
693
+
694
+ const queryInfo: QueryInfo = {
695
+ name: TEST_QUERY_NAME,
696
+ id: TEST_QUERY_ID,
697
+ versionId: '0.0.0',
698
+ groupId: 'test.group',
699
+ artifactId: 'test-artifact',
700
+ executionContext: execContextInfo,
701
+ content: 'some content',
702
+ isCurrentUserQuery: true,
703
+ };
704
+
705
+ // Resolve the data product and execution state from the built graph
706
+ const dataProduct = graphManagerState.graph.getDataProduct(dataProductPath);
707
+ const nativeAccess = guaranteeNonNullable(
708
+ dataProduct.nativeModelAccess,
709
+ `Data product '${dataProductPath}' has no native model access`,
710
+ );
711
+ const executionState = guaranteeNonNullable(
712
+ nativeAccess.nativeModelExecutionContexts.find(
713
+ (ctx) => ctx.key === executionKey,
714
+ ),
715
+ `Can't find native execution context '${executionKey}'`,
716
+ );
717
+
718
+ createSpy(
719
+ MOCK__editorStore.depotServerClient,
720
+ 'getProject',
721
+ ).mockResolvedValue(projectData);
722
+ createSpy(
723
+ MOCK__editorStore.depotServerClient,
724
+ 'getEntities',
725
+ ).mockResolvedValue(entities);
726
+ createSpy(
727
+ MOCK__editorStore.depotServerClient,
728
+ 'getEntitiesByClassifier',
729
+ ).mockResolvedValue([]);
730
+ createSpy(
731
+ MOCK__editorStore.depotServerClient,
732
+ 'getEntitiesSummaryByClassifier',
733
+ ).mockResolvedValue([]);
734
+ createSpy(
735
+ MOCK__editorStore.depotServerClient,
736
+ 'getVersions',
737
+ ).mockResolvedValue([projectData.latestVersion]);
738
+ createSpy(graphManagerState.graphManager, 'getLightQuery').mockResolvedValue(
739
+ lightQuery,
740
+ );
741
+ createSpy(graphManagerState.graphManager, 'getQueryInfo').mockResolvedValue(
742
+ queryInfo,
743
+ );
744
+ createSpy(
745
+ graphManagerState.graphManager,
746
+ 'pureCodeToLambda',
747
+ ).mockResolvedValue(new RawLambda(lambda.parameters, lambda.body));
748
+ createSpy(graphManagerState.graphManager, 'getQuery').mockResolvedValue(
749
+ query,
750
+ );
751
+ createSpy(
752
+ graphManagerState.graphManager,
753
+ 'analyzeMappingModelCoverage',
754
+ ).mockResolvedValue(
755
+ graphManagerState.graphManager.buildMappingModelCoverageAnalysisResult(
756
+ { mappedEntities: [] },
757
+ executionState.mapping.value,
758
+ ),
759
+ );
760
+
761
+ // Build the query builder state that buildDataProductQueryBuilderState would return
762
+ const mockQueryBuilderState = new LegendQueryDataProductQueryBuilderState(
763
+ MOCK__editorStore.applicationStore,
764
+ graphManagerState,
765
+ QueryBuilderDataBrowserWorkflow.INSTANCE,
766
+ new QueryBuilderActionConfig_QueryApplication(MOCK__editorStore),
767
+ dataProduct,
768
+ undefined,
769
+ executionState,
770
+ MOCK__editorStore.depotServerClient,
771
+ { groupId: 'test.group', artifactId: 'test-artifact', versionId: '0.0.0' },
772
+ async () => {
773
+ /* no-op for tests */
774
+ },
775
+ new DataProductSelectorState(
776
+ MOCK__editorStore.depotServerClient,
777
+ MOCK__editorStore.applicationStore,
778
+ ),
779
+ undefined,
780
+ undefined,
781
+ MOCK__editorStore.applicationStore.config.options.queryBuilderConfig,
782
+ {
783
+ groupId: 'test.group',
784
+ artifactId: 'test-artifact',
785
+ versionId: '0.0.0',
786
+ dataProduct: dataProductPath,
787
+ },
788
+ );
789
+ mockQueryBuilderState.initWithDataProduct(dataProduct, executionState);
790
+
791
+ MOCK__editorStore.buildGraph = createMock();
792
+ MOCK__editorStore.buildFullGraph = createMock();
793
+ MOCK__editorStore.fetchDataProductArtifact = createMock();
794
+ (
795
+ MOCK__editorStore.fetchDataProductArtifact as ReturnType<typeof createMock>
796
+ ).mockResolvedValue({});
797
+ MOCK__editorStore.buildDataProductQueryBuilderState = createMock();
798
+ (
799
+ MOCK__editorStore.buildDataProductQueryBuilderState as ReturnType<
800
+ typeof createMock
801
+ >
802
+ ).mockResolvedValue(mockQueryBuilderState);
803
+ graphManagerState.graphManager.initialize = createMock();
804
+
805
+ const renderResult = render(
806
+ <ApplicationStoreProvider store={MOCK__editorStore.applicationStore}>
807
+ <TEST__BrowserEnvironmentProvider
808
+ initialEntries={[generateExistingQueryEditorRoute(lightQuery.id)]}
809
+ >
810
+ <LegendQueryFrameworkProvider>
811
+ <Routes>
812
+ <Route
813
+ path={LEGEND_QUERY_ROUTE_PATTERN.EDIT_EXISTING_QUERY}
814
+ element={<ExistingQueryEditor />}
815
+ />
816
+ </Routes>
817
+ </LegendQueryFrameworkProvider>
818
+ </TEST__BrowserEnvironmentProvider>
819
+ </ApplicationStoreProvider>,
820
+ );
821
+ await waitFor(() =>
822
+ renderResult.getByTestId(QUERY_BUILDER_TEST_ID.QUERY_BUILDER),
823
+ );
824
+
825
+ return {
826
+ renderResult,
827
+ queryBuilderState: guaranteeNonNullable(
828
+ MOCK__editorStore.queryBuilderState,
829
+ `Query builder state should have been initialized`,
830
+ ),
831
+ };
832
+ };