schema-components 2.0.1 → 2.0.2

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.
@@ -37,7 +37,7 @@ declare function detectSchemaKind(input: unknown): SchemaKind;
37
37
  * The _zod guard in normaliseZod4 has confirmed this is a valid Zod schema,
38
38
  * but TypeScript cannot represent "has _zod.def" as the $ZodType parameter
39
39
  * that z.toJSONSchema expects. This is the library boundary equivalent of
40
- * object → Record<string, unknown> — the type mismatch is genuinely unavoidable.
40
+ * `object → Record<string, unknown>` — the type mismatch is genuinely unavoidable.
41
41
  *
42
42
  * # Options
43
43
  *
@@ -4,7 +4,7 @@ import { SchemaNormalisationError } from "./errors.mjs";
4
4
  import { appendPointer, emitDiagnostic } from "./diagnostics.mjs";
5
5
  import { dereference } from "./ref.mjs";
6
6
  import { detectOpenApiVersion, inferJsonSchemaDraftWithReason, isSwagger2, matchJsonSchemaDraftUri } from "./version.mjs";
7
- import { a as normaliseJsonSchema$1, o as normaliseOpenApiSchemas } from "../normalise-DB-Xtjmn.mjs";
7
+ import { a as normaliseJsonSchema$1, o as normaliseOpenApiSchemas } from "../normalise-BkePrJ4v.mjs";
8
8
  import { z } from "zod";
9
9
  //#region src/core/adapter.ts
10
10
  /**
@@ -118,8 +118,8 @@ function callToJsonSchema(schema, io = "output") {
118
118
  * without ever being told the wrapping was lost.
119
119
  *
120
120
  * Detection happens BEFORE the call to `z.toJSONSchema` so the response is
121
- * an immediate `SchemaNormalisationError` with `kind:
122
- * "zod-type-unrepresentable"`, matching the philosophy of
121
+ * an immediate `SchemaNormalisationError` with `kind: "zod-type-unrepresentable"`,
122
+ * matching the philosophy of
123
123
  * `UnrepresentableZodType` in `typeInference.ts` — these types are
124
124
  * rejected, not coerced.
125
125
  */
@@ -373,33 +373,41 @@ function unrepresentableMessage(typeName, fullMessage) {
373
373
  }
374
374
  /**
375
375
  * Classifier rules ordered most-specific first. Order is load-bearing:
376
- * `Literal \`undefined\` cannot be represented` must precede the broader
377
- * `Undefined cannot be represented` so the literal classification wins
378
- * even when both share a leading word. A consistency check in the unit
379
- * test suite asserts no two `prefix` values are prefixes of each other —
380
- * any future rule that breaks the invariant fails the build.
376
+ * the Literal-undefined message must precede the broader
377
+ * Undefined-cannot-be-represented message so the literal classification
378
+ * wins even when both share a leading word. A consistency check in the
379
+ * unit test suite asserts no two `prefix` values are prefixes of each
380
+ * other — any future rule that breaks the invariant fails the build.
381
381
  *
382
382
  * Verbatim sources (kept aligned with `tests/zod-error-wording-contract.unit.test.ts`).
383
383
  * Source files are referenced by message-content anchors rather than line
384
384
  * numbers — line numbers drift across Zod patch releases but the message
385
- * strings themselves are stable and protected by the contract test suite:
385
+ * strings themselves are stable and protected by the contract test suite.
386
386
  *
387
- * - `zod/src/v4/core/json-schema-processors.ts` — emits `BigInt cannot be
388
- * represented`, `Symbols cannot be represented`, `Undefined cannot be
389
- * represented`, `Void cannot be represented`, `Date cannot be
390
- * represented`, `Literal \`undefined\` cannot be represented`,
391
- * `BigInt literals cannot be represented`, `NaN cannot be represented`,
392
- * `Custom types cannot be represented`, `Function types cannot be
393
- * represented`, `Transforms cannot be represented`, `Map cannot be
394
- * represented`, `Set cannot be represented`, `Dynamic catch values are
395
- * not supported`.
396
- * - `zod/src/v4/core/to-json-schema.ts` emits `[toJSONSchema]:
397
- * Non-representable type encountered: ${def.type}` (the catch-all
398
- * fallback), `Unprocessed schema. This is a bug in Zod.` (the
399
- * internal-bug branch), `Duplicate schema id "${id}" detected during
400
- * JSON Schema conversion.` (the duplicate-id branch), `Cycle detected:
401
- * ` (the cycle-throw branch), and `Error converting schema to JSON.`
402
- * (the Standard Schema boundary wrapper).
387
+ * Messages from `zod/src/v4/core/json-schema-processors.ts`:
388
+ *
389
+ * - `BigInt cannot be represented`
390
+ * - `Symbols cannot be represented`
391
+ * - `Undefined cannot be represented`
392
+ * - `Void cannot be represented`
393
+ * - `Date cannot be represented`
394
+ * - the Literal-undefined message (the string literal at the matching `prefix` below holds the verbatim Zod text, including its own embedded backticks)
395
+ * - `BigInt literals cannot be represented`
396
+ * - `NaN cannot be represented`
397
+ * - `Custom types cannot be represented`
398
+ * - `Function types cannot be represented`
399
+ * - `Transforms cannot be represented`
400
+ * - `Map cannot be represented`
401
+ * - `Set cannot be represented`
402
+ * - `Dynamic catch values are not supported`
403
+ *
404
+ * Messages from `zod/src/v4/core/to-json-schema.ts`:
405
+ *
406
+ * - `[toJSONSchema]: Non-representable type encountered: ${def.type}` (the catch-all fallback)
407
+ * - `Unprocessed schema. This is a bug in Zod.` (the internal-bug branch)
408
+ * - `Duplicate schema id "${id}" detected during JSON Schema conversion.` (the duplicate-id branch)
409
+ * - `Cycle detected: ` (the cycle-throw branch)
410
+ * - `Error converting schema to JSON.` (the Standard Schema boundary wrapper)
403
411
  */
404
412
  const CLASSIFIER_RULES = [
405
413
  {
@@ -8,8 +8,8 @@
8
8
  *
9
9
  * The `object → Record<string, unknown>` conversion (`toRecord`) is
10
10
  * the one place where a cast is genuinely unavoidable — TypeScript's
11
- * `object` type has no index signature. See AGENTS.md: "object →
12
- * Record<string, unknown>".
11
+ * `object` type has no index signature. See AGENTS.md
12
+ * (`object → Record<string, unknown>`).
13
13
  */
14
14
  /**
15
15
  * Narrows `unknown` to a non-null, non-array object.
@@ -8,8 +8,8 @@
8
8
  *
9
9
  * The `object → Record<string, unknown>` conversion (`toRecord`) is
10
10
  * the one place where a cast is genuinely unavoidable — TypeScript's
11
- * `object` type has no index signature. See AGENTS.md: "object →
12
- * Record<string, unknown>".
11
+ * `object` type has no index signature. See AGENTS.md
12
+ * (`object → Record<string, unknown>`).
13
13
  */
14
14
  /**
15
15
  * Narrows `unknown` to a non-null, non-array object.
@@ -1,2 +1,2 @@
1
- import { a as InferredValue, i as InferredOutputValue, n as InferSchemaValue, r as InferredInputValue, t as InferFields } from "../inferValue-PPXWJpbN.mjs";
1
+ import { a as InferredValue, i as InferredOutputValue, n as InferSchemaValue, r as InferredInputValue, t as InferFields } from "../inferValue-Ce-PviSD.mjs";
2
2
  export { InferFields, InferSchemaValue, InferredInputValue, InferredOutputValue, InferredValue };
@@ -75,12 +75,12 @@ declare function deepNormaliseWithContext(schema: Record<string, unknown>, trans
75
75
  * single node.
76
76
  *
77
77
  * In Draft 04:
78
- * - `exclusiveMinimum: true` + `minimum: 5` → value must be > 5
79
- * - `exclusiveMinimum: false` (or absent) + `minimum: 5` → value must be >= 5
78
+ * - `exclusiveMinimum: true` + `minimum: 5` → value must be \> 5
79
+ * - `exclusiveMinimum: false` (or absent) + `minimum: 5` → value must be \>= 5
80
80
  *
81
81
  * In Draft 06+:
82
- * - `exclusiveMinimum: 5` → value must be > 5 (no separate `minimum`)
83
- * - `minimum: 5` → value must be >= 5
82
+ * - `exclusiveMinimum: 5` → value must be \> 5 (no separate `minimum`)
83
+ * - `minimum: 5` → value must be \>= 5
84
84
  *
85
85
  * The transform converts boolean form to number form so the walker can
86
86
  * treat `exclusiveMinimum`/`exclusiveMaximum` uniformly as numbers.
@@ -1,2 +1,2 @@
1
- import { a as normaliseJsonSchema, i as normaliseDraft04Node, n as deepNormaliseWithContext, o as normaliseOpenApiSchemas, r as documentContainsKeyword, s as selectDraftTransform, t as deepNormalise } from "../normalise-DB-Xtjmn.mjs";
1
+ import { a as normaliseJsonSchema, i as normaliseDraft04Node, n as deepNormaliseWithContext, o as normaliseOpenApiSchemas, r as documentContainsKeyword, s as selectDraftTransform, t as deepNormalise } from "../normalise-BkePrJ4v.mjs";
2
2
  export { deepNormalise, deepNormaliseWithContext, documentContainsKeyword, normaliseDraft04Node, normaliseJsonSchema, normaliseOpenApiSchemas, selectDraftTransform };
@@ -31,7 +31,7 @@ declare function normaliseOpenApi30Node(node: Record<string, unknown>): Record<s
31
31
  * values into each `oneOf`/`anyOf` option's discriminator property.
32
32
  *
33
33
  * In OpenAPI 3.0, `discriminator` is a sibling of `oneOf`/`anyOf`:
34
- * discriminator: { propertyName: "type" }
34
+ * `discriminator: { propertyName: "type" }`
35
35
  * The walker detects discriminated unions from `oneOf` + `const` on a
36
36
  * property, so this normaliser injects the `const` values from the
37
37
  * `mapping` or infers them from `$ref` fragment names.
@@ -1,2 +1,2 @@
1
- import { d as deepNormaliseOpenApiDoc, f as liftExampleToExamples, h as normaliseOpenApi30Node, l as applyDiscriminatorAllOfPrepass, m as normaliseOpenApi30Discriminator, p as normaliseOpenApi30Combined, u as deepNormaliseOpenApi30Doc } from "../normalise-DB-Xtjmn.mjs";
1
+ import { d as deepNormaliseOpenApiDoc, f as liftExampleToExamples, h as normaliseOpenApi30Node, l as applyDiscriminatorAllOfPrepass, m as normaliseOpenApi30Discriminator, p as normaliseOpenApi30Combined, u as deepNormaliseOpenApi30Doc } from "../normalise-BkePrJ4v.mjs";
2
2
  export { applyDiscriminatorAllOfPrepass, deepNormaliseOpenApi30Doc, deepNormaliseOpenApiDoc, liftExampleToExamples, normaliseOpenApi30Combined, normaliseOpenApi30Discriminator, normaliseOpenApi30Node };
@@ -1,2 +1,2 @@
1
- import { c as normaliseSwagger2Document } from "../normalise-DB-Xtjmn.mjs";
1
+ import { c as normaliseSwagger2Document } from "../normalise-BkePrJ4v.mjs";
2
2
  export { normaliseSwagger2Document };
@@ -117,23 +117,23 @@ type FromJSONSchemaMode = "input" | "output" | "both";
117
117
  *
118
118
  * Supports all JSON Schema draft versions (04-2020-12) and OpenAPI 3.x:
119
119
  * - Primitive types: string, number, integer, boolean, null
120
- * - type as array: `["string", "null"]` -> `string | null` (nullable)
121
- * - enum -> union of literal types
122
- * - const -> literal type
123
- * - object with properties/required -> specific object type
124
- * - object with properties + additionalProperties -> object & Record<string, V>
125
- * - object with additionalProperties only -> Record<string, T>
126
- * - array with items -> T[]
127
- * - array with prefixItems -> tuple type
128
- * - allOf -> intersection type
129
- * - anyOf -> union type
130
- * - oneOf -> union type (plain union, or tagged union when `discriminator` is set)
131
- * - $ref -> resolved via $defs/definitions/$anchor context
132
- * - $dynamicRef -> resolved via $dynamicAnchor in definitions
133
- * - $recursiveRef -> unknown (recursive types not expressible in TS)
134
- * - if/then/else -> base schema (conditionals not expressible in TS)
135
- * - not -> unknown (negation not expressible in TS)
136
- * - patternProperties -> merged into loose index signature
120
+ * - type as array: `["string", "null"]` -\> `string | null` (nullable)
121
+ * - enum -\> union of literal types
122
+ * - const -\> literal type
123
+ * - object with properties/required -\> specific object type
124
+ * - object with properties + additionalProperties -\> object & `Record<string, V>`
125
+ * - object with additionalProperties only -\> `Record<string, T>`
126
+ * - array with items -\> `T[]`
127
+ * - array with prefixItems -\> tuple type
128
+ * - allOf -\> intersection type
129
+ * - anyOf -\> union type
130
+ * - oneOf -\> union type (plain union, or tagged union when `discriminator` is set)
131
+ * - $ref -\> resolved via $defs/definitions/$anchor context
132
+ * - $dynamicRef -\> resolved via $dynamicAnchor in definitions
133
+ * - $recursiveRef -\> unknown (recursive types not expressible in TS)
134
+ * - if/then/else -\> base schema (conditionals not expressible in TS)
135
+ * - not -\> unknown (negation not expressible in TS)
136
+ * - patternProperties -\> merged into loose index signature
137
137
  *
138
138
  * The `Mode` parameter controls how `readOnly` / `writeOnly` keywords
139
139
  * influence inferred object properties — see {@link FromJSONSchemaMode}.
@@ -279,11 +279,12 @@ interface __SchemaInferenceFellBack {
279
279
  * a silent default.
280
280
  *
281
281
  * Earlier revisions made the brand optional (`__unsafe?: true`).
282
- * That defeated the brand's purpose: any plain `Record<string,
283
- * FieldOverride>` literal silently satisfied the type and the
284
- * "unsafe" intent was invisible to readers and reviewers. Marking
285
- * the brand required forces callers to write `{ __unsafe: true,
286
- * ... }`, making the escape-hatch use visible at the call site.
282
+ * That defeated the brand's purpose: any plain
283
+ * `Record<string, FieldOverride>` literal silently satisfied the type
284
+ * and the "unsafe" intent was invisible to readers and reviewers.
285
+ * Marking the brand required forces callers to write
286
+ * `{ __unsafe: true, ... }`, making the escape-hatch use visible at
287
+ * the call site.
287
288
  *
288
289
  * The brand key is carved out of the field-name index signature so
289
290
  * `__unsafe: true` does not collide with the `FieldOverride` value
@@ -367,8 +368,8 @@ type ResolveSchemaRef<R extends string, Defs extends Record<string, unknown>, De
367
368
  * but TypeScript's mapped-type machinery — combined with the conditional
368
369
  * dispatch above — does not always recover that distribution when the
369
370
  * union arises from a `FromJSONSchema` expansion. The pinned regression
370
- * test `allOf of unions is treated as the intersection of the union
371
- * members` in `tests/type-inference-issue-fixes.test.ts` documents the
371
+ * test "allOf of unions is treated as the intersection of the union
372
+ * members" in `tests/type-inference-issue-fixes.test.ts` documents the
372
373
  * current behaviour so future refactors do not silently make it worse.
373
374
  * There is no known way to express "distribute every member-side union
374
375
  * across the intersection" in TypeScript today without losing the
@@ -487,7 +488,7 @@ type NullableResult<Base, S> = S extends {
487
488
  type: readonly (infer T)[];
488
489
  } ? "null" extends T ? Base | null : Base : Base;
489
490
  /**
490
- * Parse an array schema: prefixItems -> tuple, items -> T[], or unknown[].
491
+ * Parse an array schema: prefixItems -\> tuple, items -\> `T[]`, or `unknown[]`.
491
492
  *
492
493
  * Draft 04 used tuple-form `items` (an array of schemas) for tuple typing;
493
494
  * Draft 2020-12 renamed this to `prefixItems`. The runtime normaliser in
@@ -511,19 +512,19 @@ type ArraySchemaToTs<S, Defs extends Record<string, unknown>, Depth extends read
511
512
  */
512
513
  type PrefixItemsToTuple<P, Defs extends Record<string, unknown>, Depth extends readonly unknown[] = [], Mode extends FromJSONSchemaMode = "both"> = P extends readonly [infer First, ...infer Rest] ? [FromJSONSchema<First, Defs, Depth, Mode>, ...PrefixItemsToTuple<Rest, Defs, Depth, Mode>] : [];
513
514
  /**
514
- * Parse an object schema: properties + required -> specific object,
515
- * additionalProperties -> Record, or empty object.
515
+ * Parse an object schema: properties + required -\> specific object,
516
+ * additionalProperties -\> Record, or empty object.
516
517
  *
517
518
  * Handles:
518
- * - `properties` + `required` -> specific object type with required/optional keys
519
- * - `additionalProperties` as schema -> Record<string, T>
520
- * - `properties` + `additionalProperties` -> base object intersected with
519
+ * - `properties` + `required` -\> specific object type with required/optional keys
520
+ * - `additionalProperties` as schema -\> `Record<string, T>`
521
+ * - `properties` + `additionalProperties` -\> base object intersected with
521
522
  * `Record<string, V>`, preserving the typed value shape of the extra props
522
- * - `patternProperties` -> merged into a loose index signature alongside specific props
523
+ * - `patternProperties` -\> merged into a loose index signature alongside specific props
523
524
  * (TypeScript cannot express regex-keyed properties)
524
- * - `propertyNames` -> ignored at type level (TS cannot validate key shapes)
525
- * - `dependentSchemas` / `dependentRequired` -> ignored (runtime-only conditionals)
526
- * - `unevaluatedProperties` -> ignored (runtime-only)
525
+ * - `propertyNames` -\> ignored at type level (TS cannot validate key shapes)
526
+ * - `dependentSchemas` / `dependentRequired` -\> ignored (runtime-only conditionals)
527
+ * - `unevaluatedProperties` -\> ignored (runtime-only)
527
528
  *
528
529
  * Properties marked `readOnly: true` are omitted when `Mode` is
529
530
  * `"input"`; properties marked `writeOnly: true` are omitted when
@@ -628,7 +629,7 @@ type RawComponentSchemasOf<S> = S extends {
628
629
  };
629
630
  } ? D extends Record<string, unknown> ? D : Record<string, never> : Record<string, never>;
630
631
  /**
631
- * Build a map of `$anchor` name -> schema from a definitions block.
632
+ * Build a map of `$anchor` name -\> schema from a definitions block.
632
633
  * Scans each definition value for `$anchor`, `$dynamicAnchor`, or the
633
634
  * Draft 2019-09 `$recursiveAnchor` keyword and creates entries like
634
635
  * `{ Tree: <schema-with-$anchor-Tree> }`.
@@ -651,7 +652,7 @@ type ExtractAnchors<D extends Record<string, unknown>> = { [K in keyof D as D[K]
651
652
  } ? "__recursive__" : never]: D[K] };
652
653
  /**
653
654
  * Convert a union to an intersection.
654
- * `A | B` -> `A & B`. Used for allOf merging.
655
+ * `A | B` -\> `A & B`. Used for allOf merging.
655
656
  */
656
657
  type UnionToIntersection<U> = (U extends unknown ? (k: U) => void : never) extends ((k: infer I) => void) ? I : never;
657
658
  /**
@@ -702,11 +703,11 @@ type ExtractDefinitions<Spec> = Spec extends {
702
703
  /**
703
704
  * Resolve a path-based $ref after the `#/paths/` prefix.
704
705
  * Splits on `/` and navigates the document tree, decoding JSON Pointer
705
- * tilde escapes (`~1` -> `/`, `~0` -> `~`) on every segment.
706
+ * tilde escapes (`~1` -\> `/`, `~0` -\> `~`) on every segment.
706
707
  *
707
708
  * SOURCE-OF-TRUTH: mirrors runtime `dereference` in
708
709
  * `packages/core/src/core/ref.ts` (line 226), which applies the same
709
- * `~1` -> `/`, `~0` -> `~` substitutions per RFC 6901 §4. The runtime
710
+ * `~1` -\> `/`, `~0` -\> `~` substitutions per RFC 6901 §4. The runtime
710
711
  * uses ordered string replacement; the type-level mirror does the same
711
712
  * via {@link DecodeJsonPointerSegment}.
712
713
  */
@@ -721,14 +722,14 @@ type ResolvePathBasedRef<Spec extends Record<string, unknown>, PathRest extends
721
722
  type ReplaceAll<S extends string, From extends string, To extends string> = S extends `${infer Head}${From}${infer Tail}` ? `${Head}${To}${ReplaceAll<Tail, From, To>}` : S;
722
723
  /**
723
724
  * Decode a single JSON Pointer reference token per RFC 6901 §4:
724
- * apply `~1` -> `/` first, then `~0` -> `~`. The order matters — an
725
+ * apply `~1` -\> `/` first, then `~0` -\> `~`. The order matters — an
725
726
  * encoded `~` containing a literal `1` (e.g. `~01`) must remain `~1`
726
727
  * after decoding, which only works when `~1` is processed first.
727
728
  */
728
729
  type DecodeJsonPointerSegment<S extends string> = ReplaceAll<ReplaceAll<S, "~1", "/">, "~0", "~">;
729
730
  /**
730
731
  * Split a path string on `/` into a tuple of segments.
731
- * The first segment is the path key (may be empty for `/pets` -> `""` / `"pets"`).
732
+ * The first segment is the path key (may be empty for `/pets` -\> `""` / `"pets"`).
732
733
  */
733
734
  type SplitPath<S extends string> = S extends `${infer Head}/${infer Tail}` ? [Head, ...SplitPath<Tail>] : [S];
734
735
  /**
@@ -801,7 +802,7 @@ type ResponseSchemaOf<Op, Status extends string, ContentType extends string = DE
801
802
  } ? S : unknown : unknown : unknown : unknown : unknown : unknown : unknown;
802
803
  /**
803
804
  * Resolve a response entry from a status code following the OpenAPI
804
- * priority order: concrete > class wildcard > `default`. When none of
805
+ * priority order: concrete \> class wildcard \> `default`. When none of
805
806
  * the three matches, the result is `never` and the caller's outer
806
807
  * conditional falls through to `unknown`.
807
808
  */
@@ -895,7 +896,7 @@ type OpenAPIRequestBodyType<Doc, Path extends string, Method extends string, Con
895
896
  * declared content type when the default is absent.
896
897
  *
897
898
  * Status-code resolution follows the OpenAPI priority order: concrete
898
- * code > class wildcard (e.g. `"2XX"`) > `"default"`. See
899
+ * code \> class wildcard (e.g. `"2XX"`) \> `"default"`. See
899
900
  * {@link ResponseSchemaOf}.
900
901
  *
901
902
  * Swagger 2.0 documents are not normalised at the type level. When the
@@ -928,8 +929,8 @@ type OpenAPIResponseType<Doc, Path extends string, Method extends string, Status
928
929
  * documents, and the existing `@ts-expect-error` regressions in
929
930
  * `type-inference.test.ts` rely on the current widening behaviour.
930
931
  * The trade-off is pinned by the
931
- * `FieldsFromInferred widens to Record<string, FieldOverride> when the
932
- * operation is unknown` regression test.
932
+ * "FieldsFromInferred widens to `Record<string, FieldOverride>` when the
933
+ * operation is unknown" regression test.
933
934
  */
934
935
  type FieldsFromInferred<T> = [T] extends [__SchemaInferenceFellBack] ? __SchemaInferenceFellBack : unknown extends T ? Record<string, FieldOverride> : FieldOverrides<T>;
935
936
  /**
@@ -33,8 +33,8 @@ declare function isSafeHyperlink(value: string): boolean;
33
33
  * the resulting `mailto:` URI. Refuse any value containing `%` to close
34
34
  * that header-injection vector. The plain email-format regex stays a
35
35
  * pure email-syntax check; the additional `%` filter lives here so other
36
- * callers of the format pattern (form validators, JSON Schema `format:
37
- * email` checks) are not affected.
36
+ * callers of the format pattern (form validators, JSON Schema
37
+ * `format: email` checks) are not affected.
38
38
  */
39
39
  declare function isSafeMailtoAddress(value: string): boolean;
40
40
  /**
package/dist/core/uri.mjs CHANGED
@@ -70,8 +70,8 @@ function isSafeHyperlink(value) {
70
70
  * the resulting `mailto:` URI. Refuse any value containing `%` to close
71
71
  * that header-injection vector. The plain email-format regex stays a
72
72
  * pure email-syntax check; the additional `%` filter lives here so other
73
- * callers of the format pattern (form validators, JSON Schema `format:
74
- * email` checks) are not affected.
73
+ * callers of the format pattern (form validators, JSON Schema
74
+ * `format: email` checks) are not affected.
75
75
  */
76
76
  function isSafeMailtoAddress(value) {
77
77
  if (value.includes("%")) return false;
@@ -115,7 +115,7 @@ declare function buildFileField(schema: Record<string, unknown>, ctx: WalkContex
115
115
  * cannot represent a JSON Schema and have no walk-time meaning.
116
116
  */
117
117
  declare function walkSubSchemaMap<T>(map: Record<string, unknown>, walkSubSchema: (schema: unknown, ctx: WalkContext) => T, ctx: WalkContext): Record<string, T>;
118
- /** Walk a dependentRequired map (Record<string, string[]>). */
118
+ /** Walk a dependentRequired map (`Record<string, string[]>`). */
119
119
  declare function walkDependentRequiredMap(map: Record<string, unknown>): Record<string, string[]>;
120
120
  /**
121
121
  * Return a copy of the schema without the specified keys.
@@ -161,7 +161,7 @@ function walkSubSchemaMap(map, walkSubSchema, ctx) {
161
161
  for (const [key, value] of Object.entries(map)) if (isObject(value) || typeof value === "boolean") result[key] = walkSubSchema(value, ctx);
162
162
  return result;
163
163
  }
164
- /** Walk a dependentRequired map (Record<string, string[]>). */
164
+ /** Walk a dependentRequired map (`Record<string, string[]>`). */
165
165
  function walkDependentRequiredMap(map) {
166
166
  const result = {};
167
167
  for (const [key, value] of Object.entries(map)) if (Array.isArray(value)) result[key] = value.filter((x) => typeof x === "string");
@@ -47,9 +47,9 @@ function walkSubSchema(value, ctx) {
47
47
  * JSON Schema 2020-12 §11.2/§11.3 semantics:
48
48
  *
49
49
  * false (forbid all extras)
50
- * > schema-object (extras must match the schema)
51
- * > true (extras explicitly permitted)
52
- * > absent (extras implicitly permitted)
50
+ * \> schema-object (extras must match the schema)
51
+ * \> true (extras explicitly permitted)
52
+ * \> absent (extras implicitly permitted)
53
53
  *
54
54
  * Unknown shapes (numbers, arrays, strings) sort below absent — we
55
55
  * cannot reason about them, so do not let them override anything.
@@ -12,16 +12,18 @@
12
12
  *
13
13
  * Usage:
14
14
  *
15
- * import { h, serialize } from "./html.ts";
15
+ * ```ts
16
+ * import { h, serialize } from "./html.ts";
16
17
  *
17
- * const el = h("input", { type: "text", id: "name", "aria-required": true });
18
- * serialize(el); // → '<input type="text" id="name" aria-required>'
18
+ * const el = h("input", { type: "text", id: "name", "aria-required": true });
19
+ * serialize(el); // → '<input type="text" id="name" aria-required>'
19
20
  *
20
- * const form = h("form", {},
21
- * h("label", { for: "name" }, "Name"),
22
- * h("input", { type: "text", id: "name" }),
23
- * );
24
- * serialize(form); // → '<form><label for="name">Name</label><input type="text" id="name"></form>'
21
+ * const form = h("form", {},
22
+ * h("label", { for: "name" }, "Name"),
23
+ * h("input", { type: "text", id: "name" }),
24
+ * );
25
+ * serialize(form); // → '<form><label for="name">Name</label><input type="text" id="name"></form>'
26
+ * ```
25
27
  */
26
28
  /**
27
29
  * An HTML element node. Void elements (input, br, etc.) have no children
@@ -2,7 +2,7 @@ import { w as SchemaMeta } from "../types-BrYbjC7_.mjs";
2
2
  import { SchemaIoSide } from "../core/adapter.mjs";
3
3
  import { HtmlResolver } from "../core/renderer.mjs";
4
4
  import { RejectUnrepresentableZod } from "../core/typeInference.mjs";
5
- import { a as InferredValue, t as InferFields } from "../inferValue-PPXWJpbN.mjs";
5
+ import { a as InferredValue, t as InferFields } from "../inferValue-Ce-PviSD.mjs";
6
6
 
7
7
  //#region src/html/renderToHtml.d.ts
8
8
  /**
@@ -18,14 +18,20 @@ import { defaultHtmlResolver } from "./renderers.mjs";
18
18
  * compile-time tag/attribute checking and automatic escaping.
19
19
  *
20
20
  * Usage:
21
- * import { renderToHtml } from "schema-components/html/renderToHtml";
22
- * const html = renderToHtml(userSchema, { value: userData });
21
+ *
22
+ * ```ts
23
+ * import { renderToHtml } from "schema-components/html/renderToHtml";
24
+ * const html = renderToHtml(userSchema, { value: userData });
25
+ * ```
23
26
  *
24
27
  * Custom resolver:
25
- * const html = renderToHtml(schema, {
26
- * value,
27
- * resolver: { string: (props) => h("b", {}, String(props.value)) },
28
- * });
28
+ *
29
+ * ```ts
30
+ * const html = renderToHtml(schema, {
31
+ * value,
32
+ * resolver: { string: (props) => h("b", {}, String(props.value)) },
33
+ * });
34
+ * ```
29
35
  */
30
36
  /**
31
37
  * Build the recursion-cap sentinel element used when the renderer
@@ -2,7 +2,7 @@ import { w as SchemaMeta } from "../types-BrYbjC7_.mjs";
2
2
  import { SchemaIoSide } from "../core/adapter.mjs";
3
3
  import { HtmlResolver } from "../core/renderer.mjs";
4
4
  import { RejectUnrepresentableZod } from "../core/typeInference.mjs";
5
- import { a as InferredValue, t as InferFields } from "../inferValue-PPXWJpbN.mjs";
5
+ import { a as InferredValue, t as InferFields } from "../inferValue-Ce-PviSD.mjs";
6
6
 
7
7
  //#region src/html/renderToHtmlStream.d.ts
8
8
  /**
@@ -46,9 +46,9 @@ type NarrowAtPath<V, P extends string | undefined> = P extends string ? TypeAtPa
46
46
  * Public alias mapping a schema input to the rendered value type.
47
47
  *
48
48
  * Picks the OUTPUT side (server → client) of every transform / pipe /
49
- * codec. For an `<SchemaComponent io="output">` or `<SchemaView
50
- * io="output">` (both defaults), this is the inferred shape of
51
- * `value` and the parameter of `onChange`.
49
+ * codec. For a `<SchemaComponent io="output">` or `<SchemaView io="output">`
50
+ * (both defaults), this is the inferred shape of `value` and the
51
+ * parameter of `onChange`.
52
52
  */
53
53
  type InferredOutputValue<T, Ref extends string | undefined = undefined, P extends string | undefined = undefined> = NarrowAtPath<InferSchemaValue<T, Ref, "output">, P>;
54
54
  /**
@@ -125,7 +125,7 @@ function compositeAlreadyAllowsNull(options) {
125
125
  * values into each `oneOf`/`anyOf` option's discriminator property.
126
126
  *
127
127
  * In OpenAPI 3.0, `discriminator` is a sibling of `oneOf`/`anyOf`:
128
- * discriminator: { propertyName: "type" }
128
+ * `discriminator: { propertyName: "type" }`
129
129
  * The walker detects discriminated unions from `oneOf` + `const` on a
130
130
  * property, so this normaliser injects the `const` values from the
131
131
  * `mapping` or infers them from `$ref` fragment names.
@@ -1308,7 +1308,7 @@ function normaliseSwaggerHeader(header, diagnostics, pointer = "") {
1308
1308
  * Deep-rewrite $ref strings in a normalised Swagger 2.0 document
1309
1309
  * from Swagger 2.0 locations to OpenAPI 3.x locations using the
1310
1310
  * shared {@link rewriteSwaggerRefPrefix} mapping. Mutates the object
1311
- * in place \u2014 called only on the fresh clone produced by
1311
+ * in place called only on the fresh clone produced by
1312
1312
  * normaliseSwagger2Document.
1313
1313
  */
1314
1314
  function rewriteSwaggerRefs(node) {
@@ -1764,12 +1764,12 @@ function applyDraft04Translations(node, ctx) {
1764
1764
  * single node.
1765
1765
  *
1766
1766
  * In Draft 04:
1767
- * - `exclusiveMinimum: true` + `minimum: 5` → value must be > 5
1768
- * - `exclusiveMinimum: false` (or absent) + `minimum: 5` → value must be >= 5
1767
+ * - `exclusiveMinimum: true` + `minimum: 5` → value must be \> 5
1768
+ * - `exclusiveMinimum: false` (or absent) + `minimum: 5` → value must be \>= 5
1769
1769
  *
1770
1770
  * In Draft 06+:
1771
- * - `exclusiveMinimum: 5` → value must be > 5 (no separate `minimum`)
1772
- * - `minimum: 5` → value must be >= 5
1771
+ * - `exclusiveMinimum: 5` → value must be \> 5 (no separate `minimum`)
1772
+ * - `minimum: 5` → value must be \>= 5
1773
1773
  *
1774
1774
  * The transform converts boolean form to number form so the walker can
1775
1775
  * treat `exclusiveMinimum`/`exclusiveMaximum` uniformly as numbers.
@@ -363,7 +363,7 @@ interface ApiResponseProps<Doc = unknown, Path extends PathKeysOf<Doc> = PathKey
363
363
  * picked out of `schema` by `path`, `method`, and `status`.
364
364
  *
365
365
  * Status resolution follows the OpenAPI priority order: concrete code
366
- * (e.g. `"200"`) > class wildcard (e.g. `"2XX"`) > `"default"`. When
366
+ * (e.g. `"200"`) \> class wildcard (e.g. `"2XX"`) \> `"default"`. When
367
367
  * `schema` is typed `as const`, `fields` autocomplete resolves from
368
368
  * the response schema; pass `contentType` to narrow inference to a
369
369
  * specific media type.
@@ -286,7 +286,7 @@ function ApiRequestBody({ schema: doc, path, method, value, onChange, meta, fiel
286
286
  * picked out of `schema` by `path`, `method`, and `status`.
287
287
  *
288
288
  * Status resolution follows the OpenAPI priority order: concrete code
289
- * (e.g. `"200"`) > class wildcard (e.g. `"2XX"`) > `"default"`. When
289
+ * (e.g. `"200"`) \> class wildcard (e.g. `"2XX"`) \> `"default"`. When
290
290
  * `schema` is typed `as const`, `fields` autocomplete resolves from
291
291
  * the response schema; pass `contentType` to narrow inference to a
292
292
  * specific media type.
@@ -3,7 +3,7 @@ import "../core/limits.mjs";
3
3
  import { emitDiagnostic } from "../core/diagnostics.mjs";
4
4
  import { isPrototypePollutingKey } from "../core/uri.mjs";
5
5
  import { detectOpenApiVersion } from "../core/version.mjs";
6
- import { o as normaliseOpenApiSchemas, r as documentContainsKeyword } from "../normalise-DB-Xtjmn.mjs";
6
+ import { o as normaliseOpenApiSchemas, r as documentContainsKeyword } from "../normalise-BkePrJ4v.mjs";
7
7
  import { resolveRefChain } from "../core/refChain.mjs";
8
8
  import { extractParameters, extractRequestBody, extractResponses, listAllOperations, parseOpenApiDocument } from "./parser.mjs";
9
9
  //#region src/openapi/resolve.ts
@@ -4,7 +4,7 @@ import { SchemaIoSide } from "../core/adapter.mjs";
4
4
  import { ComponentResolver, RenderProps, WidgetMap } from "../core/renderer.mjs";
5
5
  import { t as SchemaError } from "../errors-Dki7tji4.mjs";
6
6
  import { FromJSONSchema, PathOfType, RejectUnrepresentableZod } from "../core/typeInference.mjs";
7
- import { a as InferredValue, i as InferredOutputValue, n as InferSchemaValue, r as InferredInputValue, t as InferFields } from "../inferValue-PPXWJpbN.mjs";
7
+ import { a as InferredValue, i as InferredOutputValue, n as InferSchemaValue, r as InferredInputValue, t as InferFields } from "../inferValue-Ce-PviSD.mjs";
8
8
  import { z } from "zod";
9
9
  import * as _$react_jsx_runtime0 from "react/jsx-runtime";
10
10
  import { ReactNode } from "react";
@@ -102,9 +102,9 @@ interface SchemaComponentProps<T = unknown, Ref extends string | undefined = und
102
102
  */
103
103
  io?: Mode;
104
104
  /**
105
- * Current value to render. Typed against `InferSchemaValue<T,
106
- * Ref, Mode>` so the prop tracks the schema's inferred shape for
107
- * the chosen `io` direction.
105
+ * Current value to render. Typed against
106
+ * `InferSchemaValue<T, Ref, Mode>` so the prop tracks the schema's
107
+ * inferred shape for the chosen `io` direction.
108
108
  *
109
109
  * Falls back to `unknown` when the schema's value type cannot be
110
110
  * statically inferred (runtime `Record<string, unknown>` JSON
@@ -19,10 +19,10 @@ import { createContext, isValidElement, useCallback, useContext, useId, useMemo
19
19
  * ComponentResolver (theme adapter). Falls back to headless HTML.
20
20
  *
21
21
  * The `fields` prop type is inferred from the `schema` prop:
22
- * - Zod schemas → FieldOverrides<z.infer<T>> (full autocomplete)
23
- * - JSON Schema `as const` → FieldOverrides<FromJSONSchema<T>> (full autocomplete)
24
- * - OpenAPI `as const` + `ref` → FieldOverrides<ResolveOpenAPIRef<T, Ref>>
25
- * - Runtime schemas → Record<string, FieldOverride> (no autocomplete)
22
+ * - Zod schemas → `FieldOverrides<z.infer<T>>` (full autocomplete)
23
+ * - JSON Schema `as const` → `FieldOverrides<FromJSONSchema<T>>` (full autocomplete)
24
+ * - OpenAPI `as const` + `ref` → `FieldOverrides<ResolveOpenAPIRef<T, Ref>>`
25
+ * - Runtime schemas → `Record<string, FieldOverride>` (no autocomplete)
26
26
  */
27
27
  const UserResolverContext = createContext(void 0);
28
28
  const WidgetsContext = createContext(void 0);
@@ -384,9 +384,9 @@ function SchemaField({ path, schema: schemaInput, ref: refInput, value, onChange
384
384
  * (`FieldOverrides<U>`) and the loose `Record<string, FieldOverride>`
385
385
  * fallback share the same structural shape, so the dispatch logic only
386
386
  * needs the loose record. The previous parameter union
387
- * (`Record<string, FieldOverride> | FieldOverrides<unknown> |
388
- * undefined`) collapsed because `FieldOverrides<unknown>` reduces to
389
- * `{}`, contributing no extra precision while adding noise to readers.
387
+ * (`Record<string, FieldOverride> | FieldOverrides<unknown> | undefined`)
388
+ * collapsed because `FieldOverrides<unknown>` reduces to `{}`,
389
+ * contributing no extra precision while adding noise to readers.
390
390
  */
391
391
  function dispatchFieldErrors(fields, error) {
392
392
  if (fields === void 0 || !isObject(error)) return;
@@ -10,11 +10,14 @@ import { Component } from "react";
10
10
  * crashes the entire React tree.
11
11
  *
12
12
  * Usage:
13
- * import { SchemaErrorBoundary } from "schema-components/react/SchemaErrorBoundary";
14
13
  *
15
- * <SchemaErrorBoundary fallback={(error) => <p>{error.message}</p>}>
16
- * <SchemaComponent schema={userSchema} value={user} />
17
- * </SchemaErrorBoundary>
14
+ * ```tsx
15
+ * import { SchemaErrorBoundary } from "schema-components/react/SchemaErrorBoundary";
16
+ *
17
+ * <SchemaErrorBoundary fallback={(error) => <p>{error.message}</p>}>
18
+ * <SchemaComponent schema={userSchema} value={user} />
19
+ * </SchemaErrorBoundary>
20
+ * ```
18
21
  *
19
22
  * The boundary catches `SchemaRenderError` from theme adapters and any
20
23
  * other errors thrown during rendering. It does NOT catch:
@@ -3,7 +3,7 @@ import { t as Diagnostic } from "../diagnostics-BTrm3O6J.mjs";
3
3
  import { SchemaIoSide } from "../core/adapter.mjs";
4
4
  import { ComponentResolver, WidgetMap } from "../core/renderer.mjs";
5
5
  import { RejectUnrepresentableZod } from "../core/typeInference.mjs";
6
- import { a as InferredValue, t as InferFields } from "../inferValue-PPXWJpbN.mjs";
6
+ import { a as InferredValue, t as InferFields } from "../inferValue-Ce-PviSD.mjs";
7
7
  import { ReactNode } from "react";
8
8
 
9
9
  //#region src/react/SchemaView.d.ts
@@ -38,10 +38,11 @@ interface SchemaViewProps<T = unknown, Ref extends string | undefined = undefine
38
38
  */
39
39
  io?: Mode;
40
40
  /**
41
- * Current value to render. Typed against `InferSchemaValue<T,
42
- * Ref, Mode>` so the prop tracks the schema's inferred shape for
43
- * the chosen `io` direction. Falls back to `unknown` for runtime
44
- * schemas where the value type cannot be statically inferred.
41
+ * Current value to render. Typed against
42
+ * `InferSchemaValue<T, Ref, Mode>` so the prop tracks the schema's
43
+ * inferred shape for the chosen `io` direction. Falls back to
44
+ * `unknown` for runtime schemas where the value type cannot be
45
+ * statically inferred.
45
46
  */
46
47
  value?: InferredValue<T, Ref, undefined, Mode>;
47
48
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "schema-components",
3
- "version": "2.0.1",
3
+ "version": "2.0.2",
4
4
  "description": "React components that render UI from Zod schemas, JSON Schema, and OpenAPI documents",
5
5
  "type": "module",
6
6
  "exports": {