effect-start 0.28.0 → 0.29.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 (645) hide show
  1. package/dist/Cookies.d.ts +9 -41
  2. package/dist/Cookies.d.ts.map +1 -1
  3. package/dist/Cookies.js +2 -2
  4. package/dist/Cookies.js.map +1 -1
  5. package/dist/Entity.d.ts +5 -6
  6. package/dist/Entity.d.ts.map +1 -1
  7. package/dist/Entity.js +10 -7
  8. package/dist/Entity.js.map +1 -1
  9. package/dist/Fetch.d.ts +23 -4
  10. package/dist/Fetch.d.ts.map +1 -1
  11. package/dist/Fetch.js +90 -1
  12. package/dist/Fetch.js.map +1 -1
  13. package/dist/FileRouter.d.ts +4 -7
  14. package/dist/FileRouter.d.ts.map +1 -1
  15. package/dist/FileRouter.js +39 -30
  16. package/dist/FileRouter.js.map +1 -1
  17. package/dist/FileRouterCodegen.d.ts +2 -2
  18. package/dist/FileRouterCodegen.d.ts.map +1 -1
  19. package/dist/FileRouterCodegen.js +9 -21
  20. package/dist/FileRouterCodegen.js.map +1 -1
  21. package/dist/FileSystem.d.ts +39 -39
  22. package/dist/FileSystem.d.ts.map +1 -1
  23. package/dist/FileSystem.js +5 -3
  24. package/dist/FileSystem.js.map +1 -1
  25. package/dist/GlobalLayer.d.ts +2 -2
  26. package/dist/GlobalLayer.d.ts.map +1 -1
  27. package/dist/GlobalLayer.js +1 -1
  28. package/dist/GlobalLayer.js.map +1 -1
  29. package/dist/PlatformRuntime.d.ts.map +1 -1
  30. package/dist/PlatformRuntime.js.map +1 -1
  31. package/dist/Route.d.ts +2 -2
  32. package/dist/Route.d.ts.map +1 -1
  33. package/dist/Route.js +1 -1
  34. package/dist/Route.js.map +1 -1
  35. package/dist/RouteBody.d.ts +1 -1
  36. package/dist/RouteBody.d.ts.map +1 -1
  37. package/dist/RouteBody.js.map +1 -1
  38. package/dist/RouteError.js.map +1 -1
  39. package/dist/RouteHook.d.ts.map +1 -1
  40. package/dist/RouteHook.js.map +1 -1
  41. package/dist/RouteHttp.d.ts +1 -1
  42. package/dist/RouteHttp.d.ts.map +1 -1
  43. package/dist/RouteHttp.js +38 -31
  44. package/dist/RouteHttp.js.map +1 -1
  45. package/dist/RouteHttpTracer.d.ts.map +1 -1
  46. package/dist/RouteHttpTracer.js.map +1 -1
  47. package/dist/RouteMount.d.ts +2 -2
  48. package/dist/RouteMount.d.ts.map +1 -1
  49. package/dist/RouteMount.js +1 -1
  50. package/dist/RouteMount.js.map +1 -1
  51. package/dist/RouteSchema.d.ts +2 -2
  52. package/dist/RouteSchema.d.ts.map +1 -1
  53. package/dist/RouteSchema.js +2 -2
  54. package/dist/RouteSchema.js.map +1 -1
  55. package/dist/RouteSse.d.ts +9 -10
  56. package/dist/RouteSse.d.ts.map +1 -1
  57. package/dist/RouteSse.js +8 -12
  58. package/dist/RouteSse.js.map +1 -1
  59. package/dist/RouteTree.d.ts +2 -2
  60. package/dist/RouteTree.d.ts.map +1 -1
  61. package/dist/RouteTree.js +2 -2
  62. package/dist/RouteTree.js.map +1 -1
  63. package/dist/RouteTrie.js +1 -1
  64. package/dist/RouteTrie.js.map +1 -1
  65. package/dist/Socket.d.ts +13 -18
  66. package/dist/Socket.d.ts.map +1 -1
  67. package/dist/Socket.js +12 -13
  68. package/dist/Socket.js.map +1 -1
  69. package/dist/Start.d.ts +15 -23
  70. package/dist/Start.d.ts.map +1 -1
  71. package/dist/Start.js +17 -6
  72. package/dist/Start.js.map +1 -1
  73. package/dist/System.d.ts +20 -5
  74. package/dist/System.d.ts.map +1 -1
  75. package/dist/System.js +12 -42
  76. package/dist/System.js.map +1 -1
  77. package/dist/Unique.d.ts.map +1 -1
  78. package/dist/Unique.js.map +1 -1
  79. package/dist/{ChildProcess.d.ts → _ChildProcess.d.ts} +14 -15
  80. package/dist/_ChildProcess.d.ts.map +1 -0
  81. package/dist/{ChildProcess.js → _ChildProcess.js} +2 -2
  82. package/dist/_ChildProcess.js.map +1 -0
  83. package/dist/{ContentNegotiation.d.ts → _ContentNegotiation.d.ts} +1 -1
  84. package/dist/_ContentNegotiation.d.ts.map +1 -0
  85. package/dist/{ContentNegotiation.js → _ContentNegotiation.js} +1 -1
  86. package/dist/_ContentNegotiation.js.map +1 -0
  87. package/dist/_Development.d.ts +27 -0
  88. package/dist/_Development.d.ts.map +1 -0
  89. package/dist/{Development.js → _Development.js} +6 -9
  90. package/dist/_Development.js.map +1 -0
  91. package/dist/{Docker.d.ts → _Docker.d.ts} +2 -2
  92. package/dist/_Docker.d.ts.map +1 -0
  93. package/dist/{Docker.js → _Docker.js} +1 -1
  94. package/dist/_Docker.js.map +1 -0
  95. package/dist/{Effectify.d.ts → _Effectify.d.ts} +1 -1
  96. package/dist/_Effectify.d.ts.map +1 -0
  97. package/dist/{Effectify.js → _Effectify.js} +1 -1
  98. package/dist/_Effectify.js.map +1 -0
  99. package/dist/{Http.d.ts → _Http.d.ts} +1 -8
  100. package/dist/_Http.d.ts.map +1 -0
  101. package/dist/{Http.js → _Http.js} +1 -17
  102. package/dist/_Http.js.map +1 -0
  103. package/dist/{PathPattern.d.ts → _PathPattern.d.ts} +12 -1
  104. package/dist/_PathPattern.d.ts.map +1 -0
  105. package/dist/{PathPattern.js → _PathPattern.js} +86 -1
  106. package/dist/_PathPattern.js.map +1 -0
  107. package/dist/_SchemaExtra.d.ts +4 -0
  108. package/dist/_SchemaExtra.d.ts.map +1 -0
  109. package/dist/{SchemaExtra.js → _SchemaExtra.js} +4 -4
  110. package/dist/_SchemaExtra.js.map +1 -0
  111. package/dist/{StartApp.d.ts → _StartApp.d.ts} +1 -1
  112. package/dist/_StartApp.d.ts.map +1 -0
  113. package/dist/{StartApp.js → _StartApp.js} +1 -1
  114. package/dist/_StartApp.js.map +1 -0
  115. package/dist/{StreamExtra.d.ts → _StreamExtra.d.ts} +5 -5
  116. package/dist/_StreamExtra.d.ts.map +1 -0
  117. package/dist/{StreamExtra.js → _StreamExtra.js} +1 -1
  118. package/dist/_StreamExtra.js.map +1 -0
  119. package/dist/{Values.d.ts → _Values.d.ts} +3 -3
  120. package/dist/_Values.d.ts.map +1 -0
  121. package/dist/{Values.js → _Values.js} +1 -1
  122. package/dist/_Values.js.map +1 -0
  123. package/dist/bun/BunBundle.d.ts +2 -2
  124. package/dist/bun/BunBundle.d.ts.map +1 -1
  125. package/dist/bun/BunBundle.js.map +1 -1
  126. package/dist/bun/BunChildProcessSpawner.d.ts +1 -1
  127. package/dist/bun/BunChildProcessSpawner.d.ts.map +1 -1
  128. package/dist/bun/BunChildProcessSpawner.js +9 -9
  129. package/dist/bun/BunChildProcessSpawner.js.map +1 -1
  130. package/dist/bun/BunImportTrackerPlugin.d.ts +2 -2
  131. package/dist/bun/BunImportTrackerPlugin.d.ts.map +1 -1
  132. package/dist/bun/BunImportTrackerPlugin.js.map +1 -1
  133. package/dist/bun/BunRoute.d.ts +1 -1
  134. package/dist/bun/BunRoute.d.ts.map +1 -1
  135. package/dist/bun/BunRoute.js +6 -7
  136. package/dist/bun/BunRoute.js.map +1 -1
  137. package/dist/bun/BunRuntime.js.map +1 -1
  138. package/dist/bun/BunServer.d.ts +5 -5
  139. package/dist/bun/BunServer.d.ts.map +1 -1
  140. package/dist/bun/BunServer.js +3 -3
  141. package/dist/bun/BunServer.js.map +1 -1
  142. package/dist/bun/BunVirtualFilesPlugin.js.map +1 -1
  143. package/dist/bun/_BunEnhancedResolve.d.ts.map +1 -1
  144. package/dist/bun/_BunEnhancedResolve.js.map +1 -1
  145. package/dist/bun/_empty.html +0 -0
  146. package/dist/bundler/Bundle.d.ts +2 -2
  147. package/dist/bundler/Bundle.d.ts.map +1 -1
  148. package/dist/bundler/Bundle.js.map +1 -1
  149. package/dist/bundler/BundleFiles.d.ts +1 -1
  150. package/dist/bundler/BundleFiles.d.ts.map +1 -1
  151. package/dist/bundler/BundleFiles.js.map +1 -1
  152. package/dist/bundler/BundleRoute.d.ts +6 -5
  153. package/dist/bundler/BundleRoute.d.ts.map +1 -1
  154. package/dist/bundler/BundleRoute.js +2 -2
  155. package/dist/bundler/BundleRoute.js.map +1 -1
  156. package/dist/cli/Argument.d.ts +26 -0
  157. package/dist/cli/Argument.d.ts.map +1 -0
  158. package/dist/cli/Argument.js +31 -0
  159. package/dist/cli/Argument.js.map +1 -0
  160. package/dist/cli/CliError.d.ts +15 -0
  161. package/dist/cli/CliError.d.ts.map +1 -0
  162. package/dist/cli/CliError.js +54 -0
  163. package/dist/cli/CliError.js.map +1 -0
  164. package/dist/cli/Command.d.ts +61 -0
  165. package/dist/cli/Command.d.ts.map +1 -0
  166. package/dist/cli/Command.js +453 -0
  167. package/dist/cli/Command.js.map +1 -0
  168. package/dist/cli/Flag.d.ts +32 -0
  169. package/dist/cli/Flag.d.ts.map +1 -0
  170. package/dist/cli/Flag.js +35 -0
  171. package/dist/cli/Flag.js.map +1 -0
  172. package/dist/cli/HelpDoc.d.ts +28 -0
  173. package/dist/cli/HelpDoc.d.ts.map +1 -0
  174. package/dist/cli/HelpDoc.js +40 -0
  175. package/dist/cli/HelpDoc.js.map +1 -0
  176. package/dist/cli/Param.d.ts +71 -0
  177. package/dist/cli/Param.d.ts.map +1 -0
  178. package/dist/cli/Param.js +236 -0
  179. package/dist/cli/Param.js.map +1 -0
  180. package/dist/cli/Primitive.d.ts +22 -0
  181. package/dist/cli/Primitive.d.ts.map +1 -0
  182. package/dist/cli/Primitive.js +73 -0
  183. package/dist/cli/Primitive.js.map +1 -0
  184. package/dist/cli/index.d.ts +8 -0
  185. package/dist/cli/index.d.ts.map +1 -0
  186. package/dist/cli/index.js +8 -0
  187. package/dist/cli/index.js.map +1 -0
  188. package/dist/client/Overlay.js.map +1 -1
  189. package/dist/client/ScrollState.js.map +1 -1
  190. package/dist/client/index.js.map +1 -1
  191. package/dist/datastar/actions/fetch.js.map +1 -1
  192. package/dist/datastar/actions/peek.js.map +1 -1
  193. package/dist/datastar/actions/setAll.js.map +1 -1
  194. package/dist/datastar/actions/toggleAll.js.map +1 -1
  195. package/dist/datastar/attributes/attr.js.map +1 -1
  196. package/dist/datastar/attributes/bind.js.map +1 -1
  197. package/dist/datastar/attributes/class.js.map +1 -1
  198. package/dist/datastar/attributes/computed.js.map +1 -1
  199. package/dist/datastar/attributes/indicator.js.map +1 -1
  200. package/dist/datastar/attributes/init.js.map +1 -1
  201. package/dist/datastar/attributes/jsonSignals.js.map +1 -1
  202. package/dist/datastar/attributes/on.js.map +1 -1
  203. package/dist/datastar/attributes/onIntersect.js.map +1 -1
  204. package/dist/datastar/attributes/onInterval.js.map +1 -1
  205. package/dist/datastar/attributes/onSignalPatch.js.map +1 -1
  206. package/dist/datastar/attributes/ref.js.map +1 -1
  207. package/dist/datastar/attributes/show.js.map +1 -1
  208. package/dist/datastar/attributes/signals.js.map +1 -1
  209. package/dist/datastar/attributes/style.js.map +1 -1
  210. package/dist/datastar/attributes/text.js.map +1 -1
  211. package/dist/datastar/engine.d.ts +5 -5
  212. package/dist/datastar/engine.d.ts.map +1 -1
  213. package/dist/datastar/engine.js.map +1 -1
  214. package/dist/datastar/utils.d.ts +1 -1
  215. package/dist/datastar/utils.d.ts.map +1 -1
  216. package/dist/datastar/utils.js.map +1 -1
  217. package/dist/datastar/watchers/patchElements.js +3 -1
  218. package/dist/datastar/watchers/patchElements.js.map +1 -1
  219. package/dist/datastar/watchers/patchSignals.js.map +1 -1
  220. package/dist/experimental/EncryptedCookies.d.ts +4 -4
  221. package/dist/experimental/EncryptedCookies.d.ts.map +1 -1
  222. package/dist/experimental/EncryptedCookies.js.map +1 -1
  223. package/dist/hyper/Hyper.js.map +1 -1
  224. package/dist/hyper/HyperHtml.js.map +1 -1
  225. package/dist/hyper/HyperHtml.test.js.map +1 -1
  226. package/dist/hyper/HyperNode.d.ts +1 -2
  227. package/dist/hyper/HyperNode.d.ts.map +1 -1
  228. package/dist/hyper/HyperNode.js +1 -1
  229. package/dist/hyper/HyperNode.js.map +1 -1
  230. package/dist/hyper/HyperRoute.js.map +1 -1
  231. package/dist/hyper/HyperRoute.test.js +11 -13
  232. package/dist/hyper/HyperRoute.test.js.map +1 -1
  233. package/dist/hyper/html.d.ts +5 -4
  234. package/dist/hyper/html.d.ts.map +1 -1
  235. package/dist/hyper/html.js.map +1 -1
  236. package/dist/hyper/jsx-runtime.js.map +1 -1
  237. package/dist/index.d.ts +1 -1
  238. package/dist/index.d.ts.map +1 -1
  239. package/dist/index.js +1 -1
  240. package/dist/index.js.map +1 -1
  241. package/dist/lint/plugin.d.ts +18 -15
  242. package/dist/lint/plugin.d.ts.map +1 -1
  243. package/dist/lint/plugin.js +76 -80
  244. package/dist/lint/plugin.js.map +1 -1
  245. package/dist/node/NodeFileSystem.d.ts +3 -3
  246. package/dist/node/NodeFileSystem.d.ts.map +1 -1
  247. package/dist/node/NodeFileSystem.js +8 -7
  248. package/dist/node/NodeFileSystem.js.map +1 -1
  249. package/dist/node/NodeUtils.d.ts.map +1 -1
  250. package/dist/node/NodeUtils.js.map +1 -1
  251. package/dist/sql/SqlCache.d.ts +1 -0
  252. package/dist/sql/SqlCache.d.ts.map +1 -1
  253. package/dist/sql/SqlCache.js +5 -1
  254. package/dist/sql/SqlCache.js.map +1 -1
  255. package/dist/sql/SqlClient.js +1 -1
  256. package/dist/sql/SqlClient.js.map +1 -1
  257. package/dist/{SqlIntrospect.d.ts → sql/SqlIntrospect.d.ts} +3 -3
  258. package/dist/sql/SqlIntrospect.d.ts.map +1 -0
  259. package/dist/{SqlIntrospect.js → sql/SqlIntrospect.js} +1 -1
  260. package/dist/sql/SqlIntrospect.js.map +1 -0
  261. package/dist/sql/bun/index.d.ts +3 -3
  262. package/dist/sql/bun/index.d.ts.map +1 -1
  263. package/dist/sql/bun/index.js +1 -1
  264. package/dist/sql/bun/index.js.map +1 -1
  265. package/dist/sql/index.d.ts +1 -0
  266. package/dist/sql/index.d.ts.map +1 -1
  267. package/dist/sql/index.js +1 -0
  268. package/dist/sql/index.js.map +1 -1
  269. package/dist/sql/libsql/index.d.ts +1 -1
  270. package/dist/sql/libsql/index.d.ts.map +1 -1
  271. package/dist/sql/libsql/index.js +2 -2
  272. package/dist/sql/libsql/index.js.map +1 -1
  273. package/dist/sql/mssql/index.d.ts +3 -3
  274. package/dist/sql/mssql/index.d.ts.map +1 -1
  275. package/dist/sql/mssql/index.js +1 -1
  276. package/dist/sql/mssql/index.js.map +1 -1
  277. package/dist/sql/postgres/index.d.ts +1 -1
  278. package/dist/sql/postgres/index.d.ts.map +1 -1
  279. package/dist/sql/postgres/index.js.map +1 -1
  280. package/dist/studio/Simulation.d.ts.map +1 -0
  281. package/dist/studio/Simulation.js.map +1 -0
  282. package/dist/{tower/Tower.d.ts → studio/Studio.d.ts} +4 -4
  283. package/dist/studio/Studio.d.ts.map +1 -0
  284. package/dist/studio/Studio.js +30 -0
  285. package/dist/studio/Studio.js.map +1 -0
  286. package/dist/studio/StudioErrors.d.ts +4 -0
  287. package/dist/studio/StudioErrors.d.ts.map +1 -0
  288. package/dist/{tower/TowerErrors.js → studio/StudioErrors.js} +6 -6
  289. package/dist/studio/StudioErrors.js.map +1 -0
  290. package/dist/{tower/TowerLogger.d.ts → studio/StudioLogger.d.ts} +1 -1
  291. package/dist/studio/StudioLogger.d.ts.map +1 -0
  292. package/dist/{tower/TowerLogger.js → studio/StudioLogger.js} +7 -7
  293. package/dist/studio/StudioLogger.js.map +1 -0
  294. package/dist/studio/StudioMetrics.d.ts +4 -0
  295. package/dist/studio/StudioMetrics.d.ts.map +1 -0
  296. package/dist/{tower/TowerMetrics.js → studio/StudioMetrics.js} +3 -3
  297. package/dist/studio/StudioMetrics.js.map +1 -0
  298. package/dist/studio/StudioProcess.d.ts +4 -0
  299. package/dist/studio/StudioProcess.d.ts.map +1 -0
  300. package/dist/{tower/TowerProcess.js → studio/StudioProcess.js} +3 -3
  301. package/dist/studio/StudioProcess.js.map +1 -0
  302. package/dist/{tower/TowerStore.d.ts → studio/StudioStore.d.ts} +33 -33
  303. package/dist/studio/StudioStore.d.ts.map +1 -0
  304. package/dist/{tower/TowerStore.js → studio/StudioStore.js} +5 -5
  305. package/dist/studio/StudioStore.js.map +1 -0
  306. package/dist/studio/StudioTracer.d.ts +4 -0
  307. package/dist/studio/StudioTracer.d.ts.map +1 -0
  308. package/dist/{tower/TowerTracer.js → studio/StudioTracer.js} +21 -21
  309. package/dist/studio/StudioTracer.js.map +1 -0
  310. package/dist/studio/index.d.ts +4 -0
  311. package/dist/studio/index.d.ts.map +1 -0
  312. package/dist/studio/index.js +4 -0
  313. package/dist/studio/index.js.map +1 -0
  314. package/dist/{tower → studio}/routes/errors/route.d.ts +1 -1
  315. package/dist/{tower/routes/metrics → studio/routes/errors}/route.d.ts.map +1 -1
  316. package/dist/{tower → studio}/routes/errors/route.js +5 -9
  317. package/dist/studio/routes/errors/route.js.map +1 -0
  318. package/dist/{tower → studio}/routes/fiberDetail.d.ts +1 -1
  319. package/dist/studio/routes/fiberDetail.d.ts.map +1 -0
  320. package/dist/{tower → studio}/routes/fiberDetail.js +7 -7
  321. package/dist/studio/routes/fiberDetail.js.map +1 -0
  322. package/dist/{tower/routes/traces → studio/routes/fibers}/route.d.ts +1 -1
  323. package/dist/studio/routes/fibers/route.d.ts.map +1 -0
  324. package/dist/studio/routes/fibers/route.js +25 -0
  325. package/dist/studio/routes/fibers/route.js.map +1 -0
  326. package/dist/studio/routes/layout.d.ts.map +1 -0
  327. package/{src/tower → dist/studio}/routes/layout.html +1 -1
  328. package/dist/studio/routes/layout.js.map +1 -0
  329. package/dist/{tower → studio}/routes/logs/route.d.ts +1 -1
  330. package/dist/studio/routes/logs/route.d.ts.map +1 -0
  331. package/dist/studio/routes/logs/route.js +30 -0
  332. package/dist/studio/routes/logs/route.js.map +1 -0
  333. package/dist/{tower → studio}/routes/metrics/route.d.ts +1 -1
  334. package/dist/studio/routes/metrics/route.d.ts.map +1 -0
  335. package/dist/{tower → studio}/routes/metrics/route.js +3 -5
  336. package/dist/studio/routes/metrics/route.js.map +1 -0
  337. package/dist/{tower → studio}/routes/route.d.ts +1 -1
  338. package/dist/studio/routes/route.d.ts.map +1 -0
  339. package/dist/studio/routes/route.js +6 -0
  340. package/dist/studio/routes/route.js.map +1 -0
  341. package/dist/{tower → studio}/routes/routes/route.d.ts +1 -1
  342. package/dist/studio/routes/routes/route.d.ts.map +1 -0
  343. package/dist/{tower → studio}/routes/routes/route.js +2 -4
  344. package/dist/studio/routes/routes/route.js.map +1 -0
  345. package/dist/{tower → studio}/routes/services/route.d.ts +1 -1
  346. package/dist/studio/routes/services/route.d.ts.map +1 -0
  347. package/dist/studio/routes/services/route.js +13 -0
  348. package/dist/studio/routes/services/route.js.map +1 -0
  349. package/dist/{tower → studio}/routes/system/route.d.ts +1 -1
  350. package/dist/studio/routes/system/route.d.ts.map +1 -0
  351. package/dist/studio/routes/system/route.js +19 -0
  352. package/dist/studio/routes/system/route.js.map +1 -0
  353. package/dist/{tower → studio}/routes/traceDetail.d.ts +1 -1
  354. package/dist/studio/routes/traceDetail.d.ts.map +1 -0
  355. package/dist/{tower → studio}/routes/traceDetail.js +4 -4
  356. package/dist/studio/routes/traceDetail.js.map +1 -0
  357. package/dist/{tower/routes/fibers → studio/routes/traces}/route.d.ts +1 -1
  358. package/dist/studio/routes/traces/route.d.ts.map +1 -0
  359. package/dist/studio/routes/traces/route.js +30 -0
  360. package/dist/studio/routes/traces/route.js.map +1 -0
  361. package/dist/{tower → studio}/routes/tree.d.ts +46 -46
  362. package/dist/studio/routes/tree.d.ts.map +1 -0
  363. package/dist/studio/routes/tree.js.map +1 -0
  364. package/dist/studio/ui/Errors.d.ts +5 -0
  365. package/dist/studio/ui/Errors.d.ts.map +1 -0
  366. package/dist/studio/ui/Errors.js +17 -0
  367. package/dist/studio/ui/Errors.js.map +1 -0
  368. package/dist/{tower → studio}/ui/Fibers.d.ts +5 -5
  369. package/dist/studio/ui/Fibers.d.ts.map +1 -0
  370. package/dist/studio/ui/Fibers.js +134 -0
  371. package/dist/studio/ui/Fibers.js.map +1 -0
  372. package/dist/studio/ui/Logs.d.ts +5 -0
  373. package/dist/studio/ui/Logs.d.ts.map +1 -0
  374. package/dist/{tower → studio}/ui/Logs.js +2 -3
  375. package/dist/studio/ui/Logs.js.map +1 -0
  376. package/dist/studio/ui/Metrics.d.ts +5 -0
  377. package/dist/studio/ui/Metrics.d.ts.map +1 -0
  378. package/dist/{tower → studio}/ui/Metrics.js +4 -11
  379. package/dist/studio/ui/Metrics.js.map +1 -0
  380. package/dist/studio/ui/Routes.d.ts.map +1 -0
  381. package/dist/{tower → studio}/ui/Routes.js +4 -12
  382. package/dist/studio/ui/Routes.js.map +1 -0
  383. package/dist/studio/ui/Services.d.ts.map +1 -0
  384. package/dist/{tower → studio}/ui/Services.js +2 -9
  385. package/dist/studio/ui/Services.js.map +1 -0
  386. package/dist/studio/ui/Shell.d.ts.map +1 -0
  387. package/dist/studio/ui/Shell.js +8 -0
  388. package/dist/studio/ui/Shell.js.map +1 -0
  389. package/dist/studio/ui/System.d.ts +5 -0
  390. package/dist/studio/ui/System.d.ts.map +1 -0
  391. package/dist/studio/ui/System.js +36 -0
  392. package/dist/studio/ui/System.js.map +1 -0
  393. package/dist/studio/ui/Traces.d.ts +13 -0
  394. package/dist/studio/ui/Traces.d.ts.map +1 -0
  395. package/dist/studio/ui/Traces.js +182 -0
  396. package/dist/studio/ui/Traces.js.map +1 -0
  397. package/dist/testing/TestLogger.js.map +1 -1
  398. package/dist/testing/utils.d.ts +3 -1
  399. package/dist/testing/utils.d.ts.map +1 -1
  400. package/dist/testing/utils.js +39 -0
  401. package/dist/testing/utils.js.map +1 -1
  402. package/dist/x/cloudflare/CloudflareTunnel.d.ts +8 -7
  403. package/dist/x/cloudflare/CloudflareTunnel.d.ts.map +1 -1
  404. package/dist/x/cloudflare/CloudflareTunnel.js.map +1 -1
  405. package/dist/x/tailscale/TailscaleTunnel.d.ts +9 -9
  406. package/dist/x/tailscale/TailscaleTunnel.d.ts.map +1 -1
  407. package/dist/x/tailscale/TailscaleTunnel.js +3 -4
  408. package/dist/x/tailscale/TailscaleTunnel.js.map +1 -1
  409. package/dist/x/tailwind/TailwindPlugin.d.ts +5 -5
  410. package/dist/x/tailwind/TailwindPlugin.d.ts.map +1 -1
  411. package/dist/x/tailwind/TailwindPlugin.js.map +1 -1
  412. package/dist/x/tailwind/compile.js.map +1 -1
  413. package/dist/x/tailwind/plugin.js.map +1 -1
  414. package/package.json +42 -60
  415. package/src/Cookies.ts +4 -8
  416. package/src/Entity.ts +24 -19
  417. package/src/Fetch.ts +128 -5
  418. package/src/FileRouter.ts +46 -49
  419. package/src/FileRouterCodegen.ts +9 -23
  420. package/src/FileSystem.ts +43 -63
  421. package/src/GlobalLayer.ts +1 -1
  422. package/src/Route.ts +2 -2
  423. package/src/RouteBody.ts +1 -1
  424. package/src/RouteHttp.ts +133 -113
  425. package/src/RouteMount.ts +3 -3
  426. package/src/RouteSchema.ts +2 -2
  427. package/src/RouteSse.ts +28 -37
  428. package/src/RouteTree.ts +2 -2
  429. package/src/RouteTrie.ts +1 -1
  430. package/src/Socket.ts +17 -27
  431. package/src/Start.ts +39 -47
  432. package/src/System.ts +40 -64
  433. package/src/{ChildProcess.ts → _ChildProcess.ts} +13 -22
  434. package/src/{Development.ts → _Development.ts} +16 -21
  435. package/src/{Docker.ts → _Docker.ts} +1 -1
  436. package/src/{Http.ts → _Http.ts} +0 -28
  437. package/src/{PathPattern.ts → _PathPattern.ts} +105 -0
  438. package/src/{SchemaExtra.ts → _SchemaExtra.ts} +3 -4
  439. package/src/bun/BunChildProcessSpawner.ts +9 -9
  440. package/src/bun/BunRoute.ts +5 -8
  441. package/src/bun/BunServer.ts +3 -3
  442. package/src/bundler/BundleRoute.ts +2 -2
  443. package/src/cli/Argument.ts +45 -0
  444. package/src/cli/CliError.ts +68 -0
  445. package/src/cli/Command.ts +685 -0
  446. package/src/cli/Flag.ts +63 -0
  447. package/src/cli/HelpDoc.ts +67 -0
  448. package/src/cli/Param.ts +418 -0
  449. package/src/cli/Primitive.ts +94 -0
  450. package/src/cli/index.ts +7 -0
  451. package/src/datastar/watchers/patchElements.ts +4 -2
  452. package/src/hyper/HyperHtml.test.tsx +395 -0
  453. package/src/hyper/HyperNode.ts +1 -2
  454. package/src/hyper/HyperRoute.test.tsx +166 -0
  455. package/src/hyper/HyperRoute.ts +1 -1
  456. package/src/index.ts +1 -1
  457. package/src/lint/plugin.js +86 -97
  458. package/src/node/NodeFileSystem.ts +15 -14
  459. package/src/sql/SqlCache.ts +14 -1
  460. package/src/sql/SqlClient.ts +1 -1
  461. package/src/{SqlIntrospect.ts → sql/SqlIntrospect.ts} +1 -1
  462. package/src/sql/bun/index.ts +1 -1
  463. package/src/sql/index.ts +1 -0
  464. package/src/sql/libsql/index.ts +1 -1
  465. package/src/sql/mssql/index.ts +1 -1
  466. package/src/studio/Studio.ts +47 -0
  467. package/src/{tower/TowerErrors.ts → studio/StudioErrors.ts} +13 -13
  468. package/src/{tower/TowerLogger.ts → studio/StudioLogger.ts} +10 -10
  469. package/src/{tower/TowerMetrics.ts → studio/StudioMetrics.ts} +5 -5
  470. package/src/{tower/TowerProcess.ts → studio/StudioProcess.ts} +4 -4
  471. package/src/{tower/TowerStore.ts → studio/StudioStore.ts} +37 -37
  472. package/src/{tower/TowerTracer.ts → studio/StudioTracer.ts} +25 -25
  473. package/src/studio/index.ts +3 -0
  474. package/src/{tower → studio}/routes/errors/route.tsx +4 -4
  475. package/src/{tower → studio}/routes/fiberDetail.tsx +8 -8
  476. package/src/{tower → studio}/routes/fibers/route.tsx +10 -10
  477. package/src/studio/routes/layout.html +340 -0
  478. package/src/{tower → studio}/routes/logs/route.tsx +4 -4
  479. package/src/{tower → studio}/routes/metrics/route.tsx +5 -5
  480. package/src/studio/routes/route.tsx +8 -0
  481. package/src/{tower → studio}/routes/routes/route.tsx +2 -2
  482. package/src/{tower → studio}/routes/services/route.tsx +2 -2
  483. package/src/{tower → studio}/routes/system/route.tsx +5 -5
  484. package/src/{tower → studio}/routes/traceDetail.tsx +5 -5
  485. package/src/{tower → studio}/routes/traces/route.tsx +5 -5
  486. package/src/{tower → studio}/ui/Errors.tsx +3 -3
  487. package/src/{tower → studio}/ui/Fibers.tsx +7 -7
  488. package/src/{tower → studio}/ui/Logs.tsx +3 -3
  489. package/src/{tower → studio}/ui/Metrics.tsx +4 -4
  490. package/src/{tower → studio}/ui/Shell.tsx +1 -1
  491. package/src/{tower → studio}/ui/System.tsx +2 -2
  492. package/src/{tower → studio}/ui/Traces.tsx +16 -16
  493. package/src/testing/utils.ts +59 -0
  494. package/src/x/tailscale/TailscaleTunnel.ts +3 -4
  495. package/dist/ChildProcess.d.ts.map +0 -1
  496. package/dist/ChildProcess.js.map +0 -1
  497. package/dist/Commander.d.ts +0 -101
  498. package/dist/Commander.d.ts.map +0 -1
  499. package/dist/Commander.js +0 -327
  500. package/dist/Commander.js.map +0 -1
  501. package/dist/ContentNegotiation.d.ts.map +0 -1
  502. package/dist/ContentNegotiation.js.map +0 -1
  503. package/dist/Development.d.ts +0 -42
  504. package/dist/Development.d.ts.map +0 -1
  505. package/dist/Development.js.map +0 -1
  506. package/dist/Docker.d.ts.map +0 -1
  507. package/dist/Docker.js.map +0 -1
  508. package/dist/Effectify.d.ts.map +0 -1
  509. package/dist/Effectify.js.map +0 -1
  510. package/dist/FilePathPattern.d.ts +0 -30
  511. package/dist/FilePathPattern.d.ts.map +0 -1
  512. package/dist/FilePathPattern.js +0 -87
  513. package/dist/FilePathPattern.js.map +0 -1
  514. package/dist/Http.d.ts.map +0 -1
  515. package/dist/Http.js.map +0 -1
  516. package/dist/PathPattern.d.ts.map +0 -1
  517. package/dist/PathPattern.js.map +0 -1
  518. package/dist/PlatformError.d.ts +0 -39
  519. package/dist/PlatformError.d.ts.map +0 -1
  520. package/dist/PlatformError.js +0 -26
  521. package/dist/PlatformError.js.map +0 -1
  522. package/dist/SchemaExtra.d.ts +0 -8
  523. package/dist/SchemaExtra.d.ts.map +0 -1
  524. package/dist/SchemaExtra.js.map +0 -1
  525. package/dist/SqlIntrospect.d.ts.map +0 -1
  526. package/dist/SqlIntrospect.js.map +0 -1
  527. package/dist/StartApp.d.ts.map +0 -1
  528. package/dist/StartApp.js.map +0 -1
  529. package/dist/StreamExtra.d.ts.map +0 -1
  530. package/dist/StreamExtra.js.map +0 -1
  531. package/dist/TuplePathPattern.d.ts +0 -10
  532. package/dist/TuplePathPattern.d.ts.map +0 -1
  533. package/dist/TuplePathPattern.js +0 -69
  534. package/dist/TuplePathPattern.js.map +0 -1
  535. package/dist/Values.d.ts.map +0 -1
  536. package/dist/Values.js.map +0 -1
  537. package/dist/tower/Simulation.d.ts.map +0 -1
  538. package/dist/tower/Simulation.js.map +0 -1
  539. package/dist/tower/Tower.d.ts.map +0 -1
  540. package/dist/tower/Tower.js +0 -30
  541. package/dist/tower/Tower.js.map +0 -1
  542. package/dist/tower/TowerErrors.d.ts +0 -4
  543. package/dist/tower/TowerErrors.d.ts.map +0 -1
  544. package/dist/tower/TowerErrors.js.map +0 -1
  545. package/dist/tower/TowerLogger.d.ts.map +0 -1
  546. package/dist/tower/TowerLogger.js.map +0 -1
  547. package/dist/tower/TowerMetrics.d.ts +0 -4
  548. package/dist/tower/TowerMetrics.d.ts.map +0 -1
  549. package/dist/tower/TowerMetrics.js.map +0 -1
  550. package/dist/tower/TowerProcess.d.ts +0 -4
  551. package/dist/tower/TowerProcess.d.ts.map +0 -1
  552. package/dist/tower/TowerProcess.js.map +0 -1
  553. package/dist/tower/TowerStore.d.ts.map +0 -1
  554. package/dist/tower/TowerStore.js.map +0 -1
  555. package/dist/tower/TowerTracer.d.ts +0 -4
  556. package/dist/tower/TowerTracer.d.ts.map +0 -1
  557. package/dist/tower/TowerTracer.js.map +0 -1
  558. package/dist/tower/index.d.ts +0 -4
  559. package/dist/tower/index.d.ts.map +0 -1
  560. package/dist/tower/index.js +0 -4
  561. package/dist/tower/index.js.map +0 -1
  562. package/dist/tower/routes/errors/route.d.ts.map +0 -1
  563. package/dist/tower/routes/errors/route.js.map +0 -1
  564. package/dist/tower/routes/fiberDetail.d.ts.map +0 -1
  565. package/dist/tower/routes/fiberDetail.js.map +0 -1
  566. package/dist/tower/routes/fibers/route.d.ts.map +0 -1
  567. package/dist/tower/routes/fibers/route.js +0 -27
  568. package/dist/tower/routes/fibers/route.js.map +0 -1
  569. package/dist/tower/routes/layout.d.ts.map +0 -1
  570. package/dist/tower/routes/layout.js.map +0 -1
  571. package/dist/tower/routes/logs/route.d.ts.map +0 -1
  572. package/dist/tower/routes/logs/route.js +0 -36
  573. package/dist/tower/routes/logs/route.js.map +0 -1
  574. package/dist/tower/routes/metrics/route.js.map +0 -1
  575. package/dist/tower/routes/route.d.ts.map +0 -1
  576. package/dist/tower/routes/route.js +0 -6
  577. package/dist/tower/routes/route.js.map +0 -1
  578. package/dist/tower/routes/routes/route.d.ts.map +0 -1
  579. package/dist/tower/routes/routes/route.js.map +0 -1
  580. package/dist/tower/routes/services/route.d.ts.map +0 -1
  581. package/dist/tower/routes/services/route.js +0 -15
  582. package/dist/tower/routes/services/route.js.map +0 -1
  583. package/dist/tower/routes/system/route.d.ts.map +0 -1
  584. package/dist/tower/routes/system/route.js +0 -21
  585. package/dist/tower/routes/system/route.js.map +0 -1
  586. package/dist/tower/routes/traceDetail.d.ts.map +0 -1
  587. package/dist/tower/routes/traceDetail.js.map +0 -1
  588. package/dist/tower/routes/traces/route.d.ts.map +0 -1
  589. package/dist/tower/routes/traces/route.js +0 -36
  590. package/dist/tower/routes/traces/route.js.map +0 -1
  591. package/dist/tower/routes/tree.d.ts.map +0 -1
  592. package/dist/tower/routes/tree.js.map +0 -1
  593. package/dist/tower/ui/Errors.d.ts +0 -5
  594. package/dist/tower/ui/Errors.d.ts.map +0 -1
  595. package/dist/tower/ui/Errors.js +0 -30
  596. package/dist/tower/ui/Errors.js.map +0 -1
  597. package/dist/tower/ui/Fibers.d.ts.map +0 -1
  598. package/dist/tower/ui/Fibers.js +0 -157
  599. package/dist/tower/ui/Fibers.js.map +0 -1
  600. package/dist/tower/ui/Logs.d.ts +0 -5
  601. package/dist/tower/ui/Logs.d.ts.map +0 -1
  602. package/dist/tower/ui/Logs.js.map +0 -1
  603. package/dist/tower/ui/Metrics.d.ts +0 -5
  604. package/dist/tower/ui/Metrics.d.ts.map +0 -1
  605. package/dist/tower/ui/Metrics.js.map +0 -1
  606. package/dist/tower/ui/Routes.d.ts.map +0 -1
  607. package/dist/tower/ui/Routes.js.map +0 -1
  608. package/dist/tower/ui/Services.d.ts.map +0 -1
  609. package/dist/tower/ui/Services.js.map +0 -1
  610. package/dist/tower/ui/Shell.d.ts.map +0 -1
  611. package/dist/tower/ui/Shell.js +0 -12
  612. package/dist/tower/ui/Shell.js.map +0 -1
  613. package/dist/tower/ui/System.d.ts +0 -5
  614. package/dist/tower/ui/System.d.ts.map +0 -1
  615. package/dist/tower/ui/System.js +0 -65
  616. package/dist/tower/ui/System.js.map +0 -1
  617. package/dist/tower/ui/Traces.d.ts +0 -13
  618. package/dist/tower/ui/Traces.d.ts.map +0 -1
  619. package/dist/tower/ui/Traces.js +0 -219
  620. package/dist/tower/ui/Traces.js.map +0 -1
  621. package/src/Commander.ts +0 -585
  622. package/src/FilePathPattern.ts +0 -115
  623. package/src/PlatformError.ts +0 -73
  624. package/src/TuplePathPattern.ts +0 -75
  625. package/src/tower/Tower.ts +0 -47
  626. package/src/tower/index.ts +0 -3
  627. package/src/tower/routes/route.tsx +0 -8
  628. /package/dist/{tower → studio}/Simulation.d.ts +0 -0
  629. /package/dist/{tower → studio}/Simulation.js +0 -0
  630. /package/dist/{tower → studio}/routes/layout.d.ts +0 -0
  631. /package/dist/{tower → studio}/routes/layout.js +0 -0
  632. /package/dist/{tower → studio}/routes/tree.js +0 -0
  633. /package/dist/{tower → studio}/ui/Routes.d.ts +0 -0
  634. /package/dist/{tower → studio}/ui/Services.d.ts +0 -0
  635. /package/dist/{tower → studio}/ui/Shell.d.ts +0 -0
  636. /package/src/{ContentNegotiation.ts → _ContentNegotiation.ts} +0 -0
  637. /package/src/{Effectify.ts → _Effectify.ts} +0 -0
  638. /package/src/{StartApp.ts → _StartApp.ts} +0 -0
  639. /package/src/{StreamExtra.ts → _StreamExtra.ts} +0 -0
  640. /package/src/{Values.ts → _Values.ts} +0 -0
  641. /package/src/{tower → studio}/Simulation.ts +0 -0
  642. /package/src/{tower → studio}/routes/layout.tsx +0 -0
  643. /package/src/{tower → studio}/routes/tree.ts +0 -0
  644. /package/src/{tower → studio}/ui/Routes.tsx +0 -0
  645. /package/src/{tower → studio}/ui/Services.tsx +0 -0
@@ -0,0 +1,685 @@
1
+ import * as Console from "effect/Console"
2
+ import * as Effect from "effect/Effect"
3
+ import * as Function from "effect/Function"
4
+ import type * as Option from "effect/Option"
5
+ import * as Predicate from "effect/Predicate"
6
+ import type * as Types from "effect/Types"
7
+ import * as CliError from "./CliError.ts"
8
+ import * as Flag from "./Flag.ts"
9
+ import * as HelpDoc from "./HelpDoc.ts"
10
+ import * as Param from "./Param.ts"
11
+ import * as Primitive from "./Primitive.ts"
12
+
13
+ type Token =
14
+ | { _tag: "LongOption"; name: string; raw: string; value?: string }
15
+ | { _tag: "ShortOption"; flag: string; raw: string; value?: string }
16
+ | { _tag: "Value"; value: string }
17
+
18
+ interface LexResult {
19
+ readonly tokens: ReadonlyArray<Token>
20
+ readonly trailingOperands: ReadonlyArray<string>
21
+ }
22
+
23
+ const lex = (argv: ReadonlyArray<string>): LexResult => {
24
+ const endIdx = argv.indexOf("--")
25
+ const args = endIdx === -1 ? argv : argv.slice(0, endIdx)
26
+ const trailing = endIdx === -1 ? [] : argv.slice(endIdx + 1)
27
+ const tokens: Array<Token> = []
28
+ for (const arg of args) {
29
+ if (!arg.startsWith("-")) {
30
+ tokens.push({ _tag: "Value", value: arg })
31
+ } else if (arg.startsWith("--")) {
32
+ const [name, value] = arg.slice(2).split("=", 2)
33
+ tokens.push({ _tag: "LongOption", name, raw: arg, value })
34
+ } else if (arg.length > 1) {
35
+ const flags = arg.slice(1)
36
+ const eq = flags.indexOf("=")
37
+ if (eq !== -1) {
38
+ tokens.push({
39
+ _tag: "ShortOption",
40
+ flag: flags.slice(0, eq),
41
+ raw: `-${flags.slice(0, eq)}`,
42
+ value: flags.slice(eq + 1),
43
+ })
44
+ } else {
45
+ for (const ch of flags) tokens.push({ _tag: "ShortOption", flag: ch, raw: `-${ch}` })
46
+ }
47
+ } else {
48
+ tokens.push({ _tag: "Value", value: arg })
49
+ }
50
+ }
51
+ return { tokens, trailingOperands: trailing }
52
+ }
53
+
54
+ const levenshtein = (a: string, b: string): number => {
55
+ const m = a.length,
56
+ n = b.length
57
+ const dp: Array<Array<number>> = Array.from({ length: m + 1 }, () => new Array(n + 1).fill(0))
58
+ for (let i = 0; i <= m; i++) dp[i][0] = i
59
+ for (let j = 0; j <= n; j++) dp[0][j] = j
60
+ for (let i = 1; i <= m; i++)
61
+ for (let j = 1; j <= n; j++) {
62
+ const cost = a[i - 1] === b[j - 1] ? 0 : 1
63
+ dp[i][j] = Math.min(dp[i - 1][j] + 1, dp[i][j - 1] + 1, dp[i - 1][j - 1] + cost)
64
+ }
65
+ return dp[m][n]
66
+ }
67
+
68
+ const suggest = (input: string, candidates: ReadonlyArray<string>): ReadonlyArray<string> => {
69
+ const ds = candidates
70
+ .map((c) => [levenshtein(input, c), c] as const)
71
+ .filter(([d]) => d <= 2)
72
+ .sort(([a], [b]) => a - b)
73
+ if (ds.length === 0) return []
74
+ const min = ds[0][0]
75
+ return ds.filter(([d]) => d === min).map(([, c]) => c)
76
+ }
77
+
78
+ interface ConfigInternal {
79
+ readonly arguments: ReadonlyArray<Param.Param<"argument", any>>
80
+ readonly flags: ReadonlyArray<Param.Param<"flag", any>>
81
+ readonly orderedParams: ReadonlyArray<Param.Param<any, any>>
82
+ readonly tree: ConfigTree
83
+ }
84
+
85
+ type ConfigTree = Record<string, ConfigNode>
86
+ type ConfigNode =
87
+ | { readonly _tag: "Param"; readonly index: number }
88
+ | { readonly _tag: "Array"; readonly children: ReadonlyArray<ConfigNode> }
89
+ | { readonly _tag: "Nested"; readonly tree: ConfigTree }
90
+
91
+ const parseConfig = (config: Record<string, any>): ConfigInternal => {
92
+ const orderedParams: Array<Param.Param<any, any>> = []
93
+ const flags: Array<Param.Param<"flag", any>> = []
94
+ const args: Array<Param.Param<"argument", any>> = []
95
+
96
+ const walk = (cfg: Record<string, any>): ConfigTree => {
97
+ const tree: ConfigTree = {}
98
+ for (const key in cfg) tree[key] = walkValue(cfg[key])
99
+ return tree
100
+ }
101
+
102
+ const walkValue = (v: any): ConfigNode => {
103
+ if (Array.isArray(v)) return { _tag: "Array", children: v.map(walkValue) }
104
+ if (Param.isParam(v)) {
105
+ const idx = orderedParams.length
106
+ orderedParams.push(v)
107
+ if (v.kind === "argument") args.push(v as any)
108
+ else flags.push(v as any)
109
+ return { _tag: "Param", index: idx }
110
+ }
111
+ return { _tag: "Nested", tree: walk(v) }
112
+ }
113
+
114
+ return { flags, arguments: args, orderedParams, tree: walk(config) }
115
+ }
116
+
117
+ const reconstructTree = (tree: ConfigTree, results: ReadonlyArray<any>): Record<string, any> => {
118
+ const out: Record<string, any> = {}
119
+ for (const key in tree) out[key] = nodeValue(tree[key], results)
120
+ return out
121
+ }
122
+
123
+ const nodeValue = (node: ConfigNode, results: ReadonlyArray<any>): any => {
124
+ if (node._tag === "Param") return results[node.index]
125
+ if (node._tag === "Array") return node.children.map((c) => nodeValue(c, results))
126
+ return reconstructTree(node.tree, results)
127
+ }
128
+
129
+ const helpFlag: Flag.Flag<boolean> = Flag.boolean("help").pipe(
130
+ Flag.withAlias("h"),
131
+ Flag.withDescription("Show help information"),
132
+ )
133
+ const versionFlag: Flag.Flag<boolean> = Flag.boolean("version").pipe(
134
+ Flag.withDescription("Show version information"),
135
+ )
136
+ const logLevelFlag: Flag.Flag<Option.Option<string>> = Flag.choice("log-level", [
137
+ "all",
138
+ "trace",
139
+ "debug",
140
+ "info",
141
+ "warn",
142
+ "warning",
143
+ "error",
144
+ "fatal",
145
+ "none",
146
+ ] as const).pipe(Flag.optional, Flag.withDescription("Sets the minimum log level"))
147
+
148
+ interface ParsedTokens {
149
+ readonly flags: Record<string, ReadonlyArray<string>>
150
+ readonly arguments: ReadonlyArray<string>
151
+ readonly errors?: ReadonlyArray<CliError.CliError>
152
+ readonly subcommand?: { readonly name: string; readonly parsedInput: ParsedTokens }
153
+ }
154
+
155
+ type FlagParam = Param.SingleParam<"flag", unknown>
156
+ type FlagMap = Record<string, Array<string>>
157
+ type FlagRegistry = { params: ReadonlyArray<FlagParam>; index: Map<string, FlagParam> }
158
+
159
+ const createFlagRegistry = (params: ReadonlyArray<FlagParam>): FlagRegistry => {
160
+ const index = new Map<string, FlagParam>()
161
+ for (const p of params) {
162
+ index.set(p.name, p)
163
+ for (const a of p.aliases) index.set(a, p)
164
+ }
165
+ return { params, index }
166
+ }
167
+
168
+ const createEmptyFlagMap = (params: ReadonlyArray<FlagParam>): FlagMap =>
169
+ Object.fromEntries(params.map((p) => [p.name, []]))
170
+
171
+ type FlagToken = Extract<Token, { _tag: "LongOption" | "ShortOption" }>
172
+ const isFlagToken = (t: Token): t is FlagToken =>
173
+ t._tag === "LongOption" || t._tag === "ShortOption"
174
+ const getFlagName = (t: FlagToken): string => (t._tag === "LongOption" ? t.name : t.flag)
175
+
176
+ const consumeFlagValue = (
177
+ tokens: ReadonlyArray<Token>,
178
+ i: number,
179
+ token: FlagToken,
180
+ spec: FlagParam,
181
+ ): { value: string | undefined; skip: number } => {
182
+ if (token.value !== undefined) return { value: token.value, skip: 0 }
183
+ if (Primitive.isBoolean(spec.primitiveType)) {
184
+ const next = tokens[i + 1]
185
+ if (next?._tag === "Value" && Primitive.isBooleanLiteral(next.value))
186
+ return { value: next.value, skip: 1 }
187
+ return { value: "true", skip: 0 }
188
+ }
189
+ const next = tokens[i + 1]
190
+ if (next?._tag === "Value") return { value: next.value, skip: 1 }
191
+ return { value: undefined, skip: 0 }
192
+ }
193
+
194
+ const consumeKnownFlags = (
195
+ tokens: ReadonlyArray<Token>,
196
+ registry: FlagRegistry,
197
+ ): { flagMap: FlagMap; remainder: ReadonlyArray<Token> } => {
198
+ const flagMap = createEmptyFlagMap(registry.params)
199
+ const remainder: Array<Token> = []
200
+ let i = 0
201
+ while (i < tokens.length) {
202
+ const t = tokens[i]
203
+ if (!isFlagToken(t)) {
204
+ remainder.push(t)
205
+ i++
206
+ continue
207
+ }
208
+ const spec = registry.index.get(getFlagName(t))
209
+ if (!spec) {
210
+ remainder.push(t)
211
+ i++
212
+ continue
213
+ }
214
+ const { value, skip } = consumeFlagValue(tokens, i, t, spec)
215
+ if (value !== undefined) flagMap[spec.name].push(value)
216
+ i += 1 + skip
217
+ }
218
+ return { flagMap, remainder }
219
+ }
220
+
221
+ const builtInParams: ReadonlyArray<FlagParam> = [
222
+ ...(Param.extractSingleParams(helpFlag) as FlagParam[]),
223
+ ...(Param.extractSingleParams(versionFlag) as FlagParam[]),
224
+ ...(Param.extractSingleParams(logLevelFlag) as FlagParam[]),
225
+ ]
226
+ const builtInRegistry = createFlagRegistry(builtInParams)
227
+
228
+ const extractBuiltInOptions = (
229
+ tokens: ReadonlyArray<Token>,
230
+ ): Effect.Effect<
231
+ {
232
+ help: boolean
233
+ version: boolean
234
+ logLevel: Option.Option<string>
235
+ remainder: ReadonlyArray<Token>
236
+ },
237
+ CliError.CliError
238
+ > =>
239
+ Effect.gen(function* () {
240
+ const { flagMap, remainder } = consumeKnownFlags(tokens, builtInRegistry)
241
+ const emptyArgs: Param.ParsedArgs = { flags: flagMap, arguments: [] }
242
+ const [, help] = yield* helpFlag.parse(emptyArgs)
243
+ const [, version] = yield* versionFlag.parse(emptyArgs)
244
+ const [, logLevel] = yield* logLevelFlag.parse(emptyArgs)
245
+ return { help, version, logLevel, remainder }
246
+ })
247
+
248
+ const parseArgs = (
249
+ lexResult: LexResult,
250
+ command: Command<any, any, any, any>,
251
+ commandPath: ReadonlyArray<string> = [],
252
+ ): Effect.Effect<ParsedTokens, CliError.CliError> =>
253
+ Effect.gen(function* () {
254
+ const impl = toImpl(command)
255
+ const singles = impl.config.flags.flatMap(Param.extractSingleParams) as FlagParam[]
256
+ const flagRegistry = createFlagRegistry(singles.filter(Param.isFlagParam))
257
+ const newPath = [...commandPath, command.name]
258
+ const { tokens, trailingOperands } = lexResult
259
+
260
+ const flagMap = createEmptyFlagMap(flagRegistry.params)
261
+ const errors: Array<CliError.CliError> = []
262
+ const args: Array<string> = []
263
+ let mode: "awaiting" | "collecting" = "awaiting"
264
+ let subResult:
265
+ | { sub: Command<any, any, any, any>; childTokens: ReadonlyArray<Token> }
266
+ | undefined
267
+ let i = 0
268
+
269
+ while (i < tokens.length) {
270
+ const t = tokens[i]
271
+ if (isFlagToken(t)) {
272
+ const spec = flagRegistry.index.get(getFlagName(t))
273
+ if (!spec) {
274
+ const validNames: Array<string> = []
275
+ for (const p of flagRegistry.params) {
276
+ validNames.push(p.name)
277
+ for (const a of p.aliases) validNames.push(a)
278
+ }
279
+ const sug = suggest(getFlagName(t), validNames).map((n) =>
280
+ n.length === 1 ? `-${n}` : `--${n}`,
281
+ )
282
+ errors.push(
283
+ new CliError.CliError({
284
+ reason: "UnrecognizedOption",
285
+ option: t._tag === "LongOption" ? `--${t.name}` : `-${t.flag}`,
286
+ suggestions: sug,
287
+ command: newPath,
288
+ }),
289
+ )
290
+ i++
291
+ continue
292
+ }
293
+ const { value, skip } = consumeFlagValue(tokens, i, t, spec)
294
+ if (value !== undefined) flagMap[spec.name].push(value)
295
+ i += 1 + skip
296
+ continue
297
+ }
298
+
299
+ if (t._tag === "Value") {
300
+ if (mode === "awaiting") {
301
+ const subIndex = new Map(command.subcommands.map((s: any) => [s.name, s]))
302
+ const sub = subIndex.get(t.value) as Command<any, any, any, any> | undefined
303
+ if (sub) {
304
+ const tail = consumeKnownFlags(tokens.slice(i + 1), flagRegistry)
305
+ for (const key in tail.flagMap) {
306
+ const vals = tail.flagMap[key]
307
+ if (vals?.length) for (const v of vals) flagMap[key].push(v)
308
+ }
309
+ subResult = { sub, childTokens: tail.remainder }
310
+ break
311
+ }
312
+ const expectsArgs = impl.config.arguments.length > 0
313
+ if (!expectsArgs && command.subcommands.length > 0) {
314
+ const sug = suggest(
315
+ t.value,
316
+ command.subcommands.map((s: any) => s.name),
317
+ )
318
+ errors.push(
319
+ new CliError.CliError({
320
+ reason: "UnknownSubcommand",
321
+ subcommand: t.value,
322
+ parent: newPath,
323
+ suggestions: sug,
324
+ }),
325
+ )
326
+ }
327
+ mode = "collecting"
328
+ }
329
+ args.push(t.value)
330
+ }
331
+ i++
332
+ }
333
+
334
+ if (!subResult) {
335
+ return {
336
+ flags: flagMap,
337
+ arguments: [...args, ...trailingOperands],
338
+ ...(errors.length > 0 && { errors }),
339
+ }
340
+ }
341
+
342
+ const subParsed = yield* parseArgs(
343
+ { tokens: subResult.childTokens, trailingOperands: [] },
344
+ subResult.sub,
345
+ newPath,
346
+ )
347
+ const allErrors = [...errors, ...(subParsed.errors ?? [])]
348
+ return {
349
+ flags: flagMap,
350
+ arguments: trailingOperands,
351
+ subcommand: { name: subResult.sub.name, parsedInput: subParsed },
352
+ ...(allErrors.length > 0 && { errors: allErrors }),
353
+ }
354
+ })
355
+
356
+ const getCommandPath = (p: ParsedTokens): ReadonlyArray<string> =>
357
+ p.subcommand ? [p.subcommand.name, ...getCommandPath(p.subcommand.parsedInput)] : []
358
+
359
+ const CommandTypeId = "~effect-start/Cli/Command" as const
360
+
361
+ export interface Command<Name extends string, Input, E = never, R = never> {
362
+ readonly [CommandTypeId]: typeof CommandTypeId
363
+ readonly name: Name
364
+ readonly description: string | undefined
365
+ readonly subcommands: ReadonlyArray<Command<any, any, any, any>>
366
+ }
367
+
368
+ export declare namespace Command {
369
+ interface Config {
370
+ readonly [key: string]:
371
+ | Param.Param<Param.ParamKind, any>
372
+ | ReadonlyArray<Param.Param<Param.ParamKind, any> | Config>
373
+ | Config
374
+ }
375
+
376
+ namespace Config {
377
+ type Infer<A extends Config> = Types.Simplify<{ readonly [K in keyof A]: InferValue<A[K]> }>
378
+ type InferValue<A> =
379
+ A extends ReadonlyArray<any>
380
+ ? { readonly [K in keyof A]: InferValue<A[K]> }
381
+ : A extends Param.Param<any, infer V>
382
+ ? V
383
+ : A extends Config
384
+ ? Infer<A>
385
+ : never
386
+ }
387
+
388
+ type Any = Command<string, unknown, unknown, unknown>
389
+ }
390
+
391
+ interface CommandInternal<Name extends string, Input, E, R> extends Command<Name, Input, E, R> {
392
+ readonly config: ConfigInternal
393
+ readonly parse: (input: ParsedTokens) => Effect.Effect<Input, CliError.CliError>
394
+ readonly handle: (
395
+ input: Input,
396
+ path: ReadonlyArray<string>,
397
+ ) => Effect.Effect<void, E | CliError.CliError, R>
398
+ readonly buildHelpDoc: (path: ReadonlyArray<string>) => HelpDoc.HelpDoc
399
+ }
400
+
401
+ const toImpl = <N extends string, I, E, R>(c: Command<N, I, E, R>): CommandInternal<N, I, E, R> =>
402
+ c as CommandInternal<N, I, E, R>
403
+
404
+ export const isCommand = (u: unknown): u is Command.Any => Predicate.hasProperty(u, CommandTypeId)
405
+
406
+ const makeCommandInternal = <N extends string, I, E, R>(opts: {
407
+ name: N
408
+ config: ConfigInternal
409
+ description?: string
410
+ subcommands?: ReadonlyArray<Command<any, any, any, any>>
411
+ parse?: (input: ParsedTokens) => Effect.Effect<I, CliError.CliError>
412
+ handle?: (input: I, path: ReadonlyArray<string>) => Effect.Effect<void, E | CliError.CliError, R>
413
+ }): Command<N, I, E, R> => {
414
+ const config = opts.config
415
+
416
+ const handle = (
417
+ input: I,
418
+ path: ReadonlyArray<string>,
419
+ ): Effect.Effect<void, E | CliError.CliError, R> =>
420
+ opts.handle
421
+ ? opts.handle(input, path)
422
+ : (Effect.fail(new CliError.CliError({ reason: "ShowHelp", commandPath: path })) as any)
423
+
424
+ const parse =
425
+ opts.parse ??
426
+ ((input: ParsedTokens) =>
427
+ Effect.gen(function* () {
428
+ const parsedArgs: Param.ParsedArgs = { flags: input.flags, arguments: input.arguments }
429
+ const values: Array<unknown> = []
430
+ let current = parsedArgs.arguments
431
+ for (const param of config.orderedParams) {
432
+ const [remaining, parsed] = yield* param.parse({
433
+ flags: parsedArgs.flags,
434
+ arguments: current,
435
+ })
436
+ values.push(parsed)
437
+ current = remaining
438
+ }
439
+ return reconstructTree(config.tree, values) as I
440
+ }))
441
+
442
+ const buildHelpDoc = (path: ReadonlyArray<string>): HelpDoc.HelpDoc => {
443
+ const argDocs: Array<HelpDoc.ArgDoc> = []
444
+ for (const arg of config.arguments) {
445
+ const singles = Param.extractSingleParams(arg)
446
+ const meta = Param.getParamMetadata(arg)
447
+ for (const s of singles) {
448
+ argDocs.push({
449
+ name: s.name,
450
+ type: s.typeName ?? Primitive.getTypeName(s.primitiveType),
451
+ description: s.description,
452
+ required: !meta.isOptional,
453
+ variadic: meta.isVariadic,
454
+ })
455
+ }
456
+ }
457
+
458
+ let usage = path.length > 0 ? path.join(" ") : opts.name
459
+ const subs = opts.subcommands ?? []
460
+ if (subs.length > 0) usage += " <subcommand>"
461
+ usage += " [flags]"
462
+ for (const a of argDocs) {
463
+ const n = a.variadic ? `<${a.name}...>` : `<${a.name}>`
464
+ usage += ` ${a.required ? n : `[${n}]`}`
465
+ }
466
+
467
+ const flagDocs: Array<HelpDoc.FlagDoc> = []
468
+ for (const f of config.flags) {
469
+ const singles = Param.extractSingleParams(f)
470
+ for (const s of singles) {
471
+ flagDocs.push({
472
+ name: s.name,
473
+ aliases: s.aliases.map((a) => (a.length === 1 ? `-${a}` : `--${a}`)),
474
+ type: s.typeName ?? Primitive.getTypeName(s.primitiveType),
475
+ description: s.description,
476
+ required: s.primitiveType._tag !== "Boolean",
477
+ })
478
+ }
479
+ }
480
+
481
+ return {
482
+ description: opts.description ?? "",
483
+ usage,
484
+ flags: flagDocs,
485
+ ...(argDocs.length > 0 && { args: argDocs }),
486
+ ...(subs.length > 0 && {
487
+ subcommands: subs.map((s) => ({ name: s.name, description: s.description ?? "" })),
488
+ }),
489
+ }
490
+ }
491
+
492
+ return Object.assign(Object.create(null), {
493
+ [CommandTypeId]: CommandTypeId,
494
+ name: opts.name,
495
+ description: opts.description,
496
+ subcommands: opts.subcommands ?? [],
497
+ config,
498
+ parse,
499
+ handle,
500
+ buildHelpDoc,
501
+ })
502
+ }
503
+
504
+ const getHelpForCommandPath = (
505
+ command: Command.Any,
506
+ path: ReadonlyArray<string>,
507
+ ): HelpDoc.HelpDoc => {
508
+ let current: Command.Any = command
509
+ for (let i = 1; i < path.length; i++) {
510
+ const sub = current.subcommands.find((s) => s.name === path[i])
511
+ if (sub) current = sub
512
+ }
513
+ return toImpl(current).buildHelpDoc(path)
514
+ }
515
+
516
+ const checkForDuplicateFlags = (parent: Command.Any, subs: ReadonlyArray<Command.Any>): void => {
517
+ const parentNames = new Set<string>()
518
+ for (const f of toImpl(parent).config.flags)
519
+ for (const s of Param.extractSingleParams(f)) parentNames.add(s.name)
520
+ for (const sub of subs)
521
+ for (const f of toImpl(sub).config.flags)
522
+ for (const s of Param.extractSingleParams(f))
523
+ if (parentNames.has(s.name))
524
+ throw new CliError.CliError({
525
+ reason: "DuplicateOption",
526
+ option: s.name,
527
+ parentCommand: parent.name,
528
+ childCommand: sub.name,
529
+ })
530
+ }
531
+
532
+ export const make: {
533
+ <Name extends string>(
534
+ name: Name,
535
+ options?: {
536
+ description?: string
537
+ subcommands?: ReadonlyArray<Command<any, any, any, any>>
538
+ },
539
+ ): Command<Name, {}, never, never>
540
+ <Name extends string, const Cfg extends Command.Config>(
541
+ name: Name,
542
+ options: {
543
+ config: Cfg
544
+ description?: string
545
+ subcommands?: ReadonlyArray<Command<any, any, any, any>>
546
+ },
547
+ ): Command<Name, Command.Config.Infer<Cfg>, never, never>
548
+ <Name extends string, R, E>(
549
+ name: Name,
550
+ options: {
551
+ description?: string
552
+ subcommands?: ReadonlyArray<Command<any, any, any, any>>
553
+ handler: (config: {}) => Effect.Effect<void, E, R>
554
+ },
555
+ ): Command<Name, {}, E, R>
556
+ <Name extends string, const Cfg extends Command.Config, R, E>(
557
+ name: Name,
558
+ options: {
559
+ config: Cfg
560
+ description?: string
561
+ subcommands?: ReadonlyArray<Command<any, any, any, any>>
562
+ handler: (config: Command.Config.Infer<Cfg>) => Effect.Effect<void, E, R>
563
+ },
564
+ ): Command<Name, Command.Config.Infer<Cfg>, E, R>
565
+ } = (<Name extends string>(
566
+ name: Name,
567
+ options?: {
568
+ config?: Command.Config
569
+ description?: string
570
+ subcommands?: ReadonlyArray<Command<any, any, any, any>>
571
+ handler?: (config: any) => Effect.Effect<void, any, any>
572
+ },
573
+ ) => {
574
+ const parsed = parseConfig(options?.config ?? {})
575
+ const cmd = makeCommandInternal({
576
+ name,
577
+ config: parsed,
578
+ description: options?.description,
579
+ ...(options?.handler ? { handle: options.handler } : {}),
580
+ })
581
+ if (!options?.subcommands?.length) return cmd
582
+
583
+ const subs = options.subcommands
584
+ checkForDuplicateFlags(cmd, subs)
585
+ const impl = toImpl(cmd)
586
+ const byName = new Map(subs.map((s) => [s.name, toImpl(s)] as const))
587
+
588
+ const parse = (raw: ParsedTokens): Effect.Effect<any, CliError.CliError> =>
589
+ Effect.gen(function* () {
590
+ const parent = yield* impl.parse(raw)
591
+ if (!raw.subcommand) return parent
592
+ const sub = byName.get(raw.subcommand.name)
593
+ if (!sub) return parent
594
+ const result = yield* sub.parse(raw.subcommand.parsedInput)
595
+ return Object.assign({}, parent, { _subcommand: { name: sub.name, result } })
596
+ })
597
+
598
+ const handle = (input: any, path: ReadonlyArray<string>): Effect.Effect<void, any, any> =>
599
+ Effect.gen(function* () {
600
+ if (input._subcommand) {
601
+ const child = byName.get(input._subcommand.name)
602
+ if (!child)
603
+ return yield* Effect.fail(
604
+ new CliError.CliError({ reason: "ShowHelp", commandPath: path }),
605
+ )
606
+ return yield* child.handle(input._subcommand.result, [...path, child.name])
607
+ }
608
+ return yield* impl.handle(input, path)
609
+ })
610
+
611
+ return makeCommandInternal({
612
+ name: impl.name,
613
+ config: impl.config,
614
+ description: impl.description as any,
615
+ subcommands: subs,
616
+ parse,
617
+ handle,
618
+ })
619
+ }) as any
620
+
621
+ const showHelp = (
622
+ command: Command.Any,
623
+ path: ReadonlyArray<string>,
624
+ errors?: ReadonlyArray<CliError.CliError>,
625
+ ) =>
626
+ Effect.gen(function* () {
627
+ yield* Console.log(HelpDoc.formatHelpDoc(getHelpForCommandPath(command, path)))
628
+ if (errors && errors.length > 0) yield* Console.error(CliError.formatErrors(errors))
629
+ })
630
+
631
+ export const runWith = <N extends string, I, E, R>(
632
+ command: Command<N, I, E, R>,
633
+ config: { readonly version: string },
634
+ ): ((input: ReadonlyArray<string>) => Effect.Effect<void, E | CliError.CliError, R>) => {
635
+ const impl = toImpl(command)
636
+ return (args: ReadonlyArray<string>) =>
637
+ Effect.gen(function* () {
638
+ const { tokens, trailingOperands } = lex(args)
639
+ const { help, version, remainder } = yield* extractBuiltInOptions(tokens)
640
+ const parsedArgs = yield* parseArgs({ tokens: remainder, trailingOperands }, command)
641
+ const commandPath = [command.name, ...getCommandPath(parsedArgs)]
642
+
643
+ if (help) {
644
+ yield* Console.log(HelpDoc.formatHelpDoc(getHelpForCommandPath(command, commandPath)))
645
+ return
646
+ }
647
+ if (version) {
648
+ yield* Console.log(HelpDoc.formatVersion(command.name, config.version))
649
+ return
650
+ }
651
+
652
+ if (parsedArgs.errors && parsedArgs.errors.length > 0) {
653
+ yield* showHelp(command, commandPath, parsedArgs.errors)
654
+ return
655
+ }
656
+
657
+ const parseResult = yield* Effect.either(impl.parse(parsedArgs))
658
+ if (parseResult._tag === "Left") {
659
+ yield* showHelp(command, commandPath, [parseResult.left])
660
+ return
661
+ }
662
+
663
+ yield* impl.handle(parseResult.right, [command.name]) as Effect.Effect<
664
+ void,
665
+ E | CliError.CliError,
666
+ R
667
+ >
668
+ }) as Effect.Effect<void, E | CliError.CliError, R>
669
+ }
670
+
671
+ export const run: {
672
+ <N extends string, I, E, R>(
673
+ command: Command<N, I, E, R>,
674
+ config: { readonly version: string },
675
+ ): Effect.Effect<void, E | CliError.CliError, R>
676
+ (config: {
677
+ readonly version: string
678
+ }): <N extends string, I, E, R>(
679
+ command: Command<N, I, E, R>,
680
+ ) => Effect.Effect<void, E | CliError.CliError, R>
681
+ } = Function.dual(
682
+ 2,
683
+ <N extends string, I, E, R>(command: Command<N, I, E, R>, config: { readonly version: string }) =>
684
+ runWith(command, config)(process.argv.slice(2)),
685
+ )