@mastra/schema-compat 0.0.0-fix-message-list-args-missing-20250807205055 → 0.0.0-fix-zod-to-json-schema-ref-strategy-20250910193441

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 (63) hide show
  1. package/CHANGELOG.md +89 -1
  2. package/README.md +0 -4
  3. package/dist/chunk-7YUR5KZ5.cjs +34 -0
  4. package/dist/chunk-7YUR5KZ5.cjs.map +1 -0
  5. package/dist/chunk-GWTUXMDD.js +28 -0
  6. package/dist/chunk-GWTUXMDD.js.map +1 -0
  7. package/dist/index.cjs +842 -83
  8. package/dist/index.cjs.map +1 -1
  9. package/dist/index.d.ts +10 -8
  10. package/dist/index.d.ts.map +1 -1
  11. package/dist/index.js +841 -84
  12. package/dist/index.js.map +1 -1
  13. package/dist/provider-compats/anthropic.d.ts +6 -4
  14. package/dist/provider-compats/anthropic.d.ts.map +1 -1
  15. package/dist/provider-compats/deepseek.d.ts +6 -4
  16. package/dist/provider-compats/deepseek.d.ts.map +1 -1
  17. package/dist/provider-compats/google.d.ts +6 -4
  18. package/dist/provider-compats/google.d.ts.map +1 -1
  19. package/dist/provider-compats/meta.d.ts +6 -4
  20. package/dist/provider-compats/meta.d.ts.map +1 -1
  21. package/dist/provider-compats/openai-reasoning.d.ts +6 -4
  22. package/dist/provider-compats/openai-reasoning.d.ts.map +1 -1
  23. package/dist/provider-compats/openai.d.ts +6 -4
  24. package/dist/provider-compats/openai.d.ts.map +1 -1
  25. package/dist/schema-compatibility-v3.d.ts +319 -0
  26. package/dist/schema-compatibility-v3.d.ts.map +1 -0
  27. package/dist/schema-compatibility-v4.d.ts +310 -0
  28. package/dist/schema-compatibility-v4.d.ts.map +1 -0
  29. package/dist/schema-compatibility.d.ts +76 -133
  30. package/dist/schema-compatibility.d.ts.map +1 -1
  31. package/dist/types.d.ts +6 -0
  32. package/dist/types.d.ts.map +1 -0
  33. package/dist/utils-test-suite.d.ts +2 -0
  34. package/dist/utils-test-suite.d.ts.map +1 -0
  35. package/dist/utils.d.ts +17 -5
  36. package/dist/utils.d.ts.map +1 -1
  37. package/dist/zod-to-json.cjs +12 -0
  38. package/dist/zod-to-json.cjs.map +1 -0
  39. package/dist/zod-to-json.d.ts +6 -0
  40. package/dist/zod-to-json.d.ts.map +1 -0
  41. package/dist/zod-to-json.js +3 -0
  42. package/dist/zod-to-json.js.map +1 -0
  43. package/dist/zodTypes.d.ts +21 -0
  44. package/dist/zodTypes.d.ts.map +1 -0
  45. package/package.json +31 -8
  46. package/.turbo/turbo-build.log +0 -4
  47. package/eslint.config.js +0 -6
  48. package/src/index.ts +0 -39
  49. package/src/provider-compats/anthropic.ts +0 -43
  50. package/src/provider-compats/deepseek.ts +0 -35
  51. package/src/provider-compats/google.ts +0 -63
  52. package/src/provider-compats/meta.ts +0 -36
  53. package/src/provider-compats/openai-reasoning.ts +0 -91
  54. package/src/provider-compats/openai.ts +0 -55
  55. package/src/provider-compats.test.ts +0 -407
  56. package/src/schema-compatibility.test.ts +0 -487
  57. package/src/schema-compatibility.ts +0 -594
  58. package/src/utils.test.ts +0 -460
  59. package/src/utils.ts +0 -205
  60. package/tsconfig.build.json +0 -9
  61. package/tsconfig.json +0 -5
  62. package/tsup.config.ts +0 -17
  63. package/vitest.config.ts +0 -7
@@ -1,83 +1,10 @@
1
1
  import type { Schema } from 'ai';
2
2
  import type { JSONSchema7 } from 'json-schema';
3
- import { z, ZodOptional, ZodObject, ZodArray, ZodUnion, ZodString, ZodNumber, ZodDate, ZodDefault, ZodNull } from 'zod';
4
- import type { ZodTypeAny } from 'zod';
3
+ import type { z as zV3 } from 'zod/v3';
4
+ import type { z as zV4, ZodType } from 'zod/v4';
5
5
  import type { Targets } from 'zod-to-json-schema';
6
- /**
7
- * All supported string validation check types that can be processed or converted to descriptions.
8
- * @constant
9
- */
10
- export declare const ALL_STRING_CHECKS: readonly ["regex", "emoji", "email", "url", "uuid", "cuid", "min", "max"];
11
- /**
12
- * All supported number validation check types that can be processed or converted to descriptions.
13
- * @constant
14
- */
15
- export declare const ALL_NUMBER_CHECKS: readonly ["min", "max", "multipleOf"];
16
- /**
17
- * All supported array validation check types that can be processed or converted to descriptions.
18
- * @constant
19
- */
20
- export declare const ALL_ARRAY_CHECKS: readonly ["min", "max", "length"];
21
- export declare const isOptional: (v: ZodTypeAny) => v is ZodOptional<any>;
22
- export declare const isObj: (v: ZodTypeAny) => v is ZodObject<any, any, any>;
23
- export declare const isNull: (v: ZodTypeAny) => v is ZodNull;
24
- export declare const isArr: (v: ZodTypeAny) => v is ZodArray<any, any>;
25
- export declare const isUnion: (v: ZodTypeAny) => v is ZodUnion<[ZodTypeAny, ...ZodTypeAny[]]>;
26
- export declare const isString: (v: ZodTypeAny) => v is ZodString;
27
- export declare const isNumber: (v: ZodTypeAny) => v is ZodNumber;
28
- export declare const isDate: (v: ZodTypeAny) => v is ZodDate;
29
- export declare const isDefault: (v: ZodTypeAny) => v is ZodDefault<any>;
30
- /**
31
- * Zod types that are not supported by most AI model providers and should be avoided.
32
- * @constant
33
- */
34
- export declare const UNSUPPORTED_ZOD_TYPES: readonly ["ZodIntersection", "ZodNever", "ZodNull", "ZodTuple", "ZodUndefined"];
35
- /**
36
- * Zod types that are generally supported by AI model providers.
37
- * @constant
38
- */
39
- export declare const SUPPORTED_ZOD_TYPES: readonly ["ZodObject", "ZodArray", "ZodUnion", "ZodString", "ZodNumber", "ZodDate", "ZodAny", "ZodDefault"];
40
- /**
41
- * All Zod types (both supported and unsupported).
42
- * @constant
43
- */
44
- export declare const ALL_ZOD_TYPES: readonly ["ZodObject", "ZodArray", "ZodUnion", "ZodString", "ZodNumber", "ZodDate", "ZodAny", "ZodDefault", "ZodIntersection", "ZodNever", "ZodNull", "ZodTuple", "ZodUndefined"];
45
- /**
46
- * Type representing string validation checks.
47
- */
48
- export type StringCheckType = (typeof ALL_STRING_CHECKS)[number];
49
- /**
50
- * Type representing number validation checks.
51
- */
52
- export type NumberCheckType = (typeof ALL_NUMBER_CHECKS)[number];
53
- /**
54
- * Type representing array validation checks.
55
- */
56
- export type ArrayCheckType = (typeof ALL_ARRAY_CHECKS)[number];
57
- /**
58
- * Type representing unsupported Zod schema types.
59
- */
60
- export type UnsupportedZodType = (typeof UNSUPPORTED_ZOD_TYPES)[number];
61
- /**
62
- * Type representing supported Zod schema types.
63
- */
64
- export type SupportedZodType = (typeof SUPPORTED_ZOD_TYPES)[number];
65
- /**
66
- * Type representing all Zod schema types (supported and unsupported).
67
- */
68
- export type AllZodType = (typeof ALL_ZOD_TYPES)[number];
69
- /**
70
- * Utility type to extract the shape of a Zod object schema.
71
- */
72
- export type ZodShape<T extends z.AnyZodObject> = T['shape'];
73
- /**
74
- * Utility type to extract the keys from a Zod object shape.
75
- */
76
- export type ShapeKey<T extends z.AnyZodObject> = keyof ZodShape<T>;
77
- /**
78
- * Utility type to extract the value types from a Zod object shape.
79
- */
80
- export type ShapeValue<T extends z.AnyZodObject> = ZodShape<T>[ShapeKey<T>];
6
+ import type { UnsupportedZodType as UnsupportedZodTypeV3, ShapeValue as ShapeValueV3, StringCheckType, NumberCheckType, ArrayCheckType, AllZodType as AllZodTypeV3 } from './schema-compatibility-v3';
7
+ import type { UnsupportedZodType as UnsupportedZodTypeV4, ShapeValue as ShapeValueV4, AllZodType as AllZodTypeV4 } from './schema-compatibility-v4';
81
8
  type StringConstraints = {
82
9
  minLength?: number;
83
10
  maxLength?: number;
@@ -108,52 +35,11 @@ type DateConstraints = {
108
35
  maxDate?: string;
109
36
  dateFormat?: string;
110
37
  };
111
- export type ModelInformation = {
112
- modelId: string;
113
- provider: string;
114
- supportsStructuredOutputs: boolean;
115
- };
116
- /**
117
- * Abstract base class for creating schema compatibility layers for different AI model providers.
118
- *
119
- * This class provides a framework for transforming Zod schemas to work with specific AI model
120
- * provider requirements and limitations. Each provider may have different support levels for
121
- * JSON Schema features, validation constraints, and data types.
122
- *
123
- * @abstract
124
- *
125
- * @example
126
- * ```typescript
127
- * import { SchemaCompatLayer } from '@mastra/schema-compat';
128
- * import type { LanguageModelV1 } from 'ai';
129
- *
130
- * class CustomProviderCompat extends SchemaCompatLayer {
131
- * constructor(model: LanguageModelV1) {
132
- * super(model);
133
- * }
134
- *
135
- * shouldApply(): boolean {
136
- * return this.getModel().provider === 'custom-provider';
137
- * }
138
- *
139
- * getSchemaTarget() {
140
- * return 'jsonSchema7';
141
- * }
142
- *
143
- * processZodType<T extends z.AnyZodObject>(value: z.ZodTypeAny): ShapeValue<T> {
144
- * // Custom processing logic for this provider
145
- * switch (value._def.typeName) {
146
- * case 'ZodString':
147
- * return this.defaultZodStringHandler(value, ['email', 'url']);
148
- * default:
149
- * return this.defaultUnsupportedZodTypeHandler(value);
150
- * }
151
- * }
152
- * }
153
- * ```
154
- */
38
+ import type { ModelInformation } from './types';
155
39
  export declare abstract class SchemaCompatLayer {
156
40
  private model;
41
+ private v3Layer;
42
+ private v4Layer;
157
43
  /**
158
44
  * Creates a new schema compatibility instance.
159
45
  *
@@ -166,6 +52,52 @@ export declare abstract class SchemaCompatLayer {
166
52
  * @returns The language model instance
167
53
  */
168
54
  getModel(): ModelInformation;
55
+ getUnsupportedZodTypes(v: ZodType): readonly string[];
56
+ /**
57
+ * Type guard for optional Zod types
58
+ */
59
+ isOptional(v: zV4.ZodType): v is zV4.ZodOptional<any>;
60
+ isOptional(v: zV3.ZodType): v is zV3.ZodOptional<any>;
61
+ /**
62
+ * Type guard for object Zod types
63
+ */
64
+ isObj(v: zV4.ZodType): v is zV4.ZodObject<any, any>;
65
+ isObj(v: zV3.ZodType): v is zV3.ZodObject<any, any, any, any, any>;
66
+ /**
67
+ * Type guard for null Zod types
68
+ */
69
+ isNull(v: zV4.ZodType): v is zV4.ZodNull;
70
+ isNull(v: zV3.ZodType): v is zV3.ZodNull;
71
+ /**
72
+ * Type guard for array Zod types
73
+ */
74
+ isArr(v: zV4.ZodType): v is zV4.ZodArray<any>;
75
+ isArr(v: zV3.ZodType): v is zV3.ZodArray<any, any>;
76
+ /**
77
+ * Type guard for union Zod types
78
+ */
79
+ isUnion(v: zV4.ZodType): v is zV4.ZodUnion<[zV4.ZodType, ...zV4.ZodType[]]>;
80
+ isUnion(v: zV3.ZodType): v is zV3.ZodUnion<[zV3.ZodType, ...zV3.ZodType[]]>;
81
+ /**
82
+ * Type guard for string Zod types
83
+ */
84
+ isString(v: zV4.ZodType): v is zV4.ZodString;
85
+ isString(v: zV3.ZodType): v is zV3.ZodString;
86
+ /**
87
+ * Type guard for number Zod types
88
+ */
89
+ isNumber(v: zV4.ZodType): v is zV4.ZodNumber;
90
+ isNumber(v: zV3.ZodType): v is zV3.ZodNumber;
91
+ /**
92
+ * Type guard for date Zod types
93
+ */
94
+ isDate(v: zV4.ZodType): v is zV4.ZodDate;
95
+ isDate(v: zV3.ZodType): v is zV3.ZodDate;
96
+ /**
97
+ * Type guard for default Zod types
98
+ */
99
+ isDefault(v: zV4.ZodType): v is zV4.ZodDefault<any>;
100
+ isDefault(v: zV3.ZodType): v is zV3.ZodDefault<any>;
169
101
  /**
170
102
  * Determines whether this compatibility layer should be applied for the current model.
171
103
  *
@@ -187,16 +119,21 @@ export declare abstract class SchemaCompatLayer {
187
119
  * @returns The processed Zod type
188
120
  * @abstract
189
121
  */
190
- abstract processZodType(value: ZodTypeAny): ZodTypeAny;
122
+ abstract processZodType(value: zV4.ZodType): zV4.ZodType;
123
+ abstract processZodType(value: zV3.ZodType): zV3.ZodType;
124
+ abstract processZodType(value: zV4.ZodType | zV3.ZodType): zV4.ZodType | zV3.ZodType;
191
125
  /**
192
126
  * Default handler for Zod object types. Recursively processes all properties in the object.
193
127
  *
194
128
  * @param value - The Zod object to process
195
129
  * @returns The processed Zod object
196
130
  */
197
- defaultZodObjectHandler(value: ZodObject<any, any, any>, options?: {
131
+ defaultZodObjectHandler(value: zV4.ZodObject<any, any>, options?: {
132
+ passthrough?: boolean;
133
+ }): zV4.ZodObject<any, any>;
134
+ defaultZodObjectHandler(value: zV3.ZodObject<any, any>, options?: {
198
135
  passthrough?: boolean;
199
- }): ZodObject<any, any, any>;
136
+ }): zV3.ZodObject<any, any>;
200
137
  /**
201
138
  * Merges validation constraints into a parameter description.
202
139
  *
@@ -218,7 +155,7 @@ export declare abstract class SchemaCompatLayer {
218
155
  * @returns The original value if not in the throw list
219
156
  * @throws Error if the type is in the unsupported list
220
157
  */
221
- defaultUnsupportedZodTypeHandler<T extends z.AnyZodObject>(value: z.ZodTypeAny, throwOnTypes?: readonly UnsupportedZodType[]): ShapeValue<T>;
158
+ 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;
222
159
  /**
223
160
  * Default handler for Zod array types. Processes array constraints according to provider support.
224
161
  *
@@ -226,7 +163,8 @@ export declare abstract class SchemaCompatLayer {
226
163
  * @param handleChecks - Array constraints to convert to descriptions vs keep as validation
227
164
  * @returns The processed Zod array
228
165
  */
229
- defaultZodArrayHandler(value: ZodArray<any, any>, handleChecks?: readonly ArrayCheckType[]): ZodArray<any, any>;
166
+ defaultZodArrayHandler(value: zV4.ZodArray<any>, handleChecks?: readonly ArrayCheckType[]): zV4.ZodArray<any>;
167
+ defaultZodArrayHandler(value: zV3.ZodArray<any, any>, handleChecks?: readonly ArrayCheckType[]): zV3.ZodArray<any, any>;
230
168
  /**
231
169
  * Default handler for Zod union types. Processes all union options.
232
170
  *
@@ -234,7 +172,8 @@ export declare abstract class SchemaCompatLayer {
234
172
  * @returns The processed Zod union
235
173
  * @throws Error if union has fewer than 2 options
236
174
  */
237
- defaultZodUnionHandler(value: ZodUnion<[ZodTypeAny, ...ZodTypeAny[]]>): ZodTypeAny;
175
+ defaultZodUnionHandler(value: zV4.ZodUnion<[zV4.ZodType, ...zV4.ZodType[]]>): zV4.ZodType;
176
+ defaultZodUnionHandler(value: zV3.ZodUnion<[zV3.ZodType, ...zV3.ZodType[]]>): zV3.ZodType;
238
177
  /**
239
178
  * Default handler for Zod string types. Processes string validation constraints.
240
179
  *
@@ -242,7 +181,8 @@ export declare abstract class SchemaCompatLayer {
242
181
  * @param handleChecks - String constraints to convert to descriptions vs keep as validation
243
182
  * @returns The processed Zod string
244
183
  */
245
- defaultZodStringHandler(value: ZodString, handleChecks?: readonly StringCheckType[]): ZodString;
184
+ defaultZodStringHandler(value: zV4.ZodString, handleChecks?: readonly StringCheckType[]): zV4.ZodString;
185
+ defaultZodStringHandler(value: zV3.ZodString, handleChecks?: readonly StringCheckType[]): zV3.ZodString;
246
186
  /**
247
187
  * Default handler for Zod number types. Processes number validation constraints.
248
188
  *
@@ -250,14 +190,16 @@ export declare abstract class SchemaCompatLayer {
250
190
  * @param handleChecks - Number constraints to convert to descriptions vs keep as validation
251
191
  * @returns The processed Zod number
252
192
  */
253
- defaultZodNumberHandler(value: ZodNumber, handleChecks?: readonly NumberCheckType[]): ZodNumber;
193
+ defaultZodNumberHandler(value: zV4.ZodNumber, handleChecks?: readonly NumberCheckType[]): zV4.ZodNumber;
194
+ defaultZodNumberHandler(value: zV3.ZodNumber, handleChecks?: readonly NumberCheckType[]): zV3.ZodNumber;
254
195
  /**
255
196
  * Default handler for Zod date types. Converts dates to ISO strings with constraint descriptions.
256
197
  *
257
198
  * @param value - The Zod date to process
258
199
  * @returns A Zod string schema representing the date in ISO format
259
200
  */
260
- defaultZodDateHandler(value: ZodDate): ZodString;
201
+ defaultZodDateHandler(value: zV4.ZodDate): zV4.ZodString;
202
+ defaultZodDateHandler(value: zV3.ZodDate): zV3.ZodString;
261
203
  /**
262
204
  * Default handler for Zod optional types. Processes the inner type and maintains optionality.
263
205
  *
@@ -265,21 +207,22 @@ export declare abstract class SchemaCompatLayer {
265
207
  * @param handleTypes - Types that should be processed vs passed through
266
208
  * @returns The processed Zod optional
267
209
  */
268
- defaultZodOptionalHandler(value: ZodOptional<any>, handleTypes?: readonly AllZodType[]): ZodTypeAny;
210
+ defaultZodOptionalHandler(value: zV4.ZodOptional<any>, handleTypes?: readonly AllZodTypeV4[]): zV4.ZodType;
211
+ defaultZodOptionalHandler(value: zV3.ZodOptional<any>, handleTypes?: readonly AllZodTypeV3[]): zV3.ZodType;
269
212
  /**
270
213
  * Processes a Zod object schema and converts it to an AI SDK Schema.
271
214
  *
272
215
  * @param zodSchema - The Zod object schema to process
273
216
  * @returns An AI SDK Schema with provider-specific compatibility applied
274
217
  */
275
- processToAISDKSchema(zodSchema: z.ZodSchema): Schema;
218
+ processToAISDKSchema(zodSchema: zV3.ZodSchema | zV4.ZodType): Schema;
276
219
  /**
277
220
  * Processes a Zod object schema and converts it to a JSON Schema.
278
221
  *
279
222
  * @param zodSchema - The Zod object schema to process
280
223
  * @returns A JSONSchema7 object with provider-specific compatibility applied
281
224
  */
282
- processToJSONSchema(zodSchema: z.ZodSchema): JSONSchema7;
225
+ processToJSONSchema(zodSchema: zV3.ZodSchema | zV4.ZodType): JSONSchema7;
283
226
  }
284
227
  export {};
285
228
  //# sourceMappingURL=schema-compatibility.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"schema-compatibility.d.ts","sourceRoot":"","sources":["../src/schema-compatibility.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,IAAI,CAAC;AACjC,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC/C,OAAO,EAAE,CAAC,EAAE,WAAW,EAAE,SAAS,EAAE,QAAQ,EAAE,QAAQ,EAAE,SAAS,EAAE,SAAS,EAAE,OAAO,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,KAAK,CAAC;AACxH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,KAAK,CAAC;AACtC,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAGlD;;;GAGG;AACH,eAAO,MAAM,iBAAiB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 };
6
+ //# 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"}
@@ -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":"AAgDA,wBAAgB,YAAY,SAka3B"}
package/dist/utils.d.ts CHANGED
@@ -1,8 +1,11 @@
1
1
  import type { Schema } from 'ai';
2
2
  import type { JSONSchema7 } from 'json-schema';
3
- import type { z, ZodSchema } from 'zod';
3
+ import type { ZodSchema as ZodSchemaV3, ZodType as ZodTypeV3 } from 'zod/v3';
4
+ import type { ZodType as ZodSchemaV4, ZodType as ZodTypeV4 } from 'zod/v4';
4
5
  import type { Targets } from 'zod-to-json-schema';
5
- import type { SchemaCompatLayer } from './schema-compatibility.js';
6
+ import type { SchemaCompatLayer } from './schema-compatibility';
7
+ type ZodSchema = ZodSchemaV3 | ZodSchemaV4;
8
+ type ZodType = ZodTypeV3 | ZodTypeV4;
6
9
  /**
7
10
  * Converts a Zod schema to an AI SDK Schema with validation support.
8
11
  *
@@ -27,6 +30,14 @@ import type { SchemaCompatLayer } from './schema-compatibility.js';
27
30
  * ```
28
31
  */
29
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;
30
41
  /**
31
42
  * Converts an AI SDK Schema or Zod schema to a Zod schema.
32
43
  *
@@ -52,7 +63,7 @@ export declare function convertZodSchemaToAISDKSchema(zodSchema: ZodSchema, targ
52
63
  * const zodSchema = convertSchemaToZod(aiSchema);
53
64
  * ```
54
65
  */
55
- export declare function convertSchemaToZod(schema: Schema | z.ZodSchema): z.ZodType;
66
+ export declare function convertSchemaToZod(schema: Schema | ZodSchema): ZodType;
56
67
  /**
57
68
  * Processes a schema using provider compatibility layers and converts it to an AI SDK Schema.
58
69
  *
@@ -63,7 +74,7 @@ export declare function convertSchemaToZod(schema: Schema | z.ZodSchema): z.ZodT
63
74
  * @returns Processed schema as an AI SDK Schema
64
75
  */
65
76
  export declare function applyCompatLayer(options: {
66
- schema: Schema | z.ZodSchema;
77
+ schema: Schema | ZodSchema;
67
78
  compatLayers: SchemaCompatLayer[];
68
79
  mode: 'aiSdkSchema';
69
80
  }): Schema;
@@ -77,8 +88,9 @@ export declare function applyCompatLayer(options: {
77
88
  * @returns Processed schema as a JSONSchema7
78
89
  */
79
90
  export declare function applyCompatLayer(options: {
80
- schema: Schema | z.ZodSchema;
91
+ schema: Schema | ZodSchema;
81
92
  compatLayers: SchemaCompatLayer[];
82
93
  mode: 'jsonSchema';
83
94
  }): JSONSchema7;
95
+ export {};
84
96
  //# sourceMappingURL=utils.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,IAAI,CAAC;AACjC,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC/C,OAAO,KAAK,EAAE,CAAC,EAAE,SAAS,EAAE,MAAM,KAAK,CAAC;AAGxC,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAElD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAEhE;;;;;;;;;;;;;;;;;;;;;;GAsB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;;;;;;;;;;;;;GAsBG;AAEH,wBAAgB,6BAA6B,CAAC,SAAS,EAAE,SAAS,EAAE,MAAM,GAAE,OAAuB,eASlG;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,12 @@
1
+ 'use strict';
2
+
3
+ var chunk7YUR5KZ5_cjs = require('./chunk-7YUR5KZ5.cjs');
4
+
5
+
6
+
7
+ Object.defineProperty(exports, "zodToJsonSchema", {
8
+ enumerable: true,
9
+ get: function () { return chunk7YUR5KZ5_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;AAGlD,wBAAgB,eAAe,CAC7B,SAAS,EAAE,WAAW,GAAG,WAAW,EACpC,MAAM,GAAE,OAAuB,EAC/B,QAAQ,GAAE,MAAM,GAAG,MAAM,GAAG,MAAM,GAAG,UAAuB,eAuB7D"}
@@ -0,0 +1,3 @@
1
+ export { zodToJsonSchema } from './chunk-GWTUXMDD.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"}
@@ -0,0 +1,21 @@
1
+ import type { z as zV3 } from 'zod/v3';
2
+ import type { z as zV4 } from 'zod/v4';
3
+ export declare function isOptional<Z extends typeof zV3>(z: Z): (v: any) => v is zV3.ZodOptional<any>;
4
+ export declare function isOptional<Z extends typeof zV4>(z: Z): (v: any) => v is zV4.ZodOptional<any>;
5
+ export declare function isObj<Z extends typeof zV3>(z: Z): (v: any) => v is zV3.ZodObject<any>;
6
+ export declare function isObj<Z extends typeof zV4>(z: Z): (v: any) => v is zV4.ZodObject;
7
+ export declare function isNull<Z extends typeof zV3>(z: Z): (v: any) => v is zV3.ZodNull;
8
+ export declare function isNull<Z extends typeof zV4>(z: Z): (v: any) => v is zV4.ZodNull;
9
+ export declare function isArr<Z extends typeof zV3>(z: Z): (v: any) => v is zV3.ZodArray<any>;
10
+ export declare function isArr<Z extends typeof zV4>(z: Z): (v: any) => v is zV4.ZodArray;
11
+ export declare function isUnion<Z extends typeof zV3>(z: Z): (v: any) => v is zV3.ZodUnion<any>;
12
+ export declare function isUnion<Z extends typeof zV4>(z: Z): (v: any) => v is zV4.ZodUnion;
13
+ export declare function isString<Z extends typeof zV3>(z: Z): (v: any) => v is zV3.ZodString;
14
+ export declare function isString<Z extends typeof zV4>(z: Z): (v: any) => v is zV4.ZodString;
15
+ export declare function isNumber<Z extends typeof zV3>(z: Z): (v: any) => v is zV3.ZodNumber;
16
+ export declare function isNumber<Z extends typeof zV4>(z: Z): (v: any) => v is zV4.ZodNumber;
17
+ export declare function isDate<Z extends typeof zV3>(z: Z): (v: any) => v is zV3.ZodDate;
18
+ export declare function isDate<Z extends typeof zV4>(z: Z): (v: any) => v is zV4.ZodDate;
19
+ export declare function isDefault<Z extends typeof zV3>(z: Z): (v: any) => v is zV3.ZodDefault<any>;
20
+ export declare function isDefault<Z extends typeof zV4>(z: Z): (v: any) => v is zV4.ZodDefault;
21
+ //# sourceMappingURL=zodTypes.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"zodTypes.d.ts","sourceRoot":"","sources":["../src/zodTypes.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,CAAC,IAAI,GAAG,EAAE,MAAM,QAAQ,CAAC;AACvC,OAAO,KAAK,EAAE,CAAC,IAAI,GAAG,EAAE,MAAM,QAAQ,CAAC;AAEvC,wBAAgB,UAAU,CAAC,CAAC,SAAS,OAAO,GAAG,EAAE,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC,EAAE,GAAG,KAAK,CAAC,IAAI,GAAG,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC;AAC9F,wBAAgB,UAAU,CAAC,CAAC,SAAS,OAAO,GAAG,EAAE,CAAC,EAAE,CAAC,G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CAAC,CAAC,EAAE,GAAG,KAAK,CAAC,IAAI,GAAG,CAAC,UAAU,CAAC"}
package/package.json CHANGED
@@ -1,10 +1,14 @@
1
1
  {
2
2
  "name": "@mastra/schema-compat",
3
- "version": "0.0.0-fix-message-list-args-missing-20250807205055",
3
+ "version": "0.0.0-fix-zod-to-json-schema-ref-strategy-20250910193441",
4
4
  "description": "Tool schema compatibility layer for Mastra.ai",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
7
7
  "types": "dist/index.d.ts",
8
+ "files": [
9
+ "dist",
10
+ "CHANGELOG.md"
11
+ ],
8
12
  "exports": {
9
13
  ".": {
10
14
  "import": {
@@ -16,6 +20,16 @@
16
20
  "default": "./dist/index.cjs"
17
21
  }
18
22
  },
23
+ "./zod-to-json": {
24
+ "import": {
25
+ "types": "./dist/zod-to-json.d.ts",
26
+ "default": "./dist/zod-to-json.js"
27
+ },
28
+ "require": {
29
+ "types": "./dist/zod-to-json.d.ts",
30
+ "default": "./dist/zod-to-json.cjs"
31
+ }
32
+ },
19
33
  "./package.json": "./package.json"
20
34
  },
21
35
  "keywords": [
@@ -29,12 +43,13 @@
29
43
  "license": "Apache-2.0",
30
44
  "dependencies": {
31
45
  "json-schema": "^0.4.0",
32
- "zod-from-json-schema": "^0.0.5",
33
- "zod-to-json-schema": "^3.24.5"
46
+ "zod-from-json-schema": "^0.5.0",
47
+ "zod-from-json-schema-v3": "npm:zod-from-json-schema@^0.0.5",
48
+ "zod-to-json-schema": "^3.24.6"
34
49
  },
35
50
  "peerDependencies": {
36
- "ai": "^4.0.0",
37
- "zod": "^3.0.0"
51
+ "ai": "^4.0.0 || ^5.0.0",
52
+ "zod": "^3.25.0 || ^4.0.0"
38
53
  },
39
54
  "devDependencies": {
40
55
  "@types/json-schema": "^7.0.15",
@@ -44,9 +59,17 @@
44
59
  "tsup": "^8.5.0",
45
60
  "typescript": "^5.8.3",
46
61
  "vitest": "^3.2.4",
47
- "zod": "^3.25.67",
48
- "@internal/lint": "0.0.0-fix-message-list-args-missing-20250807205055",
49
- "@internal/types-builder": "0.0.0-fix-message-list-args-missing-20250807205055"
62
+ "zod": "^3.25.76",
63
+ "@internal/lint": "0.0.0-fix-zod-to-json-schema-ref-strategy-20250910193441"
64
+ },
65
+ "homepage": "https://mastra.ai",
66
+ "repository": {
67
+ "type": "git",
68
+ "url": "git+https://github.com/mastra-ai/mastra.git",
69
+ "directory": "packages/schema-compat"
70
+ },
71
+ "bugs": {
72
+ "url": "https://github.com/mastra-ai/mastra/issues"
50
73
  },
51
74
  "scripts": {
52
75
  "build": "tsup --silent --config tsup.config.ts",
@@ -1,4 +0,0 @@
1
-
2
- > @mastra/schema-compat@0.10.7-alpha.0 build /home/runner/work/mastra/mastra/packages/schema-compat
3
- > tsup --silent --config tsup.config.ts
4
-
package/eslint.config.js DELETED
@@ -1,6 +0,0 @@
1
- import { createConfig } from '@internal/lint/eslint';
2
-
3
- const config = await createConfig();
4
-
5
- /** @type {import("eslint").Linter.Config[]} */
6
- export default [...config];
package/src/index.ts DELETED
@@ -1,39 +0,0 @@
1
- // Schema compatibility base class and related types
2
- export {
3
- SchemaCompatLayer,
4
- // Constants
5
- ALL_STRING_CHECKS,
6
- ALL_NUMBER_CHECKS,
7
- ALL_ARRAY_CHECKS,
8
- UNSUPPORTED_ZOD_TYPES,
9
- SUPPORTED_ZOD_TYPES,
10
- ALL_ZOD_TYPES,
11
- // Types
12
- type StringCheckType,
13
- type NumberCheckType,
14
- type ArrayCheckType,
15
- type UnsupportedZodType,
16
- type SupportedZodType,
17
- type AllZodType,
18
- type ZodShape,
19
- type ShapeKey,
20
- type ShapeValue,
21
- // Re-usable type predicates
22
- isOptional,
23
- isObj,
24
- isArr,
25
- isUnion,
26
- isString,
27
- isNumber,
28
- } from './schema-compatibility';
29
-
30
- // Utility functions
31
- export { convertZodSchemaToAISDKSchema, applyCompatLayer, convertSchemaToZod } from './utils';
32
-
33
- // Provider compatibility implementations
34
- export { AnthropicSchemaCompatLayer } from './provider-compats/anthropic';
35
- export { DeepSeekSchemaCompatLayer } from './provider-compats/deepseek';
36
- export { GoogleSchemaCompatLayer } from './provider-compats/google';
37
- export { MetaSchemaCompatLayer } from './provider-compats/meta';
38
- export { OpenAISchemaCompatLayer } from './provider-compats/openai';
39
- export { OpenAIReasoningSchemaCompatLayer } from './provider-compats/openai-reasoning';