@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,265 @@
1
+ /**
2
+ * Dev workflow helpers for setup, reset, and database management.
3
+ *
4
+ * Composable functions that consumer projects (tx, visiones, etc.) use in their
5
+ * `scripts/dev_setup.ts`, `scripts/dev_reset.ts`, etc. All functions accept narrow
6
+ * `*Deps` interfaces from `runtime/deps.ts` — pass a `RuntimeDeps` instance
7
+ * created by `create_deno_runtime()`.
8
+ *
9
+ * @module
10
+ */
11
+ /** Default logger using bracket format. */
12
+ export const default_setup_logger = {
13
+ ok: (msg) => console.log(` [ok] ${msg}`),
14
+ skip: (msg) => console.log(` [skip] ${msg}`),
15
+ error: (msg) => console.error(` [error] ${msg}`),
16
+ };
17
+ // === Pure utilities ===
18
+ /**
19
+ * Extract the database name from a PostgreSQL URL.
20
+ *
21
+ * @returns the database name, or `null` if the URL is invalid or has no path
22
+ */
23
+ export const parse_db_name = (url) => {
24
+ try {
25
+ const u = new URL(url);
26
+ const name = u.pathname.slice(1); // remove leading /
27
+ return name || null;
28
+ }
29
+ catch {
30
+ return null;
31
+ }
32
+ };
33
+ /**
34
+ * Generate a random base64 key using openssl.
35
+ *
36
+ * @param deps - command execution capability
37
+ * @returns a random 32-byte base64-encoded key
38
+ */
39
+ export const generate_random_key = async (deps) => {
40
+ const result = await deps.run_command('openssl', ['rand', '-base64', '32']);
41
+ if (!result.success)
42
+ throw new Error('Failed to generate key with openssl');
43
+ return result.stdout.trim();
44
+ };
45
+ // === File helpers ===
46
+ /**
47
+ * Read a single env var from a dotenv-style file.
48
+ *
49
+ * @param deps - file read capability
50
+ * @param env_path - path to the .env file
51
+ * @param name - the variable name to read
52
+ * @returns the value, or `undefined` if the file or variable doesn't exist
53
+ */
54
+ export const read_env_var = async (deps, env_path, name) => {
55
+ const stat = await deps.stat(env_path);
56
+ if (!stat?.is_file)
57
+ return undefined;
58
+ try {
59
+ const content = await deps.read_file(env_path);
60
+ const match = new RegExp(`^${name}=(.+)$`, 'm').exec(content);
61
+ return match?.[1]?.trim();
62
+ }
63
+ catch {
64
+ return undefined;
65
+ }
66
+ };
67
+ // === Setup helpers ===
68
+ /**
69
+ * Create an env file from its example template, auto-generating `SECRET_COOKIE_KEYS`.
70
+ *
71
+ * If the file already exists, backfills any empty values that have generators.
72
+ * Idempotent — safe to re-run.
73
+ *
74
+ * @param deps - file read, write, and command capabilities
75
+ * @param env_path - path for the env file (e.g. `.env.development`)
76
+ * @param example_path - path to the example template
77
+ * @param options - extra replacements, permissions, logger
78
+ * @returns result indicating whether the file was created or updated
79
+ */
80
+ export const setup_env_file = async (deps, env_path, example_path, options) => {
81
+ const log = options?.log ?? default_setup_logger;
82
+ const set_permissions = options?.set_permissions;
83
+ // build the full replacement map (SECRET_COOKIE_KEYS + extras)
84
+ const replacements = {
85
+ SECRET_COOKIE_KEYS: () => generate_random_key(deps),
86
+ ...options?.replacements,
87
+ };
88
+ const stat = await deps.stat(env_path);
89
+ if (stat?.is_file) {
90
+ // file exists — backfill any empty values
91
+ let content = await deps.read_file(env_path);
92
+ let changed = false;
93
+ for (const [key, generate] of Object.entries(replacements)) {
94
+ const pattern = new RegExp(`^${key}=$`, 'm');
95
+ if (pattern.test(content)) {
96
+ const value = await generate(); // eslint-disable-line no-await-in-loop
97
+ content = content.replace(pattern, `${key}=${value}`);
98
+ changed = true;
99
+ log.ok(`Generated ${key} in existing ${env_path}`);
100
+ }
101
+ }
102
+ if (changed) {
103
+ await deps.write_file(env_path, content);
104
+ if (set_permissions)
105
+ await set_permissions(env_path, 0o600);
106
+ }
107
+ else {
108
+ log.skip(`${env_path} already configured`);
109
+ }
110
+ return { created: false, updated: changed, path: env_path };
111
+ }
112
+ // create from example
113
+ let content = await deps.read_file(example_path);
114
+ for (const [key, generate] of Object.entries(replacements)) {
115
+ const pattern = new RegExp(`^${key}=$`, 'm');
116
+ if (pattern.test(content)) {
117
+ const value = await generate(); // eslint-disable-line no-await-in-loop
118
+ content = content.replace(pattern, `${key}=${value}`);
119
+ }
120
+ }
121
+ await deps.write_file(env_path, content);
122
+ if (set_permissions)
123
+ await set_permissions(env_path, 0o600);
124
+ log.ok(`Created ${env_path} with generated secrets`);
125
+ return { created: true, updated: true, path: env_path };
126
+ };
127
+ /**
128
+ * Create a bootstrap token file if it doesn't exist.
129
+ *
130
+ * The token is a one-shot secret used to create the first admin account.
131
+ * Stored at `~/.{app_name}/secret_bootstrap_token` by default.
132
+ *
133
+ * @param deps - file, command, and env capabilities
134
+ * @param app_name - application name (used for default state directory)
135
+ * @param options - state_dir override, permissions, logger
136
+ * @returns result indicating whether a token was created
137
+ */
138
+ export const setup_bootstrap_token = async (deps, app_name, options) => {
139
+ const log = options?.log ?? default_setup_logger;
140
+ const set_permissions = options?.set_permissions;
141
+ const home = deps.env_get('HOME');
142
+ if (!home) {
143
+ log.skip('$HOME not set, skipping bootstrap token');
144
+ return { created: false, token_path: '' };
145
+ }
146
+ const state_dir = options?.state_dir ?? `${home}/.${app_name}`;
147
+ const token_path = `${state_dir}/secret_bootstrap_token`;
148
+ const stat = await deps.stat(token_path);
149
+ if (stat?.is_file) {
150
+ log.skip(`~/.${app_name}/secret_bootstrap_token already exists`);
151
+ return { created: false, token_path };
152
+ }
153
+ await deps.mkdir(state_dir, { recursive: true });
154
+ if (set_permissions)
155
+ await set_permissions(state_dir, 0o700);
156
+ const key = await generate_random_key(deps);
157
+ await deps.write_file(token_path, key + '\n');
158
+ if (set_permissions)
159
+ await set_permissions(token_path, 0o600);
160
+ log.ok(`Created ~/.${app_name}/secret_bootstrap_token (one-shot, deleted after first use)`);
161
+ return { created: true, token_path };
162
+ };
163
+ /**
164
+ * Remove an existing bootstrap token and create a new one.
165
+ *
166
+ * @param deps - file, command, env, and remove capabilities
167
+ * @param app_name - application name
168
+ * @param options - state_dir override, permissions, logger
169
+ * @returns result from creating the new token
170
+ */
171
+ export const reset_bootstrap_token = async (deps, app_name, options) => {
172
+ const log = options?.log ?? default_setup_logger;
173
+ const set_permissions = options?.set_permissions;
174
+ const home = deps.env_get('HOME');
175
+ if (!home) {
176
+ log.skip('$HOME not set');
177
+ return { created: false, token_path: '' };
178
+ }
179
+ const state_dir = options?.state_dir ?? `${home}/.${app_name}`;
180
+ const token_path = `${state_dir}/secret_bootstrap_token`;
181
+ const stat = await deps.stat(token_path);
182
+ if (stat?.is_file) {
183
+ await deps.remove(token_path);
184
+ log.ok('Removed existing bootstrap token');
185
+ }
186
+ return setup_bootstrap_token(deps, app_name, { state_dir, set_permissions, log });
187
+ };
188
+ // === Database helpers ===
189
+ /**
190
+ * Create a PostgreSQL database if `createdb` is available.
191
+ *
192
+ * @param deps - command execution capability
193
+ * @param db_name - database name to create
194
+ * @param options - logger
195
+ * @returns the command result
196
+ */
197
+ export const create_database = async (deps, db_name, options) => {
198
+ const log = options?.log ?? default_setup_logger;
199
+ const check = await deps.run_command('which', ['createdb']);
200
+ if (!check.success) {
201
+ log.skip('createdb not found — install PostgreSQL or use pglite');
202
+ return check;
203
+ }
204
+ const result = await deps.run_command('createdb', [db_name]);
205
+ if (result.success) {
206
+ log.ok(`Created ${db_name} database`);
207
+ }
208
+ else {
209
+ log.skip(`${db_name} database already exists`);
210
+ }
211
+ return result;
212
+ };
213
+ /**
214
+ * Reset a database to a clean slate.
215
+ *
216
+ * For PostgreSQL: drops and recreates the database.
217
+ * For pglite: removes the data directory if `pglite_data_dir` is provided.
218
+ * For empty/missing URLs: skips.
219
+ *
220
+ * @param deps - command and file capabilities
221
+ * @param database_url - the DATABASE_URL value
222
+ * @param options - pglite_data_dir, logger
223
+ * @returns result describing what happened
224
+ */
225
+ export const reset_database = async (deps, database_url, options) => {
226
+ const log = options?.log ?? default_setup_logger;
227
+ // empty or missing
228
+ if (!database_url) {
229
+ log.skip('No DATABASE_URL, skipping database reset');
230
+ return { reset: false, skipped: true, db_type: 'none' };
231
+ }
232
+ // pglite
233
+ if (database_url === 'pglite' || database_url.startsWith('pglite:')) {
234
+ const pglite_dir = options?.pglite_data_dir;
235
+ if (pglite_dir) {
236
+ const stat = await deps.stat(pglite_dir);
237
+ if (stat?.is_directory) {
238
+ await deps.remove(pglite_dir, { recursive: true });
239
+ log.ok(`Removed pglite directory: ${pglite_dir}`);
240
+ return { reset: true, skipped: false, db_type: 'pglite' };
241
+ }
242
+ }
243
+ log.skip('No pglite directory to remove');
244
+ return { reset: false, skipped: true, db_type: 'pglite' };
245
+ }
246
+ // PostgreSQL
247
+ const db_name = parse_db_name(database_url);
248
+ if (!db_name) {
249
+ log.error('Could not parse database name from DATABASE_URL');
250
+ return { reset: false, skipped: true, db_type: 'postgres' };
251
+ }
252
+ const drop = await deps.run_command('dropdb', ['--if-exists', db_name]);
253
+ if (!drop.success) {
254
+ log.error(`Failed to drop database: ${drop.stderr}`);
255
+ return { reset: false, skipped: false, db_type: 'postgres' };
256
+ }
257
+ log.ok(`Dropped database: ${db_name}`);
258
+ const create = await deps.run_command('createdb', [db_name]);
259
+ if (!create.success) {
260
+ log.error(`Failed to create database: ${create.stderr}`);
261
+ return { reset: false, skipped: false, db_type: 'postgres' };
262
+ }
263
+ log.ok(`Created database: ${db_name}`);
264
+ return { reset: true, skipped: false, db_type: 'postgres' };
265
+ };
@@ -0,0 +1,25 @@
1
+ /**
2
+ * Dotenv file parsing and loading.
3
+ *
4
+ * Provides `parse_dotenv` for parsing dotenv-format strings
5
+ * and `load_env_file` for reading and parsing env files from disk.
6
+ *
7
+ * @module
8
+ */
9
+ import type { FsReadDeps } from '../runtime/deps.js';
10
+ /**
11
+ * Parse a dotenv-format string into a record.
12
+ *
13
+ * @param content - dotenv file content
14
+ * @returns parsed key-value pairs
15
+ */
16
+ export declare const parse_dotenv: (content: string) => Record<string, string>;
17
+ /**
18
+ * Load and parse an env file.
19
+ *
20
+ * @param runtime - runtime with `read_file` capability
21
+ * @param path - path to env file
22
+ * @returns parsed env record, or null if file doesn't exist
23
+ */
24
+ export declare const load_env_file: (runtime: Pick<FsReadDeps, "read_file">, path: string) => Promise<Record<string, string> | null>;
25
+ //# sourceMappingURL=dotenv.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dotenv.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/env/dotenv.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAC,UAAU,EAAC,MAAM,oBAAoB,CAAC;AAEnD;;;;;GAKG;AACH,eAAO,MAAM,YAAY,GAAI,SAAS,MAAM,KAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAqBnE,CAAC;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,aAAa,GACzB,SAAS,IAAI,CAAC,UAAU,EAAE,WAAW,CAAC,EACtC,MAAM,MAAM,KACV,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,IAAI,CAOvC,CAAC"}
@@ -0,0 +1,52 @@
1
+ /**
2
+ * Dotenv file parsing and loading.
3
+ *
4
+ * Provides `parse_dotenv` for parsing dotenv-format strings
5
+ * and `load_env_file` for reading and parsing env files from disk.
6
+ *
7
+ * @module
8
+ */
9
+ /**
10
+ * Parse a dotenv-format string into a record.
11
+ *
12
+ * @param content - dotenv file content
13
+ * @returns parsed key-value pairs
14
+ */
15
+ export const parse_dotenv = (content) => {
16
+ const result = {};
17
+ for (const line of content.split('\n')) {
18
+ const trimmed = line.trim();
19
+ // skip empty lines and comments
20
+ if (!trimmed || trimmed.startsWith('#'))
21
+ continue;
22
+ const eq_index = trimmed.indexOf('=');
23
+ if (eq_index === -1)
24
+ continue;
25
+ const key = trimmed.slice(0, eq_index).trim();
26
+ let value = trimmed.slice(eq_index + 1).trim();
27
+ // remove surrounding quotes if present (need at least 2 chars for open+close)
28
+ if (value.length >= 2 &&
29
+ ((value.startsWith('"') && value.endsWith('"')) ||
30
+ (value.startsWith("'") && value.endsWith("'")))) {
31
+ value = value.slice(1, -1);
32
+ }
33
+ result[key] = value;
34
+ }
35
+ return result;
36
+ };
37
+ /**
38
+ * Load and parse an env file.
39
+ *
40
+ * @param runtime - runtime with `read_file` capability
41
+ * @param path - path to env file
42
+ * @returns parsed env record, or null if file doesn't exist
43
+ */
44
+ export const load_env_file = async (runtime, path) => {
45
+ try {
46
+ const content = await runtime.read_file(path);
47
+ return parse_dotenv(content);
48
+ }
49
+ catch {
50
+ return null;
51
+ }
52
+ };
@@ -0,0 +1,52 @@
1
+ /**
2
+ * Generic environment loading from Zod schemas.
3
+ *
4
+ * Provides `load_env` which iterates Zod schema keys, gets env values, and validates.
5
+ * Apps handle error messages themselves (they're always app-specific).
6
+ *
7
+ * @module
8
+ */
9
+ import { z } from 'zod';
10
+ /**
11
+ * Error thrown when environment validation fails.
12
+ *
13
+ * Contains structured information for apps to format their own error messages.
14
+ */
15
+ export declare class EnvValidationError extends Error {
16
+ /** The raw env values that were read. */
17
+ readonly raw: Record<string, string | undefined>;
18
+ /** The Zod validation error. */
19
+ readonly zod_error: z.core.$ZodError;
20
+ /** True if every env var was undefined (nothing loaded). */
21
+ readonly all_undefined: boolean;
22
+ constructor(raw: Record<string, string | undefined>, zod_error: z.core.$ZodError);
23
+ /**
24
+ * Format Zod validation issues as human-readable strings.
25
+ *
26
+ * @returns array of formatted issue strings like `"PORT: Expected number"`
27
+ */
28
+ format_issues(): Array<string>;
29
+ }
30
+ /**
31
+ * Log formatted env validation issues to stderr.
32
+ *
33
+ * Handles the common case: labels each Zod issue with an optional prefix.
34
+ * Callers who want app-specific "getting started" instructions should check
35
+ * `error.all_undefined` before calling this.
36
+ *
37
+ * @param error - the env validation error
38
+ * @param label - optional prefix for log lines (e.g., 'tx daemon', 'env')
39
+ */
40
+ export declare const log_env_validation_error: (error: EnvValidationError, label?: string) => void;
41
+ /**
42
+ * Load and validate env vars against a Zod schema.
43
+ *
44
+ * Reads each key from the schema using `get_env`, then validates.
45
+ * Throws `EnvValidationError` on failure.
46
+ *
47
+ * @param schema - Zod object schema defining expected env vars
48
+ * @param get_env - function to read an env var by key
49
+ * @returns validated env object
50
+ */
51
+ export declare const load_env: <T extends z.ZodObject>(schema: T, get_env: (key: string) => string | undefined) => z.infer<T>;
52
+ //# sourceMappingURL=load.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"load.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/env/load.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAC,CAAC,EAAC,MAAM,KAAK,CAAC;AAEtB;;;;GAIG;AACH,qBAAa,kBAAmB,SAAQ,KAAK;IAC5C,yCAAyC;IACzC,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC,CAAC;IACjD,gCAAgC;IAChC,QAAQ,CAAC,SAAS,EAAE,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC;IACrC,4DAA4D;IAC5D,QAAQ,CAAC,aAAa,EAAE,OAAO,CAAC;gBAEpB,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC,EAAE,SAAS,EAAE,CAAC,CAAC,IAAI,CAAC,SAAS;IAOhF;;;;OAIG;IACH,aAAa,IAAI,KAAK,CAAC,MAAM,CAAC;CAG9B;AAED;;;;;;;;;GASG;AACH,eAAO,MAAM,wBAAwB,GAAI,OAAO,kBAAkB,EAAE,QAAQ,MAAM,KAAG,IAUpF,CAAC;AAEF;;;;;;;;;GASG;AACH,eAAO,MAAM,QAAQ,GAAI,CAAC,SAAS,CAAC,CAAC,SAAS,EAC7C,QAAQ,CAAC,EACT,SAAS,CAAC,GAAG,EAAE,MAAM,KAAK,MAAM,GAAG,SAAS,KAC1C,CAAC,CAAC,KAAK,CAAC,CAAC,CAaX,CAAC"}
@@ -0,0 +1,79 @@
1
+ /**
2
+ * Generic environment loading from Zod schemas.
3
+ *
4
+ * Provides `load_env` which iterates Zod schema keys, gets env values, and validates.
5
+ * Apps handle error messages themselves (they're always app-specific).
6
+ *
7
+ * @module
8
+ */
9
+ import { z } from 'zod';
10
+ /**
11
+ * Error thrown when environment validation fails.
12
+ *
13
+ * Contains structured information for apps to format their own error messages.
14
+ */
15
+ export class EnvValidationError extends Error {
16
+ /** The raw env values that were read. */
17
+ raw;
18
+ /** The Zod validation error. */
19
+ zod_error;
20
+ /** True if every env var was undefined (nothing loaded). */
21
+ all_undefined;
22
+ constructor(raw, zod_error) {
23
+ super('Environment validation failed');
24
+ this.raw = raw;
25
+ this.zod_error = zod_error;
26
+ this.all_undefined = Object.values(raw).every((v) => v === undefined);
27
+ }
28
+ /**
29
+ * Format Zod validation issues as human-readable strings.
30
+ *
31
+ * @returns array of formatted issue strings like `"PORT: Expected number"`
32
+ */
33
+ format_issues() {
34
+ return this.zod_error.issues.map((issue) => `${issue.path.join('.')}: ${issue.message}`);
35
+ }
36
+ }
37
+ /**
38
+ * Log formatted env validation issues to stderr.
39
+ *
40
+ * Handles the common case: labels each Zod issue with an optional prefix.
41
+ * Callers who want app-specific "getting started" instructions should check
42
+ * `error.all_undefined` before calling this.
43
+ *
44
+ * @param error - the env validation error
45
+ * @param label - optional prefix for log lines (e.g., 'tx daemon', 'env')
46
+ */
47
+ export const log_env_validation_error = (error, label) => {
48
+ const prefix = label ? `[${label}] ` : '';
49
+ if (error.all_undefined) {
50
+ console.error(`${prefix}No environment configured.`);
51
+ }
52
+ else {
53
+ console.error(`${prefix}Invalid environment configuration:`);
54
+ for (const line of error.format_issues()) {
55
+ console.error(`${prefix} ${line}`);
56
+ }
57
+ }
58
+ };
59
+ /**
60
+ * Load and validate env vars against a Zod schema.
61
+ *
62
+ * Reads each key from the schema using `get_env`, then validates.
63
+ * Throws `EnvValidationError` on failure.
64
+ *
65
+ * @param schema - Zod object schema defining expected env vars
66
+ * @param get_env - function to read an env var by key
67
+ * @returns validated env object
68
+ */
69
+ export const load_env = (schema, get_env) => {
70
+ const raw = {};
71
+ for (const key of Object.keys(schema.shape)) {
72
+ raw[key] = get_env(key);
73
+ }
74
+ const result = schema.safeParse(raw);
75
+ if (!result.success) {
76
+ throw new EnvValidationError(raw, result.error);
77
+ }
78
+ return result.data;
79
+ };
@@ -0,0 +1,19 @@
1
+ /**
2
+ * Environment value display formatting with secret masking.
3
+ *
4
+ * Provides utilities for safely displaying env values in logs
5
+ * and startup summaries, masking secrets with a placeholder.
6
+ *
7
+ * @module
8
+ */
9
+ /** Placeholder displayed in place of secret values. */
10
+ export declare const MASKED_VALUE = "***";
11
+ /**
12
+ * Format an env value for display, masking secrets.
13
+ *
14
+ * @param value - the env value to format
15
+ * @param secret - whether the value is secret and should be masked
16
+ * @returns display string — masked placeholder for secrets, string values as-is, non-strings JSON-stringified
17
+ */
18
+ export declare const format_env_display_value: (value: unknown, secret: boolean) => string;
19
+ //# sourceMappingURL=mask.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mask.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/env/mask.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,uDAAuD;AACvD,eAAO,MAAM,YAAY,QAAQ,CAAC;AAElC;;;;;;GAMG;AACH,eAAO,MAAM,wBAAwB,GAAI,OAAO,OAAO,EAAE,QAAQ,OAAO,KAAG,MAK1E,CAAC"}
@@ -0,0 +1,26 @@
1
+ /**
2
+ * Environment value display formatting with secret masking.
3
+ *
4
+ * Provides utilities for safely displaying env values in logs
5
+ * and startup summaries, masking secrets with a placeholder.
6
+ *
7
+ * @module
8
+ */
9
+ /** Placeholder displayed in place of secret values. */
10
+ export const MASKED_VALUE = '***';
11
+ /**
12
+ * Format an env value for display, masking secrets.
13
+ *
14
+ * @param value - the env value to format
15
+ * @param secret - whether the value is secret and should be masked
16
+ * @returns display string — masked placeholder for secrets, string values as-is, non-strings JSON-stringified
17
+ */
18
+ export const format_env_display_value = (value, secret) => {
19
+ if (secret)
20
+ return MASKED_VALUE;
21
+ if (typeof value === 'string')
22
+ return value;
23
+ if (value === undefined)
24
+ return 'undefined';
25
+ return JSON.stringify(value);
26
+ };
@@ -0,0 +1,126 @@
1
+ /**
2
+ * Environment variable `$$VAR$$` resolution suite.
3
+ *
4
+ * Resolves `$$VAR$$` references in strings and object trees,
5
+ * scans configs for references, and validates/formats missing vars.
6
+ *
7
+ * The double-dollar bookending syntax is:
8
+ * - Visually distinct from shell `$VAR` syntax
9
+ * - Unambiguous about variable boundaries
10
+ * - Easy to grep: `grep '\$\$'`
11
+ * - Fails loud if accidentally shell-processed (`$$`=PID in shell)
12
+ *
13
+ * @module
14
+ */
15
+ import type { EnvDeps } from '../runtime/deps.js';
16
+ /**
17
+ * Resolve environment variable references in a string.
18
+ *
19
+ * Uses `$$VAR$$` syntax (bookended double-dollar signs).
20
+ * Only resolves variables that are actually set in the environment.
21
+ * Unset variables are left as-is for clear error messages.
22
+ *
23
+ * @param runtime - runtime with `env_get` capability
24
+ * @param value - string that may contain `$$VAR$$` references
25
+ * @returns string with env vars resolved
26
+ */
27
+ export declare const resolve_env_vars: (runtime: Pick<EnvDeps, "env_get">, value: string) => string;
28
+ /**
29
+ * Check if a string contains unresolved env var references.
30
+ *
31
+ * @param value - string to check
32
+ * @returns `true` if string contains `$$VAR$$` patterns
33
+ */
34
+ export declare const has_env_vars: (value: string) => boolean;
35
+ /**
36
+ * Get list of env var names referenced in a string.
37
+ *
38
+ * @param value - string to scan
39
+ * @returns array of variable names (without `$$` delimiters)
40
+ */
41
+ export declare const get_env_var_names: (value: string) => Array<string>;
42
+ /**
43
+ * Resolve env vars in an object's string values (shallow).
44
+ *
45
+ * @param runtime - runtime with `env_get` capability
46
+ * @param obj - object with string values
47
+ * @returns new object with env vars resolved
48
+ */
49
+ export declare const resolve_env_vars_in_object: <T extends Record<string, unknown>>(runtime: Pick<EnvDeps, "env_get">, obj: T) => T;
50
+ /**
51
+ * Resolve env vars and throw if any are missing/empty.
52
+ *
53
+ * Use this for values that must be present.
54
+ *
55
+ * @param runtime - runtime with `env_get` capability
56
+ * @param value - string with `$$VAR$$` references
57
+ * @param context - description for error message (e.g., `"target.host"`)
58
+ * @returns resolved string
59
+ * @throws error if any referenced env var is missing or empty
60
+ */
61
+ export declare const resolve_env_vars_required: (runtime: Pick<EnvDeps, "env_get">, value: string, context: string) => string;
62
+ /**
63
+ * An env var reference found in a config.
64
+ */
65
+ export interface EnvVarRef {
66
+ /** Variable name (without `$$` delimiters). */
67
+ name: string;
68
+ /** Path where the reference was found (e.g., `"target.host"`, `"resources[3].path"`). */
69
+ path: string;
70
+ }
71
+ /**
72
+ * Recursively scan an object for `$$VAR$$` env var references.
73
+ *
74
+ * Walks all string values in the object tree and extracts env var names
75
+ * with their path context for error reporting.
76
+ *
77
+ * @param obj - object to scan (typically a config)
78
+ * @returns array of env var references with paths
79
+ */
80
+ export declare const scan_env_vars: (obj: unknown) => Array<EnvVarRef>;
81
+ /**
82
+ * Result of env var validation.
83
+ *
84
+ * Uses discriminated union for better type narrowing:
85
+ * - `ok: true, missing: null` — all vars present
86
+ * - `ok: false, missing: EnvVarRef[]` — some vars missing
87
+ */
88
+ export type EnvValidationResult = {
89
+ ok: true;
90
+ missing: null;
91
+ } | {
92
+ ok: false;
93
+ missing: Array<EnvVarRef>;
94
+ };
95
+ /**
96
+ * Validate that all referenced env vars exist in the environment.
97
+ *
98
+ * Returns all missing refs (including duplicates by name). Grouping
99
+ * and deduplication is handled by `format_missing_env_vars` at display time.
100
+ *
101
+ * @param runtime - runtime with `env_get` capability
102
+ * @param refs - env var references from `scan_env_vars`
103
+ * @returns validation result with any missing vars
104
+ */
105
+ export declare const validate_env_vars: (runtime: Pick<EnvDeps, "env_get">, refs: Array<EnvVarRef>) => EnvValidationResult;
106
+ /**
107
+ * Options for `format_missing_env_vars`.
108
+ */
109
+ export interface FormatMissingEnvVarsOptions {
110
+ /** Path to env file if one was loaded. */
111
+ env_file?: string;
112
+ /** Hint text for how to set up the environment. */
113
+ setup_hint?: string;
114
+ }
115
+ /**
116
+ * Format missing env vars error message.
117
+ *
118
+ * Groups refs by variable name so each missing var is shown once
119
+ * with all paths where it's referenced.
120
+ *
121
+ * @param missing - missing env var references (may contain duplicate names)
122
+ * @param options - formatting options
123
+ * @returns formatted error message for display
124
+ */
125
+ export declare const format_missing_env_vars: (missing: Array<EnvVarRef>, options?: FormatMissingEnvVarsOptions) => string;
126
+ //# sourceMappingURL=resolve.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"resolve.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/env/resolve.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,KAAK,EAAC,OAAO,EAAC,MAAM,oBAAoB,CAAC;AAOhD;;;;;;;;;;GAUG;AACH,eAAO,MAAM,gBAAgB,GAAI,SAAS,IAAI,CAAC,OAAO,EAAE,SAAS,CAAC,EAAE,OAAO,MAAM,KAAG,MAMnF,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,YAAY,GAAI,OAAO,MAAM,KAAG,OAG5C,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,iBAAiB,GAAI,OAAO,MAAM,KAAG,KAAK,CAAC,MAAM,CAS7D,CAAC;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,0BAA0B,GAAI,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC3E,SAAS,IAAI,CAAC,OAAO,EAAE,SAAS,CAAC,EACjC,KAAK,CAAC,KACJ,CAQF,CAAC;AAEF;;;;;;;;;;GAUG;AACH,eAAO,MAAM,yBAAyB,GACrC,SAAS,IAAI,CAAC,OAAO,EAAE,SAAS,CAAC,EACjC,OAAO,MAAM,EACb,SAAS,MAAM,KACb,MAmBF,CAAC;AAEF;;GAEG;AACH,MAAM,WAAW,SAAS;IACzB,+CAA+C;IAC/C,IAAI,EAAE,MAAM,CAAC;IACb,yFAAyF;IACzF,IAAI,EAAE,MAAM,CAAC;CACb;AAED;;;;;;;;GAQG;AACH,eAAO,MAAM,aAAa,GAAI,KAAK,OAAO,KAAG,KAAK,CAAC,SAAS,CAI3D,CAAC;AAwBF;;;;;;GAMG;AACH,MAAM,MAAM,mBAAmB,GAC5B;IAAC,EAAE,EAAE,IAAI,CAAC;IAAC,OAAO,EAAE,IAAI,CAAA;CAAC,GACzB;IAAC,EAAE,EAAE,KAAK,CAAC;IAAC,OAAO,EAAE,KAAK,CAAC,SAAS,CAAC,CAAA;CAAC,CAAC;AAE1C;;;;;;;;;GASG;AACH,eAAO,MAAM,iBAAiB,GAC7B,SAAS,IAAI,CAAC,OAAO,EAAE,SAAS,CAAC,EACjC,MAAM,KAAK,CAAC,SAAS,CAAC,KACpB,mBAWF,CAAC;AAEF;;GAEG;AACH,MAAM,WAAW,2BAA2B;IAC3C,0CAA0C;IAC1C,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,mDAAmD;IACnD,UAAU,CAAC,EAAE,MAAM,CAAC;CACpB;AAED;;;;;;;;;GASG;AACH,eAAO,MAAM,uBAAuB,GACnC,SAAS,KAAK,CAAC,SAAS,CAAC,EACzB,UAAU,2BAA2B,KACnC,MA+BF,CAAC"}