@finos/legend-graph 32.3.36 → 32.3.37

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/graph-manager/protocol/pure/v1/V1_PureGraphManager.d.ts +11 -0
  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 +76 -43
  4. package/lib/graph-manager/protocol/pure/v1/V1_PureGraphManager.js.map +1 -1
  5. package/lib/graph-manager/protocol/pure/v1/transformation/pureProtocol/V1_PureProtocolSerialization.d.ts.map +1 -1
  6. package/lib/graph-manager/protocol/pure/v1/transformation/pureProtocol/V1_PureProtocolSerialization.js +14 -10
  7. package/lib/graph-manager/protocol/pure/v1/transformation/pureProtocol/V1_PureProtocolSerialization.js.map +1 -1
  8. package/lib/graph-manager/protocol/pure/v1/transformation/pureProtocol/serializationHelpers/V1_EntitlementSerializationHelper.d.ts +2 -1
  9. package/lib/graph-manager/protocol/pure/v1/transformation/pureProtocol/serializationHelpers/V1_EntitlementSerializationHelper.d.ts.map +1 -1
  10. package/lib/graph-manager/protocol/pure/v1/transformation/pureProtocol/serializationHelpers/V1_EntitlementSerializationHelper.js +20 -5
  11. package/lib/graph-manager/protocol/pure/v1/transformation/pureProtocol/serializationHelpers/V1_EntitlementSerializationHelper.js.map +1 -1
  12. package/lib/index.d.ts +1 -1
  13. package/lib/index.d.ts.map +1 -1
  14. package/lib/index.js +1 -1
  15. package/lib/index.js.map +1 -1
  16. package/lib/package.json +1 -1
  17. package/package.json +3 -3
  18. package/src/graph-manager/protocol/pure/v1/V1_PureGraphManager.ts +283 -413
  19. package/src/graph-manager/protocol/pure/v1/transformation/pureProtocol/V1_PureProtocolSerialization.ts +21 -23
  20. package/src/graph-manager/protocol/pure/v1/transformation/pureProtocol/serializationHelpers/V1_EntitlementSerializationHelper.ts +36 -5
  21. package/src/index.ts +2 -1
@@ -29,6 +29,7 @@ import {
29
29
  usingConstantValueSchema,
30
30
  UnsupportedOperationError,
31
31
  assertErrorThrown,
32
+ guaranteeNonNullable,
32
33
  usingModelSchema,
33
34
  } from '@finos/legend-shared';
34
35
  import { V1_PureModelContextData } from '../../model/context/V1_PureModelContextData.js';
@@ -101,29 +102,26 @@ export const V1_entitiesToPureModelContextData = async (
101
102
  TEMPORARY__entityPathIndex?.set(element.path, entity.path);
102
103
  return element;
103
104
  };
104
- graph.elements = await Promise.all<V1_PackageableElement>(
105
- entities.map(
106
- (e) =>
107
- new Promise((resolve, reject) =>
108
- setTimeout(() => {
109
- try {
110
- resolve(
111
- // NOTE: here we skip the check for classifier path, so there could be cases
112
- // where the classifier path is different from the actua element protocol path
113
- // we might need to do validation here. This can happen when the classifier
114
- // path is changed in the backend. If we are to check for this, we might consider
115
- // not throwing error but quitely print out warnings about elements that would not
116
- // be built.
117
- entityToElement(e),
118
- );
119
- } catch (error) {
120
- assertErrorThrown(error);
121
- reject(error);
122
- }
123
- }, 0),
124
- ),
125
- ),
126
- );
105
+ // Process entities in batches to avoid per-element setTimeout overhead.
106
+ // Each batch yields to the event loop to keep the UI responsive.
107
+ const DESERIALIZATION_BATCH_SIZE = 100;
108
+ const results: V1_PackageableElement[] = [];
109
+ for (let i = 0; i < entities.length; i += DESERIALIZATION_BATCH_SIZE) {
110
+ if (i > 0) {
111
+ await new Promise<void>((resolve) => setTimeout(resolve, 0));
112
+ }
113
+ const end = Math.min(i + DESERIALIZATION_BATCH_SIZE, entities.length);
114
+ for (let j = i; j < end; j++) {
115
+ // NOTE: here we skip the check for classifier path, so there could be cases
116
+ // where the classifier path is different from the actua element protocol path
117
+ // we might need to do validation here. This can happen when the classifier
118
+ // path is changed in the backend. If we are to check for this, we might consider
119
+ // not throwing error but quitely print out warnings about elements that would not
120
+ // be built.
121
+ results.push(entityToElement(guaranteeNonNullable(entities[j])));
122
+ }
123
+ }
124
+ graph.elements = results;
127
125
  }
128
126
  } catch (error) {
129
127
  assertErrorThrown(error);
@@ -55,8 +55,8 @@ import {
55
55
  list,
56
56
  optional,
57
57
  primitive,
58
+ raw,
58
59
  serialize,
59
- SKIP,
60
60
  } from 'serializr';
61
61
  import {
62
62
  type V1_OrganizationalScope,
@@ -139,11 +139,18 @@ export const V1_EntitlementsDataProductModelSchema = createModelSchema(
139
139
  export const V1_AccessPointGroupReferenceModelSchema = createModelSchema(
140
140
  V1_AccessPointGroupReference,
141
141
  {
142
+ _type: usingConstantValueSchema(
143
+ V1_AccessPointGroupReferenceType.AccessPointGroupReference,
144
+ ),
142
145
  dataProduct: usingModelSchema(V1_EntitlementsDataProductModelSchema),
143
146
  accessPointGroup: primitive(),
144
147
  },
145
148
  );
146
149
 
150
+ export const V1_DataBundleModelSchema = createModelSchema(V1_DataBundle, {
151
+ content: raw(),
152
+ });
153
+
147
154
  export const V1_AdhocTeamModelSchema = createModelSchema(V1_AdhocTeam, {
148
155
  _type: usingConstantValueSchema(V1_OrganizationalScopeType.AdHocTeam),
149
156
  users: customListWithSchema(V1_UserModelSchema),
@@ -207,10 +214,29 @@ const V1_serializeOrganizationalScope = (
207
214
  return result;
208
215
  }
209
216
  }
210
- throw new UnsupportedOperationError();
217
+ throw new UnsupportedOperationError(
218
+ `Can't serialize unsupported organizational scope type: ${organizationalScope.constructor.name}`,
219
+ );
211
220
  };
212
221
 
213
- const V1_deseralizeV1_ConsumerEntitlementResource = (
222
+ const V1_seralizeConsumerEntitlementResource = (
223
+ consumerEntitlementResource: V1_ConsumerEntitlementResource,
224
+ ): PlainObject<V1_ConsumerEntitlementResource> => {
225
+ if (consumerEntitlementResource instanceof V1_AccessPointGroupReference) {
226
+ return serialize(
227
+ V1_AccessPointGroupReferenceModelSchema,
228
+ consumerEntitlementResource,
229
+ );
230
+ } else if (consumerEntitlementResource instanceof V1_DataBundle) {
231
+ return serialize(V1_DataBundleModelSchema, consumerEntitlementResource);
232
+ } else {
233
+ throw new UnsupportedOperationError(
234
+ `Can't serialize unsupported consumer entitlement resource type: ${consumerEntitlementResource.constructor.name}`,
235
+ );
236
+ }
237
+ };
238
+
239
+ const V1_deseralizeConsumerEntitlementResource = (
214
240
  json: PlainObject<V1_ConsumerEntitlementResource>,
215
241
  ): V1_ConsumerEntitlementResource => {
216
242
  switch (json._type) {
@@ -240,7 +266,10 @@ export const V1_dataContractModelSchema = (
240
266
  guid: primitive(),
241
267
  version: primitive(),
242
268
  state: primitive(),
243
- resource: custom(() => SKIP, V1_deseralizeV1_ConsumerEntitlementResource),
269
+ resource: custom(
270
+ V1_seralizeConsumerEntitlementResource,
271
+ V1_deseralizeConsumerEntitlementResource,
272
+ ),
244
273
  members: optional(
245
274
  list(usingModelSchema(V1_contractUserMembershipModelSchema)),
246
275
  ),
@@ -585,7 +614,9 @@ const V1_serializeDataProductOrigin = (
585
614
  if (origin instanceof V1_SdlcDeploymentDataProductOrigin) {
586
615
  return serialize(V1_SdlcDeploymentDataProductOriginModelSchema, origin);
587
616
  }
588
- throw new UnsupportedOperationError();
617
+ throw new UnsupportedOperationError(
618
+ `Can't serialize unsupported data product origin type: ${origin?.constructor.name}`,
619
+ );
589
620
  };
590
621
 
591
622
  export const V1_EntitlementsLakehouseEnvironmentModelSchema = createModelSchema(
package/src/index.ts CHANGED
@@ -378,8 +378,8 @@ export {
378
378
  V1_EntitlementsAccessPointModelSchema,
379
379
  V1_EntitlementsDataProductDetailsModelSchema,
380
380
  V1_EntitlementsDataProductDetailsResponseModelSchema,
381
- V1_EntitlementsDataProductLiteModelSchema,
382
381
  V1_entitlementsDataProductDetailsResponseToDataProductDetails,
382
+ V1_EntitlementsDataProductLiteModelSchema,
383
383
  V1_EntitlementsDataProductModelSchema,
384
384
  V1_EntitlementsLakehouseEnvironmentModelSchema,
385
385
  V1_liteDataContractModelSchema,
@@ -388,6 +388,7 @@ export {
388
388
  V1_OrganizationalScopeType,
389
389
  V1_pendingTasksResponseModelSchema,
390
390
  V1_SdlcDeploymentDataProductOriginModelSchema,
391
+ V1_taskResponseModelSchema,
391
392
  V1_TaskStatusChangeResponseModelSchema,
392
393
  V1_terminalProvisionPayloadModelSchema,
393
394
  } from './graph-manager/protocol/pure/v1/transformation/pureProtocol/serializationHelpers/V1_EntitlementSerializationHelper.js';