@dads-framework/http 0.4.0 → 0.5.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.
Files changed (55) hide show
  1. package/README.md +90 -1
  2. package/dist/channels/channel-fan-out.d.ts +17 -0
  3. package/dist/channels/channel-fan-out.d.ts.map +1 -0
  4. package/dist/channels/channel-fan-out.js +2 -0
  5. package/dist/channels/channel-fan-out.js.map +1 -0
  6. package/dist/channels/channel-stream-routes.d.ts +33 -0
  7. package/dist/channels/channel-stream-routes.d.ts.map +1 -0
  8. package/dist/channels/channel-stream-routes.js +186 -0
  9. package/dist/channels/channel-stream-routes.js.map +1 -0
  10. package/dist/channels/in-process-channel-fan-out.d.ts +33 -0
  11. package/dist/channels/in-process-channel-fan-out.d.ts.map +1 -0
  12. package/dist/channels/in-process-channel-fan-out.js +115 -0
  13. package/dist/channels/in-process-channel-fan-out.js.map +1 -0
  14. package/dist/channels/index.d.ts +4 -0
  15. package/dist/channels/index.d.ts.map +1 -0
  16. package/dist/channels/index.js +4 -0
  17. package/dist/channels/index.js.map +1 -0
  18. package/dist/http.tsbuildinfo +1 -1
  19. package/dist/live-actions/execute-live-action.d.ts +26 -0
  20. package/dist/live-actions/execute-live-action.d.ts.map +1 -0
  21. package/dist/live-actions/execute-live-action.js +94 -0
  22. package/dist/live-actions/execute-live-action.js.map +1 -0
  23. package/dist/live-actions/index.d.ts +7 -0
  24. package/dist/live-actions/index.d.ts.map +1 -0
  25. package/dist/live-actions/index.js +7 -0
  26. package/dist/live-actions/index.js.map +1 -0
  27. package/dist/live-actions/live-action-registry.d.ts +16 -0
  28. package/dist/live-actions/live-action-registry.d.ts.map +1 -0
  29. package/dist/live-actions/live-action-registry.js +33 -0
  30. package/dist/live-actions/live-action-registry.js.map +1 -0
  31. package/dist/live-actions/live-action-routes.d.ts +69 -0
  32. package/dist/live-actions/live-action-routes.d.ts.map +1 -0
  33. package/dist/live-actions/live-action-routes.js +187 -0
  34. package/dist/live-actions/live-action-routes.js.map +1 -0
  35. package/dist/live-actions/live-action-run-store.d.ts +16 -0
  36. package/dist/live-actions/live-action-run-store.d.ts.map +1 -0
  37. package/dist/live-actions/live-action-run-store.js +47 -0
  38. package/dist/live-actions/live-action-run-store.js.map +1 -0
  39. package/dist/live-actions/live-action.d.ts +65 -0
  40. package/dist/live-actions/live-action.d.ts.map +1 -0
  41. package/dist/live-actions/live-action.js +49 -0
  42. package/dist/live-actions/live-action.js.map +1 -0
  43. package/dist/live-actions/redact-input.d.ts +9 -0
  44. package/dist/live-actions/redact-input.d.ts.map +1 -0
  45. package/dist/live-actions/redact-input.js +88 -0
  46. package/dist/live-actions/redact-input.js.map +1 -0
  47. package/dist/testing/fake-channel-fan-out.d.ts +23 -0
  48. package/dist/testing/fake-channel-fan-out.d.ts.map +1 -0
  49. package/dist/testing/fake-channel-fan-out.js +28 -0
  50. package/dist/testing/fake-channel-fan-out.js.map +1 -0
  51. package/dist/testing/index.d.ts +1 -0
  52. package/dist/testing/index.d.ts.map +1 -1
  53. package/dist/testing/index.js +1 -0
  54. package/dist/testing/index.js.map +1 -1
  55. package/package.json +11 -3
package/README.md CHANGED
@@ -261,7 +261,9 @@ an arbitrary schema) — `res.json()` is `any` and defeats the type walls.
261
261
  - `lib/openapi/` — the generated document. The kit knows how to convert a route table, never which domains exist: nothing here imports a domain contract lib (`@dads-framework/core/contract` is the kit's own vocabulary). The parity golden test that pins the generated document against the committed artifact needs real domain schemas, so it lives with the composition root that already knows them.
262
262
  - `lib/request-log/` — the captured row: `request-record` (pure builder plus the header allowlist), `request-outcome` (what the pipeline learned and the response no longer shows), `capture-request-record` (the `onResponse` hook), `request-log-sink` (the seam `@dads-framework/audit` implements).
263
263
  - `lib/http-errors.ts` — typed failures this library produces while running a route.
264
- - `src/testing/` — `buildTestApp` + typed inject-response helpers.
264
+ - `src/channels/` — auth-checked SSE channel fan-out (`createChannelFanOut`, `InProcessChannelFanOut`, `createChannelStreamRoutes`).
265
+ - `src/live-actions/` — audited operational actions (`defineLiveAction`, `LiveActionRegistry`, `redactActionInput`, `executeLiveAction`, `InMemoryLiveActionRunStore`, `createLiveActionRoutes`).
266
+ - `src/testing/` — `buildTestApp`, `FakeChannelFanOut`, and typed inject-response helpers.
265
267
 
266
268
  ## Protocol mounts — someone else's wire spec
267
269
 
@@ -339,6 +341,93 @@ are private and non-cacheable. A resolver may return a `scopeKey` for its featur
339
341
  evaluator to match against
340
342
  the context being evaluated.
341
343
 
344
+ ## Auth-checked SSE channel fan-out
345
+
346
+ Import `@dads-framework/http/channels` to stream scoped channel deltas over
347
+ Server-Sent Events without exposing unauthorized scopes or channels.
348
+
349
+ - `createChannelFanOut(options?)` builds an `InProcessChannelFanOut` that
350
+ routes `ChannelEnvelope` deltas by `(scopeId, channel)`, isolates throwing or
351
+ rejecting listeners, and removes empty buckets when the last subscriber
352
+ disconnects.
353
+ - `createChannelStreamRoutes(options)` mounts an `sseRoute` behind
354
+ `requireSession()` (default path `/channels/stream`, default query param
355
+ `scopeId`). It validates the query with Zod (`400` on invalid input), checks
356
+ `canAccessScope` before opening (`404` on denial so scope existence never
357
+ leaks), drops channel names outside `allowedChannels`, and evaluates optional
358
+ per-channel `channelAccess` checks both before opening and before delivering
359
+ each published event.
360
+ - `FakeChannelFanOut` from `@dads-framework/http/testing` records published
361
+ events while still delivering live updates to test subscribers.
362
+
363
+ ```ts
364
+ import { createChannelFanOut, createChannelStreamRoutes } from "@dads-framework/http/channels";
365
+
366
+ const fanOut = createChannelFanOut();
367
+ const channelRoutes = createChannelStreamRoutes({
368
+ channelFanOut: fanOut,
369
+ allowedChannels: ["orders.updated", "billing.updated"],
370
+ canAccessScope: {
371
+ check: ({ subject, scopeId }) => Promise.resolve(subject.id === "user-1" && scopeId === "ws-1"),
372
+ },
373
+ });
374
+ ```
375
+
376
+ ## Audited live-environment ops actions
377
+
378
+ An operational escape hatch with no audit trail is a production incident
379
+ waiting for a witness. Import `@dads-framework/http/live-actions` to declare,
380
+ authorize, redact, and record live operational actions behind typed HTTP routes.
381
+
382
+ - `defineLiveAction(spec)` validates action names (`/^[a-z][a-z0-9]*(?:[.-][a-z0-9]+)*$/`),
383
+ descriptions (at least 10 characters), danger levels (`"safe"`, `"cautious"`,
384
+ `"destructive"`), permission declarations, and Zod `inputSchema`.
385
+ - `LiveActionRegistry` registers unique actions and rejects duplicate names.
386
+ - `redactActionInput(value, customRedactor?)` recursively replaces sensitive
387
+ keys (`password`, `secret`, `token`, `apiKey`, `authorization`, `cookie`,
388
+ `privateKey`, `credential`) with `"[REDACTED]"` and handles circular
389
+ references safely.
390
+ - `executeLiveAction(options)` checks authorization before parsing input,
391
+ mints a UUIDv7 run ID, persists a `"running"` row with redacted input in a
392
+ `LiveActionRunStore` (such as `InMemoryLiveActionRunStore`), runs the action,
393
+ and records `"succeeded"` or `"failed"` with `finishedAt`.
394
+ - `createLiveActionRoutes(options)` mounts four session-guarded routes under
395
+ `basePath` (default `"/live-actions"`):
396
+ - `GET /live-actions` — lists only actions the caller is authorized to run.
397
+ - `POST /live-actions/:name/runs` — validates `{ reason, input }`, answers
398
+ `404` for unknown or unauthorized actions, and returns `201` with the run
399
+ record.
400
+ - `GET /live-actions/runs` — lists recent runs filtered to actions the caller
401
+ is authorized to run (`?actionName=&limit=`).
402
+ - `GET /live-actions/runs/:runId` — reads one run, answering `404` when
403
+ missing or unauthorized for that run's action.
404
+
405
+ ```ts
406
+ import { permissionToken } from "@dads-framework/access";
407
+ import {
408
+ createLiveActionRegistry,
409
+ createLiveActionRoutes,
410
+ defineLiveAction,
411
+ InMemoryLiveActionRunStore,
412
+ } from "@dads-framework/http/live-actions";
413
+ import { z } from "zod";
414
+
415
+ const clearCache = defineLiveAction({
416
+ name: "cache.clear",
417
+ description: "Clear cached entries for a namespace",
418
+ dangerLevel: "safe",
419
+ permission: permissionToken("ops/cache", "clear"),
420
+ inputSchema: z.strictObject({ namespace: z.string().min(1) }),
421
+ execute: ({ input }) => Promise.resolve({ summary: `Cleared ${input.namespace}` }),
422
+ });
423
+
424
+ const liveActionRoutes = createLiveActionRoutes({
425
+ registry: createLiveActionRegistry([clearCache]),
426
+ store: new InMemoryLiveActionRunStore(),
427
+ authorize: ({ subject }) => Promise.resolve(subject.id === "operator-1"),
428
+ });
429
+ ```
430
+
342
431
  ## What it refuses to do
343
432
 
344
433
  Readiness reports the results of probes supplied by the application.
@@ -0,0 +1,17 @@
1
+ import type { ChannelEnvelope } from "@dads-framework/core/contract";
2
+ export { channelEnvelopeSchema, channelNameSchema, type ChannelEnvelope } from "@dads-framework/core/contract";
3
+ /** Receives published channel envelopes for a subscribed scope and channel. */
4
+ export type ChannelListener = (envelope: ChannelEnvelope) => void | Promise<void>;
5
+ /** Releases a channel subscription; safe to call more than once. */
6
+ export type ChannelUnsubscribe = () => void;
7
+ /**
8
+ * Scope-keyed publish/subscribe bus for live channel updates.
9
+ *
10
+ * Implementations deliver envelopes only to listeners subscribed to both the
11
+ * matching `scopeId` and `envelope.channel`.
12
+ */
13
+ export type ChannelFanOut = {
14
+ publish(scopeId: string, envelope: ChannelEnvelope): void;
15
+ subscribe(scopeId: string, channels: readonly string[], listener: ChannelListener): ChannelUnsubscribe;
16
+ };
17
+ //# sourceMappingURL=channel-fan-out.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"channel-fan-out.d.ts","sourceRoot":"","sources":["../../src/channels/channel-fan-out.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAC;AAErE,OAAO,EAAE,qBAAqB,EAAE,iBAAiB,EAAE,KAAK,eAAe,EAAE,MAAM,+BAA+B,CAAC;AAE/G,+EAA+E;AAC/E,MAAM,MAAM,eAAe,GAAG,CAAC,QAAQ,EAAE,eAAe,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;AAElF,oEAAoE;AACpE,MAAM,MAAM,kBAAkB,GAAG,MAAM,IAAI,CAAC;AAE5C;;;;;GAKG;AACH,MAAM,MAAM,aAAa,GAAG;IAC1B,OAAO,CAAC,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,eAAe,GAAG,IAAI,CAAC;IAC1D,SAAS,CAAC,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,SAAS,MAAM,EAAE,EAAE,QAAQ,EAAE,eAAe,GAAG,kBAAkB,CAAC;CACxG,CAAC"}
@@ -0,0 +1,2 @@
1
+ export { channelEnvelopeSchema, channelNameSchema } from "@dads-framework/core/contract";
2
+ //# sourceMappingURL=channel-fan-out.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"channel-fan-out.js","sourceRoot":"","sources":["../../src/channels/channel-fan-out.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,qBAAqB,EAAE,iBAAiB,EAAwB,MAAM,+BAA+B,CAAC"}
@@ -0,0 +1,33 @@
1
+ import { type HttpRoute } from "../lib/route/route-group.js";
2
+ import type { ChannelFanOut } from "./channel-fan-out.js";
3
+ export type ChannelAccessSubject = {
4
+ readonly type: string;
5
+ readonly id: string;
6
+ };
7
+ export type ChannelAccessCheckInput = {
8
+ readonly subject: ChannelAccessSubject;
9
+ readonly scopeId: string;
10
+ readonly channel?: string;
11
+ };
12
+ export type ChannelAccessCheck = {
13
+ check(input: ChannelAccessCheckInput): Promise<boolean>;
14
+ };
15
+ export type ChannelStreamRoutesOptions = {
16
+ readonly channelFanOut: ChannelFanOut;
17
+ readonly canAccessScope: ChannelAccessCheck;
18
+ readonly channelAccess?: ReadonlyMap<string, ChannelAccessCheck>;
19
+ readonly allowedChannels: readonly string[];
20
+ readonly path?: string;
21
+ readonly scopeQueryParam?: string;
22
+ readonly heartbeatMs?: number;
23
+ };
24
+ /**
25
+ * Create the auth-checked SSE route group for streaming channel envelopes.
26
+ *
27
+ * Scope access is verified before the stream opens (denied callers receive 404
28
+ * without leaking whether the scope exists). Channels with an entry in
29
+ * `channelAccess` are checked both before opening and before delivering each
30
+ * published envelope.
31
+ */
32
+ export declare function createChannelStreamRoutes(options: ChannelStreamRoutesOptions): HttpRoute[];
33
+ //# sourceMappingURL=channel-stream-routes.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"channel-stream-routes.d.ts","sourceRoot":"","sources":["../../src/channels/channel-stream-routes.ts"],"names":[],"mappings":"AASA,OAAO,EAAc,KAAK,SAAS,EAAE,MAAM,6BAA6B,CAAC;AAEzE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAK1D,MAAM,MAAM,oBAAoB,GAAG;IACjC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;CACrB,CAAC;AAEF,MAAM,MAAM,uBAAuB,GAAG;IACpC,QAAQ,CAAC,OAAO,EAAE,oBAAoB,CAAC;IACvC,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAC;CAC3B,CAAC;AAEF,MAAM,MAAM,kBAAkB,GAAG;IAC/B,KAAK,CAAC,KAAK,EAAE,uBAAuB,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;CACzD,CAAC;AAEF,MAAM,MAAM,0BAA0B,GAAG;IACvC,QAAQ,CAAC,aAAa,EAAE,aAAa,CAAC;IACtC,QAAQ,CAAC,cAAc,EAAE,kBAAkB,CAAC;IAC5C,QAAQ,CAAC,aAAa,CAAC,EAAE,WAAW,CAAC,MAAM,EAAE,kBAAkB,CAAC,CAAC;IACjE,QAAQ,CAAC,eAAe,EAAE,SAAS,MAAM,EAAE,CAAC;IAC5C,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,eAAe,CAAC,EAAE,MAAM,CAAC;IAClC,QAAQ,CAAC,WAAW,CAAC,EAAE,MAAM,CAAC;CAC/B,CAAC;AA0LF;;;;;;;GAOG;AACH,wBAAgB,yBAAyB,CAAC,OAAO,EAAE,0BAA0B,GAAG,SAAS,EAAE,CAgB1F"}
@@ -0,0 +1,186 @@
1
+ import { z } from "zod";
2
+ import { ACCESS_REFUSAL_HEADER, ACCESS_REFUSAL_VALUE } from "@dads-framework/core/contract";
3
+ import { HttpWiringError, RequestValidationError } from "../lib/http-errors.js";
4
+ import { requireSession } from "../lib/route/access.js";
5
+ import { routeGroup } from "../lib/route/route-group.js";
6
+ import { sseRoute } from "../lib/route/sse-route.js";
7
+ const DEFAULT_CHANNEL_STREAM_PATH = "/channels/stream";
8
+ const DEFAULT_SCOPE_QUERY_PARAM = "scopeId";
9
+ function sendNotFoundRefusal(reply) {
10
+ void reply
11
+ .status(404)
12
+ .header(ACCESS_REFUSAL_HEADER, ACCESS_REFUSAL_VALUE)
13
+ .send({
14
+ error: { code: "RESOURCE_NOT_FOUND", message: "Resource not found" },
15
+ });
16
+ }
17
+ function validateStreamConfig(path, scopeQueryParam) {
18
+ if (!path.startsWith("/") || path.startsWith("//")) {
19
+ throw new HttpWiringError(`Channel stream path must be mount-relative, received "${path}"`);
20
+ }
21
+ if (scopeQueryParam.trim().length === 0 || scopeQueryParam === "channels") {
22
+ throw new HttpWiringError(`Invalid channel stream scopeQueryParam "${scopeQueryParam}"`);
23
+ }
24
+ }
25
+ function parseStreamQuery(rawQuery, scopeQueryParam) {
26
+ const schema = z.strictObject({
27
+ [scopeQueryParam]: z.string().trim().min(1),
28
+ channels: z.union([z.string(), z.array(z.string())]).optional(),
29
+ });
30
+ const parsed = schema.safeParse(rawQuery ?? {});
31
+ if (!parsed.success) {
32
+ throw new RequestValidationError("query", parsed.error);
33
+ }
34
+ const scopeValue = parsed.data[scopeQueryParam];
35
+ if (typeof scopeValue !== "string") {
36
+ throw new HttpWiringError(`Channel stream scope query param "${scopeQueryParam}" did not parse as string`);
37
+ }
38
+ return { scopeId: scopeValue, rawChannels: parsed.data["channels"] };
39
+ }
40
+ function resolveRequestedChannels(rawChannels, allowedSet, allowedChannels) {
41
+ if (rawChannels === undefined) {
42
+ return { explicit: false, channels: [...allowedChannels] };
43
+ }
44
+ const entries = typeof rawChannels === "string" ? [rawChannels] : rawChannels;
45
+ const requested = entries
46
+ .flatMap((entry) => entry.split(","))
47
+ .map((entry) => entry.trim())
48
+ .filter((entry) => entry.length > 0 && allowedSet.has(entry));
49
+ return { explicit: true, channels: [...new Set(requested)] };
50
+ }
51
+ async function filterPermittedChannels(input) {
52
+ if (input.channelAccess === undefined) {
53
+ return input.channels;
54
+ }
55
+ const permitted = [];
56
+ for (const channel of input.channels) {
57
+ const check = input.channelAccess.get(channel);
58
+ if (check === undefined) {
59
+ permitted.push(channel);
60
+ continue;
61
+ }
62
+ const allowed = await check.check({ subject: input.subject, scopeId: input.scopeId, channel });
63
+ if (allowed) {
64
+ permitted.push(channel);
65
+ }
66
+ else if (input.explicit) {
67
+ return null;
68
+ }
69
+ }
70
+ if (!input.explicit && input.channels.length > 0 && permitted.length === 0) {
71
+ return null;
72
+ }
73
+ return permitted;
74
+ }
75
+ function createDeliveryListener(input) {
76
+ return async (envelope) => {
77
+ if (input.isClosed()) {
78
+ return;
79
+ }
80
+ const check = input.channelAccess?.get(envelope.channel);
81
+ if (check !== undefined) {
82
+ const allowed = await check.check({
83
+ subject: input.subject,
84
+ scopeId: input.scopeId,
85
+ channel: envelope.channel,
86
+ });
87
+ if (!allowed || input.isClosed()) {
88
+ return;
89
+ }
90
+ }
91
+ input.stream.send(envelope);
92
+ };
93
+ }
94
+ function buildStreamOpenApi(scopeQueryParam) {
95
+ return {
96
+ parameters: [
97
+ {
98
+ name: scopeQueryParam,
99
+ in: "query",
100
+ required: true,
101
+ schema: { type: "string", minLength: 1 },
102
+ description: "Scope identifier whose channels should be streamed",
103
+ },
104
+ {
105
+ name: "channels",
106
+ in: "query",
107
+ required: false,
108
+ schema: { type: "string" },
109
+ description: "Optional comma-separated subset of allowed channels to subscribe to",
110
+ },
111
+ ],
112
+ responses: {
113
+ "200": {
114
+ description: "Server-Sent Events channel stream",
115
+ content: { "text/event-stream": { schema: { type: "string" } } },
116
+ },
117
+ "400": { description: "Invalid query parameters" },
118
+ "401": { description: "Authentication required" },
119
+ "404": { description: "Scope or channel not found" },
120
+ },
121
+ };
122
+ }
123
+ async function handleChannelStream(ctx, options, scopeQueryParam, allowedSet) {
124
+ const { subject, request, reply, open } = ctx;
125
+ if (subject === null) {
126
+ throw new HttpWiringError("Channel stream route ran without an authenticated subject");
127
+ }
128
+ const { scopeId, rawChannels } = parseStreamQuery(request.query, scopeQueryParam);
129
+ const scopeAllowed = await options.canAccessScope.check({ subject, scopeId });
130
+ if (!scopeAllowed) {
131
+ sendNotFoundRefusal(reply);
132
+ return;
133
+ }
134
+ const selection = resolveRequestedChannels(rawChannels, allowedSet, options.allowedChannels);
135
+ const permittedChannels = await filterPermittedChannels({
136
+ subject,
137
+ scopeId,
138
+ channels: selection.channels,
139
+ explicit: selection.explicit,
140
+ channelAccess: options.channelAccess,
141
+ });
142
+ if (permittedChannels === null) {
143
+ sendNotFoundRefusal(reply);
144
+ return;
145
+ }
146
+ open((stream) => {
147
+ let closed = false;
148
+ const listener = createDeliveryListener({
149
+ subject,
150
+ scopeId,
151
+ stream,
152
+ channelAccess: options.channelAccess,
153
+ isClosed: () => closed,
154
+ });
155
+ const unsubscribe = options.channelFanOut.subscribe(scopeId, permittedChannels, listener);
156
+ return () => {
157
+ closed = true;
158
+ unsubscribe();
159
+ };
160
+ });
161
+ }
162
+ /**
163
+ * Create the auth-checked SSE route group for streaming channel envelopes.
164
+ *
165
+ * Scope access is verified before the stream opens (denied callers receive 404
166
+ * without leaking whether the scope exists). Channels with an entry in
167
+ * `channelAccess` are checked both before opening and before delivering each
168
+ * published envelope.
169
+ */
170
+ export function createChannelStreamRoutes(options) {
171
+ const path = options.path ?? DEFAULT_CHANNEL_STREAM_PATH;
172
+ const scopeQueryParam = options.scopeQueryParam ?? DEFAULT_SCOPE_QUERY_PARAM;
173
+ validateStreamConfig(path, scopeQueryParam);
174
+ const allowedSet = new Set(options.allowedChannels);
175
+ return routeGroup("Channels", [
176
+ sseRoute({
177
+ path,
178
+ summary: "Stream authorized channel events over Server-Sent Events",
179
+ access: requireSession(),
180
+ ...(options.heartbeatMs === undefined ? {} : { heartbeatMs: options.heartbeatMs }),
181
+ openapi: buildStreamOpenApi(scopeQueryParam),
182
+ handler: (ctx) => handleChannelStream(ctx, options, scopeQueryParam, allowedSet),
183
+ }),
184
+ ]);
185
+ }
186
+ //# sourceMappingURL=channel-stream-routes.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"channel-stream-routes.js","sourceRoot":"","sources":["../../src/channels/channel-stream-routes.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAGxB,OAAO,EAAE,qBAAqB,EAAE,oBAAoB,EAAwB,MAAM,+BAA+B,CAAC;AAElH,OAAO,EAAE,eAAe,EAAE,sBAAsB,EAAE,MAAM,uBAAuB,CAAC;AAChF,OAAO,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AAExD,OAAO,EAAE,UAAU,EAAkB,MAAM,6BAA6B,CAAC;AACzE,OAAO,EAAE,QAAQ,EAAwC,MAAM,2BAA2B,CAAC;AAG3F,MAAM,2BAA2B,GAAG,kBAAkB,CAAC;AACvD,MAAM,yBAAyB,GAAG,SAAS,CAAC;AA2B5C,SAAS,mBAAmB,CAAC,KAAmB;IAC9C,KAAK,KAAK;SACP,MAAM,CAAC,GAAG,CAAC;SACX,MAAM,CAAC,qBAAqB,EAAE,oBAAoB,CAAC;SACnD,IAAI,CAAC;QACJ,KAAK,EAAE,EAAE,IAAI,EAAE,oBAAoB,EAAE,OAAO,EAAE,oBAAoB,EAAE;KACrE,CAAC,CAAC;AACP,CAAC;AAED,SAAS,oBAAoB,CAAC,IAAY,EAAE,eAAuB;IACjE,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,IAAI,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,EAAE,CAAC;QACnD,MAAM,IAAI,eAAe,CAAC,yDAAy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AAE,0DAA0D;YACnE,MAAM,EAAE,cAAc,EAAE;YACxB,GAAG,CAAC,OAAO,CAAC,WAAW,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,WAAW,EAAE,OAAO,CAAC,WAAW,EAAE,CAAC;YAClF,OAAO,EAAE,kBAAkB,CAAC,eAAe,CAAC;YAC5C,OAAO,EAAE,CAAC,GAAG,EAAE,EAAE,CAAC,mBAAmB,CAAC,GAAG,EAAE,OAAO,EAAE,eAAe,EAAE,UAAU,CAAC;SACjF,CAAC;KACH,CAAC,CAAC;AACL,CAAC"}
@@ -0,0 +1,33 @@
1
+ import type { ChannelEnvelope } from "@dads-framework/core/contract";
2
+ import type { ChannelFanOut, ChannelListener, ChannelUnsubscribe } from "./channel-fan-out.js";
3
+ /** Minimal structural logger for reporting isolated channel listener failures. */
4
+ export type ChannelFanOutLog = {
5
+ warn(obj: object, msg?: string): void;
6
+ error(obj: object, msg?: string): void;
7
+ };
8
+ export type InProcessChannelFanOutOptions = {
9
+ readonly log?: ChannelFanOutLog;
10
+ };
11
+ /**
12
+ * Single-process implementation of {@link ChannelFanOut}.
13
+ *
14
+ * Listener failures are isolated and reported via `options.log`, and empty
15
+ * channel/scope buckets are removed automatically when the last subscriber
16
+ * disconnects.
17
+ */
18
+ export declare class InProcessChannelFanOut implements ChannelFanOut {
19
+ private readonly log;
20
+ private readonly subscriptionsByScope;
21
+ private readonly listenersByScopeChannel;
22
+ constructor(options?: InProcessChannelFanOutOptions);
23
+ publish(scopeId: string, envelope: ChannelEnvelope): void;
24
+ subscribe(scopeId: string, channels: readonly string[], listener: ChannelListener): ChannelUnsubscribe;
25
+ subscriberCount(scopeId?: string): number;
26
+ private addSubscription;
27
+ private removeSubscription;
28
+ private removeChannelSubscription;
29
+ private invokeListener;
30
+ }
31
+ /** Create an in-process channel fan-out bus. */
32
+ export declare function createChannelFanOut(options?: InProcessChannelFanOutOptions): InProcessChannelFanOut;
33
+ //# sourceMappingURL=in-process-channel-fan-out.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"in-process-channel-fan-out.d.ts","sourceRoot":"","sources":["../../src/channels/in-process-channel-fan-out.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAC;AAErE,OAAO,KAAK,EAAE,aAAa,EAAE,eAAe,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAE/F,kFAAkF;AAClF,MAAM,MAAM,gBAAgB,GAAG;IAC7B,IAAI,CAAC,GAAG,EAAE,MAAM,EAAE,GAAG,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACtC,KAAK,CAAC,GAAG,EAAE,MAAM,EAAE,GAAG,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CACxC,CAAC;AAEF,MAAM,MAAM,6BAA6B,GAAG;IAC1C,QAAQ,CAAC,GAAG,CAAC,EAAE,gBAAgB,CAAC;CACjC,CAAC;AAQF;;;;;;GAMG;AACH,qBAAa,sBAAuB,YAAW,aAAa;IAC1D,OAAO,CAAC,QAAQ,CAAC,GAAG,CAA+B;IACnD,OAAO,CAAC,QAAQ,CAAC,oBAAoB,CAA+C;IACpF,OAAO,CAAC,QAAQ,CAAC,uBAAuB,CAA4D;IAEpG,YAAY,OAAO,GAAE,6BAAkC,EAEtD;IAED,OAAO,CAAC,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,eAAe,GAAG,IAAI,CAQxD;IAED,SAAS,CAAC,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,SAAS,MAAM,EAAE,EAAE,QAAQ,EAAE,eAAe,GAAG,kBAAkB,CAmBrG;IAED,eAAe,CAAC,OAAO,CAAC,EAAE,MAAM,GAAG,MAAM,CASxC;IAED,OAAO,CAAC,eAAe;IAevB,OAAO,CAAC,kBAAkB;IAsB1B,OAAO,CAAC,yBAAyB;IAejC,OAAO,CAAC,cAAc;CAevB;AAED,gDAAgD;AAChD,wBAAgB,mBAAmB,CAAC,OAAO,CAAC,EAAE,6BAA6B,GAAG,sBAAsB,CAEnG"}
@@ -0,0 +1,115 @@
1
+ /**
2
+ * Single-process implementation of {@link ChannelFanOut}.
3
+ *
4
+ * Listener failures are isolated and reported via `options.log`, and empty
5
+ * channel/scope buckets are removed automatically when the last subscriber
6
+ * disconnects.
7
+ */
8
+ export class InProcessChannelFanOut {
9
+ log;
10
+ subscriptionsByScope = new Map();
11
+ listenersByScopeChannel = new Map();
12
+ constructor(options = {}) {
13
+ this.log = options.log;
14
+ }
15
+ publish(scopeId, envelope) {
16
+ const subscribers = this.listenersByScopeChannel.get(scopeId)?.get(envelope.channel);
17
+ if (subscribers === undefined) {
18
+ return;
19
+ }
20
+ for (const subscription of [...subscribers]) {
21
+ this.invokeListener(scopeId, envelope, subscription.listener);
22
+ }
23
+ }
24
+ subscribe(scopeId, channels, listener) {
25
+ const uniqueChannels = [...new Set(channels)];
26
+ if (uniqueChannels.length === 0) {
27
+ return () => undefined;
28
+ }
29
+ const subscription = {
30
+ scopeId,
31
+ channels: uniqueChannels,
32
+ listener,
33
+ };
34
+ this.addSubscription(subscription);
35
+ let active = true;
36
+ return () => {
37
+ if (!active) {
38
+ return;
39
+ }
40
+ active = false;
41
+ this.removeSubscription(subscription);
42
+ };
43
+ }
44
+ subscriberCount(scopeId) {
45
+ if (scopeId !== undefined) {
46
+ return this.subscriptionsByScope.get(scopeId)?.size ?? 0;
47
+ }
48
+ let total = 0;
49
+ for (const set of this.subscriptionsByScope.values()) {
50
+ total += set.size;
51
+ }
52
+ return total;
53
+ }
54
+ addSubscription(subscription) {
55
+ const { scopeId, channels } = subscription;
56
+ const scopeSubscriptions = this.subscriptionsByScope.get(scopeId) ?? new Set();
57
+ scopeSubscriptions.add(subscription);
58
+ this.subscriptionsByScope.set(scopeId, scopeSubscriptions);
59
+ const byChannel = this.listenersByScopeChannel.get(scopeId) ?? new Map();
60
+ for (const channel of channels) {
61
+ const channelSet = byChannel.get(channel) ?? new Set();
62
+ channelSet.add(subscription);
63
+ byChannel.set(channel, channelSet);
64
+ }
65
+ this.listenersByScopeChannel.set(scopeId, byChannel);
66
+ }
67
+ removeSubscription(subscription) {
68
+ const { scopeId, channels } = subscription;
69
+ const scopeSubscriptions = this.subscriptionsByScope.get(scopeId);
70
+ if (scopeSubscriptions !== undefined) {
71
+ scopeSubscriptions.delete(subscription);
72
+ if (scopeSubscriptions.size === 0) {
73
+ this.subscriptionsByScope.delete(scopeId);
74
+ }
75
+ }
76
+ const byChannel = this.listenersByScopeChannel.get(scopeId);
77
+ if (byChannel === undefined) {
78
+ return;
79
+ }
80
+ for (const channel of channels) {
81
+ this.removeChannelSubscription(byChannel, channel, subscription);
82
+ }
83
+ if (byChannel.size === 0) {
84
+ this.listenersByScopeChannel.delete(scopeId);
85
+ }
86
+ }
87
+ removeChannelSubscription(byChannel, channel, subscription) {
88
+ const channelSet = byChannel.get(channel);
89
+ if (channelSet === undefined) {
90
+ return;
91
+ }
92
+ channelSet.delete(subscription);
93
+ if (channelSet.size === 0) {
94
+ byChannel.delete(channel);
95
+ }
96
+ }
97
+ invokeListener(scopeId, envelope, listener) {
98
+ try {
99
+ const result = listener(envelope);
100
+ if (result instanceof Promise) {
101
+ void result.catch((error) => {
102
+ this.log?.error({ scopeId, channel: envelope.channel, err: error }, "channel subscriber failed asynchronously");
103
+ });
104
+ }
105
+ }
106
+ catch (error) {
107
+ this.log?.error({ scopeId, channel: envelope.channel, err: error }, "channel subscriber threw synchronously");
108
+ }
109
+ }
110
+ }
111
+ /** Create an in-process channel fan-out bus. */
112
+ export function createChannelFanOut(options) {
113
+ return new InProcessChannelFanOut(options);
114
+ }
115
+ //# sourceMappingURL=in-process-channel-fan-out.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"in-process-channel-fan-out.js","sourceRoot":"","sources":["../../src/channels/in-process-channel-fan-out.ts"],"names":[],"mappings":"AAoBA;;;;;;GAMG;AACH,MAAM,OAAO,sBAAsB;IAChB,GAAG,CAA+B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,OAAO,EAAE,CAAC;gBAC9B,KAAK,MAAM,CAAC,KAAK,CAAC,CAAC,KAAc,EAAE,EAAE;oBACnC,IAAI,CAAC,GAAG,EAAE,KAAK,CACb,EAAE,OAAO,EAAE,OAAO,EAAE,QAAQ,CAAC,OAAO,EAAE,GAAG,EAAE,KAAK,EAAE,EAClD,0CAA0C,CAC3C,CAAC;gBACJ,CAAC,CAAC,CAAC;YACL,CAAC;QACH,CAAC;QAAC,OAAO,KAAc,EAAE,CAAC;YACxB,IAAI,CAAC,GAAG,EAAE,KAAK,CAAC,EAAE,OAAO,EAAE,OAAO,EAAE,QAAQ,CAAC,OAAO,EAAE,GAAG,EAAE,KAAK,EAAE,EAAE,wCAAwC,CAAC,CAAC;QAChH,CAAC;IACH,CAAC;CACF;AAED,gDAAgD;AAChD,MAAM,UAAU,mBAAmB,CAAC,OAAuC;IACzE,OAAO,IAAI,sBAAsB,CAAC,OAAO,CAAC,CAAC;AAC7C,CAAC"}
@@ -0,0 +1,4 @@
1
+ export { channelEnvelopeSchema, channelNameSchema, type ChannelEnvelope, type ChannelFanOut, type ChannelListener, type ChannelUnsubscribe, } from "./channel-fan-out.js";
2
+ export { createChannelFanOut, InProcessChannelFanOut, type ChannelFanOutLog, type InProcessChannelFanOutOptions, } from "./in-process-channel-fan-out.js";
3
+ export { createChannelStreamRoutes, type ChannelAccessCheck, type ChannelAccessCheckInput, type ChannelAccessSubject, type ChannelStreamRoutesOptions, } from "./channel-stream-routes.js";
4
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/channels/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,qBAAqB,EACrB,iBAAiB,EACjB,KAAK,eAAe,EACpB,KAAK,aAAa,EAClB,KAAK,eAAe,EACpB,KAAK,kBAAkB,GACxB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EACL,mBAAmB,EACnB,sBAAsB,EACtB,KAAK,gBAAgB,EACrB,KAAK,6BAA6B,GACnC,MAAM,iCAAiC,CAAC;AACzC,OAAO,EACL,yBAAyB,EACzB,KAAK,kBAAkB,EACvB,KAAK,uBAAuB,EAC5B,KAAK,oBAAoB,EACzB,KAAK,0BAA0B,GAChC,MAAM,4BAA4B,CAAC"}
@@ -0,0 +1,4 @@
1
+ export { channelEnvelopeSchema, channelNameSchema, } from "./channel-fan-out.js";
2
+ export { createChannelFanOut, InProcessChannelFanOut, } from "./in-process-channel-fan-out.js";
3
+ export { createChannelStreamRoutes, } from "./channel-stream-routes.js";
4
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/channels/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,qBAAqB,EACrB,iBAAiB,GAKlB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EACL,mBAAmB,EACnB,sBAAsB,GAGvB,MAAM,iCAAiC,CAAC;AACzC,OAAO,EACL,yBAAyB,GAK1B,MAAM,4BAA4B,CAAC"}