@almadar/runtime 6.59.0 → 6.61.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,5 +1,5 @@
1
1
  import { Router } from 'express';
2
- import { I as IEventBus, R as RuntimeEvent, a as EventListener, U as Unsubscribe, T as TraitDefinition, b as RuntimeConfig, c as TransitionObserver, d as TraitState, C as ConfigContext, e as TransitionResult, f as EvaluationContextExtensions, E as EffectHandlers } from './types-TwQ8Dybu.js';
2
+ import { I as IEventBus, R as RuntimeEvent, a as EventListener, U as Unsubscribe, T as TraitDefinition, b as RuntimeConfig, c as TransitionObserver, d as TraitState, C as ConfigContext, e as TransitionResult, f as EvaluationContextExtensions, E as EffectHandlers } from './types-BaD_ox7e.js';
3
3
  import { EventPayload, EventId, EntityRow, UserContext, Orbital, ServiceCallResult, TraitConfig, DeclaredTraitConfig, Entity, OrbitalSchema, Trait, PatternConfig, ResolvedPatternProps, SExpr, BusEventSource, RawUserClaims, OrbitalDefinition, TraitTick } from '@almadar/core';
4
4
 
5
5
  /**
@@ -478,8 +478,15 @@ interface LoadedSchema {
478
478
  * Result of loading a single orbital from a schema.
479
479
  */
480
480
  interface LoadedOrbital {
481
- /** The loaded orbital */
481
+ /** The loaded orbital — the named one when requested, else the first. */
482
482
  orbital: Orbital;
483
+ /**
484
+ * EVERY orbital in the loaded schema. `Alias.traits.X` carries no orbital
485
+ * segment, so a multi-orbital behavior's traits and pages must all stay
486
+ * reachable; resolving against `orbital` alone silently loses everything
487
+ * outside it. Mirrors the compiled path's `AliasEntry.orbitals`.
488
+ */
489
+ orbitals?: Orbital[];
483
490
  /** Source path/URL (resolved) */
484
491
  sourcePath: string;
485
492
  /** Original import path */
@@ -1,4 +1,4 @@
1
1
  import 'express';
2
- export { F as ClientEffectTuple, G as ClientNavigateBackTuple, H as ClientNavigateTuple, J as ClientNotifyTuple, K as ClientRenderUITuple, M as EffectResult, e as InMemoryPersistence, N as LiveBroadcastItem, Q as LoaderConfig, O as OrbitalEventRequest, f as OrbitalEventResponse, T as OrbitalServerRuntime, g as OrbitalServerRuntimeConfig, P as PersistenceAdapter, R as RegisteredOrbital, l as RuntimeOrbital, m as RuntimeOrbitalSchema, n as RuntimeTrait, V as RuntimeTraitTick, p as collectDeclaredConfigDefaults, W as createOrbitalServerRuntime } from './OrbitalServerRuntime-PI9Ioxdp.js';
3
- import './types-TwQ8Dybu.js';
2
+ export { F as ClientEffectTuple, G as ClientNavigateBackTuple, H as ClientNavigateTuple, J as ClientNotifyTuple, K as ClientRenderUITuple, M as EffectResult, e as InMemoryPersistence, N as LiveBroadcastItem, Q as LoaderConfig, O as OrbitalEventRequest, f as OrbitalEventResponse, T as OrbitalServerRuntime, g as OrbitalServerRuntimeConfig, P as PersistenceAdapter, R as RegisteredOrbital, l as RuntimeOrbital, m as RuntimeOrbitalSchema, n as RuntimeTrait, V as RuntimeTraitTick, p as collectDeclaredConfigDefaults, W as createOrbitalServerRuntime } from './OrbitalServerRuntime-CZHHxo_A.js';
3
+ import './types-BaD_ox7e.js';
4
4
  import '@almadar/core';
@@ -1,5 +1,5 @@
1
- import { createTickScheduler, EventBus, createUnifiedLoader, MockPersistenceAdapter, InMemoryPersistence, preprocessSchema, normalizeCallSiteConfigToValues, StateMachineManager, parseDurationString, validateEventPayload, formatPayloadValidationError, collectDeclaredConfigDefaults, collectDeclaredEntityDefaults, EffectExecutor } from './chunk-WSNZNXZE.js';
2
- export { InMemoryPersistence, collectDeclaredConfigDefaults } from './chunk-WSNZNXZE.js';
1
+ import { createTickScheduler, EventBus, createUnifiedLoader, MockPersistenceAdapter, InMemoryPersistence, preprocessSchema, normalizeCallSiteConfigToValues, StateMachineManager, parseDurationString, validateEventPayload, formatPayloadValidationError, collectDeclaredConfigDefaults, collectDeclaredEntityDefaults, EffectExecutor } from './chunk-QY5EUGR2.js';
2
+ export { InMemoryPersistence, collectDeclaredConfigDefaults } from './chunk-QY5EUGR2.js';
3
3
  import { isValidCronExpression } from './chunk-OU3ITB5S.js';
4
4
  import { createContextFromBindings, resolveCallSitePayloadCaptures, applyRowAccess, checkMutationAccess, accessDeniedMessage } from './chunk-ZJ62H3ES.js';
5
5
  import './chunk-T4VDAB4C.js';
@@ -1542,6 +1542,7 @@ var OrbitalServerRuntime = class {
1542
1542
  data: resultData,
1543
1543
  success: true
1544
1544
  });
1545
+ return resultData;
1545
1546
  } catch (err) {
1546
1547
  effectLog.error("persist:store-mutate-error", {
1547
1548
  action,
@@ -1556,6 +1557,7 @@ var OrbitalServerRuntime = class {
1556
1557
  error: err instanceof Error ? err.message : String(err)
1557
1558
  });
1558
1559
  }
1560
+ return void 0;
1559
1561
  },
1560
1562
  callService: async (service, action, params) => {
1561
1563
  try {
@@ -1,4 +1,4 @@
1
- import { I as IEventBus } from './types-TwQ8Dybu.js';
1
+ import { I as IEventBus } from './types-BaD_ox7e.js';
2
2
  import { EventPayload } from '@almadar/core';
3
3
 
4
4
  /**
@@ -134,6 +134,9 @@ function push(entry) {
134
134
  scheduleNotify();
135
135
  }
136
136
  function isEnabled() {
137
+ return isLogLevelEnabled("DEBUG", PERF_NAMESPACE) || globalThis.__ALMADAR_PERF__ === true;
138
+ }
139
+ function isVerbose() {
137
140
  return isLogLevelEnabled("DEBUG", PERF_NAMESPACE);
138
141
  }
139
142
  function now() {
@@ -161,7 +164,8 @@ function perfEnd(name, startToken, detail) {
161
164
  }
162
165
  }
163
166
  push({ name, durationMs, ts: endTs, detail });
164
- log.debug(name, () => ({ durationMs, ...detail ?? {} }));
167
+ aggregate(name, durationMs);
168
+ if (isVerbose()) log.debug(name, () => ({ durationMs, ...detail ?? {} }));
165
169
  }
166
170
  function perfTime(name, fn, detail) {
167
171
  const t = perfStart(name);
@@ -171,6 +175,46 @@ function perfTime(name, fn, detail) {
171
175
  perfEnd(name, t, detail);
172
176
  }
173
177
  }
178
+ async function perfTimeAsync(name, fn) {
179
+ const t = perfStart(name);
180
+ try {
181
+ return await fn();
182
+ } finally {
183
+ perfEnd(name, t);
184
+ }
185
+ }
186
+ function perfGauge(name, value) {
187
+ if (!isEnabled()) return;
188
+ aggregate(name, value);
189
+ }
190
+ var buckets = /* @__PURE__ */ new Map();
191
+ var dumpTimer = null;
192
+ function aggregate(name, ms) {
193
+ const b = buckets.get(name);
194
+ if (b) {
195
+ b.count++;
196
+ b.totalMs += ms;
197
+ if (ms > b.maxMs) b.maxMs = ms;
198
+ } else {
199
+ buckets.set(name, { count: 1, totalMs: ms, maxMs: ms });
200
+ }
201
+ if (dumpTimer === null) {
202
+ dumpTimer = setInterval(dumpSummary, 5e3);
203
+ if (typeof dumpTimer === "object" && "unref" in dumpTimer) dumpTimer.unref();
204
+ }
205
+ }
206
+ function dumpSummary() {
207
+ if (buckets.size === 0) return;
208
+ const rows = [...buckets.entries()].map(([name, b]) => ({
209
+ name,
210
+ count: b.count,
211
+ totalMs: Math.round(b.totalMs),
212
+ avgMs: Math.round(b.totalMs / b.count * 100) / 100,
213
+ maxMs: Math.round(b.maxMs * 10) / 10
214
+ })).sort((a, b) => b.totalMs - a.totalMs);
215
+ log.warn("[PROFILE] summary", { phases: JSON.stringify(rows) });
216
+ buckets.clear();
217
+ }
174
218
  function getPerfSnapshot() {
175
219
  if (ring.length < RING_SIZE) return ring.slice();
176
220
  return [...ring.slice(writeIdx), ...ring.slice(0, writeIdx)];
@@ -424,4 +468,4 @@ function bindTraitStateGetter(getter) {
424
468
  api.getTraitState = getter;
425
469
  }
426
470
 
427
- export { PERF_NAMESPACE, RendererContractViolationError, adjustSchemaForMockData, aggregateSlotContent, assertIsMultiSourceSlotManager, assertIsSlotManager, bindEventBus, bindTraitStateGetter, buildMockData, buildOrbitalsByTrait, clearPerf, createSlotSetter, ensureVerificationApi, getOrbitalVerification, perfEnd, perfStart, perfStore, perfTime, prepareSchemaForPreview, pushPerfEntry, validateSlotContent, wrapCallbackForEvent };
471
+ export { PERF_NAMESPACE, RendererContractViolationError, adjustSchemaForMockData, aggregateSlotContent, assertIsMultiSourceSlotManager, assertIsSlotManager, bindEventBus, bindTraitStateGetter, buildMockData, buildOrbitalsByTrait, clearPerf, createSlotSetter, ensureVerificationApi, getOrbitalVerification, perfEnd, perfGauge, perfStart, perfStore, perfTime, perfTimeAsync, prepareSchemaForPreview, pushPerfEntry, validateSlotContent, wrapCallbackForEvent };
@@ -1363,15 +1363,16 @@ var EffectExecutor = class _EffectExecutor {
1363
1363
  } else {
1364
1364
  const entityType = args[1];
1365
1365
  const data = args[2];
1366
- await this.handlers.persist(action, entityType, data);
1367
- const dataId = typeof data === "string" ? data : data && typeof data === "object" ? data.id : void 0;
1366
+ const persisted = await this.handlers.persist(action, entityType, data);
1367
+ const successPayload = persisted ?? data;
1368
+ const dataId = typeof successPayload === "string" ? successPayload : successPayload && typeof successPayload === "object" ? successPayload.id : void 0;
1368
1369
  persistLog.debug("persist:success", {
1369
1370
  action,
1370
1371
  entityType,
1371
1372
  dataId,
1372
1373
  willEmit: emitCfg?.success
1373
1374
  });
1374
- this.emitSuccess(emitCfg, "success", data, true);
1375
+ this.emitSuccess(emitCfg, "success", successPayload, true);
1375
1376
  persistLog.debug("persist:emit-fired", { action, eventName: emitCfg?.success });
1376
1377
  }
1377
1378
  } catch (err) {
@@ -1974,8 +1975,7 @@ var EffectExecutor = class _EffectExecutor {
1974
1975
  }
1975
1976
  };
1976
1977
  function createTestExecutor(overrides = {}) {
1977
- const noopAsync = async () => {
1978
- };
1978
+ const noopAsync = async () => void 0;
1979
1979
  const noop = () => {
1980
1980
  };
1981
1981
  return new EffectExecutor({
@@ -2635,6 +2635,7 @@ var HttpLoader = class {
2635
2635
  success: true,
2636
2636
  data: {
2637
2637
  orbital,
2638
+ orbitals: schema.orbitals,
2638
2639
  sourcePath: schemaResult.data.sourcePath,
2639
2640
  importPath
2640
2641
  }
@@ -2844,7 +2845,7 @@ async function getExternalLoaderModule() {
2844
2845
  return null;
2845
2846
  }
2846
2847
  try {
2847
- externalLoaderModule = await import('./external-loader-WYQAS3BS.js');
2848
+ externalLoaderModule = await import('./external-loader-YUUADLAP.js');
2848
2849
  return externalLoaderModule;
2849
2850
  } catch {
2850
2851
  return null;
@@ -3017,6 +3018,7 @@ var UnifiedLoader = class {
3017
3018
  success: true,
3018
3019
  data: {
3019
3020
  orbital: found,
3021
+ orbitals: schema.orbitals,
3020
3022
  sourcePath: schemaResult.data.sourcePath,
3021
3023
  importPath
3022
3024
  }
@@ -3032,6 +3034,7 @@ var UnifiedLoader = class {
3032
3034
  success: true,
3033
3035
  data: {
3034
3036
  orbital: schema.orbitals[0],
3037
+ orbitals: schema.orbitals,
3035
3038
  sourcePath: schemaResult.data.sourcePath,
3036
3039
  importPath
3037
3040
  }
@@ -3400,10 +3403,13 @@ function buildIdIndex(orbital, orbitals) {
3400
3403
  const idIndex = /* @__PURE__ */ new Map();
3401
3404
  indexOrbitalNodes(orbital, idIndex);
3402
3405
  for (const imported of orbitals.values()) {
3403
- indexOrbitalNodes(imported.orbital, idIndex);
3406
+ for (const o of importedOrbitals(imported)) indexOrbitalNodes(o, idIndex);
3404
3407
  }
3405
3408
  return idIndex;
3406
3409
  }
3410
+ function importedOrbitals(imported) {
3411
+ return imported.orbitals?.length ? imported.orbitals : [imported.orbital];
3412
+ }
3407
3413
  function renameEventsInRenderUiConfig(node, rename) {
3408
3414
  if (node === null || node === void 0) return node;
3409
3415
  if (Array.isArray(node)) {
@@ -3616,6 +3622,23 @@ function traitEmbedNamesOf(trait) {
3616
3622
  for (const field of Object.values(trait.config ?? {})) walk(field.default);
3617
3623
  return [...found];
3618
3624
  }
3625
+ function resolveForwardedSiblingConfig(trait, parent) {
3626
+ const declared = trait.config;
3627
+ const parentDeclared = parent?.config;
3628
+ if (!declared || !parentDeclared) return trait;
3629
+ let next;
3630
+ for (const [key, field] of Object.entries(declared)) {
3631
+ const forward = field.default;
3632
+ if (typeof forward !== "string" || !forward.startsWith("@config.")) continue;
3633
+ const knob = forward.slice("@config.".length);
3634
+ if (knob.length === 0 || knob.includes(".")) continue;
3635
+ const value = parentDeclared[knob]?.default;
3636
+ if (value === void 0 || value === forward) continue;
3637
+ next ??= { ...declared };
3638
+ next[key] = { ...field, default: value };
3639
+ }
3640
+ return next ? { ...trait, config: next } : trait;
3641
+ }
3619
3642
  function applyLinkedEntityRename(trait, linkedEntity) {
3620
3643
  const atomLinked = trait.linkedEntity;
3621
3644
  if (!linkedEntity || !atomLinked || linkedEntity === atomLinked) return trait;
@@ -3804,7 +3827,7 @@ var ReferenceResolver = class {
3804
3827
  if (this.loader || this.loaderInitialized) return;
3805
3828
  this.loaderInitialized = true;
3806
3829
  try {
3807
- const { ExternalOrbitalLoader } = await import('./external-loader-WYQAS3BS.js');
3830
+ const { ExternalOrbitalLoader } = await import('./external-loader-YUUADLAP.js');
3808
3831
  this.loader = new ExternalOrbitalLoader(this.options);
3809
3832
  } catch {
3810
3833
  }
@@ -3912,6 +3935,7 @@ var ReferenceResolver = class {
3912
3935
  alias: use.as,
3913
3936
  from: use.from,
3914
3937
  orbital: loadResult.data.orbital,
3938
+ orbitals: loadResult.data.orbitals ?? [loadResult.data.orbital],
3915
3939
  sourcePath: loadResult.data.sourcePath
3916
3940
  });
3917
3941
  }
@@ -4116,7 +4140,11 @@ var ReferenceResolver = class {
4116
4140
  visited.add(pullKey);
4117
4141
  const imported = imports.orbitals.get(alias);
4118
4142
  if (!imported) continue;
4119
- const atomEntry = findTraitEntryInOrbital(imported.orbital, sibling);
4143
+ let atomEntry = null;
4144
+ for (const o of importedOrbitals(imported)) {
4145
+ atomEntry = findTraitEntryInOrbital(o, sibling);
4146
+ if (atomEntry) break;
4147
+ }
4120
4148
  if (!atomEntry) continue;
4121
4149
  let atomTrait;
4122
4150
  if ("stateMachine" in atomEntry) {
@@ -4148,7 +4176,11 @@ var ReferenceResolver = class {
4148
4176
  }
4149
4177
  atomTrait = nested.data.trait;
4150
4178
  }
4151
- let copy = applyLinkedEntityRename(atomTrait, linkedEntity);
4179
+ const embedder = resolved.find((r) => r.trait.name === parent)?.trait ?? pulled.find((r) => r.trait.name === parent)?.trait;
4180
+ let copy = resolveForwardedSiblingConfig(
4181
+ applyLinkedEntityRename(atomTrait, linkedEntity),
4182
+ embedder
4183
+ );
4152
4184
  if (finalName !== sibling) {
4153
4185
  copy = { ...copy, name: finalName };
4154
4186
  noteRewrite(parent, sibling, finalName);
@@ -4261,12 +4293,17 @@ var ReferenceResolver = class {
4261
4293
  ]
4262
4294
  };
4263
4295
  }
4264
- const trait = this.findTraitInOrbital(imported.orbital, parsed.traitName, refId, imports.idIndex);
4296
+ let trait = null;
4297
+ for (const o of importedOrbitals(imported)) {
4298
+ trait = this.findTraitInOrbital(o, parsed.traitName, refId, imports.idIndex);
4299
+ if (trait) break;
4300
+ }
4265
4301
  if (!trait) {
4302
+ const available = importedOrbitals(imported).flatMap((o) => this.listTraitsInOrbital(o));
4266
4303
  return {
4267
4304
  success: false,
4268
4305
  errors: [
4269
- `Trait "${parsed.traitName}" not found in imported orbital "${parsed.alias}". Available traits: ${this.listTraitsInOrbital(imported.orbital).join(", ") || "none"}`
4306
+ `Trait "${parsed.traitName}" not found in imported orbital "${parsed.alias}". Available traits: ${available.join(", ") || "none"}`
4270
4307
  ]
4271
4308
  };
4272
4309
  }
@@ -4435,12 +4472,17 @@ var ReferenceResolver = class {
4435
4472
  ]
4436
4473
  };
4437
4474
  }
4438
- const page = this.findPageInOrbital(imported.orbital, parsed.pageName, refId, imports.idIndex);
4475
+ let page = null;
4476
+ for (const o of importedOrbitals(imported)) {
4477
+ page = this.findPageInOrbital(o, parsed.pageName, refId, imports.idIndex);
4478
+ if (page) break;
4479
+ }
4439
4480
  if (!page) {
4481
+ const available = importedOrbitals(imported).flatMap((o) => this.listPagesInOrbital(o));
4440
4482
  return {
4441
4483
  success: false,
4442
4484
  errors: [
4443
- `Page "${parsed.pageName}" not found in imported orbital "${parsed.alias}". Available pages: ${this.listPagesInOrbital(imported.orbital).join(", ") || "none"}`
4485
+ `Page "${parsed.pageName}" not found in imported orbital "${parsed.alias}". Available pages: ${available.join(", ") || "none"}`
4444
4486
  ]
4445
4487
  };
4446
4488
  }
@@ -1,4 +1,4 @@
1
- import { E as EffectHandlers } from './types-TwQ8Dybu.js';
1
+ import { E as EffectHandlers } from './types-BaD_ox7e.js';
2
2
  import { EventPayload } from '@almadar/core';
3
3
 
4
4
  /**
@@ -154,6 +154,7 @@ var ExternalOrbitalLoader = class {
154
154
  success: true,
155
155
  data: {
156
156
  orbital,
157
+ orbitals: schema.orbitals,
157
158
  sourcePath: schemaResult.data.sourcePath,
158
159
  importPath
159
160
  }
package/dist/index.d.ts CHANGED
@@ -1,15 +1,15 @@
1
- import { g as RuntimePatternValue, B as BindingContext, f as EvaluationContextExtensions, P as PatternProps, E as EffectHandlers, h as EffectContext, i as ExecutionEnvironment, j as EffectResult, S as ServiceCallContext, T as TraitDefinition } from './types-TwQ8Dybu.js';
2
- export { k as BrowserFileMeta, l as BrowserFilePickerOptions, m as BrowserGeolocationOptions, n as BrowserGeolocationPosition, C as ConfigContext, o as Effect, a as EventListener, H as HANDLER_MANIFEST, I as IEventBus, b as RuntimeConfig, R as RuntimeEvent, d as TraitState, c as TransitionObserver, e as TransitionResult, U as Unsubscribe } from './types-TwQ8Dybu.js';
3
- import { U as UnifiedLoaderOptions, S as SchemaLoader, I as ImportChainLike, L as LoadResult, a as LoadedSchema, b as LoadedOrbital, P as PersistenceAdapter } from './OrbitalServerRuntime-PI9Ioxdp.js';
4
- export { E as EntitySharingMap, c as EventBus, d as EventNamespaceMap, e as InMemoryPersistence, O as OrbitalEventRequest, f as OrbitalEventResponse, g as OrbitalServerRuntimeConfig, h as PreprocessOptions, i as PreprocessResult, j as PreprocessedSchema, k as ProcessEventOptions, R as RegisteredOrbital, l as RuntimeOrbital, m as RuntimeOrbitalSchema, n as RuntimeTrait, o as StateMachineManager, p as collectDeclaredConfigDefaults, q as collectDeclaredEntityDefaults, r as createInitialTraitState, s as findInitialState, t as findTransition, u as getIsolatedCollectionName, v as getNamespacedEvent, w as isBrowser, x as isElectron, y as isNamespacedEvent, z as isNode, A as normalizeEventKey, B as parseNamespacedEvent, C as preprocessSchema, D as processEvent } from './OrbitalServerRuntime-PI9Ioxdp.js';
1
+ import { g as RuntimePatternValue, B as BindingContext, f as EvaluationContextExtensions, P as PatternProps, E as EffectHandlers, h as EffectContext, i as ExecutionEnvironment, j as EffectResult, S as ServiceCallContext, T as TraitDefinition } from './types-BaD_ox7e.js';
2
+ export { k as BrowserFileMeta, l as BrowserFilePickerOptions, m as BrowserGeolocationOptions, n as BrowserGeolocationPosition, C as ConfigContext, o as Effect, a as EventListener, H as HANDLER_MANIFEST, I as IEventBus, b as RuntimeConfig, R as RuntimeEvent, d as TraitState, c as TransitionObserver, e as TransitionResult, U as Unsubscribe } from './types-BaD_ox7e.js';
3
+ import { U as UnifiedLoaderOptions, S as SchemaLoader, I as ImportChainLike, L as LoadResult, a as LoadedSchema, b as LoadedOrbital, P as PersistenceAdapter } from './OrbitalServerRuntime-CZHHxo_A.js';
4
+ export { E as EntitySharingMap, c as EventBus, d as EventNamespaceMap, e as InMemoryPersistence, O as OrbitalEventRequest, f as OrbitalEventResponse, g as OrbitalServerRuntimeConfig, h as PreprocessOptions, i as PreprocessResult, j as PreprocessedSchema, k as ProcessEventOptions, R as RegisteredOrbital, l as RuntimeOrbital, m as RuntimeOrbitalSchema, n as RuntimeTrait, o as StateMachineManager, p as collectDeclaredConfigDefaults, q as collectDeclaredEntityDefaults, r as createInitialTraitState, s as findInitialState, t as findTransition, u as getIsolatedCollectionName, v as getNamespacedEvent, w as isBrowser, x as isElectron, y as isNamespacedEvent, z as isNode, A as normalizeEventKey, B as parseNamespacedEvent, C as preprocessSchema, D as processEvent } from './OrbitalServerRuntime-CZHHxo_A.js';
5
5
  import { EvaluationContext, SExpressionEvaluator } from '@almadar/evaluator';
6
6
  export { EvaluationContext, createMinimalContext } from '@almadar/evaluator';
7
- import { RenderBindingMarker, SExpr, TraitConfigObject, EventPayload, PatternConfig, EntityId, EntityField, EntityRow, EntityPersistence, ServiceParams, EntityAccessPolicies, PayloadField, OrbitalDefinition, OrbitalSchema } from '@almadar/core';
7
+ import { RenderBindingMarker, SExpr, RuntimeValue, TraitConfigObject, EventPayload, PatternConfig, EntityId, EntityField, EntityRow, EntityPersistence, ServiceParams, EntityAccessPolicies, PayloadField, OrbitalDefinition, OrbitalSchema } from '@almadar/core';
8
8
  export { EntityField, normalizeCallSiteConfigToValues } from '@almadar/core';
9
9
  export { AccessBindings, applyRowAccess, checkMutationAccess } from './entityAccess.js';
10
10
  export { ServerBridgeConfig, ServerBridgeState } from './ServerBridge.js';
11
11
  export { OsHandlerContext, OsHandlerResult } from './createOsHandlers.js';
12
- export { MultiSourceSlotManager, PERF_NAMESPACE, PerfDetail, PerfDetailValue, PerfEntry, PreparedPreviewSchema, RendererContractViolationError, ResolvedPageTraits, SlotContent, SlotContentValidationError, SlotManager, SlotSource, VerificationBus, adjustSchemaForMockData, aggregateSlotContent, assertIsMultiSourceSlotManager, assertIsSlotManager, bindEventBus, bindTraitStateGetter, buildMockData, buildOrbitalsByTrait, clearPerf, collectEmbeddedTraits, collectTraitRefsFromResolvedTrait, createSlotSetter, ensureVerificationApi, getOrbitalVerification, perfEnd, perfStart, perfStore, perfTime, prepareSchemaForPreview, pushPerfEntry, validateSlotContent, wrapCallbackForEvent } from './ui/index.js';
12
+ export { MultiSourceSlotManager, PERF_NAMESPACE, PerfDetail, PerfDetailValue, PerfEntry, PreparedPreviewSchema, RendererContractViolationError, ResolvedPageTraits, SlotContent, SlotContentValidationError, SlotManager, SlotSource, VerificationBus, adjustSchemaForMockData, aggregateSlotContent, assertIsMultiSourceSlotManager, assertIsSlotManager, bindEventBus, bindTraitStateGetter, buildMockData, buildOrbitalsByTrait, clearPerf, collectEmbeddedTraits, collectTraitRefsFromResolvedTrait, createSlotSetter, ensureVerificationApi, getOrbitalVerification, perfEnd, perfGauge, perfStart, perfStore, perfTime, perfTimeAsync, prepareSchemaForPreview, pushPerfEntry, validateSlotContent, wrapCallbackForEvent } from './ui/index.js';
13
13
  import 'express';
14
14
  import '@almadar/core/patterns';
15
15
 
@@ -289,7 +289,7 @@ declare function interpolateProps(props: PatternProps, ctx: EvaluationContext):
289
289
  /**
290
290
  * Interpolate a single value.
291
291
  */
292
- declare function interpolateValue(value: unknown, ctx: EvaluationContext): unknown;
292
+ declare function interpolateValue(value: RuntimeValue, ctx: EvaluationContext): RuntimeValue;
293
293
  /**
294
294
  * Value a deferred render-ui prop tree can carry: interpolated runtime
295
295
  * values, raw pass-through S-expressions (`fn` lambdas), render-time
@@ -419,15 +419,15 @@ declare class EffectExecutor {
419
419
  /**
420
420
  * Execute a single effect.
421
421
  */
422
- execute(effect: unknown): Promise<void>;
422
+ execute(effect: RuntimeValue): Promise<void>;
423
423
  /**
424
424
  * Execute multiple effects in sequence.
425
425
  */
426
- executeAll(effects: unknown[]): Promise<void>;
426
+ executeAll(effects: RuntimeValue[]): Promise<void>;
427
427
  /**
428
428
  * Execute multiple effects in parallel.
429
429
  */
430
- executeParallel(effects: unknown[]): Promise<void>;
430
+ executeParallel(effects: RuntimeValue[]): Promise<void>;
431
431
  /**
432
432
  * Execute effects and return detailed results for each.
433
433
  * Enables compensating transitions by reporting which effects failed.
@@ -435,7 +435,7 @@ declare class EffectExecutor {
435
435
  * Unlike `executeAll`, this method does NOT throw on effect errors.
436
436
  * Instead, it captures errors in the returned `EffectResult[]` array.
437
437
  */
438
- executeWithResults(effects: unknown[]): Promise<EffectResult[]>;
438
+ executeWithResults(effects: RuntimeValue[]): Promise<EffectResult[]>;
439
439
  private extractEmitConfig;
440
440
  /** Build the source metadata stamp for an emit fired from this trait. */
441
441
  private sourceStamp;
package/dist/index.js CHANGED
@@ -1,10 +1,10 @@
1
- import { EffectExecutor } from './chunk-WSNZNXZE.js';
2
- export { EffectExecutor, EventBus, HANDLER_MANIFEST, InMemoryPersistence, MockPersistenceAdapter, StateMachineManager, TickScheduler, buildEmitsFromTraits, collectDeclaredConfigDefaults, collectDeclaredEntityDefaults, createInitialTraitState, createMockPersistence, createTestExecutor, createTickScheduler, createUnifiedLoader, findInitialState, findTransition, formatPayloadValidationError, getIsolatedCollectionName, getNamespacedEvent, isBrowser, isElectron, isNamespacedEvent, isNode, isValidDurationString, normalizeCallSiteConfigToValues, normalizeEventKey, parseDurationString, parseNamespacedEvent, preprocessSchema, processEvent, validateEventPayload, validatePayloadShapes } from './chunk-WSNZNXZE.js';
1
+ import { EffectExecutor } from './chunk-QY5EUGR2.js';
2
+ export { EffectExecutor, EventBus, HANDLER_MANIFEST, InMemoryPersistence, MockPersistenceAdapter, StateMachineManager, TickScheduler, buildEmitsFromTraits, collectDeclaredConfigDefaults, collectDeclaredEntityDefaults, createInitialTraitState, createMockPersistence, createTestExecutor, createTickScheduler, createUnifiedLoader, findInitialState, findTransition, formatPayloadValidationError, getIsolatedCollectionName, getNamespacedEvent, isBrowser, isElectron, isNamespacedEvent, isNode, isValidDurationString, normalizeCallSiteConfigToValues, normalizeEventKey, parseDurationString, parseNamespacedEvent, preprocessSchema, processEvent, validateEventPayload, validatePayloadShapes } from './chunk-QY5EUGR2.js';
3
3
  export { cronMatches, cronMinuteKey, isValidCronExpression, parseCron, parseCronField } from './chunk-OU3ITB5S.js';
4
4
  import { createContextFromBindings, applyRowAccess, checkMutationAccess, accessDeniedMessage } from './chunk-ZJ62H3ES.js';
5
5
  export { CALLSITE_PAYLOAD_PREFIX, applyRowAccess, checkMutationAccess, containsBindings, createContextFromBindings, createMinimalContext, deferEntityBindings, extractBindings, interpolateProps, interpolateValue, resolveCallSitePayloadCaptures } from './chunk-ZJ62H3ES.js';
6
6
  import './chunk-T4VDAB4C.js';
7
- export { PERF_NAMESPACE, RendererContractViolationError, adjustSchemaForMockData, aggregateSlotContent, assertIsMultiSourceSlotManager, assertIsSlotManager, bindEventBus, bindTraitStateGetter, buildMockData, buildOrbitalsByTrait, clearPerf, createSlotSetter, ensureVerificationApi, getOrbitalVerification, perfEnd, perfStart, perfStore, perfTime, prepareSchemaForPreview, pushPerfEntry, validateSlotContent, wrapCallbackForEvent } from './chunk-FOFLEZRJ.js';
7
+ export { PERF_NAMESPACE, RendererContractViolationError, adjustSchemaForMockData, aggregateSlotContent, assertIsMultiSourceSlotManager, assertIsSlotManager, bindEventBus, bindTraitStateGetter, buildMockData, buildOrbitalsByTrait, clearPerf, createSlotSetter, ensureVerificationApi, getOrbitalVerification, perfEnd, perfGauge, perfStart, perfStore, perfTime, perfTimeAsync, prepareSchemaForPreview, pushPerfEntry, validateSlotContent, wrapCallbackForEvent } from './chunk-F5W3YZGJ.js';
8
8
  export { collectEmbeddedTraits, collectTraitRefsFromResolvedTrait } from './chunk-SCRAHWOC.js';
9
9
  import { __export } from './chunk-MLKGABMK.js';
10
10
  import { createLogger } from '@almadar/logger';
@@ -416,6 +416,7 @@ function createServerEffectHandlers(opts) {
416
416
  data: resultData,
417
417
  success: true
418
418
  });
419
+ return resultData;
419
420
  } catch (err) {
420
421
  effectLog.error("persist:store-mutate-error", {
421
422
  action,
@@ -430,6 +431,7 @@ function createServerEffectHandlers(opts) {
430
431
  error: err instanceof Error ? err.message : String(err)
431
432
  });
432
433
  }
434
+ return void 0;
433
435
  },
434
436
  callService: async (service, action, params) => {
435
437
  try {
@@ -1,5 +1,5 @@
1
1
  import * as _almadar_core from '@almadar/core';
2
- import { TraitId, EventId, SExpr, TraitEventListener, AgentContext, LlmContext, WorkspaceContext, SessionContext, MemoryContext, TraceContext, IntegrationContext, TraitConfig, EventPayload, BusEvent, EntityRow, FieldValue, ServiceParams, FetchResult, PatternConfig, ResolvedPatternProps, Orbital, ServiceCallResult, BusEventSource, BusEventListener, Unsubscribe as Unsubscribe$1, UserContext, NavItem } from '@almadar/core';
2
+ import { TraitId, EventId, SExpr, TraitEventListener, AgentContext, LlmContext, WorkspaceContext, SessionContext, MemoryContext, TraceContext, IntegrationContext, TraitConfig, EventPayload, BusEvent, EntityRow, FieldValue, ServiceParams, FetchResult, PatternConfig, ResolvedPatternProps, Orbital, ServiceCallResult, BusEventSource, BusEventListener, Unsubscribe as Unsubscribe$1, UserContext, NavItem, RuntimeValue } from '@almadar/core';
3
3
 
4
4
  /** Alias for ResolvedPatternProps to avoid breaking internal consumers */
5
5
  type PatternProps = ResolvedPatternProps;
@@ -149,8 +149,19 @@ interface EffectHandlers {
149
149
  * `fetch` success envelopes, cascade re-emits).
150
150
  */
151
151
  emit: (event: string, payload?: EventPayload, source?: RuntimeEvent['source'], fromPersistSuccess?: boolean) => void;
152
- /** Persist data (create/update/delete/batch) */
153
- persist: (action: 'create' | 'update' | 'delete' | 'batch', entityType: string, data?: EntityRow) => Promise<void>;
152
+ /**
153
+ * Persist data (create/update/delete/batch).
154
+ *
155
+ * Returns the persisted ROW — for a create that is the submitted data
156
+ * plus the store-minted `id`, which the caller's `emit:{success}`
157
+ * envelope carries. Without it a `*_CREATED` listener sees no id (the
158
+ * compiled path emits the created row), so anything routing on the new
159
+ * row's identity — navigating to the page just created — worked in one
160
+ * execution path only. Implementations that have no row to hand back
161
+ * (batch, a denied write, a no-op stub) return undefined and the
162
+ * envelope falls back to the submitted data.
163
+ */
164
+ persist: (action: 'create' | 'update' | 'delete' | 'batch', entityType: string, data?: EntityRow) => Promise<EntityRow | undefined>;
154
165
  /** Set a field value on an entity */
155
166
  set: (entityId: string, field: string, value: FieldValue) => void;
156
167
  /** Call an external service. `context` carries the caller's identity
@@ -371,7 +382,7 @@ interface BindingContext {
371
382
  * a `let` body's effects resolve their value expressions against the
372
383
  * `let`-bound locals.
373
384
  */
374
- locals?: Map<string, unknown>;
385
+ locals?: Map<string, RuntimeValue>;
375
386
  /** Additional custom bindings */
376
387
  [key: string]: unknown;
377
388
  }
@@ -339,6 +339,10 @@ declare function perfStart(name: string): number;
339
339
  declare function perfEnd(name: string, startToken: number, detail?: PerfDetail): void;
340
340
  /** Synchronous wrapper that times a fn end-to-end. */
341
341
  declare function perfTime<T>(name: string, fn: () => T, detail?: PerfDetail): T;
342
+ /** Async wrapper — the tick/effect paths are async end-to-end. */
343
+ declare function perfTimeAsync<T>(name: string, fn: () => Promise<T> | T): Promise<T>;
344
+ /** Record a non-duration scalar (queue depth, entries/pass) into the summary. */
345
+ declare function perfGauge(name: string, value: number): void;
342
346
  declare function getSnapshot(): readonly PerfEntry[];
343
347
  declare function subscribe(fn: () => void): () => void;
344
348
  /** Push a pre-computed entry (e.g. React.Profiler callback). */
@@ -416,4 +420,4 @@ declare function bindEventBus(eventBus: VerificationBus): void;
416
420
  */
417
421
  declare function bindTraitStateGetter(getter: (traitName: string) => string | undefined): void;
418
422
 
419
- export { type MultiSourceSlotManager, PERF_NAMESPACE, type PerfDetail, type PerfDetailValue, type PerfEntry, type PreparedPreviewSchema, RendererContractViolationError, type ResolvedPageTraits, type SlotContent, type SlotContentValidationError, type SlotManager, type SlotSource, type VerificationBus, adjustSchemaForMockData, aggregateSlotContent, assertIsMultiSourceSlotManager, assertIsSlotManager, bindEventBus, bindTraitStateGetter, buildMockData, buildOrbitalsByTrait, clearPerf, collectEmbeddedTraits, collectTraitRefsFromResolvedTrait, createSlotSetter, ensureVerificationApi, getOrbitalVerification, perfEnd, perfStart, perfStore, perfTime, prepareSchemaForPreview, pushPerfEntry, validateSlotContent, wrapCallbackForEvent };
423
+ export { type MultiSourceSlotManager, PERF_NAMESPACE, type PerfDetail, type PerfDetailValue, type PerfEntry, type PreparedPreviewSchema, RendererContractViolationError, type ResolvedPageTraits, type SlotContent, type SlotContentValidationError, type SlotManager, type SlotSource, type VerificationBus, adjustSchemaForMockData, aggregateSlotContent, assertIsMultiSourceSlotManager, assertIsSlotManager, bindEventBus, bindTraitStateGetter, buildMockData, buildOrbitalsByTrait, clearPerf, collectEmbeddedTraits, collectTraitRefsFromResolvedTrait, createSlotSetter, ensureVerificationApi, getOrbitalVerification, perfEnd, perfGauge, perfStart, perfStore, perfTime, perfTimeAsync, prepareSchemaForPreview, pushPerfEntry, validateSlotContent, wrapCallbackForEvent };
package/dist/ui/index.js CHANGED
@@ -1,3 +1,3 @@
1
- export { PERF_NAMESPACE, RendererContractViolationError, adjustSchemaForMockData, aggregateSlotContent, assertIsMultiSourceSlotManager, assertIsSlotManager, bindEventBus, bindTraitStateGetter, buildMockData, buildOrbitalsByTrait, clearPerf, createSlotSetter, ensureVerificationApi, getOrbitalVerification, perfEnd, perfStart, perfStore, perfTime, prepareSchemaForPreview, pushPerfEntry, validateSlotContent, wrapCallbackForEvent } from '../chunk-FOFLEZRJ.js';
1
+ export { PERF_NAMESPACE, RendererContractViolationError, adjustSchemaForMockData, aggregateSlotContent, assertIsMultiSourceSlotManager, assertIsSlotManager, bindEventBus, bindTraitStateGetter, buildMockData, buildOrbitalsByTrait, clearPerf, createSlotSetter, ensureVerificationApi, getOrbitalVerification, perfEnd, perfGauge, perfStart, perfStore, perfTime, perfTimeAsync, prepareSchemaForPreview, pushPerfEntry, validateSlotContent, wrapCallbackForEvent } from '../chunk-F5W3YZGJ.js';
2
2
  export { collectEmbeddedTraits, collectTraitRefsFromResolvedTrait } from '../chunk-SCRAHWOC.js';
3
3
  import '../chunk-MLKGABMK.js';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@almadar/runtime",
3
- "version": "6.59.0",
3
+ "version": "6.61.0",
4
4
  "description": "Interpreted runtime for Almadar orbital applications (OrbitalServerRuntime)",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -57,11 +57,11 @@
57
57
  "access": "public"
58
58
  },
59
59
  "dependencies": {
60
- "@almadar/core": "^10.68.0",
61
- "@almadar/evaluator": "^2.41.0",
60
+ "@almadar/core": "^10.70.0",
61
+ "@almadar/evaluator": "^2.42.0",
62
62
  "@almadar/logger": "^1.11.0",
63
- "@almadar/server": "^2.37.0",
64
- "@almadar/std": "^16.184.0"
63
+ "@almadar/server": "^2.38.0",
64
+ "@almadar/std": "^16.186.0"
65
65
  },
66
66
  "peerDependencies": {
67
67
  "express": "^5.0.0"