@btc-embedded/cdk-extensions 0.10.5 → 0.11.1

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 (350) hide show
  1. package/.jsii +3 -4
  2. package/CHANGELOG.md +26 -0
  3. package/lib/constructs/EventPipe.js +1 -1
  4. package/lib/constructs/S3Bucket.js +1 -1
  5. package/lib/constructs/SecureRestApi.js +1 -1
  6. package/lib/constructs/SecureRestApiV2.js +1 -1
  7. package/lib/extensions/ApiGatewayExtension.js +1 -1
  8. package/lib/extensions/ApplicationLoadBalancerExtension.js +1 -1
  9. package/lib/extensions/ApplicationLoadBalancerExtensionV2.js +1 -1
  10. package/lib/extensions/CloudMapExtension.js +1 -1
  11. package/lib/extensions/DeactivatableServiceExtension.js +1 -1
  12. package/lib/extensions/DocumentDbAccessExtension.js +1 -1
  13. package/lib/extensions/DomainEventMessagingExtension.js +1 -1
  14. package/lib/extensions/ExtraContainerExtension.js +1 -1
  15. package/lib/extensions/HTTPApiExtension.js +1 -1
  16. package/lib/extensions/LogExtension.js +1 -1
  17. package/lib/extensions/ModifyContainerDefinitionExtension.js +1 -1
  18. package/lib/extensions/ModifyTaskDefinitionExtension.js +1 -1
  19. package/lib/extensions/OpenTelemetryExtension.js +1 -1
  20. package/lib/extensions/PostgresDbAccessExtension.js +1 -1
  21. package/lib/extensions/SharedVolumeExtension.js +1 -1
  22. package/lib/extensions/TcpKeepAliveExtension.js +1 -1
  23. package/lib/platform/ApiGateway.js +1 -1
  24. package/lib/platform/ApiGatewayV2.js +2 -2
  25. package/lib/platform/ApplicationLoadBalancer.js +1 -1
  26. package/lib/platform/ApplicationLoadBalancerV2.js +2 -2
  27. package/lib/platform/CognitoUserPool.js +2 -2
  28. package/lib/platform/DefaultUserPoolClients.js +1 -1
  29. package/lib/platform/DocumentDB.js +2 -2
  30. package/lib/platform/PrivateDnsNamespace.js +1 -1
  31. package/lib/platform/ResourceServer.js +1 -1
  32. package/lib/platform/Vpc.js +1 -1
  33. package/lib/utils/BTCLogGroup.js +1 -1
  34. package/lib/utils/StackParameter.js +1 -1
  35. package/lib/utils/configFileParsing.d.ts +17 -9
  36. package/lib/utils/configFileParsing.js +12 -5
  37. package/lib/utils/functions.js +10 -2
  38. package/package.json +5 -6
  39. package/node_modules/zod/LICENSE +0 -21
  40. package/node_modules/zod/README.md +0 -208
  41. package/node_modules/zod/dist/cjs/index.js +0 -22
  42. package/node_modules/zod/dist/cjs/package.json +0 -3
  43. package/node_modules/zod/dist/cjs/v3/ZodError.js +0 -137
  44. package/node_modules/zod/dist/cjs/v3/benchmarks/datetime.js +0 -54
  45. package/node_modules/zod/dist/cjs/v3/benchmarks/discriminatedUnion.js +0 -79
  46. package/node_modules/zod/dist/cjs/v3/benchmarks/index.js +0 -59
  47. package/node_modules/zod/dist/cjs/v3/benchmarks/ipv4.js +0 -54
  48. package/node_modules/zod/dist/cjs/v3/benchmarks/object.js +0 -70
  49. package/node_modules/zod/dist/cjs/v3/benchmarks/primitives.js +0 -159
  50. package/node_modules/zod/dist/cjs/v3/benchmarks/realworld.js +0 -56
  51. package/node_modules/zod/dist/cjs/v3/benchmarks/string.js +0 -55
  52. package/node_modules/zod/dist/cjs/v3/benchmarks/union.js +0 -79
  53. package/node_modules/zod/dist/cjs/v3/errors.js +0 -17
  54. package/node_modules/zod/dist/cjs/v3/external.js +0 -22
  55. package/node_modules/zod/dist/cjs/v3/helpers/enumUtil.js +0 -2
  56. package/node_modules/zod/dist/cjs/v3/helpers/errorUtil.js +0 -9
  57. package/node_modules/zod/dist/cjs/v3/helpers/parseUtil.js +0 -124
  58. package/node_modules/zod/dist/cjs/v3/helpers/partialUtil.js +0 -2
  59. package/node_modules/zod/dist/cjs/v3/helpers/typeAliases.js +0 -2
  60. package/node_modules/zod/dist/cjs/v3/helpers/util.js +0 -137
  61. package/node_modules/zod/dist/cjs/v3/index.js +0 -33
  62. package/node_modules/zod/dist/cjs/v3/locales/en.js +0 -109
  63. package/node_modules/zod/dist/cjs/v3/standard-schema.js +0 -2
  64. package/node_modules/zod/dist/cjs/v3/tests/Mocker.js +0 -57
  65. package/node_modules/zod/dist/cjs/v3/types.js +0 -3773
  66. package/node_modules/zod/dist/cjs/v4/classic/checks.js +0 -32
  67. package/node_modules/zod/dist/cjs/v4/classic/coerce.js +0 -47
  68. package/node_modules/zod/dist/cjs/v4/classic/compat.js +0 -63
  69. package/node_modules/zod/dist/cjs/v4/classic/errors.js +0 -67
  70. package/node_modules/zod/dist/cjs/v4/classic/external.js +0 -69
  71. package/node_modules/zod/dist/cjs/v4/classic/index.js +0 -33
  72. package/node_modules/zod/dist/cjs/v4/classic/iso.js +0 -60
  73. package/node_modules/zod/dist/cjs/v4/classic/parse.js +0 -32
  74. package/node_modules/zod/dist/cjs/v4/classic/schemas.js +0 -1100
  75. package/node_modules/zod/dist/cjs/v4/core/api.js +0 -1021
  76. package/node_modules/zod/dist/cjs/v4/core/checks.js +0 -580
  77. package/node_modules/zod/dist/cjs/v4/core/config.js +0 -10
  78. package/node_modules/zod/dist/cjs/v4/core/core.js +0 -63
  79. package/node_modules/zod/dist/cjs/v4/core/doc.js +0 -39
  80. package/node_modules/zod/dist/cjs/v4/core/errors.js +0 -222
  81. package/node_modules/zod/dist/cjs/v4/core/function.js +0 -102
  82. package/node_modules/zod/dist/cjs/v4/core/index.js +0 -44
  83. package/node_modules/zod/dist/cjs/v4/core/json-schema.js +0 -2
  84. package/node_modules/zod/dist/cjs/v4/core/parse.js +0 -87
  85. package/node_modules/zod/dist/cjs/v4/core/regexes.js +0 -103
  86. package/node_modules/zod/dist/cjs/v4/core/registries.js +0 -47
  87. package/node_modules/zod/dist/cjs/v4/core/schemas.js +0 -1719
  88. package/node_modules/zod/dist/cjs/v4/core/standard-schema.js +0 -2
  89. package/node_modules/zod/dist/cjs/v4/core/to-json-schema.js +0 -833
  90. package/node_modules/zod/dist/cjs/v4/core/util.js +0 -537
  91. package/node_modules/zod/dist/cjs/v4/core/versions.js +0 -8
  92. package/node_modules/zod/dist/cjs/v4/core/zsf.js +0 -172
  93. package/node_modules/zod/dist/cjs/v4/index.js +0 -22
  94. package/node_modules/zod/dist/cjs/v4/locales/ar.js +0 -142
  95. package/node_modules/zod/dist/cjs/v4/locales/az.js +0 -141
  96. package/node_modules/zod/dist/cjs/v4/locales/be.js +0 -190
  97. package/node_modules/zod/dist/cjs/v4/locales/ca.js +0 -144
  98. package/node_modules/zod/dist/cjs/v4/locales/cs.js +0 -161
  99. package/node_modules/zod/dist/cjs/v4/locales/de.js +0 -142
  100. package/node_modules/zod/dist/cjs/v4/locales/en.js +0 -145
  101. package/node_modules/zod/dist/cjs/v4/locales/es.js +0 -143
  102. package/node_modules/zod/dist/cjs/v4/locales/fa.js +0 -148
  103. package/node_modules/zod/dist/cjs/v4/locales/fi.js +0 -148
  104. package/node_modules/zod/dist/cjs/v4/locales/fr-CA.js +0 -143
  105. package/node_modules/zod/dist/cjs/v4/locales/fr.js +0 -142
  106. package/node_modules/zod/dist/cjs/v4/locales/he.js +0 -143
  107. package/node_modules/zod/dist/cjs/v4/locales/hu.js +0 -143
  108. package/node_modules/zod/dist/cjs/v4/locales/id.js +0 -142
  109. package/node_modules/zod/dist/cjs/v4/locales/index.js +0 -82
  110. package/node_modules/zod/dist/cjs/v4/locales/it.js +0 -143
  111. package/node_modules/zod/dist/cjs/v4/locales/ja.js +0 -141
  112. package/node_modules/zod/dist/cjs/v4/locales/kh.js +0 -143
  113. package/node_modules/zod/dist/cjs/v4/locales/ko.js +0 -147
  114. package/node_modules/zod/dist/cjs/v4/locales/mk.js +0 -144
  115. package/node_modules/zod/dist/cjs/v4/locales/ms.js +0 -142
  116. package/node_modules/zod/dist/cjs/v4/locales/nl.js +0 -143
  117. package/node_modules/zod/dist/cjs/v4/locales/no.js +0 -142
  118. package/node_modules/zod/dist/cjs/v4/locales/ota.js +0 -143
  119. package/node_modules/zod/dist/cjs/v4/locales/pl.js +0 -143
  120. package/node_modules/zod/dist/cjs/v4/locales/ps.js +0 -148
  121. package/node_modules/zod/dist/cjs/v4/locales/pt.js +0 -142
  122. package/node_modules/zod/dist/cjs/v4/locales/ru.js +0 -190
  123. package/node_modules/zod/dist/cjs/v4/locales/sl.js +0 -143
  124. package/node_modules/zod/dist/cjs/v4/locales/sv.js +0 -144
  125. package/node_modules/zod/dist/cjs/v4/locales/ta.js +0 -143
  126. package/node_modules/zod/dist/cjs/v4/locales/th.js +0 -143
  127. package/node_modules/zod/dist/cjs/v4/locales/tr.js +0 -143
  128. package/node_modules/zod/dist/cjs/v4/locales/ua.js +0 -143
  129. package/node_modules/zod/dist/cjs/v4/locales/ur.js +0 -143
  130. package/node_modules/zod/dist/cjs/v4/locales/vi.js +0 -142
  131. package/node_modules/zod/dist/cjs/v4/locales/zh-CN.js +0 -142
  132. package/node_modules/zod/dist/cjs/v4/locales/zh-TW.js +0 -143
  133. package/node_modules/zod/dist/cjs/v4/mini/checks.js +0 -34
  134. package/node_modules/zod/dist/cjs/v4/mini/coerce.js +0 -47
  135. package/node_modules/zod/dist/cjs/v4/mini/external.js +0 -61
  136. package/node_modules/zod/dist/cjs/v4/mini/index.js +0 -32
  137. package/node_modules/zod/dist/cjs/v4/mini/iso.js +0 -60
  138. package/node_modules/zod/dist/cjs/v4/mini/parse.js +0 -8
  139. package/node_modules/zod/dist/cjs/v4/mini/schemas.js +0 -831
  140. package/node_modules/zod/dist/esm/index.js +0 -3
  141. package/node_modules/zod/dist/esm/package.json +0 -3
  142. package/node_modules/zod/dist/esm/v3/ZodError.js +0 -132
  143. package/node_modules/zod/dist/esm/v3/benchmarks/datetime.js +0 -49
  144. package/node_modules/zod/dist/esm/v3/benchmarks/discriminatedUnion.js +0 -74
  145. package/node_modules/zod/dist/esm/v3/benchmarks/index.js +0 -54
  146. package/node_modules/zod/dist/esm/v3/benchmarks/ipv4.js +0 -49
  147. package/node_modules/zod/dist/esm/v3/benchmarks/object.js +0 -65
  148. package/node_modules/zod/dist/esm/v3/benchmarks/primitives.js +0 -154
  149. package/node_modules/zod/dist/esm/v3/benchmarks/realworld.js +0 -51
  150. package/node_modules/zod/dist/esm/v3/benchmarks/string.js +0 -50
  151. package/node_modules/zod/dist/esm/v3/benchmarks/union.js +0 -74
  152. package/node_modules/zod/dist/esm/v3/errors.js +0 -9
  153. package/node_modules/zod/dist/esm/v3/external.js +0 -6
  154. package/node_modules/zod/dist/esm/v3/helpers/enumUtil.js +0 -1
  155. package/node_modules/zod/dist/esm/v3/helpers/errorUtil.js +0 -6
  156. package/node_modules/zod/dist/esm/v3/helpers/parseUtil.js +0 -109
  157. package/node_modules/zod/dist/esm/v3/helpers/partialUtil.js +0 -1
  158. package/node_modules/zod/dist/esm/v3/helpers/typeAliases.js +0 -1
  159. package/node_modules/zod/dist/esm/v3/helpers/util.js +0 -133
  160. package/node_modules/zod/dist/esm/v3/index.js +0 -4
  161. package/node_modules/zod/dist/esm/v3/locales/en.js +0 -107
  162. package/node_modules/zod/dist/esm/v3/standard-schema.js +0 -1
  163. package/node_modules/zod/dist/esm/v3/tests/Mocker.js +0 -53
  164. package/node_modules/zod/dist/esm/v3/types.js +0 -3691
  165. package/node_modules/zod/dist/esm/v4/classic/checks.js +0 -1
  166. package/node_modules/zod/dist/esm/v4/classic/coerce.js +0 -17
  167. package/node_modules/zod/dist/esm/v4/classic/compat.js +0 -33
  168. package/node_modules/zod/dist/esm/v4/classic/errors.js +0 -41
  169. package/node_modules/zod/dist/esm/v4/classic/external.js +0 -18
  170. package/node_modules/zod/dist/esm/v4/classic/index.js +0 -4
  171. package/node_modules/zod/dist/esm/v4/classic/iso.js +0 -30
  172. package/node_modules/zod/dist/esm/v4/classic/parse.js +0 -6
  173. package/node_modules/zod/dist/esm/v4/classic/schemas.js +0 -998
  174. package/node_modules/zod/dist/esm/v4/core/api.js +0 -889
  175. package/node_modules/zod/dist/esm/v4/core/checks.js +0 -554
  176. package/node_modules/zod/dist/esm/v4/core/config.js +0 -6
  177. package/node_modules/zod/dist/esm/v4/core/core.js +0 -57
  178. package/node_modules/zod/dist/esm/v4/core/doc.js +0 -35
  179. package/node_modules/zod/dist/esm/v4/core/errors.js +0 -191
  180. package/node_modules/zod/dist/esm/v4/core/function.js +0 -75
  181. package/node_modules/zod/dist/esm/v4/core/index.js +0 -15
  182. package/node_modules/zod/dist/esm/v4/core/json-schema.js +0 -1
  183. package/node_modules/zod/dist/esm/v4/core/parse.js +0 -57
  184. package/node_modules/zod/dist/esm/v4/core/regexes.js +0 -95
  185. package/node_modules/zod/dist/esm/v4/core/registries.js +0 -42
  186. package/node_modules/zod/dist/esm/v4/core/schemas.js +0 -1688
  187. package/node_modules/zod/dist/esm/v4/core/standard-schema.js +0 -1
  188. package/node_modules/zod/dist/esm/v4/core/to-json-schema.js +0 -828
  189. package/node_modules/zod/dist/esm/v4/core/util.js +0 -491
  190. package/node_modules/zod/dist/esm/v4/core/versions.js +0 -5
  191. package/node_modules/zod/dist/esm/v4/core/zsf.js +0 -171
  192. package/node_modules/zod/dist/esm/v4/index.js +0 -3
  193. package/node_modules/zod/dist/esm/v4/locales/ar.js +0 -116
  194. package/node_modules/zod/dist/esm/v4/locales/az.js +0 -115
  195. package/node_modules/zod/dist/esm/v4/locales/be.js +0 -164
  196. package/node_modules/zod/dist/esm/v4/locales/ca.js +0 -118
  197. package/node_modules/zod/dist/esm/v4/locales/cs.js +0 -135
  198. package/node_modules/zod/dist/esm/v4/locales/de.js +0 -116
  199. package/node_modules/zod/dist/esm/v4/locales/en.js +0 -117
  200. package/node_modules/zod/dist/esm/v4/locales/es.js +0 -117
  201. package/node_modules/zod/dist/esm/v4/locales/fa.js +0 -122
  202. package/node_modules/zod/dist/esm/v4/locales/fi.js +0 -122
  203. package/node_modules/zod/dist/esm/v4/locales/fr-CA.js +0 -117
  204. package/node_modules/zod/dist/esm/v4/locales/fr.js +0 -116
  205. package/node_modules/zod/dist/esm/v4/locales/he.js +0 -117
  206. package/node_modules/zod/dist/esm/v4/locales/hu.js +0 -117
  207. package/node_modules/zod/dist/esm/v4/locales/id.js +0 -116
  208. package/node_modules/zod/dist/esm/v4/locales/index.js +0 -38
  209. package/node_modules/zod/dist/esm/v4/locales/it.js +0 -117
  210. package/node_modules/zod/dist/esm/v4/locales/ja.js +0 -115
  211. package/node_modules/zod/dist/esm/v4/locales/kh.js +0 -117
  212. package/node_modules/zod/dist/esm/v4/locales/ko.js +0 -121
  213. package/node_modules/zod/dist/esm/v4/locales/mk.js +0 -118
  214. package/node_modules/zod/dist/esm/v4/locales/ms.js +0 -116
  215. package/node_modules/zod/dist/esm/v4/locales/nl.js +0 -117
  216. package/node_modules/zod/dist/esm/v4/locales/no.js +0 -116
  217. package/node_modules/zod/dist/esm/v4/locales/ota.js +0 -117
  218. package/node_modules/zod/dist/esm/v4/locales/pl.js +0 -117
  219. package/node_modules/zod/dist/esm/v4/locales/ps.js +0 -122
  220. package/node_modules/zod/dist/esm/v4/locales/pt.js +0 -116
  221. package/node_modules/zod/dist/esm/v4/locales/ru.js +0 -164
  222. package/node_modules/zod/dist/esm/v4/locales/sl.js +0 -117
  223. package/node_modules/zod/dist/esm/v4/locales/sv.js +0 -118
  224. package/node_modules/zod/dist/esm/v4/locales/ta.js +0 -117
  225. package/node_modules/zod/dist/esm/v4/locales/th.js +0 -117
  226. package/node_modules/zod/dist/esm/v4/locales/tr.js +0 -115
  227. package/node_modules/zod/dist/esm/v4/locales/ua.js +0 -117
  228. package/node_modules/zod/dist/esm/v4/locales/ur.js +0 -117
  229. package/node_modules/zod/dist/esm/v4/locales/vi.js +0 -116
  230. package/node_modules/zod/dist/esm/v4/locales/zh-CN.js +0 -116
  231. package/node_modules/zod/dist/esm/v4/locales/zh-TW.js +0 -117
  232. package/node_modules/zod/dist/esm/v4/mini/checks.js +0 -1
  233. package/node_modules/zod/dist/esm/v4/mini/coerce.js +0 -17
  234. package/node_modules/zod/dist/esm/v4/mini/external.js +0 -13
  235. package/node_modules/zod/dist/esm/v4/mini/index.js +0 -3
  236. package/node_modules/zod/dist/esm/v4/mini/iso.js +0 -30
  237. package/node_modules/zod/dist/esm/v4/mini/parse.js +0 -1
  238. package/node_modules/zod/dist/esm/v4/mini/schemas.js +0 -725
  239. package/node_modules/zod/dist/types/index.d.ts +0 -3
  240. package/node_modules/zod/dist/types/package.json +0 -3
  241. package/node_modules/zod/dist/types/v3/ZodError.d.ts +0 -164
  242. package/node_modules/zod/dist/types/v3/benchmarks/datetime.d.ts +0 -5
  243. package/node_modules/zod/dist/types/v3/benchmarks/discriminatedUnion.d.ts +0 -5
  244. package/node_modules/zod/dist/types/v3/benchmarks/index.d.ts +0 -1
  245. package/node_modules/zod/dist/types/v3/benchmarks/ipv4.d.ts +0 -5
  246. package/node_modules/zod/dist/types/v3/benchmarks/object.d.ts +0 -5
  247. package/node_modules/zod/dist/types/v3/benchmarks/primitives.d.ts +0 -5
  248. package/node_modules/zod/dist/types/v3/benchmarks/realworld.d.ts +0 -5
  249. package/node_modules/zod/dist/types/v3/benchmarks/string.d.ts +0 -5
  250. package/node_modules/zod/dist/types/v3/benchmarks/union.d.ts +0 -5
  251. package/node_modules/zod/dist/types/v3/errors.d.ts +0 -5
  252. package/node_modules/zod/dist/types/v3/external.d.ts +0 -6
  253. package/node_modules/zod/dist/types/v3/helpers/enumUtil.d.ts +0 -8
  254. package/node_modules/zod/dist/types/v3/helpers/errorUtil.d.ts +0 -9
  255. package/node_modules/zod/dist/types/v3/helpers/parseUtil.d.ts +0 -78
  256. package/node_modules/zod/dist/types/v3/helpers/partialUtil.d.ts +0 -8
  257. package/node_modules/zod/dist/types/v3/helpers/typeAliases.d.ts +0 -2
  258. package/node_modules/zod/dist/types/v3/helpers/util.d.ts +0 -85
  259. package/node_modules/zod/dist/types/v3/index.d.ts +0 -4
  260. package/node_modules/zod/dist/types/v3/locales/en.d.ts +0 -3
  261. package/node_modules/zod/dist/types/v3/standard-schema.d.ts +0 -102
  262. package/node_modules/zod/dist/types/v3/tests/Mocker.d.ts +0 -17
  263. package/node_modules/zod/dist/types/v3/types.d.ts +0 -1031
  264. package/node_modules/zod/dist/types/v4/classic/checks.d.ts +0 -1
  265. package/node_modules/zod/dist/types/v4/classic/coerce.d.ts +0 -17
  266. package/node_modules/zod/dist/types/v4/classic/compat.d.ts +0 -48
  267. package/node_modules/zod/dist/types/v4/classic/errors.d.ts +0 -30
  268. package/node_modules/zod/dist/types/v4/classic/external.d.ts +0 -13
  269. package/node_modules/zod/dist/types/v4/classic/index.d.ts +0 -4
  270. package/node_modules/zod/dist/types/v4/classic/iso.d.ts +0 -22
  271. package/node_modules/zod/dist/types/v4/classic/parse.d.ts +0 -23
  272. package/node_modules/zod/dist/types/v4/classic/schemas.d.ts +0 -624
  273. package/node_modules/zod/dist/types/v4/core/api.d.ts +0 -281
  274. package/node_modules/zod/dist/types/v4/core/checks.d.ts +0 -277
  275. package/node_modules/zod/dist/types/v4/core/config.d.ts +0 -9
  276. package/node_modules/zod/dist/types/v4/core/core.d.ts +0 -47
  277. package/node_modules/zod/dist/types/v4/core/doc.d.ts +0 -14
  278. package/node_modules/zod/dist/types/v4/core/errors.d.ts +0 -204
  279. package/node_modules/zod/dist/types/v4/core/function.d.ts +0 -52
  280. package/node_modules/zod/dist/types/v4/core/index.d.ts +0 -15
  281. package/node_modules/zod/dist/types/v4/core/json-schema.d.ts +0 -87
  282. package/node_modules/zod/dist/types/v4/core/parse.d.ts +0 -25
  283. package/node_modules/zod/dist/types/v4/core/regexes.d.ts +0 -62
  284. package/node_modules/zod/dist/types/v4/core/registries.d.ts +0 -39
  285. package/node_modules/zod/dist/types/v4/core/schemas.d.ts +0 -1005
  286. package/node_modules/zod/dist/types/v4/core/standard-schema.d.ts +0 -55
  287. package/node_modules/zod/dist/types/v4/core/to-json-schema.d.ts +0 -84
  288. package/node_modules/zod/dist/types/v4/core/util.d.ts +0 -183
  289. package/node_modules/zod/dist/types/v4/core/versions.d.ts +0 -5
  290. package/node_modules/zod/dist/types/v4/core/zsf.d.ts +0 -91
  291. package/node_modules/zod/dist/types/v4/index.d.ts +0 -3
  292. package/node_modules/zod/dist/types/v4/locales/ar.d.ts +0 -4
  293. package/node_modules/zod/dist/types/v4/locales/az.d.ts +0 -4
  294. package/node_modules/zod/dist/types/v4/locales/be.d.ts +0 -4
  295. package/node_modules/zod/dist/types/v4/locales/ca.d.ts +0 -4
  296. package/node_modules/zod/dist/types/v4/locales/cs.d.ts +0 -4
  297. package/node_modules/zod/dist/types/v4/locales/de.d.ts +0 -4
  298. package/node_modules/zod/dist/types/v4/locales/en.d.ts +0 -5
  299. package/node_modules/zod/dist/types/v4/locales/es.d.ts +0 -4
  300. package/node_modules/zod/dist/types/v4/locales/fa.d.ts +0 -4
  301. package/node_modules/zod/dist/types/v4/locales/fi.d.ts +0 -4
  302. package/node_modules/zod/dist/types/v4/locales/fr-CA.d.ts +0 -4
  303. package/node_modules/zod/dist/types/v4/locales/fr.d.ts +0 -4
  304. package/node_modules/zod/dist/types/v4/locales/he.d.ts +0 -4
  305. package/node_modules/zod/dist/types/v4/locales/hu.d.ts +0 -4
  306. package/node_modules/zod/dist/types/v4/locales/id.d.ts +0 -4
  307. package/node_modules/zod/dist/types/v4/locales/index.d.ts +0 -38
  308. package/node_modules/zod/dist/types/v4/locales/it.d.ts +0 -4
  309. package/node_modules/zod/dist/types/v4/locales/ja.d.ts +0 -4
  310. package/node_modules/zod/dist/types/v4/locales/kh.d.ts +0 -4
  311. package/node_modules/zod/dist/types/v4/locales/ko.d.ts +0 -4
  312. package/node_modules/zod/dist/types/v4/locales/mk.d.ts +0 -4
  313. package/node_modules/zod/dist/types/v4/locales/ms.d.ts +0 -4
  314. package/node_modules/zod/dist/types/v4/locales/nl.d.ts +0 -4
  315. package/node_modules/zod/dist/types/v4/locales/no.d.ts +0 -4
  316. package/node_modules/zod/dist/types/v4/locales/ota.d.ts +0 -4
  317. package/node_modules/zod/dist/types/v4/locales/pl.d.ts +0 -4
  318. package/node_modules/zod/dist/types/v4/locales/ps.d.ts +0 -4
  319. package/node_modules/zod/dist/types/v4/locales/pt.d.ts +0 -4
  320. package/node_modules/zod/dist/types/v4/locales/ru.d.ts +0 -4
  321. package/node_modules/zod/dist/types/v4/locales/sl.d.ts +0 -4
  322. package/node_modules/zod/dist/types/v4/locales/sv.d.ts +0 -4
  323. package/node_modules/zod/dist/types/v4/locales/ta.d.ts +0 -4
  324. package/node_modules/zod/dist/types/v4/locales/th.d.ts +0 -4
  325. package/node_modules/zod/dist/types/v4/locales/tr.d.ts +0 -5
  326. package/node_modules/zod/dist/types/v4/locales/ua.d.ts +0 -4
  327. package/node_modules/zod/dist/types/v4/locales/ur.d.ts +0 -4
  328. package/node_modules/zod/dist/types/v4/locales/vi.d.ts +0 -4
  329. package/node_modules/zod/dist/types/v4/locales/zh-CN.d.ts +0 -4
  330. package/node_modules/zod/dist/types/v4/locales/zh-TW.d.ts +0 -4
  331. package/node_modules/zod/dist/types/v4/mini/checks.d.ts +0 -1
  332. package/node_modules/zod/dist/types/v4/mini/coerce.d.ts +0 -7
  333. package/node_modules/zod/dist/types/v4/mini/external.d.ts +0 -11
  334. package/node_modules/zod/dist/types/v4/mini/index.d.ts +0 -3
  335. package/node_modules/zod/dist/types/v4/mini/iso.d.ts +0 -22
  336. package/node_modules/zod/dist/types/v4/mini/parse.d.ts +0 -1
  337. package/node_modules/zod/dist/types/v4/mini/schemas.d.ts +0 -351
  338. package/node_modules/zod/package.json +0 -120
  339. package/node_modules/zod/v3/index.d.ts +0 -3
  340. package/node_modules/zod/v3/index.js +0 -1
  341. package/node_modules/zod/v4/core/index.d.ts +0 -1
  342. package/node_modules/zod/v4/core/index.js +0 -1
  343. package/node_modules/zod/v4/index.d.ts +0 -3
  344. package/node_modules/zod/v4/index.js +0 -1
  345. package/node_modules/zod/v4/locales/en.d.ts +0 -2
  346. package/node_modules/zod/v4/locales/en.js +0 -2
  347. package/node_modules/zod/v4/locales/index.d.ts +0 -1
  348. package/node_modules/zod/v4/locales/index.js +0 -1
  349. package/node_modules/zod/v4-mini/index.d.ts +0 -1
  350. package/node_modules/zod/v4-mini/index.js +0 -1
@@ -1,1688 +0,0 @@
1
- import * as checks from "./checks.js";
2
- import * as core from "./core.js";
3
- import { Doc } from "./doc.js";
4
- import { safeParse, safeParseAsync } from "./parse.js";
5
- import * as regexes from "./regexes.js";
6
- import * as util from "./util.js";
7
- import { version } from "./versions.js";
8
- export const $ZodType = /*@__PURE__*/ core.$constructor("$ZodType", (inst, def) => {
9
- var _a;
10
- inst ?? (inst = {});
11
- // avoids issues with using Math.random() in Next.js caching
12
- util.defineLazy(inst._zod, "id", () => def.type + "_" + util.randomString(10));
13
- inst._zod.def = def; // set _def property
14
- inst._zod.bag = inst._zod.bag || {}; // initialize _bag object
15
- inst._zod.version = version;
16
- const checks = [...(inst._zod.def.checks ?? [])];
17
- // if inst is itself a checks.$ZodCheck, run it as a check
18
- if (inst._zod.traits.has("$ZodCheck")) {
19
- checks.unshift(inst);
20
- }
21
- //
22
- for (const ch of checks) {
23
- for (const fn of ch._zod.onattach) {
24
- fn(inst);
25
- }
26
- }
27
- if (checks.length === 0) {
28
- // deferred initializer
29
- // inst._zod.parse is not yet defined
30
- (_a = inst._zod).deferred ?? (_a.deferred = []);
31
- inst._zod.deferred?.push(() => {
32
- inst._zod.run = inst._zod.parse;
33
- });
34
- }
35
- else {
36
- const runChecks = (payload, checks, ctx) => {
37
- let isAborted = util.aborted(payload);
38
- let asyncResult;
39
- for (const ch of checks) {
40
- if (ch._zod.when) {
41
- const shouldRun = ch._zod.when(payload);
42
- if (!shouldRun)
43
- continue;
44
- }
45
- else if (isAborted) {
46
- continue;
47
- }
48
- const currLen = payload.issues.length;
49
- const _ = ch._zod.check(payload);
50
- if (_ instanceof Promise && ctx?.async === false) {
51
- throw new core.$ZodAsyncError();
52
- }
53
- if (asyncResult || _ instanceof Promise) {
54
- asyncResult = (asyncResult ?? Promise.resolve()).then(async () => {
55
- await _;
56
- const nextLen = payload.issues.length;
57
- if (nextLen === currLen)
58
- return;
59
- if (!isAborted)
60
- isAborted = util.aborted(payload, currLen);
61
- });
62
- }
63
- else {
64
- const nextLen = payload.issues.length;
65
- if (nextLen === currLen)
66
- continue;
67
- if (!isAborted)
68
- isAborted = util.aborted(payload, currLen);
69
- }
70
- }
71
- if (asyncResult) {
72
- return asyncResult.then(() => {
73
- return payload;
74
- });
75
- }
76
- return payload;
77
- };
78
- inst._zod.run = (payload, ctx) => {
79
- const result = inst._zod.parse(payload, ctx);
80
- if (result instanceof Promise) {
81
- if (ctx.async === false)
82
- throw new core.$ZodAsyncError();
83
- return result.then((result) => runChecks(result, checks, ctx));
84
- }
85
- return runChecks(result, checks, ctx);
86
- };
87
- }
88
- inst["~standard"] = {
89
- validate: (value) => {
90
- try {
91
- const r = safeParse(inst, value);
92
- return r.success ? { value: r.data } : { issues: r.error?.issues };
93
- }
94
- catch (_) {
95
- return safeParseAsync(inst, value).then((r) => (r.success ? { value: r.data } : { issues: r.error?.issues }));
96
- }
97
- },
98
- vendor: "zod",
99
- version: 1,
100
- };
101
- });
102
- export { clone } from "./util.js";
103
- export const $ZodString = /*@__PURE__*/ core.$constructor("$ZodString", (inst, def) => {
104
- $ZodType.init(inst, def);
105
- inst._zod.pattern = [...(inst?._zod.bag?.patterns ?? [])].pop() ?? regexes.string(inst._zod.bag);
106
- inst._zod.parse = (payload, _) => {
107
- if (def.coerce)
108
- try {
109
- payload.value = String(payload.value);
110
- }
111
- catch (_) { }
112
- if (typeof payload.value === "string")
113
- return payload;
114
- payload.issues.push({
115
- expected: "string",
116
- code: "invalid_type",
117
- input: payload.value,
118
- inst,
119
- });
120
- return payload;
121
- };
122
- });
123
- export const $ZodStringFormat = /*@__PURE__*/ core.$constructor("$ZodStringFormat", (inst, def) => {
124
- // check initialization must come first
125
- checks.$ZodCheckStringFormat.init(inst, def);
126
- $ZodString.init(inst, def);
127
- });
128
- export const $ZodGUID = /*@__PURE__*/ core.$constructor("$ZodGUID", (inst, def) => {
129
- def.pattern ?? (def.pattern = regexes.guid);
130
- $ZodStringFormat.init(inst, def);
131
- });
132
- export const $ZodUUID = /*@__PURE__*/ core.$constructor("$ZodUUID", (inst, def) => {
133
- if (def.version) {
134
- const versionMap = {
135
- v1: 1,
136
- v2: 2,
137
- v3: 3,
138
- v4: 4,
139
- v5: 5,
140
- v6: 6,
141
- v7: 7,
142
- v8: 8,
143
- };
144
- const v = versionMap[def.version];
145
- if (v === undefined)
146
- throw new Error(`Invalid UUID version: "${def.version}"`);
147
- def.pattern ?? (def.pattern = regexes.uuid(v));
148
- }
149
- else
150
- def.pattern ?? (def.pattern = regexes.uuid());
151
- $ZodStringFormat.init(inst, def);
152
- });
153
- export const $ZodEmail = /*@__PURE__*/ core.$constructor("$ZodEmail", (inst, def) => {
154
- def.pattern ?? (def.pattern = regexes.email);
155
- $ZodStringFormat.init(inst, def);
156
- });
157
- export const $ZodURL = /*@__PURE__*/ core.$constructor("$ZodURL", (inst, def) => {
158
- $ZodStringFormat.init(inst, def);
159
- inst._zod.check = (payload) => {
160
- try {
161
- const url = new URL(payload.value);
162
- if (def.hostname) {
163
- def.hostname.lastIndex = 0;
164
- if (!def.hostname.test(url.hostname)) {
165
- payload.issues.push({
166
- code: "invalid_format",
167
- format: "url",
168
- note: "Invalid hostname",
169
- pattern: regexes.hostname.source,
170
- input: payload.value,
171
- inst,
172
- continue: !def.abort,
173
- });
174
- }
175
- }
176
- if (def.protocol) {
177
- def.protocol.lastIndex = 0;
178
- if (!def.protocol.test(url.protocol.endsWith(":") ? url.protocol.slice(0, -1) : url.protocol)) {
179
- payload.issues.push({
180
- code: "invalid_format",
181
- format: "url",
182
- note: "Invalid protocol",
183
- pattern: def.protocol.source,
184
- input: payload.value,
185
- inst,
186
- continue: !def.abort,
187
- });
188
- }
189
- }
190
- return;
191
- }
192
- catch (_) {
193
- payload.issues.push({
194
- code: "invalid_format",
195
- format: "url",
196
- input: payload.value,
197
- inst,
198
- continue: !def.abort,
199
- });
200
- }
201
- };
202
- });
203
- export const $ZodEmoji = /*@__PURE__*/ core.$constructor("$ZodEmoji", (inst, def) => {
204
- def.pattern ?? (def.pattern = regexes.emoji());
205
- $ZodStringFormat.init(inst, def);
206
- });
207
- export const $ZodNanoID = /*@__PURE__*/ core.$constructor("$ZodNanoID", (inst, def) => {
208
- def.pattern ?? (def.pattern = regexes.nanoid);
209
- $ZodStringFormat.init(inst, def);
210
- });
211
- export const $ZodCUID = /*@__PURE__*/ core.$constructor("$ZodCUID", (inst, def) => {
212
- def.pattern ?? (def.pattern = regexes.cuid);
213
- $ZodStringFormat.init(inst, def);
214
- });
215
- export const $ZodCUID2 = /*@__PURE__*/ core.$constructor("$ZodCUID2", (inst, def) => {
216
- def.pattern ?? (def.pattern = regexes.cuid2);
217
- $ZodStringFormat.init(inst, def);
218
- });
219
- export const $ZodULID = /*@__PURE__*/ core.$constructor("$ZodULID", (inst, def) => {
220
- def.pattern ?? (def.pattern = regexes.ulid);
221
- $ZodStringFormat.init(inst, def);
222
- });
223
- export const $ZodXID = /*@__PURE__*/ core.$constructor("$ZodXID", (inst, def) => {
224
- def.pattern ?? (def.pattern = regexes.xid);
225
- $ZodStringFormat.init(inst, def);
226
- });
227
- export const $ZodKSUID = /*@__PURE__*/ core.$constructor("$ZodKSUID", (inst, def) => {
228
- def.pattern ?? (def.pattern = regexes.ksuid);
229
- $ZodStringFormat.init(inst, def);
230
- });
231
- export const $ZodISODateTime = /*@__PURE__*/ core.$constructor("$ZodISODateTime", (inst, def) => {
232
- def.pattern ?? (def.pattern = regexes.datetime(def));
233
- $ZodStringFormat.init(inst, def);
234
- const _super = inst._zod.check;
235
- });
236
- export const $ZodISODate = /*@__PURE__*/ core.$constructor("$ZodISODate", (inst, def) => {
237
- def.pattern ?? (def.pattern = regexes.date);
238
- $ZodStringFormat.init(inst, def);
239
- });
240
- export const $ZodISOTime = /*@__PURE__*/ core.$constructor("$ZodISOTime", (inst, def) => {
241
- def.pattern ?? (def.pattern = regexes.time(def));
242
- $ZodStringFormat.init(inst, def);
243
- const _super = inst._zod.check;
244
- });
245
- export const $ZodISODuration = /*@__PURE__*/ core.$constructor("$ZodISODuration", (inst, def) => {
246
- def.pattern ?? (def.pattern = regexes.duration);
247
- $ZodStringFormat.init(inst, def);
248
- });
249
- export const $ZodIPv4 = /*@__PURE__*/ core.$constructor("$ZodIPv4", (inst, def) => {
250
- def.pattern ?? (def.pattern = regexes.ipv4);
251
- $ZodStringFormat.init(inst, def);
252
- inst._zod.onattach.push((inst) => {
253
- const bag = inst._zod.bag;
254
- bag.format = `ipv4`;
255
- });
256
- });
257
- export const $ZodIPv6 = /*@__PURE__*/ core.$constructor("$ZodIPv6", (inst, def) => {
258
- def.pattern ?? (def.pattern = regexes.ipv6);
259
- $ZodStringFormat.init(inst, def);
260
- inst._zod.onattach.push((inst) => {
261
- const bag = inst._zod.bag;
262
- bag.format = `ipv6`;
263
- });
264
- inst._zod.check = (payload) => {
265
- try {
266
- new URL(`http://[${payload.value}]`);
267
- // return;
268
- }
269
- catch {
270
- payload.issues.push({
271
- code: "invalid_format",
272
- format: "ipv6",
273
- input: payload.value,
274
- inst,
275
- continue: !def.abort,
276
- });
277
- }
278
- };
279
- });
280
- export const $ZodCIDRv4 = /*@__PURE__*/ core.$constructor("$ZodCIDRv4", (inst, def) => {
281
- def.pattern ?? (def.pattern = regexes.cidrv4);
282
- $ZodStringFormat.init(inst, def);
283
- });
284
- export const $ZodCIDRv6 = /*@__PURE__*/ core.$constructor("$ZodCIDRv6", (inst, def) => {
285
- def.pattern ?? (def.pattern = regexes.cidrv6); // not used for validation
286
- $ZodStringFormat.init(inst, def);
287
- inst._zod.check = (payload) => {
288
- const [address, prefix] = payload.value.split("/");
289
- try {
290
- if (!prefix)
291
- throw new Error();
292
- const prefixNum = Number(prefix);
293
- if (`${prefixNum}` !== prefix)
294
- throw new Error();
295
- if (prefixNum < 0 || prefixNum > 128)
296
- throw new Error();
297
- new URL(`http://[${address}]`);
298
- }
299
- catch {
300
- payload.issues.push({
301
- code: "invalid_format",
302
- format: "cidrv6",
303
- input: payload.value,
304
- inst,
305
- continue: !def.abort,
306
- });
307
- }
308
- };
309
- });
310
- ////////////////////////////// ZodBase64 //////////////////////////////
311
- export function isValidBase64(data) {
312
- if (data === "")
313
- return true;
314
- if (data.length % 4 !== 0)
315
- return false;
316
- try {
317
- atob(data);
318
- return true;
319
- }
320
- catch {
321
- return false;
322
- }
323
- }
324
- export const $ZodBase64 = /*@__PURE__*/ core.$constructor("$ZodBase64", (inst, def) => {
325
- def.pattern ?? (def.pattern = regexes.base64);
326
- $ZodStringFormat.init(inst, def);
327
- inst._zod.onattach.push((inst) => {
328
- inst._zod.bag.contentEncoding = "base64";
329
- });
330
- inst._zod.check = (payload) => {
331
- if (isValidBase64(payload.value))
332
- return;
333
- payload.issues.push({
334
- code: "invalid_format",
335
- format: "base64",
336
- input: payload.value,
337
- inst,
338
- continue: !def.abort,
339
- });
340
- };
341
- });
342
- ////////////////////////////// ZodBase64 //////////////////////////////
343
- export function isValidBase64URL(data) {
344
- if (!regexes.base64url.test(data))
345
- return false;
346
- const base64 = data.replace(/[-_]/g, (c) => (c === "-" ? "+" : "/"));
347
- const padded = base64.padEnd(Math.ceil(base64.length / 4) * 4, "=");
348
- return isValidBase64(padded);
349
- }
350
- export const $ZodBase64URL = /*@__PURE__*/ core.$constructor("$ZodBase64URL", (inst, def) => {
351
- def.pattern ?? (def.pattern = regexes.base64url);
352
- $ZodStringFormat.init(inst, def);
353
- inst._zod.onattach.push((inst) => {
354
- inst._zod.bag.contentEncoding = "base64url";
355
- });
356
- inst._zod.check = (payload) => {
357
- if (isValidBase64URL(payload.value))
358
- return;
359
- payload.issues.push({
360
- code: "invalid_format",
361
- format: "base64url",
362
- input: payload.value,
363
- inst,
364
- continue: !def.abort,
365
- });
366
- };
367
- });
368
- export const $ZodE164 = /*@__PURE__*/ core.$constructor("$ZodE164", (inst, def) => {
369
- def.pattern ?? (def.pattern = regexes.e164);
370
- $ZodStringFormat.init(inst, def);
371
- });
372
- ////////////////////////////// ZodJWT //////////////////////////////
373
- export function isValidJWT(token, algorithm = null) {
374
- try {
375
- const tokensParts = token.split(".");
376
- if (tokensParts.length !== 3)
377
- return false;
378
- const [header] = tokensParts;
379
- const parsedHeader = JSON.parse(atob(header));
380
- if ("typ" in parsedHeader && parsedHeader?.typ !== "JWT")
381
- return false;
382
- if (!parsedHeader.alg)
383
- return false;
384
- if (algorithm && (!("alg" in parsedHeader) || parsedHeader.alg !== algorithm))
385
- return false;
386
- return true;
387
- }
388
- catch {
389
- return false;
390
- }
391
- }
392
- export const $ZodJWT = /*@__PURE__*/ core.$constructor("$ZodJWT", (inst, def) => {
393
- $ZodStringFormat.init(inst, def);
394
- inst._zod.check = (payload) => {
395
- if (isValidJWT(payload.value, def.alg))
396
- return;
397
- payload.issues.push({
398
- code: "invalid_format",
399
- format: "jwt",
400
- input: payload.value,
401
- inst,
402
- continue: !def.abort,
403
- });
404
- };
405
- });
406
- export const $ZodNumber = /*@__PURE__*/ core.$constructor("$ZodNumber", (inst, def) => {
407
- $ZodType.init(inst, def);
408
- inst._zod.pattern = inst._zod.bag.pattern ?? regexes.number;
409
- inst._zod.parse = (payload, _ctx) => {
410
- if (def.coerce)
411
- try {
412
- payload.value = Number(payload.value);
413
- }
414
- catch (_) { }
415
- const input = payload.value;
416
- if (typeof input === "number" && !Number.isNaN(input) && Number.isFinite(input)) {
417
- return payload;
418
- }
419
- const received = typeof input === "number"
420
- ? Number.isNaN(input)
421
- ? "NaN"
422
- : !Number.isFinite(input)
423
- ? "Infinity"
424
- : undefined
425
- : undefined;
426
- payload.issues.push({
427
- expected: "number",
428
- code: "invalid_type",
429
- input,
430
- inst,
431
- ...(received ? { received } : {}),
432
- });
433
- return payload;
434
- };
435
- });
436
- export const $ZodNumberFormat = /*@__PURE__*/ core.$constructor("$ZodNumber", (inst, def) => {
437
- checks.$ZodCheckNumberFormat.init(inst, def);
438
- $ZodNumber.init(inst, def); // no format checksp
439
- });
440
- export const $ZodBoolean = /*@__PURE__*/ core.$constructor("$ZodBoolean", (inst, def) => {
441
- $ZodType.init(inst, def);
442
- inst._zod.pattern = regexes.boolean;
443
- inst._zod.parse = (payload, _ctx) => {
444
- if (def.coerce)
445
- try {
446
- payload.value = Boolean(payload.value);
447
- }
448
- catch (_) { }
449
- const input = payload.value;
450
- if (typeof input === "boolean")
451
- return payload;
452
- payload.issues.push({
453
- expected: "boolean",
454
- code: "invalid_type",
455
- input,
456
- inst,
457
- });
458
- return payload;
459
- };
460
- });
461
- export const $ZodBigInt = /*@__PURE__*/ core.$constructor("$ZodBigInt", (inst, def) => {
462
- $ZodType.init(inst, def);
463
- inst._zod.pattern = regexes.bigint;
464
- inst._zod.parse = (payload, _ctx) => {
465
- if (def.coerce)
466
- try {
467
- payload.value = BigInt(payload.value);
468
- }
469
- catch (_) { }
470
- const { value: input } = payload;
471
- if (typeof input === "bigint")
472
- return payload;
473
- payload.issues.push({
474
- expected: "bigint",
475
- code: "invalid_type",
476
- input,
477
- inst,
478
- });
479
- return payload;
480
- };
481
- });
482
- export const $ZodBigIntFormat = /*@__PURE__*/ core.$constructor("$ZodBigInt", (inst, def) => {
483
- checks.$ZodCheckBigIntFormat.init(inst, def);
484
- $ZodBigInt.init(inst, def); // no format checks
485
- });
486
- export const $ZodSymbol = /*@__PURE__*/ core.$constructor("$ZodSymbol", (inst, def) => {
487
- $ZodType.init(inst, def);
488
- inst._zod.parse = (payload, _ctx) => {
489
- const { value: input } = payload;
490
- if (typeof input === "symbol")
491
- return payload;
492
- payload.issues.push({
493
- expected: "symbol",
494
- code: "invalid_type",
495
- input,
496
- inst,
497
- });
498
- return payload;
499
- };
500
- });
501
- export const $ZodUndefined = /*@__PURE__*/ core.$constructor("$ZodUndefined", (inst, def) => {
502
- $ZodType.init(inst, def);
503
- inst._zod.pattern = regexes.undefined;
504
- inst._zod.values = new Set([undefined]);
505
- inst._zod.parse = (payload, _ctx) => {
506
- const { value: input } = payload;
507
- if (typeof input === "undefined")
508
- return payload;
509
- payload.issues.push({
510
- expected: "undefined",
511
- code: "invalid_type",
512
- input,
513
- inst,
514
- });
515
- return payload;
516
- };
517
- });
518
- export const $ZodNull = /*@__PURE__*/ core.$constructor("$ZodNull", (inst, def) => {
519
- $ZodType.init(inst, def);
520
- inst._zod.pattern = regexes.null;
521
- inst._zod.values = new Set([null]);
522
- inst._zod.parse = (payload, _ctx) => {
523
- const { value: input } = payload;
524
- if (input === null)
525
- return payload;
526
- payload.issues.push({
527
- expected: "null",
528
- code: "invalid_type",
529
- input,
530
- inst,
531
- });
532
- return payload;
533
- };
534
- });
535
- export const $ZodAny = /*@__PURE__*/ core.$constructor("$ZodAny", (inst, def) => {
536
- $ZodType.init(inst, def);
537
- inst._zod.parse = (payload) => payload;
538
- });
539
- export const $ZodUnknown = /*@__PURE__*/ core.$constructor("$ZodUnknown", (inst, def) => {
540
- $ZodType.init(inst, def);
541
- inst._zod.parse = (payload) => payload;
542
- });
543
- export const $ZodNever = /*@__PURE__*/ core.$constructor("$ZodNever", (inst, def) => {
544
- $ZodType.init(inst, def);
545
- inst._zod.parse = (payload, _ctx) => {
546
- payload.issues.push({
547
- expected: "never",
548
- code: "invalid_type",
549
- input: payload.value,
550
- inst,
551
- });
552
- return payload;
553
- };
554
- });
555
- export const $ZodVoid = /*@__PURE__*/ core.$constructor("$ZodVoid", (inst, def) => {
556
- $ZodType.init(inst, def);
557
- inst._zod.parse = (payload, _ctx) => {
558
- const { value: input } = payload;
559
- if (typeof input === "undefined")
560
- return payload;
561
- payload.issues.push({
562
- expected: "void",
563
- code: "invalid_type",
564
- input,
565
- inst,
566
- });
567
- return payload;
568
- };
569
- });
570
- export const $ZodDate = /*@__PURE__*/ core.$constructor("$ZodDate", (inst, def) => {
571
- $ZodType.init(inst, def);
572
- inst._zod.parse = (payload, _ctx) => {
573
- if (def.coerce) {
574
- try {
575
- payload.value = new Date(payload.value);
576
- }
577
- catch (_err) { }
578
- }
579
- const input = payload.value;
580
- const isDate = input instanceof Date;
581
- const isValidDate = isDate && !Number.isNaN(input.getTime());
582
- if (isValidDate)
583
- return payload;
584
- payload.issues.push({
585
- expected: "date",
586
- code: "invalid_type",
587
- input,
588
- ...(isDate ? { received: "Invalid Date" } : {}),
589
- inst,
590
- });
591
- return payload;
592
- };
593
- });
594
- function handleArrayResult(result, final, index) {
595
- if (result.issues.length) {
596
- final.issues.push(...util.prefixIssues(index, result.issues));
597
- }
598
- final.value[index] = result.value;
599
- }
600
- export const $ZodArray = /*@__PURE__*/ core.$constructor("$ZodArray", (inst, def) => {
601
- $ZodType.init(inst, def);
602
- inst._zod.parse = (payload, ctx) => {
603
- const input = payload.value;
604
- if (!Array.isArray(input)) {
605
- payload.issues.push({
606
- expected: "array",
607
- code: "invalid_type",
608
- input,
609
- inst,
610
- });
611
- return payload;
612
- }
613
- payload.value = Array(input.length);
614
- const proms = [];
615
- for (let i = 0; i < input.length; i++) {
616
- const item = input[i];
617
- const result = def.element._zod.run({
618
- value: item,
619
- issues: [],
620
- }, ctx);
621
- if (result instanceof Promise) {
622
- proms.push(result.then((result) => handleArrayResult(result, payload, i)));
623
- }
624
- else {
625
- handleArrayResult(result, payload, i);
626
- }
627
- }
628
- if (proms.length) {
629
- return Promise.all(proms).then(() => payload);
630
- }
631
- return payload; //handleArrayResultsAsync(parseResults, final);
632
- };
633
- });
634
- function handleObjectResult(result, final, key) {
635
- // if(isOptional)
636
- if (result.issues.length) {
637
- final.issues.push(...util.prefixIssues(key, result.issues));
638
- }
639
- final.value[key] = result.value;
640
- }
641
- function handleOptionalObjectResult(result, final, key, input) {
642
- if (result.issues.length) {
643
- // validation failed against value schema
644
- if (input[key] === undefined) {
645
- // if input was undefined, ignore the error
646
- if (key in input) {
647
- final.value[key] = undefined;
648
- }
649
- else {
650
- final.value[key] = result.value;
651
- }
652
- }
653
- else {
654
- final.issues.push(...util.prefixIssues(key, result.issues));
655
- }
656
- }
657
- else if (result.value === undefined) {
658
- // validation returned `undefined`
659
- if (key in input)
660
- final.value[key] = undefined;
661
- }
662
- else {
663
- // non-undefined value
664
- final.value[key] = result.value;
665
- }
666
- }
667
- export const $ZodObject = /*@__PURE__*/ core.$constructor("$ZodObject", (inst, def) => {
668
- // requires cast because technically $ZodObject doesn't extend
669
- $ZodType.init(inst, def);
670
- const _normalized = util.cached(() => {
671
- const keys = Object.keys(def.shape);
672
- for (const k of keys) {
673
- if (!(def.shape[k] instanceof $ZodType)) {
674
- throw new Error(`Invalid element at key "${k}": expected a Zod schema`);
675
- }
676
- }
677
- const okeys = util.optionalKeys(def.shape);
678
- return {
679
- shape: def.shape,
680
- keys,
681
- keySet: new Set(keys),
682
- numKeys: keys.length,
683
- optionalKeys: new Set(okeys),
684
- };
685
- });
686
- util.defineLazy(inst._zod, "propValues", () => {
687
- const shape = def.shape;
688
- const propValues = {};
689
- for (const key in shape) {
690
- const field = shape[key]._zod;
691
- if (field.values) {
692
- propValues[key] ?? (propValues[key] = new Set());
693
- for (const v of field.values)
694
- propValues[key].add(v);
695
- }
696
- }
697
- return propValues;
698
- });
699
- const generateFastpass = (shape) => {
700
- const doc = new Doc(["shape", "payload", "ctx"]);
701
- const { keys, optionalKeys } = _normalized.value;
702
- const parseStr = (key) => {
703
- const k = util.esc(key);
704
- return `shape[${k}]._zod.run({ value: input[${k}], issues: [] }, ctx)`;
705
- };
706
- doc.write(`const input = payload.value;`);
707
- const ids = Object.create(null);
708
- for (const key of keys) {
709
- ids[key] = util.randomString(15);
710
- }
711
- // A: preserve key order {
712
- doc.write(`const newResult = {}`);
713
- for (const key of keys) {
714
- if (optionalKeys.has(key)) {
715
- const id = ids[key];
716
- doc.write(`const ${id} = ${parseStr(key)};`);
717
- const k = util.esc(key);
718
- doc.write(`
719
- if (${id}.issues.length) {
720
- if (input[${k}] === undefined) {
721
- if (${k} in input) {
722
- newResult[${k}] = undefined;
723
- }
724
- } else {
725
- payload.issues = payload.issues.concat(
726
- ${id}.issues.map((iss) => ({
727
- ...iss,
728
- path: iss.path ? [${k}, ...iss.path] : [${k}],
729
- }))
730
- );
731
- }
732
- } else if (${id}.value === undefined) {
733
- if (${k} in input) newResult[${k}] = undefined;
734
- } else {
735
- newResult[${k}] = ${id}.value;
736
- }
737
- `);
738
- }
739
- else {
740
- const id = ids[key];
741
- // const id = ids[key];
742
- doc.write(`const ${id} = ${parseStr(key)};`);
743
- doc.write(`
744
- if (${id}.issues.length) payload.issues = payload.issues.concat(${id}.issues.map(iss => ({
745
- ...iss,
746
- path: iss.path ? [${util.esc(key)}, ...iss.path] : [${util.esc(key)}]
747
- })));`);
748
- doc.write(`newResult[${util.esc(key)}] = ${id}.value`);
749
- }
750
- }
751
- doc.write(`payload.value = newResult;`);
752
- doc.write(`return payload;`);
753
- const fn = doc.compile();
754
- return (payload, ctx) => fn(shape, payload, ctx);
755
- };
756
- let fastpass;
757
- const isObject = util.isObject;
758
- const jit = !core.globalConfig.jitless;
759
- const allowsEval = util.allowsEval;
760
- const fastEnabled = jit && allowsEval.value; // && !def.catchall;
761
- const { catchall } = def;
762
- let value;
763
- inst._zod.parse = (payload, ctx) => {
764
- value ?? (value = _normalized.value);
765
- const input = payload.value;
766
- if (!isObject(input)) {
767
- payload.issues.push({
768
- expected: "object",
769
- code: "invalid_type",
770
- input,
771
- inst,
772
- });
773
- return payload;
774
- }
775
- const proms = [];
776
- if (jit && fastEnabled && ctx?.async === false && ctx.jitless !== true) {
777
- // always synchronous
778
- if (!fastpass)
779
- fastpass = generateFastpass(def.shape);
780
- payload = fastpass(payload, ctx);
781
- }
782
- else {
783
- payload.value = {};
784
- const shape = value.shape;
785
- for (const key of value.keys) {
786
- const el = shape[key];
787
- // do not add omitted optional keys
788
- // if (!(key in input)) {
789
- // if (optionalKeys.has(key)) continue;
790
- // payload.issues.push({
791
- // code: "invalid_type",
792
- // path: [key],
793
- // expected: "nonoptional",
794
- // note: `Missing required key: "${key}"`,
795
- // input,
796
- // inst,
797
- // });
798
- // }
799
- const r = el._zod.run({ value: input[key], issues: [] }, ctx);
800
- const isOptional = el._zod.optin === "optional" && el._zod.optout === "optional";
801
- if (r instanceof Promise) {
802
- proms.push(r.then((r) => isOptional ? handleOptionalObjectResult(r, payload, key, input) : handleObjectResult(r, payload, key)));
803
- }
804
- else if (isOptional) {
805
- handleOptionalObjectResult(r, payload, key, input);
806
- }
807
- else {
808
- handleObjectResult(r, payload, key);
809
- }
810
- }
811
- }
812
- if (!catchall) {
813
- // return payload;
814
- return proms.length ? Promise.all(proms).then(() => payload) : payload;
815
- }
816
- const unrecognized = [];
817
- // iterate over input keys
818
- const keySet = value.keySet;
819
- const _catchall = catchall._zod;
820
- const t = _catchall.def.type;
821
- for (const key of Object.keys(input)) {
822
- if (keySet.has(key))
823
- continue;
824
- if (t === "never") {
825
- unrecognized.push(key);
826
- continue;
827
- }
828
- const r = _catchall.run({ value: input[key], issues: [] }, ctx);
829
- if (r instanceof Promise) {
830
- proms.push(r.then((r) => handleObjectResult(r, payload, key)));
831
- }
832
- else {
833
- handleObjectResult(r, payload, key);
834
- }
835
- }
836
- if (unrecognized.length) {
837
- payload.issues.push({
838
- code: "unrecognized_keys",
839
- keys: unrecognized,
840
- input,
841
- inst,
842
- });
843
- }
844
- if (!proms.length)
845
- return payload;
846
- return Promise.all(proms).then(() => {
847
- return payload;
848
- });
849
- };
850
- });
851
- function handleUnionResults(results, final, inst, ctx) {
852
- for (const result of results) {
853
- if (result.issues.length === 0) {
854
- final.value = result.value;
855
- return final;
856
- }
857
- }
858
- final.issues.push({
859
- code: "invalid_union",
860
- input: final.value,
861
- inst,
862
- errors: results.map((result) => result.issues.map((iss) => util.finalizeIssue(iss, ctx, core.config()))),
863
- });
864
- return final;
865
- }
866
- export const $ZodUnion = /*@__PURE__*/ core.$constructor("$ZodUnion", (inst, def) => {
867
- $ZodType.init(inst, def);
868
- util.defineLazy(inst._zod, "values", () => {
869
- if (def.options.every((o) => o._zod.values)) {
870
- return new Set(def.options.flatMap((option) => Array.from(option._zod.values)));
871
- }
872
- return undefined;
873
- });
874
- util.defineLazy(inst._zod, "pattern", () => {
875
- if (def.options.every((o) => o._zod.pattern)) {
876
- const patterns = def.options.map((o) => o._zod.pattern);
877
- return new RegExp(`^(${patterns.map((p) => util.cleanRegex(p.source)).join("|")})$`);
878
- }
879
- return undefined;
880
- });
881
- inst._zod.parse = (payload, ctx) => {
882
- let async = false;
883
- const results = [];
884
- for (const option of def.options) {
885
- const result = option._zod.run({
886
- value: payload.value,
887
- issues: [],
888
- }, ctx);
889
- if (result instanceof Promise) {
890
- results.push(result);
891
- async = true;
892
- }
893
- else {
894
- if (result.issues.length === 0)
895
- return result;
896
- results.push(result);
897
- }
898
- }
899
- if (!async)
900
- return handleUnionResults(results, payload, inst, ctx);
901
- return Promise.all(results).then((results) => {
902
- return handleUnionResults(results, payload, inst, ctx);
903
- });
904
- };
905
- });
906
- export const $ZodDiscriminatedUnion =
907
- /*@__PURE__*/
908
- core.$constructor("$ZodDiscriminatedUnion", (inst, def) => {
909
- $ZodUnion.init(inst, def);
910
- const _super = inst._zod.parse;
911
- util.defineLazy(inst._zod, "propValues", () => {
912
- const propValues = {};
913
- for (const option of def.options) {
914
- const pv = option._zod.propValues;
915
- if (!pv || Object.keys(pv).length === 0)
916
- throw new Error(`Invalid discriminated union option at index "${def.options.indexOf(option)}"`);
917
- for (const [k, v] of Object.entries(pv)) {
918
- if (!propValues[k])
919
- propValues[k] = new Set();
920
- for (const val of v) {
921
- propValues[k].add(val);
922
- }
923
- }
924
- }
925
- return propValues;
926
- });
927
- const disc = util.cached(() => {
928
- const opts = def.options;
929
- const map = new Map();
930
- for (const o of opts) {
931
- const values = o._zod.propValues[def.discriminator];
932
- if (!values || values.size === 0)
933
- throw new Error(`Invalid discriminated union option at index "${def.options.indexOf(o)}"`);
934
- for (const v of values) {
935
- if (map.has(v)) {
936
- throw new Error(`Duplicate discriminator value "${String(v)}"`);
937
- }
938
- map.set(v, o);
939
- }
940
- }
941
- return map;
942
- });
943
- inst._zod.parse = (payload, ctx) => {
944
- const input = payload.value;
945
- if (!util.isObject(input)) {
946
- payload.issues.push({
947
- code: "invalid_type",
948
- expected: "object",
949
- input,
950
- inst,
951
- });
952
- return payload;
953
- }
954
- const opt = disc.value.get(input?.[def.discriminator]);
955
- if (opt) {
956
- return opt._zod.run(payload, ctx);
957
- }
958
- if (def.unionFallback) {
959
- return _super(payload, ctx);
960
- }
961
- // no matching discriminator
962
- payload.issues.push({
963
- code: "invalid_union",
964
- errors: [],
965
- note: "No matching discriminator",
966
- input,
967
- path: [def.discriminator],
968
- inst,
969
- });
970
- return payload;
971
- };
972
- });
973
- export const $ZodIntersection = /*@__PURE__*/ core.$constructor("$ZodIntersection", (inst, def) => {
974
- $ZodType.init(inst, def);
975
- inst._zod.parse = (payload, ctx) => {
976
- const { value: input } = payload;
977
- const left = def.left._zod.run({ value: input, issues: [] }, ctx);
978
- const right = def.right._zod.run({ value: input, issues: [] }, ctx);
979
- const async = left instanceof Promise || right instanceof Promise;
980
- if (async) {
981
- return Promise.all([left, right]).then(([left, right]) => {
982
- return handleIntersectionResults(payload, left, right);
983
- });
984
- }
985
- return handleIntersectionResults(payload, left, right);
986
- };
987
- });
988
- function mergeValues(a, b) {
989
- // const aType = parse.t(a);
990
- // const bType = parse.t(b);
991
- if (a === b) {
992
- return { valid: true, data: a };
993
- }
994
- if (a instanceof Date && b instanceof Date && +a === +b) {
995
- return { valid: true, data: a };
996
- }
997
- if (util.isPlainObject(a) && util.isPlainObject(b)) {
998
- const bKeys = Object.keys(b);
999
- const sharedKeys = Object.keys(a).filter((key) => bKeys.indexOf(key) !== -1);
1000
- const newObj = { ...a, ...b };
1001
- for (const key of sharedKeys) {
1002
- const sharedValue = mergeValues(a[key], b[key]);
1003
- if (!sharedValue.valid) {
1004
- return {
1005
- valid: false,
1006
- mergeErrorPath: [key, ...sharedValue.mergeErrorPath],
1007
- };
1008
- }
1009
- newObj[key] = sharedValue.data;
1010
- }
1011
- return { valid: true, data: newObj };
1012
- }
1013
- if (Array.isArray(a) && Array.isArray(b)) {
1014
- if (a.length !== b.length) {
1015
- return { valid: false, mergeErrorPath: [] };
1016
- }
1017
- const newArray = [];
1018
- for (let index = 0; index < a.length; index++) {
1019
- const itemA = a[index];
1020
- const itemB = b[index];
1021
- const sharedValue = mergeValues(itemA, itemB);
1022
- if (!sharedValue.valid) {
1023
- return {
1024
- valid: false,
1025
- mergeErrorPath: [index, ...sharedValue.mergeErrorPath],
1026
- };
1027
- }
1028
- newArray.push(sharedValue.data);
1029
- }
1030
- return { valid: true, data: newArray };
1031
- }
1032
- return { valid: false, mergeErrorPath: [] };
1033
- }
1034
- function handleIntersectionResults(result, left, right) {
1035
- if (left.issues.length) {
1036
- result.issues.push(...left.issues);
1037
- }
1038
- if (right.issues.length) {
1039
- result.issues.push(...right.issues);
1040
- }
1041
- if (util.aborted(result))
1042
- return result;
1043
- const merged = mergeValues(left.value, right.value);
1044
- if (!merged.valid) {
1045
- throw new Error(`Unmergable intersection. Error path: ` + `${JSON.stringify(merged.mergeErrorPath)}`);
1046
- }
1047
- result.value = merged.data;
1048
- return result;
1049
- }
1050
- export const $ZodTuple = /*@__PURE__*/ core.$constructor("$ZodTuple", (inst, def) => {
1051
- $ZodType.init(inst, def);
1052
- const items = def.items;
1053
- const optStart = items.length - [...items].reverse().findIndex((item) => item._zod.optin !== "optional");
1054
- inst._zod.parse = (payload, ctx) => {
1055
- const input = payload.value;
1056
- if (!Array.isArray(input)) {
1057
- payload.issues.push({
1058
- input,
1059
- inst,
1060
- expected: "tuple",
1061
- code: "invalid_type",
1062
- });
1063
- return payload;
1064
- }
1065
- payload.value = [];
1066
- const proms = [];
1067
- if (!def.rest) {
1068
- const tooBig = input.length > items.length;
1069
- const tooSmall = input.length < optStart - 1;
1070
- if (tooBig || tooSmall) {
1071
- payload.issues.push({
1072
- input,
1073
- inst,
1074
- origin: "array",
1075
- ...(tooBig ? { code: "too_big", maximum: items.length } : { code: "too_small", minimum: items.length }),
1076
- });
1077
- return payload;
1078
- }
1079
- }
1080
- let i = -1;
1081
- for (const item of items) {
1082
- i++;
1083
- if (i >= input.length)
1084
- if (i >= optStart)
1085
- continue;
1086
- const result = item._zod.run({
1087
- value: input[i],
1088
- issues: [],
1089
- }, ctx);
1090
- if (result instanceof Promise) {
1091
- proms.push(result.then((result) => handleTupleResult(result, payload, i)));
1092
- }
1093
- else {
1094
- handleTupleResult(result, payload, i);
1095
- }
1096
- }
1097
- if (def.rest) {
1098
- const rest = input.slice(items.length);
1099
- for (const el of rest) {
1100
- i++;
1101
- const result = def.rest._zod.run({
1102
- value: el,
1103
- issues: [],
1104
- }, ctx);
1105
- if (result instanceof Promise) {
1106
- proms.push(result.then((result) => handleTupleResult(result, payload, i)));
1107
- }
1108
- else {
1109
- handleTupleResult(result, payload, i);
1110
- }
1111
- }
1112
- }
1113
- if (proms.length)
1114
- return Promise.all(proms).then(() => payload);
1115
- return payload;
1116
- };
1117
- });
1118
- function handleTupleResult(result, final, index) {
1119
- if (result.issues.length) {
1120
- final.issues.push(...util.prefixIssues(index, result.issues));
1121
- }
1122
- final.value[index] = result.value;
1123
- }
1124
- export const $ZodRecord = /*@__PURE__*/ core.$constructor("$ZodRecord", (inst, def) => {
1125
- $ZodType.init(inst, def);
1126
- inst._zod.parse = (payload, ctx) => {
1127
- const input = payload.value;
1128
- if (!util.isPlainObject(input)) {
1129
- payload.issues.push({
1130
- expected: "record",
1131
- code: "invalid_type",
1132
- input,
1133
- inst,
1134
- });
1135
- return payload;
1136
- }
1137
- const proms = [];
1138
- if (def.keyType._zod.values) {
1139
- const values = def.keyType._zod.values;
1140
- payload.value = {};
1141
- for (const key of values) {
1142
- if (typeof key === "string" || typeof key === "number" || typeof key === "symbol") {
1143
- const result = def.valueType._zod.run({ value: input[key], issues: [] }, ctx);
1144
- if (result instanceof Promise) {
1145
- proms.push(result.then((result) => {
1146
- if (result.issues.length) {
1147
- payload.issues.push(...util.prefixIssues(key, result.issues));
1148
- }
1149
- payload.value[key] = result.value;
1150
- }));
1151
- }
1152
- else {
1153
- if (result.issues.length) {
1154
- payload.issues.push(...util.prefixIssues(key, result.issues));
1155
- }
1156
- payload.value[key] = result.value;
1157
- }
1158
- }
1159
- }
1160
- let unrecognized;
1161
- for (const key in input) {
1162
- if (!values.has(key)) {
1163
- unrecognized = unrecognized ?? [];
1164
- unrecognized.push(key);
1165
- }
1166
- }
1167
- if (unrecognized && unrecognized.length > 0) {
1168
- payload.issues.push({
1169
- code: "unrecognized_keys",
1170
- input,
1171
- inst,
1172
- keys: unrecognized,
1173
- });
1174
- }
1175
- }
1176
- else {
1177
- payload.value = {};
1178
- for (const key of Reflect.ownKeys(input)) {
1179
- if (key === "__proto__")
1180
- continue;
1181
- const keyResult = def.keyType._zod.run({ value: key, issues: [] }, ctx);
1182
- if (keyResult instanceof Promise) {
1183
- throw new Error("Async schemas not supported in object keys currently");
1184
- }
1185
- if (keyResult.issues.length) {
1186
- payload.issues.push({
1187
- origin: "record",
1188
- code: "invalid_key",
1189
- issues: keyResult.issues.map((iss) => util.finalizeIssue(iss, ctx, core.config())),
1190
- input: key,
1191
- path: [key],
1192
- inst,
1193
- });
1194
- payload.value[keyResult.value] = keyResult.value;
1195
- continue;
1196
- }
1197
- const result = def.valueType._zod.run({ value: input[key], issues: [] }, ctx);
1198
- if (result instanceof Promise) {
1199
- proms.push(result.then((result) => {
1200
- if (result.issues.length) {
1201
- payload.issues.push(...util.prefixIssues(key, result.issues));
1202
- }
1203
- payload.value[keyResult.value] = result.value;
1204
- }));
1205
- }
1206
- else {
1207
- if (result.issues.length) {
1208
- payload.issues.push(...util.prefixIssues(key, result.issues));
1209
- }
1210
- payload.value[keyResult.value] = result.value;
1211
- }
1212
- }
1213
- }
1214
- if (proms.length) {
1215
- return Promise.all(proms).then(() => payload);
1216
- }
1217
- return payload;
1218
- };
1219
- });
1220
- export const $ZodMap = /*@__PURE__*/ core.$constructor("$ZodMap", (inst, def) => {
1221
- $ZodType.init(inst, def);
1222
- inst._zod.parse = (payload, ctx) => {
1223
- const input = payload.value;
1224
- if (!(input instanceof Map)) {
1225
- payload.issues.push({
1226
- expected: "map",
1227
- code: "invalid_type",
1228
- input,
1229
- inst,
1230
- });
1231
- return payload;
1232
- }
1233
- const proms = [];
1234
- payload.value = new Map();
1235
- for (const [key, value] of input) {
1236
- const keyResult = def.keyType._zod.run({ value: key, issues: [] }, ctx);
1237
- const valueResult = def.valueType._zod.run({ value: value, issues: [] }, ctx);
1238
- if (keyResult instanceof Promise || valueResult instanceof Promise) {
1239
- proms.push(Promise.all([keyResult, valueResult]).then(([keyResult, valueResult]) => {
1240
- handleMapResult(keyResult, valueResult, payload, key, input, inst, ctx);
1241
- }));
1242
- }
1243
- else {
1244
- handleMapResult(keyResult, valueResult, payload, key, input, inst, ctx);
1245
- }
1246
- }
1247
- if (proms.length)
1248
- return Promise.all(proms).then(() => payload);
1249
- return payload;
1250
- };
1251
- });
1252
- function handleMapResult(keyResult, valueResult, final, key, input, inst, ctx) {
1253
- if (keyResult.issues.length) {
1254
- if (util.propertyKeyTypes.has(typeof key)) {
1255
- final.issues.push(...util.prefixIssues(key, keyResult.issues));
1256
- }
1257
- else {
1258
- final.issues.push({
1259
- origin: "map",
1260
- code: "invalid_key",
1261
- input,
1262
- inst,
1263
- issues: keyResult.issues.map((iss) => util.finalizeIssue(iss, ctx, core.config())),
1264
- });
1265
- }
1266
- }
1267
- if (valueResult.issues.length) {
1268
- if (util.propertyKeyTypes.has(typeof key)) {
1269
- final.issues.push(...util.prefixIssues(key, valueResult.issues));
1270
- }
1271
- else {
1272
- final.issues.push({
1273
- origin: "map",
1274
- code: "invalid_element",
1275
- input,
1276
- inst,
1277
- key: key,
1278
- issues: valueResult.issues.map((iss) => util.finalizeIssue(iss, ctx, core.config())),
1279
- });
1280
- }
1281
- }
1282
- final.value.set(keyResult.value, valueResult.value);
1283
- }
1284
- export const $ZodSet = /*@__PURE__*/ core.$constructor("$ZodSet", (inst, def) => {
1285
- $ZodType.init(inst, def);
1286
- inst._zod.parse = (payload, ctx) => {
1287
- const input = payload.value;
1288
- if (!(input instanceof Set)) {
1289
- payload.issues.push({
1290
- input,
1291
- inst,
1292
- expected: "set",
1293
- code: "invalid_type",
1294
- });
1295
- return payload;
1296
- }
1297
- const proms = [];
1298
- payload.value = new Set();
1299
- for (const item of input) {
1300
- const result = def.valueType._zod.run({ value: item, issues: [] }, ctx);
1301
- if (result instanceof Promise) {
1302
- proms.push(result.then((result) => handleSetResult(result, payload)));
1303
- }
1304
- else
1305
- handleSetResult(result, payload);
1306
- }
1307
- if (proms.length)
1308
- return Promise.all(proms).then(() => payload);
1309
- return payload;
1310
- };
1311
- });
1312
- function handleSetResult(result, final) {
1313
- if (result.issues.length) {
1314
- final.issues.push(...result.issues);
1315
- }
1316
- final.value.add(result.value);
1317
- }
1318
- export const $ZodEnum = /*@__PURE__*/ core.$constructor("$ZodEnum", (inst, def) => {
1319
- $ZodType.init(inst, def);
1320
- const values = util.getEnumValues(def.entries);
1321
- inst._zod.values = new Set(values);
1322
- inst._zod.pattern = new RegExp(`^(${values
1323
- .filter((k) => util.propertyKeyTypes.has(typeof k))
1324
- .map((o) => (typeof o === "string" ? util.escapeRegex(o) : o.toString()))
1325
- .join("|")})$`);
1326
- inst._zod.parse = (payload, _ctx) => {
1327
- const input = payload.value;
1328
- if (inst._zod.values.has(input)) {
1329
- return payload;
1330
- }
1331
- payload.issues.push({
1332
- code: "invalid_value",
1333
- values,
1334
- input,
1335
- inst,
1336
- });
1337
- return payload;
1338
- };
1339
- });
1340
- export const $ZodLiteral = /*@__PURE__*/ core.$constructor("$ZodLiteral", (inst, def) => {
1341
- $ZodType.init(inst, def);
1342
- inst._zod.values = new Set(def.values);
1343
- inst._zod.pattern = new RegExp(`^(${def.values
1344
- .map((o) => (typeof o === "string" ? util.escapeRegex(o) : o ? o.toString() : String(o)))
1345
- .join("|")})$`);
1346
- inst._zod.parse = (payload, _ctx) => {
1347
- const input = payload.value;
1348
- if (inst._zod.values.has(input)) {
1349
- return payload;
1350
- }
1351
- payload.issues.push({
1352
- code: "invalid_value",
1353
- values: def.values,
1354
- input,
1355
- inst,
1356
- });
1357
- return payload;
1358
- };
1359
- });
1360
- export const $ZodFile = /*@__PURE__*/ core.$constructor("$ZodFile", (inst, def) => {
1361
- $ZodType.init(inst, def);
1362
- inst._zod.parse = (payload, _ctx) => {
1363
- const input = payload.value;
1364
- if (input instanceof File)
1365
- return payload;
1366
- payload.issues.push({
1367
- expected: "file",
1368
- code: "invalid_type",
1369
- input,
1370
- inst,
1371
- });
1372
- return payload;
1373
- };
1374
- });
1375
- export const $ZodTransform = /*@__PURE__*/ core.$constructor("$ZodTransform", (inst, def) => {
1376
- $ZodType.init(inst, def);
1377
- inst._zod.parse = (payload, _ctx) => {
1378
- const _out = def.transform(payload.value, payload);
1379
- if (_ctx.async) {
1380
- const output = _out instanceof Promise ? _out : Promise.resolve(_out);
1381
- return output.then((output) => {
1382
- payload.value = output;
1383
- return payload;
1384
- });
1385
- }
1386
- if (_out instanceof Promise) {
1387
- throw new core.$ZodAsyncError();
1388
- }
1389
- payload.value = _out;
1390
- return payload;
1391
- };
1392
- });
1393
- export const $ZodOptional = /*@__PURE__*/ core.$constructor("$ZodOptional", (inst, def) => {
1394
- $ZodType.init(inst, def);
1395
- inst._zod.optin = "optional";
1396
- inst._zod.optout = "optional";
1397
- util.defineLazy(inst._zod, "values", () => {
1398
- return def.innerType._zod.values ? new Set([...def.innerType._zod.values, undefined]) : undefined;
1399
- });
1400
- util.defineLazy(inst._zod, "pattern", () => {
1401
- const pattern = def.innerType._zod.pattern;
1402
- return pattern ? new RegExp(`^(${util.cleanRegex(pattern.source)})?$`) : undefined;
1403
- });
1404
- inst._zod.parse = (payload, ctx) => {
1405
- if (payload.value === undefined) {
1406
- return payload;
1407
- }
1408
- return def.innerType._zod.run(payload, ctx);
1409
- };
1410
- });
1411
- export const $ZodNullable = /*@__PURE__*/ core.$constructor("$ZodNullable", (inst, def) => {
1412
- $ZodType.init(inst, def);
1413
- util.defineLazy(inst._zod, "optin", () => def.innerType._zod.optin);
1414
- util.defineLazy(inst._zod, "optout", () => def.innerType._zod.optout);
1415
- util.defineLazy(inst._zod, "pattern", () => {
1416
- const pattern = def.innerType._zod.pattern;
1417
- return pattern ? new RegExp(`^(${util.cleanRegex(pattern.source)}|null)$`) : undefined;
1418
- });
1419
- util.defineLazy(inst._zod, "values", () => {
1420
- return def.innerType._zod.values ? new Set([...def.innerType._zod.values, null]) : undefined;
1421
- });
1422
- inst._zod.parse = (payload, ctx) => {
1423
- if (payload.value === null)
1424
- return payload;
1425
- return def.innerType._zod.run(payload, ctx);
1426
- };
1427
- });
1428
- export const $ZodDefault = /*@__PURE__*/ core.$constructor("$ZodDefault", (inst, def) => {
1429
- $ZodType.init(inst, def);
1430
- // inst._zod.qin = "true";
1431
- inst._zod.optin = "optional";
1432
- util.defineLazy(inst._zod, "values", () => def.innerType._zod.values);
1433
- inst._zod.parse = (payload, ctx) => {
1434
- if (payload.value === undefined) {
1435
- payload.value = def.defaultValue;
1436
- /**
1437
- * $ZodDefault always returns the default value immediately.
1438
- * It doesn't pass the default value into the validator ("prefault"). There's no reason to pass the default value through validation. The validity of the default is enforced by TypeScript statically. Otherwise, it's the responsibility of the user to ensure the default is valid. In the case of pipes with divergent in/out types, you can specify the default on the `in` schema of your ZodPipe to set a "prefault" for the pipe. */
1439
- return payload;
1440
- }
1441
- const result = def.innerType._zod.run(payload, ctx);
1442
- if (result instanceof Promise) {
1443
- return result.then((result) => handleDefaultResult(result, def));
1444
- }
1445
- return handleDefaultResult(result, def);
1446
- };
1447
- });
1448
- function handleDefaultResult(payload, def) {
1449
- if (payload.value === undefined) {
1450
- payload.value = def.defaultValue;
1451
- }
1452
- return payload;
1453
- }
1454
- export const $ZodPrefault = /*@__PURE__*/ core.$constructor("$ZodPrefault", (inst, def) => {
1455
- $ZodType.init(inst, def);
1456
- inst._zod.optin = "optional";
1457
- util.defineLazy(inst._zod, "values", () => def.innerType._zod.values);
1458
- inst._zod.parse = (payload, ctx) => {
1459
- if (payload.value === undefined) {
1460
- payload.value = def.defaultValue;
1461
- }
1462
- return def.innerType._zod.run(payload, ctx);
1463
- };
1464
- });
1465
- export const $ZodNonOptional = /*@__PURE__*/ core.$constructor("$ZodNonOptional", (inst, def) => {
1466
- $ZodType.init(inst, def);
1467
- util.defineLazy(inst._zod, "values", () => {
1468
- const v = def.innerType._zod.values;
1469
- return v ? new Set([...v].filter((x) => x !== undefined)) : undefined;
1470
- });
1471
- inst._zod.parse = (payload, ctx) => {
1472
- const result = def.innerType._zod.run(payload, ctx);
1473
- if (result instanceof Promise) {
1474
- return result.then((result) => handleNonOptionalResult(result, inst));
1475
- }
1476
- return handleNonOptionalResult(result, inst);
1477
- };
1478
- });
1479
- function handleNonOptionalResult(payload, inst) {
1480
- if (!payload.issues.length && payload.value === undefined) {
1481
- payload.issues.push({
1482
- code: "invalid_type",
1483
- expected: "nonoptional",
1484
- input: payload.value,
1485
- inst,
1486
- });
1487
- }
1488
- return payload;
1489
- }
1490
- export const $ZodSuccess = /*@__PURE__*/ core.$constructor("$ZodSuccess", (inst, def) => {
1491
- $ZodType.init(inst, def);
1492
- inst._zod.parse = (payload, ctx) => {
1493
- const result = def.innerType._zod.run(payload, ctx);
1494
- if (result instanceof Promise) {
1495
- return result.then((result) => {
1496
- payload.value = result.issues.length === 0;
1497
- return payload;
1498
- });
1499
- }
1500
- payload.value = result.issues.length === 0;
1501
- return payload;
1502
- };
1503
- });
1504
- export const $ZodCatch = /*@__PURE__*/ core.$constructor("$ZodCatch", (inst, def) => {
1505
- $ZodType.init(inst, def);
1506
- util.defineLazy(inst._zod, "optin", () => def.innerType._zod.optin);
1507
- util.defineLazy(inst._zod, "optout", () => def.innerType._zod.optout);
1508
- util.defineLazy(inst._zod, "values", () => def.innerType._zod.values);
1509
- inst._zod.parse = (payload, ctx) => {
1510
- const result = def.innerType._zod.run(payload, ctx);
1511
- if (result instanceof Promise) {
1512
- return result.then((result) => {
1513
- payload.value = result.value;
1514
- if (result.issues.length) {
1515
- payload.value = def.catchValue({
1516
- ...payload,
1517
- error: {
1518
- issues: result.issues.map((iss) => util.finalizeIssue(iss, ctx, core.config())),
1519
- },
1520
- input: payload.value,
1521
- });
1522
- payload.issues = [];
1523
- }
1524
- return payload;
1525
- });
1526
- }
1527
- payload.value = result.value;
1528
- if (result.issues.length) {
1529
- payload.value = def.catchValue({
1530
- ...payload,
1531
- error: {
1532
- issues: result.issues.map((iss) => util.finalizeIssue(iss, ctx, core.config())),
1533
- },
1534
- input: payload.value,
1535
- });
1536
- payload.issues = [];
1537
- }
1538
- return payload;
1539
- };
1540
- });
1541
- export const $ZodNaN = /*@__PURE__*/ core.$constructor("$ZodNaN", (inst, def) => {
1542
- $ZodType.init(inst, def);
1543
- inst._zod.parse = (payload, _ctx) => {
1544
- if (typeof payload.value !== "number" || !Number.isNaN(payload.value)) {
1545
- payload.issues.push({
1546
- input: payload.value,
1547
- inst,
1548
- expected: "nan",
1549
- code: "invalid_type",
1550
- });
1551
- return payload;
1552
- }
1553
- return payload;
1554
- };
1555
- });
1556
- export const $ZodPipe = /*@__PURE__*/ core.$constructor("$ZodPipe", (inst, def) => {
1557
- $ZodType.init(inst, def);
1558
- util.defineLazy(inst._zod, "values", () => def.in._zod.values);
1559
- util.defineLazy(inst._zod, "optin", () => def.in._zod.optin);
1560
- util.defineLazy(inst._zod, "optout", () => def.out._zod.optout);
1561
- inst._zod.parse = (payload, ctx) => {
1562
- const left = def.in._zod.run(payload, ctx);
1563
- if (left instanceof Promise) {
1564
- return left.then((left) => handlePipeResult(left, def, ctx));
1565
- }
1566
- return handlePipeResult(left, def, ctx);
1567
- };
1568
- });
1569
- function handlePipeResult(left, def, ctx) {
1570
- if (util.aborted(left)) {
1571
- return left;
1572
- }
1573
- return def.out._zod.run({ value: left.value, issues: left.issues }, ctx);
1574
- }
1575
- export const $ZodReadonly = /*@__PURE__*/ core.$constructor("$ZodReadonly", (inst, def) => {
1576
- $ZodType.init(inst, def);
1577
- util.defineLazy(inst._zod, "propValues", () => def.innerType._zod.propValues);
1578
- util.defineLazy(inst._zod, "optin", () => def.innerType._zod.optin);
1579
- util.defineLazy(inst._zod, "optout", () => def.innerType._zod.optout);
1580
- inst._zod.parse = (payload, ctx) => {
1581
- const result = def.innerType._zod.run(payload, ctx);
1582
- if (result instanceof Promise) {
1583
- return result.then(handleReadonlyResult);
1584
- }
1585
- return handleReadonlyResult(result);
1586
- };
1587
- });
1588
- function handleReadonlyResult(payload) {
1589
- payload.value = Object.freeze(payload.value);
1590
- return payload;
1591
- }
1592
- export const $ZodTemplateLiteral = /*@__PURE__*/ core.$constructor("$ZodTemplateLiteral", (inst, def) => {
1593
- $ZodType.init(inst, def);
1594
- const regexParts = [];
1595
- for (const part of def.parts) {
1596
- if (part instanceof $ZodType) {
1597
- if (!part._zod.pattern) {
1598
- // if (!source)
1599
- throw new Error(`Invalid template literal part, no pattern found: ${[...part._zod.traits].shift()}`);
1600
- }
1601
- const source = part._zod.pattern instanceof RegExp ? part._zod.pattern.source : part._zod.pattern;
1602
- if (!source)
1603
- throw new Error(`Invalid template literal part: ${part._zod.traits}`);
1604
- const start = source.startsWith("^") ? 1 : 0;
1605
- const end = source.endsWith("$") ? source.length - 1 : source.length;
1606
- regexParts.push(source.slice(start, end));
1607
- }
1608
- else if (part === null || util.primitiveTypes.has(typeof part)) {
1609
- regexParts.push(util.escapeRegex(`${part}`));
1610
- }
1611
- else {
1612
- throw new Error(`Invalid template literal part: ${part}`);
1613
- }
1614
- }
1615
- inst._zod.pattern = new RegExp(`^${regexParts.join("")}$`);
1616
- inst._zod.parse = (payload, _ctx) => {
1617
- if (typeof payload.value !== "string") {
1618
- payload.issues.push({
1619
- input: payload.value,
1620
- inst,
1621
- expected: "template_literal",
1622
- code: "invalid_type",
1623
- });
1624
- return payload;
1625
- }
1626
- inst._zod.pattern.lastIndex = 0;
1627
- if (!inst._zod.pattern.test(payload.value)) {
1628
- payload.issues.push({
1629
- input: payload.value,
1630
- inst,
1631
- code: "invalid_format",
1632
- format: "template_literal",
1633
- pattern: inst._zod.pattern.source,
1634
- });
1635
- return payload;
1636
- }
1637
- return payload;
1638
- };
1639
- });
1640
- export const $ZodPromise = /*@__PURE__*/ core.$constructor("$ZodPromise", (inst, def) => {
1641
- $ZodType.init(inst, def);
1642
- inst._zod.parse = (payload, ctx) => {
1643
- return Promise.resolve(payload.value).then((inner) => def.innerType._zod.run({ value: inner, issues: [] }, ctx));
1644
- };
1645
- });
1646
- export const $ZodLazy = /*@__PURE__*/ core.$constructor("$ZodLazy", (inst, def) => {
1647
- $ZodType.init(inst, def);
1648
- util.defineLazy(inst._zod, "innerType", () => def.getter());
1649
- util.defineLazy(inst._zod, "pattern", () => inst._zod.innerType._zod.pattern);
1650
- util.defineLazy(inst._zod, "propValues", () => inst._zod.innerType._zod.propValues);
1651
- util.defineLazy(inst._zod, "optin", () => inst._zod.innerType._zod.optin);
1652
- util.defineLazy(inst._zod, "optout", () => inst._zod.innerType._zod.optout);
1653
- inst._zod.parse = (payload, ctx) => {
1654
- const inner = inst._zod.innerType;
1655
- return inner._zod.run(payload, ctx);
1656
- };
1657
- });
1658
- export const $ZodCustom = /*@__PURE__*/ core.$constructor("$ZodCustom", (inst, def) => {
1659
- checks.$ZodCheck.init(inst, def);
1660
- $ZodType.init(inst, def);
1661
- inst._zod.parse = (payload, _) => {
1662
- return payload;
1663
- };
1664
- inst._zod.check = (payload) => {
1665
- const input = payload.value;
1666
- const r = def.fn(input);
1667
- if (r instanceof Promise) {
1668
- return r.then((r) => handleRefineResult(r, payload, input, inst));
1669
- }
1670
- handleRefineResult(r, payload, input, inst);
1671
- return;
1672
- };
1673
- });
1674
- function handleRefineResult(result, payload, input, inst) {
1675
- if (!result) {
1676
- const _iss = {
1677
- code: "custom",
1678
- input,
1679
- inst, // incorporates params.error into issue reporting
1680
- path: [...(inst._zod.def.path ?? [])], // incorporates params.error into issue reporting
1681
- continue: !inst._zod.def.abort,
1682
- // params: inst._zod.def.params,
1683
- };
1684
- if (inst._zod.def.params)
1685
- _iss.params = inst._zod.def.params;
1686
- payload.issues.push(util.issue(_iss));
1687
- }
1688
- }