elysia 1.4.28 → 2.0.0-beta.0

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 (454) hide show
  1. package/dist/_virtual/_rolldown/runtime.js +29 -0
  2. package/dist/_virtual/_rolldown/runtime.mjs +38 -0
  3. package/dist/adapter/bun/index.d.ts +7 -6
  4. package/dist/adapter/bun/index.js +219 -380
  5. package/dist/adapter/bun/index.mjs +217 -382
  6. package/dist/adapter/constants.d.ts +6 -0
  7. package/dist/adapter/constants.js +10 -0
  8. package/dist/adapter/constants.mjs +9 -0
  9. package/dist/adapter/default-headers.d.ts +4 -0
  10. package/dist/adapter/default-headers.js +7 -0
  11. package/dist/adapter/default-headers.mjs +5 -0
  12. package/dist/adapter/index.d.ts +8 -1
  13. package/dist/adapter/index.js +7 -14
  14. package/dist/adapter/index.mjs +5 -0
  15. package/dist/adapter/origin.d.ts +63 -0
  16. package/dist/adapter/origin.js +64 -0
  17. package/dist/adapter/origin.mjs +62 -0
  18. package/dist/adapter/response-ownership.d.ts +5 -0
  19. package/dist/adapter/response-ownership.js +13 -0
  20. package/dist/adapter/response-ownership.mjs +10 -0
  21. package/dist/adapter/skip-clone.d.ts +4 -0
  22. package/dist/adapter/skip-clone.js +7 -0
  23. package/dist/adapter/skip-clone.mjs +5 -0
  24. package/dist/adapter/types.d.ts +50 -125
  25. package/dist/adapter/types.js +1 -14
  26. package/dist/adapter/types.mjs +1 -0
  27. package/dist/adapter/utils.d.ts +47 -19
  28. package/dist/adapter/utils.js +561 -311
  29. package/dist/adapter/utils.mjs +551 -283
  30. package/dist/adapter/web-standard/handler.d.ts +11 -9
  31. package/dist/adapter/web-standard/handler.js +146 -415
  32. package/dist/adapter/web-standard/handler.mjs +144 -400
  33. package/dist/adapter/web-standard/index.d.ts +5 -2
  34. package/dist/adapter/web-standard/index.js +68 -161
  35. package/dist/adapter/web-standard/index.mjs +68 -146
  36. package/dist/adapter/web-standard/utils.d.ts +4 -0
  37. package/dist/adapter/web-standard/utils.js +153 -0
  38. package/dist/adapter/web-standard/utils.mjs +152 -0
  39. package/dist/base.d.ts +898 -0
  40. package/dist/base.js +1564 -0
  41. package/dist/base.mjs +1561 -0
  42. package/dist/compile/analysis-cache.d.ts +6 -0
  43. package/dist/compile/analysis-cache.js +12 -0
  44. package/dist/compile/analysis-cache.mjs +11 -0
  45. package/dist/compile/aot-capture.d.ts +24 -0
  46. package/dist/compile/aot-capture.js +376 -0
  47. package/dist/compile/aot-capture.mjs +365 -0
  48. package/dist/compile/aot-emit.d.ts +29 -0
  49. package/dist/compile/aot-emit.js +107 -0
  50. package/dist/compile/aot-emit.mjs +101 -0
  51. package/dist/compile/aot-reconstruct.d.ts +30 -0
  52. package/dist/compile/aot-reconstruct.js +156 -0
  53. package/dist/compile/aot-reconstruct.mjs +147 -0
  54. package/dist/compile/aot.d.ts +287 -0
  55. package/dist/compile/aot.js +220 -0
  56. package/dist/compile/aot.mjs +200 -0
  57. package/dist/compile/handler/descriptor.d.ts +77 -0
  58. package/dist/compile/handler/descriptor.js +199 -0
  59. package/dist/compile/handler/descriptor.mjs +194 -0
  60. package/dist/compile/handler/frozen-validator.d.ts +39 -0
  61. package/dist/compile/handler/frozen-validator.js +319 -0
  62. package/dist/compile/handler/frozen-validator.mjs +313 -0
  63. package/dist/compile/handler/index.d.ts +19 -0
  64. package/dist/compile/handler/index.js +379 -0
  65. package/dist/compile/handler/index.mjs +371 -0
  66. package/dist/compile/handler/jit.d.ts +43 -0
  67. package/dist/compile/handler/jit.js +536 -0
  68. package/dist/compile/handler/jit.mjs +532 -0
  69. package/dist/compile/handler/params.d.ts +28 -0
  70. package/dist/compile/handler/params.js +78 -0
  71. package/dist/compile/handler/params.mjs +76 -0
  72. package/dist/compile/handler/reconstruct.d.ts +12 -0
  73. package/dist/compile/handler/reconstruct.js +50 -0
  74. package/dist/compile/handler/reconstruct.mjs +49 -0
  75. package/dist/compile/handler/utils.d.ts +45 -0
  76. package/dist/compile/handler/utils.js +514 -0
  77. package/dist/compile/handler/utils.mjs +498 -0
  78. package/dist/compile/jit-probe.d.ts +15 -0
  79. package/dist/compile/jit-probe.js +28 -0
  80. package/dist/compile/jit-probe.mjs +26 -0
  81. package/dist/compile/lexer.d.ts +7 -0
  82. package/dist/compile/lexer.js +53 -0
  83. package/dist/compile/lexer.mjs +48 -0
  84. package/dist/compile/utils.d.ts +8 -0
  85. package/dist/compile/utils.js +23 -0
  86. package/dist/compile/utils.mjs +19 -0
  87. package/dist/compiled.d.ts +17 -0
  88. package/dist/compiled.js +20 -0
  89. package/dist/compiled.mjs +16 -0
  90. package/dist/constants.d.ts +137 -0
  91. package/dist/constants.js +96 -0
  92. package/dist/constants.mjs +88 -0
  93. package/dist/context.d.ts +86 -129
  94. package/dist/context.js +110 -13
  95. package/dist/context.mjs +108 -0
  96. package/dist/cookie/config.d.ts +31 -0
  97. package/dist/cookie/config.js +98 -0
  98. package/dist/cookie/config.mjs +95 -0
  99. package/dist/cookie/cookie.d.ts +26 -0
  100. package/dist/cookie/cookie.js +105 -0
  101. package/dist/cookie/cookie.mjs +104 -0
  102. package/dist/cookie/crypto.d.ts +20 -0
  103. package/dist/cookie/crypto.js +168 -0
  104. package/dist/cookie/crypto.mjs +151 -0
  105. package/dist/cookie/error.d.ts +17 -0
  106. package/dist/cookie/error.js +25 -0
  107. package/dist/cookie/error.mjs +24 -0
  108. package/dist/cookie/index.d.ts +7 -0
  109. package/dist/cookie/index.js +13 -0
  110. package/dist/cookie/index.mjs +7 -0
  111. package/dist/cookie/lib.d.ts +7 -0
  112. package/dist/cookie/lib.js +76 -0
  113. package/dist/cookie/lib.mjs +74 -0
  114. package/dist/cookie/serialize.d.ts +6 -0
  115. package/dist/cookie/serialize.js +32 -0
  116. package/dist/cookie/serialize.mjs +31 -0
  117. package/dist/cookie/types.d.ts +113 -0
  118. package/dist/cookie/types.js +1 -0
  119. package/dist/cookie/types.mjs +1 -0
  120. package/dist/cookie/utils.d.ts +25 -0
  121. package/dist/cookie/utils.js +182 -0
  122. package/dist/cookie/utils.mjs +171 -0
  123. package/dist/error.d.ts +226 -188
  124. package/dist/error.js +519 -357
  125. package/dist/error.mjs +503 -327
  126. package/dist/generation.d.ts +30 -0
  127. package/dist/generation.js +23 -0
  128. package/dist/generation.mjs +17 -0
  129. package/dist/handler/error.d.ts +7 -0
  130. package/dist/handler/error.js +105 -0
  131. package/dist/handler/error.mjs +104 -0
  132. package/dist/handler/fetch.d.ts +8 -0
  133. package/dist/handler/fetch.js +371 -0
  134. package/dist/handler/fetch.mjs +367 -0
  135. package/dist/handler/index.d.ts +2 -0
  136. package/dist/handler/index.js +5 -0
  137. package/dist/handler/index.mjs +3 -0
  138. package/dist/handler/utils.d.ts +15 -0
  139. package/dist/handler/utils.js +48 -0
  140. package/dist/handler/utils.mjs +42 -0
  141. package/dist/index.d.ts +23 -2198
  142. package/dist/index.js +62 -1948
  143. package/dist/index.mjs +20 -1986
  144. package/dist/memory.d.ts +4 -0
  145. package/dist/memory.js +17 -0
  146. package/dist/memory.mjs +16 -0
  147. package/dist/package.js +11 -0
  148. package/dist/package.mjs +5 -0
  149. package/dist/parse-query.d.ts +7 -9
  150. package/dist/parse-query.js +154 -164
  151. package/dist/parse-query.mjs +150 -133
  152. package/dist/plugin/aot/bun.d.ts +26 -0
  153. package/dist/plugin/aot/bun.js +35 -0
  154. package/dist/plugin/aot/bun.mjs +34 -0
  155. package/dist/plugin/aot/core.d.ts +291 -0
  156. package/dist/plugin/aot/core.js +505 -0
  157. package/dist/plugin/aot/core.mjs +481 -0
  158. package/dist/plugin/aot/esbuild.d.ts +28 -0
  159. package/dist/plugin/aot/esbuild.js +48 -0
  160. package/dist/plugin/aot/esbuild.mjs +46 -0
  161. package/dist/plugin/aot/hooks.d.ts +28 -0
  162. package/dist/plugin/aot/hooks.js +114 -0
  163. package/dist/plugin/aot/hooks.mjs +112 -0
  164. package/dist/plugin/aot/rspack-loader.d.ts +23 -0
  165. package/dist/plugin/aot/rspack-loader.js +44 -0
  166. package/dist/plugin/aot/rspack-loader.mjs +40 -0
  167. package/dist/plugin/aot/rspack.d.ts +23 -0
  168. package/dist/plugin/aot/rspack.js +85 -0
  169. package/dist/plugin/aot/rspack.mjs +82 -0
  170. package/dist/plugin/aot/source.d.ts +60 -0
  171. package/dist/plugin/aot/source.js +422 -0
  172. package/dist/plugin/aot/source.mjs +418 -0
  173. package/dist/plugin/aot/treeshake.d.ts +4 -0
  174. package/dist/plugin/aot/treeshake.js +95 -0
  175. package/dist/plugin/aot/treeshake.mjs +94 -0
  176. package/dist/plugin/aot/unplugin.d.ts +50 -0
  177. package/dist/plugin/aot/unplugin.js +64 -0
  178. package/dist/plugin/aot/unplugin.mjs +62 -0
  179. package/dist/plugin/aot/vite.d.ts +30 -0
  180. package/dist/plugin/aot/vite.js +34 -0
  181. package/dist/plugin/aot/vite.mjs +33 -0
  182. package/dist/plugin/aot/worker.d.ts +1 -0
  183. package/dist/plugin/aot/worker.js +28 -0
  184. package/dist/plugin/aot/worker.mjs +27 -0
  185. package/dist/plugin/auto-head.d.ts +6 -0
  186. package/dist/plugin/auto-head.js +38 -0
  187. package/dist/plugin/auto-head.mjs +36 -0
  188. package/dist/plugin/trace.d.ts +10 -0
  189. package/dist/plugin/trace.js +39 -0
  190. package/dist/plugin/trace.mjs +36 -0
  191. package/dist/plugin/websocket.d.ts +6 -0
  192. package/dist/plugin/websocket.js +61 -0
  193. package/dist/plugin/websocket.mjs +60 -0
  194. package/dist/route-table.d.ts +28 -0
  195. package/dist/route-table.js +64 -0
  196. package/dist/route-table.mjs +61 -0
  197. package/dist/schema-snapshot.d.ts +9 -0
  198. package/dist/schema-snapshot.js +271 -0
  199. package/dist/schema-snapshot.mjs +269 -0
  200. package/dist/sucrose.d.ts +28 -63
  201. package/dist/sucrose.js +814 -306
  202. package/dist/sucrose.mjs +805 -274
  203. package/dist/trace.d.ts +145 -130
  204. package/dist/trace.js +387 -135
  205. package/dist/trace.mjs +385 -113
  206. package/dist/type/bridge-live.d.ts +15 -0
  207. package/dist/type/bridge-live.js +39 -0
  208. package/dist/type/bridge-live.mjs +17 -0
  209. package/dist/type/bridge.d.ts +56 -0
  210. package/dist/type/bridge.js +180 -0
  211. package/dist/type/bridge.mjs +63 -0
  212. package/dist/type/coerce-plan.d.ts +38 -0
  213. package/dist/type/coerce-plan.js +107 -0
  214. package/dist/type/coerce-plan.mjs +98 -0
  215. package/dist/type/coerce.d.ts +43 -0
  216. package/dist/type/coerce.js +351 -0
  217. package/dist/type/coerce.mjs +339 -0
  218. package/dist/type/compat.d.ts +8 -0
  219. package/dist/type/compat.js +46 -0
  220. package/dist/type/compat.mjs +44 -0
  221. package/dist/type/constants.d.ts +25 -0
  222. package/dist/type/constants.js +36 -0
  223. package/dist/type/constants.mjs +32 -0
  224. package/dist/type/elysia/accelerate.d.ts +6 -0
  225. package/dist/type/elysia/accelerate.js +12 -0
  226. package/dist/type/elysia/accelerate.mjs +10 -0
  227. package/dist/type/elysia/array-buffer.d.ts +6 -0
  228. package/dist/type/elysia/array-buffer.js +27 -0
  229. package/dist/type/elysia/array-buffer.mjs +25 -0
  230. package/dist/type/elysia/array-string.d.ts +7 -0
  231. package/dist/type/elysia/array-string.js +28 -0
  232. package/dist/type/elysia/array-string.mjs +26 -0
  233. package/dist/type/elysia/array.d.ts +6 -0
  234. package/dist/type/elysia/array.js +32 -0
  235. package/dist/type/elysia/array.mjs +31 -0
  236. package/dist/type/elysia/boolean-string.d.ts +6 -0
  237. package/dist/type/elysia/boolean-string.js +24 -0
  238. package/dist/type/elysia/boolean-string.mjs +22 -0
  239. package/dist/type/elysia/boolean.d.ts +6 -0
  240. package/dist/type/elysia/boolean.js +20 -0
  241. package/dist/type/elysia/boolean.mjs +18 -0
  242. package/dist/type/elysia/cookie.d.ts +15 -0
  243. package/dist/type/elysia/cookie.js +51 -0
  244. package/dist/type/elysia/cookie.mjs +50 -0
  245. package/dist/type/elysia/date.d.ts +7 -0
  246. package/dist/type/elysia/date.js +98 -0
  247. package/dist/type/elysia/date.mjs +96 -0
  248. package/dist/type/elysia/file-type.d.ts +25 -0
  249. package/dist/type/elysia/file-type.js +81 -0
  250. package/dist/type/elysia/file-type.mjs +71 -0
  251. package/dist/type/elysia/file.d.ts +9 -0
  252. package/dist/type/elysia/file.js +64 -0
  253. package/dist/type/elysia/file.mjs +48 -0
  254. package/dist/type/elysia/files.d.ts +8 -0
  255. package/dist/type/elysia/files.js +45 -0
  256. package/dist/type/elysia/files.mjs +43 -0
  257. package/dist/type/elysia/form.d.ts +8 -0
  258. package/dist/type/elysia/form.js +17 -0
  259. package/dist/type/elysia/form.mjs +15 -0
  260. package/dist/type/elysia/integer-string.d.ts +7 -0
  261. package/dist/type/elysia/integer-string.js +40 -0
  262. package/dist/type/elysia/integer-string.mjs +38 -0
  263. package/dist/type/elysia/integer.d.ts +6 -0
  264. package/dist/type/elysia/integer.js +20 -0
  265. package/dist/type/elysia/integer.mjs +18 -0
  266. package/dist/type/elysia/intersect.d.ts +6 -0
  267. package/dist/type/elysia/intersect.js +20 -0
  268. package/dist/type/elysia/intersect.mjs +19 -0
  269. package/dist/type/elysia/maybe-empty.d.ts +7 -0
  270. package/dist/type/elysia/maybe-empty.js +21 -0
  271. package/dist/type/elysia/maybe-empty.mjs +19 -0
  272. package/dist/type/elysia/no-validate.d.ts +6 -0
  273. package/dist/type/elysia/no-validate.js +9 -0
  274. package/dist/type/elysia/no-validate.mjs +8 -0
  275. package/dist/type/elysia/nullable.d.ts +7 -0
  276. package/dist/type/elysia/nullable.js +15 -0
  277. package/dist/type/elysia/nullable.mjs +13 -0
  278. package/dist/type/elysia/number.d.ts +6 -0
  279. package/dist/type/elysia/number.js +20 -0
  280. package/dist/type/elysia/number.mjs +18 -0
  281. package/dist/type/elysia/numeric-enum.d.ts +11 -0
  282. package/dist/type/elysia/numeric-enum.js +26 -0
  283. package/dist/type/elysia/numeric-enum.mjs +24 -0
  284. package/dist/type/elysia/numeric.d.ts +7 -0
  285. package/dist/type/elysia/numeric.js +62 -0
  286. package/dist/type/elysia/numeric.mjs +60 -0
  287. package/dist/type/elysia/object-string.d.ts +7 -0
  288. package/dist/type/elysia/object-string.js +28 -0
  289. package/dist/type/elysia/object-string.mjs +26 -0
  290. package/dist/type/elysia/object.d.ts +6 -0
  291. package/dist/type/elysia/object.js +47 -0
  292. package/dist/type/elysia/object.mjs +46 -0
  293. package/dist/type/elysia/optional.d.ts +6 -0
  294. package/dist/type/elysia/optional.js +22 -0
  295. package/dist/type/elysia/optional.mjs +21 -0
  296. package/dist/type/elysia/string.d.ts +6 -0
  297. package/dist/type/elysia/string.js +43 -0
  298. package/dist/type/elysia/string.mjs +41 -0
  299. package/dist/type/elysia/uint8-array.d.ts +6 -0
  300. package/dist/type/elysia/uint8-array.js +27 -0
  301. package/dist/type/elysia/uint8-array.mjs +25 -0
  302. package/dist/type/elysia/union-enum.d.ts +8 -0
  303. package/dist/type/elysia/union-enum.js +31 -0
  304. package/dist/type/elysia/union-enum.mjs +29 -0
  305. package/dist/type/elysia/union.d.ts +6 -0
  306. package/dist/type/elysia/union.js +20 -0
  307. package/dist/type/elysia/union.mjs +19 -0
  308. package/dist/type/elysia/utils.d.ts +53 -0
  309. package/dist/type/elysia/utils.js +98 -0
  310. package/dist/type/elysia/utils.mjs +88 -0
  311. package/dist/type/exports.d.ts +36 -0
  312. package/dist/type/exports.js +68 -0
  313. package/dist/type/exports.mjs +36 -0
  314. package/dist/type/index.d.ts +13 -0
  315. package/dist/type/index.js +81 -0
  316. package/dist/type/index.mjs +68 -0
  317. package/dist/type/shared.d.ts +27 -0
  318. package/dist/type/shared.js +171 -0
  319. package/dist/type/shared.mjs +161 -0
  320. package/dist/type/types.d.ts +206 -0
  321. package/dist/type/types.js +1 -0
  322. package/dist/type/types.mjs +1 -0
  323. package/dist/type/utils.d.ts +7 -0
  324. package/dist/type/utils.js +43 -0
  325. package/dist/type/utils.mjs +41 -0
  326. package/dist/type/validator/clean-safe.d.ts +8 -0
  327. package/dist/type/validator/clean-safe.js +82 -0
  328. package/dist/type/validator/clean-safe.mjs +77 -0
  329. package/dist/type/validator/custom-error.d.ts +10 -0
  330. package/dist/type/validator/custom-error.js +191 -0
  331. package/dist/type/validator/custom-error.mjs +188 -0
  332. package/dist/type/validator/default-precompute.d.ts +26 -0
  333. package/dist/type/validator/default-precompute.js +432 -0
  334. package/dist/type/validator/default-precompute.mjs +421 -0
  335. package/dist/type/validator/exact-mirror.d.ts +7 -0
  336. package/dist/type/validator/exact-mirror.js +19 -0
  337. package/dist/type/validator/exact-mirror.mjs +15 -0
  338. package/dist/type/validator/frozen-check.d.ts +11 -0
  339. package/dist/type/validator/frozen-check.js +20 -0
  340. package/dist/type/validator/frozen-check.mjs +19 -0
  341. package/dist/type/validator/index.d.ts +32 -0
  342. package/dist/type/validator/index.js +657 -0
  343. package/dist/type/validator/index.mjs +651 -0
  344. package/dist/type/validator/string-codec-aot.d.ts +8 -0
  345. package/dist/type/validator/string-codec-aot.js +68 -0
  346. package/dist/type/validator/string-codec-aot.mjs +66 -0
  347. package/dist/type/validator/validator-cache.d.ts +26 -0
  348. package/dist/type/validator/validator-cache.js +247 -0
  349. package/dist/type/validator/validator-cache.mjs +242 -0
  350. package/dist/types.d.ts +938 -1235
  351. package/dist/types.js +1 -14
  352. package/dist/types.mjs +1 -0
  353. package/dist/universal/constants.d.ts +6 -0
  354. package/dist/universal/constants.js +19 -0
  355. package/dist/universal/constants.mjs +15 -0
  356. package/dist/universal/env.d.ts +5 -1
  357. package/dist/universal/env.js +12 -26
  358. package/dist/universal/env.mjs +10 -5
  359. package/dist/universal/file.d.ts +55 -86
  360. package/dist/universal/file.js +116 -157
  361. package/dist/universal/file.mjs +111 -132
  362. package/dist/universal/index.d.ts +5 -3
  363. package/dist/universal/index.js +8 -27
  364. package/dist/universal/index.mjs +4 -5
  365. package/dist/universal/is-production.d.ts +5 -0
  366. package/dist/universal/is-production.js +10 -0
  367. package/dist/universal/is-production.mjs +8 -0
  368. package/dist/universal/server.d.ts +318 -313
  369. package/dist/universal/server.js +1 -14
  370. package/dist/universal/server.mjs +1 -0
  371. package/dist/utils.d.ts +162 -191
  372. package/dist/utils.js +732 -693
  373. package/dist/utils.mjs +683 -631
  374. package/dist/validator/index.d.ts +63 -0
  375. package/dist/validator/index.js +299 -0
  376. package/dist/validator/index.mjs +296 -0
  377. package/dist/validator/route.d.ts +32 -0
  378. package/dist/validator/route.js +51 -0
  379. package/dist/validator/route.mjs +50 -0
  380. package/dist/ws/context.d.ts +49 -0
  381. package/dist/ws/context.js +152 -0
  382. package/dist/ws/context.mjs +150 -0
  383. package/dist/ws/index.d.ts +5 -77
  384. package/dist/ws/index.js +11 -180
  385. package/dist/ws/index.mjs +5 -157
  386. package/dist/ws/parser.d.ts +5 -0
  387. package/dist/ws/parser.js +69 -0
  388. package/dist/ws/parser.mjs +66 -0
  389. package/dist/ws/route.d.ts +16 -0
  390. package/dist/ws/route.js +560 -0
  391. package/dist/ws/route.mjs +554 -0
  392. package/dist/ws/types.d.ts +154 -57
  393. package/dist/ws/types.js +1 -14
  394. package/dist/ws/types.mjs +1 -0
  395. package/package.json +179 -120
  396. package/bunfig.toml +0 -2
  397. package/dist/adapter/bun/compose.d.ts +0 -3
  398. package/dist/adapter/bun/compose.js +0 -90
  399. package/dist/adapter/bun/compose.mjs +0 -74
  400. package/dist/adapter/bun/handler-native.d.ts +0 -3
  401. package/dist/adapter/bun/handler-native.js +0 -42
  402. package/dist/adapter/bun/handler-native.mjs +0 -22
  403. package/dist/adapter/bun/handler.d.ts +0 -7
  404. package/dist/adapter/bun/handler.js +0 -363
  405. package/dist/adapter/bun/handler.mjs +0 -346
  406. package/dist/adapter/cloudflare-worker/index.d.ts +0 -20
  407. package/dist/adapter/cloudflare-worker/index.js +0 -59
  408. package/dist/adapter/cloudflare-worker/index.mjs +0 -39
  409. package/dist/compose.d.ts +0 -30
  410. package/dist/compose.js +0 -1324
  411. package/dist/compose.mjs +0 -1336
  412. package/dist/cookies.d.ts +0 -158
  413. package/dist/cookies.js +0 -250
  414. package/dist/cookies.mjs +0 -221
  415. package/dist/dynamic-handle.d.ts +0 -15
  416. package/dist/dynamic-handle.js +0 -521
  417. package/dist/dynamic-handle.mjs +0 -509
  418. package/dist/formats.d.ts +0 -79
  419. package/dist/formats.js +0 -153
  420. package/dist/formats.mjs +0 -132
  421. package/dist/manifest.d.ts +0 -0
  422. package/dist/manifest.js +0 -1
  423. package/dist/manifest.mjs +0 -0
  424. package/dist/replace-schema.d.ts +0 -60
  425. package/dist/replace-schema.js +0 -140
  426. package/dist/replace-schema.mjs +0 -115
  427. package/dist/schema.d.ts +0 -107
  428. package/dist/schema.js +0 -833
  429. package/dist/schema.mjs +0 -814
  430. package/dist/type-system/format.d.ts +0 -55
  431. package/dist/type-system/format.js +0 -197
  432. package/dist/type-system/format.mjs +0 -175
  433. package/dist/type-system/index.d.ts +0 -45
  434. package/dist/type-system/index.js +0 -406
  435. package/dist/type-system/index.mjs +0 -394
  436. package/dist/type-system/types.d.ts +0 -155
  437. package/dist/type-system/types.js +0 -14
  438. package/dist/type-system/types.mjs +0 -0
  439. package/dist/type-system/utils.d.ts +0 -62
  440. package/dist/type-system/utils.js +0 -141
  441. package/dist/type-system/utils.mjs +0 -111
  442. package/dist/universal/request.d.ts +0 -29
  443. package/dist/universal/request.js +0 -126
  444. package/dist/universal/request.mjs +0 -105
  445. package/dist/universal/types.d.ts +0 -124
  446. package/dist/universal/types.js +0 -41
  447. package/dist/universal/types.mjs +0 -19
  448. package/dist/universal/utils.d.ts +0 -3
  449. package/dist/universal/utils.js +0 -41
  450. package/dist/universal/utils.mjs +0 -18
  451. package/dist/ws/bun.d.ts +0 -419
  452. package/dist/ws/bun.js +0 -14
  453. package/dist/ws/bun.mjs +0 -0
  454. package/knip.json +0 -22
package/dist/types.d.ts CHANGED
@@ -1,1271 +1,974 @@
1
- import type { Elysia, AnyElysia, InvertedStatusMap } from './index';
2
- import type { ElysiaFile } from './universal/file';
3
- import type { Serve } from './universal/server';
4
- import { TSchema, TAnySchema, OptionalKind, TModule, TImport, TProperties } from '@sinclair/typebox';
5
- import type { TypeCheck, ValueError } from '@sinclair/typebox/compiler';
6
- import type { OpenAPIV3 } from 'openapi-types';
7
- import type { ElysiaAdapter } from './adapter';
8
- import type { ElysiaTypeCheck } from './schema';
9
- import type { Context, ErrorContext, PreContext } from './context';
10
- import type { ComposerGeneralHandlerOptions } from './compose';
11
- import type { CookieOptions } from './cookies';
12
- import type { TraceHandler } from './trace';
13
- import type { ElysiaCustomStatusResponse, InternalServerError, InvalidCookieSignature, InvalidFileType, NotFoundError, ParseError, ValidationError } from './error';
14
- import type { AnyWSLocalHook } from './ws/types';
15
- import type { WebSocketHandler } from './ws/bun';
16
- import type { Instruction as ExactMirrorInstruction } from 'exact-mirror';
17
- import { BunHTMLBundlelike } from './universal/types';
18
- import { Sucrose } from './sucrose';
19
- import type Memoirist from 'memoirist';
20
- import type { DynamicHandler } from './dynamic-handle';
21
- export type Equal<X, Y> = (<T>() => T extends X ? 1 : 2) extends <T>() => T extends Y ? 1 : 2 ? true : false;
22
- export type IsNever<T> = [T] extends [never] ? true : false;
23
- export type PickIfExists<T, K extends string> = {} extends T ? {} : {
24
- [P in K as P extends keyof T ? P : never]: T[P];
25
- };
26
- export interface StandardSchemaV1Like<in out Input = unknown, in out Output = Input> {
27
- readonly '~standard': {
28
- readonly types?: {
29
- readonly input: Input;
30
- readonly output: Output;
31
- } | undefined;
32
- };
33
- }
34
- export interface FastStandardSchemaV1Like {
35
- readonly '~standard': {};
36
- }
37
- export type StandardSchemaV1LikeValidate = <T>(v: T) => MaybePromise<{
38
- value: T;
39
- issues?: never;
40
- } | {
41
- value?: never;
42
- issues: unknown[];
43
- }>;
44
- export type AnySchema = TSchema | StandardSchemaV1Like;
45
- export type FastAnySchema = TAnySchema | FastStandardSchemaV1Like;
46
- export interface ElysiaConfig<in out Prefix extends string | undefined> {
47
- /**
48
- * @default BunAdapter
49
- * @since 1.1.11
50
- */
51
- adapter?: ElysiaAdapter;
52
- /**
53
- * Path prefix of the instance
54
- *
55
- * @default '''
56
- */
57
- prefix?: Prefix;
58
- /**
59
- * Name of the instance for debugging, and plugin deduplication purpose
60
- */
61
- name?: string;
62
- /**
63
- * Seed for generating checksum for plugin deduplication
64
- *
65
- * @see https://elysiajs.com/essential/plugin.html#plugin-deduplication
66
- */
67
- seed?: unknown;
68
- /**
69
- * Bun serve
70
- *
71
- * @see https://bun.sh/docs/api/http
72
- */
73
- serve?: Partial<Serve>;
74
- /**
75
- * OpenAPI documentation (use in Swagger)
76
- *
77
- * @see https://swagger.io/specification/
78
- */
79
- detail?: DocumentDecoration;
80
- /**
81
- * OpenAPI tags
82
- *
83
- * current instance' routes with tags
84
- *
85
- * @see https://swagger.io/specification/#tag-object
86
- */
87
- tags?: DocumentDecoration['tags'];
88
- /**
89
- * Warm up Elysia before starting the server
90
- *
91
- * This will perform Ahead of Time compilation and generate code for route handlers
92
- *
93
- * If set to false, Elysia will perform Just in Time compilation
94
- *
95
- * Only required for root instance (instance which use listen) to effect
1
+ import { CookieOptions } from "./cookie/types.js";
2
+ import { StatusMapBack } from "./constants.js";
3
+ import { ElysiaError, ElysiaStatus } from "./error.js";
4
+ import { TraceHandler } from "./trace.js";
5
+ import { ElysiaFile } from "./universal/file.js";
6
+ import { Serve } from "./universal/server.js";
7
+ import { ChainNode } from "./utils.js";
8
+ import { Context, ErrorContext, LifecycleContext, PreContext } from "./context.js";
9
+ import { AnySchema, StandardSchemaV1Like, TypeBoxSchema } from "./type/types.js";
10
+ import { AnyElysia, Elysia } from "./base.js";
11
+ import { ElysiaAdapter } from "./adapter/index.js";
12
+ import { Static, StaticDecode, StaticEncode, TIntersect, TObject, TSchema } from "typebox";
13
+ import { OpenAPIV3 } from "openapi-types";
14
+
15
+ //#region src/types.d.ts
16
+ interface ElysiaConfig<in out Prefix extends string | undefined, in out Scope extends EventScope, in out Adapter extends ElysiaAdapter = ElysiaAdapter> {
17
+ /**
18
+ * Define event scope for the instance
19
+ *
20
+ * @since 2.0.0
21
+ */
22
+ as?: Scope;
23
+ /**
24
+ * @default BunAdapter v2
25
+ * @since 2.0.0
26
+ */
27
+ adapter?: Adapter;
28
+ /**
29
+ * Path prefix of the instance
30
+ *
31
+ * @default '''
32
+ */
33
+ prefix?: Prefix;
34
+ /**
35
+ * Name of the instance for debugging, and plugin deduplication purpose
36
+ */
37
+ name?: string;
38
+ /**
39
+ * Seed for generating checksum for plugin deduplication
40
+ *
41
+ * @see https://elysiajs.com/essential/plugin.html#plugin-deduplication
42
+ */
43
+ seed?: unknown;
44
+ /**
45
+ * Bun serve
46
+ *
47
+ * @see https://bun.sh/docs/api/http
48
+ */
49
+ serve?: Partial<Serve>;
50
+ /**
51
+ * OpenAPI documentation (use in Swagger)
52
+ *
53
+ * @see https://swagger.io/specification/
54
+ */
55
+ detail?: DocumentDecoration;
56
+ /**
57
+ * OpenAPI tags
58
+ *
59
+ * current instance' routes with tags
60
+ *
61
+ * @see https://swagger.io/specification/#tag-object
62
+ */
63
+ tags?: DocumentDecoration['tags'];
64
+ /**
65
+ * Warm up Elysia before starting the server
66
+ *
67
+ * This will perform Ahead of Time compilation and generate code for route handlers
68
+ *
69
+ * If set to false, Elysia will perform Just in Time compilation
70
+ *
71
+ * Only required for root instance (instance which use listen) to effect
72
+ *
73
+ * ! If performing a benchmark, it's recommended to set this to `true`
74
+ *
75
+ * @default false
76
+ */
77
+ precompile?: boolean;
78
+ /**
79
+ * Whether should Elysia tolerate suffix '/' or vice-versa
80
+ *
81
+ * @default false
82
+ */
83
+ strictPath?: boolean;
84
+ /**
85
+ * Abort processing when request is aborted
86
+ *
87
+ * When enabled, Elysia checks the abort state after each lifecycle stage
88
+ * and returns an empty response instead of running the remaining hooks and
89
+ * handler.
90
+ *
91
+ * @default true
92
+ */
93
+ abortSignal?: boolean;
94
+ cookie?: CookieOptions & {
95
+ /**
96
+ * Specified cookie name to be signed globally
97
+ */
98
+ sign?: true | string | string[];
99
+ /**
100
+ * Verify signed cookies lazily on access or eagerly at request entry.
101
+ * @default 'lazy'
102
+ */
103
+ verify?: 'lazy' | 'eager';
104
+ };
105
+ /**
106
+ * Retain the metadata required by introspection tooling after sealing.
107
+ * Plugins that provide introspection may enable this for their host.
108
+ *
109
+ * @default false
110
+ */
111
+ introspect?: boolean;
112
+ /**
113
+ * If enabled, Elysia will attempt to coerce value to defined type on incoming and outgoing bodies.
114
+ *
115
+ * This allows for sending unknown or disallowed properties in the bodies. These will simply be filtered out instead of failing the request.
116
+ * This has no effect when the schemas allow additional properties.
117
+ * Since this uses dynamic schema it may have an impact on performance.
118
+ *
119
+ * options:
120
+ * - true: use 'exactMirror'
121
+ * - false: do not normalize the value
122
+ * - 'exactMirror': use Elysia's custom exact-mirror which precompile a schema
123
+ * - 'typebox': Since this uses dynamic Value.Clean, it have performance impact
124
+ *
125
+ * Note: This option only works when Elysia schema is provided, doesn't work with Standard Schema
126
+ *
127
+ * @default 'exactMirror'
128
+ */
129
+ normalize?: boolean | 'exactMirror' | 'typebox';
130
+ handler?: {
131
+ /**
132
+ * optimization for standard internet hostname
133
+ * this will assume hostname is always use a standard internet hostname
134
+ * assuming hostname is at minimum of 11 length of string (http://a.bc)
96
135
  *
97
- * ! If performing a benchmark, it's recommended to set this to `true`
98
- *
99
- * @default false
100
- */
101
- precompile?: boolean | {
102
- /**
103
- * Perform dynamic code generation for route handlers before starting the server
104
- *
105
- * @default false
106
- */
107
- compose?: boolean;
108
- /**
109
- * Perform Ahead of Time compilation for schema before starting the server
110
- *
111
- * @default false
112
- */
113
- schema?: boolean;
114
- };
115
- /**
116
- * Enable Ahead of Time compilation
117
- *
118
- * Trade significant performance with slightly faster startup time and reduced memory usage
119
- */
120
- aot?: boolean;
121
- /**
122
- * Whether should Elysia tolerate suffix '/' or vice-versa
123
- *
124
- * @default false
125
- */
126
- strictPath?: boolean;
127
- /**
128
- * Override websocket configuration
129
- *
130
- * @see https://bun.sh/docs/api/websockets
131
- */
132
- websocket?: Omit<WebSocketHandler<any>, 'open' | 'close' | 'message' | 'drain'>;
133
- cookie?: CookieOptions & {
134
- /**
135
- * Specified cookie name to be signed globally
136
- */
137
- sign?: true | string | string[];
138
- };
139
- /**
140
- * Capture more detail information for each dependencies
141
- */
142
- analytic?: boolean;
143
- /**
144
- * If enabled, the schema with `t.Transform` will call `Encode` before sending the response
145
- *
146
- * @default true
147
- * @since 1.3.0
148
- * @since 1.2.16 (experimental)
149
- **/
150
- encodeSchema?: boolean;
151
- /**
152
- * Enable experimental features
153
- */
154
- experimental?: {};
155
- /**
156
- * If enabled, Elysia will attempt to coerce value to defined type on incoming and outgoing bodies.
157
- *
158
- * This allows for sending unknown or disallowed properties in the bodies. These will simply be filtered out instead of failing the request.
159
- * This has no effect when the schemas allow additional properties.
160
- * Since this uses dynamic schema it may have an impact on performance.
161
- *
162
- * options:
163
- * - true: use 'exactMirror'
164
- * - false: do not normalize the value
165
- * - 'exactMirror': use Elysia's custom exact-mirror which precompile a schema
166
- * - 'typebox': Since this uses dynamic Value.Clean, it have performance impact
167
- *
168
- * Note: This option only works when Elysia schema is provided, doesn't work with Standard Schema
136
+ * setting this to true will skip the first 11 character of the hostname
169
137
  *
170
138
  * @default true
171
139
  */
172
- normalize?: boolean | 'exactMirror' | 'typebox';
173
- handler?: ComposerGeneralHandlerOptions;
174
- /**
175
- * Enable Bun static response
176
- *
177
- * @default true
178
- * @since 1.1.11
179
- */
180
- nativeStaticResponse?: boolean;
181
- /**
182
- * Use runtime/framework provided router if possible
183
- *
184
- * @default true
185
- * @since 1.3.0
186
- */
187
- systemRouter?: boolean;
188
- /**
189
- * Array of callback function to transform a string value defined in a schema
190
- *
191
- * This option only works when `sanitlize` is `exactMirror`
192
- *
193
- * This only works when set on the main instance
194
- *
195
- * @default true
196
- * @since 1.3.0
197
- */
198
- sanitize?: ExactMirrorInstruction['sanitize'];
199
- /**
200
- * Sucrose (Static Code Analysis) configuration
201
- */
202
- sucrose?: Sucrose.Settings;
203
- /**
204
- * Allow unsafe validation details in errors thrown by Elysia's schema validator (422 status code)
205
- *
206
- * Ideally, this should only be used in development environment or public APIs
207
- * This may leak sensitive information about the server implementation and should be used with caution in production environments.
208
- *
209
- * @default false
210
- */
211
- allowUnsafeValidationDetails?: boolean;
212
- }
213
- export interface ValidatorLayer {
214
- global: SchemaValidator | null;
215
- scoped: SchemaValidator | null;
216
- local: SchemaValidator | null;
217
- getCandidate(): SchemaValidator;
218
- }
219
- export interface StandaloneInputSchema<Name extends string = string> {
220
- body?: AnySchema | Name | `${Name}[]`;
221
- headers?: AnySchema | Name | `${Name}[]`;
222
- query?: AnySchema | Name | `${Name}[]`;
223
- params?: AnySchema | Name | `${Name}[]`;
224
- cookie?: AnySchema | Name | `${Name}[]`;
225
- response?: {
226
- [status in number]: `${Name}[]` | Name | AnySchema;
227
- };
228
- }
229
- export interface StandaloneValidator {
230
- global: InputSchema[] | null;
231
- scoped: InputSchema[] | null;
232
- local: InputSchema[] | null;
233
- }
234
- export type MaybeArray<T> = T | T[];
235
- export type MaybeReadonlyArray<T> = T | readonly T[];
236
- export type MaybePromise<T> = T | Promise<T>;
237
- export type ObjectValues<T extends object> = T[keyof T];
238
- type IsPathParameter<Part extends string> = Part extends `:${infer Parameter}` ? Parameter : Part extends `*` ? '*' : never;
239
- export type GetPathParameter<Path extends string> = Path extends `${infer A}/${infer B}` ? IsPathParameter<A> | GetPathParameter<B> : IsPathParameter<Path>;
240
- type _ResolvePath<Path extends string> = {
241
- [Param in GetPathParameter<Path> as Param extends `${string}?` ? never : Param]: string;
242
- } & {
243
- [Param in GetPathParameter<Path> as Param extends `${infer OptionalParam}?` ? OptionalParam : never]?: string;
140
+ standardHostname?: boolean;
141
+ };
142
+ /**
143
+ * Enable Bun adapter native static response collection for eligible literal
144
+ * static routes.
145
+ *
146
+ * @default true
147
+ * @since 1.1.11
148
+ */
149
+ nativeStaticResponse?: boolean;
150
+ /**
151
+ * Array of callback function to transform a string value defined in a schema
152
+ *
153
+ * This option only works when `sanitlize` is `exactMirror`
154
+ *
155
+ * This only works when set on the main instance
156
+ *
157
+ * @default true
158
+ * @since 1.3.0
159
+ */
160
+ sanitize?: ((value: string) => string) | ((value: string) => string)[];
161
+ /**
162
+ * Allow unsafe validation details in errors thrown by Elysia's schema validator (422 status code)
163
+ *
164
+ * Ideally, this should only be used in development environment or public APIs
165
+ * This may leak sensitive information about the server implementation and should be used with caution in production environments.
166
+ *
167
+ * @default false
168
+ */
169
+ allowUnsafeValidationDetails?: boolean;
170
+ }
171
+ interface DocumentDecoration extends Partial<OpenAPIV3.OperationObject> {
172
+ /**
173
+ * Pass `true` to hide route from OpenAPI/swagger document
174
+ * */
175
+ hide?: boolean;
176
+ }
177
+ type Prettify<in out T> = { [K in keyof T]: T[K] } & {};
178
+ type SSEPayload<Data = unknown, Event extends string | undefined = string | undefined> = {
179
+ id?: string | number | null;
180
+ event?: Event;
181
+ retry?: number;
182
+ data?: Data;
244
183
  };
245
- export type ResolvePath<Path extends string> = Path extends '' ? {} : Path extends PathParameterLike ? _ResolvePath<Path> : {};
246
- export type Or<T1 extends boolean, T2 extends boolean> = T1 extends true ? true : T2 extends true ? true : false;
247
- export type Prettify<in out T> = {
248
- [K in keyof T]: T[K];
249
- } & {};
250
- export type NeverKey<in out T> = {
251
- [K in keyof T]?: never;
252
- } & {};
253
- type IsBothObject<A, B> = A extends Record<keyof any, any> ? B extends Record<keyof any, any> ? IsClass<A> extends false ? IsClass<B> extends false ? true : false : false : false : false;
254
- type IsClass<V> = V extends abstract new (...args: any) => any ? true : false;
255
- export type Reconcile<A extends Object, B extends Object, Override extends boolean = false, Stack extends number[] = []> = Stack['length'] extends 16 ? A : Override extends true ? {
256
- [key in keyof A as key extends keyof B ? never : key]: A[key];
257
- } extends infer Collision ? {} extends Collision ? {
258
- [key in keyof B]: IsBothObject<A[key], B[key]> extends true ? Reconcile<A[key], B[key], Override, [
259
- 0,
260
- ...Stack
261
- ]> : B[key];
262
- } : Prettify<Collision & {
263
- [key in keyof B]: B[key];
264
- }> : never : {
265
- [key in keyof B as key extends keyof A ? never : key]: B[key];
266
- } extends infer Collision ? {} extends Collision ? {
267
- [key in keyof A]: IsBothObject<A[key], B[key]> extends true ? Reconcile<A[key], B[key], Override, [
268
- 0,
269
- ...Stack
270
- ]> : A[key];
271
- } : Prettify<{
272
- [key in keyof A]: A[key];
273
- } & Collision> : never;
274
- export interface SingletonBase {
275
- decorator: Record<string, unknown>;
276
- store: Record<string, unknown>;
277
- derive: Record<string, unknown>;
278
- resolve: Record<string, unknown>;
279
- }
280
- export interface PossibleResponse {
281
- [status: number]: unknown;
282
- }
283
- export interface EphemeralType {
284
- derive: SingletonBase['derive'];
285
- resolve: SingletonBase['resolve'];
286
- schema: MetadataBase['schema'];
287
- standaloneSchema: MetadataBase['schema'];
288
- response: PossibleResponse;
289
- }
290
- export interface DefinitionBase {
291
- typebox: Record<string, AnySchema>;
292
- error: Record<string, Error>;
293
- }
294
- export type RouteBase = Record<string, unknown>;
295
- export interface MetadataBase {
296
- schema: RouteSchema;
297
- standaloneSchema: MetadataBase['schema'];
298
- macro: BaseMacro;
299
- macroFn: Macro;
300
- parser: Record<string, BodyHandler<any, any>>;
301
- response: PossibleResponse;
302
- }
303
- export interface RouteSchema {
304
- body?: unknown;
305
- headers?: unknown;
306
- query?: unknown;
307
- params?: unknown;
308
- cookie?: unknown;
309
- response?: unknown;
310
- }
311
- interface OptionalField {
312
- [OptionalKind]: 'Optional';
313
- }
314
- export type UnwrapSchema<Schema extends AnySchema | string | undefined, Definitions extends DefinitionBase['typebox'] = {}> = Schema extends undefined ? unknown : Schema extends TSchema ? Schema extends OptionalField ? Partial<TImport<Definitions & {
315
- readonly __elysia: Schema;
316
- }, '__elysia'>['static']> : TImport<Definitions & {
317
- readonly __elysia: Schema;
318
- }, '__elysia'>['static'] : Schema extends FastStandardSchemaV1Like ? NonNullable<Schema['~standard']['types']>['output'] : Schema extends string ? Schema extends keyof Definitions ? Definitions[Schema] extends TAnySchema ? TImport<Definitions, Schema>['static'] : NonNullable<Definitions[Schema]['~standard']['types']>['output'] : unknown : unknown;
319
- export type UnwrapBodySchema<Schema extends AnySchema | string | undefined, Definitions extends DefinitionBase['typebox'] = {}> = undefined extends Schema ? unknown : Schema extends TSchema ? Schema extends OptionalField ? Partial<TImport<Definitions & {
320
- readonly __elysia: Schema;
321
- }, '__elysia'>['static']> | null : TImport<Definitions & {
322
- readonly __elysia: Schema;
323
- }, '__elysia'>['static'] : Schema extends FastStandardSchemaV1Like ? NonNullable<Schema['~standard']['types']>['output'] : Schema extends string ? Schema extends keyof Definitions ? Definitions[Schema] extends TAnySchema ? TImport<Definitions, Schema>['static'] : NonNullable<Definitions[Schema]['~standard']['types']>['output'] : unknown : unknown;
324
- export interface UnwrapRoute<in out Schema extends InputSchema<any>, in out Definitions extends DefinitionBase['typebox'] = {}, in out Path extends string = ''> {
325
- body: UnwrapBodySchema<Schema['body'], Definitions>;
326
- headers: UnwrapSchema<Schema['headers'], Definitions>;
327
- query: UnwrapSchema<Schema['query'], Definitions>;
328
- params: {} extends Schema['params'] ? ResolvePath<Path> : {} extends Schema ? ResolvePath<Path> : UnwrapSchema<Schema['params'], Definitions>;
329
- cookie: UnwrapSchema<Schema['cookie'], Definitions>;
330
- response: Schema['response'] extends FastAnySchema | string ? {
331
- 200: UnwrapSchema<Schema['response'], Definitions> extends infer A ? A extends File ? File | ElysiaFile : A : unknown;
332
- } : Schema['response'] extends {
333
- [status in number]: FastAnySchema | string;
334
- } ? {
335
- [k in keyof Schema['response']]: UnwrapSchema<Schema['response'][k], Definitions> extends infer A ? A extends File ? File | ElysiaFile : A : unknown;
336
- } : unknown | void;
337
- }
338
- export interface UnwrapGroupGuardRoute<in out Schema extends InputSchema<any>, in out Definitions extends DefinitionBase['typebox'] = {}, Path extends string | undefined = undefined> {
339
- body: UnwrapBodySchema<Schema['body'], Definitions>;
340
- headers: UnwrapSchema<Schema['headers'], Definitions> extends infer A extends Record<string, any> ? A : undefined;
341
- query: UnwrapSchema<Schema['query'], Definitions> extends infer A extends Record<string, any> ? A : undefined;
342
- params: UnwrapSchema<Schema['params'], Definitions> extends infer A extends Record<string, any> ? A : Path extends PathParameterLike ? Record<GetPathParameter<Path>, string> : never;
343
- cookie: UnwrapSchema<Schema['cookie'], Definitions> extends infer A extends Record<string, any> ? A : undefined;
344
- response: Schema['response'] extends TSchema | string ? UnwrapSchema<Schema['response'], Definitions> : Schema['response'] extends {
345
- [k in string]: TSchema | string;
346
- } ? UnwrapSchema<Schema['response'][keyof Schema['response']], Definitions> : unknown | void;
347
- }
348
- export type HookContainer<T extends Function = Function> = {
349
- checksum?: number;
350
- scope?: LifeCycleType;
351
- subType?: 'derive' | 'resolve' | 'mapDerive' | 'mapResolve' | (string & {});
352
- fn: T;
353
- isAsync?: boolean;
354
- hasReturn?: boolean;
184
+ type MaybeArray<T> = T | T[];
185
+ type MaybePromise<T> = T | Promise<T>;
186
+ type IsAny<T> = 0 extends 1 & T ? true : false;
187
+ type IsTuple<T> = T extends readonly any[] ? number extends T['length'] ? false : true : false;
188
+ type Replace<Original, Target, With> = IsAny<Target> extends true ? Original : Original extends Record<string, unknown> ? { [K in keyof Original]: Original[K] extends Target ? With : Original[K] } : Original extends Target ? With : Original;
189
+ type EventScope = 'global' | 'local' | 'plugin';
190
+ type GuardSchemaType = 'override' | 'merge';
191
+ type ElysiaFormData<T extends Record<keyof any, unknown>> = FormData & {
192
+ ['~ely-form']: Replace<T, Blob | ElysiaFile, File> extends infer A ? { [key in keyof A]: IsTuple<A[key]> extends true ? A[key][number] extends Blob | ElysiaFile ? File[] : A[key] : A[key] } : T;
355
193
  };
356
- export interface LifeCycleStore {
357
- type?: ContentType;
358
- start: HookContainer<GracefulHandler<any>>[];
359
- request: HookContainer<PreHandler<any, any>>[];
360
- parse: HookContainer<BodyHandler<any, any>>[];
361
- transform: HookContainer<TransformHandler<any, any>>[];
362
- beforeHandle: HookContainer<OptionalHandler<any, any>>[];
363
- afterHandle: HookContainer<OptionalHandler<any, any>>[];
364
- mapResponse: HookContainer<MapResponse<any, any>>[];
365
- afterResponse: HookContainer<AfterResponseHandler<any, any>>[];
366
- trace: HookContainer<TraceHandler<any, any>>[];
367
- error: HookContainer<ErrorHandler<any, any, any>>[];
368
- stop: HookContainer<GracefulHandler<any>>[];
369
- }
370
- export type LifeCycleEvent = 'start' | 'request' | 'parse' | 'transform' | 'beforeHandle' | 'afterHandle' | 'response' | 'error' | 'stop';
371
- export type ContentType = MaybeArray<'none' | 'text' | 'json' | 'formdata' | 'urlencoded' | 'arrayBuffer' | 'text/plain' | 'application/json' | 'multipart/form-data' | 'application/x-www-form-urlencoded' | 'application/octet-stream'>;
372
- export type HTTPMethod = (string & {}) | 'ACL' | 'BIND' | 'CHECKOUT' | 'CONNECT' | 'COPY' | 'DELETE' | 'GET' | 'HEAD' | 'LINK' | 'LOCK' | 'M-SEARCH' | 'MERGE' | 'MKACTIVITY' | 'MKCALENDAR' | 'MKCOL' | 'MOVE' | 'NOTIFY' | 'OPTIONS' | 'PATCH' | 'POST' | 'PROPFIND' | 'PROPPATCH' | 'PURGE' | 'PUT' | 'REBIND' | 'REPORT' | 'SEARCH' | 'SOURCE' | 'SUBSCRIBE' | 'TRACE' | 'UNBIND' | 'UNLINK' | 'UNLOCK' | 'UNSUBSCRIBE' | 'ALL';
373
- export interface InputSchema<in out Name extends string = string> {
374
- body?: AnySchema | Name;
375
- headers?: AnySchema | Name;
376
- query?: AnySchema | Name;
377
- params?: AnySchema | Name;
378
- cookie?: AnySchema | Name;
379
- response?: AnySchema | {
380
- [status in number]: AnySchema;
381
- } | Name | {
382
- [status in number]: Name | AnySchema;
194
+ type ContentType = MaybeArray<'none' | 'text' | 'json' | 'formdata' | 'urlencoded' | 'arrayBuffer' | 'text/plain' | 'application/json' | 'multipart/form-data' | 'application/x-www-form-urlencoded' | 'application/octet-stream'>;
195
+ type HTTPMethod = (string & {}) | 'ACL' | 'BIND' | 'CHECKOUT' | 'CONNECT' | 'COPY' | 'DELETE' | 'GET' | 'HEAD' | 'LINK' | 'LOCK' | 'M-SEARCH' | 'MERGE' | 'MKACTIVITY' | 'MKCALENDAR' | 'MKCOL' | 'MOVE' | 'NOTIFY' | 'OPTIONS' | 'PATCH' | 'POST' | 'PROPFIND' | 'PROPPATCH' | 'PURGE' | 'PUT' | 'REBIND' | 'REPORT' | 'SEARCH' | 'SOURCE' | 'SUBSCRIBE' | 'TRACE' | 'UNBIND' | 'UNLINK' | 'UNLOCK' | 'UNSUBSCRIBE' | 'ALL';
196
+ type UnwrapArray<T> = T extends (infer U)[] ? U : T;
197
+ type AppEvent = 'start' | 'stop' | 'request' | 'parse' | 'transform' | 'beforeHandle' | 'afterHandle' | 'mapResponse' | 'afterResponse' | 'error' | 'trace';
198
+ interface AppHook {
199
+ start: GracefulHandler<any>[];
200
+ stop: GracefulHandler<any>[];
201
+ request: VoidHandler<any, any>[];
202
+ parse: (string | BodyHandler<any, any>)[];
203
+ transform: TransformHandler<any, any>[];
204
+ beforeHandle: OptionalHandler<any, any>[];
205
+ afterHandle: AfterHandler<any, any>[];
206
+ mapResponse: MapResponse<any, any>[];
207
+ afterResponse: AfterResponseHandler<any, any>[];
208
+ error: ErrorHandler<any, any, any>[];
209
+ trace: TraceHandler<any, any>[];
210
+ body: AnySchema;
211
+ headers: AnySchema;
212
+ query: AnySchema;
213
+ params: AnySchema;
214
+ cookie: AnySchema;
215
+ response: AnySchema | Record<number, AnySchema>;
216
+ schemas: RouteSchema[];
217
+ }
218
+ interface InputSchema<Name extends string = string> {
219
+ body?: Name | AnySchema;
220
+ headers?: Name | AnySchema;
221
+ query?: Name | AnySchema;
222
+ params?: Name | AnySchema;
223
+ cookie?: Name | AnySchema;
224
+ response?: Name | AnySchema | Record<number, Name | AnySchema>;
225
+ }
226
+ type InputSchemaKey = keyof InputSchema;
227
+ interface EmptyInputSchema {
228
+ body: unknown;
229
+ headers: unknown;
230
+ query: unknown;
231
+ params: {};
232
+ cookie: unknown;
233
+ response: unknown;
234
+ }
235
+ type LocalHook<Input extends BaseMacro, Schema extends RouteSchemaWithResolvedMacro, Singleton extends SingletonBase, Errors extends ErrorDefinition[], Parser extends keyof any = ''> = {
236
+ detail?: DocumentDecoration;
237
+ /**
238
+ * Short for 'Content-Type'
239
+ *
240
+ * Available:
241
+ * - 'none': do not parse body
242
+ * - 'text' / 'text/plain': parse body as string
243
+ * - 'json' / 'application/json': parse body as json
244
+ * - 'formdata' / 'multipart/form-data': parse body as form-data
245
+ * - 'urlencoded' / 'application/x-www-form-urlencoded: parse body as urlencoded
246
+ * - 'arraybuffer': parse body as readable stream
247
+ */
248
+ parse?: MaybeArray<BodyHandler<Schema, Singleton & {
249
+ derive: Schema['resolve'];
250
+ }> | ContentType | Parser>;
251
+ /**
252
+ * Transform context's value
253
+ */
254
+ transform?: MaybeArray<TransformHandler<Schema, Singleton & {
255
+ derive: Schema['resolve'];
256
+ }>>;
257
+ /**
258
+ * Execute before main handler
259
+ */
260
+ beforeHandle?: MaybeArray<OptionalHandler<Schema, Singleton & {
261
+ derive: Schema['resolve'];
262
+ }>>;
263
+ /**
264
+ * Execute after main handler
265
+ */
266
+ afterHandle?: MaybeArray<AfterHandler<Schema, Singleton & {
267
+ derive: Schema['resolve'];
268
+ }>>;
269
+ /**
270
+ * Execute after main handler
271
+ */
272
+ mapResponse?: MaybeArray<MapResponse<Schema, Singleton & {
273
+ derive: Schema['resolve'];
274
+ }>>;
275
+ /**
276
+ * Execute after response is sent
277
+ */
278
+ afterResponse?: MaybeArray<AfterResponseHandler<Schema, Singleton & {
279
+ derive: Schema['resolve'];
280
+ }>>;
281
+ /**
282
+ * Catch error
283
+ */
284
+ error?: MaybeArray<ErrorHandler<Errors, Schema, Singleton & {
285
+ derive: Schema['resolve'];
286
+ }>>;
287
+ tags?: DocumentDecoration['tags'];
288
+ } & (Input extends any ? Input : Prettify<Input>);
289
+ type AnyLocalHook = LocalHook<any, any, any, any, any>;
290
+ type GuardLocalHook<Input extends BaseMacro | undefined, Schema extends RouteSchema, Singleton extends SingletonBase, Parser extends keyof any, BeforeHandle extends MaybeArray<OptionalHandler<any, any>>, AfterHandle extends MaybeArray<AfterHandler<any, any>>, ErrorHandle extends MaybeArray<ErrorHandler<any, any, any>>, GuardType extends GuardSchemaType = 'merge'> = (Input extends any ? Input : Prettify<Input>) & {
291
+ /**
292
+ * @default 'override'
293
+ * @since 1.3.0
294
+ */
295
+ schema?: GuardType;
296
+ detail?: DocumentDecoration;
297
+ /**
298
+ * Short for 'Content-Type'
299
+ *
300
+ * Available:
301
+ * - 'none': do not parse body
302
+ * - 'text' / 'text/plain': parse body as string
303
+ * - 'json' / 'application/json': parse body as json
304
+ * - 'formdata' / 'multipart/form-data': parse body as form-data
305
+ * - 'urlencoded' / 'application/x-www-form-urlencoded: parse body as urlencoded
306
+ * - 'arraybuffer': parse body as readable stream
307
+ */
308
+ parse?: MaybeArray<BodyHandler<Schema, Singleton> | ContentType | Parser>;
309
+ /**
310
+ * Transform context's value
311
+ */
312
+ transform?: MaybeArray<TransformHandler<Schema, Singleton>>;
313
+ /**
314
+ * Execute before main handler
315
+ */
316
+ beforeHandle?: BeforeHandle;
317
+ /**
318
+ * Execute after main handler
319
+ */
320
+ afterHandle?: AfterHandle;
321
+ /**
322
+ * Execute after main handler
323
+ */
324
+ mapResponse?: MaybeArray<MapResponse<Schema, Singleton>>;
325
+ /**
326
+ * Execute after response is sent
327
+ */
328
+ afterResponse?: MaybeArray<AfterResponseHandler<Schema, Singleton>>;
329
+ /**
330
+ * Catch error
331
+ */
332
+ error?: ErrorHandle;
333
+ tags?: DocumentDecoration['tags'];
334
+ };
335
+ type EventFn<T extends AppEvent> = UnwrapArray<AppHook[T]>;
336
+ interface SingletonBase {
337
+ decorator: Record<string, unknown>;
338
+ store: Record<string, unknown>;
339
+ derive: Record<string, unknown>;
340
+ }
341
+ interface ErrorDefinition {
342
+ error: Error;
343
+ response: PossibleResponse;
344
+ }
345
+ interface EphemeralType {
346
+ derive: SingletonBase['derive'];
347
+ schema: MetadataBase['schema'];
348
+ schemas: MetadataBase['schema'];
349
+ response: PossibleResponse;
350
+ error: ErrorDefinition[];
351
+ }
352
+ interface DefinitionBase {
353
+ typebox: Record<string, AnySchema>;
354
+ error: ErrorDefinition[];
355
+ }
356
+ interface DefaultEphemeral {
357
+ derive: {};
358
+ schema: {};
359
+ schemas: {};
360
+ response: {};
361
+ error: [];
362
+ }
363
+ interface DefaultSingleton {
364
+ decorator: {};
365
+ store: {};
366
+ derive: {};
367
+ }
368
+ interface DefaultMetadata {
369
+ schema: {};
370
+ schemas: {};
371
+ macro: {};
372
+ macroFn: {};
373
+ parser: {};
374
+ response: {};
375
+ }
376
+ type RouteBase = Record<string, unknown>;
377
+ type BaseMacro = Record<string, string | number | boolean | Object | undefined | null>;
378
+ interface PossibleResponse {
379
+ [status: number]: unknown;
380
+ }
381
+ interface MetadataBase {
382
+ schema: RouteSchema;
383
+ schemas: MetadataBase['schema'];
384
+ macro: BaseMacro;
385
+ macroFn: Macro;
386
+ parser: Record<string, BodyHandler<any, any>>;
387
+ response: PossibleResponse;
388
+ }
389
+ interface RouteSchema {
390
+ body?: unknown;
391
+ headers?: unknown;
392
+ query?: unknown;
393
+ params?: unknown;
394
+ cookie?: unknown;
395
+ response?: unknown;
396
+ }
397
+ type OptionalHandler<in out Route extends RouteSchema = {}, in out Singleton extends SingletonBase = DefaultSingleton, Path extends string | undefined = undefined, ParamsScope extends 'local' | 'plugin' | 'global' = 'local'> = (context: LifecycleContext<Route, Singleton, Path, ParamsScope>) => MaybePromise<{} extends Route['response'] ? unknown : Route['response'][keyof Route['response']] | InlineHandlerResponse<Route['response']> | void>;
398
+ type AfterHandler<in out Route extends RouteSchema = {}, in out Singleton extends SingletonBase = DefaultSingleton, Path extends string | undefined = undefined, ParamsScope extends 'local' | 'plugin' | 'global' = 'local'> = (context: LifecycleContext<Route, Singleton, Path, ParamsScope> & {
399
+ responseValue: {} extends Route['response'] ? unknown : Route['response'][keyof Route['response']];
400
+ }) => MaybePromise<{} extends Route['response'] ? unknown : Route['response'][keyof Route['response']] | InlineHandlerResponse<Route['response']> | void>;
401
+ type MapResponse<in out Route extends RouteSchema = {}, in out Singleton extends SingletonBase = DefaultSingleton, Path extends string | undefined = undefined, ParamsScope extends 'local' | 'plugin' | 'global' = 'local'> = (context: LifecycleContext<Route, Singleton, Path, ParamsScope> & {
402
+ responseValue: {} extends Route['response'] ? unknown : Route['response'][keyof Route['response']];
403
+ }) => MaybePromise<Response | void>;
404
+ type VoidHandler<in out Route extends RouteSchema = {}, in out Singleton extends SingletonBase = DefaultSingleton> = (context: Context<Route, Singleton>) => MaybePromise<void>;
405
+ type TransformHandler<in out Route extends RouteSchema = {}, in out Singleton extends SingletonBase = DefaultSingleton, Path extends string | undefined = undefined, ParamsScope extends 'local' | 'plugin' | 'global' = 'local'> = (context: LifecycleContext<Route, Singleton, Path, ParamsScope>) => MaybePromise<void>;
406
+ type BodyHandler<in out Route extends RouteSchema = {}, in out Singleton extends SingletonBase = DefaultSingleton, Path extends string | undefined = undefined, ParamsScope extends 'local' | 'plugin' | 'global' = 'local'> = (context: LifecycleContext<Route, Singleton & {
407
+ decorator: {
408
+ contentType: string;
409
+ };
410
+ }, Path, ParamsScope>) => MaybePromise<any>;
411
+ type PreHandler<in out Route extends RouteSchema = {}, in out Singleton extends SingletonBase = DefaultSingleton> = (context: PreContext<Singleton>) => MaybePromise<Route['response'] | InlineHandlerResponse<Route['response']> | void>;
412
+ type AfterResponseHandler<in out Route extends RouteSchema = {}, in out Singleton extends SingletonBase = DefaultSingleton, Path extends string | undefined = undefined, ParamsScope extends 'local' | 'plugin' | 'global' = 'local'> = (context: LifecycleContext<Route, Singleton, Path, ParamsScope> & {
413
+ responseValue: {} extends Route['response'] ? unknown : Route['response'][keyof Route['response']];
414
+ }) => MaybePromise<unknown>;
415
+ type GracefulHandler<in Instance extends AnyElysia> = (data: Instance) => any;
416
+ type ResolveHandler<in out Route extends RouteSchema, in out Singleton extends SingletonBase> = (context: Context<Route, Singleton>) => MaybePromise<Record<string, unknown> | ElysiaError | AnyElysiaStatus | void>;
417
+ interface BunHTMLBundlelike {
418
+ index: string;
419
+ files?: {
420
+ input?: string;
421
+ path: string;
422
+ loader: any;
423
+ isEntry: boolean;
424
+ headers: {
425
+ etag: string;
426
+ 'content-type': string;
427
+ [key: string]: string;
383
428
  };
384
- }
385
- type PathParameterLike = `${string}/${':' | '*'}${string}`;
386
- export type IntersectIfObject<A, B> = A extends Record<any, any> ? B extends Record<any, any> ? A & B : A : B extends Record<any, any> ? B : A;
387
- export interface IntersectIfObjectSchema<A extends RouteSchema, B extends RouteSchema> {
388
- body: IntersectIfObject<A['body'], B['body']>;
389
- headers: IntersectIfObject<A['headers'], B['headers']>;
390
- query: IntersectIfObject<A['query'], B['query']>;
391
- params: IntersectIfObject<A['params'], B['params']>;
392
- cookie: IntersectIfObject<A['cookie'], B['cookie']>;
393
- response: IntersectIfObject<A['response'], B['response']>;
394
- }
395
- export type MergeSchema<A extends RouteSchema, B extends RouteSchema, Path extends string = ''> = {} extends A ? Path extends PathParameterLike ? Omit<B, 'params'> & {
396
- params: ResolvePath<Path>;
429
+ }[];
430
+ }
431
+ type InlineResponse = string | number | boolean | Record<any, unknown> | Response | AnyElysiaStatus | ElysiaFile | Blob | BunHTMLBundlelike | Error;
432
+ type InlineHandlerResponse<Route extends RouteSchema['response']> = { [Status in keyof Route]: ElysiaStatus<Status, Route[Status], Status> }[keyof Route];
433
+ type InlineHandler<Route extends RouteSchema = {}, Singleton extends SingletonBase = DefaultSingleton, MacroContext extends {
434
+ response: PossibleResponse;
435
+ return: PossibleResponse;
436
+ resolve: Record<string, unknown>;
437
+ } = {
438
+ response: {};
439
+ return: {};
440
+ resolve: {};
441
+ }> = InlineHandlerNonMacro<Route & MacroContext, Singleton & {
442
+ derive: MacroContext['resolve'];
443
+ }>;
444
+ type InlineHandlerNonMacro<Route extends RouteSchema = {}, Singleton extends SingletonBase = DefaultSingleton> = MaybePromise<InlineHandlerResponse<Route['response']> | ({} extends Route['response'] ? InlineResponse : Route['response'][keyof Route['response']])> | ((context: Context<Route, Singleton>) => MaybePromise<Response> | MaybePromise<{} extends Route['response'] ? unknown : (Route['response'] extends {
445
+ 200: any;
446
+ } ? Route['response'][200] | ElysiaStatus<200, Route['response'][200], 200> | Generator<Route['response'][200]> | AsyncGenerator<Route['response'][200]> : unknown) | Route['response'][keyof Route['response']] | InlineHandlerResponse<Route['response']>>);
447
+ type Handler = (context: Context) => unknown;
448
+ type CompiledHandler = (context: Partial<Context>) => MaybePromise<Response>;
449
+ type InternalRoute = readonly [method: string, path: string, handler: unknown, instance: AnyElysia, hook: AnyLocalHook | undefined, appHook: ChainNode | undefined, inheritedChain?: ChainNode, macroScope?: AnyElysia];
450
+ interface HistoryEntry {
451
+ readonly sequence: number;
452
+ readonly method: string;
453
+ readonly path: string;
454
+ readonly source?: string;
455
+ }
456
+ type ErrorHandler<T extends ErrorDefinition[] = [], in out Route extends RouteSchema = {}, in out Singleton extends SingletonBase = DefaultSingleton> = (context: ErrorContext<Route, {
457
+ store: Singleton['store'];
458
+ decorator: Singleton['decorator'];
459
+ derive: {};
460
+ }> & {
461
+ error: T[number]['error'] | Error;
462
+ }) => unknown;
463
+ type MergeSchema<A extends RouteSchema, B extends RouteSchema, Path extends string = '', AParamsPathDerived extends boolean = false> = {} extends A ? Path extends PathParameterLike ? Omit<B, 'params'> & {
464
+ params: ResolvePath<Path>;
397
465
  } : B : {} extends B ? Path extends PathParameterLike ? Omit<A, 'params'> & {
398
- params: ResolvePath<Path>;
466
+ params: ResolvePath<Path>;
399
467
  } : A : {
400
- body: undefined extends A['body'] ? B['body'] : A['body'];
401
- headers: undefined extends A['headers'] ? B['headers'] : A['headers'];
402
- query: undefined extends A['query'] ? B['query'] : A['query'];
403
- params: IsNever<keyof A['params']> extends true ? IsNever<keyof B['params']> extends true ? ResolvePath<Path> : B['params'] : IsNever<keyof B['params']> extends true ? A['params'] : Prettify<B['params'] & Omit<A['params'], keyof B['params']>>;
404
- cookie: undefined extends A['cookie'] ? B['cookie'] : A['cookie'];
405
- response: {} extends A['response'] ? {} extends B['response'] ? {} : B['response'] : {} extends B['response'] ? A['response'] : A['response'] & Omit<B['response'], keyof A['response']>;
468
+ body: undefined extends A['body'] ? B['body'] : A['body'];
469
+ headers: undefined extends A['headers'] ? B['headers'] : A['headers'];
470
+ query: undefined extends A['query'] ? B['query'] : A['query'];
471
+ params: AParamsPathDerived extends true ? IsNever<keyof B['params']> extends true ? A['params'] : B['params'] : IsNever<keyof A['params']> extends true ? IsNever<keyof B['params']> extends true ? ResolvePath<Path> : B['params'] : A['params'];
472
+ cookie: undefined extends A['cookie'] ? B['cookie'] : A['cookie'];
473
+ response: {} extends A['response'] ? {} extends B['response'] ? {} : B['response'] : {} extends B['response'] ? A['response'] : A['response'] & Omit<B['response'], keyof A['response']>;
406
474
  };
407
- export interface MergeStandaloneSchema<in out A extends RouteSchema, in out B extends RouteSchema, Path extends string = ''> {
408
- body: undefined extends A['body'] ? undefined extends B['body'] ? undefined : B['body'] : undefined extends B['body'] ? A['body'] : Prettify<A['body'] & B['body']>;
409
- headers: undefined extends A['headers'] ? undefined extends B['headers'] ? undefined : B['headers'] : undefined extends B['headers'] ? A['headers'] : Prettify<A['headers'] & B['headers']>;
410
- query: undefined extends A['query'] ? undefined extends B['query'] ? undefined : B['query'] : undefined extends B['query'] ? A['query'] : Prettify<A['query'] & B['query']>;
411
- params: IsNever<keyof A['params']> extends true ? IsNever<keyof B['params']> extends true ? ResolvePath<Path> : B['params'] : IsNever<keyof B['params']> extends true ? A['params'] : Prettify<A['params'] & B['params']>;
412
- cookie: undefined extends A['cookie'] ? undefined extends B['cookie'] ? undefined : B['cookie'] : undefined extends B['cookie'] ? A['cookie'] : Prettify<A['cookie'] & B['cookie']>;
413
- response: {} extends A['response'] ? {} extends B['response'] ? {} : B['response'] : {} extends B['response'] ? A['response'] : Prettify<A['response'] & B['response']>;
475
+ type AnyWSLocalHook = any;
476
+ type Equal<X, Y> = (<T>() => T extends X ? 1 : 2) extends (<T>() => T extends Y ? 1 : 2) ? true : false;
477
+ type IsNever<T> = [T] extends [never] ? true : false;
478
+ type UnionToIntersect<U> = (U extends unknown ? (arg: U) => 0 : never) extends ((arg: infer I) => 0) ? I : never;
479
+ interface PublicRoute {
480
+ method: HTTPMethod;
481
+ path: string;
482
+ handler: Handler;
483
+ hooks: AnyLocalHook;
484
+ compile(): CompiledHandler;
485
+ websocket?: AnyWSLocalHook;
486
+ }
487
+ type MaybeValueOrVoidFunction<T> = T | ((...a: any) => void | T);
488
+ type MacroProperty<Macro extends BaseMacro = {}, TypedRoute extends RouteSchema = {}, Singleton extends SingletonBase = DefaultSingleton, Errors extends ErrorDefinition[] = []> = Macro & {
489
+ /**
490
+ * Deduplication similar to Elysia.constructor.seed
491
+ */
492
+ seed?: unknown;
493
+ parse?: MaybeArray<BodyHandler<TypedRoute, Singleton>>;
494
+ transform?: MaybeArray<VoidHandler<TypedRoute, Singleton>>;
495
+ beforeHandle?: MaybeArray<OptionalHandler<TypedRoute, Singleton>>;
496
+ afterHandle?: MaybeArray<AfterHandler<TypedRoute, Singleton>>;
497
+ error?: MaybeArray<ErrorHandler<Errors, TypedRoute, Singleton>>;
498
+ mapResponse?: MaybeArray<MapResponse<TypedRoute, Singleton>>;
499
+ afterResponse?: MaybeArray<AfterResponseHandler<TypedRoute, Singleton>>;
500
+ derive?: MaybeArray<ResolveHandler<TypedRoute, Singleton>>;
501
+ detail?: DocumentDecoration;
502
+ /**
503
+ * Introspect hook option for documentation generation or analysis
504
+ *
505
+ * @param option
506
+ */
507
+ introspect?(option: Prettify<Macro>): unknown;
508
+ };
509
+ interface Macro<in out Macro extends BaseMacro = {}, in out Input extends BaseMacro = {}, in out TypedRoute extends RouteSchema = {}, in out Singleton extends SingletonBase = DefaultSingleton, Errors extends ErrorDefinition[] = []> {
510
+ [K: keyof any]: MaybeValueOrVoidFunction<Input & MacroProperty<Macro, TypedRoute, Singleton, Errors>>;
414
511
  }
415
- export type Handler<in out Route extends RouteSchema = {}, in out Singleton extends SingletonBase = {
416
- decorator: {};
417
- store: {};
418
- derive: {};
419
- resolve: {};
420
- }, Path extends string | undefined = undefined> = (context: Context<Route, Singleton, Path>) => MaybePromise<{} extends Route['response'] ? unknown : Route['response'][keyof Route['response']]>;
421
- export type IsAny<T> = 0 extends 1 & T ? true : false;
422
- export type Replace<Original, Target, With> = IsAny<Target> extends true ? Original : Original extends Record<string, unknown> ? {
423
- [K in keyof Original]: Original[K] extends Target ? With : Original[K];
424
- } : Original extends Target ? With : Original;
425
- export type CoExist<Original, Target, With> = IsAny<Target> extends true ? Original : Original extends Record<string, unknown> ? {
426
- [K in keyof Original]: Original[K] extends Target ? Original[K] | With : Original[K];
427
- } : Original extends Target ? Original | With : Original;
428
- export type MacroContextBlacklistKey = 'type' | 'detail' | 'parse' | 'transform' | 'resolve' | 'beforeHandle' | 'afterHandle' | 'mapResponse' | 'afterResponse' | 'error' | 'tags' | keyof RouteSchema;
429
- type ReturnTypeIfPossible<T, Enabled = true> = false extends Enabled ? {} : T extends (...a: any) => infer R ? R : T;
430
- type AnyElysiaCustomStatusResponse = ElysiaCustomStatusResponse<any, any, any>;
512
+ type JoinPath<A extends string, B extends string> = B extends `/${string}` ? `${A}${B}` : `${A}/${B}`;
513
+ type IsPathParameter<Part extends string> = Part extends `:${infer Parameter}` ? Parameter : Part extends `*` ? '*' : never;
514
+ type GetPathParameter<Path extends string> = Path extends `${infer A}/${infer B}` ? IsPathParameter<A> | GetPathParameter<B> : IsPathParameter<Path>;
515
+ type _ResolvePath<Path extends string> = { [Param in GetPathParameter<Path> as Param extends `${string}?` ? never : Param]: string } & { [Param in GetPathParameter<Path> as Param extends `${infer OptionalParam}?` ? OptionalParam : never]?: string };
516
+ type PathParameterLike = `${string}/${':' | '*'}${string}`;
517
+ type ResolvePath<Path extends string> = Path extends '' ? {} : Path extends PathParameterLike ? _ResolvePath<Path> : {};
518
+ type SetContentType = 'application/octet-stream' | 'application/vnd.ms-fontobject' | 'application/epub+zip' | 'application/gzip' | 'application/json' | 'application/ld+json' | 'application/ogg' | 'application/pdf' | 'application/rtf' | 'application/wasm' | 'application/xhtml+xml' | 'application/xml' | 'application/zip' | 'text/css' | 'text/csv' | 'text/calendar' | 'text/event-stream' | 'text/html' | 'text/javascript' | 'text/plain' | 'text/xml' | 'image/avif' | 'image/bmp' | 'image/gif' | 'image/x-icon' | 'image/jpeg' | 'image/png' | 'image/svg+xml' | 'image/tiff' | 'image/webp' | 'multipart/mixed' | 'multipart/alternative' | 'multipart/form-data' | 'audio/aac' | 'audio/x-midi' | 'audio/mpeg' | 'audio/ogg' | 'audio/opus' | 'audio/webm' | 'video/x-msvideo' | 'video/quicktime' | 'video/x-ms-wmv' | 'video/x-flv' | 'video/av1' | 'video/mp4' | 'video/mpeg' | 'video/ogg' | 'video/mp2t' | 'video/webm' | 'video/3gpp' | 'video/3gpp2' | 'font/otf' | 'font/ttf' | 'font/woff' | 'font/woff2' | 'model/gltf+json' | 'model/gltf-binary';
519
+ type HTTPHeaders = Record<string, string | number | string[]> & {
520
+ 'www-authenticate'?: string;
521
+ authorization?: string;
522
+ 'proxy-authenticate'?: string;
523
+ 'proxy-authorization'?: string;
524
+ age?: string;
525
+ 'cache-control'?: string;
526
+ 'clear-site-data'?: string;
527
+ expires?: string;
528
+ 'no-vary-search'?: string;
529
+ pragma?: string;
530
+ 'last-modified'?: string;
531
+ etag?: string;
532
+ 'if-match'?: string;
533
+ 'if-none-match'?: string;
534
+ 'if-modified-since'?: string;
535
+ 'if-unmodified-since'?: string;
536
+ vary?: string;
537
+ connection?: string;
538
+ 'keep-alive'?: string;
539
+ accept?: string;
540
+ 'accept-encoding'?: string;
541
+ 'accept-language'?: string;
542
+ expect?: string;
543
+ 'max-forwards'?: string;
544
+ cookie?: string;
545
+ 'set-cookie'?: string | string[];
546
+ 'access-control-allow-origin'?: string;
547
+ 'access-control-allow-credentials'?: string;
548
+ 'access-control-allow-headers'?: string;
549
+ 'access-control-allow-methods'?: string;
550
+ 'access-control-expose-headers'?: string;
551
+ 'access-control-max-age'?: string;
552
+ 'access-control-request-headers'?: string;
553
+ 'access-control-request-method'?: string;
554
+ origin?: string;
555
+ 'timing-allow-origin'?: string;
556
+ 'content-disposition'?: string;
557
+ 'content-length'?: string | number;
558
+ 'content-type'?: SetContentType | (string & {});
559
+ 'content-encoding'?: string;
560
+ 'content-language'?: string;
561
+ 'content-location'?: string;
562
+ forwarded?: string;
563
+ via?: string;
564
+ location?: string;
565
+ refresh?: string;
566
+ allow?: string;
567
+ server?: 'Elysia' | (string & {});
568
+ 'accept-ranges'?: string;
569
+ range?: string;
570
+ 'if-range'?: string;
571
+ 'content-range'?: string;
572
+ 'content-security-policy'?: string;
573
+ 'content-security-policy-report-only'?: string;
574
+ 'cross-origin-embedder-policy'?: string;
575
+ 'cross-origin-opener-policy'?: string;
576
+ 'cross-origin-resource-policy'?: string;
577
+ 'expect-ct'?: string;
578
+ 'permission-policy'?: string;
579
+ 'strict-transport-security'?: string;
580
+ 'upgrade-insecure-requests'?: string;
581
+ 'x-content-type-options'?: string;
582
+ 'x-frame-options'?: string;
583
+ 'x-xss-protection'?: string;
584
+ 'last-event-id'?: string;
585
+ 'ping-from'?: string;
586
+ 'ping-to'?: string;
587
+ 'report-to'?: string;
588
+ te?: string;
589
+ trailer?: string;
590
+ 'transfer-encoding'?: string;
591
+ 'alt-svg'?: string;
592
+ 'alt-used'?: string;
593
+ date?: string;
594
+ dnt?: string;
595
+ 'early-data'?: string;
596
+ 'large-allocation'?: string;
597
+ link?: string;
598
+ 'retry-after'?: string;
599
+ 'service-worker-allowed'?: string;
600
+ 'source-map'?: string;
601
+ upgrade?: string;
602
+ 'x-dns-prefetch-control'?: string;
603
+ 'x-forwarded-for'?: string;
604
+ 'x-forwarded-host'?: string;
605
+ 'x-forwarded-proto'?: string;
606
+ 'x-powered-by'?: 'Elysia' | (string & {});
607
+ 'x-request-id'?: string;
608
+ 'x-requested-with'?: string;
609
+ 'x-robots-tag'?: string;
610
+ 'x-ua-compatible'?: string;
611
+ };
612
+ type AnyErrorConstructor = {
613
+ prototype: Error;
614
+ };
615
+ type ContextAppendType = 'append' | 'override';
616
+ type OptionalField = {
617
+ '~optional': true;
618
+ };
619
+ type StaticCyclic<T extends TypeBoxSchema, Definitions extends Record<string, AnySchema>> = {} extends Definitions ? StaticDecode<T> : StaticDecode<T, Definitions>;
620
+ type UnwrapSchema<Schema extends AnySchema | string | undefined, Definitions extends DefinitionBase['typebox'] = {}> = Schema extends undefined ? unknown : Schema extends TypeBoxSchema ? Schema extends OptionalField ? Partial<StaticCyclic<Schema, Definitions>> : StaticCyclic<Schema, Definitions> : Schema extends StandardSchemaV1Like ? NonNullable<Schema['~standard']['types']>['output'] : Schema extends string ? Schema extends keyof Definitions ? Definitions[Schema] extends TypeBoxSchema ? StaticCyclic<Definitions[Schema], Definitions> : Definitions[Schema] extends StandardSchemaV1Like ? NonNullable<Definitions[Schema]['~standard']['types']>['output'] : unknown : unknown : unknown;
621
+ type UnwrapBodySchema<Schema extends AnySchema | string | undefined, Definitions extends DefinitionBase['typebox'] = {}> = undefined extends Schema ? unknown : Schema extends TypeBoxSchema ? Schema extends OptionalField ? Partial<StaticCyclic<Schema, Definitions>> | null : StaticCyclic<Schema, Definitions> : Schema extends StandardSchemaV1Like ? NonNullable<Schema['~standard']['types']>['output'] : Schema extends string ? Schema extends keyof Definitions ? Definitions[Schema] extends TypeBoxSchema ? StaticCyclic<Definitions[Schema], Definitions> : Definitions[Schema] extends StandardSchemaV1Like ? NonNullable<Definitions[Schema]['~standard']['types']>['output'] : unknown : unknown : unknown;
622
+ type FormInnerProperties<Schema> = Extract<Schema extends TIntersect<infer Members> ? Members[number] : never, TObject>['properties'];
623
+ type UnwrapResponseSchema<Schema extends AnySchema | string | undefined, Definitions extends DefinitionBase['typebox'] = {}> = Schema extends TypeBoxSchema ? StaticEncode<Schema> extends {
624
+ '~ely-form': any;
625
+ } ? ElysiaFormData<{ [K in keyof FormInnerProperties<Schema>]: Static<FormInnerProperties<Schema>[K] & TSchema> }> : UnwrapSchema<Schema, Definitions> : Schema extends StandardSchemaV1Like ? NonNullable<Schema['~standard']['types']>['input'] : Schema extends string ? Schema extends keyof Definitions ? Definitions[Schema] extends TypeBoxSchema ? StaticCyclic<Definitions[Schema], Definitions> : Definitions[Schema] extends StandardSchemaV1Like ? NonNullable<Definitions[Schema]['~standard']['types']>['input'] : unknown : unknown : unknown;
626
+ interface UnwrapRoute<in out Schema extends InputSchema<any>, in out Definitions extends DefinitionBase['typebox'] = {}, in out Path extends string = ''> {
627
+ body: UnwrapBodySchema<Schema['body'], Definitions>;
628
+ headers: UnwrapSchema<Schema['headers'], Definitions>;
629
+ query: UnwrapSchema<Schema['query'], Definitions>;
630
+ params: {} extends Schema['params'] ? ResolvePath<Path> : {} extends Schema ? ResolvePath<Path> : UnwrapSchema<Schema['params'], Definitions>;
631
+ cookie: UnwrapSchema<Schema['cookie'], Definitions>;
632
+ response: Schema['response'] extends AnySchema | string ? {
633
+ 200: UnwrapResponseSchema<Schema['response'], Definitions> extends infer A ? A extends File ? File | ElysiaFile : A : unknown;
634
+ } : Schema['response'] extends { [status in number]: AnySchema | string } ? { [k in keyof Schema['response']]: UnwrapResponseSchema<Schema['response'][k], Definitions> extends infer A ? A extends File ? File | ElysiaFile : A : unknown } : unknown | void;
635
+ }
636
+ type LocalLifecycleProperty = 'detail' | 'parse' | 'transform' | 'beforeHandle' | 'afterHandle' | 'mapResponse' | 'afterResponse' | 'error' | 'tags';
637
+ type MacroToProperty<in out T> = Prettify<{ [K in keyof T]: T[K] extends Function ? T[K] extends ((a: infer Params) => any) ? Params : boolean : boolean }>;
638
+ type NonResolvableMacroKey = LocalLifecycleProperty | keyof InputSchema | 'derive';
639
+ interface RouteSchemaWithResolvedMacro extends RouteSchema {
640
+ response: PossibleResponse;
641
+ return: PossibleResponse;
642
+ resolve: Record<string, unknown>;
643
+ }
644
+ type IntersectIfObject<A, B> = unknown extends A ? B : A extends Record<any, any> ? B extends Record<any, any> ? A & B : A : B extends Record<any, any> ? B : A;
645
+ interface IntersectIfObjectSchema<A extends RouteSchema, B extends RouteSchema> {
646
+ body: IntersectIfObject<A['body'], B['body']>;
647
+ headers: IntersectIfObject<A['headers'], B['headers']>;
648
+ query: IntersectIfObject<A['query'], B['query']>;
649
+ params: IntersectIfObject<A['params'], B['params']>;
650
+ cookie: IntersectIfObject<A['cookie'], B['cookie']>;
651
+ response: {} extends A['response'] ? {} extends B['response'] ? A['response'] : B['response'] : {} extends B['response'] ? A['response'] : { [K in keyof A['response'] | keyof B['response']]: K extends keyof A['response'] ? K extends keyof B['response'] ? IntersectIfObject<A['response'][K], B['response'][K]> : A['response'][K] : K extends keyof B['response'] ? B['response'][K] : never };
652
+ }
653
+ interface MergeScopedSchemas<Global extends RouteSchema, Scoped extends RouteSchema, Local extends RouteSchema> {
654
+ body: Global['body'] & Scoped['body'] & Local['body'];
655
+ headers: Global['headers'] & Scoped['headers'] & Local['headers'];
656
+ query: Global['query'] & Scoped['query'] & Local['query'];
657
+ params: Global['params'] & Scoped['params'] & Local['params'];
658
+ cookie: Global['cookie'] & Scoped['cookie'] & Local['cookie'];
659
+ response: { [K in keyof Global['response'] | keyof Scoped['response'] | keyof Local['response']]: K extends keyof Local['response'] ? Local['response'][K] : K extends keyof Scoped['response'] ? Scoped['response'][K] : K extends keyof Global['response'] ? Global['response'][K] : never };
660
+ }
661
+ type ReturnTypeIfPossible<T, Enabled = true> = false extends Enabled ? {} : T extends ((...a: any) => infer R) ? R : T;
431
662
  type FunctionArrayReturnType<T> = any[] extends T ? never : T extends any[] ? _FunctionArrayReturnType<T> : Awaited<ReturnType<T>>;
432
- type _FunctionArrayReturnType<T, Carry = undefined> = T extends [
433
- infer Fn,
434
- ...infer Rest
435
- ] ? _FunctionArrayReturnType<Rest, Awaited<ReturnType<Fn>> extends infer A ? IsNever<A> extends true ? Carry : A | Carry : Carry> : Carry;
663
+ type _FunctionArrayReturnType<T, Carry = undefined> = T extends [infer Fn, ...infer Rest] ? _FunctionArrayReturnType<Rest, Awaited<ReturnType<Fn>> extends infer A ? IsNever<A> extends true ? Carry : A | Carry : Carry> : Carry;
436
664
  type FunctionArrayReturnTypeNonNullable<T> = any[] extends T ? never : T extends any[] ? _FunctionArrayReturnTypeNonNullable<T> : NonNullable<Awaited<ReturnType<T>>>;
437
- type _FunctionArrayReturnTypeNonNullable<T, Carry = undefined> = T extends [
438
- infer Fn,
439
- ...infer Rest
440
- ] ? _FunctionArrayReturnTypeNonNullable<Rest, NonNullable<Awaited<ReturnType<Fn>>> extends infer A ? IsNever<A> extends true ? Carry : A | Carry : Carry> : Carry;
441
- type ExtractResolveFromMacro<A> = IsNever<A> extends true ? {} : A extends AnyElysiaCustomStatusResponse ? A : Exclude<A, AnyElysiaCustomStatusResponse> extends infer A ? IsAny<A> extends true ? {} : A : {};
442
- type ExtractOnlyResponseFromMacro<A> = IsNever<A> extends true ? {} : Extract<A, AnyElysiaCustomStatusResponse> extends infer A ? IsNever<A> extends true ? {} : {
443
- return: MergeResponseStatus<A>;
665
+ type _FunctionArrayReturnTypeNonNullable<T, Carry = undefined> = T extends [infer Fn, ...infer Rest] ? _FunctionArrayReturnTypeNonNullable<Rest, NonNullable<Awaited<ReturnType<Fn>>> extends infer A ? IsNever<A> extends true ? Carry : A | Carry : Carry> : Carry;
666
+ type AnyElysiaStatus = ElysiaStatus<any, any, any>;
667
+ type ExcludeElysiaResponse<T> = Exclude<Awaited<T>, AnyElysiaStatus> extends infer A ? IsNever<A & {}> extends true ? {} : undefined extends A ? Partial<A & {}> : A & {} : {};
668
+ type ExtractResolveFromMacro<A> = IsNever<A> extends true ? {} : A extends AnyElysiaStatus ? A : Exclude<A, AnyElysiaStatus> extends infer A ? IsAny<A> extends true ? {} : A : {};
669
+ type ExtractOnlyResponseFromMacro<A> = IsNever<A> extends true ? {} : Extract<A, AnyElysiaStatus> extends infer A ? IsNever<A> extends true ? {} : {
670
+ return: MergeResponseStatus<A>;
444
671
  } : {};
445
- type MergeResponseStatus<A> = {
446
- [status in keyof UnionToIntersect<A extends ElysiaCustomStatusResponse<any, any, infer Status> ? {
447
- [A in Status]: 1;
448
- } : never>]: Extract<A, {
449
- code: status;
450
- }>['response'] extends infer Value ? IsAny<Value> extends true ? InvertedStatusMap[status] : Value : never;
451
- };
452
- type MergeAllStatus<T> = {
453
- [K in T extends any ? keyof T : never]: T extends Record<K, infer V> ? V : never;
454
- };
672
+ type MergeResponseStatus<A> = { [status in keyof UnionToIntersect<A extends ElysiaStatus<any, any, infer Status> ? { [A in Status]: 1 } : never>]: Extract<A, {
673
+ code: status;
674
+ }>['response'] extends infer Value ? IsAny<Value> extends true ? StatusMapBack[status] : Value : never };
455
675
  type ExtractAllResponseFromMacro<A> = IsNever<A> extends true ? {} : {
456
- return: MergeResponseStatus<A> & (Exclude<A, AnyElysiaCustomStatusResponse> extends infer A ? IsAny<A> extends true ? {} : IsNever<A> extends true ? {} : NonNullable<void> extends A ? {} : undefined extends A ? {} : {
457
- 200: A;
458
- } : {});
676
+ return: MergeResponseStatus<A> & (Exclude<A, AnyElysiaStatus> extends infer A ? IsAny<A> extends true ? {} : IsNever<A> extends true ? {} : NonNullable<void> extends A ? {} : undefined extends A ? {} : {
677
+ 200: A;
678
+ } : {});
459
679
  };
460
- type FlattenMacroResponse<T> = T extends object ? '_' extends keyof T ? MergeFlattenMacroResponse<Omit<T, '_'>, FlattenMacroResponse<MergeAllStatus<T['_']>>> : T : T;
461
- type MergeFlattenMacroResponse<A, B> = {
462
- [K in keyof A | keyof B]: K extends keyof A ? K extends keyof B ? A[K] | B[K] : A[K] : K extends keyof B ? B[K] : never;
680
+ type FlattenMacroResponse<T> = T extends object ? '_' extends keyof T ? UnionResponseStatus<Omit<T, '_'>, FlattenMacroResponse<MergeStatusUnion<T['_']>>> : T : T;
681
+ type UnionMacroContext<A> = UnionToIntersect<{ [K in Exclude<keyof A, 'return'>]: A[K] }> & {
682
+ return: {
683
+ _: A['return'];
684
+ };
463
685
  };
464
- type UnionMacroContext<A> = UnionToIntersect<{
465
- [K in Exclude<keyof A, 'return'>]: A[K];
466
- }> & {
467
- return: {
468
- _: A['return'];
469
- };
470
- };
471
- export type MacroToContext<in out MacroFn extends Macro = {}, in out SelectedMacro extends BaseMacro = {}, in out Definitions extends DefinitionBase['typebox'] = {}, in out R extends 1[] = []> = Prettify<InnerMacroToContext<MacroFn, Pick<SelectedMacro, Extract<keyof MacroFn, keyof SelectedMacro>>, Definitions, R> extends infer A ? {
472
- [K in Exclude<keyof A, 'return'>]: UnionToIntersect<A[K]>;
473
- } & Prettify<{
474
- return: FlattenMacroResponse<A['return']>;
686
+ type MacroToContext<in out MacroFn extends Macro = {}, in out SelectedMacro extends BaseMacro = {}, in out Definitions extends DefinitionBase['typebox'] = {}, in out R extends 1[] = []> = Prettify<InnerMacroToContext<MacroFn, Pick<SelectedMacro, Extract<keyof MacroFn, keyof SelectedMacro>>, Definitions, R> extends infer A ? { [K in Exclude<keyof A, 'return'>]: UnionToIntersect<A[K]> } & Prettify<{
687
+ return: FlattenMacroResponse<A['return']>;
475
688
  }> : {}>;
476
- type InnerMacroToContext<MacroFn extends Macro = {}, SelectedMacro extends BaseMacro = {}, Definitions extends DefinitionBase['typebox'] = {}, R extends 1[] = []> = {} extends SelectedMacro ? {} : R['length'] extends 15 ? {} : UnionMacroContext<{
477
- [key in keyof SelectedMacro]: ReturnTypeIfPossible<MacroFn[key], SelectedMacro[key]> extends infer Value ? {
478
- resolve: ExtractResolveFromMacro<Extract<Exclude<FunctionArrayReturnType<Value['resolve']>, AnyElysiaCustomStatusResponse>, Record<any, unknown>>>;
479
- } & UnwrapMacroSchema<Value, Definitions> & ExtractAllResponseFromMacro<FunctionArrayReturnTypeNonNullable<Value['beforeHandle']>> & ExtractAllResponseFromMacro<FunctionArrayReturnTypeNonNullable<Value['afterHandle']>> & ExtractAllResponseFromMacro<FunctionArrayReturnType<Value['error']>> & ExtractOnlyResponseFromMacro<FunctionArrayReturnTypeNonNullable<Value['resolve']>> & InnerMacroToContext<MacroFn, Pick<Value, Extract<keyof MacroFn, keyof Value>>, Definitions, [
480
- ...R,
481
- 1
482
- ]> : {};
483
- }[keyof SelectedMacro]>;
689
+ type InnerMacroToContext<MacroFn extends Macro = {}, SelectedMacro extends BaseMacro = {}, Definitions extends DefinitionBase['typebox'] = {}, R extends 1[] = []> = {} extends SelectedMacro ? {} : R['length'] extends 15 ? {} : UnionMacroContext<{ [key in keyof SelectedMacro]: ReturnTypeIfPossible<MacroFn[key], SelectedMacro[key]> extends infer Value ? {
690
+ q: UnwrapMacroSchema<Value, Definitions>;
691
+ resolve: ExtractResolveFromMacro<Extract<Exclude<FunctionArrayReturnType<Value['derive']>, AnyElysiaStatus>, Record<any, unknown>>>;
692
+ } & UnwrapMacroSchema<Value, Definitions> & ExtractAllResponseFromMacro<FunctionArrayReturnTypeNonNullable<Value['beforeHandle']>> & ExtractAllResponseFromMacro<FunctionArrayReturnTypeNonNullable<Value['afterHandle']>> & ExtractAllResponseFromMacro<FunctionArrayReturnType<Value['error']>> & ExtractOnlyResponseFromMacro<FunctionArrayReturnTypeNonNullable<Value['derive']>> & InnerMacroToContext<MacroFn, Pick<Value, Extract<keyof MacroFn, keyof Value>>, Definitions, [...R, 1]> : {} }[keyof SelectedMacro]>;
484
693
  type UnwrapMacroSchema<T extends Partial<InputSchema<any>>, Definitions extends DefinitionBase['typebox'] = {}> = UnwrapRoute<{
485
- body: 'body' extends keyof T ? T['body'] : undefined;
486
- headers: 'headers' extends keyof T ? T['headers'] : undefined;
487
- query: 'query' extends keyof T ? T['query'] : undefined;
488
- params: 'params' extends keyof T ? T['params'] : undefined;
489
- cookie: 'cookie' extends keyof T ? T['cookie'] : undefined;
490
- response: 'response' extends keyof T ? T['response'] : undefined;
694
+ body: 'body' extends keyof T ? T['body'] : undefined;
695
+ headers: 'headers' extends keyof T ? T['headers'] : undefined;
696
+ query: 'query' extends keyof T ? T['query'] : undefined;
697
+ params: 'params' extends keyof T ? T['params'] : undefined;
698
+ cookie: 'cookie' extends keyof T ? T['cookie'] : undefined;
699
+ response: 'response' extends keyof T ? T['response'] : undefined;
491
700
  }, Definitions>;
492
- export type SimplifyToSchema<T extends InputSchema<any>> = IsUnknown<T['body']> extends false ? _SimplifyToSchema<T> : IsUnknown<T['headers']> extends false ? _SimplifyToSchema<T> : IsUnknown<T['query']> extends false ? _SimplifyToSchema<T> : IsUnknown<T['params']> extends false ? _SimplifyToSchema<T> : IsUnknown<T['cookie']> extends false ? _SimplifyToSchema<T> : IsUnknown<T['response']> extends false ? _SimplifyToSchema<T> : {};
493
- export type _SimplifyToSchema<T extends InputSchema<any>> = Omit<{
494
- body: T['body'];
495
- headers: T['headers'];
496
- query: T['query'];
497
- params: T['params'];
498
- cookie: T['cookie'];
499
- response: T['response'];
500
- }, ('body' extends keyof T ? never : 'body') | ('headers' extends keyof T ? never : 'headers') | ('query' extends keyof T ? never : 'query') | ('params' extends keyof T ? never : 'params') | ('cookie' extends keyof T ? never : 'cookie') | ('response' extends keyof T ? never : 'response')>;
501
- type InlineHandlerResponse<Route extends RouteSchema['response']> = {
502
- [Status in keyof Route]: ElysiaCustomStatusResponse<Status, Route[Status], Status>;
503
- }[keyof Route];
504
- type InlineResponse = string | number | boolean | Record<any, unknown> | Response | AnyElysiaCustomStatusResponse | ElysiaFile | Record<any, unknown> | BunHTMLBundlelike;
505
- type LastOf<T> = UnionToIntersect<T extends any ? () => T : never> extends () => infer R ? R : never;
506
- type Push<T extends any[], V> = [...T, V];
507
- type TuplifyUnion<T, L = LastOf<T>, N = [T] extends [never] ? true : false> = true extends N ? [] : Push<TuplifyUnion<Exclude<T, L>>, L>;
508
- export type Tuple<T, A extends T[] = []> = TuplifyUnion<T>['length'] extends A['length'] ? [...A] : Tuple<T, [T, ...A]>;
509
- export type InlineHandler<Route extends RouteSchema = {}, Singleton extends SingletonBase = {
510
- decorator: {};
511
- store: {};
512
- derive: {};
513
- resolve: {};
514
- }, MacroContext extends {
515
- response: PossibleResponse;
516
- return: PossibleResponse;
517
- resolve: Record<string, unknown>;
518
- } = {
519
- response: {};
520
- return: {};
521
- resolve: {};
522
- }> = MaybePromise<InlineResponse> | ((context: Context<Route & MacroContext, Singleton & {
523
- resolve: MacroContext['resolve'];
524
- }>) => MaybePromise<Response> | MaybePromise<{} extends Route['response'] ? unknown : (Route['response'] extends {
525
- 200: any;
526
- } ? Route['response'][200] | ElysiaCustomStatusResponse<200, Route['response'][200], 200> | Generator<Route['response'][200]> | AsyncGenerator<Route['response'][200]> : unknown) | Route['response'][keyof Route['response']] | InlineHandlerResponse<Route['response'] & MacroContext['response']>>);
527
- export type InlineHandlerNonMacro<Route extends RouteSchema = {}, Singleton extends SingletonBase = {
528
- decorator: {};
529
- store: {};
530
- derive: {};
531
- resolve: {};
532
- }> = MaybePromise<InlineResponse> | ((context: Context<Route, Singleton>) => MaybePromise<Response> | MaybePromise<{} extends Route['response'] ? unknown : (Route['response'] extends {
533
- 200: any;
534
- } ? Route['response'][200] | ElysiaCustomStatusResponse<200, Route['response'][200], 200> | Generator<Route['response'][200]> | AsyncGenerator<Route['response'][200]> : unknown) | Route['response'][keyof Route['response']] | InlineHandlerResponse<Route['response']>>);
535
- export type OptionalHandler<in out Route extends RouteSchema = {}, in out Singleton extends SingletonBase = {
536
- decorator: {};
537
- store: {};
538
- derive: {};
539
- resolve: {};
540
- }, Path extends string | undefined = undefined> = (context: Context<Route, Singleton, Path>) => MaybePromise<{} extends Route['response'] ? unknown : Route['response'][keyof Route['response']] | InlineHandlerResponse<Route['response']> | void>;
541
- export type AfterHandler<in out Route extends RouteSchema = {}, in out Singleton extends SingletonBase = {
542
- decorator: {};
543
- store: {};
544
- derive: {};
545
- resolve: {};
546
- }, Path extends string | undefined = undefined> = (context: Context<Route, Singleton, Path> & {
547
- responseValue: {} extends Route['response'] ? unknown : Route['response'][keyof Route['response']];
548
- /**
549
- * @deprecated use `context.responseValue` instead
550
- */
551
- response: {} extends Route['response'] ? unknown : Route['response'][keyof Route['response']];
552
- }) => MaybePromise<{} extends Route['response'] ? unknown : Route['response'][keyof Route['response']] | InlineHandlerResponse<Route['response']> | void>;
553
- export type MapResponse<in out Route extends RouteSchema = {}, in out Singleton extends SingletonBase = {
554
- decorator: {};
555
- store: {};
556
- derive: {};
557
- resolve: {};
558
- }, Path extends string | undefined = undefined> = (context: Context<Route, Singleton, Path> & {
559
- responseValue: {} extends Route['response'] ? unknown : Route['response'][keyof Route['response']];
560
- /**
561
- * @deprecated use `context.responseValue` instead
562
- */
563
- response: {} extends Route['response'] ? unknown : Route['response'][keyof Route['response']];
564
- }) => MaybePromise<Response | void>;
565
- export type VoidHandler<in out Route extends RouteSchema = {}, in out Singleton extends SingletonBase = {
566
- decorator: {};
567
- store: {};
568
- derive: {};
569
- resolve: {};
570
- }> = (context: Context<Route, Singleton>) => MaybePromise<void>;
571
- export type TransformHandler<in out Route extends RouteSchema = {}, in out Singleton extends SingletonBase = {
572
- decorator: {};
573
- store: {};
574
- derive: {};
575
- resolve: {};
576
- }, Path extends string | undefined = undefined> = (context: Context<Route, Omit<Singleton, 'resolve'> & {
577
- resolve: {};
578
- }, Path>) => MaybePromise<void>;
579
- export type BodyHandler<in out Route extends RouteSchema = {}, in out Singleton extends SingletonBase = {
580
- decorator: {};
581
- store: {};
582
- derive: {};
583
- resolve: {};
584
- }, Path extends string | undefined = undefined> = (context: Context<Route, Singleton & {
585
- decorator: {
586
- contentType: string;
587
- };
588
- }, Path>,
701
+ type MacroPropertyKey = keyof MacroProperty;
702
+ type AsMacroSchemaField<T> = [T] extends [never] ? undefined : [unknown] extends [T] ? undefined : T extends AnySchema | string ? T : undefined;
703
+ type MacroDefSchema<K, MBody, MHeaders, MQuery, MParams, MCookie> = {
704
+ body: AsMacroSchemaField<K extends keyof MBody ? MBody[K] : undefined>;
705
+ headers: AsMacroSchemaField<K extends keyof MHeaders ? MHeaders[K] : undefined>;
706
+ query: AsMacroSchemaField<K extends keyof MQuery ? MQuery[K] : undefined>;
707
+ params: AsMacroSchemaField<K extends keyof MParams ? MParams[K] : undefined>;
708
+ cookie: AsMacroSchemaField<K extends keyof MCookie ? MCookie[K] : undefined>;
709
+ response: undefined;
710
+ };
711
+ type MacroSchemaChannel<Definitions extends DefinitionBase> = Record<keyof any, AnySchema | (keyof Definitions['typebox'] & string)>;
712
+ type MacroChannel<Channel, Key extends keyof InputSchema, Definitions extends DefinitionBase> = { [K in keyof Channel]: MaybeValueOrVoidFunction<{ [F in Key]?: Channel[K] | (keyof Definitions['typebox'] & string) } & Record<string, unknown>> };
589
713
  /**
590
- * @deprecated
714
+ * Captures the verbatim `.macro()` definition record into a separate first-pass
715
+ * generic (mirrors {@link MacroChannel}). This lets each definition's enabled
716
+ * sibling flags (`{ auth: true }`) be read back without reusing the contextually
717
+ * typed `NewMacro`, which would form the record -> handler-typing inference
718
+ * cycle documented on {@link ObjectMacroDefs}.
719
+ */
720
+ type MacroRefChannel<Refs> = { [K in keyof Refs]: MaybeValueOrVoidFunction<{ [M in keyof Refs[K]]?: Refs[K][M] } & Record<string, unknown>> };
721
+ /**
722
+ * `resolve` (derive) context contributed by the sibling macros a definition
723
+ * enables via `{ name: true }`. Extracted through `infer` because
724
+ * {@link MacroToContext} is a mapped type whose `resolve` key cannot be indexed
725
+ * with a plain `['resolve']` on the generic form.
726
+ */
727
+ type MacroRefResolve<MacroFn, SelectedMacro, Definitions> = MacroToContext<MacroFn, SelectedMacro, Definitions> extends {
728
+ resolve: infer Resolve;
729
+ } ? Resolve : {};
730
+ /**
731
+ * Parameter type of the object-form `.macro({ name: definition })`
591
732
  *
592
- * use `context.contentType` instead
733
+ * TypeScript cannot infer one generic from a record while ALSO using it to
734
+ * contextually type that record's own handlers (the inference cycle that
735
+ * historically forced the named `.macro(name, def)` overload).
593
736
  *
594
- * @example
595
- * ```ts
596
- * new Elysia()
597
- * .onParse(({ contentType, request }) => {
598
- * if (contentType === 'application/json')
599
- * return request.json()
600
- * })
601
- * ```
737
+ * Handler member only consumes them so `derive`/ `beforeHandle`
738
+ * see their sibling schema fully typed while their return types
739
+ * still flow into `N` (the verbatim definitions, stored in
740
+ * `Metadata['macroFn']` for the consuming route)
602
741
  */
603
- contentType: string) => MaybePromise<any>;
604
- export type PreHandler<in out Route extends RouteSchema = {}, in out Singleton extends SingletonBase = {
605
- decorator: {};
606
- store: {};
607
- derive: {};
608
- resolve: {};
609
- }> = (context: PreContext<Singleton>) => MaybePromise<Route['response'] | InlineHandlerResponse<Route['response']> | void>;
610
- export type AfterResponseHandler<in out Route extends RouteSchema = {}, in out Singleton extends SingletonBase = {
611
- decorator: {};
612
- store: {};
613
- derive: {};
614
- resolve: {};
615
- }> = (context: Context<Route, Singleton> & {
616
- responseValue: {} extends Route['response'] ? unknown : Route['response'][keyof Route['response']];
617
- /**
618
- * @deprecated use `context.responseValue` instead
619
- */
620
- response: {} extends Route['response'] ? unknown : Route['response'][keyof Route['response']] | InlineHandlerResponse<Route['response']>;
621
- }) => MaybePromise<unknown>;
622
- export type GracefulHandler<in Instance extends AnyElysia> = (data: Instance) => any;
623
- export type ErrorHandler<in out T extends Record<string, Error> = {}, in out Route extends RouteSchema = {}, in out Singleton extends SingletonBase = {
624
- decorator: {};
625
- store: {};
626
- derive: {};
627
- resolve: {};
628
- }, in out Ephemeral extends EphemeralType = {
629
- derive: {};
630
- resolve: {};
631
- schema: {};
632
- standaloneSchema: {};
633
- response: {};
634
- }, in out Volatile extends EphemeralType = {
635
- derive: {};
636
- resolve: {};
637
- schema: {};
638
- standaloneSchema: {};
639
- response: {};
640
- }> = (context: ErrorContext<Route, {
641
- store: Singleton['store'];
642
- decorator: Singleton['decorator'];
643
- derive: {};
644
- resolve: {};
645
- }> & (Prettify<{
646
- request: Request;
647
- code: 'UNKNOWN';
648
- error: Readonly<Error>;
649
- set: Context['set'];
650
- } & Partial<Singleton['derive'] & Ephemeral['derive'] & Volatile['derive'] & Singleton['resolve'] & Ephemeral['resolve'] & Volatile['resolve']>> | Prettify<{
651
- request: Request;
652
- code: 'VALIDATION';
653
- error: Readonly<ValidationError>;
654
- set: Context['set'];
655
- } & Singleton['derive'] & Ephemeral['derive'] & Volatile['derive'] & NeverKey<Singleton['resolve'] & Ephemeral['resolve'] & Volatile['resolve']>> | Prettify<{
656
- request: Request;
657
- code: 'NOT_FOUND';
658
- error: Readonly<NotFoundError>;
659
- set: Context['set'];
660
- } & NeverKey<Singleton['derive'] & Ephemeral['derive'] & Volatile['derive'] & Singleton['resolve'] & Ephemeral['resolve'] & Volatile['resolve']>> | Prettify<{
661
- request: Request;
662
- code: 'PARSE';
663
- error: Readonly<ParseError>;
664
- set: Context['set'];
665
- } & NeverKey<Singleton['derive'] & Ephemeral['derive'] & Volatile['derive'] & Singleton['resolve'] & Ephemeral['resolve'] & Volatile['resolve']>> | Prettify<{
666
- request: Request;
667
- code: 'INTERNAL_SERVER_ERROR';
668
- error: Readonly<InternalServerError>;
669
- set: Context['set'];
670
- } & Partial<Singleton['derive'] & Ephemeral['derive'] & Volatile['derive'] & Singleton['resolve'] & Ephemeral['resolve'] & Volatile['resolve']>> | Prettify<{
671
- request: Request;
672
- code: 'INVALID_COOKIE_SIGNATURE';
673
- error: Readonly<InvalidCookieSignature>;
674
- set: Context['set'];
675
- } & NeverKey<Singleton['derive'] & Ephemeral['derive'] & Volatile['derive'] & Singleton['resolve'] & Ephemeral['resolve'] & Volatile['resolve']>> | Prettify<{
676
- request: Request;
677
- code: 'INVALID_FILE_TYPE';
678
- error: Readonly<InvalidFileType>;
679
- set: Context['set'];
680
- } & Singleton['derive'] & Ephemeral['derive'] & Volatile['derive'] & NeverKey<Singleton['resolve'] & Ephemeral['resolve'] & Volatile['resolve']>> | Prettify<{
681
- request: Request;
682
- code: number;
683
- error: Readonly<ElysiaCustomStatusResponse<number>>;
684
- set: Context['set'];
685
- } & Partial<Singleton['derive'] & Ephemeral['derive'] & Volatile['derive'] & Singleton['resolve'] & Ephemeral['resolve'] & Volatile['resolve']>> | Prettify<{
686
- [K in keyof T]: {
687
- request: Request;
688
- code: K;
689
- error: Readonly<T[K]>;
690
- set: Context['set'];
691
- };
692
- }[keyof T] & Partial<Singleton['derive'] & Ephemeral['derive'] & Volatile['derive'] & Singleton['resolve'] & Ephemeral['resolve'] & Volatile['resolve']>>)) => any | Promise<any>;
693
- export interface DocumentDecoration extends Partial<OpenAPIV3.OperationObject> {
694
- /**
695
- * Pass `true` to hide route from OpenAPI/swagger document
696
- * */
697
- hide?: boolean;
698
- }
699
- export type ResolveHandler<in out Route extends RouteSchema, in out Singleton extends SingletonBase, Derivative extends Record<string, unknown> | AnyElysiaCustomStatusResponse | void = Record<string, unknown> | AnyElysiaCustomStatusResponse | void> = (context: Context<Route, Singleton>) => MaybePromise<Derivative>;
700
- export type ResolveReturnType<T extends MaybeArray<unknown>> = any[] extends T ? {} : T extends any[] ? _ResolveReturnTypeArray<// @ts-ignore Trust me bro
701
- T> : Exclude<Awaited<ReturnType<T>>, AnyElysiaCustomStatusResponse> extends infer Value extends Record<any, unknown> ? Value : {};
702
- type _ResolveReturnTypeArray<T, Carry = {}> = T extends [
703
- infer Fn,
704
- ...infer Rest
705
- ] ? Exclude<Awaited<ReturnType<Fn>>, AnyElysiaCustomStatusResponse> extends infer Value extends Record<any, unknown> ? _ResolveReturnTypeArray<Rest, Value & Carry> : _ResolveReturnTypeArray<Rest, Carry & {}> : Prettify<Carry>;
706
- export type AnyLocalHook = LocalHook<any, any, any, any, any>;
707
- export interface BaseHookLifeCycle<in out Schema extends RouteSchema, in out Singleton extends SingletonBase, in out Errors extends {
708
- [key in string]: Error;
709
- }, in out Parser extends keyof any = ''> {
710
- detail?: DocumentDecoration;
711
- /**
712
- * Short for 'Content-Type'
713
- *
714
- * Available:
715
- * - 'none': do not parse body
716
- * - 'text' / 'text/plain': parse body as string
717
- * - 'json' / 'application/json': parse body as json
718
- * - 'formdata' / 'multipart/form-data': parse body as form-data
719
- * - 'urlencoded' / 'application/x-www-form-urlencoded: parse body as urlencoded
720
- * - 'arraybuffer': parse body as readable stream
721
- */
722
- parse?: MaybeArray<BodyHandler<Schema, Singleton> | ContentType | Parser>;
723
- /**
724
- * Transform context's value
725
- */
726
- transform?: MaybeArray<TransformHandler<Schema, Singleton>>;
727
- /**
728
- * Execute before main handler
729
- */
730
- beforeHandle?: MaybeArray<OptionalHandler<Schema, Singleton>>;
731
- /**
732
- * Execute after main handler
733
- */
734
- afterHandle?: MaybeArray<AfterHandler<Schema, Singleton>>;
735
- /**
736
- * Execute after main handler
737
- */
738
- mapResponse?: MaybeArray<MapResponse<Schema, Singleton>>;
739
- /**
740
- * Execute after response is sent
741
- */
742
- afterResponse?: MaybeArray<AfterResponseHandler<Schema, Singleton>>;
743
- /**
744
- * Catch error
745
- */
746
- error?: MaybeArray<ErrorHandler<Errors, Schema, Singleton>>;
747
- tags?: DocumentDecoration['tags'];
748
- }
749
- export type CreateDecorator<Singleton extends SingletonBase, Ephemeral extends EphemeralType, Volatile extends EphemeralType> = {} extends Ephemeral ? {} extends Volatile ? Singleton : Singleton & Volatile : {} extends Volatile ? Singleton & Ephemeral : Singleton & Ephemeral & Volatile;
750
- export type AnyBaseHookLifeCycle = BaseHookLifeCycle<any, any, any, any>;
751
- export type NonResolvableMacroKey = keyof AnyBaseHookLifeCycle | keyof InputSchema | 'resolve';
752
- interface RouteSchemaWithResolvedMacro extends RouteSchema {
753
- response: PossibleResponse;
754
- return: PossibleResponse;
755
- resolve: Record<string, unknown>;
756
- }
757
- export type LocalHook<Input extends BaseMacro, Schema extends RouteSchemaWithResolvedMacro, Singleton extends SingletonBase, Errors extends {
758
- [key in string]: Error;
759
- }, Parser extends keyof any = ''> = {
760
- detail?: DocumentDecoration;
761
- /**
762
- * Short for 'Content-Type'
763
- *
764
- * Available:
765
- * - 'none': do not parse body
766
- * - 'text' / 'text/plain': parse body as string
767
- * - 'json' / 'application/json': parse body as json
768
- * - 'formdata' / 'multipart/form-data': parse body as form-data
769
- * - 'urlencoded' / 'application/x-www-form-urlencoded: parse body as urlencoded
770
- * - 'arraybuffer': parse body as readable stream
771
- */
772
- parse?: MaybeArray<BodyHandler<Schema, Singleton & {
773
- resolve: Schema['resolve'];
774
- }> | ContentType | Parser>;
775
- /**
776
- * Transform context's value
777
- */
778
- transform?: MaybeArray<TransformHandler<Schema, Singleton & {
779
- resolve: Schema['resolve'];
780
- }>>;
781
- /**
782
- * Execute before main handler
783
- */
784
- beforeHandle?: MaybeArray<OptionalHandler<Schema, Singleton & {
785
- resolve: Schema['resolve'];
786
- }>>;
787
- /**
788
- * Execute after main handler
789
- */
790
- afterHandle?: MaybeArray<AfterHandler<Schema, Singleton & {
791
- resolve: Schema['resolve'];
792
- }>>;
793
- /**
794
- * Execute after main handler
795
- */
796
- mapResponse?: MaybeArray<MapResponse<Schema, Singleton & {
797
- resolve: Schema['resolve'];
798
- }>>;
799
- /**
800
- * Execute after response is sent
801
- */
802
- afterResponse?: MaybeArray<AfterResponseHandler<Schema, Singleton & {
803
- resolve: Schema['resolve'];
804
- }>>;
805
- /**
806
- * Catch error
807
- */
808
- error?: MaybeArray<ErrorHandler<Errors, Schema, Singleton & {
809
- resolve: Schema['resolve'];
810
- }>>;
811
- tags?: DocumentDecoration['tags'];
812
- } & (Input extends any ? Input : Prettify<Input>);
813
- export type GuardLocalHook<Input extends BaseMacro | undefined, Schema extends RouteSchema, Singleton extends SingletonBase, Parser extends keyof any, BeforeHandle extends MaybeArray<OptionalHandler<any, any>>, AfterHandle extends MaybeArray<AfterHandler<any, any>>, ErrorHandle extends MaybeArray<ErrorHandler<any, any, any>>, GuardType extends GuardSchemaType = 'standalone', AsType extends LifeCycleType = 'local'> = (Input extends any ? Input : Prettify<Input>) & {
814
- /**
815
- * @default 'override'
816
- */
817
- as?: AsType;
818
- /**
819
- * @default 'standalone'
820
- * @since 1.3.0
821
- */
822
- schema?: GuardType;
823
- detail?: DocumentDecoration;
824
- /**
825
- * Short for 'Content-Type'
826
- *
827
- * Available:
828
- * - 'none': do not parse body
829
- * - 'text' / 'text/plain': parse body as string
830
- * - 'json' / 'application/json': parse body as json
831
- * - 'formdata' / 'multipart/form-data': parse body as form-data
832
- * - 'urlencoded' / 'application/x-www-form-urlencoded: parse body as urlencoded
833
- * - 'arraybuffer': parse body as readable stream
834
- */
835
- parse?: MaybeArray<BodyHandler<Schema, Singleton> | ContentType | Parser>;
836
- /**
837
- * Transform context's value
838
- */
839
- transform?: MaybeArray<TransformHandler<Schema, Singleton>>;
840
- /**
841
- * Execute before main handler
842
- */
843
- beforeHandle?: BeforeHandle;
844
- /**
845
- * Execute after main handler
846
- */
847
- afterHandle?: AfterHandle;
848
- /**
849
- * Execute after main handler
850
- */
851
- mapResponse?: MaybeArray<MapResponse<Schema, Singleton>>;
852
- /**
853
- * Execute after response is sent
854
- */
855
- afterResponse?: MaybeArray<AfterResponseHandler<Schema, Singleton>>;
856
- /**
857
- * Catch error
858
- */
859
- error?: ErrorHandle;
860
- tags?: DocumentDecoration['tags'];
861
- };
862
- export type ComposedHandler = (context: Context) => MaybePromise<Response>;
863
- export interface InternalRoute {
864
- method: HTTPMethod;
865
- path: string;
866
- composed: ComposedHandler | Response | null;
867
- compile(): ComposedHandler;
868
- handler: Handler;
869
- hooks: AnyLocalHook;
870
- websocket?: AnyWSLocalHook;
871
- }
872
- export interface SchemaValidator {
873
- createBody?(): ElysiaTypeCheck<any>;
874
- createHeaders?(): ElysiaTypeCheck<any>;
875
- createQuery?(): ElysiaTypeCheck<any>;
876
- createParams?(): ElysiaTypeCheck<any>;
877
- createCookie?(): ElysiaTypeCheck<any>;
878
- createResponse?(): Record<number, ElysiaTypeCheck<any>>;
879
- body?: ElysiaTypeCheck<any>;
880
- headers?: ElysiaTypeCheck<any>;
881
- query?: ElysiaTypeCheck<any>;
882
- params?: ElysiaTypeCheck<any>;
883
- cookie?: ElysiaTypeCheck<any>;
884
- response?: Record<number, ElysiaTypeCheck<any>>;
885
- }
886
- export type AddPrefix<in out Prefix extends string, in out T> = {
887
- [K in keyof T as Prefix extends string ? `${Prefix}${K & string}` : K]: T[K];
888
- };
889
- export type AddPrefixCapitalize<in out Prefix extends string, in out T> = {
890
- [K in keyof T as `${Prefix}${Capitalize<K & string>}`]: T[K];
891
- };
892
- export type AddSuffix<in out Suffix extends string, in out T> = {
893
- [K in keyof T as `${K & string}${Suffix}`]: T[K];
894
- };
895
- export type AddSuffixCapitalize<in out Suffix extends string, in out T> = {
896
- [K in keyof T as `${K & string}${Capitalize<Suffix>}`]: T[K];
897
- };
898
- export interface Checksum {
899
- name?: string;
900
- seed?: unknown;
901
- checksum: number;
902
- stack?: string;
903
- routes?: InternalRoute[];
904
- decorators?: SingletonBase['decorator'];
905
- store?: SingletonBase['store'];
906
- error?: DefinitionBase['error'];
907
- dependencies?: Record<string, Checksum[]>;
908
- derive?: {
909
- fn: string;
910
- stack: string;
911
- }[];
912
- resolve?: {
913
- fn: string;
914
- stack: string;
915
- }[];
916
- }
917
- export type BaseMacro = Record<string, string | number | boolean | Object | undefined | null>;
918
- export type MaybeValueOrVoidFunction<T> = T | ((...a: any) => void | T);
919
- export interface MacroProperty<in out Macro extends BaseMacro = {}, in out TypedRoute extends RouteSchema = {}, in out Singleton extends SingletonBase = {
920
- decorator: {};
921
- store: {};
922
- derive: {};
923
- resolve: {};
924
- }, in out Errors extends Record<string, Error> = {}> {
925
- /**
926
- * Deduplication similar to Elysia.constructor.seed
927
- */
928
- seed?: unknown;
929
- parse?: MaybeArray<BodyHandler<TypedRoute, Singleton>>;
930
- transform?: MaybeArray<VoidHandler<TypedRoute, Singleton>>;
931
- beforeHandle?: MaybeArray<OptionalHandler<TypedRoute, Singleton>>;
932
- afterHandle?: MaybeArray<AfterHandler<TypedRoute, Singleton>>;
933
- error?: MaybeArray<ErrorHandler<Errors, TypedRoute, Singleton>>;
934
- mapResponse?: MaybeArray<MapResponse<TypedRoute, Singleton>>;
935
- afterResponse?: MaybeArray<AfterResponseHandler<TypedRoute, Singleton>>;
936
- resolve?: MaybeArray<ResolveHandler<TypedRoute, Singleton>>;
937
- detail?: DocumentDecoration;
938
- /**
939
- * Introspect hook option for documentation generation or analysis
940
- *
941
- * @param option
942
- */
943
- introspect?(option: Prettify<Macro>): unknown;
944
- }
945
- export interface Macro<in out Macro extends BaseMacro = {}, in out Input extends BaseMacro = {}, in out TypedRoute extends RouteSchema = {}, in out Singleton extends SingletonBase = {
946
- decorator: {};
947
- store: {};
948
- derive: {};
949
- resolve: {};
950
- }, in out Errors extends Record<string, Error> = {}> {
951
- [K: keyof any]: MaybeValueOrVoidFunction<Input & MacroProperty<Macro, TypedRoute, Singleton, Errors>>;
952
- }
953
- export type MaybeFunction<T> = T | ((...args: any[]) => T);
954
- export type MacroToProperty<in out T extends Macro<any, any, any, any>> = Prettify<{
955
- [K in keyof T]: T[K] extends Function ? T[K] extends (a: infer Params) => any ? Params : boolean : boolean;
956
- }>;
957
- interface MacroOptions {
958
- insert?: 'before' | 'after';
959
- stack?: 'global' | 'local';
960
- }
961
- export interface MacroManager<in out TypedRoute extends RouteSchema = {}, in out Singleton extends SingletonBase = {
962
- decorator: {};
963
- store: {};
964
- derive: {};
965
- resolve: {};
966
- }, in out Errors extends Record<string, Error> = {}> {
967
- body(schema: InputSchema['body']): unknown;
968
- headers(schema: InputSchema['headers']): unknown;
969
- query(schema: InputSchema['query']): unknown;
970
- params(schema: InputSchema['params']): unknown;
971
- cookie(schema: InputSchema['cookie']): unknown;
972
- response(schema: InputSchema['response']): unknown;
973
- detail(detail: DocumentDecoration): unknown;
974
- onParse(fn: MaybeArray<BodyHandler<TypedRoute, Singleton>>): unknown;
975
- onParse(options: MacroOptions, fn: MaybeArray<BodyHandler<TypedRoute, Singleton>>): unknown;
976
- onTransform(fn: MaybeArray<VoidHandler<TypedRoute, Singleton>>): unknown;
977
- onTransform(options: MacroOptions, fn: MaybeArray<VoidHandler<TypedRoute, Singleton>>): unknown;
978
- onBeforeHandle(fn: MaybeArray<OptionalHandler<TypedRoute, Singleton>>): unknown;
979
- onBeforeHandle(options: MacroOptions, fn: MaybeArray<OptionalHandler<TypedRoute, Singleton>>): unknown;
980
- onAfterHandle(fn: MaybeArray<AfterHandler<TypedRoute, Singleton>>): unknown;
981
- onAfterHandle(options: MacroOptions, fn: MaybeArray<AfterHandler<TypedRoute, Singleton>>): unknown;
982
- onError(fn: MaybeArray<ErrorHandler<Errors, TypedRoute, Singleton>>): unknown;
983
- onError(options: MacroOptions, fn: MaybeArray<ErrorHandler<Errors, TypedRoute, Singleton>>): unknown;
984
- mapResponse(fn: MaybeArray<MapResponse<TypedRoute, Singleton>>): unknown;
985
- mapResponse(options: MacroOptions, fn: MaybeArray<MapResponse<TypedRoute, Singleton>>): unknown;
986
- onAfterResponse(fn: MaybeArray<AfterResponseHandler<TypedRoute, Singleton>>): unknown;
987
- onAfterResponse(options: MacroOptions, fn: MaybeArray<AfterResponseHandler<TypedRoute, Singleton>>): unknown;
988
- events: {
989
- global: Partial<LifeCycleStore & RouteSchema>;
990
- local: Partial<LifeCycleStore & RouteSchema>;
991
- };
992
- }
993
- type _CreateEden<Path extends string, Property extends Record<string, unknown> = {}> = Path extends `${infer Start}/${infer Rest}` ? {
994
- [x in Start]: _CreateEden<Rest, Property>;
995
- } : Path extends '' ? Property : {
996
- [x in Path]: Property;
742
+ type ObjectMacroDefs<Body, Headers, Query, Params, Cookie, N, AmbientSchema extends RouteSchema, ScopedSchemas extends RouteSchema, Singleton extends SingletonBase, Definitions extends DefinitionBase, MacroNames extends BaseMacro, MacroFn = {}, Refs = {}> = MacroChannel<Body, 'body', Definitions> & MacroChannel<Headers, 'headers', Definitions> & MacroChannel<Query, 'query', Definitions> & MacroChannel<Params, 'params', Definitions> & MacroChannel<Cookie, 'cookie', Definitions> & MacroRefChannel<Refs> & { [K in keyof N]: MaybeValueOrVoidFunction<MacroProperty<MacroNames & InputSchema<keyof Definitions['typebox'] & string>, IntersectIfObjectSchema<MergeSchema<UnwrapMacroSchema<MacroDefSchema<K, Body, Headers, Query, Params, Cookie>, Definitions['typebox']>, AmbientSchema>, ScopedSchemas>, Singleton & {
743
+ derive: Singleton['derive'] & MacroRefResolve<MacroFn, K extends keyof Refs ? Refs[K] : {}, Definitions['typebox']>;
744
+ }, Definitions['error']>> } & { [K in keyof N]: N[K] extends ((...a: any[]) => any) ? unknown : string extends keyof N[K] ? unknown : { [P in Exclude<keyof N[K], MacroPropertyKey | InputSchemaKey | keyof MacroNames | keyof N>]: `Unknown macro property '${P & string}'` } } & N;
745
+ type CreateEden<Path extends string, Property extends Record<string, unknown> = {}> = Path extends `/${infer Rest}` ? _CreateEden<Rest, Property> : Path extends '' | '/' ? Property : _CreateEden<Path, Property>;
746
+ type _CreateEden<Path extends string, Property extends Record<string, unknown> = {}> = Path extends `${infer Start}/${infer Rest}` ? { [x in Start]: _CreateEden<Rest, Property> } : Path extends '' ? Property : { [x in Path]: Property };
747
+ type CreateEdenResponse<Path extends string, Schema extends RouteSchema, MacroContext extends RouteSchema, Res extends PossibleResponse, Err extends Error = never> = RouteSchema extends MacroContext ? {
748
+ body: Schema['body'];
749
+ params: IsNever<keyof Schema['params']> extends true ? ResolvePath<Path> : Schema['params'];
750
+ query: Schema['query'];
751
+ headers: Schema['headers'];
752
+ response: Prettify<Res>;
753
+ error: Err;
754
+ } : {
755
+ body: Prettify<Schema['body'] & MacroContext['body']>;
756
+ params: IsNever<keyof (Schema['params'] & MacroContext['params'])> extends true ? ResolvePath<Path> : Prettify<Schema['params'] & MacroContext['params']>;
757
+ query: Prettify<Schema['query'] & MacroContext['query']>;
758
+ headers: Prettify<Schema['headers'] & MacroContext['headers']>;
759
+ response: Prettify<Res>;
760
+ error: Err;
997
761
  };
998
- export type CreateEden<Path extends string, Property extends Record<string, unknown> = {}> = Path extends `/${infer Rest}` ? _CreateEden<Rest, Property> : Path extends '' | '/' ? Property : _CreateEden<Path, Property>;
999
- export interface EmptyRouteSchema {
1000
- body: unknown;
1001
- headers: unknown;
1002
- query: unknown;
1003
- params: {};
1004
- cookie: unknown;
1005
- response: unknown;
1006
- }
1007
- export interface UnknownRouteSchema<Params = {
1008
- [name: string]: string | undefined;
1009
- }> {
1010
- body: unknown;
1011
- headers: {
1012
- [name: string]: string | undefined;
1013
- };
1014
- query: {
1015
- [name: string]: string | undefined;
1016
- };
1017
- params: Params;
1018
- cookie: {};
1019
- response: unknown;
1020
- }
1021
- type Extract200<T> = T extends AnyElysiaCustomStatusResponse ? Exclude<T, AnyElysiaCustomStatusResponse> | Extract<T, ElysiaCustomStatusResponse<200, any, 200>>['response'] : T;
1022
- export type IsUnknown<T> = [unknown] extends [T] ? IsAny<T> extends true ? false : true : false;
1023
- export type ValueToResponseSchema<Value> = ExtractErrorFromHandle<Value> & (Extract200<Value> extends infer R200 ? undefined extends R200 ? {} : IsNever<R200> extends true ? {} : {
1024
- 200: R200;
762
+ type CreateWSEdenResponse<Path extends string, Schema extends RouteSchema, MacroContext extends RouteSchema, Res extends PossibleResponse> = Omit<CreateEdenResponse<Path, Schema, MacroContext, Res>, 'error'>;
763
+ type Extract200<T> = T extends AnyElysiaStatus ? Exclude<T, AnyElysiaStatus> | Extract<T, ElysiaStatus<200, any, 200>>['response'] : T;
764
+ type ValueToResponseSchema<Value, Errors extends ErrorDefinition[] = []> = ExtractErrorFromHandle<Exclude<Value, Error>> & ExtractReturnedError<Value, Errors> & (Extract200<Exclude<Value, Error>> extends infer R200 ? undefined extends R200 ? {} : IsNever<R200> extends true ? {} : {
765
+ 200: R200;
1025
766
  } : {});
1026
- export type ValueOrFunctionToResponseSchema<T> = T extends (...a: any) => MaybePromise<infer R> ? ValueToResponseSchema<R> : ValueToResponseSchema<T>;
1027
- export type ElysiaHandlerToResponseSchema<in out Handle extends Function> = Prettify<Handle extends (...a: any) => MaybePromise<infer R> ? ValueToResponseSchema<Exclude<R, undefined>> : {}>;
1028
- export type ElysiaHandlerToResponseSchemas<Handle extends Function[], Carry extends PossibleResponse = {}> = Handle extends [infer Current, ...infer Rest] ? ElysiaHandlerToResponseSchemas<Rest, UnionResponseStatus<ElysiaHandlerToResponseSchema<Current>, Carry>> : Prettify<Carry>;
1029
- export type ElysiaHandlerToResponseSchemaAmbiguous<Schemas extends MaybeArray<Function>> = MaybeArray<(...a: any) => any> extends Schemas ? {} : Schemas extends Function ? ElysiaHandlerToResponseSchema<Schemas> : Schemas extends Function[] ? ElysiaHandlerToResponseSchemas<Schemas> : {};
1030
- type ReconcileStatus<in out A extends Record<number, unknown>, in out B extends Record<number, unknown>> = {
1031
- [K in keyof A | keyof B]: K extends keyof A ? A[K] : B[K];
1032
- };
1033
- export type ComposeElysiaResponse<Schema extends RouteSchema, Handle, Possibility extends PossibleResponse> = ReconcileStatus<Schema['response'], UnionResponseStatus<ValueOrFunctionToResponseSchema<Handle>, Possibility & (EmptyRouteSchema extends Pick<Schema, keyof EmptyRouteSchema> ? {} : {
1034
- 422: {
1035
- type: 'validation';
1036
- on: string;
1037
- summary?: string;
1038
- message?: string;
1039
- found?: unknown;
1040
- property?: string;
1041
- expected?: string;
1042
- };
767
+ type ValueOrFunctionToResponseSchema<T, Errors extends ErrorDefinition[] = []> = T extends ((...a: any) => MaybePromise<infer R>) ? ValueToResponseSchema<R, Errors> : ValueToResponseSchema<T, Errors>;
768
+ type ElysiaHandlerToResponseSchema<in out Handle extends Function> = Prettify<Handle extends ((...a: any) => MaybePromise<infer R>) ? ValueToResponseSchema<Exclude<R, undefined>> : {}>;
769
+ type ElysiaHandlerToResponseSchemas<Handle extends Function[], Carry extends PossibleResponse = {}> = Handle extends [infer Current, ...infer Rest] ? ElysiaHandlerToResponseSchemas<Rest, UnionResponseStatus<ElysiaHandlerToResponseSchema<Current>, Carry>> : Prettify<Carry>;
770
+ type ElysiaHandlerToResponseSchemaAmbiguous<Schemas extends MaybeArray<Function>> = MaybeArray<(...a: any) => any> extends Schemas ? {} : Schemas extends Function ? ElysiaHandlerToResponseSchema<Schemas> : Schemas extends Function[] ? ElysiaHandlerToResponseSchemas<Schemas> : {};
771
+ type ReconcileStatus<in out A extends Record<number, unknown>, in out B extends Record<number, unknown>> = { [K in keyof A | keyof B]: K extends keyof A ? A[K] : B[K] };
772
+ type UnionResponseStatus<A, B> = {} extends A ? B : {} extends B ? A : { [key in keyof A | keyof B]: key extends keyof A ? key extends keyof B ? A[key] | B[key] : A[key] : key extends keyof B ? B[key] : never };
773
+ type HasInputValidator<Schema extends RouteSchema, Path extends string> = EmptyInputSchema extends Pick<Schema, Exclude<InputSchemaKey, 'params' | 'response'>> ? undefined extends Schema['params'] ? false : Schema['params'] extends ResolvePath<Path> ? ResolvePath<Path> extends Schema['params'] ? false : true : true : true;
774
+ type ComposeElysiaResponse<Schema extends RouteSchema, Handle, Possibility extends PossibleResponse, Errors extends ErrorDefinition[] = [], Path extends string = string> = ReconcileStatus<Schema['response'], UnionResponseStatus<ValueOrFunctionToResponseSchema<Handle, Errors>, Possibility & (HasInputValidator<Schema, Path> extends false ? {} : {
775
+ 422: {
776
+ type: 'validation';
777
+ title: 'Validation Error';
778
+ status: 422;
779
+ detail?: string;
780
+ on: string;
781
+ found?: unknown;
782
+ property?: string;
783
+ expected?: string;
784
+ };
1043
785
  })>>;
1044
- export type ExtractErrorFromHandle<in out Handle> = {
1045
- [ErrorResponse in Extract<Handle, AnyElysiaCustomStatusResponse> as ErrorResponse extends AnyElysiaCustomStatusResponse ? ErrorResponse['code'] : never]: Prettify<ErrorResponse['response']>;
1046
- };
1047
- export type MergeElysiaInstances<Instances extends AnyElysia[] = [], Prefix extends string = '', Singleton extends SingletonBase = {
1048
- decorator: {};
1049
- store: {};
1050
- derive: {};
1051
- resolve: {};
1052
- }, Definitions extends DefinitionBase = {
1053
- typebox: {};
1054
- error: {};
1055
- }, Metadata extends MetadataBase = {
1056
- schema: {};
1057
- standaloneSchema: {};
1058
- macro: {};
1059
- macroFn: {};
1060
- parser: {};
1061
- response: {};
1062
- }, Ephemeral extends EphemeralType = {
1063
- derive: {};
1064
- resolve: {};
1065
- schema: {};
1066
- standaloneSchema: {};
1067
- response: {};
1068
- }, Volatile extends EphemeralType = {
1069
- derive: {};
1070
- resolve: {};
1071
- schema: {};
1072
- standaloneSchema: {};
1073
- response: {};
1074
- }, Routes extends RouteBase = {}> = Instances extends [
1075
- infer Current extends AnyElysia,
1076
- ...infer Rest extends AnyElysia[]
1077
- ] ? MergeElysiaInstances<Rest, Prefix, Singleton & Current['~Singleton'], Definitions & Current['~Definitions'], Metadata & Current['~Metadata'], Ephemeral, Volatile & Current['~Ephemeral'], Routes & (Prefix extends `` ? Current['~Routes'] : CreateEden<Prefix, Current['~Routes']>)> : Elysia<Prefix, {
1078
- decorator: Singleton['decorator'];
1079
- store: Prettify<Singleton['store']>;
1080
- derive: Singleton['derive'];
1081
- resolve: Singleton['resolve'];
1082
- }, Definitions, Metadata, Routes, Ephemeral, Volatile>;
1083
- export type LifeCycleType = 'global' | 'local' | 'scoped';
1084
- export type GuardSchemaType = 'override' | 'standalone';
1085
- type PartialIf<T, Condition extends boolean> = Condition extends true ? Partial<T> : T;
1086
- export type ExcludeElysiaResponse<T> = PartialIf<Exclude<Awaited<T>, AnyElysiaCustomStatusResponse> extends infer A ? IsNever<A & {}> extends true ? {} : // Intersect all union and fallback never to {}
1087
- A & {} : {}, undefined extends Awaited<T> ? true : false>;
786
+ type ExtractErrorFromHandle<in out Handle> = { [ErrorResponse in Extract<Handle, AnyElysiaStatus> as ErrorResponse extends AnyElysiaStatus ? ErrorResponse['code'] : never]: Prettify<ErrorResponse['response']> };
1088
787
  /**
1089
- * @deprecated
788
+ * Status used when an error handler returns a plain value (or falls through):
789
+ * the error's declared literal `status`, otherwise 500
1090
790
  */
1091
- export type InferContext<T extends AnyElysia, Path extends string = T['~Prefix'], Schema extends RouteSchema = T['~Metadata']['schema']> = Context<MergeSchema<Schema, T['~Metadata']['schema']>, T['~Singleton'] & {
1092
- derive: T['~Ephemeral']['derive'] & T['~Volatile']['derive'];
1093
- resolve: T['~Ephemeral']['resolve'] & T['~Volatile']['resolve'];
1094
- }, Path>;
791
+ type ErrorFallbackStatus<E> = E extends {
792
+ status: infer S extends number;
793
+ } ? number extends S ? 500 : S : 500;
1095
794
  /**
1096
- * @deprecated
795
+ * Body produced when no error handler returns a value:
796
+ * the error's declared `response`, otherwise its message (string)
1097
797
  */
1098
- export type InferHandler<T extends AnyElysia, Path extends string = T['~Prefix'], Schema extends RouteSchema = T['~Metadata']['schema']> = InlineHandler<MergeSchema<Schema, T['~Metadata']['schema'], Path>, T['~Singleton'] & {
1099
- derive: T['~Ephemeral']['derive'] & T['~Volatile']['derive'];
1100
- resolve: T['~Ephemeral']['resolve'] & T['~Volatile']['resolve'];
1101
- }>;
1102
- export interface ModelValidatorError extends ValueError {
1103
- summary: string;
1104
- }
1105
- export interface ModelValidator<T> extends TypeCheck<T> {
1106
- schema: T;
1107
- parse(a: T): T;
1108
- safeParse(a: T): {
1109
- success: true;
1110
- data: T;
1111
- error: null;
1112
- } | {
1113
- success: true;
1114
- data: null;
1115
- error: string;
1116
- errors: ModelValidatorError[];
1117
- };
1118
- }
1119
- export type UnionToIntersect<U> = (U extends unknown ? (arg: U) => 0 : never) extends (arg: infer I) => 0 ? I : never;
1120
- export type ContextAppendType = 'append' | 'override';
1121
- export type HigherOrderFunction<T extends (...arg: unknown[]) => Function = (...arg: unknown[]) => Function> = (fn: T, request: Request) => ReturnType<T>;
1122
- type SetContentType = 'application/octet-stream' | 'application/vnd.ms-fontobject' | 'application/epub+zip' | 'application/gzip' | 'application/json' | 'application/ld+json' | 'application/ogg' | 'application/pdf' | 'application/rtf' | 'application/wasm' | 'application/xhtml+xml' | 'application/xml' | 'application/zip' | 'text/css' | 'text/csv' | 'text/calendar' | 'text/event-stream' | 'text/html' | 'text/javascript' | 'text/plain' | 'text/xml' | 'image/avif' | 'image/bmp' | 'image/gif' | 'image/x-icon' | 'image/jpeg' | 'image/png' | 'image/svg+xml' | 'image/tiff' | 'image/webp' | 'multipart/mixed' | 'multipart/alternative' | 'multipart/form-data' | 'audio/aac' | 'audio/x-midi' | 'audio/mpeg' | 'audio/ogg' | 'audio/opus' | 'audio/webm' | 'video/x-msvideo' | 'video/quicktime' | 'video/x-ms-wmv' | 'video/x-msvideo' | 'video/x-flv' | 'video/av1' | 'video/mp4' | 'video/mpeg' | 'video/ogg' | 'video/mp2t' | 'video/webm' | 'video/3gpp' | 'video/3gpp2' | 'font/otf' | 'font/ttf' | 'font/woff' | 'font/woff2' | 'model/gltf+json' | 'model/gltf-binary';
1123
- export type HTTPHeaders = Record<string, string | number> & {
1124
- 'www-authenticate'?: string;
1125
- authorization?: string;
1126
- 'proxy-authenticate'?: string;
1127
- 'proxy-authorization'?: string;
1128
- age?: string;
1129
- 'cache-control'?: string;
1130
- 'clear-site-data'?: string;
1131
- expires?: string;
1132
- 'no-vary-search'?: string;
1133
- pragma?: string;
1134
- 'last-modified'?: string;
1135
- etag?: string;
1136
- 'if-match'?: string;
1137
- 'if-none-match'?: string;
1138
- 'if-modified-since'?: string;
1139
- 'if-unmodified-since'?: string;
1140
- vary?: string;
1141
- connection?: string;
1142
- 'keep-alive'?: string;
1143
- accept?: string;
1144
- 'accept-encoding'?: string;
1145
- 'accept-language'?: string;
1146
- expect?: string;
1147
- 'max-forwards'?: string;
1148
- cookie?: string;
1149
- 'set-cookie'?: string | string[];
1150
- 'access-control-allow-origin'?: string;
1151
- 'access-control-allow-credentials'?: string;
1152
- 'access-control-allow-headers'?: string;
1153
- 'access-control-allow-methods'?: string;
1154
- 'access-control-expose-headers'?: string;
1155
- 'access-control-max-age'?: string;
1156
- 'access-control-request-headers'?: string;
1157
- 'access-control-request-method'?: string;
1158
- origin?: string;
1159
- 'timing-allow-origin'?: string;
1160
- 'content-disposition'?: string;
1161
- 'content-length'?: string | number;
1162
- 'content-type'?: SetContentType | (string & {});
1163
- 'content-encoding'?: string;
1164
- 'content-language'?: string;
1165
- 'content-location'?: string;
1166
- forwarded?: string;
1167
- via?: string;
1168
- location?: string;
1169
- refresh?: string;
1170
- allow?: string;
1171
- server?: 'Elysia' | (string & {});
1172
- 'accept-ranges'?: string;
1173
- range?: string;
1174
- 'if-range'?: string;
1175
- 'content-range'?: string;
1176
- 'content-security-policy'?: string;
1177
- 'content-security-policy-report-only'?: string;
1178
- 'cross-origin-embedder-policy'?: string;
1179
- 'cross-origin-opener-policy'?: string;
1180
- 'cross-origin-resource-policy'?: string;
1181
- 'expect-ct'?: string;
1182
- 'permission-policy'?: string;
1183
- 'strict-transport-security'?: string;
1184
- 'upgrade-insecure-requests'?: string;
1185
- 'x-content-type-options'?: string;
1186
- 'x-frame-options'?: string;
1187
- 'x-xss-protection'?: string;
1188
- 'last-event-id'?: string;
1189
- 'ping-from'?: string;
1190
- 'ping-to'?: string;
1191
- 'report-to'?: string;
1192
- te?: string;
1193
- trailer?: string;
1194
- 'transfer-encoding'?: string;
1195
- 'alt-svg'?: string;
1196
- 'alt-used'?: string;
1197
- date?: string;
1198
- dnt?: string;
1199
- 'early-data'?: string;
1200
- 'large-allocation'?: string;
1201
- link?: string;
1202
- 'retry-after'?: string;
1203
- 'service-worker-allowed'?: string;
1204
- 'source-map'?: string;
1205
- upgrade?: string;
1206
- 'x-dns-prefetch-control'?: string;
1207
- 'x-forwarded-for'?: string;
1208
- 'x-forwarded-host'?: string;
1209
- 'x-forwarded-proto'?: string;
1210
- 'x-powered-by'?: 'Elysia' | (string & {});
1211
- 'x-request-id'?: string;
1212
- 'x-requested-with'?: string;
1213
- 'x-robots-tag'?: string;
1214
- 'x-ua-compatible'?: string;
1215
- };
1216
- export type JoinPath<A extends string, B extends string> = B extends `/${string}` ? `${A}${B}` : `${A}/${B}`;
1217
- export type UnwrapTypeModule<Module extends TModule<any, any>> = Module extends TModule<infer Type extends TProperties, any> ? Type : {};
1218
- export type MergeTypeModule<A extends TModule<any, any>, B extends TModule<any, any>> = TModule<Prettify<UnwrapTypeModule<A> & UnwrapTypeModule<B>>>;
1219
- export type SSEPayload<Data extends unknown = unknown, Event extends string | undefined = string | undefined> = {
1220
- /** id of the event */
1221
- id?: string | number | null;
1222
- /** event name */
1223
- event?: Event;
1224
- /** retry in millisecond */
1225
- retry?: number;
1226
- /** data to send */
1227
- data?: Data;
798
+ type ErrorFallbackBody<E> = E extends {
799
+ response: infer R;
800
+ } ? unknown extends R ? string : R : string;
801
+ /**
802
+ * `Definitions['error']` / `EphemeralType['error']` entry registered by an
803
+ * `.error(Class, handler)` call
804
+ */
805
+ type ErrorDefinitionEntry<E extends abstract new (...args: any) => Error, R> = {
806
+ error: InstanceType<E>;
807
+ response: ErrorHandlerResponseSchema<Awaited<R>, InstanceType<E>>;
1228
808
  };
1229
- export type UnionResponseStatus<A, B> = {} extends A ? B : {} extends B ? A : {
1230
- [key in keyof A | keyof B]: key extends keyof A ? key extends keyof B ? A[key] | B[key] : A[key] : key extends keyof B ? B[key] : never;
809
+ type ErrorHandlerResponseSchema<R, E> = ExtractErrorFromHandle<Exclude<R, Error>> & (Exclude<R, Extract<Exclude<R, Error>, AnyElysiaStatus> | undefined> | (undefined extends R ? ErrorFallbackBody<E> : never) extends infer Plain ? IsNever<Plain> extends true ? {} : { [S in ErrorFallbackStatus<E>]: Plain } : {});
810
+ type MatchRegisteredError<V, Errors extends ErrorDefinition[]> = Errors extends [infer Head extends ErrorDefinition, ...infer Rest extends ErrorDefinition[]] ? [V] extends [Head['error']] ? Head['response'] : MatchRegisteredError<V, Rest> : never;
811
+ type HasErrorMatch<V, Errors extends ErrorDefinition[]> = Errors extends [infer Head extends ErrorDefinition, ...infer Rest extends ErrorDefinition[]] ? [V] extends [Head['error']] ? true : HasErrorMatch<V, Rest> : false;
812
+ type UnhandledReturnedError<Value, Errors extends ErrorDefinition[]> = 0 extends 1 & Value ? never : Extract<Value, Error> extends infer Es ? Es extends Error ? HasErrorMatch<Es, Errors> extends true ? never : Es : never : never;
813
+ type UnhandledReturnedErrorOf<T, Errors extends ErrorDefinition[]> = T extends ((...a: any) => MaybePromise<infer R>) ? UnhandledReturnedError<R, Errors> : UnhandledReturnedError<T, Errors>;
814
+ type ResolveRouteErrors<Routes, Errors extends ErrorDefinition[]> = Errors extends [] ? Routes : { [K in keyof Routes]: Routes[K] extends {
815
+ params: any;
816
+ query: any;
817
+ headers: any;
818
+ response: any;
819
+ error: any;
820
+ } ? [Routes[K]['error']] extends [never] ? Routes[K] : Omit<Routes[K], 'response' | 'error'> & {
821
+ response: Prettify<UnionResponseStatus<Routes[K]['response'], ExtractReturnedError<Routes[K]['error'], Errors>>>;
822
+ error: UnhandledReturnedError<Routes[K]['error'], Errors>;
823
+ } : Routes[K] extends Record<keyof any, any> ? ResolveRouteErrors<Routes[K], Errors> : Routes[K] };
824
+ type MergeStatusUnion<U> = { [K in U extends unknown ? keyof U : never]: U extends unknown ? K extends keyof U ? U[K] : never : never };
825
+ /**
826
+ * Map `Error` instances in a handler's return type to the response of their
827
+ * matching `.error(Class, handler)`. Returned errors are forwarded to the
828
+ * error pipeline at runtime, so they never appear in the 200 response
829
+ */
830
+ type ExtractReturnedError<Value, Errors extends ErrorDefinition[]> = 0 extends 1 & Value ? {} : Extract<Value, Error> extends infer Es ? IsNever<Es> extends true ? {} : MergeStatusUnion<Es extends Error ? MatchRegisteredError<Es, Errors> : never> : {};
831
+ type MergeElysiaInstances<Instances extends AnyElysia[] = [], Prefix extends string = '', Scope extends EventScope = 'local', Singleton extends SingletonBase = DefaultSingleton, Definitions extends DefinitionBase = {
832
+ typebox: {};
833
+ error: [];
834
+ }, Metadata extends MetadataBase = DefaultMetadata, Ephemeral extends EphemeralType = DefaultEphemeral, Volatile extends EphemeralType = DefaultEphemeral, Routes extends RouteBase = {}> = Instances extends [infer Current extends AnyElysia, ...infer Rest extends AnyElysia[]] ? MergeElysiaInstances<Rest, Prefix, Scope, Singleton & Current['~Singleton'], {
835
+ typebox: Definitions['typebox'] & Current['~Definitions']['typebox'];
836
+ error: [...Definitions['error'], ...Current['~Definitions']['error']];
837
+ }, Metadata & Current['~Metadata'], Ephemeral, {
838
+ derive: Volatile['derive'] & Current['~Ephemeral']['derive'];
839
+ schema: Volatile['schema'] & Current['~Ephemeral']['schema'];
840
+ schemas: Volatile['schemas'] & Current['~Ephemeral']['schemas'];
841
+ response: Volatile['response'] & Current['~Ephemeral']['response'];
842
+ error: [...Volatile['error'], ...Current['~Ephemeral']['error']];
843
+ }, ResolveRouteErrors<Routes, [...Current['~Definitions']['error'], ...Current['~Ephemeral']['error']]> & (Prefix extends `` ? ResolveRouteErrors<Current['~Routes'], [...Definitions['error'], ...Ephemeral['error'], ...Volatile['error']]> : CreateEden<Prefix, ResolveRouteErrors<Current['~Routes'], [...Definitions['error'], ...Ephemeral['error'], ...Volatile['error']]>>)> : Elysia<Prefix, Scope, {
844
+ decorator: Singleton['decorator'];
845
+ store: Prettify<Singleton['store']>;
846
+ derive: Singleton['derive'];
847
+ }, Definitions, Metadata, Routes, Ephemeral, Volatile>;
848
+ type WrapFn<Callback extends (...params: any) => MaybePromise<Response> = (request: Request, ...rest: any[]) => MaybePromise<Response>> = (fetch: (request: Request, ...rest: any[]) => MaybePromise<Response>) => Callback;
849
+ type AddRoute<BasePath extends string, Scope extends EventScope, Singleton extends SingletonBase, Definitions extends DefinitionBase, Metadata extends MetadataBase, Routes extends RouteBase, Ephemeral extends EphemeralType, Volatile extends EphemeralType, Method extends string, Path extends string, Schema extends RouteSchema, MacroContext extends RouteSchema, Handle> = Elysia<BasePath, Scope, Singleton, Definitions, Metadata, Routes & CreateEden<JoinPath<BasePath, Path>, { [method in Method]: CreateEdenResponse<Path, Schema, MacroContext, ComposeElysiaResponse<Schema & MacroContext & Metadata['schemas'] & Ephemeral['schemas'] & Volatile['schemas'], Handle, UnionResponseStatus<Metadata['response'], UnionResponseStatus<Ephemeral['response'], UnionResponseStatus<Volatile['response'], MacroContext['return'] & {}>>>, [...Definitions['error'], ...Ephemeral['error'], ...Volatile['error']], Path>, UnhandledReturnedErrorOf<Handle, [...Definitions['error'], ...Ephemeral['error'], ...Volatile['error']]>> }>, Ephemeral, Volatile>;
850
+ type HookContextSchema<Metadata extends MetadataBase, Ephemeral extends EphemeralType, Volatile extends EphemeralType, BasePath extends string> = MergeSchema<Volatile['schema'], MergeSchema<Ephemeral['schema'], Metadata['schema']>, BasePath> & Metadata['schemas'] & Ephemeral['schemas'] & Volatile['schemas'];
851
+ type HookContextSingleton<Singleton extends SingletonBase, Ephemeral extends EphemeralType, Volatile extends EphemeralType> = Singleton & {
852
+ derive: Ephemeral['derive'] & Volatile['derive'];
1231
853
  };
1232
- export type CreateEdenResponse<Path extends string, Schema extends RouteSchema, MacroContext extends RouteSchema, Res extends PossibleResponse> = RouteSchema extends MacroContext ? {
1233
- body: Schema['body'];
1234
- params: IsNever<keyof Schema['params']> extends true ? ResolvePath<Path> : Schema['params'];
1235
- query: Schema['query'];
1236
- headers: Schema['headers'];
1237
- response: Prettify<Res>;
854
+ type LocalHookReturn<BasePath extends string, Scope extends EventScope, Singleton extends SingletonBase, Definitions extends DefinitionBase, Metadata extends MetadataBase, Routes extends RouteBase, Ephemeral extends EphemeralType, Volatile extends EphemeralType, ResponseAddition extends PossibleResponse, DeriveAddition extends Record<string, unknown> = {}> = Elysia<BasePath, Scope, Singleton, Definitions, Metadata, Routes, Ephemeral, {
855
+ derive: Volatile['derive'] & DeriveAddition;
856
+ schema: Volatile['schema'];
857
+ schemas: Volatile['schemas'];
858
+ response: UnionResponseStatus<Volatile['response'], ResponseAddition>;
859
+ error: Volatile['error'];
860
+ }>;
861
+ type PluginHookReturn<BasePath extends string, Scope extends EventScope, Singleton extends SingletonBase, Definitions extends DefinitionBase, Metadata extends MetadataBase, Routes extends RouteBase, Ephemeral extends EphemeralType, Volatile extends EphemeralType, ResponseAddition extends PossibleResponse, DeriveAddition extends Record<string, unknown> = {}> = Elysia<BasePath, Scope, Singleton, Definitions, Metadata, Routes, {
862
+ derive: Ephemeral['derive'] & DeriveAddition;
863
+ schema: Ephemeral['schema'];
864
+ schemas: Ephemeral['schemas'];
865
+ response: UnionResponseStatus<Ephemeral['response'], ResponseAddition>;
866
+ error: Ephemeral['error'];
867
+ }, Volatile>;
868
+ type GlobalHookReturn<BasePath extends string, Scope extends EventScope, Singleton extends SingletonBase, Definitions extends DefinitionBase, Metadata extends MetadataBase, Routes extends RouteBase, Ephemeral extends EphemeralType, Volatile extends EphemeralType, ResponseAddition extends PossibleResponse, DeriveAddition extends Record<string, unknown> = never> = Elysia<BasePath, Scope, [DeriveAddition] extends [never] ? Singleton : {
869
+ decorator: Singleton['decorator'];
870
+ store: Singleton['store'];
871
+ derive: Singleton['derive'] & DeriveAddition;
872
+ }, Definitions, {
873
+ schema: Metadata['schema'];
874
+ schemas: Metadata['schemas'];
875
+ macro: Metadata['macro'];
876
+ macroFn: Metadata['macroFn'];
877
+ parser: Metadata['parser'];
878
+ response: UnionResponseStatus<Metadata['response'], ResponseAddition>;
879
+ }, Routes, Ephemeral, Volatile>;
880
+ type ScopedHookReturn<HookScope extends EventScope, BasePath extends string, Scope extends EventScope, Singleton extends SingletonBase, Definitions extends DefinitionBase, Metadata extends MetadataBase, Routes extends RouteBase, Ephemeral extends EphemeralType, Volatile extends EphemeralType, ResponseAddition extends PossibleResponse, DeriveAddition extends Record<string, unknown> = never> = Elysia<BasePath, Scope, [HookScope] extends ['global'] ? [DeriveAddition] extends [never] ? Singleton : {
881
+ decorator: Singleton['decorator'];
882
+ store: Singleton['store'];
883
+ derive: Singleton['derive'] & DeriveAddition;
884
+ } : Singleton, Definitions, [HookScope] extends ['global'] ? {
885
+ schema: Metadata['schema'];
886
+ schemas: Metadata['schemas'];
887
+ macro: Metadata['macro'];
888
+ macroFn: Metadata['macroFn'];
889
+ parser: Metadata['parser'];
890
+ response: UnionResponseStatus<Metadata['response'], ResponseAddition>;
891
+ } : Metadata, Routes, [HookScope] extends ['global'] ? Ephemeral : [HookScope] extends ['plugin' | 'global'] ? {
892
+ derive: Ephemeral['derive'] & ([DeriveAddition] extends [never] ? {} : DeriveAddition);
893
+ schema: Ephemeral['schema'];
894
+ schemas: Ephemeral['schemas'];
895
+ response: UnionResponseStatus<Ephemeral['response'], ResponseAddition>;
896
+ error: Ephemeral['error'];
897
+ } : Ephemeral, [HookScope] extends ['plugin' | 'global'] ? Volatile : {
898
+ derive: Volatile['derive'] & ([DeriveAddition] extends [never] ? {} : DeriveAddition);
899
+ schema: Volatile['schema'];
900
+ schemas: Volatile['schemas'];
901
+ response: UnionResponseStatus<Volatile['response'], ResponseAddition>;
902
+ error: Volatile['error'];
903
+ }>;
904
+ type ScopedMapDeriveReturn<HookScope extends EventScope, BasePath extends string, Scope extends EventScope, Singleton extends SingletonBase, Definitions extends DefinitionBase, Metadata extends MetadataBase, Routes extends RouteBase, Ephemeral extends EphemeralType, Volatile extends EphemeralType, ResponseAddition extends PossibleResponse, Derive extends Record<string, unknown>> = Elysia<BasePath, Scope, [HookScope] extends ['global'] ? {
905
+ decorator: Singleton['decorator'];
906
+ store: Singleton['store'];
907
+ derive: Derive;
908
+ } : [HookScope] extends ['plugin' | 'local'] ? Singleton : {
909
+ decorator: Singleton['decorator'];
910
+ store: Singleton['store'];
911
+ derive: Partial<Singleton['derive']>;
912
+ }, Definitions, [HookScope] extends ['global'] ? {
913
+ schema: Metadata['schema'];
914
+ schemas: Metadata['schemas'];
915
+ macro: Metadata['macro'];
916
+ macroFn: Metadata['macroFn'];
917
+ parser: Metadata['parser'];
918
+ response: UnionResponseStatus<Metadata['response'], ResponseAddition>;
919
+ } : Metadata, Routes, [HookScope] extends ['global'] ? Ephemeral : [HookScope] extends ['plugin'] ? {
920
+ derive: Derive;
921
+ schema: Ephemeral['schema'];
922
+ schemas: Ephemeral['schemas'];
923
+ response: UnionResponseStatus<Ephemeral['response'], ResponseAddition>;
924
+ error: Ephemeral['error'];
925
+ } : [HookScope] extends ['local'] ? Ephemeral : [HookScope] extends ['plugin' | 'global'] ? {
926
+ derive: Partial<Ephemeral['derive']> & Derive;
927
+ schema: Ephemeral['schema'];
928
+ schemas: Ephemeral['schemas'];
929
+ response: UnionResponseStatus<Ephemeral['response'], ResponseAddition>;
930
+ error: Ephemeral['error'];
931
+ } : 'plugin' extends HookScope ? {
932
+ derive: Partial<Ephemeral['derive']> & Partial<Derive>;
933
+ schema: Ephemeral['schema'];
934
+ schemas: Ephemeral['schemas'];
935
+ response: UnionResponseStatus<Ephemeral['response'], ResponseAddition>;
936
+ error: Ephemeral['error'];
937
+ } : Ephemeral, [HookScope] extends ['plugin' | 'global'] ? Volatile : [HookScope] extends ['local'] ? {
938
+ derive: Derive;
939
+ schema: Volatile['schema'];
940
+ schemas: Volatile['schemas'];
941
+ response: UnionResponseStatus<Volatile['response'], ResponseAddition>;
942
+ error: Volatile['error'];
1238
943
  } : {
1239
- body: Prettify<Schema['body'] & MacroContext['body']>;
1240
- params: IsNever<keyof (Schema['params'] & MacroContext['params'])> extends true ? ResolvePath<Path> : Prettify<Schema['params'] & MacroContext['params']>;
1241
- query: Prettify<Schema['query'] & MacroContext['query']>;
1242
- headers: Prettify<Schema['headers'] & MacroContext['headers']>;
1243
- response: Prettify<Res>;
944
+ derive: Partial<Volatile['derive']> & Derive;
945
+ schema: Volatile['schema'];
946
+ schemas: Volatile['schemas'];
947
+ response: UnionResponseStatus<Volatile['response'], ResponseAddition>;
948
+ error: Volatile['error'];
949
+ }>;
950
+ type AddWSRoute<BasePath extends string, Scope extends EventScope, Singleton extends SingletonBase, Definitions extends DefinitionBase, Metadata extends MetadataBase, Routes extends RouteBase, Ephemeral extends EphemeralType, Volatile extends EphemeralType, Path extends string, Schema extends RouteSchema, MacroContext extends RouteSchema, Response> = Elysia<BasePath, Scope, Singleton, Definitions, Metadata, Routes & CreateEden<JoinPath<BasePath, Path>, {
951
+ subscribe: CreateWSEdenResponse<Path, Schema, MacroContext, ComposeElysiaResponse<Schema & MacroContext & Metadata['schemas'] & Ephemeral['schemas'] & Volatile['schemas'], Response, UnionResponseStatus<Metadata['response'], UnionResponseStatus<Ephemeral['response'], UnionResponseStatus<Volatile['response'], MacroContext['return'] & {}>>>, [...Definitions['error'], ...Ephemeral['error'], ...Volatile['error']], Path>>;
952
+ }>, Ephemeral, Volatile>;
953
+ type GuardHookSingleton<Singleton extends SingletonBase, Ephemeral extends EphemeralType, Volatile extends EphemeralType, MacroContext> = Singleton & {
954
+ derive: Ephemeral['derive'] & Volatile['derive'] & MacroContext['resolve'];
1244
955
  };
1245
- export interface Router {
1246
- '~http': Memoirist<{
1247
- compile: Function;
1248
- handler?: ComposedHandler;
1249
- }> | undefined;
1250
- get http(): Memoirist<{
1251
- compile: Function;
1252
- handler?: ComposedHandler;
1253
- }>;
1254
- '~dynamic': Memoirist<DynamicHandler> | undefined;
1255
- get dynamic(): Memoirist<DynamicHandler>;
1256
- static: {
1257
- [path: string]: {
1258
- [method: string]: number;
1259
- };
1260
- };
1261
- response: {
1262
- [path: string]: MaybePromise<Response | undefined> | {
1263
- [method: string]: MaybePromise<Response | undefined>;
1264
- };
1265
- };
1266
- history: InternalRoute[];
1267
- }
1268
- export type ModelsToTypes<T extends Record<keyof any, AnySchema>> = {
1269
- [K in keyof T]: UnwrapSchema<T[K]>;
956
+ interface StaticMapAliases {
957
+ method: string;
958
+ paths: string[];
959
+ }
960
+ type LazyComposeEntry = {
961
+ kind: 'route';
962
+ route: InternalRoute;
963
+ source?: string;
964
+ } | {
965
+ kind: 'use';
966
+ child: AnyElysia;
967
+ preChain: ChainNode | undefined;
968
+ childBaseLen: number;
969
+ childPlan: LazyComposeEntry[] | undefined;
970
+ childPlanLen: number;
971
+ source?: string;
1270
972
  };
1271
- export {};
973
+ //#endregion
974
+ export { AddRoute, AddWSRoute, AfterHandler, AfterResponseHandler, AnyErrorConstructor, AnyLocalHook, type AnySchema, AnyWSLocalHook, AppEvent, AppHook, BaseMacro, BodyHandler, BunHTMLBundlelike, CompiledHandler, ComposeElysiaResponse, ContentType, ContextAppendType, CreateEden, CreateEdenResponse, CreateWSEdenResponse, DefaultEphemeral, DefaultMetadata, DefaultSingleton, DefinitionBase, DocumentDecoration, ElysiaConfig, ElysiaFormData, ElysiaHandlerToResponseSchema, ElysiaHandlerToResponseSchemaAmbiguous, ElysiaHandlerToResponseSchemas, EmptyInputSchema, EphemeralType, Equal, ErrorDefinition, ErrorDefinitionEntry, ErrorHandler, ErrorHandlerResponseSchema, EventFn, EventScope, ExcludeElysiaResponse, ExtractErrorFromHandle, ExtractReturnedError, GetPathParameter, GlobalHookReturn, GracefulHandler, GuardHookSingleton, GuardLocalHook, GuardSchemaType, HTTPHeaders, HTTPMethod, Handler, HistoryEntry, HookContextSchema, HookContextSingleton, InlineHandler, InlineHandlerNonMacro, InlineHandlerResponse, InlineResponse, InputSchema, InputSchemaKey, InternalRoute, IntersectIfObject, IntersectIfObjectSchema, IsAny, IsNever, IsTuple, JoinPath, LazyComposeEntry, LocalHook, LocalHookReturn, Macro, MacroProperty, MacroPropertyKey, MacroSchemaChannel, MacroToContext, MacroToProperty, MapResponse, MaybeArray, MaybePromise, MaybeValueOrVoidFunction, MergeElysiaInstances, MergeSchema, MergeScopedSchemas, MetadataBase, NonResolvableMacroKey, ObjectMacroDefs, OptionalHandler, PluginHookReturn, PossibleResponse, PreHandler, Prettify, PublicRoute, Replace, ResolveHandler, ResolvePath, ResolveRouteErrors, RouteBase, RouteSchema, SSEPayload, ScopedHookReturn, ScopedMapDeriveReturn, SingletonBase, type StandardSchemaV1Like, StaticMapAliases, TransformHandler, type TypeBoxSchema, UnhandledReturnedError, UnhandledReturnedErrorOf, UnionResponseStatus, UnionToIntersect, UnwrapArray, UnwrapBodySchema, UnwrapMacroSchema, UnwrapRoute, UnwrapSchema, ValueOrFunctionToResponseSchema, ValueToResponseSchema, VoidHandler, WrapFn };