@mastra/schema-compat 1.3.11 → 1.3.12-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/dist/_types/@internal_ai-sdk-v5/dist/index.d.ts +367 -25
- package/dist/_types/@internal_ai-v6/dist/index.d.ts +686 -37
- package/dist/index.cjs +29 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +29 -3
- package/dist/index.js.map +1 -1
- package/dist/{json-schema-DaHLYDhg.js → json-schema-R8yfooPa.js} +95 -96
- package/dist/json-schema-R8yfooPa.js.map +1 -0
- package/dist/{json-schema-8xkiEZVb.cjs → json-schema-VSnKq6-P.cjs} +95 -96
- package/dist/json-schema-VSnKq6-P.cjs.map +1 -0
- package/dist/provider-compats/openai.d.ts.map +1 -1
- package/dist/{schema-D35TsNfD.cjs → schema-IhrnbMI3.cjs} +2 -2
- package/dist/{schema-D35TsNfD.cjs.map → schema-IhrnbMI3.cjs.map} +1 -1
- package/dist/{schema-BwlBcZRB.js → schema-e0VHpMt0.js} +2 -2
- package/dist/{schema-BwlBcZRB.js.map → schema-e0VHpMt0.js.map} +1 -1
- package/dist/schema.cjs +1 -1
- package/dist/schema.js +1 -1
- package/dist/standard-schema/adapters/json-schema.cjs +1 -1
- package/dist/standard-schema/adapters/json-schema.js +1 -1
- package/dist/zod-to-json.cjs +5 -2
- 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 +5 -2
- package/dist/zod-to-json.js.map +1 -1
- package/package.json +8 -8
- package/dist/json-schema-8xkiEZVb.cjs.map +0 -1
- package/dist/json-schema-DaHLYDhg.js.map +0 -1
package/dist/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { r as __toESM$1, t as require_json_schema_traverse } from "./json-schema-traverse-B35mHRM8.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-e0VHpMt0.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";
|
|
@@ -5227,6 +5227,15 @@ var OpenAISchemaCompatLayer = class extends SchemaCompatLayer {
|
|
|
5227
5227
|
"x-optional"
|
|
5228
5228
|
];
|
|
5229
5229
|
const arrayKeywords = ["items"];
|
|
5230
|
+
const numericKeywords = [
|
|
5231
|
+
"format",
|
|
5232
|
+
"minimum",
|
|
5233
|
+
"maximum",
|
|
5234
|
+
"exclusiveMinimum",
|
|
5235
|
+
"exclusiveMaximum",
|
|
5236
|
+
"multipleOf"
|
|
5237
|
+
];
|
|
5238
|
+
const isNumericType = (type) => type === "integer" || type === "number";
|
|
5230
5239
|
const genericConstraintKeywords = [
|
|
5231
5240
|
"const",
|
|
5232
5241
|
"enum",
|
|
@@ -5276,10 +5285,26 @@ var OpenAISchemaCompatLayer = class extends SchemaCompatLayer {
|
|
|
5276
5285
|
prop.anyOf = types.map((type) => {
|
|
5277
5286
|
if (type === "null") return { type: "null" };
|
|
5278
5287
|
const branch = { type };
|
|
5279
|
-
|
|
5288
|
+
const numericFormat = typeof prop.format === "string" && [
|
|
5289
|
+
"int32",
|
|
5290
|
+
"int64",
|
|
5291
|
+
"float",
|
|
5292
|
+
"double"
|
|
5293
|
+
].includes(prop.format);
|
|
5294
|
+
const formatOwner = types.includes("string") && !numericFormat ? type === "string" : isNumericType(type);
|
|
5295
|
+
for (const keyword of [
|
|
5296
|
+
...typeSpecificKeywords(type),
|
|
5297
|
+
...isNumericType(type) ? numericKeywords.filter((k) => k !== "format") : [],
|
|
5298
|
+
...formatOwner ? ["format"] : []
|
|
5299
|
+
]) if (keyword in prop) branch[keyword] = prop[keyword];
|
|
5280
5300
|
return Object.assign(branch, branchConstraints);
|
|
5281
5301
|
});
|
|
5282
|
-
|
|
5302
|
+
const numericBranchExists = types.some(isNumericType);
|
|
5303
|
+
for (const keyword of [
|
|
5304
|
+
...objectKeywords,
|
|
5305
|
+
...arrayKeywords,
|
|
5306
|
+
...numericBranchExists ? numericKeywords : []
|
|
5307
|
+
]) delete prop[keyword];
|
|
5283
5308
|
} else if (prop.type && prop.type !== "null") {
|
|
5284
5309
|
const originalType = prop.type;
|
|
5285
5310
|
const keywords = typeSpecificKeywords(originalType);
|
|
@@ -5300,6 +5325,7 @@ var OpenAISchemaCompatLayer = class extends SchemaCompatLayer {
|
|
|
5300
5325
|
};
|
|
5301
5326
|
if (isRedundantNullableUnion(originalType)) delete propSchema.anyOf;
|
|
5302
5327
|
for (const keyword of [...genericConstraintKeywords, "anyOf"]) delete prop[keyword];
|
|
5328
|
+
if (isNumericType(originalType)) for (const keyword of numericKeywords) delete prop[keyword];
|
|
5303
5329
|
delete prop.type;
|
|
5304
5330
|
prop.anyOf = [propSchema, { type: "null" }];
|
|
5305
5331
|
}
|