@mastra/schema-compat 0.11.7 → 1.0.0-beta.1

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,46 +1,58 @@
1
1
  # @mastra/schema-compat
2
2
 
3
- ## 0.11.7
3
+ ## 1.0.0-beta.1
4
4
 
5
5
  ### Patch Changes
6
6
 
7
- - update peerdeps ([`5ca1cca`](https://github.com/mastra-ai/mastra/commit/5ca1ccac61ffa7141e6d9fa8f22d3ad4d03bf5dc))
7
+ - Fixed OpenAI schema compatibility when using `agent.generate()` or `agent.stream()` with `structuredOutput`. ([#10366](https://github.com/mastra-ai/mastra/pull/10366))
8
8
 
9
- ## 0.11.7-alpha.0
9
+ ## Changes
10
+ - **Automatic transformation**: Zod schemas are now automatically transformed for OpenAI strict mode compatibility when using OpenAI models (including reasoning models like o1, o3, o4)
11
+ - **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
12
+ - **Preserves nullable fields**: Intentionally `.nullable()` fields remain unchanged
13
+ - **Deep transformation**: Handles `.optional()` fields at any nesting level (objects, arrays, unions, etc.)
14
+ - **JSON Schema objects**: Not transformed, only Zod schemas
10
15
 
11
- ### Patch Changes
16
+ ## Example
12
17
 
13
- - update peerdeps ([`5ca1cca`](https://github.com/mastra-ai/mastra/commit/5ca1ccac61ffa7141e6d9fa8f22d3ad4d03bf5dc))
18
+ ```typescript
19
+ const agent = new Agent({
20
+ name: 'data-extractor',
21
+ model: { provider: 'openai', modelId: 'gpt-4o' },
22
+ instructions: 'Extract user information',
23
+ });
14
24
 
15
- ## 0.11.6
25
+ const schema = z.object({
26
+ name: z.string(),
27
+ age: z.number().optional(),
28
+ deletedAt: z.date().nullable(),
29
+ });
16
30
 
17
- ### Patch Changes
31
+ // Schema is automatically transformed for OpenAI compatibility
32
+ const result = await agent.generate('Extract: John, deleted yesterday', {
33
+ structuredOutput: { schema },
34
+ });
18
35
 
19
- - Fix Zod v4 toJSONSchema bug with z.record() single-argument form ([#9355](https://github.com/mastra-ai/mastra/pull/9355))
36
+ // Result: { name: 'John', age: undefined, deletedAt: null }
37
+ ```
20
38
 
21
- 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.
39
+ ## 1.0.0-beta.0
22
40
 
23
- 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.
41
+ ### Major Changes
24
42
 
25
- - Improved reliability of string field types in tool schema compatibility ([#9362](https://github.com/mastra-ai/mastra/pull/9362))
43
+ - Bump minimum required Node.js version to 22.13.0 ([#9706](https://github.com/mastra-ai/mastra/pull/9706))
26
44
 
27
- ## 0.11.6-alpha.0
45
+ - Mark as stable ([`83d5942`](https://github.com/mastra-ai/mastra/commit/83d5942669ce7bba4a6ca4fd4da697a10eb5ebdc))
28
46
 
29
47
  ### Patch Changes
30
48
 
31
- - Fix Zod v4 toJSONSchema bug with z.record() single-argument form ([#9355](https://github.com/mastra-ai/mastra/pull/9355))
49
+ - Fix Zod v4 toJSONSchema bug with z.record() single-argument form ([#9265](https://github.com/mastra-ai/mastra/pull/9265))
32
50
 
33
51
  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.
34
52
 
35
53
  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.
36
54
 
37
- - Improved reliability of string field types in tool schema compatibility ([#9362](https://github.com/mastra-ai/mastra/pull/9362))
38
-
39
- ## 0.11.5
40
-
41
- ### Patch Changes
42
-
43
- - Fix peerdependencies ([`eb7c1c8`](https://github.com/mastra-ai/mastra/commit/eb7c1c8c592d8fb16dfd250e337d9cdc73c8d5de))
55
+ - Improved reliability of string field types in tool schema compatibility ([#9266](https://github.com/mastra-ai/mastra/pull/9266))
44
56
 
45
57
  ## 0.11.4
46
58