@mastra/schema-compat 0.0.0-1.x-tester-20251106055847

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.
Files changed (50) hide show
  1. package/CHANGELOG.md +213 -0
  2. package/LICENSE.md +15 -0
  3. package/README.md +144 -0
  4. package/dist/chunk-5WM4A32G.cjs +83 -0
  5. package/dist/chunk-5WM4A32G.cjs.map +1 -0
  6. package/dist/chunk-U2HXWNAF.js +77 -0
  7. package/dist/chunk-U2HXWNAF.js.map +1 -0
  8. package/dist/index.cjs +4954 -0
  9. package/dist/index.cjs.map +1 -0
  10. package/dist/index.d.ts +13 -0
  11. package/dist/index.d.ts.map +1 -0
  12. package/dist/index.js +4928 -0
  13. package/dist/index.js.map +1 -0
  14. package/dist/json-schema.d.ts +4 -0
  15. package/dist/json-schema.d.ts.map +1 -0
  16. package/dist/provider-compats/anthropic.d.ts +13 -0
  17. package/dist/provider-compats/anthropic.d.ts.map +1 -0
  18. package/dist/provider-compats/deepseek.d.ts +13 -0
  19. package/dist/provider-compats/deepseek.d.ts.map +1 -0
  20. package/dist/provider-compats/google.d.ts +13 -0
  21. package/dist/provider-compats/google.d.ts.map +1 -0
  22. package/dist/provider-compats/meta.d.ts +13 -0
  23. package/dist/provider-compats/meta.d.ts.map +1 -0
  24. package/dist/provider-compats/openai-reasoning.d.ts +14 -0
  25. package/dist/provider-compats/openai-reasoning.d.ts.map +1 -0
  26. package/dist/provider-compats/openai.d.ts +13 -0
  27. package/dist/provider-compats/openai.d.ts.map +1 -0
  28. package/dist/schema-compatibility-v3.d.ts +287 -0
  29. package/dist/schema-compatibility-v3.d.ts.map +1 -0
  30. package/dist/schema-compatibility-v4.d.ts +278 -0
  31. package/dist/schema-compatibility-v4.d.ts.map +1 -0
  32. package/dist/schema-compatibility.d.ts +196 -0
  33. package/dist/schema-compatibility.d.ts.map +1 -0
  34. package/dist/types.d.ts +7 -0
  35. package/dist/types.d.ts.map +1 -0
  36. package/dist/utils-test-suite.d.ts +2 -0
  37. package/dist/utils-test-suite.d.ts.map +1 -0
  38. package/dist/utils.d.ts +96 -0
  39. package/dist/utils.d.ts.map +1 -0
  40. package/dist/zod-to-json-test-suite.d.ts +6 -0
  41. package/dist/zod-to-json-test-suite.d.ts.map +1 -0
  42. package/dist/zod-to-json.cjs +12 -0
  43. package/dist/zod-to-json.cjs.map +1 -0
  44. package/dist/zod-to-json.d.ts +6 -0
  45. package/dist/zod-to-json.d.ts.map +1 -0
  46. package/dist/zod-to-json.js +3 -0
  47. package/dist/zod-to-json.js.map +1 -0
  48. package/dist/zodTypes.d.ts +21 -0
  49. package/dist/zodTypes.d.ts.map +1 -0
  50. package/package.json +83 -0
@@ -0,0 +1,278 @@
1
+ import { z, ZodOptional, ZodObject, ZodArray, ZodUnion, ZodString, ZodNumber, ZodDate, ZodDefault, ZodNull } from 'zod/v4';
2
+ import type { ZodAny, ZodType } from 'zod/v4';
3
+ import type { Targets } from 'zod-to-json-schema';
4
+ import type { JSONSchema7 } from './json-schema.js';
5
+ import type { SchemaCompatLayer as ParentSchemaCompatLayer } from './schema-compatibility.js';
6
+ import type { Schema, ModelInformation } from './types.js';
7
+ /**
8
+ * All supported string validation check types that can be processed or converted to descriptions.
9
+ * @constant
10
+ */
11
+ export declare const ALL_STRING_CHECKS: readonly ["regex", "emoji", "email", "url", "uuid", "cuid", "min_length", "max_length", "string_format"];
12
+ /**
13
+ * All supported number validation check types that can be processed or converted to descriptions.
14
+ * @constant
15
+ */
16
+ export declare const ALL_NUMBER_CHECKS: readonly ["greater_than", "less_than", "multiple_of"];
17
+ /**
18
+ * All supported array validation check types that can be processed or converted to descriptions.
19
+ * @constant
20
+ */
21
+ export declare const ALL_ARRAY_CHECKS: readonly ["min", "max", "length"];
22
+ /**
23
+ * Zod types that are not supported by most AI model providers and should be avoided.
24
+ * @constant
25
+ */
26
+ export declare const UNSUPPORTED_ZOD_TYPES: readonly ["ZodIntersection", "ZodNever", "ZodNull", "ZodTuple", "ZodUndefined"];
27
+ /**
28
+ * Zod types that are generally supported by AI model providers.
29
+ * @constant
30
+ */
31
+ export declare const SUPPORTED_ZOD_TYPES: readonly ["ZodObject", "ZodArray", "ZodUnion", "ZodString", "ZodNumber", "ZodDate", "ZodAny", "ZodDefault"];
32
+ /**
33
+ * All Zod types (both supported and unsupported).
34
+ * @constant
35
+ */
36
+ export declare const ALL_ZOD_TYPES: readonly ["ZodObject", "ZodArray", "ZodUnion", "ZodString", "ZodNumber", "ZodDate", "ZodAny", "ZodDefault", "ZodIntersection", "ZodNever", "ZodNull", "ZodTuple", "ZodUndefined"];
37
+ /**
38
+ * Type representing string validation checks.
39
+ */
40
+ export type StringCheckType = (typeof ALL_STRING_CHECKS)[number];
41
+ /**
42
+ * Type representing number validation checks.
43
+ */
44
+ export type NumberCheckType = (typeof ALL_NUMBER_CHECKS)[number];
45
+ /**
46
+ * Type representing array validation checks.
47
+ */
48
+ export type ArrayCheckType = (typeof ALL_ARRAY_CHECKS)[number];
49
+ /**
50
+ * Type representing unsupported Zod schema types.
51
+ */
52
+ export type UnsupportedZodType = (typeof UNSUPPORTED_ZOD_TYPES)[number];
53
+ /**
54
+ * Type representing supported Zod schema types.
55
+ */
56
+ export type SupportedZodType = (typeof SUPPORTED_ZOD_TYPES)[number];
57
+ /**
58
+ * Type representing all Zod schema types (supported and unsupported).
59
+ */
60
+ export type AllZodType = (typeof ALL_ZOD_TYPES)[number];
61
+ /**
62
+ * Utility type to extract the shape of a Zod object schema.
63
+ */
64
+ export type ZodShape<T extends z.ZodObject<any, any>> = T['shape'];
65
+ /**
66
+ * Utility type to extract the keys from a Zod object shape.
67
+ */
68
+ export type ShapeKey<T extends z.ZodObject<any, any>> = keyof ZodShape<T>;
69
+ /**
70
+ * Utility type to extract the value types from a Zod object shape.
71
+ */
72
+ export type ShapeValue<T extends z.ZodObject<any, any>> = ZodShape<T>[ShapeKey<T>];
73
+ type ConstraintHelperText = string[];
74
+ /**
75
+ * Abstract base class for creating schema compatibility layers for different AI model providers.
76
+ *
77
+ * This class provides a framework for transforming Zod schemas to work with specific AI model
78
+ * provider requirements and limitations. Each provider may have different support levels for
79
+ * JSON Schema features, validation constraints, and data types.
80
+ *
81
+ *
82
+ * @example
83
+ * ```typescript
84
+ * import { SchemaCompatLayer } from '@mastra/schema-compat';
85
+ * import type { LanguageModelV1 } from 'ai';
86
+ *
87
+ * class CustomProviderCompat extends SchemaCompatLayer {
88
+ * constructor(model: LanguageModelV1) {
89
+ * super(model);
90
+ * }
91
+ *
92
+ * shouldApply(): boolean {
93
+ * return this.getModel().provider === 'custom-provider';
94
+ * }
95
+ *
96
+ * getSchemaTarget() {
97
+ * return 'jsonSchema7';
98
+ * }
99
+ *
100
+ * processZodType<T extends z.AnyZodObject>(value: z.ZodAny): ShapeValue<T> {
101
+ * // Custom processing logic for this provider
102
+ * switch (value._def.typeName) {
103
+ * case 'ZodString':
104
+ * return this.defaultZodStringHandler(value, ['email', 'url']);
105
+ * default:
106
+ * return this.defaultUnsupportedZodTypeHandler(value);
107
+ * }
108
+ * }
109
+ * }
110
+ * ```
111
+ */
112
+ export declare class SchemaCompatLayer {
113
+ private model;
114
+ private parent;
115
+ /**
116
+ * Creates a new schema compatibility instance.
117
+ *
118
+ * @param model - The language model this compatibility layer applies to
119
+ */
120
+ constructor(model: ModelInformation, parent: ParentSchemaCompatLayer);
121
+ /**
122
+ * Gets the language model associated with this compatibility layer.
123
+ *
124
+ * @returns The language model instance
125
+ */
126
+ getModel(): ModelInformation;
127
+ getUnsupportedZodTypes(): readonly string[];
128
+ /**
129
+ * Type guard for optional Zod types
130
+ */
131
+ isOptional(v: ZodAny | ZodOptional<any>): v is ZodOptional<any>;
132
+ /**
133
+ * Type guard for object Zod types
134
+ */
135
+ isObj(v: ZodAny | ZodObject<any, any>): v is ZodObject<any, any>;
136
+ /**
137
+ * Type guard for null Zod types
138
+ */
139
+ isNull(v: ZodAny | ZodNull): v is ZodNull;
140
+ /**
141
+ * Type guard for array Zod types
142
+ */
143
+ isArr(v: ZodAny | ZodArray<any>): v is ZodArray<any>;
144
+ /**
145
+ * Type guard for union Zod types
146
+ */
147
+ isUnion(v: ZodAny | ZodUnion<[ZodAny, ...ZodAny[]]>): v is ZodUnion<[ZodAny, ...ZodAny[]]>;
148
+ /**
149
+ * Type guard for string Zod types
150
+ */
151
+ isString(v: ZodAny | ZodString): v is ZodString;
152
+ /**
153
+ * Type guard for number Zod types
154
+ */
155
+ isNumber(v: ZodAny | ZodNumber): v is ZodNumber;
156
+ /**
157
+ * Type guard for date Zod types
158
+ */
159
+ isDate(v: ZodAny | ZodDate): v is ZodDate;
160
+ /**
161
+ * Type guard for default Zod types
162
+ */
163
+ isDefault(v: ZodAny | ZodDefault<any>): v is ZodDefault<any>;
164
+ /**
165
+ * Determines whether this compatibility layer should be applied for the current model.
166
+ *
167
+ * @returns True if this compatibility layer should be used, false otherwise
168
+ * @abstract
169
+ */
170
+ shouldApply(): boolean;
171
+ /**
172
+ * Returns the JSON Schema target format for this provider.
173
+ *
174
+ * @returns The schema target format, or undefined to use the default 'jsonSchema7'
175
+ * @abstract
176
+ */
177
+ getSchemaTarget(): Targets | undefined;
178
+ /**
179
+ * Processes a specific Zod type according to the provider's requirements.
180
+ *
181
+ * @param value - The Zod type to process
182
+ * @returns The processed Zod type
183
+ * @abstract
184
+ */
185
+ processZodType(value: ZodType): ZodType;
186
+ /**
187
+ * Default handler for Zod object types. Recursively processes all properties in the object.
188
+ *
189
+ * @param value - The Zod object to process
190
+ * @returns The processed Zod object
191
+ */
192
+ defaultZodObjectHandler(value: ZodObject<any, any>, options?: {
193
+ passthrough?: boolean;
194
+ }): ZodObject<any, any>;
195
+ /**
196
+ * Merges validation constraints into a parameter description.
197
+ *
198
+ * This helper method converts validation constraints that may not be supported
199
+ * by a provider into human-readable descriptions.
200
+ *
201
+ * @param description - The existing parameter description
202
+ * @param constraints - The validation constraints to merge
203
+ * @returns The updated description with constraints, or undefined if no constraints
204
+ */
205
+ mergeParameterDescription(description: string | undefined, constraints: ConstraintHelperText): string | undefined;
206
+ /**
207
+ * Default handler for unsupported Zod types. Throws an error for specified unsupported types.
208
+ *
209
+ * @param value - The Zod type to check
210
+ * @param throwOnTypes - Array of type names to throw errors for
211
+ * @returns The original value if not in the throw list
212
+ * @throws Error if the type is in the unsupported list
213
+ */
214
+ defaultUnsupportedZodTypeHandler<T extends z.ZodObject<any, any>>(value: z.ZodAny, throwOnTypes?: readonly UnsupportedZodType[]): ShapeValue<T>;
215
+ /**
216
+ * Default handler for Zod array types. Processes array constraints according to provider support.
217
+ *
218
+ * @param value - The Zod array to process
219
+ * @param handleChecks - Array constraints to convert to descriptions vs keep as validation
220
+ * @returns The processed Zod array
221
+ */
222
+ defaultZodArrayHandler(value: ZodArray<any>, handleChecks?: readonly ArrayCheckType[]): ZodArray<any>;
223
+ /**
224
+ * Default handler for Zod union types. Processes all union options.
225
+ *
226
+ * @param value - The Zod union to process
227
+ * @returns The processed Zod union
228
+ * @throws Error if union has fewer than 2 options
229
+ */
230
+ defaultZodUnionHandler(value: ZodUnion<[ZodAny, ...ZodAny[]]>): ZodAny;
231
+ /**
232
+ * Default handler for Zod string types. Processes string validation constraints.
233
+ *
234
+ * @param value - The Zod string to process
235
+ * @param handleChecks - String constraints to convert to descriptions vs keep as validation
236
+ * @returns The processed Zod string
237
+ */
238
+ defaultZodStringHandler(value: ZodString, handleChecks?: readonly StringCheckType[]): ZodString;
239
+ /**
240
+ * Default handler for Zod number types. Processes number validation constraints.
241
+ *
242
+ * @param value - The Zod number to process
243
+ * @param handleChecks - Number constraints to convert to descriptions vs keep as validation
244
+ * @returns The processed Zod number
245
+ */
246
+ defaultZodNumberHandler(value: ZodNumber, handleChecks?: readonly NumberCheckType[]): ZodNumber;
247
+ /**
248
+ * Default handler for Zod date types. Converts dates to ISO strings with constraint descriptions.
249
+ *
250
+ * @param value - The Zod date to process
251
+ * @returns A Zod string schema representing the date in ISO format
252
+ */
253
+ defaultZodDateHandler(value: ZodDate): ZodString;
254
+ /**
255
+ * Default handler for Zod optional types. Processes the inner type and maintains optionality.
256
+ *
257
+ * @param value - The Zod optional to process
258
+ * @param handleTypes - Types that should be processed vs passed through
259
+ * @returns The processed Zod optional
260
+ */
261
+ defaultZodOptionalHandler(value: ZodOptional<any>, handleTypes?: readonly AllZodType[]): ZodType;
262
+ /**
263
+ * Processes a Zod object schema and converts it to an AI SDK Schema.
264
+ *
265
+ * @param zodSchema - The Zod object schema to process
266
+ * @returns An AI SDK Schema with provider-specific compatibility applied
267
+ */
268
+ processToAISDKSchema(zodSchema: ZodType): Schema;
269
+ /**
270
+ * Processes a Zod object schema and converts it to a JSON Schema.
271
+ *
272
+ * @param zodSchema - The Zod object schema to process
273
+ * @returns A JSONSchema7 object with provider-specific compatibility applied
274
+ */
275
+ processToJSONSchema(zodSchema: ZodType): JSONSchema7;
276
+ }
277
+ export {};
278
+ //# sourceMappingURL=schema-compatibility-v4.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"schema-compatibility-v4.d.ts","sourceRoot":"","sources":["../src/schema-compatibility-v4.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,CAAC,EACD,WAAW,EACX,SAAS,EACT,QAAQ,EACR,QAAQ,EACR,SAAS,EACT,SAAS,EACT,OAAO,EACP,UAAU,EACV,OAAO,EACR,MAAM,QAAQ,CAAC;AAChB,OAAO,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,QAAQ,CAAC;AAC9C,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AACjD,OAAO,KAAK,EAAE,iBAAiB,IAAI,uBAAuB,EAAE,MAAM,wBAAwB,CAAC;AAC3F,OAAO,KAAK,EAAE,MAAM,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAGxD;;;GAGG;AACH,eAAO,MAAM,iBAAiB,0GAUpB,CAAC;AAEX;;;GAGG;AACH,eAA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,eAAe,EAAsB,GAC3D,SAAS;IA2DZ;;;;;;OAMG;IACI,uBAAuB,CAC5B,KAAK,EAAE,SAAS,EAChB,YAAY,GAAE,SAAS,eAAe,EAAsB,GAC3D,SAAS;IAkEZ;;;;;OAKG;IACI,qBAAqB,CAAC,KAAK,EAAE,OAAO,GAAG,SAAS;IAoCvD;;;;;;OAMG;IACI,yBAAyB,CAC9B,KAAK,EAAE,WAAW,CAAC,GAAG,CAAC,EACvB,WAAW,GAAE,SAAS,UAAU,EAAwB,GACvD,OAAO;IAQV;;;;;OAKG;IACI,oBAAoB,CAAC,SAAS,EAAE,OAAO,GAAG,MAAM;IAMvD;;;;;OAKG;IACI,mBAAmB,CAAC,SAAS,EAAE,OAAO,GAAG,WAAW;CAG5D"}
@@ -0,0 +1,196 @@
1
+ import type { z as zV3 } from 'zod/v3';
2
+ import type { z as zV4, ZodType } from 'zod/v4';
3
+ import type { Targets } from 'zod-to-json-schema';
4
+ import type { JSONSchema7 } from './json-schema.js';
5
+ import type { UnsupportedZodType as UnsupportedZodTypeV3, ShapeValue as ShapeValueV3, StringCheckType, NumberCheckType, ArrayCheckType, AllZodType as AllZodTypeV3 } from './schema-compatibility-v3.js';
6
+ import type { UnsupportedZodType as UnsupportedZodTypeV4, ShapeValue as ShapeValueV4, AllZodType as AllZodTypeV4 } from './schema-compatibility-v4.js';
7
+ import type { Schema, ModelInformation } from './types.js';
8
+ type ConstraintHelperText = string[];
9
+ export declare abstract class SchemaCompatLayer {
10
+ private model;
11
+ private v3Layer;
12
+ private v4Layer;
13
+ /**
14
+ * Creates a new schema compatibility instance.
15
+ *
16
+ * @param model - The language model this compatibility layer applies to
17
+ */
18
+ constructor(model: ModelInformation);
19
+ /**
20
+ * Gets the language model associated with this compatibility layer.
21
+ *
22
+ * @returns The language model instance
23
+ */
24
+ getModel(): ModelInformation;
25
+ getUnsupportedZodTypes(v: ZodType): readonly string[];
26
+ /**
27
+ * Type guard for optional Zod types
28
+ */
29
+ isOptional(v: zV4.ZodType): v is zV4.ZodOptional<any>;
30
+ isOptional(v: zV3.ZodType): v is zV3.ZodOptional<any>;
31
+ /**
32
+ * Type guard for object Zod types
33
+ */
34
+ isObj(v: zV4.ZodType): v is zV4.ZodObject<any, any>;
35
+ isObj(v: zV3.ZodType): v is zV3.ZodObject<any, any, any, any, any>;
36
+ /**
37
+ * Type guard for null Zod types
38
+ */
39
+ isNull(v: zV4.ZodType): v is zV4.ZodNull;
40
+ isNull(v: zV3.ZodType): v is zV3.ZodNull;
41
+ /**
42
+ * Type guard for array Zod types
43
+ */
44
+ isArr(v: zV4.ZodType): v is zV4.ZodArray<any>;
45
+ isArr(v: zV3.ZodType): v is zV3.ZodArray<any, any>;
46
+ /**
47
+ * Type guard for union Zod types
48
+ */
49
+ isUnion(v: zV4.ZodType): v is zV4.ZodUnion<[zV4.ZodType, ...zV4.ZodType[]]>;
50
+ isUnion(v: zV3.ZodType): v is zV3.ZodUnion<[zV3.ZodType, ...zV3.ZodType[]]>;
51
+ /**
52
+ * Type guard for string Zod types
53
+ */
54
+ isString(v: zV4.ZodType): v is zV4.ZodString;
55
+ isString(v: zV3.ZodType): v is zV3.ZodString;
56
+ /**
57
+ * Type guard for number Zod types
58
+ */
59
+ isNumber(v: zV4.ZodType): v is zV4.ZodNumber;
60
+ isNumber(v: zV3.ZodType): v is zV3.ZodNumber;
61
+ /**
62
+ * Type guard for date Zod types
63
+ */
64
+ isDate(v: zV4.ZodType): v is zV4.ZodDate;
65
+ isDate(v: zV3.ZodType): v is zV3.ZodDate;
66
+ /**
67
+ * Type guard for default Zod types
68
+ */
69
+ isDefault(v: zV4.ZodType): v is zV4.ZodDefault<any>;
70
+ isDefault(v: zV3.ZodType): v is zV3.ZodDefault<any>;
71
+ /**
72
+ * Determines whether this compatibility layer should be applied for the current model.
73
+ *
74
+ * @returns True if this compatibility layer should be used, false otherwise
75
+ * @abstract
76
+ */
77
+ abstract shouldApply(): boolean;
78
+ /**
79
+ * Returns the JSON Schema target format for this provider.
80
+ *
81
+ * @returns The schema target format, or undefined to use the default 'jsonSchema7'
82
+ * @abstract
83
+ */
84
+ abstract getSchemaTarget(): Targets | undefined;
85
+ /**
86
+ * Processes a specific Zod type according to the provider's requirements.
87
+ *
88
+ * @param value - The Zod type to process
89
+ * @returns The processed Zod type
90
+ * @abstract
91
+ */
92
+ abstract processZodType(value: zV4.ZodType): zV4.ZodType;
93
+ abstract processZodType(value: zV3.ZodType): zV3.ZodType;
94
+ abstract processZodType(value: zV4.ZodType | zV3.ZodType): zV4.ZodType | zV3.ZodType;
95
+ /**
96
+ * Default handler for Zod object types. Recursively processes all properties in the object.
97
+ *
98
+ * @param value - The Zod object to process
99
+ * @returns The processed Zod object
100
+ */
101
+ defaultZodObjectHandler(value: zV4.ZodObject<any, any>, options?: {
102
+ passthrough?: boolean;
103
+ }): zV4.ZodObject<any, any>;
104
+ defaultZodObjectHandler(value: zV3.ZodObject<any, any>, options?: {
105
+ passthrough?: boolean;
106
+ }): zV3.ZodObject<any, any>;
107
+ /**
108
+ * Merges validation constraints into a parameter description.
109
+ *
110
+ * This helper method converts validation constraints that may not be supported
111
+ * by a provider into human-readable descriptions.
112
+ *
113
+ * @param description - The existing parameter description
114
+ * @param constraints - The validation constraints to merge
115
+ * @returns The updated description with constraints, or undefined if no constraints
116
+ */
117
+ mergeParameterDescription(description: string | undefined, constraints: ConstraintHelperText): string | undefined;
118
+ /**
119
+ * Default handler for unsupported Zod types. Throws an error for specified unsupported types.
120
+ *
121
+ * @param value - The Zod type to check
122
+ * @param throwOnTypes - Array of type names to throw errors for
123
+ * @returns The original value if not in the throw list
124
+ * @throws Error if the type is in the unsupported list
125
+ */
126
+ defaultUnsupportedZodTypeHandler<T extends zV4.ZodObject | zV3.AnyZodObject>(value: T, throwOnTypes?: T extends zV4.ZodObject ? UnsupportedZodTypeV4[] : T extends zV3.AnyZodObject ? UnsupportedZodTypeV3[] : never): T extends zV4.ZodObject ? ShapeValueV4<T> : T extends zV3.AnyZodObject ? ShapeValueV3<T> : never;
127
+ /**
128
+ * Default handler for Zod array types. Processes array constraints according to provider support.
129
+ *
130
+ * @param value - The Zod array to process
131
+ * @param handleChecks - Array constraints to convert to descriptions vs keep as validation
132
+ * @returns The processed Zod array
133
+ */
134
+ defaultZodArrayHandler(value: zV4.ZodArray<any>, handleChecks?: readonly ArrayCheckType[]): zV4.ZodArray<any>;
135
+ defaultZodArrayHandler(value: zV3.ZodArray<any, any>, handleChecks?: readonly ArrayCheckType[]): zV3.ZodArray<any, any>;
136
+ /**
137
+ * Default handler for Zod union types. Processes all union options.
138
+ *
139
+ * @param value - The Zod union to process
140
+ * @returns The processed Zod union
141
+ * @throws Error if union has fewer than 2 options
142
+ */
143
+ defaultZodUnionHandler(value: zV4.ZodUnion<[zV4.ZodType, ...zV4.ZodType[]]>): zV4.ZodType;
144
+ defaultZodUnionHandler(value: zV3.ZodUnion<[zV3.ZodType, ...zV3.ZodType[]]>): zV3.ZodType;
145
+ /**
146
+ * Default handler for Zod string types. Processes string validation constraints.
147
+ *
148
+ * @param value - The Zod string to process
149
+ * @param handleChecks - String constraints to convert to descriptions vs keep as validation
150
+ * @returns The processed Zod string
151
+ */
152
+ defaultZodStringHandler(value: zV4.ZodString, handleChecks?: readonly StringCheckType[]): zV4.ZodString;
153
+ defaultZodStringHandler(value: zV3.ZodString, handleChecks?: readonly StringCheckType[]): zV3.ZodString;
154
+ /**
155
+ * Default handler for Zod number types. Processes number validation constraints.
156
+ *
157
+ * @param value - The Zod number to process
158
+ * @param handleChecks - Number constraints to convert to descriptions vs keep as validation
159
+ * @returns The processed Zod number
160
+ */
161
+ defaultZodNumberHandler(value: zV4.ZodNumber, handleChecks?: readonly NumberCheckType[]): zV4.ZodNumber;
162
+ defaultZodNumberHandler(value: zV3.ZodNumber, handleChecks?: readonly NumberCheckType[]): zV3.ZodNumber;
163
+ /**
164
+ * Default handler for Zod date types. Converts dates to ISO strings with constraint descriptions.
165
+ *
166
+ * @param value - The Zod date to process
167
+ * @returns A Zod string schema representing the date in ISO format
168
+ */
169
+ defaultZodDateHandler(value: zV4.ZodDate): zV4.ZodString;
170
+ defaultZodDateHandler(value: zV3.ZodDate): zV3.ZodString;
171
+ /**
172
+ * Default handler for Zod optional types. Processes the inner type and maintains optionality.
173
+ *
174
+ * @param value - The Zod optional to process
175
+ * @param handleTypes - Types that should be processed vs passed through
176
+ * @returns The processed Zod optional
177
+ */
178
+ defaultZodOptionalHandler(value: zV4.ZodOptional<any>, handleTypes?: readonly AllZodTypeV4[]): zV4.ZodType;
179
+ defaultZodOptionalHandler(value: zV3.ZodOptional<any>, handleTypes?: readonly AllZodTypeV3[]): zV3.ZodType;
180
+ /**
181
+ * Processes a Zod object schema and converts it to an AI SDK Schema.
182
+ *
183
+ * @param zodSchema - The Zod object schema to process
184
+ * @returns An AI SDK Schema with provider-specific compatibility applied
185
+ */
186
+ processToAISDKSchema(zodSchema: zV3.ZodSchema | zV4.ZodType): Schema;
187
+ /**
188
+ * Processes a Zod object schema and converts it to a JSON Schema.
189
+ *
190
+ * @param zodSchema - The Zod object schema to process
191
+ * @returns A JSONSchema7 object with provider-specific compatibility applied
192
+ */
193
+ processToJSONSchema(zodSchema: zV3.ZodSchema | zV4.ZodType): JSONSchema7;
194
+ }
195
+ export {};
196
+ //# sourceMappingURL=schema-compatibility.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"schema-compatibility.d.ts","sourceRoot":"","sources":["../src/schema-compatibility.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,CAAC,IAAI,GAAG,EAAE,MAAM,QAAQ,CAAC;AACvC,OAAO,KAAK,EAAE,CAAC,IAAI,GAAG,EAAE,OAAO,EAAE,MAAM,QAAQ,CAAC;AAChD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AASjD,OAAO,KAAK,EACV,kBAAkB,IAAI,oBAAoB,EAC1C,UAAU,I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AG,GAAG,CAAC,SAAS;IAY9G;;;;;;OAMG;IACI,uBAAuB,CAAC,KAAK,EAAE,GAAG,CAAC,SAAS,EAAE,YAAY,CAAC,EAAE,SAAS,eAAe,EAAE,GAAG,GAAG,CAAC,SAAS;IACvG,uBAAuB,CAAC,KAAK,EAAE,GAAG,CAAC,SAAS,EAAE,YAAY,CAAC,EAAE,SAAS,eAAe,EAAE,GAAG,GAAG,CAAC,SAAS;IAY9G;;;;;OAKG;IACI,qBAAqB,CAAC,KAAK,EAAE,GAAG,CAAC,OAAO,GAAG,GAAG,CAAC,SAAS;IACxD,qBAAqB,CAAC,KAAK,EAAE,GAAG,CAAC,OAAO,GAAG,GAAG,CAAC,SAAS;IAS/D;;;;;;OAMG;IACI,yBAAyB,CAAC,KAAK,EAAE,GAAG,CAAC,WAAW,CAAC,GAAG,CAAC,EAAE,WAAW,CAAC,EAAE,SAAS,YAAY,EAAE,GAAG,GAAG,CAAC,OAAO;IAC1G,yBAAyB,CAAC,KAAK,EAAE,GAAG,CAAC,WAAW,CAAC,GAAG,CAAC,EAAE,WAAW,CAAC,EAAE,SAAS,YAAY,EAAE,GAAG,GAAG,CAAC,OAAO;IAYjH;;;;;OAKG;IACI,oBAAoB,CAAC,SAAS,EAAE,GAAG,CAAC,SAAS,GAAG,GAAG,CAAC,OAAO,GAAG,MAAM;IAM3E;;;;;OAKG;IACI,mBAAmB,CAAC,SAAS,EAAE,GAAG,CAAC,SAAS,GAAG,GAAG,CAAC,OAAO,GAAG,WAAW;CAGhF"}
@@ -0,0 +1,7 @@
1
+ export type ModelInformation = {
2
+ modelId: string;
3
+ provider: string;
4
+ supportsStructuredOutputs: boolean;
5
+ };
6
+ export type { Schema } from '@internal/ai-sdk-v4/schema';
7
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,gBAAgB,GAAG;IAC7B,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,MAAM,CAAC;IACjB,yBAAyB,EAAE,OAAO,CAAC;CACpC,CAAC;AAEF,YAAY,EAAE,MAAM,EAAE,MAAM,4BAA4B,CAAC"}
@@ -0,0 +1,2 @@
1
+ export declare function runTestSuite(): void;
2
+ //# sourceMappingURL=utils-test-suite.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils-test-suite.d.ts","sourceRoot":"","sources":["../src/utils-test-suite.ts"],"names":[],"mappings":"AA+CA,wBAAgB,YAAY,SAka3B"}
@@ -0,0 +1,96 @@
1
+ import type { ZodSchema as ZodSchemaV3, ZodType as ZodTypeV3 } from 'zod/v3';
2
+ import type { ZodType as ZodSchemaV4, ZodType as ZodTypeV4 } from 'zod/v4';
3
+ import type { Targets } from 'zod-to-json-schema';
4
+ import type { JSONSchema7 } from './json-schema.js';
5
+ import type { SchemaCompatLayer } from './schema-compatibility.js';
6
+ import type { Schema } from './types.js';
7
+ type ZodSchema = ZodSchemaV3 | ZodSchemaV4;
8
+ type ZodType = ZodTypeV3 | ZodTypeV4;
9
+ /**
10
+ * Converts a Zod schema to an AI SDK Schema with validation support.
11
+ *
12
+ * This function mirrors the behavior of Vercel's AI SDK zod-schema utility but allows
13
+ * customization of the JSON Schema target format.
14
+ *
15
+ * @param zodSchema - The Zod schema to convert
16
+ * @param target - The JSON Schema target format (defaults to 'jsonSchema7')
17
+ * @returns An AI SDK Schema object with built-in validation
18
+ *
19
+ * @example
20
+ * ```typescript
21
+ * import { z } from 'zod';
22
+ * import { convertZodSchemaToAISDKSchema } from '@mastra/schema-compat';
23
+ *
24
+ * const userSchema = z.object({
25
+ * name: z.string(),
26
+ * age: z.number().min(0)
27
+ * });
28
+ *
29
+ * const aiSchema = convertZodSchemaToAISDKSchema(userSchema);
30
+ * ```
31
+ */
32
+ export declare function convertZodSchemaToAISDKSchema(zodSchema: ZodSchema, target?: Targets): Schema<any>;
33
+ /**
34
+ * Checks if a value is a Zod type by examining its properties and methods.
35
+ *
36
+ * @param value - The value to check
37
+ * @returns True if the value is a Zod type, false otherwise
38
+ * @internal
39
+ */
40
+ export declare function isZodType(value: unknown): value is ZodType;
41
+ /**
42
+ * Converts an AI SDK Schema or Zod schema to a Zod schema.
43
+ *
44
+ * If the input is already a Zod schema, it returns it unchanged.
45
+ * If the input is an AI SDK Schema, it extracts the JSON schema and converts it to Zod.
46
+ *
47
+ * @param schema - The schema to convert (AI SDK Schema or Zod schema)
48
+ * @returns A Zod schema equivalent of the input
49
+ * @throws Error if the conversion fails
50
+ *
51
+ * @example
52
+ * ```typescript
53
+ * import { jsonSchema } from 'ai';
54
+ * import { convertSchemaToZod } from '@mastra/schema-compat';
55
+ *
56
+ * const aiSchema = jsonSchema({
57
+ * type: 'object',
58
+ * properties: {
59
+ * name: { type: 'string' }
60
+ * }
61
+ * });
62
+ *
63
+ * const zodSchema = convertSchemaToZod(aiSchema);
64
+ * ```
65
+ */
66
+ export declare function convertSchemaToZod(schema: Schema | ZodSchema): ZodType;
67
+ /**
68
+ * Processes a schema using provider compatibility layers and converts it to an AI SDK Schema.
69
+ *
70
+ * @param options - Configuration object for schema processing
71
+ * @param options.schema - The schema to process (AI SDK Schema or Zod object schema)
72
+ * @param options.compatLayers - Array of compatibility layers to try
73
+ * @param options.mode - Must be 'aiSdkSchema'
74
+ * @returns Processed schema as an AI SDK Schema
75
+ */
76
+ export declare function applyCompatLayer(options: {
77
+ schema: Schema | ZodSchema;
78
+ compatLayers: SchemaCompatLayer[];
79
+ mode: 'aiSdkSchema';
80
+ }): Schema;
81
+ /**
82
+ * Processes a schema using provider compatibility layers and converts it to a JSON Schema.
83
+ *
84
+ * @param options - Configuration object for schema processing
85
+ * @param options.schema - The schema to process (AI SDK Schema or Zod object schema)
86
+ * @param options.compatLayers - Array of compatibility layers to try
87
+ * @param options.mode - Must be 'jsonSchema'
88
+ * @returns Processed schema as a JSONSchema7
89
+ */
90
+ export declare function applyCompatLayer(options: {
91
+ schema: Schema | ZodSchema;
92
+ compatLayers: SchemaCompatLayer[];
93
+ mode: 'jsonSchema';
94
+ }): JSONSchema7;
95
+ export {};
96
+ //# sourceMappingURL=utils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,IAAI,WAAW,EAAE,OAAO,IAAI,SAAS,EAAE,MAAM,QAAQ,CAAC;AAC7E,OAAO,KAAK,EAAE,OAAO,IAAI,WAAW,EAAE,OAAO,IAAI,SAAS,EAAE,MAAM,QAAQ,CAAC;AAI3E,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAEjD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAChE,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AAGtC,KAAK,SAAS,GAAG,WAAW,GAAG,WAAW,CAAC;AAC3C,KAAK,OAAO,GAAG,SAAS,GAAG,SAAS,CAAC;AAErC;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAEH,wBAAgB,6BAA6B,CAAC,SAAS,EAAE,SAAS,EAAE,MAAM,GAAE,OAAuB,GAAG,MAAM,CAAC,GAAG,CAAC,CAShH;AAED;;;;;;GAMG;AACH,wBAAgB,SAAS,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,OAAO,CAW1D;AAED;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,GAAG,OAAO,CAkBtE;AAED;;;;;;;;GAQG;AACH,wBAAgB,gBAAgB,CAAC,OAAO,EAAE;IACxC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC;IAC3B,YAAY,EAAE,iBAAiB,EAAE,CAAC;IAClC,IAAI,EAAE,aAAa,CAAC;CACrB,GAAG,MAAM,CAAC;AAEX;;;;;;;;GAQG;AACH,wBAAgB,gBAAgB,CAAC,OAAO,EAAE;IACxC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC;IAC3B,YAAY,EAAE,iBAAiB,EAAE,CAAC;IAClC,IAAI,EAAE,YAAY,CAAC;CACpB,GAAG,WAAW,CAAC"}
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Shared test suite for zodToJsonSchema that runs with both Zod v3 and v4.
3
+ * The importing test file should mock 'zod' to either v3 or v4 before calling this.
4
+ */
5
+ export declare function runZodToJsonTestSuite(): void;
6
+ //# sourceMappingURL=zod-to-json-test-suite.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"zod-to-json-test-suite.d.ts","sourceRoot":"","sources":["../src/zod-to-json-test-suite.ts"],"names":[],"mappings":"AAIA;;;GAGG;AACH,wBAAgB,qBAAqB,SA8jBpC"}
@@ -0,0 +1,12 @@
1
+ 'use strict';
2
+
3
+ var chunk5WM4A32G_cjs = require('./chunk-5WM4A32G.cjs');
4
+
5
+
6
+
7
+ Object.defineProperty(exports, "zodToJsonSchema", {
8
+ enumerable: true,
9
+ get: function () { return chunk5WM4A32G_cjs.zodToJsonSchema; }
10
+ });
11
+ //# sourceMappingURL=zod-to-json.cjs.map
12
+ //# sourceMappingURL=zod-to-json.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"names":[],"mappings":"","file":"zod-to-json.cjs"}
@@ -0,0 +1,6 @@
1
+ import type { JSONSchema7 } from 'json-schema';
2
+ import type { ZodSchema as ZodSchemaV3 } from 'zod/v3';
3
+ import type { ZodType as ZodSchemaV4 } from 'zod/v4';
4
+ import type { Targets } from 'zod-to-json-schema';
5
+ export declare function zodToJsonSchema(zodSchema: ZodSchemaV3 | ZodSchemaV4, target?: Targets, strategy?: 'none' | 'seen' | 'root' | 'relative'): JSONSchema7;
6
+ //# sourceMappingURL=zod-to-json.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"zod-to-json.d.ts","sourceRoot":"","sources":["../src/zod-to-json.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAE/C,OAAO,KAAK,EAAE,SAAS,IAAI,WAAW,EAAE,MAAM,QAAQ,CAAC;AACvD,OAAO,KAAK,EAAE,OAAO,IAAI,WAAW,EAAE,MAAM,QAAQ,CAAC;AACrD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAmFlD,wBAAgB,eAAe,CAC7B,SAAS,EAAE,WAAW,GAAG,WAAW,EACpC,MAAM,GAAE,OAAuB,EAC/B,QAAQ,GAAE,MAAM,GAAG,MAAM,GAAG,MAAM,GAAG,UAAuB,eA2B7D"}
@@ -0,0 +1,3 @@
1
+ export { zodToJsonSchema } from './chunk-U2HXWNAF.js';
2
+ //# sourceMappingURL=zod-to-json.js.map
3
+ //# sourceMappingURL=zod-to-json.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"names":[],"mappings":"","file":"zod-to-json.js"}