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:
12
AGENTS.md
12
AGENTS.md
@@ -60,7 +60,7 @@ The plugin auto-injects `workdir` for bash commands when the session is mapped t
|
||||
|
||||
## Project: @alkdev/pubsub
|
||||
|
||||
Type-safe publish/subscribe with pluggable event target adapters (in-process, Redis, WebSocket, Iroh). Core is adapted from graphql-yoga (MIT). Dual-licensed MIT / Apache-2.0.
|
||||
Type-safe publish/subscribe with pluggable event target adapters (in-process, Redis, WebSocket, Worker, Iroh). Transport layer only — no call protocol or coordination semantics. Core is adapted from graphql-yoga (MIT). Dual-licensed MIT / Apache-2.0.
|
||||
|
||||
### Commands
|
||||
|
||||
@@ -74,9 +74,11 @@ Type-safe publish/subscribe with pluggable event target adapters (in-process, Re
|
||||
|
||||
See `docs/architecture/` for full spec. Key points:
|
||||
|
||||
- **EventEnvelope**: Every event is `{ type, id, payload }`. This is the cross-platform serialization contract.
|
||||
- **Barrel + sub-path exports**: `src/index.ts` re-exports core + operators. Each adapter has its own sub-path entry (`@alkdev/pubsub/event-target-redis`, etc.).
|
||||
- **Peer dep isolation**: Redis and Iroh adapters are optional peer deps. Consumers only install the ones they need.
|
||||
- **TypedEventTarget contract**: All adapters implement the same `addEventListener`/`dispatchEvent`/`removeEventListener` interface. `createPubSub` is transport-agnostic.
|
||||
- **Transport only**: No call protocol, no PendingRequestMap, no coordination. Those belong in `@alkdev/operations`.
|
||||
- **No comments in source**: Do not add comments to code unless explicitly asked.
|
||||
- **License headers**: Files adapted from graphql-yoga must preserve their MIT attribution headers.
|
||||
|
||||
@@ -85,18 +87,22 @@ See `docs/architecture/` for full spec. Key points:
|
||||
```
|
||||
src/
|
||||
index.ts — Barrel: re-exports core API + operators
|
||||
types.ts — TypedEvent, TypedEventTarget, etc. (adapted from graphql-yoga)
|
||||
types.ts — TypedEvent, TypedEventTarget, EventEnvelope (adapted from graphql-yoga)
|
||||
create_pubsub.ts — createPubSub factory (adapted from graphql-yoga)
|
||||
operators.ts — filter, map, pipe (adapted from graphql-yoga)
|
||||
take, reduce, toArray, batch, dedupe, window,
|
||||
flat, groupBy, chain, join (from async-utility reference)
|
||||
repeater.ts — Inlined from @repeaterjs/repeater (MIT)
|
||||
event-target-redis.ts — createRedisEventTarget (peer dep: ioredis)
|
||||
# Future adapters:
|
||||
# event-target-websocket.ts — (peer dep: none, web standard)
|
||||
# event-target-worker.ts — (peer dep: none, web standard)
|
||||
# event-target-iroh.ts — (peer dep: @rayhanadev/iroh)
|
||||
```
|
||||
|
||||
### Dependencies
|
||||
|
||||
Runtime: `@repeaterjs/repeater` (direct, ~3KB).
|
||||
Runtime: none (Repeater is inlined, TypeBox removed).
|
||||
Peer (optional): `ioredis@^5.0.0` (Redis adapter), `@rayhanadev/iroh` (Iroh adapter, future).
|
||||
Dev: `tsup`, `typescript`, `vitest`, `@vitest/coverage-v8`, `ioredis` (for type resolution).
|
||||
|
||||
|
||||
Reference in New Issue
Block a user