@mastra/schema-compat 1.1.0-alpha.0 → 1.1.1-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,45 @@
1
1
  # @mastra/schema-compat
2
2
 
3
+ ## 1.1.1-alpha.0
4
+
5
+ ### Patch Changes
6
+
7
+ - fix(schema-compat): fix zodToJsonSchema routing for v3/v4 Zod schemas ([#13253](https://github.com/mastra-ai/mastra/pull/13253))
8
+
9
+ The `zodToJsonSchema` function now reliably detects and routes Zod v3 vs v4 schemas regardless of which version the ambient `zod` import resolves to. Previously, the detection relied on checking `'toJSONSchema' in z` against the ambient `z` import, which could resolve to either v3 or v4 depending on the environment (monorepo vs global install). This caused v3 schemas to be passed to v4's `toJSONSchema()` (crashing with "Cannot read properties of undefined (reading 'def')") or v4 schemas to be passed to the v3 converter (producing schemas missing the `type` field).
10
+
11
+ The fix explicitly imports `z as zV4` from `zod/v4` and routes based on the schema's own `_zod` property, making the behavior environment-independent.
12
+
13
+ Also migrates all mastracode tool files from `zod/v3` to `zod` imports now that the schema-compat fix supports both versions correctly.
14
+
15
+ ## 1.1.0
16
+
17
+ ### Minor Changes
18
+
19
+ - Added [Standard Schema](https://github.com/standard-schema/standard-schema) support to `@mastra/schema-compat`. This enables interoperability with any schema library that implements the Standard Schema specification. ([#12527](https://github.com/mastra-ai/mastra/pull/12527))
20
+
21
+ **New exports:**
22
+ - `toStandardSchema()` - Convert Zod, JSON Schema, or AI SDK schemas to Standard Schema format
23
+ - `StandardSchemaWithJSON` - Type for schemas implementing both validation and JSON Schema conversion
24
+ - `InferInput`, `InferOutput` - Utility types for type inference
25
+
26
+ **Example usage:**
27
+
28
+ ```typescript
29
+ import { toStandardSchema } from '@mastra/schema-compat/schema';
30
+ import { z } from 'zod';
31
+
32
+ // Convert a Zod schema to Standard Schema
33
+ const zodSchema = z.object({ name: z.string(), age: z.number() });
34
+ const standardSchema = toStandardSchema(zodSchema);
35
+
36
+ // Use validation
37
+ const result = standardSchema['~standard'].validate({ name: 'John', age: 30 });
38
+
39
+ // Get JSON Schema
40
+ const jsonSchema = standardSchema['~standard'].jsonSchema.output({ target: 'draft-07' });
41
+ ```
42
+
3
43
  ## 1.1.0-alpha.0
4
44
 
5
45
  ### Minor Changes