@almadar/runtime 6.61.0 → 6.62.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
- 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';
1
+ import { createTickScheduler, EventBus, createUnifiedLoader, MockPersistenceAdapter, InMemoryPersistence, preprocessSchema, normalizeCallSiteConfigToValues, StateMachineManager, parseDurationString, validateEventPayload, formatPayloadValidationError, collectDeclaredConfigDefaults, collectDeclaredEntityDefaults, EffectExecutor } from './chunk-MEBKFZC4.js';
2
+ export { InMemoryPersistence, collectDeclaredConfigDefaults } from './chunk-MEBKFZC4.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';
@@ -1613,8 +1613,9 @@ var OrbitalServerRuntime = class {
1613
1613
  const readPolicy = this.resolvedSchema ? entityAccessPolicies(this.resolvedSchema, fetchEntityType)?.read : void 0;
1614
1614
  const accessBindings = { user: bindingsRef?.user, payload: bindingsRef?.payload, config: bindingsRef?.config };
1615
1615
  if (options?.id) {
1616
- const entity = await this.persistence.getById(fetchEntityType, options.id);
1617
- if (entity && applyRowAccess([entity], readPolicy, void 0, accessBindings).length > 0) {
1616
+ const stored = await this.persistence.getById(fetchEntityType, options.id);
1617
+ if (stored && applyRowAccess([stored], readPolicy, void 0, accessBindings).length > 0) {
1618
+ const entity = { ...stored };
1618
1619
  if (options?.include && options.include.length > 0) {
1619
1620
  await this.populateRelations([entity], fetchEntityType, options.include);
1620
1621
  }
@@ -1638,6 +1639,7 @@ var OrbitalServerRuntime = class {
1638
1639
  entities = entities.slice(0, options.limit);
1639
1640
  }
1640
1641
  if (options?.include && options.include.length > 0) {
1642
+ entities = entities.map((row) => ({ ...row }));
1641
1643
  await this.populateRelations(entities, fetchEntityType, options.include);
1642
1644
  }
1643
1645
  fetchedData[fetchEntityType] = entities;
@@ -3448,16 +3448,50 @@ function renameEventsInRenderUiConfig(node, rename) {
3448
3448
  return next;
3449
3449
  }
3450
3450
  function renameEventsInEffects(effects, rename) {
3451
- return effects.map((effect) => {
3452
- if (!Array.isArray(effect)) return effect;
3453
- if (effect[0] === "render-ui" && effect.length >= 3) {
3454
- const slot = effect[1];
3455
- const config = effect[2];
3456
- const nextConfig = renameEventsInRenderUiConfig(config, rename);
3457
- return [effect[0], slot, nextConfig, ...effect.slice(3)];
3458
- }
3459
- return effect;
3460
- });
3451
+ return effects.map((effect) => renameEventRefsInNode(effect, rename));
3452
+ }
3453
+ var EMIT_OPTION_SLOTS = /* @__PURE__ */ new Set(["success", "failure", "on_message", "on_change"]);
3454
+ function renameEventRefsInNode(node, rename) {
3455
+ if (node === null || node === void 0) return node;
3456
+ if (Array.isArray(node)) {
3457
+ if (node[0] === "render-ui" && node.length >= 3) {
3458
+ const nextConfig = renameEventsInRenderUiConfig(node[2], rename);
3459
+ return [
3460
+ node[0],
3461
+ node[1],
3462
+ nextConfig,
3463
+ ...node.slice(3).map((x) => renameEventRefsInNode(x, rename))
3464
+ ];
3465
+ }
3466
+ const out = node.map((x) => renameEventRefsInNode(x, rename));
3467
+ if (node[0] === "emit" && typeof node[1] === "string") {
3468
+ out[1] = rename(node[1]) ?? node[1];
3469
+ }
3470
+ return out;
3471
+ }
3472
+ if (typeof node === "object") {
3473
+ const obj = node;
3474
+ const next = {};
3475
+ for (const [k, v] of Object.entries(obj)) {
3476
+ if (k === "emit") {
3477
+ if (typeof v === "string") {
3478
+ next[k] = rename(v) ?? v;
3479
+ } else if (v !== null && typeof v === "object" && !Array.isArray(v)) {
3480
+ const slots = {};
3481
+ for (const [slot, slotV] of Object.entries(v)) {
3482
+ slots[slot] = EMIT_OPTION_SLOTS.has(slot) && typeof slotV === "string" ? rename(slotV) ?? slotV : renameEventRefsInNode(slotV, rename);
3483
+ }
3484
+ next[k] = slots;
3485
+ } else {
3486
+ next[k] = renameEventRefsInNode(v, rename);
3487
+ }
3488
+ continue;
3489
+ }
3490
+ next[k] = renameEventRefsInNode(v, rename);
3491
+ }
3492
+ return next;
3493
+ }
3494
+ return node;
3461
3495
  }
3462
3496
  var REBIND_ENTITY_PROPS = /* @__PURE__ */ new Set(["entity"]);
3463
3497
  var ID_ENTITY_PROPS = /* @__PURE__ */ new Set(["entity", "entityType", "source"]);
@@ -3751,13 +3785,12 @@ function applyEventRenames(trait, renames) {
3751
3785
  if (!renames || Object.keys(renames).length === 0) return trait;
3752
3786
  const rename = (k) => k !== void 0 && k in renames ? renames[k] : k;
3753
3787
  const sm = trait.stateMachine;
3754
- if (!sm) return trait;
3755
- const nextTransitions = (sm.transitions ?? []).map((t) => {
3788
+ const nextTransitions = (sm?.transitions ?? []).map((t) => {
3756
3789
  const nextEvent = rename(t.event) ?? t.event;
3757
3790
  const nextEffects = t.effects ? renameEventsInEffects(t.effects, rename) : t.effects;
3758
3791
  return { ...t, event: nextEvent, effects: nextEffects };
3759
3792
  });
3760
- const nextEvents = (sm.events ?? []).map((e) => {
3793
+ const nextEvents = (sm?.events ?? []).map((e) => {
3761
3794
  const newKey = rename(e.key);
3762
3795
  if (newKey === e.key) return e;
3763
3796
  return { ...e, key: newKey ?? e.key };
@@ -3767,13 +3800,30 @@ function applyEventRenames(trait, renames) {
3767
3800
  const newEvent = rename(em.event);
3768
3801
  return newEvent === em.event ? em : { ...em, event: newEvent ?? em.event };
3769
3802
  });
3803
+ const nextTicks = (trait.ticks ?? []).map(
3804
+ (tk) => tk.effects ? {
3805
+ ...tk,
3806
+ effects: renameEventsInEffects(
3807
+ tk.effects,
3808
+ rename
3809
+ )
3810
+ } : tk
3811
+ );
3812
+ const nextListens = (trait.listens ?? []).map((l) => {
3813
+ const sourced = l.source !== void 0 && l.source.kind !== "any";
3814
+ const nextEvent = sourced ? l.event : rename(l.event) ?? l.event;
3815
+ const nextTriggers = rename(l.triggers) ?? l.triggers;
3816
+ return nextEvent === l.event && nextTriggers === l.triggers ? l : { ...l, event: nextEvent, triggers: nextTriggers };
3817
+ });
3770
3818
  return {
3771
3819
  ...trait,
3772
- stateMachine: {
3820
+ stateMachine: sm ? {
3773
3821
  ...sm,
3774
3822
  transitions: nextTransitions,
3775
3823
  events: nextEvents
3776
- },
3824
+ } : sm,
3825
+ ...trait.ticks ? { ticks: nextTicks } : {},
3826
+ ...trait.listens ? { listens: nextListens } : {},
3777
3827
  emits: nextEmits
3778
3828
  };
3779
3829
  }
package/dist/index.js CHANGED
@@ -1,5 +1,5 @@
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';
1
+ import { EffectExecutor } from './chunk-MEBKFZC4.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-MEBKFZC4.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';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@almadar/runtime",
3
- "version": "6.61.0",
3
+ "version": "6.62.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.70.0",
60
+ "@almadar/core": "^10.71.0",
61
61
  "@almadar/evaluator": "^2.42.0",
62
62
  "@almadar/logger": "^1.11.0",
63
63
  "@almadar/server": "^2.38.0",
64
- "@almadar/std": "^16.186.0"
64
+ "@almadar/std": "^16.190.0"
65
65
  },
66
66
  "peerDependencies": {
67
67
  "express": "^5.0.0"
@@ -72,7 +72,7 @@
72
72
  }
73
73
  },
74
74
  "devDependencies": {
75
- "@almadar/eslint-plugin": "^2.15.0",
75
+ "@almadar/eslint-plugin": "^2.16.0",
76
76
  "@types/express": "^5.0.0",
77
77
  "@types/node": "^20.0.0",
78
78
  "@typescript-eslint/parser": "8.65.0",