@mastra/schema-compat 1.3.16 → 1.3.17
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/dist/_types/@internal_ai-sdk-v5/dist/index.d.ts +65 -13
- package/dist/_types/@internal_ai-v6/dist/index.d.ts +110 -35
- package/dist/{esm-DA8owk0L.js → esm-BG70JlG8.js} +39 -77
- package/dist/{esm-DA8owk0L.js.map → esm-BG70JlG8.js.map} +1 -1
- package/dist/{esm-zrVJTTxY.cjs → esm-BQeGF7AD.cjs} +39 -77
- package/dist/{esm-zrVJTTxY.cjs.map → esm-BQeGF7AD.cjs.map} +1 -1
- package/dist/index.cjs +66 -83
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +66 -83
- package/dist/index.js.map +1 -1
- package/dist/{json-schema-Dh7B27IP.cjs → json-schema-7oyknwMS.cjs} +189 -204
- package/dist/json-schema-7oyknwMS.cjs.map +1 -0
- package/dist/{json-schema-DcMkkbbI.js → json-schema-BdCwqjfN.js} +189 -204
- package/dist/json-schema-BdCwqjfN.js.map +1 -0
- package/dist/{json-schema-traverse-Jrimn_T_.js → json-schema-traverse-D0CId4oM.js} +3 -5
- package/dist/{json-schema-traverse-Jrimn_T_.js.map → json-schema-traverse-D0CId4oM.js.map} +1 -1
- package/dist/{json-schema-traverse-CKLDTw5l.cjs → json-schema-traverse-evfp8uQX.cjs} +3 -5
- package/dist/{json-schema-traverse-CKLDTw5l.cjs.map → json-schema-traverse-evfp8uQX.cjs.map} +1 -1
- package/dist/json-to-zod.cjs +70 -71
- package/dist/json-to-zod.cjs.map +1 -1
- package/dist/json-to-zod.d.ts.map +1 -1
- package/dist/json-to-zod.js +70 -71
- package/dist/json-to-zod.js.map +1 -1
- package/dist/provider-compats/anthropic.d.ts.map +1 -1
- package/dist/{schema-CzbEIyhE.js → schema-Bf12g7KC.js} +4 -6
- package/dist/{schema-CzbEIyhE.js.map → schema-Bf12g7KC.js.map} +1 -1
- package/dist/{schema-BXSe2bgB.cjs → schema-D2ab1-Dc.cjs} +5 -7
- package/dist/{schema-BXSe2bgB.cjs.map → schema-D2ab1-Dc.cjs.map} +1 -1
- package/dist/schema-compatibility-v3.d.ts.map +1 -1
- package/dist/schema-compatibility-v4.d.ts.map +1 -1
- package/dist/schema-compatibility.d.ts.map +1 -1
- package/dist/schema.cjs +1 -1
- package/dist/schema.js +1 -1
- package/dist/standard-schema/adapters/ai-sdk.cjs +1 -2
- package/dist/standard-schema/adapters/ai-sdk.js +1 -2
- package/dist/standard-schema/adapters/json-schema.cjs +1 -1
- package/dist/standard-schema/adapters/json-schema.js +1 -1
- package/dist/standard-schema/adapters/zod-v3.cjs +3 -4
- package/dist/standard-schema/adapters/zod-v3.cjs.map +1 -1
- package/dist/standard-schema/adapters/zod-v3.js +3 -4
- package/dist/standard-schema/adapters/zod-v3.js.map +1 -1
- package/dist/utils.d.ts.map +1 -1
- package/dist/zod-to-json.cjs +4 -4
- package/dist/zod-to-json.cjs.map +1 -1
- package/dist/zod-to-json.d.ts.map +1 -1
- package/dist/zod-to-json.js +4 -4
- package/dist/zod-to-json.js.map +1 -1
- package/package.json +21 -21
- package/dist/json-schema-DcMkkbbI.js.map +0 -1
- package/dist/json-schema-Dh7B27IP.cjs.map +0 -1
package/dist/index.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { r as __toESM$1, t as require_json_schema_traverse } from "./json-schema-traverse-
|
|
1
|
+
import { r as __toESM$1, t as require_json_schema_traverse } from "./json-schema-traverse-D0CId4oM.js";
|
|
2
2
|
import { ensureAllPropertiesRequired, prepareJsonSchemaForOpenAIStrictMode, zodToJsonSchema as zodToJsonSchema$1 } from "./zod-to-json.js";
|
|
3
|
-
import { a as standardSchemaToJSONSchema, i as isStandardSchemaWithJSON, n as isStandardJSONSchema, o as toStandardSchema, r as isStandardSchema, t as JSON_SCHEMA_LIBRARY_OPTIONS } from "./schema-
|
|
3
|
+
import { a as standardSchemaToJSONSchema, i as isStandardSchemaWithJSON, n as isStandardJSONSchema, o as toStandardSchema, r as isStandardSchema, t as JSON_SCHEMA_LIBRARY_OPTIONS } from "./schema-Bf12g7KC.js";
|
|
4
4
|
import { ZodArray, ZodDate, ZodDefault, ZodFirstPartyTypeKind, ZodIntersection, ZodNull, ZodNullable, ZodNumber, ZodObject, ZodOptional, ZodString, ZodUnion, z } from "zod/v3";
|
|
5
5
|
import { z as z$1 } from "zod";
|
|
6
6
|
import { convertJsonSchemaToZod } from "zod-from-json-schema";
|
|
7
7
|
import { ZodArray as ZodArray$1, ZodDate as ZodDate$1, ZodDefault as ZodDefault$1, ZodIntersection as ZodIntersection$1, ZodNull as ZodNull$1, ZodNullable as ZodNullable$1, ZodNumber as ZodNumber$1, ZodObject as ZodObject$1, ZodOptional as ZodOptional$1, ZodString as ZodString$1, ZodUnion as ZodUnion$1, z as z$2 } from "zod/v4";
|
|
8
|
-
|
|
8
|
+
// ../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@/zod-from-json-schema/0.0.5/8e273a13436172e49bb0898e3f9caf0fd3966851d12111764522ea958a085aeb/node_modules/zod-from-json-schema/dist/index.mjs
|
|
9
9
|
function convertJsonSchemaToZod$1(schema) {
|
|
10
10
|
function addMetadata(zodSchema, jsonSchema) {
|
|
11
11
|
if (jsonSchema.description) zodSchema = zodSchema.describe(jsonSchema.description);
|
|
@@ -135,8 +135,7 @@ function convertJsonSchemaToZod$1(schema) {
|
|
|
135
135
|
}
|
|
136
136
|
return addMetadata(z$1.any(), schema);
|
|
137
137
|
}
|
|
138
|
-
|
|
139
|
-
//#region ../_vendored/ai_v4/dist/dist-Cm5DZgxA.js
|
|
138
|
+
// ../_vendored/ai_v4/dist/dist-DlRWVOEI.js
|
|
140
139
|
var marker$1 = "vercel.ai.error";
|
|
141
140
|
var symbol$1 = Symbol.for(marker$1);
|
|
142
141
|
var _a$1;
|
|
@@ -252,8 +251,7 @@ Error message: ${getErrorMessage(cause)}`,
|
|
|
252
251
|
};
|
|
253
252
|
_a13$1 = symbol13$1;
|
|
254
253
|
var TypeValidationError = _TypeValidationError;
|
|
255
|
-
|
|
256
|
-
//#region ../_vendored/ai_v4/dist/index.js
|
|
254
|
+
// ../_vendored/ai_v4/dist/index.js
|
|
257
255
|
var __create = Object.create;
|
|
258
256
|
var __defProp$1 = Object.defineProperty;
|
|
259
257
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
@@ -3361,8 +3359,7 @@ function trimStartOfStream() {
|
|
|
3361
3359
|
return text2;
|
|
3362
3360
|
};
|
|
3363
3361
|
}
|
|
3364
|
-
|
|
3365
|
-
//#region src/utils.ts
|
|
3362
|
+
// src/utils.ts
|
|
3366
3363
|
/**
|
|
3367
3364
|
* Converts a Zod schema to an AI SDK Schema with validation support.
|
|
3368
3365
|
*
|
|
@@ -3435,16 +3432,14 @@ function isZodType(value) {
|
|
|
3435
3432
|
*/
|
|
3436
3433
|
function convertSchemaToZod(schema) {
|
|
3437
3434
|
if (isZodType(schema)) return schema;
|
|
3438
|
-
|
|
3439
|
-
|
|
3440
|
-
|
|
3441
|
-
|
|
3442
|
-
|
|
3443
|
-
|
|
3444
|
-
|
|
3445
|
-
|
|
3446
|
-
throw new Error(errorMessage + (e instanceof Error ? `\n${e.stack}` : "\nUnknown error object"));
|
|
3447
|
-
}
|
|
3435
|
+
const jsonSchemaToConvert = "jsonSchema" in schema ? schema.jsonSchema : schema;
|
|
3436
|
+
try {
|
|
3437
|
+
if ("toJSONSchema" in z$1) return convertJsonSchemaToZod(jsonSchemaToConvert);
|
|
3438
|
+
return convertJsonSchemaToZod$1(jsonSchemaToConvert);
|
|
3439
|
+
} catch (e) {
|
|
3440
|
+
const errorMessage = `[Schema Builder] Failed to convert schema parameters to Zod. Original schema: ${JSON.stringify(jsonSchemaToConvert)}`;
|
|
3441
|
+
console.error(errorMessage, e);
|
|
3442
|
+
throw new Error(errorMessage + (e instanceof Error ? `\n${e.stack}` : "\nUnknown error object"));
|
|
3448
3443
|
}
|
|
3449
3444
|
}
|
|
3450
3445
|
/**
|
|
@@ -3490,19 +3485,17 @@ function applyCompatLayer({ schema, compatLayers, mode }) {
|
|
|
3490
3485
|
return standardSchemaToJSONSchema(compatSchema);
|
|
3491
3486
|
}
|
|
3492
3487
|
return standardSchemaToJSONSchema(standardSchema);
|
|
3493
|
-
} else {
|
|
3494
|
-
let zodSchema;
|
|
3495
|
-
if (isZodType(schema)) zodSchema = schema;
|
|
3496
|
-
else {
|
|
3497
|
-
if (isStandardSchemaWithJSON(schema)) throw new Error("StandardSchemaWithJSON is not supported for applyCompatLayer and aiSdkSchema mode");
|
|
3498
|
-
zodSchema = convertSchemaToZod(schema);
|
|
3499
|
-
}
|
|
3500
|
-
for (const compat of compatLayers) if (compat.shouldApply()) return compat.processToAISDKSchema(zodSchema);
|
|
3501
|
-
return convertZodSchemaToAISDKSchema(zodSchema);
|
|
3502
3488
|
}
|
|
3489
|
+
let zodSchema;
|
|
3490
|
+
if (isZodType(schema)) zodSchema = schema;
|
|
3491
|
+
else {
|
|
3492
|
+
if (isStandardSchemaWithJSON(schema)) throw new Error("StandardSchemaWithJSON is not supported for applyCompatLayer and aiSdkSchema mode");
|
|
3493
|
+
zodSchema = convertSchemaToZod(schema);
|
|
3494
|
+
}
|
|
3495
|
+
for (const compat of compatLayers) if (compat.shouldApply()) return compat.processToAISDKSchema(zodSchema);
|
|
3496
|
+
return convertZodSchemaToAISDKSchema(zodSchema);
|
|
3503
3497
|
}
|
|
3504
|
-
|
|
3505
|
-
//#region src/schema-compatibility-v3.ts
|
|
3498
|
+
// src/schema-compatibility-v3.ts
|
|
3506
3499
|
/**
|
|
3507
3500
|
* All supported string validation check types that can be processed or converted to descriptions.
|
|
3508
3501
|
* @constant
|
|
@@ -3757,7 +3750,7 @@ var SchemaCompatLayer$1 = class {
|
|
|
3757
3750
|
*/
|
|
3758
3751
|
mergeParameterDescription(description, constraints) {
|
|
3759
3752
|
if (constraints.length > 0) return (description ? description + "\n" : "") + `constraints: ${constraints.join(`, `)}`;
|
|
3760
|
-
|
|
3753
|
+
return description;
|
|
3761
3754
|
}
|
|
3762
3755
|
/**
|
|
3763
3756
|
* Default handler for unsupported Zod types. Throws an error for specified unsupported types.
|
|
@@ -3922,7 +3915,7 @@ var SchemaCompatLayer$1 = class {
|
|
|
3922
3915
|
*/
|
|
3923
3916
|
defaultZodOptionalHandler(value, handleTypes = SUPPORTED_ZOD_TYPES) {
|
|
3924
3917
|
if (handleTypes.includes(value._def.innerType._def.typeName)) return this.processZodType(value._def.innerType).optional();
|
|
3925
|
-
|
|
3918
|
+
return value;
|
|
3926
3919
|
}
|
|
3927
3920
|
/**
|
|
3928
3921
|
* Default handler for Zod nullable types. Processes the inner type and maintains nullability.
|
|
@@ -3933,7 +3926,7 @@ var SchemaCompatLayer$1 = class {
|
|
|
3933
3926
|
*/
|
|
3934
3927
|
defaultZodNullableHandler(value, handleTypes = SUPPORTED_ZOD_TYPES) {
|
|
3935
3928
|
if (handleTypes.includes(value._def.innerType._def.typeName)) return this.processZodType(value._def.innerType).nullable();
|
|
3936
|
-
|
|
3929
|
+
return value;
|
|
3937
3930
|
}
|
|
3938
3931
|
/**
|
|
3939
3932
|
* Recursively collects leaf types from a ZodIntersection tree.
|
|
@@ -3977,8 +3970,7 @@ var SchemaCompatLayer$1 = class {
|
|
|
3977
3970
|
return this.processToAISDKSchema(zodSchema).jsonSchema;
|
|
3978
3971
|
}
|
|
3979
3972
|
};
|
|
3980
|
-
|
|
3981
|
-
//#region src/schema-compatibility-v4.ts
|
|
3973
|
+
// src/schema-compatibility-v4.ts
|
|
3982
3974
|
/**
|
|
3983
3975
|
* All supported string validation check types that can be processed or converted to descriptions.
|
|
3984
3976
|
* @constant
|
|
@@ -4235,7 +4227,7 @@ var SchemaCompatLayer$2 = class {
|
|
|
4235
4227
|
*/
|
|
4236
4228
|
mergeParameterDescription(description, constraints) {
|
|
4237
4229
|
if (constraints.length > 0) return (description ? description + "\n" : "") + `constraints: ${constraints.join(`, `)}`;
|
|
4238
|
-
|
|
4230
|
+
return description;
|
|
4239
4231
|
}
|
|
4240
4232
|
/**
|
|
4241
4233
|
* Default handler for unsupported Zod types. Throws an error for specified unsupported types.
|
|
@@ -4409,7 +4401,7 @@ var SchemaCompatLayer$2 = class {
|
|
|
4409
4401
|
defaultZodOptionalHandler(value, handleTypes = SUPPORTED_ZOD_TYPES$2) {
|
|
4410
4402
|
const innerType = value._zod?.def?.innerType;
|
|
4411
4403
|
if (innerType && handleTypes.includes(zodV4TypeName(innerType))) return this.processZodType(innerType).optional();
|
|
4412
|
-
|
|
4404
|
+
return value;
|
|
4413
4405
|
}
|
|
4414
4406
|
/**
|
|
4415
4407
|
* Default handler for Zod nullable types. Processes the inner type and maintains nullability.
|
|
@@ -4421,7 +4413,7 @@ var SchemaCompatLayer$2 = class {
|
|
|
4421
4413
|
defaultZodNullableHandler(value, handleTypes = SUPPORTED_ZOD_TYPES$2) {
|
|
4422
4414
|
const innerType = value._zod?.def?.innerType;
|
|
4423
4415
|
if (innerType && handleTypes.includes(zodV4TypeName(innerType))) return this.processZodType(innerType).nullable();
|
|
4424
|
-
|
|
4416
|
+
return value;
|
|
4425
4417
|
}
|
|
4426
4418
|
/**
|
|
4427
4419
|
* Recursively collects leaf types from a ZodIntersection tree.
|
|
@@ -4468,8 +4460,7 @@ var SchemaCompatLayer$2 = class {
|
|
|
4468
4460
|
return this.processToAISDKSchema(zodSchema).jsonSchema;
|
|
4469
4461
|
}
|
|
4470
4462
|
};
|
|
4471
|
-
|
|
4472
|
-
//#region src/json-schema/utils.ts
|
|
4463
|
+
// src/json-schema/utils.ts
|
|
4473
4464
|
var import_json_schema_traverse = /* @__PURE__ */ __toESM$1(require_json_schema_traverse(), 1);
|
|
4474
4465
|
/**
|
|
4475
4466
|
* Type guard to check if a JSON Schema has a specific type
|
|
@@ -4537,8 +4528,7 @@ function isOptionalSchema(propertyName, parentSchema) {
|
|
|
4537
4528
|
if (!parentSchema.required || !Array.isArray(parentSchema.required)) return true;
|
|
4538
4529
|
return !parentSchema.required.includes(propertyName);
|
|
4539
4530
|
}
|
|
4540
|
-
|
|
4541
|
-
//#region src/schema-compatibility.ts
|
|
4531
|
+
// src/schema-compatibility.ts
|
|
4542
4532
|
var SchemaCompatLayer = class {
|
|
4543
4533
|
model;
|
|
4544
4534
|
v3Layer;
|
|
@@ -4565,82 +4555,82 @@ var SchemaCompatLayer = class {
|
|
|
4565
4555
|
}
|
|
4566
4556
|
getUnsupportedZodTypes(value) {
|
|
4567
4557
|
if ("_zod" in value) return this.v4Layer.getUnsupportedZodTypes();
|
|
4568
|
-
|
|
4558
|
+
return this.v3Layer.getUnsupportedZodTypes();
|
|
4569
4559
|
}
|
|
4570
4560
|
isOptional(v) {
|
|
4571
4561
|
if ("_zod" in v) return this.v4Layer.isOptional(v);
|
|
4572
|
-
|
|
4562
|
+
return this.v3Layer.isOptional(v);
|
|
4573
4563
|
}
|
|
4574
4564
|
isObj(v) {
|
|
4575
4565
|
if ("_zod" in v) return this.v4Layer.isObj(v);
|
|
4576
|
-
|
|
4566
|
+
return this.v3Layer.isObj(v);
|
|
4577
4567
|
}
|
|
4578
4568
|
isNull(v) {
|
|
4579
4569
|
if ("_zod" in v) return this.v4Layer.isNull(v);
|
|
4580
|
-
|
|
4570
|
+
return this.v3Layer.isNull(v);
|
|
4581
4571
|
}
|
|
4582
4572
|
isNullable(v) {
|
|
4583
4573
|
if ("_zod" in v) return this.v4Layer.isNullable(v);
|
|
4584
|
-
|
|
4574
|
+
return this.v3Layer.isNullable(v);
|
|
4585
4575
|
}
|
|
4586
4576
|
isArr(v) {
|
|
4587
4577
|
if ("_zod" in v) return this.v4Layer.isArr(v);
|
|
4588
|
-
|
|
4578
|
+
return this.v3Layer.isArr(v);
|
|
4589
4579
|
}
|
|
4590
4580
|
isUnion(v) {
|
|
4591
4581
|
if ("_zod" in v) return this.v4Layer.isUnion(v);
|
|
4592
|
-
|
|
4582
|
+
return this.v3Layer.isUnion(v);
|
|
4593
4583
|
}
|
|
4594
4584
|
isString(v) {
|
|
4595
4585
|
if ("_zod" in v) return this.v4Layer.isString(v);
|
|
4596
|
-
|
|
4586
|
+
return this.v3Layer.isString(v);
|
|
4597
4587
|
}
|
|
4598
4588
|
isNumber(v) {
|
|
4599
4589
|
if ("_zod" in v) return this.v4Layer.isNumber(v);
|
|
4600
|
-
|
|
4590
|
+
return this.v3Layer.isNumber(v);
|
|
4601
4591
|
}
|
|
4602
4592
|
isDate(v) {
|
|
4603
4593
|
if ("_zod" in v) return this.v4Layer.isDate(v);
|
|
4604
|
-
|
|
4594
|
+
return this.v3Layer.isDate(v);
|
|
4605
4595
|
}
|
|
4606
4596
|
isDefault(v) {
|
|
4607
4597
|
if ("_zod" in v) return this.v4Layer.isDefault(v);
|
|
4608
|
-
|
|
4598
|
+
return this.v3Layer.isDefault(v);
|
|
4609
4599
|
}
|
|
4610
4600
|
isIntersection(v) {
|
|
4611
4601
|
if ("_zod" in v) return this.v4Layer.isIntersection(v);
|
|
4612
|
-
|
|
4602
|
+
return this.v3Layer.isIntersection(v);
|
|
4613
4603
|
}
|
|
4614
4604
|
defaultZodObjectHandler(value, options = { passthrough: true }) {
|
|
4615
4605
|
if ("_zod" in value) return this.v4Layer.defaultZodObjectHandler(value, options);
|
|
4616
|
-
|
|
4606
|
+
return this.v3Layer.defaultZodObjectHandler(value, options);
|
|
4617
4607
|
}
|
|
4618
4608
|
mergeParameterDescription(description, constraints) {
|
|
4619
4609
|
return this.v3Layer.mergeParameterDescription(description, constraints);
|
|
4620
4610
|
}
|
|
4621
4611
|
defaultUnsupportedZodTypeHandler(value, throwOnTypes) {
|
|
4622
4612
|
if ("_zod" in value) return this.v4Layer.defaultUnsupportedZodTypeHandler(value, throwOnTypes ?? UNSUPPORTED_ZOD_TYPES$2);
|
|
4623
|
-
|
|
4613
|
+
return this.v3Layer.defaultUnsupportedZodTypeHandler(value, throwOnTypes ?? UNSUPPORTED_ZOD_TYPES);
|
|
4624
4614
|
}
|
|
4625
4615
|
defaultZodArrayHandler(value, handleChecks = ALL_ARRAY_CHECKS) {
|
|
4626
4616
|
if ("_zod" in value) return this.v4Layer.defaultZodArrayHandler(value, handleChecks);
|
|
4627
|
-
|
|
4617
|
+
return this.v3Layer.defaultZodArrayHandler(value, handleChecks);
|
|
4628
4618
|
}
|
|
4629
4619
|
defaultZodUnionHandler(value) {
|
|
4630
4620
|
if ("_zod" in value) return this.v4Layer.defaultZodUnionHandler(value);
|
|
4631
|
-
|
|
4621
|
+
return this.v3Layer.defaultZodUnionHandler(value);
|
|
4632
4622
|
}
|
|
4633
4623
|
defaultZodStringHandler(value, handleChecks = ALL_STRING_CHECKS) {
|
|
4634
4624
|
if ("_zod" in value) return this.v4Layer.defaultZodStringHandler(value);
|
|
4635
|
-
|
|
4625
|
+
return this.v3Layer.defaultZodStringHandler(value, handleChecks);
|
|
4636
4626
|
}
|
|
4637
4627
|
defaultZodNumberHandler(value, handleChecks = ALL_NUMBER_CHECKS) {
|
|
4638
4628
|
if ("_zod" in value) return this.v4Layer.defaultZodNumberHandler(value);
|
|
4639
|
-
|
|
4629
|
+
return this.v3Layer.defaultZodNumberHandler(value, handleChecks);
|
|
4640
4630
|
}
|
|
4641
4631
|
defaultZodDateHandler(value) {
|
|
4642
4632
|
if ("_zod" in value) return this.v4Layer.defaultZodDateHandler(value);
|
|
4643
|
-
|
|
4633
|
+
return this.v3Layer.defaultZodDateHandler(value);
|
|
4644
4634
|
}
|
|
4645
4635
|
defaultZodOptionalHandler(value, handleTypes) {
|
|
4646
4636
|
if (!handleTypes) handleTypes = [
|
|
@@ -4661,16 +4651,18 @@ var SchemaCompatLayer = class {
|
|
|
4661
4651
|
const innerType = value._zod?.def?.innerType;
|
|
4662
4652
|
if (!innerType) return value;
|
|
4663
4653
|
return this.processZodType(innerType).optional();
|
|
4664
|
-
}
|
|
4665
|
-
|
|
4654
|
+
}
|
|
4655
|
+
return this.processZodType(value._def.innerType).optional();
|
|
4656
|
+
}
|
|
4657
|
+
return value;
|
|
4666
4658
|
}
|
|
4667
4659
|
defaultZodNullableHandler(value, handleTypes) {
|
|
4668
4660
|
if ("_zod" in value) return this.v4Layer.defaultZodNullableHandler(value, handleTypes ?? SUPPORTED_ZOD_TYPES$2);
|
|
4669
|
-
|
|
4661
|
+
return this.v3Layer.defaultZodNullableHandler(value, handleTypes ?? SUPPORTED_ZOD_TYPES);
|
|
4670
4662
|
}
|
|
4671
4663
|
defaultZodIntersectionHandler(value) {
|
|
4672
4664
|
if ("_zod" in value) return this.v4Layer.defaultZodIntersectionHandler(value);
|
|
4673
|
-
|
|
4665
|
+
return this.v3Layer.defaultZodIntersectionHandler(value);
|
|
4674
4666
|
}
|
|
4675
4667
|
/**
|
|
4676
4668
|
* @deprecated please use processToCompatSchema to usse StandardSchemaWithJSON
|
|
@@ -4944,8 +4936,7 @@ var SchemaCompatLayer = class {
|
|
|
4944
4936
|
return jsonSchema;
|
|
4945
4937
|
}
|
|
4946
4938
|
};
|
|
4947
|
-
|
|
4948
|
-
//#region src/null-to-undefined.ts
|
|
4939
|
+
// src/null-to-undefined.ts
|
|
4949
4940
|
/**
|
|
4950
4941
|
* Recursively converts null values to undefined in an object based on which
|
|
4951
4942
|
* properties are optional in the JSON Schema. This is needed because OpenAI
|
|
@@ -5091,8 +5082,7 @@ function isNullable(z) {
|
|
|
5091
5082
|
function isIntersection(z) {
|
|
5092
5083
|
return (v) => v instanceof z["ZodIntersection"];
|
|
5093
5084
|
}
|
|
5094
|
-
|
|
5095
|
-
//#region src/provider-compats/openai.ts
|
|
5085
|
+
// src/provider-compats/openai.ts
|
|
5096
5086
|
const allowedStringFormats = [
|
|
5097
5087
|
"date-time",
|
|
5098
5088
|
"time",
|
|
@@ -5447,8 +5437,7 @@ var OpenAISchemaCompatLayer = class extends SchemaCompatLayer {
|
|
|
5447
5437
|
function isDateFormat(schema) {
|
|
5448
5438
|
return schema.format === "date-time" || schema.format === "date";
|
|
5449
5439
|
}
|
|
5450
|
-
|
|
5451
|
-
//#region src/provider-compats/openai-reasoning.ts
|
|
5440
|
+
// src/provider-compats/openai-reasoning.ts
|
|
5452
5441
|
var OpenAIReasoningSchemaCompatLayer = class extends OpenAISchemaCompatLayer {
|
|
5453
5442
|
getSchemaTarget() {
|
|
5454
5443
|
return `openApi3`;
|
|
@@ -5496,8 +5485,7 @@ var OpenAIReasoningSchemaCompatLayer = class extends OpenAISchemaCompatLayer {
|
|
|
5496
5485
|
return this.defaultUnsupportedZodTypeHandler(value);
|
|
5497
5486
|
}
|
|
5498
5487
|
};
|
|
5499
|
-
|
|
5500
|
-
//#region src/standard-schema-compat.ts
|
|
5488
|
+
// src/standard-schema-compat.ts
|
|
5501
5489
|
/**
|
|
5502
5490
|
* Standard Schema compatibility utilities
|
|
5503
5491
|
*
|
|
@@ -5592,8 +5580,7 @@ function applyOpenAICompatToTools(tools, modelInfo) {
|
|
|
5592
5580
|
} else transformedTools[name] = tool;
|
|
5593
5581
|
return transformedTools;
|
|
5594
5582
|
}
|
|
5595
|
-
|
|
5596
|
-
//#region src/provider-compats/anthropic.ts
|
|
5583
|
+
// src/provider-compats/anthropic.ts
|
|
5597
5584
|
var AnthropicSchemaCompatLayer = class extends SchemaCompatLayer {
|
|
5598
5585
|
constructor(model) {
|
|
5599
5586
|
super(model);
|
|
@@ -5640,7 +5627,7 @@ var AnthropicSchemaCompatLayer = class extends SchemaCompatLayer {
|
|
|
5640
5627
|
else if (this.isUnion(value)) return this.defaultZodUnionHandler(value);
|
|
5641
5628
|
else if (this.isString(value)) {
|
|
5642
5629
|
if (this.getModel().modelId.includes("claude-3.5-haiku")) return this.defaultZodStringHandler(value, ["max", "min"]);
|
|
5643
|
-
|
|
5630
|
+
return value;
|
|
5644
5631
|
} else if (isNull(z$1)(value)) return z$1.any().refine((v) => v === null, { message: "must be null" }).describe(value.description || "must be null");
|
|
5645
5632
|
else if (isIntersection(z$1)(value)) return this.defaultZodIntersectionHandler(value);
|
|
5646
5633
|
return this.defaultUnsupportedZodTypeHandler(value);
|
|
@@ -5948,8 +5935,7 @@ var AnthropicSchemaCompatLayer = class extends SchemaCompatLayer {
|
|
|
5948
5935
|
}) ?? schema;
|
|
5949
5936
|
}
|
|
5950
5937
|
};
|
|
5951
|
-
|
|
5952
|
-
//#region src/provider-compats/deepseek.ts
|
|
5938
|
+
// src/provider-compats/deepseek.ts
|
|
5953
5939
|
var DeepSeekSchemaCompatLayer = class extends SchemaCompatLayer {
|
|
5954
5940
|
constructor(model) {
|
|
5955
5941
|
super(model);
|
|
@@ -6042,8 +6028,7 @@ var DeepSeekSchemaCompatLayer = class extends SchemaCompatLayer {
|
|
|
6042
6028
|
return schema;
|
|
6043
6029
|
}
|
|
6044
6030
|
};
|
|
6045
|
-
|
|
6046
|
-
//#region src/provider-compats/google.ts
|
|
6031
|
+
// src/provider-compats/google.ts
|
|
6047
6032
|
function fixAISDKNullableUnionTypes(schema) {
|
|
6048
6033
|
if (typeof schema !== "object" || schema === null) return schema;
|
|
6049
6034
|
const result = { ...schema };
|
|
@@ -6302,8 +6287,7 @@ var GoogleSchemaCompatLayer = class extends SchemaCompatLayer {
|
|
|
6302
6287
|
return schema;
|
|
6303
6288
|
}
|
|
6304
6289
|
};
|
|
6305
|
-
|
|
6306
|
-
//#region src/provider-compats/meta.ts
|
|
6290
|
+
// src/provider-compats/meta.ts
|
|
6307
6291
|
var MetaSchemaCompatLayer = class extends SchemaCompatLayer {
|
|
6308
6292
|
constructor(model) {
|
|
6309
6293
|
super(model);
|
|
@@ -6397,7 +6381,6 @@ var MetaSchemaCompatLayer = class extends SchemaCompatLayer {
|
|
|
6397
6381
|
return schema;
|
|
6398
6382
|
}
|
|
6399
6383
|
};
|
|
6400
|
-
//#endregion
|
|
6401
6384
|
export { ALL_ARRAY_CHECKS, ALL_NUMBER_CHECKS, ALL_STRING_CHECKS, ALL_ZOD_TYPES, AnthropicSchemaCompatLayer, DeepSeekSchemaCompatLayer, GoogleSchemaCompatLayer, JSON_SCHEMA_LIBRARY_OPTIONS, MetaSchemaCompatLayer, OpenAIReasoningSchemaCompatLayer, OpenAISchemaCompatLayer, SUPPORTED_ZOD_TYPES, SchemaCompatLayer, SchemaCompatLayer$1 as SchemaCompatLayerV3, SchemaCompatLayer$2 as SchemaCompatLayerV4, UNSUPPORTED_ZOD_TYPES, applyCompatLayer, applyOpenAICompatToTools, applyOpenAICompatTransforms, convertSchemaToZod, convertZodSchemaToAISDKSchema, ensureAllPropertiesRequired, extractZodSchema, isArr, isNumber, isObj, isOptional, isStandardJSONSchema, isStandardSchema, isStandardSchemaWithJSON, isString, isUnion, isZodType, jsonSchema, prepareJsonSchemaForOpenAIStrictMode, standardSchemaToJSONSchema, toStandardSchema, wrapSchemaWithNullTransform };
|
|
6402
6385
|
|
|
6403
6386
|
//# sourceMappingURL=index.js.map
|