refactor: close type holes on the transport and error axes

- OpenApiRoute.transport was typed `string`, so the compiler could not check the
  transport branching at all. Type it Transport and key the documented 200 off a
  Record, so a new transport fails the build instead of silently going undocumented.
- pickEncoder fell through to ndjson for unknown transports; make the mapping
  exhaustive so a new transport cannot inherit the wrong wire format by accident.
- HttpError carries optional headers, removing the instanceof Redirect special case
  that coupled the error renderer to one subclass. Custom errors needing headers
  (retry-after, etag) no longer require touching transformers.
- Drop the module-global connSeq in mesh/link: `pending` is already per-connection,
  so a per-link counter suffices and connection ids stop depending on test order.

Signed-off-by: Diego Resendez <diego.resendez@zero-oneit.com>
This commit is contained in:
chrnx committed 2026-07-15 14:37:03 -05:00
1 parent 9421b102d9
commit d56eeafcd8
5 files changed
+55 -36

No files matched your search

+7 -2
View File
@@ -1,11 +1,16 @@
import type { StandardIssue } from './standard-schema';
/** Error carrying an HTTP status code and optional response body. Base of all signals. */
/**
* Error carrying an HTTP status code and optional response body. Base of all signals.
* A subclass needing response headers (e.g. `location`, `retry-after`) sets `headers`
* rather than requiring a special case in the error renderer.
*/
export class HttpError extends Error {
constructor(
readonly status: number,
message?: string,
readonly body?: unknown,
readonly headers?: Record<string, string>,
) {
super(message ?? `HTTP ${status}`);
this.name = new.target.name;
@@ -36,7 +41,7 @@ export class NotModified extends HttpError {
/** 302 redirect to `location`. */
export class Redirect extends HttpError {
constructor(readonly location: string) {
super(302);
super(302, undefined, undefined, { location });
}
}