schema-components 2.0.1 → 2.1.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/README.md +98 -1
- package/dist/SchemaComponent-B__6-5-E.d.mts +277 -0
- package/dist/SchemaComponent-BxzzsHsK.mjs +668 -0
- package/dist/adapter-ktQaheWB.d.mts +213 -0
- package/dist/constructorTypes-BdCiMS6e.d.mts +30 -0
- package/dist/core/adapter.d.mts +3 -213
- package/dist/core/adapter.mjs +33 -25
- package/dist/core/constraintHint.d.mts +1 -1
- package/dist/core/constraints.d.mts +2 -2
- package/dist/core/contexts.d.mts +71 -0
- package/dist/core/contexts.mjs +1 -0
- package/dist/core/diagnostics.d.mts +1 -1
- package/dist/core/errors.d.mts +1 -1
- package/dist/core/fieldOrder.d.mts +1 -1
- package/dist/{react → core}/fieldPath.d.mts +2 -2
- package/dist/{react → core}/fieldPath.mjs +3 -3
- package/dist/core/formats.d.mts +1 -1
- package/dist/core/guards.d.mts +2 -2
- package/dist/core/guards.mjs +2 -2
- package/dist/core/inferValue.d.mts +1 -1
- package/dist/core/limits.d.mts +1 -1
- package/dist/core/merge.d.mts +1 -1
- package/dist/core/normalise.d.mts +6 -6
- package/dist/core/normalise.mjs +1 -1
- package/dist/core/openapi30.d.mts +1 -1
- package/dist/core/openapi30.mjs +1 -1
- package/dist/core/ref.d.mts +1 -1
- package/dist/core/renderField.d.mts +147 -0
- package/dist/core/renderField.mjs +81 -0
- package/dist/core/renderer.d.mts +2 -199
- package/dist/core/swagger2.d.mts +1 -1
- package/dist/core/swagger2.mjs +1 -1
- package/dist/core/typeInference.d.mts +1 -981
- package/dist/core/types.d.mts +1 -1
- package/dist/core/unionMatch.d.mts +1 -1
- package/dist/core/uri.d.mts +2 -2
- package/dist/core/uri.mjs +2 -2
- package/dist/core/version.d.mts +1 -1
- package/dist/core/walkBuilders.d.mts +4 -4
- package/dist/core/walkBuilders.mjs +1 -1
- package/dist/core/walker.d.mts +1 -1
- package/dist/core/walker.mjs +3 -3
- package/dist/{errors-Dki7tji4.d.mts → errors-DbaI04x2.d.mts} +1 -1
- package/dist/html/a11y.d.mts +2 -2
- package/dist/html/html.d.mts +10 -8
- package/dist/html/renderToHtml.d.mts +5 -5
- package/dist/html/renderToHtml.mjs +45 -24
- package/dist/html/renderToHtmlStream.d.mts +5 -5
- package/dist/html/renderers.d.mts +1 -1
- package/dist/html/streamRenderers.d.mts +3 -3
- package/dist/{inferValue-PPXWJpbN.d.mts → inferValue-eAnh50EM.d.mts} +6 -6
- package/dist/lit/SchemaComponent.d.mts +125 -0
- package/dist/lit/SchemaComponent.mjs +2 -0
- package/dist/lit/SchemaField.d.mts +65 -0
- package/dist/lit/SchemaField.mjs +2 -0
- package/dist/lit/SchemaView.d.mts +14 -0
- package/dist/lit/SchemaView.mjs +2 -0
- package/dist/lit/constructorTypes.d.mts +2 -0
- package/dist/lit/constructorTypes.mjs +1 -0
- package/dist/lit/contexts.d.mts +78 -0
- package/dist/lit/contexts.mjs +238 -0
- package/dist/lit/defaultResolver.d.mts +33 -0
- package/dist/lit/defaultResolver.mjs +2 -0
- package/dist/lit/registry.d.mts +66 -0
- package/dist/lit/registry.mjs +2 -0
- package/dist/lit/renderers/baseElement.d.mts +131 -0
- package/dist/lit/renderers/baseElement.mjs +109 -0
- package/dist/lit/renderers/recordHelpers.d.mts +25 -0
- package/dist/lit/renderers/recordHelpers.mjs +55 -0
- package/dist/lit/renderers/scArray.d.mts +14 -0
- package/dist/lit/renderers/scArray.mjs +86 -0
- package/dist/lit/renderers/scBoolean.d.mts +15 -0
- package/dist/lit/renderers/scBoolean.mjs +47 -0
- package/dist/lit/renderers/scConditional.d.mts +23 -0
- package/dist/lit/renderers/scConditional.mjs +65 -0
- package/dist/lit/renderers/scDiscriminated.d.mts +23 -0
- package/dist/lit/renderers/scDiscriminated.mjs +138 -0
- package/dist/lit/renderers/scEnum.d.mts +16 -0
- package/dist/lit/renderers/scEnum.mjs +66 -0
- package/dist/lit/renderers/scFile.d.mts +15 -0
- package/dist/lit/renderers/scFile.mjs +53 -0
- package/dist/lit/renderers/scLiteralNullNever.d.mts +30 -0
- package/dist/lit/renderers/scLiteralNullNever.mjs +57 -0
- package/dist/lit/renderers/scNumber.d.mts +15 -0
- package/dist/lit/renderers/scNumber.mjs +64 -0
- package/dist/lit/renderers/scObject.d.mts +14 -0
- package/dist/lit/renderers/scObject.mjs +57 -0
- package/dist/lit/renderers/scRecord.d.mts +14 -0
- package/dist/lit/renderers/scRecord.mjs +112 -0
- package/dist/lit/renderers/scString.d.mts +19 -0
- package/dist/lit/renderers/scString.mjs +165 -0
- package/dist/lit/renderers/scTuple.d.mts +14 -0
- package/dist/lit/renderers/scTuple.mjs +58 -0
- package/dist/lit/renderers/scUnion.d.mts +14 -0
- package/dist/lit/renderers/scUnion.mjs +44 -0
- package/dist/lit/renderers/scUnknown.d.mts +15 -0
- package/dist/lit/renderers/scUnknown.mjs +45 -0
- package/dist/lit/ssr.d.mts +37 -0
- package/dist/lit/ssr.mjs +9565 -0
- package/dist/lit/types.d.mts +2 -0
- package/dist/lit/types.mjs +1 -0
- package/dist/lit/widget.d.mts +71 -0
- package/dist/lit/widget.mjs +87 -0
- package/dist/{normalise-DB-Xtjmn.mjs → normalise-BkePrJ4v.mjs} +6 -6
- package/dist/openapi/ApiCallbacks.d.mts +1 -1
- package/dist/openapi/ApiLinks.d.mts +1 -1
- package/dist/openapi/ApiResponseHeaders.d.mts +1 -1
- package/dist/openapi/ApiSecurity.d.mts +1 -1
- package/dist/openapi/components.d.mts +5 -5
- package/dist/openapi/components.mjs +1 -1
- package/dist/openapi/parser.d.mts +2 -2
- package/dist/openapi/resolve.d.mts +1 -1
- package/dist/openapi/resolve.mjs +1 -1
- package/dist/preact/SchemaComponent.d.mts +3 -0
- package/dist/preact/SchemaComponent.mjs +26 -0
- package/dist/preact/SchemaErrorBoundary.d.mts +2 -0
- package/dist/preact/SchemaErrorBoundary.mjs +20 -0
- package/dist/preact/SchemaView.d.mts +2 -0
- package/dist/preact/SchemaView.mjs +22 -0
- package/dist/preact/headless.d.mts +2 -0
- package/dist/preact/headless.mjs +18 -0
- package/dist/react/SchemaComponent.d.mts +3 -270
- package/dist/react/SchemaComponent.mjs +48 -39
- package/dist/react/SchemaErrorBoundary.mjs +7 -4
- package/dist/react/SchemaView.d.mts +11 -10
- package/dist/react/SchemaView.mjs +32 -29
- package/dist/react/a11y.d.mts +2 -2
- package/dist/react/fieldShell.d.mts +1 -1
- package/dist/react/headless.d.mts +1 -1
- package/dist/react/headlessRenderers.d.mts +2 -2
- package/dist/{ref-DdsbekXX.d.mts → ref-DWrQG1Er.d.mts} +1 -1
- package/dist/renderer-ab9E52Bp.d.mts +245 -0
- package/dist/solid/SchemaComponent.d.mts +136 -0
- package/dist/solid/SchemaComponent.mjs +391 -0
- package/dist/solid/SchemaErrorBoundary.d.mts +38 -0
- package/dist/solid/SchemaErrorBoundary.mjs +57 -0
- package/dist/solid/SchemaField.d.mts +40 -0
- package/dist/solid/SchemaField.mjs +113 -0
- package/dist/solid/SchemaView.d.mts +54 -0
- package/dist/solid/SchemaView.mjs +168 -0
- package/dist/solid/a11y.d.mts +70 -0
- package/dist/solid/a11y.mjs +71 -0
- package/dist/solid/contexts.d.mts +37 -0
- package/dist/solid/contexts.mjs +66 -0
- package/dist/solid/headless.d.mts +10 -0
- package/dist/solid/headless.mjs +27 -0
- package/dist/solid/renderers.d.mts +79 -0
- package/dist/solid/renderers.mjs +840 -0
- package/dist/solid/types.d.mts +90 -0
- package/dist/solid/types.mjs +1 -0
- package/dist/solid/widget.d.mts +29 -0
- package/dist/solid/widget.mjs +35 -0
- package/dist/themes/mantine.d.mts +1 -1
- package/dist/themes/mui.d.mts +1 -1
- package/dist/themes/radix.d.mts +1 -1
- package/dist/themes/shadcn.d.mts +1 -1
- package/dist/typeInference-Y8tNEQJk.d.mts +983 -0
- package/dist/types-BCy7K3nk.d.mts +125 -0
- package/package.json +71 -1
- package/src/svelte/SchemaComponent.svelte +427 -0
- package/src/svelte/SchemaErrorBoundary.svelte +66 -0
- package/src/svelte/SchemaField.svelte +216 -0
- package/src/svelte/SchemaProvider.svelte +46 -0
- package/src/svelte/SchemaView.svelte +244 -0
- package/src/svelte/a11y.ts +112 -0
- package/src/svelte/contexts.ts +79 -0
- package/src/svelte/dispatch.ts +267 -0
- package/src/svelte/headless.ts +73 -0
- package/src/svelte/headlessFns.ts +124 -0
- package/src/svelte/renderers/Array.svelte +98 -0
- package/src/svelte/renderers/Boolean.svelte +43 -0
- package/src/svelte/renderers/Conditional.svelte +67 -0
- package/src/svelte/renderers/DiscriminatedUnion.svelte +197 -0
- package/src/svelte/renderers/Enum.svelte +53 -0
- package/src/svelte/renderers/Fallback.svelte +24 -0
- package/src/svelte/renderers/File.svelte +46 -0
- package/src/svelte/renderers/Literal.svelte +29 -0
- package/src/svelte/renderers/Mount.svelte +24 -0
- package/src/svelte/renderers/Negation.svelte +35 -0
- package/src/svelte/renderers/Never.svelte +24 -0
- package/src/svelte/renderers/Null.svelte +19 -0
- package/src/svelte/renderers/Number.svelte +68 -0
- package/src/svelte/renderers/Object.svelte +74 -0
- package/src/svelte/renderers/Record.svelte +134 -0
- package/src/svelte/renderers/RecursionSentinel.svelte +27 -0
- package/src/svelte/renderers/String.svelte +152 -0
- package/src/svelte/renderers/Tuple.svelte +84 -0
- package/src/svelte/renderers/Union.svelte +49 -0
- package/src/svelte/renderers/Unknown.svelte +42 -0
- package/src/svelte/svelte-modules.d.ts +25 -0
- package/src/svelte/types.ts +238 -0
- package/src/svelte/widget.ts +62 -0
- /package/dist/{diagnostics-BTrm3O6J.d.mts → diagnostics-mftUZI7c.d.mts} +0 -0
- /package/dist/{limits-x4OiyJxh.d.mts → limits-Vv9hUbI_.d.mts} +0 -0
- /package/dist/{types-BrYbjC7_.d.mts → types-BBQaEPfE.d.mts} +0 -0
- /package/dist/{version-DL8U5RuA.d.mts → version-BEBx10ND.d.mts} +0 -0
|
@@ -0,0 +1,213 @@
|
|
|
1
|
+
import { m as JsonObject, w as SchemaMeta } from "./types-BBQaEPfE.mjs";
|
|
2
|
+
import { i as DiagnosticsOptions } from "./diagnostics-mftUZI7c.mjs";
|
|
3
|
+
|
|
4
|
+
//#region src/core/adapter.d.ts
|
|
5
|
+
/**
|
|
6
|
+
* Classification produced by {@link detectSchemaKind} when inspecting a
|
|
7
|
+
* runtime schema input.
|
|
8
|
+
*
|
|
9
|
+
* @group Adapter
|
|
10
|
+
*/
|
|
11
|
+
type SchemaKind = "zod4" | "zod3" | "jsonSchema" | "openapi" | "unsupported-schema-lib";
|
|
12
|
+
/**
|
|
13
|
+
* Classify a runtime schema input by structural markers — Zod 4, Zod 3,
|
|
14
|
+
* OpenAPI document, plain JSON Schema, or an unsupported third-party
|
|
15
|
+
* schema library.
|
|
16
|
+
*
|
|
17
|
+
* - `zod4` — has a `_zod` marker (further validation that `_zod.def` is a
|
|
18
|
+
* non-null object happens inside `normaliseZod4`).
|
|
19
|
+
* - `zod3` — has `_def` and no `_zod`. The `typeName` field is no longer
|
|
20
|
+
* required: any `_def` without `_zod` is treated as a probable Zod 3
|
|
21
|
+
* schema. Third-party libraries that expose `_def` without `_zod` are
|
|
22
|
+
* nearly always Zod 3 forks; surfacing the migration message is the
|
|
23
|
+
* correct response.
|
|
24
|
+
* - `openapi` — has `openapi` or `swagger` at the root.
|
|
25
|
+
* - `unsupported-schema-lib` — has `parse` and `safeParse` callables but
|
|
26
|
+
* no `_zod` and no `_def` marker. This catches Standard Schema
|
|
27
|
+
* implementations (valibot, arktype, etc.) that would otherwise flow
|
|
28
|
+
* through as "malformed JSON Schema".
|
|
29
|
+
* - `jsonSchema` — fallback for anything that does not match the above.
|
|
30
|
+
*
|
|
31
|
+
* @group Adapter
|
|
32
|
+
*/
|
|
33
|
+
declare function detectSchemaKind(input: unknown): SchemaKind;
|
|
34
|
+
/**
|
|
35
|
+
* Wraps z.toJSONSchema() for a runtime-validated Zod schema.
|
|
36
|
+
*
|
|
37
|
+
* The _zod guard in normaliseZod4 has confirmed this is a valid Zod schema,
|
|
38
|
+
* but TypeScript cannot represent "has _zod.def" as the $ZodType parameter
|
|
39
|
+
* that z.toJSONSchema expects. This is the library boundary equivalent of
|
|
40
|
+
* `object → Record<string, unknown>` — the type mismatch is genuinely unavoidable.
|
|
41
|
+
*
|
|
42
|
+
* # Options
|
|
43
|
+
*
|
|
44
|
+
* `z.toJSONSchema` is invoked with an explicit options object rather than
|
|
45
|
+
* Zod's defaults so the conversion contract is pinned and stable:
|
|
46
|
+
*
|
|
47
|
+
* - `target: "draft-2020-12"` — matches the walker's draft target.
|
|
48
|
+
* - `unrepresentable: "throw"` — keeps the unrepresentable-type rules in
|
|
49
|
+
* the classifier table firing instead of silently emitting `{}`.
|
|
50
|
+
* - `cycles: "ref"` — converts cyclic graphs into $ref pairs rather than
|
|
51
|
+
* throwing. Cycles in user schemas surface through the walker's $ref
|
|
52
|
+
* resolution rather than the adapter.
|
|
53
|
+
* - `io` — selects which side of every transform / pipe / codec is
|
|
54
|
+
* converted. Defaults to `"output"` (the OUTPUT side); pass `"input"`
|
|
55
|
+
* to render the INPUT side instead. The input side is invisible to
|
|
56
|
+
* the converted schema when `io: "output"` is in force, even though
|
|
57
|
+
* `safeParse` on the same Zod schema consumes the input shape. For
|
|
58
|
+
* transforms this divergence is fatal and the call throws via
|
|
59
|
+
* `Transforms cannot be represented`; for `z.codec(...)` the call
|
|
60
|
+
* succeeds but only the selected side is rendered. Consumers receive
|
|
61
|
+
* a `zod-codec-output-only` diagnostic in the codec case so the
|
|
62
|
+
* asymmetry is visible — see `screenPreConversion`.
|
|
63
|
+
*
|
|
64
|
+
* # Error classification
|
|
65
|
+
*
|
|
66
|
+
* Any exception thrown by z.toJSONSchema is classified into a
|
|
67
|
+
* SchemaNormalisationError so the caller does not have to re-parse error
|
|
68
|
+
* message strings. The classification covers:
|
|
69
|
+
*
|
|
70
|
+
* - Nested Zod 3 schemas inside a Zod 4 tree → zod3-unsupported.
|
|
71
|
+
* Detected structurally (presence of `_def.typeName` markers anywhere
|
|
72
|
+
* in the schema tree) so the check works across V8, JavaScriptCore,
|
|
73
|
+
* and SpiderMonkey, none of which agree on the wording of
|
|
74
|
+
* "Cannot read properties of undefined".
|
|
75
|
+
* - Transforms → zod-transform-unsupported. This also catches `z.codec(…)`
|
|
76
|
+
* because Zod implements codecs as a pipe + transform internally, so
|
|
77
|
+
* they trip the same processor when round-tripping is forced. (Plain
|
|
78
|
+
* `z.toJSONSchema(codec)` itself does NOT throw because Zod picks one
|
|
79
|
+
* side of the codec; the static rejection in `typeInference.ts` is the
|
|
80
|
+
* compile-time guard.)
|
|
81
|
+
* - Dynamic catch values whose handler throws → zod-type-unrepresentable
|
|
82
|
+
* with zodType "dynamic-catch".
|
|
83
|
+
* - Unrepresentable types — bigint, date, map, set, symbol, function, custom,
|
|
84
|
+
* undefined, void, NaN, and the literal-only forms `z.literal(undefined)`
|
|
85
|
+
* ("undefined-literal") and `z.literal(<bigint>)` ("bigint-literal") →
|
|
86
|
+
* zod-type-unrepresentable.
|
|
87
|
+
* - The catch-all "Non-representable type encountered: <type>" fallback Zod
|
|
88
|
+
* emits for any new schema kind without a registered processor →
|
|
89
|
+
* zod-type-unrepresentable with zodType set to the offending def.type.
|
|
90
|
+
* - Cycle detected (`cycles: "throw"`) → zod-cycle-detected.
|
|
91
|
+
* - Duplicate schema id → zod-duplicate-id.
|
|
92
|
+
* - "Unprocessed schema. This is a bug in Zod." → zod-conversion-bug.
|
|
93
|
+
* - "Error converting schema to JSON." → zod-conversion-failed (explicit
|
|
94
|
+
* classification rather than the generic fallback so the contract test
|
|
95
|
+
* protects the prefix from drift).
|
|
96
|
+
* - Anything else → zod-conversion-failed.
|
|
97
|
+
*
|
|
98
|
+
* The original error is preserved on each classified error via the `cause`
|
|
99
|
+
* field so consumers can still inspect the Zod stack trace.
|
|
100
|
+
*/
|
|
101
|
+
/**
|
|
102
|
+
* Direction of the Zod transform / pipe / codec that
|
|
103
|
+
* {@link normaliseSchema} should surface to the renderer.
|
|
104
|
+
*
|
|
105
|
+
* - `"output"` (default) — the server-facing side of every transform,
|
|
106
|
+
* matching `z.toJSONSchema`'s default and the historic adapter
|
|
107
|
+
* behaviour.
|
|
108
|
+
* - `"input"` — the client-facing side; flips a `z.codec(...)` chain
|
|
109
|
+
* so consumers can render its input shape.
|
|
110
|
+
*
|
|
111
|
+
* @group Adapter
|
|
112
|
+
*/
|
|
113
|
+
type SchemaIoSide = "input" | "output";
|
|
114
|
+
/**
|
|
115
|
+
* True when `value` is a Zod schema implemented as a codec
|
|
116
|
+
* (`z.codec(...)`). Detection looks for the `$ZodCodec` marker on the
|
|
117
|
+
* schema's `_zod.traits` Set — the same structural check used by Zod
|
|
118
|
+
* itself in `to-json-schema.ts`'s `isTransforming` helper.
|
|
119
|
+
*
|
|
120
|
+
* Promoted from a duplicated local helper in `react/SchemaComponent.tsx`
|
|
121
|
+
* so the validation boundary inside `runValidation` can branch on
|
|
122
|
+
* codec-vs-not-codec without re-implementing the trait check. The
|
|
123
|
+
* shared helper anchors a single source of truth for codec detection:
|
|
124
|
+
* any future change to Zod's trait naming flows through here, not
|
|
125
|
+
* through two parallel copies.
|
|
126
|
+
*
|
|
127
|
+
* Returns `false` for non-objects, plain JSON Schema inputs, OpenAPI
|
|
128
|
+
* documents, or Zod schemas of any other kind. This is structural
|
|
129
|
+
* rather than nominal — a Zod 4 codec produced by any path that ends
|
|
130
|
+
* up tagging `_zod.traits` with `$ZodCodec` is recognised, including
|
|
131
|
+
* schemas wrapped by user-defined helpers.
|
|
132
|
+
*/
|
|
133
|
+
declare function isCodecSchema(value: unknown): boolean;
|
|
134
|
+
/**
|
|
135
|
+
* Exposed for unit testing — lets the contract test enumerate every rule's
|
|
136
|
+
* `prefix` value and assert mutual non-prefixing.
|
|
137
|
+
*/
|
|
138
|
+
declare const __CLASSIFIER_RULES_FOR_TEST: readonly {
|
|
139
|
+
readonly prefix: string;
|
|
140
|
+
}[];
|
|
141
|
+
/**
|
|
142
|
+
* Result of {@link normaliseSchema}. Carries the canonical Draft 2020-12
|
|
143
|
+
* JSON Schema the walker consumes, the optional original Zod schema
|
|
144
|
+
* (used for validation), and the resolved root document so cross-document
|
|
145
|
+
* `$ref`s can be dereferenced downstream.
|
|
146
|
+
*
|
|
147
|
+
* @group Adapter
|
|
148
|
+
*/
|
|
149
|
+
interface NormalisedSchema {
|
|
150
|
+
/** JSON Schema object — the authoritative schema for rendering. */
|
|
151
|
+
jsonSchema: JsonObject;
|
|
152
|
+
/** Original Zod schema, if input was Zod. Used for validation. */
|
|
153
|
+
zodSchema?: unknown;
|
|
154
|
+
/** Root-level metadata. */
|
|
155
|
+
rootMeta: SchemaMeta | undefined;
|
|
156
|
+
/** The root document for $ref resolution. */
|
|
157
|
+
rootDocument: JsonObject;
|
|
158
|
+
}
|
|
159
|
+
/**
|
|
160
|
+
* Options accepted by {@link normaliseSchema}.
|
|
161
|
+
*
|
|
162
|
+
* @group Adapter
|
|
163
|
+
*/
|
|
164
|
+
interface NormaliseOptions {
|
|
165
|
+
/** Diagnostics channel for surfacing silent fallbacks. */
|
|
166
|
+
diagnostics?: DiagnosticsOptions;
|
|
167
|
+
/**
|
|
168
|
+
* Side of every transform / pipe / codec to render. Defaults to
|
|
169
|
+
* `"output"`, matching `z.toJSONSchema`'s default and the
|
|
170
|
+
* historic behaviour of the adapter. Passing `"input"` flips the
|
|
171
|
+
* conversion so consumers rendering the input shape of a
|
|
172
|
+
* `z.codec(...)` chain receive that side instead of the output
|
|
173
|
+
* side. Only the Zod 4 branch consults this option — JSON Schema
|
|
174
|
+
* and OpenAPI inputs are already a single canonical shape.
|
|
175
|
+
*/
|
|
176
|
+
io?: SchemaIoSide;
|
|
177
|
+
}
|
|
178
|
+
/**
|
|
179
|
+
* Normalise any supported schema input — Zod 4 schema, plain JSON
|
|
180
|
+
* Schema (any draft), Swagger 2.0, OpenAPI 3.0 or 3.1 document — into
|
|
181
|
+
* a canonical Draft 2020-12 {@link NormalisedSchema} the walker can
|
|
182
|
+
* consume.
|
|
183
|
+
*
|
|
184
|
+
* Dispatches on {@link detectSchemaKind}, applies the appropriate
|
|
185
|
+
* version normaliser, and returns the JSON Schema alongside the
|
|
186
|
+
* original Zod schema (for validation) and the resolved root document
|
|
187
|
+
* (for cross-document `$ref` resolution). Throws
|
|
188
|
+
* `SchemaNormalisationError` for unsupported inputs (Zod 3, valibot,
|
|
189
|
+
* arktype, codec or other unrepresentable Zod types).
|
|
190
|
+
*
|
|
191
|
+
* @group Adapter
|
|
192
|
+
*/
|
|
193
|
+
declare function normaliseSchema(input: unknown, ref?: string, options?: NormaliseOptions): NormalisedSchema;
|
|
194
|
+
/**
|
|
195
|
+
* Surface root-level metadata from the JSON Schema into the `rootMeta`
|
|
196
|
+
* shape consumed by the walker. Pulls `readOnly`, `writeOnly`,
|
|
197
|
+
* `description`, `title`, `deprecated`, `examples`, and `default`
|
|
198
|
+
* directly from the schema root.
|
|
199
|
+
*
|
|
200
|
+
* `examples` is forwarded only when present as an array (per JSON Schema
|
|
201
|
+
* Draft 2020-12 — Draft 04's `example` singular is normalised upstream).
|
|
202
|
+
* `default` is forwarded for any value the schema declares (any JSON
|
|
203
|
+
* value, including `null` and `false`); the presence check uses `in`
|
|
204
|
+
* so a literal `false` or `null` default is preserved.
|
|
205
|
+
*
|
|
206
|
+
* `examples` and `default` ride on the `[key: string]: unknown` index
|
|
207
|
+
* signature of {@link SchemaMeta}. They are not declared as named fields
|
|
208
|
+
* on `SchemaMeta` because that type lives in `types.ts` and is shared
|
|
209
|
+
* with the walker; the index signature is the agreed extension point.
|
|
210
|
+
*/
|
|
211
|
+
declare function extractRootMetaFromJson(jsonSchema: JsonObject): SchemaMeta | undefined;
|
|
212
|
+
//#endregion
|
|
213
|
+
export { __CLASSIFIER_RULES_FOR_TEST as a, isCodecSchema as c, SchemaKind as i, normaliseSchema as l, NormalisedSchema as n, detectSchemaKind as o, SchemaIoSide as r, extractRootMetaFromJson as s, NormaliseOptions as t };
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
//#region src/lit/constructorTypes.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* Tiny structural-type helpers for the Lit adapter.
|
|
4
|
+
*
|
|
5
|
+
* Lives alongside `lit/registry.ts` rather than under `core/` because
|
|
6
|
+
* the Custom-Element constructor signature is only needed by the Lit
|
|
7
|
+
* surface — other adapter directories model their renderers as plain
|
|
8
|
+
* functions and have no use for it.
|
|
9
|
+
*
|
|
10
|
+
* @packageDocumentation
|
|
11
|
+
*/
|
|
12
|
+
/**
|
|
13
|
+
* Generic newable constructor type compatible with the DOM's
|
|
14
|
+
* `CustomElementConstructor`. Used by {@link BUILT_IN_ELEMENTS} (the
|
|
15
|
+
* canonical-tag → element-constructor map) so the map's value type
|
|
16
|
+
* carries enough structure for `customElements.define` to accept it
|
|
17
|
+
* without an `as` cast.
|
|
18
|
+
*
|
|
19
|
+
* Matches the DOM type-library signature
|
|
20
|
+
* `interface CustomElementConstructor { new (...params: any[]): HTMLElement; }`
|
|
21
|
+
* but parameterised over a `T extends HTMLElement` so it can also be
|
|
22
|
+
* used in narrower contexts.
|
|
23
|
+
*
|
|
24
|
+
* `unknown[]` is used in the parameter list — the DOM lib uses
|
|
25
|
+
* `any[]`, but `unknown[]` is the strict-mode equivalent that
|
|
26
|
+
* accepts any positional argument shape without using `any`.
|
|
27
|
+
*/
|
|
28
|
+
type Constructor<T extends HTMLElement> = new (...params: unknown[]) => T;
|
|
29
|
+
//#endregion
|
|
30
|
+
export { Constructor as t };
|
package/dist/core/adapter.d.mts
CHANGED
|
@@ -1,213 +1,3 @@
|
|
|
1
|
-
import { m as JsonObject, w as SchemaMeta } from "../types-
|
|
2
|
-
import { i as
|
|
3
|
-
|
|
4
|
-
//#region src/core/adapter.d.ts
|
|
5
|
-
/**
|
|
6
|
-
* Classification produced by {@link detectSchemaKind} when inspecting a
|
|
7
|
-
* runtime schema input.
|
|
8
|
-
*
|
|
9
|
-
* @group Adapter
|
|
10
|
-
*/
|
|
11
|
-
type SchemaKind = "zod4" | "zod3" | "jsonSchema" | "openapi" | "unsupported-schema-lib";
|
|
12
|
-
/**
|
|
13
|
-
* Classify a runtime schema input by structural markers — Zod 4, Zod 3,
|
|
14
|
-
* OpenAPI document, plain JSON Schema, or an unsupported third-party
|
|
15
|
-
* schema library.
|
|
16
|
-
*
|
|
17
|
-
* - `zod4` — has a `_zod` marker (further validation that `_zod.def` is a
|
|
18
|
-
* non-null object happens inside `normaliseZod4`).
|
|
19
|
-
* - `zod3` — has `_def` and no `_zod`. The `typeName` field is no longer
|
|
20
|
-
* required: any `_def` without `_zod` is treated as a probable Zod 3
|
|
21
|
-
* schema. Third-party libraries that expose `_def` without `_zod` are
|
|
22
|
-
* nearly always Zod 3 forks; surfacing the migration message is the
|
|
23
|
-
* correct response.
|
|
24
|
-
* - `openapi` — has `openapi` or `swagger` at the root.
|
|
25
|
-
* - `unsupported-schema-lib` — has `parse` and `safeParse` callables but
|
|
26
|
-
* no `_zod` and no `_def` marker. This catches Standard Schema
|
|
27
|
-
* implementations (valibot, arktype, etc.) that would otherwise flow
|
|
28
|
-
* through as "malformed JSON Schema".
|
|
29
|
-
* - `jsonSchema` — fallback for anything that does not match the above.
|
|
30
|
-
*
|
|
31
|
-
* @group Adapter
|
|
32
|
-
*/
|
|
33
|
-
declare function detectSchemaKind(input: unknown): SchemaKind;
|
|
34
|
-
/**
|
|
35
|
-
* Wraps z.toJSONSchema() for a runtime-validated Zod schema.
|
|
36
|
-
*
|
|
37
|
-
* The _zod guard in normaliseZod4 has confirmed this is a valid Zod schema,
|
|
38
|
-
* but TypeScript cannot represent "has _zod.def" as the $ZodType parameter
|
|
39
|
-
* that z.toJSONSchema expects. This is the library boundary equivalent of
|
|
40
|
-
* object → Record<string, unknown> — the type mismatch is genuinely unavoidable.
|
|
41
|
-
*
|
|
42
|
-
* # Options
|
|
43
|
-
*
|
|
44
|
-
* `z.toJSONSchema` is invoked with an explicit options object rather than
|
|
45
|
-
* Zod's defaults so the conversion contract is pinned and stable:
|
|
46
|
-
*
|
|
47
|
-
* - `target: "draft-2020-12"` — matches the walker's draft target.
|
|
48
|
-
* - `unrepresentable: "throw"` — keeps the unrepresentable-type rules in
|
|
49
|
-
* the classifier table firing instead of silently emitting `{}`.
|
|
50
|
-
* - `cycles: "ref"` — converts cyclic graphs into $ref pairs rather than
|
|
51
|
-
* throwing. Cycles in user schemas surface through the walker's $ref
|
|
52
|
-
* resolution rather than the adapter.
|
|
53
|
-
* - `io` — selects which side of every transform / pipe / codec is
|
|
54
|
-
* converted. Defaults to `"output"` (the OUTPUT side); pass `"input"`
|
|
55
|
-
* to render the INPUT side instead. The input side is invisible to
|
|
56
|
-
* the converted schema when `io: "output"` is in force, even though
|
|
57
|
-
* `safeParse` on the same Zod schema consumes the input shape. For
|
|
58
|
-
* transforms this divergence is fatal and the call throws via
|
|
59
|
-
* `Transforms cannot be represented`; for `z.codec(...)` the call
|
|
60
|
-
* succeeds but only the selected side is rendered. Consumers receive
|
|
61
|
-
* a `zod-codec-output-only` diagnostic in the codec case so the
|
|
62
|
-
* asymmetry is visible — see `screenPreConversion`.
|
|
63
|
-
*
|
|
64
|
-
* # Error classification
|
|
65
|
-
*
|
|
66
|
-
* Any exception thrown by z.toJSONSchema is classified into a
|
|
67
|
-
* SchemaNormalisationError so the caller does not have to re-parse error
|
|
68
|
-
* message strings. The classification covers:
|
|
69
|
-
*
|
|
70
|
-
* - Nested Zod 3 schemas inside a Zod 4 tree → zod3-unsupported.
|
|
71
|
-
* Detected structurally (presence of `_def.typeName` markers anywhere
|
|
72
|
-
* in the schema tree) so the check works across V8, JavaScriptCore,
|
|
73
|
-
* and SpiderMonkey, none of which agree on the wording of
|
|
74
|
-
* "Cannot read properties of undefined".
|
|
75
|
-
* - Transforms → zod-transform-unsupported. This also catches `z.codec(…)`
|
|
76
|
-
* because Zod implements codecs as a pipe + transform internally, so
|
|
77
|
-
* they trip the same processor when round-tripping is forced. (Plain
|
|
78
|
-
* `z.toJSONSchema(codec)` itself does NOT throw because Zod picks one
|
|
79
|
-
* side of the codec; the static rejection in `typeInference.ts` is the
|
|
80
|
-
* compile-time guard.)
|
|
81
|
-
* - Dynamic catch values whose handler throws → zod-type-unrepresentable
|
|
82
|
-
* with zodType "dynamic-catch".
|
|
83
|
-
* - Unrepresentable types — bigint, date, map, set, symbol, function, custom,
|
|
84
|
-
* undefined, void, NaN, and the literal-only forms `z.literal(undefined)`
|
|
85
|
-
* ("undefined-literal") and `z.literal(<bigint>)` ("bigint-literal") →
|
|
86
|
-
* zod-type-unrepresentable.
|
|
87
|
-
* - The catch-all "Non-representable type encountered: <type>" fallback Zod
|
|
88
|
-
* emits for any new schema kind without a registered processor →
|
|
89
|
-
* zod-type-unrepresentable with zodType set to the offending def.type.
|
|
90
|
-
* - Cycle detected (`cycles: "throw"`) → zod-cycle-detected.
|
|
91
|
-
* - Duplicate schema id → zod-duplicate-id.
|
|
92
|
-
* - "Unprocessed schema. This is a bug in Zod." → zod-conversion-bug.
|
|
93
|
-
* - "Error converting schema to JSON." → zod-conversion-failed (explicit
|
|
94
|
-
* classification rather than the generic fallback so the contract test
|
|
95
|
-
* protects the prefix from drift).
|
|
96
|
-
* - Anything else → zod-conversion-failed.
|
|
97
|
-
*
|
|
98
|
-
* The original error is preserved on each classified error via the `cause`
|
|
99
|
-
* field so consumers can still inspect the Zod stack trace.
|
|
100
|
-
*/
|
|
101
|
-
/**
|
|
102
|
-
* Direction of the Zod transform / pipe / codec that
|
|
103
|
-
* {@link normaliseSchema} should surface to the renderer.
|
|
104
|
-
*
|
|
105
|
-
* - `"output"` (default) — the server-facing side of every transform,
|
|
106
|
-
* matching `z.toJSONSchema`'s default and the historic adapter
|
|
107
|
-
* behaviour.
|
|
108
|
-
* - `"input"` — the client-facing side; flips a `z.codec(...)` chain
|
|
109
|
-
* so consumers can render its input shape.
|
|
110
|
-
*
|
|
111
|
-
* @group Adapter
|
|
112
|
-
*/
|
|
113
|
-
type SchemaIoSide = "input" | "output";
|
|
114
|
-
/**
|
|
115
|
-
* True when `value` is a Zod schema implemented as a codec
|
|
116
|
-
* (`z.codec(...)`). Detection looks for the `$ZodCodec` marker on the
|
|
117
|
-
* schema's `_zod.traits` Set — the same structural check used by Zod
|
|
118
|
-
* itself in `to-json-schema.ts`'s `isTransforming` helper.
|
|
119
|
-
*
|
|
120
|
-
* Promoted from a duplicated local helper in `react/SchemaComponent.tsx`
|
|
121
|
-
* so the validation boundary inside `runValidation` can branch on
|
|
122
|
-
* codec-vs-not-codec without re-implementing the trait check. The
|
|
123
|
-
* shared helper anchors a single source of truth for codec detection:
|
|
124
|
-
* any future change to Zod's trait naming flows through here, not
|
|
125
|
-
* through two parallel copies.
|
|
126
|
-
*
|
|
127
|
-
* Returns `false` for non-objects, plain JSON Schema inputs, OpenAPI
|
|
128
|
-
* documents, or Zod schemas of any other kind. This is structural
|
|
129
|
-
* rather than nominal — a Zod 4 codec produced by any path that ends
|
|
130
|
-
* up tagging `_zod.traits` with `$ZodCodec` is recognised, including
|
|
131
|
-
* schemas wrapped by user-defined helpers.
|
|
132
|
-
*/
|
|
133
|
-
declare function isCodecSchema(value: unknown): boolean;
|
|
134
|
-
/**
|
|
135
|
-
* Exposed for unit testing — lets the contract test enumerate every rule's
|
|
136
|
-
* `prefix` value and assert mutual non-prefixing.
|
|
137
|
-
*/
|
|
138
|
-
declare const __CLASSIFIER_RULES_FOR_TEST: readonly {
|
|
139
|
-
readonly prefix: string;
|
|
140
|
-
}[];
|
|
141
|
-
/**
|
|
142
|
-
* Result of {@link normaliseSchema}. Carries the canonical Draft 2020-12
|
|
143
|
-
* JSON Schema the walker consumes, the optional original Zod schema
|
|
144
|
-
* (used for validation), and the resolved root document so cross-document
|
|
145
|
-
* `$ref`s can be dereferenced downstream.
|
|
146
|
-
*
|
|
147
|
-
* @group Adapter
|
|
148
|
-
*/
|
|
149
|
-
interface NormalisedSchema {
|
|
150
|
-
/** JSON Schema object — the authoritative schema for rendering. */
|
|
151
|
-
jsonSchema: JsonObject;
|
|
152
|
-
/** Original Zod schema, if input was Zod. Used for validation. */
|
|
153
|
-
zodSchema?: unknown;
|
|
154
|
-
/** Root-level metadata. */
|
|
155
|
-
rootMeta: SchemaMeta | undefined;
|
|
156
|
-
/** The root document for $ref resolution. */
|
|
157
|
-
rootDocument: JsonObject;
|
|
158
|
-
}
|
|
159
|
-
/**
|
|
160
|
-
* Options accepted by {@link normaliseSchema}.
|
|
161
|
-
*
|
|
162
|
-
* @group Adapter
|
|
163
|
-
*/
|
|
164
|
-
interface NormaliseOptions {
|
|
165
|
-
/** Diagnostics channel for surfacing silent fallbacks. */
|
|
166
|
-
diagnostics?: DiagnosticsOptions;
|
|
167
|
-
/**
|
|
168
|
-
* Side of every transform / pipe / codec to render. Defaults to
|
|
169
|
-
* `"output"`, matching `z.toJSONSchema`'s default and the
|
|
170
|
-
* historic behaviour of the adapter. Passing `"input"` flips the
|
|
171
|
-
* conversion so consumers rendering the input shape of a
|
|
172
|
-
* `z.codec(...)` chain receive that side instead of the output
|
|
173
|
-
* side. Only the Zod 4 branch consults this option — JSON Schema
|
|
174
|
-
* and OpenAPI inputs are already a single canonical shape.
|
|
175
|
-
*/
|
|
176
|
-
io?: SchemaIoSide;
|
|
177
|
-
}
|
|
178
|
-
/**
|
|
179
|
-
* Normalise any supported schema input — Zod 4 schema, plain JSON
|
|
180
|
-
* Schema (any draft), Swagger 2.0, OpenAPI 3.0 or 3.1 document — into
|
|
181
|
-
* a canonical Draft 2020-12 {@link NormalisedSchema} the walker can
|
|
182
|
-
* consume.
|
|
183
|
-
*
|
|
184
|
-
* Dispatches on {@link detectSchemaKind}, applies the appropriate
|
|
185
|
-
* version normaliser, and returns the JSON Schema alongside the
|
|
186
|
-
* original Zod schema (for validation) and the resolved root document
|
|
187
|
-
* (for cross-document `$ref` resolution). Throws
|
|
188
|
-
* `SchemaNormalisationError` for unsupported inputs (Zod 3, valibot,
|
|
189
|
-
* arktype, codec or other unrepresentable Zod types).
|
|
190
|
-
*
|
|
191
|
-
* @group Adapter
|
|
192
|
-
*/
|
|
193
|
-
declare function normaliseSchema(input: unknown, ref?: string, options?: NormaliseOptions): NormalisedSchema;
|
|
194
|
-
/**
|
|
195
|
-
* Surface root-level metadata from the JSON Schema into the `rootMeta`
|
|
196
|
-
* shape consumed by the walker. Pulls `readOnly`, `writeOnly`,
|
|
197
|
-
* `description`, `title`, `deprecated`, `examples`, and `default`
|
|
198
|
-
* directly from the schema root.
|
|
199
|
-
*
|
|
200
|
-
* `examples` is forwarded only when present as an array (per JSON Schema
|
|
201
|
-
* Draft 2020-12 — Draft 04's `example` singular is normalised upstream).
|
|
202
|
-
* `default` is forwarded for any value the schema declares (any JSON
|
|
203
|
-
* value, including `null` and `false`); the presence check uses `in`
|
|
204
|
-
* so a literal `false` or `null` default is preserved.
|
|
205
|
-
*
|
|
206
|
-
* `examples` and `default` ride on the `[key: string]: unknown` index
|
|
207
|
-
* signature of {@link SchemaMeta}. They are not declared as named fields
|
|
208
|
-
* on `SchemaMeta` because that type lives in `types.ts` and is shared
|
|
209
|
-
* with the walker; the index signature is the agreed extension point.
|
|
210
|
-
*/
|
|
211
|
-
declare function extractRootMetaFromJson(jsonSchema: JsonObject): SchemaMeta | undefined;
|
|
212
|
-
//#endregion
|
|
213
|
-
export { type JsonObject, NormaliseOptions, NormalisedSchema, SchemaIoSide, SchemaKind, type SchemaMeta, __CLASSIFIER_RULES_FOR_TEST, detectSchemaKind, extractRootMetaFromJson, isCodecSchema, normaliseSchema };
|
|
1
|
+
import { m as JsonObject, w as SchemaMeta } from "../types-BBQaEPfE.mjs";
|
|
2
|
+
import { a as __CLASSIFIER_RULES_FOR_TEST, c as isCodecSchema, i as SchemaKind, l as normaliseSchema, n as NormalisedSchema, o as detectSchemaKind, r as SchemaIoSide, s as extractRootMetaFromJson, t as NormaliseOptions } from "../adapter-ktQaheWB.mjs";
|
|
3
|
+
export { JsonObject, NormaliseOptions, NormalisedSchema, SchemaIoSide, SchemaKind, SchemaMeta, __CLASSIFIER_RULES_FOR_TEST, detectSchemaKind, extractRootMetaFromJson, isCodecSchema, normaliseSchema };
|
package/dist/core/adapter.mjs
CHANGED
|
@@ -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-
|
|
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
|
-
*
|
|
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
|
-
*
|
|
377
|
-
*
|
|
378
|
-
* even when both share a leading word. A consistency check in the
|
|
379
|
-
* test suite asserts no two `prefix` values are prefixes of each
|
|
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
|
-
*
|
|
388
|
-
*
|
|
389
|
-
*
|
|
390
|
-
*
|
|
391
|
-
*
|
|
392
|
-
*
|
|
393
|
-
*
|
|
394
|
-
*
|
|
395
|
-
*
|
|
396
|
-
* - `
|
|
397
|
-
*
|
|
398
|
-
*
|
|
399
|
-
*
|
|
400
|
-
*
|
|
401
|
-
*
|
|
402
|
-
*
|
|
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
|
{
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { E as StringConstraints, f as FileConstraints, t as ArrayConstraints, x as ObjectConstraints, y as NumberConstraints } from "../types-
|
|
2
|
-
import { i as DiagnosticsOptions } from "../diagnostics-
|
|
1
|
+
import { E as StringConstraints, f as FileConstraints, t as ArrayConstraints, x as ObjectConstraints, y as NumberConstraints } from "../types-BBQaEPfE.mjs";
|
|
2
|
+
import { i as DiagnosticsOptions } from "../diagnostics-mftUZI7c.mjs";
|
|
3
3
|
|
|
4
4
|
//#region src/core/constraints.d.ts
|
|
5
5
|
/**
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { d as WidgetMap, i as ComponentResolver } from "../renderer-ab9E52Bp.mjs";
|
|
2
|
+
|
|
3
|
+
//#region src/core/contexts.d.ts
|
|
4
|
+
/**
|
|
5
|
+
* Abstract provide / consume port that framework adapters implement
|
|
6
|
+
* against their native context primitive. The {@link provide} step
|
|
7
|
+
* wraps its `children` in the framework's provider machinery so any
|
|
8
|
+
* descendant calling {@link consume} receives the supplied value;
|
|
9
|
+
* {@link consume} is called from inside a child renderer to read the
|
|
10
|
+
* current value.
|
|
11
|
+
*
|
|
12
|
+
* The return type of `provide` and the argument type of `consume` are
|
|
13
|
+
* deliberately `unknown` so the port works for both React-style
|
|
14
|
+
* "wrap children in a provider component" implementations and
|
|
15
|
+
* Svelte-style "set on the current component instance" implementations
|
|
16
|
+
* without forcing one shape on the other.
|
|
17
|
+
*
|
|
18
|
+
* @typeParam T - The value carried by the context.
|
|
19
|
+
*/
|
|
20
|
+
interface ContextPort<T> {
|
|
21
|
+
/**
|
|
22
|
+
* Provide `value` to every descendant of `children`. The exact
|
|
23
|
+
* shape of `children` is framework-specific — `ReactNode` for
|
|
24
|
+
* React, the slot's render function for Svelte, the `setup`
|
|
25
|
+
* return value for Vue. The implementation simply makes the
|
|
26
|
+
* supplied value available to subsequent {@link consume} calls
|
|
27
|
+
* within that scope.
|
|
28
|
+
*/
|
|
29
|
+
provide(value: T, children: unknown): unknown;
|
|
30
|
+
/**
|
|
31
|
+
* Read the currently provided value. The exact host primitive is
|
|
32
|
+
* framework-specific — `useContext(ctx)` in React, `inject(key)`
|
|
33
|
+
* in Vue, `getContext(key)` in Svelte. When no provider is
|
|
34
|
+
* mounted in scope, adapter implementations may return their
|
|
35
|
+
* canonical "default" value or `undefined` — the choice is
|
|
36
|
+
* adapter-defined.
|
|
37
|
+
*/
|
|
38
|
+
consume(): T;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Shape carried by the resolver context. Adapters expose this through
|
|
42
|
+
* a `ContextPort<ResolverContextShape>` so the dispatcher can read
|
|
43
|
+
* the active theme adapter without taking a direct dependency on the
|
|
44
|
+
* host framework's context system.
|
|
45
|
+
*
|
|
46
|
+
* Mirrors the value carried by the React adapter's
|
|
47
|
+
* `UserResolverContext` (defined in `react/SchemaComponent.tsx`) —
|
|
48
|
+
* an optional {@link ComponentResolver}. The `undefined` branch
|
|
49
|
+
* signals "no theme provider mounted; fall through to the headless
|
|
50
|
+
* resolver".
|
|
51
|
+
*
|
|
52
|
+
* @group Framework Adapters
|
|
53
|
+
*/
|
|
54
|
+
type ResolverContextShape = ComponentResolver | undefined;
|
|
55
|
+
/**
|
|
56
|
+
* Shape carried by the widgets context. Adapters expose this through
|
|
57
|
+
* a `ContextPort<WidgetsContextShape>` so the dispatcher can read
|
|
58
|
+
* the active widget map without binding to the host framework's
|
|
59
|
+
* context system.
|
|
60
|
+
*
|
|
61
|
+
* Mirrors the value carried by the React adapter's `WidgetsContext`
|
|
62
|
+
* (defined in `react/SchemaComponent.tsx`) — an optional
|
|
63
|
+
* {@link WidgetMap}. The `undefined` branch signals "no scoped widgets
|
|
64
|
+
* for this subtree; fall through to per-instance widgets, then the
|
|
65
|
+
* global registry, then the resolver".
|
|
66
|
+
*
|
|
67
|
+
* @group Framework Adapters
|
|
68
|
+
*/
|
|
69
|
+
type WidgetsContextShape = WidgetMap | undefined;
|
|
70
|
+
//#endregion
|
|
71
|
+
export { ContextPort, ResolverContextShape, WidgetsContextShape };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as appendPointer, i as DiagnosticsOptions, n as DiagnosticCode, o as emitDiagnostic, r as DiagnosticSink, t as Diagnostic } from "../diagnostics-
|
|
1
|
+
import { a as appendPointer, i as DiagnosticsOptions, n as DiagnosticCode, o as emitDiagnostic, r as DiagnosticSink, t as Diagnostic } from "../diagnostics-mftUZI7c.mjs";
|
|
2
2
|
export { Diagnostic, DiagnosticCode, DiagnosticSink, DiagnosticsOptions, appendPointer, emitDiagnostic };
|
package/dist/core/errors.d.mts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { i as SchemaRenderError, n as SchemaFieldError, r as SchemaNormalisationError, t as SchemaError } from "../errors-
|
|
1
|
+
import { i as SchemaRenderError, n as SchemaFieldError, r as SchemaNormalisationError, t as SchemaError } from "../errors-DbaI04x2.mjs";
|
|
2
2
|
export { SchemaError, SchemaFieldError, SchemaNormalisationError, SchemaRenderError };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { j as WalkedField } from "../types-
|
|
1
|
+
import { j as WalkedField } from "../types-BBQaEPfE.mjs";
|
|
2
2
|
|
|
3
|
-
//#region src/
|
|
3
|
+
//#region src/core/fieldPath.d.ts
|
|
4
4
|
/**
|
|
5
5
|
* Resolve a dot-separated path through a WalkedField tree.
|
|
6
6
|
* Supports array index notation: `field[0]`.
|