schema-components 1.28.2 → 1.29.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 (81) hide show
  1. package/dist/{adapter-DqlAnZ_w.d.mts → adapter-DcWi4XXn.d.mts} +60 -9
  2. package/dist/core/adapter.d.mts +2 -2
  3. package/dist/core/adapter.mjs +20 -1
  4. package/dist/core/constraints.d.mts +34 -2
  5. package/dist/core/constraints.mjs +32 -0
  6. package/dist/core/cssClasses.d.mts +1 -0
  7. package/dist/core/diagnostics.d.mts +1 -1
  8. package/dist/core/errors.d.mts +1 -1
  9. package/dist/core/errors.mjs +22 -12
  10. package/dist/core/fieldOrder.d.mts +1 -1
  11. package/dist/core/formats.d.mts +7 -1
  12. package/dist/core/formats.mjs +6 -0
  13. package/dist/core/limits.d.mts +1 -1
  14. package/dist/core/limits.mjs +1 -0
  15. package/dist/core/merge.d.mts +11 -1
  16. package/dist/core/normalise.d.mts +17 -2
  17. package/dist/core/openapiConstants.d.mts +1 -0
  18. package/dist/core/ref.d.mts +1 -1
  19. package/dist/core/renderer.d.mts +1 -1
  20. package/dist/core/renderer.mjs +5 -0
  21. package/dist/core/swagger2.d.mts +1 -1
  22. package/dist/core/typeInference.d.mts +2 -2
  23. package/dist/core/types.d.mts +1 -1
  24. package/dist/core/types.mjs +17 -0
  25. package/dist/core/unionMatch.d.mts +1 -1
  26. package/dist/core/version.d.mts +1 -1
  27. package/dist/core/walkBuilders.d.mts +48 -3
  28. package/dist/core/walkBuilders.mjs +30 -0
  29. package/dist/core/walker.d.mts +14 -1
  30. package/dist/core/walker.mjs +13 -0
  31. package/dist/{diagnostics-Cbwak-ZX.d.mts → diagnostics-ByEzkjrA.d.mts} +8 -0
  32. package/dist/{errors-DQSIK4n1.d.mts → errors-D8JndRwI.d.mts} +23 -13
  33. package/dist/html/a11y.d.mts +2 -2
  34. package/dist/html/html.d.mts +11 -0
  35. package/dist/html/html.mjs +11 -0
  36. package/dist/html/renderToHtml.d.mts +25 -5
  37. package/dist/html/renderToHtml.mjs +18 -3
  38. package/dist/html/renderToHtmlStream.d.mts +41 -9
  39. package/dist/html/renderToHtmlStream.mjs +32 -7
  40. package/dist/html/renderers.d.mts +7 -1
  41. package/dist/html/renderers.mjs +6 -0
  42. package/dist/html/streamRenderers.d.mts +31 -3
  43. package/dist/html/streamRenderers.mjs +28 -0
  44. package/dist/{limits-DJhgx5Ay.d.mts → limits-DswmqWuy.d.mts} +1 -0
  45. package/dist/openapi/ApiCallbacks.d.mts +13 -1
  46. package/dist/openapi/ApiCallbacks.mjs +7 -0
  47. package/dist/openapi/ApiLinks.d.mts +13 -1
  48. package/dist/openapi/ApiLinks.mjs +7 -0
  49. package/dist/openapi/ApiResponseHeaders.d.mts +13 -1
  50. package/dist/openapi/ApiResponseHeaders.mjs +7 -0
  51. package/dist/openapi/ApiSecurity.d.mts +14 -1
  52. package/dist/openapi/ApiSecurity.mjs +8 -0
  53. package/dist/openapi/components.d.mts +96 -12
  54. package/dist/openapi/components.mjs +71 -2
  55. package/dist/openapi/parser.d.mts +129 -2
  56. package/dist/openapi/parser.mjs +72 -0
  57. package/dist/openapi/resolve.d.mts +7 -1
  58. package/dist/react/SchemaComponent.d.mts +84 -6
  59. package/dist/react/SchemaComponent.mjs +62 -1
  60. package/dist/react/SchemaErrorBoundary.d.mts +18 -1
  61. package/dist/react/SchemaErrorBoundary.mjs +13 -1
  62. package/dist/react/SchemaView.d.mts +32 -8
  63. package/dist/react/SchemaView.mjs +20 -5
  64. package/dist/react/a11y.d.mts +1 -1
  65. package/dist/react/fieldPath.d.mts +1 -1
  66. package/dist/react/headless.d.mts +1 -1
  67. package/dist/react/headlessRenderers.d.mts +13 -2
  68. package/dist/react/headlessRenderers.mjs +12 -1
  69. package/dist/{ref-TdeMfaV_.d.mts → ref-CPh8rKQ3.d.mts} +1 -1
  70. package/dist/{renderer-Ul9taFYp.d.mts → renderer-OaOz-n6-.d.mts} +17 -1
  71. package/dist/themes/mantine.d.mts +29 -3
  72. package/dist/themes/mantine.mjs +28 -2
  73. package/dist/themes/mui.d.mts +29 -2
  74. package/dist/themes/mui.mjs +29 -2
  75. package/dist/themes/radix.d.mts +40 -3
  76. package/dist/themes/radix.mjs +39 -2
  77. package/dist/themes/shadcn.d.mts +22 -1
  78. package/dist/themes/shadcn.mjs +21 -0
  79. package/dist/{types-BTB73MB8.d.mts → types-C2Ay1FEh.d.mts} +23 -0
  80. package/dist/{version-ZzL5R6cS.d.mts → version-DL8U5RuA.d.mts} +6 -0
  81. package/package.json +5 -1
@@ -1,11 +1,22 @@
1
- import { m as JsonObject } from "../types-BTB73MB8.mjs";
2
- import { i as DiagnosticsOptions } from "../diagnostics-Cbwak-ZX.mjs";
1
+ import { m as JsonObject } from "../types-C2Ay1FEh.mjs";
2
+ import { i as DiagnosticsOptions } from "../diagnostics-ByEzkjrA.mjs";
3
3
 
4
4
  //#region src/openapi/parser.d.ts
5
+ /**
6
+ * Parsed OpenAPI document: the raw root JSON plus a cache of resolved
7
+ * `#/components/schemas/*` (or Swagger 2.0 `#/definitions/*`) entries.
8
+ * Produced by {@link parseOpenApiDocument} and consumed by every other
9
+ * parser/resolver helper in this module.
10
+ */
5
11
  interface OpenApiDocument {
6
12
  doc: JsonObject;
7
13
  schemas: Map<string, JsonObject>;
8
14
  }
15
+ /**
16
+ * Lightweight summary of an OpenAPI operation: its location, identity,
17
+ * description fields, deprecation flag, and the underlying Operation
18
+ * Object. Returned by {@link listOperations} / {@link listAllOperations}.
19
+ */
9
20
  interface OperationInfo {
10
21
  path: string;
11
22
  method: string;
@@ -15,7 +26,12 @@ interface OperationInfo {
15
26
  deprecated: boolean;
16
27
  operation: JsonObject;
17
28
  }
29
+ /** Canonical four-value OpenAPI parameter `in` location. */
18
30
  type ParameterLocation = "query" | "path" | "header" | "cookie";
31
+ /**
32
+ * Parsed view of an OpenAPI Parameter Object — name, location,
33
+ * required flag, deprecation flag, description, and resolved schema.
34
+ */
19
35
  interface ParameterInfo {
20
36
  name: string;
21
37
  location: ParameterLocation;
@@ -24,6 +40,10 @@ interface ParameterInfo {
24
40
  description: string | undefined;
25
41
  schema: JsonObject | undefined;
26
42
  }
43
+ /**
44
+ * Parsed view of an OpenAPI Response Object — status code, description,
45
+ * declared content types, response schema, and resolved headers.
46
+ */
27
47
  interface ResponseInfo {
28
48
  statusCode: string;
29
49
  description: string | undefined;
@@ -31,16 +51,29 @@ interface ResponseInfo {
31
51
  schema: JsonObject | undefined;
32
52
  headers: Map<string, HeaderInfo>;
33
53
  }
54
+ /**
55
+ * Parsed view of an OpenAPI Request Body Object — required flag,
56
+ * description, declared content types, and the request body schema.
57
+ */
34
58
  interface RequestBodyInfo {
35
59
  required: boolean;
36
60
  description: string | undefined;
37
61
  contentTypes: string[];
38
62
  schema: JsonObject | undefined;
39
63
  }
64
+ /**
65
+ * A single entry in an OpenAPI Security Requirement Object — the name
66
+ * of a security scheme paired with its list of required scopes.
67
+ */
40
68
  interface SecurityRequirement {
41
69
  name: string;
42
70
  scopes: string[];
43
71
  }
72
+ /**
73
+ * Parsed view of an OpenAPI Security Scheme Object covering every
74
+ * field defined for `apiKey`, `http`, `oauth2`, `openIdConnect`, and
75
+ * `mutualTLS` schemes.
76
+ */
44
77
  interface SecurityScheme {
45
78
  type: string | undefined;
46
79
  description: string | undefined;
@@ -51,6 +84,10 @@ interface SecurityScheme {
51
84
  flows: JsonObject | undefined;
52
85
  openIdConnectUrl: string | undefined;
53
86
  }
87
+ /**
88
+ * Parsed view of an OpenAPI Header Object — name, description, required
89
+ * and deprecated flags, and resolved schema.
90
+ */
54
91
  interface HeaderInfo {
55
92
  name: string;
56
93
  description: string | undefined;
@@ -58,14 +95,23 @@ interface HeaderInfo {
58
95
  deprecated: boolean;
59
96
  schema: JsonObject | undefined;
60
97
  }
98
+ /**
99
+ * Parsed view of a single OpenAPI 3.1 webhook entry: its name and the
100
+ * operations declared on its Path Item Object.
101
+ */
61
102
  interface WebhookInfo {
62
103
  name: string;
63
104
  operations: OperationInfo[];
64
105
  }
106
+ /** Parsed view of an OpenAPI External Documentation Object. */
65
107
  interface ExternalDocs {
66
108
  url: string;
67
109
  description: string | undefined;
68
110
  }
111
+ /**
112
+ * Parsed view of an OpenAPI XML Object — controls how a schema field
113
+ * is serialised in an XML payload.
114
+ */
69
115
  interface XmlInfo {
70
116
  name: string | undefined;
71
117
  namespace: string | undefined;
@@ -73,10 +119,19 @@ interface XmlInfo {
73
119
  attribute: boolean;
74
120
  wrapped: boolean;
75
121
  }
122
+ /**
123
+ * Parsed view of a single OpenAPI Callback Object: its name and the
124
+ * operations declared on every callback path.
125
+ */
76
126
  interface CallbackInfo {
77
127
  name: string;
78
128
  operations: OperationInfo[];
79
129
  }
130
+ /**
131
+ * Parsed view of an OpenAPI Link Object — name, target operation
132
+ * (`operationId` or `operationRef`), description, parameter mappings,
133
+ * and the optional request body expression.
134
+ */
80
135
  interface LinkInfo {
81
136
  name: string;
82
137
  operationId: string | undefined;
@@ -85,15 +140,67 @@ interface LinkInfo {
85
140
  parameters: Map<string, string>;
86
141
  requestBody: string | undefined;
87
142
  }
143
+ /**
144
+ * Build an {@link OpenApiDocument} from a raw OpenAPI JSON object.
145
+ *
146
+ * Eagerly indexes the document's `#/components/schemas/*` entries and
147
+ * lazily caches any other `$ref` lookup on first request. Used by
148
+ * every other helper in this module as the single entry point for
149
+ * structured access to an OpenAPI document.
150
+ */
88
151
  declare function parseOpenApiDocument(doc: JsonObject): OpenApiDocument;
152
+ /**
153
+ * Resolve a `$ref` string against a parsed OpenAPI document. Returns
154
+ * the cached entry for `#/components/schemas/*` refs (or the lazily
155
+ * resolved value for arbitrary fragment refs), or `undefined` when the
156
+ * ref cannot be resolved.
157
+ */
89
158
  declare function getSchema(parsed: OpenApiDocument, ref: string): JsonObject | undefined;
159
+ /**
160
+ * List every operation declared under the document's `paths` map.
161
+ * Follows Path Item `$ref` chains internally; cycles and over-deep
162
+ * chains surface as diagnostics when a sink is supplied.
163
+ */
90
164
  declare function listOperations(parsed: OpenApiDocument, diagnostics?: DiagnosticsOptions, seenIds?: Map<string, string>): OperationInfo[];
165
+ /**
166
+ * Resolve the parameters of a single operation, merging path-level
167
+ * parameters with operation-level overrides and following any
168
+ * Parameter Object `$ref` chains.
169
+ */
91
170
  declare function getParameters(parsed: OpenApiDocument, path: string, method: string, diagnostics?: DiagnosticsOptions): ParameterInfo[];
171
+ /**
172
+ * Resolve the request body of a single operation, including its
173
+ * declared content types and schema. Returns `undefined` when the
174
+ * operation declares no request body.
175
+ */
92
176
  declare function getRequestBody(parsed: OpenApiDocument, path: string, method: string): RequestBodyInfo | undefined;
177
+ /**
178
+ * Resolve the responses of a single operation, returning one
179
+ * {@link ResponseInfo} per declared status code (including class
180
+ * wildcards and `default`).
181
+ */
93
182
  declare function getResponses(parsed: OpenApiDocument, path: string, method: string, diagnostics?: DiagnosticsOptions): ResponseInfo[];
183
+ /**
184
+ * Resolve the effective security requirements for a single operation.
185
+ * Operation-level requirements override the document-level defaults
186
+ * when present.
187
+ */
94
188
  declare function getSecurityRequirements(parsed: OpenApiDocument, path: string, method: string): SecurityRequirement[];
189
+ /**
190
+ * Read the document's `components.securitySchemes` map as a map of
191
+ * scheme names to {@link SecurityScheme} entries.
192
+ */
95
193
  declare function getSecuritySchemes(parsed: OpenApiDocument): Map<string, SecurityScheme>;
194
+ /**
195
+ * Resolve the headers of a single OpenAPI Response Object as a map of
196
+ * header name to {@link HeaderInfo}. Follows Header Object `$ref`
197
+ * chains via the optional document root.
198
+ */
96
199
  declare function getResponseHeaders(response: JsonObject, doc?: JsonObject, diagnostics?: DiagnosticsOptions): Map<string, HeaderInfo>;
200
+ /**
201
+ * List every OpenAPI 3.1 webhook declared under the document's
202
+ * `webhooks` map, each with its name and resolved operations.
203
+ */
97
204
  declare function listWebhooks(parsed: OpenApiDocument, diagnostics?: DiagnosticsOptions, seenIds?: Map<string, string>): WebhookInfo[];
98
205
  /**
99
206
  * Enumerate every operation in the document — both the `paths` map and
@@ -104,9 +211,29 @@ declare function listWebhooks(parsed: OpenApiDocument, diagnostics?: Diagnostics
104
211
  * grouping should call `listWebhooks` directly.
105
212
  */
106
213
  declare function listAllOperations(parsed: OpenApiDocument, diagnostics?: DiagnosticsOptions): OperationInfo[];
214
+ /**
215
+ * Read the optional `externalDocs` field on an OpenAPI object
216
+ * (document, operation, tag, schema, ...) into an {@link ExternalDocs}
217
+ * record. Returns `undefined` when absent or malformed.
218
+ */
107
219
  declare function getExternalDocs(obj: JsonObject): ExternalDocs | undefined;
220
+ /**
221
+ * Read the optional `xml` keyword on a JSON Schema object into an
222
+ * {@link XmlInfo} record describing how the field is serialised in an
223
+ * XML payload. Returns `undefined` when absent or malformed.
224
+ */
108
225
  declare function getXmlInfo(schema: JsonObject): XmlInfo | undefined;
226
+ /**
227
+ * List the OpenAPI callback definitions declared on a single
228
+ * operation. Each entry carries the callback name and the operations
229
+ * declared on its Path Item Object.
230
+ */
109
231
  declare function listCallbacks(parsed: OpenApiDocument, path: string, method: string, diagnostics?: DiagnosticsOptions): CallbackInfo[];
232
+ /**
233
+ * List the OpenAPI link definitions declared on a specific response of
234
+ * a single operation, returning each link's parsed
235
+ * {@link LinkInfo} entry.
236
+ */
110
237
  declare function getLinks(parsed: OpenApiDocument, path: string, method: string, statusCode: string, diagnostics?: DiagnosticsOptions): LinkInfo[];
111
238
  //#endregion
112
239
  export { CallbackInfo, ExternalDocs, HeaderInfo, LinkInfo, OpenApiDocument, OperationInfo, ParameterInfo, ParameterLocation, RequestBodyInfo, ResponseInfo, SecurityRequirement, SecurityScheme, WebhookInfo, XmlInfo, getExternalDocs, getLinks, getParameters, getRequestBody, getResponseHeaders, getResponses, getSchema, getSecurityRequirements, getSecuritySchemes, getXmlInfo, listAllOperations, listCallbacks, listOperations, listWebhooks, parseOpenApiDocument };
@@ -33,6 +33,14 @@ function toParameterLocation(value, parameterName, pointer, diagnostics) {
33
33
  }
34
34
  });
35
35
  }
36
+ /**
37
+ * Build an {@link OpenApiDocument} from a raw OpenAPI JSON object.
38
+ *
39
+ * Eagerly indexes the document's `#/components/schemas/*` entries and
40
+ * lazily caches any other `$ref` lookup on first request. Used by
41
+ * every other helper in this module as the single entry point for
42
+ * structured access to an OpenAPI document.
43
+ */
36
44
  function parseOpenApiDocument(doc) {
37
45
  const schemas = /* @__PURE__ */ new Map();
38
46
  const componentSchemas = getProperty(getProperty(doc, "components"), "schemas");
@@ -44,6 +52,12 @@ function parseOpenApiDocument(doc) {
44
52
  schemas
45
53
  };
46
54
  }
55
+ /**
56
+ * Resolve a `$ref` string against a parsed OpenAPI document. Returns
57
+ * the cached entry for `#/components/schemas/*` refs (or the lazily
58
+ * resolved value for arbitrary fragment refs), or `undefined` when the
59
+ * ref cannot be resolved.
60
+ */
47
61
  function getSchema(parsed, ref) {
48
62
  const cached = parsed.schemas.get(ref);
49
63
  if (cached !== void 0) return cached;
@@ -125,6 +139,11 @@ function recordOperationId(operationId, location, pointer, seenIds, diagnostics)
125
139
  }
126
140
  seenIds.set(operationId, location);
127
141
  }
142
+ /**
143
+ * List every operation declared under the document's `paths` map.
144
+ * Follows Path Item `$ref` chains internally; cycles and over-deep
145
+ * chains surface as diagnostics when a sink is supplied.
146
+ */
128
147
  function listOperations(parsed, diagnostics, seenIds = /* @__PURE__ */ new Map()) {
129
148
  const operations = [];
130
149
  const paths = getProperty(parsed.doc, "paths");
@@ -150,6 +169,11 @@ function listOperations(parsed, diagnostics, seenIds = /* @__PURE__ */ new Map()
150
169
  }
151
170
  return operations;
152
171
  }
172
+ /**
173
+ * Resolve the parameters of a single operation, merging path-level
174
+ * parameters with operation-level overrides and following any
175
+ * Parameter Object `$ref` chains.
176
+ */
153
177
  function getParameters(parsed, path, method, diagnostics) {
154
178
  const pathItem = lookupPathItem(parsed, path);
155
179
  if (pathItem === void 0) return [];
@@ -246,6 +270,11 @@ function resolveParam(doc, param, diagnostics) {
246
270
  function jsonPointerEscape(segment) {
247
271
  return segment.replace(/~/g, "~0").replace(/\//g, "~1");
248
272
  }
273
+ /**
274
+ * Resolve the request body of a single operation, including its
275
+ * declared content types and schema. Returns `undefined` when the
276
+ * operation declares no request body.
277
+ */
249
278
  function getRequestBody(parsed, path, method) {
250
279
  const requestBodyRaw = getProperty(getProperty(lookupPathItem(parsed, path), method), "requestBody");
251
280
  if (!isObject(requestBodyRaw)) return void 0;
@@ -267,6 +296,11 @@ function getRequestBody(parsed, path, method) {
267
296
  schema
268
297
  };
269
298
  }
299
+ /**
300
+ * Resolve the responses of a single operation, returning one
301
+ * {@link ResponseInfo} per declared status code (including class
302
+ * wildcards and `default`).
303
+ */
270
304
  function getResponses(parsed, path, method, diagnostics) {
271
305
  const responses = getProperty(getProperty(lookupPathItem(parsed, path), method), "responses");
272
306
  if (!isObject(responses)) return [];
@@ -409,6 +443,11 @@ function resolveRefInDoc(doc, ref) {
409
443
  }
410
444
  return isObject(current) ? current : void 0;
411
445
  }
446
+ /**
447
+ * Resolve the effective security requirements for a single operation.
448
+ * Operation-level requirements override the document-level defaults
449
+ * when present.
450
+ */
412
451
  function getSecurityRequirements(parsed, path, method) {
413
452
  const opSecurity = getProperty(getProperty(lookupPathItem(parsed, path), method), "security");
414
453
  const globalSecurity = getProperty(parsed.doc, "security");
@@ -423,6 +462,10 @@ function getSecurityRequirements(parsed, path, method) {
423
462
  }
424
463
  return result;
425
464
  }
465
+ /**
466
+ * Read the document's `components.securitySchemes` map as a map of
467
+ * scheme names to {@link SecurityScheme} entries.
468
+ */
426
469
  function getSecuritySchemes(parsed) {
427
470
  const result = /* @__PURE__ */ new Map();
428
471
  const securitySchemes = getProperty(getProperty(parsed.doc, "components"), "securitySchemes");
@@ -443,6 +486,11 @@ function getSecuritySchemes(parsed) {
443
486
  }
444
487
  return result;
445
488
  }
489
+ /**
490
+ * Resolve the headers of a single OpenAPI Response Object as a map of
491
+ * header name to {@link HeaderInfo}. Follows Header Object `$ref`
492
+ * chains via the optional document root.
493
+ */
446
494
  function getResponseHeaders(response, doc, diagnostics) {
447
495
  const result = /* @__PURE__ */ new Map();
448
496
  const headers = getProperty(response, "headers");
@@ -461,6 +509,10 @@ function getResponseHeaders(response, doc, diagnostics) {
461
509
  }
462
510
  return result;
463
511
  }
512
+ /**
513
+ * List every OpenAPI 3.1 webhook declared under the document's
514
+ * `webhooks` map, each with its name and resolved operations.
515
+ */
464
516
  function listWebhooks(parsed, diagnostics, seenIds = /* @__PURE__ */ new Map()) {
465
517
  const result = [];
466
518
  const webhooks = getProperty(parsed.doc, "webhooks");
@@ -505,6 +557,11 @@ function listAllOperations(parsed, diagnostics) {
505
557
  const webhookOps = listWebhooks(parsed, diagnostics, seenIds).flatMap((w) => w.operations);
506
558
  return [...pathOps, ...webhookOps];
507
559
  }
560
+ /**
561
+ * Read the optional `externalDocs` field on an OpenAPI object
562
+ * (document, operation, tag, schema, ...) into an {@link ExternalDocs}
563
+ * record. Returns `undefined` when absent or malformed.
564
+ */
508
565
  function getExternalDocs(obj) {
509
566
  const docs = getProperty(obj, "externalDocs");
510
567
  if (!isObject(docs)) return void 0;
@@ -515,6 +572,11 @@ function getExternalDocs(obj) {
515
572
  description: getString(docs, "description")
516
573
  };
517
574
  }
575
+ /**
576
+ * Read the optional `xml` keyword on a JSON Schema object into an
577
+ * {@link XmlInfo} record describing how the field is serialised in an
578
+ * XML payload. Returns `undefined` when absent or malformed.
579
+ */
518
580
  function getXmlInfo(schema) {
519
581
  const xml = getProperty(schema, "xml");
520
582
  if (!isObject(xml)) return void 0;
@@ -526,6 +588,11 @@ function getXmlInfo(schema) {
526
588
  wrapped: getProperty(xml, "wrapped") === true
527
589
  };
528
590
  }
591
+ /**
592
+ * List the OpenAPI callback definitions declared on a single
593
+ * operation. Each entry carries the callback name and the operations
594
+ * declared on its Path Item Object.
595
+ */
529
596
  function listCallbacks(parsed, path, method, diagnostics) {
530
597
  const operation = getProperty(lookupPathItem(parsed, path), method);
531
598
  if (!isObject(operation)) return [];
@@ -559,6 +626,11 @@ function listCallbacks(parsed, path, method, diagnostics) {
559
626
  }
560
627
  return result;
561
628
  }
629
+ /**
630
+ * List the OpenAPI link definitions declared on a specific response of
631
+ * a single operation, returning each link's parsed
632
+ * {@link LinkInfo} entry.
633
+ */
562
634
  function getLinks(parsed, path, method, statusCode, diagnostics) {
563
635
  const response = getProperty(getProperty(getProperty(lookupPathItem(parsed, path), method), "responses"), statusCode);
564
636
  if (!isObject(response)) return [];
@@ -1,4 +1,4 @@
1
- import { i as DiagnosticsOptions } from "../diagnostics-Cbwak-ZX.mjs";
1
+ import { i as DiagnosticsOptions } from "../diagnostics-ByEzkjrA.mjs";
2
2
  import { OpenApiDocument, OperationInfo, ParameterInfo, ResponseInfo, getRequestBody } from "./parser.mjs";
3
3
 
4
4
  //#region src/openapi/resolve.d.ts
@@ -58,6 +58,12 @@ interface PathItemInfo {
58
58
  summary: string | undefined;
59
59
  description: string | undefined;
60
60
  }
61
+ /**
62
+ * Aggregate view of a single OpenAPI operation: the operation itself,
63
+ * its Path Item Object context, merged parameters, request body, and
64
+ * responses. Produced by {@link resolveOperation} /
65
+ * {@link resolveOperationFromParsed} for rendering and inspection.
66
+ */
61
67
  interface ResolvedOperation {
62
68
  operation: OperationInfo;
63
69
  pathItem: PathItemInfo;
@@ -1,12 +1,12 @@
1
- import { d as FieldOverrides, j as WalkedField, u as FieldOverride, w as SchemaMeta } from "../types-BTB73MB8.mjs";
2
- import { t as Diagnostic } from "../diagnostics-Cbwak-ZX.mjs";
3
- import { i as SchemaIoSide } from "../adapter-DqlAnZ_w.mjs";
4
- import { t as SchemaError } from "../errors-DQSIK4n1.mjs";
5
- import { l as RenderProps, r as ComponentResolver } from "../renderer-Ul9taFYp.mjs";
1
+ import { d as FieldOverrides, j as WalkedField, u as FieldOverride, w as SchemaMeta } from "../types-C2Ay1FEh.mjs";
2
+ import { t as Diagnostic } from "../diagnostics-ByEzkjrA.mjs";
3
+ import { i as SchemaIoSide } from "../adapter-DcWi4XXn.mjs";
4
+ import { t as SchemaError } from "../errors-D8JndRwI.mjs";
5
+ import { l as RenderProps, r as ComponentResolver } from "../renderer-OaOz-n6-.mjs";
6
6
  import { FromJSONSchema, FromJSONSchemaMode, IsSwagger2Doc, PathOfType, RejectUnrepresentableZod, ResolveOpenAPIRef, TypeAtPath, __SchemaInferenceFellBack } from "../core/typeInference.mjs";
7
7
  import { z } from "zod";
8
- import { ReactNode } from "react";
9
8
  import * as _$react_jsx_runtime0 from "react/jsx-runtime";
9
+ import { ReactNode } from "react";
10
10
 
11
11
  //#region src/react/SchemaComponent.d.ts
12
12
  /**
@@ -20,6 +20,27 @@ import * as _$react_jsx_runtime0 from "react/jsx-runtime";
20
20
  * Resolution order: instance → context → global → resolver → headless.
21
21
  */
22
22
  type WidgetMap = ReadonlyMap<string, (props: RenderProps) => unknown>;
23
+ /**
24
+ * Provide a theme resolver and scoped widgets to every `<SchemaComponent>`
25
+ * and `<SchemaView>` rendered inside the subtree.
26
+ *
27
+ * Wrap an application (or a region of it) with `<SchemaProvider>` so a
28
+ * single theme — typically one of the bundled adapters
29
+ * (`shadcnResolver`, `muiResolver`, `mantineResolver`, `radixResolver`)
30
+ * or a custom one — drives every schema render. Without a provider,
31
+ * schema-components fall back to the headless HTML renderer.
32
+ *
33
+ * @group Components
34
+ * @example
35
+ * ```tsx
36
+ * import { SchemaProvider } from "schema-components/react/SchemaComponent";
37
+ * import { shadcnResolver } from "schema-components/themes/shadcn";
38
+ *
39
+ * <SchemaProvider resolver={shadcnResolver}>
40
+ * <SchemaComponent schema={userSchema} value={user} onChange={setUser} />
41
+ * </SchemaProvider>
42
+ * ```
43
+ */
23
44
  declare function SchemaProvider({
24
45
  resolver,
25
46
  widgets,
@@ -95,6 +116,15 @@ type InferredInputValue<T, Ref extends string | undefined = undefined, P extends
95
116
  * underlying helpers.
96
117
  */
97
118
  type InferredValue<T, Ref extends string | undefined = undefined, P extends string | undefined = undefined, Mode extends SchemaIoSide = "output"> = NarrowAtPath<InferSchemaValue<T, Ref, Mode>, P>;
119
+ /**
120
+ * Props accepted by {@link SchemaComponent}.
121
+ *
122
+ * The generic parameters carry the inferred schema shape through to
123
+ * `value`, `onChange`, and `fields` so a typed `schema` prop drives
124
+ * typed props on the rest of the component.
125
+ *
126
+ * @group Components
127
+ */
98
128
  interface SchemaComponentProps<T = unknown, Ref extends string | undefined = undefined, P extends string | undefined = undefined, Mode extends SchemaIoSide = "output"> {
99
129
  /**
100
130
  * Zod schema, JSON Schema object, or OpenAPI document.
@@ -206,6 +236,29 @@ interface SchemaComponentProps<T = unknown, Ref extends string | undefined = und
206
236
  */
207
237
  idPrefix?: string;
208
238
  }
239
+ /**
240
+ * Render an editable (or read-only) UI from a Zod schema, JSON Schema, or
241
+ * OpenAPI document.
242
+ *
243
+ * Auto-detects the input format, normalises to JSON Schema via the
244
+ * adapter, walks the JSON Schema tree, and delegates per-field rendering
245
+ * to the {@link ComponentResolver} supplied via {@link SchemaProvider} —
246
+ * falling back to a headless HTML renderer when no provider is present.
247
+ *
248
+ * Pass `readOnly` to render a presentational view instead of inputs, or
249
+ * wrap with `<SchemaProvider resolver={…}>` to swap the theme.
250
+ *
251
+ * @group Components
252
+ * @example
253
+ * ```tsx
254
+ * import { z } from "zod";
255
+ * import { SchemaComponent } from "schema-components/react/SchemaComponent";
256
+ *
257
+ * const userSchema = z.object({ name: z.string(), email: z.email() });
258
+ *
259
+ * <SchemaComponent schema={userSchema} value={user} onChange={setUser} />
260
+ * ```
261
+ */
209
262
  declare function SchemaComponent<T = unknown, Ref extends string | undefined = undefined, P extends string | undefined = undefined, Mode extends SchemaIoSide = "output">(props: SchemaComponentProps<T, Ref, P, Mode>): ReactNode;
210
263
  /**
211
264
  * Append a child path suffix to a parent path. When the suffix is omitted
@@ -225,11 +278,26 @@ declare function joinPath(parent: string, suffix: string | undefined): string;
225
278
  * with a single hyphen and trim leading/trailing hyphens.
226
279
  */
227
280
  declare function sanitisePrefix(value: string): string;
281
+ /**
282
+ * Render a single walked field through the resolved widget /
283
+ * resolver / headless pipeline. Used internally by
284
+ * {@link SchemaComponent} and {@link SchemaField}, exported so other
285
+ * React-side components (e.g. the OpenAPI renderers) can dispatch
286
+ * into the same fallback chain.
287
+ */
228
288
  declare function renderField(tree: WalkedField, value: unknown, onChange: (v: unknown) => void, userResolver: ComponentResolver | undefined, renderChild: (tree: WalkedField, value: unknown, onChange: (v: unknown) => void, pathSuffix?: string) => ReactNode, path: string, instanceWidgets?: WidgetMap, contextWidgets?: WidgetMap, depth?: number): ReactNode;
229
289
  /**
230
290
  * Infer the schema's output type for SchemaField path inference.
231
291
  */
232
292
  type InferSchemaType<T> = T extends z.ZodType ? z.infer<T> : T extends object ? unknown extends FromJSONSchema<T> ? unknown : FromJSONSchema<T> : unknown;
293
+ /**
294
+ * Props accepted by {@link SchemaField}. The generic `P` constrains
295
+ * `path` to dot-paths reachable through the schema's inferred value
296
+ * type — typed schemas get autocomplete; runtime schemas fall back to
297
+ * `string`.
298
+ *
299
+ * @group Components
300
+ */
233
301
  interface SchemaFieldProps<T = unknown, Ref extends string | undefined = undefined, P extends string = PathOfType<InferSchemaType<T>> | (string extends PathOfType<InferSchemaType<T>> ? string : never)> {
234
302
  /**
235
303
  * Dot-separated path to the field (e.g. "address.city").
@@ -254,6 +322,16 @@ interface SchemaFieldProps<T = unknown, Ref extends string | undefined = undefin
254
322
  validate?: boolean;
255
323
  onValidationError?: (error: unknown) => void;
256
324
  }
325
+ /**
326
+ * Render a single field from a schema by dot-separated `path`.
327
+ *
328
+ * Walks the full schema tree and resolves the field at the supplied
329
+ * `path`, then renders only that field through the same resolver
330
+ * pipeline as {@link SchemaComponent}. Useful for embedding individual
331
+ * fields inside bespoke layouts.
332
+ *
333
+ * @group Components
334
+ */
257
335
  declare function SchemaField<T = unknown, Ref extends string | undefined = undefined, P extends string = PathOfType<InferSchemaType<T>> | (string extends PathOfType<InferSchemaType<T>> ? string : never)>({
258
336
  path,
259
337
  schema: schemaInput,
@@ -8,8 +8,8 @@ import { walk } from "../core/walker.mjs";
8
8
  import { headlessResolver } from "./headless.mjs";
9
9
  import { resolvePath, resolveValue, setNestedValue } from "./fieldPath.mjs";
10
10
  import { z } from "zod";
11
- import { createContext, isValidElement, useCallback, useContext, useId, useMemo } from "react";
12
11
  import { jsx, jsxs } from "react/jsx-runtime";
12
+ import { createContext, isValidElement, useCallback, useContext, useId, useMemo } from "react";
13
13
  //#region src/react/SchemaComponent.tsx
14
14
  /**
15
15
  * <SchemaComponent> — renders UI from Zod, JSON Schema, or OpenAPI schemas.
@@ -26,6 +26,27 @@ import { jsx, jsxs } from "react/jsx-runtime";
26
26
  */
27
27
  const UserResolverContext = createContext(void 0);
28
28
  const WidgetsContext = createContext(void 0);
29
+ /**
30
+ * Provide a theme resolver and scoped widgets to every `<SchemaComponent>`
31
+ * and `<SchemaView>` rendered inside the subtree.
32
+ *
33
+ * Wrap an application (or a region of it) with `<SchemaProvider>` so a
34
+ * single theme — typically one of the bundled adapters
35
+ * (`shadcnResolver`, `muiResolver`, `mantineResolver`, `radixResolver`)
36
+ * or a custom one — drives every schema render. Without a provider,
37
+ * schema-components fall back to the headless HTML renderer.
38
+ *
39
+ * @group Components
40
+ * @example
41
+ * ```tsx
42
+ * import { SchemaProvider } from "schema-components/react/SchemaComponent";
43
+ * import { shadcnResolver } from "schema-components/themes/shadcn";
44
+ *
45
+ * <SchemaProvider resolver={shadcnResolver}>
46
+ * <SchemaComponent schema={userSchema} value={user} onChange={setUser} />
47
+ * </SchemaProvider>
48
+ * ```
49
+ */
29
50
  function SchemaProvider({ resolver, widgets, children }) {
30
51
  return /* @__PURE__ */ jsx(UserResolverContext.Provider, {
31
52
  value: resolver,
@@ -47,6 +68,29 @@ const globalWidgets = /* @__PURE__ */ new Map();
47
68
  function registerWidget(name, render) {
48
69
  globalWidgets.set(name, render);
49
70
  }
71
+ /**
72
+ * Render an editable (or read-only) UI from a Zod schema, JSON Schema, or
73
+ * OpenAPI document.
74
+ *
75
+ * Auto-detects the input format, normalises to JSON Schema via the
76
+ * adapter, walks the JSON Schema tree, and delegates per-field rendering
77
+ * to the {@link ComponentResolver} supplied via {@link SchemaProvider} —
78
+ * falling back to a headless HTML renderer when no provider is present.
79
+ *
80
+ * Pass `readOnly` to render a presentational view instead of inputs, or
81
+ * wrap with `<SchemaProvider resolver={…}>` to swap the theme.
82
+ *
83
+ * @group Components
84
+ * @example
85
+ * ```tsx
86
+ * import { z } from "zod";
87
+ * import { SchemaComponent } from "schema-components/react/SchemaComponent";
88
+ *
89
+ * const userSchema = z.object({ name: z.string(), email: z.email() });
90
+ *
91
+ * <SchemaComponent schema={userSchema} value={user} onChange={setUser} />
92
+ * ```
93
+ */
50
94
  function SchemaComponent(props) {
51
95
  const { schema: schemaInput, ref: refInput, io, value, onChange, validate, onValidationError, onError, onDiagnostic, strict, fields, meta: componentMeta, readOnly, writeOnly, description, widgets: instanceWidgets, idPrefix } = props;
52
96
  const userResolver = useContext(UserResolverContext);
@@ -220,6 +264,13 @@ function runValidation(zodSchema, jsonSchema, value, io, onDiagnostic) {
220
264
  }
221
265
  }
222
266
  }
267
+ /**
268
+ * Render a single walked field through the resolved widget /
269
+ * resolver / headless pipeline. Used internally by
270
+ * {@link SchemaComponent} and {@link SchemaField}, exported so other
271
+ * React-side components (e.g. the OpenAPI renderers) can dispatch
272
+ * into the same fallback chain.
273
+ */
223
274
  function renderField(tree, value, onChange, userResolver, renderChild, path, instanceWidgets, contextWidgets, depth = 0) {
224
275
  if (path.length === 0) throw new Error("renderField requires a non-empty path. Pass the root path (derived from `idPrefix` or `useId()`) for the root field, and use renderChild's pathSuffix to derive child paths.");
225
276
  if (depth >= 10) return /* @__PURE__ */ jsx("fieldset", { children: /* @__PURE__ */ jsxs("em", { children: [
@@ -255,6 +306,16 @@ function renderField(tree, value, onChange, userResolver, renderChild, path, ins
255
306
  if (value === void 0 || value === null) return /* @__PURE__ */ jsx("span", { children: "—" });
256
307
  return /* @__PURE__ */ jsx("span", { children: typeof value === "string" ? value : JSON.stringify(value) });
257
308
  }
309
+ /**
310
+ * Render a single field from a schema by dot-separated `path`.
311
+ *
312
+ * Walks the full schema tree and resolves the field at the supplied
313
+ * `path`, then renders only that field through the same resolver
314
+ * pipeline as {@link SchemaComponent}. Useful for embedding individual
315
+ * fields inside bespoke layouts.
316
+ *
317
+ * @group Components
318
+ */
258
319
  function SchemaField({ path, schema: schemaInput, ref: refInput, value, onChange, meta: fieldMeta, validate, onValidationError }) {
259
320
  const userResolver = useContext(UserResolverContext);
260
321
  const contextWidgets = useContext(WidgetsContext);
@@ -1,6 +1,11 @@
1
1
  import { Component, ReactNode } from "react";
2
2
 
3
3
  //#region src/react/SchemaErrorBoundary.d.ts
4
+ /**
5
+ * Props accepted by {@link SchemaErrorBoundary}.
6
+ *
7
+ * @group Components
8
+ */
4
9
  interface SchemaErrorBoundaryProps {
5
10
  /** Called with the caught error. Returns fallback ReactNode to render. */
6
11
  fallback: (error: Error, reset: () => void) => ReactNode;
@@ -10,10 +15,22 @@ interface ErrorBoundaryState {
10
15
  error: Error | undefined;
11
16
  }
12
17
  /**
13
- * React error boundary that catches schema rendering errors.
18
+ * React error boundary that catches rendering errors from
19
+ * `SchemaComponent`, theme adapters, and any descendant.
14
20
  *
15
21
  * Provides a `reset` callback that clears the error state, allowing
16
22
  * the children to re-render (e.g. after fixing a bad schema prop).
23
+ * Does not catch errors thrown from event handlers, async work, or
24
+ * server-side rendering — those paths must be handled by the host
25
+ * application.
26
+ *
27
+ * @group Components
28
+ * @example
29
+ * ```tsx
30
+ * <SchemaErrorBoundary fallback={(error) => <p>{error.message}</p>}>
31
+ * <SchemaComponent schema={userSchema} value={user} onChange={setUser} />
32
+ * </SchemaErrorBoundary>
33
+ * ```
17
34
  */
18
35
  declare class SchemaErrorBoundary extends Component<SchemaErrorBoundaryProps, ErrorBoundaryState> {
19
36
  state: ErrorBoundaryState;