@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
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) fuz.dev
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,49 @@
1
+ # @fuzdev/fuz_app
2
+
3
+ > fullstack app library ⚠️ pre-alpha, do not use in production
4
+
5
+ fuz_app is a fullstack app library for
6
+ TypeScript, [Svelte](https://svelte.dev/), SvelteKit,
7
+ [Hono](https://hono.dev/), and [PostgreSQL](https://www.postgresql.org/)
8
+ with [PGlite](https://pglite.dev/) for embedded targets.
9
+ It provides auth, sessions, accounts, database integration, middleware, CLI utilities, and more,
10
+ the goal being an excellent and flexible whole-stack experience
11
+ for developers, operators, and end-users.
12
+
13
+ fuz_app supports deploying with Deno, Node, and Bun,
14
+ to servers, static websites, and local-first binaries, with more to come,
15
+ eventually with compatible alternatives written in Rust.
16
+
17
+ fuz_app is part of the [Fuz stack](https://www.fuz.dev/),
18
+ for more see the <a href="https://github.com/fuzdev/fuz_app/discussions">fuz_app discussions</a>.
19
+
20
+ > ⚠️ This is a pre-alpha release, not ready for production.
21
+ > There are no known security vulnerabilities,
22
+ > and security has been \_the\_ primary focus for the initial release,
23
+ > but it shouldn't be trusted until audited.
24
+
25
+ ## Usage
26
+
27
+ ```bash
28
+ npm i -D @fuzdev/fuz_app
29
+ ```
30
+
31
+ Some projects using fuz_app are in progress and will be open source soon.
32
+ Usage currently looks something like this:
33
+
34
+ ```ts
35
+ import {create_app_backend} from '@fuzdev/fuz_app/server/app_backend.js';
36
+ import {create_app_server} from '@fuzdev/fuz_app/server/app_server.js';
37
+
38
+ const backend = await create_app_backend({...});
39
+
40
+ const {app} = await create_app_server({backend, ...});
41
+
42
+ Deno.serve({port: PORT, hostname: HOST}, app.fetch);
43
+ ```
44
+
45
+ See [CLAUDE.md](CLAUDE.md) for more usage patterns and the AI-generated docs.
46
+
47
+ ## License
48
+
49
+ [MIT](LICENSE)
@@ -0,0 +1,65 @@
1
+ /**
2
+ * Bridge functions to derive `RouteSpec` and `SseEventSpec` from `ActionSpec`.
3
+ *
4
+ * Action specs define the contract (method, input/output, auth, side effects).
5
+ * Bridge functions produce transport-specific specs from them. HTTP-specific
6
+ * concerns (path, handler) come from options.
7
+ *
8
+ * @module
9
+ */
10
+ import type { z } from 'zod';
11
+ import type { ActionSpec, ActionAuth as ActionSpecAuth, ActionSideEffects } from './action_spec.js';
12
+ import type { RouteSpec, RouteAuth, RouteMethod, RouteHandler } from '../http/route_spec.js';
13
+ import type { SseEventSpec } from '../realtime/sse.js';
14
+ import type { RouteErrorSchemas } from '../http/error_schemas.js';
15
+ /** Options for deriving a `RouteSpec` from an `ActionSpec`. */
16
+ export interface ActionRouteOptions {
17
+ path: string;
18
+ handler: RouteHandler;
19
+ /** URL path parameter schema. Use `z.strictObject()` with string fields matching `:param` segments. */
20
+ params?: z.ZodObject;
21
+ /** URL query parameter schema. Use `z.strictObject()` with string fields. */
22
+ query?: z.ZodObject;
23
+ /** Override the default HTTP method (default: `side_effects` → POST, else GET). */
24
+ http_method?: RouteMethod;
25
+ /** Override the default auth mapping (default: `'public'` → none, `'authenticated'` → authenticated, `'keeper'` → keeper, `{role}` → role). */
26
+ auth?: RouteAuth;
27
+ /** Handler-specific error schemas (HTTP status code → Zod schema). Transport-specific — not on ActionSpec. */
28
+ errors?: RouteErrorSchemas;
29
+ }
30
+ /** Options for deriving an `SseEventSpec` from an `ActionSpec`. */
31
+ export interface ActionEventOptions {
32
+ channel?: string;
33
+ }
34
+ /** Map an `ActionAuth` value to a `RouteAuth`. */
35
+ export declare const map_action_auth: (auth: ActionSpecAuth) => RouteAuth;
36
+ /** Derive the default HTTP method from side effects. */
37
+ export declare const derive_http_method: (side_effects: ActionSideEffects) => RouteMethod;
38
+ /**
39
+ * Derive a `RouteSpec` from an `ActionSpec` and options.
40
+ *
41
+ * Only `request_response` actions (which require non-null `auth`) can become routes.
42
+ * `remote_notification` actions (auth null) should use `event_spec_from_action`.
43
+ * `local_call` actions are not for HTTP transport.
44
+ *
45
+ * Error schemas are transport-specific (keyed by HTTP status codes) and belong
46
+ * on the options, not the action spec. Action specs define the contract;
47
+ * transport concerns like HTTP error codes are added at the bridge layer.
48
+ *
49
+ * @param spec - the action spec (must have non-null `auth`)
50
+ * @param options - HTTP-specific options (path, handler, optional overrides)
51
+ * @returns a `RouteSpec` ready for `apply_route_specs`
52
+ * @throws if `spec.auth` is null
53
+ */
54
+ export declare const route_spec_from_action: (spec: ActionSpec, options: ActionRouteOptions) => RouteSpec;
55
+ /**
56
+ * Derive an `SseEventSpec` from an `ActionSpec`.
57
+ *
58
+ * Only `remote_notification` actions can become SSE events.
59
+ *
60
+ * @param spec - the action spec (must have `kind: 'remote_notification'`)
61
+ * @param options - optional SSE-specific options (channel)
62
+ * @returns an `SseEventSpec` ready for `create_validated_broadcaster`
63
+ */
64
+ export declare const event_spec_from_action: (spec: ActionSpec, options?: ActionEventOptions) => SseEventSpec;
65
+ //# sourceMappingURL=action_bridge.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"action_bridge.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/actions/action_bridge.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EAAC,CAAC,EAAC,MAAM,KAAK,CAAC;AAE3B,OAAO,KAAK,EAAC,UAAU,EAAE,UAAU,IAAI,cAAc,EAAE,iBAAiB,EAAC,MAAM,kBAAkB,CAAC;AAClG,OAAO,KAAK,EAAC,SAAS,EAAE,SAAS,EAAE,WAAW,EAAE,YAAY,EAAC,MAAM,uBAAuB,CAAC;AAC3F,OAAO,KAAK,EAAC,YAAY,EAAC,MAAM,oBAAoB,CAAC;AACrD,OAAO,KAAK,EAAC,iBAAiB,EAAC,MAAM,0BAA0B,CAAC;AAEhE,+DAA+D;AAC/D,MAAM,WAAW,kBAAkB;IAClC,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,YAAY,CAAC;IACtB,uGAAuG;IACvG,MAAM,CAAC,EAAE,CAAC,CAAC,SAAS,CAAC;IACrB,6EAA6E;IAC7E,KAAK,CAAC,EAAE,CAAC,CAAC,SAAS,CAAC;IACpB,mFAAmF;IACnF,WAAW,CAAC,EAAE,WAAW,CAAC;IAC1B,+IAA+I;IAC/I,IAAI,CAAC,EAAE,SAAS,CAAC;IACjB,8GAA8G;IAC9G,MAAM,CAAC,EAAE,iBAAiB,CAAC;CAC3B;AAED,mEAAmE;AACnE,MAAM,WAAW,kBAAkB;IAClC,OAAO,CAAC,EAAE,MAAM,CAAC;CACjB;AAED,kDAAkD;AAClD,eAAO,MAAM,eAAe,GAAI,MAAM,cAAc,KAAG,SAKtD,CAAC;AAEF,wDAAwD;AACxD,eAAO,MAAM,kBAAkB,GAAI,cAAc,iBAAiB,KAAG,WAEpE,CAAC;AAEF;;;;;;;;;;;;;;;GAeG;AACH,eAAO,MAAM,sBAAsB,GAClC,MAAM,UAAU,EAChB,SAAS,kBAAkB,KACzB,SAkBF,CAAC;AAEF;;;;;;;;GAQG;AACH,eAAO,MAAM,sBAAsB,GAClC,MAAM,UAAU,EAChB,UAAU,kBAAkB,KAC1B,YAYF,CAAC"}
@@ -0,0 +1,76 @@
1
+ /**
2
+ * Bridge functions to derive `RouteSpec` and `SseEventSpec` from `ActionSpec`.
3
+ *
4
+ * Action specs define the contract (method, input/output, auth, side effects).
5
+ * Bridge functions produce transport-specific specs from them. HTTP-specific
6
+ * concerns (path, handler) come from options.
7
+ *
8
+ * @module
9
+ */
10
+ /** Map an `ActionAuth` value to a `RouteAuth`. */
11
+ export const map_action_auth = (auth) => {
12
+ if (auth === 'public')
13
+ return { type: 'none' };
14
+ if (auth === 'authenticated')
15
+ return { type: 'authenticated' };
16
+ if (auth === 'keeper')
17
+ return { type: 'keeper' };
18
+ return { type: 'role', role: auth.role };
19
+ };
20
+ /** Derive the default HTTP method from side effects. */
21
+ export const derive_http_method = (side_effects) => {
22
+ return side_effects === true ? 'POST' : 'GET';
23
+ };
24
+ /**
25
+ * Derive a `RouteSpec` from an `ActionSpec` and options.
26
+ *
27
+ * Only `request_response` actions (which require non-null `auth`) can become routes.
28
+ * `remote_notification` actions (auth null) should use `event_spec_from_action`.
29
+ * `local_call` actions are not for HTTP transport.
30
+ *
31
+ * Error schemas are transport-specific (keyed by HTTP status codes) and belong
32
+ * on the options, not the action spec. Action specs define the contract;
33
+ * transport concerns like HTTP error codes are added at the bridge layer.
34
+ *
35
+ * @param spec - the action spec (must have non-null `auth`)
36
+ * @param options - HTTP-specific options (path, handler, optional overrides)
37
+ * @returns a `RouteSpec` ready for `apply_route_specs`
38
+ * @throws if `spec.auth` is null
39
+ */
40
+ export const route_spec_from_action = (spec, options) => {
41
+ if (spec.auth === null) {
42
+ throw new Error(`Cannot derive route spec from action '${spec.method}': auth is null (only request_response actions with non-null auth can become routes)`);
43
+ }
44
+ return {
45
+ method: options.http_method ?? derive_http_method(spec.side_effects),
46
+ path: options.path,
47
+ auth: options.auth ?? map_action_auth(spec.auth),
48
+ handler: options.handler,
49
+ description: spec.description,
50
+ ...(options.params ? { params: options.params } : {}),
51
+ ...(options.query ? { query: options.query } : {}),
52
+ input: spec.input,
53
+ output: spec.output,
54
+ ...(options.errors ? { errors: options.errors } : {}),
55
+ };
56
+ };
57
+ /**
58
+ * Derive an `SseEventSpec` from an `ActionSpec`.
59
+ *
60
+ * Only `remote_notification` actions can become SSE events.
61
+ *
62
+ * @param spec - the action spec (must have `kind: 'remote_notification'`)
63
+ * @param options - optional SSE-specific options (channel)
64
+ * @returns an `SseEventSpec` ready for `create_validated_broadcaster`
65
+ */
66
+ export const event_spec_from_action = (spec, options) => {
67
+ if (spec.kind !== 'remote_notification') {
68
+ throw new Error(`Cannot derive event spec from action '${spec.method}': kind is '${spec.kind}' (must be 'remote_notification')`);
69
+ }
70
+ return {
71
+ method: spec.method,
72
+ params: spec.input,
73
+ description: spec.description,
74
+ channel: options?.channel,
75
+ };
76
+ };
@@ -0,0 +1,97 @@
1
+ import type { ActionSpecUnion, ActionEventPhase } from './action_spec.js';
2
+ /**
3
+ * Represents an import item with its kind (type, value, or namespace).
4
+ */
5
+ interface ImportItem {
6
+ name: string;
7
+ kind: 'type' | 'value' | 'namespace';
8
+ }
9
+ /**
10
+ * Manages imports for generated code, building them on demand.
11
+ * Automatically optimizes type-only imports to use `import type` syntax.
12
+ *
13
+ * Why this matters:
14
+ * - `import type` statements are completely removed during compilation
15
+ * - Mixed imports like `import { type A, B }` cannot be safely removed
16
+ * - This ensures optimal tree-shaking and smaller bundle sizes
17
+ *
18
+ * @example
19
+ * ```typescript
20
+ * const imports = new ImportBuilder();
21
+ * imports.add_types('./types.js', 'Foo', 'Bar');
22
+ * imports.add('./utils.js', 'helper');
23
+ * imports.add_type('./utils.js', 'HelperOptions');
24
+ * imports.add('./action_specs.js', '* as specs');
25
+ *
26
+ * // Generates:
27
+ * // import type {Foo, Bar} from './types.js';
28
+ * // import {helper, type HelperOptions} from './utils.js';
29
+ * // import * as specs from './action_specs.js';
30
+ * ```
31
+ */
32
+ export declare class ImportBuilder {
33
+ #private;
34
+ imports: Map<string, Map<string, ImportItem>>;
35
+ /**
36
+ * Add a value import to be included in the generated code.
37
+ * @param from - the module to import from
38
+ * @param what - what to import (value)
39
+ */
40
+ add(from: string, what: string): this;
41
+ /**
42
+ * Add a type import to be included in the generated code.
43
+ * @param from - the module to import from
44
+ * @param what - what to import (type)
45
+ */
46
+ add_type(from: string, what: string): this;
47
+ /**
48
+ * Add multiple value imports from the same module.
49
+ */
50
+ add_many(from: string, ...items: Array<string>): this;
51
+ /**
52
+ * Add multiple type imports from the same module.
53
+ */
54
+ add_types(from: string, ...items: Array<string>): this;
55
+ /**
56
+ * Generate the import statements.
57
+ * If all imports from a module are types, uses `import type` syntax.
58
+ */
59
+ build(): string;
60
+ /**
61
+ * Check if the builder has any imports.
62
+ */
63
+ has_imports(): boolean;
64
+ /**
65
+ * Get the number of import statements that will be generated.
66
+ */
67
+ get import_count(): number;
68
+ /**
69
+ * Preview what imports will be generated (useful for debugging).
70
+ * @returns array of import statement strings
71
+ */
72
+ preview(): Array<string>;
73
+ /**
74
+ * Clear all imports.
75
+ */
76
+ clear(): this;
77
+ }
78
+ /**
79
+ * Determines which phases an executor can handle based on the action spec.
80
+ */
81
+ export declare const get_executor_phases: (spec: ActionSpecUnion, executor: "frontend" | "backend") => Array<ActionEventPhase>;
82
+ /**
83
+ * Gets the handler return type for a specific phase and spec.
84
+ * Also adds necessary imports to the `ImportBuilder`.
85
+ */
86
+ export declare const get_handler_return_type: (spec: ActionSpecUnion, phase: ActionEventPhase, imports: ImportBuilder, path_prefix: string) => string;
87
+ /**
88
+ * Generates the phase handlers for an action spec using the unified ActionEvent type
89
+ * with the new phase/step type parameters.
90
+ */
91
+ export declare const generate_phase_handlers: (spec: ActionSpecUnion, executor: "frontend" | "backend", imports: ImportBuilder) => string;
92
+ /**
93
+ * Creates a file banner comment.
94
+ */
95
+ export declare const create_banner: (origin_path: string) => string;
96
+ export {};
97
+ //# sourceMappingURL=action_codegen.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"action_codegen.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/actions/action_codegen.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAC,eAAe,EAAE,gBAAgB,EAAC,MAAM,kBAAkB,CAAC;AAKxE;;GAEG;AACH,UAAU,UAAU;IACnB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,GAAG,OAAO,GAAG,WAAW,CAAC;CACrC;AAED;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,qBAAa,aAAa;;IACzB,OAAO,EAAE,GAAG,CAAC,MAAM,EAAE,GAAG,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC,CAAa;IAE1D;;;;OAIG;IACH,GAAG,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,IAAI;IAQrC;;;;OAIG;IACH,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,IAAI;IAI1C;;OAEG;IACH,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,KAAK,EAAE,KAAK,CAAC,MAAM,CAAC,GAAG,IAAI;IAOrD;;OAEG;IACH,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,KAAK,EAAE,KAAK,CAAC,MAAM,CAAC,GAAG,IAAI;IAgCtD;;;OAGG;IACH,KAAK,IAAI,MAAM;IAIf;;OAEG;IACH,WAAW,IAAI,OAAO;IAItB;;OAEG;IACH,IAAI,YAAY,IAAI,MAAM,CAEzB;IAED;;;OAGG;IACH,OAAO,IAAI,KAAK,CAAC,MAAM,CAAC;IAIxB;;OAEG;IACH,KAAK,IAAI,IAAI;CAqDb;AAED;;GAEG;AACH,eAAO,MAAM,mBAAmB,GAC/B,MAAM,eAAe,EACrB,UAAU,UAAU,GAAG,SAAS,KAC9B,KAAK,CAAC,gBAAgB,CA4DxB,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,uBAAuB,GACnC,MAAM,eAAe,EACrB,OAAO,gBAAgB,EACvB,SAAS,aAAa,EACtB,aAAa,MAAM,KACjB,MAkBF,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,uBAAuB,GACnC,MAAM,eAAe,EACrB,UAAU,UAAU,GAAG,SAAS,EAChC,SAAS,aAAa,KACpB,MA+BF,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,aAAa,GAAI,aAAa,MAAM,KAAG,MACU,CAAC"}
@@ -0,0 +1,280 @@
1
+ import { UnreachableError } from '@fuzdev/fuz_util/error.js';
2
+ /**
3
+ * Manages imports for generated code, building them on demand.
4
+ * Automatically optimizes type-only imports to use `import type` syntax.
5
+ *
6
+ * Why this matters:
7
+ * - `import type` statements are completely removed during compilation
8
+ * - Mixed imports like `import { type A, B }` cannot be safely removed
9
+ * - This ensures optimal tree-shaking and smaller bundle sizes
10
+ *
11
+ * @example
12
+ * ```typescript
13
+ * const imports = new ImportBuilder();
14
+ * imports.add_types('./types.js', 'Foo', 'Bar');
15
+ * imports.add('./utils.js', 'helper');
16
+ * imports.add_type('./utils.js', 'HelperOptions');
17
+ * imports.add('./action_specs.js', '* as specs');
18
+ *
19
+ * // Generates:
20
+ * // import type {Foo, Bar} from './types.js';
21
+ * // import {helper, type HelperOptions} from './utils.js';
22
+ * // import * as specs from './action_specs.js';
23
+ * ```
24
+ */
25
+ export class ImportBuilder {
26
+ imports = new Map();
27
+ /**
28
+ * Add a value import to be included in the generated code.
29
+ * @param from - the module to import from
30
+ * @param what - what to import (value)
31
+ */
32
+ add(from, what) {
33
+ // Handle namespace imports specially
34
+ if (what.startsWith('* as ')) {
35
+ return this.#add_import(from, what, 'namespace');
36
+ }
37
+ return this.#add_import(from, what, 'value');
38
+ }
39
+ /**
40
+ * Add a type import to be included in the generated code.
41
+ * @param from - the module to import from
42
+ * @param what - what to import (type)
43
+ */
44
+ add_type(from, what) {
45
+ return this.#add_import(from, what, 'type');
46
+ }
47
+ /**
48
+ * Add multiple value imports from the same module.
49
+ */
50
+ add_many(from, ...items) {
51
+ for (const item of items) {
52
+ this.add(from, item);
53
+ }
54
+ return this;
55
+ }
56
+ /**
57
+ * Add multiple type imports from the same module.
58
+ */
59
+ add_types(from, ...items) {
60
+ for (const item of items) {
61
+ this.add_type(from, item);
62
+ }
63
+ return this;
64
+ }
65
+ /**
66
+ * Internal method to add an import with its kind.
67
+ */
68
+ #add_import(from, name, kind) {
69
+ // Skip empty imports
70
+ if (!name || (kind !== 'namespace' && name === '')) {
71
+ return this;
72
+ }
73
+ if (!this.imports.has(from)) {
74
+ this.imports.set(from, new Map());
75
+ }
76
+ const module_imports = this.imports.get(from);
77
+ const existing = module_imports.get(name);
78
+ // If already imported as a value, don't downgrade to type
79
+ if (existing?.kind === 'value' && kind === 'type') {
80
+ return this;
81
+ }
82
+ module_imports.set(name, { name, kind });
83
+ return this;
84
+ }
85
+ /**
86
+ * Generate the import statements.
87
+ * If all imports from a module are types, uses `import type` syntax.
88
+ */
89
+ build() {
90
+ return this.#generate_import_statements().join('\n');
91
+ }
92
+ /**
93
+ * Check if the builder has any imports.
94
+ */
95
+ has_imports() {
96
+ return this.imports.size > 0;
97
+ }
98
+ /**
99
+ * Get the number of import statements that will be generated.
100
+ */
101
+ get import_count() {
102
+ return this.imports.size;
103
+ }
104
+ /**
105
+ * Preview what imports will be generated (useful for debugging).
106
+ * @returns array of import statement strings
107
+ */
108
+ preview() {
109
+ return this.#generate_import_statements();
110
+ }
111
+ /**
112
+ * Clear all imports.
113
+ */
114
+ clear() {
115
+ this.imports.clear();
116
+ return this;
117
+ }
118
+ /**
119
+ * Internal helper to generate import statements from the current state.
120
+ * Shared by both build() and preview() methods.
121
+ */
122
+ #generate_import_statements() {
123
+ const statements = [];
124
+ for (const [from, module_imports] of this.imports) {
125
+ const items = Array.from(module_imports.values());
126
+ // Check if all imports are types
127
+ const all_types = items.every((item) => item.kind === 'type');
128
+ if (all_types) {
129
+ // Use type-only import syntax
130
+ const sorted_names = items
131
+ .map((item) => item.name)
132
+ .sort((a, b) => (a < b ? -1 : a > b ? 1 : 0));
133
+ statements.push(`import type {${sorted_names.join(', ')}} from '${from}';`);
134
+ }
135
+ else {
136
+ // Check for namespace imports (should be only one per module)
137
+ const namespace_import = items.find((item) => item.kind === 'namespace');
138
+ if (namespace_import) {
139
+ statements.push(`import ${namespace_import.name} from '${from}';`);
140
+ }
141
+ else {
142
+ // Mixed imports - sort values first, then types, alphabetically within each group
143
+ const sorted_items = items.sort((a, b) => {
144
+ // First sort by kind: values before types
145
+ if (a.kind !== b.kind) {
146
+ return a.kind === 'value' ? -1 : 1;
147
+ }
148
+ // Then sort alphabetically within the same kind using standard comparison
149
+ return a.name < b.name ? -1 : a.name > b.name ? 1 : 0;
150
+ });
151
+ const formatted_imports = sorted_items.map((item) => {
152
+ if (item.kind === 'namespace') {
153
+ return item.name; // namespace imports like "* as foo" are used as-is
154
+ }
155
+ return item.kind === 'type' ? `type ${item.name}` : item.name;
156
+ });
157
+ statements.push(`import {${formatted_imports.join(', ')}} from '${from}';`);
158
+ }
159
+ }
160
+ }
161
+ return statements;
162
+ }
163
+ }
164
+ /**
165
+ * Determines which phases an executor can handle based on the action spec.
166
+ */
167
+ export const get_executor_phases = (spec, executor) => {
168
+ const { kind, initiator } = spec;
169
+ const phases = [];
170
+ switch (kind) {
171
+ case 'request_response': {
172
+ // Executor can send/receive based on initiator
173
+ const can_send = initiator === executor || initiator === 'both';
174
+ const can_receive = initiator === 'both' || initiator !== executor;
175
+ switch (executor) {
176
+ case 'frontend':
177
+ if (can_send) {
178
+ phases.push('send_request', 'receive_response');
179
+ // Add error phases for send/receive
180
+ phases.push('send_error', 'receive_error');
181
+ }
182
+ if (can_receive)
183
+ phases.push('receive_request', 'send_response');
184
+ break;
185
+ case 'backend':
186
+ if (can_send) {
187
+ phases.push('send_request', 'receive_response');
188
+ // Add error phases for send/receive
189
+ phases.push('send_error', 'receive_error');
190
+ }
191
+ if (can_receive) {
192
+ phases.push('receive_request', 'send_response');
193
+ // TODO @action-system-review This adds send_error redundantly when initiator:'both'
194
+ // (already added above). Deduplication via Set at the end handles it,
195
+ // but the logic should be consolidated when the action system is revisited.
196
+ phases.push('send_error');
197
+ }
198
+ break;
199
+ default:
200
+ throw new UnreachableError(executor);
201
+ }
202
+ break;
203
+ }
204
+ case 'remote_notification': {
205
+ const can_send = initiator === executor || initiator === 'both';
206
+ const can_receive = initiator === 'both' || initiator !== executor;
207
+ if (can_send)
208
+ phases.push('send');
209
+ if (can_receive)
210
+ phases.push('receive');
211
+ break;
212
+ }
213
+ case 'local_call': {
214
+ const can_execute = initiator === executor || initiator === 'both';
215
+ if (can_execute)
216
+ phases.push('execute');
217
+ break;
218
+ }
219
+ default:
220
+ throw new UnreachableError(kind);
221
+ }
222
+ // Deduplicate phases (e.g., send_error added twice for initiator:'both' backend actions)
223
+ return Array.from(new Set(phases));
224
+ };
225
+ /**
226
+ * Gets the handler return type for a specific phase and spec.
227
+ * Also adds necessary imports to the `ImportBuilder`.
228
+ */
229
+ export const get_handler_return_type = (spec, phase, imports, path_prefix) => {
230
+ // For request_response receive_request, handler returns the output
231
+ if (spec.kind === 'request_response' && phase === 'receive_request') {
232
+ imports.add_type(`${path_prefix}action_collections.js`, 'ActionOutputs');
233
+ const base_type = `ActionOutputs['${spec.method}']`;
234
+ // Request/response actions are always async
235
+ return `${base_type} | Promise<${base_type}>`;
236
+ }
237
+ // For local_call execute, handler returns the output
238
+ if (spec.kind === 'local_call' && phase === 'execute') {
239
+ imports.add_type(`${path_prefix}action_collections.js`, 'ActionOutputs');
240
+ const base_type = `ActionOutputs['${spec.method}']`;
241
+ return spec.async ? `${base_type} | Promise<${base_type}>` : base_type;
242
+ }
243
+ // All other phases return void
244
+ return 'void | Promise<void>';
245
+ };
246
+ /**
247
+ * Generates the phase handlers for an action spec using the unified ActionEvent type
248
+ * with the new phase/step type parameters.
249
+ */
250
+ export const generate_phase_handlers = (spec, executor, imports) => {
251
+ const { method } = spec;
252
+ const phases = get_executor_phases(spec, executor);
253
+ if (phases.length === 0) {
254
+ return `${method}?: never`;
255
+ }
256
+ // Add necessary imports for the unified system
257
+ // Backend types file is in server/ subdirectory, so needs different relative paths
258
+ const path_prefix = executor === 'frontend' ? './' : '../';
259
+ imports.add_type(`${path_prefix}action_event.js`, 'ActionEvent');
260
+ // Add environment type import
261
+ const environment_type = executor === 'frontend' ? 'Frontend' : 'Backend';
262
+ const environment_module = executor === 'frontend' ? './frontend.svelte.js' : './backend.js';
263
+ imports.add_type(environment_module, environment_type);
264
+ // Generate handler definitions for each phase
265
+ const phase_handlers = phases
266
+ .map((phase) => {
267
+ // Pass imports to get_handler_return_type so it can add necessary imports
268
+ const return_type = get_handler_return_type(spec, phase, imports, path_prefix);
269
+ // Use the new type parameter approach
270
+ return `${phase}?: (
271
+ action_event: ActionEvent<'${method}', ${environment_type}, '${phase}', 'handling'>
272
+ ) => ${return_type}`;
273
+ })
274
+ .join(';\n\t\t');
275
+ return `${method}?: {\n\t\t${phase_handlers};\n\t}`;
276
+ };
277
+ /**
278
+ * Creates a file banner comment.
279
+ */
280
+ export const create_banner = (origin_path) => `generated by ${origin_path} - DO NOT EDIT OR RISK LOST DATA`;
@@ -0,0 +1,35 @@
1
+ /**
2
+ * `ActionRegistry` — query and filter utility over `ActionSpecUnion[]`.
3
+ *
4
+ * @module
5
+ */
6
+ import type { ActionSpecUnion, RequestResponseActionSpec, RemoteNotificationActionSpec, LocalCallActionSpec } from './action_spec.js';
7
+ /**
8
+ * Utility class to manage and query action specifications.
9
+ * Provides helper methods to get actions by various criteria.
10
+ */
11
+ export declare class ActionRegistry {
12
+ readonly specs: Array<ActionSpecUnion>;
13
+ constructor(specs: Array<ActionSpecUnion>);
14
+ get spec_by_method(): Map<string, ActionSpecUnion>;
15
+ get request_response_specs(): Array<RequestResponseActionSpec>;
16
+ get remote_notification_specs(): Array<RemoteNotificationActionSpec>;
17
+ get local_call_specs(): Array<LocalCallActionSpec>;
18
+ get backend_specs(): Array<ActionSpecUnion>;
19
+ get frontend_specs(): Array<ActionSpecUnion>;
20
+ get backend_to_frontend_specs(): Array<ActionSpecUnion>;
21
+ get frontend_to_backend_specs(): Array<ActionSpecUnion>;
22
+ get public_specs(): Array<ActionSpecUnion>;
23
+ get authenticated_specs(): Array<ActionSpecUnion>;
24
+ get methods(): Array<string>;
25
+ get request_response_methods(): Array<string>;
26
+ get remote_notification_methods(): Array<string>;
27
+ get local_call_methods(): Array<string>;
28
+ get backend_methods(): Array<string>;
29
+ get frontend_methods(): Array<string>;
30
+ get frontend_to_backend_methods(): Array<string>;
31
+ get backend_to_frontend_methods(): Array<string>;
32
+ get public_methods(): Array<string>;
33
+ get authenticated_methods(): Array<string>;
34
+ }
35
+ //# sourceMappingURL=action_registry.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"action_registry.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/actions/action_registry.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EACX,eAAe,EACf,yBAAyB,EACzB,4BAA4B,EAC5B,mBAAmB,EACnB,MAAM,kBAAkB,CAAC;AAQ1B;;;GAGG;AACH,qBAAa,cAAc;IAC1B,QAAQ,CAAC,KAAK,EAAE,KAAK,CAAC,eAAe,CAAC,CAAC;gBAE3B,KAAK,EAAE,KAAK,CAAC,eAAe,CAAC;IAIzC,IAAI,cAAc,IAAI,GAAG,CAAC,MAAM,EAAE,eAAe,CAAC,CAEjD;IAED,IAAI,sBAAsB,IAAI,KAAK,CAAC,yBAAyB,CAAC,CAE7D;IAED,IAAI,yBAAyB,IAAI,KAAK,CAAC,4BAA4B,CAAC,CAEnE;IAED,IAAI,gBAAgB,IAAI,KAAK,CAAC,mBAAmB,CAAC,CAEjD;IAKD,IAAI,aAAa,IAAI,KAAK,CAAC,eAAe,CAAC,CAE1C;IAED,IAAI,cAAc,IAAI,KAAK,CAAC,eAAe,CAAC,CAE3C;IAED,IAAI,yBAAyB,IAAI,KAAK,CAAC,eAAe,CAAC,CAEtD;IAED,IAAI,yBAAyB,IAAI,KAAK,CAAC,eAAe,CAAC,CAEtD;IAED,IAAI,YAAY,IAAI,KAAK,CAAC,eAAe,CAAC,CAEzC;IAED,IAAI,mBAAmB,IAAI,KAAK,CAAC,eAAe,CAAC,CAEhD;IAED,IAAI,OAAO,IAAI,KAAK,CAAC,MAAM,CAAC,CAE3B;IAED,IAAI,wBAAwB,IAAI,KAAK,CAAC,MAAM,CAAC,CAE5C;IAED,IAAI,2BAA2B,IAAI,KAAK,CAAC,MAAM,CAAC,CAE/C;IAED,IAAI,kBAAkB,IAAI,KAAK,CAAC,MAAM,CAAC,CAEtC;IAED,IAAI,eAAe,IAAI,KAAK,CAAC,MAAM,CAAC,CAEnC;IAED,IAAI,gBAAgB,IAAI,KAAK,CAAC,MAAM,CAAC,CAEpC;IAED,IAAI,2BAA2B,IAAI,KAAK,CAAC,MAAM,CAAC,CAE/C;IAED,IAAI,2BAA2B,IAAI,KAAK,CAAC,MAAM,CAAC,CAE/C;IAED,IAAI,cAAc,IAAI,KAAK,CAAC,MAAM,CAAC,CAElC;IAED,IAAI,qBAAqB,IAAI,KAAK,CAAC,MAAM,CAAC,CAEzC;CACD"}