@finos/legend-extension-dsl-data-product 0.0.19 → 0.0.21

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 (30) hide show
  1. package/lib/components/DataProduct/DataContract/EntitlementsDataContractViewer.d.ts +1 -2
  2. package/lib/components/DataProduct/DataContract/EntitlementsDataContractViewer.d.ts.map +1 -1
  3. package/lib/components/DataProduct/DataContract/EntitlementsDataContractViewer.js +64 -18
  4. package/lib/components/DataProduct/DataContract/EntitlementsDataContractViewer.js.map +1 -1
  5. package/lib/components/DataProduct/DataProductDataAccess.d.ts.map +1 -1
  6. package/lib/components/DataProduct/DataProductDataAccess.js +37 -5
  7. package/lib/components/DataProduct/DataProductDataAccess.js.map +1 -1
  8. package/lib/components/__test-utils__/TEST_DATA__LakehouseContractData.d.ts +4 -2
  9. package/lib/components/__test-utils__/TEST_DATA__LakehouseContractData.d.ts.map +1 -1
  10. package/lib/components/__test-utils__/TEST_DATA__LakehouseContractData.js +130 -1
  11. package/lib/components/__test-utils__/TEST_DATA__LakehouseContractData.js.map +1 -1
  12. package/lib/components/__test-utils__/TEST_DATA__LakehouseDataProducts.js +3 -3
  13. package/lib/components/__test-utils__/TEST_DATA__LakehouseDataProducts.js.map +1 -1
  14. package/lib/index.css +1 -1
  15. package/lib/package.json +1 -1
  16. package/lib/stores/DataProduct/DataProductAccessPointState.d.ts +4 -1
  17. package/lib/stores/DataProduct/DataProductAccessPointState.d.ts.map +1 -1
  18. package/lib/stores/DataProduct/DataProductAccessPointState.js +19 -0
  19. package/lib/stores/DataProduct/DataProductAccessPointState.js.map +1 -1
  20. package/lib/stores/DataProduct/EntitlementsDataContractViewerState.d.ts +10 -3
  21. package/lib/stores/DataProduct/EntitlementsDataContractViewerState.d.ts.map +1 -1
  22. package/lib/stores/DataProduct/EntitlementsDataContractViewerState.js +38 -9
  23. package/lib/stores/DataProduct/EntitlementsDataContractViewerState.js.map +1 -1
  24. package/package.json +9 -9
  25. package/src/components/DataProduct/DataContract/EntitlementsDataContractViewer.tsx +289 -150
  26. package/src/components/DataProduct/DataProductDataAccess.tsx +43 -4
  27. package/src/components/__test-utils__/TEST_DATA__LakehouseContractData.ts +137 -2
  28. package/src/components/__test-utils__/TEST_DATA__LakehouseDataProducts.ts +3 -3
  29. package/src/stores/DataProduct/DataProductAccessPointState.ts +25 -0
  30. package/src/stores/DataProduct/EntitlementsDataContractViewerState.ts +64 -13
@@ -17,6 +17,7 @@
17
17
  import {
18
18
  type V1_ContractUserEventDataProducerPayload,
19
19
  type V1_ContractUserEventPrivilegeManagerPayload,
20
+ type V1_DataContract,
20
21
  type V1_LiteDataContract,
21
22
  type V1_TaskResponse,
22
23
  V1_ApprovalType,
@@ -76,7 +77,53 @@ export const mockDataContractMultipleConsumers: V1_LiteDataContract = {
76
77
  accessPointGroup: 'GROUP1',
77
78
  };
78
79
 
79
- export const mockPendingManagerApprovalTasksResponse: V1_TaskResponse = {
80
+ export const mockDataContractWithSystemAccountMember: V1_DataContract = {
81
+ description: 'Test data contract with system account member',
82
+ guid: 'test-data-contract-with-system-account-member-id',
83
+ version: 0,
84
+ state: V1_ContractState.OPEN_FOR_PRIVILEGE_MANAGER_APPROVAL,
85
+ resource: {
86
+ _type: V1_ResourceType.ACCESS_POINT_GROUP,
87
+ dataProduct: 'MOCK_SDLC_DATAPRODUCT',
88
+ accessPointGroup: 'GROUP1',
89
+ },
90
+ members: [
91
+ {
92
+ guid: 'member-1-guid',
93
+ user: {
94
+ name: 'test-consumer-user-id',
95
+ userType: V1_UserType.WORKFORCE_USER,
96
+ },
97
+ status: V1_UserApprovalStatus.PENDING,
98
+ },
99
+ {
100
+ guid: 'member-2-guid',
101
+ user: {
102
+ name: 'test-system-account-user-id',
103
+ userType: V1_UserType.SYSTEM_ACCOUNT,
104
+ },
105
+ status: V1_UserApprovalStatus.PENDING,
106
+ },
107
+ ],
108
+ consumer: {
109
+ _type: V1_OrganizationalScopeType.AdHocTeam,
110
+ users: [
111
+ {
112
+ name: 'test-consumer-user-id',
113
+ type: V1_UserType.WORKFORCE_USER,
114
+ },
115
+ {
116
+ name: 'test-system-account-user-id',
117
+ type: V1_UserType.SYSTEM_ACCOUNT,
118
+ },
119
+ ],
120
+ },
121
+ createdBy: 'test-requester-user-id',
122
+ };
123
+
124
+ export const getMockPendingManagerApprovalTasksResponse = (
125
+ isEscalated: boolean = false,
126
+ ): V1_TaskResponse => ({
80
127
  tasks: [
81
128
  {
82
129
  assignees: ['test-privilege-manager-user-id'],
@@ -90,10 +137,74 @@ export const mockPendingManagerApprovalTasksResponse: V1_TaskResponse = {
90
137
  status: V1_UserApprovalStatus.PENDING,
91
138
  taskId: 'mock-privilege-manager-approval-task-id',
92
139
  type: V1_ApprovalType.CONSUMER_PRIVILEGE_MANAGER_APPROVAL,
140
+ effectiveFrom: '2025-08-07T00:00:00.000Z',
141
+ effectiveTo: '2026-08-07T00:00:00.000Z',
142
+ isEscalated,
143
+ },
144
+ },
145
+ {
146
+ assignees: ['test-privilege-manager-user-id'],
147
+ rec: {
148
+ consumer: 'test-consumer-user-id-2',
149
+ dataContractId: 'test-data-contract-id',
150
+ eventPayload: {
151
+ type: V1_ContractEventPayloadType.SUBMITTED,
152
+ eventTimestamp: '2025-08-06T11:54:46.069672876Z',
153
+ },
154
+ status: V1_UserApprovalStatus.PENDING,
155
+ taskId: 'mock-privilege-manager-approval-task-id-2',
156
+ type: V1_ApprovalType.CONSUMER_PRIVILEGE_MANAGER_APPROVAL,
157
+ effectiveFrom: '2025-08-07T00:00:00.000Z',
158
+ effectiveTo: '2026-08-07T00:00:00.000Z',
159
+ isEscalated,
160
+ },
161
+ },
162
+ {
163
+ assignees: ['test-privilege-manager-user-id'],
164
+ rec: {
165
+ consumer: 'test-system-account-user-id',
166
+ dataContractId: 'test-data-contract-id',
167
+ eventPayload: {
168
+ type: V1_ContractEventPayloadType.SUBMITTED,
169
+ eventTimestamp: '2025-08-06T11:54:46.069672876Z',
170
+ },
171
+ status: V1_UserApprovalStatus.PENDING,
172
+ taskId: 'mock-privilege-manager-approval-task-id-3',
173
+ type: V1_ApprovalType.CONSUMER_PRIVILEGE_MANAGER_APPROVAL,
174
+ effectiveFrom: '2025-08-07T00:00:00.000Z',
175
+ effectiveTo: '2026-08-07T00:00:00.000Z',
176
+ isEscalated,
93
177
  },
94
178
  },
95
179
  ],
96
- };
180
+ });
181
+
182
+ export const mockEscalatedPendingManagerApprovalTasksResponse: V1_TaskResponse =
183
+ {
184
+ tasks: [
185
+ {
186
+ assignees: [
187
+ 'test-privilege-manager-user-id',
188
+ 'test-privilege-manager-user-id-2',
189
+ 'test-privilege-manager-user-id-3',
190
+ ],
191
+ rec: {
192
+ consumer: 'test-consumer-user-id',
193
+ dataContractId: 'test-data-contract-id',
194
+ eventPayload: {
195
+ type: V1_ContractEventPayloadType.SUBMITTED,
196
+ eventTimestamp: '2025-08-06T11:54:46.069672876Z',
197
+ },
198
+ status: V1_UserApprovalStatus.PENDING,
199
+ taskId: 'mock-privilege-manager-approval-task-id',
200
+ type: V1_ApprovalType.CONSUMER_PRIVILEGE_MANAGER_APPROVAL,
201
+ effectiveFrom: '2025-08-07T00:00:00.000Z',
202
+ effectiveTo: '2026-08-07T00:00:00.000Z',
203
+ isEscalated: true,
204
+ },
205
+ },
206
+ ],
207
+ };
97
208
 
98
209
  export const mockPendingManagerApprovalMultipleAssigneesTasksResponse: V1_TaskResponse =
99
210
  {
@@ -113,6 +224,9 @@ export const mockPendingManagerApprovalMultipleAssigneesTasksResponse: V1_TaskRe
113
224
  status: V1_UserApprovalStatus.PENDING,
114
225
  taskId: 'mock-privilege-manager-approval-task-id',
115
226
  type: V1_ApprovalType.CONSUMER_PRIVILEGE_MANAGER_APPROVAL,
227
+ effectiveFrom: '2025-08-07T00:00:00.000Z',
228
+ effectiveTo: '2026-08-07T00:00:00.000Z',
229
+ isEscalated: false,
116
230
  },
117
231
  },
118
232
  ],
@@ -133,6 +247,9 @@ export const mockPendingManagerApprovalMultipleConsumersTasksResponse: V1_TaskRe
133
247
  status: V1_UserApprovalStatus.PENDING,
134
248
  taskId: 'mock-privilege-manager-approval-task-id',
135
249
  type: V1_ApprovalType.CONSUMER_PRIVILEGE_MANAGER_APPROVAL,
250
+ effectiveFrom: '2025-08-07T00:00:00.000Z',
251
+ effectiveTo: '2026-08-07T00:00:00.000Z',
252
+ isEscalated: false,
136
253
  },
137
254
  },
138
255
  {
@@ -147,6 +264,9 @@ export const mockPendingManagerApprovalMultipleConsumersTasksResponse: V1_TaskRe
147
264
  status: V1_UserApprovalStatus.PENDING,
148
265
  taskId: 'mock-privilege-manager-approval-task-id',
149
266
  type: V1_ApprovalType.CONSUMER_PRIVILEGE_MANAGER_APPROVAL,
267
+ effectiveFrom: '2025-08-07T00:00:00.000Z',
268
+ effectiveTo: '2026-08-07T00:00:00.000Z',
269
+ isEscalated: false,
150
270
  },
151
271
  },
152
272
  ],
@@ -169,6 +289,9 @@ export const mockPendingDataOwnerApprovalTasksResponse: V1_TaskResponse = {
169
289
  status: V1_UserApprovalStatus.APPROVED,
170
290
  taskId: 'mock-privilege-manager-approval-task-id',
171
291
  type: V1_ApprovalType.CONSUMER_PRIVILEGE_MANAGER_APPROVAL,
292
+ effectiveFrom: '2025-08-07T00:00:00.000Z',
293
+ effectiveTo: '2026-08-07T00:00:00.000Z',
294
+ isEscalated: false,
172
295
  },
173
296
  },
174
297
  {
@@ -186,6 +309,9 @@ export const mockPendingDataOwnerApprovalTasksResponse: V1_TaskResponse = {
186
309
  status: V1_UserApprovalStatus.PENDING,
187
310
  taskId: 'mock-data-owner-approval-task-id',
188
311
  type: V1_ApprovalType.DATA_OWNER_APPROVAL,
312
+ effectiveFrom: '2025-08-07T00:00:00.000Z',
313
+ effectiveTo: '2026-08-07T00:00:00.000Z',
314
+ isEscalated: false,
189
315
  },
190
316
  },
191
317
  ],
@@ -208,6 +334,9 @@ export const mockApprovedTasksResponse: V1_TaskResponse = {
208
334
  status: V1_UserApprovalStatus.APPROVED,
209
335
  taskId: 'mock-privilege-manager-approval-task-id',
210
336
  type: V1_ApprovalType.CONSUMER_PRIVILEGE_MANAGER_APPROVAL,
337
+ effectiveFrom: '2025-08-07T00:00:00.000Z',
338
+ effectiveTo: '2026-08-07T00:00:00.000Z',
339
+ isEscalated: false,
211
340
  },
212
341
  },
213
342
  {
@@ -225,6 +354,9 @@ export const mockApprovedTasksResponse: V1_TaskResponse = {
225
354
  status: V1_UserApprovalStatus.APPROVED,
226
355
  taskId: 'mock-data-owner-approval-task-id',
227
356
  type: V1_ApprovalType.DATA_OWNER_APPROVAL,
357
+ effectiveFrom: '2025-08-07T00:00:00.000Z',
358
+ effectiveTo: '2026-08-07T00:00:00.000Z',
359
+ isEscalated: false,
228
360
  },
229
361
  },
230
362
  ],
@@ -247,6 +379,9 @@ export const mockDeniedTasksResponse: V1_TaskResponse = {
247
379
  status: V1_UserApprovalStatus.DENIED,
248
380
  taskId: 'mock-privilege-manager-denied-task-id',
249
381
  type: V1_ApprovalType.CONSUMER_PRIVILEGE_MANAGER_APPROVAL,
382
+ effectiveFrom: '2025-08-07T00:00:00.000Z',
383
+ effectiveTo: '2026-08-07T00:00:00.000Z',
384
+ isEscalated: false,
250
385
  },
251
386
  },
252
387
  ],
@@ -59,7 +59,7 @@ export const mockEntitlementsSDLCDataProduct: V1_EntitlementsDataProductDetails
59
59
  });
60
60
 
61
61
  export const mockSDLCDataProduct: V1_DataProduct = deserialize(
62
- V1_dataProductModelSchema,
62
+ V1_dataProductModelSchema([]),
63
63
  {
64
64
  _type: 'dataProduct',
65
65
  package: 'test',
@@ -153,7 +153,7 @@ export const mockEntitlementsSDLCDataProductNoSupportInfo: V1_EntitlementsDataPr
153
153
  });
154
154
 
155
155
  export const mockSDLCDataProductNoSupportInfo: V1_DataProduct = deserialize(
156
- V1_dataProductModelSchema,
156
+ V1_dataProductModelSchema([]),
157
157
  {
158
158
  _type: 'dataProduct',
159
159
  package: 'test',
@@ -226,7 +226,7 @@ export const mockEntitlementsEnterpriseDataProduct: V1_EntitlementsDataProductDe
226
226
  });
227
227
 
228
228
  export const mockEnterpriseDataProduct: V1_DataProduct = deserialize(
229
- V1_dataProductModelSchema,
229
+ V1_dataProductModelSchema([]),
230
230
  {
231
231
  _type: 'dataProduct',
232
232
  package: 'test',
@@ -26,6 +26,7 @@ import {
26
26
  V1_Protocol,
27
27
  V1_PureGraphManager,
28
28
  V1_PureModelContextPointer,
29
+ type V1_RelationElement,
29
30
  V1_RelationType,
30
31
  V1_relationTypeModelSchema,
31
32
  V1_RenderStyle,
@@ -48,9 +49,11 @@ export class DataProductAccessPointState {
48
49
  readonly apgState: DataProductAPGState;
49
50
  readonly accessPoint: V1_AccessPoint;
50
51
  relationType: V1_RelationType | undefined;
52
+ relationElement: V1_RelationElement | undefined;
51
53
  grammar: string | undefined;
52
54
 
53
55
  readonly fetchingRelationTypeState = ActionState.create();
56
+ readonly fetchingRelationElement = ActionState.create();
54
57
  readonly fetchingGrammarState = ActionState.create();
55
58
 
56
59
  constructor(apgState: DataProductAPGState, accessPoint: V1_AccessPoint) {
@@ -75,6 +78,7 @@ export class DataProductAccessPointState {
75
78
  dataProductArtifactPromise,
76
79
  entitlementsDataProductDetails,
77
80
  ),
81
+ this.fetchSampleDataFromArtifact(dataProductArtifactPromise),
78
82
  this.fetchGrammar(),
79
83
  ]);
80
84
  }
@@ -97,6 +101,27 @@ export class DataProductAccessPointState {
97
101
  }
98
102
  }
99
103
 
104
+ async fetchSampleDataFromArtifact(
105
+ dataProductArtifactPromise: Promise<V1_DataProductArtifact | undefined>,
106
+ ): Promise<void> {
107
+ this.fetchingRelationElement.inProgress();
108
+ try {
109
+ const artifact = await dataProductArtifactPromise;
110
+ this.relationElement = artifact?.accessPointGroups
111
+ .find((apg) => apg.id === this.apgState.apg.id)
112
+ ?.accessPointImplementations.find(
113
+ (ap) => ap.id === this.accessPoint.id,
114
+ )?.relationElement;
115
+ } catch (error) {
116
+ assertErrorThrown(error);
117
+ this.apgState.applicationStore.notificationService.notifyError(
118
+ `Error fetching access point sample data: ${error.message}`,
119
+ );
120
+ } finally {
121
+ this.fetchingRelationElement.complete();
122
+ }
123
+ }
124
+
100
125
  async fetchRelationTypeFromEngine(
101
126
  abortController: AbortController,
102
127
  entitlementsDataProductDetails?:
@@ -15,15 +15,18 @@
15
15
  */
16
16
 
17
17
  import {
18
+ type GraphManagerState,
19
+ type V1_DataContract,
18
20
  type V1_LiteDataContract,
19
21
  type V1_TaskMetadata,
20
- type V1_TaskResponse,
22
+ type V1_UserType,
23
+ V1_dataContractsResponseModelSchemaToContracts,
21
24
  V1_deserializeTaskResponse,
25
+ V1_observe_DataContract,
22
26
  V1_observe_LiteDataContract,
23
27
  } from '@finos/legend-graph';
24
28
  import {
25
29
  type GeneratorFn,
26
- type PlainObject,
27
30
  type UserSearchService,
28
31
  ActionState,
29
32
  assertErrorThrown,
@@ -33,29 +36,37 @@ import type { GenericLegendApplicationStore } from '@finos/legend-application';
33
36
  import type { LakehouseContractServerClient } from '@finos/legend-server-lakehouse';
34
37
 
35
38
  export class EntitlementsDataContractViewerState {
36
- readonly value: V1_LiteDataContract;
39
+ readonly liteContract: V1_LiteDataContract;
37
40
  readonly applicationStore: GenericLegendApplicationStore;
38
41
  readonly lakehouseContractServerClient: LakehouseContractServerClient;
42
+ readonly graphManagerState: GraphManagerState;
39
43
  readonly userSearchService?: UserSearchService | undefined;
40
44
  associatedTasks: V1_TaskMetadata[] | undefined;
41
45
  initializationState = ActionState.create();
46
+ contractWithMembers: V1_DataContract | undefined;
47
+
48
+ readonly fetchingMembersState = ActionState.create();
42
49
 
43
50
  constructor(
44
51
  dataContract: V1_LiteDataContract,
45
52
  applicationStore: GenericLegendApplicationStore,
46
53
  lakehouseContractServerClient: LakehouseContractServerClient,
54
+ graphManagerState: GraphManagerState,
47
55
  userSearchService: UserSearchService | undefined,
48
56
  ) {
49
57
  makeObservable(this, {
50
- value: observable,
58
+ liteContract: observable,
51
59
  associatedTasks: observable,
60
+ contractWithMembers: observable,
52
61
  setAssociatedTasks: action,
62
+ setContractWithMembers: action,
53
63
  init: flow,
54
64
  });
55
65
 
56
- this.value = V1_observe_LiteDataContract(dataContract);
66
+ this.liteContract = V1_observe_LiteDataContract(dataContract);
57
67
  this.applicationStore = applicationStore;
58
68
  this.lakehouseContractServerClient = lakehouseContractServerClient;
69
+ this.graphManagerState = graphManagerState;
59
70
  this.userSearchService = userSearchService;
60
71
  }
61
72
 
@@ -63,21 +74,61 @@ export class EntitlementsDataContractViewerState {
63
74
  this.associatedTasks = associatedTasks;
64
75
  }
65
76
 
77
+ setContractWithMembers(
78
+ contractWithMembers: V1_DataContract | undefined,
79
+ ): void {
80
+ this.contractWithMembers = contractWithMembers;
81
+ }
82
+
83
+ async fetchTasks(token: string | undefined): Promise<void> {
84
+ this.setAssociatedTasks(undefined);
85
+ const pendingTasks =
86
+ await this.lakehouseContractServerClient.getContractTasks(
87
+ this.liteContract.guid,
88
+ token,
89
+ );
90
+ const tasks = V1_deserializeTaskResponse(pendingTasks);
91
+ this.setAssociatedTasks(tasks);
92
+ }
93
+
94
+ async fetchContractWithMembers(token: string | undefined): Promise<void> {
95
+ this.fetchingMembersState.inProgress();
96
+ try {
97
+ const rawContracts =
98
+ await this.lakehouseContractServerClient.getDataContract(
99
+ this.liteContract.guid,
100
+ true,
101
+ token,
102
+ );
103
+ const contracts = V1_dataContractsResponseModelSchemaToContracts(
104
+ rawContracts,
105
+ this.graphManagerState.pluginManager.getPureProtocolProcessorPlugins(),
106
+ );
107
+ this.setContractWithMembers(
108
+ contracts[0] ? V1_observe_DataContract(contracts[0]) : undefined,
109
+ );
110
+ } finally {
111
+ this.fetchingMembersState.complete();
112
+ }
113
+ }
114
+
66
115
  *init(token: string | undefined): GeneratorFn<void> {
67
116
  try {
68
117
  this.initializationState.inProgress();
69
- this.setAssociatedTasks(undefined);
70
- const pendingTasks =
71
- (yield this.lakehouseContractServerClient.getContractTasks(
72
- this.value.guid,
73
- token,
74
- )) as PlainObject<V1_TaskResponse>;
75
- const tasks = V1_deserializeTaskResponse(pendingTasks);
76
- this.setAssociatedTasks(tasks);
118
+ yield Promise.all([
119
+ this.fetchTasks(token),
120
+ this.fetchContractWithMembers(token),
121
+ ]);
77
122
  } catch (error) {
78
123
  assertErrorThrown(error);
79
124
  } finally {
80
125
  this.initializationState.complete();
81
126
  }
82
127
  }
128
+
129
+ getContractUserType(userId: string): V1_UserType | undefined {
130
+ return this.contractWithMembers?.members.find(
131
+ (member) => member.user.name === userId,
132
+ )?.user.userType;
133
+ }
83
134
  }