schema-components 1.19.0 → 1.21.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 (70) hide show
  1. package/dist/core/adapter.d.mts +10 -3
  2. package/dist/core/adapter.mjs +237 -31
  3. package/dist/core/constraints.d.mts +2 -2
  4. package/dist/core/constraints.mjs +0 -2
  5. package/dist/core/diagnostics.d.mts +1 -1
  6. package/dist/core/errors.d.mts +1 -1
  7. package/dist/core/errors.mjs +10 -8
  8. package/dist/core/fieldOrder.d.mts +1 -1
  9. package/dist/core/formats.d.mts +21 -14
  10. package/dist/core/formats.mjs +88 -4
  11. package/dist/core/merge.d.mts +11 -2
  12. package/dist/core/merge.mjs +11 -0
  13. package/dist/core/normalise.d.mts +9 -3
  14. package/dist/core/normalise.mjs +1 -1
  15. package/dist/core/openapi30.d.mts +24 -1
  16. package/dist/core/openapi30.mjs +2 -2
  17. package/dist/core/ref.d.mts +1 -1
  18. package/dist/core/ref.mjs +34 -9
  19. package/dist/core/renderer.d.mts +1 -1
  20. package/dist/core/swagger2.d.mts +1 -1
  21. package/dist/core/swagger2.mjs +1 -1
  22. package/dist/core/typeInference.d.mts +2 -2
  23. package/dist/core/types.d.mts +1 -1
  24. package/dist/core/uri.d.mts +41 -0
  25. package/dist/core/uri.mjs +76 -0
  26. package/dist/core/version.d.mts +2 -2
  27. package/dist/core/version.mjs +25 -1
  28. package/dist/core/walkBuilders.d.mts +13 -5
  29. package/dist/core/walkBuilders.mjs +11 -3
  30. package/dist/core/walker.d.mts +1 -1
  31. package/dist/core/walker.mjs +80 -26
  32. package/dist/{diagnostics-VgEKI_Ct.d.mts → diagnostics-CbBPsxSt.d.mts} +1 -1
  33. package/dist/{errors-CnGjT1cg.d.mts → errors-QEwOtQAA.d.mts} +8 -5
  34. package/dist/html/a11y.d.mts +2 -2
  35. package/dist/html/renderToHtml.d.mts +2 -2
  36. package/dist/html/renderToHtmlStream.d.mts +2 -2
  37. package/dist/html/renderers.d.mts +2 -2
  38. package/dist/html/renderers.mjs +9 -2
  39. package/dist/html/streamRenderers.d.mts +2 -2
  40. package/dist/{normalise-C0ofw3W6.mjs → normalise-DaSrnr8g.mjs} +574 -40
  41. package/dist/openapi/ApiCallbacks.d.mts +1 -1
  42. package/dist/openapi/ApiLinks.d.mts +1 -1
  43. package/dist/openapi/ApiResponseHeaders.d.mts +1 -1
  44. package/dist/openapi/ApiSecurity.d.mts +1 -1
  45. package/dist/openapi/ApiSecurity.mjs +113 -7
  46. package/dist/openapi/bundle.mjs +2 -0
  47. package/dist/openapi/components.d.mts +32 -10
  48. package/dist/openapi/components.mjs +37 -16
  49. package/dist/openapi/parser.d.mts +1 -1
  50. package/dist/openapi/parser.mjs +41 -4
  51. package/dist/openapi/resolve.d.mts +70 -9
  52. package/dist/openapi/resolve.mjs +124 -24
  53. package/dist/react/SchemaComponent.d.mts +21 -9
  54. package/dist/react/SchemaComponent.mjs +32 -4
  55. package/dist/react/SchemaView.d.mts +3 -3
  56. package/dist/react/fieldPath.d.mts +1 -1
  57. package/dist/react/headless.d.mts +1 -1
  58. package/dist/react/headlessRenderers.d.mts +2 -2
  59. package/dist/react/headlessRenderers.mjs +18 -6
  60. package/dist/{ref-Bb43ZURY.d.mts → ref-si8ViYun.d.mts} +7 -2
  61. package/dist/{renderer-BQqiXUYP.d.mts → renderer-DI6ZYf7a.d.mts} +1 -1
  62. package/dist/themes/mantine.d.mts +1 -1
  63. package/dist/themes/mui.d.mts +1 -1
  64. package/dist/themes/radix.d.mts +1 -1
  65. package/dist/themes/shadcn.d.mts +1 -1
  66. package/dist/typeInference-Bxw3NOG1.d.mts +647 -0
  67. package/dist/{types-D_5ST7SS.d.mts → types-BnxPEElk.d.mts} +18 -2
  68. package/dist/{version-XNH7PRGP.d.mts → version-D-u7aMfy.d.mts} +36 -1
  69. package/package.json +1 -1
  70. package/dist/typeInference-5JiqIZ8t.d.mts +0 -388
@@ -14,11 +14,16 @@
14
14
  /**
15
15
  * Base class for all schema-components errors.
16
16
  * Catch this to handle any library error uniformly.
17
+ *
18
+ * Forwards the optional `cause` to the native ES2022 `Error` constructor so
19
+ * `error.cause` is wired up by the runtime and rendered correctly by
20
+ * `util.inspect` ("Caused by: ..."). Subclasses that need a typed `cause`
21
+ * field still get it via the platform's own `Error.cause` getter.
17
22
  */
18
23
  declare class SchemaError extends Error {
19
24
  /** The schema input that caused the error. */
20
25
  readonly schema: unknown;
21
- constructor(message: string, schema: unknown);
26
+ constructor(message: string, schema: unknown, cause?: unknown);
22
27
  }
23
28
  /**
24
29
  * The adapter failed to convert the input schema to JSON Schema.
@@ -27,13 +32,13 @@ declare class SchemaError extends Error {
27
32
  * JSON Schema, missing OpenAPI ref, unsupported ref format.
28
33
  */
29
34
  declare class SchemaNormalisationError extends SchemaError {
30
- readonly kind: "invalid-zod" | "zod3-unsupported" | "zod-transform-unsupported" | "zod-type-unrepresentable" | "zod-conversion-failed" | "invalid-json-schema" | "openapi-missing-ref" | "openapi-invalid" | "unknown";
35
+ readonly kind: "invalid-zod" | "zod3-unsupported" | "zod-transform-unsupported" | "zod-type-unrepresentable" | "zod-conversion-failed" | "zod-conversion-bug" | "zod-cycle-detected" | "zod-duplicate-id" | "invalid-json-schema" | "openapi-missing-ref" | "openapi-invalid" | "unknown";
31
36
  /**
32
37
  * For `zod-type-unrepresentable`, the offending Zod type name
33
38
  * (e.g. "bigint", "date", "map", "set"). `undefined` for other kinds.
34
39
  */
35
40
  readonly zodType: string | undefined;
36
- constructor(message: string, schema: unknown, kind: SchemaNormalisationError["kind"], zodType?: string);
41
+ constructor(message: string, schema: unknown, kind: SchemaNormalisationError["kind"], zodType?: string, cause?: unknown);
37
42
  }
38
43
  /**
39
44
  * A theme adapter's render function threw during rendering.
@@ -43,8 +48,6 @@ declare class SchemaNormalisationError extends SchemaError {
43
48
  declare class SchemaRenderError extends SchemaError {
44
49
  /** The schema type being rendered when the error occurred. */
45
50
  readonly schemaType: string;
46
- /** The original error from the render function. */
47
- readonly cause: unknown;
48
51
  constructor(message: string, schema: unknown, schemaType: string, cause: unknown);
49
52
  }
50
53
  /**
@@ -1,5 +1,5 @@
1
- import { M as WalkedField } from "../types-D_5ST7SS.mjs";
2
- import { t as AllConstraints } from "../renderer-BQqiXUYP.mjs";
1
+ import { M as WalkedField } from "../types-BnxPEElk.mjs";
2
+ import { t as AllConstraints } from "../renderer-DI6ZYf7a.mjs";
3
3
  import { HtmlAttributes, HtmlNode } from "./html.mjs";
4
4
 
5
5
  //#region src/html/a11y.d.ts
@@ -1,5 +1,5 @@
1
- import { T as SchemaMeta } from "../types-D_5ST7SS.mjs";
2
- import { o as HtmlResolver } from "../renderer-BQqiXUYP.mjs";
1
+ import { T as SchemaMeta } from "../types-BnxPEElk.mjs";
2
+ import { o as HtmlResolver } from "../renderer-DI6ZYf7a.mjs";
3
3
 
4
4
  //#region src/html/renderToHtml.d.ts
5
5
  interface RenderToHtmlOptions {
@@ -1,5 +1,5 @@
1
- import { T as SchemaMeta } from "../types-D_5ST7SS.mjs";
2
- import { o as HtmlResolver } from "../renderer-BQqiXUYP.mjs";
1
+ import { T as SchemaMeta } from "../types-BnxPEElk.mjs";
2
+ import { o as HtmlResolver } from "../renderer-DI6ZYf7a.mjs";
3
3
 
4
4
  //#region src/html/renderToHtmlStream.d.ts
5
5
  interface StreamRenderOptions {
@@ -1,5 +1,5 @@
1
- import { M as WalkedField } from "../types-D_5ST7SS.mjs";
2
- import { o as HtmlResolver } from "../renderer-BQqiXUYP.mjs";
1
+ import { M as WalkedField } from "../types-BnxPEElk.mjs";
2
+ import { o as HtmlResolver } from "../renderer-DI6ZYf7a.mjs";
3
3
 
4
4
  //#region src/html/renderers.d.ts
5
5
  declare function dateInputType(format: string | undefined): string | undefined;
@@ -1,3 +1,4 @@
1
+ import { isSafeHyperlink, isSafeMailtoAddress } from "../core/uri.mjs";
1
2
  import { sortFieldsByOrder } from "../core/fieldOrder.mjs";
2
3
  import { h, raw, serialize } from "./html.mjs";
3
4
  import { ariaDescribedByAttrs, ariaLabelAttrs, ariaReadonlyAttrs, ariaRequiredAttrs, buildHintElement, buildInputId, requiredIndicator } from "./a11y.mjs";
@@ -26,12 +27,12 @@ function renderStringReadOnly(props) {
26
27
  ...ariaReadonlyAttrs()
27
28
  }, "—");
28
29
  const format = props.constraints.format;
29
- if (format === "email") return h("a", {
30
+ if (format === "email" && isSafeMailtoAddress(strValue)) return h("a", {
30
31
  class: "sc-value",
31
32
  href: `mailto:${strValue}`,
32
33
  ...ariaReadonlyAttrs()
33
34
  }, strValue);
34
- if (format === "uri" || format === "url") return h("a", {
35
+ if ((format === "uri" || format === "url") && isSafeHyperlink(strValue)) return h("a", {
35
36
  class: "sc-value",
36
37
  href: strValue,
37
38
  ...ariaReadonlyAttrs()
@@ -356,6 +357,7 @@ function renderTupleHtml(props) {
356
357
  if (props.tree.type !== "tuple") return renderUnknownHtml(props);
357
358
  const arr = Array.isArray(props.value) ? props.value : [];
358
359
  const prefixItems = props.tree.prefixItems;
360
+ const restItems = props.tree.restItems;
359
361
  const children = [];
360
362
  for (let i = 0; i < prefixItems.length; i++) {
361
363
  const itemValue = arr[i];
@@ -364,6 +366,11 @@ function renderTupleHtml(props) {
364
366
  const childHtml = props.renderChild(element, itemValue, `[${String(i)}]`);
365
367
  children.push(h("div", { class: "sc-tuple-item" }, h("span", { class: "sc-tuple-index" }, String(i)), raw(childHtml)));
366
368
  }
369
+ if (restItems !== void 0) for (let i = prefixItems.length; i < arr.length; i++) {
370
+ const itemValue = arr[i];
371
+ const childHtml = props.renderChild(restItems, itemValue, `[${String(i)}]`);
372
+ children.push(h("div", { class: "sc-tuple-item sc-tuple-rest" }, h("span", { class: "sc-tuple-index" }, String(i)), raw(childHtml)));
373
+ }
367
374
  return serialize(h("div", { class: "sc-tuple" }, ...children));
368
375
  }
369
376
  function renderConditionalHtml(props) {
@@ -1,5 +1,5 @@
1
- import { M as WalkedField } from "../types-D_5ST7SS.mjs";
2
- import { o as HtmlResolver } from "../renderer-BQqiXUYP.mjs";
1
+ import { M as WalkedField } from "../types-BnxPEElk.mjs";
2
+ import { o as HtmlResolver } from "../renderer-DI6ZYf7a.mjs";
3
3
  import { HtmlElement } from "./html.mjs";
4
4
 
5
5
  //#region src/html/streamRenderers.d.ts