Changelog
All notable changes to PubSubJS packages are documented here. This project uses Changesets for versioning.
@pubsubjs/core
0.4.0
Minor Changes
on() now returns an UnsubscribeFn to remove a specific handler (breaking: was this)off() now returns void and tears down the transport subscription (breaking: was this)onMany() now returns an UnsubscribeFn to remove all registered handlers (breaking: was this)on() optionssubscribe() auto-subscribe to the transport0.3.0
Minor Changes
unknown.
onUpgrade type fix
The onUpgrade callback in WebSocketServerTransport now correctly accepts Record instead of requiring the full WebSocketData type. This matches the actual runtime behavior where connectionId and subscriptions are generated internally.
// Before (required type assertion)
const transport = new WebSocketServerTransport({
onUpgrade: (req) => ({ userId: "123" } as WebSocketData),
});
// After (no assertion needed)
const transport = new WebSocketServerTransport({
onUpgrade: (req) => ({ userId: "123" }),
});
Typed transport events
Transport events now have properly typed handlers viaTransportEventMap:
// Event data is now typed
transport.on("connect", ({ connectionId }) => {
console.log(connectionId); // string | undefined
});
transport.on("error", ({ error }) => {
console.error(error); // Error | undefined
});
0.2.1
Patch Changes
0.2.0
Minor Changes
FilterPolicy type with operators: $in, $exists, $prefix, $ne, $gt, $gte, $lt, $lte, $betweenEventAttributes type for attaching filterable attributes to eventsmatchesFilter() function for evaluating filter policiestoSNSFilterPolicy() for AWS SNS compatibilityPublishOptions to accept attributesSubscriber.on() to accept filter option"user.role")0.1.2
Patch Changes
0.1.1
Patch Changes
@pubsubjs/transport-websocket
0.4.0
Patch Changes
0.3.0
Patch Changes
unknown.
onUpgrade type fix
The onUpgrade callback in WebSocketServerTransport now correctly accepts Record instead of requiring the full WebSocketData type. This matches the actual runtime behavior where connectionId and subscriptions are generated internally.
// Before (required type assertion)
const transport = new WebSocketServerTransport({
onUpgrade: (req) => ({ userId: "123" } as WebSocketData),
});
// After (no assertion needed)
const transport = new WebSocketServerTransport({
onUpgrade: (req) => ({ userId: "123" }),
});
Typed transport events
Transport events now have properly typed handlers viaTransportEventMap:
// Event data is now typed
transport.on("connect", ({ connectionId }) => {
console.log(connectionId); // string | undefined
});
transport.on("error", ({ error }) => {
console.error(error); // Error | undefined
});
0.2.1
Patch Changes
0.2.0
Minor Changes
FilterPolicy type with operators: $in, $exists, $prefix, $ne, $gt, $gte, $lt, $lte, $betweenEventAttributes type for attaching filterable attributes to eventsmatchesFilter() function for evaluating filter policiestoSNSFilterPolicy() for AWS SNS compatibilityPublishOptions to accept attributesSubscriber.on() to accept filter option"user.role") const transport = new WebSocketServerTransport({ port: 3000 });
await transport.connect();
Composable mode (new) const transport = new WebSocketServerTransport(); // no port
await transport.connect();
Bun.serve({
fetch(req, server) {
if (req.headers.get("upgrade") === "websocket") {
return transport.handleUpgrade(req, server);
}
return new Response("Hello");
},
websocket: transport.websocketHandler,
});
New APIs:
websocketHandler - WebSocket handler for use with external Bun.serve()handleUpgrade(req, server) - Handle WebSocket upgrade requestsPatch Changes
0.1.2
Patch Changes
0.1.1
Patch Changes
@pubsubjs/transport-redis
0.4.0
Patch Changes
0.3.0
Patch Changes
0.2.1
Patch Changes
0.2.0
Minor Changes
FilterPolicy type with operators: $in, $exists, $prefix, $ne, $gt, $gte, $lt, $lte, $betweenEventAttributes type for attaching filterable attributes to eventsmatchesFilter() function for evaluating filter policiestoSNSFilterPolicy() for AWS SNS compatibilityPublishOptions to accept attributesSubscriber.on() to accept filter option"user.role")Patch Changes
0.1.2
Patch Changes
0.1.1
Patch Changes
@pubsubjs/transport-sse
0.4.0
Patch Changes
0.3.0
Patch Changes
unknown.
onUpgrade type fix
The onUpgrade callback in WebSocketServerTransport now correctly accepts Record instead of requiring the full WebSocketData type. This matches the actual runtime behavior where connectionId and subscriptions are generated internally.
// Before (required type assertion)
const transport = new WebSocketServerTransport({
onUpgrade: (req) => ({ userId: "123" } as WebSocketData),
});
// After (no assertion needed)
const transport = new WebSocketServerTransport({
onUpgrade: (req) => ({ userId: "123" }),
});
Typed transport events
Transport events now have properly typed handlers viaTransportEventMap:
// Event data is now typed
transport.on("connect", ({ connectionId }) => {
console.log(connectionId); // string | undefined
});
transport.on("error", ({ error }) => {
console.error(error); // Error | undefined
});
0.2.1
Patch Changes
0.2.0
Minor Changes
FilterPolicy type with operators: $in, $exists, $prefix, $ne, $gt, $gte, $lt, $lte, $betweenEventAttributes type for attaching filterable attributes to eventsmatchesFilter() function for evaluating filter policiestoSNSFilterPolicy() for AWS SNS compatibilityPublishOptions to accept attributesSubscriber.on() to accept filter option"user.role")