@nullix/zod-mongoose-studio 3.3.2 → 3.3.3
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/.output/nitro.json +1 -1
- package/.output/public/_nuxt/{B7ScFmDB.js → 5ZXm4f56.js} +1 -1
- package/.output/public/_nuxt/{DbqvVYbv.js → B2fcLSyW.js} +1 -1
- package/.output/public/_nuxt/{DKK0Mrrg.js → BBN7l5Hn.js} +1 -1
- package/.output/public/_nuxt/BBTTtb8r.js +41 -0
- package/.output/public/_nuxt/{C8xmwXC2.js → BDbISGvP.js} +1 -1
- package/.output/public/_nuxt/{DJa7_7Hz.js → BijI4RNx.js} +1 -1
- package/.output/public/_nuxt/{BlZ0x31M.js → Bp9qkJ9m.js} +1 -1
- package/.output/public/_nuxt/{BcYnCaqL.js → Bu3-sqCf.js} +1 -1
- package/.output/public/_nuxt/{C919AVYR.js → C-FtTvwz.js} +1 -1
- package/.output/public/_nuxt/C02JV0Aj.js +1 -0
- package/.output/public/_nuxt/{Bbi9UBvi.js → C1UkIsDc.js} +1 -1
- package/.output/public/_nuxt/{PXBhK7S_.js → CJT28r6J.js} +1 -1
- package/.output/public/_nuxt/{BC9tFNFa.js → CL7qtgl2.js} +3 -3
- package/.output/public/_nuxt/{B6lqezyA.js → CRMd2YH2.js} +3 -3
- package/.output/public/_nuxt/{YC-RLggm.js → CRkdQgFz.js} +1 -1
- package/.output/public/_nuxt/{iKW_mt0p.js → Cw1XFOz5.js} +1 -1
- package/.output/public/_nuxt/{d1NBz903.js → D5yWk6Ly.js} +1 -1
- package/.output/public/_nuxt/{iGzUozbF.js → DA9GjKpR.js} +1 -1
- package/.output/public/_nuxt/{JkiDMdYG.js → DaWAlZhp.js} +1 -1
- package/.output/public/_nuxt/{OVQ3C2Ge.js → DafLMUHo.js} +1 -1
- package/.output/public/_nuxt/{Bw82IGM8.js → Dyaldc-t.js} +1 -1
- package/.output/public/_nuxt/{CsQL5F-l.js → UU9fpRNQ.js} +1 -1
- package/.output/public/_nuxt/builds/latest.json +1 -1
- package/.output/public/_nuxt/builds/meta/717459d8-0da1-42ed-af0b-9ec5395e8fdc.json +1 -0
- package/.output/public/_nuxt/entry.CDPplHzk.css +1 -0
- package/.output/public/_nuxt/error-404.hPtlUQpd.css +1 -0
- package/.output/public/_nuxt/error-500.E-PXUb6B.css +1 -0
- package/.output/public/_nuxt/{DbUZZZZu.js → kFZJW2-u.js} +2 -2
- package/.output/public/_nuxt/{B8gqXD2U.js → u3DlT5Mh.js} +1 -1
- package/.output/server/chunks/_/error-500.mjs.map +1 -1
- package/.output/server/chunks/_/parse-request.mjs +29 -0
- package/.output/server/chunks/_/parse-request.mjs.map +1 -0
- package/.output/server/chunks/build/client.precomputed.mjs +1 -1
- package/.output/server/chunks/build/{error-404-KRkA0DPI.mjs → error-404-aQ5PiVuX.mjs} +6 -12
- package/.output/server/chunks/build/error-404-aQ5PiVuX.mjs.map +1 -0
- package/.output/server/chunks/build/error-404-styles.DIZfBVBR.mjs +8 -0
- package/.output/server/chunks/build/error-404-styles.DIZfBVBR.mjs.map +1 -0
- package/.output/server/chunks/build/{error-500-DIIFf55p.mjs → error-500-BY6ZAZZ2.mjs} +6 -12
- package/.output/server/chunks/build/error-500-BY6ZAZZ2.mjs.map +1 -0
- package/.output/server/chunks/build/error-500-styles.BZXgEzR5.mjs +8 -0
- package/.output/server/chunks/build/error-500-styles.BZXgEzR5.mjs.map +1 -0
- package/.output/server/chunks/build/index-57_mtIua.mjs +235 -0
- package/.output/server/chunks/build/index-57_mtIua.mjs.map +1 -0
- package/.output/server/chunks/build/{index-CB1N4gax.mjs → index-Qa-4KqCB.mjs} +7 -13
- package/.output/server/chunks/build/index-Qa-4KqCB.mjs.map +1 -0
- package/.output/server/chunks/build/server.mjs +3913 -3378
- package/.output/server/chunks/build/server.mjs.map +1 -1
- package/.output/server/chunks/build/styles.mjs +4 -4
- package/.output/server/chunks/nitro/nitro.mjs +562 -2188
- package/.output/server/chunks/nitro/nitro.mjs.map +1 -1
- package/.output/server/chunks/routes/api/editor-types.get.mjs +0 -6
- package/.output/server/chunks/routes/api/editor-types.get.mjs.map +1 -1
- package/.output/server/chunks/routes/api/parse.post.mjs +1599 -7
- package/.output/server/chunks/routes/api/parse.post.mjs.map +1 -1
- package/.output/server/chunks/routes/api/resolve.get.mjs +0 -6
- package/.output/server/chunks/routes/api/resolve.get.mjs.map +1 -1
- package/.output/server/chunks/routes/api/studio/run.post.mjs +41 -8
- package/.output/server/chunks/routes/api/studio/run.post.mjs.map +1 -1
- package/.output/server/chunks/routes/renderer.mjs +21 -44
- package/.output/server/chunks/routes/renderer.mjs.map +1 -1
- package/.output/server/index.mjs +1 -7
- package/.output/server/index.mjs.map +1 -1
- package/.output/server/node_modules/.nitro/@vue/compiler-core@3.5.43/dist/compiler-core.cjs.prod.js +6801 -0
- package/.output/server/node_modules/.nitro/@vue/compiler-core@3.5.43/package.json +58 -0
- package/.output/server/node_modules/.nitro/@vue/compiler-dom@3.5.43/dist/compiler-dom.cjs.prod.js +692 -0
- package/.output/server/node_modules/.nitro/@vue/compiler-dom@3.5.43/package.json +57 -0
- package/.output/server/node_modules/.nitro/@vue/reactivity@3.5.43/dist/reactivity.cjs.prod.js +1905 -0
- package/.output/server/node_modules/.nitro/@vue/reactivity@3.5.43/package.json +55 -0
- package/.output/server/node_modules/.nitro/@vue/runtime-core@3.5.43/dist/runtime-core.cjs.prod.js +7006 -0
- package/.output/server/node_modules/.nitro/@vue/runtime-core@3.5.43/package.json +52 -0
- package/.output/server/node_modules/.nitro/@vue/runtime-dom@3.5.43/dist/runtime-dom.cjs.prod.js +1867 -0
- package/.output/server/node_modules/.nitro/@vue/runtime-dom@3.5.43/package.json +60 -0
- package/.output/server/node_modules/.nitro/@vue/shared@3.5.43/dist/shared.cjs.prod.js +655 -0
- package/.output/server/node_modules/.nitro/@vue/shared@3.5.43/package.json +47 -0
- package/.output/server/node_modules/.nitro/source-map-js@1.2.2/lib/array-set.js +121 -0
- package/.output/server/node_modules/.nitro/source-map-js@1.2.2/lib/base64-vlq.js +140 -0
- package/.output/server/node_modules/.nitro/source-map-js@1.2.2/lib/base64.js +67 -0
- package/.output/server/node_modules/.nitro/source-map-js@1.2.2/lib/binary-search.js +111 -0
- package/.output/server/node_modules/.nitro/source-map-js@1.2.2/lib/mapping-list.js +79 -0
- package/.output/server/node_modules/.nitro/source-map-js@1.2.2/lib/quick-sort.js +141 -0
- package/.output/server/node_modules/.nitro/source-map-js@1.2.2/lib/source-map-consumer.js +1236 -0
- package/.output/server/node_modules/.nitro/source-map-js@1.2.2/lib/source-map-generator.js +446 -0
- package/.output/server/node_modules/.nitro/source-map-js@1.2.2/lib/source-node.js +420 -0
- package/.output/server/node_modules/.nitro/source-map-js@1.2.2/lib/util.js +594 -0
- package/.output/server/node_modules/.nitro/source-map-js@1.2.2/package.json +71 -0
- package/.output/server/node_modules/.nitro/source-map-js@1.2.2/source-map.js +8 -0
- package/.output/server/node_modules/.nitro/vue@3.5.43/dist/vue.cjs.js +80 -0
- package/.output/server/node_modules/.nitro/vue@3.5.43/dist/vue.cjs.prod.js +66 -0
- package/.output/server/node_modules/.nitro/vue@3.5.43/index.js +7 -0
- package/.output/server/node_modules/.nitro/vue@3.5.43/index.mjs +1 -0
- package/.output/server/node_modules/.nitro/vue@3.5.43/package.json +112 -0
- package/.output/server/node_modules/@babel/parser/lib/index.js +55 -21
- package/.output/server/node_modules/@babel/parser/package.json +7 -7
- package/.output/server/node_modules/@esbuild/linux-x64/bin/esbuild +0 -0
- package/.output/server/node_modules/@esbuild/linux-x64/package.json +1 -1
- package/.output/server/node_modules/@iconify/utils/lib/colors/index.js +19 -16
- package/.output/server/node_modules/@iconify/utils/lib/colors/keywords.js +3 -4
- package/.output/server/node_modules/@iconify/utils/lib/css/common.js +16 -16
- package/.output/server/node_modules/@iconify/utils/lib/css/format.js +1 -2
- package/.output/server/node_modules/@iconify/utils/lib/css/icon.js +11 -14
- package/.output/server/node_modules/@iconify/utils/lib/css/icons.js +13 -16
- package/.output/server/node_modules/@iconify/utils/lib/customisations/bool.js +1 -2
- package/.output/server/node_modules/@iconify/utils/lib/customisations/defaults.js +1 -3
- package/.output/server/node_modules/@iconify/utils/lib/customisations/flip.js +2 -5
- package/.output/server/node_modules/@iconify/utils/lib/customisations/merge.js +1 -3
- package/.output/server/node_modules/@iconify/utils/lib/customisations/rotate.js +4 -5
- package/.output/server/node_modules/@iconify/utils/lib/emoji/cleanup.js +1 -3
- package/.output/server/node_modules/@iconify/utils/lib/emoji/convert.js +9 -11
- package/.output/server/node_modules/@iconify/utils/lib/emoji/data.js +1 -2
- package/.output/server/node_modules/@iconify/utils/lib/emoji/format.js +1 -3
- package/.output/server/node_modules/@iconify/utils/lib/emoji/parse.js +1 -3
- package/.output/server/node_modules/@iconify/utils/lib/emoji/regex/base.js +12 -18
- package/.output/server/node_modules/@iconify/utils/lib/emoji/regex/create.js +3 -4
- package/.output/server/node_modules/@iconify/utils/lib/emoji/regex/numbers.js +5 -7
- package/.output/server/node_modules/@iconify/utils/lib/emoji/regex/similar.js +1 -8
- package/.output/server/node_modules/@iconify/utils/lib/emoji/regex/tree.js +11 -12
- package/.output/server/node_modules/@iconify/utils/lib/emoji/replace/find.js +5 -7
- package/.output/server/node_modules/@iconify/utils/lib/emoji/replace/replace.js +1 -3
- package/.output/server/node_modules/@iconify/utils/lib/emoji/test/components.js +1 -3
- package/.output/server/node_modules/@iconify/utils/lib/emoji/test/missing.js +7 -7
- package/.output/server/node_modules/@iconify/utils/lib/emoji/test/name.js +2 -4
- package/.output/server/node_modules/@iconify/utils/lib/emoji/test/parse.js +5 -9
- package/.output/server/node_modules/@iconify/utils/lib/emoji/test/similar.js +3 -5
- package/.output/server/node_modules/@iconify/utils/lib/emoji/test/tree.js +2 -4
- package/.output/server/node_modules/@iconify/utils/lib/emoji/test/variations.js +7 -8
- package/.output/server/node_modules/@iconify/utils/lib/icon/defaults.js +1 -2
- package/.output/server/node_modules/@iconify/utils/lib/icon/merge.js +1 -3
- package/.output/server/node_modules/@iconify/utils/lib/icon/name.js +3 -4
- package/.output/server/node_modules/@iconify/utils/lib/icon/square.js +1 -2
- package/.output/server/node_modules/@iconify/utils/lib/icon/transformations.js +1 -2
- package/.output/server/node_modules/@iconify/utils/lib/icon-set/convert-info.js +10 -15
- package/.output/server/node_modules/@iconify/utils/lib/icon-set/expand.js +1 -3
- package/.output/server/node_modules/@iconify/utils/lib/icon-set/get-icon.js +3 -5
- package/.output/server/node_modules/@iconify/utils/lib/icon-set/get-icons.js +1 -3
- package/.output/server/node_modules/@iconify/utils/lib/icon-set/minify.js +1 -3
- package/.output/server/node_modules/@iconify/utils/lib/icon-set/parse.js +1 -3
- package/.output/server/node_modules/@iconify/utils/lib/icon-set/tree.js +1 -2
- package/.output/server/node_modules/@iconify/utils/lib/icon-set/validate-basic.js +1 -3
- package/.output/server/node_modules/@iconify/utils/lib/icon-set/validate.js +21 -13
- package/.output/server/node_modules/@iconify/utils/lib/index.js +1 -2
- package/.output/server/node_modules/@iconify/utils/lib/loader/custom.js +3 -3
- package/.output/server/node_modules/@iconify/utils/lib/loader/hmr-utils.js +33 -0
- package/.output/server/node_modules/@iconify/utils/lib/loader/loader.js +22 -22
- package/.output/server/node_modules/@iconify/utils/lib/loader/modern.js +7 -22
- package/.output/server/node_modules/@iconify/utils/lib/loader/utils.js +60 -16
- package/.output/server/node_modules/@iconify/utils/lib/misc/objects.js +1 -2
- package/.output/server/node_modules/@iconify/utils/lib/misc/strings.js +1 -2
- package/.output/server/node_modules/@iconify/utils/lib/misc/title.js +1 -2
- package/.output/server/node_modules/@iconify/utils/lib/svg/build.js +9 -11
- package/.output/server/node_modules/@iconify/utils/lib/svg/defs.js +1 -2
- package/.output/server/node_modules/@iconify/utils/lib/svg/encode-svg-for-css.js +1 -3
- package/.output/server/node_modules/@iconify/utils/lib/svg/html.js +1 -2
- package/.output/server/node_modules/@iconify/utils/lib/svg/id.js +1 -2
- package/.output/server/node_modules/@iconify/utils/lib/svg/inner-html.js +1 -2
- package/.output/server/node_modules/@iconify/utils/lib/svg/parse.js +3 -5
- package/.output/server/node_modules/@iconify/utils/lib/svg/pretty.js +5 -4
- package/.output/server/node_modules/@iconify/utils/lib/svg/size.js +1 -2
- package/.output/server/node_modules/@iconify/utils/lib/svg/trim.js +1 -2
- package/.output/server/node_modules/@iconify/utils/lib/svg/url.js +1 -2
- package/.output/server/node_modules/@iconify/utils/lib/svg/viewbox.js +2 -3
- package/.output/server/node_modules/@iconify/utils/package.json +15 -13
- package/.output/server/node_modules/@vue/compiler-ssr/dist/compiler-ssr.cjs.js +8 -1
- package/.output/server/node_modules/@vue/compiler-ssr/package.json +3 -3
- package/.output/server/node_modules/@vue/server-renderer/dist/server-renderer.cjs.prod.js +34 -13
- package/.output/server/node_modules/@vue/server-renderer/package.json +4 -6
- package/.output/server/node_modules/devalue/index.js +15 -2
- package/.output/server/node_modules/devalue/package.json +5 -3
- package/.output/server/node_modules/devalue/src/base64.js +46 -96
- package/.output/server/node_modules/devalue/src/constants.js +5 -0
- package/.output/server/node_modules/devalue/src/operations.js +221 -0
- package/.output/server/node_modules/devalue/src/parse.js +76 -62
- package/.output/server/node_modules/devalue/src/stringify.js +164 -81
- package/.output/server/node_modules/devalue/src/uneval.js +312 -104
- package/.output/server/node_modules/devalue/src/utils.js +61 -19
- package/.output/server/node_modules/esbuild/lib/main.js +12 -8
- package/.output/server/node_modules/esbuild/package.json +50 -50
- package/.output/server/node_modules/hookable/dist/index.mjs +2 -11
- package/.output/server/node_modules/hookable/package.json +23 -22
- package/.output/server/node_modules/ip-address/dist/ipv4.js +7 -0
- package/.output/server/node_modules/ip-address/package.json +1 -1
- package/.output/server/node_modules/zod/package.json +20 -8
- package/.output/server/node_modules/zod/v4/classic/checks.js +1 -1
- package/.output/server/node_modules/zod/v4/classic/deep-partial.js +13 -0
- package/.output/server/node_modules/zod/v4/classic/errors.js +44 -35
- package/.output/server/node_modules/zod/v4/classic/external.js +5 -8
- package/.output/server/node_modules/zod/v4/classic/from-json-schema.js +375 -78
- package/.output/server/node_modules/zod/v4/classic/in-out.js +36 -0
- package/.output/server/node_modules/zod/v4/classic/index.js +2 -2
- package/.output/server/node_modules/zod/v4/classic/iso.js +2 -17
- package/.output/server/node_modules/zod/v4/classic/package.json +2 -1
- package/.output/server/node_modules/zod/v4/classic/parse.js +1 -0
- package/.output/server/node_modules/zod/v4/classic/schemas.js +601 -223
- package/.output/server/node_modules/zod/v4/core/api.js +51 -26
- package/.output/server/node_modules/zod/v4/core/checks.js +68 -127
- package/.output/server/node_modules/zod/v4/core/compile.js +1858 -0
- package/.output/server/node_modules/zod/v4/core/core.js +87 -22
- package/.output/server/node_modules/zod/v4/core/doc.js +12 -9
- package/.output/server/node_modules/zod/v4/core/errors.js +127 -42
- package/.output/server/node_modules/zod/v4/core/index.js +3 -0
- package/.output/server/node_modules/zod/v4/core/json-schema-generator.js +6 -2
- package/.output/server/node_modules/zod/v4/core/json-schema-processors.js +413 -175
- package/.output/server/node_modules/zod/v4/core/memoizer.js +311 -0
- package/.output/server/node_modules/zod/v4/core/package.json +2 -1
- package/.output/server/node_modules/zod/v4/core/parse.js +130 -48
- package/.output/server/node_modules/zod/v4/core/regexes.js +39 -16
- package/.output/server/node_modules/zod/v4/core/registries.js +2 -2
- package/.output/server/node_modules/zod/v4/core/schemas.js +895 -382
- package/.output/server/node_modules/zod/v4/core/to-json-schema.js +253 -39
- package/.output/server/node_modules/zod/v4/core/util.js +383 -175
- package/.output/server/node_modules/zod/v4/core/versions.js +2 -2
- package/.output/server/node_modules/zod/v4/core/visit.js +169 -0
- package/.output/server/node_modules/zod/v4/index.js +3 -2
- package/.output/server/node_modules/zod/v4/locales/ar.js +5 -0
- package/.output/server/node_modules/zod/v4/locales/az.js +5 -0
- package/.output/server/node_modules/zod/v4/locales/be.js +12 -0
- package/.output/server/node_modules/zod/v4/locales/bg.js +5 -0
- package/.output/server/node_modules/zod/v4/locales/bn.js +113 -0
- package/.output/server/node_modules/zod/v4/locales/ca.js +5 -0
- package/.output/server/node_modules/zod/v4/locales/ckb.js +133 -0
- package/.output/server/node_modules/zod/v4/locales/cs.js +5 -0
- package/.output/server/node_modules/zod/v4/locales/da.js +7 -2
- package/.output/server/node_modules/zod/v4/locales/de.js +5 -0
- package/.output/server/node_modules/zod/v4/locales/el.js +112 -0
- package/.output/server/node_modules/zod/v4/locales/en.js +20 -4
- package/.output/server/node_modules/zod/v4/locales/eo.js +5 -0
- package/.output/server/node_modules/zod/v4/locales/es.js +4 -0
- package/.output/server/node_modules/zod/v4/locales/fa.js +5 -0
- package/.output/server/node_modules/zod/v4/locales/fi.js +5 -0
- package/.output/server/node_modules/zod/v4/locales/fr-CA.js +5 -0
- package/.output/server/node_modules/zod/v4/locales/fr.js +38 -17
- package/.output/server/node_modules/zod/v4/locales/gu.js +113 -0
- package/.output/server/node_modules/zod/v4/locales/he.js +7 -0
- package/.output/server/node_modules/zod/v4/locales/hi.js +111 -0
- package/.output/server/node_modules/zod/v4/locales/hr.js +126 -0
- package/.output/server/node_modules/zod/v4/locales/hu.js +5 -0
- package/.output/server/node_modules/zod/v4/locales/hy.js +11 -0
- package/.output/server/node_modules/zod/v4/locales/id.js +5 -0
- package/.output/server/node_modules/zod/v4/locales/index.js +14 -0
- package/.output/server/node_modules/zod/v4/locales/is.js +5 -0
- package/.output/server/node_modules/zod/v4/locales/it.js +6 -1
- package/.output/server/node_modules/zod/v4/locales/ja.js +5 -0
- package/.output/server/node_modules/zod/v4/locales/ka.js +13 -8
- package/.output/server/node_modules/zod/v4/locales/km.js +5 -0
- package/.output/server/node_modules/zod/v4/locales/kn.js +116 -0
- package/.output/server/node_modules/zod/v4/locales/ko.js +5 -0
- package/.output/server/node_modules/zod/v4/locales/lt.js +4 -0
- package/.output/server/node_modules/zod/v4/locales/mk.js +5 -0
- package/.output/server/node_modules/zod/v4/locales/ms.js +5 -0
- package/.output/server/node_modules/zod/v4/locales/ne.js +111 -0
- package/.output/server/node_modules/zod/v4/locales/nl.js +5 -0
- package/.output/server/node_modules/zod/v4/locales/nn.js +113 -0
- package/.output/server/node_modules/zod/v4/locales/no.js +7 -2
- package/.output/server/node_modules/zod/v4/locales/ota.js +5 -0
- package/.output/server/node_modules/zod/v4/locales/package.json +2 -1
- package/.output/server/node_modules/zod/v4/locales/pl.js +5 -0
- package/.output/server/node_modules/zod/v4/locales/ps.js +5 -0
- package/.output/server/node_modules/zod/v4/locales/pt-BR.js +143 -0
- package/.output/server/node_modules/zod/v4/locales/pt.js +89 -55
- package/.output/server/node_modules/zod/v4/locales/ro.js +122 -0
- package/.output/server/node_modules/zod/v4/locales/ru.js +12 -0
- package/.output/server/node_modules/zod/v4/locales/sk.js +116 -0
- package/.output/server/node_modules/zod/v4/locales/sl.js +5 -0
- package/.output/server/node_modules/zod/v4/locales/sv.js +7 -2
- package/.output/server/node_modules/zod/v4/locales/ta.js +5 -0
- package/.output/server/node_modules/zod/v4/locales/tg.js +117 -0
- package/.output/server/node_modules/zod/v4/locales/th.js +5 -0
- package/.output/server/node_modules/zod/v4/locales/tk.js +107 -0
- package/.output/server/node_modules/zod/v4/locales/tr.js +5 -0
- package/.output/server/node_modules/zod/v4/locales/uk.js +5 -0
- package/.output/server/node_modules/zod/v4/locales/ur.js +5 -0
- package/.output/server/node_modules/zod/v4/locales/uz.js +4 -0
- package/.output/server/node_modules/zod/v4/locales/vi.js +5 -0
- package/.output/server/node_modules/zod/v4/locales/yo.js +5 -0
- package/.output/server/node_modules/zod/v4/locales/zh-CN.js +5 -0
- package/.output/server/node_modules/zod/v4/locales/zh-TW.js +5 -0
- package/.output/server/node_modules/zod/v4/package.json +2 -1
- package/.output/server/package.json +18 -18
- package/README.md +9 -0
- package/package.json +8 -8
- package/.output/public/_nuxt/Czp4_2o-.js +0 -33
- package/.output/public/_nuxt/builds/meta/46174b5e-cab6-4a73-95f8-66a1c9b1be2b.json +0 -1
- package/.output/public/_nuxt/entry.DaqrxXuH.css +0 -1
- package/.output/public/_nuxt/error-404.CTSXlFYa.css +0 -1
- package/.output/public/_nuxt/error-500.DqEfQnVZ.css +0 -1
- package/.output/server/chunks/build/error-404-KRkA0DPI.mjs.map +0 -1
- package/.output/server/chunks/build/error-404-styles.I0NYw-Bn.mjs +0 -8
- package/.output/server/chunks/build/error-404-styles.I0NYw-Bn.mjs.map +0 -1
- package/.output/server/chunks/build/error-500-DIIFf55p.mjs.map +0 -1
- package/.output/server/chunks/build/error-500-styles.D1cs9hQy.mjs +0 -8
- package/.output/server/chunks/build/error-500-styles.D1cs9hQy.mjs.map +0 -1
- package/.output/server/chunks/build/index-CB1N4gax.mjs.map +0 -1
- /package/.output/server/node_modules/{@vue/compiler-core → .nitro/@vue/compiler-core@3.5.32}/dist/compiler-core.cjs.prod.js +0 -0
- /package/.output/server/node_modules/{@vue/compiler-core → .nitro/@vue/compiler-core@3.5.32}/package.json +0 -0
- /package/.output/server/node_modules/{@vue/compiler-dom → .nitro/@vue/compiler-dom@3.5.32}/dist/compiler-dom.cjs.prod.js +0 -0
- /package/.output/server/node_modules/{@vue/compiler-dom → .nitro/@vue/compiler-dom@3.5.32}/package.json +0 -0
- /package/.output/server/node_modules/{@vue/reactivity → .nitro/@vue/reactivity@3.5.32}/dist/reactivity.cjs.prod.js +0 -0
- /package/.output/server/node_modules/{@vue/reactivity → .nitro/@vue/reactivity@3.5.32}/package.json +0 -0
- /package/.output/server/node_modules/{@vue/runtime-core → .nitro/@vue/runtime-core@3.5.32}/dist/runtime-core.cjs.prod.js +0 -0
- /package/.output/server/node_modules/{@vue/runtime-core → .nitro/@vue/runtime-core@3.5.32}/package.json +0 -0
- /package/.output/server/node_modules/{@vue/runtime-dom → .nitro/@vue/runtime-dom@3.5.32}/dist/runtime-dom.cjs.prod.js +0 -0
- /package/.output/server/node_modules/{@vue/runtime-dom → .nitro/@vue/runtime-dom@3.5.32}/package.json +0 -0
- /package/.output/server/node_modules/{@vue/shared → .nitro/@vue/shared@3.5.32}/dist/shared.cjs.prod.js +0 -0
- /package/.output/server/node_modules/{@vue/shared → .nitro/@vue/shared@3.5.32}/package.json +0 -0
- /package/.output/server/node_modules/{source-map-js → .nitro/source-map-js@1.2.1}/lib/array-set.js +0 -0
- /package/.output/server/node_modules/{source-map-js → .nitro/source-map-js@1.2.1}/lib/base64-vlq.js +0 -0
- /package/.output/server/node_modules/{source-map-js → .nitro/source-map-js@1.2.1}/lib/base64.js +0 -0
- /package/.output/server/node_modules/{source-map-js → .nitro/source-map-js@1.2.1}/lib/binary-search.js +0 -0
- /package/.output/server/node_modules/{source-map-js → .nitro/source-map-js@1.2.1}/lib/mapping-list.js +0 -0
- /package/.output/server/node_modules/{source-map-js → .nitro/source-map-js@1.2.1}/lib/quick-sort.js +0 -0
- /package/.output/server/node_modules/{source-map-js → .nitro/source-map-js@1.2.1}/lib/source-map-consumer.js +0 -0
- /package/.output/server/node_modules/{source-map-js → .nitro/source-map-js@1.2.1}/lib/source-map-generator.js +0 -0
- /package/.output/server/node_modules/{source-map-js → .nitro/source-map-js@1.2.1}/lib/source-node.js +0 -0
- /package/.output/server/node_modules/{source-map-js → .nitro/source-map-js@1.2.1}/lib/util.js +0 -0
- /package/.output/server/node_modules/{source-map-js → .nitro/source-map-js@1.2.1}/package.json +0 -0
- /package/.output/server/node_modules/{source-map-js → .nitro/source-map-js@1.2.1}/source-map.js +0 -0
- /package/.output/server/node_modules/{vue → .nitro/vue@3.5.32}/dist/vue.cjs.js +0 -0
- /package/.output/server/node_modules/{vue → .nitro/vue@3.5.32}/dist/vue.cjs.prod.js +0 -0
- /package/.output/server/node_modules/{vue → .nitro/vue@3.5.32}/index.js +0 -0
- /package/.output/server/node_modules/{vue → .nitro/vue@3.5.32}/index.mjs +0 -0
- /package/.output/server/node_modules/{vue → .nitro/vue@3.5.32}/package.json +0 -0
- /package/.output/server/node_modules/{vue → .nitro/vue@3.5.43}/server-renderer/index.mjs +0 -0
|
@@ -1,5 +1,100 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
1
|
+
import * as regexes from "./regexes.js";
|
|
2
|
+
import { base64Charset, base64urlCharset } from "./schemas.js";
|
|
3
|
+
import { extractDefs, finalize, handleUnrepresentable, initializeContext, processSchema, } from "./to-json-schema.js";
|
|
4
|
+
import { BIGINT_FORMAT_RANGES, NUMBER_FORMAT_RANGES, assignProp, getEnumValues } from "./util.js";
|
|
5
|
+
const narrowMin = (agg, key, value) => {
|
|
6
|
+
if (agg[key] === undefined || value > agg[key])
|
|
7
|
+
agg[key] = value;
|
|
8
|
+
};
|
|
9
|
+
const narrowMax = (agg, key, value) => {
|
|
10
|
+
if (agg[key] === undefined || value < agg[key])
|
|
11
|
+
agg[key] = value;
|
|
12
|
+
};
|
|
13
|
+
const narrowBoth = (agg, value) => {
|
|
14
|
+
narrowMin(agg, "minimum", value);
|
|
15
|
+
narrowMax(agg, "maximum", value);
|
|
16
|
+
};
|
|
17
|
+
const addDivisor = (agg, value) => {
|
|
18
|
+
agg.multipleOf ?? (agg.multipleOf = []);
|
|
19
|
+
if (!agg.multipleOf.includes(value))
|
|
20
|
+
agg.multipleOf.push(value);
|
|
21
|
+
};
|
|
22
|
+
const addPattern = (agg, pattern) => {
|
|
23
|
+
agg.patterns ?? (agg.patterns = new Set());
|
|
24
|
+
agg.patterns.add(pattern);
|
|
25
|
+
};
|
|
26
|
+
const intersectMime = (agg, mime) => {
|
|
27
|
+
agg.mime = agg.mime ? agg.mime.filter((m) => mime.includes(m)) : [...mime];
|
|
28
|
+
};
|
|
29
|
+
// last-wins, matching the bag's historical write order; the flag keeps an integer format from being lost to a later float one
|
|
30
|
+
const setFormat = (agg, format) => {
|
|
31
|
+
agg.format = format;
|
|
32
|
+
if (format.includes("int"))
|
|
33
|
+
agg.isInt = true;
|
|
34
|
+
};
|
|
35
|
+
const minContributor = (agg, def) => narrowMin(agg, "minimum", def.minimum);
|
|
36
|
+
const maxContributor = (agg, def) => narrowMax(agg, "maximum", def.maximum);
|
|
37
|
+
const formatContributor = (ranges) => (agg, def) => {
|
|
38
|
+
setFormat(agg, def.format);
|
|
39
|
+
const [minimum, maximum] = ranges[def.format];
|
|
40
|
+
narrowMin(agg, "minimum", minimum);
|
|
41
|
+
narrowMax(agg, "maximum", maximum);
|
|
42
|
+
};
|
|
43
|
+
const contributors = {
|
|
44
|
+
greater_than: (agg, def) => narrowMin(agg, def.inclusive ? "minimum" : "exclusiveMinimum", def.value),
|
|
45
|
+
less_than: (agg, def) => narrowMax(agg, def.inclusive ? "maximum" : "exclusiveMaximum", def.value),
|
|
46
|
+
multiple_of: (agg, def) => addDivisor(agg, def.value),
|
|
47
|
+
number_format: formatContributor(NUMBER_FORMAT_RANGES),
|
|
48
|
+
bigint_format: formatContributor(BIGINT_FORMAT_RANGES),
|
|
49
|
+
min_length: minContributor,
|
|
50
|
+
max_length: maxContributor,
|
|
51
|
+
length_equals: (agg, def) => narrowBoth(agg, def.length),
|
|
52
|
+
min_size: minContributor,
|
|
53
|
+
max_size: maxContributor,
|
|
54
|
+
size_equals: (agg, def) => narrowBoth(agg, def.size),
|
|
55
|
+
string_format: (agg, def) => {
|
|
56
|
+
setFormat(agg, def.format);
|
|
57
|
+
if (def.pattern)
|
|
58
|
+
addPattern(agg, def.pattern);
|
|
59
|
+
if (def.format === "base64" || def.format === "base64url")
|
|
60
|
+
agg.contentEncoding = def.format;
|
|
61
|
+
if (def.local || def.precision === -1)
|
|
62
|
+
agg.laxFormat = true;
|
|
63
|
+
},
|
|
64
|
+
mime_type: (agg, def) => intersectMime(agg, def.mime),
|
|
65
|
+
};
|
|
66
|
+
export function aggregateChecks(schema) {
|
|
67
|
+
const agg = {};
|
|
68
|
+
const def = schema._zod.def;
|
|
69
|
+
// a format schema is its own first check, same rule as $ZodType init
|
|
70
|
+
const list = schema._zod.traits.has("$ZodCheck")
|
|
71
|
+
? [schema, ...(def.checks ?? [])]
|
|
72
|
+
: (def.checks ?? []);
|
|
73
|
+
for (const ch of list)
|
|
74
|
+
contributors[ch._zod.def.check]?.(agg, ch._zod.def);
|
|
75
|
+
// reconcile with the bag so third-party onattach contributions still land; first-party residue is never tighter than the fold, so merging it back is idempotent for one and additive for the other
|
|
76
|
+
const bag = schema._zod.bag;
|
|
77
|
+
if (bag.minimum !== undefined)
|
|
78
|
+
narrowMin(agg, "minimum", bag.minimum);
|
|
79
|
+
if (bag.exclusiveMinimum !== undefined)
|
|
80
|
+
narrowMin(agg, "exclusiveMinimum", bag.exclusiveMinimum);
|
|
81
|
+
if (bag.maximum !== undefined)
|
|
82
|
+
narrowMax(agg, "maximum", bag.maximum);
|
|
83
|
+
if (bag.exclusiveMaximum !== undefined)
|
|
84
|
+
narrowMax(agg, "exclusiveMaximum", bag.exclusiveMaximum);
|
|
85
|
+
if (bag.multipleOf !== undefined)
|
|
86
|
+
addDivisor(agg, bag.multipleOf);
|
|
87
|
+
if (bag.format !== undefined) {
|
|
88
|
+
agg.format ?? (agg.format = bag.format);
|
|
89
|
+
if (bag.format.includes("int"))
|
|
90
|
+
agg.isInt = true;
|
|
91
|
+
}
|
|
92
|
+
if (bag.mime)
|
|
93
|
+
intersectMime(agg, bag.mime);
|
|
94
|
+
for (const pattern of bag.patterns ?? [])
|
|
95
|
+
addPattern(agg, pattern);
|
|
96
|
+
return agg;
|
|
97
|
+
}
|
|
3
98
|
const formatMap = {
|
|
4
99
|
guid: "uuid",
|
|
5
100
|
url: "uri",
|
|
@@ -8,11 +103,16 @@ const formatMap = {
|
|
|
8
103
|
regex: "", // do not set
|
|
9
104
|
};
|
|
10
105
|
// ==================== SIMPLE TYPE PROCESSORS ====================
|
|
106
|
+
// the runtime patterns are lax so parse paths never overflow the regex stack; the emitted schema swaps in the exact block forms, which zod itself never executes
|
|
107
|
+
const exactPatterns = new Map([
|
|
108
|
+
[base64Charset, regexes.base64],
|
|
109
|
+
[base64urlCharset, regexes.base64url],
|
|
110
|
+
]);
|
|
111
|
+
const exactPattern = (p) => exactPatterns.get(p) ?? p;
|
|
11
112
|
export const stringProcessor = (schema, ctx, _json, _params) => {
|
|
12
113
|
const json = _json;
|
|
13
114
|
json.type = "string";
|
|
14
|
-
const { minimum, maximum, format, patterns, contentEncoding } = schema
|
|
15
|
-
.bag;
|
|
115
|
+
const { minimum, maximum, format, patterns, contentEncoding, laxFormat } = aggregateChecks(schema);
|
|
16
116
|
if (typeof minimum === "number")
|
|
17
117
|
json.minLength = minimum;
|
|
18
118
|
if (typeof maximum === "number")
|
|
@@ -22,21 +122,20 @@ export const stringProcessor = (schema, ctx, _json, _params) => {
|
|
|
22
122
|
json.format = formatMap[format] ?? format;
|
|
23
123
|
if (json.format === "")
|
|
24
124
|
delete json.format; // empty format is not valid
|
|
25
|
-
//
|
|
26
|
-
|
|
27
|
-
if (format === "time") {
|
|
125
|
+
// `z.iso.time()` is never full-time, and `laxFormat` carries the datetime shapes that also accept what their keyword forbids
|
|
126
|
+
if (format === "time" || laxFormat) {
|
|
28
127
|
delete json.format;
|
|
29
128
|
}
|
|
30
129
|
}
|
|
31
130
|
if (contentEncoding)
|
|
32
131
|
json.contentEncoding = contentEncoding;
|
|
33
132
|
if (patterns && patterns.size > 0) {
|
|
34
|
-
const
|
|
35
|
-
if (
|
|
36
|
-
json.pattern =
|
|
37
|
-
else if (
|
|
133
|
+
const patternList = [...patterns].map(exactPattern);
|
|
134
|
+
if (patternList.length === 1)
|
|
135
|
+
json.pattern = patternList[0].source;
|
|
136
|
+
else if (patternList.length > 1) {
|
|
38
137
|
json.allOf = [
|
|
39
|
-
...
|
|
138
|
+
...patternList.map((regex) => ({
|
|
40
139
|
...(ctx.target === "draft-07" || ctx.target === "draft-04" || ctx.target === "openapi-3.0"
|
|
41
140
|
? { type: "string" }
|
|
42
141
|
: {}),
|
|
@@ -46,15 +145,16 @@ export const stringProcessor = (schema, ctx, _json, _params) => {
|
|
|
46
145
|
}
|
|
47
146
|
}
|
|
48
147
|
};
|
|
49
|
-
export const numberProcessor = (schema, ctx, _json,
|
|
148
|
+
export const numberProcessor = (schema, ctx, _json, params) => {
|
|
50
149
|
const json = _json;
|
|
51
|
-
const { minimum, maximum,
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
150
|
+
const { minimum, maximum, multipleOf, exclusiveMaximum, exclusiveMinimum, isInt } = aggregateChecks(schema);
|
|
151
|
+
json.type = isInt ? "integer" : "number";
|
|
152
|
+
// when both minimum and exclusiveMinimum exist, pick the more restrictive one
|
|
153
|
+
const exMin = typeof exclusiveMinimum === "number" && exclusiveMinimum >= (minimum ?? Number.NEGATIVE_INFINITY);
|
|
154
|
+
const exMax = typeof exclusiveMaximum === "number" && exclusiveMaximum <= (maximum ?? Number.POSITIVE_INFINITY);
|
|
155
|
+
const legacy = ctx.target === "draft-04" || ctx.target === "openapi-3.0";
|
|
156
|
+
if (exMin) {
|
|
157
|
+
if (legacy) {
|
|
58
158
|
json.minimum = exclusiveMinimum;
|
|
59
159
|
json.exclusiveMinimum = true;
|
|
60
160
|
}
|
|
@@ -62,17 +162,11 @@ export const numberProcessor = (schema, ctx, _json, _params) => {
|
|
|
62
162
|
json.exclusiveMinimum = exclusiveMinimum;
|
|
63
163
|
}
|
|
64
164
|
}
|
|
65
|
-
if (typeof minimum === "number") {
|
|
165
|
+
else if (typeof minimum === "number") {
|
|
66
166
|
json.minimum = minimum;
|
|
67
|
-
if (typeof exclusiveMinimum === "number" && ctx.target !== "draft-04") {
|
|
68
|
-
if (exclusiveMinimum >= minimum)
|
|
69
|
-
delete json.minimum;
|
|
70
|
-
else
|
|
71
|
-
delete json.exclusiveMinimum;
|
|
72
|
-
}
|
|
73
167
|
}
|
|
74
|
-
if (
|
|
75
|
-
if (
|
|
168
|
+
if (exMax) {
|
|
169
|
+
if (legacy) {
|
|
76
170
|
json.maximum = exclusiveMaximum;
|
|
77
171
|
json.exclusiveMaximum = true;
|
|
78
172
|
}
|
|
@@ -80,30 +174,34 @@ export const numberProcessor = (schema, ctx, _json, _params) => {
|
|
|
80
174
|
json.exclusiveMaximum = exclusiveMaximum;
|
|
81
175
|
}
|
|
82
176
|
}
|
|
83
|
-
if (typeof maximum === "number") {
|
|
177
|
+
else if (typeof maximum === "number") {
|
|
84
178
|
json.maximum = maximum;
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
179
|
+
}
|
|
180
|
+
if (multipleOf) {
|
|
181
|
+
// JSON Schema requires a divisor strictly greater than zero, and a non-finite one does not survive JSON at all. A negative divisor accepts exactly what its absolute value accepts, so it still maps; zero, NaN and Infinity have no keyword form.
|
|
182
|
+
const divisors = new Set();
|
|
183
|
+
for (const divisor of multipleOf) {
|
|
184
|
+
if (Number.isFinite(divisor) && divisor !== 0)
|
|
185
|
+
divisors.add(Math.abs(divisor));
|
|
88
186
|
else
|
|
89
|
-
|
|
187
|
+
handleUnrepresentable(schema, ctx, json, params, `A multipleOf divisor of ${divisor} cannot be represented in JSON Schema`);
|
|
90
188
|
}
|
|
189
|
+
// chained divisors are a conjunction the keyword cannot carry alone, so extras ride an allOf, same as stacked patterns
|
|
190
|
+
const [first, ...rest] = divisors;
|
|
191
|
+
if (first !== undefined)
|
|
192
|
+
json.multipleOf = first;
|
|
193
|
+
if (rest.length)
|
|
194
|
+
json.allOf = [...(json.allOf ?? []), ...rest.map((m) => ({ multipleOf: m }))];
|
|
91
195
|
}
|
|
92
|
-
if (typeof multipleOf === "number")
|
|
93
|
-
json.multipleOf = multipleOf;
|
|
94
196
|
};
|
|
95
197
|
export const booleanProcessor = (_schema, _ctx, json, _params) => {
|
|
96
198
|
json.type = "boolean";
|
|
97
199
|
};
|
|
98
|
-
export const bigintProcessor = (
|
|
99
|
-
|
|
100
|
-
throw new Error("BigInt cannot be represented in JSON Schema");
|
|
101
|
-
}
|
|
200
|
+
export const bigintProcessor = (schema, ctx, json, params) => {
|
|
201
|
+
handleUnrepresentable(schema, ctx, json, params, "BigInt cannot be represented in JSON Schema");
|
|
102
202
|
};
|
|
103
|
-
export const symbolProcessor = (
|
|
104
|
-
|
|
105
|
-
throw new Error("Symbols cannot be represented in JSON Schema");
|
|
106
|
-
}
|
|
203
|
+
export const symbolProcessor = (schema, ctx, json, params) => {
|
|
204
|
+
handleUnrepresentable(schema, ctx, json, params, "Symbols cannot be represented in JSON Schema");
|
|
107
205
|
};
|
|
108
206
|
export const nullProcessor = (_schema, ctx, json, _params) => {
|
|
109
207
|
if (ctx.target === "openapi-3.0") {
|
|
@@ -115,15 +213,11 @@ export const nullProcessor = (_schema, ctx, json, _params) => {
|
|
|
115
213
|
json.type = "null";
|
|
116
214
|
}
|
|
117
215
|
};
|
|
118
|
-
export const undefinedProcessor = (
|
|
119
|
-
|
|
120
|
-
throw new Error("Undefined cannot be represented in JSON Schema");
|
|
121
|
-
}
|
|
216
|
+
export const undefinedProcessor = (schema, ctx, json, params) => {
|
|
217
|
+
handleUnrepresentable(schema, ctx, json, params, "Undefined cannot be represented in JSON Schema");
|
|
122
218
|
};
|
|
123
|
-
export const voidProcessor = (
|
|
124
|
-
|
|
125
|
-
throw new Error("Void cannot be represented in JSON Schema");
|
|
126
|
-
}
|
|
219
|
+
export const voidProcessor = (schema, ctx, json, params) => {
|
|
220
|
+
handleUnrepresentable(schema, ctx, json, params, "Void cannot be represented in JSON Schema");
|
|
127
221
|
};
|
|
128
222
|
export const neverProcessor = (_schema, _ctx, json, _params) => {
|
|
129
223
|
json.not = {};
|
|
@@ -134,14 +228,17 @@ export const anyProcessor = (_schema, _ctx, _json, _params) => {
|
|
|
134
228
|
export const unknownProcessor = (_schema, _ctx, _json, _params) => {
|
|
135
229
|
// empty schema accepts anything
|
|
136
230
|
};
|
|
137
|
-
export const dateProcessor = (
|
|
138
|
-
|
|
139
|
-
throw new Error("Date cannot be represented in JSON Schema");
|
|
140
|
-
}
|
|
231
|
+
export const dateProcessor = (schema, ctx, json, params) => {
|
|
232
|
+
handleUnrepresentable(schema, ctx, json, params, "Date cannot be represented in JSON Schema");
|
|
141
233
|
};
|
|
142
234
|
export const enumProcessor = (schema, _ctx, json, _params) => {
|
|
143
235
|
const def = schema._zod.def;
|
|
144
236
|
const values = getEnumValues(def.entries);
|
|
237
|
+
// an empty enum accepts nothing, same as z.never()
|
|
238
|
+
if (values.length === 0) {
|
|
239
|
+
json.not = {};
|
|
240
|
+
return;
|
|
241
|
+
}
|
|
145
242
|
// Number enums can have both string and number values
|
|
146
243
|
if (values.every((v) => typeof v === "number"))
|
|
147
244
|
json.type = "number";
|
|
@@ -149,25 +246,25 @@ export const enumProcessor = (schema, _ctx, json, _params) => {
|
|
|
149
246
|
json.type = "string";
|
|
150
247
|
json.enum = values;
|
|
151
248
|
};
|
|
152
|
-
export const literalProcessor = (schema, ctx, json,
|
|
249
|
+
export const literalProcessor = (schema, ctx, json, params) => {
|
|
153
250
|
const def = schema._zod.def;
|
|
251
|
+
// a literal with no values accepts nothing, same as z.never()
|
|
252
|
+
if (def.values.length === 0) {
|
|
253
|
+
json.not = {};
|
|
254
|
+
return;
|
|
255
|
+
}
|
|
154
256
|
const vals = [];
|
|
155
257
|
for (const val of def.values) {
|
|
156
258
|
if (val === undefined) {
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
// do not add to vals
|
|
162
|
-
}
|
|
259
|
+
// a custom schema replaces the whole literal, so there is nothing left to accumulate
|
|
260
|
+
if (handleUnrepresentable(schema, ctx, json, params, "Literal `undefined` cannot be represented in JSON Schema"))
|
|
261
|
+
return;
|
|
262
|
+
// otherwise do not add to vals
|
|
163
263
|
}
|
|
164
264
|
else if (typeof val === "bigint") {
|
|
165
|
-
if (ctx
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
else {
|
|
169
|
-
vals.push(Number(val));
|
|
170
|
-
}
|
|
265
|
+
if (handleUnrepresentable(schema, ctx, json, params, "BigInt literals cannot be represented in JSON Schema"))
|
|
266
|
+
return;
|
|
267
|
+
vals.push(Number(val));
|
|
171
268
|
}
|
|
172
269
|
else {
|
|
173
270
|
vals.push(val);
|
|
@@ -198,10 +295,8 @@ export const literalProcessor = (schema, ctx, json, _params) => {
|
|
|
198
295
|
json.enum = vals;
|
|
199
296
|
}
|
|
200
297
|
};
|
|
201
|
-
export const nanProcessor = (
|
|
202
|
-
|
|
203
|
-
throw new Error("NaN cannot be represented in JSON Schema");
|
|
204
|
-
}
|
|
298
|
+
export const nanProcessor = (schema, ctx, json, params) => {
|
|
299
|
+
handleUnrepresentable(schema, ctx, json, params, "NaN cannot be represented in JSON Schema");
|
|
205
300
|
};
|
|
206
301
|
export const templateLiteralProcessor = (schema, _ctx, json, _params) => {
|
|
207
302
|
const _json = json;
|
|
@@ -213,95 +308,102 @@ export const templateLiteralProcessor = (schema, _ctx, json, _params) => {
|
|
|
213
308
|
};
|
|
214
309
|
export const fileProcessor = (schema, _ctx, json, _params) => {
|
|
215
310
|
const _json = json;
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
};
|
|
221
|
-
const { minimum, maximum, mime } = schema._zod.bag;
|
|
311
|
+
_json.type = "string";
|
|
312
|
+
_json.format = "binary";
|
|
313
|
+
_json.contentEncoding = "binary";
|
|
314
|
+
const { minimum, maximum, mime } = aggregateChecks(schema);
|
|
222
315
|
if (minimum !== undefined)
|
|
223
|
-
|
|
316
|
+
_json.minLength = minimum;
|
|
224
317
|
if (maximum !== undefined)
|
|
225
|
-
|
|
226
|
-
if (mime)
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
}
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
else {
|
|
237
|
-
Object.assign(_json, file);
|
|
238
|
-
}
|
|
318
|
+
_json.maxLength = maximum;
|
|
319
|
+
if (!mime)
|
|
320
|
+
return;
|
|
321
|
+
// an empty intersection means the mime checks share no value, so nothing passes at runtime; `anyOf` must be non-empty, so the false schema is `not: {}`
|
|
322
|
+
if (mime.length === 0)
|
|
323
|
+
_json.not = {};
|
|
324
|
+
else if (mime.length === 1)
|
|
325
|
+
_json.contentMediaType = mime[0];
|
|
326
|
+
// only contentMediaType differs, so the shared props stay at the root
|
|
327
|
+
else
|
|
328
|
+
_json.anyOf = mime.map((m) => ({ contentMediaType: m }));
|
|
239
329
|
};
|
|
240
330
|
export const successProcessor = (_schema, _ctx, json, _params) => {
|
|
241
331
|
json.type = "boolean";
|
|
242
332
|
};
|
|
243
|
-
export const customProcessor = (
|
|
244
|
-
|
|
245
|
-
throw new Error("Custom types cannot be represented in JSON Schema");
|
|
246
|
-
}
|
|
333
|
+
export const customProcessor = (schema, ctx, json, params) => {
|
|
334
|
+
handleUnrepresentable(schema, ctx, json, params, "Custom types cannot be represented in JSON Schema");
|
|
247
335
|
};
|
|
248
|
-
export const functionProcessor = (
|
|
249
|
-
|
|
250
|
-
throw new Error("Function types cannot be represented in JSON Schema");
|
|
251
|
-
}
|
|
336
|
+
export const functionProcessor = (schema, ctx, json, params) => {
|
|
337
|
+
handleUnrepresentable(schema, ctx, json, params, "Function types cannot be represented in JSON Schema");
|
|
252
338
|
};
|
|
253
|
-
export const transformProcessor = (
|
|
254
|
-
|
|
255
|
-
throw new Error("Transforms cannot be represented in JSON Schema");
|
|
256
|
-
}
|
|
339
|
+
export const transformProcessor = (schema, ctx, json, params) => {
|
|
340
|
+
handleUnrepresentable(schema, ctx, json, params, "Transforms cannot be represented in JSON Schema");
|
|
257
341
|
};
|
|
258
|
-
export const mapProcessor = (
|
|
259
|
-
|
|
260
|
-
throw new Error("Map cannot be represented in JSON Schema");
|
|
261
|
-
}
|
|
342
|
+
export const mapProcessor = (schema, ctx, json, params) => {
|
|
343
|
+
handleUnrepresentable(schema, ctx, json, params, "Map cannot be represented in JSON Schema");
|
|
262
344
|
};
|
|
263
|
-
export const setProcessor = (
|
|
264
|
-
|
|
265
|
-
throw new Error("Set cannot be represented in JSON Schema");
|
|
266
|
-
}
|
|
345
|
+
export const setProcessor = (schema, ctx, json, params) => {
|
|
346
|
+
handleUnrepresentable(schema, ctx, json, params, "Set cannot be represented in JSON Schema");
|
|
267
347
|
};
|
|
268
348
|
// ==================== COMPOSITE TYPE PROCESSORS ====================
|
|
269
349
|
export const arrayProcessor = (schema, ctx, _json, params) => {
|
|
270
350
|
const json = _json;
|
|
271
351
|
const def = schema._zod.def;
|
|
272
|
-
const { minimum, maximum } = schema
|
|
352
|
+
const { minimum, maximum } = aggregateChecks(schema);
|
|
273
353
|
if (typeof minimum === "number")
|
|
274
354
|
json.minItems = minimum;
|
|
275
355
|
if (typeof maximum === "number")
|
|
276
356
|
json.maxItems = maximum;
|
|
277
357
|
json.type = "array";
|
|
278
|
-
json.items =
|
|
358
|
+
json.items = processSchema(def.element, ctx, {
|
|
359
|
+
...params,
|
|
360
|
+
path: [...params.path, "items"],
|
|
361
|
+
});
|
|
279
362
|
};
|
|
363
|
+
// Transform and catch set `optin = "optional"` at runtime so the parser lets them observe an
|
|
364
|
+
// absent key, but their declared input type stays required. An input JSON Schema describes the
|
|
365
|
+
// declared type, so resolve past them to the schema that actually carries the optionality.
|
|
366
|
+
// Used by both `objectProcessor` (for `required`) and `tupleProcessor` (for `minItems`); see
|
|
367
|
+
// wiki/optionality.md, "The JSON Schema emitter reads the *static* value".
|
|
368
|
+
function inputOptin(schema) {
|
|
369
|
+
const def = schema._zod.def;
|
|
370
|
+
if (def.type === "pipe" && def.in._zod.traits.has("$ZodTransform")) {
|
|
371
|
+
return inputOptin(def.out);
|
|
372
|
+
}
|
|
373
|
+
if (def.type === "catch") {
|
|
374
|
+
return inputOptin(def.innerType);
|
|
375
|
+
}
|
|
376
|
+
return schema._zod.optin;
|
|
377
|
+
}
|
|
280
378
|
export const objectProcessor = (schema, ctx, _json, params) => {
|
|
281
379
|
const json = _json;
|
|
282
380
|
const def = schema._zod.def;
|
|
381
|
+
const shape = def.shape;
|
|
382
|
+
// dropping it while still emitting `additionalProperties: false` would emit a schema that rejects data this one requires
|
|
383
|
+
const symbolKeys = Object.getOwnPropertySymbols(shape);
|
|
384
|
+
if (symbolKeys.length &&
|
|
385
|
+
handleUnrepresentable(schema, ctx, json, params, "Symbol keys cannot be represented in JSON Schema")) {
|
|
386
|
+
return;
|
|
387
|
+
}
|
|
283
388
|
json.type = "object";
|
|
284
389
|
json.properties = {};
|
|
285
|
-
const shape = def.shape;
|
|
286
390
|
for (const key in shape) {
|
|
287
|
-
|
|
391
|
+
// assignProp so a __proto__ key becomes an own property instead of hitting the inherited setter on the plain {} we build into
|
|
392
|
+
assignProp(json.properties, key, processSchema(shape[key], ctx, {
|
|
288
393
|
...params,
|
|
289
394
|
path: [...params.path, "properties", key],
|
|
290
|
-
});
|
|
395
|
+
}));
|
|
291
396
|
}
|
|
292
397
|
// required keys
|
|
293
|
-
const
|
|
294
|
-
const
|
|
295
|
-
const
|
|
296
|
-
if (ctx.io === "input") {
|
|
297
|
-
|
|
298
|
-
}
|
|
299
|
-
else {
|
|
300
|
-
return v.optout === undefined;
|
|
398
|
+
const requiredKeys = [];
|
|
399
|
+
for (const key of Object.keys(shape)) {
|
|
400
|
+
const field = def.shape[key];
|
|
401
|
+
if (ctx.io === "input" ? inputOptin(field) === undefined : field._zod.optout === undefined) {
|
|
402
|
+
requiredKeys.push(key);
|
|
301
403
|
}
|
|
302
|
-
}
|
|
303
|
-
if (requiredKeys.
|
|
304
|
-
json.required =
|
|
404
|
+
}
|
|
405
|
+
if (requiredKeys.length > 0) {
|
|
406
|
+
json.required = requiredKeys;
|
|
305
407
|
}
|
|
306
408
|
// catchall
|
|
307
409
|
if (def.catchall?._zod.def.type === "never") {
|
|
@@ -314,7 +416,7 @@ export const objectProcessor = (schema, ctx, _json, params) => {
|
|
|
314
416
|
json.additionalProperties = false;
|
|
315
417
|
}
|
|
316
418
|
else if (def.catchall) {
|
|
317
|
-
json.additionalProperties =
|
|
419
|
+
json.additionalProperties = processSchema(def.catchall, ctx, {
|
|
318
420
|
...params,
|
|
319
421
|
path: [...params.path, "additionalProperties"],
|
|
320
422
|
});
|
|
@@ -322,10 +424,9 @@ export const objectProcessor = (schema, ctx, _json, params) => {
|
|
|
322
424
|
};
|
|
323
425
|
export const unionProcessor = (schema, ctx, json, params) => {
|
|
324
426
|
const def = schema._zod.def;
|
|
325
|
-
// Exclusive unions (inclusive === false) use oneOf (exactly one match) instead of anyOf (one or more matches)
|
|
326
|
-
// This includes both z.xor() and discriminated unions
|
|
427
|
+
// Exclusive unions (inclusive === false) use oneOf (exactly one match) instead of anyOf (one or more matches). This includes both z.xor() and discriminated unions
|
|
327
428
|
const isExclusive = def.inclusive === false;
|
|
328
|
-
const options = def.options.map((x, i) =>
|
|
429
|
+
const options = def.options.map((x, i) => processSchema(x, ctx, {
|
|
329
430
|
...params,
|
|
330
431
|
path: [...params.path, isExclusive ? "oneOf" : "anyOf", i],
|
|
331
432
|
}));
|
|
@@ -338,11 +439,11 @@ export const unionProcessor = (schema, ctx, json, params) => {
|
|
|
338
439
|
};
|
|
339
440
|
export const intersectionProcessor = (schema, ctx, json, params) => {
|
|
340
441
|
const def = schema._zod.def;
|
|
341
|
-
const a =
|
|
442
|
+
const a = processSchema(def.left, ctx, {
|
|
342
443
|
...params,
|
|
343
444
|
path: [...params.path, "allOf", 0],
|
|
344
445
|
});
|
|
345
|
-
const b =
|
|
446
|
+
const b = processSchema(def.right, ctx, {
|
|
346
447
|
...params,
|
|
347
448
|
path: [...params.path, "allOf", 1],
|
|
348
449
|
});
|
|
@@ -352,6 +453,8 @@ export const intersectionProcessor = (schema, ctx, json, params) => {
|
|
|
352
453
|
...(isSimpleIntersection(b) ? b.allOf : [b]),
|
|
353
454
|
];
|
|
354
455
|
json.allOf = allOf;
|
|
456
|
+
// Recorded innermost first, so a nested intersection has already folded by the time this one is considered. The array is the handle rather than the schema, because a wrapper that inherits this schema shares the same array; `finalize` folds every object holding it. See `foldIntersection`.
|
|
457
|
+
ctx.intersections.push(allOf);
|
|
355
458
|
};
|
|
356
459
|
export const tupleProcessor = (schema, ctx, _json, params) => {
|
|
357
460
|
const json = _json;
|
|
@@ -359,21 +462,38 @@ export const tupleProcessor = (schema, ctx, _json, params) => {
|
|
|
359
462
|
json.type = "array";
|
|
360
463
|
const prefixPath = ctx.target === "draft-2020-12" ? "prefixItems" : "items";
|
|
361
464
|
const restPath = ctx.target === "draft-2020-12" ? "items" : ctx.target === "openapi-3.0" ? "items" : "additionalItems";
|
|
362
|
-
const prefixItems = def.items.map((x, i) =>
|
|
465
|
+
const prefixItems = def.items.map((x, i) => processSchema(x, ctx, {
|
|
363
466
|
...params,
|
|
364
467
|
path: [...params.path, prefixPath, i],
|
|
365
468
|
}));
|
|
366
469
|
const rest = def.rest
|
|
367
|
-
?
|
|
470
|
+
? processSchema(def.rest, ctx, {
|
|
368
471
|
...params,
|
|
369
472
|
path: [...params.path, restPath, ...(ctx.target === "openapi-3.0" ? [def.items.length] : [])],
|
|
370
473
|
})
|
|
371
474
|
: null;
|
|
475
|
+
let minItems = def.items.length;
|
|
476
|
+
while (minItems > 0) {
|
|
477
|
+
const item = def.items[minItems - 1];
|
|
478
|
+
const optional = ctx.io === "input" ? inputOptin(item) !== undefined : item._zod.optout === "optional";
|
|
479
|
+
if (!optional)
|
|
480
|
+
break;
|
|
481
|
+
minItems--;
|
|
482
|
+
}
|
|
483
|
+
const maxItems = def.items.length;
|
|
484
|
+
const isClosed = !def.rest;
|
|
372
485
|
if (ctx.target === "draft-2020-12") {
|
|
373
486
|
json.prefixItems = prefixItems;
|
|
374
|
-
if (
|
|
487
|
+
if (isClosed) {
|
|
488
|
+
json.items = false;
|
|
489
|
+
}
|
|
490
|
+
else if (rest) {
|
|
375
491
|
json.items = rest;
|
|
376
492
|
}
|
|
493
|
+
if (minItems > 0)
|
|
494
|
+
json.minItems = minItems;
|
|
495
|
+
if (isClosed)
|
|
496
|
+
json.maxItems = maxItems;
|
|
377
497
|
}
|
|
378
498
|
else if (ctx.target === "openapi-3.0") {
|
|
379
499
|
json.items = {
|
|
@@ -382,70 +502,164 @@ export const tupleProcessor = (schema, ctx, _json, params) => {
|
|
|
382
502
|
if (rest) {
|
|
383
503
|
json.items.anyOf.push(rest);
|
|
384
504
|
}
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
505
|
+
if (minItems > 0)
|
|
506
|
+
json.minItems = minItems;
|
|
507
|
+
if (isClosed)
|
|
508
|
+
json.maxItems = maxItems;
|
|
389
509
|
}
|
|
390
510
|
else {
|
|
391
511
|
json.items = prefixItems;
|
|
392
|
-
if (
|
|
512
|
+
if (isClosed) {
|
|
513
|
+
json.additionalItems = false;
|
|
514
|
+
}
|
|
515
|
+
else if (rest) {
|
|
393
516
|
json.additionalItems = rest;
|
|
394
517
|
}
|
|
518
|
+
if (minItems > 0)
|
|
519
|
+
json.minItems = minItems;
|
|
520
|
+
if (isClosed)
|
|
521
|
+
json.maxItems = maxItems;
|
|
395
522
|
}
|
|
396
|
-
// length
|
|
397
|
-
const { minimum, maximum } = schema
|
|
523
|
+
// explicit user-defined length checks take precedence
|
|
524
|
+
const { minimum, maximum } = aggregateChecks(schema);
|
|
398
525
|
if (typeof minimum === "number")
|
|
399
526
|
json.minItems = minimum;
|
|
400
527
|
if (typeof maximum === "number")
|
|
401
528
|
json.maxItems = maximum;
|
|
402
529
|
};
|
|
530
|
+
/** JSON object keys are always strings, so a numeric record key schema is re-expressed over the
|
|
531
|
+
* numeric-string form the record parser matches. Deferred to `finalize`, after the flatten: a key
|
|
532
|
+
* behind a wrapper only carries its own `type` before then, and a union key only has its branches.
|
|
533
|
+
*
|
|
534
|
+
* A numeric bound cannot apply to a property name, so `minimum` and its siblings are dropped rather
|
|
535
|
+
* than carried over: keeping them beside `type: "string"` reproduces the match-nothing schema this
|
|
536
|
+
* exists to fix. A key that carries one therefore emits wider than the record parses — `z.record(z.number().min(5), V)`
|
|
537
|
+
* accepts `"3"` — which is the deliberate trade, since throwing on it would reject an ordinary schema
|
|
538
|
+
* outright. */
|
|
539
|
+
function stringifyKeyNames(bySchema, json, visited) {
|
|
540
|
+
// an extracted key that rewrites cannot go on sharing its definition — the string form a key position needs is not the number form every other reference wants — so it inlines. One that does not rewrite keeps the `$ref`.
|
|
541
|
+
if (json.$ref) {
|
|
542
|
+
// a recursive key holds its own reference inside its definition, so a node already on the path is left alone rather than resolved again
|
|
543
|
+
if (visited.has(json))
|
|
544
|
+
return json;
|
|
545
|
+
visited.add(json);
|
|
546
|
+
const def = bySchema.get(json)?.def;
|
|
547
|
+
if (!def)
|
|
548
|
+
return json;
|
|
549
|
+
const inlined = stringifyKeyNames(bySchema, def, visited);
|
|
550
|
+
return inlined === def ? json : inlined;
|
|
551
|
+
}
|
|
552
|
+
for (const keyword of ["anyOf", "oneOf"]) {
|
|
553
|
+
const branches = json[keyword];
|
|
554
|
+
if (!Array.isArray(branches))
|
|
555
|
+
continue;
|
|
556
|
+
const mapped = branches.map((branch) => stringifyKeyNames(bySchema, branch, visited));
|
|
557
|
+
// rebuilding regardless would detach a key that had nothing to re-express, dropping its `$ref` and leaking the internal `id`
|
|
558
|
+
if (mapped.some((branch, i) => branch !== branches[i]))
|
|
559
|
+
json = { ...json, [keyword]: mapped };
|
|
560
|
+
}
|
|
561
|
+
// a member that already admits a string leaves the key unconstrained, so the node's own type re-expresses only when every member is numeric
|
|
562
|
+
const types = Array.isArray(json.type) ? json.type : [json.type];
|
|
563
|
+
const numericType = !types.includes("string") && types.some((t) => t === "number" || t === "integer");
|
|
564
|
+
// a heterogeneous key carries no type at all, so its numeric members are caught here instead
|
|
565
|
+
const values = json.enum ?? (json.const !== undefined ? [json.const] : undefined);
|
|
566
|
+
if (!numericType && !values?.some((v) => typeof v === "number"))
|
|
567
|
+
return json;
|
|
568
|
+
const { minimum, maximum, exclusiveMinimum, exclusiveMaximum, multipleOf, format, id, ...rest } = json;
|
|
569
|
+
if (rest.enum)
|
|
570
|
+
rest.enum = rest.enum.map((v) => (typeof v === "number" ? String(v) : v));
|
|
571
|
+
else if (typeof rest.const === "number")
|
|
572
|
+
rest.const = String(rest.const);
|
|
573
|
+
// a heterogeneous key keeps its absent type: the stringified members already say what a key may be
|
|
574
|
+
if (!numericType)
|
|
575
|
+
return rest;
|
|
576
|
+
rest.type = "string";
|
|
577
|
+
if (!values)
|
|
578
|
+
rest.pattern = (types.includes("number") ? regexes.number : regexes.integer).source;
|
|
579
|
+
return rest;
|
|
580
|
+
}
|
|
581
|
+
/** Every record of one conversion, so the carriers are found in a single pass rather than once per record. */
|
|
582
|
+
const pendingRecords = new WeakMap();
|
|
583
|
+
function rewriteKeyNames(ctx) {
|
|
584
|
+
// an extracted key is resolved by the object `extractToDef` left in its place, so the map is built once rather than searched per reference. `_zod.toJSONSchema` can hand the same object to two schemas, so the first entry carrying a body wins, as a search would have found it.
|
|
585
|
+
const bySchema = new Map();
|
|
586
|
+
for (const entry of ctx.seen.values()) {
|
|
587
|
+
if (entry.def && !bySchema.has(entry.schema))
|
|
588
|
+
bySchema.set(entry.schema, entry);
|
|
589
|
+
}
|
|
590
|
+
const rewrites = new Map();
|
|
591
|
+
for (const record of pendingRecords.get(ctx) ?? []) {
|
|
592
|
+
const seen = ctx.seen.get(record);
|
|
593
|
+
const names = (seen?.def ?? seen?.schema)?.propertyNames;
|
|
594
|
+
if (!names || names === true || rewrites.has(names))
|
|
595
|
+
continue;
|
|
596
|
+
const rewritten = stringifyKeyNames(bySchema, names, new Set());
|
|
597
|
+
if (rewritten !== names)
|
|
598
|
+
rewrites.set(names, rewritten);
|
|
599
|
+
}
|
|
600
|
+
if (!rewrites.size)
|
|
601
|
+
return;
|
|
602
|
+
// the flatten has already copied each record's own properties onto every wrapper by reference, and an extracted body is another such copy, so every carrier holding a rewritten key is updated together
|
|
603
|
+
for (const entry of ctx.seen.values()) {
|
|
604
|
+
for (const carrier of [entry.schema, entry.def]) {
|
|
605
|
+
const rewritten = carrier && rewrites.get(carrier.propertyNames);
|
|
606
|
+
if (rewritten)
|
|
607
|
+
carrier.propertyNames = rewritten;
|
|
608
|
+
}
|
|
609
|
+
}
|
|
610
|
+
}
|
|
403
611
|
export const recordProcessor = (schema, ctx, _json, params) => {
|
|
404
612
|
const json = _json;
|
|
405
613
|
const def = schema._zod.def;
|
|
406
614
|
json.type = "object";
|
|
407
|
-
// For looseRecord with regex patterns, use patternProperties
|
|
408
|
-
// This correctly represents "only validate keys matching the pattern" semantics
|
|
409
|
-
// and composes well with allOf (intersections)
|
|
615
|
+
// For looseRecord with regex patterns, use patternProperties. This correctly represents "only validate keys matching the pattern" semantics and composes well with allOf (intersections)
|
|
410
616
|
const keyType = def.keyType;
|
|
411
|
-
const
|
|
412
|
-
const patterns = keyBag?.patterns;
|
|
617
|
+
const patterns = aggregateChecks(keyType).patterns;
|
|
413
618
|
if (def.mode === "loose" && patterns && patterns.size > 0) {
|
|
414
619
|
// Use patternProperties for looseRecord with regex patterns
|
|
415
|
-
const valueSchema =
|
|
620
|
+
const valueSchema = processSchema(def.valueType, ctx, {
|
|
416
621
|
...params,
|
|
417
622
|
path: [...params.path, "patternProperties", "*"],
|
|
418
623
|
});
|
|
419
624
|
json.patternProperties = {};
|
|
420
625
|
for (const pattern of patterns) {
|
|
421
|
-
json.patternProperties
|
|
626
|
+
assignProp(json.patternProperties, exactPattern(pattern).source, valueSchema);
|
|
422
627
|
}
|
|
423
628
|
}
|
|
424
629
|
else {
|
|
425
630
|
// Default behavior: use propertyNames + additionalProperties
|
|
426
631
|
if (ctx.target === "draft-07" || ctx.target === "draft-2020-12") {
|
|
427
|
-
json.propertyNames =
|
|
632
|
+
json.propertyNames = processSchema(def.keyType, ctx, {
|
|
428
633
|
...params,
|
|
429
634
|
path: [...params.path, "propertyNames"],
|
|
430
635
|
});
|
|
636
|
+
let pending = pendingRecords.get(ctx);
|
|
637
|
+
if (!pending) {
|
|
638
|
+
pending = [];
|
|
639
|
+
pendingRecords.set(ctx, pending);
|
|
640
|
+
ctx.deferred.push(() => rewriteKeyNames(ctx));
|
|
641
|
+
}
|
|
642
|
+
pending.push(schema);
|
|
431
643
|
}
|
|
432
|
-
json.additionalProperties =
|
|
644
|
+
json.additionalProperties = processSchema(def.valueType, ctx, {
|
|
433
645
|
...params,
|
|
434
646
|
path: [...params.path, "additionalProperties"],
|
|
435
647
|
});
|
|
436
648
|
}
|
|
437
649
|
// Add required for keys with discrete values (enum, literal, etc.)
|
|
438
650
|
const keyValues = keyType._zod.values;
|
|
439
|
-
|
|
651
|
+
// Every key shares one value schema, so an optional-in value makes the whole key set omittable on input. Output keeps them: the exhaustive branch assigns every key, even one whose value came back undefined.
|
|
652
|
+
const omittableOnInput = ctx.io === "input" && inputOptin(def.valueType) !== undefined;
|
|
653
|
+
if (keyValues && !def.partial && !omittableOnInput) {
|
|
440
654
|
const validKeyValues = [...keyValues].filter((v) => typeof v === "string" || typeof v === "number");
|
|
441
655
|
if (validKeyValues.length > 0) {
|
|
442
|
-
json.required = validKeyValues;
|
|
656
|
+
json.required = validKeyValues.map(String);
|
|
443
657
|
}
|
|
444
658
|
}
|
|
445
659
|
};
|
|
446
660
|
export const nullableProcessor = (schema, ctx, json, params) => {
|
|
447
661
|
const def = schema._zod.def;
|
|
448
|
-
const inner =
|
|
662
|
+
const inner = processSchema(def.innerType, ctx, params);
|
|
449
663
|
const seen = ctx.seen.get(schema);
|
|
450
664
|
if (ctx.target === "openapi-3.0") {
|
|
451
665
|
seen.ref = def.innerType;
|
|
@@ -457,28 +671,50 @@ export const nullableProcessor = (schema, ctx, json, params) => {
|
|
|
457
671
|
};
|
|
458
672
|
export const nonoptionalProcessor = (schema, ctx, _json, params) => {
|
|
459
673
|
const def = schema._zod.def;
|
|
460
|
-
|
|
674
|
+
processSchema(def.innerType, ctx, params);
|
|
461
675
|
const seen = ctx.seen.get(schema);
|
|
462
676
|
seen.ref = def.innerType;
|
|
463
677
|
};
|
|
678
|
+
/** Round-trips a default value through JSON so the emitted schema is guaranteed to be valid JSON.
|
|
679
|
+
* A BigInt has no reliable encoding, so it goes through `unrepresentable` like any other
|
|
680
|
+
* unrepresentable value. Returns a sentinel when the caller must not write a default of its own. */
|
|
681
|
+
const UNREPRESENTABLE_DEFAULT = Symbol();
|
|
682
|
+
function serializeDefaultValue(value, schema, ctx, json, params) {
|
|
683
|
+
let unrepresentable = false;
|
|
684
|
+
const serialized = JSON.stringify(value, (_, val) => {
|
|
685
|
+
if (typeof val !== "bigint")
|
|
686
|
+
return val;
|
|
687
|
+
unrepresentable = true;
|
|
688
|
+
return null;
|
|
689
|
+
});
|
|
690
|
+
if (!unrepresentable)
|
|
691
|
+
return JSON.parse(serialized);
|
|
692
|
+
handleUnrepresentable(schema, ctx, json, params, "BigInt defaults cannot be represented in JSON Schema");
|
|
693
|
+
return UNREPRESENTABLE_DEFAULT;
|
|
694
|
+
}
|
|
464
695
|
export const defaultProcessor = (schema, ctx, json, params) => {
|
|
465
696
|
const def = schema._zod.def;
|
|
466
|
-
|
|
697
|
+
processSchema(def.innerType, ctx, params);
|
|
467
698
|
const seen = ctx.seen.get(schema);
|
|
468
699
|
seen.ref = def.innerType;
|
|
469
|
-
|
|
700
|
+
const value = serializeDefaultValue(def.defaultValue, schema, ctx, json, params);
|
|
701
|
+
if (value !== UNREPRESENTABLE_DEFAULT)
|
|
702
|
+
json.default = value;
|
|
470
703
|
};
|
|
471
704
|
export const prefaultProcessor = (schema, ctx, json, params) => {
|
|
472
705
|
const def = schema._zod.def;
|
|
473
|
-
|
|
706
|
+
processSchema(def.innerType, ctx, params);
|
|
474
707
|
const seen = ctx.seen.get(schema);
|
|
475
708
|
seen.ref = def.innerType;
|
|
476
|
-
if (ctx.io
|
|
477
|
-
|
|
709
|
+
if (ctx.io !== "input")
|
|
710
|
+
return;
|
|
711
|
+
const value = serializeDefaultValue(def.defaultValue, schema, ctx, json, params);
|
|
712
|
+
if (value !== UNREPRESENTABLE_DEFAULT)
|
|
713
|
+
json._prefault = value;
|
|
478
714
|
};
|
|
479
715
|
export const catchProcessor = (schema, ctx, json, params) => {
|
|
480
716
|
const def = schema._zod.def;
|
|
481
|
-
|
|
717
|
+
processSchema(def.innerType, ctx, params);
|
|
482
718
|
const seen = ctx.seen.get(schema);
|
|
483
719
|
seen.ref = def.innerType;
|
|
484
720
|
let catchValue;
|
|
@@ -486,39 +722,41 @@ export const catchProcessor = (schema, ctx, json, params) => {
|
|
|
486
722
|
catchValue = def.catchValue(undefined);
|
|
487
723
|
}
|
|
488
724
|
catch {
|
|
489
|
-
|
|
725
|
+
handleUnrepresentable(schema, ctx, json, params, "Dynamic catch values are not supported in JSON Schema");
|
|
726
|
+
return;
|
|
490
727
|
}
|
|
491
728
|
json.default = catchValue;
|
|
492
729
|
};
|
|
493
730
|
export const pipeProcessor = (schema, ctx, _json, params) => {
|
|
494
731
|
const def = schema._zod.def;
|
|
495
|
-
const
|
|
496
|
-
|
|
732
|
+
const inIsTransform = def.in._zod.traits.has("$ZodTransform");
|
|
733
|
+
const innerType = ctx.io === "input" ? (inIsTransform ? def.out : def.in) : def.out;
|
|
734
|
+
processSchema(innerType, ctx, params);
|
|
497
735
|
const seen = ctx.seen.get(schema);
|
|
498
736
|
seen.ref = innerType;
|
|
499
737
|
};
|
|
500
738
|
export const readonlyProcessor = (schema, ctx, json, params) => {
|
|
501
739
|
const def = schema._zod.def;
|
|
502
|
-
|
|
740
|
+
processSchema(def.innerType, ctx, params);
|
|
503
741
|
const seen = ctx.seen.get(schema);
|
|
504
742
|
seen.ref = def.innerType;
|
|
505
743
|
json.readOnly = true;
|
|
506
744
|
};
|
|
507
745
|
export const promiseProcessor = (schema, ctx, _json, params) => {
|
|
508
746
|
const def = schema._zod.def;
|
|
509
|
-
|
|
747
|
+
processSchema(def.innerType, ctx, params);
|
|
510
748
|
const seen = ctx.seen.get(schema);
|
|
511
749
|
seen.ref = def.innerType;
|
|
512
750
|
};
|
|
513
751
|
export const optionalProcessor = (schema, ctx, _json, params) => {
|
|
514
752
|
const def = schema._zod.def;
|
|
515
|
-
|
|
753
|
+
processSchema(def.innerType, ctx, params);
|
|
516
754
|
const seen = ctx.seen.get(schema);
|
|
517
755
|
seen.ref = def.innerType;
|
|
518
756
|
};
|
|
519
757
|
export const lazyProcessor = (schema, ctx, _json, params) => {
|
|
520
758
|
const innerType = schema._zod.innerType;
|
|
521
|
-
|
|
759
|
+
processSchema(innerType, ctx, params);
|
|
522
760
|
const seen = ctx.seen.get(schema);
|
|
523
761
|
seen.ref = innerType;
|
|
524
762
|
};
|
|
@@ -573,7 +811,7 @@ export function toJSONSchema(input, params) {
|
|
|
573
811
|
// First pass: process all schemas to build the seen map
|
|
574
812
|
for (const entry of registry._idmap.entries()) {
|
|
575
813
|
const [_, schema] = entry;
|
|
576
|
-
|
|
814
|
+
processSchema(schema, ctx);
|
|
577
815
|
}
|
|
578
816
|
const schemas = {};
|
|
579
817
|
const external = {
|
|
@@ -587,7 +825,7 @@ export function toJSONSchema(input, params) {
|
|
|
587
825
|
for (const entry of registry._idmap.entries()) {
|
|
588
826
|
const [key, schema] = entry;
|
|
589
827
|
extractDefs(ctx, schema);
|
|
590
|
-
schemas
|
|
828
|
+
assignProp(schemas, key, finalize(ctx, schema));
|
|
591
829
|
}
|
|
592
830
|
if (Object.keys(defs).length > 0) {
|
|
593
831
|
const defsSegment = ctx.target === "draft-2020-12" ? "$defs" : "definitions";
|
|
@@ -599,7 +837,7 @@ export function toJSONSchema(input, params) {
|
|
|
599
837
|
}
|
|
600
838
|
// Single schema case
|
|
601
839
|
const ctx = initializeContext({ ...params, processors: allProcessors });
|
|
602
|
-
|
|
840
|
+
processSchema(input, ctx);
|
|
603
841
|
extractDefs(ctx, input);
|
|
604
842
|
return finalize(ctx, input);
|
|
605
843
|
}
|