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,39 +0,0 @@
1
- import * as FileSystem from "./FileSystem.ts";
2
- import * as Context from "effect/Context";
3
- import * as Effect from "effect/Effect";
4
- import * as Layer from "effect/Layer";
5
- import * as PubSub from "effect/PubSub";
6
- import * as Stream from "effect/Stream";
7
- import type * as PlatformError from "./PlatformError.ts";
8
- export type DevelopmentEvent = FileSystem.WatchEvent | {
9
- readonly _tag: "Reload";
10
- };
11
- /** @internal */
12
- export declare const _resetForTesting: () => void;
13
- export type DevelopmentService = {
14
- events: PubSub.PubSub<DevelopmentEvent>;
15
- };
16
- declare const Development_base: Context.TagClass<Development, "effect-start/Development", DevelopmentService>;
17
- export declare class Development extends Development_base {
18
- }
19
- export declare const filterSourceFiles: (event: FileSystem.WatchEvent) => boolean;
20
- export declare const filterDirectory: (event: FileSystem.WatchEvent) => boolean;
21
- export declare const watchSource: (opts?: {
22
- path?: string;
23
- recursive?: boolean;
24
- filter?: (event: FileSystem.WatchEvent) => boolean;
25
- }) => Stream.Stream<FileSystem.WatchEvent, PlatformError.PlatformError, FileSystem.FileSystem>;
26
- export declare const watch: (opts?: {
27
- path?: string;
28
- recursive?: boolean;
29
- filter?: (event: FileSystem.WatchEvent) => boolean;
30
- }) => Effect.Effect<{
31
- events: PubSub.PubSub<DevelopmentEvent>;
32
- }, never, FileSystem.FileSystem>;
33
- export declare const layerWatch: (opts?: {
34
- path?: string;
35
- recursive?: boolean;
36
- filter?: (event: FileSystem.WatchEvent) => boolean;
37
- }) => Layer.Layer<Development, never, FileSystem.FileSystem>;
38
- export declare const stream: () => Stream.Stream<DevelopmentEvent>;
39
- export {};
@@ -1,58 +0,0 @@
1
- import * as FileSystem from "./FileSystem.js";
2
- import * as Context from "effect/Context";
3
- import * as Effect from "effect/Effect";
4
- import * as Function from "effect/Function";
5
- import * as GlobalValue from "effect/GlobalValue";
6
- import * as Layer from "effect/Layer";
7
- import * as Option from "effect/Option";
8
- import * as PubSub from "effect/PubSub";
9
- import * as Stream from "effect/Stream";
10
- const devState = GlobalValue.globalValue(Symbol.for("effect-start/Development"), () => ({
11
- count: 0,
12
- pubsub: null,
13
- }));
14
- /** @internal */
15
- export const _resetForTesting = () => {
16
- devState.count = 0;
17
- devState.pubsub = null;
18
- };
19
- export class Development extends Context.Tag("effect-start/Development")() {
20
- }
21
- const SOURCE_FILENAME = /\.(tsx?|jsx?|html?|css|json)$/;
22
- export const filterSourceFiles = (event) => {
23
- return SOURCE_FILENAME.test(event.path);
24
- };
25
- export const filterDirectory = (event) => {
26
- return event.path.endsWith("/");
27
- };
28
- export const watchSource = (opts) => {
29
- const baseDir = opts?.path ?? process.cwd();
30
- const customFilter = opts?.filter;
31
- return Function.pipe(Stream.unwrap(Effect.map(FileSystem.FileSystem, (fs) => fs.watch(baseDir, { recursive: opts?.recursive ?? true }))), customFilter ? Stream.filter(customFilter) : Function.identity, Stream.rechunk(1), Stream.throttle({
32
- units: 1,
33
- cost: () => 1,
34
- duration: "400 millis",
35
- strategy: "enforce",
36
- }));
37
- };
38
- export const watch = (opts) => Effect.gen(function* () {
39
- devState.count++;
40
- if (devState.count === 1) {
41
- const pubsub = yield* PubSub.unbounded();
42
- devState.pubsub = pubsub;
43
- yield* Function.pipe(watchSource({
44
- path: opts?.path,
45
- recursive: opts?.recursive,
46
- filter: opts?.filter ?? filterSourceFiles,
47
- }), Stream.runForEach((event) => PubSub.publish(pubsub, event)), Effect.fork);
48
- }
49
- else {
50
- yield* PubSub.publish(devState.pubsub, { _tag: "Reload" });
51
- }
52
- return { events: devState.pubsub };
53
- });
54
- export const layerWatch = (opts) => Layer.scoped(Development, watch(opts));
55
- export const stream = () => Stream.unwrap(Function.pipe(Effect.serviceOption(Development), Effect.map(Option.match({
56
- onNone: () => Stream.empty,
57
- onSome: (dev) => Stream.fromPubSub(dev.events),
58
- }))));
@@ -1,209 +0,0 @@
1
- import * as Effect from "effect/Effect";
2
- interface Callback<E, A> {
3
- (err: E, a?: A): void;
4
- }
5
- type ArgsWithCallback<Args extends Array<any>, E, A> = [...args: Args, cb: Callback<E, A>];
6
- type WithoutNull<A> = unknown extends A ? void : Exclude<A, null | undefined>;
7
- type Effectify<T, E> = T extends {
8
- (...args: ArgsWithCallback<infer Args1, infer _E1, infer A1>): infer _R1;
9
- (...args: ArgsWithCallback<infer Args2, infer _E2, infer A2>): infer _R2;
10
- (...args: ArgsWithCallback<infer Args3, infer _E3, infer A3>): infer _R3;
11
- (...args: ArgsWithCallback<infer Args4, infer _E4, infer A4>): infer _R4;
12
- (...args: ArgsWithCallback<infer Args5, infer _E5, infer A5>): infer _R5;
13
- (...args: ArgsWithCallback<infer Args6, infer _E6, infer A6>): infer _R6;
14
- (...args: ArgsWithCallback<infer Args7, infer _E7, infer A7>): infer _R7;
15
- (...args: ArgsWithCallback<infer Args8, infer _E8, infer A8>): infer _R8;
16
- (...args: ArgsWithCallback<infer Args9, infer _E9, infer A9>): infer _R9;
17
- (...args: ArgsWithCallback<infer Args10, infer _E10, infer A10>): infer _R10;
18
- } ? {
19
- (...args: Args1): Effect.Effect<WithoutNull<A1>, E>;
20
- (...args: Args2): Effect.Effect<WithoutNull<A2>, E>;
21
- (...args: Args3): Effect.Effect<WithoutNull<A3>, E>;
22
- (...args: Args4): Effect.Effect<WithoutNull<A4>, E>;
23
- (...args: Args5): Effect.Effect<WithoutNull<A5>, E>;
24
- (...args: Args6): Effect.Effect<WithoutNull<A6>, E>;
25
- (...args: Args7): Effect.Effect<WithoutNull<A7>, E>;
26
- (...args: Args8): Effect.Effect<WithoutNull<A8>, E>;
27
- (...args: Args9): Effect.Effect<WithoutNull<A9>, E>;
28
- (...args: Args10): Effect.Effect<WithoutNull<A10>, E>;
29
- } : T extends {
30
- (...args: ArgsWithCallback<infer Args1, infer _E1, infer A1>): infer _R1;
31
- (...args: ArgsWithCallback<infer Args2, infer _E2, infer A2>): infer _R2;
32
- (...args: ArgsWithCallback<infer Args3, infer _E3, infer A3>): infer _R3;
33
- (...args: ArgsWithCallback<infer Args4, infer _E4, infer A4>): infer _R4;
34
- (...args: ArgsWithCallback<infer Args5, infer _E5, infer A5>): infer _R5;
35
- (...args: ArgsWithCallback<infer Args6, infer _E6, infer A6>): infer _R6;
36
- (...args: ArgsWithCallback<infer Args7, infer _E7, infer A7>): infer _R7;
37
- (...args: ArgsWithCallback<infer Args8, infer _E8, infer A8>): infer _R8;
38
- (...args: ArgsWithCallback<infer Args9, infer _E9, infer A9>): infer _R9;
39
- } ? {
40
- (...args: Args1): Effect.Effect<WithoutNull<A1>, E>;
41
- (...args: Args2): Effect.Effect<WithoutNull<A2>, E>;
42
- (...args: Args3): Effect.Effect<WithoutNull<A3>, E>;
43
- (...args: Args4): Effect.Effect<WithoutNull<A4>, E>;
44
- (...args: Args5): Effect.Effect<WithoutNull<A5>, E>;
45
- (...args: Args6): Effect.Effect<WithoutNull<A6>, E>;
46
- (...args: Args7): Effect.Effect<WithoutNull<A7>, E>;
47
- (...args: Args8): Effect.Effect<WithoutNull<A8>, E>;
48
- (...args: Args9): Effect.Effect<WithoutNull<A9>, E>;
49
- } : T extends {
50
- (...args: ArgsWithCallback<infer Args1, infer _E1, infer A1>): infer _R1;
51
- (...args: ArgsWithCallback<infer Args2, infer _E2, infer A2>): infer _R2;
52
- (...args: ArgsWithCallback<infer Args3, infer _E3, infer A3>): infer _R3;
53
- (...args: ArgsWithCallback<infer Args4, infer _E4, infer A4>): infer _R4;
54
- (...args: ArgsWithCallback<infer Args5, infer _E5, infer A5>): infer _R5;
55
- (...args: ArgsWithCallback<infer Args6, infer _E6, infer A6>): infer _R6;
56
- (...args: ArgsWithCallback<infer Args7, infer _E7, infer A7>): infer _R7;
57
- (...args: ArgsWithCallback<infer Args8, infer _E8, infer A8>): infer _R8;
58
- } ? {
59
- (...args: Args1): Effect.Effect<WithoutNull<A1>, E>;
60
- (...args: Args2): Effect.Effect<WithoutNull<A2>, E>;
61
- (...args: Args3): Effect.Effect<WithoutNull<A3>, E>;
62
- (...args: Args4): Effect.Effect<WithoutNull<A4>, E>;
63
- (...args: Args5): Effect.Effect<WithoutNull<A5>, E>;
64
- (...args: Args6): Effect.Effect<WithoutNull<A6>, E>;
65
- (...args: Args7): Effect.Effect<WithoutNull<A7>, E>;
66
- (...args: Args8): Effect.Effect<WithoutNull<A8>, E>;
67
- } : T extends {
68
- (...args: ArgsWithCallback<infer Args1, infer _E1, infer A1>): infer _R1;
69
- (...args: ArgsWithCallback<infer Args2, infer _E2, infer A2>): infer _R2;
70
- (...args: ArgsWithCallback<infer Args3, infer _E3, infer A3>): infer _R3;
71
- (...args: ArgsWithCallback<infer Args4, infer _E4, infer A4>): infer _R4;
72
- (...args: ArgsWithCallback<infer Args5, infer _E5, infer A5>): infer _R5;
73
- (...args: ArgsWithCallback<infer Args6, infer _E6, infer A6>): infer _R6;
74
- (...args: ArgsWithCallback<infer Args7, infer _E7, infer A7>): infer _R7;
75
- } ? {
76
- (...args: Args1): Effect.Effect<WithoutNull<A1>, E>;
77
- (...args: Args2): Effect.Effect<WithoutNull<A2>, E>;
78
- (...args: Args3): Effect.Effect<WithoutNull<A3>, E>;
79
- (...args: Args4): Effect.Effect<WithoutNull<A4>, E>;
80
- (...args: Args5): Effect.Effect<WithoutNull<A5>, E>;
81
- (...args: Args6): Effect.Effect<WithoutNull<A6>, E>;
82
- (...args: Args7): Effect.Effect<WithoutNull<A7>, E>;
83
- } : T extends {
84
- (...args: ArgsWithCallback<infer Args1, infer _E1, infer A1>): infer _R1;
85
- (...args: ArgsWithCallback<infer Args2, infer _E2, infer A2>): infer _R2;
86
- (...args: ArgsWithCallback<infer Args3, infer _E3, infer A3>): infer _R3;
87
- (...args: ArgsWithCallback<infer Args4, infer _E4, infer A4>): infer _R4;
88
- (...args: ArgsWithCallback<infer Args5, infer _E5, infer A5>): infer _R5;
89
- (...args: ArgsWithCallback<infer Args6, infer _E6, infer A6>): infer _R6;
90
- } ? {
91
- (...args: Args1): Effect.Effect<WithoutNull<A1>, E>;
92
- (...args: Args2): Effect.Effect<WithoutNull<A2>, E>;
93
- (...args: Args3): Effect.Effect<WithoutNull<A3>, E>;
94
- (...args: Args4): Effect.Effect<WithoutNull<A4>, E>;
95
- (...args: Args5): Effect.Effect<WithoutNull<A5>, E>;
96
- (...args: Args6): Effect.Effect<WithoutNull<A6>, E>;
97
- } : T extends {
98
- (...args: ArgsWithCallback<infer Args1, infer _E1, infer A1>): infer _R1;
99
- (...args: ArgsWithCallback<infer Args2, infer _E2, infer A2>): infer _R2;
100
- (...args: ArgsWithCallback<infer Args3, infer _E3, infer A3>): infer _R3;
101
- (...args: ArgsWithCallback<infer Args4, infer _E4, infer A4>): infer _R4;
102
- (...args: ArgsWithCallback<infer Args5, infer _E5, infer A5>): infer _R5;
103
- } ? {
104
- (...args: Args1): Effect.Effect<WithoutNull<A1>, E>;
105
- (...args: Args2): Effect.Effect<WithoutNull<A2>, E>;
106
- (...args: Args3): Effect.Effect<WithoutNull<A3>, E>;
107
- (...args: Args4): Effect.Effect<WithoutNull<A4>, E>;
108
- (...args: Args5): Effect.Effect<WithoutNull<A5>, E>;
109
- } : T extends {
110
- (...args: ArgsWithCallback<infer Args1, infer _E1, infer A1>): infer _R1;
111
- (...args: ArgsWithCallback<infer Args2, infer _E2, infer A2>): infer _R2;
112
- (...args: ArgsWithCallback<infer Args3, infer _E3, infer A3>): infer _R3;
113
- (...args: ArgsWithCallback<infer Args4, infer _E4, infer A4>): infer _R4;
114
- } ? {
115
- (...args: Args1): Effect.Effect<WithoutNull<A1>, E>;
116
- (...args: Args2): Effect.Effect<WithoutNull<A2>, E>;
117
- (...args: Args3): Effect.Effect<WithoutNull<A3>, E>;
118
- (...args: Args4): Effect.Effect<WithoutNull<A4>, E>;
119
- } : T extends {
120
- (...args: ArgsWithCallback<infer Args1, infer _E1, infer A1>): infer _R1;
121
- (...args: ArgsWithCallback<infer Args2, infer _E2, infer A2>): infer _R2;
122
- (...args: ArgsWithCallback<infer Args3, infer _E3, infer A3>): infer _R3;
123
- } ? {
124
- (...args: Args1): Effect.Effect<WithoutNull<A1>, E>;
125
- (...args: Args2): Effect.Effect<WithoutNull<A2>, E>;
126
- (...args: Args3): Effect.Effect<WithoutNull<A3>, E>;
127
- } : T extends {
128
- (...args: ArgsWithCallback<infer Args1, infer _E1, infer A1>): infer _R1;
129
- (...args: ArgsWithCallback<infer Args2, infer _E2, infer A2>): infer _R2;
130
- } ? {
131
- (...args: Args1): Effect.Effect<WithoutNull<A1>, E>;
132
- (...args: Args2): Effect.Effect<WithoutNull<A2>, E>;
133
- } : T extends {
134
- (...args: ArgsWithCallback<infer Args1, infer _E1, infer A1>): infer _R1;
135
- } ? {
136
- (...args: Args1): Effect.Effect<WithoutNull<A1>, E>;
137
- } : never;
138
- type EffectifyError<T> = T extends {
139
- (...args: ArgsWithCallback<infer _Args1, infer E1, infer _A1>): infer _R1;
140
- (...args: ArgsWithCallback<infer _Args2, infer E2, infer _A2>): infer _R2;
141
- (...args: ArgsWithCallback<infer _Args3, infer E3, infer _A3>): infer _R3;
142
- (...args: ArgsWithCallback<infer _Args4, infer E4, infer _A4>): infer _R4;
143
- (...args: ArgsWithCallback<infer _Args5, infer E5, infer _A5>): infer _R5;
144
- (...args: ArgsWithCallback<infer _Args6, infer E6, infer _A6>): infer _R6;
145
- (...args: ArgsWithCallback<infer _Args7, infer E7, infer _A7>): infer _R7;
146
- (...args: ArgsWithCallback<infer _Args8, infer E8, infer _A8>): infer _R8;
147
- (...args: ArgsWithCallback<infer _Args9, infer E9, infer _A9>): infer _R9;
148
- (...args: ArgsWithCallback<infer _Args10, infer E10, infer _A10>): infer _R10;
149
- } ? NonNullable<E1 | E2 | E3 | E4 | E5 | E6 | E7 | E8 | E9 | E10> : T extends {
150
- (...args: ArgsWithCallback<infer _Args1, infer E1, infer _A1>): infer _R1;
151
- (...args: ArgsWithCallback<infer _Args2, infer E2, infer _A2>): infer _R2;
152
- (...args: ArgsWithCallback<infer _Args3, infer E3, infer _A3>): infer _R3;
153
- (...args: ArgsWithCallback<infer _Args4, infer E4, infer _A4>): infer _R4;
154
- (...args: ArgsWithCallback<infer _Args5, infer E5, infer _A5>): infer _R5;
155
- (...args: ArgsWithCallback<infer _Args6, infer E6, infer _A6>): infer _R6;
156
- (...args: ArgsWithCallback<infer _Args7, infer E7, infer _A7>): infer _R7;
157
- (...args: ArgsWithCallback<infer _Args8, infer E8, infer _A8>): infer _R8;
158
- (...args: ArgsWithCallback<infer _Args9, infer E9, infer _A9>): infer _R9;
159
- } ? NonNullable<E1 | E2 | E3 | E4 | E5 | E6 | E7 | E8 | E9> : T extends {
160
- (...args: ArgsWithCallback<infer _Args1, infer E1, infer _A1>): infer _R1;
161
- (...args: ArgsWithCallback<infer _Args2, infer E2, infer _A2>): infer _R2;
162
- (...args: ArgsWithCallback<infer _Args3, infer E3, infer _A3>): infer _R3;
163
- (...args: ArgsWithCallback<infer _Args4, infer E4, infer _A4>): infer _R4;
164
- (...args: ArgsWithCallback<infer _Args5, infer E5, infer _A5>): infer _R5;
165
- (...args: ArgsWithCallback<infer _Args6, infer E6, infer _A6>): infer _R6;
166
- (...args: ArgsWithCallback<infer _Args7, infer E7, infer _A7>): infer _R7;
167
- (...args: ArgsWithCallback<infer _Args8, infer E8, infer _A8>): infer _R8;
168
- } ? NonNullable<E1 | E2 | E3 | E4 | E5 | E6 | E7 | E8> : T extends {
169
- (...args: ArgsWithCallback<infer _Args1, infer E1, infer _A1>): infer _R1;
170
- (...args: ArgsWithCallback<infer _Args2, infer E2, infer _A2>): infer _R2;
171
- (...args: ArgsWithCallback<infer _Args3, infer E3, infer _A3>): infer _R3;
172
- (...args: ArgsWithCallback<infer _Args4, infer E4, infer _A4>): infer _R4;
173
- (...args: ArgsWithCallback<infer _Args5, infer E5, infer _A5>): infer _R5;
174
- (...args: ArgsWithCallback<infer _Args6, infer E6, infer _A6>): infer _R6;
175
- (...args: ArgsWithCallback<infer _Args7, infer E7, infer _A7>): infer _R7;
176
- } ? NonNullable<E1 | E2 | E3 | E4 | E5 | E6 | E7> : T extends {
177
- (...args: ArgsWithCallback<infer _Args1, infer E1, infer _A1>): infer _R1;
178
- (...args: ArgsWithCallback<infer _Args2, infer E2, infer _A2>): infer _R2;
179
- (...args: ArgsWithCallback<infer _Args3, infer E3, infer _A3>): infer _R3;
180
- (...args: ArgsWithCallback<infer _Args4, infer E4, infer _A4>): infer _R4;
181
- (...args: ArgsWithCallback<infer _Args5, infer E5, infer _A5>): infer _R5;
182
- (...args: ArgsWithCallback<infer _Args6, infer E6, infer _A6>): infer _R6;
183
- } ? NonNullable<E1 | E2 | E3 | E4 | E5 | E6> : T extends {
184
- (...args: ArgsWithCallback<infer _Args1, infer E1, infer _A1>): infer _R1;
185
- (...args: ArgsWithCallback<infer _Args2, infer E2, infer _A2>): infer _R2;
186
- (...args: ArgsWithCallback<infer _Args3, infer E3, infer _A3>): infer _R3;
187
- (...args: ArgsWithCallback<infer _Args4, infer E4, infer _A4>): infer _R4;
188
- (...args: ArgsWithCallback<infer _Args5, infer E5, infer _A5>): infer _R5;
189
- } ? NonNullable<E1 | E2 | E3 | E4 | E5> : T extends {
190
- (...args: ArgsWithCallback<infer _Args1, infer E1, infer _A1>): infer _R1;
191
- (...args: ArgsWithCallback<infer _Args2, infer E2, infer _A2>): infer _R2;
192
- (...args: ArgsWithCallback<infer _Args3, infer E3, infer _A3>): infer _R3;
193
- (...args: ArgsWithCallback<infer _Args4, infer E4, infer _A4>): infer _R4;
194
- } ? NonNullable<E1 | E2 | E3 | E4> : T extends {
195
- (...args: ArgsWithCallback<infer _Args1, infer E1, infer _A1>): infer _R1;
196
- (...args: ArgsWithCallback<infer _Args2, infer E2, infer _A2>): infer _R2;
197
- (...args: ArgsWithCallback<infer _Args3, infer E3, infer _A3>): infer _R3;
198
- } ? NonNullable<E1 | E2 | E3> : T extends {
199
- (...args: ArgsWithCallback<infer _Args1, infer E1, infer _A1>): infer _R1;
200
- (...args: ArgsWithCallback<infer _Args2, infer E2, infer _A2>): infer _R2;
201
- } ? NonNullable<E1 | E2> : T extends {
202
- (...args: ArgsWithCallback<infer _Args1, infer E1, infer _A1>): infer _R1;
203
- } ? NonNullable<E1> : never;
204
- export declare const effectify: {
205
- <F extends (...args: Array<any>) => any>(fn: F): Effectify<F, EffectifyError<F>>;
206
- <F extends (...args: Array<any>) => any, E>(fn: F, onError: (error: EffectifyError<F>, args: Parameters<F>) => E): Effectify<F, E>;
207
- <F extends (...args: Array<any>) => any, E, E2>(fn: F, onError: (error: EffectifyError<F>, args: Parameters<F>) => E, onSyncError: (error: unknown, args: Parameters<F>) => E2): Effectify<F, E | E2>;
208
- };
209
- export {};
package/dist/Effectify.js DELETED
@@ -1,19 +0,0 @@
1
- /*
2
- * Adapted from @effect/platform
3
- */
4
- import * as Effect from "effect/Effect";
5
- export const effectify = ((fn, onError, onSyncError) => (...args) => Effect.async((resume) => {
6
- try {
7
- fn(...args, (err, result) => {
8
- if (err) {
9
- resume(Effect.fail(onError ? onError(err, args) : err));
10
- }
11
- else {
12
- resume(Effect.succeed(result));
13
- }
14
- });
15
- }
16
- catch (err) {
17
- resume(onSyncError ? Effect.fail(onSyncError(err, args)) : Effect.die(err));
18
- }
19
- }));
package/dist/Entity.d.ts DELETED
@@ -1,47 +0,0 @@
1
- import * as Effect from "effect/Effect";
2
- import * as ParseResult from "effect/ParseResult";
3
- import * as Pipeable from "effect/Pipeable";
4
- import * as Stream from "effect/Stream";
5
- import * as Values from "./Values.ts";
6
- export declare const TypeId: unique symbol;
7
- export type TypeId = typeof TypeId;
8
- /**
9
- * Header keys are guaranteed to be lowercase.
10
- */
11
- export type Headers = {
12
- [header: string]: string | null | undefined;
13
- };
14
- export interface Entity<T = unknown, E = never> extends Pipeable.Pipeable {
15
- readonly [TypeId]: TypeId;
16
- readonly body: T;
17
- readonly headers: Headers;
18
- /**
19
- * Accepts any valid URI (Uniform Resource Identifier), including URLs
20
- * (http://, https://, file://), URNs (urn:isbn:...), S3 URIs (s3://bucket/key),
21
- * data URIs, and other schemes. While commonly called "URL" in many APIs,
22
- * this property handles URIs as the correct superset term per RFC 3986.
23
- */
24
- readonly url: string | undefined;
25
- readonly status: number | undefined;
26
- readonly text: T extends string ? Effect.Effect<T, ParseResult.ParseError | E> : Effect.Effect<string, ParseResult.ParseError | E>;
27
- readonly json: [T] extends [Effect.Effect<infer A, any, any>] ? Effect.Effect<A extends string | Uint8Array | ArrayBuffer ? unknown : A, ParseResult.ParseError | E> : [T] extends [Stream.Stream<any, any, any>] ? Effect.Effect<unknown, ParseResult.ParseError | E> : [T] extends [string | Uint8Array | ArrayBuffer] ? Effect.Effect<unknown, ParseResult.ParseError | E> : [T] extends [Values.Json] ? Effect.Effect<T, ParseResult.ParseError | E> : Effect.Effect<unknown, ParseResult.ParseError | E>;
28
- readonly bytes: Effect.Effect<Uint8Array, ParseResult.ParseError | E>;
29
- readonly stream: T extends Stream.Stream<infer A, infer E1, any> ? Stream.Stream<A, ParseResult.ParseError | E | E1> : Stream.Stream<Uint8Array, ParseResult.ParseError | E>;
30
- }
31
- export interface Proto extends Pipeable.Pipeable {
32
- readonly [TypeId]: TypeId;
33
- }
34
- export declare function isEntity(input: unknown): input is Entity;
35
- interface Options {
36
- readonly headers?: Headers;
37
- readonly url?: string;
38
- readonly status?: number;
39
- }
40
- export declare function make<A, E>(body: Effect.Effect<A, E, never>, options?: Options): Entity<Effect.Effect<A, E, never>, E>;
41
- export declare function make<A extends Uint8Array | string, E>(body: Stream.Stream<A, E, never>, options?: Options): Entity<Stream.Stream<A, E, never>, E>;
42
- export declare function make<T>(body: T, options?: Options): Entity<T, never>;
43
- export declare function effect<A, E, R>(body: Effect.Effect<Entity<A> | A, E, R>): Entity<A, E>;
44
- export declare function resolve<A, E>(entity: Entity<A, E>): Effect.Effect<Entity<A, E>, E, never>;
45
- export declare function type(self: Entity): string;
46
- export declare function length(self: Entity): number | undefined;
47
- export {};
package/dist/Entity.js DELETED
@@ -1,224 +0,0 @@
1
- import * as Effect from "effect/Effect";
2
- import * as ParseResult from "effect/ParseResult";
3
- import * as Pipeable from "effect/Pipeable";
4
- import * as Predicate from "effect/Predicate";
5
- import * as Schema from "effect/Schema";
6
- import * as Stream from "effect/Stream";
7
- import * as StreamExtra from "./StreamExtra.js";
8
- import * as Values from "./Values.js";
9
- export const TypeId = Symbol.for("effect-start/Entity");
10
- const textDecoder = new TextDecoder();
11
- const textEncoder = new TextEncoder();
12
- function isBinary(v) {
13
- return v instanceof Uint8Array || v instanceof ArrayBuffer;
14
- }
15
- function parseJson(s) {
16
- try {
17
- return Effect.succeed(JSON.parse(s));
18
- }
19
- catch (e) {
20
- return Effect.fail(new ParseResult.ParseError({
21
- issue: new ParseResult.Type(Schema.Unknown.ast, s, e instanceof Error ? e.message : "Failed to parse JSON"),
22
- }));
23
- }
24
- }
25
- function getText(self) {
26
- const v = self.body;
27
- if (StreamExtra.isStream(v)) {
28
- return Stream.mkString(Stream.decodeText(v));
29
- }
30
- if (Effect.isEffect(v)) {
31
- return Effect.flatMap(v, (inner) => {
32
- if (isEntity(inner)) {
33
- return inner.text;
34
- }
35
- if (typeof inner === "string") {
36
- return Effect.succeed(inner);
37
- }
38
- if (isBinary(inner)) {
39
- return Effect.succeed(textDecoder.decode(inner));
40
- }
41
- return Effect.fail(mismatch(Schema.String, inner));
42
- });
43
- }
44
- if (typeof v === "string") {
45
- return Effect.succeed(v);
46
- }
47
- if (isBinary(v)) {
48
- return Effect.succeed(textDecoder.decode(v));
49
- }
50
- return Effect.fail(mismatch(Schema.String, v));
51
- }
52
- function getJson(self) {
53
- const v = self.body;
54
- if (StreamExtra.isStream(v)) {
55
- return Effect.flatMap(getText(self), parseJson);
56
- }
57
- if (Effect.isEffect(v)) {
58
- return Effect.flatMap(v, (inner) => {
59
- if (isEntity(inner)) {
60
- return inner.json;
61
- }
62
- if (typeof inner === "object" && inner !== null && !isBinary(inner)) {
63
- return Effect.succeed(inner);
64
- }
65
- if (typeof inner === "string") {
66
- return parseJson(inner);
67
- }
68
- if (isBinary(inner)) {
69
- return parseJson(textDecoder.decode(inner));
70
- }
71
- return Effect.fail(mismatch(Schema.Unknown, inner));
72
- });
73
- }
74
- if (typeof v === "object" && v !== null && !isBinary(v)) {
75
- return Effect.succeed(v);
76
- }
77
- if (typeof v === "string") {
78
- return parseJson(v);
79
- }
80
- if (isBinary(v)) {
81
- return parseJson(textDecoder.decode(v));
82
- }
83
- return Effect.fail(mismatch(Schema.Unknown, v));
84
- }
85
- function getBytes(self) {
86
- const v = self.body;
87
- if (StreamExtra.isStream(v)) {
88
- return Stream.runFold(v, new Uint8Array(0), Values.concatBytes);
89
- }
90
- if (Effect.isEffect(v)) {
91
- return Effect.flatMap(v, (inner) => {
92
- if (isEntity(inner)) {
93
- return inner.bytes;
94
- }
95
- if (inner instanceof Uint8Array) {
96
- return Effect.succeed(inner);
97
- }
98
- if (inner instanceof ArrayBuffer) {
99
- return Effect.succeed(new Uint8Array(inner));
100
- }
101
- if (typeof inner === "string") {
102
- return Effect.succeed(textEncoder.encode(inner));
103
- }
104
- return Effect.fail(mismatch(Schema.Uint8ArrayFromSelf, inner));
105
- });
106
- }
107
- if (v instanceof Uint8Array) {
108
- return Effect.succeed(v);
109
- }
110
- if (v instanceof ArrayBuffer) {
111
- return Effect.succeed(new Uint8Array(v));
112
- }
113
- if (typeof v === "string") {
114
- return Effect.succeed(textEncoder.encode(v));
115
- }
116
- // Allows entity.stream to work when body is a JSON object
117
- if (typeof v === "object" && v !== null && !isBinary(v)) {
118
- return Effect.succeed(textEncoder.encode(JSON.stringify(v)));
119
- }
120
- return Effect.fail(mismatch(Schema.Uint8ArrayFromSelf, v));
121
- }
122
- function getStream(self) {
123
- const v = self.body;
124
- if (StreamExtra.isStream(v)) {
125
- return v;
126
- }
127
- if (Effect.isEffect(v)) {
128
- return Stream.unwrap(Effect.map(v, (inner) => {
129
- if (isEntity(inner)) {
130
- return inner.stream;
131
- }
132
- return Stream.fromEffect(getBytes(make(inner)));
133
- }));
134
- }
135
- return Stream.fromEffect(getBytes(self));
136
- }
137
- const Proto = Object.defineProperties(Object.create(null), {
138
- [TypeId]: { value: TypeId },
139
- pipe: {
140
- value: function () {
141
- return Pipeable.pipeArguments(this, arguments);
142
- },
143
- },
144
- text: {
145
- get() {
146
- return getText(this);
147
- },
148
- },
149
- json: {
150
- get() {
151
- return getJson(this);
152
- },
153
- },
154
- bytes: {
155
- get() {
156
- return getBytes(this);
157
- },
158
- },
159
- stream: {
160
- get() {
161
- return getStream(this);
162
- },
163
- },
164
- });
165
- export function isEntity(input) {
166
- return Predicate.hasProperty(input, TypeId);
167
- }
168
- export function make(body, options) {
169
- return Object.assign(Object.create(Proto), {
170
- body,
171
- headers: options?.headers ?? {},
172
- url: options?.url,
173
- status: options?.status,
174
- });
175
- }
176
- export function effect(body) {
177
- return make(body);
178
- }
179
- export function resolve(entity) {
180
- const body = entity.body;
181
- if (Effect.isEffect(body)) {
182
- return Effect.map(body, (inner) => isEntity(inner)
183
- ? inner
184
- : make(inner, {
185
- status: entity.status,
186
- headers: entity.headers,
187
- url: entity.url,
188
- }));
189
- }
190
- return Effect.succeed(entity);
191
- }
192
- export function type(self) {
193
- const h = self.headers;
194
- if (h["content-type"]) {
195
- return h["content-type"];
196
- }
197
- const v = self.body;
198
- if (typeof v === "string") {
199
- return "text/plain";
200
- }
201
- if (typeof v === "object" && v !== null && !isBinary(v)) {
202
- return "application/json";
203
- }
204
- return "application/octet-stream";
205
- }
206
- export function length(self) {
207
- const h = self.headers;
208
- if (h["content-length"]) {
209
- return parseInt(h["content-length"], 10);
210
- }
211
- const v = self.body;
212
- if (typeof v === "string") {
213
- return textEncoder.encode(v).byteLength;
214
- }
215
- if (isBinary(v)) {
216
- return v.byteLength;
217
- }
218
- return undefined;
219
- }
220
- function mismatch(expected, actual) {
221
- return new ParseResult.ParseError({
222
- issue: new ParseResult.Type(expected.ast, actual),
223
- });
224
- }
@@ -1,29 +0,0 @@
1
- import * as Either from "effect/Either";
2
- import type * as PathPattern from "./PathPattern.ts";
3
- export type FilePathPattern = string;
4
- export type Segment = {
5
- _tag: "GroupSegment";
6
- name: string;
7
- } | {
8
- _tag: "RestSegment";
9
- name: string;
10
- } | {
11
- _tag: "ParamSegment";
12
- name: string;
13
- } | {
14
- _tag: "LiteralSegment";
15
- value: string;
16
- } | {
17
- _tag: "InvalidSegment";
18
- value: string;
19
- };
20
- export declare function segments(pattern: string): Array<Segment>;
21
- export type ValidationError = {
22
- _tag: "FilePathPatternError";
23
- pattern: string;
24
- message: string;
25
- };
26
- export type ValidationResult = Either.Either<Array<Segment>, ValidationError>;
27
- export declare function validate(pattern: string): ValidationResult;
28
- export declare function format(segs: Array<Segment>): `/${string}`;
29
- export declare function toPathPattern(pattern: string): Either.Either<PathPattern.PathPattern, ValidationError>;