@almadar/runtime 5.10.2 → 5.11.0

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,7 +1,7 @@
1
1
  import * as _almadar_core from '@almadar/core';
2
2
  import { EventPayload, EntityRow, OrbitalSchema, Orbital, Trait, PatternConfig, ResolvedPatternProps, SExpr, BusEventSource, OrbitalDefinition, Entity, TraitConfig, TraitTick } from '@almadar/core';
3
3
  import { Router } from 'express';
4
- import { I as IEventBus, g as RuntimeEvent, f as EventListener, U as Unsubscribe, T as TraitDefinition, R as RuntimeConfig, i as TransitionObserver, C as ConfigContext, h as TraitState, j as TransitionResult, E as EvaluationContextExtensions, a as EffectHandlers } from './types-ByLpy6yj.js';
4
+ import { I as IEventBus, g as RuntimeEvent, f as EventListener, U as Unsubscribe, T as TraitDefinition, R as RuntimeConfig, i as TransitionObserver, C as ConfigContext, h as TraitState, j as TransitionResult, E as EvaluationContextExtensions, a as EffectHandlers } from './types-cuy5gd29.js';
5
5
  import { P as PersistenceAdapter } from './PersistenceAdapter-B6dQCbbU.js';
6
6
 
7
7
  /**
@@ -1,5 +1,5 @@
1
1
  import '@almadar/core';
2
2
  import 'express';
3
- export { C as ClientEffectTuple, B as ClientNavigateTuple, D as ClientNotifyTuple, F as ClientRenderUITuple, G as EffectResult, H as LoaderConfig, O as OrbitalEventRequest, e as OrbitalEventResponse, J as OrbitalServerRuntime, f as OrbitalServerRuntimeConfig, R as RegisteredOrbital, j as RuntimeOrbital, k as RuntimeOrbitalSchema, l as RuntimeTrait, K as RuntimeTraitTick, n as collectDeclaredConfigDefaults, M as createOrbitalServerRuntime } from './OrbitalServerRuntime-VQBv8J8m.js';
4
- import './types-ByLpy6yj.js';
3
+ export { C as ClientEffectTuple, B as ClientNavigateTuple, D as ClientNotifyTuple, F as ClientRenderUITuple, G as EffectResult, H as LoaderConfig, O as OrbitalEventRequest, e as OrbitalEventResponse, J as OrbitalServerRuntime, f as OrbitalServerRuntimeConfig, R as RegisteredOrbital, j as RuntimeOrbital, k as RuntimeOrbitalSchema, l as RuntimeTrait, K as RuntimeTraitTick, n as collectDeclaredConfigDefaults, M as createOrbitalServerRuntime } from './OrbitalServerRuntime-B-8J_5e9.js';
4
+ import './types-cuy5gd29.js';
5
5
  export { I as InMemoryPersistence, P as PersistenceAdapter } from './PersistenceAdapter-B6dQCbbU.js';
@@ -1,4 +1,4 @@
1
- export { InMemoryPersistence, OrbitalServerRuntime, collectDeclaredConfigDefaults, createOrbitalServerRuntime } from './chunk-6W6XCOLH.js';
1
+ export { InMemoryPersistence, OrbitalServerRuntime, collectDeclaredConfigDefaults, createOrbitalServerRuntime } from './chunk-7CGDR3GM.js';
2
2
  import './chunk-PZ5AY32C.js';
3
3
  //# sourceMappingURL=OrbitalServerRuntime.js.map
4
4
  //# sourceMappingURL=OrbitalServerRuntime.js.map
@@ -1,4 +1,4 @@
1
- import { I as IEventBus } from './types-ByLpy6yj.js';
1
+ import { I as IEventBus } from './types-cuy5gd29.js';
2
2
  import { EventPayload } from '@almadar/core';
3
3
 
4
4
  /**
@@ -1292,7 +1292,8 @@ var EffectExecutor = class {
1292
1292
  const emitCfg = this.extractEmitConfig(rawOpt);
1293
1293
  try {
1294
1294
  const result = await this.handlers.fetch(entityType, options);
1295
- this.emitSuccess(emitCfg, "success", { data: result });
1295
+ const payload = result ? { data: result.rows, totalCount: result.total } : { data: null, totalCount: 0 };
1296
+ this.emitSuccess(emitCfg, "success", payload);
1296
1297
  } catch (err) {
1297
1298
  this.emitFailure(emitCfg, err);
1298
1299
  throw err;
@@ -1309,7 +1310,7 @@ var EffectExecutor = class {
1309
1310
  const refOptions = typeof rawRefOpt === "string" ? { id: rawRefOpt } : rawRefOpt;
1310
1311
  const refEmitCfg = this.extractEmitConfig(rawRefOpt);
1311
1312
  try {
1312
- let result = void 0;
1313
+ let result = null;
1313
1314
  if (this.handlers.ref) {
1314
1315
  result = await this.handlers.ref(refEntityType, refOptions);
1315
1316
  } else if (this.handlers.fetch) {
@@ -1317,7 +1318,8 @@ var EffectExecutor = class {
1317
1318
  } else {
1318
1319
  this.logUnsupported("ref");
1319
1320
  }
1320
- this.emitSuccess(refEmitCfg, "on_change", { data: result });
1321
+ const refPayload = result ? { data: result.rows, totalCount: result.total } : { data: null, totalCount: 0 };
1322
+ this.emitSuccess(refEmitCfg, "on_change", refPayload);
1321
1323
  } catch (err) {
1322
1324
  this.emitFailure(refEmitCfg, err);
1323
1325
  throw err;
@@ -4699,15 +4701,14 @@ var OrbitalServerRuntime = class {
4699
4701
  xOrbitalLog.info("fetch:enter", {
4700
4702
  entityType: fetchEntityType,
4701
4703
  hasOptions: options !== void 0 && options !== null,
4702
- optionsKeys: options && typeof options === "object" ? Object.keys(options).join(",") : "",
4704
+ optionsKeys: options ? Object.keys(options).join(",") : "",
4703
4705
  filterType: typeof options?.filter,
4704
4706
  filterIsArray: Array.isArray(options?.filter),
4705
- filterJson: JSON.stringify(
4706
- options?.filter ?? null
4707
- ).slice(0, 300),
4707
+ filterJson: JSON.stringify(options?.filter ?? null).slice(0, 300),
4708
4708
  payloadJson: JSON.stringify(bindingsRef?.payload ?? null).slice(0, 300)
4709
4709
  });
4710
4710
  let result = null;
4711
+ let total = 0;
4711
4712
  if (options?.id) {
4712
4713
  const entity = await this.persistence.getById(fetchEntityType, options.id);
4713
4714
  if (entity) {
@@ -4716,6 +4717,7 @@ var OrbitalServerRuntime = class {
4716
4717
  }
4717
4718
  fetchedData[fetchEntityType] = [entity];
4718
4719
  result = entity;
4720
+ total = 1;
4719
4721
  }
4720
4722
  } else {
4721
4723
  let entities = await this.persistence.list(fetchEntityType);
@@ -4737,6 +4739,7 @@ var OrbitalServerRuntime = class {
4737
4739
  }
4738
4740
  });
4739
4741
  }
4742
+ total = entities.length;
4740
4743
  if (options?.offset && options.offset > 0) {
4741
4744
  entities = entities.slice(options.offset);
4742
4745
  }
@@ -4777,7 +4780,7 @@ var OrbitalServerRuntime = class {
4777
4780
  registered.dataCache.set(fetchEntityType, emptyCollection);
4778
4781
  }
4779
4782
  }
4780
- return result;
4783
+ return result === null ? null : { rows: result, total };
4781
4784
  } catch (error) {
4782
4785
  console.error(`[OrbitalRuntime] Fetch error for ${fetchEntityType}:`, error);
4783
4786
  return null;
@@ -4795,16 +4798,19 @@ var OrbitalServerRuntime = class {
4795
4798
  deref: async (derefEntityType, options) => {
4796
4799
  try {
4797
4800
  let result = null;
4801
+ let total = 0;
4798
4802
  if (options?.id) {
4799
4803
  const entity = await this.persistence.getById(derefEntityType, options.id);
4800
4804
  if (entity) {
4801
4805
  fetchedData[derefEntityType] = [entity];
4802
4806
  result = entity;
4807
+ total = 1;
4803
4808
  }
4804
4809
  } else {
4805
4810
  const entities = await this.persistence.list(derefEntityType);
4806
4811
  fetchedData[derefEntityType] = entities;
4807
4812
  result = entities;
4813
+ total = entities.length;
4808
4814
  }
4809
4815
  if (bindingsRef && result) {
4810
4816
  const records = Array.isArray(result) ? result : [result];
@@ -4821,7 +4827,7 @@ var OrbitalServerRuntime = class {
4821
4827
  entityType: derefEntityType,
4822
4828
  success: true
4823
4829
  });
4824
- return result;
4830
+ return result === null ? null : { rows: result, total };
4825
4831
  } catch (error) {
4826
4832
  effectResults.push({
4827
4833
  effect: "deref",
@@ -5405,5 +5411,5 @@ function buildMatcher(src, listenerOrbital) {
5405
5411
  }
5406
5412
 
5407
5413
  export { EffectExecutor, EventBus, HANDLER_MANIFEST, InMemoryPersistence, MockPersistenceAdapter, OrbitalServerRuntime, StateMachineManager, buildEmitsFromTraits, collectDeclaredConfigDefaults, containsBindings, createContextFromBindings, createInitialTraitState, createLogger, createMockPersistence, createOrbitalServerRuntime, createTestExecutor, createUnifiedLoader, extractBindings, findInitialState, findTransition, formatPayloadValidationError, getIsolatedCollectionName, getNamespacedEvent, interpolateProps, interpolateValue, isBrowser, isElectron, isNamespacedEvent, isNode, normalizeEventKey, parseNamespacedEvent, preprocessSchema, processEvent, validateEventPayload, validatePayloadShapes };
5408
- //# sourceMappingURL=chunk-6W6XCOLH.js.map
5409
- //# sourceMappingURL=chunk-6W6XCOLH.js.map
5414
+ //# sourceMappingURL=chunk-7CGDR3GM.js.map
5415
+ //# sourceMappingURL=chunk-7CGDR3GM.js.map