@mastra/schema-compat 1.2.9-alpha.1 → 1.2.10-alpha.0
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 +14 -0
- package/dist/_types/@internal_ai-sdk-v4/dist/index.d.ts +51 -5
- package/dist/_types/@internal_ai-sdk-v5/dist/index.d.ts +487 -1773
- package/dist/_types/@internal_ai-v6/dist/index.d.ts +357 -1772
- package/dist/index.cjs +32 -28
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +32 -28
- package/dist/index.js.map +1 -1
- package/dist/provider-compats/google.d.ts +1 -0
- package/dist/provider-compats/google.d.ts.map +1 -1
- package/package.json +16 -16
package/dist/index.cjs
CHANGED
|
@@ -10,7 +10,7 @@ var zodFromJsonSchema = require('zod-from-json-schema');
|
|
|
10
10
|
var zodFromJsonSchemaV3 = require('zod-from-json-schema-v3');
|
|
11
11
|
var v4 = require('zod/v4');
|
|
12
12
|
|
|
13
|
-
// ../_vendored/ai_v4/dist/chunk-
|
|
13
|
+
// ../_vendored/ai_v4/dist/chunk-HB6FLTHO.js
|
|
14
14
|
var __create = Object.create;
|
|
15
15
|
var __defProp = Object.defineProperty;
|
|
16
16
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
@@ -5905,56 +5905,62 @@ var DeepSeekSchemaCompatLayer = class extends SchemaCompatLayer3 {
|
|
|
5905
5905
|
return schema;
|
|
5906
5906
|
}
|
|
5907
5907
|
};
|
|
5908
|
-
function
|
|
5908
|
+
function fixAISDKNullableUnionTypes(schema) {
|
|
5909
5909
|
if (typeof schema !== "object" || schema === null) {
|
|
5910
5910
|
return schema;
|
|
5911
5911
|
}
|
|
5912
5912
|
const result = { ...schema };
|
|
5913
5913
|
if (Array.isArray(result.type)) {
|
|
5914
5914
|
const nonNullTypes = result.type.filter((t) => t !== "null");
|
|
5915
|
-
if (nonNullTypes.length
|
|
5915
|
+
if (nonNullTypes.length === 1) {
|
|
5916
|
+
result.type = nonNullTypes[0];
|
|
5916
5917
|
result.nullable = true;
|
|
5917
|
-
|
|
5918
|
-
|
|
5919
|
-
|
|
5920
|
-
result.type = nonNullTypes;
|
|
5921
|
-
} else {
|
|
5922
|
-
delete result.type;
|
|
5923
|
-
}
|
|
5918
|
+
} else {
|
|
5919
|
+
delete result.type;
|
|
5920
|
+
delete result.nullable;
|
|
5924
5921
|
}
|
|
5925
5922
|
}
|
|
5926
|
-
if (
|
|
5923
|
+
if (Array.isArray(result.enum) && result.enum.some((value) => typeof value !== "string")) {
|
|
5924
|
+
delete result.enum;
|
|
5925
|
+
}
|
|
5926
|
+
if ("const" in result && typeof result.const !== "string") {
|
|
5927
|
+
delete result.const;
|
|
5928
|
+
}
|
|
5929
|
+
if (result.anyOf && Array.isArray(result.anyOf)) {
|
|
5927
5930
|
const nullSchema = result.anyOf.find((s) => typeof s === "object" && s !== null && s.type === "null");
|
|
5928
|
-
const
|
|
5929
|
-
if (nullSchema
|
|
5931
|
+
const nonNullSchemas = result.anyOf.filter((s) => !(typeof s === "object" && s !== null && s.type === "null"));
|
|
5932
|
+
if (nullSchema) {
|
|
5930
5933
|
const { anyOf: _, ...rest } = result;
|
|
5931
|
-
|
|
5932
|
-
|
|
5934
|
+
if (nonNullSchemas.length === 1 && typeof nonNullSchemas[0] === "object" && nonNullSchemas[0] !== null) {
|
|
5935
|
+
const fixedOther = fixAISDKNullableUnionTypes(nonNullSchemas[0]);
|
|
5936
|
+
return fixedOther.type ? { ...rest, ...fixedOther, nullable: true } : { ...rest, ...fixedOther };
|
|
5937
|
+
}
|
|
5938
|
+
return rest;
|
|
5933
5939
|
}
|
|
5934
5940
|
}
|
|
5935
5941
|
if (result.properties && typeof result.properties === "object") {
|
|
5936
5942
|
result.properties = Object.fromEntries(
|
|
5937
|
-
Object.entries(result.properties).map(([key, value]) => [key,
|
|
5943
|
+
Object.entries(result.properties).map(([key, value]) => [key, fixAISDKNullableUnionTypes(value)])
|
|
5938
5944
|
);
|
|
5939
5945
|
}
|
|
5940
5946
|
if (result.items) {
|
|
5941
5947
|
if (Array.isArray(result.items)) {
|
|
5942
|
-
result.items = result.items.map((item) =>
|
|
5948
|
+
result.items = result.items.map((item) => fixAISDKNullableUnionTypes(item));
|
|
5943
5949
|
} else {
|
|
5944
|
-
result.items =
|
|
5950
|
+
result.items = fixAISDKNullableUnionTypes(result.items);
|
|
5945
5951
|
}
|
|
5946
5952
|
}
|
|
5947
5953
|
if (result.additionalProperties && typeof result.additionalProperties === "object") {
|
|
5948
|
-
result.additionalProperties =
|
|
5954
|
+
result.additionalProperties = fixAISDKNullableUnionTypes(result.additionalProperties);
|
|
5949
5955
|
}
|
|
5950
5956
|
if (result.anyOf && Array.isArray(result.anyOf)) {
|
|
5951
|
-
result.anyOf = result.anyOf.map((s) =>
|
|
5957
|
+
result.anyOf = result.anyOf.map((s) => fixAISDKNullableUnionTypes(s));
|
|
5952
5958
|
}
|
|
5953
5959
|
if (result.oneOf && Array.isArray(result.oneOf)) {
|
|
5954
|
-
result.oneOf = result.oneOf.map((s) =>
|
|
5960
|
+
result.oneOf = result.oneOf.map((s) => fixAISDKNullableUnionTypes(s));
|
|
5955
5961
|
}
|
|
5956
5962
|
if (result.allOf && Array.isArray(result.allOf)) {
|
|
5957
|
-
result.allOf = result.allOf.map((s) =>
|
|
5963
|
+
result.allOf = result.allOf.map((s) => fixAISDKNullableUnionTypes(s));
|
|
5958
5964
|
}
|
|
5959
5965
|
if (result.anyOf && Array.isArray(result.anyOf)) {
|
|
5960
5966
|
if (result.description) {
|
|
@@ -6007,15 +6013,13 @@ var GoogleSchemaCompatLayer = class extends SchemaCompatLayer3 {
|
|
|
6007
6013
|
}
|
|
6008
6014
|
return this.defaultUnsupportedZodTypeHandler(value);
|
|
6009
6015
|
}
|
|
6010
|
-
|
|
6011
|
-
|
|
6012
|
-
|
|
6013
|
-
// return fixNullableUnionTypes(result as Record<string, any>) as JSONSchema7;
|
|
6014
|
-
// }
|
|
6016
|
+
processToJSONSchema(schema, io) {
|
|
6017
|
+
return super.processToJSONSchema(schema, io);
|
|
6018
|
+
}
|
|
6015
6019
|
processToAISDKSchema(zodSchema2) {
|
|
6016
6020
|
const compat = this.processToCompatSchema(zodSchema2);
|
|
6017
6021
|
const transformedJsonSchema = chunkQ6XZFGLX_cjs.standardSchemaToJSONSchema(compat);
|
|
6018
|
-
const fixedJsonSchema =
|
|
6022
|
+
const fixedJsonSchema = fixAISDKNullableUnionTypes(transformedJsonSchema);
|
|
6019
6023
|
return jsonSchema(fixedJsonSchema, {
|
|
6020
6024
|
validate: (value) => {
|
|
6021
6025
|
const transformed = this.#traverse(value, fixedJsonSchema);
|