@dads-framework/http 0.0.0-stage → 0.2.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/LICENSE.md +21 -0
- package/README.md +295 -2
- package/dist/http.tsbuildinfo +1 -0
- package/dist/index.d.ts +56 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +37 -0
- package/dist/index.js.map +1 -0
- package/dist/lib/create-http-app.d.ts +108 -0
- package/dist/lib/create-http-app.d.ts.map +1 -0
- package/dist/lib/create-http-app.js +181 -0
- package/dist/lib/create-http-app.js.map +1 -0
- package/dist/lib/http-errors.d.ts +52 -0
- package/dist/lib/http-errors.d.ts.map +1 -0
- package/dist/lib/http-errors.js +66 -0
- package/dist/lib/http-errors.js.map +1 -0
- package/dist/lib/mcp/mcp-tool.d.ts +94 -0
- package/dist/lib/mcp/mcp-tool.d.ts.map +1 -0
- package/dist/lib/mcp/mcp-tool.js +11 -0
- package/dist/lib/mcp/mcp-tool.js.map +1 -0
- package/dist/lib/object-value.d.ts +3 -0
- package/dist/lib/object-value.d.ts.map +1 -0
- package/dist/lib/object-value.js +5 -0
- package/dist/lib/object-value.js.map +1 -0
- package/dist/lib/openapi/build-document.d.ts +27 -0
- package/dist/lib/openapi/build-document.d.ts.map +1 -0
- package/dist/lib/openapi/build-document.js +192 -0
- package/dist/lib/openapi/build-document.js.map +1 -0
- package/dist/lib/openapi/logic/add-discriminators.d.ts +16 -0
- package/dist/lib/openapi/logic/add-discriminators.d.ts.map +1 -0
- package/dist/lib/openapi/logic/add-discriminators.js +235 -0
- package/dist/lib/openapi/logic/add-discriminators.js.map +1 -0
- package/dist/lib/openapi/logic/by-code-point.d.ts +2 -0
- package/dist/lib/openapi/logic/by-code-point.d.ts.map +1 -0
- package/dist/lib/openapi/logic/by-code-point.js +6 -0
- package/dist/lib/openapi/logic/by-code-point.js.map +1 -0
- package/dist/lib/openapi/logic/capitalize-initial.d.ts +2 -0
- package/dist/lib/openapi/logic/capitalize-initial.d.ts.map +1 -0
- package/dist/lib/openapi/logic/capitalize-initial.js +4 -0
- package/dist/lib/openapi/logic/capitalize-initial.js.map +1 -0
- package/dist/lib/openapi/logic/document-record.d.ts +5 -0
- package/dist/lib/openapi/logic/document-record.d.ts.map +1 -0
- package/dist/lib/openapi/logic/document-record.js +14 -0
- package/dist/lib/openapi/logic/document-record.js.map +1 -0
- package/dist/lib/openapi/logic/list-order.d.ts +23 -0
- package/dist/lib/openapi/logic/list-order.d.ts.map +1 -0
- package/dist/lib/openapi/logic/list-order.js +102 -0
- package/dist/lib/openapi/logic/list-order.js.map +1 -0
- package/dist/lib/openapi/logic/open-response-objects.d.ts +14 -0
- package/dist/lib/openapi/logic/open-response-objects.d.ts.map +1 -0
- package/dist/lib/openapi/logic/open-response-objects.js +130 -0
- package/dist/lib/openapi/logic/open-response-objects.js.map +1 -0
- package/dist/lib/openapi/logic/openapi-parts.d.ts +37 -0
- package/dist/lib/openapi/logic/openapi-parts.d.ts.map +1 -0
- package/dist/lib/openapi/logic/openapi-parts.js +243 -0
- package/dist/lib/openapi/logic/openapi-parts.js.map +1 -0
- package/dist/lib/openapi/logic/schema-components.d.ts +5 -0
- package/dist/lib/openapi/logic/schema-components.d.ts.map +1 -0
- package/dist/lib/openapi/logic/schema-components.js +47 -0
- package/dist/lib/openapi/logic/schema-components.js.map +1 -0
- package/dist/lib/request-log/authorization-warning-faults.d.ts +30 -0
- package/dist/lib/request-log/authorization-warning-faults.d.ts.map +1 -0
- package/dist/lib/request-log/authorization-warning-faults.js +35 -0
- package/dist/lib/request-log/authorization-warning-faults.js.map +1 -0
- package/dist/lib/request-log/capture-request-record.d.ts +50 -0
- package/dist/lib/request-log/capture-request-record.d.ts.map +1 -0
- package/dist/lib/request-log/capture-request-record.js +132 -0
- package/dist/lib/request-log/capture-request-record.js.map +1 -0
- package/dist/lib/request-log/request-log-sink.d.ts +31 -0
- package/dist/lib/request-log/request-log-sink.d.ts.map +1 -0
- package/dist/lib/request-log/request-log-sink.js +26 -0
- package/dist/lib/request-log/request-log-sink.js.map +1 -0
- package/dist/lib/request-log/request-outcome.d.ts +53 -0
- package/dist/lib/request-log/request-outcome.d.ts.map +1 -0
- package/dist/lib/request-log/request-outcome.js +96 -0
- package/dist/lib/request-log/request-outcome.js.map +1 -0
- package/dist/lib/request-log/request-record.d.ts +114 -0
- package/dist/lib/request-log/request-record.d.ts.map +1 -0
- package/dist/lib/request-log/request-record.js +231 -0
- package/dist/lib/request-log/request-record.js.map +1 -0
- package/dist/lib/request-pipeline/assert-no-app-site-serving.d.ts +8 -0
- package/dist/lib/request-pipeline/assert-no-app-site-serving.d.ts.map +1 -0
- package/dist/lib/request-pipeline/assert-no-app-site-serving.js +15 -0
- package/dist/lib/request-pipeline/assert-no-app-site-serving.js.map +1 -0
- package/dist/lib/request-pipeline/carry-audit-actor.d.ts +71 -0
- package/dist/lib/request-pipeline/carry-audit-actor.d.ts.map +1 -0
- package/dist/lib/request-pipeline/carry-audit-actor.js +79 -0
- package/dist/lib/request-pipeline/carry-audit-actor.js.map +1 -0
- package/dist/lib/request-pipeline/carry-authorization-consistency.d.ts +4 -0
- package/dist/lib/request-pipeline/carry-authorization-consistency.d.ts.map +1 -0
- package/dist/lib/request-pipeline/carry-authorization-consistency.js +21 -0
- package/dist/lib/request-pipeline/carry-authorization-consistency.js.map +1 -0
- package/dist/lib/request-pipeline/enforce-access.d.ts +146 -0
- package/dist/lib/request-pipeline/enforce-access.d.ts.map +1 -0
- package/dist/lib/request-pipeline/enforce-access.js +238 -0
- package/dist/lib/request-pipeline/enforce-access.js.map +1 -0
- package/dist/lib/request-pipeline/enforce-scope.d.ts +23 -0
- package/dist/lib/request-pipeline/enforce-scope.d.ts.map +1 -0
- package/dist/lib/request-pipeline/enforce-scope.js +58 -0
- package/dist/lib/request-pipeline/enforce-scope.js.map +1 -0
- package/dist/lib/request-pipeline/envelope.d.ts +17 -0
- package/dist/lib/request-pipeline/envelope.d.ts.map +1 -0
- package/dist/lib/request-pipeline/envelope.js +4 -0
- package/dist/lib/request-pipeline/envelope.js.map +1 -0
- package/dist/lib/request-pipeline/error-handler.d.ts +14 -0
- package/dist/lib/request-pipeline/error-handler.d.ts.map +1 -0
- package/dist/lib/request-pipeline/error-handler.js +138 -0
- package/dist/lib/request-pipeline/error-handler.js.map +1 -0
- package/dist/lib/request-pipeline/feature-state-preview.d.ts +79 -0
- package/dist/lib/request-pipeline/feature-state-preview.d.ts.map +1 -0
- package/dist/lib/request-pipeline/feature-state-preview.js +77 -0
- package/dist/lib/request-pipeline/feature-state-preview.js.map +1 -0
- package/dist/lib/request-pipeline/feature-state.d.ts +70 -0
- package/dist/lib/request-pipeline/feature-state.d.ts.map +1 -0
- package/dist/lib/request-pipeline/feature-state.js +46 -0
- package/dist/lib/request-pipeline/feature-state.js.map +1 -0
- package/dist/lib/request-pipeline/logic/is-write-method.d.ts +2 -0
- package/dist/lib/request-pipeline/logic/is-write-method.d.ts.map +1 -0
- package/dist/lib/request-pipeline/logic/is-write-method.js +7 -0
- package/dist/lib/request-pipeline/logic/is-write-method.js.map +1 -0
- package/dist/lib/request-pipeline/logic/read-request-source.d.ts +19 -0
- package/dist/lib/request-pipeline/logic/read-request-source.d.ts.map +1 -0
- package/dist/lib/request-pipeline/logic/read-request-source.js +40 -0
- package/dist/lib/request-pipeline/logic/read-request-source.js.map +1 -0
- package/dist/lib/request-pipeline/logic/single-request-header.d.ts +3 -0
- package/dist/lib/request-pipeline/logic/single-request-header.d.ts.map +1 -0
- package/dist/lib/request-pipeline/logic/single-request-header.js +16 -0
- package/dist/lib/request-pipeline/logic/single-request-header.js.map +1 -0
- package/dist/lib/request-pipeline/machine-credential-access.d.ts +19 -0
- package/dist/lib/request-pipeline/machine-credential-access.d.ts.map +1 -0
- package/dist/lib/request-pipeline/machine-credential-access.js +28 -0
- package/dist/lib/request-pipeline/machine-credential-access.js.map +1 -0
- package/dist/lib/request-pipeline/rate-limit.d.ts +15 -0
- package/dist/lib/request-pipeline/rate-limit.d.ts.map +1 -0
- package/dist/lib/request-pipeline/rate-limit.js +40 -0
- package/dist/lib/request-pipeline/rate-limit.js.map +1 -0
- package/dist/lib/request-pipeline/raw-route-byte-body.d.ts +19 -0
- package/dist/lib/request-pipeline/raw-route-byte-body.d.ts.map +1 -0
- package/dist/lib/request-pipeline/raw-route-byte-body.js +26 -0
- package/dist/lib/request-pipeline/raw-route-byte-body.js.map +1 -0
- package/dist/lib/request-pipeline/refuse-visible-record-list.d.ts +16 -0
- package/dist/lib/request-pipeline/refuse-visible-record-list.d.ts.map +1 -0
- package/dist/lib/request-pipeline/refuse-visible-record-list.js +33 -0
- package/dist/lib/request-pipeline/refuse-visible-record-list.js.map +1 -0
- package/dist/lib/request-pipeline/register-routes.d.ts +50 -0
- package/dist/lib/request-pipeline/register-routes.d.ts.map +1 -0
- package/dist/lib/request-pipeline/register-routes.js +217 -0
- package/dist/lib/request-pipeline/register-routes.js.map +1 -0
- package/dist/lib/request-pipeline/request-id.d.ts +22 -0
- package/dist/lib/request-pipeline/request-id.d.ts.map +1 -0
- package/dist/lib/request-pipeline/request-id.js +26 -0
- package/dist/lib/request-pipeline/request-id.js.map +1 -0
- package/dist/lib/request-pipeline/request-language-response.d.ts +14 -0
- package/dist/lib/request-pipeline/request-language-response.d.ts.map +1 -0
- package/dist/lib/request-pipeline/request-language-response.js +47 -0
- package/dist/lib/request-pipeline/request-language-response.js.map +1 -0
- package/dist/lib/request-pipeline/request-locale.d.ts +38 -0
- package/dist/lib/request-pipeline/request-locale.d.ts.map +1 -0
- package/dist/lib/request-pipeline/request-locale.js +102 -0
- package/dist/lib/request-pipeline/request-locale.js.map +1 -0
- package/dist/lib/request-pipeline/request-origin.d.ts +17 -0
- package/dist/lib/request-pipeline/request-origin.d.ts.map +1 -0
- package/dist/lib/request-pipeline/request-origin.js +38 -0
- package/dist/lib/request-pipeline/request-origin.js.map +1 -0
- package/dist/lib/request-pipeline/request-trace.d.ts +10 -0
- package/dist/lib/request-pipeline/request-trace.d.ts.map +1 -0
- package/dist/lib/request-pipeline/request-trace.js +24 -0
- package/dist/lib/request-pipeline/request-trace.js.map +1 -0
- package/dist/lib/request-pipeline/route-rate-limit.d.ts +19 -0
- package/dist/lib/request-pipeline/route-rate-limit.d.ts.map +1 -0
- package/dist/lib/request-pipeline/route-rate-limit.js +32 -0
- package/dist/lib/request-pipeline/route-rate-limit.js.map +1 -0
- package/dist/lib/request-pipeline/run-route.d.ts +9 -0
- package/dist/lib/request-pipeline/run-route.d.ts.map +1 -0
- package/dist/lib/request-pipeline/run-route.js +42 -0
- package/dist/lib/request-pipeline/run-route.js.map +1 -0
- package/dist/lib/request-pipeline/with-deadline.d.ts +12 -0
- package/dist/lib/request-pipeline/with-deadline.d.ts.map +1 -0
- package/dist/lib/request-pipeline/with-deadline.js +55 -0
- package/dist/lib/request-pipeline/with-deadline.js.map +1 -0
- package/dist/lib/route/access.d.ts +143 -0
- package/dist/lib/route/access.d.ts.map +1 -0
- package/dist/lib/route/access.js +97 -0
- package/dist/lib/route/access.js.map +1 -0
- package/dist/lib/route/capabilities.d.ts +100 -0
- package/dist/lib/route/capabilities.d.ts.map +1 -0
- package/dist/lib/route/capabilities.js +42 -0
- package/dist/lib/route/capabilities.js.map +1 -0
- package/dist/lib/route/define-raw-route.d.ts +81 -0
- package/dist/lib/route/define-raw-route.d.ts.map +1 -0
- package/dist/lib/route/define-raw-route.js +5 -0
- package/dist/lib/route/define-raw-route.js.map +1 -0
- package/dist/lib/route/delete-route.d.ts +26 -0
- package/dist/lib/route/delete-route.d.ts.map +1 -0
- package/dist/lib/route/delete-route.js +6 -0
- package/dist/lib/route/delete-route.js.map +1 -0
- package/dist/lib/route/get-route.d.ts +43 -0
- package/dist/lib/route/get-route.d.ts.map +1 -0
- package/dist/lib/route/get-route.js +18 -0
- package/dist/lib/route/get-route.js.map +1 -0
- package/dist/lib/route/list-result.d.ts +11 -0
- package/dist/lib/route/list-result.d.ts.map +1 -0
- package/dist/lib/route/list-result.js +8 -0
- package/dist/lib/route/list-result.js.map +1 -0
- package/dist/lib/route/list-route.d.ts +60 -0
- package/dist/lib/route/list-route.d.ts.map +1 -0
- package/dist/lib/route/list-route.js +68 -0
- package/dist/lib/route/list-route.js.map +1 -0
- package/dist/lib/route/patch-route.d.ts +27 -0
- package/dist/lib/route/patch-route.d.ts.map +1 -0
- package/dist/lib/route/patch-route.js +8 -0
- package/dist/lib/route/patch-route.js.map +1 -0
- package/dist/lib/route/post-no-content-route.d.ts +18 -0
- package/dist/lib/route/post-no-content-route.d.ts.map +1 -0
- package/dist/lib/route/post-no-content-route.js +8 -0
- package/dist/lib/route/post-no-content-route.js.map +1 -0
- package/dist/lib/route/post-route.d.ts +34 -0
- package/dist/lib/route/post-route.d.ts.map +1 -0
- package/dist/lib/route/post-route.js +23 -0
- package/dist/lib/route/post-route.js.map +1 -0
- package/dist/lib/route/route-definition.d.ts +224 -0
- package/dist/lib/route/route-definition.d.ts.map +1 -0
- package/dist/lib/route/route-definition.js +32 -0
- package/dist/lib/route/route-definition.js.map +1 -0
- package/dist/lib/route/route-execution.d.ts +47 -0
- package/dist/lib/route/route-execution.d.ts.map +1 -0
- package/dist/lib/route/route-execution.js +162 -0
- package/dist/lib/route/route-execution.js.map +1 -0
- package/dist/lib/route/route-group.d.ts +21 -0
- package/dist/lib/route/route-group.d.ts.map +1 -0
- package/dist/lib/route/route-group.js +18 -0
- package/dist/lib/route/route-group.js.map +1 -0
- package/dist/lib/route/route-guards.test-support.d.ts +2 -0
- package/dist/lib/route/route-guards.test-support.d.ts.map +1 -0
- package/dist/lib/route/route-guards.test-support.js +2 -0
- package/dist/lib/route/route-guards.test-support.js.map +1 -0
- package/dist/lib/route/sse-route.d.ts +54 -0
- package/dist/lib/route/sse-route.d.ts.map +1 -0
- package/dist/lib/route/sse-route.js +63 -0
- package/dist/lib/route/sse-route.js.map +1 -0
- package/dist/lib/route/web-socket-route.d.ts +45 -0
- package/dist/lib/route/web-socket-route.d.ts.map +1 -0
- package/dist/lib/route/web-socket-route.js +180 -0
- package/dist/lib/route/web-socket-route.js.map +1 -0
- package/dist/lib/route-catalog/route-catalog-parts.d.ts +27 -0
- package/dist/lib/route-catalog/route-catalog-parts.d.ts.map +1 -0
- package/dist/lib/route-catalog/route-catalog-parts.js +87 -0
- package/dist/lib/route-catalog/route-catalog-parts.js.map +1 -0
- package/dist/protocol-mounts/index.d.ts +19 -0
- package/dist/protocol-mounts/index.d.ts.map +1 -0
- package/dist/protocol-mounts/index.js +19 -0
- package/dist/protocol-mounts/index.js.map +1 -0
- package/dist/protocol-mounts/lib/mcp/json-rpc.d.ts +54 -0
- package/dist/protocol-mounts/lib/mcp/json-rpc.d.ts.map +1 -0
- package/dist/protocol-mounts/lib/mcp/json-rpc.js +53 -0
- package/dist/protocol-mounts/lib/mcp/json-rpc.js.map +1 -0
- package/dist/protocol-mounts/lib/mcp/mcp-endpoint.d.ts +31 -0
- package/dist/protocol-mounts/lib/mcp/mcp-endpoint.d.ts.map +1 -0
- package/dist/protocol-mounts/lib/mcp/mcp-endpoint.js +179 -0
- package/dist/protocol-mounts/lib/mcp/mcp-endpoint.js.map +1 -0
- package/dist/protocol-mounts/lib/mcp/mcp-methods.d.ts +68 -0
- package/dist/protocol-mounts/lib/mcp/mcp-methods.d.ts.map +1 -0
- package/dist/protocol-mounts/lib/mcp/mcp-methods.js +201 -0
- package/dist/protocol-mounts/lib/mcp/mcp-methods.js.map +1 -0
- package/dist/protocol-mounts/lib/mcp/protected-resource-metadata.d.ts +18 -0
- package/dist/protocol-mounts/lib/mcp/protected-resource-metadata.d.ts.map +1 -0
- package/dist/protocol-mounts/lib/mcp/protected-resource-metadata.js +34 -0
- package/dist/protocol-mounts/lib/mcp/protected-resource-metadata.js.map +1 -0
- package/dist/protocol-mounts/lib/protocol-mount/mount-fetch-handler.d.ts +57 -0
- package/dist/protocol-mounts/lib/protocol-mount/mount-fetch-handler.d.ts.map +1 -0
- package/dist/protocol-mounts/lib/protocol-mount/mount-fetch-handler.js +100 -0
- package/dist/protocol-mounts/lib/protocol-mount/mount-fetch-handler.js.map +1 -0
- package/dist/protocol-mounts/lib/protocol-mount/to-web-request.d.ts +14 -0
- package/dist/protocol-mounts/lib/protocol-mount/to-web-request.d.ts.map +1 -0
- package/dist/protocol-mounts/lib/protocol-mount/to-web-request.js +60 -0
- package/dist/protocol-mounts/lib/protocol-mount/to-web-request.js.map +1 -0
- package/dist/testing/build-test-app.d.ts +47 -0
- package/dist/testing/build-test-app.d.ts.map +1 -0
- package/dist/testing/build-test-app.js +79 -0
- package/dist/testing/build-test-app.js.map +1 -0
- package/dist/testing/index.d.ts +3 -0
- package/dist/testing/index.d.ts.map +1 -0
- package/dist/testing/index.js +3 -0
- package/dist/testing/index.js.map +1 -0
- package/dist/testing/parse-inject-response.d.ts +32 -0
- package/dist/testing/parse-inject-response.d.ts.map +1 -0
- package/dist/testing/parse-inject-response.js +39 -0
- package/dist/testing/parse-inject-response.js.map +1 -0
- package/package.json +55 -4
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
import { type FastifyInstance } from "fastify";
|
|
2
|
+
import type { DestinationStream } from "pino";
|
|
3
|
+
import type { DiagnosticsReporter } from "@dads-framework/diagnostics";
|
|
4
|
+
import type { RequestLogSink } from "./request-log/request-log-sink.js";
|
|
5
|
+
import { type RequestTrace } from "./request-pipeline/request-trace.js";
|
|
6
|
+
/**
|
|
7
|
+
* Platform defaults for every HTTP app. The runaway-resource bounds are
|
|
8
|
+
* numbers, not `number | false` — a caller can raise them for a special
|
|
9
|
+
* deployment but can never disable them (process-discipline bar,
|
|
10
|
+
* docs/plans/2026-07-09-remove-nest-http-kit.md).
|
|
11
|
+
*/
|
|
12
|
+
export type HttpAppOptions = {
|
|
13
|
+
readonly nodeEnv: string;
|
|
14
|
+
/** CORS origins allowed to send credentials. */
|
|
15
|
+
readonly trustedOrigins: readonly string[];
|
|
16
|
+
/**
|
|
17
|
+
* Response headers a browser client may read, beyond the request id and
|
|
18
|
+
* the access-refusal mark this kit always exposes. Which headers an app's own client speaks is that app's
|
|
19
|
+
* wire contract, so the app names them.
|
|
20
|
+
*/
|
|
21
|
+
readonly exposedHeaders?: readonly string[];
|
|
22
|
+
/** false only via the test harness — production apps always log. */
|
|
23
|
+
readonly logger?: boolean;
|
|
24
|
+
/** A giant payload dies at the edge, not in V8. Default 1 MiB. */
|
|
25
|
+
readonly bodyLimitBytes?: number;
|
|
26
|
+
/** A hung handler cannot pin a socket forever. Default 30s. */
|
|
27
|
+
readonly requestTimeoutMs?: number;
|
|
28
|
+
/** Slow-loris connections die before their headers complete. Default 10s. */
|
|
29
|
+
readonly headersTimeoutMs?: number;
|
|
30
|
+
/**
|
|
31
|
+
* How long a socket may sit with no traffic at all, which includes a
|
|
32
|
+
* handler still working on its answer. Default 70s: past the 30s handler
|
|
33
|
+
* deadline and past keep-alive, so neither is cut short.
|
|
34
|
+
*/
|
|
35
|
+
readonly idleSocketTimeoutMs?: number;
|
|
36
|
+
/** Above typical load-balancer idle (60s) so the LB closes first. Default 65s. */
|
|
37
|
+
readonly keepAliveTimeoutMs?: number;
|
|
38
|
+
/** Probe routes kept out of the log stream. */
|
|
39
|
+
readonly quietPaths?: readonly string[];
|
|
40
|
+
/**
|
|
41
|
+
* Trusted reverse-proxy hops in front of this process (0 = none).
|
|
42
|
+
* CloudFront + ALB is 2; ALB only is 1. Never `true` — that takes the
|
|
43
|
+
* leftmost client-supplied X-Forwarded-For as `request.ip`.
|
|
44
|
+
*/
|
|
45
|
+
readonly trustedProxyHops?: number;
|
|
46
|
+
/**
|
|
47
|
+
* Where the per-request row goes. A lookup rather than
|
|
48
|
+
* the sink itself: the capture hook must be installed before any route or
|
|
49
|
+
* protocol mount is registered, and the sink needs a database the
|
|
50
|
+
* composition root builds after the app exists. Omit it and nothing is
|
|
51
|
+
* captured.
|
|
52
|
+
*/
|
|
53
|
+
readonly requestLog?: () => RequestLogSink | undefined;
|
|
54
|
+
/** Build identity stamped on every captured row; null in the table until the image supplies one. */
|
|
55
|
+
readonly apiRelease?: string;
|
|
56
|
+
/**
|
|
57
|
+
* Which process answered, stamped on every captured row. The
|
|
58
|
+
* composition root resolves it once — a kit does not get to decide what a
|
|
59
|
+
* deployment calls its instances.
|
|
60
|
+
*/
|
|
61
|
+
readonly instanceId?: string;
|
|
62
|
+
/**
|
|
63
|
+
* Where a fault goes besides the log line. Omitted, faults are
|
|
64
|
+
* logged exactly as they are today and reported nowhere.
|
|
65
|
+
*/
|
|
66
|
+
readonly diagnostics?: DiagnosticsReporter;
|
|
67
|
+
/**
|
|
68
|
+
* Reads the trace in flight, when the deployment runs tracing at all. A
|
|
69
|
+
* function so this kit never imports OpenTelemetry.
|
|
70
|
+
*/
|
|
71
|
+
readonly currentTraceId?: () => string | undefined;
|
|
72
|
+
/** Annotates the active span with the request ID and audit actor kind. */
|
|
73
|
+
readonly requestTrace?: RequestTrace;
|
|
74
|
+
/**
|
|
75
|
+
* Body media types this app accepts as raw text.
|
|
76
|
+
*
|
|
77
|
+
* Fastify answers 415 for a content type it has no parser for, before any
|
|
78
|
+
* handler runs — so a raw route receiving a format the typed verbs cannot
|
|
79
|
+
* express (a newline-delimited telemetry envelope) needs its type
|
|
80
|
+
* named here. The body arrives as the string it was sent as: this kit does
|
|
81
|
+
* not learn any format, it only agrees to hand one through.
|
|
82
|
+
*
|
|
83
|
+
* Still under `bodyLimit`, like every other body.
|
|
84
|
+
*/
|
|
85
|
+
readonly rawBodyContentTypes?: readonly string[];
|
|
86
|
+
/**
|
|
87
|
+
* Body media types this app accepts as raw bytes (a `Buffer`), for a raw
|
|
88
|
+
* route that stores a file's bytes exactly as they were sent. Opt-in: an
|
|
89
|
+
* app that names none answers 415 for these types, as before. Still under
|
|
90
|
+
* `bodyLimit`, or the route's own `bodyLimitBytes`.
|
|
91
|
+
*/
|
|
92
|
+
readonly byteBodyContentTypes?: readonly string[];
|
|
93
|
+
/**
|
|
94
|
+
* Where log lines go instead of stdout. Site process only; Vector never
|
|
95
|
+
* sets it. Redaction runs before the stream. When set, the kit configures
|
|
96
|
+
* no `transport` (pino refuses both at once): a caller that wants pretty
|
|
97
|
+
* output in development puts it into its own stream.
|
|
98
|
+
*/
|
|
99
|
+
readonly logStream?: DestinationStream;
|
|
100
|
+
};
|
|
101
|
+
/**
|
|
102
|
+
* Builds a Fastify instance carrying the house edge behavior: pino logging
|
|
103
|
+
* with credential redaction, request-id correlation (inbound `x-request-id`
|
|
104
|
+
* honored, always echoed), the error envelope handler, CORS for the trusted
|
|
105
|
+
* origins, and the non-disableable resource bounds above.
|
|
106
|
+
*/
|
|
107
|
+
export declare function createHttpApp(options: HttpAppOptions): Promise<FastifyInstance>;
|
|
108
|
+
//# sourceMappingURL=create-http-app.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"create-http-app.d.ts","sourceRoot":"","sources":["../../src/lib/create-http-app.ts"],"names":[],"mappings":"AACA,OAAgB,EACd,KAAK,eAAe,EAGrB,MAAM,SAAS,CAAC;AACjB,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,MAAM,CAAC;AAE9C,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,6BAA6B,CAAC;AASvE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,mCAAmC,CAAC;AAQxE,OAAO,EAEL,KAAK,YAAY,EAClB,MAAM,qCAAqC,CAAC;AAM7C;;;;;GAKG;AACH,MAAM,MAAM,cAAc,GAAG;IAC3B,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,gDAAgD;IAChD,QAAQ,CAAC,cAAc,EAAE,SAAS,MAAM,EAAE,CAAC;IAC3C;;;;OAIG;IACH,QAAQ,CAAC,cAAc,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IAC5C,oEAAoE;IACpE,QAAQ,CAAC,MAAM,CAAC,EAAE,OAAO,CAAC;IAC1B,kEAAkE;IAClE,QAAQ,CAAC,cAAc,CAAC,EAAE,MAAM,CAAC;IACjC,+DAA+D;IAC/D,Q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ify, {} from "fastify";
|
|
3
|
+
import { beginRequestWork } from "@dads-framework/request-work";
|
|
4
|
+
import { ACCESS_REFUSAL_HEADER, REQUEST_ID_HEADER, } from "@dads-framework/contract";
|
|
5
|
+
import { AuthorizationWarningFaults } from "./request-log/authorization-warning-faults.js";
|
|
6
|
+
import { captureRequestRecord } from "./request-log/capture-request-record.js";
|
|
7
|
+
import { enterAnonymousRequestActor } from "./request-pipeline/carry-audit-actor.js";
|
|
8
|
+
import { installErrorHandling, } from "./request-pipeline/error-handler.js";
|
|
9
|
+
import { resolveRequestId } from "./request-pipeline/request-id.js";
|
|
10
|
+
import { enterRequestOrigin } from "./request-pipeline/request-origin.js";
|
|
11
|
+
import { beginRequestTrace, } from "./request-pipeline/request-trace.js";
|
|
12
|
+
import { acceptWebSocketUpgrades, isWebSocketRoutePath, } from "./route/web-socket-route.js";
|
|
13
|
+
/**
|
|
14
|
+
* Agree to receive body types Fastify has no parser for, as the text they
|
|
15
|
+
* arrived as.
|
|
16
|
+
*
|
|
17
|
+
* Its own function for the same reason as `errorHandlingFrom` below: the loop
|
|
18
|
+
* would otherwise count against `createHttpApp`'s complexity budget, which is
|
|
19
|
+
* what keeps the composition readable.
|
|
20
|
+
*/
|
|
21
|
+
function acceptRawBodies(app, contentTypes) {
|
|
22
|
+
for (const contentType of contentTypes ?? []) {
|
|
23
|
+
app.addContentTypeParser(contentType, { parseAs: "string" }, (_request, body, done) => {
|
|
24
|
+
// Handed through exactly as received. Whatever reads it owns the
|
|
25
|
+
// format; this kit owns only the fact that a body was allowed.
|
|
26
|
+
done(null, body);
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Agree to receive body types as the bytes they arrived as. Its own function
|
|
32
|
+
* for the same complexity reason as `acceptRawBodies`.
|
|
33
|
+
*/
|
|
34
|
+
function acceptByteBodies(app, contentTypes) {
|
|
35
|
+
for (const contentType of contentTypes ?? []) {
|
|
36
|
+
app.addContentTypeParser(contentType, { parseAs: "buffer" }, (_request, body, done) => {
|
|
37
|
+
// Handed through exactly as received; the route owns the bytes.
|
|
38
|
+
done(null, body);
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* The subset of the app's options the error handler needs, with the absent
|
|
44
|
+
* ones left absent rather than passed as `undefined`. Its own function so the
|
|
45
|
+
* three optional spreads do not count against `createHttpApp`'s complexity —
|
|
46
|
+
* which is the budget that keeps the composition readable.
|
|
47
|
+
*/
|
|
48
|
+
function errorHandlingFrom(options) {
|
|
49
|
+
return {
|
|
50
|
+
...(options.diagnostics === undefined
|
|
51
|
+
? {}
|
|
52
|
+
: { diagnostics: options.diagnostics }),
|
|
53
|
+
...(options.apiRelease === undefined
|
|
54
|
+
? {}
|
|
55
|
+
: { release: options.apiRelease }),
|
|
56
|
+
...(options.instanceId === undefined
|
|
57
|
+
? {}
|
|
58
|
+
: { instanceId: options.instanceId }),
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
const DEFAULT_BODY_LIMIT_BYTES = 1_048_576;
|
|
62
|
+
const DEFAULT_REQUEST_TIMEOUT_MS = 30_000;
|
|
63
|
+
const DEFAULT_HEADERS_TIMEOUT_MS = 10_000;
|
|
64
|
+
const DEFAULT_KEEP_ALIVE_TIMEOUT_MS = 65_000;
|
|
65
|
+
const DEFAULT_IDLE_SOCKET_TIMEOUT_MS = 70_000;
|
|
66
|
+
const DEFAULT_QUIET_PATHS = ["/api/health", "/api/ready"];
|
|
67
|
+
/** Slow-loris bound: a client that never finishes its headers is dropped. */
|
|
68
|
+
function applyHeadersTimeout(app, options) {
|
|
69
|
+
app.server.headersTimeout =
|
|
70
|
+
options.headersTimeoutMs ?? DEFAULT_HEADERS_TIMEOUT_MS;
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Pino options with credential redaction and an optional caller-supplied stream.
|
|
74
|
+
*/
|
|
75
|
+
function loggerOptionsFrom(options) {
|
|
76
|
+
if (options.logger === false)
|
|
77
|
+
return false;
|
|
78
|
+
return {
|
|
79
|
+
serializers: {
|
|
80
|
+
req: (request) => ({
|
|
81
|
+
method: request.method,
|
|
82
|
+
// Verification and reset links carry credentials in the query string.
|
|
83
|
+
url: request.url.split("?")[0] ?? "",
|
|
84
|
+
host: request.host,
|
|
85
|
+
remoteAddress: request.ip,
|
|
86
|
+
}),
|
|
87
|
+
},
|
|
88
|
+
redact: {
|
|
89
|
+
paths: [
|
|
90
|
+
"req.headers.authorization",
|
|
91
|
+
"req.headers.cookie",
|
|
92
|
+
"res.headers['set-cookie']",
|
|
93
|
+
],
|
|
94
|
+
},
|
|
95
|
+
...(options.logStream === undefined ? {} : { stream: options.logStream }),
|
|
96
|
+
};
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* Builds a Fastify instance carrying the house edge behavior: pino logging
|
|
100
|
+
* with credential redaction, request-id correlation (inbound `x-request-id`
|
|
101
|
+
* honored, always echoed), the error envelope handler, CORS for the trusted
|
|
102
|
+
* origins, and the non-disableable resource bounds above.
|
|
103
|
+
*/
|
|
104
|
+
export async function createHttpApp(options) {
|
|
105
|
+
const app = Fastify({
|
|
106
|
+
logger: loggerOptionsFrom(options),
|
|
107
|
+
// resolveRequestId is the same ingress the old middleware used: trust a
|
|
108
|
+
// sane inbound id, otherwise generate one.
|
|
109
|
+
genReqId: (req) => resolveRequestId(req.headers[REQUEST_ID_HEADER]).id,
|
|
110
|
+
requestIdHeader: false,
|
|
111
|
+
bodyLimit: options.bodyLimitBytes ?? DEFAULT_BODY_LIMIT_BYTES,
|
|
112
|
+
requestTimeout: options.requestTimeoutMs ?? DEFAULT_REQUEST_TIMEOUT_MS,
|
|
113
|
+
connectionTimeout: options.idleSocketTimeoutMs ?? DEFAULT_IDLE_SOCKET_TIMEOUT_MS,
|
|
114
|
+
keepAliveTimeout: options.keepAliveTimeoutMs ?? DEFAULT_KEEP_ALIVE_TIMEOUT_MS,
|
|
115
|
+
// close() destroys idle sockets instead of waiting on keep-alive — a
|
|
116
|
+
// deploy drains in-flight work and exits, never hangs on idle clients.
|
|
117
|
+
forceCloseConnections: "idle",
|
|
118
|
+
trustProxy: options.trustedProxyHops ?? 0,
|
|
119
|
+
});
|
|
120
|
+
applyHeadersTimeout(app, options);
|
|
121
|
+
// The first hook Fastify runs, so everything downstream inherits all four:
|
|
122
|
+
// correlation egress (every response carries the id, success or error), the
|
|
123
|
+
// anonymous audit-actor context that keeps a pre-authentication write —
|
|
124
|
+
// Better Auth's login rows, SCIM's first touch — from reaching the
|
|
125
|
+
// `audit_record` trigger unattributed, the work tally the
|
|
126
|
+
// pool and the authorization port charge into, and the origin the request
|
|
127
|
+
// reached the server on (`requestOriginOr`).
|
|
128
|
+
app.addHook("onRequest", (request, reply, done) => {
|
|
129
|
+
void reply.header(REQUEST_ID_HEADER, request.id);
|
|
130
|
+
enterAnonymousRequestActor(request);
|
|
131
|
+
beginRequestTrace(request, options.requestTrace);
|
|
132
|
+
beginRequestWork(request);
|
|
133
|
+
enterRequestOrigin(request);
|
|
134
|
+
done();
|
|
135
|
+
});
|
|
136
|
+
const quiet = new Set(options.quietPaths ?? DEFAULT_QUIET_PATHS);
|
|
137
|
+
const warningFaults = new AuthorizationWarningFaults();
|
|
138
|
+
app.addHook("onRoute", (route) => {
|
|
139
|
+
if (quiet.has(route.url)) {
|
|
140
|
+
route.logLevel = "silent";
|
|
141
|
+
}
|
|
142
|
+
// The first WebSocket route makes the app route upgrades through Fastify.
|
|
143
|
+
if (route.method === "GET" && isWebSocketRoutePath(route.url)) {
|
|
144
|
+
acceptWebSocketUpgrades(app);
|
|
145
|
+
}
|
|
146
|
+
});
|
|
147
|
+
// Registered here, before the protocol mounts and the route table, because
|
|
148
|
+
// a hook added to the root after a plugin has booted is not inherited by
|
|
149
|
+
// it — and a request row that missed `/api/auth` would miss exactly the
|
|
150
|
+
// requests with no subject to identify them by.
|
|
151
|
+
app.addHook("onResponse", (request, reply, done) => {
|
|
152
|
+
captureRequestRecord(request, reply, {
|
|
153
|
+
requestLog: options.requestLog,
|
|
154
|
+
apiRelease: options.apiRelease,
|
|
155
|
+
instanceId: options.instanceId,
|
|
156
|
+
...(options.currentTraceId === undefined
|
|
157
|
+
? {}
|
|
158
|
+
: { currentTraceId: options.currentTraceId }),
|
|
159
|
+
quietPaths: quiet,
|
|
160
|
+
warningFaults,
|
|
161
|
+
...(options.diagnostics === undefined
|
|
162
|
+
? {}
|
|
163
|
+
: { diagnostics: options.diagnostics }),
|
|
164
|
+
});
|
|
165
|
+
done();
|
|
166
|
+
});
|
|
167
|
+
acceptRawBodies(app, options.rawBodyContentTypes);
|
|
168
|
+
acceptByteBodies(app, options.byteBodyContentTypes);
|
|
169
|
+
installErrorHandling(app, errorHandlingFrom(options));
|
|
170
|
+
await app.register(cors, {
|
|
171
|
+
origin: [...options.trustedOrigins],
|
|
172
|
+
credentials: true,
|
|
173
|
+
exposedHeaders: [
|
|
174
|
+
REQUEST_ID_HEADER,
|
|
175
|
+
ACCESS_REFUSAL_HEADER,
|
|
176
|
+
...(options.exposedHeaders ?? []),
|
|
177
|
+
],
|
|
178
|
+
});
|
|
179
|
+
return app;
|
|
180
|
+
}
|
|
181
|
+
//# sourceMappingURL=create-http-app.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"create-http-app.js","sourceRoot":"","sources":["../../src/lib/create-http-app.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,eAAe,CAAC;AACjC,OAAO,OAAO,EAAE,EAIf,MAAM,SAAS,CAAC;AAIjB,OAAO,EAAE,gBAAgB,EAAE,MAAM,8BAA8B,CAAC;AAChE,OAAO,EACL,qBAAqB,EACrB,iBAAiB,GAClB,MAAM,0BAA0B,CAAC;AAElC,OAAO,EAAE,0BAA0B,EAAE,MAAM,+CAA+C,CAAC;AAC3F,OAAO,EAAE,oBAAoB,EAAE,MAAM,yCAAyC,CAAC;AAE/E,OAAO,EAAE,0BAA0B,EAAE,MAAM,yC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AC,CAAC,EAAE;gBACJ,CAAC,CAAC,EAAE,WAAW,EAAE,OAAO,CAAC,WAAW,EAAE,CAAC;SAC1C,CAAC,CAAC;QACH,IAAI,EAAE,CAAC;IACT,CAAC,CAAC,CAAC;IAEH,eAAe,CAAC,GAAG,EAAE,OAAO,CAAC,mBAAmB,CAAC,CAAC;IAClD,gBAAgB,CAAC,GAAG,EAAE,OAAO,CAAC,oBAAoB,CAAC,CAAC;IAEpD,oBAAoB,CAAC,GAAG,EAAE,iBAAiB,CAAC,OAAO,CAAC,CAAC,CAAC;IAEtD,MAAM,GAAG,CAAC,QAAQ,CAAC,IAAI,EAAE;QACvB,MAAM,EAAE,CAAC,GAAG,OAAO,CAAC,cAAc,CAAC;QACnC,WAAW,EAAE,IAAI;QACjB,cAAc,EAAE;YACd,iBAAiB;YACjB,qBAAqB;YACrB,GAAG,CAAC,OAAO,CAAC,cAAc,IAAI,EAAE,CAAC;SAClC;KACF,CAAC,CAAC;IAEH,OAAO,GAAG,CAAC;AACb,CAAC"}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import type { z } from "zod";
|
|
2
|
+
/**
|
|
3
|
+
* Typed failures the kit itself can produce while running a route. The error
|
|
4
|
+
* handler maps each to exactly one HTTP outcome; nothing else in the kit
|
|
5
|
+
* decides status codes (docs/architecture/type-safety.md).
|
|
6
|
+
*/
|
|
7
|
+
/** Which part of the request failed validation. */
|
|
8
|
+
export type RequestPart = "params" | "query" | "body";
|
|
9
|
+
/** A request that failed its Zod schema — becomes a 400 with field issues. */
|
|
10
|
+
export declare class RequestValidationError extends Error {
|
|
11
|
+
readonly part: RequestPart;
|
|
12
|
+
readonly cause: z.ZodError;
|
|
13
|
+
constructor(part: RequestPart, cause: z.ZodError);
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* A handler returned data that does not satisfy the route's response schema.
|
|
17
|
+
* This is a programming error, never a client error — it becomes a loud 500
|
|
18
|
+
* (the `@ZodResponse` drift-fails-at-the-boundary posture, preserved).
|
|
19
|
+
*/
|
|
20
|
+
export declare class ResponseDriftError extends Error {
|
|
21
|
+
readonly routePath: string;
|
|
22
|
+
readonly cause: z.ZodError;
|
|
23
|
+
constructor(routePath: string, cause: z.ZodError);
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* The kit was asked to run a route in a state its access declaration rules
|
|
27
|
+
* out (e.g. a session-guarded handler invoked with no subject). Defensive —
|
|
28
|
+
* the access hook prevents this; reaching it is a wiring bug, a loud 500.
|
|
29
|
+
*/
|
|
30
|
+
export declare class HttpWiringError extends Error {
|
|
31
|
+
constructor(message: string);
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* A handler exceeded the kit's hard deadline. The socket is released with a
|
|
35
|
+
* 503 and the incident is logged loud — a hung handler must never pin a
|
|
36
|
+
* connection (process-discipline bar).
|
|
37
|
+
*/
|
|
38
|
+
export declare class HandlerTimeoutError extends Error {
|
|
39
|
+
readonly routePath: string;
|
|
40
|
+
readonly afterMs: number;
|
|
41
|
+
constructor(routePath: string, afterMs: number);
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* An infrastructure dependency the route needs is unavailable (readiness
|
|
45
|
+
* probes, upstream outages) — a 503 with a stable code, expected rather
|
|
46
|
+
* than masked.
|
|
47
|
+
*/
|
|
48
|
+
export declare class ServiceUnavailableError extends Error {
|
|
49
|
+
readonly code: string;
|
|
50
|
+
constructor(code: string, message: string);
|
|
51
|
+
}
|
|
52
|
+
//# sourceMappingURL=http-errors.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"http-errors.d.ts","sourceRoot":"","sources":["../../src/lib/http-errors.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAE7B;;;;GAIG;AAEH,mDAAmD;AACnD,MAAM,MAAM,WAAW,GAAG,QAAQ,GAAG,OAAO,GAAG,MAAM,CAAC;AAEtD,8EAA8E;AAC9E,qBAAa,sBAAuB,SAAQ,KAAK;IAE7C,QAAQ,CAAC,IAAI,EAAE,WAAW;aACR,KAAK,EAAE,CAAC,CAAC,QAAQ;IAFrC,YACW,IAAI,EAAE,WAAW,EACR,KAAK,EAAE,CAAC,CAAC,QAAQ,EAIpC;CACF;AAED;;;;GAIG;AACH,qBAAa,kBAAmB,SAAQ,KAAK;IAEzC,QAAQ,CAAC,SAAS,EAAE,MAAM;aACR,KAAK,EAAE,CAAC,CAAC,QAAQ;IAFrC,YACW,SAAS,EAAE,MAAM,EACR,KAAK,EAAE,CAAC,CAAC,QAAQ,EAIpC;CACF;AAED;;;;GAIG;AACH,qBAAa,eAAgB,SAAQ,KAAK;IACxC,YAAY,OAAO,EAAE,MAAM,EAG1B;CACF;AAED;;;;GAIG;AACH,qBAAa,mBAAoB,SAAQ,KAAK;IAE1C,QAAQ,CAAC,SAAS,EAAE,MAAM;IAC1B,QAAQ,CAAC,OAAO,EAAE,MAAM;IAF1B,YACW,SAAS,EAAE,MAAM,EACjB,OAAO,EAAE,MAAM,EAIzB;CACF;AAED;;;;GAIG;AACH,qBAAa,uBAAwB,SAAQ,KAAK;IAE9C,QAAQ,CAAC,IAAI,EAAE,MAAM;IADvB,YACW,IAAI,EAAE,MAAM,EACrB,OAAO,EAAE,MAAM,EAIhB;CACF"}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
/** A request that failed its Zod schema — becomes a 400 with field issues. */
|
|
2
|
+
export class RequestValidationError extends Error {
|
|
3
|
+
part;
|
|
4
|
+
cause;
|
|
5
|
+
constructor(part, cause) {
|
|
6
|
+
super(`request ${part} failed validation`);
|
|
7
|
+
this.part = part;
|
|
8
|
+
this.cause = cause;
|
|
9
|
+
this.name = "RequestValidationError";
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* A handler returned data that does not satisfy the route's response schema.
|
|
14
|
+
* This is a programming error, never a client error — it becomes a loud 500
|
|
15
|
+
* (the `@ZodResponse` drift-fails-at-the-boundary posture, preserved).
|
|
16
|
+
*/
|
|
17
|
+
export class ResponseDriftError extends Error {
|
|
18
|
+
routePath;
|
|
19
|
+
cause;
|
|
20
|
+
constructor(routePath, cause) {
|
|
21
|
+
super(`response for ${routePath} drifted from its schema`);
|
|
22
|
+
this.routePath = routePath;
|
|
23
|
+
this.cause = cause;
|
|
24
|
+
this.name = "ResponseDriftError";
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* The kit was asked to run a route in a state its access declaration rules
|
|
29
|
+
* out (e.g. a session-guarded handler invoked with no subject). Defensive —
|
|
30
|
+
* the access hook prevents this; reaching it is a wiring bug, a loud 500.
|
|
31
|
+
*/
|
|
32
|
+
export class HttpWiringError extends Error {
|
|
33
|
+
constructor(message) {
|
|
34
|
+
super(message);
|
|
35
|
+
this.name = "HttpWiringError";
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* A handler exceeded the kit's hard deadline. The socket is released with a
|
|
40
|
+
* 503 and the incident is logged loud — a hung handler must never pin a
|
|
41
|
+
* connection (process-discipline bar).
|
|
42
|
+
*/
|
|
43
|
+
export class HandlerTimeoutError extends Error {
|
|
44
|
+
routePath;
|
|
45
|
+
afterMs;
|
|
46
|
+
constructor(routePath, afterMs) {
|
|
47
|
+
super(`handler for ${routePath} exceeded ${afterMs}ms`);
|
|
48
|
+
this.routePath = routePath;
|
|
49
|
+
this.afterMs = afterMs;
|
|
50
|
+
this.name = "HandlerTimeoutError";
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* An infrastructure dependency the route needs is unavailable (readiness
|
|
55
|
+
* probes, upstream outages) — a 503 with a stable code, expected rather
|
|
56
|
+
* than masked.
|
|
57
|
+
*/
|
|
58
|
+
export class ServiceUnavailableError extends Error {
|
|
59
|
+
code;
|
|
60
|
+
constructor(code, message) {
|
|
61
|
+
super(message);
|
|
62
|
+
this.code = code;
|
|
63
|
+
this.name = "ServiceUnavailableError";
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
//# sourceMappingURL=http-errors.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"http-errors.js","sourceRoot":"","sources":["../../src/lib/http-errors.ts"],"names":[],"mappings":"AAWA,8EAA8E;AAC9E,MAAM,OAAO,sBAAuB,SAAQ,KAAK;IAEpC,IAAI;IACK,KAAK;IAFzB,YACW,IAAiB,EACR,KAAiB;QAEnC,KAAK,CAAC,WAAW,IAAI,oBAAoB,CAAC,CAAC;oBAHlC,IAAI;qBACK,KAAK;QAGvB,IAAI,CAAC,IAAI,GAAG,wBAAwB,CAAC;IACvC,CAAC;CACF;AAED;;;;GAIG;AACH,MAAM,OAAO,kBAAmB,SAAQ,KAAK;IAEhC,SAAS;IACA,KAAK;IAFzB,YACW,SAAiB,EACR,KAAiB;QAEnC,KAAK,CAAC,gBAAgB,SAAS,0BAA0B,CAAC,CAAC;yBAHlD,SAAS;qBACA,KAAK;QAGvB,IAAI,CAAC,IAAI,GAAG,oBAAoB,CAAC;IACnC,CAAC;CACF;AAED;;;;GAIG;AACH,MAAM,OAAO,eAAgB,SAAQ,KAAK;IACxC,YAAY,OAAe;QACzB,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,iBAAiB,CAAC;IAChC,CAAC;CACF;AAED;;;;GAIG;AACH,MAAM,OAAO,mBAAoB,SAAQ,KAAK;IAEjC,SAAS;IACT,OAAO;IAFlB,YACW,SAAiB,EACjB,OAAe;QAExB,KAAK,CAAC,eAAe,SAAS,aAAa,OAAO,IAAI,CAAC,CAAC;yBAH/C,SAAS;uBACT,OAAO;QAGhB,IAAI,CAAC,IAAI,GAAG,qBAAqB,CAAC;IACpC,CAAC;CACF;AAED;;;;GAIG;AACH,MAAM,OAAO,uBAAwB,SAAQ,KAAK;IAErC,IAAI;IADf,YACW,IAAY,EACrB,OAAe;QAEf,KAAK,CAAC,OAAO,CAAC,CAAC;oBAHN,IAAI;QAIb,IAAI,CAAC,IAAI,GAAG,yBAAyB,CAAC;IACxC,CAAC;CACF"}
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import type { z } from "zod";
|
|
2
|
+
import type { SubjectRef } from "@dads-framework/access/runtime";
|
|
3
|
+
/**
|
|
4
|
+
* The signed-in person behind one MCP request. The endpoint resolves it from
|
|
5
|
+
* the OAuth bearer before any tool runs; tools act as this subject through the
|
|
6
|
+
* same operations the HTTP routes call.
|
|
7
|
+
*/
|
|
8
|
+
export type McpCaller = Readonly<{
|
|
9
|
+
subject: SubjectRef;
|
|
10
|
+
requestId: string;
|
|
11
|
+
/**
|
|
12
|
+
* The OAuth client the person connected (Claude, ChatGPT, or any MCP
|
|
13
|
+
* client): its registered client id. Every audit row a tool writes names
|
|
14
|
+
* it. Absent when the bearer resolver does not say.
|
|
15
|
+
*/
|
|
16
|
+
clientId?: string;
|
|
17
|
+
/** The name that client registered under, when it gave one. */
|
|
18
|
+
clientName?: string;
|
|
19
|
+
}>;
|
|
20
|
+
/** What a tool hands back, in MCP's own content shapes. */
|
|
21
|
+
export type McpContent = Readonly<{
|
|
22
|
+
type: "text";
|
|
23
|
+
text: string;
|
|
24
|
+
}> | Readonly<{
|
|
25
|
+
type: "image";
|
|
26
|
+
data: string;
|
|
27
|
+
mimeType: string;
|
|
28
|
+
}> | Readonly<{
|
|
29
|
+
type: "resource";
|
|
30
|
+
resource: Readonly<{
|
|
31
|
+
uri: string;
|
|
32
|
+
mimeType: string;
|
|
33
|
+
blob: string;
|
|
34
|
+
}>;
|
|
35
|
+
}>;
|
|
36
|
+
export type McpToolResult = Readonly<{
|
|
37
|
+
content: readonly McpContent[];
|
|
38
|
+
structuredContent?: Readonly<Record<string, unknown>>;
|
|
39
|
+
/** A refusal the agent should read and correct, not a protocol failure. */
|
|
40
|
+
isError?: boolean;
|
|
41
|
+
}>;
|
|
42
|
+
export type McpToolAnnotations = Readonly<{
|
|
43
|
+
readOnlyHint?: boolean;
|
|
44
|
+
destructiveHint?: boolean;
|
|
45
|
+
idempotentHint?: boolean;
|
|
46
|
+
}>;
|
|
47
|
+
/** One tool after its input type is erased for the registry. */
|
|
48
|
+
export type McpTool = Readonly<{
|
|
49
|
+
name: string;
|
|
50
|
+
title: string;
|
|
51
|
+
description: string;
|
|
52
|
+
inputSchema: z.ZodType;
|
|
53
|
+
annotations?: McpToolAnnotations;
|
|
54
|
+
run: (input: unknown, caller: McpCaller) => Promise<McpToolResult>;
|
|
55
|
+
}>;
|
|
56
|
+
/** A domain's contribution to the endpoint, all under one OAuth scope. */
|
|
57
|
+
export type McpToolSet = Readonly<{
|
|
58
|
+
scope: string;
|
|
59
|
+
tools: readonly McpTool[];
|
|
60
|
+
/**
|
|
61
|
+
* The feature flag that rolls this set out, if any. The kit only carries
|
|
62
|
+
* it: the composition root's `isToolSetOn` decides what it means for a
|
|
63
|
+
* caller, and a set that is off is neither listed nor callable.
|
|
64
|
+
*/
|
|
65
|
+
featureFlag?: string;
|
|
66
|
+
}>;
|
|
67
|
+
/** Whether one tool set is on for one caller (its feature flag, typically). */
|
|
68
|
+
export type IsMcpToolSetOn = (toolSet: McpToolSet, caller: McpCaller) => Promise<boolean>;
|
|
69
|
+
/**
|
|
70
|
+
* Types one tool's input against its schema. The endpoint parses arguments with
|
|
71
|
+
* `inputSchema` before `run` sees them, so `run` only ever gets parsed input.
|
|
72
|
+
*/
|
|
73
|
+
export declare function defineMcpTool<Schema extends z.ZodType>(definition: {
|
|
74
|
+
name: string;
|
|
75
|
+
title: string;
|
|
76
|
+
description: string;
|
|
77
|
+
inputSchema: Schema;
|
|
78
|
+
annotations?: McpToolAnnotations;
|
|
79
|
+
run: (input: z.output<Schema>, caller: McpCaller) => Promise<McpToolResult>;
|
|
80
|
+
}): McpTool;
|
|
81
|
+
/**
|
|
82
|
+
* Turns the request's `Authorization` header into the person it was issued
|
|
83
|
+
* to, or null for a missing, unknown, expired or revoked token, or a person
|
|
84
|
+
* who may no longer sign in. Implemented by the identity domain.
|
|
85
|
+
*/
|
|
86
|
+
export type ResolveMcpBearer = (authorization: string | undefined) => Promise<Readonly<{
|
|
87
|
+
userId: string;
|
|
88
|
+
scopes: readonly string[];
|
|
89
|
+
/** The OAuth client the token was issued to. */
|
|
90
|
+
clientId?: string;
|
|
91
|
+
/** The name that client registered under, when it gave one. */
|
|
92
|
+
clientName?: string;
|
|
93
|
+
}> | null>;
|
|
94
|
+
//# sourceMappingURL=mcp-tool.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mcp-tool.d.ts","sourceRoot":"","sources":["../../../src/lib/mcp/mcp-tool.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAE7B,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,gCAAgC,CAAC;AAEjE;;;;GAIG;AACH,MAAM,MAAM,SAAS,GAAG,QAAQ,CAAC;IAC/B,OAAO,EAAE,UAAU,CAAC;IACpB,SAAS,EAAE,MAAM,CAAC;IAClB;;;;OAIG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,+DAA+D;IAC/D,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB,CAAC,CAAC;AAEH,2DAA2D;AAC3D,MAAM,MAAM,UAAU,GAClB,QAAQ,CAAC;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,CAAC,GACxC,QAAQ,CAAC;IAAE,IAAI,EAAE,OAAO,CAAC;IAAC,IAAI,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAA;CAAE,CAAC,GAC3D,QAAQ,CAAC;IACP,IAAI,EAAE,UAAU,CAAC;IACjB,QAAQ,EAAE,QAAQ,CAAC;QAAE,GAAG,EAAE,MAAM,CAAC;QAAC,QAAQ,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;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;IACb,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,EAAE,MAAM,CAAC;IACpB,WAAW,EAAE,MAAM,CAAC;IACpB,WAAW,CAAC,EAAE,kBAAkB,CAAC;IACjC,GAAG,EAAE,CAAC,KAAK,EAAE,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,EAAE,MAAM,EAAE,SAAS,KAAK,OAAO,CAAC,aAAa,CAAC,CAAC;CAC7E,GAAG,OAAO,CAMV;AAED;;;;GAIG;AACH,MAAM,MAAM,gBAAgB,GAAG,CAC7B,aAAa,EAAE,MAAM,GAAG,SAAS,KAC9B,OAAO,CAAC,QAAQ,CAAC;IACpB,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,SAAS,MAAM,EAAE,CAAC;IAC1B,gDAAgD;IAChD,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,+DAA+D;IAC/D,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB,CAAC,GAAG,IAAI,CAAC,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Types one tool's input against its schema. The endpoint parses arguments with
|
|
3
|
+
* `inputSchema` before `run` sees them, so `run` only ever gets parsed input.
|
|
4
|
+
*/
|
|
5
|
+
export function defineMcpTool(definition) {
|
|
6
|
+
return {
|
|
7
|
+
...definition,
|
|
8
|
+
run: async (input, caller) => definition.run(definition.inputSchema.parse(input), caller),
|
|
9
|
+
};
|
|
10
|
+
}
|
|
11
|
+
//# sourceMappingURL=mcp-tool.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mcp-tool.js","sourceRoot":"","sources":["../../../src/lib/mcp/mcp-tool.ts"],"names":[],"mappings":"AAwEA;;;GAGG;AACH,MAAM,UAAU,aAAa,CAA2B,UAOvD;IACC,OAAO;QACL,GAAG,UAAU;QACb,GAAG,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,EAAE,CAC3B,UAAU,CAAC,GAAG,CAAC,UAAU,CAAC,WAAW,CAAC,KAAK,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC;KAC9D,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"object-value.d.ts","sourceRoot":"","sources":["../../src/lib/object-value.ts"],"names":[],"mappings":"AAAA,wEAAwE;AACxE,wBAAgB,aAAa,CAC3B,KAAK,EAAE,OAAO,GACb,KAAK,IAAI,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAElC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"object-value.js","sourceRoot":"","sources":["../../src/lib/object-value.ts"],"names":[],"mappings":"AAAA,wEAAwE;AACxE,MAAM,UAAU,aAAa,CAC3B,KAAc;IAEd,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,CAAC;AACrD,CAAC"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { RawRouteDefinition } from "../route/define-raw-route.js";
|
|
2
|
+
import type { RouteDefinition } from "../route/route-definition.js";
|
|
3
|
+
/**
|
|
4
|
+
* OpenAPI generated from the route table — never hand-written (ADR-0006,
|
|
5
|
+
* docs/architecture/api-documentation.md). Schemas convert via Zod 4's
|
|
6
|
+
* native `z.toJSONSchema` targeting OpenAPI 3.0 (matching the committed
|
|
7
|
+
* artifact's dialect); the enveloped response components are built with the
|
|
8
|
+
* same `apiResponseSchema` the contract libs use, so the document cannot
|
|
9
|
+
* drift from the wire truth.
|
|
10
|
+
*/
|
|
11
|
+
export type OpenApiTag = {
|
|
12
|
+
readonly name: string;
|
|
13
|
+
readonly description: string;
|
|
14
|
+
};
|
|
15
|
+
export type OpenApiDocumentMeta = {
|
|
16
|
+
readonly title: string;
|
|
17
|
+
readonly description: string;
|
|
18
|
+
readonly version: string;
|
|
19
|
+
readonly tags: readonly OpenApiTag[];
|
|
20
|
+
/** Prepended to every route path (the app's global prefix), e.g. "/api". */
|
|
21
|
+
readonly pathPrefix: string;
|
|
22
|
+
};
|
|
23
|
+
type JsonRecord = Record<string, unknown>;
|
|
24
|
+
/** Builds the full OpenAPI 3.0 document from a route table. */
|
|
25
|
+
export declare function buildOpenApiDocument(routes: readonly (RouteDefinition | RawRouteDefinition)[], meta: OpenApiDocumentMeta): JsonRecord;
|
|
26
|
+
export {};
|
|
27
|
+
//# sourceMappingURL=build-document.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"build-document.d.ts","sourceRoot":"","sources":["../../../src/lib/openapi/build-document.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,8BAA8B,CAAC;AACvE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;AAIpE;;;;;;;GAOG;AAEH,MAAM,MAAM,UAAU,GAAG;IACvB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;CAC9B,CAAC;AAEF,MAAM,MAAM,mBAAmB,GAAG;IAChC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,IAAI,EAAE,SAAS,UAAU,EAAE,CAAC;IACrC,4EAA4E;IAC5E,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;CAC7B,CAAC;AAEF,KAAK,UAAU,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AA8N1C,+DAA+D;AAC/D,wBAAgB,oBAAoB,CAClC,MAAM,EAAE,SAAS,CAAC,eAAe,GAAG,kBAAkB,CAAC,EAAE,EACzD,IAAI,EAAE,mBAAmB,GACxB,UAAU,CA4BZ"}
|