schema-components 1.17.0 → 1.18.1
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/dist/core/adapter.d.mts +1 -1
- package/dist/core/constraints.d.mts +1 -1
- package/dist/core/diagnostics.d.mts +1 -1
- package/dist/core/fieldOrder.d.mts +10 -0
- package/dist/core/fieldOrder.mjs +12 -0
- package/dist/core/merge.d.mts +14 -8
- package/dist/core/merge.mjs +109 -12
- package/dist/core/normalise.d.mts +1 -1
- package/dist/core/ref.d.mts +1 -1
- package/dist/core/renderer.d.mts +2 -2
- package/dist/core/renderer.mjs +31 -1
- package/dist/core/swagger2.d.mts +1 -1
- package/dist/core/typeInference.d.mts +2 -2
- package/dist/core/walkBuilders.d.mts +2 -2
- package/dist/core/walker.mjs +2 -2
- package/dist/{diagnostics-DzbZmcLI.d.mts → diagnostics-BYk63jsC.d.mts} +1 -1
- package/dist/html/a11y.d.mts +13 -2
- package/dist/html/a11y.mjs +26 -2
- package/dist/html/renderToHtml.d.mts +1 -1
- package/dist/html/renderToHtml.mjs +18 -33
- package/dist/html/renderToHtmlStream.d.mts +1 -1
- package/dist/html/renderers.d.mts +4 -3
- package/dist/html/renderers.mjs +37 -36
- package/dist/html/streamRenderers.d.mts +1 -1
- package/dist/html/streamRenderers.mjs +10 -21
- package/dist/openapi/ApiSecurity.mjs +1 -1
- package/dist/openapi/bundle.d.mts +9 -4
- package/dist/openapi/bundle.mjs +74 -15
- package/dist/openapi/components.d.mts +1 -1
- package/dist/openapi/components.mjs +20 -15
- package/dist/openapi/parser.d.mts +2 -2
- package/dist/openapi/parser.mjs +12 -12
- package/dist/openapi/resolve.d.mts +13 -2
- package/dist/openapi/resolve.mjs +19 -3
- package/dist/react/SchemaComponent.d.mts +3 -3
- package/dist/react/SchemaComponent.mjs +1 -30
- package/dist/react/SchemaView.d.mts +4 -3
- package/dist/react/SchemaView.mjs +12 -43
- package/dist/react/headless.d.mts +1 -1
- package/dist/react/headlessRenderers.d.mts +1 -1
- package/dist/react/headlessRenderers.mjs +37 -32
- package/dist/{ref-DvWoULcy.d.mts → ref-Ckt5liZs.d.mts} +1 -1
- package/dist/{renderer-B3s8o2B8.d.mts → renderer-BAGoX4AK.d.mts} +20 -26
- package/dist/themes/mantine.d.mts +1 -1
- package/dist/themes/mantine.mjs +6 -4
- package/dist/themes/mui.d.mts +1 -1
- package/dist/themes/mui.mjs +7 -5
- package/dist/themes/radix.d.mts +1 -1
- package/dist/themes/radix.mjs +5 -4
- package/dist/themes/shadcn.d.mts +1 -1
- package/dist/themes/shadcn.mjs +8 -6
- package/dist/{typeInference-k7FXfTVO.d.mts → typeInference-5JiqIZ8t.d.mts} +57 -4
- package/package.json +1 -1
|
@@ -84,26 +84,71 @@ type UnsafeFields = Record<string, FieldOverride> & {
|
|
|
84
84
|
* Returns the original type when the schema is non-recursive.
|
|
85
85
|
*/
|
|
86
86
|
type DetectRecursiveFallback<T> = unknown extends T ? __SchemaInferenceFellBack : T;
|
|
87
|
+
/**
|
|
88
|
+
* Type-level recursion bound for $ref resolution.
|
|
89
|
+
*
|
|
90
|
+
* The TypeScript type system imposes its own recursion limit; without an
|
|
91
|
+
* explicit bound a cyclic schema graph would exhaust it and degrade to
|
|
92
|
+
* `any`/`unknown` silently. Ten levels is the runtime walker's parallel
|
|
93
|
+
* — see `countDistinctRefs` in `ref.ts` (lines 52-55), which derives its
|
|
94
|
+
* bound from the number of distinct `$ref` strings in the document.
|
|
95
|
+
*
|
|
96
|
+
* A fixed bound is used here rather than a derived one because the type
|
|
97
|
+
* system has no way to count distinct strings across a recursive `Defs`
|
|
98
|
+
* map without itself recursing — which is the problem the bound exists
|
|
99
|
+
* to solve. Ten covers every realistic schema graph encountered in
|
|
100
|
+
* practice; deeper graphs surface as `__SchemaInferenceFellBack` so
|
|
101
|
+
* consumers can detect the limit explicitly.
|
|
102
|
+
*/
|
|
103
|
+
type DEFAULT_MAX_DEPTH = 10;
|
|
87
104
|
/**
|
|
88
105
|
* Resolve a $ref against the local definitions context.
|
|
106
|
+
*
|
|
107
|
+
* SOURCE-OF-TRUTH: mirrors runtime `resolveRef` in
|
|
108
|
+
* `packages/core/src/core/ref.ts` (line 90). Any change to the runtime
|
|
109
|
+
* ref-resolution rules (new ref forms, different cycle handling) must be
|
|
110
|
+
* reflected here and pinned in
|
|
111
|
+
* `packages/core/tests/typeInference-walker-parity.test.ts`.
|
|
112
|
+
*
|
|
89
113
|
* Supports:
|
|
90
114
|
* - `#` (root)
|
|
91
115
|
* - `#/$defs/Name` and `#/definitions/Name` (named definitions)
|
|
92
116
|
* - `#SomeName` ($anchor, $dynamicAnchor resolved from definitions)
|
|
93
117
|
*/
|
|
94
|
-
type ResolveSchemaRef<R extends string, Defs extends Record<string, unknown>, Depth extends number = 0> = Depth extends
|
|
118
|
+
type ResolveSchemaRef<R extends string, Defs extends Record<string, unknown>, Depth extends number = 0> = Depth extends DEFAULT_MAX_DEPTH ? __SchemaInferenceFellBack : R extends "#" ? unknown : R extends `#/$defs/${infer Name}` ? Name extends keyof Defs ? DetectRecursiveFallback<FromJSONSchema<Defs[Name], Defs>> : unknown : R extends `#/definitions/${infer Name}` ? Name extends keyof Defs ? DetectRecursiveFallback<FromJSONSchema<Defs[Name], Defs>> : unknown : R extends `#${infer AnchorName}` ? AnchorName extends keyof Defs ? DetectRecursiveFallback<FromJSONSchema<Defs[AnchorName], Defs>> : unknown : unknown;
|
|
95
119
|
/**
|
|
96
120
|
* Merge an allOf array into an intersection type.
|
|
97
121
|
*/
|
|
98
122
|
type AllOfToType<A, Defs extends Record<string, unknown>> = A extends readonly unknown[] ? UnionToIntersection<FromJSONSchema<A[number], Defs>> : unknown;
|
|
99
123
|
/**
|
|
100
124
|
* Convert an anyOf/oneOf array into a union type.
|
|
101
|
-
*
|
|
102
|
-
*
|
|
125
|
+
*
|
|
126
|
+
* SOURCE-OF-TRUTH: mirrors runtime `walkUnion` (and the
|
|
127
|
+
* `walkDiscriminatedUnion` fast path) in
|
|
128
|
+
* `packages/core/src/core/walker.ts` (lines 723-752), together with
|
|
129
|
+
* `detectDiscriminated` and `normaliseAnyOf` in
|
|
130
|
+
* `packages/core/src/core/merge.ts` (lines 190-260).
|
|
131
|
+
*
|
|
132
|
+
* Deliberate divergence: the walker collapses qualifying `oneOf` members
|
|
133
|
+
* into a `discriminatedUnion` field at runtime. The type-level helper
|
|
134
|
+
* produces a plain TypeScript union because a discriminated union and a
|
|
135
|
+
* plain union over the same members are structurally indistinguishable
|
|
136
|
+
* at the type level. Parity is pinned in
|
|
137
|
+
* `packages/core/tests/typeInference-walker-parity.test.ts`.
|
|
138
|
+
*
|
|
139
|
+
* Filters out `{ type: "null" }` members and instead makes the result
|
|
140
|
+
* nullable when at least one null member is present — mirrors the
|
|
141
|
+
* walker's `normaliseAnyOf`.
|
|
103
142
|
*/
|
|
104
143
|
type UnionOfMembers<A, Defs extends Record<string, unknown>> = A extends readonly unknown[] ? HasNullMember<A> extends true ? Exclude<FromJSONSchema<A[number], Defs>, null> | null : FromJSONSchema<A[number], Defs> : unknown;
|
|
105
144
|
/**
|
|
106
145
|
* Check whether an anyOf/oneOf array contains a `{ type: "null" }` member.
|
|
146
|
+
*
|
|
147
|
+
* SOURCE-OF-TRUTH: mirrors runtime `normaliseAnyOf` in
|
|
148
|
+
* `packages/core/src/core/merge.ts` (lines 190-209). Both implementations
|
|
149
|
+
* only recognise schema-shaped null members (`{ type: "null" }`); a bare
|
|
150
|
+
* `null` literal in the array is treated as non-nullable. Parity is
|
|
151
|
+
* pinned in `packages/core/tests/typeInference-walker-parity.test.ts`.
|
|
107
152
|
*/
|
|
108
153
|
type HasNullMember<A> = A extends readonly unknown[] ? null extends A[number] ? false : {
|
|
109
154
|
type: "null";
|
|
@@ -214,6 +259,14 @@ type UnionToIntersection<U> = (U extends unknown ? (k: U) => void : never) exten
|
|
|
214
259
|
/**
|
|
215
260
|
* Resolves an OpenAPI `ref` string to its JSON Schema, then parses it.
|
|
216
261
|
*
|
|
262
|
+
* SOURCE-OF-TRUTH: mirrors runtime `resolveRef` in
|
|
263
|
+
* `packages/core/src/core/ref.ts` (line 90), which is invoked by the
|
|
264
|
+
* walker entry point in `packages/core/src/core/walker.ts` (lines
|
|
265
|
+
* 144-154) for OpenAPI documents. Any change to the runtime ref-resolution
|
|
266
|
+
* rules (new ref forms, different cycle handling, JSON Pointer decoding)
|
|
267
|
+
* must be reflected here and pinned in
|
|
268
|
+
* `packages/core/tests/typeInference-walker-parity.test.ts`.
|
|
269
|
+
*
|
|
217
270
|
* Handles:
|
|
218
271
|
* - `#/components/schemas/Name` (OpenAPI 3.x)
|
|
219
272
|
* - `#/definitions/Name` (Swagger 2.0)
|
|
@@ -332,4 +385,4 @@ type PathOfType<T, Prefix extends string = ""> = IsNarrowObject<T> extends true
|
|
|
332
385
|
*/
|
|
333
386
|
type TypeAtPath<T, P extends string> = P extends `${infer Key}.${infer Rest}` ? Key extends keyof T ? TypeAtPath<T[Key], Rest> : unknown : P extends keyof T ? T[P] : unknown;
|
|
334
387
|
//#endregion
|
|
335
|
-
export {
|
|
388
|
+
export { InferResponseFields as a, PathOfType as c, UnsafeFields as d, __SchemaInferenceFellBack as f, InferRequestBodyFields as i, ResolveOpenAPIRef as l, FromJSONSchema as n, OpenAPIRequestBodyType as o, InferParameterOverrides as r, OpenAPIResponseType as s, DEFAULT_MAX_DEPTH as t, TypeAtPath as u };
|