@mastra/schema-compat 1.3.2 → 1.3.3-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.
package/dist/index.js CHANGED
@@ -4137,6 +4137,10 @@ var SUPPORTED_ZOD_TYPES2 = [
4137
4137
  "ZodDefault",
4138
4138
  "ZodNullable"
4139
4139
  ];
4140
+ function zodV4TypeName(value) {
4141
+ const v4Type = value?._zod?.def?.type;
4142
+ return v4Type ? "Zod" + v4Type.charAt(0).toUpperCase() + v4Type.slice(1) : "";
4143
+ }
4140
4144
  var SchemaCompatLayer2 = class {
4141
4145
  model;
4142
4146
  parent;
@@ -4535,8 +4539,9 @@ var SchemaCompatLayer2 = class {
4535
4539
  * @returns The processed Zod optional
4536
4540
  */
4537
4541
  defaultZodOptionalHandler(value, handleTypes = SUPPORTED_ZOD_TYPES2) {
4538
- if (handleTypes.includes(value.constructor.name)) {
4539
- return this.processZodType(value._zod.def.innerType).optional();
4542
+ const innerType = value._zod?.def?.innerType;
4543
+ if (innerType && handleTypes.includes(zodV4TypeName(innerType))) {
4544
+ return this.processZodType(innerType).optional();
4540
4545
  } else {
4541
4546
  return value;
4542
4547
  }
@@ -4549,8 +4554,9 @@ var SchemaCompatLayer2 = class {
4549
4554
  * @returns The processed Zod nullable
4550
4555
  */
4551
4556
  defaultZodNullableHandler(value, handleTypes = SUPPORTED_ZOD_TYPES2) {
4552
- if (handleTypes.includes(value.constructor.name)) {
4553
- return this.processZodType(value._zod.def.innerType).nullable();
4557
+ const innerType = value._zod?.def?.innerType;
4558
+ if (innerType && handleTypes.includes(zodV4TypeName(innerType))) {
4559
+ return this.processZodType(innerType).nullable();
4554
4560
  } else {
4555
4561
  return value;
4556
4562
  }