@fuzdev/fuz_app 0.1.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 (457) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +49 -0
  3. package/dist/actions/action_bridge.d.ts +65 -0
  4. package/dist/actions/action_bridge.d.ts.map +1 -0
  5. package/dist/actions/action_bridge.js +76 -0
  6. package/dist/actions/action_codegen.d.ts +97 -0
  7. package/dist/actions/action_codegen.d.ts.map +1 -0
  8. package/dist/actions/action_codegen.js +280 -0
  9. package/dist/actions/action_registry.d.ts +35 -0
  10. package/dist/actions/action_registry.d.ts.map +1 -0
  11. package/dist/actions/action_registry.js +83 -0
  12. package/dist/actions/action_spec.d.ts +169 -0
  13. package/dist/actions/action_spec.d.ts.map +1 -0
  14. package/dist/actions/action_spec.js +76 -0
  15. package/dist/auth/account_queries.d.ts +96 -0
  16. package/dist/auth/account_queries.d.ts.map +1 -0
  17. package/dist/auth/account_queries.js +172 -0
  18. package/dist/auth/account_routes.d.ts +86 -0
  19. package/dist/auth/account_routes.d.ts.map +1 -0
  20. package/dist/auth/account_routes.js +406 -0
  21. package/dist/auth/account_schema.d.ts +192 -0
  22. package/dist/auth/account_schema.d.ts.map +1 -0
  23. package/dist/auth/account_schema.js +105 -0
  24. package/dist/auth/admin_routes.d.ts +29 -0
  25. package/dist/auth/admin_routes.d.ts.map +1 -0
  26. package/dist/auth/admin_routes.js +193 -0
  27. package/dist/auth/api_token.d.ts +33 -0
  28. package/dist/auth/api_token.d.ts.map +1 -0
  29. package/dist/auth/api_token.js +36 -0
  30. package/dist/auth/api_token_queries.d.ts +80 -0
  31. package/dist/auth/api_token_queries.d.ts.map +1 -0
  32. package/dist/auth/api_token_queries.js +116 -0
  33. package/dist/auth/app_settings_queries.d.ts +33 -0
  34. package/dist/auth/app_settings_queries.d.ts.map +1 -0
  35. package/dist/auth/app_settings_queries.js +51 -0
  36. package/dist/auth/app_settings_routes.d.ts +27 -0
  37. package/dist/auth/app_settings_routes.d.ts.map +1 -0
  38. package/dist/auth/app_settings_routes.js +66 -0
  39. package/dist/auth/app_settings_schema.d.ts +35 -0
  40. package/dist/auth/app_settings_schema.d.ts.map +1 -0
  41. package/dist/auth/app_settings_schema.js +22 -0
  42. package/dist/auth/audit_log_queries.d.ts +90 -0
  43. package/dist/auth/audit_log_queries.d.ts.map +1 -0
  44. package/dist/auth/audit_log_queries.js +205 -0
  45. package/dist/auth/audit_log_routes.d.ts +33 -0
  46. package/dist/auth/audit_log_routes.d.ts.map +1 -0
  47. package/dist/auth/audit_log_routes.js +106 -0
  48. package/dist/auth/audit_log_schema.d.ts +259 -0
  49. package/dist/auth/audit_log_schema.d.ts.map +1 -0
  50. package/dist/auth/audit_log_schema.js +123 -0
  51. package/dist/auth/bearer_auth.d.ts +32 -0
  52. package/dist/auth/bearer_auth.d.ts.map +1 -0
  53. package/dist/auth/bearer_auth.js +90 -0
  54. package/dist/auth/bootstrap_account.d.ts +82 -0
  55. package/dist/auth/bootstrap_account.d.ts.map +1 -0
  56. package/dist/auth/bootstrap_account.js +97 -0
  57. package/dist/auth/bootstrap_routes.d.ts +74 -0
  58. package/dist/auth/bootstrap_routes.d.ts.map +1 -0
  59. package/dist/auth/bootstrap_routes.js +154 -0
  60. package/dist/auth/daemon_token.d.ts +49 -0
  61. package/dist/auth/daemon_token.d.ts.map +1 -0
  62. package/dist/auth/daemon_token.js +49 -0
  63. package/dist/auth/daemon_token_middleware.d.ts +93 -0
  64. package/dist/auth/daemon_token_middleware.d.ts.map +1 -0
  65. package/dist/auth/daemon_token_middleware.js +167 -0
  66. package/dist/auth/ddl.d.ts +27 -0
  67. package/dist/auth/ddl.d.ts.map +1 -0
  68. package/dist/auth/ddl.js +111 -0
  69. package/dist/auth/deps.d.ts +52 -0
  70. package/dist/auth/deps.d.ts.map +1 -0
  71. package/dist/auth/deps.js +10 -0
  72. package/dist/auth/invite_queries.d.ts +68 -0
  73. package/dist/auth/invite_queries.d.ts.map +1 -0
  74. package/dist/auth/invite_queries.js +105 -0
  75. package/dist/auth/invite_routes.d.ts +18 -0
  76. package/dist/auth/invite_routes.d.ts.map +1 -0
  77. package/dist/auth/invite_routes.js +129 -0
  78. package/dist/auth/invite_schema.d.ts +51 -0
  79. package/dist/auth/invite_schema.d.ts.map +1 -0
  80. package/dist/auth/invite_schema.js +25 -0
  81. package/dist/auth/keyring.d.ts +87 -0
  82. package/dist/auth/keyring.d.ts.map +1 -0
  83. package/dist/auth/keyring.js +142 -0
  84. package/dist/auth/middleware.d.ts +40 -0
  85. package/dist/auth/middleware.d.ts.map +1 -0
  86. package/dist/auth/middleware.js +64 -0
  87. package/dist/auth/migrations.d.ts +42 -0
  88. package/dist/auth/migrations.d.ts.map +1 -0
  89. package/dist/auth/migrations.js +79 -0
  90. package/dist/auth/password.d.ts +39 -0
  91. package/dist/auth/password.d.ts.map +1 -0
  92. package/dist/auth/password.js +25 -0
  93. package/dist/auth/password_argon2.d.ts +43 -0
  94. package/dist/auth/password_argon2.d.ts.map +1 -0
  95. package/dist/auth/password_argon2.js +76 -0
  96. package/dist/auth/permit_queries.d.ts +72 -0
  97. package/dist/auth/permit_queries.d.ts.map +1 -0
  98. package/dist/auth/permit_queries.js +116 -0
  99. package/dist/auth/request_context.d.ts +114 -0
  100. package/dist/auth/request_context.d.ts.map +1 -0
  101. package/dist/auth/request_context.js +176 -0
  102. package/dist/auth/require_keeper.d.ts +20 -0
  103. package/dist/auth/require_keeper.d.ts.map +1 -0
  104. package/dist/auth/require_keeper.js +35 -0
  105. package/dist/auth/role_schema.d.ts +69 -0
  106. package/dist/auth/role_schema.d.ts.map +1 -0
  107. package/dist/auth/role_schema.js +70 -0
  108. package/dist/auth/route_guards.d.ts +21 -0
  109. package/dist/auth/route_guards.d.ts.map +1 -0
  110. package/dist/auth/route_guards.js +32 -0
  111. package/dist/auth/session_cookie.d.ts +158 -0
  112. package/dist/auth/session_cookie.d.ts.map +1 -0
  113. package/dist/auth/session_cookie.js +135 -0
  114. package/dist/auth/session_lifecycle.d.ts +35 -0
  115. package/dist/auth/session_lifecycle.d.ts.map +1 -0
  116. package/dist/auth/session_lifecycle.js +27 -0
  117. package/dist/auth/session_middleware.d.ts +33 -0
  118. package/dist/auth/session_middleware.d.ts.map +1 -0
  119. package/dist/auth/session_middleware.js +62 -0
  120. package/dist/auth/session_queries.d.ts +135 -0
  121. package/dist/auth/session_queries.d.ts.map +1 -0
  122. package/dist/auth/session_queries.js +186 -0
  123. package/dist/auth/signup_routes.d.ts +32 -0
  124. package/dist/auth/signup_routes.d.ts.map +1 -0
  125. package/dist/auth/signup_routes.js +150 -0
  126. package/dist/cli/args.d.ts +48 -0
  127. package/dist/cli/args.d.ts.map +1 -0
  128. package/dist/cli/args.js +76 -0
  129. package/dist/cli/config.d.ts +48 -0
  130. package/dist/cli/config.d.ts.map +1 -0
  131. package/dist/cli/config.js +77 -0
  132. package/dist/cli/daemon.d.ts +82 -0
  133. package/dist/cli/daemon.d.ts.map +1 -0
  134. package/dist/cli/daemon.js +149 -0
  135. package/dist/cli/help.d.ts +85 -0
  136. package/dist/cli/help.d.ts.map +1 -0
  137. package/dist/cli/help.js +138 -0
  138. package/dist/cli/logger.d.ts +46 -0
  139. package/dist/cli/logger.d.ts.map +1 -0
  140. package/dist/cli/logger.js +48 -0
  141. package/dist/cli/util.d.ts +36 -0
  142. package/dist/cli/util.d.ts.map +1 -0
  143. package/dist/cli/util.js +50 -0
  144. package/dist/crypto.d.ts +13 -0
  145. package/dist/crypto.d.ts.map +1 -0
  146. package/dist/crypto.js +19 -0
  147. package/dist/db/assert_row.d.ts +18 -0
  148. package/dist/db/assert_row.d.ts.map +1 -0
  149. package/dist/db/assert_row.js +24 -0
  150. package/dist/db/create_db.d.ts +38 -0
  151. package/dist/db/create_db.d.ts.map +1 -0
  152. package/dist/db/create_db.js +57 -0
  153. package/dist/db/db.d.ts +97 -0
  154. package/dist/db/db.d.ts.map +1 -0
  155. package/dist/db/db.js +76 -0
  156. package/dist/db/db_pg.d.ts +21 -0
  157. package/dist/db/db_pg.d.ts.map +1 -0
  158. package/dist/db/db_pg.js +45 -0
  159. package/dist/db/db_pglite.d.ts +21 -0
  160. package/dist/db/db_pglite.d.ts.map +1 -0
  161. package/dist/db/db_pglite.js +28 -0
  162. package/dist/db/migrate.d.ts +67 -0
  163. package/dist/db/migrate.d.ts.map +1 -0
  164. package/dist/db/migrate.js +118 -0
  165. package/dist/db/pg_error.d.ts +16 -0
  166. package/dist/db/pg_error.d.ts.map +1 -0
  167. package/dist/db/pg_error.js +15 -0
  168. package/dist/db/query_deps.d.ts +14 -0
  169. package/dist/db/query_deps.d.ts.map +1 -0
  170. package/dist/db/query_deps.js +9 -0
  171. package/dist/db/sql_identifier.d.ts +27 -0
  172. package/dist/db/sql_identifier.d.ts.map +1 -0
  173. package/dist/db/sql_identifier.js +31 -0
  174. package/dist/db/status.d.ts +62 -0
  175. package/dist/db/status.d.ts.map +1 -0
  176. package/dist/db/status.js +116 -0
  177. package/dist/dev/setup.d.ts +159 -0
  178. package/dist/dev/setup.d.ts.map +1 -0
  179. package/dist/dev/setup.js +265 -0
  180. package/dist/env/dotenv.d.ts +25 -0
  181. package/dist/env/dotenv.d.ts.map +1 -0
  182. package/dist/env/dotenv.js +52 -0
  183. package/dist/env/load.d.ts +52 -0
  184. package/dist/env/load.d.ts.map +1 -0
  185. package/dist/env/load.js +79 -0
  186. package/dist/env/mask.d.ts +19 -0
  187. package/dist/env/mask.d.ts.map +1 -0
  188. package/dist/env/mask.js +26 -0
  189. package/dist/env/resolve.d.ts +126 -0
  190. package/dist/env/resolve.d.ts.map +1 -0
  191. package/dist/env/resolve.js +200 -0
  192. package/dist/hono_context.d.ts +48 -0
  193. package/dist/hono_context.d.ts.map +1 -0
  194. package/dist/hono_context.js +22 -0
  195. package/dist/http/common_routes.d.ts +52 -0
  196. package/dist/http/common_routes.d.ts.map +1 -0
  197. package/dist/http/common_routes.js +65 -0
  198. package/dist/http/db_routes.d.ts +57 -0
  199. package/dist/http/db_routes.d.ts.map +1 -0
  200. package/dist/http/db_routes.js +176 -0
  201. package/dist/http/error_schemas.d.ts +169 -0
  202. package/dist/http/error_schemas.d.ts.map +1 -0
  203. package/dist/http/error_schemas.js +178 -0
  204. package/dist/http/middleware_spec.d.ts +19 -0
  205. package/dist/http/middleware_spec.d.ts.map +1 -0
  206. package/dist/http/middleware_spec.js +9 -0
  207. package/dist/http/origin.d.ts +57 -0
  208. package/dist/http/origin.d.ts.map +1 -0
  209. package/dist/http/origin.js +207 -0
  210. package/dist/http/proxy.d.ts +112 -0
  211. package/dist/http/proxy.d.ts.map +1 -0
  212. package/dist/http/proxy.js +240 -0
  213. package/dist/http/route_spec.d.ts +197 -0
  214. package/dist/http/route_spec.d.ts.map +1 -0
  215. package/dist/http/route_spec.js +243 -0
  216. package/dist/http/schema_helpers.d.ts +64 -0
  217. package/dist/http/schema_helpers.d.ts.map +1 -0
  218. package/dist/http/schema_helpers.js +90 -0
  219. package/dist/http/surface.d.ts +132 -0
  220. package/dist/http/surface.d.ts.map +1 -0
  221. package/dist/http/surface.js +156 -0
  222. package/dist/http/surface_query.d.ts +77 -0
  223. package/dist/http/surface_query.d.ts.map +1 -0
  224. package/dist/http/surface_query.js +86 -0
  225. package/dist/rate_limiter.d.ts +94 -0
  226. package/dist/rate_limiter.d.ts.map +1 -0
  227. package/dist/rate_limiter.js +156 -0
  228. package/dist/realtime/sse.d.ts +80 -0
  229. package/dist/realtime/sse.d.ts.map +1 -0
  230. package/dist/realtime/sse.js +109 -0
  231. package/dist/realtime/sse_auth_guard.d.ts +93 -0
  232. package/dist/realtime/sse_auth_guard.d.ts.map +1 -0
  233. package/dist/realtime/sse_auth_guard.js +111 -0
  234. package/dist/realtime/subscriber_registry.d.ts +85 -0
  235. package/dist/realtime/subscriber_registry.d.ts.map +1 -0
  236. package/dist/realtime/subscriber_registry.js +108 -0
  237. package/dist/runtime/deno.d.ts +21 -0
  238. package/dist/runtime/deno.d.ts.map +1 -0
  239. package/dist/runtime/deno.js +83 -0
  240. package/dist/runtime/deps.d.ts +113 -0
  241. package/dist/runtime/deps.d.ts.map +1 -0
  242. package/dist/runtime/deps.js +10 -0
  243. package/dist/runtime/fs.d.ts +15 -0
  244. package/dist/runtime/fs.d.ts.map +1 -0
  245. package/dist/runtime/fs.js +17 -0
  246. package/dist/runtime/mock.d.ts +81 -0
  247. package/dist/runtime/mock.d.ts.map +1 -0
  248. package/dist/runtime/mock.js +195 -0
  249. package/dist/runtime/node.d.ts +17 -0
  250. package/dist/runtime/node.d.ts.map +1 -0
  251. package/dist/runtime/node.js +117 -0
  252. package/dist/schema_meta.d.ts +16 -0
  253. package/dist/schema_meta.d.ts.map +1 -0
  254. package/dist/schema_meta.js +9 -0
  255. package/dist/sensitivity.d.ts +15 -0
  256. package/dist/sensitivity.d.ts.map +1 -0
  257. package/dist/sensitivity.js +9 -0
  258. package/dist/server/app_backend.d.ts +74 -0
  259. package/dist/server/app_backend.d.ts.map +1 -0
  260. package/dist/server/app_backend.js +39 -0
  261. package/dist/server/app_server.d.ts +201 -0
  262. package/dist/server/app_server.d.ts.map +1 -0
  263. package/dist/server/app_server.js +266 -0
  264. package/dist/server/env.d.ts +68 -0
  265. package/dist/server/env.d.ts.map +1 -0
  266. package/dist/server/env.js +95 -0
  267. package/dist/server/startup.d.ts +22 -0
  268. package/dist/server/startup.d.ts.map +1 -0
  269. package/dist/server/startup.js +48 -0
  270. package/dist/server/static.d.ts +39 -0
  271. package/dist/server/static.d.ts.map +1 -0
  272. package/dist/server/static.js +38 -0
  273. package/dist/server/validate_nginx.d.ts +34 -0
  274. package/dist/server/validate_nginx.d.ts.map +1 -0
  275. package/dist/server/validate_nginx.js +118 -0
  276. package/dist/testing/CLAUDE.md +3 -0
  277. package/dist/testing/admin_integration.d.ts +45 -0
  278. package/dist/testing/admin_integration.d.ts.map +1 -0
  279. package/dist/testing/admin_integration.js +840 -0
  280. package/dist/testing/adversarial_404.d.ts +15 -0
  281. package/dist/testing/adversarial_404.d.ts.map +1 -0
  282. package/dist/testing/adversarial_404.js +118 -0
  283. package/dist/testing/adversarial_headers.d.ts +36 -0
  284. package/dist/testing/adversarial_headers.d.ts.map +1 -0
  285. package/dist/testing/adversarial_headers.js +128 -0
  286. package/dist/testing/adversarial_input.d.ts +56 -0
  287. package/dist/testing/adversarial_input.d.ts.map +1 -0
  288. package/dist/testing/adversarial_input.js +494 -0
  289. package/dist/testing/app_server.d.ts +169 -0
  290. package/dist/testing/app_server.d.ts.map +1 -0
  291. package/dist/testing/app_server.js +240 -0
  292. package/dist/testing/assert_dev_env.d.ts +10 -0
  293. package/dist/testing/assert_dev_env.d.ts.map +1 -0
  294. package/dist/testing/assert_dev_env.js +13 -0
  295. package/dist/testing/assertions.d.ts +61 -0
  296. package/dist/testing/assertions.d.ts.map +1 -0
  297. package/dist/testing/assertions.js +96 -0
  298. package/dist/testing/attack_surface.d.ts +63 -0
  299. package/dist/testing/attack_surface.d.ts.map +1 -0
  300. package/dist/testing/attack_surface.js +224 -0
  301. package/dist/testing/audit_completeness.d.ts +29 -0
  302. package/dist/testing/audit_completeness.d.ts.map +1 -0
  303. package/dist/testing/audit_completeness.js +410 -0
  304. package/dist/testing/auth_apps.d.ts +55 -0
  305. package/dist/testing/auth_apps.d.ts.map +1 -0
  306. package/dist/testing/auth_apps.js +122 -0
  307. package/dist/testing/data_exposure.d.ts +62 -0
  308. package/dist/testing/data_exposure.d.ts.map +1 -0
  309. package/dist/testing/data_exposure.js +297 -0
  310. package/dist/testing/db.d.ts +111 -0
  311. package/dist/testing/db.d.ts.map +1 -0
  312. package/dist/testing/db.js +258 -0
  313. package/dist/testing/entities.d.ts +21 -0
  314. package/dist/testing/entities.d.ts.map +1 -0
  315. package/dist/testing/entities.js +42 -0
  316. package/dist/testing/error_coverage.d.ts +78 -0
  317. package/dist/testing/error_coverage.d.ts.map +1 -0
  318. package/dist/testing/error_coverage.js +135 -0
  319. package/dist/testing/integration.d.ts +37 -0
  320. package/dist/testing/integration.d.ts.map +1 -0
  321. package/dist/testing/integration.js +1139 -0
  322. package/dist/testing/integration_helpers.d.ts +107 -0
  323. package/dist/testing/integration_helpers.d.ts.map +1 -0
  324. package/dist/testing/integration_helpers.js +246 -0
  325. package/dist/testing/middleware.d.ts +125 -0
  326. package/dist/testing/middleware.d.ts.map +1 -0
  327. package/dist/testing/middleware.js +210 -0
  328. package/dist/testing/rate_limiting.d.ts +43 -0
  329. package/dist/testing/rate_limiting.d.ts.map +1 -0
  330. package/dist/testing/rate_limiting.js +216 -0
  331. package/dist/testing/round_trip.d.ts +37 -0
  332. package/dist/testing/round_trip.d.ts.map +1 -0
  333. package/dist/testing/round_trip.js +128 -0
  334. package/dist/testing/schema_generators.d.ts +33 -0
  335. package/dist/testing/schema_generators.d.ts.map +1 -0
  336. package/dist/testing/schema_generators.js +137 -0
  337. package/dist/testing/standard.d.ts +49 -0
  338. package/dist/testing/standard.d.ts.map +1 -0
  339. package/dist/testing/standard.js +16 -0
  340. package/dist/testing/stubs.d.ts +96 -0
  341. package/dist/testing/stubs.d.ts.map +1 -0
  342. package/dist/testing/stubs.js +192 -0
  343. package/dist/testing/surface_invariants.d.ts +189 -0
  344. package/dist/testing/surface_invariants.d.ts.map +1 -0
  345. package/dist/testing/surface_invariants.js +450 -0
  346. package/dist/ui/AccountSessions.svelte +75 -0
  347. package/dist/ui/AccountSessions.svelte.d.ts +19 -0
  348. package/dist/ui/AccountSessions.svelte.d.ts.map +1 -0
  349. package/dist/ui/AdminAccounts.svelte +107 -0
  350. package/dist/ui/AdminAccounts.svelte.d.ts +19 -0
  351. package/dist/ui/AdminAccounts.svelte.d.ts.map +1 -0
  352. package/dist/ui/AdminAuditLog.svelte +144 -0
  353. package/dist/ui/AdminAuditLog.svelte.d.ts +4 -0
  354. package/dist/ui/AdminAuditLog.svelte.d.ts.map +1 -0
  355. package/dist/ui/AdminInvites.svelte +142 -0
  356. package/dist/ui/AdminInvites.svelte.d.ts +4 -0
  357. package/dist/ui/AdminInvites.svelte.d.ts.map +1 -0
  358. package/dist/ui/AdminOverview.svelte +337 -0
  359. package/dist/ui/AdminOverview.svelte.d.ts +4 -0
  360. package/dist/ui/AdminOverview.svelte.d.ts.map +1 -0
  361. package/dist/ui/AdminPermitHistory.svelte +61 -0
  362. package/dist/ui/AdminPermitHistory.svelte.d.ts +19 -0
  363. package/dist/ui/AdminPermitHistory.svelte.d.ts.map +1 -0
  364. package/dist/ui/AdminSessions.svelte +85 -0
  365. package/dist/ui/AdminSessions.svelte.d.ts +19 -0
  366. package/dist/ui/AdminSessions.svelte.d.ts.map +1 -0
  367. package/dist/ui/AdminSettings.svelte +32 -0
  368. package/dist/ui/AdminSettings.svelte.d.ts +19 -0
  369. package/dist/ui/AdminSettings.svelte.d.ts.map +1 -0
  370. package/dist/ui/AdminSurface.svelte +42 -0
  371. package/dist/ui/AdminSurface.svelte.d.ts +4 -0
  372. package/dist/ui/AdminSurface.svelte.d.ts.map +1 -0
  373. package/dist/ui/AppShell.svelte +93 -0
  374. package/dist/ui/AppShell.svelte.d.ts +20 -0
  375. package/dist/ui/AppShell.svelte.d.ts.map +1 -0
  376. package/dist/ui/BootstrapForm.svelte +105 -0
  377. package/dist/ui/BootstrapForm.svelte.d.ts +4 -0
  378. package/dist/ui/BootstrapForm.svelte.d.ts.map +1 -0
  379. package/dist/ui/ColumnLayout.svelte +46 -0
  380. package/dist/ui/ColumnLayout.svelte.d.ts +11 -0
  381. package/dist/ui/ColumnLayout.svelte.d.ts.map +1 -0
  382. package/dist/ui/ConfirmButton.svelte +125 -0
  383. package/dist/ui/ConfirmButton.svelte.d.ts +54 -0
  384. package/dist/ui/ConfirmButton.svelte.d.ts.map +1 -0
  385. package/dist/ui/Datatable.svelte +185 -0
  386. package/dist/ui/Datatable.svelte.d.ts +35 -0
  387. package/dist/ui/Datatable.svelte.d.ts.map +1 -0
  388. package/dist/ui/LoginForm.svelte +82 -0
  389. package/dist/ui/LoginForm.svelte.d.ts +8 -0
  390. package/dist/ui/LoginForm.svelte.d.ts.map +1 -0
  391. package/dist/ui/LogoutButton.svelte +36 -0
  392. package/dist/ui/LogoutButton.svelte.d.ts +10 -0
  393. package/dist/ui/LogoutButton.svelte.d.ts.map +1 -0
  394. package/dist/ui/MenuLink.svelte +35 -0
  395. package/dist/ui/MenuLink.svelte.d.ts +12 -0
  396. package/dist/ui/MenuLink.svelte.d.ts.map +1 -0
  397. package/dist/ui/OpenSignupToggle.svelte +36 -0
  398. package/dist/ui/OpenSignupToggle.svelte.d.ts +19 -0
  399. package/dist/ui/OpenSignupToggle.svelte.d.ts.map +1 -0
  400. package/dist/ui/PopoverButton.svelte +136 -0
  401. package/dist/ui/PopoverButton.svelte.d.ts +63 -0
  402. package/dist/ui/PopoverButton.svelte.d.ts.map +1 -0
  403. package/dist/ui/SignupForm.svelte +117 -0
  404. package/dist/ui/SignupForm.svelte.d.ts +7 -0
  405. package/dist/ui/SignupForm.svelte.d.ts.map +1 -0
  406. package/dist/ui/SurfaceExplorer.svelte +287 -0
  407. package/dist/ui/SurfaceExplorer.svelte.d.ts +8 -0
  408. package/dist/ui/SurfaceExplorer.svelte.d.ts.map +1 -0
  409. package/dist/ui/account_sessions_state.svelte.d.ts +15 -0
  410. package/dist/ui/account_sessions_state.svelte.d.ts.map +1 -0
  411. package/dist/ui/account_sessions_state.svelte.js +45 -0
  412. package/dist/ui/admin_accounts_state.svelte.d.ts +19 -0
  413. package/dist/ui/admin_accounts_state.svelte.d.ts.map +1 -0
  414. package/dist/ui/admin_accounts_state.svelte.js +65 -0
  415. package/dist/ui/admin_invites_state.svelte.d.ts +19 -0
  416. package/dist/ui/admin_invites_state.svelte.d.ts.map +1 -0
  417. package/dist/ui/admin_invites_state.svelte.js +71 -0
  418. package/dist/ui/admin_sessions_state.svelte.d.ts +18 -0
  419. package/dist/ui/admin_sessions_state.svelte.d.ts.map +1 -0
  420. package/dist/ui/admin_sessions_state.svelte.js +62 -0
  421. package/dist/ui/app_settings_state.svelte.d.ts +14 -0
  422. package/dist/ui/app_settings_state.svelte.d.ts.map +1 -0
  423. package/dist/ui/app_settings_state.svelte.js +44 -0
  424. package/dist/ui/audit_log_state.svelte.d.ts +40 -0
  425. package/dist/ui/audit_log_state.svelte.d.ts.map +1 -0
  426. package/dist/ui/audit_log_state.svelte.js +153 -0
  427. package/dist/ui/auth_state.svelte.d.ts +85 -0
  428. package/dist/ui/auth_state.svelte.d.ts.map +1 -0
  429. package/dist/ui/auth_state.svelte.js +238 -0
  430. package/dist/ui/datatable.d.ts +25 -0
  431. package/dist/ui/datatable.d.ts.map +1 -0
  432. package/dist/ui/datatable.js +9 -0
  433. package/dist/ui/enter_advance.d.ts +13 -0
  434. package/dist/ui/enter_advance.d.ts.map +1 -0
  435. package/dist/ui/enter_advance.js +30 -0
  436. package/dist/ui/loadable.svelte.d.ts +55 -0
  437. package/dist/ui/loadable.svelte.d.ts.map +1 -0
  438. package/dist/ui/loadable.svelte.js +75 -0
  439. package/dist/ui/popover.svelte.d.ts +137 -0
  440. package/dist/ui/popover.svelte.d.ts.map +1 -0
  441. package/dist/ui/popover.svelte.js +288 -0
  442. package/dist/ui/position_helpers.d.ts +27 -0
  443. package/dist/ui/position_helpers.d.ts.map +1 -0
  444. package/dist/ui/position_helpers.js +81 -0
  445. package/dist/ui/sidebar_state.svelte.d.ts +30 -0
  446. package/dist/ui/sidebar_state.svelte.d.ts.map +1 -0
  447. package/dist/ui/sidebar_state.svelte.js +39 -0
  448. package/dist/ui/table_state.svelte.d.ts +63 -0
  449. package/dist/ui/table_state.svelte.d.ts.map +1 -0
  450. package/dist/ui/table_state.svelte.js +117 -0
  451. package/dist/ui/ui_fetch.d.ts +29 -0
  452. package/dist/ui/ui_fetch.d.ts.map +1 -0
  453. package/dist/ui/ui_fetch.js +37 -0
  454. package/dist/ui/ui_format.d.ts +63 -0
  455. package/dist/ui/ui_format.d.ts.map +1 -0
  456. package/dist/ui/ui_format.js +196 -0
  457. package/package.json +121 -0
@@ -0,0 +1,186 @@
1
+ /**
2
+ * Auth session database queries.
3
+ *
4
+ * Server-side sessions keyed by blake3 hash of the session token.
5
+ * The cookie contains the raw token; the database stores only the hash.
6
+ *
7
+ * @module
8
+ */
9
+ import { hash_blake3 } from '@fuzdev/fuz_util/hash_blake3.js';
10
+ import { generate_random_base64url } from '../crypto.js';
11
+ /** Session lifetime in milliseconds (30 days). */
12
+ export const AUTH_SESSION_LIFETIME_MS = 30 * 24 * 60 * 60 * 1000;
13
+ /** Extend session when it has less than this remaining (1 day in ms). */
14
+ export const AUTH_SESSION_EXTEND_THRESHOLD_MS = 24 * 60 * 60 * 1000;
15
+ /**
16
+ * Hash a session token to its storage key using blake3.
17
+ *
18
+ * @param token - the raw session token
19
+ * @returns hex-encoded blake3 hash
20
+ */
21
+ export const hash_session_token = (token) => {
22
+ return hash_blake3(token);
23
+ };
24
+ /**
25
+ * Generate a cryptographically random session token.
26
+ *
27
+ * @returns a 32-byte base64url-encoded token
28
+ */
29
+ export const generate_session_token = () => {
30
+ return generate_random_base64url();
31
+ };
32
+ /**
33
+ * Create a new auth session.
34
+ *
35
+ * @param deps - query dependencies
36
+ * @param token_hash - blake3 hash of the session token (use `hash_session_token`)
37
+ * @param account_id - the account this session belongs to
38
+ * @param expires_at - when the session expires
39
+ */
40
+ export const query_create_session = async (deps, token_hash, account_id, expires_at) => {
41
+ await deps.db.query(`INSERT INTO auth_session (id, account_id, expires_at) VALUES ($1, $2, $3)`, [
42
+ token_hash,
43
+ account_id,
44
+ expires_at.toISOString(),
45
+ ]);
46
+ };
47
+ /**
48
+ * Get a session if it exists, is not expired, and has not been revoked.
49
+ *
50
+ * @param deps - query dependencies
51
+ * @param token_hash - blake3 hash of the session token
52
+ */
53
+ export const query_session_get_valid = async (deps, token_hash) => {
54
+ return deps.db.query_one(`SELECT * FROM auth_session WHERE id = $1 AND expires_at > NOW()`, [token_hash]);
55
+ };
56
+ /**
57
+ * Update `last_seen_at` and optionally extend expiry for a session.
58
+ *
59
+ * Extends if less than `AUTH_SESSION_EXTEND_THRESHOLD_MS` remaining.
60
+ *
61
+ * @param deps - query dependencies
62
+ * @param token_hash - blake3 hash of the session token
63
+ */
64
+ export const query_session_touch = async (deps, token_hash) => {
65
+ const new_expires = new Date(Date.now() + AUTH_SESSION_LIFETIME_MS);
66
+ await deps.db.query(`UPDATE auth_session
67
+ SET last_seen_at = NOW(),
68
+ expires_at = CASE
69
+ WHEN expires_at - NOW() < INTERVAL '1 day' THEN $2::timestamptz
70
+ ELSE expires_at
71
+ END
72
+ WHERE id = $1`, [token_hash, new_expires.toISOString()]);
73
+ };
74
+ /**
75
+ * Revoke (delete) a session by its token hash.
76
+ *
77
+ * No account_id constraint — caller must ensure the hash comes from a
78
+ * trusted source (e.g. the authenticated session cookie). For user-facing
79
+ * revocation of a specific session by ID, prefer `query_session_revoke_for_account`
80
+ * which includes an IDOR guard.
81
+ */
82
+ export const query_session_revoke_by_hash = async (deps, token_hash) => {
83
+ await deps.db.query(`DELETE FROM auth_session WHERE id = $1`, [token_hash]);
84
+ };
85
+ /**
86
+ * Revoke a session only if it belongs to the specified account.
87
+ *
88
+ * Prevents cross-account session revocation.
89
+ *
90
+ * @param deps - query dependencies
91
+ * @param token_hash - blake3 hash of the session token
92
+ * @param account_id - the account that must own the session
93
+ * @returns `true` if a session was revoked, `false` if not found or wrong account
94
+ */
95
+ export const query_session_revoke_for_account = async (deps, token_hash, account_id) => {
96
+ const rows = await deps.db.query(`DELETE FROM auth_session WHERE id = $1 AND account_id = $2 RETURNING id`, [token_hash, account_id]);
97
+ return rows.length > 0;
98
+ };
99
+ /**
100
+ * Revoke all sessions for an account.
101
+ *
102
+ * @returns the number of sessions revoked
103
+ */
104
+ export const query_session_revoke_all_for_account = async (deps, account_id) => {
105
+ const rows = await deps.db.query(`DELETE FROM auth_session WHERE account_id = $1 RETURNING id`, [account_id]);
106
+ return rows.length;
107
+ };
108
+ /**
109
+ * List sessions for an account, newest first.
110
+ */
111
+ export const query_session_list_for_account = async (deps, account_id, limit = 50) => {
112
+ return deps.db.query(`SELECT * FROM auth_session WHERE account_id = $1 ORDER BY created_at DESC LIMIT $2`, [account_id, limit]);
113
+ };
114
+ /**
115
+ * Enforce a per-account session limit by evicting the oldest sessions.
116
+ *
117
+ * Keeps the newest `max_sessions` sessions and deletes the rest.
118
+ *
119
+ * Race safety: this function must run inside a transaction alongside the
120
+ * INSERT that created the new session. All callers satisfy this requirement:
121
+ * - `POST /login` and `POST /tokens/create` use the default `transaction: true`
122
+ * (framework-managed transaction wrapping in `apply_route_specs`)
123
+ * - `POST /bootstrap` and `POST /signup` manage their own transactions
124
+ * and pass the transaction-scoped `deps` to `create_session_and_set_cookie`
125
+ *
126
+ * The transaction ensures the INSERT + enforce_limit pair is atomic —
127
+ * concurrent session creation cannot interleave between the two statements.
128
+ *
129
+ * @param deps - query dependencies (must be transaction-scoped)
130
+ * @param account_id - the account to enforce the limit for
131
+ * @param max_sessions - maximum number of sessions to keep
132
+ * @returns the number of sessions evicted
133
+ */
134
+ export const query_session_enforce_limit = async (deps, account_id, max_sessions) => {
135
+ const rows = await deps.db.query(`DELETE FROM auth_session
136
+ WHERE id IN (
137
+ SELECT id FROM auth_session
138
+ WHERE account_id = $1
139
+ ORDER BY created_at DESC
140
+ OFFSET $2
141
+ ) RETURNING id`, [account_id, max_sessions]);
142
+ return rows.length;
143
+ };
144
+ /**
145
+ * List all active sessions across all accounts with usernames.
146
+ *
147
+ * @param deps - query dependencies
148
+ * @param limit - maximum entries to return
149
+ * @returns active sessions joined with account usernames, newest activity first
150
+ */
151
+ export const query_session_list_all_active = async (deps, limit = 200) => {
152
+ return deps.db.query(`SELECT s.id, s.account_id, s.created_at, s.expires_at, s.last_seen_at, a.username
153
+ FROM auth_session s
154
+ JOIN account a ON a.id = s.account_id
155
+ WHERE s.expires_at > NOW()
156
+ ORDER BY s.last_seen_at DESC LIMIT $1`, [limit]);
157
+ };
158
+ /**
159
+ * Delete expired sessions.
160
+ *
161
+ * @returns the number of sessions cleaned up
162
+ */
163
+ export const query_session_cleanup_expired = async (deps) => {
164
+ const rows = await deps.db.query(`DELETE FROM auth_session WHERE expires_at <= NOW() RETURNING id`);
165
+ return rows.length;
166
+ };
167
+ /**
168
+ * Touch a session without blocking the caller.
169
+ *
170
+ * Errors are logged to console — session touching never breaks request flows.
171
+ * Pass `pending_effects` (from `c.var.pending_effects`) to register
172
+ * the promise for test flushing.
173
+ *
174
+ * @param deps - query dependencies
175
+ * @param token_hash - blake3 hash of the session token
176
+ * @param pending_effects - optional array to register the effect for later awaiting
177
+ * @param log - the logger instance
178
+ * @returns the settled promise (callers may ignore it — fire-and-forget semantics preserved)
179
+ */
180
+ export const session_touch_fire_and_forget = (deps, token_hash, pending_effects, log) => {
181
+ const p = query_session_touch(deps, token_hash).catch((err) => {
182
+ log.error('Session touch failed:', err);
183
+ });
184
+ pending_effects?.push(p);
185
+ return p;
186
+ };
@@ -0,0 +1,32 @@
1
+ /**
2
+ * Signup route spec for account creation.
3
+ *
4
+ * Public endpoint that creates an account. When `open_signup` is disabled
5
+ * (default), a matching unclaimed invite is required. When enabled, anyone
6
+ * can sign up without an invite. Follows the `bootstrap_routes.ts` pattern.
7
+ *
8
+ * @module
9
+ */
10
+ import { type RouteSpec } from '../http/route_spec.js';
11
+ import { type RateLimiter } from '../rate_limiter.js';
12
+ import type { RouteFactoryDeps } from './deps.js';
13
+ import type { AppSettings } from './app_settings_schema.js';
14
+ import type { AuthSessionRouteOptions } from './account_routes.js';
15
+ /**
16
+ * Per-factory configuration for signup route specs.
17
+ */
18
+ export interface SignupRouteOptions extends AuthSessionRouteOptions {
19
+ /** Rate limiter for signup attempts, keyed by submitted username. Pass `null` to disable. */
20
+ signup_account_rate_limiter: RateLimiter | null;
21
+ /** Mutable ref to app settings — when `open_signup` is true, invite check is skipped. */
22
+ app_settings: AppSettings;
23
+ }
24
+ /**
25
+ * Create signup route specs for account creation.
26
+ *
27
+ * @param deps - stateless capabilities
28
+ * @param options - per-factory configuration
29
+ * @returns route specs (not yet applied to Hono)
30
+ */
31
+ export declare const create_signup_route_specs: (deps: RouteFactoryDeps, options: SignupRouteOptions) => Array<RouteSpec>;
32
+ //# sourceMappingURL=signup_routes.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"signup_routes.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/auth/signup_routes.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAUH,OAAO,EAAkB,KAAK,SAAS,EAAC,MAAM,uBAAuB,CAAC;AAEtE,OAAO,EAA+B,KAAK,WAAW,EAAC,MAAM,oBAAoB,CAAC;AAClF,OAAO,KAAK,EAAC,gBAAgB,EAAC,MAAM,WAAW,CAAC;AAGhD,OAAO,KAAK,EAAC,WAAW,EAAC,MAAM,0BAA0B,CAAC;AAE1D,OAAO,KAAK,EAAC,uBAAuB,EAAC,MAAM,qBAAqB,CAAC;AAEjE;;GAEG;AACH,MAAM,WAAW,kBAAmB,SAAQ,uBAAuB;IAClE,6FAA6F;IAC7F,2BAA2B,EAAE,WAAW,GAAG,IAAI,CAAC;IAChD,yFAAyF;IACzF,YAAY,EAAE,WAAW,CAAC;CAC1B;AAED;;;;;;GAMG;AACH,eAAO,MAAM,yBAAyB,GACrC,MAAM,gBAAgB,EACtB,SAAS,kBAAkB,KACzB,KAAK,CAAC,SAAS,CAqIjB,CAAC"}
@@ -0,0 +1,150 @@
1
+ /**
2
+ * Signup route spec for account creation.
3
+ *
4
+ * Public endpoint that creates an account. When `open_signup` is disabled
5
+ * (default), a matching unclaimed invite is required. When enabled, anyone
6
+ * can sign up without an invite. Follows the `bootstrap_routes.ts` pattern.
7
+ *
8
+ * @module
9
+ */
10
+ import { z } from 'zod';
11
+ import { create_session_and_set_cookie } from './session_lifecycle.js';
12
+ import { query_create_account_with_actor } from './account_queries.js';
13
+ import { query_invite_find_unclaimed_match, query_invite_claim } from './invite_queries.js';
14
+ import { Username, Email } from './account_schema.js';
15
+ import { Password } from './password.js';
16
+ import { get_route_input } from '../http/route_spec.js';
17
+ import { get_client_ip } from '../http/proxy.js';
18
+ import { rate_limit_exceeded_response } from '../rate_limiter.js';
19
+ import { ERROR_NO_MATCHING_INVITE, ERROR_SIGNUP_CONFLICT } from '../http/error_schemas.js';
20
+ import { audit_log_fire_and_forget } from './audit_log_queries.js';
21
+ import { is_pg_unique_violation } from '../db/pg_error.js';
22
+ /**
23
+ * Create signup route specs for account creation.
24
+ *
25
+ * @param deps - stateless capabilities
26
+ * @param options - per-factory configuration
27
+ * @returns route specs (not yet applied to Hono)
28
+ */
29
+ export const create_signup_route_specs = (deps, options) => {
30
+ const { keyring, password, on_audit_event } = deps;
31
+ const { session_options, ip_rate_limiter, signup_account_rate_limiter, app_settings } = options;
32
+ return [
33
+ {
34
+ method: 'POST',
35
+ path: '/signup',
36
+ auth: { type: 'none' },
37
+ description: 'Create account (invite-gated or open signup)',
38
+ transaction: false, // manages its own transaction for TOCTOU safety
39
+ input: z.strictObject({
40
+ username: Username,
41
+ password: Password,
42
+ email: Email.optional(),
43
+ }),
44
+ output: z.strictObject({ ok: z.literal(true) }),
45
+ rate_limit: signup_account_rate_limiter ? 'both' : 'ip',
46
+ errors: {
47
+ 403: z.looseObject({ error: z.literal(ERROR_NO_MATCHING_INVITE) }),
48
+ 409: z.looseObject({ error: z.literal(ERROR_SIGNUP_CONFLICT) }),
49
+ },
50
+ handler: async (c, route) => {
51
+ // Per-IP rate limit check (before any work)
52
+ const ip = ip_rate_limiter ? get_client_ip(c) : null;
53
+ if (ip_rate_limiter && ip) {
54
+ const check = ip_rate_limiter.check(ip);
55
+ if (!check.allowed) {
56
+ return rate_limit_exceeded_response(c, check.retry_after);
57
+ }
58
+ }
59
+ const { username, password: pw, email, } = get_route_input(c);
60
+ // Per-account rate limit check (after input parsing, before DB work)
61
+ const account_key = username.toLowerCase();
62
+ if (signup_account_rate_limiter) {
63
+ const check = signup_account_rate_limiter.check(account_key);
64
+ if (!check.allowed) {
65
+ return rate_limit_exceeded_response(c, check.retry_after);
66
+ }
67
+ }
68
+ // Check for matching invite (unless open signup is enabled)
69
+ let invite;
70
+ if (!app_settings.open_signup) {
71
+ invite = await query_invite_find_unclaimed_match({ db: route.background_db }, email ?? null, username);
72
+ if (!invite) {
73
+ if (ip_rate_limiter && ip)
74
+ ip_rate_limiter.record(ip);
75
+ if (signup_account_rate_limiter)
76
+ signup_account_rate_limiter.record(account_key);
77
+ return c.json({ error: ERROR_NO_MATCHING_INVITE }, 403);
78
+ }
79
+ }
80
+ // Create account, optionally claim invite, and create session atomically.
81
+ // Username/email uniqueness enforced by DB unique constraints.
82
+ const password_hash = await password.hash_password(pw);
83
+ let result;
84
+ try {
85
+ result = await route.background_db.transaction(async (tx) => {
86
+ const tx_deps = { db: tx };
87
+ const { account } = await query_create_account_with_actor(tx_deps, {
88
+ username,
89
+ password_hash,
90
+ email,
91
+ });
92
+ if (invite) {
93
+ const claimed = await query_invite_claim(tx_deps, invite.id, account.id);
94
+ if (!claimed) {
95
+ // Race: invite was claimed between the find and this claim
96
+ throw new SignupConflictError(ERROR_NO_MATCHING_INVITE);
97
+ }
98
+ }
99
+ await create_session_and_set_cookie({
100
+ keyring,
101
+ deps: tx_deps,
102
+ c,
103
+ account_id: account.id,
104
+ session_options,
105
+ });
106
+ return account;
107
+ });
108
+ }
109
+ catch (e) {
110
+ if (e instanceof SignupConflictError) {
111
+ if (ip_rate_limiter && ip)
112
+ ip_rate_limiter.record(ip);
113
+ if (signup_account_rate_limiter)
114
+ signup_account_rate_limiter.record(account_key);
115
+ return c.json({ error: e.error }, 403);
116
+ }
117
+ // Unique constraint violation: username or email already exists.
118
+ if (is_pg_unique_violation(e)) {
119
+ if (ip_rate_limiter && ip)
120
+ ip_rate_limiter.record(ip);
121
+ if (signup_account_rate_limiter)
122
+ signup_account_rate_limiter.record(account_key);
123
+ return c.json({ error: ERROR_SIGNUP_CONFLICT }, 409);
124
+ }
125
+ throw e;
126
+ }
127
+ // Reset rate limiters on success
128
+ if (ip_rate_limiter && ip)
129
+ ip_rate_limiter.reset(ip);
130
+ if (signup_account_rate_limiter)
131
+ signup_account_rate_limiter.reset(account_key);
132
+ void audit_log_fire_and_forget(route, {
133
+ event_type: 'signup',
134
+ account_id: result.id,
135
+ ip: get_client_ip(c),
136
+ metadata: invite ? { invite_id: invite.id, username } : { open_signup: true, username },
137
+ }, deps.log, on_audit_event);
138
+ return c.json({ ok: true });
139
+ },
140
+ },
141
+ ];
142
+ };
143
+ /** Thrown inside the signup transaction to signal a conflict that should roll back. */
144
+ class SignupConflictError extends Error {
145
+ error;
146
+ constructor(error) {
147
+ super(error);
148
+ this.error = error;
149
+ }
150
+ }
@@ -0,0 +1,48 @@
1
+ /**
2
+ * Shared CLI argument parsing utilities.
3
+ *
4
+ * Provides `parse_command_args` for schema-validated command parsing and
5
+ * `create_extract_global_flags` as a factory for project-specific global flag extraction.
6
+ * Both are used identically across tx, zzz, and mageguild.
7
+ *
8
+ * @module
9
+ */
10
+ import { type ParsedArgs } from '@fuzdev/fuz_util/args.js';
11
+ import { z } from 'zod';
12
+ /**
13
+ * Discriminated union result for CLI argument parsing.
14
+ */
15
+ export type ParseResult<T> = {
16
+ success: true;
17
+ data: T;
18
+ } | {
19
+ success: false;
20
+ error: string;
21
+ };
22
+ /**
23
+ * Parse command-specific args against a Zod schema.
24
+ *
25
+ * Validates `remaining` args (after global flag extraction) with alias expansion
26
+ * and returns a typed result or a prettified error string.
27
+ *
28
+ * @param remaining - remaining args after global flag extraction
29
+ * @param schema - Zod schema for the command
30
+ * @returns parse result with typed data or error message
31
+ */
32
+ export declare const parse_command_args: <T extends Record<string, unknown>>(remaining: ParsedArgs, schema: z.ZodType<T>) => ParseResult<T>;
33
+ /**
34
+ * Create a project-specific global flag extractor.
35
+ *
36
+ * Returns a function that separates global flags from command-specific args.
37
+ * The schema defines which flags are global (with aliases via `.meta({aliases})`),
38
+ * and the fallback provides defaults when parsing fails.
39
+ *
40
+ * @param schema - Zod schema for global flags
41
+ * @param fallback - default values when parsing fails
42
+ * @returns extractor function `(unparsed) => {flags, remaining}`
43
+ */
44
+ export declare const create_extract_global_flags: <T extends Record<string, unknown>>(schema: z.ZodType<T>, fallback: T) => ((unparsed: ParsedArgs) => {
45
+ flags: T;
46
+ remaining: ParsedArgs;
47
+ });
48
+ //# sourceMappingURL=args.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"args.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/cli/args.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAwB,KAAK,UAAU,EAAgB,MAAM,0BAA0B,CAAC;AAC/F,OAAO,EAAC,CAAC,EAAC,MAAM,KAAK,CAAC;AAGtB;;GAEG;AACH,MAAM,MAAM,WAAW,CAAC,CAAC,IAAI;IAAC,OAAO,EAAE,IAAI,CAAC;IAAC,IAAI,EAAE,CAAC,CAAA;CAAC,GAAG;IAAC,OAAO,EAAE,KAAK,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAC,CAAC;AAExF;;;;;;;;;GASG;AACH,eAAO,MAAM,kBAAkB,GAAI,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EACnE,WAAW,UAAU,EACrB,QAAQ,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,KAClB,WAAW,CAAC,CAAC,CAMf,CAAC;AAEF;;;;;;;;;;GAUG;AACH,eAAO,MAAM,2BAA2B,GAAI,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC5E,QAAQ,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,EACpB,UAAU,CAAC,KACT,CAAC,CAAC,QAAQ,EAAE,UAAU,KAAK;IAAC,KAAK,EAAE,CAAC,CAAC;IAAC,SAAS,EAAE,UAAU,CAAA;CAAC,CAuC9D,CAAC"}
@@ -0,0 +1,76 @@
1
+ /**
2
+ * Shared CLI argument parsing utilities.
3
+ *
4
+ * Provides `parse_command_args` for schema-validated command parsing and
5
+ * `create_extract_global_flags` as a factory for project-specific global flag extraction.
6
+ * Both are used identically across tx, zzz, and mageguild.
7
+ *
8
+ * @module
9
+ */
10
+ import { args_parse } from '@fuzdev/fuz_util/args.js';
11
+ import { z } from 'zod';
12
+ import { zod_to_schema_properties, zod_to_schema_names_with_aliases } from '@fuzdev/fuz_util/zod.js';
13
+ /**
14
+ * Parse command-specific args against a Zod schema.
15
+ *
16
+ * Validates `remaining` args (after global flag extraction) with alias expansion
17
+ * and returns a typed result or a prettified error string.
18
+ *
19
+ * @param remaining - remaining args after global flag extraction
20
+ * @param schema - Zod schema for the command
21
+ * @returns parse result with typed data or error message
22
+ */
23
+ export const parse_command_args = (remaining, schema) => {
24
+ const parsed = args_parse(remaining, schema);
25
+ if (!parsed.success) {
26
+ return { success: false, error: z.prettifyError(parsed.error) };
27
+ }
28
+ return { success: true, data: parsed.data };
29
+ };
30
+ /**
31
+ * Create a project-specific global flag extractor.
32
+ *
33
+ * Returns a function that separates global flags from command-specific args.
34
+ * The schema defines which flags are global (with aliases via `.meta({aliases})`),
35
+ * and the fallback provides defaults when parsing fails.
36
+ *
37
+ * @param schema - Zod schema for global flags
38
+ * @param fallback - default values when parsing fails
39
+ * @returns extractor function `(unparsed) => {flags, remaining}`
40
+ */
41
+ export const create_extract_global_flags = (schema, fallback) => {
42
+ return (unparsed) => {
43
+ // get all global flag names and aliases from schema
44
+ const global_names = zod_to_schema_names_with_aliases(schema);
45
+ const global_props = zod_to_schema_properties(schema);
46
+ // extract global flag values, handling aliases
47
+ const flags_input = {};
48
+ for (const prop of global_props) {
49
+ // check canonical name first, then aliases
50
+ if (prop.name in unparsed) {
51
+ flags_input[prop.name] = unparsed[prop.name];
52
+ }
53
+ else {
54
+ for (const alias of prop.aliases) {
55
+ if (alias in unparsed) {
56
+ flags_input[prop.name] = unparsed[alias];
57
+ break;
58
+ }
59
+ }
60
+ }
61
+ }
62
+ // parse global flags
63
+ const global_parsed = args_parse(flags_input, schema);
64
+ const flags = global_parsed.success ? global_parsed.data : fallback;
65
+ // build remaining args without global flags
66
+ const remaining = { _: [...unparsed._] };
67
+ for (const [key, value] of Object.entries(unparsed)) {
68
+ if (key === '_')
69
+ continue;
70
+ if (global_names.has(key))
71
+ continue;
72
+ remaining[key] = value;
73
+ }
74
+ return { flags, remaining };
75
+ };
76
+ };
@@ -0,0 +1,48 @@
1
+ /**
2
+ * Generic CLI configuration loader.
3
+ *
4
+ * Manages CLI-specific configuration stored at `~/.{name}/config.json`.
5
+ * Consumers keep their project-specific Zod schemas locally and use
6
+ * these generic load/save functions.
7
+ *
8
+ * @module
9
+ */
10
+ import type { z } from 'zod';
11
+ import type { EnvDeps, FsReadDeps, FsWriteDeps, LogDeps } from '../runtime/deps.js';
12
+ /**
13
+ * Get the CLI config directory path (`~/.{name}`).
14
+ *
15
+ * @param runtime - runtime with `env_get` capability
16
+ * @param name - application name (e.g., `"tx"`, `"zzz"`)
17
+ * @returns path to config directory, or null if `$HOME` is not set
18
+ */
19
+ export declare const get_app_dir: (runtime: Pick<EnvDeps, "env_get">, name: string) => string | null;
20
+ /**
21
+ * Get the CLI config file path (`~/.{name}/config.json`).
22
+ *
23
+ * @param runtime - runtime with `env_get` capability
24
+ * @param name - application name
25
+ * @returns path to `config.json`, or null if `$HOME` is not set
26
+ */
27
+ export declare const get_config_path: (runtime: Pick<EnvDeps, "env_get">, name: string) => string | null;
28
+ /**
29
+ * Load CLI configuration from a JSON file with Zod schema validation.
30
+ *
31
+ * @param runtime - runtime with file read capability
32
+ * @param path - path to the config JSON file
33
+ * @param schema - Zod schema to validate against
34
+ * @returns parsed config, or null if file doesn't exist or is invalid
35
+ */
36
+ export declare const load_config: <T>(runtime: FsReadDeps & LogDeps, path: string, schema: z.ZodType<T>) => Promise<T | null>;
37
+ /**
38
+ * Save CLI configuration to a JSON file.
39
+ *
40
+ * Creates parent directories if they don't exist.
41
+ *
42
+ * @param runtime - runtime with file write capability
43
+ * @param path - path to the config JSON file
44
+ * @param dir - directory containing the config file (created if missing)
45
+ * @param config - configuration to save
46
+ */
47
+ export declare const save_config: <T>(runtime: FsWriteDeps, path: string, dir: string, config: T) => Promise<void>;
48
+ //# sourceMappingURL=config.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/cli/config.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EAAC,CAAC,EAAC,MAAM,KAAK,CAAC;AAE3B,OAAO,KAAK,EAAC,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,OAAO,EAAC,MAAM,oBAAoB,CAAC;AAElF;;;;;;GAMG;AACH,eAAO,MAAM,WAAW,GAAI,SAAS,IAAI,CAAC,OAAO,EAAE,SAAS,CAAC,EAAE,MAAM,MAAM,KAAG,MAAM,GAAG,IAGtF,CAAC;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,eAAe,GAAI,SAAS,IAAI,CAAC,OAAO,EAAE,SAAS,CAAC,EAAE,MAAM,MAAM,KAAG,MAAM,GAAG,IAG1F,CAAC;AAEF;;;;;;;GAOG;AACH,eAAO,MAAM,WAAW,GAAU,CAAC,EAClC,SAAS,UAAU,GAAG,OAAO,EAC7B,MAAM,MAAM,EACZ,QAAQ,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,KAClB,OAAO,CAAC,CAAC,GAAG,IAAI,CAoBlB,CAAC;AAEF;;;;;;;;;GASG;AACH,eAAO,MAAM,WAAW,GAAU,CAAC,EAClC,SAAS,WAAW,EACpB,MAAM,MAAM,EACZ,KAAK,MAAM,EACX,QAAQ,CAAC,KACP,OAAO,CAAC,IAAI,CAOd,CAAC"}
@@ -0,0 +1,77 @@
1
+ /**
2
+ * Generic CLI configuration loader.
3
+ *
4
+ * Manages CLI-specific configuration stored at `~/.{name}/config.json`.
5
+ * Consumers keep their project-specific Zod schemas locally and use
6
+ * these generic load/save functions.
7
+ *
8
+ * @module
9
+ */
10
+ /**
11
+ * Get the CLI config directory path (`~/.{name}`).
12
+ *
13
+ * @param runtime - runtime with `env_get` capability
14
+ * @param name - application name (e.g., `"tx"`, `"zzz"`)
15
+ * @returns path to config directory, or null if `$HOME` is not set
16
+ */
17
+ export const get_app_dir = (runtime, name) => {
18
+ const home = runtime.env_get('HOME');
19
+ return home ? `${home}/.${name}` : null;
20
+ };
21
+ /**
22
+ * Get the CLI config file path (`~/.{name}/config.json`).
23
+ *
24
+ * @param runtime - runtime with `env_get` capability
25
+ * @param name - application name
26
+ * @returns path to `config.json`, or null if `$HOME` is not set
27
+ */
28
+ export const get_config_path = (runtime, name) => {
29
+ const app_dir = get_app_dir(runtime, name);
30
+ return app_dir ? `${app_dir}/config.json` : null;
31
+ };
32
+ /**
33
+ * Load CLI configuration from a JSON file with Zod schema validation.
34
+ *
35
+ * @param runtime - runtime with file read capability
36
+ * @param path - path to the config JSON file
37
+ * @param schema - Zod schema to validate against
38
+ * @returns parsed config, or null if file doesn't exist or is invalid
39
+ */
40
+ export const load_config = async (runtime, path, schema) => {
41
+ // check if file exists
42
+ const stat = await runtime.stat(path);
43
+ if (!stat) {
44
+ return null;
45
+ }
46
+ try {
47
+ const content = await runtime.read_file(path);
48
+ const parsed = JSON.parse(content);
49
+ const result = schema.safeParse(parsed);
50
+ if (!result.success) {
51
+ runtime.warn(`Invalid config.json: ${result.error.message}`);
52
+ return null;
53
+ }
54
+ return result.data;
55
+ }
56
+ catch (error) {
57
+ runtime.warn(`Failed to read config.json: ${error.message}`);
58
+ return null;
59
+ }
60
+ };
61
+ /**
62
+ * Save CLI configuration to a JSON file.
63
+ *
64
+ * Creates parent directories if they don't exist.
65
+ *
66
+ * @param runtime - runtime with file write capability
67
+ * @param path - path to the config JSON file
68
+ * @param dir - directory containing the config file (created if missing)
69
+ * @param config - configuration to save
70
+ */
71
+ export const save_config = async (runtime, path, dir, config) => {
72
+ // ensure directory exists
73
+ await runtime.mkdir(dir, { recursive: true });
74
+ // write with pretty formatting
75
+ const content = JSON.stringify(config, null, '\t');
76
+ await runtime.write_file(path, content + '\n');
77
+ };