/** * Runtime reflection for schemas and registered routes. * * Standard Schema deliberately standardizes validation, not introspection. This module makes that * distinction explicit: `standard` is present when a value can validate, while `jsonSchema` and * `fields` are present only when the value carries inspectable JSON Schema metadata. The implementation * recognizes Nifra/TypeBox carriers and raw JSON Schema without depending on a validator package. */ import { type ResponseClassification } from "./classification.js"; import { type AssuranceEvidence } from "./internal/route-assurance.js"; import type { StandardSchemaV1 } from "./schema/standard.js"; import type { ToolAnnotations } from "./server/server.js"; /** JSON Schema permits either a schema object or the boolean schemas `true` and `false`. */ export type JsonSchema = boolean | Readonly>; /** One top-level property of an introspectable object schema. */ export interface ReflectedSchemaField { readonly name: string; readonly required: boolean; readonly schema: JsonSchema; } /** Validation and introspection capabilities discovered for one schema-like value. */ export interface SchemaReflection { /** The Standard Schema validator, when the value implements Standard Schema v1. */ readonly standard: StandardSchemaV1 | undefined; /** Raw JSON Schema metadata, when the value exposes it or is itself a raw JSON Schema. */ readonly jsonSchema: JsonSchema | undefined; /** Top-level object fields, or `undefined` when the JSON Schema is absent/non-object. */ readonly fields: readonly ReflectedSchemaField[] | undefined; } export interface ReflectedRouteSchema { /** Effective transport body policy; surfaced so upload/streaming exemptions are auditable. */ readonly bodyLimit?: number | "unlimited"; readonly bodyLimitReason?: string; /** Request-header schema; names are normalized to lower-case at runtime. */ readonly headers?: SchemaReflection; readonly body?: SchemaReflection; readonly query?: SchemaReflection; /** Path-params schema - constraints (uuid format, integer min/max) declared via `params: t.object(…)`. */ readonly params?: SchemaReflection; readonly response?: SchemaReflection; readonly errors?: Readonly>; /** The SSE event-payload schema of a typed streaming route (`app.sse()`). */ readonly sse?: SchemaReflection; } export interface ReflectedRoute { readonly method: string; readonly path: string; readonly schema?: ReflectedRouteSchema; readonly assurance?: readonly AssuranceEvidence[]; readonly capabilities?: readonly string[]; /** Set when the route is a declared dynamic route family (a runtime-resolved template like * `/api/:slug/:resource`) - so the assurance gate treats it as one classified family, not a single route. */ readonly family?: boolean; /** Field-level response classification plus the highest sensitivity present. */ readonly classification?: ResponseClassification; readonly tool?: { readonly name: string; readonly description: string; readonly annotations?: ToolAnnotations; }; } /** * Reflect a Standard Schema, Nifra/TypeBox schema carrier, or raw JSON Schema. Never throws. * Validation-only schemas have `standard` but no `jsonSchema`; raw JSON Schema has the reverse. */ export declare function reflectSchema(value: unknown): SchemaReflection; /** * Safely enumerate and normalize route descriptors from an app or descriptor array. Invalid entries * are ignored; a missing/throwing `routes()` method yields an empty array. */ export declare function reflectRoutes(source: unknown): readonly ReflectedRoute[]; //# sourceMappingURL=reflection.d.ts.map