Simplify to transport-only: remove call protocol, add EventEnvelope, expand stream operators

- Remove src/call.ts (PendingRequestMap, CallEventSchema, CallError) — call protocol belongs in @alkdev/operations
- Add EventEnvelope type ({ type, id, payload }) as the cross-platform serialization contract
- Simplify createPubSub: replace PubSubPublishArgsByKey tuple model with PubSubEventMap; publish(type, id, payload) and subscribe(type, id) use explicit id for topic scoping
- Update Redis adapter to serialize/deserialize full EventEnvelope
- Expand operators: add take, reduce, toArray, batch, dedupe, window, flat, groupBy, chain, join
- Remove @alkdev/typebox runtime dependency (was only used by call.ts)
- Remove ./call sub-path export from package.json and tsup config
- Update all architecture docs to reflect transport-only scope, add Worker adapter, remove call protocol references
- Remove docs/architecture/call-protocol.md
- Update AGENTS.md with new source layout and transport-only principle
This commit is contained in:
2026-05-01 19:40:25 +00:00
parent 04b3464c36
commit de7fc88f99
17 changed files with 446 additions and 764 deletions

View File

@@ -28,10 +28,11 @@
* - Uses our TypedEventTarget/TypedEvent types from types.ts
* - Removed tslib dependency
* - Uses ioredis types directly (already a dependency)
* - Serializes full EventEnvelope for cross-process transport
*/
import type { Cluster, Redis } from "ioredis";
import type { TypedEventTarget, TypedEvent } from "./types.js";
import type { TypedEventTarget, TypedEvent, EventEnvelope } from "./types.js";
export type CreateRedisEventTargetArgs = {
publishClient: Redis | Cluster;
@@ -57,8 +58,9 @@ export function createRedisEventTarget<TEvent extends TypedEvent>(
return;
}
const envelope = serializer.parse(message) as EventEnvelope;
const event = new CustomEvent(channel, {
detail: message === "" ? null : serializer.parse(message),
detail: envelope,
}) as TEvent;
for (const callback of callbacks) {
callback(event);
@@ -102,7 +104,7 @@ export function createRedisEventTarget<TEvent extends TypedEvent>(
dispatchEvent(event: TEvent) {
publishClient.publish(
event.type,
event.detail === undefined ? "" : serializer.stringify(event.detail),
serializer.stringify(event.detail),
);
return true;
},