Add call protocol module with streaming support

New sub-path export @alkdev/pubsub/call providing:
- CallEventSchema (TypeBox schemas) for call.requested/responded/part/completed/aborted/error
- PendingRequestMap with call() (request/response) and subscribe() (streaming via Repeater)
- CallError class and CallErrorCode constants
- Scoped topic subscriptions (call.responded:{requestId}) to avoid O(n) fanout
- subscribe() yields call.part events until call.completed or call.error,
  with automatic call.aborted on consumer break

Also adds @alkdev/typebox as runtime dependency and architecture doc.
This commit is contained in:
2026-04-30 13:46:39 +00:00
parent 9c332529df
commit 04b3464c36
6 changed files with 619 additions and 3 deletions

9
package-lock.json generated
View File

@@ -8,6 +8,9 @@
"name": "@alkdev/pubsub",
"version": "0.1.0",
"license": "MIT OR Apache-2.0",
"dependencies": {
"@alkdev/typebox": "^0.34.49"
},
"devDependencies": {
"@types/node": "^22.0.0",
"@vitest/coverage-v8": "^3.2.4",
@@ -28,6 +31,12 @@
}
}
},
"node_modules/@alkdev/typebox": {
"version": "0.34.49",
"resolved": "https://registry.npmjs.org/@alkdev/typebox/-/typebox-0.34.49.tgz",
"integrity": "sha512-hMidpI6GlMgQMlW9KEd8I3ywgewV6mva9iJaDuBfGtgeRAGrB8yyu6T/fHmgmyQineZ8l4/1PdH/VNr3S2er2g==",
"license": "MIT"
},
"node_modules/@ampproject/remapping": {
"version": "2.3.0",
"resolved": "https://registry.npmjs.org/@ampproject/remapping/-/remapping-2.3.0.tgz",