@almadar/runtime 6.9.5 → 6.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.
- package/dist/{OrbitalServerRuntime-CpKcmAUY.d.ts → OrbitalServerRuntime-D4aKILQZ.d.ts} +1 -1
- package/dist/OrbitalServerRuntime.d.ts +2 -2
- package/dist/OrbitalServerRuntime.js +35 -8
- package/dist/OrbitalServerRuntime.js.map +1 -1
- package/dist/ServerBridge.d.ts +1 -1
- package/dist/{chunk-R6Y4IJ7I.js → chunk-JVSO6C6L.js} +28 -3
- package/dist/chunk-JVSO6C6L.js.map +1 -0
- package/dist/createOsHandlers.d.ts +1 -1
- package/dist/index.d.ts +4 -4
- package/dist/index.js +18 -2
- package/dist/index.js.map +1 -1
- package/dist/{types-cuy5gd29.d.ts → types-B-7blJ5k.d.ts} +10 -0
- package/package.json +3 -1
- package/dist/chunk-R6Y4IJ7I.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-B-7blJ5k.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
|
|
|
@@ -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-D4aKILQZ.js';
|
|
3
|
+
import './types-B-7blJ5k.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-JVSO6C6L.js';
|
|
2
|
+
export { InMemoryPersistence, collectDeclaredConfigDefaults } from './chunk-JVSO6C6L.js';
|
|
3
3
|
import './chunk-PZ5AY32C.js';
|
|
4
4
|
import { createLogger } from '@almadar/logger';
|
|
5
5
|
import * as nodeModule from 'module';
|
|
@@ -1746,6 +1746,24 @@ var OrbitalServerRuntime = class {
|
|
|
1746
1746
|
router.post(
|
|
1747
1747
|
"/:orbital/events",
|
|
1748
1748
|
async (req, res, next) => {
|
|
1749
|
+
const wantsStream = req.query["stream"] === "true" || (req.headers["accept"] ?? "").includes("text/event-stream");
|
|
1750
|
+
if (!wantsStream) {
|
|
1751
|
+
try {
|
|
1752
|
+
const orbitalName = req.params.orbital;
|
|
1753
|
+
const firebaseUser = req.firebaseUser;
|
|
1754
|
+
const user = firebaseUser ? {
|
|
1755
|
+
...firebaseUser,
|
|
1756
|
+
displayName: firebaseUser.name ?? firebaseUser.displayName
|
|
1757
|
+
} : void 0;
|
|
1758
|
+
const result = await this.processOrbitalEvent(orbitalName, { ...req.body, user });
|
|
1759
|
+
res.json(result);
|
|
1760
|
+
} catch (error) {
|
|
1761
|
+
next(error);
|
|
1762
|
+
}
|
|
1763
|
+
return;
|
|
1764
|
+
}
|
|
1765
|
+
const { setupSSE, sendSSEEvent, sendSSEDone, closeSSE } = await import('@almadar/server');
|
|
1766
|
+
setupSSE(res);
|
|
1749
1767
|
try {
|
|
1750
1768
|
const orbitalName = req.params.orbital;
|
|
1751
1769
|
const firebaseUser = req.firebaseUser;
|
|
@@ -1753,13 +1771,22 @@ var OrbitalServerRuntime = class {
|
|
|
1753
1771
|
...firebaseUser,
|
|
1754
1772
|
displayName: firebaseUser.name ?? firebaseUser.displayName
|
|
1755
1773
|
} : void 0;
|
|
1756
|
-
const result = await this.processOrbitalEvent(orbitalName, {
|
|
1757
|
-
|
|
1758
|
-
|
|
1759
|
-
|
|
1760
|
-
|
|
1774
|
+
const result = await this.processOrbitalEvent(orbitalName, { ...req.body, user });
|
|
1775
|
+
const ts = Date.now();
|
|
1776
|
+
for (const emitted of result.emittedEvents) {
|
|
1777
|
+
sendSSEEvent(res, { type: "event", data: emitted, timestamp: ts });
|
|
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
|
+
sendSSEDone(res);
|
|
1784
|
+
closeSSE(res);
|
|
1761
1785
|
} catch (error) {
|
|
1762
|
-
|
|
1786
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
1787
|
+
sendSSEEvent(res, { type: "error", data: { message }, timestamp: Date.now() });
|
|
1788
|
+
sendSSEDone(res);
|
|
1789
|
+
closeSSE(res);
|
|
1763
1790
|
}
|
|
1764
1791
|
}
|
|
1765
1792
|
);
|