@mastra/schema-compat 0.0.0-fix-fetching-workflow-snapshots-20250625000954 → 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.
- package/CHANGELOG.md +139 -1
- package/LICENSE.md +11 -42
- package/README.md +0 -4
- package/dist/chunk-7YUR5KZ5.cjs +34 -0
- package/dist/chunk-7YUR5KZ5.cjs.map +1 -0
- package/dist/chunk-GWTUXMDD.js +28 -0
- package/dist/chunk-GWTUXMDD.js.map +1 -0
- package/dist/index.cjs +847 -85
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.ts +11 -31
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +846 -86
- package/dist/index.js.map +1 -0
- package/dist/provider-compats/anthropic.d.ts +13 -0
- package/dist/provider-compats/anthropic.d.ts.map +1 -0
- package/dist/provider-compats/deepseek.d.ts +13 -0
- package/dist/provider-compats/deepseek.d.ts.map +1 -0
- package/dist/provider-compats/google.d.ts +13 -0
- package/dist/provider-compats/google.d.ts.map +1 -0
- package/dist/provider-compats/meta.d.ts +13 -0
- package/dist/provider-compats/meta.d.ts.map +1 -0
- package/dist/provider-compats/openai-reasoning.d.ts +14 -0
- package/dist/provider-compats/openai-reasoning.d.ts.map +1 -0
- package/dist/provider-compats/openai.d.ts +13 -0
- package/dist/provider-compats/openai.d.ts.map +1 -0
- package/dist/schema-compatibility-v3.d.ts +319 -0
- package/dist/schema-compatibility-v3.d.ts.map +1 -0
- package/dist/schema-compatibility-v4.d.ts +310 -0
- package/dist/schema-compatibility-v4.d.ts.map +1 -0
- package/dist/schema-compatibility.d.ts +228 -0
- package/dist/schema-compatibility.d.ts.map +1 -0
- package/dist/types.d.ts +6 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/utils-test-suite.d.ts +2 -0
- package/dist/utils-test-suite.d.ts.map +1 -0
- package/dist/utils.d.ts +96 -0
- package/dist/utils.d.ts.map +1 -0
- package/dist/zod-to-json.cjs +12 -0
- package/dist/zod-to-json.cjs.map +1 -0
- package/dist/zod-to-json.d.ts +6 -0
- package/dist/zod-to-json.d.ts.map +1 -0
- package/dist/zod-to-json.js +3 -0
- package/dist/zod-to-json.js.map +1 -0
- package/dist/zodTypes.d.ts +21 -0
- package/dist/zodTypes.d.ts.map +1 -0
- package/package.json +37 -13
- package/.turbo/turbo-build.log +0 -23
- package/dist/_tsup-dts-rollup.d.cts +0 -504
- package/dist/_tsup-dts-rollup.d.ts +0 -504
- package/dist/index.d.cts +0 -31
- package/eslint.config.js +0 -6
- package/src/index.ts +0 -39
- package/src/provider-compats/anthropic.ts +0 -44
- package/src/provider-compats/deepseek.ts +0 -35
- package/src/provider-compats/google.ts +0 -55
- package/src/provider-compats/meta.ts +0 -36
- package/src/provider-compats/openai-reasoning.ts +0 -87
- package/src/provider-compats/openai.ts +0 -56
- package/src/provider-compats.test.ts +0 -312
- package/src/schema-compatibility.test.ts +0 -471
- package/src/schema-compatibility.ts +0 -587
- package/src/utils.test.ts +0 -434
- package/src/utils.ts +0 -205
- package/tsconfig.json +0 -5
- package/vitest.config.ts +0 -7
package/CHANGELOG.md
CHANGED
|
@@ -1,6 +1,144 @@
|
|
|
1
1
|
# @mastra/schema-compat
|
|
2
2
|
|
|
3
|
-
## 0.0.0-fix-
|
|
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
|
|
85
|
+
|
|
86
|
+
### Patch Changes
|
|
87
|
+
|
|
88
|
+
- dd94a26: Dont rely on the full language model for schema compat
|
|
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.
|
|
97
|
+
|
|
98
|
+
## 0.10.7-alpha.0
|
|
99
|
+
|
|
100
|
+
### Patch Changes
|
|
101
|
+
|
|
102
|
+
- dd94a26: Dont rely on the full language model for schema compat
|
|
103
|
+
- 2fff911: Fix vnext working memory tool schema when model is incompatible with schema
|
|
104
|
+
|
|
105
|
+
## 0.10.6
|
|
106
|
+
|
|
107
|
+
### Patch Changes
|
|
108
|
+
|
|
109
|
+
- 4a406ec: fixes TypeScript declaration file imports to ensure proper ESM compatibility
|
|
110
|
+
|
|
111
|
+
## 0.10.6-alpha.0
|
|
112
|
+
|
|
113
|
+
### Patch Changes
|
|
114
|
+
|
|
115
|
+
- 4a406ec: fixes TypeScript declaration file imports to ensure proper ESM compatibility
|
|
116
|
+
|
|
117
|
+
## 0.10.5
|
|
118
|
+
|
|
119
|
+
### Patch Changes
|
|
120
|
+
|
|
121
|
+
- 4da943f: Fix Cannot read properties of undefined (reading 'typeName') in schema compat check
|
|
122
|
+
|
|
123
|
+
## 0.10.5-alpha.0
|
|
124
|
+
|
|
125
|
+
### Patch Changes
|
|
126
|
+
|
|
127
|
+
- 4da943f: Fix Cannot read properties of undefined (reading 'typeName') in schema compat check
|
|
128
|
+
|
|
129
|
+
## 0.10.4
|
|
130
|
+
|
|
131
|
+
### Patch Changes
|
|
132
|
+
|
|
133
|
+
- 0c85311: Fix Google models ZodNull tool schema handling
|
|
134
|
+
|
|
135
|
+
## 0.10.4-alpha.0
|
|
136
|
+
|
|
137
|
+
### Patch Changes
|
|
138
|
+
|
|
139
|
+
- 0c85311: Fix Google models ZodNull tool schema handling
|
|
140
|
+
|
|
141
|
+
## 0.10.3
|
|
4
142
|
|
|
5
143
|
### Patch Changes
|
|
6
144
|
|
package/LICENSE.md
CHANGED
|
@@ -1,46 +1,15 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Apache License 2.0
|
|
2
2
|
|
|
3
|
-
Copyright (c) 2025
|
|
3
|
+
Copyright (c) 2025 Kepler Software, Inc.
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
5
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
you may not use this file except in compliance with the License.
|
|
7
|
+
You may obtain a copy of the License at
|
|
7
8
|
|
|
8
|
-
|
|
9
|
-
The licensor grants you a non-exclusive, royalty-free, worldwide, non-sublicensable, non-transferable license to use, copy, distribute, make available, and prepare derivative works of the software, in each case subject to the limitations and conditions below
|
|
9
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
10
10
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
You may not alter, remove, or obscure any licensing, copyright, or other notices of the licensor in the software. Any use of the licensor’s trademarks is subject to applicable law.
|
|
17
|
-
|
|
18
|
-
**Patents**
|
|
19
|
-
The licensor grants you a license, under any patent claims the licensor can license, or becomes able to license, to make, have made, use, sell, offer for sale, import and have imported the software, in each case subject to the limitations and conditions in this license. This license does not cover any patent claims that you cause to be infringed by modifications or additions to the software. If you or your company make any written claim that the software infringes or contributes to infringement of any patent, your patent license for the software granted under these terms ends immediately. If your company makes such a claim, your patent license ends immediately for work on behalf of your company.
|
|
20
|
-
|
|
21
|
-
**Notices**
|
|
22
|
-
You must ensure that anyone who gets a copy of any part of the software from you also gets a copy of these terms.
|
|
23
|
-
|
|
24
|
-
If you modify the software, you must include in any modified copies of the software prominent notices stating that you have modified the software.
|
|
25
|
-
|
|
26
|
-
**No Other Rights**
|
|
27
|
-
These terms do not imply any licenses other than those expressly granted in these terms.
|
|
28
|
-
|
|
29
|
-
**Termination**
|
|
30
|
-
If you use the software in violation of these terms, such use is not licensed, and your licenses will automatically terminate. If the licensor provides you with a notice of your violation, and you cease all violation of this license no later than 30 days after you receive that notice, your licenses will be reinstated retroactively. However, if you violate these terms after such reinstatement, any additional violation of these terms will cause your licenses to terminate automatically and permanently.
|
|
31
|
-
|
|
32
|
-
**No Liability**
|
|
33
|
-
As far as the law allows, the software comes as is, without any warranty or condition, and the licensor will not be liable to you for any damages arising out of these terms or the use or nature of the software, under any kind of legal claim.
|
|
34
|
-
|
|
35
|
-
**Definitions**
|
|
36
|
-
The _licensor_ is the entity offering these terms, and the _software_ is the software the licensor makes available under these terms, including any portion of it.
|
|
37
|
-
|
|
38
|
-
_you_ refers to the individual or entity agreeing to these terms.
|
|
39
|
-
|
|
40
|
-
_your company_ is any legal entity, sole proprietorship, or other kind of organization that you work for, plus all organizations that have control over, are under the control of, or are under common control with that organization. _control_ means ownership of substantially all the assets of an entity, or the power to direct its management and policies by vote, contract, or otherwise. Control can be direct or indirect.
|
|
41
|
-
|
|
42
|
-
_your licenses_ are all the licenses granted to you for the software under these terms.
|
|
43
|
-
|
|
44
|
-
_use_ means anything you do with the software requiring one of your licenses.
|
|
45
|
-
|
|
46
|
-
_trademark_ means trademarks, service marks, and similar rights.
|
|
11
|
+
Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
See the License for the specific language governing permissions and
|
|
15
|
+
limitations under the License.
|
package/README.md
CHANGED
|
@@ -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"]}
|