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
@@ -1,46 +0,0 @@
1
- import * as Cause from "effect/Cause";
2
- import * as Effect from "effect/Effect";
3
- import * as Exit from "effect/Exit";
4
- import * as FiberRef from "effect/FiberRef";
5
- import * as FiberRefs from "effect/FiberRefs";
6
- import * as Function from "effect/Function";
7
- import * as HashSet from "effect/HashSet";
8
- import * as Logger from "effect/Logger";
9
- export const defaultTeardown = (exit, onExit) => {
10
- onExit(Exit.isFailure(exit) && !Cause.isInterruptedOnly(exit.cause) ? 1 : 0);
11
- };
12
- const addPrettyLogger = (refs, fiberId) => {
13
- const loggers = FiberRefs.getOrDefault(refs, FiberRef.currentLoggers);
14
- if (!HashSet.has(loggers, Logger.defaultLogger)) {
15
- return refs;
16
- }
17
- return FiberRefs.updateAs(refs, {
18
- fiberId,
19
- fiberRef: FiberRef.currentLoggers,
20
- value: loggers.pipe(HashSet.remove(Logger.defaultLogger), HashSet.add(Logger.prettyLoggerDefault)),
21
- });
22
- };
23
- export const makeRunMain = (f) => Function.dual((args) => Effect.isEffect(args[0]), (effect, options) => {
24
- const fiber = options?.disableErrorReporting === true
25
- ? Effect.runFork(effect, {
26
- updateRefs: options?.disablePrettyLogger === true ? undefined : addPrettyLogger,
27
- })
28
- : Effect.runFork(Effect.tapErrorCause(effect, (cause) => {
29
- if (Cause.isInterruptedOnly(cause)) {
30
- return Effect.void;
31
- }
32
- return Effect.logError(cause);
33
- }), {
34
- updateRefs: options?.disablePrettyLogger === true ? undefined : addPrettyLogger,
35
- });
36
- const teardown = options?.teardown ?? defaultTeardown;
37
- return f({ fiber, teardown });
38
- });
39
- /**
40
- * Are we running within an agent harness, like Claude Code?
41
- */
42
- export function isAgentHarness() {
43
- return (typeof process !== "undefined" &&
44
- !process.stdout.isTTY &&
45
- (process.env.CLAUDECODE || process.env.CURSOR_AGENT));
46
- }
package/dist/Route.d.ts DELETED
@@ -1,97 +0,0 @@
1
- import * as Context from "effect/Context";
2
- import * as Effect from "effect/Effect";
3
- import * as Layer from "effect/Layer";
4
- import * as Pipeable from "effect/Pipeable";
5
- import * as Entity from "./Entity.ts";
6
- import * as RouteBody from "./RouteBody.ts";
7
- import * as RouteTree from "./RouteTree.ts";
8
- import type * as Values from "./Values.ts";
9
- export declare const RouteItems: unique symbol;
10
- export declare const RouteDescriptor: unique symbol;
11
- export declare const RouteBindings: unique symbol;
12
- export declare const TypeId: unique symbol;
13
- export declare namespace RouteDescriptor {
14
- type Any = {
15
- [key: string]: unknown;
16
- };
17
- }
18
- export declare namespace RouteSet {
19
- type RouteSet<D extends RouteDescriptor.Any = {}, B = {}, M extends Route.Tuple = []> = Data<D, B, M> & {
20
- [TypeId]: typeof TypeId;
21
- } & Pipeable.Pipeable & Iterable<M[number]>;
22
- type Data<D extends RouteDescriptor.Any = {}, B = {}, M extends Route.Tuple = []> = {
23
- [RouteItems]: M;
24
- [RouteDescriptor]: D;
25
- [RouteBindings]: B;
26
- };
27
- type Proto = Pipeable.Pipeable & Iterable<Route.Route<any, any, any, any, any>> & {
28
- [TypeId]: typeof TypeId;
29
- };
30
- type Any = RouteSet<{}, {}, Route.Tuple>;
31
- type Infer<R> = R extends RouteSet<infer D, infer B, infer I> ? RouteSet<D, B, I> : R;
32
- type Items<T extends Data<any, any, any>> = T extends Data<any, any, infer M> ? M : never;
33
- type Descriptor<T extends Data<any, any, any>> = T extends Data<infer D, any, any> ? D : never;
34
- }
35
- export declare namespace Route {
36
- export interface Route<D extends RouteDescriptor.Any = {}, B = {}, A = any, E = never, R = never> extends RouteSet.RouteSet<D, {}, [Route<D, B, A, E, R>]> {
37
- readonly handler: Handler<B & D, A, E, R>;
38
- }
39
- export type With<D extends RouteDescriptor.Any> = Route<any, any, any, any, any> & {
40
- [RouteDescriptor]: D;
41
- };
42
- export type Tuple<_D extends RouteDescriptor.Any = {}> = [...Route<any, any, any, any, any>[]];
43
- export type Handler<B, A, E, R> = (context: B, next: (context?: Partial<B> & Record<string, unknown>) => Entity.Entity<A>) => Effect.Effect<Entity.Entity<A>, E, R>;
44
- /**
45
- * Extracts only the bindings (B) from routes, excluding descriptors.
46
- */
47
- export type Bindings<T extends RouteSet.Any, M extends Tuple = RouteSet.Items<T>> = M extends [
48
- infer Head,
49
- ...infer Tail extends Tuple
50
- ] ? Head extends Route<any, infer B, any, any, any> ? ShallowMerge<B, Bindings<T, Tail>> : Bindings<T, Tail> : {};
51
- /**
52
- * Extracts the full handler context from a RouteSet.
53
- * Merges descriptors and bindings from all routes, with later values
54
- * taking precedence via ShallowMerge to avoid `never` from conflicting
55
- * literal types (e.g. `{ method: "*" } & { method: "GET" }`).
56
- */
57
- export type Context<T extends RouteSet.Any> = Omit<RouteSet.Descriptor<T>, keyof ExtractContext<RouteSet.Items<T>>> & ExtractContext<RouteSet.Items<T>>;
58
- type ExtractContext<M extends Tuple> = M extends [infer Head, ...infer Tail extends Tuple] ? Head extends Route<infer D, infer B, any, any, any> ? ShallowMerge<Omit<D, keyof B> & B, ExtractContext<Tail>> : ExtractContext<Tail> : {};
59
- export {};
60
- }
61
- export declare function isRouteSet(input: unknown): input is RouteSet.Any;
62
- export declare function isRoute(input: unknown): input is Route.Route;
63
- export declare function set<D extends RouteDescriptor.Any = {}, B = {}, I extends Route.Tuple = []>(items?: I, descriptor?: D): RouteSet.RouteSet<D, B, I>;
64
- export declare function make<D extends RouteDescriptor.Any, B, A, E = never, R = never>(handler: Route.Handler<B & D, A, E, R>, descriptor?: D): Route.Route<D, B, A, E, R>;
65
- export declare const empty: RouteSet.RouteSet<{}, {}, []>;
66
- export declare function describe<D extends RouteDescriptor.Any>(descriptor: D): RouteSet.RouteSet<D, {}, never[]>;
67
- export declare function items<T extends RouteSet.Data<any, any, any>>(self: T): RouteSet.Items<T>;
68
- export declare function descriptor<T extends RouteSet.Data<any, any, any>>(self: T): T[typeof RouteDescriptor];
69
- export declare function descriptor<T extends RouteSet.Data<any, any, any>>(self: Iterable<T>): Array<T[typeof RouteDescriptor]>;
70
- export type ExtractBindings<M extends Route.Tuple> = M extends [
71
- infer Head,
72
- ...infer Tail extends Route.Tuple
73
- ] ? Head extends Route.Route<any, infer B, any, any, any> ? ShallowMerge<B, ExtractBindings<Tail>> : ExtractBindings<Tail> : {};
74
- type ShallowMerge<A, B> = Omit<A, keyof B> & {
75
- [K in keyof B]: K extends keyof A ? A[K] & B[K] : B[K];
76
- };
77
- export type ExtractContext<Items extends Route.Tuple, Descriptor extends RouteDescriptor.Any> = ExtractBindings<Items> & Descriptor;
78
- export * from "./RouteHook.ts";
79
- export * from "./RouteSchema.ts";
80
- export { add, del, get, head, options, patch, post, put, use } from "./RouteMount.ts";
81
- export declare const text: RouteBody.BuildReturn<string, "text">;
82
- export declare const html: RouteBody.BuildReturn<string, "html">;
83
- export declare const json: RouteBody.BuildReturn<Values.Json, "json">;
84
- export declare const bytes: RouteBody.BuildReturn<Uint8Array<ArrayBufferLike>, "bytes">;
85
- export { render } from "./RouteBody.ts";
86
- export { sse } from "./RouteSse.ts";
87
- export declare function redirect(url: string | URL, options?: {
88
- status?: 301 | 302 | 303 | 307 | 308;
89
- }): Entity.Entity<"">;
90
- declare const Routes_base: Context.TagClass<Routes, "effect-start/Routes", RouteTree.RouteTree<RouteTree.RouteMap>>;
91
- export declare class Routes extends Routes_base {
92
- }
93
- export declare function layer(routes: RouteTree.RouteMap | RouteTree.RouteTree): Layer.Layer<Routes, never, never>;
94
- export { make as tree } from "./RouteTree.ts";
95
- export declare function lazy<T extends RouteSet.Any>(load: () => Promise<{
96
- default: T;
97
- }>): Effect.Effect<T, never, never>;
package/dist/Route.js DELETED
@@ -1,100 +0,0 @@
1
- import * as Context from "effect/Context";
2
- import * as Effect from "effect/Effect";
3
- import * as Layer from "effect/Layer";
4
- import * as Pipeable from "effect/Pipeable";
5
- import * as Predicate from "effect/Predicate";
6
- import * as Entity from "./Entity.js";
7
- import * as RouteBody from "./RouteBody.js";
8
- import * as RouteTree from "./RouteTree.js";
9
- export const RouteItems = Symbol();
10
- export const RouteDescriptor = Symbol();
11
- // only for structural type matching
12
- export const RouteBindings = Symbol();
13
- export const TypeId = Symbol.for("effect-start/RouteSet");
14
- const Proto = {
15
- [TypeId]: TypeId,
16
- pipe() {
17
- return Pipeable.pipeArguments(this, arguments);
18
- },
19
- *[Symbol.iterator]() {
20
- yield* items(this);
21
- },
22
- };
23
- export function isRouteSet(input) {
24
- return Predicate.hasProperty(input, TypeId);
25
- }
26
- export function isRoute(input) {
27
- return isRouteSet(input) && Predicate.hasProperty(input, "handler");
28
- }
29
- export function set(items = [], descriptor = {}) {
30
- return Object.assign(Object.create(Proto), {
31
- [RouteItems]: items,
32
- [RouteDescriptor]: descriptor,
33
- });
34
- }
35
- export function make(handler, descriptor) {
36
- const items = [];
37
- const route = Object.assign(Object.create(Proto), {
38
- [RouteItems]: items,
39
- [RouteDescriptor]: descriptor,
40
- handler,
41
- });
42
- items.push(route);
43
- return route;
44
- }
45
- export const empty = set();
46
- export function describe(descriptor) {
47
- return set([], descriptor);
48
- }
49
- export function items(self) {
50
- return self[RouteItems];
51
- }
52
- export function descriptor(self) {
53
- if (RouteDescriptor in self) {
54
- return self[RouteDescriptor];
55
- }
56
- return [...self].map((r) => r[RouteDescriptor]);
57
- }
58
- export * from "./RouteHook.js";
59
- export * from "./RouteSchema.js";
60
- export { add, del, get, head, options, patch, post, put, use } from "./RouteMount.js";
61
- export const text = RouteBody.build({
62
- format: "text",
63
- });
64
- export const html = RouteBody.build({
65
- format: "html",
66
- });
67
- export const json = RouteBody.build({
68
- format: "json",
69
- });
70
- export const bytes = RouteBody.build({
71
- format: "bytes",
72
- });
73
- export { render } from "./RouteBody.js";
74
- export { sse } from "./RouteSse.js";
75
- export function redirect(url, options) {
76
- return Entity.make("", {
77
- status: options?.status ?? 302,
78
- headers: {
79
- location: url instanceof URL ? url.href : url,
80
- },
81
- });
82
- }
83
- export class Routes extends Context.Tag("effect-start/Routes")() {
84
- }
85
- export function layer(routes) {
86
- return Layer.sync(Routes, () => (RouteTree.isRouteTree(routes) ? routes : RouteTree.make(routes)));
87
- }
88
- export { make as tree } from "./RouteTree.js";
89
- export function lazy(load) {
90
- let cached;
91
- return Effect.suspend(() => {
92
- if (cached !== undefined) {
93
- return Effect.succeed(cached);
94
- }
95
- return Effect.promise(load).pipe(Effect.map((mod) => {
96
- cached = mod.default;
97
- return cached;
98
- }));
99
- });
100
- }
@@ -1,47 +0,0 @@
1
- import * as Effect from "effect/Effect";
2
- import type * as Stream from "effect/Stream";
3
- import type * as Utils from "effect/Utils";
4
- import * as Entity from "./Entity.ts";
5
- import * as Route from "./Route.ts";
6
- import type * as Values from "./Values.ts";
7
- export type Format = "text" | "html" | "json" | "bytes" | "*";
8
- type UnwrapStream<T> = T extends Stream.Stream<infer V, any, any> ? V : T;
9
- type YieldError<T> = T extends Utils.YieldWrap<Effect.Effect<any, infer E, any>> ? E : never;
10
- type YieldContext<T> = T extends Utils.YieldWrap<Effect.Effect<any, any, infer R>> ? R : never;
11
- export type GeneratorHandler<B, A, Y> = (context: Values.Simplify<B>, next: (context?: Partial<B> & Record<string, unknown>) => Entity.Entity<UnwrapStream<A>>) => Generator<Y, A | Entity.Entity<A>, never>;
12
- export type HandlerInput<B, A, E, R> = A | Entity.Entity<A> | Effect.Effect<A | Entity.Entity<A>, E, R> | ((context: Values.Simplify<B>, next: (context?: Partial<B> & Record<string, unknown>) => Entity.Entity<UnwrapStream<A>>) => Effect.Effect<A | Entity.Entity<A>, E, R> | Generator<Utils.YieldWrap<Effect.Effect<unknown, E, R>>, A | Entity.Entity<A>, unknown>);
13
- export declare function handle<B, A, Y extends Utils.YieldWrap<Effect.Effect<any, any, any>>>(handler: GeneratorHandler<B, A, Y>): Route.Route.Handler<B, A, YieldError<Y>, YieldContext<Y>>;
14
- export declare function handle<B, A, E, R>(handler: HandlerInput<B, A, E, R>): Route.Route.Handler<B, A, E, R>;
15
- export interface BuildReturn<Value, F extends Format> {
16
- <D extends Route.RouteDescriptor.Any, B, I extends Route.Route.Tuple, A extends F extends "json" ? Value : Value | Stream.Stream<Value, any, any>, Y extends Utils.YieldWrap<Effect.Effect<any, any, any>>>(handler: GeneratorHandler<NoInfer<D & B & Route.ExtractBindings<I> & {
17
- format: F;
18
- }>, A, Y>): (self: Route.RouteSet.RouteSet<D, B, I>) => Route.RouteSet.RouteSet<D, B, [
19
- ...I,
20
- Route.Route.Route<{
21
- format: F;
22
- }, {}, A, YieldError<Y>, YieldContext<Y>>
23
- ]>;
24
- <D extends Route.RouteDescriptor.Any, B, I extends Route.Route.Tuple, A extends F extends "json" ? Value : Value | Stream.Stream<Value, any, any>, E = never, R = never>(handler: HandlerInput<NoInfer<D & B & Route.ExtractBindings<I> & {
25
- format: F;
26
- }>, A, E, R>): (self: Route.RouteSet.RouteSet<D, B, I>) => Route.RouteSet.RouteSet<D, B, [...I, Route.Route.Route<{
27
- format: F;
28
- }, {}, A, E, R>]>;
29
- }
30
- export declare function build<Value, F extends Format>(descriptors: {
31
- format: F;
32
- }): BuildReturn<Value, F>;
33
- export type RenderValue = string | Uint8Array | Stream.Stream<string | Uint8Array, any, any>;
34
- export declare function render<D extends Route.RouteDescriptor.Any, B extends {}, I extends Route.Route.Tuple, A extends RenderValue, Y extends Utils.YieldWrap<Effect.Effect<any, any, any>>>(handler: GeneratorHandler<NoInfer<D & B & Route.ExtractBindings<I> & {
35
- format: "*";
36
- }>, A, Y>): (self: Route.RouteSet.RouteSet<D, B, I>) => Route.RouteSet.RouteSet<D, B, [
37
- ...I,
38
- Route.Route.Route<{
39
- format: "*";
40
- }, {}, A, YieldError<Y>, YieldContext<Y>>
41
- ]>;
42
- export declare function render<D extends Route.RouteDescriptor.Any, B extends {}, I extends Route.Route.Tuple, A extends RenderValue, E = never, R = never>(handler: HandlerInput<NoInfer<D & B & Route.ExtractBindings<I> & {
43
- format: "*";
44
- }>, A, E, R>): (self: Route.RouteSet.RouteSet<D, B, I>) => Route.RouteSet.RouteSet<D, B, [...I, Route.Route.Route<{
45
- format: "*";
46
- }, {}, A, E, R>]>;
47
- export {};
package/dist/RouteBody.js DELETED
@@ -1,67 +0,0 @@
1
- import * as Effect from "effect/Effect";
2
- import * as Entity from "./Entity.js";
3
- import * as Route from "./Route.js";
4
- const formatToContentType = {
5
- text: "text/plain; charset=utf-8",
6
- html: "text/html; charset=utf-8",
7
- json: "application/json",
8
- bytes: "application/octet-stream",
9
- "*": undefined,
10
- };
11
- export function handle(handler) {
12
- if (typeof handler === "function") {
13
- return (context, next) => {
14
- const result = handler(context, next);
15
- const effect = Effect.isEffect(result)
16
- ? result
17
- : Effect.gen(function* () {
18
- return yield* result;
19
- });
20
- return Effect.map(effect, normalizeToEntity);
21
- };
22
- }
23
- if (Effect.isEffect(handler)) {
24
- return (_context, _next) => Effect.map(handler, normalizeToEntity);
25
- }
26
- if (Entity.isEntity(handler)) {
27
- return (_context, _next) => Effect.succeed(handler);
28
- }
29
- return (_context, _next) => Effect.succeed(normalizeToEntity(handler));
30
- }
31
- function normalizeToEntity(value) {
32
- if (Entity.isEntity(value)) {
33
- return value;
34
- }
35
- return Entity.make(value, { status: 200 });
36
- }
37
- export function build(descriptors) {
38
- return function (handler) {
39
- return function (self) {
40
- const contentType = formatToContentType[descriptors.format];
41
- const baseHandler = handle(handler);
42
- const wrappedHandler = (ctx, next) => Effect.map(baseHandler(ctx, next), (entity) => entity.headers["content-type"]
43
- ? entity
44
- : Entity.make(entity.body, {
45
- status: entity.status,
46
- url: entity.url,
47
- headers: { ...entity.headers, "content-type": contentType },
48
- }));
49
- const route = Route.make(wrappedHandler, descriptors);
50
- const items = [
51
- ...Route.items(self),
52
- route,
53
- ];
54
- return Route.set(items, Route.descriptor(self));
55
- };
56
- };
57
- }
58
- export function render(handler) {
59
- return function (self) {
60
- const route = Route.make(handle(handler), { format: "*" });
61
- const items = [
62
- ...Route.items(self),
63
- route,
64
- ];
65
- return Route.set(items, Route.descriptor(self));
66
- };
67
- }
@@ -1,98 +0,0 @@
1
- import * as Schema from "effect/Schema";
2
- declare const BadRequest_base: Schema.TaggedErrorClass<BadRequest, "BadRequest", {
3
- readonly _tag: Schema.tag<"BadRequest">;
4
- } & {
5
- message: typeof Schema.String;
6
- }>;
7
- export declare class BadRequest extends BadRequest_base {
8
- static readonly status = 400;
9
- }
10
- declare const Unauthorized_base: Schema.TaggedErrorClass<Unauthorized, "Unauthorized", {
11
- readonly _tag: Schema.tag<"Unauthorized">;
12
- } & {
13
- message: typeof Schema.String;
14
- }>;
15
- export declare class Unauthorized extends Unauthorized_base {
16
- static readonly status = 401;
17
- }
18
- declare const Forbidden_base: Schema.TaggedErrorClass<Forbidden, "Forbidden", {
19
- readonly _tag: Schema.tag<"Forbidden">;
20
- } & {
21
- message: typeof Schema.String;
22
- }>;
23
- export declare class Forbidden extends Forbidden_base {
24
- static readonly status = 403;
25
- }
26
- declare const NotFound_base: Schema.TaggedErrorClass<NotFound, "NotFound", {
27
- readonly _tag: Schema.tag<"NotFound">;
28
- } & {
29
- message: typeof Schema.String;
30
- }>;
31
- export declare class NotFound extends NotFound_base {
32
- static readonly status = 404;
33
- }
34
- declare const MethodNotAllowed_base: Schema.TaggedErrorClass<MethodNotAllowed, "MethodNotAllowed", {
35
- readonly _tag: Schema.tag<"MethodNotAllowed">;
36
- } & {
37
- message: typeof Schema.String;
38
- }>;
39
- export declare class MethodNotAllowed extends MethodNotAllowed_base {
40
- static readonly status = 405;
41
- }
42
- declare const Conflict_base: Schema.TaggedErrorClass<Conflict, "Conflict", {
43
- readonly _tag: Schema.tag<"Conflict">;
44
- } & {
45
- message: typeof Schema.String;
46
- }>;
47
- export declare class Conflict extends Conflict_base {
48
- static readonly status = 409;
49
- }
50
- declare const Gone_base: Schema.TaggedErrorClass<Gone, "Gone", {
51
- readonly _tag: Schema.tag<"Gone">;
52
- } & {
53
- message: typeof Schema.String;
54
- }>;
55
- export declare class Gone extends Gone_base {
56
- static readonly status = 410;
57
- }
58
- declare const UnprocessableEntity_base: Schema.TaggedErrorClass<UnprocessableEntity, "UnprocessableEntity", {
59
- readonly _tag: Schema.tag<"UnprocessableEntity">;
60
- } & {
61
- message: typeof Schema.String;
62
- }>;
63
- export declare class UnprocessableEntity extends UnprocessableEntity_base {
64
- static readonly status = 422;
65
- }
66
- declare const TooManyRequests_base: Schema.TaggedErrorClass<TooManyRequests, "TooManyRequests", {
67
- readonly _tag: Schema.tag<"TooManyRequests">;
68
- } & {
69
- message: typeof Schema.String;
70
- }>;
71
- export declare class TooManyRequests extends TooManyRequests_base {
72
- static readonly status = 429;
73
- }
74
- declare const InternalServerError_base: Schema.TaggedErrorClass<InternalServerError, "InternalServerError", {
75
- readonly _tag: Schema.tag<"InternalServerError">;
76
- } & {
77
- message: typeof Schema.String;
78
- }>;
79
- export declare class InternalServerError extends InternalServerError_base {
80
- static readonly status = 500;
81
- }
82
- declare const NotImplemented_base: Schema.TaggedErrorClass<NotImplemented, "NotImplemented", {
83
- readonly _tag: Schema.tag<"NotImplemented">;
84
- } & {
85
- message: typeof Schema.String;
86
- }>;
87
- export declare class NotImplemented extends NotImplemented_base {
88
- static readonly status = 501;
89
- }
90
- declare const ServiceUnavailable_base: Schema.TaggedErrorClass<ServiceUnavailable, "ServiceUnavailable", {
91
- readonly _tag: Schema.tag<"ServiceUnavailable">;
92
- } & {
93
- message: typeof Schema.String;
94
- }>;
95
- export declare class ServiceUnavailable extends ServiceUnavailable_base {
96
- static readonly status = 503;
97
- }
98
- export {};
@@ -1,55 +0,0 @@
1
- import * as Schema from "effect/Schema";
2
- export class BadRequest extends Schema.TaggedError()("BadRequest", {
3
- message: Schema.String,
4
- }) {
5
- static status = 400;
6
- }
7
- export class Unauthorized extends Schema.TaggedError()("Unauthorized", {
8
- message: Schema.String,
9
- }) {
10
- static status = 401;
11
- }
12
- export class Forbidden extends Schema.TaggedError()("Forbidden", {
13
- message: Schema.String,
14
- }) {
15
- static status = 403;
16
- }
17
- export class NotFound extends Schema.TaggedError()("NotFound", {
18
- message: Schema.String,
19
- }) {
20
- static status = 404;
21
- }
22
- export class MethodNotAllowed extends Schema.TaggedError()("MethodNotAllowed", {
23
- message: Schema.String,
24
- }) {
25
- static status = 405;
26
- }
27
- export class Conflict extends Schema.TaggedError()("Conflict", {
28
- message: Schema.String,
29
- }) {
30
- static status = 409;
31
- }
32
- export class Gone extends Schema.TaggedError()("Gone", {
33
- message: Schema.String,
34
- }) {
35
- static status = 410;
36
- }
37
- export class UnprocessableEntity extends Schema.TaggedError()("UnprocessableEntity", { message: Schema.String }) {
38
- static status = 422;
39
- }
40
- export class TooManyRequests extends Schema.TaggedError()("TooManyRequests", {
41
- message: Schema.String,
42
- }) {
43
- static status = 429;
44
- }
45
- export class InternalServerError extends Schema.TaggedError()("InternalServerError", { message: Schema.String }) {
46
- static status = 500;
47
- }
48
- export class NotImplemented extends Schema.TaggedError()("NotImplemented", {
49
- message: Schema.String,
50
- }) {
51
- static status = 501;
52
- }
53
- export class ServiceUnavailable extends Schema.TaggedError()("ServiceUnavailable", { message: Schema.String }) {
54
- static status = 503;
55
- }
@@ -1,12 +0,0 @@
1
- import * as Effect from "effect/Effect";
2
- import type * as Utils from "effect/Utils";
3
- import * as Route from "./Route.ts";
4
- export type FilterResult<BOut, E, R> = {
5
- context: BOut;
6
- } | Effect.Effect<{
7
- context: BOut;
8
- }, E, R>;
9
- export type FilterHandlerInput<BIn, BOut, E, R> = FilterResult<BOut, E, R> | ((context: BIn) => FilterResult<BOut, E, R> | Generator<Utils.YieldWrap<Effect.Effect<unknown, E, R>>, {
10
- context: BOut;
11
- }, unknown>);
12
- export declare function filter<D extends Route.RouteDescriptor.Any, SB extends {}, P extends Route.Route.Tuple, BOut extends {}, E = never, R = never, BIn = D & SB & Route.ExtractBindings<P>>(filterHandler: FilterHandlerInput<BIn, BOut, E, R>): (self: Route.RouteSet.RouteSet<D, SB, P>) => Route.RouteSet.RouteSet<D, SB, [...P, Route.Route.Route<{}, BOut, unknown, E, R>]>;
package/dist/RouteHook.js DELETED
@@ -1,40 +0,0 @@
1
- import * as Effect from "effect/Effect";
2
- import * as Entity from "./Entity.js";
3
- import * as Route from "./Route.js";
4
- export function filter(filterHandler) {
5
- const normalized = normalizeFilterHandler(filterHandler);
6
- return function (self) {
7
- const route = Route.make((context, next) => Effect.gen(function* () {
8
- const filterResult = yield* normalized(context);
9
- const mergedContext = filterResult ? { ...context, ...filterResult.context } : context;
10
- return yield* Entity.resolve(next(mergedContext));
11
- }));
12
- return Route.set([...Route.items(self), route], Route.descriptor(self));
13
- };
14
- }
15
- function isGenerator(value) {
16
- return (typeof value === "object" &&
17
- value !== null &&
18
- Symbol.iterator in value &&
19
- typeof value.next === "function");
20
- }
21
- function normalizeFilterHandler(handler) {
22
- if (typeof handler === "function") {
23
- return (context) => {
24
- const result = handler(context);
25
- if (Effect.isEffect(result)) {
26
- return result;
27
- }
28
- if (isGenerator(result)) {
29
- return Effect.gen(function* () {
30
- return yield* result;
31
- });
32
- }
33
- return Effect.succeed(result);
34
- };
35
- }
36
- if (Effect.isEffect(handler)) {
37
- return (_context) => handler;
38
- }
39
- return (_context) => Effect.succeed(handler);
40
- }
@@ -1,21 +0,0 @@
1
- import * as FiberId from "effect/FiberId";
2
- import * as Runtime from "effect/Runtime";
3
- import type * as Http from "./Http.ts";
4
- import * as Route from "./Route.ts";
5
- import type * as RouteBody from "./RouteBody.ts";
6
- import type * as RouteMount from "./RouteMount.ts";
7
- import * as RouteTree from "./RouteTree.ts";
8
- type UnboundedRouteWithMethod = Route.Route.With<{
9
- method: RouteMount.RouteMount.Method;
10
- format?: RouteBody.Format;
11
- }>;
12
- /**
13
- * A synthetic fiber used to tag interruptions caused by client disconnects.
14
- * Number stands for HTTP status 499 "Client Closed Request".
15
- * This is what @effect/platform does to signal request cancelation.
16
- */
17
- export declare const clientAbortFiberId: FiberId.Runtime;
18
- export declare const toWebHandlerRuntime: <R>(runtime: Runtime.Runtime<R>) => (routes: Iterable<UnboundedRouteWithMethod>) => Http.WebHandler;
19
- export declare const toWebHandler: (routes: Iterable<UnboundedRouteWithMethod>) => Http.WebHandler;
20
- export declare function walkHandles(tree: RouteTree.RouteTree, runtime?: Runtime.Runtime<never>): Generator<[path: string, handler: Http.WebHandler]>;
21
- export {};