@fuzdev/fuz_app 0.184.0 → 0.186.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 (174) hide show
  1. package/dist/actions/CLAUDE.md +18 -3
  2. package/dist/actions/perform_action.d.ts.map +1 -1
  3. package/dist/actions/perform_action.js +36 -5
  4. package/dist/actions/register_action_ws.d.ts +14 -7
  5. package/dist/actions/register_action_ws.d.ts.map +1 -1
  6. package/dist/actions/ws_socket_session.d.ts +17 -4
  7. package/dist/actions/ws_socket_session.d.ts.map +1 -1
  8. package/dist/actions/ws_socket_session.js +41 -7
  9. package/dist/auth/CLAUDE.md +18 -9
  10. package/dist/auth/account_queries.d.ts +53 -40
  11. package/dist/auth/account_queries.d.ts.map +1 -1
  12. package/dist/auth/account_queries.js +57 -50
  13. package/dist/auth/account_routes.d.ts.map +1 -1
  14. package/dist/auth/account_routes.js +59 -25
  15. package/dist/auth/admin_actions.d.ts.map +1 -1
  16. package/dist/auth/admin_actions.js +26 -9
  17. package/dist/auth/audit_emitter.js +2 -2
  18. package/dist/auth/audit_log_queries.d.ts +11 -3
  19. package/dist/auth/audit_log_queries.d.ts.map +1 -1
  20. package/dist/auth/audit_log_queries.js +4 -4
  21. package/dist/auth/audit_log_routes.d.ts +1 -1
  22. package/dist/auth/audit_log_routes.d.ts.map +1 -1
  23. package/dist/auth/audit_log_routes.js +3 -2
  24. package/dist/auth/audit_log_schema.js +1 -1
  25. package/dist/auth/auth_ddl.d.ts.map +1 -1
  26. package/dist/auth/auth_ddl.js +4 -0
  27. package/dist/auth/cleanup.d.ts +34 -3
  28. package/dist/auth/cleanup.d.ts.map +1 -1
  29. package/dist/auth/cleanup.js +12 -4
  30. package/dist/auth/migrations.d.ts.map +1 -1
  31. package/dist/auth/migrations.js +35 -0
  32. package/dist/auth/role_grant_offer_queries.d.ts +13 -13
  33. package/dist/auth/role_grant_offer_queries.d.ts.map +1 -1
  34. package/dist/auth/role_grant_offer_queries.js +12 -13
  35. package/dist/auth/role_grant_queries.d.ts +16 -9
  36. package/dist/auth/role_grant_queries.d.ts.map +1 -1
  37. package/dist/auth/role_grant_queries.js +16 -9
  38. package/dist/auth/self_service_role_actions.d.ts.map +1 -1
  39. package/dist/auth/self_service_role_actions.js +15 -0
  40. package/dist/auth/session_queries.d.ts +24 -0
  41. package/dist/auth/session_queries.d.ts.map +1 -1
  42. package/dist/auth/session_queries.js +28 -0
  43. package/dist/db/CLAUDE.md +3 -3
  44. package/dist/db/cell_ddl.d.ts +8 -3
  45. package/dist/db/cell_ddl.d.ts.map +1 -1
  46. package/dist/db/cell_ddl.js +10 -5
  47. package/dist/http/CLAUDE.md +1 -1
  48. package/dist/http/body_limit.d.ts +4 -4
  49. package/dist/http/body_limit.js +4 -4
  50. package/dist/http/pending_effects.d.ts +8 -4
  51. package/dist/http/pending_effects.d.ts.map +1 -1
  52. package/dist/http/route_spec.d.ts +3 -3
  53. package/dist/http/route_spec.d.ts.map +1 -1
  54. package/dist/realtime/audit_log_sse.d.ts +1 -1
  55. package/dist/realtime/sse.d.ts +2 -2
  56. package/dist/realtime/sse.d.ts.map +1 -1
  57. package/dist/realtime/sse_constants.d.ts +1 -1
  58. package/dist/realtime/sse_constants.js +1 -1
  59. package/dist/server/app_server.d.ts +59 -71
  60. package/dist/server/app_server.d.ts.map +1 -1
  61. package/dist/server/app_server.js +52 -60
  62. package/dist/server/shutdown_drain.d.ts +69 -0
  63. package/dist/server/shutdown_drain.d.ts.map +1 -0
  64. package/dist/server/shutdown_drain.js +77 -0
  65. package/dist/testing/CLAUDE.md +197 -66
  66. package/dist/testing/admin_integration.d.ts +2 -2
  67. package/dist/testing/admin_integration.d.ts.map +1 -1
  68. package/dist/testing/admin_integration.js +36 -20
  69. package/dist/testing/app_server.d.ts +5 -7
  70. package/dist/testing/app_server.d.ts.map +1 -1
  71. package/dist/testing/app_server.js +5 -7
  72. package/dist/testing/auth_apps.d.ts +3 -1
  73. package/dist/testing/auth_apps.d.ts.map +1 -1
  74. package/dist/testing/auth_apps.js +22 -5
  75. package/dist/testing/cross_backend/backend_config.d.ts +8 -0
  76. package/dist/testing/cross_backend/backend_config.d.ts.map +1 -1
  77. package/dist/testing/cross_backend/backend_log.d.ts +71 -0
  78. package/dist/testing/cross_backend/backend_log.d.ts.map +1 -0
  79. package/dist/testing/cross_backend/backend_log.js +134 -0
  80. package/dist/testing/cross_backend/backend_swap.d.ts +41 -0
  81. package/dist/testing/cross_backend/backend_swap.d.ts.map +1 -0
  82. package/dist/testing/cross_backend/backend_swap.js +431 -0
  83. package/dist/testing/cross_backend/body_size_smuggling.js +3 -3
  84. package/dist/testing/cross_backend/bootstrap_backend.d.ts +3 -1
  85. package/dist/testing/cross_backend/bootstrap_backend.d.ts.map +1 -1
  86. package/dist/testing/cross_backend/bootstrap_backend.js +9 -5
  87. package/dist/testing/cross_backend/conformance_case.d.ts +11 -6
  88. package/dist/testing/cross_backend/conformance_case.d.ts.map +1 -1
  89. package/dist/testing/cross_backend/conformance_case.js +4 -0
  90. package/dist/testing/cross_backend/conformance_principal.d.ts +2 -2
  91. package/dist/testing/cross_backend/conformance_principal.d.ts.map +1 -1
  92. package/dist/testing/cross_backend/conformance_principal.js +27 -10
  93. package/dist/testing/cross_backend/create_dual_spawn_global_setup.d.ts +10 -1
  94. package/dist/testing/cross_backend/create_dual_spawn_global_setup.d.ts.map +1 -1
  95. package/dist/testing/cross_backend/create_dual_spawn_global_setup.js +33 -7
  96. package/dist/testing/cross_backend/default_backend_configs.d.ts +38 -5
  97. package/dist/testing/cross_backend/default_backend_configs.d.ts.map +1 -1
  98. package/dist/testing/cross_backend/default_backend_configs.js +50 -15
  99. package/dist/testing/cross_backend/in_process_setup.d.ts +1 -1
  100. package/dist/testing/cross_backend/in_process_setup.d.ts.map +1 -1
  101. package/dist/testing/cross_backend/in_process_setup.js +53 -31
  102. package/dist/testing/cross_backend/revocation_drivers.d.ts +14 -2
  103. package/dist/testing/cross_backend/revocation_drivers.d.ts.map +1 -1
  104. package/dist/testing/cross_backend/revocation_drivers.js +36 -8
  105. package/dist/testing/cross_backend/rpc_success_fixtures.d.ts.map +1 -1
  106. package/dist/testing/cross_backend/rpc_success_fixtures.js +2 -1
  107. package/dist/testing/cross_backend/rust_spine_stub_backend_config.d.ts +7 -0
  108. package/dist/testing/cross_backend/rust_spine_stub_backend_config.d.ts.map +1 -1
  109. package/dist/testing/cross_backend/rust_spine_stub_backend_config.js +4 -2
  110. package/dist/testing/cross_backend/setup.d.ts +44 -43
  111. package/dist/testing/cross_backend/setup.d.ts.map +1 -1
  112. package/dist/testing/cross_backend/setup.js +64 -62
  113. package/dist/testing/cross_backend/spawn_backend.d.ts +19 -1
  114. package/dist/testing/cross_backend/spawn_backend.d.ts.map +1 -1
  115. package/dist/testing/cross_backend/spawn_backend.js +138 -11
  116. package/dist/testing/cross_backend/spine_suites.d.ts +17 -14
  117. package/dist/testing/cross_backend/spine_suites.d.ts.map +1 -1
  118. package/dist/testing/cross_backend/spine_suites.js +37 -15
  119. package/dist/testing/cross_backend/sse_round_trip.d.ts.map +1 -1
  120. package/dist/testing/cross_backend/sse_round_trip.js +4 -2
  121. package/dist/testing/cross_backend/standard.d.ts +18 -82
  122. package/dist/testing/cross_backend/standard.d.ts.map +1 -1
  123. package/dist/testing/cross_backend/standard.js +6 -21
  124. package/dist/testing/cross_backend/standard_auth.d.ts +74 -0
  125. package/dist/testing/cross_backend/standard_auth.d.ts.map +1 -0
  126. package/dist/testing/cross_backend/standard_auth.js +28 -0
  127. package/dist/testing/cross_backend/standard_bundle.d.ts +48 -0
  128. package/dist/testing/cross_backend/standard_bundle.d.ts.map +1 -0
  129. package/dist/testing/cross_backend/standard_bundle.js +43 -0
  130. package/dist/testing/cross_backend/testing_reset_actions.d.ts +18 -6
  131. package/dist/testing/cross_backend/testing_reset_actions.d.ts.map +1 -1
  132. package/dist/testing/cross_backend/testing_reset_actions.js +23 -8
  133. package/dist/testing/cross_backend/testing_server_bun.d.ts.map +1 -1
  134. package/dist/testing/cross_backend/testing_server_bun.js +7 -30
  135. package/dist/testing/cross_backend/testing_server_core.d.ts +16 -3
  136. package/dist/testing/cross_backend/testing_server_core.d.ts.map +1 -1
  137. package/dist/testing/cross_backend/testing_server_core.js +20 -4
  138. package/dist/testing/cross_backend/ts_spine_backend_config.d.ts +6 -2
  139. package/dist/testing/cross_backend/ts_spine_backend_config.d.ts.map +1 -1
  140. package/dist/testing/cross_backend/ts_spine_backend_config.js +7 -3
  141. package/dist/testing/cross_backend/ws_round_trip.d.ts.map +1 -1
  142. package/dist/testing/cross_backend/ws_round_trip.js +4 -3
  143. package/dist/testing/data_exposure.d.ts +4 -1
  144. package/dist/testing/data_exposure.d.ts.map +1 -1
  145. package/dist/testing/data_exposure.js +93 -25
  146. package/dist/testing/db_invariants.d.ts +5 -5
  147. package/dist/testing/db_invariants.js +5 -5
  148. package/dist/testing/error_coverage.d.ts +5 -0
  149. package/dist/testing/error_coverage.d.ts.map +1 -1
  150. package/dist/testing/error_coverage.js +2 -1
  151. package/dist/testing/integration.d.ts +4 -20
  152. package/dist/testing/integration.d.ts.map +1 -1
  153. package/dist/testing/integration.js +49 -79
  154. package/dist/testing/integration_helpers.d.ts +16 -0
  155. package/dist/testing/integration_helpers.d.ts.map +1 -1
  156. package/dist/testing/integration_helpers.js +29 -1
  157. package/dist/testing/logged_errors.d.ts +61 -0
  158. package/dist/testing/logged_errors.d.ts.map +1 -0
  159. package/dist/testing/logged_errors.js +285 -0
  160. package/dist/testing/middleware_gate_probes.d.ts +55 -1
  161. package/dist/testing/middleware_gate_probes.d.ts.map +1 -1
  162. package/dist/testing/middleware_gate_probes.js +76 -3
  163. package/dist/testing/rpc_attack_surface.d.ts.map +1 -1
  164. package/dist/testing/rpc_attack_surface.js +41 -16
  165. package/dist/testing/stubs.d.ts +5 -1
  166. package/dist/testing/stubs.d.ts.map +1 -1
  167. package/dist/testing/stubs.js +6 -3
  168. package/dist/testing/test_app.d.ts +39 -9
  169. package/dist/testing/test_app.d.ts.map +1 -1
  170. package/dist/testing/test_app.js +70 -12
  171. package/dist/testing/transports/fetch_transport.d.ts +10 -0
  172. package/dist/testing/transports/fetch_transport.d.ts.map +1 -1
  173. package/dist/testing/transports/fetch_transport.js +13 -0
  174. package/package.json +4 -3
@@ -0,0 +1,69 @@
1
+ /**
2
+ * The bounded wait `AppServer.close` makes for the work still in flight, and
3
+ * the report of what it gave up on.
4
+ *
5
+ * Its own module, free of any server framework, so a process that serves the
6
+ * app (`testing/cross_backend/testing_server_core.ts`) reads the report
7
+ * without loading the server. Twin of the Rust spine's shutdown drain
8
+ * (`fuz_http::serve_with_shutdown` and its `ServeShutdown`).
9
+ *
10
+ * @module
11
+ */
12
+ import type { Logger } from '@fuzdev/fuz_util/log.ts';
13
+ import type { RequestTracker } from '../http/pending_effects.js';
14
+ import type { AuditEmitter } from '../auth/audit_emitter.js';
15
+ /**
16
+ * Default bound on `AppServer.close`'s wait for the effects still in flight
17
+ * (`AppServerOptions.shutdown_drain_timeout_ms`). Twin of the Rust spine's
18
+ * `DEFAULT_DRAIN_TIMEOUT`.
19
+ */
20
+ export declare const DEFAULT_SHUTDOWN_DRAIN_TIMEOUT_MS = 10000;
21
+ /**
22
+ * What `AppServer.close` gave up on at its drain bound
23
+ * (`drain_effects_on_shutdown`), each counted on its own: a request still
24
+ * waiting on its audit writes has those writes counted in `audit_writes` too,
25
+ * so the counts are not summed. Every count `0` is a shutdown that drained
26
+ * everything. Twin of the Rust spine's `fuz_http::ServeShutdown`.
27
+ */
28
+ export interface ShutdownDrainGivenUp {
29
+ /**
30
+ * Requests still held — HTTP requests and WS messages alike, each with its
31
+ * handler or its effect flush still running, and WS upgrades still opening.
32
+ */
33
+ requests: number;
34
+ /** Pool writes of the audit emitter still in flight. */
35
+ audit_writes: number;
36
+ /**
37
+ * Upkeep tasks still running — the auth cleanup pass in progress when
38
+ * `auth_cleanup` scheduled one. Twin of `ServeShutdown`'s
39
+ * `upkeep_given_up`; here the pass is left to finish rather than aborted.
40
+ */
41
+ upkeep: number;
42
+ }
43
+ /**
44
+ * Whether a shutdown gave up on anything — its drain bound ran out before
45
+ * every wait finished. A process reports it as a failed exit. Twin of the
46
+ * Rust `ServeShutdown::gave_up`.
47
+ *
48
+ * @param report - what `AppServer.close` resolved
49
+ */
50
+ export declare const shutdown_gave_up: (report: ShutdownDrainGivenUp) => boolean;
51
+ /**
52
+ * Wait for the upkeep stops (the auth cleanup's pass in progress), then the
53
+ * requests held (HTTP requests, WS messages and WS upgrades still opening,
54
+ * one tracker — each until its handler has returned and its flush settled)
55
+ * and then the audit emitter's pool writes, until none is left or
56
+ * `timeout_ms` passes — then log an error naming what was given up on. One
57
+ * bound for all of it. Never rejects. The Rust shutdown joins its upkeep after
58
+ * the request drain; both wait concurrently against one deadline, so only the
59
+ * wait order differs.
60
+ *
61
+ * @param requests - the request tracker
62
+ * @param audit - the audit emitter
63
+ * @param upkeep - each upkeep task's stop, already requested; one still pending at the bound is counted
64
+ * @param timeout_ms - the bound
65
+ * @param log - where a give-up is logged
66
+ * @returns what was given up on, every count `0` when everything settled
67
+ */
68
+ export declare const drain_effects_on_shutdown: (requests: Pick<RequestTracker, "drain_inflight" | "inflight_count">, audit: Pick<AuditEmitter, "drain_inflight" | "inflight_count">, upkeep: ReadonlyArray<Promise<void>>, timeout_ms: number, log: Logger) => Promise<ShutdownDrainGivenUp>;
69
+ //# sourceMappingURL=shutdown_drain.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"shutdown_drain.d.ts","sourceRoot":"","sources":["../../src/lib/server/shutdown_drain.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,yBAAyB,CAAC;AAEtD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AACjE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AAE7D;;;;GAIG;AACH,eAAO,MAAM,iCAAiC,QAAS,CAAC;AAExD;;;;;;GAMG;AACH,MAAM,WAAW,oBAAoB;IACpC;;;OAGG;IACH,QAAQ,EAAE,MAAM,CAAC;IACjB,wDAAwD;IACxD,YAAY,EAAE,MAAM,CAAC;IACrB;;;;OAIG;IACH,MAAM,EAAE,MAAM,CAAC;CACf;AAED;;;;;;GAMG;AACH,eAAO,MAAM,gBAAgB,GAAI,QAAQ,oBAAoB,KAAG,OACI,CAAC;AAErE;;;;;;;;;;;;;;;;GAgBG;AACH,eAAO,MAAM,yBAAyB,GACrC,UAAU,IAAI,CAAC,cAAc,EAAE,gBAAgB,GAAG,gBAAgB,CAAC,EACnE,OAAO,IAAI,CAAC,YAAY,EAAE,gBAAgB,GAAG,gBAAgB,CAAC,EAC9D,QAAQ,aAAa,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,EACpC,YAAY,MAAM,EAClB,KAAK,MAAM,KACT,OAAO,CAAC,oBAAoB,CAoC9B,CAAC"}
@@ -0,0 +1,77 @@
1
+ /**
2
+ * The bounded wait `AppServer.close` makes for the work still in flight, and
3
+ * the report of what it gave up on.
4
+ *
5
+ * Its own module, free of any server framework, so a process that serves the
6
+ * app (`testing/cross_backend/testing_server_core.ts`) reads the report
7
+ * without loading the server. Twin of the Rust spine's shutdown drain
8
+ * (`fuz_http::serve_with_shutdown` and its `ServeShutdown`).
9
+ *
10
+ * @module
11
+ */
12
+ /**
13
+ * Default bound on `AppServer.close`'s wait for the effects still in flight
14
+ * (`AppServerOptions.shutdown_drain_timeout_ms`). Twin of the Rust spine's
15
+ * `DEFAULT_DRAIN_TIMEOUT`.
16
+ */
17
+ export const DEFAULT_SHUTDOWN_DRAIN_TIMEOUT_MS = 10_000;
18
+ /**
19
+ * Whether a shutdown gave up on anything — its drain bound ran out before
20
+ * every wait finished. A process reports it as a failed exit. Twin of the
21
+ * Rust `ServeShutdown::gave_up`.
22
+ *
23
+ * @param report - what `AppServer.close` resolved
24
+ */
25
+ export const shutdown_gave_up = (report) => report.requests > 0 || report.audit_writes > 0 || report.upkeep > 0;
26
+ /**
27
+ * Wait for the upkeep stops (the auth cleanup's pass in progress), then the
28
+ * requests held (HTTP requests, WS messages and WS upgrades still opening,
29
+ * one tracker — each until its handler has returned and its flush settled)
30
+ * and then the audit emitter's pool writes, until none is left or
31
+ * `timeout_ms` passes — then log an error naming what was given up on. One
32
+ * bound for all of it. Never rejects. The Rust shutdown joins its upkeep after
33
+ * the request drain; both wait concurrently against one deadline, so only the
34
+ * wait order differs.
35
+ *
36
+ * @param requests - the request tracker
37
+ * @param audit - the audit emitter
38
+ * @param upkeep - each upkeep task's stop, already requested; one still pending at the bound is counted
39
+ * @param timeout_ms - the bound
40
+ * @param log - where a give-up is logged
41
+ * @returns what was given up on, every count `0` when everything settled
42
+ */
43
+ export const drain_effects_on_shutdown = async (requests, audit, upkeep, timeout_ms, log) => {
44
+ let upkeep_pending = upkeep.length;
45
+ const drain = async () => {
46
+ // the upkeep first, so a write a pass started is in the loop below
47
+ await Promise.all(upkeep.map(async (stopped) => {
48
+ await stopped;
49
+ upkeep_pending--;
50
+ }));
51
+ // until both are empty: a flush's post-commit thunk can start an audit
52
+ // write, and a request accepted meanwhile is held too
53
+ do {
54
+ await requests.drain_inflight();
55
+ await audit.drain_inflight();
56
+ } while (requests.inflight_count() > 0 || audit.inflight_count() > 0);
57
+ };
58
+ let timer;
59
+ const timed_out = new Promise((resolve) => {
60
+ timer = setTimeout(resolve, timeout_ms);
61
+ });
62
+ try {
63
+ await Promise.race([drain(), timed_out]);
64
+ }
65
+ finally {
66
+ clearTimeout(timer);
67
+ }
68
+ const given_up = {
69
+ requests: requests.inflight_count(),
70
+ audit_writes: audit.inflight_count(),
71
+ upkeep: upkeep_pending
72
+ };
73
+ if (!shutdown_gave_up(given_up))
74
+ return given_up;
75
+ log.error(`create_app_server: shutdown gave up after ${timeout_ms}ms on work still running — ${given_up.requests} request(s) (handler, effect flush, or WS open), ${given_up.audit_writes} audit row write(s), ${given_up.upkeep} upkeep task(s)`);
76
+ return given_up;
77
+ };