@finos/legend-application-marketplace 0.2.13 → 0.2.14

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 (21) hide show
  1. package/lib/index.css +2 -2
  2. package/lib/index.css.map +1 -1
  3. package/lib/package.json +1 -1
  4. package/lib/pages/Lakehouse/entitlements/EntitlementsClosedContractsDashboard.d.ts.map +1 -1
  5. package/lib/pages/Lakehouse/entitlements/EntitlementsClosedContractsDashboard.js +9 -12
  6. package/lib/pages/Lakehouse/entitlements/EntitlementsClosedContractsDashboard.js.map +1 -1
  7. package/lib/pages/Lakehouse/entitlements/EntitlementsPendingContractsDashboard.d.ts.map +1 -1
  8. package/lib/pages/Lakehouse/entitlements/EntitlementsPendingContractsDashboard.js +7 -11
  9. package/lib/pages/Lakehouse/entitlements/EntitlementsPendingContractsDashboard.js.map +1 -1
  10. package/lib/pages/Lakehouse/entitlements/EntitlementsPendingTasksDashboard.d.ts.map +1 -1
  11. package/lib/pages/Lakehouse/entitlements/EntitlementsPendingTasksDashboard.js +7 -11
  12. package/lib/pages/Lakehouse/entitlements/EntitlementsPendingTasksDashboard.js.map +1 -1
  13. package/lib/stores/lakehouse/entitlements/EntitlementsDashboardState.d.ts +26 -2
  14. package/lib/stores/lakehouse/entitlements/EntitlementsDashboardState.d.ts.map +1 -1
  15. package/lib/stores/lakehouse/entitlements/EntitlementsDashboardState.js +72 -14
  16. package/lib/stores/lakehouse/entitlements/EntitlementsDashboardState.js.map +1 -1
  17. package/package.json +8 -8
  18. package/src/pages/Lakehouse/entitlements/EntitlementsClosedContractsDashboard.tsx +15 -17
  19. package/src/pages/Lakehouse/entitlements/EntitlementsPendingContractsDashboard.tsx +12 -17
  20. package/src/pages/Lakehouse/entitlements/EntitlementsPendingTasksDashboard.tsx +12 -17
  21. package/src/stores/lakehouse/entitlements/EntitlementsDashboardState.ts +112 -18
@@ -19,7 +19,9 @@ import {
19
19
  assertErrorThrown,
20
20
  guaranteeNonNullable,
21
21
  guaranteeType,
22
+ HttpStatus,
22
23
  isNonNullable,
24
+ NetworkClientError,
23
25
  type GeneratorFn,
24
26
  type PlainObject,
25
27
  } from '@finos/legend-shared';
@@ -28,7 +30,6 @@ import {
28
30
  type PureProtocolProcessorPlugin,
29
31
  type V1_DataProduct,
30
32
  type V1_EnrichedUserApprovalStatus,
31
- type V1_EntitlementsDataProductDetails,
32
33
  type V1_LiteDataContract,
33
34
  type V1_LiteDataContractWithUserStatus,
34
35
  type V1_PendingTasksResponse,
@@ -51,7 +52,7 @@ import {
51
52
  V1_transformDataContractToLiteDatacontract,
52
53
  } from '@finos/legend-graph';
53
54
  import { DEFAULT_TAB_SIZE } from '@finos/legend-application';
54
- import { type IngestDeploymentServerConfig } from '@finos/legend-server-lakehouse';
55
+ import type { ContractErrorLayer } from '@finos/legend-extension-dsl-data-product';
55
56
  import {
56
57
  makeObservable,
57
58
  flow,
@@ -66,6 +67,18 @@ import {
66
67
  } from './LakehouseEntitlementsStore.js';
67
68
  import { getDataProductFromDetails } from '../../../utils/LakehouseUtils.js';
68
69
 
70
+ export enum ContractSyncStatus {
71
+ NEVER_SYNCED = 'NEVER_SYNCED',
72
+ NOT_FULLY_SYNCED = 'NOT_FULLY_SYNCED',
73
+ }
74
+
75
+ export type LakehouseContractSyncStatusResponse = {
76
+ status: string;
77
+ unsyncedUsers?: { username: string }[];
78
+ unsyncedAccessPoints?: { accessPointName: string }[];
79
+ unsyncedTargetAccounts?: string[];
80
+ };
81
+
69
82
  const collectIngestSpecPathsFromOriginDp = (
70
83
  rootDataProduct: V1_DataProduct,
71
84
  accessPointGroupId: string,
@@ -214,7 +227,6 @@ export class EntitlementsDashboardState {
214
227
  fetchContractsForUser: flow,
215
228
  fetchContractsCreatedByUser: flow,
216
229
  fetchContractDeploymentEnvironments: flow,
217
- getUnverifiedIngestDefinitions: flow,
218
230
  updateContract: flow,
219
231
  });
220
232
  }
@@ -478,10 +490,10 @@ export class EntitlementsDashboardState {
478
490
  return didToEnvType;
479
491
  }
480
492
 
481
- *getUnverifiedIngestDefinitions(
493
+ async getUnverifiedIngestDefinitions(
482
494
  contractId: string,
483
495
  token: string | undefined,
484
- ): GeneratorFn<string[] | undefined> {
496
+ ): Promise<string[]> {
485
497
  const entitlementsStore = this.lakehouseEntitlementsStore;
486
498
  const baseStore = entitlementsStore.marketplaceBaseStore;
487
499
  const applicationStore = entitlementsStore.applicationStore;
@@ -493,7 +505,7 @@ export class EntitlementsDashboardState {
493
505
  const SDLC_DEPLOYMENT = 'alloy-git';
494
506
 
495
507
  try {
496
- const liteContract = (yield (async () => {
508
+ const liteContract = await (async () => {
497
509
  try {
498
510
  const rawContractResponse = await contractClient.getDataContract(
499
511
  contractId,
@@ -512,7 +524,7 @@ export class EntitlementsDashboardState {
512
524
  assertErrorThrown(error);
513
525
  return undefined;
514
526
  }
515
- })()) as V1_LiteDataContract | undefined;
527
+ })();
516
528
  if (!liteContract) {
517
529
  return [];
518
530
  }
@@ -525,7 +537,7 @@ export class EntitlementsDashboardState {
525
537
  return [];
526
538
  }
527
539
 
528
- const dpDetails = (yield (async () => {
540
+ const dpDetails = await (async () => {
529
541
  try {
530
542
  const raw = await contractClient.getDataProductByIdAndDID(
531
543
  liteContract.resourceId,
@@ -539,7 +551,7 @@ export class EntitlementsDashboardState {
539
551
  assertErrorThrown(error);
540
552
  return undefined;
541
553
  }
542
- })()) as V1_EntitlementsDataProductDetails | undefined;
554
+ })();
543
555
  if (!dpDetails) {
544
556
  return [];
545
557
  }
@@ -553,7 +565,7 @@ export class EntitlementsDashboardState {
553
565
  applicationStore.logService,
554
566
  baseStore.remoteEngine,
555
567
  );
556
- yield graphManager.initialize(
568
+ await graphManager.initialize(
557
569
  {
558
570
  env: applicationStore.config.env,
559
571
  tabSize: DEFAULT_TAB_SIZE,
@@ -564,11 +576,11 @@ export class EntitlementsDashboardState {
564
576
  { engine: baseStore.remoteEngine },
565
577
  );
566
578
 
567
- const v1DataProduct = (yield getDataProductFromDetails(
579
+ const v1DataProduct = await getDataProductFromDetails(
568
580
  dpDetails,
569
581
  graphManager,
570
582
  baseStore,
571
- )) as V1_DataProduct | undefined;
583
+ );
572
584
  if (!v1DataProduct) {
573
585
  return [];
574
586
  }
@@ -584,10 +596,10 @@ export class EntitlementsDashboardState {
584
596
  }
585
597
 
586
598
  const ingestEnvironment =
587
- (yield baseStore.lakehouseDataProductService.getOrFetchEnvironmentForDID(
599
+ await baseStore.lakehouseDataProductService.getOrFetchEnvironmentForDID(
588
600
  liteContract.deploymentId,
589
601
  token,
590
- )) as IngestDeploymentServerConfig | undefined;
602
+ );
591
603
  const ingestServerUrl = ingestEnvironment?.ingestServerUrl;
592
604
  if (ingestServerUrl === undefined) {
593
605
  return [];
@@ -604,7 +616,7 @@ export class EntitlementsDashboardState {
604
616
  }));
605
617
 
606
618
  const ingestClient = baseStore.lakehouseIngestServerClient;
607
- const settled = (yield Promise.all(
619
+ const settled = await Promise.all(
608
620
  specsToVerify.map(async (entry) => {
609
621
  try {
610
622
  await ingestClient.getIngestDefinitionDetail(
@@ -615,18 +627,100 @@ export class EntitlementsDashboardState {
615
627
  return undefined;
616
628
  } catch (error) {
617
629
  assertErrorThrown(error);
618
- return entry.specPath;
630
+ if (
631
+ error instanceof NetworkClientError &&
632
+ error.response.status === HttpStatus.NOT_FOUND
633
+ ) {
634
+ return entry.specPath;
635
+ }
636
+ return undefined;
619
637
  }
620
638
  }),
621
- )) as (string | undefined)[];
639
+ );
622
640
  return settled.filter(isNonNullable);
641
+ } catch (error) {
642
+ assertErrorThrown(error);
643
+ return [];
644
+ }
645
+ }
646
+
647
+ async getContractSyncErrors(
648
+ contractId: string,
649
+ token: string | undefined,
650
+ ): Promise<ContractErrorLayer | undefined> {
651
+ try {
652
+ const response =
653
+ (await this.lakehouseEntitlementsStore.lakehouseContractServerClient.getContractSyncStatus(
654
+ contractId,
655
+ token,
656
+ )) as LakehouseContractSyncStatusResponse;
657
+
658
+ const status = response.status.toUpperCase();
659
+
660
+ if (status === ContractSyncStatus.NEVER_SYNCED) {
661
+ return { title: 'Sync Error: Contract Never Synced' };
662
+ }
663
+
664
+ if (status === ContractSyncStatus.NOT_FULLY_SYNCED) {
665
+ const unsyncedUsers =
666
+ response.unsyncedUsers?.map((user) => user.username) ?? [];
667
+ const unsyncedAccessPoints =
668
+ response.unsyncedAccessPoints?.map(
669
+ (accessPoint) => accessPoint.accessPointName,
670
+ ) ?? [];
671
+ const unsyncedTargetAccounts = response.unsyncedTargetAccounts ?? [];
672
+
673
+ const syncGroupingLayers: ContractErrorLayer[] = [
674
+ { title: 'Users', errorItems: unsyncedUsers },
675
+ { title: 'Target Accounts', errorItems: unsyncedTargetAccounts },
676
+ { title: 'Access Points', errorItems: unsyncedAccessPoints },
677
+ ].filter((layer) => layer.errorItems.length > 0);
678
+
679
+ if (syncGroupingLayers.length === 0) {
680
+ return undefined;
681
+ }
682
+
683
+ return {
684
+ title: 'Unsynced Entities',
685
+ childLayers: syncGroupingLayers,
686
+ };
687
+ }
688
+
689
+ return undefined;
623
690
  } catch (error) {
624
691
  assertErrorThrown(error);
625
692
  return undefined;
626
693
  }
627
694
  }
628
695
 
629
- private filterByUserEnvironment(
696
+ async getContractErrors(
697
+ contractId: string,
698
+ token: string | undefined,
699
+ checkSyncStatus = false,
700
+ ): Promise<ContractErrorLayer | undefined> {
701
+ const [unverifiedIngestDefinitions, syncErrorsLayer] = await Promise.all([
702
+ this.getUnverifiedIngestDefinitions(contractId, token),
703
+ checkSyncStatus
704
+ ? this.getContractSyncErrors(contractId, token)
705
+ : Promise.resolve(undefined),
706
+ ]);
707
+
708
+ const childLayers: ContractErrorLayer[] = [
709
+ unverifiedIngestDefinitions.length > 0
710
+ ? {
711
+ title: `Ingest${unverifiedIngestDefinitions.length === 1 ? '' : 's'} Not Found`,
712
+ errorItems: unverifiedIngestDefinitions,
713
+ }
714
+ : undefined,
715
+ syncErrorsLayer,
716
+ ].filter(isNonNullable);
717
+
718
+ return childLayers.length > 0
719
+ ? { title: 'Contract Errors', childLayers }
720
+ : undefined;
721
+ }
722
+
723
+ filterByUserEnvironment(
630
724
  pendingData: {
631
725
  tasks: V1_ContractUserEventRecord[];
632
726
  taskContractMap: Map<string, V1_LiteDataContract>;