@mastra/schema-compat 0.11.0 → 0.11.2-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/.turbo/turbo-build.log +1 -1
- package/CHANGELOG.md +12 -0
- package/dist/{chunk-FTKGHMGD.js → chunk-MKYBUMTK.js} +5 -5
- package/dist/chunk-MKYBUMTK.js.map +1 -0
- package/dist/{chunk-LNR4XKDU.cjs → chunk-V7Y3FXBJ.cjs} +5 -5
- package/dist/chunk-V7Y3FXBJ.cjs.map +1 -0
- package/dist/index.cjs +3 -3
- package/dist/index.js +1 -1
- package/dist/zod-to-json.cjs +2 -2
- package/dist/zod-to-json.d.ts.map +1 -1
- package/dist/zod-to-json.js +1 -1
- package/package.json +2 -2
- package/src/zod-to-json.ts +5 -4
- package/dist/chunk-FTKGHMGD.js.map +0 -1
- package/dist/chunk-LNR4XKDU.cjs.map +0 -1
package/.turbo/turbo-build.log
CHANGED
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# @mastra/schema-compat
|
|
2
2
|
|
|
3
|
+
## 0.11.2-alpha.0
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#7121](https://github.com/mastra-ai/mastra/pull/7121) [`637f323`](https://github.com/mastra-ai/mastra/commit/637f32371d79a8f78c52c0d53411af0915fcec67) Thanks [@DanielSLew](https://github.com/DanielSLew)! - Fix issue with some compilers and calling zod v4's toJSONSchema function
|
|
8
|
+
|
|
9
|
+
## 0.11.1
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- [`c6113ed`](https://github.com/mastra-ai/mastra/commit/c6113ed7f9df297e130d94436ceee310273d6430) Thanks [@wardpeet](https://github.com/wardpeet)! - Fix peerdpes for @mastra/core
|
|
14
|
+
|
|
3
15
|
## 0.11.0
|
|
4
16
|
|
|
5
17
|
### Minor Changes
|
|
@@ -4,11 +4,11 @@ import zodToJsonSchemaOriginal from 'zod-to-json-schema';
|
|
|
4
4
|
// src/zod-to-json.ts
|
|
5
5
|
function zodToJsonSchema(zodSchema, target = "jsonSchema7") {
|
|
6
6
|
if ("toJSONSchema" in z) {
|
|
7
|
-
return z
|
|
7
|
+
return z["toJSONSchema"](zodSchema, {
|
|
8
8
|
unrepresentable: "any",
|
|
9
9
|
override: (ctx) => {
|
|
10
|
-
const def = ctx.zodSchema
|
|
11
|
-
if (def.type === "date") {
|
|
10
|
+
const def = ctx.zodSchema?._zod?.def;
|
|
11
|
+
if (def && def.type === "date") {
|
|
12
12
|
ctx.jsonSchema.type = "string";
|
|
13
13
|
ctx.jsonSchema.format = "date-time";
|
|
14
14
|
}
|
|
@@ -23,5 +23,5 @@ function zodToJsonSchema(zodSchema, target = "jsonSchema7") {
|
|
|
23
23
|
}
|
|
24
24
|
|
|
25
25
|
export { zodToJsonSchema };
|
|
26
|
-
//# sourceMappingURL=chunk-
|
|
27
|
-
//# sourceMappingURL=chunk-
|
|
26
|
+
//# sourceMappingURL=chunk-MKYBUMTK.js.map
|
|
27
|
+
//# sourceMappingURL=chunk-MKYBUMTK.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/zod-to-json.ts"],"names":[],"mappings":";;;;AAOO,SAAS,eAAA,CAAgB,SAAA,EAAsC,MAAA,GAAkB,aAAA,EAAe;AACrG,EAAA,IAAI,kBAAkB,CAAA,EAAG;AAEvB,IAAA,OAAQ,CAAA,CAAU,cAAc,CAAA,CAAE,SAAA,EAAW;AAAA,MAC3C,eAAA,EAAiB,KAAA;AAAA,MACjB,QAAA,EAAU,CAAC,GAAA,KAAa;AAEtB,QAAA,MAAM,GAAA,GAAM,GAAA,CAAI,SAAA,EAAW,IAAA,EAAM,GAAA;AACjC,QAAA,IAAI,GAAA,IAAO,GAAA,CAAI,IAAA,KAAS,MAAA,EAAQ;AAC9B,UAAA,GAAA,CAAI,WAAW,IAAA,GAAO,QAAA;AACtB,UAAA,GAAA,CAAI,WAAW,MAAA,GAAS,WAAA;AAAA,QAC1B;AAAA,MACF;AAAA,KACD,CAAA;AAAA,EACH,CAAA,MAAO;AACL,IAAA,OAAO,wBAAwB,SAAA,EAA0B;AAAA,MACvD,YAAA,EAAc,MAAA;AAAA,MACd;AAAA,KACD,CAAA;AAAA,EACH;AACF","file":"chunk-MKYBUMTK.js","sourcesContent":["import type { JSONSchema7 } from 'json-schema';\nimport { z } from 'zod';\nimport type { ZodSchema as ZodSchemaV3 } from 'zod/v3';\nimport type { ZodType as ZodSchemaV4 } from 'zod/v4';\nimport type { Targets } from 'zod-to-json-schema';\nimport zodToJsonSchemaOriginal from 'zod-to-json-schema';\n\nexport function zodToJsonSchema(zodSchema: ZodSchemaV3 | ZodSchemaV4, target: Targets = 'jsonSchema7') {\n if ('toJSONSchema' in z) {\n // Use dynamic property access to avoid import errors in Zod v3\n return (z as any)['toJSONSchema'](zodSchema, {\n unrepresentable: 'any',\n override: (ctx: any) => {\n // Safe access to handle cases where _zod might be undefined\n const def = ctx.zodSchema?._zod?.def;\n if (def && def.type === 'date') {\n ctx.jsonSchema.type = 'string';\n ctx.jsonSchema.format = 'date-time';\n }\n },\n }) as JSONSchema7;\n } else {\n return zodToJsonSchemaOriginal(zodSchema as ZodSchemaV3, {\n $refStrategy: 'none',\n target,\n }) as JSONSchema7;\n }\n}\n"]}
|
|
@@ -10,11 +10,11 @@ var zodToJsonSchemaOriginal__default = /*#__PURE__*/_interopDefault(zodToJsonSch
|
|
|
10
10
|
// src/zod-to-json.ts
|
|
11
11
|
function zodToJsonSchema(zodSchema, target = "jsonSchema7") {
|
|
12
12
|
if ("toJSONSchema" in zod.z) {
|
|
13
|
-
return zod.z
|
|
13
|
+
return zod.z["toJSONSchema"](zodSchema, {
|
|
14
14
|
unrepresentable: "any",
|
|
15
15
|
override: (ctx) => {
|
|
16
|
-
const def = ctx.zodSchema
|
|
17
|
-
if (def.type === "date") {
|
|
16
|
+
const def = ctx.zodSchema?._zod?.def;
|
|
17
|
+
if (def && def.type === "date") {
|
|
18
18
|
ctx.jsonSchema.type = "string";
|
|
19
19
|
ctx.jsonSchema.format = "date-time";
|
|
20
20
|
}
|
|
@@ -29,5 +29,5 @@ function zodToJsonSchema(zodSchema, target = "jsonSchema7") {
|
|
|
29
29
|
}
|
|
30
30
|
|
|
31
31
|
exports.zodToJsonSchema = zodToJsonSchema;
|
|
32
|
-
//# sourceMappingURL=chunk-
|
|
33
|
-
//# sourceMappingURL=chunk-
|
|
32
|
+
//# sourceMappingURL=chunk-V7Y3FXBJ.cjs.map
|
|
33
|
+
//# sourceMappingURL=chunk-V7Y3FXBJ.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/zod-to-json.ts"],"names":["z","zodToJsonSchemaOriginal"],"mappings":";;;;;;;;;;AAOO,SAAS,eAAA,CAAgB,SAAA,EAAsC,MAAA,GAAkB,aAAA,EAAe;AACrG,EAAA,IAAI,kBAAkBA,KAAA,EAAG;AAEvB,IAAA,OAAQA,KAAA,CAAU,cAAc,CAAA,CAAE,SAAA,EAAW;AAAA,MAC3C,eAAA,EAAiB,KAAA;AAAA,MACjB,QAAA,EAAU,CAAC,GAAA,KAAa;AAEtB,QAAA,MAAM,GAAA,GAAM,GAAA,CAAI,SAAA,EAAW,IAAA,EAAM,GAAA;AACjC,QAAA,IAAI,GAAA,IAAO,GAAA,CAAI,IAAA,KAAS,MAAA,EAAQ;AAC9B,UAAA,GAAA,CAAI,WAAW,IAAA,GAAO,QAAA;AACtB,UAAA,GAAA,CAAI,WAAW,MAAA,GAAS,WAAA;AAAA,QAC1B;AAAA,MACF;AAAA,KACD,CAAA;AAAA,EACH,CAAA,MAAO;AACL,IAAA,OAAOC,yCAAwB,SAAA,EAA0B;AAAA,MACvD,YAAA,EAAc,MAAA;AAAA,MACd;AAAA,KACD,CAAA;AAAA,EACH;AACF","file":"chunk-V7Y3FXBJ.cjs","sourcesContent":["import type { JSONSchema7 } from 'json-schema';\nimport { z } from 'zod';\nimport type { ZodSchema as ZodSchemaV3 } from 'zod/v3';\nimport type { ZodType as ZodSchemaV4 } from 'zod/v4';\nimport type { Targets } from 'zod-to-json-schema';\nimport zodToJsonSchemaOriginal from 'zod-to-json-schema';\n\nexport function zodToJsonSchema(zodSchema: ZodSchemaV3 | ZodSchemaV4, target: Targets = 'jsonSchema7') {\n if ('toJSONSchema' in z) {\n // Use dynamic property access to avoid import errors in Zod v3\n return (z as any)['toJSONSchema'](zodSchema, {\n unrepresentable: 'any',\n override: (ctx: any) => {\n // Safe access to handle cases where _zod might be undefined\n const def = ctx.zodSchema?._zod?.def;\n if (def && def.type === 'date') {\n ctx.jsonSchema.type = 'string';\n ctx.jsonSchema.format = 'date-time';\n }\n },\n }) as JSONSchema7;\n } else {\n return zodToJsonSchemaOriginal(zodSchema as ZodSchemaV3, {\n $refStrategy: 'none',\n target,\n }) as JSONSchema7;\n }\n}\n"]}
|
package/dist/index.cjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var chunkV7Y3FXBJ_cjs = require('./chunk-V7Y3FXBJ.cjs');
|
|
4
4
|
var zod = require('zod');
|
|
5
5
|
var ai = require('ai');
|
|
6
6
|
var zodFromJsonSchema = require('zod-from-json-schema');
|
|
@@ -8,7 +8,7 @@ var zodFromJsonSchemaV3 = require('zod-from-json-schema-v3');
|
|
|
8
8
|
var v4 = require('zod/v4');
|
|
9
9
|
|
|
10
10
|
function convertZodSchemaToAISDKSchema(zodSchema, target = "jsonSchema7") {
|
|
11
|
-
const jsonSchemaToUse =
|
|
11
|
+
const jsonSchemaToUse = chunkV7Y3FXBJ_cjs.zodToJsonSchema(zodSchema, target);
|
|
12
12
|
return ai.jsonSchema(jsonSchemaToUse, {
|
|
13
13
|
validate: (value) => {
|
|
14
14
|
const result = zodSchema.safeParse(value);
|
|
@@ -55,7 +55,7 @@ function applyCompatLayer({
|
|
|
55
55
|
}
|
|
56
56
|
}
|
|
57
57
|
if (mode === "jsonSchema") {
|
|
58
|
-
return
|
|
58
|
+
return chunkV7Y3FXBJ_cjs.zodToJsonSchema(zodSchema, "jsonSchema7");
|
|
59
59
|
} else {
|
|
60
60
|
return convertZodSchemaToAISDKSchema(zodSchema);
|
|
61
61
|
}
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { zodToJsonSchema } from './chunk-
|
|
1
|
+
import { zodToJsonSchema } from './chunk-MKYBUMTK.js';
|
|
2
2
|
import { z, ZodOptional, ZodObject, ZodArray, ZodUnion, ZodString, ZodNumber, ZodNull, ZodDate, ZodDefault } from 'zod';
|
|
3
3
|
import { jsonSchema } from 'ai';
|
|
4
4
|
import { convertJsonSchemaToZod } from 'zod-from-json-schema';
|
package/dist/zod-to-json.cjs
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var chunkV7Y3FXBJ_cjs = require('./chunk-V7Y3FXBJ.cjs');
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
|
|
7
7
|
Object.defineProperty(exports, "zodToJsonSchema", {
|
|
8
8
|
enumerable: true,
|
|
9
|
-
get: function () { return
|
|
9
|
+
get: function () { return chunkV7Y3FXBJ_cjs.zodToJsonSchema; }
|
|
10
10
|
});
|
|
11
11
|
//# sourceMappingURL=zod-to-json.cjs.map
|
|
12
12
|
//# sourceMappingURL=zod-to-json.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"zod-to-json.d.ts","sourceRoot":"","sources":["../src/zod-to-json.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAE/C,OAAO,KAAK,EAAE,SAAS,IAAI,WAAW,EAAE,MAAM,QAAQ,CAAC;AACvD,OAAO,KAAK,EAAE,OAAO,IAAI,WAAW,EAAE,MAAM,QAAQ,CAAC;AACrD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAGlD,wBAAgB,eAAe,CAAC,SAAS,EAAE,WAAW,GAAG,WAAW,EAAE,MAAM,GAAE,OAAuB,
|
|
1
|
+
{"version":3,"file":"zod-to-json.d.ts","sourceRoot":"","sources":["../src/zod-to-json.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAE/C,OAAO,KAAK,EAAE,SAAS,IAAI,WAAW,EAAE,MAAM,QAAQ,CAAC;AACvD,OAAO,KAAK,EAAE,OAAO,IAAI,WAAW,EAAE,MAAM,QAAQ,CAAC;AACrD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAGlD,wBAAgB,eAAe,CAAC,SAAS,EAAE,WAAW,GAAG,WAAW,EAAE,MAAM,GAAE,OAAuB,eAoBpG"}
|
package/dist/zod-to-json.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mastra/schema-compat",
|
|
3
|
-
"version": "0.11.0",
|
|
3
|
+
"version": "0.11.2-alpha.0",
|
|
4
4
|
"description": "Tool schema compatibility layer for Mastra.ai",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -56,7 +56,7 @@
|
|
|
56
56
|
"typescript": "^5.8.3",
|
|
57
57
|
"vitest": "^3.2.4",
|
|
58
58
|
"zod": "^3.25.67",
|
|
59
|
-
"@internal/lint": "0.0.
|
|
59
|
+
"@internal/lint": "0.0.34"
|
|
60
60
|
},
|
|
61
61
|
"scripts": {
|
|
62
62
|
"build": "tsup --silent --config tsup.config.ts",
|
package/src/zod-to-json.ts
CHANGED
|
@@ -7,12 +7,13 @@ import zodToJsonSchemaOriginal from 'zod-to-json-schema';
|
|
|
7
7
|
|
|
8
8
|
export function zodToJsonSchema(zodSchema: ZodSchemaV3 | ZodSchemaV4, target: Targets = 'jsonSchema7') {
|
|
9
9
|
if ('toJSONSchema' in z) {
|
|
10
|
-
//
|
|
11
|
-
return z
|
|
10
|
+
// Use dynamic property access to avoid import errors in Zod v3
|
|
11
|
+
return (z as any)['toJSONSchema'](zodSchema, {
|
|
12
12
|
unrepresentable: 'any',
|
|
13
13
|
override: (ctx: any) => {
|
|
14
|
-
|
|
15
|
-
|
|
14
|
+
// Safe access to handle cases where _zod might be undefined
|
|
15
|
+
const def = ctx.zodSchema?._zod?.def;
|
|
16
|
+
if (def && def.type === 'date') {
|
|
16
17
|
ctx.jsonSchema.type = 'string';
|
|
17
18
|
ctx.jsonSchema.format = 'date-time';
|
|
18
19
|
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/zod-to-json.ts"],"names":[],"mappings":";;;;AAOO,SAAS,eAAA,CAAgB,SAAA,EAAsC,MAAA,GAAkB,aAAA,EAAe;AACrG,EAAA,IAAI,kBAAkB,CAAA,EAAG;AAEvB,IAAA,OAAO,CAAA,CAAE,aAAa,SAAA,EAAW;AAAA,MAC/B,eAAA,EAAiB,KAAA;AAAA,MACjB,QAAA,EAAU,CAAC,GAAA,KAAa;AACtB,QAAA,MAAM,GAAA,GAAM,GAAA,CAAI,SAAA,CAAU,IAAA,CAAK,GAAA;AAC/B,QAAA,IAAI,GAAA,CAAI,SAAS,MAAA,EAAQ;AACvB,UAAA,GAAA,CAAI,WAAW,IAAA,GAAO,QAAA;AACtB,UAAA,GAAA,CAAI,WAAW,MAAA,GAAS,WAAA;AAAA,QAC1B;AAAA,MACF;AAAA,KACD,CAAA;AAAA,EACH,CAAA,MAAO;AACL,IAAA,OAAO,wBAAwB,SAAA,EAA0B;AAAA,MACvD,YAAA,EAAc,MAAA;AAAA,MACd;AAAA,KACD,CAAA;AAAA,EACH;AACF","file":"chunk-FTKGHMGD.js","sourcesContent":["import type { JSONSchema7 } from 'json-schema';\nimport { z } from 'zod';\nimport type { ZodSchema as ZodSchemaV3 } from 'zod/v3';\nimport type { ZodType as ZodSchemaV4 } from 'zod/v4';\nimport type { Targets } from 'zod-to-json-schema';\nimport zodToJsonSchemaOriginal from 'zod-to-json-schema';\n\nexport function zodToJsonSchema(zodSchema: ZodSchemaV3 | ZodSchemaV4, target: Targets = 'jsonSchema7') {\n if ('toJSONSchema' in z) {\n // @ts-expect-error - type not present main zod v3\n return z.toJSONSchema(zodSchema, {\n unrepresentable: 'any',\n override: (ctx: any) => {\n const def = ctx.zodSchema._zod.def;\n if (def.type === 'date') {\n ctx.jsonSchema.type = 'string';\n ctx.jsonSchema.format = 'date-time';\n }\n },\n }) as JSONSchema7;\n } else {\n return zodToJsonSchemaOriginal(zodSchema as ZodSchemaV3, {\n $refStrategy: 'none',\n target,\n }) as JSONSchema7;\n }\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/zod-to-json.ts"],"names":["z","zodToJsonSchemaOriginal"],"mappings":";;;;;;;;;;AAOO,SAAS,eAAA,CAAgB,SAAA,EAAsC,MAAA,GAAkB,aAAA,EAAe;AACrG,EAAA,IAAI,kBAAkBA,KAAA,EAAG;AAEvB,IAAA,OAAOA,KAAA,CAAE,aAAa,SAAA,EAAW;AAAA,MAC/B,eAAA,EAAiB,KAAA;AAAA,MACjB,QAAA,EAAU,CAAC,GAAA,KAAa;AACtB,QAAA,MAAM,GAAA,GAAM,GAAA,CAAI,SAAA,CAAU,IAAA,CAAK,GAAA;AAC/B,QAAA,IAAI,GAAA,CAAI,SAAS,MAAA,EAAQ;AACvB,UAAA,GAAA,CAAI,WAAW,IAAA,GAAO,QAAA;AACtB,UAAA,GAAA,CAAI,WAAW,MAAA,GAAS,WAAA;AAAA,QAC1B;AAAA,MACF;AAAA,KACD,CAAA;AAAA,EACH,CAAA,MAAO;AACL,IAAA,OAAOC,yCAAwB,SAAA,EAA0B;AAAA,MACvD,YAAA,EAAc,MAAA;AAAA,MACd;AAAA,KACD,CAAA;AAAA,EACH;AACF","file":"chunk-LNR4XKDU.cjs","sourcesContent":["import type { JSONSchema7 } from 'json-schema';\nimport { z } from 'zod';\nimport type { ZodSchema as ZodSchemaV3 } from 'zod/v3';\nimport type { ZodType as ZodSchemaV4 } from 'zod/v4';\nimport type { Targets } from 'zod-to-json-schema';\nimport zodToJsonSchemaOriginal from 'zod-to-json-schema';\n\nexport function zodToJsonSchema(zodSchema: ZodSchemaV3 | ZodSchemaV4, target: Targets = 'jsonSchema7') {\n if ('toJSONSchema' in z) {\n // @ts-expect-error - type not present main zod v3\n return z.toJSONSchema(zodSchema, {\n unrepresentable: 'any',\n override: (ctx: any) => {\n const def = ctx.zodSchema._zod.def;\n if (def.type === 'date') {\n ctx.jsonSchema.type = 'string';\n ctx.jsonSchema.format = 'date-time';\n }\n },\n }) as JSONSchema7;\n } else {\n return zodToJsonSchemaOriginal(zodSchema as ZodSchemaV3, {\n $refStrategy: 'none',\n target,\n }) as JSONSchema7;\n }\n}\n"]}
|