@mastra/schema-compat 1.3.10-alpha.1 → 1.3.11-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.
@@ -1,8 +1,288 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- const require_rolldown_runtime = require("./rolldown-runtime-emK7D4bc.cjs");
3
- let json_schema_to_zod = require("json-schema-to-zod");
4
- json_schema_to_zod = require_rolldown_runtime.__toESM(json_schema_to_zod, 1);
5
- //#region src/json-to-zod.ts
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
3
+ const parseAnyOf = (schema, refs) => {
4
+ return schema.anyOf.length ? schema.anyOf.length === 1 ? parseSchema(schema.anyOf[0], {
5
+ ...refs,
6
+ path: [
7
+ ...refs.path,
8
+ "anyOf",
9
+ 0
10
+ ]
11
+ }) : `z.union([${schema.anyOf.map((schema, i) => parseSchema(schema, {
12
+ ...refs,
13
+ path: [
14
+ ...refs.path,
15
+ "anyOf",
16
+ i
17
+ ]
18
+ })).join(", ")}])` : `z.any()`;
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
22
+ const parseBoolean = (_schema) => {
23
+ return "z.boolean()";
24
+ };
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
27
+ const parseDefault = (_schema) => {
28
+ return "z.any()";
29
+ };
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
32
+ const parseMultipleType = (schema, refs) => {
33
+ return `z.union([${schema.type.map((type) => parseSchema({
34
+ ...schema,
35
+ type
36
+ }, {
37
+ ...refs,
38
+ withoutDefaults: true
39
+ })).join(", ")}])`;
40
+ };
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
43
+ const parseNot = (schema, refs) => {
44
+ return `z.any().refine((value) => !${parseSchema(schema.not, {
45
+ ...refs,
46
+ path: [...refs.path, "not"]
47
+ })}.safeParse(value).success, "Invalid input: Should NOT be valid against schema")`;
48
+ };
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
51
+ const parseNull = (_schema) => {
52
+ return "z.null()";
53
+ };
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
56
+ const half = (arr) => {
57
+ return [arr.slice(0, arr.length / 2), arr.slice(arr.length / 2)];
58
+ };
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
61
+ const originalIndex = Symbol("Original index");
62
+ const ensureOriginalIndex = (arr) => {
63
+ let newArr = [];
64
+ for (let i = 0; i < arr.length; i++) {
65
+ const item = arr[i];
66
+ if (typeof item === "boolean") newArr.push(item ? { [originalIndex]: i } : {
67
+ [originalIndex]: i,
68
+ not: {}
69
+ });
70
+ else if (originalIndex in item) return arr;
71
+ else newArr.push({
72
+ ...item,
73
+ [originalIndex]: i
74
+ });
75
+ }
76
+ return newArr;
77
+ };
78
+ function parseAllOf(schema, refs) {
79
+ if (schema.allOf.length === 0) return "z.never()";
80
+ else if (schema.allOf.length === 1) {
81
+ const item = schema.allOf[0];
82
+ return parseSchema(item, {
83
+ ...refs,
84
+ path: [
85
+ ...refs.path,
86
+ "allOf",
87
+ item[originalIndex]
88
+ ]
89
+ });
90
+ } else {
91
+ const [left, right] = half(ensureOriginalIndex(schema.allOf));
92
+ return `z.intersection(${parseAllOf({ allOf: left }, refs)}, ${parseAllOf({ allOf: right }, refs)})`;
93
+ }
94
+ }
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) {
98
+ const value = schema[key];
99
+ let r = "";
100
+ if (value !== void 0) {
101
+ const got = get({
102
+ value,
103
+ json: JSON.stringify(value)
104
+ });
105
+ if (got) {
106
+ const opener = got[0];
107
+ const prefix = got.length === 3 ? got[1] : "";
108
+ const closer = got.length === 3 ? got[2] : got[1];
109
+ r += opener;
110
+ if (schema.errorMessage?.[key] !== void 0) r += prefix + JSON.stringify(schema.errorMessage[key]);
111
+ r += closer;
112
+ }
113
+ }
114
+ return r;
115
+ }
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
118
+ const parseArray = (schema, refs) => {
119
+ if (Array.isArray(schema.items)) return `z.tuple([${schema.items.map((v, i) => parseSchema(v, {
120
+ ...refs,
121
+ path: [
122
+ ...refs.path,
123
+ "items",
124
+ i
125
+ ]
126
+ }))}])`;
127
+ let r = !schema.items ? "z.array(z.any())" : `z.array(${parseSchema(schema.items, {
128
+ ...refs,
129
+ path: [...refs.path, "items"]
130
+ })})`;
131
+ r += withMessage(schema, "minItems", ({ json }) => [
132
+ `.min(${json}`,
133
+ ", ",
134
+ ")"
135
+ ]);
136
+ r += withMessage(schema, "maxItems", ({ json }) => [
137
+ `.max(${json}`,
138
+ ", ",
139
+ ")"
140
+ ]);
141
+ if (schema.uniqueItems === true) r += withMessage(schema, "uniqueItems", () => [
142
+ ".unique(",
143
+ "",
144
+ ")"
145
+ ]);
146
+ return r;
147
+ };
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
150
+ const parseConst = (schema) => {
151
+ return `z.literal(${JSON.stringify(schema.const)})`;
152
+ };
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
155
+ const parseEnum = (schema) => {
156
+ if (schema.enum.length === 0) return "z.never()";
157
+ else if (schema.enum.length === 1) return `z.literal(${JSON.stringify(schema.enum[0])})`;
158
+ else if (schema.enum.every((x) => typeof x === "string")) return `z.enum([${schema.enum.map((x) => JSON.stringify(x))}])`;
159
+ else return `z.union([${schema.enum.map((x) => `z.literal(${JSON.stringify(x)})`).join(", ")}])`;
160
+ };
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
163
+ const parseIfThenElse = (schema, refs) => {
164
+ const $if = parseSchema(schema.if, {
165
+ ...refs,
166
+ path: [...refs.path, "if"]
167
+ });
168
+ const $then = parseSchema(schema.then, {
169
+ ...refs,
170
+ path: [...refs.path, "then"]
171
+ });
172
+ const $else = parseSchema(schema.else, {
173
+ ...refs,
174
+ path: [...refs.path, "else"]
175
+ });
176
+ return `z.union([${$then}, ${$else}]).superRefine((value,ctx) => {
177
+ const result = ${$if}.safeParse(value).success
178
+ ? ${$then}.safeParse(value)
179
+ : ${$else}.safeParse(value);
180
+ if (!result.success) {
181
+ result.error.errors.forEach((error) => ctx.addIssue(error))
182
+ }
183
+ })`;
184
+ };
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
187
+ const parseNumber = (schema) => {
188
+ let r = "z.number()";
189
+ if (schema.type === "integer") r += withMessage(schema, "type", () => [".int(", ")"]);
190
+ else r += withMessage(schema, "format", ({ value }) => {
191
+ if (value === "int64") return [".int(", ")"];
192
+ });
193
+ r += withMessage(schema, "multipleOf", ({ value, json }) => {
194
+ if (value === 1) {
195
+ if (r.startsWith("z.number().int(")) return;
196
+ return [".int(", ")"];
197
+ }
198
+ return [
199
+ `.multipleOf(${json}`,
200
+ ", ",
201
+ ")"
202
+ ];
203
+ });
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 }) => [
215
+ `.gt(${json}`,
216
+ ", ",
217
+ ")"
218
+ ]);
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 }) => [
230
+ `.lt(${json}`,
231
+ ", ",
232
+ ")"
233
+ ]);
234
+ return r;
235
+ };
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
238
+ const parseOneOf = (schema, refs) => {
239
+ return schema.oneOf.length ? schema.oneOf.length === 1 ? parseSchema(schema.oneOf[0], {
240
+ ...refs,
241
+ path: [
242
+ ...refs.path,
243
+ "oneOf",
244
+ 0
245
+ ]
246
+ }) : `z.any().superRefine((x, ctx) => {
247
+ const schemas = [${schema.oneOf.map((schema, i) => parseSchema(schema, {
248
+ ...refs,
249
+ path: [
250
+ ...refs.path,
251
+ "oneOf",
252
+ i
253
+ ]
254
+ })).join(", ")}];
255
+ const errors = schemas.reduce<z.ZodError[]>(
256
+ (errors, schema) =>
257
+ ((result) =>
258
+ result.error ? [...errors, result.error] : errors)(
259
+ schema.safeParse(x),
260
+ ),
261
+ [],
262
+ );
263
+ if (schemas.length - errors.length !== 1) {
264
+ ctx.addIssue({
265
+ path: ctx.path,
266
+ code: "invalid_union",
267
+ unionErrors: errors,
268
+ message: "Invalid input: Should pass single schema",
269
+ });
270
+ }
271
+ })` : "z.any()";
272
+ };
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
275
+ const expandJsdocs = (jsdocs) => {
276
+ const lines = jsdocs.split("\n");
277
+ return `/**${lines.length === 1 ? lines[0] : `\n${lines.map((x) => `* ${x}`).join("\n")}\n`}*/\n`;
278
+ };
279
+ const addJsdocs = (schema, parsed) => {
280
+ const description = schema.description;
281
+ if (!description) return parsed;
282
+ return `\n${expandJsdocs(description)}${parsed}`;
283
+ };
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
6
286
  function parseObject(objectSchema, refs) {
7
287
  let properties = void 0;
8
288
  if (objectSchema.properties) if (!Object.keys(objectSchema.properties).length) properties = "z.object({})";
@@ -10,7 +290,7 @@ function parseObject(objectSchema, refs) {
10
290
  properties = "z.object({ ";
11
291
  properties += Object.keys(objectSchema.properties).map((key) => {
12
292
  const propSchema = objectSchema.properties[key];
13
- let result = `${JSON.stringify(key)}: ${(0, json_schema_to_zod.parseSchema)(propSchema, {
293
+ let result = `${JSON.stringify(key)}: ${parseSchema(propSchema, {
14
294
  ...refs,
15
295
  path: [
16
296
  ...refs.path,
@@ -18,21 +298,21 @@ function parseObject(objectSchema, refs) {
18
298
  key
19
299
  ]
20
300
  })}`;
21
- if (refs.withJsdocs && typeof propSchema === "object") result = (0, json_schema_to_zod.addJsdocs)(propSchema, result);
301
+ if (refs.withJsdocs && typeof propSchema === "object") result = addJsdocs(propSchema, result);
22
302
  const hasDefault = typeof propSchema === "object" && propSchema.default !== void 0;
23
303
  const required = Array.isArray(objectSchema.required) ? objectSchema.required.includes(key) : typeof propSchema === "object" && propSchema.required === true;
24
304
  return !hasDefault && !required ? `${result}.optional()` : result;
25
305
  }).join(", ");
26
306
  properties += " })";
27
307
  }
28
- const additionalProperties = objectSchema.additionalProperties !== void 0 && objectSchema.additionalProperties !== false ? (0, json_schema_to_zod.parseSchema)(objectSchema.additionalProperties, {
308
+ const additionalProperties = objectSchema.additionalProperties !== void 0 ? parseSchema(objectSchema.additionalProperties, {
29
309
  ...refs,
30
310
  path: [...refs.path, "additionalProperties"]
31
311
  }) : void 0;
32
312
  let patternProperties = void 0;
33
313
  if (objectSchema.patternProperties) {
34
314
  const parsedPatternProperties = Object.fromEntries(Object.entries(objectSchema.patternProperties).map(([key, value]) => {
35
- return [key, (0, json_schema_to_zod.parseSchema)(value, {
315
+ return [key, parseSchema(value, {
36
316
  ...refs,
37
317
  path: [
38
318
  ...refs.path,
@@ -87,21 +367,356 @@ function parseObject(objectSchema, refs) {
87
367
  patternProperties += "})";
88
368
  }
89
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())";
90
- if (json_schema_to_zod.its.an.anyOf(objectSchema)) output += `.and(${(0, json_schema_to_zod.parseAnyOf)({
370
+ if (its.an.anyOf(objectSchema)) output += `.and(${parseAnyOf({
91
371
  ...objectSchema,
92
372
  anyOf: objectSchema.anyOf.map((x) => typeof x === "object" && !x.type && (x.properties || x.additionalProperties || x.patternProperties) ? {
93
373
  ...x,
94
374
  type: "object"
95
375
  } : x)
96
376
  }, refs)})`;
97
- if (json_schema_to_zod.its.a.oneOf(objectSchema)) output += `.and(${(0, json_schema_to_zod.parseOneOf)({
377
+ if (its.a.oneOf(objectSchema)) output += `.and(${parseOneOf({
98
378
  ...objectSchema,
99
379
  oneOf: objectSchema.oneOf.map((x) => typeof x === "object" && !x.type && (x.properties || x.additionalProperties || x.patternProperties) ? {
100
380
  ...x,
101
381
  type: "object"
102
382
  } : x)
103
383
  }, refs)})`;
104
- if (json_schema_to_zod.its.an.allOf(objectSchema)) output += `.and(${(0, json_schema_to_zod.parseAllOf)({
384
+ if (its.an.allOf(objectSchema)) output += `.and(${parseAllOf({
385
+ ...objectSchema,
386
+ allOf: objectSchema.allOf.map((x) => typeof x === "object" && !x.type && (x.properties || x.additionalProperties || x.patternProperties) ? {
387
+ ...x,
388
+ type: "object"
389
+ } : x)
390
+ }, refs)})`;
391
+ return output;
392
+ }
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
395
+ const parseString = (schema) => {
396
+ let r = "z.string()";
397
+ r += withMessage(schema, "format", ({ value }) => {
398
+ switch (value) {
399
+ case "email": return [".email(", ")"];
400
+ case "ip": return [".ip(", ")"];
401
+ case "ipv4": return [
402
+ ".ip({ version: \"v4\"",
403
+ ", message: ",
404
+ " })"
405
+ ];
406
+ case "ipv6": return [
407
+ ".ip({ version: \"v6\"",
408
+ ", message: ",
409
+ " })"
410
+ ];
411
+ case "uri": return [".url(", ")"];
412
+ case "uuid": return [".uuid(", ")"];
413
+ case "date-time": return [
414
+ ".datetime({ offset: true",
415
+ ", message: ",
416
+ " })"
417
+ ];
418
+ case "time": return [".time(", ")"];
419
+ case "date": return [".date(", ")"];
420
+ case "binary": return [".base64(", ")"];
421
+ case "duration": return [".duration(", ")"];
422
+ }
423
+ });
424
+ r += withMessage(schema, "pattern", ({ json }) => [
425
+ `.regex(new RegExp(${json})`,
426
+ ", ",
427
+ ")"
428
+ ]);
429
+ r += withMessage(schema, "minLength", ({ json }) => [
430
+ `.min(${json}`,
431
+ ", ",
432
+ ")"
433
+ ]);
434
+ r += withMessage(schema, "maxLength", ({ json }) => [
435
+ `.max(${json}`,
436
+ ", ",
437
+ ")"
438
+ ]);
439
+ r += withMessage(schema, "contentEncoding", ({ value }) => {
440
+ if (value === "base64") return [".base64(", ")"];
441
+ });
442
+ const contentMediaType = withMessage(schema, "contentMediaType", ({ value }) => {
443
+ if (value === "application/json") return [
444
+ ".transform((str, ctx) => { try { return JSON.parse(str); } catch (err) { ctx.addIssue({ code: \"custom\", message: \"Invalid JSON\" }); }}",
445
+ ", ",
446
+ ")"
447
+ ];
448
+ });
449
+ if (contentMediaType != "") {
450
+ r += contentMediaType;
451
+ r += withMessage(schema, "contentSchema", ({ value }) => {
452
+ if (value && value instanceof Object) return [
453
+ `.pipe(${parseSchema(value)}`,
454
+ ", ",
455
+ ")"
456
+ ];
457
+ });
458
+ }
459
+ return r;
460
+ };
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
463
+ const parseSimpleDiscriminatedOneOf = (schema, refs) => {
464
+ return schema.oneOf.length ? schema.oneOf.length === 1 ? parseSchema(schema.oneOf[0], {
465
+ ...refs,
466
+ path: [
467
+ ...refs.path,
468
+ "oneOf",
469
+ 0
470
+ ]
471
+ }) : `z.discriminatedUnion("${schema.discriminator.propertyName}", [${schema.oneOf.map((schema, i) => parseSchema(schema, {
472
+ ...refs,
473
+ path: [
474
+ ...refs.path,
475
+ "oneOf",
476
+ i
477
+ ]
478
+ })).join(", ")}])` : "z.any()";
479
+ };
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
482
+ const omit = (obj, ...keys) => Object.keys(obj).reduce((acc, key) => {
483
+ if (!keys.includes(key)) acc[key] = obj[key];
484
+ return acc;
485
+ }, {});
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
488
+ /**
489
+ * For compatibility with open api 3.0 nullable
490
+ */
491
+ const parseNullable = (schema, refs) => {
492
+ return `${parseSchema(omit(schema, "nullable"), refs, true)}.nullable()`;
493
+ };
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
496
+ const parseSchema = (schema, refs = {
497
+ seen: /* @__PURE__ */ new Map(),
498
+ path: []
499
+ }, blockMeta) => {
500
+ if (typeof schema !== "object") return schema ? "z.any()" : "z.never()";
501
+ if (refs.parserOverride) {
502
+ const custom = refs.parserOverride(schema, refs);
503
+ if (typeof custom === "string") return custom;
504
+ }
505
+ let seen = refs.seen.get(schema);
506
+ if (seen) {
507
+ if (seen.r !== void 0) return seen.r;
508
+ if (refs.depth === void 0 || seen.n >= refs.depth) return "z.any()";
509
+ seen.n += 1;
510
+ } else {
511
+ seen = {
512
+ r: void 0,
513
+ n: 0
514
+ };
515
+ refs.seen.set(schema, seen);
516
+ }
517
+ let parsed = selectParser(schema, refs);
518
+ if (!blockMeta) {
519
+ if (!refs.withoutDescribes) parsed = addDescribes$1(schema, parsed);
520
+ if (!refs.withoutDefaults) parsed = addDefaults$1(schema, parsed);
521
+ parsed = addAnnotations$1(schema, parsed);
522
+ }
523
+ seen.r = parsed;
524
+ return parsed;
525
+ };
526
+ const addDescribes$1 = (schema, parsed) => {
527
+ if (schema.description) parsed += `.describe(${JSON.stringify(schema.description)})`;
528
+ return parsed;
529
+ };
530
+ const addDefaults$1 = (schema, parsed) => {
531
+ if (schema.default !== void 0) parsed += `.default(${JSON.stringify(schema.default)})`;
532
+ return parsed;
533
+ };
534
+ const addAnnotations$1 = (schema, parsed) => {
535
+ if (schema.readOnly) parsed += ".readonly()";
536
+ return parsed;
537
+ };
538
+ const selectParser = (schema, refs) => {
539
+ if (its.a.nullable(schema)) return parseNullable(schema, refs);
540
+ else if (its.an.object(schema)) return parseObject(schema, refs);
541
+ else if (its.an.array(schema)) return parseArray(schema, refs);
542
+ else if (its.an.anyOf(schema)) return parseAnyOf(schema, refs);
543
+ else if (its.an.allOf(schema)) return parseAllOf(schema, refs);
544
+ else if (its.a.simpleDiscriminatedOneOf(schema)) return parseSimpleDiscriminatedOneOf(schema, refs);
545
+ else if (its.a.oneOf(schema)) return parseOneOf(schema, refs);
546
+ else if (its.a.not(schema)) return parseNot(schema, refs);
547
+ else if (its.an.enum(schema)) return parseEnum(schema);
548
+ else if (its.a.const(schema)) return parseConst(schema);
549
+ else if (its.a.multipleType(schema)) return parseMultipleType(schema, refs);
550
+ else if (its.a.primitive(schema, "string")) return parseString(schema);
551
+ else if (its.a.primitive(schema, "number") || its.a.primitive(schema, "integer")) return parseNumber(schema);
552
+ else if (its.a.primitive(schema, "boolean")) return parseBoolean(schema);
553
+ else if (its.a.primitive(schema, "null")) return parseNull(schema);
554
+ else if (its.a.conditional(schema)) return parseIfThenElse(schema, refs);
555
+ else return parseDefault(schema);
556
+ };
557
+ const its = {
558
+ an: {
559
+ object: (x) => x.type === "object",
560
+ array: (x) => x.type === "array",
561
+ anyOf: (x) => x.anyOf !== void 0,
562
+ allOf: (x) => x.allOf !== void 0,
563
+ enum: (x) => x.enum !== void 0
564
+ },
565
+ a: {
566
+ nullable: (x) => x.nullable === true,
567
+ multipleType: (x) => Array.isArray(x.type),
568
+ not: (x) => x.not !== void 0,
569
+ const: (x) => x.const !== void 0,
570
+ primitive: (x, p) => x.type === p,
571
+ conditional: (x) => Boolean("if" in x && x.if && "then" in x && "else" in x && x.then && x.else),
572
+ simpleDiscriminatedOneOf: (x) => {
573
+ if (!x.oneOf || !Array.isArray(x.oneOf) || x.oneOf.length === 0 || !x.discriminator || typeof x.discriminator !== "object" || !("propertyName" in x.discriminator) || typeof x.discriminator.propertyName !== "string") return false;
574
+ const discriminatorProp = x.discriminator.propertyName;
575
+ return x.oneOf.every((schema) => {
576
+ if (!schema || typeof schema !== "object" || schema.type !== "object" || !schema.properties || typeof schema.properties !== "object" || !(discriminatorProp in schema.properties)) return false;
577
+ const property = schema.properties[discriminatorProp];
578
+ return property && typeof property === "object" && property.type === "string" && (property.const !== void 0 || property.enum && Array.isArray(property.enum) && property.enum.length === 1) && Array.isArray(schema.required) && schema.required.includes(discriminatorProp);
579
+ });
580
+ },
581
+ oneOf: (x) => x.oneOf !== void 0
582
+ }
583
+ };
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 } = {}) => {
587
+ if (type && (!name || module !== "esm")) throw new Error("Option `type` requires `name` to be set and `module` to be `esm`");
588
+ let result = parseSchema(schema, {
589
+ module,
590
+ name,
591
+ path: [],
592
+ seen: /* @__PURE__ */ new Map(),
593
+ ...rest
594
+ });
595
+ const jsdocs = rest.withJsdocs && typeof schema !== "boolean" && schema.description ? expandJsdocs(schema.description) : "";
596
+ if (module === "cjs") {
597
+ result = `${jsdocs}module.exports = ${name ? `{ ${JSON.stringify(name)}: ${result} }` : result}
598
+ `;
599
+ if (!noImport) result = `${jsdocs}const { z } = require("zod")
600
+
601
+ ${result}`;
602
+ } else if (module === "esm") {
603
+ result = `${jsdocs}export ${name ? `const ${name} =` : `default`} ${result}
604
+ `;
605
+ if (!noImport) result = `import { z } from "zod"
606
+
607
+ ${result}`;
608
+ } else if (name) result = `${jsdocs}const ${name} = ${result}`;
609
+ if (type && name) {
610
+ let typeName = typeof type === "string" ? type : `${name[0].toUpperCase()}${name.substring(1)}`;
611
+ result += `export type ${typeName} = z.infer<typeof ${name}>
612
+ `;
613
+ }
614
+ return result;
615
+ };
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
618
+ var esm_default = jsonSchemaToZod$1;
619
+ //#endregion
620
+ //#region src/json-to-zod.ts
621
+ function parseObject$1(objectSchema, refs) {
622
+ 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 += " })";
642
+ }
643
+ const additionalProperties = objectSchema.additionalProperties !== void 0 && objectSchema.additionalProperties !== false ? parseSchema(objectSchema.additionalProperties, {
644
+ ...refs,
645
+ path: [...refs.path, "additionalProperties"]
646
+ }) : void 0;
647
+ let patternProperties = void 0;
648
+ if (objectSchema.patternProperties) {
649
+ const parsedPatternProperties = Object.fromEntries(Object.entries(objectSchema.patternProperties).map(([key, value]) => {
650
+ return [key, parseSchema(value, {
651
+ ...refs,
652
+ path: [
653
+ ...refs.path,
654
+ "patternProperties",
655
+ key
656
+ ]
657
+ })];
658
+ }, {}));
659
+ 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(", ")}]))`;
664
+ else if (Object.keys(parsedPatternProperties).length > 1) patternProperties += `z.record(z.string(), z.union([${Object.values(parsedPatternProperties).join(", ")}]))`;
665
+ else patternProperties += `z.record(z.string(), ${Object.values(parsedPatternProperties)})`;
666
+ patternProperties += ".superRefine((value, ctx) => {\n";
667
+ 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`;
670
+ for (const key in objectSchema.patternProperties) {
671
+ patternProperties += "if (key.match(new RegExp(" + JSON.stringify(key) + "))) {\n";
672
+ if (additionalProperties) patternProperties += "evaluated = true\n";
673
+ patternProperties += "const result = " + parsedPatternProperties[key] + ".safeParse(value[key])\n";
674
+ patternProperties += "if (!result.success) {\n";
675
+ patternProperties += `ctx.addIssue({
676
+ path: [...ctx.path, key],
677
+ code: 'custom',
678
+ message: \`Invalid input: Key matching regex /\${key}/ must match schema\`,
679
+ params: {
680
+ issues: result.error.issues
681
+ }
682
+ })\n`;
683
+ patternProperties += "}\n";
684
+ patternProperties += "}\n";
685
+ }
686
+ if (additionalProperties) {
687
+ patternProperties += "if (!evaluated) {\n";
688
+ patternProperties += "const result = " + additionalProperties + ".safeParse(value[key])\n";
689
+ patternProperties += "if (!result.success) {\n";
690
+ patternProperties += `ctx.addIssue({
691
+ path: [...ctx.path, key],
692
+ code: 'custom',
693
+ message: \`Invalid input: must match catchall schema\`,
694
+ params: {
695
+ issues: result.error.issues
696
+ }
697
+ })\n`;
698
+ patternProperties += "}\n";
699
+ patternProperties += "}\n";
700
+ }
701
+ patternProperties += "}\n";
702
+ patternProperties += "})";
703
+ }
704
+ let output = properties ? patternProperties ? properties + patternProperties : additionalProperties ? additionalProperties === "z.never()" ? properties + ".strict()" : properties + `.catchall(${additionalProperties})` : properties : patternProperties ? patternProperties : additionalProperties ? `z.record(z.string(), ${additionalProperties})` : "z.record(z.string(), z.any())";
705
+ if (its.an.anyOf(objectSchema)) output += `.and(${parseAnyOf({
706
+ ...objectSchema,
707
+ anyOf: objectSchema.anyOf.map((x) => typeof x === "object" && !x.type && (x.properties || x.additionalProperties || x.patternProperties) ? {
708
+ ...x,
709
+ type: "object"
710
+ } : x)
711
+ }, refs)})`;
712
+ if (its.a.oneOf(objectSchema)) output += `.and(${parseOneOf({
713
+ ...objectSchema,
714
+ oneOf: objectSchema.oneOf.map((x) => typeof x === "object" && !x.type && (x.properties || x.additionalProperties || x.patternProperties) ? {
715
+ ...x,
716
+ type: "object"
717
+ } : x)
718
+ }, refs)})`;
719
+ if (its.an.allOf(objectSchema)) output += `.and(${parseAllOf({
105
720
  ...objectSchema,
106
721
  allOf: objectSchema.allOf.map((x) => typeof x === "object" && !x.type && (x.properties || x.additionalProperties || x.patternProperties) ? {
107
722
  ...x,
@@ -113,11 +728,11 @@ function parseObject(objectSchema, refs) {
113
728
  const parserOverride = (schema, refs) => {
114
729
  let parsed = "";
115
730
  let seen = refs.seen.get(schema);
116
- if (json_schema_to_zod.its.an.anyOf(schema)) {
117
- const allObjects = schema.anyOf.every((item) => typeof item === "object" && json_schema_to_zod.its.an.object(item) && item.properties !== void 0);
731
+ if (its.an.anyOf(schema)) {
732
+ const allObjects = schema.anyOf.every((item) => typeof item === "object" && its.an.object(item) && item.properties !== void 0);
118
733
  if (schema.anyOf.length > 1 && allObjects) {
119
734
  const propertiesWithConst = schema.anyOf.reduce((acc, item) => {
120
- if (typeof item === "object" && json_schema_to_zod.its.an.object(item)) {
735
+ if (typeof item === "object" && its.an.object(item)) {
121
736
  const propertyWithConst = Object.entries(item.properties ?? {}).filter(([_, value]) => typeof value === "object" && value?.const !== void 0);
122
737
  if (propertyWithConst?.length) {
123
738
  const ppties = propertyWithConst.map(([key, _]) => key);
@@ -143,7 +758,7 @@ const parserOverride = (schema, refs) => {
143
758
  }, propertiesWithConst[0]) : [];
144
759
  if (discriminators.length > 0) {
145
760
  const discriminator = discriminators[0];
146
- if (discriminator) parsed = `z.discriminatedUnion("${discriminator}", [${schema.anyOf.map((schema, i) => (0, json_schema_to_zod.parseSchema)(schema, {
761
+ if (discriminator) parsed = `z.discriminatedUnion("${discriminator}", [${schema.anyOf.map((schema, i) => parseSchema(schema, {
147
762
  ...refs,
148
763
  path: [
149
764
  ...refs.path,
@@ -154,7 +769,7 @@ const parserOverride = (schema, refs) => {
154
769
  }
155
770
  }
156
771
  }
157
- } else if (json_schema_to_zod.its.an.object(schema)) {
772
+ } else if (its.an.object(schema)) {
158
773
  if (seen) {
159
774
  if (seen.r !== void 0) return seen.r;
160
775
  if (refs.depth === void 0 || seen.n >= refs.depth) return "z.any()";
@@ -166,7 +781,7 @@ const parserOverride = (schema, refs) => {
166
781
  };
167
782
  refs.seen.set(schema, seen);
168
783
  }
169
- parsed = parseObject(schema, refs);
784
+ parsed = parseObject$1(schema, refs);
170
785
  }
171
786
  if (parsed) {
172
787
  if (!refs.withoutDescribes) parsed = addDescribes(schema, parsed);
@@ -189,20 +804,36 @@ const addAnnotations = (schema, parsed) => {
189
804
  return parsed;
190
805
  };
191
806
  function jsonSchemaToZod(schema, options = {}) {
192
- return (0, json_schema_to_zod.default)(schema, {
807
+ return esm_default(schema, {
193
808
  ...options,
194
809
  parserOverride
195
810
  }).replace(/\.reduce<[^>]+>/g, ".reduce");
196
811
  }
197
812
  //#endregion
813
+ exports.addJsdocs = addJsdocs;
814
+ exports.expandJsdocs = expandJsdocs;
815
+ exports.half = half;
816
+ exports.its = its;
198
817
  exports.jsonSchemaToZod = jsonSchemaToZod;
199
- Object.keys(json_schema_to_zod).forEach(function(k) {
200
- if (k !== "default" && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
201
- enumerable: true,
202
- get: function() {
203
- return json_schema_to_zod[k];
204
- }
205
- });
206
- });
818
+ exports.omit = omit;
819
+ exports.parseAllOf = parseAllOf;
820
+ exports.parseAnyOf = parseAnyOf;
821
+ exports.parseArray = parseArray;
822
+ exports.parseBoolean = parseBoolean;
823
+ exports.parseConst = parseConst;
824
+ exports.parseDefault = parseDefault;
825
+ exports.parseEnum = parseEnum;
826
+ exports.parseIfThenElse = parseIfThenElse;
827
+ exports.parseMultipleType = parseMultipleType;
828
+ exports.parseNot = parseNot;
829
+ exports.parseNull = parseNull;
830
+ exports.parseNullable = parseNullable;
831
+ exports.parseNumber = parseNumber;
832
+ exports.parseObject = parseObject;
833
+ exports.parseOneOf = parseOneOf;
834
+ exports.parseSchema = parseSchema;
835
+ exports.parseSimpleDiscriminatedOneOf = parseSimpleDiscriminatedOneOf;
836
+ exports.parseString = parseString;
837
+ exports.withMessage = withMessage;
207
838
 
208
839
  //# sourceMappingURL=json-to-zod.cjs.map