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,100 +0,0 @@
1
- import * as Cause from "effect/Cause";
2
- import * as Effect from "effect/Effect";
3
- import * as Fiber from "effect/Fiber";
4
- import * as Function from "effect/Function";
5
- import * as Predicate from "effect/Predicate";
6
- import * as Runtime from "effect/Runtime";
7
- import * as Stream from "effect/Stream";
8
- export const isStream = (u) => Predicate.hasProperty(u, Stream.StreamTypeId);
9
- /**
10
- * Patched version of original Stream.toReadableStreamRuntime (v3.14.4) to
11
- * fix an issue in Bun when native stream controller stops working when request
12
- * is terminated by the client:
13
- *
14
- * TypeError: Value of "this" must be of type ReadableStreamDefaultController
15
- *
16
- * See related issues:
17
- * https://github.com/Effect-TS/effect/issues/4538
18
- * https://github.com/oven-sh/bun/issues/17837
19
- */
20
- export const toReadableStreamRuntimePatched = Function.dual((args) => Predicate.hasProperty(args[0], Stream.StreamTypeId) || Effect.isEffect(args[0]), (self, runtime, options) => {
21
- const runFork = Runtime.runFork(runtime);
22
- let currentResolve = undefined;
23
- let fiber = undefined;
24
- const latch = Effect.unsafeMakeLatch(false);
25
- return new ReadableStream({
26
- start(controller) {
27
- fiber = runFork(Stream.runForEachChunk(self, (chunk) => latch.whenOpen(Effect.sync(() => {
28
- latch.unsafeClose();
29
- try {
30
- for (const item of chunk) {
31
- controller.enqueue(item);
32
- }
33
- }
34
- catch (e) {
35
- if (e.message ===
36
- `Value of "this" must be of type ReadableStreamDefaultController`) {
37
- // Do nothing when this happens in Bun.
38
- }
39
- else {
40
- throw e;
41
- }
42
- }
43
- currentResolve();
44
- currentResolve = undefined;
45
- }))));
46
- // --- CHANGES HERE ---
47
- // In original code, we had fiber.addObserver here that called
48
- // error() or close() on controller. This patched version removes it.
49
- },
50
- pull() {
51
- return new Promise((resolve) => {
52
- currentResolve = resolve;
53
- Effect.runSync(latch.open);
54
- });
55
- },
56
- cancel() {
57
- if (!fiber)
58
- return;
59
- return Effect.runPromise(Effect.asVoid(Fiber.interrupt(fiber)));
60
- },
61
- }, options?.strategy);
62
- });
63
- export const toReadableStreamRuntimePatched2 = Function.dual((args) => Predicate.hasProperty(args[0], Stream.StreamTypeId) || Effect.isEffect(args[0]), (self, runtime, options) => {
64
- const runSync = Runtime.runSync(runtime);
65
- const runFork = Runtime.runFork(runtime);
66
- let currentResolve = undefined;
67
- let fiber = undefined;
68
- const latch = Effect.unsafeMakeLatch(false);
69
- return new ReadableStream({
70
- start(controller) {
71
- fiber = runFork(Stream.runForEachChunk(self, (chunk) => latch.whenOpen(Effect.sync(() => {
72
- latch.unsafeClose();
73
- for (const item of chunk) {
74
- controller.enqueue(item);
75
- }
76
- currentResolve();
77
- currentResolve = undefined;
78
- }))));
79
- fiber.addObserver((exit) => {
80
- if (exit._tag === "Failure") {
81
- controller.error(Cause.squash(exit.cause));
82
- }
83
- else {
84
- controller.close();
85
- }
86
- });
87
- },
88
- pull() {
89
- return new Promise((resolve) => {
90
- currentResolve = resolve;
91
- Effect.runSync(latch.open);
92
- });
93
- },
94
- cancel() {
95
- if (!fiber)
96
- return;
97
- return Effect.runPromise(Effect.asVoid(Fiber.interrupt(fiber)));
98
- },
99
- }, options?.strategy);
100
- });
package/dist/System.d.ts DELETED
@@ -1,7 +0,0 @@
1
- import * as Effect from "effect/Effect";
2
- import type * as Scope from "effect/Scope";
3
- import * as ChildProcess from "./ChildProcess.ts";
4
- import * as PlatformError from "./PlatformError.ts";
5
- export declare const cwd: Effect.Effect<string>;
6
- export declare const which: (name: string) => Effect.Effect<string, PlatformError.SystemError>;
7
- export declare const spawn: (command: string, args?: ReadonlyArray<string>, options?: ChildProcess.Command.Options) => Effect.Effect<ChildProcess.ChildProcessHandle, PlatformError.PlatformError, ChildProcess.ChildProcessSpawner | Scope.Scope>;
package/dist/System.js DELETED
@@ -1,22 +0,0 @@
1
- import * as Effect from "effect/Effect";
2
- import * as ChildProcess from "./ChildProcess.js";
3
- import * as PlatformError from "./PlatformError.js";
4
- export const cwd = Effect.sync(() => process.cwd());
5
- export const which = (name) => Effect.flatMap(Effect.try({
6
- try: () => Bun.which(name),
7
- catch: (err) => new PlatformError.SystemError({
8
- reason: "Unknown",
9
- module: "System",
10
- method: "which",
11
- description: err instanceof Error ? err.message : `Failed to look up "${name}"`,
12
- cause: err,
13
- }),
14
- }), (path) => path === null
15
- ? Effect.fail(new PlatformError.SystemError({
16
- reason: "NotFound",
17
- module: "System",
18
- method: "which",
19
- description: `Executable not found: "${name}"`,
20
- }))
21
- : Effect.succeed(path));
22
- export const spawn = (command, args, options) => ChildProcess.spawn(ChildProcess.make(command, args, options));
@@ -1,9 +0,0 @@
1
- export type PathTuple = ReadonlyArray<string | [string, string?, string?] | [[string]]>;
2
- export declare function format(tuple: PathTuple): `/${string}`;
3
- export declare function toColon(tuple: PathTuple): string;
4
- export declare const toHono: typeof toColon;
5
- export declare function toExpress(tuple: PathTuple): string;
6
- export declare const toEffect: typeof toColon;
7
- export declare function toURLPattern(tuple: PathTuple): string;
8
- export declare function toRemix(tuple: PathTuple): string;
9
- export declare const toBun: typeof toColon;
@@ -1,68 +0,0 @@
1
- export function format(tuple) {
2
- return ("/" +
3
- tuple
4
- .map((el) => {
5
- if (typeof el === "string")
6
- return el;
7
- if (Array.isArray(el[0]))
8
- return "[[" + el[0][0] + "]]";
9
- const [name, suffix, prefix] = el;
10
- return (prefix ?? "") + "[" + name + "]" + (suffix ?? "");
11
- })
12
- .join("/"));
13
- }
14
- export function toColon(tuple) {
15
- return ("/" +
16
- tuple
17
- .map((el) => {
18
- if (typeof el === "string")
19
- return el;
20
- if (Array.isArray(el[0]))
21
- return "*";
22
- const [name, suffix, prefix] = el;
23
- return (prefix ?? "") + ":" + name + (suffix ?? "");
24
- })
25
- .join("/"));
26
- }
27
- export const toHono = toColon;
28
- export function toExpress(tuple) {
29
- return ("/" +
30
- tuple
31
- .map((el) => {
32
- if (typeof el === "string")
33
- return el;
34
- if (Array.isArray(el[0]))
35
- return "*" + el[0][0];
36
- const [name, suffix, prefix] = el;
37
- return (prefix ?? "") + ":" + name + (suffix ?? "");
38
- })
39
- .join("/"));
40
- }
41
- export const toEffect = toColon;
42
- export function toURLPattern(tuple) {
43
- return ("/" +
44
- tuple
45
- .map((el) => {
46
- if (typeof el === "string")
47
- return el;
48
- if (Array.isArray(el[0]))
49
- return ":" + el[0][0] + "+";
50
- const [name, suffix, prefix] = el;
51
- return (prefix ?? "") + ":" + name + (suffix ?? "");
52
- })
53
- .join("/"));
54
- }
55
- export function toRemix(tuple) {
56
- return ("/" +
57
- tuple
58
- .map((el) => {
59
- if (typeof el === "string")
60
- return el;
61
- if (Array.isArray(el[0]))
62
- return "$";
63
- const [name, suffix, prefix] = el;
64
- return (prefix ?? "") + "$" + name + (suffix ?? "");
65
- })
66
- .join("/"));
67
- }
68
- export const toBun = toColon;
package/dist/Unique.d.ts DELETED
@@ -1,50 +0,0 @@
1
- export declare const ALPHABET_BASE32_CROCKFORD = "0123456789ABCDEFGHJKMNPQRSTVWXYZ";
2
- export declare const ALPHABET_BASE32_RFC4648 = "ABCDEFGHIJKLMNOPQRSTUVWXYZ234567";
3
- export declare const ALPHABET_BASE64_URL = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_";
4
- export declare const ALPHABET_HEX = "0123456789abcdef";
5
- /**
6
- * Generate a random string for ids, session tokens, and API keys.
7
- * It uses human-friendly crockford base32 encoding (5 bit of entropy per char)
8
- *
9
- * Minimal recommended length:
10
- * - public ids: 16 chars (~80 bits)
11
- * - API keys: 32 chars (~160 bits)
12
- * - session tokens: 32-40 chars (~160-200 bits)
13
- */
14
- export declare function token(length?: number): string;
15
- export declare function bytes(length: number): Uint8Array;
16
- export declare const UUID_NIL = "00000000-0000-0000-0000-000000000000";
17
- export declare function uuid4(): string;
18
- export declare function uuid7(time?: number): string;
19
- /**
20
- * Decode a 48-bit Unix timestamp (ms) from UUID7 or ULID.
21
- *
22
- * @example
23
- * const bytes = Unique.uuid7Bytes()
24
- * const timestamp = Unique.toTimestamp(bytes)
25
- *
26
- * @example
27
- * const bytes = Unique.ulidBytes()
28
- * const timestamp = Unique.toTimestamp(bytes)
29
- */
30
- export declare function toTimestamp(bytes: Uint8Array): number;
31
- export declare function uuid7Bytes(time?: number): Uint8Array;
32
- /**
33
- * Convert UUID bytes to canonical (RFC9562) representation.
34
- *
35
- * @example
36
- * Unique.formatUuid(new Uint8Array(16))
37
- */
38
- export declare function formatUuid(bytes: Uint8Array): string;
39
- export declare function ulid(time?: number): string;
40
- export declare function ulidBytes(time?: number): Uint8Array;
41
- /**
42
- * Generate a nanoid-style random string.
43
- *
44
- * FUN_FACT: Original nanoid implementation uses base64url alphabet
45
- * with non-standard custom order where charater form common words found
46
- * in source code (like use, random, strict) to make gzip/brotli more efficient.
47
- * It's qt lil opt from the times where web developers
48
- * were competing to have the smallest possible bundle size.
49
- */
50
- export declare function nanoid(size?: number, alphabet?: string): string;
package/dist/Unique.js DELETED
@@ -1,187 +0,0 @@
1
- export const ALPHABET_BASE32_CROCKFORD = "0123456789ABCDEFGHJKMNPQRSTVWXYZ";
2
- export const ALPHABET_BASE32_RFC4648 = "ABCDEFGHIJKLMNOPQRSTUVWXYZ234567";
3
- export const ALPHABET_BASE64_URL = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_";
4
- export const ALPHABET_HEX = "0123456789abcdef";
5
- /**
6
- * Generate a random string for ids, session tokens, and API keys.
7
- * It uses human-friendly crockford base32 encoding (5 bit of entropy per char)
8
- *
9
- * Minimal recommended length:
10
- * - public ids: 16 chars (~80 bits)
11
- * - API keys: 32 chars (~160 bits)
12
- * - session tokens: 32-40 chars (~160-200 bits)
13
- */
14
- export function token(length = 32) {
15
- if (length <= 0)
16
- return "";
17
- const buf = new Uint8Array(length);
18
- crypto.getRandomValues(buf);
19
- let result = "";
20
- for (let i = 0; i < buf.length; i++) {
21
- result += ALPHABET_BASE32_CROCKFORD[buf[i] & 31];
22
- }
23
- return result;
24
- }
25
- export function bytes(length) {
26
- const buf = new Uint8Array(length);
27
- crypto.getRandomValues(buf);
28
- return buf;
29
- }
30
- export const UUID_NIL = "00000000-0000-0000-0000-000000000000";
31
- export function uuid4() {
32
- return formatUuid(uuid4bytes());
33
- }
34
- export function uuid7(time = Date.now()) {
35
- return formatUuid(uuid7Bytes(time));
36
- }
37
- function uuid4bytes() {
38
- const buf = bytes(16);
39
- buf[6] = (buf[6] & 0x0f) | 0x40; // version 4
40
- buf[8] = (buf[8] & 0x3f) | 0x80; // variant
41
- return buf;
42
- }
43
- /**
44
- * Decode a 48-bit Unix timestamp (ms) from UUID7 or ULID.
45
- *
46
- * @example
47
- * const bytes = Unique.uuid7Bytes()
48
- * const timestamp = Unique.toTimestamp(bytes)
49
- *
50
- * @example
51
- * const bytes = Unique.ulidBytes()
52
- * const timestamp = Unique.toTimestamp(bytes)
53
- */
54
- export function toTimestamp(bytes) {
55
- if (bytes.length < 6)
56
- return 0;
57
- return (bytes[0] * 0x10000000000 +
58
- bytes[1] * 0x100000000 +
59
- bytes[2] * 0x1000000 +
60
- bytes[3] * 0x10000 +
61
- bytes[4] * 0x100 +
62
- bytes[5]);
63
- }
64
- export function uuid7Bytes(time = Date.now()) {
65
- const buf = new Uint8Array(16);
66
- const timestamp = BigInt(toSafeTime(time));
67
- // 48-bit timestamp (6 bytes)
68
- buf[0] = Number((timestamp >> 40n) & 0xffn);
69
- buf[1] = Number((timestamp >> 32n) & 0xffn);
70
- buf[2] = Number((timestamp >> 24n) & 0xffn);
71
- buf[3] = Number((timestamp >> 16n) & 0xffn);
72
- buf[4] = Number((timestamp >> 8n) & 0xffn);
73
- buf[5] = Number(timestamp & 0xffn);
74
- // 12-bit random A (1.5 bytes)
75
- crypto.getRandomValues(buf.subarray(6, 8));
76
- buf[6] = (buf[6] & 0x0f) | 0x70; // version 7
77
- // 2-bit variant + 62-bit random B (8 bytes)
78
- crypto.getRandomValues(buf.subarray(8, 16));
79
- buf[8] = (buf[8] & 0x3f) | 0x80; // variant
80
- return buf;
81
- }
82
- /**
83
- * Convert UUID bytes to canonical (RFC9562) representation.
84
- *
85
- * @example
86
- * Unique.formatUuid(new Uint8Array(16))
87
- */
88
- export function formatUuid(bytes) {
89
- if (bytes.length === 0)
90
- return "";
91
- let result = "";
92
- for (let i = 0; i < bytes.length; i++) {
93
- const byte = bytes[i];
94
- result += ALPHABET_HEX[(byte >> 4) & 0x0f];
95
- result += ALPHABET_HEX[byte & 0x0f];
96
- if (i === 3 || i === 5 || i === 7 || i === 9)
97
- result += "-";
98
- }
99
- return result;
100
- }
101
- export function ulid(time = Date.now()) {
102
- const bytes = ulidBytes(time);
103
- return formatUlid(bytes);
104
- }
105
- export function ulidBytes(time = Date.now()) {
106
- const buf = new Uint8Array(16);
107
- const timestamp = BigInt(toSafeTime(time));
108
- buf[0] = Number((timestamp >> 40n) & 0xffn);
109
- buf[1] = Number((timestamp >> 32n) & 0xffn);
110
- buf[2] = Number((timestamp >> 24n) & 0xffn);
111
- buf[3] = Number((timestamp >> 16n) & 0xffn);
112
- buf[4] = Number((timestamp >> 8n) & 0xffn);
113
- buf[5] = Number(timestamp & 0xffn);
114
- crypto.getRandomValues(buf.subarray(6, 16));
115
- return buf;
116
- }
117
- function formatUlid(bytes) {
118
- if (bytes.length !== 16)
119
- return "";
120
- const timestamp = toTimestamp(bytes);
121
- const timePart = encodeUlidTime(timestamp);
122
- const randomPart = toBase32(bytes.subarray(6, 16));
123
- return `${timePart}${randomPart}`;
124
- }
125
- function encodeUlidTime(time) {
126
- let value = BigInt(time);
127
- const result = Array.from({ length: 10 });
128
- for (let i = 9; i >= 0; i--) {
129
- result[i] = ALPHABET_BASE32_CROCKFORD[Number(value & 31n)];
130
- value >>= 5n;
131
- }
132
- return result.join("");
133
- }
134
- function toSafeTime(time) {
135
- if (!Number.isFinite(time))
136
- return 0;
137
- return Math.max(0, Math.trunc(time));
138
- }
139
- /**
140
- * Generate a nanoid-style random string.
141
- *
142
- * FUN_FACT: Original nanoid implementation uses base64url alphabet
143
- * with non-standard custom order where charater form common words found
144
- * in source code (like use, random, strict) to make gzip/brotli more efficient.
145
- * It's qt lil opt from the times where web developers
146
- * were competing to have the smallest possible bundle size.
147
- */
148
- export function nanoid(size = 21, alphabet = ALPHABET_BASE64_URL) {
149
- if (size <= 0 || alphabet.length === 0)
150
- return "";
151
- const length = alphabet.length;
152
- const mask = (2 << Math.floor(Math.log2(length - 1))) - 1;
153
- const step = Math.ceil((1.6 * mask * size) / length);
154
- let id = "";
155
- while (id.length < size) {
156
- const bytes = new Uint8Array(step);
157
- crypto.getRandomValues(bytes);
158
- for (let i = 0; i < step && id.length < size; i++) {
159
- const index = bytes[i] & mask;
160
- if (index < length)
161
- id += alphabet[index];
162
- }
163
- }
164
- return id;
165
- }
166
- function toBase32(bytes, alphabet = ALPHABET_BASE32_CROCKFORD) {
167
- if (bytes.length === 0)
168
- return "";
169
- let result = "";
170
- let buffer = 0;
171
- let bits = 0;
172
- for (const byte of bytes) {
173
- buffer = (buffer << 8) | byte;
174
- bits += 8;
175
- while (bits >= 5) {
176
- bits -= 5;
177
- const index = (buffer >> bits) & 31;
178
- result += alphabet[index];
179
- buffer &= (1 << bits) - 1;
180
- }
181
- }
182
- if (bits > 0) {
183
- const index = (buffer << (5 - bits)) & 31;
184
- result += alphabet[index];
185
- }
186
- return result;
187
- }
package/dist/Values.d.ts DELETED
@@ -1,27 +0,0 @@
1
- type JsonPrimitives = string | number | boolean | null;
2
- export type JsonObject = {
3
- [key: string]: Json | undefined;
4
- };
5
- export type Json = JsonPrimitives | Json[] | JsonObject;
6
- export declare function isPlainObject(value: unknown): value is Record<string, unknown>;
7
- /**
8
- * Type helper that returns `true` if type T has any method properties,
9
- * otherwise returns `never`.
10
- *
11
- * Used internally by IsPlainObject to distinguish plain objects from
12
- * class instances or objects with methods.
13
- */
14
- type HasMethod<T> = {
15
- [K in keyof T]: T[K] extends (...args: Array<any>) => any ? true : never;
16
- }[keyof T];
17
- export type IsPlainObject<T> = T extends object ? T extends Function ? false : HasMethod<T> extends never ? true : false : false;
18
- export type Simplify<T> = {
19
- -readonly [K in keyof T]: IsPlainObject<T[K]> extends true ? {
20
- -readonly [P in keyof T[K]]: T[K][P];
21
- } : T[K];
22
- } extends infer U ? {
23
- [K in keyof U]: U[K];
24
- } : never;
25
- export declare const firstValue: <T>(record: Record<string, T>) => T | undefined;
26
- export declare const concatBytes: (a: Uint8Array, b: Uint8Array) => Uint8Array;
27
- export {};
package/dist/Values.js DELETED
@@ -1,36 +0,0 @@
1
- export function isPlainObject(value) {
2
- if (value === null || typeof value !== "object") {
3
- return false;
4
- }
5
- // Check for built-in types and web APIs
6
- if (ArrayBuffer.isView(value) ||
7
- value instanceof ArrayBuffer ||
8
- value instanceof Blob ||
9
- value instanceof FormData ||
10
- value instanceof URLSearchParams ||
11
- value instanceof ReadableStream ||
12
- value instanceof Date ||
13
- value instanceof Map ||
14
- value instanceof Set ||
15
- value instanceof RegExp ||
16
- value instanceof Error ||
17
- value instanceof Promise ||
18
- Array.isArray(value)) {
19
- return false;
20
- }
21
- // Check if it's a plain object (Object.prototype or null prototype)
22
- const proto = Object.getPrototypeOf(value);
23
- return proto === null || proto === Object.prototype;
24
- }
25
- export const firstValue = (record) => {
26
- for (const key in record) {
27
- return record[key];
28
- }
29
- return undefined;
30
- };
31
- export const concatBytes = (a, b) => {
32
- const result = new Uint8Array(a.byteLength + b.byteLength);
33
- result.set(a);
34
- result.set(b, a.byteLength);
35
- return result;
36
- };
@@ -1,6 +0,0 @@
1
- import * as Layer from "effect/Layer";
2
- import { BlobStore as BlobStoreTag } from "../BlobStore.ts";
3
- export interface DiskConfig {
4
- readonly directory?: string;
5
- }
6
- export declare const layer: (config?: DiskConfig) => Layer.Layer<BlobStoreTag>;
@@ -1,116 +0,0 @@
1
- import * as Chunk from "effect/Chunk";
2
- import * as Effect from "effect/Effect";
3
- import * as Layer from "effect/Layer";
4
- import * as Option from "effect/Option";
5
- import * as Stream from "effect/Stream";
6
- import * as NFS from "node:fs";
7
- import * as NPath from "node:path";
8
- import { BlobStore as BlobStoreTag } from "../BlobStore.js";
9
- import * as PlatformError from "../PlatformError.js";
10
- import { handleErrnoException } from "../node/NodeFileSystem.js";
11
- const handleBadArgument = (method) => (cause) => new PlatformError.BadArgument({
12
- module: "BlobStore",
13
- method,
14
- cause,
15
- });
16
- const handleErrno = (method) => handleErrnoException("BlobStore", method);
17
- const tryPromise = (method, path, promise) => Effect.tryPromise({
18
- try: promise,
19
- catch: (err) => {
20
- if (err instanceof Error && "code" in err) {
21
- return handleErrno(method)(err, [path]);
22
- }
23
- return handleBadArgument(method)(err);
24
- },
25
- });
26
- const validatePath = (directory, key) => {
27
- const resolved = NPath.resolve(directory, key);
28
- const root = NPath.resolve(directory);
29
- if (resolved !== root && !resolved.startsWith(root + NPath.sep)) {
30
- return Effect.fail(new PlatformError.BadArgument({
31
- module: "BlobStore",
32
- method: "ref",
33
- description: `Path traversal: key "${key}" escapes directory "${directory}"`,
34
- }));
35
- }
36
- return Effect.succeed(resolved);
37
- };
38
- const makeRef = (directory, path, key, begin, end) => {
39
- const getFile = () => {
40
- const f = Bun.file(path);
41
- return begin !== undefined || end !== undefined ? f.slice(begin, end) : f;
42
- };
43
- return {
44
- key,
45
- bytes: tryPromise("bytes", path, () => getFile().bytes()),
46
- text: tryPromise("text", path, () => getFile().text()),
47
- json: tryPromise("json", path, () => getFile().json()),
48
- stat: Effect.flatMap(tryPromise("stat", path, () => Bun.file(path).stat()), (s) => Effect.succeed({
49
- size: s.size,
50
- lastModified: Option.fromNullable(s.mtime),
51
- etag: Option.none(),
52
- type: Option.fromNullable(Bun.file(path).type || null),
53
- })),
54
- exists: tryPromise("exists", path, () => Bun.file(path).exists()),
55
- delete: tryPromise("delete", path, () => NFS.promises.unlink(path)),
56
- stream: Stream.fromReadableStream(() => getFile().stream(), (err) => {
57
- if (err instanceof Error && "code" in err) {
58
- return handleErrno("stream")(err, [path]);
59
- }
60
- return handleBadArgument("stream")(err);
61
- }),
62
- write: (data) => tryPromise("write", path, () => Bun.write(path, data, { createPath: true }).then(() => undefined)),
63
- slice: (b, e) => makeRef(directory, path, key, b, e),
64
- };
65
- };
66
- const listEntries = (directory, options) => {
67
- const baseDir = options?.prefix
68
- ? NPath.join(directory, options.prefix)
69
- : directory;
70
- return Stream.fromEffect(Effect.tryPromise({
71
- try: async () => {
72
- try {
73
- const entries = await NFS.promises.readdir(baseDir, {
74
- recursive: true,
75
- withFileTypes: true,
76
- });
77
- return entries
78
- .filter((e) => e.isFile())
79
- .map((e) => {
80
- const rel = NPath.join(e.parentPath, e.name);
81
- const key = NPath.relative(directory, rel);
82
- return {
83
- key,
84
- size: Option.none(),
85
- lastModified: Option.none(),
86
- etag: Option.none(),
87
- };
88
- });
89
- }
90
- catch (err) {
91
- if (err instanceof Error && "code" in err && err.code === "ENOENT") {
92
- return [];
93
- }
94
- throw err;
95
- }
96
- },
97
- catch: (err) => {
98
- if (err instanceof Error && "code" in err) {
99
- return handleErrno("list")(err, [baseDir]);
100
- }
101
- return handleBadArgument("list")(err);
102
- },
103
- })).pipe(Stream.flatMap((entries) => Stream.fromChunk(Chunk.fromIterable(entries))));
104
- };
105
- export const layer = (config) => {
106
- const directory = config?.directory ?? "/";
107
- return Layer.succeed(BlobStoreTag, {
108
- ref: (key) => Effect.map(validatePath(directory, key), (path) => makeRef(directory, path, key)),
109
- list: (options) => listEntries(directory, options),
110
- presign: (_key, _options) => Effect.fail(new PlatformError.BadArgument({
111
- module: "BlobStore",
112
- method: "presign",
113
- description: "Presigned URLs are not supported for disk storage",
114
- })),
115
- });
116
- };
@@ -1,11 +0,0 @@
1
- import * as Layer from "effect/Layer";
2
- import { BlobStore as BlobStoreTag } from "../BlobStore.ts";
3
- export interface S3Config {
4
- readonly bucket?: string;
5
- readonly endpoint?: string;
6
- readonly region?: string;
7
- readonly accessKeyId?: string;
8
- readonly secretAccessKey?: string;
9
- readonly sessionToken?: string;
10
- }
11
- export declare const layer: (config?: S3Config) => Layer.Layer<BlobStoreTag>;