@finos/legend-extension-dsl-data-product 0.0.2

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 (143) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +3 -0
  3. package/lib/__lib__/DSL_DataProduct_Event.d.ts +19 -0
  4. package/lib/__lib__/DSL_DataProduct_Event.d.ts.map +1 -0
  5. package/lib/__lib__/DSL_DataProduct_Event.js +20 -0
  6. package/lib/__lib__/DSL_DataProduct_Event.js.map +1 -0
  7. package/lib/components/Core_DataProductDataAccess_LegendApplicationPlugin.d.ts +25 -0
  8. package/lib/components/Core_DataProductDataAccess_LegendApplicationPlugin.d.ts.map +1 -0
  9. package/lib/components/Core_DataProductDataAccess_LegendApplicationPlugin.js +105 -0
  10. package/lib/components/Core_DataProductDataAccess_LegendApplicationPlugin.js.map +1 -0
  11. package/lib/components/DataProduct/DataContract/EntitlementsDataContractCreator.d.ts +27 -0
  12. package/lib/components/DataProduct/DataContract/EntitlementsDataContractCreator.d.ts.map +1 -0
  13. package/lib/components/DataProduct/DataContract/EntitlementsDataContractCreator.js +57 -0
  14. package/lib/components/DataProduct/DataContract/EntitlementsDataContractCreator.js.map +1 -0
  15. package/lib/components/DataProduct/DataContract/EntitlementsDataContractViewer.d.ts +29 -0
  16. package/lib/components/DataProduct/DataContract/EntitlementsDataContractViewer.d.ts.map +1 -0
  17. package/lib/components/DataProduct/DataContract/EntitlementsDataContractViewer.js +165 -0
  18. package/lib/components/DataProduct/DataContract/EntitlementsDataContractViewer.js.map +1 -0
  19. package/lib/components/DataProduct/DataProductDataAccess.d.ts +34 -0
  20. package/lib/components/DataProduct/DataProductDataAccess.d.ts.map +1 -0
  21. package/lib/components/DataProduct/DataProductDataAccess.js +336 -0
  22. package/lib/components/DataProduct/DataProductDataAccess.js.map +1 -0
  23. package/lib/components/DataProduct/DataProductSupportInfo.d.ts +22 -0
  24. package/lib/components/DataProduct/DataProductSupportInfo.d.ts.map +1 -0
  25. package/lib/components/DataProduct/DataProductSupportInfo.js +43 -0
  26. package/lib/components/DataProduct/DataProductSupportInfo.js.map +1 -0
  27. package/lib/components/DataProduct/Subscriptions/DataProductSubscriptionsViewer.d.ts +26 -0
  28. package/lib/components/DataProduct/Subscriptions/DataProductSubscriptionsViewer.d.ts.map +1 -0
  29. package/lib/components/DataProduct/Subscriptions/DataProductSubscriptionsViewer.js +219 -0
  30. package/lib/components/DataProduct/Subscriptions/DataProductSubscriptionsViewer.js.map +1 -0
  31. package/lib/components/ProductViewer.d.ts +33 -0
  32. package/lib/components/ProductViewer.d.ts.map +1 -0
  33. package/lib/components/ProductViewer.js +113 -0
  34. package/lib/components/ProductViewer.js.map +1 -0
  35. package/lib/components/ProductWiki.d.ts +39 -0
  36. package/lib/components/ProductWiki.d.ts.map +1 -0
  37. package/lib/components/ProductWiki.js +95 -0
  38. package/lib/components/ProductWiki.js.map +1 -0
  39. package/lib/components/TerminalProduct/TerminalProductPrice.d.ts +22 -0
  40. package/lib/components/TerminalProduct/TerminalProductPrice.d.ts.map +1 -0
  41. package/lib/components/TerminalProduct/TerminalProductPrice.js +39 -0
  42. package/lib/components/TerminalProduct/TerminalProductPrice.js.map +1 -0
  43. package/lib/components/UserRenderer/MultiUserRenderer.d.ts +24 -0
  44. package/lib/components/UserRenderer/MultiUserRenderer.d.ts.map +1 -0
  45. package/lib/components/UserRenderer/MultiUserRenderer.js +46 -0
  46. package/lib/components/UserRenderer/MultiUserRenderer.js.map +1 -0
  47. package/lib/components/UserRenderer/UserRenderer.d.ts +27 -0
  48. package/lib/components/UserRenderer/UserRenderer.d.ts.map +1 -0
  49. package/lib/components/UserRenderer/UserRenderer.js +57 -0
  50. package/lib/components/UserRenderer/UserRenderer.js.map +1 -0
  51. package/lib/components/__test-utils__/StateTestUtils.d.ts +36 -0
  52. package/lib/components/__test-utils__/StateTestUtils.d.ts.map +1 -0
  53. package/lib/components/__test-utils__/StateTestUtils.js +97 -0
  54. package/lib/components/__test-utils__/StateTestUtils.js.map +1 -0
  55. package/lib/components/__test-utils__/TEST_DATA__LakehouseContractData.d.ts +25 -0
  56. package/lib/components/__test-utils__/TEST_DATA__LakehouseContractData.d.ts.map +1 -0
  57. package/lib/components/__test-utils__/TEST_DATA__LakehouseContractData.js +231 -0
  58. package/lib/components/__test-utils__/TEST_DATA__LakehouseContractData.js.map +1 -0
  59. package/lib/components/__test-utils__/TEST_DATA__LakehouseDataProducts.d.ts +71 -0
  60. package/lib/components/__test-utils__/TEST_DATA__LakehouseDataProducts.d.ts.map +1 -0
  61. package/lib/components/__test-utils__/TEST_DATA__LakehouseDataProducts.js +316 -0
  62. package/lib/components/__test-utils__/TEST_DATA__LakehouseDataProducts.js.map +1 -0
  63. package/lib/index.css +17 -0
  64. package/lib/index.css.map +1 -0
  65. package/lib/index.d.ts +32 -0
  66. package/lib/index.d.ts.map +1 -0
  67. package/lib/index.js +32 -0
  68. package/lib/index.js.map +1 -0
  69. package/lib/package.json +95 -0
  70. package/lib/stores/BaseLayoutState.d.ts +35 -0
  71. package/lib/stores/BaseLayoutState.d.ts.map +1 -0
  72. package/lib/stores/BaseLayoutState.js +166 -0
  73. package/lib/stores/BaseLayoutState.js.map +1 -0
  74. package/lib/stores/BaseViewerState.d.ts +33 -0
  75. package/lib/stores/BaseViewerState.d.ts.map +1 -0
  76. package/lib/stores/BaseViewerState.js +27 -0
  77. package/lib/stores/BaseViewerState.js.map +1 -0
  78. package/lib/stores/DataProduct/DataProductAPGState.d.ts +62 -0
  79. package/lib/stores/DataProduct/DataProductAPGState.d.ts.map +1 -0
  80. package/lib/stores/DataProduct/DataProductAPGState.js +222 -0
  81. package/lib/stores/DataProduct/DataProductAPGState.js.map +1 -0
  82. package/lib/stores/DataProduct/DataProductDataAccessState.d.ts +66 -0
  83. package/lib/stores/DataProduct/DataProductDataAccessState.d.ts.map +1 -0
  84. package/lib/stores/DataProduct/DataProductDataAccessState.js +191 -0
  85. package/lib/stores/DataProduct/DataProductDataAccessState.js.map +1 -0
  86. package/lib/stores/DataProduct/DataProductViewerState.d.ts +40 -0
  87. package/lib/stores/DataProduct/DataProductViewerState.d.ts.map +1 -0
  88. package/lib/stores/DataProduct/DataProductViewerState.js +60 -0
  89. package/lib/stores/DataProduct/DataProductViewerState.js.map +1 -0
  90. package/lib/stores/DataProduct/EntitlementsDataContractViewerState.d.ts +31 -0
  91. package/lib/stores/DataProduct/EntitlementsDataContractViewerState.d.ts.map +1 -0
  92. package/lib/stores/DataProduct/EntitlementsDataContractViewerState.js +57 -0
  93. package/lib/stores/DataProduct/EntitlementsDataContractViewerState.js.map +1 -0
  94. package/lib/stores/DataProductDataAccess_LegendApplicationPlugin_Extension.d.ts +33 -0
  95. package/lib/stores/DataProductDataAccess_LegendApplicationPlugin_Extension.d.ts.map +1 -0
  96. package/lib/stores/DataProductDataAccess_LegendApplicationPlugin_Extension.js +17 -0
  97. package/lib/stores/DataProductDataAccess_LegendApplicationPlugin_Extension.js.map +1 -0
  98. package/lib/stores/ProductViewerNavigation.d.ts +29 -0
  99. package/lib/stores/ProductViewerNavigation.d.ts.map +1 -0
  100. package/lib/stores/ProductViewerNavigation.js +35 -0
  101. package/lib/stores/ProductViewerNavigation.js.map +1 -0
  102. package/lib/stores/TerminalProduct/TerminalProductViewerState.d.ts +25 -0
  103. package/lib/stores/TerminalProduct/TerminalProductViewerState.d.ts.map +1 -0
  104. package/lib/stores/TerminalProduct/TerminalProductViewerState.js +32 -0
  105. package/lib/stores/TerminalProduct/TerminalProductViewerState.js.map +1 -0
  106. package/lib/utils/DataContractUtils.d.ts +23 -0
  107. package/lib/utils/DataContractUtils.d.ts.map +1 -0
  108. package/lib/utils/DataContractUtils.js +76 -0
  109. package/lib/utils/DataContractUtils.js.map +1 -0
  110. package/lib/utils/LakehouseUtils.d.ts +21 -0
  111. package/lib/utils/LakehouseUtils.d.ts.map +1 -0
  112. package/lib/utils/LakehouseUtils.js +72 -0
  113. package/lib/utils/LakehouseUtils.js.map +1 -0
  114. package/package.json +95 -0
  115. package/src/__lib__/DSL_DataProduct_Event.ts +19 -0
  116. package/src/components/Core_DataProductDataAccess_LegendApplicationPlugin.tsx +233 -0
  117. package/src/components/DataProduct/DataContract/EntitlementsDataContractCreator.tsx +182 -0
  118. package/src/components/DataProduct/DataContract/EntitlementsDataContractViewer.tsx +586 -0
  119. package/src/components/DataProduct/DataProductDataAccess.tsx +767 -0
  120. package/src/components/DataProduct/DataProductSupportInfo.tsx +195 -0
  121. package/src/components/DataProduct/Subscriptions/DataProductSubscriptionsViewer.tsx +602 -0
  122. package/src/components/ProductViewer.tsx +287 -0
  123. package/src/components/ProductWiki.tsx +196 -0
  124. package/src/components/TerminalProduct/TerminalProductPrice.tsx +56 -0
  125. package/src/components/UserRenderer/MultiUserRenderer.tsx +89 -0
  126. package/src/components/UserRenderer/UserRenderer.tsx +100 -0
  127. package/src/components/__test-utils__/StateTestUtils.ts +170 -0
  128. package/src/components/__test-utils__/TEST_DATA__LakehouseContractData.ts +253 -0
  129. package/src/components/__test-utils__/TEST_DATA__LakehouseDataProducts.ts +343 -0
  130. package/src/index.ts +34 -0
  131. package/src/stores/BaseLayoutState.ts +220 -0
  132. package/src/stores/BaseViewerState.ts +75 -0
  133. package/src/stores/DataProduct/DataProductAPGState.ts +385 -0
  134. package/src/stores/DataProduct/DataProductDataAccessState.ts +354 -0
  135. package/src/stores/DataProduct/DataProductViewerState.ts +100 -0
  136. package/src/stores/DataProduct/EntitlementsDataContractViewerState.ts +83 -0
  137. package/src/stores/DataProductDataAccess_LegendApplicationPlugin_Extension.ts +38 -0
  138. package/src/stores/ProductViewerNavigation.ts +48 -0
  139. package/src/stores/TerminalProduct/TerminalProductViewerState.ts +43 -0
  140. package/src/utils/DataContractUtils.ts +121 -0
  141. package/src/utils/LakehouseUtils.ts +91 -0
  142. package/tsconfig.json +91 -0
  143. package/tsconfig.package.json +56 -0
@@ -0,0 +1,385 @@
1
+ /**
2
+ * Copyright (c) 2020-present, Goldman Sachs
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+
17
+ import type { GenericLegendApplicationStore } from '@finos/legend-application';
18
+ import {
19
+ type V1_AccessPointGroup,
20
+ type V1_DataSubscription,
21
+ type V1_User,
22
+ type V1_ContractUserStatusResponse,
23
+ type V1_DataSubscriptionResponse,
24
+ type V1_DataSubscriptionTarget,
25
+ V1_DataContract,
26
+ V1_EnrichedUserApprovalStatus,
27
+ V1_DataContractApprovedUsersResponseModelSchema,
28
+ V1_dataContractsResponseModelSchemaToContracts,
29
+ V1_ContractUserStatusResponseModelSchema,
30
+ V1_dataSubscriptionModelSchema,
31
+ V1_CreateSubscriptionInput,
32
+ V1_CreateSubscriptionInputModelSchema,
33
+ V1_DataSubscriptionResponseModelSchema,
34
+ } from '@finos/legend-graph';
35
+ import {
36
+ type GeneratorFn,
37
+ type PlainObject,
38
+ ActionState,
39
+ assertErrorThrown,
40
+ guaranteeNonNullable,
41
+ isNonNullable,
42
+ uuid,
43
+ } from '@finos/legend-shared';
44
+ import { makeAutoObservable, action, observable, flow, computed } from 'mobx';
45
+ import { deserialize, serialize } from 'serializr';
46
+ import {
47
+ dataContractContainsAccessGroup,
48
+ isMemberOfContract,
49
+ contractContainsSystemAccount,
50
+ } from '../../utils/DataContractUtils.js';
51
+ import type { DataProductDataAccessState } from './DataProductDataAccessState.js';
52
+ import type { DataProductViewerState } from './DataProductViewerState.js';
53
+ import type { LakehouseContractServerClient } from '@finos/legend-server-lakehouse';
54
+
55
+ export enum AccessPointGroupAccess {
56
+ // can be used to indicate fetching or resyncing of group access
57
+ UNKNOWN = 'UNKNOWN',
58
+
59
+ PENDING_MANAGER_APPROVAL = 'PENDING_MANAGER_APPROVAL',
60
+ PENDING_DATA_OWNER_APPROVAL = 'PENDING_DATA_OWNER_APPROVAL',
61
+ APPROVED = 'APPROVED',
62
+ DENIED = 'DENIED',
63
+ NO_ACCESS = 'NO_ACCESS',
64
+ ENTERPRISE = 'ENTERPRISE', // Used to indicate that the group is available for all users in the organization
65
+ }
66
+
67
+ export class DataProductAPGState {
68
+ readonly dataProductViewerState: DataProductViewerState;
69
+ readonly applicationStore: GenericLegendApplicationStore;
70
+ readonly apg: V1_AccessPointGroup;
71
+ readonly id = uuid();
72
+
73
+ subscriptions: V1_DataSubscription[] = [];
74
+
75
+ // ASSUMPTION: one contract per user per group;
76
+ // false here mentions contracts have not been fetched
77
+ associatedContract: V1_DataContract | undefined | false = false;
78
+ userAccessStatus: V1_EnrichedUserApprovalStatus | undefined = undefined;
79
+
80
+ associatedSystemAccountContractsAndApprovedUsers: {
81
+ contract: V1_DataContract;
82
+ approvedUsers: V1_User[];
83
+ }[] = [];
84
+
85
+ fetchingAccessState = ActionState.create();
86
+ handlingContractsState = ActionState.create();
87
+ fetchingUserAccessState = ActionState.create();
88
+ fetchingApprovedContractsState = ActionState.create();
89
+ fetchingSubscriptionsState = ActionState.create();
90
+ creatingSubscriptionState = ActionState.create();
91
+
92
+ constructor(
93
+ group: V1_AccessPointGroup,
94
+ dataProductViewerState: DataProductViewerState,
95
+ ) {
96
+ makeAutoObservable(this, {
97
+ handleContractClick: action,
98
+ handleDataProductContracts: action,
99
+ associatedContract: observable,
100
+ userAccessStatus: observable,
101
+ associatedSystemAccountContractsAndApprovedUsers: observable,
102
+ setAssociatedContract: action,
103
+ fetchAndSetAssociatedSystemAccountContracts: flow,
104
+ subscriptions: observable,
105
+ fetchingSubscriptionsState: observable,
106
+ creatingSubscriptionState: observable,
107
+ createSubscription: flow,
108
+ setSubscriptions: action,
109
+ fetchUserAccessStatus: flow,
110
+ setUserAccessStatus: action,
111
+ canCreateSubscription: computed,
112
+ });
113
+
114
+ this.apg = group;
115
+ this.dataProductViewerState = dataProductViewerState;
116
+ this.applicationStore = dataProductViewerState.applicationStore;
117
+ }
118
+
119
+ get access(): AccessPointGroupAccess {
120
+ const publicStereotype =
121
+ this.dataProductViewerState.dataProductConfig?.publicStereotype;
122
+ if (
123
+ publicStereotype &&
124
+ this.apg.stereotypes.filter(
125
+ (stereotype) =>
126
+ stereotype.profile === publicStereotype.profile &&
127
+ stereotype.value === publicStereotype.stereotype,
128
+ ).length > 0
129
+ ) {
130
+ return AccessPointGroupAccess.ENTERPRISE;
131
+ }
132
+ if (this.associatedContract === false) {
133
+ return AccessPointGroupAccess.UNKNOWN;
134
+ } else if (
135
+ this.userAccessStatus ===
136
+ V1_EnrichedUserApprovalStatus.PENDING_CONSUMER_PRIVILEGE_MANAGER_APPROVAL
137
+ ) {
138
+ return AccessPointGroupAccess.PENDING_MANAGER_APPROVAL;
139
+ } else if (
140
+ this.userAccessStatus ===
141
+ V1_EnrichedUserApprovalStatus.PENDING_DATA_OWNER_APPROVAL
142
+ ) {
143
+ return AccessPointGroupAccess.PENDING_DATA_OWNER_APPROVAL;
144
+ } else if (
145
+ this.userAccessStatus === V1_EnrichedUserApprovalStatus.APPROVED
146
+ ) {
147
+ return AccessPointGroupAccess.APPROVED;
148
+ } else {
149
+ return AccessPointGroupAccess.NO_ACCESS;
150
+ }
151
+ }
152
+
153
+ get canCreateSubscription(): boolean {
154
+ return (
155
+ (this.associatedContract instanceof V1_DataContract &&
156
+ this.userAccessStatus === V1_EnrichedUserApprovalStatus.APPROVED) ||
157
+ this.associatedSystemAccountContractsAndApprovedUsers.some(
158
+ (contract) => contract.approvedUsers.length > 0,
159
+ )
160
+ );
161
+ }
162
+
163
+ setAssociatedContract(
164
+ val: V1_DataContract | undefined,
165
+ lakehouseContractServerClient: LakehouseContractServerClient,
166
+ token: string | undefined,
167
+ ): void {
168
+ this.associatedContract = val;
169
+
170
+ if (this.associatedContract) {
171
+ this.fetchUserAccessStatus(
172
+ this.associatedContract.guid,
173
+ lakehouseContractServerClient,
174
+ token,
175
+ );
176
+ }
177
+ }
178
+
179
+ *fetchAndSetAssociatedSystemAccountContracts(
180
+ systemAccountContracts: V1_DataContract[],
181
+ lakehouseContractServerClient: LakehouseContractServerClient,
182
+ token: string | undefined,
183
+ ): GeneratorFn<void> {
184
+ this.fetchingApprovedContractsState.inProgress();
185
+ try {
186
+ this.associatedSystemAccountContractsAndApprovedUsers =
187
+ (yield Promise.all(
188
+ systemAccountContracts.map(async (contract) => {
189
+ const rawApprovedUsers =
190
+ await lakehouseContractServerClient.getApprovedUsersForDataContract(
191
+ contract.guid,
192
+ token,
193
+ );
194
+ const approvedUsers =
195
+ deserialize(
196
+ V1_DataContractApprovedUsersResponseModelSchema,
197
+ rawApprovedUsers,
198
+ ).approvedUsers ?? [];
199
+ return {
200
+ contract,
201
+ approvedUsers,
202
+ };
203
+ }),
204
+ )) as { contract: V1_DataContract; approvedUsers: V1_User[] }[];
205
+ } catch (error) {
206
+ assertErrorThrown(error);
207
+ this.applicationStore.notificationService.notifyError(
208
+ `Error fetching approved users for contract: ${error.message}`,
209
+ );
210
+ } finally {
211
+ this.fetchingApprovedContractsState.complete();
212
+ }
213
+ }
214
+
215
+ setUserAccessStatus(val: V1_EnrichedUserApprovalStatus | undefined): void {
216
+ this.userAccessStatus = val;
217
+ }
218
+
219
+ setSubscriptions(val: V1_DataSubscription[]): void {
220
+ this.subscriptions = val;
221
+ }
222
+
223
+ async handleDataProductContracts(
224
+ contracts: V1_DataContract[],
225
+ lakehouseContractServerClient: LakehouseContractServerClient,
226
+ token: string | undefined,
227
+ ): Promise<void> {
228
+ try {
229
+ this.handlingContractsState.inProgress();
230
+
231
+ const accessPointGroupContracts = contracts.filter((_contract) =>
232
+ dataContractContainsAccessGroup(this.apg, _contract),
233
+ );
234
+ const rawAccessPointGroupContractsWithMembers = await Promise.all(
235
+ accessPointGroupContracts.map((_contract) =>
236
+ lakehouseContractServerClient.getDataContract(
237
+ _contract.guid,
238
+ true,
239
+ token,
240
+ ),
241
+ ),
242
+ );
243
+ const accessPointGroupContractsWithMembers =
244
+ rawAccessPointGroupContractsWithMembers.flatMap((_response) =>
245
+ V1_dataContractsResponseModelSchemaToContracts(
246
+ _response,
247
+ this.dataProductViewerState.graphManagerState.pluginManager.getPureProtocolProcessorPlugins(),
248
+ ),
249
+ );
250
+ const userContracts = (
251
+ await Promise.all(
252
+ accessPointGroupContractsWithMembers.map(async (_contract) => {
253
+ const isMember = await isMemberOfContract(
254
+ this.applicationStore.identityService.currentUser,
255
+ _contract,
256
+ lakehouseContractServerClient,
257
+ token,
258
+ );
259
+ return isMember ? _contract : undefined;
260
+ }),
261
+ )
262
+ ).filter(isNonNullable);
263
+ const systemAccountContracts = accessPointGroupContracts.filter(
264
+ contractContainsSystemAccount,
265
+ );
266
+ // ASSUMPTION: one contract per user per group
267
+ const userContract = userContracts[0];
268
+ this.setAssociatedContract(
269
+ userContract,
270
+ lakehouseContractServerClient,
271
+ token,
272
+ );
273
+ this.fetchAndSetAssociatedSystemAccountContracts(
274
+ systemAccountContracts,
275
+ lakehouseContractServerClient,
276
+ token,
277
+ );
278
+ } finally {
279
+ this.handlingContractsState.complete();
280
+ }
281
+ }
282
+
283
+ handleContractClick(dataAccessState: DataProductDataAccessState): void {
284
+ switch (this.access) {
285
+ case AccessPointGroupAccess.NO_ACCESS:
286
+ case AccessPointGroupAccess.DENIED:
287
+ dataAccessState.setDataContractAccessPointGroup(this.apg);
288
+ break;
289
+ case AccessPointGroupAccess.PENDING_MANAGER_APPROVAL:
290
+ case AccessPointGroupAccess.PENDING_DATA_OWNER_APPROVAL:
291
+ case AccessPointGroupAccess.APPROVED:
292
+ if (this.associatedContract) {
293
+ dataAccessState.setDataContract(this.associatedContract);
294
+ }
295
+ break;
296
+ default:
297
+ break;
298
+ }
299
+ }
300
+
301
+ *fetchUserAccessStatus(
302
+ contractId: string,
303
+ lakehouseContractServerClient: LakehouseContractServerClient,
304
+ token: string | undefined,
305
+ ): GeneratorFn<void> {
306
+ try {
307
+ this.fetchingUserAccessState.inProgress();
308
+ const rawUserStatus =
309
+ (yield lakehouseContractServerClient.getContractUserStatus(
310
+ contractId,
311
+ this.applicationStore.identityService.currentUser,
312
+ token,
313
+ )) as PlainObject<V1_ContractUserStatusResponse>;
314
+ const userStatus = deserialize(
315
+ V1_ContractUserStatusResponseModelSchema,
316
+ rawUserStatus,
317
+ ).status;
318
+ this.setUserAccessStatus(userStatus);
319
+ } catch (error) {
320
+ assertErrorThrown(error);
321
+ this.applicationStore.notificationService.notifyError(
322
+ `Error fetching user access status: ${error.message}`,
323
+ );
324
+ } finally {
325
+ this.fetchingUserAccessState.complete();
326
+ }
327
+ }
328
+
329
+ *fetchSubscriptions(
330
+ contractId: string,
331
+ lakehouseContractServerClient: LakehouseContractServerClient,
332
+ token: string | undefined,
333
+ ): GeneratorFn<void> {
334
+ try {
335
+ this.fetchingSubscriptionsState.inProgress();
336
+ const rawSubscriptions =
337
+ (yield lakehouseContractServerClient.getSubscriptionsForContract(
338
+ contractId,
339
+ token,
340
+ )) as V1_DataSubscriptionResponse;
341
+ const subscriptions = rawSubscriptions.subscriptions?.map(
342
+ (rawSubscription) =>
343
+ deserialize(V1_dataSubscriptionModelSchema, rawSubscription),
344
+ );
345
+ this.setSubscriptions(subscriptions ?? []);
346
+ } catch (error) {
347
+ assertErrorThrown(error);
348
+ this.applicationStore.notificationService.notifyError(`${error.message}`);
349
+ } finally {
350
+ this.fetchingSubscriptionsState.complete();
351
+ }
352
+ }
353
+
354
+ *createSubscription(
355
+ contractId: string,
356
+ target: V1_DataSubscriptionTarget,
357
+ lakehouseContractServerClient: LakehouseContractServerClient,
358
+ token: string | undefined,
359
+ ): GeneratorFn<void> {
360
+ try {
361
+ this.creatingSubscriptionState.inProgress();
362
+ const input = new V1_CreateSubscriptionInput();
363
+ input.contractId = contractId;
364
+ input.target = target;
365
+ const response = (yield lakehouseContractServerClient.createSubscription(
366
+ serialize(V1_CreateSubscriptionInputModelSchema, input),
367
+ token,
368
+ )) as PlainObject<V1_DataSubscriptionResponse>;
369
+ guaranteeNonNullable(
370
+ deserialize(V1_DataSubscriptionResponseModelSchema, response)
371
+ .subscriptions?.[0],
372
+ 'No subsription returned from server',
373
+ );
374
+ this.applicationStore.notificationService.notifySuccess(
375
+ `Subscription created`,
376
+ );
377
+ this.fetchSubscriptions(contractId, lakehouseContractServerClient, token);
378
+ } catch (error) {
379
+ assertErrorThrown(error);
380
+ this.applicationStore.notificationService.notifyError(`${error.message}`);
381
+ } finally {
382
+ this.creatingSubscriptionState.complete();
383
+ }
384
+ }
385
+ }