@xenosystem/agent-cli 0.5.180 → 0.5.181

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 (865) hide show
  1. package/dist/cli.js +1 -1
  2. package/dist/index.js +2455 -2453
  3. package/dist/metafile-esm.json +1 -1
  4. package/dist/sdk-build-identity.json +12 -12
  5. package/ownership/ownership-policy.json +99 -20
  6. package/package.json +94 -94
  7. package/node_modules/@xeno-corporation/account/LICENSE +0 -39
  8. package/node_modules/@xeno-corporation/account/README.md +0 -266
  9. package/node_modules/@xeno-corporation/account/dist/chunk-FELZILY4.mjs +0 -60
  10. package/node_modules/@xeno-corporation/account/dist/chunk-FELZILY4.mjs.map +0 -1
  11. package/node_modules/@xeno-corporation/account/dist/client-CVtf6u7F.d.mts +0 -2346
  12. package/node_modules/@xeno-corporation/account/dist/client-CVtf6u7F.d.ts +0 -2346
  13. package/node_modules/@xeno-corporation/account/dist/index.d.mts +0 -110
  14. package/node_modules/@xeno-corporation/account/dist/index.d.ts +0 -110
  15. package/node_modules/@xeno-corporation/account/dist/index.js +0 -4115
  16. package/node_modules/@xeno-corporation/account/dist/index.js.map +0 -1
  17. package/node_modules/@xeno-corporation/account/dist/index.mjs +0 -3967
  18. package/node_modules/@xeno-corporation/account/dist/index.mjs.map +0 -1
  19. package/node_modules/@xeno-corporation/account/dist/node.d.mts +0 -109
  20. package/node_modules/@xeno-corporation/account/dist/node.d.ts +0 -109
  21. package/node_modules/@xeno-corporation/account/dist/node.js +0 -1448
  22. package/node_modules/@xeno-corporation/account/dist/node.js.map +0 -1
  23. package/node_modules/@xeno-corporation/account/dist/node.mjs +0 -1374
  24. package/node_modules/@xeno-corporation/account/dist/node.mjs.map +0 -1
  25. package/node_modules/@xeno-corporation/account/package.json +0 -62
  26. package/node_modules/zod/LICENSE +0 -21
  27. package/node_modules/zod/README.md +0 -218
  28. package/node_modules/zod/compile.cjs +0 -96
  29. package/node_modules/zod/compile.d.cts +0 -1
  30. package/node_modules/zod/compile.d.ts +0 -1
  31. package/node_modules/zod/compile.js +0 -52
  32. package/node_modules/zod/index.cjs +0 -52
  33. package/node_modules/zod/index.d.cts +0 -3
  34. package/node_modules/zod/index.d.ts +0 -3
  35. package/node_modules/zod/index.js +0 -7
  36. package/node_modules/zod/locales/index.cjs +0 -36
  37. package/node_modules/zod/locales/index.d.cts +0 -1
  38. package/node_modules/zod/locales/index.d.ts +0 -1
  39. package/node_modules/zod/locales/index.js +0 -1
  40. package/node_modules/zod/locales/package.json +0 -7
  41. package/node_modules/zod/mini/index.cjs +0 -51
  42. package/node_modules/zod/mini/index.d.cts +0 -3
  43. package/node_modules/zod/mini/index.d.ts +0 -3
  44. package/node_modules/zod/mini/index.js +0 -3
  45. package/node_modules/zod/mini/package.json +0 -7
  46. package/node_modules/zod/package.json +0 -147
  47. package/node_modules/zod/src/compile.ts +0 -56
  48. package/node_modules/zod/src/index.ts +0 -7
  49. package/node_modules/zod/src/locales/index.ts +0 -1
  50. package/node_modules/zod/src/mini/index.ts +0 -3
  51. package/node_modules/zod/src/v3/ZodError.ts +0 -340
  52. package/node_modules/zod/src/v3/benchmarks/datetime.ts +0 -58
  53. package/node_modules/zod/src/v3/benchmarks/discriminatedUnion.ts +0 -80
  54. package/node_modules/zod/src/v3/benchmarks/index.ts +0 -59
  55. package/node_modules/zod/src/v3/benchmarks/ipv4.ts +0 -57
  56. package/node_modules/zod/src/v3/benchmarks/object.ts +0 -69
  57. package/node_modules/zod/src/v3/benchmarks/primitives.ts +0 -162
  58. package/node_modules/zod/src/v3/benchmarks/realworld.ts +0 -63
  59. package/node_modules/zod/src/v3/benchmarks/string.ts +0 -55
  60. package/node_modules/zod/src/v3/benchmarks/union.ts +0 -80
  61. package/node_modules/zod/src/v3/errors.ts +0 -13
  62. package/node_modules/zod/src/v3/external.ts +0 -6
  63. package/node_modules/zod/src/v3/helpers/enumUtil.ts +0 -17
  64. package/node_modules/zod/src/v3/helpers/errorUtil.ts +0 -8
  65. package/node_modules/zod/src/v3/helpers/parseUtil.ts +0 -176
  66. package/node_modules/zod/src/v3/helpers/partialUtil.ts +0 -34
  67. package/node_modules/zod/src/v3/helpers/typeAliases.ts +0 -2
  68. package/node_modules/zod/src/v3/helpers/util.ts +0 -224
  69. package/node_modules/zod/src/v3/index.ts +0 -4
  70. package/node_modules/zod/src/v3/locales/en.ts +0 -124
  71. package/node_modules/zod/src/v3/standard-schema.ts +0 -113
  72. package/node_modules/zod/src/v3/tests/Mocker.ts +0 -54
  73. package/node_modules/zod/src/v3/tests/all-errors.test.ts +0 -157
  74. package/node_modules/zod/src/v3/tests/anyunknown.test.ts +0 -28
  75. package/node_modules/zod/src/v3/tests/array.test.ts +0 -71
  76. package/node_modules/zod/src/v3/tests/async-parsing.test.ts +0 -388
  77. package/node_modules/zod/src/v3/tests/async-refinements.test.ts +0 -46
  78. package/node_modules/zod/src/v3/tests/base.test.ts +0 -29
  79. package/node_modules/zod/src/v3/tests/bigint.test.ts +0 -55
  80. package/node_modules/zod/src/v3/tests/branded.test.ts +0 -53
  81. package/node_modules/zod/src/v3/tests/catch.test.ts +0 -220
  82. package/node_modules/zod/src/v3/tests/coerce.test.ts +0 -133
  83. package/node_modules/zod/src/v3/tests/complex.test.ts +0 -70
  84. package/node_modules/zod/src/v3/tests/custom.test.ts +0 -31
  85. package/node_modules/zod/src/v3/tests/date.test.ts +0 -32
  86. package/node_modules/zod/src/v3/tests/deepmasking.test.ts +0 -186
  87. package/node_modules/zod/src/v3/tests/default.test.ts +0 -112
  88. package/node_modules/zod/src/v3/tests/description.test.ts +0 -33
  89. package/node_modules/zod/src/v3/tests/discriminated-unions.test.ts +0 -315
  90. package/node_modules/zod/src/v3/tests/enum.test.ts +0 -80
  91. package/node_modules/zod/src/v3/tests/error.test.ts +0 -586
  92. package/node_modules/zod/src/v3/tests/firstparty.test.ts +0 -87
  93. package/node_modules/zod/src/v3/tests/firstpartyschematypes.test.ts +0 -21
  94. package/node_modules/zod/src/v3/tests/function.test.ts +0 -261
  95. package/node_modules/zod/src/v3/tests/generics.test.ts +0 -48
  96. package/node_modules/zod/src/v3/tests/instanceof.test.ts +0 -37
  97. package/node_modules/zod/src/v3/tests/intersection.test.ts +0 -128
  98. package/node_modules/zod/src/v3/tests/language-server.source.ts +0 -76
  99. package/node_modules/zod/src/v3/tests/language-server.test.ts +0 -206
  100. package/node_modules/zod/src/v3/tests/literal.test.ts +0 -36
  101. package/node_modules/zod/src/v3/tests/map.test.ts +0 -110
  102. package/node_modules/zod/src/v3/tests/masking.test.ts +0 -4
  103. package/node_modules/zod/src/v3/tests/mocker.test.ts +0 -19
  104. package/node_modules/zod/src/v3/tests/nan.test.ts +0 -24
  105. package/node_modules/zod/src/v3/tests/nativeEnum.test.ts +0 -87
  106. package/node_modules/zod/src/v3/tests/nullable.test.ts +0 -42
  107. package/node_modules/zod/src/v3/tests/number.test.ts +0 -176
  108. package/node_modules/zod/src/v3/tests/object-augmentation.test.ts +0 -29
  109. package/node_modules/zod/src/v3/tests/object-in-es5-env.test.ts +0 -29
  110. package/node_modules/zod/src/v3/tests/object.test.ts +0 -431
  111. package/node_modules/zod/src/v3/tests/optional.test.ts +0 -42
  112. package/node_modules/zod/src/v3/tests/parseUtil.test.ts +0 -23
  113. package/node_modules/zod/src/v3/tests/parser.test.ts +0 -41
  114. package/node_modules/zod/src/v3/tests/partials.test.ts +0 -243
  115. package/node_modules/zod/src/v3/tests/pickomit.test.ts +0 -111
  116. package/node_modules/zod/src/v3/tests/pipeline.test.ts +0 -29
  117. package/node_modules/zod/src/v3/tests/preprocess.test.ts +0 -186
  118. package/node_modules/zod/src/v3/tests/primitive.test.ts +0 -440
  119. package/node_modules/zod/src/v3/tests/promise.test.ts +0 -90
  120. package/node_modules/zod/src/v3/tests/readonly.test.ts +0 -114
  121. package/node_modules/zod/src/v3/tests/record.test.ts +0 -171
  122. package/node_modules/zod/src/v3/tests/recursive.test.ts +0 -197
  123. package/node_modules/zod/src/v3/tests/refine.test.ts +0 -313
  124. package/node_modules/zod/src/v3/tests/safeparse.test.ts +0 -27
  125. package/node_modules/zod/src/v3/tests/set.test.ts +0 -142
  126. package/node_modules/zod/src/v3/tests/standard-schema.test.ts +0 -83
  127. package/node_modules/zod/src/v3/tests/string.test.ts +0 -922
  128. package/node_modules/zod/src/v3/tests/transformer.test.ts +0 -233
  129. package/node_modules/zod/src/v3/tests/tuple.test.ts +0 -90
  130. package/node_modules/zod/src/v3/tests/unions.test.ts +0 -57
  131. package/node_modules/zod/src/v3/tests/validations.test.ts +0 -133
  132. package/node_modules/zod/src/v3/tests/void.test.ts +0 -15
  133. package/node_modules/zod/src/v3/types.ts +0 -5138
  134. package/node_modules/zod/src/v4/classic/checks.ts +0 -33
  135. package/node_modules/zod/src/v4/classic/coerce.ts +0 -27
  136. package/node_modules/zod/src/v4/classic/compat.ts +0 -78
  137. package/node_modules/zod/src/v4/classic/deep-partial.ts +0 -76
  138. package/node_modules/zod/src/v4/classic/errors.ts +0 -97
  139. package/node_modules/zod/src/v4/classic/external.ts +0 -57
  140. package/node_modules/zod/src/v4/classic/from-json-schema.ts +0 -944
  141. package/node_modules/zod/src/v4/classic/in-out.ts +0 -45
  142. package/node_modules/zod/src/v4/classic/index.ts +0 -5
  143. package/node_modules/zod/src/v4/classic/iso.ts +0 -20
  144. package/node_modules/zod/src/v4/classic/parse.ts +0 -88
  145. package/node_modules/zod/src/v4/classic/schemas.ts +0 -2937
  146. package/node_modules/zod/src/v4/classic/tests/anyunknown.test.ts +0 -26
  147. package/node_modules/zod/src/v4/classic/tests/apply.test.ts +0 -86
  148. package/node_modules/zod/src/v4/classic/tests/array.test.ts +0 -291
  149. package/node_modules/zod/src/v4/classic/tests/assignability.test.ts +0 -402
  150. package/node_modules/zod/src/v4/classic/tests/async-parsing.test.ts +0 -381
  151. package/node_modules/zod/src/v4/classic/tests/async-refinements.test.ts +0 -68
  152. package/node_modules/zod/src/v4/classic/tests/base.test.ts +0 -7
  153. package/node_modules/zod/src/v4/classic/tests/bigint.test.ts +0 -89
  154. package/node_modules/zod/src/v4/classic/tests/brand.test.ts +0 -106
  155. package/node_modules/zod/src/v4/classic/tests/catch.test.ts +0 -604
  156. package/node_modules/zod/src/v4/classic/tests/coalesce.test.ts +0 -20
  157. package/node_modules/zod/src/v4/classic/tests/codec-examples.test.ts +0 -572
  158. package/node_modules/zod/src/v4/classic/tests/codec.test.ts +0 -704
  159. package/node_modules/zod/src/v4/classic/tests/coerce.test.ts +0 -160
  160. package/node_modules/zod/src/v4/classic/tests/continuability.test.ts +0 -374
  161. package/node_modules/zod/src/v4/classic/tests/credit-card.test.ts +0 -76
  162. package/node_modules/zod/src/v4/classic/tests/custom.test.ts +0 -40
  163. package/node_modules/zod/src/v4/classic/tests/cyclic-data.test.ts +0 -985
  164. package/node_modules/zod/src/v4/classic/tests/date.test.ts +0 -92
  165. package/node_modules/zod/src/v4/classic/tests/datetime.test.ts +0 -316
  166. package/node_modules/zod/src/v4/classic/tests/deep-partial.test.ts +0 -380
  167. package/node_modules/zod/src/v4/classic/tests/default-locale.test.ts +0 -32
  168. package/node_modules/zod/src/v4/classic/tests/default.test.ts +0 -455
  169. package/node_modules/zod/src/v4/classic/tests/describe-meta-checks.test.ts +0 -27
  170. package/node_modules/zod/src/v4/classic/tests/description.test.ts +0 -32
  171. package/node_modules/zod/src/v4/classic/tests/detached-methods.test.ts +0 -221
  172. package/node_modules/zod/src/v4/classic/tests/discriminated-unions.test.ts +0 -942
  173. package/node_modules/zod/src/v4/classic/tests/enum.test.ts +0 -305
  174. package/node_modules/zod/src/v4/classic/tests/error-utils.test.ts +0 -917
  175. package/node_modules/zod/src/v4/classic/tests/error.test.ts +0 -1108
  176. package/node_modules/zod/src/v4/classic/tests/file.test.ts +0 -96
  177. package/node_modules/zod/src/v4/classic/tests/firstparty.test.ts +0 -179
  178. package/node_modules/zod/src/v4/classic/tests/fix-json-issue.test.ts +0 -26
  179. package/node_modules/zod/src/v4/classic/tests/from-json-schema.test.ts +0 -1467
  180. package/node_modules/zod/src/v4/classic/tests/function.test.ts +0 -391
  181. package/node_modules/zod/src/v4/classic/tests/generics.test.ts +0 -72
  182. package/node_modules/zod/src/v4/classic/tests/global-config.test.ts +0 -32
  183. package/node_modules/zod/src/v4/classic/tests/hash.test.ts +0 -67
  184. package/node_modules/zod/src/v4/classic/tests/iban.test.ts +0 -81
  185. package/node_modules/zod/src/v4/classic/tests/in-out.test.ts +0 -159
  186. package/node_modules/zod/src/v4/classic/tests/index.test.ts +0 -958
  187. package/node_modules/zod/src/v4/classic/tests/instance-footprint.test.ts +0 -319
  188. package/node_modules/zod/src/v4/classic/tests/instanceof.test.ts +0 -127
  189. package/node_modules/zod/src/v4/classic/tests/intersection.test.ts +0 -334
  190. package/node_modules/zod/src/v4/classic/tests/issue-schema.test.ts +0 -215
  191. package/node_modules/zod/src/v4/classic/tests/jitless-allows-eval.test.ts +0 -39
  192. package/node_modules/zod/src/v4/classic/tests/json.test.ts +0 -109
  193. package/node_modules/zod/src/v4/classic/tests/lazy.test.ts +0 -262
  194. package/node_modules/zod/src/v4/classic/tests/literal.test.ts +0 -128
  195. package/node_modules/zod/src/v4/classic/tests/locales_ka.test.ts +0 -29
  196. package/node_modules/zod/src/v4/classic/tests/locales_ro.test.ts +0 -24
  197. package/node_modules/zod/src/v4/classic/tests/map.test.ts +0 -349
  198. package/node_modules/zod/src/v4/classic/tests/nan.test.ts +0 -21
  199. package/node_modules/zod/src/v4/classic/tests/nested-refine.test.ts +0 -168
  200. package/node_modules/zod/src/v4/classic/tests/nonoptional.test.ts +0 -101
  201. package/node_modules/zod/src/v4/classic/tests/nullable.test.ts +0 -22
  202. package/node_modules/zod/src/v4/classic/tests/number.test.ts +0 -401
  203. package/node_modules/zod/src/v4/classic/tests/object.test.ts +0 -1006
  204. package/node_modules/zod/src/v4/classic/tests/optin-ladder.test.ts +0 -235
  205. package/node_modules/zod/src/v4/classic/tests/optional.test.ts +0 -366
  206. package/node_modules/zod/src/v4/classic/tests/partial.test.ts +0 -497
  207. package/node_modules/zod/src/v4/classic/tests/pickomit.test.ts +0 -211
  208. package/node_modules/zod/src/v4/classic/tests/pipe.test.ts +0 -101
  209. package/node_modules/zod/src/v4/classic/tests/prefault.test.ts +0 -144
  210. package/node_modules/zod/src/v4/classic/tests/preprocess-types.test.ts +0 -44
  211. package/node_modules/zod/src/v4/classic/tests/preprocess.test.ts +0 -351
  212. package/node_modules/zod/src/v4/classic/tests/primitive.test.ts +0 -175
  213. package/node_modules/zod/src/v4/classic/tests/promise.test.ts +0 -81
  214. package/node_modules/zod/src/v4/classic/tests/properties.test.ts +0 -141
  215. package/node_modules/zod/src/v4/classic/tests/prototypes.test.ts +0 -23
  216. package/node_modules/zod/src/v4/classic/tests/readonly.test.ts +0 -184
  217. package/node_modules/zod/src/v4/classic/tests/record.test.ts +0 -885
  218. package/node_modules/zod/src/v4/classic/tests/recursive-types.test.ts +0 -707
  219. package/node_modules/zod/src/v4/classic/tests/redos.test.ts +0 -68
  220. package/node_modules/zod/src/v4/classic/tests/refine.test.ts +0 -693
  221. package/node_modules/zod/src/v4/classic/tests/registries.test.ts +0 -243
  222. package/node_modules/zod/src/v4/classic/tests/set.test.ts +0 -196
  223. package/node_modules/zod/src/v4/classic/tests/standard-schema.test.ts +0 -153
  224. package/node_modules/zod/src/v4/classic/tests/string-formats.test.ts +0 -125
  225. package/node_modules/zod/src/v4/classic/tests/string.test.ts +0 -1440
  226. package/node_modules/zod/src/v4/classic/tests/stringbool.test.ts +0 -124
  227. package/node_modules/zod/src/v4/classic/tests/template-literal.test.ts +0 -812
  228. package/node_modules/zod/src/v4/classic/tests/to-json-schema-methods.test.ts +0 -438
  229. package/node_modules/zod/src/v4/classic/tests/to-json-schema.test.ts +0 -4733
  230. package/node_modules/zod/src/v4/classic/tests/transform.test.ts +0 -378
  231. package/node_modules/zod/src/v4/classic/tests/tuple.test.ts +0 -511
  232. package/node_modules/zod/src/v4/classic/tests/union.test.ts +0 -310
  233. package/node_modules/zod/src/v4/classic/tests/url.test.ts +0 -13
  234. package/node_modules/zod/src/v4/classic/tests/validate.test.ts +0 -645
  235. package/node_modules/zod/src/v4/classic/tests/validations.test.ts +0 -283
  236. package/node_modules/zod/src/v4/classic/tests/void.test.ts +0 -12
  237. package/node_modules/zod/src/v4/core/api.ts +0 -1875
  238. package/node_modules/zod/src/v4/core/checks.ts +0 -1266
  239. package/node_modules/zod/src/v4/core/compile.ts +0 -2322
  240. package/node_modules/zod/src/v4/core/core.ts +0 -230
  241. package/node_modules/zod/src/v4/core/doc.ts +0 -52
  242. package/node_modules/zod/src/v4/core/errors.ts +0 -543
  243. package/node_modules/zod/src/v4/core/index.ts +0 -19
  244. package/node_modules/zod/src/v4/core/json-schema-generator.ts +0 -131
  245. package/node_modules/zod/src/v4/core/json-schema-processors.ts +0 -934
  246. package/node_modules/zod/src/v4/core/json-schema.ts +0 -148
  247. package/node_modules/zod/src/v4/core/memoizer.ts +0 -331
  248. package/node_modules/zod/src/v4/core/parse.ts +0 -309
  249. package/node_modules/zod/src/v4/core/regexes.ts +0 -217
  250. package/node_modules/zod/src/v4/core/registries.ts +0 -105
  251. package/node_modules/zod/src/v4/core/schemas.ts +0 -5226
  252. package/node_modules/zod/src/v4/core/standard-schema.ts +0 -159
  253. package/node_modules/zod/src/v4/core/tests/cached.test.ts +0 -54
  254. package/node_modules/zod/src/v4/core/tests/compile-differential.test.ts +0 -1004
  255. package/node_modules/zod/src/v4/core/tests/compile-generative.test.ts +0 -445
  256. package/node_modules/zod/src/v4/core/tests/compile-global.test.ts +0 -89
  257. package/node_modules/zod/src/v4/core/tests/compile-off-by-default.test.ts +0 -26
  258. package/node_modules/zod/src/v4/core/tests/compile-stats.test.ts +0 -34
  259. package/node_modules/zod/src/v4/core/tests/compile.test.ts +0 -2036
  260. package/node_modules/zod/src/v4/core/tests/email-regex.test.ts +0 -140
  261. package/node_modules/zod/src/v4/core/tests/extend.test.ts +0 -59
  262. package/node_modules/zod/src/v4/core/tests/index.test.ts +0 -46
  263. package/node_modules/zod/src/v4/core/tests/locales/be.test.ts +0 -124
  264. package/node_modules/zod/src/v4/core/tests/locales/el.test.ts +0 -214
  265. package/node_modules/zod/src/v4/core/tests/locales/en.test.ts +0 -22
  266. package/node_modules/zod/src/v4/core/tests/locales/es.test.ts +0 -180
  267. package/node_modules/zod/src/v4/core/tests/locales/fr.test.ts +0 -72
  268. package/node_modules/zod/src/v4/core/tests/locales/he.test.ts +0 -379
  269. package/node_modules/zod/src/v4/core/tests/locales/hr.test.ts +0 -163
  270. package/node_modules/zod/src/v4/core/tests/locales/nl.test.ts +0 -46
  271. package/node_modules/zod/src/v4/core/tests/locales/parity.test.ts +0 -42
  272. package/node_modules/zod/src/v4/core/tests/locales/ru.test.ts +0 -128
  273. package/node_modules/zod/src/v4/core/tests/locales/tg.test.ts +0 -85
  274. package/node_modules/zod/src/v4/core/tests/locales/tk.test.ts +0 -69
  275. package/node_modules/zod/src/v4/core/tests/locales/tr.test.ts +0 -69
  276. package/node_modules/zod/src/v4/core/tests/locales/uz.test.ts +0 -105
  277. package/node_modules/zod/src/v4/core/tests/polyfill-collision.test.ts +0 -46
  278. package/node_modules/zod/src/v4/core/tests/record-constructor.test.ts +0 -125
  279. package/node_modules/zod/src/v4/core/tests/recursive-tuples.test.ts +0 -45
  280. package/node_modules/zod/src/v4/core/tests/treeshake.test.ts +0 -51
  281. package/node_modules/zod/src/v4/core/tests/url-no-canparse.test.ts +0 -133
  282. package/node_modules/zod/src/v4/core/to-json-schema.ts +0 -857
  283. package/node_modules/zod/src/v4/core/util.ts +0 -1293
  284. package/node_modules/zod/src/v4/core/versions.ts +0 -5
  285. package/node_modules/zod/src/v4/core/visit.ts +0 -193
  286. package/node_modules/zod/src/v4/core/zsf.ts +0 -323
  287. package/node_modules/zod/src/v4/index.ts +0 -4
  288. package/node_modules/zod/src/v4/locales/ar.ts +0 -120
  289. package/node_modules/zod/src/v4/locales/az.ts +0 -116
  290. package/node_modules/zod/src/v4/locales/be.ts +0 -188
  291. package/node_modules/zod/src/v4/locales/bg.ts +0 -133
  292. package/node_modules/zod/src/v4/locales/bn.ts +0 -123
  293. package/node_modules/zod/src/v4/locales/ca.ts +0 -121
  294. package/node_modules/zod/src/v4/locales/ckb.ts +0 -140
  295. package/node_modules/zod/src/v4/locales/cs.ts +0 -123
  296. package/node_modules/zod/src/v4/locales/da.ts +0 -128
  297. package/node_modules/zod/src/v4/locales/de.ts +0 -121
  298. package/node_modules/zod/src/v4/locales/el.ts +0 -124
  299. package/node_modules/zod/src/v4/locales/en.ts +0 -136
  300. package/node_modules/zod/src/v4/locales/eo.ts +0 -123
  301. package/node_modules/zod/src/v4/locales/es.ts +0 -145
  302. package/node_modules/zod/src/v4/locales/fa.ts +0 -131
  303. package/node_modules/zod/src/v4/locales/fi.ts +0 -126
  304. package/node_modules/zod/src/v4/locales/fr-CA.ts +0 -121
  305. package/node_modules/zod/src/v4/locales/fr.ts +0 -139
  306. package/node_modules/zod/src/v4/locales/gu.ts +0 -123
  307. package/node_modules/zod/src/v4/locales/he.ts +0 -253
  308. package/node_modules/zod/src/v4/locales/hi.ts +0 -126
  309. package/node_modules/zod/src/v4/locales/hr.ts +0 -135
  310. package/node_modules/zod/src/v4/locales/hu.ts +0 -122
  311. package/node_modules/zod/src/v4/locales/hy.ts +0 -175
  312. package/node_modules/zod/src/v4/locales/id.ts +0 -120
  313. package/node_modules/zod/src/v4/locales/index.ts +0 -63
  314. package/node_modules/zod/src/v4/locales/is.ts +0 -124
  315. package/node_modules/zod/src/v4/locales/it.ts +0 -121
  316. package/node_modules/zod/src/v4/locales/ja.ts +0 -119
  317. package/node_modules/zod/src/v4/locales/ka.ts +0 -128
  318. package/node_modules/zod/src/v4/locales/kh.ts +0 -7
  319. package/node_modules/zod/src/v4/locales/km.ts +0 -124
  320. package/node_modules/zod/src/v4/locales/kn.ts +0 -126
  321. package/node_modules/zod/src/v4/locales/ko.ts +0 -126
  322. package/node_modules/zod/src/v4/locales/lt.ts +0 -243
  323. package/node_modules/zod/src/v4/locales/mk.ts +0 -123
  324. package/node_modules/zod/src/v4/locales/ms.ts +0 -120
  325. package/node_modules/zod/src/v4/locales/ne.ts +0 -128
  326. package/node_modules/zod/src/v4/locales/nl.ts +0 -126
  327. package/node_modules/zod/src/v4/locales/nn.ts +0 -121
  328. package/node_modules/zod/src/v4/locales/no.ts +0 -121
  329. package/node_modules/zod/src/v4/locales/ota.ts +0 -122
  330. package/node_modules/zod/src/v4/locales/pl.ts +0 -123
  331. package/node_modules/zod/src/v4/locales/ps.ts +0 -131
  332. package/node_modules/zod/src/v4/locales/pt-BR.ts +0 -161
  333. package/node_modules/zod/src/v4/locales/pt.ts +0 -159
  334. package/node_modules/zod/src/v4/locales/ro.ts +0 -132
  335. package/node_modules/zod/src/v4/locales/ru.ts +0 -188
  336. package/node_modules/zod/src/v4/locales/sk.ts +0 -123
  337. package/node_modules/zod/src/v4/locales/sl.ts +0 -123
  338. package/node_modules/zod/src/v4/locales/sv.ts +0 -124
  339. package/node_modules/zod/src/v4/locales/ta.ts +0 -123
  340. package/node_modules/zod/src/v4/locales/tg.ts +0 -135
  341. package/node_modules/zod/src/v4/locales/th.ts +0 -124
  342. package/node_modules/zod/src/v4/locales/tk.ts +0 -113
  343. package/node_modules/zod/src/v4/locales/tr.ts +0 -116
  344. package/node_modules/zod/src/v4/locales/ua.ts +0 -7
  345. package/node_modules/zod/src/v4/locales/uk.ts +0 -122
  346. package/node_modules/zod/src/v4/locales/ur.ts +0 -124
  347. package/node_modules/zod/src/v4/locales/uz.ts +0 -120
  348. package/node_modules/zod/src/v4/locales/vi.ts +0 -122
  349. package/node_modules/zod/src/v4/locales/yo.ts +0 -129
  350. package/node_modules/zod/src/v4/locales/zh-CN.ts +0 -121
  351. package/node_modules/zod/src/v4/locales/zh-TW.ts +0 -120
  352. package/node_modules/zod/src/v4/mini/checks.ts +0 -33
  353. package/node_modules/zod/src/v4/mini/coerce.ts +0 -27
  354. package/node_modules/zod/src/v4/mini/deep-partial.ts +0 -73
  355. package/node_modules/zod/src/v4/mini/external.ts +0 -52
  356. package/node_modules/zod/src/v4/mini/in-out.ts +0 -45
  357. package/node_modules/zod/src/v4/mini/index.ts +0 -3
  358. package/node_modules/zod/src/v4/mini/iso.ts +0 -66
  359. package/node_modules/zod/src/v4/mini/parse.ts +0 -16
  360. package/node_modules/zod/src/v4/mini/schemas.ts +0 -2051
  361. package/node_modules/zod/src/v4/mini/tests/apply.test.ts +0 -57
  362. package/node_modules/zod/src/v4/mini/tests/assignability.test.ts +0 -190
  363. package/node_modules/zod/src/v4/mini/tests/brand.test.ts +0 -94
  364. package/node_modules/zod/src/v4/mini/tests/checks.test.ts +0 -158
  365. package/node_modules/zod/src/v4/mini/tests/codec.test.ts +0 -582
  366. package/node_modules/zod/src/v4/mini/tests/computed.test.ts +0 -30
  367. package/node_modules/zod/src/v4/mini/tests/cyclic-data.test.ts +0 -84
  368. package/node_modules/zod/src/v4/mini/tests/deep-partial.test.ts +0 -54
  369. package/node_modules/zod/src/v4/mini/tests/error.test.ts +0 -41
  370. package/node_modules/zod/src/v4/mini/tests/functions.test.ts +0 -14
  371. package/node_modules/zod/src/v4/mini/tests/index.test.ts +0 -1146
  372. package/node_modules/zod/src/v4/mini/tests/number.test.ts +0 -109
  373. package/node_modules/zod/src/v4/mini/tests/object.test.ts +0 -292
  374. package/node_modules/zod/src/v4/mini/tests/prototypes.test.ts +0 -43
  375. package/node_modules/zod/src/v4/mini/tests/recursive-types.test.ts +0 -341
  376. package/node_modules/zod/src/v4/mini/tests/standard-schema.test.ts +0 -50
  377. package/node_modules/zod/src/v4/mini/tests/string.test.ts +0 -396
  378. package/node_modules/zod/src/v4-mini/index.ts +0 -3
  379. package/node_modules/zod/v3/ZodError.cjs +0 -167
  380. package/node_modules/zod/v3/ZodError.d.cts +0 -164
  381. package/node_modules/zod/v3/ZodError.d.ts +0 -164
  382. package/node_modules/zod/v3/ZodError.js +0 -143
  383. package/node_modules/zod/v3/errors.cjs +0 -36
  384. package/node_modules/zod/v3/errors.d.cts +0 -5
  385. package/node_modules/zod/v3/errors.d.ts +0 -5
  386. package/node_modules/zod/v3/errors.js +0 -9
  387. package/node_modules/zod/v3/external.cjs +0 -41
  388. package/node_modules/zod/v3/external.d.cts +0 -6
  389. package/node_modules/zod/v3/external.d.ts +0 -6
  390. package/node_modules/zod/v3/external.js +0 -6
  391. package/node_modules/zod/v3/helpers/enumUtil.cjs +0 -21
  392. package/node_modules/zod/v3/helpers/enumUtil.d.cts +0 -8
  393. package/node_modules/zod/v3/helpers/enumUtil.d.ts +0 -8
  394. package/node_modules/zod/v3/helpers/enumUtil.js +0 -1
  395. package/node_modules/zod/v3/helpers/errorUtil.cjs +0 -28
  396. package/node_modules/zod/v3/helpers/errorUtil.d.cts +0 -9
  397. package/node_modules/zod/v3/helpers/errorUtil.d.ts +0 -9
  398. package/node_modules/zod/v3/helpers/errorUtil.js +0 -6
  399. package/node_modules/zod/v3/helpers/parseUtil.cjs +0 -143
  400. package/node_modules/zod/v3/helpers/parseUtil.d.cts +0 -78
  401. package/node_modules/zod/v3/helpers/parseUtil.d.ts +0 -78
  402. package/node_modules/zod/v3/helpers/parseUtil.js +0 -109
  403. package/node_modules/zod/v3/helpers/partialUtil.cjs +0 -21
  404. package/node_modules/zod/v3/helpers/partialUtil.d.cts +0 -8
  405. package/node_modules/zod/v3/helpers/partialUtil.d.ts +0 -8
  406. package/node_modules/zod/v3/helpers/partialUtil.js +0 -1
  407. package/node_modules/zod/v3/helpers/typeAliases.cjs +0 -21
  408. package/node_modules/zod/v3/helpers/typeAliases.d.cts +0 -2
  409. package/node_modules/zod/v3/helpers/typeAliases.d.ts +0 -2
  410. package/node_modules/zod/v3/helpers/typeAliases.js +0 -1
  411. package/node_modules/zod/v3/helpers/util.cjs +0 -156
  412. package/node_modules/zod/v3/helpers/util.d.cts +0 -85
  413. package/node_modules/zod/v3/helpers/util.d.ts +0 -85
  414. package/node_modules/zod/v3/helpers/util.js +0 -133
  415. package/node_modules/zod/v3/index.cjs +0 -52
  416. package/node_modules/zod/v3/index.d.cts +0 -4
  417. package/node_modules/zod/v3/index.d.ts +0 -4
  418. package/node_modules/zod/v3/index.js +0 -4
  419. package/node_modules/zod/v3/locales/en.cjs +0 -112
  420. package/node_modules/zod/v3/locales/en.d.cts +0 -3
  421. package/node_modules/zod/v3/locales/en.d.ts +0 -3
  422. package/node_modules/zod/v3/locales/en.js +0 -109
  423. package/node_modules/zod/v3/package.json +0 -7
  424. package/node_modules/zod/v3/standard-schema.cjs +0 -21
  425. package/node_modules/zod/v3/standard-schema.d.cts +0 -102
  426. package/node_modules/zod/v3/standard-schema.d.ts +0 -102
  427. package/node_modules/zod/v3/standard-schema.js +0 -1
  428. package/node_modules/zod/v3/types.cjs +0 -3798
  429. package/node_modules/zod/v3/types.d.cts +0 -1034
  430. package/node_modules/zod/v3/types.d.ts +0 -1034
  431. package/node_modules/zod/v3/types.js +0 -3697
  432. package/node_modules/zod/v4/classic/checks.cjs +0 -53
  433. package/node_modules/zod/v4/classic/checks.d.cts +0 -1
  434. package/node_modules/zod/v4/classic/checks.d.ts +0 -1
  435. package/node_modules/zod/v4/classic/checks.js +0 -1
  436. package/node_modules/zod/v4/classic/coerce.cjs +0 -66
  437. package/node_modules/zod/v4/classic/coerce.d.cts +0 -17
  438. package/node_modules/zod/v4/classic/coerce.d.ts +0 -17
  439. package/node_modules/zod/v4/classic/coerce.js +0 -17
  440. package/node_modules/zod/v4/classic/compat.cjs +0 -80
  441. package/node_modules/zod/v4/classic/compat.d.cts +0 -48
  442. package/node_modules/zod/v4/classic/compat.d.ts +0 -48
  443. package/node_modules/zod/v4/classic/compat.js +0 -31
  444. package/node_modules/zod/v4/classic/deep-partial.cjs +0 -58
  445. package/node_modules/zod/v4/classic/deep-partial.d.cts +0 -14
  446. package/node_modules/zod/v4/classic/deep-partial.d.ts +0 -14
  447. package/node_modules/zod/v4/classic/deep-partial.js +0 -13
  448. package/node_modules/zod/v4/classic/errors.cjs +0 -102
  449. package/node_modules/zod/v4/classic/errors.d.cts +0 -29
  450. package/node_modules/zod/v4/classic/errors.d.ts +0 -29
  451. package/node_modules/zod/v4/classic/errors.js +0 -57
  452. package/node_modules/zod/v4/classic/external.cjs +0 -97
  453. package/node_modules/zod/v4/classic/external.d.cts +0 -19
  454. package/node_modules/zod/v4/classic/external.d.ts +0 -19
  455. package/node_modules/zod/v4/classic/external.js +0 -17
  456. package/node_modules/zod/v4/classic/from-json-schema.cjs +0 -926
  457. package/node_modules/zod/v4/classic/from-json-schema.d.cts +0 -12
  458. package/node_modules/zod/v4/classic/from-json-schema.d.ts +0 -12
  459. package/node_modules/zod/v4/classic/from-json-schema.js +0 -881
  460. package/node_modules/zod/v4/classic/in-out.cjs +0 -82
  461. package/node_modules/zod/v4/classic/in-out.d.cts +0 -8
  462. package/node_modules/zod/v4/classic/in-out.d.ts +0 -8
  463. package/node_modules/zod/v4/classic/in-out.js +0 -36
  464. package/node_modules/zod/v4/classic/index.cjs +0 -52
  465. package/node_modules/zod/v4/classic/index.d.cts +0 -3
  466. package/node_modules/zod/v4/classic/index.d.ts +0 -3
  467. package/node_modules/zod/v4/classic/index.js +0 -4
  468. package/node_modules/zod/v4/classic/iso.cjs +0 -68
  469. package/node_modules/zod/v4/classic/iso.d.cts +0 -7
  470. package/node_modules/zod/v4/classic/iso.d.ts +0 -7
  471. package/node_modules/zod/v4/classic/iso.js +0 -15
  472. package/node_modules/zod/v4/classic/package.json +0 -7
  473. package/node_modules/zod/v4/classic/parse.cjs +0 -63
  474. package/node_modules/zod/v4/classic/parse.d.cts +0 -44
  475. package/node_modules/zod/v4/classic/parse.d.ts +0 -44
  476. package/node_modules/zod/v4/classic/parse.js +0 -16
  477. package/node_modules/zod/v4/classic/schemas.cjs +0 -1676
  478. package/node_modules/zod/v4/classic/schemas.d.cts +0 -816
  479. package/node_modules/zod/v4/classic/schemas.d.ts +0 -816
  480. package/node_modules/zod/v4/classic/schemas.js +0 -1535
  481. package/node_modules/zod/v4/core/api.cjs +0 -1269
  482. package/node_modules/zod/v4/core/api.d.cts +0 -335
  483. package/node_modules/zod/v4/core/api.d.ts +0 -335
  484. package/node_modules/zod/v4/core/api.js +0 -1107
  485. package/node_modules/zod/v4/core/checks.cjs +0 -561
  486. package/node_modules/zod/v4/core/checks.d.cts +0 -294
  487. package/node_modules/zod/v4/core/checks.d.ts +0 -294
  488. package/node_modules/zod/v4/core/checks.js +0 -516
  489. package/node_modules/zod/v4/core/compile.cjs +0 -1916
  490. package/node_modules/zod/v4/core/compile.d.cts +0 -65
  491. package/node_modules/zod/v4/core/compile.d.ts +0 -65
  492. package/node_modules/zod/v4/core/compile.js +0 -1866
  493. package/node_modules/zod/v4/core/core.cjs +0 -167
  494. package/node_modules/zod/v4/core/core.d.cts +0 -82
  495. package/node_modules/zod/v4/core/core.d.ts +0 -82
  496. package/node_modules/zod/v4/core/core.js +0 -141
  497. package/node_modules/zod/v4/core/doc.cjs +0 -61
  498. package/node_modules/zod/v4/core/doc.d.cts +0 -16
  499. package/node_modules/zod/v4/core/doc.d.ts +0 -16
  500. package/node_modules/zod/v4/core/doc.js +0 -38
  501. package/node_modules/zod/v4/core/errors.cjs +0 -317
  502. package/node_modules/zod/v4/core/errors.d.cts +0 -225
  503. package/node_modules/zod/v4/core/errors.d.ts +0 -225
  504. package/node_modules/zod/v4/core/errors.js +0 -267
  505. package/node_modules/zod/v4/core/index.cjs +0 -70
  506. package/node_modules/zod/v4/core/index.d.cts +0 -19
  507. package/node_modules/zod/v4/core/index.d.ts +0 -19
  508. package/node_modules/zod/v4/core/index.js +0 -19
  509. package/node_modules/zod/v4/core/json-schema-generator.cjs +0 -122
  510. package/node_modules/zod/v4/core/json-schema-generator.d.cts +0 -65
  511. package/node_modules/zod/v4/core/json-schema-generator.d.ts +0 -65
  512. package/node_modules/zod/v4/core/json-schema-generator.js +0 -99
  513. package/node_modules/zod/v4/core/json-schema-processors.cjs +0 -929
  514. package/node_modules/zod/v4/core/json-schema-processors.d.cts +0 -65
  515. package/node_modules/zod/v4/core/json-schema-processors.d.ts +0 -65
  516. package/node_modules/zod/v4/core/json-schema-processors.js +0 -843
  517. package/node_modules/zod/v4/core/json-schema.cjs +0 -21
  518. package/node_modules/zod/v4/core/json-schema.d.cts +0 -89
  519. package/node_modules/zod/v4/core/json-schema.d.ts +0 -89
  520. package/node_modules/zod/v4/core/json-schema.js +0 -1
  521. package/node_modules/zod/v4/core/memoizer.cjs +0 -360
  522. package/node_modules/zod/v4/core/memoizer.d.cts +0 -15
  523. package/node_modules/zod/v4/core/memoizer.d.ts +0 -15
  524. package/node_modules/zod/v4/core/memoizer.js +0 -311
  525. package/node_modules/zod/v4/core/package.json +0 -7
  526. package/node_modules/zod/v4/core/parse.cjs +0 -233
  527. package/node_modules/zod/v4/core/parse.d.cts +0 -52
  528. package/node_modules/zod/v4/core/parse.d.ts +0 -52
  529. package/node_modules/zod/v4/core/parse.js +0 -175
  530. package/node_modules/zod/v4/core/regexes.cjs +0 -209
  531. package/node_modules/zod/v4/core/regexes.d.cts +0 -90
  532. package/node_modules/zod/v4/core/regexes.d.ts +0 -90
  533. package/node_modules/zod/v4/core/regexes.js +0 -156
  534. package/node_modules/zod/v4/core/registries.cjs +0 -75
  535. package/node_modules/zod/v4/core/registries.d.cts +0 -35
  536. package/node_modules/zod/v4/core/registries.d.ts +0 -35
  537. package/node_modules/zod/v4/core/registries.js +0 -51
  538. package/node_modules/zod/v4/core/schemas.cjs +0 -2699
  539. package/node_modules/zod/v4/core/schemas.d.cts +0 -1275
  540. package/node_modules/zod/v4/core/schemas.d.ts +0 -1275
  541. package/node_modules/zod/v4/core/schemas.js +0 -2636
  542. package/node_modules/zod/v4/core/standard-schema.cjs +0 -21
  543. package/node_modules/zod/v4/core/standard-schema.d.cts +0 -126
  544. package/node_modules/zod/v4/core/standard-schema.d.ts +0 -126
  545. package/node_modules/zod/v4/core/standard-schema.js +0 -1
  546. package/node_modules/zod/v4/core/to-json-schema.cjs +0 -681
  547. package/node_modules/zod/v4/core/to-json-schema.d.cts +0 -154
  548. package/node_modules/zod/v4/core/to-json-schema.d.ts +0 -154
  549. package/node_modules/zod/v4/core/to-json-schema.js +0 -651
  550. package/node_modules/zod/v4/core/util.cjs +0 -964
  551. package/node_modules/zod/v4/core/util.d.cts +0 -280
  552. package/node_modules/zod/v4/core/util.d.ts +0 -280
  553. package/node_modules/zod/v4/core/util.js +0 -873
  554. package/node_modules/zod/v4/core/versions.cjs +0 -27
  555. package/node_modules/zod/v4/core/versions.d.cts +0 -5
  556. package/node_modules/zod/v4/core/versions.d.ts +0 -5
  557. package/node_modules/zod/v4/core/versions.js +0 -5
  558. package/node_modules/zod/v4/core/visit.cjs +0 -214
  559. package/node_modules/zod/v4/core/visit.d.cts +0 -30
  560. package/node_modules/zod/v4/core/visit.d.ts +0 -30
  561. package/node_modules/zod/v4/core/visit.js +0 -169
  562. package/node_modules/zod/v4/index.cjs +0 -51
  563. package/node_modules/zod/v4/index.d.cts +0 -3
  564. package/node_modules/zod/v4/index.d.ts +0 -3
  565. package/node_modules/zod/v4/index.js +0 -4
  566. package/node_modules/zod/v4/locales/ar.cjs +0 -138
  567. package/node_modules/zod/v4/locales/ar.d.cts +0 -5
  568. package/node_modules/zod/v4/locales/ar.d.ts +0 -4
  569. package/node_modules/zod/v4/locales/ar.js +0 -111
  570. package/node_modules/zod/v4/locales/az.cjs +0 -137
  571. package/node_modules/zod/v4/locales/az.d.cts +0 -5
  572. package/node_modules/zod/v4/locales/az.d.ts +0 -4
  573. package/node_modules/zod/v4/locales/az.js +0 -110
  574. package/node_modules/zod/v4/locales/be.cjs +0 -195
  575. package/node_modules/zod/v4/locales/be.d.cts +0 -5
  576. package/node_modules/zod/v4/locales/be.d.ts +0 -4
  577. package/node_modules/zod/v4/locales/be.js +0 -168
  578. package/node_modules/zod/v4/locales/bg.cjs +0 -152
  579. package/node_modules/zod/v4/locales/bg.d.cts +0 -5
  580. package/node_modules/zod/v4/locales/bg.d.ts +0 -4
  581. package/node_modules/zod/v4/locales/bg.js +0 -125
  582. package/node_modules/zod/v4/locales/bn.cjs +0 -140
  583. package/node_modules/zod/v4/locales/bn.d.cts +0 -5
  584. package/node_modules/zod/v4/locales/bn.d.ts +0 -4
  585. package/node_modules/zod/v4/locales/bn.js +0 -113
  586. package/node_modules/zod/v4/locales/ca.cjs +0 -139
  587. package/node_modules/zod/v4/locales/ca.d.cts +0 -5
  588. package/node_modules/zod/v4/locales/ca.d.ts +0 -4
  589. package/node_modules/zod/v4/locales/ca.js +0 -112
  590. package/node_modules/zod/v4/locales/ckb.cjs +0 -160
  591. package/node_modules/zod/v4/locales/ckb.d.cts +0 -5
  592. package/node_modules/zod/v4/locales/ckb.d.ts +0 -4
  593. package/node_modules/zod/v4/locales/ckb.js +0 -133
  594. package/node_modules/zod/v4/locales/cs.cjs +0 -143
  595. package/node_modules/zod/v4/locales/cs.d.cts +0 -5
  596. package/node_modules/zod/v4/locales/cs.d.ts +0 -4
  597. package/node_modules/zod/v4/locales/cs.js +0 -116
  598. package/node_modules/zod/v4/locales/da.cjs +0 -147
  599. package/node_modules/zod/v4/locales/da.d.cts +0 -5
  600. package/node_modules/zod/v4/locales/da.d.ts +0 -4
  601. package/node_modules/zod/v4/locales/da.js +0 -120
  602. package/node_modules/zod/v4/locales/de.cjs +0 -140
  603. package/node_modules/zod/v4/locales/de.d.cts +0 -5
  604. package/node_modules/zod/v4/locales/de.d.ts +0 -4
  605. package/node_modules/zod/v4/locales/de.js +0 -113
  606. package/node_modules/zod/v4/locales/el.cjs +0 -139
  607. package/node_modules/zod/v4/locales/el.d.cts +0 -5
  608. package/node_modules/zod/v4/locales/el.d.ts +0 -4
  609. package/node_modules/zod/v4/locales/el.js +0 -112
  610. package/node_modules/zod/v4/locales/en.cjs +0 -152
  611. package/node_modules/zod/v4/locales/en.d.cts +0 -5
  612. package/node_modules/zod/v4/locales/en.d.ts +0 -4
  613. package/node_modules/zod/v4/locales/en.js +0 -125
  614. package/node_modules/zod/v4/locales/eo.cjs +0 -141
  615. package/node_modules/zod/v4/locales/eo.d.cts +0 -5
  616. package/node_modules/zod/v4/locales/eo.d.ts +0 -4
  617. package/node_modules/zod/v4/locales/eo.js +0 -114
  618. package/node_modules/zod/v4/locales/es.cjs +0 -163
  619. package/node_modules/zod/v4/locales/es.d.cts +0 -5
  620. package/node_modules/zod/v4/locales/es.d.ts +0 -4
  621. package/node_modules/zod/v4/locales/es.js +0 -136
  622. package/node_modules/zod/v4/locales/fa.cjs +0 -146
  623. package/node_modules/zod/v4/locales/fa.d.cts +0 -5
  624. package/node_modules/zod/v4/locales/fa.d.ts +0 -4
  625. package/node_modules/zod/v4/locales/fa.js +0 -119
  626. package/node_modules/zod/v4/locales/fi.cjs +0 -144
  627. package/node_modules/zod/v4/locales/fi.d.cts +0 -5
  628. package/node_modules/zod/v4/locales/fi.d.ts +0 -4
  629. package/node_modules/zod/v4/locales/fi.js +0 -117
  630. package/node_modules/zod/v4/locales/fr-CA.cjs +0 -139
  631. package/node_modules/zod/v4/locales/fr-CA.d.cts +0 -5
  632. package/node_modules/zod/v4/locales/fr-CA.d.ts +0 -4
  633. package/node_modules/zod/v4/locales/fr-CA.js +0 -112
  634. package/node_modules/zod/v4/locales/fr.cjs +0 -156
  635. package/node_modules/zod/v4/locales/fr.d.cts +0 -5
  636. package/node_modules/zod/v4/locales/fr.d.ts +0 -4
  637. package/node_modules/zod/v4/locales/fr.js +0 -129
  638. package/node_modules/zod/v4/locales/gu.cjs +0 -140
  639. package/node_modules/zod/v4/locales/gu.d.cts +0 -5
  640. package/node_modules/zod/v4/locales/gu.d.ts +0 -4
  641. package/node_modules/zod/v4/locales/gu.js +0 -113
  642. package/node_modules/zod/v4/locales/he.cjs +0 -248
  643. package/node_modules/zod/v4/locales/he.d.cts +0 -5
  644. package/node_modules/zod/v4/locales/he.d.ts +0 -4
  645. package/node_modules/zod/v4/locales/he.js +0 -221
  646. package/node_modules/zod/v4/locales/hi.cjs +0 -138
  647. package/node_modules/zod/v4/locales/hi.d.cts +0 -5
  648. package/node_modules/zod/v4/locales/hi.d.ts +0 -4
  649. package/node_modules/zod/v4/locales/hi.js +0 -111
  650. package/node_modules/zod/v4/locales/hr.cjs +0 -153
  651. package/node_modules/zod/v4/locales/hr.d.cts +0 -5
  652. package/node_modules/zod/v4/locales/hr.d.ts +0 -4
  653. package/node_modules/zod/v4/locales/hr.js +0 -126
  654. package/node_modules/zod/v4/locales/hu.cjs +0 -140
  655. package/node_modules/zod/v4/locales/hu.d.cts +0 -5
  656. package/node_modules/zod/v4/locales/hu.d.ts +0 -4
  657. package/node_modules/zod/v4/locales/hu.js +0 -113
  658. package/node_modules/zod/v4/locales/hy.cjs +0 -185
  659. package/node_modules/zod/v4/locales/hy.d.cts +0 -5
  660. package/node_modules/zod/v4/locales/hy.d.ts +0 -4
  661. package/node_modules/zod/v4/locales/hy.js +0 -158
  662. package/node_modules/zod/v4/locales/id.cjs +0 -138
  663. package/node_modules/zod/v4/locales/id.d.cts +0 -5
  664. package/node_modules/zod/v4/locales/id.d.ts +0 -4
  665. package/node_modules/zod/v4/locales/id.js +0 -111
  666. package/node_modules/zod/v4/locales/index.cjs +0 -152
  667. package/node_modules/zod/v4/locales/index.d.cts +0 -63
  668. package/node_modules/zod/v4/locales/index.d.ts +0 -63
  669. package/node_modules/zod/v4/locales/index.js +0 -63
  670. package/node_modules/zod/v4/locales/is.cjs +0 -141
  671. package/node_modules/zod/v4/locales/is.d.cts +0 -5
  672. package/node_modules/zod/v4/locales/is.d.ts +0 -4
  673. package/node_modules/zod/v4/locales/is.js +0 -114
  674. package/node_modules/zod/v4/locales/it.cjs +0 -140
  675. package/node_modules/zod/v4/locales/it.d.cts +0 -5
  676. package/node_modules/zod/v4/locales/it.d.ts +0 -4
  677. package/node_modules/zod/v4/locales/it.js +0 -113
  678. package/node_modules/zod/v4/locales/ja.cjs +0 -139
  679. package/node_modules/zod/v4/locales/ja.d.cts +0 -5
  680. package/node_modules/zod/v4/locales/ja.d.ts +0 -4
  681. package/node_modules/zod/v4/locales/ja.js +0 -112
  682. package/node_modules/zod/v4/locales/ka.cjs +0 -144
  683. package/node_modules/zod/v4/locales/ka.d.cts +0 -5
  684. package/node_modules/zod/v4/locales/ka.d.ts +0 -4
  685. package/node_modules/zod/v4/locales/ka.js +0 -117
  686. package/node_modules/zod/v4/locales/kh.cjs +0 -12
  687. package/node_modules/zod/v4/locales/kh.d.cts +0 -5
  688. package/node_modules/zod/v4/locales/kh.d.ts +0 -5
  689. package/node_modules/zod/v4/locales/kh.js +0 -5
  690. package/node_modules/zod/v4/locales/km.cjs +0 -142
  691. package/node_modules/zod/v4/locales/km.d.cts +0 -5
  692. package/node_modules/zod/v4/locales/km.d.ts +0 -4
  693. package/node_modules/zod/v4/locales/km.js +0 -115
  694. package/node_modules/zod/v4/locales/kn.cjs +0 -143
  695. package/node_modules/zod/v4/locales/kn.d.cts +0 -5
  696. package/node_modules/zod/v4/locales/kn.d.ts +0 -4
  697. package/node_modules/zod/v4/locales/kn.js +0 -116
  698. package/node_modules/zod/v4/locales/ko.cjs +0 -143
  699. package/node_modules/zod/v4/locales/ko.d.cts +0 -5
  700. package/node_modules/zod/v4/locales/ko.d.ts +0 -4
  701. package/node_modules/zod/v4/locales/ko.js +0 -116
  702. package/node_modules/zod/v4/locales/lt.cjs +0 -234
  703. package/node_modules/zod/v4/locales/lt.d.cts +0 -5
  704. package/node_modules/zod/v4/locales/lt.d.ts +0 -4
  705. package/node_modules/zod/v4/locales/lt.js +0 -207
  706. package/node_modules/zod/v4/locales/mk.cjs +0 -141
  707. package/node_modules/zod/v4/locales/mk.d.cts +0 -5
  708. package/node_modules/zod/v4/locales/mk.d.ts +0 -4
  709. package/node_modules/zod/v4/locales/mk.js +0 -114
  710. package/node_modules/zod/v4/locales/ms.cjs +0 -139
  711. package/node_modules/zod/v4/locales/ms.d.cts +0 -5
  712. package/node_modules/zod/v4/locales/ms.d.ts +0 -4
  713. package/node_modules/zod/v4/locales/ms.js +0 -112
  714. package/node_modules/zod/v4/locales/ne.cjs +0 -138
  715. package/node_modules/zod/v4/locales/ne.d.cts +0 -5
  716. package/node_modules/zod/v4/locales/ne.d.ts +0 -4
  717. package/node_modules/zod/v4/locales/ne.js +0 -111
  718. package/node_modules/zod/v4/locales/nl.cjs +0 -142
  719. package/node_modules/zod/v4/locales/nl.d.cts +0 -5
  720. package/node_modules/zod/v4/locales/nl.d.ts +0 -4
  721. package/node_modules/zod/v4/locales/nl.js +0 -115
  722. package/node_modules/zod/v4/locales/nn.cjs +0 -140
  723. package/node_modules/zod/v4/locales/nn.d.cts +0 -5
  724. package/node_modules/zod/v4/locales/nn.d.ts +0 -4
  725. package/node_modules/zod/v4/locales/nn.js +0 -113
  726. package/node_modules/zod/v4/locales/no.cjs +0 -140
  727. package/node_modules/zod/v4/locales/no.d.cts +0 -5
  728. package/node_modules/zod/v4/locales/no.d.ts +0 -4
  729. package/node_modules/zod/v4/locales/no.js +0 -113
  730. package/node_modules/zod/v4/locales/ota.cjs +0 -141
  731. package/node_modules/zod/v4/locales/ota.d.cts +0 -5
  732. package/node_modules/zod/v4/locales/ota.d.ts +0 -4
  733. package/node_modules/zod/v4/locales/ota.js +0 -114
  734. package/node_modules/zod/v4/locales/package.json +0 -7
  735. package/node_modules/zod/v4/locales/pl.cjs +0 -141
  736. package/node_modules/zod/v4/locales/pl.d.cts +0 -5
  737. package/node_modules/zod/v4/locales/pl.d.ts +0 -4
  738. package/node_modules/zod/v4/locales/pl.js +0 -114
  739. package/node_modules/zod/v4/locales/ps.cjs +0 -146
  740. package/node_modules/zod/v4/locales/ps.d.cts +0 -5
  741. package/node_modules/zod/v4/locales/ps.d.ts +0 -4
  742. package/node_modules/zod/v4/locales/ps.js +0 -119
  743. package/node_modules/zod/v4/locales/pt-BR.cjs +0 -170
  744. package/node_modules/zod/v4/locales/pt-BR.d.cts +0 -5
  745. package/node_modules/zod/v4/locales/pt-BR.d.ts +0 -4
  746. package/node_modules/zod/v4/locales/pt-BR.js +0 -143
  747. package/node_modules/zod/v4/locales/pt.cjs +0 -169
  748. package/node_modules/zod/v4/locales/pt.d.cts +0 -5
  749. package/node_modules/zod/v4/locales/pt.d.ts +0 -4
  750. package/node_modules/zod/v4/locales/pt.js +0 -142
  751. package/node_modules/zod/v4/locales/ro.cjs +0 -149
  752. package/node_modules/zod/v4/locales/ro.d.cts +0 -5
  753. package/node_modules/zod/v4/locales/ro.d.ts +0 -4
  754. package/node_modules/zod/v4/locales/ro.js +0 -122
  755. package/node_modules/zod/v4/locales/ru.cjs +0 -195
  756. package/node_modules/zod/v4/locales/ru.d.cts +0 -5
  757. package/node_modules/zod/v4/locales/ru.d.ts +0 -4
  758. package/node_modules/zod/v4/locales/ru.js +0 -168
  759. package/node_modules/zod/v4/locales/sk.cjs +0 -143
  760. package/node_modules/zod/v4/locales/sk.d.cts +0 -5
  761. package/node_modules/zod/v4/locales/sk.d.ts +0 -4
  762. package/node_modules/zod/v4/locales/sk.js +0 -116
  763. package/node_modules/zod/v4/locales/sl.cjs +0 -141
  764. package/node_modules/zod/v4/locales/sl.d.cts +0 -5
  765. package/node_modules/zod/v4/locales/sl.d.ts +0 -4
  766. package/node_modules/zod/v4/locales/sl.js +0 -114
  767. package/node_modules/zod/v4/locales/sv.cjs +0 -142
  768. package/node_modules/zod/v4/locales/sv.d.cts +0 -5
  769. package/node_modules/zod/v4/locales/sv.d.ts +0 -4
  770. package/node_modules/zod/v4/locales/sv.js +0 -115
  771. package/node_modules/zod/v4/locales/ta.cjs +0 -142
  772. package/node_modules/zod/v4/locales/ta.d.cts +0 -5
  773. package/node_modules/zod/v4/locales/ta.d.ts +0 -4
  774. package/node_modules/zod/v4/locales/ta.js +0 -115
  775. package/node_modules/zod/v4/locales/tg.cjs +0 -144
  776. package/node_modules/zod/v4/locales/tg.d.cts +0 -5
  777. package/node_modules/zod/v4/locales/tg.d.ts +0 -4
  778. package/node_modules/zod/v4/locales/tg.js +0 -117
  779. package/node_modules/zod/v4/locales/th.cjs +0 -142
  780. package/node_modules/zod/v4/locales/th.d.cts +0 -5
  781. package/node_modules/zod/v4/locales/th.d.ts +0 -4
  782. package/node_modules/zod/v4/locales/th.js +0 -115
  783. package/node_modules/zod/v4/locales/tk.cjs +0 -134
  784. package/node_modules/zod/v4/locales/tk.d.cts +0 -5
  785. package/node_modules/zod/v4/locales/tk.d.ts +0 -4
  786. package/node_modules/zod/v4/locales/tk.js +0 -107
  787. package/node_modules/zod/v4/locales/tr.cjs +0 -137
  788. package/node_modules/zod/v4/locales/tr.d.cts +0 -5
  789. package/node_modules/zod/v4/locales/tr.d.ts +0 -4
  790. package/node_modules/zod/v4/locales/tr.js +0 -110
  791. package/node_modules/zod/v4/locales/ua.cjs +0 -12
  792. package/node_modules/zod/v4/locales/ua.d.cts +0 -5
  793. package/node_modules/zod/v4/locales/ua.d.ts +0 -5
  794. package/node_modules/zod/v4/locales/ua.js +0 -5
  795. package/node_modules/zod/v4/locales/uk.cjs +0 -140
  796. package/node_modules/zod/v4/locales/uk.d.cts +0 -5
  797. package/node_modules/zod/v4/locales/uk.d.ts +0 -4
  798. package/node_modules/zod/v4/locales/uk.js +0 -113
  799. package/node_modules/zod/v4/locales/ur.cjs +0 -142
  800. package/node_modules/zod/v4/locales/ur.d.cts +0 -5
  801. package/node_modules/zod/v4/locales/ur.d.ts +0 -4
  802. package/node_modules/zod/v4/locales/ur.js +0 -115
  803. package/node_modules/zod/v4/locales/uz.cjs +0 -140
  804. package/node_modules/zod/v4/locales/uz.d.cts +0 -5
  805. package/node_modules/zod/v4/locales/uz.d.ts +0 -4
  806. package/node_modules/zod/v4/locales/uz.js +0 -113
  807. package/node_modules/zod/v4/locales/vi.cjs +0 -140
  808. package/node_modules/zod/v4/locales/vi.d.cts +0 -5
  809. package/node_modules/zod/v4/locales/vi.d.ts +0 -4
  810. package/node_modules/zod/v4/locales/vi.js +0 -113
  811. package/node_modules/zod/v4/locales/yo.cjs +0 -139
  812. package/node_modules/zod/v4/locales/yo.d.cts +0 -5
  813. package/node_modules/zod/v4/locales/yo.d.ts +0 -4
  814. package/node_modules/zod/v4/locales/yo.js +0 -112
  815. package/node_modules/zod/v4/locales/zh-CN.cjs +0 -141
  816. package/node_modules/zod/v4/locales/zh-CN.d.cts +0 -5
  817. package/node_modules/zod/v4/locales/zh-CN.d.ts +0 -4
  818. package/node_modules/zod/v4/locales/zh-CN.js +0 -114
  819. package/node_modules/zod/v4/locales/zh-TW.cjs +0 -139
  820. package/node_modules/zod/v4/locales/zh-TW.d.cts +0 -5
  821. package/node_modules/zod/v4/locales/zh-TW.d.ts +0 -4
  822. package/node_modules/zod/v4/locales/zh-TW.js +0 -112
  823. package/node_modules/zod/v4/mini/checks.cjs +0 -54
  824. package/node_modules/zod/v4/mini/checks.d.cts +0 -1
  825. package/node_modules/zod/v4/mini/checks.d.ts +0 -1
  826. package/node_modules/zod/v4/mini/checks.js +0 -1
  827. package/node_modules/zod/v4/mini/coerce.cjs +0 -71
  828. package/node_modules/zod/v4/mini/coerce.d.cts +0 -7
  829. package/node_modules/zod/v4/mini/coerce.d.ts +0 -7
  830. package/node_modules/zod/v4/mini/coerce.js +0 -22
  831. package/node_modules/zod/v4/mini/deep-partial.cjs +0 -58
  832. package/node_modules/zod/v4/mini/deep-partial.d.cts +0 -14
  833. package/node_modules/zod/v4/mini/deep-partial.d.ts +0 -14
  834. package/node_modules/zod/v4/mini/deep-partial.js +0 -13
  835. package/node_modules/zod/v4/mini/external.cjs +0 -95
  836. package/node_modules/zod/v4/mini/external.d.cts +0 -16
  837. package/node_modules/zod/v4/mini/external.d.ts +0 -16
  838. package/node_modules/zod/v4/mini/external.js +0 -16
  839. package/node_modules/zod/v4/mini/in-out.cjs +0 -82
  840. package/node_modules/zod/v4/mini/in-out.d.cts +0 -8
  841. package/node_modules/zod/v4/mini/in-out.d.ts +0 -8
  842. package/node_modules/zod/v4/mini/in-out.js +0 -36
  843. package/node_modules/zod/v4/mini/index.cjs +0 -51
  844. package/node_modules/zod/v4/mini/index.d.cts +0 -3
  845. package/node_modules/zod/v4/mini/index.d.ts +0 -3
  846. package/node_modules/zod/v4/mini/index.js +0 -3
  847. package/node_modules/zod/v4/mini/iso.cjs +0 -83
  848. package/node_modules/zod/v4/mini/iso.d.cts +0 -22
  849. package/node_modules/zod/v4/mini/iso.d.ts +0 -22
  850. package/node_modules/zod/v4/mini/iso.js +0 -34
  851. package/node_modules/zod/v4/mini/package.json +0 -7
  852. package/node_modules/zod/v4/mini/parse.cjs +0 -37
  853. package/node_modules/zod/v4/mini/parse.d.cts +0 -1
  854. package/node_modules/zod/v4/mini/parse.d.ts +0 -1
  855. package/node_modules/zod/v4/mini/parse.js +0 -1
  856. package/node_modules/zod/v4/mini/schemas.cjs +0 -1147
  857. package/node_modules/zod/v4/mini/schemas.d.cts +0 -480
  858. package/node_modules/zod/v4/mini/schemas.d.ts +0 -480
  859. package/node_modules/zod/v4/mini/schemas.js +0 -1002
  860. package/node_modules/zod/v4/package.json +0 -7
  861. package/node_modules/zod/v4-mini/index.cjs +0 -51
  862. package/node_modules/zod/v4-mini/index.d.cts +0 -3
  863. package/node_modules/zod/v4-mini/index.d.ts +0 -3
  864. package/node_modules/zod/v4-mini/index.js +0 -3
  865. package/node_modules/zod/v4-mini/package.json +0 -7
@@ -1,1916 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || function (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
24
- };
25
- Object.defineProperty(exports, "__esModule", { value: true });
26
- exports.ZodCompileUnsupportedError = exports.ZodCompileAsyncError = exports.INVALID = void 0;
27
- exports.compile = compile;
28
- exports.withParser = withParser;
29
- exports.compileFn = compileFn;
30
- const core_js_1 = require("./core.cjs");
31
- const doc_js_1 = require("./doc.cjs");
32
- const memoizer_js_1 = require("./memoizer.cjs");
33
- const regexes = __importStar(require("./regexes.cjs"));
34
- const schemas_js_1 = require("./schemas.cjs");
35
- const util = __importStar(require("./util.cjs"));
36
- /** @internal Sentinel the compiled fast path returns when validation fails. */
37
- exports.INVALID = Symbol.for("zod.compile.invalid");
38
- // Set on the parse ctx when a compiled wrapper falls back to the runtime, so nested compiled wrappers skip their fast paths for the rest of that parse.
39
- const FALLBACK_FLAG = Symbol.for("zod.compile.fallback");
40
- /** Raised when the schema contains async refinements or transforms. Surfaces only under `compile(schema, { strict: true })`. */
41
- class ZodCompileAsyncError extends Error {
42
- constructor(message = "z.compile does not support async refinements, transforms, or checks") {
43
- super(message);
44
- this.name = "ZodCompileAsyncError";
45
- }
46
- }
47
- exports.ZodCompileAsyncError = ZodCompileAsyncError;
48
- /**
49
- * Raised when the schema contains a feature whose semantics the fast path
50
- * can't fully model. Both the shim in `zod/compile` and the default
51
- * `compile()` fall back to the runtime parser for that schema; only
52
- * `compile(schema, { strict: true })` lets it surface.
53
- */
54
- class ZodCompileUnsupportedError extends Error {
55
- constructor(feature, islandable = true) {
56
- super(`z.compile does not support ${feature}; this schema must use the runtime parser`);
57
- this.name = "ZodCompileUnsupportedError";
58
- this.islandable = islandable;
59
- }
60
- }
61
- exports.ZodCompileUnsupportedError = ZodCompileUnsupportedError;
62
- /**
63
- * Build the validator `validate` calls: the same codegen as the parser with the output construction
64
- * dropped. A schema the flag cannot express reuses the parser, which still answers correctly — it
65
- * just builds a value nothing reads.
66
- */
67
- function compileValidator(schema, parser) {
68
- try {
69
- return compileFn(schema, { assertOnly: true });
70
- }
71
- catch {
72
- return parser;
73
- }
74
- }
75
- /**
76
- * AOT-compile a Zod schema. Returns a clone whose `_zod.run` calls a generated
77
- * fast path first and falls back to the original runtime parser on failure.
78
- *
79
- * - Forward direction only. Backward (encode), async, and `skipChecks` paths
80
- * bypass the fast path and use the runtime directly.
81
- * - Never throws. A schema the fast path can't model is returned unchanged and
82
- * keeps using the runtime parser. Pass `{ strict: true }` to get the refusal
83
- * as a thrown `ZodCompileUnsupportedError` / `ZodCompileAsyncError` instead.
84
- * - The original schema is unchanged. The clone shares children by reference.
85
- */
86
- function compile(schema, options) {
87
- try {
88
- const parser = compileFn(schema);
89
- const clone = withParser(schema, parser);
90
- // withParser leaves the parser as its own validator; the generated assert-only variant is better when we have one
91
- clone._zod.bag.validator = compileValidator(schema, parser);
92
- return clone;
93
- }
94
- catch (err) {
95
- if (options?.strict)
96
- throw err;
97
- // a schema we can't compile still has to work, so hand it back untouched on the runtime parser — the same silent fallback global mode already does
98
- return schema;
99
- }
100
- }
101
- /**
102
- * Install an already-generated parser as a schema's fast path. Returns a clone; the original is
103
- * unchanged.
104
- *
105
- * The parser takes the input and returns the parsed value, or `INVALID` to hand the parse to the
106
- * runtime. It must be synchronous and forward-direction, and it must build fresh output rather than
107
- * return its input — Zod cannot check either, and a wrong *success* is returned to the caller as-is.
108
- *
109
- * `compile()` is the ordinary entry point. This is for a build-time or native compiler that produces
110
- * a parser where `new Function` is unavailable.
111
- */
112
- function withParser(schema, parser) {
113
- // generated code never receives the parse context, so only the runtime can close a reference cycle; compileFn refuses these too
114
- if ((0, memoizer_js_1.isRecursiveSchema)(schema)) {
115
- throw new ZodCompileUnsupportedError("a schema whose subtree contains a reference cycle");
116
- }
117
- const clone = util.clone(schema);
118
- // Capture the source-of-truth runtime eagerly. If schema._zod.run is itself a shim installed by global-mode (`__originalRun` set), unwrap past it. Otherwise capturing the live property lazily would let a later self- replacement of schema._zod.run feed our wrapper back into itself.
119
- const liveRun = schema._zod.run;
120
- const originalRun = liveRun.__originalRun ?? liveRun;
121
- // Delegate to the *original* schema's run on bypass/fallback, not the clone's. The original closed over its own `inst` at construction time, and issue payloads use that reference to derive things like the class name for `z.instanceof(Test)`; calling the clone's freshly-initialized run would push issues with `inst === clone` and diverge from the original schema's error messages.
122
- const wrapped = (payload, ctx) => {
123
- if (ctx?.async ||
124
- ctx?.direction === "backward" ||
125
- ctx?.skipChecks ||
126
- ctx?.[FALLBACK_FLAG]) {
127
- return originalRun(payload, ctx);
128
- }
129
- // A memoized back-edge: only the runtime can close a reference cycle, and a transform on one must raise $ZodCyclicError from its own parse.
130
- if (ctx && (0, memoizer_js_1.isBackEdge)(ctx, payload.value)) {
131
- return originalRun(payload, ctx);
132
- }
133
- const out = parser(payload.value);
134
- if (out !== exports.INVALID) {
135
- payload.value = out;
136
- return payload;
137
- }
138
- // Mark this parse as runtime-driven: under global mode every nested schema carries its own compiled wrapper, and without the flag the parent's runtime fallback re-enters each child's fast path, running user callbacks a third time on invalid input.
139
- if (ctx)
140
- ctx[FALLBACK_FLAG] = true;
141
- return originalRun(payload, ctx);
142
- };
143
- // Let later compiles of (or through) this run unwrap to the true runtime — both the global shim and repeated z.compile calls rely on this. The bag also carries the parser and the validator, so the standalone validate can skip the payload and wrapper on the happy path.
144
- wrapped.__originalRun = originalRun;
145
- clone._zod.bag.fallbackRun = originalRun;
146
- // a supplied parser answers `validate` too: one implementation means parse and validate cannot disagree, and its undefined `definite` keeps the runtime re-parse on every rejection
147
- clone._zod.bag.validator = parser;
148
- clone._zod.run = wrapped;
149
- // The fast parse/safeParse closures fall back through the source schema's methods. If the source is shim- or wrapper-managed, those methods route into a compiled run and would execute user callbacks a third time on invalid input — the plain method → wrapper path is exactly 2x, so skip.
150
- if (!liveRun.__originalRun)
151
- installCompiledUserMethods(clone, schema, parser);
152
- return clone;
153
- }
154
- function installCompiledUserMethods(target, source, parser) {
155
- const targetAny = target;
156
- const sourceAny = source;
157
- if (typeof sourceAny.safeParse === "function") {
158
- const originalSafeParse = sourceAny.safeParse;
159
- targetAny.safeParse = (data, params) => {
160
- const out = parser(data);
161
- if (out !== exports.INVALID) {
162
- return { success: true, data: out };
163
- }
164
- return originalSafeParse(data, params);
165
- };
166
- }
167
- if (typeof sourceAny.parse === "function") {
168
- const originalParse = sourceAny.parse;
169
- targetAny.parse = (data, params) => {
170
- const out = parser(data);
171
- if (out !== exports.INVALID) {
172
- return out;
173
- }
174
- return originalParse(data, params);
175
- };
176
- }
177
- }
178
- /**
179
- * @internal Generate the standalone compiled function: a parser by default, a validator under
180
- * `assertOnly`. Returns the parsed value, `true` where nothing reads the output, or `INVALID`. Consumers use `compile()`.
181
- */
182
- function compileFn(schema, options) {
183
- // Cycle-breaking is keyed on the parse context, which generated code never receives. `shape` can be a getter that throws (z.pick() with an unrecognized mask key), so treat "can't tell" as recursive.
184
- let recursive = true;
185
- try {
186
- recursive = (0, memoizer_js_1.isRecursiveSchema)(schema);
187
- }
188
- catch { }
189
- if (recursive) {
190
- throw new ZodCompileUnsupportedError("a schema whose subtree contains a reference cycle");
191
- }
192
- const ctx = {
193
- constants: new Map(),
194
- constantCounter: 0,
195
- varCounter: 0,
196
- definite: true,
197
- };
198
- const doc = new doc_js_1.Doc(["input"]);
199
- const outputAccessor = generateCheck(doc, ctx, schema, "input", !options?.assertOnly);
200
- // In assert mode a root that built nothing has already returned INVALID on every failure, so reaching the end means valid.
201
- doc.write(outputAccessor === null ? `return true;` : `return ${outputAccessor};`);
202
- // Build the function with hoisted constants Always include INVALID as the first constant
203
- const constantNames = ["INVALID", ...ctx.constants.keys()];
204
- const constantValues = [exports.INVALID, ...ctx.constants.values()];
205
- const code = doc.content.join("\n");
206
- const fullCode = options?.debug
207
- ? constantNames.length > 0
208
- ? `// Constants: ${constantNames.join(", ")}\n${code}`
209
- : code
210
- : "";
211
- const F = Function;
212
- const factoryCode = `return (input) => {\n${code}\n}`;
213
- let fn;
214
- try {
215
- const factory = new F(...constantNames, factoryCode);
216
- fn = factory(...constantValues);
217
- }
218
- catch (err) {
219
- // Malformed generated code (or a CSP environment rejecting `new Function`) surfaces as a typed error so the global shim falls back to the runtime instead of crashing with a raw SyntaxError/EvalError.
220
- throw new ZodCompileUnsupportedError(`this schema (generated code failed to evaluate: ${err.message})`);
221
- }
222
- if (options?.debug) {
223
- fn.code = fullCode;
224
- }
225
- fn.definite = ctx.definite;
226
- return fn;
227
- }
228
- function addConstant(ctx, value) {
229
- // Check if we already have this constant
230
- for (const [name, v] of ctx.constants) {
231
- if (v === value)
232
- return name;
233
- }
234
- const name = `c${ctx.constantCounter++}`;
235
- ctx.constants.set(name, value);
236
- return name;
237
- }
238
- /** Hoists a user-supplied callback. Anything the schema's author wrote can throw, and generated code can reject an earlier sibling before ever reaching it, so this clears `definite` — a rejection is then no longer proof that the interpreter would have rejected rather than thrown. */
239
- function addUserConstant(ctx, fn) {
240
- ctx.definite = false;
241
- return addConstant(ctx, fn);
242
- }
243
- function newVar(ctx) {
244
- return `v${ctx.varCounter++}`;
245
- }
246
- // Runs a child schema as a black box: its value, or INVALID for a failure or an async run.
247
- function runtimeRun(schema, value) {
248
- const result = schema._zod.run({ value, issues: [] }, {});
249
- if (result && typeof result.then === "function")
250
- return exports.INVALID;
251
- const r = result;
252
- return r.issues.length === 0 ? r.value : exports.INVALID;
253
- }
254
- // `null` means the node built no value because nothing reads it. The overloads keep that case out of the 20-odd callers that always want one, so only a caller passing needsValue has to handle it.
255
- function compileChild(doc, ctx, schema, accessor, needsValue = true) {
256
- const contentLen = doc.content.length;
257
- const constantCount = ctx.constants.size;
258
- const constantCounter = ctx.constantCounter;
259
- const varCounter = ctx.varCounter;
260
- try {
261
- return generateCheck(doc, ctx, schema, accessor, needsValue);
262
- }
263
- catch (err) {
264
- if (!(err instanceof ZodCompileUnsupportedError) || !err.islandable)
265
- throw err;
266
- doc.content.length = contentLen;
267
- if (ctx.constants.size > constantCount) {
268
- const trailing = Array.from(ctx.constants.keys()).slice(constantCount);
269
- for (const k of trailing)
270
- ctx.constants.delete(k);
271
- }
272
- ctx.constantCounter = constantCounter;
273
- ctx.varCounter = varCounter;
274
- return emitRuntimeIsland(doc, ctx, schema, accessor);
275
- }
276
- }
277
- function emitRuntimeIsland(doc, ctx, schema, accessor) {
278
- // an islanded child answers INVALID for an async run too, which the interpreter throws for
279
- ctx.definite = false;
280
- const schemaConst = addConstant(ctx, schema);
281
- const runConst = addConstant(ctx, runtimeRun);
282
- const outVar = newVar(ctx);
283
- doc.write(`const ${outVar} = ${runConst}(${schemaConst}, ${accessor});`);
284
- doc.write(`if (${outVar} === INVALID) return INVALID;`);
285
- return outVar;
286
- }
287
- // Check classes whose `when` is auto-defaulted at init (checks.ts `when ??=`).
288
- const WHEN_DEFAULTED_CHECKS = new Set([
289
- "max_size",
290
- "min_size",
291
- "size_equals",
292
- "max_length",
293
- "min_length",
294
- "length_equals",
295
- ]);
296
- function generateChecks(doc, ctx, schema, accessor) {
297
- const schemaChecks = schema._zod.def.checks;
298
- if (!schemaChecks || schemaChecks.length === 0)
299
- return accessor;
300
- // Track current accessor - may change if overwrite checks are encountered
301
- let currentAccessor = accessor;
302
- for (const check of schemaChecks) {
303
- const def = check._zod.def;
304
- // A custom `when` skips a check the fast path always runs; the one auto-defaulted on size/length classes matches its bail-on-first-failure.
305
- if (def.when && !WHEN_DEFAULTED_CHECKS.has(def.check)) {
306
- throw new ZodCompileUnsupportedError(`check with a custom "when" condition`);
307
- }
308
- switch (def.check) {
309
- case "greater_than":
310
- generateGreaterThanCheck(doc, ctx, def, currentAccessor);
311
- break;
312
- case "less_than":
313
- generateLessThanCheck(doc, ctx, def, currentAccessor);
314
- break;
315
- case "multiple_of":
316
- generateMultipleOfCheck(doc, ctx, def, currentAccessor);
317
- break;
318
- case "number_format":
319
- generateNumberFormatCheck(doc, def, currentAccessor);
320
- break;
321
- case "min_length": {
322
- const min = numericOperand(def.minimum, "min_length");
323
- const len = codePointLengthVar(doc, ctx, currentAccessor, `${currentAccessor}.length >= ${min} && ${currentAccessor}.length < ${def.minimum * 2}`);
324
- doc.write(`if (${len} < ${min}) return INVALID;`);
325
- break;
326
- }
327
- case "max_length": {
328
- const max = numericOperand(def.maximum, "max_length");
329
- const len = codePointLengthVar(doc, ctx, currentAccessor, `${currentAccessor}.length > ${max}`);
330
- doc.write(`if (${len} > ${max}) return INVALID;`);
331
- break;
332
- }
333
- case "length_equals": {
334
- const exact = numericOperand(def.length, "length_equals");
335
- const len = codePointLengthVar(doc, ctx, currentAccessor, `${currentAccessor}.length >= ${exact} && ${currentAccessor}.length <= ${def.length * 2}`);
336
- doc.write(`if (${len} !== ${exact}) return INVALID;`);
337
- break;
338
- }
339
- case "min_size":
340
- doc.write(`if (${currentAccessor}.size < ${numericOperand(def.minimum, "min_size")}) return INVALID;`);
341
- break;
342
- case "max_size":
343
- doc.write(`if (${currentAccessor}.size > ${numericOperand(def.maximum, "max_size")}) return INVALID;`);
344
- break;
345
- case "size_equals":
346
- doc.write(`if (${currentAccessor}.size !== ${numericOperand(def.size, "size_equals")}) return INVALID;`);
347
- break;
348
- case "string_format":
349
- currentAccessor = generateStringFormatCheck(doc, ctx, def, currentAccessor);
350
- break;
351
- case "custom":
352
- currentAccessor = generateCustomRefineCheck(doc, ctx, check, currentAccessor);
353
- break;
354
- case "bigint_format":
355
- generateBigIntFormatCheck(doc, def, currentAccessor);
356
- break;
357
- case "mime_type":
358
- generateMimeTypeCheck(doc, ctx, def, currentAccessor);
359
- break;
360
- case "property":
361
- generatePropertyCheck(doc, ctx, def, currentAccessor);
362
- break;
363
- case "properties":
364
- generatePropertiesChecks(doc, ctx, def, currentAccessor);
365
- break;
366
- case "overwrite": {
367
- // Overwrite transforms the value - create new variable for transformed result
368
- const newAccessor = newVar(ctx);
369
- generateOverwriteCheck(doc, ctx, check, currentAccessor, newAccessor);
370
- currentAccessor = newAccessor;
371
- break;
372
- }
373
- default: {
374
- void def;
375
- throw new ZodCompileUnsupportedError(`check type ${def.check}`);
376
- }
377
- }
378
- }
379
- return currentAccessor;
380
- }
381
- // Emit the length operand for a length check, mirroring `$ZodCheckMinLength` and friends: strings measure in code points, everything else in `.length`. `inDoubt` is the caller's cheap UTF-16 bound test — outside it the unit count already settles the comparison, so the scan is skipped.
382
- function codePointLengthVar(doc, ctx, accessor, inDoubt) {
383
- const cpLen = addConstant(ctx, util.codePointLength);
384
- const v = newVar(ctx);
385
- doc.write(`const ${v} = typeof ${accessor} === "string" && ${inDoubt} ? ${cpLen}(${accessor}) : ${accessor}.length;`);
386
- return v;
387
- }
388
- // Emit a source operand for a gt/lt bound. Numbers inline; Dates hoist as a constant (relational operators compare via valueOf). NaN and Invalid Date bounds can't compile to a comparison that matches runtime semantics.
389
- /**
390
- * A count bound reaches generated source verbatim, so a non-number would be
391
- * emitted as code rather than as a value — `min('0) {} evil(); if (0')` writes an
392
- * arbitrary statement into the function body. TypeScript types these as `number`
393
- * and fromJSONSchema guards them, so this is a backstop rather than a live hole,
394
- * but generated source is the one place a wrong type stops being a type error.
395
- */
396
- function numericOperand(value, label) {
397
- if (typeof value !== "number" || !Number.isFinite(value)) {
398
- throw new ZodCompileUnsupportedError(`${label} bound of type ${typeof value}`);
399
- }
400
- return `${value}`;
401
- }
402
- function comparisonOperand(ctx, value) {
403
- if (typeof value === "bigint")
404
- return `${value}n`;
405
- if (typeof value === "number") {
406
- if (Number.isNaN(value))
407
- throw new ZodCompileUnsupportedError("comparison check with NaN bound");
408
- return `${value}`;
409
- }
410
- if (value instanceof Date) {
411
- if (Number.isNaN(value.getTime())) {
412
- throw new ZodCompileUnsupportedError("comparison check with Invalid Date bound");
413
- }
414
- return addConstant(ctx, value);
415
- }
416
- throw new ZodCompileUnsupportedError(`comparison check bound of type ${typeof value}`);
417
- }
418
- function generateGreaterThanCheck(doc, ctx, def, accessor) {
419
- const op = def.inclusive ? "<" : "<=";
420
- doc.write(`if (${accessor} ${op} ${comparisonOperand(ctx, def.value)}) return INVALID;`);
421
- }
422
- function generateLessThanCheck(doc, ctx, def, accessor) {
423
- const op = def.inclusive ? ">" : ">=";
424
- doc.write(`if (${accessor} ${op} ${comparisonOperand(ctx, def.value)}) return INVALID;`);
425
- }
426
- function generateMultipleOfCheck(doc, ctx, def, accessor) {
427
- if (typeof def.value === "bigint") {
428
- // a zero divisor has no compiled form: `x % 0n` throws
429
- if (def.value === BigInt(0))
430
- throw new ZodCompileUnsupportedError("multiple_of check with a zero divisor");
431
- doc.write(`if (${accessor} % ${def.value}n !== 0n) return INVALID;`);
432
- }
433
- else {
434
- // Float `%` has well-known precision issues for sub-integer steps
435
- // (`1.5 % 0.1`, `2.5e-7 % 1e-7`). Defer to util.floatSafeRemainder so the
436
- // exact tolerance logic stays in one place — single function call is fine
437
- // since `multipleOf` runs at most once per number.
438
- const remainder = addConstant(ctx, util.floatSafeRemainder);
439
- doc.write(`if (${remainder}(${accessor}, ${numericOperand(def.value, "multiple_of")}) !== 0) return INVALID;`);
440
- }
441
- }
442
- function generateNumberFormatCheck(doc, def, accessor) {
443
- const format = def.format;
444
- switch (format) {
445
- case "safeint":
446
- doc.write(`if (!Number.isSafeInteger(${accessor})) return INVALID;`);
447
- break;
448
- case "int32":
449
- doc.write(`if (!Number.isInteger(${accessor}) || ${accessor} < -2147483648 || ${accessor} > 2147483647) return INVALID;`);
450
- break;
451
- case "uint32":
452
- doc.write(`if (!Number.isInteger(${accessor}) || ${accessor} < 0 || ${accessor} > 4294967295) return INVALID;`);
453
- break;
454
- case "float32":
455
- // Float32 range per util.NUMBER_FORMAT_RANGES
456
- doc.write(`if (!Number.isFinite(${accessor}) || ${accessor} < -3.4028234663852886e38 || ${accessor} > 3.4028234663852886e38) return INVALID;`);
457
- break;
458
- case "float64":
459
- doc.write(`if (!Number.isFinite(${accessor})) return INVALID;`);
460
- break;
461
- default: {
462
- void format;
463
- throw new ZodCompileUnsupportedError(`number format ${format}`);
464
- }
465
- }
466
- }
467
- function generateBigIntFormatCheck(doc, def, accessor) {
468
- const format = def.format;
469
- if (!format)
470
- return; // undefined format means no range check
471
- switch (format) {
472
- case "int64":
473
- doc.write(`if (${accessor} < -9223372036854775808n || ${accessor} > 9223372036854775807n) return INVALID;`);
474
- break;
475
- case "uint64":
476
- doc.write(`if (${accessor} < 0n || ${accessor} > 18446744073709551615n) return INVALID;`);
477
- break;
478
- default: {
479
- void format;
480
- throw new ZodCompileUnsupportedError(`bigint format ${format}`);
481
- }
482
- }
483
- }
484
- function generateMimeTypeCheck(doc, ctx, def, accessor) {
485
- const mimeTypes = def.mime;
486
- if (mimeTypes && mimeTypes.length > 0) {
487
- const mimeSet = addConstant(ctx, new Set(mimeTypes));
488
- doc.write(`if (!${mimeSet}.has(${accessor}.type)) return INVALID;`);
489
- }
490
- }
491
- // asserts each named property in place; children compile assert-only because z.properties never rebuilds its input
492
- function generatePropertiesChecks(doc, ctx, def, accessor) {
493
- // a custom `when` gates the assertion at runtime; inside a union a wrongly-run branch is absorbed as a branch failure rather than falling back, so refuse at codegen
494
- if (def.when) {
495
- throw new ZodCompileUnsupportedError(`check with a custom "when" condition`);
496
- }
497
- // matches the runtime gate: the base schema already typed the value, so only a nullish one is rejected
498
- doc.write(`if (${accessor} == null) return INVALID;`);
499
- const shape = def.shape;
500
- for (const key of Reflect.ownKeys(shape)) {
501
- // a symbol has no source literal, so it is hoisted as a constant
502
- const keyExpr = typeof key === "symbol" ? addConstant(ctx, key) : util.esc(key);
503
- // cache the property read so a getter runs exactly once, matching the runtime
504
- const inputVar = newVar(ctx);
505
- doc.write(`const ${inputVar} = ${accessor}[${keyExpr}];`);
506
- compileChild(doc, ctx, shape[key], inputVar, false);
507
- }
508
- }
509
- function generatePropertyCheck(doc, ctx, def, accessor) {
510
- const propAccessor = `${accessor}[${JSON.stringify(def.property)}]`;
511
- generateCheck(doc, ctx, def.schema, propAccessor);
512
- }
513
- function generateOverwriteCheck(doc, ctx, check, currentAccessor, newAccessor) {
514
- const tx = check._zod.def.tx;
515
- if (!tx) {
516
- throw new ZodCompileUnsupportedError("overwrite check without a transform function");
517
- }
518
- // Check for async transform
519
- if (isAsyncFunction(tx)) {
520
- throw new ZodCompileAsyncError("z.compile: async overwrite transforms are not supported");
521
- }
522
- // Hoist the transform function as a constant and apply it
523
- const txConst = addConstant(ctx, tx);
524
- doc.write(`const ${newAccessor} = ${txConst}(${currentAccessor});`);
525
- }
526
- /** A predicate that hands back a thenable is an async check reached synchronously, and the interpreter throws `$ZodAsyncError` for it. Returning INVALID instead would be a bail-out, and a union reads a bail-out as a rejected branch and answers with a later one — so the throw has to survive into generated code. */
527
- function throwAsync() {
528
- throw new core_js_1.$ZodAsyncError();
529
- }
530
- /** Shared `addIssue` for the spoofed payloads a refine, check or transform receives. Allocating one per call — a fresh closure plus a `this`-bound method on a fresh literal — pinned every payload-allocating schema at ~2.7M ops/sec against 135M for a plain object literal. It captures nothing per call; it only reaches `this.issues`. */
531
- function pushIssue(issue) {
532
- this.issues.push(issue);
533
- }
534
- function generateCustomRefineCheck(doc, ctx, check, accessor) {
535
- const def = check._zod.def;
536
- if (def.fn) {
537
- // Simple predicate function (from .refine())
538
- if (isAsyncFunction(def.fn)) {
539
- throw new ZodCompileAsyncError("z.compile: async .refine() predicates are not supported");
540
- }
541
- const fnConst = addUserConstant(ctx, def.fn);
542
- const throwAsyncConst = addConstant(ctx, throwAsync);
543
- const resVar = newVar(ctx);
544
- doc.write(`const ${resVar} = ${fnConst}(${accessor});`);
545
- // A thenable is truthy, so it would otherwise read as a pass. It is not a rejection either: the interpreter throws, and INVALID inside a union would just hand the parse to the next branch.
546
- doc.write(`if (${resVar} instanceof Promise) ${throwAsyncConst}();`);
547
- doc.write(`if (!${resVar}) return INVALID;`);
548
- // A `.refine()` predicate only answers yes or no; it cannot rewrite the value.
549
- return accessor;
550
- }
551
- if (check._zod.check) {
552
- if (isAsyncFunction(check._zod.check)) {
553
- throw new ZodCompileAsyncError("z.compile: async .superRefine() / check functions are not supported");
554
- }
555
- // SuperRefine or other check function - need to spoof context Create a helper that runs the check and returns true if no issues
556
- const checkFn = check._zod.check;
557
- // `$RefinementCtx` extends the parse payload, so a check may rewrite
558
- // `ctx.value` as well as push issues — `.superRefine((v, ctx) => { ctx.value =
559
- // v.trim() })` is a value transform. Returning only a boolean discarded that
560
- // write and emitted the untrimmed input. Hand the value back and thread it on.
561
- const helperFn = (value) => {
562
- const fakePayload = { value, issues: [], addIssue: pushIssue };
563
- const result = checkFn(fakePayload);
564
- // Throw rather than return INVALID: the interpreter throws here, and a union would read INVALID as a rejected branch.
565
- if (result instanceof Promise)
566
- throwAsync();
567
- return fakePayload.issues.length === 0 ? fakePayload.value : exports.INVALID;
568
- };
569
- const helperConst = addUserConstant(ctx, helperFn);
570
- const outVar = newVar(ctx);
571
- doc.write(`const ${outVar} = ${helperConst}(${accessor});`);
572
- doc.write(`if (${outVar} === INVALID) return INVALID;`);
573
- return outVar;
574
- }
575
- throw new ZodCompileUnsupportedError("custom check without a predicate or check function");
576
- }
577
- /**
578
- * Built-in formats that validate with nothing but `def.pattern`, so compiling
579
- * the regex reproduces the runtime exactly. Deliberately an allowlist: a format
580
- * missing from it loses its fast path, while a format wrongly added to it
581
- * silently accepts input the runtime rejects. Formats that layer extra
582
- * validation over a shape-only pattern (`credit_card`, `base64`, `ipv6`, …) are
583
- * handled above by hoisting the runtime validator itself.
584
- */
585
- const PATTERN_IS_COMPLETE = new Set([
586
- "cidrv4",
587
- "cuid",
588
- "cuid2",
589
- "date",
590
- "datetime",
591
- "duration",
592
- "e164",
593
- "email",
594
- "emoji",
595
- "ends_with",
596
- "guid",
597
- "includes",
598
- "ipv4",
599
- "ksuid",
600
- "lowercase",
601
- "mac",
602
- "nanoid",
603
- "regex",
604
- "starts_with",
605
- "time",
606
- "ulid",
607
- "uppercase",
608
- "uuid",
609
- "xid",
610
- ]);
611
- function generateStringFormatCheck(doc, ctx, def, accessor, needsValue = true) {
612
- // Some string formats do runtime validation beyond their advertised pattern. For cheap pure utility checks, hoist the runtime function and call it so the fast path stays correct without cloning the utility logic into codegen.
613
- const fmt = def.format;
614
- if (fmt === "base64") {
615
- const validator = addConstant(ctx, schemas_js_1.isValidBase64);
616
- doc.write(`if (!${validator}(${accessor})) return INVALID;`);
617
- return accessor;
618
- }
619
- if (fmt === "base64url") {
620
- const validator = addConstant(ctx, schemas_js_1.isValidBase64URL);
621
- doc.write(`if (!${validator}(${accessor})) return INVALID;`);
622
- return accessor;
623
- }
624
- if (fmt === "jwt") {
625
- const validator = addConstant(ctx, schemas_js_1.isValidJWT);
626
- const alg = addConstant(ctx, def.alg ?? null);
627
- doc.write(`if (!${validator}(${accessor}, ${alg})) return INVALID;`);
628
- return accessor;
629
- }
630
- if (fmt === "ipv6") {
631
- const validator = addConstant(ctx, schemas_js_1.isValidIPv6);
632
- doc.write(`if (!${validator}(${accessor})) return INVALID;`);
633
- return accessor;
634
- }
635
- if (fmt === "cidrv6") {
636
- const validator = addConstant(ctx, schemas_js_1.isValidCIDRv6);
637
- doc.write(`if (!${validator}(${accessor})) return INVALID;`);
638
- return accessor;
639
- }
640
- if (fmt === "credit_card") {
641
- const validator = addConstant(ctx, schemas_js_1.isValidCreditCard);
642
- doc.write(`if (!${validator}(${accessor})) return INVALID;`);
643
- return accessor;
644
- }
645
- if (fmt === "iban") {
646
- const validator = addConstant(ctx, schemas_js_1.isValidIBAN);
647
- doc.write(`if (!${validator}(${accessor})) return INVALID;`);
648
- return accessor;
649
- }
650
- const formatDef = def;
651
- if (fmt === "url" ||
652
- fmt === "httpurl" ||
653
- formatDef.normalize ||
654
- formatDef.hostname !== undefined ||
655
- formatDef.protocol !== undefined) {
656
- // Same three predicates the runtime calls, in the same order, so there is no second URL implementation to drift. Which options exist is known now, so the calls the runtime makes conditionally are emitted conditionally instead.
657
- const parseConst = addConstant(ctx, schemas_js_1.validateURL);
658
- const defConst = addConstant(ctx, def);
659
- const trimVar = newVar(ctx);
660
- const urlVar = newVar(ctx);
661
- doc.write(`const ${trimVar} = ${accessor}.trim();`);
662
- doc.write(`const ${urlVar} = ${parseConst}(${trimVar}, ${defConst});`);
663
- doc.write(`if (typeof ${urlVar} === "number") return INVALID;`);
664
- if (formatDef.hostname !== undefined) {
665
- const hostnameConst = addConstant(ctx, schemas_js_1.urlHostnameOk);
666
- doc.write(`if (!${hostnameConst}(${urlVar}, ${defConst}.hostname)) return INVALID;`);
667
- }
668
- if (formatDef.protocol !== undefined) {
669
- const protocolConst = addConstant(ctx, schemas_js_1.urlProtocolOk);
670
- doc.write(`if (!${protocolConst}(${urlVar}, ${defConst}.protocol)) return INVALID;`);
671
- }
672
- if (!needsValue)
673
- return null;
674
- const outputVar = newVar(ctx);
675
- const outputExpr = formatDef.normalize ? `${urlVar}.href` : `${addConstant(ctx, schemas_js_1.stripTabAndNewline)}(${trimVar})`;
676
- doc.write(`const ${outputVar} = ${outputExpr};`);
677
- return outputVar;
678
- }
679
- // A custom string format carries the predicate the runtime actually calls. Hoist and call it instead of testing `def.pattern`: the two only coincide when the format was built from a RegExp, and relying on that coupling is how supplemental validation gets dropped.
680
- const customFn = def.fn;
681
- if (customFn) {
682
- if (isAsyncFunction(customFn))
683
- throw new ZodCompileUnsupportedError(`async string format ${fmt}`);
684
- const fnConst = addConstant(ctx, customFn);
685
- doc.write(`if (!${fnConst}(${accessor})) return INVALID;`);
686
- return accessor;
687
- }
688
- // Formats whose `pattern` IS the whole check. An allowlist rather than `if (def.pattern)`, because credit_card, base64 and ipv6 carry a shape-only pattern and validate the rest separately.
689
- if (PATTERN_IS_COMPLETE.has(fmt) && def.pattern) {
690
- const patternConst = addConstant(ctx, def.pattern);
691
- doc.write(`${patternConst}.lastIndex = 0;`);
692
- doc.write(`if (!${patternConst}.test(${accessor})) return INVALID;`);
693
- return accessor;
694
- }
695
- const format = def.format;
696
- switch (format) {
697
- case "regex":
698
- // A regex check with a pattern returned above. Reaching here means there is no pattern to test, and accepting unconditionally would pass every input, so hand the schema back to the runtime.
699
- throw new ZodCompileUnsupportedError("regex format without a pattern");
700
- case "lowercase":
701
- doc.write(`if (${accessor} !== ${accessor}.toLowerCase()) return INVALID;`);
702
- break;
703
- case "uppercase":
704
- doc.write(`if (${accessor} !== ${accessor}.toUpperCase()) return INVALID;`);
705
- break;
706
- case "includes":
707
- doc.write(`if (!${accessor}.includes(${util.esc(def.includes)})) return INVALID;`);
708
- break;
709
- case "starts_with": {
710
- const prefix = def.prefix;
711
- doc.write(`if (${accessor}.slice(0, ${prefix.length}) !== ${util.esc(prefix)}) return INVALID;`);
712
- break;
713
- }
714
- case "ends_with": {
715
- const suffix = def.suffix;
716
- doc.write(`if (${accessor}.slice(-${suffix.length}) !== ${util.esc(suffix)}) return INVALID;`);
717
- break;
718
- }
719
- default: {
720
- void format;
721
- throw new ZodCompileUnsupportedError(`string format ${format}`);
722
- }
723
- }
724
- return accessor;
725
- }
726
- function generateCheck(doc, ctx, schema, accessor, needsValue = true) {
727
- const def = schema._zod.def;
728
- const type = def.type;
729
- // A coercing schema would compile to the bare type test and reject what it should convert; inside a union that reads as a rejected branch, so refuse at codegen.
730
- if (def.coerce) {
731
- throw new ZodCompileUnsupportedError(`coercion (z.coerce.${type}())`);
732
- }
733
- // A node builds its output when its caller reads one, or when it carries checks of its own, since a check reads what was built. One polarity for the whole walk: this is what the node does, and it is what its children are told they need.
734
- const buildsValue = needsValue || !!def.checks?.length;
735
- let typeAccessor;
736
- switch (type) {
737
- case "string":
738
- typeAccessor = generateStringCheck(doc, ctx, schema, accessor, buildsValue);
739
- break;
740
- case "number":
741
- typeAccessor = generateNumberCheck(doc, schema, accessor);
742
- break;
743
- case "boolean":
744
- typeAccessor = generateBooleanCheck(doc, accessor);
745
- break;
746
- case "bigint":
747
- typeAccessor = generateBigIntCheck(doc, schema, accessor);
748
- break;
749
- case "symbol":
750
- typeAccessor = generateSymbolCheck(doc, accessor);
751
- break;
752
- case "undefined":
753
- typeAccessor = generateUndefinedCheck(doc, accessor);
754
- break;
755
- case "null":
756
- typeAccessor = generateNullCheck(doc, accessor);
757
- break;
758
- case "any":
759
- case "unknown":
760
- // No check needed - pass through
761
- typeAccessor = accessor;
762
- break;
763
- case "never":
764
- doc.write("return INVALID;");
765
- typeAccessor = accessor;
766
- break;
767
- case "void":
768
- typeAccessor = generateVoidCheck(doc, accessor);
769
- break;
770
- case "nan":
771
- typeAccessor = generateNaNCheck(doc, accessor);
772
- break;
773
- case "date":
774
- typeAccessor = generateDateCheck(doc, accessor);
775
- break;
776
- case "object":
777
- typeAccessor = generateObjectCheck(doc, ctx, schema, accessor, buildsValue);
778
- break;
779
- case "optional":
780
- typeAccessor = generateOptionalCheck(doc, ctx, schema, accessor, buildsValue);
781
- break;
782
- case "nullable":
783
- typeAccessor = generateNullableCheck(doc, ctx, schema, accessor, buildsValue);
784
- break;
785
- case "array":
786
- typeAccessor = generateArrayCheck(doc, ctx, schema, accessor, buildsValue);
787
- break;
788
- case "literal":
789
- typeAccessor = generateLiteralCheck(doc, ctx, schema, accessor);
790
- break;
791
- case "enum":
792
- typeAccessor = generateEnumCheck(doc, ctx, schema, accessor);
793
- break;
794
- case "readonly": {
795
- const innerOut = generateWrapperCheck(doc, ctx, schema, accessor);
796
- // Runtime freezes the parsed value (schemas.ts handleReadonlyResult).
797
- const frozenVar = newVar(ctx);
798
- doc.write(`const ${frozenVar} = Object.freeze(${innerOut});`);
799
- typeAccessor = frozenVar;
800
- break;
801
- }
802
- case "success":
803
- // Runtime output is `issues.length === 0`. The fast path only reaches
804
- // here when the inner check passed (failure returns INVALID and the
805
- // runtime fallback reproduces the inner issues), so the output is
806
- // always `true`.
807
- generateWrapperCheck(doc, ctx, schema, accessor);
808
- typeAccessor = "true";
809
- break;
810
- case "default":
811
- case "prefault":
812
- typeAccessor = generateDefaultCheck(doc, ctx, schema, accessor);
813
- break;
814
- case "nonoptional":
815
- typeAccessor = generateNonOptionalCheck(doc, ctx, schema, accessor);
816
- break;
817
- case "tuple":
818
- typeAccessor = generateTupleCheck(doc, ctx, schema, accessor);
819
- break;
820
- case "union":
821
- typeAccessor = generateUnionCheck(doc, ctx, schema, accessor);
822
- break;
823
- case "intersection":
824
- typeAccessor = generateIntersectionCheck(doc, ctx, schema, accessor);
825
- break;
826
- case "record":
827
- typeAccessor = generateRecordCheck(doc, ctx, schema, accessor);
828
- break;
829
- case "map":
830
- typeAccessor = generateMapCheck(doc, ctx, schema, accessor);
831
- break;
832
- case "set":
833
- typeAccessor = generateSetCheck(doc, ctx, schema, accessor);
834
- break;
835
- case "file":
836
- typeAccessor = generateFileCheck(doc, accessor);
837
- break;
838
- case "template_literal":
839
- typeAccessor = generateTemplateLiteralCheck(doc, ctx, schema, accessor);
840
- break;
841
- case "lazy":
842
- typeAccessor = generateLazyCheck(doc, ctx, schema, accessor);
843
- break;
844
- case "pipe":
845
- typeAccessor = generatePipeCheck(doc, ctx, schema, accessor);
846
- break;
847
- case "custom":
848
- typeAccessor = generateCustomCheck(doc, ctx, schema, accessor);
849
- break;
850
- case "transform":
851
- typeAccessor = generateTransformCheck(doc, ctx, schema, accessor);
852
- break;
853
- case "catch":
854
- typeAccessor = generateCatchCheck(doc, ctx, schema, accessor);
855
- break;
856
- default: {
857
- void type;
858
- throw new ZodCompileUnsupportedError(`schema type ${type}`);
859
- }
860
- }
861
- // a node that built nothing has no checks to run: not building requires an empty check list
862
- if (typeAccessor === null)
863
- return null;
864
- // Generate checks after the type-specific validation (may transform value)
865
- return generateChecks(doc, ctx, schema, typeAccessor);
866
- }
867
- function generateStringCheck(doc, ctx, schema, accessor, needsValue = true) {
868
- doc.write(`if (typeof ${accessor} !== "string") return INVALID;`);
869
- // z.email() carries its format on the def, z.string().email() in def.checks; both route here so the format table has no second copy to drift from.
870
- const def = schema._zod.def;
871
- if (def.format === undefined)
872
- return accessor;
873
- return generateStringFormatCheck(doc, ctx, def, accessor, needsValue);
874
- }
875
- function generateNumberCheck(doc, schema, accessor) {
876
- // Runtime z.number() rejects NaN and ±Infinity. Number.isFinite covers both.
877
- doc.write(`if (typeof ${accessor} !== "number" || !Number.isFinite(${accessor})) return INVALID;`);
878
- // Mini factories like z.int(), z.int32(), z.uint32(), z.float32() bake a number_format check into the schema def itself (not into def.checks). Apply the same constraint here.
879
- const def = schema._zod.def;
880
- if (def.check === "number_format" && def.format) {
881
- generateNumberFormatCheck(doc, { format: def.format }, accessor);
882
- }
883
- return accessor;
884
- }
885
- function generateBooleanCheck(doc, accessor) {
886
- doc.write(`if (typeof ${accessor} !== "boolean") return INVALID;`);
887
- return accessor;
888
- }
889
- function generateBigIntCheck(doc, schema, accessor) {
890
- doc.write(`if (typeof ${accessor} !== "bigint") return INVALID;`);
891
- // Handle bigint format (int64, uint64) directly on the schema def
892
- const def = schema._zod.def;
893
- if (def.format) {
894
- switch (def.format) {
895
- case "int64":
896
- doc.write(`if (${accessor} < -9223372036854775808n || ${accessor} > 9223372036854775807n) return INVALID;`);
897
- break;
898
- case "uint64":
899
- doc.write(`if (${accessor} < 0n || ${accessor} > 18446744073709551615n) return INVALID;`);
900
- break;
901
- }
902
- }
903
- return accessor;
904
- }
905
- function generateSymbolCheck(doc, accessor) {
906
- doc.write(`if (typeof ${accessor} !== "symbol") return INVALID;`);
907
- return accessor;
908
- }
909
- function generateUndefinedCheck(doc, accessor) {
910
- doc.write(`if (${accessor} !== undefined) return INVALID;`);
911
- return accessor;
912
- }
913
- function generateNullCheck(doc, accessor) {
914
- doc.write(`if (${accessor} !== null) return INVALID;`);
915
- return accessor;
916
- }
917
- function generateVoidCheck(doc, accessor) {
918
- doc.write(`if (${accessor} !== undefined) return INVALID;`);
919
- return accessor;
920
- }
921
- function generateNaNCheck(doc, accessor) {
922
- doc.write(`if (typeof ${accessor} !== "number" || !Number.isNaN(${accessor})) return INVALID;`);
923
- return accessor;
924
- }
925
- function generateDateCheck(doc, accessor) {
926
- doc.write(`if (!(${accessor} instanceof Date) || Number.isNaN(${accessor}.getTime())) return INVALID;`);
927
- return accessor;
928
- }
929
- function generateObjectCheck(doc, ctx, schema, accessor, buildsValue = true) {
930
- const def = schema._zod.def;
931
- // Check that input is a non-null, non-array object
932
- doc.write(`if (typeof ${accessor} !== "object" || ${accessor} === null || Array.isArray(${accessor})) return INVALID;`);
933
- const shape = def.shape;
934
- const keys = Object.keys(shape);
935
- const symbolKeys = Object.getOwnPropertySymbols(shape);
936
- // a symbol has no source literal, so it is hoisted as a constant; `keys` stays string-only where the emitted code uses `for...in`
937
- const allKeys = symbolKeys.length ? [...keys, ...symbolKeys] : keys;
938
- const keyExpr = (k) => (typeof k === "symbol" ? addConstant(ctx, k) : util.esc(k));
939
- const propKey = (k) => (typeof k === "symbol" ? `[${keyExpr(k)}]` : util.esc(k));
940
- const propShape = shape;
941
- // `__proto__` as an own shape key can't be expressed in an output object literal (the literal form sets the prototype instead of an own property).
942
- if (keys.includes("__proto__")) {
943
- throw new ZodCompileUnsupportedError('object shape key "__proto__"');
944
- }
945
- // Map from key to output accessor for that property
946
- const propOutputs = new Map();
947
- // Validate each property and collect output accessors
948
- for (const key of allKeys) {
949
- const propSchema = propShape[key];
950
- const kx = keyExpr(key);
951
- // Always cache the property read: the runtime reads input[key] exactly once, so a getter must not be re-read by checks or output assembly.
952
- const inputVar = newVar(ctx);
953
- doc.write(`const ${inputVar} = ${accessor}[${kx}];`);
954
- if (propSchema._zod.optin !== undefined) {
955
- // Any optin rung means the key may be omitted. The runtime runs the property anyway and ignores issues only when the key is genuinely absent, which is what makes exactOptional compositional.
956
- const outputVar = newVar(ctx);
957
- doc.write(`let ${outputVar} = (() => {`);
958
- doc.indented((d) => {
959
- const outputAccessor = compileChild(d, ctx, propSchema, inputVar);
960
- d.write(`return ${outputAccessor};`);
961
- });
962
- doc.write(`})();`);
963
- if (propSchema._zod.optout === "optional") {
964
- doc.write(`if (${outputVar} === INVALID) {`);
965
- doc.indented((d) => {
966
- d.write(`if (${kx} in ${accessor}) return INVALID;`);
967
- d.write(`${outputVar} = undefined;`);
968
- });
969
- doc.write(`}`);
970
- }
971
- else {
972
- doc.write(`if (${outputVar} === INVALID) return INVALID;`);
973
- }
974
- propOutputs.set(key, outputVar);
975
- }
976
- else {
977
- if (requiresPresenceCheck(propSchema)) {
978
- doc.write(`if (!(${kx} in ${accessor})) return INVALID;`);
979
- }
980
- // Generate check and get output accessor
981
- const outputAccessor = compileChild(doc, ctx, propSchema, inputVar, buildsValue);
982
- if (outputAccessor !== null)
983
- propOutputs.set(key, outputAccessor);
984
- }
985
- }
986
- // Handle catchall
987
- const catchall = def.catchall;
988
- let unknownKeysMode = "none";
989
- if (catchall) {
990
- const catchallType = catchall._zod.def.type;
991
- if (catchallType === "never") {
992
- // Strict: one `for...in`, as the runtime does, so inherited enumerable keys count. An undeclared `__proto__` is reported here and excluded only from the output (#6221); an own-key count would wrongly reject a class instance.
993
- const condition = keys.map((k) => `k !== ${util.esc(k)}`).join(" && ") || "true";
994
- doc.write(`for (const k in ${accessor}) {`);
995
- doc.indented((d) => {
996
- d.write(`if (${condition}) return INVALID;`);
997
- });
998
- doc.write(`}`);
999
- }
1000
- else if ((catchallType === "unknown" || catchallType === "any") && !catchall._zod.def.checks?.length) {
1001
- unknownKeysMode = "passthrough";
1002
- }
1003
- else {
1004
- unknownKeysMode = "schema";
1005
- }
1006
- }
1007
- // else: strip mode (no catchall) - unknown keys ignored, only include known keys
1008
- // defaulted required outputs keep their keys even when undefined
1009
- const outputVar = newVar(ctx);
1010
- const hasConditionalKeys = allKeys.some((k) => mayOmitUndefined(propShape[k]) || dropsWhenAbsent(propShape[k]));
1011
- // Assert mode: every declared key is validated above, so the output literal and the unknown-key copy are pure waste. A `never` catchall already emitted its rejection loop; a schema catchall still has to validate the values it would otherwise have stored.
1012
- if (!buildsValue) {
1013
- if (unknownKeysMode === "schema") {
1014
- const knownSet = keys.length > 0 ? addConstant(ctx, new Set(keys)) : null;
1015
- doc.write(`for (const k in ${accessor}) {`);
1016
- doc.indented((d) => {
1017
- d.write(`if (k === "__proto__") continue;`);
1018
- if (knownSet)
1019
- d.write(`if (${knownSet}.has(k)) continue;`);
1020
- const valVar = newVar(ctx);
1021
- d.write(`const ${valVar} = ${accessor}[k];`);
1022
- compileChild(d, ctx, catchall, valVar, false);
1023
- });
1024
- doc.write(`}`);
1025
- }
1026
- return null;
1027
- }
1028
- if (!hasConditionalKeys) {
1029
- const propLiterals = allKeys.map((k) => `${propKey(k)}: ${propOutputs.get(k)}`).join(", ");
1030
- doc.write(`const ${outputVar} = { ${propLiterals} };`);
1031
- }
1032
- else {
1033
- doc.write(`const ${outputVar} = {};`);
1034
- for (const k of allKeys) {
1035
- const kx = keyExpr(k);
1036
- const out = propOutputs.get(k);
1037
- if (dropsWhenAbsent(propShape[k])) {
1038
- doc.write(`if (${kx} in ${accessor}) ${outputVar}[${kx}] = ${out};`);
1039
- }
1040
- else if (mayOmitUndefined(propShape[k])) {
1041
- doc.write(`if (${out} !== undefined || ${kx} in ${accessor}) ${outputVar}[${kx}] = ${out};`);
1042
- }
1043
- else {
1044
- doc.write(`${outputVar}[${kx}] = ${out};`);
1045
- }
1046
- }
1047
- }
1048
- if (unknownKeysMode !== "none") {
1049
- // Unknown keys are written directly into the output after shape keys — for...in (like the runtime) so inherited enumerables participate.
1050
- const knownSet = keys.length > 0 ? addConstant(ctx, new Set(keys)) : null;
1051
- doc.write(`for (const k in ${accessor}) {`);
1052
- doc.indented((d) => {
1053
- // Skip __proto__: assigning obj["__proto__"] on a plain {} replaces the prototype via the setter rather than adding an own property. Mirrors the runtime catchall fix (#5898).
1054
- d.write(`if (k === "__proto__") continue;`);
1055
- if (knownSet)
1056
- d.write(`if (${knownSet}.has(k)) continue;`);
1057
- if (unknownKeysMode === "passthrough") {
1058
- d.write(`${outputVar}[k] = ${accessor}[k];`);
1059
- }
1060
- else {
1061
- const valVar = newVar(ctx);
1062
- d.write(`const ${valVar} = ${accessor}[k];`);
1063
- const catchallOut = compileChild(d, ctx, catchall, valVar);
1064
- d.write(`${outputVar}[k] = ${catchallOut};`);
1065
- }
1066
- });
1067
- doc.write(`}`);
1068
- }
1069
- return outputVar;
1070
- }
1071
- function generateOptionalCheck(doc, ctx, schema, accessor, buildsValue = true) {
1072
- const def = schema._zod.def;
1073
- if (isExactOptional(schema)) {
1074
- return generateCheck(doc, ctx, def.innerType, accessor, buildsValue);
1075
- }
1076
- // Same question $ZodOptional asks: only the top rung of the optin ladder substitutes a value for an absent input, so only it is worth running on `undefined`. Every other rung leaves the value intact, which is the skip branch below.
1077
- if (def.innerType._zod.optin === "defaulted") {
1078
- const outputVar = newVar(ctx);
1079
- const branchVar = newVar(ctx);
1080
- doc.write(`let ${outputVar};`);
1081
- doc.write(`if (${accessor} === undefined) {`);
1082
- doc.indented((d) => {
1083
- d.write(`const ${branchVar} = (() => {`);
1084
- d.indented((d2) => {
1085
- const innerOutput = generateCheck(d2, ctx, def.innerType, accessor);
1086
- d2.write(`return ${innerOutput};`);
1087
- });
1088
- d.write(`})();`);
1089
- d.write(`if (${branchVar} !== INVALID) ${outputVar} = ${branchVar};`);
1090
- });
1091
- doc.write(`} else {`);
1092
- doc.indented((d) => {
1093
- const innerOutput = generateCheck(d, ctx, def.innerType, accessor);
1094
- d.write(`${outputVar} = ${innerOutput};`);
1095
- });
1096
- doc.write(`}`);
1097
- return outputVar;
1098
- }
1099
- const outputVar = buildsValue ? newVar(ctx) : null;
1100
- if (outputVar)
1101
- doc.write(`let ${outputVar};`);
1102
- doc.write(`if (${accessor} !== undefined) {`);
1103
- doc.indented((d) => {
1104
- const innerOutput = generateCheck(d, ctx, def.innerType, accessor, buildsValue);
1105
- if (outputVar && innerOutput !== null)
1106
- d.write(`${outputVar} = ${innerOutput};`);
1107
- });
1108
- doc.write(`}`);
1109
- return outputVar;
1110
- }
1111
- function isExactOptional(schema) {
1112
- return schema._zod.traits?.has("$ZodExactOptional") === true;
1113
- }
1114
- // A value-level fast path reads an absent key as `undefined`, so z.undefined(), z.any() and unions containing undefined would accept a missing property the runtime rejects.
1115
- function requiresPresenceCheck(schema) {
1116
- return schema._zod.optin === undefined && fastPathAcceptsAbsence(schema);
1117
- }
1118
- function fastPathAcceptsAbsence(schema) {
1119
- // An island is handed `input[key]` and cannot tell absent from explicitly undefined, so report absence-accepting and let the object emit the presence guard (#6405).
1120
- if (schema._zod.def.coerce)
1121
- return true;
1122
- const def = schema._zod.def;
1123
- switch (def.type) {
1124
- case "any":
1125
- case "unknown":
1126
- case "undefined":
1127
- case "void":
1128
- case "default":
1129
- case "prefault":
1130
- case "transform":
1131
- case "custom":
1132
- case "lazy":
1133
- return true;
1134
- case "string":
1135
- case "number":
1136
- case "boolean":
1137
- case "bigint":
1138
- case "symbol":
1139
- case "null":
1140
- case "never":
1141
- case "nan":
1142
- case "date":
1143
- case "object":
1144
- case "array":
1145
- case "tuple":
1146
- case "record":
1147
- case "map":
1148
- case "set":
1149
- case "file":
1150
- case "template_literal":
1151
- return false;
1152
- case "nonoptional":
1153
- // Normally rejects an absent key, but not when something inside supplies a value for it: `.default(v).optional().nonoptional()` accepts absence and yields v. Defer to the inner — over-reporting here only costs a presence check, and a fast path that wrongly rejects still falls back to the runtime.
1154
- return def.innerType ? fastPathAcceptsAbsence(def.innerType) : false;
1155
- case "literal":
1156
- return !!def.values?.includes(undefined);
1157
- case "enum":
1158
- return !!schema._zod.values?.has(undefined);
1159
- case "optional":
1160
- case "nullable":
1161
- case "readonly":
1162
- case "success":
1163
- return def.innerType ? fastPathAcceptsAbsence(def.innerType) : true;
1164
- case "catch":
1165
- // catch always produces a value (inner may fail → catchValue substitutes), so it accepts an absent key regardless of inner.
1166
- return true;
1167
- case "union":
1168
- return def.options ? def.options.some(fastPathAcceptsAbsence) : true;
1169
- case "intersection":
1170
- if (!def.left || !def.right)
1171
- return true;
1172
- return fastPathAcceptsAbsence(def.left) && fastPathAcceptsAbsence(def.right);
1173
- case "pipe":
1174
- return def.in ? fastPathAcceptsAbsence(def.in) : true;
1175
- default:
1176
- return true;
1177
- }
1178
- }
1179
- /** The middle rung permits absence without supplying anything in its place, so an absent key contributes nothing — mirrors the leading gate in `handlePropertyResult`. */
1180
- function dropsWhenAbsent(schema) {
1181
- return schema._zod.optin === "optional" && schema._zod.optout === "optional";
1182
- }
1183
- function mayOmitUndefined(schema) {
1184
- return (schema._zod.optin !== "defaulted" || schema._zod.optout === "optional") && mayOutputUndefined(schema);
1185
- }
1186
- // whether a schema's success-path output can be undefined
1187
- function mayOutputUndefined(schema) {
1188
- const def = schema._zod.def;
1189
- switch (def.type) {
1190
- case "string":
1191
- case "number":
1192
- case "boolean":
1193
- case "bigint":
1194
- case "symbol":
1195
- case "null":
1196
- case "nan":
1197
- case "date":
1198
- case "object":
1199
- case "array":
1200
- case "tuple":
1201
- case "record":
1202
- case "map":
1203
- case "set":
1204
- case "file":
1205
- case "template_literal":
1206
- case "never":
1207
- case "success":
1208
- return false;
1209
- case "literal":
1210
- return !!def.values?.includes(undefined);
1211
- case "enum":
1212
- return !!schema._zod.values?.has(undefined);
1213
- case "optional":
1214
- return true;
1215
- case "nullable":
1216
- case "readonly":
1217
- case "nonoptional":
1218
- return def.innerType ? mayOutputUndefined(def.innerType) : true;
1219
- case "union":
1220
- return def.options ? def.options.some(mayOutputUndefined) : true;
1221
- case "intersection":
1222
- return !def.left || !def.right || mayOutputUndefined(def.left) || mayOutputUndefined(def.right);
1223
- case "pipe":
1224
- return def.out ? mayOutputUndefined(def.out) : true;
1225
- default:
1226
- // any/unknown/undefined/void/default/prefault/transform/custom/lazy/catch
1227
- return true;
1228
- }
1229
- }
1230
- function generateNullableCheck(doc, ctx, schema, accessor, buildsValue = true) {
1231
- const def = schema._zod.def;
1232
- const outputVar = buildsValue ? newVar(ctx) : null;
1233
- if (outputVar)
1234
- doc.write(`let ${outputVar} = null;`);
1235
- doc.write(`if (${accessor} !== null) {`);
1236
- doc.indented((d) => {
1237
- const innerOutput = generateCheck(d, ctx, def.innerType, accessor, buildsValue);
1238
- if (outputVar && innerOutput !== null)
1239
- d.write(`${outputVar} = ${innerOutput};`);
1240
- });
1241
- doc.write(`}`);
1242
- return outputVar;
1243
- }
1244
- function generateSizeGate(doc, schema, size) {
1245
- for (const [max, check] of util.sizeCaps(schema._zod.def.checks)) {
1246
- doc.write(`if (${size} > ${numericOperand(max, check._zod.def.check)}) return INVALID;`);
1247
- }
1248
- }
1249
- function generateArrayCheck(doc, ctx, schema, accessor, buildsValue = true) {
1250
- const def = schema._zod.def;
1251
- doc.write(`if (!Array.isArray(${accessor})) return INVALID;`);
1252
- generateSizeGate(doc, schema, `${accessor}.length`);
1253
- // Build a new array with validated/transformed elements.
1254
- const outputVar = buildsValue ? newVar(ctx) : null;
1255
- const iVar = newVar(ctx);
1256
- const elemVar = newVar(ctx);
1257
- if (outputVar)
1258
- doc.write(`const ${outputVar} = new Array(${accessor}.length);`);
1259
- doc.write(`for (let ${iVar} = 0; ${iVar} < ${accessor}.length; ${iVar}++) {`);
1260
- doc.indented((d) => {
1261
- d.write(`const ${elemVar} = ${accessor}[${iVar}];`);
1262
- const elemOutput = compileChild(d, ctx, def.element, elemVar, buildsValue);
1263
- if (outputVar && elemOutput !== null)
1264
- d.write(`${outputVar}[${iVar}] = ${elemOutput};`);
1265
- });
1266
- doc.write(`}`);
1267
- return outputVar;
1268
- }
1269
- function generateLiteralCheck(doc, ctx, schema, accessor) {
1270
- const def = schema._zod.def;
1271
- const values = def.values;
1272
- // Anything but a single value goes through Set.has: multi-value so every value participates, empty so nothing does — values[0] would be undefined and compile to an `!== undefined` check that accepts it. Single-value stays inlined for speed.
1273
- if (values.length !== 1) {
1274
- const literalSet = addConstant(ctx, new Set(values));
1275
- doc.write(`if (!${literalSet}.has(${accessor})) return INVALID;`);
1276
- return accessor;
1277
- }
1278
- const value = values[0];
1279
- // `$ZodLiteral` matches with `values.has`, i.e. SameValueZero, so NaN matches itself. `x !== NaN` is true for every input, which would reject everything — hand it to the same Set form the multi-value path uses.
1280
- if (typeof value === "number" && Number.isNaN(value)) {
1281
- const literalSet = addConstant(ctx, new Set(values));
1282
- doc.write(`if (!${literalSet}.has(${accessor})) return INVALID;`);
1283
- return accessor;
1284
- }
1285
- if (typeof value === "string") {
1286
- doc.write(`if (${accessor} !== ${util.esc(value)}) return INVALID;`);
1287
- }
1288
- else if (typeof value === "number" || typeof value === "boolean") {
1289
- doc.write(`if (${accessor} !== ${value}) return INVALID;`);
1290
- }
1291
- else if (value === null) {
1292
- doc.write(`if (${accessor} !== null) return INVALID;`);
1293
- }
1294
- else if (value === undefined) {
1295
- doc.write(`if (${accessor} !== undefined) return INVALID;`);
1296
- }
1297
- else if (typeof value === "bigint") {
1298
- doc.write(`if (${accessor} !== ${value}n) return INVALID;`);
1299
- }
1300
- else {
1301
- throw new ZodCompileUnsupportedError(`literal type ${typeof value}`);
1302
- }
1303
- return accessor;
1304
- }
1305
- function generateEnumCheck(doc, ctx, schema, accessor) {
1306
- const values = schema._zod.values;
1307
- // z.partialRecord and friends clear `_zod.values`, leaving no set to test membership against. Throw rather than emit INVALID so a union falls back whole instead of counting a false rejection.
1308
- if (!values) {
1309
- throw new ZodCompileUnsupportedError("enum schema without enumerated values");
1310
- }
1311
- const enumSet = addConstant(ctx, values);
1312
- doc.write(`if (!${enumSet}.has(${accessor})) return INVALID;`);
1313
- return accessor;
1314
- }
1315
- function generateWrapperCheck(doc, ctx, schema, accessor) {
1316
- const def = schema._zod.def;
1317
- return generateCheck(doc, ctx, def.innerType, accessor);
1318
- }
1319
- function generateDefaultCheck(doc, ctx, schema, accessor) {
1320
- const def = schema._zod.def;
1321
- // `defaultValue` is an accessor on schemas built through the classic/mini
1322
- // factories and a plain data property on ones rebuilt programmatically
1323
- // (deepPartial and friends). Read it off the def either way — taking only
1324
- // `descriptor.get` silently dropped the default for the second kind, so
1325
- // `.default(v)` compiled to `undefined` instead of `v`.
1326
- const descriptor = Object.getOwnPropertyDescriptor(schema._zod.def, "defaultValue");
1327
- const defaultGetter = descriptor
1328
- ? () => schema._zod.def.defaultValue
1329
- : undefined;
1330
- // prefault differs from default: undefined-input is first replaced with the prefault value, then run through the inner schema.
1331
- if (schema._zod.def.type === "prefault") {
1332
- if (!defaultGetter) {
1333
- return generateCheck(doc, ctx, def.innerType, accessor);
1334
- }
1335
- const defaultFn = addConstant(ctx, defaultGetter);
1336
- const inputVar = newVar(ctx);
1337
- doc.write(`let ${inputVar} = ${accessor};`);
1338
- doc.write(`if (${accessor} === undefined) ${inputVar} = ${defaultFn}();`);
1339
- return generateCheck(doc, ctx, def.innerType, inputVar);
1340
- }
1341
- const outputVar = newVar(ctx);
1342
- // Default allows undefined (replaces with default value), otherwise validates inner type
1343
- if (defaultGetter) {
1344
- const defaultFn = addConstant(ctx, defaultGetter);
1345
- const cloneFn = addConstant(ctx, util.shallowClone);
1346
- doc.write(`let ${outputVar};`);
1347
- doc.write(`if (${accessor} === undefined) {`);
1348
- doc.indented((d) => {
1349
- // Shallow-clone the default so callers can mutate the result without affecting subsequent parses (#5855 — also covers Map/Set).
1350
- d.write(`${outputVar} = ${cloneFn}(${defaultFn}());`);
1351
- });
1352
- doc.write(`} else {`);
1353
- doc.indented((d) => {
1354
- const innerOutput = generateCheck(d, ctx, def.innerType, accessor);
1355
- d.write(`${outputVar} = ${innerOutput} === undefined ? ${cloneFn}(${defaultFn}()) : ${innerOutput};`);
1356
- });
1357
- doc.write(`}`);
1358
- }
1359
- else {
1360
- doc.write(`let ${outputVar};`);
1361
- doc.write(`if (${accessor} !== undefined) {`);
1362
- doc.indented((d) => {
1363
- const innerOutput = generateCheck(d, ctx, def.innerType, accessor);
1364
- d.write(`${outputVar} = ${innerOutput};`);
1365
- });
1366
- doc.write(`}`);
1367
- }
1368
- return outputVar;
1369
- }
1370
- function generateNonOptionalCheck(doc, ctx, schema, accessor) {
1371
- const def = schema._zod.def;
1372
- // The runtime inspects what the inner produced, not what it was given: a catch can turn a defined input into undefined, a default an absent one into a value.
1373
- const innerOutput = generateCheck(doc, ctx, def.innerType, accessor);
1374
- const outputVar = newVar(ctx);
1375
- doc.write(`const ${outputVar} = ${innerOutput};`);
1376
- doc.write(`if (${outputVar} === undefined) return INVALID;`);
1377
- return outputVar;
1378
- }
1379
- function generateTupleCheck(doc, ctx, schema, accessor) {
1380
- const def = schema._zod.def;
1381
- const items = def.items;
1382
- const rest = def.rest;
1383
- doc.write(`if (!Array.isArray(${accessor})) return INVALID;`);
1384
- // Mirror the runtime's getTupleOptStart: find the first index where every subsequent slot accepts `undefined` (i.e. is optional on input). Anything shorter than this is too_small; trailing absent slots are legal.
1385
- const optinStart = getTupleOptStart(items, "optin");
1386
- const optoutStart = getTupleOptStart(items, "optout");
1387
- // Length bounds
1388
- if (rest) {
1389
- // With rest: minimum length is the last required input slot
1390
- doc.write(`if (${accessor}.length < ${optinStart}) return INVALID;`);
1391
- }
1392
- else {
1393
- // No rest: input must be in [optinStart, items.length]
1394
- doc.write(`if (${accessor}.length < ${optinStart} || ${accessor}.length > ${items.length}) return INVALID;`);
1395
- }
1396
- // Build the output in assignment order so absent optional-output tail slots can truncate while default/prefault slots still fill missing positions.
1397
- const outputVar = newVar(ctx);
1398
- doc.write(`const ${outputVar} = [];`);
1399
- // Validate and collect each fixed item
1400
- for (let i = 0; i < items.length; i++) {
1401
- const itemSchema = items[i];
1402
- if (i >= optoutStart) {
1403
- doc.write(`if (${outputVar}.length === ${i}) {`);
1404
- doc.indented((d) => {
1405
- d.write(`if (${i} < ${accessor}.length) {`);
1406
- d.indented((d2) => {
1407
- const elemVar = newVar(ctx);
1408
- d2.write(`const ${elemVar} = ${accessor}[${i}];`);
1409
- const elemOutput = compileChild(d2, ctx, itemSchema, elemVar);
1410
- d2.write(`${outputVar}[${i}] = ${elemOutput};`);
1411
- });
1412
- d.write(`} else {`);
1413
- d.indented((d2) => {
1414
- // Middle rung: absence supplies nothing in its place, so truncate rather than running the item on `undefined` and keeping what it invents. Mirrors the leading gate in `handleTupleResults`.
1415
- if (dropsWhenAbsent(itemSchema)) {
1416
- d2.write(`${outputVar}.length = ${i};`);
1417
- return;
1418
- }
1419
- const elemVar = newVar(ctx);
1420
- const branchVar = newVar(ctx);
1421
- d2.write(`const ${elemVar} = undefined;`);
1422
- d2.write(`const ${branchVar} = (() => {`);
1423
- d2.indented((d3) => {
1424
- const elemOutput = compileChild(d3, ctx, itemSchema, elemVar);
1425
- d3.write(`return ${elemOutput};`);
1426
- });
1427
- d2.write(`})();`);
1428
- d2.write(`if (${branchVar} === INVALID || ${branchVar} === undefined) ${outputVar}.length = ${i};`);
1429
- d2.write(`else ${outputVar}[${i}] = ${branchVar};`);
1430
- });
1431
- d.write(`}`);
1432
- });
1433
- doc.write(`}`);
1434
- }
1435
- else {
1436
- const elemVar = newVar(ctx);
1437
- doc.write(`const ${elemVar} = ${accessor}[${i}];`);
1438
- const elemOutput = compileChild(doc, ctx, itemSchema, elemVar);
1439
- doc.write(`${outputVar}[${i}] = ${elemOutput};`);
1440
- }
1441
- }
1442
- // Validate and collect rest elements if present
1443
- if (rest) {
1444
- const iVar = newVar(ctx);
1445
- const elemVar = newVar(ctx);
1446
- doc.write(`for (let ${iVar} = ${items.length}; ${iVar} < ${accessor}.length; ${iVar}++) {`);
1447
- doc.indented((d) => {
1448
- d.write(`const ${elemVar} = ${accessor}[${iVar}];`);
1449
- const elemOutput = compileChild(d, ctx, rest, elemVar);
1450
- d.write(`${outputVar}[${iVar}] = ${elemOutput};`);
1451
- });
1452
- doc.write(`}`);
1453
- }
1454
- return outputVar;
1455
- }
1456
- function getTupleOptStart(items, key) {
1457
- for (let i = items.length - 1; i >= 0; i--) {
1458
- // Mirrors the runtime: optin is a three-rung ladder so any rung above `undefined` permits an absent slot; optout stays two-valued.
1459
- const omittable = key === "optin" ? items[i]._zod.optin !== undefined : items[i]._zod.optout === "optional";
1460
- if (!omittable)
1461
- return i + 1;
1462
- }
1463
- return 0;
1464
- }
1465
- function generateUnionCheck(doc, ctx, schema, accessor) {
1466
- const def = schema._zod.def;
1467
- const options = def.options;
1468
- if (def.discriminator) {
1469
- return generateDiscriminatedUnionCheck(doc, ctx, def, accessor);
1470
- }
1471
- // z.xor requires *exactly one* option to match. Match-counting in the fast path is only sound if every branch is exactly as strict as the runtime — any falsely-rejecting branch silently turns a multi-match rejection into an accept. Force the runtime for this rare combinator.
1472
- if (def.inclusive === false) {
1473
- throw new ZodCompileUnsupportedError("exclusive unions (z.xor)");
1474
- }
1475
- if (options.length === 0) {
1476
- doc.write("return INVALID;");
1477
- return accessor;
1478
- }
1479
- if (options.length === 1) {
1480
- return generateCheck(doc, ctx, options[0], accessor);
1481
- }
1482
- // Check if all options are bare literals - use Set optimization. A literal option carrying checks (e.g. .refine) must take the general path or the Set would accept values its checks reject.
1483
- const allLiterals = options.every((opt) => opt._zod.def.type === "literal" && !opt._zod.def.checks?.length);
1484
- if (allLiterals) {
1485
- const values = new Set(options.flatMap((opt) => opt._zod.def.values));
1486
- const valuesConst = addConstant(ctx, values);
1487
- doc.write(`if (!${valuesConst}.has(${accessor})) return INVALID;`);
1488
- return accessor;
1489
- }
1490
- // General case: try each option until one succeeds Use IIFEs that return the output or INVALID
1491
- const outputVar = newVar(ctx);
1492
- doc.write(`let ${outputVar};`);
1493
- for (let i = 0; i < options.length; i++) {
1494
- const opt = options[i];
1495
- if (i === 0) {
1496
- doc.write(`${outputVar} = (() => {`);
1497
- }
1498
- else {
1499
- doc.write(`if (${outputVar} === INVALID) ${outputVar} = (() => {`);
1500
- }
1501
- doc.indented((d) => {
1502
- // Generate check inside IIFE - returns INVALID on failure
1503
- const branchOutput = generateCheck(d, ctx, opt, accessor);
1504
- d.write(`return ${branchOutput};`);
1505
- });
1506
- doc.write(`})();`);
1507
- }
1508
- doc.write(`if (${outputVar} === INVALID) return INVALID;`);
1509
- return outputVar;
1510
- }
1511
- function generateDiscriminatedUnionCheck(doc, ctx, def, accessor) {
1512
- if (def.unionFallback) {
1513
- throw new ZodCompileUnsupportedError("discriminated union with unionFallback");
1514
- }
1515
- if (def.options.length === 0) {
1516
- doc.write("return INVALID;");
1517
- return accessor;
1518
- }
1519
- const discVar = newVar(ctx);
1520
- const outputVar = newVar(ctx);
1521
- doc.write(`const ${discVar} = ${accessor}?.[${util.esc(def.discriminator)}];`);
1522
- doc.write(`let ${outputVar};`);
1523
- let firstBranch = true;
1524
- const claimed = new Set();
1525
- for (const option of def.options) {
1526
- const values = option._zod.propValues?.[def.discriminator];
1527
- if (!values || values.size === 0) {
1528
- throw new ZodCompileUnsupportedError("discriminated union option without static discriminator values");
1529
- }
1530
- // let the interpreter handle collisions instead of compiling first-match dispatch
1531
- for (const value of values) {
1532
- if (claimed.has(value)) {
1533
- throw new ZodCompileUnsupportedError(`duplicate discriminator value ${String(value)}`);
1534
- }
1535
- claimed.add(value);
1536
- }
1537
- const conditions = Array.from(values, (value) => literalEquality(ctx, discVar, value));
1538
- const prefix = firstBranch ? "if" : "else if";
1539
- doc.write(`${prefix} (${conditions.join(" || ")}) {`);
1540
- doc.indented((d) => {
1541
- const branchOutput = generateCheck(d, ctx, option, accessor);
1542
- d.write(`${outputVar} = ${branchOutput};`);
1543
- });
1544
- doc.write(`}`);
1545
- firstBranch = false;
1546
- }
1547
- doc.write(`else { return INVALID; }`);
1548
- return outputVar;
1549
- }
1550
- function literalEquality(ctx, accessor, value) {
1551
- if (typeof value === "string")
1552
- return `${accessor} === ${util.esc(value)}`;
1553
- if (typeof value === "number") {
1554
- if (Number.isNaN(value))
1555
- return `Number.isNaN(${accessor})`;
1556
- return `${accessor} === ${value}`;
1557
- }
1558
- if (typeof value === "boolean")
1559
- return `${accessor} === ${value}`;
1560
- if (value === null)
1561
- return `${accessor} === null`;
1562
- if (value === undefined)
1563
- return `${accessor} === undefined`;
1564
- if (typeof value === "bigint")
1565
- return `${accessor} === ${value}n`;
1566
- if (typeof value === "symbol") {
1567
- const symbolConst = addConstant(ctx, value);
1568
- return `${accessor} === ${symbolConst}`;
1569
- }
1570
- throw new ZodCompileUnsupportedError(`literal discriminator value ${String(value)}`);
1571
- }
1572
- function generateIntersectionCheck(doc, ctx, schema, accessor) {
1573
- const def = schema._zod.def;
1574
- // An unmergeable merge, and a child failing before the merge is even reached, both return INVALID for a case the interpreter answers with a throw.
1575
- ctx.definite = false;
1576
- const leftOutput = compileChild(doc, ctx, def.left, accessor);
1577
- const rightOutput = compileChild(doc, ctx, def.right, accessor);
1578
- // Hoist the runtime merge helper so recursive object/array merge semantics stay in one place. If the merge is invalid, return INVALID and let the runtime fallback construct canonical errors.
1579
- const mergeConst = addConstant(ctx, schemas_js_1.mergeValues);
1580
- const mergedVar = newVar(ctx);
1581
- doc.write(`const ${mergedVar} = ${mergeConst}(${leftOutput}, ${rightOutput});`);
1582
- doc.write(`if (!${mergedVar}.valid) return INVALID;`);
1583
- return `${mergedVar}.data`;
1584
- }
1585
- function generateRecordCheck(doc, ctx, schema, accessor) {
1586
- const def = schema._zod.def;
1587
- // Use util.isPlainObject (rejects Date, Map, Set, class instances, etc.) to match runtime behavior. Hoisted call instead of inline so this stays a single source of truth with the runtime parser.
1588
- const isPlainObjectConst = addConstant(ctx, util.isPlainObject);
1589
- doc.write(`if (!${isPlainObjectConst}(${accessor})) return INVALID;`);
1590
- const outputVar = newVar(ctx);
1591
- const kVar = newVar(ctx);
1592
- const valVar = newVar(ctx);
1593
- doc.write(`const ${outputVar} = {};`);
1594
- // Exhaustive record. The runtime gates this on `values && !def.partial`, since z.partialRecord keeps its value set but makes every key optional; a loose record passes unrecognized keys through, which the per-key scan cannot express.
1595
- const recordDef = def;
1596
- const keyValues = recordDef.partial ? undefined : def.keyType._zod.values;
1597
- if (keyValues) {
1598
- const inputKeys = [];
1599
- for (const key of keyValues) {
1600
- if (!(typeof key === "string" || typeof key === "number" || typeof key === "symbol")) {
1601
- throw new ZodCompileUnsupportedError(`record key value ${String(key)}`);
1602
- }
1603
- const inputKey = typeof key === "number" ? key.toString() : key;
1604
- if (inputKey === "__proto__") {
1605
- // `out["__proto__"] = v` would hit the prototype setter on the output.
1606
- throw new ZodCompileUnsupportedError('record key "__proto__"');
1607
- }
1608
- inputKeys.push(inputKey);
1609
- const keyConst = addConstant(ctx, key);
1610
- const outKey = generateCheck(doc, ctx, def.keyType, keyConst);
1611
- // Read the property once. Passing the raw expression let compileChild validate one read while the output write performed a second, so a getter could hand back a value nothing had checked.
1612
- const valueVar = newVar(ctx);
1613
- doc.write(`const ${valueVar} = ${accessor}[${literalPropertyKey(ctx, inputKey)}];`);
1614
- const valOutput = compileChild(doc, ctx, def.valueType, valueVar);
1615
- doc.write(`${outputVar}[${outKey}] = ${valOutput};`);
1616
- }
1617
- // `mode: "loose"` changes only what happens to unrecognized keys, so it belongs here rather than the per-present-key scan. Passing them through matches the runtime, which skips `__proto__`.
1618
- const knownKeysConst = addConstant(ctx, new Set(inputKeys));
1619
- doc.write(`for (const ${kVar} in ${accessor}) {`);
1620
- doc.indented((d) => {
1621
- d.write(`if (${knownKeysConst}.has(${kVar})) continue;`);
1622
- if (recordDef.mode === "loose") {
1623
- d.write(`if (${kVar} !== "__proto__") ${outputVar}[${kVar}] = ${accessor}[${kVar}];`);
1624
- }
1625
- else {
1626
- d.write(`return INVALID;`);
1627
- }
1628
- });
1629
- doc.write(`}`);
1630
- return outputVar;
1631
- }
1632
- // The bare-string shortcut below only tests `typeof key === "string"`, so it
1633
- // is correct exclusively for a `z.string()` carrying nothing else. A string
1634
- // *format* lives on the def rather than in `checks` — `z.record(z.email(), …)`
1635
- // reads as a plain string here — and coercion rewrites the key, so both have
1636
- // to take the general path or the shortcut accepts keys the runtime rejects.
1637
- const keyDef = def.keyType._zod.def;
1638
- const keyIsBareString = keyDef.type === "string" && keyDef.format === undefined && !keyDef.coerce && (keyDef.checks?.length ?? 0) === 0;
1639
- if (!keyIsBareString) {
1640
- // A key schema with no value set is a constraint every key must satisfy
1641
- // (`z.email()`, `z.string().min(3)`, `z.number()`, a template literal).
1642
- // The runtime runs it against each own enumerable key and writes the value
1643
- // under the key it produced, so compile it once and call it per key.
1644
- const isLoose = def.mode === "loose";
1645
- // the key compiles in its own context, so carry its verdict out: a key schema that can answer INVALID undecidably makes this validator undecidable too
1646
- const keyFn = compileFn(def.keyType);
1647
- if (keyFn.definite === false)
1648
- ctx.definite = false;
1649
- const keyFast = addConstant(ctx, keyFn);
1650
- const numericConst = addConstant(ctx, regexes.number);
1651
- const outKeyVar = newVar(ctx);
1652
- // the body runs once per string key and once per symbol key, since a key schema can accept symbols
1653
- emitOwnKeys(doc, ctx, accessor, kVar, (d) => {
1654
- d.write(`let ${outKeyVar} = ${keyFast}(${kVar});`);
1655
- // Numeric-string retry, mirroring the runtime: a key the schema rejects as a string is tried again as a number, so z.record(z.number(), …) matches the numeric keys JavaScript stringified on the way in.
1656
- d.write(`if (${outKeyVar} === INVALID && typeof ${kVar} === "string" && ${numericConst}.test(${kVar})) ${outKeyVar} = ${keyFast}(Number(${kVar}));`);
1657
- if (isLoose) {
1658
- // A loose record keeps a key its schema rejects, copying the value across unvalidated rather than failing the parse.
1659
- d.write(`if (${outKeyVar} === INVALID) { ${outputVar}[${kVar}] = ${accessor}[${kVar}]; continue; }`);
1660
- }
1661
- else {
1662
- d.write(`if (${outKeyVar} === INVALID) return INVALID;`);
1663
- }
1664
- // The guard above tested the input key, but the schema can normalize an ordinary key into __proto__; re-check the one actually written under.
1665
- d.write(`if (${outKeyVar} === "__proto__") continue;`);
1666
- // Read once: the raw expression would be evaluated again by the output write below, so an accessor could return an unvalidated second value.
1667
- const valueVar = newVar(ctx);
1668
- d.write(`const ${valueVar} = ${accessor}[${kVar}];`);
1669
- const valOutput = compileChild(d, ctx, def.valueType, valueVar);
1670
- d.write(`${outputVar}[${outKeyVar}] = ${valOutput};`);
1671
- });
1672
- return outputVar;
1673
- }
1674
- // Plain z.string() keys: every own enumerable string key's value is validated, and an own enumerable symbol key fails the string key schema, as it does in the runtime's Reflect.ownKeys walk.
1675
- emitOwnKeys(doc, ctx, accessor, kVar, (d) => {
1676
- d.write(`const ${valVar} = ${accessor}[${kVar}];`);
1677
- const valOutput = compileChild(d, ctx, def.valueType, valVar);
1678
- d.write(`${outputVar}[${kVar}] = ${valOutput};`);
1679
- }, `return INVALID;`);
1680
- return outputVar;
1681
- }
1682
- // Walks the own enumerable keys of a plain object in Reflect.ownKeys order — strings from getOwnPropertyNames, then symbols — instead of Reflect.ownKeys, whose accumulator made that walk 3–6x the cost of the loop it fed. Both snapshots are taken before any value is read and every key is rechecked with propertyIsEnumerable when visited, exactly the runtime's walk, so a getter that adds, deletes, hides or reveals a key mid-walk sees the runtime's verdict; for-in and Object.keys were no faster and each lost a case (for-in enumerates the prototype chain after the own keys, Object.keys drops a key that is non-enumerable at snapshot time). `body` is written once for the string loop and once for the symbol loop unless `onSymbol` replaces the latter.
1683
- function emitOwnKeys(doc, ctx, accessor, kVar, body, onSymbol) {
1684
- const propIsEnumerableConst = addConstant(ctx, Object.prototype.propertyIsEnumerable);
1685
- const symsVar = newVar(ctx);
1686
- const keysVar = newVar(ctx);
1687
- const iVar = newVar(ctx);
1688
- doc.write(`const ${symsVar} = Object.getOwnPropertySymbols(${accessor});`);
1689
- doc.write(`const ${keysVar} = Object.getOwnPropertyNames(${accessor});`);
1690
- doc.write(`for (let ${iVar} = 0; ${iVar} < ${keysVar}.length; ${iVar}++) {`);
1691
- doc.indented((d) => {
1692
- d.write(`const ${kVar} = ${keysVar}[${iVar}];`);
1693
- d.write(`if (${kVar} === "__proto__" || !${propIsEnumerableConst}.call(${accessor}, ${kVar})) continue;`);
1694
- body(d);
1695
- });
1696
- doc.write(`}`);
1697
- doc.write(`for (let ${iVar} = 0; ${iVar} < ${symsVar}.length; ${iVar}++) {`);
1698
- doc.indented((d) => {
1699
- d.write(`const ${kVar} = ${symsVar}[${iVar}];`);
1700
- d.write(`if (!${propIsEnumerableConst}.call(${accessor}, ${kVar})) continue;`);
1701
- if (onSymbol)
1702
- d.write(onSymbol);
1703
- else
1704
- body(d);
1705
- });
1706
- doc.write(`}`);
1707
- }
1708
- function literalPropertyKey(ctx, key) {
1709
- if (typeof key === "string")
1710
- return util.esc(key);
1711
- return addConstant(ctx, key);
1712
- }
1713
- function generateMapCheck(doc, ctx, schema, accessor) {
1714
- const def = schema._zod.def;
1715
- doc.write(`if (!(${accessor} instanceof Map)) return INVALID;`);
1716
- generateSizeGate(doc, schema, `${accessor}.size`);
1717
- const outputVar = newVar(ctx);
1718
- const kVar = newVar(ctx);
1719
- const valVar = newVar(ctx);
1720
- doc.write(`const ${outputVar} = new Map();`);
1721
- doc.write(`for (const [${kVar}, ${valVar}] of ${accessor}) {`);
1722
- doc.indented((d) => {
1723
- const keyOutput = generateCheck(d, ctx, def.keyType, kVar);
1724
- const valOutput = generateCheck(d, ctx, def.valueType, valVar);
1725
- d.write(`${outputVar}.set(${keyOutput}, ${valOutput});`);
1726
- });
1727
- doc.write(`}`);
1728
- return outputVar;
1729
- }
1730
- function generateSetCheck(doc, ctx, schema, accessor) {
1731
- const def = schema._zod.def;
1732
- doc.write(`if (!(${accessor} instanceof Set)) return INVALID;`);
1733
- generateSizeGate(doc, schema, `${accessor}.size`);
1734
- const outputVar = newVar(ctx);
1735
- const valVar = newVar(ctx);
1736
- doc.write(`const ${outputVar} = new Set();`);
1737
- doc.write(`for (const ${valVar} of ${accessor}) {`);
1738
- doc.indented((d) => {
1739
- const valOutput = generateCheck(d, ctx, def.valueType, valVar);
1740
- d.write(`${outputVar}.add(${valOutput});`);
1741
- });
1742
- doc.write(`}`);
1743
- return outputVar;
1744
- }
1745
- function generateFileCheck(doc, accessor) {
1746
- // Runtime $ZodFile is a bare `instanceof File`, including the implicit global lookup. The previous duck-typed fallback accepted arbitrary {name, size} objects in File-less environments — behavior the runtime never had.
1747
- doc.write(`if (!(${accessor} instanceof File)) return INVALID;`);
1748
- return accessor;
1749
- }
1750
- function generateTemplateLiteralCheck(doc, ctx, schema, accessor) {
1751
- doc.write(`if (typeof ${accessor} !== "string") return INVALID;`);
1752
- // Template literal schemas have a pre-computed pattern in _zod.pattern
1753
- const pattern = schema._zod.pattern;
1754
- if (pattern) {
1755
- const patternConst = addConstant(ctx, pattern);
1756
- doc.write(`${patternConst}.lastIndex = 0;`);
1757
- doc.write(`if (!${patternConst}.test(${accessor})) return INVALID;`);
1758
- }
1759
- return accessor;
1760
- }
1761
- function generateLazyCheck(doc, ctx, schema, accessor) {
1762
- // For lazy schemas, we use a cached parser that falls back to runtime Zod parsing This handles recursive schemas correctly by avoiding infinite compilation loops
1763
- const def = schema._zod.def;
1764
- const getterConst = addUserConstant(ctx, def.getter);
1765
- const cacheConst = addConstant(ctx, { parser: null });
1766
- doc.write(`if (!${cacheConst}.parser) {`);
1767
- doc.indented((d) => {
1768
- d.write(`const inner = ${getterConst}();`);
1769
- d.write(`${cacheConst}.parser = function(input) {`);
1770
- d.indented((d2) => {
1771
- // Use runtime Zod parsing - this correctly handles recursive schemas Pass an empty ctx like runtimeRun does — runtime parsers read ctx.skipChecks/ctx.direction unconditionally and crash on undefined.
1772
- d2.write(`const result = inner._zod.run({ value: input, issues: [] }, {});`);
1773
- d2.write(`return result.issues.length === 0 ? result.value : INVALID;`);
1774
- });
1775
- d.write(`};`);
1776
- });
1777
- doc.write(`}`);
1778
- const outputVar = newVar(ctx);
1779
- doc.write(`const ${outputVar} = ${cacheConst}.parser(${accessor});`);
1780
- doc.write(`if (${outputVar} === INVALID) return INVALID;`);
1781
- return outputVar;
1782
- }
1783
- function generatePipeCheck(doc, ctx, schema, accessor) {
1784
- const def = schema._zod.def;
1785
- // Validate input type first
1786
- const inputOutput = generateCheck(doc, ctx, def.in, accessor);
1787
- if (def.transform) {
1788
- // Apply transform and validate output. The transform may read its second `payload` argument (codec transforms like z.stringbool() push issues there) so wrap the call in a helper that spoofs a payload. Pushed issues signal INVALID and the wrapper falls back to the runtime, and a plain function handing back a promise answers INVALID too — union parity, but not a decidable rejection at the top level.
1789
- if (isAsyncFunction(def.transform)) {
1790
- throw new ZodCompileAsyncError("z.compile: async transforms in pipes are not supported");
1791
- }
1792
- const transformFn = def.transform;
1793
- const helperFn = (value) => {
1794
- // `addIssue` has to be here: a transform reporting through it is reporting, not failing. Without it the call threw a TypeError that the old catch swallowed into a fallback, so every ctx.addIssue transform quietly lost its fast path and the real error was never visible.
1795
- const fakePayload = { value, issues: [], addIssue: pushIssue };
1796
- // A throw is deliberately not caught. The interpreter lets one propagate out of the whole parse; swallowing it into INVALID turned a thrown error into a merely-rejected union branch, so a later branch answered instead.
1797
- const result = transformFn(value, fakePayload);
1798
- if (result instanceof Promise)
1799
- return exports.INVALID;
1800
- return fakePayload.issues.length === 0 ? result : exports.INVALID;
1801
- };
1802
- const helperConst = addUserConstant(ctx, helperFn);
1803
- const transformedVar = newVar(ctx);
1804
- doc.write(`const ${transformedVar} = ${helperConst}(${inputOutput});`);
1805
- doc.write(`if (${transformedVar} === INVALID) return INVALID;`);
1806
- return generateCheck(doc, ctx, def.out, transformedVar);
1807
- }
1808
- else {
1809
- // No transform - validate output type on same value
1810
- return generateCheck(doc, ctx, def.out, inputOutput);
1811
- }
1812
- }
1813
- function isAsyncFunction(fn) {
1814
- return (typeof fn === "function" &&
1815
- (fn.constructor.name === "AsyncFunction" ||
1816
- fn[Symbol.toStringTag] === "AsyncFunction"));
1817
- }
1818
- function generateCustomCheck(doc, ctx, schema, accessor) {
1819
- const def = schema._zod.def;
1820
- if (def.fn) {
1821
- // Check for async function
1822
- if (isAsyncFunction(def.fn)) {
1823
- throw new ZodCompileAsyncError("z.compile: async custom predicates are not supported");
1824
- }
1825
- // Custom schema with a predicate function (e.g. z.instanceof). `isAsyncFunction` above is syntactic, so a plain function returning a promise reaches here, and a promise is truthy — it would read as a pass where the interpreter throws.
1826
- const fnConst = addUserConstant(ctx, def.fn);
1827
- const throwAsyncConst = addConstant(ctx, throwAsync);
1828
- const resVar = newVar(ctx);
1829
- doc.write(`const ${resVar} = ${fnConst}(${accessor});`);
1830
- doc.write(`if (${resVar} instanceof Promise) ${throwAsyncConst}();`);
1831
- doc.write(`if (!${resVar}) return INVALID;`);
1832
- }
1833
- else {
1834
- throw new ZodCompileUnsupportedError("custom schema without a predicate function");
1835
- }
1836
- return accessor;
1837
- }
1838
- // Runtime helper for a compiled `catch`: runs the inner schema once and returns its value when it succeeded. Anything else — a failure the catch would handle, or an async inner — returns INVALID so the interpreter takes over.
1839
- function runtimeCatch(innerSchema, catchValue, value) {
1840
- const result = innerSchema._zod.run({ value, issues: [] }, {});
1841
- if (result && typeof result.then === "function")
1842
- return exports.INVALID;
1843
- const r = result;
1844
- if (r.issues.length === 0)
1845
- return r.value;
1846
- // Only reached for a catch value that ignores the parse context — codegen refuses the rest — so there are no issues to finalize and nothing here needs the caller's error map.
1847
- return catchValue();
1848
- }
1849
- function generateCatchCheck(doc, ctx, schema, accessor) {
1850
- const def = schema._zod.def;
1851
- // An untagged catchValue is a user callback, and one reading `ctx.error` needs the caller's per-parse error map. Catch *succeeds*, so a wrong message there is unobservable — refuse at codegen, and not islandable either, since `runtimeRun` has no context to hand it.
1852
- if (!def.catchValue[util.CONSTANT_CATCH]) {
1853
- throw new ZodCompileUnsupportedError("catch with a callback (only a constant catch value compiles)", false);
1854
- }
1855
- const outputVar = newVar(ctx);
1856
- doc.write(`let ${outputVar} = (() => {`);
1857
- doc.indented((d) => {
1858
- const innerOut = compileChild(d, ctx, def.innerType, accessor);
1859
- d.write(`return ${innerOut};`);
1860
- });
1861
- doc.write(`})();`);
1862
- const innerConst = addConstant(ctx, def.innerType);
1863
- const catchConst = addUserConstant(ctx, def.catchValue);
1864
- const catchHelperConst = addConstant(ctx, runtimeCatch);
1865
- doc.write(`if (${outputVar} === INVALID) {`);
1866
- doc.indented((d) => {
1867
- d.write(`${outputVar} = ${catchHelperConst}(${innerConst}, ${catchConst}, ${accessor});`);
1868
- d.write(`if (${outputVar} === INVALID) return INVALID;`);
1869
- });
1870
- doc.write(`}`);
1871
- return outputVar;
1872
- }
1873
- function generateTransformCheck(doc, ctx, schema, accessor) {
1874
- const def = schema._zod.def;
1875
- if (def.transform) {
1876
- // Check for async transform
1877
- if (isAsyncFunction(def.transform)) {
1878
- throw new ZodCompileAsyncError("z.compile: async transforms are not supported");
1879
- }
1880
- // Create a helper that runs the transform and returns the result or INVALID on error
1881
- const transformFn = def.transform;
1882
- const helperFn = (value) => {
1883
- const fakePayload = { value, issues: [], addIssue: pushIssue };
1884
- // As in the pipe helper: a throw propagates, because the interpreter lets it out of the whole parse rather than treating it as a failed branch.
1885
- const result = transformFn(value, fakePayload);
1886
- if (result instanceof Promise)
1887
- return exports.INVALID;
1888
- return fakePayload.issues.length === 0 ? result : exports.INVALID;
1889
- };
1890
- const helperConst = addUserConstant(ctx, helperFn);
1891
- const outputVar = newVar(ctx);
1892
- doc.write(`const ${outputVar} = ${helperConst}(${accessor});`);
1893
- doc.write(`if (${outputVar} === INVALID) return INVALID;`);
1894
- return outputVar;
1895
- }
1896
- return accessor;
1897
- }
1898
-
1899
- // seal-cjs-exports
1900
- (function () {
1901
- var keys = Object.getOwnPropertyNames(exports);
1902
- for (var i = 0; i < keys.length; i++) {
1903
- var desc = Object.getOwnPropertyDescriptor(exports, keys[i]);
1904
- if (!desc || !desc.get || !desc.configurable) continue;
1905
- var value;
1906
- try {
1907
- value = desc.get();
1908
- } catch (e) {
1909
- continue;
1910
- }
1911
- // a circular require may not have settled this one yet, so leave it live
1912
- if (value === undefined) continue;
1913
- Object.defineProperty(exports, keys[i], { value: value, writable: false, enumerable: desc.enumerable, configurable: false });
1914
- }
1915
- Object.freeze(exports);
1916
- })();