@mastra/schema-compat 1.3.2-alpha.1 → 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/CHANGELOG.md CHANGED
@@ -1,5 +1,21 @@
1
1
  # @mastra/schema-compat
2
2
 
3
+ ## 1.3.3-alpha.0
4
+
5
+ ### Patch Changes
6
+
7
+ - Fix the Zod v4 nullable and optional handlers gating on the wrapper type instead of the wrapped inner type. They checked `value.constructor.name` (always `"ZodNullable"`/`"ZodOptional"`), so the inner type was always processed. A nullable/optional wrapping an unsupported inner type (such as a tuple) is now passed through unchanged, matching the v3 handler, instead of being processed and rejected. Closes #18687. ([#18688](https://github.com/mastra-ai/mastra/pull/18688))
8
+
9
+ ## 1.3.2
10
+
11
+ ### Patch Changes
12
+
13
+ - Fix the Zod v4 string handler silently dropping unrecognized `string_format` checks. Formats without a textual description (such as `ipv4`, `ipv6`, `datetime`, `date`, `time`, `base64`, `cuid2`, `ulid`, `nanoid`, `jwt`) are now preserved as validation instead of being removed, so schemas using them keep rejecting invalid input. Closes #18634. ([#18673](https://github.com/mastra-ai/mastra/pull/18673))
14
+
15
+ - Fix inverted date constraint descriptions in the Zod v4 schema handler. `z.date().min()` and `z.date().max()` were described with their bounds swapped (a lower bound was labelled "older than" and an upper bound "newer than"), so the schema sent to the model stated the opposite and impossible constraint. The handler now matches Zod semantics and the existing v3 handler. Closes #18581. ([#18582](https://github.com/mastra-ai/mastra/pull/18582))
16
+
17
+ - Fixed 'Type instantiation is excessively deep' (TS2589) errors that occurred when defining workflows with Zod schemas. Workflow and step type inference is now significantly faster and no longer causes TypeScript to crash or report depth errors. ([#18608](https://github.com/mastra-ai/mastra/pull/18608))
18
+
3
19
  ## 1.3.2-alpha.1
4
20
 
5
21
  ### Patch Changes
package/dist/index.cjs 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
  }