schema-components 1.12.11 → 1.14.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.
Files changed (83) hide show
  1. package/README.md +35 -0
  2. package/dist/core/adapter.d.mts +8 -3
  3. package/dist/core/adapter.mjs +58 -14
  4. package/dist/core/constraints.d.mts +17 -0
  5. package/dist/core/constraints.mjs +150 -0
  6. package/dist/core/diagnostics.d.mts +2 -0
  7. package/dist/core/diagnostics.mjs +33 -0
  8. package/dist/core/errors.d.mts +1 -1
  9. package/dist/core/formats.d.mts +33 -0
  10. package/dist/core/formats.mjs +67 -0
  11. package/dist/core/merge.d.mts +48 -0
  12. package/dist/core/merge.mjs +125 -0
  13. package/dist/core/normalise.d.mts +41 -0
  14. package/dist/core/normalise.mjs +2 -0
  15. package/dist/core/openapi30.d.mts +41 -0
  16. package/dist/core/openapi30.mjs +2 -0
  17. package/dist/core/ref.d.mts +2 -0
  18. package/dist/core/ref.mjs +165 -0
  19. package/dist/core/renderer.d.mts +2 -2
  20. package/dist/core/renderer.mjs +8 -0
  21. package/dist/core/swagger2.d.mts +11 -0
  22. package/dist/core/swagger2.mjs +2 -0
  23. package/dist/core/typeInference.d.mts +2 -0
  24. package/dist/core/typeInference.mjs +1 -0
  25. package/dist/core/types.d.mts +2 -3
  26. package/dist/core/types.mjs +58 -2
  27. package/dist/core/version.d.mts +2 -0
  28. package/dist/core/version.mjs +151 -0
  29. package/dist/core/walkBuilders.d.mts +66 -0
  30. package/dist/core/walkBuilders.mjs +152 -0
  31. package/dist/core/walker.d.mts +3 -10
  32. package/dist/core/walker.mjs +245 -233
  33. package/dist/diagnostics-DzbZmcLI.d.mts +64 -0
  34. package/dist/html/a11y.d.mts +5 -4
  35. package/dist/html/renderToHtml.d.mts +3 -3
  36. package/dist/html/renderToHtml.mjs +23 -379
  37. package/dist/html/renderToHtmlStream.d.mts +29 -47
  38. package/dist/html/renderToHtmlStream.mjs +33 -305
  39. package/dist/html/renderers.d.mts +14 -0
  40. package/dist/html/renderers.mjs +406 -0
  41. package/dist/html/streamRenderers.d.mts +13 -0
  42. package/dist/html/streamRenderers.mjs +243 -0
  43. package/dist/normalise-tL9FckAk.mjs +748 -0
  44. package/dist/openapi/ApiCallbacks.d.mts +16 -0
  45. package/dist/openapi/ApiCallbacks.mjs +34 -0
  46. package/dist/openapi/ApiLinks.d.mts +16 -0
  47. package/dist/openapi/ApiLinks.mjs +42 -0
  48. package/dist/openapi/ApiResponseHeaders.d.mts +16 -0
  49. package/dist/openapi/ApiResponseHeaders.mjs +35 -0
  50. package/dist/openapi/ApiSecurity.d.mts +19 -0
  51. package/dist/openapi/ApiSecurity.mjs +33 -0
  52. package/dist/openapi/bundle.d.mts +47 -0
  53. package/dist/openapi/bundle.mjs +95 -0
  54. package/dist/openapi/components.d.mts +7 -1
  55. package/dist/openapi/components.mjs +30 -6
  56. package/dist/openapi/parser.d.mts +59 -2
  57. package/dist/openapi/parser.mjs +189 -8
  58. package/dist/react/SchemaComponent.d.mts +13 -4
  59. package/dist/react/SchemaComponent.mjs +51 -91
  60. package/dist/react/SchemaView.d.mts +10 -2
  61. package/dist/react/SchemaView.mjs +33 -15
  62. package/dist/react/fieldPath.d.mts +20 -0
  63. package/dist/react/fieldPath.mjs +81 -0
  64. package/dist/react/headless.d.mts +2 -4
  65. package/dist/react/headless.mjs +3 -492
  66. package/dist/react/headlessRenderers.d.mts +23 -0
  67. package/dist/react/headlessRenderers.mjs +507 -0
  68. package/dist/ref-DvWoULcy.d.mts +44 -0
  69. package/dist/renderer-BdSqllx5.d.mts +160 -0
  70. package/dist/themes/mantine.d.mts +1 -1
  71. package/dist/themes/mantine.mjs +2 -1
  72. package/dist/themes/mui.d.mts +1 -1
  73. package/dist/themes/mui.mjs +3 -2
  74. package/dist/themes/radix.d.mts +1 -1
  75. package/dist/themes/radix.mjs +2 -1
  76. package/dist/themes/shadcn.d.mts +1 -1
  77. package/dist/themes/shadcn.mjs +10 -6
  78. package/dist/typeInference-k7FXfTVO.d.mts +335 -0
  79. package/dist/types-D_5ST7SS.d.mts +269 -0
  80. package/dist/version-B5NV-35j.d.mts +69 -0
  81. package/package.json +1 -1
  82. package/dist/types-BJzEgJdX.d.mts +0 -335
  83. /package/dist/{errors-DIKI2C78.d.mts → errors-C5zRC2PU.d.mts} +0 -0
@@ -0,0 +1,125 @@
1
+ import { isObject } from "./guards.mjs";
2
+ //#region src/core/merge.ts
3
+ /**
4
+ * Schema merging, nullable detection, and discriminated union detection.
5
+ *
6
+ * Used by the walker to handle `allOf`, `anyOf [T, null]`, and
7
+ * `oneOf` with discriminator properties.
8
+ */
9
+ function getString(obj, key) {
10
+ const value = obj[key];
11
+ return typeof value === "string" ? value : void 0;
12
+ }
13
+ function getArray(obj, key) {
14
+ const value = obj[key];
15
+ return Array.isArray(value) ? value : void 0;
16
+ }
17
+ function getObject(obj, key) {
18
+ const value = obj[key];
19
+ return isObject(value) ? value : void 0;
20
+ }
21
+ /**
22
+ * Annotation keywords that can appear as siblings of `$ref` per
23
+ * Draft 2020-12 / OpenAPI 3.1. Structural keywords (type, properties,
24
+ * etc.) are NOT annotation siblings and should not be merged.
25
+ */
26
+ const ANNOTATION_SIBLINGS = new Set([
27
+ "title",
28
+ "description",
29
+ "default",
30
+ "examples",
31
+ "deprecated",
32
+ "readOnly",
33
+ "writeOnly",
34
+ "$comment"
35
+ ]);
36
+ /**
37
+ * Merge annotation siblings from the referencing node onto the
38
+ * resolved target's annotations. The referencer wins for annotations.
39
+ *
40
+ * Structural keywords on the referencer are NOT merged — per spec,
41
+ * `$ref` with structural siblings was invalid pre-2019-09.
42
+ *
43
+ * Returns a new meta object with the merged annotations.
44
+ */
45
+ function mergeRefSiblings(referencer, resolvedMeta) {
46
+ const merged = { ...resolvedMeta };
47
+ for (const key of ANNOTATION_SIBLINGS) if (key in referencer) merged[key] = referencer[key];
48
+ return merged;
49
+ }
50
+ /**
51
+ * Merge multiple JSON Schema objects from allOf into one.
52
+ * Merges: properties, required, meta fields, and constraints.
53
+ */
54
+ function mergeAllOf(schemas) {
55
+ const merged = {};
56
+ const properties = {};
57
+ const required = [];
58
+ for (const entry of schemas) {
59
+ if (!isObject(entry)) continue;
60
+ const props = getObject(entry, "properties");
61
+ if (props !== void 0) for (const [key, value] of Object.entries(props)) properties[key] = value;
62
+ const req = getArray(entry, "required");
63
+ if (req !== void 0) {
64
+ for (const r of req) if (typeof r === "string" && !required.includes(r)) required.push(r);
65
+ }
66
+ for (const [key, value] of Object.entries(entry)) {
67
+ if (key === "properties" || key === "required" || key === "allOf" || key === "type") continue;
68
+ if (!(key in merged)) merged[key] = value;
69
+ }
70
+ if (!("type" in merged)) {
71
+ const type = getString(entry, "type");
72
+ if (type !== void 0) merged.type = type;
73
+ }
74
+ }
75
+ if (Object.keys(properties).length > 0) merged.properties = properties;
76
+ if (required.length > 0) merged.required = required;
77
+ return merged;
78
+ }
79
+ /**
80
+ * Detect `anyOf: [T, { type: "null" }]` → nullable T.
81
+ * Returns the non-null schema and a nullable flag.
82
+ */
83
+ function normaliseAnyOf(options) {
84
+ if (options.length !== 2) return void 0;
85
+ let inner;
86
+ let hasNull = false;
87
+ for (const opt of options) {
88
+ if (!isObject(opt)) return void 0;
89
+ if (opt.type === "null") hasNull = true;
90
+ else inner = opt;
91
+ }
92
+ if (!hasNull || inner === void 0) return void 0;
93
+ return {
94
+ inner,
95
+ isNullable: true
96
+ };
97
+ }
98
+ /**
99
+ * Detect oneOf where every option is an object with a property
100
+ * that has a `const` value → discriminated union.
101
+ */
102
+ function detectDiscriminated(options) {
103
+ if (options.length === 0) return void 0;
104
+ let discriminator;
105
+ for (const opt of options) {
106
+ if (!isObject(opt)) return void 0;
107
+ const props = getObject(opt, "properties");
108
+ if (props === void 0) return void 0;
109
+ let foundKey;
110
+ for (const [key, value] of Object.entries(props)) if (isObject(value) && "const" in value) {
111
+ foundKey = key;
112
+ break;
113
+ }
114
+ if (foundKey === void 0) return void 0;
115
+ if (discriminator === void 0) discriminator = foundKey;
116
+ else if (discriminator !== foundKey) return;
117
+ }
118
+ if (discriminator === void 0) return void 0;
119
+ return {
120
+ options: options.filter(isObject),
121
+ discriminator
122
+ };
123
+ }
124
+ //#endregion
125
+ export { ANNOTATION_SIBLINGS, detectDiscriminated, mergeAllOf, mergeRefSiblings, normaliseAnyOf };
@@ -0,0 +1,41 @@
1
+ import { i as DiagnosticsOptions } from "../diagnostics-DzbZmcLI.mjs";
2
+ import { n as JsonSchemaDraft, r as OpenApiVersionInfo } from "../version-B5NV-35j.mjs";
3
+
4
+ //#region src/core/normalise.d.ts
5
+ type NodeTransform = (node: Record<string, unknown>) => Record<string, unknown>;
6
+ /**
7
+ * Deep-normalise a JSON Schema object by applying a per-node transform
8
+ * and recursing into every sub-schema location.
9
+ */
10
+ declare function deepNormalise(schema: Record<string, unknown>, transform: NodeTransform): Record<string, unknown>;
11
+ /**
12
+ * Normalise Draft 04 `exclusiveMinimum`/`exclusiveMaximum` from boolean
13
+ * to number form.
14
+ *
15
+ * In Draft 04:
16
+ * - `exclusiveMinimum: true` + `minimum: 5` → value must be > 5
17
+ * - `exclusiveMinimum: false` (or absent) + `minimum: 5` → value must be >= 5
18
+ *
19
+ * In Draft 06+:
20
+ * - `exclusiveMinimum: 5` → value must be > 5 (no separate `minimum`)
21
+ * - `minimum: 5` → value must be >= 5
22
+ *
23
+ * The transform converts boolean form to number form so the walker can
24
+ * treat `exclusiveMinimum`/`exclusiveMaximum` uniformly as numbers.
25
+ */
26
+ declare function normaliseDraft04Node(node: Record<string, unknown>): Record<string, unknown>;
27
+ /**
28
+ * Normalise a JSON Schema to canonical Draft 2020-12 form.
29
+ * Deep-clones the input — the original is never mutated.
30
+ */
31
+ declare function normaliseJsonSchema(schema: Record<string, unknown>, draft: JsonSchemaDraft): Record<string, unknown>;
32
+ /**
33
+ * Normalise an OpenAPI document's schemas for walker consumption.
34
+ * Handles version-specific keyword transformations.
35
+ *
36
+ * Returns the same object reference if no normalisation is needed
37
+ * (OpenAPI 3.1.x), or a deep-cloned normalised copy otherwise.
38
+ */
39
+ declare function normaliseOpenApiSchemas(doc: Record<string, unknown>, version: OpenApiVersionInfo, diagnostics?: DiagnosticsOptions): Record<string, unknown>;
40
+ //#endregion
41
+ export { NodeTransform, deepNormalise, normaliseDraft04Node, normaliseJsonSchema, normaliseOpenApiSchemas };
@@ -0,0 +1,2 @@
1
+ import { i as normaliseOpenApiSchemas, n as normaliseDraft04Node, r as normaliseJsonSchema, t as deepNormalise } from "../normalise-tL9FckAk.mjs";
2
+ export { deepNormalise, normaliseDraft04Node, normaliseJsonSchema, normaliseOpenApiSchemas };
@@ -0,0 +1,41 @@
1
+ import { NodeTransform } from "./normalise.mjs";
2
+
3
+ //#region src/core/openapi30.d.ts
4
+ /**
5
+ * Normalise OpenAPI 3.0.x `nullable` keyword to `anyOf [T, null]`.
6
+ *
7
+ * OpenAPI 3.0 uses `nullable: true` instead of the JSON Schema standard
8
+ * `anyOf: [T, { type: "null" }]`. The walker understands the latter form
9
+ * natively, so this normaliser converts `nullable` to `anyOf`.
10
+ *
11
+ * Only applied when `nullable` is explicitly `true`. `nullable: false` or
12
+ * absent is the default and requires no transformation.
13
+ */
14
+ declare function normaliseOpenApi30Node(node: Record<string, unknown>): Record<string, unknown>;
15
+ /**
16
+ * Normalise OpenAPI 3.0.x `discriminator` keyword by injecting `const`
17
+ * values into each `oneOf`/`anyOf` option's discriminator property.
18
+ *
19
+ * In OpenAPI 3.0, `discriminator` is a sibling of `oneOf`/`anyOf`:
20
+ * discriminator: { propertyName: "type" }
21
+ * The walker detects discriminated unions from `oneOf` + `const` on a
22
+ * property, so this normaliser injects the `const` values from the
23
+ * `mapping` or infers them from `$ref` fragment names.
24
+ */
25
+ declare function normaliseOpenApi30Discriminator(node: Record<string, unknown>): Record<string, unknown>;
26
+ /**
27
+ * Combined OpenAPI 3.0.x node transform: Draft 04 + nullable + discriminator.
28
+ * Applied to every schema node in an OpenAPI 3.0 document.
29
+ *
30
+ * Draft 04 normalisation is included because OpenAPI 3.0 inherits
31
+ * Draft 04/05 schema semantics including `exclusiveMinimum: boolean`.
32
+ */
33
+ declare function normaliseOpenApi30Combined(node: Record<string, unknown>): Record<string, unknown>;
34
+ /**
35
+ * Deep-normalise all schemas in an OpenAPI 3.0.x document.
36
+ * Walks components/schemas, path operations, parameters, request bodies,
37
+ * and responses — applying `nullable` normalisation to each schema.
38
+ */
39
+ declare function deepNormaliseOpenApi30Doc(doc: Record<string, unknown>, deepNormalise: (schema: Record<string, unknown>, transform: NodeTransform) => Record<string, unknown>): Record<string, unknown>;
40
+ //#endregion
41
+ export { deepNormaliseOpenApi30Doc, normaliseOpenApi30Combined, normaliseOpenApi30Discriminator, normaliseOpenApi30Node };
@@ -0,0 +1,2 @@
1
+ import { c as normaliseOpenApi30Discriminator, l as normaliseOpenApi30Node, o as deepNormaliseOpenApi30Doc, s as normaliseOpenApi30Combined } from "../normalise-tL9FckAk.mjs";
2
+ export { deepNormaliseOpenApi30Doc, normaliseOpenApi30Combined, normaliseOpenApi30Discriminator, normaliseOpenApi30Node };
@@ -0,0 +1,2 @@
1
+ import { a as findAnchor, i as dereference, n as RefOptions, o as resolveRef, r as countDistinctRefs, t as ExternalResolver } from "../ref-DvWoULcy.mjs";
2
+ export { ExternalResolver, RefOptions, countDistinctRefs, dereference, findAnchor, resolveRef };
@@ -0,0 +1,165 @@
1
+ import { isObject } from "./guards.mjs";
2
+ import { emitDiagnostic } from "./diagnostics.mjs";
3
+ //#region src/core/ref.ts
4
+ /**
5
+ * $ref resolution for JSON Schema.
6
+ *
7
+ * Handles JSON Pointer dereference, $anchor lookup, cycle detection,
8
+ * and depth limiting derived from the document's own $ref count.
9
+ */
10
+ function getString(obj, key) {
11
+ const value = obj[key];
12
+ return typeof value === "string" ? value : void 0;
13
+ }
14
+ /**
15
+ * Count all distinct `$ref` strings reachable from a root document.
16
+ * A chain longer than the number of distinct refs is necessarily cyclic.
17
+ * Returns at least 1 so that single-ref schemas have a usable bound.
18
+ */
19
+ function countDistinctRefs(root) {
20
+ const refs = /* @__PURE__ */ new Set();
21
+ collectRefs(root, refs);
22
+ return Math.max(refs.size, 1);
23
+ }
24
+ function collectRefs(node, refs) {
25
+ if (!isObject(node)) return;
26
+ const ref = node.$ref;
27
+ if (typeof ref === "string") refs.add(ref);
28
+ for (const value of Object.values(node)) if (isObject(value)) collectRefs(value, refs);
29
+ else if (Array.isArray(value)) for (const item of value) collectRefs(item, refs);
30
+ }
31
+ /**
32
+ * Resolve a `$ref` in a schema against a root document.
33
+ * Returns the original schema if no `$ref` is present.
34
+ * Returns an unknown-schema placeholder on cycle or depth exceeded.
35
+ *
36
+ * The depth bound is derived from the number of distinct `$ref` strings
37
+ * in the root document — a chain longer than that count is necessarily
38
+ * cyclic. When `maxDepth` is not provided, a reasonable default is used.
39
+ */
40
+ function resolveRef(schema, rootDocument, visited, diagnostics, maxDepth, externalResolver) {
41
+ const ref = getString(schema, "$ref");
42
+ if (ref === void 0) return schema;
43
+ if (visited.has(ref)) {
44
+ emitDiagnostic(diagnostics, {
45
+ code: "unresolved-ref",
46
+ message: `Circular $ref detected: ${ref}`,
47
+ pointer: ref,
48
+ detail: { ref }
49
+ });
50
+ return {
51
+ type: "unknown",
52
+ editability: "editable",
53
+ meta: {},
54
+ constraints: {}
55
+ };
56
+ }
57
+ const depthLimit = maxDepth ?? 64;
58
+ if (visited.size >= depthLimit) {
59
+ emitDiagnostic(diagnostics, {
60
+ code: "depth-exceeded",
61
+ message: `$ref depth exceeded derived bound (${String(depthLimit)}): ${ref}`,
62
+ pointer: ref,
63
+ detail: {
64
+ ref,
65
+ depth: visited.size,
66
+ bound: depthLimit
67
+ }
68
+ });
69
+ return {
70
+ type: "unknown",
71
+ editability: "editable",
72
+ meta: {},
73
+ constraints: {}
74
+ };
75
+ }
76
+ if (!ref.startsWith("#") && externalResolver !== void 0) {
77
+ const hashIndex = ref.indexOf("#");
78
+ const uri = hashIndex >= 0 ? ref.slice(0, hashIndex) : ref;
79
+ const fragment = hashIndex >= 0 ? ref.slice(hashIndex) : "#";
80
+ const externalDoc = externalResolver(uri);
81
+ if (isObject(externalDoc)) {
82
+ const target = dereference(fragment, externalDoc);
83
+ if (target !== void 0) {
84
+ const nextVisited = new Set(visited);
85
+ nextVisited.add(ref);
86
+ return resolveRef(target, externalDoc, nextVisited, diagnostics, maxDepth, externalResolver);
87
+ }
88
+ }
89
+ emitDiagnostic(diagnostics, {
90
+ code: "external-ref",
91
+ message: `External resolver returned no document for: ${ref}`,
92
+ pointer: ref,
93
+ detail: {
94
+ ref,
95
+ uri
96
+ }
97
+ });
98
+ return {
99
+ type: "unknown",
100
+ editability: "editable",
101
+ meta: {},
102
+ constraints: {}
103
+ };
104
+ }
105
+ const resolved = dereference(ref, rootDocument);
106
+ if (resolved === void 0) {
107
+ emitDiagnostic(diagnostics, {
108
+ code: "unresolved-ref",
109
+ message: `Could not resolve $ref: ${ref}`,
110
+ pointer: ref,
111
+ detail: { ref }
112
+ });
113
+ return {
114
+ type: "unknown",
115
+ editability: "editable",
116
+ meta: {},
117
+ constraints: {}
118
+ };
119
+ }
120
+ const nextVisited = new Set(visited);
121
+ nextVisited.add(ref);
122
+ return resolveRef(resolved, rootDocument, nextVisited, diagnostics, maxDepth, externalResolver);
123
+ }
124
+ /**
125
+ * Dereference a JSON Pointer fragment (`#/path/to/schema`) or an
126
+ * `$anchor` (`#SomeName`) against a root document.
127
+ */
128
+ function dereference(ref, root) {
129
+ if (ref === "#") return root;
130
+ if (ref.startsWith("#/")) {
131
+ const parts = ref.slice(2).split("/");
132
+ if (parts.length === 1 && parts[0] === "") return root;
133
+ let current = root;
134
+ for (const part of parts) {
135
+ if (!isObject(current)) return void 0;
136
+ const decoded = part.replace(/~1/g, "/").replace(/~0/g, "~");
137
+ current = current[decoded];
138
+ }
139
+ return isObject(current) ? current : void 0;
140
+ }
141
+ if (ref.startsWith("#") && ref.length > 1) {
142
+ const found = findAnchor(root, ref.slice(1));
143
+ if (found !== void 0) return found;
144
+ }
145
+ }
146
+ /**
147
+ * Recursively scan a schema document for a `$anchor` matching the given name.
148
+ * Returns the schema object containing the anchor, or undefined.
149
+ */
150
+ function findAnchor(node, anchorName) {
151
+ if (!isObject(node)) return void 0;
152
+ if (node.$anchor === anchorName) return node;
153
+ for (const value of Object.values(node)) {
154
+ if (isObject(value)) {
155
+ const found = findAnchor(value, anchorName);
156
+ if (found !== void 0) return found;
157
+ }
158
+ if (Array.isArray(value)) for (const item of value) {
159
+ const found = findAnchor(item, anchorName);
160
+ if (found !== void 0) return found;
161
+ }
162
+ }
163
+ }
164
+ //#endregion
165
+ export { countDistinctRefs, dereference, findAnchor, resolveRef };
@@ -1,2 +1,2 @@
1
- import { A as mergeResolvers, C as HtmlResolver, D as getHtmlRenderFn, E as RenderProps, O as getRenderFunction, S as HtmlRenderProps, T as RenderFunction, b as ComponentResolver, j as typeToKey, k as mergeHtmlResolvers, w as RESOLVER_KEYS, x as HtmlRenderFunction, y as BaseFieldProps } from "../types-BJzEgJdX.mjs";
2
- export { BaseFieldProps, ComponentResolver, HtmlRenderFunction, HtmlRenderProps, HtmlResolver, RESOLVER_KEYS, RenderFunction, RenderProps, getHtmlRenderFn, getRenderFunction, mergeHtmlResolvers, mergeResolvers, typeToKey };
1
+ import { a as HtmlRenderProps, c as RenderFunction, d as getRenderFunction, f as mergeHtmlResolvers, i as HtmlRenderFunction, l as RenderProps, m as typeToKey, n as BaseFieldProps, o as HtmlResolver, p as mergeResolvers, r as ComponentResolver, s as RESOLVER_KEYS, t as AllConstraints, u as getHtmlRenderFn } from "../renderer-BdSqllx5.mjs";
2
+ export { AllConstraints, BaseFieldProps, ComponentResolver, HtmlRenderFunction, HtmlRenderProps, HtmlResolver, RESOLVER_KEYS, RenderFunction, RenderProps, getHtmlRenderFn, getRenderFunction, mergeHtmlResolvers, mergeResolvers, typeToKey };
@@ -6,9 +6,13 @@ const RESOLVER_KEYS = [
6
6
  "enum",
7
7
  "object",
8
8
  "array",
9
+ "tuple",
9
10
  "record",
10
11
  "union",
11
12
  "discriminatedUnion",
13
+ "conditional",
14
+ "negation",
15
+ "recursive",
12
16
  "literal",
13
17
  "file",
14
18
  "unknown"
@@ -25,9 +29,13 @@ function typeToKey(type) {
25
29
  case "enum":
26
30
  case "object":
27
31
  case "array":
32
+ case "tuple":
28
33
  case "record":
29
34
  case "union":
30
35
  case "discriminatedUnion":
36
+ case "conditional":
37
+ case "negation":
38
+ case "recursive":
31
39
  case "literal":
32
40
  case "file":
33
41
  case "unknown": return type;
@@ -0,0 +1,11 @@
1
+ import { i as DiagnosticsOptions } from "../diagnostics-DzbZmcLI.mjs";
2
+ import { NodeTransform } from "./normalise.mjs";
3
+
4
+ //#region src/core/swagger2.d.ts
5
+ /**
6
+ * Transform a Swagger 2.0 document into an OpenAPI 3.1-compatible
7
+ * structure.
8
+ */
9
+ declare function normaliseSwagger2Document(doc: Record<string, unknown>, deepNormalise: (schema: Record<string, unknown>, transform: NodeTransform) => Record<string, unknown>, normaliseDraft04Node: NodeTransform, diagnostics?: DiagnosticsOptions): Record<string, unknown>;
10
+ //#endregion
11
+ export { normaliseSwagger2Document };
@@ -0,0 +1,2 @@
1
+ import { a as normaliseSwagger2Document } from "../normalise-tL9FckAk.mjs";
2
+ export { normaliseSwagger2Document };
@@ -0,0 +1,2 @@
1
+ import { a as OpenAPIRequestBodyType, c as ResolveOpenAPIRef, d as __SchemaInferenceFellBack, i as InferResponseFields, l as TypeAtPath, n as InferParameterOverrides, o as OpenAPIResponseType, r as InferRequestBodyFields, s as PathOfType, t as FromJSONSchema, u as UnsafeFields } from "../typeInference-k7FXfTVO.mjs";
2
+ export { FromJSONSchema, InferParameterOverrides, InferRequestBodyFields, InferResponseFields, OpenAPIRequestBodyType, OpenAPIResponseType, PathOfType, ResolveOpenAPIRef, TypeAtPath, UnsafeFields, __SchemaInferenceFellBack };
@@ -0,0 +1 @@
1
+ export {};
@@ -1,3 +1,2 @@
1
- import { C as HtmlResolver, E as RenderProps, S as HtmlRenderProps, T as RenderFunction, _ as WalkedField, a as FromJSONSchema, b as ComponentResolver, c as InferResponseFields, d as OpenAPIResponseType, f as PathOfType, g as TypeAtPath, h as SchemaType, i as FieldOverrides, l as JsonObject, m as SchemaMeta, n as FieldConstraints, o as InferParameterOverrides, p as ResolveOpenAPIRef, r as FieldOverride, s as InferRequestBodyFields, t as Editability, u as OpenAPIRequestBodyType, v as resolveEditability, x as HtmlRenderFunction, y as BaseFieldProps } from "../types-BJzEgJdX.mjs";
2
- import { i as SchemaRenderError, n as SchemaFieldError, r as SchemaNormalisationError, t as SchemaError } from "../errors-DIKI2C78.mjs";
3
- export { BaseFieldProps, ComponentResolver, Editability, FieldConstraints, FieldOverride, FieldOverrides, FromJSONSchema, HtmlRenderFunction, HtmlRenderProps, HtmlResolver, InferParameterOverrides, InferRequestBodyFields, InferResponseFields, JsonObject, OpenAPIRequestBodyType, OpenAPIResponseType, PathOfType, RenderFunction, RenderProps, ResolveOpenAPIRef, SchemaError, SchemaFieldError, SchemaMeta, SchemaNormalisationError, SchemaRenderError, SchemaType, TypeAtPath, WalkedField, resolveEditability };
1
+ import { A as UnionField, B as isNegationField, C as RecordField, D as StringConstraints, E as SchemaType, F as isConditionalField, G as isRecordField, H as isNullField, I as isDiscriminatedUnionField, J as isTupleField, K as isRecursiveField, L as isEnumField, M as WalkedField, N as isArrayField, O as StringField, P as isBooleanField, R as isFileField, S as ObjectField, T as SchemaMeta, U as isNumberField, V as isNeverField, W as isObjectField, X as isUnknownField, Y as isUnionField, Z as resolveEditability, _ as NeverField, a as DiscriminatedUnionField, b as NumberField, c as FieldBase, d as FieldOverrides, f as FileConstraints, g as NegationField, h as LiteralField, i as ConditionalField, j as UnknownField, k as TupleField, l as FieldConstraints, m as JsonObject, n as ArrayField, o as Editability, p as FileField, q as isStringField, r as BooleanField, s as EnumField, t as ArrayConstraints, u as FieldOverride, v as NullField, w as RecursiveField, x as ObjectConstraints, y as NumberConstraints, z as isLiteralField } from "../types-D_5ST7SS.mjs";
2
+ export { ArrayConstraints, ArrayField, BooleanField, ConditionalField, DiscriminatedUnionField, Editability, EnumField, FieldBase, FieldConstraints, FieldOverride, FieldOverrides, FileConstraints, FileField, JsonObject, LiteralField, NegationField, NeverField, NullField, NumberConstraints, NumberField, ObjectConstraints, ObjectField, RecordField, RecursiveField, SchemaMeta, SchemaType, StringConstraints, StringField, TupleField, UnionField, UnknownField, WalkedField, isArrayField, isBooleanField, isConditionalField, isDiscriminatedUnionField, isEnumField, isFileField, isLiteralField, isNegationField, isNeverField, isNullField, isNumberField, isObjectField, isRecordField, isRecursiveField, isStringField, isTupleField, isUnionField, isUnknownField, resolveEditability };
@@ -1,4 +1,3 @@
1
- import { SchemaError, SchemaFieldError, SchemaNormalisationError, SchemaRenderError } from "./errors.mjs";
2
1
  //#region src/core/types.ts
3
2
  /**
4
3
  * Resolved editability state for a single field.
@@ -36,5 +35,62 @@ function resolveEditability(propertyMeta, componentMeta, rootMeta) {
36
35
  if (rootMeta !== void 0 && ("readOnly" in rootMeta || "writeOnly" in rootMeta)) return "editable";
37
36
  return "editable";
38
37
  }
38
+ function isField(field, t) {
39
+ return field.type === t;
40
+ }
41
+ function isStringField(field) {
42
+ return isField(field, "string");
43
+ }
44
+ function isNumberField(field) {
45
+ return isField(field, "number");
46
+ }
47
+ function isBooleanField(field) {
48
+ return isField(field, "boolean");
49
+ }
50
+ function isNullField(field) {
51
+ return isField(field, "null");
52
+ }
53
+ function isEnumField(field) {
54
+ return isField(field, "enum");
55
+ }
56
+ function isLiteralField(field) {
57
+ return isField(field, "literal");
58
+ }
59
+ function isObjectField(field) {
60
+ return isField(field, "object");
61
+ }
62
+ function isArrayField(field) {
63
+ return isField(field, "array");
64
+ }
65
+ function isTupleField(field) {
66
+ return isField(field, "tuple");
67
+ }
68
+ function isRecordField(field) {
69
+ return isField(field, "record");
70
+ }
71
+ function isUnionField(field) {
72
+ return isField(field, "union");
73
+ }
74
+ function isDiscriminatedUnionField(field) {
75
+ return isField(field, "discriminatedUnion");
76
+ }
77
+ function isConditionalField(field) {
78
+ return isField(field, "conditional");
79
+ }
80
+ function isNegationField(field) {
81
+ return isField(field, "negation");
82
+ }
83
+ function isFileField(field) {
84
+ return isField(field, "file");
85
+ }
86
+ function isRecursiveField(field) {
87
+ return isField(field, "recursive");
88
+ }
89
+ function isNeverField(field) {
90
+ return isField(field, "never");
91
+ }
92
+ function isUnknownField(field) {
93
+ return isField(field, "unknown");
94
+ }
39
95
  //#endregion
40
- export { SchemaError, SchemaFieldError, SchemaNormalisationError, SchemaRenderError, resolveEditability };
96
+ export { isArrayField, isBooleanField, isConditionalField, isDiscriminatedUnionField, isEnumField, isFileField, isLiteralField, isNegationField, isNeverField, isNullField, isNumberField, isObjectField, isRecordField, isRecursiveField, isStringField, isTupleField, isUnionField, isUnknownField, resolveEditability };
@@ -0,0 +1,2 @@
1
+ import { a as detectOpenApiVersion, c as isOpenApi30, i as detectJsonSchemaDraft, l as isOpenApi31, n as JsonSchemaDraft, o as inferJsonSchemaDraft, r as OpenApiVersionInfo, s as inferJsonSchemaDraftWithReason, t as InferredDraft, u as isSwagger2 } from "../version-B5NV-35j.mjs";
2
+ export { InferredDraft, JsonSchemaDraft, OpenApiVersionInfo, detectJsonSchemaDraft, detectOpenApiVersion, inferJsonSchemaDraft, inferJsonSchemaDraftWithReason, isOpenApi30, isOpenApi31, isSwagger2 };