@almadar/runtime 6.12.0 → 6.14.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.
- package/dist/{OrbitalServerRuntime-D4UFgl5l.d.ts → OrbitalServerRuntime-Cg1CiUdz.d.ts} +18 -3
- package/dist/OrbitalServerRuntime.d.ts +2 -2
- package/dist/OrbitalServerRuntime.js +19 -15
- package/dist/OrbitalServerRuntime.js.map +1 -1
- package/dist/ServerBridge.d.ts +1 -1
- package/dist/{chunk-QJ4UEHGC.js → chunk-QVGSVPYW.js} +44 -6
- package/dist/chunk-QVGSVPYW.js.map +1 -0
- package/dist/createOsHandlers.d.ts +1 -1
- package/dist/index.d.ts +4 -4
- package/dist/index.js +2 -2
- package/dist/{types-ymgqmXOq.d.ts → types-GFwSbdv_.d.ts} +8 -0
- package/package.json +1 -1
- package/dist/chunk-QJ4UEHGC.js.map +0 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Router } from 'express';
|
|
2
|
-
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-
|
|
2
|
+
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-GFwSbdv_.js';
|
|
3
3
|
import { EventPayload, EntityRow, DeclaredTraitConfig, TraitConfig, OrbitalSchema, Orbital, Trait, PatternConfig, ResolvedPatternProps, SExpr, BusEventSource, OrbitalDefinition, Entity, TraitTick } from '@almadar/core';
|
|
4
4
|
import { P as PersistenceAdapter } from './PersistenceAdapter-B6dQCbbU.js';
|
|
5
5
|
|
|
@@ -1104,8 +1104,23 @@ declare class OrbitalServerRuntime {
|
|
|
1104
1104
|
resetMockPersistence(): void;
|
|
1105
1105
|
/**
|
|
1106
1106
|
* Process an event for an orbital
|
|
1107
|
-
|
|
1108
|
-
|
|
1107
|
+
*
|
|
1108
|
+
* @param onPush - Optional incremental-push callback. Called immediately
|
|
1109
|
+
* when an event is emitted or a client effect fires, before the promise
|
|
1110
|
+
* resolves. Used by the SSE streaming path to write items to the
|
|
1111
|
+
* response as they arrive rather than buffering and flushing at the end.
|
|
1112
|
+
*/
|
|
1113
|
+
processOrbitalEvent(orbitalName: string, request: OrbitalEventRequest, onPush?: (item: {
|
|
1114
|
+
type: 'event';
|
|
1115
|
+
data: {
|
|
1116
|
+
event: string;
|
|
1117
|
+
payload?: EventPayload;
|
|
1118
|
+
source?: BusEventSource;
|
|
1119
|
+
};
|
|
1120
|
+
} | {
|
|
1121
|
+
type: 'effect';
|
|
1122
|
+
data: ClientEffectTuple;
|
|
1123
|
+
}) => void): Promise<OrbitalEventResponse>;
|
|
1109
1124
|
/**
|
|
1110
1125
|
* Execute effects from a transition
|
|
1111
1126
|
*/
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import 'express';
|
|
2
|
-
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-
|
|
3
|
-
import './types-
|
|
2
|
+
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-Cg1CiUdz.js';
|
|
3
|
+
import './types-GFwSbdv_.js';
|
|
4
4
|
import '@almadar/core';
|
|
5
5
|
export { I as InMemoryPersistence, P as PersistenceAdapter } from './PersistenceAdapter-B6dQCbbU.js';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { EventBus, createUnifiedLoader, MockPersistenceAdapter, InMemoryPersistence, preprocessSchema, StateMachineManager, createContextFromBindings, validateEventPayload, formatPayloadValidationError, collectDeclaredConfigDefaults, EffectExecutor } from './chunk-
|
|
2
|
-
export { InMemoryPersistence, collectDeclaredConfigDefaults } from './chunk-
|
|
1
|
+
import { EventBus, createUnifiedLoader, MockPersistenceAdapter, InMemoryPersistence, preprocessSchema, StateMachineManager, createContextFromBindings, validateEventPayload, formatPayloadValidationError, collectDeclaredConfigDefaults, EffectExecutor } from './chunk-QVGSVPYW.js';
|
|
2
|
+
export { InMemoryPersistence, collectDeclaredConfigDefaults } from './chunk-QVGSVPYW.js';
|
|
3
3
|
import './chunk-PZ5AY32C.js';
|
|
4
4
|
import { createLogger } from '@almadar/logger';
|
|
5
5
|
import * as nodeModule from 'module';
|
|
@@ -789,8 +789,13 @@ var OrbitalServerRuntime = class {
|
|
|
789
789
|
// ==========================================================================
|
|
790
790
|
/**
|
|
791
791
|
* Process an event for an orbital
|
|
792
|
+
*
|
|
793
|
+
* @param onPush - Optional incremental-push callback. Called immediately
|
|
794
|
+
* when an event is emitted or a client effect fires, before the promise
|
|
795
|
+
* resolves. Used by the SSE streaming path to write items to the
|
|
796
|
+
* response as they arrive rather than buffering and flushing at the end.
|
|
792
797
|
*/
|
|
793
|
-
async processOrbitalEvent(orbitalName, request) {
|
|
798
|
+
async processOrbitalEvent(orbitalName, request, onPush) {
|
|
794
799
|
await this.ensureOsHandlers();
|
|
795
800
|
const registered = this.orbitals.get(orbitalName);
|
|
796
801
|
if (!registered) {
|
|
@@ -905,7 +910,8 @@ var OrbitalServerRuntime = class {
|
|
|
905
910
|
clientEffects,
|
|
906
911
|
effectResults,
|
|
907
912
|
user,
|
|
908
|
-
clientEffectsByTrait
|
|
913
|
+
clientEffectsByTrait,
|
|
914
|
+
onPush
|
|
909
915
|
);
|
|
910
916
|
}
|
|
911
917
|
}
|
|
@@ -933,11 +939,12 @@ var OrbitalServerRuntime = class {
|
|
|
933
939
|
/**
|
|
934
940
|
* Execute effects from a transition
|
|
935
941
|
*/
|
|
936
|
-
async executeEffects(registered, traitName, effects, payload, entityData, entityId, emittedEvents, fetchedData, clientEffects, effectResults, user, clientEffectsByTrait) {
|
|
942
|
+
async executeEffects(registered, traitName, effects, payload, entityData, entityId, emittedEvents, fetchedData, clientEffects, effectResults, user, clientEffectsByTrait, onPush) {
|
|
937
943
|
const entityType = registered.entity.name;
|
|
938
944
|
const pushClientEffect = (effect) => {
|
|
939
945
|
clientEffects.push(effect);
|
|
940
946
|
clientEffectsByTrait?.push({ traitName, effect });
|
|
947
|
+
onPush?.({ type: "effect", data: effect });
|
|
941
948
|
};
|
|
942
949
|
let bindingsRef = null;
|
|
943
950
|
let contextRef = null;
|
|
@@ -956,7 +963,9 @@ var OrbitalServerRuntime = class {
|
|
|
956
963
|
trait: traitName
|
|
957
964
|
};
|
|
958
965
|
this.eventBus.emit(event, eventPayload, stamp);
|
|
959
|
-
|
|
966
|
+
const emittedItem = { event, payload: eventPayload, source: stamp };
|
|
967
|
+
emittedEvents.push(emittedItem);
|
|
968
|
+
onPush?.({ type: "event", data: emittedItem });
|
|
960
969
|
effectLog.debug("emit:push", {
|
|
961
970
|
event,
|
|
962
971
|
cumulativeEmittedCount: emittedEvents.length,
|
|
@@ -1771,15 +1780,10 @@ var OrbitalServerRuntime = class {
|
|
|
1771
1780
|
...firebaseUser,
|
|
1772
1781
|
displayName: firebaseUser.name ?? firebaseUser.displayName
|
|
1773
1782
|
} : void 0;
|
|
1774
|
-
const result = await this.processOrbitalEvent(orbitalName, { ...req.body, user })
|
|
1775
|
-
|
|
1776
|
-
|
|
1777
|
-
|
|
1778
|
-
}
|
|
1779
|
-
for (const effect of result.clientEffects ?? []) {
|
|
1780
|
-
sendSSEEvent(res, { type: "effect", data: effect, timestamp: ts });
|
|
1781
|
-
}
|
|
1782
|
-
sendSSEEvent(res, { type: "complete", data: result, timestamp: ts });
|
|
1783
|
+
const result = await this.processOrbitalEvent(orbitalName, { ...req.body, user }, (item) => {
|
|
1784
|
+
sendSSEEvent(res, { type: item.type, data: item.data, timestamp: Date.now() });
|
|
1785
|
+
});
|
|
1786
|
+
sendSSEEvent(res, { type: "complete", data: result, timestamp: Date.now() });
|
|
1783
1787
|
sendSSEDone(res);
|
|
1784
1788
|
closeSSE(res);
|
|
1785
1789
|
} catch (error) {
|