opinionated-machine 9.0.0 → 10.0.0
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 +69 -0
- package/README.md +103 -5
- package/dist/lib/DIContext.js +33 -27
- package/dist/lib/DIContext.js.map +1 -1
- package/dist/lib/routes/fastifyRouteBuilder.js +79 -21
- package/dist/lib/routes/fastifyRouteBuilder.js.map +1 -1
- package/dist/lib/routes/fastifyRouteTypes.d.ts +97 -12
- package/dist/lib/routes/fastifyRouteTypes.js.map +1 -1
- package/dist/lib/routes/fastifyRouteUtils.js +15 -5
- package/dist/lib/routes/fastifyRouteUtils.js.map +1 -1
- package/dist/lib/routes/index.d.ts +2 -1
- package/dist/lib/routes/index.js +2 -0
- package/dist/lib/routes/index.js.map +1 -1
- package/dist/lib/routes/sseResponseSchema.d.ts +35 -0
- package/dist/lib/routes/sseResponseSchema.js +115 -0
- package/dist/lib/routes/sseResponseSchema.js.map +1 -0
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,74 @@
|
|
|
1
1
|
# opinionated-machine
|
|
2
2
|
|
|
3
|
+
## 10.0.0
|
|
4
|
+
|
|
5
|
+
### Major Changes
|
|
6
|
+
|
|
7
|
+
- d06517a: Replace the silently-ignored per-route `heartbeatInterval` SSE option with `heartbeat: boolean`.
|
|
8
|
+
|
|
9
|
+
`@fastify/sse` has no per-route `heartbeatInterval`: the route-level knob is `heartbeat`, a boolean
|
|
10
|
+
that can only turn the heartbeat off, while the interval is a plugin-registration option shared by
|
|
11
|
+
all routes. The route builder was copying `heartbeatInterval` onto the route's `sse` option, where
|
|
12
|
+
the plugin never read it — so `buildHandler(contract, handlers, { heartbeatInterval: 5000 })`
|
|
13
|
+
type-checked, ran, and did nothing, and there was no way to disable the heartbeat for a single route.
|
|
14
|
+
|
|
15
|
+
Breaking changes:
|
|
16
|
+
|
|
17
|
+
- `FastifySSERouteOptions` / `FastifyDualModeRouteOptions`: `heartbeatInterval?: number` is replaced
|
|
18
|
+
by `heartbeat?: boolean`. Set `heartbeat: false` to suppress heartbeat comments on a route.
|
|
19
|
+
- `RegisterSSERoutesOptions` / `RegisterDualModeRoutesOptions`: `heartbeatInterval?: number` is
|
|
20
|
+
likewise replaced by `heartbeat?: boolean`. These options are applied to individual routes, not to
|
|
21
|
+
plugin registration, so they could never carry an interval either.
|
|
22
|
+
|
|
23
|
+
Configure the interval where it actually works, once for all routes:
|
|
24
|
+
`app.register(fastifySSE, { heartbeatInterval: 30000 })`.
|
|
25
|
+
|
|
26
|
+
Also fixes the registration-level `heartbeat` / `serializer` defaults from `registerSSERoutes()` and
|
|
27
|
+
`registerDualModeRoutes()`, which were written to `config.sse` — a location `@fastify/sse` never
|
|
28
|
+
reads — and are now merged into the top-level `sse` route option, with per-route values taking
|
|
29
|
+
precedence.
|
|
30
|
+
|
|
31
|
+
### Minor Changes
|
|
32
|
+
|
|
33
|
+
- e935a42: Register SSE and dual-mode routes with an explicit `@fastify/sse` kind of `'manual'` instead of falling back to the plugin's `'legacy'` kind.
|
|
34
|
+
|
|
35
|
+
Previously `buildFastifyRoute` emitted `sse: true` (or an options object without `kind`), which resolves to `'legacy'` and applies a strict `Accept` gate: a client that did not send an explicit `text/event-stream` token — a wildcard `Accept` header, `Accept: application/json`, or no `Accept` header at all — reached the SSE handler with `reply.sse` undefined, so the first `sse.start()` threw and the request returned a 500. The same applied to dual-mode routes configured with `defaultMode: 'sse'`. With `'manual'` there is no plugin-side negotiation: `reply.sse` is always attached and the handler decides whether to stream, which is what these route handlers already do.
|
|
36
|
+
|
|
37
|
+
Adds a `kind` route option so the default can be overridden, restricted per route type to the kinds that can actually work:
|
|
38
|
+
|
|
39
|
+
- SSE-only routes accept `'manual' | 'only'` (`SSEOnlyRouteKind`). `'only'` makes the plugin content-negotiate and answer `406 Not Acceptable` before the handler runs; note its gate admits a missing `Accept` header and the `*/*` and `text/*` wildcards but rejects every other concrete media type, `application/json` included.
|
|
40
|
+
- Dual-mode routes accept `'manual' | 'dual'` (`DualModeRouteKind`). Combining `kind: 'dual'` with `defaultMode: 'sse'` now throws at route-build time instead of returning a 500 per request, because the plugin's gate and the handler's own `determineMode()` disagree for wildcard or absent `Accept` headers.
|
|
41
|
+
|
|
42
|
+
Also stops the SSE teardown path from masking errors: `closeSSESession` re-read `reply.sse.isConnected` from inside its own `catch`, which raised a second `TypeError` and replaced the original failure, and `sse.start()` now marks the session started only after its first successful `reply.sse` access.
|
|
43
|
+
|
|
44
|
+
## 9.1.0
|
|
45
|
+
|
|
46
|
+
### Minor Changes
|
|
47
|
+
|
|
48
|
+
- a806edc: Document SSE and dual-mode route responses in the generated OpenAPI spec.
|
|
49
|
+
|
|
50
|
+
`buildFastifyRoute` left `schema.response` empty for `AbstractSSEController` and
|
|
51
|
+
`AbstractDualModeController` routes, so the spec showed a bare "Default Response" with no
|
|
52
|
+
event shapes and no error bodies, even though the same contract data was already used for
|
|
53
|
+
runtime validation. Both builders now derive `schema.response` from the contract: 200
|
|
54
|
+
describes the event stream under `text/event-stream` (one `{ id?, event, data, retry? }`
|
|
55
|
+
envelope per event, as a `oneOf` with the event name pinned to a `const`, matching what
|
|
56
|
+
`@lokalise/fastify-api-contracts` emits for `sseBody()`) plus the JSON body under
|
|
57
|
+
`application/json`, and each status in `responseBodySchemasByStatusCode` gets its declared
|
|
58
|
+
schema.
|
|
59
|
+
|
|
60
|
+
Statuses that more than one body shape can reach accept all of them, since Fastify rejects
|
|
61
|
+
anything the schema does not cover: a dual-mode 2xx accepts both `successResponseBodySchema`
|
|
62
|
+
(the `sync` handler) and the schema declared for that status (`sse.respond()`), and a non-2xx
|
|
63
|
+
accepts the framework error envelope alongside the declared body, so declaring a 400 no longer
|
|
64
|
+
turns a failed request validation into a 500. Errors the builders raise themselves before
|
|
65
|
+
streaming starts are sent pre-serialized and skip the schema, keeping the thrown error's
|
|
66
|
+
message intact.
|
|
67
|
+
|
|
68
|
+
This puts Fastify's serializer in the path for the status codes a contract declares. A
|
|
69
|
+
response body that previously went out through plain `JSON.stringify` is now serialized
|
|
70
|
+
against its contract schema, so keys the schema does not declare are dropped.
|
|
71
|
+
|
|
3
72
|
## 9.0.0
|
|
4
73
|
|
|
5
74
|
### Major Changes
|
package/README.md
CHANGED
|
@@ -732,6 +732,13 @@ const app = fastify()
|
|
|
732
732
|
await app.register(FastifySSEPlugin)
|
|
733
733
|
```
|
|
734
734
|
|
|
735
|
+
Plugin-level options apply to every SSE route. The heartbeat interval is set here and only
|
|
736
|
+
here - it is not a per-route option:
|
|
737
|
+
|
|
738
|
+
```ts
|
|
739
|
+
await app.register(FastifySSEPlugin, { heartbeatInterval: 30000 })
|
|
740
|
+
```
|
|
741
|
+
|
|
735
742
|
### Defining SSE Contracts
|
|
736
743
|
|
|
737
744
|
Use `buildSseContract` from `@lokalise/api-contracts` to define SSE routes. The `method` field determines the HTTP method. Paths are defined using `pathResolver`, a type-safe function that receives typed params and returns the URL path:
|
|
@@ -1101,7 +1108,8 @@ private handleAdminStream = buildHandler(adminStreamContract, {
|
|
|
1101
1108
|
| `onReconnect` | Handle Last-Event-ID reconnection, return events to replay |
|
|
1102
1109
|
| `logger` | Optional `SSELogger` for error handling (compatible with pino and `@lokalise/node-core`). If not provided, errors in lifecycle hooks are silently ignored |
|
|
1103
1110
|
| `serializer` | Custom serializer for SSE data (e.g., for custom JSON encoding) |
|
|
1104
|
-
| `
|
|
1111
|
+
| `heartbeat` | Set to `false` to disable heartbeat keep-alive comments for this route. The *interval* is not per-route — configure it once via `app.register(fastifySSE, { heartbeatInterval })` |
|
|
1112
|
+
| `kind` | `@fastify/sse` route kind - how the `Accept` header is negotiated. Defaults to `'manual'` (see below) |
|
|
1105
1113
|
| `contractMetadataToRouteMapper` | Maps contract metadata to Fastify route options (see below) |
|
|
1106
1114
|
|
|
1107
1115
|
**onClose reason parameter:**
|
|
@@ -1116,10 +1124,65 @@ options: {
|
|
|
1116
1124
|
// reason is 'server' or 'client'
|
|
1117
1125
|
},
|
|
1118
1126
|
serializer: (data) => JSON.stringify(data, null, 2), // Pretty-print JSON
|
|
1119
|
-
|
|
1127
|
+
heartbeat: false, // Disable heartbeat comments on this route
|
|
1120
1128
|
}
|
|
1121
1129
|
```
|
|
1122
1130
|
|
|
1131
|
+
The heartbeat *interval* is not a route option - `@fastify/sse` only exposes a boolean at route
|
|
1132
|
+
level, and reads the interval once, when the plugin is registered, applying it to every SSE route:
|
|
1133
|
+
|
|
1134
|
+
```ts
|
|
1135
|
+
await app.register(FastifySSEPlugin, { heartbeatInterval: 30000 })
|
|
1136
|
+
```
|
|
1137
|
+
|
|
1138
|
+
#### `kind` and `Accept` header negotiation
|
|
1139
|
+
|
|
1140
|
+
Routes are registered with the `@fastify/sse` kind `'manual'`, which means the plugin performs **no**
|
|
1141
|
+
`Accept` header negotiation: `reply.sse` is always attached and the route handler decides at runtime
|
|
1142
|
+
whether to stream or to send a regular HTTP response.
|
|
1143
|
+
|
|
1144
|
+
This matters because SSE handlers built with `buildHandler` have a single code path that calls
|
|
1145
|
+
`sse.start()`. Clients that do not send an explicit `Accept: text/event-stream` token - a wildcard
|
|
1146
|
+
`Accept` header (the default for most non-browser HTTP clients), `Accept: application/json`, or no
|
|
1147
|
+
`Accept` header at all (typical of clients generated from the route's OpenAPI spec) - would otherwise
|
|
1148
|
+
reach the handler with `reply.sse` left undefined and get a `500` instead of a stream. It also keeps
|
|
1149
|
+
`sse.respond()` early returns available to every client. Dual-mode routes negotiate the `Accept`
|
|
1150
|
+
header themselves (honouring `defaultMode`), so they use the same kind.
|
|
1151
|
+
|
|
1152
|
+
Each route type accepts only the kinds that can actually work for it:
|
|
1153
|
+
|
|
1154
|
+
**SSE-only routes** - `'manual' | 'only'`
|
|
1155
|
+
|
|
1156
|
+
| Kind | Behavior |
|
|
1157
|
+
| ---- | -------- |
|
|
1158
|
+
| `'manual'` (default) | No negotiation. `reply.sse` is always attached, the handler decides |
|
|
1159
|
+
| `'only'` | The plugin gates on `Accept` and answers `406 Not Acceptable` before the handler runs. A missing `Accept` header and the wildcards `*/*` and `text/*` pass; **every other concrete media type is rejected**, `application/json` included - so `sse.respond()` early returns become unreachable for JSON clients |
|
|
1160
|
+
|
|
1161
|
+
**Dual-mode routes** - `'manual' | 'dual'`
|
|
1162
|
+
|
|
1163
|
+
| Kind | Behavior |
|
|
1164
|
+
| ---- | -------- |
|
|
1165
|
+
| `'manual'` (default) | No plugin-side negotiation. The route's own `determineMode()` picks the mode, honouring `defaultMode` |
|
|
1166
|
+
| `'dual'` | The plugin gates first: only an explicit `text/event-stream` token admits SSE, everything else reaches the handler with `reply.sse` undefined. Sound only with `defaultMode: 'json'` - pairing it with `defaultMode: 'sse'` is rejected at route-build time, because a wildcard or absent `Accept` header would select the SSE branch after the plugin already declined to attach the stream |
|
|
1167
|
+
|
|
1168
|
+
The plugin's other kinds are deliberately not exposed: `'dual'` on an SSE-only route (and the
|
|
1169
|
+
`sse: true` `'legacy'` default) can only ever leave a single-code-path handler without `reply.sse`,
|
|
1170
|
+
and `'only'` on a dual-mode route would make the JSON half unreachable.
|
|
1171
|
+
|
|
1172
|
+
Override it per route when you want different semantics:
|
|
1173
|
+
|
|
1174
|
+
```ts
|
|
1175
|
+
private handleAdminStream = buildHandler(adminStreamContract, {
|
|
1176
|
+
sse: async (request, sse) => {
|
|
1177
|
+
const session = sse.start('keepAlive')
|
|
1178
|
+
// ... handler logic
|
|
1179
|
+
},
|
|
1180
|
+
}, {
|
|
1181
|
+
// Content-negotiate: anything that does not accept text/event-stream gets 406 Not Acceptable
|
|
1182
|
+
kind: 'only',
|
|
1183
|
+
})
|
|
1184
|
+
```
|
|
1185
|
+
|
|
1123
1186
|
#### `contractMetadataToRouteMapper`
|
|
1124
1187
|
|
|
1125
1188
|
Allows attaching cross-cutting behavior (auth, rate limiting, tracing, etc.) to a route based on metadata defined in the
|
|
@@ -2448,9 +2511,44 @@ sync: (request, reply) => {
|
|
|
2448
2511
|
|
|
2449
2512
|
**Validation priority for 2xx status codes:**
|
|
2450
2513
|
|
|
2451
|
-
- All 2xx responses (200, 201, 204, etc.) are validated against
|
|
2452
|
-
|
|
2453
|
-
-
|
|
2514
|
+
- All 2xx responses (200, 201, 204, etc.) returned by the `sync` handler are validated against
|
|
2515
|
+
`successResponseBodySchema`
|
|
2516
|
+
- For the `sync` handler, `responseBodySchemasByStatusCode` is only used for non-2xx status codes,
|
|
2517
|
+
so `successResponseBodySchema` takes precedence when the same 2xx code is defined in both
|
|
2518
|
+
- `sse.respond(code, body)` is validated against `responseBodySchemasByStatusCode[code]` at every
|
|
2519
|
+
status, 2xx included, because that is the schema its argument is typed from
|
|
2520
|
+
|
|
2521
|
+
**OpenAPI output and serialization:**
|
|
2522
|
+
|
|
2523
|
+
`buildFastifyRoute` fills in the route's `schema.response` from the contract, so the generated
|
|
2524
|
+
spec describes each status instead of showing a bare "Default Response":
|
|
2525
|
+
|
|
2526
|
+
- 200 carries `text/event-stream` with one `{ id?, event, data, retry? }` envelope per entry in
|
|
2527
|
+
`serverSentEventSchemas`, rendered as a `oneOf` with the `event` name pinned to a `const` in
|
|
2528
|
+
each branch, plus `application/json` for the JSON body
|
|
2529
|
+
- Every status in `responseBodySchemasByStatusCode` gets its declared schema
|
|
2530
|
+
|
|
2531
|
+
Because Fastify drives serialization from the same `schema.response`, a response body for a
|
|
2532
|
+
status the contract declares is serialized against that schema. Keys the schema does not
|
|
2533
|
+
declare are dropped from the body that goes out. Streamed SSE events are written directly by
|
|
2534
|
+
`@fastify/sse` and bypass the serializer, so the 200 event schema documents the stream without
|
|
2535
|
+
affecting it.
|
|
2536
|
+
|
|
2537
|
+
A status can be reached by more than one body shape, and Fastify rejects anything the schema
|
|
2538
|
+
does not accept, so each status accepts every shape the runtime can produce there:
|
|
2539
|
+
|
|
2540
|
+
- On a 2xx of a dual-mode contract, `application/json` accepts `successResponseBodySchema` (what
|
|
2541
|
+
the `sync` handler is validated against) as well as the schema declared for that status (what
|
|
2542
|
+
`sse.respond()` is validated against), rather than one taking precedence over the other in the
|
|
2543
|
+
spec
|
|
2544
|
+
- On a non-2xx, the declared schema is joined by the framework error envelope
|
|
2545
|
+
(`{ statusCode, message, error?, code?, ... }`), which is what Fastify sends for a failed
|
|
2546
|
+
request validation and what an application-level error handler typically returns. Without it,
|
|
2547
|
+
declaring a 400 body would turn every `FST_ERR_VALIDATION` on that route into a 500
|
|
2548
|
+
|
|
2549
|
+
Both show up in the spec as an `anyOf`. Errors the SSE builders raise themselves, before
|
|
2550
|
+
streaming starts, are sent pre-serialized and skip the schema entirely, so the thrown error's
|
|
2551
|
+
message always reaches the client.
|
|
2454
2552
|
|
|
2455
2553
|
### Single Sync Handler
|
|
2456
2554
|
|
package/dist/lib/DIContext.js
CHANGED
|
@@ -1,8 +1,38 @@
|
|
|
1
1
|
import { AwilixManager } from 'awilix-manager';
|
|
2
|
-
import { merge } from 'ts-deepmerge';
|
|
3
2
|
import { mergeConfigAndDependencyOverrides } from './configUtils.js';
|
|
4
3
|
import { buildGatewayManifestFrom, } from './gateway/index.js';
|
|
5
4
|
import { buildFastifyRoute, } from './routes/index.js';
|
|
5
|
+
/**
|
|
6
|
+
* Apply registration-level SSE defaults (`heartbeat`, `serializer`) to a route.
|
|
7
|
+
*
|
|
8
|
+
* `@fastify/sse` reads its per-route configuration from the top-level `sse` route
|
|
9
|
+
* option (not from `config.sse`), and only supports a boolean `heartbeat` there —
|
|
10
|
+
* the heartbeat interval is a plugin-registration option shared by all routes.
|
|
11
|
+
*
|
|
12
|
+
* Values already set on the route by the route builder win over the registration-level
|
|
13
|
+
* defaults.
|
|
14
|
+
*/
|
|
15
|
+
function applyGlobalSSEOptions(route, options) {
|
|
16
|
+
if (options?.heartbeat === undefined && options?.serializer === undefined) {
|
|
17
|
+
return;
|
|
18
|
+
}
|
|
19
|
+
const routeWithSSE = route;
|
|
20
|
+
const routeSSEOption = routeWithSSE.sse;
|
|
21
|
+
if (!routeSSEOption) {
|
|
22
|
+
return;
|
|
23
|
+
}
|
|
24
|
+
// The route option is either `true` (plain SSE), a bare kind string, or an options object.
|
|
25
|
+
const routeSSEConfig = typeof routeSSEOption === 'string'
|
|
26
|
+
? { kind: routeSSEOption }
|
|
27
|
+
: typeof routeSSEOption === 'object'
|
|
28
|
+
? routeSSEOption
|
|
29
|
+
: {};
|
|
30
|
+
routeWithSSE.sse = {
|
|
31
|
+
...(options.heartbeat !== undefined && { heartbeat: options.heartbeat }),
|
|
32
|
+
...(options.serializer !== undefined && { serializer: options.serializer }),
|
|
33
|
+
...routeSSEConfig,
|
|
34
|
+
};
|
|
35
|
+
}
|
|
6
36
|
export class DIContext {
|
|
7
37
|
options;
|
|
8
38
|
awilixManager;
|
|
@@ -249,19 +279,7 @@ export class DIContext {
|
|
|
249
279
|
if (options?.rateLimit) {
|
|
250
280
|
this.applyRateLimit(route, options.rateLimit);
|
|
251
281
|
}
|
|
252
|
-
|
|
253
|
-
if (options?.heartbeatInterval !== undefined || options?.serializer !== undefined) {
|
|
254
|
-
// biome-ignore lint/suspicious/noExplicitAny: config types vary by plugins
|
|
255
|
-
const routeWithConfig = route;
|
|
256
|
-
routeWithConfig.config = merge(routeWithConfig.config || {}, {
|
|
257
|
-
sse: {
|
|
258
|
-
...(options.heartbeatInterval !== undefined && {
|
|
259
|
-
heartbeatInterval: options.heartbeatInterval,
|
|
260
|
-
}),
|
|
261
|
-
...(options.serializer !== undefined && { serializer: options.serializer }),
|
|
262
|
-
},
|
|
263
|
-
});
|
|
264
|
-
}
|
|
282
|
+
applyGlobalSSEOptions(route, options);
|
|
265
283
|
}
|
|
266
284
|
applySSERouteOptions(route, options) {
|
|
267
285
|
if (options?.preHandler) {
|
|
@@ -270,19 +288,7 @@ export class DIContext {
|
|
|
270
288
|
if (options?.rateLimit) {
|
|
271
289
|
this.applyRateLimit(route, options.rateLimit);
|
|
272
290
|
}
|
|
273
|
-
|
|
274
|
-
if (options?.heartbeatInterval !== undefined || options?.serializer !== undefined) {
|
|
275
|
-
// biome-ignore lint/suspicious/noExplicitAny: config types vary by plugins
|
|
276
|
-
const routeWithConfig = route;
|
|
277
|
-
routeWithConfig.config = merge(routeWithConfig.config || {}, {
|
|
278
|
-
sse: {
|
|
279
|
-
...(options.heartbeatInterval !== undefined && {
|
|
280
|
-
heartbeatInterval: options.heartbeatInterval,
|
|
281
|
-
}),
|
|
282
|
-
...(options.serializer !== undefined && { serializer: options.serializer }),
|
|
283
|
-
},
|
|
284
|
-
});
|
|
285
|
-
}
|
|
291
|
+
applyGlobalSSEOptions(route, options);
|
|
286
292
|
}
|
|
287
293
|
applyPreHandlers(route, globalPreHandler) {
|
|
288
294
|
const existingPreHandler = route.preHandler;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DIContext.js","sourceRoot":"","sources":["../../lib/DIContext.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"DIContext.js","sourceRoot":"","sources":["../../lib/DIContext.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAA;AAK9C,OAAO,EAAE,iCAAiC,EAAsB,MAAM,kBAAkB,CAAA;AAGxF,OAAO,EAEL,wBAAwB,GAGzB,MAAM,oBAAoB,CAAA;AAC3B,OAAO,EACL,iBAAiB,GAGlB,MAAM,mBAAmB,CAAA;AA8B1B;;;;;;;;;GASG;AACH,SAAS,qBAAqB,CAC5B,KAAmB,EACnB,OAAoE;IAEpE,IAAI,OAAO,EAAE,SAAS,KAAK,SAAS,IAAI,OAAO,EAAE,UAAU,KAAK,SAAS,EAAE,CAAC;QAC1E,OAAM;IACR,CAAC;IAED,MAAM,YAAY,GAAG,KAAyC,CAAA;IAC9D,MAAM,cAAc,GAAG,YAAY,CAAC,GAAG,CAAA;IACvC,IAAI,CAAC,cAAc,EAAE,CAAC;QACpB,OAAM;IACR,CAAC;IAED,2FAA2F;IAC3F,MAAM,cAAc,GAClB,OAAO,cAAc,KAAK,QAAQ;QAChC,CAAC,CAAC,EAAE,IAAI,EAAE,cAA2D,EAAE;Q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AC,OAAO;QACX,MAAM,IAAI,CAAC,aAAa,CAAC,cAAc,EAAE,CAAA;QACzC,MAAM,IAAI,CAAC,WAAW,CAAC,OAAO,EAAE,CAAA;IAClC,CAAC;IAED,KAAK,CAAC,IAAI;QACR,MAAM,IAAI,CAAC,aAAa,CAAC,WAAW,EAAE,CAAA;IACxC,CAAC;CACF"}
|
|
@@ -2,22 +2,54 @@ import { InternalError } from '@lokalise/node-core';
|
|
|
2
2
|
import { ZodObject } from 'zod';
|
|
3
3
|
import { isErrorLike } from "../errorUtils.js";
|
|
4
4
|
import { createSSEContext, determineMode, extractPathTemplate, handleSSEError, hasHttpStatusCode, } from "./fastifyRouteUtils.js";
|
|
5
|
+
import { buildSseResponseSchemas } from "./sseResponseSchema.js";
|
|
5
6
|
// Re-export for convenience
|
|
6
7
|
export { extractPathTemplate };
|
|
8
|
+
/**
|
|
9
|
+
* Default `@fastify/sse` route kind used by both SSE-only and dual-mode routes.
|
|
10
|
+
*
|
|
11
|
+
* `'manual'` disables the plugin's `Accept` header negotiation entirely: `reply.sse` is
|
|
12
|
+
* always attached and the route handler decides at runtime whether to stream or to send a
|
|
13
|
+
* regular HTTP response. That matches what the handlers this builder produces already do,
|
|
14
|
+
* and it is the only kind that is safe for every shape of route:
|
|
15
|
+
*
|
|
16
|
+
* - SSE-only handlers have a single code path that calls `sse.start()`. Under the plugin's
|
|
17
|
+
* `sse: true` default (`kind: 'legacy'`) a client that does not send an explicit
|
|
18
|
+
* `text/event-stream` token - a wildcard `Accept` header, `Accept: application/json`, or
|
|
19
|
+
* no `Accept` header at all, which is what most non-browser clients and OpenAPI-generated
|
|
20
|
+
* clients send - leaves `reply.sse` undefined while still running the handler, so the
|
|
21
|
+
* first `sse.start()` throws and the request 500s.
|
|
22
|
+
* - Dual-mode handlers negotiate themselves via `determineMode()`, which honours
|
|
23
|
+
* `defaultMode`. Under a plugin-side gate, `defaultMode: 'sse'` combined with a
|
|
24
|
+
* non-specific `Accept` header hits the same 500.
|
|
25
|
+
* - `sse.respond()` (an early HTTP response before streaming starts) stays reachable for
|
|
26
|
+
* every client. `kind: 'only'` would cut that off for JSON clients: its gate admits a
|
|
27
|
+
* missing `Accept` header plus the `*\/*` and `text/*` wildcards, but answers `406` to
|
|
28
|
+
* every other concrete media type, `application/json` included.
|
|
29
|
+
*
|
|
30
|
+
* Override per route with the `kind` route option when different semantics are wanted -
|
|
31
|
+
* `'only'` on an SSE-only route for `406 Not Acceptable` content negotiation, or `'dual'`
|
|
32
|
+
* on a dual-mode route to let the plugin gate before the handler runs.
|
|
33
|
+
*/
|
|
34
|
+
const DEFAULT_SSE_ROUTE_KIND = 'manual';
|
|
7
35
|
/**
|
|
8
36
|
* Build the SSE config object for route options.
|
|
9
|
-
*
|
|
37
|
+
*
|
|
38
|
+
* Always returns the object form with an explicit `kind`: omitting it (or passing
|
|
39
|
+
* `sse: true`) makes `@fastify/sse` fall back to its `'legacy'` kind, which applies a
|
|
40
|
+
* strict `Accept` gate and leaves `reply.sse` undefined for clients that do not ask
|
|
41
|
+
* for `text/event-stream` explicitly.
|
|
42
|
+
*
|
|
43
|
+
* `heartbeat` is a boolean: the plugin only supports turning the heartbeat on or off per
|
|
44
|
+
* route, while the interval is set once for all routes at plugin registration.
|
|
10
45
|
*/
|
|
11
46
|
function buildSSEConfig(options) {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
}
|
|
15
|
-
const sseConfig = {};
|
|
16
|
-
if (options.serializer) {
|
|
47
|
+
const sseConfig = { kind: options?.kind ?? DEFAULT_SSE_ROUTE_KIND };
|
|
48
|
+
if (options?.serializer) {
|
|
17
49
|
sseConfig.serializer = options.serializer;
|
|
18
50
|
}
|
|
19
|
-
if (options
|
|
20
|
-
sseConfig.
|
|
51
|
+
if (options?.heartbeat !== undefined) {
|
|
52
|
+
sseConfig.heartbeat = options.heartbeat;
|
|
21
53
|
}
|
|
22
54
|
return sseConfig;
|
|
23
55
|
}
|
|
@@ -232,11 +264,13 @@ request, reply, options) {
|
|
|
232
264
|
// Respect httpStatusCode from errors like PublicNonRecoverableError
|
|
233
265
|
const statusCode = hasHttpStatusCode(err) ? err.httpStatusCode : 500;
|
|
234
266
|
const statusText = statusCode >= 500 ? 'Internal Server Error' : 'Error';
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
267
|
+
// Sent pre-serialized: Fastify skips the response serializer for string payloads, so this
|
|
268
|
+
// envelope reaches the client intact even when the contract declares a different body for
|
|
269
|
+
// `statusCode`. Serializing it against that schema would drop `message`.
|
|
270
|
+
reply
|
|
271
|
+
.code(statusCode)
|
|
272
|
+
.type('application/json')
|
|
273
|
+
.send(JSON.stringify({ statusCode, error: statusText, message }));
|
|
240
274
|
}
|
|
241
275
|
}
|
|
242
276
|
/**
|
|
@@ -262,6 +296,24 @@ function buildDualModeRouteInternal(controller, config) {
|
|
|
262
296
|
});
|
|
263
297
|
}
|
|
264
298
|
const url = extractPathTemplate(contract.pathResolver, contract.requestPathParamsSchema);
|
|
299
|
+
// `kind: 'dual'` hands Accept negotiation to @fastify/sse, which admits SSE only for an
|
|
300
|
+
// explicit `text/event-stream` token. `determineMode()` then negotiates a second time
|
|
301
|
+
// inside the handler and falls back to `defaultMode` for anything non-specific, so with
|
|
302
|
+
// `defaultMode: 'sse'` a wildcard or absent Accept header takes the SSE branch after the
|
|
303
|
+
// plugin already declined to attach `reply.sse` - a guaranteed 500 on every such request.
|
|
304
|
+
// The two negotiators only agree when the fallback is JSON, so reject the combination at
|
|
305
|
+
// route-build time rather than letting it fail per request. `kind: 'manual'` (the default)
|
|
306
|
+
// performs no plugin-side gating and supports `defaultMode: 'sse'` fine.
|
|
307
|
+
if (options?.kind === 'dual' && defaultMode === 'sse') {
|
|
308
|
+
throw new InternalError({
|
|
309
|
+
message: `Dual-mode route ${contract.method.toUpperCase()} ${url} cannot combine kind: "dual" ` +
|
|
310
|
+
'with defaultMode: "sse": @fastify/sse would decline to attach reply.sse for ' +
|
|
311
|
+
'wildcard or absent Accept headers while the handler still selects SSE mode. ' +
|
|
312
|
+
'Use kind: "manual" (the default) instead.',
|
|
313
|
+
errorCode: 'INVALID_SSE_ROUTE_KIND',
|
|
314
|
+
details: { url, method: contract.method, defaultMode, kind: options.kind },
|
|
315
|
+
});
|
|
316
|
+
}
|
|
265
317
|
const schema = {
|
|
266
318
|
params: contract.requestPathParamsSchema,
|
|
267
319
|
querystring: contract.requestQuerySchema,
|
|
@@ -271,13 +323,16 @@ function buildDualModeRouteInternal(controller, config) {
|
|
|
271
323
|
tags: contract.tags,
|
|
272
324
|
hide: contract.visibility !== 'public',
|
|
273
325
|
...(contract.requestBodySchema && { body: contract.requestBodySchema }),
|
|
274
|
-
//
|
|
326
|
+
// 200 describes both branches: the JSON sync body and the SSE event stream.
|
|
327
|
+
// `isEmptyResponseExpected` contracts have no sync body to describe, so they get the
|
|
328
|
+
// stream alone rather than a schema that would serialize an empty response.
|
|
329
|
+
response: buildSseResponseSchemas(contract.serverSentEventSchemas, contract.responseBodySchemasByStatusCode, contract.isEmptyResponseExpected ? undefined : contract.successResponseBodySchema),
|
|
275
330
|
};
|
|
276
331
|
const routeOptions = {
|
|
277
332
|
...(options?.contractMetadataToRouteMapper?.(contract.metadata) ?? {}),
|
|
278
333
|
method: contract.method,
|
|
279
334
|
url,
|
|
280
|
-
sse: buildSSEConfig(options), // Enable SSE support with optional per-route config
|
|
335
|
+
sse: buildSSEConfig(options), // Enable SSE support with explicit kind + optional per-route config
|
|
281
336
|
schema,
|
|
282
337
|
handler: async (request, reply) => {
|
|
283
338
|
// Determine mode based on Accept header
|
|
@@ -323,12 +378,13 @@ function buildSSERouteInternal(controller, config) {
|
|
|
323
378
|
tags: contract.tags,
|
|
324
379
|
hide: contract.visibility !== 'public',
|
|
325
380
|
...(contract.requestBodySchema && { body: contract.requestBodySchema }),
|
|
381
|
+
response: buildSseResponseSchemas(contract.serverSentEventSchemas, contract.responseBodySchemasByStatusCode),
|
|
326
382
|
};
|
|
327
383
|
const routeOptions = {
|
|
328
384
|
...(options?.contractMetadataToRouteMapper?.(contract.metadata) ?? {}),
|
|
329
385
|
method: contract.method,
|
|
330
386
|
url,
|
|
331
|
-
sse: buildSSEConfig(options), // Enable SSE support with optional per-route config
|
|
387
|
+
sse: buildSSEConfig(options), // Enable SSE support with explicit kind + optional per-route config
|
|
332
388
|
schema,
|
|
333
389
|
// biome-ignore lint/complexity/noExcessiveCognitiveComplexity: Core SSE route handler must coordinate context, error handling, and result processing
|
|
334
390
|
handler: async (request, reply) => {
|
|
@@ -367,11 +423,13 @@ function buildSSERouteInternal(controller, config) {
|
|
|
367
423
|
// Respect httpStatusCode from errors like PublicNonRecoverableError
|
|
368
424
|
const statusCode = hasHttpStatusCode(err) ? err.httpStatusCode : 500;
|
|
369
425
|
const statusText = statusCode >= 500 ? 'Internal Server Error' : 'Error';
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
426
|
+
// Sent pre-serialized: Fastify skips the response serializer for string payloads, so
|
|
427
|
+
// this envelope reaches the client intact even when the contract declares a different
|
|
428
|
+
// body for `statusCode`. Serializing it against that schema would drop `message`.
|
|
429
|
+
reply
|
|
430
|
+
.code(statusCode)
|
|
431
|
+
.type('application/json')
|
|
432
|
+
.send(JSON.stringify({ statusCode, error: statusText, message }));
|
|
375
433
|
}
|
|
376
434
|
},
|
|
377
435
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fastifyRouteBuilder.js","sourceRoot":"","sources":["../../../lib/routes/fastifyRouteBuilder.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAA;AAGnD,OAAO,EAAE,SAAS,EAAE,MAAM,KAAK,CAAA;AAE/B,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAA;AAS9C,OAAO,EACL,gBAAgB,EAChB,aAAa,EACb,mBAAmB,EACnB,cAAc,EACd,iBAAiB,GAClB,MAAM,wB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;IAC7F,MAAM,WAAW,GAAG,cAAc,CAAC,MAAM,IAAI,WAAW,CAAA;IACxD,MAAM,eAAe,GACnB,OAAO,cAAc,CAAC,QAAQ,EAAE,YAAY,KAAK,UAAU;QACzD,CAAC,CAAC,uBAAuB,cAAc,CAAC,QAAQ,CAAC,YAAY,CAAC,EAAE,CAAC,GAAG;QACpE,CAAC,CAAC,iBAAiB,CAAA;IACvB,MAAM,IAAI,KAAK,CACb,0DAA0D,WAAW,SAAS,eAAe,IAAI;QAC/F,2GAA2G;QAC3G,uFAAuF;QACvF,sDAAsD,CACzD,CAAA;AACH,CAAC"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { SSERouteKind } from '@fastify/sse';
|
|
1
2
|
import type { AnyDualModeContractDefinition, AnySSEContractDefinition, HttpStatusCode } from '@lokalise/api-contracts';
|
|
2
3
|
import type { ApiContractMetadataToRouteMapper } from '@lokalise/fastify-api-contracts';
|
|
3
4
|
import type { FastifyReply, FastifyRequest } from 'fastify';
|
|
@@ -331,10 +332,51 @@ export type SSEContext<Events extends SSEEventSchemas = SSEEventSchemas, Respons
|
|
|
331
332
|
* ```
|
|
332
333
|
*/
|
|
333
334
|
export type FastifySSEPreHandler = (request: FastifyRequest, reply: FastifyReply) => Promise<unknown>;
|
|
335
|
+
/**
|
|
336
|
+
* Constrains a route kind we expose to the set `@fastify/sse` actually accepts.
|
|
337
|
+
*
|
|
338
|
+
* Used purely as a compile-time guard on the aliases below: if the plugin ever renames or
|
|
339
|
+
* drops a kind, the alias stops compiling instead of silently degrading (which is what
|
|
340
|
+
* `Extract<SSERouteKind, ...>` would do - it would quietly resolve to `never`).
|
|
341
|
+
*/
|
|
342
|
+
type SupportedSSERouteKind<Kind extends SSERouteKind> = Kind;
|
|
343
|
+
/**
|
|
344
|
+
* `@fastify/sse` route kinds that are sound for an **SSE-only** route.
|
|
345
|
+
*
|
|
346
|
+
* The plugin also has `'dual'` (and the `sse: true` `'legacy'` default), but neither is
|
|
347
|
+
* usable here: both leave `reply.sse` undefined for clients that do not send an explicit
|
|
348
|
+
* `text/event-stream` token, while still invoking the handler - and an SSE-only handler
|
|
349
|
+
* has a single code path that calls `sse.start()`, so it can only fail.
|
|
350
|
+
*/
|
|
351
|
+
export type SSEOnlyRouteKind = SupportedSSERouteKind<'manual' | 'only'>;
|
|
352
|
+
/**
|
|
353
|
+
* `@fastify/sse` route kinds that are sound for a **dual-mode** route.
|
|
354
|
+
*
|
|
355
|
+
* `'only'` is excluded: it answers non-SSE clients with `406 Not Acceptable` before the
|
|
356
|
+
* handler runs, which makes the JSON half of a dual-mode route unreachable.
|
|
357
|
+
*/
|
|
358
|
+
export type DualModeRouteKind = SupportedSSERouteKind<'manual' | 'dual'>;
|
|
334
359
|
/**
|
|
335
360
|
* Options for configuring an SSE route.
|
|
336
361
|
*/
|
|
337
362
|
export type FastifySSERouteOptions = {
|
|
363
|
+
/**
|
|
364
|
+
* `@fastify/sse` route kind, controlling how the plugin negotiates the `Accept` header.
|
|
365
|
+
*
|
|
366
|
+
* - `'manual'` (default): no negotiation at all. `reply.sse` is always attached and the
|
|
367
|
+
* route handler decides at runtime whether to stream or to send a regular HTTP response.
|
|
368
|
+
* This keeps the route working for clients that send a wildcard `Accept` header,
|
|
369
|
+
* `Accept: application/json` or no `Accept` header at all, and keeps `sse.respond()`
|
|
370
|
+
* early returns available to every client.
|
|
371
|
+
* - `'only'`: the plugin gates on `Accept` and answers `406 Not Acceptable` before the
|
|
372
|
+
* handler runs unless the client accepts `text/event-stream`. A missing `Accept` header
|
|
373
|
+
* and the wildcards `*\/*` and `text/*` pass the gate; every other concrete media type
|
|
374
|
+
* is rejected - including `Accept: application/json`, which means `sse.respond()` early
|
|
375
|
+
* returns become unreachable for JSON clients.
|
|
376
|
+
*
|
|
377
|
+
* @default 'manual'
|
|
378
|
+
*/
|
|
379
|
+
kind?: SSEOnlyRouteKind;
|
|
338
380
|
/**
|
|
339
381
|
* Async preHandler hook for authentication/authorization.
|
|
340
382
|
* Runs BEFORE the SSE connection is established.
|
|
@@ -380,12 +422,18 @@ export type FastifySSERouteOptions = {
|
|
|
380
422
|
*/
|
|
381
423
|
serializer?: (data: unknown) => string;
|
|
382
424
|
/**
|
|
383
|
-
*
|
|
384
|
-
*
|
|
385
|
-
* Set to
|
|
386
|
-
*
|
|
425
|
+
* Whether the SSE keep-alive heartbeat is enabled for this route.
|
|
426
|
+
*
|
|
427
|
+
* Set to `false` to suppress heartbeat comments on this route entirely.
|
|
428
|
+
*
|
|
429
|
+
* The heartbeat *interval* is not configurable per route: `@fastify/sse`
|
|
430
|
+
* only exposes a boolean at route level. Configure the interval once for all
|
|
431
|
+
* routes when registering the plugin:
|
|
432
|
+
* `app.register(fastifySSE, { heartbeatInterval: 30000 })`.
|
|
433
|
+
*
|
|
434
|
+
* @default true
|
|
387
435
|
*/
|
|
388
|
-
|
|
436
|
+
heartbeat?: boolean;
|
|
389
437
|
/**
|
|
390
438
|
* Maps contract metadata to additional Fastify route options.
|
|
391
439
|
*
|
|
@@ -574,12 +622,29 @@ export type DualModeHandlers<Params = unknown, Query = unknown, Headers = unknow
|
|
|
574
622
|
* Options for configuring a dual-mode route.
|
|
575
623
|
* Extends SSE route options with JSON-specific options.
|
|
576
624
|
*/
|
|
577
|
-
export type FastifyDualModeRouteOptions = FastifySSERouteOptions & {
|
|
625
|
+
export type FastifyDualModeRouteOptions = Omit<FastifySSERouteOptions, 'kind'> & {
|
|
578
626
|
/**
|
|
579
627
|
* Default mode when Accept header doesn't specify preference.
|
|
580
628
|
* @default 'json'
|
|
581
629
|
*/
|
|
582
630
|
defaultMode?: DualModeType;
|
|
631
|
+
/**
|
|
632
|
+
* `@fastify/sse` route kind, controlling how the plugin negotiates the `Accept` header.
|
|
633
|
+
*
|
|
634
|
+
* - `'manual'` (default): no plugin-side negotiation. `reply.sse` is always attached and
|
|
635
|
+
* the route's own `determineMode()` picks the mode, honouring {@link defaultMode}.
|
|
636
|
+
* - `'dual'`: the plugin gates first, and only an explicit `text/event-stream` token
|
|
637
|
+
* admits SSE. Everything else reaches the handler with `reply.sse` undefined, so this
|
|
638
|
+
* is only sound with `defaultMode: 'json'` - the two negotiators would otherwise
|
|
639
|
+
* disagree and the SSE branch would run without a stream. `buildFastifyRoute` rejects
|
|
640
|
+
* that combination at route-build time.
|
|
641
|
+
*
|
|
642
|
+
* `'only'` is not offered: it answers non-SSE clients with `406` before the handler runs,
|
|
643
|
+
* which would make the JSON half of the route unreachable.
|
|
644
|
+
*
|
|
645
|
+
* @default 'manual'
|
|
646
|
+
*/
|
|
647
|
+
kind?: DualModeRouteKind;
|
|
583
648
|
};
|
|
584
649
|
/**
|
|
585
650
|
* Infer handlers type based on contract type.
|
|
@@ -752,12 +817,22 @@ export declare function buildHandler<Contract extends AnyDualModeContractDefinit
|
|
|
752
817
|
*/
|
|
753
818
|
export type RegisterSSERoutesOptions = {
|
|
754
819
|
/**
|
|
755
|
-
*
|
|
756
|
-
*
|
|
820
|
+
* Whether the SSE keep-alive heartbeat is enabled for the registered routes.
|
|
821
|
+
*
|
|
822
|
+
* Set to `false` to suppress heartbeat comments. Routes that set `heartbeat`
|
|
823
|
+
* themselves keep their own value.
|
|
824
|
+
*
|
|
825
|
+
* The heartbeat *interval* is not configurable per route: `@fastify/sse`
|
|
826
|
+
* only exposes a boolean at route level. Configure the interval once for all
|
|
827
|
+
* routes when registering the plugin:
|
|
828
|
+
* `app.register(fastifySSE, { heartbeatInterval: 30000 })`.
|
|
829
|
+
*
|
|
830
|
+
* @default true
|
|
757
831
|
*/
|
|
758
|
-
|
|
832
|
+
heartbeat?: boolean;
|
|
759
833
|
/**
|
|
760
834
|
* Custom serializer for SSE message data.
|
|
835
|
+
* Routes that set `serializer` themselves keep their own value.
|
|
761
836
|
* @default JSON.stringify
|
|
762
837
|
*/
|
|
763
838
|
serializer?: (data: unknown) => string;
|
|
@@ -787,12 +862,22 @@ export type RegisterSSERoutesOptions = {
|
|
|
787
862
|
*/
|
|
788
863
|
export type RegisterDualModeRoutesOptions = {
|
|
789
864
|
/**
|
|
790
|
-
*
|
|
791
|
-
*
|
|
865
|
+
* Whether the SSE keep-alive heartbeat is enabled for the registered routes.
|
|
866
|
+
*
|
|
867
|
+
* Set to `false` to suppress heartbeat comments in SSE mode. Routes that set
|
|
868
|
+
* `heartbeat` themselves keep their own value.
|
|
869
|
+
*
|
|
870
|
+
* The heartbeat *interval* is not configurable per route: `@fastify/sse`
|
|
871
|
+
* only exposes a boolean at route level. Configure the interval once for all
|
|
872
|
+
* routes when registering the plugin:
|
|
873
|
+
* `app.register(fastifySSE, { heartbeatInterval: 30000 })`.
|
|
874
|
+
*
|
|
875
|
+
* @default true
|
|
792
876
|
*/
|
|
793
|
-
|
|
877
|
+
heartbeat?: boolean;
|
|
794
878
|
/**
|
|
795
879
|
* Custom serializer for SSE message data.
|
|
880
|
+
* Routes that set `serializer` themselves keep their own value.
|
|
796
881
|
* @default JSON.stringify
|
|
797
882
|
*/
|
|
798
883
|
serializer?: (data: unknown) => string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fastifyRouteTypes.js","sourceRoot":"","sources":["../../../lib/routes/fastifyRouteTypes.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"fastifyRouteTypes.js","sourceRoot":"","sources":["../../../lib/routes/fastifyRouteTypes.ts"],"names":[],"mappings":"AAmgCA,MAAM,UAAU,YAAY,CAG1B,QAAkB,EAClB,QAAuC,EACvC,OAA8D;IAE9D,6FAA6F;IAC7F,IAAI,YAAY,IAAI,QAAQ,IAAI,QAAQ,CAAC,UAAU,EAAE,CAAC;QACpD,OAAO;YACL,MAAM,EAAE,sBAAsB;YAC9B,QAAQ,EAAE,QAAyC;YACnD,QAAQ,EAAE,QAAgE;YAC1E,OAAO,EAAE,OAAsC;SAChD,CAAA;IACH,CAAC;IAED,oBAAoB;IACpB,OAAO;QACL,MAAM,EAAE,iBAAiB;QACzB,QAAQ,EAAE,QAAoC;QAC9C,4GAA4G;QAC5G,QAAQ,EAAE,QAAe;QACzB,OAAO,EAAE,OAAiC;KAC3C,CAAA;AACH,CAAC"}
|
|
@@ -135,8 +135,12 @@ function closeSSESession(sseReply, controller, connectionId, logger) {
|
|
|
135
135
|
sseReply.sse.close();
|
|
136
136
|
}
|
|
137
137
|
catch (err) {
|
|
138
|
-
|
|
139
|
-
|
|
138
|
+
// Never let the recovery path throw: this runs from error handling, and an exception
|
|
139
|
+
// raised here would replace the error we are recovering from with a far less useful one.
|
|
140
|
+
// `sseReply.sse` itself can be undefined - the plugin only attaches it when its Accept
|
|
141
|
+
// gate admits SSE - so read `isConnected` defensively rather than dereferencing blind.
|
|
142
|
+
if (sseReply.sse?.isConnected !== false) {
|
|
143
|
+
// Log error if connection closure failed and the connection is not known to be closed
|
|
140
144
|
logger?.error({
|
|
141
145
|
connectionId,
|
|
142
146
|
error: isErrorLike(err) ? err.message : 'Internal server error',
|
|
@@ -283,12 +287,18 @@ export function createSSEContext(controller, request, reply, eventSchemas, optio
|
|
|
283
287
|
if (responseSent) {
|
|
284
288
|
throw new Error('Cannot start streaming after sending a response.');
|
|
285
289
|
}
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
//
|
|
290
|
+
// Register callback for when server explicitly closes via reply.sse.close().
|
|
291
|
+
// This is the first `reply.sse` dereference, and it runs before `started` flips: if
|
|
292
|
+
// the plugin never attached the SSE context (its Accept gate refused, which the
|
|
293
|
+
// supported route kinds prevent but a JavaScript caller can still reach), the route
|
|
294
|
+
// handler's catch then takes the not-yet-streaming branch and reports the real error
|
|
295
|
+
// instead of trying to tear down a stream that was never set up. Everything after
|
|
296
|
+
// this point may have written to the socket, so it stays inside `started`.
|
|
289
297
|
sseReply.sse.onClose(async () => {
|
|
290
298
|
await callOnClose('server');
|
|
291
299
|
});
|
|
300
|
+
started = true;
|
|
301
|
+
sessionMode = mode;
|
|
292
302
|
// Send headers if not already sent via sendHeaders()
|
|
293
303
|
if (!headersSent) {
|
|
294
304
|
// Tell @fastify/sse to keep the connection open after handler returns
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fastifyRouteUtils.js","sourceRoot":"","sources":["../../../lib/routes/fastifyRouteUtils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;AAKxC,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAA;AA6D9C;;;;;;;;;;;;GAYG;AACH,MAAM,UAAU,mBAAmB,CACjC,YAAwC,EACxC,YAAwC;IAExC,4DAA4D;IAC5D,MAAM,iBAAiB,GAA2B,EAAE,CAAA;IACpD,KAAK,MAAM,GAAG,IAAI,MAAM,CAAC,IAAI,CAAC,YAAY,CAAC,KAAK,CAAC,EAAE,CAAC;QAClD,iBAAiB,CAAC,GAAG,CAAC,GAAG,IAAI,GAAG,EAAE,CAAA;IACpC,CAAC;IACD,OAAO,YAAY,CAAC,iBAAsC,CAAC,CAAA;AAC7D,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,iBAAiB,CAAC,GAAY;IAC5C,IAAI,OAAO,GAAG,KAAK,QAAQ,IAAI,GAAG,KAAK,IAAI,IAAI,CAAC,CAAC,gBAAgB,IAAI,GAAG,CAAC,EAAE,CAAC;QAC1E,OAAO,KAAK,CAAA;IACd,CAAC;IACD,MAAM,UAAU,GAAI,GAAmC,CAAC,cAAc,CAAA;IACtE,OAAO,CACL,OAAO,UAAU,KAAK,QAAQ;QAC9B,MAAM,CAAC,QAAQ,CAAC,UAAU,CAAC;QAC3B,MAAM,CAAC,SAAS,CAAC,UAAU,CAAC;QAC5B,UAAU,IAAI,GAAG;QACjB,UAAU,IAAI,GAAG,CAClB,CAAA;AACH,CAAC;AAED;;GAEG;AACH,MAAM,CAAC,KAAK,UAAU,gBAAgB,CACpC,QAAkB,EAClB,YAA8D;IAE9D,4EAA4E;IAC5E,MAAM,QAAQ,GAAG,YAAmB,CAAA;IACpC,IAAI,OAAO,QAAQ,CAAC,MAAM,CAAC,aAAa,CAAC,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C,UAAU,CAAC,GAAG,QAAQ,GAAG,CAAC,CAAC,CAAA;YAC1F,IAAI,aAAa,EAAE,CAAC;gBAClB,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,WAAW,EAAE,aAAa,EAAE,CAAA;YACrD,CAAC;QACH,CAAC;IACH,CAAC;IAED,wCAAwC;IACxC,IAAI,UAAU,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,SAAS,KAAK,KAAK,CAAC,EAAE,CAAC;QAClD,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,WAAW,EAAE,cAAc,EAAE,CAAA;IACtD,CAAC;IAED,oCAAoC;IACpC,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,WAAW,EAAE,cAAc,EAAE,CAAA;AACtD,CAAC"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
export { buildFastifyRoute, extractPathTemplate } from './fastifyRouteBuilder.js';
|
|
2
|
-
export { type BuildFastifyDualModeRoutesReturnType, type BuildFastifySSERoutesReturnType, buildHandler, type DualModeHandlers, type DualModeRouteHandler, type FastifyDualModeHandlerConfig, type FastifyDualModeRouteOptions, type FastifySSEHandlerConfig, type FastifySSEPreHandler, type FastifySSERouteOptions, type InferDualModeHandlers, type InferHandlers, type InferSSERequest, type RegisterDualModeRoutesOptions, type RegisterSSERoutesOptions, type SSEContext, type SSEHandlerResult, type SSEModeHandler, type SSEOnlyHandlers, type SSERespondResult, type SSERouteHandler, type SSESession, type SSESessionMode, type SSEStartOptions, type SSEStreamMessage, type SyncModeHandler, type SyncModeReply, } from './fastifyRouteTypes.js';
|
|
2
|
+
export { type BuildFastifyDualModeRoutesReturnType, type BuildFastifySSERoutesReturnType, buildHandler, type DualModeHandlers, type DualModeRouteHandler, type DualModeRouteKind, type FastifyDualModeHandlerConfig, type FastifyDualModeRouteOptions, type FastifySSEHandlerConfig, type FastifySSEPreHandler, type FastifySSERouteOptions, type InferDualModeHandlers, type InferHandlers, type InferSSERequest, type RegisterDualModeRoutesOptions, type RegisterSSERoutesOptions, type SSEContext, type SSEHandlerResult, type SSEModeHandler, type SSEOnlyHandlers, type SSEOnlyRouteKind, type SSERespondResult, type SSERouteHandler, type SSESession, type SSESessionMode, type SSEStartOptions, type SSEStreamMessage, type SyncModeHandler, type SyncModeReply, } from './fastifyRouteTypes.js';
|
|
3
3
|
export { createSSEContext, determineMode, determineSyncFormat, handleReconnection, handleSSEError, type SSECloseReason, type SSEContextResult, type SSEControllerLike, type SSELifecycleOptions, type SSEReply, type SSESessionSetupResult, type SyncFormatResult, sendReplayEvents, setupSSESession, } from './fastifyRouteUtils.js';
|
|
4
|
+
export { buildSseEventSchema, buildSseResponseSchemas, type ResponseSchemasByStatusCode, } from './sseResponseSchema.js';
|
package/dist/lib/routes/index.js
CHANGED
|
@@ -6,4 +6,6 @@ export {
|
|
|
6
6
|
buildHandler, } from './fastifyRouteTypes.js';
|
|
7
7
|
// Route utilities
|
|
8
8
|
export { createSSEContext, determineMode, determineSyncFormat, handleReconnection, handleSSEError, sendReplayEvents, setupSSESession, } from './fastifyRouteUtils.js';
|
|
9
|
+
// Response schema helpers
|
|
10
|
+
export { buildSseEventSchema, buildSseResponseSchemas, } from './sseResponseSchema.js';
|
|
9
11
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../lib/routes/index.ts"],"names":[],"mappings":"AAAA,wBAAwB;AACxB,OAAO,EAAE,iBAAiB,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAA;AAEjF,cAAc;AACd,OAAO;AAGL,0BAA0B;AAC1B,YAAY,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../lib/routes/index.ts"],"names":[],"mappings":"AAAA,wBAAwB;AACxB,OAAO,EAAE,iBAAiB,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAA;AAEjF,cAAc;AACd,OAAO;AAGL,0BAA0B;AAC1B,YAAY,GAkCb,MAAM,wBAAwB,CAAA;AAE/B,kBAAkB;AAClB,OAAO,EACL,gBAAgB,EAChB,aAAa,EACb,mBAAmB,EACnB,kBAAkB,EAClB,cAAc,EAQd,gBAAgB,EAChB,eAAe,GAChB,MAAM,wBAAwB,CAAA;AAE/B,0BAA0B;AAC1B,OAAO,EACL,mBAAmB,EACnB,uBAAuB,GAExB,MAAM,wBAAwB,CAAA"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import type { HttpStatusCode, SSEEventSchemas } from '@lokalise/api-contracts';
|
|
2
|
+
import { z } from 'zod';
|
|
3
|
+
/**
|
|
4
|
+
* Fastify response schemas keyed by status code. Values are either a bare Zod schema (JSON)
|
|
5
|
+
* or Fastify's per-media-type form (`{ content: { '<mediaType>': { schema } } }`).
|
|
6
|
+
*/
|
|
7
|
+
export type ResponseSchemasByStatusCode = Record<string, unknown>;
|
|
8
|
+
/**
|
|
9
|
+
* Describe an SSE stream as the union of its event envelopes, following the OpenAPI 3.x
|
|
10
|
+
* convention for `text/event-stream`: one object schema per event type (`{ id?, event, data,
|
|
11
|
+
* retry? }`), discriminated on the `event` name so the contract's event payloads show up in
|
|
12
|
+
* the generated spec as a `oneOf` of envelopes with a `const` event name.
|
|
13
|
+
*
|
|
14
|
+
* Mirrors what `@lokalise/fastify-api-contracts` produces for an `sseBody()` response, so
|
|
15
|
+
* legacy SSE / dual-mode contracts and `ApiContract` ones document the same way.
|
|
16
|
+
*
|
|
17
|
+
* @returns The event envelope schema, or `undefined` when the contract declares no events
|
|
18
|
+
*/
|
|
19
|
+
export declare function buildSseEventSchema(serverSentEventSchemas: SSEEventSchemas): z.ZodTypeAny | undefined;
|
|
20
|
+
/**
|
|
21
|
+
* Build the `schema.response` map for an SSE or dual-mode route from its contract.
|
|
22
|
+
*
|
|
23
|
+
* The 200 entry uses Fastify's per-media-type form so a single status can describe both the
|
|
24
|
+
* event stream and the JSON body: `text/event-stream` carries the event envelopes, and
|
|
25
|
+
* `application/json` carries the sync body (dual-mode), the body the contract declares for
|
|
26
|
+
* 200 (an SSE route that answers `sse.respond(200, ...)` before streaming starts), or both.
|
|
27
|
+
*
|
|
28
|
+
* Populating this drives both the OpenAPI spec and Fastify's serializer, so a status code the
|
|
29
|
+
* contract declares is now serialized against its schema instead of plain `JSON.stringify`.
|
|
30
|
+
*
|
|
31
|
+
* @param serverSentEventSchemas - Contract's event name to payload schema map
|
|
32
|
+
* @param responseBodySchemasByStatusCode - Contract's per-status response schemas, if any
|
|
33
|
+
* @param syncSuccessSchema - Dual-mode sync 2xx body schema; omit for SSE-only contracts
|
|
34
|
+
*/
|
|
35
|
+
export declare function buildSseResponseSchemas(serverSentEventSchemas: SSEEventSchemas, responseBodySchemasByStatusCode: Partial<Record<HttpStatusCode, z.ZodTypeAny>> | undefined, syncSuccessSchema?: z.ZodTypeAny): ResponseSchemasByStatusCode;
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
/**
|
|
3
|
+
* Shape of the error bodies Fastify and the SSE route builders emit themselves, rather than
|
|
4
|
+
* the handler: `FST_ERR_VALIDATION` when a request fails schema validation, whatever an
|
|
5
|
+
* application-level `setErrorHandler` returns, and the `{ statusCode, error, message }`
|
|
6
|
+
* envelope the builders send when a handler throws before streaming starts.
|
|
7
|
+
*
|
|
8
|
+
* A declared status schema is unioned with this so those bodies stay serializable. Without it
|
|
9
|
+
* Fastify serializes them against the handler's schema, fails, and turns a declared 400 or 404
|
|
10
|
+
* into a 500 `FST_ERR_FAILED_ERROR_SERIALIZATION`. Loose so a custom error handler's extra
|
|
11
|
+
* fields survive; `statusCode` and `message` are what keeps it from matching handler bodies.
|
|
12
|
+
* `error` and `code` are listed even though loose mode would carry them anyway, because
|
|
13
|
+
* Fastify defines them as non-enumerable properties that key enumeration would skip.
|
|
14
|
+
*/
|
|
15
|
+
const frameworkErrorSchema = z.looseObject({
|
|
16
|
+
statusCode: z.number(),
|
|
17
|
+
message: z.string(),
|
|
18
|
+
error: z.string().optional(),
|
|
19
|
+
code: z.string().optional(),
|
|
20
|
+
});
|
|
21
|
+
/**
|
|
22
|
+
* Combine alternative body schemas for one status.
|
|
23
|
+
*
|
|
24
|
+
* A single schema is returned as-is rather than wrapped, so a status with only one possible
|
|
25
|
+
* body does not pick up a pointless `anyOf` in the generated spec.
|
|
26
|
+
*
|
|
27
|
+
* @returns The combined schema, or `undefined` when there is nothing to describe
|
|
28
|
+
*/
|
|
29
|
+
function unionOf(schemas) {
|
|
30
|
+
const [first, ...rest] = schemas;
|
|
31
|
+
if (!first) {
|
|
32
|
+
return undefined;
|
|
33
|
+
}
|
|
34
|
+
return rest.length === 0 ? first : z.union(schemas);
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Describe an SSE stream as the union of its event envelopes, following the OpenAPI 3.x
|
|
38
|
+
* convention for `text/event-stream`: one object schema per event type (`{ id?, event, data,
|
|
39
|
+
* retry? }`), discriminated on the `event` name so the contract's event payloads show up in
|
|
40
|
+
* the generated spec as a `oneOf` of envelopes with a `const` event name.
|
|
41
|
+
*
|
|
42
|
+
* Mirrors what `@lokalise/fastify-api-contracts` produces for an `sseBody()` response, so
|
|
43
|
+
* legacy SSE / dual-mode contracts and `ApiContract` ones document the same way.
|
|
44
|
+
*
|
|
45
|
+
* @returns The event envelope schema, or `undefined` when the contract declares no events
|
|
46
|
+
*/
|
|
47
|
+
export function buildSseEventSchema(serverSentEventSchemas) {
|
|
48
|
+
const eventSchemas = Object.entries(serverSentEventSchemas).map(([eventName, dataSchema]) => z.object({
|
|
49
|
+
id: z.string().optional(),
|
|
50
|
+
event: z.literal(eventName),
|
|
51
|
+
data: dataSchema,
|
|
52
|
+
retry: z.int().optional(),
|
|
53
|
+
}));
|
|
54
|
+
const [firstEventSchema, ...restEventSchemas] = eventSchemas;
|
|
55
|
+
if (!firstEventSchema) {
|
|
56
|
+
return undefined;
|
|
57
|
+
}
|
|
58
|
+
return restEventSchemas.length === 0
|
|
59
|
+
? firstEventSchema
|
|
60
|
+
: z.discriminatedUnion('event', [firstEventSchema, ...restEventSchemas]);
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Build the JSON schema for one declared status code.
|
|
64
|
+
*
|
|
65
|
+
* A status's schema has to accept every body the runtime can put out at that status,
|
|
66
|
+
* because Fastify serializes against it and rejects anything that does not match:
|
|
67
|
+
*
|
|
68
|
+
* - 2xx on a dual-mode contract: `handleSyncMode` validates the sync body against
|
|
69
|
+
* `successResponseBodySchema` while `processSSEHandlerResult` validates `sse.respond()`
|
|
70
|
+
* against the contract's schema for that status, so both shapes are possible.
|
|
71
|
+
* - Non-2xx: the handler's declared body, or a framework error envelope.
|
|
72
|
+
*/
|
|
73
|
+
function buildStatusSchema(statusCode, declaredSchema, syncSuccessSchema) {
|
|
74
|
+
const isSuccessStatus = statusCode >= 200 && statusCode < 300;
|
|
75
|
+
if (isSuccessStatus) {
|
|
76
|
+
return unionOf([syncSuccessSchema, declaredSchema].filter((schema) => schema !== undefined));
|
|
77
|
+
}
|
|
78
|
+
return declaredSchema && z.union([declaredSchema, frameworkErrorSchema]);
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Build the `schema.response` map for an SSE or dual-mode route from its contract.
|
|
82
|
+
*
|
|
83
|
+
* The 200 entry uses Fastify's per-media-type form so a single status can describe both the
|
|
84
|
+
* event stream and the JSON body: `text/event-stream` carries the event envelopes, and
|
|
85
|
+
* `application/json` carries the sync body (dual-mode), the body the contract declares for
|
|
86
|
+
* 200 (an SSE route that answers `sse.respond(200, ...)` before streaming starts), or both.
|
|
87
|
+
*
|
|
88
|
+
* Populating this drives both the OpenAPI spec and Fastify's serializer, so a status code the
|
|
89
|
+
* contract declares is now serialized against its schema instead of plain `JSON.stringify`.
|
|
90
|
+
*
|
|
91
|
+
* @param serverSentEventSchemas - Contract's event name to payload schema map
|
|
92
|
+
* @param responseBodySchemasByStatusCode - Contract's per-status response schemas, if any
|
|
93
|
+
* @param syncSuccessSchema - Dual-mode sync 2xx body schema; omit for SSE-only contracts
|
|
94
|
+
*/
|
|
95
|
+
export function buildSseResponseSchemas(serverSentEventSchemas, responseBodySchemasByStatusCode, syncSuccessSchema) {
|
|
96
|
+
const { 200: declaredOkSchema, ...otherStatusSchemas } = responseBodySchemasByStatusCode ?? {};
|
|
97
|
+
const jsonOkSchema = buildStatusSchema(200, declaredOkSchema, syncSuccessSchema);
|
|
98
|
+
const eventSchema = buildSseEventSchema(serverSentEventSchemas);
|
|
99
|
+
const okContent = {
|
|
100
|
+
...(eventSchema && { 'text/event-stream': { schema: eventSchema } }),
|
|
101
|
+
...(jsonOkSchema && { 'application/json': { schema: jsonOkSchema } }),
|
|
102
|
+
};
|
|
103
|
+
const responseSchemas = {};
|
|
104
|
+
if (Object.keys(okContent).length > 0) {
|
|
105
|
+
responseSchemas[200] = { content: okContent };
|
|
106
|
+
}
|
|
107
|
+
for (const [statusCode, declaredSchema] of Object.entries(otherStatusSchemas)) {
|
|
108
|
+
const schema = buildStatusSchema(Number(statusCode), declaredSchema, syncSuccessSchema);
|
|
109
|
+
if (schema) {
|
|
110
|
+
responseSchemas[statusCode] = schema;
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
return responseSchemas;
|
|
114
|
+
}
|
|
115
|
+
//# sourceMappingURL=sseResponseSchema.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sseResponseSchema.js","sourceRoot":"","sources":["../../../lib/routes/sseResponseSchema.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAQvB;;;;;;;;;;;;GAYG;AACH,MAAM,oBAAoB,GAAG,CAAC,CAAC,WAAW,CAAC;IACzC,UAAU,EAAE,CAAC,CAAC,MAAM,EAAE;IACtB,OAAO,EAAE,CAAC,CAAC,MAAM,EAAE;IACnB,KAAK,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IAC5B,IAAI,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