@almadar/runtime 6.9.0 → 6.9.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.
@@ -1,4 +1,4 @@
1
- export { InMemoryPersistence, OrbitalServerRuntime, collectDeclaredConfigDefaults, createOrbitalServerRuntime } from './chunk-TNK77RLG.js';
1
+ export { InMemoryPersistence, OrbitalServerRuntime, collectDeclaredConfigDefaults, createOrbitalServerRuntime } from './chunk-VUXJJPIQ.js';
2
2
  import './chunk-PZ5AY32C.js';
3
3
  //# sourceMappingURL=OrbitalServerRuntime.js.map
4
4
  //# sourceMappingURL=OrbitalServerRuntime.js.map
@@ -2316,11 +2316,9 @@ var ReferenceResolver = class {
2316
2316
  }, clone() {
2317
2317
  return this;
2318
2318
  } };
2319
- const importsResult = await this.resolveImports(
2320
- orbital.uses ?? [],
2321
- sourcePath,
2322
- importChain
2323
- );
2319
+ const traitsList = orbital.traits ?? [];
2320
+ const alreadyResolved = traitsList.length > 0 && traitsList.every((t) => isInlineTrait(t));
2321
+ const importsResult = alreadyResolved ? { success: true, data: { orbitals: /* @__PURE__ */ new Map() }} : await this.resolveImports(orbital.uses ?? [], sourcePath, importChain);
2324
2322
  if (!importsResult.success) {
2325
2323
  return { success: false, errors: importsResult.errors };
2326
2324
  }
@@ -5256,12 +5254,20 @@ var OrbitalServerRuntime = class {
5256
5254
  }
5257
5255
  }
5258
5256
  const populatedFieldName = includeField.endsWith("Id") ? includeField.slice(0, -2) : includeField;
5257
+ const isSelfRef = relatedEntityType === entityType;
5258
+ const hydrateClone = (id) => {
5259
+ const related = relatedEntities.get(id);
5260
+ if (!related) return void 0;
5261
+ const copy = { ...related };
5262
+ if (isSelfRef) copy[foreignKeyField] = [];
5263
+ return copy;
5264
+ };
5259
5265
  for (const entity of entities) {
5260
5266
  const fkValue = entity[foreignKeyField];
5261
5267
  if (cardinality === "one" || cardinality === "many-to-one") {
5262
5268
  if (typeof fkValue === "string" && relatedEntities.has(fkValue)) {
5263
5269
  Object.defineProperty(entity, populatedFieldName, {
5264
- value: relatedEntities.get(fkValue),
5270
+ value: hydrateClone(fkValue),
5265
5271
  writable: true,
5266
5272
  enumerable: true,
5267
5273
  configurable: true
@@ -5271,14 +5277,14 @@ var OrbitalServerRuntime = class {
5271
5277
  if (Array.isArray(fkValue)) {
5272
5278
  const fkIds = fkValue.filter((id) => typeof id === "string");
5273
5279
  Object.defineProperty(entity, populatedFieldName, {
5274
- value: fkIds.map((id) => relatedEntities.get(id)).filter(Boolean),
5280
+ value: fkIds.map(hydrateClone).filter(Boolean),
5275
5281
  writable: true,
5276
5282
  enumerable: true,
5277
5283
  configurable: true
5278
5284
  });
5279
5285
  } else if (typeof fkValue === "string" && relatedEntities.has(fkValue)) {
5280
5286
  Object.defineProperty(entity, populatedFieldName, {
5281
- value: [relatedEntities.get(fkValue)],
5287
+ value: [hydrateClone(fkValue)],
5282
5288
  writable: true,
5283
5289
  enumerable: true,
5284
5290
  configurable: true
@@ -5475,5 +5481,5 @@ function buildMatcher(src, listenerOrbital) {
5475
5481
  }
5476
5482
 
5477
5483
  export { EffectExecutor, EventBus, HANDLER_MANIFEST, InMemoryPersistence, MockPersistenceAdapter, OrbitalServerRuntime, StateMachineManager, buildEmitsFromTraits, collectDeclaredConfigDefaults, containsBindings, createContextFromBindings, createInitialTraitState, createMockPersistence, createOrbitalServerRuntime, createTestExecutor, createUnifiedLoader, extractBindings, findInitialState, findTransition, formatPayloadValidationError, getIsolatedCollectionName, getNamespacedEvent, interpolateProps, interpolateValue, isBrowser, isElectron, isNamespacedEvent, isNode, normalizeEventKey, parseNamespacedEvent, preprocessSchema, processEvent, validateEventPayload, validatePayloadShapes };
5478
- //# sourceMappingURL=chunk-TNK77RLG.js.map
5479
- //# sourceMappingURL=chunk-TNK77RLG.js.map
5484
+ //# sourceMappingURL=chunk-VUXJJPIQ.js.map
5485
+ //# sourceMappingURL=chunk-VUXJJPIQ.js.map