@mastra/schema-compat 0.0.0-remove-unused-model-providers-api-20251030210744 → 0.0.0-scorers-logs-20251208093427

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,6 +1,106 @@
1
1
  # @mastra/schema-compat
2
2
 
3
- ## 0.0.0-remove-unused-model-providers-api-20251030210744
3
+ ## 0.0.0-scorers-logs-20251208093427
4
+
5
+ ### Major Changes
6
+
7
+ - Bump minimum required Node.js version to 22.13.0 ([#9706](https://github.com/mastra-ai/mastra/pull/9706))
8
+
9
+ - Mark as stable ([`83d5942`](https://github.com/mastra-ai/mastra/commit/83d5942669ce7bba4a6ca4fd4da697a10eb5ebdc))
10
+
11
+ ### Patch Changes
12
+
13
+ - Fix Zod v4 toJSONSchema bug with z.record() single-argument form ([#9265](https://github.com/mastra-ai/mastra/pull/9265))
14
+
15
+ Zod v4 has a bug in the single-argument form of `z.record(valueSchema)` where it incorrectly assigns the value schema to `keyType` instead of `valueType`, leaving `valueType` undefined. This causes `toJSONSchema()` to throw "Cannot read properties of undefined (reading '\_zod')" when processing schemas containing `z.record()` fields.
16
+
17
+ This fix patches affected schemas before conversion by detecting records with missing `valueType` and correctly assigning the schema to `valueType` while setting `keyType` to `z.string()` (the default). The patch recursively handles nested schemas including those wrapped in `.optional()`, `.nullable()`, arrays, unions, and objects.
18
+
19
+ - Improved reliability of string field types in tool schema compatibility ([#9266](https://github.com/mastra-ai/mastra/pull/9266))
20
+
21
+ - Fix discriminatedUnion schema information lost when json schema is converted to zod ([#10500](https://github.com/mastra-ai/mastra/pull/10500))
22
+
23
+ - Fixed OpenAI schema compatibility when using `agent.generate()` or `agent.stream()` with `structuredOutput`. ([#10366](https://github.com/mastra-ai/mastra/pull/10366))
24
+
25
+ ## Changes
26
+ - **Automatic transformation**: Zod schemas are now automatically transformed for OpenAI strict mode compatibility when using OpenAI models (including reasoning models like o1, o3, o4)
27
+ - **Optional field handling**: `.optional()` fields are converted to `.nullable()` with a transform that converts `null` → `undefined`, preserving optional semantics while satisfying OpenAI's strict mode requirements
28
+ - **Preserves nullable fields**: Intentionally `.nullable()` fields remain unchanged
29
+ - **Deep transformation**: Handles `.optional()` fields at any nesting level (objects, arrays, unions, etc.)
30
+ - **JSON Schema objects**: Not transformed, only Zod schemas
31
+
32
+ ## Example
33
+
34
+ ```typescript
35
+ const agent = new Agent({
36
+ name: 'data-extractor',
37
+ model: { provider: 'openai', modelId: 'gpt-4o' },
38
+ instructions: 'Extract user information',
39
+ });
40
+
41
+ const schema = z.object({
42
+ name: z.string(),
43
+ age: z.number().optional(),
44
+ deletedAt: z.date().nullable(),
45
+ });
46
+
47
+ // Schema is automatically transformed for OpenAI compatibility
48
+ const result = await agent.generate('Extract: John, deleted yesterday', {
49
+ structuredOutput: { schema },
50
+ });
51
+
52
+ // Result: { name: 'John', age: undefined, deletedAt: null }
53
+ ```
54
+
55
+ ## 1.0.0-beta.2
56
+
57
+ ### Patch Changes
58
+
59
+ - Fix discriminatedUnion schema information lost when json schema is converted to zod ([#10500](https://github.com/mastra-ai/mastra/pull/10500))
60
+
61
+ ## 1.0.0-beta.1
62
+
63
+ ### Patch Changes
64
+
65
+ - Fixed OpenAI schema compatibility when using `agent.generate()` or `agent.stream()` with `structuredOutput`. ([#10366](https://github.com/mastra-ai/mastra/pull/10366))
66
+
67
+ ## Changes
68
+ - **Automatic transformation**: Zod schemas are now automatically transformed for OpenAI strict mode compatibility when using OpenAI models (including reasoning models like o1, o3, o4)
69
+ - **Optional field handling**: `.optional()` fields are converted to `.nullable()` with a transform that converts `null` → `undefined`, preserving optional semantics while satisfying OpenAI's strict mode requirements
70
+ - **Preserves nullable fields**: Intentionally `.nullable()` fields remain unchanged
71
+ - **Deep transformation**: Handles `.optional()` fields at any nesting level (objects, arrays, unions, etc.)
72
+ - **JSON Schema objects**: Not transformed, only Zod schemas
73
+
74
+ ## Example
75
+
76
+ ```typescript
77
+ const agent = new Agent({
78
+ name: 'data-extractor',
79
+ model: { provider: 'openai', modelId: 'gpt-4o' },
80
+ instructions: 'Extract user information',
81
+ });
82
+
83
+ const schema = z.object({
84
+ name: z.string(),
85
+ age: z.number().optional(),
86
+ deletedAt: z.date().nullable(),
87
+ });
88
+
89
+ // Schema is automatically transformed for OpenAI compatibility
90
+ const result = await agent.generate('Extract: John, deleted yesterday', {
91
+ structuredOutput: { schema },
92
+ });
93
+
94
+ // Result: { name: 'John', age: undefined, deletedAt: null }
95
+ ```
96
+
97
+ ## 1.0.0-beta.0
98
+
99
+ ### Major Changes
100
+
101
+ - Bump minimum required Node.js version to 22.13.0 ([#9706](https://github.com/mastra-ai/mastra/pull/9706))
102
+
103
+ - Mark as stable ([`83d5942`](https://github.com/mastra-ai/mastra/commit/83d5942669ce7bba4a6ca4fd4da697a10eb5ebdc))
4
104
 
5
105
  ### Patch Changes
6
106