@loomhelm/multi-task-flow 0.2.7 → 0.2.9

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 (1046) hide show
  1. package/README.md +22 -18
  2. package/package.json +3 -13
  3. package/src/build-info.ts +4 -2
  4. package/src/cli/release.ts +4 -40
  5. package/src/cli/service.ts +26 -0
  6. package/src/cli.ts +3 -1
  7. package/src/release-tarball.ts +1 -1
  8. package/src/release.ts +7 -1
  9. package/src/runtime-identity.ts +4 -2
  10. package/src/toolkit.ts +71 -15
  11. package/toolkit/artifact-manifest.json +317 -4224
  12. package/toolkit/package.json +1 -1
  13. package/toolkit/skills/bin/check_source_policy.ts +13 -7
  14. package/toolkit/skills/bin/multi_task_platform_gate.ts +2 -2
  15. package/toolkit/skills/bin/tests/core/package_scripts.test.ts +1 -1
  16. package/toolkit/skills/bin/tests/plan/multi-task-flow.test.ts +3 -3
  17. package/toolkit/skills/catalog.json +0 -1
  18. package/toolkit/skills/docs/vendor/dot-codex/design/multi-task-flow/data-and-scripts.md +84 -28
  19. package/toolkit/skills/docs/vendor/dot-codex/design/multi-task-flow/execution.md +1 -1
  20. package/toolkit/skills/docs/vendor/dot-codex/design/multi-task-flow/plan-revision-and-change-audit.md +1 -1
  21. package/toolkit/skills/docs/vendor/dot-codex/design/multi-task-flow/web-template.md +1 -1
  22. package/toolkit/skills/docs/vendor/dot-codex/specs/a4ge9-stable-preview-runtime/IMPLEMENTATION.md +0 -2
  23. package/toolkit/skills/docs/vendor/dot-codex/specs/a4ge9-stable-preview-runtime/SPEC.md +0 -1
  24. package/toolkit/skills/docs/vendor/dot-codex/specs/dev-plan-standalone-typescript-finalizer/IMPLEMENTATION.md +1 -1
  25. package/toolkit/skills/docs/vendor/dot-codex/specs/multi-task-flow/IMPLEMENTATION.md +3 -3
  26. package/toolkit/skills/docs/vendor/dot-codex/specs/multi-task-flow/SCHEMA.md +4 -4
  27. package/toolkit/skills/docs/vendor/dot-codex/specs/stable-preview-runtime/IMPLEMENTATION.md +0 -2
  28. package/toolkit/skills/docs/vendor/dot-codex/specs/stable-preview-runtime/SPEC.md +0 -1
  29. package/toolkit/skills/multi-task-flow/SKILL.md +65 -47
  30. package/toolkit/skills/multi-task-flow/dist/app.css +1 -1
  31. package/toolkit/skills/multi-task-flow/dist/app.js +74 -74
  32. package/toolkit/skills/multi-task-flow/dist/index.html +3 -3
  33. package/toolkit/skills/multi-task-flow/lib/atomic-orchestration.ts +26 -3
  34. package/toolkit/skills/multi-task-flow/lib/engine.ts +136 -17
  35. package/toolkit/skills/multi-task-flow/lib/package-source.ts +5 -5
  36. package/toolkit/skills/multi-task-flow/lib/schema.ts +82 -2
  37. package/toolkit/skills/multi-task-flow/lib/service-pages.ts +1 -26
  38. package/toolkit/skills/multi-task-flow/lib/view.ts +125 -11
  39. package/toolkit/skills/multi-task-flow/references/shared-viewer.md +1 -1
  40. package/toolkit/skills/multi-task-flow/scripts/check-client-skills.ts +7 -4
  41. package/toolkit/skills/multi-task-flow/scripts/check-skills-installation.ts +14 -8
  42. package/toolkit/skills/multi-task-flow/scripts/import-client-skills.ts +1 -1
  43. package/toolkit/skills/multi-task-flow/scripts/package-client-skills.ts +28 -157
  44. package/toolkit/skills/multi-task-flow/scripts/preview-source.ts +3 -0
  45. package/toolkit/skills/multi-task-flow/scripts/test-viewer-source.ts +1 -1
  46. package/toolkit/skills/multi-task-flow/tests/atomic-orchestration-schema.test.ts +40 -0
  47. package/toolkit/skills/multi-task-flow/tests/browser/README.md +1 -1
  48. package/toolkit/skills/multi-task-flow/tests/check-skills-installation.test.ts +12 -38
  49. package/toolkit/skills/multi-task-flow/tests/delivery-topology.test.ts +33 -0
  50. package/toolkit/skills/multi-task-flow/tests/engine.test.ts +339 -0
  51. package/toolkit/skills/multi-task-flow/tests/orchestrate.test.ts +3 -5
  52. package/toolkit/skills/multi-task-flow/tests/source-preview.test.ts +29 -0
  53. package/toolkit/skills/multi-task-flow/tests/ui/details-content.test.ts +31 -0
  54. package/toolkit/skills/multi-task-flow/tests/ui/responsive-width-contract.test.ts +25 -1
  55. package/toolkit/skills/multi-task-flow/tests/ui/task-context-menu.test.ts +2 -1
  56. package/toolkit/skills/multi-task-flow/tests/view.test.ts +149 -0
  57. package/toolkit/skills/multi-task-flow/web/app.css +68 -9
  58. package/toolkit/skills/multi-task-flow/web/app.ts +42 -15
  59. package/toolkit/skills/multi-task-flow/web/atomic-graph-view.tsx +2 -2
  60. package/toolkit/skills/multi-task-flow/web/details-content.ts +54 -38
  61. package/toolkit/skills/multi-task-flow/web/graph-view.tsx +1 -1
  62. package/toolkit/skills/multi-task-flow/web/index.html +3 -3
  63. package/toolkit/skills/multi-task-flow/web/model.ts +1 -1
  64. package/toolkit/skills/multi-task-flow/web/timeline.ts +11 -8
  65. package/toolkit/skills/package.json +2 -2
  66. package/toolkit/skills/source-manifest.json +693 -400
  67. package/toolkit/skills/support-manifest.json +1 -0
  68. package/toolkit/skills/multi-task-flow/node_modules/zod/LICENSE +0 -21
  69. package/toolkit/skills/multi-task-flow/node_modules/zod/README.md +0 -218
  70. package/toolkit/skills/multi-task-flow/node_modules/zod/compile.cjs +0 -96
  71. package/toolkit/skills/multi-task-flow/node_modules/zod/compile.d.cts +0 -1
  72. package/toolkit/skills/multi-task-flow/node_modules/zod/compile.d.ts +0 -1
  73. package/toolkit/skills/multi-task-flow/node_modules/zod/compile.js +0 -52
  74. package/toolkit/skills/multi-task-flow/node_modules/zod/index.cjs +0 -52
  75. package/toolkit/skills/multi-task-flow/node_modules/zod/index.d.cts +0 -3
  76. package/toolkit/skills/multi-task-flow/node_modules/zod/index.d.ts +0 -3
  77. package/toolkit/skills/multi-task-flow/node_modules/zod/index.js +0 -7
  78. package/toolkit/skills/multi-task-flow/node_modules/zod/locales/index.cjs +0 -36
  79. package/toolkit/skills/multi-task-flow/node_modules/zod/locales/index.d.cts +0 -1
  80. package/toolkit/skills/multi-task-flow/node_modules/zod/locales/index.d.ts +0 -1
  81. package/toolkit/skills/multi-task-flow/node_modules/zod/locales/index.js +0 -1
  82. package/toolkit/skills/multi-task-flow/node_modules/zod/locales/package.json +0 -7
  83. package/toolkit/skills/multi-task-flow/node_modules/zod/mini/index.cjs +0 -51
  84. package/toolkit/skills/multi-task-flow/node_modules/zod/mini/index.d.cts +0 -3
  85. package/toolkit/skills/multi-task-flow/node_modules/zod/mini/index.d.ts +0 -3
  86. package/toolkit/skills/multi-task-flow/node_modules/zod/mini/index.js +0 -3
  87. package/toolkit/skills/multi-task-flow/node_modules/zod/mini/package.json +0 -7
  88. package/toolkit/skills/multi-task-flow/node_modules/zod/package.json +0 -147
  89. package/toolkit/skills/multi-task-flow/node_modules/zod/src/compile.ts +0 -56
  90. package/toolkit/skills/multi-task-flow/node_modules/zod/src/index.ts +0 -7
  91. package/toolkit/skills/multi-task-flow/node_modules/zod/src/locales/index.ts +0 -1
  92. package/toolkit/skills/multi-task-flow/node_modules/zod/src/mini/index.ts +0 -3
  93. package/toolkit/skills/multi-task-flow/node_modules/zod/src/v3/ZodError.ts +0 -340
  94. package/toolkit/skills/multi-task-flow/node_modules/zod/src/v3/benchmarks/datetime.ts +0 -58
  95. package/toolkit/skills/multi-task-flow/node_modules/zod/src/v3/benchmarks/discriminatedUnion.ts +0 -80
  96. package/toolkit/skills/multi-task-flow/node_modules/zod/src/v3/benchmarks/index.ts +0 -59
  97. package/toolkit/skills/multi-task-flow/node_modules/zod/src/v3/benchmarks/ipv4.ts +0 -57
  98. package/toolkit/skills/multi-task-flow/node_modules/zod/src/v3/benchmarks/object.ts +0 -69
  99. package/toolkit/skills/multi-task-flow/node_modules/zod/src/v3/benchmarks/primitives.ts +0 -162
  100. package/toolkit/skills/multi-task-flow/node_modules/zod/src/v3/benchmarks/realworld.ts +0 -63
  101. package/toolkit/skills/multi-task-flow/node_modules/zod/src/v3/benchmarks/string.ts +0 -55
  102. package/toolkit/skills/multi-task-flow/node_modules/zod/src/v3/benchmarks/union.ts +0 -80
  103. package/toolkit/skills/multi-task-flow/node_modules/zod/src/v3/errors.ts +0 -13
  104. package/toolkit/skills/multi-task-flow/node_modules/zod/src/v3/external.ts +0 -6
  105. package/toolkit/skills/multi-task-flow/node_modules/zod/src/v3/helpers/enumUtil.ts +0 -17
  106. package/toolkit/skills/multi-task-flow/node_modules/zod/src/v3/helpers/errorUtil.ts +0 -8
  107. package/toolkit/skills/multi-task-flow/node_modules/zod/src/v3/helpers/parseUtil.ts +0 -176
  108. package/toolkit/skills/multi-task-flow/node_modules/zod/src/v3/helpers/partialUtil.ts +0 -34
  109. package/toolkit/skills/multi-task-flow/node_modules/zod/src/v3/helpers/typeAliases.ts +0 -2
  110. package/toolkit/skills/multi-task-flow/node_modules/zod/src/v3/helpers/util.ts +0 -224
  111. package/toolkit/skills/multi-task-flow/node_modules/zod/src/v3/index.ts +0 -4
  112. package/toolkit/skills/multi-task-flow/node_modules/zod/src/v3/locales/en.ts +0 -124
  113. package/toolkit/skills/multi-task-flow/node_modules/zod/src/v3/standard-schema.ts +0 -113
  114. package/toolkit/skills/multi-task-flow/node_modules/zod/src/v3/tests/Mocker.ts +0 -54
  115. package/toolkit/skills/multi-task-flow/node_modules/zod/src/v3/tests/all-errors.test.ts +0 -157
  116. package/toolkit/skills/multi-task-flow/node_modules/zod/src/v3/tests/anyunknown.test.ts +0 -28
  117. package/toolkit/skills/multi-task-flow/node_modules/zod/src/v3/tests/array.test.ts +0 -71
  118. package/toolkit/skills/multi-task-flow/node_modules/zod/src/v3/tests/async-parsing.test.ts +0 -388
  119. package/toolkit/skills/multi-task-flow/node_modules/zod/src/v3/tests/async-refinements.test.ts +0 -46
  120. package/toolkit/skills/multi-task-flow/node_modules/zod/src/v3/tests/base.test.ts +0 -29
  121. package/toolkit/skills/multi-task-flow/node_modules/zod/src/v3/tests/bigint.test.ts +0 -55
  122. package/toolkit/skills/multi-task-flow/node_modules/zod/src/v3/tests/branded.test.ts +0 -53
  123. package/toolkit/skills/multi-task-flow/node_modules/zod/src/v3/tests/catch.test.ts +0 -220
  124. package/toolkit/skills/multi-task-flow/node_modules/zod/src/v3/tests/coerce.test.ts +0 -133
  125. package/toolkit/skills/multi-task-flow/node_modules/zod/src/v3/tests/complex.test.ts +0 -70
  126. package/toolkit/skills/multi-task-flow/node_modules/zod/src/v3/tests/custom.test.ts +0 -31
  127. package/toolkit/skills/multi-task-flow/node_modules/zod/src/v3/tests/date.test.ts +0 -32
  128. package/toolkit/skills/multi-task-flow/node_modules/zod/src/v3/tests/deepmasking.test.ts +0 -186
  129. package/toolkit/skills/multi-task-flow/node_modules/zod/src/v3/tests/default.test.ts +0 -112
  130. package/toolkit/skills/multi-task-flow/node_modules/zod/src/v3/tests/description.test.ts +0 -33
  131. package/toolkit/skills/multi-task-flow/node_modules/zod/src/v3/tests/discriminated-unions.test.ts +0 -315
  132. package/toolkit/skills/multi-task-flow/node_modules/zod/src/v3/tests/enum.test.ts +0 -80
  133. package/toolkit/skills/multi-task-flow/node_modules/zod/src/v3/tests/error.test.ts +0 -586
  134. package/toolkit/skills/multi-task-flow/node_modules/zod/src/v3/tests/firstparty.test.ts +0 -87
  135. package/toolkit/skills/multi-task-flow/node_modules/zod/src/v3/tests/firstpartyschematypes.test.ts +0 -21
  136. package/toolkit/skills/multi-task-flow/node_modules/zod/src/v3/tests/function.test.ts +0 -261
  137. package/toolkit/skills/multi-task-flow/node_modules/zod/src/v3/tests/generics.test.ts +0 -48
  138. package/toolkit/skills/multi-task-flow/node_modules/zod/src/v3/tests/instanceof.test.ts +0 -37
  139. package/toolkit/skills/multi-task-flow/node_modules/zod/src/v3/tests/intersection.test.ts +0 -128
  140. package/toolkit/skills/multi-task-flow/node_modules/zod/src/v3/tests/language-server.source.ts +0 -76
  141. package/toolkit/skills/multi-task-flow/node_modules/zod/src/v3/tests/language-server.test.ts +0 -206
  142. package/toolkit/skills/multi-task-flow/node_modules/zod/src/v3/tests/literal.test.ts +0 -36
  143. package/toolkit/skills/multi-task-flow/node_modules/zod/src/v3/tests/map.test.ts +0 -110
  144. package/toolkit/skills/multi-task-flow/node_modules/zod/src/v3/tests/masking.test.ts +0 -4
  145. package/toolkit/skills/multi-task-flow/node_modules/zod/src/v3/tests/mocker.test.ts +0 -19
  146. package/toolkit/skills/multi-task-flow/node_modules/zod/src/v3/tests/nan.test.ts +0 -24
  147. package/toolkit/skills/multi-task-flow/node_modules/zod/src/v3/tests/nativeEnum.test.ts +0 -87
  148. package/toolkit/skills/multi-task-flow/node_modules/zod/src/v3/tests/nullable.test.ts +0 -42
  149. package/toolkit/skills/multi-task-flow/node_modules/zod/src/v3/tests/number.test.ts +0 -176
  150. package/toolkit/skills/multi-task-flow/node_modules/zod/src/v3/tests/object-augmentation.test.ts +0 -29
  151. package/toolkit/skills/multi-task-flow/node_modules/zod/src/v3/tests/object-in-es5-env.test.ts +0 -29
  152. package/toolkit/skills/multi-task-flow/node_modules/zod/src/v3/tests/object.test.ts +0 -431
  153. package/toolkit/skills/multi-task-flow/node_modules/zod/src/v3/tests/optional.test.ts +0 -42
  154. package/toolkit/skills/multi-task-flow/node_modules/zod/src/v3/tests/parseUtil.test.ts +0 -23
  155. package/toolkit/skills/multi-task-flow/node_modules/zod/src/v3/tests/parser.test.ts +0 -41
  156. package/toolkit/skills/multi-task-flow/node_modules/zod/src/v3/tests/partials.test.ts +0 -243
  157. package/toolkit/skills/multi-task-flow/node_modules/zod/src/v3/tests/pickomit.test.ts +0 -111
  158. package/toolkit/skills/multi-task-flow/node_modules/zod/src/v3/tests/pipeline.test.ts +0 -29
  159. package/toolkit/skills/multi-task-flow/node_modules/zod/src/v3/tests/preprocess.test.ts +0 -186
  160. package/toolkit/skills/multi-task-flow/node_modules/zod/src/v3/tests/primitive.test.ts +0 -440
  161. package/toolkit/skills/multi-task-flow/node_modules/zod/src/v3/tests/promise.test.ts +0 -90
  162. package/toolkit/skills/multi-task-flow/node_modules/zod/src/v3/tests/readonly.test.ts +0 -114
  163. package/toolkit/skills/multi-task-flow/node_modules/zod/src/v3/tests/record.test.ts +0 -171
  164. package/toolkit/skills/multi-task-flow/node_modules/zod/src/v3/tests/recursive.test.ts +0 -197
  165. package/toolkit/skills/multi-task-flow/node_modules/zod/src/v3/tests/refine.test.ts +0 -313
  166. package/toolkit/skills/multi-task-flow/node_modules/zod/src/v3/tests/safeparse.test.ts +0 -27
  167. package/toolkit/skills/multi-task-flow/node_modules/zod/src/v3/tests/set.test.ts +0 -142
  168. package/toolkit/skills/multi-task-flow/node_modules/zod/src/v3/tests/standard-schema.test.ts +0 -83
  169. package/toolkit/skills/multi-task-flow/node_modules/zod/src/v3/tests/string.test.ts +0 -922
  170. package/toolkit/skills/multi-task-flow/node_modules/zod/src/v3/tests/transformer.test.ts +0 -233
  171. package/toolkit/skills/multi-task-flow/node_modules/zod/src/v3/tests/tuple.test.ts +0 -90
  172. package/toolkit/skills/multi-task-flow/node_modules/zod/src/v3/tests/unions.test.ts +0 -57
  173. package/toolkit/skills/multi-task-flow/node_modules/zod/src/v3/tests/validations.test.ts +0 -133
  174. package/toolkit/skills/multi-task-flow/node_modules/zod/src/v3/tests/void.test.ts +0 -15
  175. package/toolkit/skills/multi-task-flow/node_modules/zod/src/v3/types.ts +0 -5138
  176. package/toolkit/skills/multi-task-flow/node_modules/zod/src/v4/classic/checks.ts +0 -33
  177. package/toolkit/skills/multi-task-flow/node_modules/zod/src/v4/classic/coerce.ts +0 -27
  178. package/toolkit/skills/multi-task-flow/node_modules/zod/src/v4/classic/compat.ts +0 -78
  179. package/toolkit/skills/multi-task-flow/node_modules/zod/src/v4/classic/deep-partial.ts +0 -76
  180. package/toolkit/skills/multi-task-flow/node_modules/zod/src/v4/classic/errors.ts +0 -97
  181. package/toolkit/skills/multi-task-flow/node_modules/zod/src/v4/classic/external.ts +0 -57
  182. package/toolkit/skills/multi-task-flow/node_modules/zod/src/v4/classic/from-json-schema.ts +0 -944
  183. package/toolkit/skills/multi-task-flow/node_modules/zod/src/v4/classic/in-out.ts +0 -45
  184. package/toolkit/skills/multi-task-flow/node_modules/zod/src/v4/classic/index.ts +0 -5
  185. package/toolkit/skills/multi-task-flow/node_modules/zod/src/v4/classic/iso.ts +0 -20
  186. package/toolkit/skills/multi-task-flow/node_modules/zod/src/v4/classic/parse.ts +0 -88
  187. package/toolkit/skills/multi-task-flow/node_modules/zod/src/v4/classic/schemas.ts +0 -2937
  188. package/toolkit/skills/multi-task-flow/node_modules/zod/src/v4/classic/tests/anyunknown.test.ts +0 -26
  189. package/toolkit/skills/multi-task-flow/node_modules/zod/src/v4/classic/tests/apply.test.ts +0 -86
  190. package/toolkit/skills/multi-task-flow/node_modules/zod/src/v4/classic/tests/array.test.ts +0 -291
  191. package/toolkit/skills/multi-task-flow/node_modules/zod/src/v4/classic/tests/assignability.test.ts +0 -402
  192. package/toolkit/skills/multi-task-flow/node_modules/zod/src/v4/classic/tests/async-parsing.test.ts +0 -381
  193. package/toolkit/skills/multi-task-flow/node_modules/zod/src/v4/classic/tests/async-refinements.test.ts +0 -68
  194. package/toolkit/skills/multi-task-flow/node_modules/zod/src/v4/classic/tests/base.test.ts +0 -7
  195. package/toolkit/skills/multi-task-flow/node_modules/zod/src/v4/classic/tests/bigint.test.ts +0 -89
  196. package/toolkit/skills/multi-task-flow/node_modules/zod/src/v4/classic/tests/brand.test.ts +0 -106
  197. package/toolkit/skills/multi-task-flow/node_modules/zod/src/v4/classic/tests/catch.test.ts +0 -604
  198. package/toolkit/skills/multi-task-flow/node_modules/zod/src/v4/classic/tests/coalesce.test.ts +0 -20
  199. package/toolkit/skills/multi-task-flow/node_modules/zod/src/v4/classic/tests/codec-examples.test.ts +0 -572
  200. package/toolkit/skills/multi-task-flow/node_modules/zod/src/v4/classic/tests/codec.test.ts +0 -704
  201. package/toolkit/skills/multi-task-flow/node_modules/zod/src/v4/classic/tests/coerce.test.ts +0 -160
  202. package/toolkit/skills/multi-task-flow/node_modules/zod/src/v4/classic/tests/continuability.test.ts +0 -374
  203. package/toolkit/skills/multi-task-flow/node_modules/zod/src/v4/classic/tests/credit-card.test.ts +0 -76
  204. package/toolkit/skills/multi-task-flow/node_modules/zod/src/v4/classic/tests/custom.test.ts +0 -40
  205. package/toolkit/skills/multi-task-flow/node_modules/zod/src/v4/classic/tests/cyclic-data.test.ts +0 -985
  206. package/toolkit/skills/multi-task-flow/node_modules/zod/src/v4/classic/tests/date.test.ts +0 -92
  207. package/toolkit/skills/multi-task-flow/node_modules/zod/src/v4/classic/tests/datetime.test.ts +0 -316
  208. package/toolkit/skills/multi-task-flow/node_modules/zod/src/v4/classic/tests/deep-partial.test.ts +0 -380
  209. package/toolkit/skills/multi-task-flow/node_modules/zod/src/v4/classic/tests/default-locale.test.ts +0 -32
  210. package/toolkit/skills/multi-task-flow/node_modules/zod/src/v4/classic/tests/default.test.ts +0 -455
  211. package/toolkit/skills/multi-task-flow/node_modules/zod/src/v4/classic/tests/describe-meta-checks.test.ts +0 -27
  212. package/toolkit/skills/multi-task-flow/node_modules/zod/src/v4/classic/tests/description.test.ts +0 -32
  213. package/toolkit/skills/multi-task-flow/node_modules/zod/src/v4/classic/tests/detached-methods.test.ts +0 -221
  214. package/toolkit/skills/multi-task-flow/node_modules/zod/src/v4/classic/tests/discriminated-unions.test.ts +0 -942
  215. package/toolkit/skills/multi-task-flow/node_modules/zod/src/v4/classic/tests/enum.test.ts +0 -305
  216. package/toolkit/skills/multi-task-flow/node_modules/zod/src/v4/classic/tests/error-utils.test.ts +0 -917
  217. package/toolkit/skills/multi-task-flow/node_modules/zod/src/v4/classic/tests/error.test.ts +0 -1108
  218. package/toolkit/skills/multi-task-flow/node_modules/zod/src/v4/classic/tests/file.test.ts +0 -96
  219. package/toolkit/skills/multi-task-flow/node_modules/zod/src/v4/classic/tests/firstparty.test.ts +0 -179
  220. package/toolkit/skills/multi-task-flow/node_modules/zod/src/v4/classic/tests/fix-json-issue.test.ts +0 -26
  221. package/toolkit/skills/multi-task-flow/node_modules/zod/src/v4/classic/tests/from-json-schema.test.ts +0 -1467
  222. package/toolkit/skills/multi-task-flow/node_modules/zod/src/v4/classic/tests/function.test.ts +0 -391
  223. package/toolkit/skills/multi-task-flow/node_modules/zod/src/v4/classic/tests/generics.test.ts +0 -72
  224. package/toolkit/skills/multi-task-flow/node_modules/zod/src/v4/classic/tests/global-config.test.ts +0 -32
  225. package/toolkit/skills/multi-task-flow/node_modules/zod/src/v4/classic/tests/hash.test.ts +0 -67
  226. package/toolkit/skills/multi-task-flow/node_modules/zod/src/v4/classic/tests/iban.test.ts +0 -81
  227. package/toolkit/skills/multi-task-flow/node_modules/zod/src/v4/classic/tests/in-out.test.ts +0 -159
  228. package/toolkit/skills/multi-task-flow/node_modules/zod/src/v4/classic/tests/index.test.ts +0 -958
  229. package/toolkit/skills/multi-task-flow/node_modules/zod/src/v4/classic/tests/instance-footprint.test.ts +0 -319
  230. package/toolkit/skills/multi-task-flow/node_modules/zod/src/v4/classic/tests/instanceof.test.ts +0 -127
  231. package/toolkit/skills/multi-task-flow/node_modules/zod/src/v4/classic/tests/intersection.test.ts +0 -334
  232. package/toolkit/skills/multi-task-flow/node_modules/zod/src/v4/classic/tests/issue-schema.test.ts +0 -215
  233. package/toolkit/skills/multi-task-flow/node_modules/zod/src/v4/classic/tests/jitless-allows-eval.test.ts +0 -39
  234. package/toolkit/skills/multi-task-flow/node_modules/zod/src/v4/classic/tests/json.test.ts +0 -109
  235. package/toolkit/skills/multi-task-flow/node_modules/zod/src/v4/classic/tests/lazy.test.ts +0 -262
  236. package/toolkit/skills/multi-task-flow/node_modules/zod/src/v4/classic/tests/literal.test.ts +0 -128
  237. package/toolkit/skills/multi-task-flow/node_modules/zod/src/v4/classic/tests/locales_ka.test.ts +0 -29
  238. package/toolkit/skills/multi-task-flow/node_modules/zod/src/v4/classic/tests/locales_ro.test.ts +0 -24
  239. package/toolkit/skills/multi-task-flow/node_modules/zod/src/v4/classic/tests/map.test.ts +0 -349
  240. package/toolkit/skills/multi-task-flow/node_modules/zod/src/v4/classic/tests/nan.test.ts +0 -21
  241. package/toolkit/skills/multi-task-flow/node_modules/zod/src/v4/classic/tests/nested-refine.test.ts +0 -168
  242. package/toolkit/skills/multi-task-flow/node_modules/zod/src/v4/classic/tests/nonoptional.test.ts +0 -101
  243. package/toolkit/skills/multi-task-flow/node_modules/zod/src/v4/classic/tests/nullable.test.ts +0 -22
  244. package/toolkit/skills/multi-task-flow/node_modules/zod/src/v4/classic/tests/number.test.ts +0 -401
  245. package/toolkit/skills/multi-task-flow/node_modules/zod/src/v4/classic/tests/object.test.ts +0 -1006
  246. package/toolkit/skills/multi-task-flow/node_modules/zod/src/v4/classic/tests/optin-ladder.test.ts +0 -235
  247. package/toolkit/skills/multi-task-flow/node_modules/zod/src/v4/classic/tests/optional.test.ts +0 -366
  248. package/toolkit/skills/multi-task-flow/node_modules/zod/src/v4/classic/tests/partial.test.ts +0 -497
  249. package/toolkit/skills/multi-task-flow/node_modules/zod/src/v4/classic/tests/pickomit.test.ts +0 -211
  250. package/toolkit/skills/multi-task-flow/node_modules/zod/src/v4/classic/tests/pipe.test.ts +0 -101
  251. package/toolkit/skills/multi-task-flow/node_modules/zod/src/v4/classic/tests/prefault.test.ts +0 -144
  252. package/toolkit/skills/multi-task-flow/node_modules/zod/src/v4/classic/tests/preprocess-types.test.ts +0 -44
  253. package/toolkit/skills/multi-task-flow/node_modules/zod/src/v4/classic/tests/preprocess.test.ts +0 -351
  254. package/toolkit/skills/multi-task-flow/node_modules/zod/src/v4/classic/tests/primitive.test.ts +0 -175
  255. package/toolkit/skills/multi-task-flow/node_modules/zod/src/v4/classic/tests/promise.test.ts +0 -81
  256. package/toolkit/skills/multi-task-flow/node_modules/zod/src/v4/classic/tests/properties.test.ts +0 -141
  257. package/toolkit/skills/multi-task-flow/node_modules/zod/src/v4/classic/tests/prototypes.test.ts +0 -23
  258. package/toolkit/skills/multi-task-flow/node_modules/zod/src/v4/classic/tests/readonly.test.ts +0 -184
  259. package/toolkit/skills/multi-task-flow/node_modules/zod/src/v4/classic/tests/record.test.ts +0 -885
  260. package/toolkit/skills/multi-task-flow/node_modules/zod/src/v4/classic/tests/recursive-types.test.ts +0 -707
  261. package/toolkit/skills/multi-task-flow/node_modules/zod/src/v4/classic/tests/redos.test.ts +0 -68
  262. package/toolkit/skills/multi-task-flow/node_modules/zod/src/v4/classic/tests/refine.test.ts +0 -693
  263. package/toolkit/skills/multi-task-flow/node_modules/zod/src/v4/classic/tests/registries.test.ts +0 -243
  264. package/toolkit/skills/multi-task-flow/node_modules/zod/src/v4/classic/tests/set.test.ts +0 -196
  265. package/toolkit/skills/multi-task-flow/node_modules/zod/src/v4/classic/tests/standard-schema.test.ts +0 -153
  266. package/toolkit/skills/multi-task-flow/node_modules/zod/src/v4/classic/tests/string-formats.test.ts +0 -125
  267. package/toolkit/skills/multi-task-flow/node_modules/zod/src/v4/classic/tests/string.test.ts +0 -1440
  268. package/toolkit/skills/multi-task-flow/node_modules/zod/src/v4/classic/tests/stringbool.test.ts +0 -124
  269. package/toolkit/skills/multi-task-flow/node_modules/zod/src/v4/classic/tests/template-literal.test.ts +0 -812
  270. package/toolkit/skills/multi-task-flow/node_modules/zod/src/v4/classic/tests/to-json-schema-methods.test.ts +0 -438
  271. package/toolkit/skills/multi-task-flow/node_modules/zod/src/v4/classic/tests/to-json-schema.test.ts +0 -4733
  272. package/toolkit/skills/multi-task-flow/node_modules/zod/src/v4/classic/tests/transform.test.ts +0 -378
  273. package/toolkit/skills/multi-task-flow/node_modules/zod/src/v4/classic/tests/tuple.test.ts +0 -511
  274. package/toolkit/skills/multi-task-flow/node_modules/zod/src/v4/classic/tests/union.test.ts +0 -310
  275. package/toolkit/skills/multi-task-flow/node_modules/zod/src/v4/classic/tests/url.test.ts +0 -13
  276. package/toolkit/skills/multi-task-flow/node_modules/zod/src/v4/classic/tests/validate.test.ts +0 -645
  277. package/toolkit/skills/multi-task-flow/node_modules/zod/src/v4/classic/tests/validations.test.ts +0 -283
  278. package/toolkit/skills/multi-task-flow/node_modules/zod/src/v4/classic/tests/void.test.ts +0 -12
  279. package/toolkit/skills/multi-task-flow/node_modules/zod/src/v4/core/api.ts +0 -1875
  280. package/toolkit/skills/multi-task-flow/node_modules/zod/src/v4/core/checks.ts +0 -1266
  281. package/toolkit/skills/multi-task-flow/node_modules/zod/src/v4/core/compile.ts +0 -2322
  282. package/toolkit/skills/multi-task-flow/node_modules/zod/src/v4/core/core.ts +0 -230
  283. package/toolkit/skills/multi-task-flow/node_modules/zod/src/v4/core/doc.ts +0 -52
  284. package/toolkit/skills/multi-task-flow/node_modules/zod/src/v4/core/errors.ts +0 -543
  285. package/toolkit/skills/multi-task-flow/node_modules/zod/src/v4/core/index.ts +0 -19
  286. package/toolkit/skills/multi-task-flow/node_modules/zod/src/v4/core/json-schema-generator.ts +0 -131
  287. package/toolkit/skills/multi-task-flow/node_modules/zod/src/v4/core/json-schema-processors.ts +0 -934
  288. package/toolkit/skills/multi-task-flow/node_modules/zod/src/v4/core/json-schema.ts +0 -148
  289. package/toolkit/skills/multi-task-flow/node_modules/zod/src/v4/core/memoizer.ts +0 -331
  290. package/toolkit/skills/multi-task-flow/node_modules/zod/src/v4/core/parse.ts +0 -309
  291. package/toolkit/skills/multi-task-flow/node_modules/zod/src/v4/core/regexes.ts +0 -217
  292. package/toolkit/skills/multi-task-flow/node_modules/zod/src/v4/core/registries.ts +0 -105
  293. package/toolkit/skills/multi-task-flow/node_modules/zod/src/v4/core/schemas.ts +0 -5226
  294. package/toolkit/skills/multi-task-flow/node_modules/zod/src/v4/core/standard-schema.ts +0 -159
  295. package/toolkit/skills/multi-task-flow/node_modules/zod/src/v4/core/tests/cached.test.ts +0 -54
  296. package/toolkit/skills/multi-task-flow/node_modules/zod/src/v4/core/tests/compile-differential.test.ts +0 -1004
  297. package/toolkit/skills/multi-task-flow/node_modules/zod/src/v4/core/tests/compile-generative.test.ts +0 -445
  298. package/toolkit/skills/multi-task-flow/node_modules/zod/src/v4/core/tests/compile-global.test.ts +0 -89
  299. package/toolkit/skills/multi-task-flow/node_modules/zod/src/v4/core/tests/compile-off-by-default.test.ts +0 -26
  300. package/toolkit/skills/multi-task-flow/node_modules/zod/src/v4/core/tests/compile-stats.test.ts +0 -34
  301. package/toolkit/skills/multi-task-flow/node_modules/zod/src/v4/core/tests/compile.test.ts +0 -2036
  302. package/toolkit/skills/multi-task-flow/node_modules/zod/src/v4/core/tests/email-regex.test.ts +0 -140
  303. package/toolkit/skills/multi-task-flow/node_modules/zod/src/v4/core/tests/extend.test.ts +0 -59
  304. package/toolkit/skills/multi-task-flow/node_modules/zod/src/v4/core/tests/index.test.ts +0 -46
  305. package/toolkit/skills/multi-task-flow/node_modules/zod/src/v4/core/tests/locales/be.test.ts +0 -124
  306. package/toolkit/skills/multi-task-flow/node_modules/zod/src/v4/core/tests/locales/el.test.ts +0 -214
  307. package/toolkit/skills/multi-task-flow/node_modules/zod/src/v4/core/tests/locales/en.test.ts +0 -22
  308. package/toolkit/skills/multi-task-flow/node_modules/zod/src/v4/core/tests/locales/es.test.ts +0 -180
  309. package/toolkit/skills/multi-task-flow/node_modules/zod/src/v4/core/tests/locales/fr.test.ts +0 -72
  310. package/toolkit/skills/multi-task-flow/node_modules/zod/src/v4/core/tests/locales/he.test.ts +0 -379
  311. package/toolkit/skills/multi-task-flow/node_modules/zod/src/v4/core/tests/locales/hr.test.ts +0 -163
  312. package/toolkit/skills/multi-task-flow/node_modules/zod/src/v4/core/tests/locales/nl.test.ts +0 -46
  313. package/toolkit/skills/multi-task-flow/node_modules/zod/src/v4/core/tests/locales/parity.test.ts +0 -42
  314. package/toolkit/skills/multi-task-flow/node_modules/zod/src/v4/core/tests/locales/ru.test.ts +0 -128
  315. package/toolkit/skills/multi-task-flow/node_modules/zod/src/v4/core/tests/locales/tg.test.ts +0 -85
  316. package/toolkit/skills/multi-task-flow/node_modules/zod/src/v4/core/tests/locales/tk.test.ts +0 -69
  317. package/toolkit/skills/multi-task-flow/node_modules/zod/src/v4/core/tests/locales/tr.test.ts +0 -69
  318. package/toolkit/skills/multi-task-flow/node_modules/zod/src/v4/core/tests/locales/uz.test.ts +0 -105
  319. package/toolkit/skills/multi-task-flow/node_modules/zod/src/v4/core/tests/polyfill-collision.test.ts +0 -46
  320. package/toolkit/skills/multi-task-flow/node_modules/zod/src/v4/core/tests/record-constructor.test.ts +0 -125
  321. package/toolkit/skills/multi-task-flow/node_modules/zod/src/v4/core/tests/recursive-tuples.test.ts +0 -45
  322. package/toolkit/skills/multi-task-flow/node_modules/zod/src/v4/core/tests/treeshake.test.ts +0 -51
  323. package/toolkit/skills/multi-task-flow/node_modules/zod/src/v4/core/tests/url-no-canparse.test.ts +0 -133
  324. package/toolkit/skills/multi-task-flow/node_modules/zod/src/v4/core/to-json-schema.ts +0 -857
  325. package/toolkit/skills/multi-task-flow/node_modules/zod/src/v4/core/util.ts +0 -1293
  326. package/toolkit/skills/multi-task-flow/node_modules/zod/src/v4/core/versions.ts +0 -5
  327. package/toolkit/skills/multi-task-flow/node_modules/zod/src/v4/core/visit.ts +0 -193
  328. package/toolkit/skills/multi-task-flow/node_modules/zod/src/v4/core/zsf.ts +0 -323
  329. package/toolkit/skills/multi-task-flow/node_modules/zod/src/v4/index.ts +0 -4
  330. package/toolkit/skills/multi-task-flow/node_modules/zod/src/v4/locales/ar.ts +0 -120
  331. package/toolkit/skills/multi-task-flow/node_modules/zod/src/v4/locales/az.ts +0 -116
  332. package/toolkit/skills/multi-task-flow/node_modules/zod/src/v4/locales/be.ts +0 -188
  333. package/toolkit/skills/multi-task-flow/node_modules/zod/src/v4/locales/bg.ts +0 -133
  334. package/toolkit/skills/multi-task-flow/node_modules/zod/src/v4/locales/bn.ts +0 -123
  335. package/toolkit/skills/multi-task-flow/node_modules/zod/src/v4/locales/ca.ts +0 -121
  336. package/toolkit/skills/multi-task-flow/node_modules/zod/src/v4/locales/ckb.ts +0 -140
  337. package/toolkit/skills/multi-task-flow/node_modules/zod/src/v4/locales/cs.ts +0 -123
  338. package/toolkit/skills/multi-task-flow/node_modules/zod/src/v4/locales/da.ts +0 -128
  339. package/toolkit/skills/multi-task-flow/node_modules/zod/src/v4/locales/de.ts +0 -121
  340. package/toolkit/skills/multi-task-flow/node_modules/zod/src/v4/locales/el.ts +0 -124
  341. package/toolkit/skills/multi-task-flow/node_modules/zod/src/v4/locales/en.ts +0 -136
  342. package/toolkit/skills/multi-task-flow/node_modules/zod/src/v4/locales/eo.ts +0 -123
  343. package/toolkit/skills/multi-task-flow/node_modules/zod/src/v4/locales/es.ts +0 -145
  344. package/toolkit/skills/multi-task-flow/node_modules/zod/src/v4/locales/fa.ts +0 -131
  345. package/toolkit/skills/multi-task-flow/node_modules/zod/src/v4/locales/fi.ts +0 -126
  346. package/toolkit/skills/multi-task-flow/node_modules/zod/src/v4/locales/fr-CA.ts +0 -121
  347. package/toolkit/skills/multi-task-flow/node_modules/zod/src/v4/locales/fr.ts +0 -139
  348. package/toolkit/skills/multi-task-flow/node_modules/zod/src/v4/locales/gu.ts +0 -123
  349. package/toolkit/skills/multi-task-flow/node_modules/zod/src/v4/locales/he.ts +0 -253
  350. package/toolkit/skills/multi-task-flow/node_modules/zod/src/v4/locales/hi.ts +0 -126
  351. package/toolkit/skills/multi-task-flow/node_modules/zod/src/v4/locales/hr.ts +0 -135
  352. package/toolkit/skills/multi-task-flow/node_modules/zod/src/v4/locales/hu.ts +0 -122
  353. package/toolkit/skills/multi-task-flow/node_modules/zod/src/v4/locales/hy.ts +0 -175
  354. package/toolkit/skills/multi-task-flow/node_modules/zod/src/v4/locales/id.ts +0 -120
  355. package/toolkit/skills/multi-task-flow/node_modules/zod/src/v4/locales/index.ts +0 -63
  356. package/toolkit/skills/multi-task-flow/node_modules/zod/src/v4/locales/is.ts +0 -124
  357. package/toolkit/skills/multi-task-flow/node_modules/zod/src/v4/locales/it.ts +0 -121
  358. package/toolkit/skills/multi-task-flow/node_modules/zod/src/v4/locales/ja.ts +0 -119
  359. package/toolkit/skills/multi-task-flow/node_modules/zod/src/v4/locales/ka.ts +0 -128
  360. package/toolkit/skills/multi-task-flow/node_modules/zod/src/v4/locales/kh.ts +0 -7
  361. package/toolkit/skills/multi-task-flow/node_modules/zod/src/v4/locales/km.ts +0 -124
  362. package/toolkit/skills/multi-task-flow/node_modules/zod/src/v4/locales/kn.ts +0 -126
  363. package/toolkit/skills/multi-task-flow/node_modules/zod/src/v4/locales/ko.ts +0 -126
  364. package/toolkit/skills/multi-task-flow/node_modules/zod/src/v4/locales/lt.ts +0 -243
  365. package/toolkit/skills/multi-task-flow/node_modules/zod/src/v4/locales/mk.ts +0 -123
  366. package/toolkit/skills/multi-task-flow/node_modules/zod/src/v4/locales/ms.ts +0 -120
  367. package/toolkit/skills/multi-task-flow/node_modules/zod/src/v4/locales/ne.ts +0 -128
  368. package/toolkit/skills/multi-task-flow/node_modules/zod/src/v4/locales/nl.ts +0 -126
  369. package/toolkit/skills/multi-task-flow/node_modules/zod/src/v4/locales/nn.ts +0 -121
  370. package/toolkit/skills/multi-task-flow/node_modules/zod/src/v4/locales/no.ts +0 -121
  371. package/toolkit/skills/multi-task-flow/node_modules/zod/src/v4/locales/ota.ts +0 -122
  372. package/toolkit/skills/multi-task-flow/node_modules/zod/src/v4/locales/pl.ts +0 -123
  373. package/toolkit/skills/multi-task-flow/node_modules/zod/src/v4/locales/ps.ts +0 -131
  374. package/toolkit/skills/multi-task-flow/node_modules/zod/src/v4/locales/pt-BR.ts +0 -161
  375. package/toolkit/skills/multi-task-flow/node_modules/zod/src/v4/locales/pt.ts +0 -159
  376. package/toolkit/skills/multi-task-flow/node_modules/zod/src/v4/locales/ro.ts +0 -132
  377. package/toolkit/skills/multi-task-flow/node_modules/zod/src/v4/locales/ru.ts +0 -188
  378. package/toolkit/skills/multi-task-flow/node_modules/zod/src/v4/locales/sk.ts +0 -123
  379. package/toolkit/skills/multi-task-flow/node_modules/zod/src/v4/locales/sl.ts +0 -123
  380. package/toolkit/skills/multi-task-flow/node_modules/zod/src/v4/locales/sv.ts +0 -124
  381. package/toolkit/skills/multi-task-flow/node_modules/zod/src/v4/locales/ta.ts +0 -123
  382. package/toolkit/skills/multi-task-flow/node_modules/zod/src/v4/locales/tg.ts +0 -135
  383. package/toolkit/skills/multi-task-flow/node_modules/zod/src/v4/locales/th.ts +0 -124
  384. package/toolkit/skills/multi-task-flow/node_modules/zod/src/v4/locales/tk.ts +0 -113
  385. package/toolkit/skills/multi-task-flow/node_modules/zod/src/v4/locales/tr.ts +0 -116
  386. package/toolkit/skills/multi-task-flow/node_modules/zod/src/v4/locales/ua.ts +0 -7
  387. package/toolkit/skills/multi-task-flow/node_modules/zod/src/v4/locales/uk.ts +0 -122
  388. package/toolkit/skills/multi-task-flow/node_modules/zod/src/v4/locales/ur.ts +0 -124
  389. package/toolkit/skills/multi-task-flow/node_modules/zod/src/v4/locales/uz.ts +0 -120
  390. package/toolkit/skills/multi-task-flow/node_modules/zod/src/v4/locales/vi.ts +0 -122
  391. package/toolkit/skills/multi-task-flow/node_modules/zod/src/v4/locales/yo.ts +0 -129
  392. package/toolkit/skills/multi-task-flow/node_modules/zod/src/v4/locales/zh-CN.ts +0 -121
  393. package/toolkit/skills/multi-task-flow/node_modules/zod/src/v4/locales/zh-TW.ts +0 -120
  394. package/toolkit/skills/multi-task-flow/node_modules/zod/src/v4/mini/checks.ts +0 -33
  395. package/toolkit/skills/multi-task-flow/node_modules/zod/src/v4/mini/coerce.ts +0 -27
  396. package/toolkit/skills/multi-task-flow/node_modules/zod/src/v4/mini/deep-partial.ts +0 -73
  397. package/toolkit/skills/multi-task-flow/node_modules/zod/src/v4/mini/external.ts +0 -52
  398. package/toolkit/skills/multi-task-flow/node_modules/zod/src/v4/mini/in-out.ts +0 -45
  399. package/toolkit/skills/multi-task-flow/node_modules/zod/src/v4/mini/index.ts +0 -3
  400. package/toolkit/skills/multi-task-flow/node_modules/zod/src/v4/mini/iso.ts +0 -66
  401. package/toolkit/skills/multi-task-flow/node_modules/zod/src/v4/mini/parse.ts +0 -16
  402. package/toolkit/skills/multi-task-flow/node_modules/zod/src/v4/mini/schemas.ts +0 -2051
  403. package/toolkit/skills/multi-task-flow/node_modules/zod/src/v4/mini/tests/apply.test.ts +0 -57
  404. package/toolkit/skills/multi-task-flow/node_modules/zod/src/v4/mini/tests/assignability.test.ts +0 -190
  405. package/toolkit/skills/multi-task-flow/node_modules/zod/src/v4/mini/tests/brand.test.ts +0 -94
  406. package/toolkit/skills/multi-task-flow/node_modules/zod/src/v4/mini/tests/checks.test.ts +0 -158
  407. package/toolkit/skills/multi-task-flow/node_modules/zod/src/v4/mini/tests/codec.test.ts +0 -582
  408. package/toolkit/skills/multi-task-flow/node_modules/zod/src/v4/mini/tests/computed.test.ts +0 -30
  409. package/toolkit/skills/multi-task-flow/node_modules/zod/src/v4/mini/tests/cyclic-data.test.ts +0 -84
  410. package/toolkit/skills/multi-task-flow/node_modules/zod/src/v4/mini/tests/deep-partial.test.ts +0 -54
  411. package/toolkit/skills/multi-task-flow/node_modules/zod/src/v4/mini/tests/error.test.ts +0 -41
  412. package/toolkit/skills/multi-task-flow/node_modules/zod/src/v4/mini/tests/functions.test.ts +0 -14
  413. package/toolkit/skills/multi-task-flow/node_modules/zod/src/v4/mini/tests/index.test.ts +0 -1146
  414. package/toolkit/skills/multi-task-flow/node_modules/zod/src/v4/mini/tests/number.test.ts +0 -109
  415. package/toolkit/skills/multi-task-flow/node_modules/zod/src/v4/mini/tests/object.test.ts +0 -292
  416. package/toolkit/skills/multi-task-flow/node_modules/zod/src/v4/mini/tests/prototypes.test.ts +0 -43
  417. package/toolkit/skills/multi-task-flow/node_modules/zod/src/v4/mini/tests/recursive-types.test.ts +0 -341
  418. package/toolkit/skills/multi-task-flow/node_modules/zod/src/v4/mini/tests/standard-schema.test.ts +0 -50
  419. package/toolkit/skills/multi-task-flow/node_modules/zod/src/v4/mini/tests/string.test.ts +0 -396
  420. package/toolkit/skills/multi-task-flow/node_modules/zod/src/v4-mini/index.ts +0 -3
  421. package/toolkit/skills/multi-task-flow/node_modules/zod/v3/ZodError.cjs +0 -167
  422. package/toolkit/skills/multi-task-flow/node_modules/zod/v3/ZodError.d.cts +0 -164
  423. package/toolkit/skills/multi-task-flow/node_modules/zod/v3/ZodError.d.ts +0 -164
  424. package/toolkit/skills/multi-task-flow/node_modules/zod/v3/ZodError.js +0 -143
  425. package/toolkit/skills/multi-task-flow/node_modules/zod/v3/errors.cjs +0 -36
  426. package/toolkit/skills/multi-task-flow/node_modules/zod/v3/errors.d.cts +0 -5
  427. package/toolkit/skills/multi-task-flow/node_modules/zod/v3/errors.d.ts +0 -5
  428. package/toolkit/skills/multi-task-flow/node_modules/zod/v3/errors.js +0 -9
  429. package/toolkit/skills/multi-task-flow/node_modules/zod/v3/external.cjs +0 -41
  430. package/toolkit/skills/multi-task-flow/node_modules/zod/v3/external.d.cts +0 -6
  431. package/toolkit/skills/multi-task-flow/node_modules/zod/v3/external.d.ts +0 -6
  432. package/toolkit/skills/multi-task-flow/node_modules/zod/v3/external.js +0 -6
  433. package/toolkit/skills/multi-task-flow/node_modules/zod/v3/helpers/enumUtil.cjs +0 -21
  434. package/toolkit/skills/multi-task-flow/node_modules/zod/v3/helpers/enumUtil.d.cts +0 -8
  435. package/toolkit/skills/multi-task-flow/node_modules/zod/v3/helpers/enumUtil.d.ts +0 -8
  436. package/toolkit/skills/multi-task-flow/node_modules/zod/v3/helpers/enumUtil.js +0 -1
  437. package/toolkit/skills/multi-task-flow/node_modules/zod/v3/helpers/errorUtil.cjs +0 -28
  438. package/toolkit/skills/multi-task-flow/node_modules/zod/v3/helpers/errorUtil.d.cts +0 -9
  439. package/toolkit/skills/multi-task-flow/node_modules/zod/v3/helpers/errorUtil.d.ts +0 -9
  440. package/toolkit/skills/multi-task-flow/node_modules/zod/v3/helpers/errorUtil.js +0 -6
  441. package/toolkit/skills/multi-task-flow/node_modules/zod/v3/helpers/parseUtil.cjs +0 -143
  442. package/toolkit/skills/multi-task-flow/node_modules/zod/v3/helpers/parseUtil.d.cts +0 -78
  443. package/toolkit/skills/multi-task-flow/node_modules/zod/v3/helpers/parseUtil.d.ts +0 -78
  444. package/toolkit/skills/multi-task-flow/node_modules/zod/v3/helpers/parseUtil.js +0 -109
  445. package/toolkit/skills/multi-task-flow/node_modules/zod/v3/helpers/partialUtil.cjs +0 -21
  446. package/toolkit/skills/multi-task-flow/node_modules/zod/v3/helpers/partialUtil.d.cts +0 -8
  447. package/toolkit/skills/multi-task-flow/node_modules/zod/v3/helpers/partialUtil.d.ts +0 -8
  448. package/toolkit/skills/multi-task-flow/node_modules/zod/v3/helpers/partialUtil.js +0 -1
  449. package/toolkit/skills/multi-task-flow/node_modules/zod/v3/helpers/typeAliases.cjs +0 -21
  450. package/toolkit/skills/multi-task-flow/node_modules/zod/v3/helpers/typeAliases.d.cts +0 -2
  451. package/toolkit/skills/multi-task-flow/node_modules/zod/v3/helpers/typeAliases.d.ts +0 -2
  452. package/toolkit/skills/multi-task-flow/node_modules/zod/v3/helpers/typeAliases.js +0 -1
  453. package/toolkit/skills/multi-task-flow/node_modules/zod/v3/helpers/util.cjs +0 -156
  454. package/toolkit/skills/multi-task-flow/node_modules/zod/v3/helpers/util.d.cts +0 -85
  455. package/toolkit/skills/multi-task-flow/node_modules/zod/v3/helpers/util.d.ts +0 -85
  456. package/toolkit/skills/multi-task-flow/node_modules/zod/v3/helpers/util.js +0 -133
  457. package/toolkit/skills/multi-task-flow/node_modules/zod/v3/index.cjs +0 -52
  458. package/toolkit/skills/multi-task-flow/node_modules/zod/v3/index.d.cts +0 -4
  459. package/toolkit/skills/multi-task-flow/node_modules/zod/v3/index.d.ts +0 -4
  460. package/toolkit/skills/multi-task-flow/node_modules/zod/v3/index.js +0 -4
  461. package/toolkit/skills/multi-task-flow/node_modules/zod/v3/locales/en.cjs +0 -112
  462. package/toolkit/skills/multi-task-flow/node_modules/zod/v3/locales/en.d.cts +0 -3
  463. package/toolkit/skills/multi-task-flow/node_modules/zod/v3/locales/en.d.ts +0 -3
  464. package/toolkit/skills/multi-task-flow/node_modules/zod/v3/locales/en.js +0 -109
  465. package/toolkit/skills/multi-task-flow/node_modules/zod/v3/package.json +0 -7
  466. package/toolkit/skills/multi-task-flow/node_modules/zod/v3/standard-schema.cjs +0 -21
  467. package/toolkit/skills/multi-task-flow/node_modules/zod/v3/standard-schema.d.cts +0 -102
  468. package/toolkit/skills/multi-task-flow/node_modules/zod/v3/standard-schema.d.ts +0 -102
  469. package/toolkit/skills/multi-task-flow/node_modules/zod/v3/standard-schema.js +0 -1
  470. package/toolkit/skills/multi-task-flow/node_modules/zod/v3/types.cjs +0 -3798
  471. package/toolkit/skills/multi-task-flow/node_modules/zod/v3/types.d.cts +0 -1034
  472. package/toolkit/skills/multi-task-flow/node_modules/zod/v3/types.d.ts +0 -1034
  473. package/toolkit/skills/multi-task-flow/node_modules/zod/v3/types.js +0 -3697
  474. package/toolkit/skills/multi-task-flow/node_modules/zod/v4/classic/checks.cjs +0 -53
  475. package/toolkit/skills/multi-task-flow/node_modules/zod/v4/classic/checks.d.cts +0 -1
  476. package/toolkit/skills/multi-task-flow/node_modules/zod/v4/classic/checks.d.ts +0 -1
  477. package/toolkit/skills/multi-task-flow/node_modules/zod/v4/classic/checks.js +0 -1
  478. package/toolkit/skills/multi-task-flow/node_modules/zod/v4/classic/coerce.cjs +0 -66
  479. package/toolkit/skills/multi-task-flow/node_modules/zod/v4/classic/coerce.d.cts +0 -17
  480. package/toolkit/skills/multi-task-flow/node_modules/zod/v4/classic/coerce.d.ts +0 -17
  481. package/toolkit/skills/multi-task-flow/node_modules/zod/v4/classic/coerce.js +0 -17
  482. package/toolkit/skills/multi-task-flow/node_modules/zod/v4/classic/compat.cjs +0 -80
  483. package/toolkit/skills/multi-task-flow/node_modules/zod/v4/classic/compat.d.cts +0 -48
  484. package/toolkit/skills/multi-task-flow/node_modules/zod/v4/classic/compat.d.ts +0 -48
  485. package/toolkit/skills/multi-task-flow/node_modules/zod/v4/classic/compat.js +0 -31
  486. package/toolkit/skills/multi-task-flow/node_modules/zod/v4/classic/deep-partial.cjs +0 -58
  487. package/toolkit/skills/multi-task-flow/node_modules/zod/v4/classic/deep-partial.d.cts +0 -14
  488. package/toolkit/skills/multi-task-flow/node_modules/zod/v4/classic/deep-partial.d.ts +0 -14
  489. package/toolkit/skills/multi-task-flow/node_modules/zod/v4/classic/deep-partial.js +0 -13
  490. package/toolkit/skills/multi-task-flow/node_modules/zod/v4/classic/errors.cjs +0 -102
  491. package/toolkit/skills/multi-task-flow/node_modules/zod/v4/classic/errors.d.cts +0 -29
  492. package/toolkit/skills/multi-task-flow/node_modules/zod/v4/classic/errors.d.ts +0 -29
  493. package/toolkit/skills/multi-task-flow/node_modules/zod/v4/classic/errors.js +0 -57
  494. package/toolkit/skills/multi-task-flow/node_modules/zod/v4/classic/external.cjs +0 -97
  495. package/toolkit/skills/multi-task-flow/node_modules/zod/v4/classic/external.d.cts +0 -19
  496. package/toolkit/skills/multi-task-flow/node_modules/zod/v4/classic/external.d.ts +0 -19
  497. package/toolkit/skills/multi-task-flow/node_modules/zod/v4/classic/external.js +0 -17
  498. package/toolkit/skills/multi-task-flow/node_modules/zod/v4/classic/from-json-schema.cjs +0 -926
  499. package/toolkit/skills/multi-task-flow/node_modules/zod/v4/classic/from-json-schema.d.cts +0 -12
  500. package/toolkit/skills/multi-task-flow/node_modules/zod/v4/classic/from-json-schema.d.ts +0 -12
  501. package/toolkit/skills/multi-task-flow/node_modules/zod/v4/classic/from-json-schema.js +0 -881
  502. package/toolkit/skills/multi-task-flow/node_modules/zod/v4/classic/in-out.cjs +0 -82
  503. package/toolkit/skills/multi-task-flow/node_modules/zod/v4/classic/in-out.d.cts +0 -8
  504. package/toolkit/skills/multi-task-flow/node_modules/zod/v4/classic/in-out.d.ts +0 -8
  505. package/toolkit/skills/multi-task-flow/node_modules/zod/v4/classic/in-out.js +0 -36
  506. package/toolkit/skills/multi-task-flow/node_modules/zod/v4/classic/index.cjs +0 -52
  507. package/toolkit/skills/multi-task-flow/node_modules/zod/v4/classic/index.d.cts +0 -3
  508. package/toolkit/skills/multi-task-flow/node_modules/zod/v4/classic/index.d.ts +0 -3
  509. package/toolkit/skills/multi-task-flow/node_modules/zod/v4/classic/index.js +0 -4
  510. package/toolkit/skills/multi-task-flow/node_modules/zod/v4/classic/iso.cjs +0 -68
  511. package/toolkit/skills/multi-task-flow/node_modules/zod/v4/classic/iso.d.cts +0 -7
  512. package/toolkit/skills/multi-task-flow/node_modules/zod/v4/classic/iso.d.ts +0 -7
  513. package/toolkit/skills/multi-task-flow/node_modules/zod/v4/classic/iso.js +0 -15
  514. package/toolkit/skills/multi-task-flow/node_modules/zod/v4/classic/package.json +0 -7
  515. package/toolkit/skills/multi-task-flow/node_modules/zod/v4/classic/parse.cjs +0 -63
  516. package/toolkit/skills/multi-task-flow/node_modules/zod/v4/classic/parse.d.cts +0 -44
  517. package/toolkit/skills/multi-task-flow/node_modules/zod/v4/classic/parse.d.ts +0 -44
  518. package/toolkit/skills/multi-task-flow/node_modules/zod/v4/classic/parse.js +0 -16
  519. package/toolkit/skills/multi-task-flow/node_modules/zod/v4/classic/schemas.cjs +0 -1676
  520. package/toolkit/skills/multi-task-flow/node_modules/zod/v4/classic/schemas.d.cts +0 -816
  521. package/toolkit/skills/multi-task-flow/node_modules/zod/v4/classic/schemas.d.ts +0 -816
  522. package/toolkit/skills/multi-task-flow/node_modules/zod/v4/classic/schemas.js +0 -1535
  523. package/toolkit/skills/multi-task-flow/node_modules/zod/v4/core/api.cjs +0 -1269
  524. package/toolkit/skills/multi-task-flow/node_modules/zod/v4/core/api.d.cts +0 -335
  525. package/toolkit/skills/multi-task-flow/node_modules/zod/v4/core/api.d.ts +0 -335
  526. package/toolkit/skills/multi-task-flow/node_modules/zod/v4/core/api.js +0 -1107
  527. package/toolkit/skills/multi-task-flow/node_modules/zod/v4/core/checks.cjs +0 -561
  528. package/toolkit/skills/multi-task-flow/node_modules/zod/v4/core/checks.d.cts +0 -294
  529. package/toolkit/skills/multi-task-flow/node_modules/zod/v4/core/checks.d.ts +0 -294
  530. package/toolkit/skills/multi-task-flow/node_modules/zod/v4/core/checks.js +0 -516
  531. package/toolkit/skills/multi-task-flow/node_modules/zod/v4/core/compile.cjs +0 -1916
  532. package/toolkit/skills/multi-task-flow/node_modules/zod/v4/core/compile.d.cts +0 -65
  533. package/toolkit/skills/multi-task-flow/node_modules/zod/v4/core/compile.d.ts +0 -65
  534. package/toolkit/skills/multi-task-flow/node_modules/zod/v4/core/compile.js +0 -1866
  535. package/toolkit/skills/multi-task-flow/node_modules/zod/v4/core/core.cjs +0 -167
  536. package/toolkit/skills/multi-task-flow/node_modules/zod/v4/core/core.d.cts +0 -82
  537. package/toolkit/skills/multi-task-flow/node_modules/zod/v4/core/core.d.ts +0 -82
  538. package/toolkit/skills/multi-task-flow/node_modules/zod/v4/core/core.js +0 -141
  539. package/toolkit/skills/multi-task-flow/node_modules/zod/v4/core/doc.cjs +0 -61
  540. package/toolkit/skills/multi-task-flow/node_modules/zod/v4/core/doc.d.cts +0 -16
  541. package/toolkit/skills/multi-task-flow/node_modules/zod/v4/core/doc.d.ts +0 -16
  542. package/toolkit/skills/multi-task-flow/node_modules/zod/v4/core/doc.js +0 -38
  543. package/toolkit/skills/multi-task-flow/node_modules/zod/v4/core/errors.cjs +0 -317
  544. package/toolkit/skills/multi-task-flow/node_modules/zod/v4/core/errors.d.cts +0 -225
  545. package/toolkit/skills/multi-task-flow/node_modules/zod/v4/core/errors.d.ts +0 -225
  546. package/toolkit/skills/multi-task-flow/node_modules/zod/v4/core/errors.js +0 -267
  547. package/toolkit/skills/multi-task-flow/node_modules/zod/v4/core/index.cjs +0 -70
  548. package/toolkit/skills/multi-task-flow/node_modules/zod/v4/core/index.d.cts +0 -19
  549. package/toolkit/skills/multi-task-flow/node_modules/zod/v4/core/index.d.ts +0 -19
  550. package/toolkit/skills/multi-task-flow/node_modules/zod/v4/core/index.js +0 -19
  551. package/toolkit/skills/multi-task-flow/node_modules/zod/v4/core/json-schema-generator.cjs +0 -122
  552. package/toolkit/skills/multi-task-flow/node_modules/zod/v4/core/json-schema-generator.d.cts +0 -65
  553. package/toolkit/skills/multi-task-flow/node_modules/zod/v4/core/json-schema-generator.d.ts +0 -65
  554. package/toolkit/skills/multi-task-flow/node_modules/zod/v4/core/json-schema-generator.js +0 -99
  555. package/toolkit/skills/multi-task-flow/node_modules/zod/v4/core/json-schema-processors.cjs +0 -929
  556. package/toolkit/skills/multi-task-flow/node_modules/zod/v4/core/json-schema-processors.d.cts +0 -65
  557. package/toolkit/skills/multi-task-flow/node_modules/zod/v4/core/json-schema-processors.d.ts +0 -65
  558. package/toolkit/skills/multi-task-flow/node_modules/zod/v4/core/json-schema-processors.js +0 -843
  559. package/toolkit/skills/multi-task-flow/node_modules/zod/v4/core/json-schema.cjs +0 -21
  560. package/toolkit/skills/multi-task-flow/node_modules/zod/v4/core/json-schema.d.cts +0 -89
  561. package/toolkit/skills/multi-task-flow/node_modules/zod/v4/core/json-schema.d.ts +0 -89
  562. package/toolkit/skills/multi-task-flow/node_modules/zod/v4/core/json-schema.js +0 -1
  563. package/toolkit/skills/multi-task-flow/node_modules/zod/v4/core/memoizer.cjs +0 -360
  564. package/toolkit/skills/multi-task-flow/node_modules/zod/v4/core/memoizer.d.cts +0 -15
  565. package/toolkit/skills/multi-task-flow/node_modules/zod/v4/core/memoizer.d.ts +0 -15
  566. package/toolkit/skills/multi-task-flow/node_modules/zod/v4/core/memoizer.js +0 -311
  567. package/toolkit/skills/multi-task-flow/node_modules/zod/v4/core/package.json +0 -7
  568. package/toolkit/skills/multi-task-flow/node_modules/zod/v4/core/parse.cjs +0 -233
  569. package/toolkit/skills/multi-task-flow/node_modules/zod/v4/core/parse.d.cts +0 -52
  570. package/toolkit/skills/multi-task-flow/node_modules/zod/v4/core/parse.d.ts +0 -52
  571. package/toolkit/skills/multi-task-flow/node_modules/zod/v4/core/parse.js +0 -175
  572. package/toolkit/skills/multi-task-flow/node_modules/zod/v4/core/regexes.cjs +0 -209
  573. package/toolkit/skills/multi-task-flow/node_modules/zod/v4/core/regexes.d.cts +0 -90
  574. package/toolkit/skills/multi-task-flow/node_modules/zod/v4/core/regexes.d.ts +0 -90
  575. package/toolkit/skills/multi-task-flow/node_modules/zod/v4/core/regexes.js +0 -156
  576. package/toolkit/skills/multi-task-flow/node_modules/zod/v4/core/registries.cjs +0 -75
  577. package/toolkit/skills/multi-task-flow/node_modules/zod/v4/core/registries.d.cts +0 -35
  578. package/toolkit/skills/multi-task-flow/node_modules/zod/v4/core/registries.d.ts +0 -35
  579. package/toolkit/skills/multi-task-flow/node_modules/zod/v4/core/registries.js +0 -51
  580. package/toolkit/skills/multi-task-flow/node_modules/zod/v4/core/schemas.cjs +0 -2699
  581. package/toolkit/skills/multi-task-flow/node_modules/zod/v4/core/schemas.d.cts +0 -1275
  582. package/toolkit/skills/multi-task-flow/node_modules/zod/v4/core/schemas.d.ts +0 -1275
  583. package/toolkit/skills/multi-task-flow/node_modules/zod/v4/core/schemas.js +0 -2636
  584. package/toolkit/skills/multi-task-flow/node_modules/zod/v4/core/standard-schema.cjs +0 -21
  585. package/toolkit/skills/multi-task-flow/node_modules/zod/v4/core/standard-schema.d.cts +0 -126
  586. package/toolkit/skills/multi-task-flow/node_modules/zod/v4/core/standard-schema.d.ts +0 -126
  587. package/toolkit/skills/multi-task-flow/node_modules/zod/v4/core/standard-schema.js +0 -1
  588. package/toolkit/skills/multi-task-flow/node_modules/zod/v4/core/to-json-schema.cjs +0 -681
  589. package/toolkit/skills/multi-task-flow/node_modules/zod/v4/core/to-json-schema.d.cts +0 -154
  590. package/toolkit/skills/multi-task-flow/node_modules/zod/v4/core/to-json-schema.d.ts +0 -154
  591. package/toolkit/skills/multi-task-flow/node_modules/zod/v4/core/to-json-schema.js +0 -651
  592. package/toolkit/skills/multi-task-flow/node_modules/zod/v4/core/util.cjs +0 -964
  593. package/toolkit/skills/multi-task-flow/node_modules/zod/v4/core/util.d.cts +0 -280
  594. package/toolkit/skills/multi-task-flow/node_modules/zod/v4/core/util.d.ts +0 -280
  595. package/toolkit/skills/multi-task-flow/node_modules/zod/v4/core/util.js +0 -873
  596. package/toolkit/skills/multi-task-flow/node_modules/zod/v4/core/versions.cjs +0 -27
  597. package/toolkit/skills/multi-task-flow/node_modules/zod/v4/core/versions.d.cts +0 -5
  598. package/toolkit/skills/multi-task-flow/node_modules/zod/v4/core/versions.d.ts +0 -5
  599. package/toolkit/skills/multi-task-flow/node_modules/zod/v4/core/versions.js +0 -5
  600. package/toolkit/skills/multi-task-flow/node_modules/zod/v4/core/visit.cjs +0 -214
  601. package/toolkit/skills/multi-task-flow/node_modules/zod/v4/core/visit.d.cts +0 -30
  602. package/toolkit/skills/multi-task-flow/node_modules/zod/v4/core/visit.d.ts +0 -30
  603. package/toolkit/skills/multi-task-flow/node_modules/zod/v4/core/visit.js +0 -169
  604. package/toolkit/skills/multi-task-flow/node_modules/zod/v4/index.cjs +0 -51
  605. package/toolkit/skills/multi-task-flow/node_modules/zod/v4/index.d.cts +0 -3
  606. package/toolkit/skills/multi-task-flow/node_modules/zod/v4/index.d.ts +0 -3
  607. package/toolkit/skills/multi-task-flow/node_modules/zod/v4/index.js +0 -4
  608. package/toolkit/skills/multi-task-flow/node_modules/zod/v4/locales/ar.cjs +0 -138
  609. package/toolkit/skills/multi-task-flow/node_modules/zod/v4/locales/ar.d.cts +0 -5
  610. package/toolkit/skills/multi-task-flow/node_modules/zod/v4/locales/ar.d.ts +0 -4
  611. package/toolkit/skills/multi-task-flow/node_modules/zod/v4/locales/ar.js +0 -111
  612. package/toolkit/skills/multi-task-flow/node_modules/zod/v4/locales/az.cjs +0 -137
  613. package/toolkit/skills/multi-task-flow/node_modules/zod/v4/locales/az.d.cts +0 -5
  614. package/toolkit/skills/multi-task-flow/node_modules/zod/v4/locales/az.d.ts +0 -4
  615. package/toolkit/skills/multi-task-flow/node_modules/zod/v4/locales/az.js +0 -110
  616. package/toolkit/skills/multi-task-flow/node_modules/zod/v4/locales/be.cjs +0 -195
  617. package/toolkit/skills/multi-task-flow/node_modules/zod/v4/locales/be.d.cts +0 -5
  618. package/toolkit/skills/multi-task-flow/node_modules/zod/v4/locales/be.d.ts +0 -4
  619. package/toolkit/skills/multi-task-flow/node_modules/zod/v4/locales/be.js +0 -168
  620. package/toolkit/skills/multi-task-flow/node_modules/zod/v4/locales/bg.cjs +0 -152
  621. package/toolkit/skills/multi-task-flow/node_modules/zod/v4/locales/bg.d.cts +0 -5
  622. package/toolkit/skills/multi-task-flow/node_modules/zod/v4/locales/bg.d.ts +0 -4
  623. package/toolkit/skills/multi-task-flow/node_modules/zod/v4/locales/bg.js +0 -125
  624. package/toolkit/skills/multi-task-flow/node_modules/zod/v4/locales/bn.cjs +0 -140
  625. package/toolkit/skills/multi-task-flow/node_modules/zod/v4/locales/bn.d.cts +0 -5
  626. package/toolkit/skills/multi-task-flow/node_modules/zod/v4/locales/bn.d.ts +0 -4
  627. package/toolkit/skills/multi-task-flow/node_modules/zod/v4/locales/bn.js +0 -113
  628. package/toolkit/skills/multi-task-flow/node_modules/zod/v4/locales/ca.cjs +0 -139
  629. package/toolkit/skills/multi-task-flow/node_modules/zod/v4/locales/ca.d.cts +0 -5
  630. package/toolkit/skills/multi-task-flow/node_modules/zod/v4/locales/ca.d.ts +0 -4
  631. package/toolkit/skills/multi-task-flow/node_modules/zod/v4/locales/ca.js +0 -112
  632. package/toolkit/skills/multi-task-flow/node_modules/zod/v4/locales/ckb.cjs +0 -160
  633. package/toolkit/skills/multi-task-flow/node_modules/zod/v4/locales/ckb.d.cts +0 -5
  634. package/toolkit/skills/multi-task-flow/node_modules/zod/v4/locales/ckb.d.ts +0 -4
  635. package/toolkit/skills/multi-task-flow/node_modules/zod/v4/locales/ckb.js +0 -133
  636. package/toolkit/skills/multi-task-flow/node_modules/zod/v4/locales/cs.cjs +0 -143
  637. package/toolkit/skills/multi-task-flow/node_modules/zod/v4/locales/cs.d.cts +0 -5
  638. package/toolkit/skills/multi-task-flow/node_modules/zod/v4/locales/cs.d.ts +0 -4
  639. package/toolkit/skills/multi-task-flow/node_modules/zod/v4/locales/cs.js +0 -116
  640. package/toolkit/skills/multi-task-flow/node_modules/zod/v4/locales/da.cjs +0 -147
  641. package/toolkit/skills/multi-task-flow/node_modules/zod/v4/locales/da.d.cts +0 -5
  642. package/toolkit/skills/multi-task-flow/node_modules/zod/v4/locales/da.d.ts +0 -4
  643. package/toolkit/skills/multi-task-flow/node_modules/zod/v4/locales/da.js +0 -120
  644. package/toolkit/skills/multi-task-flow/node_modules/zod/v4/locales/de.cjs +0 -140
  645. package/toolkit/skills/multi-task-flow/node_modules/zod/v4/locales/de.d.cts +0 -5
  646. package/toolkit/skills/multi-task-flow/node_modules/zod/v4/locales/de.d.ts +0 -4
  647. package/toolkit/skills/multi-task-flow/node_modules/zod/v4/locales/de.js +0 -113
  648. package/toolkit/skills/multi-task-flow/node_modules/zod/v4/locales/el.cjs +0 -139
  649. package/toolkit/skills/multi-task-flow/node_modules/zod/v4/locales/el.d.cts +0 -5
  650. package/toolkit/skills/multi-task-flow/node_modules/zod/v4/locales/el.d.ts +0 -4
  651. package/toolkit/skills/multi-task-flow/node_modules/zod/v4/locales/el.js +0 -112
  652. package/toolkit/skills/multi-task-flow/node_modules/zod/v4/locales/en.cjs +0 -152
  653. package/toolkit/skills/multi-task-flow/node_modules/zod/v4/locales/en.d.cts +0 -5
  654. package/toolkit/skills/multi-task-flow/node_modules/zod/v4/locales/en.d.ts +0 -4
  655. package/toolkit/skills/multi-task-flow/node_modules/zod/v4/locales/en.js +0 -125
  656. package/toolkit/skills/multi-task-flow/node_modules/zod/v4/locales/eo.cjs +0 -141
  657. package/toolkit/skills/multi-task-flow/node_modules/zod/v4/locales/eo.d.cts +0 -5
  658. package/toolkit/skills/multi-task-flow/node_modules/zod/v4/locales/eo.d.ts +0 -4
  659. package/toolkit/skills/multi-task-flow/node_modules/zod/v4/locales/eo.js +0 -114
  660. package/toolkit/skills/multi-task-flow/node_modules/zod/v4/locales/es.cjs +0 -163
  661. package/toolkit/skills/multi-task-flow/node_modules/zod/v4/locales/es.d.cts +0 -5
  662. package/toolkit/skills/multi-task-flow/node_modules/zod/v4/locales/es.d.ts +0 -4
  663. package/toolkit/skills/multi-task-flow/node_modules/zod/v4/locales/es.js +0 -136
  664. package/toolkit/skills/multi-task-flow/node_modules/zod/v4/locales/fa.cjs +0 -146
  665. package/toolkit/skills/multi-task-flow/node_modules/zod/v4/locales/fa.d.cts +0 -5
  666. package/toolkit/skills/multi-task-flow/node_modules/zod/v4/locales/fa.d.ts +0 -4
  667. package/toolkit/skills/multi-task-flow/node_modules/zod/v4/locales/fa.js +0 -119
  668. package/toolkit/skills/multi-task-flow/node_modules/zod/v4/locales/fi.cjs +0 -144
  669. package/toolkit/skills/multi-task-flow/node_modules/zod/v4/locales/fi.d.cts +0 -5
  670. package/toolkit/skills/multi-task-flow/node_modules/zod/v4/locales/fi.d.ts +0 -4
  671. package/toolkit/skills/multi-task-flow/node_modules/zod/v4/locales/fi.js +0 -117
  672. package/toolkit/skills/multi-task-flow/node_modules/zod/v4/locales/fr-CA.cjs +0 -139
  673. package/toolkit/skills/multi-task-flow/node_modules/zod/v4/locales/fr-CA.d.cts +0 -5
  674. package/toolkit/skills/multi-task-flow/node_modules/zod/v4/locales/fr-CA.d.ts +0 -4
  675. package/toolkit/skills/multi-task-flow/node_modules/zod/v4/locales/fr-CA.js +0 -112
  676. package/toolkit/skills/multi-task-flow/node_modules/zod/v4/locales/fr.cjs +0 -156
  677. package/toolkit/skills/multi-task-flow/node_modules/zod/v4/locales/fr.d.cts +0 -5
  678. package/toolkit/skills/multi-task-flow/node_modules/zod/v4/locales/fr.d.ts +0 -4
  679. package/toolkit/skills/multi-task-flow/node_modules/zod/v4/locales/fr.js +0 -129
  680. package/toolkit/skills/multi-task-flow/node_modules/zod/v4/locales/gu.cjs +0 -140
  681. package/toolkit/skills/multi-task-flow/node_modules/zod/v4/locales/gu.d.cts +0 -5
  682. package/toolkit/skills/multi-task-flow/node_modules/zod/v4/locales/gu.d.ts +0 -4
  683. package/toolkit/skills/multi-task-flow/node_modules/zod/v4/locales/gu.js +0 -113
  684. package/toolkit/skills/multi-task-flow/node_modules/zod/v4/locales/he.cjs +0 -248
  685. package/toolkit/skills/multi-task-flow/node_modules/zod/v4/locales/he.d.cts +0 -5
  686. package/toolkit/skills/multi-task-flow/node_modules/zod/v4/locales/he.d.ts +0 -4
  687. package/toolkit/skills/multi-task-flow/node_modules/zod/v4/locales/he.js +0 -221
  688. package/toolkit/skills/multi-task-flow/node_modules/zod/v4/locales/hi.cjs +0 -138
  689. package/toolkit/skills/multi-task-flow/node_modules/zod/v4/locales/hi.d.cts +0 -5
  690. package/toolkit/skills/multi-task-flow/node_modules/zod/v4/locales/hi.d.ts +0 -4
  691. package/toolkit/skills/multi-task-flow/node_modules/zod/v4/locales/hi.js +0 -111
  692. package/toolkit/skills/multi-task-flow/node_modules/zod/v4/locales/hr.cjs +0 -153
  693. package/toolkit/skills/multi-task-flow/node_modules/zod/v4/locales/hr.d.cts +0 -5
  694. package/toolkit/skills/multi-task-flow/node_modules/zod/v4/locales/hr.d.ts +0 -4
  695. package/toolkit/skills/multi-task-flow/node_modules/zod/v4/locales/hr.js +0 -126
  696. package/toolkit/skills/multi-task-flow/node_modules/zod/v4/locales/hu.cjs +0 -140
  697. package/toolkit/skills/multi-task-flow/node_modules/zod/v4/locales/hu.d.cts +0 -5
  698. package/toolkit/skills/multi-task-flow/node_modules/zod/v4/locales/hu.d.ts +0 -4
  699. package/toolkit/skills/multi-task-flow/node_modules/zod/v4/locales/hu.js +0 -113
  700. package/toolkit/skills/multi-task-flow/node_modules/zod/v4/locales/hy.cjs +0 -185
  701. package/toolkit/skills/multi-task-flow/node_modules/zod/v4/locales/hy.d.cts +0 -5
  702. package/toolkit/skills/multi-task-flow/node_modules/zod/v4/locales/hy.d.ts +0 -4
  703. package/toolkit/skills/multi-task-flow/node_modules/zod/v4/locales/hy.js +0 -158
  704. package/toolkit/skills/multi-task-flow/node_modules/zod/v4/locales/id.cjs +0 -138
  705. package/toolkit/skills/multi-task-flow/node_modules/zod/v4/locales/id.d.cts +0 -5
  706. package/toolkit/skills/multi-task-flow/node_modules/zod/v4/locales/id.d.ts +0 -4
  707. package/toolkit/skills/multi-task-flow/node_modules/zod/v4/locales/id.js +0 -111
  708. package/toolkit/skills/multi-task-flow/node_modules/zod/v4/locales/index.cjs +0 -152
  709. package/toolkit/skills/multi-task-flow/node_modules/zod/v4/locales/index.d.cts +0 -63
  710. package/toolkit/skills/multi-task-flow/node_modules/zod/v4/locales/index.d.ts +0 -63
  711. package/toolkit/skills/multi-task-flow/node_modules/zod/v4/locales/index.js +0 -63
  712. package/toolkit/skills/multi-task-flow/node_modules/zod/v4/locales/is.cjs +0 -141
  713. package/toolkit/skills/multi-task-flow/node_modules/zod/v4/locales/is.d.cts +0 -5
  714. package/toolkit/skills/multi-task-flow/node_modules/zod/v4/locales/is.d.ts +0 -4
  715. package/toolkit/skills/multi-task-flow/node_modules/zod/v4/locales/is.js +0 -114
  716. package/toolkit/skills/multi-task-flow/node_modules/zod/v4/locales/it.cjs +0 -140
  717. package/toolkit/skills/multi-task-flow/node_modules/zod/v4/locales/it.d.cts +0 -5
  718. package/toolkit/skills/multi-task-flow/node_modules/zod/v4/locales/it.d.ts +0 -4
  719. package/toolkit/skills/multi-task-flow/node_modules/zod/v4/locales/it.js +0 -113
  720. package/toolkit/skills/multi-task-flow/node_modules/zod/v4/locales/ja.cjs +0 -139
  721. package/toolkit/skills/multi-task-flow/node_modules/zod/v4/locales/ja.d.cts +0 -5
  722. package/toolkit/skills/multi-task-flow/node_modules/zod/v4/locales/ja.d.ts +0 -4
  723. package/toolkit/skills/multi-task-flow/node_modules/zod/v4/locales/ja.js +0 -112
  724. package/toolkit/skills/multi-task-flow/node_modules/zod/v4/locales/ka.cjs +0 -144
  725. package/toolkit/skills/multi-task-flow/node_modules/zod/v4/locales/ka.d.cts +0 -5
  726. package/toolkit/skills/multi-task-flow/node_modules/zod/v4/locales/ka.d.ts +0 -4
  727. package/toolkit/skills/multi-task-flow/node_modules/zod/v4/locales/ka.js +0 -117
  728. package/toolkit/skills/multi-task-flow/node_modules/zod/v4/locales/kh.cjs +0 -12
  729. package/toolkit/skills/multi-task-flow/node_modules/zod/v4/locales/kh.d.cts +0 -5
  730. package/toolkit/skills/multi-task-flow/node_modules/zod/v4/locales/kh.d.ts +0 -5
  731. package/toolkit/skills/multi-task-flow/node_modules/zod/v4/locales/kh.js +0 -5
  732. package/toolkit/skills/multi-task-flow/node_modules/zod/v4/locales/km.cjs +0 -142
  733. package/toolkit/skills/multi-task-flow/node_modules/zod/v4/locales/km.d.cts +0 -5
  734. package/toolkit/skills/multi-task-flow/node_modules/zod/v4/locales/km.d.ts +0 -4
  735. package/toolkit/skills/multi-task-flow/node_modules/zod/v4/locales/km.js +0 -115
  736. package/toolkit/skills/multi-task-flow/node_modules/zod/v4/locales/kn.cjs +0 -143
  737. package/toolkit/skills/multi-task-flow/node_modules/zod/v4/locales/kn.d.cts +0 -5
  738. package/toolkit/skills/multi-task-flow/node_modules/zod/v4/locales/kn.d.ts +0 -4
  739. package/toolkit/skills/multi-task-flow/node_modules/zod/v4/locales/kn.js +0 -116
  740. package/toolkit/skills/multi-task-flow/node_modules/zod/v4/locales/ko.cjs +0 -143
  741. package/toolkit/skills/multi-task-flow/node_modules/zod/v4/locales/ko.d.cts +0 -5
  742. package/toolkit/skills/multi-task-flow/node_modules/zod/v4/locales/ko.d.ts +0 -4
  743. package/toolkit/skills/multi-task-flow/node_modules/zod/v4/locales/ko.js +0 -116
  744. package/toolkit/skills/multi-task-flow/node_modules/zod/v4/locales/lt.cjs +0 -234
  745. package/toolkit/skills/multi-task-flow/node_modules/zod/v4/locales/lt.d.cts +0 -5
  746. package/toolkit/skills/multi-task-flow/node_modules/zod/v4/locales/lt.d.ts +0 -4
  747. package/toolkit/skills/multi-task-flow/node_modules/zod/v4/locales/lt.js +0 -207
  748. package/toolkit/skills/multi-task-flow/node_modules/zod/v4/locales/mk.cjs +0 -141
  749. package/toolkit/skills/multi-task-flow/node_modules/zod/v4/locales/mk.d.cts +0 -5
  750. package/toolkit/skills/multi-task-flow/node_modules/zod/v4/locales/mk.d.ts +0 -4
  751. package/toolkit/skills/multi-task-flow/node_modules/zod/v4/locales/mk.js +0 -114
  752. package/toolkit/skills/multi-task-flow/node_modules/zod/v4/locales/ms.cjs +0 -139
  753. package/toolkit/skills/multi-task-flow/node_modules/zod/v4/locales/ms.d.cts +0 -5
  754. package/toolkit/skills/multi-task-flow/node_modules/zod/v4/locales/ms.d.ts +0 -4
  755. package/toolkit/skills/multi-task-flow/node_modules/zod/v4/locales/ms.js +0 -112
  756. package/toolkit/skills/multi-task-flow/node_modules/zod/v4/locales/ne.cjs +0 -138
  757. package/toolkit/skills/multi-task-flow/node_modules/zod/v4/locales/ne.d.cts +0 -5
  758. package/toolkit/skills/multi-task-flow/node_modules/zod/v4/locales/ne.d.ts +0 -4
  759. package/toolkit/skills/multi-task-flow/node_modules/zod/v4/locales/ne.js +0 -111
  760. package/toolkit/skills/multi-task-flow/node_modules/zod/v4/locales/nl.cjs +0 -142
  761. package/toolkit/skills/multi-task-flow/node_modules/zod/v4/locales/nl.d.cts +0 -5
  762. package/toolkit/skills/multi-task-flow/node_modules/zod/v4/locales/nl.d.ts +0 -4
  763. package/toolkit/skills/multi-task-flow/node_modules/zod/v4/locales/nl.js +0 -115
  764. package/toolkit/skills/multi-task-flow/node_modules/zod/v4/locales/nn.cjs +0 -140
  765. package/toolkit/skills/multi-task-flow/node_modules/zod/v4/locales/nn.d.cts +0 -5
  766. package/toolkit/skills/multi-task-flow/node_modules/zod/v4/locales/nn.d.ts +0 -4
  767. package/toolkit/skills/multi-task-flow/node_modules/zod/v4/locales/nn.js +0 -113
  768. package/toolkit/skills/multi-task-flow/node_modules/zod/v4/locales/no.cjs +0 -140
  769. package/toolkit/skills/multi-task-flow/node_modules/zod/v4/locales/no.d.cts +0 -5
  770. package/toolkit/skills/multi-task-flow/node_modules/zod/v4/locales/no.d.ts +0 -4
  771. package/toolkit/skills/multi-task-flow/node_modules/zod/v4/locales/no.js +0 -113
  772. package/toolkit/skills/multi-task-flow/node_modules/zod/v4/locales/ota.cjs +0 -141
  773. package/toolkit/skills/multi-task-flow/node_modules/zod/v4/locales/ota.d.cts +0 -5
  774. package/toolkit/skills/multi-task-flow/node_modules/zod/v4/locales/ota.d.ts +0 -4
  775. package/toolkit/skills/multi-task-flow/node_modules/zod/v4/locales/ota.js +0 -114
  776. package/toolkit/skills/multi-task-flow/node_modules/zod/v4/locales/package.json +0 -7
  777. package/toolkit/skills/multi-task-flow/node_modules/zod/v4/locales/pl.cjs +0 -141
  778. package/toolkit/skills/multi-task-flow/node_modules/zod/v4/locales/pl.d.cts +0 -5
  779. package/toolkit/skills/multi-task-flow/node_modules/zod/v4/locales/pl.d.ts +0 -4
  780. package/toolkit/skills/multi-task-flow/node_modules/zod/v4/locales/pl.js +0 -114
  781. package/toolkit/skills/multi-task-flow/node_modules/zod/v4/locales/ps.cjs +0 -146
  782. package/toolkit/skills/multi-task-flow/node_modules/zod/v4/locales/ps.d.cts +0 -5
  783. package/toolkit/skills/multi-task-flow/node_modules/zod/v4/locales/ps.d.ts +0 -4
  784. package/toolkit/skills/multi-task-flow/node_modules/zod/v4/locales/ps.js +0 -119
  785. package/toolkit/skills/multi-task-flow/node_modules/zod/v4/locales/pt-BR.cjs +0 -170
  786. package/toolkit/skills/multi-task-flow/node_modules/zod/v4/locales/pt-BR.d.cts +0 -5
  787. package/toolkit/skills/multi-task-flow/node_modules/zod/v4/locales/pt-BR.d.ts +0 -4
  788. package/toolkit/skills/multi-task-flow/node_modules/zod/v4/locales/pt-BR.js +0 -143
  789. package/toolkit/skills/multi-task-flow/node_modules/zod/v4/locales/pt.cjs +0 -169
  790. package/toolkit/skills/multi-task-flow/node_modules/zod/v4/locales/pt.d.cts +0 -5
  791. package/toolkit/skills/multi-task-flow/node_modules/zod/v4/locales/pt.d.ts +0 -4
  792. package/toolkit/skills/multi-task-flow/node_modules/zod/v4/locales/pt.js +0 -142
  793. package/toolkit/skills/multi-task-flow/node_modules/zod/v4/locales/ro.cjs +0 -149
  794. package/toolkit/skills/multi-task-flow/node_modules/zod/v4/locales/ro.d.cts +0 -5
  795. package/toolkit/skills/multi-task-flow/node_modules/zod/v4/locales/ro.d.ts +0 -4
  796. package/toolkit/skills/multi-task-flow/node_modules/zod/v4/locales/ro.js +0 -122
  797. package/toolkit/skills/multi-task-flow/node_modules/zod/v4/locales/ru.cjs +0 -195
  798. package/toolkit/skills/multi-task-flow/node_modules/zod/v4/locales/ru.d.cts +0 -5
  799. package/toolkit/skills/multi-task-flow/node_modules/zod/v4/locales/ru.d.ts +0 -4
  800. package/toolkit/skills/multi-task-flow/node_modules/zod/v4/locales/ru.js +0 -168
  801. package/toolkit/skills/multi-task-flow/node_modules/zod/v4/locales/sk.cjs +0 -143
  802. package/toolkit/skills/multi-task-flow/node_modules/zod/v4/locales/sk.d.cts +0 -5
  803. package/toolkit/skills/multi-task-flow/node_modules/zod/v4/locales/sk.d.ts +0 -4
  804. package/toolkit/skills/multi-task-flow/node_modules/zod/v4/locales/sk.js +0 -116
  805. package/toolkit/skills/multi-task-flow/node_modules/zod/v4/locales/sl.cjs +0 -141
  806. package/toolkit/skills/multi-task-flow/node_modules/zod/v4/locales/sl.d.cts +0 -5
  807. package/toolkit/skills/multi-task-flow/node_modules/zod/v4/locales/sl.d.ts +0 -4
  808. package/toolkit/skills/multi-task-flow/node_modules/zod/v4/locales/sl.js +0 -114
  809. package/toolkit/skills/multi-task-flow/node_modules/zod/v4/locales/sv.cjs +0 -142
  810. package/toolkit/skills/multi-task-flow/node_modules/zod/v4/locales/sv.d.cts +0 -5
  811. package/toolkit/skills/multi-task-flow/node_modules/zod/v4/locales/sv.d.ts +0 -4
  812. package/toolkit/skills/multi-task-flow/node_modules/zod/v4/locales/sv.js +0 -115
  813. package/toolkit/skills/multi-task-flow/node_modules/zod/v4/locales/ta.cjs +0 -142
  814. package/toolkit/skills/multi-task-flow/node_modules/zod/v4/locales/ta.d.cts +0 -5
  815. package/toolkit/skills/multi-task-flow/node_modules/zod/v4/locales/ta.d.ts +0 -4
  816. package/toolkit/skills/multi-task-flow/node_modules/zod/v4/locales/ta.js +0 -115
  817. package/toolkit/skills/multi-task-flow/node_modules/zod/v4/locales/tg.cjs +0 -144
  818. package/toolkit/skills/multi-task-flow/node_modules/zod/v4/locales/tg.d.cts +0 -5
  819. package/toolkit/skills/multi-task-flow/node_modules/zod/v4/locales/tg.d.ts +0 -4
  820. package/toolkit/skills/multi-task-flow/node_modules/zod/v4/locales/tg.js +0 -117
  821. package/toolkit/skills/multi-task-flow/node_modules/zod/v4/locales/th.cjs +0 -142
  822. package/toolkit/skills/multi-task-flow/node_modules/zod/v4/locales/th.d.cts +0 -5
  823. package/toolkit/skills/multi-task-flow/node_modules/zod/v4/locales/th.d.ts +0 -4
  824. package/toolkit/skills/multi-task-flow/node_modules/zod/v4/locales/th.js +0 -115
  825. package/toolkit/skills/multi-task-flow/node_modules/zod/v4/locales/tk.cjs +0 -134
  826. package/toolkit/skills/multi-task-flow/node_modules/zod/v4/locales/tk.d.cts +0 -5
  827. package/toolkit/skills/multi-task-flow/node_modules/zod/v4/locales/tk.d.ts +0 -4
  828. package/toolkit/skills/multi-task-flow/node_modules/zod/v4/locales/tk.js +0 -107
  829. package/toolkit/skills/multi-task-flow/node_modules/zod/v4/locales/tr.cjs +0 -137
  830. package/toolkit/skills/multi-task-flow/node_modules/zod/v4/locales/tr.d.cts +0 -5
  831. package/toolkit/skills/multi-task-flow/node_modules/zod/v4/locales/tr.d.ts +0 -4
  832. package/toolkit/skills/multi-task-flow/node_modules/zod/v4/locales/tr.js +0 -110
  833. package/toolkit/skills/multi-task-flow/node_modules/zod/v4/locales/ua.cjs +0 -12
  834. package/toolkit/skills/multi-task-flow/node_modules/zod/v4/locales/ua.d.cts +0 -5
  835. package/toolkit/skills/multi-task-flow/node_modules/zod/v4/locales/ua.d.ts +0 -5
  836. package/toolkit/skills/multi-task-flow/node_modules/zod/v4/locales/ua.js +0 -5
  837. package/toolkit/skills/multi-task-flow/node_modules/zod/v4/locales/uk.cjs +0 -140
  838. package/toolkit/skills/multi-task-flow/node_modules/zod/v4/locales/uk.d.cts +0 -5
  839. package/toolkit/skills/multi-task-flow/node_modules/zod/v4/locales/uk.d.ts +0 -4
  840. package/toolkit/skills/multi-task-flow/node_modules/zod/v4/locales/uk.js +0 -113
  841. package/toolkit/skills/multi-task-flow/node_modules/zod/v4/locales/ur.cjs +0 -142
  842. package/toolkit/skills/multi-task-flow/node_modules/zod/v4/locales/ur.d.cts +0 -5
  843. package/toolkit/skills/multi-task-flow/node_modules/zod/v4/locales/ur.d.ts +0 -4
  844. package/toolkit/skills/multi-task-flow/node_modules/zod/v4/locales/ur.js +0 -115
  845. package/toolkit/skills/multi-task-flow/node_modules/zod/v4/locales/uz.cjs +0 -140
  846. package/toolkit/skills/multi-task-flow/node_modules/zod/v4/locales/uz.d.cts +0 -5
  847. package/toolkit/skills/multi-task-flow/node_modules/zod/v4/locales/uz.d.ts +0 -4
  848. package/toolkit/skills/multi-task-flow/node_modules/zod/v4/locales/uz.js +0 -113
  849. package/toolkit/skills/multi-task-flow/node_modules/zod/v4/locales/vi.cjs +0 -140
  850. package/toolkit/skills/multi-task-flow/node_modules/zod/v4/locales/vi.d.cts +0 -5
  851. package/toolkit/skills/multi-task-flow/node_modules/zod/v4/locales/vi.d.ts +0 -4
  852. package/toolkit/skills/multi-task-flow/node_modules/zod/v4/locales/vi.js +0 -113
  853. package/toolkit/skills/multi-task-flow/node_modules/zod/v4/locales/yo.cjs +0 -139
  854. package/toolkit/skills/multi-task-flow/node_modules/zod/v4/locales/yo.d.cts +0 -5
  855. package/toolkit/skills/multi-task-flow/node_modules/zod/v4/locales/yo.d.ts +0 -4
  856. package/toolkit/skills/multi-task-flow/node_modules/zod/v4/locales/yo.js +0 -112
  857. package/toolkit/skills/multi-task-flow/node_modules/zod/v4/locales/zh-CN.cjs +0 -141
  858. package/toolkit/skills/multi-task-flow/node_modules/zod/v4/locales/zh-CN.d.cts +0 -5
  859. package/toolkit/skills/multi-task-flow/node_modules/zod/v4/locales/zh-CN.d.ts +0 -4
  860. package/toolkit/skills/multi-task-flow/node_modules/zod/v4/locales/zh-CN.js +0 -114
  861. package/toolkit/skills/multi-task-flow/node_modules/zod/v4/locales/zh-TW.cjs +0 -139
  862. package/toolkit/skills/multi-task-flow/node_modules/zod/v4/locales/zh-TW.d.cts +0 -5
  863. package/toolkit/skills/multi-task-flow/node_modules/zod/v4/locales/zh-TW.d.ts +0 -4
  864. package/toolkit/skills/multi-task-flow/node_modules/zod/v4/locales/zh-TW.js +0 -112
  865. package/toolkit/skills/multi-task-flow/node_modules/zod/v4/mini/checks.cjs +0 -54
  866. package/toolkit/skills/multi-task-flow/node_modules/zod/v4/mini/checks.d.cts +0 -1
  867. package/toolkit/skills/multi-task-flow/node_modules/zod/v4/mini/checks.d.ts +0 -1
  868. package/toolkit/skills/multi-task-flow/node_modules/zod/v4/mini/checks.js +0 -1
  869. package/toolkit/skills/multi-task-flow/node_modules/zod/v4/mini/coerce.cjs +0 -71
  870. package/toolkit/skills/multi-task-flow/node_modules/zod/v4/mini/coerce.d.cts +0 -7
  871. package/toolkit/skills/multi-task-flow/node_modules/zod/v4/mini/coerce.d.ts +0 -7
  872. package/toolkit/skills/multi-task-flow/node_modules/zod/v4/mini/coerce.js +0 -22
  873. package/toolkit/skills/multi-task-flow/node_modules/zod/v4/mini/deep-partial.cjs +0 -58
  874. package/toolkit/skills/multi-task-flow/node_modules/zod/v4/mini/deep-partial.d.cts +0 -14
  875. package/toolkit/skills/multi-task-flow/node_modules/zod/v4/mini/deep-partial.d.ts +0 -14
  876. package/toolkit/skills/multi-task-flow/node_modules/zod/v4/mini/deep-partial.js +0 -13
  877. package/toolkit/skills/multi-task-flow/node_modules/zod/v4/mini/external.cjs +0 -95
  878. package/toolkit/skills/multi-task-flow/node_modules/zod/v4/mini/external.d.cts +0 -16
  879. package/toolkit/skills/multi-task-flow/node_modules/zod/v4/mini/external.d.ts +0 -16
  880. package/toolkit/skills/multi-task-flow/node_modules/zod/v4/mini/external.js +0 -16
  881. package/toolkit/skills/multi-task-flow/node_modules/zod/v4/mini/in-out.cjs +0 -82
  882. package/toolkit/skills/multi-task-flow/node_modules/zod/v4/mini/in-out.d.cts +0 -8
  883. package/toolkit/skills/multi-task-flow/node_modules/zod/v4/mini/in-out.d.ts +0 -8
  884. package/toolkit/skills/multi-task-flow/node_modules/zod/v4/mini/in-out.js +0 -36
  885. package/toolkit/skills/multi-task-flow/node_modules/zod/v4/mini/index.cjs +0 -51
  886. package/toolkit/skills/multi-task-flow/node_modules/zod/v4/mini/index.d.cts +0 -3
  887. package/toolkit/skills/multi-task-flow/node_modules/zod/v4/mini/index.d.ts +0 -3
  888. package/toolkit/skills/multi-task-flow/node_modules/zod/v4/mini/index.js +0 -3
  889. package/toolkit/skills/multi-task-flow/node_modules/zod/v4/mini/iso.cjs +0 -83
  890. package/toolkit/skills/multi-task-flow/node_modules/zod/v4/mini/iso.d.cts +0 -22
  891. package/toolkit/skills/multi-task-flow/node_modules/zod/v4/mini/iso.d.ts +0 -22
  892. package/toolkit/skills/multi-task-flow/node_modules/zod/v4/mini/iso.js +0 -34
  893. package/toolkit/skills/multi-task-flow/node_modules/zod/v4/mini/package.json +0 -7
  894. package/toolkit/skills/multi-task-flow/node_modules/zod/v4/mini/parse.cjs +0 -37
  895. package/toolkit/skills/multi-task-flow/node_modules/zod/v4/mini/parse.d.cts +0 -1
  896. package/toolkit/skills/multi-task-flow/node_modules/zod/v4/mini/parse.d.ts +0 -1
  897. package/toolkit/skills/multi-task-flow/node_modules/zod/v4/mini/parse.js +0 -1
  898. package/toolkit/skills/multi-task-flow/node_modules/zod/v4/mini/schemas.cjs +0 -1147
  899. package/toolkit/skills/multi-task-flow/node_modules/zod/v4/mini/schemas.d.cts +0 -480
  900. package/toolkit/skills/multi-task-flow/node_modules/zod/v4/mini/schemas.d.ts +0 -480
  901. package/toolkit/skills/multi-task-flow/node_modules/zod/v4/mini/schemas.js +0 -1002
  902. package/toolkit/skills/multi-task-flow/node_modules/zod/v4/package.json +0 -7
  903. package/toolkit/skills/multi-task-flow/node_modules/zod/v4-mini/index.cjs +0 -51
  904. package/toolkit/skills/multi-task-flow/node_modules/zod/v4-mini/index.d.cts +0 -3
  905. package/toolkit/skills/multi-task-flow/node_modules/zod/v4-mini/index.d.ts +0 -3
  906. package/toolkit/skills/multi-task-flow/node_modules/zod/v4-mini/index.js +0 -3
  907. package/toolkit/skills/multi-task-flow/node_modules/zod/v4-mini/package.json +0 -7
  908. package/toolkit/skills/multi-task-flow/scripts/serve.ts +0 -218
  909. package/toolkit/skills/multi-task-flow/tests/serve.test.ts +0 -194
  910. package/toolkit/skills/node_modules/@img/colour/LICENSE.md +0 -82
  911. package/toolkit/skills/node_modules/@img/colour/README.md +0 -15
  912. package/toolkit/skills/node_modules/@img/colour/color.cjs +0 -1596
  913. package/toolkit/skills/node_modules/@img/colour/index.cjs +0 -1
  914. package/toolkit/skills/node_modules/@img/colour/index.d.ts +0 -929
  915. package/toolkit/skills/node_modules/@img/colour/package.json +0 -58
  916. package/toolkit/skills/node_modules/@img/sharp-libvips-linux-x64/README.md +0 -46
  917. package/toolkit/skills/node_modules/@img/sharp-libvips-linux-x64/lib/glib-2.0/include/glibconfig.h +0 -219
  918. package/toolkit/skills/node_modules/@img/sharp-libvips-linux-x64/lib/index.js +0 -1
  919. package/toolkit/skills/node_modules/@img/sharp-libvips-linux-x64/lib/libvips-cpp.so.8.18.7 +0 -0
  920. package/toolkit/skills/node_modules/@img/sharp-libvips-linux-x64/package.json +0 -43
  921. package/toolkit/skills/node_modules/@img/sharp-libvips-linux-x64/versions.json +0 -30
  922. package/toolkit/skills/node_modules/@img/sharp-libvips-linuxmusl-x64/README.md +0 -46
  923. package/toolkit/skills/node_modules/@img/sharp-libvips-linuxmusl-x64/lib/glib-2.0/include/glibconfig.h +0 -219
  924. package/toolkit/skills/node_modules/@img/sharp-libvips-linuxmusl-x64/lib/index.js +0 -1
  925. package/toolkit/skills/node_modules/@img/sharp-libvips-linuxmusl-x64/lib/libvips-cpp.so.8.18.7 +0 -0
  926. package/toolkit/skills/node_modules/@img/sharp-libvips-linuxmusl-x64/package.json +0 -43
  927. package/toolkit/skills/node_modules/@img/sharp-libvips-linuxmusl-x64/versions.json +0 -30
  928. package/toolkit/skills/node_modules/@img/sharp-linux-x64/LICENSE +0 -191
  929. package/toolkit/skills/node_modules/@img/sharp-linux-x64/README.md +0 -18
  930. package/toolkit/skills/node_modules/@img/sharp-linux-x64/index.cjs +0 -2
  931. package/toolkit/skills/node_modules/@img/sharp-linux-x64/lib/sharp-linux-x64-0.35.5.node +0 -0
  932. package/toolkit/skills/node_modules/@img/sharp-linux-x64/package.json +0 -47
  933. package/toolkit/skills/node_modules/@img/sharp-linuxmusl-x64/LICENSE +0 -191
  934. package/toolkit/skills/node_modules/@img/sharp-linuxmusl-x64/README.md +0 -18
  935. package/toolkit/skills/node_modules/@img/sharp-linuxmusl-x64/index.cjs +0 -2
  936. package/toolkit/skills/node_modules/@img/sharp-linuxmusl-x64/lib/sharp-linuxmusl-x64-0.35.5.node +0 -0
  937. package/toolkit/skills/node_modules/@img/sharp-linuxmusl-x64/package.json +0 -47
  938. package/toolkit/skills/node_modules/detect-libc/LICENSE +0 -201
  939. package/toolkit/skills/node_modules/detect-libc/README.md +0 -163
  940. package/toolkit/skills/node_modules/detect-libc/index.d.ts +0 -14
  941. package/toolkit/skills/node_modules/detect-libc/lib/detect-libc.js +0 -313
  942. package/toolkit/skills/node_modules/detect-libc/lib/elf.js +0 -39
  943. package/toolkit/skills/node_modules/detect-libc/lib/filesystem.js +0 -51
  944. package/toolkit/skills/node_modules/detect-libc/lib/process.js +0 -24
  945. package/toolkit/skills/node_modules/detect-libc/package.json +0 -44
  946. package/toolkit/skills/node_modules/semver/LICENSE +0 -15
  947. package/toolkit/skills/node_modules/semver/README.md +0 -680
  948. package/toolkit/skills/node_modules/semver/bin/semver.js +0 -195
  949. package/toolkit/skills/node_modules/semver/classes/comparator.js +0 -143
  950. package/toolkit/skills/node_modules/semver/classes/index.js +0 -7
  951. package/toolkit/skills/node_modules/semver/classes/range.js +0 -577
  952. package/toolkit/skills/node_modules/semver/classes/semver.js +0 -350
  953. package/toolkit/skills/node_modules/semver/functions/clean.js +0 -8
  954. package/toolkit/skills/node_modules/semver/functions/cmp.js +0 -54
  955. package/toolkit/skills/node_modules/semver/functions/coerce.js +0 -62
  956. package/toolkit/skills/node_modules/semver/functions/compare-build.js +0 -9
  957. package/toolkit/skills/node_modules/semver/functions/compare-loose.js +0 -5
  958. package/toolkit/skills/node_modules/semver/functions/compare.js +0 -7
  959. package/toolkit/skills/node_modules/semver/functions/diff.js +0 -60
  960. package/toolkit/skills/node_modules/semver/functions/eq.js +0 -5
  961. package/toolkit/skills/node_modules/semver/functions/gt.js +0 -5
  962. package/toolkit/skills/node_modules/semver/functions/gte.js +0 -5
  963. package/toolkit/skills/node_modules/semver/functions/inc.js +0 -21
  964. package/toolkit/skills/node_modules/semver/functions/lt.js +0 -5
  965. package/toolkit/skills/node_modules/semver/functions/lte.js +0 -5
  966. package/toolkit/skills/node_modules/semver/functions/major.js +0 -5
  967. package/toolkit/skills/node_modules/semver/functions/minor.js +0 -5
  968. package/toolkit/skills/node_modules/semver/functions/neq.js +0 -5
  969. package/toolkit/skills/node_modules/semver/functions/parse.js +0 -18
  970. package/toolkit/skills/node_modules/semver/functions/patch.js +0 -5
  971. package/toolkit/skills/node_modules/semver/functions/prerelease.js +0 -8
  972. package/toolkit/skills/node_modules/semver/functions/rcompare.js +0 -5
  973. package/toolkit/skills/node_modules/semver/functions/rsort.js +0 -5
  974. package/toolkit/skills/node_modules/semver/functions/satisfies.js +0 -12
  975. package/toolkit/skills/node_modules/semver/functions/sort.js +0 -5
  976. package/toolkit/skills/node_modules/semver/functions/truncate.js +0 -48
  977. package/toolkit/skills/node_modules/semver/functions/valid.js +0 -8
  978. package/toolkit/skills/node_modules/semver/index.js +0 -93
  979. package/toolkit/skills/node_modules/semver/internal/constants.js +0 -67
  980. package/toolkit/skills/node_modules/semver/internal/debug.js +0 -11
  981. package/toolkit/skills/node_modules/semver/internal/identifiers.js +0 -29
  982. package/toolkit/skills/node_modules/semver/internal/lrucache.js +0 -42
  983. package/toolkit/skills/node_modules/semver/internal/parse-options.js +0 -17
  984. package/toolkit/skills/node_modules/semver/internal/re.js +0 -223
  985. package/toolkit/skills/node_modules/semver/internal/trim-comparator-whitespace.js +0 -438
  986. package/toolkit/skills/node_modules/semver/package.json +0 -78
  987. package/toolkit/skills/node_modules/semver/preload.js +0 -4
  988. package/toolkit/skills/node_modules/semver/range.bnf +0 -17
  989. package/toolkit/skills/node_modules/semver/ranges/gtr.js +0 -6
  990. package/toolkit/skills/node_modules/semver/ranges/intersects.js +0 -9
  991. package/toolkit/skills/node_modules/semver/ranges/ltr.js +0 -6
  992. package/toolkit/skills/node_modules/semver/ranges/max-satisfying.js +0 -27
  993. package/toolkit/skills/node_modules/semver/ranges/min-satisfying.js +0 -26
  994. package/toolkit/skills/node_modules/semver/ranges/min-version.js +0 -63
  995. package/toolkit/skills/node_modules/semver/ranges/outside.js +0 -82
  996. package/toolkit/skills/node_modules/semver/ranges/simplify.js +0 -49
  997. package/toolkit/skills/node_modules/semver/ranges/subset.js +0 -249
  998. package/toolkit/skills/node_modules/semver/ranges/to-comparators.js +0 -10
  999. package/toolkit/skills/node_modules/semver/ranges/valid.js +0 -13
  1000. package/toolkit/skills/node_modules/sharp/LICENSE +0 -191
  1001. package/toolkit/skills/node_modules/sharp/README.md +0 -112
  1002. package/toolkit/skills/node_modules/sharp/dist/channel.cjs +0 -177
  1003. package/toolkit/skills/node_modules/sharp/dist/channel.mjs +0 -177
  1004. package/toolkit/skills/node_modules/sharp/dist/colour.cjs +0 -199
  1005. package/toolkit/skills/node_modules/sharp/dist/colour.mjs +0 -199
  1006. package/toolkit/skills/node_modules/sharp/dist/composite.cjs +0 -213
  1007. package/toolkit/skills/node_modules/sharp/dist/composite.mjs +0 -213
  1008. package/toolkit/skills/node_modules/sharp/dist/constructor.cjs +0 -511
  1009. package/toolkit/skills/node_modules/sharp/dist/constructor.mjs +0 -511
  1010. package/toolkit/skills/node_modules/sharp/dist/index.cjs +0 -25
  1011. package/toolkit/skills/node_modules/sharp/dist/index.d.cts +0 -1999
  1012. package/toolkit/skills/node_modules/sharp/dist/index.d.mts +0 -2046
  1013. package/toolkit/skills/node_modules/sharp/dist/index.mjs +0 -25
  1014. package/toolkit/skills/node_modules/sharp/dist/input.cjs +0 -819
  1015. package/toolkit/skills/node_modules/sharp/dist/input.mjs +0 -819
  1016. package/toolkit/skills/node_modules/sharp/dist/is.cjs +0 -149
  1017. package/toolkit/skills/node_modules/sharp/dist/is.mjs +0 -149
  1018. package/toolkit/skills/node_modules/sharp/dist/libvips.cjs +0 -212
  1019. package/toolkit/skills/node_modules/sharp/dist/libvips.mjs +0 -212
  1020. package/toolkit/skills/node_modules/sharp/dist/operation.cjs +0 -1002
  1021. package/toolkit/skills/node_modules/sharp/dist/operation.mjs +0 -1002
  1022. package/toolkit/skills/node_modules/sharp/dist/output.cjs +0 -1786
  1023. package/toolkit/skills/node_modules/sharp/dist/output.mjs +0 -1786
  1024. package/toolkit/skills/node_modules/sharp/dist/resize.cjs +0 -617
  1025. package/toolkit/skills/node_modules/sharp/dist/resize.mjs +0 -617
  1026. package/toolkit/skills/node_modules/sharp/dist/sharp.cjs +0 -174
  1027. package/toolkit/skills/node_modules/sharp/dist/sharp.mjs +0 -174
  1028. package/toolkit/skills/node_modules/sharp/dist/utility.cjs +0 -301
  1029. package/toolkit/skills/node_modules/sharp/dist/utility.mjs +0 -301
  1030. package/toolkit/skills/node_modules/sharp/install/build.js +0 -38
  1031. package/toolkit/skills/node_modules/sharp/lib/index.d.ts +0 -1999
  1032. package/toolkit/skills/node_modules/sharp/package.json +0 -227
  1033. package/toolkit/skills/node_modules/sharp/src/binding.gyp +0 -303
  1034. package/toolkit/skills/node_modules/sharp/src/common.cc +0 -1186
  1035. package/toolkit/skills/node_modules/sharp/src/common.h +0 -421
  1036. package/toolkit/skills/node_modules/sharp/src/metadata.cc +0 -404
  1037. package/toolkit/skills/node_modules/sharp/src/metadata.h +0 -95
  1038. package/toolkit/skills/node_modules/sharp/src/operations.cc +0 -516
  1039. package/toolkit/skills/node_modules/sharp/src/operations.h +0 -137
  1040. package/toolkit/skills/node_modules/sharp/src/pipeline.cc +0 -1973
  1041. package/toolkit/skills/node_modules/sharp/src/pipeline.h +0 -422
  1042. package/toolkit/skills/node_modules/sharp/src/sharp.cc +0 -43
  1043. package/toolkit/skills/node_modules/sharp/src/stats.cc +0 -186
  1044. package/toolkit/skills/node_modules/sharp/src/stats.h +0 -62
  1045. package/toolkit/skills/node_modules/sharp/src/utilities.cc +0 -289
  1046. package/toolkit/skills/node_modules/sharp/src/utilities.h +0 -22
@@ -1,2322 +0,0 @@
1
- import type * as checks from "./checks.js";
2
- import type * as core from "./core.js";
3
- import { $ZodAsyncError } from "./core.js";
4
- import { Doc } from "./doc.js";
5
- import { isBackEdge, isRecursiveSchema } from "./memoizer.js";
6
- import * as regexes from "./regexes.js";
7
- import {
8
- isValidBase64,
9
- isValidBase64URL,
10
- isValidCIDRv6,
11
- isValidCreditCard,
12
- isValidIBAN,
13
- isValidIPv6,
14
- isValidJWT,
15
- mergeValues,
16
- stripTabAndNewline,
17
- urlHostnameOk,
18
- urlProtocolOk,
19
- validateURL,
20
- } from "./schemas.js";
21
- import type { ParseContextInternal, ParsePayload, SomeType } from "./schemas.js";
22
- import * as util from "./util.js";
23
-
24
- /** @internal Sentinel the compiled fast path returns when validation fails. */
25
- export const INVALID: unique symbol = Symbol.for("zod.compile.invalid");
26
- /** @internal */
27
- export type INVALID = typeof INVALID;
28
-
29
- // 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.
30
- const FALLBACK_FLAG: unique symbol = Symbol.for("zod.compile.fallback");
31
-
32
- interface CompileFnOptions {
33
- debug?: boolean | undefined;
34
- /** Emit a validator instead of a parser: skip building the output value where nothing reads it. */
35
- assertOnly?: boolean | undefined;
36
- }
37
-
38
- type CompiledFn<T> = ((input: unknown) => T | INVALID) & {
39
- code?: string | undefined;
40
- /** False when this function's INVALID does not strictly mean "the runtime would reject". */
41
- definite?: boolean | undefined;
42
- };
43
-
44
- /** Raised when the schema contains async refinements or transforms. Surfaces only under `compile(schema, { strict: true })`. */
45
- export class ZodCompileAsyncError extends Error {
46
- constructor(message = "z.compile does not support async refinements, transforms, or checks") {
47
- super(message);
48
- this.name = "ZodCompileAsyncError";
49
- }
50
- }
51
-
52
- /**
53
- * Raised when the schema contains a feature whose semantics the fast path
54
- * can't fully model. Both the shim in `zod/compile` and the default
55
- * `compile()` fall back to the runtime parser for that schema; only
56
- * `compile(schema, { strict: true })` lets it surface.
57
- */
58
- export class ZodCompileUnsupportedError extends Error {
59
- /** Whether a container may absorb this refusal by running the child through the runtime (see `compileChild`). False when running only that node on the runtime is not equivalent to running the whole parse there — a runtime island gets no parse context, so a node that *consumes* issues rather than propagating them would finalize them against the wrong error map and still succeed. */
60
- readonly islandable: boolean;
61
-
62
- constructor(feature: string, islandable = true) {
63
- super(`z.compile does not support ${feature}; this schema must use the runtime parser`);
64
- this.name = "ZodCompileUnsupportedError";
65
- this.islandable = islandable;
66
- }
67
- }
68
-
69
- interface CompileContext {
70
- constants: Map<string, unknown>;
71
- constantCounter: number;
72
- varCounter: number;
73
- /** Cleared when a construct can return INVALID for something the interpreter throws on, so `validate` keeps its fallback. */
74
- definite: boolean;
75
- }
76
-
77
- // Union of all check types we support in AOT compilation
78
- type SupportedCheck =
79
- | checks.$ZodCheckLessThan
80
- | checks.$ZodCheckGreaterThan
81
- | checks.$ZodCheckMultipleOf
82
- | checks.$ZodCheckNumberFormat
83
- | checks.$ZodCheckBigIntFormat
84
- | checks.$ZodCheckMaxSize
85
- | checks.$ZodCheckMinSize
86
- | checks.$ZodCheckSizeEquals
87
- | checks.$ZodCheckMaxLength
88
- | checks.$ZodCheckMinLength
89
- | checks.$ZodCheckLengthEquals
90
- | checks.$ZodCheckStringFormat
91
- | checks.$ZodCheckProperty
92
- | checks.$ZodCheckProperties
93
- | checks.$ZodCheckMimeType
94
- | checks.$ZodCheckOverwrite
95
- | { _zod: { def: { check: "custom"; fn?: (value: unknown) => boolean }; check?: (payload: unknown) => unknown } };
96
-
97
- /**
98
- * Build the validator `validate` calls: the same codegen as the parser with the output construction
99
- * dropped. A schema the flag cannot express reuses the parser, which still answers correctly — it
100
- * just builds a value nothing reads.
101
- */
102
- function compileValidator(schema: SomeType, parser: CompiledFn<unknown>): CompiledFn<unknown> {
103
- try {
104
- return compileFn(schema, { assertOnly: true }) as CompiledFn<unknown>;
105
- } catch {
106
- return parser;
107
- }
108
- }
109
-
110
- export interface CompileOptions {
111
- /** Throw the refusal instead of returning the schema uncompiled. */
112
- strict?: boolean | undefined;
113
- }
114
-
115
- /**
116
- * AOT-compile a Zod schema. Returns a clone whose `_zod.run` calls a generated
117
- * fast path first and falls back to the original runtime parser on failure.
118
- *
119
- * - Forward direction only. Backward (encode), async, and `skipChecks` paths
120
- * bypass the fast path and use the runtime directly.
121
- * - Never throws. A schema the fast path can't model is returned unchanged and
122
- * keeps using the runtime parser. Pass `{ strict: true }` to get the refusal
123
- * as a thrown `ZodCompileUnsupportedError` / `ZodCompileAsyncError` instead.
124
- * - The original schema is unchanged. The clone shares children by reference.
125
- */
126
- export function compile<T extends SomeType>(schema: T, options?: CompileOptions): T {
127
- try {
128
- const parser = compileFn(schema);
129
- const clone = withParser(schema, parser);
130
- // withParser leaves the parser as its own validator; the generated assert-only variant is better when we have one
131
- clone._zod.bag.validator = compileValidator(schema, parser as CompiledFn<unknown>);
132
- return clone;
133
- } catch (err) {
134
- if (options?.strict) throw err;
135
- // 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
136
- return schema;
137
- }
138
- }
139
-
140
- /**
141
- * Install an already-generated parser as a schema's fast path. Returns a clone; the original is
142
- * unchanged.
143
- *
144
- * The parser takes the input and returns the parsed value, or `INVALID` to hand the parse to the
145
- * runtime. It must be synchronous and forward-direction, and it must build fresh output rather than
146
- * return its input — Zod cannot check either, and a wrong *success* is returned to the caller as-is.
147
- *
148
- * `compile()` is the ordinary entry point. This is for a build-time or native compiler that produces
149
- * a parser where `new Function` is unavailable.
150
- */
151
- export function withParser<T extends SomeType>(schema: T, parser: (input: unknown) => core.output<T> | INVALID): T {
152
- // generated code never receives the parse context, so only the runtime can close a reference cycle; compileFn refuses these too
153
- if (isRecursiveSchema(schema as any)) {
154
- throw new ZodCompileUnsupportedError("a schema whose subtree contains a reference cycle");
155
- }
156
- const clone = util.clone(schema as any) as T;
157
-
158
- // 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.
159
- const liveRun = schema._zod.run as ((p: ParsePayload, c: ParseContextInternal) => any) & {
160
- __originalRun?: (p: ParsePayload, c: ParseContextInternal) => any;
161
- };
162
- const originalRun = liveRun.__originalRun ?? liveRun;
163
-
164
- // 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.
165
- const wrapped = (payload: ParsePayload, ctx: ParseContextInternal): any => {
166
- if (
167
- ctx?.async ||
168
- ctx?.direction === "backward" ||
169
- ctx?.skipChecks ||
170
- (ctx as Record<symbol, unknown> | undefined)?.[FALLBACK_FLAG]
171
- ) {
172
- return originalRun(payload, ctx);
173
- }
174
-
175
- // A memoized back-edge: only the runtime can close a reference cycle, and a transform on one must raise $ZodCyclicError from its own parse.
176
- if (ctx && isBackEdge(ctx, payload.value)) {
177
- return originalRun(payload, ctx);
178
- }
179
-
180
- const out = parser(payload.value);
181
- if (out !== INVALID) {
182
- payload.value = out;
183
- return payload;
184
- }
185
- // 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.
186
- if (ctx) (ctx as Record<symbol, unknown>)[FALLBACK_FLAG] = true;
187
- return originalRun(payload, ctx);
188
- };
189
- // 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.
190
- (wrapped as { __originalRun?: typeof originalRun }).__originalRun = originalRun;
191
- clone._zod.bag.fallbackRun = originalRun;
192
- // 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
193
- clone._zod.bag.validator = parser as CompiledFn<unknown>;
194
- clone._zod.run = wrapped;
195
-
196
- // 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.
197
- if (!liveRun.__originalRun) installCompiledUserMethods(clone, schema, parser as CompiledFn<core.output<T>>);
198
-
199
- return clone;
200
- }
201
-
202
- function installCompiledUserMethods<T extends SomeType>(
203
- target: T,
204
- source: T,
205
- parser: CompiledFn<core.output<T>>
206
- ): void {
207
- const targetAny = target as any;
208
- const sourceAny = source as any;
209
-
210
- if (typeof sourceAny.safeParse === "function") {
211
- const originalSafeParse = sourceAny.safeParse;
212
- targetAny.safeParse = (data: unknown, params?: unknown) => {
213
- const out = parser(data);
214
- if (out !== INVALID) {
215
- return { success: true, data: out };
216
- }
217
- return originalSafeParse(data, params);
218
- };
219
- }
220
-
221
- if (typeof sourceAny.parse === "function") {
222
- const originalParse = sourceAny.parse;
223
- targetAny.parse = (data: unknown, params?: unknown) => {
224
- const out = parser(data);
225
- if (out !== INVALID) {
226
- return out;
227
- }
228
- return originalParse(data, params);
229
- };
230
- }
231
- }
232
-
233
- /**
234
- * @internal Generate the standalone compiled function: a parser by default, a validator under
235
- * `assertOnly`. Returns the parsed value, `true` where nothing reads the output, or `INVALID`. Consumers use `compile()`.
236
- */
237
- export function compileFn<T extends SomeType>(schema: T, options?: CompileFnOptions): CompiledFn<core.output<T>> {
238
- // 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.
239
- let recursive = true;
240
- try {
241
- recursive = isRecursiveSchema(schema as any);
242
- } catch {}
243
- if (recursive) {
244
- throw new ZodCompileUnsupportedError("a schema whose subtree contains a reference cycle");
245
- }
246
-
247
- const ctx: CompileContext = {
248
- constants: new Map(),
249
- constantCounter: 0,
250
- varCounter: 0,
251
- definite: true,
252
- };
253
-
254
- const doc = new Doc(["input"]);
255
- const outputAccessor = generateCheck(doc, ctx, schema, "input", !options?.assertOnly);
256
- // In assert mode a root that built nothing has already returned INVALID on every failure, so reaching the end means valid.
257
- doc.write(outputAccessor === null ? `return true;` : `return ${outputAccessor};`);
258
-
259
- // Build the function with hoisted constants Always include INVALID as the first constant
260
- const constantNames = ["INVALID", ...ctx.constants.keys()];
261
- const constantValues = [INVALID, ...ctx.constants.values()];
262
-
263
- const code = doc.content.join("\n");
264
- const fullCode = options?.debug
265
- ? constantNames.length > 0
266
- ? `// Constants: ${constantNames.join(", ")}\n${code}`
267
- : code
268
- : "";
269
-
270
- const F = Function;
271
- const factoryCode = `return (input) => {\n${code}\n}`;
272
- let fn: CompiledFn<core.output<T>>;
273
- try {
274
- const factory = new F(...constantNames, factoryCode);
275
- fn = factory(...constantValues) as CompiledFn<core.output<T>>;
276
- } catch (err) {
277
- // 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.
278
- throw new ZodCompileUnsupportedError(`this schema (generated code failed to evaluate: ${(err as Error).message})`);
279
- }
280
- if (options?.debug) {
281
- fn.code = fullCode;
282
- }
283
- fn.definite = ctx.definite;
284
- return fn;
285
- }
286
-
287
- function addConstant(ctx: CompileContext, value: unknown): string {
288
- // Check if we already have this constant
289
- for (const [name, v] of ctx.constants) {
290
- if (v === value) return name;
291
- }
292
- const name = `c${ctx.constantCounter++}`;
293
- ctx.constants.set(name, value);
294
- return name;
295
- }
296
-
297
- /** 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. */
298
- function addUserConstant(ctx: CompileContext, fn: unknown): string {
299
- ctx.definite = false;
300
- return addConstant(ctx, fn);
301
- }
302
-
303
- function newVar(ctx: CompileContext): string {
304
- return `v${ctx.varCounter++}`;
305
- }
306
-
307
- // Runs a child schema as a black box: its value, or INVALID for a failure or an async run.
308
- function runtimeRun(schema: SomeType, value: unknown): unknown {
309
- const result = (schema._zod.run as (p: ParsePayload, c: ParseContextInternal) => any)(
310
- { value, issues: [] },
311
- {} as ParseContextInternal
312
- );
313
- if (result && typeof (result as Promise<unknown>).then === "function") return INVALID;
314
- const r = result as { value: unknown; issues: unknown[] };
315
- return r.issues.length === 0 ? r.value : INVALID;
316
- }
317
-
318
- // Try to compile `schema` against `accessor`. If `generateCheck` throws
319
- // `ZodCompileUnsupportedError`, the doc + ctx state is rolled back and a
320
- // runtime island is emitted instead — the child schema is invoked through
321
- // `runtimeRun` at parse time and treated as a black box. Anything else thrown
322
- // propagates (e.g. `ZodCompileAsyncError`).
323
- function compileChild(doc: Doc, ctx: CompileContext, schema: SomeType, accessor: string): string;
324
- function compileChild(
325
- doc: Doc,
326
- ctx: CompileContext,
327
- schema: SomeType,
328
- accessor: string,
329
- needsValue: boolean
330
- ): string | null;
331
- // `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.
332
- function compileChild(
333
- doc: Doc,
334
- ctx: CompileContext,
335
- schema: SomeType,
336
- accessor: string,
337
- needsValue = true
338
- ): string | null {
339
- const contentLen = doc.content.length;
340
- const constantCount = ctx.constants.size;
341
- const constantCounter = ctx.constantCounter;
342
- const varCounter = ctx.varCounter;
343
- try {
344
- return generateCheck(doc, ctx, schema, accessor, needsValue);
345
- } catch (err) {
346
- if (!(err instanceof ZodCompileUnsupportedError) || !err.islandable) throw err;
347
- doc.content.length = contentLen;
348
- if (ctx.constants.size > constantCount) {
349
- const trailing = Array.from(ctx.constants.keys()).slice(constantCount);
350
- for (const k of trailing) ctx.constants.delete(k);
351
- }
352
- ctx.constantCounter = constantCounter;
353
- ctx.varCounter = varCounter;
354
- return emitRuntimeIsland(doc, ctx, schema, accessor);
355
- }
356
- }
357
-
358
- function emitRuntimeIsland(doc: Doc, ctx: CompileContext, schema: SomeType, accessor: string): string {
359
- // an islanded child answers INVALID for an async run too, which the interpreter throws for
360
- ctx.definite = false;
361
- const schemaConst = addConstant(ctx, schema);
362
- const runConst = addConstant(ctx, runtimeRun);
363
- const outVar = newVar(ctx);
364
- doc.write(`const ${outVar} = ${runConst}(${schemaConst}, ${accessor});`);
365
- doc.write(`if (${outVar} === INVALID) return INVALID;`);
366
- return outVar;
367
- }
368
-
369
- // Check classes whose `when` is auto-defaulted at init (checks.ts `when ??=`).
370
- const WHEN_DEFAULTED_CHECKS = new Set([
371
- "max_size",
372
- "min_size",
373
- "size_equals",
374
- "max_length",
375
- "min_length",
376
- "length_equals",
377
- ]);
378
-
379
- function generateChecks(doc: Doc, ctx: CompileContext, schema: SomeType, accessor: string): string {
380
- const schemaChecks = schema._zod.def.checks as SupportedCheck[] | undefined;
381
- if (!schemaChecks || schemaChecks.length === 0) return accessor;
382
-
383
- // Track current accessor - may change if overwrite checks are encountered
384
- let currentAccessor = accessor;
385
-
386
- for (const check of schemaChecks) {
387
- const def = check._zod.def;
388
- // 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.
389
- if ((def as { when?: unknown }).when && !WHEN_DEFAULTED_CHECKS.has(def.check)) {
390
- throw new ZodCompileUnsupportedError(`check with a custom "when" condition`);
391
- }
392
- switch (def.check) {
393
- case "greater_than":
394
- generateGreaterThanCheck(doc, ctx, def, currentAccessor);
395
- break;
396
- case "less_than":
397
- generateLessThanCheck(doc, ctx, def, currentAccessor);
398
- break;
399
- case "multiple_of":
400
- generateMultipleOfCheck(doc, ctx, def, currentAccessor);
401
- break;
402
- case "number_format":
403
- generateNumberFormatCheck(doc, def, currentAccessor);
404
- break;
405
- case "min_length": {
406
- const min = numericOperand(def.minimum, "min_length");
407
- const len = codePointLengthVar(
408
- doc,
409
- ctx,
410
- currentAccessor,
411
- `${currentAccessor}.length >= ${min} && ${currentAccessor}.length < ${def.minimum * 2}`
412
- );
413
- doc.write(`if (${len} < ${min}) return INVALID;`);
414
- break;
415
- }
416
- case "max_length": {
417
- const max = numericOperand(def.maximum, "max_length");
418
- const len = codePointLengthVar(doc, ctx, currentAccessor, `${currentAccessor}.length > ${max}`);
419
- doc.write(`if (${len} > ${max}) return INVALID;`);
420
- break;
421
- }
422
- case "length_equals": {
423
- const exact = numericOperand(def.length, "length_equals");
424
- const len = codePointLengthVar(
425
- doc,
426
- ctx,
427
- currentAccessor,
428
- `${currentAccessor}.length >= ${exact} && ${currentAccessor}.length <= ${def.length * 2}`
429
- );
430
- doc.write(`if (${len} !== ${exact}) return INVALID;`);
431
- break;
432
- }
433
- case "min_size":
434
- doc.write(`if (${currentAccessor}.size < ${numericOperand(def.minimum, "min_size")}) return INVALID;`);
435
- break;
436
- case "max_size":
437
- doc.write(`if (${currentAccessor}.size > ${numericOperand(def.maximum, "max_size")}) return INVALID;`);
438
- break;
439
- case "size_equals":
440
- doc.write(`if (${currentAccessor}.size !== ${numericOperand(def.size, "size_equals")}) return INVALID;`);
441
- break;
442
- case "string_format":
443
- currentAccessor = generateStringFormatCheck(doc, ctx, def, currentAccessor);
444
- break;
445
- case "custom":
446
- currentAccessor = generateCustomRefineCheck(doc, ctx, check as CustomCheck, currentAccessor);
447
- break;
448
- case "bigint_format":
449
- generateBigIntFormatCheck(doc, def, currentAccessor);
450
- break;
451
- case "mime_type":
452
- generateMimeTypeCheck(doc, ctx, def, currentAccessor);
453
- break;
454
- case "property":
455
- generatePropertyCheck(doc, ctx, def, currentAccessor);
456
- break;
457
- case "properties":
458
- generatePropertiesChecks(doc, ctx, def, currentAccessor);
459
- break;
460
- case "overwrite": {
461
- // Overwrite transforms the value - create new variable for transformed result
462
- const newAccessor = newVar(ctx);
463
- generateOverwriteCheck(doc, ctx, check as checks.$ZodCheckOverwrite, currentAccessor, newAccessor);
464
- currentAccessor = newAccessor;
465
- break;
466
- }
467
- default: {
468
- void (def satisfies never);
469
- throw new ZodCompileUnsupportedError(`check type ${(def as { check: string }).check}`);
470
- }
471
- }
472
- }
473
-
474
- return currentAccessor;
475
- }
476
-
477
- // 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.
478
- function codePointLengthVar(doc: Doc, ctx: CompileContext, accessor: string, inDoubt: string): string {
479
- const cpLen = addConstant(ctx, util.codePointLength);
480
- const v = newVar(ctx);
481
- doc.write(`const ${v} = typeof ${accessor} === "string" && ${inDoubt} ? ${cpLen}(${accessor}) : ${accessor}.length;`);
482
- return v;
483
- }
484
-
485
- // 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.
486
- /**
487
- * A count bound reaches generated source verbatim, so a non-number would be
488
- * emitted as code rather than as a value — `min('0) {} evil(); if (0')` writes an
489
- * arbitrary statement into the function body. TypeScript types these as `number`
490
- * and fromJSONSchema guards them, so this is a backstop rather than a live hole,
491
- * but generated source is the one place a wrong type stops being a type error.
492
- */
493
- function numericOperand(value: unknown, label: string): string {
494
- if (typeof value !== "number" || !Number.isFinite(value)) {
495
- throw new ZodCompileUnsupportedError(`${label} bound of type ${typeof value}`);
496
- }
497
- return `${value}`;
498
- }
499
-
500
- function comparisonOperand(ctx: CompileContext, value: number | bigint | Date): string {
501
- if (typeof value === "bigint") return `${value}n`;
502
- if (typeof value === "number") {
503
- if (Number.isNaN(value)) throw new ZodCompileUnsupportedError("comparison check with NaN bound");
504
- return `${value}`;
505
- }
506
- if (value instanceof Date) {
507
- if (Number.isNaN(value.getTime())) {
508
- throw new ZodCompileUnsupportedError("comparison check with Invalid Date bound");
509
- }
510
- return addConstant(ctx, value);
511
- }
512
- throw new ZodCompileUnsupportedError(`comparison check bound of type ${typeof value}`);
513
- }
514
-
515
- function generateGreaterThanCheck(
516
- doc: Doc,
517
- ctx: CompileContext,
518
- def: checks.$ZodCheckGreaterThanDef,
519
- accessor: string
520
- ): void {
521
- const op = def.inclusive ? "<" : "<=";
522
- doc.write(`if (${accessor} ${op} ${comparisonOperand(ctx, def.value)}) return INVALID;`);
523
- }
524
-
525
- function generateLessThanCheck(
526
- doc: Doc,
527
- ctx: CompileContext,
528
- def: checks.$ZodCheckLessThanDef,
529
- accessor: string
530
- ): void {
531
- const op = def.inclusive ? ">" : ">=";
532
- doc.write(`if (${accessor} ${op} ${comparisonOperand(ctx, def.value)}) return INVALID;`);
533
- }
534
-
535
- function generateMultipleOfCheck(
536
- doc: Doc,
537
- ctx: CompileContext,
538
- def: checks.$ZodCheckMultipleOfDef,
539
- accessor: string
540
- ): void {
541
- if (typeof def.value === "bigint") {
542
- // a zero divisor has no compiled form: `x % 0n` throws
543
- if (def.value === BigInt(0)) throw new ZodCompileUnsupportedError("multiple_of check with a zero divisor");
544
- doc.write(`if (${accessor} % ${def.value}n !== 0n) return INVALID;`);
545
- } else {
546
- // Float `%` has well-known precision issues for sub-integer steps
547
- // (`1.5 % 0.1`, `2.5e-7 % 1e-7`). Defer to util.floatSafeRemainder so the
548
- // exact tolerance logic stays in one place — single function call is fine
549
- // since `multipleOf` runs at most once per number.
550
- const remainder = addConstant(ctx, util.floatSafeRemainder);
551
- doc.write(`if (${remainder}(${accessor}, ${numericOperand(def.value, "multiple_of")}) !== 0) return INVALID;`);
552
- }
553
- }
554
-
555
- function generateNumberFormatCheck(doc: Doc, def: checks.$ZodCheckNumberFormatDef, accessor: string): void {
556
- const format = def.format;
557
- switch (format) {
558
- case "safeint":
559
- doc.write(`if (!Number.isSafeInteger(${accessor})) return INVALID;`);
560
- break;
561
- case "int32":
562
- doc.write(
563
- `if (!Number.isInteger(${accessor}) || ${accessor} < -2147483648 || ${accessor} > 2147483647) return INVALID;`
564
- );
565
- break;
566
- case "uint32":
567
- doc.write(`if (!Number.isInteger(${accessor}) || ${accessor} < 0 || ${accessor} > 4294967295) return INVALID;`);
568
- break;
569
- case "float32":
570
- // Float32 range per util.NUMBER_FORMAT_RANGES
571
- doc.write(
572
- `if (!Number.isFinite(${accessor}) || ${accessor} < -3.4028234663852886e38 || ${accessor} > 3.4028234663852886e38) return INVALID;`
573
- );
574
- break;
575
- case "float64":
576
- doc.write(`if (!Number.isFinite(${accessor})) return INVALID;`);
577
- break;
578
- default: {
579
- void (format satisfies never);
580
- throw new ZodCompileUnsupportedError(`number format ${format}`);
581
- }
582
- }
583
- }
584
-
585
- function generateBigIntFormatCheck(doc: Doc, def: checks.$ZodCheckBigIntFormatDef, accessor: string): void {
586
- const format = def.format;
587
- if (!format) return; // undefined format means no range check
588
- switch (format) {
589
- case "int64":
590
- doc.write(`if (${accessor} < -9223372036854775808n || ${accessor} > 9223372036854775807n) return INVALID;`);
591
- break;
592
- case "uint64":
593
- doc.write(`if (${accessor} < 0n || ${accessor} > 18446744073709551615n) return INVALID;`);
594
- break;
595
- default: {
596
- void (format satisfies never);
597
- throw new ZodCompileUnsupportedError(`bigint format ${format}`);
598
- }
599
- }
600
- }
601
-
602
- function generateMimeTypeCheck(
603
- doc: Doc,
604
- ctx: CompileContext,
605
- def: checks.$ZodCheckMimeTypeDef,
606
- accessor: string
607
- ): void {
608
- const mimeTypes = def.mime;
609
- if (mimeTypes && mimeTypes.length > 0) {
610
- const mimeSet = addConstant(ctx, new Set(mimeTypes));
611
- doc.write(`if (!${mimeSet}.has(${accessor}.type)) return INVALID;`);
612
- }
613
- }
614
-
615
- // asserts each named property in place; children compile assert-only because z.properties never rebuilds its input
616
- function generatePropertiesChecks(
617
- doc: Doc,
618
- ctx: CompileContext,
619
- def: checks.$ZodCheckPropertiesDef,
620
- accessor: string
621
- ): void {
622
- // 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
623
- if (def.when) {
624
- throw new ZodCompileUnsupportedError(`check with a custom "when" condition`);
625
- }
626
- // matches the runtime gate: the base schema already typed the value, so only a nullish one is rejected
627
- doc.write(`if (${accessor} == null) return INVALID;`);
628
- const shape = def.shape as Record<string | symbol, SomeType>;
629
- for (const key of Reflect.ownKeys(shape)) {
630
- // a symbol has no source literal, so it is hoisted as a constant
631
- const keyExpr = typeof key === "symbol" ? addConstant(ctx, key) : util.esc(key);
632
- // cache the property read so a getter runs exactly once, matching the runtime
633
- const inputVar = newVar(ctx);
634
- doc.write(`const ${inputVar} = ${accessor}[${keyExpr}];`);
635
- compileChild(doc, ctx, shape[key]!, inputVar, false);
636
- }
637
- }
638
-
639
- function generatePropertyCheck(
640
- doc: Doc,
641
- ctx: CompileContext,
642
- def: checks.$ZodCheckPropertyDef,
643
- accessor: string
644
- ): void {
645
- const propAccessor = `${accessor}[${JSON.stringify(def.property)}]`;
646
- generateCheck(doc, ctx, def.schema as SomeType, propAccessor);
647
- }
648
-
649
- function generateOverwriteCheck(
650
- doc: Doc,
651
- ctx: CompileContext,
652
- check: checks.$ZodCheckOverwrite,
653
- currentAccessor: string,
654
- newAccessor: string
655
- ): void {
656
- const tx = check._zod.def.tx;
657
- if (!tx) {
658
- throw new ZodCompileUnsupportedError("overwrite check without a transform function");
659
- }
660
-
661
- // Check for async transform
662
- if (isAsyncFunction(tx)) {
663
- throw new ZodCompileAsyncError("z.compile: async overwrite transforms are not supported");
664
- }
665
-
666
- // Hoist the transform function as a constant and apply it
667
- const txConst = addConstant(ctx, tx);
668
- doc.write(`const ${newAccessor} = ${txConst}(${currentAccessor});`);
669
- }
670
-
671
- type CustomCheck = {
672
- _zod: { def: { check: "custom"; fn?: (value: unknown) => boolean }; check?: (payload: unknown) => unknown };
673
- };
674
- /** 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. */
675
- function throwAsync(): never {
676
- throw new $ZodAsyncError();
677
- }
678
-
679
- /** 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`. */
680
- function pushIssue(this: { issues: unknown[] }, issue: unknown): void {
681
- this.issues.push(issue);
682
- }
683
-
684
- function generateCustomRefineCheck(doc: Doc, ctx: CompileContext, check: CustomCheck, accessor: string): string {
685
- const def = check._zod.def;
686
-
687
- if (def.fn) {
688
- // Simple predicate function (from .refine())
689
- if (isAsyncFunction(def.fn)) {
690
- throw new ZodCompileAsyncError("z.compile: async .refine() predicates are not supported");
691
- }
692
- const fnConst = addUserConstant(ctx, def.fn);
693
- const throwAsyncConst = addConstant(ctx, throwAsync);
694
- const resVar = newVar(ctx);
695
- doc.write(`const ${resVar} = ${fnConst}(${accessor});`);
696
- // 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.
697
- doc.write(`if (${resVar} instanceof Promise) ${throwAsyncConst}();`);
698
- doc.write(`if (!${resVar}) return INVALID;`);
699
- // A `.refine()` predicate only answers yes or no; it cannot rewrite the value.
700
- return accessor;
701
- }
702
- if (check._zod.check) {
703
- if (isAsyncFunction(check._zod.check)) {
704
- throw new ZodCompileAsyncError("z.compile: async .superRefine() / check functions are not supported");
705
- }
706
- // SuperRefine or other check function - need to spoof context Create a helper that runs the check and returns true if no issues
707
- const checkFn = check._zod.check;
708
- // `$RefinementCtx` extends the parse payload, so a check may rewrite
709
- // `ctx.value` as well as push issues — `.superRefine((v, ctx) => { ctx.value =
710
- // v.trim() })` is a value transform. Returning only a boolean discarded that
711
- // write and emitted the untrimmed input. Hand the value back and thread it on.
712
- const helperFn = (value: unknown): unknown => {
713
- const fakePayload = { value, issues: [] as unknown[], addIssue: pushIssue };
714
- const result = checkFn(fakePayload);
715
- // Throw rather than return INVALID: the interpreter throws here, and a union would read INVALID as a rejected branch.
716
- if (result instanceof Promise) throwAsync();
717
- return fakePayload.issues.length === 0 ? fakePayload.value : INVALID;
718
- };
719
- const helperConst = addUserConstant(ctx, helperFn);
720
- const outVar = newVar(ctx);
721
- doc.write(`const ${outVar} = ${helperConst}(${accessor});`);
722
- doc.write(`if (${outVar} === INVALID) return INVALID;`);
723
- return outVar;
724
- }
725
- throw new ZodCompileUnsupportedError("custom check without a predicate or check function");
726
- }
727
-
728
- type StringFormatDef =
729
- | checks.$ZodCheckStringFormatDef
730
- | checks.$ZodCheckRegexDef
731
- | checks.$ZodCheckLowerCaseDef
732
- | checks.$ZodCheckUpperCaseDef
733
- | checks.$ZodCheckIncludesDef
734
- | checks.$ZodCheckStartsWithDef
735
- | checks.$ZodCheckEndsWithDef;
736
-
737
- type SupportedStringFormat = "regex" | "lowercase" | "uppercase" | "includes" | "starts_with" | "ends_with";
738
-
739
- /**
740
- * Built-in formats that validate with nothing but `def.pattern`, so compiling
741
- * the regex reproduces the runtime exactly. Deliberately an allowlist: a format
742
- * missing from it loses its fast path, while a format wrongly added to it
743
- * silently accepts input the runtime rejects. Formats that layer extra
744
- * validation over a shape-only pattern (`credit_card`, `base64`, `ipv6`, …) are
745
- * handled above by hoisting the runtime validator itself.
746
- */
747
- const PATTERN_IS_COMPLETE: Set<string> = new Set([
748
- "cidrv4",
749
- "cuid",
750
- "cuid2",
751
- "date",
752
- "datetime",
753
- "duration",
754
- "e164",
755
- "email",
756
- "emoji",
757
- "ends_with",
758
- "guid",
759
- "includes",
760
- "ipv4",
761
- "ksuid",
762
- "lowercase",
763
- "mac",
764
- "nanoid",
765
- "regex",
766
- "starts_with",
767
- "time",
768
- "ulid",
769
- "uppercase",
770
- "uuid",
771
- "xid",
772
- ]);
773
-
774
- // Returns the accessor holding the (possibly normalized) value after the check — url/normalize formats produce a new value like overwrite does. Never assigns to the incoming accessor: it may be a `const` or a property expression on user input.
775
- function generateStringFormatCheck(doc: Doc, ctx: CompileContext, def: StringFormatDef, accessor: string): string;
776
- function generateStringFormatCheck(
777
- doc: Doc,
778
- ctx: CompileContext,
779
- def: StringFormatDef,
780
- accessor: string,
781
- needsValue: boolean
782
- ): string | null;
783
- function generateStringFormatCheck(
784
- doc: Doc,
785
- ctx: CompileContext,
786
- def: StringFormatDef,
787
- accessor: string,
788
- needsValue = true
789
- ): string | null {
790
- // 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.
791
- const fmt = def.format;
792
- if (fmt === "base64") {
793
- const validator = addConstant(ctx, isValidBase64);
794
- doc.write(`if (!${validator}(${accessor})) return INVALID;`);
795
- return accessor;
796
- }
797
- if (fmt === "base64url") {
798
- const validator = addConstant(ctx, isValidBase64URL);
799
- doc.write(`if (!${validator}(${accessor})) return INVALID;`);
800
- return accessor;
801
- }
802
- if (fmt === "jwt") {
803
- const validator = addConstant(ctx, isValidJWT);
804
- const alg = addConstant(ctx, (def as unknown as { alg?: util.JWTAlgorithm }).alg ?? null);
805
- doc.write(`if (!${validator}(${accessor}, ${alg})) return INVALID;`);
806
- return accessor;
807
- }
808
- if (fmt === "ipv6") {
809
- const validator = addConstant(ctx, isValidIPv6);
810
- doc.write(`if (!${validator}(${accessor})) return INVALID;`);
811
- return accessor;
812
- }
813
- if (fmt === "cidrv6") {
814
- const validator = addConstant(ctx, isValidCIDRv6);
815
- doc.write(`if (!${validator}(${accessor})) return INVALID;`);
816
- return accessor;
817
- }
818
- if (fmt === "credit_card") {
819
- const validator = addConstant(ctx, isValidCreditCard);
820
- doc.write(`if (!${validator}(${accessor})) return INVALID;`);
821
- return accessor;
822
- }
823
- if (fmt === "iban") {
824
- const validator = addConstant(ctx, isValidIBAN);
825
- doc.write(`if (!${validator}(${accessor})) return INVALID;`);
826
- return accessor;
827
- }
828
- const formatDef = def as unknown as { normalize?: boolean; hostname?: unknown; protocol?: unknown };
829
- if (
830
- fmt === "url" ||
831
- fmt === "httpurl" ||
832
- formatDef.normalize ||
833
- formatDef.hostname !== undefined ||
834
- formatDef.protocol !== undefined
835
- ) {
836
- // 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.
837
- const parseConst = addConstant(ctx, validateURL);
838
- const defConst = addConstant(ctx, def);
839
- const trimVar = newVar(ctx);
840
- const urlVar = newVar(ctx);
841
- doc.write(`const ${trimVar} = ${accessor}.trim();`);
842
- doc.write(`const ${urlVar} = ${parseConst}(${trimVar}, ${defConst});`);
843
- doc.write(`if (typeof ${urlVar} === "number") return INVALID;`);
844
- if (formatDef.hostname !== undefined) {
845
- const hostnameConst = addConstant(ctx, urlHostnameOk);
846
- doc.write(`if (!${hostnameConst}(${urlVar}, ${defConst}.hostname)) return INVALID;`);
847
- }
848
- if (formatDef.protocol !== undefined) {
849
- const protocolConst = addConstant(ctx, urlProtocolOk);
850
- doc.write(`if (!${protocolConst}(${urlVar}, ${defConst}.protocol)) return INVALID;`);
851
- }
852
- if (!needsValue) return null;
853
- const outputVar = newVar(ctx);
854
- const outputExpr = formatDef.normalize ? `${urlVar}.href` : `${addConstant(ctx, stripTabAndNewline)}(${trimVar})`;
855
- doc.write(`const ${outputVar} = ${outputExpr};`);
856
- return outputVar;
857
- }
858
-
859
- // 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.
860
- const customFn = (def as unknown as { fn?: (input: string) => unknown }).fn;
861
- if (customFn) {
862
- if (isAsyncFunction(customFn)) throw new ZodCompileUnsupportedError(`async string format ${fmt}`);
863
- const fnConst = addConstant(ctx, customFn);
864
- doc.write(`if (!${fnConst}(${accessor})) return INVALID;`);
865
- return accessor;
866
- }
867
-
868
- // 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.
869
- if (PATTERN_IS_COMPLETE.has(fmt) && def.pattern) {
870
- const patternConst = addConstant(ctx, def.pattern);
871
- doc.write(`${patternConst}.lastIndex = 0;`);
872
- doc.write(`if (!${patternConst}.test(${accessor})) return INVALID;`);
873
- return accessor;
874
- }
875
-
876
- const format = def.format as SupportedStringFormat;
877
- switch (format) {
878
- case "regex":
879
- // 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.
880
- throw new ZodCompileUnsupportedError("regex format without a pattern");
881
- case "lowercase":
882
- doc.write(`if (${accessor} !== ${accessor}.toLowerCase()) return INVALID;`);
883
- break;
884
- case "uppercase":
885
- doc.write(`if (${accessor} !== ${accessor}.toUpperCase()) return INVALID;`);
886
- break;
887
- case "includes":
888
- doc.write(
889
- `if (!${accessor}.includes(${util.esc((def as checks.$ZodCheckIncludesDef).includes)})) return INVALID;`
890
- );
891
- break;
892
- case "starts_with": {
893
- const prefix = (def as checks.$ZodCheckStartsWithDef).prefix;
894
- doc.write(`if (${accessor}.slice(0, ${prefix.length}) !== ${util.esc(prefix)}) return INVALID;`);
895
- break;
896
- }
897
- case "ends_with": {
898
- const suffix = (def as checks.$ZodCheckEndsWithDef).suffix;
899
- doc.write(`if (${accessor}.slice(-${suffix.length}) !== ${util.esc(suffix)}) return INVALID;`);
900
- break;
901
- }
902
- default: {
903
- void (format satisfies never);
904
- throw new ZodCompileUnsupportedError(`string format ${format}`);
905
- }
906
- }
907
- return accessor;
908
- }
909
-
910
- // Union of all schema types we support in AOT compilation
911
- type SupportedSchemaType =
912
- | "string"
913
- | "number"
914
- | "boolean"
915
- | "bigint"
916
- | "symbol"
917
- | "undefined"
918
- | "null"
919
- | "any"
920
- | "unknown"
921
- | "never"
922
- | "void"
923
- | "nan"
924
- | "date"
925
- | "object"
926
- | "optional"
927
- | "nullable"
928
- | "array"
929
- | "literal"
930
- | "enum"
931
- | "readonly"
932
- | "success"
933
- | "default"
934
- | "prefault"
935
- | "nonoptional"
936
- | "tuple"
937
- | "union"
938
- | "intersection"
939
- | "record"
940
- | "map"
941
- | "set"
942
- | "file"
943
- | "template_literal"
944
- | "lazy"
945
- | "pipe"
946
- | "custom"
947
- | "transform"
948
- | "catch";
949
-
950
- function generateCheck(doc: Doc, ctx: CompileContext, schema: SomeType, accessor: string): string;
951
- function generateCheck(
952
- doc: Doc,
953
- ctx: CompileContext,
954
- schema: SomeType,
955
- accessor: string,
956
- needsValue: boolean
957
- ): string | null;
958
- function generateCheck(
959
- doc: Doc,
960
- ctx: CompileContext,
961
- schema: SomeType,
962
- accessor: string,
963
- needsValue = true
964
- ): string | null {
965
- const def = schema._zod.def;
966
- const type = def.type as SupportedSchemaType;
967
-
968
- // 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.
969
- if ((def as { coerce?: boolean }).coerce) {
970
- throw new ZodCompileUnsupportedError(`coercion (z.coerce.${type}())`);
971
- }
972
-
973
- // 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.
974
- const buildsValue = needsValue || !!def.checks?.length;
975
- let typeAccessor: string | null;
976
-
977
- switch (type) {
978
- case "string":
979
- typeAccessor = generateStringCheck(doc, ctx, schema, accessor, buildsValue);
980
- break;
981
- case "number":
982
- typeAccessor = generateNumberCheck(doc, schema, accessor);
983
- break;
984
- case "boolean":
985
- typeAccessor = generateBooleanCheck(doc, accessor);
986
- break;
987
- case "bigint":
988
- typeAccessor = generateBigIntCheck(doc, schema, accessor);
989
- break;
990
- case "symbol":
991
- typeAccessor = generateSymbolCheck(doc, accessor);
992
- break;
993
- case "undefined":
994
- typeAccessor = generateUndefinedCheck(doc, accessor);
995
- break;
996
- case "null":
997
- typeAccessor = generateNullCheck(doc, accessor);
998
- break;
999
- case "any":
1000
- case "unknown":
1001
- // No check needed - pass through
1002
- typeAccessor = accessor;
1003
- break;
1004
- case "never":
1005
- doc.write("return INVALID;");
1006
- typeAccessor = accessor;
1007
- break;
1008
- case "void":
1009
- typeAccessor = generateVoidCheck(doc, accessor);
1010
- break;
1011
- case "nan":
1012
- typeAccessor = generateNaNCheck(doc, accessor);
1013
- break;
1014
- case "date":
1015
- typeAccessor = generateDateCheck(doc, accessor);
1016
- break;
1017
- case "object":
1018
- typeAccessor = generateObjectCheck(doc, ctx, schema, accessor, buildsValue);
1019
- break;
1020
- case "optional":
1021
- typeAccessor = generateOptionalCheck(doc, ctx, schema, accessor, buildsValue);
1022
- break;
1023
- case "nullable":
1024
- typeAccessor = generateNullableCheck(doc, ctx, schema, accessor, buildsValue);
1025
- break;
1026
- case "array":
1027
- typeAccessor = generateArrayCheck(doc, ctx, schema, accessor, buildsValue);
1028
- break;
1029
- case "literal":
1030
- typeAccessor = generateLiteralCheck(doc, ctx, schema, accessor);
1031
- break;
1032
- case "enum":
1033
- typeAccessor = generateEnumCheck(doc, ctx, schema, accessor);
1034
- break;
1035
- case "readonly": {
1036
- const innerOut = generateWrapperCheck(doc, ctx, schema, accessor);
1037
- // Runtime freezes the parsed value (schemas.ts handleReadonlyResult).
1038
- const frozenVar = newVar(ctx);
1039
- doc.write(`const ${frozenVar} = Object.freeze(${innerOut});`);
1040
- typeAccessor = frozenVar;
1041
- break;
1042
- }
1043
- case "success":
1044
- // Runtime output is `issues.length === 0`. The fast path only reaches
1045
- // here when the inner check passed (failure returns INVALID and the
1046
- // runtime fallback reproduces the inner issues), so the output is
1047
- // always `true`.
1048
- generateWrapperCheck(doc, ctx, schema, accessor);
1049
- typeAccessor = "true";
1050
- break;
1051
- case "default":
1052
- case "prefault":
1053
- typeAccessor = generateDefaultCheck(doc, ctx, schema, accessor);
1054
- break;
1055
- case "nonoptional":
1056
- typeAccessor = generateNonOptionalCheck(doc, ctx, schema, accessor);
1057
- break;
1058
- case "tuple":
1059
- typeAccessor = generateTupleCheck(doc, ctx, schema, accessor);
1060
- break;
1061
- case "union":
1062
- typeAccessor = generateUnionCheck(doc, ctx, schema, accessor);
1063
- break;
1064
- case "intersection":
1065
- typeAccessor = generateIntersectionCheck(doc, ctx, schema, accessor);
1066
- break;
1067
- case "record":
1068
- typeAccessor = generateRecordCheck(doc, ctx, schema, accessor);
1069
- break;
1070
- case "map":
1071
- typeAccessor = generateMapCheck(doc, ctx, schema, accessor);
1072
- break;
1073
- case "set":
1074
- typeAccessor = generateSetCheck(doc, ctx, schema, accessor);
1075
- break;
1076
- case "file":
1077
- typeAccessor = generateFileCheck(doc, accessor);
1078
- break;
1079
- case "template_literal":
1080
- typeAccessor = generateTemplateLiteralCheck(doc, ctx, schema, accessor);
1081
- break;
1082
- case "lazy":
1083
- typeAccessor = generateLazyCheck(doc, ctx, schema, accessor);
1084
- break;
1085
- case "pipe":
1086
- typeAccessor = generatePipeCheck(doc, ctx, schema, accessor);
1087
- break;
1088
- case "custom":
1089
- typeAccessor = generateCustomCheck(doc, ctx, schema, accessor);
1090
- break;
1091
- case "transform":
1092
- typeAccessor = generateTransformCheck(doc, ctx, schema, accessor);
1093
- break;
1094
- case "catch":
1095
- typeAccessor = generateCatchCheck(doc, ctx, schema, accessor);
1096
- break;
1097
- default: {
1098
- void (type satisfies never);
1099
- throw new ZodCompileUnsupportedError(`schema type ${type}`);
1100
- }
1101
- }
1102
-
1103
- // a node that built nothing has no checks to run: not building requires an empty check list
1104
- if (typeAccessor === null) return null;
1105
-
1106
- // Generate checks after the type-specific validation (may transform value)
1107
- return generateChecks(doc, ctx, schema, typeAccessor);
1108
- }
1109
-
1110
- function generateStringCheck(
1111
- doc: Doc,
1112
- ctx: CompileContext,
1113
- schema: SomeType,
1114
- accessor: string,
1115
- needsValue = true
1116
- ): string | null {
1117
- doc.write(`if (typeof ${accessor} !== "string") return INVALID;`);
1118
-
1119
- // 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.
1120
- const def = schema._zod.def as unknown as StringFormatDef & { format?: string };
1121
- if (def.format === undefined) return accessor;
1122
- return generateStringFormatCheck(doc, ctx, def, accessor, needsValue);
1123
- }
1124
-
1125
- function generateNumberCheck(doc: Doc, schema: SomeType, accessor: string): string {
1126
- // Runtime z.number() rejects NaN and ±Infinity. Number.isFinite covers both.
1127
- doc.write(`if (typeof ${accessor} !== "number" || !Number.isFinite(${accessor})) return INVALID;`);
1128
-
1129
- // 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.
1130
- const def = schema._zod.def as unknown as { check?: string; format?: string };
1131
- if (def.check === "number_format" && def.format) {
1132
- generateNumberFormatCheck(doc, { format: def.format } as checks.$ZodCheckNumberFormatDef, accessor);
1133
- }
1134
- return accessor;
1135
- }
1136
-
1137
- function generateBooleanCheck(doc: Doc, accessor: string): string {
1138
- doc.write(`if (typeof ${accessor} !== "boolean") return INVALID;`);
1139
- return accessor;
1140
- }
1141
-
1142
- function generateBigIntCheck(doc: Doc, schema: SomeType, accessor: string): string {
1143
- doc.write(`if (typeof ${accessor} !== "bigint") return INVALID;`);
1144
-
1145
- // Handle bigint format (int64, uint64) directly on the schema def
1146
- const def = schema._zod.def as unknown as { format?: string };
1147
- if (def.format) {
1148
- switch (def.format) {
1149
- case "int64":
1150
- doc.write(`if (${accessor} < -9223372036854775808n || ${accessor} > 9223372036854775807n) return INVALID;`);
1151
- break;
1152
- case "uint64":
1153
- doc.write(`if (${accessor} < 0n || ${accessor} > 18446744073709551615n) return INVALID;`);
1154
- break;
1155
- }
1156
- }
1157
- return accessor;
1158
- }
1159
-
1160
- function generateSymbolCheck(doc: Doc, accessor: string): string {
1161
- doc.write(`if (typeof ${accessor} !== "symbol") return INVALID;`);
1162
- return accessor;
1163
- }
1164
-
1165
- function generateUndefinedCheck(doc: Doc, accessor: string): string {
1166
- doc.write(`if (${accessor} !== undefined) return INVALID;`);
1167
- return accessor;
1168
- }
1169
-
1170
- function generateNullCheck(doc: Doc, accessor: string): string {
1171
- doc.write(`if (${accessor} !== null) return INVALID;`);
1172
- return accessor;
1173
- }
1174
-
1175
- function generateVoidCheck(doc: Doc, accessor: string): string {
1176
- doc.write(`if (${accessor} !== undefined) return INVALID;`);
1177
- return accessor;
1178
- }
1179
-
1180
- function generateNaNCheck(doc: Doc, accessor: string): string {
1181
- doc.write(`if (typeof ${accessor} !== "number" || !Number.isNaN(${accessor})) return INVALID;`);
1182
- return accessor;
1183
- }
1184
-
1185
- function generateDateCheck(doc: Doc, accessor: string): string {
1186
- doc.write(`if (!(${accessor} instanceof Date) || Number.isNaN(${accessor}.getTime())) return INVALID;`);
1187
- return accessor;
1188
- }
1189
-
1190
- function generateObjectCheck(
1191
- doc: Doc,
1192
- ctx: CompileContext,
1193
- schema: SomeType,
1194
- accessor: string,
1195
- buildsValue = true
1196
- ): string | null {
1197
- const def = schema._zod.def as unknown as { shape: Record<string, SomeType>; catchall?: SomeType };
1198
-
1199
- // Check that input is a non-null, non-array object
1200
- doc.write(
1201
- `if (typeof ${accessor} !== "object" || ${accessor} === null || Array.isArray(${accessor})) return INVALID;`
1202
- );
1203
-
1204
- const shape = def.shape;
1205
- const keys = Object.keys(shape);
1206
- const symbolKeys = Object.getOwnPropertySymbols(shape);
1207
- // a symbol has no source literal, so it is hoisted as a constant; `keys` stays string-only where the emitted code uses `for...in`
1208
- const allKeys: (string | symbol)[] = symbolKeys.length ? [...keys, ...symbolKeys] : keys;
1209
- const keyExpr = (k: string | symbol) => (typeof k === "symbol" ? addConstant(ctx, k) : util.esc(k));
1210
- const propKey = (k: string | symbol) => (typeof k === "symbol" ? `[${keyExpr(k)}]` : util.esc(k));
1211
- const propShape = shape as Record<string | symbol, SomeType>;
1212
-
1213
- // `__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).
1214
- if (keys.includes("__proto__")) {
1215
- throw new ZodCompileUnsupportedError('object shape key "__proto__"');
1216
- }
1217
-
1218
- // Map from key to output accessor for that property
1219
- const propOutputs = new Map<string | symbol, string>();
1220
-
1221
- // Validate each property and collect output accessors
1222
- for (const key of allKeys) {
1223
- const propSchema = propShape[key]!;
1224
- const kx = keyExpr(key);
1225
- // 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.
1226
- const inputVar = newVar(ctx);
1227
- doc.write(`const ${inputVar} = ${accessor}[${kx}];`);
1228
-
1229
- if (propSchema._zod.optin !== undefined) {
1230
- // 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.
1231
- const outputVar = newVar(ctx);
1232
- doc.write(`let ${outputVar} = (() => {`);
1233
- doc.indented((d) => {
1234
- const outputAccessor = compileChild(d, ctx, propSchema, inputVar);
1235
- d.write(`return ${outputAccessor};`);
1236
- });
1237
- doc.write(`})();`);
1238
-
1239
- if (propSchema._zod.optout === "optional") {
1240
- doc.write(`if (${outputVar} === INVALID) {`);
1241
- doc.indented((d) => {
1242
- d.write(`if (${kx} in ${accessor}) return INVALID;`);
1243
- d.write(`${outputVar} = undefined;`);
1244
- });
1245
- doc.write(`}`);
1246
- } else {
1247
- doc.write(`if (${outputVar} === INVALID) return INVALID;`);
1248
- }
1249
- propOutputs.set(key, outputVar);
1250
- } else {
1251
- if (requiresPresenceCheck(propSchema)) {
1252
- doc.write(`if (!(${kx} in ${accessor})) return INVALID;`);
1253
- }
1254
-
1255
- // Generate check and get output accessor
1256
- const outputAccessor = compileChild(doc, ctx, propSchema, inputVar, buildsValue);
1257
- if (outputAccessor !== null) propOutputs.set(key, outputAccessor);
1258
- }
1259
- }
1260
-
1261
- // Handle catchall
1262
- const catchall = def.catchall;
1263
- let unknownKeysMode: "none" | "passthrough" | "schema" = "none";
1264
-
1265
- if (catchall) {
1266
- const catchallType = catchall._zod.def.type;
1267
-
1268
- if (catchallType === "never") {
1269
- // 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.
1270
- const condition = keys.map((k) => `k !== ${util.esc(k)}`).join(" && ") || "true";
1271
- doc.write(`for (const k in ${accessor}) {`);
1272
- doc.indented((d) => {
1273
- d.write(`if (${condition}) return INVALID;`);
1274
- });
1275
- doc.write(`}`);
1276
- } else if ((catchallType === "unknown" || catchallType === "any") && !catchall._zod.def.checks?.length) {
1277
- unknownKeysMode = "passthrough";
1278
- } else {
1279
- unknownKeysMode = "schema";
1280
- }
1281
- }
1282
- // else: strip mode (no catchall) - unknown keys ignored, only include known keys
1283
-
1284
- // defaulted required outputs keep their keys even when undefined
1285
- const outputVar = newVar(ctx);
1286
- const hasConditionalKeys = allKeys.some((k) => mayOmitUndefined(propShape[k]!) || dropsWhenAbsent(propShape[k]!));
1287
-
1288
- // 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.
1289
- if (!buildsValue) {
1290
- if (unknownKeysMode === "schema") {
1291
- const knownSet = keys.length > 0 ? addConstant(ctx, new Set(keys)) : null;
1292
- doc.write(`for (const k in ${accessor}) {`);
1293
- doc.indented((d) => {
1294
- d.write(`if (k === "__proto__") continue;`);
1295
- if (knownSet) d.write(`if (${knownSet}.has(k)) continue;`);
1296
- const valVar = newVar(ctx);
1297
- d.write(`const ${valVar} = ${accessor}[k];`);
1298
- compileChild(d, ctx, catchall!, valVar, false);
1299
- });
1300
- doc.write(`}`);
1301
- }
1302
- return null;
1303
- }
1304
-
1305
- if (!hasConditionalKeys) {
1306
- const propLiterals = allKeys.map((k) => `${propKey(k)}: ${propOutputs.get(k)}`).join(", ");
1307
- doc.write(`const ${outputVar} = { ${propLiterals} };`);
1308
- } else {
1309
- doc.write(`const ${outputVar} = {};`);
1310
- for (const k of allKeys) {
1311
- const kx = keyExpr(k);
1312
- const out = propOutputs.get(k);
1313
- if (dropsWhenAbsent(propShape[k]!)) {
1314
- doc.write(`if (${kx} in ${accessor}) ${outputVar}[${kx}] = ${out};`);
1315
- } else if (mayOmitUndefined(propShape[k]!)) {
1316
- doc.write(`if (${out} !== undefined || ${kx} in ${accessor}) ${outputVar}[${kx}] = ${out};`);
1317
- } else {
1318
- doc.write(`${outputVar}[${kx}] = ${out};`);
1319
- }
1320
- }
1321
- }
1322
-
1323
- if (unknownKeysMode !== "none") {
1324
- // Unknown keys are written directly into the output after shape keys — for...in (like the runtime) so inherited enumerables participate.
1325
- const knownSet = keys.length > 0 ? addConstant(ctx, new Set(keys)) : null;
1326
- doc.write(`for (const k in ${accessor}) {`);
1327
- doc.indented((d) => {
1328
- // 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).
1329
- d.write(`if (k === "__proto__") continue;`);
1330
- if (knownSet) d.write(`if (${knownSet}.has(k)) continue;`);
1331
- if (unknownKeysMode === "passthrough") {
1332
- d.write(`${outputVar}[k] = ${accessor}[k];`);
1333
- } else {
1334
- const valVar = newVar(ctx);
1335
- d.write(`const ${valVar} = ${accessor}[k];`);
1336
- const catchallOut = compileChild(d, ctx, catchall!, valVar);
1337
- d.write(`${outputVar}[k] = ${catchallOut};`);
1338
- }
1339
- });
1340
- doc.write(`}`);
1341
- }
1342
-
1343
- return outputVar;
1344
- }
1345
-
1346
- function generateOptionalCheck(
1347
- doc: Doc,
1348
- ctx: CompileContext,
1349
- schema: SomeType,
1350
- accessor: string,
1351
- buildsValue = true
1352
- ): string | null {
1353
- const def = schema._zod.def as unknown as { innerType: SomeType };
1354
- if (isExactOptional(schema)) {
1355
- return generateCheck(doc, ctx, def.innerType, accessor, buildsValue);
1356
- }
1357
-
1358
- // 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.
1359
- if (def.innerType._zod.optin === "defaulted") {
1360
- const outputVar = newVar(ctx);
1361
- const branchVar = newVar(ctx);
1362
- doc.write(`let ${outputVar};`);
1363
- doc.write(`if (${accessor} === undefined) {`);
1364
- doc.indented((d) => {
1365
- d.write(`const ${branchVar} = (() => {`);
1366
- d.indented((d2) => {
1367
- const innerOutput = generateCheck(d2, ctx, def.innerType, accessor);
1368
- d2.write(`return ${innerOutput};`);
1369
- });
1370
- d.write(`})();`);
1371
- d.write(`if (${branchVar} !== INVALID) ${outputVar} = ${branchVar};`);
1372
- });
1373
- doc.write(`} else {`);
1374
- doc.indented((d) => {
1375
- const innerOutput = generateCheck(d, ctx, def.innerType, accessor);
1376
- d.write(`${outputVar} = ${innerOutput};`);
1377
- });
1378
- doc.write(`}`);
1379
- return outputVar;
1380
- }
1381
-
1382
- const outputVar = buildsValue ? newVar(ctx) : null;
1383
- if (outputVar) doc.write(`let ${outputVar};`);
1384
- doc.write(`if (${accessor} !== undefined) {`);
1385
- doc.indented((d) => {
1386
- const innerOutput = generateCheck(d, ctx, def.innerType, accessor, buildsValue);
1387
- if (outputVar && innerOutput !== null) d.write(`${outputVar} = ${innerOutput};`);
1388
- });
1389
- doc.write(`}`);
1390
- return outputVar;
1391
- }
1392
-
1393
- function isExactOptional(schema: SomeType): boolean {
1394
- return (schema._zod as { traits?: Set<string> }).traits?.has("$ZodExactOptional") === true;
1395
- }
1396
-
1397
- // 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.
1398
- function requiresPresenceCheck(schema: SomeType): boolean {
1399
- return schema._zod.optin === undefined && fastPathAcceptsAbsence(schema);
1400
- }
1401
-
1402
- function fastPathAcceptsAbsence(schema: SomeType): boolean {
1403
- // 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).
1404
- if ((schema._zod.def as { coerce?: boolean }).coerce) return true;
1405
-
1406
- const def = schema._zod.def as {
1407
- type: string;
1408
- values?: unknown[];
1409
- innerType?: SomeType;
1410
- options?: SomeType[];
1411
- in?: SomeType;
1412
- out?: SomeType;
1413
- left?: SomeType;
1414
- right?: SomeType;
1415
- };
1416
-
1417
- switch (def.type) {
1418
- case "any":
1419
- case "unknown":
1420
- case "undefined":
1421
- case "void":
1422
- case "default":
1423
- case "prefault":
1424
- case "transform":
1425
- case "custom":
1426
- case "lazy":
1427
- return true;
1428
- case "string":
1429
- case "number":
1430
- case "boolean":
1431
- case "bigint":
1432
- case "symbol":
1433
- case "null":
1434
- case "never":
1435
- case "nan":
1436
- case "date":
1437
- case "object":
1438
- case "array":
1439
- case "tuple":
1440
- case "record":
1441
- case "map":
1442
- case "set":
1443
- case "file":
1444
- case "template_literal":
1445
- return false;
1446
- case "nonoptional":
1447
- // 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.
1448
- return def.innerType ? fastPathAcceptsAbsence(def.innerType) : false;
1449
- case "literal":
1450
- return !!def.values?.includes(undefined);
1451
- case "enum":
1452
- return !!(schema._zod as unknown as { values?: Set<unknown> }).values?.has(undefined);
1453
- case "optional":
1454
- case "nullable":
1455
- case "readonly":
1456
- case "success":
1457
- return def.innerType ? fastPathAcceptsAbsence(def.innerType) : true;
1458
- case "catch":
1459
- // catch always produces a value (inner may fail → catchValue substitutes), so it accepts an absent key regardless of inner.
1460
- return true;
1461
- case "union":
1462
- return def.options ? def.options.some(fastPathAcceptsAbsence) : true;
1463
- case "intersection":
1464
- if (!def.left || !def.right) return true;
1465
- return fastPathAcceptsAbsence(def.left) && fastPathAcceptsAbsence(def.right);
1466
- case "pipe":
1467
- return def.in ? fastPathAcceptsAbsence(def.in) : true;
1468
- default:
1469
- return true;
1470
- }
1471
- }
1472
-
1473
- /** The middle rung permits absence without supplying anything in its place, so an absent key contributes nothing — mirrors the leading gate in `handlePropertyResult`. */
1474
- function dropsWhenAbsent(schema: SomeType): boolean {
1475
- return schema._zod.optin === "optional" && schema._zod.optout === "optional";
1476
- }
1477
-
1478
- function mayOmitUndefined(schema: SomeType): boolean {
1479
- return (schema._zod.optin !== "defaulted" || schema._zod.optout === "optional") && mayOutputUndefined(schema);
1480
- }
1481
-
1482
- // whether a schema's success-path output can be undefined
1483
- function mayOutputUndefined(schema: SomeType): boolean {
1484
- const def = schema._zod.def as {
1485
- type: string;
1486
- values?: unknown[];
1487
- innerType?: SomeType;
1488
- options?: SomeType[];
1489
- out?: SomeType;
1490
- left?: SomeType;
1491
- right?: SomeType;
1492
- };
1493
- switch (def.type) {
1494
- case "string":
1495
- case "number":
1496
- case "boolean":
1497
- case "bigint":
1498
- case "symbol":
1499
- case "null":
1500
- case "nan":
1501
- case "date":
1502
- case "object":
1503
- case "array":
1504
- case "tuple":
1505
- case "record":
1506
- case "map":
1507
- case "set":
1508
- case "file":
1509
- case "template_literal":
1510
- case "never":
1511
- case "success":
1512
- return false;
1513
- case "literal":
1514
- return !!def.values?.includes(undefined);
1515
- case "enum":
1516
- return !!(schema._zod as unknown as { values?: Set<unknown> }).values?.has(undefined);
1517
- case "optional":
1518
- return true;
1519
- case "nullable":
1520
- case "readonly":
1521
- case "nonoptional":
1522
- return def.innerType ? mayOutputUndefined(def.innerType) : true;
1523
- case "union":
1524
- return def.options ? def.options.some(mayOutputUndefined) : true;
1525
- case "intersection":
1526
- return !def.left || !def.right || mayOutputUndefined(def.left) || mayOutputUndefined(def.right);
1527
- case "pipe":
1528
- return def.out ? mayOutputUndefined(def.out) : true;
1529
- default:
1530
- // any/unknown/undefined/void/default/prefault/transform/custom/lazy/catch
1531
- return true;
1532
- }
1533
- }
1534
-
1535
- function generateNullableCheck(
1536
- doc: Doc,
1537
- ctx: CompileContext,
1538
- schema: SomeType,
1539
- accessor: string,
1540
- buildsValue = true
1541
- ): string | null {
1542
- const def = schema._zod.def as unknown as { innerType: SomeType };
1543
- const outputVar = buildsValue ? newVar(ctx) : null;
1544
- if (outputVar) doc.write(`let ${outputVar} = null;`);
1545
- doc.write(`if (${accessor} !== null) {`);
1546
- doc.indented((d) => {
1547
- const innerOutput = generateCheck(d, ctx, def.innerType, accessor, buildsValue);
1548
- if (outputVar && innerOutput !== null) d.write(`${outputVar} = ${innerOutput};`);
1549
- });
1550
- doc.write(`}`);
1551
- return outputVar;
1552
- }
1553
-
1554
- function generateSizeGate(doc: Doc, schema: SomeType, size: string): void {
1555
- for (const [max, check] of util.sizeCaps(schema._zod.def.checks)) {
1556
- doc.write(`if (${size} > ${numericOperand(max, check._zod.def.check)}) return INVALID;`);
1557
- }
1558
- }
1559
-
1560
- function generateArrayCheck(
1561
- doc: Doc,
1562
- ctx: CompileContext,
1563
- schema: SomeType,
1564
- accessor: string,
1565
- buildsValue = true
1566
- ): string | null {
1567
- const def = schema._zod.def as unknown as { element: SomeType };
1568
- doc.write(`if (!Array.isArray(${accessor})) return INVALID;`);
1569
- generateSizeGate(doc, schema, `${accessor}.length`);
1570
-
1571
- // Build a new array with validated/transformed elements.
1572
- const outputVar = buildsValue ? newVar(ctx) : null;
1573
- const iVar = newVar(ctx);
1574
- const elemVar = newVar(ctx);
1575
-
1576
- if (outputVar) doc.write(`const ${outputVar} = new Array(${accessor}.length);`);
1577
- doc.write(`for (let ${iVar} = 0; ${iVar} < ${accessor}.length; ${iVar}++) {`);
1578
- doc.indented((d) => {
1579
- d.write(`const ${elemVar} = ${accessor}[${iVar}];`);
1580
- const elemOutput = compileChild(d, ctx, def.element, elemVar, buildsValue);
1581
- if (outputVar && elemOutput !== null) d.write(`${outputVar}[${iVar}] = ${elemOutput};`);
1582
- });
1583
- doc.write(`}`);
1584
-
1585
- return outputVar;
1586
- }
1587
-
1588
- function generateLiteralCheck(doc: Doc, ctx: CompileContext, schema: SomeType, accessor: string): string {
1589
- const def = schema._zod.def as unknown as { values: unknown[] };
1590
- const values = def.values;
1591
-
1592
- // 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.
1593
- if (values.length !== 1) {
1594
- const literalSet = addConstant(ctx, new Set(values));
1595
- doc.write(`if (!${literalSet}.has(${accessor})) return INVALID;`);
1596
- return accessor;
1597
- }
1598
-
1599
- const value = values[0];
1600
- // `$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.
1601
- if (typeof value === "number" && Number.isNaN(value)) {
1602
- const literalSet = addConstant(ctx, new Set(values));
1603
- doc.write(`if (!${literalSet}.has(${accessor})) return INVALID;`);
1604
- return accessor;
1605
- }
1606
- if (typeof value === "string") {
1607
- doc.write(`if (${accessor} !== ${util.esc(value)}) return INVALID;`);
1608
- } else if (typeof value === "number" || typeof value === "boolean") {
1609
- doc.write(`if (${accessor} !== ${value}) return INVALID;`);
1610
- } else if (value === null) {
1611
- doc.write(`if (${accessor} !== null) return INVALID;`);
1612
- } else if (value === undefined) {
1613
- doc.write(`if (${accessor} !== undefined) return INVALID;`);
1614
- } else if (typeof value === "bigint") {
1615
- doc.write(`if (${accessor} !== ${value}n) return INVALID;`);
1616
- } else {
1617
- throw new ZodCompileUnsupportedError(`literal type ${typeof value}`);
1618
- }
1619
- return accessor;
1620
- }
1621
-
1622
- function generateEnumCheck(doc: Doc, ctx: CompileContext, schema: SomeType, accessor: string): string {
1623
- const values = (schema._zod as unknown as { values?: Set<unknown> }).values;
1624
- // 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.
1625
- if (!values) {
1626
- throw new ZodCompileUnsupportedError("enum schema without enumerated values");
1627
- }
1628
- const enumSet = addConstant(ctx, values);
1629
- doc.write(`if (!${enumSet}.has(${accessor})) return INVALID;`);
1630
- return accessor;
1631
- }
1632
-
1633
- function generateWrapperCheck(doc: Doc, ctx: CompileContext, schema: SomeType, accessor: string): string {
1634
- const def = schema._zod.def as unknown as { innerType: SomeType };
1635
- return generateCheck(doc, ctx, def.innerType, accessor);
1636
- }
1637
-
1638
- function generateDefaultCheck(doc: Doc, ctx: CompileContext, schema: SomeType, accessor: string): string {
1639
- const def = schema._zod.def as unknown as { innerType: SomeType };
1640
-
1641
- // `defaultValue` is an accessor on schemas built through the classic/mini
1642
- // factories and a plain data property on ones rebuilt programmatically
1643
- // (deepPartial and friends). Read it off the def either way — taking only
1644
- // `descriptor.get` silently dropped the default for the second kind, so
1645
- // `.default(v)` compiled to `undefined` instead of `v`.
1646
- const descriptor = Object.getOwnPropertyDescriptor(schema._zod.def, "defaultValue");
1647
- const defaultGetter = descriptor
1648
- ? () => (schema._zod.def as unknown as { defaultValue: unknown }).defaultValue
1649
- : undefined;
1650
-
1651
- // prefault differs from default: undefined-input is first replaced with the prefault value, then run through the inner schema.
1652
- if (schema._zod.def.type === "prefault") {
1653
- if (!defaultGetter) {
1654
- return generateCheck(doc, ctx, def.innerType, accessor);
1655
- }
1656
- const defaultFn = addConstant(ctx, defaultGetter);
1657
- const inputVar = newVar(ctx);
1658
- doc.write(`let ${inputVar} = ${accessor};`);
1659
- doc.write(`if (${accessor} === undefined) ${inputVar} = ${defaultFn}();`);
1660
- return generateCheck(doc, ctx, def.innerType, inputVar);
1661
- }
1662
-
1663
- const outputVar = newVar(ctx);
1664
-
1665
- // Default allows undefined (replaces with default value), otherwise validates inner type
1666
- if (defaultGetter) {
1667
- const defaultFn = addConstant(ctx, defaultGetter);
1668
- const cloneFn = addConstant(ctx, util.shallowClone);
1669
- doc.write(`let ${outputVar};`);
1670
- doc.write(`if (${accessor} === undefined) {`);
1671
- doc.indented((d) => {
1672
- // Shallow-clone the default so callers can mutate the result without affecting subsequent parses (#5855 — also covers Map/Set).
1673
- d.write(`${outputVar} = ${cloneFn}(${defaultFn}());`);
1674
- });
1675
- doc.write(`} else {`);
1676
- doc.indented((d) => {
1677
- const innerOutput = generateCheck(d, ctx, def.innerType, accessor);
1678
- d.write(`${outputVar} = ${innerOutput} === undefined ? ${cloneFn}(${defaultFn}()) : ${innerOutput};`);
1679
- });
1680
- doc.write(`}`);
1681
- } else {
1682
- doc.write(`let ${outputVar};`);
1683
- doc.write(`if (${accessor} !== undefined) {`);
1684
- doc.indented((d) => {
1685
- const innerOutput = generateCheck(d, ctx, def.innerType, accessor);
1686
- d.write(`${outputVar} = ${innerOutput};`);
1687
- });
1688
- doc.write(`}`);
1689
- }
1690
-
1691
- return outputVar;
1692
- }
1693
-
1694
- function generateNonOptionalCheck(doc: Doc, ctx: CompileContext, schema: SomeType, accessor: string): string {
1695
- const def = schema._zod.def as unknown as { innerType: SomeType };
1696
- // 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.
1697
- const innerOutput = generateCheck(doc, ctx, def.innerType, accessor);
1698
- const outputVar = newVar(ctx);
1699
- doc.write(`const ${outputVar} = ${innerOutput};`);
1700
- doc.write(`if (${outputVar} === undefined) return INVALID;`);
1701
- return outputVar;
1702
- }
1703
-
1704
- function generateTupleCheck(doc: Doc, ctx: CompileContext, schema: SomeType, accessor: string): string {
1705
- const def = schema._zod.def as unknown as { items: SomeType[]; rest: SomeType | null };
1706
- const items = def.items;
1707
- const rest = def.rest;
1708
-
1709
- doc.write(`if (!Array.isArray(${accessor})) return INVALID;`);
1710
-
1711
- // 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.
1712
- const optinStart = getTupleOptStart(items, "optin");
1713
- const optoutStart = getTupleOptStart(items, "optout");
1714
-
1715
- // Length bounds
1716
- if (rest) {
1717
- // With rest: minimum length is the last required input slot
1718
- doc.write(`if (${accessor}.length < ${optinStart}) return INVALID;`);
1719
- } else {
1720
- // No rest: input must be in [optinStart, items.length]
1721
- doc.write(`if (${accessor}.length < ${optinStart} || ${accessor}.length > ${items.length}) return INVALID;`);
1722
- }
1723
-
1724
- // Build the output in assignment order so absent optional-output tail slots can truncate while default/prefault slots still fill missing positions.
1725
- const outputVar = newVar(ctx);
1726
- doc.write(`const ${outputVar} = [];`);
1727
-
1728
- // Validate and collect each fixed item
1729
- for (let i = 0; i < items.length; i++) {
1730
- const itemSchema = items[i]!;
1731
- if (i >= optoutStart) {
1732
- doc.write(`if (${outputVar}.length === ${i}) {`);
1733
- doc.indented((d) => {
1734
- d.write(`if (${i} < ${accessor}.length) {`);
1735
- d.indented((d2) => {
1736
- const elemVar = newVar(ctx);
1737
- d2.write(`const ${elemVar} = ${accessor}[${i}];`);
1738
- const elemOutput = compileChild(d2, ctx, itemSchema, elemVar);
1739
- d2.write(`${outputVar}[${i}] = ${elemOutput};`);
1740
- });
1741
- d.write(`} else {`);
1742
- d.indented((d2) => {
1743
- // 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`.
1744
- if (dropsWhenAbsent(itemSchema)) {
1745
- d2.write(`${outputVar}.length = ${i};`);
1746
- return;
1747
- }
1748
- const elemVar = newVar(ctx);
1749
- const branchVar = newVar(ctx);
1750
- d2.write(`const ${elemVar} = undefined;`);
1751
- d2.write(`const ${branchVar} = (() => {`);
1752
- d2.indented((d3) => {
1753
- const elemOutput = compileChild(d3, ctx, itemSchema, elemVar);
1754
- d3.write(`return ${elemOutput};`);
1755
- });
1756
- d2.write(`})();`);
1757
- d2.write(`if (${branchVar} === INVALID || ${branchVar} === undefined) ${outputVar}.length = ${i};`);
1758
- d2.write(`else ${outputVar}[${i}] = ${branchVar};`);
1759
- });
1760
- d.write(`}`);
1761
- });
1762
- doc.write(`}`);
1763
- } else {
1764
- const elemVar = newVar(ctx);
1765
- doc.write(`const ${elemVar} = ${accessor}[${i}];`);
1766
- const elemOutput = compileChild(doc, ctx, itemSchema, elemVar);
1767
- doc.write(`${outputVar}[${i}] = ${elemOutput};`);
1768
- }
1769
- }
1770
-
1771
- // Validate and collect rest elements if present
1772
- if (rest) {
1773
- const iVar = newVar(ctx);
1774
- const elemVar = newVar(ctx);
1775
- doc.write(`for (let ${iVar} = ${items.length}; ${iVar} < ${accessor}.length; ${iVar}++) {`);
1776
- doc.indented((d) => {
1777
- d.write(`const ${elemVar} = ${accessor}[${iVar}];`);
1778
- const elemOutput = compileChild(d, ctx, rest, elemVar);
1779
- d.write(`${outputVar}[${iVar}] = ${elemOutput};`);
1780
- });
1781
- doc.write(`}`);
1782
- }
1783
-
1784
- return outputVar;
1785
- }
1786
-
1787
- function getTupleOptStart(items: SomeType[], key: "optin" | "optout"): number {
1788
- for (let i = items.length - 1; i >= 0; i--) {
1789
- // Mirrors the runtime: optin is a three-rung ladder so any rung above `undefined` permits an absent slot; optout stays two-valued.
1790
- const omittable = key === "optin" ? items[i]!._zod.optin !== undefined : items[i]!._zod.optout === "optional";
1791
- if (!omittable) return i + 1;
1792
- }
1793
- return 0;
1794
- }
1795
-
1796
- function generateUnionCheck(doc: Doc, ctx: CompileContext, schema: SomeType, accessor: string): string {
1797
- const def = schema._zod.def as unknown as {
1798
- options: SomeType[];
1799
- inclusive?: boolean;
1800
- discriminator?: string;
1801
- unionFallback?: boolean;
1802
- };
1803
- const options = def.options;
1804
-
1805
- if (def.discriminator) {
1806
- return generateDiscriminatedUnionCheck(
1807
- doc,
1808
- ctx,
1809
- def as { options: SomeType[]; discriminator: string; unionFallback?: boolean },
1810
- accessor
1811
- );
1812
- }
1813
-
1814
- // 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.
1815
- if (def.inclusive === false) {
1816
- throw new ZodCompileUnsupportedError("exclusive unions (z.xor)");
1817
- }
1818
-
1819
- if (options.length === 0) {
1820
- doc.write("return INVALID;");
1821
- return accessor;
1822
- }
1823
-
1824
- if (options.length === 1) {
1825
- return generateCheck(doc, ctx, options[0]!, accessor);
1826
- }
1827
-
1828
- // 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.
1829
- const allLiterals = options.every(
1830
- (opt) => opt._zod.def.type === "literal" && !(opt._zod.def.checks as unknown[] | undefined)?.length
1831
- );
1832
- if (allLiterals) {
1833
- const values = new Set(options.flatMap((opt) => (opt._zod.def as unknown as { values: unknown[] }).values));
1834
- const valuesConst = addConstant(ctx, values);
1835
- doc.write(`if (!${valuesConst}.has(${accessor})) return INVALID;`);
1836
- return accessor;
1837
- }
1838
-
1839
- // General case: try each option until one succeeds Use IIFEs that return the output or INVALID
1840
- const outputVar = newVar(ctx);
1841
- doc.write(`let ${outputVar};`);
1842
-
1843
- for (let i = 0; i < options.length; i++) {
1844
- const opt = options[i]!;
1845
-
1846
- if (i === 0) {
1847
- doc.write(`${outputVar} = (() => {`);
1848
- } else {
1849
- doc.write(`if (${outputVar} === INVALID) ${outputVar} = (() => {`);
1850
- }
1851
-
1852
- doc.indented((d) => {
1853
- // Generate check inside IIFE - returns INVALID on failure
1854
- const branchOutput = generateCheck(d, ctx, opt, accessor);
1855
- d.write(`return ${branchOutput};`);
1856
- });
1857
- doc.write(`})();`);
1858
- }
1859
-
1860
- doc.write(`if (${outputVar} === INVALID) return INVALID;`);
1861
- return outputVar;
1862
- }
1863
-
1864
- function generateDiscriminatedUnionCheck(
1865
- doc: Doc,
1866
- ctx: CompileContext,
1867
- def: { options: SomeType[]; discriminator: string; unionFallback?: boolean },
1868
- accessor: string
1869
- ): string {
1870
- if (def.unionFallback) {
1871
- throw new ZodCompileUnsupportedError("discriminated union with unionFallback");
1872
- }
1873
-
1874
- if (def.options.length === 0) {
1875
- doc.write("return INVALID;");
1876
- return accessor;
1877
- }
1878
-
1879
- const discVar = newVar(ctx);
1880
- const outputVar = newVar(ctx);
1881
- doc.write(`const ${discVar} = ${accessor}?.[${util.esc(def.discriminator)}];`);
1882
- doc.write(`let ${outputVar};`);
1883
-
1884
- let firstBranch = true;
1885
- const claimed = new Set<util.Primitive>();
1886
- for (const option of def.options) {
1887
- const values = option._zod.propValues?.[def.discriminator];
1888
- if (!values || values.size === 0) {
1889
- throw new ZodCompileUnsupportedError("discriminated union option without static discriminator values");
1890
- }
1891
-
1892
- // let the interpreter handle collisions instead of compiling first-match dispatch
1893
- for (const value of values) {
1894
- if (claimed.has(value)) {
1895
- throw new ZodCompileUnsupportedError(`duplicate discriminator value ${String(value)}`);
1896
- }
1897
- claimed.add(value);
1898
- }
1899
-
1900
- const conditions = Array.from(values, (value) => literalEquality(ctx, discVar, value));
1901
- const prefix = firstBranch ? "if" : "else if";
1902
- doc.write(`${prefix} (${conditions.join(" || ")}) {`);
1903
- doc.indented((d) => {
1904
- const branchOutput = generateCheck(d, ctx, option, accessor);
1905
- d.write(`${outputVar} = ${branchOutput};`);
1906
- });
1907
- doc.write(`}`);
1908
- firstBranch = false;
1909
- }
1910
-
1911
- doc.write(`else { return INVALID; }`);
1912
- return outputVar;
1913
- }
1914
-
1915
- function literalEquality(ctx: CompileContext, accessor: string, value: unknown): string {
1916
- if (typeof value === "string") return `${accessor} === ${util.esc(value)}`;
1917
- if (typeof value === "number") {
1918
- if (Number.isNaN(value)) return `Number.isNaN(${accessor})`;
1919
- return `${accessor} === ${value}`;
1920
- }
1921
- if (typeof value === "boolean") return `${accessor} === ${value}`;
1922
- if (value === null) return `${accessor} === null`;
1923
- if (value === undefined) return `${accessor} === undefined`;
1924
- if (typeof value === "bigint") return `${accessor} === ${value}n`;
1925
- if (typeof value === "symbol") {
1926
- const symbolConst = addConstant(ctx, value);
1927
- return `${accessor} === ${symbolConst}`;
1928
- }
1929
- throw new ZodCompileUnsupportedError(`literal discriminator value ${String(value)}`);
1930
- }
1931
-
1932
- function generateIntersectionCheck(doc: Doc, ctx: CompileContext, schema: SomeType, accessor: string): string {
1933
- const def = schema._zod.def as unknown as { left: SomeType; right: SomeType };
1934
- // 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.
1935
- ctx.definite = false;
1936
- const leftOutput = compileChild(doc, ctx, def.left, accessor);
1937
- const rightOutput = compileChild(doc, ctx, def.right, accessor);
1938
-
1939
- // 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.
1940
- const mergeConst = addConstant(ctx, mergeValues);
1941
- const mergedVar = newVar(ctx);
1942
- doc.write(`const ${mergedVar} = ${mergeConst}(${leftOutput}, ${rightOutput});`);
1943
- doc.write(`if (!${mergedVar}.valid) return INVALID;`);
1944
- return `${mergedVar}.data`;
1945
- }
1946
-
1947
- function generateRecordCheck(doc: Doc, ctx: CompileContext, schema: SomeType, accessor: string): string {
1948
- const def = schema._zod.def as unknown as { keyType: SomeType; valueType: SomeType };
1949
-
1950
- // 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.
1951
- const isPlainObjectConst = addConstant(ctx, util.isPlainObject);
1952
- doc.write(`if (!${isPlainObjectConst}(${accessor})) return INVALID;`);
1953
-
1954
- const outputVar = newVar(ctx);
1955
- const kVar = newVar(ctx);
1956
- const valVar = newVar(ctx);
1957
-
1958
- doc.write(`const ${outputVar} = {};`);
1959
-
1960
- // 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.
1961
- const recordDef = def as unknown as { mode?: string; partial?: boolean };
1962
- const keyValues = recordDef.partial ? undefined : (def.keyType._zod as unknown as { values?: Set<unknown> }).values;
1963
- if (keyValues) {
1964
- const inputKeys: Array<string | symbol> = [];
1965
- for (const key of keyValues) {
1966
- if (!(typeof key === "string" || typeof key === "number" || typeof key === "symbol")) {
1967
- throw new ZodCompileUnsupportedError(`record key value ${String(key)}`);
1968
- }
1969
-
1970
- const inputKey = typeof key === "number" ? key.toString() : key;
1971
- if (inputKey === "__proto__") {
1972
- // `out["__proto__"] = v` would hit the prototype setter on the output.
1973
- throw new ZodCompileUnsupportedError('record key "__proto__"');
1974
- }
1975
- inputKeys.push(inputKey);
1976
-
1977
- const keyConst = addConstant(ctx, key);
1978
- const outKey = generateCheck(doc, ctx, def.keyType, keyConst);
1979
- // 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.
1980
- const valueVar = newVar(ctx);
1981
- doc.write(`const ${valueVar} = ${accessor}[${literalPropertyKey(ctx, inputKey)}];`);
1982
- const valOutput = compileChild(doc, ctx, def.valueType, valueVar);
1983
- doc.write(`${outputVar}[${outKey}] = ${valOutput};`);
1984
- }
1985
-
1986
- // `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__`.
1987
- const knownKeysConst = addConstant(ctx, new Set(inputKeys));
1988
- doc.write(`for (const ${kVar} in ${accessor}) {`);
1989
- doc.indented((d) => {
1990
- d.write(`if (${knownKeysConst}.has(${kVar})) continue;`);
1991
- if (recordDef.mode === "loose") {
1992
- d.write(`if (${kVar} !== "__proto__") ${outputVar}[${kVar}] = ${accessor}[${kVar}];`);
1993
- } else {
1994
- d.write(`return INVALID;`);
1995
- }
1996
- });
1997
- doc.write(`}`);
1998
- return outputVar;
1999
- }
2000
-
2001
- // The bare-string shortcut below only tests `typeof key === "string"`, so it
2002
- // is correct exclusively for a `z.string()` carrying nothing else. A string
2003
- // *format* lives on the def rather than in `checks` — `z.record(z.email(), …)`
2004
- // reads as a plain string here — and coercion rewrites the key, so both have
2005
- // to take the general path or the shortcut accepts keys the runtime rejects.
2006
- const keyDef = def.keyType._zod.def as { type: string; format?: string; coerce?: boolean; checks?: unknown[] };
2007
- const keyIsBareString =
2008
- keyDef.type === "string" && keyDef.format === undefined && !keyDef.coerce && (keyDef.checks?.length ?? 0) === 0;
2009
- if (!keyIsBareString) {
2010
- // A key schema with no value set is a constraint every key must satisfy
2011
- // (`z.email()`, `z.string().min(3)`, `z.number()`, a template literal).
2012
- // The runtime runs it against each own enumerable key and writes the value
2013
- // under the key it produced, so compile it once and call it per key.
2014
- const isLoose = (def as { mode?: string }).mode === "loose";
2015
- // 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
2016
- const keyFn = compileFn(def.keyType);
2017
- if (keyFn.definite === false) ctx.definite = false;
2018
- const keyFast = addConstant(ctx, keyFn);
2019
- const numericConst = addConstant(ctx, regexes.number);
2020
- const outKeyVar = newVar(ctx);
2021
-
2022
- // the body runs once per string key and once per symbol key, since a key schema can accept symbols
2023
- emitOwnKeys(doc, ctx, accessor, kVar, (d) => {
2024
- d.write(`let ${outKeyVar} = ${keyFast}(${kVar});`);
2025
- // 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.
2026
- d.write(
2027
- `if (${outKeyVar} === INVALID && typeof ${kVar} === "string" && ${numericConst}.test(${kVar})) ${outKeyVar} = ${keyFast}(Number(${kVar}));`
2028
- );
2029
- if (isLoose) {
2030
- // A loose record keeps a key its schema rejects, copying the value across unvalidated rather than failing the parse.
2031
- d.write(`if (${outKeyVar} === INVALID) { ${outputVar}[${kVar}] = ${accessor}[${kVar}]; continue; }`);
2032
- } else {
2033
- d.write(`if (${outKeyVar} === INVALID) return INVALID;`);
2034
- }
2035
- // The guard above tested the input key, but the schema can normalize an ordinary key into __proto__; re-check the one actually written under.
2036
- d.write(`if (${outKeyVar} === "__proto__") continue;`);
2037
- // Read once: the raw expression would be evaluated again by the output write below, so an accessor could return an unvalidated second value.
2038
- const valueVar = newVar(ctx);
2039
- d.write(`const ${valueVar} = ${accessor}[${kVar}];`);
2040
- const valOutput = compileChild(d, ctx, def.valueType, valueVar);
2041
- d.write(`${outputVar}[${outKeyVar}] = ${valOutput};`);
2042
- });
2043
- return outputVar;
2044
- }
2045
-
2046
- // 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.
2047
- emitOwnKeys(
2048
- doc,
2049
- ctx,
2050
- accessor,
2051
- kVar,
2052
- (d) => {
2053
- d.write(`const ${valVar} = ${accessor}[${kVar}];`);
2054
- const valOutput = compileChild(d, ctx, def.valueType, valVar);
2055
- d.write(`${outputVar}[${kVar}] = ${valOutput};`);
2056
- },
2057
- `return INVALID;`
2058
- );
2059
-
2060
- return outputVar;
2061
- }
2062
-
2063
- // 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.
2064
- function emitOwnKeys(
2065
- doc: Doc,
2066
- ctx: CompileContext,
2067
- accessor: string,
2068
- kVar: string,
2069
- body: (d: Doc) => void,
2070
- onSymbol?: string
2071
- ): void {
2072
- const propIsEnumerableConst = addConstant(ctx, Object.prototype.propertyIsEnumerable);
2073
- const symsVar = newVar(ctx);
2074
- const keysVar = newVar(ctx);
2075
- const iVar = newVar(ctx);
2076
- doc.write(`const ${symsVar} = Object.getOwnPropertySymbols(${accessor});`);
2077
- doc.write(`const ${keysVar} = Object.getOwnPropertyNames(${accessor});`);
2078
- doc.write(`for (let ${iVar} = 0; ${iVar} < ${keysVar}.length; ${iVar}++) {`);
2079
- doc.indented((d) => {
2080
- d.write(`const ${kVar} = ${keysVar}[${iVar}];`);
2081
- d.write(`if (${kVar} === "__proto__" || !${propIsEnumerableConst}.call(${accessor}, ${kVar})) continue;`);
2082
- body(d);
2083
- });
2084
- doc.write(`}`);
2085
- doc.write(`for (let ${iVar} = 0; ${iVar} < ${symsVar}.length; ${iVar}++) {`);
2086
- doc.indented((d) => {
2087
- d.write(`const ${kVar} = ${symsVar}[${iVar}];`);
2088
- d.write(`if (!${propIsEnumerableConst}.call(${accessor}, ${kVar})) continue;`);
2089
- if (onSymbol) d.write(onSymbol);
2090
- else body(d);
2091
- });
2092
- doc.write(`}`);
2093
- }
2094
-
2095
- function literalPropertyKey(ctx: CompileContext, key: string | symbol): string {
2096
- if (typeof key === "string") return util.esc(key);
2097
- return addConstant(ctx, key);
2098
- }
2099
-
2100
- function generateMapCheck(doc: Doc, ctx: CompileContext, schema: SomeType, accessor: string): string {
2101
- const def = schema._zod.def as unknown as { keyType: SomeType; valueType: SomeType };
2102
-
2103
- doc.write(`if (!(${accessor} instanceof Map)) return INVALID;`);
2104
- generateSizeGate(doc, schema, `${accessor}.size`);
2105
-
2106
- const outputVar = newVar(ctx);
2107
- const kVar = newVar(ctx);
2108
- const valVar = newVar(ctx);
2109
-
2110
- doc.write(`const ${outputVar} = new Map();`);
2111
- doc.write(`for (const [${kVar}, ${valVar}] of ${accessor}) {`);
2112
- doc.indented((d) => {
2113
- const keyOutput = generateCheck(d, ctx, def.keyType, kVar);
2114
- const valOutput = generateCheck(d, ctx, def.valueType, valVar);
2115
- d.write(`${outputVar}.set(${keyOutput}, ${valOutput});`);
2116
- });
2117
- doc.write(`}`);
2118
-
2119
- return outputVar;
2120
- }
2121
-
2122
- function generateSetCheck(doc: Doc, ctx: CompileContext, schema: SomeType, accessor: string): string {
2123
- const def = schema._zod.def as unknown as { valueType: SomeType };
2124
-
2125
- doc.write(`if (!(${accessor} instanceof Set)) return INVALID;`);
2126
- generateSizeGate(doc, schema, `${accessor}.size`);
2127
-
2128
- const outputVar = newVar(ctx);
2129
- const valVar = newVar(ctx);
2130
-
2131
- doc.write(`const ${outputVar} = new Set();`);
2132
- doc.write(`for (const ${valVar} of ${accessor}) {`);
2133
- doc.indented((d) => {
2134
- const valOutput = generateCheck(d, ctx, def.valueType, valVar);
2135
- d.write(`${outputVar}.add(${valOutput});`);
2136
- });
2137
- doc.write(`}`);
2138
-
2139
- return outputVar;
2140
- }
2141
-
2142
- function generateFileCheck(doc: Doc, accessor: string): string {
2143
- // 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.
2144
- doc.write(`if (!(${accessor} instanceof File)) return INVALID;`);
2145
- return accessor;
2146
- }
2147
-
2148
- function generateTemplateLiteralCheck(doc: Doc, ctx: CompileContext, schema: SomeType, accessor: string): string {
2149
- doc.write(`if (typeof ${accessor} !== "string") return INVALID;`);
2150
-
2151
- // Template literal schemas have a pre-computed pattern in _zod.pattern
2152
- const pattern = (schema._zod as unknown as { pattern: RegExp }).pattern;
2153
- if (pattern) {
2154
- const patternConst = addConstant(ctx, pattern);
2155
- doc.write(`${patternConst}.lastIndex = 0;`);
2156
- doc.write(`if (!${patternConst}.test(${accessor})) return INVALID;`);
2157
- }
2158
- return accessor;
2159
- }
2160
-
2161
- function generateLazyCheck(doc: Doc, ctx: CompileContext, schema: SomeType, accessor: string): string {
2162
- // 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
2163
- const def = schema._zod.def as unknown as { getter: () => SomeType };
2164
- const getterConst = addUserConstant(ctx, def.getter);
2165
- const cacheConst = addConstant(ctx, { parser: null as ((input: unknown) => unknown) | null });
2166
-
2167
- doc.write(`if (!${cacheConst}.parser) {`);
2168
- doc.indented((d) => {
2169
- d.write(`const inner = ${getterConst}();`);
2170
- d.write(`${cacheConst}.parser = function(input) {`);
2171
- d.indented((d2) => {
2172
- // 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.
2173
- d2.write(`const result = inner._zod.run({ value: input, issues: [] }, {});`);
2174
- d2.write(`return result.issues.length === 0 ? result.value : INVALID;`);
2175
- });
2176
- d.write(`};`);
2177
- });
2178
- doc.write(`}`);
2179
-
2180
- const outputVar = newVar(ctx);
2181
- doc.write(`const ${outputVar} = ${cacheConst}.parser(${accessor});`);
2182
- doc.write(`if (${outputVar} === INVALID) return INVALID;`);
2183
- return outputVar;
2184
- }
2185
-
2186
- function generatePipeCheck(doc: Doc, ctx: CompileContext, schema: SomeType, accessor: string): string {
2187
- const def = schema._zod.def as unknown as {
2188
- in: SomeType;
2189
- out: SomeType;
2190
- transform?: (value: unknown, payload: unknown) => unknown;
2191
- };
2192
-
2193
- // Validate input type first
2194
- const inputOutput = generateCheck(doc, ctx, def.in, accessor);
2195
-
2196
- if (def.transform) {
2197
- // 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.
2198
- if (isAsyncFunction(def.transform)) {
2199
- throw new ZodCompileAsyncError("z.compile: async transforms in pipes are not supported");
2200
- }
2201
- const transformFn = def.transform;
2202
- const helperFn = (value: unknown): unknown => {
2203
- // `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.
2204
- const fakePayload = { value, issues: [] as unknown[], addIssue: pushIssue };
2205
- // 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.
2206
- const result = transformFn(value, fakePayload as any);
2207
- if (result instanceof Promise) return INVALID;
2208
- return fakePayload.issues.length === 0 ? result : INVALID;
2209
- };
2210
- const helperConst = addUserConstant(ctx, helperFn);
2211
- const transformedVar = newVar(ctx);
2212
- doc.write(`const ${transformedVar} = ${helperConst}(${inputOutput});`);
2213
- doc.write(`if (${transformedVar} === INVALID) return INVALID;`);
2214
- return generateCheck(doc, ctx, def.out, transformedVar);
2215
- } else {
2216
- // No transform - validate output type on same value
2217
- return generateCheck(doc, ctx, def.out, inputOutput);
2218
- }
2219
- }
2220
-
2221
- function isAsyncFunction(fn: unknown): boolean {
2222
- return (
2223
- typeof fn === "function" &&
2224
- (fn.constructor.name === "AsyncFunction" ||
2225
- (fn as { [Symbol.toStringTag]?: string })[Symbol.toStringTag] === "AsyncFunction")
2226
- );
2227
- }
2228
-
2229
- function generateCustomCheck(doc: Doc, ctx: CompileContext, schema: SomeType, accessor: string): string {
2230
- const def = schema._zod.def as unknown as { fn?: (value: unknown) => boolean };
2231
-
2232
- if (def.fn) {
2233
- // Check for async function
2234
- if (isAsyncFunction(def.fn)) {
2235
- throw new ZodCompileAsyncError("z.compile: async custom predicates are not supported");
2236
- }
2237
- // 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.
2238
- const fnConst = addUserConstant(ctx, def.fn);
2239
- const throwAsyncConst = addConstant(ctx, throwAsync);
2240
- const resVar = newVar(ctx);
2241
- doc.write(`const ${resVar} = ${fnConst}(${accessor});`);
2242
- doc.write(`if (${resVar} instanceof Promise) ${throwAsyncConst}();`);
2243
- doc.write(`if (!${resVar}) return INVALID;`);
2244
- } else {
2245
- throw new ZodCompileUnsupportedError("custom schema without a predicate function");
2246
- }
2247
- return accessor;
2248
- }
2249
-
2250
- // 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.
2251
- function runtimeCatch(innerSchema: SomeType, catchValue: () => unknown, value: unknown): unknown {
2252
- const result = (innerSchema._zod.run as (p: ParsePayload, c: ParseContextInternal) => any)(
2253
- { value, issues: [] },
2254
- {} as ParseContextInternal
2255
- );
2256
- if (result && typeof (result as Promise<unknown>).then === "function") return INVALID;
2257
- const r = result as { value: unknown; issues: any[] };
2258
- if (r.issues.length === 0) return r.value;
2259
- // 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.
2260
- return catchValue();
2261
- }
2262
-
2263
- function generateCatchCheck(doc: Doc, ctx: CompileContext, schema: SomeType, accessor: string): string {
2264
- const def = schema._zod.def as unknown as {
2265
- innerType: SomeType;
2266
- catchValue: (ctx: any) => unknown;
2267
- };
2268
-
2269
- // 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.
2270
- if (!(def.catchValue as { [util.CONSTANT_CATCH]?: boolean })[util.CONSTANT_CATCH]) {
2271
- throw new ZodCompileUnsupportedError("catch with a callback (only a constant catch value compiles)", false);
2272
- }
2273
-
2274
- const outputVar = newVar(ctx);
2275
- doc.write(`let ${outputVar} = (() => {`);
2276
- doc.indented((d) => {
2277
- const innerOut = compileChild(d, ctx, def.innerType, accessor);
2278
- d.write(`return ${innerOut};`);
2279
- });
2280
- doc.write(`})();`);
2281
-
2282
- const innerConst = addConstant(ctx, def.innerType);
2283
- const catchConst = addUserConstant(ctx, def.catchValue);
2284
- const catchHelperConst = addConstant(ctx, runtimeCatch);
2285
- doc.write(`if (${outputVar} === INVALID) {`);
2286
- doc.indented((d) => {
2287
- d.write(`${outputVar} = ${catchHelperConst}(${innerConst}, ${catchConst}, ${accessor});`);
2288
- d.write(`if (${outputVar} === INVALID) return INVALID;`);
2289
- });
2290
- doc.write(`}`);
2291
- return outputVar;
2292
- }
2293
-
2294
- function generateTransformCheck(doc: Doc, ctx: CompileContext, schema: SomeType, accessor: string): string {
2295
- const def = schema._zod.def as unknown as {
2296
- transform: (value: unknown, payload: unknown) => unknown;
2297
- };
2298
-
2299
- if (def.transform) {
2300
- // Check for async transform
2301
- if (isAsyncFunction(def.transform)) {
2302
- throw new ZodCompileAsyncError("z.compile: async transforms are not supported");
2303
- }
2304
-
2305
- // Create a helper that runs the transform and returns the result or INVALID on error
2306
- const transformFn = def.transform;
2307
- const helperFn = (value: unknown): unknown => {
2308
- const fakePayload = { value, issues: [] as unknown[], addIssue: pushIssue };
2309
- // 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.
2310
- const result = transformFn(value, fakePayload);
2311
- if (result instanceof Promise) return INVALID;
2312
- return fakePayload.issues.length === 0 ? result : INVALID;
2313
- };
2314
- const helperConst = addUserConstant(ctx, helperFn);
2315
- const outputVar = newVar(ctx);
2316
- doc.write(`const ${outputVar} = ${helperConst}(${accessor});`);
2317
- doc.write(`if (${outputVar} === INVALID) return INVALID;`);
2318
- return outputVar;
2319
- }
2320
-
2321
- return accessor;
2322
- }