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.
- package/dist/core/adapter.d.mts +10 -3
- package/dist/core/adapter.mjs +237 -31
- package/dist/core/constraints.d.mts +2 -2
- package/dist/core/constraints.mjs +0 -2
- package/dist/core/diagnostics.d.mts +1 -1
- package/dist/core/errors.d.mts +1 -1
- package/dist/core/errors.mjs +10 -8
- package/dist/core/fieldOrder.d.mts +1 -1
- package/dist/core/formats.d.mts +21 -14
- package/dist/core/formats.mjs +88 -4
- package/dist/core/merge.d.mts +11 -2
- package/dist/core/merge.mjs +11 -0
- package/dist/core/normalise.d.mts +9 -3
- package/dist/core/normalise.mjs +1 -1
- package/dist/core/openapi30.d.mts +24 -1
- package/dist/core/openapi30.mjs +2 -2
- package/dist/core/ref.d.mts +1 -1
- package/dist/core/ref.mjs +34 -9
- package/dist/core/renderer.d.mts +1 -1
- package/dist/core/swagger2.d.mts +1 -1
- package/dist/core/swagger2.mjs +1 -1
- package/dist/core/typeInference.d.mts +2 -2
- package/dist/core/types.d.mts +1 -1
- package/dist/core/uri.d.mts +41 -0
- package/dist/core/uri.mjs +76 -0
- package/dist/core/version.d.mts +2 -2
- package/dist/core/version.mjs +25 -1
- package/dist/core/walkBuilders.d.mts +13 -5
- package/dist/core/walkBuilders.mjs +11 -3
- package/dist/core/walker.d.mts +1 -1
- package/dist/core/walker.mjs +80 -26
- package/dist/{diagnostics-VgEKI_Ct.d.mts → diagnostics-CbBPsxSt.d.mts} +1 -1
- package/dist/{errors-CnGjT1cg.d.mts → errors-QEwOtQAA.d.mts} +8 -5
- package/dist/html/a11y.d.mts +2 -2
- package/dist/html/renderToHtml.d.mts +2 -2
- package/dist/html/renderToHtmlStream.d.mts +2 -2
- package/dist/html/renderers.d.mts +2 -2
- package/dist/html/renderers.mjs +9 -2
- package/dist/html/streamRenderers.d.mts +2 -2
- package/dist/{normalise-C0ofw3W6.mjs → normalise-DaSrnr8g.mjs} +574 -40
- 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/ApiSecurity.mjs +113 -7
- package/dist/openapi/bundle.mjs +2 -0
- package/dist/openapi/components.d.mts +32 -10
- package/dist/openapi/components.mjs +37 -16
- package/dist/openapi/parser.d.mts +1 -1
- package/dist/openapi/parser.mjs +41 -4
- package/dist/openapi/resolve.d.mts +70 -9
- package/dist/openapi/resolve.mjs +124 -24
- package/dist/react/SchemaComponent.d.mts +21 -9
- package/dist/react/SchemaComponent.mjs +32 -4
- package/dist/react/SchemaView.d.mts +3 -3
- package/dist/react/fieldPath.d.mts +1 -1
- package/dist/react/headless.d.mts +1 -1
- package/dist/react/headlessRenderers.d.mts +2 -2
- package/dist/react/headlessRenderers.mjs +18 -6
- package/dist/{ref-Bb43ZURY.d.mts → ref-si8ViYun.d.mts} +7 -2
- package/dist/{renderer-BQqiXUYP.d.mts → renderer-DI6ZYf7a.d.mts} +1 -1
- 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-Bxw3NOG1.d.mts +647 -0
- package/dist/{types-D_5ST7SS.d.mts → types-BnxPEElk.d.mts} +18 -2
- package/dist/{version-XNH7PRGP.d.mts → version-D-u7aMfy.d.mts} +36 -1
- package/package.json +1 -1
- 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
|
/**
|
package/dist/html/a11y.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { M as WalkedField } from "../types-
|
|
2
|
-
import { t as AllConstraints } from "../renderer-
|
|
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-
|
|
2
|
-
import { o as HtmlResolver } from "../renderer-
|
|
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-
|
|
2
|
-
import { o as HtmlResolver } from "../renderer-
|
|
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-
|
|
2
|
-
import { o as HtmlResolver } from "../renderer-
|
|
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;
|
package/dist/html/renderers.mjs
CHANGED
|
@@ -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-
|
|
2
|
-
import { o as HtmlResolver } from "../renderer-
|
|
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
|