@finos/legend-graph 32.3.37 → 32.3.38

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.
@@ -29,7 +29,6 @@ import {
29
29
  usingConstantValueSchema,
30
30
  UnsupportedOperationError,
31
31
  assertErrorThrown,
32
- guaranteeNonNullable,
33
32
  usingModelSchema,
34
33
  } from '@finos/legend-shared';
35
34
  import { V1_PureModelContextData } from '../../model/context/V1_PureModelContextData.js';
@@ -102,26 +101,29 @@ export const V1_entitiesToPureModelContextData = async (
102
101
  TEMPORARY__entityPathIndex?.set(element.path, entity.path);
103
102
  return element;
104
103
  };
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;
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
+ );
125
127
  }
126
128
  } catch (error) {
127
129
  assertErrorThrown(error);