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:
@@ -1,6 +1,6 @@
|
||||
---
|
||||
status: draft
|
||||
last_updated: 2026-04-30
|
||||
last_updated: 2026-05-01
|
||||
---
|
||||
|
||||
# Build & Distribution
|
||||
@@ -9,32 +9,38 @@ Dependencies, project structure, tree-shaking, sub-path exports, and build targe
|
||||
|
||||
## Dependencies
|
||||
|
||||
No runtime dependencies. The `Repeater` class is inlined from `@repeaterjs/repeater` (MIT) — no external package required.
|
||||
|
||||
| Package | Type | Purpose |
|
||||
|---------|------|---------|
|
||||
| `@repeaterjs/repeater` | direct | Small (~3KB). Core async iterable primitive for `subscribe()`. |
|
||||
| (none) | runtime | — |
|
||||
| `ioredis` | peer (optional) | Redis client. Only imported by `event-target-redis.ts`. Type-only import at compile time. |
|
||||
| `@rayhanadev/iroh` | peer (optional, future) | Iroh NAPI-RS binding. Only imported by `event-target-iroh.ts`. |
|
||||
|
||||
No other external dependencies. No logger dependency.
|
||||
No logger dependency. No TypeBox dependency (call protocol and schemas moved to `@alkdev/operations`).
|
||||
|
||||
## Project Structure
|
||||
|
||||
```
|
||||
@alkdev/pubsub/
|
||||
src/
|
||||
index.ts # Barrel: re-exports core API
|
||||
types.ts # TypedEvent, TypedEventTarget, etc.
|
||||
create_pubsub.ts # createPubSub factory
|
||||
operators.ts # filter, map, pipe
|
||||
event-target-redis.ts # createRedisEventTarget (peer dep: ioredis)
|
||||
index.ts # Barrel: re-exports core API + operators
|
||||
types.ts # TypedEvent, TypedEventTarget, EventEnvelope
|
||||
create_pubsub.ts # createPubSub factory (adapted from graphql-yoga)
|
||||
operators.ts # filter, map, pipe, take, reduce, toArray,
|
||||
# batch, dedupe, window, flat, groupBy, chain, join
|
||||
repeater.ts # Inlined from @repeaterjs/repeater (MIT)
|
||||
event-target-redis.ts # createRedisEventTarget (peer dep: ioredis)
|
||||
# Future adapters (each is its own entry point + peer dep island):
|
||||
# event-target-websocket.ts # peer dep: none (web standard)
|
||||
# event-target-iroh.ts # peer dep: @rayhanadev/iroh
|
||||
# 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)
|
||||
test/
|
||||
create_pubsub.test.ts
|
||||
operators.test.ts
|
||||
event-target-redis.test.ts
|
||||
# event-target-websocket.test.ts
|
||||
# event-target-worker.test.ts
|
||||
# event-target-iroh.test.ts
|
||||
docs/
|
||||
architecture.md
|
||||
@@ -56,6 +62,7 @@ We use explicit sub-path exports rather than barrel-only + tree-shaking. Each ad
|
||||
".": { ... },
|
||||
"./event-target-redis": { ... },
|
||||
"./event-target-websocket": { ... },
|
||||
"./event-target-worker": { ... },
|
||||
"./event-target-iroh": { ... }
|
||||
}
|
||||
}
|
||||
@@ -86,21 +93,6 @@ Optional peer deps means `npm install @alkdev/pubsub` does NOT install ioredis o
|
||||
- **Target**: `es2022`
|
||||
- **Splitting**: enabled (tsup code splitting for shared chunks)
|
||||
|
||||
```ts
|
||||
// tsup.config.ts
|
||||
import { defineConfig } from 'tsup';
|
||||
|
||||
export default defineConfig({
|
||||
entry: ['src/index.ts', 'src/event-target-redis.ts'],
|
||||
format: ['esm', 'cjs'],
|
||||
dts: true,
|
||||
sourcemap: true,
|
||||
clean: true,
|
||||
splitting: true,
|
||||
target: 'es2022',
|
||||
});
|
||||
```
|
||||
|
||||
## Testing
|
||||
|
||||
- **Runner**: `vitest` — matches taskgraph, natural fit with tsup/Node build pipeline
|
||||
|
||||
Reference in New Issue
Block a user