@stryke/zod 0.2.0 → 0.2.1
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/CHANGELOG.md +6 -0
- package/dist/index.d.cts +4 -4
- package/dist/index.d.mts +4 -4
- package/dist/{is-zod-type-CDtbhw8L.d.mts → is-zod-type-C-QXMMqm.d.cts} +3 -3
- package/dist/{is-zod-type-CDtbhw8L.d.mts.map → is-zod-type-C-QXMMqm.d.cts.map} +1 -1
- package/dist/{is-zod-type-x0dit7lA.d.cts → is-zod-type-QkJykM8H.d.mts} +3 -3
- package/dist/{is-zod-type-x0dit7lA.d.cts.map → is-zod-type-QkJykM8H.d.mts.map} +1 -1
- package/dist/is-zod-type.d.cts +1 -1
- package/dist/is-zod-type.d.mts +2 -2
- package/dist/schema-B6usLZOz.mjs.map +1 -1
- package/dist/schema-D72c2GKP.d.cts +187 -0
- package/dist/schema-D72c2GKP.d.cts.map +1 -0
- package/dist/schema-TGJB_m82.d.mts +189 -0
- package/dist/schema-TGJB_m82.d.mts.map +1 -0
- package/dist/schema.d.cts +1 -1
- package/dist/schema.d.mts +2 -2
- package/dist/types-DWWjtQA0.d.mts +8 -0
- package/dist/types-DWWjtQA0.d.mts.map +1 -0
- package/dist/types-i4I6mfMQ.d.cts +8 -0
- package/dist/types-i4I6mfMQ.d.cts.map +1 -0
- package/dist/types.d.cts +2 -2
- package/dist/types.d.mts +2 -2
- package/package.json +15 -11
- package/dist/schema-DQPkBDAQ.d.mts +0 -32
- package/dist/schema-DQPkBDAQ.d.mts.map +0 -1
- package/dist/schema-s8jVY_-l.d.cts +0 -32
- package/dist/schema-s8jVY_-l.d.cts.map +0 -1
- package/dist/types-4nTrnOUu.d.cts +0 -20
- package/dist/types-4nTrnOUu.d.cts.map +0 -1
- package/dist/types-UlEWkGXF.d.mts +0 -20
- package/dist/types-UlEWkGXF.d.mts.map +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,12 @@
|
|
|
2
2
|
|
|
3
3
|
# Changelog for Stryke - Zod
|
|
4
4
|
|
|
5
|
+
## [0.2.0](https://github.com/storm-software/stryke/releases/tag/zod%400.2.0) (03/02/2026)
|
|
6
|
+
|
|
7
|
+
### Features
|
|
8
|
+
|
|
9
|
+
- **zod:** Added the `extractJsonSchema7` convenience wrapper function ([7307bb68](https://github.com/storm-software/stryke/commit/7307bb68))
|
|
10
|
+
|
|
5
11
|
## [0.1.1](https://github.com/storm-software/stryke/releases/tag/zod%400.1.1) (03/02/2026)
|
|
6
12
|
|
|
7
13
|
### Miscellaneous
|
package/dist/index.d.cts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { n as isZod4Type, r as isZodType, t as isZod3Type } from "./is-zod-type-
|
|
3
|
-
import { n as extractJsonSchema7, t as extractJsonSchema } from "./schema-
|
|
4
|
-
export { ZodType,
|
|
1
|
+
import { t as ZodType } from "./types-i4I6mfMQ.cjs";
|
|
2
|
+
import { n as isZod4Type, r as isZodType, t as isZod3Type } from "./is-zod-type-C-QXMMqm.cjs";
|
|
3
|
+
import { n as extractJsonSchema7, t as extractJsonSchema } from "./schema-D72c2GKP.cjs";
|
|
4
|
+
export { ZodType, extractJsonSchema, extractJsonSchema7, isZod3Type, isZod4Type, isZodType };
|
package/dist/index.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { n as isZod4Type, r as isZodType, t as isZod3Type } from "./is-zod-type-
|
|
3
|
-
import { n as extractJsonSchema7, t as extractJsonSchema } from "./schema-
|
|
4
|
-
export { ZodType,
|
|
1
|
+
import { t as ZodType } from "./types-DWWjtQA0.mjs";
|
|
2
|
+
import { n as isZod4Type, r as isZodType, t as isZod3Type } from "./is-zod-type-QkJykM8H.mjs";
|
|
3
|
+
import { n as extractJsonSchema7, t as extractJsonSchema } from "./schema-TGJB_m82.mjs";
|
|
4
|
+
export { ZodType, extractJsonSchema, extractJsonSchema7, isZod3Type, isZod4Type, isZodType };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { t as ZodType } from "./types-
|
|
2
|
-
import * as z4 from "zod/v4/core";
|
|
1
|
+
import { t as ZodType } from "./types-i4I6mfMQ.cjs";
|
|
3
2
|
import * as z3 from "zod/v3";
|
|
3
|
+
import * as z4 from "zod/v4/core";
|
|
4
4
|
|
|
5
5
|
//#region src/is-zod-type.d.ts
|
|
6
6
|
|
|
@@ -27,4 +27,4 @@ declare function isZod4Type(type: unknown): type is z4.$ZodType;
|
|
|
27
27
|
declare function isZodType(type: unknown): type is ZodType;
|
|
28
28
|
//#endregion
|
|
29
29
|
export { isZod4Type as n, isZodType as r, isZod3Type as t };
|
|
30
|
-
//# sourceMappingURL=is-zod-type-
|
|
30
|
+
//# sourceMappingURL=is-zod-type-C-QXMMqm.d.cts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"is-zod-type-
|
|
1
|
+
{"version":3,"file":"is-zod-type-C-QXMMqm.d.cts","names":[],"sources":["../src/is-zod-type.ts"],"sourcesContent":[],"mappings":";;;;;;;;AA8BA;AAcA;AAYA;;iBA1BgB,UAAA,yBAAmC,EAAA,CAAG;;;;;;;iBActC,UAAA,yBAAmC,EAAA,CAAG;;;;;;;iBAYtC,SAAA,yBAAkC"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { t as ZodType } from "./types-
|
|
2
|
-
import * as z3 from "zod/v3";
|
|
1
|
+
import { t as ZodType } from "./types-DWWjtQA0.mjs";
|
|
3
2
|
import * as z4 from "zod/v4/core";
|
|
3
|
+
import * as z3 from "zod/v3";
|
|
4
4
|
|
|
5
5
|
//#region src/is-zod-type.d.ts
|
|
6
6
|
|
|
@@ -27,4 +27,4 @@ declare function isZod4Type(type: unknown): type is z4.$ZodType;
|
|
|
27
27
|
declare function isZodType(type: unknown): type is ZodType;
|
|
28
28
|
//#endregion
|
|
29
29
|
export { isZod4Type as n, isZodType as r, isZod3Type as t };
|
|
30
|
-
//# sourceMappingURL=is-zod-type-
|
|
30
|
+
//# sourceMappingURL=is-zod-type-QkJykM8H.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"is-zod-type-
|
|
1
|
+
{"version":3,"file":"is-zod-type-QkJykM8H.d.mts","names":[],"sources":["../src/is-zod-type.ts"],"sourcesContent":[],"mappings":";;;;;;;;AA8BA;AAcA;AAYA;;iBA1BgB,UAAA,yBAAmC,EAAA,CAAG;;;;;;;iBActC,UAAA,yBAAmC,EAAA,CAAG;;;;;;;iBAYtC,SAAA,yBAAkC"}
|
package/dist/is-zod-type.d.cts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { n as isZod4Type, r as isZodType, t as isZod3Type } from "./is-zod-type-
|
|
1
|
+
import { n as isZod4Type, r as isZodType, t as isZod3Type } from "./is-zod-type-C-QXMMqm.cjs";
|
|
2
2
|
export { isZod3Type, isZod4Type, isZodType };
|
package/dist/is-zod-type.d.mts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import "./types-
|
|
2
|
-
import { n as isZod4Type, r as isZodType, t as isZod3Type } from "./is-zod-type-
|
|
1
|
+
import "./types-DWWjtQA0.mjs";
|
|
2
|
+
import { n as isZod4Type, r as isZodType, t as isZod3Type } from "./is-zod-type-QkJykM8H.mjs";
|
|
3
3
|
export { isZod3Type, isZod4Type, isZodType };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schema-B6usLZOz.mjs","names":[],"sources":["../src/schema.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Stryke\n\n This code was released as part of the Stryke project. Stryke\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/stryke.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/stryke\n Documentation: https://docs.stormsoftware.com/projects/stryke\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport type { JsonSchema7Type } from \"
|
|
1
|
+
{"version":3,"file":"schema-B6usLZOz.mjs","names":[],"sources":["../src/schema.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Stryke\n\n This code was released as part of the Stryke project. Stryke\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/stryke.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/stryke\n Documentation: https://docs.stormsoftware.com/projects/stryke\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport type { JsonSchema7Type } from \"@stryke/json\";\nimport { zodToJsonSchema } from \"zod-to-json-schema\";\nimport * as z4 from \"zod/v4/core\";\nimport { isZod3Type, isZod4Type } from \"./is-zod-type\";\nimport type { ZodType } from \"./types\";\n\n/**\n * Extracts a JSON Schema from a given Zod schema, supporting both version 3 and version 4 of Zod.\n *\n * @param type - The Zod schema to extract the JSON Schema from. Can be either a Zod v3 or v4 schema.\n * @param target - The JSON Schema draft version to target. Defaults to \"draft-07\".\n * @returns The extracted JSON Schema.\n */\nexport function extractJsonSchema(\n type: ZodType,\n target: \"draft-07\" | \"draft-2020-12\" = \"draft-07\"\n) {\n if (isZod3Type(type)) {\n const result = zodToJsonSchema(type, {\n $refStrategy: \"root\",\n definitionPath: \"$defs\",\n target: target === \"draft-07\" ? \"jsonSchema7\" : \"jsonSchema2019-09\"\n });\n if (!result) {\n throw new Error(\"Failed to extract JSON Schema from Zod v3 schema\");\n }\n\n return result;\n } else if (isZod4Type(type)) {\n return z4.toJSONSchema(type, {\n target: target === \"draft-07\" ? \"draft-07\" : \"draft-2020-12\",\n // eslint-disable-next-line @cspell/spellchecker\n unrepresentable: \"any\",\n reused: \"ref\"\n });\n } else {\n throw new Error(\"Unsupported Zod schema version\");\n }\n}\n\n/**\n * Extracts a JSON Schema (draft-07) from a given Zod schema, supporting both version 3 and version 4 of Zod.\n *\n * @remarks\n * This function is a convenience wrapper around `extractJsonSchema` that defaults to targeting the JSON Schema draft-07 specification.\n *\n * @param type - The Zod schema to extract the JSON Schema from. Can be either a Zod v3 or v4 schema.\n * @returns The extracted JSON Schema.\n */\nexport function extractJsonSchema7(type: ZodType) {\n return extractJsonSchema(type, \"draft-07\") as JsonSchema7Type;\n}\n"],"mappings":";;;;;;;;;;;;AA+BA,SAAgB,kBACd,MACA,SAAuC,YACvC;AACA,KAAI,WAAW,KAAK,EAAE;EACpB,MAAM,SAAS,gBAAgB,MAAM;GACnC,cAAc;GACd,gBAAgB;GAChB,QAAQ,WAAW,aAAa,gBAAgB;GACjD,CAAC;AACF,MAAI,CAAC,OACH,OAAM,IAAI,MAAM,mDAAmD;AAGrE,SAAO;YACE,WAAW,KAAK,CACzB,QAAO,GAAG,aAAa,MAAM;EAC3B,QAAQ,WAAW,aAAa,aAAa;EAE7C,iBAAiB;EACjB,QAAQ;EACT,CAAC;KAEF,OAAM,IAAI,MAAM,iCAAiC;;;;;;;;;;;AAarD,SAAgB,mBAAmB,MAAe;AAChD,QAAO,kBAAkB,MAAM,WAAW"}
|
|
@@ -0,0 +1,187 @@
|
|
|
1
|
+
import { t as ZodType } from "./types-i4I6mfMQ.cjs";
|
|
2
|
+
import * as z4 from "zod/v4/core";
|
|
3
|
+
import * as zod_to_json_schema0 from "zod-to-json-schema";
|
|
4
|
+
|
|
5
|
+
//#region ../json/src/types.d.ts
|
|
6
|
+
|
|
7
|
+
interface JsonSchema7AnyType {
|
|
8
|
+
$ref?: string;
|
|
9
|
+
}
|
|
10
|
+
interface JsonSchema7ArrayType {
|
|
11
|
+
type: "array";
|
|
12
|
+
items?: JsonSchema7Type;
|
|
13
|
+
minItems?: number;
|
|
14
|
+
maxItems?: number;
|
|
15
|
+
}
|
|
16
|
+
interface JsonSchema7BigintType {
|
|
17
|
+
type: "integer";
|
|
18
|
+
format: "int64";
|
|
19
|
+
minimum?: bigint;
|
|
20
|
+
exclusiveMinimum?: bigint;
|
|
21
|
+
maximum?: bigint;
|
|
22
|
+
exclusiveMaximum?: bigint;
|
|
23
|
+
multipleOf?: bigint;
|
|
24
|
+
}
|
|
25
|
+
interface JsonSchema7BooleanType {
|
|
26
|
+
type: "boolean";
|
|
27
|
+
}
|
|
28
|
+
type JsonSchema7DateType = {
|
|
29
|
+
type: "integer" | "string";
|
|
30
|
+
format: "unix-time" | "date-time" | "date";
|
|
31
|
+
minimum?: number;
|
|
32
|
+
maximum?: number;
|
|
33
|
+
} | {
|
|
34
|
+
anyOf: JsonSchema7DateType[];
|
|
35
|
+
};
|
|
36
|
+
interface JsonSchema7EnumType {
|
|
37
|
+
type: "string";
|
|
38
|
+
enum: string[];
|
|
39
|
+
}
|
|
40
|
+
interface JsonSchema7AllOfType {
|
|
41
|
+
allOf: JsonSchema7Type[];
|
|
42
|
+
unevaluatedProperties?: boolean;
|
|
43
|
+
}
|
|
44
|
+
type JsonSchema7LiteralType = {
|
|
45
|
+
type: "string" | "number" | "integer" | "boolean";
|
|
46
|
+
const: string | number | boolean;
|
|
47
|
+
} | {
|
|
48
|
+
type: "object" | "array";
|
|
49
|
+
};
|
|
50
|
+
interface JsonSchema7MapType {
|
|
51
|
+
type: "array";
|
|
52
|
+
maxItems: 125;
|
|
53
|
+
items: {
|
|
54
|
+
type: "array";
|
|
55
|
+
items: [JsonSchema7Type, JsonSchema7Type];
|
|
56
|
+
minItems: 2;
|
|
57
|
+
maxItems: 2;
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
interface JsonSchema7NativeEnumType {
|
|
61
|
+
type: "string" | "number" | ["string", "number"];
|
|
62
|
+
enum: (string | number)[];
|
|
63
|
+
}
|
|
64
|
+
interface JsonSchema7NeverType {
|
|
65
|
+
not: JsonSchema7AnyType;
|
|
66
|
+
}
|
|
67
|
+
interface JsonSchema7NullType {
|
|
68
|
+
type: "null";
|
|
69
|
+
}
|
|
70
|
+
type JsonSchema7NullableType = {
|
|
71
|
+
anyOf: [JsonSchema7Type, JsonSchema7NullType];
|
|
72
|
+
} | {
|
|
73
|
+
type: [string, "null"];
|
|
74
|
+
};
|
|
75
|
+
interface JsonSchema7NumberType {
|
|
76
|
+
type: "number" | "integer";
|
|
77
|
+
minimum?: number;
|
|
78
|
+
exclusiveMinimum?: number;
|
|
79
|
+
maximum?: number;
|
|
80
|
+
exclusiveMaximum?: number;
|
|
81
|
+
multipleOf?: number;
|
|
82
|
+
}
|
|
83
|
+
interface JsonSchema7ObjectType {
|
|
84
|
+
type: "object";
|
|
85
|
+
properties: Record<string, JsonSchema7Type>;
|
|
86
|
+
additionalProperties?: boolean | JsonSchema7Type;
|
|
87
|
+
required?: string[];
|
|
88
|
+
}
|
|
89
|
+
interface JsonSchema7StringType {
|
|
90
|
+
type: "string";
|
|
91
|
+
minLength?: number;
|
|
92
|
+
maxLength?: number;
|
|
93
|
+
format?: "email" | "idn-email" | "uri" | "uuid" | "date-time" | "ipv4" | "ipv6" | "date" | "time" | "duration";
|
|
94
|
+
pattern?: string;
|
|
95
|
+
contentEncoding?: string;
|
|
96
|
+
}
|
|
97
|
+
interface JsonSchema7SetType {
|
|
98
|
+
type: "array";
|
|
99
|
+
uniqueItems: true;
|
|
100
|
+
items?: JsonSchema7Type;
|
|
101
|
+
minItems?: number;
|
|
102
|
+
maxItems?: number;
|
|
103
|
+
}
|
|
104
|
+
type JsonSchema7RecordPropertyNamesType = Omit<JsonSchema7StringType, "type"> | Omit<JsonSchema7EnumType, "type">;
|
|
105
|
+
interface JsonSchema7RecordType {
|
|
106
|
+
type: "object";
|
|
107
|
+
additionalProperties?: JsonSchema7Type | true;
|
|
108
|
+
propertyNames?: JsonSchema7RecordPropertyNamesType;
|
|
109
|
+
}
|
|
110
|
+
type JsonSchema7TupleType = {
|
|
111
|
+
type: "array";
|
|
112
|
+
minItems: number;
|
|
113
|
+
items: JsonSchema7Type[];
|
|
114
|
+
} & ({
|
|
115
|
+
maxItems: number;
|
|
116
|
+
} | {
|
|
117
|
+
additionalItems?: JsonSchema7Type;
|
|
118
|
+
});
|
|
119
|
+
interface JsonSchema7UndefinedType {
|
|
120
|
+
not: JsonSchema7AnyType;
|
|
121
|
+
}
|
|
122
|
+
type JsonSchema7Primitive = "string" | "number" | "integer" | "boolean" | "null";
|
|
123
|
+
type JsonSchema7UnionType = JsonSchema7PrimitiveUnionType | JsonSchema7AnyOfType;
|
|
124
|
+
type JsonSchema7PrimitiveUnionType = {
|
|
125
|
+
type: JsonSchema7Primitive | JsonSchema7Primitive[];
|
|
126
|
+
} | {
|
|
127
|
+
type: JsonSchema7Primitive | JsonSchema7Primitive[];
|
|
128
|
+
enum: (string | number | bigint | boolean | null)[];
|
|
129
|
+
};
|
|
130
|
+
type JsonSchema7UnknownType = JsonSchema7AnyType;
|
|
131
|
+
interface JsonSchema7AnyOfType {
|
|
132
|
+
anyOf: JsonSchema7Type[];
|
|
133
|
+
}
|
|
134
|
+
interface JsonSchema7RefType {
|
|
135
|
+
$ref: string;
|
|
136
|
+
}
|
|
137
|
+
interface JsonSchema7Meta {
|
|
138
|
+
$id?: string;
|
|
139
|
+
$ref?: string;
|
|
140
|
+
$schema?: string;
|
|
141
|
+
$comment?: string;
|
|
142
|
+
title?: string;
|
|
143
|
+
default?: any;
|
|
144
|
+
description?: string;
|
|
145
|
+
markdownDescription?: string;
|
|
146
|
+
/**
|
|
147
|
+
* @see https://datatracker.ietf.org/doc/html/draft-bhutton-json-schema-00#section-8.2.4
|
|
148
|
+
* @see https://datatracker.ietf.org/doc/html/draft-bhutton-json-schema-validation-00#appendix-A
|
|
149
|
+
*/
|
|
150
|
+
$defs?: {
|
|
151
|
+
[key: string]: JsonSchema7Type;
|
|
152
|
+
};
|
|
153
|
+
}
|
|
154
|
+
type JsonSchema7TypeUnion = JsonSchema7StringType | JsonSchema7ArrayType | JsonSchema7NumberType | JsonSchema7BigintType | JsonSchema7BooleanType | JsonSchema7DateType | JsonSchema7EnumType | JsonSchema7LiteralType | JsonSchema7NativeEnumType | JsonSchema7NullType | JsonSchema7NumberType | JsonSchema7ObjectType | JsonSchema7RecordType | JsonSchema7TupleType | JsonSchema7UnionType | JsonSchema7UndefinedType | JsonSchema7RefType | JsonSchema7NeverType | JsonSchema7MapType | JsonSchema7AnyType | JsonSchema7NullableType | JsonSchema7AllOfType | JsonSchema7UnknownType | JsonSchema7SetType;
|
|
155
|
+
/**
|
|
156
|
+
* JSON Schema v7
|
|
157
|
+
* @see https://tools.ietf.org/html/draft-handrews-json-schema-validation-01
|
|
158
|
+
*/
|
|
159
|
+
type JsonSchema7Type = JsonSchema7TypeUnion & JsonSchema7Meta;
|
|
160
|
+
//#endregion
|
|
161
|
+
//#region src/schema.d.ts
|
|
162
|
+
/**
|
|
163
|
+
* Extracts a JSON Schema from a given Zod schema, supporting both version 3 and version 4 of Zod.
|
|
164
|
+
*
|
|
165
|
+
* @param type - The Zod schema to extract the JSON Schema from. Can be either a Zod v3 or v4 schema.
|
|
166
|
+
* @param target - The JSON Schema draft version to target. Defaults to "draft-07".
|
|
167
|
+
* @returns The extracted JSON Schema.
|
|
168
|
+
*/
|
|
169
|
+
declare function extractJsonSchema(type: ZodType, target?: "draft-07" | "draft-2020-12"): (object & {
|
|
170
|
+
$schema?: string | undefined;
|
|
171
|
+
definitions?: {
|
|
172
|
+
[key: string]: zod_to_json_schema0.JsonSchema7Type;
|
|
173
|
+
} | undefined;
|
|
174
|
+
}) | z4.ZodStandardJSONSchemaPayload<z4.$ZodType<unknown, unknown, z4.$ZodTypeInternals<unknown, unknown>>>;
|
|
175
|
+
/**
|
|
176
|
+
* Extracts a JSON Schema (draft-07) from a given Zod schema, supporting both version 3 and version 4 of Zod.
|
|
177
|
+
*
|
|
178
|
+
* @remarks
|
|
179
|
+
* This function is a convenience wrapper around `extractJsonSchema` that defaults to targeting the JSON Schema draft-07 specification.
|
|
180
|
+
*
|
|
181
|
+
* @param type - The Zod schema to extract the JSON Schema from. Can be either a Zod v3 or v4 schema.
|
|
182
|
+
* @returns The extracted JSON Schema.
|
|
183
|
+
*/
|
|
184
|
+
declare function extractJsonSchema7(type: ZodType): JsonSchema7Type;
|
|
185
|
+
//#endregion
|
|
186
|
+
export { extractJsonSchema7 as n, extractJsonSchema as t };
|
|
187
|
+
//# sourceMappingURL=schema-D72c2GKP.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schema-D72c2GKP.d.cts","names":[],"sources":["../../json/src/types.ts","../src/schema.ts"],"sourcesContent":[],"mappings":";;;;;;AAgWI,UAhOa,kBAAA,CAgOb;EACA,IAAA,CAAA,EAAA,MAAA;;AAEA,UA/Na,oBAAA,CA+Nb;EACA,IAAA,EAAA,OAAA;EACA,KAAA,CAAA,EA/NM,eA+NN;EACA,QAAA,CAAA,EAAA,MAAA;EACA,QAAA,CAAA,EAAA,MAAA;;AAMQ,UAlOK,qBAAA,CAkOa;;;;EC9Ud,gBAAA,CAAA,EAAA,MAAiB;EACzB,OAAA,CAAA,EAAA,MAAA;EAAO,gBAAA,CAAA,EAAA,MAAA;;;UDqHE,sBAAA;;AClFjB;KDsFY,mBAAA;;;;;;SAQC;;UAGI,mBAAA;;;;UAKA,oBAAA;SACR;;;KAIG,sBAAA;;;;;;UASK,kBAAA;;;;;YAKL,iBAAiB;;;;;UAMZ,yBAAA;;;;UAKA,oBAAA;OACV;;UAGU,mBAAA;;;KAIL,uBAAA;UAEE,iBAAiB;;;;UAMd,qBAAA;;;;;;;;UASA,qBAAA;;cAEH,eAAe;mCACM;;;UAIlB,qBAAA;;;;;;;;UAmBA,kBAAA;;;UAGP;;;;KAKE,kCAAA,GACR,KAAK,iCACL,KAAK;UAEQ,qBAAA;;yBAEQ;kBACP;;KAGN,oBAAA;;;SAGH;;;;oBAMe;;UAIP,wBAAA;OACV;;KAGK,oBAAA;KAOA,oBAAA,GACR,gCACA;KAEQ,6BAAA;QAEA,uBAAuB;;QAGvB,uBAAuB;;;KAIvB,sBAAA,GAAyB;UAEpB,oBAAA;SACR;;UAGQ,kBAAA;;;UAIA,eAAA;;;;;;;;;;;;;;mBAgBE;;;KAIP,oBAAA,GACR,wBACA,uBACA,wBACA,wBACA,yBACA,sBACA,sBACA,yBACA,4BACA,sBACA,wBACA,wBACA,wBACA,uBACA,uBACA,2BACA,qBACA,uBACA,qBACA,qBACA,0BACA,uBACA,yBACA;;;;;KAMQ,eAAA,GAAkB,uBAAuB;;;;;AA7OrD;AAIA;AAOA;AAUA;AAIA;AAWiB,iBCrID,iBAAA,CDqIoB,IAAA,ECpI5B,ODoI4B,EAAA,MAAA,CAAA,EAAA,UAAA,GAAA,eAAA,CAAA,EAAA,CAAA,MAAA,GAAA;EAKnB,OAAA,CAAA,EAAA,MAAA,GAAA,SAAoB;EAKzB,WAAA,CAAA,EAAA;IASK,CAAA,GAAA,EAAA,MAAA,CAAA,ECvJF,mBAAA,CAAA,eD4Jc;EAMZ,CAAA,GAAA,SAAA;AAKjB,CAAA,CAAA,kCAAqC,YAC9B,CAAA,OAAA,EAAkB,OAAA,sBAAA,CAAA,OAAA,EAAA,OAAA,CAAA,CAAA,CAAA;AAGzB;AAIA;AAQA;AASA;;;;;AAOA;AAmBiB,iBCvLD,kBAAA,CD0LN,IAAA,EC1L+B,OD0LhB,CAAA,ECzLuB,eDyLvB"}
|
|
@@ -0,0 +1,189 @@
|
|
|
1
|
+
import { t as ZodType } from "./types-DWWjtQA0.mjs";
|
|
2
|
+
import * as zod_to_json_schema0 from "zod-to-json-schema";
|
|
3
|
+
import * as z4 from "zod/v4/core";
|
|
4
|
+
import "jsonc-parser";
|
|
5
|
+
import "superjson";
|
|
6
|
+
|
|
7
|
+
//#region ../json/src/types.d.ts
|
|
8
|
+
|
|
9
|
+
interface JsonSchema7AnyType {
|
|
10
|
+
$ref?: string;
|
|
11
|
+
}
|
|
12
|
+
interface JsonSchema7ArrayType {
|
|
13
|
+
type: "array";
|
|
14
|
+
items?: JsonSchema7Type;
|
|
15
|
+
minItems?: number;
|
|
16
|
+
maxItems?: number;
|
|
17
|
+
}
|
|
18
|
+
interface JsonSchema7BigintType {
|
|
19
|
+
type: "integer";
|
|
20
|
+
format: "int64";
|
|
21
|
+
minimum?: bigint;
|
|
22
|
+
exclusiveMinimum?: bigint;
|
|
23
|
+
maximum?: bigint;
|
|
24
|
+
exclusiveMaximum?: bigint;
|
|
25
|
+
multipleOf?: bigint;
|
|
26
|
+
}
|
|
27
|
+
interface JsonSchema7BooleanType {
|
|
28
|
+
type: "boolean";
|
|
29
|
+
}
|
|
30
|
+
type JsonSchema7DateType = {
|
|
31
|
+
type: "integer" | "string";
|
|
32
|
+
format: "unix-time" | "date-time" | "date";
|
|
33
|
+
minimum?: number;
|
|
34
|
+
maximum?: number;
|
|
35
|
+
} | {
|
|
36
|
+
anyOf: JsonSchema7DateType[];
|
|
37
|
+
};
|
|
38
|
+
interface JsonSchema7EnumType {
|
|
39
|
+
type: "string";
|
|
40
|
+
enum: string[];
|
|
41
|
+
}
|
|
42
|
+
interface JsonSchema7AllOfType {
|
|
43
|
+
allOf: JsonSchema7Type[];
|
|
44
|
+
unevaluatedProperties?: boolean;
|
|
45
|
+
}
|
|
46
|
+
type JsonSchema7LiteralType = {
|
|
47
|
+
type: "string" | "number" | "integer" | "boolean";
|
|
48
|
+
const: string | number | boolean;
|
|
49
|
+
} | {
|
|
50
|
+
type: "object" | "array";
|
|
51
|
+
};
|
|
52
|
+
interface JsonSchema7MapType {
|
|
53
|
+
type: "array";
|
|
54
|
+
maxItems: 125;
|
|
55
|
+
items: {
|
|
56
|
+
type: "array";
|
|
57
|
+
items: [JsonSchema7Type, JsonSchema7Type];
|
|
58
|
+
minItems: 2;
|
|
59
|
+
maxItems: 2;
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
interface JsonSchema7NativeEnumType {
|
|
63
|
+
type: "string" | "number" | ["string", "number"];
|
|
64
|
+
enum: (string | number)[];
|
|
65
|
+
}
|
|
66
|
+
interface JsonSchema7NeverType {
|
|
67
|
+
not: JsonSchema7AnyType;
|
|
68
|
+
}
|
|
69
|
+
interface JsonSchema7NullType {
|
|
70
|
+
type: "null";
|
|
71
|
+
}
|
|
72
|
+
type JsonSchema7NullableType = {
|
|
73
|
+
anyOf: [JsonSchema7Type, JsonSchema7NullType];
|
|
74
|
+
} | {
|
|
75
|
+
type: [string, "null"];
|
|
76
|
+
};
|
|
77
|
+
interface JsonSchema7NumberType {
|
|
78
|
+
type: "number" | "integer";
|
|
79
|
+
minimum?: number;
|
|
80
|
+
exclusiveMinimum?: number;
|
|
81
|
+
maximum?: number;
|
|
82
|
+
exclusiveMaximum?: number;
|
|
83
|
+
multipleOf?: number;
|
|
84
|
+
}
|
|
85
|
+
interface JsonSchema7ObjectType {
|
|
86
|
+
type: "object";
|
|
87
|
+
properties: Record<string, JsonSchema7Type>;
|
|
88
|
+
additionalProperties?: boolean | JsonSchema7Type;
|
|
89
|
+
required?: string[];
|
|
90
|
+
}
|
|
91
|
+
interface JsonSchema7StringType {
|
|
92
|
+
type: "string";
|
|
93
|
+
minLength?: number;
|
|
94
|
+
maxLength?: number;
|
|
95
|
+
format?: "email" | "idn-email" | "uri" | "uuid" | "date-time" | "ipv4" | "ipv6" | "date" | "time" | "duration";
|
|
96
|
+
pattern?: string;
|
|
97
|
+
contentEncoding?: string;
|
|
98
|
+
}
|
|
99
|
+
interface JsonSchema7SetType {
|
|
100
|
+
type: "array";
|
|
101
|
+
uniqueItems: true;
|
|
102
|
+
items?: JsonSchema7Type;
|
|
103
|
+
minItems?: number;
|
|
104
|
+
maxItems?: number;
|
|
105
|
+
}
|
|
106
|
+
type JsonSchema7RecordPropertyNamesType = Omit<JsonSchema7StringType, "type"> | Omit<JsonSchema7EnumType, "type">;
|
|
107
|
+
interface JsonSchema7RecordType {
|
|
108
|
+
type: "object";
|
|
109
|
+
additionalProperties?: JsonSchema7Type | true;
|
|
110
|
+
propertyNames?: JsonSchema7RecordPropertyNamesType;
|
|
111
|
+
}
|
|
112
|
+
type JsonSchema7TupleType = {
|
|
113
|
+
type: "array";
|
|
114
|
+
minItems: number;
|
|
115
|
+
items: JsonSchema7Type[];
|
|
116
|
+
} & ({
|
|
117
|
+
maxItems: number;
|
|
118
|
+
} | {
|
|
119
|
+
additionalItems?: JsonSchema7Type;
|
|
120
|
+
});
|
|
121
|
+
interface JsonSchema7UndefinedType {
|
|
122
|
+
not: JsonSchema7AnyType;
|
|
123
|
+
}
|
|
124
|
+
type JsonSchema7Primitive = "string" | "number" | "integer" | "boolean" | "null";
|
|
125
|
+
type JsonSchema7UnionType = JsonSchema7PrimitiveUnionType | JsonSchema7AnyOfType;
|
|
126
|
+
type JsonSchema7PrimitiveUnionType = {
|
|
127
|
+
type: JsonSchema7Primitive | JsonSchema7Primitive[];
|
|
128
|
+
} | {
|
|
129
|
+
type: JsonSchema7Primitive | JsonSchema7Primitive[];
|
|
130
|
+
enum: (string | number | bigint | boolean | null)[];
|
|
131
|
+
};
|
|
132
|
+
type JsonSchema7UnknownType = JsonSchema7AnyType;
|
|
133
|
+
interface JsonSchema7AnyOfType {
|
|
134
|
+
anyOf: JsonSchema7Type[];
|
|
135
|
+
}
|
|
136
|
+
interface JsonSchema7RefType {
|
|
137
|
+
$ref: string;
|
|
138
|
+
}
|
|
139
|
+
interface JsonSchema7Meta {
|
|
140
|
+
$id?: string;
|
|
141
|
+
$ref?: string;
|
|
142
|
+
$schema?: string;
|
|
143
|
+
$comment?: string;
|
|
144
|
+
title?: string;
|
|
145
|
+
default?: any;
|
|
146
|
+
description?: string;
|
|
147
|
+
markdownDescription?: string;
|
|
148
|
+
/**
|
|
149
|
+
* @see https://datatracker.ietf.org/doc/html/draft-bhutton-json-schema-00#section-8.2.4
|
|
150
|
+
* @see https://datatracker.ietf.org/doc/html/draft-bhutton-json-schema-validation-00#appendix-A
|
|
151
|
+
*/
|
|
152
|
+
$defs?: {
|
|
153
|
+
[key: string]: JsonSchema7Type;
|
|
154
|
+
};
|
|
155
|
+
}
|
|
156
|
+
type JsonSchema7TypeUnion = JsonSchema7StringType | JsonSchema7ArrayType | JsonSchema7NumberType | JsonSchema7BigintType | JsonSchema7BooleanType | JsonSchema7DateType | JsonSchema7EnumType | JsonSchema7LiteralType | JsonSchema7NativeEnumType | JsonSchema7NullType | JsonSchema7NumberType | JsonSchema7ObjectType | JsonSchema7RecordType | JsonSchema7TupleType | JsonSchema7UnionType | JsonSchema7UndefinedType | JsonSchema7RefType | JsonSchema7NeverType | JsonSchema7MapType | JsonSchema7AnyType | JsonSchema7NullableType | JsonSchema7AllOfType | JsonSchema7UnknownType | JsonSchema7SetType;
|
|
157
|
+
/**
|
|
158
|
+
* JSON Schema v7
|
|
159
|
+
* @see https://tools.ietf.org/html/draft-handrews-json-schema-validation-01
|
|
160
|
+
*/
|
|
161
|
+
type JsonSchema7Type = JsonSchema7TypeUnion & JsonSchema7Meta;
|
|
162
|
+
//#endregion
|
|
163
|
+
//#region src/schema.d.ts
|
|
164
|
+
/**
|
|
165
|
+
* Extracts a JSON Schema from a given Zod schema, supporting both version 3 and version 4 of Zod.
|
|
166
|
+
*
|
|
167
|
+
* @param type - The Zod schema to extract the JSON Schema from. Can be either a Zod v3 or v4 schema.
|
|
168
|
+
* @param target - The JSON Schema draft version to target. Defaults to "draft-07".
|
|
169
|
+
* @returns The extracted JSON Schema.
|
|
170
|
+
*/
|
|
171
|
+
declare function extractJsonSchema(type: ZodType, target?: "draft-07" | "draft-2020-12"): (object & {
|
|
172
|
+
$schema?: string | undefined;
|
|
173
|
+
definitions?: {
|
|
174
|
+
[key: string]: zod_to_json_schema0.JsonSchema7Type;
|
|
175
|
+
} | undefined;
|
|
176
|
+
}) | z4.ZodStandardJSONSchemaPayload<z4.$ZodType<unknown, unknown, z4.$ZodTypeInternals<unknown, unknown>>>;
|
|
177
|
+
/**
|
|
178
|
+
* Extracts a JSON Schema (draft-07) from a given Zod schema, supporting both version 3 and version 4 of Zod.
|
|
179
|
+
*
|
|
180
|
+
* @remarks
|
|
181
|
+
* This function is a convenience wrapper around `extractJsonSchema` that defaults to targeting the JSON Schema draft-07 specification.
|
|
182
|
+
*
|
|
183
|
+
* @param type - The Zod schema to extract the JSON Schema from. Can be either a Zod v3 or v4 schema.
|
|
184
|
+
* @returns The extracted JSON Schema.
|
|
185
|
+
*/
|
|
186
|
+
declare function extractJsonSchema7(type: ZodType): JsonSchema7Type;
|
|
187
|
+
//#endregion
|
|
188
|
+
export { extractJsonSchema7 as n, extractJsonSchema as t };
|
|
189
|
+
//# sourceMappingURL=schema-TGJB_m82.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schema-TGJB_m82.d.mts","names":[],"sources":["../../json/src/types.ts","../src/schema.ts"],"sourcesContent":[],"mappings":";;;;;;;;AA8VI,UA9Na,kBAAA,CA8Nb;EACA,IAAA,CAAA,EAAA,MAAA;;AAEA,UA7Na,oBAAA,CA6Nb;EACA,IAAA,EAAA,OAAA;EACA,KAAA,CAAA,EA7NM,eA6NN;EACA,QAAA,CAAA,EAAA,MAAA;EACA,QAAA,CAAA,EAAA,MAAA;;AAEA,UA5Na,qBAAA,CA4Nb;EAAkB,IAAA,EAAA,SAAA;EAMV,MAAA,EAAA,OAAA;;;;EC9UI,gBAAA,CAAA,EAAA,MAAiB;EACzB,UAAA,CAAA,EAAA,MAAA;;UDqHS,sBAAA;;;KAIL,mBAAA;ECtFI,IAAA,EAAA,SAAA,GAAA,QAAkB;;;;;SD8FrB;;UAGI,mBAAA;;;;UAKA,oBAAA;SACR;;;KAIG,sBAAA;;;;;;UASK,kBAAA;;;;;YAKL,iBAAiB;;;;;UAMZ,yBAAA;;;;UAKA,oBAAA;OACV;;UAGU,mBAAA;;;KAIL,uBAAA;UAEE,iBAAiB;;;;UAMd,qBAAA;;;;;;;;UASA,qBAAA;;cAEH,eAAe;mCACM;;;UAIlB,qBAAA;;;;;;;;UAmBA,kBAAA;;;UAGP;;;;KAKE,kCAAA,GACR,KAAK,iCACL,KAAK;UAEQ,qBAAA;;yBAEQ;kBACP;;KAGN,oBAAA;;;SAGH;;;;oBAMe;;UAIP,wBAAA;OACV;;KAGK,oBAAA;KAOA,oBAAA,GACR,gCACA;KAEQ,6BAAA;QAEA,uBAAuB;;QAGvB,uBAAuB;;;KAIvB,sBAAA,GAAyB;UAEpB,oBAAA;SACR;;UAGQ,kBAAA;;;UAIA,eAAA;;;;;;;;;;;;;;mBAgBE;;;KAIP,oBAAA,GACR,wBACA,uBACA,wBACA,wBACA,yBACA,sBACA,sBACA,yBACA,4BACA,sBACA,wBACA,wBACA,wBACA,uBACA,uBACA,2BACA,qBACA,uBACA,qBACA,qBACA,0BACA,uBACA,yBACA;;;;;KAMQ,eAAA,GAAkB,uBAAuB;;;;;;;AA7OrD;AAIA;AAOA;AAUiB,iBCtHD,iBAAA,CDsHuB,IAAA,ECrH/B,ODqH+B,EAAA,MAAA,CAAA,EAAA,UAAA,GAAA,eAAA,CAAA,EAAA,CAAA,MAAA,GAAA;EAI3B,OAAA,CAAA,EAAA,MAAA,GAAA,SAAmB;EAWd,WAAA,CAAA,EAAA;IAKA,CAAA,GAAA,EAAA,MAAA,CAAA,ECzIF,mBAAA,CAAA,eD0IS;EAIZ,CAAA,GAAA,SAAA;AASZ,CAAA,CAAA,kCAAmC,YAKvB,CAAA,OAAiB,EAAA,OAAA,sBAAe,CAAA,OAAA,EAAA,OAAA,CAAA,CAAA,CAAA;AAM5C;AAKA;AAIA;AAIA;AAQA;AASA;;;;AAGkD,iBChKlC,kBAAA,CDgKkC,IAAA,EChKT,ODgKS,CAAA,EC/JF,eD+JE"}
|
package/dist/schema.d.cts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { n as extractJsonSchema7, t as extractJsonSchema } from "./schema-
|
|
1
|
+
import { n as extractJsonSchema7, t as extractJsonSchema } from "./schema-D72c2GKP.cjs";
|
|
2
2
|
export { extractJsonSchema, extractJsonSchema7 };
|
package/dist/schema.d.mts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import "./types-
|
|
2
|
-
import { n as extractJsonSchema7, t as extractJsonSchema } from "./schema-
|
|
1
|
+
import "./types-DWWjtQA0.mjs";
|
|
2
|
+
import { n as extractJsonSchema7, t as extractJsonSchema } from "./schema-TGJB_m82.mjs";
|
|
3
3
|
export { extractJsonSchema, extractJsonSchema7 };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types-DWWjtQA0.d.mts","names":[],"sources":["../src/types.ts"],"sourcesContent":[],"mappings":";;;;KAqBY,OAAA,GAAU,EAAA,CAAG,aAAa,EAAA,CAAG"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types-i4I6mfMQ.d.cts","names":[],"sources":["../src/types.ts"],"sourcesContent":[],"mappings":";;;;KAqBY,OAAA,GAAU,EAAA,CAAG,aAAa,EAAA,CAAG"}
|
package/dist/types.d.cts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export { ZodType
|
|
1
|
+
import { t as ZodType } from "./types-i4I6mfMQ.cjs";
|
|
2
|
+
export { ZodType };
|
package/dist/types.d.mts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export { ZodType
|
|
1
|
+
import { t as ZodType } from "./types-DWWjtQA0.mjs";
|
|
2
|
+
export { ZodType };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stryke/zod",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.1",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "A package containing helper utilities for working with zod schemas.",
|
|
6
6
|
"repository": {
|
|
@@ -9,17 +9,8 @@
|
|
|
9
9
|
"directory": "packages/zod"
|
|
10
10
|
},
|
|
11
11
|
"private": false,
|
|
12
|
-
"peerDependencies": { "zod": "^3.25.0 || ^4.0.0" },
|
|
13
|
-
"peerDependenciesMeta": { "zod": { "optional": true } },
|
|
14
|
-
"dependencies": {
|
|
15
|
-
"@stryke/type-checks": "^0.5.26",
|
|
16
|
-
"zod-to-json-schema": "^3.25.1"
|
|
17
|
-
},
|
|
18
|
-
"devDependencies": { "tsdown": "^0.17.2", "zod": "^4.3.6" },
|
|
19
|
-
"publishConfig": { "access": "public" },
|
|
20
12
|
"main": "./dist/index.cjs",
|
|
21
13
|
"module": "./dist/index.mjs",
|
|
22
|
-
"types": "./dist/index.d.cts",
|
|
23
14
|
"exports": {
|
|
24
15
|
".": {
|
|
25
16
|
"require": {
|
|
@@ -75,5 +66,18 @@
|
|
|
75
66
|
},
|
|
76
67
|
"./*": "./*"
|
|
77
68
|
},
|
|
78
|
-
"
|
|
69
|
+
"types": "./dist/index.d.cts",
|
|
70
|
+
"peerDependencies": { "zod": "^3.25.0 || ^4.0.0" },
|
|
71
|
+
"peerDependenciesMeta": { "zod": { "optional": true } },
|
|
72
|
+
"dependencies": {
|
|
73
|
+
"@stryke/type-checks": "^0.5.27",
|
|
74
|
+
"zod-to-json-schema": "^3.25.1"
|
|
75
|
+
},
|
|
76
|
+
"devDependencies": {
|
|
77
|
+
"@stryke/json": "^0.10.0",
|
|
78
|
+
"tsdown": "^0.17.2",
|
|
79
|
+
"zod": "^4.3.6"
|
|
80
|
+
},
|
|
81
|
+
"publishConfig": { "access": "public" },
|
|
82
|
+
"gitHead": "7755bd92180cadaa0ef8168e4e123deaacc4ccb8"
|
|
79
83
|
}
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import { t as ZodType } from "./types-UlEWkGXF.mjs";
|
|
2
|
-
import { JsonSchema7Type } from "zod-to-json-schema";
|
|
3
|
-
import * as z4 from "zod/v4/core";
|
|
4
|
-
|
|
5
|
-
//#region src/schema.d.ts
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* Extracts a JSON Schema from a given Zod schema, supporting both version 3 and version 4 of Zod.
|
|
9
|
-
*
|
|
10
|
-
* @param type - The Zod schema to extract the JSON Schema from. Can be either a Zod v3 or v4 schema.
|
|
11
|
-
* @param target - The JSON Schema draft version to target. Defaults to "draft-07".
|
|
12
|
-
* @returns The extracted JSON Schema.
|
|
13
|
-
*/
|
|
14
|
-
declare function extractJsonSchema(type: ZodType, target?: "draft-07" | "draft-2020-12"): (object & {
|
|
15
|
-
$schema?: string | undefined;
|
|
16
|
-
definitions?: {
|
|
17
|
-
[key: string]: JsonSchema7Type;
|
|
18
|
-
} | undefined;
|
|
19
|
-
}) | z4.ZodStandardJSONSchemaPayload<z4.$ZodType<unknown, unknown, z4.$ZodTypeInternals<unknown, unknown>>>;
|
|
20
|
-
/**
|
|
21
|
-
* Extracts a JSON Schema (draft-07) from a given Zod schema, supporting both version 3 and version 4 of Zod.
|
|
22
|
-
*
|
|
23
|
-
* @remarks
|
|
24
|
-
* This function is a convenience wrapper around `extractJsonSchema` that defaults to targeting the JSON Schema draft-07 specification.
|
|
25
|
-
*
|
|
26
|
-
* @param type - The Zod schema to extract the JSON Schema from. Can be either a Zod v3 or v4 schema.
|
|
27
|
-
* @returns The extracted JSON Schema.
|
|
28
|
-
*/
|
|
29
|
-
declare function extractJsonSchema7(type: ZodType): JsonSchema7Type;
|
|
30
|
-
//#endregion
|
|
31
|
-
export { extractJsonSchema7 as n, extractJsonSchema as t };
|
|
32
|
-
//# sourceMappingURL=schema-DQPkBDAQ.d.mts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"schema-DQPkBDAQ.d.mts","names":[],"sources":["../src/schema.ts"],"sourcesContent":[],"mappings":";;;;;;;;AA+BA;;;;;iBAAgB,iBAAA,OACR;;EAmCQ,WAAA,CAAA,EAAA;;;;;;;;;;;;;iBAAA,kBAAA,OAAyB,UACO"}
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import { t as ZodType } from "./types-4nTrnOUu.cjs";
|
|
2
|
-
import * as z4 from "zod/v4/core";
|
|
3
|
-
import { JsonSchema7Type } from "zod-to-json-schema";
|
|
4
|
-
|
|
5
|
-
//#region src/schema.d.ts
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* Extracts a JSON Schema from a given Zod schema, supporting both version 3 and version 4 of Zod.
|
|
9
|
-
*
|
|
10
|
-
* @param type - The Zod schema to extract the JSON Schema from. Can be either a Zod v3 or v4 schema.
|
|
11
|
-
* @param target - The JSON Schema draft version to target. Defaults to "draft-07".
|
|
12
|
-
* @returns The extracted JSON Schema.
|
|
13
|
-
*/
|
|
14
|
-
declare function extractJsonSchema(type: ZodType, target?: "draft-07" | "draft-2020-12"): (object & {
|
|
15
|
-
$schema?: string | undefined;
|
|
16
|
-
definitions?: {
|
|
17
|
-
[key: string]: JsonSchema7Type;
|
|
18
|
-
} | undefined;
|
|
19
|
-
}) | z4.ZodStandardJSONSchemaPayload<z4.$ZodType<unknown, unknown, z4.$ZodTypeInternals<unknown, unknown>>>;
|
|
20
|
-
/**
|
|
21
|
-
* Extracts a JSON Schema (draft-07) from a given Zod schema, supporting both version 3 and version 4 of Zod.
|
|
22
|
-
*
|
|
23
|
-
* @remarks
|
|
24
|
-
* This function is a convenience wrapper around `extractJsonSchema` that defaults to targeting the JSON Schema draft-07 specification.
|
|
25
|
-
*
|
|
26
|
-
* @param type - The Zod schema to extract the JSON Schema from. Can be either a Zod v3 or v4 schema.
|
|
27
|
-
* @returns The extracted JSON Schema.
|
|
28
|
-
*/
|
|
29
|
-
declare function extractJsonSchema7(type: ZodType): JsonSchema7Type;
|
|
30
|
-
//#endregion
|
|
31
|
-
export { extractJsonSchema7 as n, extractJsonSchema as t };
|
|
32
|
-
//# sourceMappingURL=schema-s8jVY_-l.d.cts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"schema-s8jVY_-l.d.cts","names":[],"sources":["../src/schema.ts"],"sourcesContent":[],"mappings":";;;;;;;;AA+BA;;;;;iBAAgB,iBAAA,OACR;;EAmCQ,WAAA,CAAA,EAAA;;;;;;;;;;;;;iBAAA,kBAAA,OAAyB,UACO"}
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import * as z3 from "zod/v3";
|
|
2
|
-
import * as z4 from "zod/v4/core";
|
|
3
|
-
|
|
4
|
-
//#region src/types.d.ts
|
|
5
|
-
type ZodType = z3.ZodTypeAny | z4.$ZodType;
|
|
6
|
-
type ZodTypeKind = "string" | "number" | "bigint" | "boolean" | "symbol" | "undefined" | "object" | "function" | "date" | "array" | "null" | "void" | "any" | "unknown" | "union" | "intersection";
|
|
7
|
-
/**
|
|
8
|
-
* Extracted metadata from a Zod schema.
|
|
9
|
-
*/
|
|
10
|
-
interface ZodTypeInfo {
|
|
11
|
-
kind: ZodTypeKind;
|
|
12
|
-
optional: boolean;
|
|
13
|
-
defaultValue?: unknown;
|
|
14
|
-
description?: string;
|
|
15
|
-
variadic: boolean;
|
|
16
|
-
choices?: (string | number)[];
|
|
17
|
-
}
|
|
18
|
-
//#endregion
|
|
19
|
-
export { ZodTypeInfo as n, ZodTypeKind as r, ZodType as t };
|
|
20
|
-
//# sourceMappingURL=types-4nTrnOUu.d.cts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"types-4nTrnOUu.d.cts","names":[],"sources":["../src/types.ts"],"sourcesContent":[],"mappings":";;;;KAqBY,OAAA,GAAU,EAAA,CAAG,aAAa,EAAA,CAAG;KAE7B,WAAA;AAFZ;AAEA;AAqBA;UAAiB,WAAA;QACT"}
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import * as z4 from "zod/v4/core";
|
|
2
|
-
import * as z3 from "zod/v3";
|
|
3
|
-
|
|
4
|
-
//#region src/types.d.ts
|
|
5
|
-
type ZodType = z3.ZodTypeAny | z4.$ZodType;
|
|
6
|
-
type ZodTypeKind = "string" | "number" | "bigint" | "boolean" | "symbol" | "undefined" | "object" | "function" | "date" | "array" | "null" | "void" | "any" | "unknown" | "union" | "intersection";
|
|
7
|
-
/**
|
|
8
|
-
* Extracted metadata from a Zod schema.
|
|
9
|
-
*/
|
|
10
|
-
interface ZodTypeInfo {
|
|
11
|
-
kind: ZodTypeKind;
|
|
12
|
-
optional: boolean;
|
|
13
|
-
defaultValue?: unknown;
|
|
14
|
-
description?: string;
|
|
15
|
-
variadic: boolean;
|
|
16
|
-
choices?: (string | number)[];
|
|
17
|
-
}
|
|
18
|
-
//#endregion
|
|
19
|
-
export { ZodTypeInfo as n, ZodTypeKind as r, ZodType as t };
|
|
20
|
-
//# sourceMappingURL=types-UlEWkGXF.d.mts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"types-UlEWkGXF.d.mts","names":[],"sources":["../src/types.ts"],"sourcesContent":[],"mappings":";;;;KAqBY,OAAA,GAAU,EAAA,CAAG,aAAa,EAAA,CAAG;KAE7B,WAAA;AAFZ;AAEA;AAqBA;UAAiB,WAAA;QACT"}
|