@mastra/schema-compat 0.0.0-fix-message-list-args-missing-20250807205055 → 0.0.0-fix-zod-to-json-schema-ref-strategy-20250910193441

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.
Files changed (63) hide show
  1. package/CHANGELOG.md +89 -1
  2. package/README.md +0 -4
  3. package/dist/chunk-7YUR5KZ5.cjs +34 -0
  4. package/dist/chunk-7YUR5KZ5.cjs.map +1 -0
  5. package/dist/chunk-GWTUXMDD.js +28 -0
  6. package/dist/chunk-GWTUXMDD.js.map +1 -0
  7. package/dist/index.cjs +842 -83
  8. package/dist/index.cjs.map +1 -1
  9. package/dist/index.d.ts +10 -8
  10. package/dist/index.d.ts.map +1 -1
  11. package/dist/index.js +841 -84
  12. package/dist/index.js.map +1 -1
  13. package/dist/provider-compats/anthropic.d.ts +6 -4
  14. package/dist/provider-compats/anthropic.d.ts.map +1 -1
  15. package/dist/provider-compats/deepseek.d.ts +6 -4
  16. package/dist/provider-compats/deepseek.d.ts.map +1 -1
  17. package/dist/provider-compats/google.d.ts +6 -4
  18. package/dist/provider-compats/google.d.ts.map +1 -1
  19. package/dist/provider-compats/meta.d.ts +6 -4
  20. package/dist/provider-compats/meta.d.ts.map +1 -1
  21. package/dist/provider-compats/openai-reasoning.d.ts +6 -4
  22. package/dist/provider-compats/openai-reasoning.d.ts.map +1 -1
  23. package/dist/provider-compats/openai.d.ts +6 -4
  24. package/dist/provider-compats/openai.d.ts.map +1 -1
  25. package/dist/schema-compatibility-v3.d.ts +319 -0
  26. package/dist/schema-compatibility-v3.d.ts.map +1 -0
  27. package/dist/schema-compatibility-v4.d.ts +310 -0
  28. package/dist/schema-compatibility-v4.d.ts.map +1 -0
  29. package/dist/schema-compatibility.d.ts +76 -133
  30. package/dist/schema-compatibility.d.ts.map +1 -1
  31. package/dist/types.d.ts +6 -0
  32. package/dist/types.d.ts.map +1 -0
  33. package/dist/utils-test-suite.d.ts +2 -0
  34. package/dist/utils-test-suite.d.ts.map +1 -0
  35. package/dist/utils.d.ts +17 -5
  36. package/dist/utils.d.ts.map +1 -1
  37. package/dist/zod-to-json.cjs +12 -0
  38. package/dist/zod-to-json.cjs.map +1 -0
  39. package/dist/zod-to-json.d.ts +6 -0
  40. package/dist/zod-to-json.d.ts.map +1 -0
  41. package/dist/zod-to-json.js +3 -0
  42. package/dist/zod-to-json.js.map +1 -0
  43. package/dist/zodTypes.d.ts +21 -0
  44. package/dist/zodTypes.d.ts.map +1 -0
  45. package/package.json +31 -8
  46. package/.turbo/turbo-build.log +0 -4
  47. package/eslint.config.js +0 -6
  48. package/src/index.ts +0 -39
  49. package/src/provider-compats/anthropic.ts +0 -43
  50. package/src/provider-compats/deepseek.ts +0 -35
  51. package/src/provider-compats/google.ts +0 -63
  52. package/src/provider-compats/meta.ts +0 -36
  53. package/src/provider-compats/openai-reasoning.ts +0 -91
  54. package/src/provider-compats/openai.ts +0 -55
  55. package/src/provider-compats.test.ts +0 -407
  56. package/src/schema-compatibility.test.ts +0 -487
  57. package/src/schema-compatibility.ts +0 -594
  58. package/src/utils.test.ts +0 -460
  59. package/src/utils.ts +0 -205
  60. package/tsconfig.build.json +0 -9
  61. package/tsconfig.json +0 -5
  62. package/tsup.config.ts +0 -17
  63. package/vitest.config.ts +0 -7
package/CHANGELOG.md CHANGED
@@ -1,11 +1,99 @@
1
1
  # @mastra/schema-compat
2
2
 
3
- ## 0.0.0-fix-message-list-args-missing-20250807205055
3
+ ## 0.0.0-fix-zod-to-json-schema-ref-strategy-20250910193441
4
+
5
+ ### Patch Changes
6
+
7
+ - Change SchemaCompat zodToJsonSchema ref strategy from none to relative, leading to less schema warnings and smaller converted schema sizes ([`194f0cf`](https://github.com/mastra-ai/mastra/commit/194f0cffbcaa0cfc9631a00f5450863038b8454b))
8
+
9
+ ## 0.11.2
10
+
11
+ ### Patch Changes
12
+
13
+ - ab48c97: dependencies updates:
14
+ - Updated dependency [`zod-to-json-schema@^3.24.6` ↗︎](https://www.npmjs.com/package/zod-to-json-schema/v/3.24.6) (from `^3.24.5`, in `dependencies`)
15
+ - 637f323: Fix issue with some compilers and calling zod v4's toJSONSchema function
16
+ - de3cbc6: Update the `package.json` file to include additional fields like `repository`, `homepage` or `files`.
17
+ - 45e4d39: Try fixing the `Attempted import error: 'z'.'toJSONSchema' is not exported from 'zod'` error by tricking the compiler
18
+
19
+ ## 0.11.2-alpha.3
20
+
21
+ ### Patch Changes
22
+
23
+ - [#7350](https://github.com/mastra-ai/mastra/pull/7350) [`45e4d39`](https://github.com/mastra-ai/mastra/commit/45e4d391a2a09fc70c48e4d60f505586ada1ba0e) Thanks [@LekoArts](https://github.com/LekoArts)! - Try fixing the `Attempted import error: 'z'.'toJSONSchema' is not exported from 'zod'` error by tricking the compiler
24
+
25
+ ## 0.11.2-alpha.2
26
+
27
+ ### Patch Changes
28
+
29
+ - [#7343](https://github.com/mastra-ai/mastra/pull/7343) [`de3cbc6`](https://github.com/mastra-ai/mastra/commit/de3cbc61079211431bd30487982ea3653517278e) Thanks [@LekoArts](https://github.com/LekoArts)! - Update the `package.json` file to include additional fields like `repository`, `homepage` or `files`.
30
+
31
+ ## 0.11.2-alpha.1
32
+
33
+ ### Patch Changes
34
+
35
+ - [#5816](https://github.com/mastra-ai/mastra/pull/5816) [`ab48c97`](https://github.com/mastra-ai/mastra/commit/ab48c979098ea571faf998a55d3a00e7acd7a715) Thanks [@dane-ai-mastra](https://github.com/apps/dane-ai-mastra)! - dependencies updates:
36
+ - Updated dependency [`zod-to-json-schema@^3.24.6` ↗︎](https://www.npmjs.com/package/zod-to-json-schema/v/3.24.6) (from `^3.24.5`, in `dependencies`)
37
+
38
+ ## 0.11.2-alpha.0
39
+
40
+ ### Patch Changes
41
+
42
+ - [#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
43
+
44
+ ## 0.11.1
45
+
46
+ ### Patch Changes
47
+
48
+ - [`c6113ed`](https://github.com/mastra-ai/mastra/commit/c6113ed7f9df297e130d94436ceee310273d6430) Thanks [@wardpeet](https://github.com/wardpeet)! - Fix peerdpes for @mastra/core
49
+
50
+ ## 0.11.0
51
+
52
+ ### Minor Changes
53
+
54
+ - [#7032](https://github.com/mastra-ai/mastra/pull/7032) [`1191ce9`](https://github.com/mastra-ai/mastra/commit/1191ce946b40ed291e7877a349f8388e3cff7e5c) Thanks [@wardpeet](https://github.com/wardpeet)! - Bump zod peerdep to 3.25.0 to support both v3/v4
55
+
56
+ ### Patch Changes
57
+
58
+ - [#7028](https://github.com/mastra-ai/mastra/pull/7028) [`da58ccc`](https://github.com/mastra-ai/mastra/commit/da58ccc1f2ac33da0cb97b00443fc6208b45bdec) Thanks [@wardpeet](https://github.com/wardpeet)! - Fix exportsmap
59
+
60
+ - [#6982](https://github.com/mastra-ai/mastra/pull/6982) [`94e9f54`](https://github.com/mastra-ai/mastra/commit/94e9f547d66ef7cd01d9075ab53b5ca9a1cae100) Thanks [@wardpeet](https://github.com/wardpeet)! - Fix AI peerdeps for NPM install
61
+
62
+ - [#6944](https://github.com/mastra-ai/mastra/pull/6944) [`a93f3ba`](https://github.com/mastra-ai/mastra/commit/a93f3ba05eef4cf17f876d61d29cf0841a9e70b7) Thanks [@wardpeet](https://github.com/wardpeet)! - Add support for zod v4
63
+
64
+ ## 0.11.0-alpha.2
65
+
66
+ ### Minor Changes
67
+
68
+ - [#7032](https://github.com/mastra-ai/mastra/pull/7032) [`1191ce9`](https://github.com/mastra-ai/mastra/commit/1191ce946b40ed291e7877a349f8388e3cff7e5c) Thanks [@wardpeet](https://github.com/wardpeet)! - Bump zod peerdep to 3.25.0 to support both v3/v4
69
+
70
+ ## 0.10.6-alpha.1
71
+
72
+ ### Patch Changes
73
+
74
+ - [#7028](https://github.com/mastra-ai/mastra/pull/7028) [`da58ccc`](https://github.com/mastra-ai/mastra/commit/da58ccc1f2ac33da0cb97b00443fc6208b45bdec) Thanks [@wardpeet](https://github.com/wardpeet)! - Fix exportsmap
75
+
76
+ ## 0.10.6-alpha.0
77
+
78
+ ### Patch Changes
79
+
80
+ - [#6982](https://github.com/mastra-ai/mastra/pull/6982) [`94e9f54`](https://github.com/mastra-ai/mastra/commit/94e9f547d66ef7cd01d9075ab53b5ca9a1cae100) Thanks [@wardpeet](https://github.com/wardpeet)! - Fix AI peerdeps for NPM install
81
+
82
+ - [#6944](https://github.com/mastra-ai/mastra/pull/6944) [`a93f3ba`](https://github.com/mastra-ai/mastra/commit/a93f3ba05eef4cf17f876d61d29cf0841a9e70b7) Thanks [@wardpeet](https://github.com/wardpeet)! - Add support for zod v4
83
+
84
+ ## 0.10.7
4
85
 
5
86
  ### Patch Changes
6
87
 
7
88
  - dd94a26: Dont rely on the full language model for schema compat
8
89
  - 2fff911: Fix vnext working memory tool schema when model is incompatible with schema
90
+ - ae2eb63: Handle regex checks better, return description as a string rather than an object with pattern and flags.
91
+
92
+ ## 0.10.7-alpha.1
93
+
94
+ ### Patch Changes
95
+
96
+ - ae2eb63: Handle regex checks better, return description as a string rather than an object with pattern and flags.
9
97
 
10
98
  ## 0.10.7-alpha.0
11
99
 
package/README.md CHANGED
@@ -142,7 +142,3 @@ pnpm test
142
142
  # Run tests in watch mode
143
143
  pnpm test --watch
144
144
  ```
145
-
146
- ## License
147
-
148
- Elastic-2.0
@@ -0,0 +1,34 @@
1
+ 'use strict';
2
+
3
+ var zod = require('zod');
4
+ var zodToJsonSchemaOriginal = require('zod-to-json-schema');
5
+
6
+ function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
7
+
8
+ var zodToJsonSchemaOriginal__default = /*#__PURE__*/_interopDefault(zodToJsonSchemaOriginal);
9
+
10
+ // src/zod-to-json.ts
11
+ function zodToJsonSchema(zodSchema, target = "jsonSchema7", strategy = "relative") {
12
+ const fn = "toJSONSchema";
13
+ if (fn in zod.z) {
14
+ return zod.z[fn](zodSchema, {
15
+ unrepresentable: "any",
16
+ override: (ctx) => {
17
+ const def = ctx.zodSchema?._zod?.def;
18
+ if (def && def.type === "date") {
19
+ ctx.jsonSchema.type = "string";
20
+ ctx.jsonSchema.format = "date-time";
21
+ }
22
+ }
23
+ });
24
+ } else {
25
+ return zodToJsonSchemaOriginal__default.default(zodSchema, {
26
+ $refStrategy: strategy,
27
+ target
28
+ });
29
+ }
30
+ }
31
+
32
+ exports.zodToJsonSchema = zodToJsonSchema;
33
+ //# sourceMappingURL=chunk-7YUR5KZ5.cjs.map
34
+ //# sourceMappingURL=chunk-7YUR5KZ5.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/zod-to-json.ts"],"names":["z","zodToJsonSchemaOriginal"],"mappings":";;;;;;;;;;AAOO,SAAS,eAAA,CACd,SAAA,EACA,MAAA,GAAkB,aAAA,EAClB,WAAkD,UAAA,EAClD;AACA,EAAA,MAAM,EAAA,GAAK,cAAA;AAEX,EAAA,IAAI,MAAMA,KAAA,EAAG;AAEX,IAAA,OAAQA,KAAA,CAAU,EAAE,CAAA,CAAE,SAAA,EAAW;AAAA,MAC/B,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,QAAA;AAAA,MACd;AAAA,KACD,CAAA;AAAA,EACH;AACF","file":"chunk-7YUR5KZ5.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(\n zodSchema: ZodSchemaV3 | ZodSchemaV4,\n target: Targets = 'jsonSchema7',\n strategy: 'none' | 'seen' | 'root' | 'relative' = 'relative',\n) {\n const fn = 'toJSONSchema';\n\n if (fn in z) {\n // Use dynamic property access to avoid import errors in Zod v3\n return (z as any)[fn](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: strategy,\n target,\n }) as JSONSchema7;\n }\n}\n"]}
@@ -0,0 +1,28 @@
1
+ import { z } from 'zod';
2
+ import zodToJsonSchemaOriginal from 'zod-to-json-schema';
3
+
4
+ // src/zod-to-json.ts
5
+ function zodToJsonSchema(zodSchema, target = "jsonSchema7", strategy = "relative") {
6
+ const fn = "toJSONSchema";
7
+ if (fn in z) {
8
+ return z[fn](zodSchema, {
9
+ unrepresentable: "any",
10
+ override: (ctx) => {
11
+ const def = ctx.zodSchema?._zod?.def;
12
+ if (def && def.type === "date") {
13
+ ctx.jsonSchema.type = "string";
14
+ ctx.jsonSchema.format = "date-time";
15
+ }
16
+ }
17
+ });
18
+ } else {
19
+ return zodToJsonSchemaOriginal(zodSchema, {
20
+ $refStrategy: strategy,
21
+ target
22
+ });
23
+ }
24
+ }
25
+
26
+ export { zodToJsonSchema };
27
+ //# sourceMappingURL=chunk-GWTUXMDD.js.map
28
+ //# sourceMappingURL=chunk-GWTUXMDD.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/zod-to-json.ts"],"names":[],"mappings":";;;;AAOO,SAAS,eAAA,CACd,SAAA,EACA,MAAA,GAAkB,aAAA,EAClB,WAAkD,UAAA,EAClD;AACA,EAAA,MAAM,EAAA,GAAK,cAAA;AAEX,EAAA,IAAI,MAAM,CAAA,EAAG;AAEX,IAAA,OAAQ,CAAA,CAAU,EAAE,CAAA,CAAE,SAAA,EAAW;AAAA,MAC/B,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,QAAA;AAAA,MACd;AAAA,KACD,CAAA;AAAA,EACH;AACF","file":"chunk-GWTUXMDD.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(\n zodSchema: ZodSchemaV3 | ZodSchemaV4,\n target: Targets = 'jsonSchema7',\n strategy: 'none' | 'seen' | 'root' | 'relative' = 'relative',\n) {\n const fn = 'toJSONSchema';\n\n if (fn in z) {\n // Use dynamic property access to avoid import errors in Zod v3\n return (z as any)[fn](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: strategy,\n target,\n }) as JSONSchema7;\n }\n}\n"]}