effect-start 0.23.1 → 0.26.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 (351) hide show
  1. package/package.json +18 -86
  2. package/src/Development.ts +3 -1
  3. package/src/Entity.ts +17 -0
  4. package/src/Fetch.ts +271 -0
  5. package/src/SqlIntrospect.ts +64 -70
  6. package/src/Start.ts +21 -24
  7. package/src/StartApp.ts +1 -1
  8. package/src/bun/BunServer.ts +42 -10
  9. package/src/hyper/HyperHtml.ts +0 -1
  10. package/src/sql/bun/index.ts +1 -1
  11. package/src/sql/index.ts +1 -0
  12. package/src/sql/libsql/index.ts +173 -0
  13. package/src/sql/libsql/libsql.d.ts +39 -0
  14. package/src/sql/mssql/index.ts +1 -1
  15. package/dist/BlobStore.d.ts +0 -80
  16. package/dist/BlobStore.js +0 -19
  17. package/dist/ChildProcess.d.ts +0 -60
  18. package/dist/ChildProcess.js +0 -30
  19. package/dist/Commander.d.ts +0 -100
  20. package/dist/Commander.js +0 -326
  21. package/dist/ContentNegotiation.d.ts +0 -12
  22. package/dist/ContentNegotiation.js +0 -359
  23. package/dist/Cookies.d.ts +0 -47
  24. package/dist/Cookies.js +0 -302
  25. package/dist/Development.d.ts +0 -39
  26. package/dist/Development.js +0 -58
  27. package/dist/Effectify.d.ts +0 -209
  28. package/dist/Effectify.js +0 -19
  29. package/dist/Entity.d.ts +0 -47
  30. package/dist/Entity.js +0 -224
  31. package/dist/FilePathPattern.d.ts +0 -29
  32. package/dist/FilePathPattern.js +0 -86
  33. package/dist/FileRouter.d.ts +0 -56
  34. package/dist/FileRouter.js +0 -148
  35. package/dist/FileRouterCodegen.d.ts +0 -18
  36. package/dist/FileRouterCodegen.js +0 -227
  37. package/dist/FileRouterPattern.d.ts +0 -9
  38. package/dist/FileRouterPattern.js +0 -35
  39. package/dist/FileSystem.d.ts +0 -158
  40. package/dist/FileSystem.js +0 -70
  41. package/dist/Http.d.ts +0 -37
  42. package/dist/Http.js +0 -88
  43. package/dist/HttpAppExtra.d.ts +0 -7
  44. package/dist/HttpAppExtra.js +0 -320
  45. package/dist/HttpUtils.d.ts +0 -3
  46. package/dist/HttpUtils.js +0 -11
  47. package/dist/PathPattern.d.ts +0 -134
  48. package/dist/PathPattern.js +0 -413
  49. package/dist/PlatformError.d.ts +0 -38
  50. package/dist/PlatformError.js +0 -25
  51. package/dist/PlatformRuntime.d.ts +0 -27
  52. package/dist/PlatformRuntime.js +0 -46
  53. package/dist/Route.d.ts +0 -97
  54. package/dist/Route.js +0 -100
  55. package/dist/RouteBody.d.ts +0 -47
  56. package/dist/RouteBody.js +0 -67
  57. package/dist/RouteError.d.ts +0 -98
  58. package/dist/RouteError.js +0 -55
  59. package/dist/RouteHook.d.ts +0 -12
  60. package/dist/RouteHook.js +0 -40
  61. package/dist/RouteHttp.d.ts +0 -21
  62. package/dist/RouteHttp.js +0 -258
  63. package/dist/RouteHttpTracer.d.ts +0 -10
  64. package/dist/RouteHttpTracer.js +0 -62
  65. package/dist/RouteMount.d.ts +0 -86
  66. package/dist/RouteMount.js +0 -63
  67. package/dist/RouteSchema.d.ts +0 -86
  68. package/dist/RouteSchema.js +0 -188
  69. package/dist/RouteSse.d.ts +0 -21
  70. package/dist/RouteSse.js +0 -79
  71. package/dist/RouteTree.d.ts +0 -57
  72. package/dist/RouteTree.js +0 -93
  73. package/dist/RouteTrie.d.ts +0 -20
  74. package/dist/RouteTrie.js +0 -152
  75. package/dist/RouterPattern.d.ts +0 -118
  76. package/dist/RouterPattern.js +0 -269
  77. package/dist/SchemaExtra.d.ts +0 -7
  78. package/dist/SchemaExtra.js +0 -74
  79. package/dist/Socket.d.ts +0 -27
  80. package/dist/Socket.js +0 -29
  81. package/dist/Sql.d.ts +0 -34
  82. package/dist/Sql.js +0 -5
  83. package/dist/SqlIntrospect.d.ts +0 -91
  84. package/dist/SqlIntrospect.js +0 -466
  85. package/dist/Start.d.ts +0 -44
  86. package/dist/Start.js +0 -49
  87. package/dist/StartApp.d.ts +0 -19
  88. package/dist/StartApp.js +0 -21
  89. package/dist/StreamExtra.d.ts +0 -28
  90. package/dist/StreamExtra.js +0 -100
  91. package/dist/System.d.ts +0 -7
  92. package/dist/System.js +0 -22
  93. package/dist/TuplePathPattern.d.ts +0 -9
  94. package/dist/TuplePathPattern.js +0 -68
  95. package/dist/Unique.d.ts +0 -50
  96. package/dist/Unique.js +0 -187
  97. package/dist/Values.d.ts +0 -27
  98. package/dist/Values.js +0 -36
  99. package/dist/bun/BunBlobStoreDisk.d.ts +0 -6
  100. package/dist/bun/BunBlobStoreDisk.js +0 -116
  101. package/dist/bun/BunBlobStoreS3.d.ts +0 -11
  102. package/dist/bun/BunBlobStoreS3.js +0 -89
  103. package/dist/bun/BunBlobWatcherDisk.d.ts +0 -6
  104. package/dist/bun/BunBlobWatcherDisk.js +0 -60
  105. package/dist/bun/BunBlobWatcherQueue.d.ts +0 -6
  106. package/dist/bun/BunBlobWatcherQueue.js +0 -17
  107. package/dist/bun/BunBundle.d.ts +0 -11
  108. package/dist/bun/BunBundle.js +0 -137
  109. package/dist/bun/BunChildProcessSpawner.d.ts +0 -3
  110. package/dist/bun/BunChildProcessSpawner.js +0 -103
  111. package/dist/bun/BunHttpServer.d.ts +0 -44
  112. package/dist/bun/BunHttpServer.js +0 -186
  113. package/dist/bun/BunHttpServer_web.d.ts +0 -60
  114. package/dist/bun/BunHttpServer_web.js +0 -252
  115. package/dist/bun/BunImportTrackerPlugin.d.ts +0 -13
  116. package/dist/bun/BunImportTrackerPlugin.js +0 -69
  117. package/dist/bun/BunPlatformHttpServer.d.ts +0 -10
  118. package/dist/bun/BunPlatformHttpServer.js +0 -53
  119. package/dist/bun/BunRoute.d.ts +0 -48
  120. package/dist/bun/BunRoute.js +0 -121
  121. package/dist/bun/BunRuntime.d.ts +0 -2
  122. package/dist/bun/BunRuntime.js +0 -31
  123. package/dist/bun/BunServer.d.ts +0 -40
  124. package/dist/bun/BunServer.js +0 -157
  125. package/dist/bun/BunServerRequest.d.ts +0 -60
  126. package/dist/bun/BunServerRequest.js +0 -252
  127. package/dist/bun/BunSql.d.ts +0 -4
  128. package/dist/bun/BunSql.js +0 -81
  129. package/dist/bun/BunVirtualFilesPlugin.d.ts +0 -4
  130. package/dist/bun/BunVirtualFilesPlugin.js +0 -40
  131. package/dist/bun/_BunEnhancedResolve.d.ts +0 -45
  132. package/dist/bun/_BunEnhancedResolve.js +0 -102
  133. package/dist/bun/index.d.ts +0 -5
  134. package/dist/bun/index.js +0 -5
  135. package/dist/bundler/Bundle.d.ts +0 -61
  136. package/dist/bundler/Bundle.js +0 -48
  137. package/dist/bundler/BundleFiles.d.ts +0 -13
  138. package/dist/bundler/BundleFiles.js +0 -96
  139. package/dist/bundler/BundleHttp.d.ts +0 -45
  140. package/dist/bundler/BundleHttp.js +0 -176
  141. package/dist/bundler/BundleRoute.d.ts +0 -27
  142. package/dist/bundler/BundleRoute.js +0 -51
  143. package/dist/client/Overlay.d.ts +0 -2
  144. package/dist/client/Overlay.js +0 -32
  145. package/dist/client/ScrollState.d.ts +0 -6
  146. package/dist/client/ScrollState.js +0 -94
  147. package/dist/client/index.d.ts +0 -6
  148. package/dist/client/index.js +0 -79
  149. package/dist/console/Console.d.ts +0 -6
  150. package/dist/console/Console.js +0 -26
  151. package/dist/console/ConsoleErrors.d.ts +0 -3
  152. package/dist/console/ConsoleErrors.js +0 -200
  153. package/dist/console/ConsoleLogger.d.ts +0 -3
  154. package/dist/console/ConsoleLogger.js +0 -47
  155. package/dist/console/ConsoleMetrics.d.ts +0 -3
  156. package/dist/console/ConsoleMetrics.js +0 -61
  157. package/dist/console/ConsoleProcess.d.ts +0 -3
  158. package/dist/console/ConsoleProcess.js +0 -49
  159. package/dist/console/ConsoleStore.d.ts +0 -144
  160. package/dist/console/ConsoleStore.js +0 -61
  161. package/dist/console/ConsoleTracer.d.ts +0 -3
  162. package/dist/console/ConsoleTracer.js +0 -94
  163. package/dist/console/Simulation.d.ts +0 -2
  164. package/dist/console/Simulation.js +0 -633
  165. package/dist/console/index.d.ts +0 -3
  166. package/dist/console/index.js +0 -3
  167. package/dist/console/routes/errors/route.d.ts +0 -10
  168. package/dist/console/routes/errors/route.js +0 -47
  169. package/dist/console/routes/fiberDetail.d.ts +0 -16
  170. package/dist/console/routes/fiberDetail.js +0 -38
  171. package/dist/console/routes/fibers/route.d.ts +0 -10
  172. package/dist/console/routes/fibers/route.js +0 -19
  173. package/dist/console/routes/git/route.d.ts +0 -11
  174. package/dist/console/routes/git/route.js +0 -33
  175. package/dist/console/routes/layout.d.ts +0 -9
  176. package/dist/console/routes/layout.js +0 -3
  177. package/dist/console/routes/logs/route.d.ts +0 -10
  178. package/dist/console/routes/logs/route.js +0 -32
  179. package/dist/console/routes/metrics/route.d.ts +0 -10
  180. package/dist/console/routes/metrics/route.js +0 -17
  181. package/dist/console/routes/route.d.ts +0 -6
  182. package/dist/console/routes/route.js +0 -5
  183. package/dist/console/routes/routes/route.d.ts +0 -6
  184. package/dist/console/routes/routes/route.js +0 -20
  185. package/dist/console/routes/services/route.d.ts +0 -6
  186. package/dist/console/routes/services/route.js +0 -12
  187. package/dist/console/routes/system/route.d.ts +0 -10
  188. package/dist/console/routes/system/route.js +0 -18
  189. package/dist/console/routes/traceDetail.d.ts +0 -16
  190. package/dist/console/routes/traceDetail.js +0 -14
  191. package/dist/console/routes/traces/route.d.ts +0 -10
  192. package/dist/console/routes/traces/route.js +0 -39
  193. package/dist/console/routes/tree.d.ts +0 -153
  194. package/dist/console/routes/tree.js +0 -29
  195. package/dist/console/ui/Errors.d.ts +0 -4
  196. package/dist/console/ui/Errors.js +0 -15
  197. package/dist/console/ui/Fibers.d.ts +0 -24
  198. package/dist/console/ui/Fibers.js +0 -121
  199. package/dist/console/ui/Git.d.ts +0 -20
  200. package/dist/console/ui/Git.js +0 -95
  201. package/dist/console/ui/Logs.d.ts +0 -4
  202. package/dist/console/ui/Logs.js +0 -25
  203. package/dist/console/ui/Metrics.d.ts +0 -4
  204. package/dist/console/ui/Metrics.js +0 -26
  205. package/dist/console/ui/Routes.d.ts +0 -8
  206. package/dist/console/ui/Routes.js +0 -70
  207. package/dist/console/ui/Services.d.ts +0 -10
  208. package/dist/console/ui/Services.js +0 -246
  209. package/dist/console/ui/Shell.d.ts +0 -10
  210. package/dist/console/ui/Shell.js +0 -7
  211. package/dist/console/ui/System.d.ts +0 -4
  212. package/dist/console/ui/System.js +0 -35
  213. package/dist/console/ui/Traces.d.ts +0 -12
  214. package/dist/console/ui/Traces.js +0 -179
  215. package/dist/datastar/actions/fetch.d.ts +0 -30
  216. package/dist/datastar/actions/fetch.js +0 -403
  217. package/dist/datastar/actions/peek.d.ts +0 -1
  218. package/dist/datastar/actions/peek.js +0 -13
  219. package/dist/datastar/actions/setAll.d.ts +0 -1
  220. package/dist/datastar/actions/setAll.js +0 -12
  221. package/dist/datastar/actions/toggleAll.d.ts +0 -1
  222. package/dist/datastar/actions/toggleAll.js +0 -12
  223. package/dist/datastar/attributes/attr.d.ts +0 -1
  224. package/dist/datastar/attributes/attr.js +0 -48
  225. package/dist/datastar/attributes/bind.d.ts +0 -1
  226. package/dist/datastar/attributes/bind.js +0 -175
  227. package/dist/datastar/attributes/class.d.ts +0 -1
  228. package/dist/datastar/attributes/class.js +0 -47
  229. package/dist/datastar/attributes/computed.d.ts +0 -1
  230. package/dist/datastar/attributes/computed.js +0 -26
  231. package/dist/datastar/attributes/effect.d.ts +0 -1
  232. package/dist/datastar/attributes/effect.js +0 -9
  233. package/dist/datastar/attributes/indicator.d.ts +0 -1
  234. package/dist/datastar/attributes/indicator.js +0 -30
  235. package/dist/datastar/attributes/init.d.ts +0 -1
  236. package/dist/datastar/attributes/init.js +0 -26
  237. package/dist/datastar/attributes/jsonSignals.d.ts +0 -1
  238. package/dist/datastar/attributes/jsonSignals.js +0 -30
  239. package/dist/datastar/attributes/on.d.ts +0 -1
  240. package/dist/datastar/attributes/on.js +0 -78
  241. package/dist/datastar/attributes/onIntersect.d.ts +0 -1
  242. package/dist/datastar/attributes/onIntersect.js +0 -53
  243. package/dist/datastar/attributes/onInterval.d.ts +0 -1
  244. package/dist/datastar/attributes/onInterval.js +0 -30
  245. package/dist/datastar/attributes/onSignalPatch.d.ts +0 -1
  246. package/dist/datastar/attributes/onSignalPatch.js +0 -42
  247. package/dist/datastar/attributes/ref.d.ts +0 -1
  248. package/dist/datastar/attributes/ref.js +0 -10
  249. package/dist/datastar/attributes/show.d.ts +0 -1
  250. package/dist/datastar/attributes/show.js +0 -31
  251. package/dist/datastar/attributes/signals.d.ts +0 -1
  252. package/dist/datastar/attributes/signals.js +0 -17
  253. package/dist/datastar/attributes/style.d.ts +0 -1
  254. package/dist/datastar/attributes/style.js +0 -50
  255. package/dist/datastar/attributes/text.d.ts +0 -1
  256. package/dist/datastar/attributes/text.js +0 -26
  257. package/dist/datastar/engine.d.ts +0 -162
  258. package/dist/datastar/engine.js +0 -999
  259. package/dist/datastar/happydom.d.ts +0 -1
  260. package/dist/datastar/happydom.js +0 -8
  261. package/dist/datastar/index.d.ts +0 -24
  262. package/dist/datastar/index.js +0 -24
  263. package/dist/datastar/load.d.ts +0 -24
  264. package/dist/datastar/load.js +0 -24
  265. package/dist/datastar/utils.d.ts +0 -51
  266. package/dist/datastar/utils.js +0 -202
  267. package/dist/datastar/watchers/patchElements.d.ts +0 -1
  268. package/dist/datastar/watchers/patchElements.js +0 -399
  269. package/dist/datastar/watchers/patchSignals.d.ts +0 -1
  270. package/dist/datastar/watchers/patchSignals.js +0 -14
  271. package/dist/experimental/EncryptedCookies.d.ts +0 -48
  272. package/dist/experimental/EncryptedCookies.js +0 -212
  273. package/dist/experimental/SseHttpResponse.d.ts +0 -7
  274. package/dist/experimental/SseHttpResponse.js +0 -28
  275. package/dist/experimental/index.d.ts +0 -1
  276. package/dist/experimental/index.js +0 -1
  277. package/dist/hyper/Hyper.d.ts +0 -25
  278. package/dist/hyper/Hyper.js +0 -23
  279. package/dist/hyper/HyperHtml.d.ts +0 -23
  280. package/dist/hyper/HyperHtml.js +0 -150
  281. package/dist/hyper/HyperHtml.test.d.ts +0 -1
  282. package/dist/hyper/HyperHtml.test.js +0 -197
  283. package/dist/hyper/HyperNode.d.ts +0 -14
  284. package/dist/hyper/HyperNode.js +0 -11
  285. package/dist/hyper/HyperRoute.d.ts +0 -8
  286. package/dist/hyper/HyperRoute.js +0 -32
  287. package/dist/hyper/HyperRoute.test.d.ts +0 -1
  288. package/dist/hyper/HyperRoute.test.js +0 -83
  289. package/dist/hyper/html.d.ts +0 -11
  290. package/dist/hyper/html.js +0 -30
  291. package/dist/hyper/index.d.ts +0 -6
  292. package/dist/hyper/index.js +0 -5
  293. package/dist/hyper/jsx-runtime.d.ts +0 -7
  294. package/dist/hyper/jsx-runtime.js +0 -8
  295. package/dist/index.d.ts +0 -8
  296. package/dist/index.js +0 -8
  297. package/dist/inference_check.d.ts +0 -1
  298. package/dist/inference_check.js +0 -15
  299. package/dist/lint/plugin.d.ts +0 -86
  300. package/dist/lint/plugin.js +0 -341
  301. package/dist/middlewares/BasicAuthMiddleware.d.ts +0 -8
  302. package/dist/middlewares/BasicAuthMiddleware.js +0 -22
  303. package/dist/middlewares/index.d.ts +0 -1
  304. package/dist/middlewares/index.js +0 -1
  305. package/dist/node/Effectify.d.ts +0 -209
  306. package/dist/node/Effectify.js +0 -19
  307. package/dist/node/FileSystem.d.ts +0 -7
  308. package/dist/node/FileSystem.js +0 -420
  309. package/dist/node/NodeFileSystem.d.ts +0 -7
  310. package/dist/node/NodeFileSystem.js +0 -410
  311. package/dist/node/NodeUtils.d.ts +0 -2
  312. package/dist/node/NodeUtils.js +0 -20
  313. package/dist/node/PlatformError.d.ts +0 -46
  314. package/dist/node/PlatformError.js +0 -43
  315. package/dist/node/Utils.d.ts +0 -1
  316. package/dist/node/Utils.js +0 -19
  317. package/dist/repro_fail.d.ts +0 -1
  318. package/dist/repro_fail.js +0 -14
  319. package/dist/sql/bun/index.d.ts +0 -3
  320. package/dist/sql/bun/index.js +0 -75
  321. package/dist/sql/mssql/docker.d.ts +0 -2
  322. package/dist/sql/mssql/docker.js +0 -67
  323. package/dist/sql/mssql/index.d.ts +0 -21
  324. package/dist/sql/mssql/index.js +0 -113
  325. package/dist/testing/TestHttpClient.d.ts +0 -13
  326. package/dist/testing/TestHttpClient.js +0 -68
  327. package/dist/testing/TestLogger.d.ts +0 -13
  328. package/dist/testing/TestLogger.js +0 -32
  329. package/dist/testing/index.d.ts +0 -2
  330. package/dist/testing/index.js +0 -2
  331. package/dist/testing/utils.d.ts +0 -9
  332. package/dist/testing/utils.js +0 -39
  333. package/dist/x/cloudflare/CloudflareTunnel.d.ts +0 -10
  334. package/dist/x/cloudflare/CloudflareTunnel.js +0 -30
  335. package/dist/x/cloudflare/index.d.ts +0 -1
  336. package/dist/x/cloudflare/index.js +0 -1
  337. package/dist/x/datastar/Datastar.d.ts +0 -6
  338. package/dist/x/datastar/Datastar.js +0 -47
  339. package/dist/x/datastar/index.d.ts +0 -1
  340. package/dist/x/datastar/index.js +0 -1
  341. package/dist/x/tailscale/TailscaleTunnel.d.ts +0 -15
  342. package/dist/x/tailscale/TailscaleTunnel.js +0 -68
  343. package/dist/x/tailscale/index.d.ts +0 -1
  344. package/dist/x/tailscale/index.js +0 -1
  345. package/dist/x/tailwind/TailwindPlugin.d.ts +0 -23
  346. package/dist/x/tailwind/TailwindPlugin.js +0 -219
  347. package/dist/x/tailwind/compile.d.ts +0 -19
  348. package/dist/x/tailwind/compile.js +0 -154
  349. package/dist/x/tailwind/plugin.d.ts +0 -2
  350. package/dist/x/tailwind/plugin.js +0 -15
  351. /package/src/{Sql.ts → sql/Sql.ts} +0 -0
package/dist/RouteHttp.js DELETED
@@ -1,258 +0,0 @@
1
- import * as Cause from "effect/Cause";
2
- import * as Effect from "effect/Effect";
3
- import * as FiberId from "effect/FiberId";
4
- import * as FiberRef from "effect/FiberRef";
5
- import * as HashSet from "effect/HashSet";
6
- import * as Option from "effect/Option";
7
- import * as Runtime from "effect/Runtime";
8
- import * as Stream from "effect/Stream";
9
- import * as ContentNegotiation from "./ContentNegotiation.js";
10
- import * as Entity from "./Entity.js";
11
- import * as Route from "./Route.js";
12
- import * as RouteHttpTracer from "./RouteHttpTracer.js";
13
- import * as RouteTree from "./RouteTree.js";
14
- import * as StreamExtra from "./StreamExtra.js";
15
- // Used to match Accept headers against available route formats.
16
- // text/* matches any text type (text/plain, text/event-stream, text/markdown, etc.)
17
- const formatToMediaType = {
18
- text: "text/*",
19
- html: "text/html",
20
- json: "application/json",
21
- bytes: "application/octet-stream",
22
- };
23
- // Used after content negotiation to determine which format was selected.
24
- const mediaTypeToFormat = {
25
- "text/*": "text",
26
- "text/html": "html",
27
- "application/json": "json",
28
- "application/octet-stream": "bytes",
29
- };
30
- /**
31
- * A synthetic fiber used to tag interruptions caused by client disconnects.
32
- * Number stands for HTTP status 499 "Client Closed Request".
33
- * This is what @effect/platform does to signal request cancelation.
34
- */
35
- export const clientAbortFiberId = FiberId.runtime(-499, 0);
36
- const isClientAbort = (cause) => Cause.isInterruptedOnly(cause) &&
37
- HashSet.some(Cause.interruptors(cause), (id) => id === clientAbortFiberId);
38
- const getStatusFromCause = (cause) => {
39
- const failure = Cause.failureOption(cause);
40
- if (failure._tag === "Some") {
41
- const error = failure.value;
42
- if (error._tag === "ParseError" || error._tag === "RequestBodyError") {
43
- return 400;
44
- }
45
- }
46
- return 500;
47
- };
48
- const respondError = (options) => new Response(JSON.stringify(options, null, 2), {
49
- status: options.status,
50
- headers: { "content-type": "application/json" },
51
- });
52
- function streamResponse(stream, headers, status, runtime) {
53
- const encoder = new TextEncoder();
54
- const byteStream = stream.pipe(Stream.map((chunk) => typeof chunk === "string" ? encoder.encode(chunk) : chunk), Stream.catchAll((error) => Stream.fail(error instanceof Error ? error : new Error(String(error)))));
55
- return new Response(Stream.toReadableStreamRuntime(byteStream, runtime), {
56
- status,
57
- headers: headers,
58
- });
59
- }
60
- function toResponse(entity, format, runtime) {
61
- const contentType = Entity.type(entity);
62
- const status = entity.status ?? 200;
63
- const headers = { ...entity.headers, "content-type": contentType };
64
- if (StreamExtra.isStream(entity.body)) {
65
- return Effect.succeed(streamResponse(entity.body, headers, status, runtime));
66
- }
67
- if (format === "json") {
68
- return Effect.map(entity.json, (data) => new Response(JSON.stringify(data), { status, headers }));
69
- }
70
- if (format === "text" || format === "html") {
71
- return Effect.map(entity.text, (text) => new Response(text, { status, headers }));
72
- }
73
- if (format === "bytes") {
74
- return Effect.map(entity.bytes, (bytes) => new Response(bytes, { status, headers }));
75
- }
76
- return Effect.succeed(streamResponse(entity.stream, headers, status, runtime));
77
- }
78
- function determineSelectedFormat(accept, routes) {
79
- const formats = routes
80
- .filter((r) => Route.descriptor(r).method !== "*")
81
- .map((r) => Route.descriptor(r).format)
82
- .filter((f) => Boolean(f) && f !== "*");
83
- const uniqueFormats = [...new Set(formats)];
84
- const mediaTypes = uniqueFormats.map((f) => formatToMediaType[f]).filter(Boolean);
85
- if (mediaTypes.length === 0) {
86
- return undefined;
87
- }
88
- if (!accept) {
89
- return uniqueFormats[0];
90
- }
91
- const negotiated = ContentNegotiation.media(accept, mediaTypes);
92
- if (negotiated.length > 0) {
93
- return mediaTypeToFormat[negotiated[0]];
94
- }
95
- return undefined;
96
- }
97
- export const toWebHandlerRuntime = (runtime) => {
98
- const runFork = Runtime.runFork(runtime);
99
- return (routes) => {
100
- const grouped = Object.groupBy(routes, (route) => Route.descriptor(route).method?.toUpperCase() ?? "*");
101
- const wildcards = grouped["*"] ?? [];
102
- const methodGroups = {
103
- GET: undefined,
104
- POST: undefined,
105
- PUT: undefined,
106
- PATCH: undefined,
107
- DELETE: undefined,
108
- HEAD: undefined,
109
- OPTIONS: undefined,
110
- };
111
- for (const method in grouped) {
112
- if (method !== "*") {
113
- methodGroups[method] = grouped[method];
114
- }
115
- }
116
- return (request) => {
117
- const method = request.method.toUpperCase();
118
- const accept = request.headers.get("accept");
119
- const methodRoutes = methodGroups[method] ?? [];
120
- if (methodRoutes.length === 0 && wildcards.length === 0) {
121
- return Promise.resolve(respondError({ status: 405, message: "method not allowed" }));
122
- }
123
- const allRoutes = [...wildcards, ...methodRoutes];
124
- const selectedFormat = determineSelectedFormat(accept, allRoutes);
125
- const specificFormats = new Set();
126
- let hasWildcardFormatRoutes = false;
127
- for (const r of allRoutes) {
128
- const format = Route.descriptor(r).format;
129
- if (format === "*")
130
- hasWildcardFormatRoutes = true;
131
- else if (format)
132
- specificFormats.add(format);
133
- }
134
- const hasSpecificFormatRoutes = specificFormats.size > 0;
135
- const varyAccept = specificFormats.size > 1;
136
- if (selectedFormat === undefined && hasSpecificFormatRoutes && !hasWildcardFormatRoutes) {
137
- return Promise.resolve(respondError({ status: 406, message: "not acceptable" }));
138
- }
139
- const createChain = (initialContext) => {
140
- let index = 0;
141
- let currentContext = initialContext;
142
- let routePathSet = false;
143
- const runNext = (passedContext) => {
144
- if (passedContext !== undefined) {
145
- currentContext = passedContext;
146
- }
147
- if (index >= allRoutes.length) {
148
- return Effect.succeed(Entity.make({ status: 404, message: "route not found" }, { status: 404 }));
149
- }
150
- const route = allRoutes[index++];
151
- const descriptor = Route.descriptor(route);
152
- const format = descriptor.format;
153
- const handler = route.handler;
154
- if (format && format !== "*" && format !== selectedFormat) {
155
- return runNext();
156
- }
157
- currentContext = { ...currentContext, ...descriptor };
158
- const nextArg = (ctx) => Entity.effect(Effect.suspend(() => runNext(ctx)));
159
- const routePath = descriptor["path"];
160
- if (!routePathSet && routePath !== undefined) {
161
- routePathSet = true;
162
- return Effect.flatMap(Effect.currentSpan.pipe(Effect.option), (spanOption) => {
163
- if (Option.isSome(spanOption)) {
164
- spanOption.value.attribute("http.route", routePath);
165
- }
166
- return handler(currentContext, nextArg);
167
- });
168
- }
169
- return handler(currentContext, nextArg);
170
- };
171
- return runNext();
172
- };
173
- const effect = Effect.withFiberRuntime((fiber) => {
174
- const tracerDisabled = !fiber.getFiberRef(FiberRef.currentTracerEnabled) ||
175
- fiber.getFiberRef(RouteHttpTracer.currentTracerDisabledWhen)(request);
176
- const url = new URL(request.url);
177
- const innerEffect = Effect.gen(function* () {
178
- const result = yield* createChain({ request, selectedFormat });
179
- const entity = Entity.isEntity(result) ? result : Entity.make(result, { status: 200 });
180
- if (entity.status === 404 && entity.body === undefined) {
181
- return respondError({ status: 406, message: "not acceptable" });
182
- }
183
- const response = yield* toResponse(entity, selectedFormat, runtime);
184
- if (varyAccept) {
185
- response.headers.set("vary", "Accept");
186
- }
187
- return response;
188
- });
189
- if (tracerDisabled) {
190
- return innerEffect;
191
- }
192
- const spanNameGenerator = fiber.getFiberRef(RouteHttpTracer.currentSpanNameGenerator);
193
- return Effect.useSpan(spanNameGenerator(request), {
194
- parent: Option.getOrUndefined(RouteHttpTracer.parentSpanFromHeaders(request.headers)),
195
- kind: "server",
196
- captureStackTrace: false,
197
- }, (span) => {
198
- span.attribute("http.request.method", request.method);
199
- span.attribute("url.full", url.toString());
200
- span.attribute("url.path", url.pathname);
201
- const query = url.search.slice(1);
202
- if (query !== "") {
203
- span.attribute("url.query", query);
204
- }
205
- span.attribute("url.scheme", url.protocol.slice(0, -1));
206
- const userAgent = request.headers.get("user-agent");
207
- if (userAgent !== null) {
208
- span.attribute("user_agent.original", userAgent);
209
- }
210
- return Effect.flatMap(Effect.exit(Effect.withParentSpan(innerEffect, span)), (exit) => {
211
- if (exit._tag === "Success") {
212
- span.attribute("http.response.status_code", exit.value.status);
213
- }
214
- return exit;
215
- });
216
- });
217
- });
218
- return new Promise((resolve) => {
219
- const fiber = runFork(effect.pipe(Effect.scoped, Effect.catchAllCause((cause) => Effect.gen(function* () {
220
- yield* Effect.logError(cause);
221
- const status = getStatusFromCause(cause);
222
- const message = Cause.pretty(cause, { renderErrorCause: true });
223
- return respondError({ status, message });
224
- }))));
225
- request.signal?.addEventListener("abort", () => {
226
- fiber.unsafeInterruptAsFork(clientAbortFiberId);
227
- }, { once: true });
228
- fiber.addObserver((exit) => {
229
- if (exit._tag === "Success") {
230
- resolve(exit.value);
231
- }
232
- else if (isClientAbort(exit.cause)) {
233
- resolve(respondError({ status: 499, message: "client closed request" }));
234
- }
235
- else {
236
- const status = getStatusFromCause(exit.cause);
237
- const message = Cause.pretty(exit.cause, { renderErrorCause: true });
238
- resolve(respondError({ status, message }));
239
- }
240
- });
241
- });
242
- };
243
- };
244
- };
245
- export const toWebHandler = toWebHandlerRuntime(Runtime.defaultRuntime);
246
- export function* walkHandles(tree, runtime = Runtime.defaultRuntime) {
247
- const pathGroups = new Map();
248
- for (const route of RouteTree.walk(tree)) {
249
- const path = Route.descriptor(route).path;
250
- const group = pathGroups.get(path) ?? [];
251
- group.push(route);
252
- pathGroups.set(path, group);
253
- }
254
- const toHandler = toWebHandlerRuntime(runtime);
255
- for (const [path, routes] of pathGroups) {
256
- yield [path, toHandler(routes)];
257
- }
258
- }
@@ -1,10 +0,0 @@
1
- import * as Effect from "effect/Effect";
2
- import * as FiberRef from "effect/FiberRef";
3
- import * as Option from "effect/Option";
4
- import type * as Predicate from "effect/Predicate";
5
- import * as Tracer from "effect/Tracer";
6
- export declare const currentTracerDisabledWhen: FiberRef.FiberRef<Predicate.Predicate<Request>>;
7
- export declare const withTracerDisabledWhen: <A, E, R>(effect: Effect.Effect<A, E, R>, predicate: Predicate.Predicate<Request>) => Effect.Effect<A, E, R>;
8
- export declare const currentSpanNameGenerator: FiberRef.FiberRef<(request: Request) => string>;
9
- export declare const withSpanNameGenerator: <A, E, R>(effect: Effect.Effect<A, E, R>, f: (request: Request) => string) => Effect.Effect<A, E, R>;
10
- export declare const parentSpanFromHeaders: (headers: Headers) => Option.Option<Tracer.ExternalSpan>;
@@ -1,62 +0,0 @@
1
- import * as Effect from "effect/Effect";
2
- import * as FiberRef from "effect/FiberRef";
3
- import * as GlobalValue from "effect/GlobalValue";
4
- import * as Option from "effect/Option";
5
- import * as Tracer from "effect/Tracer";
6
- export const currentTracerDisabledWhen = GlobalValue.globalValue(Symbol.for("effect-start/RouteHttp/tracerDisabledWhen"), () => FiberRef.unsafeMake(() => false));
7
- export const withTracerDisabledWhen = (effect, predicate) => Effect.locally(effect, currentTracerDisabledWhen, predicate);
8
- export const currentSpanNameGenerator = GlobalValue.globalValue(Symbol.for("effect-start/RouteHttp/spanNameGenerator"), () => FiberRef.unsafeMake((request) => `http.server ${request.method}`));
9
- export const withSpanNameGenerator = (effect, f) => Effect.locally(effect, currentSpanNameGenerator, f);
10
- const w3cTraceparent = (headers) => {
11
- const header = headers.get("traceparent");
12
- if (header === null)
13
- return Option.none();
14
- const parts = header.split("-");
15
- if (parts.length < 4)
16
- return Option.none();
17
- const [_version, traceId, spanId, flags] = parts;
18
- if (!traceId || !spanId)
19
- return Option.none();
20
- return Option.some(Tracer.externalSpan({
21
- spanId,
22
- traceId,
23
- sampled: flags === "01",
24
- }));
25
- };
26
- const b3Single = (headers) => {
27
- const header = headers.get("b3");
28
- if (header === null)
29
- return Option.none();
30
- const parts = header.split("-");
31
- if (parts.length < 2)
32
- return Option.none();
33
- const [traceId, spanId, sampledStr] = parts;
34
- if (!traceId || !spanId)
35
- return Option.none();
36
- return Option.some(Tracer.externalSpan({
37
- spanId,
38
- traceId,
39
- sampled: sampledStr === "1",
40
- }));
41
- };
42
- const xb3 = (headers) => {
43
- const traceId = headers.get("x-b3-traceid");
44
- const spanId = headers.get("x-b3-spanid");
45
- if (traceId === null || spanId === null)
46
- return Option.none();
47
- const sampled = headers.get("x-b3-sampled");
48
- return Option.some(Tracer.externalSpan({
49
- spanId,
50
- traceId,
51
- sampled: sampled === "1",
52
- }));
53
- };
54
- export const parentSpanFromHeaders = (headers) => {
55
- let span = w3cTraceparent(headers);
56
- if (span._tag === "Some")
57
- return span;
58
- span = b3Single(headers);
59
- if (span._tag === "Some")
60
- return span;
61
- return xb3(headers);
62
- };
@@ -1,86 +0,0 @@
1
- import type * as Types from "effect/Types";
2
- import type * as Http from "./Http.ts";
3
- import type * as PathPattern from "./PathPattern.ts";
4
- import * as Route from "./Route.ts";
5
- import type * as RouteBody from "./RouteBody.ts";
6
- type Module = typeof import("./RouteMount.ts");
7
- export type Self = RouteMount.Builder | Module;
8
- export declare const use: RouteMount.Describer<"*">;
9
- export declare const get: RouteMount.Describer<"GET">;
10
- export declare const post: RouteMount.Describer<"POST">;
11
- export declare const put: RouteMount.Describer<"PUT">;
12
- export declare const del: RouteMount.Describer<"DELETE">;
13
- export declare const patch: RouteMount.Describer<"PATCH">;
14
- export declare const head: RouteMount.Describer<"HEAD">;
15
- export declare const options: RouteMount.Describer<"OPTIONS">;
16
- export declare const add: RouteMount.Add;
17
- export type MountedRoute = Route.Route.Route<{
18
- method: RouteMount.Method;
19
- path: PathPattern.PathPattern;
20
- format?: RouteBody.Format;
21
- }, {}, any, any, any>;
22
- export declare namespace RouteMount {
23
- export type Method = "*" | Http.Method;
24
- export type MountSet = Route.RouteSet.RouteSet<{
25
- method: Method;
26
- }, {}, Route.Route.Tuple>;
27
- export interface Builder<D extends {} = {}, I extends Route.Route.Tuple = []> extends Route.RouteSet.RouteSet<D, {}, I>, Module {
28
- }
29
- export type EmptySet<M extends Method, B = {}> = Route.RouteSet.RouteSet<{
30
- method: M;
31
- }, B, []>;
32
- export type Items<S> = S extends Builder<any, infer I> ? I : [];
33
- export type BuilderBindings<S> = S extends Builder<any, infer I> ? Types.Simplify<WildcardBindings<I>> & {
34
- request: Request;
35
- } : {
36
- request: Request;
37
- };
38
- type WildcardBindingsItem<T> = T extends Route.Route.Route<{
39
- method: "*";
40
- }, infer B, any, any, any> ? B : {};
41
- type UnionToIntersection<U> = (U extends any ? (k: U) => void : never) extends (k: infer I) => void ? I : never;
42
- export type WildcardBindings<I extends Route.Route.Tuple> = UnionToIntersection<{
43
- [K in keyof I]: WildcardBindingsItem<I[K]>;
44
- }[number]>;
45
- type PrefixPathItem<Prefix extends string, T> = T extends Route.Route.Route<infer D, infer B, infer A, infer E, infer R> ? D extends {
46
- path: infer P extends string;
47
- } ? Route.Route.Route<Omit<D, "path"> & {
48
- path: `${Prefix}${P}`;
49
- }, B, A, E, R> : Route.Route.Route<D & {
50
- path: Prefix;
51
- }, B, A, E, R> : T;
52
- export type PrefixPath<Prefix extends string, I extends Route.Route.Tuple> = {
53
- [K in keyof I]: PrefixPathItem<Prefix, I[K]>;
54
- } extends infer R extends Route.Route.Tuple ? R : never;
55
- export interface Add {
56
- <S extends Self, P extends string, R extends Route.RouteSet.Any>(this: S, path: P, routes: R): Builder<{}, [...Items<S>, ...PrefixPath<P, Route.RouteSet.Items<R>>]>;
57
- <S extends Self, P extends string, R extends Route.RouteSet.Any>(this: S, path: P,
58
- /**
59
- * Callback form provides a builder seeded with higher-level bindings so
60
- * nested routes can type-infer outer context when mounting.
61
- */
62
- routes: (self: Builder<{}, []>) => R): Builder<{}, [...Items<S>, ...PrefixPath<P, Route.RouteSet.Items<R>>]>;
63
- }
64
- export type FlattenItems<M extends Method, B, I extends Route.Route.Tuple> = I extends [
65
- Route.Route.Route<infer D, infer RB, infer A, infer E, infer R>,
66
- ...infer Tail extends Route.Route.Tuple
67
- ] ? [
68
- Route.Route.Route<Types.Simplify<{
69
- method: M;
70
- } & D> & {}, Types.Simplify<Omit<B & RB, "request">>, A, E, R>,
71
- ...FlattenItems<M, Types.Simplify<B & RB>, Tail>
72
- ] : [];
73
- export interface Describer<M extends Method> {
74
- <S extends Self, A extends Route.RouteSet.Any>(this: S, ab: (a: EmptySet<M, BuilderBindings<S>>) => A): Builder<{}, [...Items<S>, ...FlattenItems<M, BuilderBindings<S>, Route.RouteSet.Items<A>>]>;
75
- <S extends Self, A extends Route.RouteSet.Any, B extends Route.RouteSet.Any>(this: S, ab: (a: EmptySet<M, BuilderBindings<S>>) => A, bc: (b: A) => B): Builder<{}, [...Items<S>, ...FlattenItems<M, BuilderBindings<S>, Route.RouteSet.Items<B>>]>;
76
- <S extends Self, A extends Route.RouteSet.Any, B extends Route.RouteSet.Any, C extends Route.RouteSet.Any>(this: S, ab: (a: EmptySet<M, BuilderBindings<S>>) => A, bc: (b: A) => B, cd: (c: B) => C): Builder<{}, [...Items<S>, ...FlattenItems<M, BuilderBindings<S>, Route.RouteSet.Items<C>>]>;
77
- <S extends Self, A extends Route.RouteSet.Any, B extends Route.RouteSet.Any, C extends Route.RouteSet.Any, D extends Route.RouteSet.Any>(this: S, ab: (a: EmptySet<M, BuilderBindings<S>>) => A, bc: (b: A) => B, cd: (c: B) => C, de: (d: C) => D): Builder<{}, [...Items<S>, ...FlattenItems<M, BuilderBindings<S>, Route.RouteSet.Items<D>>]>;
78
- <S extends Self, A extends Route.RouteSet.Any, B extends Route.RouteSet.Any, C extends Route.RouteSet.Any, D extends Route.RouteSet.Any, E extends Route.RouteSet.Any>(this: S, ab: (a: EmptySet<M, BuilderBindings<S>>) => A, bc: (b: A) => B, cd: (c: B) => C, de: (d: C) => D, ef: (e: D) => E): Builder<{}, [...Items<S>, ...FlattenItems<M, BuilderBindings<S>, Route.RouteSet.Items<E>>]>;
79
- <S extends Self, A extends Route.RouteSet.Any, B extends Route.RouteSet.Any, C extends Route.RouteSet.Any, D extends Route.RouteSet.Any, E extends Route.RouteSet.Any, F extends Route.RouteSet.Any>(this: S, ab: (a: EmptySet<M, BuilderBindings<S>>) => A, bc: (b: A) => B, cd: (c: B) => C, de: (d: C) => D, ef: (e: D) => E, fg: (f: E) => F): Builder<{}, [...Items<S>, ...FlattenItems<M, BuilderBindings<S>, Route.RouteSet.Items<F>>]>;
80
- <S extends Self, A extends Route.RouteSet.Any, B extends Route.RouteSet.Any, C extends Route.RouteSet.Any, D extends Route.RouteSet.Any, E extends Route.RouteSet.Any, F extends Route.RouteSet.Any, G extends Route.RouteSet.Any>(this: S, ab: (a: EmptySet<M, BuilderBindings<S>>) => A, bc: (b: A) => B, cd: (c: B) => C, de: (d: C) => D, ef: (e: D) => E, fg: (f: E) => F, gh: (g: F) => G): Builder<{}, [...Items<S>, ...FlattenItems<M, BuilderBindings<S>, Route.RouteSet.Items<G>>]>;
81
- <S extends Self, A extends Route.RouteSet.Any, B extends Route.RouteSet.Any, C extends Route.RouteSet.Any, D extends Route.RouteSet.Any, E extends Route.RouteSet.Any, F extends Route.RouteSet.Any, G extends Route.RouteSet.Any, H extends Route.RouteSet.Any>(this: S, ab: (a: EmptySet<M, BuilderBindings<S>>) => A, bc: (b: A) => B, cd: (c: B) => C, de: (d: C) => D, ef: (e: D) => E, fg: (f: E) => F, gh: (g: F) => G, hi: (h: G) => H): Builder<{}, [...Items<S>, ...FlattenItems<M, BuilderBindings<S>, Route.RouteSet.Items<H>>]>;
82
- <S extends Self, A extends Route.RouteSet.Any, B extends Route.RouteSet.Any, C extends Route.RouteSet.Any, D extends Route.RouteSet.Any, E extends Route.RouteSet.Any, F extends Route.RouteSet.Any, G extends Route.RouteSet.Any, H extends Route.RouteSet.Any, I extends Route.RouteSet.Any>(this: S, ab: (a: EmptySet<M, BuilderBindings<S>>) => A, bc: (b: A) => B, cd: (c: B) => C, de: (d: C) => D, ef: (e: D) => E, fg: (f: E) => F, gh: (g: F) => G, hi: (h: G) => H, ij: (i: H) => I): Builder<{}, [...Items<S>, ...FlattenItems<M, BuilderBindings<S>, Route.RouteSet.Items<I>>]>;
83
- }
84
- export {};
85
- }
86
- export {};
@@ -1,63 +0,0 @@
1
- import * as Function from "effect/Function";
2
- import * as Route from "./Route.js";
3
- const RouteSetTypeId = Symbol.for("effect-start/RouteSet");
4
- export const use = makeMethodDescriber("*");
5
- export const get = makeMethodDescriber("GET");
6
- export const post = makeMethodDescriber("POST");
7
- export const put = makeMethodDescriber("PUT");
8
- export const del = makeMethodDescriber("DELETE");
9
- export const patch = makeMethodDescriber("PATCH");
10
- export const head = makeMethodDescriber("HEAD");
11
- export const options = makeMethodDescriber("OPTIONS");
12
- export const add = function (path, routes) {
13
- const baseItems = Route.isRouteSet(this) ? Route.items(this) : [];
14
- const routeSet = typeof routes === "function" ? routes(make([])) : routes;
15
- const routeItems = Route.items(routeSet);
16
- const newItems = routeItems.map((item) => {
17
- const itemDescriptor = Route.descriptor(item);
18
- const concatenatedPath = typeof itemDescriptor?.path === "string" ? path + itemDescriptor.path : path;
19
- const newDescriptor = { ...itemDescriptor, path: concatenatedPath };
20
- return Route.isRoute(item)
21
- ? Route.make(item.handler, newDescriptor)
22
- : Route.set(Route.items(item), newDescriptor);
23
- });
24
- return make([...baseItems, ...newItems]);
25
- };
26
- const Proto = Object.assign(Object.create(null), {
27
- [RouteSetTypeId]: RouteSetTypeId,
28
- *[Symbol.iterator]() {
29
- yield* Route.items(this);
30
- },
31
- use,
32
- get,
33
- post,
34
- put,
35
- del,
36
- patch,
37
- head,
38
- options,
39
- add,
40
- });
41
- function make(items) {
42
- return Object.assign(Object.create(Proto), {
43
- [Route.RouteItems]: items,
44
- [Route.RouteDescriptor]: {},
45
- });
46
- }
47
- function makeMethodDescriber(method) {
48
- function describeMethod(...fs) {
49
- const baseItems = Route.isRouteSet(this) ? Route.items(this) : [];
50
- const methodSet = Route.set([], { method });
51
- const f = Function.flow(...fs);
52
- const result = f(methodSet);
53
- const resultItems = Route.items(result);
54
- // Items are already flat (only Routes), just merge method into each descriptor
55
- const flattenedItems = resultItems.map((item) => {
56
- const itemDescriptor = Route.descriptor(item);
57
- const newDescriptor = { method, ...itemDescriptor };
58
- return Route.make(item.handler, newDescriptor);
59
- });
60
- return make([...baseItems, ...flattenedItems]);
61
- }
62
- return describeMethod;
63
- }
@@ -1,86 +0,0 @@
1
- import type * as ParseResult from "effect/ParseResult";
2
- import * as Schema from "effect/Schema";
3
- import type * as Scope from "effect/Scope";
4
- import * as Http from "./Http.ts";
5
- import * as Route from "./Route.ts";
6
- export interface RequestBodyError {
7
- readonly _tag: "RequestBodyError";
8
- readonly reason: "JsonError" | "UrlParamsError" | "MultipartError" | "FormDataError";
9
- readonly cause: unknown;
10
- }
11
- export declare const RequestBodyError: (reason: RequestBodyError["reason"], cause: unknown) => RequestBodyError;
12
- export declare const File: Schema.TaggedStruct<"File", {
13
- key: typeof Schema.String;
14
- name: typeof Schema.String;
15
- contentType: typeof Schema.String;
16
- content: typeof Schema.Uint8ArrayFromSelf;
17
- }>;
18
- export declare function schemaHeaders<A, I extends Readonly<Record<string, string | undefined>>, R>(fields: Schema.Schema<A, I, R>): <D extends Route.RouteDescriptor.Any, SB extends {}, P extends Route.Route.Tuple>(self: Route.RouteSet.RouteSet<D, SB, P>) => Route.RouteSet.RouteSet<D, SB, [
19
- ...P,
20
- Route.Route.Route<{}, {
21
- headers: A;
22
- }, unknown, ParseResult.ParseError, R>
23
- ]>;
24
- export declare function schemaCookies<A, I extends Readonly<Record<string, string | undefined>>, R>(fields: Schema.Schema<A, I, R>): <D extends Route.RouteDescriptor.Any, SB extends {}, P extends Route.Route.Tuple>(self: Route.RouteSet.RouteSet<D, SB, P>) => Route.RouteSet.RouteSet<D, SB, [
25
- ...P,
26
- Route.Route.Route<{}, {
27
- cookies: A;
28
- }, unknown, ParseResult.ParseError, R>
29
- ]>;
30
- export declare function schemaSearchParams<A, I extends Readonly<Record<string, string | ReadonlyArray<string> | undefined>>, R>(fields: Schema.Schema<A, I, R>): <D extends Route.RouteDescriptor.Any, SB extends {}, P extends Route.Route.Tuple>(self: Route.RouteSet.RouteSet<D, SB, P>) => Route.RouteSet.RouteSet<D, SB, [
31
- ...P,
32
- Route.Route.Route<{}, {
33
- searchParams: A;
34
- }, unknown, ParseResult.ParseError, R>
35
- ]>;
36
- export declare function schemaPathParams<A, I extends Readonly<Record<string, string | undefined>>, R>(fields: Schema.Schema<A, I, R>): <D extends Route.RouteDescriptor.Any, SB extends {}, P extends Route.Route.Tuple>(self: Route.RouteSet.RouteSet<D, SB, P>) => Route.RouteSet.RouteSet<D, SB, [
37
- ...P,
38
- Route.Route.Route<{}, {
39
- pathParams: A;
40
- }, unknown, ParseResult.ParseError, R>
41
- ]>;
42
- export declare function schemaBodyJson<A, I, R>(fields: Schema.Schema<A, I, R>): <D extends Route.RouteDescriptor.Any, SB extends {}, P extends Route.Route.Tuple>(self: Route.RouteSet.RouteSet<D, SB, P>) => Route.RouteSet.RouteSet<D, SB, [
43
- ...P,
44
- Route.Route.Route<{}, {
45
- body: A;
46
- }, unknown, RequestBodyError | ParseResult.ParseError, R>
47
- ]>;
48
- export declare function schemaBodyUrlParams<A, I extends Readonly<Record<string, string | ReadonlyArray<string> | undefined>>, R>(fields: Schema.Schema<A, I, R>): <D extends Route.RouteDescriptor.Any, SB extends {}, P extends Route.Route.Tuple>(self: Route.RouteSet.RouteSet<D, SB, P>) => Route.RouteSet.RouteSet<D, SB, [
49
- ...P,
50
- Route.Route.Route<{}, {
51
- body: A;
52
- }, unknown, RequestBodyError | ParseResult.ParseError, R>
53
- ]>;
54
- export declare function schemaBodyMultipart<A, I extends Partial<Record<string, ReadonlyArray<Http.FilePart> | ReadonlyArray<string> | string>>, R>(fields: Schema.Schema<A, I, R>): <D extends Route.RouteDescriptor.Any, SB extends {}, P extends Route.Route.Tuple>(self: Route.RouteSet.RouteSet<D, SB, P>) => Route.RouteSet.RouteSet<D, SB, [
55
- ...P,
56
- Route.Route.Route<{}, {
57
- body: A;
58
- }, unknown, RequestBodyError | ParseResult.ParseError, R | Scope.Scope>
59
- ]>;
60
- export declare function schemaBodyForm<A, I extends Partial<Record<string, ReadonlyArray<Http.FilePart> | ReadonlyArray<string> | string>>, R>(fields: Schema.Schema<A, I, R>): <D extends Route.RouteDescriptor.Any, SB extends {}, P extends Route.Route.Tuple>(self: Route.RouteSet.RouteSet<D, SB, P>) => Route.RouteSet.RouteSet<D, SB, [
61
- ...P,
62
- Route.Route.Route<{}, {
63
- body: A;
64
- }, unknown, RequestBodyError | ParseResult.ParseError, R | Scope.Scope>
65
- ]>;
66
- /**
67
- * Intercepts typed errors from downstream handlers, encodes them through the
68
- * schema, and returns a JSON response with the given status code.
69
- *
70
- * Without `schemaError`, handler errors fall through to global catch during
71
- * execution of request. `schemaError` short circuts error handling by
72
- * return an error response immedietly.
73
- *
74
- * TODO: store the errors in runtime to enable generating OpenAPI and other
75
- * goodies.
76
- */
77
- export declare function schemaError<A, I, R>(schema: Schema.Schema<A, I, R> & {
78
- readonly status: number;
79
- }): <D extends Route.RouteDescriptor.Any, SB extends {}, P extends Route.Route.Tuple>(self: Route.RouteSet.RouteSet<D, SB, P>) => Route.RouteSet.RouteSet<D, SB, [...P, Route.Route.Route<{}, {}, unknown, never, R>]>;
80
- export declare function schemaError<A, I, R>(schema: Schema.Schema<A, I, R>, options: {
81
- readonly status: number;
82
- }): <D extends Route.RouteDescriptor.Any, SB extends {}, P extends Route.Route.Tuple>(self: Route.RouteSet.RouteSet<D, SB, P>) => Route.RouteSet.RouteSet<D, SB, [...P, Route.Route.Route<{}, {}, unknown, never, R>]>;
83
- export declare function schemaSuccess<A, I, R>(schema: Schema.Schema<A, I, R>): <D extends Route.RouteDescriptor.Any, SB extends {}, P extends Route.Route.Tuple>(self: Route.RouteSet.RouteSet<D, SB, P>) => Route.RouteSet.RouteSet<D, SB, [
84
- ...P,
85
- Route.Route.Route<{}, {}, I, ParseResult.ParseError, R>
86
- ]>;