@stryke/zod 0.2.4 → 0.3.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 CHANGED
@@ -2,6 +2,24 @@
2
2
 
3
3
  # Changelog for Stryke - Zod
4
4
 
5
+ ## [0.3.0](https://github.com/storm-software/stryke/releases/tag/zod%400.3.0) (03/03/2026)
6
+
7
+ ### Features
8
+
9
+ - **zod:** Added `io` option to `extractJsonSchema` function ([172dab78](https://github.com/storm-software/stryke/commit/172dab78))
10
+
11
+ ### Updated Dependencies
12
+
13
+ - Updated **type-checks** to **v0.5.31**
14
+ - Updated **json** to **v0.13.1**
15
+
16
+ ## [0.2.4](https://github.com/storm-software/stryke/releases/tag/zod%400.2.4) (03/03/2026)
17
+
18
+ ### Updated Dependencies
19
+
20
+ - Updated **type-checks** to **v0.5.30**
21
+ - Updated **json** to **v0.13.0**
22
+
5
23
  ## [0.2.3](https://github.com/storm-software/stryke/releases/tag/zod%400.2.3) (03/03/2026)
6
24
 
7
25
  ### Miscellaneous
package/dist/index.cjs CHANGED
@@ -1,4 +1,4 @@
1
- const require_schema = require('./schema-C9c6yHpZ.cjs');
1
+ const require_schema = require('./schema-DYckL2kJ.cjs');
2
2
  const require_is_zod_type = require('./is-zod-type-RGE-O0aK.cjs');
3
3
  require('./types.cjs');
4
4
 
package/dist/index.d.cts CHANGED
@@ -1,4 +1,4 @@
1
1
  import { t as ZodType } from "./types-i4I6mfMQ.cjs";
2
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-DAmyxbgH.cjs";
4
- export { ZodType, extractJsonSchema, extractJsonSchema7, isZod3Type, isZod4Type, isZodType };
3
+ import { n as extractJsonSchema, r as extractJsonSchema7, t as ExtractJsonSchemaOptions } from "./schema-r-i8wUJm.cjs";
4
+ export { ExtractJsonSchemaOptions, ZodType, extractJsonSchema, extractJsonSchema7, isZod3Type, isZod4Type, isZodType };
package/dist/index.d.mts CHANGED
@@ -1,4 +1,4 @@
1
1
  import { t as ZodType } from "./types-DWWjtQA0.mjs";
2
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-DJs6pbWQ.mjs";
4
- export { ZodType, extractJsonSchema, extractJsonSchema7, isZod3Type, isZod4Type, isZodType };
3
+ import { n as extractJsonSchema, r as extractJsonSchema7, t as ExtractJsonSchemaOptions } from "./schema-CM-MXRuJ.mjs";
4
+ export { ExtractJsonSchemaOptions, ZodType, extractJsonSchema, extractJsonSchema7, isZod3Type, isZod4Type, isZodType };
package/dist/index.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  import { n as isZod4Type, r as isZodType, t as isZod3Type } from "./is-zod-type-B-jL80F-.mjs";
2
- import { n as extractJsonSchema7, t as extractJsonSchema } from "./schema-XGYh6TgB.mjs";
2
+ import { n as extractJsonSchema7, t as extractJsonSchema } from "./schema-BscDIlVR.mjs";
3
3
  import "./types.mjs";
4
4
 
5
5
  export { extractJsonSchema, extractJsonSchema7, isZod3Type, isZod4Type, isZodType };
@@ -7,10 +7,11 @@ import * as z4 from "zod/v4/core";
7
7
  * Extracts a JSON Schema from a given Zod schema, supporting both version 3 and version 4 of Zod.
8
8
  *
9
9
  * @param type - The Zod schema to extract the JSON Schema from. Can be either a Zod v3 or v4 schema.
10
- * @param target - The JSON Schema draft version to target. Defaults to "draft-07".
10
+ * @param options - Options for extracting the JSON Schema, including the target draft version and input/output selection.
11
11
  * @returns The extracted JSON Schema.
12
12
  */
13
- function extractJsonSchema(type, target = "draft-07") {
13
+ function extractJsonSchema(type, options = {}) {
14
+ const { target = "draft-07", io = "input" } = options;
14
15
  if (isZod3Type(type)) {
15
16
  const result = zodToJsonSchema(type, {
16
17
  $refStrategy: "root",
@@ -18,7 +19,8 @@ function extractJsonSchema(type, target = "draft-07") {
18
19
  target: target === "draft-07" ? "jsonSchema7" : "jsonSchema2019-09",
19
20
  mapStrategy: "entries",
20
21
  errorMessages: false,
21
- markdownDescription: false
22
+ markdownDescription: false,
23
+ pipeStrategy: io
22
24
  });
23
25
  if (!result) throw new Error("Failed to extract JSON Schema from Zod v3 schema");
24
26
  return result;
@@ -39,9 +41,9 @@ function extractJsonSchema(type, target = "draft-07") {
39
41
  * @returns The extracted JSON Schema.
40
42
  */
41
43
  function extractJsonSchema7(type) {
42
- return extractJsonSchema(type, "draft-07");
44
+ return extractJsonSchema(type, { target: "draft-07" });
43
45
  }
44
46
 
45
47
  //#endregion
46
48
  export { extractJsonSchema7 as n, extractJsonSchema as t };
47
- //# sourceMappingURL=schema-XGYh6TgB.mjs.map
49
+ //# sourceMappingURL=schema-BscDIlVR.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"schema-BscDIlVR.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\nexport interface ExtractJsonSchemaOptions {\n /**\n * The JSON Schema draft version to target. Defaults to \"draft-07\".\n */\n target?: \"draft-07\" | \"draft-2020-12\";\n\n /**\n * Whether to include the input or output schema for Zod schemas.\n *\n * @remarks\n */\n io?: \"input\" | \"output\";\n}\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 options - Options for extracting the JSON Schema, including the target draft version and input/output selection.\n * @returns The extracted JSON Schema.\n */\nexport function extractJsonSchema(\n type: ZodType,\n options: ExtractJsonSchemaOptions = {}\n) {\n const { target = \"draft-07\", io = \"input\" } = options;\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 mapStrategy: \"entries\",\n errorMessages: false,\n markdownDescription: false,\n pipeStrategy: io\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 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, { target: \"draft-07\" }) as JsonSchema7Type;\n}\n"],"mappings":";;;;;;;;;;;;AA6CA,SAAgB,kBACd,MACA,UAAoC,EAAE,EACtC;CACA,MAAM,EAAE,SAAS,YAAY,KAAK,YAAY;AAE9C,KAAI,WAAW,KAAK,EAAE;EACpB,MAAM,SAAS,gBAAgB,MAAM;GACnC,cAAc;GACd,gBAAgB;GAChB,QAAQ,WAAW,aAAa,gBAAgB;GAChD,aAAa;GACb,eAAe;GACf,qBAAqB;GACrB,cAAc;GACf,CAAC;AACF,MAAI,CAAC,OACH,OAAM,IAAI,MAAM,mDAAmD;AAGrE,SAAO;YACE,WAAW,KAAK,CACzB,QAAO,GAAG,aAAa,MAAM;EAC3B,QAAQ,WAAW,aAAa,aAAa;EAC7C,iBAAiB;EACjB,QAAQ;EACT,CAAC;KAEF,OAAM,IAAI,MAAM,iCAAiC;;;;;;;;;;;AAarD,SAAgB,mBAAmB,MAAe;AAChD,QAAO,kBAAkB,MAAM,EAAE,QAAQ,YAAY,CAAC"}
@@ -0,0 +1,237 @@
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 JsonSchema7Metadata {
10
+ /**
11
+ * The `$id` keyword is used to identify a schema and can be used for referencing the schema within other schemas. It is a URI that serves as a unique identifier for the schema.
12
+ *
13
+ * @see https://datatracker.ietf.org/doc/html/draft-handrews-json-schema-validation-01#section-8.2.1
14
+ */
15
+ $id?: string;
16
+ /**
17
+ * The `$schema` keyword is used to specify the version of the JSON Schema specification that the schema adheres to. It is a URI that indicates which version of the JSON Schema specification the schema is written against.
18
+ *
19
+ * @see https://datatracker.ietf.org/doc/html/draft-handrews-json-schema-validation-01#section-8.2.2
20
+ */
21
+ $schema?: string;
22
+ /**
23
+ * The `$comment` keyword is used to add comments to a JSON Schema. It allows schema authors to include human-readable explanations or notes within the schema without affecting its validation behavior.
24
+ *
25
+ * @see https://datatracker.ietf.org/doc/html/draft-handrews-json-schema-validation-01#section-8.2.3
26
+ */
27
+ $comment?: string;
28
+ /**
29
+ * The `$defs` keyword is used to define reusable sub-schemas within a JSON Schema. It allows you to define sub-schemas that can be referenced elsewhere in the schema using the `$ref` keyword. The `$defs` keyword is an object where each key is a unique identifier for the sub-schema, and the value is the sub-schema itself.
30
+ *
31
+ * @see https://datatracker.ietf.org/doc/html/draft-handrews-json-schema-validation-01#section-8.2.4
32
+ * @see https://datatracker.ietf.org/doc/html/draft-bhutton-json-schema-00#section-8.2.4
33
+ * @see https://datatracker.ietf.org/doc/html/draft-bhutton-json-schema-validation-00#appendix-A
34
+ */
35
+ $defs?: {
36
+ [key: string]: JsonSchema7Type;
37
+ };
38
+ /**
39
+ * The `name` keyword is a custom metadata property that can be used to provide a human-readable name for the schema. It is not part of the official JSON Schema specification but can be useful for documentation and identification purposes.
40
+ */
41
+ name?: string;
42
+ /**
43
+ * The `title` keyword is a custom metadata property that can be used to provide a human-readable title for the schema. It is not part of the official JSON Schema specification but can be useful for documentation and identification purposes.
44
+ */
45
+ title?: string;
46
+ /**
47
+ * The `default` keyword is used to specify a default value for a property in a JSON Schema. It provides a default value that can be used when an instance does not provide a value for that property.
48
+ *
49
+ * @see https://datatracker.ietf.org/doc/html/draft-handrews-json-schema-validation-01#section-8.2.5
50
+ */
51
+ default?: any;
52
+ /**
53
+ * The `description` keyword is used to provide a human-readable description of the schema or a specific property within the schema. It is not part of the official JSON Schema specification but can be useful for documentation purposes.
54
+ */
55
+ description?: string;
56
+ /**
57
+ * The `alias` keyword is a custom metadata property that can be used to provide alternative names or aliases for the schema. It is not part of the official JSON Schema specification but can be useful for documentation and identification purposes.
58
+ */
59
+ alias?: string | string[];
60
+ }
61
+ interface JsonSchema7AnyType extends JsonSchema7Metadata {
62
+ $ref?: string;
63
+ }
64
+ interface JsonSchema7ArrayType extends JsonSchema7Metadata {
65
+ type: "array";
66
+ items?: JsonSchema7Type;
67
+ minItems?: number;
68
+ maxItems?: number;
69
+ }
70
+ interface JsonSchema7BigintType extends JsonSchema7Metadata {
71
+ type: "integer";
72
+ format: "int64";
73
+ minimum?: bigint;
74
+ exclusiveMinimum?: bigint;
75
+ maximum?: bigint;
76
+ exclusiveMaximum?: bigint;
77
+ multipleOf?: bigint;
78
+ }
79
+ interface JsonSchema7BooleanType extends JsonSchema7Metadata {
80
+ type: "boolean";
81
+ }
82
+ type JsonSchema7DateType = JsonSchema7Metadata & ({
83
+ type: "integer" | "string";
84
+ format: "unix-time" | "date-time" | "date";
85
+ minimum?: number;
86
+ maximum?: number;
87
+ } | {
88
+ anyOf: JsonSchema7DateType[];
89
+ });
90
+ interface JsonSchema7EnumType extends JsonSchema7Metadata {
91
+ type: "string";
92
+ enum: string[];
93
+ }
94
+ interface JsonSchema7AllOfType extends JsonSchema7Metadata {
95
+ allOf: JsonSchema7Type[];
96
+ unevaluatedProperties?: boolean;
97
+ }
98
+ interface JsonSchema7PrimitiveLiteralType extends JsonSchema7Metadata {
99
+ type: "string" | "number" | "integer" | "boolean";
100
+ const: string | number | boolean;
101
+ }
102
+ type JsonSchema7LiteralType = JsonSchema7Metadata & (JsonSchema7PrimitiveLiteralType | {
103
+ type: "object" | "array";
104
+ });
105
+ interface JsonSchema7MapType extends JsonSchema7Metadata {
106
+ type: "array";
107
+ maxItems: 125;
108
+ items: {
109
+ type: "array";
110
+ items: [JsonSchema7Type, JsonSchema7Type];
111
+ minItems: 2;
112
+ maxItems: 2;
113
+ };
114
+ }
115
+ interface JsonSchema7NativeEnumType extends JsonSchema7Metadata {
116
+ type: "string" | "number" | ["string", "number"];
117
+ enum: (string | number)[];
118
+ }
119
+ interface JsonSchema7NeverType extends JsonSchema7Metadata {
120
+ not: JsonSchema7AnyType;
121
+ }
122
+ interface JsonSchema7NullType extends JsonSchema7Metadata {
123
+ type: "null";
124
+ }
125
+ type JsonSchema7NullableType = JsonSchema7Metadata & ({
126
+ anyOf: [JsonSchema7Type, JsonSchema7NullType];
127
+ } | {
128
+ type: [string, "null"];
129
+ });
130
+ interface JsonSchema7NumberType extends JsonSchema7Metadata {
131
+ type: "number" | "integer";
132
+ minimum?: number;
133
+ exclusiveMinimum?: number;
134
+ maximum?: number;
135
+ exclusiveMaximum?: number;
136
+ multipleOf?: number;
137
+ }
138
+ interface JsonSchema7ObjectType extends JsonSchema7Metadata {
139
+ type: "object";
140
+ properties: Record<string, JsonSchema7Type>;
141
+ additionalProperties?: boolean | JsonSchema7Type;
142
+ required?: string[];
143
+ }
144
+ interface JsonSchema7StringType extends JsonSchema7Metadata {
145
+ type: "string";
146
+ minLength?: number;
147
+ maxLength?: number;
148
+ format?: "email" | "idn-email" | "uri" | "uuid" | "date-time" | "ipv4" | "ipv6" | "date" | "time" | "duration";
149
+ pattern?: string;
150
+ contentEncoding?: string;
151
+ }
152
+ interface JsonSchema7SetType extends JsonSchema7Metadata {
153
+ type: "array";
154
+ uniqueItems: true;
155
+ items?: JsonSchema7Type;
156
+ minItems?: number;
157
+ maxItems?: number;
158
+ }
159
+ type JsonSchema7RecordPropertyNamesType = JsonSchema7Metadata & (Omit<JsonSchema7StringType, "type"> | Omit<JsonSchema7EnumType, "type">);
160
+ interface JsonSchema7RecordType extends JsonSchema7Metadata {
161
+ type: "object";
162
+ additionalProperties?: JsonSchema7Type | true;
163
+ propertyNames?: JsonSchema7RecordPropertyNamesType;
164
+ }
165
+ type JsonSchema7TupleType = JsonSchema7Metadata & {
166
+ type: "array";
167
+ minItems: number;
168
+ items: JsonSchema7Type[];
169
+ } & ({
170
+ maxItems: number;
171
+ } | {
172
+ additionalItems?: JsonSchema7Type;
173
+ });
174
+ interface JsonSchema7UndefinedType extends JsonSchema7Metadata {
175
+ not: JsonSchema7AnyType;
176
+ }
177
+ type JsonSchema7Primitive = "string" | "number" | "integer" | "boolean" | "null";
178
+ type JsonSchema7UnionType = JsonSchema7Metadata & (JsonSchema7PrimitiveUnionType | JsonSchema7AnyOfType);
179
+ type JsonSchema7PrimitiveUnionType = JsonSchema7Metadata & ({
180
+ type: JsonSchema7Primitive | JsonSchema7Primitive[];
181
+ } | {
182
+ type: JsonSchema7Primitive | JsonSchema7Primitive[];
183
+ enum: (string | number | bigint | boolean | null)[];
184
+ });
185
+ type JsonSchema7UnknownType = JsonSchema7Metadata & JsonSchema7AnyType;
186
+ interface JsonSchema7AnyOfType extends JsonSchema7Metadata {
187
+ anyOf: JsonSchema7Type[];
188
+ }
189
+ interface JsonSchema7RefType extends JsonSchema7Metadata {
190
+ $ref: string;
191
+ }
192
+ 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;
193
+ /**
194
+ * JSON Schema v7
195
+ * @see https://tools.ietf.org/html/draft-handrews-json-schema-validation-01
196
+ */
197
+ type JsonSchema7Type = JsonSchema7TypeUnion & JsonSchema7Metadata;
198
+ //#endregion
199
+ //#region src/schema.d.ts
200
+ interface ExtractJsonSchemaOptions {
201
+ /**
202
+ * The JSON Schema draft version to target. Defaults to "draft-07".
203
+ */
204
+ target?: "draft-07" | "draft-2020-12";
205
+ /**
206
+ * Whether to include the input or output schema for Zod schemas.
207
+ *
208
+ * @remarks
209
+ */
210
+ io?: "input" | "output";
211
+ }
212
+ /**
213
+ * Extracts a JSON Schema from a given Zod schema, supporting both version 3 and version 4 of Zod.
214
+ *
215
+ * @param type - The Zod schema to extract the JSON Schema from. Can be either a Zod v3 or v4 schema.
216
+ * @param options - Options for extracting the JSON Schema, including the target draft version and input/output selection.
217
+ * @returns The extracted JSON Schema.
218
+ */
219
+ declare function extractJsonSchema(type: ZodType, options?: ExtractJsonSchemaOptions): (object & {
220
+ $schema?: string | undefined;
221
+ definitions?: {
222
+ [key: string]: zod_to_json_schema0.JsonSchema7Type;
223
+ } | undefined;
224
+ }) | z4.ZodStandardJSONSchemaPayload<z4.$ZodType<unknown, unknown, z4.$ZodTypeInternals<unknown, unknown>>>;
225
+ /**
226
+ * Extracts a JSON Schema (draft-07) from a given Zod schema, supporting both version 3 and version 4 of Zod.
227
+ *
228
+ * @remarks
229
+ * This function is a convenience wrapper around `extractJsonSchema` that defaults to targeting the JSON Schema draft-07 specification.
230
+ *
231
+ * @param type - The Zod schema to extract the JSON Schema from. Can be either a Zod v3 or v4 schema.
232
+ * @returns The extracted JSON Schema.
233
+ */
234
+ declare function extractJsonSchema7(type: ZodType): JsonSchema7Type;
235
+ //#endregion
236
+ export { extractJsonSchema as n, extractJsonSchema7 as r, ExtractJsonSchemaOptions as t };
237
+ //# sourceMappingURL=schema-CM-MXRuJ.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"schema-CM-MXRuJ.d.mts","names":[],"sources":["../../json/src/types.ts","../src/schema.ts"],"sourcesContent":[],"mappings":";;;;;;;;AA2W4C,UA3O3B,mBAAA,CA2O2B;EAG9B;;;;;EAQF,GAAA,CAAA,EAAA,MAAA;EAEK;AAIjB;AAIA;;;EAGI,OAAA,CAAA,EAAA,MAAA;EACA;;;;;EAKA,QAAA,CAAA,EAAA,MAAA;EACA;;;;;;;EAOA,KAAA,CAAA,EAAA;IACA,CAAA,GAAA,EAAA,MAAA,CAAA,EApPe,eAoPf;EACA,CAAA;EACA;;;EAGA,IAAA,CAAA,EAAA,MAAA;EACA;;AAMJ;;;;ACtYA;AAqBA;;EAEW,OAAA,CAAA,EAAA,GAAA;EAA6B;;;;;AAuCxC;;;;UDuGiB,kBAAA,SAA2B;;;UAI3B,oBAAA,SAA6B;;UAEpC;;;;UAKO,qBAAA,SAA8B;;;;;;;;;UAU9B,sBAAA,SAA+B;;;KAIpC,mBAAA,GAAsB;;;;;;SASnB;;UAIE,mBAAA,SAA4B;;;;UAK5B,oBAAA,SAA6B;SACrC;;;UAIQ,+BAAA,SAAwC;;;;KAK7C,sBAAA,GAAyB,uBAE/B;;;UAMW,kBAAA,SAA2B;;;;;YAKhC,iBAAiB;;;;;UAMZ,yBAAA,SAAkC;;;;UAKlC,oBAAA,SAA6B;OACvC;;UAGU,mBAAA,SAA4B;;;KAIjC,uBAAA,GAA0B;UAGtB,iBAAiB;;;;UAOhB,qBAAA,SAA8B;;;;;;;;UAS9B,qBAAA,SAA8B;;cAEjC,eAAe;mCACM;;;UAIlB,qBAAA,SAA8B;;;;;;;;UAmB9B,kBAAA,SAA2B;;;UAGlC;;;;KAKE,kCAAA,GAAqC,uBAC9C,KAAK,iCAAiC,KAAK;UAE7B,qBAAA,SAA8B;;yBAEtB;kBACP;;KAGN,oBAAA,GAAuB;;;SAG1B;;;;oBAMiB;;UAIT,wBAAA,SAAiC;OAC3C;;KAGK,oBAAA;KAOA,oBAAA,GAAuB,uBAChC,gCAAgC;KAEvB,6BAAA,GAAgC;QAG9B,uBAAuB;;QAGvB,uBAAuB;;;KAKzB,sBAAA,GAAyB,sBAAsB;UAE1C,oBAAA,SAA6B;SACrC;;UAGQ,kBAAA,SAA2B;;;KAIhC,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;;;UCtYpC,wBAAA;;;;EDwGA,MAAA,CAAA,EAAA,UAAA,GAAmB,eA8BjB;EA+BF;AAIjB;AAOA;AAUA;AAIA;EAaiB,EAAA,CAAA,EAAA,OAAA,GAAA,QAAoB;AAKrC;AAKA;AAKA;AAQA;;;;;AAWiB,iBCxND,iBAAA,CDwN2B,IAAQ,ECvN3C,ODuN2C,EAAA,OAAmB,CAAA,ECtN3D,wBDsN2D,CAAA,EAAA,CAAA,MAAA,GAAA;EAKrD,OAAA,CAAA,EAAA,MAAA,GAAA,SAAqB;EAIrB,WAAA,CAAA,EAAA;IAIL,CAAA,GAAA,EAAA,MAAA,CAAA,ECnO4B,mBAAA,CAAA,eDmOL;EAAG,CAAA,GAAA,SAAA;CAGtB,CAAA,kCAAA,YAAA,CAAA,OAAA,EAAA,OAAA,sBAAA,CAAA,OAAA,EAAA,OAAA,CAAA,CAAA,CAAA;;;AAOhB;AASA;;;;;;AAOiB,iBCtND,kBAAA,CDsN+B,IAAA,ECtNN,ODsNM,CAAA,ECrNa,eDqNM"}
@@ -35,10 +35,11 @@ zod_v4_core = __toESM(zod_v4_core);
35
35
  * Extracts a JSON Schema from a given Zod schema, supporting both version 3 and version 4 of Zod.
36
36
  *
37
37
  * @param type - The Zod schema to extract the JSON Schema from. Can be either a Zod v3 or v4 schema.
38
- * @param target - The JSON Schema draft version to target. Defaults to "draft-07".
38
+ * @param options - Options for extracting the JSON Schema, including the target draft version and input/output selection.
39
39
  * @returns The extracted JSON Schema.
40
40
  */
41
- function extractJsonSchema(type, target = "draft-07") {
41
+ function extractJsonSchema(type, options = {}) {
42
+ const { target = "draft-07", io = "input" } = options;
42
43
  if (require_is_zod_type.isZod3Type(type)) {
43
44
  const result = (0, zod_to_json_schema.zodToJsonSchema)(type, {
44
45
  $refStrategy: "root",
@@ -46,7 +47,8 @@ function extractJsonSchema(type, target = "draft-07") {
46
47
  target: target === "draft-07" ? "jsonSchema7" : "jsonSchema2019-09",
47
48
  mapStrategy: "entries",
48
49
  errorMessages: false,
49
- markdownDescription: false
50
+ markdownDescription: false,
51
+ pipeStrategy: io
50
52
  });
51
53
  if (!result) throw new Error("Failed to extract JSON Schema from Zod v3 schema");
52
54
  return result;
@@ -67,7 +69,7 @@ function extractJsonSchema(type, target = "draft-07") {
67
69
  * @returns The extracted JSON Schema.
68
70
  */
69
71
  function extractJsonSchema7(type) {
70
- return extractJsonSchema(type, "draft-07");
72
+ return extractJsonSchema(type, { target: "draft-07" });
71
73
  }
72
74
 
73
75
  //#endregion
@@ -0,0 +1,235 @@
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 JsonSchema7Metadata {
8
+ /**
9
+ * The `$id` keyword is used to identify a schema and can be used for referencing the schema within other schemas. It is a URI that serves as a unique identifier for the schema.
10
+ *
11
+ * @see https://datatracker.ietf.org/doc/html/draft-handrews-json-schema-validation-01#section-8.2.1
12
+ */
13
+ $id?: string;
14
+ /**
15
+ * The `$schema` keyword is used to specify the version of the JSON Schema specification that the schema adheres to. It is a URI that indicates which version of the JSON Schema specification the schema is written against.
16
+ *
17
+ * @see https://datatracker.ietf.org/doc/html/draft-handrews-json-schema-validation-01#section-8.2.2
18
+ */
19
+ $schema?: string;
20
+ /**
21
+ * The `$comment` keyword is used to add comments to a JSON Schema. It allows schema authors to include human-readable explanations or notes within the schema without affecting its validation behavior.
22
+ *
23
+ * @see https://datatracker.ietf.org/doc/html/draft-handrews-json-schema-validation-01#section-8.2.3
24
+ */
25
+ $comment?: string;
26
+ /**
27
+ * The `$defs` keyword is used to define reusable sub-schemas within a JSON Schema. It allows you to define sub-schemas that can be referenced elsewhere in the schema using the `$ref` keyword. The `$defs` keyword is an object where each key is a unique identifier for the sub-schema, and the value is the sub-schema itself.
28
+ *
29
+ * @see https://datatracker.ietf.org/doc/html/draft-handrews-json-schema-validation-01#section-8.2.4
30
+ * @see https://datatracker.ietf.org/doc/html/draft-bhutton-json-schema-00#section-8.2.4
31
+ * @see https://datatracker.ietf.org/doc/html/draft-bhutton-json-schema-validation-00#appendix-A
32
+ */
33
+ $defs?: {
34
+ [key: string]: JsonSchema7Type;
35
+ };
36
+ /**
37
+ * The `name` keyword is a custom metadata property that can be used to provide a human-readable name for the schema. It is not part of the official JSON Schema specification but can be useful for documentation and identification purposes.
38
+ */
39
+ name?: string;
40
+ /**
41
+ * The `title` keyword is a custom metadata property that can be used to provide a human-readable title for the schema. It is not part of the official JSON Schema specification but can be useful for documentation and identification purposes.
42
+ */
43
+ title?: string;
44
+ /**
45
+ * The `default` keyword is used to specify a default value for a property in a JSON Schema. It provides a default value that can be used when an instance does not provide a value for that property.
46
+ *
47
+ * @see https://datatracker.ietf.org/doc/html/draft-handrews-json-schema-validation-01#section-8.2.5
48
+ */
49
+ default?: any;
50
+ /**
51
+ * The `description` keyword is used to provide a human-readable description of the schema or a specific property within the schema. It is not part of the official JSON Schema specification but can be useful for documentation purposes.
52
+ */
53
+ description?: string;
54
+ /**
55
+ * The `alias` keyword is a custom metadata property that can be used to provide alternative names or aliases for the schema. It is not part of the official JSON Schema specification but can be useful for documentation and identification purposes.
56
+ */
57
+ alias?: string | string[];
58
+ }
59
+ interface JsonSchema7AnyType extends JsonSchema7Metadata {
60
+ $ref?: string;
61
+ }
62
+ interface JsonSchema7ArrayType extends JsonSchema7Metadata {
63
+ type: "array";
64
+ items?: JsonSchema7Type;
65
+ minItems?: number;
66
+ maxItems?: number;
67
+ }
68
+ interface JsonSchema7BigintType extends JsonSchema7Metadata {
69
+ type: "integer";
70
+ format: "int64";
71
+ minimum?: bigint;
72
+ exclusiveMinimum?: bigint;
73
+ maximum?: bigint;
74
+ exclusiveMaximum?: bigint;
75
+ multipleOf?: bigint;
76
+ }
77
+ interface JsonSchema7BooleanType extends JsonSchema7Metadata {
78
+ type: "boolean";
79
+ }
80
+ type JsonSchema7DateType = JsonSchema7Metadata & ({
81
+ type: "integer" | "string";
82
+ format: "unix-time" | "date-time" | "date";
83
+ minimum?: number;
84
+ maximum?: number;
85
+ } | {
86
+ anyOf: JsonSchema7DateType[];
87
+ });
88
+ interface JsonSchema7EnumType extends JsonSchema7Metadata {
89
+ type: "string";
90
+ enum: string[];
91
+ }
92
+ interface JsonSchema7AllOfType extends JsonSchema7Metadata {
93
+ allOf: JsonSchema7Type[];
94
+ unevaluatedProperties?: boolean;
95
+ }
96
+ interface JsonSchema7PrimitiveLiteralType extends JsonSchema7Metadata {
97
+ type: "string" | "number" | "integer" | "boolean";
98
+ const: string | number | boolean;
99
+ }
100
+ type JsonSchema7LiteralType = JsonSchema7Metadata & (JsonSchema7PrimitiveLiteralType | {
101
+ type: "object" | "array";
102
+ });
103
+ interface JsonSchema7MapType extends JsonSchema7Metadata {
104
+ type: "array";
105
+ maxItems: 125;
106
+ items: {
107
+ type: "array";
108
+ items: [JsonSchema7Type, JsonSchema7Type];
109
+ minItems: 2;
110
+ maxItems: 2;
111
+ };
112
+ }
113
+ interface JsonSchema7NativeEnumType extends JsonSchema7Metadata {
114
+ type: "string" | "number" | ["string", "number"];
115
+ enum: (string | number)[];
116
+ }
117
+ interface JsonSchema7NeverType extends JsonSchema7Metadata {
118
+ not: JsonSchema7AnyType;
119
+ }
120
+ interface JsonSchema7NullType extends JsonSchema7Metadata {
121
+ type: "null";
122
+ }
123
+ type JsonSchema7NullableType = JsonSchema7Metadata & ({
124
+ anyOf: [JsonSchema7Type, JsonSchema7NullType];
125
+ } | {
126
+ type: [string, "null"];
127
+ });
128
+ interface JsonSchema7NumberType extends JsonSchema7Metadata {
129
+ type: "number" | "integer";
130
+ minimum?: number;
131
+ exclusiveMinimum?: number;
132
+ maximum?: number;
133
+ exclusiveMaximum?: number;
134
+ multipleOf?: number;
135
+ }
136
+ interface JsonSchema7ObjectType extends JsonSchema7Metadata {
137
+ type: "object";
138
+ properties: Record<string, JsonSchema7Type>;
139
+ additionalProperties?: boolean | JsonSchema7Type;
140
+ required?: string[];
141
+ }
142
+ interface JsonSchema7StringType extends JsonSchema7Metadata {
143
+ type: "string";
144
+ minLength?: number;
145
+ maxLength?: number;
146
+ format?: "email" | "idn-email" | "uri" | "uuid" | "date-time" | "ipv4" | "ipv6" | "date" | "time" | "duration";
147
+ pattern?: string;
148
+ contentEncoding?: string;
149
+ }
150
+ interface JsonSchema7SetType extends JsonSchema7Metadata {
151
+ type: "array";
152
+ uniqueItems: true;
153
+ items?: JsonSchema7Type;
154
+ minItems?: number;
155
+ maxItems?: number;
156
+ }
157
+ type JsonSchema7RecordPropertyNamesType = JsonSchema7Metadata & (Omit<JsonSchema7StringType, "type"> | Omit<JsonSchema7EnumType, "type">);
158
+ interface JsonSchema7RecordType extends JsonSchema7Metadata {
159
+ type: "object";
160
+ additionalProperties?: JsonSchema7Type | true;
161
+ propertyNames?: JsonSchema7RecordPropertyNamesType;
162
+ }
163
+ type JsonSchema7TupleType = JsonSchema7Metadata & {
164
+ type: "array";
165
+ minItems: number;
166
+ items: JsonSchema7Type[];
167
+ } & ({
168
+ maxItems: number;
169
+ } | {
170
+ additionalItems?: JsonSchema7Type;
171
+ });
172
+ interface JsonSchema7UndefinedType extends JsonSchema7Metadata {
173
+ not: JsonSchema7AnyType;
174
+ }
175
+ type JsonSchema7Primitive = "string" | "number" | "integer" | "boolean" | "null";
176
+ type JsonSchema7UnionType = JsonSchema7Metadata & (JsonSchema7PrimitiveUnionType | JsonSchema7AnyOfType);
177
+ type JsonSchema7PrimitiveUnionType = JsonSchema7Metadata & ({
178
+ type: JsonSchema7Primitive | JsonSchema7Primitive[];
179
+ } | {
180
+ type: JsonSchema7Primitive | JsonSchema7Primitive[];
181
+ enum: (string | number | bigint | boolean | null)[];
182
+ });
183
+ type JsonSchema7UnknownType = JsonSchema7Metadata & JsonSchema7AnyType;
184
+ interface JsonSchema7AnyOfType extends JsonSchema7Metadata {
185
+ anyOf: JsonSchema7Type[];
186
+ }
187
+ interface JsonSchema7RefType extends JsonSchema7Metadata {
188
+ $ref: string;
189
+ }
190
+ 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;
191
+ /**
192
+ * JSON Schema v7
193
+ * @see https://tools.ietf.org/html/draft-handrews-json-schema-validation-01
194
+ */
195
+ type JsonSchema7Type = JsonSchema7TypeUnion & JsonSchema7Metadata;
196
+ //#endregion
197
+ //#region src/schema.d.ts
198
+ interface ExtractJsonSchemaOptions {
199
+ /**
200
+ * The JSON Schema draft version to target. Defaults to "draft-07".
201
+ */
202
+ target?: "draft-07" | "draft-2020-12";
203
+ /**
204
+ * Whether to include the input or output schema for Zod schemas.
205
+ *
206
+ * @remarks
207
+ */
208
+ io?: "input" | "output";
209
+ }
210
+ /**
211
+ * Extracts a JSON Schema from a given Zod schema, supporting both version 3 and version 4 of Zod.
212
+ *
213
+ * @param type - The Zod schema to extract the JSON Schema from. Can be either a Zod v3 or v4 schema.
214
+ * @param options - Options for extracting the JSON Schema, including the target draft version and input/output selection.
215
+ * @returns The extracted JSON Schema.
216
+ */
217
+ declare function extractJsonSchema(type: ZodType, options?: ExtractJsonSchemaOptions): (object & {
218
+ $schema?: string | undefined;
219
+ definitions?: {
220
+ [key: string]: zod_to_json_schema0.JsonSchema7Type;
221
+ } | undefined;
222
+ }) | z4.ZodStandardJSONSchemaPayload<z4.$ZodType<unknown, unknown, z4.$ZodTypeInternals<unknown, unknown>>>;
223
+ /**
224
+ * Extracts a JSON Schema (draft-07) from a given Zod schema, supporting both version 3 and version 4 of Zod.
225
+ *
226
+ * @remarks
227
+ * This function is a convenience wrapper around `extractJsonSchema` that defaults to targeting the JSON Schema draft-07 specification.
228
+ *
229
+ * @param type - The Zod schema to extract the JSON Schema from. Can be either a Zod v3 or v4 schema.
230
+ * @returns The extracted JSON Schema.
231
+ */
232
+ declare function extractJsonSchema7(type: ZodType): JsonSchema7Type;
233
+ //#endregion
234
+ export { extractJsonSchema as n, extractJsonSchema7 as r, ExtractJsonSchemaOptions as t };
235
+ //# sourceMappingURL=schema-r-i8wUJm.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"schema-r-i8wUJm.d.cts","names":[],"sources":["../../json/src/types.ts","../src/schema.ts"],"sourcesContent":[],"mappings":";;;;;;AA8WqC,UA9OpB,mBAAA,CA8OoB;EAGvB;;;AAKd;AAEA;EAIiB,GAAA,CAAA,EAAA,MAAA;EAIL;;;;;EAKR,OAAA,CAAA,EAAA,MAAA;EACA;;;;;EAKA,QAAA,CAAA,EAAA,MAAA;EACA;;;;;;;EAOA,KAAA,CAAA,EAAA;IACA,CAAA,GAAA,EAAA,MAAA,CAAA,EAtPe,eAsPf;EACA,CAAA;EACA;;;EAEkB,IAAA,CAAA,EAAA,MAAA;EAMV;;;;ECtYK;AAqBjB;;;;;;;;EAyCgB,WAAA,CAAA,EAAA,MAAA;;;;;;UDuGC,kBAAA,SAA2B;;;UAI3B,oBAAA,SAA6B;;UAEpC;;;;UAKO,qBAAA,SAA8B;;;;;;;;;UAU9B,sBAAA,SAA+B;;;KAIpC,mBAAA,GAAsB;;;;;;SASnB;;UAIE,mBAAA,SAA4B;;;;UAK5B,oBAAA,SAA6B;SACrC;;;UAIQ,+BAAA,SAAwC;;;;KAK7C,sBAAA,GAAyB,uBAE/B;;;UAMW,kBAAA,SAA2B;;;;;YAKhC,iBAAiB;;;;;UAMZ,yBAAA,SAAkC;;;;UAKlC,oBAAA,SAA6B;OACvC;;UAGU,mBAAA,SAA4B;;;KAIjC,uBAAA,GAA0B;UAGtB,iBAAiB;;;;UAOhB,qBAAA,SAA8B;;;;;;;;UAS9B,qBAAA,SAA8B;;cAEjC,eAAe;mCACM;;;UAIlB,qBAAA,SAA8B;;;;;;;;UAmB9B,kBAAA,SAA2B;;;UAGlC;;;;KAKE,kCAAA,GAAqC,uBAC9C,KAAK,iCAAiC,KAAK;UAE7B,qBAAA,SAA8B;;yBAEtB;kBACP;;KAGN,oBAAA,GAAuB;;;SAG1B;;;;oBAMiB;;UAIT,wBAAA,SAAiC;OAC3C;;KAGK,oBAAA;KAOA,oBAAA,GAAuB,uBAChC,gCAAgC;KAEvB,6BAAA,GAAgC;QAG9B,uBAAuB;;QAGvB,uBAAuB;;;KAKzB,sBAAA,GAAyB,sBAAsB;UAE1C,oBAAA,SAA6B;SACrC;;UAGQ,kBAAA,SAA2B;;;KAIhC,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;;;UCtYpC,wBAAA;;ADwGjB;AA6DA;EAIiB,MAAA,CAAA,EAAA,UAAA,GAAA,eAEP;EAKO;AAUjB;AAIA;AAaA;AAKA;EAKiB,EAAA,CAAA,EAAA,OAAA,GAAA,QAAA;AAKjB;AAQA;;;;;AAWA;AAKA;AAIiB,iBCjOD,iBAAA,CDiO6B,IAAA,EChOrC,ODgOqC,EAAA,OAAmB,CAAA,EC/NrD,wBD+NqD,CAAA,EAAA,CAAA,MAAA,GAAA;EAIpD,OAAA,CAAA,EAAA,MAAA,GAAA,SAAuB;EAAG,WAAA,CAAA,EAAA;IAGtB,CAAA,GAAA,EAAA,MAAA,CAAA,ECtOwB,mBAAA,CAAA,eDsOxB;EAAiB,CAAA,GAAA,SAAA;CAAmB,CAAA,kCAAA,YAAA,CAAA,OAAA,EAAA,OAAA,sBAAA,CAAA,OAAA,EAAA,OAAA,CAAA,CAAA,CAAA;AAOpD;AASA;;;;;;AAOA;AAmBA;AAQY,iBCjPI,kBAAA,CDiP8B,IAAA,ECjPL,ODiPK,CAAA,EChPc,eDgPd"}
package/dist/schema.cjs CHANGED
@@ -1,4 +1,4 @@
1
- const require_schema = require('./schema-C9c6yHpZ.cjs');
1
+ const require_schema = require('./schema-DYckL2kJ.cjs');
2
2
 
3
3
  exports.extractJsonSchema = require_schema.extractJsonSchema;
4
4
  exports.extractJsonSchema7 = require_schema.extractJsonSchema7;
package/dist/schema.d.cts CHANGED
@@ -1,2 +1,2 @@
1
- import { n as extractJsonSchema7, t as extractJsonSchema } from "./schema-DAmyxbgH.cjs";
2
- export { extractJsonSchema, extractJsonSchema7 };
1
+ import { n as extractJsonSchema, r as extractJsonSchema7, t as ExtractJsonSchemaOptions } from "./schema-r-i8wUJm.cjs";
2
+ export { ExtractJsonSchemaOptions, extractJsonSchema, extractJsonSchema7 };
package/dist/schema.d.mts CHANGED
@@ -1,3 +1,3 @@
1
1
  import "./types-DWWjtQA0.mjs";
2
- import { n as extractJsonSchema7, t as extractJsonSchema } from "./schema-DJs6pbWQ.mjs";
3
- export { extractJsonSchema, extractJsonSchema7 };
2
+ import { n as extractJsonSchema, r as extractJsonSchema7, t as ExtractJsonSchemaOptions } from "./schema-CM-MXRuJ.mjs";
3
+ export { ExtractJsonSchemaOptions, extractJsonSchema, extractJsonSchema7 };
package/dist/schema.mjs CHANGED
@@ -1,3 +1,3 @@
1
- import { n as extractJsonSchema7, t as extractJsonSchema } from "./schema-XGYh6TgB.mjs";
1
+ import { n as extractJsonSchema7, t as extractJsonSchema } from "./schema-BscDIlVR.mjs";
2
2
 
3
3
  export { extractJsonSchema, extractJsonSchema7 };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stryke/zod",
3
- "version": "0.2.4",
3
+ "version": "0.3.1",
4
4
  "type": "module",
5
5
  "description": "A package containing helper utilities for working with zod schemas.",
6
6
  "repository": {
@@ -70,14 +70,14 @@
70
70
  "peerDependencies": { "zod": "^3.25.0 || ^4.0.0" },
71
71
  "peerDependenciesMeta": { "zod": { "optional": true } },
72
72
  "dependencies": {
73
- "@stryke/type-checks": "^0.5.30",
73
+ "@stryke/type-checks": "^0.5.31",
74
74
  "zod-to-json-schema": "^3.25.1"
75
75
  },
76
76
  "devDependencies": {
77
- "@stryke/json": "^0.13.0",
77
+ "@stryke/json": "^0.14.0",
78
78
  "tsdown": "^0.17.2",
79
79
  "zod": "^4.3.6"
80
80
  },
81
81
  "publishConfig": { "access": "public" },
82
- "gitHead": "793c21dcc2c0734890ffe5e40bd69683455dc301"
82
+ "gitHead": "1405021e71e320bcc0d7800ec36947f69055e91a"
83
83
  }
@@ -1,187 +0,0 @@
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
- interface JsonSchema7PrimitiveLiteralType {
45
- type: "string" | "number" | "integer" | "boolean";
46
- const: string | number | boolean;
47
- }
48
- type JsonSchema7LiteralType = JsonSchema7PrimitiveLiteralType | {
49
- type: "object" | "array";
50
- };
51
- interface JsonSchema7MapType {
52
- type: "array";
53
- maxItems: 125;
54
- items: {
55
- type: "array";
56
- items: [JsonSchema7Type, JsonSchema7Type];
57
- minItems: 2;
58
- maxItems: 2;
59
- };
60
- }
61
- interface JsonSchema7NativeEnumType {
62
- type: "string" | "number" | ["string", "number"];
63
- enum: (string | number)[];
64
- }
65
- interface JsonSchema7NeverType {
66
- not: JsonSchema7AnyType;
67
- }
68
- interface JsonSchema7NullType {
69
- type: "null";
70
- }
71
- type JsonSchema7NullableType = {
72
- anyOf: [JsonSchema7Type, JsonSchema7NullType];
73
- } | {
74
- type: [string, "null"];
75
- };
76
- interface JsonSchema7NumberType {
77
- type: "number" | "integer";
78
- minimum?: number;
79
- exclusiveMinimum?: number;
80
- maximum?: number;
81
- exclusiveMaximum?: number;
82
- multipleOf?: number;
83
- }
84
- interface JsonSchema7ObjectType {
85
- type: "object";
86
- properties: Record<string, JsonSchema7Type>;
87
- additionalProperties?: boolean | JsonSchema7Type;
88
- required?: string[];
89
- }
90
- interface JsonSchema7StringType {
91
- type: "string";
92
- minLength?: number;
93
- maxLength?: number;
94
- format?: "email" | "idn-email" | "uri" | "uuid" | "date-time" | "ipv4" | "ipv6" | "date" | "time" | "duration";
95
- pattern?: string;
96
- contentEncoding?: string;
97
- }
98
- interface JsonSchema7SetType {
99
- type: "array";
100
- uniqueItems: true;
101
- items?: JsonSchema7Type;
102
- minItems?: number;
103
- maxItems?: number;
104
- }
105
- type JsonSchema7RecordPropertyNamesType = Omit<JsonSchema7StringType, "type"> | Omit<JsonSchema7EnumType, "type">;
106
- interface JsonSchema7RecordType {
107
- type: "object";
108
- additionalProperties?: JsonSchema7Type | true;
109
- propertyNames?: JsonSchema7RecordPropertyNamesType;
110
- }
111
- type JsonSchema7TupleType = {
112
- type: "array";
113
- minItems: number;
114
- items: JsonSchema7Type[];
115
- } & ({
116
- maxItems: number;
117
- } | {
118
- additionalItems?: JsonSchema7Type;
119
- });
120
- interface JsonSchema7UndefinedType {
121
- not: JsonSchema7AnyType;
122
- }
123
- type JsonSchema7Primitive = "string" | "number" | "integer" | "boolean" | "null";
124
- type JsonSchema7UnionType = JsonSchema7PrimitiveUnionType | JsonSchema7AnyOfType;
125
- type JsonSchema7PrimitiveUnionType = {
126
- type: JsonSchema7Primitive | JsonSchema7Primitive[];
127
- } | {
128
- type: JsonSchema7Primitive | JsonSchema7Primitive[];
129
- enum: (string | number | bigint | boolean | null)[];
130
- };
131
- type JsonSchema7UnknownType = JsonSchema7AnyType;
132
- interface JsonSchema7AnyOfType {
133
- anyOf: JsonSchema7Type[];
134
- }
135
- interface JsonSchema7RefType {
136
- $ref: string;
137
- }
138
- interface JsonSchema7Meta {
139
- $id?: string;
140
- $ref?: string;
141
- $schema?: string;
142
- $comment?: string;
143
- title?: string;
144
- default?: any;
145
- description?: 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-DAmyxbgH.d.cts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"schema-DAmyxbgH.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;;AACkB,UA7NL,qBAAA,CA6NK;EAMV,IAAA,EAAA,SAAA;;;;EC/UI,OAAA,CAAA,EAAA,MAAA;EACR,gBAAA,CAAA,EAAA,MAAA;EAAO,UAAA,CAAA,EAAA,MAAA;;UDqHE,sBAAA;;;AChFD,KDoFJ,mBAAA,GCpFsB;;;;;;SD4FrB;;UAGI,mBAAA;;;;UAKA,oBAAA;SACR;;;UAIQ,+BAAA;;;;KAKL,sBAAA,GACR;;;UAKa,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;;;;;;;;;;;;;mBAeE;;;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;;;;;AA9OrD;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;EAKpB,WAAA,CAAA,EAAA;IAKL,CAAA,GAAA,EAAA,MAAA,CAAA,ECnJG,mBAAA,CAAA,eDoJX;EAKa,CAAA,GAAA,SAAA;AAWjB,CAAA,CAAA,kCAA0C,YAAA,CAAA,OAAA,EAAA,OAAA,sBAAA,CAAA,OAAA,EAAA,OAAA,CAAA,CAAA,CAAA;AAK1C;AAIA;AAIA;AAQA;AASA;;;;;AAOiB,iBCpKD,kBAAA,CDoKsB,IAAA,ECpKG,ODoKH,CAAA,ECnKU,eDmKV"}
@@ -1,189 +0,0 @@
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
- interface JsonSchema7PrimitiveLiteralType {
47
- type: "string" | "number" | "integer" | "boolean";
48
- const: string | number | boolean;
49
- }
50
- type JsonSchema7LiteralType = JsonSchema7PrimitiveLiteralType | {
51
- type: "object" | "array";
52
- };
53
- interface JsonSchema7MapType {
54
- type: "array";
55
- maxItems: 125;
56
- items: {
57
- type: "array";
58
- items: [JsonSchema7Type, JsonSchema7Type];
59
- minItems: 2;
60
- maxItems: 2;
61
- };
62
- }
63
- interface JsonSchema7NativeEnumType {
64
- type: "string" | "number" | ["string", "number"];
65
- enum: (string | number)[];
66
- }
67
- interface JsonSchema7NeverType {
68
- not: JsonSchema7AnyType;
69
- }
70
- interface JsonSchema7NullType {
71
- type: "null";
72
- }
73
- type JsonSchema7NullableType = {
74
- anyOf: [JsonSchema7Type, JsonSchema7NullType];
75
- } | {
76
- type: [string, "null"];
77
- };
78
- interface JsonSchema7NumberType {
79
- type: "number" | "integer";
80
- minimum?: number;
81
- exclusiveMinimum?: number;
82
- maximum?: number;
83
- exclusiveMaximum?: number;
84
- multipleOf?: number;
85
- }
86
- interface JsonSchema7ObjectType {
87
- type: "object";
88
- properties: Record<string, JsonSchema7Type>;
89
- additionalProperties?: boolean | JsonSchema7Type;
90
- required?: string[];
91
- }
92
- interface JsonSchema7StringType {
93
- type: "string";
94
- minLength?: number;
95
- maxLength?: number;
96
- format?: "email" | "idn-email" | "uri" | "uuid" | "date-time" | "ipv4" | "ipv6" | "date" | "time" | "duration";
97
- pattern?: string;
98
- contentEncoding?: string;
99
- }
100
- interface JsonSchema7SetType {
101
- type: "array";
102
- uniqueItems: true;
103
- items?: JsonSchema7Type;
104
- minItems?: number;
105
- maxItems?: number;
106
- }
107
- type JsonSchema7RecordPropertyNamesType = Omit<JsonSchema7StringType, "type"> | Omit<JsonSchema7EnumType, "type">;
108
- interface JsonSchema7RecordType {
109
- type: "object";
110
- additionalProperties?: JsonSchema7Type | true;
111
- propertyNames?: JsonSchema7RecordPropertyNamesType;
112
- }
113
- type JsonSchema7TupleType = {
114
- type: "array";
115
- minItems: number;
116
- items: JsonSchema7Type[];
117
- } & ({
118
- maxItems: number;
119
- } | {
120
- additionalItems?: JsonSchema7Type;
121
- });
122
- interface JsonSchema7UndefinedType {
123
- not: JsonSchema7AnyType;
124
- }
125
- type JsonSchema7Primitive = "string" | "number" | "integer" | "boolean" | "null";
126
- type JsonSchema7UnionType = JsonSchema7PrimitiveUnionType | JsonSchema7AnyOfType;
127
- type JsonSchema7PrimitiveUnionType = {
128
- type: JsonSchema7Primitive | JsonSchema7Primitive[];
129
- } | {
130
- type: JsonSchema7Primitive | JsonSchema7Primitive[];
131
- enum: (string | number | bigint | boolean | null)[];
132
- };
133
- type JsonSchema7UnknownType = JsonSchema7AnyType;
134
- interface JsonSchema7AnyOfType {
135
- anyOf: JsonSchema7Type[];
136
- }
137
- interface JsonSchema7RefType {
138
- $ref: string;
139
- }
140
- interface JsonSchema7Meta {
141
- $id?: string;
142
- $ref?: string;
143
- $schema?: string;
144
- $comment?: string;
145
- title?: string;
146
- default?: any;
147
- description?: 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-DJs6pbWQ.d.mts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"schema-DJs6pbWQ.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;EACA,IAAA,EAAA,SAAA;EAAkB,MAAA,EAAA,OAAA;EAMV,OAAA,CAAA,EAAA,MAAA;;;;EC/UI,UAAA,CAAA,EAAA,MAAA;;AACD,UDqHE,sBAAA,CCrHF;;;KDyHH,mBAAA;;ECpFI,MAAA,EAAA,WAAA,GAAkB,WAAO,GAAA,MACO;;;;SD2FnC;;UAGI,mBAAA;;;;UAKA,oBAAA;SACR;;;UAIQ,+BAAA;;;;KAKL,sBAAA,GACR;;;UAKa,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;;;;;;;;;;;;;mBAeE;;;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;;;;;;;AA9OrD;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;EAIP,CAAA,GAAA,SAAA;AAKjB,CAAA,CAAA,kCAAkC,YAC9B,CAAA,OAAA,EAAA,OAAA,sBAA+B,CAAA,OAAA,EAAA,OAAA,CAAA,CAAA,CAAA;AAKnC;AAWA;AAKA;AAIA;AAIA;AAQA;AASA;;;AAGmC,iBChKnB,kBAAA,CDgKmB,IAAA,EChKM,ODgKN,CAAA,EC/Ja,eD+Jb"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"schema-XGYh6TgB.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 mapStrategy: \"entries\",\n errorMessages: false,\n markdownDescription: false\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 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;GAChD,aAAa;GACb,eAAe;GACf,qBAAqB;GACtB,CAAC;AACF,MAAI,CAAC,OACH,OAAM,IAAI,MAAM,mDAAmD;AAGrE,SAAO;YACE,WAAW,KAAK,CACzB,QAAO,GAAG,aAAa,MAAM;EAC3B,QAAQ,WAAW,aAAa,aAAa;EAC7C,iBAAiB;EACjB,QAAQ;EACT,CAAC;KAEF,OAAM,IAAI,MAAM,iCAAiC;;;;;;;;;;;AAarD,SAAgB,mBAAmB,MAAe;AAChD,QAAO,kBAAkB,MAAM,WAAW"}