@almadar/runtime 6.57.0 → 6.58.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-D20NPs1X.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-TwQ8Dybu.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
  /**
@@ -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-CgDV0DwN.js';
3
- import './types-D20NPs1X.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-Dn9dIwJk.js';
3
+ import './types-TwQ8Dybu.js';
4
4
  import '@almadar/core';
@@ -1522,7 +1522,8 @@ var OrbitalServerRuntime = class {
1522
1522
  result = await this.config.effectHandlers.callService(
1523
1523
  service,
1524
1524
  action,
1525
- params
1525
+ params,
1526
+ user ? { principal: user.id, role: user.role } : void 0
1526
1527
  );
1527
1528
  } else if (this.config.mode === "mock") {
1528
1529
  const mockId = `mock_${service}_${action}_${Math.random().toString(36).slice(2, 10)}`;
@@ -1,4 +1,4 @@
1
- import { I as IEventBus } from './types-D20NPs1X.js';
1
+ import { I as IEventBus } from './types-TwQ8Dybu.js';
2
2
  import { EventPayload } from '@almadar/core';
3
3
 
4
4
  /**
@@ -1,4 +1,4 @@
1
- import { E as EffectHandlers } from './types-D20NPs1X.js';
1
+ import { E as EffectHandlers } from './types-TwQ8Dybu.js';
2
2
  import { EventPayload } from '@almadar/core';
3
3
 
4
4
  /**
package/dist/index.d.ts CHANGED
@@ -1,7 +1,7 @@
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, T as TraitDefinition } from './types-D20NPs1X.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-D20NPs1X.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-CgDV0DwN.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-CgDV0DwN.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-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-Dn9dIwJk.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-Dn9dIwJk.js';
5
5
  import { EvaluationContext, SExpressionEvaluator } from '@almadar/evaluator';
6
6
  export { EvaluationContext, createMinimalContext } from '@almadar/evaluator';
7
7
  import { RenderBindingMarker, SExpr, TraitConfigObject, EventPayload, PatternConfig, EntityId, EntityField, EntityRow, EntityPersistence, ServiceParams, EntityAccessPolicies, PayloadField, OrbitalDefinition, OrbitalSchema } from '@almadar/core';
@@ -803,7 +803,7 @@ interface CreateServerEffectHandlersOptions {
803
803
  trait?: string;
804
804
  };
805
805
  /** Consumer-supplied `call-service` handler. When absent, calls warn and return null. */
806
- callService?: (service: string, action: string, params?: ServiceParams) => Promise<EventPayload | null>;
806
+ callService?: (service: string, action: string, params?: ServiceParams, context?: ServiceCallContext) => Promise<EventPayload | null>;
807
807
  /**
808
808
  * The declared `@read`/`@create`/`@update`/`@delete` directives, keyed by
809
809
  * entity name. Build it with `entityAccessTable(schema)` from `@almadar/core`.
package/dist/index.js CHANGED
@@ -435,7 +435,13 @@ function createServerEffectHandlers(opts) {
435
435
  try {
436
436
  let result = null;
437
437
  if (consumerCallService) {
438
- result = await consumerCallService(service, action, params);
438
+ const viewer = bindings?.user;
439
+ result = await consumerCallService(
440
+ service,
441
+ action,
442
+ params,
443
+ viewer ? { principal: viewer.id, role: viewer.role } : void 0
444
+ );
439
445
  } else {
440
446
  const mockId = `mock_${service}_${action}_${Math.random().toString(36).slice(2, 10)}`;
441
447
  const paramsEcho = {};
@@ -121,6 +121,16 @@ interface TraitDefinition {
121
121
  * Client: React hooks, DOM, router
122
122
  * Server: Express, database, integrators
123
123
  */
124
+ /**
125
+ * Caller identity forwarded with a call-service dispatch (I-25) — the id and
126
+ * roster role of the SAME normalized viewer entity ACL enforces against.
127
+ * Absent when no viewer is bound (ticks, anonymous); role-gated services
128
+ * fail closed on absence.
129
+ */
130
+ interface ServiceCallContext {
131
+ principal?: string;
132
+ role?: string;
133
+ }
124
134
  interface EffectHandlers {
125
135
  /**
126
136
  * Emit an event to the event bus.
@@ -143,8 +153,10 @@ interface EffectHandlers {
143
153
  persist: (action: 'create' | 'update' | 'delete' | 'batch', entityType: string, data?: EntityRow) => Promise<void>;
144
154
  /** Set a field value on an entity */
145
155
  set: (entityId: string, field: string, value: FieldValue) => void;
146
- /** Call an external service */
147
- callService: (service: string, action: string, params?: ServiceParams) => Promise<EventPayload | null>;
156
+ /** Call an external service. `context` carries the caller's identity
157
+ * (the same viewer entity ACL enforces against) so role-gated services
158
+ * can enforce server-side; hosts forward it to the integration factory. */
159
+ callService: (service: string, action: string, params?: ServiceParams, context?: ServiceCallContext) => Promise<EventPayload | null>;
148
160
  /** Fetch entity data (server only) - returns data for client-side rendering.
149
161
  *
150
162
  * Always returns a `FetchResult` (`{rows, total}`) on success. `total`
@@ -489,4 +501,4 @@ interface TransitionObserver {
489
501
  */
490
502
  declare const HANDLER_MANIFEST: Record<ExecutionEnvironment, string[]>;
491
503
 
492
- export { type BindingContext as B, type ConfigContext as C, type EffectHandlers as E, HANDLER_MANIFEST as H, type IEventBus as I, type PatternProps as P, type RuntimeEvent as R, type TraitDefinition as T, type Unsubscribe as U, type EventListener as a, type RuntimeConfig as b, type TransitionObserver as c, type TraitState as d, type TransitionResult as e, type EvaluationContextExtensions as f, type RuntimePatternValue as g, type EffectContext as h, type ExecutionEnvironment as i, type EffectResult as j, type BrowserFileMeta as k, type BrowserFilePickerOptions as l, type BrowserGeolocationOptions as m, type BrowserGeolocationPosition as n, type Effect as o };
504
+ export { type BindingContext as B, type ConfigContext as C, type EffectHandlers as E, HANDLER_MANIFEST as H, type IEventBus as I, type PatternProps as P, type RuntimeEvent as R, type ServiceCallContext as S, type TraitDefinition as T, type Unsubscribe as U, type EventListener as a, type RuntimeConfig as b, type TransitionObserver as c, type TraitState as d, type TransitionResult as e, type EvaluationContextExtensions as f, type RuntimePatternValue as g, type EffectContext as h, type ExecutionEnvironment as i, type EffectResult as j, type BrowserFileMeta as k, type BrowserFilePickerOptions as l, type BrowserGeolocationOptions as m, type BrowserGeolocationPosition as n, type Effect as o };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@almadar/runtime",
3
- "version": "6.57.0",
3
+ "version": "6.58.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.66.0",
60
+ "@almadar/core": "^10.67.0",
61
61
  "@almadar/evaluator": "^2.41.0",
62
62
  "@almadar/logger": "^1.11.0",
63
- "@almadar/server": "^2.36.0",
64
- "@almadar/std": "^16.182.0"
63
+ "@almadar/server": "^2.37.0",
64
+ "@almadar/std": "^16.183.0"
65
65
  },
66
66
  "peerDependencies": {
67
67
  "express": "^5.0.0"