@mastra/schema-compat 1.3.16-alpha.0 → 1.3.17-alpha.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (47) hide show
  1. package/dist/_types/@internal_ai-sdk-v5/dist/index.d.ts +274 -889
  2. package/dist/_types/@internal_ai-v6/dist/index.d.ts +1051 -1301
  3. package/dist/{esm-CWlHuVIx.js → esm-BG70JlG8.js} +60 -108
  4. package/dist/{esm-CWlHuVIx.js.map → esm-BG70JlG8.js.map} +1 -1
  5. package/dist/{esm-CkNCkZSB.cjs → esm-BQeGF7AD.cjs} +60 -108
  6. package/dist/{esm-CkNCkZSB.cjs.map → esm-BQeGF7AD.cjs.map} +1 -1
  7. package/dist/index.cjs +162 -185
  8. package/dist/index.cjs.map +1 -1
  9. package/dist/index.js +162 -185
  10. package/dist/index.js.map +1 -1
  11. package/dist/{json-schema-VSnKq6-P.cjs → json-schema-7oyknwMS.cjs} +241 -247
  12. package/dist/json-schema-7oyknwMS.cjs.map +1 -0
  13. package/dist/{json-schema-R8yfooPa.js → json-schema-BdCwqjfN.js} +241 -247
  14. package/dist/json-schema-BdCwqjfN.js.map +1 -0
  15. package/dist/{json-schema-traverse-B35mHRM8.js → json-schema-traverse-D0CId4oM.js} +5 -7
  16. package/dist/{json-schema-traverse-B35mHRM8.js.map → json-schema-traverse-D0CId4oM.js.map} +1 -1
  17. package/dist/{json-schema-traverse-DbuWNYgg.cjs → json-schema-traverse-evfp8uQX.cjs} +5 -7
  18. package/dist/{json-schema-traverse-DbuWNYgg.cjs.map → json-schema-traverse-evfp8uQX.cjs.map} +1 -1
  19. package/dist/json-to-zod.cjs +153 -142
  20. package/dist/json-to-zod.cjs.map +1 -1
  21. package/dist/json-to-zod.d.ts.map +1 -1
  22. package/dist/json-to-zod.js +153 -142
  23. package/dist/json-to-zod.js.map +1 -1
  24. package/dist/{schema-e0VHpMt0.js → schema-Bf12g7KC.js} +4 -6
  25. package/dist/{schema-e0VHpMt0.js.map → schema-Bf12g7KC.js.map} +1 -1
  26. package/dist/{schema-IhrnbMI3.cjs → schema-D2ab1-Dc.cjs} +5 -7
  27. package/dist/schema-D2ab1-Dc.cjs.map +1 -0
  28. package/dist/schema.cjs +1 -1
  29. package/dist/schema.js +1 -2
  30. package/dist/standard-schema/adapters/ai-sdk.cjs +2 -7
  31. package/dist/standard-schema/adapters/ai-sdk.cjs.map +1 -1
  32. package/dist/standard-schema/adapters/ai-sdk.js +2 -7
  33. package/dist/standard-schema/adapters/ai-sdk.js.map +1 -1
  34. package/dist/standard-schema/adapters/json-schema.cjs +1 -1
  35. package/dist/standard-schema/adapters/json-schema.js +1 -2
  36. package/dist/standard-schema/adapters/zod-v3.cjs +3 -4
  37. package/dist/standard-schema/adapters/zod-v3.cjs.map +1 -1
  38. package/dist/standard-schema/adapters/zod-v3.js +3 -4
  39. package/dist/standard-schema/adapters/zod-v3.js.map +1 -1
  40. package/dist/zod-to-json.cjs +6 -5
  41. package/dist/zod-to-json.cjs.map +1 -1
  42. package/dist/zod-to-json.js +6 -5
  43. package/dist/zod-to-json.js.map +1 -1
  44. package/package.json +24 -25
  45. package/dist/json-schema-R8yfooPa.js.map +0 -1
  46. package/dist/json-schema-VSnKq6-P.cjs.map +0 -1
  47. package/dist/schema-IhrnbMI3.cjs.map +0 -1
@@ -1,5 +1,5 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- //#region ../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@/json-schema-to-zod/2.7.0/a13e04d716ba0ad807c80424b9ecc2fa744903d957ce250899a6422d8d845e4a/node_modules/json-schema-to-zod/dist/esm/parsers/parseAnyOf.js
2
+ // ../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@/json-schema-to-zod/2.8.1/c100d4d307044bc24116b6230c3615807364a7e5d169923ae0cf63fb170f8f2b/node_modules/json-schema-to-zod/dist/esm/parsers/parseAnyOf.js
3
3
  const parseAnyOf = (schema, refs) => {
4
4
  return schema.anyOf.length ? schema.anyOf.length === 1 ? parseSchema(schema.anyOf[0], {
5
5
  ...refs,
@@ -17,18 +17,15 @@ const parseAnyOf = (schema, refs) => {
17
17
  ]
18
18
  })).join(", ")}])` : `z.any()`;
19
19
  };
20
- //#endregion
21
- //#region ../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@/json-schema-to-zod/2.7.0/a13e04d716ba0ad807c80424b9ecc2fa744903d957ce250899a6422d8d845e4a/node_modules/json-schema-to-zod/dist/esm/parsers/parseBoolean.js
20
+ // ../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@/json-schema-to-zod/2.8.1/c100d4d307044bc24116b6230c3615807364a7e5d169923ae0cf63fb170f8f2b/node_modules/json-schema-to-zod/dist/esm/parsers/parseBoolean.js
22
21
  const parseBoolean = (_schema) => {
23
22
  return "z.boolean()";
24
23
  };
25
- //#endregion
26
- //#region ../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@/json-schema-to-zod/2.7.0/a13e04d716ba0ad807c80424b9ecc2fa744903d957ce250899a6422d8d845e4a/node_modules/json-schema-to-zod/dist/esm/parsers/parseDefault.js
24
+ // ../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@/json-schema-to-zod/2.8.1/c100d4d307044bc24116b6230c3615807364a7e5d169923ae0cf63fb170f8f2b/node_modules/json-schema-to-zod/dist/esm/parsers/parseDefault.js
27
25
  const parseDefault = (_schema) => {
28
26
  return "z.any()";
29
27
  };
30
- //#endregion
31
- //#region ../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@/json-schema-to-zod/2.7.0/a13e04d716ba0ad807c80424b9ecc2fa744903d957ce250899a6422d8d845e4a/node_modules/json-schema-to-zod/dist/esm/parsers/parseMultipleType.js
28
+ // ../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@/json-schema-to-zod/2.8.1/c100d4d307044bc24116b6230c3615807364a7e5d169923ae0cf63fb170f8f2b/node_modules/json-schema-to-zod/dist/esm/parsers/parseMultipleType.js
32
29
  const parseMultipleType = (schema, refs) => {
33
30
  return `z.union([${schema.type.map((type) => parseSchema({
34
31
  ...schema,
@@ -38,26 +35,22 @@ const parseMultipleType = (schema, refs) => {
38
35
  withoutDefaults: true
39
36
  })).join(", ")}])`;
40
37
  };
41
- //#endregion
42
- //#region ../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@/json-schema-to-zod/2.7.0/a13e04d716ba0ad807c80424b9ecc2fa744903d957ce250899a6422d8d845e4a/node_modules/json-schema-to-zod/dist/esm/parsers/parseNot.js
38
+ // ../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@/json-schema-to-zod/2.8.1/c100d4d307044bc24116b6230c3615807364a7e5d169923ae0cf63fb170f8f2b/node_modules/json-schema-to-zod/dist/esm/parsers/parseNot.js
43
39
  const parseNot = (schema, refs) => {
44
40
  return `z.any().refine((value) => !${parseSchema(schema.not, {
45
41
  ...refs,
46
42
  path: [...refs.path, "not"]
47
43
  })}.safeParse(value).success, "Invalid input: Should NOT be valid against schema")`;
48
44
  };
49
- //#endregion
50
- //#region ../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@/json-schema-to-zod/2.7.0/a13e04d716ba0ad807c80424b9ecc2fa744903d957ce250899a6422d8d845e4a/node_modules/json-schema-to-zod/dist/esm/parsers/parseNull.js
45
+ // ../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@/json-schema-to-zod/2.8.1/c100d4d307044bc24116b6230c3615807364a7e5d169923ae0cf63fb170f8f2b/node_modules/json-schema-to-zod/dist/esm/parsers/parseNull.js
51
46
  const parseNull = (_schema) => {
52
47
  return "z.null()";
53
48
  };
54
- //#endregion
55
- //#region ../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@/json-schema-to-zod/2.7.0/a13e04d716ba0ad807c80424b9ecc2fa744903d957ce250899a6422d8d845e4a/node_modules/json-schema-to-zod/dist/esm/utils/half.js
49
+ // ../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@/json-schema-to-zod/2.8.1/c100d4d307044bc24116b6230c3615807364a7e5d169923ae0cf63fb170f8f2b/node_modules/json-schema-to-zod/dist/esm/utils/half.js
56
50
  const half = (arr) => {
57
51
  return [arr.slice(0, arr.length / 2), arr.slice(arr.length / 2)];
58
52
  };
59
- //#endregion
60
- //#region ../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@/json-schema-to-zod/2.7.0/a13e04d716ba0ad807c80424b9ecc2fa744903d957ce250899a6422d8d845e4a/node_modules/json-schema-to-zod/dist/esm/parsers/parseAllOf.js
53
+ // ../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@/json-schema-to-zod/2.8.1/c100d4d307044bc24116b6230c3615807364a7e5d169923ae0cf63fb170f8f2b/node_modules/json-schema-to-zod/dist/esm/parsers/parseAllOf.js
61
54
  const originalIndex = Symbol("Original index");
62
55
  const ensureOriginalIndex = (arr) => {
63
56
  let newArr = [];
@@ -92,9 +85,8 @@ function parseAllOf(schema, refs) {
92
85
  return `z.intersection(${parseAllOf({ allOf: left }, refs)}, ${parseAllOf({ allOf: right }, refs)})`;
93
86
  }
94
87
  }
95
- //#endregion
96
- //#region ../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@/json-schema-to-zod/2.7.0/a13e04d716ba0ad807c80424b9ecc2fa744903d957ce250899a6422d8d845e4a/node_modules/json-schema-to-zod/dist/esm/utils/withMessage.js
97
- function withMessage(schema, key, get) {
88
+ // ../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@/json-schema-to-zod/2.8.1/c100d4d307044bc24116b6230c3615807364a7e5d169923ae0cf63fb170f8f2b/node_modules/json-schema-to-zod/dist/esm/utils/withMessage.js
89
+ function withMessage(schema, key, get, fallbackMessage) {
98
90
  const value = schema[key];
99
91
  let r = "";
100
92
  if (value !== void 0) {
@@ -107,14 +99,14 @@ function withMessage(schema, key, get) {
107
99
  const prefix = got.length === 3 ? got[1] : "";
108
100
  const closer = got.length === 3 ? got[2] : got[1];
109
101
  r += opener;
110
- if (schema.errorMessage?.[key] !== void 0) r += prefix + JSON.stringify(schema.errorMessage[key]);
102
+ const message = schema.errorMessage?.[key] ?? fallbackMessage;
103
+ if (message !== void 0) r += prefix + JSON.stringify(message);
111
104
  r += closer;
112
105
  }
113
106
  }
114
107
  return r;
115
108
  }
116
- //#endregion
117
- //#region ../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@/json-schema-to-zod/2.7.0/a13e04d716ba0ad807c80424b9ecc2fa744903d957ce250899a6422d8d845e4a/node_modules/json-schema-to-zod/dist/esm/parsers/parseArray.js
109
+ // ../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@/json-schema-to-zod/2.8.1/c100d4d307044bc24116b6230c3615807364a7e5d169923ae0cf63fb170f8f2b/node_modules/json-schema-to-zod/dist/esm/parsers/parseArray.js
118
110
  const parseArray = (schema, refs) => {
119
111
  if (Array.isArray(schema.items)) return `z.tuple([${schema.items.map((v, i) => parseSchema(v, {
120
112
  ...refs,
@@ -139,27 +131,24 @@ const parseArray = (schema, refs) => {
139
131
  ")"
140
132
  ]);
141
133
  if (schema.uniqueItems === true) r += withMessage(schema, "uniqueItems", () => [
142
- ".unique(",
143
- "",
134
+ ".refine((arr) => arr.every((item, i) => arr.indexOf(item) == i)",
135
+ ", ",
144
136
  ")"
145
- ]);
137
+ ], "All items must be unique!");
146
138
  return r;
147
139
  };
148
- //#endregion
149
- //#region ../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@/json-schema-to-zod/2.7.0/a13e04d716ba0ad807c80424b9ecc2fa744903d957ce250899a6422d8d845e4a/node_modules/json-schema-to-zod/dist/esm/parsers/parseConst.js
140
+ // ../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@/json-schema-to-zod/2.8.1/c100d4d307044bc24116b6230c3615807364a7e5d169923ae0cf63fb170f8f2b/node_modules/json-schema-to-zod/dist/esm/parsers/parseConst.js
150
141
  const parseConst = (schema) => {
151
142
  return `z.literal(${JSON.stringify(schema.const)})`;
152
143
  };
153
- //#endregion
154
- //#region ../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@/json-schema-to-zod/2.7.0/a13e04d716ba0ad807c80424b9ecc2fa744903d957ce250899a6422d8d845e4a/node_modules/json-schema-to-zod/dist/esm/parsers/parseEnum.js
144
+ // ../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@/json-schema-to-zod/2.8.1/c100d4d307044bc24116b6230c3615807364a7e5d169923ae0cf63fb170f8f2b/node_modules/json-schema-to-zod/dist/esm/parsers/parseEnum.js
155
145
  const parseEnum = (schema) => {
156
146
  if (schema.enum.length === 0) return "z.never()";
157
147
  else if (schema.enum.length === 1) return `z.literal(${JSON.stringify(schema.enum[0])})`;
158
148
  else if (schema.enum.every((x) => typeof x === "string")) return `z.enum([${schema.enum.map((x) => JSON.stringify(x))}])`;
159
149
  else return `z.union([${schema.enum.map((x) => `z.literal(${JSON.stringify(x)})`).join(", ")}])`;
160
150
  };
161
- //#endregion
162
- //#region ../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@/json-schema-to-zod/2.7.0/a13e04d716ba0ad807c80424b9ecc2fa744903d957ce250899a6422d8d845e4a/node_modules/json-schema-to-zod/dist/esm/parsers/parseIfThenElse.js
151
+ // ../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@/json-schema-to-zod/2.8.1/c100d4d307044bc24116b6230c3615807364a7e5d169923ae0cf63fb170f8f2b/node_modules/json-schema-to-zod/dist/esm/parsers/parseIfThenElse.js
163
152
  const parseIfThenElse = (schema, refs) => {
164
153
  const $if = parseSchema(schema.if, {
165
154
  ...refs,
@@ -182,8 +171,7 @@ const parseIfThenElse = (schema, refs) => {
182
171
  }
183
172
  })`;
184
173
  };
185
- //#endregion
186
- //#region ../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@/json-schema-to-zod/2.7.0/a13e04d716ba0ad807c80424b9ecc2fa744903d957ce250899a6422d8d845e4a/node_modules/json-schema-to-zod/dist/esm/parsers/parseNumber.js
174
+ // ../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@/json-schema-to-zod/2.8.1/c100d4d307044bc24116b6230c3615807364a7e5d169923ae0cf63fb170f8f2b/node_modules/json-schema-to-zod/dist/esm/parsers/parseNumber.js
187
175
  const parseNumber = (schema) => {
188
176
  let r = "z.number()";
189
177
  if (schema.type === "integer") r += withMessage(schema, "type", () => [".int(", ")"]);
@@ -201,41 +189,43 @@ const parseNumber = (schema) => {
201
189
  ")"
202
190
  ];
203
191
  });
204
- if (typeof schema.minimum === "number") if (schema.exclusiveMinimum === true) r += withMessage(schema, "minimum", ({ json }) => [
205
- `.gt(${json}`,
206
- ", ",
207
- ")"
208
- ]);
209
- else r += withMessage(schema, "minimum", ({ json }) => [
210
- `.gte(${json}`,
211
- ", ",
212
- ")"
213
- ]);
214
- else if (typeof schema.exclusiveMinimum === "number") r += withMessage(schema, "exclusiveMinimum", ({ json }) => [
192
+ if (typeof schema.minimum === "number") {
193
+ if (schema.exclusiveMinimum === true) r += withMessage(schema, "minimum", ({ json }) => [
194
+ `.gt(${json}`,
195
+ ", ",
196
+ ")"
197
+ ]);
198
+ else r += withMessage(schema, "minimum", ({ json }) => [
199
+ `.gte(${json}`,
200
+ ", ",
201
+ ")"
202
+ ]);
203
+ } else if (typeof schema.exclusiveMinimum === "number") r += withMessage(schema, "exclusiveMinimum", ({ json }) => [
215
204
  `.gt(${json}`,
216
205
  ", ",
217
206
  ")"
218
207
  ]);
219
- if (typeof schema.maximum === "number") if (schema.exclusiveMaximum === true) r += withMessage(schema, "maximum", ({ json }) => [
220
- `.lt(${json}`,
221
- ", ",
222
- ")"
223
- ]);
224
- else r += withMessage(schema, "maximum", ({ json }) => [
225
- `.lte(${json}`,
226
- ", ",
227
- ")"
228
- ]);
229
- else if (typeof schema.exclusiveMaximum === "number") r += withMessage(schema, "exclusiveMaximum", ({ json }) => [
208
+ if (typeof schema.maximum === "number") {
209
+ if (schema.exclusiveMaximum === true) r += withMessage(schema, "maximum", ({ json }) => [
210
+ `.lt(${json}`,
211
+ ", ",
212
+ ")"
213
+ ]);
214
+ else r += withMessage(schema, "maximum", ({ json }) => [
215
+ `.lte(${json}`,
216
+ ", ",
217
+ ")"
218
+ ]);
219
+ } else if (typeof schema.exclusiveMaximum === "number") r += withMessage(schema, "exclusiveMaximum", ({ json }) => [
230
220
  `.lt(${json}`,
231
221
  ", ",
232
222
  ")"
233
223
  ]);
234
224
  return r;
235
225
  };
236
- //#endregion
237
- //#region ../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@/json-schema-to-zod/2.7.0/a13e04d716ba0ad807c80424b9ecc2fa744903d957ce250899a6422d8d845e4a/node_modules/json-schema-to-zod/dist/esm/parsers/parseOneOf.js
226
+ // ../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@/json-schema-to-zod/2.8.1/c100d4d307044bc24116b6230c3615807364a7e5d169923ae0cf63fb170f8f2b/node_modules/json-schema-to-zod/dist/esm/parsers/parseOneOf.js
238
227
  const parseOneOf = (schema, refs) => {
228
+ let is3 = refs.zodVersion === 3;
239
229
  return schema.oneOf.length ? schema.oneOf.length === 1 ? parseSchema(schema.oneOf[0], {
240
230
  ...refs,
241
231
  path: [
@@ -252,26 +242,38 @@ const parseOneOf = (schema, refs) => {
252
242
  i
253
243
  ]
254
244
  })).join(", ")}];
255
- const errors = schemas.reduce<z.ZodError[]>(
256
- (errors, schema) =>
245
+ const { errors, failed } = schemas.reduce<{
246
+ errors: z.${is3 ? "ZodError" : "core.$ZodIssue"}[];
247
+ failed: number;
248
+ }>(
249
+ ({ errors, failed }, schema) =>
257
250
  ((result) =>
258
- result.error ? [...errors, result.error] : errors)(
251
+ result.error
252
+ ? {
253
+ errors: [...errors, ${is3 ? "result.error" : "...result.error.issues"}],
254
+ failed: failed + 1,
255
+ }
256
+ : { errors, failed })(
259
257
  schema.safeParse(x),
260
258
  ),
261
- [],
259
+ { errors: [], failed: 0 },
262
260
  );
263
- if (schemas.length - errors.length !== 1) {
264
- ctx.addIssue({
265
- path: ctx.path,
261
+ const passed = schemas.length - failed;
262
+ if (passed !== 1) {
263
+ ctx.addIssue(errors.length ? {
264
+ path: ${is3 ? "ctx.path" : "[]"},
266
265
  code: "invalid_union",
267
- unionErrors: errors,
268
- message: "Invalid input: Should pass single schema",
266
+ ${is3 ? "unionErrors: errors" : "errors: [errors]"},
267
+ message: "Invalid input: Should pass single schema. Passed " + passed,
268
+ } : {
269
+ path: ${is3 ? "ctx.path" : "[]"},
270
+ code: "custom",${is3 ? "" : "\n errors: [errors],"}
271
+ message: "Invalid input: Should pass single schema. Passed " + passed,
269
272
  });
270
273
  }
271
274
  })` : "z.any()";
272
275
  };
273
- //#endregion
274
- //#region ../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@/json-schema-to-zod/2.7.0/a13e04d716ba0ad807c80424b9ecc2fa744903d957ce250899a6422d8d845e4a/node_modules/json-schema-to-zod/dist/esm/utils/jsdocs.js
276
+ // ../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@/json-schema-to-zod/2.8.1/c100d4d307044bc24116b6230c3615807364a7e5d169923ae0cf63fb170f8f2b/node_modules/json-schema-to-zod/dist/esm/utils/jsdocs.js
275
277
  const expandJsdocs = (jsdocs) => {
276
278
  const lines = jsdocs.split("\n");
277
279
  return `/**${lines.length === 1 ? lines[0] : `\n${lines.map((x) => `* ${x}`).join("\n")}\n`}*/\n`;
@@ -281,29 +283,38 @@ const addJsdocs = (schema, parsed) => {
281
283
  if (!description) return parsed;
282
284
  return `\n${expandJsdocs(description)}${parsed}`;
283
285
  };
284
- //#endregion
285
- //#region ../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@/json-schema-to-zod/2.7.0/a13e04d716ba0ad807c80424b9ecc2fa744903d957ce250899a6422d8d845e4a/node_modules/json-schema-to-zod/dist/esm/parsers/parseObject.js
286
+ // ../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@/json-schema-to-zod/2.8.1/c100d4d307044bc24116b6230c3615807364a7e5d169923ae0cf63fb170f8f2b/node_modules/json-schema-to-zod/dist/esm/parsers/parseObject.js
287
+ function emitRecord(valueSchema, refs) {
288
+ if (refs.zodVersion === 3) return `z.record(${valueSchema})`;
289
+ return `z.record(z.string(), ${valueSchema})`;
290
+ }
291
+ function emitErrorPath(refs) {
292
+ if (refs.zodVersion === 3) return `path: [...ctx.path, key]`;
293
+ return `path: [key]`;
294
+ }
286
295
  function parseObject(objectSchema, refs) {
287
296
  let properties = void 0;
288
- if (objectSchema.properties) if (!Object.keys(objectSchema.properties).length) properties = "z.object({})";
289
- else {
290
- properties = "z.object({ ";
291
- properties += Object.keys(objectSchema.properties).map((key) => {
292
- const propSchema = objectSchema.properties[key];
293
- let result = `${JSON.stringify(key)}: ${parseSchema(propSchema, {
294
- ...refs,
295
- path: [
296
- ...refs.path,
297
- "properties",
298
- key
299
- ]
300
- })}`;
301
- if (refs.withJsdocs && typeof propSchema === "object") result = addJsdocs(propSchema, result);
302
- const hasDefault = typeof propSchema === "object" && propSchema.default !== void 0;
303
- const required = Array.isArray(objectSchema.required) ? objectSchema.required.includes(key) : typeof propSchema === "object" && propSchema.required === true;
304
- return !hasDefault && !required ? `${result}.optional()` : result;
305
- }).join(", ");
306
- properties += " })";
297
+ if (objectSchema.properties) {
298
+ if (!Object.keys(objectSchema.properties).length) properties = "z.object({})";
299
+ else {
300
+ properties = "z.object({ ";
301
+ properties += Object.keys(objectSchema.properties).map((key) => {
302
+ const propSchema = objectSchema.properties[key];
303
+ let result = `${JSON.stringify(key)}: ${parseSchema(propSchema, {
304
+ ...refs,
305
+ path: [
306
+ ...refs.path,
307
+ "properties",
308
+ key
309
+ ]
310
+ })}`;
311
+ if (refs.withJsdocs && typeof propSchema === "object") result = addJsdocs(propSchema, result);
312
+ const hasDefault = typeof propSchema === "object" && propSchema.default !== void 0;
313
+ const required = Array.isArray(objectSchema.required) ? objectSchema.required.includes(key) : typeof propSchema === "object" && propSchema.required === true;
314
+ return !hasDefault && !required ? `${result}.optional()` : result;
315
+ }).join(", ");
316
+ properties += " })";
317
+ }
307
318
  }
308
319
  const additionalProperties = objectSchema.additionalProperties !== void 0 ? parseSchema(objectSchema.additionalProperties, {
309
320
  ...refs,
@@ -322,23 +333,26 @@ function parseObject(objectSchema, refs) {
322
333
  })];
323
334
  }, {}));
324
335
  patternProperties = "";
325
- if (properties) if (additionalProperties) patternProperties += `.catchall(z.union([${[...Object.values(parsedPatternProperties), additionalProperties].join(", ")}]))`;
326
- else if (Object.keys(parsedPatternProperties).length > 1) patternProperties += `.catchall(z.union([${Object.values(parsedPatternProperties).join(", ")}]))`;
327
- else patternProperties += `.catchall(${Object.values(parsedPatternProperties)})`;
328
- else if (additionalProperties) patternProperties += `z.record(z.union([${[...Object.values(parsedPatternProperties), additionalProperties].join(", ")}]))`;
329
- else if (Object.keys(parsedPatternProperties).length > 1) patternProperties += `z.record(z.union([${Object.values(parsedPatternProperties).join(", ")}]))`;
330
- else patternProperties += `z.record(${Object.values(parsedPatternProperties)})`;
336
+ if (properties) {
337
+ if (additionalProperties) patternProperties += `.catchall(z.union([${[...Object.values(parsedPatternProperties), additionalProperties].join(", ")}]))`;
338
+ else if (Object.keys(parsedPatternProperties).length > 1) patternProperties += `.catchall(z.union([${Object.values(parsedPatternProperties).join(", ")}]))`;
339
+ else patternProperties += `.catchall(${Object.values(parsedPatternProperties)})`;
340
+ } else if (additionalProperties) patternProperties += emitRecord(`z.union([${[...Object.values(parsedPatternProperties), additionalProperties].join(", ")}])`, refs);
341
+ else if (Object.keys(parsedPatternProperties).length > 1) patternProperties += emitRecord(`z.union([${Object.values(parsedPatternProperties).join(", ")}])`, refs);
342
+ else patternProperties += emitRecord(`${Object.values(parsedPatternProperties)}`, refs);
331
343
  patternProperties += ".superRefine((value, ctx) => {\n";
332
344
  patternProperties += "for (const key in value) {\n";
333
- if (additionalProperties) if (objectSchema.properties) patternProperties += `let evaluated = [${Object.keys(objectSchema.properties).map((key) => JSON.stringify(key)).join(", ")}].includes(key)\n`;
334
- else patternProperties += `let evaluated = false\n`;
345
+ if (additionalProperties) {
346
+ if (objectSchema.properties) patternProperties += `let evaluated = [${Object.keys(objectSchema.properties).map((key) => JSON.stringify(key)).join(", ")}].includes(key)\n`;
347
+ else patternProperties += `let evaluated = false\n`;
348
+ }
335
349
  for (const key in objectSchema.patternProperties) {
336
350
  patternProperties += "if (key.match(new RegExp(" + JSON.stringify(key) + "))) {\n";
337
351
  if (additionalProperties) patternProperties += "evaluated = true\n";
338
352
  patternProperties += "const result = " + parsedPatternProperties[key] + ".safeParse(value[key])\n";
339
353
  patternProperties += "if (!result.success) {\n";
340
354
  patternProperties += `ctx.addIssue({
341
- path: [...ctx.path, key],
355
+ ${emitErrorPath(refs)},
342
356
  code: 'custom',
343
357
  message: \`Invalid input: Key matching regex /\${key}/ must match schema\`,
344
358
  params: {
@@ -353,7 +367,7 @@ function parseObject(objectSchema, refs) {
353
367
  patternProperties += "const result = " + additionalProperties + ".safeParse(value[key])\n";
354
368
  patternProperties += "if (!result.success) {\n";
355
369
  patternProperties += `ctx.addIssue({
356
- path: [...ctx.path, key],
370
+ ${emitErrorPath(refs)},
357
371
  code: 'custom',
358
372
  message: \`Invalid input: must match catchall schema\`,
359
373
  params: {
@@ -366,7 +380,7 @@ function parseObject(objectSchema, refs) {
366
380
  patternProperties += "}\n";
367
381
  patternProperties += "})";
368
382
  }
369
- let output = properties ? patternProperties ? properties + patternProperties : additionalProperties ? additionalProperties === "z.never()" ? properties + ".strict()" : properties + `.catchall(${additionalProperties})` : properties : patternProperties ? patternProperties : additionalProperties ? `z.record(${additionalProperties})` : "z.record(z.any())";
383
+ let output = properties ? patternProperties ? properties + patternProperties : additionalProperties ? additionalProperties === "z.never()" ? properties + ".strict()" : properties + `.catchall(${additionalProperties})` : properties : patternProperties ? patternProperties : additionalProperties ? emitRecord(additionalProperties, refs) : emitRecord("z.any()", refs);
370
384
  if (its.an.anyOf(objectSchema)) output += `.and(${parseAnyOf({
371
385
  ...objectSchema,
372
386
  anyOf: objectSchema.anyOf.map((x) => typeof x === "object" && !x.type && (x.properties || x.additionalProperties || x.patternProperties) ? {
@@ -390,8 +404,7 @@ function parseObject(objectSchema, refs) {
390
404
  }, refs)})`;
391
405
  return output;
392
406
  }
393
- //#endregion
394
- //#region ../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@/json-schema-to-zod/2.7.0/a13e04d716ba0ad807c80424b9ecc2fa744903d957ce250899a6422d8d845e4a/node_modules/json-schema-to-zod/dist/esm/parsers/parseString.js
407
+ // ../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@/json-schema-to-zod/2.8.1/c100d4d307044bc24116b6230c3615807364a7e5d169923ae0cf63fb170f8f2b/node_modules/json-schema-to-zod/dist/esm/parsers/parseString.js
395
408
  const parseString = (schema) => {
396
409
  let r = "z.string()";
397
410
  r += withMessage(schema, "format", ({ value }) => {
@@ -458,8 +471,7 @@ const parseString = (schema) => {
458
471
  }
459
472
  return r;
460
473
  };
461
- //#endregion
462
- //#region ../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@/json-schema-to-zod/2.7.0/a13e04d716ba0ad807c80424b9ecc2fa744903d957ce250899a6422d8d845e4a/node_modules/json-schema-to-zod/dist/esm/parsers/parseSimpleDiscriminatedOneOf.js
474
+ // ../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@/json-schema-to-zod/2.8.1/c100d4d307044bc24116b6230c3615807364a7e5d169923ae0cf63fb170f8f2b/node_modules/json-schema-to-zod/dist/esm/parsers/parseSimpleDiscriminatedOneOf.js
463
475
  const parseSimpleDiscriminatedOneOf = (schema, refs) => {
464
476
  return schema.oneOf.length ? schema.oneOf.length === 1 ? parseSchema(schema.oneOf[0], {
465
477
  ...refs,
@@ -477,22 +489,19 @@ const parseSimpleDiscriminatedOneOf = (schema, refs) => {
477
489
  ]
478
490
  })).join(", ")}])` : "z.any()";
479
491
  };
480
- //#endregion
481
- //#region ../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@/json-schema-to-zod/2.7.0/a13e04d716ba0ad807c80424b9ecc2fa744903d957ce250899a6422d8d845e4a/node_modules/json-schema-to-zod/dist/esm/utils/omit.js
492
+ // ../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@/json-schema-to-zod/2.8.1/c100d4d307044bc24116b6230c3615807364a7e5d169923ae0cf63fb170f8f2b/node_modules/json-schema-to-zod/dist/esm/utils/omit.js
482
493
  const omit = (obj, ...keys) => Object.keys(obj).reduce((acc, key) => {
483
494
  if (!keys.includes(key)) acc[key] = obj[key];
484
495
  return acc;
485
496
  }, {});
486
- //#endregion
487
- //#region ../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@/json-schema-to-zod/2.7.0/a13e04d716ba0ad807c80424b9ecc2fa744903d957ce250899a6422d8d845e4a/node_modules/json-schema-to-zod/dist/esm/parsers/parseNullable.js
497
+ // ../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@/json-schema-to-zod/2.8.1/c100d4d307044bc24116b6230c3615807364a7e5d169923ae0cf63fb170f8f2b/node_modules/json-schema-to-zod/dist/esm/parsers/parseNullable.js
488
498
  /**
489
499
  * For compatibility with open api 3.0 nullable
490
500
  */
491
501
  const parseNullable = (schema, refs) => {
492
502
  return `${parseSchema(omit(schema, "nullable"), refs, true)}.nullable()`;
493
503
  };
494
- //#endregion
495
- //#region ../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@/json-schema-to-zod/2.7.0/a13e04d716ba0ad807c80424b9ecc2fa744903d957ce250899a6422d8d845e4a/node_modules/json-schema-to-zod/dist/esm/parsers/parseSchema.js
504
+ // ../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@/json-schema-to-zod/2.8.1/c100d4d307044bc24116b6230c3615807364a7e5d169923ae0cf63fb170f8f2b/node_modules/json-schema-to-zod/dist/esm/parsers/parseSchema.js
496
505
  const parseSchema = (schema, refs = {
497
506
  seen: /* @__PURE__ */ new Map(),
498
507
  path: []
@@ -581,15 +590,15 @@ const its = {
581
590
  oneOf: (x) => x.oneOf !== void 0
582
591
  }
583
592
  };
584
- //#endregion
585
- //#region ../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@/json-schema-to-zod/2.7.0/a13e04d716ba0ad807c80424b9ecc2fa744903d957ce250899a6422d8d845e4a/node_modules/json-schema-to-zod/dist/esm/jsonSchemaToZod.js
586
- const jsonSchemaToZod$1 = (schema, { module, name, type, noImport, ...rest } = {}) => {
593
+ // ../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@/json-schema-to-zod/2.8.1/c100d4d307044bc24116b6230c3615807364a7e5d169923ae0cf63fb170f8f2b/node_modules/json-schema-to-zod/dist/esm/jsonSchemaToZod.js
594
+ const jsonSchemaToZod$1 = (schema, { module, name, type, noImport, zodVersion = 4, ...rest } = {}) => {
587
595
  if (type && (!name || module !== "esm")) throw new Error("Option `type` requires `name` to be set and `module` to be `esm`");
588
596
  let result = parseSchema(schema, {
589
597
  module,
590
598
  name,
591
599
  path: [],
592
600
  seen: /* @__PURE__ */ new Map(),
601
+ zodVersion,
593
602
  ...rest
594
603
  });
595
604
  const jsdocs = rest.withJsdocs && typeof schema !== "boolean" && schema.description ? expandJsdocs(schema.description) : "";
@@ -613,32 +622,32 @@ ${result}`;
613
622
  }
614
623
  return result;
615
624
  };
616
- //#endregion
617
- //#region ../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@/json-schema-to-zod/2.7.0/a13e04d716ba0ad807c80424b9ecc2fa744903d957ce250899a6422d8d845e4a/node_modules/json-schema-to-zod/dist/esm/index.js
625
+ // ../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@/json-schema-to-zod/2.8.1/c100d4d307044bc24116b6230c3615807364a7e5d169923ae0cf63fb170f8f2b/node_modules/json-schema-to-zod/dist/esm/index.js
618
626
  var esm_default = jsonSchemaToZod$1;
619
- //#endregion
620
- //#region src/json-to-zod.ts
627
+ // src/json-to-zod.ts
621
628
  function parseObject$1(objectSchema, refs) {
622
629
  let properties = void 0;
623
- if (objectSchema.properties) if (!Object.keys(objectSchema.properties).length) properties = "z.object({})";
624
- else {
625
- properties = "z.object({ ";
626
- properties += Object.keys(objectSchema.properties).map((key) => {
627
- const propSchema = objectSchema.properties[key];
628
- let result = `${JSON.stringify(key)}: ${parseSchema(propSchema, {
629
- ...refs,
630
- path: [
631
- ...refs.path,
632
- "properties",
633
- key
634
- ]
635
- })}`;
636
- if (refs.withJsdocs && typeof propSchema === "object") result = addJsdocs(propSchema, result);
637
- const hasDefault = typeof propSchema === "object" && propSchema.default !== void 0;
638
- const required = Array.isArray(objectSchema.required) ? objectSchema.required.includes(key) : typeof propSchema === "object" && propSchema.required === true;
639
- return !hasDefault && !required ? `${result}.optional()` : result;
640
- }).join(", ");
641
- properties += " })";
630
+ if (objectSchema.properties) {
631
+ if (!Object.keys(objectSchema.properties).length) properties = "z.object({})";
632
+ else {
633
+ properties = "z.object({ ";
634
+ properties += Object.keys(objectSchema.properties).map((key) => {
635
+ const propSchema = objectSchema.properties[key];
636
+ let result = `${JSON.stringify(key)}: ${parseSchema(propSchema, {
637
+ ...refs,
638
+ path: [
639
+ ...refs.path,
640
+ "properties",
641
+ key
642
+ ]
643
+ })}`;
644
+ if (refs.withJsdocs && typeof propSchema === "object") result = addJsdocs(propSchema, result);
645
+ const hasDefault = typeof propSchema === "object" && propSchema.default !== void 0;
646
+ const required = Array.isArray(objectSchema.required) ? objectSchema.required.includes(key) : typeof propSchema === "object" && propSchema.required === true;
647
+ return !hasDefault && !required ? `${result}.optional()` : result;
648
+ }).join(", ");
649
+ properties += " })";
650
+ }
642
651
  }
643
652
  const additionalProperties = objectSchema.additionalProperties !== void 0 && objectSchema.additionalProperties !== false ? parseSchema(objectSchema.additionalProperties, {
644
653
  ...refs,
@@ -657,16 +666,19 @@ function parseObject$1(objectSchema, refs) {
657
666
  })];
658
667
  }, {}));
659
668
  patternProperties = "";
660
- if (properties) if (additionalProperties) patternProperties += `.catchall(z.union([${[...Object.values(parsedPatternProperties), additionalProperties].join(", ")}]))`;
661
- else if (Object.keys(parsedPatternProperties).length > 1) patternProperties += `.catchall(z.union([${Object.values(parsedPatternProperties).join(", ")}]))`;
662
- else patternProperties += `.catchall(${Object.values(parsedPatternProperties)})`;
663
- else if (additionalProperties) patternProperties += `z.record(z.string(), z.union([${[...Object.values(parsedPatternProperties), additionalProperties].join(", ")}]))`;
669
+ if (properties) {
670
+ if (additionalProperties) patternProperties += `.catchall(z.union([${[...Object.values(parsedPatternProperties), additionalProperties].join(", ")}]))`;
671
+ else if (Object.keys(parsedPatternProperties).length > 1) patternProperties += `.catchall(z.union([${Object.values(parsedPatternProperties).join(", ")}]))`;
672
+ else patternProperties += `.catchall(${Object.values(parsedPatternProperties)})`;
673
+ } else if (additionalProperties) patternProperties += `z.record(z.string(), z.union([${[...Object.values(parsedPatternProperties), additionalProperties].join(", ")}]))`;
664
674
  else if (Object.keys(parsedPatternProperties).length > 1) patternProperties += `z.record(z.string(), z.union([${Object.values(parsedPatternProperties).join(", ")}]))`;
665
675
  else patternProperties += `z.record(z.string(), ${Object.values(parsedPatternProperties)})`;
666
676
  patternProperties += ".superRefine((value, ctx) => {\n";
667
677
  patternProperties += "for (const key in value) {\n";
668
- if (additionalProperties) if (objectSchema.properties) patternProperties += `let evaluated = [${Object.keys(objectSchema.properties).map((key) => JSON.stringify(key)).join(", ")}].includes(key)\n`;
669
- else patternProperties += `let evaluated = false\n`;
678
+ if (additionalProperties) {
679
+ if (objectSchema.properties) patternProperties += `let evaluated = [${Object.keys(objectSchema.properties).map((key) => JSON.stringify(key)).join(", ")}].includes(key)\n`;
680
+ else patternProperties += `let evaluated = false\n`;
681
+ }
670
682
  for (const key in objectSchema.patternProperties) {
671
683
  patternProperties += "if (key.match(new RegExp(" + JSON.stringify(key) + "))) {\n";
672
684
  if (additionalProperties) patternProperties += "evaluated = true\n";
@@ -809,7 +821,6 @@ function jsonSchemaToZod(schema, options = {}) {
809
821
  parserOverride
810
822
  }).replace(/\.reduce<[^>]+>/g, ".reduce");
811
823
  }
812
- //#endregion
813
824
  exports.addJsdocs = addJsdocs;
814
825
  exports.expandJsdocs = expandJsdocs;
815
826
  exports.half = half;