@mastra/schema-compat 0.0.0-ai-v5-20250813235735 → 0.0.0-allow-to-pass-a-mastra-url-instance-20251105224938
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 +113 -2
- package/README.md +0 -4
- package/dist/chunk-5WM4A32G.cjs +83 -0
- package/dist/chunk-5WM4A32G.cjs.map +1 -0
- package/dist/chunk-U2HXWNAF.js +77 -0
- package/dist/chunk-U2HXWNAF.js.map +1 -0
- package/dist/index.cjs +4562 -276
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +5 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4560 -277
- package/dist/index.js.map +1 -1
- package/dist/json-schema.d.ts +4 -0
- package/dist/json-schema.d.ts.map +1 -0
- package/dist/provider-compats/anthropic.d.ts +5 -3
- package/dist/provider-compats/anthropic.d.ts.map +1 -1
- package/dist/provider-compats/deepseek.d.ts +5 -3
- package/dist/provider-compats/deepseek.d.ts.map +1 -1
- package/dist/provider-compats/google.d.ts +5 -3
- package/dist/provider-compats/google.d.ts.map +1 -1
- package/dist/provider-compats/meta.d.ts +5 -3
- package/dist/provider-compats/meta.d.ts.map +1 -1
- package/dist/provider-compats/openai-reasoning.d.ts +5 -3
- package/dist/provider-compats/openai-reasoning.d.ts.map +1 -1
- package/dist/provider-compats/openai.d.ts +5 -3
- package/dist/provider-compats/openai.d.ts.map +1 -1
- package/dist/schema-compatibility-v3.d.ts +287 -0
- package/dist/schema-compatibility-v3.d.ts.map +1 -0
- package/dist/schema-compatibility-v4.d.ts +278 -0
- package/dist/schema-compatibility-v4.d.ts.map +1 -0
- package/dist/schema-compatibility.d.ts +79 -165
- package/dist/schema-compatibility.d.ts.map +1 -1
- package/dist/types.d.ts +7 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/utils-test-suite.d.ts +2 -0
- package/dist/utils-test-suite.d.ts.map +1 -0
- package/dist/utils.d.ts +18 -6
- package/dist/utils.d.ts.map +1 -1
- package/dist/zod-to-json-test-suite.d.ts +6 -0
- package/dist/zod-to-json-test-suite.d.ts.map +1 -0
- package/dist/zod-to-json.cjs +12 -0
- package/dist/zod-to-json.cjs.map +1 -0
- package/dist/zod-to-json.d.ts +6 -0
- package/dist/zod-to-json.d.ts.map +1 -0
- package/dist/zod-to-json.js +3 -0
- package/dist/zod-to-json.js.map +1 -0
- package/dist/zodTypes.d.ts +21 -0
- package/dist/zodTypes.d.ts.map +1 -0
- package/package.json +36 -10
- package/.turbo/turbo-build.log +0 -4
- package/eslint.config.js +0 -6
- package/src/index.ts +0 -39
- package/src/provider-compats/anthropic.ts +0 -43
- package/src/provider-compats/deepseek.ts +0 -35
- package/src/provider-compats/google.ts +0 -62
- package/src/provider-compats/meta.ts +0 -36
- package/src/provider-compats/openai-reasoning.ts +0 -91
- package/src/provider-compats/openai.ts +0 -56
- package/src/provider-compats.test.ts +0 -383
- package/src/schema-compatibility.test.ts +0 -491
- package/src/schema-compatibility.ts +0 -592
- package/src/utils.test.ts +0 -463
- package/src/utils.ts +0 -205
- package/tsconfig.build.json +0 -9
- package/tsconfig.json +0 -5
- package/tsup.config.ts +0 -17
- package/vitest.config.ts +0 -7
|
@@ -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,eAAO,MAAM,iBAAiB,uDAAwD,CAAC;AAEvF;;;GAGG;AACH,eAAO,MAAM,gBAAgB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AK,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"}
|
|
@@ -1,156 +1,15 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type {
|
|
3
|
-
import { z, ZodOptional, ZodObject, ZodArray, ZodUnion, ZodString, ZodNumber, ZodDate, ZodDefault, ZodNull } from 'zod';
|
|
4
|
-
import type { ZodTypeAny } from 'zod';
|
|
1
|
+
import type { z as zV3 } from 'zod/v3';
|
|
2
|
+
import type { z as zV4, ZodType } from 'zod/v4';
|
|
5
3
|
import type { Targets } from 'zod-to-json-schema';
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
export declare const ALL_STRING_CHECKS: readonly ["regex", "emoji", "email", "url", "uuid", "cuid", "min", "max"];
|
|
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 ["min", "max", "multipleOf"];
|
|
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
|
-
export declare const isOptional: (v: ZodTypeAny) => v is ZodOptional<any>;
|
|
23
|
-
export declare const isObj: (v: ZodTypeAny) => v is ZodObject<any, any, any>;
|
|
24
|
-
export declare const isNull: (v: ZodTypeAny) => v is ZodNull;
|
|
25
|
-
export declare const isArr: (v: ZodTypeAny) => v is ZodArray<any, any>;
|
|
26
|
-
export declare const isUnion: (v: ZodTypeAny) => v is ZodUnion<[ZodTypeAny, ...ZodTypeAny[]]>;
|
|
27
|
-
export declare const isString: (v: ZodTypeAny) => v is ZodString;
|
|
28
|
-
export declare const isNumber: (v: ZodTypeAny) => v is ZodNumber;
|
|
29
|
-
export declare const isDate: (v: ZodTypeAny) => v is ZodDate;
|
|
30
|
-
export declare const isDefault: (v: ZodTypeAny) => v is ZodDefault<any>;
|
|
31
|
-
/**
|
|
32
|
-
* Zod types that are not supported by most AI model providers and should be avoided.
|
|
33
|
-
* @constant
|
|
34
|
-
*/
|
|
35
|
-
export declare const UNSUPPORTED_ZOD_TYPES: readonly ["ZodIntersection", "ZodNever", "ZodNull", "ZodTuple", "ZodUndefined"];
|
|
36
|
-
/**
|
|
37
|
-
* Zod types that are generally supported by AI model providers.
|
|
38
|
-
* @constant
|
|
39
|
-
*/
|
|
40
|
-
export declare const SUPPORTED_ZOD_TYPES: readonly ["ZodObject", "ZodArray", "ZodUnion", "ZodString", "ZodNumber", "ZodDate", "ZodAny", "ZodDefault"];
|
|
41
|
-
/**
|
|
42
|
-
* All Zod types (both supported and unsupported).
|
|
43
|
-
* @constant
|
|
44
|
-
*/
|
|
45
|
-
export declare const ALL_ZOD_TYPES: readonly ["ZodObject", "ZodArray", "ZodUnion", "ZodString", "ZodNumber", "ZodDate", "ZodAny", "ZodDefault", "ZodIntersection", "ZodNever", "ZodNull", "ZodTuple", "ZodUndefined"];
|
|
46
|
-
/**
|
|
47
|
-
* Type representing string validation checks.
|
|
48
|
-
*/
|
|
49
|
-
export type StringCheckType = (typeof ALL_STRING_CHECKS)[number];
|
|
50
|
-
/**
|
|
51
|
-
* Type representing number validation checks.
|
|
52
|
-
*/
|
|
53
|
-
export type NumberCheckType = (typeof ALL_NUMBER_CHECKS)[number];
|
|
54
|
-
/**
|
|
55
|
-
* Type representing array validation checks.
|
|
56
|
-
*/
|
|
57
|
-
export type ArrayCheckType = (typeof ALL_ARRAY_CHECKS)[number];
|
|
58
|
-
/**
|
|
59
|
-
* Type representing unsupported Zod schema types.
|
|
60
|
-
*/
|
|
61
|
-
export type UnsupportedZodType = (typeof UNSUPPORTED_ZOD_TYPES)[number];
|
|
62
|
-
/**
|
|
63
|
-
* Type representing supported Zod schema types.
|
|
64
|
-
*/
|
|
65
|
-
export type SupportedZodType = (typeof SUPPORTED_ZOD_TYPES)[number];
|
|
66
|
-
/**
|
|
67
|
-
* Type representing all Zod schema types (supported and unsupported).
|
|
68
|
-
*/
|
|
69
|
-
export type AllZodType = (typeof ALL_ZOD_TYPES)[number];
|
|
70
|
-
/**
|
|
71
|
-
* Utility type to extract the shape of a Zod object schema.
|
|
72
|
-
*/
|
|
73
|
-
export type ZodShape<T extends z.AnyZodObject> = T['shape'];
|
|
74
|
-
/**
|
|
75
|
-
* Utility type to extract the keys from a Zod object shape.
|
|
76
|
-
*/
|
|
77
|
-
export type ShapeKey<T extends z.AnyZodObject> = keyof ZodShape<T>;
|
|
78
|
-
/**
|
|
79
|
-
* Utility type to extract the value types from a Zod object shape.
|
|
80
|
-
*/
|
|
81
|
-
export type ShapeValue<T extends z.AnyZodObject> = ZodShape<T>[ShapeKey<T>];
|
|
82
|
-
type StringConstraints = {
|
|
83
|
-
minLength?: number;
|
|
84
|
-
maxLength?: number;
|
|
85
|
-
email?: boolean;
|
|
86
|
-
url?: boolean;
|
|
87
|
-
uuid?: boolean;
|
|
88
|
-
cuid?: boolean;
|
|
89
|
-
emoji?: boolean;
|
|
90
|
-
regex?: string;
|
|
91
|
-
};
|
|
92
|
-
type NumberConstraints = {
|
|
93
|
-
gt?: number;
|
|
94
|
-
gte?: number;
|
|
95
|
-
lt?: number;
|
|
96
|
-
lte?: number;
|
|
97
|
-
multipleOf?: number;
|
|
98
|
-
};
|
|
99
|
-
type ArrayConstraints = {
|
|
100
|
-
minLength?: number;
|
|
101
|
-
maxLength?: number;
|
|
102
|
-
exactLength?: number;
|
|
103
|
-
};
|
|
104
|
-
type DateConstraints = {
|
|
105
|
-
minDate?: string;
|
|
106
|
-
maxDate?: string;
|
|
107
|
-
dateFormat?: string;
|
|
108
|
-
};
|
|
109
|
-
export type ModelInformation = {
|
|
110
|
-
modelId: string;
|
|
111
|
-
provider: string;
|
|
112
|
-
};
|
|
113
|
-
/**
|
|
114
|
-
* Abstract base class for creating schema compatibility layers for different AI model providers.
|
|
115
|
-
*
|
|
116
|
-
* This class provides a framework for transforming Zod schemas to work with specific AI model
|
|
117
|
-
* provider requirements and limitations. Each provider may have different support levels for
|
|
118
|
-
* JSON Schema features, validation constraints, and data types.
|
|
119
|
-
*
|
|
120
|
-
* @abstract
|
|
121
|
-
*
|
|
122
|
-
* @example
|
|
123
|
-
* ```typescript
|
|
124
|
-
* import { SchemaCompatLayer } from '@mastra/schema-compat';
|
|
125
|
-
* import type { LanguageModelV1 } from 'ai';
|
|
126
|
-
*
|
|
127
|
-
* class CustomProviderCompat extends SchemaCompatLayer {
|
|
128
|
-
* constructor(model: LanguageModelV1) {
|
|
129
|
-
* super(model);
|
|
130
|
-
* }
|
|
131
|
-
*
|
|
132
|
-
* shouldApply(): boolean {
|
|
133
|
-
* return this.getModel().provider === 'custom-provider';
|
|
134
|
-
* }
|
|
135
|
-
*
|
|
136
|
-
* getSchemaTarget() {
|
|
137
|
-
* return 'jsonSchema7';
|
|
138
|
-
* }
|
|
139
|
-
*
|
|
140
|
-
* processZodType<T extends z.AnyZodObject>(value: z.ZodTypeAny): ShapeValue<T> {
|
|
141
|
-
* // Custom processing logic for this provider
|
|
142
|
-
* switch (value._def.typeName) {
|
|
143
|
-
* case 'ZodString':
|
|
144
|
-
* return this.defaultZodStringHandler(value, ['email', 'url']);
|
|
145
|
-
* default:
|
|
146
|
-
* return this.defaultUnsupportedZodTypeHandler(value);
|
|
147
|
-
* }
|
|
148
|
-
* }
|
|
149
|
-
* }
|
|
150
|
-
* ```
|
|
151
|
-
*/
|
|
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[];
|
|
152
9
|
export declare abstract class SchemaCompatLayer {
|
|
153
10
|
private model;
|
|
11
|
+
private v3Layer;
|
|
12
|
+
private v4Layer;
|
|
154
13
|
/**
|
|
155
14
|
* Creates a new schema compatibility instance.
|
|
156
15
|
*
|
|
@@ -163,6 +22,52 @@ export declare abstract class SchemaCompatLayer {
|
|
|
163
22
|
* @returns The language model instance
|
|
164
23
|
*/
|
|
165
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>;
|
|
166
71
|
/**
|
|
167
72
|
* Determines whether this compatibility layer should be applied for the current model.
|
|
168
73
|
*
|
|
@@ -184,16 +89,21 @@ export declare abstract class SchemaCompatLayer {
|
|
|
184
89
|
* @returns The processed Zod type
|
|
185
90
|
* @abstract
|
|
186
91
|
*/
|
|
187
|
-
abstract processZodType(value:
|
|
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;
|
|
188
95
|
/**
|
|
189
96
|
* Default handler for Zod object types. Recursively processes all properties in the object.
|
|
190
97
|
*
|
|
191
98
|
* @param value - The Zod object to process
|
|
192
99
|
* @returns The processed Zod object
|
|
193
100
|
*/
|
|
194
|
-
defaultZodObjectHandler(value: ZodObject<any, any
|
|
101
|
+
defaultZodObjectHandler(value: zV4.ZodObject<any, any>, options?: {
|
|
102
|
+
passthrough?: boolean;
|
|
103
|
+
}): zV4.ZodObject<any, any>;
|
|
104
|
+
defaultZodObjectHandler(value: zV3.ZodObject<any, any>, options?: {
|
|
195
105
|
passthrough?: boolean;
|
|
196
|
-
}): ZodObject<any, any
|
|
106
|
+
}): zV3.ZodObject<any, any>;
|
|
197
107
|
/**
|
|
198
108
|
* Merges validation constraints into a parameter description.
|
|
199
109
|
*
|
|
@@ -204,9 +114,7 @@ export declare abstract class SchemaCompatLayer {
|
|
|
204
114
|
* @param constraints - The validation constraints to merge
|
|
205
115
|
* @returns The updated description with constraints, or undefined if no constraints
|
|
206
116
|
*/
|
|
207
|
-
mergeParameterDescription(description: string | undefined, constraints:
|
|
208
|
-
defaultValue?: unknown;
|
|
209
|
-
}): string | undefined;
|
|
117
|
+
mergeParameterDescription(description: string | undefined, constraints: ConstraintHelperText): string | undefined;
|
|
210
118
|
/**
|
|
211
119
|
* Default handler for unsupported Zod types. Throws an error for specified unsupported types.
|
|
212
120
|
*
|
|
@@ -215,7 +123,7 @@ export declare abstract class SchemaCompatLayer {
|
|
|
215
123
|
* @returns The original value if not in the throw list
|
|
216
124
|
* @throws Error if the type is in the unsupported list
|
|
217
125
|
*/
|
|
218
|
-
defaultUnsupportedZodTypeHandler<T extends
|
|
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;
|
|
219
127
|
/**
|
|
220
128
|
* Default handler for Zod array types. Processes array constraints according to provider support.
|
|
221
129
|
*
|
|
@@ -223,7 +131,8 @@ export declare abstract class SchemaCompatLayer {
|
|
|
223
131
|
* @param handleChecks - Array constraints to convert to descriptions vs keep as validation
|
|
224
132
|
* @returns The processed Zod array
|
|
225
133
|
*/
|
|
226
|
-
defaultZodArrayHandler(value: ZodArray<any
|
|
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>;
|
|
227
136
|
/**
|
|
228
137
|
* Default handler for Zod union types. Processes all union options.
|
|
229
138
|
*
|
|
@@ -231,7 +140,8 @@ export declare abstract class SchemaCompatLayer {
|
|
|
231
140
|
* @returns The processed Zod union
|
|
232
141
|
* @throws Error if union has fewer than 2 options
|
|
233
142
|
*/
|
|
234
|
-
defaultZodUnionHandler(value: ZodUnion<[
|
|
143
|
+
defaultZodUnionHandler(value: zV4.ZodUnion<[zV4.ZodType, ...zV4.ZodType[]]>): zV4.ZodType;
|
|
144
|
+
defaultZodUnionHandler(value: zV3.ZodUnion<[zV3.ZodType, ...zV3.ZodType[]]>): zV3.ZodType;
|
|
235
145
|
/**
|
|
236
146
|
* Default handler for Zod string types. Processes string validation constraints.
|
|
237
147
|
*
|
|
@@ -239,7 +149,8 @@ export declare abstract class SchemaCompatLayer {
|
|
|
239
149
|
* @param handleChecks - String constraints to convert to descriptions vs keep as validation
|
|
240
150
|
* @returns The processed Zod string
|
|
241
151
|
*/
|
|
242
|
-
defaultZodStringHandler(value: ZodString, handleChecks?: readonly StringCheckType[]): ZodString;
|
|
152
|
+
defaultZodStringHandler(value: zV4.ZodString, handleChecks?: readonly StringCheckType[]): zV4.ZodString;
|
|
153
|
+
defaultZodStringHandler(value: zV3.ZodString, handleChecks?: readonly StringCheckType[]): zV3.ZodString;
|
|
243
154
|
/**
|
|
244
155
|
* Default handler for Zod number types. Processes number validation constraints.
|
|
245
156
|
*
|
|
@@ -247,14 +158,16 @@ export declare abstract class SchemaCompatLayer {
|
|
|
247
158
|
* @param handleChecks - Number constraints to convert to descriptions vs keep as validation
|
|
248
159
|
* @returns The processed Zod number
|
|
249
160
|
*/
|
|
250
|
-
defaultZodNumberHandler(value: ZodNumber, handleChecks?: readonly NumberCheckType[]): ZodNumber;
|
|
161
|
+
defaultZodNumberHandler(value: zV4.ZodNumber, handleChecks?: readonly NumberCheckType[]): zV4.ZodNumber;
|
|
162
|
+
defaultZodNumberHandler(value: zV3.ZodNumber, handleChecks?: readonly NumberCheckType[]): zV3.ZodNumber;
|
|
251
163
|
/**
|
|
252
164
|
* Default handler for Zod date types. Converts dates to ISO strings with constraint descriptions.
|
|
253
165
|
*
|
|
254
166
|
* @param value - The Zod date to process
|
|
255
167
|
* @returns A Zod string schema representing the date in ISO format
|
|
256
168
|
*/
|
|
257
|
-
defaultZodDateHandler(value: ZodDate): ZodString;
|
|
169
|
+
defaultZodDateHandler(value: zV4.ZodDate): zV4.ZodString;
|
|
170
|
+
defaultZodDateHandler(value: zV3.ZodDate): zV3.ZodString;
|
|
258
171
|
/**
|
|
259
172
|
* Default handler for Zod optional types. Processes the inner type and maintains optionality.
|
|
260
173
|
*
|
|
@@ -262,21 +175,22 @@ export declare abstract class SchemaCompatLayer {
|
|
|
262
175
|
* @param handleTypes - Types that should be processed vs passed through
|
|
263
176
|
* @returns The processed Zod optional
|
|
264
177
|
*/
|
|
265
|
-
defaultZodOptionalHandler(value: ZodOptional<any>, handleTypes?: readonly
|
|
178
|
+
defaultZodOptionalHandler(value: zV4.ZodOptional<any>, handleTypes?: readonly AllZodTypeV4[]): zV4.ZodType;
|
|
179
|
+
defaultZodOptionalHandler(value: zV3.ZodOptional<any>, handleTypes?: readonly AllZodTypeV3[]): zV3.ZodType;
|
|
266
180
|
/**
|
|
267
181
|
* Processes a Zod object schema and converts it to an AI SDK Schema.
|
|
268
182
|
*
|
|
269
183
|
* @param zodSchema - The Zod object schema to process
|
|
270
184
|
* @returns An AI SDK Schema with provider-specific compatibility applied
|
|
271
185
|
*/
|
|
272
|
-
processToAISDKSchema(zodSchema:
|
|
186
|
+
processToAISDKSchema(zodSchema: zV3.ZodSchema | zV4.ZodType): Schema;
|
|
273
187
|
/**
|
|
274
188
|
* Processes a Zod object schema and converts it to a JSON Schema.
|
|
275
189
|
*
|
|
276
190
|
* @param zodSchema - The Zod object schema to process
|
|
277
191
|
* @returns A JSONSchema7 object with provider-specific compatibility applied
|
|
278
192
|
*/
|
|
279
|
-
processToJSONSchema(zodSchema:
|
|
193
|
+
processToJSONSchema(zodSchema: zV3.ZodSchema | zV4.ZodType): JSONSchema7;
|
|
280
194
|
}
|
|
281
195
|
export {};
|
|
282
196
|
//# 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,
|
|
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,IAAI,Y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