effect 4.0.0-beta.103 → 4.0.0-beta.105

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 (667) hide show
  1. package/AGENTS.md +381 -0
  2. package/CLAUDE.md +381 -0
  3. package/ai-docs/README.md +44 -0
  4. package/ai-docs/package.json +36 -0
  5. package/ai-docs/src/01_effect/01_basics/01_effect-gen.ts +30 -0
  6. package/ai-docs/src/01_effect/01_basics/02_effect-fn.ts +39 -0
  7. package/ai-docs/src/01_effect/01_basics/10_creating-effects.ts +74 -0
  8. package/ai-docs/src/01_effect/01_basics/index.md +5 -0
  9. package/ai-docs/src/01_effect/02_schema/10_schema-basics.ts +43 -0
  10. package/ai-docs/src/01_effect/02_schema/index.md +7 -0
  11. package/ai-docs/src/01_effect/03_services/01_service.ts +45 -0
  12. package/ai-docs/src/01_effect/03_services/10_reference.ts +10 -0
  13. package/ai-docs/src/01_effect/03_services/20_layer-composition.ts +70 -0
  14. package/ai-docs/src/01_effect/03_services/20_layer-unwrap.ts +66 -0
  15. package/ai-docs/src/01_effect/03_services/index.md +5 -0
  16. package/ai-docs/src/01_effect/04_errors/01_error-handling.ts +30 -0
  17. package/ai-docs/src/01_effect/04_errors/10_catch-tags.ts +24 -0
  18. package/ai-docs/src/01_effect/04_errors/20_reason-errors.ts +64 -0
  19. package/ai-docs/src/01_effect/04_errors/index.md +1 -0
  20. package/ai-docs/src/01_effect/05_resources/10_acquire-release.ts +105 -0
  21. package/ai-docs/src/01_effect/05_resources/20_layer-side-effects.ts +31 -0
  22. package/ai-docs/src/01_effect/05_resources/30_layer-map.ts +86 -0
  23. package/ai-docs/src/01_effect/05_resources/index.md +3 -0
  24. package/ai-docs/src/01_effect/06_running/10_run-main.ts +30 -0
  25. package/ai-docs/src/01_effect/06_running/20_layer-launch.ts +27 -0
  26. package/ai-docs/src/01_effect/06_running/index.md +1 -0
  27. package/ai-docs/src/01_effect/07_pubsub/10_pubsub.ts +56 -0
  28. package/ai-docs/src/01_effect/07_pubsub/index.md +3 -0
  29. package/ai-docs/src/03_stream/10_creating-streams.ts +103 -0
  30. package/ai-docs/src/03_stream/20_consuming-streams.ts +137 -0
  31. package/ai-docs/src/03_stream/30_encoding.ts +165 -0
  32. package/ai-docs/src/03_stream/index.md +4 -0
  33. package/ai-docs/src/04_integration/10_managed-runtime.ts +129 -0
  34. package/ai-docs/src/04_integration/index.md +5 -0
  35. package/ai-docs/src/05_batching/10_request-resolver.ts +89 -0
  36. package/ai-docs/src/05_batching/index.md +3 -0
  37. package/ai-docs/src/06_schedule/10_schedules.ts +110 -0
  38. package/ai-docs/src/06_schedule/index.md +3 -0
  39. package/ai-docs/src/07_datetime/10_creating-and-formatting.ts +30 -0
  40. package/ai-docs/src/07_datetime/20_time-zones.ts +44 -0
  41. package/ai-docs/src/07_datetime/index.md +5 -0
  42. package/ai-docs/src/08_observability/10_logging.ts +66 -0
  43. package/ai-docs/src/08_observability/20_otlp-tracing.ts +95 -0
  44. package/ai-docs/src/08_observability/index.md +7 -0
  45. package/ai-docs/src/09_testing/10_effect-tests.ts +55 -0
  46. package/ai-docs/src/09_testing/20_layer-tests.ts +138 -0
  47. package/ai-docs/src/09_testing/index.md +1 -0
  48. package/ai-docs/src/10_predicate/01_basics.ts +14 -0
  49. package/ai-docs/src/10_predicate/index.md +9 -0
  50. package/ai-docs/src/50_http-client/10_basics.ts +102 -0
  51. package/ai-docs/src/50_http-client/index.md +3 -0
  52. package/ai-docs/src/51_http-server/10_basics.ts +116 -0
  53. package/ai-docs/src/51_http-server/fixtures/api/Api.ts +14 -0
  54. package/ai-docs/src/51_http-server/fixtures/api/Authorization.ts +36 -0
  55. package/ai-docs/src/51_http-server/fixtures/api/System.ts +10 -0
  56. package/ai-docs/src/51_http-server/fixtures/api/Users.ts +91 -0
  57. package/ai-docs/src/51_http-server/fixtures/domain/User.ts +12 -0
  58. package/ai-docs/src/51_http-server/fixtures/domain/UserErrors.ts +22 -0
  59. package/ai-docs/src/51_http-server/fixtures/server/Authorization.ts +36 -0
  60. package/ai-docs/src/51_http-server/fixtures/server/Users/http.ts +71 -0
  61. package/ai-docs/src/51_http-server/fixtures/server/Users.ts +62 -0
  62. package/ai-docs/src/51_http-server/index.md +3 -0
  63. package/ai-docs/src/60_child-process/10_working-with-child-processes.ts +117 -0
  64. package/ai-docs/src/60_child-process/index.md +3 -0
  65. package/ai-docs/src/70_cli/10_basics.ts +136 -0
  66. package/ai-docs/src/70_cli/index.md +5 -0
  67. package/ai-docs/src/71_ai/10_language-model.ts +156 -0
  68. package/ai-docs/src/71_ai/20_tools.ts +226 -0
  69. package/ai-docs/src/71_ai/30_chat.ts +158 -0
  70. package/ai-docs/src/71_ai/fixtures/domain/LaunchPlan.ts +9 -0
  71. package/ai-docs/src/71_ai/index.md +5 -0
  72. package/ai-docs/src/80_cluster/10_entities.ts +97 -0
  73. package/ai-docs/src/80_cluster/index.md +4 -0
  74. package/ai-docs/src/index.md +10 -0
  75. package/ai-docs/tsconfig.json +24 -0
  76. package/dist/Brand.d.ts +3 -3
  77. package/dist/Brand.d.ts.map +1 -1
  78. package/dist/Brand.js +4 -3
  79. package/dist/Brand.js.map +1 -1
  80. package/dist/Cache.js +1 -1
  81. package/dist/Cache.js.map +1 -1
  82. package/dist/Channel.d.ts +1 -1
  83. package/dist/Channel.d.ts.map +1 -1
  84. package/dist/Channel.js.map +1 -1
  85. package/dist/Config.d.ts.map +1 -1
  86. package/dist/Config.js +30 -8
  87. package/dist/Config.js.map +1 -1
  88. package/dist/ConfigProvider.d.ts.map +1 -1
  89. package/dist/ConfigProvider.js +2 -1
  90. package/dist/ConfigProvider.js.map +1 -1
  91. package/dist/Context.d.ts +2 -3
  92. package/dist/Context.d.ts.map +1 -1
  93. package/dist/Context.js +1 -22
  94. package/dist/Context.js.map +1 -1
  95. package/dist/Cron.d.ts +31 -0
  96. package/dist/Cron.d.ts.map +1 -1
  97. package/dist/Cron.js +58 -2
  98. package/dist/Cron.js.map +1 -1
  99. package/dist/Crypto.d.ts.map +1 -1
  100. package/dist/Crypto.js +13 -5
  101. package/dist/Crypto.js.map +1 -1
  102. package/dist/Duration.d.ts.map +1 -1
  103. package/dist/Duration.js +12 -1
  104. package/dist/Duration.js.map +1 -1
  105. package/dist/Effect.d.ts +132 -14
  106. package/dist/Effect.d.ts.map +1 -1
  107. package/dist/Effect.js +38 -0
  108. package/dist/Effect.js.map +1 -1
  109. package/dist/Equal.d.ts.map +1 -1
  110. package/dist/Equal.js +10 -2
  111. package/dist/Equal.js.map +1 -1
  112. package/dist/ExecutionPlan.d.ts +73 -0
  113. package/dist/ExecutionPlan.d.ts.map +1 -1
  114. package/dist/ExecutionPlan.js +1 -1
  115. package/dist/ExecutionPlan.js.map +1 -1
  116. package/dist/FiberSet.js +1 -1
  117. package/dist/FileSystem.d.ts +2 -2
  118. package/dist/Function.d.ts +4 -3
  119. package/dist/Function.d.ts.map +1 -1
  120. package/dist/Function.js +5 -5
  121. package/dist/Function.js.map +1 -1
  122. package/dist/Iterable.d.ts.map +1 -1
  123. package/dist/Iterable.js +11 -10
  124. package/dist/Iterable.js.map +1 -1
  125. package/dist/Layer.d.ts.map +1 -1
  126. package/dist/Layer.js +7 -5
  127. package/dist/Layer.js.map +1 -1
  128. package/dist/Optic.d.ts +35 -21
  129. package/dist/Optic.d.ts.map +1 -1
  130. package/dist/Optic.js +33 -34
  131. package/dist/Optic.js.map +1 -1
  132. package/dist/Schedule.d.ts +8 -8
  133. package/dist/Schedule.d.ts.map +1 -1
  134. package/dist/Schedule.js +4 -4
  135. package/dist/Schedule.js.map +1 -1
  136. package/dist/Schema.d.ts +105 -57
  137. package/dist/Schema.d.ts.map +1 -1
  138. package/dist/Schema.js +105 -67
  139. package/dist/Schema.js.map +1 -1
  140. package/dist/SchemaAST.d.ts +33 -3
  141. package/dist/SchemaAST.d.ts.map +1 -1
  142. package/dist/SchemaAST.js +87 -63
  143. package/dist/SchemaAST.js.map +1 -1
  144. package/dist/SchemaError.d.ts +8 -8
  145. package/dist/SchemaError.d.ts.map +1 -1
  146. package/dist/SchemaError.js +7 -6
  147. package/dist/SchemaError.js.map +1 -1
  148. package/dist/SchemaGetter.d.ts +8 -5
  149. package/dist/SchemaGetter.d.ts.map +1 -1
  150. package/dist/SchemaGetter.js +41 -37
  151. package/dist/SchemaGetter.js.map +1 -1
  152. package/dist/SchemaIssue.d.ts +195 -38
  153. package/dist/SchemaIssue.d.ts.map +1 -1
  154. package/dist/SchemaIssue.js +243 -68
  155. package/dist/SchemaIssue.js.map +1 -1
  156. package/dist/SchemaParser.d.ts +30 -0
  157. package/dist/SchemaParser.d.ts.map +1 -1
  158. package/dist/SchemaParser.js +74 -62
  159. package/dist/SchemaParser.js.map +1 -1
  160. package/dist/SchemaTransformation.d.ts +2 -2
  161. package/dist/SchemaTransformation.d.ts.map +1 -1
  162. package/dist/SchemaTransformation.js +26 -26
  163. package/dist/SchemaTransformation.js.map +1 -1
  164. package/dist/ScopedCache.js +1 -1
  165. package/dist/ScopedCache.js.map +1 -1
  166. package/dist/Sink.d.ts +1 -1
  167. package/dist/Sink.d.ts.map +1 -1
  168. package/dist/Stdio.d.ts +17 -4
  169. package/dist/Stdio.d.ts.map +1 -1
  170. package/dist/Stdio.js +6 -3
  171. package/dist/Stdio.js.map +1 -1
  172. package/dist/Stream.d.ts +27 -4
  173. package/dist/Stream.d.ts.map +1 -1
  174. package/dist/Stream.js +27 -2
  175. package/dist/Stream.js.map +1 -1
  176. package/dist/SynchronizedRef.js +1 -1
  177. package/dist/SynchronizedRef.js.map +1 -1
  178. package/dist/Terminal.js +1 -1
  179. package/dist/Terminal.js.map +1 -1
  180. package/dist/Tuple.d.ts +6 -4
  181. package/dist/Tuple.d.ts.map +1 -1
  182. package/dist/Tuple.js.map +1 -1
  183. package/dist/TxReentrantLock.d.ts +0 -56
  184. package/dist/TxReentrantLock.d.ts.map +1 -1
  185. package/dist/TxReentrantLock.js +8 -8
  186. package/dist/TxReentrantLock.js.map +1 -1
  187. package/dist/internal/dateTime.js +1 -1
  188. package/dist/internal/dateTime.js.map +1 -1
  189. package/dist/internal/executionPlan.js +51 -3
  190. package/dist/internal/executionPlan.js.map +1 -1
  191. package/dist/internal/hashMap.js +12 -8
  192. package/dist/internal/hashMap.js.map +1 -1
  193. package/dist/internal/matcher.js +1 -1
  194. package/dist/internal/matcher.js.map +1 -1
  195. package/dist/internal/schedule.js.map +1 -1
  196. package/dist/internal/schema/annotations.js +2 -0
  197. package/dist/internal/schema/annotations.js.map +1 -1
  198. package/dist/internal/schema/schema.js +1 -9
  199. package/dist/internal/schema/schema.js.map +1 -1
  200. package/dist/internal/schema/toArbitrary.js +1 -1
  201. package/dist/internal/schema/toArbitrary.js.map +1 -1
  202. package/dist/internal/trie.js +13 -3
  203. package/dist/internal/trie.js.map +1 -1
  204. package/dist/testing/TestClock.d.ts.map +1 -1
  205. package/dist/testing/TestClock.js +11 -1
  206. package/dist/testing/TestClock.js.map +1 -1
  207. package/dist/testing/TestSchema.d.ts +2 -2
  208. package/dist/testing/TestSchema.d.ts.map +1 -1
  209. package/dist/testing/TestSchema.js +8 -7
  210. package/dist/testing/TestSchema.js.map +1 -1
  211. package/dist/unstable/ai/AiError.js +19 -19
  212. package/dist/unstable/ai/AiError.js.map +1 -1
  213. package/dist/unstable/ai/Chat.js +1 -1
  214. package/dist/unstable/ai/Chat.js.map +1 -1
  215. package/dist/unstable/ai/LanguageModel.js +4 -2
  216. package/dist/unstable/ai/LanguageModel.js.map +1 -1
  217. package/dist/unstable/ai/McpSchema.d.ts +132 -132
  218. package/dist/unstable/ai/McpSchema.d.ts.map +1 -1
  219. package/dist/unstable/ai/McpSchema.js +8 -8
  220. package/dist/unstable/ai/McpSchema.js.map +1 -1
  221. package/dist/unstable/ai/McpServer.js +1 -1
  222. package/dist/unstable/ai/McpServer.js.map +1 -1
  223. package/dist/unstable/ai/Prompt.d.ts +15 -3
  224. package/dist/unstable/ai/Prompt.d.ts.map +1 -1
  225. package/dist/unstable/ai/Prompt.js +10 -7
  226. package/dist/unstable/ai/Prompt.js.map +1 -1
  227. package/dist/unstable/cli/CliError.d.ts +3 -3
  228. package/dist/unstable/cli/CliError.js +11 -11
  229. package/dist/unstable/cli/CliError.js.map +1 -1
  230. package/dist/unstable/cli/Command.d.ts +9 -9
  231. package/dist/unstable/cli/Command.d.ts.map +1 -1
  232. package/dist/unstable/cli/Command.js +8 -6
  233. package/dist/unstable/cli/Command.js.map +1 -1
  234. package/dist/unstable/cli/Param.d.ts +7 -5
  235. package/dist/unstable/cli/Param.d.ts.map +1 -1
  236. package/dist/unstable/cli/Param.js +15 -11
  237. package/dist/unstable/cli/Param.js.map +1 -1
  238. package/dist/unstable/cli/Primitive.d.ts.map +1 -1
  239. package/dist/unstable/cli/Primitive.js +31 -24
  240. package/dist/unstable/cli/Primitive.js.map +1 -1
  241. package/dist/unstable/cli/Prompt.d.ts.map +1 -1
  242. package/dist/unstable/cli/Prompt.js +31 -17
  243. package/dist/unstable/cli/Prompt.js.map +1 -1
  244. package/dist/unstable/cli/internal/ansi.js +2 -2
  245. package/dist/unstable/cli/internal/ansi.js.map +1 -1
  246. package/dist/unstable/cli/internal/command.d.ts +2 -2
  247. package/dist/unstable/cli/internal/command.d.ts.map +1 -1
  248. package/dist/unstable/cli/internal/command.js +10 -9
  249. package/dist/unstable/cli/internal/command.js.map +1 -1
  250. package/dist/unstable/cli/internal/completions/bash.js +69 -9
  251. package/dist/unstable/cli/internal/completions/bash.js.map +1 -1
  252. package/dist/unstable/cli/internal/completions/descriptor.js +24 -18
  253. package/dist/unstable/cli/internal/completions/descriptor.js.map +1 -1
  254. package/dist/unstable/cli/internal/completions/fish.js +5 -5
  255. package/dist/unstable/cli/internal/completions/fish.js.map +1 -1
  256. package/dist/unstable/cli/internal/help.d.ts.map +1 -1
  257. package/dist/unstable/cli/internal/help.js +4 -2
  258. package/dist/unstable/cli/internal/help.js.map +1 -1
  259. package/dist/unstable/cli/internal/parser.js +3 -3
  260. package/dist/unstable/cli/internal/parser.js.map +1 -1
  261. package/dist/unstable/cli/internal/wizard.js +2 -2
  262. package/dist/unstable/cli/internal/wizard.js.map +1 -1
  263. package/dist/unstable/cluster/ClusterError.js +7 -7
  264. package/dist/unstable/cluster/ClusterError.js.map +1 -1
  265. package/dist/unstable/cluster/ClusterWorkflowEngine.d.ts.map +1 -1
  266. package/dist/unstable/cluster/ClusterWorkflowEngine.js +1 -1
  267. package/dist/unstable/cluster/ClusterWorkflowEngine.js.map +1 -1
  268. package/dist/unstable/cluster/MessageStorage.d.ts.map +1 -1
  269. package/dist/unstable/cluster/MessageStorage.js +8 -1
  270. package/dist/unstable/cluster/MessageStorage.js.map +1 -1
  271. package/dist/unstable/cluster/Reply.d.ts +8 -0
  272. package/dist/unstable/cluster/Reply.d.ts.map +1 -1
  273. package/dist/unstable/cluster/Reply.js +16 -4
  274. package/dist/unstable/cluster/Reply.js.map +1 -1
  275. package/dist/unstable/cluster/RunnerServer.d.ts.map +1 -1
  276. package/dist/unstable/cluster/RunnerServer.js +4 -2
  277. package/dist/unstable/cluster/RunnerServer.js.map +1 -1
  278. package/dist/unstable/cluster/RunnerStorage.d.ts +1 -2
  279. package/dist/unstable/cluster/RunnerStorage.d.ts.map +1 -1
  280. package/dist/unstable/cluster/RunnerStorage.js +7 -6
  281. package/dist/unstable/cluster/RunnerStorage.js.map +1 -1
  282. package/dist/unstable/cluster/Sharding.d.ts.map +1 -1
  283. package/dist/unstable/cluster/Sharding.js +22 -4
  284. package/dist/unstable/cluster/Sharding.js.map +1 -1
  285. package/dist/unstable/cluster/internal/entityManager.js +1 -1
  286. package/dist/unstable/cluster/internal/entityManager.js.map +1 -1
  287. package/dist/unstable/cluster/internal/resourceMap.js +2 -2
  288. package/dist/unstable/cluster/internal/resourceMap.js.map +1 -1
  289. package/dist/unstable/cluster/internal/resourceRef.js +17 -0
  290. package/dist/unstable/cluster/internal/resourceRef.js.map +1 -1
  291. package/dist/unstable/devtools/DevToolsClient.d.ts.map +1 -1
  292. package/dist/unstable/devtools/DevToolsClient.js +7 -2
  293. package/dist/unstable/devtools/DevToolsClient.js.map +1 -1
  294. package/dist/unstable/encoding/Ini.d.ts +20 -0
  295. package/dist/unstable/encoding/Ini.d.ts.map +1 -0
  296. package/dist/unstable/encoding/Ini.js +153 -0
  297. package/dist/unstable/encoding/Ini.js.map +1 -0
  298. package/dist/unstable/encoding/Msgpack.d.ts +2 -1
  299. package/dist/unstable/encoding/Msgpack.d.ts.map +1 -1
  300. package/dist/unstable/encoding/Msgpack.js +27 -13
  301. package/dist/unstable/encoding/Msgpack.js.map +1 -1
  302. package/dist/unstable/encoding/Ndjson.d.ts.map +1 -1
  303. package/dist/unstable/encoding/Ndjson.js +7 -1
  304. package/dist/unstable/encoding/Ndjson.js.map +1 -1
  305. package/dist/unstable/encoding/Sse.d.ts.map +1 -1
  306. package/dist/unstable/encoding/Sse.js +14 -23
  307. package/dist/unstable/encoding/Sse.js.map +1 -1
  308. package/dist/unstable/encoding/Toml.d.ts +19 -0
  309. package/dist/unstable/encoding/Toml.d.ts.map +1 -0
  310. package/dist/unstable/encoding/Toml.js +434 -0
  311. package/dist/unstable/encoding/Toml.js.map +1 -0
  312. package/dist/unstable/encoding/Yaml.d.ts +19 -0
  313. package/dist/unstable/encoding/Yaml.d.ts.map +1 -0
  314. package/dist/unstable/encoding/Yaml.js +461 -0
  315. package/dist/unstable/encoding/Yaml.js.map +1 -0
  316. package/dist/unstable/encoding/index.d.ts +12 -0
  317. package/dist/unstable/encoding/index.d.ts.map +1 -1
  318. package/dist/unstable/encoding/index.js +12 -0
  319. package/dist/unstable/encoding/index.js.map +1 -1
  320. package/dist/unstable/eventlog/EventJournal.d.ts +1 -1
  321. package/dist/unstable/eventlog/EventJournal.d.ts.map +1 -1
  322. package/dist/unstable/eventlog/EventJournal.js +13 -5
  323. package/dist/unstable/eventlog/EventJournal.js.map +1 -1
  324. package/dist/unstable/eventlog/EventLogMessage.js +1 -1
  325. package/dist/unstable/eventlog/EventLogMessage.js.map +1 -1
  326. package/dist/unstable/eventlog/EventLogServerUnencrypted.js +1 -1
  327. package/dist/unstable/eventlog/EventLogServerUnencrypted.js.map +1 -1
  328. package/dist/unstable/eventlog/SqlEventJournal.d.ts.map +1 -1
  329. package/dist/unstable/eventlog/SqlEventJournal.js +1 -4
  330. package/dist/unstable/eventlog/SqlEventJournal.js.map +1 -1
  331. package/dist/unstable/http/FindMyWay/internal/queryString.d.ts +11 -0
  332. package/dist/unstable/http/FindMyWay/internal/queryString.d.ts.map +1 -0
  333. package/dist/unstable/http/FindMyWay/internal/queryString.js +259 -0
  334. package/dist/unstable/http/FindMyWay/internal/queryString.js.map +1 -0
  335. package/dist/unstable/http/FindMyWay/internal/router.d.ts +2 -0
  336. package/dist/unstable/http/FindMyWay/internal/router.d.ts.map +1 -0
  337. package/dist/unstable/http/FindMyWay/internal/router.js +665 -0
  338. package/dist/unstable/http/FindMyWay/internal/router.js.map +1 -0
  339. package/dist/unstable/http/FindMyWay.d.ts +33 -8
  340. package/dist/unstable/http/FindMyWay.d.ts.map +1 -1
  341. package/dist/unstable/http/FindMyWay.js +4 -7
  342. package/dist/unstable/http/FindMyWay.js.map +1 -1
  343. package/dist/unstable/http/HttpClient.d.ts +59 -3
  344. package/dist/unstable/http/HttpClient.d.ts.map +1 -1
  345. package/dist/unstable/http/HttpClient.js +33 -19
  346. package/dist/unstable/http/HttpClient.js.map +1 -1
  347. package/dist/unstable/http/HttpClientError.js +1 -1
  348. package/dist/unstable/http/HttpClientError.js.map +1 -1
  349. package/dist/unstable/http/HttpClientRequest.d.ts.map +1 -1
  350. package/dist/unstable/http/HttpClientRequest.js +2 -14
  351. package/dist/unstable/http/HttpClientRequest.js.map +1 -1
  352. package/dist/unstable/http/HttpClientResponse.js +1 -16
  353. package/dist/unstable/http/HttpClientResponse.js.map +1 -1
  354. package/dist/unstable/http/HttpPlatform.d.ts.map +1 -1
  355. package/dist/unstable/http/HttpPlatform.js +21 -3
  356. package/dist/unstable/http/HttpPlatform.js.map +1 -1
  357. package/dist/unstable/http/HttpServerRequest.d.ts.map +1 -1
  358. package/dist/unstable/http/HttpServerRequest.js +7 -6
  359. package/dist/unstable/http/HttpServerRequest.js.map +1 -1
  360. package/dist/unstable/http/HttpServerResponse.d.ts.map +1 -1
  361. package/dist/unstable/http/HttpServerResponse.js +8 -6
  362. package/dist/unstable/http/HttpServerResponse.js.map +1 -1
  363. package/dist/unstable/http/Multipart.d.ts +1 -1
  364. package/dist/unstable/http/Multipart.d.ts.map +1 -1
  365. package/dist/unstable/http/Multipart.js +9 -2
  366. package/dist/unstable/http/Multipart.js.map +1 -1
  367. package/dist/unstable/http/MultipartParser/HeadersParser.d.ts +53 -0
  368. package/dist/unstable/http/MultipartParser/HeadersParser.d.ts.map +1 -0
  369. package/dist/unstable/http/MultipartParser/HeadersParser.js +14 -0
  370. package/dist/unstable/http/MultipartParser/HeadersParser.js.map +1 -0
  371. package/dist/unstable/http/MultipartParser/Search.d.ts +11 -0
  372. package/dist/unstable/http/MultipartParser/Search.d.ts.map +1 -0
  373. package/dist/unstable/http/MultipartParser/Search.js +14 -0
  374. package/dist/unstable/http/MultipartParser/Search.js.map +1 -0
  375. package/dist/unstable/http/MultipartParser/internal/contentType.d.ts +5 -0
  376. package/dist/unstable/http/MultipartParser/internal/contentType.d.ts.map +1 -0
  377. package/dist/unstable/http/MultipartParser/internal/contentType.js +82 -0
  378. package/dist/unstable/http/MultipartParser/internal/contentType.js.map +1 -0
  379. package/dist/unstable/http/MultipartParser/internal/headers.d.ts +3 -0
  380. package/dist/unstable/http/MultipartParser/internal/headers.d.ts.map +1 -0
  381. package/dist/unstable/http/MultipartParser/internal/headers.js +194 -0
  382. package/dist/unstable/http/MultipartParser/internal/headers.js.map +1 -0
  383. package/dist/unstable/http/MultipartParser/internal/multipart.d.ts +8 -0
  384. package/dist/unstable/http/MultipartParser/internal/multipart.d.ts.map +1 -0
  385. package/dist/unstable/http/MultipartParser/internal/multipart.js +226 -0
  386. package/dist/unstable/http/MultipartParser/internal/multipart.js.map +1 -0
  387. package/dist/unstable/http/MultipartParser/internal/search.d.ts +5 -0
  388. package/dist/unstable/http/MultipartParser/internal/search.d.ts.map +1 -0
  389. package/dist/unstable/http/MultipartParser/internal/search.js +120 -0
  390. package/dist/unstable/http/MultipartParser/internal/search.js.map +1 -0
  391. package/dist/unstable/http/MultipartParser.d.ts +98 -0
  392. package/dist/unstable/http/MultipartParser.d.ts.map +1 -0
  393. package/dist/unstable/http/MultipartParser.js +23 -0
  394. package/dist/unstable/http/MultipartParser.js.map +1 -0
  395. package/dist/unstable/http/Template.d.ts.map +1 -1
  396. package/dist/unstable/http/Template.js +2 -2
  397. package/dist/unstable/http/Template.js.map +1 -1
  398. package/dist/unstable/http/index.d.ts +1 -1
  399. package/dist/unstable/http/index.d.ts.map +1 -1
  400. package/dist/unstable/http/index.js +1 -1
  401. package/dist/unstable/http/index.js.map +1 -1
  402. package/dist/unstable/http/internal/httpBody.d.ts +2 -0
  403. package/dist/unstable/http/internal/httpBody.d.ts.map +1 -0
  404. package/dist/unstable/http/internal/httpBody.js +10 -0
  405. package/dist/unstable/http/internal/httpBody.js.map +1 -0
  406. package/dist/unstable/httpapi/HttpApi.d.ts.map +1 -1
  407. package/dist/unstable/httpapi/HttpApi.js +5 -5
  408. package/dist/unstable/httpapi/HttpApi.js.map +1 -1
  409. package/dist/unstable/httpapi/HttpApiBuilder.js +73 -20
  410. package/dist/unstable/httpapi/HttpApiBuilder.js.map +1 -1
  411. package/dist/unstable/httpapi/HttpApiClient.d.ts +1 -1
  412. package/dist/unstable/httpapi/HttpApiClient.d.ts.map +1 -1
  413. package/dist/unstable/httpapi/HttpApiClient.js +74 -34
  414. package/dist/unstable/httpapi/HttpApiClient.js.map +1 -1
  415. package/dist/unstable/httpapi/HttpApiEndpoint.d.ts +6 -4
  416. package/dist/unstable/httpapi/HttpApiEndpoint.d.ts.map +1 -1
  417. package/dist/unstable/httpapi/HttpApiEndpoint.js +73 -16
  418. package/dist/unstable/httpapi/HttpApiEndpoint.js.map +1 -1
  419. package/dist/unstable/httpapi/HttpApiError.d.ts +5 -5
  420. package/dist/unstable/httpapi/HttpApiError.d.ts.map +1 -1
  421. package/dist/unstable/httpapi/HttpApiError.js +17 -17
  422. package/dist/unstable/httpapi/HttpApiError.js.map +1 -1
  423. package/dist/unstable/httpapi/HttpApiMiddleware.d.ts +1 -1
  424. package/dist/unstable/httpapi/HttpApiMiddleware.js +1 -1
  425. package/dist/unstable/httpapi/HttpApiSchema.d.ts +219 -0
  426. package/dist/unstable/httpapi/HttpApiSchema.d.ts.map +1 -1
  427. package/dist/unstable/httpapi/HttpApiSchema.js +170 -0
  428. package/dist/unstable/httpapi/HttpApiSchema.js.map +1 -1
  429. package/dist/unstable/httpapi/OpenApi.d.ts +8 -0
  430. package/dist/unstable/httpapi/OpenApi.d.ts.map +1 -1
  431. package/dist/unstable/httpapi/OpenApi.js +45 -18
  432. package/dist/unstable/httpapi/OpenApi.js.map +1 -1
  433. package/dist/unstable/observability/OtlpExporter.d.ts +1 -1
  434. package/dist/unstable/observability/OtlpExporter.d.ts.map +1 -1
  435. package/dist/unstable/observability/OtlpExporter.js +2 -1
  436. package/dist/unstable/observability/OtlpExporter.js.map +1 -1
  437. package/dist/unstable/observability/OtlpLogger.d.ts.map +1 -1
  438. package/dist/unstable/observability/OtlpLogger.js +2 -2
  439. package/dist/unstable/observability/OtlpLogger.js.map +1 -1
  440. package/dist/unstable/observability/OtlpMetrics.d.ts +2 -2
  441. package/dist/unstable/observability/OtlpMetrics.d.ts.map +1 -1
  442. package/dist/unstable/observability/OtlpMetrics.js +28 -15
  443. package/dist/unstable/observability/OtlpMetrics.js.map +1 -1
  444. package/dist/unstable/observability/OtlpTracer.js +1 -1
  445. package/dist/unstable/observability/OtlpTracer.js.map +1 -1
  446. package/dist/unstable/persistence/PersistedQueue.d.ts.map +1 -1
  447. package/dist/unstable/persistence/PersistedQueue.js +9 -9
  448. package/dist/unstable/persistence/PersistedQueue.js.map +1 -1
  449. package/dist/unstable/persistence/Persistence.d.ts.map +1 -1
  450. package/dist/unstable/persistence/Persistence.js +17 -7
  451. package/dist/unstable/persistence/Persistence.js.map +1 -1
  452. package/dist/unstable/persistence/RateLimiter.d.ts +22 -12
  453. package/dist/unstable/persistence/RateLimiter.d.ts.map +1 -1
  454. package/dist/unstable/persistence/RateLimiter.js +15 -42
  455. package/dist/unstable/persistence/RateLimiter.js.map +1 -1
  456. package/dist/unstable/persistence/Redis.js +1 -1
  457. package/dist/unstable/persistence/Redis.js.map +1 -1
  458. package/dist/unstable/reactivity/AsyncResult.d.ts.map +1 -1
  459. package/dist/unstable/reactivity/AsyncResult.js +4 -4
  460. package/dist/unstable/reactivity/AsyncResult.js.map +1 -1
  461. package/dist/unstable/reactivity/Atom.d.ts +26 -11
  462. package/dist/unstable/reactivity/Atom.d.ts.map +1 -1
  463. package/dist/unstable/reactivity/Atom.js +9 -22
  464. package/dist/unstable/reactivity/Atom.js.map +1 -1
  465. package/dist/unstable/rpc/RpcClient.d.ts +14 -0
  466. package/dist/unstable/rpc/RpcClient.d.ts.map +1 -1
  467. package/dist/unstable/rpc/RpcClient.js +21 -10
  468. package/dist/unstable/rpc/RpcClient.js.map +1 -1
  469. package/dist/unstable/rpc/RpcClientError.js +2 -2
  470. package/dist/unstable/rpc/RpcClientError.js.map +1 -1
  471. package/dist/unstable/rpc/RpcSerialization.js +3 -1
  472. package/dist/unstable/rpc/RpcSerialization.js.map +1 -1
  473. package/dist/unstable/rpc/RpcServer.d.ts.map +1 -1
  474. package/dist/unstable/rpc/RpcServer.js +3 -2
  475. package/dist/unstable/rpc/RpcServer.js.map +1 -1
  476. package/dist/unstable/schema/Model.d.ts +1 -1
  477. package/dist/unstable/schema/Model.d.ts.map +1 -1
  478. package/dist/unstable/schema/VariantSchema.d.ts +5 -5
  479. package/dist/unstable/schema/VariantSchema.d.ts.map +1 -1
  480. package/dist/unstable/schema/VariantSchema.js +17 -9
  481. package/dist/unstable/schema/VariantSchema.js.map +1 -1
  482. package/dist/unstable/socket/Socket.d.ts.map +1 -1
  483. package/dist/unstable/socket/Socket.js +28 -12
  484. package/dist/unstable/socket/Socket.js.map +1 -1
  485. package/dist/unstable/sql/SqlClient.d.ts.map +1 -1
  486. package/dist/unstable/sql/SqlClient.js +7 -3
  487. package/dist/unstable/sql/SqlClient.js.map +1 -1
  488. package/dist/unstable/sql/SqlError.js +13 -13
  489. package/dist/unstable/sql/SqlError.js.map +1 -1
  490. package/dist/unstable/sql/SqlResolver.js +8 -6
  491. package/dist/unstable/sql/SqlResolver.js.map +1 -1
  492. package/dist/unstable/sql/Statement.d.ts.map +1 -1
  493. package/dist/unstable/sql/Statement.js +8 -6
  494. package/dist/unstable/sql/Statement.js.map +1 -1
  495. package/dist/unstable/workers/WorkerError.js +5 -5
  496. package/dist/unstable/workers/WorkerError.js.map +1 -1
  497. package/dist/unstable/workflow/Workflow.d.ts.map +1 -1
  498. package/dist/unstable/workflow/Workflow.js +2 -2
  499. package/dist/unstable/workflow/Workflow.js.map +1 -1
  500. package/dist/unstable/workflow/WorkflowEngine.d.ts +1 -1
  501. package/dist/unstable/workflow/WorkflowEngine.d.ts.map +1 -1
  502. package/dist/unstable/workflow/WorkflowEngine.js +3 -3
  503. package/dist/unstable/workflow/WorkflowEngine.js.map +1 -1
  504. package/package.json +6 -9
  505. package/src/Brand.ts +4 -4
  506. package/src/Cache.ts +1 -1
  507. package/src/Channel.ts +1 -1
  508. package/src/Config.ts +31 -8
  509. package/src/ConfigProvider.ts +4 -1
  510. package/src/Context.ts +6 -28
  511. package/src/Cron.ts +65 -2
  512. package/src/Crypto.ts +17 -8
  513. package/src/Duration.ts +16 -2
  514. package/src/Effect.ts +141 -17
  515. package/src/Equal.ts +10 -2
  516. package/src/ExecutionPlan.ts +78 -1
  517. package/src/FiberSet.ts +1 -1
  518. package/src/FileSystem.ts +2 -2
  519. package/src/Function.ts +6 -6
  520. package/src/Iterable.ts +11 -10
  521. package/src/Layer.ts +7 -5
  522. package/src/Optic.ts +59 -58
  523. package/src/Schedule.ts +13 -13
  524. package/src/Schema.ts +195 -112
  525. package/src/SchemaAST.ts +154 -85
  526. package/src/SchemaError.ts +9 -9
  527. package/src/SchemaGetter.ts +89 -30
  528. package/src/SchemaIssue.ts +285 -80
  529. package/src/SchemaParser.ts +126 -86
  530. package/src/SchemaTransformation.ts +66 -18
  531. package/src/ScopedCache.ts +1 -1
  532. package/src/Sink.ts +1 -1
  533. package/src/Stdio.ts +23 -4
  534. package/src/Stream.ts +77 -10
  535. package/src/SynchronizedRef.ts +1 -1
  536. package/src/Terminal.ts +1 -1
  537. package/src/Tuple.ts +7 -4
  538. package/src/TxReentrantLock.ts +39 -35
  539. package/src/internal/dateTime.ts +1 -1
  540. package/src/internal/executionPlan.ts +105 -10
  541. package/src/internal/hashMap.ts +20 -14
  542. package/src/internal/matcher.ts +2 -2
  543. package/src/internal/schedule.ts +4 -4
  544. package/src/internal/schema/annotations.ts +3 -0
  545. package/src/internal/schema/schema.ts +1 -17
  546. package/src/internal/schema/toArbitrary.ts +3 -1
  547. package/src/internal/trie.ts +12 -2
  548. package/src/testing/TestClock.ts +13 -1
  549. package/src/testing/TestSchema.ts +9 -9
  550. package/src/unstable/ai/AiError.ts +19 -19
  551. package/src/unstable/ai/Chat.ts +1 -1
  552. package/src/unstable/ai/LanguageModel.ts +4 -2
  553. package/src/unstable/ai/McpSchema.ts +17 -16
  554. package/src/unstable/ai/McpServer.ts +1 -1
  555. package/src/unstable/ai/Prompt.ts +35 -10
  556. package/src/unstable/cli/CliError.ts +12 -12
  557. package/src/unstable/cli/Command.ts +12 -10
  558. package/src/unstable/cli/Param.ts +41 -19
  559. package/src/unstable/cli/Primitive.ts +11 -5
  560. package/src/unstable/cli/Prompt.ts +36 -20
  561. package/src/unstable/cli/internal/ansi.ts +2 -2
  562. package/src/unstable/cli/internal/command.ts +15 -10
  563. package/src/unstable/cli/internal/completions/bash.ts +59 -9
  564. package/src/unstable/cli/internal/completions/descriptor.ts +14 -20
  565. package/src/unstable/cli/internal/completions/fish.ts +5 -7
  566. package/src/unstable/cli/internal/help.ts +4 -2
  567. package/src/unstable/cli/internal/parser.ts +3 -3
  568. package/src/unstable/cli/internal/wizard.ts +2 -2
  569. package/src/unstable/cluster/ClusterError.ts +7 -7
  570. package/src/unstable/cluster/ClusterWorkflowEngine.ts +4 -1
  571. package/src/unstable/cluster/MessageStorage.ts +9 -5
  572. package/src/unstable/cluster/Reply.ts +25 -4
  573. package/src/unstable/cluster/RunnerServer.ts +4 -10
  574. package/src/unstable/cluster/RunnerStorage.ts +9 -7
  575. package/src/unstable/cluster/Sharding.ts +35 -7
  576. package/src/unstable/cluster/internal/entityManager.ts +1 -1
  577. package/src/unstable/cluster/internal/resourceMap.ts +5 -2
  578. package/src/unstable/cluster/internal/resourceRef.ts +27 -5
  579. package/src/unstable/devtools/DevToolsClient.ts +3 -2
  580. package/src/unstable/encoding/Ini.ts +174 -0
  581. package/src/unstable/encoding/Msgpack.ts +59 -36
  582. package/src/unstable/encoding/Ndjson.ts +9 -1
  583. package/src/unstable/encoding/Sse.ts +11 -21
  584. package/src/unstable/encoding/Toml.ts +504 -0
  585. package/src/unstable/encoding/Yaml.ts +541 -0
  586. package/src/unstable/encoding/index.ts +15 -0
  587. package/src/unstable/eventlog/EventJournal.ts +14 -6
  588. package/src/unstable/eventlog/EventLogMessage.ts +1 -1
  589. package/src/unstable/eventlog/EventLogServerUnencrypted.ts +1 -1
  590. package/src/unstable/eventlog/SqlEventJournal.ts +6 -4
  591. package/src/unstable/http/FindMyWay/internal/queryString.ts +420 -0
  592. package/src/unstable/http/FindMyWay/internal/router.ts +950 -0
  593. package/src/unstable/http/FindMyWay.ts +65 -6
  594. package/src/unstable/http/HttpClient.ts +132 -23
  595. package/src/unstable/http/HttpClientError.ts +1 -1
  596. package/src/unstable/http/HttpClientRequest.ts +2 -14
  597. package/src/unstable/http/HttpClientResponse.ts +1 -17
  598. package/src/unstable/http/HttpPlatform.ts +34 -6
  599. package/src/unstable/http/HttpServerRequest.ts +14 -6
  600. package/src/unstable/http/HttpServerResponse.ts +9 -7
  601. package/src/unstable/http/Multipart.ts +9 -2
  602. package/src/unstable/http/MultipartParser/HeadersParser.ts +68 -0
  603. package/src/unstable/http/MultipartParser/Search.ts +17 -0
  604. package/src/unstable/http/MultipartParser/internal/contentType.ts +103 -0
  605. package/src/unstable/http/MultipartParser/internal/headers.ts +615 -0
  606. package/src/unstable/http/MultipartParser/internal/multipart.ts +262 -0
  607. package/src/unstable/http/MultipartParser/internal/search.ts +167 -0
  608. package/src/unstable/http/MultipartParser.ts +115 -0
  609. package/src/unstable/http/Template.ts +6 -5
  610. package/src/unstable/http/index.ts +1 -1
  611. package/src/unstable/http/internal/httpBody.ts +15 -0
  612. package/src/unstable/httpapi/HttpApi.ts +6 -7
  613. package/src/unstable/httpapi/HttpApiBuilder.ts +142 -25
  614. package/src/unstable/httpapi/HttpApiClient.ts +130 -49
  615. package/src/unstable/httpapi/HttpApiEndpoint.ts +117 -29
  616. package/src/unstable/httpapi/HttpApiError.ts +33 -39
  617. package/src/unstable/httpapi/HttpApiMiddleware.ts +1 -1
  618. package/src/unstable/httpapi/HttpApiSchema.ts +353 -0
  619. package/src/unstable/httpapi/OpenApi.ts +70 -20
  620. package/src/unstable/observability/OtlpExporter.ts +4 -2
  621. package/src/unstable/observability/OtlpLogger.ts +3 -1
  622. package/src/unstable/observability/OtlpMetrics.ts +32 -18
  623. package/src/unstable/observability/OtlpTracer.ts +1 -1
  624. package/src/unstable/persistence/PersistedQueue.ts +12 -9
  625. package/src/unstable/persistence/Persistence.ts +27 -7
  626. package/src/unstable/persistence/RateLimiter.ts +54 -31
  627. package/src/unstable/persistence/Redis.ts +1 -1
  628. package/src/unstable/reactivity/AsyncResult.ts +11 -6
  629. package/src/unstable/reactivity/Atom.ts +44 -25
  630. package/src/unstable/rpc/RpcClient.ts +42 -13
  631. package/src/unstable/rpc/RpcClientError.ts +2 -2
  632. package/src/unstable/rpc/RpcSerialization.ts +1 -1
  633. package/src/unstable/rpc/RpcServer.ts +4 -2
  634. package/src/unstable/schema/VariantSchema.ts +36 -18
  635. package/src/unstable/socket/Socket.ts +24 -14
  636. package/src/unstable/sql/SqlClient.ts +65 -56
  637. package/src/unstable/sql/SqlError.ts +13 -13
  638. package/src/unstable/sql/SqlResolver.ts +8 -6
  639. package/src/unstable/sql/Statement.ts +13 -8
  640. package/src/unstable/workers/WorkerError.ts +5 -5
  641. package/src/unstable/workflow/Workflow.ts +2 -5
  642. package/src/unstable/workflow/WorkflowEngine.ts +8 -3
  643. package/dist/unstable/http/Multipasta/HeadersParser.d.ts +0 -14
  644. package/dist/unstable/http/Multipasta/HeadersParser.d.ts.map +0 -1
  645. package/dist/unstable/http/Multipasta/HeadersParser.js +0 -14
  646. package/dist/unstable/http/Multipasta/HeadersParser.js.map +0 -1
  647. package/dist/unstable/http/Multipasta/Node.d.ts +0 -14
  648. package/dist/unstable/http/Multipasta/Node.d.ts.map +0 -1
  649. package/dist/unstable/http/Multipasta/Node.js +0 -14
  650. package/dist/unstable/http/Multipasta/Node.js.map +0 -1
  651. package/dist/unstable/http/Multipasta/Search.d.ts +0 -14
  652. package/dist/unstable/http/Multipasta/Search.d.ts.map +0 -1
  653. package/dist/unstable/http/Multipasta/Search.js +0 -14
  654. package/dist/unstable/http/Multipasta/Search.js.map +0 -1
  655. package/dist/unstable/http/Multipasta/Web.d.ts +0 -14
  656. package/dist/unstable/http/Multipasta/Web.d.ts.map +0 -1
  657. package/dist/unstable/http/Multipasta/Web.js +0 -14
  658. package/dist/unstable/http/Multipasta/Web.js.map +0 -1
  659. package/dist/unstable/http/Multipasta.d.ts +0 -15
  660. package/dist/unstable/http/Multipasta.d.ts.map +0 -1
  661. package/dist/unstable/http/Multipasta.js +0 -15
  662. package/dist/unstable/http/Multipasta.js.map +0 -1
  663. package/src/unstable/http/Multipasta/HeadersParser.ts +0 -14
  664. package/src/unstable/http/Multipasta/Node.ts +0 -14
  665. package/src/unstable/http/Multipasta/Search.ts +0 -14
  666. package/src/unstable/http/Multipasta/Web.ts +0 -14
  667. package/src/unstable/http/Multipasta.ts +0 -15
@@ -1,15 +1,74 @@
1
1
  /**
2
- * Re-exports the `find-my-way-ts` router package used by the unstable HTTP
3
- * routing modules.
2
+ * A radix-tree HTTP router used by the unstable HTTP routing modules.
4
3
  *
5
- * This module keeps the router types and helpers available from the Effect HTTP
6
- * namespace without wrapping or changing them.
4
+ * @since 4.0.0
5
+ */
6
+ import * as internal from "./FindMyWay/internal/router.ts"
7
+
8
+ /*
9
+ * MIT License
10
+ *
11
+ * Copyright (c) 2017-2019 Tomas Della Vedova
12
+ *
13
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
14
+ * of this software and associated documentation files (the "Software"), to deal
15
+ * in the Software without restriction, including without limitation the rights
16
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
17
+ * copies of the Software, and to permit persons to whom the Software is
18
+ * furnished to do so, subject to the following conditions:
19
+ *
20
+ * The above copyright notice and this permission notice shall be included in all
21
+ * copies or substantial portions of the Software.
7
22
  *
23
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
24
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
25
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
26
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
27
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
28
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
29
+ * SOFTWARE.
30
+ */
31
+
32
+ /**
33
+ * @since 4.0.0
34
+ * @category models
35
+ */
36
+ export interface RouterConfig {
37
+ readonly ignoreTrailingSlash: boolean
38
+ readonly ignoreDuplicateSlashes: boolean
39
+ readonly caseSensitive: boolean
40
+ readonly maxParamLength: number
41
+ }
42
+
43
+ /**
44
+ * @since 4.0.0
45
+ * @category models
46
+ */
47
+ export type PathInput = `/${string}` | "*"
48
+
49
+ /**
50
+ * @since 4.0.0
51
+ * @category models
52
+ */
53
+ export interface Router<A> {
54
+ readonly on: (method: string | Iterable<string>, path: PathInput, handler: A) => void
55
+ readonly all: (path: PathInput, handler: A) => void
56
+ readonly find: (method: string, url: string) => FindResult<A> | undefined
57
+ readonly has: (method: string, url: string) => boolean
58
+ }
59
+
60
+ /**
8
61
  * @since 4.0.0
62
+ * @category models
9
63
  */
64
+ export interface FindResult<A> {
65
+ readonly handler: A
66
+ readonly params: Record<string, string | undefined>
67
+ readonly searchParams: Record<string, string | Array<string>>
68
+ }
10
69
 
11
70
  /**
12
- * @category re-exports
13
71
  * @since 4.0.0
72
+ * @category constructors
14
73
  */
15
- export * from "find-my-way-ts"
74
+ export const make: <A>(options?: Partial<RouterConfig>) => Router<A> = internal.make
@@ -1267,7 +1267,8 @@ export declare namespace WithRateLimiter {
1267
1267
  *
1268
1268
  * **Details**
1269
1269
  *
1270
- * They define the backing limiter, initial limit window, keying strategy, algorithm, token cost, and whether response headers update future limits.
1270
+ * They define the backing limiter, initial limit window, keying strategy,
1271
+ * algorithm, token cost, retry count, and response header inspection.
1271
1272
  *
1272
1273
  * @category rate limiting
1273
1274
  * @since 4.0.0
@@ -1300,11 +1301,48 @@ export declare namespace WithRateLimiter {
1300
1301
  */
1301
1302
  readonly tokens?: number | ((request: HttpClientRequest.HttpClientRequest) => number) | undefined
1302
1303
  /**
1303
- * Disable automatic limits updates from response headers.
1304
+ * The maximum number of automatic retries after an HTTP `429` response.
1305
+ * Use a non-negative integer. Defaults to an unlimited number of retries.
1306
+ * Set to `0` to disable automatic retries.
1307
+ */
1308
+ readonly times?: number | undefined
1309
+ /**
1310
+ * Overrides the response header names used for rate limit inspection.
1311
+ * Header names are matched case-insensitively. An omitted field continues
1312
+ * using the built-in names, while a configured field replaces them for
1313
+ * that value. Header value formats are unchanged.
1314
+ */
1315
+ readonly responseHeaders?: {
1316
+ /**
1317
+ * Header containing the maximum number of requests in a window.
1318
+ */
1319
+ readonly limit?: string | undefined
1320
+ /**
1321
+ * Header containing the number of requests remaining in a window.
1322
+ */
1323
+ readonly remaining?: string | undefined
1324
+ /**
1325
+ * Header containing the rate limit reset time.
1326
+ */
1327
+ readonly reset?: string | undefined
1328
+ /**
1329
+ * Header containing the number of seconds until the rate limit resets.
1330
+ */
1331
+ readonly resetAfter?: string | undefined
1332
+ /**
1333
+ * Header containing the retry delay for an HTTP `429` response.
1334
+ */
1335
+ readonly retryAfter?: string | undefined
1336
+ } | undefined
1337
+ /**
1338
+ * Disables automatic limit updates, `Retry-After` delays, and adaptive
1339
+ * feedback from response headers. This does not disable automatic HTTP
1340
+ * `429` retries. Set `times` to `0` to disable them.
1304
1341
  */
1305
1342
  readonly disableResponseInspection?: boolean | undefined
1306
1343
  /**
1307
- * Disable adaptive learning from `Retry-After` responses.
1344
+ * Disables adaptive learning from `Retry-After` responses. Response
1345
+ * inspection and direct `Retry-After` delays remain enabled.
1308
1346
  */
1309
1347
  readonly disableAdaptiveLearning?: boolean | undefined
1310
1348
  }
@@ -1319,6 +1357,12 @@ export declare namespace WithRateLimiter {
1319
1357
  * automatically retries HTTP `429` responses (or `HttpClientError` values
1320
1358
  * wrapping a `429` response) by forcing the retry back through the limiter.
1321
1359
  *
1360
+ * **Gotchas**
1361
+ *
1362
+ * Automatic HTTP `429` retries are unlimited unless `times` is specified.
1363
+ * Disabling response inspection does not disable retries; set `times` to `0`
1364
+ * to return or fail with the first `429`.
1365
+ *
1322
1366
  * @category rate limiting
1323
1367
  * @since 4.0.0
1324
1368
  */
@@ -1332,6 +1376,12 @@ export const withRateLimiter: {
1332
1376
  * automatically retries HTTP `429` responses (or `HttpClientError` values
1333
1377
  * wrapping a `429` response) by forcing the retry back through the limiter.
1334
1378
  *
1379
+ * **Gotchas**
1380
+ *
1381
+ * Automatic HTTP `429` retries are unlimited unless `times` is specified.
1382
+ * Disabling response inspection does not disable retries; set `times` to `0`
1383
+ * to return or fail with the first `429`.
1384
+ *
1335
1385
  * @category rate limiting
1336
1386
  * @since 4.0.0
1337
1387
  */
@@ -1347,6 +1397,12 @@ export const withRateLimiter: {
1347
1397
  * automatically retries HTTP `429` responses (or `HttpClientError` values
1348
1398
  * wrapping a `429` response) by forcing the retry back through the limiter.
1349
1399
  *
1400
+ * **Gotchas**
1401
+ *
1402
+ * Automatic HTTP `429` retries are unlimited unless `times` is specified.
1403
+ * Disabling response inspection does not disable retries; set `times` to `0`
1404
+ * to return or fail with the first `429`.
1405
+ *
1350
1406
  * @category rate limiting
1351
1407
  * @since 4.0.0
1352
1408
  */
@@ -1371,6 +1427,7 @@ export const withRateLimiter: {
1371
1427
  ? tokensOption
1372
1428
  : constant(tokensOption ?? 1)
1373
1429
  const adaptiveLearningEnabled = !options.disableAdaptiveLearning
1430
+ const headerNames = resolveRateLimiterHeaderNames(options.responseHeaders)
1374
1431
 
1375
1432
  const getState = (key: string): RateLimiterState => {
1376
1433
  const current = states.get(key)
@@ -1385,13 +1442,13 @@ export const withRateLimiter: {
1385
1442
  ? undefined
1386
1443
  : (clock: Clock, key: string, headers: Headers.Headers, tokens: number) => {
1387
1444
  const current = getState(key)
1388
- const next = parseRateLimiterState(current, clock, headers, tokens)
1445
+ const next = parseRateLimiterState(current, clock, headers, tokens, headerNames)
1389
1446
  if (next.limit !== current.limit || !Duration.equals(next.window, current.window)) {
1390
1447
  states.set(key, next)
1391
1448
  }
1392
1449
  }
1393
1450
 
1394
- return transform(self, function loop(effect, request): Effect.Effect<
1451
+ return transform(self, function loop(effect, request, retries = 0): Effect.Effect<
1395
1452
  HttpClientResponse.HttpClientResponse,
1396
1453
  E | RateLimiter.RateLimiterError,
1397
1454
  R
@@ -1401,11 +1458,11 @@ export const withRateLimiter: {
1401
1458
  const key = resolveKey(request)
1402
1459
  const tokens = Math.max(resolveTokens(request), 1)
1403
1460
  const current = getState(key)
1461
+ const canRetry = options.times === undefined || retries < options.times
1404
1462
  function retry(retryAfter: Duration.Duration | undefined) {
1405
- if (options.disableResponseInspection) return loop(effect, request)
1406
1463
  return retryAfter
1407
- ? Effect.flatMap(Effect.sleep(retryAfter), () => loop(effect, request))
1408
- : loop(effect, request)
1464
+ ? Effect.flatMap(Effect.sleep(retryAfter), () => loop(effect, request, retries + 1))
1465
+ : loop(effect, request, retries + 1)
1409
1466
  }
1410
1467
  const inspectResponse = (
1411
1468
  response: HttpClientResponse.HttpClientResponse,
@@ -1422,12 +1479,18 @@ export const withRateLimiter: {
1422
1479
  * automatically retries HTTP `429` responses (or `HttpClientError` values
1423
1480
  * wrapping a `429` response) by forcing the retry back through the limiter.
1424
1481
  *
1482
+ * **Gotchas**
1483
+ *
1484
+ * Automatic HTTP `429` retries are unlimited unless `times` is specified.
1485
+ * Disabling response inspection does not disable retries; set `times` to `0`
1486
+ * to return or fail with the first `429`.
1487
+ *
1425
1488
  * @category rate limiting
1426
1489
  * @since 4.0.0
1427
1490
  */
1428
1491
  Duration.Duration | undefined>(undefined);
1429
1492
  }
1430
- const retryAfter = parseRetryAfter(clock, getHeader(response.headers, "retry-after"))
1493
+ const retryAfter = parseRetryAfter(clock, getHeader(response.headers, ...headerNames.retryAfter))
1431
1494
  if (retryAfter === undefined) {
1432
1495
  return Effect.succeed</**
1433
1496
  * Applies request rate limiting using the `RateLimiter` service.
@@ -1438,12 +1501,18 @@ export const withRateLimiter: {
1438
1501
  * automatically retries HTTP `429` responses (or `HttpClientError` values
1439
1502
  * wrapping a `429` response) by forcing the retry back through the limiter.
1440
1503
  *
1504
+ * **Gotchas**
1505
+ *
1506
+ * Automatic HTTP `429` retries are unlimited unless `times` is specified.
1507
+ * Disabling response inspection does not disable retries; set `times` to `0`
1508
+ * to return or fail with the first `429`.
1509
+ *
1441
1510
  * @category rate limiting
1442
1511
  * @since 4.0.0
1443
1512
  */
1444
1513
  Duration.Duration | undefined>(undefined);
1445
1514
  }
1446
- const delay = parseRateLimitWindow(clock, response.headers) ?? retryAfter
1515
+ const delay = parseRateLimitWindow(clock, response.headers, headerNames) ?? retryAfter
1447
1516
  if (adaptive === undefined) {
1448
1517
  return Effect.succeed</**
1449
1518
  * Applies request rate limiting using the `RateLimiter` service.
@@ -1454,6 +1523,12 @@ export const withRateLimiter: {
1454
1523
  * automatically retries HTTP `429` responses (or `HttpClientError` values
1455
1524
  * wrapping a `429` response) by forcing the retry back through the limiter.
1456
1525
  *
1526
+ * **Gotchas**
1527
+ *
1528
+ * Automatic HTTP `429` retries are unlimited unless `times` is specified.
1529
+ * Disabling response inspection does not disable retries; set `times` to `0`
1530
+ * to return or fail with the first `429`.
1531
+ *
1457
1532
  * @category rate limiting
1458
1533
  * @since 4.0.0
1459
1534
  */
@@ -1489,7 +1564,7 @@ export const withRateLimiter: {
1489
1564
  const request = Effect.matchEffect(effect, {
1490
1565
  onSuccess(response) {
1491
1566
  return Effect.flatMap(inspectResponse(response, adaptive), (retryAfter) => {
1492
- if (response.status !== 429) return Effect.succeed(response)
1567
+ if (response.status !== 429 || !canRetry) return Effect.succeed(response)
1493
1568
  return retry(retryAfter)
1494
1569
  })
1495
1570
  },
@@ -1497,7 +1572,7 @@ export const withRateLimiter: {
1497
1572
  if (isTooManyRequestsHttpClientError(error)) {
1498
1573
  return Effect.flatMap(
1499
1574
  inspectResponse(error.reason.response, adaptive),
1500
- (retryAfter) => retry(retryAfter)
1575
+ (retryAfter) => canRetry ? retry(retryAfter) : Effect.fail(error)
1501
1576
  )
1502
1577
  }
1503
1578
  return Effect.fail(error)
@@ -1531,6 +1606,34 @@ export const withRateLimiter: {
1531
1606
  });
1532
1607
  })
1533
1608
 
1609
+ interface RateLimiterHeaderNames {
1610
+ readonly limit: ReadonlyArray<string>
1611
+ readonly remaining: ReadonlyArray<string>
1612
+ readonly reset: ReadonlyArray<string>
1613
+ readonly resetAfter: ReadonlyArray<string>
1614
+ readonly retryAfter: ReadonlyArray<string>
1615
+ }
1616
+
1617
+ const resolveRateLimiterHeaderNames = (
1618
+ responseHeaders: WithRateLimiter.Options["responseHeaders"]
1619
+ ): RateLimiterHeaderNames => ({
1620
+ limit: responseHeaders?.limit === undefined
1621
+ ? ["ratelimit-limit", "x-ratelimit-limit"]
1622
+ : [responseHeaders.limit.toLowerCase()],
1623
+ remaining: responseHeaders?.remaining === undefined
1624
+ ? ["ratelimit-remaining", "x-ratelimit-remaining"]
1625
+ : [responseHeaders.remaining.toLowerCase()],
1626
+ reset: responseHeaders?.reset === undefined
1627
+ ? ["ratelimit-reset", "x-ratelimit-reset"]
1628
+ : [responseHeaders.reset.toLowerCase()],
1629
+ resetAfter: responseHeaders?.resetAfter === undefined
1630
+ ? ["ratelimit-reset-after", "x-ratelimit-reset-after"]
1631
+ : [responseHeaders.resetAfter.toLowerCase()],
1632
+ retryAfter: responseHeaders?.retryAfter === undefined
1633
+ ? ["retry-after"]
1634
+ : [responseHeaders.retryAfter.toLowerCase()]
1635
+ })
1636
+
1534
1637
  interface RateLimiterState {
1535
1638
  readonly limit: number
1536
1639
  readonly window: Duration.Duration
@@ -1541,10 +1644,11 @@ const parseRateLimiterState = (
1541
1644
  state: RateLimiterState,
1542
1645
  clock: Clock,
1543
1646
  headers: Headers.Headers,
1544
- tokens: number
1647
+ tokens: number,
1648
+ headerNames: RateLimiterHeaderNames
1545
1649
  ): RateLimiterState => {
1546
- const limit = parseRateLimitLimit(state, headers, tokens) ?? state.limit
1547
- const window = parseRateLimitWindow(clock, headers) ?? state.window
1650
+ const limit = parseRateLimitLimit(state, headers, tokens, headerNames) ?? state.limit
1651
+ const window = parseRateLimitWindow(clock, headers, headerNames) ?? state.window
1548
1652
  if (limit === state.limit && Duration.equals(window, state.window)) {
1549
1653
  return state
1550
1654
  }
@@ -1554,35 +1658,40 @@ const parseRateLimiterState = (
1554
1658
  const parseRateLimitLimit = (
1555
1659
  state: RateLimiterState,
1556
1660
  headers: Headers.Headers,
1557
- tokens: number
1661
+ tokens: number,
1662
+ headerNames: RateLimiterHeaderNames
1558
1663
  ): number | undefined => {
1559
- const raw = getHeader(headers, "ratelimit-limit", "x-ratelimit-limit")
1664
+ const raw = getHeader(headers, ...headerNames.limit)
1560
1665
  const value = parseNumberHeader(raw)
1561
1666
  if (value !== undefined && value > 0) {
1562
1667
  return value
1563
1668
  }
1564
- const remaining = parseRateLimitRemaining(headers)
1669
+ const remaining = parseRateLimitRemaining(headers, headerNames)
1565
1670
  if (remaining === undefined) {
1566
1671
  return undefined
1567
1672
  }
1568
1673
  return state.initial ? remaining + tokens : Math.max(remaining + tokens, state.limit)
1569
1674
  }
1570
1675
 
1571
- const parseRateLimitRemaining = (headers: Headers.Headers): number | undefined => {
1572
- const raw = getHeader(headers, "ratelimit-remaining", "x-ratelimit-remaining")
1676
+ const parseRateLimitRemaining = (
1677
+ headers: Headers.Headers,
1678
+ headerNames: RateLimiterHeaderNames
1679
+ ): number | undefined => {
1680
+ const raw = getHeader(headers, ...headerNames.remaining)
1573
1681
  const value = parseNumberHeader(raw)
1574
1682
  return value !== undefined && value >= 0 ? value : undefined
1575
1683
  }
1576
1684
 
1577
1685
  const parseRateLimitWindow = (
1578
1686
  clock: Clock,
1579
- headers: Headers.Headers
1687
+ headers: Headers.Headers,
1688
+ headerNames: RateLimiterHeaderNames
1580
1689
  ): Duration.Duration | undefined => {
1581
- const resetAfter = parseResetAfter(getHeader(headers, "ratelimit-reset-after", "x-ratelimit-reset-after"))
1690
+ const resetAfter = parseResetAfter(getHeader(headers, ...headerNames.resetAfter))
1582
1691
  if (resetAfter !== undefined) {
1583
1692
  return resetAfter
1584
1693
  }
1585
- return parseResetHeader(clock, getHeader(headers, "ratelimit-reset", "x-ratelimit-reset"))
1694
+ return parseResetHeader(clock, getHeader(headers, ...headerNames.reset))
1586
1695
  }
1587
1696
 
1588
1697
  const parseRetryAfter = (
@@ -299,7 +299,7 @@ export type HttpClientErrorReason = RequestError | ResponseError
299
299
  * @category schemas
300
300
  * @since 4.0.0
301
301
  */
302
- export class HttpClientErrorSchema extends Schema.ErrorClass<HttpClientErrorSchema>(TypeId)({
302
+ export class HttpClientErrorSchema extends Schema.Error<HttpClientErrorSchema>(TypeId)({
303
303
  _tag: Schema.tag("HttpError"),
304
304
  kind: Schema.Literals(
305
305
  [
@@ -28,6 +28,7 @@ import * as Stream from "../../Stream.ts"
28
28
  import * as Headers from "./Headers.ts"
29
29
  import * as HttpBody from "./HttpBody.ts"
30
30
  import { hasBody, type HttpMethod } from "./HttpMethod.ts"
31
+ import * as bodyInternal from "./internal/httpBody.ts"
31
32
  import * as Url from "./Url.ts"
32
33
  import * as UrlParams from "./UrlParams.ts"
33
34
 
@@ -874,25 +875,12 @@ export const setBody: {
874
875
  */
875
876
  (self: HttpClientRequest, body: HttpBody.HttpBody): HttpClientRequest
876
877
  } = dual(2, (self: HttpClientRequest, body: HttpBody.HttpBody): HttpClientRequest => {
877
- let headers = self.headers
878
- if (body._tag === "Empty" || body._tag === "FormData") {
879
- headers = Headers.remove(Headers.remove(headers, "Content-Type"), "Content-length")
880
- } else {
881
- if (body.contentType) {
882
- headers = Headers.set(headers, "content-type", body.contentType)
883
- }
884
- if (body.contentLength !== undefined) {
885
- headers = Headers.set(headers, "content-length", body.contentLength.toString())
886
- } else {
887
- headers = Headers.remove(headers, "content-length")
888
- }
889
- }
890
878
  return makeWith(
891
879
  self.method,
892
880
  self.url,
893
881
  self.urlParams,
894
882
  self.hash,
895
- headers,
883
+ bodyInternal.updateHeaders(self.headers, body),
896
884
  body
897
885
  )
898
886
  })
@@ -355,22 +355,7 @@ class WebHttpClientResponse extends Inspectable.Class implements HttpClientRespo
355
355
 
356
356
  private textBody?: Effect.Effect<string, Error.HttpClientError>
357
357
  get text(): Effect.Effect<string, Error.HttpClientError> {
358
- if (this.textBody) {
359
- return this.textBody
360
- }
361
- this.textBody = Effect.tryPromise({
362
- try: () => this.source.text(),
363
- catch: (cause) =>
364
- new Error.HttpClientError({
365
- reason: new Error.DecodeError({
366
- request: this.request,
367
- response: this,
368
- cause
369
- })
370
- })
371
- }).pipe(Effect.cached, Effect.runSync)
372
- this.arrayBufferBody = Effect.map(this.textBody, (_) => new TextEncoder().encode(_).buffer)
373
- return this.textBody
358
+ return this.textBody ??= Effect.map(this.arrayBuffer, (_) => new TextDecoder().decode(_))
374
359
  }
375
360
 
376
361
  get urlParamsBody(): Effect.Effect<UrlParams.UrlParams, Error.HttpClientError> {
@@ -419,7 +404,6 @@ class WebHttpClientResponse extends Inspectable.Class implements HttpClientRespo
419
404
  })
420
405
  })
421
406
  }).pipe(Effect.cached, Effect.runSync)
422
- this.textBody = Effect.map(this.arrayBufferBody, (_) => new TextDecoder().decode(_))
423
407
  return this.arrayBufferBody
424
408
  }
425
409
 
@@ -161,14 +161,42 @@ export const layer = Layer.effect(HttpPlatform)(
161
161
  { contentLength, headers, status, statusText }
162
162
  )
163
163
  },
164
- fileWebResponse(file, status, statusText, headers, _options) {
165
- return Response.stream(
166
- Stream.fromReadableStream({
164
+ fileWebResponse(file, status, statusText, headers, options) {
165
+ const offset = Number(options?.offset ?? 0)
166
+ const bytesToRead = options?.bytesToRead !== undefined ? Number(options.bytesToRead) : undefined
167
+ const chunkSize = options?.chunkSize !== undefined ? Math.max(1, Number(options.chunkSize)) : Infinity
168
+ const end = offset + (bytesToRead ?? Infinity)
169
+ const stream = end <= offset
170
+ ? Stream.empty
171
+ : Stream.fromReadableStream({
167
172
  evaluate: () => file.stream() as ReadableStream<Uint8Array>,
168
173
  onError: identity
169
- }),
170
- { headers, status, statusText }
171
- )
174
+ }).pipe(
175
+ Stream.mapAccum(
176
+ () => 0,
177
+ (position, bytes) => {
178
+ const next = position + bytes.length
179
+ const start = Math.min(Math.max(offset - position, 0), bytes.length)
180
+ const stop = Math.min(Math.max(end - position, 0), bytes.length)
181
+ const chunks: Array<{ readonly bytes: Uint8Array; readonly done: boolean }> = []
182
+ for (let index = start; index < stop; index += chunkSize) {
183
+ chunks.push({
184
+ bytes: bytes.subarray(index, Math.min(index + chunkSize, stop)),
185
+ done: next >= end && index + chunkSize >= stop
186
+ })
187
+ }
188
+ return [next, chunks]
189
+ }
190
+ ),
191
+ Stream.takeUntil((chunk) => chunk.done),
192
+ Stream.map((chunk) => chunk.bytes)
193
+ )
194
+ return Response.stream(stream, {
195
+ contentLength: bytesToRead ?? file.size - offset,
196
+ headers,
197
+ status,
198
+ statusText
199
+ })
172
200
  }
173
201
  }))
174
202
  ).pipe(Layer.provide(Etag.layerWeak))
@@ -863,25 +863,25 @@ const rawBodyStream = (request: HttpServerRequest, body: unknown): Stream.Stream
863
863
  if (body instanceof Request) {
864
864
  return streamFromReadable(request, body.body)
865
865
  }
866
- if (isFormData(body)) {
867
- return streamFromReadable(request, new Response(body).body)
868
- }
869
866
  if (isReadableStream(body)) {
870
867
  return streamFromReadable(request, body)
871
868
  }
869
+ if (isBodyInit(body)) {
870
+ return streamFromReadable(request, new Response(body).body)
871
+ }
872
872
  return Stream.fail(requestParseError(request, "Unsupported body type"))
873
873
  }
874
874
 
875
875
  const rawBodyBytes = (request: HttpServerRequest, body: unknown): Effect.Effect<Uint8Array, HttpServerError> => {
876
- if (body instanceof Blob) {
877
- return bytesFromBodyInit(request, body)
878
- }
879
876
  if (body instanceof Request) {
880
877
  return Effect.tryPromise({
881
878
  try: () => body.arrayBuffer().then((buffer) => new Uint8Array(buffer)),
882
879
  catch: (cause) => requestParseError(request, undefined, cause)
883
880
  })
884
881
  }
882
+ if (isBodyInit(body)) {
883
+ return bytesFromBodyInit(request, body)
884
+ }
885
885
  return Effect.fail(requestParseError(request, "Unsupported body type"))
886
886
  }
887
887
 
@@ -995,6 +995,14 @@ const isReadableStream = (u: unknown): u is ReadableStream<Uint8Array> =>
995
995
 
996
996
  const isFormData = (u: unknown): u is FormData => typeof FormData !== "undefined" && u instanceof FormData
997
997
 
998
+ const isBodyInit = (u: unknown): u is BodyInit =>
999
+ typeof u === "string" ||
1000
+ (typeof ArrayBuffer !== "undefined" && (u instanceof ArrayBuffer || ArrayBuffer.isView(u))) ||
1001
+ (typeof Blob !== "undefined" && u instanceof Blob) ||
1002
+ isFormData(u) ||
1003
+ (typeof URLSearchParams !== "undefined" && u instanceof URLSearchParams) ||
1004
+ isReadableStream(u)
1005
+
998
1006
  const textDecoder = new TextDecoder()
999
1007
 
1000
1008
  /**
@@ -34,6 +34,7 @@ import * as HttpClientRequest from "./HttpClientRequest.ts"
34
34
  import * as HttpClientResponse from "./HttpClientResponse.ts"
35
35
  import * as HttpIncomingMessage from "./HttpIncomingMessage.ts"
36
36
  import type { HttpPlatform } from "./HttpPlatform.ts"
37
+ import * as bodyInternal from "./internal/httpBody.ts"
37
38
  import * as Template from "./Template.ts"
38
39
  import * as UrlParams from "./UrlParams.ts"
39
40
 
@@ -563,7 +564,7 @@ export const setHeader: {
563
564
  makeResponse({
564
565
  ...self,
565
566
  headers: Headers.set(self.headers, key, value)
566
- })
567
+ }, true)
567
568
  )
568
569
 
569
570
  /**
@@ -623,7 +624,7 @@ export const setHeaders: {
623
624
  makeResponse({
624
625
  ...self,
625
626
  headers: Headers.setAll(self.headers, input)
626
- })
627
+ }, true)
627
628
  )
628
629
 
629
630
  /**
@@ -1204,7 +1205,8 @@ export const setBody: {
1204
1205
  (self: HttpServerResponse, body: Body.HttpBody): HttpServerResponse
1205
1206
  } = dual(
1206
1207
  2,
1207
- (self: HttpServerResponse, body: Body.HttpBody): HttpServerResponse => makeResponse({ ...self, body })
1208
+ (self: HttpServerResponse, body: Body.HttpBody): HttpServerResponse =>
1209
+ makeResponse({ ...self, headers: bodyInternal.updateHeaders(self.headers, body), body })
1208
1210
  )
1209
1211
 
1210
1212
  /**
@@ -1623,7 +1625,7 @@ const makeResponse = (options: {
1623
1625
  readonly headers?: Headers.Headers | undefined
1624
1626
  readonly cookies?: Cookies.Cookies | undefined
1625
1627
  readonly body?: Body.HttpBody | undefined
1626
- }) => {
1628
+ }, preferHeaders = false) => {
1627
1629
  const self = Object.create(Proto) as Mutable<HttpServerResponse>
1628
1630
  self.status = options.status
1629
1631
  self.statusText = options.statusText
@@ -1631,13 +1633,13 @@ const makeResponse = (options: {
1631
1633
  self.body = options.body ?? Body.empty
1632
1634
  if (
1633
1635
  self.body._tag !== "Empty" &&
1634
- (self.body.contentType || self.body.contentLength)
1636
+ (self.body.contentType || self.body.contentLength !== undefined)
1635
1637
  ) {
1636
1638
  const newHeaders = Headers.fromRecordUnsafe({ ...options.headers }) as any
1637
- if (self.body.contentType) {
1639
+ if (self.body.contentType && (!preferHeaders || newHeaders["content-type"] === undefined)) {
1638
1640
  newHeaders["content-type"] = self.body.contentType
1639
1641
  }
1640
- if (self.body.contentLength) {
1642
+ if (self.body.contentLength !== undefined && (!preferHeaders || newHeaders["content-length"] === undefined)) {
1641
1643
  newHeaders["content-length"] = self.body.contentLength.toString()
1642
1644
  }
1643
1645
  self.headers = newHeaders
@@ -34,7 +34,7 @@ import * as UndefinedOr from "../../UndefinedOr.ts"
34
34
  import * as IncomingMessage from "./HttpIncomingMessage.ts"
35
35
  import * as HttpServerRespondable from "./HttpServerRespondable.ts"
36
36
  import * as HttpServerResponse from "./HttpServerResponse.ts"
37
- import * as MP from "./Multipasta.ts"
37
+ import * as MP from "./MultipartParser.ts"
38
38
 
39
39
  /**
40
40
  * Type identifier used to brand multipart part values.
@@ -678,6 +678,8 @@ export const toPersisted = (
678
678
  const path_ = yield* Path.Path
679
679
  const dir = yield* fs.makeTempDirectoryScoped()
680
680
  const persisted: Record<string, Array<PersistedFile> | Array<string> | string> = Object.create(null)
681
+ const usedPaths = new Set<string>()
682
+ let fileIndex = 0
681
683
  yield* Stream.runForEach(stream, (part) => {
682
684
  if (part._tag === "Field") {
683
685
  if (!(part.key in persisted)) {
@@ -692,7 +694,12 @@ export const toPersisted = (
692
694
  return Effect.void
693
695
  }
694
696
  const file = part
695
- const path = path_.join(dir, path_.basename(file.name).slice(-128))
697
+ const fileName = path_.basename(file.name).slice(-128)
698
+ let path = path_.join(dir, fileName)
699
+ while (usedPaths.has(path)) {
700
+ path = path_.join(dir, `${fileIndex++}-${fileName}`)
701
+ }
702
+ usedPaths.add(path)
696
703
  const filePart = new PersistedFileImpl(
697
704
  file.key,
698
705
  file.name,