@mastra/schema-compat 0.10.2-alpha.2

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.
@@ -0,0 +1,312 @@
1
+ import { MockLanguageModelV1 } from 'ai/test';
2
+ import { describe, it, expect } from 'vitest';
3
+ import { z } from 'zod';
4
+ import {
5
+ AnthropicSchemaCompatLayer,
6
+ OpenAISchemaCompatLayer,
7
+ OpenAIReasoningSchemaCompatLayer,
8
+ GoogleSchemaCompatLayer,
9
+ DeepSeekSchemaCompatLayer,
10
+ MetaSchemaCompatLayer,
11
+ } from './index';
12
+
13
+ describe('Provider Compatibility Classes', () => {
14
+ const mockModels = {
15
+ anthropic: new MockLanguageModelV1({
16
+ modelId: 'claude-3-sonnet-20240229',
17
+ doGenerate: async () => ({ response: { id: 'test' } }) as any,
18
+ }),
19
+ openai: new MockLanguageModelV1({
20
+ modelId: 'openai/gpt-4',
21
+ doGenerate: async () => ({ response: { id: 'test' } }) as any,
22
+ }),
23
+ openaiReasoning: new MockLanguageModelV1({
24
+ modelId: 'openai/o3-mini',
25
+ doGenerate: async () => ({ response: { id: 'test' } }) as any,
26
+ }),
27
+ google: new MockLanguageModelV1({
28
+ modelId: 'gemini-pro',
29
+ doGenerate: async () => ({ response: { id: 'test' } }) as any,
30
+ }),
31
+ deepseek: new MockLanguageModelV1({
32
+ modelId: 'deepseek-chat',
33
+ doGenerate: async () => ({ response: { id: 'test' } }) as any,
34
+ }),
35
+ meta: new MockLanguageModelV1({
36
+ modelId: 'llama-3.1-405b-instruct',
37
+ doGenerate: async () => ({ response: { id: 'test' } }) as any,
38
+ }),
39
+ };
40
+
41
+ describe('AnthropicSchemaCompatLayer', () => {
42
+ it('should apply for Anthropic models', () => {
43
+ const compat = new AnthropicSchemaCompatLayer(mockModels.anthropic);
44
+ expect(compat.shouldApply()).toBe(true);
45
+ });
46
+
47
+ it('should not apply for non-Anthropic models', () => {
48
+ const compat = new AnthropicSchemaCompatLayer(mockModels.openai);
49
+ expect(compat.shouldApply()).toBe(false);
50
+ });
51
+
52
+ it('should return correct schema target', () => {
53
+ const compat = new AnthropicSchemaCompatLayer(mockModels.anthropic);
54
+ expect(compat.getSchemaTarget()).toBe('jsonSchema7');
55
+ });
56
+
57
+ it('should process schemas correctly', () => {
58
+ const compat = new AnthropicSchemaCompatLayer(mockModels.anthropic);
59
+ const schema = z.object({
60
+ text: z.string().min(1).max(100),
61
+ count: z.number().min(1),
62
+ });
63
+
64
+ const result = compat.processToAISDKSchema(schema);
65
+
66
+ expect(result).toHaveProperty('jsonSchema');
67
+ expect(result).toHaveProperty('validate');
68
+
69
+ const validData = {
70
+ text: 'Hello, world!',
71
+ count: 10,
72
+ };
73
+
74
+ const validationResult = result.validate!(validData);
75
+ expect(typeof validationResult).toBe('object');
76
+ expect(validationResult).toHaveProperty('success');
77
+ });
78
+ });
79
+
80
+ describe('OpenAISchemaCompatLayer', () => {
81
+ it('should apply for OpenAI models without structured outputs support', () => {
82
+ const compat = new OpenAISchemaCompatLayer(mockModels.openai);
83
+ expect(compat.shouldApply()).toBe(true);
84
+ });
85
+
86
+ it('should return correct schema target', () => {
87
+ const compat = new OpenAISchemaCompatLayer(mockModels.openai);
88
+ expect(compat.getSchemaTarget()).toBe('jsonSchema7');
89
+ });
90
+
91
+ it('should process complex schemas', () => {
92
+ const compat = new OpenAISchemaCompatLayer(mockModels.openai);
93
+ const schema = z.object({
94
+ user: z.object({
95
+ name: z.string().email(),
96
+ preferences: z.array(z.enum(['dark', 'light'])),
97
+ }),
98
+ settings: z.record(z.boolean()),
99
+ });
100
+
101
+ const result = compat.processToAISDKSchema(schema);
102
+
103
+ const validData = {
104
+ user: {
105
+ name: 'John Doe',
106
+ preferences: ['dark'],
107
+ },
108
+ settings: {
109
+ public: true,
110
+ featured: false,
111
+ },
112
+ };
113
+
114
+ expect(result).toHaveProperty('jsonSchema');
115
+ expect(result).toHaveProperty('validate');
116
+
117
+ const validationResult = result.validate!(validData);
118
+ expect(typeof validationResult).toBe('object');
119
+ expect(validationResult).toHaveProperty('success');
120
+ });
121
+ });
122
+
123
+ describe('OpenAIReasoningSchemaCompatLayer', () => {
124
+ it('should have consistent behavior', () => {
125
+ const compat = new OpenAIReasoningSchemaCompatLayer(mockModels.openaiReasoning);
126
+ expect(compat.shouldApply()).toBe(true);
127
+ });
128
+
129
+ it('should return correct schema target', () => {
130
+ const compat = new OpenAIReasoningSchemaCompatLayer(mockModels.openaiReasoning);
131
+ expect(compat.getSchemaTarget()).toBe('openApi3');
132
+ });
133
+ });
134
+
135
+ describe('GoogleSchemaCompatLayer', () => {
136
+ it('should have consistent behavior', () => {
137
+ const compat = new GoogleSchemaCompatLayer(mockModels.google);
138
+ expect(typeof compat.shouldApply()).toBe('boolean');
139
+ });
140
+
141
+ it('should return correct schema target', () => {
142
+ const compat = new GoogleSchemaCompatLayer(mockModels.google);
143
+ expect(compat.getSchemaTarget()).toBe('jsonSchema7');
144
+ });
145
+
146
+ it('should handle date types correctly', () => {
147
+ const compat = new GoogleSchemaCompatLayer(mockModels.google);
148
+ const schema = z.object({
149
+ startDate: z.date(),
150
+ endDate: z.date().optional(),
151
+ title: z.string(),
152
+ });
153
+
154
+ const result = compat.processToAISDKSchema(schema);
155
+
156
+ expect(result).toHaveProperty('jsonSchema');
157
+ expect(result).toHaveProperty('validate');
158
+
159
+ const validData = {
160
+ startDate: new Date(),
161
+ title: 'Hello, world!',
162
+ };
163
+
164
+ const validationResult = result.validate!(validData);
165
+ expect(typeof validationResult).toBe('object');
166
+ expect(validationResult).toHaveProperty('success');
167
+ });
168
+ });
169
+
170
+ describe('DeepSeekSchemaCompatLayer', () => {
171
+ it('should apply for DeepSeek models', () => {
172
+ const compat = new DeepSeekSchemaCompatLayer(mockModels.deepseek);
173
+ expect(compat.shouldApply()).toBe(true);
174
+ });
175
+
176
+ it('should not apply for non-DeepSeek models', () => {
177
+ const compat = new DeepSeekSchemaCompatLayer(mockModels.openai);
178
+ expect(compat.shouldApply()).toBe(false);
179
+ });
180
+
181
+ it('should return correct schema target', () => {
182
+ const compat = new DeepSeekSchemaCompatLayer(mockModels.deepseek);
183
+ expect(compat.getSchemaTarget()).toBe('jsonSchema7');
184
+ });
185
+
186
+ it('should handle string constraints', () => {
187
+ const compat = new DeepSeekSchemaCompatLayer(mockModels.deepseek);
188
+ const schema = z.object({
189
+ email: z.string().email(),
190
+ url: z.string().url(),
191
+ uuid: z.string().uuid(),
192
+ text: z.string().min(10).max(1000),
193
+ });
194
+
195
+ const result = compat.processToAISDKSchema(schema);
196
+
197
+ expect(result).toHaveProperty('jsonSchema');
198
+ expect(result).toHaveProperty('validate');
199
+
200
+ const validData = {
201
+ email: 'john@example.com',
202
+ url: 'https://example.com',
203
+ uuid: '123e4567-e89b-12d3-a456-426614174000',
204
+ text: 'Hello, world!',
205
+ };
206
+
207
+ const validationResult = result.validate!(validData);
208
+ expect(typeof validationResult).toBe('object');
209
+ expect(validationResult).toHaveProperty('success');
210
+ });
211
+ });
212
+
213
+ describe('MetaSchemaCompatLayer', () => {
214
+ it('should have consistent behavior', () => {
215
+ const compat = new MetaSchemaCompatLayer(mockModels.meta);
216
+ expect(typeof compat.shouldApply()).toBe('boolean');
217
+ });
218
+
219
+ it('should return correct schema target', () => {
220
+ const compat = new MetaSchemaCompatLayer(mockModels.meta);
221
+ expect(compat.getSchemaTarget()).toBe('jsonSchema7');
222
+ });
223
+
224
+ it('should handle array and union types', () => {
225
+ const compat = new MetaSchemaCompatLayer(mockModels.meta);
226
+ const schema = z.object({
227
+ tags: z.array(z.string()).min(1).max(10),
228
+ status: z.union([z.literal('active'), z.literal('inactive')]),
229
+ priority: z.enum(['low', 'medium', 'high']),
230
+ });
231
+
232
+ const result = compat.processToAISDKSchema(schema);
233
+
234
+ expect(result).toHaveProperty('jsonSchema');
235
+ expect(result).toHaveProperty('validate');
236
+
237
+ const validData = {
238
+ tags: ['tag1'],
239
+ status: 'active',
240
+ priority: 'high',
241
+ };
242
+
243
+ const validationResult = result.validate!(validData);
244
+ expect(typeof validationResult).toBe('object');
245
+ expect(validationResult).toHaveProperty('success');
246
+ });
247
+ });
248
+
249
+ describe('Integration tests', () => {
250
+ it('should handle schema processing across providers', () => {
251
+ const complexSchema = z.object({
252
+ user: z.object({
253
+ name: z.string().min(1).max(100),
254
+ email: z.string().email(),
255
+ age: z.number().min(0).max(120).optional(),
256
+ }),
257
+ preferences: z.object({
258
+ theme: z.enum(['light', 'dark']),
259
+ notifications: z.boolean(),
260
+ language: z.string().regex(/^[a-z]{2}$/),
261
+ }),
262
+ tags: z.array(z.string()).min(1).max(5),
263
+ metadata: z.record(z.union([z.string(), z.number(), z.boolean()])),
264
+ createdAt: z.date(),
265
+ settings: z
266
+ .object({
267
+ public: z.boolean(),
268
+ featured: z.boolean().optional(),
269
+ })
270
+ .optional(),
271
+ });
272
+
273
+ const providers = [
274
+ new AnthropicSchemaCompatLayer(mockModels.anthropic),
275
+ new OpenAISchemaCompatLayer(mockModels.openai),
276
+ new OpenAIReasoningSchemaCompatLayer(mockModels.openaiReasoning),
277
+ new GoogleSchemaCompatLayer(mockModels.google),
278
+ new DeepSeekSchemaCompatLayer(mockModels.deepseek),
279
+ new MetaSchemaCompatLayer(mockModels.meta),
280
+ ];
281
+
282
+ providers.forEach(provider => {
283
+ const result = provider.processToAISDKSchema(complexSchema);
284
+
285
+ expect(result).toHaveProperty('jsonSchema');
286
+ expect(result).toHaveProperty('validate');
287
+ expect(typeof result.validate).toBe('function');
288
+
289
+ const validData = {
290
+ user: {
291
+ name: 'John Doe',
292
+ email: 'john@example.com',
293
+ },
294
+ preferences: {
295
+ theme: 'dark' as const,
296
+ notifications: true,
297
+ language: 'en',
298
+ },
299
+ tags: ['tag1'],
300
+ metadata: {
301
+ key1: 'value1',
302
+ },
303
+ createdAt: new Date(),
304
+ };
305
+
306
+ const validationResult = result.validate!(validData);
307
+ expect(typeof validationResult).toBe('object');
308
+ expect(validationResult).toHaveProperty('success');
309
+ });
310
+ });
311
+ });
312
+ });
@@ -0,0 +1,350 @@
1
+ import type { LanguageModelV1 } from 'ai';
2
+ import { MockLanguageModelV1 } from 'ai/test';
3
+ import { describe, it, expect, beforeEach } from 'vitest';
4
+ import { z } from 'zod';
5
+ import { SchemaCompatLayer } from './schema-compatibility';
6
+
7
+ class MockSchemaCompatibility extends SchemaCompatLayer {
8
+ constructor(model: LanguageModelV1) {
9
+ super(model);
10
+ }
11
+
12
+ shouldApply(): boolean {
13
+ return true;
14
+ }
15
+
16
+ getSchemaTarget() {
17
+ return 'jsonSchema7' as const;
18
+ }
19
+
20
+ processZodType(value: z.ZodTypeAny): any {
21
+ return value;
22
+ }
23
+ }
24
+
25
+ const mockModel = new MockLanguageModelV1({
26
+ modelId: 'test-model',
27
+ defaultObjectGenerationMode: 'json',
28
+ });
29
+
30
+ describe('SchemaCompatLayer', () => {
31
+ let compatibility: MockSchemaCompatibility;
32
+
33
+ beforeEach(() => {
34
+ compatibility = new MockSchemaCompatibility(mockModel);
35
+ });
36
+
37
+ describe('constructor and getModel', () => {
38
+ it('should store and return the model', () => {
39
+ expect(compatibility.getModel()).toBe(mockModel);
40
+ });
41
+ });
42
+
43
+ describe('mergeParameterDescription', () => {
44
+ it('should return original description when no constraints', () => {
45
+ const description = 'Original description';
46
+ const constraints = {};
47
+
48
+ const result = compatibility.mergeParameterDescription(description, constraints);
49
+
50
+ expect(result).toBe(description);
51
+ });
52
+
53
+ it('should append constraints to description', () => {
54
+ const description = 'Original description';
55
+ const constraints = { minLength: 5, maxLength: 10 };
56
+
57
+ const result = compatibility.mergeParameterDescription(description, constraints);
58
+
59
+ expect(result).toBe('Original description\n{"minLength":5,"maxLength":10}');
60
+ });
61
+
62
+ it('should handle undefined description with constraints', () => {
63
+ const constraints = { email: true };
64
+
65
+ const result = compatibility.mergeParameterDescription(undefined, constraints);
66
+
67
+ expect(result).toBe('{"email":true}');
68
+ });
69
+
70
+ it('should handle empty constraints', () => {
71
+ const description = 'Test description';
72
+ const constraints = {};
73
+
74
+ const result = compatibility.mergeParameterDescription(description, constraints);
75
+
76
+ expect(result).toBe(description);
77
+ });
78
+ });
79
+
80
+ describe('defaultZodObjectHandler', () => {
81
+ it('should process object shape correctly', () => {
82
+ const testSchema = z.object({
83
+ name: z.string(),
84
+ age: z.number(),
85
+ });
86
+
87
+ const result = compatibility.defaultZodObjectHandler(testSchema);
88
+
89
+ expect(result).toBeInstanceOf(z.ZodObject);
90
+ expect(result._def.typeName).toBe('ZodObject');
91
+ });
92
+
93
+ it('should preserve description', () => {
94
+ const testSchema = z
95
+ .object({
96
+ name: z.string(),
97
+ })
98
+ .describe('Test object');
99
+
100
+ const result = compatibility.defaultZodObjectHandler(testSchema);
101
+
102
+ expect(result.description).toBe('Test object');
103
+ });
104
+ });
105
+
106
+ describe('defaultUnsupportedZodTypeHandler', () => {
107
+ it('should throw error for unsupported types', () => {
108
+ const unsupportedSchema = z.never();
109
+
110
+ expect(() => {
111
+ compatibility.defaultUnsupportedZodTypeHandler(unsupportedSchema);
112
+ }).toThrow('test-model does not support zod type: ZodNever');
113
+ });
114
+
115
+ it('should return value for supported types', () => {
116
+ const supportedSchema = z.string();
117
+
118
+ const result = compatibility.defaultUnsupportedZodTypeHandler(supportedSchema);
119
+
120
+ expect(result).toBe(supportedSchema);
121
+ });
122
+
123
+ it('should respect custom throwOnTypes parameter', () => {
124
+ const neverSchema = z.never();
125
+
126
+ const result = compatibility.defaultUnsupportedZodTypeHandler(neverSchema, []);
127
+
128
+ expect(result).toBe(neverSchema);
129
+ });
130
+ });
131
+
132
+ describe('defaultZodArrayHandler', () => {
133
+ it('should handle array with constraints', () => {
134
+ const arraySchema = z.array(z.string()).min(2).max(10);
135
+
136
+ const result = compatibility.defaultZodArrayHandler(arraySchema);
137
+
138
+ expect(result).toBeInstanceOf(z.ZodArray);
139
+ expect(result.description).toContain('minLength');
140
+ expect(result.description).toContain('maxLength');
141
+ });
142
+
143
+ it('should handle array without constraints', () => {
144
+ const arraySchema = z.array(z.string());
145
+
146
+ const result = compatibility.defaultZodArrayHandler(arraySchema);
147
+
148
+ expect(result).toBeInstanceOf(z.ZodArray);
149
+ });
150
+
151
+ it('should handle exact length constraint', () => {
152
+ const arraySchema = z.array(z.string()).length(5);
153
+
154
+ const result = compatibility.defaultZodArrayHandler(arraySchema);
155
+
156
+ expect(result).toBeInstanceOf(z.ZodArray);
157
+ expect(result.description).toContain('exactLength');
158
+ });
159
+
160
+ it('should preserve original description', () => {
161
+ const arraySchema = z.array(z.string()).describe('String array');
162
+
163
+ const result = compatibility.defaultZodArrayHandler(arraySchema);
164
+
165
+ expect(result.description).toContain('String array');
166
+ });
167
+ });
168
+
169
+ describe('defaultZodUnionHandler', () => {
170
+ it('should handle union types', () => {
171
+ const unionSchema = z.union([z.string(), z.number()]);
172
+
173
+ const result = compatibility.defaultZodUnionHandler(unionSchema);
174
+
175
+ expect(result).toBeInstanceOf(z.ZodUnion);
176
+ });
177
+
178
+ it('should preserve description', () => {
179
+ const unionSchema = z.union([z.string(), z.number()]).describe('String or number');
180
+
181
+ const result = compatibility.defaultZodUnionHandler(unionSchema);
182
+
183
+ expect(result.description).toBe('String or number');
184
+ });
185
+
186
+ it('should throw error for union with less than 2 options', () => {
187
+ const mockUnion = {
188
+ _def: {
189
+ typeName: 'ZodUnion' as const,
190
+ options: [z.string()],
191
+ },
192
+ } as z.ZodUnion<[z.ZodString]>;
193
+
194
+ expect(() => {
195
+ compatibility.defaultZodUnionHandler(mockUnion);
196
+ }).toThrow('Union must have at least 2 options');
197
+ });
198
+ });
199
+
200
+ describe('defaultZodStringHandler', () => {
201
+ it('should handle string with length constraints', () => {
202
+ const stringSchema = z.string().min(5).max(10);
203
+
204
+ const result = compatibility.defaultZodStringHandler(stringSchema);
205
+
206
+ expect(result).toBeInstanceOf(z.ZodString);
207
+ expect(result.description).toContain('minLength');
208
+ expect(result.description).toContain('maxLength');
209
+ });
210
+
211
+ it('should handle email constraint', () => {
212
+ const stringSchema = z.string().email();
213
+
214
+ const result = compatibility.defaultZodStringHandler(stringSchema);
215
+
216
+ expect(result).toBeInstanceOf(z.ZodString);
217
+ expect(result.description).toContain('email');
218
+ });
219
+
220
+ it('should handle url constraint', () => {
221
+ const stringSchema = z.string().url();
222
+
223
+ const result = compatibility.defaultZodStringHandler(stringSchema);
224
+
225
+ expect(result).toBeInstanceOf(z.ZodString);
226
+ expect(result.description).toContain('url');
227
+ });
228
+
229
+ it('should handle uuid constraint', () => {
230
+ const stringSchema = z.string().uuid();
231
+
232
+ const result = compatibility.defaultZodStringHandler(stringSchema);
233
+
234
+ expect(result).toBeInstanceOf(z.ZodString);
235
+ expect(result.description).toContain('uuid');
236
+ });
237
+
238
+ it('should handle regex constraint', () => {
239
+ const stringSchema = z.string().regex(/^[A-Z]+$/);
240
+
241
+ const result = compatibility.defaultZodStringHandler(stringSchema);
242
+
243
+ expect(result).toBeInstanceOf(z.ZodString);
244
+ expect(result.description).toContain('regex');
245
+ });
246
+
247
+ it('should preserve checks not in handleChecks', () => {
248
+ const stringSchema = z.string().min(5).max(10);
249
+
250
+ const result = compatibility.defaultZodStringHandler(stringSchema, ['min']);
251
+
252
+ expect(result).toBeInstanceOf(z.ZodString);
253
+ expect(result.description).toContain('minLength');
254
+ });
255
+ });
256
+
257
+ describe('defaultZodNumberHandler', () => {
258
+ it('should handle number with min/max constraints', () => {
259
+ const numberSchema = z.number().min(0).max(100);
260
+
261
+ const result = compatibility.defaultZodNumberHandler(numberSchema);
262
+
263
+ expect(result).toBeInstanceOf(z.ZodNumber);
264
+ expect(result.description).toContain('gte');
265
+ expect(result.description).toContain('lte');
266
+ });
267
+
268
+ it('should handle exclusive min/max', () => {
269
+ const numberSchema = z.number().gt(0).lt(100);
270
+
271
+ const result = compatibility.defaultZodNumberHandler(numberSchema);
272
+
273
+ expect(result).toBeInstanceOf(z.ZodNumber);
274
+ expect(result.description).toContain('gt');
275
+ expect(result.description).toContain('lt');
276
+ });
277
+
278
+ it('should handle multipleOf constraint', () => {
279
+ const numberSchema = z.number().multipleOf(5);
280
+
281
+ const result = compatibility.defaultZodNumberHandler(numberSchema);
282
+
283
+ expect(result).toBeInstanceOf(z.ZodNumber);
284
+ expect(result.description).toContain('multipleOf');
285
+ });
286
+
287
+ it('should preserve int and finite checks', () => {
288
+ const numberSchema = z.number().int().finite();
289
+ const result = compatibility.defaultZodNumberHandler(numberSchema);
290
+ expect(result).toBeInstanceOf(z.ZodNumber);
291
+ expect(result._def.checks).toEqual(
292
+ expect.arrayContaining([expect.objectContaining({ kind: 'int' }), expect.objectContaining({ kind: 'finite' })]),
293
+ );
294
+ });
295
+ });
296
+
297
+ describe('defaultZodDateHandler', () => {
298
+ it('should convert date to string with date-time format', () => {
299
+ const dateSchema = z.date();
300
+
301
+ const result = compatibility.defaultZodDateHandler(dateSchema);
302
+
303
+ expect(result).toBeInstanceOf(z.ZodString);
304
+ expect(result.description).toContain('date-time');
305
+ expect(result.description).toContain('dateFormat');
306
+ });
307
+
308
+ it('should handle date with min/max constraints', () => {
309
+ const minDate = new Date('2023-01-01');
310
+ const maxDate = new Date('2023-12-31');
311
+ const dateSchema = z.date().min(minDate).max(maxDate);
312
+
313
+ const result = compatibility.defaultZodDateHandler(dateSchema);
314
+
315
+ expect(result).toBeInstanceOf(z.ZodString);
316
+ expect(result.description).toContain('minDate');
317
+ expect(result.description).toContain('maxDate');
318
+ expect(result.description).toContain('2023-01-01');
319
+ expect(result.description).toContain('2023-12-31');
320
+ });
321
+ });
322
+
323
+ describe('defaultZodOptionalHandler', () => {
324
+ it('should handle optional string', () => {
325
+ const optionalSchema = z.string().optional();
326
+
327
+ class TestCompatibility extends MockSchemaCompatibility {
328
+ processZodType(value: z.ZodTypeAny): any {
329
+ if (value._def.typeName === 'ZodString') {
330
+ return z.string().describe('processed');
331
+ }
332
+ return value;
333
+ }
334
+ }
335
+
336
+ const testCompat = new TestCompatibility(mockModel);
337
+ const result = testCompat.defaultZodOptionalHandler(optionalSchema);
338
+
339
+ expect(result._def.typeName).toBe('ZodOptional');
340
+ });
341
+
342
+ it('should return original value for unsupported types', () => {
343
+ const optionalNever = z.never().optional();
344
+
345
+ const result = compatibility.defaultZodOptionalHandler(optionalNever, ['ZodString']);
346
+
347
+ expect(result).toBe(optionalNever);
348
+ });
349
+ });
350
+ });