@bymax-one/nest-realtime 1.0.3 → 1.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +32 -1
- package/dist/internal/index.cjs +2 -2
- package/dist/internal/index.d.cts +54 -4
- package/dist/internal/index.d.ts +54 -4
- package/dist/internal/index.mjs +2 -2
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -7,6 +7,36 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
7
7
|
|
|
8
8
|
## [Unreleased]
|
|
9
9
|
|
|
10
|
+
## [1.0.4] - 2026-08-02
|
|
11
|
+
|
|
12
|
+
### Fixed
|
|
13
|
+
|
|
14
|
+
- **The published declarations required `@types/express`, which the package does
|
|
15
|
+
not depend on.** `dist/internal/index.d.ts` imported `Request` and `Response`
|
|
16
|
+
from `express`, so a consumer compiling with `skipLibCheck: false` failed with
|
|
17
|
+
`TS2307: Cannot find module 'express'` on the root and `./websocket` subpaths.
|
|
18
|
+
`express` is not a dependency, nor a peer, nor an optional peer, so there was no
|
|
19
|
+
supported way to satisfy it.
|
|
20
|
+
|
|
21
|
+
The SSE endpoint reads three fields from the request — `headers`, `ip`, `query` —
|
|
22
|
+
and does two things to the response: sets the anti-buffering headers, and writes
|
|
23
|
+
the keepalive comment. Those are now described by `SseRequest` and
|
|
24
|
+
`SseResponse`, structural contracts an `express.Request` satisfies without being
|
|
25
|
+
named by it. The same shape is what a Fastify request
|
|
26
|
+
provides, so the endpoint no longer assumes a platform it never required.
|
|
27
|
+
|
|
28
|
+
Runtime is unaffected: no bundle ever imported `express`, and the only change to
|
|
29
|
+
the built JavaScript is two JSDoc lines.
|
|
30
|
+
|
|
31
|
+
### Changed
|
|
32
|
+
|
|
33
|
+
- **`pnpm check:surface` now also checks what the published declarations import.**
|
|
34
|
+
Every module a `.d.ts` names has to be a declared peer, `./internal` included —
|
|
35
|
+
the root's declarations re-export from it, so an undeclared import there reaches
|
|
36
|
+
the consumer's compiler just the same. `tsc` could not see this (it only checks
|
|
37
|
+
what this repository references) and neither could `attw` (it checks that
|
|
38
|
+
declarations resolve, not what they contain).
|
|
39
|
+
|
|
10
40
|
## [1.0.3] - 2026-08-02
|
|
11
41
|
|
|
12
42
|
### Fixed
|
|
@@ -167,7 +197,8 @@ First published release.
|
|
|
167
197
|
rather than by the manual sweep that raised the NestJS floors — that sweep
|
|
168
198
|
asked about NestJS and never put the same question to the other ten peers.
|
|
169
199
|
|
|
170
|
-
[Unreleased]: https://github.com/bymaxone/nest-realtime/compare/v1.0.
|
|
200
|
+
[Unreleased]: https://github.com/bymaxone/nest-realtime/compare/v1.0.4...HEAD
|
|
201
|
+
[1.0.4]: https://github.com/bymaxone/nest-realtime/compare/v1.0.3...v1.0.4
|
|
171
202
|
[1.0.3]: https://github.com/bymaxone/nest-realtime/compare/v1.0.2...v1.0.3
|
|
172
203
|
[1.0.2]: https://github.com/bymaxone/nest-realtime/compare/v1.0.1...v1.0.2
|
|
173
204
|
[1.0.1]: https://github.com/bymaxone/nest-realtime/compare/v1.0.0...v1.0.1
|
package/dist/internal/index.cjs
CHANGED
|
@@ -789,8 +789,8 @@ exports.SseSubscriptionHandler = class SseSubscriptionHandler {
|
|
|
789
789
|
* wires the downstream listener BEFORE calling `registerConnection` — so a plain
|
|
790
790
|
* `Subject` suffices and the replay buffer cannot grow unboundedly.
|
|
791
791
|
*
|
|
792
|
-
* @param req - The
|
|
793
|
-
* @param res - The
|
|
792
|
+
* @param req - The incoming request (SSE GET).
|
|
793
|
+
* @param res - The response (passthrough for header mutations and heartbeat writes).
|
|
794
794
|
* @returns An Observable of `MessageEvent` values for NestJS `@Sse` to stream.
|
|
795
795
|
* @throws UnauthorizedException when authentication returns null.
|
|
796
796
|
*/
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { ModuleMetadata, Type, Provider, Logger, DynamicModule, MessageEvent, OnModuleInit, OnApplicationShutdown } from '@nestjs/common';
|
|
2
2
|
import { Subject, Observable } from 'rxjs';
|
|
3
|
-
import { Request, Response } from 'express';
|
|
4
3
|
import { Redis } from 'ioredis';
|
|
5
4
|
|
|
6
5
|
/**
|
|
@@ -854,6 +853,57 @@ declare class HeartbeatService {
|
|
|
854
853
|
stopAll(): void;
|
|
855
854
|
}
|
|
856
855
|
|
|
856
|
+
/**
|
|
857
|
+
* @fileoverview The HTTP shape the SSE endpoint depends on.
|
|
858
|
+
* @layer contracts
|
|
859
|
+
*
|
|
860
|
+
* Structural on purpose, rather than `express.Request` and `express.Response`.
|
|
861
|
+
*
|
|
862
|
+
* Naming Express would make the published declarations import its types, and
|
|
863
|
+
* `@types/express` is not a dependency of this package — nor an optional peer, so
|
|
864
|
+
* a consumer compiling with `skipLibCheck: false` would have no supported way to
|
|
865
|
+
* satisfy it. It would also be the wrong type for an application on Fastify,
|
|
866
|
+
* which NestJS supports equally.
|
|
867
|
+
*
|
|
868
|
+
* The endpoint reads three fields from the request — `headers`, `ip`, `query` —
|
|
869
|
+
* and does two things to the response: sets the anti-buffering headers, and
|
|
870
|
+
* writes the keepalive comment. An `express.Request` satisfies these interfaces
|
|
871
|
+
* without being named by them, and so does a Fastify request, because
|
|
872
|
+
* assignability is structural.
|
|
873
|
+
*/
|
|
874
|
+
/** A header value as an HTTP server exposes it, before normalization. */
|
|
875
|
+
type SseHeaderValue = string | string[] | undefined;
|
|
876
|
+
/** The request fields the SSE endpoint reads. */
|
|
877
|
+
interface SseRequest {
|
|
878
|
+
/**
|
|
879
|
+
* Request headers, keyed as the HTTP framework delivers them. Node lowercases
|
|
880
|
+
* incoming header names, and the endpoint looks them up lowercase — `cookie`,
|
|
881
|
+
* `user-agent`, `x-forwarded-for` and `last-event-id` — so an adapter that
|
|
882
|
+
* preserves the client's casing has to lowercase the keys before it gets here,
|
|
883
|
+
* or those lookups miss.
|
|
884
|
+
*/
|
|
885
|
+
readonly headers: Readonly<Record<string, SseHeaderValue>>;
|
|
886
|
+
/** Remote address as the HTTP framework resolved it, when it resolves one. */
|
|
887
|
+
readonly ip?: string | undefined;
|
|
888
|
+
/** Parsed query string. Values are narrowed to strings by the caller. */
|
|
889
|
+
readonly query: Readonly<Record<string, unknown>>;
|
|
890
|
+
}
|
|
891
|
+
/**
|
|
892
|
+
* The response surface the SSE endpoint uses: anti-buffering headers, and a
|
|
893
|
+
* writable stream for the keepalive.
|
|
894
|
+
*
|
|
895
|
+
* `write` is structurally the same contract as `HeartbeatWritable`, which the
|
|
896
|
+
* heartbeat declares for itself so it can be driven by any writable in a test.
|
|
897
|
+
* It is repeated here rather than imported so the contracts layer does not depend
|
|
898
|
+
* on a service module.
|
|
899
|
+
*/
|
|
900
|
+
interface SseResponse {
|
|
901
|
+
/** Set a response header before the stream begins. */
|
|
902
|
+
setHeader(name: string, value: string): unknown;
|
|
903
|
+
/** Write raw bytes to the open stream — the `: keepalive` comment. */
|
|
904
|
+
write(chunk: string): unknown;
|
|
905
|
+
}
|
|
906
|
+
|
|
857
907
|
/** Parameters required to register a freshly authenticated SSE connection. */
|
|
858
908
|
interface RegisterSseConnectionParams {
|
|
859
909
|
connectionId: string;
|
|
@@ -1009,12 +1059,12 @@ declare class SseSubscriptionHandler {
|
|
|
1009
1059
|
* wires the downstream listener BEFORE calling `registerConnection` — so a plain
|
|
1010
1060
|
* `Subject` suffices and the replay buffer cannot grow unboundedly.
|
|
1011
1061
|
*
|
|
1012
|
-
* @param req - The
|
|
1013
|
-
* @param res - The
|
|
1062
|
+
* @param req - The incoming request (SSE GET).
|
|
1063
|
+
* @param res - The response (passthrough for header mutations and heartbeat writes).
|
|
1014
1064
|
* @returns An Observable of `MessageEvent` values for NestJS `@Sse` to stream.
|
|
1015
1065
|
* @throws UnauthorizedException when authentication returns null.
|
|
1016
1066
|
*/
|
|
1017
|
-
handle(req:
|
|
1067
|
+
handle(req: SseRequest, res: SseResponse): Promise<Observable<MessageEvent>>;
|
|
1018
1068
|
/**
|
|
1019
1069
|
* Build the live Observable using a subscribe-before-register pattern.
|
|
1020
1070
|
*
|
package/dist/internal/index.d.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { ModuleMetadata, Type, Provider, Logger, DynamicModule, MessageEvent, OnModuleInit, OnApplicationShutdown } from '@nestjs/common';
|
|
2
2
|
import { Subject, Observable } from 'rxjs';
|
|
3
|
-
import { Request, Response } from 'express';
|
|
4
3
|
import { Redis } from 'ioredis';
|
|
5
4
|
|
|
6
5
|
/**
|
|
@@ -854,6 +853,57 @@ declare class HeartbeatService {
|
|
|
854
853
|
stopAll(): void;
|
|
855
854
|
}
|
|
856
855
|
|
|
856
|
+
/**
|
|
857
|
+
* @fileoverview The HTTP shape the SSE endpoint depends on.
|
|
858
|
+
* @layer contracts
|
|
859
|
+
*
|
|
860
|
+
* Structural on purpose, rather than `express.Request` and `express.Response`.
|
|
861
|
+
*
|
|
862
|
+
* Naming Express would make the published declarations import its types, and
|
|
863
|
+
* `@types/express` is not a dependency of this package — nor an optional peer, so
|
|
864
|
+
* a consumer compiling with `skipLibCheck: false` would have no supported way to
|
|
865
|
+
* satisfy it. It would also be the wrong type for an application on Fastify,
|
|
866
|
+
* which NestJS supports equally.
|
|
867
|
+
*
|
|
868
|
+
* The endpoint reads three fields from the request — `headers`, `ip`, `query` —
|
|
869
|
+
* and does two things to the response: sets the anti-buffering headers, and
|
|
870
|
+
* writes the keepalive comment. An `express.Request` satisfies these interfaces
|
|
871
|
+
* without being named by them, and so does a Fastify request, because
|
|
872
|
+
* assignability is structural.
|
|
873
|
+
*/
|
|
874
|
+
/** A header value as an HTTP server exposes it, before normalization. */
|
|
875
|
+
type SseHeaderValue = string | string[] | undefined;
|
|
876
|
+
/** The request fields the SSE endpoint reads. */
|
|
877
|
+
interface SseRequest {
|
|
878
|
+
/**
|
|
879
|
+
* Request headers, keyed as the HTTP framework delivers them. Node lowercases
|
|
880
|
+
* incoming header names, and the endpoint looks them up lowercase — `cookie`,
|
|
881
|
+
* `user-agent`, `x-forwarded-for` and `last-event-id` — so an adapter that
|
|
882
|
+
* preserves the client's casing has to lowercase the keys before it gets here,
|
|
883
|
+
* or those lookups miss.
|
|
884
|
+
*/
|
|
885
|
+
readonly headers: Readonly<Record<string, SseHeaderValue>>;
|
|
886
|
+
/** Remote address as the HTTP framework resolved it, when it resolves one. */
|
|
887
|
+
readonly ip?: string | undefined;
|
|
888
|
+
/** Parsed query string. Values are narrowed to strings by the caller. */
|
|
889
|
+
readonly query: Readonly<Record<string, unknown>>;
|
|
890
|
+
}
|
|
891
|
+
/**
|
|
892
|
+
* The response surface the SSE endpoint uses: anti-buffering headers, and a
|
|
893
|
+
* writable stream for the keepalive.
|
|
894
|
+
*
|
|
895
|
+
* `write` is structurally the same contract as `HeartbeatWritable`, which the
|
|
896
|
+
* heartbeat declares for itself so it can be driven by any writable in a test.
|
|
897
|
+
* It is repeated here rather than imported so the contracts layer does not depend
|
|
898
|
+
* on a service module.
|
|
899
|
+
*/
|
|
900
|
+
interface SseResponse {
|
|
901
|
+
/** Set a response header before the stream begins. */
|
|
902
|
+
setHeader(name: string, value: string): unknown;
|
|
903
|
+
/** Write raw bytes to the open stream — the `: keepalive` comment. */
|
|
904
|
+
write(chunk: string): unknown;
|
|
905
|
+
}
|
|
906
|
+
|
|
857
907
|
/** Parameters required to register a freshly authenticated SSE connection. */
|
|
858
908
|
interface RegisterSseConnectionParams {
|
|
859
909
|
connectionId: string;
|
|
@@ -1009,12 +1059,12 @@ declare class SseSubscriptionHandler {
|
|
|
1009
1059
|
* wires the downstream listener BEFORE calling `registerConnection` — so a plain
|
|
1010
1060
|
* `Subject` suffices and the replay buffer cannot grow unboundedly.
|
|
1011
1061
|
*
|
|
1012
|
-
* @param req - The
|
|
1013
|
-
* @param res - The
|
|
1062
|
+
* @param req - The incoming request (SSE GET).
|
|
1063
|
+
* @param res - The response (passthrough for header mutations and heartbeat writes).
|
|
1014
1064
|
* @returns An Observable of `MessageEvent` values for NestJS `@Sse` to stream.
|
|
1015
1065
|
* @throws UnauthorizedException when authentication returns null.
|
|
1016
1066
|
*/
|
|
1017
|
-
handle(req:
|
|
1067
|
+
handle(req: SseRequest, res: SseResponse): Promise<Observable<MessageEvent>>;
|
|
1018
1068
|
/**
|
|
1019
1069
|
* Build the live Observable using a subscribe-before-register pattern.
|
|
1020
1070
|
*
|
package/dist/internal/index.mjs
CHANGED
|
@@ -787,8 +787,8 @@ var SseSubscriptionHandler = class {
|
|
|
787
787
|
* wires the downstream listener BEFORE calling `registerConnection` — so a plain
|
|
788
788
|
* `Subject` suffices and the replay buffer cannot grow unboundedly.
|
|
789
789
|
*
|
|
790
|
-
* @param req - The
|
|
791
|
-
* @param res - The
|
|
790
|
+
* @param req - The incoming request (SSE GET).
|
|
791
|
+
* @param res - The response (passthrough for header mutations and heartbeat writes).
|
|
792
792
|
* @returns An Observable of `MessageEvent` values for NestJS `@Sse` to stream.
|
|
793
793
|
* @throws UnauthorizedException when authentication returns null.
|
|
794
794
|
*/
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bymax-one/nest-realtime",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.4",
|
|
4
4
|
"description": "Realtime backend → frontend communication for NestJS — dual-transport SSE (default) and WebSocket (opt-in) with a unified server-side API.",
|
|
5
5
|
"author": "Bymax One <support@bymax.one>",
|
|
6
6
|
"license": "MIT",
|