@stryke/zod 0.2.4 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -2,6 +2,13 @@
2
2
 
3
3
  # Changelog for Stryke - Zod
4
4
 
5
+ ## [0.2.4](https://github.com/storm-software/stryke/releases/tag/zod%400.2.4) (03/03/2026)
6
+
7
+ ### Updated Dependencies
8
+
9
+ - Updated **type-checks** to **v0.5.30**
10
+ - Updated **json** to **v0.13.0**
11
+
5
12
  ## [0.2.3](https://github.com/storm-software/stryke/releases/tag/zod%400.2.3) (03/03/2026)
6
13
 
7
14
  ### 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-6XYtc78K.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-Cj952H5H.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 };
@@ -159,14 +159,26 @@ type JsonSchema7TypeUnion = JsonSchema7StringType | JsonSchema7ArrayType | JsonS
159
159
  type JsonSchema7Type = JsonSchema7TypeUnion & JsonSchema7Meta;
160
160
  //#endregion
161
161
  //#region src/schema.d.ts
162
+ interface ExtractJsonSchemaOptions {
163
+ /**
164
+ * The JSON Schema draft version to target. Defaults to "draft-07".
165
+ */
166
+ target?: "draft-07" | "draft-2020-12";
167
+ /**
168
+ * Whether to include the input or output schema for Zod schemas.
169
+ *
170
+ * @remarks
171
+ */
172
+ io?: "input" | "output";
173
+ }
162
174
  /**
163
175
  * Extracts a JSON Schema from a given Zod schema, supporting both version 3 and version 4 of Zod.
164
176
  *
165
177
  * @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".
178
+ * @param options - Options for extracting the JSON Schema, including the target draft version and input/output selection.
167
179
  * @returns The extracted JSON Schema.
168
180
  */
169
- declare function extractJsonSchema(type: ZodType, target?: "draft-07" | "draft-2020-12"): (object & {
181
+ declare function extractJsonSchema(type: ZodType, options?: ExtractJsonSchemaOptions): (object & {
170
182
  $schema?: string | undefined;
171
183
  definitions?: {
172
184
  [key: string]: zod_to_json_schema0.JsonSchema7Type;
@@ -183,5 +195,5 @@ declare function extractJsonSchema(type: ZodType, target?: "draft-07" | "draft-2
183
195
  */
184
196
  declare function extractJsonSchema7(type: ZodType): JsonSchema7Type;
185
197
  //#endregion
186
- export { extractJsonSchema7 as n, extractJsonSchema as t };
187
- //# sourceMappingURL=schema-DAmyxbgH.d.cts.map
198
+ export { extractJsonSchema as n, extractJsonSchema7 as r, ExtractJsonSchemaOptions as t };
199
+ //# sourceMappingURL=schema-6XYtc78K.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"schema-6XYtc78K.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;;;;ECtVK,OAAA,CAAA,EAAA,MAAA;EAqBD,gBAAA,CAAA,EAAA,MAAiB;EACzB,UAAA,CAAA,EAAA,MAAA;;AACgC,UDsGvB,sBAAA,CCtGuB;;;KD0G5B,mBAAA;;ECnEI,MAAA,EAAA,WAAA,GAAkB,WAAO,GAAA,MACmB;;;;SD0E/C;;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;;;;;;;;UA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/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"}
@@ -161,14 +161,26 @@ type JsonSchema7TypeUnion = JsonSchema7StringType | JsonSchema7ArrayType | JsonS
161
161
  type JsonSchema7Type = JsonSchema7TypeUnion & JsonSchema7Meta;
162
162
  //#endregion
163
163
  //#region src/schema.d.ts
164
+ interface ExtractJsonSchemaOptions {
165
+ /**
166
+ * The JSON Schema draft version to target. Defaults to "draft-07".
167
+ */
168
+ target?: "draft-07" | "draft-2020-12";
169
+ /**
170
+ * Whether to include the input or output schema for Zod schemas.
171
+ *
172
+ * @remarks
173
+ */
174
+ io?: "input" | "output";
175
+ }
164
176
  /**
165
177
  * Extracts a JSON Schema from a given Zod schema, supporting both version 3 and version 4 of Zod.
166
178
  *
167
179
  * @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".
180
+ * @param options - Options for extracting the JSON Schema, including the target draft version and input/output selection.
169
181
  * @returns The extracted JSON Schema.
170
182
  */
171
- declare function extractJsonSchema(type: ZodType, target?: "draft-07" | "draft-2020-12"): (object & {
183
+ declare function extractJsonSchema(type: ZodType, options?: ExtractJsonSchemaOptions): (object & {
172
184
  $schema?: string | undefined;
173
185
  definitions?: {
174
186
  [key: string]: zod_to_json_schema0.JsonSchema7Type;
@@ -185,5 +197,5 @@ declare function extractJsonSchema(type: ZodType, target?: "draft-07" | "draft-2
185
197
  */
186
198
  declare function extractJsonSchema7(type: ZodType): JsonSchema7Type;
187
199
  //#endregion
188
- export { extractJsonSchema7 as n, extractJsonSchema as t };
189
- //# sourceMappingURL=schema-DJs6pbWQ.d.mts.map
200
+ export { extractJsonSchema as n, extractJsonSchema7 as r, ExtractJsonSchemaOptions as t };
201
+ //# sourceMappingURL=schema-Cj952H5H.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"schema-Cj952H5H.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;;;;ECtVK,UAAA,CAAA,EAAA,MAAA;AAqBjB;AACQ,UDuGS,sBAAA,CCvGT;EACG,IAAA,EAAA,SAAA;;KD0GC,mBAAA;;;;ECnEI,OAAA,CAAA,EAAA,MAAA;;SD2EH;;UAGI,mBAAA;;;;UAKA,oBAAA;S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,CAAA,CAAA,kCAAsC,YAAA,CAAA,OAAA,EAAA,OAAA,sBAAA,CAAA,OAAA,EAAA,OAAA,CAAA,CAAA,CAAA;AAmBtC;AAQA;;;;;;AAIA;AAMA;AAaiB,iBCrMD,kBAAA,CDsMT,IAAA,ECtMkC,ODsMlC,CAAA,ECrMqD,eDqMnC"}
@@ -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
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-6XYtc78K.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-Cj952H5H.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.0",
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.13.1",
78
78
  "tsdown": "^0.17.2",
79
79
  "zod": "^4.3.6"
80
80
  },
81
81
  "publishConfig": { "access": "public" },
82
- "gitHead": "793c21dcc2c0734890ffe5e40bd69683455dc301"
82
+ "gitHead": "7d12d78184a0812114d762186fe34f82d9e9083d"
83
83
  }
@@ -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,u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AA,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"}