@finos/legend-graph 32.3.37 → 32.3.39

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 (86) hide show
  1. package/lib/graph-manager/protocol/pure/v1/V1_PureGraphManager.d.ts +0 -11
  2. package/lib/graph-manager/protocol/pure/v1/V1_PureGraphManager.d.ts.map +1 -1
  3. package/lib/graph-manager/protocol/pure/v1/V1_PureGraphManager.js +43 -76
  4. package/lib/graph-manager/protocol/pure/v1/V1_PureGraphManager.js.map +1 -1
  5. package/lib/graph-manager/protocol/pure/v1/lakehouse/entitlements/V1_ConsumerEntitlements.d.ts +5 -24
  6. package/lib/graph-manager/protocol/pure/v1/lakehouse/entitlements/V1_ConsumerEntitlements.d.ts.map +1 -1
  7. package/lib/graph-manager/protocol/pure/v1/lakehouse/entitlements/V1_ConsumerEntitlements.js +5 -24
  8. package/lib/graph-manager/protocol/pure/v1/lakehouse/entitlements/V1_ConsumerEntitlements.js.map +1 -1
  9. package/lib/graph-manager/protocol/pure/v1/lakehouse/entitlements/V1_CoreEntitlements.d.ts +50 -9
  10. package/lib/graph-manager/protocol/pure/v1/lakehouse/entitlements/V1_CoreEntitlements.d.ts.map +1 -1
  11. package/lib/graph-manager/protocol/pure/v1/lakehouse/entitlements/V1_CoreEntitlements.js +58 -10
  12. package/lib/graph-manager/protocol/pure/v1/lakehouse/entitlements/V1_CoreEntitlements.js.map +1 -1
  13. package/lib/graph-manager/protocol/pure/v1/lakehouse/entitlements/V1_DataAccessRequest.d.ts +100 -0
  14. package/lib/graph-manager/protocol/pure/v1/lakehouse/entitlements/V1_DataAccessRequest.d.ts.map +1 -0
  15. package/lib/graph-manager/protocol/pure/v1/lakehouse/entitlements/V1_DataAccessRequest.js +108 -0
  16. package/lib/graph-manager/protocol/pure/v1/lakehouse/entitlements/V1_DataAccessRequest.js.map +1 -0
  17. package/lib/graph-manager/protocol/pure/v1/lakehouse/entitlements/V1_EntitlementsDataProduct.d.ts +1 -16
  18. package/lib/graph-manager/protocol/pure/v1/lakehouse/entitlements/V1_EntitlementsDataProduct.d.ts.map +1 -1
  19. package/lib/graph-manager/protocol/pure/v1/lakehouse/entitlements/V1_EntitlementsDataProduct.js +0 -14
  20. package/lib/graph-manager/protocol/pure/v1/lakehouse/entitlements/V1_EntitlementsDataProduct.js.map +1 -1
  21. package/lib/graph-manager/protocol/pure/v1/lakehouse/helpers/V1_ConsumerEntitlementsUtils.d.ts.map +1 -1
  22. package/lib/graph-manager/protocol/pure/v1/lakehouse/helpers/V1_ConsumerEntitlementsUtils.js +2 -1
  23. package/lib/graph-manager/protocol/pure/v1/lakehouse/helpers/V1_ConsumerEntitlementsUtils.js.map +1 -1
  24. package/lib/graph-manager/protocol/pure/v1/lakehouse/subscriptions/V1_ConsumerSubscriptions.d.ts +5 -0
  25. package/lib/graph-manager/protocol/pure/v1/lakehouse/subscriptions/V1_ConsumerSubscriptions.d.ts.map +1 -1
  26. package/lib/graph-manager/protocol/pure/v1/lakehouse/subscriptions/V1_ConsumerSubscriptions.js +4 -0
  27. package/lib/graph-manager/protocol/pure/v1/lakehouse/subscriptions/V1_ConsumerSubscriptions.js.map +1 -1
  28. package/lib/graph-manager/protocol/pure/v1/transformation/pureProtocol/V1_PureProtocolSerialization.d.ts.map +1 -1
  29. package/lib/graph-manager/protocol/pure/v1/transformation/pureProtocol/V1_PureProtocolSerialization.js +10 -14
  30. package/lib/graph-manager/protocol/pure/v1/transformation/pureProtocol/V1_PureProtocolSerialization.js.map +1 -1
  31. package/lib/graph-manager/protocol/pure/v1/transformation/pureProtocol/serializationHelpers/V1_IngestSerializationHelper.js +1 -1
  32. package/lib/graph-manager/protocol/pure/v1/transformation/pureProtocol/serializationHelpers/V1_IngestSerializationHelper.js.map +1 -1
  33. package/lib/graph-manager/protocol/pure/v1/transformation/pureProtocol/serializationHelpers/lakehouse/V1_ConsumerEntitlementsSerializationHelper.d.ts +45 -0
  34. package/lib/graph-manager/protocol/pure/v1/transformation/pureProtocol/serializationHelpers/lakehouse/V1_ConsumerEntitlementsSerializationHelper.d.ts.map +1 -0
  35. package/lib/graph-manager/protocol/pure/v1/transformation/pureProtocol/serializationHelpers/lakehouse/V1_ConsumerEntitlementsSerializationHelper.js +190 -0
  36. package/lib/graph-manager/protocol/pure/v1/transformation/pureProtocol/serializationHelpers/lakehouse/V1_ConsumerEntitlementsSerializationHelper.js.map +1 -0
  37. package/lib/graph-manager/protocol/pure/v1/transformation/pureProtocol/serializationHelpers/lakehouse/V1_CoreEntitlementsSerializationHelper.d.ts +41 -0
  38. package/lib/graph-manager/protocol/pure/v1/transformation/pureProtocol/serializationHelpers/lakehouse/V1_CoreEntitlementsSerializationHelper.d.ts.map +1 -0
  39. package/lib/graph-manager/protocol/pure/v1/transformation/pureProtocol/serializationHelpers/lakehouse/V1_CoreEntitlementsSerializationHelper.js +141 -0
  40. package/lib/graph-manager/protocol/pure/v1/transformation/pureProtocol/serializationHelpers/lakehouse/V1_CoreEntitlementsSerializationHelper.js.map +1 -0
  41. package/lib/graph-manager/protocol/pure/v1/transformation/pureProtocol/serializationHelpers/lakehouse/V1_DataAccessRequestSerializationHelper.d.ts +34 -0
  42. package/lib/graph-manager/protocol/pure/v1/transformation/pureProtocol/serializationHelpers/lakehouse/V1_DataAccessRequestSerializationHelper.d.ts.map +1 -0
  43. package/lib/graph-manager/protocol/pure/v1/transformation/pureProtocol/serializationHelpers/lakehouse/V1_DataAccessRequestSerializationHelper.js +136 -0
  44. package/lib/graph-manager/protocol/pure/v1/transformation/pureProtocol/serializationHelpers/lakehouse/V1_DataAccessRequestSerializationHelper.js.map +1 -0
  45. package/lib/graph-manager/protocol/pure/v1/transformation/pureProtocol/serializationHelpers/lakehouse/V1_EntitlementsDataProductSerializationHelper.d.ts +31 -0
  46. package/lib/graph-manager/protocol/pure/v1/transformation/pureProtocol/serializationHelpers/lakehouse/V1_EntitlementsDataProductSerializationHelper.d.ts.map +1 -0
  47. package/lib/graph-manager/protocol/pure/v1/transformation/pureProtocol/serializationHelpers/lakehouse/V1_EntitlementsDataProductSerializationHelper.js +98 -0
  48. package/lib/graph-manager/protocol/pure/v1/transformation/pureProtocol/serializationHelpers/lakehouse/V1_EntitlementsDataProductSerializationHelper.js.map +1 -0
  49. package/lib/graph-manager/protocol/pure/v1/transformation/pureProtocol/serializationHelpers/lakehouse/V1_EntitlementsTasksSerializationHelper.d.ts +18 -0
  50. package/lib/graph-manager/protocol/pure/v1/transformation/pureProtocol/serializationHelpers/lakehouse/V1_EntitlementsTasksSerializationHelper.d.ts.map +1 -0
  51. package/lib/graph-manager/protocol/pure/v1/transformation/pureProtocol/serializationHelpers/lakehouse/V1_EntitlementsTasksSerializationHelper.js +22 -0
  52. package/lib/graph-manager/protocol/pure/v1/transformation/pureProtocol/serializationHelpers/lakehouse/V1_EntitlementsTasksSerializationHelper.js.map +1 -0
  53. package/lib/graph-manager/protocol/pure/v1/transformation/pureProtocol/serializationHelpers/{V1_SubscriptionSerializationHelper.d.ts → lakehouse/V1_SubscriptionSerializationHelper.d.ts} +2 -1
  54. package/lib/graph-manager/protocol/pure/v1/transformation/pureProtocol/serializationHelpers/lakehouse/V1_SubscriptionSerializationHelper.d.ts.map +1 -0
  55. package/lib/graph-manager/protocol/pure/v1/transformation/pureProtocol/serializationHelpers/{V1_SubscriptionSerializationHelper.js → lakehouse/V1_SubscriptionSerializationHelper.js} +6 -1
  56. package/lib/graph-manager/protocol/pure/v1/transformation/pureProtocol/serializationHelpers/lakehouse/V1_SubscriptionSerializationHelper.js.map +1 -0
  57. package/lib/index.d.ts +11 -6
  58. package/lib/index.d.ts.map +1 -1
  59. package/lib/index.js +11 -6
  60. package/lib/index.js.map +1 -1
  61. package/lib/package.json +1 -1
  62. package/package.json +1 -1
  63. package/src/graph-manager/protocol/pure/v1/V1_PureGraphManager.ts +413 -283
  64. package/src/graph-manager/protocol/pure/v1/lakehouse/entitlements/V1_ConsumerEntitlements.ts +9 -28
  65. package/src/graph-manager/protocol/pure/v1/lakehouse/entitlements/V1_CoreEntitlements.ts +76 -11
  66. package/src/graph-manager/protocol/pure/v1/lakehouse/entitlements/V1_DataAccessRequest.ts +126 -0
  67. package/src/graph-manager/protocol/pure/v1/lakehouse/entitlements/V1_EntitlementsDataProduct.ts +1 -20
  68. package/src/graph-manager/protocol/pure/v1/lakehouse/helpers/V1_ConsumerEntitlementsUtils.ts +4 -2
  69. package/src/graph-manager/protocol/pure/v1/lakehouse/subscriptions/V1_ConsumerSubscriptions.ts +7 -0
  70. package/src/graph-manager/protocol/pure/v1/transformation/pureProtocol/V1_PureProtocolSerialization.ts +23 -21
  71. package/src/graph-manager/protocol/pure/v1/transformation/pureProtocol/serializationHelpers/V1_IngestSerializationHelper.ts +1 -1
  72. package/src/graph-manager/protocol/pure/v1/transformation/pureProtocol/serializationHelpers/lakehouse/V1_ConsumerEntitlementsSerializationHelper.ts +394 -0
  73. package/src/graph-manager/protocol/pure/v1/transformation/pureProtocol/serializationHelpers/lakehouse/V1_CoreEntitlementsSerializationHelper.ts +238 -0
  74. package/src/graph-manager/protocol/pure/v1/transformation/pureProtocol/serializationHelpers/lakehouse/V1_DataAccessRequestSerializationHelper.ts +261 -0
  75. package/src/graph-manager/protocol/pure/v1/transformation/pureProtocol/serializationHelpers/lakehouse/V1_EntitlementsDataProductSerializationHelper.ts +179 -0
  76. package/src/graph-manager/protocol/pure/v1/transformation/pureProtocol/serializationHelpers/lakehouse/V1_EntitlementsTasksSerializationHelper.ts +26 -0
  77. package/src/graph-manager/protocol/pure/v1/transformation/pureProtocol/serializationHelpers/{V1_SubscriptionSerializationHelper.ts → lakehouse/V1_SubscriptionSerializationHelper.ts} +11 -1
  78. package/src/index.ts +11 -95
  79. package/tsconfig.json +7 -2
  80. package/lib/graph-manager/protocol/pure/v1/transformation/pureProtocol/serializationHelpers/V1_EntitlementSerializationHelper.d.ts +0 -77
  81. package/lib/graph-manager/protocol/pure/v1/transformation/pureProtocol/serializationHelpers/V1_EntitlementSerializationHelper.d.ts.map +0 -1
  82. package/lib/graph-manager/protocol/pure/v1/transformation/pureProtocol/serializationHelpers/V1_EntitlementSerializationHelper.js +0 -376
  83. package/lib/graph-manager/protocol/pure/v1/transformation/pureProtocol/serializationHelpers/V1_EntitlementSerializationHelper.js.map +0 -1
  84. package/lib/graph-manager/protocol/pure/v1/transformation/pureProtocol/serializationHelpers/V1_SubscriptionSerializationHelper.d.ts.map +0 -1
  85. package/lib/graph-manager/protocol/pure/v1/transformation/pureProtocol/serializationHelpers/V1_SubscriptionSerializationHelper.js.map +0 -1
  86. package/src/graph-manager/protocol/pure/v1/transformation/pureProtocol/serializationHelpers/V1_EntitlementSerializationHelper.ts +0 -701
@@ -0,0 +1,394 @@
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 {
18
+ customListWithSchema,
19
+ optionalCustomListWithSchema,
20
+ usingModelSchema,
21
+ type PlainObject,
22
+ } from '@finos/legend-shared';
23
+ import {
24
+ createModelSchema,
25
+ custom,
26
+ deserialize,
27
+ list,
28
+ optional,
29
+ primitive,
30
+ serialize,
31
+ } from 'serializr';
32
+ import {
33
+ type V1_ContractUserEventPayload,
34
+ V1_ContractEventPayloadType,
35
+ V1_ContractUserEventDataProducerPayload,
36
+ V1_ContractUserEventPrivilegeManagerPayload,
37
+ V1_ContractUserEventRecord,
38
+ V1_CreateContractPayload,
39
+ V1_DataContract,
40
+ V1_DataContractSubscriptions,
41
+ V1_DataContractsResponse,
42
+ V1_PendingTasksResponse,
43
+ V1_TaskMetadata,
44
+ V1_TaskResponse,
45
+ V1_TaskStatusChangeResponse,
46
+ V1_ContractUserStatusResponse,
47
+ V1_LiteDataContractsResponse,
48
+ V1_LiteDataContract,
49
+ V1_DataContractApprovedUsersResponse,
50
+ V1_TerminalOrderItem,
51
+ V1_TerminalProvisionPayload,
52
+ V1_LiteDataContractWithUserStatus,
53
+ V1_LiteDataContractsPaginatedResponse,
54
+ } from '../../../../lakehouse/entitlements/V1_ConsumerEntitlements.js';
55
+ import type { PureProtocolProcessorPlugin } from '../../../../../PureProtocolProcessorPlugin.js';
56
+ import {
57
+ V1_UserModelSchema,
58
+ V1_paginationMetadataRecordModelSchema,
59
+ V1_serializeOrganizationalScope,
60
+ V1_deserializeOrganizationalScope,
61
+ V1_contractUserMembershipModelSchema,
62
+ V1_deseralizeConsumerEntitlementResource,
63
+ V1_seralizeConsumerEntitlementResource,
64
+ } from './V1_CoreEntitlementsSerializationHelper.js';
65
+ import { V1_pendingTaskWithAssigneesModelSchema } from './V1_EntitlementsTasksSerializationHelper.js';
66
+ import { V1_dataSubscriptionModelSchema } from './V1_SubscriptionSerializationHelper.js';
67
+
68
+ export const V1_dataContractModelSchema = (
69
+ plugins: PureProtocolProcessorPlugin[],
70
+ ) =>
71
+ createModelSchema(V1_DataContract, {
72
+ description: primitive(),
73
+ guid: primitive(),
74
+ version: primitive(),
75
+ state: primitive(),
76
+ resource: custom(
77
+ V1_seralizeConsumerEntitlementResource,
78
+ V1_deseralizeConsumerEntitlementResource,
79
+ ),
80
+ members: optional(
81
+ list(usingModelSchema(V1_contractUserMembershipModelSchema)),
82
+ ),
83
+ consumer: custom(
84
+ (val) => V1_serializeOrganizationalScope(val, plugins),
85
+ (val) => V1_deserializeOrganizationalScope(val, plugins),
86
+ ),
87
+ createdBy: primitive(),
88
+ createdAt: primitive(),
89
+ });
90
+
91
+ export const V1_dataContractSubscriptionsModelSchema = (
92
+ plugins: PureProtocolProcessorPlugin[],
93
+ ) =>
94
+ createModelSchema(V1_DataContractSubscriptions, {
95
+ dataContract: usingModelSchema(V1_dataContractModelSchema(plugins)),
96
+ subscriptions: optional(
97
+ list(usingModelSchema(V1_dataSubscriptionModelSchema)),
98
+ ),
99
+ });
100
+
101
+ export const V1_liteDataContractModelSchema = (
102
+ plugins: PureProtocolProcessorPlugin[],
103
+ ) =>
104
+ createModelSchema(V1_LiteDataContract, {
105
+ description: primitive(),
106
+ guid: primitive(),
107
+ version: primitive(),
108
+ state: primitive(),
109
+ members: optional(
110
+ list(usingModelSchema(V1_contractUserMembershipModelSchema)),
111
+ ),
112
+ consumer: custom(
113
+ (val) => V1_serializeOrganizationalScope(val, plugins),
114
+ (val) => V1_deserializeOrganizationalScope(val, plugins),
115
+ ),
116
+ createdAt: primitive(),
117
+ createdBy: primitive(),
118
+ resourceId: primitive(),
119
+ resourceType: primitive(),
120
+ deploymentId: primitive(),
121
+ accessPointGroup: optional(primitive()),
122
+ });
123
+
124
+ export const V1_dataContractsResponseModelSchema = (
125
+ plugins: PureProtocolProcessorPlugin[],
126
+ ) =>
127
+ createModelSchema(V1_DataContractsResponse, {
128
+ dataContracts: optional(
129
+ customListWithSchema(V1_dataContractSubscriptionsModelSchema(plugins)),
130
+ ),
131
+ subscriptions: optional(
132
+ customListWithSchema(V1_dataSubscriptionModelSchema),
133
+ ),
134
+ });
135
+
136
+ const V1_liteDataContractsResponseModelSchema = (
137
+ plugins: PureProtocolProcessorPlugin[],
138
+ ) =>
139
+ createModelSchema(V1_LiteDataContractsResponse, {
140
+ dataContracts: optional(
141
+ customListWithSchema(V1_liteDataContractModelSchema(plugins)),
142
+ ),
143
+ });
144
+
145
+ export const V1_liteDataContractsPaginatedResponseModelSchema = (
146
+ plugins: PureProtocolProcessorPlugin[],
147
+ ) =>
148
+ createModelSchema(V1_LiteDataContractsPaginatedResponse, {
149
+ liteDataContractsResponse: usingModelSchema(
150
+ V1_liteDataContractsResponseModelSchema(plugins),
151
+ ),
152
+ paginationMetadataRecord: usingModelSchema(
153
+ V1_paginationMetadataRecordModelSchema,
154
+ ),
155
+ });
156
+
157
+ export const V1_liteDataContractWithUserStatusModelSchema = (
158
+ plugins: PureProtocolProcessorPlugin[],
159
+ ) =>
160
+ createModelSchema(V1_LiteDataContractWithUserStatus, {
161
+ contractResultLite: usingModelSchema(
162
+ V1_liteDataContractModelSchema(plugins),
163
+ ),
164
+ status: primitive(),
165
+ pendingTaskWithAssignees: optional(
166
+ usingModelSchema(V1_pendingTaskWithAssigneesModelSchema),
167
+ ),
168
+ user: primitive(),
169
+ });
170
+
171
+ export const V1_contractUserEventPrivilegeManagerPayloadModelSchema =
172
+ createModelSchema(V1_ContractUserEventPrivilegeManagerPayload, {
173
+ type: primitive(),
174
+ managerIdentity: primitive(),
175
+ candidateIdentity: primitive(),
176
+ taskId: primitive(),
177
+ eventTimestamp: primitive(),
178
+ });
179
+
180
+ export const V1_contractUserEventDataProducerPayloadModelSchema =
181
+ createModelSchema(V1_ContractUserEventDataProducerPayload, {
182
+ type: primitive(),
183
+ dataProducerIdentity: primitive(),
184
+ candidateIdentity: primitive(),
185
+ taskId: primitive(),
186
+ eventTimestamp: primitive(),
187
+ });
188
+
189
+ const V1_deserializeContractUserEventPayload = (
190
+ json: PlainObject<V1_ContractUserEventPayload>,
191
+ ): V1_ContractUserEventPayload => {
192
+ if (
193
+ [
194
+ V1_ContractEventPayloadType.DATA_PRODUCER_APPROVED,
195
+ V1_ContractEventPayloadType.DATA_PRODUCER_REJECTED,
196
+ ].includes((json as unknown as V1_ContractUserEventPayload).type)
197
+ ) {
198
+ return deserialize(
199
+ V1_contractUserEventDataProducerPayloadModelSchema,
200
+ json,
201
+ );
202
+ } else {
203
+ return deserialize(
204
+ V1_contractUserEventPrivilegeManagerPayloadModelSchema,
205
+ json,
206
+ );
207
+ }
208
+ };
209
+
210
+ const V1_serializeContractUserEventPayload = (
211
+ payload: V1_ContractUserEventPayload,
212
+ ): PlainObject<V1_ContractUserEventPayload> => {
213
+ if (payload instanceof V1_ContractUserEventDataProducerPayload) {
214
+ return serialize(
215
+ V1_contractUserEventDataProducerPayloadModelSchema,
216
+ payload,
217
+ );
218
+ } else {
219
+ return serialize(
220
+ V1_contractUserEventPrivilegeManagerPayloadModelSchema,
221
+ payload,
222
+ );
223
+ }
224
+ };
225
+
226
+ export const V1_contractUserEventRecordModelSchema = createModelSchema(
227
+ V1_ContractUserEventRecord,
228
+ {
229
+ taskId: primitive(),
230
+ dataContractId: primitive(),
231
+ status: primitive(),
232
+ consumer: primitive(),
233
+ eventPayload: custom(
234
+ V1_serializeContractUserEventPayload,
235
+ V1_deserializeContractUserEventPayload,
236
+ ),
237
+ type: primitive(),
238
+ effectiveFrom: primitive(),
239
+ effectiveTo: primitive(),
240
+ isEscalated: primitive(),
241
+ },
242
+ );
243
+ export const V1_taskMetadataModelSchema = createModelSchema(V1_TaskMetadata, {
244
+ rec: usingModelSchema(V1_contractUserEventRecordModelSchema),
245
+ assignees: list(primitive()),
246
+ });
247
+
248
+ export const V1_taskResponseModelSchema = createModelSchema(V1_TaskResponse, {
249
+ tasks: customListWithSchema(V1_taskMetadataModelSchema),
250
+ });
251
+
252
+ export const V1_pendingTasksResponseModelSchema = createModelSchema(
253
+ V1_PendingTasksResponse,
254
+ {
255
+ privilegeManager: customListWithSchema(
256
+ V1_contractUserEventRecordModelSchema,
257
+ ),
258
+ dataOwner: customListWithSchema(V1_contractUserEventRecordModelSchema),
259
+ },
260
+ );
261
+
262
+ export const V1_TaskStatusChangeResponseModelSchema = createModelSchema(
263
+ V1_TaskStatusChangeResponse,
264
+ {
265
+ status: primitive(),
266
+ errorType: primitive(),
267
+ errorMessage: primitive(),
268
+ },
269
+ );
270
+
271
+ export const V1_deserializeDataContractResponse = (
272
+ json: PlainObject<V1_DataContractsResponse>,
273
+ plugins: PureProtocolProcessorPlugin[],
274
+ ): V1_DataContractSubscriptions[] => {
275
+ const contracts = deserialize(
276
+ V1_dataContractsResponseModelSchema(plugins),
277
+ json,
278
+ );
279
+ return contracts.dataContracts ?? [];
280
+ };
281
+
282
+ export const V1_deserializeLiteDataContractsPaginatedResponse = (
283
+ json: PlainObject<V1_LiteDataContractsResponse>,
284
+ plugins: PureProtocolProcessorPlugin[],
285
+ ): V1_LiteDataContractsPaginatedResponse => {
286
+ return deserialize(
287
+ V1_liteDataContractsPaginatedResponseModelSchema(plugins),
288
+ json,
289
+ );
290
+ };
291
+
292
+ export const V1_liteDataContractsResponseModelSchemaToContracts = (
293
+ json: PlainObject<V1_LiteDataContractsResponse>,
294
+ plugins: PureProtocolProcessorPlugin[],
295
+ ): V1_LiteDataContract[] => {
296
+ const contracts = deserialize(
297
+ V1_liteDataContractsResponseModelSchema(plugins),
298
+ json,
299
+ );
300
+ return contracts.dataContracts ?? [];
301
+ };
302
+
303
+ export const V1_deserializeTaskResponse = (
304
+ json: PlainObject<V1_TaskResponse>,
305
+ ): V1_TaskMetadata[] => {
306
+ return deserialize(V1_taskResponseModelSchema, json).tasks ?? [];
307
+ };
308
+
309
+ export const V1_createContractPayloadModelSchema = (
310
+ plugins: PureProtocolProcessorPlugin[],
311
+ ) =>
312
+ createModelSchema(V1_CreateContractPayload, {
313
+ description: primitive(),
314
+ resourceId: primitive(),
315
+ resourceType: primitive(),
316
+ deploymentId: primitive(),
317
+ accessPointGroup: optional(primitive()),
318
+ consumer: custom(
319
+ (val) => V1_serializeOrganizationalScope(val, plugins),
320
+ (val) => V1_deserializeOrganizationalScope(val, plugins),
321
+ ),
322
+ });
323
+
324
+ export const V1_terminalOrderItemModelSchema = createModelSchema(
325
+ V1_TerminalOrderItem,
326
+ {
327
+ providerName: primitive(),
328
+ productName: primitive(),
329
+ category: primitive(),
330
+ price: primitive(),
331
+ id: primitive(),
332
+ perm_id: optional(primitive()),
333
+ },
334
+ );
335
+
336
+ export const V1_serializeOrderItems = (
337
+ val: Record<number, V1_TerminalOrderItem[]>,
338
+ ): Record<number, PlainObject<V1_TerminalOrderItem>[]> => {
339
+ const result: Record<number, PlainObject<V1_TerminalOrderItem>[]> = {};
340
+ for (const [key, items] of Object.entries(val)) {
341
+ result[Number(key)] = items.map(
342
+ (item: V1_TerminalOrderItem): PlainObject<V1_TerminalOrderItem> =>
343
+ serialize(V1_terminalOrderItemModelSchema, item),
344
+ );
345
+ }
346
+ return result;
347
+ };
348
+
349
+ export const V1_deserializeOrderItems = (
350
+ val: Record<string, PlainObject<V1_TerminalOrderItem>[]>,
351
+ ): Record<number, V1_TerminalOrderItem[]> => {
352
+ const result: Record<number, V1_TerminalOrderItem[]> = {};
353
+ for (const [key, items] of Object.entries(val)) {
354
+ result[Number(key)] = items.map(
355
+ (item: PlainObject<V1_TerminalOrderItem>): V1_TerminalOrderItem =>
356
+ deserialize(V1_terminalOrderItemModelSchema, item),
357
+ );
358
+ }
359
+ return result;
360
+ };
361
+
362
+ export const V1_terminalProvisionPayloadModelSchema = createModelSchema(
363
+ V1_TerminalProvisionPayload,
364
+ {
365
+ ordered_by: primitive(),
366
+ kerberos: primitive(),
367
+ order_items: custom(V1_serializeOrderItems, V1_deserializeOrderItems),
368
+ business_justification: primitive(),
369
+ },
370
+ );
371
+
372
+ export const V1_serializeTerminalProvisionPayload = (
373
+ payload: V1_TerminalProvisionPayload,
374
+ ): PlainObject<V1_TerminalProvisionPayload> => {
375
+ return serialize(V1_terminalProvisionPayloadModelSchema, payload);
376
+ };
377
+
378
+ export const V1_deserializeTerminalProvisionPayload = (
379
+ json: PlainObject<V1_TerminalProvisionPayload>,
380
+ ): V1_TerminalProvisionPayload => {
381
+ return deserialize(V1_terminalProvisionPayloadModelSchema, json);
382
+ };
383
+
384
+ export const V1_ContractUserStatusResponseModelSchema = createModelSchema(
385
+ V1_ContractUserStatusResponse,
386
+ {
387
+ status: primitive(),
388
+ },
389
+ );
390
+
391
+ export const V1_DataContractApprovedUsersResponseModelSchema =
392
+ createModelSchema(V1_DataContractApprovedUsersResponse, {
393
+ approvedUsers: optionalCustomListWithSchema(V1_UserModelSchema),
394
+ });
@@ -0,0 +1,238 @@
1
+ /**
2
+ * Copyright (c) 2026-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 {
18
+ customListWithSchema,
19
+ UnsupportedOperationError,
20
+ usingConstantValueSchema,
21
+ usingModelSchema,
22
+ type PlainObject,
23
+ } from '@finos/legend-shared';
24
+ import {
25
+ createModelSchema,
26
+ deserialize,
27
+ list,
28
+ primitive,
29
+ raw,
30
+ serialize,
31
+ } from 'serializr';
32
+ import {
33
+ type V1_ConsumerEntitlementResource,
34
+ type V1_OrganizationalScope,
35
+ V1_AccessPointGroupReference,
36
+ V1_AccessPointGroupStereotypeMapping,
37
+ V1_AdhocTeam,
38
+ V1_AppDirNode,
39
+ V1_ContractUserMembership,
40
+ V1_DataBundle,
41
+ V1_EntitlementsAccessPoint,
42
+ V1_EntitlementsDataProduct,
43
+ V1_PaginationMetadataRecord,
44
+ V1_ProducerScope,
45
+ V1_UnknownOrganizationalScopeType,
46
+ V1_User,
47
+ } from '../../../../lakehouse/entitlements/V1_CoreEntitlements.js';
48
+ import type { PureProtocolProcessorPlugin } from '../../../../../PureProtocolProcessorPlugin.js';
49
+ import type { DSL_Lakehouse_PureProtocolProcessorPlugin_Extension } from '../../../../../extensions/DSL_Lakehouse_PureProtocolProcessorPlugin_Extension.js';
50
+ import { V1_stereotypePtrModelSchema } from '../V1_CoreSerializationHelper.js';
51
+
52
+ // ---------------------------------------- Users & App Directory --------------------------------------
53
+
54
+ export const V1_UserModelSchema = createModelSchema(V1_User, {
55
+ name: primitive(),
56
+ userType: primitive(),
57
+ });
58
+
59
+ export const V1_AppDirNodeModelSchema = createModelSchema(V1_AppDirNode, {
60
+ appDirId: primitive(),
61
+ level: primitive(),
62
+ });
63
+
64
+ // -------------------------------------------- Pagination ---------------------------------------------
65
+
66
+ export const V1_paginationMetadataRecordModelSchema = createModelSchema(
67
+ V1_PaginationMetadataRecord,
68
+ {
69
+ hasNextPage: primitive(),
70
+ lastValuesMap: raw(),
71
+ size: primitive(),
72
+ },
73
+ );
74
+
75
+ // ---------------------------------------- Organizational Scopes --------------------------------------
76
+
77
+ export enum V1_OrganizationalScopeType {
78
+ AdHocTeam = 'AdHocTeam',
79
+ Producer = 'Producer',
80
+ }
81
+
82
+ export const V1_AdhocTeamModelSchema = createModelSchema(V1_AdhocTeam, {
83
+ _type: usingConstantValueSchema(V1_OrganizationalScopeType.AdHocTeam),
84
+ users: customListWithSchema(V1_UserModelSchema),
85
+ });
86
+
87
+ export const V1_ProducerScopeModelSchema = createModelSchema(V1_ProducerScope, {
88
+ _type: usingConstantValueSchema(V1_OrganizationalScopeType.Producer),
89
+ did: primitive(),
90
+ });
91
+
92
+ export const V1_deserializeOrganizationalScope = (
93
+ json: PlainObject<V1_OrganizationalScope>,
94
+ plugins: PureProtocolProcessorPlugin[],
95
+ ): V1_OrganizationalScope => {
96
+ switch (json._type) {
97
+ case V1_OrganizationalScopeType.AdHocTeam:
98
+ return deserialize(V1_AdhocTeamModelSchema, json);
99
+ case V1_OrganizationalScopeType.Producer:
100
+ return deserialize(V1_ProducerScopeModelSchema, json);
101
+ default: {
102
+ const extraOrganizationalScopeDeserializers = plugins.flatMap(
103
+ (plugin) =>
104
+ (
105
+ plugin as DSL_Lakehouse_PureProtocolProcessorPlugin_Extension
106
+ ).V1_getExtraOrganizationalScopeDeserializers?.() ?? [],
107
+ );
108
+ for (const deserializer of extraOrganizationalScopeDeserializers) {
109
+ const protocol = deserializer(json);
110
+ if (protocol) {
111
+ return protocol;
112
+ }
113
+ }
114
+
115
+ // Fall back to create unknown stub if not supported
116
+ const org = new V1_UnknownOrganizationalScopeType();
117
+ org.content = json;
118
+ return org;
119
+ }
120
+ }
121
+ };
122
+
123
+ export const V1_serializeOrganizationalScope = (
124
+ organizationalScope: V1_OrganizationalScope,
125
+ plugins: PureProtocolProcessorPlugin[],
126
+ ): PlainObject<V1_OrganizationalScope> => {
127
+ if (organizationalScope instanceof V1_AdhocTeam) {
128
+ return serialize(V1_AdhocTeamModelSchema, organizationalScope);
129
+ }
130
+ if (organizationalScope instanceof V1_ProducerScope) {
131
+ return serialize(V1_ProducerScopeModelSchema, organizationalScope);
132
+ }
133
+ const extraOrganizationalScopeSerializers = plugins.flatMap(
134
+ (plugin) =>
135
+ (
136
+ plugin as DSL_Lakehouse_PureProtocolProcessorPlugin_Extension
137
+ ).V1_getExtraOrganizationalScopeSerializers?.() ?? [],
138
+ );
139
+ for (const serializer of extraOrganizationalScopeSerializers) {
140
+ const result = serializer(organizationalScope);
141
+ if (result) {
142
+ return result;
143
+ }
144
+ }
145
+ throw new UnsupportedOperationError(
146
+ `Can't serialize unsupported organizational scope type: ${organizationalScope.constructor.name}`,
147
+ );
148
+ };
149
+
150
+ // -------------------------------- Entitlements Data Products & Access Points --------------------------
151
+
152
+ export const V1_EntitlementsAccessPointModelSchema = createModelSchema(
153
+ V1_EntitlementsAccessPoint,
154
+ {
155
+ name: primitive(),
156
+ groups: list(primitive()),
157
+ },
158
+ );
159
+
160
+ export const V1_AccessPointGroupStereotypeMappingModelSchema =
161
+ createModelSchema(V1_AccessPointGroupStereotypeMapping, {
162
+ accessPointGroup: primitive(),
163
+ stereotypes: customListWithSchema(V1_stereotypePtrModelSchema),
164
+ });
165
+
166
+ export const V1_EntitlementsDataProductModelSchema = createModelSchema(
167
+ V1_EntitlementsDataProduct,
168
+ {
169
+ name: primitive(),
170
+ accessPoints: customListWithSchema(V1_EntitlementsAccessPointModelSchema),
171
+ accessPointGroupStereotypeMappings: customListWithSchema(
172
+ V1_AccessPointGroupStereotypeMappingModelSchema,
173
+ ),
174
+ owner: usingModelSchema(V1_AppDirNodeModelSchema),
175
+ },
176
+ );
177
+
178
+ // ------------------------------------- Consumer Entitlement Resources --------------------------------
179
+
180
+ export enum V1_AccessPointGroupReferenceType {
181
+ AccessPointGroupReference = 'AccessPointGroupReference',
182
+ }
183
+
184
+ export const V1_AccessPointGroupReferenceModelSchema = createModelSchema(
185
+ V1_AccessPointGroupReference,
186
+ {
187
+ _type: usingConstantValueSchema(
188
+ V1_AccessPointGroupReferenceType.AccessPointGroupReference,
189
+ ),
190
+ dataProduct: usingModelSchema(V1_EntitlementsDataProductModelSchema),
191
+ accessPointGroup: primitive(),
192
+ },
193
+ );
194
+
195
+ export const V1_DataBundleModelSchema = createModelSchema(V1_DataBundle, {
196
+ content: raw(),
197
+ });
198
+
199
+ export const V1_seralizeConsumerEntitlementResource = (
200
+ consumerEntitlementResource: V1_ConsumerEntitlementResource,
201
+ ): PlainObject<V1_ConsumerEntitlementResource> => {
202
+ if (consumerEntitlementResource instanceof V1_AccessPointGroupReference) {
203
+ return serialize(
204
+ V1_AccessPointGroupReferenceModelSchema,
205
+ consumerEntitlementResource,
206
+ );
207
+ } else if (consumerEntitlementResource instanceof V1_DataBundle) {
208
+ return serialize(V1_DataBundleModelSchema, consumerEntitlementResource);
209
+ } else {
210
+ throw new UnsupportedOperationError(
211
+ `Can't serialize unsupported consumer entitlement resource type: ${consumerEntitlementResource.constructor.name}`,
212
+ );
213
+ }
214
+ };
215
+
216
+ export const V1_deseralizeConsumerEntitlementResource = (
217
+ json: PlainObject<V1_ConsumerEntitlementResource>,
218
+ ): V1_ConsumerEntitlementResource => {
219
+ switch (json._type) {
220
+ case V1_AccessPointGroupReferenceType.AccessPointGroupReference:
221
+ return deserialize(V1_AccessPointGroupReferenceModelSchema, json);
222
+ default:
223
+ const bundle = new V1_DataBundle();
224
+ bundle.content = json;
225
+ return bundle;
226
+ }
227
+ };
228
+
229
+ // -------------------------------------- Contract User Membership -------------------------------------
230
+
231
+ export const V1_contractUserMembershipModelSchema = createModelSchema(
232
+ V1_ContractUserMembership,
233
+ {
234
+ guid: primitive(),
235
+ user: usingModelSchema(V1_UserModelSchema),
236
+ status: primitive(),
237
+ },
238
+ );