@fuzdev/fuz_app 0.181.0 → 0.183.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 (267) hide show
  1. package/README.md +2 -0
  2. package/dist/actions/CLAUDE.md +28 -10
  3. package/dist/actions/action_rpc.d.ts +11 -1
  4. package/dist/actions/action_rpc.d.ts.map +1 -1
  5. package/dist/actions/action_rpc.js +3 -2
  6. package/dist/actions/action_types.d.ts +16 -1
  7. package/dist/actions/action_types.d.ts.map +1 -1
  8. package/dist/actions/action_types.js +1 -1
  9. package/dist/actions/notification_sender.d.ts +83 -0
  10. package/dist/actions/notification_sender.d.ts.map +1 -0
  11. package/dist/actions/notification_sender.js +85 -0
  12. package/dist/actions/perform_action.d.ts +9 -0
  13. package/dist/actions/perform_action.d.ts.map +1 -1
  14. package/dist/actions/perform_action.js +22 -13
  15. package/dist/actions/register_action_ws.d.ts +14 -0
  16. package/dist/actions/register_action_ws.d.ts.map +1 -1
  17. package/dist/actions/register_action_ws.js +3 -2
  18. package/dist/actions/ws_socket_session.d.ts +3 -0
  19. package/dist/actions/ws_socket_session.d.ts.map +1 -1
  20. package/dist/actions/ws_socket_session.js +2 -1
  21. package/dist/auth/CLAUDE.md +113 -70
  22. package/dist/auth/account_actions.d.ts.map +1 -1
  23. package/dist/auth/account_actions.js +13 -3
  24. package/dist/auth/account_queries.d.ts +158 -16
  25. package/dist/auth/account_queries.d.ts.map +1 -1
  26. package/dist/auth/account_queries.js +189 -18
  27. package/dist/auth/account_routes.d.ts +6 -4
  28. package/dist/auth/account_routes.d.ts.map +1 -1
  29. package/dist/auth/account_routes.js +98 -92
  30. package/dist/auth/admin_actions.d.ts.map +1 -1
  31. package/dist/auth/admin_actions.js +93 -45
  32. package/dist/auth/api_token_queries.d.ts +13 -5
  33. package/dist/auth/api_token_queries.d.ts.map +1 -1
  34. package/dist/auth/api_token_queries.js +24 -9
  35. package/dist/auth/audit_emitter.d.ts +75 -84
  36. package/dist/auth/audit_emitter.d.ts.map +1 -1
  37. package/dist/auth/audit_emitter.js +83 -71
  38. package/dist/auth/audit_log_schema.d.ts +10 -5
  39. package/dist/auth/audit_log_schema.d.ts.map +1 -1
  40. package/dist/auth/audit_log_schema.js +22 -6
  41. package/dist/auth/bearer_auth.d.ts.map +1 -1
  42. package/dist/auth/bearer_auth.js +3 -2
  43. package/dist/auth/bootstrap_account.d.ts +31 -13
  44. package/dist/auth/bootstrap_account.d.ts.map +1 -1
  45. package/dist/auth/bootstrap_account.js +34 -15
  46. package/dist/auth/bootstrap_routes.d.ts +1 -1
  47. package/dist/auth/bootstrap_routes.d.ts.map +1 -1
  48. package/dist/auth/bootstrap_routes.js +7 -14
  49. package/dist/auth/daemon_token_middleware.d.ts.map +1 -1
  50. package/dist/auth/daemon_token_middleware.js +12 -1
  51. package/dist/auth/deps.d.ts +18 -5
  52. package/dist/auth/deps.d.ts.map +1 -1
  53. package/dist/auth/deps.js +3 -2
  54. package/dist/auth/request_context.d.ts +73 -73
  55. package/dist/auth/request_context.d.ts.map +1 -1
  56. package/dist/auth/request_context.js +78 -96
  57. package/dist/auth/resolved_auth.d.ts +16 -11
  58. package/dist/auth/resolved_auth.d.ts.map +1 -1
  59. package/dist/auth/resolved_auth.js +6 -6
  60. package/dist/auth/role_grant_offer_action_specs.d.ts +1 -1
  61. package/dist/auth/role_grant_offer_action_specs.d.ts.map +1 -1
  62. package/dist/auth/role_grant_offer_action_specs.js +2 -1
  63. package/dist/auth/role_grant_offer_actions.d.ts +32 -12
  64. package/dist/auth/role_grant_offer_actions.d.ts.map +1 -1
  65. package/dist/auth/role_grant_offer_actions.js +91 -116
  66. package/dist/auth/role_grant_offer_notifications.d.ts +87 -38
  67. package/dist/auth/role_grant_offer_notifications.d.ts.map +1 -1
  68. package/dist/auth/role_grant_offer_notifications.js +75 -22
  69. package/dist/auth/role_grant_offer_queries.d.ts +155 -18
  70. package/dist/auth/role_grant_offer_queries.d.ts.map +1 -1
  71. package/dist/auth/role_grant_offer_queries.js +262 -73
  72. package/dist/auth/role_grant_offer_schema.js +1 -1
  73. package/dist/auth/role_grant_queries.d.ts +43 -52
  74. package/dist/auth/role_grant_queries.d.ts.map +1 -1
  75. package/dist/auth/role_grant_queries.js +50 -74
  76. package/dist/auth/role_grant_sql.d.ts +21 -0
  77. package/dist/auth/role_grant_sql.d.ts.map +1 -1
  78. package/dist/auth/role_grant_sql.js +21 -0
  79. package/dist/auth/self_service_role_actions.d.ts.map +1 -1
  80. package/dist/auth/self_service_role_actions.js +17 -21
  81. package/dist/auth/session_queries.d.ts +40 -16
  82. package/dist/auth/session_queries.d.ts.map +1 -1
  83. package/dist/auth/session_queries.js +68 -29
  84. package/dist/auth/signup_routes.d.ts.map +1 -1
  85. package/dist/auth/signup_routes.js +90 -38
  86. package/dist/auth/standard_rpc_actions.d.ts +6 -19
  87. package/dist/auth/standard_rpc_actions.d.ts.map +1 -1
  88. package/dist/auth/standard_rpc_actions.js +5 -6
  89. package/dist/auth/token_scope.d.ts +1 -1
  90. package/dist/auth/token_scope.js +1 -1
  91. package/dist/db/sql_columns.d.ts +1 -1
  92. package/dist/db/sql_columns.js +1 -1
  93. package/dist/http/CLAUDE.md +22 -16
  94. package/dist/http/auth_shape.d.ts +1 -1
  95. package/dist/http/db_routes.d.ts +7 -22
  96. package/dist/http/db_routes.d.ts.map +1 -1
  97. package/dist/http/db_routes.js +72 -72
  98. package/dist/http/error_schemas.d.ts +9 -21
  99. package/dist/http/error_schemas.d.ts.map +1 -1
  100. package/dist/http/error_schemas.js +14 -24
  101. package/dist/http/pending_effects.d.ts +42 -4
  102. package/dist/http/pending_effects.d.ts.map +1 -1
  103. package/dist/http/pending_effects.js +34 -4
  104. package/dist/http/route_spec.d.ts +2 -2
  105. package/dist/server/app_backend.d.ts.map +1 -1
  106. package/dist/server/app_backend.js +3 -1
  107. package/dist/server/app_server.d.ts +69 -18
  108. package/dist/server/app_server.d.ts.map +1 -1
  109. package/dist/server/app_server.js +74 -10
  110. package/dist/server/serve_fact_route.d.ts +3 -3
  111. package/dist/server/serve_fact_route.js +12 -12
  112. package/dist/testing/CLAUDE.md +259 -790
  113. package/dist/testing/adversarial_404.d.ts +6 -1
  114. package/dist/testing/adversarial_404.d.ts.map +1 -1
  115. package/dist/testing/adversarial_404.js +38 -17
  116. package/dist/testing/app_server.d.ts +20 -140
  117. package/dist/testing/app_server.d.ts.map +1 -1
  118. package/dist/testing/app_server.js +48 -125
  119. package/dist/testing/audit_drift_guard.d.ts +11 -6
  120. package/dist/testing/audit_drift_guard.d.ts.map +1 -1
  121. package/dist/testing/audit_drift_guard.js +15 -8
  122. package/dist/testing/auth_apps.js +1 -1
  123. package/dist/testing/cross_backend/account_lifecycle.d.ts.map +1 -1
  124. package/dist/testing/cross_backend/account_lifecycle.js +43 -0
  125. package/dist/testing/cross_backend/audit_cross_helpers.d.ts +12 -9
  126. package/dist/testing/cross_backend/audit_cross_helpers.d.ts.map +1 -1
  127. package/dist/testing/cross_backend/audit_cross_helpers.js +13 -14
  128. package/dist/testing/cross_backend/capabilities.d.ts +9 -6
  129. package/dist/testing/cross_backend/capabilities.d.ts.map +1 -1
  130. package/dist/testing/cross_backend/capabilities.js +11 -7
  131. package/dist/testing/cross_backend/capability_mounts.d.ts +103 -0
  132. package/dist/testing/cross_backend/capability_mounts.d.ts.map +1 -0
  133. package/dist/testing/cross_backend/capability_mounts.js +423 -0
  134. package/dist/testing/cross_backend/cell_moderate.js +2 -2
  135. package/dist/testing/cross_backend/cell_relations.d.ts.map +1 -1
  136. package/dist/testing/cross_backend/cell_relations.js +12 -11
  137. package/dist/testing/cross_backend/conformance_principal.d.ts +54 -0
  138. package/dist/testing/cross_backend/conformance_principal.d.ts.map +1 -0
  139. package/dist/testing/cross_backend/conformance_principal.js +283 -0
  140. package/dist/testing/cross_backend/conformance_table.d.ts +2 -50
  141. package/dist/testing/cross_backend/conformance_table.d.ts.map +1 -1
  142. package/dist/testing/cross_backend/conformance_table.js +2 -270
  143. package/dist/testing/cross_backend/credential_deadline.d.ts.map +1 -1
  144. package/dist/testing/cross_backend/credential_deadline.js +2 -0
  145. package/dist/testing/cross_backend/credential_wire.d.ts +1 -1
  146. package/dist/testing/cross_backend/credential_wire.d.ts.map +1 -1
  147. package/dist/testing/cross_backend/db_state_diff.d.ts +72 -0
  148. package/dist/testing/cross_backend/db_state_diff.d.ts.map +1 -0
  149. package/dist/testing/cross_backend/db_state_diff.js +444 -0
  150. package/dist/testing/cross_backend/declared_skips.d.ts +68 -0
  151. package/dist/testing/cross_backend/declared_skips.d.ts.map +1 -0
  152. package/dist/testing/cross_backend/declared_skips.js +132 -0
  153. package/dist/testing/cross_backend/default_spine_surface.d.ts +1 -26
  154. package/dist/testing/cross_backend/default_spine_surface.d.ts.map +1 -1
  155. package/dist/testing/cross_backend/default_spine_surface.js +2 -6
  156. package/dist/testing/cross_backend/differential.d.ts +11 -2
  157. package/dist/testing/cross_backend/differential.d.ts.map +1 -1
  158. package/dist/testing/cross_backend/differential.js +35 -11
  159. package/dist/testing/cross_backend/differential_normalize.d.ts +12 -0
  160. package/dist/testing/cross_backend/differential_normalize.d.ts.map +1 -1
  161. package/dist/testing/cross_backend/differential_normalize.js +16 -0
  162. package/dist/testing/cross_backend/full_spine_mount.d.ts +3 -10
  163. package/dist/testing/cross_backend/full_spine_mount.d.ts.map +1 -1
  164. package/dist/testing/cross_backend/full_spine_mount.js +4 -4
  165. package/dist/testing/cross_backend/in_process_setup.d.ts +22 -12
  166. package/dist/testing/cross_backend/in_process_setup.d.ts.map +1 -1
  167. package/dist/testing/cross_backend/in_process_setup.js +151 -134
  168. package/dist/testing/cross_backend/login_security.d.ts +12 -0
  169. package/dist/testing/cross_backend/login_security.d.ts.map +1 -1
  170. package/dist/testing/cross_backend/login_security.js +21 -4
  171. package/dist/testing/cross_backend/request_target_conformance_wire.d.ts +0 -2
  172. package/dist/testing/cross_backend/request_target_conformance_wire.d.ts.map +1 -1
  173. package/dist/testing/cross_backend/request_target_conformance_wire.js +3 -1
  174. package/dist/testing/cross_backend/revocation_drivers.d.ts +18 -5
  175. package/dist/testing/cross_backend/revocation_drivers.d.ts.map +1 -1
  176. package/dist/testing/cross_backend/revocation_drivers.js +18 -10
  177. package/dist/testing/cross_backend/role_grant_cross_helpers.d.ts +1 -1
  178. package/dist/testing/cross_backend/role_grant_cross_helpers.d.ts.map +1 -1
  179. package/dist/testing/cross_backend/role_grant_offer_lifecycle.d.ts.map +1 -1
  180. package/dist/testing/cross_backend/role_grant_offer_lifecycle.js +33 -1
  181. package/dist/testing/cross_backend/role_grant_offer_notification_ws.d.ts +5 -4
  182. package/dist/testing/cross_backend/role_grant_offer_notification_ws.d.ts.map +1 -1
  183. package/dist/testing/cross_backend/role_grant_offer_notification_ws.js +183 -30
  184. package/dist/testing/cross_backend/role_grant_participation.js +4 -4
  185. package/dist/testing/cross_backend/rpc_adversarial.js +1 -1
  186. package/dist/testing/cross_backend/session_cap.d.ts +2 -2
  187. package/dist/testing/cross_backend/session_cap.d.ts.map +1 -1
  188. package/dist/testing/cross_backend/session_cap.js +48 -16
  189. package/dist/testing/cross_backend/setup.d.ts +31 -1
  190. package/dist/testing/cross_backend/setup.d.ts.map +1 -1
  191. package/dist/testing/cross_backend/setup.js +32 -1
  192. package/dist/testing/cross_backend/spine_suites.d.ts +123 -12
  193. package/dist/testing/cross_backend/spine_suites.d.ts.map +1 -1
  194. package/dist/testing/cross_backend/spine_suites.js +454 -57
  195. package/dist/testing/cross_backend/spine_surface_constants.d.ts +1 -1
  196. package/dist/testing/cross_backend/spine_surface_constants.d.ts.map +1 -1
  197. package/dist/testing/cross_backend/spine_surface_constants.js +1 -0
  198. package/dist/testing/cross_backend/sse_round_trip.d.ts +9 -1
  199. package/dist/testing/cross_backend/sse_round_trip.d.ts.map +1 -1
  200. package/dist/testing/cross_backend/sse_round_trip.js +123 -27
  201. package/dist/testing/cross_backend/testing_backdoor.d.ts.map +1 -1
  202. package/dist/testing/cross_backend/testing_backdoor.js +4 -2
  203. package/dist/testing/cross_backend/testing_reset_actions.d.ts +59 -27
  204. package/dist/testing/cross_backend/testing_reset_actions.d.ts.map +1 -1
  205. package/dist/testing/cross_backend/testing_reset_actions.js +66 -42
  206. package/dist/testing/cross_backend/transport_composition.d.ts +1 -1
  207. package/dist/testing/cross_backend/transport_composition.d.ts.map +1 -1
  208. package/dist/testing/cross_backend/transport_composition.js +7 -3
  209. package/dist/testing/cross_backend/ws_round_trip.d.ts +5 -0
  210. package/dist/testing/cross_backend/ws_round_trip.d.ts.map +1 -1
  211. package/dist/testing/cross_backend/ws_round_trip.js +54 -8
  212. package/dist/testing/data_exposure.d.ts.map +1 -1
  213. package/dist/testing/data_exposure.js +3 -0
  214. package/dist/testing/db.d.ts +0 -32
  215. package/dist/testing/db.d.ts.map +1 -1
  216. package/dist/testing/db.js +0 -86
  217. package/dist/testing/db_entities.d.ts +14 -0
  218. package/dist/testing/db_entities.d.ts.map +1 -1
  219. package/dist/testing/db_entities.js +17 -0
  220. package/dist/testing/db_invariant_queries.d.ts +259 -0
  221. package/dist/testing/db_invariant_queries.d.ts.map +1 -0
  222. package/dist/testing/db_invariant_queries.js +400 -0
  223. package/dist/testing/db_invariants.d.ts +106 -0
  224. package/dist/testing/db_invariants.d.ts.map +1 -0
  225. package/dist/testing/db_invariants.gen.sql.d.ts +11 -0
  226. package/dist/testing/db_invariants.gen.sql.d.ts.map +1 -0
  227. package/dist/testing/db_invariants.gen.sql.js +13 -0
  228. package/dist/testing/db_invariants.js +141 -0
  229. package/dist/testing/db_invariants.sql +152 -0
  230. package/dist/testing/describe_db.d.ts +36 -0
  231. package/dist/testing/describe_db.d.ts.map +1 -0
  232. package/dist/testing/describe_db.js +71 -0
  233. package/dist/testing/integration.d.ts +6 -9
  234. package/dist/testing/integration.d.ts.map +1 -1
  235. package/dist/testing/integration.js +9 -13
  236. package/dist/testing/integration_helpers.d.ts +1 -1
  237. package/dist/testing/integration_helpers.d.ts.map +1 -1
  238. package/dist/testing/middleware.d.ts +1 -1
  239. package/dist/testing/middleware.js +5 -5
  240. package/dist/testing/rate_limiting.d.ts +1 -1
  241. package/dist/testing/rate_limiting.d.ts.map +1 -1
  242. package/dist/testing/rate_limiting.js +3 -2
  243. package/dist/testing/resolved_auth.d.ts +3 -1
  244. package/dist/testing/resolved_auth.d.ts.map +1 -1
  245. package/dist/testing/resolved_auth.js +4 -4
  246. package/dist/testing/role_grant_helpers.d.ts +1 -1
  247. package/dist/testing/role_grant_helpers.d.ts.map +1 -1
  248. package/dist/testing/round_trip.d.ts.map +1 -1
  249. package/dist/testing/round_trip.js +3 -0
  250. package/dist/testing/rpc_attack_surface.d.ts +8 -6
  251. package/dist/testing/rpc_attack_surface.d.ts.map +1 -1
  252. package/dist/testing/rpc_attack_surface.js +69 -6
  253. package/dist/testing/rpc_round_trip.d.ts +1 -1
  254. package/dist/testing/rpc_round_trip.d.ts.map +1 -1
  255. package/dist/testing/rpc_round_trip.js +3 -0
  256. package/dist/testing/sse_round_trip.d.ts +1 -1
  257. package/dist/testing/sse_round_trip.d.ts.map +1 -1
  258. package/dist/testing/sse_round_trip.js +13 -4
  259. package/dist/testing/stubs.d.ts +4 -2
  260. package/dist/testing/stubs.d.ts.map +1 -1
  261. package/dist/testing/stubs.js +15 -7
  262. package/dist/testing/test_app.d.ts +166 -0
  263. package/dist/testing/test_app.d.ts.map +1 -0
  264. package/dist/testing/test_app.js +124 -0
  265. package/dist/testing/ws_round_trip.d.ts.map +1 -1
  266. package/dist/testing/ws_round_trip.js +8 -4
  267. package/package.json +1 -1
@@ -0,0 +1,166 @@
1
+ import './assert_dev_env.js';
2
+ /**
3
+ * Fully assembled Hono test app for integration tests.
4
+ *
5
+ * `create_test_app` combines `create_test_app_server` (`testing/app_server.ts`,
6
+ * the vitest-free backend primitives) with `create_app_server`, and hands back
7
+ * the app, the backend, the surface, and request header builders. Built inside
8
+ * a test, the app's database is held to the auth-schema invariants when the
9
+ * test finishes (`register_db_invariants_check`).
10
+ *
11
+ * @module
12
+ */
13
+ import type { Hono } from 'hono';
14
+ import type { Uuid } from '../primitive_schemas.js';
15
+ import { type AppServer, type AppServerOptions, type BootstrapServerOptions } from '../server/app_server.js';
16
+ import type { AppServerContext } from '../server/app_server_context.js';
17
+ import type { AppSurface, AppSurfaceSpec } from '../http/surface.js';
18
+ import type { RouteSpec } from '../http/route_spec.js';
19
+ import type { RpcEndpointsSuiteOption } from './rpc_helpers.js';
20
+ import { type TestAppServer, type TestAppServerOptions } from './app_server.js';
21
+ import type { DbInvariantExclusions } from './db_invariant_queries.js';
22
+ /**
23
+ * Configuration for `create_test_app`.
24
+ */
25
+ export interface CreateTestAppOptions extends TestAppServerOptions {
26
+ /** Route spec factory — called with the assembled `AppServerContext`. */
27
+ create_route_specs: (context: AppServerContext) => Array<RouteSpec>;
28
+ /**
29
+ * RPC endpoints mounted by `create_app_server` — eager array or
30
+ * `(ctx: AppServerContext) => Array<RpcEndpointSpec>` factory. Single
31
+ * source of truth; the equivalent slot under `app_options` is `Omit`'d
32
+ * so setup-time path lookup and runtime dispatch read from one place.
33
+ * Symmetric with the suite-level `rpc_endpoints` option on
34
+ * `describe_standard_admin_integration_tests` etc.
35
+ */
36
+ rpc_endpoints?: RpcEndpointsSuiteOption;
37
+ /**
38
+ * Bootstrap config — symmetric with `AppServerOptions.bootstrap`. Same
39
+ * single-source-of-truth precedent as `rpc_endpoints`: setup-time surface
40
+ * generation and runtime dispatch both read this slot, so the equivalent
41
+ * field under `app_options` is `Omit`'d. Discriminated union over
42
+ * `{mode: 'disabled' | 'surface_only' | 'live'}`. Omit (or pass
43
+ * `{mode: 'disabled'}`) for the default — no bootstrap route mounted.
44
+ */
45
+ bootstrap?: BootstrapServerOptions;
46
+ /**
47
+ * Optional overrides for `AppServerOptions`. Excludes fields
48
+ * `create_test_app` manages directly: `backend`, `session_options`,
49
+ * `create_route_specs`, `rpc_endpoints`, `bootstrap` (top-level slots
50
+ * above).
51
+ */
52
+ app_options?: SuiteAppOptions;
53
+ /**
54
+ * Database invariants left unchecked on this app's database, each with the
55
+ * reason the test's state is deliberate — rows written by hand without the
56
+ * cascade production runs. Every other invariant is checked when the test
57
+ * that built the app finishes, and by `TestApp.assert_db_invariants`.
58
+ * Never exclude a state a production path produces: that is a bug.
59
+ * Validated on every call; logged once per distinct set.
60
+ */
61
+ exclude_db_invariants?: DbInvariantExclusions;
62
+ }
63
+ /**
64
+ * `app_options` shape accepted by `create_test_app` and the DB-backed suite
65
+ * helpers. Excludes fields the helpers manage directly — `backend` /
66
+ * `session_options` / `create_route_specs` are constructed by the helper
67
+ * itself; `rpc_endpoints` and `bootstrap` live on top-level options so
68
+ * setup-time surface lookup and runtime dispatch read from one source of
69
+ * truth.
70
+ */
71
+ export type SuiteAppOptions = Partial<Omit<AppServerOptions, 'backend' | 'session_options' | 'create_route_specs' | 'rpc_endpoints' | 'bootstrap'>>;
72
+ /**
73
+ * A bootstrapped test account with credentials.
74
+ */
75
+ export interface TestAccount {
76
+ account: {
77
+ id: Uuid;
78
+ username: string;
79
+ };
80
+ actor: {
81
+ id: Uuid;
82
+ };
83
+ /** Signed session cookie value. */
84
+ session_cookie: string;
85
+ /** Raw API token for Bearer auth. */
86
+ api_token: string;
87
+ /** Build request headers with this account's session cookie. */
88
+ create_session_headers: (extra?: Record<string, string>) => Record<string, string>;
89
+ /** Build request headers with this account's Bearer token. */
90
+ create_bearer_headers: (extra?: Record<string, string>) => Record<string, string>;
91
+ }
92
+ /**
93
+ * Args for `TestApp.create_account` — mint an additional account alongside the
94
+ * keeper. Mirrors the cross-process `CreateTestAccountOptions` (the two
95
+ * `create_account` paths share a shape so fixture call sites read identically),
96
+ * kept local to avoid a cross-module cycle with `cross_backend/setup.ts`.
97
+ */
98
+ export interface CreateTestAppAccountArgs {
99
+ username?: string;
100
+ password_value?: string;
101
+ roles?: Array<string>;
102
+ /** Optional email stored on the account row — exercises the username-or-email login lookup. */
103
+ email?: string;
104
+ }
105
+ /**
106
+ * A fully assembled test app — Hono app + backend + helpers.
107
+ */
108
+ export interface TestApp {
109
+ app: Hono;
110
+ backend: TestAppServer;
111
+ /**
112
+ * The assembled `AppServer` — reach for what `create_app_server` built
113
+ * beyond the fields lifted onto `TestApp`: `audit_sse` (with
114
+ * `audit_log_sse` in `app_options`), the `ws_endpoints` transports,
115
+ * `bootstrap_status`, `migration_results`.
116
+ */
117
+ server: AppServer;
118
+ surface_spec: AppSurfaceSpec;
119
+ surface: AppSurface;
120
+ route_specs: Array<RouteSpec>;
121
+ /** Build request headers with the bootstrapped session cookie. */
122
+ create_session_headers: (extra?: Record<string, string>) => Record<string, string>;
123
+ /** Build request headers with the bootstrapped Bearer token. */
124
+ create_bearer_headers: (extra?: Record<string, string>) => Record<string, string>;
125
+ /** Build request headers with the daemon token (keeper auth). */
126
+ create_daemon_token_headers: (extra?: Record<string, string>) => Record<string, string>;
127
+ /** Create an additional account with credentials. */
128
+ create_account: (options?: CreateTestAppAccountArgs) => Promise<TestAccount>;
129
+ /**
130
+ * Check the app's database against the auth-schema invariants now, less
131
+ * `exclude_db_invariants` — what runs when the test that built the app
132
+ * finishes, and what `check_db_invariants_after_all` and
133
+ * `check_db_invariants_after_suite` call for an app built in `beforeAll`.
134
+ *
135
+ * @throws Error listing every broken invariant and its rows
136
+ */
137
+ assert_db_invariants: () => Promise<void>;
138
+ /** Cleanup resources — `AppServer.close`: stops an opted-in auth cleanup schedule, closes live connections, disposes the limiters the server built and removes the audit listeners and closer members it added, then the backend's `close`. Idempotent. */
139
+ cleanup: () => Promise<void>;
140
+ }
141
+ /**
142
+ * Create a fully assembled test app with a Hono server, middleware, and routes.
143
+ *
144
+ * Combines `create_test_app_server` + `create_app_server` into a single call.
145
+ * Disables every rate limiter (`rate_limiters: 'disabled_for_testing'`) and
146
+ * logging by default (test-friendly). A limiter passed through `app_options`
147
+ * wins over the mode, so a rate-limit test enables just the one it pins.
148
+ *
149
+ * A fresh Hono app is created each call — middleware closures bind to the
150
+ * server's deps (db, keyring), so reuse across servers is unsafe.
151
+ * The expensive resource (the WASM database) is cached separately in `testing/db.ts`.
152
+ *
153
+ * Built inside a running test, it registers the database invariant check
154
+ * (`register_db_invariants_check`) to run when the test finishes; built in
155
+ * `beforeAll`, nothing is registered, and the suite calls
156
+ * `check_db_invariants_after_all(() => test_app)`, or, when the describe
157
+ * closes the app in its own `afterAll`, `check_db_invariants_after_suite(suite,
158
+ * test_app)` inside that hook ahead of the close.
159
+ *
160
+ * @param options - test app configuration
161
+ * @returns a `TestApp` ready for HTTP testing
162
+ * @throws Error on an `exclude_db_invariants` entry naming no invariant or
163
+ * carrying no reason
164
+ */
165
+ export declare const create_test_app: (options: CreateTestAppOptions) => Promise<TestApp>;
166
+ //# sourceMappingURL=test_app.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"test_app.d.ts","sourceRoot":"","sources":["../../src/lib/testing/test_app.ts"],"names":[],"mappings":"AAAA,OAAO,qBAAqB,CAAC;AAE7B;;;;;;;;;;GAUG;AAEH,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AACjC,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,yBAAyB,CAAC;AAEpD,OAAO,EAEN,KAAK,SAAS,EACd,KAAK,gBAAgB,EACrB,KAAK,sBAAsB,EAC3B,MAAM,yBAAyB,CAAC;AACjC,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,iCAAiC,CAAC;AACxE,OAAO,KAAK,EAAE,UAAU,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AACrE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAMvD,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,kBAAkB,CAAC;AAEhE,OAAO,EAKN,KAAK,aAAa,EAClB,KAAK,oBAAoB,EACzB,MAAM,iBAAiB,CAAC;AAMzB,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,2BAA2B,CAAC;AAEvE;;GAEG;AACH,MAAM,WAAW,oBAAqB,SAAQ,oBAA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;IACtB,+FAA+F;IAC/F,KAAK,CAAC,EAAE,MAAM,CAAC;CACf;AAED;;GAEG;AACH,MAAM,WAAW,OAAO;IACvB,GAAG,EAAE,IAAI,CAAC;IACV,OAAO,EAAE,aAAa,CAAC;IACvB;;;;;OAKG;IACH,MAAM,EAAE,SAAS,CAAC;IAClB,YAAY,EAAE,cAAc,CAAC;IAC7B,OAAO,EAAE,UAAU,CAAC;IACpB,WAAW,EAAE,KAAK,CAAC,SAAS,CAAC,CAAC;IAC9B,kEAAkE;IAClE,sBAAsB,EAAE,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,KAAK,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACnF,gEAAgE;IAChE,qBAAqB,EAAE,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,KAAK,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAClF,iEAAiE;IACjE,2BAA2B,EAAE,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,KAAK,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACxF,qDAAqD;IACrD,cAAc,EAAE,CAAC,OAAO,CAAC,EAAE,wBAAwB,KAAK,OAAO,CAAC,WAAW,CAAC,CAAC;IAC7E;;;;;;;OAOG;IACH,oBAAoB,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;IAC1C,2PAA2P;IAC3P,OAAO,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;CAC7B;AAgCD;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,eAAO,MAAM,eAAe,GAAU,SAAS,oBAAoB,KAAG,OAAO,CAAC,OAAO,CA4FpF,CAAC"}
@@ -0,0 +1,124 @@
1
+ import './assert_dev_env.js';
2
+ import { DEFAULT_TEST_PASSWORD } from './test_credentials.js';
3
+ import { create_app_server } from '../server/app_server.js';
4
+ import { generate_daemon_token, DAEMON_TOKEN_HEADER } from '../auth/daemon_token.js';
5
+ import { create_test_request_headers } from './test_origin.js';
6
+ import { create_loopback_app_server_options, create_test_account_with_credentials, create_test_app_server, stub_password_deps } from './app_server.js';
7
+ import { announce_db_invariant_exclusions, assert_db_invariants, register_db_invariants_check } from './db_invariants.js';
8
+ /**
9
+ * The `create_app_server` options both test-app builders share — a fresh
10
+ * object per call, spread ahead of the per-builder options and `app_options`.
11
+ */
12
+ const test_app_options = () => ({
13
+ ...create_loopback_app_server_options(),
14
+ // every limiter off unless `app_options` passes one — a rate-limit test
15
+ // enables just the limiter it pins
16
+ rate_limiters: 'disabled_for_testing',
17
+ await_pending_effects: true
18
+ });
19
+ /** Build request headers carrying `session_cookie` in the `cookie_name` cookie. */
20
+ const create_session_headers_builder = (cookie_name, session_cookie) => (extra) => create_test_request_headers({ cookie: `${cookie_name}=${session_cookie}`, ...extra });
21
+ /** Build request headers carrying `api_token` as a Bearer token. */
22
+ const create_bearer_headers_builder = (api_token) => (extra) => ({
23
+ host: 'localhost',
24
+ authorization: `Bearer ${api_token}`,
25
+ ...extra
26
+ });
27
+ /**
28
+ * Create a fully assembled test app with a Hono server, middleware, and routes.
29
+ *
30
+ * Combines `create_test_app_server` + `create_app_server` into a single call.
31
+ * Disables every rate limiter (`rate_limiters: 'disabled_for_testing'`) and
32
+ * logging by default (test-friendly). A limiter passed through `app_options`
33
+ * wins over the mode, so a rate-limit test enables just the one it pins.
34
+ *
35
+ * A fresh Hono app is created each call — middleware closures bind to the
36
+ * server's deps (db, keyring), so reuse across servers is unsafe.
37
+ * The expensive resource (the WASM database) is cached separately in `testing/db.ts`.
38
+ *
39
+ * Built inside a running test, it registers the database invariant check
40
+ * (`register_db_invariants_check`) to run when the test finishes; built in
41
+ * `beforeAll`, nothing is registered, and the suite calls
42
+ * `check_db_invariants_after_all(() => test_app)`, or, when the describe
43
+ * closes the app in its own `afterAll`, `check_db_invariants_after_suite(suite,
44
+ * test_app)` inside that hook ahead of the close.
45
+ *
46
+ * @param options - test app configuration
47
+ * @returns a `TestApp` ready for HTTP testing
48
+ * @throws Error on an `exclude_db_invariants` entry naming no invariant or
49
+ * carrying no reason
50
+ */
51
+ export const create_test_app = async (options) => {
52
+ const { exclude_db_invariants } = options;
53
+ announce_db_invariant_exclusions(exclude_db_invariants, 'create_test_app');
54
+ const test_server = await create_test_app_server(options);
55
+ // Daemon token state for keeper auth in tests.
56
+ // Uses a static token (no rotation) — sufficient for request-level testing.
57
+ const test_daemon_token = generate_daemon_token();
58
+ const daemon_token_state = {
59
+ current_token: test_daemon_token,
60
+ previous_token: null,
61
+ rotated_at: new Date(),
62
+ keeper_account_id: test_server.account.id
63
+ };
64
+ const result = await create_app_server({
65
+ ...test_app_options(),
66
+ backend: test_server,
67
+ session_options: options.session_options,
68
+ daemon_token_state,
69
+ rpc_endpoints: options.rpc_endpoints,
70
+ bootstrap: options.bootstrap,
71
+ // `auth_cleanup` stays at its default, off: a background pass would
72
+ // delete rows and write audit rows mid-test. A suite that opts in
73
+ // through `app_options` has the schedule stopped by `cleanup`.
74
+ ...options.app_options,
75
+ create_route_specs: options.create_route_specs
76
+ });
77
+ const { app, surface_spec } = result;
78
+ const { cookie_name } = options.session_options;
79
+ const { password = stub_password_deps } = options;
80
+ const create_session_headers = create_session_headers_builder(cookie_name, test_server.session_cookie);
81
+ const create_bearer_headers = create_bearer_headers_builder(test_server.api_token);
82
+ const create_daemon_token_headers = (extra) => ({
83
+ host: 'localhost',
84
+ [DAEMON_TOKEN_HEADER]: test_daemon_token,
85
+ ...extra
86
+ });
87
+ let account_counter = 0;
88
+ const create_account = async (account_options) => {
89
+ account_counter++;
90
+ const bootstrapped = await create_test_account_with_credentials({
91
+ db: test_server.deps.db,
92
+ keyring: test_server.keyring,
93
+ session_options: options.session_options,
94
+ password,
95
+ username: account_options?.username ?? `test_user_${account_counter}`,
96
+ password_value: account_options?.password_value ?? DEFAULT_TEST_PASSWORD,
97
+ roles: account_options?.roles ?? [],
98
+ ...(account_options?.email !== undefined && { email: account_options.email })
99
+ });
100
+ return {
101
+ ...bootstrapped,
102
+ create_session_headers: create_session_headers_builder(cookie_name, bootstrapped.session_cookie),
103
+ create_bearer_headers: create_bearer_headers_builder(bootstrapped.api_token)
104
+ };
105
+ };
106
+ const check_db_invariants = () => assert_db_invariants({ db: test_server.deps.db }, 'in-process', exclude_db_invariants);
107
+ register_db_invariants_check(check_db_invariants);
108
+ return {
109
+ app,
110
+ backend: test_server,
111
+ server: result,
112
+ surface_spec,
113
+ surface: surface_spec.surface,
114
+ route_specs: surface_spec.route_specs,
115
+ create_session_headers,
116
+ create_bearer_headers,
117
+ create_daemon_token_headers,
118
+ create_account,
119
+ assert_db_invariants: check_db_invariants,
120
+ // the server's `close`, not the backend's: it also stops an auth cleanup
121
+ // schedule a suite opted into
122
+ cleanup: () => result.close()
123
+ };
124
+ };
@@ -1 +1 @@
1
- {"version":3,"file":"ws_round_trip.d.ts","sourceRoot":"","sources":["../../src/lib/testing/ws_round_trip.ts"],"names":[],"mappings":"AAAA,OAAO,qBAAqB,CAAC;AAE7B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoCG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAQ,MAAM,MAAM,CAAC;AAC1C,OAAO,EACN,SAAS,EAET,KAAK,gBAAgB,EAErB,KAAK,QAAQ,EACb,MAAM,SAAS,CAAC;AACjB,OAAO,EAAE,MAAM,EAAE,MAAM,yBAAyB,CAAC;AACjD,OAAO,EAAe,KAAK,IAAI,EAAE,MAAM,yBAAyB,CAAC;AAEjE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAC;AACjE,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,4BAA4B,CAAC;AACzD,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,kCAAkC,CAAC;AAC/E,OAAO,EAAsB,KAAK,uBAAuB,EAAE,MAAM,kCAAkC,CAAC;AAEpG,OAAO,E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ST_CONTEXT_KEY]: request_context,
67
67
  [RESOLVED_AUTH_KEY]: create_test_resolved_auth({
68
68
  credential_type: opts.credential_type,
69
- account_id: request_context.account.id,
69
+ account: request_context.account,
70
70
  session_id: auth_session_id ?? undefined,
71
71
  api_token_id: opts.api_token_id
72
72
  }),
@@ -241,7 +241,10 @@ export const create_ws_test_harness = (options) => {
241
241
  // the harness drives per-message dispatch, not throttling — the
242
242
  // assembled-app tests cover the limiters `create_app_server` threads
243
243
  action_ip_rate_limiter: null,
244
- action_account_rate_limiter: null
244
+ action_account_rate_limiter: null,
245
+ // the harness's one registry is every socket a handler's notification
246
+ // can reach
247
+ notification_sender: registry
245
248
  });
246
249
  const events_factory = stub.get_create_events();
247
250
  const connect = async (identity = {}) => {
@@ -249,13 +252,14 @@ export const create_ws_test_harness = (options) => {
249
252
  const credential_type = identity.credential_type ?? 'session';
250
253
  const session_id = identity.session_id ?? create_uuid();
251
254
  const roles = identity.roles ?? [];
255
+ const request_context = build_multi_role_request_context(account_id, roles);
252
256
  const ctx_store = new Map([
253
- [REQUEST_CONTEXT_KEY, build_multi_role_request_context(account_id, roles)],
257
+ [REQUEST_CONTEXT_KEY, request_context],
254
258
  [
255
259
  RESOLVED_AUTH_KEY,
256
260
  create_test_resolved_auth({
257
261
  credential_type,
258
- account_id,
262
+ account: request_context.account,
259
263
  session_id,
260
264
  api_token_id: identity.api_token_id
261
265
  })
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fuzdev/fuz_app",
3
- "version": "0.181.0",
3
+ "version": "0.183.0",
4
4
  "description": "fullstack app library",
5
5
  "glyph": "🗝",
6
6
  "logo": "logo.svg",