@ai-sdk/provider-utils
Advanced tools
+6
-0
| # @ai-sdk/provider-utils | ||
| ## 5.0.10 | ||
| ### Patch Changes | ||
| - 31c7be8: Accept callable Standard Schema validators that do not provide JSON Schema conversion. | ||
| ## 5.0.9 | ||
@@ -4,0 +10,0 @@ |
+1
-1
| { | ||
| "name": "@ai-sdk/provider-utils", | ||
| "version": "5.0.9", | ||
| "version": "5.0.10", | ||
| "type": "module", | ||
@@ -5,0 +5,0 @@ "license": "Apache-2.0", |
+23
-4
@@ -72,3 +72,9 @@ import { TypeValidationError, type JSONSchema7 } from '@ai-sdk/provider'; | ||
| export type StandardSchema<SCHEMA = any> = StandardSchemaV1<unknown, SCHEMA> & | ||
| export type StandardSchema<SCHEMA = any> = StandardSchemaV1<unknown, SCHEMA> & { | ||
| readonly '~standard': StandardSchemaV1.Props<unknown, SCHEMA> & { | ||
| readonly jsonSchema?: StandardJSONSchemaV1.Converter; | ||
| }; | ||
| }; | ||
| type StandardSchemaWithJsonSchema<SCHEMA = any> = StandardSchema<SCHEMA> & | ||
| StandardJSONSchemaV1<unknown, SCHEMA>; | ||
@@ -158,8 +164,15 @@ | ||
| return jsonSchema( | ||
| () => | ||
| addAdditionalPropertiesToJsonSchema( | ||
| () => { | ||
| if (!hasStandardJsonSchema(standardSchema)) { | ||
| throw new Error( | ||
| `Standard schema vendor '${standardSchema['~standard'].vendor}' does not support JSON Schema conversion.`, | ||
| ); | ||
| } | ||
| return addAdditionalPropertiesToJsonSchema( | ||
| standardSchema['~standard'].jsonSchema.input({ | ||
| target: 'draft-07', | ||
| }) as JSONSchema7, | ||
| ), | ||
| ); | ||
| }, | ||
| { | ||
@@ -182,2 +195,8 @@ validate: async value => { | ||
| function hasStandardJsonSchema<OBJECT>( | ||
| schema: StandardSchema<OBJECT>, | ||
| ): schema is StandardSchemaWithJsonSchema<OBJECT> { | ||
| return schema['~standard'].jsonSchema != null; | ||
| } | ||
| export function zod3Schema<OBJECT>( | ||
@@ -184,0 +203,0 @@ zodSchema: z3.Schema<OBJECT, z3.ZodTypeDef, any>, |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
847419
0.24%14357
0.21%