@ai-sdk/provider-utils
Advanced tools
+6
-0
| # @ai-sdk/provider-utils | ||
| ## 4.0.39 | ||
| ### Patch Changes | ||
| - 06fb54c: Accept callable Standard Schema validators that do not provide JSON Schema conversion. | ||
| ## 4.0.38 | ||
@@ -4,0 +10,0 @@ |
+5
-1
@@ -310,3 +310,7 @@ import { LanguageModelV3FunctionTool, LanguageModelV3ProviderTool, ImageModelV3File, AISDKError, JSONSchema7, JSONParseError, TypeValidationError, JSONValue, APICallError, LanguageModelV3Prompt, SharedV3ProviderOptions, JSONObject, TypeValidationContext } from '@ai-sdk/provider'; | ||
| type ZodSchema<SCHEMA = any> = z3.Schema<SCHEMA, z3.ZodTypeDef, any> | z4.core.$ZodType<SCHEMA, any>; | ||
| type StandardSchema<SCHEMA = any> = StandardSchemaV1<unknown, SCHEMA> & StandardJSONSchemaV1<unknown, SCHEMA>; | ||
| type StandardSchema<SCHEMA = any> = StandardSchemaV1<unknown, SCHEMA> & { | ||
| readonly '~standard': StandardSchemaV1.Props<unknown, SCHEMA> & { | ||
| readonly jsonSchema?: StandardJSONSchemaV1.Converter; | ||
| }; | ||
| }; | ||
| type FlexibleSchema<SCHEMA = any> = Schema<SCHEMA> | LazySchema<SCHEMA> | ZodSchema<SCHEMA> | StandardSchema<SCHEMA>; | ||
@@ -313,0 +317,0 @@ type InferSchema<SCHEMA> = SCHEMA extends ZodSchema<infer T> ? T : SCHEMA extends StandardSchema<infer T> ? T : SCHEMA extends LazySchema<infer T> ? T : SCHEMA extends Schema<infer T> ? T : never; |
+5
-1
@@ -310,3 +310,7 @@ import { LanguageModelV3FunctionTool, LanguageModelV3ProviderTool, ImageModelV3File, AISDKError, JSONSchema7, JSONParseError, TypeValidationError, JSONValue, APICallError, LanguageModelV3Prompt, SharedV3ProviderOptions, JSONObject, TypeValidationContext } from '@ai-sdk/provider'; | ||
| type ZodSchema<SCHEMA = any> = z3.Schema<SCHEMA, z3.ZodTypeDef, any> | z4.core.$ZodType<SCHEMA, any>; | ||
| type StandardSchema<SCHEMA = any> = StandardSchemaV1<unknown, SCHEMA> & StandardJSONSchemaV1<unknown, SCHEMA>; | ||
| type StandardSchema<SCHEMA = any> = StandardSchemaV1<unknown, SCHEMA> & { | ||
| readonly '~standard': StandardSchemaV1.Props<unknown, SCHEMA> & { | ||
| readonly jsonSchema?: StandardJSONSchemaV1.Converter; | ||
| }; | ||
| }; | ||
| type FlexibleSchema<SCHEMA = any> = Schema<SCHEMA> | LazySchema<SCHEMA> | ZodSchema<SCHEMA> | StandardSchema<SCHEMA>; | ||
@@ -313,0 +317,0 @@ type InferSchema<SCHEMA> = SCHEMA extends ZodSchema<infer T> ? T : SCHEMA extends StandardSchema<infer T> ? T : SCHEMA extends LazySchema<infer T> ? T : SCHEMA extends Schema<infer T> ? T : never; |
+1
-1
| { | ||
| "name": "@ai-sdk/provider-utils", | ||
| "version": "4.0.38", | ||
| "version": "4.0.39", | ||
| "license": "Apache-2.0", | ||
@@ -5,0 +5,0 @@ "sideEffects": false, |
+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
Sorry, the diff of this file is too big to display
953409
0.35%13004
0.31%